diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b0139859ef..79ea2b9de95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1304,6 +1304,7 @@ set(EXPECTED_DATA languages/czech.txt languages/danish.txt languages/dutch.txt + languages/esperanto.txt languages/finnish.txt languages/french.txt languages/german.txt diff --git a/data/languages/esperanto.txt b/data/languages/esperanto.txt new file mode 100644 index 00000000000..7b65b9153aa --- /dev/null +++ b/data/languages/esperanto.txt @@ -0,0 +1,1550 @@ +##### translated strings ##### + +Successfully saved the replay! +== + +Saving ddnet-settings.cfg failed +== + +Replay feature is disabled! +== + +The width of texture %s is not divisible by %d, or the height is not divisible by %d, which might cause visual bugs. +== + + unsupported +== + +The format of texture %s is not RGBA which will cause visual bugs. +== + +Preparing demo playback +== + +Connected +== Konektita + +Loading map file from storage +== Ŝargas mapdosieron el la diskaparato + +Loading DDNet Client +== Ŝargas DDNet + +Initializing components +== + +Initializing assets +== + +Initializing map logic +== + +Sending initial client info +== + +Warning +== Averto + +All +== Ĉio + +Team +== Teamo + +Chat +== Diskutejo + +-Page %d- +== -Paĝo %d- + +Debug mode enabled. Press Ctrl+Shift+D to disable debug mode. +== + +Game paused +== Paŭzata ludo + +Sudden Death +== + +Warmup +== Trejnado + +Connection Problems... +== Konekta problemoj... + +Please balance teams! +== Bonvolu ekvilibrigi teamojn! + +%ds left +== Restas %ds + +Reason: +== Kialo: + +Vote yes +== Voĉdoni jes + +Vote no +== Voĉdoni ne + +Position: +== + +Speed: +== Rapideco: + +Angle: +== + +Spectate +== Spekti + +Free-View +== Libera vidado + +Server best: +== + +Personal best: +== + +Uploading map data to GPU +== + +Reset +== + +News +== Novaĵoj + +Demos +== + +Internet +== Internet + +LAN +== LAN + +Favorites +== Favoratoj + +Game +== Ludo + +Players +== Ludantoj + +Server info +== Servila informoj + +Browser +== Retumilo + +Ghost +== Fantomo + +Call vote +== Voĉdoni + +Connecting to +== Konektas al + +Abort +== Nuligi + +Trying to determine UDP connectivity... +== + +UDP seems to be filtered. +== + +UDP and TCP IP addresses seem to be different. Try disabling VPN, proxy or network accelerators. +== + +No answer from server yet. +== + +Downloading map +== Elŝutas mapon + +Getting game info +== + +Requesting to join the game +== + +Disconnected +== Malkonektita + +Ok +== Okej + +Reconnect in %d sec +== Rekonektiĝos post %d sek + +The server is running a non-standard tuning on a pure game type. +== + +Delete demo +== + +Are you sure that you want to delete the demo? +== + +Rename demo +== + +Render demo +== + +Replace video +== + +File already exists, do you want to overwrite it? +== + +Remove friend +== + +Are you sure that you want to remove the player from your friends list? +== + +Sound error +== + +The audio device couldn't be initialised. +== + +Password incorrect +== + +Try again +== Reprovi + +Quit +== Eliri + +Are you sure that you want to quit? +== Ĉu vi certas eliri? + +Disconnect +== Malkonektiĝi + +Are you sure that you want to disconnect? +== Ĉu vi certas malkonektiĝi? + +Disconnect Dummy +== Malkonektigi pupon + +Are you sure that you want to disconnect your dummy? +== Ĉu vi certas malkonektiĝi vian pupon? + +Welcome to DDNet +== Bonvenon en DDNet + +DDraceNetwork is a cooperative online game where the goal is for you and your group of tees to reach the finish line of the map. As a newcomer you should start on Novice servers, which host the easiest maps. Consider the ping to choose a server close to you. +== + +Use k key to kill (restart), q to pause and watch other players. See settings for other key binds. +== + +It's recommended that you check the settings to adjust them to your liking before joining a server. +== + +Please enter your nickname below. +== Bonvolu tajpi vian kromnomon. + +Existing Player +== Ekzista ludanto + +Your nickname '%s' is already used (%d points). Do you still want to use it? +== Vian kromnomon '%s' estas jam uzata (%d poentoj). Ĉu vi tamen volas uzi ĝin? + +Checking for existing player with your name +== Kontrolas ekzistan ludanton kun via nomo + +Are you sure that you want to disconnect and switch to a different server? +== Ĉu vi certas malkonektiĝi kaj movi al alia servilo? + +There's an unsaved map in the editor, you might want to save it before you quit the game. +== Estas nesavata mapo en la redaktilo, vi eble volas savi ĝin antaŭ eliri la ludon. + +Quit anyway? +== Eliri tamen + +No +== Ne + +Yes +== Jes + +Password +== Pasvorto + +%i minute left +== Restas %i minuto + +%i minutes left +== Restas %i minutoj + +%i second left +== Restas %i sekundo + +%i seconds left +== Restas %i sekundoj + +Country / Region +== Lando / Regiono + +Error +== Eraro + +Unable to delete the demo +== + +Unable to rename the demo +== + +New name: +== Nova nomo: + +Destination file already exist +== + +Error loading demo +== + +Show chat +== Montri la diskutejon + +Use sounds +== Uzi sonojn + +Speed +== Rapideco + +Show ingame HUD +== + +Video name: +== + +Join Tutorial Server +== Aliĝi al la lernila servilo + +Skip Tutorial +== Pasi la lernilo + +Show DDNet map finishes in server browser +== + +transmits your player name to info2.ddnet.tw +== sendas vian ludantnomon al info2.ddnet.tw + +Nickname +== Kromnomo + +Theme +== Temo + +Loading menu images +== + +AFR +== AFR + +ASI +== AZI + +AUS +== AŬS + +EUR +== EŬR + +NA +== NA + +SA +== SA + +CHN +== ĈIN + +Type +== Tipo + +Getting server list from master server +== Elŝutas servilaro de ĉefa servilo + +No servers found +== Neniuj serviloj trovitaj + +No servers match your filter criteria +== Neniuj serviloj kun via filtro + +Search +== Serĉi + +Exclude +== Ekskludi + +%d of %d servers +== %d de %d serviloj + +%d of %d server +== %d de %d servilo + +%d players +== %d ludantoj + +%d player +== %d ludanto + +Server address: +== Retadreso de servilo: + +Refresh +== Aktualigi + +Refreshing... +== Aktualas... + +Connect +== Konektiĝi + +Server filter +== + +Has people playing +== + +Count players only +== Nur nombri ludantojn + +Server not full +== + +Show friends only +== Nur montri amikojn + +No password +== Neniu pasvorto + +Strict gametype filter +== + +Game types: +== Ludtipoj: + +Player country: +== + +Filter connecting players +== + +Indicate map finish +== + +Unfinished map +== + +Countries +== Landoj + +Types +== + +Reset filter +== + +Server details +== + +Favorite +== Favorati + +Leak IP +== + +Scoreboard +== + +Friends +== Amikoj + +Remove +== + +Name +== Nomo + +Clan +== Klano + +Add Friend +== Aldoni amikon + +Filter +== Filtri + +Info +== + +Select a name +== Elekti nomon + +Please use a different name +== Bonvolu uzi malsaman nomon + +Remove chat +== Malmontri la diskutejon + +Close +== Fermi + +Demofile: %s +== + +Loading demo files +== + +Parent Folder +== + +Folder +== Dosierujo + +Invalid Demo +== + +Demo details +== + +Created: +== + +Type: +== + +Length: +== + +Version: +== Versio: + +Markers: +== + +Map: +== Mapo: + +Size: +== + +%.2f MiB +== + +%.2f KiB +== + +Crc: +== + +Netversion: +== + +Demo +== + +Markers +== + +Length +== + +Date +== + +Fetch Info +== + +Open +== Malfermi + +[Demo browser] +Play +== Legi + +Demos directory +== + +Delete +== Forigi + +Rename +== Renomigi + +Render +== + +Connect Dummy +== Konektigi pupon + +Connecting dummy +== Pupo konektas + +Stop record +== + +Record demo +== + +Join red +== Aliĝi al ruĝa taemo + +Join blue +== Aliĝi al blua teamo + +Join game +== Aliĝi al la ludo + +Kill +== Mortiĝi + +Pause +== Paŭzi + +Player options +== Ludantaj agordoj + +Player +== Ludanto + +Address +== Retadreso + +Ping +== Latenco + +Version +== Versio + +Game info +== Ludaj informoj + +Game type +== Ludtipo + +Map +== Mapo + +Score limit +== + +Time limit +== + +MOTD +== MDLT + +Change settings +== Ŝanĝi agordojn + +Kick player +== Elirigi ludanton + +Move player to spectators +== Movi ludanton al spektantoj + +Force vote +== Forci voĉdonon + +Vote description: +== Voĉdona priskribo: + +Vote command: +== Voĉdona komando: + +Add +== Aldoni + +Loading ghost files +== + +Time +== Tempo + +Reload +== + +Deactivate +== + +Activate +== + +Save +== + +Dynamic Camera +== + +Smooth Dynamic Camera +== + +Switch weapon on pickup +== + +Switch weapon when out of ammo +== + +Client +== + +Skip the main menu +== + +Automatically record demos +== + +Max demos +== + +Automatically take game over screenshot +== + +Max Screenshots +== + +Refresh Rate +== + +Settings file +== + +Config directory +== + +Themes directory +== + +Automatically take statboard screenshot +== + +Automatically create statboard csv +== + +Max CSVs +== + +Dummy settings +== Agordoj de la pupo + +Your skin +== + +Toggle to edit your dummy settings +== + +Download skins +== + +Download community skins +== + +Vanilla skins only +== + +Fat skins (DDFat) +== + +Skin prefix +== + +Choose default eyes when joining a server +== + +Custom colors +== + +Body +== + +Feet +== + +Skins +== Haŭtoj + +Skin Database +== Datumbazo de haŭtoj + +Skins directory +== Dosierujo de haŭtoj + +Loading skin files +== + +Move left +== Movi maldekstren + +Move right +== Movi dekstren + +Jump +== Salti + +Fire +== Pafi + +Hook +== Hoki + +Hook collisions +== + +Zoom in +== + +Zoom out +== + +Default zoom +== + +Show others +== Montri aliaj + +Show all +== Montri ĉiuj + +Toggle dyncam +== + +Toggle dummy +== + +Toggle ghost +== + +Dummy copy +== + +Hammerfly dummy +== + +Hammer +== Martelo + +Pistol +== Pistolo + +Shotgun +== + +Grenade +== + +Laser +== Lasero + +Next weapon +== + +Prev. weapon +== + +Team chat +== + +Converse +== + +Emoticon +== + +Spectator mode +== + +Spectate next +== + +Spectate previous +== + +Console +== + +Remote console +== + +Screenshot +== + +Statboard +== + +Lock team +== + +Show entities +== + +Show HUD +== + +Chat command +== + +Enable controller +== + +Controller %d: %s +== + +Click to cycle through all available controllers. +== + +[Ingame controller mode] +Relative +== + +[Ingame controller mode] +Absolute +== + +Ingame controller mode +== + +Ingame controller sens. +== + +UI controller sens. +== + +Controller jitter tolerance +== + +No controller found. Plug in a controller and restart the game. +== + +Device +== + +Status +== + +Aim bind +== + +Controller Axis #%d +== + +Controls +== + +Mouse +== Muso + +Ingame mouse sens. +== + +UI mouse sens. +== + +Controller +== + +Movement +== + +Weapon +== Batalilo + +Reset to defaults +== + +Voting +== + +Dummy +== Pupo + +Miscellaneous +== + +Current +== + +Display Modes +== + +Windowed +== + +Windowed borderless +== + +Windowed fullscreen +== + +Desktop fullscreen +== + +Fullscreen +== + +V-Sync +== + +may cause delay +== + +Screen +== Ekrano + +FSAA samples +== + +High Detail +== + +Allows maps to render with more detail +== + +Use high DPI +== + +UI Color +== + +Renderer +== + +default +== defaŭlta + +custom +== + +Graphics cards +== + +auto +== aŭtomata + +Play background music +== + +Mute when not active +== + +Enable game sounds +== + +Enable gun sound +== + +Enable long pain sound (used when shooting in freeze) +== + +Enable server message sound +== + +Enable regular chat sound +== + +Enable team chat sound +== + +Enable highlighted chat sound +== + +Threaded sound loading +== + +Sample rate +== + +Sound volume +== + +Game sound volume +== + +Chat sound volume +== + +Map sound volume +== + +Background music volume +== + +Language +== Lingvo + +General +== Ĝenerala + +Appearance +== Aspekto + +Graphics +== Grafikoj + +Sound +== Sono + +DDNet +== DDNet + +Assets +== Bildoj + +DDNet Client needs to be restarted to complete update! +== Vi devas relanci DDNet por kompletigi la ĝisdatigon. + +You must restart the game for all settings to take effect. +== Vi devas relanci la ludon por aktivigi ĉiujn agordojn. + +Hue +== + +Sat. +== + +Lht. +== + +Alpha +== + +HUD +== + +Name Plate +== + +Hook Collisions +== + +Kill Messages +== + +Show health, shields and ammo +== + +Show name plates +== + +Show kill messages +== + +Show score +== + +Show votes window after voting +== + +DDRace HUD +== + +Use DDRace Scoreboard +== + +Show client IDs in scoreboard +== + +Show DDRace HUD +== + +Show jumps indicator +== + +Show dummy actions +== Montri la agojn de la pupo + +Show player position +== + +Show player speed +== + +Show player target angle +== + +Show freeze bars +== + +Opacity of freeze bars inside freeze +== + +Show names in chat in team colors +== + +Show only chat messages from friends +== + +Use old chat style +== + +Messages +== + +System message +== + +Highlighted message +== + +Team message +== Mesaĝo de teamo + +Friend message +== Mesaĝo de amiko + +Normal message +== Normala mesaĝo + +Client message +== + +Preview +== Antaŭrigardilo + +Name plates size +== + +Show clan above name plates +== + +Clan plates size +== + +Use team colors for name plates +== + +Show hook strength indicator +== + +Show other players' key presses +== + +Show local player's key presses +== + +Hook collision line +== + +Show other players' hook collision lines +== + +Hook collision line width +== + +Hook collision line opacity +== + +Colors of the hook collision line, in case of a possible collision with: +== + +Your movements are not taken into account when calculating the line colors +== + +Nothing hookable +== + +Something hookable +== + +A Tee +== Tejo + +Normal Color +== + +Highlight Color +== + +Laser Outline Color +== + +Laser Inner Color +== + +Save the best demo of each race +== + +Enable replays +== + +Default length: %d +== + +When you cross the start line, show a ghost tee replicating the movements of your best time +== + +Show ghost +== + +Save ghost +== + +Gameplay +== + +Overlay entities +== + +Size +== + +Show text entities +== + +Opacity +== + +Adjust the opacity of entities belonging to other teams, such as tees and nameplates +== + +Show others (own team only) +== + +Show quads +== + +Quads are used for background decoration +== + +AntiPing +== + +Tries to predict other entities to give a feel of low latency +== + +AntiPing: predict other players +== + +AntiPing: predict weapons +== + +AntiPing: predict grenade paths +== + +Old mouse mode +== + +Background +== + +Entities Background color +== + +Use current map as background +== + +Show tiles layers from BG map +== + +Regular Background Color +== + +Try fast HTTP map download first +== + +New random timeout code +== + +Run on join +== + +Chat command (e.g. showall 1) +== + +DDNet %s is available: +== DDNet %s estas disponebla: + +Update now +== Ĝisdatigi nun + +Updating... +== Ĝisdatiĝas... + +DDNet Client updated! +== + +No updates available +== + +Check now +== Kontroli nun + +Entities +== + +Emoticons +== + +Particles +== + +Extras +== + +Loading assets +== + +Assets directory +== + +Discord +== Diskordo + +https://ddnet.tw/discord +== https://ddnet.tw/discord + +Learn +== Lerni + +https://wiki.ddnet.tw/ +== https://wiki.ddnet.tw/ + +Tutorial +== Lernilo + +Can't find a Tutorial server +== + +Website +== Retejo + +Settings +== Agordoj + +Stop server +== Halti servilon + +Run server +== Lanci servilon + +Server executable not found, can't run server +== + +Editor +== Redaktilo + +[Start menu] +Play +== Ludi + +DDNet %s is out! +== DDNet %s estas disponebla! + +Downloading %s: +== Elŝutas %s: + +Update failed! Check log... +== + +Restart +== Relanci + +Loading race demo files +== + +Time limit: %d min +== + +Round +== + +Spectators +== Spektantoj + +Game over +== + +Score +== + +Super +== + +Team %d +== + +Manual +== + +Race +== + +Auto +== + +Replay +== + +Draw! +== + +%s wins! +== + +Red team wins! +== + +Blue team wins! +== + +Red team +== Ruĝa teamo + +Blue team +== Blua teamo + +Loading sound files +== + +Follow +== Sekvi + +Frags +== + +Deaths +== Mortoj + +Suicides +== + +Ratio +== + +Net +== + +FPM +== + +Spree +== + +Best +== + +Grabs +== + +1 new mention +== 1 nova mencio + +%d new mentions +== %d novaj mencioj + +9+ new mentions +== 9+ novaj mencioj diff --git a/data/languages/index.txt b/data/languages/index.txt index e964ad36aee..a266a0add6a 100644 --- a/data/languages/index.txt +++ b/data/languages/index.txt @@ -40,6 +40,10 @@ dutch == Nederlands == 528 +esperanto +== Esperanto +== -1 + finnish == Suomi == 246 diff --git a/src/engine/client/favorites.cpp b/src/engine/client/favorites.cpp index cbd9426d773..b2d570c6908 100644 --- a/src/engine/client/favorites.cpp +++ b/src/engine/client/favorites.cpp @@ -19,18 +19,18 @@ class CFavorites : public IFavorites void AllEntries(const CEntry **ppEntries, int *pNumEntries) override; private: - std::vector m_aEntries; + std::vector m_vEntries; std::unordered_map m_ByAddr; CEntry *Entry(const NETADDR &Addr); const CEntry *Entry(const NETADDR &Addr) const; - // `pEntry` must come from the `m_aEntries` vector. + // `pEntry` must come from the `m_vEntries` vector. void RemoveEntry(CEntry *pEntry); }; void CFavorites::OnConfigSave(IConfigManager *pConfigManager) { - for(const auto &Entry : m_aEntries) + for(const auto &Entry : m_vEntries) { if(Entry.m_NumAddrs > 1) { @@ -161,10 +161,10 @@ void CFavorites::Add(const NETADDR *pAddrs, int NumAddrs) for(int i = 0; i < NewEntry.m_NumAddrs; i++) { NewEntry.m_aAddrs[i] = pAddrs[i]; - m_ByAddr[pAddrs[i]] = m_aEntries.size(); + m_ByAddr[pAddrs[i]] = m_vEntries.size(); } NewEntry.m_AllowPing = false; - m_aEntries.push_back(NewEntry); + m_vEntries.push_back(NewEntry); } void CFavorites::AllowPing(const NETADDR *pAddrs, int NumAddrs, bool AllowPing) @@ -199,8 +199,8 @@ void CFavorites::Remove(const NETADDR *pAddrs, int NumAddrs) void CFavorites::AllEntries(const CEntry **ppEntries, int *pNumEntries) { - *ppEntries = m_aEntries.data(); - *pNumEntries = m_aEntries.size(); + *ppEntries = m_vEntries.data(); + *pNumEntries = m_vEntries.size(); } CFavorites::CEntry *CFavorites::Entry(const NETADDR &Addr) @@ -210,7 +210,7 @@ CFavorites::CEntry *CFavorites::Entry(const NETADDR &Addr) { return nullptr; } - return &m_aEntries[Entry->second]; + return &m_vEntries[Entry->second]; } const CFavorites::CEntry *CFavorites::Entry(const NETADDR &Addr) const @@ -220,16 +220,16 @@ const CFavorites::CEntry *CFavorites::Entry(const NETADDR &Addr) const { return nullptr; } - return &m_aEntries[Entry->second]; + return &m_vEntries[Entry->second]; } void CFavorites::RemoveEntry(CEntry *pEntry) { // Replace the entry - int Index = pEntry - &m_aEntries[0]; - *pEntry = m_aEntries[m_aEntries.size() - 1]; - m_aEntries.pop_back(); - if(Index != (int)m_aEntries.size()) + int Index = pEntry - m_vEntries.data(); + *pEntry = m_vEntries[m_vEntries.size() - 1]; + m_vEntries.pop_back(); + if(Index != (int)m_vEntries.size()) { for(int i = 0; i < pEntry->m_NumAddrs; i++) { diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index 8da0c1faa06..ef4ce6ca0cf 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -796,7 +796,7 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine) { // on demo playback use local id from snap directly, // since m_aLocalIDs isn't valid there - if(LineShouldHighlight(pLine, m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_aName)) + if(m_pClient->m_Snap.m_LocalClientID >= 0 && LineShouldHighlight(pLine, m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_aName)) Highlighted = true; } diff --git a/src/game/client/components/maplayers.cpp b/src/game/client/components/maplayers.cpp index e63f467be52..6c21603af28 100644 --- a/src/game/client/components/maplayers.cpp +++ b/src/game/client/components/maplayers.cpp @@ -94,15 +94,18 @@ void CMapLayers::EnvelopeEval(int TimeOffsetMillis, int Env, ColorRGBA &Channels } if(pItem->m_Version < 2 || pItem->m_Synchronized) { - // get the lerp of the current tick and prev - int MinTick = pThis->Client()->PrevGameTick(g_Config.m_ClDummy) - pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick; - int CurTick = pThis->Client()->GameTick(g_Config.m_ClDummy) - pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick; - s_Time = std::chrono::nanoseconds((int64_t)(mix( - 0, - (CurTick - MinTick), - (double)pThis->Client()->IntraGameTick(g_Config.m_ClDummy)) * - TickToNanoSeconds.count())) + - MinTick * TickToNanoSeconds; + if(pThis->m_pClient->m_Snap.m_pGameInfoObj) + { + // get the lerp of the current tick and prev + int MinTick = pThis->Client()->PrevGameTick(g_Config.m_ClDummy) - pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick; + int CurTick = pThis->Client()->GameTick(g_Config.m_ClDummy) - pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick; + s_Time = std::chrono::nanoseconds((int64_t)(mix( + 0, + (CurTick - MinTick), + (double)pThis->Client()->IntraGameTick(g_Config.m_ClDummy)) * + TickToNanoSeconds.count())) + + MinTick * TickToNanoSeconds; + } } else { diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 20563c3240d..575bb310d47 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -130,7 +130,7 @@ int CMenus::DoButton_Toggle(const void *pID, int Checked, const CUIRect *pRect, return Active ? UI()->DoButtonLogic(pID, Checked, pRect) : 0; } -int CMenus::DoButton_Menu(const void *pID, const char *pText, int Checked, const CUIRect *pRect, const char *pImageName, int Corners, float r, float FontFactor, vec4 ColorHot, vec4 Color, int AlignVertically, bool CheckForActiveColorPicker) +int CMenus::DoButton_Menu(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, const char *pImageName, int Corners, float r, float FontFactor, vec4 ColorHot, vec4 Color, int AlignVertically, bool CheckForActiveColorPicker) { CUIRect Text = *pRect; @@ -151,7 +151,7 @@ int CMenus::DoButton_Menu(const void *pID, const char *pText, int Checked, const } if(!MouseInsideColorPicker) - Color.a *= UI()->ButtonColorMul(pID); + Color.a *= UI()->ButtonColorMul(pButtonContainer); RenderTools()->DrawUIRect(pRect, Color, Corners, r); if(pImageName) @@ -163,7 +163,7 @@ int CMenus::DoButton_Menu(const void *pID, const char *pText, int Checked, const const CMenuImage *pImage = FindMenuImage(pImageName); if(pImage) { - Graphics()->TextureSet(UI()->HotItem() == pID ? pImage->m_OrgTexture : pImage->m_GreyTexture); + Graphics()->TextureSet(UI()->HotItem() == pButtonContainer ? pImage->m_OrgTexture : pImage->m_GreyTexture); Graphics()->WrapClamp(); Graphics()->QuadsBegin(); Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); @@ -183,7 +183,7 @@ int CMenus::DoButton_Menu(const void *pID, const char *pText, int Checked, const if(MouseInsideColorPicker) return 0; - return UI()->DoButtonLogic(pID, Checked, pRect); + return UI()->DoButtonLogic(pButtonContainer, Checked, pRect); } void CMenus::DoButton_KeySelect(const void *pID, const char *pText, int Checked, const CUIRect *pRect) @@ -194,7 +194,7 @@ void CMenus::DoButton_KeySelect(const void *pID, const char *pText, int Checked, UI()->DoLabel(&Temp, pText, Temp.h * CUI::ms_FontmodHeight, TEXTALIGN_CENTER); } -int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners, SUIAnimator *pAnimator, const ColorRGBA *pDefaultColor, const ColorRGBA *pActiveColor, const ColorRGBA *pHoverColor, float EdgeRounding, int AlignVertically) +int CMenus::DoButton_MenuTab(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, int Corners, SUIAnimator *pAnimator, const ColorRGBA *pDefaultColor, const ColorRGBA *pActiveColor, const ColorRGBA *pHoverColor, float EdgeRounding, int AlignVertically) { const bool MouseInside = UI()->MouseInside(pRect); CUIRect Rect = *pRect; @@ -273,7 +273,7 @@ int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, co Props.m_AlignVertically = AlignVertically; UI()->DoLabel(&Temp, pText, Temp.h * CUI::ms_FontmodHeight, TEXTALIGN_CENTER, Props); - return UI()->DoButtonLogic(pID, Checked, pRect); + return UI()->DoButtonLogic(pButtonContainer, Checked, pRect); } int CMenus::DoButton_GridHeader(const void *pID, const char *pText, int Checked, const CUIRect *pRect) @@ -367,7 +367,7 @@ void CMenus::DoLaserPreview(const CUIRect *pRect, const ColorHSLA LaserOutlineCo Graphics()->QuadsEnd(); } -ColorHSLA CMenus::DoLine_ColorPicker(int *pResetID, const float LineSize, const float WantedPickerPosition, const float LabelSize, const float BottomMargin, CUIRect *pMainRect, const char *pText, unsigned int *pColorValue, const ColorRGBA DefaultColor, bool CheckBoxSpacing, bool UseCheckBox, int *pCheckBoxValue) +ColorHSLA CMenus::DoLine_ColorPicker(CButtonContainer *pResetID, const float LineSize, const float WantedPickerPosition, const float LabelSize, const float BottomMargin, CUIRect *pMainRect, const char *pText, unsigned int *pColorValue, const ColorRGBA DefaultColor, bool CheckBoxSpacing, bool UseCheckBox, int *pCheckBoxValue) { CUIRect Section, Button, Label; @@ -657,7 +657,7 @@ int CMenus::RenderMenubar(CUIRect r) if(Client()->State() == IClient::STATE_OFFLINE) { Box.VSplitLeft(33.0f, &Button, &Box); - static int s_StartButton = 0; + static CButtonContainer s_StartButton; TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); @@ -703,7 +703,7 @@ int CMenus::RenderMenubar(CUIRect r) if(m_ActivePage == PAGE_NEWS) { Box.VSplitLeft(100.0f, &Button, &Box); - static int s_NewsButton = 0; + static CButtonContainer s_NewsButton; if(DoButton_MenuTab(&s_NewsButton, Localize("News"), m_ActivePage == PAGE_NEWS, &Button, CUI::CORNER_T, &m_aAnimatorsBigPage[BIG_TAB_NEWS])) { NewPage = PAGE_NEWS; @@ -713,7 +713,7 @@ int CMenus::RenderMenubar(CUIRect r) else if(m_ActivePage == PAGE_DEMOS) { Box.VSplitLeft(100.0f, &Button, &Box); - static int s_DemosButton = 0; + static CButtonContainer s_DemosButton; if(DoButton_MenuTab(&s_DemosButton, Localize("Demos"), m_ActivePage == PAGE_DEMOS, &Button, CUI::CORNER_T, &m_aAnimatorsBigPage[BIG_TAB_DEMOS])) { DemolistPopulate(); @@ -724,7 +724,7 @@ int CMenus::RenderMenubar(CUIRect r) else { Box.VSplitLeft(100.0f, &Button, &Box); - static int s_InternetButton = 0; + static CButtonContainer s_InternetButton; if(DoButton_MenuTab(&s_InternetButton, Localize("Internet"), m_ActivePage == PAGE_INTERNET, &Button, CUI::CORNER_T, &m_aAnimatorsBigPage[BIG_TAB_INTERNET])) { if(ServerBrowser()->GetCurrentType() != IServerBrowser::TYPE_INTERNET) @@ -734,7 +734,7 @@ int CMenus::RenderMenubar(CUIRect r) } Box.VSplitLeft(100.0f, &Button, &Box); - static int s_LanButton = 0; + static CButtonContainer s_LanButton; if(DoButton_MenuTab(&s_LanButton, Localize("LAN"), m_ActivePage == PAGE_LAN, &Button, CUI::CORNER_T, &m_aAnimatorsBigPage[BIG_TAB_LAN])) { if(ServerBrowser()->GetCurrentType() != IServerBrowser::TYPE_LAN) @@ -744,7 +744,7 @@ int CMenus::RenderMenubar(CUIRect r) } Box.VSplitLeft(100.0f, &Button, &Box); - static int s_FavoritesButton = 0; + static CButtonContainer s_FavoritesButton; if(DoButton_MenuTab(&s_FavoritesButton, Localize("Favorites"), m_ActivePage == PAGE_FAVORITES, &Button, CUI::CORNER_T, &m_aAnimatorsBigPage[BIG_TAB_FAVORITES])) { if(ServerBrowser()->GetCurrentType() != IServerBrowser::TYPE_FAVORITES) @@ -754,7 +754,7 @@ int CMenus::RenderMenubar(CUIRect r) } Box.VSplitLeft(90.0f, &Button, &Box); - static int s_DDNetButton = 0; + static CButtonContainer s_DDNetButton; if(DoButton_MenuTab(&s_DDNetButton, "DDNet", m_ActivePage == PAGE_DDNET, &Button, CUI::CORNER_T, &m_aAnimatorsBigPage[BIG_TAB_DDNET])) { if(ServerBrowser()->GetCurrentType() != IServerBrowser::TYPE_DDNET) @@ -767,7 +767,7 @@ int CMenus::RenderMenubar(CUIRect r) } Box.VSplitLeft(90.0f, &Button, &Box); - static int s_KoGButton = 0; + static CButtonContainer s_KoGButton; if(DoButton_MenuTab(&s_KoGButton, "KoG", m_ActivePage == PAGE_KOG, &Button, CUI::CORNER_T, &m_aAnimatorsBigPage[BIG_TAB_KOG])) { if(ServerBrowser()->GetCurrentType() != IServerBrowser::TYPE_KOG) @@ -784,27 +784,27 @@ int CMenus::RenderMenubar(CUIRect r) { // online menus Box.VSplitLeft(90.0f, &Button, &Box); - static int s_GameButton = 0; + static CButtonContainer s_GameButton; if(DoButton_MenuTab(&s_GameButton, Localize("Game"), m_ActivePage == PAGE_GAME, &Button, CUI::CORNER_TL)) NewPage = PAGE_GAME; Box.VSplitLeft(90.0f, &Button, &Box); - static int s_PlayersButton = 0; + static CButtonContainer s_PlayersButton; if(DoButton_MenuTab(&s_PlayersButton, Localize("Players"), m_ActivePage == PAGE_PLAYERS, &Button, 0)) NewPage = PAGE_PLAYERS; Box.VSplitLeft(130.0f, &Button, &Box); - static int s_ServerInfoButton = 0; + static CButtonContainer s_ServerInfoButton; if(DoButton_MenuTab(&s_ServerInfoButton, Localize("Server info"), m_ActivePage == PAGE_SERVER_INFO, &Button, 0)) NewPage = PAGE_SERVER_INFO; Box.VSplitLeft(90.0f, &Button, &Box); - static int s_NetworkButton = 0; + static CButtonContainer s_NetworkButton; if(DoButton_MenuTab(&s_NetworkButton, Localize("Browser"), m_ActivePage == PAGE_NETWORK, &Button, 0)) NewPage = PAGE_NETWORK; { - static int s_GhostButton = 0; + static CButtonContainer s_GhostButton; if(GameClient()->m_GameInfo.m_Race) { Box.VSplitLeft(90.0f, &Button, &Box); @@ -815,7 +815,7 @@ int CMenus::RenderMenubar(CUIRect r) Box.VSplitLeft(100.0f, &Button, &Box); Box.VSplitLeft(4.0f, 0, &Box); - static int s_CallVoteButton = 0; + static CButtonContainer s_CallVoteButton; if(DoButton_MenuTab(&s_CallVoteButton, Localize("Call vote"), m_ActivePage == PAGE_CALLVOTE, &Button, CUI::CORNER_TR)) { NewPage = PAGE_CALLVOTE; @@ -827,7 +827,7 @@ int CMenus::RenderMenubar(CUIRect r) TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); Box.VSplitRight(33.0f, &Box, &Button); - static int s_QuitButton = 0; + static CButtonContainer s_QuitButton; ColorRGBA QuitColor(1, 0, 0, 0.5f); if(DoButton_MenuTab(&s_QuitButton, "\xEF\x80\x91", 0, &Button, CUI::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_QUIT], NULL, NULL, &QuitColor, 10.0f, 0)) { @@ -843,14 +843,14 @@ int CMenus::RenderMenubar(CUIRect r) Box.VSplitRight(10.0f, &Box, &Button); Box.VSplitRight(33.0f, &Box, &Button); - static int s_SettingsButton = 0; + static CButtonContainer s_SettingsButton; if(DoButton_MenuTab(&s_SettingsButton, "\xEF\x80\x93", m_ActivePage == PAGE_SETTINGS, &Button, CUI::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_SETTINGS], NULL, NULL, NULL, 10.0f, 0)) NewPage = PAGE_SETTINGS; Box.VSplitRight(10.0f, &Box, &Button); Box.VSplitRight(33.0f, &Box, &Button); - static int s_EditorButton = 0; + static CButtonContainer s_EditorButton; if(DoButton_MenuTab(&s_EditorButton, "\xEF\x81\x84", 0, &Button, CUI::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_EDITOR], NULL, NULL, NULL, 10.0f, 0)) { g_Config.m_ClEditor = 1; @@ -860,14 +860,14 @@ int CMenus::RenderMenubar(CUIRect r) { Box.VSplitRight(10.0f, &Box, &Button); Box.VSplitRight(33.0f, &Box, &Button); - static int s_DemoButton = 0; + static CButtonContainer s_DemoButton; if(DoButton_MenuTab(&s_DemoButton, "\xEE\x84\xB1", m_ActivePage == PAGE_DEMOS, &Button, CUI::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_DEMOBUTTON], NULL, NULL, NULL, 10.0f, 0)) NewPage = PAGE_DEMOS; Box.VSplitRight(10.0f, &Box, &Button); Box.VSplitRight(33.0f, &Box, &Button); - static int s_ServerButton = 0; + static CButtonContainer s_ServerButton; if(DoButton_MenuTab(&s_ServerButton, "\xEF\x95\xBD", m_ActivePage == g_Config.m_UiPage, &Button, CUI::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_SERVER], NULL, NULL, NULL, 10.0f, 0)) NewPage = g_Config.m_UiPage; @@ -1695,11 +1695,11 @@ int CMenus::Render() Yes.VMargin(20.0f, &Yes); No.VMargin(20.0f, &No); - static int s_ButtonAbort = 0; + static CButtonContainer s_ButtonAbort; if(DoButton_Menu(&s_ButtonAbort, Localize("No"), 0, &No) || m_EscapePressed) m_Popup = POPUP_NONE; - static int s_ButtonTryAgain = 0; + static CButtonContainer s_ButtonTryAgain; if(DoButton_Menu(&s_ButtonTryAgain, Localize("Yes"), 0, &Yes) || m_EnterPressed) { m_Popup = POPUP_NONE; @@ -1718,11 +1718,11 @@ int CMenus::Render() Yes.VMargin(20.0f, &Yes); No.VMargin(20.0f, &No); - static int s_ButtonAbort = 0; + static CButtonContainer s_ButtonAbort; if(DoButton_Menu(&s_ButtonAbort, Localize("No"), 0, &No) || m_EscapePressed) m_Popup = POPUP_NONE; - static int s_ButtonTryAgain = 0; + static CButtonContainer s_ButtonTryAgain; if(DoButton_Menu(&s_ButtonTryAgain, Localize("Yes"), 0, &Yes) || m_EnterPressed) Client()->Disconnect(); } @@ -1738,11 +1738,11 @@ int CMenus::Render() Yes.VMargin(20.0f, &Yes); No.VMargin(20.0f, &No); - static int s_ButtonAbort = 0; + static CButtonContainer s_ButtonAbort; if(DoButton_Menu(&s_ButtonAbort, Localize("No"), 0, &No) || m_EscapePressed) m_Popup = POPUP_NONE; - static int s_ButtonTryAgain = 0; + static CButtonContainer s_ButtonTryAgain; if(DoButton_Menu(&s_ButtonTryAgain, Localize("Yes"), 0, &Yes) || m_EnterPressed) { Client()->DummyDisconnect(0); @@ -1763,11 +1763,11 @@ int CMenus::Render() TryAgain.VMargin(20.0f, &TryAgain); Abort.VMargin(20.0f, &Abort); - static int s_ButtonAbort = 0; + static CButtonContainer s_ButtonAbort; if(DoButton_Menu(&s_ButtonAbort, Localize("Abort"), 0, &Abort) || m_EscapePressed) m_Popup = POPUP_NONE; - static int s_ButtonTryAgain = 0; + static CButtonContainer s_ButtonTryAgain; if(DoButton_Menu(&s_ButtonTryAgain, Localize("Try again"), 0, &TryAgain) || m_EnterPressed) { Client()->Connect(g_Config.m_UiServerAddress, g_Config.m_Password); @@ -1792,7 +1792,7 @@ int CMenus::Render() Box.HSplitBottom(24.f, &Box, &Part); Part.VMargin(120.0f, &Part); - static int s_Button = 0; + static CButtonContainer s_Button; if(DoButton_Menu(&s_Button, pButtonText, 0, &Part) || m_EscapePressed || (m_EnterPressed && m_Popup != POPUP_CONNECTING)) { Client()->Disconnect(); @@ -1862,7 +1862,7 @@ int CMenus::Render() RenderLanguageSelection(Box); Part.VMargin(120.0f, &Part); - static int s_Button = 0; + static CButtonContainer s_Button; if(DoButton_Menu(&s_Button, Localize("Ok"), 0, &Part) || m_EscapePressed || m_EnterPressed) m_Popup = POPUP_FIRST_LAUNCH; } @@ -1910,7 +1910,7 @@ int CMenus::Render() Part.VMargin(120.0f, &Part); - static int s_Button = 0; + static CButtonContainer s_Button; if(DoButton_Menu(&s_Button, Localize("Ok"), 0, &Part) || m_EnterPressed) { g_Config.m_BrFilterCountryIndex = CurSelection; @@ -1936,11 +1936,11 @@ int CMenus::Render() Yes.VMargin(20.0f, &Yes); No.VMargin(20.0f, &No); - static int s_ButtonAbort = 0; + static CButtonContainer s_ButtonAbort; if(DoButton_Menu(&s_ButtonAbort, Localize("No"), 0, &No) || m_EscapePressed) m_Popup = POPUP_NONE; - static int s_ButtonTryAgain = 0; + static CButtonContainer s_ButtonTryAgain; if(DoButton_Menu(&s_ButtonTryAgain, Localize("Yes"), 0, &Yes) || m_EnterPressed) { m_Popup = POPUP_NONE; @@ -1971,11 +1971,11 @@ int CMenus::Render() Ok.VMargin(20.0f, &Ok); Abort.VMargin(20.0f, &Abort); - static int s_ButtonAbort = 0; + static CButtonContainer s_ButtonAbort; if(DoButton_Menu(&s_ButtonAbort, Localize("Abort"), 0, &Abort) || m_EscapePressed) m_Popup = POPUP_NONE; - static int s_ButtonOk = 0; + static CButtonContainer s_ButtonOk; if(DoButton_Menu(&s_ButtonOk, Localize("Ok"), 0, &Ok) || m_EnterPressed) { m_Popup = POPUP_NONE; @@ -2030,11 +2030,11 @@ int CMenus::Render() Ok.VMargin(20.0f, &Ok); Abort.VMargin(20.0f, &Abort); - static int s_ButtonAbort = 0; + static CButtonContainer s_ButtonAbort; if(DoButton_Menu(&s_ButtonAbort, Localize("Abort"), 0, &Abort) || m_EscapePressed) m_Popup = POPUP_NONE; - static int s_ButtonOk = 0; + static CButtonContainer s_ButtonOk; if(DoButton_Menu(&s_ButtonOk, Localize("Ok"), 0, &Ok) || m_EnterPressed) { m_Popup = POPUP_NONE; @@ -2093,14 +2093,14 @@ int CMenus::Render() // slowdown Part.VSplitLeft(5.0f, 0, &Part); Part.VSplitLeft(ButtonSize, &Button, &Part); - static int s_SlowDownButton = 0; + static CButtonContainer s_SlowDownButton; if(DoButton_Sprite(&s_SlowDownButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_SLOWER, 0, &Button, CUI::CORNER_ALL)) DecDemoSpeed = true; // fastforward Part.VSplitLeft(5.0f, 0, &Part); Part.VSplitLeft(ButtonSize, &Button, &Part); - static int s_FastForwardButton = 0; + static CButtonContainer s_FastForwardButton; if(DoButton_Sprite(&s_FastForwardButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_FASTER, 0, &Button, CUI::CORNER_ALL)) IncDemoSpeed = true; @@ -2150,11 +2150,11 @@ int CMenus::Render() Yes.VMargin(20.0f, &Yes); No.VMargin(20.0f, &No); - static int s_ButtonAbort = 0; + static CButtonContainer s_ButtonAbort; if(DoButton_Menu(&s_ButtonAbort, Localize("No"), 0, &No) || m_EscapePressed) m_Popup = POPUP_RENDER_DEMO; - static int s_ButtonTryAgain = 0; + static CButtonContainer s_ButtonTryAgain; if(DoButton_Menu(&s_ButtonTryAgain, Localize("Yes"), 0, &Yes) || m_EnterPressed) { m_Popup = POPUP_NONE; @@ -2179,11 +2179,11 @@ int CMenus::Render() Yes.VMargin(20.0f, &Yes); No.VMargin(20.0f, &No); - static int s_ButtonAbort = 0; + static CButtonContainer s_ButtonAbort; if(DoButton_Menu(&s_ButtonAbort, Localize("No"), 0, &No) || m_EscapePressed) m_Popup = POPUP_NONE; - static int s_ButtonTryAgain = 0; + static CButtonContainer s_ButtonTryAgain; if(DoButton_Menu(&s_ButtonTryAgain, Localize("Yes"), 0, &Yes) || m_EnterPressed) { m_Popup = POPUP_NONE; @@ -2208,7 +2208,7 @@ int CMenus::Render() Skip.VMargin(20.0f, &Skip); Join.VMargin(20.0f, &Join); - static int s_JoinTutorialButton = 0; + static CButtonContainer s_JoinTutorialButton; if(DoButton_Menu(&s_JoinTutorialButton, Localize("Join Tutorial Server"), 0, &Join) || m_EnterPressed) { m_JoinTutorial = true; @@ -2216,7 +2216,7 @@ int CMenus::Render() m_Popup = g_Config.m_BrIndicateFinished ? POPUP_POINTS : POPUP_NONE; } - static int s_SkipTutorialButton = 0; + static CButtonContainer s_SkipTutorialButton; if(DoButton_Menu(&s_SkipTutorialButton, Localize("Skip Tutorial"), 0, &Skip) || m_EscapePressed) { m_JoinTutorial = false; @@ -2261,11 +2261,11 @@ int CMenus::Render() Yes.VMargin(20.0f, &Yes); No.VMargin(20.0f, &No); - static int s_ButtonNo = 0; + static CButtonContainer s_ButtonNo; if(DoButton_Menu(&s_ButtonNo, Localize("No"), 0, &No) || m_EscapePressed) m_Popup = POPUP_FIRST_LAUNCH; - static int s_ButtonYes = 0; + static CButtonContainer s_ButtonYes; if(DoButton_Menu(&s_ButtonYes, Localize("Yes"), 0, &Yes) || m_EnterPressed) m_Popup = POPUP_NONE; } @@ -2275,7 +2275,7 @@ int CMenus::Render() Box.HSplitBottom(24.f, &Box, &Part); Part.VMargin(120.0f, &Part); - static int s_Button = 0; + static CButtonContainer s_Button; if(DoButton_Menu(&s_Button, pButtonText, 0, &Part) || m_EscapePressed || m_EnterPressed || (time_get_nanoseconds() - m_PopupWarningLastTime >= m_PopupWarningDuration)) { m_Popup = POPUP_NONE; @@ -2294,14 +2294,14 @@ int CMenus::Render() Yes.VMargin(20.0f, &Yes); No.VMargin(20.0f, &No); - static int s_ButtonAbort = 0; + static CButtonContainer s_ButtonAbort; if(DoButton_Menu(&s_ButtonAbort, Localize("No"), 0, &No) || m_EscapePressed) { m_Popup = POPUP_NONE; m_aNextServer[0] = '\0'; } - static int s_ButtonTryAgain = 0; + static CButtonContainer s_ButtonTryAgain; if(DoButton_Menu(&s_ButtonTryAgain, Localize("Yes"), 0, &Yes) || m_EnterPressed) Client()->Connect(m_aNextServer); } @@ -2311,7 +2311,7 @@ int CMenus::Render() Box.HSplitBottom(24.f, &Box, &Part); Part.VMargin(120.0f, &Part); - static int s_Button = 0; + static CButtonContainer s_Button; if(DoButton_Menu(&s_Button, pButtonText, 0, &Part) || m_EscapePressed || m_EnterPressed) { if(m_Popup == POPUP_DISCONNECTED && Client()->m_ReconnectTime > 0) diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index 37caad03207..5adbedfdf7f 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -83,16 +83,16 @@ class CMenus : public CComponent CUIEx *UIEx() { return &m_UIEx; } int DoButton_DemoPlayer(const void *pID, const char *pText, int Checked, const CUIRect *pRect); - int DoButton_Sprite(const void *pID, int ImageID, int SpriteID, int Checked, const CUIRect *pRect, int Corners); + int DoButton_Sprite(CButtonContainer *pButtonContainer, int ImageID, int SpriteID, int Checked, const CUIRect *pRect, int Corners); int DoButton_Toggle(const void *pID, int Checked, const CUIRect *pRect, bool Active); - int DoButton_Menu(const void *pID, const char *pText, int Checked, const CUIRect *pRect, const char *pImageName = nullptr, int Corners = CUI::CORNER_ALL, float r = 5.0f, float FontFactor = 0.0f, vec4 ColorHot = vec4(1.0f, 1.0f, 1.0f, 0.75f), vec4 Color = vec4(1, 1, 1, 0.5f), int AlignVertically = 1, bool CheckForActiveColorPicker = false); - int DoButton_MenuTab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners, SUIAnimator *pAnimator = nullptr, const ColorRGBA *pDefaultColor = nullptr, const ColorRGBA *pActiveColor = nullptr, const ColorRGBA *pHoverColor = nullptr, float EdgeRounding = 10, int AlignVertically = 1); + int DoButton_Menu(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, const char *pImageName = nullptr, int Corners = CUI::CORNER_ALL, float r = 5.0f, float FontFactor = 0.0f, vec4 ColorHot = vec4(1.0f, 1.0f, 1.0f, 0.75f), vec4 Color = vec4(1, 1, 1, 0.5f), int AlignVertically = 1, bool CheckForActiveColorPicker = false); + int DoButton_MenuTab(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, int Corners, SUIAnimator *pAnimator = nullptr, const ColorRGBA *pDefaultColor = nullptr, const ColorRGBA *pActiveColor = nullptr, const ColorRGBA *pHoverColor = nullptr, float EdgeRounding = 10, int AlignVertically = 1); int DoButton_CheckBox_Common(const void *pID, const char *pText, const char *pBoxText, const CUIRect *pRect); int DoButton_CheckBox(const void *pID, const char *pText, int Checked, const CUIRect *pRect); int DoButton_CheckBoxAutoVMarginAndSet(const void *pID, const char *pText, int *pValue, CUIRect *pRect, float VMargin); int DoButton_CheckBox_Number(const void *pID, const char *pText, int Checked, const CUIRect *pRect); - ColorHSLA DoLine_ColorPicker(int *pResetID, float LineSize, float WantedPickerPosition, float LabelSize, float BottomMargin, CUIRect *pMainRect, const char *pText, unsigned int *pColorValue, ColorRGBA DefaultColor, bool CheckBoxSpacing = true, bool UseCheckBox = false, int *pCheckBoxValue = nullptr); + ColorHSLA DoLine_ColorPicker(CButtonContainer *pResetID, float LineSize, float WantedPickerPosition, float LabelSize, float BottomMargin, CUIRect *pMainRect, const char *pText, unsigned int *pColorValue, ColorRGBA DefaultColor, bool CheckBoxSpacing = true, bool UseCheckBox = false, int *pCheckBoxValue = nullptr); void DoLaserPreview(const CUIRect *pRect, ColorHSLA OutlineColor, ColorHSLA InnerColor); int DoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, bool UseScroll, int Current, int Min, int Max, int Step, float Scale, bool IsHex, float Round, ColorRGBA *pColor); int DoButton_GridHeader(const void *pID, const char *pText, int Checked, const CUIRect *pRect); @@ -726,7 +726,7 @@ class CMenus : public CComponent ColorHSLA RenderHSLColorPicker(const CUIRect *pRect, unsigned int *pColor, bool Alpha); ColorHSLA RenderHSLScrollbars(CUIRect *pRect, unsigned int *pColor, bool Alpha = false, bool ClampedLight = false); - int RenderDropDown(int &CurDropDownState, CUIRect *pRect, int CurSelection, const void **pIDs, const char **pStr, int PickNum, const void *pID, float &ScrollVal); + int RenderDropDown(int &CurDropDownState, CUIRect *pRect, int CurSelection, const void **pIDs, const char **pStr, int PickNum, CButtonContainer *pButtonContainer, float &ScrollVal); CServerProcess m_ServerProcess; }; diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index 95adf11e1f4..a6dd54ef264 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -803,13 +803,13 @@ void CMenus::RenderServerbrowserFilters(CUIRect View) static int s_ActivePage = 0; - static int s_CountriesButton = 0; + static CButtonContainer s_CountriesButton; if(DoButton_MenuTab(&s_CountriesButton, Localize("Countries"), s_ActivePage == 0, &Button, CUI::CORNER_TL)) { s_ActivePage = 0; } - static int s_TypesButton = 0; + static CButtonContainer s_TypesButton; if(DoButton_MenuTab(&s_TypesButton, Localize("Types"), s_ActivePage == 1, &Button2, CUI::CORNER_TR)) { s_ActivePage = 1; @@ -1006,7 +1006,7 @@ void CMenus::RenderServerbrowserFilters(CUIRect View) } } - static int s_ClearButton = 0; + static CButtonContainer s_ClearButton; if(DoButton_Menu(&s_ClearButton, Localize("Reset filter"), 0, &ResetButton)) { g_Config.m_BrFilterString[0] = 0; @@ -1342,7 +1342,7 @@ void CMenus::RenderServerbrowserFriends(CUIRect View) ServerFriends.HSplitTop(20.0f, &Button, &ServerFriends); if(m_FriendlistSelectedIndex != -1) { - static int s_RemoveButton = 0; + static CButtonContainer s_RemoveButton; if(DoButton_Menu(&s_RemoveButton, Localize("Remove"), 0, &Button)) m_Popup = POPUP_REMOVE_FRIEND; } @@ -1371,7 +1371,7 @@ void CMenus::RenderServerbrowserFriends(CUIRect View) ServerFriends.HSplitTop(3.0f, 0, &ServerFriends); ServerFriends.HSplitTop(20.0f, &Button, &ServerFriends); - static int s_AddButton = 0; + static CButtonContainer s_AddButton; if(DoButton_Menu(&s_AddButton, Localize("Add Friend"), 0, &Button)) { m_pClient->Friends()->AddFriend(s_aName, s_aClan); @@ -1437,15 +1437,15 @@ void CMenus::RenderServerbrowser(CUIRect MainView) ms_ColorTabbarActive = ColorRGBA(0.0f, 0.0f, 0.0f, 0.3f); ms_ColorTabbarInactive = ColorRGBA(0.0f, 0.0f, 0.0f, 0.15f); - static int s_FiltersTab = 0; + static CButtonContainer s_FiltersTab; if(DoButton_MenuTab(&s_FiltersTab, Localize("Filter"), ToolboxPage == 0, &TabButton0, CUI::CORNER_BL, NULL, NULL, NULL, NULL, 4.0f)) ToolboxPage = 0; - static int s_InfoTab = 0; + static CButtonContainer s_InfoTab; if(DoButton_MenuTab(&s_InfoTab, Localize("Info"), ToolboxPage == 1, &TabButton1, 0, NULL, NULL, NULL, NULL, 4.0f)) ToolboxPage = 1; - static int s_FriendsTab = 0; + static CButtonContainer s_FriendsTab; if(DoButton_MenuTab(&s_FriendsTab, Localize("Friends"), ToolboxPage == 2, &TabButton2, CUI::CORNER_BR, NULL, NULL, NULL, NULL, 4.0f)) ToolboxPage = 2; diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index aca2f5415a3..9179ce54d35 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -34,9 +34,9 @@ int CMenus::DoButton_DemoPlayer(const void *pID, const char *pText, int Checked, return UI()->DoButtonLogic(pID, Checked, pRect); } -int CMenus::DoButton_Sprite(const void *pID, int ImageID, int SpriteID, int Checked, const CUIRect *pRect, int Corners) +int CMenus::DoButton_Sprite(CButtonContainer *pButtonContainer, int ImageID, int SpriteID, int Checked, const CUIRect *pRect, int Corners) { - RenderTools()->DrawUIRect(pRect, ColorRGBA(1.0f, 1.0f, 1.0f, (Checked ? 0.10f : 0.5f) * UI()->ButtonColorMul(pID)), Corners, 5.0f); + RenderTools()->DrawUIRect(pRect, ColorRGBA(1.0f, 1.0f, 1.0f, (Checked ? 0.10f : 0.5f) * UI()->ButtonColorMul(pButtonContainer)), Corners, 5.0f); Graphics()->TextureSet(g_pData->m_aImages[ImageID].m_Id); Graphics()->QuadsBegin(); if(!Checked) @@ -46,7 +46,7 @@ int CMenus::DoButton_Sprite(const void *pID, int ImageID, int SpriteID, int Chec Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsEnd(); - return UI()->DoButtonLogic(pID, Checked, pRect); + return UI()->DoButtonLogic(pButtonContainer, Checked, pRect); } bool CMenus::DemoFilterChat(const void *pData, int Size, void *pUser) @@ -110,11 +110,11 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) static int s_RemoveChat = 0; - static int s_ButtonAbort = 0; + static CButtonContainer s_ButtonAbort; if(DoButton_Menu(&s_ButtonAbort, Localize("Abort"), 0, &Abort) || m_EscapePressed) m_DemoPlayerState = DEMOPLAYER_NONE; - static int s_ButtonOk = 0; + static CButtonContainer s_ButtonOk; if(DoButton_Menu(&s_ButtonOk, Localize("Ok"), 0, &Ok) || m_EnterPressed) { if(str_comp(m_vDemos[m_DemolistSelectedIndex].m_aFilename, m_aCurrentDemoFile) == 0) @@ -392,7 +392,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) // combined play and pause button ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); - static int s_PlayPauseButton = 0; + static CButtonContainer s_PlayPauseButton; if(DoButton_Sprite(&s_PlayPauseButton, IMAGE_DEMOBUTTONS, pInfo->m_Paused ? SPRITE_DEMOBUTTON_PLAY : SPRITE_DEMOBUTTON_PAUSE, false, &Button, CUI::CORNER_ALL)) { if(pInfo->m_Paused) @@ -409,7 +409,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) ButtonBar.VSplitLeft(Margins, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); - static int s_ResetButton = 0; + static CButtonContainer s_ResetButton; if(DoButton_Sprite(&s_ResetButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_STOP, false, &Button, CUI::CORNER_ALL)) { DemoPlayer()->Pause(); @@ -419,14 +419,14 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) // slowdown ButtonBar.VSplitLeft(Margins, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); - static int s_SlowDownButton = 0; + static CButtonContainer s_SlowDownButton; if(DoButton_Sprite(&s_SlowDownButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_SLOWER, 0, &Button, CUI::CORNER_ALL)) DecreaseDemoSpeed = true; // fastforward ButtonBar.VSplitLeft(Margins, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); - static int s_FastForwardButton = 0; + static CButtonContainer s_FastForwardButton; if(DoButton_Sprite(&s_FastForwardButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_FASTER, 0, &Button, CUI::CORNER_ALL)) IncreaseDemoSpeed = true; @@ -439,21 +439,21 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) // slice begin button ButtonBar.VSplitLeft(Margins * 10, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); - static int s_SliceBeginButton = 0; + static CButtonContainer s_SliceBeginButton; if(DoButton_Sprite(&s_SliceBeginButton, IMAGE_DEMOBUTTONS2, SPRITE_DEMOBUTTON_SLICE_BEGIN, 0, &Button, CUI::CORNER_ALL)) Client()->DemoSliceBegin(); // slice end button ButtonBar.VSplitLeft(Margins, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); - static int s_SliceEndButton = 0; + static CButtonContainer s_SliceEndButton; if(DoButton_Sprite(&s_SliceEndButton, IMAGE_DEMOBUTTONS2, SPRITE_DEMOBUTTON_SLICE_END, 0, &Button, CUI::CORNER_ALL)) Client()->DemoSliceEnd(); // slice save button ButtonBar.VSplitLeft(Margins, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); - static int s_SliceSaveButton = 0; + static CButtonContainer s_SliceSaveButton; if(DoButton_Sprite(&s_SliceSaveButton, IMAGE_FILEICONS, SPRITE_FILE_DEMO2, 0, &Button, CUI::CORNER_ALL)) { str_copy(m_aCurrentDemoFile, m_vDemos[m_DemolistSelectedIndex].m_aFilename); @@ -473,7 +473,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) // toggle keyboard shortcuts button ButtonBar.VSplitRight(Margins * 3, &ButtonBar, 0); ButtonBar.VSplitRight(ButtonbarHeight, &ButtonBar, &Button); - static int s_KeyboardShortcutsButton = 0; + static CButtonContainer s_KeyboardShortcutsButton; int Sprite = g_Config.m_ClDemoKeyboardShortcuts ? SPRITE_DEMOBUTTON_SHORTCUTS_ENABLED : SPRITE_DEMOBUTTON_SHORTCUTS_DISABLED; if(DoButton_Sprite(&s_KeyboardShortcutsButton, IMAGE_DEMOBUTTONS2, Sprite, 0, &Button, CUI::CORNER_ALL)) { @@ -1203,7 +1203,7 @@ void CMenus::RenderDemoList(CUIRect MainView) Activated = true; } - static int s_RefreshButton = 0; + static CButtonContainer s_RefreshButton; if(DoButton_Menu(&s_RefreshButton, Localize("Refresh"), 0, &RefreshRect) || Input()->KeyPress(KEY_F5) || (Input()->KeyPress(KEY_R) && Input()->ModifierIsPressed())) { DemolistPopulate(); @@ -1217,7 +1217,7 @@ void CMenus::RenderDemoList(CUIRect MainView) FetchAllHeaders(); } - static int s_PlayButton = 0; + static CButtonContainer s_PlayButton; if(DoButton_Menu(&s_PlayButton, m_DemolistSelectedIsDir ? Localize("Open") : Localize("Play", "Demo browser"), 0, &PlayRect) || Activated || (Input()->KeyPress(KEY_P) && m_pClient->m_GameConsole.IsClosed() && m_DemoPlayerState == DEMOPLAYER_NONE)) { if(m_DemolistSelectedIndex >= 0) @@ -1252,7 +1252,7 @@ void CMenus::RenderDemoList(CUIRect MainView) } } - static int s_DirectoryButtonID = 0; + static CButtonContainer s_DirectoryButtonID; if(DoButton_Menu(&s_DirectoryButtonID, Localize("Demos directory"), 0, &DirectoryButton)) { char aBuf[IO_MAX_PATH_LENGTH]; @@ -1266,7 +1266,7 @@ void CMenus::RenderDemoList(CUIRect MainView) if(!m_DemolistSelectedIsDir) { - static int s_DeleteButton = 0; + static CButtonContainer s_DeleteButton; if(DoButton_Menu(&s_DeleteButton, Localize("Delete"), 0, &DeleteRect) || m_DeletePressed || (Input()->KeyPress(KEY_D) && m_pClient->m_GameConsole.IsClosed())) { if(m_DemolistSelectedIndex >= 0) @@ -1277,7 +1277,7 @@ void CMenus::RenderDemoList(CUIRect MainView) } } - static int s_RenameButton = 0; + static CButtonContainer s_RenameButton; if(DoButton_Menu(&s_RenameButton, Localize("Rename"), 0, &RenameRect)) { if(m_DemolistSelectedIndex >= 0) @@ -1290,7 +1290,7 @@ void CMenus::RenderDemoList(CUIRect MainView) } #if defined(CONF_VIDEORECORDER) - static int s_RenderButton = 0; + static CButtonContainer s_RenderButton; if(DoButton_Menu(&s_RenderButton, Localize("Render"), 0, &RenderRect) || (Input()->KeyPress(KEY_R) && m_pClient->m_GameConsole.IsClosed())) { if(m_DemolistSelectedIndex >= 0) diff --git a/src/game/client/components/menus_ingame.cpp b/src/game/client/components/menus_ingame.cpp index ddb353d0703..5b15fd56201 100644 --- a/src/game/client/components/menus_ingame.cpp +++ b/src/game/client/components/menus_ingame.cpp @@ -50,7 +50,7 @@ void CMenus::RenderGame(CUIRect MainView) ButtonBar.VSplitRight(120.0f, &ButtonBar, &Button); - static int s_DisconnectButton = 0; + static CButtonContainer s_DisconnectButton; if(DoButton_Menu(&s_DisconnectButton, Localize("Disconnect"), 0, &Button)) { if(Client()->GetCurrentRaceTime() / 60 >= g_Config.m_ClConfirmDisconnectTime && g_Config.m_ClConfirmDisconnectTime >= 0) @@ -67,7 +67,7 @@ void CMenus::RenderGame(CUIRect MainView) ButtonBar.VSplitRight(170.0f, &ButtonBar, &Button); bool DummyConnecting = Client()->DummyConnecting(); - static int s_DummyButton = 0; + static CButtonContainer s_DummyButton; if(!Client()->DummyAllowed()) { DoButton_Menu(&s_DummyButton, Localize("Connect Dummy"), 1, &Button, nullptr, CUI::CORNER_ALL, 5.0f, 0.0f, vec4(1.0f, 0.5f, 0.5f, 0.75f), vec4(1, 0.5f, 0.5f, 0.5f)); @@ -99,7 +99,7 @@ void CMenus::RenderGame(CUIRect MainView) ButtonBar.VSplitRight(5.0f, &ButtonBar, 0); ButtonBar.VSplitRight(140.0f, &ButtonBar, &Button); - static int s_DemoButton = 0; + static CButtonContainer s_DemoButton; bool Recording = DemoRecorder(RECORDER_MANUAL)->IsRecording(); if(DoButton_Menu(&s_DemoButton, Recording ? Localize("Stop record") : Localize("Record demo"), 0, &Button)) { @@ -109,9 +109,9 @@ void CMenus::RenderGame(CUIRect MainView) Client()->DemoRecorder_Stop(RECORDER_MANUAL); } - static int s_SpectateButton = 0; - static int s_JoinRedButton = 0; - static int s_JoinBlueButton = 0; + static CButtonContainer s_SpectateButton; + static CButtonContainer s_JoinRedButton; + static CButtonContainer s_JoinBlueButton; bool Paused = false; bool Spec = false; @@ -180,7 +180,7 @@ void CMenus::RenderGame(CUIRect MainView) ButtonBar.VSplitLeft(5.0f, 0, &ButtonBar); ButtonBar.VSplitLeft(65.0f, &Button, &ButtonBar); - static int s_KillButton = 0; + static CButtonContainer s_KillButton; if(DoButton_Menu(&s_KillButton, Localize("Kill"), 0, &Button)) { m_pClient->SendKill(-1); @@ -196,7 +196,7 @@ void CMenus::RenderGame(CUIRect MainView) ButtonBar.VSplitLeft(5.0f, 0, &ButtonBar); ButtonBar.VSplitLeft((!Paused && !Spec) ? 65.0f : 120.0f, &Button, &ButtonBar); - static int s_PauseButton = 0; + static CButtonContainer s_PauseButton; if(DoButton_Menu(&s_PauseButton, (!Paused && !Spec) ? Localize("Pause") : Localize("Join game"), 0, &Button)) { m_pClient->Console()->ExecuteLine("say /pause"); @@ -576,16 +576,16 @@ void CMenus::RenderServerControl(CUIRect MainView) // tab bar { TabBar.VSplitLeft(TabBar.w / 3, &Button, &TabBar); - static int s_Button0 = 0; + static CButtonContainer s_Button0; if(DoButton_MenuTab(&s_Button0, Localize("Change settings"), s_ControlPage == 0, &Button, 0)) s_ControlPage = 0; TabBar.VSplitMid(&Button, &TabBar); - static int s_Button1 = 0; + static CButtonContainer s_Button1; if(DoButton_MenuTab(&s_Button1, Localize("Kick player"), s_ControlPage == 1, &Button, 0)) s_ControlPage = 1; - static int s_Button2 = 0; + static CButtonContainer s_Button2; if(DoButton_MenuTab(&s_Button2, Localize("Move player to spectators"), s_ControlPage == 2, &TabBar, 0)) s_ControlPage = 2; } @@ -638,7 +638,7 @@ void CMenus::RenderServerControl(CUIRect MainView) Bottom.VSplitRight(120.0f, &Bottom, &Button); - static int s_CallVoteButton = 0; + static CButtonContainer s_CallVoteButton; if(DoButton_Menu(&s_CallVoteButton, Localize("Call vote"), 0, &Button) || Call) { if(s_ControlPage == 0) @@ -694,7 +694,7 @@ void CMenus::RenderServerControl(CUIRect MainView) Bottom.VSplitLeft(5.0f, 0, &Bottom); Bottom.VSplitLeft(120.0f, &Button, &Bottom); - static int s_ForceVoteButton = 0; + static CButtonContainer s_ForceVoteButton; if(DoButton_Menu(&s_ForceVoteButton, Localize("Force vote"), 0, &Button)) { if(s_ControlPage == 0) @@ -725,7 +725,7 @@ void CMenus::RenderServerControl(CUIRect MainView) // remove vote Bottom.VSplitRight(10.0f, &Bottom, 0); Bottom.VSplitRight(120.0f, 0, &Button); - static int s_RemoveVoteButton = 0; + static CButtonContainer s_RemoveVoteButton; if(DoButton_Menu(&s_RemoveVoteButton, Localize("Remove"), 0, &Button)) m_pClient->m_Voting.RemovevoteOption(m_CallvoteSelectedOption); @@ -743,7 +743,7 @@ void CMenus::RenderServerControl(CUIRect MainView) RconExtension.HSplitTop(20.0f, &Bottom, &RconExtension); Bottom.VSplitRight(10.0f, &Bottom, 0); Bottom.VSplitRight(120.0f, &Bottom, &Button); - static int s_AddVoteButton = 0; + static CButtonContainer s_AddVoteButton; if(DoButton_Menu(&s_AddVoteButton, Localize("Add"), 0, &Button)) if(s_aVoteDescription[0] != 0 && s_aVoteCommand[0] != 0) m_pClient->m_Voting.AddvoteOption(s_aVoteDescription, s_aVoteCommand); @@ -775,7 +775,7 @@ void CMenus::RenderInGameNetwork(CUIRect MainView) Box.HSplitTop(24.0f, &Box, &MainView); Box.VSplitLeft(100.0f, &Button, &Box); - static int s_InternetButton = 0; + static CButtonContainer s_InternetButton; if(DoButton_MenuTab(&s_InternetButton, Localize("Internet"), Page == PAGE_INTERNET, &Button, 0)) { if(Page != PAGE_INTERNET) @@ -784,7 +784,7 @@ void CMenus::RenderInGameNetwork(CUIRect MainView) } Box.VSplitLeft(80.0f, &Button, &Box); - static int s_LanButton = 0; + static CButtonContainer s_LanButton; if(DoButton_MenuTab(&s_LanButton, Localize("LAN"), Page == PAGE_LAN, &Button, 0)) { if(Page != PAGE_LAN) @@ -793,7 +793,7 @@ void CMenus::RenderInGameNetwork(CUIRect MainView) } Box.VSplitLeft(110.0f, &Button, &Box); - static int s_FavoritesButton = 0; + static CButtonContainer s_FavoritesButton; if(DoButton_MenuTab(&s_FavoritesButton, Localize("Favorites"), Page == PAGE_FAVORITES, &Button, 0)) { if(Page != PAGE_FAVORITES) @@ -802,7 +802,7 @@ void CMenus::RenderInGameNetwork(CUIRect MainView) } Box.VSplitLeft(110.0f, &Button, &Box); - static int s_DDNetButton = 0; + static CButtonContainer s_DDNetButton; if(DoButton_MenuTab(&s_DDNetButton, "DDNet", Page == PAGE_DDNET, &Button, 0) || Page < PAGE_INTERNET || Page > PAGE_KOG) { if(Page != PAGE_DDNET) @@ -814,7 +814,7 @@ void CMenus::RenderInGameNetwork(CUIRect MainView) } Box.VSplitLeft(110.0f, &Button, &Box); - static int s_KoGButton = 0; + static CButtonContainer s_KoGButton; if(DoButton_MenuTab(&s_KoGButton, "KoG", Page == PAGE_KOG, &Button, CUI::CORNER_BR)) { if(Page != PAGE_KOG) @@ -1086,7 +1086,7 @@ void CMenus::RenderGhost(CUIRect MainView) CUIRect Button; Status.VSplitLeft(120.0f, &Button, &Status); - static int s_ReloadButton = 0; + static CButtonContainer s_ReloadButton; if(DoButton_Menu(&s_ReloadButton, Localize("Reload"), 0, &Button) || Input()->KeyPress(KEY_F5)) { m_pClient->m_Ghost.UnloadAll(); @@ -1104,7 +1104,7 @@ void CMenus::RenderGhost(CUIRect MainView) { Status.VSplitRight(120.0f, &Status, &Button); - static int s_GhostButton = 0; + static CButtonContainer s_GhostButton; const char *pText = pGhost->Active() ? Localize("Deactivate") : Localize("Activate"); if(DoButton_Menu(&s_GhostButton, pText, 0, &Button) || (DoubleClicked && Input()->MouseDoubleClick())) { @@ -1122,7 +1122,7 @@ void CMenus::RenderGhost(CUIRect MainView) Status.VSplitRight(120.0f, &Status, &Button); - static int s_DeleteButton = 0; + static CButtonContainer s_DeleteButton; if(DoButton_Menu(&s_DeleteButton, Localize("Delete"), 0, &Button)) { if(pGhost->Active()) @@ -1135,7 +1135,7 @@ void CMenus::RenderGhost(CUIRect MainView) bool Recording = m_pClient->m_Ghost.GhostRecorder()->IsRecording(); if(!pGhost->HasFile() && !Recording && pGhost->Active()) { - static int s_SaveButton = 0; + static CButtonContainer s_SaveButton; Status.VSplitRight(120.0f, &Status, &Button); if(DoButton_Menu(&s_SaveButton, Localize("Save"), 0, &Button)) m_pClient->m_Ghost.SaveGhost(pGhost); diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 2b629e882b3..c470298af0e 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -195,7 +195,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView) Left.HSplitBottom(25.0f, &Left, &SettingsButton); SettingsButton.HSplitTop(5.0f, 0, &SettingsButton); - static int s_SettingsButtonID = 0; + static CButtonContainer s_SettingsButtonID; if(DoButton_Menu(&s_SettingsButtonID, Localize("Settings file"), 0, &SettingsButton)) { Storage()->GetCompletePath(IStorage::TYPE_SAVE, CONFIG_FILE, aBuf, sizeof(aBuf)); @@ -210,7 +210,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView) Left.HSplitBottom(25.0f, &Left, &ConfigButton); ConfigButton.HSplitTop(5.0f, 0, &ConfigButton); - static int s_ConfigButtonID = 0; + static CButtonContainer s_ConfigButtonID; if(DoButton_Menu(&s_ConfigButtonID, Localize("Config directory"), 0, &ConfigButton)) { Storage()->GetCompletePath(IStorage::TYPE_SAVE, "", aBuf, sizeof(aBuf)); @@ -226,7 +226,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView) RenderThemeSelection(Left); DirectoryButton.HSplitTop(5.0f, 0, &DirectoryButton); - static int s_ThemesButtonID = 0; + static CButtonContainer s_ThemesButtonID; if(DoButton_Menu(&s_ThemesButtonID, Localize("Themes directory"), 0, &DirectoryButton)) { Storage()->GetCompletePath(IStorage::TYPE_SAVE, "themes", aBuf, sizeof(aBuf)); @@ -511,7 +511,8 @@ void CMenus::RenderSettingsTee(CUIRect MainView) { SkinPrefix.HSplitTop(20.0f, &Button, &SkinPrefix); Button.HMargin(2.0f, &Button); - if(DoButton_Menu(&pPrefix, pPrefix, 0, &Button)) + static CButtonContainer s_PrefixButton; + if(DoButton_Menu(&s_PrefixButton, pPrefix, 0, &Button)) { str_copy(g_Config.m_ClSkinPrefix, pPrefix); } @@ -550,7 +551,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView) EyesLabel.HSplitTop(50.0f, &EyesLabel, &Eyes); float Highlight = 0.0f; - static int s_aEyeButtons[6]; + static CButtonContainer s_aEyeButtons[6]; static int s_aEyesToolTip[6]; for(int CurrentEyeEmote = 0; CurrentEyeEmote < 6; CurrentEyeEmote++) { @@ -745,7 +746,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView) SkinDB.VSplitLeft(150.0f, &SkinDB, &DirectoryButton); SkinDB.HSplitTop(5.0f, 0, &SkinDB); - static int s_SkinDBDirID = 0; + static CButtonContainer s_SkinDBDirID; if(DoButton_Menu(&s_SkinDBDirID, Localize("Skin Database"), 0, &SkinDB)) { if(!open_link("https://ddnet.tw/skins/")) @@ -758,7 +759,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView) DirectoryButton.VSplitRight(175.0f, 0, &DirectoryButton); DirectoryButton.VSplitRight(25.0f, &DirectoryButton, &RefreshButton); DirectoryButton.VSplitRight(10.0f, &DirectoryButton, 0); - static int s_DirectoryButtonID = 0; + static CButtonContainer s_DirectoryButtonID; if(DoButton_Menu(&s_DirectoryButtonID, Localize("Skins directory"), 0, &DirectoryButton)) { Storage()->GetCompletePath(IStorage::TYPE_SAVE, "skins", aBuf, sizeof(aBuf)); @@ -771,7 +772,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView) TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); - static int s_SkinRefreshButtonID = 0; + static CButtonContainer s_SkinRefreshButtonID; if(DoButton_Menu(&s_SkinRefreshButtonID, "\xEF\x80\x9E", 0, &RefreshButton, nullptr, CUI::CORNER_ALL, 5, 0, vec4(1.0f, 1.0f, 1.0f, 0.75f), vec4(1, 1, 1, 0.5f), 0)) { // reset render flags for possible loading screen @@ -939,7 +940,7 @@ float CMenus::RenderSettingsControlsJoystick(CUIRect View) { View.HSplitTop(Spacing, 0, &View); View.HSplitTop(ButtonHeight, &Button, &View); - static int s_ButtonJoystickId; + static CButtonContainer s_ButtonJoystickId; char aBuf[96]; str_format(aBuf, sizeof(aBuf), Localize("Controller %d: %s"), Input()->GetActiveJoystick()->GetIndex(), Input()->GetActiveJoystick()->GetName()); if(DoButton_Menu(&s_ButtonJoystickId, aBuf, 0, &Button)) @@ -1187,8 +1188,8 @@ void CMenus::RenderSettingsControls(CUIRect MainView) ResetButton.HMargin(10.0f, &ResetButton); ResetButton.VMargin(30.0f, &ResetButton); ResetButton.HSplitTop(20.0f, &ResetButton, 0); - static int s_DefaultButton = 0; - if(DoButton_Menu((void *)&s_DefaultButton, Localize("Reset to defaults"), 0, &ResetButton)) + static CButtonContainer s_DefaultButton; + if(DoButton_Menu(&s_DefaultButton, Localize("Reset to defaults"), 0, &ResetButton)) { m_pClient->m_Binds.SetDefaults(); @@ -1261,14 +1262,14 @@ void CMenus::RenderSettingsControls(CUIRect MainView) UiDoListboxEnd(&s_ScrollValue, 0); } -int CMenus::RenderDropDown(int &CurDropDownState, CUIRect *pRect, int CurSelection, const void **pIDs, const char **pStr, int PickNum, const void *pID, float &ScrollVal) +int CMenus::RenderDropDown(int &CurDropDownState, CUIRect *pRect, int CurSelection, const void **pIDs, const char **pStr, int PickNum, CButtonContainer *pButtonContainer, float &ScrollVal) { if(CurDropDownState != 0) { CUIRect ListRect; pRect->HSplitTop(24.0f * PickNum, &ListRect, pRect); char aBuf[1024]; - UiDoListboxStart(&pID, &ListRect, 24.0f, "", aBuf, PickNum, 1, CurSelection, ScrollVal); + UiDoListboxStart(&pButtonContainer, &ListRect, 24.0f, "", aBuf, PickNum, 1, CurSelection, ScrollVal); for(int i = 0; i < PickNum; ++i) { CListboxItem Item = UiDoListboxNextItem(pIDs[i], CurSelection == i); @@ -1292,7 +1293,7 @@ int CMenus::RenderDropDown(int &CurDropDownState, CUIRect *pRect, int CurSelecti { CUIRect Button; pRect->HSplitTop(24.0f, &Button, pRect); - if(DoButton_MenuTab(pID, CurSelection > -1 ? pStr[CurSelection] : "", 0, &Button, CUI::CORNER_ALL, NULL, NULL, NULL, NULL, 4.0f)) + if(DoButton_MenuTab(pButtonContainer, CurSelection > -1 ? pStr[CurSelection] : "", 0, &Button, CUI::CORNER_ALL, NULL, NULL, NULL, NULL, 4.0f)) CurDropDownState = 1; CUIRect DropDownIcon = Button; @@ -1407,7 +1408,8 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) OldSelected = (g_Config.m_GfxFullscreen ? (g_Config.m_GfxFullscreen == 1 ? 4 : (g_Config.m_GfxFullscreen == 2 ? 3 : 2)) : (g_Config.m_GfxBorderless ? 1 : 0)); - const int NewWindowMode = RenderDropDown(s_WindowModeDropDownState, &MainView, OldSelected, apWindowModeIDs, apWindowModes, s_NumWindowMode, &s_NumWindowMode, s_ScrollValueDrop); + static CButtonContainer s_WindowButton; + const int NewWindowMode = RenderDropDown(s_WindowModeDropDownState, &MainView, OldSelected, apWindowModeIDs, apWindowModes, s_NumWindowMode, &s_WindowButton, s_ScrollValueDrop); if(OldSelected != NewWindowMode) { if(NewWindowMode == 0) @@ -1558,18 +1560,18 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) static float s_ScrollValueDropBackend = 0; static int s_BackendDropDownState = 0; - static std::vector> vBackendIDs; - static std::vector vBackendIDPtrs; - static std::vector vBackendIDNames; - static std::vector vBackendIDNamesCStr; - static std::vector vBackendInfos; + static std::vector> s_vBackendIDs; + static std::vector s_vBackendIDPtrs; + static std::vector s_vBackendIDNames; + static std::vector s_vBackendIDNamesCStr; + static std::vector s_vBackendInfos; size_t BackendCount = FoundBackendCount + 1; - vBackendIDs.resize(BackendCount); - vBackendIDPtrs.resize(BackendCount); - vBackendIDNames.resize(BackendCount); - vBackendIDNamesCStr.resize(BackendCount); - vBackendInfos.resize(BackendCount); + s_vBackendIDs.resize(BackendCount); + s_vBackendIDPtrs.resize(BackendCount); + s_vBackendIDNames.resize(BackendCount); + s_vBackendIDNamesCStr.resize(BackendCount); + s_vBackendInfos.resize(BackendCount); char aTmpBackendName[256]; @@ -1586,21 +1588,21 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) auto &Info = aaSupportedBackends[i][n]; if(Info.m_Found) { - if(vBackendIDs[CurCounter].get() == nullptr) - vBackendIDs[CurCounter] = std::make_unique(); - vBackendIDPtrs[CurCounter] = vBackendIDs[CurCounter].get(); + if(s_vBackendIDs[CurCounter].get() == nullptr) + s_vBackendIDs[CurCounter] = std::make_unique(); + s_vBackendIDPtrs[CurCounter] = s_vBackendIDs[CurCounter].get(); { bool IsDefault = IsInfoDefault(Info); str_format(aTmpBackendName, sizeof(aTmpBackendName), "%s (%d.%d.%d)%s%s", Info.m_pBackendName, Info.m_Major, Info.m_Minor, Info.m_Patch, IsDefault ? " - " : "", IsDefault ? Localize("default") : ""); - vBackendIDNames[CurCounter] = aTmpBackendName; - vBackendIDNamesCStr[CurCounter] = vBackendIDNames[CurCounter].c_str(); + s_vBackendIDNames[CurCounter] = aTmpBackendName; + s_vBackendIDNamesCStr[CurCounter] = s_vBackendIDNames[CurCounter].c_str(); if(str_comp_nocase(Info.m_pBackendName, g_Config.m_GfxBackend) == 0 && g_Config.m_GfxGLMajor == Info.m_Major && g_Config.m_GfxGLMinor == Info.m_Minor && g_Config.m_GfxGLPatch == Info.m_Patch) { OldSelectedBackend = CurCounter; } - vBackendInfos[CurCounter] = Info; + s_vBackendInfos[CurCounter] = Info; } ++CurCounter; } @@ -1615,19 +1617,19 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) else { // custom selected one - if(vBackendIDs[CurCounter].get() == nullptr) - vBackendIDs[CurCounter] = std::make_unique(); - vBackendIDPtrs[CurCounter] = vBackendIDs[CurCounter].get(); + if(s_vBackendIDs[CurCounter].get() == nullptr) + s_vBackendIDs[CurCounter] = std::make_unique(); + s_vBackendIDPtrs[CurCounter] = s_vBackendIDs[CurCounter].get(); str_format(aTmpBackendName, sizeof(aTmpBackendName), "%s (%s %d.%d.%d)", Localize("custom"), g_Config.m_GfxBackend, g_Config.m_GfxGLMajor, g_Config.m_GfxGLMinor, g_Config.m_GfxGLPatch); - vBackendIDNames[CurCounter] = aTmpBackendName; - vBackendIDNamesCStr[CurCounter] = vBackendIDNames[CurCounter].c_str(); + s_vBackendIDNames[CurCounter] = aTmpBackendName; + s_vBackendIDNamesCStr[CurCounter] = s_vBackendIDNames[CurCounter].c_str(); OldSelectedBackend = CurCounter; - vBackendInfos[CurCounter].m_pBackendName = "custom"; - vBackendInfos[CurCounter].m_Major = g_Config.m_GfxGLMajor; - vBackendInfos[CurCounter].m_Minor = g_Config.m_GfxGLMinor; - vBackendInfos[CurCounter].m_Patch = g_Config.m_GfxGLPatch; + s_vBackendInfos[CurCounter].m_pBackendName = "custom"; + s_vBackendInfos[CurCounter].m_Major = g_Config.m_GfxGLMajor; + s_vBackendInfos[CurCounter].m_Minor = g_Config.m_GfxGLMinor; + s_vBackendInfos[CurCounter].m_Patch = g_Config.m_GfxGLPatch; } if(s_OldSelectedBackend == -1) @@ -1636,13 +1638,14 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) static int s_BackendCount = 0; s_BackendCount = BackendCount; - const int NewBackend = RenderDropDown(s_BackendDropDownState, &MainView, OldSelectedBackend, vBackendIDPtrs.data(), vBackendIDNamesCStr.data(), s_BackendCount, &s_BackendCount, s_ScrollValueDropBackend); + static CButtonContainer s_BackendButton; + const int NewBackend = RenderDropDown(s_BackendDropDownState, &MainView, OldSelectedBackend, s_vBackendIDPtrs.data(), s_vBackendIDNamesCStr.data(), s_BackendCount, &s_BackendButton, s_ScrollValueDropBackend); if(OldSelectedBackend != NewBackend) { - str_copy(g_Config.m_GfxBackend, vBackendInfos[NewBackend].m_pBackendName); - g_Config.m_GfxGLMajor = vBackendInfos[NewBackend].m_Major; - g_Config.m_GfxGLMinor = vBackendInfos[NewBackend].m_Minor; - g_Config.m_GfxGLPatch = vBackendInfos[NewBackend].m_Patch; + str_copy(g_Config.m_GfxBackend, s_vBackendInfos[NewBackend].m_pBackendName); + g_Config.m_GfxGLMajor = s_vBackendInfos[NewBackend].m_Major; + g_Config.m_GfxGLMinor = s_vBackendInfos[NewBackend].m_Minor; + g_Config.m_GfxGLPatch = s_vBackendInfos[NewBackend].m_Patch; CheckSettings = true; s_GfxBackendChanged = s_OldSelectedBackend != NewBackend; @@ -1660,27 +1663,27 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) static float s_ScrollValueDropGPU = 0; static int s_GPUDropDownState = 0; - static std::vector> vGPUIDs; - static std::vector vGPUIDPtrs; - static std::vector vGPUIDNames; + static std::vector> s_vGPUIDs; + static std::vector s_vGPUIDPtrs; + static std::vector s_vGPUIDNames; size_t GPUCount = GPUList.m_vGPUs.size() + 1; - vGPUIDs.resize(GPUCount); - vGPUIDPtrs.resize(GPUCount); - vGPUIDNames.resize(GPUCount); + s_vGPUIDs.resize(GPUCount); + s_vGPUIDPtrs.resize(GPUCount); + s_vGPUIDNames.resize(GPUCount); char aCurDeviceName[256 + 4]; int OldSelectedGPU = -1; for(size_t i = 0; i < GPUCount; ++i) { - if(vGPUIDs[i].get() == nullptr) - vGPUIDs[i] = std::make_unique(); - vGPUIDPtrs[i] = vGPUIDs[i].get(); + if(s_vGPUIDs[i].get() == nullptr) + s_vGPUIDs[i] = std::make_unique(); + s_vGPUIDPtrs[i] = s_vGPUIDs[i].get(); if(i == 0) { str_format(aCurDeviceName, sizeof(aCurDeviceName), "%s(%s)", Localize("auto"), GPUList.m_AutoGPU.m_aName); - vGPUIDNames[i] = aCurDeviceName; + s_vGPUIDNames[i] = aCurDeviceName; if(str_comp("auto", g_Config.m_GfxGPUName) == 0) { OldSelectedGPU = 0; @@ -1688,7 +1691,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) } else { - vGPUIDNames[i] = GPUList.m_vGPUs[i - 1].m_aName; + s_vGPUIDNames[i] = GPUList.m_vGPUs[i - 1].m_aName; if(str_comp(GPUList.m_vGPUs[i - 1].m_aName, g_Config.m_GfxGPUName) == 0) { OldSelectedGPU = i; @@ -1702,7 +1705,8 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) if(s_OldSelectedGPU == -1) s_OldSelectedGPU = OldSelectedGPU; - const int NewGPU = RenderDropDown(s_GPUDropDownState, &MainView, OldSelectedGPU, vGPUIDPtrs.data(), vGPUIDNames.data(), s_GPUCount, &s_GPUCount, s_ScrollValueDropGPU); + static CButtonContainer s_GpuButton; + const int NewGPU = RenderDropDown(s_GPUDropDownState, &MainView, OldSelectedGPU, s_vGPUIDPtrs.data(), s_vGPUIDNames.data(), s_GPUCount, &s_GpuButton, s_ScrollValueDropGPU); if(OldSelectedGPU != NewGPU) { if(NewGPU == 0) @@ -1995,6 +1999,8 @@ void CMenus::RenderSettings(CUIRect MainView) Localize("Assets"), ("chillerbot")}; + static CButtonContainer s_aTabButtons[sizeof(apTabs)]; + int NumTabs = (int)std::size(apTabs); int PreviousPage = g_Config.m_UiSettingsPage; @@ -2002,7 +2008,7 @@ void CMenus::RenderSettings(CUIRect MainView) { TabBar.HSplitTop(10, &Button, &TabBar); TabBar.HSplitTop(26, &Button, &TabBar); - if(DoButton_MenuTab(apTabs[i], apTabs[i], g_Config.m_UiSettingsPage == i, &Button, CUI::CORNER_R, &m_aAnimatorsSettingsTab[i])) + if(DoButton_MenuTab(&s_aTabButtons[i], apTabs[i], g_Config.m_UiSettingsPage == i, &Button, CUI::CORNER_R, &m_aAnimatorsSettingsTab[i])) g_Config.m_UiSettingsPage = i; } @@ -2482,19 +2488,19 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView) Page4Tab.VSplitLeft(TabsW / NUMBER_OF_APPEARANCE_TABS, &Page4Tab, &Page5Tab); Page5Tab.VSplitLeft(TabsW / NUMBER_OF_APPEARANCE_TABS, &Page5Tab, &Page6Tab); - static int s_aPageTabs[NUMBER_OF_APPEARANCE_TABS] = {}; + static CButtonContainer s_aPageTabs[NUMBER_OF_APPEARANCE_TABS] = {}; - if(DoButton_MenuTab((void *)&s_aPageTabs[APPEARANCE_TAB_HUD], Localize("HUD"), s_CurTab == APPEARANCE_TAB_HUD, &Page1Tab, CUI::CORNER_L, NULL, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab(&s_aPageTabs[APPEARANCE_TAB_HUD], Localize("HUD"), s_CurTab == APPEARANCE_TAB_HUD, &Page1Tab, CUI::CORNER_L, NULL, NULL, NULL, NULL, 4)) s_CurTab = APPEARANCE_TAB_HUD; - if(DoButton_MenuTab((void *)&s_aPageTabs[APPEARANCE_TAB_CHAT], Localize("Chat"), s_CurTab == APPEARANCE_TAB_CHAT, &Page2Tab, 0, NULL, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab(&s_aPageTabs[APPEARANCE_TAB_CHAT], Localize("Chat"), s_CurTab == APPEARANCE_TAB_CHAT, &Page2Tab, 0, NULL, NULL, NULL, NULL, 4)) s_CurTab = APPEARANCE_TAB_CHAT; - if(DoButton_MenuTab((void *)&s_aPageTabs[APPEARANCE_TAB_NAME_PLATE], Localize("Name Plate"), s_CurTab == APPEARANCE_TAB_NAME_PLATE, &Page3Tab, 0, NULL, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab(&s_aPageTabs[APPEARANCE_TAB_NAME_PLATE], Localize("Name Plate"), s_CurTab == APPEARANCE_TAB_NAME_PLATE, &Page3Tab, 0, NULL, NULL, NULL, NULL, 4)) s_CurTab = APPEARANCE_TAB_NAME_PLATE; - if(DoButton_MenuTab((void *)&s_aPageTabs[APPEARANCE_TAB_HOOK_COLLISION], Localize("Hook Collisions"), s_CurTab == APPEARANCE_TAB_HOOK_COLLISION, &Page4Tab, 0, NULL, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab(&s_aPageTabs[APPEARANCE_TAB_HOOK_COLLISION], Localize("Hook Collisions"), s_CurTab == APPEARANCE_TAB_HOOK_COLLISION, &Page4Tab, 0, NULL, NULL, NULL, NULL, 4)) s_CurTab = APPEARANCE_TAB_HOOK_COLLISION; - if(DoButton_MenuTab((void *)&s_aPageTabs[APPEARANCE_TAB_KILL_MESSAGES], Localize("Kill Messages"), s_CurTab == APPEARANCE_TAB_KILL_MESSAGES, &Page5Tab, 0, NULL, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab(&s_aPageTabs[APPEARANCE_TAB_KILL_MESSAGES], Localize("Kill Messages"), s_CurTab == APPEARANCE_TAB_KILL_MESSAGES, &Page5Tab, 0, NULL, NULL, NULL, NULL, 4)) s_CurTab = APPEARANCE_TAB_KILL_MESSAGES; - if(DoButton_MenuTab((void *)&s_aPageTabs[APPEARANCE_TAB_LASER], Localize("Laser"), s_CurTab == APPEARANCE_TAB_LASER, &Page6Tab, CUI::CORNER_R, NULL, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab(&s_aPageTabs[APPEARANCE_TAB_LASER], Localize("Laser"), s_CurTab == APPEARANCE_TAB_LASER, &Page6Tab, CUI::CORNER_R, NULL, NULL, NULL, NULL, 4)) s_CurTab = APPEARANCE_TAB_LASER; MainView.HSplitTop(10.0f, 0x0, &MainView); // Margin @@ -2623,7 +2629,7 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView) Section.Margin(SectionMargin, &Section); int i = 0; - static int s_aResetIDs[24]; + static CButtonContainer s_aResetIDs[24]; DoLine_ColorPicker(&s_aResetIDs[i++], ColorPickerLineSize, LeftViewColorPickerPosition, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("System message"), &g_Config.m_ClMessageSystemColor, ColorRGBA(1.0f, 1.0f, 0.5f), true, true, &g_Config.m_ClShowChatSystem); DoLine_ColorPicker(&s_aResetIDs[i++], ColorPickerLineSize, LeftViewColorPickerPosition, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("Highlighted message"), &g_Config.m_ClMessageHighlightColor, ColorRGBA(1.0f, 0.5f, 0.5f)); @@ -2898,14 +2904,15 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView) g_Config.m_ClHookCollAlpha = (int)(UIEx()->DoScrollbarH(&g_Config.m_ClHookCollAlpha, &Button, g_Config.m_ClHookCollAlpha / 100.0f) * 100.0f); } - static int HookCollNoCollResetID, HookCollHookableCollResetID, HookCollTeeCollResetID, HookCollToolTop; + static CButtonContainer s_HookCollNoCollResetID, s_HookCollHookableCollResetID, s_HookCollTeeCollResetID; + static int s_HookCollToolTip; Section.HSplitTop(LineSize, &Label, &Section); UI()->DoLabel(&Label, Localize("Colors of the hook collision line, in case of a possible collision with:"), 13.0f, TEXTALIGN_LEFT); - GameClient()->m_Tooltips.DoToolTip(&HookCollToolTop, &Label, Localize("Your movements are not taken into account when calculating the line colors")); - DoLine_ColorPicker(&HookCollNoCollResetID, ColorPickerLineSize, LeftViewColorPickerPosition, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("Nothing hookable"), &g_Config.m_ClHookCollColorNoColl, ColorRGBA(1.0f, 0.0f, 0.0f, 1.0f), false); - DoLine_ColorPicker(&HookCollHookableCollResetID, ColorPickerLineSize, LeftViewColorPickerPosition, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("Something hookable"), &g_Config.m_ClHookCollColorHookableColl, ColorRGBA(130.0f / 255.0f, 232.0f / 255.0f, 160.0f / 255.0f, 1.0f), false); - DoLine_ColorPicker(&HookCollTeeCollResetID, ColorPickerLineSize, LeftViewColorPickerPosition, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("A Tee"), &g_Config.m_ClHookCollColorTeeColl, ColorRGBA(1.0f, 1.0f, 0.0f, 1.0f), false); + GameClient()->m_Tooltips.DoToolTip(&s_HookCollToolTip, &Label, Localize("Your movements are not taken into account when calculating the line colors")); + DoLine_ColorPicker(&s_HookCollNoCollResetID, ColorPickerLineSize, LeftViewColorPickerPosition, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("Nothing hookable"), &g_Config.m_ClHookCollColorNoColl, ColorRGBA(1.0f, 0.0f, 0.0f, 1.0f), false); + DoLine_ColorPicker(&s_HookCollHookableCollResetID, ColorPickerLineSize, LeftViewColorPickerPosition, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("Something hookable"), &g_Config.m_ClHookCollColorHookableColl, ColorRGBA(130.0f / 255.0f, 232.0f / 255.0f, 160.0f / 255.0f, 1.0f), false); + DoLine_ColorPicker(&s_HookCollTeeCollResetID, ColorPickerLineSize, LeftViewColorPickerPosition, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("A Tee"), &g_Config.m_ClHookCollColorTeeColl, ColorRGBA(1.0f, 1.0f, 0.0f, 1.0f), false); } else if(s_CurTab == APPEARANCE_TAB_KILL_MESSAGES) { @@ -2919,10 +2926,10 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView) LeftView.HSplitTop(SectionTotalMargin + 2 * ColorPickerLineSize, &Section, &LeftView); Section.Margin(SectionMargin, &Section); - static int KillMessageNormalColorID, KillMessageHighlightColorID; + static CButtonContainer s_KillMessageNormalColorID, s_KillMessageHighlightColorID; - DoLine_ColorPicker(&KillMessageNormalColorID, ColorPickerLineSize, LeftViewColorPickerPosition, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("Normal Color"), &g_Config.m_ClKillMessageNormalColor, ColorRGBA(1.0f, 1.0f, 1.0f), false); - DoLine_ColorPicker(&KillMessageHighlightColorID, ColorPickerLineSize, LeftViewColorPickerPosition, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("Highlight Color"), &g_Config.m_ClKillMessageHighlightColor, ColorRGBA(1.0f, 1.0f, 1.0f), false); + DoLine_ColorPicker(&s_KillMessageNormalColorID, ColorPickerLineSize, LeftViewColorPickerPosition, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("Normal Color"), &g_Config.m_ClKillMessageNormalColor, ColorRGBA(1.0f, 1.0f, 1.0f), false); + DoLine_ColorPicker(&s_KillMessageHighlightColorID, ColorPickerLineSize, LeftViewColorPickerPosition, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("Highlight Color"), &g_Config.m_ClKillMessageHighlightColor, ColorRGBA(1.0f, 1.0f, 1.0f), false); } else if(s_CurTab == APPEARANCE_TAB_LASER) { @@ -2936,10 +2943,10 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView) LeftView.HSplitTop(SectionTotalMargin + 2 * ColorPickerLineSize, &Section, &LeftView); Section.Margin(SectionMargin, &Section); - static int LaserOutResetID, LaserInResetID; + static CButtonContainer s_LaserOutResetID, s_LaserInResetID; - ColorHSLA LaserOutlineColor = DoLine_ColorPicker(&LaserOutResetID, ColorPickerLineSize, LeftViewColorPickerPosition, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("Laser Outline Color"), &g_Config.m_ClLaserOutlineColor, ColorRGBA(0.074402f, 0.074402f, 0.247166f, 1.0f), false); - ColorHSLA LaserInnerColor = DoLine_ColorPicker(&LaserInResetID, ColorPickerLineSize, LeftViewColorPickerPosition, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("Laser Inner Color"), &g_Config.m_ClLaserInnerColor, ColorRGBA(0.498039f, 0.498039f, 1.0f, 1.0f), false); + ColorHSLA LaserOutlineColor = DoLine_ColorPicker(&s_LaserOutResetID, ColorPickerLineSize, LeftViewColorPickerPosition, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("Laser Outline Color"), &g_Config.m_ClLaserOutlineColor, ColorRGBA(0.074402f, 0.074402f, 0.247166f, 1.0f), false); + ColorHSLA LaserInnerColor = DoLine_ColorPicker(&s_LaserInResetID, ColorPickerLineSize, LeftViewColorPickerPosition, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("Laser Inner Color"), &g_Config.m_ClLaserInnerColor, ColorRGBA(0.498039f, 0.498039f, 1.0f, 1.0f), false); // ***** Laser Preview ***** // RightView.HSplitTop(HeadlineAndVMargin, &Label, &RightView); @@ -3151,10 +3158,9 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView) UI()->DoLabel(&TempLabel, Localize("Miscellaneous"), 20.0f, TEXTALIGN_LEFT); - static int ResetID1 = 0; - static int ResetID2 = 0; + static CButtonContainer s_ResetID2; ColorRGBA GreyDefault(0.5f, 0.5f, 0.5f, 1); - DoLine_ColorPicker(&ResetID2, 25.0f, 194.0f, 13.0f, 5.0f, &Left, Localize("Entities Background color"), &g_Config.m_ClBackgroundEntitiesColor, GreyDefault, false); + DoLine_ColorPicker(&s_ResetID2, 25.0f, 194.0f, 13.0f, 5.0f, &Left, Localize("Entities Background color"), &g_Config.m_ClBackgroundEntitiesColor, GreyDefault, false); Left.VSplitLeft(5.0f, 0x0, &Left); Left.HSplitTop(25.0f, &Background, &Left); @@ -3179,14 +3185,15 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView) if(DoButton_CheckBox(&g_Config.m_ClBackgroundShowTilesLayers, Localize("Show tiles layers from BG map"), g_Config.m_ClBackgroundShowTilesLayers, &Button)) g_Config.m_ClBackgroundShowTilesLayers ^= 1; + static CButtonContainer s_ResetID1; Miscellaneous.HSplitTop(25.0f, &Button, &Right); - DoLine_ColorPicker(&ResetID1, 25.0f, 194.0f, 13.0f, 5.0f, &Button, Localize("Regular Background Color"), &g_Config.m_ClBackgroundColor, GreyDefault, false); + DoLine_ColorPicker(&s_ResetID1, 25.0f, 194.0f, 13.0f, 5.0f, &Button, Localize("Regular Background Color"), &g_Config.m_ClBackgroundColor, GreyDefault, false); Right.HSplitTop(5.0f, 0x0, &Right); Right.HSplitTop(20.0f, &Button, &Right); if(DoButton_CheckBox(&g_Config.m_ClHttpMapDownload, Localize("Try fast HTTP map download first"), g_Config.m_ClHttpMapDownload, &Button)) g_Config.m_ClHttpMapDownload ^= 1; - static int s_ButtonTimeout = 0; + static CButtonContainer s_ButtonTimeout; Right.HSplitTop(10.0f, 0x0, &Right); Right.HSplitTop(20.0f, &Button, &Right); if(DoButton_Menu(&s_ButtonTimeout, Localize("New random timeout code"), 0, &Button)) @@ -3219,7 +3226,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView) str_format(aBuf, sizeof(aBuf), Localize("DDNet %s is available:"), Client()->LatestVersion()); Label.VSplitLeft(TextRender()->TextWidth(0, 14.0f, aBuf, -1, -1.0f) + 10.0f, &Label, &Button); Button.VSplitLeft(100.0f, &Button, 0); - static int s_ButtonUpdate = 0; + static CButtonContainer s_ButtonUpdate; if(DoButton_Menu(&s_ButtonUpdate, Localize("Update now"), 0, &Button)) { Updater()->InitiateUpdate(); @@ -3237,7 +3244,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView) str_format(aBuf, sizeof(aBuf), Localize("No updates available")); Label.VSplitLeft(TextRender()->TextWidth(0, 14.0f, aBuf, -1, -1.0f) + 10.0f, &Label, &Button); Button.VSplitLeft(100.0f, &Button, 0); - static int s_ButtonUpdate = 0; + static CButtonContainer s_ButtonUpdate; if(DoButton_Menu(&s_ButtonUpdate, Localize("Check now"), 0, &Button)) { Client()->RequestDDNetInfo(); diff --git a/src/game/client/components/menus_settings_assets.cpp b/src/game/client/components/menus_settings_assets.cpp index 8fa8dd71223..a388a1fda52 100644 --- a/src/game/client/components/menus_settings_assets.cpp +++ b/src/game/client/components/menus_settings_assets.cpp @@ -394,19 +394,19 @@ void CMenus::RenderSettingsCustom(CUIRect MainView) Page4Tab.VSplitLeft(TabsW / NUMBER_OF_ASSETS_TABS, &Page4Tab, &Page5Tab); Page5Tab.VSplitLeft(TabsW / NUMBER_OF_ASSETS_TABS, &Page5Tab, &Page6Tab); - static int s_aPageTabs[NUMBER_OF_ASSETS_TABS] = {}; + static CButtonContainer s_aPageTabs[NUMBER_OF_ASSETS_TABS] = {}; - if(DoButton_MenuTab((void *)&s_aPageTabs[ASSETS_TAB_ENTITIES], Localize("Entities"), s_CurCustomTab == ASSETS_TAB_ENTITIES, &Page1Tab, CUI::CORNER_L, NULL, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab((CButtonContainer *)&s_aPageTabs[ASSETS_TAB_ENTITIES], Localize("Entities"), s_CurCustomTab == ASSETS_TAB_ENTITIES, &Page1Tab, CUI::CORNER_L, NULL, NULL, NULL, NULL, 4)) s_CurCustomTab = ASSETS_TAB_ENTITIES; - if(DoButton_MenuTab((void *)&s_aPageTabs[ASSETS_TAB_GAME], Localize("Game"), s_CurCustomTab == ASSETS_TAB_GAME, &Page2Tab, 0, NULL, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab((CButtonContainer *)&s_aPageTabs[ASSETS_TAB_GAME], Localize("Game"), s_CurCustomTab == ASSETS_TAB_GAME, &Page2Tab, 0, NULL, NULL, NULL, NULL, 4)) s_CurCustomTab = ASSETS_TAB_GAME; - if(DoButton_MenuTab((void *)&s_aPageTabs[ASSETS_TAB_EMOTICONS], Localize("Emoticons"), s_CurCustomTab == ASSETS_TAB_EMOTICONS, &Page3Tab, 0, NULL, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab((CButtonContainer *)&s_aPageTabs[ASSETS_TAB_EMOTICONS], Localize("Emoticons"), s_CurCustomTab == ASSETS_TAB_EMOTICONS, &Page3Tab, 0, NULL, NULL, NULL, NULL, 4)) s_CurCustomTab = ASSETS_TAB_EMOTICONS; - if(DoButton_MenuTab((void *)&s_aPageTabs[ASSETS_TAB_PARTICLES], Localize("Particles"), s_CurCustomTab == ASSETS_TAB_PARTICLES, &Page4Tab, 0, NULL, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab((CButtonContainer *)&s_aPageTabs[ASSETS_TAB_PARTICLES], Localize("Particles"), s_CurCustomTab == ASSETS_TAB_PARTICLES, &Page4Tab, 0, NULL, NULL, NULL, NULL, 4)) s_CurCustomTab = ASSETS_TAB_PARTICLES; - if(DoButton_MenuTab((void *)&s_aPageTabs[ASSETS_TAB_HUD], Localize("HUD"), s_CurCustomTab == ASSETS_TAB_HUD, &Page5Tab, 0, NULL, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab((CButtonContainer *)&s_aPageTabs[ASSETS_TAB_HUD], Localize("HUD"), s_CurCustomTab == ASSETS_TAB_HUD, &Page5Tab, 0, NULL, NULL, NULL, NULL, 4)) s_CurCustomTab = ASSETS_TAB_HUD; - if(DoButton_MenuTab((void *)&s_aPageTabs[ASSETS_TAB_EXTRAS], Localize("Extras"), s_CurCustomTab == ASSETS_TAB_EXTRAS, &Page6Tab, CUI::CORNER_R, NULL, NULL, NULL, NULL, 4)) + if(DoButton_MenuTab((CButtonContainer *)&s_aPageTabs[ASSETS_TAB_EXTRAS], Localize("Extras"), s_CurCustomTab == ASSETS_TAB_EXTRAS, &Page6Tab, CUI::CORNER_R, NULL, NULL, NULL, NULL, 4)) s_CurCustomTab = ASSETS_TAB_EXTRAS; auto LoadStartTime = time_get_nanoseconds(); @@ -667,7 +667,7 @@ void CMenus::RenderSettingsCustom(CUIRect MainView) DirectoryButton.VSplitRight(175.0f, 0, &DirectoryButton); DirectoryButton.VSplitRight(25.0f, &DirectoryButton, &ReloadButton); DirectoryButton.VSplitRight(10.0f, &DirectoryButton, 0); - static int s_AssetsDirID = 0; + static CButtonContainer s_AssetsDirID; if(DoButton_Menu(&s_AssetsDirID, Localize("Assets directory"), 0, &DirectoryButton)) { char aBuf[IO_MAX_PATH_LENGTH]; @@ -695,7 +695,7 @@ void CMenus::RenderSettingsCustom(CUIRect MainView) TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); - static int s_AssetsReloadBtnID = 0; + static CButtonContainer s_AssetsReloadBtnID; if(DoButton_Menu(&s_AssetsReloadBtnID, "\xEF\x80\x9E", 0, &ReloadButton, nullptr, CUI::CORNER_ALL, 5, 0, vec4(1.0f, 1.0f, 1.0f, 0.75f), vec4(1, 1, 1, 0.5f), 0)) { ClearCustomItems(s_CurCustomTab); diff --git a/src/game/client/components/menus_start.cpp b/src/game/client/components/menus_start.cpp index c4b833e5d75..e21a4f23e32 100644 --- a/src/game/client/components/menus_start.cpp +++ b/src/game/client/components/menus_start.cpp @@ -41,7 +41,7 @@ void CMenus::RenderStartMenu(CUIRect MainView) ExtMenu.VSplitLeft(100.0f, &ExtMenu, 0); ExtMenu.HSplitBottom(20.0f, &ExtMenu, &Button); - static int s_DiscordButton; + static CButtonContainer s_DiscordButton; if(DoButton_Menu(&s_DiscordButton, Localize("Discord"), 0, &Button, 0, CUI::CORNER_ALL, 5.0f, 0.0f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f))) { if(!open_link(Localize("https://ddnet.tw/discord"))) @@ -53,7 +53,7 @@ void CMenus::RenderStartMenu(CUIRect MainView) ExtMenu.HSplitBottom(5.0f, &ExtMenu, 0); // little space ExtMenu.HSplitBottom(20.0f, &ExtMenu, &Button); - static int s_LearnButton; + static CButtonContainer s_LearnButton; if(DoButton_Menu(&s_LearnButton, Localize("Learn"), 0, &Button, 0, CUI::CORNER_ALL, 5.0f, 0.0f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f))) { if(!open_link(Localize("https://wiki.ddnet.tw/"))) @@ -65,7 +65,7 @@ void CMenus::RenderStartMenu(CUIRect MainView) ExtMenu.HSplitBottom(5.0f, &ExtMenu, 0); // little space ExtMenu.HSplitBottom(20.0f, &ExtMenu, &Button); - static int s_TutorialButton; + static CButtonContainer s_TutorialButton; static float s_JoinTutorialTime = 0.0f; if(DoButton_Menu(&s_TutorialButton, Localize("Tutorial"), 0, &Button, 0, CUI::CORNER_ALL, 5.0f, 0.0f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f)) || (s_JoinTutorialTime != 0.0f && Client()->LocalTime() >= s_JoinTutorialTime)) @@ -91,7 +91,7 @@ void CMenus::RenderStartMenu(CUIRect MainView) ExtMenu.HSplitBottom(5.0f, &ExtMenu, 0); // little space ExtMenu.HSplitBottom(20.0f, &ExtMenu, &Button); - static int s_WebsiteButton; + static CButtonContainer s_WebsiteButton; if(DoButton_Menu(&s_WebsiteButton, Localize("Website"), 0, &Button, 0, CUI::CORNER_ALL, 5.0f, 0.0f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f))) { if(!open_link("https://ddnet.tw/")) @@ -103,7 +103,7 @@ void CMenus::RenderStartMenu(CUIRect MainView) ExtMenu.HSplitBottom(5.0f, &ExtMenu, 0); // little space ExtMenu.HSplitBottom(20.0f, &ExtMenu, &Button); - static int s_NewsButton; + static CButtonContainer s_NewsButton; if(DoButton_Menu(&s_NewsButton, Localize("News"), 0, &Button, 0, CUI::CORNER_ALL, 5.0f, 0.0f, vec4(0.0f, 0.0f, 0.0f, 0.5f), g_Config.m_UiUnreadNews ? vec4(0.0f, 1.0f, 0.0f, 0.25f) : vec4(0.0f, 0.0f, 0.0f, 0.25f)) || CheckHotKey(KEY_N)) NewPage = PAGE_NEWS; @@ -112,7 +112,7 @@ void CMenus::RenderStartMenu(CUIRect MainView) Menu.HSplitBottom(25.0f, &Menu, 0); Menu.HSplitBottom(40.0f, &Menu, &Button); - static int s_QuitButton; + static CButtonContainer s_QuitButton; if(DoButton_Menu(&s_QuitButton, Localize("Quit"), 0, &Button, 0, CUI::CORNER_ALL, Rounding, 0.5f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f)) || m_EscapePressed || CheckHotKey(KEY_Q)) { if(m_EscapePressed || m_pClient->Editor()->HasUnsavedData() || (Client()->GetCurrentRaceTime() / 60 >= g_Config.m_ClConfirmQuitTime && g_Config.m_ClConfirmQuitTime >= 0)) @@ -127,13 +127,13 @@ void CMenus::RenderStartMenu(CUIRect MainView) Menu.HSplitBottom(100.0f, &Menu, 0); Menu.HSplitBottom(40.0f, &Menu, &Button); - static int s_SettingsButton; + static CButtonContainer s_SettingsButton; if(DoButton_Menu(&s_SettingsButton, Localize("Settings"), 0, &Button, g_Config.m_ClShowStartMenuImages ? "settings" : 0, CUI::CORNER_ALL, Rounding, 0.5f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f)) || CheckHotKey(KEY_S)) NewPage = PAGE_SETTINGS; Menu.HSplitBottom(5.0f, &Menu, 0); // little space Menu.HSplitBottom(40.0f, &Menu, &Button); - static int s_LocalServerButton = 0; + static CButtonContainer s_LocalServerButton; if(DoButton_Menu(&s_LocalServerButton, m_ServerProcess.Process ? Localize("Stop server") : Localize("Run server"), 0, &Button, g_Config.m_ClShowStartMenuImages ? "local_server" : 0, CUI::CORNER_ALL, Rounding, 0.5f, vec4(0.0f, 0.0f, 0.0f, 0.5f), m_ServerProcess.Process ? vec4(0.0f, 1.0f, 0.0f, 0.25f) : vec4(0.0f, 0.0f, 0.0f, 0.25f)) || (CheckHotKey(KEY_R) && Input()->KeyPress(KEY_R))) { if(m_ServerProcess.Process) @@ -165,7 +165,7 @@ void CMenus::RenderStartMenu(CUIRect MainView) static float EditorHotKeyChecktime = 0.0f; Menu.HSplitBottom(5.0f, &Menu, 0); // little space Menu.HSplitBottom(40.0f, &Menu, &Button); - static int s_MapEditorButton; + static CButtonContainer s_MapEditorButton; if(DoButton_Menu(&s_MapEditorButton, Localize("Editor"), 0, &Button, g_Config.m_ClShowStartMenuImages ? "editor" : 0, CUI::CORNER_ALL, Rounding, 0.5f, vec4(0.0f, 0.0f, 0.0f, 0.5f), m_pClient->Editor()->HasUnsavedData() ? vec4(0.0f, 1.0f, 0.0f, 0.25f) : vec4(0.0f, 0.0f, 0.0f, 0.25f)) || (!EditorHotkeyWasPressed && Client()->LocalTime() - EditorHotKeyChecktime < 0.1f && CheckHotKey(KEY_E))) { g_Config.m_ClEditor = 1; @@ -180,7 +180,7 @@ void CMenus::RenderStartMenu(CUIRect MainView) Menu.HSplitBottom(5.0f, &Menu, 0); // little space Menu.HSplitBottom(40.0f, &Menu, &Button); - static int s_DemoButton; + static CButtonContainer s_DemoButton; if(DoButton_Menu(&s_DemoButton, Localize("Demos"), 0, &Button, g_Config.m_ClShowStartMenuImages ? "demos" : 0, CUI::CORNER_ALL, Rounding, 0.5f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f)) || CheckHotKey(KEY_D)) { NewPage = PAGE_DEMOS; @@ -188,7 +188,7 @@ void CMenus::RenderStartMenu(CUIRect MainView) Menu.HSplitBottom(5.0f, &Menu, 0); // little space Menu.HSplitBottom(40.0f, &Menu, &Button); - static int s_PlayButton; + static CButtonContainer s_PlayButton; if(DoButton_Menu(&s_PlayButton, Localize("Play", "Start menu"), 0, &Button, g_Config.m_ClShowStartMenuImages ? "play_game" : 0, CUI::CORNER_ALL, Rounding, 0.5f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f)) || m_EnterPressed || CheckHotKey(KEY_P)) { NewPage = g_Config.m_UiPage >= PAGE_INTERNET && g_Config.m_UiPage <= PAGE_KOG ? g_Config.m_UiPage : PAGE_DDNET; @@ -242,7 +242,7 @@ void CMenus::RenderStartMenu(CUIRect MainView) CUIRect Update; Part.VSplitLeft(100.0f, &Update, NULL); - static int s_VersionUpdate = 0; + static CButtonContainer s_VersionUpdate; if(DoButton_Menu(&s_VersionUpdate, Localize("Update now"), 0, &Update, 0, CUI::CORNER_ALL, 5.0f, 0.0f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f))) { Updater()->InitiateUpdate(); @@ -253,7 +253,7 @@ void CMenus::RenderStartMenu(CUIRect MainView) CUIRect Restart; Part.VSplitLeft(50.0f, &Restart, &Part); - static int s_VersionUpdate = 0; + static CButtonContainer s_VersionUpdate; if(DoButton_Menu(&s_VersionUpdate, Localize("Restart"), 0, &Restart, 0, CUI::CORNER_ALL, 5.0f, 0.0f, vec4(0.0f, 0.0f, 0.0f, 0.5f), vec4(0.0f, 0.0f, 0.0f, 0.25f))) { Client()->Restart(); diff --git a/src/game/client/ui.h b/src/game/client/ui.h index f834e1bda18..bb5e08a6974 100644 --- a/src/game/client/ui.h +++ b/src/game/client/ui.h @@ -187,6 +187,10 @@ struct SLabelProperties bool m_EnableWidthCheck = true; }; +class CButtonContainer +{ +}; + class CUI { bool m_Enabled;