change sprBullet to an AutoActor

This commit is contained in:
Chris Danford
2005-07-16 07:01:48 +00:00
parent ce4156625d
commit 146c505c5a
6 changed files with 64 additions and 25 deletions
+31 -11
View File
@@ -63,7 +63,6 @@ OptionRow::OptionRow( const OptionRowType *pSource )
m_pParentType = pSource;
m_pHand = NULL;
m_sprBullet = NULL;
m_textTitle = NULL;
ZERO( m_OptionIcons );
@@ -108,13 +107,15 @@ void OptionRow::DetachHandler()
void OptionRowType::Load( const CString &sType )
{
m_sType = sType;
m_textItemParent.LoadFromFont( THEME->GetPathF(sType,"item") );
m_UnderlineParent.Load( sType, OptionsCursor::underline );
m_textTitle.LoadFromFont( THEME->GetPathF(sType,"title") );
m_sprBullet.Load( THEME->GetPathG(sType,"bullet") );
//m_sprBullet.Load( THEME->GetPathG(sType,"bullet") );
m_OptionIcon.Load( sType );
ARROWS_X .Load(sType,"ArrowsX");
BULLET_X .Load(sType,"BulletX");
LABELS_X .Load(sType,"LabelsX");
LABELS_ON_COMMAND .Load(sType,"LabelsOnCommand");
LABEL_GAIN_FOCUS_COMMAND .Load(sType,"LabelGainFocusCommand");
@@ -234,7 +235,7 @@ void OptionRow::InitText()
m_textTitle = new BitmapText( m_pParentType->m_textTitle );
m_Frame.AddChild( m_textTitle );
m_sprBullet = new Sprite( m_pParentType->m_sprBullet );
m_sprBullet.Load( THEME->GetPathG(m_pParentType->m_sType,"bullet") );
m_sprBullet->SetDrawOrder(-1); // under title
m_Frame.AddChild( m_sprBullet );
@@ -248,7 +249,9 @@ void OptionRow::InitText()
m_OptionIcons[p]->RunCommands( m_pParentType->ICONS_ON_COMMAND );
m_Frame.AddChild( m_OptionIcons[p] );
SetOptionIcon( p, "" );
GameCommand gc;
SetOptionIcon( p, "", gc );
}
break;
case ROW_EXIT:
@@ -375,7 +378,7 @@ void OptionRow::InitText()
m_textTitle->SetX( m_pParentType->LABELS_X );
m_textTitle->RunCommands( m_pParentType->LABELS_ON_COMMAND );
m_sprBullet->SetX( m_pParentType->ARROWS_X );
m_sprBullet->SetX( m_pParentType->BULLET_X );
break;
case OptionRow::ROW_EXIT:
m_textTitle->SetHidden( true );
@@ -428,6 +431,7 @@ void OptionRow::AfterImportOptions()
}
}
//
// HACK: Set focus to one item in the row, which is "go down"
//
@@ -569,7 +573,8 @@ void OptionRow::UpdateEnabledDisabled()
if( m_bHidden )
color.a = 0;
m_sprBullet->SetGlobalDiffuseColor( color );
if( m_sprBullet.IsLoaded() )
m_sprBullet->SetGlobalDiffuseColor( color );
m_textTitle->SetGlobalDiffuseColor( color );
@@ -653,18 +658,33 @@ void OptionRow::UpdateEnabledDisabled()
if( m_sprBullet->DestTweenState().diffuse[0] != color )
{
m_sprBullet->StopTweening();
m_textTitle->StopTweening();
m_sprBullet->BeginTweening( m_pParentType->TWEEN_SECONDS );
m_textTitle->BeginTweening( m_pParentType->TWEEN_SECONDS );
m_sprBullet->SetDiffuseAlpha( color.a );
m_textTitle->SetDiffuseAlpha( color.a );
if( m_sprBullet.IsLoaded() )
{
m_sprBullet->StopTweening();
m_sprBullet->BeginTweening( m_pParentType->TWEEN_SECONDS );
m_sprBullet->SetDiffuseAlpha( color.a );
}
}
}
void OptionRow::SetOptionIcon( PlayerNumber pn, const CString &sText )
void OptionRow::SetOptionIcon( PlayerNumber pn, const CString &sText, GameCommand &gc )
{
// update bullet
Lua *L = LUA->Get();
gc.PushSelf( L );
GAMESTATE->m_Environment->Set( L, "ThisGameCommand" );
LUA->Release( L );
m_sprBullet->PlayCommand( "Refresh" );
m_OptionIcons[pn]->Set( pn, sText, false );
L = LUA->Get();
GAMESTATE->m_Environment->Unset( L, "ThisGameCommand" );
LUA->Release( L );
}
BitmapText &OptionRow::GetTextItemForRow( PlayerNumber pn, int iChoiceOnRow )
+10 -4
View File
@@ -8,8 +8,10 @@
#include "OptionsCursor.h"
#include "OptionIcon.h"
#include "ThemeMetric.h"
#include "AutoActor.h"
class OptionRowHandler;
class GameCommand;
enum SelectType
{
@@ -88,14 +90,16 @@ public:
void Load( const CString &sType );
private:
CString m_sType;
BitmapText m_textItemParent;
OptionsCursor m_UnderlineParent;
Sprite m_sprBullet;
//Sprite m_sprBullet;
BitmapText m_textTitle;
OptionIcon m_OptionIcon;
// metrics
ThemeMetric<float> ARROWS_X;
ThemeMetric<float> BULLET_X;
ThemeMetric<float> LABELS_X;
ThemeMetric<apActorCommands> LABELS_ON_COMMAND;
ThemeMetric<apActorCommands> LABEL_GAIN_FOCUS_COMMAND;
@@ -131,7 +135,8 @@ public:
void Clear();
void LoadNormal( const OptionRowDefinition &def, OptionRowHandler *pHand, bool bFirstItemGoesDown );
void LoadExit();
void SetOptionIcon( PlayerNumber pn, const CString &sText );
void SetOptionIcon( PlayerNumber pn, const CString &sText, GameCommand &gc );
void ImportOptions( const vector<PlayerNumber> &vpns );
int ExportOptions( const vector<PlayerNumber> &vpns, bool bRowHasFocus[NUM_PLAYERS] );
@@ -215,7 +220,8 @@ protected:
vector<BitmapText *> m_textItems; // size depends on m_bRowIsLong and which players are joined
vector<OptionsCursor *> m_Underline[NUM_PLAYERS]; // size depends on m_bRowIsLong and which players are joined
Sprite *m_sprBullet;
AutoActor m_sprBullet;
BitmapText *m_textTitle;
OptionIcon *m_OptionIcons[NUM_PLAYERS];
+12 -4
View File
@@ -24,6 +24,12 @@
#define ENTRY_MODE(s,i) THEME->GetMetric ("ScreenOptionsMaster",ssprintf("%s,%i",(s).c_str(),(i+1)))
#define ENTRY_DEFAULT(s) THEME->GetMetric ("ScreenOptionsMaster",(s) + "Default")
void OptionRowHandler::GetIconTextAndGameCommand( const OptionRowDefinition &def, int iFirstSelection, CString &sIconTextOut, GameCommand &gcOut ) const
{
sIconTextOut = "";
gcOut.Init();
}
static void SelectExactlyOne( int iSelection, vector<bool> &vbSelectedOut )
{
ASSERT_M( iSelection >= 0 && iSelection < (int) vbSelectedOut.size(),
@@ -239,16 +245,18 @@ public:
return 0;
}
virtual CString GetIconText( const OptionRowDefinition &def, int iFirstSelection ) const
virtual void GetIconTextAndGameCommand( const OptionRowDefinition &def, int iFirstSelection, CString &sIconTextOut, GameCommand &gcOut ) const
{
return m_bUseModNameForIcon ?
sIconTextOut = m_bUseModNameForIcon ?
ListEntries[iFirstSelection].m_sModifiers :
def.m_vsChoices[iFirstSelection];
gcOut = ListEntries[iFirstSelection];
}
virtual bool HasScreen( int iChoice ) const
{
const GameCommand &mc = ListEntries[iChoice];
return !mc.m_sScreen.empty();
const GameCommand &gc = ListEntries[iChoice];
return !gc.m_sScreen.empty();
}
void FillNoteSkins( OptionRowDefinition &defOut, CString sParam )
+1 -1
View File
@@ -28,7 +28,7 @@ public:
virtual void ImportOption( const OptionRowDefinition &row, const vector<PlayerNumber> &vpns, vector<bool> vbSelectedOut[NUM_PLAYERS] ) const = 0;
/* Returns an OPT mask. */
virtual int ExportOption( const OptionRowDefinition &def, const vector<PlayerNumber> &vpns, const vector<bool> vbSelected[NUM_PLAYERS] ) const = 0;
virtual CString GetIconText( const OptionRowDefinition &def, int iFirstSelection ) const { return ""; }
virtual void GetIconTextAndGameCommand( const OptionRowDefinition &def, int iFirstSelection, CString &sIconTextOut, GameCommand &gcOut ) const;
virtual bool HasScreen( int iChoice ) const { return false; }
};
+8 -4
View File
@@ -195,9 +195,9 @@ void ScreenOptions::Init()
}
}
void ScreenOptions::SetOptionIcon( PlayerNumber pn, int iRow, CString sText )
void ScreenOptions::SetOptionIcon( PlayerNumber pn, int iRow, CString sText, GameCommand &gc )
{
m_pRows[iRow]->SetOptionIcon( pn, sText );
m_pRows[iRow]->SetOptionIcon( pn, sText, gc );
}
void ScreenOptions::InitMenu( const vector<OptionRowDefinition> &vDefs, const vector<OptionRowHandler*> &vHands )
@@ -342,11 +342,15 @@ CString ScreenOptions::GetExplanationText( int iRow ) const
{
OptionRow &row = *m_pRows[iRow];
bool bAllowExplanation = row.GetRowDef().m_bAllowExplanation;
bool bShowExplanations = bAllowExplanation && SHOW_EXPLANATIONS.GetValue();
if( !bShowExplanations )
return "";
CString sLineName = row.GetRowDef().m_sName;
ASSERT( !sLineName.empty() );
bool bAllowExplanation = row.GetRowDef().m_bAllowExplanation;
return (bAllowExplanation && SHOW_EXPLANATIONS.GetValue()) ? OPTION_EXPLANATION(sLineName) : "";
return OPTION_EXPLANATION(sLineName);
}
BitmapText &ScreenOptions::GetTextItemForRow( PlayerNumber pn, int iRow, int iChoiceOnRow )
+2 -1
View File
@@ -83,7 +83,8 @@ protected:
bool AllAreOnLastRow() const;
protected: // derived classes need access to these
void SetOptionIcon( PlayerNumber pn, int iRow, CString sText );
void SetOptionIcon( PlayerNumber pn, int iRow, CString sText, GameCommand &gc );
enum Navigation { NAV_THREE_KEY, NAV_THREE_KEY_MENU, NAV_FIVE_KEY, NAV_TOGGLE_THREE_KEY, NAV_TOGGLE_FIVE_KEY };
void SetNavigation( Navigation nav ) { m_OptionsNavigation = nav; }
void SetInputMode( InputMode im ) { m_InputMode = im; }