forked from Mirrorlandia_minetest/minetest
GUI: Make singleplayer default tab, store selected serverlist, show title of serverlist
This commit is contained in:
parent
6cf581e360
commit
e17ae475cf
@ -157,6 +157,7 @@ enum
|
|||||||
GUI_ID_SERVERLIST,
|
GUI_ID_SERVERLIST,
|
||||||
GUI_ID_SERVERLIST_TOGGLE,
|
GUI_ID_SERVERLIST_TOGGLE,
|
||||||
GUI_ID_SERVERLIST_DELETE,
|
GUI_ID_SERVERLIST_DELETE,
|
||||||
|
GUI_ID_SERVERLIST_TITLE,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -427,16 +428,37 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
|
|||||||
changeCtype("");
|
changeCtype("");
|
||||||
// Server List
|
// Server List
|
||||||
{
|
{
|
||||||
core::rect<s32> rect(0, 0, 390, 160);
|
core::rect<s32> rect(0, 0, 390, 140);
|
||||||
rect += m_topleft_client + v2s32(50, 10);
|
rect += m_topleft_client + v2s32(50, 30);
|
||||||
gui::IGUIListBox *e = Environment->addListBox(rect, this,
|
gui::IGUIListBox *e = Environment->addListBox(rect, this,
|
||||||
GUI_ID_SERVERLIST);
|
GUI_ID_SERVERLIST);
|
||||||
e->setDrawBackground(true);
|
e->setDrawBackground(true);
|
||||||
if (m_data->serverlist_show_available == false)
|
|
||||||
m_data->servers = ServerList::getLocal();
|
|
||||||
#if USE_CURL
|
#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();
|
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
|
#endif
|
||||||
updateGuiServerList();
|
updateGuiServerList();
|
||||||
e->setSelected(0);
|
e->setSelected(0);
|
||||||
@ -474,7 +496,7 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
|
|||||||
gui::IGUIButton *e = Environment->addButton(rect, this, GUI_ID_SERVERLIST_TOGGLE,
|
gui::IGUIButton *e = Environment->addButton(rect, this, GUI_ID_SERVERLIST_TOGGLE,
|
||||||
wgettext("Show Public"));
|
wgettext("Show Public"));
|
||||||
e->setIsPushButton(true);
|
e->setIsPushButton(true);
|
||||||
if (m_data->serverlist_show_available)
|
if (m_data->selected_serverlist == SERVERLIST_PUBLIC)
|
||||||
{
|
{
|
||||||
e->setText(wgettext("Show Favorites"));
|
e->setText(wgettext("Show Favorites"));
|
||||||
e->setPressed();
|
e->setPressed();
|
||||||
@ -487,7 +509,7 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
|
|||||||
rect += m_topleft_client + v2s32(50+260+10, 180);
|
rect += m_topleft_client + v2s32(50+260+10, 180);
|
||||||
gui::IGUIButton *e = Environment->addButton(rect, this, GUI_ID_SERVERLIST_DELETE,
|
gui::IGUIButton *e = Environment->addButton(rect, this, GUI_ID_SERVERLIST_DELETE,
|
||||||
wgettext("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);
|
e->setVisible(false);
|
||||||
}
|
}
|
||||||
// Start game button
|
// Start game button
|
||||||
@ -1154,25 +1176,28 @@ bool GUIMainMenu::OnEvent(const SEvent& event)
|
|||||||
gui::IGUIElement *togglebutton = getElementFromId(GUI_ID_SERVERLIST_TOGGLE);
|
gui::IGUIElement *togglebutton = getElementFromId(GUI_ID_SERVERLIST_TOGGLE);
|
||||||
gui::IGUIElement *deletebutton = getElementFromId(GUI_ID_SERVERLIST_DELETE);
|
gui::IGUIElement *deletebutton = getElementFromId(GUI_ID_SERVERLIST_DELETE);
|
||||||
gui::IGUIListBox *serverlist = (gui::IGUIListBox*)getElementFromId(GUI_ID_SERVERLIST);
|
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();
|
m_data->servers = ServerList::getLocal();
|
||||||
togglebutton->setText(wgettext("Show Public"));
|
togglebutton->setText(wgettext("Show Public"));
|
||||||
|
title->setText(wgettext("Favorites:"));
|
||||||
deletebutton->setVisible(true);
|
deletebutton->setVisible(true);
|
||||||
updateGuiServerList();
|
updateGuiServerList();
|
||||||
serverlist->setSelected(0);
|
serverlist->setSelected(0);
|
||||||
|
m_data->selected_serverlist = SERVERLIST_FAVORITES;
|
||||||
}
|
}
|
||||||
else // switch to online list
|
else // switch to online list
|
||||||
{
|
{
|
||||||
m_data->servers = ServerList::getOnline();
|
m_data->servers = ServerList::getOnline();
|
||||||
togglebutton->setText(wgettext("Show Favorites"));
|
togglebutton->setText(wgettext("Show Favorites"));
|
||||||
|
title->setText(wgettext("Public Server List:"));
|
||||||
deletebutton->setVisible(false);
|
deletebutton->setVisible(false);
|
||||||
updateGuiServerList();
|
updateGuiServerList();
|
||||||
serverlist->setSelected(0);
|
serverlist->setSelected(0);
|
||||||
|
m_data->selected_serverlist = SERVERLIST_PUBLIC;
|
||||||
}
|
}
|
||||||
serverListOnSelected();
|
serverListOnSelected();
|
||||||
|
|
||||||
m_data->serverlist_show_available = !m_data->serverlist_show_available;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
|
|
||||||
class IGameCallback;
|
class IGameCallback;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
SERVERLIST_FAVORITES,
|
||||||
|
SERVERLIST_PUBLIC,
|
||||||
|
};
|
||||||
|
|
||||||
struct MainMenuData
|
struct MainMenuData
|
||||||
{
|
{
|
||||||
// These are in the native format of the gui elements
|
// These are in the native format of the gui elements
|
||||||
@ -64,7 +69,7 @@ struct MainMenuData
|
|||||||
std::string create_world_gameid;
|
std::string create_world_gameid;
|
||||||
bool only_refresh;
|
bool only_refresh;
|
||||||
|
|
||||||
bool serverlist_show_available; // if false show local favorites only
|
int selected_serverlist;
|
||||||
|
|
||||||
std::vector<WorldSpec> worlds;
|
std::vector<WorldSpec> worlds;
|
||||||
std::vector<SubgameSpec> games;
|
std::vector<SubgameSpec> games;
|
||||||
@ -72,13 +77,7 @@ struct MainMenuData
|
|||||||
|
|
||||||
MainMenuData():
|
MainMenuData():
|
||||||
// Generic
|
// Generic
|
||||||
selected_tab(
|
selected_tab(0),
|
||||||
#if USE_CURL
|
|
||||||
1
|
|
||||||
#else
|
|
||||||
0
|
|
||||||
#endif
|
|
||||||
),
|
|
||||||
// Client opts
|
// Client opts
|
||||||
fancy_trees(false),
|
fancy_trees(false),
|
||||||
smooth_lighting(false),
|
smooth_lighting(false),
|
||||||
@ -91,13 +90,7 @@ struct MainMenuData
|
|||||||
// Actions
|
// Actions
|
||||||
only_refresh(false),
|
only_refresh(false),
|
||||||
|
|
||||||
serverlist_show_available(
|
selected_serverlist(SERVERLIST_FAVORITES)
|
||||||
#if USE_CURL
|
|
||||||
true
|
|
||||||
#else
|
|
||||||
false
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1556,6 +1556,8 @@ int main(int argc, char *argv[])
|
|||||||
MainMenuData menudata;
|
MainMenuData menudata;
|
||||||
if(g_settings->exists("selected_mainmenu_tab"))
|
if(g_settings->exists("selected_mainmenu_tab"))
|
||||||
menudata.selected_tab = g_settings->getS32("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.address = narrow_to_wide(address);
|
||||||
menudata.name = narrow_to_wide(playername);
|
menudata.name = narrow_to_wide(playername);
|
||||||
menudata.port = narrow_to_wide(itos(port));
|
menudata.port = narrow_to_wide(itos(port));
|
||||||
@ -1752,6 +1754,7 @@ int main(int argc, char *argv[])
|
|||||||
simple_singleplayer_mode = menudata.simple_singleplayer_mode;
|
simple_singleplayer_mode = menudata.simple_singleplayer_mode;
|
||||||
// Save settings
|
// Save settings
|
||||||
g_settings->setS32("selected_mainmenu_tab", menudata.selected_tab);
|
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("new_style_leaves", itos(menudata.fancy_trees));
|
||||||
g_settings->set("smooth_lighting", itos(menudata.smooth_lighting));
|
g_settings->set("smooth_lighting", itos(menudata.smooth_lighting));
|
||||||
g_settings->set("enable_3d_clouds", itos(menudata.clouds_3d));
|
g_settings->set("enable_3d_clouds", itos(menudata.clouds_3d));
|
||||||
|
Loading…
Reference in New Issue
Block a user