From d82e8db4c29958a066d75c03b4a38de36c431d80 Mon Sep 17 00:00:00 2001 From: darkrose Date: Mon, 27 Oct 2014 03:33:09 +1000 Subject: [PATCH] widen main menu so longer translations fit --- src/guiMainMenu.cpp | 188 +++++++++++++++++++++++--------------------- src/guiMainMenu.h | 6 +- src/main.cpp | 147 ++++++++++++++++------------------ 3 files changed, 168 insertions(+), 173 deletions(-) diff --git a/src/guiMainMenu.cpp b/src/guiMainMenu.cpp index 02ba0e6..c47fa94 100644 --- a/src/guiMainMenu.cpp +++ b/src/guiMainMenu.cpp @@ -377,7 +377,7 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) Calculate new sizes and positions */ - v2s32 size(600, 500); + v2s32 size(800, 500); core::rect rect( screensize.X/2 - size.X/2, @@ -389,38 +389,44 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) DesiredRect = rect; recalculateAbsolutePosition(false); + // Character Creator button + { + core::rect rect(0, 0, 200, 40); + rect += v2s32(25, 200); + Environment->addButton(rect, this, GUI_ID_CHARACTER_CREATOR, wgettext("Character Creator")); + } // Single Player button { - core::rect rect(0, 0, 150, 30); - rect += v2s32(25, 200); + core::rect rect(0, 0, 200, 40); + rect += v2s32(25, 260); Environment->addButton(rect, this, GUI_ID_TAB_SINGLEPLAYER, wgettext("Single Player")); } // Multi Player button { - core::rect rect(0, 0, 150, 30); - rect += v2s32(25, 240); + core::rect rect(0, 0, 200, 40); + rect += v2s32(25, 305); Environment->addButton(rect, this, GUI_ID_TAB_MULTIPLAYER, wgettext("Multi Player")); } // Settings button { - core::rect rect(0, 0, 130, 30); - rect += v2s32(35, 280); + core::rect rect(0, 0, 180, 40); + rect += v2s32(35, 350); Environment->addButton(rect, this, GUI_ID_TAB_SETTINGS, wgettext("Settings")); } // Credits button { - core::rect rect(0, 0, 130, 30); - rect += v2s32(35, 320); + core::rect rect(0, 0, 180, 40); + rect += v2s32(35, 395); Environment->addButton(rect, this, GUI_ID_TAB_CREDITS, wgettext("Credits")); } // Quit button { - core::rect rect(0, 0, 130, 30); - rect += v2s32(35, 360); + core::rect rect(0, 0, 180, 40); + rect += v2s32(35, 440); Environment->addButton(rect, this, GUI_ID_TAB_QUIT, wgettext("Quit")); } - v2s32 topleft_content(200, 0); + v2s32 topleft_content(250, 0); v2s32 size_content = size - v2s32(300, 0); //v2s32 size = rect.getSize(); @@ -450,7 +456,7 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) if (m_data->selected_tab == TAB_MULTIPLAYER) { changeCtype(""); { - core::rect rect(0, 0, 400, 20); + core::rect rect(0, 0, 550, 20); rect += topleft_content + v2s32(0, 20); gui::IGUIStaticText *t = Environment->addStaticText(wgettext("Multi Player"), rect, false, true, this, -1); t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); @@ -459,25 +465,25 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) // Nickname + password { core::rect rect(0, 0, 110, 20); - rect += topleft_content + v2s32(70, 60); + rect += topleft_content + v2s32(120, 60); Environment->addStaticText(wgettext("Name/Password"), rect, false, true, this, -1); } changeCtype("C"); { core::rect rect(0, 0, 230, 30); - rect += topleft_content + v2s32(85, 90); + rect += topleft_content + v2s32(135, 90); gui::IGUIElement *e = Environment->addEditBox(text_name.c_str(), rect, false, this, GUI_ID_NAME_INPUT); - if(text_name == L"") + if (text_name == L"") Environment->setFocus(e); } { core::rect rect(0, 0, 230, 30); - rect += topleft_content + v2s32(85, 125); + rect += topleft_content + v2s32(135, 125); gui::IGUIEditBox *e = Environment->addEditBox(L"", rect, false, this, 264); e->setPasswordBox(true); - if(text_name != L"" && text_address != L"") + if (text_name != L"" && text_address != L"") Environment->setFocus(e); } @@ -485,100 +491,99 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) // Address + port { core::rect rect(0, 0, 110, 20); - rect += topleft_content + v2s32(70, 170); - Environment->addStaticText(wgettext("Address/Port"), - rect, false, true, this, -1); + rect += topleft_content + v2s32(120, 170); + Environment->addStaticText(wgettext("Address/Port"), rect, false, true, this, -1); } changeCtype("C"); { core::rect rect(0, 0, 230, 30); - rect += topleft_content + v2s32(85, 200); + rect += topleft_content + v2s32(135, 200); gui::IGUIElement *e = Environment->addEditBox(text_address.c_str(), rect, false, this, GUI_ID_ADDRESS_INPUT); - if(text_name != L"" && text_address == L"") + if (text_name != L"" && text_address == L"") Environment->setFocus(e); } { core::rect rect(0, 0, 120, 30); - rect += topleft_content + v2s32(195, 240); + rect += topleft_content + v2s32(245, 240); Environment->addEditBox(text_port.c_str(), rect, false, this, GUI_ID_PORT_INPUT); } changeCtype(""); // Start game button { core::rect rect(0, 0, 180, 30); - rect += topleft_content + v2s32(110, 290); + rect += topleft_content + v2s32(160, 290); Environment->addButton(rect, this, GUI_ID_JOIN_GAME_BUTTON, wgettext("Connect")); } }else if (m_data->selected_tab == TAB_SETTINGS) { changeCtype(""); { - core::rect rect(0, 0, 400, 20); + core::rect rect(0, 0, 550, 20); rect += topleft_content + v2s32(0, 20); gui::IGUIStaticText *t = Environment->addStaticText(wgettext("Settings"), rect, false, true, this, -1); t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect rect(0, 0, 200, 30); - rect += topleft_content + v2s32(40, 60); + rect += topleft_content + v2s32(80, 60); Environment->addCheckBox(fancy_trees, rect, this, GUI_ID_FANCYTREE_CB, wgettext("Fancy trees")); } { core::rect rect(0, 0, 200, 30); - rect += topleft_content + v2s32(40, 90); + rect += topleft_content + v2s32(80, 90); Environment->addCheckBox(smooth_lighting, rect, this, GUI_ID_SMOOTH_LIGHTING_CB, wgettext("Smooth Lighting")); } { core::rect rect(0, 0, 200, 30); - rect += topleft_content + v2s32(40, 120); + rect += topleft_content + v2s32(80, 120); Environment->addCheckBox(clouds_3d, rect, this, GUI_ID_3D_CLOUDS_CB, wgettext("3D Clouds")); } { core::rect rect(0, 0, 200, 30); - rect += topleft_content + v2s32(40, 150); + rect += topleft_content + v2s32(80, 150); Environment->addCheckBox(opaque_water, rect, this, GUI_ID_OPAQUE_WATER_CB, wgettext("Opaque water")); } { core::rect rect(0, 0, 200, 30); - rect += topleft_content + v2s32(200, 60); + rect += topleft_content + v2s32(290, 60); Environment->addCheckBox(fullscreen, rect, this, GUI_ID_FULLSCREEN_CB, wgettext("Fullscreen")); } { core::rect rect(0, 0, 200, 30); - rect += topleft_content + v2s32(200, 90); + rect += topleft_content + v2s32(290, 90); Environment->addCheckBox(particles, rect, this, GUI_ID_PARTICLES_CB, wgettext("Particles")); } { core::rect rect(0, 0, 200, 30); - rect += topleft_content + v2s32(200, 120); + rect += topleft_content + v2s32(290, 120); Environment->addCheckBox(mipmap, rect, this, GUI_ID_MIPMAP_CB, wgettext("Mip-Mapping")); } { core::rect rect(0, 0, 200, 30); - rect += topleft_content + v2s32(200, 150); + rect += topleft_content + v2s32(290, 150); Environment->addCheckBox(bilinear, rect, this, GUI_ID_BILINEAR_CB, wgettext("Bi-Linear Filtering")); } { core::rect rect(0, 0, 200, 30); - rect += topleft_content + v2s32(200, 180); + rect += topleft_content + v2s32(290, 180); Environment->addCheckBox(trilinear, rect, this, GUI_ID_TRILINEAR_CB, wgettext("Tri-Linear Filtering")); } { core::rect rect(0, 0, 200, 30); - rect += topleft_content + v2s32(200, 210); + rect += topleft_content + v2s32(290, 210); Environment->addCheckBox(anisotropic, rect, this, GUI_ID_ANISOTROPIC_CB, wgettext("Anisotropic Filtering")); } // Key change button { core::rect rect(0, 0, 130, 30); - rect += topleft_content + v2s32(140, 280); + rect += topleft_content + v2s32(210, 280); Environment->addButton(rect, this, GUI_ID_CHANGE_KEYS_BUTTON, wgettext("Change keys")); } }else if (m_data->selected_tab == TAB_SINGLEPLAYER) { changeCtype(""); { - core::rect rect(0, 0, 400, 20); + core::rect rect(0, 0, 550, 20); rect += topleft_content + v2s32(0, 20); gui::IGUIStaticText *t = Environment->addStaticText(wgettext("Single Player"), rect, false, true, this, -1); t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); @@ -587,7 +592,7 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) // Server parameters { core::rect rect(0, 0, 200, 30); - rect += topleft_content + v2s32(100, 60); + rect += topleft_content + v2s32(175, 60); gui::IGUIComboBox *c = Environment->addComboBox(rect, this, GUI_ID_GAME_MODE_COMBO); u32 cm = c->addItem(wgettext("Creative Mode"),GUI_ID_GAME_MODE_CREATIVE); u32 am = c->addItem(wgettext("Adventure Mode"),GUI_ID_GAME_MODE_ADVENTURE); @@ -602,26 +607,26 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) } // Advanced settings button { - core::rect rect(0, 0, 130, 30); - rect += topleft_content + v2s32(40, 100); + core::rect rect(0, 0, 170, 30); + rect += topleft_content + v2s32(90, 100); Environment->addButton(rect, this, GUI_ID_GAME_SETTINGS_ADV, wgettext("Advanced Settings")); } // Map options button { - core::rect rect(0, 0, 130, 30); - rect += topleft_content + v2s32(200, 100); + core::rect rect(0, 0, 170, 30); + rect += topleft_content + v2s32(290, 100); Environment->addButton(rect, this, GUI_ID_MAP_OPTIONS_BUTTON, wgettext("Map Options")); } // Start game button { core::rect rect(0, 0, 180, 30); - rect += topleft_content + v2s32(110, 170); + rect += topleft_content + v2s32(185, 170); Environment->addButton(rect, this, GUI_ID_JOIN_GAME_BUTTON, wgettext("Start Game")); } }else if (m_data->selected_tab == TAB_SINGLEPLAYER_ADVANCED) { changeCtype(""); { - core::rect rect(0, 0, 400, 20); + core::rect rect(0, 0, 550, 20); rect += topleft_content + v2s32(0, 20); gui::IGUIStaticText *t = Environment->addStaticText(wgettext("Single Player"), rect, false, true, this, -1); t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); @@ -630,39 +635,40 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) // Server parameters { core::rect rect(0, 0, 200, 30); - rect += topleft_content + v2s32(100, 60); + rect += topleft_content + v2s32(175, 60); gui::IGUIComboBox *c = Environment->addComboBox(rect, this, GUI_ID_GAME_MODE_COMBO); u32 cm = c->addItem(wgettext("Creative Mode"),GUI_ID_GAME_MODE_CREATIVE); u32 am = c->addItem(wgettext("Adventure Mode"),GUI_ID_GAME_MODE_ADVENTURE); u32 sm = c->addItem(wgettext("Survival Mode"),GUI_ID_GAME_MODE_SURVIVAL); if (game_mode == L"creative") { c->setSelected(cm); + }else if (game_mode == L"adventure") { + c->setSelected(am); }else if (game_mode == L"survival") { c->setSelected(sm); - }else{ - c->setSelected(am); } } // Basic settings button { - core::rect rect(0, 0, 150, 30); - rect += topleft_content + v2s32(40, 100); + core::rect rect(0, 0, 170, 30); + rect += topleft_content + v2s32(90, 100); Environment->addButton(rect, this, GUI_ID_GAME_SETTINGS_BASIC, wgettext("Hide Advanced Settings")); } // Map options button { - core::rect rect(0, 0, 130, 30); - rect += topleft_content + v2s32(200, 100); + core::rect rect(0, 0, 170, 30); + rect += topleft_content + v2s32(290, 100); Environment->addButton(rect, this, GUI_ID_MAP_OPTIONS_BUTTON, wgettext("Map Options")); } { - core::rect rect(0, 0, 100, 20); + core::rect rect(0, 0, 125, 20); rect += topleft_content + v2s32(40, 160); - Environment->addStaticText(wgettext("Creatures"), rect, false, true, this, -1); + gui::IGUIStaticText *t = Environment->addStaticText(wgettext("Creatures"), rect, false, true, this, -1); + t->setTextAlignment(gui::EGUIA_LOWERRIGHT, gui::EGUIA_UPPERLEFT); } { core::rect rect(0, 0, 240, 30); - rect += topleft_content + v2s32(120, 155); + rect += topleft_content + v2s32(170, 155); gui::IGUIComboBox *c = Environment->addComboBox(rect, this, GUI_ID_MOBS_COMBO); u32 pm = c->addItem(wgettext("Passive"),GUI_ID_MOBS_PASSIVE); u32 am = c->addItem(wgettext("Passive & Aggressive"),GUI_ID_MOBS_AGGRESSIVE); @@ -677,49 +683,49 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) } { core::rect rect(0, 0, 200, 30); - rect += topleft_content + v2s32(40, 200); + rect += topleft_content + v2s32(70, 200); Environment->addCheckBox(enable_damage, rect, this, GUI_ID_DAMAGE_CB, wgettext("Player Damage")); } { core::rect rect(0, 0, 200, 30); - rect += topleft_content + v2s32(50, 230); + rect += topleft_content + v2s32(80, 230); Environment->addCheckBox(suffocation, rect, this, GUI_ID_SUFFOCATE_CB, wgettext("Suffocation/Drowning")); } { core::rect rect(0, 0, 200, 30); - rect += topleft_content + v2s32(50, 260); + rect += topleft_content + v2s32(80, 260); Environment->addCheckBox(hunger, rect, this, GUI_ID_HUNGER_CB, wgettext("Hunger")); } { core::rect rect(0, 0, 200, 30); - rect += topleft_content + v2s32(40, 290); + rect += topleft_content + v2s32(70, 290); Environment->addCheckBox(tool_wear, rect, this, GUI_ID_TOOL_WEAR_CB, wgettext("Tool Wear")); } { core::rect rect(0, 0, 200, 30); - rect += topleft_content + v2s32(220, 200); + rect += topleft_content + v2s32(300, 200); Environment->addCheckBox(infinite_inventory, rect, this, GUI_ID_INFINITE_INV_CB, wgettext("Infinite Inventory")); } { core::rect rect(0, 0, 200, 30); - rect += topleft_content + v2s32(230, 230); + rect += topleft_content + v2s32(310, 230); Environment->addCheckBox(initial_inventory, rect, this, GUI_ID_INITIAL_INV_CB, wgettext("Initial Inventory")); } { core::rect rect(0, 0, 200, 30); - rect += topleft_content + v2s32(220, 260); + rect += topleft_content + v2s32(300, 260); Environment->addCheckBox(droppable_inventory, rect, this, GUI_ID_DROPPABLE_INV_CB, wgettext("Droppable Inventory")); } // Start game button { core::rect rect(0, 0, 180, 30); - rect += topleft_content + v2s32(110, 340); + rect += topleft_content + v2s32(185, 340); Environment->addButton(rect, this, GUI_ID_JOIN_GAME_BUTTON, wgettext("Start Game")); } }else if (m_data->selected_tab == TAB_SINGLEPLAYER_MAP) { changeCtype(""); { - core::rect rect(0, 0, 400, 20); + core::rect rect(0, 0, 550, 20); rect += topleft_content + v2s32(0, 20); gui::IGUIStaticText *t = Environment->addStaticText(wgettext("Single Player"), rect, false, true, this, -1); t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); @@ -728,7 +734,7 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) // Server parameters { core::rect rect(0, 0, 200, 30); - rect += topleft_content + v2s32(100, 60); + rect += topleft_content + v2s32(175, 60); gui::IGUIComboBox *c = Environment->addComboBox(rect, this, GUI_ID_GAME_MODE_COMBO); u32 cm = c->addItem(wgettext("Creative Mode"),GUI_ID_GAME_MODE_CREATIVE); u32 am = c->addItem(wgettext("Adventure Mode"),GUI_ID_GAME_MODE_ADVENTURE); @@ -743,37 +749,37 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) } // Advanced settings button { - core::rect rect(0, 0, 150, 30); - rect += topleft_content + v2s32(40, 100); + core::rect rect(0, 0, 170, 30); + rect += topleft_content + v2s32(90, 100); Environment->addButton(rect, this, GUI_ID_GAME_SETTINGS_ADV, wgettext("Advanced Settings")); } // Basic settings button { - core::rect rect(0, 0, 150, 30); - rect += topleft_content + v2s32(200, 100); + core::rect rect(0, 0, 170, 30); + rect += topleft_content + v2s32(290, 100); Environment->addButton(rect, this, GUI_ID_GAME_SETTINGS_BASIC, wgettext("Hide Map Options")); } { core::rect rect(0, 0, 200, 30); - rect += topleft_content + v2s32(100, 130); + rect += topleft_content + v2s32(150, 130); Environment->addCheckBox(delete_map, rect, this, GUI_ID_MAP_DELETE_CB, wgettext("Create New Map")); } if (delete_map) { { core::rect rect(0, 0, 300, 20); - rect += topleft_content + v2s32(70, 160); + rect += topleft_content + v2s32(120, 160); Environment->addStaticText(wgettext("Warning! Your old map will be deleted!"), rect, false, true, this, -1); } { - core::rect rect(0, 0, 110, 20); - rect += topleft_content + v2s32(40, 195); - Environment->addStaticText(wgettext("Map Type"), - rect, false, true, this, -1); + core::rect rect(0, 0, 120, 20); + rect += topleft_content + v2s32(45, 195); + gui::IGUIStaticText *t = Environment->addStaticText(wgettext("Map Type"), rect, false, true, this, -1); + t->setTextAlignment(gui::EGUIA_LOWERRIGHT, gui::EGUIA_UPPERLEFT); } { core::rect rect(0, 0, 240, 30); - rect += topleft_content + v2s32(120, 190); + rect += topleft_content + v2s32(170, 190); gui::IGUIComboBox *c = Environment->addComboBox(rect, this, GUI_ID_MAP_TYPE_COMBO); u32 m1 = c->addItem(wgettext("Flat"),GUI_ID_MAP_TYPE_FLAT); u32 m2 = c->addItem(wgettext("Flatter"),GUI_ID_MAP_TYPE_FLATTER); @@ -803,20 +809,20 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) } { core::rect rect(0, 0, 200, 30); - rect += topleft_content + v2s32(70, 230); + rect += topleft_content + v2s32(150, 230); Environment->addCheckBox(use_fixed_seed, rect, this, GUI_ID_MAP_SEED_CB, wgettext("Use Fixed Seed")); } if (use_fixed_seed) { { - core::rect rect(0, 0, 110, 20); - rect += topleft_content + v2s32(70, 265); - Environment->addStaticText(wgettext("Map Seed"), - rect, false, true, this, -1); + core::rect rect(0, 0, 120, 20); + rect += topleft_content + v2s32(65, 265); + gui::IGUIStaticText *t = Environment->addStaticText(wgettext("Map Seed"), rect, false, true, this, -1); + t->setTextAlignment(gui::EGUIA_LOWERRIGHT, gui::EGUIA_UPPERLEFT); } changeCtype("C"); { core::rect rect(0, 0, 190, 30); - rect += topleft_content + v2s32(140, 260); + rect += topleft_content + v2s32(190, 260); Environment->addEditBox(fixed_seed.c_str(), rect, false, this, GUI_ID_MAP_SEED_INPUT); } changeCtype(""); @@ -824,12 +830,12 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) }else{ { core::rect rect(0, 0, 200, 30); - rect += topleft_content + v2s32(100, 160); + rect += topleft_content + v2s32(150, 160); Environment->addCheckBox(clear_map, rect, this, GUI_ID_MAP_CLEAR_CB, wgettext("Clear Map")); } if (clear_map) { core::rect rect(0, 0, 300, 40); - rect += topleft_content + v2s32(70, 190); + rect += topleft_content + v2s32(120, 190); Environment->addStaticText(wgettext("Warning! This will delete all construction from your map!"), rect, false, true, this, -1); } @@ -837,19 +843,19 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) // Start game button { core::rect rect(0, 0, 180, 30); - rect += topleft_content + v2s32(110, 310); + rect += topleft_content + v2s32(185, 310); Environment->addButton(rect, this, GUI_ID_JOIN_GAME_BUTTON, wgettext("Start Game")); } }else if(m_data->selected_tab == TAB_CREDITS) { // CREDITS { - core::rect rect(0, 0, 400, 20); + core::rect rect(0, 0, 550, 20); rect += topleft_content + v2s32(0, 20); gui::IGUIStaticText *t = Environment->addStaticText(wgettext("Credits"), rect, false, true, this, -1); t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { - core::rect rect(0, 0, 400, 350); + core::rect rect(0, 0, 550, 350); rect += topleft_content + v2s32(0, 50); gui::IGUIStaticText *t = Environment->addStaticText( wgettext( @@ -886,11 +892,11 @@ void GUIMainMenu::drawMenu() core::rect left( AbsoluteRect.UpperLeftCorner.X, AbsoluteRect.UpperLeftCorner.Y, - AbsoluteRect.LowerRightCorner.X-400, + AbsoluteRect.LowerRightCorner.X-550, AbsoluteRect.LowerRightCorner.Y ); core::rect right( - AbsoluteRect.UpperLeftCorner.X+200, + AbsoluteRect.UpperLeftCorner.X+250, AbsoluteRect.UpperLeftCorner.Y, AbsoluteRect.LowerRightCorner.X, AbsoluteRect.LowerRightCorner.Y @@ -901,9 +907,9 @@ void GUIMainMenu::drawMenu() if (texture != 0) { const core::dimension2d& img_origsize = texture->getOriginalSize(); core::rect logo( - AbsoluteRect.UpperLeftCorner.X, + AbsoluteRect.UpperLeftCorner.X+25, AbsoluteRect.UpperLeftCorner.Y, - AbsoluteRect.UpperLeftCorner.X+200, + AbsoluteRect.UpperLeftCorner.X+225, AbsoluteRect.UpperLeftCorner.Y+200 ); const video::SColor color(255,255,255,255); diff --git a/src/guiMainMenu.h b/src/guiMainMenu.h index 56e96d5..113b7cd 100644 --- a/src/guiMainMenu.h +++ b/src/guiMainMenu.h @@ -75,6 +75,7 @@ enum { GUI_ID_MAP_TYPE_MOUNTAINS, GUI_ID_MAP_TYPE_CRAZY, GUI_ID_MAP_TYPE_CRAZYHILLS, + GUI_ID_CHARACTER_CREATOR, GUI_ID_TAB_SINGLEPLAYER, GUI_ID_TAB_MULTIPLAYER, GUI_ID_TAB_SETTINGS, @@ -116,7 +117,8 @@ struct MainMenuData clear_map(false), use_fixed_seed(false), fixed_seed(L""), - map_type("default") + map_type("default"), + character_creator(false) {} // These are in the native format of the gui elements @@ -155,6 +157,8 @@ struct MainMenuData bool use_fixed_seed; std::wstring fixed_seed; std:: string map_type; + // go to character creator, not the game + bool character_creator; }; class GUIMainMenu : public GUIModalMenu diff --git a/src/main.cpp b/src/main.cpp index fd23076..3a5fd3b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -748,28 +748,16 @@ int main(int argc, char *argv[]) bool ret = cmd_args.parseCommandLine(argc, argv, allowed_options); - if(ret == false || cmd_args.getFlag("help")) - { + if (ret == false || cmd_args.getFlag("help")) { dstream<<"Allowed options:"<::Iterator - i = allowed_options.getIterator(); - i.atEnd() == false; i++) - { + for (core::map::Iterator i = allowed_options.getIterator(); i.atEnd() == false; i++) { dstream<<" --"<getKey(); - if(i.getNode()->getValue().type == VALUETYPE_FLAG) - { - } - else - { + if(i.getNode()->getValue().type != VALUETYPE_FLAG) dstream<<" "; - } dstream<getValue().help != NULL) - { - dstream<<" "<getValue().help - <getValue().help != NULL) + dstream<<" "<getValue().help<readConfigFile(cmd_args.get("config").c_str()); - if(r == false) - { + if (r == false) { errorstream<<"Could not read configuration from \"" < filenames; filenames.push_back(porting::path_userdata + DIR_DELIM + "voxelands.conf"); @@ -862,18 +846,16 @@ int main(int argc, char *argv[]) DIR_DELIM + ".." + DIR_DELIM + "voxelands.conf"); #endif - for(u32 i=0; ireadConfigFile(filenames[i].c_str()); - if(r) - { + if (r) { configpath = filenames[i]; break; } } // If no path found, use the first one (menu creates the file) - if(configpath == "") + if (configpath == "") configpath = filenames[0]; } @@ -904,11 +886,11 @@ int main(int argc, char *argv[]) Run unit tests */ - if((ENABLE_TESTS && cmd_args.getFlag("disable-unittests") == false) - || cmd_args.getFlag("enable-unittests") == true) - { + if ( + (ENABLE_TESTS && cmd_args.getFlag("disable-unittests") == false) + || cmd_args.getFlag("enable-unittests") == true + ) run_tests(); - } /*for(s16 y=-100; y<100; y++) for(s16 x=-100; x<100; x++) @@ -923,23 +905,24 @@ int main(int argc, char *argv[]) // Port u16 port = 30000; - if(cmd_args.exists("port")) + if (cmd_args.exists("port")) { port = cmd_args.getU16("port"); - else if(g_settings->exists("port")) + }else if (g_settings->exists("port")) { port = g_settings->getU16("port"); - if(port == 0) + } + if (port == 0) port = 30000; // Map directory std::string map_dir = porting::path_userdata+DIR_DELIM+"world"; - if(cmd_args.exists("map-dir")) + if (cmd_args.exists("map-dir")) { map_dir = cmd_args.get("map-dir"); - else if(g_settings->exists("map-dir")) + }else if (g_settings->exists("map-dir")) { map_dir = g_settings->get("map-dir"); + } // Run dedicated server if asked to - if(cmd_args.getFlag("server")) - { + if (cmd_args.getFlag("server")) { DSTACK("Dedicated server branch"); // Create time getter @@ -963,12 +946,9 @@ int main(int argc, char *argv[]) // Address to connect to std::string address = ""; - if(cmd_args.exists("address")) - { + if (cmd_args.exists("address")) { address = cmd_args.get("address"); - } - else - { + }else{ address = g_settings->get("address"); } @@ -996,20 +976,19 @@ int main(int argc, char *argv[]) std::string driverstring = g_settings->get("video_driver"); - if(driverstring == "null") + if (driverstring == "null") { driverType = video::EDT_NULL; - else if(driverstring == "software") + }else if (driverstring == "software") { driverType = video::EDT_SOFTWARE; - else if(driverstring == "burningsvideo") + }else if (driverstring == "burningsvideo") { driverType = video::EDT_BURNINGSVIDEO; - else if(driverstring == "direct3d8") + }else if (driverstring == "direct3d8") { driverType = video::EDT_DIRECT3D8; - else if(driverstring == "direct3d9") + }else if (driverstring == "direct3d9") { driverType = video::EDT_DIRECT3D9; - else if(driverstring == "opengl") + }else if (driverstring == "opengl") { driverType = video::EDT_OPENGL; - else - { + }else{ errorstream<<"WARNING: Invalid video_driver specified; defaulting " "to opengl"<getBool("random_input") || cmd_args.getFlag("random-input"); InputHandler *input = NULL; - if(random_input) + if (random_input) { input = new RandomInputHandler(); - else + }else{ input = new RealInputHandler(device, &receiver); + } scene::ISceneManager* smgr = device->getSceneManager(); guienv = device->getGUIEnvironment(); gui::IGUISkin* skin = guienv->getSkin(); gui::IGUIFont* font = guienv->getFont(getTexturePath("fontlucida.png").c_str()); - if(font) + if (font) { skin->setFont(font); - else - errorstream<<"WARNING: Font file was not found." - " Using default font."<getFont(); assert(font); @@ -1146,15 +1125,16 @@ int main(int argc, char *argv[]) // The password entered during the menu screen, std::string password; + // if there's no chardef then put the player directly into the character creator + bool character_creator = !g_settings->exists("character_definition"); + /* Menu-game loop */ - while(device->run() && kill == false) - { + while (device->run() && kill == false) { // This is used for catching disconnects - try - { + try{ /* Clear everything from the GUIEnvironment @@ -1166,16 +1146,14 @@ int main(int argc, char *argv[]) custom gui elements directly on the screen. Otherwise they won't be automatically drawn. */ - guiroot = guienv->addStaticText(L"", - core::rect(0, 0, 10000, 10000)); + guiroot = guienv->addStaticText(L"",core::rect(0, 0, 10000, 10000)); /* Out-of-game menu loop. - Loop quits when menu returns proper parameters. + break out immediately if we should be in the character creator */ - while(kill == false) - { + while (kill == false && character_creator == false) { // Cursor can be non-visible when coming from the game device->getCursorControl()->setVisible(true); // Some stuff are left to scene manager when coming from the game @@ -1223,8 +1201,7 @@ int main(int argc, char *argv[]) &g_menumgr, &menudata, g_gamecallback); menu->allowFocusRemoval(true); - if(error_message != L"") - { + if (error_message != L"") { errorstream<<"error_message = " <run() && kill == false) - { - if(menu->getStatus() == true) + while (device->run() && kill == false) { + if (menu->getStatus() == true) break; //driver->beginScene(true, true, video::SColor(255,0,0,0)); @@ -1259,13 +1235,18 @@ int main(int argc, char *argv[]) } // Break out of menu-game loop to shut down cleanly - if(device->run() == false || kill == true) + if (device->run() == false || kill == true) break; infostream<<"Dropping main menu"<drop(); + character_creator = menudata.character_creator; + + if (character_creator) + break; + // Delete map if requested if (menudata.delete_map) { bool r = fs::RecursiveDeleteContent(map_dir); @@ -1293,7 +1274,7 @@ int main(int argc, char *argv[]) address = wide_to_narrow(menudata.address); int newport = mywstoi(menudata.port); - if(newport != 0) + if (newport != 0) port = newport; g_settings->set("new_style_leaves", itos(menudata.fancy_trees)); g_settings->set("smooth_lighting", itos(menudata.smooth_lighting)); @@ -1320,7 +1301,7 @@ int main(int argc, char *argv[]) g_settings->set("address", address); g_settings->set("port", itos(port)); // Update configuration file - if(configpath != "") + if (configpath != "") g_settings->updateConfigFile(configpath.c_str()); // Continue to game @@ -1328,9 +1309,13 @@ int main(int argc, char *argv[]) } // Break out of menu-game loop to shut down cleanly - if(device->run() == false) + if (device->run() == false) break; + if (character_creator) { + character_creator = false; + continue; + } // Initialize mapnode again to enable changed graphics settings init_mapnode(driver);