Mana
Loading...
Searching...
No Matches
gui.h
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2004-2009 The Mana World Development Team
4 * Copyright (C) 2009-2012 The Mana Developers
5 *
6 * This file is part of The Mana Client.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24#include "eventlistener.h"
25#include "guichanfwd.h"
26
27#include "resources/theme.h"
28
29#include "utils/time.h"
30
31#include <guichan/gui.hpp>
32
33#include <SDL.h>
34
35#include <memory>
36#include <vector>
37
38class TextInput;
39class Graphics;
40class SDLInput;
41
54enum class Cursor
55{
56 Pointer = 0,
61 Fight,
62 PickUp,
63 Talk,
64 Action,
65 Left,
66 Up,
67 Right,
68 Down,
69 Drag,
70 Hand,
71 Count,
72};
73
79class Gui final : public gcn::Gui, public EventListener
80{
81 public:
82 Gui(Graphics *screen, const std::string &themePath);
83
84 ~Gui() override;
85
90 void logic() override;
91
92 void event(Event::Channel channel, const Event &event) override;
93
99 bool videoResized(int width, int height);
100
101 gcn::FocusHandler *getFocusHandler() const
102 { return mFocusHandler; }
103
107 gcn::Font *getFont() const
108 { return mGuiFont; }
109
114 gcn::Font *getInfoParticleFont() const
115 { return mInfoParticleFont; }
116
120 void setUseCustomCursor(bool customCursor);
121
125 void setCursorType(Cursor cursor);
126
127 const std::vector<ThemeInfo> &getAvailableThemes() const
128 { return mAvailableThemes; }
129
133 void setTheme(const ThemeInfo &theme);
134
139 { return mTheme.get(); }
140
141 static bool debugDraw;
142
143 protected:
144 void handleMouseMoved(const gcn::MouseInput &mouseInput) override;
145 void handleTextInput(const TextInput &textInput);
146
147 private:
148 void updateCursor();
149
150 void loadCustomCursors();
151 void loadSystemCursors();
152
153 std::vector<ThemeInfo> mAvailableThemes;
154 std::unique_ptr<Theme> mTheme;
155 gcn::Font *mGuiFont;
156 gcn::Font *mInfoParticleFont;
157 bool mCustomCursor = false;
158 float mCustomCursorScale = 1.0f;
159 std::vector<SDL_Cursor *> mSystemMouseCursors;
160 std::vector<SDL_Cursor *> mCustomMouseCursors;
163};
164
165extern Gui *gui;
166extern SDLInput *guiInput;
171extern gcn::Font *boldFont;
172
176extern gcn::Font *monoFont;
Definition event.h:42
Channel
Definition event.h:45
A central point of control for graphics.
Definition graphics.h:78
Main GUI class.
Definition gui.h:80
Timer mMouseActivityTimer
Definition gui.h:161
float mCustomCursorScale
Definition gui.h:158
void handleTextInput(const TextInput &textInput)
Definition gui.cpp:262
bool mCustomCursor
Show custom cursor.
Definition gui.h:157
void loadSystemCursors()
Definition gui.cpp:330
void handleMouseMoved(const gcn::MouseInput &mouseInput) override
Definition gui.cpp:253
static bool debugDraw
Definition gui.h:141
gcn::Font * getFont() const
Return game font.
Definition gui.h:107
gcn::Font * mInfoParticleFont
Font for Info Particles.
Definition gui.h:156
void loadCustomCursors()
Definition gui.cpp:280
gcn::Font * getInfoParticleFont() const
Return the Font used for "Info Particles", i.e.
Definition gui.h:114
std::vector< ThemeInfo > mAvailableThemes
Definition gui.h:153
bool videoResized(int width, int height)
Called when the application window has been resized.
Definition gui.cpp:196
std::unique_ptr< Theme > mTheme
The global GUI theme.
Definition gui.h:154
std::vector< SDL_Cursor * > mCustomMouseCursors
Definition gui.h:160
gcn::Font * mGuiFont
The global GUI font.
Definition gui.h:155
Cursor mCursorType
Definition gui.h:162
Theme * getTheme() const
The global GUI theme.
Definition gui.h:138
void updateCursor()
Definition gui.cpp:245
gcn::FocusHandler * getFocusHandler() const
Definition gui.h:101
void setUseCustomCursor(bool customCursor)
Sets whether a custom cursor should be rendered.
Definition gui.cpp:222
std::vector< SDL_Cursor * > mSystemMouseCursors
Definition gui.h:159
void event(Event::Channel channel, const Event &event) override
Definition gui.cpp:184
~Gui() override
Definition gui.cpp:150
void setTheme(const ThemeInfo &theme)
Sets the global GUI theme.
Definition gui.cpp:240
void setCursorType(Cursor cursor)
Sets which cursor should be used.
Definition gui.cpp:231
const std::vector< ThemeInfo > & getAvailableThemes() const
Definition gui.h:127
void logic() override
Performs logic of the GUI.
Definition gui.cpp:167
SDL implementation of Input.
Definition sdlinput.h:143
Definition theme.h:196
Simple timer that can be used to check if a certain amount of time has passed.
Definition time.h:62
SDLInput * guiInput
GUI input.
Definition gui.cpp:51
Gui * gui
The GUI system.
Definition gui.cpp:50
gcn::Font * monoFont
Monospaced text font.
Definition gui.cpp:57
Cursor
Cursors are in graphic order from left to right.
Definition gui.h:55
@ ResizeDownRight
@ ResizeDown
@ ResizeAcross
@ ResizeDownLeft
gcn::Font * boldFont
Bolded text font.
Definition gui.cpp:54