mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-02-18 02:34:57 +00:00
Preparations to get rid of DSQ::inputMode -- Pass device to action() methods.
This commit is contained in:
parent
e8a4b58e80
commit
9d80077754
28 changed files with 80 additions and 91 deletions
|
@ -537,7 +537,7 @@ void AnimationEditor::redo()
|
|||
}
|
||||
}
|
||||
|
||||
void AnimationEditor::action(int id, int state, int source)
|
||||
void AnimationEditor::action(int id, int state, int source, InputDevice device)
|
||||
{
|
||||
if (editingBone && state)
|
||||
{
|
||||
|
|
|
@ -113,7 +113,7 @@ public:
|
|||
|
||||
std::vector<KeyframeWidget*> keyframeWidgets;
|
||||
|
||||
void action(int id, int state, int source);
|
||||
void action(int id, int state, int source, InputDevice device);
|
||||
|
||||
void rebuildKeyframeWidgets();
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ public:
|
|||
bool useQuad(const std::string &tex);
|
||||
void useGlow(const std::string &tex, int w, int h);
|
||||
void useSound(const std::string &tex);
|
||||
virtual void action(int actionID, int state, int source) {}
|
||||
virtual void action(int actionID, int state, int source, InputDevice device) {}
|
||||
|
||||
virtual bool isCursorInMenuItem();
|
||||
Vector getGuiPosition();
|
||||
|
|
|
@ -183,18 +183,15 @@ Vector Avatar::getAim()
|
|||
break;
|
||||
}
|
||||
}
|
||||
else if (dsq->inputMode == INPUT_KEYBOARD)
|
||||
{
|
||||
d = dsq->getGameCursorPosition() - position;
|
||||
d.z = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
d = dsq->getGameCursorPosition() - position;
|
||||
d.z = 1;
|
||||
}
|
||||
|
||||
if (d.isZero())
|
||||
d = getForwardAim();
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
|
@ -3019,14 +3016,11 @@ bool Avatar::isMouseInputEnabled()
|
|||
return true;
|
||||
}
|
||||
|
||||
void Avatar::rmbd()
|
||||
void Avatar::rmbd(int source, InputDevice device)
|
||||
{
|
||||
//core->setDockIcon("BitBlot");
|
||||
if (!isMouseInputEnabled() || isEntityDead()) return;
|
||||
if (dsq->continuity.form == FORM_NORMAL )
|
||||
{
|
||||
//if (isCoordinateInRadius(dsq->getGameCursorPosition(), 96))
|
||||
///Vector diff = core->mouse.position - c;
|
||||
if (dsq->inputMode == INPUT_MOUSE)
|
||||
{
|
||||
Vector diff = getVectorToCursorFromScreenCentre();
|
||||
|
@ -3044,7 +3038,7 @@ void Avatar::rmbd()
|
|||
}
|
||||
}
|
||||
|
||||
void Avatar::rmbu()
|
||||
void Avatar::rmbu(int source, InputDevice device)
|
||||
{
|
||||
if (!isMouseInputEnabled() || isEntityDead()) return;
|
||||
|
||||
|
@ -3201,7 +3195,7 @@ void Avatar::onUpdateBoneLock()
|
|||
rotateToVec(wallNormal, 0.01);
|
||||
}
|
||||
|
||||
void Avatar::lmbd()
|
||||
void Avatar::lmbd(int source, InputDevice device)
|
||||
{
|
||||
if (!isMouseInputEnabled()) return;
|
||||
|
||||
|
@ -3243,7 +3237,7 @@ void Avatar::fallOffWall()
|
|||
}
|
||||
}
|
||||
|
||||
void Avatar::lmbu()
|
||||
void Avatar::lmbu(int source, InputDevice device)
|
||||
{
|
||||
if (!isMouseInputEnabled()) return;
|
||||
|
||||
|
@ -4270,15 +4264,15 @@ Vector Avatar::getVectorToCursor(bool trueMouse)
|
|||
//return core->mouse.position - Vector(400,300);
|
||||
}
|
||||
|
||||
void Avatar::action(int id, int state, int source)
|
||||
void Avatar::action(int id, int state, int source, InputDevice device)
|
||||
{
|
||||
if(dsq->game->isIgnoreAction((AquariaActions)id))
|
||||
return;
|
||||
|
||||
_lastActionSourceID = source;
|
||||
|
||||
if (id == ACTION_PRIMARY) { if (state) lmbd(); else lmbu(); }
|
||||
if (id == ACTION_SECONDARY) { if (state) rmbd(); else rmbu(); }
|
||||
if (id == ACTION_PRIMARY) { if (state) lmbd(source, device); else lmbu(source, device); }
|
||||
if (id == ACTION_SECONDARY) { if (state) rmbd(source, device); else rmbu(source, device); }
|
||||
|
||||
if (id == ACTION_REVERT && !state)
|
||||
revert();
|
||||
|
|
|
@ -138,7 +138,7 @@ public:
|
|||
Avatar();
|
||||
virtual ~Avatar();
|
||||
void destroy();
|
||||
void action(int actionID, int state, int source);
|
||||
void action(int actionID, int state, int source, InputDevice device);
|
||||
AvatarState state;
|
||||
float burst, burstTimer;
|
||||
float burstDelay;
|
||||
|
@ -439,11 +439,11 @@ protected:
|
|||
Quad *glow;
|
||||
bool swimming;
|
||||
|
||||
void lmbd();
|
||||
void lmbu();
|
||||
void lmbd(int source, InputDevice device);
|
||||
void lmbu(int source, InputDevice device);
|
||||
|
||||
void rmbd();
|
||||
void rmbu();
|
||||
void rmbd(int source, InputDevice device);
|
||||
void rmbu(int source, InputDevice device);
|
||||
|
||||
bool charging;
|
||||
|
||||
|
|
|
@ -1687,7 +1687,7 @@ void DSQ::toggleVersionLabel(bool on)
|
|||
versionLabel->alpha.interpolateTo(a, 1);
|
||||
}
|
||||
|
||||
void DSQ::setInputMode(InputMode mode)
|
||||
void DSQ::setInputMode(InputDevice mode)
|
||||
{
|
||||
inputMode = mode;
|
||||
switch(inputMode)
|
||||
|
@ -3659,9 +3659,9 @@ void DSQ::watch(float t, int canQuit)
|
|||
}
|
||||
}
|
||||
|
||||
void DSQ::action(int id, int state, int source)
|
||||
void DSQ::action(int id, int state, int source, InputDevice device)
|
||||
{
|
||||
Core::action(id, state, source);
|
||||
Core::action(id, state, source, device);
|
||||
|
||||
if (id == ACTION_ESC && !state)
|
||||
{
|
||||
|
|
|
@ -210,7 +210,7 @@ public:
|
|||
|
||||
void nag(NagType type);
|
||||
|
||||
void action(int id, int state, int source);
|
||||
void action(int id, int state, int source, InputDevice device);
|
||||
|
||||
void title(bool fadeMusic=true);
|
||||
|
||||
|
@ -350,8 +350,8 @@ public:
|
|||
|
||||
InterpolatedVector gameSpeed;
|
||||
|
||||
InputMode inputMode;
|
||||
void setInputMode(InputMode mode);
|
||||
InputDevice inputMode;
|
||||
void setInputMode(InputDevice mode);
|
||||
|
||||
void rumble(float leftMotor, float rightMotor, float time, int source);
|
||||
void vision(std::string folder, int num, bool ignoreMusic = false);
|
||||
|
|
|
@ -2525,13 +2525,13 @@ float Game::getHalfTimer(float mod)
|
|||
return halfTimer*mod;
|
||||
}
|
||||
|
||||
void Game::action(int id, int state, int source)
|
||||
void Game::action(int id, int state, int source, InputDevice device)
|
||||
{
|
||||
for (int i = 0; i < paths.size(); i++)
|
||||
{
|
||||
if (paths[i]->catchActions)
|
||||
{
|
||||
if (!paths[i]->action(id, state, source))
|
||||
if (!paths[i]->action(id, state, source, device))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2542,7 +2542,7 @@ void Game::action(int id, int state, int source)
|
|||
// forward
|
||||
if(id == ACTION_TOGGLEMENU)
|
||||
{
|
||||
themenu->action(id, state, source);
|
||||
themenu->action(id, state, source, device);
|
||||
}
|
||||
|
||||
if (id == ACTION_TOGGLEHELPSCREEN && !state)
|
||||
|
@ -2550,7 +2550,7 @@ void Game::action(int id, int state, int source)
|
|||
onToggleHelpScreen();
|
||||
}
|
||||
if (id == ACTION_ESC && !state)
|
||||
onPressEscape();
|
||||
onPressEscape(source, device);
|
||||
|
||||
if (id == ACTION_TOGGLEWORLDMAP && !state)
|
||||
{
|
||||
|
@ -3776,7 +3776,7 @@ bool Game::updateMusic()
|
|||
return false;
|
||||
}
|
||||
|
||||
void Game::onPressEscape()
|
||||
void Game::onPressEscape(int source, InputDevice device)
|
||||
{
|
||||
if (dsq->isInCutscene())
|
||||
{
|
||||
|
@ -3799,7 +3799,7 @@ void Game::onPressEscape()
|
|||
{
|
||||
if (core->getNestedMains() == 1 && !core->isStateJumpPending())
|
||||
{
|
||||
action(ACTION_TOGGLEMENU, 1, -1); // show menu
|
||||
action(ACTION_TOGGLEMENU, 1, source, device); // show menu
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -210,7 +210,7 @@ public:
|
|||
void flipElementVert();
|
||||
void deleteSelectedElement();
|
||||
void deleteElement(int selectedIdx);
|
||||
virtual void action(int id, int state, int source);
|
||||
virtual void action(int id, int state, int source, InputDevice device);
|
||||
void scaleElementUp();
|
||||
void scaleElementDown();
|
||||
void scaleElement1();
|
||||
|
@ -408,7 +408,7 @@ public:
|
|||
|
||||
void toggleWorldMap();
|
||||
|
||||
void action(int id, int state, int source);
|
||||
void action(int id, int state, int source, InputDevice device);
|
||||
|
||||
InGameMenu *getInGameMenu() { return themenu; }
|
||||
|
||||
|
@ -675,7 +675,7 @@ public:
|
|||
|
||||
bool cameraOffBounds;
|
||||
|
||||
void toggleHelpScreen() { action(ACTION_TOGGLEHELPSCREEN, 0, -1); }
|
||||
void toggleHelpScreen() { action(ACTION_TOGGLEHELPSCREEN, 0, -1, INPUT_NODEVICE); }
|
||||
|
||||
void setWorldPaused(bool b) { worldPaused = b; }
|
||||
bool isWorldPaused() const { return worldPaused; }
|
||||
|
@ -741,7 +741,7 @@ protected:
|
|||
float deathTimer;
|
||||
|
||||
|
||||
void onPressEscape();
|
||||
void onPressEscape(int source, InputDevice device);
|
||||
|
||||
bool paused;
|
||||
bool worldPaused;
|
||||
|
|
|
@ -199,17 +199,6 @@ enum FormUpgradeType
|
|||
FORMUPGRADE_MAX
|
||||
};
|
||||
|
||||
// defined by windows includes
|
||||
#undef INPUT_MOUSE
|
||||
#undef INPUT_KEYBOARD
|
||||
|
||||
enum InputMode
|
||||
{
|
||||
INPUT_MOUSE = 0,
|
||||
INPUT_JOYSTICK = 1,
|
||||
INPUT_KEYBOARD = 2
|
||||
};
|
||||
|
||||
enum EFXType
|
||||
{
|
||||
EFX_NONE =-1,
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
Vector getAvatarWorldMapPosition();
|
||||
Vector getWorldToTile(WorldMapTile *tile, Vector position, bool fromCenter, bool tilePos);
|
||||
void setProperTileColor(WorldMapTile *tile);
|
||||
void action(int id, int state, int source);
|
||||
void action(int id, int state, int source, InputDevice device);
|
||||
GemMover* addGem(GemData *gemData);
|
||||
void bindInput();
|
||||
void createGemHint(const std::string &gfx);
|
||||
|
|
|
@ -981,7 +981,7 @@ void InGameMenu::onContinuityReset()
|
|||
lastOptionsMenuPage = MENUPAGE_NONE;
|
||||
}
|
||||
|
||||
void InGameMenu::action(int id, int state, int source)
|
||||
void InGameMenu::action(int id, int state, int source, InputDevice device)
|
||||
{
|
||||
if(game->isIgnoreAction((AquariaActions)id))
|
||||
return;
|
||||
|
@ -1014,7 +1014,7 @@ void InGameMenu::action(int id, int state, int source)
|
|||
if (optionsMenu || keyConfigMenu)
|
||||
onOptionsCancel();
|
||||
else
|
||||
action(ACTION_TOGGLEMENU, 0, -1); // hide menu
|
||||
action(ACTION_TOGGLEMENU, 0, source, device); // hide menu
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ public:
|
|||
void onContinuityReset();
|
||||
|
||||
void bindInput();
|
||||
virtual void action(int actionID, int state, int source);
|
||||
virtual void action(int actionID, int state, int source, InputDevice device);
|
||||
|
||||
void refreshFoodSlots(bool effects);
|
||||
|
||||
|
|
|
@ -413,7 +413,7 @@ void MiniMapRender::onUpdate(float dt)
|
|||
{
|
||||
doubleClickDelay = 0;
|
||||
if (!core->isStateJumpPending())
|
||||
dsq->game->action(ACTION_TOGGLEMENU, 1, -1);
|
||||
dsq->game->action(ACTION_TOGGLEMENU, 1, -1, INPUT_NODEVICE);
|
||||
btn = true;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -166,7 +166,7 @@ public:
|
|||
|
||||
void setSubText(const std::string& s);
|
||||
|
||||
virtual void action(int actionID, int state, int source) {}
|
||||
virtual void action(int actionID, int state, int source, InputDevice device) {}
|
||||
|
||||
protected:
|
||||
virtual void onUpdate(float dt);
|
||||
|
|
|
@ -637,7 +637,7 @@ void Path::update(float dt)
|
|||
}
|
||||
}
|
||||
|
||||
bool Path::action(int id, int state, int source)
|
||||
bool Path::action(int id, int state, int source, InputDevice device)
|
||||
{
|
||||
if (hasScript())
|
||||
{
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
void addNode(int idx);
|
||||
void update(float dt);
|
||||
void setActive(bool v);
|
||||
bool action(int id, int state, int source);
|
||||
bool action(int id, int state, int source, InputDevice device);
|
||||
void setEmitter(const std::string& name);
|
||||
|
||||
PathNode *getPathNode(int idx);
|
||||
|
|
|
@ -1849,7 +1849,7 @@ void SceneEditor::removeEntity()
|
|||
void SceneEditor::placeAvatar()
|
||||
{
|
||||
dsq->game->avatar->position = dsq->getGameCursorPosition();
|
||||
dsq->game->action(ACTION_PLACE_AVATAR, 0, -1);
|
||||
dsq->game->action(ACTION_PLACE_AVATAR, 0, -1, INPUT_NODEVICE);
|
||||
}
|
||||
|
||||
void SceneEditor::scaleElementUp()
|
||||
|
@ -1956,7 +1956,7 @@ void SceneEditor::updateMultiSelect()
|
|||
}
|
||||
}
|
||||
|
||||
void SceneEditor::action(int id, int state, int source)
|
||||
void SceneEditor::action(int id, int state, int source, InputDevice device)
|
||||
{
|
||||
if (core->getCtrlState() && editingElement)
|
||||
{
|
||||
|
|
|
@ -50,6 +50,7 @@ extern "C"
|
|||
#include "Hair.h"
|
||||
#include "Spore.h"
|
||||
#include "Shader.h"
|
||||
#include "ActionMapper.h"
|
||||
|
||||
|
||||
#include "../BBGE/MathFunctions.h"
|
||||
|
@ -2041,12 +2042,13 @@ luaFunc(sendAction)
|
|||
int state = lua_tointeger(L, 2);
|
||||
int mask = lua_tointeger(L, 3);
|
||||
int source = lua_tointeger(L, 4);
|
||||
InputDevice device = (InputDevice)lua_tointeger(L, 5);
|
||||
if(!mask)
|
||||
mask = -1;
|
||||
if(mask & 1)
|
||||
dsq->game->action(ac, state, source);
|
||||
dsq->game->action(ac, state, source, device);
|
||||
if((mask & 2) && dsq->game->avatar)
|
||||
dsq->game->avatar->action(ac, state, source);
|
||||
dsq->game->avatar->action(ac, state, source, device);
|
||||
luaReturnNil();
|
||||
}
|
||||
|
||||
|
|
|
@ -1501,7 +1501,7 @@ void WorldMapRender::updateEditor()
|
|||
areaLabel->setText(os.str());
|
||||
}
|
||||
|
||||
void WorldMapRender::action (int id, int state, int source)
|
||||
void WorldMapRender::action (int id, int state, int source, InputDevice device)
|
||||
{
|
||||
if (isOn())
|
||||
{
|
||||
|
|
|
@ -19,6 +19,15 @@ See the GNU General Public License for more details.
|
|||
#include "Core.h"
|
||||
|
||||
|
||||
InputDevice getDeviceForActionbutton(int k)
|
||||
{
|
||||
if(k <= KEY_MAXARRAY)
|
||||
return INPUT_KEYBOARD;
|
||||
if(k < MOUSE_BUTTON_EXTRA_END)
|
||||
return INPUT_MOUSE;
|
||||
return INPUT_JOYSTICK;
|
||||
}
|
||||
|
||||
ActionMapper::ActionMapper()
|
||||
{
|
||||
cleared = false;
|
||||
|
@ -167,9 +176,7 @@ void ActionMapper::onUpdate (float dt)
|
|||
|
||||
for (ActionDataSet::iterator i = actionData.begin(); i != actionData.end(); ++i)
|
||||
{
|
||||
ButtonList::iterator j;
|
||||
j = i->buttonList.begin();
|
||||
for (; j != i->buttonList.end(); j++)
|
||||
for (ButtonList::iterator j = i->buttonList.begin(); j != i->buttonList.end(); j++)
|
||||
{
|
||||
const int k = (*j);
|
||||
const ActionData *ad = &(*i);
|
||||
|
@ -189,7 +196,7 @@ void ActionMapper::onUpdate (float dt)
|
|||
}
|
||||
else
|
||||
{
|
||||
action(ad->id, keyState, ad->source);
|
||||
action(ad->id, keyState, ad->source, getDeviceForActionbutton(k));
|
||||
}
|
||||
if (core->loopDone) goto out;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "Base.h"
|
||||
|
||||
enum InputDevice
|
||||
{
|
||||
INPUT_NODEVICE = 0,
|
||||
INPUT_MOUSE,
|
||||
INPUT_JOYSTICK,
|
||||
INPUT_KEYBOARD
|
||||
};
|
||||
|
||||
InputDevice getDeviceForActionbutton(int k);
|
||||
|
||||
class Event;
|
||||
class ActionMapper;
|
||||
|
||||
|
@ -57,7 +67,7 @@ public:
|
|||
void addAction(int actionID, int k, int source);
|
||||
|
||||
bool isActing(int actionID, int source);
|
||||
virtual void action(int actionID, int state, int source) = 0;
|
||||
virtual void action(int actionID, int state, int source, InputDevice device) = 0;
|
||||
|
||||
|
||||
void clearActions();
|
||||
|
|
|
@ -153,15 +153,9 @@ void ActionSet::importAction(ActionMapper *mapper, const std::string &name, int
|
|||
const ActionInput *actionInput = &inputSet[i];
|
||||
if (actionInput->name == name)
|
||||
{
|
||||
for (int i = 0; i < INP_MSESIZE; i++)
|
||||
if (actionInput->mse[i])
|
||||
mapper->addAction(actionID, actionInput->mse[i], sourceID);
|
||||
for (int i = 0; i < INP_KEYSIZE; i++)
|
||||
if (actionInput->key[i])
|
||||
mapper->addAction(actionID, actionInput->key[i], sourceID);
|
||||
for (int i = 0; i < INP_JOYSIZE; i++)
|
||||
if (actionInput->joy[i])
|
||||
mapper->addAction(actionID, actionInput->joy[i], sourceID);
|
||||
for (int i = 0; i < INP_COMBINED_SIZE; i++)
|
||||
if (actionInput->all[i])
|
||||
mapper->addAction(actionID, actionInput->all[i], sourceID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -177,16 +171,9 @@ void ActionSet::importAction(ActionMapper *mapper, const std::string &name, Even
|
|||
const ActionInput *actionInput = &inputSet[i];
|
||||
if (actionInput->name == name)
|
||||
{
|
||||
for (int i = 0; i < INP_MSESIZE; i++)
|
||||
if (actionInput->mse[i])
|
||||
mapper->addAction(event, actionInput->mse[i], state);
|
||||
for (int i = 0; i < INP_KEYSIZE; i++)
|
||||
if (actionInput->key[i])
|
||||
mapper->addAction(event, actionInput->key[i], state);
|
||||
for (int i = 0; i < INP_JOYSIZE; i++)
|
||||
if (actionInput->joy[i])
|
||||
mapper->addAction(event, actionInput->joy[i], state);
|
||||
|
||||
for (int i = 0; i < INP_COMBINED_SIZE; i++)
|
||||
if (actionInput->all[i])
|
||||
mapper->addAction(event, actionInput->all[i], state);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "Core.h"
|
||||
#include "ActionSet.h"
|
||||
|
||||
|
||||
ActionButtonStatus::ActionButtonStatus()
|
||||
: joystickID(-1)
|
||||
{
|
||||
|
|
|
@ -28,7 +28,6 @@ enum ActionButtonType
|
|||
ACTION_BUTTON_ENUM_SIZE = JOY_AXIS_END_NEG
|
||||
};
|
||||
|
||||
|
||||
class ActionButtonStatus
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -261,7 +261,7 @@ public:
|
|||
void setMouseConstraint(bool on);
|
||||
void setMouseConstraintCircle(const Vector& pos, float mouseCircle);
|
||||
|
||||
virtual void action(int id, int state, int source){}
|
||||
virtual void action(int id, int state, int source, InputDevice device){}
|
||||
|
||||
bool exists(const std::string &file);
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ void EventPtr::call()
|
|||
}
|
||||
if (actionMapperCallback)
|
||||
{
|
||||
actionMapperCallback->action(actionValue, stateToCall, -1);
|
||||
actionMapperCallback->action(actionValue, stateToCall, -1, INPUT_NODEVICE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ public:
|
|||
void removeRenderObject(RenderObject *renderObject);
|
||||
std::string name;
|
||||
|
||||
virtual void action(int actionID, int state, int source) {}
|
||||
virtual void action(int actionID, int state, int source, InputDevice device) {}
|
||||
|
||||
protected:
|
||||
void registerState(StateObject *sb, const std::string &name);
|
||||
|
|
Loading…
Add table
Reference in a new issue