Commit 4c3df51d authored by Gerhard Stein's avatar Gerhard Stein Committed by Gerhard Stein

Cleanups, fixes

parent 69080729
......@@ -1310,7 +1310,9 @@ bool CInput::getPressedCommand(int command)
{
bool retval = false;
for(int player=0; player<NUM_INPUTS ; player++ )
{
retval |= getPressedCommand(player, command);
}
return retval;
}
......
......@@ -16,7 +16,7 @@
#define INPUTEVENTS_H_
enum InputCommands
enum InputCommand
{
IC_LEFT = 0,
IC_RIGHT,
......@@ -65,10 +65,10 @@ struct MouseWheelEvent : CEvent
struct CommandEvent : public CEvent
{
CommandEvent(const InputCommands command) :
CommandEvent(const InputCommand command) :
mCommand(command) {}
InputCommands mCommand;
InputCommand mCommand;
};
......
......@@ -50,7 +50,7 @@ void CBaseMenu::ponder(const float deltaT)
{
if( gInput.getPressedCommand(cmd) )
{
std::shared_ptr<CEvent> command(new CommandEvent( static_cast<InputCommands>(cmd) ));
std::shared_ptr<CEvent> command(new CommandEvent( static_cast<InputCommand>(cmd) ));
sendEvent(command);
break;
}
......
......@@ -40,7 +40,7 @@ void GsButton::setupButtonSurface()
}
bool GsButton::sendEvent(const InputCommands command)
bool GsButton::sendEvent(const InputCommand command)
{
if(command == IC_STATUS || command == IC_JUMP)
{
......
......@@ -30,7 +30,7 @@ public:
void setupButtonSurface();
bool sendEvent(const InputCommands command);
bool sendEvent(const InputCommand command);
void updateGraphics();
......
......@@ -33,7 +33,7 @@ void CGUIComboSelection::cycleOption()
bool CGUIComboSelection::sendEvent(const InputCommands command)
bool CGUIComboSelection::sendEvent(const InputCommand command)
{
if(command == IC_STATUS || command == IC_JUMP)
{
......
......@@ -29,7 +29,7 @@ public:
virtual void cycleOption();
bool sendEvent(const InputCommands command);
bool sendEvent(const InputCommand command);
virtual void setSelection( const std::string& selectionText );
......
......@@ -74,7 +74,7 @@ public:
mHovered = value;
}
virtual bool sendEvent(const InputCommands command) { return false; }
virtual bool sendEvent(const InputCommand command) { return false; }
void drawTwirl( const SDL_Rect& lRect );
......
......@@ -39,7 +39,7 @@ mTick(false)
}
bool CGUIInputText::sendEvent(const InputCommands command)
bool CGUIInputText::sendEvent(const InputCommand command)
{
if(command == IC_STATUS || command == IC_JUMP)
{
......
......@@ -21,7 +21,7 @@ public:
const int fontID = 0,
const GsControl::Style style = Style::NONE);
bool sendEvent(const InputCommands command);
bool sendEvent(const InputCommand command);
void processLogic();
......
......@@ -52,7 +52,7 @@ void CGUINumberControl::decrement()
}
bool CGUINumberControl::sendEvent(const InputCommands command)
bool CGUINumberControl::sendEvent(const InputCommand command)
{
if(command == IC_STATUS || command == IC_JUMP || command == IC_RIGHT)
{
......
......@@ -30,7 +30,7 @@ public:
void increment();
void decrement();
bool sendEvent(const InputCommands command);
bool sendEvent(const InputCommand command);
int getSelection();
void setSelection( const int value );
......
......@@ -115,7 +115,7 @@ void GsScrollbar::processRender(const GsRect<float> &RectDispCoordFloat)
drawScrollBar(lRect);
}
bool GsScrollbar::sendEvent(const InputCommands command)
bool GsScrollbar::sendEvent(const InputCommand command)
{
return false;
}
......
......@@ -13,7 +13,7 @@ public:
void processRender(const GsRect<float> &RectDispCoordFloat);
bool sendEvent(const InputCommands command);
bool sendEvent(const InputCommand command);
void scrollUp()
{
......
......@@ -32,7 +32,7 @@ void CGUITextSelectionList::setBackButtonEvent(CEvent *ev)
mBackEvent.reset(ev);
}
bool CGUITextSelectionList::sendEvent(const InputCommands command)
bool CGUITextSelectionList::sendEvent(const InputCommand command)
{
if(command == IC_UP)
{
......
......@@ -27,7 +27,7 @@ public:
void setConfirmButtonEvent(CEvent *ev);
void setBackButtonEvent(CEvent *ev);
bool sendEvent(const InputCommands command);
bool sendEvent(const InputCommand command);
void addText(const std::string &text);
void processLogic();
void processRender(const GsRect<float> &RectDispCoordFloat);
......
......@@ -677,7 +677,7 @@ void CGameLauncher::ponderGameSelDialog(const float deltaT)
{
if( gInput.getPressedCommand(cmd) )
{
mLauncherDialog.sendEvent(new CommandEvent( static_cast<InputCommands>(cmd) ));
mLauncherDialog.sendEvent(new CommandEvent( static_cast<InputCommand>(cmd) ));
break;
}
}
......@@ -802,7 +802,7 @@ void CGameLauncher::ponder(const float deltaT)
{
if( gInput.getPressedCommand(cmd) )
{
mpGameStoreDialog->sendEvent(new CommandEvent( static_cast<InputCommands>(cmd) ));
mpGameStoreDialog->sendEvent(new CommandEvent( static_cast<InputCommand>(cmd) ));
break;
}
}
......
......@@ -56,6 +56,8 @@ bool VirtualKeenControl::init()
if(!mConfirmButton.loadPicture("confirm.png")) return false;
mConfirmButton.invisible = false;
if(!mStartButton.loadPicture("start.png")) return false;
if(!mJumpButton.loadPicture("1.png")) return false;
......@@ -113,7 +115,7 @@ bool VirtualKeenControl::ponder()
void VirtualKeenControl::render(GsWeakSurface &sfc)
{
#if SDL_VERSION_ATLEAST(2, 0, 0)
GsRect<Uint16> clickGameArea = gVideoDriver.mpVideoEngine->getActiveAreaRect();
//GsRect<Uint16> clickGameArea = gVideoDriver.mpVideoEngine->getActiveAreaRect();
auto addTexture = [](TouchButton &button) -> void
{
......@@ -128,10 +130,7 @@ void VirtualKeenControl::render(GsWeakSurface &sfc)
//addTexture(mStatusButton);
if(mButtonMode == BUTTON_MODE::OK)
{
addTexture(mConfirmButton);
}
addTexture(mConfirmButton);
/*if(mButtonMode == BUTTON_MODE::WMAP &&
!mHideStartButton)
......@@ -193,17 +192,9 @@ void VirtualKeenControl::render(GsWeakSurface &sfc)
void VirtualKeenControl::mouseState(const Vector2D<float> &Pos, const bool down)
{
#if SDL_VERSION_ATLEAST(2, 0, 0)
/// Menu Control process of one mouse state
const float dpadSize = 0.2f;
// Size of the buttons on the dpad
const float dpadSizePiece = 0.3f*dpadSize;
const float yBottom = 1.0f;
const float yTop = yBottom-dpadSize;
auto verifyButtonMatch = [&](const GsRect<float> &buttonRect,
InputCommands cmd)
auto bindButtonCommand = [&](const GsRect<float> &buttonRect,
const InputCommand &cmd)
{
if( buttonRect.HasPoint(Pos) )
{
......@@ -212,99 +203,50 @@ void VirtualKeenControl::mouseState(const Vector2D<float> &Pos, const bool down)
};
if(Pos.y >= yTop && Pos.y < 1.0f)
SDL_Event ev;
ev.type = (down ? SDL_KEYDOWN : SDL_KEYUP);
if( !mDPad.invisible &&
mDPad.isInside(Pos.x, Pos.y) )
{
SDL_Event ev;
ev.type = (down ? SDL_KEYDOWN : SDL_KEYUP);
// Size of the buttons on the dpad
const float dpadSizePiece = 0.3f*mDPad.w;
if( !mDPad.invisible &&
mDPad.isInside(Pos.x, Pos.y) )
// Y-Direction
// Up presses
if(Pos.y<mDPad.y+dpadSizePiece)
{
// Y-Direction
// Up presses
if(Pos.y<yTop+dpadSizePiece)
{
ev.key.keysym.sym = SDLK_UP;
SDL_PushEvent(&ev);
}
// Down presses
else if(Pos.y>=yBottom-dpadSizePiece)
{
ev.key.keysym.sym = SDLK_DOWN;
SDL_PushEvent(&ev);
}
// X-Direction
// Left presses
if(Pos.x<dpadSizePiece)
{
ev.key.keysym.sym = SDLK_LEFT;
SDL_PushEvent(&ev);
}
// Right presses
else if(Pos.x>=dpadSize-dpadSizePiece)
{
ev.key.keysym.sym = SDLK_RIGHT;
SDL_PushEvent(&ev);
}
ev.key.keysym.sym = SDLK_UP;
SDL_PushEvent(&ev);
}
// Down presses
else if(Pos.y>=1.0f-dpadSizePiece)
{
ev.key.keysym.sym = SDLK_DOWN;
SDL_PushEvent(&ev);
}
/// Dpad presses
if(Pos.x > dpadSize)
// X-Direction
// Left presses
if(Pos.x<dpadSizePiece)
{
ev.key.keysym.sym = SDLK_LEFT;
SDL_PushEvent(&ev);
}
// Right presses
else if(Pos.x>=mDPad.w-dpadSizePiece)
{
/// Then, if any other button was pressed...
const float buttonSize = 0.1f;
if(mButtonMode == BUTTON_MODE::OK)
{
// Was the Ok button pressed?
GsRect<float> confirmRect(1.0f-2.0f*buttonSize,
1.0f-2.0f*buttonSize,
buttonSize, buttonSize);
if( confirmRect.HasPoint(Pos) )
{
ev.key.keysym.sym = SDLK_RETURN;
SDL_PushEvent(&ev);
}
}
// On map if we can enter a level, let's enter!
if(mButtonMode == BUTTON_MODE::WMAP && !mHideStartButton)
{
// Was the Ok button pressed?
GsRect<float> confirmRect(1.0f-2.0f*buttonSize, 1.0f-2.0f*buttonSize, buttonSize, buttonSize);
verifyButtonMatch(confirmRect, IC_JUMP);
// Was the Status button pressed?
const GsRect<float> statusButtonRect(0.5f, 1.0f-buttonSize, buttonSize, buttonSize);
verifyButtonMatch(statusButtonRect, IC_STATUS);
}
if(mButtonMode == BUTTON_MODE::ACTION)
{
// Was the Shoot button pressed?
const GsRect<float> shootButtonRect(1.0f-2.0f*buttonSize, 1.0f-2.0f*buttonSize, buttonSize, buttonSize);
verifyButtonMatch(shootButtonRect, IC_FIRE);
// Was the Jump button pressed?
const GsRect<float> jumpButtonRect(1.0f-2.0f*buttonSize, 1.0f-buttonSize, buttonSize, buttonSize);
verifyButtonMatch(jumpButtonRect, IC_JUMP);
// Was the Pogo button pressed?
const GsRect<float> pogoButtonRect(1.0f-buttonSize, 1.0f-buttonSize, buttonSize, buttonSize);
verifyButtonMatch(pogoButtonRect, IC_POGO);
}
if(mShowStatusButton)
{
// Was the Status button pressed?
const GsRect<float> statusButtonRect(0.5f, 1.0f-buttonSize, buttonSize, buttonSize);
verifyButtonMatch(statusButtonRect, IC_STATUS);
}
ev.key.keysym.sym = SDLK_RIGHT;
SDL_PushEvent(&ev);
}
}
bindButtonCommand(mConfirmButton.Rect(), IC_JUMP);
bindButtonCommand(mStatusButton.Rect(), IC_STATUS);
bindButtonCommand(mShootButton.Rect(), IC_FIRE);
bindButtonCommand(mJumpButton.Rect(), IC_JUMP);
bindButtonCommand(mPogoButton.Rect(), IC_POGO);
#endif
}
......@@ -63,19 +63,11 @@ public:
#if SDL_VERSION_ATLEAST(2, 0, 0)
//GsTexture mDPadTexture;
//GsTexture mConfirmButtonTexture;
//GsTexture mStartButtonTexture;
TouchButton mDPad;
TouchButton mConfirmButton;
TouchButton mStartButton;
// Control buttons
//GsTexture mJumpButtonTexture;
//GsTexture mShootButtonTexture;
//GsTexture mPogoButtonTexture;
//GsTexture mStatusButtonTexture;
TouchButton mJumpButton;
TouchButton mShootButton;
TouchButton mPogoButton;
......@@ -86,7 +78,7 @@ public:
bool mShowStatusButton = false;
bool mHideStartButton = false;
BUTTON_MODE mButtonMode = BUTTON_MODE::OK;
//BUTTON_MODE mButtonMode = BUTTON_MODE::OK;
};
#endif // VGAMEPADSIMPLE_H
......@@ -102,8 +102,9 @@ void CLevelPlay::ponder(const float deltaT)
{
VirtualKeenControl *vkc = dynamic_cast<VirtualKeenControl*>(gInput.mpVirtPad.get());
assert(vkc);
vkc->mButtonMode = VirtualKeenControl::ACTION;
//vkc->mButtonMode = VirtualKeenControl::BUTTON_MODE::ACTION;
vkc->mHideStartButton = true;
vkc->mShowStatusButton = true;
}
ponderBase(deltaT);
......
......@@ -82,7 +82,7 @@ void CWorldMap::ponder(const float deltaT)
{
VirtualKeenControl *vkc = dynamic_cast<VirtualKeenControl*>(gInput.mpVirtPad.get());
assert(vkc);
vkc->mButtonMode = VirtualKeenControl::WMAP;
//vkc->mButtonMode = VirtualKeenControl::BUTTON_MODE::WMAP;
vkc->mHideStartButton = true;
}
......
......@@ -23,6 +23,8 @@
#include <array>
#include "engine/core/CBehaviorEngine.h"
const int TIME_TO_WAVE = 400;
namespace galaxy {
......@@ -147,7 +149,7 @@ void CPlayerWM::pumpEvent(const CEvent *evPtr)
// Events for the Player are processed here.
if( const EventPlayerEndLevel* ev = dynamic_cast<const EventPlayerEndLevel*>(evPtr) )
{
if(ev->who == mSprVar)
if(ev->who == mSpecialIdx)
{
gEventManager.flush();
if(ev->sucess)
......@@ -434,7 +436,6 @@ void CPlayerWM::processMoving()
if( gVideoDriver.VGamePadEnabled() )
{
VirtualKeenControl *vkc = dynamic_cast<VirtualKeenControl*>(gInput.mpVirtPad.get());
int level = object - 0xC000;
......@@ -463,8 +464,9 @@ void CPlayerWM::processMoving()
{
VirtualKeenControl *vkc = dynamic_cast<VirtualKeenControl*>(gInput.mpVirtPad.get());
assert(vkc);
vkc->mButtonMode = VirtualKeenControl::WMAP;
//vkc->mButtonMode = VirtualKeenControl::BUTTON_MODE::WMAP;
vkc->mHideStartButton = true;
vkc->mShowStatusButton = true;
}
......@@ -1040,7 +1042,12 @@ void CPlayerWM::startLevel(Uint16 object)
if(ep == 4)
{
shipLevel = gKeenFiles.exeFile.getRawData()[0x60FD];
shipLevel = 18;
if(!gKeenFiles.exeFile.isPythonScript())
{
shipLevel = gKeenFiles.exeFile.getRawData()[0x60FD];
}
}
const Uint16 flag_dest = level + 0xF000;
......
......@@ -27,7 +27,7 @@ class ReadInputEvent : public InvokeFunctorEvent
public:
ReadInputEvent( const int selPlayer,
const InputCommands command,
const InputCommand command,
const std::string &commandName ) :
mSelPlayer(selPlayer),
mCommand(command),
......@@ -49,7 +49,7 @@ public:
}
int mSelPlayer;
InputCommands mCommand;
InputCommand mCommand;
const std::string mCommandName;
GsButton* mpButton;
};
......@@ -151,7 +151,7 @@ void CControlSettingsBase::ponder(const float deltaT)
int pos; unsigned char input;
std::string evName = gInput.getNewMappedEvent(pos, input);
InputCommands com = static_cast<InputCommands>(pos);
InputCommand com = static_cast<InputCommand>(pos);
if(pos >= MID_COMMANDS_OFFSETS)
pos -= MID_COMMANDS_OFFSETS;
......@@ -188,7 +188,7 @@ void CControlSettingsMovement::refresh()
if(!mpButtonList.empty())
mpButtonList.clear();
std::map<InputCommands, std::string>::iterator it = mCommandName.begin();
std::map<InputCommand, std::string>::iterator it = mCommandName.begin();
for ( ; it != mCommandName.end(); it++ )
{
const std::string buf = it->second;
......@@ -223,7 +223,7 @@ void CControlSettingsButtons::refresh()
if(!mpButtonList.empty())
mpButtonList.clear();
std::map<InputCommands, std::string>::iterator it = mCommandName.begin();
std::map<InputCommand, std::string>::iterator it = mCommandName.begin();
for ( ; it != mCommandName.end(); it++ )
{
const std::string buf = it->second;
......
......@@ -56,8 +56,13 @@ public:
protected:
int mSelectedPlayer;
<<<<<<< HEAD:src/engine/keen/galaxy/menu/ControlSettings.h
std::vector<GalaxyButton*> mpButtonList;
std::map<InputCommands, std::string> mCommandName;
=======
std::vector<GameButton*> mpButtonList;
std::map<InputCommand, std::string> mCommandName;
>>>>>>> ce7f64a6... Cleanups, fixes:src/engine/core/menu/ControlSettings.h
bool mapping;
};
......
......@@ -91,7 +91,7 @@ void CSaveMenu::ponder(const float deltaT)
{
if( gInput.getPressedCommand(cmd) )
{
std::shared_ptr<CEvent> command(new CommandEvent( static_cast<InputCommands>(cmd) ));
std::shared_ptr<CEvent> command(new CommandEvent( static_cast<InputCommand>(cmd) ));
sendEvent(command);
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment