add mapgen types to gui
This commit is contained in:
parent
2d94936df5
commit
6edf399e66
|
@ -105,6 +105,7 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
|
|||
bool clear_map;
|
||||
bool use_fixed_seed;
|
||||
std::wstring fixed_seed;
|
||||
std::string map_type;
|
||||
|
||||
m_screensize = screensize;
|
||||
|
||||
|
@ -333,6 +334,39 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
|
|||
else
|
||||
fixed_seed = m_data->fixed_seed;
|
||||
}
|
||||
{
|
||||
gui::IGUIElement *e = getElementFromId(GUI_ID_MAP_TYPE_COMBO);
|
||||
if (e != NULL && e->getType() == gui::EGUIET_COMBO_BOX) {
|
||||
gui::IGUIComboBox *c = (gui::IGUIComboBox*)e;
|
||||
switch (c->getItemData(c->getSelected())) {
|
||||
case GUI_ID_MAP_TYPE_FLAT:
|
||||
map_type = "flat";
|
||||
break;
|
||||
case GUI_ID_MAP_TYPE_FLATTER:
|
||||
map_type = "flatter";
|
||||
break;
|
||||
case GUI_ID_MAP_TYPE_SMOOTHER:
|
||||
map_type = "smoother";
|
||||
break;
|
||||
case GUI_ID_MAP_TYPE_HILLY:
|
||||
map_type = "hilly";
|
||||
break;
|
||||
case GUI_ID_MAP_TYPE_MOUNTAINS:
|
||||
map_type = "mountains";
|
||||
break;
|
||||
case GUI_ID_MAP_TYPE_CRAZY:
|
||||
map_type = "crazy";
|
||||
break;
|
||||
case GUI_ID_MAP_TYPE_CRAZYHILLS:
|
||||
map_type = "crazyhills";
|
||||
break;
|
||||
default:
|
||||
map_type = "default";
|
||||
}
|
||||
}else{
|
||||
map_type = m_data->map_type;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Remove stuff
|
||||
|
@ -748,22 +782,58 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
|
|||
Environment->addStaticText(wgettext("Warning! Your old map will be deleted!"),
|
||||
rect, false, true, this, -1);
|
||||
}
|
||||
{
|
||||
core::rect<s32> rect(0, 0, 110, 20);
|
||||
rect += topleft_content + v2s32(40, 195);
|
||||
Environment->addStaticText(wgettext("Map Type"),
|
||||
rect, false, true, this, -1);
|
||||
}
|
||||
{
|
||||
core::rect<s32> rect(0, 0, 240, 30);
|
||||
rect += topleft_content + v2s32(120, 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);
|
||||
u32 m3 = c->addItem(wgettext("Smoother"),GUI_ID_MAP_TYPE_SMOOTHER);
|
||||
u32 m4 = c->addItem(wgettext("Default"),GUI_ID_MAP_TYPE_DEFAULT);
|
||||
u32 m5 = c->addItem(wgettext("Hilly"),GUI_ID_MAP_TYPE_HILLY);
|
||||
u32 m6 = c->addItem(wgettext("Mountains"),GUI_ID_MAP_TYPE_MOUNTAINS);
|
||||
u32 m7 = c->addItem(wgettext("Crazy"),GUI_ID_MAP_TYPE_CRAZY);
|
||||
u32 m8 = c->addItem(wgettext("Crazy Hills"),GUI_ID_MAP_TYPE_CRAZYHILLS);
|
||||
if (map_type == "flat") {
|
||||
c->setSelected(m1);
|
||||
}else if (map_type == "flatter") {
|
||||
c->setSelected(m2);
|
||||
}else if (map_type == "smoother") {
|
||||
c->setSelected(m3);
|
||||
}else if (map_type == "hilly") {
|
||||
c->setSelected(m5);
|
||||
}else if (map_type == "mountains") {
|
||||
c->setSelected(m6);
|
||||
}else if (map_type == "crazy") {
|
||||
c->setSelected(m7);
|
||||
}else if (map_type == "crazyhills") {
|
||||
c->setSelected(m8);
|
||||
}else{
|
||||
c->setSelected(m4);
|
||||
}
|
||||
}
|
||||
{
|
||||
core::rect<s32> rect(0, 0, 200, 30);
|
||||
rect += topleft_content + v2s32(70, 190);
|
||||
rect += topleft_content + v2s32(70, 230);
|
||||
Environment->addCheckBox(use_fixed_seed, rect, this, GUI_ID_MAP_SEED_CB, wgettext("Use Fixed Seed"));
|
||||
}
|
||||
if (use_fixed_seed) {
|
||||
{
|
||||
core::rect<s32> rect(0, 0, 110, 20);
|
||||
rect += topleft_content + v2s32(70, 225);
|
||||
rect += topleft_content + v2s32(70, 265);
|
||||
Environment->addStaticText(wgettext("Map Seed"),
|
||||
rect, false, true, this, -1);
|
||||
}
|
||||
changeCtype("C");
|
||||
{
|
||||
core::rect<s32> rect(0, 0, 190, 30);
|
||||
rect += topleft_content + v2s32(140, 220);
|
||||
rect += topleft_content + v2s32(140, 260);
|
||||
Environment->addEditBox(fixed_seed.c_str(), rect, false, this, GUI_ID_MAP_SEED_INPUT);
|
||||
}
|
||||
changeCtype("");
|
||||
|
@ -784,7 +854,7 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
|
|||
// Start game button
|
||||
{
|
||||
core::rect<s32> rect(0, 0, 180, 30);
|
||||
rect += topleft_content + v2s32(110, 280);
|
||||
rect += topleft_content + v2s32(110, 310);
|
||||
Environment->addButton(rect, this, GUI_ID_JOIN_GAME_BUTTON, wgettext("Start Game"));
|
||||
}
|
||||
}else if(m_data->selected_tab == TAB_CREDITS) {
|
||||
|
@ -1121,6 +1191,37 @@ void GUIMainMenu::acceptInput()
|
|||
if(e != NULL)
|
||||
m_data->fixed_seed = e->getText();
|
||||
}
|
||||
{
|
||||
gui::IGUIElement *e = getElementFromId(GUI_ID_MAP_TYPE_COMBO);
|
||||
if (e != NULL && e->getType() == gui::EGUIET_COMBO_BOX) {
|
||||
gui::IGUIComboBox *c = (gui::IGUIComboBox*)e;
|
||||
switch (c->getItemData(c->getSelected())) {
|
||||
case GUI_ID_MAP_TYPE_FLAT:
|
||||
m_data->map_type = "flat";
|
||||
break;
|
||||
case GUI_ID_MAP_TYPE_FLATTER:
|
||||
m_data->map_type = "flatter";
|
||||
break;
|
||||
case GUI_ID_MAP_TYPE_SMOOTHER:
|
||||
m_data->map_type = "smoother";
|
||||
break;
|
||||
case GUI_ID_MAP_TYPE_HILLY:
|
||||
m_data->map_type = "hilly";
|
||||
break;
|
||||
case GUI_ID_MAP_TYPE_MOUNTAINS:
|
||||
m_data->map_type = "mountains";
|
||||
break;
|
||||
case GUI_ID_MAP_TYPE_CRAZY:
|
||||
m_data->map_type = "crazy";
|
||||
break;
|
||||
case GUI_ID_MAP_TYPE_CRAZYHILLS:
|
||||
m_data->map_type = "crazyhills";
|
||||
break;
|
||||
default:
|
||||
m_data->map_type = "default";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_accepted = true;
|
||||
}
|
||||
|
|
|
@ -66,6 +66,15 @@ enum {
|
|||
GUI_ID_MAP_CLEAR_CB,
|
||||
GUI_ID_MAP_SEED_CB,
|
||||
GUI_ID_MAP_SEED_INPUT,
|
||||
GUI_ID_MAP_TYPE_COMBO,
|
||||
GUI_ID_MAP_TYPE_FLAT,
|
||||
GUI_ID_MAP_TYPE_FLATTER,
|
||||
GUI_ID_MAP_TYPE_SMOOTHER,
|
||||
GUI_ID_MAP_TYPE_DEFAULT,
|
||||
GUI_ID_MAP_TYPE_HILLY,
|
||||
GUI_ID_MAP_TYPE_MOUNTAINS,
|
||||
GUI_ID_MAP_TYPE_CRAZY,
|
||||
GUI_ID_MAP_TYPE_CRAZYHILLS,
|
||||
GUI_ID_TAB_SINGLEPLAYER,
|
||||
GUI_ID_TAB_MULTIPLAYER,
|
||||
GUI_ID_TAB_SETTINGS,
|
||||
|
@ -106,7 +115,8 @@ struct MainMenuData
|
|||
delete_map(false),
|
||||
clear_map(false),
|
||||
use_fixed_seed(false),
|
||||
fixed_seed(L"")
|
||||
fixed_seed(L""),
|
||||
map_type("default")
|
||||
{}
|
||||
|
||||
// These are in the native format of the gui elements
|
||||
|
@ -144,6 +154,7 @@ struct MainMenuData
|
|||
bool clear_map;
|
||||
bool use_fixed_seed;
|
||||
std::wstring fixed_seed;
|
||||
std:: string map_type;
|
||||
};
|
||||
|
||||
class GUIMainMenu : public GUIModalMenu
|
||||
|
|
|
@ -1215,6 +1215,8 @@ int main(int argc, char *argv[])
|
|||
if (menudata.fixed_seed != L"")
|
||||
menudata.use_fixed_seed = true;
|
||||
}
|
||||
if (g_settings->exists("mapgen_type"))
|
||||
menudata.map_type = g_settings->get("mapgen_type");
|
||||
|
||||
GUIMainMenu *menu =
|
||||
new GUIMainMenu(guienv, guiroot, -1,
|
||||
|
@ -1273,6 +1275,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
if (menudata.use_fixed_seed)
|
||||
g_settings->set("fixed_map_seed",wide_to_narrow(menudata.fixed_seed));
|
||||
g_settings->set("mapgen_type",menudata.map_type);
|
||||
}else if (menudata.clear_map) {
|
||||
std::string map_file = map_dir+DIR_DELIM+"map.sqlite";
|
||||
bool r = fs::RecursiveDelete(map_file);
|
||||
|
|
|
@ -198,6 +198,16 @@
|
|||
#strict_protocol_version_checking = false
|
||||
# A chosen map seed for a new map, leave empty for random
|
||||
#fixed_map_seed =
|
||||
# The type of map to create:
|
||||
# flat - a completely flat map, with some caves cut in
|
||||
# flatter - not as hilly as default
|
||||
# smoother - less crazy terrain than default
|
||||
# default - the original
|
||||
# hilly - generally higher terrain
|
||||
# mountains - big hills and deep oceans
|
||||
# crazy - exaggerated crazy terrain
|
||||
# crazyhills - a mix of 'crazy' and 'mountains'
|
||||
#mapgen_type = default
|
||||
# New users need to input this password
|
||||
#default_password =
|
||||
# Don't let players join with an empty password
|
||||
|
|
Loading…
Reference in New Issue