Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*
   Copyright (c) 2017 DIVIDE-Studio
   Copyright (c) 2009 Ionut Cava

   This file is part of DIVIDE Framework.

   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software
   and associated documentation files (the "Software"), to deal in the Software
   without restriction,
   including without limitation the rights to use, copy, modify, merge, publish,
   distribute, sublicense,
   and/or sell copies of the Software, and to permit persons to whom the
   Software is furnished to do so,
   subject to the following conditions:

   The above copyright notice and this permission notice shall be included in
   all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED,
   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
   PARTICULAR PURPOSE AND NONINFRINGEMENT.
   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
   DAMAGES OR OTHER LIABILITY,
   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
   IN CONNECTION WITH THE SOFTWARE
   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

 */

#ifndef GUI_H_
#define GUI_H_

#include "GUIInterface.h"
#include "Core/Headers/KernelComponent.h"
#include "Core/Math/Headers/MathMatrices.h"
#include "GUI/CEGUIAddons/Headers/CEGUIInput.h"
#include "Platform/Input/Headers/InputAggregatorInterface.h"

namespace CEGUI {
class Renderer;
};

namespace Divide {

namespace Font {
const static char* DIVIDE_DEFAULT = "DroidSerif-Regular.ttf"; /*"Test.ttf"*/
const static char* BATANG = "Batang.ttf";
const static char* DEJA_VU = "DejaVuSans.ttf";
const static char* DROID_SERIF = "DroidSerif-Regular.ttf";
const static char* DROID_SERIF_ITALIC = "DroidSerif-Italic.ttf";
const static char* DROID_SERIF_BOLD = "DroidSerif-Bold.ttf";
};

class GUIEditor;
class GUIConsole;
class GUIElement;
class ResourceCache;
class PlatformContext;
class RenderStateBlock;

FWD_DECLARE_MANAGED_CLASS(ShaderProgram);

#define CEGUI_DEFAULT_CTX CEGUI::System::getSingleton().getDefaultGUIContext()

class Scene;

/// Graphical User Interface

class SceneGUIElements;
class GUI : public GUIInterface,
            public KernelComponent,
            public Input::InputAggregatorInterface {
public:
    typedef hashMapImpl<I64, SceneGUIElements*> GUIMapPerScene;

public:
    explicit GUI(Kernel& parent);
    ~GUI();

    /// Create the GUI
    bool init(PlatformContext& context, ResourceCache& cache, const vec2<U16>& renderResolution);
    void destroy();

    void onChangeResolution(U16 w, U16 h) override;
    void onChangeScene(Scene* newScene);
    void onUnloadScene(Scene* scene);

    /// Main update call
    void update(const U64 deltaTime);

    template<typename T = GUIElement>
    inline T* getGUIElement(I64 sceneID, U64 elementName) {
        static_assert(std::is_base_of<GUIElement, T>::value,
            "getGuiElement error: Target is not a valid GUI item");

        return static_cast<T*>(getGUIElementImpl(sceneID, elementName, getTypeEnum<T>()));
    }

    template<typename T = GUIElement>
    inline T* getGUIElement(I64 sceneID, I64 elementID) {
        static_assert(std::is_base_of<GUIElement, T>::value,
            "getGuiElement error: Target is not a valid GUI item");

        return static_cast<T*>(getGUIElementImpl(sceneID, elementID, getTypeEnum<T>()));
    }

    /// Get a pointer to our console window
    inline GUIConsole& getConsole() { return *_console; }
    inline const GUIConsole& getConsole() const { return *_console; }

    inline GUIEditor& getEditor() { return *_guiEditor; }
    inline const GUIEditor& getEditor() const { return *_guiEditor; }

    inline CEGUI::Window* rootSheet() const { return _rootSheet; }
    inline const stringImpl& guiScheme() const { return _defaultGUIScheme; }

    void selectionChangeCallback(Scene* const activeScene, U8 playerIndex);
    /// Return a pointer to the default, general purpose message box
    inline GUIMessageBox* const getDefaultMessageBox() const {
        return _defaultMsgBox;
    }
    /// Used to prevent text updating every frame
    inline void setTextRenderTimer(const U64 renderIntervalUs) {
        _textRenderInterval = renderIntervalUs;
    }
    /// Mouse cursor forced to a certain position
    void setCursorPosition(I32 x, I32 y) const;
    /// Key pressed: return true if input was consumed
    bool onKeyDown(const Input::KeyEvent& key);
    /// Key released: return true if input was consumed
    bool onKeyUp(const Input::KeyEvent& key);
    /// Joystick axis change: return true if input was consumed
    bool joystickAxisMoved(const Input::JoystickEvent& arg, I8 axis);
    /// Joystick direction change: return true if input was consumed
    bool joystickPovMoved(const Input::JoystickEvent& arg, I8 pov);
    /// Joystick button pressed: return true if input was consumed
    bool joystickButtonPressed(const Input::JoystickEvent& arg, Input::JoystickButton button);
    /// Joystick button released: return true if input was consumed
    bool joystickButtonReleased(const Input::JoystickEvent& arg, Input::JoystickButton button);
    bool joystickSliderMoved(const Input::JoystickEvent& arg, I8 index);
    bool joystickVector3DMoved(const Input::JoystickEvent& arg, I8 index);
    /// Mouse moved: return true if input was consumed
    bool mouseMoved(const Input::MouseEvent& arg);
    /// Mouse button pressed: return true if input was consumed
    bool mouseButtonPressed(const Input::MouseEvent& arg, Input::MouseButton button);
    /// Mouse button released: return true if input was consumed
    bool mouseButtonReleased(const Input::MouseEvent& arg, Input::MouseButton button);

    Scene* activeScene() {
        return _activeScene;
    }

    const Scene* activeScene() const {
        return _activeScene;
    }

protected:
    GUIElement* getGUIElementImpl(I64 sceneID, U64 elementName, GUIType type) const;
    GUIElement* getGUIElementImpl(I64 sceneID, I64 elementID, GUIType type) const;

protected:
    friend class SceneGUIElements;
    CEGUI::Window* _rootSheet;  //< gui root Window
    stringImpl _defaultGUIScheme;

private:
    void draw(GFXDevice& context) const;

private:
    bool _init;              //< Set to true when the GUI has finished loading
                             /// Toggle CEGUI rendering on/off (e.g. to check raw application rendering
                             /// performance)
    CEGUIInput _ceguiInput;  //< Used to implement key repeat
    GUIConsole* _console;    //< Pointer to the GUIConsole object
    GUIMessageBox* _defaultMsgBox;  //< Pointer to a default message box used for general purpose messages
    GUIEditor*  _guiEditor; //< Pointer to a World Editor type interface
    U64 _textRenderInterval;  //< We should avoid rendering text as fast as possible
                              //for performance reasons
    ShaderProgram_ptr _guiShader;  //<Used to apply colour for text for now

    /// Each scene has its own gui elements! (0 = global)
    Scene* _activeScene;

    U32 _debugVarCacheCount;
    // GROUP, VAR
    vectorImpl<std::pair<I64, I64>> _debugDisplayEntries;

    /// All the GUI elements created per scene
    GUIMapPerScene _guiStack;
    mutable SharedLock _guiStackLock;
};

};  // namespace Divide
#endif

Commits for Divide-Framework/trunk/Source Code/GUI/Headers/GUI.h

Diff revisions: vs.
Revision Author Commited Message
912 Diff Diff IonutCava picture IonutCava Sun 02 Jul, 2017 23:42:39 +0000

[Ionut]
- Add experimental Weighted Blended Order Independed Transparency (ref: http://casual-effects.blogspot.co.uk/2015/03/implemented-weighted-blended-order.html)
— Add per drawbuffer blend
— All translucent renderbin items go via the new OIT 2-step rendering: accumulation and composition
- Make sure we have proper blend enabled for text rendering
- Add a primitive form of PushConstants (unused yet. Emulated via Uniform calls)
- Fix bug with XMLParser not using case insensitive key lookups

902 Diff Diff IonutCava picture IonutCava Sun 25 Jun, 2017 16:56:57 +0000

[Ionut]
- Rework input system a bit for easier maintenance and readability
- Toggle AntTweakBar display using CTRL+F11

861 Diff Diff IonutCava picture IonutCava Tue 14 Feb, 2017 15:53:14 +0000

[IonutCava]
- Fix mouse hover/select system that wasn’t working since the local split-screen feature got implemented.

836 Diff Diff IonutCava picture IonutCava Fri 27 Jan, 2017 14:59:56 +0000

[IonutCava]
- Update copyright notice

835 Diff Diff IonutCava picture IonutCava Fri 27 Jan, 2017 14:58:07 +0000

[IonutCava]
- Split Engine lib into Core and Engine lib.
- Fix Server build issues

818 Diff Diff IonutCava picture IonutCava Mon 16 Jan, 2017 17:23:20 +0000

[IonutCava]
- Units get their bound node setup by the SGN UnitComponent and not during creation
- Profile guided optimizations

804 Diff Diff IonutCava picture IonutCava Thu 01 Dec, 2016 17:20:59 +0000

[IonutCava]
- Singleton elimination update Part I: get it to compile
— The following classes are no longer Singletons: GFXDevice, GL_API, DX_API, SFXWrapper, FmodWrapper, SDLWrapper, ALWrapper, PXDevice, InputInterface, RenderPassManager, SceneManager and ResourceManager;
— Refactor system to a Context / Component based implementation (Pass relevant context to objects: e.g. GFXDevice object to Textures, GUI to GUIElements, etc)
— Make devices and managers components of the kernel
— Allow multiple Resource caches to co-exist. This may prove useful for later when a more fragmented memory model is need (per frame / per scene / global caches / etc)

  • next steps: part II – cleanup/refactor new code, part III – optimise code, part IV – remove remaining Singletons (e.g. Application, ParamHandler, FrameListenerManager, Recast, PostFX and DebugInterface)
802 Diff Diff IonutCava picture IonutCava Tue 29 Nov, 2016 17:15:38 +0000

[IonutCava]
- GUI class is no longer a Singleton
- Reduced usage of GFXDevice::instance()

795 Diff Diff IonutCava picture IonutCava Wed 23 Nov, 2016 17:14:33 +0000

[IonutCava]
- Remove ULL. Use U64 instead
- Various small bug fixes and typos.

721 IonutCava picture IonutCava Wed 08 Jun, 2016 15:47:49 +0000

[IonutCava]
- Spelling: change all references from our code of “color” to the PROPER British version of “colour” because it sounds 100x better