mirror of
https://github.com/devZoGok/gameBase.git
synced 2026-08-26 19:43:28 +00:00
general refactoring
This commit is contained in:
@@ -20,7 +20,7 @@ namespace gameBase {
|
||||
int trigger = atoi(bindingsLines[i].substr(semicolon + 5, string::npos).c_str());
|
||||
|
||||
Mapping *m = new Mapping;
|
||||
m->bind = (Mapping::Bind)(3 + i);
|
||||
m->bind = 3 + i;
|
||||
m->type = type;
|
||||
m->action = action;
|
||||
m->trigger = trigger;
|
||||
@@ -30,11 +30,12 @@ namespace gameBase {
|
||||
|
||||
void AbstractAppState::onDettached(){
|
||||
attached = false;
|
||||
|
||||
while(!mappings.empty())
|
||||
mappings.pop_back();
|
||||
}
|
||||
|
||||
void AbstractAppState::update(){}
|
||||
|
||||
void AbstractAppState::removeMapping(Mapping::Bind bind){
|
||||
void AbstractAppState::removeMapping(int bind){
|
||||
int id = -1;
|
||||
|
||||
for(int i = 0; i < mappings.size(); i++)
|
||||
|
||||
+9
-8
@@ -9,7 +9,7 @@
|
||||
namespace gameBase {
|
||||
class AbstractAppState{
|
||||
public:
|
||||
virtual void update();
|
||||
virtual void update(){}
|
||||
virtual void onAttached();
|
||||
virtual void onDettached();
|
||||
inline int getType(){return type;}
|
||||
@@ -17,16 +17,17 @@ namespace gameBase {
|
||||
inline std::vector<Mapping*>& getMappings(){return mappings;}
|
||||
inline int getNumMappings(){return mappings.size();}
|
||||
inline bool isAttached(){return attached;}
|
||||
void removeMapping(Mapping::Bind);
|
||||
virtual void onAction(Mapping::Bind,bool){}
|
||||
virtual void onAnalog(Mapping::Bind,float){}
|
||||
virtual void onRawKeyButton(short){}
|
||||
virtual void onRawMouseButton(short){}
|
||||
virtual void onRawJoystickAxis(short,float){}
|
||||
virtual void onRawJoystickButton(short){}
|
||||
void removeMapping(int);
|
||||
virtual void onAction(int, bool){}
|
||||
virtual void onAnalog(int, float){}
|
||||
virtual void onRawKeyPress(int){}
|
||||
virtual void onRawMousePress(int){}
|
||||
virtual void onRawJoystickMove(int, float){}
|
||||
virtual void onRawJoystickPress(int){}
|
||||
protected:
|
||||
AbstractAppState(){}
|
||||
~AbstractAppState(){}
|
||||
|
||||
std::vector<Mapping*> mappings;
|
||||
std::vector<std::string> bindingsLines;
|
||||
int type;
|
||||
|
||||
+4
-4
@@ -101,9 +101,9 @@ namespace gameBase{
|
||||
|
||||
for(int i = 0; i < 350; i++){
|
||||
if(glfwGetKey(window, i))
|
||||
a->onRawKeyButton(i);
|
||||
a->onRawKeyPress(i);
|
||||
else if(glfwGetMouseButton(window, i))
|
||||
a->onRawMouseButton(i);
|
||||
a->onRawMousePress(i);
|
||||
}
|
||||
|
||||
glfwSetCursorPosCallback(window, foo);
|
||||
@@ -111,11 +111,11 @@ namespace gameBase{
|
||||
if(glfwJoystickPresent(GLFW_JOYSTICK_1)){
|
||||
for(int i = 0; i < numAxis; i++)
|
||||
if(abs(axis[i]) == 1)
|
||||
a->onRawJoystickAxis(i, axis[i]);
|
||||
a->onRawJoystickMove(i, axis[i]);
|
||||
|
||||
for(int i = 0; i < numButtons; i++)
|
||||
if(buttons[i])
|
||||
a->onRawJoystickButton(i);
|
||||
a->onRawJoystickPress(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,53 +4,10 @@
|
||||
|
||||
namespace gameBase{
|
||||
struct Mapping{
|
||||
enum Bind{
|
||||
LEFT_CLICK,
|
||||
SCROLLING_UP,
|
||||
SCROLLING_DOWN,
|
||||
LEFT,
|
||||
RIGHT,
|
||||
DELETE_CHAR,
|
||||
CAPS_LOCK,
|
||||
SHIFT_CAPS,
|
||||
SPACE,
|
||||
PLUS,
|
||||
MINUS,
|
||||
DEVSTERISK,
|
||||
TOGGLE_MAIN_MENU,
|
||||
HALT,
|
||||
ZOOM_IN,
|
||||
ZOOM_OUT,
|
||||
LOOK_AROUND,
|
||||
LOOK_UP,
|
||||
LOOK_DOWN,
|
||||
LOOK_LEFT,
|
||||
LOOK_RIGHT,
|
||||
DRAG_BOX,
|
||||
DESELECT,
|
||||
LEFT_CONTROL,
|
||||
LEFT_SHIFT,
|
||||
SELECT_PATROL_POINTS,
|
||||
LAUNCH,
|
||||
TOGGLE_SUB,
|
||||
INSTALL_AWM,
|
||||
INSTALL_AAM,
|
||||
GROUP_0,
|
||||
GROUP_1,
|
||||
GROUP_2,
|
||||
GROUP_3,
|
||||
GROUP_4,
|
||||
GROUP_5,
|
||||
GROUP_6,
|
||||
GROUP_7,
|
||||
GROUP_8,
|
||||
GROUP_9,
|
||||
LAST_BIND
|
||||
};
|
||||
enum BindType{KEYBOARD, MOUSE_KEY, MOUSE_AXIS, JOYSTICK_KEY, JOYSTICK_AXIS};
|
||||
enum AuxTriggers{MOUSE_AXIS_LEFT = 310, MOUSE_AXIS_RIGHT = 311, MOUSE_AXIS_UP = 312, MOUSE_AXIS_DOWN = 313};
|
||||
|
||||
Bind bind;
|
||||
int bind;
|
||||
BindType type;
|
||||
int trigger;
|
||||
bool action, pressed = false;
|
||||
|
||||
Reference in New Issue
Block a user