Engine puzzle completed
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/ini_parser.hpp>
|
||||
|
||||
#include "../Common.h"
|
||||
#include "ResourceManager.h"
|
||||
|
||||
class ConfigFile : public Resource
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef Events_GamepadAxis_h__
|
||||
#define Events_GamepadAxis_h__
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
#include "EventBroker.h"
|
||||
|
||||
namespace Gamepad
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef Events_GamepadButton_h__
|
||||
#define Events_GamepadButton_h__
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
#include "EventBroker.h"
|
||||
|
||||
namespace Gamepad
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef Events_KeyDown_h__
|
||||
#define Events_KeyDown_h__
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
#include "EventBroker.h"
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef Events_KeyUp_h__
|
||||
#define Events_KeyUp_h__
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
#include "EventBroker.h"
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef Events_LockMouse_h__
|
||||
#define Events_LockMouse_h__
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
#include "EventBroker.h"
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef Events_MouseMove_h__
|
||||
#define Events_MouseMove_h__
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
#include "EventBroker.h"
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef Events_MousePress_h__
|
||||
#define Events_MousePress_h__
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
#include "EventBroker.h"
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef Events_MouseRelease_h__
|
||||
#define Events_MouseRelease_h__
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
#include "EventBroker.h"
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
@@ -3,16 +3,15 @@
|
||||
|
||||
#include <typeinfo>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <list>
|
||||
#include <tuple>
|
||||
|
||||
#include "../Common.h"
|
||||
#include "Event.h"
|
||||
|
||||
#define EVENT_SUBSCRIBE_MEMBER(relay, handler) \
|
||||
relay = decltype(relay)(std::bind(handler, this, std::placeholders::_1)); \
|
||||
EventBroker->Subscribe(relay);
|
||||
m_EventBroker->Subscribe(relay);
|
||||
|
||||
class EventBroker;
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#ifndef InputController_h__
|
||||
#define InputController_h__
|
||||
|
||||
#include <memory>
|
||||
#include "../Common.h"
|
||||
|
||||
#include "EventBroker.h"
|
||||
#include "EMouseMove.h"
|
||||
#include "Input/EInputCommand.h"
|
||||
#include "../Input/EInputCommand.h"
|
||||
|
||||
template <typename EventContext>
|
||||
class InputController
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
#define InputManager_h__
|
||||
|
||||
#include <array>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
#include "../Common.h"
|
||||
#include "EventBroker.h"
|
||||
#include "EKeyDown.h"
|
||||
#include "EKeyUp.h"
|
||||
#include "EMousePress.h"
|
||||
@@ -16,9 +18,9 @@
|
||||
class InputManager
|
||||
{
|
||||
public:
|
||||
InputManager(GLFWwindow* window, std::shared_ptr<::EventBroker> eventBroker)
|
||||
InputManager(GLFWwindow* window, EventBroker* eventBroker)
|
||||
: m_GLFWWindow(window)
|
||||
, EventBroker(eventBroker)
|
||||
, m_EventBroker(eventBroker)
|
||||
, m_CurrentKeyState()
|
||||
, m_LastKeyState()
|
||||
, m_CurrentMouseState()
|
||||
@@ -37,7 +39,7 @@ public:
|
||||
|
||||
private:
|
||||
GLFWwindow* m_GLFWWindow;
|
||||
std::shared_ptr<::EventBroker> EventBroker;
|
||||
EventBroker* m_EventBroker;
|
||||
|
||||
EventRelay<InputManager, Events::LockMouse> m_ELockMouse;
|
||||
bool OnLockMouse(const Events::LockMouse &event);
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
#ifndef ResourceManager_h__
|
||||
#define ResourceManager_h__
|
||||
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
#include <fstream>
|
||||
|
||||
#include "../Common.h"
|
||||
#include "Util/UnorderedMapPair.h"
|
||||
#include "Util/FileWatcher.h"
|
||||
|
||||
|
||||
@@ -1,13 +1,23 @@
|
||||
#ifndef BoostPathHash_h__
|
||||
#define BoostPathHash_h__
|
||||
|
||||
struct BoostPathHash
|
||||
namespace std
|
||||
{
|
||||
template <typename T>
|
||||
std::size_t operator()(const boost::filesystem::path& p) const
|
||||
template<> struct hash<boost::filesystem::path>
|
||||
{
|
||||
return boost::filesystem::hash_value(p);
|
||||
}
|
||||
};
|
||||
size_t operator()(const boost::filesystem::path& p) const
|
||||
{
|
||||
return boost::filesystem::hash_value(p);
|
||||
}
|
||||
};
|
||||
}
|
||||
//struct BoostPathHash
|
||||
//{
|
||||
//
|
||||
// template <typename T>
|
||||
// std::size_t operator()(const boost::filesystem::path& p) const
|
||||
// {
|
||||
// return boost::filesystem::hash_value(p);
|
||||
// }
|
||||
//};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -58,8 +58,8 @@ private:
|
||||
std::time_t Timestamp;
|
||||
};
|
||||
|
||||
std::unordered_map<boost::filesystem::path, FileEventCallback_t, BoostPathHash> m_FileCallbacks;
|
||||
std::unordered_map<boost::filesystem::path, FileInfo, BoostPathHash> m_FileInfo;
|
||||
std::unordered_map<boost::filesystem::path, FileEventCallback_t> m_FileCallbacks;
|
||||
std::unordered_map<boost::filesystem::path, FileInfo> m_FileInfo;
|
||||
boost::mutex m_Mutex;
|
||||
|
||||
FileInfo GetFileInfo(boost::filesystem::path path);
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
#ifndef Rectangle_h__
|
||||
#define Rectangle_h__
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
struct Rectangle
|
||||
{
|
||||
Rectangle()
|
||||
: X(0), Y(0), Width(0), Height(0) { }
|
||||
|
||||
Rectangle(int width, int height)
|
||||
: X(0), Y(0), Width(width), Height(height) { }
|
||||
|
||||
Rectangle(int x, int y, int width, int height)
|
||||
: X(x), Y(y), Width(width), Height(height) { }
|
||||
|
||||
/*Rectangle(const Rectangle &rect)
|
||||
: X(rect.X), Y(rect.Y), Width(rect.Width), Height(rect.Height) { }*/
|
||||
|
||||
int X;
|
||||
int Y;
|
||||
int Width;
|
||||
int Height;
|
||||
|
||||
virtual int Left() const { return X; }
|
||||
virtual void SetLeft(int left)
|
||||
{
|
||||
//Width += X - left;
|
||||
X = left;
|
||||
}
|
||||
virtual int Right() const { return X + Width; }
|
||||
virtual void SetRight(int right)
|
||||
{
|
||||
Width = right - X;
|
||||
}
|
||||
virtual int Top() const { return Y; }
|
||||
virtual void SetTop(int top)
|
||||
{
|
||||
//Height += Y - top;
|
||||
Y = top;
|
||||
}
|
||||
virtual int Bottom() const { return Y + Height; }
|
||||
virtual void SetBottom(int bottom)
|
||||
{
|
||||
Height = bottom - Y;
|
||||
}
|
||||
|
||||
Rectangle& operator+=(const Rectangle &rhs)
|
||||
{
|
||||
SetLeft(std::min(Left(), rhs.Left()));
|
||||
SetRight(std::max(Right(), rhs.Right()));
|
||||
SetTop(std::min(Top(), rhs.Top()));
|
||||
SetBottom(std::max(Bottom(), rhs.Bottom()));
|
||||
}
|
||||
|
||||
static bool Intersects(const Rectangle &r1, const Rectangle &r2)
|
||||
{
|
||||
return !(r2.Left() > r1.Right() || r2.Right() < r1.Left() || r2.Top() > r1.Bottom() || r2.Bottom() < r1.Top());
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator==(const Rectangle &r1, const Rectangle &r2)
|
||||
{
|
||||
return (r1.X == r2.X) && (r1.Y == r2.Y) && (r1.Width == r2.Width) && (r1.Height == r2.Height);
|
||||
}
|
||||
|
||||
inline bool operator!=(const Rectangle &lhs, const Rectangle &rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
inline bool operator<(const Rectangle &lhs, const Rectangle &rhs)
|
||||
{
|
||||
return (lhs.Width < rhs.Width) && (lhs.Height < rhs.Height);
|
||||
}
|
||||
|
||||
inline bool operator>(const Rectangle &lhs, const Rectangle &rhs)
|
||||
{
|
||||
return rhs < lhs;
|
||||
}
|
||||
|
||||
inline bool operator<=(const Rectangle &lhs, const Rectangle &rhs)
|
||||
{
|
||||
return !(lhs > rhs);
|
||||
}
|
||||
|
||||
inline bool operator>=(const Rectangle &lhs, const Rectangle &rhs)
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
|
||||
inline Rectangle operator+(Rectangle lhs, const Rectangle &rhs)
|
||||
{
|
||||
lhs += rhs;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
#endif // Util_Rectangle_h__
|
||||
Reference in New Issue
Block a user