1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-01-24 17:26:41 +00:00

temp commit

This commit is contained in:
fgenesis 2018-01-21 12:47:32 +01:00
parent 8f565c6171
commit 5f2eafad7c
11 changed files with 57 additions and 19 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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;
}

View file

@ -347,8 +347,16 @@ public:
InterpolatedVector gameSpeed;
InputDevice inputMode;
private:
InputDevice lastInputMode; // really don't want to expose this one
std::vector<InputDevice> _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);

View file

@ -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;

View file

@ -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)

View file

@ -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)

View file

@ -66,4 +66,12 @@ enum InputSetType
INPUTSET_OTHER = 4
};
enum InputDevice
{
INPUT_NODEVICE = 0,
INPUT_MOUSE,
INPUT_JOYSTICK,
INPUT_KEYBOARD
};
#endif

View file

@ -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);

View file

@ -33,6 +33,7 @@ JoystickConfig::JoystickConfig()
ActionSet::ActionSet()
{
inputMode = INPUT_NODEVICE;
enabled = true;
joystickID = ACTIONSET_REASSIGN_JOYSTICK;
}

View file

@ -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 ---