123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- //===========================================================================//
- // Copyright (C) Microsoft Corporation. All rights reserved. //
- //===========================================================================//
- #ifndef ABUTTON_H
- #define ABUTTON_H
- #include "aSystem.h"
- #include "aFont.h"
- #include "aAnim.h"
- class FitIniFile;
- class aButton : public aObject
- {
- public:
- aButton();
- long init(long xPos, long yPos, long w, long h);
- void destroy();
- virtual void update();
- virtual void render();
- void init( FitIniFile& file, const char* headerName, HGOSFONT3D font = 0 );
-
- aButton& operator=( const aButton& src);
- aButton( const aButton& src);
- virtual void move( float offsetX, float offsetY );
- void setHoldTime( float newTime ) { holdTime = newTime; }
- virtual bool pointInside(long xPos, long yPos) const;
-
-
- void press( bool );
- void toggle();
-
- void disable( bool );
- bool isEnabled();
- bool isPressed() { return state == PRESSED; }
- void makeAmbiguous( bool bAmbiguous );
- void setSinglePress(){ singlePress = true; }
- void setMessageOnRelease() { messageOnRelease = true; }
-
- void hide( bool );
- int getID();
- void setID( int ID );
- void setText( int newID ) { data.textID = newID; }
- void setPressFX( int newFX ){ clickSFX = newFX; }
- void setHighlightFX( int newFX ){ highlightSFX = newFX; }
- void setDisabledFX( int newFX ){ disabledSFX = newFX; }
- enum States
- {
- ENABLED = 0,
- PRESSED,
- DISABLED,
- AMBIGUOUS,
- HIGHLIGHT,
- HIDDEN
- };
-
-
- protected:
- struct aButtonData
- {
- long ID;
- long textID;
- long textColors[5];
- HGOSFONT3D textFont;
- long textSize; // for ttf
- char fileName[32];
- long stateCoords[5][2];
- long textureWidth;
- long textureHeight;
- int fileWidth;
- int fileHeight;
- bool textureRotated;
- GUI_RECT textRect; // center text in here
- bool outlineText; // draw empty square around text rect
- bool outline; // draw empty square around button
- long textAlign;
- };
- aButtonData data;
- int state;
- bool toggleButton;
- bool singlePress;
- bool messageOnRelease;
- float holdTime;
- long clickSFX;
- long highlightSFX;
- long disabledSFX;
-
- static void makeUVs( gos_VERTEX* vertices, int State, aButtonData& data );
- private:
- void copyData( const aButton& src );
-
- };
- class aAnimButton : public aButton
- {
- public:
- aAnimButton();
- void init( FitIniFile& file, const char* headerName, HGOSFONT3D font = 0 );
- virtual void update();
- virtual void render();
- void destroy();
- aAnimButton& operator=( const aAnimButton& src);
- aAnimButton( const aAnimButton& src );
- void setAnimationInfo( aAnimation* normal, aAnimation* highlight,
- aAnimation* pressed, aAnimation* disabled );
- void animateChildren( bool bAnimate ){ bAnimateChildren = bAnimate; }
- private:
- aAnimation normalData;
- aAnimation highlightData;
- aAnimation pressedData;
- aAnimation disabledData;
- void update( const aAnimation& data );
- bool animateText;
- bool animateBmp;
- bool bAnimateChildren;
- void copyData( const aAnimButton& src );
- };
- #endif
|