Make cheat menu color and font configurable via settings

This commit is contained in:
realOneplustwo 2020-10-21 17:49:17 -07:00
parent aea9b36ef7
commit b29d6bc196
4 changed files with 79 additions and 1 deletions

View File

@ -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

View File

@ -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");

View File

@ -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 <cstddef>
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;

View File

@ -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 <cstddef>
#include <string>
@ -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;