Merge branch 'master' into server

This commit is contained in:
Kayne Ruse
2014-03-07 21:05:09 +11:00
3 changed files with 72 additions and 92 deletions
+69 -92
View File
@@ -51,9 +51,9 @@ EditorScene::EditorScene(ConfigUtility* const arg1):
menuBar.SetImage(&buttonImage); menuBar.SetImage(&buttonImage);
menuBar.SetEntries({ menuBar.SetEntries({
{"File", "New", "Open", "Save", "Save As...", "Close", "Exit"}, {"File", "New", "Open", "Save", "Close"},
{"Edit", "Set Tile", "Load Sheet", "Delete Sheet", "Metadata", "Run Script"}, {"Edit", "Set Tile", "Set Brush", "Script"},
{"Debugging", "Debug On", "Debug Off", "Toggle Debug", "Testificate"} {"Debug", "Debug On", "Debug Off", "Toggle", "Testificate"}
}); });
//debug //debug
@@ -95,7 +95,7 @@ void EditorScene::Render(SDL_Surface* const screen) {
} }
} }
//draw a big bar across the top //draw a big bar across the top (hackish)
buttonImage.SetClipY(0); buttonImage.SetClipY(0);
for (int i = 0; i < screen->w; i += buttonImage.GetClipW()) { for (int i = 0; i < screen->w; i += buttonImage.GetClipW()) {
buttonImage.DrawTo(screen, i, 0); buttonImage.DrawTo(screen, i, 0);
@@ -114,13 +114,15 @@ void EditorScene::Render(SDL_Surface* const screen) {
} }
void EditorScene::DrawToDebugInfo(std::string str, int line) { void EditorScene::DrawToDebugInfo(std::string str, int line) {
//draw the debug info on the right //draw the debug info on the right, with a grey background
font.DrawStringTo( SDL_Rect clip = {
str, Sint16(debugInfo.GetClipW() - str.size() * font.GetCharW()),
debugInfo.GetSurface(), Sint16(font.GetCharH() * line),
debugInfo.GetClipW() - str.size() * font.GetCharW(), Uint16(str.size() * font.GetCharW()),
font.GetCharH() * line Uint16(font.GetCharH())
); };
SDL_FillRect(debugInfo.GetSurface(), &clip, SDL_MapRGB(debugInfo.GetSurface()->format, 64, 64, 64));
font.DrawStringTo(str, debugInfo.GetSurface(), clip.x, clip.y);
} }
//------------------------- //-------------------------
@@ -143,85 +145,7 @@ void EditorScene::MouseButtonDown(SDL_MouseButtonEvent const& button) {
void EditorScene::MouseButtonUp(SDL_MouseButtonEvent const& button) { void EditorScene::MouseButtonUp(SDL_MouseButtonEvent const& button) {
int entry, drop; int entry, drop;
menuBar.MouseButtonUp(button, &entry, &drop); menuBar.MouseButtonUp(button, &entry, &drop);
HandleMenuOption(entry, drop);
//manage input from the menu bar
switch(entry) {
case 0: //File
switch(drop) {
case 0:
//TODO: NEW
break;
case 1:
//TODO: OPEN
break;
case 2:
//TODO: SAVE
break;
case 3:
//TODO: SAVE AS
break;
case 4:
//TODO: CLOSE
break;
case 5: {
//EXIT
SDL_Event e;
e.type = SDL_QUIT;
SDL_PushEvent(&e);
}
break;
}
break;
case 1: //Edit
switch(drop) {
case 0:
//TODO: SET TILE
break;
case 1:
//TODO: LOAD SHEET
break;
case 2:
//TODO: DELETE SHEET
break;
case 3:
//TODO: METADATA
break;
case 4:
//TODO: RUN SCRIPT
break;
}
break;
case 2: //Debug
switch(drop) {
case 0:
debugOpen = true;
break;
case 1:
debugOpen = false;
break;
case 2:
debugOpen = !debugOpen;
break;
case 3:
SetNextScene(SceneList::TESTIFICATESCENE);
break;
}
break;
}
} }
void EditorScene::KeyDown(SDL_KeyboardEvent const& key) { void EditorScene::KeyDown(SDL_KeyboardEvent const& key) {
@@ -229,12 +153,10 @@ void EditorScene::KeyDown(SDL_KeyboardEvent const& key) {
case SDLK_ESCAPE: case SDLK_ESCAPE:
QuitEvent(); QuitEvent();
break; break;
case SDLK_SPACE: case SDLK_SPACE:
camera.x = 0; camera.x = 0;
camera.y = 0; camera.y = 0;
break; break;
case SDLK_TAB: case SDLK_TAB:
debugOpen = !debugOpen; debugOpen = !debugOpen;
break; break;
@@ -244,3 +166,58 @@ void EditorScene::KeyDown(SDL_KeyboardEvent const& key) {
void EditorScene::KeyUp(SDL_KeyboardEvent const& key) { void EditorScene::KeyUp(SDL_KeyboardEvent const& key) {
// //
} }
//-------------------------
//Members
//-------------------------
void EditorScene::HandleMenuOption(int entry, int drop) {
//manage input from the menu bar
switch(entry) {
case 0: //File
switch(drop) {
case 0:
//TODO: NEW
break;
case 1:
//TODO: OPEN
break;
case 2:
//TODO: SAVE
break;
case 3:
//TODO: CLOSE
break;
}
break;
case 1: //Edit
switch(drop) {
case 0:
//TODO: SET TILE
break;
case 1:
//TODO: SET BRUSH
break;
case 2:
//TODO: SCRIPT
break;
}
break;
case 2: //Debug
switch(drop) {
case 0:
debugOpen = true;
break;
case 1:
debugOpen = false;
break;
case 2:
debugOpen = !debugOpen;
break;
case 3:
SetNextScene(SceneList::TESTIFICATESCENE);
break;
}
break;
}
}
+3
View File
@@ -54,6 +54,9 @@ protected:
void KeyDown(SDL_KeyboardEvent const&); void KeyDown(SDL_KeyboardEvent const&);
void KeyUp(SDL_KeyboardEvent const&); void KeyUp(SDL_KeyboardEvent const&);
//members
void HandleMenuOption(int entry, int drop);
//globals //globals
ConfigUtility& config; ConfigUtility& config;
Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 18 KiB