Files
itgmania212121/stepmania/src/ScreenMiniMenu.cpp
T

160 lines
4.7 KiB
C++
Raw Normal View History

2003-02-18 23:15:38 +00:00
#include "global.h"
#include "ScreenMiniMenu.h"
#include "ScreenManager.h"
#include "GameConstantsAndTypes.h"
#include "ThemeManager.h"
#include "Foreach.h"
#include "ScreenDimensions.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
bool ScreenMiniMenu::s_bCancelled = false;
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
void ScreenMiniMenu::MiniMenu( MenuDef* pDef, ScreenMessage SM_SendOnOK, ScreenMessage SM_SendOnCancel, float fX, float fY )
2005-07-03 04:50:21 +00:00
{
ScreenMiniMenu *pNewScreen = new ScreenMiniMenu( pDef->sClassName );
pNewScreen->Init();
pNewScreen->LoadMenu( pDef );
pNewScreen->SetOKMessage( SM_SendOnOK );
pNewScreen->SetCancelMessage( SM_SendOnCancel );
pNewScreen->SetXY( fX, fY );
2005-07-03 04:50:21 +00:00
SCREENMAN->ZeroNextUpdate();
SCREENMAN->PushScreen( pNewScreen, true );
2005-07-03 04:50:21 +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
void ScreenMiniMenu::LoadMenu( const MenuDef* pDef )
2005-03-20 06:41:56 +00:00
{
2005-07-14 04:59:06 +00:00
m_vMenuRows = pDef->rows;
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++ )
{
2005-07-05 11:23:31 +00:00
const MenuRowDef &mr = m_vMenuRows[r];
OptionRowDefinition &def = vDefs[r];
2003-02-18 23:15:38 +00:00
def.m_sName = mr.sName;
FontCharAliases::ReplaceMarkers( def.m_sName ); // Allow special characters
2005-03-25 07:22:10 +00:00
2005-03-20 06:41:56 +00:00
if( mr.bEnabled )
2004-01-26 19:11:25 +00:00
{
def.m_vEnabledForPlayers.clear();
2005-03-20 06:41:56 +00:00
FOREACH_EnabledPlayer( pn )
def.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
{
def.m_vEnabledForPlayers.clear();
2003-02-18 23:15:38 +00:00
}
def.m_bOneChoiceForAllPlayers = true;
def.m_selectType = SELECT_ONE;
def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW;
def.m_bExportOnChange = false;
2005-03-20 06:41:56 +00:00
def.m_vsChoices = mr.choices;
2005-03-25 07:22:10 +00:00
FOREACH( CString, def.m_vsChoices, c )
2005-03-25 07:22:10 +00:00
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
ScreenOptions::InitMenu( vDefs, vHands );
2003-02-18 23:15:38 +00:00
}
2005-07-29 22:52:36 +00:00
void ScreenMiniMenu::AfterChangeValueOrRow( PlayerNumber pn )
{
2005-07-29 22:52:36 +00:00
ScreenOptions::AfterChangeValueOrRow( pn );
vector<PlayerNumber> vpns;
vpns.push_back( GAMESTATE->m_MasterPlayerNumber );
2005-06-23 08:05:09 +00:00
for( unsigned i=0; i<m_pRows.size(); i++ )
ExportOptions( i, vpns );
2005-06-23 08:05:09 +00:00
for( unsigned i=0; i<m_pRows.size(); i++ )
{
2005-07-05 11:23:31 +00:00
MenuRowDef &mr = m_vMenuRows[i];
2005-06-23 08:05:09 +00:00
OptionRow &optrow = *m_pRows[i];
if( mr.pfnEnabled )
{
optrow.GetRowDef().m_vEnabledForPlayers.clear();
if( mr.pfnEnabled() )
optrow.GetRowDef().m_vEnabledForPlayers.insert( GAMESTATE->m_MasterPlayerNumber );
}
}
UpdateEnabledDisabled();
}
2005-04-03 06:21:02 +00:00
void ScreenMiniMenu::ImportOptions( int r, const vector<PlayerNumber> &vpns )
2003-02-18 23:15:38 +00:00
{
2005-06-23 08:05:09 +00:00
OptionRow &optrow = *m_pRows[r];
2005-07-05 11:23:31 +00:00
MenuRowDef &mr = m_vMenuRows[r];
2005-03-20 06:41:56 +00:00
if( !mr.choices.empty() )
optrow.SetOneSharedSelection( mr.iDefaultChoice );
2003-02-18 23:15:38 +00:00
}
2005-04-03 06:21:02 +00:00
void ScreenMiniMenu::ExportOptions( int r, const vector<PlayerNumber> &vpns )
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() );
2005-06-23 08:05:09 +00:00
s_viLastAnswers[r] = m_pRows[r]->GetOneSharedSelection( true );
2003-02-18 23:15:38 +00:00
}
void ScreenMiniMenu::HandleScreenMessage( const ScreenMessage SM )
2003-02-18 23:15:38 +00:00
{
if( SM == SM_GoToNextScreen )
{
s_bCancelled = false;
SCREENMAN->PopTopScreen( m_SMSendOnOK );
return;
}
else if( SM == SM_GoToPrevScreen )
{
s_bCancelled = true;
SCREENMAN->PopTopScreen( m_SMSendOnCancel );
return;
}
2003-02-18 23:15:38 +00:00
ScreenOptions::HandleScreenMessage( SM );
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.
*/