aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/guiMainMenu.cpp45
-rw-r--r--src/guiMainMenu.h23
-rw-r--r--src/main.cpp3
3 files changed, 46 insertions, 25 deletions
diff --git a/src/guiMainMenu.cpp b/src/guiMainMenu.cpp
index 49028fc5b..579e6092d 100644
--- a/src/guiMainMenu.cpp
+++ b/src/guiMainMenu.cpp
@@ -157,6 +157,7 @@ enum
GUI_ID_SERVERLIST,
GUI_ID_SERVERLIST_TOGGLE,
GUI_ID_SERVERLIST_DELETE,
+ GUI_ID_SERVERLIST_TITLE,
};
enum
@@ -427,16 +428,37 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
changeCtype("");
// Server List
{
- core::rect<s32> rect(0, 0, 390, 160);
- rect += m_topleft_client + v2s32(50, 10);
+ core::rect<s32> rect(0, 0, 390, 140);
+ rect += m_topleft_client + v2s32(50, 30);
gui::IGUIListBox *e = Environment->addListBox(rect, this,
GUI_ID_SERVERLIST);
e->setDrawBackground(true);
- if (m_data->serverlist_show_available == false)
- m_data->servers = ServerList::getLocal();
#if USE_CURL
- else
+ if(m_data->selected_serverlist == SERVERLIST_FAVORITES) {
+ m_data->servers = ServerList::getLocal();
+ {
+ core::rect<s32> rect(0, 0, 110, 20);
+ rect += m_topleft_client + v2s32(50, 10);
+ Environment->addStaticText(wgettext("Favorites:"),
+ rect, false, true, this, GUI_ID_SERVERLIST_TITLE);
+ }
+ } else {
m_data->servers = ServerList::getOnline();
+ {
+ core::rect<s32> rect(0, 0, 110, 20);
+ rect += m_topleft_client + v2s32(50, 10);
+ Environment->addStaticText(wgettext("Public Server List:"),
+ rect, false, true, this, GUI_ID_SERVERLIST_TITLE);
+ }
+ }
+#else
+ m_data->servers = ServerList::getLocal();
+ {
+ core::rect<s32> rect(0, 0, 110, 20);
+ rect += m_topleft_client + v2s32(50, 10);
+ Environment->addStaticText(wgettext("Favorites:"),
+ rect, false, true, this, GUI_ID_SERVERLIST_TITLE);
+ }
#endif
updateGuiServerList();
e->setSelected(0);
@@ -474,7 +496,7 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
gui::IGUIButton *e = Environment->addButton(rect, this, GUI_ID_SERVERLIST_TOGGLE,
wgettext("Show Public"));
e->setIsPushButton(true);
- if (m_data->serverlist_show_available)
+ if (m_data->selected_serverlist == SERVERLIST_PUBLIC)
{
e->setText(wgettext("Show Favorites"));
e->setPressed();
@@ -487,7 +509,7 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
rect += m_topleft_client + v2s32(50+260+10, 180);
gui::IGUIButton *e = Environment->addButton(rect, this, GUI_ID_SERVERLIST_DELETE,
wgettext("Delete"));
- if (m_data->serverlist_show_available) // Hidden on Show-Online mode
+ if (m_data->selected_serverlist == SERVERLIST_PUBLIC) // Hidden when on public list
e->setVisible(false);
}
// Start game button
@@ -1154,25 +1176,28 @@ bool GUIMainMenu::OnEvent(const SEvent& event)
gui::IGUIElement *togglebutton = getElementFromId(GUI_ID_SERVERLIST_TOGGLE);
gui::IGUIElement *deletebutton = getElementFromId(GUI_ID_SERVERLIST_DELETE);
gui::IGUIListBox *serverlist = (gui::IGUIListBox*)getElementFromId(GUI_ID_SERVERLIST);
- if (m_data->serverlist_show_available) // switch to favorite list
+ gui::IGUIElement *title = getElementFromId(GUI_ID_SERVERLIST_TITLE);
+ if (m_data->selected_serverlist == SERVERLIST_PUBLIC) // switch to favorite list
{
m_data->servers = ServerList::getLocal();
togglebutton->setText(wgettext("Show Public"));
+ title->setText(wgettext("Favorites:"));
deletebutton->setVisible(true);
updateGuiServerList();
serverlist->setSelected(0);
+ m_data->selected_serverlist = SERVERLIST_FAVORITES;
}
else // switch to online list
{
m_data->servers = ServerList::getOnline();
togglebutton->setText(wgettext("Show Favorites"));
+ title->setText(wgettext("Public Server List:"));
deletebutton->setVisible(false);
updateGuiServerList();
serverlist->setSelected(0);
+ m_data->selected_serverlist = SERVERLIST_PUBLIC;
}
serverListOnSelected();
-
- m_data->serverlist_show_available = !m_data->serverlist_show_available;
}
#endif
}
diff --git a/src/guiMainMenu.h b/src/guiMainMenu.h
index fa5f19def..a594ccd41 100644
--- a/src/guiMainMenu.h
+++ b/src/guiMainMenu.h
@@ -29,6 +29,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
class IGameCallback;
+enum {
+ SERVERLIST_FAVORITES,
+ SERVERLIST_PUBLIC,
+};
+
struct MainMenuData
{
// These are in the native format of the gui elements
@@ -64,7 +69,7 @@ struct MainMenuData
std::string create_world_gameid;
bool only_refresh;
- bool serverlist_show_available; // if false show local favorites only
+ int selected_serverlist;
std::vector<WorldSpec> worlds;
std::vector<SubgameSpec> games;
@@ -72,13 +77,7 @@ struct MainMenuData
MainMenuData():
// Generic
- selected_tab(
-#if USE_CURL
- 1
-#else
- 0
-#endif
- ),
+ selected_tab(0),
// Client opts
fancy_trees(false),
smooth_lighting(false),
@@ -91,13 +90,7 @@ struct MainMenuData
// Actions
only_refresh(false),
- serverlist_show_available(
-#if USE_CURL
- true
-#else
- false
-#endif
-)
+ selected_serverlist(SERVERLIST_FAVORITES)
{}
};
diff --git a/src/main.cpp b/src/main.cpp
index 56c125859..2e57a8c20 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1556,6 +1556,8 @@ int main(int argc, char *argv[])
MainMenuData menudata;
if(g_settings->exists("selected_mainmenu_tab"))
menudata.selected_tab = g_settings->getS32("selected_mainmenu_tab");
+ if(g_settings->exists("selected_serverlist"))
+ menudata.selected_serverlist = g_settings->getS32("selected_serverlist");
menudata.address = narrow_to_wide(address);
menudata.name = narrow_to_wide(playername);
menudata.port = narrow_to_wide(itos(port));
@@ -1752,6 +1754,7 @@ int main(int argc, char *argv[])
simple_singleplayer_mode = menudata.simple_singleplayer_mode;
// Save settings
g_settings->setS32("selected_mainmenu_tab", menudata.selected_tab);
+ g_settings->setS32("selected_serverlist", menudata.selected_serverlist);
g_settings->set("new_style_leaves", itos(menudata.fancy_trees));
g_settings->set("smooth_lighting", itos(menudata.smooth_lighting));
g_settings->set("enable_3d_clouds", itos(menudata.clouds_3d));