]> git.lizzy.rs Git - dragonfireclient.git/blob - src/gui/cheatMenu.h
Re-add empty lines
[dragonfireclient.git] / src / gui / cheatMenu.h
1 /*
2 Dragonfire
3 Copyright (C) 2020 Elias Fleckenstein <eliasfleckenstein@web.de>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #pragma once
21
22 #include "client/client.h"
23 #include "irrlichttypes_extrabloated.h"
24 #include "script/scripting_client.h"
25 #include <cstddef>
26 #include <string>
27
28 #define CHEAT_MENU_GET_SCRIPTPTR                                                         \
29         ClientScripting *script = m_client->getScript();                                 \
30         if (!script || !script->m_cheats_loaded)                                         \
31                 return;
32
33 enum CheatMenuEntryType
34 {
35         CHEAT_MENU_ENTRY_TYPE_HEAD,
36         CHEAT_MENU_ENTRY_TYPE_CATEGORY,
37         CHEAT_MENU_ENTRY_TYPE_ENTRY,
38 };
39
40 class CheatMenu
41 {
42 public:
43         CheatMenu(Client *client);
44
45         ClientScripting *getScript()
46         {
47                 return m_client->getScript();
48         }
49
50         void draw(video::IVideoDriver *driver, bool show_debug);
51
52         void drawEntry(video::IVideoDriver *driver, std::string name,
53                 std::size_t column_align_index, std::size_t cheat_entry_index,
54                 bool is_selected, bool is_enabled,
55                 CheatMenuEntryType entry_type = CHEAT_MENU_ENTRY_TYPE_ENTRY);
56
57         void selectUp();
58         void selectDown();
59         void selectLeft();
60         void selectRight();
61         void selectConfirm();
62
63 private:
64         bool m_cheat_layer = false;
65         int m_selected_cheat = 0;
66         int m_selected_category = 0;
67
68         int m_head_height = 20;
69         int m_entry_height = 20;
70         int m_entry_width = 150;
71         int m_gap = 3;
72
73         video::SColor m_bg_color = video::SColor(173, 45, 45, 68);
74         video::SColor m_active_bg_color = video::SColor(210, 0, 0, 0);
75         video::SColor m_font_color = video::SColor(195, 255, 255, 255);
76         video::SColor m_selected_font_color = video::SColor(235, 255, 255, 255);
77
78         FontMode fontStringToEnum(std::string str);
79
80         Client *m_client;
81
82         gui::IGUIFont *m_font = nullptr;
83         v2u32 m_fontsize;
84 };