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
#include "Headers/GUIButton.h"

#include "Platform/Audio/Headers/SFXDevice.h"

#ifndef CEGUI_STATIC
#define CEGUI_STATIC
#include <CEGUI/CEGUI.h>
#endif //CEGUI_STATIC

namespace Divide {

GUIButton::AudioCallback GUIButton::_soundCallback;

GUIButton::GUIButton(U64 guiID,
                     const stringImpl& text,
                     const stringImpl& guiScheme,
                     const vec2<F32>& relativeOffset,
                     const vec2<F32>& relativeDimensions,
                     CEGUI::Window* parent,
                     ButtonCallback callback,
                     AudioDescriptor_ptr onClickSound)
    : GUIElement(guiID, parent, GUIType::GUI_BUTTON),
      _callbackFunction(callback),
      _btnWindow(nullptr),
      _onClickSound(onClickSound)
{
    
    _btnWindow = CEGUI::WindowManager::getSingleton().createWindow((guiScheme + "/Button").c_str(), text.c_str());
    _btnWindow->setPosition(CEGUI::UVector2(CEGUI::UDim(relativeOffset.x / 100, 0.0f),
                                            CEGUI::UDim(relativeOffset.y / 100, 0.0f)));
    _btnWindow->setSize(CEGUI::USize(CEGUI::UDim(relativeDimensions.x / 100, 0.0f),
                                     CEGUI::UDim(relativeDimensions.y / 100, 0.0f)));
    _btnWindow->setText(text.c_str());
    _btnWindow->subscribeEvent(CEGUI::PushButton::EventClicked,
                               CEGUI::Event::Subscriber(&GUIButton::joystickButtonPressed, this));
    _parent->addChild(_btnWindow);
    _btnWindow->setEnabled(true);

    setActive(true);
}

GUIButton::~GUIButton()
{
    _parent->removeChild(_btnWindow);
}

void GUIButton::setActive(const bool active) {
    _btnWindow->setEnabled(active);
    GUIElement::setActive(active);
}

void GUIButton::setVisible(const bool visible) {
    _btnWindow->setVisible(visible);
    GUIElement::setVisible(visible);
}

void GUIButton::setText(const stringImpl& text) {
    _btnWindow->setText(text.c_str());
}

void GUIButton::draw(GFXDevice& context) const {
    ACKNOWLEDGE_UNUSED(context);
    //Nothing. CEGUI should handle this
}

void GUIButton::setTooltip(const stringImpl& tooltipText) {
    _btnWindow->setTooltipText(tooltipText.c_str());
}

void GUIButton::setFont(const stringImpl& fontName,
                        const stringImpl& fontFileName, U32 size) {
    if (!fontName.empty()) {
        if (!CEGUI::FontManager::getSingleton().isDefined(fontName.c_str())) {
            CEGUI::FontManager::getSingleton().createFreeTypeFont(
                fontName.c_str(), to_float(size), true, fontFileName.c_str());
        }

        if (CEGUI::FontManager::getSingleton().isDefined(fontName.c_str())) {
            _btnWindow->setFont(fontName.c_str());
        }
    }
}

bool GUIButton::joystickButtonPressed(const CEGUI::EventArgs& /*e*/) {
    if (_callbackFunction) {
        _callbackFunction(getGUID());
        if (_onClickSound && _soundCallback) {
            _soundCallback(_onClickSound);
        }
        return true;
    }
    return false;
}

void GUIButton::setOnClickSound(const AudioDescriptor_ptr& onClickSound) {
    _onClickSound = onClickSound;
}


bool GUIButton::soundCallback(const AudioCallback& cbk) {
    bool hasCbk = _soundCallback ? true : false;
    _soundCallback = cbk;

    return hasCbk;
}

};

Commits for Divide-Framework/trunk/Source Code/GUI/GUIButton.cpp

Diff revisions: vs.
Revision Author Commited Message
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.

745 Diff Diff IonutCava picture IonutCava Wed 29 Jun, 2016 20:14:50 +0000

[IonutCava]
- Added on click sounds for buttons
- Added music playlist options for scenes (configurable via XML)
- Cache sound chunks and music files in SDLWrapper.cpp

710 Diff Diff IonutCava picture IonutCava Fri 20 May, 2016 16:24:40 +0000

[IonutCava]
- Code cleanup
- Initial work on Scene loading and unloading with and without unloading assets:
— Need to change AIManager from a Singleton to a per-scene component

706 Diff Diff IonutCava picture IonutCava Fri 13 May, 2016 16:29:40 +0000

[IonutCava]
- Renamed LightManager to LightPool and changed it from a Singleton to a scene specific pointer
- More scene load / unload updates (changing scenes now works properly!)
- Allowed GUI interface to hold per-scene elements and only render relevant ones
- Reduced dependencies between nodes, scenemanager, scene, loaders and kernel
- Removed Reflector base class as it was useless and integrate Water class with the Reflection system already in place
- Extended RenderingComponent’s reflection system to allow refraction as well

704 Diff Diff IonutCava picture IonutCava Thu 12 May, 2016 16:24:17 +0000

[IonutCava]
- More work on the DefaultScene:
— Automatically list each available scene as a button that will load the actual desired scene

693 Diff Diff IonutCava picture IonutCava Thu 28 Apr, 2016 16:19:35 +0000

[IonutCava]
- Cleanup Time and Profiling code

671 Diff Diff IonutCava picture IonutCava Fri 08 Apr, 2016 16:26:49 +0000

[Ionut]
- Custom memory allocation system part 1:
— Add http://www.codeproject.com/Articles/1089905/A-Custom-STL-std-allocator-Replacement-Improves-Pe
— Add custom allocators to strings and vectors
— Add custom allocators to a few test classes
— No support for aligned memory yet, so vec4<F32> and mat4<F32> vectors use the old allocation system
- Replace more std::async call with our custom task system

466 IonutCava picture IonutCava Fri 05 Jun, 2015 15:07:17 +0000

[Ionut]
- Moved EASTL, SimpleINI and Threadpool libraries from Dependencies repo to engine repo
- Disabled EASTL string and vector support as they are really out of date and missing required features.
— EASTL hash map is still usable