remove decorative header from icon row, load separate graphics for each icon type instead of multi-frame sprites
This commit is contained in:
@@ -19,19 +19,23 @@ OptionIcon::OptionIcon()
|
|||||||
|
|
||||||
OptionIcon::OptionIcon( const OptionIcon &cpy ):
|
OptionIcon::OptionIcon( const OptionIcon &cpy ):
|
||||||
ActorFrame(cpy),
|
ActorFrame(cpy),
|
||||||
m_text(cpy.m_text),
|
m_sprFilled(cpy.m_sprFilled),
|
||||||
m_spr(cpy.m_spr)
|
m_sprEmpty(cpy.m_sprEmpty),
|
||||||
|
m_text(cpy.m_text)
|
||||||
{
|
{
|
||||||
this->RemoveAllChildren();
|
this->RemoveAllChildren();
|
||||||
this->AddChild( &m_spr );
|
this->AddChild( m_sprFilled );
|
||||||
|
this->AddChild( m_sprEmpty );
|
||||||
this->AddChild( &m_text );
|
this->AddChild( &m_text );
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionIcon::Load( RString sType )
|
void OptionIcon::Load( RString sType )
|
||||||
{
|
{
|
||||||
m_spr.Load( THEME->GetPathG(sType,"icon 3x2") );
|
m_sprFilled.Load( THEME->GetPathG(sType,"icon filled") );
|
||||||
m_spr.StopAnimating();
|
this->AddChild( m_sprFilled );
|
||||||
this->AddChild( &m_spr );
|
|
||||||
|
m_sprEmpty.Load( THEME->GetPathG(sType,"icon empty") );
|
||||||
|
this->AddChild( m_sprEmpty );
|
||||||
|
|
||||||
m_text.LoadFromFont( THEME->GetPathF(sType,"icon") );
|
m_text.LoadFromFont( THEME->GetPathF(sType,"icon") );
|
||||||
m_text.SetShadowLength( 0 );
|
m_text.SetShadowLength( 0 );
|
||||||
@@ -41,9 +45,11 @@ void OptionIcon::Load( RString sType )
|
|||||||
((Actor&)m_text).SetHorizAlign( (HorizAlign)TEXT_H_ALIGN );
|
((Actor&)m_text).SetHorizAlign( (HorizAlign)TEXT_H_ALIGN );
|
||||||
((Actor&)m_text).SetVertAlign( (VertAlign)TEXT_V_ALIGN );
|
((Actor&)m_text).SetVertAlign( (VertAlign)TEXT_V_ALIGN );
|
||||||
this->AddChild( &m_text );
|
this->AddChild( &m_text );
|
||||||
|
|
||||||
|
Set("");
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionIcon::Set( PlayerNumber pn, const RString &_sText, bool bHeader )
|
void OptionIcon::Set( const RString &_sText )
|
||||||
{
|
{
|
||||||
RString sText = _sText;
|
RString sText = _sText;
|
||||||
|
|
||||||
@@ -65,10 +71,10 @@ void OptionIcon::Set( PlayerNumber pn, const RString &_sText, bool bHeader )
|
|||||||
sText.Replace( " ", "\n" );
|
sText.Replace( " ", "\n" );
|
||||||
|
|
||||||
bool bVacant = (sText=="");
|
bool bVacant = (sText=="");
|
||||||
int iState = pn*3 + (bHeader?0:(bVacant?1:2));
|
m_sprFilled->SetVisible( !bVacant );
|
||||||
m_spr.SetState( iState );
|
m_sprEmpty->SetVisible( bVacant );
|
||||||
|
|
||||||
m_text.SetText( bHeader ? RString("") : sText );
|
m_text.SetText( sText );
|
||||||
m_text.SetZoom( TEXT_ZOOM );
|
m_text.SetZoom( TEXT_ZOOM );
|
||||||
m_text.CropToWidth( TEXT_WIDTH );
|
m_text.CropToWidth( TEXT_WIDTH );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#define OPTION_ICON_H
|
#define OPTION_ICON_H
|
||||||
|
|
||||||
#include "ActorFrame.h"
|
#include "ActorFrame.h"
|
||||||
#include "Sprite.h"
|
#include "AutoActor.h"
|
||||||
#include "BitmapText.h"
|
#include "BitmapText.h"
|
||||||
#include "PlayerNumber.h"
|
#include "PlayerNumber.h"
|
||||||
|
|
||||||
@@ -15,11 +15,12 @@ public:
|
|||||||
OptionIcon();
|
OptionIcon();
|
||||||
OptionIcon( const OptionIcon &cpy );
|
OptionIcon( const OptionIcon &cpy );
|
||||||
void Load( RString sType );
|
void Load( RString sType );
|
||||||
void Set( PlayerNumber pn, const RString &sText, bool bHeader = false );
|
void Set( const RString &sText );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BitmapText m_text;
|
BitmapText m_text;
|
||||||
Sprite m_spr;
|
AutoActor m_sprFilled;
|
||||||
|
AutoActor m_sprEmpty;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -8,22 +8,35 @@
|
|||||||
#include "ActorUtil.h"
|
#include "ActorUtil.h"
|
||||||
#include "XmlFile.h"
|
#include "XmlFile.h"
|
||||||
#include "LuaManager.h"
|
#include "LuaManager.h"
|
||||||
|
#include "Foreach.h"
|
||||||
|
|
||||||
REGISTER_ACTOR_CLASS( OptionIconRow )
|
REGISTER_ACTOR_CLASS( OptionIconRow )
|
||||||
|
|
||||||
#define SPACING_X THEME->GetMetricF("OptionIconRow","SpacingX")
|
#define SPACING_X THEME->GetMetricF("OptionIconRow","SpacingX")
|
||||||
#define SPACING_Y THEME->GetMetricF("OptionIconRow","SpacingY")
|
#define SPACING_Y THEME->GetMetricF("OptionIconRow","SpacingY")
|
||||||
|
#define NUM_OPTION_ICONS THEME->GetMetricF("OptionIconRow","NumOptionIcons")
|
||||||
|
|
||||||
|
|
||||||
OptionIconRow::OptionIconRow()
|
OptionIconRow::OptionIconRow()
|
||||||
{
|
{
|
||||||
for( unsigned i=0; i<NUM_OPTION_COLS; i++ )
|
for( unsigned i=0; i<NUM_OPTION_ICONS; i++ )
|
||||||
{
|
{
|
||||||
m_OptionIcon[i].SetXY( i*SPACING_X, i*SPACING_Y );
|
OptionIcon *p = new OptionIcon;
|
||||||
this->AddChild( &m_OptionIcon[i] );
|
p->SetXY( i*SPACING_X, i*SPACING_Y );
|
||||||
|
m_vpOptionIcon.push_back( p );
|
||||||
|
this->AddChild( p );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OptionIconRow::~OptionIconRow()
|
||||||
|
{
|
||||||
|
FOREACH( OptionIcon*, m_vpOptionIcon, p )
|
||||||
|
{
|
||||||
|
SAFE_DELETE( *p );
|
||||||
|
}
|
||||||
|
this->RemoveAllChildren();
|
||||||
|
}
|
||||||
|
|
||||||
void OptionIconRow::LoadFromNode( const XNode* pNode )
|
void OptionIconRow::LoadFromNode( const XNode* pNode )
|
||||||
{
|
{
|
||||||
Load();
|
Load();
|
||||||
@@ -95,8 +108,8 @@ int OptionToPreferredColumn( RString sOptionText )
|
|||||||
|
|
||||||
void OptionIconRow::Load()
|
void OptionIconRow::Load()
|
||||||
{
|
{
|
||||||
for( unsigned i=0; i<NUM_OPTION_COLS; i++ )
|
FOREACH( OptionIcon*, m_vpOptionIcon, p )
|
||||||
m_OptionIcon[i].Load( "OptionIconRow" );
|
(*p)->Load( "OptionIconRow" );
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionIconRow::SetFromGameState( PlayerNumber pn )
|
void OptionIconRow::SetFromGameState( PlayerNumber pn )
|
||||||
@@ -104,39 +117,39 @@ void OptionIconRow::SetFromGameState( PlayerNumber pn )
|
|||||||
// init
|
// init
|
||||||
|
|
||||||
RString sOptions = GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions.GetStage().GetString();
|
RString sOptions = GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions.GetStage().GetString();
|
||||||
vector<RString> asOptions;
|
vector<RString> vsOptions;
|
||||||
split( sOptions, ", ", asOptions, true );
|
split( sOptions, ", ", vsOptions, true );
|
||||||
|
|
||||||
|
vector<RString> vsText; // fill these with what will be displayed on the tabs
|
||||||
RString asTabs[NUM_OPTION_COLS-1]; // fill these with what will be displayed on the tabs
|
vsText.resize( m_vpOptionIcon.size() );
|
||||||
|
|
||||||
// for each option, look for the best column to place it in
|
// for each option, look for the best column to place it in
|
||||||
for( unsigned i=0; i<asOptions.size(); i++ )
|
for( unsigned i=0; i<vsOptions.size(); i++ )
|
||||||
{
|
{
|
||||||
RString sOption = asOptions[i];
|
RString sOption = vsOptions[i];
|
||||||
int iPerferredCol = OptionToPreferredColumn( sOption );
|
int iPerferredCol = OptionToPreferredColumn( sOption );
|
||||||
|
clamp( iPerferredCol, 0, (int)m_vpOptionIcon.size()-1 );
|
||||||
|
|
||||||
if( iPerferredCol == -1 )
|
if( iPerferredCol == -1 )
|
||||||
continue; // skip
|
continue; // skip
|
||||||
|
|
||||||
// search for a vacant spot
|
// search for a vacant spot
|
||||||
for( unsigned i=iPerferredCol; i<NUM_OPTION_COLS-1; i++ )
|
for( unsigned i=iPerferredCol; i<NUM_OPTION_ICONS; i++ )
|
||||||
|
{
|
||||||
|
if( vsText[i] != "" )
|
||||||
{
|
{
|
||||||
if( asTabs[i] != "" )
|
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
asTabs[i] = sOption;
|
vsText[i] = sOption;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for( unsigned i=0; i<NUM_OPTION_COLS; i++ )
|
for( unsigned i=0; i<vsOptions.size(); i++ )
|
||||||
if( i == 0 )
|
m_vpOptionIcon[i]->Set( vsText[i] );
|
||||||
m_OptionIcon[i].Set( pn, "", true );
|
|
||||||
else
|
|
||||||
m_OptionIcon[i].Set( pn, asTabs[i-1], false );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// lua start
|
// lua start
|
||||||
|
|||||||
@@ -9,13 +9,11 @@
|
|||||||
class PlayerOptions;
|
class PlayerOptions;
|
||||||
struct lua_State;
|
struct lua_State;
|
||||||
|
|
||||||
const unsigned NUM_OPTION_COLS = 8;
|
|
||||||
|
|
||||||
|
|
||||||
class OptionIconRow : public ActorFrame
|
class OptionIconRow : public ActorFrame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OptionIconRow();
|
OptionIconRow();
|
||||||
|
~OptionIconRow();
|
||||||
|
|
||||||
void Load();
|
void Load();
|
||||||
virtual void LoadFromNode( const XNode* pNode );
|
virtual void LoadFromNode( const XNode* pNode );
|
||||||
@@ -28,7 +26,7 @@ public:
|
|||||||
virtual void PushSelf( lua_State *L );
|
virtual void PushSelf( lua_State *L );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
OptionIcon m_OptionIcon[NUM_OPTION_COLS];
|
vector<OptionIcon*> m_vpOptionIcon;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -667,7 +667,7 @@ void OptionRow::SetOptionIcon( PlayerNumber pn, const RString &sText, GameComman
|
|||||||
msg.SetParam( "GameCommand", &gc );
|
msg.SetParam( "GameCommand", &gc );
|
||||||
m_sprBullet->HandleMessage( msg );
|
m_sprBullet->HandleMessage( msg );
|
||||||
if( m_OptionIcons[pn] != NULL )
|
if( m_OptionIcons[pn] != NULL )
|
||||||
m_OptionIcons[pn]->Set( pn, sText, false );
|
m_OptionIcons[pn]->Set( sText );
|
||||||
}
|
}
|
||||||
|
|
||||||
const BitmapText &OptionRow::GetTextItemForRow( PlayerNumber pn, int iChoiceOnRow ) const
|
const BitmapText &OptionRow::GetTextItemForRow( PlayerNumber pn, int iChoiceOnRow ) const
|
||||||
|
|||||||
Reference in New Issue
Block a user