mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2024-11-25 01:33:49 +00:00
some wip things but will probably throw this away
This commit is contained in:
parent
08b971b7ba
commit
167e6da372
8 changed files with 83 additions and 40 deletions
|
@ -159,6 +159,9 @@ DSQ::DSQ(const std::string& fileSystem, const std::string& extraDataDir)
|
|||
assert(!dsq);
|
||||
dsq = this;
|
||||
|
||||
mouse.actionToLeft = ACTION_PRIMARY;
|
||||
mouse.actionToRight = ACTION_SECONDARY;
|
||||
|
||||
cutscene_bg = 0;
|
||||
cutscene_text = 0;
|
||||
cutscene_text2 = 0;
|
||||
|
@ -3927,7 +3930,11 @@ void DSQ::onUpdate(float dt)
|
|||
os << "invGlobalScale: " << core->invGlobalScale;
|
||||
os << std::endl;
|
||||
os << "globalScale: " << core->globalScale.x << std::endl;
|
||||
os << "mousePos:(" << core->mouse.position.x << ", " << core->mouse.position.y << ") mouseChange:(" << core->mouse.change.x << ", " << core->mouse.change.y << ")\n";
|
||||
os << "mouse["
|
||||
<< (mouse.buttons.left ? 'L' : '-')
|
||||
<< (mouse.buttons.middle ? 'M' : '-')
|
||||
<< (mouse.buttons.right ? 'R' : '-')
|
||||
<< "]:pos(" << core->mouse.position.x << ", " << core->mouse.position.y << ") change:(" << core->mouse.change.x << ", " << core->mouse.change.y << ")\n";
|
||||
/*for(size_t i = 0; i < getNumJoysticks(); ++i)
|
||||
if(Joystick *j = getJoystick(i))
|
||||
{
|
||||
|
|
|
@ -2993,8 +2993,6 @@ void InGameMenu::onCook()
|
|||
|
||||
// do animationy stuff.
|
||||
|
||||
core->mouse.buttonsEnabled = false;
|
||||
|
||||
bool longAnim = true;
|
||||
int cooks = dsq->continuity.getFlag(FLAG_COOKS);
|
||||
|
||||
|
@ -3132,8 +3130,6 @@ void InGameMenu::onCook()
|
|||
if (haveLeftovers)
|
||||
updatePreviewRecipe();
|
||||
}
|
||||
|
||||
core->mouse.buttonsEnabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -78,7 +78,7 @@ protected:
|
|||
{
|
||||
importInput(&a[0], N);
|
||||
}
|
||||
void importInput(const NamedAction *actions, size_t N);*/
|
||||
void importInput(const NamedAction *actions, size_t N);*/ // TODO controllerfixup: remove this everywhere
|
||||
|
||||
std::vector<Event*> createdEvents;
|
||||
|
||||
|
|
|
@ -636,11 +636,10 @@ void Core::onUpdate(float dt)
|
|||
|
||||
pollEvents(dt);
|
||||
|
||||
|
||||
|
||||
ActionMapper::onUpdate(dt);
|
||||
StateManager::onUpdate(dt);
|
||||
|
||||
mouse.update(dt);
|
||||
onMouseInput();
|
||||
|
||||
globalScale.update(dt);
|
||||
|
|
34
BBGE/Core.h
34
BBGE/Core.h
|
@ -34,6 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "GameKeys.h"
|
||||
#include "InputMapperRaw.h"
|
||||
#include "VirtualMouse.h"
|
||||
|
||||
class ParticleEffect;
|
||||
class Joystick;
|
||||
|
@ -70,37 +71,6 @@ class Texture;
|
|||
const int baseVirtualWidth = 800;
|
||||
const int baseVirtualHeight = 600;
|
||||
|
||||
enum ButtonState { UP = 0, DOWN };
|
||||
|
||||
struct MouseButtons
|
||||
{
|
||||
MouseButtons ()
|
||||
{
|
||||
left = UP;
|
||||
right = UP;
|
||||
middle = UP;
|
||||
}
|
||||
|
||||
ButtonState left, right, middle;
|
||||
};
|
||||
|
||||
struct Mouse
|
||||
{
|
||||
Mouse()
|
||||
{
|
||||
scrollWheelChange = 0;
|
||||
buttonsEnabled = true;
|
||||
}
|
||||
Vector position, lastPosition;
|
||||
MouseButtons buttons;
|
||||
MouseButtons pure_buttons;
|
||||
unsigned rawButtonMask;
|
||||
Vector change;
|
||||
bool buttonsEnabled; //KILL
|
||||
|
||||
int scrollWheelChange;
|
||||
};
|
||||
|
||||
enum FollowCameraLock
|
||||
{
|
||||
FCL_NONE = 0,
|
||||
|
@ -325,7 +295,7 @@ public:
|
|||
int fps;
|
||||
bool loopDone;
|
||||
|
||||
Mouse mouse;
|
||||
VirtualMouse mouse;
|
||||
|
||||
AfterEffectManager *afterEffectManager;
|
||||
|
||||
|
|
29
BBGE/VirtualMouse.cpp
Normal file
29
BBGE/VirtualMouse.cpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include "VirtualMouse.h"
|
||||
#include <SDL.h>
|
||||
|
||||
VirtualMouse::VirtualMouse()
|
||||
: buttons(_buttons), pure_buttons(_pure_buttons)
|
||||
, actionToLeft(-1), actionToRight(-1)
|
||||
{
|
||||
}
|
||||
|
||||
VirtualMouse::update(float dt)
|
||||
{
|
||||
int x, int y;
|
||||
Uint32 mousestate = SDL_GetMouseState(&x, &y);
|
||||
pure_buttons.left = mousestate & SDL_BUTTON_LMASK;
|
||||
pure_buttons.right = mousestate & SDL_BUTTON_MMASK;
|
||||
pure_buttons.middle = mousestate & SDL_BUTTON_RMASK;
|
||||
|
||||
buttons = pure_buttons;
|
||||
|
||||
ActionMapper::onUpdate(dt);
|
||||
|
||||
if(actionToLeft >= 0 && isActing(actionToLeft))
|
||||
buttons.left = true;
|
||||
if(actionToRight> 0 && isActing(actionToRight))
|
||||
buttons.right = true;
|
||||
|
||||
// TODO: controller to mouse?
|
||||
}
|
||||
|
34
BBGE/VirtualMouse.h
Normal file
34
BBGE/VirtualMouse.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
#ifndef VIRTUALMOUSE_H
|
||||
#define VIRTUALMOUSE_H
|
||||
|
||||
#include "ActionMapper.h"
|
||||
|
||||
class VirtualMouse : public ActionMapper
|
||||
{
|
||||
VirtualMouse();
|
||||
|
||||
struct Buttons
|
||||
{
|
||||
bool left, middle, right;
|
||||
};
|
||||
|
||||
// externally set to actions that are to be handled as a button press
|
||||
int actionToLeft, actionToRight;
|
||||
|
||||
// const references to keep the "API" for the rest of the code
|
||||
// but make sure that nothing can be externally modified
|
||||
const Buttons &buttons, &pure_buttons;
|
||||
|
||||
Vector position, lastPosition;
|
||||
Vector change;
|
||||
|
||||
void update(float dt);
|
||||
|
||||
// override
|
||||
virtual void action(int actionID, int state, int playerID, InputDeviceType device);
|
||||
|
||||
private:
|
||||
Buttons _buttons, _pure_buttons;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -729,6 +729,14 @@
|
|||
RelativePath="..\..\BBGE\Vector.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\BBGE\VirtualMouse.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\BBGE\VirtualMouse.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\BBGE\Window.cpp"
|
||||
>
|
||||
|
|
Loading…
Reference in a new issue