diff options
author | Elias Fleckenstein <54945686+EliasFleckenstein03@users.noreply.github.com> | 2020-11-04 14:40:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-04 14:40:00 +0100 |
commit | fc8c8f01ca15912b1db176fec473bcfb0333032f (patch) | |
tree | 08182e80b69d5352f81c6827d3caa4efe13e6f14 /src/gui/cheatMenu.cpp | |
parent | 61e2b3a33190d5979bc2e36f9734cebd18465f26 (diff) | |
parent | a7dc1135e94bde5f8c3385d54388563eaffe7553 (diff) | |
download | dragonfireclient-fc8c8f01ca15912b1db176fec473bcfb0333032f.tar.xz |
Merge branch 'master' into master
Diffstat (limited to 'src/gui/cheatMenu.cpp')
-rw-r--r-- | src/gui/cheatMenu.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/gui/cheatMenu.cpp b/src/gui/cheatMenu.cpp index f4f85c7fe..5a7f52477 100644 --- a/src/gui/cheatMenu.cpp +++ b/src/gui/cheatMenu.cpp @@ -151,6 +151,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::selectLeft() { CHEAT_MENU_GET_SCRIPTPTR |