void LinkedOptionsMenu::SetChoices( const CStringArray &asChoices ) { ClearChoices(); for( unsigned i = 0; i < asChoices.size(); i++ ) { CString ch = asChoices[i]; BitmapText *bt = new BitmapText; m_Rows.push_back( bt ); bt->LoadFromFont( THEME->GetPathF( m_sName, "menutext" ) ); bt->SetName( "Row" ); bt->SetXY( ROW_OFFSET_X, ROW_OFFSET_Y + (ROW_SPACING_Y * (float)(i % ROWS_PER_PAGE)) ); bt->SetText( ch ); m_Frame.AddChild( bt ); ON_COMMAND( *bt ); } // show first page of choices for( unsigned i = 0; i < asChoices.size() && i < (unsigned)ROWS_PER_PAGE; i++ ) { m_Rows[i]->PlayCommand("TweenOn"); } m_iCurPage = 0; if ( asChoices.size() > (unsigned)ROWS_PER_PAGE ) { m_sprIndicatorDown.PlayCommand("TweenOn"); m_bIndTweenedOn[1] = true; } if ( m_Rows.size() > 0 ) { if ( m_bFocus ) m_Cursor.PlayCommand( "TweenOn" ); m_Cursor.SetXY( CURSOR_OFFSET_X + m_Rows[0]->GetX(), m_Rows[0]->GetY() ); m_Cursor.SetBarWidth( floor(m_Rows[0]->GetZoomedWidth()) ); m_iCurrentSelection = 0; } else { m_iCurrentSelection = -1; m_Cursor.PlayCommand( "TweenOff" ); if ( m_bFocus ) SCREENMAN->PostMessageToTopScreen( m_smChangeMenu, 0.0f ); } }
// begin ScreenTextEntryVisual void ScreenTextEntryVisual::Init() { ROW_START_X.Load( m_sName, "RowStartX" ); ROW_START_Y.Load( m_sName, "RowStartY" ); ROW_END_X.Load( m_sName, "RowEndX" ); ROW_END_Y.Load( m_sName, "RowEndY" ); ScreenTextEntry::Init(); m_sprCursor.Load( THEME->GetPathG(m_sName,"cursor") ); m_sprCursor->SetName( "Cursor" ); LOAD_ALL_COMMANDS( m_sprCursor ); this->AddChild( m_sprCursor ); // Init keyboard { BitmapText text; text.LoadFromFont( THEME->GetPathF(m_sName,"keyboard") ); text.SetName( "Keys" ); ActorUtil::LoadAllCommands( text, m_sName ); text.PlayCommand( "Init" ); FOREACH_KeyboardRow( r ) { for( int x=0; x<KEYS_PER_ROW; ++x ) { BitmapText *&pbt = m_ptextKeys[r][x]; pbt = text.Copy(); this->AddChild( pbt ); RString s = g_szKeys[r][x]; if( !s.empty() && r == KEYBOARD_ROW_SPECIAL ) s = THEME->GetString( m_sName, s ); pbt->SetText( s ); } } } m_sndChange.Load( THEME->GetPathS(m_sName,"change"), true ); }
void ScreenDebugOverlay::Init() { Screen::Init(); // Init debug mappings // TODO: Arch-specific? { g_Mappings.Clear(); g_Mappings.holdForDebug1 = DeviceInput(DEVICE_KEYBOARD, KEY_F3); g_Mappings.holdForDebug2.MakeInvalid(); g_Mappings.holdForSlow = DeviceInput(DEVICE_KEYBOARD, KEY_ACCENT); g_Mappings.holdForFast = DeviceInput(DEVICE_KEYBOARD, KEY_TAB); g_Mappings.toggleMute = DeviceInput(DEVICE_KEYBOARD, KEY_PAUSE); /* TODO: Find a better way of indicating which option is which here. * Maybe we should take a page from ScreenEdit's menus and make * RowDefs()? */ int i=0; g_Mappings.gameplayButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_F8); g_Mappings.gameplayButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_F7); g_Mappings.gameplayButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_F6); i=0; g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C1); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C2); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C3); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C4); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C5); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C6); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C7); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C8); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C9); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C0); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cq); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cw); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ce); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cr); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ct); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cy); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cu); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ci); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Co); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cp); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ca); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cs); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cd); g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F5)] = 0; g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F6)] = 1; g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F7)] = 2; g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F8)] = 3; } std::map<std::string,int> iNextDebugButton; int iNextGameplayButton = 0; for (auto *p: *g_pvpSubscribers) { std::string sPageName = p->GetPageName(); DeviceInput di; switch( p->GetType() ) { case IDebugLine::all_screens: di = g_Mappings.debugButton[iNextDebugButton[sPageName]++]; break; case IDebugLine::gameplay_only: di = g_Mappings.gameplayButton[iNextGameplayButton++]; break; } p->m_Button = di; if( find(m_asPages.begin(), m_asPages.end(), sPageName) == m_asPages.end() ) m_asPages.push_back( sPageName ); } m_iCurrentPage = 0; m_bForcedHidden = false; m_Quad.StretchTo( Rage::RectF( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ) ); m_Quad.SetDiffuse( BACKGROUND_COLOR ); this->AddChild( &m_Quad ); // if you're going to add user commands, make sure to have the overrides // set after parsing the metrics. -aj m_textHeader.SetName( "HeaderText" ); m_textHeader.LoadFromFont( THEME->GetPathF("ScreenDebugOverlay", "header") ); LOAD_ALL_COMMANDS_AND_SET_XY_AND_ON_COMMAND( m_textHeader ); m_textHeader.SetText( DEBUG_MENU.GetValue() ); this->AddChild( &m_textHeader ); for (auto s = m_asPages.begin(); s != m_asPages.end(); ++s) { int iPage = s - m_asPages.begin(); DeviceInput di; bool b = GetKeyFromMap( g_Mappings.pageButton, iPage, di ); ASSERT( b ); std::string sButton = INPUTMAN->GetDeviceSpecificInputString( di ); BitmapText *p = new BitmapText; p->SetName( "PageText" ); p->LoadFromFont( THEME->GetPathF("ScreenDebugOverlay", "page") ); LOAD_ALL_COMMANDS_AND_ON_COMMAND( p ); // todo: Y value is still hardcoded. -aj p->SetXY( PAGE_START_X+iPage*PAGE_SPACING_X, SCREEN_TOP+20 ); p->SetText( *s + " (" + sButton + ")" ); m_vptextPages.push_back( p ); this->AddChild( p ); } auto onEachLine = [this](IDebugLine *) { { BitmapText *bt = new BitmapText; bt->SetName( "ButtonText" ); bt->LoadFromFont( THEME->GetPathF("ScreenDebugOverlay", "line") ); bt->SetHorizAlign( align_right ); bt->SetText( "blah" ); LOAD_ALL_COMMANDS_AND_ON_COMMAND( *bt ); m_vptextButton.push_back( bt ); this->AddChild( bt ); } { BitmapText *bt = new BitmapText; bt->SetName( "FunctionText" ); bt->LoadFromFont( THEME->GetPathF("ScreenDebugOverlay", "line") ); bt->SetHorizAlign( align_left ); bt->SetText( "blah" ); LOAD_ALL_COMMANDS_AND_ON_COMMAND( *bt ); m_vptextFunction.push_back( bt ); this->AddChild( bt ); } }; std::for_each(g_pvpSubscribers->begin(), g_pvpSubscribers->end(), onEachLine); this->SetVisible( false ); }
void ScreenDebugOverlay::Init() { Screen::Init(); // Init debug mappings // TODO: Arch-specific? { g_Mappings.Clear(); g_Mappings.holdForDebug1 = DeviceInput(DEVICE_KEYBOARD, KEY_F3); g_Mappings.holdForDebug2.MakeInvalid(); g_Mappings.holdForSlow = DeviceInput(DEVICE_KEYBOARD, KEY_ACCENT); g_Mappings.holdForFast = DeviceInput(DEVICE_KEYBOARD, KEY_TAB); /* TODO: Find a better way of indicating which option is which here. * Maybe we should take a page from ScreenEdit's menus and make * RowDefs()? */ int i=0; g_Mappings.gameplayButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_F8); g_Mappings.gameplayButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_F7); g_Mappings.gameplayButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_F6); i=0; g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C1); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C2); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C3); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C4); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C5); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C6); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C7); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C8); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C9); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C0); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cq); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cw); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ce); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cr); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ct); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cy); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cu); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ci); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Co); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cp); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_UP); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_DOWN); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_BACK); g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F5)] = 0; g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F6)] = 1; g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F7)] = 2; g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F8)] = 3; } map<RString,int> iNextDebugButton; int iNextGameplayButton = 0; FOREACH( IDebugLine*, *g_pvpSubscribers, p ) { RString sPageName = (*p)->GetPageName(); DeviceInput di; switch( (*p)->GetType() ) { case IDebugLine::all_screens: di = g_Mappings.debugButton[iNextDebugButton[sPageName]++]; break; case IDebugLine::gameplay_only: di = g_Mappings.gameplayButton[iNextGameplayButton++]; break; } (*p)->m_Button = di; if( find(m_asPages.begin(), m_asPages.end(), sPageName) == m_asPages.end() ) m_asPages.push_back( sPageName ); } m_iCurrentPage = 0; m_bForcedHidden = false; m_Quad.StretchTo( RectF( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ) ); m_Quad.SetDiffuse( BACKGROUND_COLOR ); this->AddChild( &m_Quad ); // if you're going to add user commands, make sure to have the overrides // set after parsing the metrics. -aj m_textHeader.SetName( "HeaderText" ); m_textHeader.LoadFromFont( THEME->GetPathF("ScreenDebugOverlay", "header") ); LOAD_ALL_COMMANDS_AND_SET_XY_AND_ON_COMMAND( m_textHeader ); m_textHeader.SetText( DEBUG_MENU ); this->AddChild( &m_textHeader ); FOREACH_CONST( RString, m_asPages, s ) { int iPage = s - m_asPages.begin(); DeviceInput di; bool b = GetKeyFromMap( g_Mappings.pageButton, iPage, di ); ASSERT( b ); RString sButton = INPUTMAN->GetDeviceSpecificInputString( di ); BitmapText *p = new BitmapText; p->SetName( "PageText" ); p->LoadFromFont( THEME->GetPathF("ScreenDebugOverlay", "page") ); LOAD_ALL_COMMANDS_AND_ON_COMMAND( p ); // todo: Y value is still hardcoded. -aj p->SetXY( PAGE_START_X+iPage*PAGE_SPACING_X, SCREEN_TOP+20 ); p->SetText( *s + " (" + sButton + ")" ); m_vptextPages.push_back( p ); this->AddChild( p ); }
void ComboGraph::Load( CString Path, const StageStats &s, PlayerNumber pn ) { ASSERT( m_SubActors.size() == 0 ); /* Find the largest combo. */ int MaxComboSize = 0; unsigned i; for( i = 0; i < s.ComboList[pn].size(); ++i ) MaxComboSize = max( MaxComboSize, s.ComboList[pn][i].GetStageCnt() ); float width = -1; for( i = 0; i < s.ComboList[pn].size(); ++i ) { const StageStats::Combo_t &combo = s.ComboList[pn][i]; if( combo.GetStageCnt() < MinComboSizeToShow ) continue; /* too small */ const bool IsMax = (combo.GetStageCnt() == MaxComboSize); LOG->Trace("combo %i is %f+%f", i, combo.fStartSecond, combo.fSizeSeconds); Sprite *sprite = new Sprite; sprite->SetName( "ComboBar" ); const CString path = ssprintf( "%s %s", Path.c_str(), IsMax? "max":"normal" ); sprite->Load( THEME->GetPathToG(path) ); const float start = SCALE( combo.fStartSecond, s.fFirstSecond[pn], s.fLastSecond[pn], 0.0f, 1.0f ); const float size = SCALE( combo.fSizeSeconds, 0, s.fLastSecond[pn]-s.fFirstSecond[pn], 0.0f, 1.0f ); sprite->SetCropLeft ( SCALE( size, 0.0f, 1.0f, 0.5f, 0.0f ) ); sprite->SetCropRight( SCALE( size, 0.0f, 1.0f, 0.5f, 0.0f ) ); sprite->BeginTweening( .5f ); sprite->SetCropLeft( start ); sprite->SetCropRight( 1 - (size + start) ); if( width < 0 ) width = sprite->GetUnzoomedWidth(); m_Sprites.push_back( sprite ); this->AddChild( sprite ); } for( i = 0; i < s.ComboList[pn].size(); ++i ) { const StageStats::Combo_t &combo = s.ComboList[pn][i]; if( combo.GetStageCnt() < MinComboSizeToShow ) continue; /* too small */ if( !MaxComboSize ) continue; const bool IsMax = (combo.GetStageCnt() == MaxComboSize); if( !IsMax ) continue; BitmapText *text = new BitmapText; text->SetName( "ComboMaxNumber" ); text->LoadFromFont( THEME->GetPathToF(Path) ); const float start = SCALE( combo.fStartSecond, s.fFirstSecond[pn], s.fLastSecond[pn], 0.0f, 1.0f ); const float size = SCALE( combo.fSizeSeconds, 0, s.fLastSecond[pn]-s.fFirstSecond[pn], 0.0f, 1.0f ); const float CenterPercent = start + size/2; const float CenterXPos = SCALE( CenterPercent, 0.0f, 1.0f, -width/2.0f, width/2.0f ); text->SetX( CenterXPos ); text->SetText( ssprintf("%i",combo.GetStageCnt()) ); ON_COMMAND( text ); m_Numbers.push_back( text ); this->AddChild( text ); } }