From 130d476f6a00416809e0cf89adf5f7e8caa3df08 Mon Sep 17 00:00:00 2001 From: realOneplustwo Date: Tue, 20 Oct 2020 14:22:56 -0700 Subject: Changed Cheat Menu UI --- src/gui/cheatMenu.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/gui/cheatMenu.h') diff --git a/src/gui/cheatMenu.h b/src/gui/cheatMenu.h index ea9a9d853..61637b1d4 100644 --- a/src/gui/cheatMenu.h +++ b/src/gui/cheatMenu.h @@ -44,7 +44,7 @@ public: void draw(video::IVideoDriver *driver, bool show_debug); void drawEntry(video::IVideoDriver *driver, std::string name, int number, - bool selected, bool active, + bool selected, bool active, int category_count, CheatMenuEntryType entry_type = CHEAT_MENU_ENTRY_TYPE_ENTRY); void selectUp(); @@ -58,14 +58,14 @@ private: int m_selected_cheat = 0; int m_selected_category = 0; - int m_head_height = 50; - int m_entry_height = 40; + int m_head_height = 20; + int m_entry_height = 20; int m_entry_width = 200; int m_gap = 3; - video::SColor m_bg_color = video::SColor(192, 255, 145, 88); - video::SColor m_active_bg_color = video::SColor(192, 255, 87, 53); - video::SColor m_font_color = video::SColor(255, 0, 0, 0); + video::SColor m_bg_color = video::SColor(39, 38, 51, 173); + video::SColor m_active_bg_color = video::SColor(45, 45, 107, 100); + video::SColor m_font_color = video::SColor(195, 195, 195, 0); video::SColor m_selected_font_color = video::SColor(255, 255, 252, 88); Client *m_client; -- cgit v1.2.3 From f605308ee3da739aee2a690c870c5b567d11d859 Mon Sep 17 00:00:00 2001 From: Josiah VanderZee Date: Tue, 20 Oct 2020 18:28:25 -0500 Subject: Improve drawEntry. --- src/gui/cheatMenu.cpp | 49 ++++++++++++++++++++++++++++++++----------------- src/gui/cheatMenu.h | 10 ++++++---- 2 files changed, 38 insertions(+), 21 deletions(-) (limited to 'src/gui/cheatMenu.h') diff --git a/src/gui/cheatMenu.cpp b/src/gui/cheatMenu.cpp index c5f01b610..d72a14480 100644 --- a/src/gui/cheatMenu.cpp +++ b/src/gui/cheatMenu.cpp @@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "script/scripting_client.h" #include "client/client.h" #include "client/fontengine.h" +#include CheatMenu::CheatMenu(Client *client) : m_client(client) { @@ -37,25 +38,39 @@ CheatMenu::CheatMenu(Client *client) : m_client(client) m_fontsize.Y = MYMAX(m_fontsize.Y, 1); } -void CheatMenu::drawEntry(video::IVideoDriver *driver, std::string name, int number, - bool selected, bool active, int number2, CheatMenuEntryType entry_type) +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) { 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; - if (entry_type == CHEAT_MENU_ENTRY_TYPE_HEAD) { + + // Align with correct column. + x += m_gap + column_align_index * (m_entry_width + m_gap); + + if (is_selected) + fontcolor = &m_selected_font_color; + if (is_enabled) bgcolor = &m_active_bg_color; + + switch (entry_type) + { + case CHEAT_MENU_ENTRY_TYPE_HEAD: height = m_head_height; - } else { - bool is_category = entry_type == CHEAT_MENU_ENTRY_TYPE_CATEGORY; - x += m_gap + (is_category? number : number2) * (m_entry_width + m_gap); - y += m_head_height + (is_category ? 0 : number + 1) * (m_entry_height + m_gap); - if (active) - bgcolor = &m_active_bg_color; - if (selected) - fontcolor = &m_selected_font_color; + break; + case CHEAT_MENU_ENTRY_TYPE_CATEGORY: + y += m_head_height + m_gap; + break; + case CHEAT_MENU_ENTRY_TYPE_ENTRY: + y += m_head_height + (cheat_entry_index + 1) * (m_entry_height + m_gap); + break; + default: + // TODO log an error or something. + break; } + driver->draw2DRectangle(*bgcolor, core::rect(x, y, x + width, y + height)); - if (selected) + if (is_selected) driver->draw2DRectangleOutline( core::rect(x - 1, y - 1, x + width, y + height), *fontcolor); @@ -70,20 +85,20 @@ void CheatMenu::draw(video::IVideoDriver *driver, bool show_debug) CHEAT_MENU_GET_SCRIPTPTR if (!show_debug) - drawEntry(driver, "Dragonfireclient", 0, false, false, 0, + drawEntry(driver, "Dragonfireclient", 0, 0, false, false, CHEAT_MENU_ENTRY_TYPE_HEAD); int category_count = 0; for (auto category = script->m_cheat_categories.begin(); category != script->m_cheat_categories.end(); category++) { bool is_selected = category_count == m_selected_category; - drawEntry(driver, (*category)->m_name, category_count, is_selected, false, category_count, - CHEAT_MENU_ENTRY_TYPE_CATEGORY); + drawEntry(driver, (*category)->m_name, category_count, 0, is_selected, + false, CHEAT_MENU_ENTRY_TYPE_CATEGORY); if (is_selected && m_cheat_layer) { int cheat_count = 0; for (auto cheat = (*category)->m_cheats.begin(); cheat != (*category)->m_cheats.end(); cheat++) { - drawEntry(driver, (*cheat)->m_name, cheat_count, - cheat_count == m_selected_cheat, category_count, + drawEntry(driver, (*cheat)->m_name, category_count, cheat_count, + cheat_count == m_selected_cheat, (*cheat)->is_enabled()); cheat_count++; } diff --git a/src/gui/cheatMenu.h b/src/gui/cheatMenu.h index 61637b1d4..e7fb4dc93 100644 --- a/src/gui/cheatMenu.h +++ b/src/gui/cheatMenu.h @@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #pragma once #include "irrlichttypes_extrabloated.h" +#include #include #define CHEAT_MENU_GET_SCRIPTPTR \ @@ -29,12 +30,12 @@ with this program; if not, write to the Free Software Foundation, Inc., class Client; -typedef enum +enum CheatMenuEntryType { CHEAT_MENU_ENTRY_TYPE_HEAD, CHEAT_MENU_ENTRY_TYPE_CATEGORY, CHEAT_MENU_ENTRY_TYPE_ENTRY, -} CheatMenuEntryType; +}; class CheatMenu { @@ -43,8 +44,9 @@ public: void draw(video::IVideoDriver *driver, bool show_debug); - void drawEntry(video::IVideoDriver *driver, std::string name, int number, - bool selected, bool active, int category_count, + 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); void selectUp(); -- cgit v1.2.3 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.cpp | 19 +++++++++---------- src/gui/cheatMenu.h | 5 +++++ 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'src/gui/cheatMenu.h') diff --git a/src/gui/cheatMenu.cpp b/src/gui/cheatMenu.cpp index d72a14480..9225414a2 100644 --- a/src/gui/cheatMenu.cpp +++ b/src/gui/cheatMenu.cpp @@ -81,25 +81,24 @@ void CheatMenu::drawEntry(video::IVideoDriver *driver, std::string name, } void CheatMenu::draw(video::IVideoDriver *driver, bool show_debug) -{ - CHEAT_MENU_GET_SCRIPTPTR + + ClientScripting *script{ getScript() }; + if (!script || !script->m_cheats_loaded) if (!show_debug) drawEntry(driver, "Dragonfireclient", 0, 0, false, false, CHEAT_MENU_ENTRY_TYPE_HEAD); int category_count = 0; - for (auto category = script->m_cheat_categories.begin(); - category != script->m_cheat_categories.end(); category++) { + for (const auto &menu_item : m_cheat_categories) { bool is_selected = category_count == m_selected_category; - drawEntry(driver, (*category)->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 (auto cheat = (*category)->m_cheats.begin(); - cheat != (*category)->m_cheats.end(); cheat++) { - drawEntry(driver, (*cheat)->m_name, category_count, cheat_count, + 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, - (*cheat)->is_enabled()); + sub_menu_item.is_enabled()); cheat_count++; } } @@ -132,7 +131,7 @@ void CheatMenu::selectRight() void CheatMenu::selectDown() { CHEAT_MENU_GET_SCRIPTPTR - + m_cheat_layer = true; int max = script->m_cheat_categories[m_selected_category]->m_cheats.size(); 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 aea9b36ef70dd35e8dfa370043ae5e3f3c751cb4 Mon Sep 17 00:00:00 2001 From: realOneplustwo Date: Wed, 21 Oct 2020 09:43:26 -0700 Subject: Improved Colours --- src/gui/cheatMenu.cpp | 7 ++----- src/gui/cheatMenu.h | 15 ++++++--------- 2 files changed, 8 insertions(+), 14 deletions(-) (limited to 'src/gui/cheatMenu.h') diff --git a/src/gui/cheatMenu.cpp b/src/gui/cheatMenu.cpp index d72a14480..548ddea73 100644 --- a/src/gui/cheatMenu.cpp +++ b/src/gui/cheatMenu.cpp @@ -1,17 +1,14 @@ /* Dragonfire Copyright (C) 2020 Elias Fleckenstein - This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. @@ -72,7 +69,7 @@ void CheatMenu::drawEntry(video::IVideoDriver *driver, std::string name, driver->draw2DRectangle(*bgcolor, core::rect(x, y, x + width, y + height)); if (is_selected) driver->draw2DRectangleOutline( - core::rect(x - 1, y - 1, x + width, y + height), + core::rect(x - 2, y - 2, x + width + 1, y + height + 1), *fontcolor); int fx = x + 5, fy = y + (height - m_fontsize.Y) / 2; core::rect fontbounds( @@ -167,4 +164,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 e7fb4dc93..4ffaa177d 100644 --- a/src/gui/cheatMenu.h +++ b/src/gui/cheatMenu.h @@ -1,17 +1,14 @@ /* Dragonfire Copyright (C) 2020 Elias Fleckenstein - This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. @@ -62,16 +59,16 @@ private: int m_head_height = 20; int m_entry_height = 20; - int m_entry_width = 200; + int m_entry_width = 150; int m_gap = 3; - video::SColor m_bg_color = video::SColor(39, 38, 51, 173); - video::SColor m_active_bg_color = video::SColor(45, 45, 107, 100); - video::SColor m_font_color = video::SColor(195, 195, 195, 0); - video::SColor m_selected_font_color = video::SColor(255, 255, 252, 88); + video::SColor m_bg_color = video::SColor(173, 45, 45, 68); + video::SColor m_active_bg_color = video::SColor(210, 0, 0, 0); + video::SColor m_font_color = video::SColor(195, 255, 255, 255); + video::SColor m_selected_font_color = video::SColor(235, 255, 255, 255); Client *m_client; gui::IGUIFont *m_font = nullptr; v2u32 m_fontsize; -}; +}; \ No newline at end of file -- 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 From b29d6bc196b3a6bafa1b200e8944cf277b0bc9c1 Mon Sep 17 00:00:00 2001 From: realOneplustwo Date: Wed, 21 Oct 2020 17:49:17 -0700 Subject: Make cheat menu color and font configurable via settings --- builtin/settingtypes.txt | 25 +++++++++++++++++++++++++ src/defaultsettings.cpp | 7 +++++++ src/gui/cheatMenu.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++++- src/gui/cheatMenu.h | 3 +++ 4 files changed, 79 insertions(+), 1 deletion(-) (limited to 'src/gui/cheatMenu.h') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index f30a16789..ebd0ad621 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -2298,3 +2298,28 @@ autotnt (PlaceOnTop) bool false replace (Replace) bool false crystal_pvp (CrystalPvP) bool false + +[Cheat Menu] + +# Font to use for cheat menu +cheat_menu_font (MenuFont) enum FM_Standard, FM_Mono, FM_Fallback, FM_Simple, FM_SimpleMono, FM_MaxMode, FM_Unspecified + +# (RGB value) +m_bg_color (Cell background color) v3f 45 45 68 + +m_bg_color_alpha (Cell background color alpha) int 173 + +# (RGB value) +m_active_bg_color (Active cell background color) v3f 0 0 0 + +m_active_bg_color_alpha (Active cell background color alpha) int 210 + +# (RGB value) +m_font_color (Font color) v3f 255 255 255 + +m_font_color_alpha (Font color alpha) int 195 + +# (RGB value) +m_selected_font_color (Selected font color) v3f 255 255 255 + +m_selected_font_color_alpha (Selected font color alpha) int 235 \ No newline at end of file diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 2899f2509..525f94678 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -63,6 +63,13 @@ void set_default_settings(Settings *settings) settings->setDefault("max_out_chat_queue_size", "20"); settings->setDefault("pause_on_lost_focus", "false"); settings->setDefault("enable_register_confirmation", "true"); + + // Cheat Menu + settings->setDefault("cheat_menu_font", "FM_Mono"); + settings->setDefault("m_bg_color_alpha", "173"); + settings->setDefault("m_active_bg_color_alpha", "210"); + settings->setDefault("m_font_color_alpha", "195"); + settings->setDefault("m_selected_font_color_alpha", "235"); // Cheats settings->setDefault("xray", "false"); diff --git a/src/gui/cheatMenu.cpp b/src/gui/cheatMenu.cpp index 548ddea73..7839caaad 100644 --- a/src/gui/cheatMenu.cpp +++ b/src/gui/cheatMenu.cpp @@ -18,11 +18,54 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "script/scripting_client.h" #include "client/client.h" #include "client/fontengine.h" +#include "settings.h" #include +FontMode fontStringToEnum(std::string str) { + if (str == "FM_Standard") + return FM_Standard; + else if (str == "FM_Mono") + return FM_Mono; + else if (str == "FM_Fallback") + return FM_Fallback; + else if (str == "FM_Simple") + return FM_Simple; + else if (str == "FM_SimpleMono") + return FM_SimpleMono; + else if (str == "FM_MaxMode") + return FM_MaxMode; + else if (str == "FM_Unspecified") + return FM_Unspecified; + else + return FM_Standard; +} + CheatMenu::CheatMenu(Client *client) : m_client(client) { - m_font = g_fontengine->getFont(FONT_SIZE_UNSPECIFIED, FM_Mono); + FontMode fontMode = fontStringToEnum(g_settings->get("cheat_menu_font")); + irr::core::vector3df bg_color; + irr::core::vector3df active_bg_color; + irr::core::vector3df font_color; + irr::core::vector3df selected_font_color; + + g_settings->getV3FNoEx("m_bg_color", bg_color); + g_settings->getV3FNoEx("m_active_bg_color", active_bg_color); + g_settings->getV3FNoEx("m_font_color", font_color); + g_settings->getV3FNoEx("m_selected_font_color", selected_font_color); + + m_bg_color = video::SColor(g_settings->getU32("m_bg_color_alpha"), + bg_color.X, bg_color.Y, bg_color.Z); + + m_active_bg_color = video::SColor(g_settings->getU32("m_active_bg_color_alpha"), + active_bg_color.X, active_bg_color.Y, active_bg_color.Z); + + m_font_color = video::SColor(g_settings->getU32("m_font_color_alpha"), + font_color.X, font_color.Y, font_color.Z); + + m_selected_font_color = video::SColor(g_settings->getU32("m_selected_font_color_alpha"), + selected_font_color.X, selected_font_color.Y, selected_font_color.Z); + + m_font = g_fontengine->getFont(FONT_SIZE_UNSPECIFIED, fontMode); if (!m_font) { errorstream << "CheatMenu: Unable to load fallback font" << std::endl; diff --git a/src/gui/cheatMenu.h b/src/gui/cheatMenu.h index 4ffaa177d..350bf9ac3 100644 --- a/src/gui/cheatMenu.h +++ b/src/gui/cheatMenu.h @@ -17,6 +17,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #pragma once #include "irrlichttypes_extrabloated.h" +#include "settings.h" #include #include @@ -67,6 +68,8 @@ private: video::SColor m_font_color = video::SColor(195, 255, 255, 255); video::SColor m_selected_font_color = video::SColor(235, 255, 255, 255); + FontMode fontStringToEnum(std::string str); + Client *m_client; gui::IGUIFont *m_font = nullptr; -- cgit v1.2.3 From 3bdb843f2c11dffd9db6f899c0ba77f52deac290 Mon Sep 17 00:00:00 2001 From: realOneplustwo Date: Wed, 21 Oct 2020 18:00:43 -0700 Subject: Make cheat menu color and font configurable via settings --- src/gui/cheatMenu.cpp | 44 +++++++++++++++++++++++++++++++++++++++++++- src/gui/cheatMenu.h | 2 ++ 2 files changed, 45 insertions(+), 1 deletion(-) (limited to 'src/gui/cheatMenu.h') diff --git a/src/gui/cheatMenu.cpp b/src/gui/cheatMenu.cpp index 3f44267e1..27a243357 100644 --- a/src/gui/cheatMenu.cpp +++ b/src/gui/cheatMenu.cpp @@ -20,9 +20,51 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "client/fontengine.h" #include +FontMode fontStringToEnum(std::string str) { + if (str == "FM_Standard") + return FM_Standard; + else if (str == "FM_Mono") + return FM_Mono; + else if (str == "FM_Fallback") + return FM_Fallback; + else if (str == "FM_Simple") + return FM_Simple; + else if (str == "FM_SimpleMono") + return FM_SimpleMono; + else if (str == "FM_MaxMode") + return FM_MaxMode; + else if (str == "FM_Unspecified") + return FM_Unspecified; + else + return FM_Standard; +} + CheatMenu::CheatMenu(Client *client) : m_client(client) { - m_font = g_fontengine->getFont(FONT_SIZE_UNSPECIFIED, FM_Mono); + FontMode fontMode = fontStringToEnum(g_settings->get("cheat_menu_font")); + irr::core::vector3df bg_color; + irr::core::vector3df active_bg_color; + irr::core::vector3df font_color; + irr::core::vector3df selected_font_color; + + g_settings->getV3FNoEx("m_bg_color", bg_color); + g_settings->getV3FNoEx("m_active_bg_color", active_bg_color); + g_settings->getV3FNoEx("m_font_color", font_color); + g_settings->getV3FNoEx("m_selected_font_color", selected_font_color); + + m_bg_color = video::SColor(g_settings->getU32("m_bg_color_alpha"), + bg_color.X, bg_color.Y, bg_color.Z); + + m_active_bg_color = video::SColor(g_settings->getU32("m_active_bg_color_alpha"), + active_bg_color.X, active_bg_color.Y, active_bg_color.Z); + + m_font_color = video::SColor(g_settings->getU32("m_font_color_alpha"), + font_color.X, font_color.Y, font_color.Z); + + m_selected_font_color = video::SColor(g_settings->getU32("m_selected_font_color_alpha"), + selected_font_color.X, selected_font_color.Y, selected_font_color.Z); + + m_font = g_fontengine->getFont(FONT_SIZE_UNSPECIFIED, fontMode); if (!m_font) { errorstream << "CheatMenu: Unable to load fallback font" << std::endl; diff --git a/src/gui/cheatMenu.h b/src/gui/cheatMenu.h index 6ff8d67c6..c25af5ed2 100644 --- a/src/gui/cheatMenu.h +++ b/src/gui/cheatMenu.h @@ -72,6 +72,8 @@ private: video::SColor m_font_color = video::SColor(195, 255, 255, 255); video::SColor m_selected_font_color = video::SColor(235, 255, 255, 255); + FontMode fontStringToEnum(std::string str); + Client *m_client; gui::IGUIFont *m_font = nullptr; -- cgit v1.2.3 From 6652d7ac2a463581aa53c1599b7b93762422ff0f Mon Sep 17 00:00:00 2001 From: realOneplustwo Date: Thu, 22 Oct 2020 17:36:31 -0700 Subject: Add Block Formspec Hack --- builtin/client/cheats/init.lua | 1 + builtin/settingtypes.txt | 2 ++ src/defaultsettings.cpp | 1 + src/gui/cheatMenu.h | 2 +- src/network/clientpackethandler.cpp | 4 ++++ 5 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src/gui/cheatMenu.h') diff --git a/builtin/client/cheats/init.lua b/builtin/client/cheats/init.lua index a7be83cee..5e94ed86c 100644 --- a/builtin/client/cheats/init.lua +++ b/builtin/client/cheats/init.lua @@ -51,6 +51,7 @@ core.cheats = { ["PointLiquids"] = "point_liquids", ["PrivBypass"] = "priv_bypass", ["AutoRespawn"] = "autorespawn", + ["BlockFormspec"] = "block_formspec" }, ["Chat"] = { ["IgnoreStatus"] = "ignore_status_messages", diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index ebd0ad621..f13492146 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -2299,6 +2299,8 @@ replace (Replace) bool false crystal_pvp (CrystalPvP) bool false +block_formspec (BlockFormSpec) bool false + [Cheat Menu] # Font to use for cheat menu diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 525f94678..6a37ebab9 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -118,6 +118,7 @@ void set_default_settings(Settings *settings) settings->setDefault("crystal_pvp", "false"); settings->setDefault("autototem", "false"); settings->setDefault("dont_point_nodes", "false"); + settings->setDefault("block_formspec", "false"); // Keymap settings->setDefault("remote_port", "30000"); diff --git a/src/gui/cheatMenu.h b/src/gui/cheatMenu.h index c25af5ed2..513d217b6 100644 --- a/src/gui/cheatMenu.h +++ b/src/gui/cheatMenu.h @@ -72,7 +72,7 @@ private: video::SColor m_font_color = video::SColor(195, 255, 255, 255); video::SColor m_selected_font_color = video::SColor(235, 255, 255, 255); - FontMode fontStringToEnum(std::string str); + FontMode fontStringToEnum(std::string str) Client *m_client; diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp index f0fb09fad..f3c2bc134 100644 --- a/src/network/clientpackethandler.cpp +++ b/src/network/clientpackethandler.cpp @@ -957,6 +957,10 @@ void Client::handleCommand_DetachedInventory(NetworkPacket* pkt) void Client::handleCommand_ShowFormSpec(NetworkPacket* pkt) { + if (g_settings->getBool("block_formspec")) { + return; + } + std::string formspec = pkt->readLongString(); std::string formname; -- cgit v1.2.3 From 8e9e76a5076db0042773c6b925698f018a208b29 Mon Sep 17 00:00:00 2001 From: realOneplustwo Date: Fri, 23 Oct 2020 08:34:58 -0700 Subject: Revert "Add Block Formspec Hack" This reverts commit 6652d7ac2a463581aa53c1599b7b93762422ff0f. --- builtin/client/cheats/init.lua | 1 - builtin/settingtypes.txt | 2 -- src/defaultsettings.cpp | 1 - src/gui/cheatMenu.h | 2 +- src/network/clientpackethandler.cpp | 4 ---- 5 files changed, 1 insertion(+), 9 deletions(-) (limited to 'src/gui/cheatMenu.h') diff --git a/builtin/client/cheats/init.lua b/builtin/client/cheats/init.lua index 5e94ed86c..a7be83cee 100644 --- a/builtin/client/cheats/init.lua +++ b/builtin/client/cheats/init.lua @@ -51,7 +51,6 @@ core.cheats = { ["PointLiquids"] = "point_liquids", ["PrivBypass"] = "priv_bypass", ["AutoRespawn"] = "autorespawn", - ["BlockFormspec"] = "block_formspec" }, ["Chat"] = { ["IgnoreStatus"] = "ignore_status_messages", diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index f13492146..ebd0ad621 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -2299,8 +2299,6 @@ replace (Replace) bool false crystal_pvp (CrystalPvP) bool false -block_formspec (BlockFormSpec) bool false - [Cheat Menu] # Font to use for cheat menu diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 6a37ebab9..525f94678 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -118,7 +118,6 @@ void set_default_settings(Settings *settings) settings->setDefault("crystal_pvp", "false"); settings->setDefault("autototem", "false"); settings->setDefault("dont_point_nodes", "false"); - settings->setDefault("block_formspec", "false"); // Keymap settings->setDefault("remote_port", "30000"); diff --git a/src/gui/cheatMenu.h b/src/gui/cheatMenu.h index 513d217b6..c25af5ed2 100644 --- a/src/gui/cheatMenu.h +++ b/src/gui/cheatMenu.h @@ -72,7 +72,7 @@ private: video::SColor m_font_color = video::SColor(195, 255, 255, 255); video::SColor m_selected_font_color = video::SColor(235, 255, 255, 255); - FontMode fontStringToEnum(std::string str) + FontMode fontStringToEnum(std::string str); Client *m_client; diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp index f3c2bc134..f0fb09fad 100644 --- a/src/network/clientpackethandler.cpp +++ b/src/network/clientpackethandler.cpp @@ -957,10 +957,6 @@ void Client::handleCommand_DetachedInventory(NetworkPacket* pkt) void Client::handleCommand_ShowFormSpec(NetworkPacket* pkt) { - if (g_settings->getBool("block_formspec")) { - return; - } - std::string formspec = pkt->readLongString(); std::string formname; -- cgit v1.2.3 From 61e2b3a33190d5979bc2e36f9734cebd18465f26 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein <54945686+EliasFleckenstein03@users.noreply.github.com> Date: Wed, 4 Nov 2020 14:34:03 +0100 Subject: Re-add empty lines --- src/gui/cheatMenu.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/gui/cheatMenu.h') diff --git a/src/gui/cheatMenu.h b/src/gui/cheatMenu.h index c25af5ed2..f12f10ac0 100644 --- a/src/gui/cheatMenu.h +++ b/src/gui/cheatMenu.h @@ -1,14 +1,17 @@ /* Dragonfire Copyright (C) 2020 Elias Fleckenstein + This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. @@ -78,4 +81,4 @@ private: gui::IGUIFont *m_font = nullptr; v2u32 m_fontsize; -}; \ No newline at end of file +}; -- cgit v1.2.3