Commit ad93b1df authored by Gerhard Stein's avatar Gerhard Stein

Better controls in Player Selection

parent e80e3d10
...@@ -22,7 +22,7 @@ class CBaseMenu ...@@ -22,7 +22,7 @@ class CBaseMenu
public: public:
enum Property enum Property
{ {
CLOSEABLE, CLOSEABLE,
CANGOBACK CANGOBACK
}; };
......
...@@ -15,10 +15,10 @@ class CSaveMenu : public GameMenu ...@@ -15,10 +15,10 @@ class CSaveMenu : public GameMenu
{ {
public: public:
CSaveMenu(const GsControl::Style &style); CSaveMenu(const GsControl::Style &style);
void refresh(); void refresh() override;
void processSpecific(){} void processSpecific(){}
void ponder(const float deltaT); void ponder(const float deltaT) override;
void sendEvent(std::shared_ptr<CEvent> &command); void sendEvent(std::shared_ptr<CEvent> &command) override;
void release(); void release();
......
...@@ -98,8 +98,10 @@ class CPlayerSpriteVarSelection : public GameMenu ...@@ -98,8 +98,10 @@ class CPlayerSpriteVarSelection : public GameMenu
public: public:
CPlayerSpriteVarSelection(const GsControl::Style style); CPlayerSpriteVarSelection(const GsControl::Style style);
void changeEvent();
// Processes the stuff that the menus have in common // Processes the stuff that the menus have in common
void ponder(const float deltaT); void ponder(const float deltaT) override;
private: private:
...@@ -114,6 +116,7 @@ private: ...@@ -114,6 +116,7 @@ private:
ComboSelection *mpComboSelection = nullptr; ComboSelection *mpComboSelection = nullptr;
GameButton *mpGameButton = nullptr; GameButton *mpGameButton = nullptr;
GameButton *mpChangeButton = nullptr;
}; };
......
...@@ -4,6 +4,21 @@ ...@@ -4,6 +4,21 @@
#include "graphics/GsGraphics.h" #include "graphics/GsGraphics.h"
struct ChangeEvent : InvokeFunctorEvent
{
ChangeEvent(CPlayerSpriteVarSelection &selObj):
mSelObj(selObj) {}
CPlayerSpriteVarSelection &mSelObj;
void operator()() const
{
mSelObj.changeEvent();
}
};
CPlayerSpriteVarSelection:: CPlayerSpriteVarSelection::
CPlayerSpriteVarSelection(const GsControl::Style style) : CPlayerSpriteVarSelection(const GsControl::Style style) :
GameMenu( GsRect<float>(0.25f, 0.2f, 0.5f, 0.5f), style ) GameMenu( GsRect<float>(0.25f, 0.2f, 0.5f, 0.5f), style )
...@@ -33,8 +48,37 @@ CPlayerSpriteVarSelection(const GsControl::Style style) : ...@@ -33,8 +48,37 @@ CPlayerSpriteVarSelection(const GsControl::Style style) :
mpMenuDialog->addControl( mpGameButton, mpMenuDialog->addControl( mpGameButton,
GsRect<float>(0.07f, 0.71f, GsRect<float>(0.07f, 0.71f,
0.1f, 0.8f)); 0.8f, 0.1f));
mpChangeButton = new GameButton( "Change",
new ChangeEvent(*this),
style);
mpMenuDialog->addControl( mpChangeButton,
GsRect<float>(0.07f, 0.81f,
0.8f, 0.1f));
}
void
CPlayerSpriteVarSelection::
changeEvent()
{
mCurIdx++;
if( mCurIdx >= int(mpPlayerBmpVec.size()) )
{
mCurIdx = 0;
}
mBmpBox->setBitmapPtr(mpPlayerBmpVec[mCurIdx]);
// Change data in the event of the game button
auto event = mpGameButton->event();
auto spsv = std::dynamic_pointer_cast<SelectPlayerSpriteVarEvent>(event);
spsv->mSpecialIdx = mCurIdx;
} }
void void
......
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