Files
itgmania212121/stepmania/src/ScreenMiniMenu.cpp
T

140 lines
4.1 KiB
C++
Raw Normal View History

2003-02-18 23:15:38 +00:00
#include "global.h"
#include "ScreenMiniMenu.h"
#include "PrefsManager.h"
#include "ScreenManager.h"
2004-07-08 00:10:34 +00:00
#include "GameSoundManager.h"
2003-02-18 23:15:38 +00:00
#include "GameConstantsAndTypes.h"
#include "PrefsManager.h"
#include "ThemeManager.h"
#include "Foreach.h"
#include "ScreenDimensions.h"
#include "CommonMetrics.h"
2005-03-20 06:41:56 +00:00
#include "GameState.h"
2005-03-25 07:22:10 +00:00
#include "FontCharAliases.h"
2003-02-19 05:46:09 +00:00
AutoScreenMessage( SM_GoToOK )
AutoScreenMessage( SM_GoToCancel )
2003-02-18 23:15:38 +00:00
2005-03-20 06:41:56 +00:00
int ScreenMiniMenu::s_iLastRowCode = -1;
vector<int> ScreenMiniMenu::s_viLastAnswers;
2003-02-18 23:15:38 +00:00
2004-11-26 17:28:47 +00:00
//REGISTER_SCREEN_CLASS( ScreenMiniMenu );
2005-03-20 06:41:56 +00:00
ScreenMiniMenu::ScreenMiniMenu( CString sClassName ) :ScreenOptions( sClassName )
2003-02-18 23:15:38 +00:00
{
2005-03-20 06:41:56 +00:00
}
2003-02-18 23:15:38 +00:00
2005-03-20 06:41:56 +00:00
void ScreenMiniMenu::Init( const Menu* pDef, ScreenMessage SM_SendOnOK, ScreenMessage SM_SendOnCancel )
{
ScreenOptions::Init();
2003-02-18 23:15:38 +00:00
2005-03-20 06:41:56 +00:00
m_Background.Load( THEME->GetPathB(m_sName,"background") );
m_Background->SetDrawOrder( DRAW_ORDER_BEFORE_EVERYTHING );
this->AddChild( m_Background );
m_Background->PlayCommand( "On" );
2003-02-18 23:15:38 +00:00
2005-03-20 06:41:56 +00:00
this->SortByDrawOrder();
2003-02-18 23:15:38 +00:00
2005-03-20 06:41:56 +00:00
m_bIsTransparent = true; // draw screens below us
2005-03-15 22:52:01 +00:00
2005-03-20 06:41:56 +00:00
m_SMSendOnOK = SM_SendOnOK;
m_SMSendOnCancel = SM_SendOnCancel;
2003-02-19 05:46:09 +00:00
2005-03-20 06:41:56 +00:00
FOREACH_CONST( MenuRow, pDef->rows, r )
2003-02-18 23:15:38 +00:00
{
2005-03-20 06:41:56 +00:00
// Don't add rows that aren't applicable to HomeEditMode.
if( !HOME_EDIT_MODE || r->bShowInHomeEditMode )
m_vMenuRows.push_back( *r );
}
2003-02-18 23:15:38 +00:00
2005-03-20 06:41:56 +00:00
// Convert from m_vMenuRows to vector<OptionRowDefinition>
vector<OptionRowDefinition> vDefs;
vDefs.resize( m_vMenuRows.size() );
for( unsigned r=0; r<m_vMenuRows.size(); r++ )
{
const MenuRow &mr = m_vMenuRows[r];
OptionRowDefinition &ord = vDefs[r];
2003-02-18 23:15:38 +00:00
2005-03-20 06:41:56 +00:00
ord.name = mr.sName;
2005-03-25 07:22:10 +00:00
FontCharAliases::ReplaceMarkers( ord.name ); // Allow special characters
2005-03-20 06:41:56 +00:00
if( mr.bEnabled )
2004-01-26 19:11:25 +00:00
{
2005-03-20 06:41:56 +00:00
ord.m_vEnabledForPlayers.clear();
FOREACH_EnabledPlayer( pn )
ord.m_vEnabledForPlayers.insert( pn );
2004-01-26 19:11:25 +00:00
}
2005-03-20 06:41:56 +00:00
else
2003-02-18 23:15:38 +00:00
{
2005-03-20 06:41:56 +00:00
ord.m_vEnabledForPlayers.clear();
2003-02-18 23:15:38 +00:00
}
2005-03-20 06:41:56 +00:00
ord.bOneChoiceForAllPlayers = true;
ord.selectType = SELECT_ONE;
ord.layoutType = LAYOUT_SHOW_ONE_IN_ROW;
ord.m_bExportOnChange = false;
ord.choices = mr.choices;
2005-03-25 07:22:10 +00:00
FOREACH( CString, ord.choices, c )
FontCharAliases::ReplaceMarkers( *c ); // Allow special characters
2003-02-18 23:15:38 +00:00
}
2005-03-20 06:41:56 +00:00
vector<OptionRowHandler*> vHands;
vHands.resize( vDefs.size(), NULL );
2003-02-18 23:15:38 +00:00
2005-03-20 06:41:56 +00:00
ScreenOptions::InitMenu( INPUTMODE_SHARE_CURSOR, vDefs, vHands );
2003-02-18 23:15:38 +00:00
}
2005-03-20 06:41:56 +00:00
void ScreenMiniMenu::ImportOptions( int r, PlayerNumber pn )
2003-02-18 23:15:38 +00:00
{
OptionRow &optrow = *m_Rows[r];
2005-03-20 06:41:56 +00:00
MenuRow &mr = m_vMenuRows[r];
if( !mr.choices.empty() )
optrow.SetOneSharedSelection( mr.iDefaultChoice );
2003-02-18 23:15:38 +00:00
}
2005-03-20 06:41:56 +00:00
void ScreenMiniMenu::ExportOptions( int r, PlayerNumber pn )
2003-02-18 23:15:38 +00:00
{
2005-03-20 06:41:56 +00:00
if( r == GetCurrentRow() )
s_iLastRowCode = m_vMenuRows[r].iRowCode;
s_viLastAnswers.resize( m_vMenuRows.size() );
s_viLastAnswers[r] = m_Rows[r]->GetOneSharedSelection( true );
2003-02-18 23:15:38 +00:00
}
2005-03-20 06:41:56 +00:00
void ScreenMiniMenu::GoToNextScreen()
2003-02-18 23:15:38 +00:00
{
2005-03-20 06:41:56 +00:00
SCREENMAN->PopTopScreen( m_SMSendOnOK );
2003-02-18 23:15:38 +00:00
}
2005-03-20 06:41:56 +00:00
void ScreenMiniMenu::GoToPrevScreen()
2003-02-18 23:15:38 +00:00
{
2005-03-20 06:41:56 +00:00
SCREENMAN->PopTopScreen( m_SMSendOnCancel );
2003-02-18 23:15:38 +00:00
}
2004-06-08 05:22:33 +00:00
/*
* (c) 2003-2004 Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/