void GUITextInputMenu::removeChildren() { { gui::IGUIElement *e = getElementFromId(256); if(e != NULL) e->remove(); } { gui::IGUIElement *e = getElementFromId(257); if(e != NULL) e->remove(); } }
void GUIMainMenu::serverListOnSelected() { if (!m_data->servers.empty()) { gui::IGUIListBox *serverlist = (gui::IGUIListBox*)getElementFromId(GUI_ID_SERVERLIST); u16 id = serverlist->getSelected(); //if (id < 0) return; // u16>0! ((gui::IGUIEditBox*)getElementFromId(GUI_ID_ADDRESS_INPUT)) ->setText(narrow_to_wide(m_data->servers[id]["address"].asString()).c_str()); ((gui::IGUIEditBox*)getElementFromId(GUI_ID_PORT_INPUT)) ->setText(narrow_to_wide(m_data->servers[id]["port"].asString()).c_str()); } }
void GUIVolumeChange::removeChildren() { if (gui::IGUIElement *e = getElementFromId(ID_soundText1)) e->remove(); if (gui::IGUIElement *e = getElementFromId(ID_soundText2)) e->remove(); if (gui::IGUIElement *e = getElementFromId(ID_soundExitButton)) e->remove(); if (gui::IGUIElement *e = getElementFromId(ID_soundSlider)) e->remove(); }
bool GUIMultiplayerMenu::acceptInput() { { gui::IGUIElement *e = getElementFromId(GUI_ID_NAME_INPUT); if (e != NULL) m_data.mmdata->name = e->getText(); if (m_data.mmdata->name == L"") m_data.mmdata->name = narrow_to_wide(porting::getUser()); } { gui::IGUIElement *e = getElementFromId(GUI_ID_PW_INPUT); if (e != NULL) m_data.mmdata->password = e->getText(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_ADDRESS_INPUT); if (e != NULL) m_data.mmdata->address = e->getText(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_PORT_INPUT); if (e != NULL) m_data.mmdata->port = e->getText(); } { gui::IGUIListBox *e = (gui::IGUIListBox*)getElementFromId(GUI_ID_SERVER_LIST); if (e != NULL) m_data.selected_row = e->getSelected(); if (m_data.selected_row > -1) { if (m_data.selected_tab == TAB_MP_LIST) { ServerInfo info = m_data.servers.at(m_data.selected_row); if (info.name == L"") m_data.selected_row = -1; WStrfnd sf(info.addr); m_data.mmdata->address = sf.next(L":"); m_data.mmdata->port = sf.end(); }else if (m_data.selected_tab == TAB_MP_FAVOURITES) { ServerInfo info = m_data.favourites.at(m_data.selected_row); if (info.name == L"") m_data.selected_row = -1; WStrfnd sf(info.addr); m_data.mmdata->address = sf.next(L":"); m_data.mmdata->port = sf.end(); }else if (m_data.selected_tab != TAB_MP_CONNECT) { m_data.selected_row = -1; } } } return true; }
int GUIMainMenu::getTab() { gui::IGUIElement *e = getElementFromId(GUI_ID_TAB_CONTROL); if(e != NULL && e->getType() == gui::EGUIET_TAB_CONTROL) return ((gui::IGUITabControl*)e)->getActiveTab(); return TAB_SINGLEPLAYER; // Default }
void GUIConfirmRegistration::acceptInput() { gui::IGUIElement *e; e = getElementFromId(ID_confirmPassword); if (e) m_pass_confirm = e->getText(); }
void GUIFormSpecMenu::acceptInput() { if(m_text_dst) { std::map<std::string, std::string> fields; gui::IGUIElement *e; for(u32 i=0; i<m_fields.size(); i++) { const FieldSpec &s = m_fields[i]; if(s.send) { if(s.is_button) { fields[wide_to_narrow(s.fname.c_str())] = wide_to_narrow(s.flabel.c_str()); } else { e = getElementFromId(s.fid); if(e != NULL) { fields[wide_to_narrow(s.fname.c_str())] = wide_to_narrow(e->getText()); } } } } m_text_dst->gotText(fields); } }
bool GUIVolumeChange::OnEvent(const SEvent& event) { if (event.EventType == EET_KEY_INPUT_EVENT) { if (event.KeyInput.Key == KEY_ESCAPE && event.KeyInput.PressedDown) { quitMenu(); return true; } if (event.KeyInput.Key == KEY_RETURN && event.KeyInput.PressedDown) { quitMenu(); return true; } } if (event.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED) { if (event.GUIEvent.Caller->getID() == ID_soundExitButton) { quitMenu(); return true; } } if (event.GUIEvent.EventType == gui::EGET_SCROLL_BAR_CHANGED) { if (event.GUIEvent.Caller->getID() == ID_soundSlider) { s32 pos = ((gui::IGUIScrollBar*)event.GUIEvent.Caller)->getPos(); g_settings->setFloat("sound_volume", (float)pos/100); gui::IGUIElement *e = getElementFromId(ID_soundText2); e->setText(core::stringw(pos).c_str()); return true; } } return Parent ? Parent->OnEvent(event) : false; }
void GUITextInputMenu::regenerateGui(v2u32 screensize) { std::wstring text; { gui::IGUIElement *e = getElementFromId(256); if(e != NULL) { text = e->getText(); } else { text = m_initial_text; m_initial_text = L""; } } /* Remove stuff */ removeChildren(); /* Calculate new sizes and positions */ core::rect<s32> rect( // screensize.X/2 - 580/2, // screensize.Y/2 - 300/2, // screensize.X/2 + 580/2, // screensize.Y/2 + 300/2 10, screensize.Y - 200, screensize.X - 100, screensize.Y - 58 ); DesiredRect = rect; recalculateAbsolutePosition(false); v2s32 size = rect.getSize(); /* Add stuff */ { core::rect<s32> rect(0, 0, size.X-100-9, 30); rect = rect + v2s32(3, size.Y-8-25); gui::IGUIElement *e = Environment->addEditBox(text.c_str(), rect, true, this, 256); Environment->setFocus(e); } { core::rect<s32> rect(0, 0, 100, 30); rect = rect + v2s32(size.X-100-3, size.Y-8-25); Environment->addButton(rect, this, 257, chartowchar_t(gettext("Proceed"))); } }
bool GUIConfirmRegistration::processInput() { std::wstring m_password_ws = narrow_to_wide(m_password); if (m_password_ws != m_pass_confirm) { gui::IGUIElement *e = getElementFromId(ID_message); if (e) e->setVisible(true); return false; } return true; }
bool GUIKeyChangeMenu::acceptInput() { for(size_t i = 0; i < key_settings.size(); i++) { key_setting *k = key_settings.at(i); g_settings->set(k->setting_name, k->key.sym()); } { gui::IGUIElement *e = getElementFromId(GUI_ID_CB_AUX1_DESCENDS); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) g_settings->setBool("aux1_descends", ((gui::IGUICheckBox*)e)->isChecked()); } { gui::IGUIElement *e = getElementFromId(GUI_ID_CB_DOUBLETAP_JUMP); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) g_settings->setBool("doubletap_jump", ((gui::IGUICheckBox*)e)->isChecked()); } clearKeyCache(); return true; }
void GUIPauseMenu::removeChildren() { { gui::IGUIElement *e = getElementFromId(256); if(e != NULL) e->remove(); } { gui::IGUIElement *e = getElementFromId(257); if(e != NULL) e->remove(); } { gui::IGUIElement *e = getElementFromId(258); if(e != NULL) e->remove(); } { gui::IGUIElement *e = getElementFromId(259); if(e != NULL) e->remove(); } { gui::IGUIElement *e = getElementFromId(260); if(e != NULL) e->remove(); } { gui::IGUIElement *e = getElementFromId(261); if(e != NULL) e->remove(); } }
void GUITextInputMenu::acceptInput() { if(m_dest) { gui::IGUIElement *e = getElementFromId(256); if(e != NULL) { m_dest->gotText(e->getText()); } delete m_dest; m_dest = NULL; } }
bool GUIConfirmRegistration::getAndroidUIInput() { if (!hasAndroidUIInput() || m_jni_field_name != "password") return false; std::string text = porting::getInputDialogValue(); gui::IGUIElement *e = getElementFromId(ID_confirmPassword); if (e) e->setText(utf8_to_wide(text).c_str()); m_jni_field_name.clear(); return false; }
bool GUIPasswordChange::acceptInput() { std::wstring oldpass; std::wstring newpass; gui::IGUIElement *e; e = getElementFromId(ID_oldPassword); if(e != NULL) oldpass = e->getText(); e = getElementFromId(ID_newPassword1); if(e != NULL) newpass = e->getText(); e = getElementFromId(ID_newPassword2); if(e != NULL && newpass != e->getText()) { e = getElementFromId(ID_message); if(e != NULL) e->setVisible(true); return false; } m_client->sendChangePassword(oldpass, newpass); return true; }
bool GUISettingsMenu::resetMenu() { if (activeKey >= 0) { gui::IGUIElement *e = getElementFromId(activeKey); if (e != NULL && e->getType() == gui::EGUIET_BUTTON) { e->setEnabled(true); e->setText(keynames[activeKey-GUI_ID_KEYSETTINGS_BASE]); } activeKey = -1; return false; } return true; }
void GUIPasswordChange::removeChildren() { { gui::IGUIElement *e = getElementFromId(ID_oldPassword); if(e != NULL) e->remove(); } { gui::IGUIElement *e = getElementFromId(ID_newPassword1); if(e != NULL) e->remove(); } { gui::IGUIElement *e = getElementFromId(ID_newPassword2); if(e != NULL) e->remove(); } { gui::IGUIElement *e = getElementFromId(ID_change); if(e != NULL) e->remove(); } }
void GUIVolumeChange::removeChildren() { { gui::IGUIElement *e = getElementFromId(ID_soundText1); if(e != NULL) e->remove(); } { gui::IGUIElement *e = getElementFromId(ID_soundText2); if(e != NULL) e->remove(); } { gui::IGUIElement *e = getElementFromId(ID_soundExitButton); if(e != NULL) e->remove(); } { gui::IGUIElement *e = getElementFromId(ID_soundSlider); if(e != NULL) e->remove(); } }
void GUIMainMenu::readInput(MainMenuData *dst) { dst->simple_singleplayer_mode = true; { gui::IGUIElement *e = getElementFromId(GUI_ID_WORLD_LISTBOX); if(e != NULL && e->getType() == gui::EGUIET_LIST_BOX){ int list_i = ((gui::IGUIListBox*)e)->getSelected(); if(list_i == -1) dst->selected_world = -1; else dst->selected_world = m_world_indices[list_i]; } } }
void GUIMainMenu::acceptInput() { { gui::IGUIElement *e = getElementFromId(GUI_ID_NAME_INPUT); if(e != NULL) m_data->name = e->getText(); } { gui::IGUIElement *e = getElementFromId(264); if(e != NULL) m_data->password = e->getText(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_ADDRESS_INPUT); if(e != NULL) m_data->address = e->getText(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_PORT_INPUT); if(e != NULL) m_data->port = e->getText(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_CREATIVE_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) m_data->creative_mode = ((gui::IGUICheckBox*)e)->isChecked(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_DAMAGE_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) m_data->enable_damage = ((gui::IGUICheckBox*)e)->isChecked(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_SMOOTH_LIGHTING_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) m_data->smooth_lighting = ((gui::IGUICheckBox*)e)->isChecked(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_FANCYTREE_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) m_data->fancy_trees = ((gui::IGUICheckBox*)e)->isChecked(); } m_accepted = true; }
void GUIPauseMenu::removeChildren() { { gui::IGUIElement *e = getElementFromId(256); if(e != NULL) e->remove(); } // { // gui::IGUIElement *e = getElementFromId(257); // if(e != NULL) // e->remove(); // } { gui::IGUIElement *e = getElementFromId(258); if(e != NULL) e->remove(); } { gui::IGUIElement *e = getElementFromId(259); if(e != NULL) e->remove(); } { gui::IGUIElement *e = getElementFromId(260); if(e != NULL) e->remove(); } { gui::IGUIElement *e = getElementFromId(261); if(e != NULL) e->remove(); } { gui::IGUIElement *e = getElementFromId(262); if(e != NULL) e->remove(); } { //文本:ip/port gui::IGUIElement *e = getElementFromId(100); if(e != NULL) e->remove(); } }
void GUIMainMenu::updateGuiServerList() { gui::IGUIListBox *serverlist = (gui::IGUIListBox *)getElementFromId(GUI_ID_SERVERLIST); serverlist->clear(); for(std::vector<ServerListSpec>::iterator i = m_data->servers.begin(); i != m_data->servers.end(); i++) { std::string text; if ((*i)["clients"].asString().size()) text += (*i)["clients"].asString(); if ((*i)["clients_max"].asString().size()) text += "/" + (*i)["clients_max"].asString(); text += " "; if ((*i)["version"].asString().size()) text += (*i)["version"].asString() + " "; if ((*i)["password"].asString().size()) text += "*"; if ((*i)["creative"].asString().size()) text += "C"; if ((*i)["damage"].asString().size()) text += "D"; if ((*i)["pvp"].asString().size()) text += "P"; text += " "; if ((*i)["name"] != "" && (*i)["description"] != "") text += (*i)["name"].asString() + " (" + (*i)["description"].asString() + ")"; else if ((*i)["name"] !="") text += (*i)["name"].asString(); else text += (*i)["address"].asString() + ":" + (*i)["port"].asString(); serverlist->addItem(narrow_to_wide(text).c_str()); } }
bool GUIMainMenu::OnEvent(const SEvent& event) { if(event.EventType==EET_KEY_INPUT_EVENT) { if(event.KeyInput.Key==KEY_ESCAPE && event.KeyInput.PressedDown) { m_gamecallback->exitToOS(); quitMenu(); return true; } if(event.KeyInput.Key==KEY_RETURN && event.KeyInput.PressedDown) { acceptInput(); quitMenu(); return true; } } if(event.EventType==EET_GUI_EVENT) { if(event.GUIEvent.EventType==gui::EGET_ELEMENT_FOCUS_LOST && isVisible()) { if(!canTakeFocus(event.GUIEvent.Element)) { dstream<<"GUIMainMenu: Not allowing focus change." <<std::endl; // Returning true disables focus change return true; } } if(event.GUIEvent.EventType==gui::EGET_TAB_CHANGED) { if(!m_is_regenerating) regenerateGui(m_screensize_old); return true; } if(event.GUIEvent.EventType==gui::EGET_LISTBOX_CHANGED && event.GUIEvent.Caller->getID() == GUI_ID_SERVERLIST) { serverListOnSelected(); return true; } if(event.GUIEvent.EventType==gui::EGET_BUTTON_CLICKED) { switch(event.GUIEvent.Caller->getID()) { case GUI_ID_JOIN_GAME_BUTTON: { MainMenuData cur; readInput(&cur); if (getTab() == TAB_MULTIPLAYER && cur.address == L"") { wchar_t* text = wgettext("Address required."); (new GUIMessageMenu(env, parent, -1, menumgr, text) )->drop(); delete[] text; return true; } acceptInput(); quitMenu(); return true; } case GUI_ID_CHANGE_KEYS_BUTTON: { GUIKeyChangeMenu *kmenu = new GUIKeyChangeMenu(env, parent, -1,menumgr); kmenu->drop(); return true; } case GUI_ID_DELETE_WORLD_BUTTON: { MainMenuData cur; readInput(&cur); if(cur.selected_world == -1){ wchar_t* text = wgettext("Cannot delete world: Nothing selected"); (new GUIMessageMenu(env, parent, -1, menumgr, text) )->drop(); delete[] text; } else { WorldSpec spec = m_data->worlds[cur.selected_world]; // Get files and directories involved std::vector<std::string> paths; paths.push_back(spec.path); fs::GetRecursiveSubPaths(spec.path, paths); // Launch confirmation dialog ConfirmDestDeleteWorld *dest = new ConfirmDestDeleteWorld(spec, this, paths); wchar_t* text1 = wgettext("Delete world"); wchar_t* text2 = wgettext("Files to be deleted"); std::wstring text = text1; text += L" \""; text += narrow_to_wide(spec.name); text += L"\"?\n\n"; text += text2; text += L":\n"; delete[] text1; delete[] text2; for(u32 i=0; i<paths.size(); i++){ if(i == 3){ text += L"..."; break; } text += narrow_to_wide(paths[i]) + L"\n"; } (new GUIConfirmMenu(env, parent, -1, menumgr, dest, text.c_str()))->drop(); } return true; } case GUI_ID_CREATE_WORLD_BUTTON: { const std::vector<SubgameSpec> &games = m_data->games; if(games.size() == 0){ wchar_t* text = wgettext("Cannot create world: No games found"); GUIMessageMenu *menu = new GUIMessageMenu(env, parent, -1, menumgr, text); menu->drop(); delete[] text; } else { CreateWorldDest *dest = new CreateWorldDestMainMenu(this); GUICreateWorld *menu = new GUICreateWorld(env, parent, -1, menumgr, dest, games, m_data->selected_game); menu->drop(); } return true; } case GUI_ID_CONFIGURE_WORLD_BUTTON: { MainMenuData cur; readInput(&cur); if(cur.selected_world == -1) { wchar_t* text = wgettext("Cannot configure world: Nothing selected"); (new GUIMessageMenu(env, parent, -1, menumgr, text) )->drop(); delete[] text; } else { WorldSpec wspec = m_data->worlds[cur.selected_world]; GUIConfigureWorld *menu = new GUIConfigureWorld(env, parent, -1, menumgr, wspec); menu->drop(); } return true; } case GUI_ID_SERVERLIST_DELETE: { gui::IGUIListBox *serverlist = (gui::IGUIListBox*)getElementFromId(GUI_ID_SERVERLIST); s32 selected = ((gui::IGUIListBox*)serverlist)->getSelected(); if (selected == -1) return true; ServerList::deleteEntry(m_data->servers[selected]); m_data->servers = ServerList::getLocal(); updateGuiServerList(); if (selected > 0) selected -= 1; serverlist->setSelected(selected); serverListOnSelected(); return true; } #if USE_CURL case GUI_ID_SERVERLIST_TOGGLE: { 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); gui::IGUIElement *title = getElementFromId(GUI_ID_SERVERLIST_TITLE); if (m_data->selected_serverlist == SERVERLIST_PUBLIC) // switch to favorite list { m_data->servers = ServerList::getLocal(); wchar_t* text1 = wgettext("Show Public"); wchar_t* text2 = wgettext("Favorites:"); togglebutton->setText(text1); title->setText(text2); delete[] text1; delete[] text2; deletebutton->setVisible(true); updateGuiServerList(); serverlist->setSelected(0); m_data->selected_serverlist = SERVERLIST_FAVORITES; } else // switch to online list { m_data->servers = ServerList::getOnline(); wchar_t* text1 = wgettext("Show Favorites"); wchar_t* text2 = wgettext("Public Server List:"); togglebutton->setText(text1); title->setText(text2); delete[] text1; delete[] text2; deletebutton->setVisible(false); updateGuiServerList(); serverlist->setSelected(0); m_data->selected_serverlist = SERVERLIST_PUBLIC; } serverListOnSelected(); } #endif } /* Game buttons */ int eid = event.GUIEvent.Caller->getID(); if(eid >= GUI_ID_GAME_BUTTON_FIRST && eid <= GUI_ID_GAME_BUTTON_MAX){ m_data->selected_game = m_data->games[eid - GUI_ID_GAME_BUTTON_FIRST].id; m_data->selected_game_name = m_data->games[eid - GUI_ID_GAME_BUTTON_FIRST].name; regenerateGui(m_screensize_old); } } if(event.GUIEvent.EventType==gui::EGET_EDITBOX_ENTER) { switch(event.GUIEvent.Caller->getID()) { case GUI_ID_ADDRESS_INPUT: case GUI_ID_PORT_INPUT: case GUI_ID_NAME_INPUT: case 264: MainMenuData cur; readInput(&cur); if (getTab() == TAB_MULTIPLAYER && cur.address == L"") { wchar_t* text = wgettext("Address required."); (new GUIMessageMenu(env, parent, -1, menumgr, text) )->drop(); delete[] text; return true; } acceptInput(); quitMenu(); return true; } } if(event.GUIEvent.EventType==gui::EGET_LISTBOX_CHANGED) { readInput(m_data); } if(event.GUIEvent.EventType==gui::EGET_LISTBOX_SELECTED_AGAIN) { switch(event.GUIEvent.Caller->getID()) { case GUI_ID_WORLD_LISTBOX: acceptInput(); if(getTab() != TAB_SINGLEPLAYER) m_data->address = L""; // Force local game quitMenu(); return true; case GUI_ID_SERVERLIST: gui::IGUIListBox *serverlist = (gui::IGUIListBox*)getElementFromId(GUI_ID_SERVERLIST); if (serverlist->getSelected() > -1) { acceptInput(); quitMenu(); return true; } } } } return Parent ? Parent->OnEvent(event) : false; }
void GUIMainMenu::readInput(MainMenuData *dst) { { gui::IGUIElement *e = getElementFromId(GUI_ID_TAB_CONTROL); if(e != NULL && e->getType() == gui::EGUIET_TAB_CONTROL) dst->selected_tab = ((gui::IGUITabControl*)e)->getActiveTab(); } if(dst->selected_tab == TAB_SINGLEPLAYER) { dst->simple_singleplayer_mode = true; } else { dst->simple_singleplayer_mode = false; { gui::IGUIElement *e = getElementFromId(GUI_ID_NAME_INPUT); if(e != NULL) dst->name = e->getText(); } { gui::IGUIElement *e = getElementFromId(264); if(e != NULL) dst->password = e->getText(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_ADDRESS_INPUT); if(e != NULL) dst->address = e->getText(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_PORT_INPUT); if(e != NULL) dst->port = e->getText(); } } { gui::IGUIElement *e = getElementFromId(GUI_ID_CREATIVE_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) dst->creative_mode = ((gui::IGUICheckBox*)e)->isChecked(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_DAMAGE_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) dst->enable_damage = ((gui::IGUICheckBox*)e)->isChecked(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_FANCYTREE_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) dst->fancy_trees = ((gui::IGUICheckBox*)e)->isChecked(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_SMOOTH_LIGHTING_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) dst->smooth_lighting = ((gui::IGUICheckBox*)e)->isChecked(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_3D_CLOUDS_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) dst->clouds_3d = ((gui::IGUICheckBox*)e)->isChecked(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_OPAQUE_WATER_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) dst->opaque_water = ((gui::IGUICheckBox*)e)->isChecked(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_WORLD_LISTBOX); if(e != NULL && e->getType() == gui::EGUIET_LIST_BOX) dst->selected_world = ((gui::IGUIListBox*)e)->getSelected(); } }
void GUIMainMenu::regenerateGui(v2u32 screensize) { std::wstring text_name; std::wstring text_address; std::wstring text_port; bool creative_mode; bool enable_damage; bool fancy_trees; bool smooth_lighting; // Client options { gui::IGUIElement *e = getElementFromId(GUI_ID_NAME_INPUT); if(e != NULL) text_name = e->getText(); else text_name = m_data->name; } { gui::IGUIElement *e = getElementFromId(GUI_ID_ADDRESS_INPUT); if(e != NULL) text_address = e->getText(); else text_address = m_data->address; } { gui::IGUIElement *e = getElementFromId(GUI_ID_PORT_INPUT); if(e != NULL) text_port = e->getText(); else text_port = m_data->port; } { gui::IGUIElement *e = getElementFromId(GUI_ID_FANCYTREE_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) fancy_trees = ((gui::IGUICheckBox*)e)->isChecked(); else fancy_trees = m_data->fancy_trees; } { gui::IGUIElement *e = getElementFromId(GUI_ID_SMOOTH_LIGHTING_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) smooth_lighting = ((gui::IGUICheckBox*)e)->isChecked(); else smooth_lighting = m_data->smooth_lighting; } // Server options { gui::IGUIElement *e = getElementFromId(GUI_ID_CREATIVE_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) creative_mode = ((gui::IGUICheckBox*)e)->isChecked(); else creative_mode = m_data->creative_mode; } { gui::IGUIElement *e = getElementFromId(GUI_ID_DAMAGE_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) enable_damage = ((gui::IGUICheckBox*)e)->isChecked(); else enable_damage = m_data->enable_damage; } /* Remove stuff */ removeChildren(); /* Calculate new sizes and positions */ v2s32 size(620, 430); core::rect<s32> rect( screensize.X/2 - size.X/2, screensize.Y/2 - size.Y/2, screensize.X/2 + size.X/2, screensize.Y/2 + size.Y/2 ); DesiredRect = rect; recalculateAbsolutePosition(false); //v2s32 size = rect.getSize(); /* Add stuff */ /* Client section */ v2s32 topleft_client(40, 0); v2s32 size_client = size - v2s32(40, 0); changeCtype(""); { core::rect<s32> rect(0, 0, 20, 125); rect += topleft_client + v2s32(-15, 60); const wchar_t *text = L"C\nL\nI\nE\nN\nT"; //gui::IGUIStaticText *t = Environment->addStaticText(text, rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } // Nickname + password { core::rect<s32> rect(0, 0, 110, 20); rect += topleft_client + v2s32(35, 50+6); Environment->addStaticText(wgettext("Name/Password"), rect, false, true, this, -1); } changeCtype("C"); { core::rect<s32> rect(0, 0, 230, 30); rect += topleft_client + v2s32(160, 50); gui::IGUIElement *e = Environment->addEditBox(text_name.c_str(), rect, true, this, GUI_ID_NAME_INPUT); if(text_name == L"") Environment->setFocus(e); } { core::rect<s32> rect(0, 0, 120, 30); rect += topleft_client + v2s32(size_client.X-60-100, 50); gui::IGUIEditBox *e = Environment->addEditBox(L"", rect, true, this, 264); e->setPasswordBox(true); if(text_name != L"" && text_address != L"") Environment->setFocus(e); } changeCtype(""); // Address + port { core::rect<s32> rect(0, 0, 110, 20); rect += topleft_client + v2s32(35, 100+6); Environment->addStaticText(wgettext("Address/Port"), rect, false, true, this, -1); } changeCtype("C"); { core::rect<s32> rect(0, 0, 230, 30); rect += topleft_client + v2s32(160, 100); gui::IGUIElement *e = Environment->addEditBox(text_address.c_str(), rect, true, this, GUI_ID_ADDRESS_INPUT); if(text_name != L"" && text_address == L"") Environment->setFocus(e); } { core::rect<s32> rect(0, 0, 120, 30); //rect += topleft_client + v2s32(160+250+20, 125); rect += topleft_client + v2s32(size_client.X-60-100, 100); Environment->addEditBox(text_port.c_str(), rect, true, this, GUI_ID_PORT_INPUT); } changeCtype(""); { core::rect<s32> rect(0, 0, 400, 20); rect += topleft_client + v2s32(160, 100+35); Environment->addStaticText(wgettext("Leave address blank to start a local server."), rect, false, true, this, -1); } { core::rect<s32> rect(0, 0, 250, 30); rect += topleft_client + v2s32(35, 150); Environment->addCheckBox(fancy_trees, rect, this, GUI_ID_FANCYTREE_CB, wgettext("Fancy trees")); } { core::rect<s32> rect(0, 0, 250, 30); rect += topleft_client + v2s32(35, 150+30); Environment->addCheckBox(smooth_lighting, rect, this, GUI_ID_SMOOTH_LIGHTING_CB, wgettext("Smooth Lighting")); } // Start game button { core::rect<s32> rect(0, 0, 180, 30); //rect += topleft_client + v2s32(size_client.X/2-180/2, 225-30/2); rect += topleft_client + v2s32(size_client.X-180-40, 150+25); Environment->addButton(rect, this, GUI_ID_JOIN_GAME_BUTTON, wgettext("Start Game / Connect")); } // Key change button { core::rect<s32> rect(0, 0, 100, 30); //rect += topleft_client + v2s32(size_client.X/2-180/2, 225-30/2); rect += topleft_client + v2s32(size_client.X-180-40-100-20, 150+25); Environment->addButton(rect, this, GUI_ID_CHANGE_KEYS_BUTTON, wgettext("Change keys")); } /* Server section */ v2s32 topleft_server(40, 250); v2s32 size_server = size - v2s32(40, 0); { core::rect<s32> rect(0, 0, 20, 125); rect += topleft_server + v2s32(-15, 40); const wchar_t *text = L"S\nE\nR\nV\nE\nR"; //gui::IGUIStaticText *t = Environment->addStaticText(text, rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } // Server parameters { core::rect<s32> rect(0, 0, 250, 30); rect += topleft_server + v2s32(35, 30); Environment->addCheckBox(creative_mode, rect, this, GUI_ID_CREATIVE_CB, wgettext("Creative Mode")); } { core::rect<s32> rect(0, 0, 250, 30); rect += topleft_server + v2s32(35, 60); Environment->addCheckBox(enable_damage, rect, this, GUI_ID_DAMAGE_CB, wgettext("Enable Damage")); } // Map delete button { core::rect<s32> rect(0, 0, 130, 30); //rect += topleft_server + v2s32(size_server.X-40-130, 100+25); rect += topleft_server + v2s32(40, 100+25); Environment->addButton(rect, this, GUI_ID_DELETE_MAP_BUTTON, wgettext("Delete map")); } changeCtype("C"); }
void GUIMultiplayerMenu::regenerateGui(v2u32 screensize) { std::wstring text_name; std::wstring text_address; std::wstring text_port; m_screensize = screensize; // Client options { gui::IGUIElement *e = getElementFromId(GUI_ID_NAME_INPUT); if (e != NULL) { text_name = e->getText(); }else{ text_name = m_data.mmdata->name; } if (text_name == L"") text_name = narrow_to_wide(porting::getUser()); } { gui::IGUIElement *e = getElementFromId(GUI_ID_ADDRESS_INPUT); if (e != NULL) { text_address = e->getText(); }else{ text_address = m_data.mmdata->address; } } { gui::IGUIElement *e = getElementFromId(GUI_ID_PORT_INPUT); if (e != NULL) { text_port = e->getText(); }else{ text_port = m_data.mmdata->port; } } /* Remove stuff */ removeChildren(); /* Calculate new sizes and positions */ v2s32 size(800, 500); core::rect<s32> rect( screensize.X/2 - size.X/2, screensize.Y/2 - size.Y/2, screensize.X/2 + size.X/2, screensize.Y/2 + size.Y/2 ); DesiredRect = rect; recalculateAbsolutePosition(false); // Main Menu button { core::rect<s32> rect(0, 0, 200, 40); rect += v2s32(25, 200); Environment->addButton(rect, this, GUI_ID_TAB_MP_MAINMENU, wgettext("Main Menu")); } // Dynamic List button { core::rect<s32> rect(0, 0, 180, 40); rect += v2s32(35, 260); Environment->addButton(rect, this, GUI_ID_TAB_MP_LIST, wgettext("All Servers")); } // Favourites List button { core::rect<s32> rect(0, 0, 180, 40); rect += v2s32(35, 305); Environment->addButton(rect, this, GUI_ID_TAB_MP_FAVOURITES, wgettext("Favourite Servers")); } // Custom Connect button (the old multiplayer menu) { core::rect<s32> rect(0, 0, 180, 40); rect += v2s32(35, 350); Environment->addButton(rect, this, GUI_ID_TAB_MP_CUSTOM, wgettext("Custom Connect")); } v2s32 topleft_content(250, 0); { core::rect<s32> rect(0, 0, 550, 20); rect += topleft_content + v2s32(0, 10); gui::IGUIStaticText *t = Environment->addStaticText(wgettext("Multi Player"), rect, false, true, this, -1); t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } if (m_data.selected_tab == TAB_MP_CUSTOM) { { core::rect<s32> rect(0, 0, 550, 20); rect += topleft_content + v2s32(0, 30); gui::IGUIStaticText *t = Environment->addStaticText(wgettext("Custom Connection"), rect, false, true, this, -1); t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } // Address + port { core::rect<s32> rect(0, 0, 110, 20); rect += topleft_content + v2s32(120, 60); Environment->addStaticText(wgettext("Address/Port"), rect, false, true, this, -1); } { if (text_address == L"") text_address = L"servers.voxelands.com"; core::rect<s32> rect(0, 0, 230, 30); rect += topleft_content + v2s32(135, 90); #if USE_FREETYPE new gui::intlGUIEditBox(text_address.c_str(), true, Environment, this, GUI_ID_ADDRESS_INPUT, rect); #else Environment->addEditBox(text_address.c_str(), rect, false, this, GUI_ID_ADDRESS_INPUT); #endif } { core::rect<s32> rect(0, 0, 120, 30); rect += topleft_content + v2s32(245, 125); #if USE_FREETYPE new gui::intlGUIEditBox(text_port.c_str(), true, Environment, this, GUI_ID_PORT_INPUT, rect); #else Environment->addEditBox(text_port.c_str(), rect, false, this, GUI_ID_PORT_INPUT); #endif } { core::rect<s32> rect(0, 0, 180, 30); rect += topleft_content + v2s32(80, 160); Environment->addButton(rect, this, GUI_ID_ADDFAV_BUTTON, wgettext("Add to Favourites")); } { core::rect<s32> rect(0, 0, 180, 30); rect += topleft_content + v2s32(270, 160); Environment->addButton(rect, this, GUI_ID_CONNECT_BUTTON, wgettext("Connect")); } }else if (m_data.selected_tab == TAB_MP_CONNECT) { // Nickname + password { core::rect<s32> rect(0, 0, 110, 20); rect += topleft_content + v2s32(120, 60); Environment->addStaticText(wgettext("Name/Password"), rect, false, true, this, -1); } { core::rect<s32> rect(0, 0, 230, 30); rect += topleft_content + v2s32(135, 90); #if USE_FREETYPE new gui::intlGUIEditBox(text_name.c_str(), true, Environment, this, GUI_ID_NAME_INPUT, rect); #else Environment->addEditBox(text_name.c_str(), rect, false, this, GUI_ID_NAME_INPUT); #endif } { core::rect<s32> rect(0, 0, 230, 30); rect += topleft_content + v2s32(135, 125); gui::IGUIEditBox *e; #if USE_FREETYPE e = (gui::IGUIEditBox *) new gui::intlGUIEditBox(L"", true, Environment, this, GUI_ID_PW_INPUT, rect); #else e = Environment->addEditBox(L"", rect, false, this, GUI_ID_PW_INPUT); #endif e->setPasswordBox(true); Environment->setFocus(e); // Start game button { core::rect<s32> rect(0, 0, 180, 30); rect += topleft_content + v2s32(160, 160); Environment->addButton(rect, this, GUI_ID_START_BUTTON, wgettext("Join Server")); } } }else{ gui::IGUIListBox *box = NULL; gui::IGUIStaticText *header = NULL; std::vector<ServerInfo> *list = NULL; { core::rect<s32> rect(0, 0, 550, 20); rect += topleft_content + v2s32(0, 30); header = Environment->addStaticText(L"", rect, false, true, this, -1); header->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect<s32> rect(0, 0, 350, 200); rect += topleft_content + v2s32(100, 60); box = Environment->addListBox(rect, this, GUI_ID_SERVER_LIST, true); box->setItemHeight(25); } if (m_data.selected_tab == TAB_MP_FAVOURITES) { header->setText(wgettext("My Favourites")); list = &m_data.favourites; }else{ header->setText(wgettext("Server List")); list = &m_data.servers; { core::rect<s32> rect(0, 0, 180, 25); rect += topleft_content + v2s32(270, 260); Environment->addButton(rect, this, GUI_ID_REFRESH_BUTTON, wgettext("Get New List")); } } for (std::vector<ServerInfo>::iterator i = list->begin(); i != list->end(); i++) { box->addItem(i->name.c_str()); } if (m_data.selected_row > -1) { ServerInfo info = list->at(m_data.selected_row); if (info.name == L"") { m_data.selected_row = -1; }else{ box->setSelected(m_data.selected_row); { core::rect<s32> rect(0, 0, 550, 20); rect += topleft_content + v2s32(0, 300); gui::IGUIStaticText *t = Environment->addStaticText(info.name.c_str(), rect, false, true, this, -1); t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect<s32> rect(0, 0, 350, 20); rect += topleft_content + v2s32(100, 330); gui::IGUIStaticText *t = Environment->addStaticText(info.addr.c_str(), rect, false, true, this, -1); t->setTextAlignment(gui::EGUIA_UPPERLEFT, gui::EGUIA_UPPERLEFT); } { core::rect<s32> rect(0, 0, 350, 20); rect += topleft_content + v2s32(100, 350); gui::IGUIStaticText *t = Environment->addStaticText(info.mode.c_str(), rect, false, true, this, -1); t->setTextAlignment(gui::EGUIA_UPPERLEFT, gui::EGUIA_UPPERLEFT); } if (info.is_favourite) { { core::rect<s32> rect(0, 0, 180, 30); rect += topleft_content + v2s32(80, 390); Environment->addButton(rect, this, GUI_ID_REMFAV_BUTTON, wgettext("Remove from Favourites")); } }else{ { core::rect<s32> rect(0, 0, 180, 30); rect += topleft_content + v2s32(80, 390); Environment->addButton(rect, this, GUI_ID_ADDFAV_BUTTON, wgettext("Add to Favourites")); } } { core::rect<s32> rect(0, 0, 180, 30); rect += topleft_content + v2s32(270, 390); Environment->addButton(rect, this, GUI_ID_CONNECT_BUTTON, wgettext("Connect")); } } } } }
void GUITextInputMenu::regenerateGui(v2u32 screensize) { std::wstring text; { gui::IGUIElement *e = getElementFromId(256); if(e != NULL) { text = e->getText(); } else { text = m_initial_text; m_initial_text = L""; } } /* Remove stuff */ removeChildren(); /* Calculate new sizes and positions */ core::rect<s32> rect( screensize.X/2 - 580/2, screensize.Y/2 - 300/2, screensize.X/2 + 580/2, screensize.Y/2 + 300/2 ); DesiredRect = rect; recalculateAbsolutePosition(false); v2s32 size = rect.getSize(); /* Add stuff */ { core::rect<s32> rect(0, 0, 300, 30); rect = rect + v2s32(size.X/2-300/2, size.Y/2-30/2-25); #if USE_FREETYPE gui::IGUIElement *e = (gui::IGUIElement *) new gui::intlGUIEditBox(text.c_str(), true, Environment, this, 256, rect); e->drop(); #else gui::IGUIElement *e = Environment->addEditBox(text.c_str(), rect, true, this, 256); #endif Environment->setFocus(e); irr::SEvent evt; evt.EventType = EET_KEY_INPUT_EVENT; evt.KeyInput.Key = KEY_END; evt.KeyInput.PressedDown = true; e->OnEvent(evt); } changeCtype(""); { core::rect<s32> rect(0, 0, 140, 30); rect = rect + v2s32(size.X/2-140/2, size.Y/2-30/2+25); wchar_t* text = wgettext("Proceed"); Environment->addButton(rect, this, 257, text); delete[] text; } changeCtype("C"); }
void GUISettingsMenu::regenerateGui(v2u32 screensize) { bool fancy_trees; bool smooth_lighting; bool clouds_3d; bool opaque_water; bool fullscreen; bool particles; bool mipmap; bool bilinear; bool trilinear; bool anisotropic; bool hotbar; bool wield_index; f32 volume; m_screensize = screensize; { gui::IGUIElement *e = getElementFromId(GUI_ID_FANCYTREE_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) fancy_trees = ((gui::IGUICheckBox*)e)->isChecked(); else fancy_trees = m_data.fancy_trees; } { gui::IGUIElement *e = getElementFromId(GUI_ID_SMOOTH_LIGHTING_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) smooth_lighting = ((gui::IGUICheckBox*)e)->isChecked(); else smooth_lighting = m_data.smooth_lighting; } { gui::IGUIElement *e = getElementFromId(GUI_ID_3D_CLOUDS_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) clouds_3d = ((gui::IGUICheckBox*)e)->isChecked(); else clouds_3d = m_data.clouds_3d; } { gui::IGUIElement *e = getElementFromId(GUI_ID_OPAQUE_WATER_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) opaque_water = ((gui::IGUICheckBox*)e)->isChecked(); else opaque_water = m_data.opaque_water; } { gui::IGUIElement *e = getElementFromId(GUI_ID_FULLSCREEN_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) fullscreen = ((gui::IGUICheckBox*)e)->isChecked(); else fullscreen = m_data.fullscreen; } { gui::IGUIElement *e = getElementFromId(GUI_ID_PARTICLES_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) particles = ((gui::IGUICheckBox*)e)->isChecked(); else particles = m_data.particles; } { gui::IGUIElement *e = getElementFromId(GUI_ID_MIPMAP_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) mipmap = ((gui::IGUICheckBox*)e)->isChecked(); else mipmap = m_data.mip_map; } { gui::IGUIElement *e = getElementFromId(GUI_ID_BILINEAR_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) bilinear = ((gui::IGUICheckBox*)e)->isChecked(); else bilinear = m_data.bilinear_filter; } { gui::IGUIElement *e = getElementFromId(GUI_ID_TRILINEAR_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) trilinear = ((gui::IGUICheckBox*)e)->isChecked(); else trilinear = m_data.trilinear_filter; } { gui::IGUIElement *e = getElementFromId(GUI_ID_ANISOTROPIC_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) anisotropic = ((gui::IGUICheckBox*)e)->isChecked(); else anisotropic = m_data.anisotropic_filter; } { gui::IGUIElement *e = getElementFromId(GUI_ID_HOTBAR_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) hotbar = ((gui::IGUICheckBox*)e)->isChecked(); else hotbar = m_data.hotbar; } { gui::IGUIElement *e = getElementFromId(GUI_ID_WIELDINDEX_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) wield_index = ((gui::IGUICheckBox*)e)->isChecked(); else wield_index = m_data.wield_index; } { gui::IGUIElement *e = getElementFromId(GUI_ID_VOLUME_SB); if(e != NULL && e->getType() == gui::EGUIET_SCROLL_BAR) volume = (float)((gui::IGUIScrollBar*)e)->getPos(); else volume = m_data.volume; } /* Remove stuff */ removeChildren(); /* Calculate new sizes and positions */ v2s32 size(800, 500); core::rect<s32> rect( screensize.X/2 - size.X/2, screensize.Y/2 - size.Y/2, screensize.X/2 + size.X/2, screensize.Y/2 + size.Y/2 ); DesiredRect = rect; recalculateAbsolutePosition(false); // Main Menu button { core::rect<s32> rect(0, 0, 200, 40); rect += v2s32(25, 200); Environment->addButton(rect, this, GUI_ID_TAB_MAINMENU, wgettext("Main Menu")); } // Controls Settings button { core::rect<s32> rect(0, 0, 180, 40); rect += v2s32(35, 260); Environment->addButton(rect, this, GUI_ID_TAB_SETTINGS_CONTROLS, wgettext("Controls")); } // Graphics Settings button { core::rect<s32> rect(0, 0, 180, 40); rect += v2s32(35, 305); Environment->addButton(rect, this, GUI_ID_TAB_SETTINGS_GRAPHICS, wgettext("Graphics")); } // Video Settings button { core::rect<s32> rect(0, 0, 180, 40); rect += v2s32(35, 350); Environment->addButton(rect, this, GUI_ID_TAB_SETTINGS_VIDEO, wgettext("Video")); } // Sound Settings button { core::rect<s32> rect(0, 0, 180, 40); rect += v2s32(35, 395); Environment->addButton(rect, this, GUI_ID_TAB_SETTINGS_SOUND, wgettext("Sound")); } v2s32 topleft_content(250, 0); if (m_data.selected_tab == TAB_SETTINGS_CONTROLS) { { core::rect<s32> rect(0, 0, 550, 20); rect += topleft_content + v2s32(0, 20); gui::IGUIStaticText *t = Environment->addStaticText(wgettext("Controls"), rect, false, true, this, -1); t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } v2s32 offset(0, 40); for (int i=0; i<VLKC_MAX; i++) { if (keynames[i] == NULL) continue; { core::rect < s32 > rect(0, 0, 150, 20); rect += topleft_content + offset; gui::IGUIStaticText *t = Environment->addStaticText(keynames[i], rect, false, true, this, -1); t->setTextAlignment(gui::EGUIA_LOWERRIGHT, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 110, 30); rect += topleft_content + offset + v2s32(155, -5); Environment->addButton(rect, this, GUI_ID_KEYSETTINGS_BASE+i, keys[i].guiName().c_str()); } offset += v2s32(0, 33); if (offset.Y > 450) { offset.Y = 40; offset.X = 275; } } }else if (m_data.selected_tab == TAB_SETTINGS_GRAPHICS) { { core::rect<s32> rect(0, 0, 550, 20); rect += topleft_content + v2s32(0, 20); gui::IGUIStaticText *t = Environment->addStaticText(wgettext("Graphics"), rect, false, true, this, -1); t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect<s32> rect(0, 0, 200, 30); rect += topleft_content + v2s32(80, 60); Environment->addCheckBox(fancy_trees, rect, this, GUI_ID_FANCYTREE_CB, wgettext("Fancy trees")); } { core::rect<s32> rect(0, 0, 200, 30); rect += topleft_content + v2s32(80, 90); Environment->addCheckBox(smooth_lighting, rect, this, GUI_ID_SMOOTH_LIGHTING_CB, wgettext("Smooth Lighting")); } { core::rect<s32> rect(0, 0, 200, 30); rect += topleft_content + v2s32(80, 120); Environment->addCheckBox(clouds_3d, rect, this, GUI_ID_3D_CLOUDS_CB, wgettext("3D Clouds")); } { core::rect<s32> rect(0, 0, 200, 30); rect += topleft_content + v2s32(80, 150); Environment->addCheckBox(opaque_water, rect, this, GUI_ID_OPAQUE_WATER_CB, wgettext("Opaque water")); } { core::rect<s32> rect(0, 0, 200, 30); rect += topleft_content + v2s32(290, 60); Environment->addCheckBox(hotbar, rect, this, GUI_ID_HOTBAR_CB, wgettext("Classic HUD")); } { core::rect<s32> rect(0, 0, 200, 30); rect += topleft_content + v2s32(290, 90); gui::IGUICheckBox *c = Environment->addCheckBox(wield_index, rect, this, GUI_ID_WIELDINDEX_CB, wgettext("Wieldring Index")); c->setEnabled(!hotbar); } if (m_is_ingame) { core::rect<s32> rect(0, 0, 550, 20); rect += topleft_content + v2s32(0, 200); gui::IGUIStaticText *t = Environment->addStaticText(wgettext("Some settings cannot be changed in-game."), rect, false, true, this, -1); t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } }else if (m_data.selected_tab == TAB_SETTINGS_VIDEO) { { core::rect<s32> rect(0, 0, 550, 20); rect += topleft_content + v2s32(0, 20); gui::IGUIStaticText *t = Environment->addStaticText(wgettext("Video"), rect, false, true, this, -1); t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect<s32> rect(0, 0, 200, 30); rect += topleft_content + v2s32(80, 60); Environment->addCheckBox(fullscreen, rect, this, GUI_ID_FULLSCREEN_CB, wgettext("Fullscreen")); } { core::rect<s32> rect(0, 0, 200, 30); rect += topleft_content + v2s32(80, 90); Environment->addCheckBox(particles, rect, this, GUI_ID_PARTICLES_CB, wgettext("Particles")); } { core::rect<s32> rect(0, 0, 200, 30); rect += topleft_content + v2s32(80, 120); Environment->addCheckBox(mipmap, rect, this, GUI_ID_MIPMAP_CB, wgettext("Mip-Mapping")); } { core::rect<s32> rect(0, 0, 200, 30); rect += topleft_content + v2s32(80, 150); Environment->addCheckBox(bilinear, rect, this, GUI_ID_BILINEAR_CB, wgettext("Bi-Linear Filtering")); } { core::rect<s32> rect(0, 0, 200, 30); rect += topleft_content + v2s32(80, 180); Environment->addCheckBox(trilinear, rect, this, GUI_ID_TRILINEAR_CB, wgettext("Tri-Linear Filtering")); } { core::rect<s32> rect(0, 0, 200, 30); rect += topleft_content + v2s32(80, 210); Environment->addCheckBox(anisotropic, rect, this, GUI_ID_ANISOTROPIC_CB, wgettext("Anisotropic Filtering")); } if (m_is_ingame) { core::rect<s32> rect(0, 0, 550, 20); rect += topleft_content + v2s32(0, 250); gui::IGUIStaticText *t = Environment->addStaticText(wgettext("Some settings cannot be changed in-game."), rect, false, true, this, -1); t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } }else if (m_data.selected_tab == TAB_SETTINGS_SOUND) { { core::rect<s32> rect(0, 0, 550, 20); rect += topleft_content + v2s32(0, 20); gui::IGUIStaticText *t = Environment->addStaticText(wgettext("Sound"), rect, false, true, this, -1); t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect<s32> rect(0, 0, 200, 15); rect += topleft_content + v2s32(80, 60); Environment->addStaticText(wgettext("Volume:"), rect, false, false, this, -1); } { core::rect<s32> rect(0, 0, 200, 15); rect += topleft_content + v2s32(290, 60); gui::IGUIScrollBar *sb = Environment->addScrollBar(true, rect, this, GUI_ID_VOLUME_SB); sb->setMin(0); sb->setMax(100); sb->setPos(volume); } } }
bool GUISettingsMenu::OnEvent(const SEvent& event) { if (event.EventType == EET_KEY_INPUT_EVENT && activeKey >= 0 && event.KeyInput.PressedDown) { KeyPress kp(event.KeyInput); gui::IGUIElement *e = getElementFromId(activeKey); if (e != NULL && e->getType() == gui::EGUIET_BUTTON) { e->setEnabled(true); e->setText(kp.guiName().c_str()); keys[activeKey-GUI_ID_KEYSETTINGS_BASE] = kp; } activeKey = -1; return true; } if (event.EventType == EET_GUI_EVENT) { if (event.GUIEvent.EventType == gui::EGET_ELEMENT_FOCUS_LOST && isVisible()) { if (!canTakeFocus(event.GUIEvent.Element)) { dstream << "GUIMainMenu: Not allowing focus change." << std::endl; // Returning true disables focus change return true; } } if (event.GUIEvent.EventType==gui::EGET_CHECKBOX_CHANGED) { acceptInput(); m_accepted = false; regenerateGui(m_screensize); } if (event.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED) { s32 id = event.GUIEvent.Caller->getID(); if (id >= GUI_ID_KEYSETTINGS_BASE) { resetMenu(); activeKey = id; gui::IGUIElement *e = getElementFromId(id); if (e != NULL && e->getType() == gui::EGUIET_BUTTON) { e->setText(wgettext("press Key")); e->setEnabled(false); return true; } }else{ switch (event.GUIEvent.Caller->getID()) { case GUI_ID_TAB_SETTINGS_CONTROLS: acceptInput(); m_accepted = false; m_data.selected_tab = TAB_SETTINGS_CONTROLS; regenerateGui(m_screensize); return true; case GUI_ID_TAB_SETTINGS_GRAPHICS: acceptInput(); m_accepted = false; m_data.selected_tab = TAB_SETTINGS_GRAPHICS; regenerateGui(m_screensize); return true; case GUI_ID_TAB_SETTINGS_VIDEO: acceptInput(); m_accepted = false; m_data.selected_tab = TAB_SETTINGS_VIDEO; regenerateGui(m_screensize); return true; case GUI_ID_TAB_SETTINGS_SOUND: acceptInput(); m_accepted = false; m_data.selected_tab = TAB_SETTINGS_SOUND; regenerateGui(m_screensize); return true; case GUI_ID_TAB_MAINMENU: //back acceptInput(); save(); quitMenu(); return true; } } } if (event.GUIEvent.EventType == gui::EGET_SCROLL_BAR_CHANGED) { switch (event.GUIEvent.Caller->getID()) { case GUI_ID_VOLUME_SB: gui::IGUIElement *vsb = getElementFromId(GUI_ID_VOLUME_SB); if(vsb != NULL && vsb->getType() == gui::EGUIET_SCROLL_BAR) { m_data.volume = (float)((gui::IGUIScrollBar*)vsb)->getPos(); if (g_sound) g_sound->setListenerGain(m_data.volume/100.0); } return true; } } } return Parent ? Parent->OnEvent(event) : false; }
bool GUISettingsMenu::acceptInput() { { gui::IGUIElement *e = getElementFromId(GUI_ID_FANCYTREE_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) m_data.fancy_trees = ((gui::IGUICheckBox*)e)->isChecked(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_SMOOTH_LIGHTING_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) m_data.smooth_lighting = ((gui::IGUICheckBox*)e)->isChecked(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_3D_CLOUDS_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) m_data.clouds_3d = ((gui::IGUICheckBox*)e)->isChecked(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_OPAQUE_WATER_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) m_data.opaque_water = ((gui::IGUICheckBox*)e)->isChecked(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_FULLSCREEN_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) m_data.fullscreen = ((gui::IGUICheckBox*)e)->isChecked(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_PARTICLES_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) m_data.particles = ((gui::IGUICheckBox*)e)->isChecked(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_MIPMAP_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) m_data.mip_map = ((gui::IGUICheckBox*)e)->isChecked(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_BILINEAR_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) m_data.bilinear_filter = ((gui::IGUICheckBox*)e)->isChecked(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_TRILINEAR_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) m_data.trilinear_filter = ((gui::IGUICheckBox*)e)->isChecked(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_ANISOTROPIC_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) m_data.anisotropic_filter = ((gui::IGUICheckBox*)e)->isChecked(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_HOTBAR_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) m_data.hotbar = ((gui::IGUICheckBox*)e)->isChecked(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_WIELDINDEX_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) m_data.wield_index = ((gui::IGUICheckBox*)e)->isChecked(); } { gui::IGUIElement *e = getElementFromId(GUI_ID_VOLUME_SB); if(e != NULL && e->getType() == gui::EGUIET_SCROLL_BAR) m_data.volume = (float)((gui::IGUIScrollBar*)e)->getPos(); } return true; }