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