]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Added CheatHUD
authorElias Fleckenstein <eliasfleckenstein@web.de>
Wed, 4 Nov 2020 13:19:15 +0000 (14:19 +0100)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Wed, 4 Nov 2020 13:19:15 +0000 (14:19 +0100)
builtin/client/cheats/init.lua
builtin/settingtypes.txt
src/client/game.cpp
src/defaultsettings.cpp
src/gui/cheatMenu.cpp
src/gui/cheatMenu.h

index 466ce4aee919f735ca93ce9df2dca263ae69b1ed..03fc20c60246253404e63e115cbb2a8efdb53a70 100644 (file)
@@ -27,6 +27,7 @@ core.cheats = {
                ["Coords"] = "coords",
                ["Tracers"] = "enable_tracers",
                ["ESP"] = "enable_esp",
+               ["CheatHUD"] = "cheat_hud",
        },
        ["World"] = {
                ["FastDig"] = "fastdig",
index ec05c619601187b742d969af0dd81dc703fd9d80..adb8e7a0035ffdc85ce22f4bf3dea6c2b31f851d 100644 (file)
@@ -2318,3 +2318,5 @@ chat_reverse (ReversedChat) bool false
 forcefield (Forcefield) bool false
 
 friendlist (Killaura / Forcefield Friendlist) string
+
+cheat_hud (CheatHUD) bool true
index 491d55a348d913440aa20768ecd41cd70452a050..479484ae92a327817cd93e02d12e3b4c74c5d8e6 100644 (file)
@@ -3206,9 +3206,12 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
                Cheat menu
        */
 
-       if (m_game_ui->m_flags.show_cheat_menu && ! gui_chat_console->isOpen())
-               m_cheat_menu->draw(driver, m_game_ui->m_flags.show_debug);
-               
+       if (! gui_chat_console->isOpen()) {
+               if (m_game_ui->m_flags.show_cheat_menu)
+                       m_cheat_menu->draw(driver, m_game_ui->m_flags.show_debug);
+               if (g_settings->getBool("cheat_hud"))
+                       m_cheat_menu->drawHUD(driver, dtime);
+       }
        /*
                Damage flash
        */
index bcdd8007498e61635183b306f99332206a8a0f4c..9e32a11fed1038d0feaa741ad293be78ffd8390e 100644 (file)
@@ -119,6 +119,7 @@ void set_default_settings(Settings *settings)
        settings->setDefault("chat_reverse", "false");
        settings->setDefault("forcefield", "false");
        settings->setDefault("friendlist", "");
+       settings->setDefault("cheat_hud", "true");
 
        // Keymap
        settings->setDefault("remote_port", "30000");
index f796fb0ba256111d90a3ceb96412cab2a0f9e3dc..1485541c255e375b542ec8d04fd3b0b4149ee6e0 100644 (file)
@@ -94,6 +94,72 @@ void CheatMenu::draw(video::IVideoDriver *driver, bool show_debug)
        }
 }
 
+void CheatMenu::drawHUD(video::IVideoDriver *driver, double dtime)
+{
+       CHEAT_MENU_GET_SCRIPTPTR
+       
+       m_rainbow_offset += dtime;
+
+       m_rainbow_offset = fmod(m_rainbow_offset, 6.0f);
+       
+       std::vector<std::string> enabled_cheats;
+       
+       int cheat_count = 0;
+       
+       for (auto category = script->m_cheat_categories.begin(); category != script->m_cheat_categories.end(); category++) {
+               for (auto cheat = (*category)->m_cheats.begin(); cheat != (*category)->m_cheats.end(); cheat++) {
+                       if ((*cheat)->is_enabled()) {
+                               enabled_cheats.push_back((*cheat)->m_name);
+                               cheat_count++;
+                       }
+               }
+       }
+       
+       if (enabled_cheats.empty())
+               return;
+       
+       std::vector<video::SColor> colors;
+       
+       for (int i = 0; i < cheat_count; i++) {
+               video::SColor color;
+               f32 h = (f32)i * 2.0f / (f32)cheat_count - m_rainbow_offset;
+               if (h < 0)
+                       h = 6.0f + h;
+               f32 x = (1 - fabs(fmod(h, 2.0f) - 1.0f)) * 255.0f;
+               switch((int)h) {
+               case 0:
+                       color = video::SColor(255, 255, x, 0); break;
+               case 1:
+                       color = video::SColor(255, x, 255, 0); break;
+               case 2:
+                       color = video::SColor(255, 0, 255, x); break;
+               case 3:
+                       color = video::SColor(255, 0, x, 255); break;
+               case 4:
+                       color = video::SColor(255, x, 0, 255); break;
+               case 5:
+                       color = video::SColor(255, 255, 0, x); break;
+               }
+               colors.push_back(color);
+       }
+       
+       core::dimension2d<u32> screensize = driver->getScreenSize();
+       
+       u32 y = 5;
+       
+       int i = 0;
+       for (std::string cheat : enabled_cheats) {
+               core::dimension2d<u32> dim = m_font->getDimension(utf8_to_wide(cheat).c_str());
+               u32 x = screensize.Width - 5 - dim.Width;
+               
+               core::rect<s32> fontbounds(x, y, x + dim.Width, y + dim.Height);
+               m_font->draw(cheat.c_str(), fontbounds, colors[i], false, false);
+               
+               y += dim.Height;
+               i++;
+       }
+}
+
 void CheatMenu::selectUp()
 {
        CHEAT_MENU_GET_SCRIPTPTR
index ea9a9d8536376b2eba8c13700176756d16da3b7f..f67cdea5ae532cc8be1c3bee86bac96dd7aa1f1e 100644 (file)
@@ -42,6 +42,8 @@ class CheatMenu
        CheatMenu(Client *client);
 
        void draw(video::IVideoDriver *driver, bool show_debug);
+       
+       void drawHUD(video::IVideoDriver *driver, double dtime);
 
        void drawEntry(video::IVideoDriver *driver, std::string name, int number,
                        bool selected, bool active,
@@ -72,4 +74,6 @@ class CheatMenu
 
        gui::IGUIFont *m_font = nullptr;
        v2u32 m_fontsize;
+       
+       float m_rainbow_offset = 0.0;
 };