VPS
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
/*
   Copyright (c) 2014 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 "Utility/Headers/HashMap.h"
#include "Core/Math/Headers/MathClasses.h"
#include "GUI/GUIEditor/Headers/GUIEditor.h"
#include "GUI/CEGUIAddons/Headers/CEGUIInput.h"
#include "Hardware/Input/Headers/InputAggregatorInterface.h"

namespace CEGUI {
    class Renderer;
};


namespace Divide {

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

class GUIConsole;
class GUIElement;
class ShaderProgram;
class RenderStateBlock;

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

class GUIText;
class GUIFlash;
class GUIButton;
class GUIMessageBox;
class Scene;

/// Graphical User Interface

DEFINE_SINGLETON_EXT1( GUI, Input::InputAggregatorInterface )
    typedef hashMapImpl<stringImpl, GUIElement*> guiMap;
	typedef DELEGATE_CBK<> ButtonCallback;

public:
    /// Main update call
    void update(const U64 deltaTime);
    /// Add a text label
    GUIText* addText(const stringImpl& id,
                     const vec2<I32>& position,
                     const stringImpl& font,
                     const vec3<F32>& color,
                     char* format, ...);
    /// Modify a text label
    GUIText* modifyText(const stringImpl& id, char* format, ...);
    GUIMessageBox* addMsgBox(const stringImpl& id,
                             const stringImpl& title,
                             const stringImpl& message,
                             const vec2<I32>& offsetFromCentre = vec2<I32>(0));
    /// Add a button with a specific callback. 
    /// The root of the window positioning system is bottom left, so 100,60 will place the button 100 pixels to the right and 60 up
    /// from the bottom
    GUIButton* addButton(const stringImpl& id,
                         const stringImpl& text,
                         const vec2<I32>& position,
                         const vec2<U32>& dimensions,
                         const vec3<F32>& color,
                         ButtonCallback callback,
                         const stringImpl& rootSheetId = "");
    /// Add a flash element -DEPRECATED-
    GUIFlash* addFlash(const stringImpl& id, stringImpl movie, const vec2<U32>& position, const vec2<U32>& extent);
    /// Called on window resize to adjust the dimensions of all the GUI elements
    void onResize(const vec2<U16>& newResolution);
    /// Get a pointer to our console window
    inline GUIConsole* const getConsole() {return _console;}
    inline const GUIEditor&  getEditor()  {return GUIEditor::getInstance(); }
    /// Get a const pointer to an element by name/id
    inline GUIElement* const getItem(const stringImpl& id) {return _guiStack[id];}
    /// Get a pointer to an element by name/id
    inline GUIElement* getGuiElement(const stringImpl& id){return _guiStack[id];}
    /// Create the GUI
    bool init(const vec2<U16>& resolution);
    /// Used by CEGUI to setup rendering (D3D/OGL/OGRE/etc)
    bool bindRenderer(CEGUI::Renderer& renderer);
    void selectionChangeCallback(Scene* const activeScene);
	/// 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(U16 x, U16 y) const;
    ///Key pressed
    bool onKeyDown(const Input::KeyEvent& key);
    ///Key released
    bool onKeyUp(const Input::KeyEvent& key);
    ///Joystick axis change
    bool joystickAxisMoved(const Input::JoystickEvent& arg,I8 axis);
    ///Joystick direction change
    bool joystickPovMoved(const Input::JoystickEvent& arg,I8 pov);
    ///Joystick button pressed
    bool joystickButtonPressed(const Input::JoystickEvent& arg,I8 button);
    ///Joystick button released
    bool joystickButtonReleased(const Input::JoystickEvent& arg, I8 button);
    bool joystickSliderMoved( const Input::JoystickEvent &arg, I8 index);
    bool joystickVector3DMoved( const Input::JoystickEvent &arg, I8 index);
    ///Mouse moved
    bool mouseMoved(const Input::MouseEvent& arg);
    ///Mouse button pressed
    bool mouseButtonPressed(const Input::MouseEvent& arg, Input::MouseButton button);
    ///Mouse button released
    bool mouseButtonReleased(const Input::MouseEvent& arg, Input::MouseButton button);
private:
    GUI();               //< Constructor
    ~GUI();              //< Destructor
    void drawText();     //< TextLabel rendering
    void draw2D();

private:
    bool _init;                     //< Set to true when the GUI has finished loading
    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
    guiMap         _guiStack;          //< All the GUI elements created
    vec2<U16>      _cachedResolution;  //< We keep a cache of the current resolution to avoid useless queries
    U64            _textRenderInterval;//< We should avoid rendering text as fast as possible for performance reasons
    CEGUI::Window* _rootSheet; //< gui root Window
    stringImpl     _defaultGUIScheme;
    ShaderProgram* _guiShader;//<Used to apply color for text for now

END_SINGLETON

}; //namespace Divide
#endif

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

Diff revisions: vs.
Revision Author Commited Message
331 Diff Diff IonutCava picture IonutCava Sat 06 Dec, 2014 20:53:45 +0000

[Ionut]
- Limited line length to 132 characters to improve readability and diff-comparisons
- Refactored memory allocation/deallocation functions
- Fixed a few compatibility issues with HashMap.h
- Fixed a bug in GPU Skinning shaders (cast a float to int)

324 Diff Diff IonutCava picture IonutCava Sun 14 Sep, 2014 14:01:39 +0000

[Ionut]
- New memory management system (no custom allocators in this commit)
— Memory tracer to detect memory leaks on shutdown (from: https://www.relisoft.com/book/tech/9new.html)
— SAFE_DELETE_XYZ are now inline template functions not macros
— ASSERTION system now supports logging and message boxes and continue on error configurable for each build type
— Fixed a lot of memory leaks detected by the new system (some still remain)

- Added SRGB support (part 1)
— Albedo textures are loaded as SRGB (make sure resources are SRGB)
— Shaders output gamma corrected colors
— Moved terrain textures back to 2 array system (albedo and normal maps, albedo maps using a SRGB sampler)

- Sky is now loaded via the ResourceCache system
- Added include safeguards in shader atoms

322 Diff Diff IonutCava picture IonutCava Sat 06 Sep, 2014 20:33:47 +0000

[Ionut]
- Refactored most of Boost related code to be C++11 based
— Boost is only used for ThreadPool, Mutex handling, XML parsing and networking (ASIO)
— Function binds, threads, regex, NonCopyable base, Hashing algorithms and more are now using C++11 libraries
- Replaced all FOR_EACH calls with standard, range, “for” calls

321 Diff Diff IonutCava picture IonutCava Wed 03 Sep, 2014 22:05:15 +0000

[Ionut]
- Added support (and enabled by default) for the EASTL library (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2271.html / https://github.com/paulhodge/EASTL)
— Strings, vectors and hash_maps can be combined from EASTL, STL and Boost (not all combinations work. e.g. EASTL strings with STL/Boost containers due to the lack of a proper hash function)

318 Diff Diff IonutCava picture IonutCava Sat 30 Aug, 2014 17:35:53 +0000

[Ionut]
- Wrapped the entire code in a “Divide” namespace
- VertexBuffers now call “shrink_to_fit” on all internal data storage
- Improved some vector performance by preferring “emplace_back” instead of “push_back” + proepr usage of reserve / resize
- Wrapped OIS specific types and classes in Divide::Input namespace
- Added the messageBox.layout file (forgot it in the previous few commits)

313 Diff Diff IonutCava picture IonutCava Sat 23 Aug, 2014 23:46:25 +0000

[Ionut]
- Added a messageBox gui element. Simple title/message hide/show System
- Added a working memory system to the WarSceneAISceneImpl class and a few memory facts for testing
- Reworked AI sensor system

309 Diff Diff IonutCava picture IonutCava Sat 16 Aug, 2014 22:57:33 +0000

[Ionut]
- Added an InputAggregator interface to standardize input event handling

308 Diff Diff IonutCava picture IonutCava Sat 16 Aug, 2014 19:49:31 +0000

[Ionut]
- Moved Transform from SceneGraphNode to PhysicsComponent and modified BoundingBox update system based on transform update
- Added PhysicsAsset to PhysicsComponent for interfacing with PshysicsAPIs (e.g. PhysXActor inherits PhysicsAsset)
- PhysicsAsset keeps track of the parent PhysicsComponent to have direct access to a node’s transform
- Rewrote GUIConsole to only print items when visible, and use a single circular buffer for entries.
- Updated GUI input system to match the interface that both Kernel and SceneManager share (should probably abstract all the input methods in a class and have Kernel, SceneManager, Scene and GUI inherit from that. In next commit.)
- Updated CEGUI to probably match the OIS states(mouse, keyboard, etc) and properly inject time inputs.

306 Diff Diff IonutCava picture IonutCava Tue 12 Aug, 2014 12:47:31 +0000

[Ionut]
- More World Editor work:
— Move and Scale selected objects
— Disabling object specific controls when nothing is selected
— Toggle PostFX and Fog controls working
— Do not pass input to scene when clicking on any editor controls
— Granularity fields working
— Input fields only allow floating point inputs (via regex check)
- Cleaned up Transform class

296 k1ngp1n picture k1ngp1n Sun 03 Aug, 2014 14:54:21 +0000

[Ionut]
- nVidia compatibility fixes (GUI, shadows, post-processing)
- Texture bind slots are now part of ShaderProgram class
- Renamed ForwardRenderer class to ForwardPlusRenderer and moved ligh grid creation to it
- More code cleanups and comments