And then Microsoft happened...
This commit is contained in:
+75
-75
@@ -1,75 +1,75 @@
|
|||||||
//#ifndef GUI_Frame_h__
|
#ifndef GUI_Frame_h__
|
||||||
//#define GUI_Frame_h__
|
#define GUI_Frame_h__
|
||||||
//
|
|
||||||
//#include <memory>
|
#include <memory>
|
||||||
//
|
|
||||||
//#include "Util/Rectangle.h"
|
#include "Util/Rectangle.h"
|
||||||
//#include "EventBroker.h"
|
#include "EventBroker.h"
|
||||||
//
|
|
||||||
//// HACK: Decouple renderer plz
|
// HACK: Decouple renderer plz
|
||||||
//#include "Renderer.h"
|
#include "Renderer.h"
|
||||||
//
|
|
||||||
//namespace GUI
|
namespace GUI
|
||||||
//{
|
{
|
||||||
//
|
|
||||||
//class Frame : public Rectangle
|
class Frame : public Rectangle
|
||||||
//{
|
{
|
||||||
//public:
|
public:
|
||||||
// enum class Anchor
|
enum class Anchor
|
||||||
// {
|
{
|
||||||
// Left,
|
Left,
|
||||||
// Right,
|
Right,
|
||||||
// Top,
|
Top,
|
||||||
// Bottom
|
Bottom
|
||||||
// };
|
};
|
||||||
//
|
|
||||||
// // Set up a base frame with an event broker
|
// Set up a base frame with an event broker
|
||||||
// Frame(std::shared_ptr<::EventBroker> eventBroker)
|
Frame(std::shared_ptr<::EventBroker> eventBroker)
|
||||||
// : EventBroker(eventBroker)
|
: EventBroker(eventBroker)
|
||||||
// , Rectangle()
|
, Rectangle()
|
||||||
// { Initialize(); }
|
{ Initialize(); }
|
||||||
// // Create a frame as a child
|
// Create a frame as a child
|
||||||
// Frame(std::shared_ptr<Frame> parent)
|
Frame(std::shared_ptr<Frame> parent)
|
||||||
// : Rectangle(static_cast<Rectangle>(*parent)) // Clone parent rectangle using copy constructor
|
: Rectangle(static_cast<Rectangle>(*parent)) // Clone parent rectangle using copy constructor
|
||||||
// { SetParent(parent); Initialize(); }
|
{ SetParent(parent); Initialize(); }
|
||||||
//
|
|
||||||
// virtual void Initialize() { }
|
virtual void Initialize() { }
|
||||||
// std::shared_ptr<Frame> Parent() const { return m_Parent; }
|
std::shared_ptr<Frame> Parent() const { return m_Parent; }
|
||||||
// void SetParent(std::shared_ptr<Frame> parent)
|
void SetParent(std::shared_ptr<Frame> parent)
|
||||||
// {
|
{
|
||||||
// parent->AddChild(std::shared_ptr<Frame>(this));
|
parent->AddChild(std::shared_ptr<Frame>(this));
|
||||||
// m_Parent = parent;
|
m_Parent = parent;
|
||||||
// EventBroker = parent->EventBroker;
|
EventBroker = parent->EventBroker;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// void AddChild(std::shared_ptr<Frame> child)
|
void AddChild(std::shared_ptr<Frame> child)
|
||||||
// {
|
{
|
||||||
// m_Children.push_back(child);
|
m_Children.push_back(child);
|
||||||
// if (m_Parent != nullptr)
|
if (m_Parent != nullptr)
|
||||||
// {
|
{
|
||||||
// m_Parent->AddChild(child);
|
m_Parent->AddChild(child);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// typedef std::list<std::shared_ptr<Frame>>::const_iterator FrameChildrenIterator;
|
typedef std::list<std::shared_ptr<Frame>>::const_iterator FrameChildrenIterator;
|
||||||
// FrameChildrenIterator begin()
|
FrameChildrenIterator begin()
|
||||||
// {
|
{
|
||||||
// return m_Children.begin();
|
return m_Children.begin();
|
||||||
// }
|
}
|
||||||
// FrameChildrenIterator end()
|
FrameChildrenIterator end()
|
||||||
// {
|
{
|
||||||
// return m_Children.end();
|
return m_Children.end();
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// virtual void Update(double dt) { }
|
virtual void Update(double dt) { }
|
||||||
// virtual void Draw(Renderer* renderer) { }
|
virtual void Draw(Renderer* renderer) { }
|
||||||
//
|
|
||||||
//protected:
|
protected:
|
||||||
// std::shared_ptr<::EventBroker> EventBroker;
|
std::shared_ptr<::EventBroker> EventBroker;
|
||||||
// std::shared_ptr<Frame> m_Parent;
|
std::shared_ptr<Frame> m_Parent;
|
||||||
// std::list<std::shared_ptr<Frame>> m_Children;
|
std::list<std::shared_ptr<Frame>> m_Children;
|
||||||
//};
|
};
|
||||||
//
|
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
//#endif // GUI_Frame_h__
|
#endif // GUI_Frame_h__
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "PrecompiledHeader.h"
|
#include "PrecompiledHeader.h"
|
||||||
#include "InputManager.h"
|
#include "InputManager.h"
|
||||||
|
#include <XInput.h>
|
||||||
|
|
||||||
void InputManager::Initialize()
|
void InputManager::Initialize()
|
||||||
{
|
{
|
||||||
@@ -97,9 +98,9 @@ void InputManager::Update(double dt)
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// Xbox360 controller
|
// Xbox360 controller
|
||||||
using namespace Windows;
|
//using namespace ;
|
||||||
DWORD dwResult;
|
DWORD dwResult;
|
||||||
for (int i = 0; i < XUSER_MAX_COUNT; i++)
|
for (int i = 0; i < MAX_GAMEPADS; i++)
|
||||||
{
|
{
|
||||||
XINPUT_STATE state = { 0 };
|
XINPUT_STATE state = { 0 };
|
||||||
// Simply get the state of the controller from XInput.
|
// Simply get the state of the controller from XInput.
|
||||||
|
|||||||
+6
-11
@@ -3,13 +3,6 @@
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
namespace Windows
|
|
||||||
{
|
|
||||||
#include <Xinput.h>
|
|
||||||
#undef min
|
|
||||||
#undef max
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "EventBroker.h"
|
#include "EventBroker.h"
|
||||||
#include "Events/KeyDown.h"
|
#include "Events/KeyDown.h"
|
||||||
#include "Events/KeyUp.h"
|
#include "Events/KeyUp.h"
|
||||||
@@ -36,6 +29,8 @@ public:
|
|||||||
|
|
||||||
void Initialize();
|
void Initialize();
|
||||||
|
|
||||||
|
static const short MAX_GAMEPADS = 4;
|
||||||
|
|
||||||
void Update(double dt);
|
void Update(double dt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -47,11 +42,11 @@ private:
|
|||||||
std::array<int, GLFW_MOUSE_BUTTON_LAST+1> m_CurrentMouseState;
|
std::array<int, GLFW_MOUSE_BUTTON_LAST+1> m_CurrentMouseState;
|
||||||
std::array<int, GLFW_MOUSE_BUTTON_LAST+1> m_LastMouseState;
|
std::array<int, GLFW_MOUSE_BUTTON_LAST+1> m_LastMouseState;
|
||||||
typedef std::array<float, static_cast<int>(Gamepad::Axis::LAST) + 1> GamepadAxisState;
|
typedef std::array<float, static_cast<int>(Gamepad::Axis::LAST) + 1> GamepadAxisState;
|
||||||
std::array<GamepadAxisState, XUSER_MAX_COUNT> m_CurrentGamepadAxisState;
|
std::array<GamepadAxisState, MAX_GAMEPADS> m_CurrentGamepadAxisState;
|
||||||
std::array<GamepadAxisState, XUSER_MAX_COUNT> m_LastGamepadAxisState;
|
std::array<GamepadAxisState, MAX_GAMEPADS> m_LastGamepadAxisState;
|
||||||
typedef std::array<bool, static_cast<int>(Gamepad::Button::LAST) + 1> GamepadButtonState;
|
typedef std::array<bool, static_cast<int>(Gamepad::Button::LAST) + 1> GamepadButtonState;
|
||||||
std::array<GamepadButtonState, XUSER_MAX_COUNT> m_CurrentGamepadButtonState;
|
std::array<GamepadButtonState, MAX_GAMEPADS> m_CurrentGamepadButtonState;
|
||||||
std::array<GamepadButtonState, XUSER_MAX_COUNT> m_LastGamepadButtonState;
|
std::array<GamepadButtonState, MAX_GAMEPADS> m_LastGamepadButtonState;
|
||||||
|
|
||||||
double m_CurrentMouseX, m_CurrentMouseY;
|
double m_CurrentMouseX, m_CurrentMouseY;
|
||||||
double m_LastMouseX, m_LastMouseY;
|
double m_LastMouseX, m_LastMouseY;
|
||||||
|
|||||||
+95
-95
@@ -1,95 +1,95 @@
|
|||||||
//#ifndef Util_Rectangle_h__
|
#ifndef Util_Rectangle_h__
|
||||||
//#define Util_Rectangle_h__
|
#define Util_Rectangle_h__
|
||||||
//
|
|
||||||
//#include <algorithm>
|
#include <algorithm>
|
||||||
//
|
|
||||||
//struct Rectangle
|
struct Rectangle
|
||||||
//{
|
{
|
||||||
// Rectangle()
|
Rectangle()
|
||||||
// : X(0), Y(0), Width(0), Height(0) { }
|
: X(0), Y(0), Width(0), Height(0) { }
|
||||||
//
|
|
||||||
// Rectangle(int x, int y, int width = 0, int height = 0)
|
Rectangle(int x, int y, int width = 0, int height = 0)
|
||||||
// : X(x), Y(y), Width(width), Height(height) { }
|
: X(x), Y(y), Width(width), Height(height) { }
|
||||||
//
|
|
||||||
// /*Rectangle(const Rectangle &rect)
|
/*Rectangle(const Rectangle &rect)
|
||||||
// : X(rect.X), Y(rect.Y), Width(rect.Width), Height(rect.Height) { }*/
|
: X(rect.X), Y(rect.Y), Width(rect.Width), Height(rect.Height) { }*/
|
||||||
//
|
|
||||||
// int X;
|
int X;
|
||||||
// int Y;
|
int Y;
|
||||||
// int Width;
|
int Width;
|
||||||
// int Height;
|
int Height;
|
||||||
//
|
|
||||||
// const int& GetLeft() const { return X; }
|
const int& GetLeft() const { return X; }
|
||||||
// void SetLeft(int left)
|
void SetLeft(int left)
|
||||||
// {
|
{
|
||||||
// Width += X - left;
|
Width += X - left;
|
||||||
// X = left;
|
X = left;
|
||||||
// }
|
}
|
||||||
// int GetRight() const { return X + Width; }
|
int GetRight() const { return X + Width; }
|
||||||
// void SetRight(int right)
|
void SetRight(int right)
|
||||||
// {
|
{
|
||||||
// Width = right - X;
|
Width = right - X;
|
||||||
// }
|
}
|
||||||
// const int& GetTop() const { return Y; }
|
const int& GetTop() const { return Y; }
|
||||||
// void SetTop(int top)
|
void SetTop(int top)
|
||||||
// {
|
{
|
||||||
// Height += Y - top;
|
Height += Y - top;
|
||||||
// Y = top;
|
Y = top;
|
||||||
// }
|
}
|
||||||
// int GetBottom() const { return Y + Height; }
|
int GetBottom() const { return Y + Height; }
|
||||||
// int SetBottom(int bottom)
|
int SetBottom(int bottom)
|
||||||
// {
|
{
|
||||||
// Height = bottom - Y;
|
Height = bottom - Y;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// Rectangle& operator+=(const Rectangle &rhs)
|
Rectangle& operator+=(const Rectangle &rhs)
|
||||||
// {
|
{
|
||||||
// SetLeft(std::min(GetLeft(), rhs.GetLeft()));
|
SetLeft(std::min(GetLeft(), rhs.GetLeft()));
|
||||||
// SetRight(std::max(GetRight(), rhs.GetRight()));
|
SetRight(std::max(GetRight(), rhs.GetRight()));
|
||||||
// SetTop(std::min(GetTop(), rhs.GetTop()));
|
SetTop(std::min(GetTop(), rhs.GetTop()));
|
||||||
// SetBottom(std::max(GetBottom(), rhs.GetBottom()));
|
SetBottom(std::max(GetBottom(), rhs.GetBottom()));
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// static bool Intersects(const Rectangle &r1, const Rectangle &r2)
|
static bool Intersects(const Rectangle &r1, const Rectangle &r2)
|
||||||
// {
|
{
|
||||||
// return !(r2.GetLeft() > r1.GetRight() || r2.GetRight() < r1.GetLeft() || r2.GetTop() > r1.GetBottom() || r2.GetBottom() < r1.GetTop());
|
return !(r2.GetLeft() > r1.GetRight() || r2.GetRight() < r1.GetLeft() || r2.GetTop() > r1.GetBottom() || r2.GetBottom() < r1.GetTop());
|
||||||
// }
|
}
|
||||||
//};
|
};
|
||||||
//
|
|
||||||
//inline bool operator==(const Rectangle &r1, const Rectangle &r2)
|
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);
|
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)
|
inline bool operator!=(const Rectangle &lhs, const Rectangle &rhs)
|
||||||
//{
|
{
|
||||||
// return !(lhs == rhs);
|
return !(lhs == rhs);
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
//inline bool operator<(const Rectangle &lhs, const Rectangle &rhs)
|
inline bool operator<(const Rectangle &lhs, const Rectangle &rhs)
|
||||||
//{
|
{
|
||||||
// return (lhs.Width < rhs.Width) && (lhs.Height < rhs.Height);
|
return (lhs.Width < rhs.Width) && (lhs.Height < rhs.Height);
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
//inline bool operator>(const Rectangle &lhs, const Rectangle &rhs)
|
inline bool operator>(const Rectangle &lhs, const Rectangle &rhs)
|
||||||
//{
|
{
|
||||||
// return rhs < lhs;
|
return rhs < lhs;
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
//inline bool operator<=(const Rectangle &lhs, const Rectangle &rhs)
|
inline bool operator<=(const Rectangle &lhs, const Rectangle &rhs)
|
||||||
//{
|
{
|
||||||
// return !(lhs > rhs);
|
return !(lhs > rhs);
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
//inline bool operator>=(const Rectangle &lhs, const Rectangle &rhs)
|
inline bool operator>=(const Rectangle &lhs, const Rectangle &rhs)
|
||||||
//{
|
{
|
||||||
// return !(lhs < rhs);
|
return !(lhs < rhs);
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
//inline Rectangle operator+(Rectangle lhs, const Rectangle &rhs)
|
inline Rectangle operator+(Rectangle lhs, const Rectangle &rhs)
|
||||||
//{
|
{
|
||||||
// lhs += rhs;
|
lhs += rhs;
|
||||||
// return lhs;
|
return lhs;
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
//#endif // Util_Rectangle_h__
|
#endif // Util_Rectangle_h__
|
||||||
|
|||||||
Reference in New Issue
Block a user