Added first draft of an interactive button. Needs to handle addition of images a little better
refined detailed info window for stats display removed PSP button for Touch interfaces (currently only iOS and Android) on deck selection screens to not break the core engine and reduce some more complex code, I created a new vector in the JController object. mButtons. This vector will contain all the valid buttons for a given screen. The appropriate Add/Remove methods have been updated to account for this new vector.
This commit is contained in:
@@ -9,9 +9,13 @@
|
||||
#include "hge/hgeparticle.h"
|
||||
#include "DeckMetaData.h"
|
||||
#include "TextScroller.h"
|
||||
#include "InteractiveButton.h"
|
||||
|
||||
class DeckMenu: public JGuiController
|
||||
{
|
||||
private:
|
||||
InteractiveButton *dismissButton;
|
||||
|
||||
protected:
|
||||
|
||||
float mHeight, mWidth, mX, mY;
|
||||
@@ -62,14 +66,14 @@ public:
|
||||
DeckMetaData * getSelectedDeck();
|
||||
void enableDisplayDetailsOverride();
|
||||
bool showDetailsScreen();
|
||||
|
||||
virtual bool isClosed() const { return mClosed; }
|
||||
virtual int getSelectedDeckId() const { return mSelectedDeckId; }
|
||||
|
||||
bool isClosed() const { return mClosed; }
|
||||
int getSelectedDeckId() const { return mSelectedDeckId; }
|
||||
|
||||
void Render();
|
||||
void Update(float dt);
|
||||
void Add(int id, const char * Text, string desc = "", bool forceFocus = false, DeckMetaData *deckMetaData = NULL);
|
||||
void Close();
|
||||
virtual void Render();
|
||||
virtual void Update(float dt);
|
||||
virtual void Add(int id, const char * Text, string desc = "", bool forceFocus = false, DeckMetaData *deckMetaData = NULL);
|
||||
virtual void Close();
|
||||
void updateScroller();
|
||||
void RenderBackground();
|
||||
void RenderDeckManaColors();
|
||||
|
||||
@@ -15,7 +15,7 @@ private:
|
||||
bool mScrollEnabled;
|
||||
bool mDisplayInitialized;
|
||||
|
||||
DeckMenu* parent;
|
||||
DeckMenu* deckController;
|
||||
float mTitleResetWidth;
|
||||
|
||||
protected:
|
||||
@@ -43,6 +43,7 @@ public:
|
||||
virtual bool Leaving(JButton key);
|
||||
virtual bool ButtonPressed();
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
virtual JGuiController* getParent() const;
|
||||
virtual void RenderWithOffset(float yOffset);
|
||||
|
||||
};
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// InteractiveButton.h
|
||||
//
|
||||
// Created by Michael Nguyen on 1/23/12.
|
||||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef wagic_InteractiveButton_h
|
||||
#define wagic_InteractiveButton_h
|
||||
|
||||
#include <string>
|
||||
#include <JLBFont.h>
|
||||
#include <JGui.h>
|
||||
#include "WResource_Fwd.h"
|
||||
#include "SimpleButton.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
#define SCALE_SELECTED 1.2f
|
||||
#define SCALE_NORMAL 1.0f
|
||||
|
||||
class InteractiveButton: public SimpleButton
|
||||
{
|
||||
private:
|
||||
JQuadPtr buttonImage;
|
||||
JButton mActionKey;
|
||||
|
||||
public:
|
||||
InteractiveButton(JGuiController* _parent, int id, int fontId, string text, float x, float y, JButton actionKey, bool hasFocus = false, bool autoTranslate = false);
|
||||
|
||||
virtual void Entering();
|
||||
virtual bool ButtonPressed();
|
||||
virtual void setImage( const JQuadPtr imagePtr, float xOffset = 0, float yOffset = 0);
|
||||
virtual void checkUserClick();
|
||||
//virtual void Update(float dt);
|
||||
virtual void Render();
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -23,4 +23,8 @@
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#if defined (IOS) || defined (ANDROID)
|
||||
#define TOUCH_ENABLED
|
||||
#endif
|
||||
|
||||
#endif //PRECOMPILEDHEADER_H
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
//
|
||||
// SimpleButton.h
|
||||
// - base class for creating buttons/links inside of the game engine.
|
||||
//
|
||||
// Created by Michael Nguyen on 1/21/12.
|
||||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef wagic_SimpleButton_h
|
||||
#define wagic_SimpleButton_h
|
||||
|
||||
#include <string>
|
||||
#include <JLBFont.h>
|
||||
#include <JGui.h>
|
||||
|
||||
using std::string;
|
||||
|
||||
#define SCALE_SELECTED 1.2f
|
||||
#define SCALE_NORMAL 1.0f
|
||||
|
||||
class SimpleButton: public JGuiObject
|
||||
{
|
||||
private:
|
||||
|
||||
float mScale;
|
||||
float mTargetScale;
|
||||
bool mHasFocus;
|
||||
bool mIsValidSelection;
|
||||
float mX;
|
||||
float mY;
|
||||
|
||||
protected:
|
||||
float mYOffset;
|
||||
JGuiController* parent;
|
||||
int mFontId;
|
||||
string mText;
|
||||
float mXOffset;
|
||||
|
||||
public:
|
||||
|
||||
SimpleButton(int id);
|
||||
SimpleButton(JGuiController* _parent, int id, int fontId, string text, float x, float y, bool hasFocus = false, bool autoTranslate = false);
|
||||
|
||||
virtual float getScale() const;
|
||||
virtual float getTargetScale() const;
|
||||
virtual JGuiController* getParent() const;
|
||||
|
||||
virtual int getFontId() const;
|
||||
virtual void setFontId( const int& fontId );
|
||||
virtual void setX( const float& x ) { mX = x; };
|
||||
virtual void setY( const float& y ) { mY = y; };
|
||||
|
||||
virtual void setIsSelectionValid( bool validSelection );
|
||||
virtual void setFocus(bool value);
|
||||
virtual void setText( const string& text);
|
||||
|
||||
virtual bool isSelectionValid() const;
|
||||
virtual bool hasFocus() const;
|
||||
virtual string getText() const;
|
||||
float getX() const;
|
||||
float getY() const;
|
||||
virtual void checkUserClick();
|
||||
|
||||
virtual float GetWidth();
|
||||
virtual void Relocate(float x, float y);
|
||||
|
||||
virtual void RenderWithOffset(float yOffset);
|
||||
virtual void Render();
|
||||
virtual void Update(float dt);
|
||||
|
||||
virtual void Entering();
|
||||
virtual bool Leaving(JButton key);
|
||||
virtual bool ButtonPressed();
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
virtual bool getTopLeft(float& top, float& left)
|
||||
{
|
||||
top = mY + mYOffset;
|
||||
left = mX;
|
||||
return true;
|
||||
}
|
||||
;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -39,17 +39,17 @@ public:
|
||||
bool isMultipleChoice;
|
||||
SimpleMenu(JGE*, int id, JGuiListener* listener, int fontId, float x, float y, const char * _title = "", int _maxItems = 7, bool centerHorizontal = true, bool centerVertical = true);
|
||||
virtual ~SimpleMenu();
|
||||
void Render();
|
||||
void Update(float dt);
|
||||
void Add(int id, const char * Text, string desc = "", bool forceFocus = false);
|
||||
virtual void Render();
|
||||
virtual void Update(float dt);
|
||||
virtual void Add(int id, const char * Text, string desc = "", bool forceFocus = false);
|
||||
int getmCurr(){return mCurr;}
|
||||
float getWidth(){return mWidth; }
|
||||
void Close();
|
||||
virtual void Close();
|
||||
|
||||
void RecenterMenu();
|
||||
|
||||
float selectionTargetY;
|
||||
bool isClosed()
|
||||
virtual bool isClosed() const
|
||||
{
|
||||
return mClosed;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <string>
|
||||
#include <JLBFont.h>
|
||||
#include <JGui.h>
|
||||
#include "SimpleButton.h"
|
||||
#include "SimpleMenu.h"
|
||||
|
||||
using std::string;
|
||||
@@ -11,65 +12,20 @@ using std::string;
|
||||
#define SCALE_SELECTED 1.2f
|
||||
#define SCALE_NORMAL 1.0f
|
||||
|
||||
class SimpleMenuItem: public JGuiObject
|
||||
class SimpleMenuItem: public SimpleButton
|
||||
{
|
||||
private:
|
||||
|
||||
SimpleMenu* parent;
|
||||
float mScale;
|
||||
float mTargetScale;
|
||||
bool mHasFocus;
|
||||
bool mIsValidSelection;
|
||||
float mX;
|
||||
float mY;
|
||||
|
||||
protected:
|
||||
int mFontId;
|
||||
string mText;
|
||||
static float mYOffset;
|
||||
float mXOffset;
|
||||
string mDescription;
|
||||
|
||||
public:
|
||||
SimpleMenuItem(int id);
|
||||
SimpleMenuItem(SimpleMenu* _parent, int id, int fontId, string text, float x, float y, bool hasFocus = false, bool autoTranslate = false);
|
||||
|
||||
virtual int getFontId() const;
|
||||
virtual void setFontId( const int& fontId );
|
||||
virtual void setX( const float& x ) { mX = x; };
|
||||
virtual void setY( const float& y ) { mY = y; };
|
||||
|
||||
virtual void setIsSelectionValid( bool validSelection );
|
||||
virtual void setFocus(bool value);
|
||||
virtual void setDescription( const string& desc );
|
||||
virtual void setText( const string& text);
|
||||
|
||||
virtual bool isSelectionValid() const;
|
||||
virtual bool hasFocus() const;
|
||||
virtual string getDescription() const;
|
||||
virtual string getText() const;
|
||||
float getX() const;
|
||||
float getY() const;
|
||||
virtual void checkUserClick();
|
||||
|
||||
virtual float GetWidth() const;
|
||||
virtual void Relocate(float x, float y);
|
||||
|
||||
virtual void RenderWithOffset(float yOffset);
|
||||
virtual void Render();
|
||||
virtual void Update(float dt);
|
||||
|
||||
virtual void Entering();
|
||||
virtual bool Leaving(JButton key);
|
||||
virtual bool ButtonPressed();
|
||||
virtual void setDescription( const string& desc );
|
||||
virtual string getDescription() const;
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
virtual bool getTopLeft(float& top, float& left)
|
||||
{
|
||||
top = mY + mYOffset;
|
||||
left = mX;
|
||||
return true;
|
||||
}
|
||||
;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -35,7 +35,7 @@ private:
|
||||
public:
|
||||
bool autoTranslate;
|
||||
|
||||
SimplePopup(int id, JGuiListener* listener, const int fontId, const char * _title = "", DeckMetaData* deckInfo = NULL, MTGAllCards * collection = NULL);
|
||||
SimplePopup(int id, JGuiListener* listener, const int fontId, const char * _title = "", DeckMetaData* deckInfo = NULL, MTGAllCards * collection = NULL, int x = 364, int y = 235);
|
||||
~SimplePopup(void);
|
||||
void drawBoundingBox(float x, float y, float width, float height);
|
||||
bool isClosed()
|
||||
|
||||
Reference in New Issue
Block a user