From 5f2eafad7cbd3dbef5d3c1f6c6b6db3d74b80acf Mon Sep 17 00:00:00 2001 From: fgenesis Date: Sun, 21 Jan 2018 12:47:32 +0100 Subject: [PATCH] temp commit --- Aquaria/AquariaMenuItem.cpp | 2 +- Aquaria/Avatar.cpp | 8 ++++---- Aquaria/DSQ.cpp | 30 ++++++++++++++++++++++++++++-- Aquaria/DSQ.h | 10 +++++++++- Aquaria/InGameMenu.cpp | 2 +- Aquaria/ModSelector.cpp | 2 +- Aquaria/ScriptInterface.cpp | 3 ++- BBGE/ActionInput.h | 8 ++++++++ BBGE/ActionMapper.h | 9 +-------- BBGE/ActionSet.cpp | 1 + BBGE/ActionSet.h | 1 + 11 files changed, 57 insertions(+), 19 deletions(-) diff --git a/Aquaria/AquariaMenuItem.cpp b/Aquaria/AquariaMenuItem.cpp index 16a0a88..dde23c1 100644 --- a/Aquaria/AquariaMenuItem.cpp +++ b/Aquaria/AquariaMenuItem.cpp @@ -89,7 +89,7 @@ void AquariaGuiElement::setFocus(bool v) if (v) { currentFocus = this; - if (dsq->inputMode == INPUT_JOYSTICK || dsq->inputMode == INPUT_KEYBOARD) + if (dsq->getInputMode() == INPUT_JOYSTICK || dsq->getInputMode() == INPUT_KEYBOARD) core->setMousePosition(getGuiPosition()); AquariaGuiElement *gui=0, *guiThis = (AquariaGuiElement*)this; diff --git a/Aquaria/Avatar.cpp b/Aquaria/Avatar.cpp index fa5a03a..f78f81e 100644 --- a/Aquaria/Avatar.cpp +++ b/Aquaria/Avatar.cpp @@ -163,7 +163,7 @@ void Avatar::bindInput() Vector Avatar::getAim() { Vector d; - if (dsq->inputMode == INPUT_JOYSTICK) + if (dsq->getInputMode() == INPUT_JOYSTICK) { for(size_t i = 0; i < core->getNumJoysticks(); ++i) if(Joystick *j = core->getJoystick(i)) @@ -1730,7 +1730,7 @@ void Avatar::updateSingingInterface(float dt) { if (songIcons.size()>0 && songIcons[0]->alpha.x > 0) { - if (dsq->inputMode != INPUT_JOYSTICK && !core->mouse.change.isZero()) + if (dsq->getInputMode() != INPUT_JOYSTICK && !core->mouse.change.isZero()) { if (dsq->game->songLineRender && songIcons[0]->alpha.x == 1) { @@ -1756,7 +1756,7 @@ void Avatar::updateSingingInterface(float dt) } else { - if (dsq->inputMode == INPUT_JOYSTICK) + if (dsq->getInputMode() == INPUT_JOYSTICK) { Vector d; for(size_t i = 0; i < core->getNumJoysticks(); ++i) @@ -1948,7 +1948,7 @@ void Avatar::updateTargets(float dt, bool override) break; } } - if ((dsq->inputMode == INPUT_MOUSE || dsq->inputMode == INPUT_KEYBOARD) && !(wasDown && core->mouse.buttons.right)) + if ((dsq->getInputMode() == INPUT_MOUSE || dsq->getInputMode() == INPUT_KEYBOARD) && !(wasDown && core->mouse.buttons.right)) { wasDown = false; float mod = 1; diff --git a/Aquaria/DSQ.cpp b/Aquaria/DSQ.cpp index dc9d8b6..a94cd99 100644 --- a/Aquaria/DSQ.cpp +++ b/Aquaria/DSQ.cpp @@ -142,7 +142,7 @@ const bool isReleaseCandidate = false; const bool isFinalCandidate = false; const bool isGoldMaster = true; -Vector savesz; +static const Vector savesz(750.0f/1024.0f, 750.0f/1024.0f); /// WARNING: this is just to init, the actual value is set from user settings! #define PARTICLE_AMOUNT_DEFAULT 2048 @@ -2605,7 +2605,6 @@ void DSQ::createSaveSlots(SaveSlotMode ssm) menu[1] = new Quad("gui/save-menu", Vector(400,300)); - savesz = Vector(750.0f/1024.0f, 750.0f/1024.0f); menu[1]->alpha = 0; menu[1]->alpha.interpolateTo(1, t); menu[1]->scale = savesz * 0.5f; @@ -4560,3 +4559,30 @@ void DSQ::loadStringBank() stringbank.load(fname); } } + +InputDevice DSQ::getInputMode() const +{ + return lastInputMode; +} + +InputDevice DSQ::getInputMode(int source) const +{ + assert(source >= 0 && size_t(source) < _inputModes.size()); + return _inputModes[source]; +} + +void DSQ::getInputModeSafe(int source) const +{ + return source < 0 ? lastInputMode : + (size_t(source) < _inputModes.size() ? _inputModes[source] : INPUT_NODEVICE); +} + +bool DSQ::useMouseInput() const +{ + return lastInputMode == INPUT_MOUSE; +} + +bool DSQ::useJoystickInput() const +{ + return lastInputMode == INPUT_JOYSTICK; +} \ No newline at end of file diff --git a/Aquaria/DSQ.h b/Aquaria/DSQ.h index 2f282cd..20ea5e7 100644 --- a/Aquaria/DSQ.h +++ b/Aquaria/DSQ.h @@ -347,8 +347,16 @@ public: InterpolatedVector gameSpeed; - InputDevice inputMode; +private: + InputDevice lastInputMode; // really don't want to expose this one + std::vector _inputModes; // index: FIXME ADD INFO +public: void setInputMode(InputDevice mode); + InputDevice getInputMode() const; + InputDevice getInputMode(int source) const; + InputDevice getInputModeSafe(int source) const; + bool useMouseInput() const; + bool useJoystickInput() const; void rumble(float leftMotor, float rightMotor, float time, int source, InputDevice device); void vision(std::string folder, int num, bool ignoreMusic = false); diff --git a/Aquaria/InGameMenu.cpp b/Aquaria/InGameMenu.cpp index 908464c..78f96a8 100644 --- a/Aquaria/InGameMenu.cpp +++ b/Aquaria/InGameMenu.cpp @@ -646,7 +646,7 @@ void FoodSlot::onUpdate(float dt) { if (!themenu->recipeMenu.on) { - if (dsq->inputMode == INPUT_MOUSE) + if (dsq->getInputMode() == INPUT_MOUSE) { Vector diff = core->mouse.position - getWorldPosition(); position += diff; diff --git a/Aquaria/ModSelector.cpp b/Aquaria/ModSelector.cpp index 4133b9a..7e45873 100644 --- a/Aquaria/ModSelector.cpp +++ b/Aquaria/ModSelector.cpp @@ -120,7 +120,7 @@ void ModSelectorScreen::onUpdate(float dt) } } - if(!AquariaGuiElement::currentFocus && dsq->inputMode == INPUT_JOYSTICK) + if(!AquariaGuiElement::currentFocus && dsq->getInputMode() == INPUT_JOYSTICK) { AquariaGuiElement *closest = AquariaGuiElement::getClosestGuiElement(core->mouse.position); if(closest) diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index 38fc67c..118d002 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -8396,7 +8396,8 @@ luaFunc(disableInput) luaFunc(getInputMode) { - luaReturnInt(dsq->inputMode); + int source = lua_tointeger(L, 1); + luaReturnInt(dsq->getInputModeSafe(source - 1)); } static Joystick *_getJoystick(lua_State *L, int idx = 1) diff --git a/BBGE/ActionInput.h b/BBGE/ActionInput.h index 57cb164..26f5120 100644 --- a/BBGE/ActionInput.h +++ b/BBGE/ActionInput.h @@ -66,4 +66,12 @@ enum InputSetType INPUTSET_OTHER = 4 }; +enum InputDevice +{ + INPUT_NODEVICE = 0, + INPUT_MOUSE, + INPUT_JOYSTICK, + INPUT_KEYBOARD +}; + #endif diff --git a/BBGE/ActionMapper.h b/BBGE/ActionMapper.h index 53bfb04..246d32f 100644 --- a/BBGE/ActionMapper.h +++ b/BBGE/ActionMapper.h @@ -22,14 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define _actionmapper_ #include "Base.h" - -enum InputDevice -{ - INPUT_NODEVICE = 0, - INPUT_MOUSE, - INPUT_JOYSTICK, - INPUT_KEYBOARD -}; +#include "ActionInput.h" InputDevice getDeviceForActionbutton(int k); diff --git a/BBGE/ActionSet.cpp b/BBGE/ActionSet.cpp index 1553d0a..2d3a053 100644 --- a/BBGE/ActionSet.cpp +++ b/BBGE/ActionSet.cpp @@ -33,6 +33,7 @@ JoystickConfig::JoystickConfig() ActionSet::ActionSet() { + inputMode = INPUT_NODEVICE; enabled = true; joystickID = ACTIONSET_REASSIGN_JOYSTICK; } diff --git a/BBGE/ActionSet.h b/BBGE/ActionSet.h index 38d213a..91c88d7 100644 --- a/BBGE/ActionSet.h +++ b/BBGE/ActionSet.h @@ -59,6 +59,7 @@ public: ActionInput *addActionInput(const std::string &name); ActionInput *getActionInputByName(const std::string &name); + InputDevice inputMode; size_t joystickID; // >= 0: use that, -1 = no joystick, or ACTIONSET_REASSIGN_JOYSTICK // --- Saved in config ---