Merge branch 'master' into reflection-mapping
This commit is contained in:
@@ -8,13 +8,11 @@
|
||||
#define NDK_APPLICATION_HPP
|
||||
|
||||
#include <NDK/Prerequesites.hpp>
|
||||
#include <NDK/EntityOwner.hpp>
|
||||
#include <NDK/World.hpp>
|
||||
#include <Nazara/Core/Clock.hpp>
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
#include <NDK/Console.hpp>
|
||||
@@ -22,7 +20,7 @@
|
||||
#include <Nazara/Lua/LuaInstance.hpp>
|
||||
#include <Nazara/Graphics/TextSprite.hpp>
|
||||
#include <Nazara/Renderer/RenderTarget.hpp>
|
||||
#include <Nazara/Utility/Window.hpp>
|
||||
#include <Nazara/Platform/Window.hpp>
|
||||
#endif
|
||||
|
||||
namespace Ndk
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <NDK/Application.hpp>
|
||||
#include <Nazara/Core/ErrorFlags.hpp>
|
||||
#include <type_traits>
|
||||
#include <NDK/Sdk.hpp>
|
||||
|
||||
namespace Ndk
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <NDK/BaseComponent.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
|
||||
namespace Ndk
|
||||
|
||||
@@ -8,9 +8,7 @@
|
||||
#define NDK_BASESYSTEM_HPP
|
||||
|
||||
#include <Nazara/Core/Bitset.hpp>
|
||||
#include <NDK/Entity.hpp>
|
||||
#include <NDK/EntityList.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
@@ -35,17 +33,19 @@ namespace Ndk
|
||||
bool Filters(const Entity* entity) const;
|
||||
|
||||
inline const EntityList& GetEntities() const;
|
||||
inline float GetFixedUpdateRate() const;
|
||||
inline SystemIndex GetIndex() const;
|
||||
inline float GetMaximumUpdateRate() const;
|
||||
inline int GetUpdateOrder() const;
|
||||
inline float GetUpdateRate() const;
|
||||
inline World& GetWorld() const;
|
||||
|
||||
inline bool IsEnabled() const;
|
||||
|
||||
inline bool HasEntity(const Entity* entity) const;
|
||||
|
||||
inline void SetFixedUpdateRate(float updatePerSecond);
|
||||
inline void SetMaximumUpdateRate(float updatePerSecond);
|
||||
void SetUpdateOrder(int updateOrder);
|
||||
inline void SetUpdateRate(float updatePerSecond);
|
||||
|
||||
inline void Update(float elapsedTime);
|
||||
|
||||
@@ -93,8 +93,9 @@ namespace Ndk
|
||||
SystemIndex m_systemIndex;
|
||||
World* m_world;
|
||||
bool m_updateEnabled;
|
||||
float m_fixedUpdateRate;
|
||||
float m_maxUpdateRate;
|
||||
float m_updateCounter;
|
||||
float m_updateRate;
|
||||
int m_updateOrder;
|
||||
|
||||
static SystemIndex s_nextIndex;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <NDK/BaseSystem.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
@@ -20,7 +19,8 @@ namespace Ndk
|
||||
m_updateEnabled(true),
|
||||
m_updateOrder(0)
|
||||
{
|
||||
SetUpdateRate(30);
|
||||
SetFixedUpdateRate(0);
|
||||
SetMaximumUpdateRate(30);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -34,8 +34,9 @@ namespace Ndk
|
||||
m_requiredComponents(system.m_requiredComponents),
|
||||
m_systemIndex(system.m_systemIndex),
|
||||
m_updateEnabled(system.m_updateEnabled),
|
||||
m_fixedUpdateRate(system.m_fixedUpdateRate),
|
||||
m_maxUpdateRate(system.m_maxUpdateRate),
|
||||
m_updateCounter(0.f),
|
||||
m_updateRate(system.m_updateRate),
|
||||
m_updateOrder(system.m_updateOrder)
|
||||
{
|
||||
}
|
||||
@@ -61,6 +62,24 @@ namespace Ndk
|
||||
return m_entities;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the maximum rate of update of the system
|
||||
* \return Update rate
|
||||
*/
|
||||
inline float BaseSystem::GetFixedUpdateRate() const
|
||||
{
|
||||
return (m_fixedUpdateRate > 0.f) ? 1.f / m_fixedUpdateRate : 0.f;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the maximum rate of update of the system
|
||||
* \return Update rate
|
||||
*/
|
||||
inline float BaseSystem::GetMaximumUpdateRate() const
|
||||
{
|
||||
return (m_maxUpdateRate > 0.f) ? 1.f / m_maxUpdateRate : 0.f;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the index of the system
|
||||
* \return Index of the system
|
||||
@@ -82,16 +101,6 @@ namespace Ndk
|
||||
return m_updateOrder;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the rate of update of the system
|
||||
* \return Update rate
|
||||
*/
|
||||
|
||||
inline float BaseSystem::GetUpdateRate() const
|
||||
{
|
||||
return (m_updateRate > 0.f) ? 1.f / m_updateRate : 0.f;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the world on which the system operate
|
||||
* \return World in which the system is
|
||||
@@ -125,15 +134,25 @@ namespace Ndk
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the rate of update for the system
|
||||
* \brief Sets the fixed update rate for the system
|
||||
*
|
||||
* \param updatePerSecond Update rate, 0 means update rate is not fixed
|
||||
*/
|
||||
inline void BaseSystem::SetFixedUpdateRate(float updatePerSecond)
|
||||
{
|
||||
m_updateCounter = 0.f;
|
||||
m_fixedUpdateRate = (updatePerSecond > 0.f) ? 1.f / updatePerSecond : 0.f; // 0.f means no limit
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the maximum update rate for the system
|
||||
*
|
||||
* \param updatePerSecond Update rate, 0 means as much as possible
|
||||
*/
|
||||
|
||||
inline void BaseSystem::SetUpdateRate(float updatePerSecond)
|
||||
inline void BaseSystem::SetMaximumUpdateRate(float updatePerSecond)
|
||||
{
|
||||
m_updateCounter = 0.f;
|
||||
m_updateRate = (updatePerSecond > 0.f) ? 1.f / updatePerSecond : 0.f; // 0.f means no limit
|
||||
m_maxUpdateRate = (updatePerSecond > 0.f) ? 1.f / updatePerSecond : 0.f; // 0.f means no limit
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -147,18 +166,40 @@ namespace Ndk
|
||||
if (!IsEnabled())
|
||||
return;
|
||||
|
||||
if (m_updateRate > 0.f)
|
||||
{
|
||||
m_updateCounter += elapsedTime;
|
||||
m_updateCounter += elapsedTime;
|
||||
|
||||
while (m_updateCounter >= m_updateRate)
|
||||
if (m_maxUpdateRate > 0.f)
|
||||
{
|
||||
if (m_updateCounter >= m_maxUpdateRate)
|
||||
{
|
||||
OnUpdate(m_updateRate);
|
||||
m_updateCounter -= m_updateRate;
|
||||
if (m_fixedUpdateRate > 0.f)
|
||||
{
|
||||
while (m_updateCounter >= m_fixedUpdateRate)
|
||||
{
|
||||
OnUpdate(m_fixedUpdateRate);
|
||||
m_updateCounter -= m_fixedUpdateRate;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OnUpdate(m_maxUpdateRate);
|
||||
m_updateCounter -= m_maxUpdateRate;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
OnUpdate(elapsedTime);
|
||||
{
|
||||
if (m_fixedUpdateRate > 0.f)
|
||||
{
|
||||
while (m_updateCounter >= m_fixedUpdateRate)
|
||||
{
|
||||
OnUpdate(m_fixedUpdateRate);
|
||||
m_updateCounter -= m_fixedUpdateRate;
|
||||
}
|
||||
}
|
||||
else
|
||||
OnUpdate(elapsedTime);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -12,9 +12,8 @@
|
||||
#include <NDK/EntityOwner.hpp>
|
||||
#include <NDK/World.hpp>
|
||||
#include <Nazara/Graphics/Sprite.hpp>
|
||||
#include <Nazara/Utility/Cursor.hpp>
|
||||
#include <Nazara/Utility/Event.hpp>
|
||||
#include <Nazara/Utility/Mouse.hpp>
|
||||
#include <Nazara/Platform/Event.hpp>
|
||||
#include <Nazara/Platform/Mouse.hpp>
|
||||
#include <Nazara/Utility/Node.hpp>
|
||||
#include <limits>
|
||||
|
||||
@@ -38,6 +37,8 @@ namespace Ndk
|
||||
inline void AddChild(std::unique_ptr<BaseWidget>&& widget);
|
||||
|
||||
inline void Center();
|
||||
inline void CenterHorizontal();
|
||||
inline void CenterVertical();
|
||||
|
||||
inline void Destroy();
|
||||
|
||||
|
||||
@@ -46,6 +46,24 @@ namespace Ndk
|
||||
SetPosition((parentSize.x - mySize.x) / 2.f, (parentSize.y - mySize.y) / 2.f);
|
||||
}
|
||||
|
||||
inline void BaseWidget::CenterHorizontal()
|
||||
{
|
||||
NazaraAssert(m_widgetParent, "Widget has no parent");
|
||||
|
||||
Nz::Vector2f parentSize = m_widgetParent->GetSize();
|
||||
Nz::Vector2f mySize = GetSize();
|
||||
SetPosition((parentSize.x - mySize.x) / 2.f, GetPosition(Nz::CoordSys_Local).y);
|
||||
}
|
||||
|
||||
inline void BaseWidget::CenterVertical()
|
||||
{
|
||||
NazaraAssert(m_widgetParent, "Widget has no parent");
|
||||
|
||||
Nz::Vector2f parentSize = m_widgetParent->GetSize();
|
||||
Nz::Vector2f mySize = GetSize();
|
||||
SetPosition(GetPosition(Nz::CoordSys_Local).x, (parentSize.y - mySize.y) / 2.f);
|
||||
}
|
||||
|
||||
inline const Nz::Color& BaseWidget::GetBackgroundColor() const
|
||||
{
|
||||
return m_backgroundColor;
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
#include <NDK/Prerequesites.hpp>
|
||||
#include <NDK/BaseWidget.hpp>
|
||||
#include <Nazara/Utility/CursorController.hpp>
|
||||
#include <Nazara/Utility/EventHandler.hpp>
|
||||
#include <Nazara/Platform/CursorController.hpp>
|
||||
#include <Nazara/Platform/EventHandler.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
@@ -44,13 +44,13 @@ namespace Ndk
|
||||
void UnregisterWidget(std::size_t index);
|
||||
|
||||
private:
|
||||
void OnMouseButtonPressed(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::MouseButtonEvent& event);
|
||||
void OnMouseButtonRelease(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::MouseButtonEvent& event);
|
||||
void OnMouseMoved(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::MouseMoveEvent& event);
|
||||
void OnMouseLeft(const Nz::EventHandler* eventHandler);
|
||||
void OnKeyPressed(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::KeyEvent& event);
|
||||
void OnKeyReleased(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::KeyEvent& event);
|
||||
void OnTextEntered(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::TextEvent& event);
|
||||
void OnEventMouseButtonPressed(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::MouseButtonEvent& event);
|
||||
void OnEventMouseButtonRelease(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::MouseButtonEvent& event);
|
||||
void OnEventMouseMoved(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::MouseMoveEvent& event);
|
||||
void OnEventMouseLeft(const Nz::EventHandler* eventHandler);
|
||||
void OnEventKeyPressed(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::KeyEvent& event);
|
||||
void OnEventKeyReleased(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::KeyEvent& event);
|
||||
void OnEventTextEntered(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::TextEvent& event);
|
||||
|
||||
struct WidgetBox
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <NDK/Canvas.hpp>
|
||||
#include <Nazara/Utility/Cursor.hpp>
|
||||
#include <Nazara/Platform/Cursor.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
@@ -20,13 +20,13 @@ namespace Ndk
|
||||
RegisterToCanvas();
|
||||
|
||||
// Connect to every meaningful event
|
||||
m_keyPressedSlot.Connect(eventHandler.OnKeyPressed, this, &Canvas::OnKeyPressed);
|
||||
m_keyReleasedSlot.Connect(eventHandler.OnKeyReleased, this, &Canvas::OnKeyReleased);
|
||||
m_mouseButtonPressedSlot.Connect(eventHandler.OnMouseButtonPressed, this, &Canvas::OnMouseButtonPressed);
|
||||
m_mouseButtonReleasedSlot.Connect(eventHandler.OnMouseButtonReleased, this, &Canvas::OnMouseButtonRelease);
|
||||
m_mouseMovedSlot.Connect(eventHandler.OnMouseMoved, this, &Canvas::OnMouseMoved);
|
||||
m_mouseLeftSlot.Connect(eventHandler.OnMouseLeft, this, &Canvas::OnMouseLeft);
|
||||
m_textEnteredSlot.Connect(eventHandler.OnTextEntered, this, &Canvas::OnTextEntered);
|
||||
m_keyPressedSlot.Connect(eventHandler.OnKeyPressed, this, &Canvas::OnEventKeyPressed);
|
||||
m_keyReleasedSlot.Connect(eventHandler.OnKeyReleased, this, &Canvas::OnEventKeyReleased);
|
||||
m_mouseButtonPressedSlot.Connect(eventHandler.OnMouseButtonPressed, this, &Canvas::OnEventMouseButtonPressed);
|
||||
m_mouseButtonReleasedSlot.Connect(eventHandler.OnMouseButtonReleased, this, &Canvas::OnEventMouseButtonRelease);
|
||||
m_mouseMovedSlot.Connect(eventHandler.OnMouseMoved, this, &Canvas::OnEventMouseMoved);
|
||||
m_mouseLeftSlot.Connect(eventHandler.OnMouseLeft, this, &Canvas::OnEventMouseLeft);
|
||||
m_textEnteredSlot.Connect(eventHandler.OnTextEntered, this, &Canvas::OnEventTextEntered);
|
||||
|
||||
// Disable padding by default
|
||||
SetPadding(0.f, 0.f, 0.f, 0.f);
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
namespace Ndk
|
||||
{
|
||||
class CameraComponent;
|
||||
class Entity;
|
||||
|
||||
using CameraComponentHandle = Nz::ObjectHandle<CameraComponent>;
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <NDK/Components/CameraComponent.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Math/Algorithm.hpp>
|
||||
|
||||
|
||||
@@ -8,18 +8,12 @@
|
||||
#define NDK_COMPONENTS_COLLISIONCOMPONENT2D_HPP
|
||||
|
||||
#include <Nazara/Physics2D/Collider2D.hpp>
|
||||
#include <Nazara/Physics2D/RigidBody2D.hpp>
|
||||
#include <NDK/Component.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class RigidBody2D;
|
||||
}
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class Entity;
|
||||
|
||||
class NDK_API CollisionComponent2D : public Component<CollisionComponent2D>
|
||||
{
|
||||
friend class PhysicsSystem2D;
|
||||
@@ -29,6 +23,7 @@ namespace Ndk
|
||||
CollisionComponent2D(const CollisionComponent2D& collision);
|
||||
~CollisionComponent2D() = default;
|
||||
|
||||
Nz::Rectf GetAABB() const;
|
||||
const Nz::Collider2DRef& GetGeom() const;
|
||||
|
||||
void SetGeom(Nz::Collider2DRef geom);
|
||||
|
||||
@@ -2,12 +2,6 @@
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <NDK/Components/CollisionComponent2D.hpp>
|
||||
#include <NDK/Entity.hpp>
|
||||
#include <NDK/World.hpp>
|
||||
#include <NDK/Components/PhysicsComponent2D.hpp>
|
||||
#include <NDK/Systems/PhysicsSystem2D.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
/*!
|
||||
@@ -34,6 +28,16 @@ namespace Ndk
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the collision box representing the entity
|
||||
* \return The physics collision box
|
||||
*/
|
||||
|
||||
inline Nz::Rectf CollisionComponent2D::GetAABB() const
|
||||
{
|
||||
return m_staticBody->GetAABB();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the geometry representing the entity
|
||||
* \return A constant reference to the physics geometry
|
||||
|
||||
@@ -8,18 +8,12 @@
|
||||
#define NDK_COMPONENTS_COLLISIONCOMPONENT3D_HPP
|
||||
|
||||
#include <Nazara/Physics3D/Collider3D.hpp>
|
||||
#include <Nazara/Physics3D/RigidBody3D.hpp>
|
||||
#include <NDK/Component.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class RigidBody3D;
|
||||
}
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class Entity;
|
||||
|
||||
class NDK_API CollisionComponent3D : public Component<CollisionComponent3D>
|
||||
{
|
||||
friend class PhysicsSystem3D;
|
||||
|
||||
@@ -2,11 +2,6 @@
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <NDK/Entity.hpp>
|
||||
#include <NDK/World.hpp>
|
||||
#include <NDK/Components/PhysicsComponent3D.hpp>
|
||||
#include <NDK/Systems/PhysicsSystem3D.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
/*!
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#define NDK_COMPONENTS_PARTICLEEMITTERCOMPONENT_HPP
|
||||
|
||||
#include <Nazara/Graphics/ParticleEmitter.hpp>
|
||||
#include <Nazara/Graphics/ParticleGroup.hpp>
|
||||
#include <NDK/Component.hpp>
|
||||
|
||||
namespace Ndk
|
||||
@@ -24,7 +23,7 @@ namespace Ndk
|
||||
ParticleEmitterComponent(ParticleEmitterComponent&& emitter) = default;
|
||||
~ParticleEmitterComponent() = default;
|
||||
|
||||
void Enable(bool active = true);
|
||||
inline void Enable(bool active = true);
|
||||
|
||||
inline bool IsActive() const;
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <NDK/Components/ParticleEmitterComponent.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
/*!
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <NDK/Components/ParticleGroupComponent.hpp>
|
||||
#include <NDK/Components/ParticleEmitterComponent.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class Entity;
|
||||
|
||||
class NDK_API PhysicsComponent2D : public Component<PhysicsComponent2D>
|
||||
{
|
||||
friend class CollisionComponent2D;
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include "PhysicsComponent2D.hpp"
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class Entity;
|
||||
|
||||
class NDK_API PhysicsComponent3D : public Component<PhysicsComponent3D>
|
||||
{
|
||||
friend class CollisionComponent3D;
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <NDK/Entity.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
/*!
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <Nazara/Core/ObjectHandle.hpp>
|
||||
#include <Nazara/Graphics/Sprite.hpp>
|
||||
#include <Nazara/Graphics/TextSprite.hpp>
|
||||
#include <Nazara/Utility/Event.hpp>
|
||||
#include <Nazara/Utility/Node.hpp>
|
||||
#include <Nazara/Utility/SimpleTextDrawer.hpp>
|
||||
#include <NDK/EntityOwner.hpp>
|
||||
@@ -20,12 +19,12 @@
|
||||
namespace Nz
|
||||
{
|
||||
class LuaState;
|
||||
struct WindowEvent;
|
||||
}
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class Console;
|
||||
class Entity;
|
||||
|
||||
using ConsoleHandle = Nz::ObjectHandle<Console>;
|
||||
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include "Console.hpp"
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
/*!
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <Nazara/Core/HandledObject.hpp>
|
||||
#include <Nazara/Core/Signal.hpp>
|
||||
#include <NDK/Algorithm.hpp>
|
||||
#include <NDK/Prerequesites.hpp>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
|
||||
@@ -2,13 +2,11 @@
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <NDK/Entity.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/StringStream.hpp>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace Ndk
|
||||
inline void Insert(Entity* entity);
|
||||
|
||||
inline void Remove(Entity* entity);
|
||||
inline void Reserve(std::size_t entityCount);
|
||||
|
||||
// STL API
|
||||
inline iterator begin() const;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <NDK/EntityList.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
@@ -137,6 +136,16 @@ namespace Ndk
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Reserves enough space to contains entityCount entities
|
||||
*
|
||||
* \param entityCount Number of entities to reserve
|
||||
*/
|
||||
inline void EntityList::Reserve(std::size_t entityCount)
|
||||
{
|
||||
m_entityBits.Reserve(entityCount);
|
||||
}
|
||||
|
||||
// STL Interface
|
||||
inline EntityList::iterator EntityList::begin() const
|
||||
{
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#ifndef NDK_LUABINDING_HPP
|
||||
#define NDK_LUABINDING_HPP
|
||||
|
||||
#include <NDK/BaseComponent.hpp>
|
||||
#include <NDK/Entity.hpp>
|
||||
#include <NDK/Lua/LuaBinding_Base.hpp>
|
||||
#include <memory>
|
||||
@@ -36,6 +35,7 @@ namespace Ndk
|
||||
std::unique_ptr<LuaBinding_Base> audio;
|
||||
std::unique_ptr<LuaBinding_Base> graphics;
|
||||
std::unique_ptr<LuaBinding_Base> renderer;
|
||||
std::unique_ptr<LuaBinding_Base> platform;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
@@ -2,10 +2,37 @@
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <NDK/Lua/LuaBinding.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
namespace Detail
|
||||
{
|
||||
template<bool HasDefaultConstructor>
|
||||
struct AddComponentIf;
|
||||
|
||||
template<>
|
||||
struct AddComponentIf<true>
|
||||
{
|
||||
template<typename T>
|
||||
static int AddComponent(Nz::LuaState& lua, EntityHandle& handle)
|
||||
{
|
||||
T& component = handle->AddComponent<T>();
|
||||
lua.Push(component.CreateHandle());
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct AddComponentIf<false>
|
||||
{
|
||||
template<typename T>
|
||||
static int AddComponent(Nz::LuaState& lua, EntityHandle& /*handle*/)
|
||||
{
|
||||
lua.Error("Component has no default constructor and cannot be created from Lua yet");
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Binds a component to a name
|
||||
*
|
||||
@@ -13,14 +40,15 @@ namespace Ndk
|
||||
*
|
||||
* \remark Produces a NazaraAssert if name is empty
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
void LuaBinding::BindComponent(const Nz::String& name)
|
||||
{
|
||||
NazaraAssert(!name.IsEmpty(), "Component name cannot be empty");
|
||||
|
||||
static_assert(std::is_base_of<BaseComponent, T>::value, "ComponentType must inherit BaseComponent");
|
||||
|
||||
ComponentBinding binding;
|
||||
binding.adder = &AddComponentOfType<T>;
|
||||
binding.adder = &Detail::AddComponentIf<std::is_default_constructible<T>::value>::template AddComponent<T>;
|
||||
binding.getter = &PushComponentOfType<T>;
|
||||
binding.index = T::componentIndex;
|
||||
binding.name = name;
|
||||
@@ -32,21 +60,9 @@ namespace Ndk
|
||||
m_componentBindingByName[name] = T::componentIndex;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
int LuaBinding::AddComponentOfType(Nz::LuaState& lua, EntityHandle& handle)
|
||||
{
|
||||
static_assert(std::is_base_of<BaseComponent, T>::value, "ComponentType must inherit BaseComponent");
|
||||
|
||||
T& component = handle->AddComponent<T>();
|
||||
lua.Push(component.CreateHandle());
|
||||
return 1;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
int LuaBinding::PushComponentOfType(Nz::LuaState& lua, BaseComponent& component)
|
||||
{
|
||||
static_assert(std::is_base_of<BaseComponent, T>::value, "ComponentType must inherit BaseComponent");
|
||||
|
||||
T& rightComponent = static_cast<T&>(component);
|
||||
lua.Push(rightComponent.CreateHandle());
|
||||
return 1;
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace Ndk
|
||||
class LuaBinding_Renderer;
|
||||
class LuaBinding_SDK;
|
||||
class LuaBinding_Utility;
|
||||
class LuaBinding_Platform;
|
||||
|
||||
class NDK_API LuaBinding_Base
|
||||
{
|
||||
@@ -43,6 +44,7 @@ namespace Ndk
|
||||
static std::unique_ptr<LuaBinding_Base> BindAudio(LuaBinding& binding);
|
||||
static std::unique_ptr<LuaBinding_Base> BindGraphics(LuaBinding& binding);
|
||||
static std::unique_ptr<LuaBinding_Base> BindRenderer(LuaBinding& binding);
|
||||
static std::unique_ptr<LuaBinding_Base> BindPlatform(LuaBinding& binding);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
28
SDK/include/NDK/Lua/LuaBinding_Platform.hpp
Normal file
28
SDK/include/NDK/Lua/LuaBinding_Platform.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_LUABINDING_SYSTEM_HPP
|
||||
#define NDK_LUABINDING_SYSTEM_HPP
|
||||
|
||||
#include <Nazara/Platform/Keyboard.hpp>
|
||||
#include <NDK/Lua/LuaBinding_Base.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LuaBinding_Platform : public LuaBinding_Base
|
||||
{
|
||||
public:
|
||||
LuaBinding_Platform(LuaBinding& binding);
|
||||
~LuaBinding_Platform() = default;
|
||||
|
||||
void Register(Nz::LuaState& state) override;
|
||||
|
||||
// Platform
|
||||
Nz::LuaClass<Nz::Keyboard> keyboard;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NDK_LUABINDING_SYSTEM_HPP
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <NDK/Components.hpp>
|
||||
#include <NDK/Console.hpp>
|
||||
#include <NDK/Entity.hpp>
|
||||
#include <NDK/World.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include <Nazara/Utility/AbstractImage.hpp>
|
||||
#include <Nazara/Utility/Font.hpp>
|
||||
#include <Nazara/Utility/Keyboard.hpp>
|
||||
#include <Nazara/Utility/Node.hpp>
|
||||
#include <NDK/Lua/LuaBinding_Base.hpp>
|
||||
|
||||
@@ -26,7 +25,6 @@ namespace Ndk
|
||||
// Utility
|
||||
Nz::LuaClass<Nz::AbstractImageRef> abstractImage;
|
||||
Nz::LuaClass<Nz::FontRef> font;
|
||||
Nz::LuaClass<Nz::Keyboard> keyboard;
|
||||
Nz::LuaClass<Nz::Node> node;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <NDK/LuaAPI.hpp>
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Lua/LuaState.hpp>
|
||||
#include <Nazara/Math/EulerAngles.hpp>
|
||||
@@ -16,7 +15,6 @@
|
||||
#include <NDK/Components.hpp>
|
||||
#include <NDK/Entity.hpp>
|
||||
#include <NDK/World.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
#include <Nazara/Audio/Music.hpp>
|
||||
|
||||
@@ -11,16 +11,16 @@
|
||||
#include <Nazara/Graphics/AbstractBackground.hpp>
|
||||
#include <Nazara/Graphics/CullingList.hpp>
|
||||
#include <Nazara/Graphics/DepthRenderTechnique.hpp>
|
||||
#include <Nazara/Graphics/ForwardRenderTechnique.hpp>
|
||||
#include <Nazara/Renderer/RenderTexture.hpp>
|
||||
#include <NDK/Components/GraphicsComponent.hpp>
|
||||
#include <NDK/EntityList.hpp>
|
||||
#include <NDK/System.hpp>
|
||||
#include <unordered_map>
|
||||
#include <NDK/Components/GraphicsComponent.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class AbstractViewer;
|
||||
|
||||
class NDK_API RenderSystem : public System<RenderSystem>
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
#define NDK_WIDGETS_GLOBAL_HPP
|
||||
|
||||
#include <NDK/Widgets/ButtonWidget.hpp>
|
||||
#include <NDK/Widgets/CheckboxWidget.hpp>
|
||||
#include <NDK/Widgets/LabelWidget.hpp>
|
||||
#include <NDK/Widgets/ProgressBarWidget.hpp>
|
||||
#include <NDK/Widgets/TextAreaWidget.hpp>
|
||||
|
||||
#endif // NDK_WIDGETS_GLOBAL_HPP
|
||||
|
||||
@@ -9,14 +9,17 @@
|
||||
|
||||
#include <NDK/Prerequesites.hpp>
|
||||
#include <NDK/BaseWidget.hpp>
|
||||
#include <Nazara/Utility/AbstractTextDrawer.hpp>
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Graphics/Sprite.hpp>
|
||||
#include <Nazara/Graphics/TextSprite.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class AbstractTextDrawer;
|
||||
}
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class World;
|
||||
|
||||
class NDK_API ButtonWidget : public BaseWidget
|
||||
{
|
||||
public:
|
||||
@@ -29,17 +32,44 @@ namespace Ndk
|
||||
|
||||
void ResizeToContent() override;
|
||||
|
||||
inline const Nz::Color& GetColor() const;
|
||||
inline const Nz::Color& GetCornerColor() const;
|
||||
inline const Nz::Color& GetHoverColor() const;
|
||||
inline const Nz::Color& GetHoverCornerColor() const;
|
||||
inline const Nz::Color& GetPressColor() const;
|
||||
inline const Nz::Color& GetPressCornerColor() const;
|
||||
|
||||
inline const Nz::TextureRef& GetTexture() const;
|
||||
inline const Nz::TextureRef& GetHoverTexture() const;
|
||||
inline const Nz::TextureRef& GetPressTexture() const;
|
||||
|
||||
inline void SetColor(const Nz::Color& color, const Nz::Color& cornerColor);
|
||||
inline void SetHoverColor(const Nz::Color& color, const Nz::Color& cornerColor);
|
||||
inline void SetPressColor(const Nz::Color& color, const Nz::Color& cornerColor);
|
||||
|
||||
inline void SetTexture(const Nz::TextureRef& texture);
|
||||
inline void SetHoverTexture(const Nz::TextureRef& texture);
|
||||
inline void SetPressTexture(const Nz::TextureRef& texture);
|
||||
|
||||
inline void UpdateText(const Nz::AbstractTextDrawer& drawer);
|
||||
|
||||
ButtonWidget& operator=(const ButtonWidget&) = delete;
|
||||
ButtonWidget& operator=(ButtonWidget&&) = default;
|
||||
|
||||
static const Nz::Color& GetDefaultColor();
|
||||
static const Nz::Color& GetDefaultCornerColor();
|
||||
static const Nz::Color& GetDefaultHoverColor();
|
||||
static const Nz::Color& GetDefaultHoverCornerColor();
|
||||
static const Nz::Color& GetDefaultPressColor();
|
||||
static const Nz::Color& GetDefaultPressCornerColor();
|
||||
|
||||
NazaraSignal(OnButtonTrigger, const ButtonWidget* /*button*/);
|
||||
|
||||
private:
|
||||
void Layout() override;
|
||||
|
||||
void OnMouseEnter() override;
|
||||
void OnMouseButtonPress(int x, int y, Nz::Mouse::Button button) override;
|
||||
void OnMouseButtonRelease(int x, int y, Nz::Mouse::Button button) override;
|
||||
void OnMouseExit() override;
|
||||
|
||||
@@ -47,6 +77,24 @@ namespace Ndk
|
||||
EntityHandle m_gradientEntity;
|
||||
Nz::SpriteRef m_gradientSprite;
|
||||
Nz::TextSpriteRef m_textSprite;
|
||||
|
||||
Nz::Color m_color;
|
||||
Nz::Color m_cornerColor;
|
||||
Nz::Color m_hoverColor;
|
||||
Nz::Color m_hoverCornerColor;
|
||||
Nz::Color m_pressColor;
|
||||
Nz::Color m_pressCornerColor;
|
||||
|
||||
Nz::TextureRef m_texture;
|
||||
Nz::TextureRef m_hoverTexture;
|
||||
Nz::TextureRef m_pressTexture;
|
||||
|
||||
static Nz::Color s_color;
|
||||
static Nz::Color s_cornerColor;
|
||||
static Nz::Color s_hoverColor;
|
||||
static Nz::Color s_hoverCornerColor;
|
||||
static Nz::Color s_pressColor;
|
||||
static Nz::Color s_pressCornerColor;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,93 @@
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
inline const Nz::Color& ButtonWidget::GetColor() const
|
||||
{
|
||||
return m_color;
|
||||
}
|
||||
|
||||
inline const Nz::Color& ButtonWidget::GetCornerColor() const
|
||||
{
|
||||
return m_cornerColor;
|
||||
}
|
||||
|
||||
inline const Nz::Color& ButtonWidget::GetHoverColor() const
|
||||
{
|
||||
return m_hoverColor;
|
||||
}
|
||||
|
||||
inline const Nz::Color& ButtonWidget::GetHoverCornerColor() const
|
||||
{
|
||||
return m_hoverCornerColor;
|
||||
}
|
||||
|
||||
inline const Nz::Color& ButtonWidget::GetPressColor() const
|
||||
{
|
||||
return m_pressColor;
|
||||
}
|
||||
|
||||
inline const Nz::Color& ButtonWidget::GetPressCornerColor() const
|
||||
{
|
||||
return m_pressCornerColor;
|
||||
}
|
||||
|
||||
inline const Nz::TextureRef& ButtonWidget::GetTexture() const
|
||||
{
|
||||
return m_texture;
|
||||
}
|
||||
|
||||
inline const Nz::TextureRef& ButtonWidget::GetHoverTexture() const
|
||||
{
|
||||
return m_hoverTexture;
|
||||
}
|
||||
|
||||
inline const Nz::TextureRef& ButtonWidget::GetPressTexture() const
|
||||
{
|
||||
return m_pressTexture;
|
||||
}
|
||||
|
||||
inline void ButtonWidget::SetColor(const Nz::Color& color, const Nz::Color& cornerColor)
|
||||
{
|
||||
m_color = color;
|
||||
m_cornerColor = cornerColor;
|
||||
|
||||
m_gradientSprite->SetColor(m_color);
|
||||
m_gradientSprite->SetCornerColor(Nz::RectCorner_LeftBottom, m_cornerColor);
|
||||
m_gradientSprite->SetCornerColor(Nz::RectCorner_RightBottom, m_cornerColor);
|
||||
}
|
||||
|
||||
inline void ButtonWidget::SetHoverColor(const Nz::Color& color, const Nz::Color& cornerColor)
|
||||
{
|
||||
m_hoverColor = color;
|
||||
m_hoverCornerColor = cornerColor;
|
||||
}
|
||||
|
||||
inline void ButtonWidget::SetPressColor(const Nz::Color& color, const Nz::Color& cornerColor)
|
||||
{
|
||||
m_pressColor = color;
|
||||
m_pressCornerColor = cornerColor;
|
||||
}
|
||||
|
||||
inline void ButtonWidget::SetTexture(const Nz::TextureRef& texture)
|
||||
{
|
||||
m_texture = texture;
|
||||
m_gradientSprite->SetTexture(m_texture);
|
||||
}
|
||||
|
||||
inline void ButtonWidget::SetHoverTexture(const Nz::TextureRef& texture)
|
||||
{
|
||||
m_hoverTexture = texture;
|
||||
}
|
||||
|
||||
inline void ButtonWidget::SetPressTexture(const Nz::TextureRef& texture)
|
||||
{
|
||||
m_pressTexture = texture;
|
||||
}
|
||||
|
||||
inline void ButtonWidget::UpdateText(const Nz::AbstractTextDrawer& drawer)
|
||||
{
|
||||
m_textSprite->Update(drawer);
|
||||
|
||||
Layout();
|
||||
}
|
||||
}
|
||||
|
||||
105
SDK/include/NDK/Widgets/CheckboxWidget.hpp
Normal file
105
SDK/include/NDK/Widgets/CheckboxWidget.hpp
Normal file
@@ -0,0 +1,105 @@
|
||||
// Copyright (C) 2017 Samy Bensaid
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_WIDGETS_CHECKBOXWIDGET_HPP
|
||||
#define NDK_WIDGETS_CHECKBOXWIDGET_HPP
|
||||
|
||||
#include <NDK/Prerequesites.hpp>
|
||||
#include <NDK/BaseWidget.hpp>
|
||||
#include <NDK/Components/NodeComponent.hpp>
|
||||
#include <NDK/Widgets/Enums.hpp>
|
||||
#include <Nazara/Renderer/Texture.hpp>
|
||||
#include <Nazara/Graphics/Sprite.hpp>
|
||||
#include <Nazara/Graphics/TextSprite.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class AbstractTextDrawer;
|
||||
}
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API CheckboxWidget : public BaseWidget
|
||||
{
|
||||
friend class Sdk;
|
||||
|
||||
public:
|
||||
CheckboxWidget(BaseWidget* parent = nullptr);
|
||||
CheckboxWidget(const CheckboxWidget&) = delete;
|
||||
CheckboxWidget(CheckboxWidget&&) = default;
|
||||
~CheckboxWidget() = default;
|
||||
|
||||
//virtual CheckboxWidget* Clone() const = 0;
|
||||
|
||||
inline void EnableAdaptativeMargin(bool enable = true);
|
||||
inline void EnableCheckbox(bool enable = true);
|
||||
inline void EnableTristate(bool enable = true);
|
||||
|
||||
inline bool IsCheckboxEnabled() const;
|
||||
inline bool IsMarginAdaptative() const;
|
||||
inline bool IsTristateEnabled() const;
|
||||
|
||||
inline const Nz::Vector2f& GetCheckboxSize() const;
|
||||
inline Nz::Vector2f GetCheckboxBorderSize() const;
|
||||
inline CheckboxState GetState() const;
|
||||
inline float GetTextMargin() const;
|
||||
|
||||
inline void SetCheckboxSize(const Nz::Vector2f& size);
|
||||
CheckboxState SwitchToNextState();
|
||||
void SetState(CheckboxState state);
|
||||
inline void SetTextMargin(float margin);
|
||||
|
||||
void ResizeToContent() override;
|
||||
inline void UpdateText(const Nz::AbstractTextDrawer& drawer);
|
||||
|
||||
|
||||
CheckboxWidget& operator=(const CheckboxWidget&) = delete;
|
||||
CheckboxWidget& operator=(CheckboxWidget&&) = default;
|
||||
|
||||
NazaraSignal(OnStateChanged, const CheckboxWidget* /*checkbox*/);
|
||||
|
||||
private:
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
void Layout() override;
|
||||
void UpdateCheckbox();
|
||||
|
||||
void OnMouseButtonRelease(int x, int y, Nz::Mouse::Button button) override;
|
||||
inline bool ContainsCheckbox(int x, int y) const;
|
||||
|
||||
|
||||
EntityHandle m_checkboxBorderEntity;
|
||||
EntityHandle m_checkboxBackgroundEntity;
|
||||
EntityHandle m_checkboxContentEntity;
|
||||
EntityHandle m_textEntity;
|
||||
|
||||
Nz::TextureRef m_checkMark;
|
||||
|
||||
Nz::SpriteRef m_checkboxContentSprite;
|
||||
Nz::SpriteRef m_checkboxBorderSprite;
|
||||
Nz::SpriteRef m_checkboxBackgroundSprite;
|
||||
Nz::TextSpriteRef m_textSprite;
|
||||
|
||||
static Nz::Color s_backgroundColor;
|
||||
static Nz::Color s_disabledBackgroundColor;
|
||||
static Nz::Color s_disabledBorderColor;
|
||||
static Nz::Color s_borderColor;
|
||||
|
||||
bool m_adaptativeMargin;
|
||||
bool m_checkboxEnabled;
|
||||
bool m_tristateEnabled;
|
||||
|
||||
static float s_borderScale;
|
||||
float m_textMargin;
|
||||
CheckboxState m_state;
|
||||
};
|
||||
}
|
||||
|
||||
#include <NDK/Widgets/CheckboxWidget.inl>
|
||||
|
||||
#endif // NDK_WIDGETS_CHECKBOXWIDGET_HPP
|
||||
91
SDK/include/NDK/Widgets/CheckboxWidget.inl
Normal file
91
SDK/include/NDK/Widgets/CheckboxWidget.inl
Normal file
@@ -0,0 +1,91 @@
|
||||
// Copyright (C) 2017 Samy Bensaid
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
inline void CheckboxWidget::EnableAdaptativeMargin(bool enable)
|
||||
{
|
||||
m_adaptativeMargin = enable;
|
||||
Layout();
|
||||
}
|
||||
|
||||
inline void CheckboxWidget::EnableCheckbox(bool enable)
|
||||
{
|
||||
m_checkboxEnabled = enable;
|
||||
UpdateCheckbox();
|
||||
}
|
||||
|
||||
inline void CheckboxWidget::EnableTristate(bool enable)
|
||||
{
|
||||
m_tristateEnabled = enable;
|
||||
|
||||
if (m_tristateEnabled && GetState() == CheckboxState_Tristate)
|
||||
SetState(CheckboxState_Unchecked);
|
||||
}
|
||||
|
||||
inline bool CheckboxWidget::IsCheckboxEnabled() const
|
||||
{
|
||||
return m_checkboxEnabled;
|
||||
}
|
||||
|
||||
inline bool CheckboxWidget::IsMarginAdaptative() const
|
||||
{
|
||||
return m_adaptativeMargin;
|
||||
}
|
||||
|
||||
inline bool CheckboxWidget::IsTristateEnabled() const
|
||||
{
|
||||
return m_tristateEnabled;
|
||||
}
|
||||
|
||||
inline const Nz::Vector2f& CheckboxWidget::GetCheckboxSize() const
|
||||
{
|
||||
return m_checkboxBorderSprite->GetSize();
|
||||
}
|
||||
|
||||
inline Nz::Vector2f CheckboxWidget::GetCheckboxBorderSize() const
|
||||
{
|
||||
return GetCheckboxSize() / s_borderScale;
|
||||
}
|
||||
|
||||
inline CheckboxState CheckboxWidget::GetState() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
inline float CheckboxWidget::GetTextMargin() const
|
||||
{
|
||||
return m_textMargin;
|
||||
}
|
||||
|
||||
inline void CheckboxWidget::SetCheckboxSize(const Nz::Vector2f& size)
|
||||
{
|
||||
m_checkboxBorderSprite->SetSize(size);
|
||||
m_checkboxBackgroundSprite->SetSize(size - GetCheckboxBorderSize() * 2.f);
|
||||
m_checkboxContentSprite->SetSize(GetCheckboxSize() - GetCheckboxBorderSize() * 2.f - Nz::Vector2f { 4.f, 4.f });
|
||||
|
||||
Layout();
|
||||
}
|
||||
|
||||
inline void CheckboxWidget::SetTextMargin(float margin)
|
||||
{
|
||||
m_textMargin = margin;
|
||||
Layout();
|
||||
}
|
||||
|
||||
inline void CheckboxWidget::UpdateText(const Nz::AbstractTextDrawer& drawer)
|
||||
{
|
||||
m_textSprite->Update(drawer);
|
||||
Layout();
|
||||
}
|
||||
|
||||
inline bool CheckboxWidget::ContainsCheckbox(int x, int y) const
|
||||
{
|
||||
Nz::Vector2f checkboxSize = GetCheckboxSize();
|
||||
Nz::Vector3f pos = m_checkboxBorderEntity->GetComponent<NodeComponent>().GetPosition(Nz::CoordSys_Local);
|
||||
|
||||
return x > pos.x && x < pos.x + checkboxSize.x &&
|
||||
y > pos.y && y < pos.y + checkboxSize.y;
|
||||
}
|
||||
}
|
||||
22
SDK/include/NDK/Widgets/Enums.hpp
Normal file
22
SDK/include/NDK/Widgets/Enums.hpp
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2017 Samy Bensaid
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_ENUMS_SDK_HPP
|
||||
#define NAZARA_ENUMS_SDK_HPP
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
enum CheckboxState
|
||||
{
|
||||
CheckboxState_Checked,
|
||||
CheckboxState_Tristate,
|
||||
CheckboxState_Unchecked,
|
||||
|
||||
CheckboxState_Max = CheckboxState_Unchecked
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_ENUMS_SDK_HPP
|
||||
@@ -9,13 +9,15 @@
|
||||
|
||||
#include <NDK/Prerequesites.hpp>
|
||||
#include <NDK/BaseWidget.hpp>
|
||||
#include <Nazara/Utility/AbstractTextDrawer.hpp>
|
||||
#include <Nazara/Graphics/TextSprite.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class AbstractTextDrawer;
|
||||
}
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class World;
|
||||
|
||||
class NDK_API LabelWidget : public BaseWidget
|
||||
{
|
||||
public:
|
||||
|
||||
103
SDK/include/NDK/Widgets/ProgressBarWidget.hpp
Normal file
103
SDK/include/NDK/Widgets/ProgressBarWidget.hpp
Normal file
@@ -0,0 +1,103 @@
|
||||
// Copyright (C) 2017 Samy Bensaid
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_WIDGETS_PROGRESSBARWIDGET_HPP
|
||||
#define NDK_WIDGETS_PROGRESSBARWIDGET_HPP
|
||||
|
||||
#include <NDK/Prerequesites.hpp>
|
||||
#include <NDK/BaseWidget.hpp>
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Graphics/Sprite.hpp>
|
||||
#include <Nazara/Graphics/TextSprite.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Renderer/Texture.hpp>
|
||||
#include <Nazara/Utility/SimpleTextDrawer.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API ProgressBarWidget : public BaseWidget
|
||||
{
|
||||
friend class Sdk;
|
||||
|
||||
public:
|
||||
ProgressBarWidget(BaseWidget* parent = nullptr);
|
||||
ProgressBarWidget(const ProgressBarWidget&) = delete;
|
||||
ProgressBarWidget(ProgressBarWidget&&) = default;
|
||||
~ProgressBarWidget() = default;
|
||||
|
||||
//virtual ProgressBarWidget* Clone() const = 0;
|
||||
|
||||
inline void EnableText(bool enable = true);
|
||||
inline void EnableBorder(bool enable = true);
|
||||
|
||||
inline bool IsTextEnabled() const;
|
||||
inline bool IsBorderEnabled() const;
|
||||
|
||||
|
||||
inline unsigned GetPercentageValue() const;
|
||||
inline Nz::Vector2f GetProgressBarSize() const;
|
||||
inline Nz::Vector2f GetProgressBarBorderSize() const;
|
||||
inline float GetTextMargin() const;
|
||||
|
||||
|
||||
inline const Nz::Color& GetBarBackgroundColor() const;
|
||||
inline const Nz::Color& GetBarBackgroundCornerColor() const;
|
||||
inline const Nz::Color& GetBarColor() const;
|
||||
inline const Nz::Color& GetBarCornerColor() const;
|
||||
|
||||
inline const Nz::TextureRef& GetBarBackgroundTexture() const;
|
||||
inline const Nz::TextureRef& GetBarTexture() const;
|
||||
|
||||
static const Nz::Color& GetDefaultBarColor();
|
||||
static const Nz::Color& GetDefaultBarCornerColor();
|
||||
static const Nz::Color& GetDefaultBarBackgroundColor();
|
||||
static const Nz::Color& GetDefaultBarBackgroundCornerColor();
|
||||
|
||||
|
||||
inline void SetBarBackgroundColor(const Nz::Color& globalColor, const Nz::Color& cornerColor);
|
||||
inline void SetBarBackgroundTexture(Nz::TextureRef texture, bool resetColors = true);
|
||||
inline void SetBarColor(const Nz::Color& globalColor, const Nz::Color& cornerColor);
|
||||
inline void SetBarTexture(Nz::TextureRef texture, bool resetColors = true);
|
||||
|
||||
|
||||
inline void SetPercentageValue(unsigned percentage);
|
||||
inline void SetTextMargin(float margin);
|
||||
inline void SetTextColor(const Nz::Color& color);
|
||||
|
||||
inline void ResizeToContent() override {}
|
||||
|
||||
NazaraSignal(OnValueChanged, const ProgressBarWidget* /*progressBar*/);
|
||||
|
||||
private:
|
||||
void Layout() override;
|
||||
inline void UpdateText();
|
||||
|
||||
|
||||
EntityHandle m_borderEntity;
|
||||
EntityHandle m_barEntity;
|
||||
EntityHandle m_textEntity;
|
||||
|
||||
static Nz::Color s_borderColor;
|
||||
static Nz::Color s_barBackgroundColor;
|
||||
static Nz::Color s_barBackgroundCornerColor;
|
||||
static Nz::Color s_barColor;
|
||||
static Nz::Color s_barCornerColor;
|
||||
Nz::Color m_textColor;
|
||||
|
||||
Nz::SpriteRef m_borderSprite;
|
||||
Nz::SpriteRef m_barBackgroundSprite;
|
||||
Nz::SpriteRef m_barSprite;
|
||||
Nz::TextSpriteRef m_textSprite;
|
||||
|
||||
static float s_borderScale;
|
||||
float m_textMargin;
|
||||
unsigned m_value;
|
||||
};
|
||||
}
|
||||
|
||||
#include <NDK/Widgets/ProgressBarWidget.inl>
|
||||
|
||||
#endif // NDK_WIDGETS_PROGRESSBARWIDGET_HPP
|
||||
156
SDK/include/NDK/Widgets/ProgressBarWidget.inl
Normal file
156
SDK/include/NDK/Widgets/ProgressBarWidget.inl
Normal file
@@ -0,0 +1,156 @@
|
||||
// Copyright (C) 2017 Samy Bensaid
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
inline void ProgressBarWidget::EnableText(bool enable)
|
||||
{
|
||||
m_textEntity->Enable(enable);
|
||||
Layout();
|
||||
}
|
||||
|
||||
inline void ProgressBarWidget::EnableBorder(bool enable)
|
||||
{
|
||||
m_borderEntity->Enable(enable);
|
||||
}
|
||||
|
||||
inline bool ProgressBarWidget::IsTextEnabled() const
|
||||
{
|
||||
return m_textEntity->IsEnabled();
|
||||
}
|
||||
|
||||
inline bool ProgressBarWidget::IsBorderEnabled() const
|
||||
{
|
||||
return m_borderEntity->IsEnabled();
|
||||
}
|
||||
|
||||
|
||||
inline unsigned ProgressBarWidget::GetPercentageValue() const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
inline Nz::Vector2f ProgressBarWidget::GetProgressBarSize() const
|
||||
{
|
||||
Nz::Vector3f progressBarSize = m_borderSprite->GetBoundingVolume().obb.localBox.GetLengths();
|
||||
|
||||
if (IsTextEnabled())
|
||||
{
|
||||
Nz::Vector3f textSize = m_textSprite->GetBoundingVolume().obb.localBox.GetLengths();
|
||||
progressBarSize -= { textSize.x + m_textMargin, 0.f, 0.f };
|
||||
}
|
||||
|
||||
return { progressBarSize.x, progressBarSize.y };
|
||||
}
|
||||
|
||||
inline Nz::Vector2f ProgressBarWidget::GetProgressBarBorderSize() const
|
||||
{
|
||||
Nz::Vector2f barSize = GetProgressBarSize();
|
||||
return { barSize.y / s_borderScale, barSize.y / s_borderScale };
|
||||
}
|
||||
|
||||
inline float ProgressBarWidget::GetTextMargin() const
|
||||
{
|
||||
return m_textMargin;
|
||||
}
|
||||
|
||||
|
||||
inline const Nz::Color& ProgressBarWidget::GetBarBackgroundColor() const
|
||||
{
|
||||
return m_barBackgroundSprite->GetColor();
|
||||
}
|
||||
|
||||
inline const Nz::Color& ProgressBarWidget::GetBarBackgroundCornerColor() const
|
||||
{
|
||||
return m_barBackgroundSprite->GetCornerColor(Nz::RectCorner_LeftTop);
|
||||
}
|
||||
|
||||
inline const Nz::Color& ProgressBarWidget::GetBarColor() const
|
||||
{
|
||||
return m_barSprite->GetColor();
|
||||
}
|
||||
|
||||
inline const Nz::Color& ProgressBarWidget::GetBarCornerColor() const
|
||||
{
|
||||
return m_barSprite->GetCornerColor(Nz::RectCorner_LeftTop);
|
||||
}
|
||||
|
||||
|
||||
inline const Nz::TextureRef& ProgressBarWidget::GetBarBackgroundTexture() const
|
||||
{
|
||||
return m_barBackgroundSprite->GetMaterial()->GetDiffuseMap();
|
||||
}
|
||||
|
||||
inline const Nz::TextureRef& ProgressBarWidget::GetBarTexture() const
|
||||
{
|
||||
return m_barSprite->GetMaterial()->GetDiffuseMap();
|
||||
}
|
||||
|
||||
|
||||
inline void ProgressBarWidget::SetBarBackgroundColor(const Nz::Color& globalColor, const Nz::Color& cornerColor)
|
||||
{
|
||||
m_barBackgroundSprite->SetColor(globalColor);
|
||||
m_barBackgroundSprite->SetCornerColor(Nz::RectCorner_LeftTop, cornerColor);
|
||||
m_barBackgroundSprite->SetCornerColor(Nz::RectCorner_RightTop, cornerColor);
|
||||
m_barBackgroundSprite->SetCornerColor(Nz::RectCorner_LeftBottom, globalColor);
|
||||
m_barBackgroundSprite->SetCornerColor(Nz::RectCorner_RightBottom, globalColor);
|
||||
}
|
||||
|
||||
inline void ProgressBarWidget::SetBarBackgroundTexture(Nz::TextureRef texture, bool resetColors)
|
||||
{
|
||||
m_barBackgroundSprite->SetTexture(texture, false);
|
||||
|
||||
if (resetColors)
|
||||
SetBarBackgroundColor(Nz::Color::White, Nz::Color::White);
|
||||
}
|
||||
|
||||
inline void ProgressBarWidget::SetBarColor(const Nz::Color& globalColor, const Nz::Color& cornerColor)
|
||||
{
|
||||
m_barSprite->SetColor(globalColor);
|
||||
m_barSprite->SetCornerColor(Nz::RectCorner_LeftTop, cornerColor);
|
||||
m_barSprite->SetCornerColor(Nz::RectCorner_RightTop, cornerColor);
|
||||
m_barSprite->SetCornerColor(Nz::RectCorner_LeftBottom, globalColor);
|
||||
m_barSprite->SetCornerColor(Nz::RectCorner_RightBottom, globalColor);
|
||||
}
|
||||
|
||||
inline void ProgressBarWidget::SetBarTexture(Nz::TextureRef texture, bool resetColors)
|
||||
{
|
||||
m_barSprite->SetTexture(texture, false);
|
||||
|
||||
if (resetColors)
|
||||
SetBarColor(Nz::Color::White, Nz::Color::White);
|
||||
}
|
||||
|
||||
|
||||
inline void ProgressBarWidget::SetPercentageValue(unsigned percentage)
|
||||
{
|
||||
m_value = percentage;
|
||||
OnValueChanged(this);
|
||||
Layout();
|
||||
}
|
||||
|
||||
inline void ProgressBarWidget::SetTextMargin(float margin)
|
||||
{
|
||||
m_textMargin = margin;
|
||||
|
||||
if (IsTextEnabled())
|
||||
Layout();
|
||||
}
|
||||
|
||||
inline void ProgressBarWidget::SetTextColor(const Nz::Color& color)
|
||||
{
|
||||
m_textColor = color;
|
||||
UpdateText();
|
||||
}
|
||||
|
||||
inline void ProgressBarWidget::UpdateText()
|
||||
{
|
||||
if (IsTextEnabled())
|
||||
{
|
||||
Nz::Vector2f size = GetContentSize();
|
||||
m_textSprite->Update(Nz::SimpleTextDrawer::Draw(Nz::String::Number(m_value).Append('%'),
|
||||
static_cast<unsigned>(std::min(size.x, size.y) / 2.f), 0u, m_textColor));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,8 +14,6 @@
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class World;
|
||||
|
||||
class NDK_API TextAreaWidget : public BaseWidget
|
||||
{
|
||||
public:
|
||||
@@ -32,7 +30,8 @@ namespace Ndk
|
||||
|
||||
inline void EnableMultiline(bool enable = true);
|
||||
|
||||
inline std::size_t GetCursorPosition() const;
|
||||
inline const Nz::Vector2ui& GetCursorPosition() const;
|
||||
inline std::size_t GetGlyphUnderCursor() const;
|
||||
inline std::size_t GetLineCount() const;
|
||||
inline const Nz::String& GetText() const;
|
||||
inline const Nz::Color& GetTextColor() const;
|
||||
@@ -43,10 +42,12 @@ namespace Ndk
|
||||
inline bool IsReadOnly() const;
|
||||
|
||||
inline void MoveCursor(int offset);
|
||||
inline void MoveCursor(const Nz::Vector2i& offset);
|
||||
|
||||
void ResizeToContent() override;
|
||||
|
||||
inline void SetCursorPosition(std::size_t cursorPosition);
|
||||
inline void SetCursorPosition(std::size_t glyphIndex);
|
||||
inline void SetCursorPosition(Nz::Vector2ui cursorPosition);
|
||||
inline void SetReadOnly(bool readOnly = true);
|
||||
inline void SetText(const Nz::String& text);
|
||||
inline void SetTextColor(const Nz::Color& text);
|
||||
@@ -82,7 +83,8 @@ namespace Ndk
|
||||
Nz::SimpleTextDrawer m_drawer;
|
||||
Nz::SpriteRef m_cursorSprite;
|
||||
Nz::TextSpriteRef m_textSprite;
|
||||
std::size_t m_cursorPosition;
|
||||
Nz::Vector2ui m_cursorPosition;
|
||||
std::size_t m_cursorGlyph;
|
||||
bool m_multiLineEnabled;
|
||||
bool m_readOnly;
|
||||
};
|
||||
|
||||
@@ -20,11 +20,16 @@ namespace Ndk
|
||||
m_multiLineEnabled = enable;
|
||||
}
|
||||
|
||||
inline std::size_t TextAreaWidget::GetCursorPosition() const
|
||||
inline const Nz::Vector2ui& TextAreaWidget::GetCursorPosition() const
|
||||
{
|
||||
return m_cursorPosition;
|
||||
}
|
||||
|
||||
inline std::size_t Ndk::TextAreaWidget::GetGlyphUnderCursor() const
|
||||
{
|
||||
return m_cursorGlyph;
|
||||
}
|
||||
|
||||
inline std::size_t TextAreaWidget::GetLineCount() const
|
||||
{
|
||||
return m_drawer.GetLineCount();
|
||||
@@ -53,22 +58,84 @@ namespace Ndk
|
||||
inline void TextAreaWidget::MoveCursor(int offset)
|
||||
{
|
||||
if (offset >= 0)
|
||||
SetCursorPosition(m_cursorPosition += static_cast<std::size_t>(offset));
|
||||
SetCursorPosition(m_cursorGlyph + static_cast<std::size_t>(offset));
|
||||
else
|
||||
{
|
||||
std::size_t nOffset = static_cast<std::size_t>(-offset);
|
||||
if (nOffset >= m_cursorPosition)
|
||||
if (nOffset >= m_cursorGlyph)
|
||||
SetCursorPosition(0);
|
||||
else
|
||||
SetCursorPosition(m_cursorPosition - nOffset);
|
||||
SetCursorPosition(m_cursorGlyph - nOffset);
|
||||
}
|
||||
}
|
||||
|
||||
inline void TextAreaWidget::SetCursorPosition(std::size_t cursorPosition)
|
||||
inline void TextAreaWidget::MoveCursor(const Nz::Vector2i& offset)
|
||||
{
|
||||
OnTextAreaCursorMove(this, &cursorPosition);
|
||||
auto BoundOffset = [] (unsigned int cursorPosition, int cursorOffset) -> unsigned int
|
||||
{
|
||||
if (cursorOffset >= 0)
|
||||
return cursorPosition + cursorOffset;
|
||||
else
|
||||
{
|
||||
unsigned int nOffset = static_cast<unsigned int>(-cursorOffset);
|
||||
if (nOffset >= cursorPosition)
|
||||
return 0;
|
||||
else
|
||||
return cursorPosition - nOffset;
|
||||
}
|
||||
};
|
||||
|
||||
m_cursorPosition = std::min(cursorPosition, m_drawer.GetGlyphCount());
|
||||
Nz::Vector2ui cursorPosition = m_cursorPosition;
|
||||
cursorPosition.x = BoundOffset(static_cast<unsigned int>(cursorPosition.x), offset.x);
|
||||
cursorPosition.y = BoundOffset(static_cast<unsigned int>(cursorPosition.y), offset.y);
|
||||
|
||||
SetCursorPosition(cursorPosition);
|
||||
}
|
||||
|
||||
inline void TextAreaWidget::SetCursorPosition(std::size_t glyphIndex)
|
||||
{
|
||||
OnTextAreaCursorMove(this, &glyphIndex);
|
||||
|
||||
m_cursorGlyph = std::min(glyphIndex, m_drawer.GetGlyphCount());
|
||||
|
||||
std::size_t lineCount = m_drawer.GetLineCount();
|
||||
std::size_t line = 0U;
|
||||
for (std::size_t i = line + 1; i < lineCount; ++i)
|
||||
{
|
||||
if (m_drawer.GetLine(i).glyphIndex > m_cursorGlyph)
|
||||
break;
|
||||
|
||||
line = i;
|
||||
}
|
||||
|
||||
const auto& lineInfo = m_drawer.GetLine(line);
|
||||
|
||||
m_cursorPosition.y = line;
|
||||
m_cursorPosition.x = m_cursorGlyph - lineInfo.glyphIndex;
|
||||
|
||||
RefreshCursor();
|
||||
}
|
||||
|
||||
inline void TextAreaWidget::SetCursorPosition(Nz::Vector2ui cursorPosition)
|
||||
{
|
||||
std::size_t lineCount = m_drawer.GetLineCount();
|
||||
if (cursorPosition.y >= lineCount)
|
||||
cursorPosition.y = static_cast<unsigned int>(lineCount - 1);
|
||||
|
||||
m_cursorPosition = cursorPosition;
|
||||
|
||||
const auto& lineInfo = m_drawer.GetLine(cursorPosition.y);
|
||||
if (cursorPosition.y + 1 < lineCount)
|
||||
{
|
||||
const auto& nextLineInfo = m_drawer.GetLine(cursorPosition.y + 1);
|
||||
cursorPosition.x = std::min(cursorPosition.x, static_cast<unsigned int>(nextLineInfo.glyphIndex - lineInfo.glyphIndex - 1));
|
||||
}
|
||||
|
||||
std::size_t glyphIndex = lineInfo.glyphIndex + cursorPosition.x;
|
||||
|
||||
OnTextAreaCursorMove(this, &glyphIndex);
|
||||
|
||||
m_cursorGlyph = std::min(glyphIndex, m_drawer.GetGlyphCount());
|
||||
|
||||
RefreshCursor();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
|
||||
@@ -314,7 +314,8 @@ namespace Ndk
|
||||
|
||||
m_systems = std::move(world.m_systems);
|
||||
for (const auto& systemPtr : m_systems)
|
||||
systemPtr->SetWorld(this);
|
||||
if (systemPtr)
|
||||
systemPtr->SetWorld(this);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user