From b211e90ffcabefc3c75cf00ee053970951f01488 Mon Sep 17 00:00:00 2001 From: Josiah Date: Wed, 21 Oct 2020 09:16:32 -0500 Subject: Prepare cheatMenu::draw function for easier UI changes. --- src/gui/cheatMenu.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/gui/cheatMenu.h') diff --git a/src/gui/cheatMenu.h b/src/gui/cheatMenu.h index e7fb4dc93..e42edfbb0 100644 --- a/src/gui/cheatMenu.h +++ b/src/gui/cheatMenu.h @@ -42,6 +42,11 @@ class CheatMenu public: CheatMenu(Client *client); + Client* getScript() + { + return m_client->getScript(); + } + void draw(video::IVideoDriver *driver, bool show_debug); void drawEntry(video::IVideoDriver *driver, std::string name, -- cgit v1.2.3 From 7aff09ab232704b0abc8d95d107c07f67f581e2e Mon Sep 17 00:00:00 2001 From: Josiah Date: Wed, 21 Oct 2020 11:47:38 -0500 Subject: Fix overindent! --- src/gui/cheatMenu.cpp | 12 ++++++------ src/gui/cheatMenu.h | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/gui/cheatMenu.h') diff --git a/src/gui/cheatMenu.cpp b/src/gui/cheatMenu.cpp index 440d3abf6..0afe1051a 100644 --- a/src/gui/cheatMenu.cpp +++ b/src/gui/cheatMenu.cpp @@ -39,8 +39,8 @@ CheatMenu::CheatMenu(Client *client) : m_client(client) } void CheatMenu::drawEntry(video::IVideoDriver *driver, std::string name, - std::size_t column_align_index, std::size_t cheat_entry_index, - bool is_selected, bool is_enabled, CheatMenuEntryType entry_type) + std::size_t column_align_index, std::size_t cheat_entry_index, + bool is_selected, bool is_enabled, CheatMenuEntryType entry_type) { int x = m_gap, y = m_gap, width = m_entry_width, height = m_entry_height; video::SColor *bgcolor = &m_bg_color, *fontcolor = &m_font_color; @@ -89,19 +89,19 @@ void CheatMenu::draw(video::IVideoDriver *driver, bool show_debug) // Draw menu header if debug info is not being drawn. if (!show_debug) drawEntry(driver, "Dragonfireclient", 0, 0, false, false, - CHEAT_MENU_ENTRY_TYPE_HEAD); + CHEAT_MENU_ENTRY_TYPE_HEAD); int category_count = 0; for (const auto &menu_item : m_cheat_categories) { bool is_selected = category_count == m_selected_category; drawEntry(driver, menu_item.m_name, category_count, 0, is_selected, - false, CHEAT_MENU_ENTRY_TYPE_CATEGORY); + false, CHEAT_MENU_ENTRY_TYPE_CATEGORY); if (is_selected && m_cheat_layer) { int cheat_count = 0; for (const auto &sub_menu_item : menu_item.m_cheats) { drawEntry(driver, sub_menu_item.m_name, category_count, cheat_count, - cheat_count == m_selected_cheat, - sub_menu_item.is_enabled()); + cheat_count == m_selected_cheat, + sub_menu_item.is_enabled()); cheat_count++; } } diff --git a/src/gui/cheatMenu.h b/src/gui/cheatMenu.h index e42edfbb0..5aba306e0 100644 --- a/src/gui/cheatMenu.h +++ b/src/gui/cheatMenu.h @@ -50,9 +50,9 @@ public: void draw(video::IVideoDriver *driver, bool show_debug); void drawEntry(video::IVideoDriver *driver, std::string name, - std::size_t column_align_index, std::size_t cheat_entry_index, - bool is_selected, bool is_enabled, - CheatMenuEntryType entry_type = CHEAT_MENU_ENTRY_TYPE_ENTRY); + std::size_t column_align_index, std::size_t cheat_entry_index, + bool is_selected, bool is_enabled, + CheatMenuEntryType entry_type = CHEAT_MENU_ENTRY_TYPE_ENTRY); void selectUp(); void selectDown(); -- cgit v1.2.3 From f236476af96cfc468d0a76a2f8215f566d1b7de1 Mon Sep 17 00:00:00 2001 From: Josiah VanderZee Date: Wed, 21 Oct 2020 18:53:38 -0500 Subject: Fix errors in cheatMenu. --- src/gui/cheatMenu.cpp | 16 ++++++++-------- src/gui/cheatMenu.h | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src/gui/cheatMenu.h') diff --git a/src/gui/cheatMenu.cpp b/src/gui/cheatMenu.cpp index e37f584fd..9949becc3 100644 --- a/src/gui/cheatMenu.cpp +++ b/src/gui/cheatMenu.cpp @@ -78,7 +78,7 @@ void CheatMenu::drawEntry(video::IVideoDriver *driver, std::string name, } void CheatMenu::draw(video::IVideoDriver *driver, bool show_debug) - +{ ClientScripting *script{ getScript() }; if (!script || !script->m_cheats_loaded) return; @@ -89,16 +89,16 @@ void CheatMenu::draw(video::IVideoDriver *driver, bool show_debug) CHEAT_MENU_ENTRY_TYPE_HEAD); int category_count = 0; - for (const auto &menu_item : m_cheat_categories) { + for (const auto &menu_item : script->m_cheat_categories) { bool is_selected = category_count == m_selected_category; - drawEntry(driver, menu_item.m_name, category_count, 0, is_selected, + drawEntry(driver, menu_item->m_name, category_count, 0, is_selected, false, CHEAT_MENU_ENTRY_TYPE_CATEGORY); if (is_selected && m_cheat_layer) { int cheat_count = 0; - for (const auto &sub_menu_item : menu_item.m_cheats) { - drawEntry(driver, sub_menu_item.m_name, category_count, cheat_count, - cheat_count == m_selected_cheat, - sub_menu_item.is_enabled()); + for (const auto &sub_menu_item : menu_item->m_cheats) { + drawEntry(driver, sub_menu_item->m_name, category_count, + cheat_count, cheat_count == m_selected_cheat, + sub_menu_item->is_enabled()); cheat_count++; } } @@ -166,4 +166,4 @@ void CheatMenu::selectConfirm() if (m_cheat_layer) script->toggle_cheat(script->m_cheat_categories[m_selected_category] ->m_cheats[m_selected_cheat]); -} \ No newline at end of file +} diff --git a/src/gui/cheatMenu.h b/src/gui/cheatMenu.h index 018b63ae0..dfe92798b 100644 --- a/src/gui/cheatMenu.h +++ b/src/gui/cheatMenu.h @@ -16,7 +16,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #pragma once +#include "client/client.h" #include "irrlichttypes_extrabloated.h" +#include "script/scripting_client.h" #include #include @@ -25,8 +27,6 @@ with this program; if not, write to the Free Software Foundation, Inc., if (!script || !script->m_cheats_loaded) \ return; -class Client; - enum CheatMenuEntryType { CHEAT_MENU_ENTRY_TYPE_HEAD, @@ -39,7 +39,7 @@ class CheatMenu public: CheatMenu(Client *client); - Client* getScript() + ClientScripting *getScript() { return m_client->getScript(); } @@ -76,4 +76,4 @@ private: gui::IGUIFont *m_font = nullptr; v2u32 m_fontsize; -}; \ No newline at end of file +}; -- cgit v1.2.3