New module: Platform - Split window management from Utility module (#128)
* New module: Platform - Split window management from Utility module Final touch * NDK/SDK: Bring back initialization of Utility
This commit is contained in:
committed by
Jérôme Leclercq
parent
41a1b5d493
commit
5aa072cee3
@@ -25,7 +25,7 @@ Ndk::EntityHandle AddCamera(Ndk::World& world, Nz::RenderWindow& window);
|
||||
- Text entered is never repeated
|
||||
*/
|
||||
|
||||
SCENARIO("EventHandler", "[UTILITY][EVENTHANDLER][INTERACTIVE][.]")
|
||||
SCENARIO("EventHandler", "[PLATFORM][EVENTHANDLER][INTERACTIVE][.]")
|
||||
{
|
||||
GIVEN("An application")
|
||||
{
|
||||
39
tests/Engine/Platform/EventHandler/BaseState.cpp
Normal file
39
tests/Engine/Platform/EventHandler/BaseState.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "BaseState.hpp"
|
||||
|
||||
#include "StateContext.hpp"
|
||||
#include "StateFactory.hpp"
|
||||
|
||||
#include <Nazara/Renderer/RenderWindow.hpp>
|
||||
#include <NDK/StateMachine.hpp>
|
||||
|
||||
BaseState::BaseState(StateContext& context) :
|
||||
State(),
|
||||
m_context(context),
|
||||
m_text(context)
|
||||
{
|
||||
}
|
||||
|
||||
BaseState::~BaseState()
|
||||
{
|
||||
}
|
||||
|
||||
void BaseState::Enter(Ndk::StateMachine& fsm)
|
||||
{
|
||||
m_text.SetVisible(true);
|
||||
DrawMenu();
|
||||
}
|
||||
|
||||
void BaseState::Leave(Ndk::StateMachine& /*fsm*/)
|
||||
{
|
||||
m_text.SetVisible(false);
|
||||
}
|
||||
|
||||
bool BaseState::Update(Ndk::StateMachine& /*fsm*/, float /*elapsedTime*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void BaseState::DrawMenu()
|
||||
{
|
||||
m_text.SetContent("This shouldn't be visible\nM for Menu");
|
||||
}
|
||||
31
tests/Engine/Platform/EventHandler/BaseState.hpp
Normal file
31
tests/Engine/Platform/EventHandler/BaseState.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef BASESTATE_HPP
|
||||
#define BASESTATE_HPP
|
||||
|
||||
#include "Text.hpp"
|
||||
|
||||
#include <Nazara/Platform/EventHandler.hpp>
|
||||
|
||||
#include <NDK/State.hpp>
|
||||
|
||||
class StateContext;
|
||||
|
||||
class BaseState : public Ndk::State
|
||||
{
|
||||
public:
|
||||
BaseState(StateContext& stateContext);
|
||||
virtual ~BaseState();
|
||||
|
||||
virtual void Enter(Ndk::StateMachine& fsm) override;
|
||||
|
||||
virtual void Leave(Ndk::StateMachine& fsm) override;
|
||||
|
||||
virtual bool Update(Ndk::StateMachine& fsm, float elapsedTime) override;
|
||||
|
||||
protected:
|
||||
virtual void DrawMenu();
|
||||
|
||||
StateContext& m_context;
|
||||
Text m_text;
|
||||
};
|
||||
|
||||
#endif // BASESTATE_HPP
|
||||
@@ -7,17 +7,14 @@
|
||||
#include <NDK/StateMachine.hpp>
|
||||
|
||||
EventState::EventState(StateContext& context) :
|
||||
State(),
|
||||
m_context(context),
|
||||
m_text(context),
|
||||
BaseState(context),
|
||||
m_count(0)
|
||||
{
|
||||
}
|
||||
|
||||
void EventState::Enter(Ndk::StateMachine& fsm)
|
||||
{
|
||||
m_text.SetVisible(true);
|
||||
DrawMenu();
|
||||
BaseState::Enter(fsm);
|
||||
|
||||
Nz::EventHandler& eventHandler = m_context.window.GetEventHandler();
|
||||
m_keyPressedSlot.Connect(eventHandler.OnKeyPressed, [&] (const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& key)
|
||||
@@ -35,16 +32,6 @@ void EventState::Enter(Ndk::StateMachine& fsm)
|
||||
});
|
||||
}
|
||||
|
||||
void EventState::Leave(Ndk::StateMachine& /*fsm*/)
|
||||
{
|
||||
m_text.SetVisible(false);
|
||||
}
|
||||
|
||||
bool EventState::Update(Ndk::StateMachine& /*fsm*/, float /*elapsedTime*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void EventState::AddEvent(const Nz::WindowEvent& event)
|
||||
{
|
||||
if (m_events.size() > 9)
|
||||
@@ -1,32 +1,26 @@
|
||||
#ifndef __EVENTSTATE_HPP__
|
||||
#define __EVENTSTATE_HPP__
|
||||
|
||||
#include "Text.hpp"
|
||||
|
||||
#include <Nazara/Utility/EventHandler.hpp>
|
||||
|
||||
#include <NDK/State.hpp>
|
||||
#include "BaseState.hpp"
|
||||
|
||||
#include <deque>
|
||||
|
||||
class StateContext;
|
||||
|
||||
class EventState : public Ndk::State
|
||||
class EventState : public BaseState
|
||||
{
|
||||
public:
|
||||
EventState(StateContext& stateContext);
|
||||
|
||||
void Enter(Ndk::StateMachine& fsm) override;
|
||||
void Leave(Ndk::StateMachine& fsm) override;
|
||||
bool Update(Ndk::StateMachine& fsm, float elapsedTime) override;
|
||||
|
||||
private:
|
||||
void AddEvent(const Nz::WindowEvent& event);
|
||||
void DrawMenu();
|
||||
|
||||
void DrawMenu() override;
|
||||
|
||||
Nz::String ToString(const Nz::WindowEvent& event) const;
|
||||
|
||||
StateContext& m_context;
|
||||
Text m_text;
|
||||
std::deque<Nz::String> m_events;
|
||||
int m_count;
|
||||
NazaraSlot(Nz::EventHandler, OnEvent, m_eventSlot);
|
||||
@@ -7,16 +7,13 @@
|
||||
#include <NDK/StateMachine.hpp>
|
||||
|
||||
FocusState::FocusState(StateContext& context) :
|
||||
State(),
|
||||
m_context(context),
|
||||
m_text(context)
|
||||
BaseState(context)
|
||||
{
|
||||
}
|
||||
|
||||
void FocusState::Enter(Ndk::StateMachine& fsm)
|
||||
{
|
||||
m_text.SetVisible(true);
|
||||
DrawMenu();
|
||||
BaseState::Enter(fsm);
|
||||
|
||||
Nz::EventHandler& eventHandler = m_context.window.GetEventHandler();
|
||||
m_keyPressedSlot.Connect(eventHandler.OnKeyPressed, [&] (const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& key)
|
||||
@@ -38,16 +35,6 @@ void FocusState::Enter(Ndk::StateMachine& fsm)
|
||||
});
|
||||
}
|
||||
|
||||
void FocusState::Leave(Ndk::StateMachine& /*fsm*/)
|
||||
{
|
||||
m_text.SetVisible(false);
|
||||
}
|
||||
|
||||
bool FocusState::Update(Ndk::StateMachine& /*fsm*/, float /*elapsedTime*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void FocusState::DrawMenu()
|
||||
{
|
||||
m_text.SetContent("Click outside the windows, this text should change !\nM for Menu");
|
||||
@@ -1,28 +1,20 @@
|
||||
#ifndef __FOCUSSTATE_HPP__
|
||||
#define __FOCUSSTATE_HPP__
|
||||
|
||||
#include "Text.hpp"
|
||||
|
||||
#include <Nazara/Utility/EventHandler.hpp>
|
||||
|
||||
#include <NDK/State.hpp>
|
||||
#include "BaseState.hpp"
|
||||
|
||||
class StateContext;
|
||||
|
||||
class FocusState : public Ndk::State
|
||||
class FocusState : public BaseState
|
||||
{
|
||||
public:
|
||||
FocusState(StateContext& stateContext);
|
||||
|
||||
void Enter(Ndk::StateMachine& fsm) override;
|
||||
void Leave(Ndk::StateMachine& fsm) override;
|
||||
bool Update(Ndk::StateMachine& fsm, float elapsedTime) override;
|
||||
|
||||
private:
|
||||
void DrawMenu();
|
||||
void DrawMenu() override;
|
||||
|
||||
StateContext& m_context;
|
||||
Text m_text;
|
||||
NazaraSlot(Nz::EventHandler, OnGainedFocus, m_gainedFocusSlot);
|
||||
NazaraSlot(Nz::EventHandler, OnLostFocus, m_lostFocusSlot);
|
||||
NazaraSlot(Nz::EventHandler, OnKeyPressed, m_keyPressedSlot);
|
||||
@@ -7,17 +7,14 @@
|
||||
#include <NDK/StateMachine.hpp>
|
||||
|
||||
KeyState::KeyState(StateContext& context) :
|
||||
State(),
|
||||
m_context(context),
|
||||
m_text(context),
|
||||
BaseState(context),
|
||||
m_keyStatus(KeyStatus::Pressed)
|
||||
{
|
||||
}
|
||||
|
||||
void KeyState::Enter(Ndk::StateMachine& fsm)
|
||||
{
|
||||
m_text.SetVisible(true);
|
||||
DrawMenu();
|
||||
BaseState::Enter(fsm);
|
||||
|
||||
Nz::EventHandler& eventHandler = m_context.window.GetEventHandler();
|
||||
m_keyPressedSlot.Connect(eventHandler.OnKeyPressed, [&] (const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& key)
|
||||
@@ -31,16 +28,6 @@ void KeyState::Enter(Ndk::StateMachine& fsm)
|
||||
});
|
||||
}
|
||||
|
||||
void KeyState::Leave(Ndk::StateMachine& /*fsm*/)
|
||||
{
|
||||
m_text.SetVisible(false);
|
||||
}
|
||||
|
||||
bool KeyState::Update(Ndk::StateMachine& /*fsm*/, float /*elapsedTime*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void KeyState::DrawMenu()
|
||||
{
|
||||
m_text.SetContent("Clic on a key, this text should change !\nN for alternating event\nM for Menu");
|
||||
@@ -1,11 +1,7 @@
|
||||
#ifndef __KEYSTATE_HPP__
|
||||
#define __KEYSTATE_HPP__
|
||||
|
||||
#include "Text.hpp"
|
||||
|
||||
#include <Nazara/Utility/EventHandler.hpp>
|
||||
|
||||
#include <NDK/State.hpp>
|
||||
#include "BaseState.hpp"
|
||||
|
||||
class StateContext;
|
||||
|
||||
@@ -15,21 +11,18 @@ enum class KeyStatus
|
||||
Released
|
||||
};
|
||||
|
||||
class KeyState : public Ndk::State
|
||||
class KeyState : public BaseState
|
||||
{
|
||||
public:
|
||||
KeyState(StateContext& stateContext);
|
||||
|
||||
void Enter(Ndk::StateMachine& fsm) override;
|
||||
void Leave(Ndk::StateMachine& fsm) override;
|
||||
bool Update(Ndk::StateMachine& fsm, float elapsedTime) override;
|
||||
|
||||
private:
|
||||
void DrawMenu();
|
||||
void DrawMenu() override;
|
||||
|
||||
void ManageInput(KeyStatus isKeyPressed, const Nz::WindowEvent::KeyEvent& key, Ndk::StateMachine& fsm);
|
||||
|
||||
StateContext& m_context;
|
||||
Text m_text;
|
||||
KeyStatus m_keyStatus;
|
||||
NazaraSlot(Nz::EventHandler, OnKeyPressed, m_keyPressedSlot);
|
||||
NazaraSlot(Nz::EventHandler, OnKeyReleased, m_keyReleasedSlot);
|
||||
@@ -7,17 +7,14 @@
|
||||
#include <NDK/StateMachine.hpp>
|
||||
|
||||
MenuState::MenuState(StateContext& context) :
|
||||
State(),
|
||||
m_context(context),
|
||||
m_text(context),
|
||||
BaseState(context),
|
||||
m_selectedNextState(-1)
|
||||
{
|
||||
}
|
||||
|
||||
void MenuState::Enter(Ndk::StateMachine& /*fsm*/)
|
||||
void MenuState::Enter(Ndk::StateMachine& fsm)
|
||||
{
|
||||
m_text.SetVisible(true);
|
||||
DrawMenu();
|
||||
BaseState::Enter(fsm);
|
||||
|
||||
Nz::EventHandler& eventHandler = m_context.window.GetEventHandler();
|
||||
m_keyPressedSlot.Connect(eventHandler.OnKeyPressed, [this] (const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& key)
|
||||
@@ -29,9 +26,9 @@ void MenuState::Enter(Ndk::StateMachine& /*fsm*/)
|
||||
});
|
||||
}
|
||||
|
||||
void MenuState::Leave(Ndk::StateMachine& /*fsm*/)
|
||||
void MenuState::Leave(Ndk::StateMachine& fsm)
|
||||
{
|
||||
m_text.SetVisible(false);
|
||||
BaseState::Leave(fsm);
|
||||
m_selectedNextState = -1;
|
||||
}
|
||||
|
||||
@@ -1,28 +1,24 @@
|
||||
#ifndef __MENUSTATE_HPP__
|
||||
#define __MENUSTATE_HPP__
|
||||
|
||||
#include "Text.hpp"
|
||||
|
||||
#include <Nazara/Utility/EventHandler.hpp>
|
||||
|
||||
#include <NDK/State.hpp>
|
||||
#include "BaseState.hpp"
|
||||
|
||||
class StateContext;
|
||||
|
||||
class MenuState : public Ndk::State
|
||||
class MenuState : public BaseState
|
||||
{
|
||||
public:
|
||||
MenuState(StateContext& stateContext);
|
||||
|
||||
void Enter(Ndk::StateMachine& fsm) override;
|
||||
|
||||
void Leave(Ndk::StateMachine& fsm) override;
|
||||
|
||||
bool Update(Ndk::StateMachine& fsm, float elapsedTime) override;
|
||||
|
||||
private:
|
||||
void DrawMenu();
|
||||
|
||||
StateContext& m_context;
|
||||
Text m_text;
|
||||
NazaraSlot(Nz::EventHandler, OnKeyPressed, m_keyPressedSlot);
|
||||
int m_selectedNextState;
|
||||
};
|
||||
@@ -7,16 +7,13 @@
|
||||
#include <NDK/StateMachine.hpp>
|
||||
|
||||
MouseClickState::MouseClickState(StateContext& context) :
|
||||
State(),
|
||||
m_context(context),
|
||||
m_text(context)
|
||||
BaseState(context)
|
||||
{
|
||||
}
|
||||
|
||||
void MouseClickState::Enter(Ndk::StateMachine& fsm)
|
||||
{
|
||||
m_text.SetVisible(true);
|
||||
DrawMenu();
|
||||
BaseState::Enter(fsm);
|
||||
|
||||
Nz::EventHandler& eventHandler = m_context.window.GetEventHandler();
|
||||
m_keyPressedSlot.Connect(eventHandler.OnKeyPressed, [&] (const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& key)
|
||||
@@ -43,16 +40,6 @@ void MouseClickState::Enter(Ndk::StateMachine& fsm)
|
||||
});
|
||||
}
|
||||
|
||||
void MouseClickState::Leave(Ndk::StateMachine& /*fsm*/)
|
||||
{
|
||||
m_text.SetVisible(false);
|
||||
}
|
||||
|
||||
bool MouseClickState::Update(Ndk::StateMachine& /*fsm*/, float /*elapsedTime*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void MouseClickState::DrawMenu()
|
||||
{
|
||||
m_text.SetContent("Click in the windows, this text should change !\nM for Menu");
|
||||
@@ -1,11 +1,7 @@
|
||||
#ifndef __MOUSECLICKSTATE_HPP__
|
||||
#define __MOUSECLICKSTATE_HPP__
|
||||
|
||||
#include "Text.hpp"
|
||||
|
||||
#include <Nazara/Utility/EventHandler.hpp>
|
||||
|
||||
#include <NDK/State.hpp>
|
||||
#include "BaseState.hpp"
|
||||
|
||||
class StateContext;
|
||||
|
||||
@@ -16,21 +12,18 @@ enum class MouseStatus
|
||||
Released
|
||||
};
|
||||
|
||||
class MouseClickState : public Ndk::State
|
||||
class MouseClickState : public BaseState
|
||||
{
|
||||
public:
|
||||
MouseClickState(StateContext& stateContext);
|
||||
|
||||
void Enter(Ndk::StateMachine& fsm) override;
|
||||
void Leave(Ndk::StateMachine& fsm) override;
|
||||
bool Update(Ndk::StateMachine& fsm, float elapsedTime) override;
|
||||
|
||||
private:
|
||||
void DrawMenu();
|
||||
void DrawMenu() override;
|
||||
|
||||
void ManageInput(MouseStatus mouseStatus, const Nz::WindowEvent::MouseButtonEvent& mouse, Ndk::StateMachine& fsm);
|
||||
|
||||
StateContext& m_context;
|
||||
Text m_text;
|
||||
NazaraSlot(Nz::EventHandler, OnKeyPressed, m_keyPressedSlot);
|
||||
NazaraSlot(Nz::EventHandler, OnMouseButtonDoubleClicked, m_mouseButtonDoubleClickedSlot);
|
||||
NazaraSlot(Nz::EventHandler, OnMouseButtonPressed, m_mouseButtonPressedSlot);
|
||||
@@ -7,16 +7,13 @@
|
||||
#include <NDK/StateMachine.hpp>
|
||||
|
||||
MouseEnterState::MouseEnterState(StateContext& context) :
|
||||
State(),
|
||||
m_context(context),
|
||||
m_text(context)
|
||||
BaseState(context)
|
||||
{
|
||||
}
|
||||
|
||||
void MouseEnterState::Enter(Ndk::StateMachine& fsm)
|
||||
{
|
||||
m_text.SetVisible(true);
|
||||
DrawMenu();
|
||||
BaseState::Enter(fsm);
|
||||
|
||||
Nz::EventHandler& eventHandler = m_context.window.GetEventHandler();
|
||||
m_keyPressedSlot.Connect(eventHandler.OnKeyPressed, [&] (const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& key)
|
||||
@@ -38,16 +35,6 @@ void MouseEnterState::Enter(Ndk::StateMachine& fsm)
|
||||
});
|
||||
}
|
||||
|
||||
void MouseEnterState::Leave(Ndk::StateMachine& /*fsm*/)
|
||||
{
|
||||
m_text.SetVisible(false);
|
||||
}
|
||||
|
||||
bool MouseEnterState::Update(Ndk::StateMachine& /*fsm*/, float /*elapsedTime*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void MouseEnterState::DrawMenu()
|
||||
{
|
||||
m_text.SetContent("Move your mouse outside the windows, this text should change !\nM for Menu");
|
||||
@@ -1,28 +1,20 @@
|
||||
#ifndef __MOUSEENTERSTATE_HPP__
|
||||
#define __MOUSEENTERSTATE_HPP__
|
||||
|
||||
#include "Text.hpp"
|
||||
|
||||
#include <Nazara/Utility/EventHandler.hpp>
|
||||
|
||||
#include <NDK/State.hpp>
|
||||
#include "BaseState.hpp"
|
||||
|
||||
class StateContext;
|
||||
|
||||
class MouseEnterState : public Ndk::State
|
||||
class MouseEnterState : public BaseState
|
||||
{
|
||||
public:
|
||||
MouseEnterState(StateContext& stateContext);
|
||||
|
||||
void Enter(Ndk::StateMachine& fsm) override;
|
||||
void Leave(Ndk::StateMachine& fsm) override;
|
||||
bool Update(Ndk::StateMachine& fsm, float elapsedTime) override;
|
||||
|
||||
private:
|
||||
void DrawMenu();
|
||||
void DrawMenu() override;
|
||||
|
||||
StateContext& m_context;
|
||||
Text m_text;
|
||||
NazaraSlot(Nz::EventHandler, OnKeyPressed, m_keyPressedSlot);
|
||||
NazaraSlot(Nz::EventHandler, OnMouseEntered, m_mouseEnteredSlot);
|
||||
NazaraSlot(Nz::EventHandler, OnMouseLeft, m_mouseLeftSlot);
|
||||
@@ -7,16 +7,13 @@
|
||||
#include <NDK/StateMachine.hpp>
|
||||
|
||||
MouseMoveState::MouseMoveState(StateContext& context) :
|
||||
State(),
|
||||
m_context(context),
|
||||
m_text(context)
|
||||
BaseState(context)
|
||||
{
|
||||
}
|
||||
|
||||
void MouseMoveState::Enter(Ndk::StateMachine& fsm)
|
||||
{
|
||||
m_text.SetVisible(true);
|
||||
DrawMenu();
|
||||
BaseState::Enter(fsm);
|
||||
|
||||
Nz::EventHandler& eventHandler = m_context.window.GetEventHandler();
|
||||
m_keyPressedSlot.Connect(eventHandler.OnKeyPressed, [&] (const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& key)
|
||||
@@ -38,16 +35,6 @@ void MouseMoveState::Enter(Ndk::StateMachine& fsm)
|
||||
});
|
||||
}
|
||||
|
||||
void MouseMoveState::Leave(Ndk::StateMachine& /*fsm*/)
|
||||
{
|
||||
m_text.SetVisible(false);
|
||||
}
|
||||
|
||||
bool MouseMoveState::Update(Ndk::StateMachine& /*fsm*/, float /*elapsedTime*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void MouseMoveState::DrawMenu()
|
||||
{
|
||||
m_text.SetContent("Move your mouse or your wheel, this text should change !\nM for Menu");
|
||||
@@ -1,28 +1,20 @@
|
||||
#ifndef __MOUSEMOVESTATE_HPP__
|
||||
#define __MOUSEMOVESTATE_HPP__
|
||||
|
||||
#include "Text.hpp"
|
||||
|
||||
#include <Nazara/Utility/EventHandler.hpp>
|
||||
|
||||
#include <NDK/State.hpp>
|
||||
#include "BaseState.hpp"
|
||||
|
||||
class StateContext;
|
||||
|
||||
class MouseMoveState : public Ndk::State
|
||||
class MouseMoveState : public BaseState
|
||||
{
|
||||
public:
|
||||
MouseMoveState(StateContext& stateContext);
|
||||
|
||||
void Enter(Ndk::StateMachine& fsm) override;
|
||||
void Leave(Ndk::StateMachine& fsm) override;
|
||||
bool Update(Ndk::StateMachine& fsm, float elapsedTime) override;
|
||||
|
||||
private:
|
||||
void DrawMenu();
|
||||
void DrawMenu() override;
|
||||
|
||||
StateContext& m_context;
|
||||
Text m_text;
|
||||
NazaraSlot(Nz::EventHandler, OnKeyPressed, m_keyPressedSlot);
|
||||
NazaraSlot(Nz::EventHandler, OnMouseMoved, m_mouseMovedSlot);
|
||||
NazaraSlot(Nz::EventHandler, OnMouseWheelMoved, m_mouseWheelMovedSlot);
|
||||
@@ -7,16 +7,13 @@
|
||||
#include <NDK/StateMachine.hpp>
|
||||
|
||||
TextEnterState::TextEnterState(StateContext& context) :
|
||||
State(),
|
||||
m_context(context),
|
||||
m_text(context)
|
||||
BaseState(context)
|
||||
{
|
||||
}
|
||||
|
||||
void TextEnterState::Enter(Ndk::StateMachine& fsm)
|
||||
{
|
||||
m_text.SetVisible(true);
|
||||
DrawMenu();
|
||||
BaseState::Enter(fsm);
|
||||
|
||||
Nz::EventHandler& eventHandler = m_context.window.GetEventHandler();
|
||||
m_keyPressedSlot.Connect(eventHandler.OnKeyPressed, [&] (const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& key)
|
||||
@@ -36,16 +33,6 @@ void TextEnterState::Enter(Ndk::StateMachine& fsm)
|
||||
});
|
||||
}
|
||||
|
||||
void TextEnterState::Leave(Ndk::StateMachine& /*fsm*/)
|
||||
{
|
||||
m_text.SetVisible(false);
|
||||
}
|
||||
|
||||
bool TextEnterState::Update(Ndk::StateMachine& /*fsm*/, float /*elapsedTime*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void TextEnterState::DrawMenu()
|
||||
{
|
||||
m_text.SetContent("Enter some text, this text should change !\nM for Menu");
|
||||
@@ -1,28 +1,20 @@
|
||||
#ifndef __TEXTENTERSTATE_HPP__
|
||||
#define __TEXTENTERSTATE_HPP__
|
||||
|
||||
#include "Text.hpp"
|
||||
|
||||
#include <Nazara/Utility/EventHandler.hpp>
|
||||
|
||||
#include <NDK/State.hpp>
|
||||
#include "BaseState.hpp"
|
||||
|
||||
class StateContext;
|
||||
|
||||
class TextEnterState : public Ndk::State
|
||||
class TextEnterState : public BaseState
|
||||
{
|
||||
public:
|
||||
TextEnterState(StateContext& stateContext);
|
||||
|
||||
void Enter(Ndk::StateMachine& fsm) override;
|
||||
void Leave(Ndk::StateMachine& fsm) override;
|
||||
bool Update(Ndk::StateMachine& fsm, float elapsedTime) override;
|
||||
|
||||
private:
|
||||
void DrawMenu();
|
||||
void DrawMenu() override;
|
||||
|
||||
StateContext& m_context;
|
||||
Text m_text;
|
||||
NazaraSlot(Nz::EventHandler, OnKeyPressed, m_keyPressedSlot);
|
||||
NazaraSlot(Nz::EventHandler, OnTextEntered, m_textEnteredSlot);
|
||||
};
|
||||
@@ -7,16 +7,13 @@
|
||||
#include <NDK/StateMachine.hpp>
|
||||
|
||||
WindowModificationState::WindowModificationState(StateContext& context) :
|
||||
State(),
|
||||
m_context(context),
|
||||
m_text(context)
|
||||
BaseState(context)
|
||||
{
|
||||
}
|
||||
|
||||
void WindowModificationState::Enter(Ndk::StateMachine& fsm)
|
||||
{
|
||||
m_text.SetVisible(true);
|
||||
DrawMenu();
|
||||
BaseState::Enter(fsm);
|
||||
|
||||
Nz::EventHandler& eventHandler = m_context.window.GetEventHandler();
|
||||
m_keyPressedSlot.Connect(eventHandler.OnKeyPressed, [&] (const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& key)
|
||||
@@ -38,16 +35,6 @@ void WindowModificationState::Enter(Ndk::StateMachine& fsm)
|
||||
});
|
||||
}
|
||||
|
||||
void WindowModificationState::Leave(Ndk::StateMachine& /*fsm*/)
|
||||
{
|
||||
m_text.SetVisible(false);
|
||||
}
|
||||
|
||||
bool WindowModificationState::Update(Ndk::StateMachine& /*fsm*/, float /*elapsedTime*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void WindowModificationState::DrawMenu()
|
||||
{
|
||||
m_text.SetContent("Move the window or resize it, this text should change !\nM for Menu");
|
||||
@@ -1,28 +1,20 @@
|
||||
#ifndef __WINDOWMODIFICATIONSTATE_HPP__
|
||||
#define __WINDOWMODIFICATIONSTATE_HPP__
|
||||
|
||||
#include "Text.hpp"
|
||||
|
||||
#include <Nazara/Utility/EventHandler.hpp>
|
||||
|
||||
#include <NDK/State.hpp>
|
||||
#include "BaseState.hpp"
|
||||
|
||||
class StateContext;
|
||||
|
||||
class WindowModificationState : public Ndk::State
|
||||
class WindowModificationState : public BaseState
|
||||
{
|
||||
public:
|
||||
WindowModificationState(StateContext& stateContext);
|
||||
|
||||
void Enter(Ndk::StateMachine& fsm) override;
|
||||
void Leave(Ndk::StateMachine& fsm) override;
|
||||
bool Update(Ndk::StateMachine& fsm, float elapsedTime) override;
|
||||
|
||||
private:
|
||||
void DrawMenu();
|
||||
void DrawMenu() override;
|
||||
|
||||
StateContext& m_context;
|
||||
Text m_text;
|
||||
NazaraSlot(Nz::EventHandler, OnKeyPressed, m_keyPressedSlot);
|
||||
NazaraSlot(Nz::EventHandler, OnMoved, m_movedSlot);
|
||||
NazaraSlot(Nz::EventHandler, OnResized, m_resizedSlot);
|
||||
Reference in New Issue
Block a user