diff --git a/controls/BaseItem.h b/controls/BaseItem.h index 2a788ada..1b2bf3af 100644 --- a/controls/BaseItem.h +++ b/controls/BaseItem.h @@ -156,8 +156,14 @@ class CMenuBaseItem } CMenuItemsHolder* Parent() const { return m_pParent; } - // breaks msvc6/owocc -// template T* Parent() const { return static_cast(m_pParent); } // a shortcut to parent + + #ifndef MY_COMPILER_SUCKS + template T* _Parent() const { return static_cast(m_pParent); } // a shortcut to parent + #define GetParent(type) _Parent() + #else + template T* _Parent(T*) const { return static_cast(m_pParent); } // a shortcut to parent + #define GetParent(type) _Parent((type*)(NULL)) + #endif bool IsPressed() const { return m_bPressed; } int LastFocusTime() const { return m_iLastFocusTime; } diff --git a/menus/ConnectionWarning.cpp b/menus/ConnectionWarning.cpp index 3031f08c..f854eeb7 100644 --- a/menus/ConnectionWarning.cpp +++ b/menus/ConnectionWarning.cpp @@ -68,7 +68,7 @@ void CMenuConnectionWarning::_Init() options.szName = L( "Adv. Options" ); SET_EVENT_MULTI( options.onReleased, { - CMenuConnectionWarning *p = (CMenuConnectionWarning*)pSelf->Parent(); + CMenuConnectionWarning *p = pSelf->GetParent(CMenuConnectionWarning); UI_GameOptions_Menu(); p->done.SetGrayed( false ); }); diff --git a/menus/GameOptions.cpp b/menus/GameOptions.cpp index 78ef95b9..c643caf3 100644 --- a/menus/GameOptions.cpp +++ b/menus/GameOptions.cpp @@ -215,7 +215,7 @@ void CMenuGameOptions::_Init( void ) normal.szName = L( "Normal internet connection" ); // Такая строка где-то уже была, поэтому в отдельный файл НЕ ВЫНОШУ ! SET_EVENT_MULTI( normal.onChanged, { - ((CMenuGameOptions*)pSelf->Parent())->SetNetworkMode( 1400, 0, 30, 60, 25000 ); + pSelf->GetParent(CMenuGameOptions)->SetNetworkMode( 1400, 0, 30, 60, 25000 ); ((CMenuCheckBox*)pSelf)->bChecked = true; }); @@ -223,7 +223,7 @@ void CMenuGameOptions::_Init( void ) dsl.szName = L( "DSL or PPTP with limited packet size" ); // И такое тоже уже было ! SET_EVENT_MULTI( dsl.onChanged, { - ((CMenuGameOptions*)pSelf->Parent())->SetNetworkMode( 1200, 1000, 30, 60, 25000 ); + pSelf->GetParent(CMenuGameOptions)->SetNetworkMode( 1200, 1000, 30, 60, 25000 ); ((CMenuCheckBox*)pSelf)->bChecked = true; }); @@ -232,7 +232,7 @@ void CMenuGameOptions::_Init( void ) slowest.szName = L( "Slow connection mode (64kbps)" ); // Было, повтор ! SET_EVENT_MULTI( slowest.onChanged, { - ((CMenuGameOptions*)pSelf->Parent())->SetNetworkMode( 900, 700, 25, 30, 7500 ); + pSelf->GetParent(CMenuGameOptions)->SetNetworkMode( 900, 700, 25, 30, 7500 ); ((CMenuCheckBox*)pSelf)->bChecked = true; }); compress.SetNameAndStatus( L( "Compress" ), L( "Compress splitted packets (need split to work)" ) ); diff --git a/menus/InputDevices.cpp b/menus/InputDevices.cpp index 3ae34f83..2444be41 100644 --- a/menus/InputDevices.cpp +++ b/menus/InputDevices.cpp @@ -95,7 +95,7 @@ void CMenuInputDevices::_Init( void ) "Are you sure to disable mouse?" ) ); SET_EVENT_MULTI( msgbox.onNegative, { - ((CMenuInputDevices*)pSelf->Parent())->mouse.bChecked = false; + pSelf->GetParent(CMenuInputDevices)->mouse.bChecked = false; }); msgbox.Show(); diff --git a/menus/Multiplayer.cpp b/menus/Multiplayer.cpp index ed9d63a1..941e3dcb 100644 --- a/menus/Multiplayer.cpp +++ b/menus/Multiplayer.cpp @@ -82,13 +82,13 @@ void CMenuMultiplayer::_Init( void ) EngFuncs::CvarSetValue( "cl_predict", 1.0f ); EngFuncs::CvarSetValue( "menu_mp_firsttime", 0.0f ); - UI_PlayerIntroduceDialog_Show( (CMenuBaseWindow*)pSelf->Parent() ); + UI_PlayerIntroduceDialog_Show( pSelf->GetParent(CMenuBaseWindow) ); }); SET_EVENT_MULTI( msgBox.onNegative, { EngFuncs::CvarSetValue( "menu_mp_firsttime", 0.0f ); - UI_PlayerIntroduceDialog_Show( (CMenuBaseWindow*)pSelf->Parent() ); + UI_PlayerIntroduceDialog_Show( pSelf->GetParent(CMenuBaseWindow) ); }); msgBox.Link( this ); diff --git a/menus/VideoModes.cpp b/menus/VideoModes.cpp index 1345075e..e496c093 100644 --- a/menus/VideoModes.cpp +++ b/menus/VideoModes.cpp @@ -311,14 +311,14 @@ void CMenuVidModes::_Init( void ) windowed.SetCoord( 360, 620 ); SET_EVENT_MULTI( windowed.onChanged, { - CMenuVidModes *parent = (CMenuVidModes*)pSelf->Parent(); + CMenuVidModes *parent = pSelf->GetParent(CMenuVidModes); if( !parent->windowed.bChecked && parent->vidList.GetCurrentIndex() < VID_AUTOMODE_POS ) parent->vidList.SetCurrentIndex( VID_AUTOMODE_POS ); }); SET_EVENT_MULTI( vidList.onChanged, { - CMenuVidModes *parent = (CMenuVidModes*)pSelf->Parent(); + CMenuVidModes *parent = pSelf->GetParent(CMenuVidModes); if( !parent->windowed.bChecked && parent->vidList.GetCurrentIndex() < VID_AUTOMODE_POS ) parent->vidList.SetCurrentIndex( VID_AUTOMODE_POS ); });