Merge branch 'GameLogic-MessageHandler' of https://github.com/dean11/Danbias into GameLogic-MessageHandler
Conflicts: Code/Misc/EventHandler/EventButton.h
This commit is contained in:
commit
e7d592e71a
|
@ -4,39 +4,23 @@
|
||||||
|
|
||||||
#include "../../Input/L_inputClass.h"
|
#include "../../Input/L_inputClass.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "IEventButton.h"
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
namespace Event
|
namespace Event
|
||||||
{
|
{
|
||||||
struct IButton
|
|
||||||
{
|
template <class owner>
|
||||||
enum ButtonState
|
class EventButton : public IEventButton
|
||||||
{
|
|
||||||
Button_Clicked,
|
|
||||||
Button_Hover,
|
|
||||||
Button_Hold,
|
|
||||||
Button_Smashed,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
template <class T>
|
|
||||||
class EventButton :public IButton
|
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
struct ButtonEvent
|
|
||||||
{
|
|
||||||
ButtonState state;
|
|
||||||
EventButton &sender;
|
|
||||||
T owner;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct PrivData
|
struct PrivData
|
||||||
{
|
{
|
||||||
static unsigned int currID;
|
static unsigned int currID;
|
||||||
unsigned int ID;
|
unsigned int ID;
|
||||||
|
|
||||||
T owner;
|
owner owner;
|
||||||
void (*EventFunc)( ButtonEvent e );
|
void (*EventFunc)( ButtonEvent e );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -44,9 +28,9 @@ namespace Oyster
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EventButton();
|
EventButton();
|
||||||
EventButton(T owner);
|
EventButton(owner owner);
|
||||||
EventButton(void (*EventFunc)( ButtonEvent e));
|
EventButton(void (*EventFunc)( ButtonEvent e));
|
||||||
EventButton(void (*EventFunc)( ButtonEvent e), T owner);
|
EventButton(void (*EventFunc)( ButtonEvent e), owner owner);
|
||||||
|
|
||||||
~EventButton();
|
~EventButton();
|
||||||
|
|
||||||
|
@ -55,13 +39,13 @@ namespace Oyster
|
||||||
void SetEventFunc(void (*EventFunc)( ButtonEvent e )); //?
|
void SetEventFunc(void (*EventFunc)( ButtonEvent e )); //?
|
||||||
|
|
||||||
unsigned int GetID();
|
unsigned int GetID();
|
||||||
T& GetOwner();
|
owner& GetOwner();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class T>
|
template <class owner>
|
||||||
EventButton<T>::EventButton()
|
EventButton<owner>::EventButton()
|
||||||
{
|
{
|
||||||
this->privData.ID = privData.currID;
|
this->privData.ID = privData.currID;
|
||||||
this->privData.currID += 1;
|
this->privData.currID += 1;
|
||||||
|
@ -69,8 +53,8 @@ namespace Oyster
|
||||||
this->privData.EventFunc = NULL;
|
this->privData.EventFunc = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class owner>
|
||||||
EventButton<T>::EventButton(T owner)
|
EventButton<owner>::EventButton(owner owner)
|
||||||
{
|
{
|
||||||
this->privData.ID = privData.currID;
|
this->privData.ID = privData.currID;
|
||||||
this->privData.currID += 1;
|
this->privData.currID += 1;
|
||||||
|
@ -78,8 +62,8 @@ namespace Oyster
|
||||||
this->privData.EventFunc = NULL;
|
this->privData.EventFunc = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class owner>
|
||||||
EventButton<T>::EventButton(void (*EventFunc)( ButtonEvent e))
|
EventButton<owner>::EventButton(void (*EventFunc)( ButtonEvent e))
|
||||||
{
|
{
|
||||||
this->privData.ID = privData.currID;
|
this->privData.ID = privData.currID;
|
||||||
this->privData.currID += 1;
|
this->privData.currID += 1;
|
||||||
|
@ -87,8 +71,8 @@ namespace Oyster
|
||||||
this->privData.EventFunc = EventFunc;
|
this->privData.EventFunc = EventFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class owner>
|
||||||
EventButton<T>::EventButton(void (*EventFunc)( ButtonEvent e), T owner)
|
EventButton<owner>::EventButton(void (*EventFunc)( ButtonEvent e), owner owner)
|
||||||
{
|
{
|
||||||
this->privData.ID = privData.currID;
|
this->privData.ID = privData.currID;
|
||||||
this->privData.currID += 1;
|
this->privData.currID += 1;
|
||||||
|
@ -96,32 +80,32 @@ namespace Oyster
|
||||||
this->privData.EventFunc = EventFunc;
|
this->privData.EventFunc = EventFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class owner>
|
||||||
EventButton<T>~EventButton()
|
EventButton<owner>~EventButton()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class owner>
|
||||||
void EventButton<T>::checkCollision(InputClass *input)
|
void EventButton<owner>::checkCollision(InputClass *input)
|
||||||
{
|
{
|
||||||
//??????????????? TODO: everything
|
//??????????????? TODO: everything
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class owner>
|
||||||
void EventButton<T>::SetEventFunc(void (*EventFunc)( ButtonEvent e ))
|
void EventButton<owner>::SetEventFunc(void (*EventFunc)( ButtonEvent e ))
|
||||||
{
|
{
|
||||||
this->privData.EventFunc = EventFunc;
|
this->privData.EventFunc = EventFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class owner>
|
||||||
unsigned int EventButton<T>::GetID()
|
unsigned int EventButton<owner>::GetID()
|
||||||
{
|
{
|
||||||
return this->privData.ID;
|
return this->privData.ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class owner>
|
||||||
T& EventButton<T>::GetOwner()
|
owner& EventButton<owner>::GetOwner()
|
||||||
{
|
{
|
||||||
return this->privData.owner;
|
return this->privData.owner;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
#include "../../Input/L_inputClass.h"
|
||||||
|
|
||||||
|
namespace Oyster
|
||||||
|
{
|
||||||
|
namespace Event
|
||||||
|
{
|
||||||
|
class IEventButton
|
||||||
|
{
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
enum ButtonState
|
||||||
|
{
|
||||||
|
Button_Clicked,
|
||||||
|
Button_Hover,
|
||||||
|
Button_Hold,
|
||||||
|
Button_Smashed,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ButtonEvent
|
||||||
|
{
|
||||||
|
ButtonState state;
|
||||||
|
IEventButton &sender;
|
||||||
|
|
||||||
|
template<class owner>
|
||||||
|
owner owner;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual void checkCollision(InputClass *input) = 0;
|
||||||
|
|
||||||
|
virtual void SetEventFunc(void (*EventFunc)( ButtonEvent e )) = 0;
|
||||||
|
|
||||||
|
virtual unsigned int GetID() = 0;
|
||||||
|
|
||||||
|
template<class owner>
|
||||||
|
virtual owner& GetOwner() = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -166,6 +166,7 @@
|
||||||
<ClInclude Include="DynamicArray.h" />
|
<ClInclude Include="DynamicArray.h" />
|
||||||
<ClInclude Include="EventHandler\EventButton.h" />
|
<ClInclude Include="EventHandler\EventButton.h" />
|
||||||
<ClInclude Include="EventHandler\EventButtonCollection.h" />
|
<ClInclude Include="EventHandler\EventButtonCollection.h" />
|
||||||
|
<ClInclude Include="EventHandler\IEventButton.h" />
|
||||||
<ClInclude Include="GID.h" />
|
<ClInclude Include="GID.h" />
|
||||||
<ClInclude Include="IQueue.h" />
|
<ClInclude Include="IQueue.h" />
|
||||||
<ClInclude Include="EventHandler\EventHandler.h" />
|
<ClInclude Include="EventHandler\EventHandler.h" />
|
||||||
|
|
|
@ -131,5 +131,8 @@
|
||||||
<ClInclude Include="EventHandler\EventButtonCollection.h">
|
<ClInclude Include="EventHandler\EventButtonCollection.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="EventHandler\IEventButton.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in New Issue