aboutsummaryrefslogtreecommitdiff
path: root/src/gui/cheatMenu.h
blob: e7fb4dc9399d7013ee0cf1f0e8b6f9e8b2012b9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
Dragonfire
Copyright (C) 2020 Elias Fleckenstein <eliasfleckenstein@web.de>

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.
*/

#pragma once

#include "irrlichttypes_extrabloated.h"
#include <cstddef>
#include <string>

#define CHEAT_MENU_GET_SCRIPTPTR                                                         \
	ClientScripting *script = m_client->getScript();                                 \
	if (!script || !script->m_cheats_loaded)                                         \
		return;

class Client;

enum CheatMenuEntryType
{
	CHEAT_MENU_ENTRY_TYPE_HEAD,
	CHEAT_MENU_ENTRY_TYPE_CATEGORY,
	CHEAT_MENU_ENTRY_TYPE_ENTRY,
};

class CheatMenu
{
public:
	CheatMenu(Client *client);

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

	void selectUp();
	void selectDown();
	void selectLeft();
	void selectRight();
	void selectConfirm();

private:
	bool m_cheat_layer = false;
	int m_selected_cheat = 0;
	int m_selected_category = 0;

	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(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;

	gui::IGUIFont *m_font = nullptr;
	v2u32 m_fontsize;
};