11#include " Menu.h"
22
33#include " ../utils/utils.h"
4+ #include " ../configuration/Configuration.h"
45
56Menu::Menu (std::string id, std::string title, std::string color, std::vector<std::pair<std::string, std::string>> options, bool tmp)
67{
@@ -43,27 +44,28 @@ size_t Menu::GetItemsOnPage(int page)
4344 return processedOptions[page - 1 ].size ();
4445}
4546
46- // TODO: Translation for Next, Back, Exit (Maybe a file called Generic for generic translations?)
4747void Menu::ProcessOptions ()
4848{
4949 int pages = 0 ;
5050 int processedItems = 0 ;
5151 int totalProcessedItems = 0 ;
5252 std::vector<std::pair<std::string, std::string>> tempmap;
5353
54+ int maxProcessedItems = (g_Config->FetchValue <bool >(" core.menu.buttons.exit.option" ) ? (pages == 0 ? 4 : 3 ) : (pages == 0 ? 5 : 4 ));
5455 for (const std::pair<std::string, std::string> entry : this ->options )
5556 {
5657 ++processedItems;
5758 ++totalProcessedItems;
5859 tempmap.push_back ({entry.first , entry.second });
59- if (processedItems == (pages == 0 ? 4 : 3 ) )
60+ if (processedItems == maxProcessedItems )
6061 {
6162 if (options.size () - totalProcessedItems > 0 )
6263 tempmap.push_back ({g_translations->FetchTranslation (" core.menu.next" ), " menunext" });
6364 if (pages != 0 )
6465 tempmap.push_back ({g_translations->FetchTranslation (" core.menu.back" ), " menuback" });
6566
66- tempmap.push_back ({g_translations->FetchTranslation (" core.menu.exit" ), " menuexit" });
67+ if (g_Config->FetchValue <bool >(" core.menu.buttons.exit.option" ))
68+ tempmap.push_back ({g_translations->FetchTranslation (" core.menu.exit" ), " menuexit" });
6769
6870 processedItems = 0 ;
6971 pages++;
@@ -77,7 +79,8 @@ void Menu::ProcessOptions()
7779 if (this ->processedOptions .size () != 0 )
7880 tempmap.push_back ({g_translations->FetchTranslation (" core.menu.back" ), " menuback" });
7981
80- tempmap.push_back ({g_translations->FetchTranslation (" core.menu.exit" ), " menuexit" });
82+ if (g_Config->FetchValue <bool >(" core.menu.buttons.exit.option" ))
83+ tempmap.push_back ({g_translations->FetchTranslation (" core.menu.exit" ), " menuexit" });
8184
8285 processedItems = 0 ;
8386 this ->processedOptions .push_back (tempmap);
@@ -104,7 +107,13 @@ void Menu::RegeneratePage(int playerid, int page, int selected)
104107 for (int i = 0 ; i < processedOptions[page - 1 ].size (); i++)
105108 stringPage += string_format (" <div><font color=\" #%s\" >%s%s</font></div><br/>" , (i == selected ? this ->color .c_str () : " ffffff" ), (i == selected ? " ➤ " : " " ), processedOptions[page - 1 ][i].first .c_str ());
106109
107- stringPage += string_format (" <font class='fontSize-s'>%s</font>" , replace (replace (g_translations->FetchTranslation (" core.menu.footer" ), " {PAGE}" , std::to_string (page)), " {MAXPAGES}" , std::to_string (processedOptions.size ())).c_str ());
110+ std::string footer = replace (g_translations->FetchTranslation (g_Config->FetchValue <bool >(" core.menu.buttons.exit.option" ) ? " core.menu.footer" : " core.menu.footer.nooption" ), " {PAGE}" , std::to_string (page));
111+ footer = replace (footer, " {MAXPAGES}" , std::to_string (processedOptions.size ()));
112+ footer = replace (footer, " {CYCLE_BUTTON}" , str_toupper (g_Config->FetchValue <std::string>(" core.menu.buttons.scroll" )));
113+ footer = replace (footer, " {USE_BUTTON}" , str_toupper (g_Config->FetchValue <std::string>(" core.menu.buttons.use" )));
114+ footer = replace (footer, " {EXIT_BUTTON}" , str_toupper (g_Config->FetchValue <std::string>(" core.menu.buttons.exit.button" )));
115+
116+ stringPage += string_format (" <font class='fontSize-s'>%s</font>" , footer.c_str ());
108117
109118 this ->generatedPages [playerid][page - 1 ] = stringPage;
110119}
0 commit comments