diff --git a/src/client/gui/screens/StartMenuScreen.cpp b/src/client/gui/screens/StartMenuScreen.cpp index 6670750..b98487d 100755 --- a/src/client/gui/screens/StartMenuScreen.cpp +++ b/src/client/gui/screens/StartMenuScreen.cpp @@ -6,6 +6,7 @@ #include "OptionsScreen.h" #include "PauseScreen.h" #include "PrerenderTilesScreen.h" // test button +#include "../components/ImageButton.h" #include "../../../util/Mth.h" @@ -25,7 +26,8 @@ StartMenuScreen::StartMenuScreen() : bHost( 2, 0, 0, 160, 24, "Start Game"), bJoin( 3, 0, 0, 160, 24, "Join Game"), - bOptions( 4, 0, 0, 78, 22, "Options") + bOptions( 4, 0, 0, 78, 22, "Options"), + bQuit( 5, "") { } @@ -54,10 +56,18 @@ void StartMenuScreen::init() tabButtons.push_back(&bOptions); #endif - #ifdef DEMO_MODE - buttons.push_back(&bBuy); - tabButtons.push_back(&bBuy); - #endif + // add quit button (top right X icon) – match OptionsScreen style + { + ImageDef def; + def.name = "gui/touchgui.png"; + def.width = 34; + def.height = 26; + def.setSrc(IntRectangle(150, 0, (int)def.width, (int)def.height)); + bQuit.setImageDef(def, true); + bQuit.scaleWhenPressed = false; + buttons.push_back(&bQuit); + // don't include in tab navigation + } copyright = "\xffMojang AB";//. Do not distribute!"; @@ -100,8 +110,9 @@ void StartMenuScreen::setupPositions() { bJoin.x = (width - bJoin.width) / 2; bOptions.x = (width - bJoin.width) / 2; - copyrightPosX = width - minecraft->font->width(copyright) - 1; - versionPosX = (width - minecraft->font->width(version)) / 2;// - minecraft->font->width(version) - 2; + // position quit icon at top-right (use image-defined size) + bQuit.x = width - bQuit.width; + bQuit.y = 0; } void StartMenuScreen::tick() { @@ -130,6 +141,10 @@ void StartMenuScreen::buttonClicked(Button* button) { { minecraft->setScreen(new OptionsScreen()); } + if (button == &bQuit) + { + minecraft->quit(); + } } bool StartMenuScreen::isInGameScreen() { return false; } diff --git a/src/client/gui/screens/StartMenuScreen.h b/src/client/gui/screens/StartMenuScreen.h index a14ebd8..dd0ccb3 100755 --- a/src/client/gui/screens/StartMenuScreen.h +++ b/src/client/gui/screens/StartMenuScreen.h @@ -3,6 +3,7 @@ #include "../Screen.h" #include "../components/Button.h" +#include "../components/ImageButton.h" class StartMenuScreen: public Screen { @@ -25,6 +26,7 @@ private: Button bHost; Button bJoin; Button bOptions; + ImageButton bQuit; // X button in top-right corner std::string copyright; int copyrightPosX; diff --git a/src/client/gui/screens/touch/TouchStartMenuScreen.cpp b/src/client/gui/screens/touch/TouchStartMenuScreen.cpp index c5d704e..ccf96b6 100755 --- a/src/client/gui/screens/touch/TouchStartMenuScreen.cpp +++ b/src/client/gui/screens/touch/TouchStartMenuScreen.cpp @@ -30,7 +30,8 @@ namespace Touch { StartMenuScreen::StartMenuScreen() : bHost( 2, "Start Game"), bJoin( 3, "Join Game"), - bOptions( 4, "Options") + bOptions( 4, "Options"), + bQuit( 5, "") { ImageDef def; bJoin.width = 75; @@ -58,8 +59,18 @@ void StartMenuScreen::init() buttons.push_back(&bHost); buttons.push_back(&bJoin); buttons.push_back(&bOptions); - + // add quit icon (same look as options header) + { + ImageDef def; + def.name = "gui/touchgui.png"; + def.width = 34; + def.height = 26; + def.setSrc(IntRectangle(150, 0, (int)def.width, (int)def.height)); + bQuit.setImageDef(def, true); + bQuit.scaleWhenPressed = false; + buttons.push_back(&bQuit); + } tabButtons.push_back(&bHost); tabButtons.push_back(&bJoin); @@ -108,6 +119,10 @@ void StartMenuScreen::setupPositions() { bHost.x = 1*buttonWidth + (int)(2*spacing); bOptions.x = 2*buttonWidth + (int)(3*spacing); + // quit icon top-right (use size assigned in init) + bQuit.x = width - bQuit.width; + bQuit.y = 0; + copyrightPosX = width - minecraft->font->width(copyright) - 1; versionPosX = (width - minecraft->font->width(version)) / 2;// - minecraft->font->width(version) - 2; } @@ -135,6 +150,10 @@ void StartMenuScreen::buttonClicked(::Button* button) { { minecraft->setScreen(new OptionsScreen()); } + if (button == &bQuit) + { + minecraft->quit(); + } } bool StartMenuScreen::isInGameScreen() { return false; } diff --git a/src/client/gui/screens/touch/TouchStartMenuScreen.h b/src/client/gui/screens/touch/TouchStartMenuScreen.h index 82030b4..b9bcb5b 100755 --- a/src/client/gui/screens/touch/TouchStartMenuScreen.h +++ b/src/client/gui/screens/touch/TouchStartMenuScreen.h @@ -3,6 +3,7 @@ #include "../../Screen.h" #include "../../components/LargeImageButton.h" +#include "../../components/ImageButton.h" #include "../../components/TextBox.h" namespace Touch { @@ -27,6 +28,7 @@ private: LargeImageButton bHost; LargeImageButton bJoin; LargeImageButton bOptions; + ImageButton bQuit; // X close icon std::string copyright; int copyrightPosX;