123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867 |
- //===========================================================================//
- // Copyright (C) Microsoft Corporation. All rights reserved. //
- //===========================================================================//
- // UnitSettingsDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "resource.h"
- #include "UnitSettingsDlg.h"
- #include "EditorObjects.h"
- #include "EditorObjectMgr.h"
- #include "EditorInterface.h" // just for the undo manager
- /////////////////////////////////////////////////////////////////////////////
- // UnitSettingsDlg dialog
- UnitSettingsDlg::UnitSettingsDlg( EList< Unit*, Unit* >& newList/*=NULL*/, ActionUndoMgr &undoMgr)
- : CDialog(UnitSettingsDlg::IDD), units( newList )
- {
- //{{AFX_DATA_INIT(UnitSettingsDlg)
- m_Alignment = -1;
- m_SquadEdit = _T("");
- m_SelfRepairBehavior = -1;
- //}}AFX_DATA_INIT
- pUndoMgr = &undoMgr;
- pAction = NULL;
- }
- void UnitSettingsDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(UnitSettingsDlg)
- DDX_Control(pDX, IDC_VARIANT, m_Variant);
- DDX_Control(pDX, IDC_PILOT, m_Pilot);
- DDX_Control(pDX, IDC_MECH, m_Mech);
- DDX_Control(pDX, IDC_GROUP, m_Group);
- DDX_Radio(pDX, IDC_ALIGN1, m_Alignment);
- DDX_Text(pDX, IDC_SQUAD_EDIT, m_SquadEdit);
- DDX_Radio(pDX, IDC_SELF_REPAIR1, m_SelfRepairBehavior);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(UnitSettingsDlg, CDialog)
- //{{AFX_MSG_MAP(UnitSettingsDlg)
- ON_CBN_SELCHANGE(IDC_GROUP, OnSelchangeGroup)
- ON_BN_CLICKED(IDC_HIGHILIGHT2EDIT, OnHighilight2edit)
- ON_EN_CHANGE(IDC_HIGHLIGHT1, OnChangeHighlight1)
- ON_BN_CLICKED(IDC_HIGHLIGHT1EDIT, OnHighlight1edit)
- ON_EN_CHANGE(IDC_HIGHLIGHT2, OnChangeHighlight2)
- ON_EN_CHANGE(IDC_BASE, OnChangeBase)
- ON_BN_CLICKED(IDC_BASEEDIT, OnBaseedit)
- ON_WM_CTLCOLOR()
- ON_CBN_SELCHANGE(IDC_MECH, OnSelchangeMech)
- //}}AFX_MSG_MAP
- ON_CONTROL_RANGE( BN_CLICKED, IDC_ALIGN1, IDC_ALIGN1 + 8, OnAlign1)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // UnitSettingsDlg message handlers
- void UnitSettingsDlg::OnSelchangeGroup()
- {
- m_Mech.ResetContent();
- int group = m_Group.GetCurSel();
- group = m_Group.GetItemData( group );
- const char* MechNames[256];
- int count = 256;
-
- EditorObjectMgr::instance()->getBuildingNamesInGroup( group, MechNames, count );
- for ( int i = 0; i < count; ++i )
- {
- m_Mech.AddString( MechNames[i] );
- }
- m_Mech.SetCurSel( 0 );
- }
- void UnitSettingsDlg::OnHighilight2edit()
- {
-
- CWnd* pWnd = GetDlgItem( IDC_HIGHLIGHT2 );
- DoColorBox( pWnd );
- }
- void UnitSettingsDlg::OnChangeHighlight1()
- {
- // TODO: If this is a RICHEDIT control, the control will not
- // send this notification unless you override the CDialog::OnInitDialog()
- // function and call CRichEditCtrl().SetEventMask()
- // with the ENM_CHANGE flag ORed into the mask.
-
- CString text;
- GetDlgItem( IDC_HIGHLIGHT1 )->GetWindowText( text );
- bool bChanged = false;
- int i = 0;
-
- if ( text.GetLength() > 1 && (text[0] == '0' && (text[1] == 'x' || text[i] == 'X' )) )
- i = 2;
- for ( ; i < text.GetLength(); ++i )
- {
- if ( !isxdigit( text[i] ) )
- {
- text.Remove( text[i] );
- bChanged = true;
- }
- }
- if ( bChanged )
- GetDlgItem( IDC_HIGHLIGHT1 )->SetWindowText( text );
- GetDlgItem( IDC_HIGHLIGHT1 )->RedrawWindow( );
-
- }
- void UnitSettingsDlg::OnHighlight1edit()
- {
-
- CWnd* pWnd = GetDlgItem( IDC_HIGHLIGHT1 );
- DoColorBox( pWnd );
- }
- void UnitSettingsDlg::OnChangeHighlight2()
- {
- CString text;
- GetDlgItem( IDC_HIGHLIGHT2 )->GetWindowText( text );
- bool bChanged = false;
- int i = 0;
-
- if ( text.GetLength() > 1 && (text[0] == '0' && (text[1] == 'x' || text[i] == 'X' )) )
- i = 2;
- for ( ; i < text.GetLength(); ++i )
- {
- if ( !isxdigit( text[i] ) )
- {
- text.Remove( text[i] );
- bChanged = true;
- }
- }
- if ( bChanged )
- GetDlgItem( IDC_HIGHLIGHT2 )->SetWindowText( text );
- GetDlgItem( IDC_HIGHLIGHT2 )->RedrawWindow( );
-
- }
- void UnitSettingsDlg::OnChangeBase()
- {
- CString text;
- GetDlgItem( IDC_BASE )->GetWindowText( text );
- bool bChanged = false;
- int i = 0;
-
- if ( text.GetLength() > 1 && (text[0] == '0' && (text[1] == 'x' || text[i] == 'X' )) )
- i = 2;
- for ( ; i < text.GetLength(); ++i )
- {
- if ( !isxdigit( text[i] ) )
- {
- text.Remove( text[i] );
- bChanged = true;
- }
- }
- if ( bChanged )
- GetDlgItem( IDC_BASE )->SetWindowText( text );
- GetDlgItem( IDC_BASE )->RedrawWindow( );
-
- }
- void UnitSettingsDlg::OnBaseedit()
- {
- CWnd* pWnd = GetDlgItem( IDC_BASE );
- DoColorBox( pWnd );
- }
- void UnitSettingsDlg::DoColorBox( CWnd* pWnd )
- {
- if ( pWnd )
- {
- CString tmpStr;
- pWnd->GetWindowText( tmpStr );
- tmpStr.Replace( "0x", "" );
- long base;
- sscanf( tmpStr, "%x", &base );
- base &= 0x00ffffff;
- CColorDialog dlg( reverseRGB(base), NULL, this );
- if (IDOK == dlg.DoModal() )
- {
- base = reverseRGB( dlg.GetColor() );
- tmpStr.Format( "0x%x", base );
- pWnd->SetWindowText( tmpStr );
- }
- }
- }
- void UnitSettingsDlg::applyChanges()
- {
- // get the type info from the dlg box
- int index = m_Group.GetCurSel( );
- if ( index != -1 )
- {
- int group = m_Group.GetItemData( index );
- int indexInGroup = m_Mech.GetCurSel( );
- if ( indexInGroup != -1 )
- {
- for ( UNIT_LIST::EIterator iter = units.Begin(); !iter.IsDone(); iter++ )
- {
- (*iter)->setAppearance( group, indexInGroup );
- }
- int variant = m_Variant.GetCurSel();
- if ( variant != -1 )
- {
- for ( iter = units.Begin(); !iter.IsDone(); iter++ )
- {
- (*iter)->setVariant( variant );
- }
- }
- }
- }
- //set pilots
- index = m_Pilot.GetCurSel();
- if ( index != -1 )
- {
- for ( UNIT_LIST::EIterator iter = units.Begin(); !iter.IsDone(); iter++ )
- {
- CString txt;
- m_Pilot.GetLBText( index, txt );
- (*iter)->getPilot()->setName( txt );
- }
- }
- // now set the alignment
- UpdateData( true );
- index = m_Alignment;
- if ( index != -1 )
- {
- for ( UNIT_LIST::EIterator iter = units.Begin(); !iter.IsDone(); iter++ )
- {
- (*iter)->setAlignment( index );
- }
- }
- if ( !(m_SquadEdit.IsEmpty()) )
- {
- index = _ttol(m_SquadEdit.GetBuffer(0));
- if (1 != units.Count())
- {
- for ( UNIT_LIST::EIterator iter = units.Begin(); !iter.IsDone(); iter++ )
- {
- (*iter)->setSquad( index );
- }
- }
- else
- {
- pFirstPossibility->setSquad( index );
- }
- }
- bool bSelfRepairBehavior = true;
- if (0 != m_SelfRepairBehavior)
- {
- bSelfRepairBehavior = false;
- }
- for ( UNIT_LIST::EIterator iter = units.Begin(); !iter.IsDone(); iter++ )
- {
- (*iter)->setSelfRepairBehaviorEnabled(bSelfRepairBehavior);
- }
- unsigned long base=0, color1=0, color2=0;
- bool bBase = false;
- bool bColor1 = false;
- bool bColor2 = false;
- // now figure out the colors
- CWnd* pWnd = GetDlgItem( IDC_BASE );
- if ( pWnd )
- {
- CString tmpStr;
- pWnd->GetWindowText( tmpStr );
- if ( tmpStr.GetLength() )
- {
- bBase = true;
-
- tmpStr.Replace( "0x", "" );
- sscanf( tmpStr, "%x", &base );
- base |= 0xff000000;
- }
-
- }
- pWnd = GetDlgItem( IDC_HIGHLIGHT1 );
- if ( pWnd )
- {
- CString tmpStr;
- pWnd->GetWindowText( tmpStr );
- if ( tmpStr.GetLength() )
- {
- bColor1 = true;
-
- tmpStr.Replace( "0x", "" );
- sscanf( tmpStr, "%x", &color1 );
- color1 |= 0xff000000;
- }
-
- }
- pWnd = GetDlgItem( IDC_HIGHLIGHT2 );
- if ( pWnd )
- {
- CString tmpStr;
- pWnd->GetWindowText( tmpStr );
- if ( tmpStr.GetLength() )
- {
- bColor2 = true;
-
- tmpStr.Replace( "0x", "" );
- sscanf( tmpStr, "%x", &color2 );
- color2 |= 0xff000000;
- }
-
- }
- if ( bBase && bColor1 && bColor2 )
- {
- for ( UNIT_LIST::EIterator iter = units.Begin(); !iter.IsDone(); iter++ )
- {
- (*iter)->setColors( base, color1, color2 );
- }
- }
- }
- void UnitSettingsDlg::OnOK()
- {
- if (NULL != pUndoMgr)
- {
- pUndoMgr->AddAction(pAction);
- }
- else
- {
- delete pAction;
- }
- pAction = NULL;
- applyChanges();
- CDialog::OnOK();
- }
- BOOL UnitSettingsDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- pAction = new ModifyBuildingAction;
- UNIT_LIST::EIterator iter;
- for ( iter = units.Begin(); !iter.IsDone(); iter++ )
- {
- pAction->addBuildingInfo(*(*iter));
- }
- updateMemberVariables();
- if (1 != units.Count())
- {
- pFirstPossibility = NULL;
- }
- else
- {
- pFirstPossibility = (*(units.Begin()));
- }
- updatePossibiltyControls();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void UnitSettingsDlg::updatePossibiltyControls()
- {
- updateMemberVariables();
- }
- HBRUSH UnitSettingsDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
- {
- HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
- if ( GetDlgItem( IDC_BASE )->m_hWnd == pWnd->m_hWnd )
- {
- CString tmpStr;
- pWnd->GetWindowText( tmpStr );
- tmpStr.Replace( "0x", "" );
- long base;
- sscanf( tmpStr, "%x", &base );
- base &= 0x00ffffff;
- base = reverseRGB( base );
-
- if ( baseBrush.m_hObject )
- baseBrush.DeleteObject();
- baseBrush.CreateSolidBrush( base );
- pDC->SetBkColor( base );
-
- if ( ((base & 0xff) + ( (base & 0xff00)>>8 ) + ( (base & 0xff0000)>>16 ))/3 < 85 )
- pDC->SetTextColor( 0x00ffffff );
- return (HBRUSH)baseBrush.m_hObject;
- }
- if ( GetDlgItem( IDC_HIGHLIGHT1 )->m_hWnd == pWnd->m_hWnd )
- {
- CString tmpStr;
- pWnd->GetWindowText( tmpStr );
- tmpStr.Replace( "0x", "" );
- long base;
- sscanf( tmpStr, "%x", &base );
- base &= 0x00ffffff;
- base = reverseRGB( base );
- if ( brush1.m_hObject )
- brush1.DeleteObject();
- brush1.CreateSolidBrush( base );
- pDC->SetBkColor( base );
- if ( ((base & 0xff) + ( (base & 0xff00)>>8 ) + ( (base & 0xff0000)>>16 ))/3 < 85 )
- pDC->SetTextColor( 0x00ffffff );
- return (HBRUSH)brush1.m_hObject;
- }
- if ( GetDlgItem( IDC_HIGHLIGHT2 )->m_hWnd == pWnd->m_hWnd )
- {
- CString tmpStr;
- pWnd->GetWindowText( tmpStr );
-
- tmpStr.Replace( "0x", "" );
- long base;
- sscanf( tmpStr, "%x", &base );
- base &= 0x00ffffff;
- base = reverseRGB( base );
-
- if ( brush2.m_hObject )
- brush2.DeleteObject();
- brush2.CreateSolidBrush( base );
- pDC->SetBkColor( base );
-
- if ( ((base & 0xff) + ( (base & 0xff00)>>8 ) + ( (base & 0xff0000)>>16 ))/3 < 85 )
- pDC->SetTextColor( 0x00ffffff );
- return (HBRUSH)brush2.m_hObject;
- }
-
-
- // TODO: Return a different brush if the default is not desired
- return hbr;
- }
- void UnitSettingsDlg::OnSelchangeMech()
- {
- m_Variant.ResetContent();
-
- int group = m_Group.GetCurSel();
- group = m_Group.GetItemData( group );
- int indexInGroup = m_Mech.GetCurSel();
- int varCount = EditorObjectMgr::instance()->getNumberOfVariants( group, indexInGroup );
- const char** VariantNames = 0;
- if (0 < varCount)
- {
- VariantNames = new const char*[varCount];
- EditorObjectMgr::instance()->getVariantNames( group, indexInGroup, VariantNames, varCount );
- for ( int v = 0; v < varCount; ++v )
- {
- m_Variant.AddString( VariantNames[v] );
- }
- delete VariantNames;
- VariantNames = 0;
- m_Variant.SetCurSel( 0 );
- }
- }
- int UnitSettingsDlg::getPossibilityIndex()
- {
- if (!pFirstPossibility) { gosASSERT(false); return -1; }
- const Unit * pUnit = (*(units.Begin()));
- if (pUnit == pFirstPossibility)
- {
- return 0;
- }
- int i;
- for (i = 0; i < (int)pFirstPossibility->pAlternativeInstances->Count(); i++)
- {
- if (pUnit == &(*(pFirstPossibility->pAlternativeInstances->Iterator(i))))
- {
- return i + 1;
- }
- }
- return -1;
- }
- void UnitSettingsDlg::updateMemberVariables()
- {
- // now need to check all of the colors
- unsigned long tmpBase, tmpHighlight1, tmpHighlight2;
- unsigned long base, highlight1, highlight2;
- bool bBase = true;
- bool bHighlight = true;
- bool bHighlight2 = true;
- Unit* pUnit = units.GetHead();
- m_Alignment = pUnit->getAlignment();
- for ( UNIT_LIST::EIterator iter = units.Begin(); !iter.IsDone(); iter++ )
- {
- if ( (*iter)->getAlignment() != m_Alignment )
- {
- m_Alignment = -1;
- break;
- }
- }
- m_SelfRepairBehavior = 0;
- if (true != pUnit->getSelfRepairBehaviorEnabled())
- {
- m_SelfRepairBehavior = 1;
- }
- for ( iter = units.Begin(); !iter.IsDone(); iter++ )
- {
- if ( (*iter)->getSelfRepairBehaviorEnabled() != pUnit->getSelfRepairBehaviorEnabled() )
- {
- m_SelfRepairBehavior = -1;
- break;
- }
- }
- unsigned long tmpSquadNum = pUnit->getSquad();
- m_SquadEdit.Format("%lu", tmpSquadNum);
- for ( iter = units.Begin(); !iter.IsDone(); iter++ )
- {
- if ( (*iter)->getSquad() != tmpSquadNum )
- {
- m_SquadEdit.Empty();
- break;
- }
- }
- UpdateData( false );
-
- pUnit->getColors( base, highlight1, highlight2 );
- char pBase[256];
- char pH1[256];
- char pH2[256];
- for ( iter = units.Begin(); !iter.IsDone(); iter++ )
- {
- (*iter)->getColors( tmpBase, tmpHighlight1, tmpHighlight2 );
- if ( tmpBase != base )
- bBase = false;
-
- if ( tmpHighlight1 != highlight1 )
- bHighlight = false;
-
- if ( tmpHighlight2 != highlight2 )
- bHighlight2 = false;
- }
- base &= 0x00ffffff;
- highlight1 &= 0x00ffffff;
- highlight2 &= 0x00ffffff;
- sprintf( pBase, "0x%6x", base );
- sprintf( pH1, "0x%6x", highlight1 );
- sprintf( pH2, "0x%6x", highlight2 );
- if ( bBase )
- {
- GetDlgItem( IDC_BASE )->SetWindowText( pBase );
- }
- if ( bHighlight )
- GetDlgItem( IDC_HIGHLIGHT1 )->SetWindowText( pH1 );
-
- if ( bHighlight2 )
- GetDlgItem( IDC_HIGHLIGHT2 )->SetWindowText( pH2 );
- EditorObjectMgr* pMgr = EditorObjectMgr::instance();
- int groupCount = pMgr->getUnitGroupCount();
- const char** pGroups = new const char*[groupCount];
- int* groupIDs = new int[groupCount];
-
- m_Group.ResetContent();
-
- pMgr->getUnitGroupNames(pGroups, groupIDs, groupCount);
- for ( int i = 0; i < groupCount; ++i )
- {
- m_Group.AddString( pGroups[i] );
- m_Group.SetItemData( i, groupIDs[i] );
- }
- delete [] pGroups;
- delete [] groupIDs;
- // make sure all the units we are editing are in the same group
- int group = units.GetHead()->getGroup();
- for ( iter = units.Begin(); !iter.IsDone(); iter++ )
- {
- if ( (*iter)->getGroup() != group )
- {
- group = -1;
- break;
- }
- }
- if ( group != -1 ) // we found a valid group
- {
- const char* pGroupName = pMgr->getGroupName( group );
-
- int index = m_Group.FindString( -1, pGroupName );
- m_Group.SetCurSel( index );
- // OK, now fill in the index....
- const char* MechNames[256];
- int count = 256;
- m_Mech.ResetContent();
- pMgr->getBuildingNamesInGroup( group, MechNames, count );
- for ( int i = 0; i < count; ++i )
- {
- m_Mech.AddString( MechNames[i] );
- }
- // ok, now determine if all of the mechs are the same.
- int indexInGroup = units.GetHead()->getIndexInGroup();
- for ( iter = units.Begin(); !iter.IsDone(); iter++ )
- {
- if ( (*iter)->getIndexInGroup() != indexInGroup )
- {
- indexInGroup = -1;
- break;
- }
- }
- if ( indexInGroup != -1 )
- {
- const char* pName = units.GetHead()->getDisplayName();
- index = m_Mech.FindString( -1, pName );
- if ( index != -1 )
- {
- m_Mech.SetCurSel( index );
- // now we need to find the variant
- m_Variant.ResetContent();
-
- int varCount = EditorObjectMgr::instance()->getNumberOfVariants( group, indexInGroup );
- const char** VariantNames = 0;
- if (0 < varCount)
- {
- VariantNames = new const char*[varCount];
- EditorObjectMgr::instance()->getVariantNames( group, indexInGroup, VariantNames, varCount );
- for ( int v = 0; v < varCount; ++v )
- {
- m_Variant.AddString( VariantNames[v] );
- }
- delete VariantNames;
- VariantNames = 0;
- // OK, now see if they all have the same variant name
- int variant = units.GetHead()->getVariant();
- for ( iter = units.Begin(); !iter.IsDone(); iter++ )
- {
- if ( (*iter)->getVariant() != variant )
- {
- variant = -1;
- break;
- }
- }
- if ( variant != -1 )
- m_Variant.SetCurSel( variant );
- }
- }
- }
- }
- Pilot::PilotInfo* pInfo = Pilot::s_BadPilots;
- long* count = &Pilot::badCount;
- if ( (m_Alignment == 0) || (!EditorData::instance->IsSinglePlayer()) )
- {
- pInfo = Pilot::s_GoodPilots;
- count = &Pilot::goodCount;
- }
- else if ( m_Alignment == -1 )
- pInfo = 0;
- if ( pInfo )
- {
- m_Pilot.ResetContent();
- for ( int i = 0; i < *count; i++ )
- {
- m_Pilot.AddString( pInfo[i].name );
- m_Pilot.SetItemDataPtr(i, (void *)pInfo[i].fileName);
- }
- }
- Pilot* pPilot = pUnit->getPilot();
- const char* defaultPilot = pPilot->info->fileName;
- for ( iter = units.Begin(); !iter.IsDone(); iter++ )
- {
- pPilot = (*iter)->getPilot();
- const char* tmpName = pPilot->info->fileName;
- if ( stricmp( tmpName, defaultPilot ) != 0 )
- {
- defaultPilot = 0;
- break;
- }
- }
-
- if ( defaultPilot )
- {
- int index;
- for (index = 0; index < m_Pilot.GetCount(); index++)
- {
- char *fileName = (char *)m_Pilot.GetItemDataPtr(index);
- if (0 == strcmp(fileName, defaultPilot))
- {
- break;
- }
- }
- if (!(index < m_Pilot.GetCount()))
- {
- index = -1;
- }
- m_Pilot.SetCurSel( index );
- }
- }
- void UnitSettingsDlg::OnCancel()
- {
- pAction->undo();
- delete pAction;
- pAction = NULL;
-
- CDialog::OnCancel();
- }
- void UnitSettingsDlg::OnAlign1( UINT whichID )
- {
- UpdateData();
- Pilot::PilotInfo* pInfo = Pilot::s_BadPilots;
- long* count = &Pilot::badCount;
- if ( m_Alignment == 0 )
- {
- pInfo = Pilot::s_GoodPilots;
- count = &Pilot::goodCount;
- }
- else if ( m_Alignment == -1 )
- pInfo = 0;
- if ( pInfo )
- {
- m_Pilot.ResetContent();
- for ( int i = 0; i < *count; i++ )
- {
- m_Pilot.AddString( pInfo[i].name );
- }
- }
- Unit * pUnit = (*(units.Begin()));
- Pilot* pPilot = pUnit->getPilot();
- const char* defaultPilot = pPilot->getName();
- for ( UNIT_LIST::EIterator iter = units.Begin(); !iter.IsDone(); iter++ )
- {
- pPilot = (*iter)->getPilot();
- const char* tmpName = pPilot->getName();
- if ( stricmp( tmpName, defaultPilot ) != 0 )
- {
- defaultPilot = 0;
- break;
- }
- }
-
- if ( defaultPilot )
- {
- int index = m_Pilot.FindString( -1, defaultPilot );
- m_Pilot.SetCurSel( index );
- }
-
- }
|