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"
|
2004-08-11 07:30:41 +00:00
|
|
|
#include "Foreach.h"
|
2004-09-21 06:07:12 +00:00
|
|
|
#include "ScreenDimensions.h"
|
2005-03-07 18:26:30 +00:00
|
|
|
#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
|
|
|
|
2005-03-28 08:01:36 +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.
|
2005-04-14 06:34:17 +00:00
|
|
|
if( EDIT_MODE >= r->emShowIn )
|
2005-03-20 06:41:56 +00:00
|
|
|
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];
|
2005-05-31 01:17:37 +00:00
|
|
|
OptionRowDefinition &def = vDefs[r];
|
2003-02-18 23:15:38 +00:00
|
|
|
|
2005-05-31 01:17:37 +00:00
|
|
|
def.name = mr.sName;
|
|
|
|
|
FontCharAliases::ReplaceMarkers( def.name ); // 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
|
|
|
{
|
2005-05-31 01:17:37 +00:00
|
|
|
def.m_vEnabledForPlayers.clear();
|
2005-03-20 06:41:56 +00:00
|
|
|
FOREACH_EnabledPlayer( pn )
|
2005-05-31 01:17:37 +00:00
|
|
|
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
|
|
|
{
|
2005-05-31 01:17:37 +00:00
|
|
|
def.m_vEnabledForPlayers.clear();
|
2003-02-18 23:15:38 +00:00
|
|
|
}
|
|
|
|
|
|
2005-05-31 01:17:37 +00:00
|
|
|
def.bOneChoiceForAllPlayers = true;
|
|
|
|
|
def.selectType = SELECT_ONE;
|
|
|
|
|
def.layoutType = LAYOUT_SHOW_ONE_IN_ROW;
|
|
|
|
|
def.m_bExportOnChange = false;
|
2005-03-20 06:41:56 +00:00
|
|
|
|
2005-05-31 01:17:37 +00:00
|
|
|
def.choices = mr.choices;
|
2005-03-25 07:22:10 +00:00
|
|
|
|
2005-05-31 01:17:37 +00:00
|
|
|
FOREACH( CString, def.choices, 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
|
|
|
|
2005-03-20 06:41:56 +00:00
|
|
|
ScreenOptions::InitMenu( INPUTMODE_SHARE_CURSOR, vDefs, vHands );
|
2003-02-18 23:15:38 +00:00
|
|
|
}
|
|
|
|
|
|
2005-05-31 01:17:37 +00:00
|
|
|
void ScreenMiniMenu::OnChange( PlayerNumber pn )
|
|
|
|
|
{
|
|
|
|
|
ScreenOptions::OnChange( pn );
|
|
|
|
|
|
|
|
|
|
vector<PlayerNumber> vpns;
|
|
|
|
|
vpns.push_back( GAMESTATE->m_MasterPlayerNumber );
|
|
|
|
|
for( unsigned i=0; i<m_Rows.size(); i++ )
|
|
|
|
|
ExportOptions( i, vpns );
|
|
|
|
|
|
|
|
|
|
for( unsigned i=0; i<m_Rows.size(); i++ )
|
|
|
|
|
{
|
|
|
|
|
MenuRow &mr = m_vMenuRows[i];
|
|
|
|
|
OptionRow &optrow = *m_Rows[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-03-20 11:20:58 +00:00
|
|
|
OptionRow &optrow = *m_Rows[r];
|
2005-03-20 06:41:56 +00:00
|
|
|
MenuRow &mr = m_vMenuRows[r];
|
|
|
|
|
if( !mr.choices.empty() )
|
2005-03-20 11:20:58 +00:00
|
|
|
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() );
|
|
|
|
|
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-08-11 07:30:41 +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.
|
|
|
|
|
*/
|