Files
itgmania212121/stepmania/src/OptionIconRow.cpp
T

138 lines
2.9 KiB
C++
Raw Normal View History

2003-02-16 04:01:45 +00:00
#include "global.h"
2002-09-03 06:33:08 +00:00
/*
-----------------------------------------------------------------------------
Class: OptionIconRow
Desc: A graphic displayed in the OptionIconRow during Dancing.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
#include "OptionIconRow.h"
#include "ThemeManager.h"
#include "PlayerOptions.h"
#include "GameState.h"
#include "RageLog.h"
2002-09-03 06:33:08 +00:00
#define SPACING_X THEME->GetMetricF("OptionIconRow","SpacingX")
#define SPACING_Y THEME->GetMetricF("OptionIconRow","SpacingY")
OptionIconRow::OptionIconRow()
{
2002-11-16 09:12:55 +00:00
for( unsigned i=0; i<NUM_OPTION_COLS; i++ )
2002-09-03 06:33:08 +00:00
{
m_OptionIcon[i].SetXY( i*SPACING_X, i*SPACING_Y );
this->AddChild( &m_OptionIcon[i] );
}
}
struct OptionColumnEntry
{
char szString[30];
int iSlotIndex;
};
const OptionColumnEntry g_OptionColumnEntries[] =
{
2003-04-01 19:31:27 +00:00
{"Boost", 0},
{"Brake", 0},
{"Wave", 0},
{"Expand", 0},
{"Boomerang", 0},
{"Drunk", 1},
{"Dizzy", 1},
{"Mini", 1},
{"Flip", 1},
{"Tornado", 1},
{"Hidden", 2},
{"Sudden", 2},
{"Stealth", 2},
{"Blink", 2},
{"RandomVanish", 2},
2003-04-01 19:31:27 +00:00
{"Mirror", 3},
{"Left", 3},
{"Right", 3},
{"Shuffle", 3},
{"SuperShuffle",3},
{"Little", 4},
{"NoHolds", 4},
{"Dark", 4},
2003-09-06 05:53:51 +00:00
{"Blind", 4},
2003-04-01 19:31:27 +00:00
{"Reverse", 5},
2003-09-06 05:53:51 +00:00
{"Split", 5},
{"Alternate", 5},
2003-04-01 19:31:27 +00:00
{"Incoming", 6},
{"Space", 6},
2003-09-21 18:07:29 +00:00
{"Hallway", 6},
{"Distant", 6},
2003-04-01 19:31:27 +00:00
{"TimingAssist",-1},
};
int OptionToPreferredColumn( CString sOptionText )
{
/* Speedups always go in column 0. digit ... x */
if(sOptionText.GetLength() > 1 &&
isdigit(sOptionText[0]) &&
tolower(sOptionText[sOptionText.GetLength()-1]) == 'x') {
return 0;
}
2003-08-07 10:47:00 +00:00
for( unsigned i=0; i<ARRAYSIZE(g_OptionColumnEntries); i++ )
if( g_OptionColumnEntries[i].szString == sOptionText )
return g_OptionColumnEntries[i].iSlotIndex;
2003-04-25 00:27:30 +00:00
LOG->Warn("Unknown option: '%s'", sOptionText.c_str() );
2003-04-01 19:31:27 +00:00
return 0;
}
2002-09-03 06:33:08 +00:00
void OptionIconRow::Refresh( PlayerNumber pn )
{
// init
unsigned i;
for( i=0; i<NUM_OPTION_COLS; i++ )
m_OptionIcon[i].Load( pn, "", i==0 );
CString sOptions = GAMESTATE->m_PlayerOptions[pn].GetString();
CStringArray asOptions;
split( sOptions, ", ", asOptions, true );
CString asTabs[NUM_OPTION_COLS-1]; // fill these with what will be displayed on the tabs
// for each option, look for the best column to place it in
for( i=0; i<asOptions.size(); i++ )
{
CString sOption = asOptions[i];
int iPerferredCol = OptionToPreferredColumn( sOption );
if( iPerferredCol == -1 )
continue; // skip
// search for a vacant spot
2002-11-16 09:12:55 +00:00
for( unsigned i=iPerferredCol; i<NUM_OPTION_COLS-1; i++ )
{
if( asTabs[i] != "" )
continue;
else
{
asTabs[i] = sOption;
break;
}
}
}
for( i=0; i<NUM_OPTION_COLS-1; i++ )
m_OptionIcon[i+1].Load( pn, asTabs[i], false );
2002-09-03 06:33:08 +00:00
}
void OptionIconRow::DrawPrimitives()
{
ActorFrame::DrawPrimitives();
2002-11-16 09:12:55 +00:00
}