initial
This commit is contained in:
5854
game/client/cstrike15/gameui/BasePanel.cpp
Normal file
5854
game/client/cstrike15/gameui/BasePanel.cpp
Normal file
File diff suppressed because it is too large
Load Diff
72
game/client/cstrike15/gameui/backgroundmenubutton.cpp
Normal file
72
game/client/cstrike15/gameui/backgroundmenubutton.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "backgroundmenubutton.h"
|
||||
|
||||
#include <keyvalues.h>
|
||||
#include <vgui/IImage.h>
|
||||
#include <vgui/IScheme.h>
|
||||
#include <vgui_controls/Menu.h>
|
||||
#include <vgui_controls/MenuItem.h>
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CBackgroundMenuButton::CBackgroundMenuButton(vgui::Panel *parent, const char *name) : BaseClass(parent, name, "")
|
||||
{
|
||||
m_pImage = NULL;
|
||||
m_pMouseOverImage = NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CBackgroundMenuButton::~CBackgroundMenuButton()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBackgroundMenuButton::OnCommand(const char *command)
|
||||
{
|
||||
BaseClass::OnCommand(command);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Makes the button transparent
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBackgroundMenuButton::ApplySchemeSettings(IScheme *pScheme)
|
||||
{
|
||||
BaseClass::ApplySchemeSettings(pScheme);
|
||||
|
||||
// hack some colors in
|
||||
SetFgColor(Color(255, 255, 255, 255));
|
||||
SetBgColor(Color(0, 0, 0, 0));
|
||||
SetDefaultColor(Color(255, 255, 255, 255), Color(0, 0, 0, 0));
|
||||
SetArmedColor(Color(255, 255, 0, 255), Color(0, 0, 0, 0));
|
||||
SetDepressedColor(Color(255, 255, 0, 255), Color(0, 0, 0, 0));
|
||||
SetContentAlignment(Label::a_west);
|
||||
SetBorder(NULL);
|
||||
SetDefaultBorder(NULL);
|
||||
SetDepressedBorder(NULL);
|
||||
SetKeyFocusBorder(NULL);
|
||||
SetTextInset(0, 0);
|
||||
SetAlpha(0);
|
||||
|
||||
/*
|
||||
// sounds disabled for this button (since it's so big now)
|
||||
SetArmedSound("UI/buttonrollover.wav");
|
||||
SetDepressedSound("UI/buttonclick.wav");
|
||||
SetReleasedSound("UI/buttonclickrelease.wav");
|
||||
*/
|
||||
}
|
||||
39
game/client/cstrike15/gameui/backgroundmenubutton.h
Normal file
39
game/client/cstrike15/gameui/backgroundmenubutton.h
Normal file
@@ -0,0 +1,39 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef BACKGROUNDMENUBUTTON_H
|
||||
#define BACKGROUNDMENUBUTTON_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui_controls/Button.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Baseclass for the left and right ingame menus that lay on the background
|
||||
//-----------------------------------------------------------------------------
|
||||
class CBackgroundMenuButton : public vgui::Button
|
||||
{
|
||||
public:
|
||||
CBackgroundMenuButton(vgui::Panel *parent, const char *name);
|
||||
~CBackgroundMenuButton();
|
||||
|
||||
virtual void OnCommand(const char *command);
|
||||
|
||||
protected:
|
||||
vgui::Menu *RecursiveLoadGameMenu(KeyValues *datafile);
|
||||
vgui::Menu *m_pMenu;
|
||||
|
||||
virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
|
||||
|
||||
private:
|
||||
vgui::IImage *m_pImage, *m_pMouseOverImage;
|
||||
typedef vgui::Button BaseClass;
|
||||
};
|
||||
|
||||
|
||||
#endif // BACKGROUNDMENUBUTTON_H
|
||||
568
game/client/cstrike15/gameui/basepanel.h
Normal file
568
game/client/cstrike15/gameui/basepanel.h
Normal file
@@ -0,0 +1,568 @@
|
||||
//========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef BASEPANEL_H
|
||||
#define BASEPANEL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if !defined( NO_STEAM )
|
||||
#include "utlvector.h"
|
||||
#include "clientsteamcontext.h"
|
||||
#endif
|
||||
|
||||
#if defined( SWARM_DLL )
|
||||
|
||||
#include "swarm/basemodpanel.h"
|
||||
inline BaseModUI::CBaseModPanel * BasePanel() { return &BaseModUI::CBaseModPanel::GetSingleton(); }
|
||||
|
||||
#elif defined( PORTAL2_UITEST_DLL )
|
||||
|
||||
#include "portal2uitest/basemodpanel.h"
|
||||
inline BaseModUI::CBaseModPanel * BasePanel() { return &BaseModUI::CBaseModPanel::GetSingleton(); }
|
||||
|
||||
#else
|
||||
|
||||
#define BASEPANEL_LEGACY_SOURCE1
|
||||
|
||||
#include "vgui_controls/Panel.h"
|
||||
#include "vgui_controls/PHandle.h"
|
||||
#include "vgui_controls/MenuItem.h"
|
||||
#include "vgui_controls/MessageDialog.h"
|
||||
#include "keyvalues.h"
|
||||
#include "utlvector.h"
|
||||
#include "tier1/commandbuffer.h"
|
||||
#include "vgui_controls/footerpanel.h"
|
||||
|
||||
#include "ixboxsystem.h"
|
||||
|
||||
#if !defined( _GAMECONSOLE )
|
||||
#include "xbox/xboxstubs.h"
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
DIALOG_STACK_IDX_STANDARD,
|
||||
DIALOG_STACK_IDX_WARNING,
|
||||
DIALOG_STACK_IDX_ERROR,
|
||||
};
|
||||
|
||||
class CBackgroundMenuButton;
|
||||
class CGameMenu;
|
||||
|
||||
// X360TBD: Move into a separate module when finished
|
||||
class CMessageDialogHandler
|
||||
{
|
||||
public:
|
||||
CMessageDialogHandler();
|
||||
void ShowMessageDialog( int nType, vgui::Panel *pOwner );
|
||||
void CloseMessageDialog( const uint nType = 0 );
|
||||
void CloseAllMessageDialogs();
|
||||
void CreateMessageDialog( const uint nType, const char *pTitle, const char *pMsg, const char *pCmdA, const char *pCmdB, vgui::Panel *pCreator, bool bShowActivity = false );
|
||||
void ActivateMessageDialog( int nStackIdx );
|
||||
void PositionDialogs( int wide, int tall );
|
||||
void PositionDialog( vgui::PHandle dlg, int wide, int tall );
|
||||
|
||||
private:
|
||||
static const int MAX_MESSAGE_DIALOGS = 3;
|
||||
vgui::DHANDLE< CMessageDialog > m_hMessageDialogs[MAX_MESSAGE_DIALOGS];
|
||||
int m_iDialogStackTop;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: EditablePanel that can replace the GameMenuButtons in CBaseModPanel
|
||||
//-----------------------------------------------------------------------------
|
||||
class CMainMenuGameLogo : public vgui::EditablePanel
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CMainMenuGameLogo, vgui::EditablePanel );
|
||||
public:
|
||||
CMainMenuGameLogo( vgui::Panel *parent, const char *name );
|
||||
|
||||
virtual void ApplySettings( KeyValues *inResourceData );
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
|
||||
int GetOffsetX(){ return m_nOffsetX; }
|
||||
int GetOffsetY(){ return m_nOffsetY; }
|
||||
|
||||
private:
|
||||
int m_nOffsetX;
|
||||
int m_nOffsetY;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Transparent menu item designed to sit on the background ingame
|
||||
//-----------------------------------------------------------------------------
|
||||
class CGameMenuItem : public vgui::MenuItem
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CGameMenuItem, vgui::MenuItem );
|
||||
public:
|
||||
CGameMenuItem(vgui::Menu *parent, const char *name);
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
virtual void PaintBackground( void );
|
||||
void SetRightAlignedText( bool state );
|
||||
|
||||
private:
|
||||
bool m_bRightAligned;
|
||||
};
|
||||
|
||||
// dgoodenough - GCC does not treat "friend class foo;" as a forward declaration of foo, so
|
||||
// explicitly forward declare class CAsyncCtxOnDeviceAttached here.
|
||||
// PS3_BUILDFIX
|
||||
class CAsyncCtxOnDeviceAttached;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: This is the panel at the top of the panel hierarchy for GameUI
|
||||
// It handles all the menus, background images, and loading dialogs
|
||||
//-----------------------------------------------------------------------------
|
||||
class CBaseModPanel : public vgui::Panel
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CBaseModPanel, vgui::Panel );
|
||||
|
||||
protected:
|
||||
explicit CBaseModPanel( const char *panelName );
|
||||
|
||||
public:
|
||||
virtual ~CBaseModPanel();
|
||||
|
||||
public:
|
||||
//
|
||||
// Implementation of async jobs
|
||||
// An async job is enqueued by calling "ExecuteAsync" with the proper job context.
|
||||
// Job's function "ExecuteAsync" is called on a separate thread.
|
||||
// After the job finishes the "Completed" function is called on the
|
||||
// main thread.
|
||||
//
|
||||
class CAsyncJobContext
|
||||
{
|
||||
public:
|
||||
explicit CAsyncJobContext( float flLeastExecuteTime = 0.0f ) : m_flLeastExecuteTime( flLeastExecuteTime ), m_hThreadHandle( NULL ) {}
|
||||
virtual ~CAsyncJobContext() {}
|
||||
|
||||
virtual void ExecuteAsync() = 0; // Executed on the secondary thread
|
||||
virtual void Completed() = 0; // Executed on the main thread
|
||||
|
||||
public:
|
||||
void * volatile m_hThreadHandle; // Handle to an async job thread waiting for
|
||||
float m_flLeastExecuteTime; // Least amount of time this job should keep executing
|
||||
};
|
||||
|
||||
CAsyncJobContext *m_pAsyncJob;
|
||||
void ExecuteAsync( CAsyncJobContext *pAsync );
|
||||
|
||||
|
||||
public:
|
||||
// notifications
|
||||
virtual void OnLevelLoadingStarted( const char *levelName, bool bShowProgressDialog );
|
||||
virtual void OnLevelLoadingFinished();
|
||||
virtual bool UpdateProgressBar(float progress, const char *statusText, bool showDialog = true ) { return false; }
|
||||
|
||||
// update the taskbar a frame
|
||||
virtual void RunFrame();
|
||||
|
||||
// fades to black then runs an engine command (usually to start a level)
|
||||
void FadeToBlackAndRunEngineCommand( const char *engineCommand );
|
||||
|
||||
// sets the blinking state of a menu item
|
||||
void SetMenuItemBlinkingState( const char *itemName, bool state );
|
||||
|
||||
// handles gameUI being shown
|
||||
virtual void OnGameUIActivated();
|
||||
|
||||
// game dialogs
|
||||
void OnOpenNewGameDialog( const char *chapter = NULL );
|
||||
void OnOpenBonusMapsDialog();
|
||||
void OnOpenLoadGameDialog();
|
||||
void OnOpenLoadGameDialog_Xbox();
|
||||
void OnOpenSaveGameDialog();
|
||||
void OnOpenSaveGameDialog_Xbox();
|
||||
void OnCloseServerBrowser();
|
||||
void OnOpenFriendsDialog();
|
||||
void OnOpenDemoDialog();
|
||||
// Overridden with the Scaleform dialog box in Cstrike15Basepanel
|
||||
virtual void OnOpenQuitConfirmationDialog( bool bForceToDesktop = false );
|
||||
void OnOpenChangeGameDialog();
|
||||
void OnOpenPlayerListDialog();
|
||||
void OnOpenBenchmarkDialog();
|
||||
void OnOpenOptionsDialog();
|
||||
void OnOpenOptionsDialog_Xbox();
|
||||
void OnOpenLoadCommentaryDialog();
|
||||
void OpenLoadSingleplayerCommentaryDialog();
|
||||
void OnOpenAchievementsDialog();
|
||||
void OnOpenAchievementsDialog_Xbox();
|
||||
void OnOpenCSAchievementsDialog();
|
||||
virtual void OnOpenSettingsDialog();
|
||||
virtual void OnOpenControllerDialog();
|
||||
virtual void OnOpenMouseDialog();
|
||||
virtual void OnOpenKeyboardDialog();
|
||||
virtual void OnOpenMotionControllerMoveDialog();
|
||||
virtual void OnOpenMotionControllerSharpshooterDialog();
|
||||
virtual void OnOpenMotionControllerDialog();
|
||||
virtual void OnOpenMotionCalibrationDialog();
|
||||
virtual void OnOpenVideoSettingsDialog();
|
||||
virtual void OnOpenOptionsQueued();
|
||||
virtual void OnOpenAudioSettingsDialog();
|
||||
|
||||
// [jason] For displaying medals/stats in Cstrike15
|
||||
virtual void OnOpenMedalsDialog();
|
||||
virtual void OnOpenStatsDialog();
|
||||
virtual void CloseMedalsStatsDialog();
|
||||
|
||||
// [jason] For displaying Leaderboards in Cstrike15
|
||||
virtual void OnOpenLeaderboardsDialog();
|
||||
virtual void OnOpenCallVoteDialog();
|
||||
virtual void OnOpenMarketplace();
|
||||
virtual void UpdateLeaderboardsDialog();
|
||||
virtual void CloseLeaderboardsDialog();
|
||||
|
||||
virtual void OnOpenDisconnectConfirmationDialog();
|
||||
|
||||
// gameconsole
|
||||
void SystemNotification( const int notification );
|
||||
void ShowMessageDialog( const uint nType, vgui::Panel *pParent = NULL );
|
||||
void CloseMessageDialog( const uint nType );
|
||||
void OnChangeStorageDevice();
|
||||
bool ValidateStorageDevice();
|
||||
bool ValidateStorageDevice( int *pStorageDeviceValidated );
|
||||
void OnCreditsFinished();
|
||||
|
||||
virtual void OnOpenCreateSingleplayerGameDialog( bool bMatchmakingFilter = false ) {}
|
||||
virtual void OnOpenCreateMultiplayerGameDialog();
|
||||
virtual void OnOpenCreateMultiplayerGameCommunity();
|
||||
virtual void ShowMatchmakingStatus() {}
|
||||
|
||||
// returns true if message box is displayed successfully
|
||||
virtual bool ShowLockInput( void ) { return false; }
|
||||
|
||||
virtual void OnOpenHowToPlayDialog() {}
|
||||
|
||||
virtual void OnOpenServerBrowser() {}
|
||||
virtual void OnOpenCreateLobbyScreen( bool bIsHost = false ) {}
|
||||
virtual void OnOpenLobbyBrowserScreen( bool bIsHost = false ) {}
|
||||
virtual void UpdateLobbyScreen( void ) {}
|
||||
virtual void UpdateMainMenuScreen() {}
|
||||
virtual void UpdateLobbyBrowser( void ) {}
|
||||
|
||||
// Determine if we have an active team lobby we are part of
|
||||
virtual bool InTeamLobby( void );
|
||||
|
||||
// [jason] Provides the "Press Start" screen interface (show, hide, and reset flags)
|
||||
virtual void OnOpenCreateStartScreen( void );
|
||||
virtual void HandleOpenCreateStartScreen( void );
|
||||
virtual void DismissStartScreen( void );
|
||||
virtual bool IsStartScreenActive( void );
|
||||
|
||||
// Do we want the start screen to come up when we boot up, before we reach main menu?
|
||||
bool IsStartScreenEnabled( void ) { return m_bShowStartScreen; }
|
||||
|
||||
// [jason] Start the sign-in blade
|
||||
void SignInFromStartScreen( void );
|
||||
|
||||
// [jason] Dismiss the start screen and commit the user once they've signed in
|
||||
void CompleteStartScreenSignIn( void );
|
||||
|
||||
// [jason] Callback for the CreateStartScreen interface to allow us to complete the signin process
|
||||
void NotifySignInCompleted(int userID = -1);
|
||||
void NotifySignInCancelled( void );
|
||||
|
||||
// [jason] Helper function to allow show/hide of the standard Valve main menu (which also enables/disables its processing)
|
||||
void ShowMainMenu( bool bShow );
|
||||
|
||||
virtual void OnPlayCreditsVideo( void );
|
||||
|
||||
// [jason] New scaleform Main Menu setup
|
||||
virtual void OnOpenCreateMainMenuScreen( void );
|
||||
virtual void DismissMainMenuScreen( void );
|
||||
virtual void RestoreMainMenuScreen( void );
|
||||
|
||||
// Tear down all screens, and either tear down or just hide the main/pause menu (by default, they are also torn down)
|
||||
virtual void DismissAllMainMenuScreens( bool bHideMainMenuOnly = false );
|
||||
|
||||
// Controls whether we allow the next main menu transition to use the Scaleform main menu, or the vgui version
|
||||
void EnableScaleformMainMenu( bool bEnable ) { m_bScaleformMainMenuEnabled = bEnable; }
|
||||
bool IsScaleformMainMenuEnabled( void ) { return m_bScaleformMainMenuEnabled; }
|
||||
|
||||
// [jason] Notification that a vgui dialog has completed, in case we need to restore Scaleform menu
|
||||
void NotifyVguiDialogClosed( void );
|
||||
|
||||
virtual void OnOpenPauseMenu( void );
|
||||
virtual void DismissPauseMenu( void );
|
||||
virtual void RestorePauseMenu( void );
|
||||
|
||||
virtual void OnOpenUpsellDialog( void );
|
||||
|
||||
void OnMakeGamePublic( void );
|
||||
|
||||
virtual void ShowScaleformPauseMenu( bool bShow );
|
||||
virtual bool IsScaleformPauseMenuActive( void );
|
||||
virtual bool IsScaleformPauseMenuVisible( void );
|
||||
|
||||
bool IsScaleformPauseMenuEnabled( void ) { return m_bScaleformPauseMenuEnabled; }
|
||||
|
||||
KeyValues *GetConsoleControlSettings( void );
|
||||
|
||||
// forces any changed options dialog settings to be applied immediately, if it's open
|
||||
void ApplyOptionsDialogSettings();
|
||||
|
||||
vgui::AnimationController *GetAnimationController( void ) { return m_pConsoleAnimationController; }
|
||||
void RunCloseAnimation( const char *animName );
|
||||
void RunAnimationWithCallback( vgui::Panel *parent, const char *animName, KeyValues *msgFunc );
|
||||
void PositionDialog( vgui::PHandle dlg );
|
||||
|
||||
virtual void OnSizeChanged( int newWide, int newTall );
|
||||
|
||||
void ArmFirstMenuItem( void );
|
||||
|
||||
void OnGameUIHidden();
|
||||
|
||||
virtual void CloseBaseDialogs( void );
|
||||
bool IsWaitingForConsoleUI( void ) { return m_bWaitingForStorageDeviceHandle || m_bWaitingForUserSignIn || m_bXUIVisible; }
|
||||
|
||||
bool LoadingProgressWantsIsolatedRender( bool bContextValid );
|
||||
|
||||
bool IsLevelLoading( void ) const { return m_bLevelLoading; }
|
||||
|
||||
#if defined( _GAMECONSOLE )
|
||||
CON_COMMAND_MEMBER_F( CBaseModPanel, "gameui_reload_resources", Reload_Resources, "Reload the Xbox 360 UI res files", 0 );
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void PaintBackground();
|
||||
virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
|
||||
|
||||
// [jason] Input locking and unlocking based on user sign-in
|
||||
virtual void LockInput( void );
|
||||
virtual void UnlockInput( void );
|
||||
|
||||
// [jason] Allow toggle of the new scaleform version of the main menu
|
||||
virtual void ShowScaleformMainMenu( bool bShow );
|
||||
|
||||
virtual bool IsScaleformMainMenuActive( void );
|
||||
|
||||
virtual bool IsScaleformIntroMovieEnabled( void ) { return false; }
|
||||
virtual void CreateScaleformIntroMovie( void ) {}
|
||||
virtual void DismissScaleformIntroMovie( void ) {}
|
||||
|
||||
void CreateStartScreenIfNeeded( void );
|
||||
int CheckForAnyKeyPressed( bool bCheckKeyboard );
|
||||
|
||||
void ForcePrimaryUserId( int id ) { m_primaryUserId = id; }
|
||||
|
||||
public:
|
||||
// FIXME: This should probably become a friend relationship between the classes
|
||||
bool HandleSignInRequest( const char *command );
|
||||
bool HandleStorageDeviceRequest( const char *command );
|
||||
void ClearPostPromptCommand( const char *pCompletedCommand );
|
||||
|
||||
bool IsSinglePlayer() const { return m_bSinglePlayer; }
|
||||
void SetSinglePlayer( bool singlePlayer ) { m_bSinglePlayer = singlePlayer; }
|
||||
void UpdateRichPresenceInfo();
|
||||
|
||||
virtual void OnCommand(const char *command);
|
||||
|
||||
//HACK: could make this generic...
|
||||
bool m_bReturnToMPGameMenuOnDisconnect;
|
||||
bool m_bForceQuitToDesktopOnDisconnect;
|
||||
|
||||
protected:
|
||||
virtual void StartExitingProcess( void );
|
||||
void SetStatsLoaded( bool value ) { m_bStatsLoaded = value; }
|
||||
bool GetStatsLoaded( void ) const { return m_bStatsLoaded; }
|
||||
|
||||
private:
|
||||
enum EBackgroundState
|
||||
{
|
||||
BACKGROUND_INITIAL,
|
||||
BACKGROUND_LOADING,
|
||||
BACKGROUND_MAINMENU,
|
||||
BACKGROUND_LEVEL,
|
||||
BACKGROUND_DISCONNECTED,
|
||||
BACKGROUND_EXITING, // Console has started an exiting state, cannot be stopped
|
||||
};
|
||||
void SetBackgroundRenderState(EBackgroundState state);
|
||||
|
||||
friend class CAsyncCtxOnDeviceAttached;
|
||||
void OnDeviceAttached( void );
|
||||
void OnCompletedAsyncDeviceAttached( CAsyncCtxOnDeviceAttached *job );
|
||||
|
||||
void IssuePostPromptCommand( void );
|
||||
|
||||
void UpdateBackgroundState();
|
||||
|
||||
// sets the menu alpha [0..255]
|
||||
void SetMenuAlpha(int alpha);
|
||||
|
||||
// menu manipulation
|
||||
void CreatePlatformMenu();
|
||||
void CreateGameMenu();
|
||||
void CreateGameLogo();
|
||||
void CheckBonusBlinkState();
|
||||
void UpdateGameMenus();
|
||||
CGameMenu *RecursiveLoadGameMenu(KeyValues *datafile);
|
||||
|
||||
|
||||
bool IsPromptableCommand( const char *command );
|
||||
bool CommandRequiresSignIn( const char *command );
|
||||
bool CommandRequiresStorageDevice( const char *command );
|
||||
bool CommandRespectsSignInDenied( const char *command );
|
||||
|
||||
void QueueCommand( const char *pCommand );
|
||||
void RunQueuedCommands();
|
||||
void ClearQueuedCommands();
|
||||
|
||||
virtual void PerformLayout();
|
||||
MESSAGE_FUNC_INT( OnActivateModule, "ActivateModule", moduleIndex);
|
||||
|
||||
void LoadVersionNumbers();
|
||||
bool LoadVersionNumber( const char *fileNameA, const char *fileNameB, wchar_t *pVersionBuffer, unsigned int versionBufferSizeBytes );
|
||||
|
||||
// Primary user id: used to determine signin privileges, etc
|
||||
int m_primaryUserId;
|
||||
|
||||
// menu logo
|
||||
CMainMenuGameLogo *m_pGameLogo;
|
||||
|
||||
// menu buttons
|
||||
CUtlVector< CBackgroundMenuButton * >m_pGameMenuButtons;
|
||||
CGameMenu *m_pGameMenu;
|
||||
bool m_bPlatformMenuInitialized;
|
||||
int m_iGameMenuInset;
|
||||
|
||||
struct coord {
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
CUtlVector< coord > m_iGameTitlePos;
|
||||
coord m_iGameMenuPos;
|
||||
|
||||
// base dialogs
|
||||
vgui::DHANDLE<vgui::Frame> m_hNewGameDialog;
|
||||
vgui::DHANDLE<vgui::Frame> m_hBonusMapsDialog;
|
||||
vgui::DHANDLE<vgui::Frame> m_hLoadGameDialog;
|
||||
vgui::DHANDLE<vgui::Frame> m_hLoadGameDialog_Xbox;
|
||||
vgui::DHANDLE<vgui::Frame> m_hSaveGameDialog;
|
||||
vgui::DHANDLE<vgui::Frame> m_hSaveGameDialog_Xbox;
|
||||
vgui::DHANDLE<vgui::PropertyDialog> m_hOptionsDialog;
|
||||
vgui::DHANDLE<vgui::Frame> m_hCreateMultiplayerGameDialog;
|
||||
//vgui::DHANDLE<vgui::Frame> m_hDemoPlayerDialog;
|
||||
vgui::DHANDLE<vgui::Frame> m_hChangeGameDialog;
|
||||
vgui::DHANDLE<vgui::Frame> m_hPlayerListDialog;
|
||||
vgui::DHANDLE<vgui::Frame> m_hBenchmarkDialog;
|
||||
vgui::DHANDLE<vgui::Frame> m_hLoadCommentaryDialog;
|
||||
|
||||
vgui::Label *m_pCodeVersionLabel;
|
||||
vgui::Label *m_pContentVersionLabel;
|
||||
|
||||
EBackgroundState m_eBackgroundState;
|
||||
|
||||
CMessageDialogHandler m_MessageDialogHandler;
|
||||
CUtlVector< CUtlString > m_CommandQueue;
|
||||
|
||||
vgui::AnimationController *m_pConsoleAnimationController;
|
||||
KeyValues *m_pConsoleControlSettings;
|
||||
|
||||
void DrawBackgroundImage();
|
||||
int m_iBackgroundImageID;
|
||||
int m_iRenderTargetImageID;
|
||||
int m_iLoadingImageID;
|
||||
int m_iProductImageID;
|
||||
bool m_bLevelLoading;
|
||||
bool m_bEverActivated;
|
||||
bool m_bCopyFrameBuffer;
|
||||
bool m_bUseRenderTargetImage;
|
||||
int m_ExitingFrameCount;
|
||||
bool m_bXUIVisible;
|
||||
bool m_bUseMatchmaking;
|
||||
bool m_bRestartFromInvite;
|
||||
bool m_bRestartSameGame;
|
||||
|
||||
// Used for internal state dealing with blades
|
||||
bool m_bUserRefusedSignIn;
|
||||
bool m_bUserRefusedStorageDevice;
|
||||
bool m_bWaitingForUserSignIn;
|
||||
bool m_bStorageBladeShown;
|
||||
CUtlString m_strPostPromptCommand;
|
||||
|
||||
// Used on PS3 to make sure stats get loaded before the player presses start.
|
||||
bool m_bStatsLoaded;
|
||||
|
||||
// Storage device changing vars
|
||||
bool m_bWaitingForStorageDeviceHandle;
|
||||
bool m_bNeedStorageDeviceHandle;
|
||||
AsyncHandle_t m_hStorageDeviceChangeHandle;
|
||||
uint m_iStorageID;
|
||||
int *m_pStorageDeviceValidatedNotify;
|
||||
|
||||
// background transition
|
||||
bool m_bFadingInMenus;
|
||||
float m_flFadeMenuStartTime;
|
||||
float m_flFadeMenuEndTime;
|
||||
|
||||
bool m_bRenderingBackgroundTransition;
|
||||
float m_flTransitionStartTime;
|
||||
float m_flTransitionEndTime;
|
||||
|
||||
// Used for rich presence updates on xbox360
|
||||
bool m_bSinglePlayer;
|
||||
uint m_iGameID; // matches context value in hl2orange.spa.h
|
||||
|
||||
// background fill transition
|
||||
bool m_bHaveDarkenedBackground;
|
||||
bool m_bHaveDarkenedTitleText;
|
||||
bool m_bForceTitleTextUpdate;
|
||||
float m_flFrameFadeInTime;
|
||||
Color m_BackdropColor;
|
||||
CPanelAnimationVar( float, m_flBackgroundFillAlpha, "m_flBackgroundFillAlpha", "0" );
|
||||
|
||||
// [jason] For platforms that don't require the start screen to set the default controller
|
||||
bool m_bBypassStartScreen;
|
||||
|
||||
// [jason] When flagged, we initially display "Press Start" screen and wait for controller input
|
||||
bool m_bShowStartScreen;
|
||||
|
||||
// [jason] Have we been notified (via CreateStartScreen) that the signin completed successfully?
|
||||
bool m_bStartScreenPlayerSigninCompleted;
|
||||
|
||||
// [jason] Should we use the Scaleform main menu, or the old vgui one?
|
||||
bool m_bScaleformMainMenuEnabled;
|
||||
bool m_bScaleformPauseMenuEnabled;
|
||||
|
||||
// [jason] Last value that ShowMainMenu was called with: is the old vgui active or not?
|
||||
bool m_bMainMenuShown;
|
||||
|
||||
|
||||
protected:
|
||||
int m_iIntroMovieButtonPressed;
|
||||
bool m_bIntroMovieWaitForButtonToClear;
|
||||
|
||||
// [sb] If true, then force us back to the start screen; useful for when primary player signs out
|
||||
bool m_bForceStartScreen;
|
||||
|
||||
public:
|
||||
void SetForceStartScreen() { m_bForceStartScreen = true; };
|
||||
|
||||
protected:
|
||||
|
||||
// fading to game
|
||||
MESSAGE_FUNC_CHARPTR( RunEngineCommand, "RunEngineCommand", command );
|
||||
MESSAGE_FUNC_CHARPTR( RunMenuCommand, "RunMenuCommand", command );
|
||||
MESSAGE_FUNC_INT_CHARPTR( RunSlottedMenuCommand, "RunSlottedMenuCommand", slot, command );
|
||||
MESSAGE_FUNC( FinishDialogClose, "FinishDialogClose" );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: singleton accessor
|
||||
//
|
||||
// These must be defined in the mod's derived panel
|
||||
//-----------------------------------------------------------------------------
|
||||
extern CBaseModPanel *BasePanel();
|
||||
extern CBaseModPanel *BasePanelSingleton(); // Constructs if not built yet
|
||||
|
||||
#endif
|
||||
|
||||
#endif // BASEPANEL_H
|
||||
549
game/client/cstrike15/gameui/basesavegamedialog.cpp
Normal file
549
game/client/cstrike15/gameui/basesavegamedialog.cpp
Normal file
@@ -0,0 +1,549 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
|
||||
#include "basesavegamedialog.h"
|
||||
#include "filesystem.h"
|
||||
#include "savegame_version.h"
|
||||
#include "vgui_controls/PanelListPanel.h"
|
||||
#include "vgui_controls/Label.h"
|
||||
#include "vgui_controls/ImagePanel.h"
|
||||
#include "vgui_controls/Button.h"
|
||||
#include "vgui_controls/tgaimagepanel.h"
|
||||
#include "tier1/utlbuffer.h"
|
||||
#include "tier2/resourceprecacher.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "filesystem.h"
|
||||
|
||||
#include "mousemessageforwardingpanel.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
#define TGA_IMAGE_PANEL_WIDTH 180
|
||||
#define TGA_IMAGE_PANEL_HEIGHT 100
|
||||
|
||||
#define MAX_LISTED_SAVE_GAMES 128
|
||||
|
||||
PRECACHE_REGISTER_BEGIN( GLOBAL, BaseSaveGameDialog )
|
||||
PRECACHE( MATERIAL, "vgui/resource/autosave.vmt" )
|
||||
PRECACHE_REGISTER_END()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Describes the layout of a same game pic
|
||||
//-----------------------------------------------------------------------------
|
||||
class CSaveGamePanel : public vgui::EditablePanel
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CSaveGamePanel, vgui::EditablePanel );
|
||||
public:
|
||||
CSaveGamePanel( PanelListPanel *parent, const char *name, int saveGameListItemID ) : BaseClass( parent, name )
|
||||
{
|
||||
m_iSaveGameListItemID = saveGameListItemID;
|
||||
m_pParent = parent;
|
||||
m_pSaveGameImage = new CTGAImagePanel( this, "SaveGameImage" );
|
||||
m_pAutoSaveImage = new ImagePanel( this, "AutoSaveImage" );
|
||||
m_pSaveGameScreenshotBackground = new ImagePanel( this, "SaveGameScreenshotBackground" );
|
||||
m_pChapterLabel = new Label( this, "ChapterLabel", "" );
|
||||
m_pTypeLabel = new Label( this, "TypeLabel", "" );
|
||||
m_pElapsedTimeLabel = new Label( this, "ElapsedTimeLabel", "" );
|
||||
m_pFileTimeLabel = new Label( this, "FileTimeLabel", "" );
|
||||
|
||||
CMouseMessageForwardingPanel *panel = new CMouseMessageForwardingPanel(this, NULL);
|
||||
panel->SetZPos(2);
|
||||
|
||||
SetSize( 200, 140 );
|
||||
|
||||
LoadControlSettings( "resource/SaveGamePanel.res" );
|
||||
|
||||
m_FillColor = m_pSaveGameScreenshotBackground->GetFillColor();
|
||||
}
|
||||
|
||||
void SetSaveGameInfo( SaveGameDescription_t &save )
|
||||
{
|
||||
// set the bitmap to display
|
||||
char tga[_MAX_PATH];
|
||||
Q_strncpy( tga, save.szFileName, sizeof(tga) );
|
||||
char *ext = strstr( tga, ".sav" );
|
||||
if ( ext )
|
||||
{
|
||||
strcpy( ext, ".tga" );
|
||||
}
|
||||
|
||||
// If a TGA file exists then it is a user created savegame
|
||||
if ( g_pFullFileSystem->FileExists( tga ) )
|
||||
{
|
||||
m_pSaveGameImage->SetTGAFilename( tga );
|
||||
}
|
||||
// If there is no TGA then it is either an autosave or the user TGA file has been deleted
|
||||
else
|
||||
{
|
||||
m_pSaveGameImage->SetVisible( false );
|
||||
m_pAutoSaveImage->SetVisible( true );
|
||||
m_pAutoSaveImage->SetImage( "resource\\autosave" );
|
||||
}
|
||||
|
||||
// set the title text
|
||||
m_pChapterLabel->SetText( save.szComment );
|
||||
|
||||
// type
|
||||
SetControlString( "TypeLabel", save.szType );
|
||||
SetControlString( "ElapsedTimeLabel", save.szElapsedTime );
|
||||
SetControlString( "FileTimeLabel", save.szFileTime );
|
||||
}
|
||||
|
||||
MESSAGE_FUNC_INT( OnPanelSelected, "PanelSelected", state )
|
||||
{
|
||||
if ( state )
|
||||
{
|
||||
// set the text color to be orange, and the pic border to be orange
|
||||
m_pSaveGameScreenshotBackground->SetFillColor( m_SelectedColor );
|
||||
m_pChapterLabel->SetFgColor( m_SelectedColor );
|
||||
m_pTypeLabel->SetFgColor( m_SelectedColor );
|
||||
m_pElapsedTimeLabel->SetFgColor( m_SelectedColor );
|
||||
m_pFileTimeLabel->SetFgColor( m_SelectedColor );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pSaveGameScreenshotBackground->SetFillColor( m_FillColor );
|
||||
m_pChapterLabel->SetFgColor( m_TextColor );
|
||||
m_pTypeLabel->SetFgColor( m_TextColor );
|
||||
m_pElapsedTimeLabel->SetFgColor( m_TextColor );
|
||||
m_pFileTimeLabel->SetFgColor( m_TextColor );
|
||||
}
|
||||
|
||||
PostMessage( m_pParent->GetVParent(), new KeyValues("PanelSelected") );
|
||||
}
|
||||
|
||||
virtual void OnMousePressed( vgui::MouseCode code )
|
||||
{
|
||||
m_pParent->SetSelectedPanel( this );
|
||||
}
|
||||
|
||||
virtual void ApplySchemeSettings( IScheme *pScheme )
|
||||
{
|
||||
m_TextColor = pScheme->GetColor( "NewGame.TextColor", Color(255, 255, 255, 255) );
|
||||
m_SelectedColor = pScheme->GetColor( "NewGame.SelectionColor", Color(255, 255, 255, 255) );
|
||||
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
}
|
||||
|
||||
virtual void OnMouseDoublePressed( vgui::MouseCode code )
|
||||
{
|
||||
// call the panel
|
||||
OnMousePressed( code );
|
||||
PostMessage( m_pParent->GetParent(), new KeyValues("Command", "command", "loadsave") );
|
||||
}
|
||||
|
||||
int GetSaveGameListItemID()
|
||||
{
|
||||
return m_iSaveGameListItemID;
|
||||
}
|
||||
|
||||
private:
|
||||
vgui::PanelListPanel *m_pParent;
|
||||
vgui::Label *m_pChapterLabel;
|
||||
CTGAImagePanel *m_pSaveGameImage;
|
||||
ImagePanel *m_pAutoSaveImage;
|
||||
|
||||
// things to change color when the selection changes
|
||||
ImagePanel *m_pSaveGameScreenshotBackground;
|
||||
Label *m_pTypeLabel;
|
||||
Label *m_pElapsedTimeLabel;
|
||||
Label *m_pFileTimeLabel;
|
||||
Color m_TextColor, m_FillColor, m_SelectedColor;
|
||||
|
||||
int m_iSaveGameListItemID;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CBaseSaveGameDialog::CBaseSaveGameDialog( vgui::Panel *parent, const char *name ) : BaseClass( parent, name )
|
||||
{
|
||||
CreateSavedGamesList();
|
||||
ScanSavedGames();
|
||||
|
||||
new vgui::Button( this, "loadsave", "" );
|
||||
SetControlEnabled( "loadsave", false );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Creates the load game display list
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseSaveGameDialog::CreateSavedGamesList()
|
||||
{
|
||||
m_pGameList = new vgui::PanelListPanel( this, "listpanel_loadgame" );
|
||||
m_pGameList->SetFirstColumnWidth( 0 );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: returns the save file name of the selected item
|
||||
//-----------------------------------------------------------------------------
|
||||
int CBaseSaveGameDialog::GetSelectedItemSaveIndex()
|
||||
{
|
||||
CSaveGamePanel *panel = dynamic_cast<CSaveGamePanel *>(m_pGameList->GetSelectedPanel());
|
||||
if ( panel )
|
||||
{
|
||||
// find the panel in the list
|
||||
for ( int i = 0; i < m_SaveGames.Count(); i++ )
|
||||
{
|
||||
if ( i == panel->GetSaveGameListItemID() )
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return m_SaveGames.InvalidIndex();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: builds save game list from directory
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseSaveGameDialog::ScanSavedGames()
|
||||
{
|
||||
// populate list box with all saved games on record:
|
||||
char szDirectory[_MAX_PATH];
|
||||
Q_snprintf( szDirectory, sizeof( szDirectory ), "save/*.sav" );
|
||||
|
||||
// clear the current list
|
||||
m_pGameList->DeleteAllItems();
|
||||
m_SaveGames.RemoveAll();
|
||||
|
||||
// iterate the saved files
|
||||
FileFindHandle_t handle;
|
||||
const char *pFileName = g_pFullFileSystem->FindFirst( szDirectory, &handle );
|
||||
while (pFileName)
|
||||
{
|
||||
if ( StringHasPrefix( pFileName, "HLSave" ) )
|
||||
{
|
||||
pFileName = g_pFullFileSystem->FindNext( handle );
|
||||
continue;
|
||||
}
|
||||
|
||||
char szFileName[_MAX_PATH];
|
||||
Q_snprintf(szFileName, sizeof( szFileName ), "save/%s", pFileName);
|
||||
|
||||
// Only load save games from the current mod's save dir
|
||||
if( !g_pFullFileSystem->FileExists( szFileName, "MOD" ) )
|
||||
{
|
||||
pFileName = g_pFullFileSystem->FindNext( handle );
|
||||
continue;
|
||||
}
|
||||
|
||||
SaveGameDescription_t save;
|
||||
if ( ParseSaveData( szFileName, pFileName, save ) )
|
||||
{
|
||||
m_SaveGames.AddToTail( save );
|
||||
}
|
||||
|
||||
pFileName = g_pFullFileSystem->FindNext( handle );
|
||||
}
|
||||
|
||||
g_pFullFileSystem->FindClose( handle );
|
||||
|
||||
// notify derived classes that save games are being scanned (so they can insert their own)
|
||||
OnScanningSaveGames();
|
||||
|
||||
// sort the save list
|
||||
qsort( m_SaveGames.Base(), m_SaveGames.Count(), sizeof(SaveGameDescription_t), &SaveGameSortFunc );
|
||||
|
||||
// add to the list
|
||||
for ( int saveIndex = 0; saveIndex < m_SaveGames.Count() && saveIndex < MAX_LISTED_SAVE_GAMES; saveIndex++ )
|
||||
{
|
||||
// add the item to the panel
|
||||
AddSaveGameItemToList( saveIndex );
|
||||
}
|
||||
|
||||
// display a message if there are no save games
|
||||
if ( !m_SaveGames.Count() )
|
||||
{
|
||||
vgui::Label *pNoSavesLabel = SETUP_PANEL(new Label(m_pGameList, "NoSavesLabel", "#GameUI_NoSaveGamesToDisplay"));
|
||||
pNoSavesLabel->SetTextColorState(vgui::Label::CS_DULL);
|
||||
m_pGameList->AddItem( NULL, pNoSavesLabel );
|
||||
}
|
||||
|
||||
SetControlEnabled( "loadsave", false );
|
||||
SetControlEnabled( "delete", false );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Adds an item to the list
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseSaveGameDialog::AddSaveGameItemToList( int saveIndex )
|
||||
{
|
||||
// create the new panel and add to the list
|
||||
CSaveGamePanel *saveGamePanel = new CSaveGamePanel( m_pGameList, "SaveGamePanel", saveIndex );
|
||||
saveGamePanel->SetSaveGameInfo( m_SaveGames[saveIndex] );
|
||||
m_pGameList->AddItem( NULL, saveGamePanel );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Parses the save game info out of the .sav file header
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CBaseSaveGameDialog::ParseSaveData( char const *pszFileName, char const *pszShortName, SaveGameDescription_t &save )
|
||||
{
|
||||
char szMapName[SAVEGAME_MAPNAME_LEN];
|
||||
char szComment[SAVEGAME_COMMENT_LEN];
|
||||
char szElapsedTime[SAVEGAME_ELAPSED_LEN];
|
||||
|
||||
if ( !pszFileName || !pszShortName )
|
||||
return false;
|
||||
|
||||
Q_strncpy( save.szShortName, pszShortName, sizeof(save.szShortName) );
|
||||
Q_strncpy( save.szFileName, pszFileName, sizeof(save.szFileName) );
|
||||
|
||||
FileHandle_t fh = g_pFullFileSystem->Open( pszFileName, "rb", "MOD" );
|
||||
if (fh == FILESYSTEM_INVALID_HANDLE)
|
||||
return false;
|
||||
|
||||
int readok = SaveReadNameAndComment( fh, szMapName, szComment );
|
||||
g_pFullFileSystem->Close(fh);
|
||||
|
||||
if ( !readok )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Q_strncpy( save.szMapName, szMapName, sizeof(save.szMapName) );
|
||||
|
||||
// Elapsed time is the last 6 characters in comment. (mmm:ss)
|
||||
int i;
|
||||
i = strlen( szComment );
|
||||
Q_strncpy( szElapsedTime, "??", sizeof( szElapsedTime ) );
|
||||
if (i >= 6)
|
||||
{
|
||||
Q_strncpy( szElapsedTime, (char *)&szComment[i - 6], 7 );
|
||||
szElapsedTime[6] = '\0';
|
||||
|
||||
// parse out
|
||||
int minutes = atoi( szElapsedTime );
|
||||
int seconds = atoi( szElapsedTime + 4);
|
||||
|
||||
// reformat
|
||||
if ( minutes )
|
||||
{
|
||||
Q_snprintf( szElapsedTime, sizeof(szElapsedTime), "%d %s %d seconds", minutes, minutes > 1 ? "minutes" : "minute", seconds );
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_snprintf( szElapsedTime, sizeof(szElapsedTime), "%d seconds", seconds );
|
||||
}
|
||||
|
||||
// Chop elapsed out of comment.
|
||||
int n;
|
||||
|
||||
n = i - 6;
|
||||
szComment[n] = '\0';
|
||||
|
||||
n--;
|
||||
|
||||
// Strip back the spaces at the end.
|
||||
while ((n >= 1) &&
|
||||
szComment[n] &&
|
||||
szComment[n] == ' ')
|
||||
{
|
||||
szComment[n--] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
// calculate the file name to print
|
||||
const char *pszType = "";
|
||||
if (strstr(pszFileName, "quick"))
|
||||
{
|
||||
pszType = "#GameUI_QuickSave";
|
||||
}
|
||||
else if (strstr(pszFileName, "autosave"))
|
||||
{
|
||||
pszType = "#GameUI_AutoSave";
|
||||
}
|
||||
|
||||
Q_strncpy( save.szType, pszType, sizeof(save.szType) );
|
||||
Q_strncpy( save.szComment, szComment, sizeof(save.szComment) );
|
||||
Q_strncpy( save.szElapsedTime, szElapsedTime, sizeof(save.szElapsedTime) );
|
||||
|
||||
// Now get file time stamp.
|
||||
long fileTime = g_pFullFileSystem->GetFileTime(pszFileName);
|
||||
char szFileTime[32];
|
||||
g_pFullFileSystem->FileTimeToString(szFileTime, sizeof(szFileTime), fileTime);
|
||||
char *newline = strstr(szFileTime, "\n");
|
||||
if (newline)
|
||||
{
|
||||
*newline = 0;
|
||||
}
|
||||
Q_strncpy( save.szFileTime, szFileTime, sizeof(save.szFileTime) );
|
||||
save.iTimestamp = fileTime;
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: timestamp sort function for savegames
|
||||
//-----------------------------------------------------------------------------
|
||||
int CBaseSaveGameDialog::SaveGameSortFunc( const void *lhs, const void *rhs )
|
||||
{
|
||||
const SaveGameDescription_t *s1 = (const SaveGameDescription_t *)lhs;
|
||||
const SaveGameDescription_t *s2 = (const SaveGameDescription_t *)rhs;
|
||||
|
||||
if (s1->iTimestamp < s2->iTimestamp)
|
||||
return 1;
|
||||
else if (s1->iTimestamp > s2->iTimestamp)
|
||||
return -1;
|
||||
|
||||
// timestamps are equal, so just sort by filename
|
||||
return strcmp(s1->szFileName, s2->szFileName);
|
||||
}
|
||||
|
||||
#define MAKEID(d,c,b,a) ( ((int)(a) << 24) | ((int)(b) << 16) | ((int)(c) << 8) | ((int)(d)) )
|
||||
|
||||
int SaveReadNameAndComment( FileHandle_t f, char *name, char *comment )
|
||||
{
|
||||
int i, tag, size, tokenSize, tokenCount;
|
||||
char *pSaveData, *pFieldName, **pTokenList;
|
||||
|
||||
g_pFullFileSystem->Read( &tag, sizeof(int), f );
|
||||
if ( tag != MAKEID('J','S','A','V') )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_pFullFileSystem->Read( &tag, sizeof(int), f );
|
||||
if ( tag != SAVEGAME_VERSION ) // Enforce version for now
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
name[0] = '\0';
|
||||
comment[0] = '\0';
|
||||
g_pFullFileSystem->Read( &size, sizeof(int), f );
|
||||
|
||||
g_pFullFileSystem->Read( &tokenCount, sizeof(int), f ); // These two ints are the token list
|
||||
g_pFullFileSystem->Read( &tokenSize, sizeof(int), f );
|
||||
size += tokenSize;
|
||||
|
||||
// Sanity Check.
|
||||
if ( tokenCount < 0 || tokenCount > 1024*1024*32 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( tokenSize < 0 || tokenSize > 1024*1024*32 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
pSaveData = (char *)new char[size];
|
||||
g_pFullFileSystem->Read(pSaveData, size, f);
|
||||
|
||||
int nNumberOfFields;
|
||||
|
||||
char *pData;
|
||||
int nFieldSize;
|
||||
|
||||
pData = pSaveData;
|
||||
|
||||
// Allocate a table for the strings, and parse the table
|
||||
if ( tokenSize > 0 )
|
||||
{
|
||||
pTokenList = new char *[tokenCount];
|
||||
|
||||
// Make sure the token strings pointed to by the pToken hashtable.
|
||||
for( i=0; i<tokenCount; i++ )
|
||||
{
|
||||
pTokenList[i] = *pData ? pData : NULL; // Point to each string in the pToken table
|
||||
while( *pData++ ); // Find next token (after next null)
|
||||
}
|
||||
}
|
||||
else
|
||||
pTokenList = NULL;
|
||||
|
||||
// short, short (size, index of field name)
|
||||
nFieldSize = *(short *)pData;
|
||||
pData += sizeof(short);
|
||||
pFieldName = pTokenList[ *(short *)pData ];
|
||||
|
||||
if (stricmp(pFieldName, "GameHeader"))
|
||||
{
|
||||
delete[] pSaveData;
|
||||
return 0;
|
||||
};
|
||||
|
||||
// int (fieldcount)
|
||||
pData += sizeof(short);
|
||||
nNumberOfFields = *(int*)pData;
|
||||
pData += nFieldSize;
|
||||
|
||||
// Each field is a short (size), short (index of name), binary string of "size" bytes (data)
|
||||
for (i = 0; i < nNumberOfFields; i++)
|
||||
{
|
||||
// Data order is:
|
||||
// Size
|
||||
// szName
|
||||
// Actual Data
|
||||
|
||||
nFieldSize = *(short *)pData;
|
||||
pData += sizeof(short);
|
||||
|
||||
pFieldName = pTokenList[ *(short *)pData ];
|
||||
pData += sizeof(short);
|
||||
|
||||
if (!stricmp(pFieldName, "comment"))
|
||||
{
|
||||
Q_strncpy(comment, pData, nFieldSize);
|
||||
}
|
||||
else if (!stricmp(pFieldName, "mapName"))
|
||||
{
|
||||
Q_strncpy(name, pData, nFieldSize);
|
||||
};
|
||||
|
||||
// Move to Start of next field.
|
||||
pData += nFieldSize;
|
||||
};
|
||||
|
||||
// Delete the string table we allocated
|
||||
delete[] pTokenList;
|
||||
delete[] pSaveData;
|
||||
|
||||
if (strlen(name) > 0 && strlen(comment) > 0)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: deletes an existing save game
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseSaveGameDialog::DeleteSaveGame( const char *fileName )
|
||||
{
|
||||
if ( !fileName || !fileName[0] )
|
||||
return;
|
||||
|
||||
// delete the save game file
|
||||
g_pFullFileSystem->RemoveFile( fileName, "MOD" );
|
||||
|
||||
// delete the associated tga
|
||||
char tga[_MAX_PATH];
|
||||
Q_strncpy( tga, fileName, sizeof(tga) );
|
||||
char *ext = strstr( tga, ".sav" );
|
||||
if ( ext )
|
||||
{
|
||||
strcpy( ext, ".tga" );
|
||||
}
|
||||
g_pFullFileSystem->RemoveFile( tga, "MOD" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: One item has been selected
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseSaveGameDialog::OnPanelSelected()
|
||||
{
|
||||
SetControlEnabled( "loadsave", true );
|
||||
SetControlEnabled( "delete", true );
|
||||
}
|
||||
|
||||
|
||||
71
game/client/cstrike15/gameui/basesavegamedialog.h
Normal file
71
game/client/cstrike15/gameui/basesavegamedialog.h
Normal file
@@ -0,0 +1,71 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef BASESAVEGAMEDIALOG_H
|
||||
#define BASESAVEGAMEDIALOG_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui_controls/Frame.h"
|
||||
#include "vgui/MouseCode.h"
|
||||
#include "keyvalues.h"
|
||||
#include "utlvector.h"
|
||||
|
||||
|
||||
#define SAVEGAME_MAPNAME_LEN 32
|
||||
#define SAVEGAME_COMMENT_LEN 80
|
||||
#define SAVEGAME_ELAPSED_LEN 32
|
||||
|
||||
|
||||
struct SaveGameDescription_t
|
||||
{
|
||||
char szShortName[64];
|
||||
char szFileName[128];
|
||||
char szMapName[SAVEGAME_MAPNAME_LEN];
|
||||
char szComment[SAVEGAME_COMMENT_LEN];
|
||||
char szType[64];
|
||||
char szElapsedTime[SAVEGAME_ELAPSED_LEN];
|
||||
char szFileTime[32];
|
||||
unsigned int iTimestamp;
|
||||
unsigned int iSize;
|
||||
};
|
||||
|
||||
|
||||
int SaveReadNameAndComment( FileHandle_t f, char *name, char *comment );
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Base class for save & load game dialogs
|
||||
//-----------------------------------------------------------------------------
|
||||
class CBaseSaveGameDialog : public vgui::Frame
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CBaseSaveGameDialog, vgui::Frame );
|
||||
|
||||
public:
|
||||
CBaseSaveGameDialog( vgui::Panel *parent, const char *name );
|
||||
static int __cdecl SaveGameSortFunc( const void *lhs, const void *rhs );
|
||||
|
||||
protected:
|
||||
CUtlVector<SaveGameDescription_t> m_SaveGames;
|
||||
vgui::PanelListPanel *m_pGameList;
|
||||
|
||||
virtual void OnScanningSaveGames() {}
|
||||
|
||||
void DeleteSaveGame( const char *fileName );
|
||||
void ScanSavedGames();
|
||||
void CreateSavedGamesList();
|
||||
int GetSelectedItemSaveIndex();
|
||||
void AddSaveGameItemToList( int saveIndex );
|
||||
|
||||
bool ParseSaveData( char const *pszFileName, char const *pszShortName, SaveGameDescription_t &save );
|
||||
|
||||
private:
|
||||
MESSAGE_FUNC( OnPanelSelected, "PanelSelected" );
|
||||
};
|
||||
|
||||
|
||||
#endif // BASESAVEGAMEDIALOG_H
|
||||
118
game/client/cstrike15/gameui/benchmarkdialog.cpp
Normal file
118
game/client/cstrike15/gameui/benchmarkdialog.cpp
Normal file
@@ -0,0 +1,118 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "benchmarkdialog.h"
|
||||
#include "engineinterface.h"
|
||||
#include "basepanel.h"
|
||||
#include "tier1/keyvalues.h"
|
||||
#include "tier1/convar.h"
|
||||
#include "filesystem.h"
|
||||
#include "vgui_controls/Button.h"
|
||||
#include "vgui_controls/CheckButton.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CBenchmarkDialog::CBenchmarkDialog(vgui::Panel *parent, const char *name) : BaseClass(parent, name)
|
||||
{
|
||||
Button *button = new Button(this, "RunButton", "RunButton");
|
||||
button->SetCommand(new KeyValues("RunBenchmark"));
|
||||
SetSizeable(false);
|
||||
SetDeleteSelfOnClose(true);
|
||||
|
||||
LoadControlSettings("Resource/BenchmarkDialog.res");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Launches the benchmark
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBenchmarkDialog::RunBenchmark()
|
||||
{
|
||||
// apply settings
|
||||
BasePanel()->ApplyOptionsDialogSettings();
|
||||
|
||||
// launch the map
|
||||
engine->ClientCmd_Unrestricted("disconnect\n");
|
||||
engine->ClientCmd_Unrestricted("wait\n");
|
||||
engine->ClientCmd_Unrestricted("wait\n");
|
||||
engine->ClientCmd_Unrestricted("maxplayers 1\n");
|
||||
engine->ClientCmd_Unrestricted("progress_enable\n");
|
||||
engine->ClientCmd_Unrestricted("map test_hardware\n");
|
||||
|
||||
// close this dialog
|
||||
Close();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Displays benchmark results
|
||||
//-----------------------------------------------------------------------------
|
||||
class CBenchmarkResultsDialog : public vgui::Frame
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CBenchmarkResultsDialog, vgui::Frame );
|
||||
public:
|
||||
CBenchmarkResultsDialog( vgui::Panel *parent, const char *name ) : BaseClass( parent, name )
|
||||
{
|
||||
SetTitle("#GameUI_BenchmarkResults_Title", true);
|
||||
SetDeleteSelfOnClose(true);
|
||||
SetSizeable(false);
|
||||
|
||||
m_pUploadCheck = new CheckButton( this, "UploadCheck", "#GameUI_BenchmarkResults_UploadNow" );
|
||||
|
||||
LoadControlSettings("Resource/BenchmarkResultsDialog.res");
|
||||
|
||||
m_pUploadCheck->SetSelected( true );
|
||||
MoveToCenterOfScreen();
|
||||
}
|
||||
|
||||
virtual void Activate()
|
||||
{
|
||||
BaseClass::Activate();
|
||||
|
||||
KeyValues *kv = new KeyValues( "Benchmark" );
|
||||
if ( kv->LoadFromFile( g_pFullFileSystem, "results/results.txt", "MOD" ) )
|
||||
{
|
||||
// get the framerate
|
||||
char szFrameRate[32];
|
||||
Q_snprintf( szFrameRate, sizeof(szFrameRate), "%.2f", kv->GetFloat("framerate") );
|
||||
SetDialogVariable( "framerate", szFrameRate );
|
||||
}
|
||||
else
|
||||
{
|
||||
Close();
|
||||
}
|
||||
kv->deleteThis();
|
||||
}
|
||||
|
||||
private:
|
||||
virtual void OnClose()
|
||||
{
|
||||
if ( m_pUploadCheck->IsSelected() )
|
||||
{
|
||||
engine->ClientCmd_Unrestricted( "bench_upload\n" );
|
||||
}
|
||||
BaseClass::OnClose();
|
||||
}
|
||||
|
||||
vgui::CheckButton *m_pUploadCheck;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Launches the stats dialog
|
||||
//-----------------------------------------------------------------------------
|
||||
CON_COMMAND_F( bench_showstatsdialog, "Shows a dialog displaying the most recent benchmark results.", FCVAR_CHEAT )
|
||||
{
|
||||
static vgui::DHANDLE<CBenchmarkResultsDialog> g_BenchmarkResultsDialog;
|
||||
|
||||
if (!g_BenchmarkResultsDialog.Get())
|
||||
{
|
||||
g_BenchmarkResultsDialog = new CBenchmarkResultsDialog( BasePanel(), "BenchmarkResultsDialog" );
|
||||
}
|
||||
|
||||
g_BenchmarkResultsDialog->Activate();
|
||||
}
|
||||
29
game/client/cstrike15/gameui/benchmarkdialog.h
Normal file
29
game/client/cstrike15/gameui/benchmarkdialog.h
Normal file
@@ -0,0 +1,29 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef BENCHMARKDIALOG_H
|
||||
#define BENCHMARKDIALOG_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui_controls/Frame.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Benchmark launch dialog
|
||||
//-----------------------------------------------------------------------------
|
||||
class CBenchmarkDialog : public vgui::Frame
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CBenchmarkDialog, vgui::Frame );
|
||||
public:
|
||||
CBenchmarkDialog(vgui::Panel *parent, const char *name);
|
||||
|
||||
private:
|
||||
MESSAGE_FUNC( RunBenchmark, "RunBenchmark" );
|
||||
};
|
||||
|
||||
|
||||
#endif // BENCHMARKDIALOG_H
|
||||
78
game/client/cstrike15/gameui/bitmapimagepanel.cpp
Normal file
78
game/client/cstrike15/gameui/bitmapimagepanel.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "bitmapimagepanel.h"
|
||||
#include <vgui/ISurface.h>
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
CBitmapImagePanel::CBitmapImagePanel( Panel *parent, char const *panelName,
|
||||
char const *filename /*= NULL*/ ) : Panel( parent, panelName )
|
||||
{
|
||||
m_szTexture[ 0 ] = 0;
|
||||
m_bUploaded = false;
|
||||
m_nTextureId = -1;
|
||||
|
||||
SetBounds( 0, 0, 100, 100 );
|
||||
|
||||
if ( filename && filename[ 0 ] )
|
||||
{
|
||||
Q_strncpy( m_szTexture, filename, sizeof( m_szTexture ) );
|
||||
}
|
||||
}
|
||||
|
||||
void CBitmapImagePanel::PaintBackground()
|
||||
{
|
||||
if (!m_szTexture[0])
|
||||
return;
|
||||
|
||||
if ( !m_bUploaded )
|
||||
forceUpload();
|
||||
|
||||
int w, h;
|
||||
GetSize( w, h );
|
||||
surface()->DrawSetColor( Color( 255, 255, 255, 255 ) );
|
||||
surface()->DrawSetTexture( m_nTextureId );
|
||||
surface()->DrawTexturedRect( 0, 0, w, h );
|
||||
}
|
||||
|
||||
void CBitmapImagePanel::setTexture( char const *filename )
|
||||
{
|
||||
Q_strncpy( m_szTexture, filename, sizeof( m_szTexture ) );
|
||||
|
||||
if ( m_bUploaded )
|
||||
{
|
||||
forceReload();
|
||||
}
|
||||
else
|
||||
{
|
||||
forceUpload();
|
||||
}
|
||||
}
|
||||
|
||||
void CBitmapImagePanel::forceUpload()
|
||||
{
|
||||
if ( !m_szTexture[ 0 ] )
|
||||
return;
|
||||
|
||||
m_bUploaded = true;
|
||||
|
||||
m_nTextureId = surface()->CreateNewTextureID();
|
||||
surface()->DrawSetTextureFile( m_nTextureId, m_szTexture, false, true);
|
||||
}
|
||||
|
||||
void CBitmapImagePanel::forceReload( void )
|
||||
{
|
||||
if ( !m_bUploaded )
|
||||
return;
|
||||
|
||||
// Force texture to re-upload to video card
|
||||
surface()->DrawSetTextureFile( m_nTextureId, m_szTexture, false, true);
|
||||
}
|
||||
37
game/client/cstrike15/gameui/bitmapimagepanel.h
Normal file
37
game/client/cstrike15/gameui/bitmapimagepanel.h
Normal file
@@ -0,0 +1,37 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef BITMAPIMAGEPANEL_H
|
||||
#define BITMAPIMAGEPANEL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui_controls/Panel.h>
|
||||
|
||||
class CBitmapImagePanel : public vgui::Panel
|
||||
{
|
||||
public:
|
||||
CBitmapImagePanel( vgui::Panel *parent, char const *panelName, char const *filename = NULL );
|
||||
|
||||
virtual void PaintBackground();
|
||||
|
||||
virtual void setTexture( char const *filename );
|
||||
|
||||
virtual void forceReload( void );
|
||||
|
||||
private:
|
||||
typedef vgui::Panel BaseClass;
|
||||
|
||||
void forceUpload();
|
||||
|
||||
bool m_bUploaded;
|
||||
int m_nTextureId;
|
||||
char m_szTexture[ 128 ];
|
||||
};
|
||||
|
||||
#endif // BITMAPIMAGEPANEL_H
|
||||
881
game/client/cstrike15/gameui/bonusmapsdatabase.cpp
Normal file
881
game/client/cstrike15/gameui/bonusmapsdatabase.cpp
Normal file
@@ -0,0 +1,881 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "bonusmapsdatabase.h"
|
||||
#include "engineinterface.h"
|
||||
|
||||
#include "tier1/convar.h"
|
||||
#include "tier1/utlbuffer.h"
|
||||
|
||||
#include "filesystem.h"
|
||||
#include "modinfo.h"
|
||||
#include "engineinterface.h"
|
||||
#include "ixboxsystem.h"
|
||||
#include "keyvalues.h"
|
||||
#include "basepanel.h"
|
||||
#include "gameui_interface.h"
|
||||
#include "bonusmapsdialog.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
#define MOD_DIR ( "MOD" )
|
||||
|
||||
|
||||
const char g_pszMedalNames[4][8] =
|
||||
{
|
||||
"none",
|
||||
"bronze",
|
||||
"silver",
|
||||
"gold"
|
||||
};
|
||||
|
||||
|
||||
const char *COM_GetModDirectory();
|
||||
|
||||
|
||||
bool WriteBonusMapSavedData( KeyValues *data )
|
||||
{
|
||||
if ( IsGameConsole() && ( XBX_GetStorageDeviceId(XBX_GetPrimaryUserId()) == XBX_INVALID_STORAGE_ID || XBX_GetStorageDeviceId(XBX_GetPrimaryUserId()) == XBX_STORAGE_DECLINED ) )
|
||||
return false;
|
||||
|
||||
CUtlBuffer buf( 0, 0, CUtlBuffer::TEXT_BUFFER );
|
||||
|
||||
data->RecursiveSaveToFile( buf, 0 );
|
||||
|
||||
char szFilename[_MAX_PATH];
|
||||
|
||||
if ( IsGameConsole() )
|
||||
Q_snprintf( szFilename, sizeof( szFilename ), "cfg:/bonus_maps_data.bmd" );
|
||||
else
|
||||
Q_snprintf( szFilename, sizeof( szFilename ), "save/bonus_maps_data.bmd" );
|
||||
|
||||
bool bWriteSuccess = g_pFullFileSystem->WriteFile( szFilename, MOD_DIR, buf );
|
||||
|
||||
xboxsystem->FinishContainerWrites(XBX_GetPrimaryUserId());
|
||||
|
||||
return bWriteSuccess;
|
||||
}
|
||||
|
||||
void GetBooleanStatus( KeyValues *pBonusFilesKey, BonusMapDescription_t &map )
|
||||
{
|
||||
KeyValues *pFileKey = NULL;
|
||||
KeyValues *pBonusKey = NULL;
|
||||
|
||||
for ( pFileKey = pBonusFilesKey->GetFirstSubKey(); pFileKey; pFileKey = pFileKey->GetNextTrueSubKey() )
|
||||
{
|
||||
if ( Q_strcmp( pFileKey->GetName(), map.szFileName ) == 0 )
|
||||
{
|
||||
for ( pBonusKey = pFileKey->GetFirstSubKey(); pBonusKey; pBonusKey = pBonusKey->GetNextKey() )
|
||||
{
|
||||
if ( Q_strcmp( pBonusKey->GetName(), map.szMapName ) == 0 )
|
||||
{
|
||||
// Found the data
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( pBonusKey )
|
||||
{
|
||||
map.bLocked = ( pBonusKey->GetInt( "lock" ) != 0 );
|
||||
map.bComplete = ( pBonusKey->GetInt( "complete" ) != 0 );
|
||||
}
|
||||
}
|
||||
|
||||
bool SetBooleanStatus( KeyValues *pBonusFilesKey, const char *pchName, const char *pchFileName, const char *pchMapName, bool bValue )
|
||||
{
|
||||
// Don't create entries for files that don't exist
|
||||
if ( !IsGameConsole() && !g_pFullFileSystem->FileExists( pchFileName, "MOD" ) )
|
||||
{
|
||||
DevMsg( "Failed to set boolean status for file %s.", pchFileName );
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bChanged = false;
|
||||
|
||||
KeyValues *pFileKey = NULL;
|
||||
KeyValues *pBonusKey = NULL;
|
||||
|
||||
for ( pFileKey = pBonusFilesKey->GetFirstSubKey(); pFileKey; pFileKey = pFileKey->GetNextTrueSubKey() )
|
||||
{
|
||||
if ( Q_strcmp( pFileKey->GetName(), pchFileName ) == 0 )
|
||||
{
|
||||
for ( pBonusKey = pFileKey->GetFirstSubKey(); pBonusKey; pBonusKey = pBonusKey->GetNextKey() )
|
||||
{
|
||||
if ( Q_strcmp( pBonusKey->GetName(), pchMapName ) == 0 )
|
||||
{
|
||||
// Found the data
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !pFileKey )
|
||||
{
|
||||
// Didn't find it, so create a new spot for the data
|
||||
pFileKey = new KeyValues( pchFileName );
|
||||
pBonusFilesKey->AddSubKey( pFileKey );
|
||||
}
|
||||
|
||||
if ( !pBonusKey )
|
||||
{
|
||||
pBonusKey = new KeyValues( pchMapName, pchName, "0" );
|
||||
pFileKey->AddSubKey( pBonusKey );
|
||||
bChanged = true;
|
||||
}
|
||||
|
||||
if ( ( pBonusKey->GetInt( pchName ) != 0 ) != bValue )
|
||||
{
|
||||
bChanged = true;
|
||||
pBonusKey->SetInt( pchName, bValue );
|
||||
}
|
||||
|
||||
return bChanged;
|
||||
}
|
||||
|
||||
float GetChallengeBests( KeyValues *pBonusFilesKey, BonusMapDescription_t &challenge )
|
||||
{
|
||||
// There's no challenges, so bail and assume 0% challenge completion
|
||||
if ( challenge.m_pChallenges == NULL || challenge.m_pChallenges->Count() == 0 )
|
||||
return 0.0f;
|
||||
|
||||
KeyValues *pFileKey = NULL;
|
||||
KeyValues *pBonusKey = NULL;
|
||||
|
||||
for ( pFileKey = pBonusFilesKey->GetFirstSubKey(); pFileKey; pFileKey = pFileKey->GetNextTrueSubKey() )
|
||||
{
|
||||
if ( Q_strcmp( pFileKey->GetName(), challenge.szFileName ) == 0 )
|
||||
{
|
||||
for ( pBonusKey = pFileKey->GetFirstSubKey(); pBonusKey; pBonusKey = pBonusKey->GetNextKey() )
|
||||
{
|
||||
if ( Q_strcmp( pBonusKey->GetName(), challenge.szMapName ) == 0 )
|
||||
{
|
||||
// Found the data
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
float fChallengePoints = 0.0f;
|
||||
|
||||
for ( int iChallenge = 0; iChallenge < challenge.m_pChallenges->Count(); ++iChallenge )
|
||||
{
|
||||
ChallengeDescription_t *pChallengeDescription = &((*challenge.m_pChallenges)[ iChallenge ]);
|
||||
pChallengeDescription->iBest = ( ( pBonusKey ) ? ( pBonusKey->GetInt( pChallengeDescription->szName, -1 ) ) : ( -1 ) );
|
||||
|
||||
if ( pChallengeDescription->iBest >= 0 )
|
||||
{
|
||||
if ( pChallengeDescription->iBest <= pChallengeDescription->iGold )
|
||||
fChallengePoints += 3.0f;
|
||||
else if ( pChallengeDescription->iBest <= pChallengeDescription->iSilver )
|
||||
fChallengePoints += 2.0f;
|
||||
else if ( pChallengeDescription->iBest <= pChallengeDescription->iBronze )
|
||||
fChallengePoints += 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
return fChallengePoints / ( challenge.m_pChallenges->Count() * 3.0f );
|
||||
}
|
||||
|
||||
bool UpdateChallengeBest( KeyValues *pBonusFilesKey, const BonusMapChallenge_t &challenge )
|
||||
{
|
||||
// Don't create entries for files that don't exist
|
||||
if ( !IsGameConsole() && !g_pFullFileSystem->FileExists( challenge.szFileName, "MOD" ) )
|
||||
{
|
||||
DevMsg( "Failed to set challenge best for file %s.", challenge.szFileName );
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bChanged = false;
|
||||
|
||||
KeyValues *pFileKey = NULL;
|
||||
KeyValues *pBonusKey = NULL;
|
||||
|
||||
for ( pFileKey = pBonusFilesKey->GetFirstSubKey(); pFileKey; pFileKey = pFileKey->GetNextTrueSubKey() )
|
||||
{
|
||||
if ( Q_strcmp( pFileKey->GetName(), challenge.szFileName ) == 0 )
|
||||
{
|
||||
for ( pBonusKey = pFileKey->GetFirstSubKey(); pBonusKey; pBonusKey = pBonusKey->GetNextKey() )
|
||||
{
|
||||
if ( Q_strcmp( pBonusKey->GetName(), challenge.szMapName ) == 0 )
|
||||
{
|
||||
// Found the challenge
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !pFileKey )
|
||||
{
|
||||
// Didn't find it, so create a new spot for data
|
||||
pFileKey = new KeyValues( challenge.szFileName );
|
||||
pBonusFilesKey->AddSubKey( pFileKey );
|
||||
}
|
||||
|
||||
if ( !pBonusKey )
|
||||
{
|
||||
pBonusKey = new KeyValues( challenge.szMapName, challenge.szChallengeName, -1 );
|
||||
pFileKey->AddSubKey( pBonusKey );
|
||||
bChanged = true;
|
||||
}
|
||||
|
||||
int iCurrentBest = pBonusKey->GetInt( challenge.szChallengeName, -1 );
|
||||
if ( iCurrentBest == -1 || iCurrentBest > challenge.iBest )
|
||||
{
|
||||
bChanged = true;
|
||||
pBonusKey->SetInt( challenge.szChallengeName, challenge.iBest );
|
||||
}
|
||||
|
||||
return bChanged;
|
||||
}
|
||||
|
||||
void GetChallengeMedals( ChallengeDescription_t *pChallengeDescription, int &iBest, int &iEarnedMedal, int &iNext, int &iNextMedal )
|
||||
{
|
||||
iBest = pChallengeDescription->iBest;
|
||||
|
||||
if ( iBest == -1 )
|
||||
iEarnedMedal = 0;
|
||||
else if ( iBest <= pChallengeDescription->iGold )
|
||||
iEarnedMedal = 3;
|
||||
else if ( iBest <= pChallengeDescription->iSilver )
|
||||
iEarnedMedal = 2;
|
||||
else if ( iBest <= pChallengeDescription->iBronze )
|
||||
iEarnedMedal = 1;
|
||||
else
|
||||
iEarnedMedal = 0;
|
||||
|
||||
iNext = -1;
|
||||
|
||||
switch ( iEarnedMedal )
|
||||
{
|
||||
case 0:
|
||||
iNext = pChallengeDescription->iBronze;
|
||||
iNextMedal = 1;
|
||||
break;
|
||||
case 1:
|
||||
iNext = pChallengeDescription->iSilver;
|
||||
iNextMedal = 2;
|
||||
break;
|
||||
case 2:
|
||||
iNext = pChallengeDescription->iGold;
|
||||
iNextMedal = 3;
|
||||
break;
|
||||
case 3:
|
||||
iNext = -1;
|
||||
iNextMedal = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CBonusMapsDatabase *g_pBonusMapsDatabase = NULL;
|
||||
|
||||
CBonusMapsDatabase *BonusMapsDatabase( void )
|
||||
{
|
||||
if ( !g_pBonusMapsDatabase )
|
||||
static CBonusMapsDatabase StaticBonusMapsDatabase;
|
||||
|
||||
return g_pBonusMapsDatabase;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CBonusMapsDatabase::CBonusMapsDatabase( void )
|
||||
{
|
||||
Assert( g_pBonusMapsDatabase == NULL ); // There should only be 1 bonus maps database
|
||||
g_pBonusMapsDatabase = this;
|
||||
|
||||
RootPath();
|
||||
|
||||
m_pBonusMapsManifest = new KeyValues( "bonus_maps_manifest" );
|
||||
m_pBonusMapsManifest->LoadFromFile( g_pFullFileSystem, "scripts/bonus_maps_manifest.txt", NULL );
|
||||
|
||||
m_iX360BonusesUnlocked = -1; // Only used on X360
|
||||
m_bHasLoadedSaveData = false;
|
||||
|
||||
ReadBonusMapSaveData();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CBonusMapsDatabase::~CBonusMapsDatabase()
|
||||
{
|
||||
WriteSaveData();
|
||||
|
||||
g_pBonusMapsDatabase = NULL;
|
||||
}
|
||||
|
||||
extern bool g_bIsCreatingNewGameMenuForPreFetching;
|
||||
|
||||
bool CBonusMapsDatabase::ReadBonusMapSaveData( void )
|
||||
{
|
||||
if ( !m_pBonusMapSavedData )
|
||||
m_pBonusMapSavedData = new KeyValues( "bonus_map_saved_data" );
|
||||
|
||||
if ( g_bIsCreatingNewGameMenuForPreFetching )
|
||||
{
|
||||
// Although we may have a storage device it's not going to be able to find our file at this point! BAIL!
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef _GAMECONSOLE
|
||||
#pragma message( __FILE__ "(" __LINE__AS_STRING ") : warning custom: Slamming controller for xbox storage id to 0" )
|
||||
// Nothing to read
|
||||
if ( XBX_GetStorageDeviceId( 0 ) == XBX_INVALID_STORAGE_ID || XBX_GetStorageDeviceId( 0 ) == XBX_STORAGE_DECLINED )
|
||||
return false;
|
||||
#endif
|
||||
|
||||
char szFilename[_MAX_PATH];
|
||||
|
||||
if ( IsGameConsole() )
|
||||
Q_snprintf( szFilename, sizeof( szFilename ), "cfg:/bonus_maps_data.bmd" );
|
||||
else
|
||||
Q_snprintf( szFilename, sizeof( szFilename ), "save/bonus_maps_data.bmd" );
|
||||
|
||||
m_pBonusMapSavedData->LoadFromFile( g_pFullFileSystem, szFilename, NULL );
|
||||
|
||||
m_bSavedDataChanged = false;
|
||||
m_bHasLoadedSaveData = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CBonusMapsDatabase::WriteSaveData( void )
|
||||
{
|
||||
bool bSuccess = false;
|
||||
|
||||
if ( m_bSavedDataChanged )
|
||||
bSuccess = WriteBonusMapSavedData( m_pBonusMapSavedData );
|
||||
|
||||
if ( bSuccess )
|
||||
m_bSavedDataChanged = false;
|
||||
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
void CBonusMapsDatabase::RootPath( void )
|
||||
{
|
||||
m_iDirDepth = 0;
|
||||
Q_strcpy( m_szCurrentPath, "." );
|
||||
}
|
||||
|
||||
void CBonusMapsDatabase::AppendPath( const char *pchAppend )
|
||||
{
|
||||
++m_iDirDepth;
|
||||
Q_snprintf( m_szCurrentPath, sizeof( m_szCurrentPath ), "%s/%s", m_szCurrentPath, pchAppend );
|
||||
}
|
||||
|
||||
void CBonusMapsDatabase::BackPath( void )
|
||||
{
|
||||
if ( m_iDirDepth == 0 )
|
||||
return;
|
||||
|
||||
if ( m_iDirDepth == 1 )
|
||||
{
|
||||
RootPath(); // back to root
|
||||
return;
|
||||
}
|
||||
|
||||
--m_iDirDepth;
|
||||
Q_strrchr( m_szCurrentPath, '/' )[ 0 ] = '\0'; // remove a dir from the end
|
||||
}
|
||||
|
||||
void CBonusMapsDatabase::SetPath( const char *pchPath, int iDirDepth )
|
||||
{
|
||||
Q_strcpy( m_szCurrentPath, pchPath );
|
||||
m_iDirDepth = iDirDepth;
|
||||
}
|
||||
|
||||
void CBonusMapsDatabase::ClearBonusMapsList( void )
|
||||
{
|
||||
m_BonusMaps.RemoveAll();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: builds bonus map list from directory
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBonusMapsDatabase::ScanBonusMaps( void )
|
||||
{
|
||||
// Don't load in the bonus maps before we've properly read in the save data
|
||||
if ( !m_bHasLoadedSaveData )
|
||||
{
|
||||
if ( ! ReadBonusMapSaveData() )
|
||||
return;
|
||||
}
|
||||
|
||||
char *pCurrentPath = &(m_szCurrentPath[2]);
|
||||
|
||||
// Reset completion percentage
|
||||
m_iCompletableLevels = 0;
|
||||
m_fCurrentCompletion = 0.0f;
|
||||
|
||||
// populate list box with all bonus maps in the current path
|
||||
char szDirectory[_MAX_PATH];
|
||||
|
||||
if ( Q_strcmp( m_szCurrentPath, "." ) == 0 )
|
||||
{
|
||||
// We're at the root, so look at the directories in the manifest
|
||||
KeyValues *pKey = NULL;
|
||||
for ( pKey = m_pBonusMapsManifest->GetFirstSubKey(); pKey; pKey = pKey->GetNextKey() )
|
||||
{
|
||||
const char *pchType = pKey->GetName();
|
||||
if ( Q_strcmp( pchType, "search" ) == 0 )
|
||||
{
|
||||
// Search through the directory
|
||||
Q_snprintf( szDirectory, sizeof( szDirectory ), "%s/", pKey->GetString() );
|
||||
|
||||
BuildSubdirectoryList( szDirectory, true );
|
||||
BuildBonusMapsList( szDirectory, true );
|
||||
}
|
||||
else if ( Q_strcmp( pchType, "dir" ) == 0 )
|
||||
{
|
||||
AddBonus( "", pKey->GetString(), true );
|
||||
}
|
||||
else if ( Q_strcmp( pchType, "map" ) == 0 )
|
||||
{
|
||||
AddBonus( "", pKey->GetString(), false );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Search through the current directory
|
||||
Q_snprintf( szDirectory, sizeof( szDirectory ), "%s/", pCurrentPath );
|
||||
|
||||
BuildSubdirectoryList( szDirectory, false );
|
||||
BuildBonusMapsList( szDirectory, false );
|
||||
}
|
||||
}
|
||||
|
||||
void CBonusMapsDatabase::RefreshMapData( void )
|
||||
{
|
||||
// Reset completion percentage
|
||||
m_iCompletableLevels = 0;
|
||||
m_fCurrentCompletion = 0.0f;
|
||||
|
||||
for ( int iMap = 0; iMap < m_BonusMaps.Count(); ++iMap )
|
||||
{
|
||||
BonusMapDescription_t *pMap = &m_BonusMaps[ iMap ];
|
||||
|
||||
float fCompletion = GetChallengeBests( m_pBonusMapSavedData->FindKey( "bonusfiles", true ), *pMap );
|
||||
|
||||
// If all the challenges are completed set it as complete
|
||||
if ( fCompletion == 1.0f )
|
||||
SetBooleanStatus( "complete", pMap->szFileName, pMap->szMapName, true );
|
||||
|
||||
GetBooleanStatus( m_pBonusMapSavedData->FindKey( "bonusfiles", true ), *pMap );
|
||||
|
||||
if ( pMap->bComplete )
|
||||
fCompletion = 1.0f;
|
||||
|
||||
if ( !pMap->bIsFolder )
|
||||
{
|
||||
m_fCurrentCompletion += fCompletion;
|
||||
++m_iCompletableLevels;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int CBonusMapsDatabase::BonusCount( void )
|
||||
{
|
||||
if ( m_BonusMaps.Count() == 0 )
|
||||
ScanBonusMaps();
|
||||
|
||||
return m_BonusMaps.Count();
|
||||
}
|
||||
|
||||
bool CBonusMapsDatabase::GetBlink( void )
|
||||
{
|
||||
KeyValues *pBlinkKey = m_pBonusMapSavedData->FindKey( "blink" );
|
||||
if ( !pBlinkKey )
|
||||
return false;
|
||||
|
||||
return ( pBlinkKey->GetInt() != 0 );
|
||||
}
|
||||
|
||||
void CBonusMapsDatabase::SetBlink( bool bState )
|
||||
{
|
||||
KeyValues *pBlinkKey = m_pBonusMapSavedData->FindKey( "blink" );
|
||||
if ( pBlinkKey )
|
||||
{
|
||||
bool bCurrentState = ( pBlinkKey->GetInt() != 0 );
|
||||
if ( bState && !bCurrentState )
|
||||
{
|
||||
pBlinkKey->SetStringValue( "1" );
|
||||
m_bSavedDataChanged = true;
|
||||
}
|
||||
else if ( !bState && bCurrentState )
|
||||
{
|
||||
pBlinkKey->SetStringValue( "0" );
|
||||
m_bSavedDataChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Only used on X360
|
||||
bool CBonusMapsDatabase::BonusesUnlocked( void )
|
||||
{
|
||||
if ( m_iX360BonusesUnlocked == -1 )
|
||||
{
|
||||
// Never checked, so set up the proper X360 scan
|
||||
BonusMapsDatabase()->ClearBonusMapsList(); // clear the current list
|
||||
BonusMapsDatabase()->RootPath();
|
||||
BonusMapsDatabase()->ScanBonusMaps();
|
||||
|
||||
m_iX360BonusesUnlocked = 0;
|
||||
}
|
||||
|
||||
if ( m_iX360BonusesUnlocked == 0 )
|
||||
{
|
||||
// Hasn't been recorded as unlocked yet
|
||||
for ( int iBonusMap = 0; iBonusMap < BonusMapsDatabase()->BonusCount(); ++iBonusMap )
|
||||
{
|
||||
BonusMapDescription_t *pMap = BonusMapsDatabase()->GetBonusData( iBonusMap );
|
||||
if ( Q_strcmp( pMap->szMapName, "#Bonus_Map_AdvancedChambers" ) == 0 && !pMap->bLocked )
|
||||
{
|
||||
// All bonuses unlocked, remember this and set up the proper X360 scan to get info.
|
||||
m_iX360BonusesUnlocked = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ( m_iX360BonusesUnlocked != 0 );
|
||||
}
|
||||
|
||||
void CBonusMapsDatabase::SetCurrentChallengeNames( const char *pchFileName, const char *pchMapName, const char *pchChallengeName )
|
||||
{
|
||||
Q_strcpy( m_CurrentChallengeNames.szFileName, pchFileName );
|
||||
Q_strcpy( m_CurrentChallengeNames.szMapName, pchMapName );
|
||||
Q_strcpy( m_CurrentChallengeNames.szChallengeName, pchChallengeName );
|
||||
}
|
||||
|
||||
void CBonusMapsDatabase::GetCurrentChallengeNames( char *pchFileName, char *pchMapName, char *pchChallengeName )
|
||||
{
|
||||
Q_strcpy( pchFileName, m_CurrentChallengeNames.szFileName );
|
||||
Q_strcpy( pchMapName, m_CurrentChallengeNames.szMapName );
|
||||
Q_strcpy( pchChallengeName, m_CurrentChallengeNames.szChallengeName );
|
||||
}
|
||||
|
||||
void CBonusMapsDatabase::SetCurrentChallengeObjectives( int iBronze, int iSilver, int iGold )
|
||||
{
|
||||
m_CurrentChallengeObjectives.iBronze = iBronze;
|
||||
m_CurrentChallengeObjectives.iSilver = iSilver;
|
||||
m_CurrentChallengeObjectives.iGold = iGold;
|
||||
}
|
||||
|
||||
void CBonusMapsDatabase::GetCurrentChallengeObjectives( int &iBronze, int &iSilver, int &iGold )
|
||||
{
|
||||
iBronze = m_CurrentChallengeObjectives.iBronze;
|
||||
iSilver = m_CurrentChallengeObjectives.iSilver;
|
||||
iGold = m_CurrentChallengeObjectives.iGold;
|
||||
}
|
||||
|
||||
bool CBonusMapsDatabase::SetBooleanStatus( const char *pchName, const char *pchFileName, const char *pchMapName, bool bValue )
|
||||
{
|
||||
bool bChanged = ::SetBooleanStatus( m_pBonusMapSavedData->FindKey( "bonusfiles", true ), pchName, pchFileName, pchMapName, bValue );
|
||||
if ( bChanged )
|
||||
m_bSavedDataChanged = true;
|
||||
|
||||
return bChanged;
|
||||
}
|
||||
|
||||
bool CBonusMapsDatabase::SetBooleanStatus( const char *pchName, int iIndex, bool bValue )
|
||||
{
|
||||
BonusMapDescription_t *pMap = &(m_BonusMaps[iIndex]);
|
||||
|
||||
bool bChanged = SetBooleanStatus( pchName, pMap->szFileName, pMap->szMapName, bValue );
|
||||
GetBooleanStatus( m_pBonusMapSavedData->FindKey( "bonusfiles", true ), *pMap );
|
||||
|
||||
return bChanged;
|
||||
}
|
||||
|
||||
bool CBonusMapsDatabase::UpdateChallengeBest( const char *pchFileName, const char *pchMapName, const char *pchChallengeName, int iBest )
|
||||
{
|
||||
BonusMapChallenge_t challenge;
|
||||
Q_strcpy( challenge.szFileName, pchFileName );
|
||||
Q_strcpy( challenge.szMapName, pchMapName );
|
||||
Q_strcpy( challenge.szChallengeName, pchChallengeName );
|
||||
challenge.iBest = iBest;
|
||||
|
||||
bool bChanged = ::UpdateChallengeBest( m_pBonusMapSavedData->FindKey( "bonusfiles", true ), challenge );
|
||||
if ( bChanged )
|
||||
m_bSavedDataChanged = true;
|
||||
|
||||
return bChanged;
|
||||
}
|
||||
|
||||
float CBonusMapsDatabase::GetCompletionPercentage( void )
|
||||
{
|
||||
// Avoid divide by zero
|
||||
if ( m_iCompletableLevels <= 0 )
|
||||
return 0.0f;
|
||||
|
||||
return m_fCurrentCompletion / m_iCompletableLevels;
|
||||
}
|
||||
|
||||
int CBonusMapsDatabase::NumAdvancedComplete( void )
|
||||
{
|
||||
char szCurrentPath[_MAX_PATH];
|
||||
Q_strcpy( szCurrentPath, m_szCurrentPath );
|
||||
int iDirDepth = m_iDirDepth;
|
||||
|
||||
BonusMapsDatabase()->ClearBonusMapsList();
|
||||
SetPath( "./scripts/advanced_chambers", 1 );
|
||||
ScanBonusMaps();
|
||||
|
||||
int iNumComplete = 0;
|
||||
|
||||
// Look through all the bonus maps
|
||||
for ( int iBonusMap = 0; iBonusMap < BonusMapsDatabase()->BonusCount(); ++iBonusMap )
|
||||
{
|
||||
BonusMapDescription_t *pMap = BonusMapsDatabase()->GetBonusData( iBonusMap );
|
||||
|
||||
if ( pMap && Q_strstr( pMap->szMapName, "Advanced" ) != NULL )
|
||||
{
|
||||
// It's an advanced map, so check if it's complete
|
||||
if ( pMap->bComplete )
|
||||
++iNumComplete;
|
||||
}
|
||||
}
|
||||
|
||||
BonusMapsDatabase()->ClearBonusMapsList();
|
||||
SetPath( szCurrentPath, iDirDepth );
|
||||
ScanBonusMaps();
|
||||
|
||||
return iNumComplete;
|
||||
}
|
||||
|
||||
void CBonusMapsDatabase::NumMedals( int piNumMedals[ 3 ] )
|
||||
{
|
||||
char szCurrentPath[_MAX_PATH];
|
||||
Q_strcpy( szCurrentPath, m_szCurrentPath );
|
||||
int iDirDepth = m_iDirDepth;
|
||||
|
||||
BonusMapsDatabase()->ClearBonusMapsList();
|
||||
SetPath( "./scripts/challenges", 1 );
|
||||
ScanBonusMaps();
|
||||
|
||||
for ( int i = 0; i < 3; ++i )
|
||||
piNumMedals[ i ] = 0;
|
||||
|
||||
// Look through all the bonus maps
|
||||
for ( int iBonusMap = 0; iBonusMap < BonusMapsDatabase()->BonusCount(); ++iBonusMap )
|
||||
{
|
||||
BonusMapDescription_t *pMap = BonusMapsDatabase()->GetBonusData( iBonusMap );
|
||||
|
||||
if ( pMap && pMap->m_pChallenges )
|
||||
{
|
||||
for ( int iChallenge = 0; iChallenge < pMap->m_pChallenges->Count(); ++iChallenge )
|
||||
{
|
||||
ChallengeDescription_t *pChallengeDescription = &((*pMap->m_pChallenges)[ iChallenge ]);
|
||||
|
||||
int iBest, iEarnedMedal, iNext, iNextMedal;
|
||||
GetChallengeMedals( pChallengeDescription, iBest, iEarnedMedal, iNext, iNextMedal );
|
||||
|
||||
// Increase the count for this medal and every medal below it
|
||||
while ( iEarnedMedal > 0 )
|
||||
{
|
||||
--iEarnedMedal; // Medals are 1,2&3 so subtract 1 first
|
||||
piNumMedals[ iEarnedMedal ]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BonusMapsDatabase()->ClearBonusMapsList();
|
||||
SetPath( szCurrentPath, iDirDepth );
|
||||
ScanBonusMaps();
|
||||
}
|
||||
|
||||
|
||||
void CBonusMapsDatabase::AddBonus( const char *pCurrentPath, const char *pDirFileName, bool bIsFolder )
|
||||
{
|
||||
char szFileName[_MAX_PATH];
|
||||
Q_snprintf( szFileName, sizeof( szFileName ), "%s%s", pCurrentPath, pDirFileName );
|
||||
|
||||
// Only load bonus maps from the current mod's maps dir
|
||||
if( !IsGameConsole() && !g_pFullFileSystem->FileExists( szFileName, "MOD" ) )
|
||||
return;
|
||||
|
||||
ParseBonusMapData( szFileName, pDirFileName, bIsFolder );
|
||||
}
|
||||
|
||||
void CBonusMapsDatabase::BuildSubdirectoryList( const char *pCurrentPath, bool bOutOfRoot )
|
||||
{
|
||||
char szDirectory[_MAX_PATH];
|
||||
Q_snprintf( szDirectory, sizeof( szDirectory ), "%s*", pCurrentPath );
|
||||
|
||||
FileFindHandle_t dirHandle;
|
||||
const char *pDirFileName = g_pFullFileSystem->FindFirst( szDirectory, &dirHandle );
|
||||
|
||||
while (pDirFileName)
|
||||
{
|
||||
// Skip it if it's not a directory, is the root, is back, or is an invalid folder
|
||||
if ( !g_pFullFileSystem->FindIsDirectory( dirHandle ) ||
|
||||
Q_strcmp( pDirFileName, "." ) == 0 ||
|
||||
Q_strcmp( pDirFileName, ".." ) == 0 ||
|
||||
Q_stricmp( pDirFileName, "soundcache" ) == 0 ||
|
||||
Q_stricmp( pDirFileName, "graphs" ) == 0 )
|
||||
{
|
||||
pDirFileName = g_pFullFileSystem->FindNext( dirHandle );
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !bOutOfRoot )
|
||||
AddBonus( pCurrentPath, pDirFileName, true );
|
||||
else
|
||||
{
|
||||
char szFileName[_MAX_PATH];
|
||||
Q_snprintf( szFileName, sizeof( szFileName ), "%s%s", pCurrentPath, pDirFileName );
|
||||
AddBonus( "", szFileName, true );
|
||||
}
|
||||
|
||||
pDirFileName = g_pFullFileSystem->FindNext( dirHandle );
|
||||
}
|
||||
|
||||
g_pFullFileSystem->FindClose( dirHandle );
|
||||
}
|
||||
|
||||
void CBonusMapsDatabase::BuildBonusMapsList( const char *pCurrentPath, bool bOutOfRoot )
|
||||
{
|
||||
char szDirectory[_MAX_PATH];
|
||||
Q_snprintf( szDirectory, sizeof( szDirectory ), "%s*.bns", pCurrentPath );
|
||||
|
||||
FileFindHandle_t mapHandle;
|
||||
const char *pMapFileName = g_pFullFileSystem->FindFirst( szDirectory, &mapHandle );
|
||||
|
||||
while (pMapFileName)
|
||||
{
|
||||
// Skip it if it's a directory or is the folder info
|
||||
if ( g_pFullFileSystem->FindIsDirectory( mapHandle ) || Q_strstr( pMapFileName, "folderinfo.bns" ) )
|
||||
{
|
||||
pMapFileName = g_pFullFileSystem->FindNext( mapHandle );
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !bOutOfRoot )
|
||||
AddBonus( pCurrentPath, pMapFileName, false );
|
||||
else
|
||||
{
|
||||
char szFileName[_MAX_PATH];
|
||||
Q_snprintf( szFileName, sizeof( szFileName ), "%s%s", pCurrentPath, pMapFileName );
|
||||
AddBonus( "", szFileName, false );
|
||||
}
|
||||
|
||||
pMapFileName = g_pFullFileSystem->FindNext( mapHandle );
|
||||
}
|
||||
|
||||
g_pFullFileSystem->FindClose( mapHandle );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Parses the save game info out of the .sav file header
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBonusMapsDatabase::ParseBonusMapData( char const *pszFileName, char const *pszShortName, bool bIsFolder )
|
||||
{
|
||||
if ( !pszFileName || !pszShortName )
|
||||
return;
|
||||
|
||||
char szMapInfo[_MAX_PATH];
|
||||
|
||||
// if it's a directory, there's no optional info
|
||||
if ( bIsFolder )
|
||||
{
|
||||
// get the folder info file name
|
||||
Q_snprintf( szMapInfo, sizeof(szMapInfo), "%s/folderinfo.bns", pszFileName );
|
||||
}
|
||||
else
|
||||
{
|
||||
// get the map info file name
|
||||
Q_strncpy( szMapInfo, pszFileName, sizeof(szMapInfo) );
|
||||
}
|
||||
|
||||
KeyValues *kv = new KeyValues( pszShortName );
|
||||
if ( !kv->LoadFromFile( g_pFullFileSystem, szMapInfo, NULL ) )
|
||||
DevMsg( "Unable to load bonus map info file\n" );
|
||||
|
||||
while ( kv )
|
||||
{
|
||||
int iMap = m_BonusMaps.AddToTail();
|
||||
|
||||
BonusMapDescription_t *pMap = &m_BonusMaps[ iMap ];
|
||||
|
||||
// set required map data
|
||||
Q_strncpy( pMap->szFileName, pszFileName, sizeof(pMap->szFileName) );
|
||||
Q_strncpy( pMap->szShortName, pszShortName, sizeof(pMap->szShortName) );
|
||||
pMap->bIsFolder = bIsFolder;
|
||||
|
||||
// set optional map data
|
||||
Q_strcpy( pMap->szMapName, kv->GetName() );
|
||||
Q_strcpy( pMap->szMapFileName, kv->GetString( "map" ) );
|
||||
Q_strcpy( pMap->szChapterName, kv->GetString( "chapter" ) );
|
||||
Q_strcpy( pMap->szImageName, kv->GetString( "image" ) );
|
||||
Q_strcpy( pMap->szComment, kv->GetString( "comment" ) );
|
||||
pMap->bLocked = ( kv->GetInt( "lock", 0 ) != 0 );
|
||||
pMap->bComplete = ( kv->GetInt( "complete", 0 ) != 0 );
|
||||
|
||||
float fCompletion = 0.0f;
|
||||
|
||||
KeyValues *pChallenges = kv->FindKey( "challenges" );
|
||||
|
||||
if ( pChallenges )
|
||||
{
|
||||
for ( KeyValues *pChallengeKey = pChallenges->GetFirstSubKey(); pChallengeKey; pChallengeKey = pChallengeKey->GetNextKey() )
|
||||
{
|
||||
if ( !pMap->m_pChallenges )
|
||||
pMap->m_pChallenges = new CUtlVector<ChallengeDescription_t>;
|
||||
|
||||
int iChallenge = pMap->m_pChallenges->AddToTail();
|
||||
|
||||
ChallengeDescription_t *pChallenge = &(*pMap->m_pChallenges)[ iChallenge ];
|
||||
Q_strcpy( pChallenge->szName, pChallengeKey->GetName() );
|
||||
Q_strcpy( pChallenge->szComment, pChallengeKey->GetString( "comment" ) );
|
||||
pChallenge->iType = pChallengeKey->GetInt( "type", -1 );
|
||||
pChallenge->iBronze = pChallengeKey->GetInt( "bronze" );
|
||||
pChallenge->iSilver = pChallengeKey->GetInt( "silver" );
|
||||
pChallenge->iGold = pChallengeKey->GetInt( "gold" );
|
||||
}
|
||||
|
||||
fCompletion = GetChallengeBests( m_pBonusMapSavedData->FindKey( "bonusfiles", true ), *pMap );
|
||||
|
||||
// If all the challenges are completed set it as complete
|
||||
if ( fCompletion == 1.0f )
|
||||
SetBooleanStatus( "complete", pMap->szFileName, pMap->szMapName, true );
|
||||
}
|
||||
|
||||
// Get boolean status last because it can be altered if all the challenges were completed
|
||||
GetBooleanStatus( m_pBonusMapSavedData->FindKey( "bonusfiles", true ), *pMap );
|
||||
|
||||
if ( pMap->bComplete )
|
||||
fCompletion = 1.0f;
|
||||
|
||||
if ( !pMap->bIsFolder )
|
||||
{
|
||||
m_fCurrentCompletion += fCompletion;
|
||||
++m_iCompletableLevels;
|
||||
kv = kv->GetNextTrueSubKey();
|
||||
}
|
||||
else
|
||||
kv = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
167
game/client/cstrike15/gameui/bonusmapsdatabase.h
Normal file
167
game/client/cstrike15/gameui/bonusmapsdatabase.h
Normal file
@@ -0,0 +1,167 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef BONUSMAPSDATABASE_H
|
||||
#define BONUSMAPSDATABASE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include "utlvector.h"
|
||||
|
||||
|
||||
struct ChallengeDescription_t
|
||||
{
|
||||
char szName[32];
|
||||
char szComment[256];
|
||||
|
||||
int iType;
|
||||
|
||||
int iBronze;
|
||||
int iSilver;
|
||||
int iGold;
|
||||
|
||||
int iBest;
|
||||
};
|
||||
|
||||
struct BonusMapDescription_t
|
||||
{
|
||||
bool bIsFolder;
|
||||
|
||||
char szShortName[64];
|
||||
char szFileName[128];
|
||||
|
||||
char szMapFileName[128];
|
||||
char szChapterName[128];
|
||||
char szImageName[128];
|
||||
|
||||
char szMapName[64];
|
||||
char szComment[256];
|
||||
|
||||
bool bLocked;
|
||||
bool bComplete;
|
||||
|
||||
CUtlVector<ChallengeDescription_t> *m_pChallenges;
|
||||
|
||||
BonusMapDescription_t( void )
|
||||
{
|
||||
bIsFolder = false;
|
||||
|
||||
szShortName[ 0 ] = '\0';
|
||||
szFileName[ 0 ] = '\0';
|
||||
|
||||
szMapFileName[ 0 ] = '\0';
|
||||
szChapterName[ 0 ] = '\0';
|
||||
szImageName[ 0 ] = '\0';
|
||||
|
||||
szMapName[ 0 ] = '\0';
|
||||
szComment[ 0 ] = '\0';
|
||||
|
||||
bLocked = false;
|
||||
bComplete = false;
|
||||
|
||||
m_pChallenges = NULL;
|
||||
}
|
||||
};
|
||||
|
||||
struct BonusMapChallenge_t
|
||||
{
|
||||
char szFileName[128];
|
||||
char szMapName[32];
|
||||
char szChallengeName[32];
|
||||
int iBest;
|
||||
};
|
||||
|
||||
|
||||
class KeyValues;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Keeps track of bonus maps on disk
|
||||
//-----------------------------------------------------------------------------
|
||||
class CBonusMapsDatabase
|
||||
{
|
||||
|
||||
public:
|
||||
CBonusMapsDatabase( void );
|
||||
~CBonusMapsDatabase();
|
||||
|
||||
bool ReadBonusMapSaveData( void );
|
||||
bool WriteSaveData( void );
|
||||
|
||||
const char * GetPath( void ) { return m_szCurrentPath; }
|
||||
void RootPath( void );
|
||||
void AppendPath( const char *pchAppend );
|
||||
void BackPath( void );
|
||||
void SetPath( const char *pchPath, int iDirDepth );
|
||||
|
||||
void ClearBonusMapsList( void );
|
||||
void ScanBonusMaps( void );
|
||||
void RefreshMapData( void );
|
||||
|
||||
int BonusCount( void );
|
||||
BonusMapDescription_t * GetBonusData( int iIndex ) { return &(m_BonusMaps[ iIndex ]); }
|
||||
int InvalidIndex( void ) { return m_BonusMaps.InvalidIndex(); }
|
||||
bool IsValidIndex( int iIndex ) { return m_BonusMaps.IsValidIndex( iIndex ); }
|
||||
|
||||
bool GetBlink( void );
|
||||
void SetBlink( bool bState );
|
||||
|
||||
bool BonusesUnlocked( void );
|
||||
|
||||
void SetCurrentChallengeNames( const char *pchFileName, const char *pchMapName, const char *pchChallengeName );
|
||||
void GetCurrentChallengeNames( char *pchFileName, char *pchMapName, char *pchChallengeName );
|
||||
void SetCurrentChallengeObjectives( int iBronze, int iSilver, int iGold );
|
||||
void GetCurrentChallengeObjectives( int &iBronze, int &iSilver, int &iGold );
|
||||
|
||||
bool SetBooleanStatus( const char *pchName, const char *pchFileName, const char *pchMapName, bool bValue );
|
||||
bool SetBooleanStatus( const char *pchName, int iIndex, bool bValue );
|
||||
bool UpdateChallengeBest( const char *pchFileName, const char *pchMapName, const char *pchChallengeName, int iBest );
|
||||
|
||||
float GetCompletionPercentage( void );
|
||||
|
||||
int NumAdvancedComplete( void );
|
||||
void NumMedals( int piNumMedals[ 3 ] );
|
||||
|
||||
private:
|
||||
|
||||
void AddBonus( const char *pCurrentPath, const char *pDirFileName, bool bIsFolder );
|
||||
void BuildSubdirectoryList( const char *pCurrentPath, bool bOutOfRoot );
|
||||
void BuildBonusMapsList( const char *pCurrentPath, bool bOutOfRoot );
|
||||
|
||||
void ParseBonusMapData( char const *pszFileName, char const *pszShortName, bool bIsFolder );
|
||||
|
||||
private:
|
||||
|
||||
KeyValues *m_pBonusMapsManifest;
|
||||
|
||||
CUtlVector<BonusMapDescription_t> m_BonusMaps;
|
||||
|
||||
KeyValues *m_pBonusMapSavedData;
|
||||
bool m_bSavedDataChanged;
|
||||
|
||||
int m_iX360BonusesUnlocked; // Only used on 360
|
||||
bool m_bHasLoadedSaveData;
|
||||
|
||||
int m_iDirDepth;
|
||||
char m_szCurrentPath[_MAX_PATH];
|
||||
float m_fCurrentCompletion;
|
||||
int m_iCompletableLevels;
|
||||
|
||||
BonusMapChallenge_t m_CurrentChallengeNames;
|
||||
ChallengeDescription_t m_CurrentChallengeObjectives;
|
||||
};
|
||||
|
||||
|
||||
void GetChallengeMedals( ChallengeDescription_t *pChallengeDescription, int &iBest, int &iEarnedMedal, int &iNext, int &iNextMedal );
|
||||
CBonusMapsDatabase *BonusMapsDatabase( void );
|
||||
|
||||
extern const char g_pszMedalNames[4][8];
|
||||
|
||||
|
||||
#endif // BONUSMAPSDATABASE_H
|
||||
863
game/client/cstrike15/gameui/bonusmapsdialog.cpp
Normal file
863
game/client/cstrike15/gameui/bonusmapsdialog.cpp
Normal file
@@ -0,0 +1,863 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "bonusmapsdialog.h"
|
||||
#include "engineinterface.h"
|
||||
|
||||
#include "vgui/ISystem.h"
|
||||
#include "vgui/ISurface.h"
|
||||
#include "vgui/IVGui.h"
|
||||
#include <vgui/ILocalize.h>
|
||||
#include "filesystem.h"
|
||||
|
||||
#include "vgui_controls/Button.h"
|
||||
#include "vgui_controls/ComboBox.h"
|
||||
#include "vgui_controls/PanelListPanel.h"
|
||||
#include "vgui_controls/QueryBox.h"
|
||||
#include "vgui_controls/ImagePanel.h"
|
||||
#include "vgui_controls/BitmapImagePanel.h"
|
||||
#include "vgui_controls/FileOpenDialog.h"
|
||||
#include "vgui_controls/tgaimagepanel.h"
|
||||
|
||||
#include "mousemessageforwardingpanel.h"
|
||||
|
||||
#include "basepanel.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
|
||||
#define MAX_LISTED_BONUS_MAPS 128
|
||||
|
||||
|
||||
extern const char *COM_GetModDirectory( void );
|
||||
|
||||
|
||||
bool ConstructFullImagePath( const char *pCurrentPath, const char *pchImageName, char *pchImageFileName )
|
||||
{
|
||||
char *ext = Q_strstr( pchImageName , ".tga" );
|
||||
if ( ext )
|
||||
{
|
||||
// Use the specified image
|
||||
if ( pchImageName[ 0 ] != '.' )
|
||||
Q_snprintf( pchImageFileName, _MAX_PATH, "%s", pchImageName );
|
||||
else
|
||||
Q_snprintf( pchImageFileName, _MAX_PATH, "%s/%s", pCurrentPath, pchImageName );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Q_strcpy( pchImageFileName, pchImageName );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Describes the layout of a same game pic
|
||||
//-----------------------------------------------------------------------------
|
||||
class CBonusMapPanel : public vgui::EditablePanel
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CBonusMapPanel, vgui::EditablePanel );
|
||||
public:
|
||||
CBonusMapPanel( PanelListPanel *parent, const char *name, int bonusMapListItemID ) : BaseClass( parent, name )
|
||||
{
|
||||
m_iBonusMapListItemID = bonusMapListItemID;
|
||||
m_pParent = parent;
|
||||
m_pBonusMapTGAImage = new CTGAImagePanel( this, "BonusMapTGAImage" );
|
||||
m_pBonusMapImage = SETUP_PANEL( new ImagePanel( this, "BonusMapImage" ) );
|
||||
m_pBonusMapScreenshotBackground = SETUP_PANEL( new ImagePanel( this, "BonusMapScreenshotBackground" ) );
|
||||
m_pMapNameLabel = new Label( this, "MapNameLabel", "" );
|
||||
m_pLockIcon = new ImagePanel( this, "LockIcon" );
|
||||
m_pCompleteIcon = new ImagePanel( this, "CompleteIcon" );
|
||||
|
||||
CMouseMessageForwardingPanel *panel = new CMouseMessageForwardingPanel(this, NULL);
|
||||
panel->SetZPos(2);
|
||||
|
||||
SetSize( 200, 140 );
|
||||
|
||||
LoadControlSettings( "resource/BonusMapPanel.res" );
|
||||
|
||||
m_FillColor = m_pBonusMapScreenshotBackground->GetFillColor();
|
||||
}
|
||||
|
||||
void SetBonusMapInfo( const char *pCurrentPath, BonusMapDescription_t &map )
|
||||
{
|
||||
// set the image to display
|
||||
char szImageFileName[_MAX_PATH];
|
||||
|
||||
bool bIsTGA = false;
|
||||
|
||||
if ( map.bIsFolder )
|
||||
{
|
||||
if ( map.szImageName[ 0 ] == '\0' )
|
||||
{
|
||||
// use associate bonus folder icon
|
||||
Q_snprintf( szImageFileName, sizeof(szImageFileName), "%s/foldericon.tga", map.szFileName );
|
||||
bIsTGA = true;
|
||||
|
||||
// use default folder icon
|
||||
if( !g_pFullFileSystem->FileExists( szImageFileName, "MOD" ) )
|
||||
{
|
||||
Q_strcpy( szImageFileName, "bonusmaps/icon_bonus_map_folder" );
|
||||
bIsTGA = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use the specified image
|
||||
bIsTGA = ConstructFullImagePath( pCurrentPath, map.szImageName, szImageFileName );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( map.szImageName[ 0 ] == '\0' )
|
||||
{
|
||||
// Didn't specify an image name, so pair it with the name of this file
|
||||
char szImpliedTgaName[_MAX_PATH];
|
||||
Q_snprintf( szImpliedTgaName, sizeof( szImpliedTgaName ), "%s.tga", map.szMapFileName );
|
||||
bIsTGA = ConstructFullImagePath( pCurrentPath, szImpliedTgaName, szImageFileName );
|
||||
|
||||
// if it doesn't exist use default bonus map icon
|
||||
if( !g_pFullFileSystem->FileExists( szImageFileName, "MOD" ) )
|
||||
{
|
||||
Q_strcpy( szImageFileName, "bonusmaps/icon_bonus_map_default" );
|
||||
bIsTGA = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use the specified image
|
||||
bIsTGA = ConstructFullImagePath( pCurrentPath, map.szImageName, szImageFileName );
|
||||
}
|
||||
}
|
||||
|
||||
if ( bIsTGA )
|
||||
{
|
||||
m_pBonusMapTGAImage->SetTGAFilenameNonMod( szImageFileName );
|
||||
m_pBonusMapTGAImage->SetSize( 180, 100 );
|
||||
m_pBonusMapTGAImage->SetVisible( true );
|
||||
m_pBonusMapImage->SetVisible( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pBonusMapImage->SetImage( szImageFileName );
|
||||
m_pBonusMapImage->SetSize( 180, 100 );
|
||||
m_pBonusMapImage->SetVisible( true );
|
||||
m_pBonusMapTGAImage->SetVisible( false );
|
||||
}
|
||||
|
||||
m_pLockIcon->SetVisible( map.bLocked );
|
||||
m_pCompleteIcon->SetVisible( map.bComplete );
|
||||
|
||||
// set the title text
|
||||
m_pMapNameLabel->SetText( map.szMapName );
|
||||
}
|
||||
|
||||
MESSAGE_FUNC_INT( OnPanelSelected, "PanelSelected", state )
|
||||
{
|
||||
if ( state )
|
||||
{
|
||||
// set the text color to be orange, and the pic border to be orange
|
||||
m_pBonusMapScreenshotBackground->SetFillColor( m_SelectedColor );
|
||||
m_pMapNameLabel->SetFgColor( Color( 0, 0, 0, 255 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pBonusMapScreenshotBackground->SetFillColor( m_FillColor );
|
||||
m_pMapNameLabel->SetFgColor( m_TextColor );
|
||||
}
|
||||
|
||||
PostMessage( m_pParent->GetVParent(), new KeyValues("PanelSelected") );
|
||||
}
|
||||
|
||||
virtual void OnMousePressed( vgui::MouseCode code )
|
||||
{
|
||||
m_pParent->SetSelectedPanel( this );
|
||||
}
|
||||
|
||||
virtual void ApplySchemeSettings( IScheme *pScheme )
|
||||
{
|
||||
m_TextColor = pScheme->GetColor( "NewGame.TextColor", Color(255, 255, 255, 255) );
|
||||
m_SelectedColor = pScheme->GetColor( "NewGame.SelectionColor", Color(255, 255, 255, 255) );
|
||||
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
}
|
||||
|
||||
virtual void OnMouseDoublePressed( vgui::MouseCode code )
|
||||
{
|
||||
// call the panel
|
||||
OnMousePressed( code );
|
||||
PostMessage( m_pParent->GetParent(), new KeyValues("Command", "command", "loadbonusmap") );
|
||||
}
|
||||
|
||||
int GetBonusMapListItemID()
|
||||
{
|
||||
return m_iBonusMapListItemID;
|
||||
}
|
||||
|
||||
private:
|
||||
vgui::PanelListPanel *m_pParent;
|
||||
vgui::Label *m_pMapNameLabel;
|
||||
ImagePanel *m_pBonusMapImage;
|
||||
CTGAImagePanel *m_pBonusMapTGAImage;
|
||||
|
||||
ImagePanel *m_pLockIcon;
|
||||
ImagePanel *m_pCompleteIcon;
|
||||
|
||||
// things to change color when the selection changes
|
||||
ImagePanel *m_pBonusMapScreenshotBackground;
|
||||
Color m_TextColor, m_FillColor, m_SelectedColor;
|
||||
|
||||
int m_iBonusMapListItemID;
|
||||
};
|
||||
|
||||
CBonusMapsDialog *g_pBonusMapsDialog = NULL;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CBonusMapsDialog::CBonusMapsDialog(vgui::Panel *parent) : BaseClass(parent, "BonusMapsDialog")
|
||||
{
|
||||
g_pBonusMapsDialog = this;
|
||||
m_hImportBonusMapsDialog = NULL;
|
||||
|
||||
BonusMapsDatabase()->RootPath();
|
||||
|
||||
CreateBonusMapsList();
|
||||
|
||||
BuildMapsList();
|
||||
|
||||
new vgui::Button( this, "loadbonusmap", "" );
|
||||
SetControlEnabled( "loadbonusmap", false );
|
||||
|
||||
SetDeleteSelfOnClose(true);
|
||||
//SetBounds(0, 0, 512, 384);
|
||||
//SetMinimumSize( 256, 300 );
|
||||
SetSizeable( false );
|
||||
|
||||
SetTitle("#GameUI_BonusMaps", true);
|
||||
|
||||
vgui::Button *cancel = new vgui::Button( this, "Cancel", "#GameUI_Cancel" );
|
||||
cancel->SetCommand( "Close" );
|
||||
|
||||
m_pPercentageBarBackground = SETUP_PANEL( new ImagePanel( this, "PercentageBarBackground" ) );
|
||||
m_pPercentageBar = SETUP_PANEL( new ImagePanel( this, "PercentageBar" ) );
|
||||
|
||||
LoadControlSettings("resource/BonusMapsDialog.res");
|
||||
|
||||
// Stop blinking the bonus maps menu item
|
||||
CBaseModPanel *pBasePanel = BasePanel();
|
||||
if ( pBasePanel )
|
||||
pBasePanel->SetMenuItemBlinkingState( "OpenBonusMapsDialog", false );
|
||||
|
||||
BonusMapsDatabase()->SetBlink( false );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CBonusMapsDialog::~CBonusMapsDialog()
|
||||
{
|
||||
BonusMapsDatabase()->WriteSaveData(); // Closing this dialog is a good time to save
|
||||
g_pBonusMapsDialog = NULL;
|
||||
}
|
||||
|
||||
|
||||
bool CBonusMapsDialog::ImportZippedBonusMaps( const char *pchZippedFileName )
|
||||
{
|
||||
// Get the zip file's name with dir info
|
||||
char *pchShortFileName = Q_strrchr( pchZippedFileName, '\\' );
|
||||
|
||||
if ( !pchShortFileName )
|
||||
return false;
|
||||
|
||||
// It's going to go in the maps folder
|
||||
char szOutFilename[ 512 ];
|
||||
|
||||
Q_snprintf( szOutFilename, sizeof( szOutFilename ), "maps%s", pchShortFileName );
|
||||
Q_StripExtension( szOutFilename, szOutFilename, sizeof( szOutFilename ) );
|
||||
|
||||
// If there's already a folder by the same name we're going to tack a number onto the end
|
||||
int iOutFilenameLength = Q_strlen( szOutFilename );
|
||||
int iSameFolderCount = 1;
|
||||
|
||||
while ( g_pFullFileSystem->FileExists( szOutFilename, "MOD" ) )
|
||||
{
|
||||
++iSameFolderCount;
|
||||
|
||||
if ( iSameFolderCount > 99 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
szOutFilename[ iOutFilenameLength ] = '\0';
|
||||
Q_snprintf( szOutFilename, sizeof( szOutFilename ), "%s%02i", szOutFilename, iSameFolderCount );
|
||||
}
|
||||
|
||||
// Pull the files out of the zip
|
||||
if ( g_pFullFileSystem->UnzipFile( pchZippedFileName, "MOD", szOutFilename ) )
|
||||
{
|
||||
// New maps have been imported, so refresh the list
|
||||
BuildMapsList();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: builds bonus map list from directory
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBonusMapsDialog::BuildMapsList( void )
|
||||
{
|
||||
// clear the current list
|
||||
m_pGameList->DeleteAllItems();
|
||||
|
||||
BonusMapsDatabase()->ClearBonusMapsList();
|
||||
BonusMapsDatabase()->ScanBonusMaps();
|
||||
|
||||
// Enable back button if we're in a sub folder
|
||||
bool bIsRoot = ( Q_strcmp( BonusMapsDatabase()->GetPath(), "." ) == 0 );
|
||||
SetControlEnabled( "Back", !bIsRoot );
|
||||
SetControlVisible( "Back", !bIsRoot );
|
||||
SetControlEnabled( "ImportBonusMaps", bIsRoot );
|
||||
SetControlVisible( "ImportBonusMaps", bIsRoot );
|
||||
|
||||
char szDisplayPath[_MAX_PATH];
|
||||
Q_snprintf( szDisplayPath, _MAX_PATH, "%s/", BonusMapsDatabase()->GetPath() );
|
||||
|
||||
SetControlString( "FileName", szDisplayPath );
|
||||
SetControlString( "CommentLabel", "" );
|
||||
|
||||
int iMapCount = BonusMapsDatabase()->BonusCount();
|
||||
|
||||
// add to the list
|
||||
for ( int iMapIndex = 0; iMapIndex < iMapCount && iMapIndex < MAX_LISTED_BONUS_MAPS; ++iMapIndex )
|
||||
{
|
||||
CBonusMapPanel *bonusMapPanel = new CBonusMapPanel( m_pGameList, "BonusMapPanel", iMapIndex );
|
||||
bonusMapPanel->SetBonusMapInfo( BonusMapsDatabase()->GetPath(), *(BonusMapsDatabase()->GetBonusData( iMapIndex )) );
|
||||
m_pGameList->AddItem( NULL, bonusMapPanel );
|
||||
}
|
||||
|
||||
// display a message if there are no save games
|
||||
if ( iMapCount <= 0 )
|
||||
{
|
||||
vgui::Label *pNoSavesLabel = SETUP_PANEL(new Label(m_pGameList, "NoBonusMapsLabel", "#GameUI_NoBonusMapsToDisplay"));
|
||||
pNoSavesLabel->SetTextColorState(vgui::Label::CS_DULL);
|
||||
m_pGameList->AddItem( NULL, pNoSavesLabel );
|
||||
m_pGameList->SetNumColumns( 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pGameList->SetNumColumns( 3 );
|
||||
}
|
||||
|
||||
RefreshCompletionPercentage();
|
||||
|
||||
// Disable load button
|
||||
SetControlEnabled( "loadbonusmap", false );
|
||||
|
||||
// Make challenge selection invisible
|
||||
m_pChallengeSelection->SetEnabled( false );
|
||||
m_pChallengeSelection->SetVisible( false );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Creates the load game display list
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBonusMapsDialog::CreateBonusMapsList()
|
||||
{
|
||||
m_pGameList = new vgui::PanelListPanel( this, "listpanel_bonusmaps" );
|
||||
m_pGameList->SetFirstColumnWidth( 0 );
|
||||
|
||||
new Label( this, "FileName", "./" );
|
||||
new Label( this, "CommentLabel", "" );
|
||||
|
||||
m_pChallengeSelection = new vgui::ComboBox( this, "ChallengeSelection", 0, false );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: returns the save file name of the selected item
|
||||
//-----------------------------------------------------------------------------
|
||||
int CBonusMapsDialog::GetSelectedItemBonusMapIndex()
|
||||
{
|
||||
CBonusMapPanel *panel = dynamic_cast<CBonusMapPanel *>(m_pGameList->GetSelectedPanel());
|
||||
if ( panel && panel->GetBonusMapListItemID() < BonusMapsDatabase()->BonusCount() )
|
||||
return panel->GetBonusMapListItemID();
|
||||
|
||||
return BonusMapsDatabase()->InvalidIndex();
|
||||
}
|
||||
|
||||
void CBonusMapsDialog::SetSelectedBooleanStatus( const char *pchName, bool bValue )
|
||||
{
|
||||
CBonusMapPanel *pSelectedBonusMapPanel = (CBonusMapPanel *)m_pGameList->GetSelectedPanel();
|
||||
if ( !pSelectedBonusMapPanel )
|
||||
return;
|
||||
|
||||
BonusMapsDatabase()->SetBooleanStatus( pchName, pSelectedBonusMapPanel->GetBonusMapListItemID(), bValue );
|
||||
|
||||
// Change the status in the dialog
|
||||
BonusMapDescription_t *pMap = BonusMapsDatabase()->GetBonusData( pSelectedBonusMapPanel->GetBonusMapListItemID() );
|
||||
pSelectedBonusMapPanel->SetBonusMapInfo( BonusMapsDatabase()->GetPath(), *pMap );
|
||||
|
||||
RefreshCompletionPercentage();
|
||||
RefreshDialog( pMap );
|
||||
}
|
||||
|
||||
void CBonusMapsDialog::RefreshData( void )
|
||||
{
|
||||
for ( int iMap = 0; iMap < m_pGameList->GetItemCount(); ++iMap )
|
||||
{
|
||||
CBonusMapPanel *pBonusMapPanel = (CBonusMapPanel *)m_pGameList->GetItemPanel( iMap );
|
||||
|
||||
if ( pBonusMapPanel )
|
||||
pBonusMapPanel->SetBonusMapInfo( BonusMapsDatabase()->GetPath(), *(BonusMapsDatabase()->GetBonusData( pBonusMapPanel->GetBonusMapListItemID() ) ) );
|
||||
}
|
||||
|
||||
CBonusMapPanel *pSelectedBonusMapPanel = (CBonusMapPanel *)m_pGameList->GetSelectedPanel();
|
||||
if ( !pSelectedBonusMapPanel )
|
||||
return;
|
||||
|
||||
BonusMapDescription_t *pMap = BonusMapsDatabase()->GetBonusData( pSelectedBonusMapPanel->GetBonusMapListItemID() );
|
||||
|
||||
RefreshCompletionPercentage();
|
||||
RefreshDialog( pMap );
|
||||
}
|
||||
|
||||
int CBonusMapsDialog::GetSelectedChallenge( void )
|
||||
{
|
||||
if ( !m_pChallengeSelection->IsEnabled() )
|
||||
return -1;
|
||||
|
||||
KeyValues *pUserDataKey = m_pChallengeSelection->GetActiveItemUserData();
|
||||
return pUserDataKey->GetInt( "challenge" );
|
||||
}
|
||||
|
||||
void CBonusMapsDialog::RefreshDialog( BonusMapDescription_t *pMap )
|
||||
{
|
||||
if ( !pMap || pMap->bLocked || ( m_pChallengeSelection->IsEnabled() && GetSelectedChallenge() == -1 ) )
|
||||
{
|
||||
// It's locked or no challenge is selected, so disable the load button
|
||||
SetControlEnabled( "loadbonusmap", false );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Enable the load button
|
||||
SetControlEnabled( "loadbonusmap", true );
|
||||
}
|
||||
|
||||
RefreshMedalDisplay( pMap );
|
||||
|
||||
if ( pMap )
|
||||
SetControlString( "CommentLabel", pMap->szComment );
|
||||
else
|
||||
SetControlString( "CommentLabel", "" );
|
||||
}
|
||||
|
||||
void CBonusMapsDialog::RefreshMedalDisplay( BonusMapDescription_t *pMap )
|
||||
{
|
||||
int iFirstChildIndex = FindChildIndexByName( "ChallengeMedalOverview00" );
|
||||
for ( int iMedal = 0; iMedal < 5; ++iMedal )
|
||||
{
|
||||
Panel *pMedalImage = GetChild( iFirstChildIndex + iMedal );
|
||||
pMedalImage->SetVisible( false );
|
||||
}
|
||||
|
||||
if ( !pMap || !pMap->m_pChallenges )
|
||||
{
|
||||
SetControlVisible( "ChallengeCommentLabel", false );
|
||||
SetControlVisible( "ChallengeEarnedMedal", false );
|
||||
SetControlVisible( "ChallengeBestLabel", false );
|
||||
SetControlVisible( "ChallengeNextMedal", false );
|
||||
SetControlVisible( "ChallengeNextLabel", false );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
char szBuff[ 512 ];
|
||||
|
||||
int iChallenge = GetSelectedChallenge();
|
||||
|
||||
if ( iChallenge < 0 )
|
||||
{
|
||||
SetControlVisible( "ChallengeCommentLabel", false );
|
||||
SetControlVisible( "ChallengeEarnedMedal", false );
|
||||
SetControlVisible( "ChallengeBestLabel", false );
|
||||
SetControlVisible( "ChallengeNextMedal", false );
|
||||
SetControlVisible( "ChallengeNextLabel", false );
|
||||
|
||||
int iFirstChildIndex = FindChildIndexByName( "ChallengeMedalOverview00" );
|
||||
for ( int iChallengeIndex = 0; iChallengeIndex < m_pChallengeSelection->GetItemCount(); ++iChallengeIndex )
|
||||
{
|
||||
KeyValues *pUserDataKey = m_pChallengeSelection->GetItemUserData( iChallengeIndex );
|
||||
int iChallengeNum = pUserDataKey->GetInt( "challenge" );
|
||||
|
||||
if ( iChallengeNum >= 0 )
|
||||
{
|
||||
ChallengeDescription_t *pChallengeDescription = NULL;
|
||||
|
||||
for ( int i = 0 ; i < pMap->m_pChallenges->Count(); ++i )
|
||||
{
|
||||
int iType = ((*pMap->m_pChallenges)[ i ]).iType;
|
||||
|
||||
if ( iType == -1 )
|
||||
{
|
||||
iType = i;
|
||||
}
|
||||
|
||||
if ( iType == iChallengeNum )
|
||||
pChallengeDescription = &((*pMap->m_pChallenges)[ i ]);
|
||||
}
|
||||
|
||||
if ( pChallengeDescription )
|
||||
{
|
||||
int iBest, iEarnedMedal, iNext, iNextMedal;
|
||||
GetChallengeMedals( pChallengeDescription, iBest, iEarnedMedal, iNext, iNextMedal );
|
||||
|
||||
if ( iChallengeNum < 10 )
|
||||
Q_snprintf( szBuff, 256, "medals/medal_0%i_%s", iChallengeNum, g_pszMedalNames[ iEarnedMedal ] );
|
||||
else
|
||||
Q_snprintf( szBuff, 256, "medals/medal_%i_%s", iChallengeNum, g_pszMedalNames[ iEarnedMedal ] );
|
||||
}
|
||||
|
||||
CBitmapImagePanel *pBitmap = dynamic_cast<CBitmapImagePanel*>( GetChild( iFirstChildIndex + iChallengeNum ) );
|
||||
pBitmap->SetVisible( true );
|
||||
pBitmap->setTexture( szBuff );
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ChallengeDescription_t *pChallengeDescription = NULL;
|
||||
|
||||
for ( int i = 0 ; i < pMap->m_pChallenges->Count(); ++i )
|
||||
{
|
||||
int iType = ((*pMap->m_pChallenges)[ i ]).iType;
|
||||
|
||||
if ( iType == -1 )
|
||||
{
|
||||
iType = i;
|
||||
}
|
||||
|
||||
if ( iType == iChallenge )
|
||||
pChallengeDescription = &((*pMap->m_pChallenges)[ i ]);
|
||||
}
|
||||
|
||||
if ( !pChallengeDescription )
|
||||
return;
|
||||
|
||||
const char *pchChallengeComment = pChallengeDescription->szComment;
|
||||
|
||||
int iBest, iEarnedMedal, iNext, iNextMedal;
|
||||
GetChallengeMedals( pChallengeDescription, iBest, iEarnedMedal, iNext, iNextMedal );
|
||||
|
||||
// Set comment label
|
||||
SetControlString( "ChallengeCommentLabel", pchChallengeComment );
|
||||
SetControlVisible( "ChallengeCommentLabel", true );
|
||||
|
||||
// Set earned medal
|
||||
if ( iEarnedMedal > -1 )
|
||||
{
|
||||
if ( iChallenge < 10 )
|
||||
Q_snprintf( szBuff, sizeof( szBuff ), "medals/medal_0%i_%s", iChallenge, g_pszMedalNames[ iEarnedMedal ] );
|
||||
else
|
||||
Q_snprintf( szBuff, sizeof( szBuff ), "medals/medal_%i_%s", iChallenge, g_pszMedalNames[ iEarnedMedal ] );
|
||||
|
||||
CBitmapImagePanel *pBitmap = dynamic_cast<CBitmapImagePanel*>( FindChildByName( "ChallengeEarnedMedal" ) );
|
||||
pBitmap->SetVisible( true );
|
||||
pBitmap->setTexture( szBuff );
|
||||
}
|
||||
|
||||
// Set next medal
|
||||
if ( iNextMedal > 0 )
|
||||
{
|
||||
if ( iChallenge < 10 )
|
||||
Q_snprintf( szBuff, sizeof( szBuff ), "medals/medal_0%i_%s", iChallenge, g_pszMedalNames[ iNextMedal ] );
|
||||
else
|
||||
Q_snprintf( szBuff, sizeof( szBuff ), "medals/medal_%i_%s", iChallenge, g_pszMedalNames[ iNextMedal ] );
|
||||
|
||||
CBitmapImagePanel *pBitmap = dynamic_cast<CBitmapImagePanel*>( FindChildByName( "ChallengeNextMedal" ) );
|
||||
pBitmap->SetVisible( true );
|
||||
pBitmap->setTexture( szBuff );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetControlVisible( "ChallengeNextMedal", false );
|
||||
}
|
||||
|
||||
wchar_t szWideBuff[ 64 ];
|
||||
wchar_t szWideBuff2[ 64 ];
|
||||
|
||||
// Best label
|
||||
if ( iBest != -1 )
|
||||
{
|
||||
Q_snprintf( szBuff, sizeof( szBuff ), "%i", iBest );
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode( szBuff, szWideBuff2, sizeof( szWideBuff2 ) );
|
||||
g_pVGuiLocalize->ConstructString( szWideBuff, sizeof( szWideBuff ), g_pVGuiLocalize->Find( "#GameUI_BonusMapsBest" ), 1, szWideBuff2 );
|
||||
g_pVGuiLocalize->ConvertUnicodeToANSI( szWideBuff, szBuff, sizeof( szBuff ) );
|
||||
|
||||
SetControlString( "ChallengeBestLabel", szBuff );
|
||||
SetControlVisible( "ChallengeBestLabel", true );
|
||||
}
|
||||
else
|
||||
SetControlVisible( "ChallengeBestLabel", false );
|
||||
|
||||
// Next label
|
||||
if ( iNext != -1 )
|
||||
{
|
||||
Q_snprintf( szBuff, sizeof( szBuff ), "%i", iNext );
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode( szBuff, szWideBuff2, sizeof( szWideBuff2 ) );
|
||||
g_pVGuiLocalize->ConstructString( szWideBuff, sizeof( szWideBuff ), g_pVGuiLocalize->Find( "#GameUI_BonusMapsGoal" ), 1, szWideBuff2 );
|
||||
g_pVGuiLocalize->ConvertUnicodeToANSI( szWideBuff, szBuff, sizeof( szBuff ) );
|
||||
|
||||
SetControlString( "ChallengeNextLabel", szBuff );
|
||||
SetControlVisible( "ChallengeNextLabel", true );
|
||||
}
|
||||
else
|
||||
SetControlVisible( "ChallengeNextLabel", false );
|
||||
}
|
||||
|
||||
void CBonusMapsDialog::RefreshCompletionPercentage( void )
|
||||
{
|
||||
float fPercentage = BonusMapsDatabase()->GetCompletionPercentage();
|
||||
if ( fPercentage > 0.0f )
|
||||
{
|
||||
char szBuff[ 256 ];
|
||||
if ( fPercentage * 100.0f < 1.0f )
|
||||
Q_snprintf( szBuff, 256, "%.2f%%", fPercentage * 100.0f ); // Show decimal places if less than 1%
|
||||
else
|
||||
Q_snprintf( szBuff, 256, "%.0f%%", fPercentage * 100.0f );
|
||||
|
||||
SetControlString( "PercentageText", szBuff );
|
||||
SetControlVisible( "PercentageText", true );
|
||||
SetControlVisible( "CompletionText", true );
|
||||
|
||||
// Blend the color from backround color 0% to selected color 100%
|
||||
Color cProgressBar = Color( static_cast<float>( m_PercentageBarBackgroundColor.r() ) * ( 1.0f - fPercentage ) + static_cast<float>( m_PercentageBarColor.r() ) * fPercentage,
|
||||
static_cast<float>( m_PercentageBarBackgroundColor.g() ) * ( 1.0f - fPercentage ) + static_cast<float>( m_PercentageBarColor.g() ) * fPercentage,
|
||||
static_cast<float>( m_PercentageBarBackgroundColor.b() ) * ( 1.0f - fPercentage ) + static_cast<float>( m_PercentageBarColor.b() ) * fPercentage,
|
||||
static_cast<float>( m_PercentageBarBackgroundColor.a() ) * ( 1.0f - fPercentage ) + static_cast<float>( m_PercentageBarColor.a() ) * fPercentage );
|
||||
|
||||
m_pPercentageBar->SetFillColor( cProgressBar );
|
||||
m_pPercentageBar->SetWide( m_pPercentageBarBackground->GetWide() * fPercentage );
|
||||
|
||||
SetControlVisible( "PercentageBarBackground", true );
|
||||
SetControlVisible( "PercentageBar", true );
|
||||
}
|
||||
else
|
||||
{
|
||||
// 0% complete so don't display
|
||||
SetControlVisible( "PercentageText", false );
|
||||
SetControlVisible( "CompletionText", false );
|
||||
SetControlVisible( "PercentageBarBackground", false );
|
||||
SetControlVisible( "PercentageBar", false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CBonusMapsDialog::ApplySchemeSettings( IScheme *pScheme )
|
||||
{
|
||||
m_PercentageBarBackgroundColor = Color( 0, 0, 0, 64 );
|
||||
m_PercentageBarColor = pScheme->GetColor( "NewGame.SelectionColor", Color(255, 255, 255, 255) );
|
||||
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBonusMapsDialog::OnCommand( const char *command )
|
||||
{
|
||||
if ( !stricmp( command, "loadbonusmap" ) )
|
||||
{
|
||||
int mapIndex = GetSelectedItemBonusMapIndex();
|
||||
if ( BonusMapsDatabase()->IsValidIndex( mapIndex ) )
|
||||
{
|
||||
BonusMapDescription_t *pBonusMap = BonusMapsDatabase()->GetBonusData( mapIndex );
|
||||
|
||||
// Don't do anything with locked items
|
||||
if ( pBonusMap->bLocked || ( m_pChallengeSelection->IsEnabled() && GetSelectedChallenge() == -1 ) )
|
||||
return;
|
||||
|
||||
const char *shortName = pBonusMap->szShortName;
|
||||
if ( shortName && shortName[ 0 ] )
|
||||
{
|
||||
if ( pBonusMap->bIsFolder )
|
||||
{
|
||||
BonusMapsDatabase()->AppendPath( shortName );
|
||||
|
||||
// repopulate list with current directory
|
||||
BuildMapsList();
|
||||
|
||||
m_pGameList->MoveScrollBarToTop();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Load the game, return to top and switch to engine
|
||||
char sz[ 256 ];
|
||||
|
||||
// Set the challenge mode if one is selected
|
||||
int iChallenge = GetSelectedChallenge() + 1;
|
||||
|
||||
if ( iChallenge > 0 )
|
||||
{
|
||||
Q_snprintf( sz, sizeof( sz ), "sv_bonus_challenge %i\n", iChallenge );
|
||||
engine->ClientCmd_Unrestricted( sz );
|
||||
|
||||
ChallengeDescription_t *pChallengeDescription = &((*pBonusMap->m_pChallenges)[ iChallenge - 1 ]);
|
||||
|
||||
// Set up medal goals
|
||||
BonusMapsDatabase()->SetCurrentChallengeObjectives( pChallengeDescription->iBronze, pChallengeDescription->iSilver, pChallengeDescription->iGold );
|
||||
BonusMapsDatabase()->SetCurrentChallengeNames( pBonusMap->szFileName, pBonusMap->szMapName, pChallengeDescription->szName );
|
||||
}
|
||||
|
||||
if ( pBonusMap->szMapFileName[ 0 ] != '.' )
|
||||
{
|
||||
Q_snprintf( sz, sizeof( sz ), "map %s\n", pBonusMap->szMapFileName );
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *pchSubDir = Q_strnchr( BonusMapsDatabase()->GetPath(), '/', Q_strlen( BonusMapsDatabase()->GetPath() ) );
|
||||
|
||||
if ( pchSubDir )
|
||||
{
|
||||
pchSubDir = Q_strnchr( pchSubDir + 1, '/', Q_strlen( pchSubDir ) );
|
||||
|
||||
if ( pchSubDir )
|
||||
{
|
||||
++pchSubDir;
|
||||
const char *pchMapFileName = pBonusMap->szMapFileName + 2;
|
||||
Q_snprintf( sz, sizeof( sz ), "map %s/%s\n", pchSubDir, pchMapFileName );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
engine->ClientCmd_Unrestricted( sz );
|
||||
|
||||
// Close this dialog
|
||||
//OnClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( !stricmp( command, "back" ) )
|
||||
{
|
||||
BonusMapsDatabase()->BackPath();
|
||||
|
||||
// repopulate list with current directory
|
||||
BuildMapsList();
|
||||
|
||||
m_pChallengeSelection->RemoveAll();
|
||||
m_pChallengeSelection->AddItem( "<Select A Challenge>", new KeyValues( "ChallengeSelection", "challenge", -1 ) );
|
||||
|
||||
RefreshDialog( NULL );
|
||||
|
||||
m_pGameList->MoveScrollBarToTop();
|
||||
}
|
||||
else if ( !stricmp( command, "ImportBonusMaps" ) )
|
||||
{
|
||||
if ( m_hImportBonusMapsDialog == NULL )
|
||||
{
|
||||
m_hImportBonusMapsDialog = new FileOpenDialog( NULL, "#GameUI_ImportBonusMaps", true );
|
||||
m_hImportBonusMapsDialog->AddFilter( "*.bmz", "#GameUI_BMZ_Files", true );
|
||||
m_hImportBonusMapsDialog->AddActionSignalTarget( this );
|
||||
}
|
||||
m_hImportBonusMapsDialog->DoModal(false);
|
||||
m_hImportBonusMapsDialog->Activate();
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnCommand( command );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: One item has been selected
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBonusMapsDialog::OnPanelSelected()
|
||||
{
|
||||
CBonusMapPanel *pSelectedBonusMapPanel = (CBonusMapPanel *)m_pGameList->GetSelectedPanel();
|
||||
BonusMapDescription_t *pMap = BonusMapsDatabase()->GetBonusData( pSelectedBonusMapPanel->GetBonusMapListItemID() );
|
||||
|
||||
SetControlString( "CommentLabel", pMap->szComment );
|
||||
|
||||
// Handle challenge selection box
|
||||
int iNumChallenges = 0;
|
||||
|
||||
if ( pMap->m_pChallenges )
|
||||
{
|
||||
// Get the name of the previously selected challenge so that we can select a matching challenge (if one exists)
|
||||
int iSelectedChallenge = GetSelectedChallenge();
|
||||
|
||||
m_pChallengeSelection->RemoveAll();
|
||||
|
||||
m_pChallengeSelection->AddItem( "<Select A Challenge>", new KeyValues( "ChallengeSelection", "challenge", -1 ) );
|
||||
|
||||
int iFoundSimilar = 0;
|
||||
|
||||
for ( iNumChallenges; iNumChallenges < pMap->m_pChallenges->Count(); ++iNumChallenges )
|
||||
{
|
||||
ChallengeDescription_t *pChallenge = &(*pMap->m_pChallenges)[ iNumChallenges ];
|
||||
int iType = iNumChallenges;
|
||||
|
||||
// If the challenge type was specified then use that instead of (legacy) the order the challenges were listed
|
||||
if ( pChallenge->iType != -1 )
|
||||
iType = pChallenge->iType;
|
||||
|
||||
m_pChallengeSelection->AddItem( pChallenge->szName, new KeyValues( "ChallengeSelection", "challenge", iType ) );
|
||||
|
||||
if ( iSelectedChallenge == iNumChallenges )
|
||||
iFoundSimilar = iNumChallenges + 1;
|
||||
}
|
||||
|
||||
m_pChallengeSelection->ActivateItemByRow( iFoundSimilar );
|
||||
}
|
||||
|
||||
if ( iNumChallenges > 0 )
|
||||
{
|
||||
m_pChallengeSelection->SetEnabled( true );
|
||||
m_pChallengeSelection->SetVisible( true );
|
||||
m_pChallengeSelection->SetNumberOfEditLines( iNumChallenges + 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pChallengeSelection->SetEnabled( false );
|
||||
m_pChallengeSelection->SetVisible( false );
|
||||
}
|
||||
|
||||
RefreshDialog( pMap );
|
||||
}
|
||||
|
||||
void CBonusMapsDialog::OnControlModified()
|
||||
{
|
||||
CBonusMapPanel *pSelectedBonusMapPanel = (CBonusMapPanel *)m_pGameList->GetSelectedPanel();
|
||||
BonusMapDescription_t *pMap = BonusMapsDatabase()->GetBonusData( pSelectedBonusMapPanel->GetBonusMapListItemID() );
|
||||
|
||||
RefreshDialog( pMap );
|
||||
}
|
||||
|
||||
// file selected. This can only happen when someone selects an image to be imported as a spray logo.
|
||||
void CBonusMapsDialog::OnFileSelected( const char *fullpath )
|
||||
{
|
||||
if ( fullpath == NULL || fullpath[ 0 ] == '\0' )
|
||||
return;
|
||||
|
||||
// this can take a while, put up a waiting cursor
|
||||
surface()->SetCursor(dc_hourglass);
|
||||
|
||||
ImportZippedBonusMaps( fullpath );
|
||||
|
||||
// change the cursor back to normal
|
||||
surface()->SetCursor(dc_user);
|
||||
}
|
||||
72
game/client/cstrike15/gameui/bonusmapsdialog.h
Normal file
72
game/client/cstrike15/gameui/bonusmapsdialog.h
Normal file
@@ -0,0 +1,72 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef BONUSMAPSDIALOG_H
|
||||
#define BONUSMAPSDIALOG_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui_controls/Frame.h"
|
||||
|
||||
#include "bonusmapsdatabase.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Displays and loads available bonus maps
|
||||
//-----------------------------------------------------------------------------
|
||||
class CBonusMapsDialog : public vgui::Frame
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CBonusMapsDialog, vgui::Frame );
|
||||
|
||||
public:
|
||||
explicit CBonusMapsDialog(vgui::Panel *parent);
|
||||
~CBonusMapsDialog();
|
||||
|
||||
void SetSelectedBooleanStatus( const char *pchName, bool bValue );
|
||||
void RefreshData( void );
|
||||
|
||||
int GetSelectedChallenge( void );
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
virtual void OnCommand( const char *command );
|
||||
|
||||
private:
|
||||
bool ImportZippedBonusMaps( const char *pchZippedFileName );
|
||||
|
||||
void BuildMapsList( void );
|
||||
|
||||
void CreateBonusMapsList();
|
||||
int GetSelectedItemBonusMapIndex();
|
||||
|
||||
void RefreshDialog( BonusMapDescription_t *pMap );
|
||||
void RefreshMedalDisplay( BonusMapDescription_t *pMap );
|
||||
void RefreshCompletionPercentage( void );
|
||||
|
||||
MESSAGE_FUNC( OnPanelSelected, "PanelSelected" );
|
||||
MESSAGE_FUNC( OnControlModified, "ControlModified" );
|
||||
MESSAGE_FUNC( OnTextChanged, "TextChanged" )
|
||||
{
|
||||
OnControlModified();
|
||||
}
|
||||
MESSAGE_FUNC_CHARPTR( OnFileSelected, "FileSelected", fullpath );
|
||||
|
||||
private:
|
||||
Color m_PercentageBarBackgroundColor, m_PercentageBarColor;
|
||||
|
||||
vgui::FileOpenDialog *m_hImportBonusMapsDialog;
|
||||
vgui::PanelListPanel *m_pGameList;
|
||||
vgui::ComboBox *m_pChallengeSelection;
|
||||
vgui::ImagePanel *m_pPercentageBarBackground;
|
||||
vgui::ImagePanel *m_pPercentageBar;
|
||||
};
|
||||
|
||||
|
||||
extern CBonusMapsDialog *g_pBonusMapsDialog;
|
||||
|
||||
|
||||
#endif // BONUSMAPSDIALOG_H
|
||||
323
game/client/cstrike15/gameui/cdkeyentrydialog.cpp
Normal file
323
game/client/cstrike15/gameui/cdkeyentrydialog.cpp
Normal file
@@ -0,0 +1,323 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "CDKeyEntryDialog.h"
|
||||
#include "EngineInterface.h"
|
||||
|
||||
#include "SteamCommon.h" // VALVE_AUTH cd key checking code
|
||||
#include "ValidateNewValveCDKeyClient.h"
|
||||
#include "ValveCDKeyGameAndTerritoryCodes.h"
|
||||
|
||||
#include "vgui/IInput.h"
|
||||
#include "vgui/IPanel.h"
|
||||
#include "vgui/ISystem.h"
|
||||
#include "vgui/ISurface.h"
|
||||
#include "vgui_controls/Button.h"
|
||||
#include "vgui_controls/MessageBox.h"
|
||||
#include "vgui_controls/TextEntry.h"
|
||||
#include "vstdlib/random.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
#define FAKE_CDKEY_LEN 49
|
||||
#define FAKE_CDKEY_REGKEY "HKEY_CURRENT_USER\\Software\\Valve\\Source\\Settings\\EncryptedCDKey"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: hacky class to make all input uppercase
|
||||
//-----------------------------------------------------------------------------
|
||||
class CUpperCaseTextEntry : public vgui::TextEntry
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CUpperCaseTextEntry, vgui::TextEntry );
|
||||
public:
|
||||
CUpperCaseTextEntry(vgui::Panel *parent, const char *name) : TextEntry(parent, name) {}
|
||||
|
||||
virtual void InsertChar(wchar_t unichar)
|
||||
{
|
||||
// only allow input of valid cdkey characters
|
||||
if (unichar >= 'a' && unichar <= 'z')
|
||||
{
|
||||
// force to be uppercase
|
||||
BaseClass::InsertChar(unichar - 'a' + 'A');
|
||||
}
|
||||
else if ((unichar >= 'A' && unichar <= 'Z')
|
||||
|| (unichar >= '0' && unichar <= '9'))
|
||||
{
|
||||
BaseClass::InsertChar(unichar);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class CloseMessageBox : public vgui::MessageBox
|
||||
{
|
||||
public:
|
||||
CloseMessageBox(const char *title, const char *text, Panel *parent = NULL): MessageBox( title, text, parent) {}
|
||||
|
||||
virtual void OnClose()
|
||||
{
|
||||
engine->ClientCmd_Unrestricted("quit\n");
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CCDKeyEntryDialog::CCDKeyEntryDialog(vgui::Panel *parent, bool inConnect) : BaseClass(parent, "CDKeyEntryDialog")
|
||||
{
|
||||
// see what type of cdkey we have
|
||||
SetDeleteSelfOnClose(true);
|
||||
m_bInConnect = inConnect;
|
||||
m_iErrCount = 0;
|
||||
m_bEnteredValidCDKey = false;
|
||||
|
||||
m_pOK = new Button(this, "OKButton", "#GameUI_OK");
|
||||
m_pQuitGame = new Button(this, "CancelButton", "#GameUI_Quit");
|
||||
m_pEntry1 = new CUpperCaseTextEntry(this, "Entry1");;
|
||||
m_pEntry2 = new CUpperCaseTextEntry(this, "Entry2");
|
||||
m_pEntry3 = new CUpperCaseTextEntry(this, "Entry3");
|
||||
m_pEntry4 = new CUpperCaseTextEntry(this, "Entry4");
|
||||
m_pEntry5 = new CUpperCaseTextEntry(this, "Entry5");
|
||||
|
||||
m_pEntry1->SetMaximumCharCount(5);
|
||||
m_pEntry2->SetMaximumCharCount(5);
|
||||
m_pEntry3->SetMaximumCharCount(5);
|
||||
m_pEntry4->SetMaximumCharCount(5);
|
||||
m_pEntry5->SetMaximumCharCount(5);
|
||||
|
||||
m_pEntry1->SetAutoProgressOnHittingCharLimit(true);
|
||||
m_pEntry2->SetAutoProgressOnHittingCharLimit(true);
|
||||
m_pEntry3->SetAutoProgressOnHittingCharLimit(true);
|
||||
m_pEntry4->SetAutoProgressOnHittingCharLimit(true);
|
||||
m_pEntry5->SetAutoProgressOnHittingCharLimit(false);
|
||||
|
||||
SetSizeable(false);
|
||||
SetSize(360, 224);
|
||||
SetTitle("#GameUI_CDKey", true);
|
||||
|
||||
LoadControlSettings("Resource/ValveCDKeyEntryDialog.res");
|
||||
// MoveToCenterOfScreen();
|
||||
|
||||
SetMinimizeButtonVisible(false);
|
||||
SetMaximizeButtonVisible(false);
|
||||
|
||||
m_pOK->SetEnabled(false);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CCDKeyEntryDialog::~CCDKeyEntryDialog()
|
||||
{
|
||||
vgui::surface()->RestrictPaintToSinglePanel(NULL);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: returns true if there is a valid weak check key in the registry
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CCDKeyEntryDialog::IsValidWeakCDKeyInRegistry()
|
||||
{
|
||||
char fakekey[FAKE_CDKEY_LEN];
|
||||
if (vgui::system()->GetRegistryString(FAKE_CDKEY_REGKEY, fakekey, sizeof(fakekey)))
|
||||
{
|
||||
if (strlen(fakekey) == (FAKE_CDKEY_LEN - 1)
|
||||
&& fakekey[17] == 'E'
|
||||
&& fakekey[31] == 'z'
|
||||
&& fakekey[43] == 'n')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCDKeyEntryDialog::OnCommand(const char *command)
|
||||
{
|
||||
if (!stricmp(command, "OK"))
|
||||
{
|
||||
if (IsEnteredKeyValid())
|
||||
{
|
||||
m_bEnteredValidCDKey = true;
|
||||
|
||||
// write out fake key and continue
|
||||
char fakekey[FAKE_CDKEY_LEN];
|
||||
for (int i = 0; i < sizeof(fakekey) - 1; i++)
|
||||
{
|
||||
// pick some random fields for us to check later
|
||||
if (i == 17)
|
||||
{
|
||||
fakekey[i] = 'E';
|
||||
}
|
||||
else if (i == 31)
|
||||
{
|
||||
fakekey[i] = 'z';
|
||||
}
|
||||
else if (i == 43)
|
||||
{
|
||||
fakekey[i] = 'n';
|
||||
}
|
||||
else
|
||||
{
|
||||
fakekey[i] = RandomInt('0', 'z');
|
||||
}
|
||||
}
|
||||
fakekey[sizeof(fakekey) - 1] = 0;
|
||||
vgui::system()->SetRegistryString(FAKE_CDKEY_REGKEY, fakekey);
|
||||
|
||||
if ( m_bInConnect )
|
||||
{
|
||||
engine->ClientCmd_Unrestricted( "retry\n" ); // retry the server connection with this new key...
|
||||
}
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_hErrorBox = new MessageBox("#GameUI_CDKey_Invalid_Title","#GameUI_CDKey_Invalid_Text", this);
|
||||
m_hErrorBox->ShowWindow( this );
|
||||
}
|
||||
}
|
||||
else if (!stricmp(command, "Cancel") || !stricmp(command, "Close"))
|
||||
{
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnCommand(command);
|
||||
}
|
||||
|
||||
if (!m_bEnteredValidCDKey) // moved away from the dialog box to make it a little harder to crack...
|
||||
{
|
||||
m_iErrCount++;
|
||||
if( m_iErrCount >= MAX_CDKEY_ERRORS )
|
||||
{
|
||||
// too many bad entries, make em quit
|
||||
CloseMessageBox *bx = new CloseMessageBox("#GameUI_CDKey_Invalid_Title","#GameUI_CDKey_TooManyTries", this);
|
||||
bx->ShowWindow( this );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCDKeyEntryDialog::OnClose()
|
||||
{
|
||||
if (!m_bEnteredValidCDKey)
|
||||
{
|
||||
// if we don't have a valid key we can't continue
|
||||
engine->ClientCmd_Unrestricted("quit\n");
|
||||
}
|
||||
|
||||
BaseClass::OnClose();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCDKeyEntryDialog::OnThink()
|
||||
{
|
||||
if (!m_bEnteredValidCDKey)
|
||||
{
|
||||
// force us to be the only thing to draw
|
||||
VPANEL vpanel = m_hErrorBox.Get() ? m_hErrorBox->GetVPanel() : GetVPanel();
|
||||
vgui::surface()->RestrictPaintToSinglePanel(vpanel);
|
||||
|
||||
// make sure we're the focus
|
||||
if (!(input()->GetFocus() && ipanel()->HasParent(input()->GetFocus(), GetVPanel())))
|
||||
{
|
||||
BaseClass::Activate();
|
||||
}
|
||||
}
|
||||
BaseClass::OnThink();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: returns whether or not the key entered by the user passes the simple check
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CCDKeyEntryDialog::IsEnteredKeyValid()
|
||||
{
|
||||
// get the entered text
|
||||
char cdkey[32];
|
||||
m_pEntry1->GetText(cdkey, 6);
|
||||
m_pEntry2->GetText(cdkey + 6, 6);
|
||||
m_pEntry3->GetText(cdkey + 12, 6);
|
||||
m_pEntry4->GetText(cdkey + 18, 6);
|
||||
m_pEntry5->GetText(cdkey + 24, 6);
|
||||
|
||||
// add in the hyphens
|
||||
cdkey[5] = '-';
|
||||
cdkey[11] = '-';
|
||||
cdkey[17] = '-';
|
||||
cdkey[23] = '-';
|
||||
|
||||
// verify the entry
|
||||
for (int i = 0; i < 29; i++)
|
||||
{
|
||||
if (cdkey[i] != '-' && !isalnum(cdkey[i]))
|
||||
return false;
|
||||
}
|
||||
#if !defined( NO_STEAM )
|
||||
uint gameCode, salesTerritoryCode, uniqueSerialNumber;
|
||||
|
||||
// test key - this key passes they weak check, but not the strong check
|
||||
// "5J5Q3-QCME2-2SMMV-SBHN9-43S2S"
|
||||
if ( SteamWeakVerifyNewValveCDKey(cdkey, &gameCode, &salesTerritoryCode, &uniqueSerialNumber) == eSteamErrorNone )
|
||||
{
|
||||
// require hl2 retail cdkey (ATI Bundle keys are also in this category)
|
||||
if (gameCode == eHalfLife2)
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: handles user entering data in fields
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCDKeyEntryDialog::OnTextChanged(Panel *entry)
|
||||
{
|
||||
char cdkey[32];
|
||||
m_pEntry1->GetText(cdkey, 6);
|
||||
m_pEntry2->GetText(cdkey + 6, 6);
|
||||
m_pEntry3->GetText(cdkey + 12, 6);
|
||||
m_pEntry4->GetText(cdkey + 18, 6);
|
||||
m_pEntry5->GetText(cdkey + 24, 6);
|
||||
|
||||
// add in the hyphens
|
||||
cdkey[5] = '-';
|
||||
cdkey[11] = '-';
|
||||
cdkey[17] = '-';
|
||||
cdkey[23] = '-';
|
||||
|
||||
if (strlen(cdkey) == 29)
|
||||
{
|
||||
m_pOK->SetEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pOK->SetEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCDKeyEntryDialog::Activate()
|
||||
{
|
||||
BaseClass::Activate();
|
||||
m_pEntry1->RequestFocus();
|
||||
}
|
||||
58
game/client/cstrike15/gameui/cdkeyentrydialog.h
Normal file
58
game/client/cstrike15/gameui/cdkeyentrydialog.h
Normal file
@@ -0,0 +1,58 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CDKEYENTRYDIALOG_H
|
||||
#define CDKEYENTRYDIALOG_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui_controls/Frame.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CCDKeyEntryDialog : public vgui::Frame
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CCDKeyEntryDialog, vgui::Frame );
|
||||
|
||||
public:
|
||||
CCDKeyEntryDialog(vgui::Panel *parent, bool inConnect = false);
|
||||
~CCDKeyEntryDialog();
|
||||
|
||||
virtual void Activate();
|
||||
|
||||
static bool IsValidWeakCDKeyInRegistry();
|
||||
|
||||
private:
|
||||
enum { MAX_CDKEY_ERRORS = 5 };
|
||||
|
||||
virtual void OnCommand(const char *command);
|
||||
virtual void OnClose();
|
||||
virtual void OnThink();
|
||||
|
||||
MESSAGE_FUNC_PTR( OnTextChanged, "TextChanged", panel );
|
||||
bool IsEnteredKeyValid();
|
||||
|
||||
vgui::Button *m_pOK;
|
||||
vgui::Button *m_pQuitGame;
|
||||
vgui::TextEntry *m_pEntry1;
|
||||
vgui::TextEntry *m_pEntry2;
|
||||
vgui::TextEntry *m_pEntry3;
|
||||
vgui::TextEntry *m_pEntry4;
|
||||
vgui::TextEntry *m_pEntry5;
|
||||
|
||||
vgui::DHANDLE<vgui::MessageBox> m_hErrorBox;
|
||||
|
||||
bool m_bEnteredValidCDKey;
|
||||
|
||||
bool m_bInConnect;
|
||||
int m_iErrCount;
|
||||
};
|
||||
|
||||
|
||||
#endif // CDKEYENTRYDIALOG_H
|
||||
159
game/client/cstrike15/gameui/changegamedialog.cpp
Normal file
159
game/client/cstrike15/gameui/changegamedialog.cpp
Normal file
@@ -0,0 +1,159 @@
|
||||
//========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#undef fopen
|
||||
|
||||
#if !defined( _GAMECONSOLE ) && !defined( _OSX ) && !defined (LINUX)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
||||
#include "changegamedialog.h"
|
||||
#include "modinfo.h"
|
||||
#include "engineinterface.h"
|
||||
|
||||
#include <vgui_controls/ListPanel.h>
|
||||
#include <keyvalues.h>
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CChangeGameDialog::CChangeGameDialog(vgui::Panel *parent) : Frame(parent, "ChangeGameDialog")
|
||||
{
|
||||
SetSize(400, 340);
|
||||
SetMinimumSize(400, 340);
|
||||
SetTitle("#GameUI_ChangeGame", true);
|
||||
|
||||
m_pModList = new ListPanel(this, "ModList");
|
||||
m_pModList->SetEmptyListText("#GameUI_NoOtherGamesAvailable");
|
||||
m_pModList->AddColumnHeader(0, "ModName", "#GameUI_Game", 128);
|
||||
|
||||
LoadModList();
|
||||
LoadControlSettings("Resource/ChangeGameDialog.res");
|
||||
|
||||
// if there's a mod in the list, select the first one
|
||||
if (m_pModList->GetItemCount() > 0)
|
||||
{
|
||||
m_pModList->SetSingleSelectedItem(m_pModList->GetItemIDFromRow(0));
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CChangeGameDialog::~CChangeGameDialog()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Fills the mod list
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChangeGameDialog::LoadModList()
|
||||
{
|
||||
#if !defined( _OSX ) && !defined( _PS3 ) && !defined(LINUX)
|
||||
// look for third party games
|
||||
char szSearchPath[_MAX_PATH + 5];
|
||||
Q_strncpy(szSearchPath, "*.*", sizeof( szSearchPath ) );
|
||||
|
||||
// use local filesystem since it has to look outside path system, and will never be used under steam
|
||||
WIN32_FIND_DATA wfd;
|
||||
HANDLE hResult;
|
||||
memset(&wfd, 0, sizeof(WIN32_FIND_DATA));
|
||||
|
||||
hResult = FindFirstFile( szSearchPath, &wfd);
|
||||
if (hResult != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
BOOL bMoreFiles;
|
||||
while (1)
|
||||
{
|
||||
if ( (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && wfd.cFileName[ 0 ] != '.' )
|
||||
{
|
||||
// Check for dlls\*.dll
|
||||
char szDllDirectory[MAX_PATH + 16];
|
||||
Q_snprintf(szDllDirectory, sizeof( szDllDirectory ), "%s\\gameinfo.txt", wfd.cFileName);
|
||||
|
||||
FILE *f = fopen(szDllDirectory, "rb");
|
||||
if (f)
|
||||
{
|
||||
// find the description
|
||||
fseek(f, 0, SEEK_END);
|
||||
unsigned int size = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
char *buf = (char *)malloc(size + 1);
|
||||
if (fread(buf, 1, size, f) == size)
|
||||
{
|
||||
buf[size] = 0;
|
||||
|
||||
CModInfo modInfo;
|
||||
modInfo.LoadGameInfoFromBuffer(buf);
|
||||
|
||||
if (strcmp(modInfo.GetGameName(), ModInfo().GetGameName()))
|
||||
{
|
||||
// Add the game directory.
|
||||
strlwr(wfd.cFileName);
|
||||
KeyValues *itemData = new KeyValues("Mod");
|
||||
itemData->SetString("ModName", modInfo.GetGameName());
|
||||
itemData->SetString("ModDir", wfd.cFileName);
|
||||
m_pModList->AddItem(itemData, 0, false, false);
|
||||
}
|
||||
}
|
||||
free(buf);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
bMoreFiles = FindNextFile(hResult, &wfd);
|
||||
if (!bMoreFiles)
|
||||
break;
|
||||
}
|
||||
|
||||
FindClose(hResult);
|
||||
}
|
||||
#endif // !_OSX && !_PS3
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CChangeGameDialog::OnCommand(const char *command)
|
||||
{
|
||||
if (!stricmp(command, "OK"))
|
||||
{
|
||||
if (m_pModList->GetSelectedItemsCount() > 0)
|
||||
{
|
||||
KeyValues *kv = m_pModList->GetItem(m_pModList->GetSelectedItem(0));
|
||||
if (kv)
|
||||
{
|
||||
// change the game dir and restart the engine
|
||||
char szCmd[256];
|
||||
Q_snprintf(szCmd, sizeof( szCmd ), "_setgamedir %s\n", kv->GetString("ModDir"));
|
||||
engine->ClientCmd_Unrestricted(szCmd);
|
||||
|
||||
// Force restart of entire engine
|
||||
engine->ClientCmd_Unrestricted("_restart\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!stricmp(command, "Cancel"))
|
||||
{
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
36
game/client/cstrike15/gameui/changegamedialog.h
Normal file
36
game/client/cstrike15/gameui/changegamedialog.h
Normal file
@@ -0,0 +1,36 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CHANGEGAMEDIALOG_H
|
||||
#define CHANGEGAMEDIALOG_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui_controls/Frame.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Dialogs for use to change current loaded mod
|
||||
//-----------------------------------------------------------------------------
|
||||
class CChangeGameDialog : public vgui::Frame
|
||||
{
|
||||
public:
|
||||
explicit CChangeGameDialog(vgui::Panel *parent);
|
||||
~CChangeGameDialog();
|
||||
|
||||
virtual void OnCommand( const char *command );
|
||||
|
||||
private:
|
||||
void LoadModList();
|
||||
|
||||
vgui::ListPanel *m_pModList;
|
||||
|
||||
typedef vgui::Frame BaseClass;
|
||||
};
|
||||
|
||||
|
||||
#endif // CHANGEGAMEDIALOG_H
|
||||
45
game/client/cstrike15/gameui/commandcheckbutton.cpp
Normal file
45
game/client/cstrike15/gameui/commandcheckbutton.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "commandcheckbutton.h"
|
||||
#include "engineinterface.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
CCommandCheckButton::CCommandCheckButton( Panel *parent, const char *panelName, const char *text, const char *downcmd, const char *upcmd )
|
||||
: CheckButton( parent, panelName, text )
|
||||
{
|
||||
m_pszDown = downcmd ? strdup( downcmd ) : NULL;
|
||||
m_pszUp = upcmd ? strdup( upcmd ) : NULL;
|
||||
}
|
||||
|
||||
CCommandCheckButton::~CCommandCheckButton()
|
||||
{
|
||||
free( m_pszDown );
|
||||
free( m_pszUp );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *panel -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCommandCheckButton::SetSelected( bool state )
|
||||
{
|
||||
BaseClass::SetSelected( state );
|
||||
|
||||
if ( IsSelected() && m_pszDown )
|
||||
{
|
||||
engine->ClientCmd_Unrestricted( m_pszDown );
|
||||
}
|
||||
else if ( !IsSelected() && m_pszUp )
|
||||
{
|
||||
engine->ClientCmd_Unrestricted( m_pszUp );
|
||||
}
|
||||
}
|
||||
30
game/client/cstrike15/gameui/commandcheckbutton.h
Normal file
30
game/client/cstrike15/gameui/commandcheckbutton.h
Normal file
@@ -0,0 +1,30 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef COMMANDCHECKBUTTON_H
|
||||
#define COMMANDCHECKBUTTON_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui_controls/CheckButton.h>
|
||||
|
||||
class CCommandCheckButton : public vgui::CheckButton
|
||||
{
|
||||
public:
|
||||
CCommandCheckButton( vgui::Panel *parent, const char *panelName, const char *text, const char *downcmd, const char *upcmd );
|
||||
~CCommandCheckButton();
|
||||
|
||||
// virtual void OnCheckButtonChecked(vgui::Panel *panel);
|
||||
virtual void SetSelected( bool state );
|
||||
private:
|
||||
typedef vgui::CheckButton BaseClass;
|
||||
|
||||
char *m_pszDown;
|
||||
char *m_pszUp;
|
||||
};
|
||||
#endif // COMMANDCHECKBUTTON_H
|
||||
227
game/client/cstrike15/gameui/commentarydialog.cpp
Normal file
227
game/client/cstrike15/gameui/commentarydialog.cpp
Normal file
@@ -0,0 +1,227 @@
|
||||
//====== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. =======
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#include "commentarydialog.h"
|
||||
#include "basepanel.h"
|
||||
#include "convar.h"
|
||||
#include "engineinterface.h"
|
||||
#include "gameui_interface.h"
|
||||
#include "vgui/ISurface.h"
|
||||
#include "vgui/IInput.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CCommentaryDialog::CCommentaryDialog(vgui::Panel *parent) : BaseClass(parent, "CommentaryDialog")
|
||||
{
|
||||
SetDeleteSelfOnClose(true);
|
||||
SetSizeable( false );
|
||||
|
||||
input()->SetAppModalSurface(GetVPanel());
|
||||
vgui::surface()->RestrictPaintToSinglePanel(GetVPanel());
|
||||
GameUI().PreventEngineHideGameUI();
|
||||
|
||||
SetTitle("#GameUI_CommentaryDialogTitle", true);
|
||||
|
||||
LoadControlSettings("Resource/CommentaryDialog.res");
|
||||
|
||||
MoveToCenterOfScreen();
|
||||
|
||||
bool bCommentaryOn = false;
|
||||
ConVarRef commentary( "commentary" );
|
||||
if ( commentary.IsValid() )
|
||||
{
|
||||
bCommentaryOn = commentary.GetBool();
|
||||
}
|
||||
|
||||
// Setup the buttons & labels to reflect the current state of the commentary
|
||||
if ( bCommentaryOn )
|
||||
{
|
||||
SetControlString( "ModeLabel", "#GAMEUI_Commentary_LabelOn" );
|
||||
SetControlString( "TurnOnButton", "#GAMEUI_Commentary_LeaveOn" );
|
||||
SetControlString( "TurnOffButton", "#GAMEUI_Commentary_TurnOff" );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetControlString( "ModeLabel", "#GAMEUI_Commentary_LabelOff" );
|
||||
SetControlString( "TurnOnButton", "#GAMEUI_Commentary_TurnOn" );
|
||||
SetControlString( "TurnOffButton", "#GAMEUI_Commentary_LeaveOff" );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CCommentaryDialog::~CCommentaryDialog()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCommentaryDialog::OnClose( void )
|
||||
{
|
||||
BaseClass::OnClose();
|
||||
|
||||
vgui::surface()->RestrictPaintToSinglePanel(NULL);
|
||||
GameUI().AllowEngineHideGameUI();
|
||||
|
||||
// Bring up the post dialog
|
||||
DHANDLE<CPostCommentaryDialog> hPostCommentaryDialog;
|
||||
if ( !hPostCommentaryDialog.Get() )
|
||||
{
|
||||
hPostCommentaryDialog = new CPostCommentaryDialog( BasePanel() );
|
||||
}
|
||||
hPostCommentaryDialog->Activate();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *command -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCommentaryDialog::OnCommand( const char *command )
|
||||
{
|
||||
if ( !Q_stricmp( command, "TurnOn" ) )
|
||||
{
|
||||
ConVarRef commentary("commentary");
|
||||
commentary.SetValue( 1 );
|
||||
Close();
|
||||
}
|
||||
else if ( !Q_stricmp( command, "TurnOff" ) )
|
||||
{
|
||||
ConVarRef commentary("commentary");
|
||||
commentary.SetValue( 0 );
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnCommand( command );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCommentaryDialog::OnKeyCodePressed(KeyCode code)
|
||||
{
|
||||
// Ignore escape key
|
||||
if (code == KEY_ESCAPE)
|
||||
return;
|
||||
|
||||
BaseClass::OnKeyCodePressed(code);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void OpenCommentaryDialog( void )
|
||||
{
|
||||
DHANDLE<CCommentaryDialog> hCommentaryDialog;
|
||||
if ( !hCommentaryDialog.Get() )
|
||||
{
|
||||
hCommentaryDialog = new CCommentaryDialog( BasePanel() );
|
||||
}
|
||||
|
||||
GameUI().ActivateGameUI();
|
||||
hCommentaryDialog->Activate();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
ConVar commentary_firstrun("commentary_firstrun", "0", FCVAR_ARCHIVE );
|
||||
void CC_CommentaryTestFirstRun( void )
|
||||
{
|
||||
if ( !commentary_firstrun.GetBool() )
|
||||
{
|
||||
commentary_firstrun.SetValue(1);
|
||||
OpenCommentaryDialog();
|
||||
}
|
||||
}
|
||||
static ConCommand commentary_testfirstrun("commentary_testfirstrun", CC_CommentaryTestFirstRun, 0 );
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CPostCommentaryDialog::CPostCommentaryDialog(vgui::Panel *parent) : BaseClass(parent, "PostCommentaryDialog")
|
||||
{
|
||||
SetDeleteSelfOnClose(true);
|
||||
SetSizeable( false );
|
||||
|
||||
input()->SetAppModalSurface(GetVPanel());
|
||||
vgui::surface()->RestrictPaintToSinglePanel(GetVPanel());
|
||||
m_bResetPaintRestrict = false;
|
||||
|
||||
SetTitle("#GameUI_CommentaryDialogTitle", true);
|
||||
|
||||
LoadControlSettings("Resource/PostCommentaryDialog.res");
|
||||
|
||||
MoveToCenterOfScreen();
|
||||
|
||||
bool bCommentaryOn = false;
|
||||
ConVarRef commentary("commentary");
|
||||
if ( commentary.IsValid() )
|
||||
{
|
||||
bCommentaryOn = commentary.GetBool();
|
||||
}
|
||||
|
||||
// Setup the buttons & labels to reflect the current state of the commentary
|
||||
if ( bCommentaryOn )
|
||||
{
|
||||
SetControlString( "PostModeLabel", "#GAMEUI_PostCommentary_ModeLabelOn" );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetControlString( "PostModeLabel", "#GAMEUI_PostCommentary_ModeLabelOff" );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CPostCommentaryDialog::~CPostCommentaryDialog()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CPostCommentaryDialog::OnFinishedClose( void )
|
||||
{
|
||||
BaseClass::OnFinishedClose();
|
||||
|
||||
if ( !m_bResetPaintRestrict )
|
||||
{
|
||||
m_bResetPaintRestrict = true;
|
||||
vgui::surface()->RestrictPaintToSinglePanel(NULL);
|
||||
GameUI().HideGameUI();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CPostCommentaryDialog::OnKeyCodePressed(KeyCode code)
|
||||
{
|
||||
if (code == KEY_ESCAPE)
|
||||
{
|
||||
Close();
|
||||
vgui::surface()->RestrictPaintToSinglePanel(NULL);
|
||||
m_bResetPaintRestrict = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnKeyCodePressed(code);
|
||||
}
|
||||
}
|
||||
54
game/client/cstrike15/gameui/commentarydialog.h
Normal file
54
game/client/cstrike15/gameui/commentarydialog.h
Normal file
@@ -0,0 +1,54 @@
|
||||
//====== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. =======
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef COMMENTARYDIALOG_H
|
||||
#define COMMENTARYDIALOG_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui_controls/Frame.h"
|
||||
#include "utlvector.h"
|
||||
#include <vgui/KeyCode.h>
|
||||
|
||||
class CGameChapterPanel;
|
||||
class CSkillSelectionDialog;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Handles selection of commentary mode on/off
|
||||
//-----------------------------------------------------------------------------
|
||||
class CCommentaryDialog : public vgui::Frame
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CCommentaryDialog, vgui::Frame );
|
||||
|
||||
public:
|
||||
explicit CCommentaryDialog(vgui::Panel *parent);
|
||||
~CCommentaryDialog();
|
||||
|
||||
virtual void OnClose( void );
|
||||
virtual void OnCommand( const char *command );
|
||||
virtual void OnKeyCodePressed(vgui::KeyCode code);
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Small dialog to remind players on method of changing commentary mode
|
||||
//-----------------------------------------------------------------------------
|
||||
class CPostCommentaryDialog : public vgui::Frame
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CPostCommentaryDialog, vgui::Frame );
|
||||
|
||||
public:
|
||||
explicit CPostCommentaryDialog(vgui::Panel *parent);
|
||||
~CPostCommentaryDialog();
|
||||
|
||||
virtual void OnFinishedClose( void );
|
||||
virtual void OnKeyCodePressed(vgui::KeyCode code);
|
||||
|
||||
private:
|
||||
bool m_bResetPaintRestrict;
|
||||
};
|
||||
|
||||
#endif // COMMENTARYDIALOG_H
|
||||
91
game/client/cstrike15/gameui/commentaryexplanationdialog.cpp
Normal file
91
game/client/cstrike15/gameui/commentaryexplanationdialog.cpp
Normal file
@@ -0,0 +1,91 @@
|
||||
//====== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. =======
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#include "commentaryexplanationdialog.h"
|
||||
#include "basepanel.h"
|
||||
#include "convar.h"
|
||||
#include "engineinterface.h"
|
||||
#include "gameui_interface.h"
|
||||
#include "vgui/ISurface.h"
|
||||
#include "vgui/IInput.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CCommentaryExplanationDialog::CCommentaryExplanationDialog(vgui::Panel *parent, char *pszFinishCommand) : BaseClass(parent, "CommentaryExplanationDialog")
|
||||
{
|
||||
SetDeleteSelfOnClose(true);
|
||||
SetSizeable( false );
|
||||
|
||||
input()->SetAppModalSurface(GetVPanel());
|
||||
|
||||
LoadControlSettings("Resource/CommentaryExplanationDialog.res");
|
||||
|
||||
MoveToCenterOfScreen();
|
||||
|
||||
GameUI().PreventEngineHideGameUI();
|
||||
|
||||
// Save off the finish command
|
||||
Q_snprintf( m_pszFinishCommand, sizeof( m_pszFinishCommand ), "%s", pszFinishCommand );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CCommentaryExplanationDialog::~CCommentaryExplanationDialog()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCommentaryExplanationDialog::OnKeyCodePressed(KeyCode code)
|
||||
{
|
||||
if (code == KEY_ESCAPE)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnKeyCodePressed(code);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: handles button commands
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCommentaryExplanationDialog::OnCommand( const char *command )
|
||||
{
|
||||
if ( !stricmp( command, "ok" ) )
|
||||
{
|
||||
Close();
|
||||
BasePanel()->FadeToBlackAndRunEngineCommand( m_pszFinishCommand );
|
||||
}
|
||||
else if ( !stricmp( command, "cancel" ) || !stricmp( command, "close" ) )
|
||||
{
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnCommand( command );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCommentaryExplanationDialog::OnClose( void )
|
||||
{
|
||||
BaseClass::OnClose();
|
||||
GameUI().AllowEngineHideGameUI();
|
||||
}
|
||||
36
game/client/cstrike15/gameui/commentaryexplanationdialog.h
Normal file
36
game/client/cstrike15/gameui/commentaryexplanationdialog.h
Normal file
@@ -0,0 +1,36 @@
|
||||
//====== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. =======
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef COMMENTARYEXPLANATIONDIALOG_H
|
||||
#define COMMENTARYEXPLANATIONDIALOG_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui_controls/Frame.h"
|
||||
#include "utlvector.h"
|
||||
#include <vgui/KeyCode.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Dialog that explains the commentary mode
|
||||
//-----------------------------------------------------------------------------
|
||||
class CCommentaryExplanationDialog : public vgui::Frame
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CCommentaryExplanationDialog, vgui::Frame );
|
||||
|
||||
public:
|
||||
CCommentaryExplanationDialog(vgui::Panel *parent, char *pszFinishCommand);
|
||||
~CCommentaryExplanationDialog();
|
||||
|
||||
virtual void OnKeyCodePressed(vgui::KeyCode code);
|
||||
virtual void OnCommand( const char *command );
|
||||
virtual void OnClose( void );
|
||||
|
||||
private:
|
||||
char m_pszFinishCommand[ 512 ];
|
||||
};
|
||||
|
||||
#endif // COMMENTARYEXPLANATIONDIALOG_H
|
||||
407
game/client/cstrike15/gameui/contentcontroldialog.cpp
Normal file
407
game/client/cstrike15/gameui/contentcontroldialog.cpp
Normal file
@@ -0,0 +1,407 @@
|
||||
//========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
// dgoodenough - memory.h doesn't exist on PS3
|
||||
// PS3_BUILDFIX
|
||||
#if !defined( _PS3 )
|
||||
#include <memory.h>
|
||||
#endif
|
||||
#if !defined( _GAMECONSOLE ) && !defined( _OSX ) && !defined (LINUX)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "contentcontroldialog.h"
|
||||
#include "checksum_md5.h"
|
||||
#include "engineinterface.h"
|
||||
|
||||
#include <vgui/IInput.h>
|
||||
#include <vgui/ISystem.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include "tier1/keyvalues.h"
|
||||
#include "tier1/convar.h"
|
||||
|
||||
#include <vgui_controls/Button.h>
|
||||
#include <vgui_controls/CheckButton.h>
|
||||
#include <vgui_controls/Label.h>
|
||||
#include <vgui_controls/RadioButton.h>
|
||||
#include <vgui_controls/TextEntry.h>
|
||||
|
||||
// dgoodenough - select correct stub header based on console
|
||||
// PS3_BUILDFIX
|
||||
#if defined( _PS3 )
|
||||
#include "ps3/ps3_win32stubs.h"
|
||||
#endif
|
||||
#if defined( _X360 )
|
||||
#include "xbox/xbox_win32stubs.h"
|
||||
#endif
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Basic help dialog
|
||||
//-----------------------------------------------------------------------------
|
||||
CContentControlDialog::CContentControlDialog(vgui::Panel *parent) : vgui::Frame(parent, "ContentControlDialog")
|
||||
{
|
||||
SetBounds(0, 0, 372, 160);
|
||||
SetSizeable( false );
|
||||
|
||||
SetTitle( "#GameUI_ContentLock", true );
|
||||
|
||||
m_pStatus = new vgui::Label( this, "ContentStatus", "" );
|
||||
|
||||
m_pPasswordLabel = new vgui::Label( this, "PasswordPrompt", "#GameUI_PasswordPrompt" );
|
||||
m_pPassword2Label = new vgui::Label( this, "PasswordReentryPrompt", "#GameUI_PasswordReentryPrompt" );
|
||||
|
||||
m_pExplain = new vgui::Label( this, "ContentControlExplain", "" );
|
||||
|
||||
m_pPassword = new vgui::TextEntry( this, "Password" );
|
||||
m_pPassword2 = new vgui::TextEntry( this, "Password2" );
|
||||
|
||||
m_pOK = new vgui::Button( this, "Ok", "#GameUI_OK" );
|
||||
m_pOK->SetCommand( "Ok" );
|
||||
|
||||
vgui::Button *cancel = new vgui::Button( this, "Cancel", "#GameUI_Cancel" );
|
||||
cancel->SetCommand( "Cancel" );
|
||||
|
||||
m_szGorePW[ 0 ] = 0;
|
||||
ResetPassword();
|
||||
|
||||
LoadControlSettings("Resource\\ContentControlDialog.res");
|
||||
|
||||
// Explain("");
|
||||
// UpdateContentControlStatus();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CContentControlDialog::~CContentControlDialog()
|
||||
{
|
||||
}
|
||||
|
||||
void CContentControlDialog::Activate()
|
||||
{
|
||||
BaseClass::Activate();
|
||||
|
||||
m_pPassword->SetText("");
|
||||
m_pPassword->RequestFocus();
|
||||
m_pPassword2->SetText("");
|
||||
Explain("");
|
||||
UpdateContentControlStatus();
|
||||
|
||||
input()->SetAppModalSurface(GetVPanel());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CContentControlDialog::ResetPassword()
|
||||
{
|
||||
#if !defined( _OSX ) && !defined (LINUX)
|
||||
// Set initial value
|
||||
HKEY key;
|
||||
if ( ERROR_SUCCESS == RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Valve\\Half-Life\\Settings", 0, KEY_READ, &key))
|
||||
{
|
||||
DWORD type;
|
||||
DWORD bufSize = sizeof(m_szGorePW);
|
||||
|
||||
RegQueryValueEx(key, "User Token 2", NULL, &type, (unsigned char *)m_szGorePW, &bufSize );
|
||||
RegCloseKey( key );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_szGorePW[ 0 ] = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CContentControlDialog::ApplyPassword()
|
||||
{
|
||||
WriteToken( m_szGorePW );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CContentControlDialog::Explain( PRINTF_FORMAT_STRING char const *fmt, ... )
|
||||
{
|
||||
if ( !m_pExplain )
|
||||
return;
|
||||
|
||||
va_list argptr;
|
||||
char text[1024];
|
||||
|
||||
va_start (argptr,fmt);
|
||||
Q_vsnprintf (text, sizeof(text), fmt, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
m_pExplain->SetText( text );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *command -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CContentControlDialog::OnCommand( const char *command )
|
||||
{
|
||||
if ( !stricmp( command, "Ok" ) )
|
||||
{
|
||||
bool canclose = false;
|
||||
|
||||
char pw1[ 256 ];
|
||||
char pw2[ 256 ];
|
||||
|
||||
m_pPassword->GetText( pw1, 256 );
|
||||
m_pPassword2->GetText( pw2, 256 );
|
||||
|
||||
// Get text and check
|
||||
// bool enabled = PasswordEnabled(); //( m_szGorePW[0]!=0 ) ? true : false;
|
||||
// bool pwMatch = stricmp( pw1, pw2 ) == 0 ? true : false;
|
||||
|
||||
if (IsPasswordEnabledInDialog())
|
||||
{
|
||||
canclose = DisablePassword(pw1);
|
||||
// canclose = CheckPassword( m_szGorePW, pw1, false );
|
||||
}
|
||||
else if (!strcmp(pw1, pw2))
|
||||
{
|
||||
canclose = EnablePassword(pw1);
|
||||
// canclose = CheckPassword( NULL, pw1, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
Explain( "#GameUI_PasswordsDontMatch" );
|
||||
}
|
||||
|
||||
if ( canclose )
|
||||
{
|
||||
OnClose();
|
||||
}
|
||||
}
|
||||
else if ( !stricmp( command, "Cancel" ) )
|
||||
{
|
||||
OnClose();
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnCommand( command );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CContentControlDialog::OnClose()
|
||||
{
|
||||
BaseClass::OnClose();
|
||||
PostActionSignal(new KeyValues("ContentControlClose"));
|
||||
// MarkForDeletion();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CContentControlDialog::WriteToken( const char *str )
|
||||
{
|
||||
#if !defined( _OSX ) && !defined (LINUX)
|
||||
// Set initial value
|
||||
HKEY key;
|
||||
if ( ERROR_SUCCESS == RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Valve\\Half-Life\\Settings", 0, KEY_WRITE, &key))
|
||||
{
|
||||
DWORD type = REG_SZ;
|
||||
DWORD bufSize = strlen( str ) + 1;
|
||||
|
||||
RegSetValueEx(key, "User Token 2", 0, type, (const unsigned char *)str, bufSize );
|
||||
|
||||
RegCloseKey( key );
|
||||
}
|
||||
|
||||
Q_strncpy( m_szGorePW, str, sizeof( m_szGorePW ) );
|
||||
|
||||
UpdateContentControlStatus();
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CContentControlDialog::HashPassword(const char *newPW, char *hashBuffer, int maxlen )
|
||||
{
|
||||
// Compute the md5 hash and save it.
|
||||
unsigned char md5_hash[16];
|
||||
MD5Context_t ctx;
|
||||
|
||||
MD5Init( &ctx );
|
||||
MD5Update( &ctx, (unsigned char const *)newPW, strlen( newPW ) );
|
||||
MD5Final( md5_hash, &ctx );
|
||||
|
||||
char hex[ 128 ];
|
||||
Q_binarytohex( md5_hash, sizeof( md5_hash ), hex, sizeof( hex ) );
|
||||
|
||||
// char digestedPW[ 128 ];
|
||||
Q_strncpy( hashBuffer, hex, maxlen );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
/*
|
||||
bool CContentControlDialog::CheckPassword( char const *oldPW, char const *newPW, bool enableContentControl )
|
||||
{
|
||||
char digestedPW[ 128 ];
|
||||
HashPassword(newPW, digestedPW, sizeof( digestedPW ) );
|
||||
|
||||
// Compute the md5 hash and save it.
|
||||
unsigned char md5_hash[16];
|
||||
MD5Context_t ctx;
|
||||
|
||||
MD5Init( &ctx );
|
||||
MD5Update( &ctx, (unsigned char const *)(LPCSTR)newPW, strlen( newPW ) );
|
||||
MD5Final( md5_hash, &ctx );
|
||||
|
||||
char hex[ 128 ];
|
||||
Q_binarytohex( md5_hash, sizeof( md5_hash ), hex, sizeof( hex ) );
|
||||
|
||||
Q_strncpy( digestedPW, hex, sizeof( digestedPW ) );
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CContentControlDialog::EnablePassword(const char *newPW)
|
||||
{
|
||||
if ( !newPW[ 0 ] )
|
||||
{
|
||||
Explain( "#GameUI_MustEnterPassword" );
|
||||
return false;
|
||||
}
|
||||
|
||||
char digestedPW[ 128 ];
|
||||
HashPassword(newPW, digestedPW, sizeof( digestedPW ) );
|
||||
|
||||
// disable violence
|
||||
/* engine->Cvar_SetValue("violence_hblood", 0.0 );
|
||||
engine->Cvar_SetValue("violence_hgibs" , 0.0 );
|
||||
engine->Cvar_SetValue("violence_ablood", 0.0 );
|
||||
engine->Cvar_SetValue("violence_agibs" , 0.0 );
|
||||
*/
|
||||
|
||||
ConVarRef violence_hblood( "violence_hblood" );
|
||||
violence_hblood.SetValue(false);
|
||||
|
||||
ConVarRef violence_hgibs( "violence_hgibs" );
|
||||
violence_hgibs.SetValue(false);
|
||||
|
||||
ConVarRef violence_ablood( "violence_ablood" );
|
||||
violence_ablood.SetValue(false);
|
||||
|
||||
ConVarRef violence_agibs( "violence_agibs" );
|
||||
violence_agibs.SetValue(false);
|
||||
|
||||
// Store digest to registry
|
||||
// WriteToken( digestedPW );
|
||||
Q_strncpy(m_szGorePW, digestedPW, sizeof( m_szGorePW ) );
|
||||
/*
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( stricmp( oldPW, digestedPW ) )
|
||||
{
|
||||
// Warn that password is invalid
|
||||
Explain( "#GameUI_IncorrectPassword" );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CContentControlDialog::DisablePassword(const char *oldPW)
|
||||
{
|
||||
if ( !oldPW[ 0 ] )
|
||||
{
|
||||
Explain( "#GameUI_MustEnterPassword" );
|
||||
return false;
|
||||
}
|
||||
|
||||
char digestedPW[ 128 ];
|
||||
HashPassword(oldPW, digestedPW, sizeof( digestedPW ) );
|
||||
|
||||
if( stricmp( m_szGorePW, digestedPW ) )
|
||||
{
|
||||
Explain( "#GameUI_IncorrectPassword" );
|
||||
return false;
|
||||
}
|
||||
|
||||
m_szGorePW[0] = 0;
|
||||
|
||||
// set the violence cvars
|
||||
/* engine->Cvar_SetValue("violence_hblood", 1.0 );
|
||||
engine->Cvar_SetValue("violence_hgibs" , 1.0 );
|
||||
engine->Cvar_SetValue("violence_ablood", 1.0 );
|
||||
engine->Cvar_SetValue("violence_agibs" , 1.0 );
|
||||
*/
|
||||
ConVarRef violence_hblood( "violence_hblood" );
|
||||
violence_hblood.SetValue(true);
|
||||
|
||||
ConVarRef violence_hgibs( "violence_hgibs" );
|
||||
violence_hgibs.SetValue(true);
|
||||
|
||||
ConVarRef violence_ablood( "violence_ablood" );
|
||||
violence_ablood.SetValue(true);
|
||||
|
||||
ConVarRef violence_agibs( "violence_agibs" );
|
||||
violence_agibs.SetValue(true);
|
||||
|
||||
|
||||
// // Remove digest value
|
||||
// WriteToken( "" );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CContentControlDialog::IsPasswordEnabledInDialog()
|
||||
{
|
||||
return m_szGorePW[0] != 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CContentControlDialog::UpdateContentControlStatus( void )
|
||||
{
|
||||
bool enabled = IsPasswordEnabledInDialog(); //( m_szGorePW[0]!=0 ) ? true : false;
|
||||
m_pStatus->SetText( enabled ? "#GameUI_ContentStatusEnabled" : "#GameUI_ContentStatusDisabled" );
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
m_pPasswordLabel->SetText("#GameUI_PasswordDisablePrompt");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pPasswordLabel->SetText("#GameUI_PasswordPrompt");
|
||||
}
|
||||
|
||||
// hide the re-entry
|
||||
m_pPassword2Label->SetVisible(!enabled);
|
||||
m_pPassword2->SetVisible(!enabled);
|
||||
// m_pOK->SetText( enabled ? "#GameUI_Disable" : "#GameUI_Enable" );
|
||||
}
|
||||
66
game/client/cstrike15/gameui/contentcontroldialog.h
Normal file
66
game/client/cstrike15/gameui/contentcontroldialog.h
Normal file
@@ -0,0 +1,66 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CONTENTCONTROLDIALOG_H
|
||||
#define CONTENTCONTROLDIALOG_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui_controls/Frame.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CContentControlDialog : public vgui::Frame
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CContentControlDialog, vgui::Frame );
|
||||
|
||||
public:
|
||||
explicit CContentControlDialog(vgui::Panel *parent);
|
||||
~CContentControlDialog();
|
||||
|
||||
virtual void OnCommand( const char *command );
|
||||
virtual void OnClose();
|
||||
virtual void Activate();
|
||||
|
||||
void ResetPassword();
|
||||
void ApplyPassword();
|
||||
bool IsPasswordEnabledInDialog();
|
||||
bool IsPasswordEnabled() { return ( m_szGorePW[0] != 0 ); }
|
||||
|
||||
protected:
|
||||
void WriteToken( const char *str );
|
||||
bool CheckPassword( char const *oldPW, char const *newPW, bool enableContentControl );
|
||||
void UpdateContentControlStatus( void );
|
||||
|
||||
void Explain( PRINTF_FORMAT_STRING char const *fmt, ... );
|
||||
|
||||
void HashPassword(const char *newPW, char *hashBuffer, int maxlen );
|
||||
bool EnablePassword(const char *newPW);
|
||||
bool DisablePassword(const char *oldPW);
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_GORE_PW = 64,
|
||||
};
|
||||
|
||||
char m_szGorePW[ MAX_GORE_PW ];
|
||||
|
||||
bool m_bDefaultPassword;
|
||||
vgui::Label *m_pStatus;
|
||||
vgui::Button *m_pOK;
|
||||
vgui::TextEntry *m_pPassword;
|
||||
vgui::Label *m_pPasswordLabel;
|
||||
vgui::Label *m_pPassword2Label;
|
||||
vgui::TextEntry *m_pPassword2;
|
||||
|
||||
vgui::Label *m_pExplain;
|
||||
};
|
||||
|
||||
|
||||
#endif // CONTENTCONTROLDIALOG_H
|
||||
227
game/client/cstrike15/gameui/createmultiplayergamebotpage.cpp
Normal file
227
game/client/cstrike15/gameui/createmultiplayergamebotpage.cpp
Normal file
@@ -0,0 +1,227 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "createmultiplayergamebotpage.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
#include <keyvalues.h>
|
||||
#include <vgui_controls/ComboBox.h>
|
||||
#include <vgui_controls/CheckButton.h>
|
||||
#include <vgui_controls/Label.h>
|
||||
#include <vgui_controls/TextEntry.h>
|
||||
|
||||
#include "filesystem.h"
|
||||
#include "panellistpanel.h"
|
||||
#include "scriptobject.h"
|
||||
#include "tier1/convar.h"
|
||||
#include "engineinterface.h"
|
||||
#include "cvartogglecheckbutton.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
// for join team combo box
|
||||
enum BotGUITeamType
|
||||
{
|
||||
BOT_GUI_TEAM_RANDOM = 0,
|
||||
BOT_GUI_TEAM_CT = 1,
|
||||
BOT_GUI_TEAM_T = 2
|
||||
};
|
||||
|
||||
// these must correlate with above enum
|
||||
static const char *joinTeamArg[] = { "any", "ct", "t", NULL };
|
||||
|
||||
|
||||
// for bot chatter combo box
|
||||
enum BotGUIChatterType
|
||||
{
|
||||
BOT_GUI_CHATTER_NORMAL = 0,
|
||||
BOT_GUI_CHATTER_MINIMAL = 1,
|
||||
BOT_GUI_CHATTER_RADIO = 2,
|
||||
BOT_GUI_CHATTER_OFF = 3
|
||||
};
|
||||
|
||||
// these must correlate with above enum
|
||||
static const char *chatterArg[] = { "normal", "minimal", "radio", "off", NULL };
|
||||
|
||||
|
||||
extern void UTIL_StripInvalidCharacters( char *pszInput );
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCreateMultiplayerGameBotPage::SetJoinTeamCombo( const char *team )
|
||||
{
|
||||
if (team)
|
||||
{
|
||||
for( int i=0; joinTeamArg[i]; ++i )
|
||||
if (!stricmp( team, joinTeamArg[i] ))
|
||||
{
|
||||
m_joinTeamCombo->ActivateItemByRow( i );
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_joinTeamCombo->ActivateItemByRow( BOT_GUI_TEAM_RANDOM );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCreateMultiplayerGameBotPage::SetChatterCombo( const char *chatter )
|
||||
{
|
||||
if (chatter)
|
||||
{
|
||||
for( int i=0; chatterArg[i]; ++i )
|
||||
if (!stricmp( chatter, chatterArg[i] ))
|
||||
{
|
||||
m_chatterCombo->ActivateItemByRow( i );
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_joinTeamCombo->ActivateItemByRow( BOT_GUI_CHATTER_NORMAL );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CCreateMultiplayerGameBotPage::CCreateMultiplayerGameBotPage( vgui::Panel *parent, const char *name, KeyValues *botKeys ) : PropertyPage( parent, name )
|
||||
{
|
||||
m_pSavedData = botKeys;
|
||||
|
||||
m_allowRogues = new CCvarToggleCheckButton( this, "BotAllowRogueCheck", "", "bot_allow_rogues" );
|
||||
m_allowPistols = new CCvarToggleCheckButton( this, "BotAllowPistolsCheck", "", "bot_allow_pistols" );
|
||||
m_allowShotguns = new CCvarToggleCheckButton( this, "BotAllowShotgunsCheck", "", "bot_allow_shotguns" );
|
||||
m_allowSubmachineGuns = new CCvarToggleCheckButton( this, "BotAllowSubmachineGunsCheck", "", "bot_allow_sub_machine_guns" );
|
||||
m_allowRifles = new CCvarToggleCheckButton( this, "BotAllowRiflesCheck", "", "bot_allow_rifles" );
|
||||
m_allowMachineGuns = new CCvarToggleCheckButton( this, "BotAllowMachineGunsCheck", "", "bot_allow_machine_guns" );
|
||||
m_allowGrenades = new CCvarToggleCheckButton( this, "BotAllowGrenadesCheck", "", "bot_allow_grenades" );
|
||||
m_allowSnipers = new CCvarToggleCheckButton( this, "BotAllowSnipersCheck", "", "bot_allow_snipers" );
|
||||
#ifdef CS_SHIELD_ENABLED
|
||||
m_allowShields = new CCvarToggleCheckButton( this, "BotAllowShieldCheck", "", "bot_allow_shield" );
|
||||
#endif // CS_SHIELD_ENABLED
|
||||
|
||||
m_joinAfterPlayer = new CCvarToggleCheckButton( this, "BotJoinAfterPlayerCheck", "", "bot_join_after_player" );
|
||||
|
||||
m_deferToHuman = new CCvarToggleCheckButton( this, "BotDeferToHumanCheck", "", "bot_defer_to_human_goals" );
|
||||
|
||||
// set up team join combo box
|
||||
// NOTE: If order of AddItem is changed, update the associated enum
|
||||
m_joinTeamCombo = new ComboBox( this, "BotJoinTeamCombo", 3, false );
|
||||
m_joinTeamCombo->AddItem( "#Cstrike_Random", NULL );
|
||||
m_joinTeamCombo->AddItem( "#Cstrike_ScoreBoard_CT", NULL );
|
||||
m_joinTeamCombo->AddItem( "#Cstrike_ScoreBoard_Ter", NULL );
|
||||
|
||||
// set up chatter combo box
|
||||
// NOTE: If order of AddItem is changed, update the associated enum
|
||||
m_chatterCombo = new ComboBox( this, "BotChatterCombo", 4, false );
|
||||
m_chatterCombo->AddItem( "#Cstrike_Bot_Chatter_Normal", NULL );
|
||||
m_chatterCombo->AddItem( "#Cstrike_Bot_Chatter_Minimal", NULL );
|
||||
m_chatterCombo->AddItem( "#Cstrike_Bot_Chatter_Radio", NULL );
|
||||
m_chatterCombo->AddItem( "#Cstrike_Bot_Chatter_Off", NULL );
|
||||
|
||||
// create text entry fields for quota and prefix
|
||||
m_prefixEntry = new TextEntry( this, "BotPrefixEntry" );
|
||||
|
||||
// set positions and sizes from resources file
|
||||
LoadControlSettings( "Resource/CreateMultiplayerGameBotPage.res" );
|
||||
|
||||
// get initial values from bot keys
|
||||
m_joinAfterPlayer->SetSelected( botKeys->GetBool( "bot_join_after_player", true ) );
|
||||
m_allowRogues->SetSelected( botKeys->GetBool( "bot_allow_rogues", true ) );
|
||||
m_allowPistols->SetSelected( botKeys->GetBool( "bot_allow_pistols", true ) );
|
||||
m_allowShotguns->SetSelected( botKeys->GetBool( "bot_allow_shotguns", true ) );
|
||||
m_allowSubmachineGuns->SetSelected( botKeys->GetBool( "bot_allow_sub_machine_guns", true ) );
|
||||
m_allowMachineGuns->SetSelected( botKeys->GetBool( "bot_allow_machine_guns", true ) );
|
||||
m_allowRifles->SetSelected( botKeys->GetBool( "bot_allow_rifles", true ) );
|
||||
m_allowSnipers->SetSelected( botKeys->GetBool( "bot_allow_snipers", true ) );
|
||||
m_allowGrenades->SetSelected( botKeys->GetBool( "bot_allow_grenades", true ) );
|
||||
#ifdef CS_SHIELD_ENABLED
|
||||
m_allowShields->SetSelected( botKeys->GetBool( "bot_allow_shield", true ) );
|
||||
#endif // CS_SHIELD_ENABLED
|
||||
m_deferToHuman->SetSelected( botKeys->GetBool( "bot_defer_to_human_goals", true ) );
|
||||
|
||||
SetJoinTeamCombo( botKeys->GetString( "bot_join_team", "any" ) );
|
||||
SetChatterCombo( botKeys->GetString( "bot_chatter", "normal" ) );
|
||||
|
||||
// set bot_prefix
|
||||
const char *prefix = botKeys->GetString( "bot_prefix" );
|
||||
if (prefix)
|
||||
SetControlString( "BotPrefixEntry", prefix );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CCreateMultiplayerGameBotPage::~CCreateMultiplayerGameBotPage()
|
||||
{
|
||||
// vgui handles deletion of children automatically through the hierarchy
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Reset values
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCreateMultiplayerGameBotPage::OnResetChanges()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
void UpdateValue( KeyValues *data, const char *cvarName, int value )
|
||||
{
|
||||
data->SetInt( cvarName, value );
|
||||
|
||||
ConVarRef var( cvarName );
|
||||
var.SetValue( value );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
void UpdateValue( KeyValues *data, const char *cvarName, const char *value )
|
||||
{
|
||||
data->SetString( cvarName, value );
|
||||
|
||||
ConVarRef var( cvarName );
|
||||
var.SetValue( value );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Called to get data from the page
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCreateMultiplayerGameBotPage::OnApplyChanges()
|
||||
{
|
||||
UpdateValue( m_pSavedData, "bot_join_after_player", m_joinAfterPlayer->IsSelected() );
|
||||
UpdateValue( m_pSavedData, "bot_allow_rogues", m_allowRogues->IsSelected() );
|
||||
UpdateValue( m_pSavedData, "bot_allow_pistols", m_allowPistols->IsSelected() );
|
||||
UpdateValue( m_pSavedData, "bot_allow_shotguns", m_allowShotguns->IsSelected() );
|
||||
UpdateValue( m_pSavedData, "bot_allow_sub_machine_guns", m_allowSubmachineGuns->IsSelected() );
|
||||
UpdateValue( m_pSavedData, "bot_allow_machine_guns", m_allowMachineGuns->IsSelected() );
|
||||
UpdateValue( m_pSavedData, "bot_allow_rifles", m_allowRifles->IsSelected() );
|
||||
UpdateValue( m_pSavedData, "bot_allow_snipers", m_allowSnipers->IsSelected() );
|
||||
UpdateValue( m_pSavedData, "bot_allow_grenades", m_allowGrenades->IsSelected() );
|
||||
#ifdef CS_SHIELD_ENABLED
|
||||
UpdateValue( m_pSavedData, "bot_allow_shield", m_allowShields->IsSelected() );
|
||||
#endif // CS_SHIELD_ENABLED
|
||||
UpdateValue( m_pSavedData, "bot_defer_to_human_goals", m_deferToHuman->IsSelected() );
|
||||
|
||||
// set bot_join_team
|
||||
UpdateValue( m_pSavedData, "bot_join_team", joinTeamArg[ m_joinTeamCombo->GetActiveItem() ] );
|
||||
|
||||
// set bot_chatter
|
||||
UpdateValue( m_pSavedData, "bot_chatter", chatterArg[ m_chatterCombo->GetActiveItem() ] );
|
||||
|
||||
// set bot_prefix
|
||||
#define BUF_LENGTH 256
|
||||
char entryBuffer[ BUF_LENGTH ];
|
||||
m_prefixEntry->GetText( entryBuffer, BUF_LENGTH );
|
||||
UpdateValue( m_pSavedData, "bot_prefix", entryBuffer );
|
||||
}
|
||||
|
||||
66
game/client/cstrike15/gameui/createmultiplayergamebotpage.h
Normal file
66
game/client/cstrike15/gameui/createmultiplayergamebotpage.h
Normal file
@@ -0,0 +1,66 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CREATEMULTIPLAYERGAMEBOTPAGE_H
|
||||
#define CREATEMULTIPLAYERGAMEBOTPAGE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui_controls/PropertyPage.h>
|
||||
|
||||
class CPanelListPanel;
|
||||
class CDescription;
|
||||
class mpcontrol_t;
|
||||
class CCvarToggleCheckButton;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: advanced bot properties page of the create game server dialog
|
||||
//-----------------------------------------------------------------------------
|
||||
class CCreateMultiplayerGameBotPage : public vgui::PropertyPage
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CCreateMultiplayerGameBotPage, vgui::PropertyPage );
|
||||
|
||||
public:
|
||||
CCreateMultiplayerGameBotPage( vgui::Panel *parent, const char *name, KeyValues *botKeys );
|
||||
~CCreateMultiplayerGameBotPage();
|
||||
|
||||
protected:
|
||||
virtual void OnResetChanges();
|
||||
virtual void OnApplyChanges();
|
||||
|
||||
private:
|
||||
CCvarToggleCheckButton *m_joinAfterPlayer;
|
||||
|
||||
CCvarToggleCheckButton *m_allowRogues;
|
||||
|
||||
CCvarToggleCheckButton *m_allowPistols;
|
||||
CCvarToggleCheckButton *m_allowShotguns;
|
||||
CCvarToggleCheckButton *m_allowSubmachineGuns;
|
||||
CCvarToggleCheckButton *m_allowMachineGuns;
|
||||
CCvarToggleCheckButton *m_allowRifles;
|
||||
CCvarToggleCheckButton *m_allowGrenades;
|
||||
#ifdef CS_SHIELD_ENABLED
|
||||
CCvarToggleCheckButton *m_allowShields;
|
||||
#endif // CS_SHIELD_ENABLED
|
||||
CCvarToggleCheckButton *m_allowSnipers;
|
||||
|
||||
CCvarToggleCheckButton *m_deferToHuman;
|
||||
|
||||
vgui::ComboBox *m_joinTeamCombo;
|
||||
void SetJoinTeamCombo( const char *team );
|
||||
|
||||
vgui::ComboBox *m_chatterCombo;
|
||||
void SetChatterCombo( const char *team );
|
||||
|
||||
vgui::TextEntry *m_prefixEntry;
|
||||
|
||||
KeyValues *m_pSavedData;
|
||||
};
|
||||
|
||||
|
||||
#endif // CREATEMULTIPLAYERGAMEBOTPAGE_H
|
||||
144
game/client/cstrike15/gameui/createmultiplayergamedialog.cpp
Normal file
144
game/client/cstrike15/gameui/createmultiplayergamedialog.cpp
Normal file
@@ -0,0 +1,144 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "createmultiplayergamedialog.h"
|
||||
#include "createmultiplayergameserverpage.h"
|
||||
#include "createmultiplayergamegameplaypage.h"
|
||||
#include "createmultiplayergamebotpage.h"
|
||||
|
||||
#include "engineinterface.h"
|
||||
#include "modinfo.h"
|
||||
#include "gameui_interface.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
#include <vgui/ILocalize.h>
|
||||
|
||||
#include "filesystem.h"
|
||||
#include <keyvalues.h>
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CCreateMultiplayerGameDialog::CCreateMultiplayerGameDialog(vgui::Panel *parent) : PropertyDialog(parent, "CreateMultiplayerGameDialog")
|
||||
{
|
||||
m_bBotsEnabled = false;
|
||||
SetDeleteSelfOnClose(true);
|
||||
SetSize(348, 460);
|
||||
|
||||
SetTitle("#GameUI_CreateServer", true);
|
||||
SetOKButtonText("#GameUI_Start");
|
||||
|
||||
if (!stricmp( ModInfo().GetGameName(), "Counter-Strike Source" ))
|
||||
{
|
||||
m_bBotsEnabled = true;
|
||||
}
|
||||
|
||||
m_pServerPage = new CCreateMultiplayerGameServerPage(this, "ServerPage");
|
||||
m_pGameplayPage = new CCreateMultiplayerGameGameplayPage(this, "GameplayPage");
|
||||
m_pBotPage = NULL;
|
||||
|
||||
AddPage(m_pServerPage, "#GameUI_Server");
|
||||
AddPage(m_pGameplayPage, "#GameUI_Game");
|
||||
|
||||
// create KeyValues object to load/save config options
|
||||
m_pSavedData = new KeyValues( "ServerConfig" );
|
||||
|
||||
// load the config data
|
||||
if (m_pSavedData)
|
||||
{
|
||||
m_pSavedData->LoadFromFile( g_pFullFileSystem, "ServerConfig.vdf", "GAME" ); // this is game-specific data, so it should live in GAME, not CONFIG
|
||||
|
||||
const char *startMap = m_pSavedData->GetString("map", "");
|
||||
if (startMap[0])
|
||||
{
|
||||
m_pServerPage->SetMap(startMap);
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_bBotsEnabled )
|
||||
{
|
||||
// add a page of advanced bot controls
|
||||
// NOTE: These controls will use the bot keys to initialize their values
|
||||
m_pBotPage = new CCreateMultiplayerGameBotPage( this, "BotPage", m_pSavedData );
|
||||
AddPage( m_pBotPage, "#GameUI_CPUPlayerOptions" );
|
||||
m_pServerPage->EnableBots( m_pSavedData );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CCreateMultiplayerGameDialog::~CCreateMultiplayerGameDialog()
|
||||
{
|
||||
if (m_pSavedData)
|
||||
{
|
||||
m_pSavedData->deleteThis();
|
||||
m_pSavedData = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: runs the server when the OK button is pressed
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CCreateMultiplayerGameDialog::OnOK(bool applyOnly)
|
||||
{
|
||||
// reset server enforced cvars
|
||||
g_pCVar->RevertFlaggedConVars( FCVAR_REPLICATED );
|
||||
|
||||
// Cheats were disabled; revert all cheat cvars to their default values.
|
||||
// This must be done heading into multiplayer games because people can play
|
||||
// demos etc and set cheat cvars with sv_cheats 0.
|
||||
g_pCVar->RevertFlaggedConVars( FCVAR_CHEAT );
|
||||
|
||||
DevMsg( "FCVAR_CHEAT cvars reverted to defaults.\n" );
|
||||
|
||||
BaseClass::OnOK(applyOnly);
|
||||
|
||||
// get these values from m_pServerPage and store them temporarily
|
||||
char szMapName[64], szHostName[64], szPassword[64];
|
||||
Q_strncpy(szMapName, m_pServerPage->GetMapName(), sizeof( szMapName ));
|
||||
Q_strncpy(szHostName, m_pGameplayPage->GetHostName(), sizeof( szHostName ));
|
||||
Q_strncpy(szPassword, m_pGameplayPage->GetPassword(), sizeof( szPassword ));
|
||||
|
||||
// save the config data
|
||||
if (m_pSavedData)
|
||||
{
|
||||
if (m_pServerPage->IsRandomMapSelected())
|
||||
{
|
||||
// it's set to random map, just save an
|
||||
m_pSavedData->SetString("map", "");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pSavedData->SetString("map", szMapName);
|
||||
}
|
||||
|
||||
// save config to a file
|
||||
m_pSavedData->SaveToFile( g_pFullFileSystem, "ServerConfig.vdf", "GAME" );
|
||||
}
|
||||
|
||||
char szMapCommand[1024];
|
||||
|
||||
// create the command to execute
|
||||
Q_snprintf(szMapCommand, sizeof( szMapCommand ), "disconnect\nwait\nwait\nsv_lan 1\nsetmaster enable\nmaxplayers %i\nsv_password \"%s\"\nhostname \"%s\"\nprogress_enable\nmap %s\n",
|
||||
m_pGameplayPage->GetMaxPlayers(),
|
||||
szPassword,
|
||||
szHostName,
|
||||
szMapName
|
||||
);
|
||||
|
||||
// exec
|
||||
engine->ClientCmd_Unrestricted(szMapCommand);
|
||||
|
||||
return true;
|
||||
}
|
||||
46
game/client/cstrike15/gameui/createmultiplayergamedialog.h
Normal file
46
game/client/cstrike15/gameui/createmultiplayergamedialog.h
Normal file
@@ -0,0 +1,46 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CREATEMULTIPLAYERGAMEDIALOG_H
|
||||
#define CREATEMULTIPLAYERGAMEDIALOG_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui_controls/PropertyDialog.h>
|
||||
|
||||
class CCreateMultiplayerGameServerPage;
|
||||
class CCreateMultiplayerGameGameplayPage;
|
||||
class CCreateMultiplayerGameBotPage;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: dialog for launching a listenserver
|
||||
//-----------------------------------------------------------------------------
|
||||
class CCreateMultiplayerGameDialog : public vgui::PropertyDialog
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CCreateMultiplayerGameDialog, vgui::PropertyDialog );
|
||||
|
||||
public:
|
||||
explicit CCreateMultiplayerGameDialog(vgui::Panel *parent);
|
||||
~CCreateMultiplayerGameDialog();
|
||||
|
||||
protected:
|
||||
virtual bool OnOK(bool applyOnly);
|
||||
|
||||
private:
|
||||
CCreateMultiplayerGameServerPage *m_pServerPage;
|
||||
CCreateMultiplayerGameGameplayPage *m_pGameplayPage;
|
||||
CCreateMultiplayerGameBotPage *m_pBotPage;
|
||||
|
||||
bool m_bBotsEnabled;
|
||||
|
||||
// for loading/saving game config
|
||||
KeyValues *m_pSavedData;
|
||||
};
|
||||
|
||||
|
||||
#endif // CREATEMULTIPLAYERGAMEDIALOG_H
|
||||
@@ -0,0 +1,479 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "createmultiplayergamegameplaypage.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
#include <keyvalues.h>
|
||||
#include <vgui/ILocalize.h>
|
||||
#include <vgui_controls/ComboBox.h>
|
||||
#include <vgui_controls/CheckButton.h>
|
||||
#include <vgui_controls/Label.h>
|
||||
#include <vgui_controls/TextEntry.h>
|
||||
|
||||
#include "filesystem.h"
|
||||
#include "panellistpanel.h"
|
||||
#include "scriptobject.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
#define OPTIONS_DIR "cfg"
|
||||
#define DEFAULT_OPTIONS_FILE OPTIONS_DIR "/settings_default.scr"
|
||||
#define OPTIONS_FILE OPTIONS_DIR "/settings.scr"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: class for loading/saving server config file
|
||||
//-----------------------------------------------------------------------------
|
||||
class CServerDescription : public CDescription
|
||||
{
|
||||
public:
|
||||
explicit CServerDescription( CPanelListPanel *panel );
|
||||
|
||||
void WriteScriptHeader( FileHandle_t fp );
|
||||
void WriteFileHeader( FileHandle_t fp );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CCreateMultiplayerGameGameplayPage::CCreateMultiplayerGameGameplayPage(vgui::Panel *parent, const char *name) : PropertyPage(parent, name)
|
||||
{
|
||||
m_pOptionsList = new CPanelListPanel(this, "GameOptions");
|
||||
|
||||
m_pDescription = new CServerDescription(m_pOptionsList);
|
||||
m_pDescription->InitFromFile( DEFAULT_OPTIONS_FILE );
|
||||
m_pDescription->InitFromFile( OPTIONS_FILE );
|
||||
m_pList = NULL;
|
||||
|
||||
LoadControlSettings("Resource/CreateMultiplayerGameGameplayPage.res");
|
||||
|
||||
LoadGameOptionsList();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CCreateMultiplayerGameGameplayPage::~CCreateMultiplayerGameGameplayPage()
|
||||
{
|
||||
delete m_pDescription;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
int CCreateMultiplayerGameGameplayPage::GetMaxPlayers()
|
||||
{
|
||||
return atoi(GetValue("maxplayers", "32"));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CCreateMultiplayerGameGameplayPage::GetPassword()
|
||||
{
|
||||
return GetValue("sv_password", "");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CCreateMultiplayerGameGameplayPage::GetHostName()
|
||||
{
|
||||
return GetValue("hostname", "Half-Life");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CCreateMultiplayerGameGameplayPage::GetValue(const char *cvarName, const char *defaultValue)
|
||||
{
|
||||
for (mpcontrol_t *mp = m_pList; mp != NULL; mp = mp->next)
|
||||
{
|
||||
Panel *control = mp->pControl;
|
||||
if (control && !stricmp(mp->GetName(), cvarName))
|
||||
{
|
||||
KeyValues *data = new KeyValues("GetText");
|
||||
static char buf[128];
|
||||
if (control && control->RequestInfo(data))
|
||||
{
|
||||
Q_strncpy(buf, data->GetString("text", defaultValue), sizeof(buf) - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// no value found, copy in default text
|
||||
Q_strncpy(buf, defaultValue, sizeof(buf) - 1);
|
||||
}
|
||||
|
||||
// ensure null termination of string
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
|
||||
// free
|
||||
data->deleteThis();
|
||||
return buf;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: called to get data from the page
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCreateMultiplayerGameGameplayPage::OnApplyChanges()
|
||||
{
|
||||
// Get the values from the controls
|
||||
GatherCurrentValues();
|
||||
|
||||
// Create the game.cfg file
|
||||
if ( m_pDescription )
|
||||
{
|
||||
FileHandle_t fp;
|
||||
|
||||
// Add settings to config.cfg
|
||||
m_pDescription->WriteToConfig();
|
||||
|
||||
// save out in the settings file
|
||||
g_pFullFileSystem->CreateDirHierarchy( OPTIONS_DIR, "GAME" );
|
||||
fp = g_pFullFileSystem->Open( OPTIONS_FILE, "wb", "GAME" );
|
||||
if ( fp )
|
||||
{
|
||||
m_pDescription->WriteToScriptFile( fp );
|
||||
g_pFullFileSystem->Close( fp );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Creates all the controls in the game options list
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCreateMultiplayerGameGameplayPage::LoadGameOptionsList()
|
||||
{
|
||||
// destroy any existing controls
|
||||
mpcontrol_t *p, *n;
|
||||
|
||||
p = m_pList;
|
||||
while ( p )
|
||||
{
|
||||
n = p->next;
|
||||
//
|
||||
delete p->pControl;
|
||||
delete p->pPrompt;
|
||||
delete p;
|
||||
p = n;
|
||||
}
|
||||
|
||||
m_pList = NULL;
|
||||
|
||||
|
||||
// Go through desciption creating controls
|
||||
CScriptObject *pObj;
|
||||
|
||||
pObj = m_pDescription->pObjList;
|
||||
|
||||
mpcontrol_t *pCtrl;
|
||||
|
||||
CheckButton *pBox;
|
||||
TextEntry *pEdit;
|
||||
ComboBox *pCombo;
|
||||
CScriptListItem *pListItem;
|
||||
|
||||
Panel *objParent = m_pOptionsList;
|
||||
|
||||
while ( pObj )
|
||||
{
|
||||
if ( pObj->type == O_OBSOLETE )
|
||||
{
|
||||
pObj = pObj->pNext;
|
||||
continue;
|
||||
}
|
||||
|
||||
pCtrl = new mpcontrol_t( objParent, pObj->cvarname );
|
||||
pCtrl->type = pObj->type;
|
||||
|
||||
switch ( pCtrl->type )
|
||||
{
|
||||
case O_BOOL:
|
||||
pBox = new CheckButton( pCtrl, "DescCheckButton", pObj->prompt );
|
||||
pBox->SetSelected( pObj->fdefValue != 0.0f ? true : false );
|
||||
|
||||
pCtrl->pControl = (Panel *)pBox;
|
||||
break;
|
||||
case O_STRING:
|
||||
case O_NUMBER:
|
||||
pEdit = new TextEntry( pCtrl, "DescEdit");
|
||||
pEdit->InsertString(pObj->defValue);
|
||||
pCtrl->pControl = (Panel *)pEdit;
|
||||
break;
|
||||
case O_LIST:
|
||||
pCombo = new ComboBox( pCtrl, "DescEdit", 5, false );
|
||||
|
||||
pListItem = pObj->pListItems;
|
||||
while ( pListItem )
|
||||
{
|
||||
pCombo->AddItem(pListItem->szItemText, NULL);
|
||||
pListItem = pListItem->pNext;
|
||||
}
|
||||
|
||||
pCombo->ActivateItemByRow((int)pObj->fdefValue);
|
||||
|
||||
pCtrl->pControl = (Panel *)pCombo;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if ( pCtrl->type != O_BOOL )
|
||||
{
|
||||
pCtrl->pPrompt = new vgui::Label( pCtrl, "DescLabel", "" );
|
||||
pCtrl->pPrompt->SetContentAlignment( vgui::Label::a_west );
|
||||
pCtrl->pPrompt->SetTextInset( 5, 0 );
|
||||
pCtrl->pPrompt->SetText( pObj->prompt );
|
||||
}
|
||||
|
||||
pCtrl->pScrObj = pObj;
|
||||
pCtrl->SetSize( 100, 28 );
|
||||
//pCtrl->SetBorder( scheme()->GetBorder(1, "DepressedButtonBorder") );
|
||||
m_pOptionsList->AddItem( pCtrl );
|
||||
|
||||
// Link it in
|
||||
if ( !m_pList )
|
||||
{
|
||||
m_pList = pCtrl;
|
||||
pCtrl->next = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
mpcontrol_t *p;
|
||||
p = m_pList;
|
||||
while ( p )
|
||||
{
|
||||
if ( !p->next )
|
||||
{
|
||||
p->next = pCtrl;
|
||||
pCtrl->next = NULL;
|
||||
break;
|
||||
}
|
||||
p = p->next;
|
||||
}
|
||||
}
|
||||
|
||||
pObj = pObj->pNext;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: applies all the values in the page
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCreateMultiplayerGameGameplayPage::GatherCurrentValues()
|
||||
{
|
||||
if ( !m_pDescription )
|
||||
return;
|
||||
|
||||
// OK
|
||||
CheckButton *pBox;
|
||||
TextEntry *pEdit;
|
||||
ComboBox *pCombo;
|
||||
|
||||
mpcontrol_t *pList;
|
||||
|
||||
CScriptObject *pObj;
|
||||
CScriptListItem *pItem;
|
||||
|
||||
char szValue[256];
|
||||
char strValue[256];
|
||||
wchar_t w_szStrValue[256];
|
||||
|
||||
pList = m_pList;
|
||||
while ( pList )
|
||||
{
|
||||
pObj = pList->pScrObj;
|
||||
|
||||
if ( !pList->pControl )
|
||||
{
|
||||
pObj->SetCurValue( pObj->defValue );
|
||||
pList = pList->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
switch ( pObj->type )
|
||||
{
|
||||
case O_BOOL:
|
||||
pBox = (CheckButton *)pList->pControl;
|
||||
Q_snprintf( szValue, sizeof( szValue ), "%s", pBox->IsSelected() ? "1" : "0" );
|
||||
break;
|
||||
case O_NUMBER:
|
||||
pEdit = ( TextEntry * )pList->pControl;
|
||||
pEdit->GetText( strValue, sizeof( strValue ) );
|
||||
Q_snprintf( szValue, sizeof( szValue ), "%s", strValue );
|
||||
break;
|
||||
case O_STRING:
|
||||
pEdit = ( TextEntry * )pList->pControl;
|
||||
pEdit->GetText( strValue, sizeof( strValue ) );
|
||||
Q_snprintf( szValue, sizeof( szValue ), "%s", strValue );
|
||||
break;
|
||||
case O_LIST:
|
||||
pCombo = ( ComboBox *)pList->pControl;
|
||||
pCombo->GetText( w_szStrValue, sizeof( w_szStrValue ) / sizeof( wchar_t ) );
|
||||
|
||||
pItem = pObj->pListItems;
|
||||
|
||||
while ( pItem )
|
||||
{
|
||||
wchar_t *wLocalizedString = NULL;
|
||||
wchar_t w_szStrTemp[256];
|
||||
|
||||
// Localized string?
|
||||
if ( pItem->szItemText[0] == '#' )
|
||||
{
|
||||
wLocalizedString = g_pVGuiLocalize->Find( pItem->szItemText );
|
||||
}
|
||||
|
||||
if ( wLocalizedString )
|
||||
{
|
||||
// Copy the string we found into our temp array
|
||||
V_wcscpy_safe( w_szStrTemp, wLocalizedString );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Just convert what we have to Unicode
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode( pItem->szItemText, w_szStrTemp, sizeof( w_szStrTemp ) );
|
||||
}
|
||||
|
||||
if ( _wcsicmp( w_szStrTemp, w_szStrValue ) == 0 )
|
||||
{
|
||||
// Found a match!
|
||||
break;
|
||||
}
|
||||
|
||||
pItem = pItem->pNext;
|
||||
}
|
||||
|
||||
if ( pItem )
|
||||
{
|
||||
Q_snprintf( szValue, sizeof( szValue ), "%s", pItem->szValue );
|
||||
}
|
||||
else //Couldn't find index
|
||||
{
|
||||
Q_snprintf( szValue, sizeof( szValue ), "%s", pObj->defValue );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Remove double quotes and % characters
|
||||
UTIL_StripInvalidCharacters( szValue, sizeof( szValue ) );
|
||||
|
||||
Q_strncpy( strValue, szValue, sizeof( strValue ) );
|
||||
|
||||
pObj->SetCurValue( strValue );
|
||||
|
||||
pList = pList->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor, load/save server settings object
|
||||
//-----------------------------------------------------------------------------
|
||||
CServerDescription::CServerDescription(CPanelListPanel *panel) : CDescription(panel)
|
||||
{
|
||||
setHint( "// NOTE: THIS FILE IS AUTOMATICALLY REGENERATED, \r\n"
|
||||
"//DO NOT EDIT THIS HEADER, YOUR COMMENTS WILL BE LOST IF YOU DO\r\n"
|
||||
"// Multiplayer options script\r\n"
|
||||
"//\r\n"
|
||||
"// Format:\r\n"
|
||||
"// Version [float]\r\n"
|
||||
"// Options description followed by \r\n"
|
||||
"// Options defaults\r\n"
|
||||
"//\r\n"
|
||||
"// Option description syntax:\r\n"
|
||||
"//\r\n"
|
||||
"// \"cvar\" { \"Prompt\" { type [ type info ] } { default } }\r\n"
|
||||
"//\r\n"
|
||||
"// type = \r\n"
|
||||
"// BOOL (a yes/no toggle)\r\n"
|
||||
"// STRING\r\n"
|
||||
"// NUMBER\r\n"
|
||||
"// LIST\r\n"
|
||||
"//\r\n"
|
||||
"// type info:\r\n"
|
||||
"// BOOL no type info\r\n"
|
||||
"// NUMBER min max range, use -1 -1 for no limits\r\n"
|
||||
"// STRING no type info\r\n"
|
||||
"// LIST "" delimited list of options value pairs\r\n"
|
||||
"//\r\n"
|
||||
"//\r\n"
|
||||
"// default depends on type\r\n"
|
||||
"// BOOL is \"0\" or \"1\"\r\n"
|
||||
"// NUMBER is \"value\"\r\n"
|
||||
"// STRING is \"value\"\r\n"
|
||||
"// LIST is \"index\", where index \"0\" is the first element of the list\r\n\r\n\r\n" );
|
||||
|
||||
setDescription ( "SERVER_OPTIONS" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CServerDescription::WriteScriptHeader( FileHandle_t fp )
|
||||
{
|
||||
char am_pm[] = "AM";
|
||||
tm newtime;
|
||||
Plat_GetLocalTime( &newtime );
|
||||
|
||||
if( newtime.tm_hour > 12 ) /* Set up extension. */
|
||||
Q_strncpy( am_pm, "PM", sizeof( am_pm ) );
|
||||
if( newtime.tm_hour > 12 ) /* Convert from 24-hour */
|
||||
newtime.tm_hour -= 12; /* to 12-hour clock. */
|
||||
if( newtime.tm_hour == 0 ) /*Set hour to 12 if midnight. */
|
||||
newtime.tm_hour = 12;
|
||||
|
||||
g_pFullFileSystem->FPrintf( fp, "%s", (char *)getHint() );
|
||||
|
||||
char timeString[64];
|
||||
Plat_GetTimeString( &newtime, timeString, sizeof( timeString ) );
|
||||
|
||||
// Write out the comment and Cvar Info:
|
||||
g_pFullFileSystem->FPrintf( fp, "// Half-Life Server Configuration Layout Script (stores last settings chosen, too)\r\n" );
|
||||
g_pFullFileSystem->FPrintf( fp, "// File generated: %.19s %s\r\n", timeString, am_pm );
|
||||
g_pFullFileSystem->FPrintf( fp, "//\r\n//\r\n// Cvar\t-\tSetting\r\n\r\n" );
|
||||
|
||||
g_pFullFileSystem->FPrintf( fp, "VERSION %.1f\r\n\r\n", SCRIPT_VERSION );
|
||||
|
||||
g_pFullFileSystem->FPrintf( fp, "DESCRIPTION SERVER_OPTIONS\r\n{\r\n" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CServerDescription::WriteFileHeader( FileHandle_t fp )
|
||||
{
|
||||
char am_pm[] = "AM";
|
||||
tm newtime;
|
||||
Plat_GetLocalTime( &newtime );
|
||||
|
||||
if( newtime.tm_hour > 12 ) /* Set up extension. */
|
||||
Q_strncpy( am_pm, "PM", sizeof( am_pm ) );
|
||||
if( newtime.tm_hour > 12 ) /* Convert from 24-hour */
|
||||
newtime.tm_hour -= 12; /* to 12-hour clock. */
|
||||
if( newtime.tm_hour == 0 ) /*Set hour to 12 if midnight. */
|
||||
newtime.tm_hour = 12;
|
||||
|
||||
char timeString[64];
|
||||
Plat_GetTimeString( &newtime, timeString, sizeof( timeString ) );
|
||||
|
||||
g_pFullFileSystem->FPrintf( fp, "// Half-Life Server Configuration Settings\r\n" );
|
||||
g_pFullFileSystem->FPrintf( fp, "// DO NOT EDIT, GENERATED BY HALF-LIFE\r\n" );
|
||||
g_pFullFileSystem->FPrintf( fp, "// File generated: %.19s %s\r\n", timeString, am_pm );
|
||||
g_pFullFileSystem->FPrintf( fp, "//\r\n//\r\n// Cvar\t-\tSetting\r\n\r\n" );
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CREATEMULTIPLAYERGAMEGAMEPLAYPAGE_H
|
||||
#define CREATEMULTIPLAYERGAMEGAMEPLAYPAGE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui_controls/PropertyPage.h>
|
||||
|
||||
class CPanelListPanel;
|
||||
class CDescription;
|
||||
class mpcontrol_t;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: server options page of the create game server dialog
|
||||
//-----------------------------------------------------------------------------
|
||||
class CCreateMultiplayerGameGameplayPage : public vgui::PropertyPage
|
||||
{
|
||||
public:
|
||||
CCreateMultiplayerGameGameplayPage(vgui::Panel *parent, const char *name);
|
||||
~CCreateMultiplayerGameGameplayPage();
|
||||
|
||||
// returns currently entered information about the server
|
||||
int GetMaxPlayers();
|
||||
const char *GetPassword();
|
||||
const char *GetHostName();
|
||||
|
||||
protected:
|
||||
virtual void OnApplyChanges();
|
||||
|
||||
private:
|
||||
const char *GetValue(const char *cvarName, const char *defaultValue);
|
||||
void LoadGameOptionsList();
|
||||
void GatherCurrentValues();
|
||||
|
||||
CDescription *m_pDescription;
|
||||
mpcontrol_t *m_pList;
|
||||
CPanelListPanel *m_pOptionsList;
|
||||
};
|
||||
|
||||
|
||||
#endif // CREATEMULTIPLAYERGAMEGAMEPLAYPAGE_H
|
||||
300
game/client/cstrike15/gameui/createmultiplayergameserverpage.cpp
Normal file
300
game/client/cstrike15/gameui/createmultiplayergameserverpage.cpp
Normal file
@@ -0,0 +1,300 @@
|
||||
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
|
||||
#include "createmultiplayergameserverpage.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
#include <keyvalues.h>
|
||||
#include <vgui_controls/ComboBox.h>
|
||||
#include <vgui_controls/RadioButton.h>
|
||||
#include <vgui_controls/CheckButton.h>
|
||||
#include "filesystem.h"
|
||||
#include "tier1/convar.h"
|
||||
#include "engineinterface.h"
|
||||
#include "cvartogglecheckbutton.h"
|
||||
|
||||
#include "modinfo.h"
|
||||
|
||||
// for SRC
|
||||
#include <vstdlib/random.h>
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
#define RANDOM_MAP "#GameUI_RandomMap"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CCreateMultiplayerGameServerPage::CCreateMultiplayerGameServerPage(vgui::Panel *parent, const char *name) : PropertyPage(parent, name)
|
||||
{
|
||||
m_pSavedData = NULL;
|
||||
|
||||
// we can use this if we decide we want to put "listen server" at the end of the game name
|
||||
m_pMapList = new ComboBox(this, "MapList", 12, false);
|
||||
|
||||
m_pEnableBotsCheck = new CheckButton( this, "EnableBotsCheck", "" );
|
||||
m_pEnableBotsCheck->SetVisible( false );
|
||||
m_pEnableBotsCheck->SetEnabled( false );
|
||||
|
||||
LoadControlSettings("Resource/CreateMultiplayerGameServerPage.res");
|
||||
|
||||
LoadMapList();
|
||||
m_szMapName[0] = 0;
|
||||
|
||||
// initialize hostname
|
||||
SetControlString("ServerNameEdit", ModInfo().GetGameName());//szHostName);
|
||||
|
||||
// initialize password
|
||||
// SetControlString("PasswordEdit", engine->pfnGetCvarString("sv_password"));
|
||||
ConVarRef var( "sv_password" );
|
||||
if ( var.IsValid() )
|
||||
{
|
||||
SetControlString("PasswordEdit", var.GetString() );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CCreateMultiplayerGameServerPage::~CCreateMultiplayerGameServerPage()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCreateMultiplayerGameServerPage::EnableBots( KeyValues *data )
|
||||
{
|
||||
m_pSavedData = data;
|
||||
|
||||
int quota = data->GetInt( "bot_quota", 0 );
|
||||
SetControlInt( "BotQuotaCombo", quota );
|
||||
m_pEnableBotsCheck->SetSelected( (quota > 0) );
|
||||
|
||||
int difficulty = data->GetInt( "bot_difficulty", 0 );
|
||||
difficulty = MAX( difficulty, 0 );
|
||||
difficulty = MIN( 3, difficulty );
|
||||
|
||||
char buttonName[64];
|
||||
Q_snprintf( buttonName, sizeof( buttonName ), "SkillLevel%d", difficulty );
|
||||
vgui::RadioButton *button = dynamic_cast< vgui::RadioButton * >(FindChildByName( buttonName ));
|
||||
if ( button )
|
||||
{
|
||||
button->SetSelected( true );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: called to get the info from the dialog
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCreateMultiplayerGameServerPage::OnApplyChanges()
|
||||
{
|
||||
KeyValues *kv = m_pMapList->GetActiveItemUserData();
|
||||
Q_strncpy(m_szMapName, kv->GetString("mapname", ""), DATA_STR_LENGTH);
|
||||
|
||||
if ( m_pSavedData )
|
||||
{
|
||||
int quota = GetControlInt( "BotQuotaCombo", 0 );
|
||||
if ( !m_pEnableBotsCheck->IsSelected() )
|
||||
{
|
||||
quota = 0;
|
||||
}
|
||||
m_pSavedData->SetInt( "bot_quota", quota );
|
||||
ConVarRef bot_quota( "bot_quota" );
|
||||
bot_quota.SetValue( quota );
|
||||
|
||||
int difficulty = 0;
|
||||
for ( int i=0; i<4; ++i )
|
||||
{
|
||||
char buttonName[64];
|
||||
Q_snprintf( buttonName, sizeof( buttonName ), "SkillLevel%d", i );
|
||||
vgui::RadioButton *button = dynamic_cast< vgui::RadioButton * >(FindChildByName( buttonName ));
|
||||
if ( button )
|
||||
{
|
||||
if ( button->IsSelected() )
|
||||
{
|
||||
difficulty = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_pSavedData->SetInt( "bot_difficulty", difficulty );
|
||||
ConVarRef bot_difficulty( "bot_difficulty" );
|
||||
bot_difficulty.SetValue( difficulty );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: loads the list of available maps into the map list
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCreateMultiplayerGameServerPage::LoadMaps( const char *pszPathID )
|
||||
{
|
||||
FileFindHandle_t findHandle = NULL;
|
||||
|
||||
KeyValues *hiddenMaps = ModInfo().GetHiddenMaps();
|
||||
|
||||
const char *pszFilename = g_pFullFileSystem->FindFirst( "maps/*.bsp", &findHandle );
|
||||
while ( pszFilename )
|
||||
{
|
||||
char mapname[256];
|
||||
|
||||
// FindFirst ignores the pszPathID, so check it here
|
||||
// TODO: this doesn't find maps in fallback dirs
|
||||
Q_snprintf( mapname, sizeof(mapname), "maps/%s", pszFilename );
|
||||
if ( !g_pFullFileSystem->FileExists( mapname, pszPathID ) )
|
||||
{
|
||||
goto nextFile;
|
||||
}
|
||||
|
||||
// remove the text 'maps/' and '.bsp' from the file name to get the map name
|
||||
|
||||
{
|
||||
const char *str = Q_strstr( pszFilename, "maps" );
|
||||
if ( str )
|
||||
{
|
||||
Q_strncpy( mapname, str + 5, sizeof(mapname) - 1 ); // maps + \\ = 5
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_strncpy( mapname, pszFilename, sizeof(mapname) - 1 );
|
||||
}
|
||||
char *ext = Q_strstr( mapname, ".bsp" );
|
||||
if ( ext )
|
||||
{
|
||||
*ext = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//!! hack: strip out single player HL maps
|
||||
// this needs to be specified in a seperate file
|
||||
if ( !stricmp( ModInfo().GetGameName(), "Half-Life" ) && ( mapname[0] == 'c' || mapname[0] == 't') && mapname[2] == 'a' && mapname[1] >= '0' && mapname[1] <= '5' )
|
||||
{
|
||||
goto nextFile;
|
||||
}
|
||||
|
||||
// strip out maps that shouldn't be displayed
|
||||
if ( hiddenMaps )
|
||||
{
|
||||
if ( hiddenMaps->GetInt( mapname, 0 ) )
|
||||
{
|
||||
goto nextFile;
|
||||
}
|
||||
}
|
||||
|
||||
// add to the map list
|
||||
m_pMapList->AddItem( mapname, new KeyValues( "data", "mapname", mapname ) );
|
||||
|
||||
// get the next file
|
||||
nextFile:
|
||||
pszFilename = g_pFullFileSystem->FindNext( findHandle );
|
||||
}
|
||||
g_pFullFileSystem->FindClose( findHandle );
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: loads the list of available maps into the map list
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCreateMultiplayerGameServerPage::LoadMapList()
|
||||
{
|
||||
// clear the current list (if any)
|
||||
m_pMapList->DeleteAllItems();
|
||||
|
||||
// add special "name" to represent loading a randomly selected map
|
||||
m_pMapList->AddItem( RANDOM_MAP, new KeyValues( "data", "mapname", RANDOM_MAP ) );
|
||||
|
||||
// iterate the filesystem getting the list of all the files
|
||||
// UNDONE: steam wants this done in a special way, need to support that
|
||||
const char *pathID = "MOD";
|
||||
if ( !stricmp(ModInfo().GetGameName(), "Half-Life" ) )
|
||||
{
|
||||
pathID = NULL; // hl is the base dir
|
||||
}
|
||||
|
||||
// Load the GameDir maps
|
||||
LoadMaps( pathID );
|
||||
|
||||
// If we're not the Valve directory and we're using a "fallback_dir" in gameinfo.txt then include those maps...
|
||||
// (pathID is NULL if we're "Half-Life")
|
||||
const char *pszFallback = ModInfo().GetFallbackDir();
|
||||
if ( pathID && pszFallback[0] )
|
||||
{
|
||||
LoadMaps( "GAME_FALLBACK" );
|
||||
}
|
||||
|
||||
// set the first item to be selected
|
||||
m_pMapList->ActivateItem( 0 );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CCreateMultiplayerGameServerPage::IsRandomMapSelected()
|
||||
{
|
||||
const char *mapname = m_pMapList->GetActiveItemUserData()->GetString("mapname");
|
||||
if (!stricmp( mapname, RANDOM_MAP ))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CCreateMultiplayerGameServerPage::GetMapName()
|
||||
{
|
||||
int count = m_pMapList->GetItemCount();
|
||||
|
||||
// if there is only one entry it's the special "select random map" entry
|
||||
if( count <= 1 )
|
||||
return NULL;
|
||||
|
||||
const char *mapname = m_pMapList->GetActiveItemUserData()->GetString("mapname");
|
||||
if (!strcmp( mapname, RANDOM_MAP ))
|
||||
{
|
||||
int which = RandomInt( 1, count - 1 );
|
||||
mapname = m_pMapList->GetItemUserData( which )->GetString("mapname");
|
||||
}
|
||||
|
||||
return mapname;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Sets currently selected map in the map combobox
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCreateMultiplayerGameServerPage::SetMap(const char *mapName)
|
||||
{
|
||||
for (int i = 0; i < m_pMapList->GetItemCount(); i++)
|
||||
{
|
||||
if (!m_pMapList->IsItemIDValid(i))
|
||||
continue;
|
||||
|
||||
if (!stricmp(m_pMapList->GetItemUserData(i)->GetString("mapname"), mapName))
|
||||
{
|
||||
m_pMapList->ActivateItem(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCreateMultiplayerGameServerPage::OnCheckButtonChecked()
|
||||
{
|
||||
SetControlEnabled("SkillLevel0", m_pEnableBotsCheck->IsSelected());
|
||||
SetControlEnabled("SkillLevel1", m_pEnableBotsCheck->IsSelected());
|
||||
SetControlEnabled("SkillLevel2", m_pEnableBotsCheck->IsSelected());
|
||||
SetControlEnabled("SkillLevel3", m_pEnableBotsCheck->IsSelected());
|
||||
SetControlEnabled("BotQuotaCombo", m_pEnableBotsCheck->IsSelected());
|
||||
SetControlEnabled("BotQuotaLabel", m_pEnableBotsCheck->IsSelected());
|
||||
SetControlEnabled("BotDifficultyLabel", m_pEnableBotsCheck->IsSelected());
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CREATEMULTIPLAYERGAMESERVERPAGE_H
|
||||
#define CREATEMULTIPLAYERGAMESERVERPAGE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui_controls/PropertyPage.h>
|
||||
#include "cvartogglecheckbutton.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: server options page of the create game server dialog
|
||||
//-----------------------------------------------------------------------------
|
||||
class CCreateMultiplayerGameServerPage : public vgui::PropertyPage
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CCreateMultiplayerGameServerPage, vgui::PropertyPage );
|
||||
|
||||
public:
|
||||
CCreateMultiplayerGameServerPage(vgui::Panel *parent, const char *name);
|
||||
~CCreateMultiplayerGameServerPage();
|
||||
|
||||
// returns currently entered information about the server
|
||||
void SetMap(const char *name);
|
||||
bool IsRandomMapSelected();
|
||||
const char *GetMapName();
|
||||
|
||||
// CS Bots
|
||||
void EnableBots( KeyValues *data );
|
||||
int GetBotQuota( void );
|
||||
bool GetBotsEnabled( void );
|
||||
|
||||
protected:
|
||||
virtual void OnApplyChanges();
|
||||
MESSAGE_FUNC( OnCheckButtonChecked, "CheckButtonChecked" );
|
||||
|
||||
private:
|
||||
void LoadMapList();
|
||||
void LoadMaps( const char *pszPathID );
|
||||
|
||||
vgui::ComboBox *m_pMapList;
|
||||
vgui::CheckButton *m_pEnableBotsCheck;
|
||||
CCvarToggleCheckButton *m_pEnableTutorCheck;
|
||||
KeyValues *m_pSavedData;
|
||||
|
||||
enum { DATA_STR_LENGTH = 64 };
|
||||
char m_szMapName[DATA_STR_LENGTH];
|
||||
};
|
||||
|
||||
|
||||
#endif // CREATEMULTIPLAYERGAMESERVERPAGE_H
|
||||
1600
game/client/cstrike15/gameui/cstrike15/cstrike15basepanel.cpp
Normal file
1600
game/client/cstrike15/gameui/cstrike15/cstrike15basepanel.cpp
Normal file
File diff suppressed because it is too large
Load Diff
207
game/client/cstrike15/gameui/cstrike15/cstrike15basepanel.h
Normal file
207
game/client/cstrike15/gameui/cstrike15/cstrike15basepanel.h
Normal file
@@ -0,0 +1,207 @@
|
||||
//========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CSTRIKE15BASEPANEL_H
|
||||
#define CSTRIKE15BASEPANEL_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#ifdef _PS3
|
||||
#include "steam/steam_api.h"
|
||||
#endif
|
||||
|
||||
#include "basepanel.h"
|
||||
#include "messagebox_scaleform.h"
|
||||
#include "GameEventListener.h"
|
||||
#include "splitscreensignon.h"
|
||||
|
||||
#ifdef _PS3
|
||||
void MarkRegisteredKnownConsoleUserSteamIDToUnregisterLater( CSteamID steamIdConsoleUser );
|
||||
void ConfigurePSNPresenceStatusBasedOnCurrentSessionState( bool bCanUseSession = true );
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: This is the panel at the top of the panel hierarchy for GameUI
|
||||
// It handles all the menus, background images, and loading dialogs
|
||||
//-----------------------------------------------------------------------------
|
||||
class CCStrike15BasePanel: public CBaseModPanel, public IMessageBoxEventCallback, public IMatchEventsSink, public CGameEventListener
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CCStrike15BasePanel, CBaseModPanel );
|
||||
|
||||
public:
|
||||
CCStrike15BasePanel();
|
||||
virtual ~CCStrike15BasePanel();
|
||||
|
||||
virtual void OnEvent( KeyValues *pEvent );
|
||||
|
||||
virtual void FireGameEvent( IGameEvent *event );
|
||||
|
||||
#if defined( _X360 )
|
||||
// Prompts the user via the Xbox Guide to switch to Game Chat channel, as necessary
|
||||
void Xbox_PromptSwitchToGameVoiceChannel( void );
|
||||
|
||||
// Is the local user using Party Chat currently?
|
||||
bool Xbox_IsPartyChatEnabled( void );
|
||||
#endif // _X360
|
||||
|
||||
#if defined(INCLUDE_SCALEFORM)
|
||||
virtual void OnOpenCreateStartScreen( void ); // [jason] provides the "Press Start" screen interface
|
||||
virtual void DismissStartScreen( void );
|
||||
virtual bool IsStartScreenActive( void );
|
||||
|
||||
virtual void OnOpenCreateMainMenuScreen( void );
|
||||
virtual void DismissMainMenuScreen( void );
|
||||
virtual void RestoreMainMenuScreen( void );
|
||||
virtual void DismissAllMainMenuScreens( bool bHideMainMenuOnly = false );
|
||||
|
||||
void RestoreMPGameMenu( void );
|
||||
|
||||
virtual void ShowScaleformMainMenu( bool bShow );
|
||||
virtual bool IsScaleformMainMenuActive( void );
|
||||
|
||||
virtual void OnOpenCreateSingleplayerGameDialog( bool bMatchmakingFilter );
|
||||
virtual void OnOpenCreateMultiplayerGameDialog( void );
|
||||
virtual void OnOpenCreateMultiplayerGameCommunity( void );
|
||||
virtual void OnOpenDisconnectConfirmationDialog( void );
|
||||
virtual void OnOpenQuitConfirmationDialog( bool bForceToDesktop = false );
|
||||
|
||||
virtual void OnOpenServerBrowser();
|
||||
virtual void OnOpenCreateLobbyScreen( bool bIsHost = false );
|
||||
virtual void OnOpenLobbyBrowserScreen( bool bIsHost = false );
|
||||
virtual void UpdateLobbyScreen( void );
|
||||
virtual void UpdateMainMenuScreen();
|
||||
virtual void UpdateLobbyBrowser( void );
|
||||
|
||||
virtual void OnOpenMessageBox( char const *pszTitle, char const *pszMessage, char const *pszButtonLegend, DWORD dwFlags, IMessageBoxEventCallback *pEventCallback = NULL, CMessageBoxScaleform** ppInstance = NULL, wchar_t const *pszWideMessage = NULL );
|
||||
virtual void OnOpenMessageBoxInSlot( int slot, char const *pszTitle, char const *pszMessage, char const *pszButtonLegend, DWORD dwFlags, IMessageBoxEventCallback *pEventCallback = NULL, CMessageBoxScaleform** ppInstance = NULL );
|
||||
virtual void OnOpenMessageBoxThreeway( char const *pszTitle, char const *pszMessage, char const *pszButtonLegend, char const *pszThirdButtonLabel, DWORD dwFlags, IMessageBoxEventCallback *pEventCallback = NULL, CMessageBoxScaleform** ppInstance = NULL );
|
||||
|
||||
virtual void CreateCommandMsgBox( const char* pszTitle, const char* pszMessage, bool showOk = true, bool showCancel = false, const char* okCommand = NULL, const char* cancelCommand = NULL, const char* closedCommand = NULL, const char* pszLegend = NULL );
|
||||
virtual void CreateCommandMsgBoxInSlot( ECommandMsgBoxSlot slot, const char* pszTitle, const char* pszMessage, bool showOk = true, bool showCancel = false, const char* okCommand = NULL, const char* cancelCommand = NULL, const char* closedCommand = NULL, const char* pszLegend = NULL );
|
||||
|
||||
virtual void ShowMatchmakingStatus( void );
|
||||
|
||||
// returns true if message box is displayed successfully
|
||||
virtual bool ShowLockInput( void );
|
||||
|
||||
virtual void OnOpenPauseMenu( void );
|
||||
virtual void DismissPauseMenu( void );
|
||||
virtual void RestorePauseMenu( void );
|
||||
virtual void OnOpenControllerDialog( void );
|
||||
virtual void OnOpenSettingsDialog( void );
|
||||
virtual void OnOpenMouseDialog();
|
||||
virtual void OnOpenKeyboardDialog();
|
||||
virtual void OnOpenMotionControllerMoveDialog();
|
||||
virtual void OnOpenMotionControllerSharpshooterDialog();
|
||||
virtual void OnOpenMotionControllerDialog();
|
||||
virtual void OnOpenMotionCalibrationDialog();
|
||||
virtual void OnOpenVideoSettingsDialog();
|
||||
virtual void OnOpenOptionsQueued();
|
||||
virtual void OnOpenAudioSettingsDialog();
|
||||
|
||||
virtual void OnOpenUpsellDialog( void );
|
||||
|
||||
virtual void OnOpenHowToPlayDialog( void );
|
||||
|
||||
|
||||
virtual void ShowScaleformPauseMenu( bool bShow );
|
||||
virtual bool IsScaleformPauseMenuActive( void );
|
||||
virtual bool IsScaleformPauseMenuVisible( void );
|
||||
|
||||
virtual bool OnMessageBoxEvent( MessageBoxFlags_t buttonPressed );
|
||||
|
||||
virtual void OnOpenMedalsDialog();
|
||||
virtual void OnOpenStatsDialog();
|
||||
virtual void CloseMedalsStatsDialog();
|
||||
|
||||
|
||||
virtual void OnOpenLeaderboardsDialog();
|
||||
virtual void OnOpenCallVoteDialog();
|
||||
virtual void OnOpenMarketplace();
|
||||
virtual void UpdateLeaderboardsDialog();
|
||||
virtual void CloseLeaderboardsDialog();
|
||||
virtual void StartExitingProcess( void );
|
||||
|
||||
virtual void RunFrame( void );
|
||||
|
||||
void DoCommunityQuickPlay( void );
|
||||
|
||||
protected:
|
||||
virtual void LockInput( void );
|
||||
virtual void UnlockInput( void );
|
||||
|
||||
virtual bool IsScaleformIntroMovieEnabled( void );
|
||||
virtual void CreateScaleformIntroMovie( void );
|
||||
virtual void DismissScaleformIntroMovie( void );
|
||||
virtual void OnPlayCreditsVideo( void );
|
||||
|
||||
void CheckIntroMovieStaticDependencies( void );
|
||||
|
||||
|
||||
protected:
|
||||
enum CCSOnClosedCommand
|
||||
{
|
||||
ON_CLOSED_NULL,
|
||||
ON_CLOSED_DISCONNECT,
|
||||
ON_CLOSED_QUIT,
|
||||
ON_CLOSED_RESTORE_PAUSE_MENU,
|
||||
ON_CLOSED_RESTORE_MAIN_MENU,
|
||||
ON_CLOSED_DISCONNECT_TO_MP_GAME_MENU, // quit from a game and return to the create game menu instead of main menu
|
||||
};
|
||||
|
||||
CCSOnClosedCommand m_OnClosedCommand;
|
||||
|
||||
bool m_bMigratingActive;
|
||||
|
||||
bool m_bShowRequiredGameVoiceChannelUI;
|
||||
CountdownTimer m_GameVoiceChannelRecheckTimer;
|
||||
|
||||
bool m_bNeedToStartIntroMovie;
|
||||
bool m_bTestedStaticIntroMovieDependencies;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
#if defined ( _PS3 )&& !defined ( NO_STEAM )
|
||||
|
||||
void OnGameBootCheckInvites();
|
||||
void OnGameBootInstallTrophies();
|
||||
void ShowFatalError( uint32 unSize );
|
||||
void PerformPS3GameBootWork();
|
||||
void OnGameBootVerifyPs3DRM();
|
||||
void OnGameBootDrmVerified();
|
||||
void OnGameBootSaveContainerReady();
|
||||
|
||||
STEAM_CALLBACK_MANUAL( CCStrike15BasePanel, Steam_OnUserStatsReceived, UserStatsReceived_t, m_CallbackOnUserStatsReceived );
|
||||
STEAM_CALLBACK_MANUAL( CCStrike15BasePanel, Steam_OnPS3TrophiesInstalled, PS3TrophiesInstalled_t, m_CallbackOnPS3TrophiesInstalled );
|
||||
STEAM_CALLBACK_MANUAL( CCStrike15BasePanel, Steam_OnPSNGameBootInviteResult, PSNGameBootInviteResult_t, m_CallbackOnPSNGameBootInviteResult );
|
||||
STEAM_CALLBACK_MANUAL( CCStrike15BasePanel, Steam_OnLobbyInvite, LobbyInvite_t, m_CallbackOnLobbyInvite );
|
||||
|
||||
#endif// _PS3 && !NO_STEAM
|
||||
|
||||
#endif// Scaleform
|
||||
|
||||
SplitScreenSignonWidget* m_pSplitScreenSignon;
|
||||
bool m_bStartLogoIsShowing;
|
||||
bool m_bServerBrowserWarningRaised;
|
||||
bool m_bCommunityQuickPlayWarningRaised;
|
||||
bool m_bCommunityServerWarningIssued;
|
||||
bool m_bGameIsShuttingDown;
|
||||
};
|
||||
|
||||
#ifdef _GAMECONSOLE
|
||||
void GameStats_UserStartedPlaying( float flTime );
|
||||
void GameStats_ReportAction( char const *szReportAction );
|
||||
#else
|
||||
inline void GameStats_UserStartedPlaying( float flTime ) {}
|
||||
inline void GameStats_ReportAction( char const *szReportAction ) {}
|
||||
#endif
|
||||
|
||||
#endif // CSTRIKE15BASEPANEL_H
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#ifndef ISTEAMOVERLAYMGR_H
|
||||
#define ISTEAMOVERLAYMGR_H
|
||||
|
||||
abstract_class ISteamOverlayManager
|
||||
{
|
||||
public:
|
||||
virtual void Create( vgui::VPANEL parent ) = 0;
|
||||
virtual void GameBootReady() = 0;
|
||||
virtual void SetEnhancedOverlayInput( bool bEnable ) = 0;
|
||||
virtual void Destroy( void ) = 0;
|
||||
};
|
||||
|
||||
#ifdef _PS3
|
||||
extern ISteamOverlayManager *g_pISteamOverlayMgr;
|
||||
#else
|
||||
#define g_pISteamOverlayMgr ( ( ISteamOverlayManager * ) 0 )
|
||||
#endif
|
||||
|
||||
#endif // ISTEAMOVERLAYMGR_H
|
||||
@@ -0,0 +1,95 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#ifndef ISTEAMOVERLAYRENDER_H
|
||||
#define ISTEAMOVERLAYRENDER_H
|
||||
|
||||
/*
|
||||
Interfaces required for Steam overlay rendering
|
||||
*/
|
||||
|
||||
struct SteamOverlayRenderInfo_t
|
||||
{
|
||||
uint32 m_nScreenWidth; // screen width in pixels
|
||||
uint32 m_nScreenHeight; // screen height in pixels
|
||||
float m_flScreenAspectRatio; // screen aspect ratio
|
||||
float m_flRefreshRate; // screen refresh ratio in Hz
|
||||
};
|
||||
|
||||
struct SteamOverlayColor_t
|
||||
{
|
||||
SteamOverlayColor_t() : m_r(255), m_g(255), m_b(255), m_a(255) {}
|
||||
SteamOverlayColor_t( int r, int g, int b, int a ) : m_r( r ), m_g( g ), m_b( b ), m_a( a ) {}
|
||||
int m_r, m_g, m_b, m_a;
|
||||
};
|
||||
|
||||
struct SteamOverlayRect_t
|
||||
{
|
||||
SteamOverlayRect_t() : m_x0(0), m_y0(0), m_x1(0), m_y1(0) {}
|
||||
SteamOverlayRect_t( int x0, int y0, int x1, int y1 ) : m_x0(x0), m_y0(y0), m_x1(x1), m_y1(y1) {}
|
||||
int m_x0, m_y0, m_x1, m_y1;
|
||||
};
|
||||
|
||||
typedef int SteamOverlayTextureHandle_t;
|
||||
typedef uint32 SteamOverlayFontHandle_t;
|
||||
|
||||
class ISteamOverlayRenderHost
|
||||
{
|
||||
public:
|
||||
virtual void GetRenderInfo( SteamOverlayRenderInfo_t &info ) = 0;
|
||||
|
||||
// Font Information
|
||||
public:
|
||||
virtual SteamOverlayFontHandle_t FontGetHandle( char const *szFontName, bool bProportional = false ) = 0;
|
||||
virtual int FontGetTall( SteamOverlayFontHandle_t hFont ) = 0;
|
||||
virtual int FontGetAscent( SteamOverlayFontHandle_t hFont, wchar_t wch ) = 0;
|
||||
virtual bool FontIsAdditive( SteamOverlayFontHandle_t hFont ) = 0;
|
||||
virtual void FontCharABCwide( SteamOverlayFontHandle_t hFont, wchar_t ch, int &a, int &b, int &c ) = 0;
|
||||
virtual int FontGetCharWidth( SteamOverlayFontHandle_t hFont, wchar_t ch ) = 0;
|
||||
virtual void FontGetTextSize( SteamOverlayFontHandle_t hFont, wchar_t const *text, int &wide, int &tall ) = 0;
|
||||
virtual void FontGetKernedCharWidth( SteamOverlayFontHandle_t hFont, wchar_t ch, wchar_t chBefore, wchar_t chAfter, float &wide, float &flabcA, float &abcC ) = 0;
|
||||
|
||||
// Text Rendering
|
||||
public:
|
||||
virtual void TextSetFont( SteamOverlayFontHandle_t hFont ) = 0;
|
||||
virtual void TextSetColor( SteamOverlayColor_t const &clr ) = 0;
|
||||
virtual void TextSetPos( int x, int y ) = 0;
|
||||
virtual void TextDrawStringW( wchar_t const *pStringW ) = 0;
|
||||
|
||||
// Solid Rendering
|
||||
public:
|
||||
virtual void FillSetColor( SteamOverlayColor_t const &clr ) = 0;
|
||||
virtual void FillRect( SteamOverlayRect_t const &rc ) = 0;
|
||||
virtual void FillRectFade( SteamOverlayRect_t const &rc, int a0, int a1, bool bHorizontalFade ) = 0;
|
||||
|
||||
// Texture Rendering
|
||||
public:
|
||||
virtual SteamOverlayTextureHandle_t TextureCreate() = 0;
|
||||
virtual void TextureSetRGBA( SteamOverlayTextureHandle_t hTexture, unsigned char const *pbRGBA, int nWidth, int nHeight ) = 0;
|
||||
virtual void TextureSetFile( SteamOverlayTextureHandle_t hTexture, char const *szFileName ) = 0;
|
||||
virtual void TextureBind( SteamOverlayTextureHandle_t hTexture ) = 0;
|
||||
virtual void TextureRect( SteamOverlayRect_t const &rc ) = 0;
|
||||
virtual void TextureGetSize( SteamOverlayTextureHandle_t hTexture, int &nWidth, int &nHeight ) = 0;
|
||||
virtual bool TextureIsValid( SteamOverlayTextureHandle_t hTexture ) = 0;
|
||||
virtual void TextureDestroy( SteamOverlayTextureHandle_t hTexture ) = 0;
|
||||
};
|
||||
|
||||
class ISteamOverlayRender
|
||||
{
|
||||
public:
|
||||
virtual void Initialize( ISteamOverlayRenderHost *pSteamOverlayRenderHost ) = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
|
||||
virtual void Render() = 0;
|
||||
|
||||
// Handle input event in the overlay.
|
||||
// Params:
|
||||
// iCode = Joystick code including controller information
|
||||
// iValue = 1 for button press, 0 for button release; or analog value for axis
|
||||
// Returns:
|
||||
// true to keep the overlay active
|
||||
// false to exit the overlay mode
|
||||
virtual bool HandleInputEvent( int iCode, int iValue ) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // ISTEAMOVERLAYRENDER_H
|
||||
@@ -0,0 +1,260 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "isteamoverlaymgr.h"
|
||||
#include <vgui_controls/Panel.h>
|
||||
#include "view.h"
|
||||
#include <vgui/IVGui.h>
|
||||
#include "vguimatsurface/imatsystemsurface.h"
|
||||
#include <vgui_controls/Controls.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include <vgui/IScheme.h>
|
||||
#include <vgui/IPanel.h>
|
||||
#include "materialsystem/imaterialsystemhardwareconfig.h"
|
||||
#include "filesystem.h"
|
||||
#include "../common/xbox/xboxstubs.h"
|
||||
|
||||
#include "steam/steam_api.h"
|
||||
#include "cdll_int.h"
|
||||
#include "eiface.h"
|
||||
#include "matchmaking/imatchframework.h"
|
||||
#include "inputsystem/iinputsystem.h"
|
||||
#include "steam/steam_platform_ps3/isteamps3overlayrenderer.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
extern ISteamPS3OverlayRenderHost *g_SteamOverlayPanel_RenderHostImplementation;
|
||||
|
||||
vgui::IScheme *g_SteamOverlayPanel_Scheme;
|
||||
IMatSystemSurface *g_SteamOverlayPanel_Surface;
|
||||
|
||||
|
||||
#ifndef NO_STEAM
|
||||
static bool g_bRealEnhancedOverlayInputModeSetting = false;
|
||||
static bool BCellPadDataHook( CellPadData &data )
|
||||
{
|
||||
if ( !SteamPS3OverlayRender() )
|
||||
return false;
|
||||
|
||||
return SteamPS3OverlayRender()->BHandleCellPadData( data )
|
||||
|| g_bRealEnhancedOverlayInputModeSetting;
|
||||
}
|
||||
|
||||
static bool BCellPadNoDataHook()
|
||||
{
|
||||
if ( !SteamPS3OverlayRender() )
|
||||
return false;
|
||||
|
||||
return SteamPS3OverlayRender()->BResetInputState();
|
||||
}
|
||||
#endif // NO_STEAM
|
||||
|
||||
class CSteamOverlayPanel : public vgui::Panel
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CSteamOverlayPanel, vgui::Panel );
|
||||
|
||||
public:
|
||||
explicit CSteamOverlayPanel( vgui::VPANEL parent );
|
||||
virtual ~CSteamOverlayPanel( void );
|
||||
|
||||
virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
|
||||
virtual void Paint() {}
|
||||
virtual void PaintBackground();
|
||||
|
||||
protected:
|
||||
bool m_bInitializedRenderInterface;
|
||||
};
|
||||
|
||||
CSteamOverlayPanel::CSteamOverlayPanel( vgui::VPANEL parent ) : BaseClass( NULL, "SteamOverlayPanel" )
|
||||
{
|
||||
SetParent( parent );
|
||||
SetVisible( true );
|
||||
SetCursor( null );
|
||||
|
||||
int w, h;
|
||||
materials->GetBackBufferDimensions( w, h );
|
||||
|
||||
SetPos( 0, 0 );
|
||||
SetSize( w, h );
|
||||
DevMsg( "CSteamOverlayPanel created (%d x %d)\n", w, h );
|
||||
|
||||
SetFgColor( Color( 0, 0, 0, 255 ) );
|
||||
SetPaintBackgroundEnabled( true );
|
||||
|
||||
m_bInitializedRenderInterface = false;
|
||||
}
|
||||
|
||||
CSteamOverlayPanel::~CSteamOverlayPanel()
|
||||
{
|
||||
m_bInitializedRenderInterface = false;
|
||||
}
|
||||
|
||||
void CSteamOverlayPanel::ApplySchemeSettings(vgui::IScheme *pScheme)
|
||||
{
|
||||
g_SteamOverlayPanel_Scheme = pScheme;
|
||||
BaseClass::ApplySchemeSettings(pScheme);
|
||||
}
|
||||
|
||||
static bool g_bGameBootReadyForSteamOverlay = true;
|
||||
static bool g_bEnhancedOverlayInputMode = false;
|
||||
class CSteamOverlayMgr : public ISteamOverlayManager
|
||||
{
|
||||
public:
|
||||
CSteamOverlayPanel *m_pPanel;
|
||||
public:
|
||||
CSteamOverlayMgr( void )
|
||||
{
|
||||
m_pPanel = NULL;
|
||||
}
|
||||
void Create( vgui::VPANEL parent )
|
||||
{
|
||||
m_pPanel = new CSteamOverlayPanel( parent );
|
||||
}
|
||||
|
||||
void GameBootReady()
|
||||
{
|
||||
g_bGameBootReadyForSteamOverlay = true;
|
||||
}
|
||||
|
||||
void SetEnhancedOverlayInput( bool bEnable )
|
||||
{
|
||||
g_bEnhancedOverlayInputMode = bEnable;
|
||||
}
|
||||
|
||||
void Destroy( void )
|
||||
{
|
||||
if ( m_pPanel )
|
||||
{
|
||||
m_pPanel->SetParent( (vgui::Panel *)NULL );
|
||||
delete m_pPanel;
|
||||
m_pPanel = NULL;
|
||||
}
|
||||
}
|
||||
};
|
||||
static CSteamOverlayMgr g_SteamOverlayMgr;
|
||||
ISteamOverlayManager *g_pISteamOverlayMgr = &g_SteamOverlayMgr;
|
||||
|
||||
void CSteamOverlayPanel::PaintBackground()
|
||||
{
|
||||
g_pMatSystemSurface->SetClipRect( 0, 0, 10000, 10000 );
|
||||
g_SteamOverlayPanel_Surface = g_pMatSystemSurface;
|
||||
|
||||
if ( !m_bInitializedRenderInterface && g_bGameBootReadyForSteamOverlay )
|
||||
{
|
||||
m_bInitializedRenderInterface = true;
|
||||
|
||||
int wide, tall;
|
||||
materials->GetBackBufferDimensions( wide, tall );
|
||||
|
||||
#ifndef NO_STEAM
|
||||
// Setup overlay render interface for PS3 Steam overlay
|
||||
#if defined(NO_STEAM_PS3_OVERLAY)
|
||||
SteamPS3OverlayRender()->BHostInitialize( wide, tall, 60, NULL, materials->PS3GetFontLibPtr() );
|
||||
#else
|
||||
SteamPS3OverlayRender()->BHostInitialize( wide, tall, 60, g_SteamOverlayPanel_RenderHostImplementation, materials->PS3GetFontLibPtr() );
|
||||
#endif
|
||||
g_pInputSystem->SetPS3CellPadDataHook( &BCellPadDataHook );
|
||||
g_pInputSystem->SetPS3CellPadNoDataHook( &BCellPadNoDataHook );
|
||||
#endif
|
||||
}
|
||||
|
||||
if ( m_bInitializedRenderInterface )
|
||||
{
|
||||
#ifndef NO_STEAM
|
||||
if ( g_bRealEnhancedOverlayInputModeSetting != g_bEnhancedOverlayInputMode )
|
||||
{
|
||||
g_pInputSystem->ResetInputState();
|
||||
g_bRealEnhancedOverlayInputModeSetting = g_bEnhancedOverlayInputMode;
|
||||
}
|
||||
if ( g_bRealEnhancedOverlayInputModeSetting )
|
||||
{
|
||||
g_pInputSystem->PollInputState();
|
||||
}
|
||||
SteamPS3OverlayRender()->Render();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
class CSteamOverlayRenderHost : public ISteamPS3OverlayRenderHost
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
CUtlMap< int32, int > m_mapSteamToVGUITextureIDs;
|
||||
|
||||
static void ConvertColorFromSRGBToGamma( Color &color )
|
||||
{
|
||||
color.SetColor(
|
||||
clamp( static_cast< int >( .5f + 255.0f * LinearToGammaFullRange( SrgbGammaToLinear( color.r() * 1.0f/255.0f ) ) ), 0, 255 ),
|
||||
clamp( static_cast< int >( .5f + 255.0f * LinearToGammaFullRange( SrgbGammaToLinear( color.g() * 1.0f/255.0f ) ) ), 0, 255 ),
|
||||
clamp( static_cast< int >( .5f + 255.0f * LinearToGammaFullRange( SrgbGammaToLinear( color.b() * 1.0f/255.0f ) ) ), 0, 255 ),
|
||||
color.a() );
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
CSteamOverlayRenderHost()
|
||||
{
|
||||
|
||||
m_mapSteamToVGUITextureIDs.SetLessFunc( DefLessFunc( int32 ) );
|
||||
}
|
||||
|
||||
virtual void DrawTexturedRect( int x0, int y0, int x1, int y1, float u0, float v0, float u1, float v1, int32 iTextureID, DWORD colorStart, DWORD colorEnd, EOverlayGradientDirection eDirection )
|
||||
{
|
||||
unsigned short iMap = m_mapSteamToVGUITextureIDs.Find( iTextureID );
|
||||
if ( iMap != m_mapSteamToVGUITextureIDs.InvalidIndex() )
|
||||
{
|
||||
Color colStart( STEAM_COLOR_RED( colorStart ), STEAM_COLOR_GREEN( colorStart ), STEAM_COLOR_BLUE( colorStart ), STEAM_COLOR_ALPHA( colorStart ) );
|
||||
Color colEnd( STEAM_COLOR_RED( colorEnd ), STEAM_COLOR_GREEN( colorEnd ), STEAM_COLOR_BLUE( colorEnd ), STEAM_COLOR_ALPHA( colorEnd ) );
|
||||
|
||||
// The input colors are in sRGB space, but IMatSystemSurface's draw helpers are expecting the colors in gamma space (because they ultimately
|
||||
// use the vertexlit_and_unlit_generic vertex shader (NOT unlit_generic, which is actually no longer used), which converts the vertex colors from gamma to linear).
|
||||
ConvertColorFromSRGBToGamma( colStart );
|
||||
ConvertColorFromSRGBToGamma( colEnd );
|
||||
|
||||
g_SteamOverlayPanel_Surface->DrawSetTexture( m_mapSteamToVGUITextureIDs[iMap] );
|
||||
g_SteamOverlayPanel_Surface->DrawTexturedSubRectGradient( x0, y0, x1, y1, u0, v0, u1, v1, colStart, colEnd, eDirection == k_EOverlayGradientHorizontal ? true : false );
|
||||
}
|
||||
}
|
||||
|
||||
virtual void LoadOrUpdateTexture( int32 iTextureID, bool bIsFullTexture, int x0, int y0, uint32 uWidth, uint32 uHeight, int32 iBytes, char *pData )
|
||||
{
|
||||
if ( !bIsFullTexture )
|
||||
{
|
||||
unsigned short iMap = m_mapSteamToVGUITextureIDs.Find( iTextureID );
|
||||
if ( iMap != m_mapSteamToVGUITextureIDs.InvalidIndex() )
|
||||
{
|
||||
g_SteamOverlayPanel_Surface->DrawSetSubTextureRGBA( m_mapSteamToVGUITextureIDs[iMap], x0, y0, (unsigned char*)pData, uWidth, uHeight );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int iVGUITexture = g_SteamOverlayPanel_Surface->CreateNewTextureID( true );
|
||||
g_SteamOverlayPanel_Surface->DrawSetTextureRGBALinear( iVGUITexture, (unsigned char *)pData, uWidth, uHeight );
|
||||
m_mapSteamToVGUITextureIDs.InsertOrReplace( iTextureID, iVGUITexture );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual void DeleteTexture( int32 iTextureID )
|
||||
{
|
||||
unsigned short iMap = m_mapSteamToVGUITextureIDs.Find( iTextureID );
|
||||
if ( iMap != m_mapSteamToVGUITextureIDs.InvalidIndex() )
|
||||
{
|
||||
g_SteamOverlayPanel_Surface->DestroyTextureID( m_mapSteamToVGUITextureIDs[iMap] );
|
||||
m_mapSteamToVGUITextureIDs.RemoveAt( iMap );
|
||||
}
|
||||
}
|
||||
|
||||
virtual void DeleteAllTextures()
|
||||
{
|
||||
FOR_EACH_MAP( m_mapSteamToVGUITextureIDs, iMap )
|
||||
{
|
||||
g_SteamOverlayPanel_Surface->DestroyTextureID( m_mapSteamToVGUITextureIDs[iMap] );
|
||||
}
|
||||
m_mapSteamToVGUITextureIDs.Purge();
|
||||
}
|
||||
};
|
||||
static CSteamOverlayRenderHost g_SteamOverlayPanel_RenderHostInstance;
|
||||
ISteamPS3OverlayRenderHost *g_SteamOverlayPanel_RenderHostImplementation = &g_SteamOverlayPanel_RenderHostInstance;
|
||||
@@ -0,0 +1,97 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#include "souirender_pch.h"
|
||||
// additional #includes must be here
|
||||
#include "souirender_pchend.h"
|
||||
|
||||
static ConVar soui_debugtext( "soui_debugtext", "0", FCVAR_DEVELOPMENTONLY );
|
||||
class SOUIrenderPanel_DebugText : public ISOUIrenderInputHandler
|
||||
{
|
||||
public:
|
||||
virtual void Render()
|
||||
{
|
||||
if ( !soui_debugtext.GetBool() )
|
||||
return;
|
||||
|
||||
SOUIrender_RegisterInputHandler( this, true ); // always be the first to handle events
|
||||
|
||||
// Expire input buffers
|
||||
if ( m_flTimestamp && ( ( Plat_FloatTime() - m_flTimestamp ) > soui_debugtext.GetFloat() ) )
|
||||
{
|
||||
m_flTimestamp = 0;
|
||||
Q_memset( m_chBuffer, 0, sizeof( m_chBuffer ) );
|
||||
}
|
||||
|
||||
g_pISteamOverlayRenderHost->FillSetColor( SteamOverlayColor_t( 0, 0, 0, 128 ) );
|
||||
g_pISteamOverlayRenderHost->FillRect( SteamOverlayRect_t(
|
||||
AdjustUiPosX( 0, false, -1 ), AdjustUiPosY( 20, true, -1 ),
|
||||
AdjustUiPosX( 0, false, 0 ), AdjustUiPosY( 50, true, -1 )
|
||||
) );
|
||||
|
||||
g_pISteamOverlayRenderHost->TextSetFont( SOUIrenderGetFontHandle( kSOUIrenderFont_DefaultFixedOutline ) );
|
||||
g_pISteamOverlayRenderHost->TextSetColor( SteamOverlayColor_t( 255, 0, 0, 255 ) );
|
||||
g_pISteamOverlayRenderHost->TextSetPos( AdjustUiPosX( 40, true, -1 ), AdjustUiPosY( 25, true, -1 ) );
|
||||
|
||||
wchar_t wchBuf[128];
|
||||
Q_snwprintf( wchBuf, 128, L"[Steam overlay @ %.2f]" PRI_WS_FOR_WS, Plat_FloatTime(), m_chBuffer );
|
||||
g_pISteamOverlayRenderHost->TextDrawStringW( wchBuf );
|
||||
}
|
||||
|
||||
virtual uint32 HandleInputEvent( int iCode, int iValue )
|
||||
{
|
||||
if ( 0 == m_chBuffer[0] )
|
||||
{
|
||||
m_flTimestamp = Plat_FloatTime();
|
||||
}
|
||||
if ( 0 == m_chBuffer[50] )
|
||||
{
|
||||
wchar_t *chBuffer = m_chBuffer + Q_wcslen( m_chBuffer );
|
||||
switch ( SOUIGetBaseButtonCode( iCode ) )
|
||||
{
|
||||
case KEY_XBUTTON_A: Q_snwprintf( chBuffer, ARRAYSIZE( m_chBuffer ), L" A%d", iValue ); break;
|
||||
case KEY_XBUTTON_B: Q_snwprintf( chBuffer, ARRAYSIZE( m_chBuffer ), L" B%d", iValue ); break;
|
||||
case KEY_XBUTTON_X: Q_snwprintf( chBuffer, ARRAYSIZE( m_chBuffer ), L" X%d", iValue ); break;
|
||||
case KEY_XBUTTON_Y: Q_snwprintf( chBuffer, ARRAYSIZE( m_chBuffer ), L" Y%d", iValue ); break;
|
||||
case KEY_XBUTTON_START: Q_snwprintf( chBuffer, ARRAYSIZE( m_chBuffer ), L" ST%d", iValue ); break;
|
||||
case KEY_XBUTTON_INACTIVE_START: Q_snwprintf( chBuffer, ARRAYSIZE( m_chBuffer ), L" ST*%d", iValue ); break;
|
||||
case KEY_XBUTTON_BACK: Q_snwprintf( chBuffer, ARRAYSIZE( m_chBuffer ), L" BK%d", iValue ); break;
|
||||
case KEY_XBUTTON_LEFT_SHOULDER: Q_snwprintf( chBuffer, ARRAYSIZE( m_chBuffer ), L" Ls%d", iValue ); break;
|
||||
case KEY_XBUTTON_RIGHT_SHOULDER: Q_snwprintf( chBuffer, ARRAYSIZE( m_chBuffer ), L" Rs%d", iValue ); break;
|
||||
case KEY_XBUTTON_LEFT: Q_snwprintf( chBuffer, ARRAYSIZE( m_chBuffer ), L" <%d", iValue ); break;
|
||||
case KEY_XBUTTON_RIGHT: Q_snwprintf( chBuffer, ARRAYSIZE( m_chBuffer ), L" >%d", iValue ); break;
|
||||
case KEY_XBUTTON_UP: Q_snwprintf( chBuffer, ARRAYSIZE( m_chBuffer ), L" ^%d", iValue ); break;
|
||||
case KEY_XBUTTON_DOWN: Q_snwprintf( chBuffer, ARRAYSIZE( m_chBuffer ), L" v%d", iValue ); break;
|
||||
case KEY_XBUTTON_STICK1: Q_snwprintf( chBuffer, ARRAYSIZE( m_chBuffer ), L" (1)%d", iValue ); break;
|
||||
case KEY_XBUTTON_STICK2: Q_snwprintf( chBuffer, ARRAYSIZE( m_chBuffer ), L" (2)%d", iValue ); break;
|
||||
// analog values:
|
||||
case KEY_XBUTTON_LTRIGGER: Q_snwprintf( chBuffer, ARRAYSIZE( m_chBuffer ), L" Lt%d", iValue ); break;
|
||||
case KEY_XBUTTON_RTRIGGER: Q_snwprintf( chBuffer, ARRAYSIZE( m_chBuffer ), L" Rt%d", iValue ); break;
|
||||
case KEY_XSTICK1_RIGHT: Q_snwprintf( chBuffer, ARRAYSIZE( m_chBuffer ), L" (1)>%d", iValue ); break;
|
||||
case KEY_XSTICK1_LEFT: Q_snwprintf( chBuffer, ARRAYSIZE( m_chBuffer ), L" (1)<%d", iValue ); break;
|
||||
case KEY_XSTICK1_UP: Q_snwprintf( chBuffer, ARRAYSIZE( m_chBuffer ), L" (1)^%d", iValue ); break;
|
||||
case KEY_XSTICK1_DOWN: Q_snwprintf( chBuffer, ARRAYSIZE( m_chBuffer ), L" (1)v%d", iValue ); break;
|
||||
case KEY_XSTICK2_RIGHT: Q_snwprintf( chBuffer, ARRAYSIZE( m_chBuffer ), L" (2)>%d", iValue ); break;
|
||||
case KEY_XSTICK2_LEFT: Q_snwprintf( chBuffer, ARRAYSIZE( m_chBuffer ), L" (2)<%d", iValue ); break;
|
||||
case KEY_XSTICK2_UP: Q_snwprintf( chBuffer, ARRAYSIZE( m_chBuffer ), L" (2)^%d", iValue ); break;
|
||||
case KEY_XSTICK2_DOWN: Q_snwprintf( chBuffer, ARRAYSIZE( m_chBuffer ), L" (2)v%d", iValue ); break;
|
||||
default: Q_snwprintf( chBuffer, ARRAYSIZE( chBuffer ), L" (?x%X)%d", iCode, iValue ); break;
|
||||
}
|
||||
|
||||
if ( int userId = SOUIGetJoystickForCode( iCode ) )
|
||||
{
|
||||
Q_snwprintf( chBuffer, ARRAYSIZE( m_chBuffer ), L"/j%d", userId );
|
||||
}
|
||||
}
|
||||
if ( iCode == -1 && !iValue )
|
||||
{
|
||||
// Overlay is hiding
|
||||
Q_memset( m_chBuffer, 0, sizeof( m_chBuffer ) );
|
||||
m_flTimestamp = 0;
|
||||
}
|
||||
return INPUT_EVENT_RESULT_FALLTHROUGH; // let anybody else handle
|
||||
}
|
||||
|
||||
wchar_t m_chBuffer[ 64 ];
|
||||
float m_flTimestamp;
|
||||
};
|
||||
SOUIrenderDeclarePanel( SOUIrenderPanel_DebugText );
|
||||
@@ -0,0 +1,162 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#include "souirender_pch.h"
|
||||
// additional #includes must be here
|
||||
#include "souirender_pchend.h"
|
||||
|
||||
class SOUIrenderPanel_FriendChat_Individual
|
||||
{
|
||||
public:
|
||||
explicit SOUIrenderPanel_FriendChat_Individual( XUID xuid ) :
|
||||
m_xuid( xuid ),
|
||||
m_uiLatestLobbyInvite( 0 )
|
||||
{
|
||||
char const *szName = steamapicontext->SteamFriends()->GetFriendPersonaName( xuid );
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode( szName, m_wszNameBuf, sizeof( m_wszNameBuf ) );
|
||||
}
|
||||
|
||||
void OnInviteReceived( uint64 uiLobbyId )
|
||||
{
|
||||
m_uiLatestLobbyInvite = uiLobbyId;
|
||||
AddText( L"invited you to play Portal 2" );
|
||||
}
|
||||
|
||||
void AddText( wchar_t const *wszText )
|
||||
{
|
||||
SOUIrender_AddNotification( m_xuid, wszText );
|
||||
}
|
||||
|
||||
void Render()
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
public:
|
||||
XUID m_xuid;
|
||||
wchar_t m_wszNameBuf[64];
|
||||
uint64 m_uiLatestLobbyInvite;
|
||||
struct Message_t
|
||||
{
|
||||
XUID m_xuid;
|
||||
wchar_t *m_msg;
|
||||
};
|
||||
CUtlVector< Message_t > m_arrLatestMessages;
|
||||
};
|
||||
|
||||
class SOUIrenderPanel_FriendChat : public ISOUIrenderInputHandler
|
||||
{
|
||||
public:
|
||||
SOUIrenderPanel_FriendChat()
|
||||
{
|
||||
m_pLatestInvite = NULL;
|
||||
}
|
||||
|
||||
virtual void Initialize()
|
||||
{
|
||||
m_LobbyInvite_t.Register( this, &SOUIrenderPanel_FriendChat::Steam_LobbyInvite_t );
|
||||
}
|
||||
|
||||
virtual void Render()
|
||||
{
|
||||
FOR_EACH_VEC( m_arrFriends, i )
|
||||
m_arrFriends[i]->Render();
|
||||
|
||||
if ( m_pLatestInvite )
|
||||
{
|
||||
// Render text
|
||||
int x = 0, y = 0, w = 0, h = 0;
|
||||
SteamOverlayFontHandle_t hFont = SOUIrenderGetFontHandle( kSOUIrenderFont_DefaultFixedOutline );
|
||||
g_pISteamOverlayRenderHost->TextSetFont( hFont );
|
||||
g_pISteamOverlayRenderHost->TextSetColor( SteamOverlayColor_t( 0, 0, 255, 255 ) );
|
||||
g_pISteamOverlayRenderHost->TextSetPos( AdjustUiPosX( -100, true, 0 ), AdjustUiPosY( -100, true, 0 ) );
|
||||
g_pISteamOverlayRenderHost->TextDrawStringW( L"Latest invite:" );
|
||||
|
||||
x = AdjustUiPosX( -100, true, 0 ), y = AdjustUiPosY( -80, true, 0 );
|
||||
g_pISteamOverlayRenderHost->TextSetPos( x, y );
|
||||
g_pISteamOverlayRenderHost->TextSetColor( SteamOverlayColor_t( 0, 0, 255, 255 ) );
|
||||
g_pISteamOverlayRenderHost->TextDrawStringW( L"From: " );
|
||||
g_pISteamOverlayRenderHost->FontGetTextSize( hFont, L"From: ", w, h );
|
||||
g_pISteamOverlayRenderHost->TextSetPos( x + w, y );
|
||||
g_pISteamOverlayRenderHost->TextSetColor( SteamOverlayColor_t( 0, 255, 0, 255 ) );
|
||||
g_pISteamOverlayRenderHost->TextDrawStringW( m_pLatestInvite->m_wszNameBuf );
|
||||
|
||||
x = AdjustUiPosX( -100, true, 0 ), y = AdjustUiPosY( -60, true, 0 );
|
||||
g_pISteamOverlayRenderHost->TextSetPos( x, y );
|
||||
g_pISteamOverlayRenderHost->TextSetColor( SteamOverlayColor_t( 0, 0, 255, 255 ) );
|
||||
g_pISteamOverlayRenderHost->TextDrawStringW( L"Lobby: " );
|
||||
g_pISteamOverlayRenderHost->FontGetTextSize( hFont, L"Lobby: ", w, h );
|
||||
g_pISteamOverlayRenderHost->TextSetPos( x + w, y );
|
||||
g_pISteamOverlayRenderHost->TextSetColor( SteamOverlayColor_t( 0, 255, 0, 255 ) );
|
||||
wchar_t wchLobbyId[64];
|
||||
Q_snwprintf( wchLobbyId, sizeof( wchLobbyId ), L"0x%016llX", m_pLatestInvite->m_uiLatestLobbyInvite );
|
||||
g_pISteamOverlayRenderHost->TextDrawStringW( wchLobbyId );
|
||||
|
||||
g_pISteamOverlayRenderHost->TextSetColor( SteamOverlayColor_t( 0, 0, 255, 255 ) );
|
||||
g_pISteamOverlayRenderHost->TextSetPos( AdjustUiPosX( -100, true, 0 ), AdjustUiPosY( -40, true, 0 ) );
|
||||
g_pISteamOverlayRenderHost->TextDrawStringW( L"Press START to join" );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Render text
|
||||
g_pISteamOverlayRenderHost->TextSetFont( SOUIrenderGetFontHandle( kSOUIrenderFont_DefaultFixedOutline ) );
|
||||
g_pISteamOverlayRenderHost->TextSetColor( SteamOverlayColor_t( 255, 255, 0, 255 ) );
|
||||
g_pISteamOverlayRenderHost->TextSetPos( AdjustUiPosX( -100, true, 0 ), AdjustUiPosY( -100, true, 0 ) );
|
||||
g_pISteamOverlayRenderHost->TextDrawStringW( L"Your friends invites show up here" );
|
||||
}
|
||||
}
|
||||
|
||||
virtual uint32 HandleInputEvent( int iCode, int iValue )
|
||||
{
|
||||
if ( m_pLatestInvite && iValue )
|
||||
{
|
||||
switch ( SOUIGetBaseButtonCode( iCode ) )
|
||||
{
|
||||
case KEY_XBUTTON_START:
|
||||
if ( m_pLatestInvite && m_pLatestInvite->m_uiLatestLobbyInvite )
|
||||
{
|
||||
KeyValues *kvEvent = new KeyValues( "OnSteamOverlayCall::LobbyJoin" );
|
||||
kvEvent->SetUint64( "sessionid", m_pLatestInvite->m_uiLatestLobbyInvite );
|
||||
g_pMatchFramework->GetEventsSubscription()->BroadcastEvent( kvEvent );
|
||||
}
|
||||
return INPUT_EVENT_RESULT_CLOSEOVERLAY;
|
||||
}
|
||||
}
|
||||
return INPUT_EVENT_RESULT_FALLTHROUGH;
|
||||
}
|
||||
|
||||
public:
|
||||
STEAM_CALLBACK_MANUAL( SOUIrenderPanel_FriendChat, Steam_LobbyInvite_t, LobbyInvite_t, m_LobbyInvite_t );
|
||||
CUtlVector< SOUIrenderPanel_FriendChat_Individual * > m_arrFriends;
|
||||
SOUIrenderPanel_FriendChat_Individual *m_pLatestInvite;
|
||||
};
|
||||
SOUIrenderDeclarePanel( SOUIrenderPanel_FriendChat );
|
||||
|
||||
|
||||
|
||||
void SOUIrenderPanel_FriendChat::Steam_LobbyInvite_t( LobbyInvite_t *pParam )
|
||||
{
|
||||
DevMsg( "SOUIrenderPanel_FriendChat::Steam_LobbyInvite_t( %llX, %llX ) @ %.2f\n", pParam->m_ulSteamIDUser, pParam->m_ulSteamIDLobby, Plat_FloatTime() );
|
||||
|
||||
// Find the friend or make new friend
|
||||
SOUIrenderPanel_FriendChat_Individual *pFriend = NULL;
|
||||
FOR_EACH_VEC( m_arrFriends, i )
|
||||
{
|
||||
if ( m_arrFriends[i]->m_xuid == pParam->m_ulSteamIDUser )
|
||||
{
|
||||
pFriend = m_arrFriends[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !pFriend )
|
||||
{
|
||||
pFriend = new SOUIrenderPanel_FriendChat_Individual( pParam->m_ulSteamIDUser );
|
||||
m_arrFriends.AddToTail( pFriend );
|
||||
}
|
||||
|
||||
pFriend->OnInviteReceived( pParam->m_ulSteamIDLobby );
|
||||
m_pLatestInvite = pFriend;
|
||||
|
||||
// Mark us as preferring focus input
|
||||
SOUIrender_RegisterInputHandler( this, true );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#include "souirender_pch.h"
|
||||
// additional #includes must be here
|
||||
#include "souirender_pchend.h"
|
||||
|
||||
class CSteamOverlayRender : public ISteamOverlayRender
|
||||
{
|
||||
public:
|
||||
CSteamOverlayRender();
|
||||
|
||||
public:
|
||||
virtual void Initialize( ISteamOverlayRenderHost *pSteamOverlayRenderHost );
|
||||
virtual void Shutdown();
|
||||
|
||||
virtual void Render();
|
||||
|
||||
virtual bool HandleInputEvent( int iCode, int iValue );
|
||||
|
||||
public:
|
||||
bool m_bOverlayFullyActive;
|
||||
SteamOverlayFontHandle_t m_arrFontHandles[ kSOUIrenderFont_Count ];
|
||||
CUtlVector< ISOUIrenderInputHandler * > m_arrInputHandlers;
|
||||
};
|
||||
|
||||
static CSteamOverlayRender g_CSteamOverlayRender;
|
||||
ISteamOverlayRender *g_pISteamOverlayRender = &g_CSteamOverlayRender;
|
||||
|
||||
ISteamOverlayRenderHost *g_pISteamOverlayRenderHost;
|
||||
UiPosAdjustment_t g_ISteamOverlayRenderHost_PosAdjustment;
|
||||
SteamOverlayFontHandle_t *g_ISteamOverlayRenderHost_FontHandles;
|
||||
|
||||
SOUIrenderDeclareExternPanel( SOUIrenderPanel_FriendChat )
|
||||
SOUIrenderDeclareExternPanel( SOUIrenderPanel_Notification );
|
||||
SOUIrenderDeclareExternPanel( SOUIrenderPanel_DebugText );
|
||||
|
||||
CSteamOverlayRender::CSteamOverlayRender()
|
||||
{
|
||||
m_bOverlayFullyActive = false;
|
||||
Q_memset( m_arrFontHandles, 0, sizeof( m_arrFontHandles ) );
|
||||
}
|
||||
|
||||
void CSteamOverlayRender::Initialize( ISteamOverlayRenderHost *pSteamOverlayRenderHost )
|
||||
{
|
||||
g_pISteamOverlayRenderHost = pSteamOverlayRenderHost;
|
||||
|
||||
// Font handles
|
||||
m_arrFontHandles[ kSOUIrenderFont_DefaultFixedOutline ] = g_pISteamOverlayRenderHost->FontGetHandle( "DefaultFixedOutline" );
|
||||
g_ISteamOverlayRenderHost_FontHandles = &m_arrFontHandles[0];
|
||||
|
||||
// Pos adjustment
|
||||
SteamOverlayRenderInfo_t sori;
|
||||
g_pISteamOverlayRenderHost->GetRenderInfo( sori );
|
||||
g_ISteamOverlayRenderHost_PosAdjustment.m_size[0] = sori.m_nScreenWidth;
|
||||
g_ISteamOverlayRenderHost_PosAdjustment.m_size[1] = sori.m_nScreenHeight;
|
||||
g_ISteamOverlayRenderHost_PosAdjustment.m_flScaleFactor[0] =
|
||||
g_ISteamOverlayRenderHost_PosAdjustment.m_flScaleFactor[1] =
|
||||
sori.m_nScreenHeight / 480.0f;
|
||||
|
||||
SOUIrenderReferenceExternPanel( SOUIrenderPanel_FriendChat )->Initialize();
|
||||
SOUIrenderReferenceExternPanel( SOUIrenderPanel_Notification )->Initialize();
|
||||
SOUIrenderReferenceExternPanel( SOUIrenderPanel_DebugText )->Initialize();
|
||||
}
|
||||
|
||||
void CSteamOverlayRender::Shutdown()
|
||||
{
|
||||
SOUIrenderReferenceExternPanel( SOUIrenderPanel_DebugText )->Shutdown();
|
||||
SOUIrenderReferenceExternPanel( SOUIrenderPanel_Notification )->Shutdown();
|
||||
SOUIrenderReferenceExternPanel( SOUIrenderPanel_FriendChat )->Shutdown();
|
||||
}
|
||||
|
||||
void SOUIrender_RegisterInputHandler( ISOUIrenderInputHandler *p, bool bAdd )
|
||||
{
|
||||
// Cannot have the same handler registered twice
|
||||
while ( g_CSteamOverlayRender.m_arrInputHandlers.FindAndRemove( p ) ) continue;
|
||||
if ( bAdd )
|
||||
g_CSteamOverlayRender.m_arrInputHandlers.AddToHead( p );
|
||||
|
||||
}
|
||||
|
||||
void CSteamOverlayRender::Render()
|
||||
{
|
||||
if ( m_bOverlayFullyActive )
|
||||
{
|
||||
{ // Darken background
|
||||
g_pISteamOverlayRenderHost->FillSetColor( SteamOverlayColor_t( 0, 0, 0, 220 ) );
|
||||
g_pISteamOverlayRenderHost->FillRect( SteamOverlayRect_t(
|
||||
AdjustUiPosX( 0, false, -1 ), AdjustUiPosY( 0, false, -1 ),
|
||||
AdjustUiPosX( 0, false, 1 ), AdjustUiPosY( 0, false, 1 )
|
||||
) );
|
||||
}
|
||||
SOUIrenderReferenceExternPanel( SOUIrenderPanel_FriendChat )->Render();
|
||||
}
|
||||
// Panels rendering on top of overlay
|
||||
SOUIrenderReferenceExternPanel( SOUIrenderPanel_Notification )->Render();
|
||||
SOUIrenderReferenceExternPanel( SOUIrenderPanel_DebugText )->Render();
|
||||
}
|
||||
|
||||
bool CSteamOverlayRender::HandleInputEvent( int iCode, int iValue )
|
||||
{
|
||||
if ( iCode == -1 )
|
||||
m_bOverlayFullyActive = !!iValue;
|
||||
|
||||
// Let registered handlers handle the event
|
||||
for ( int k = 0; k < m_arrInputHandlers.Count(); ++ k )
|
||||
{
|
||||
uint32 uiResult = m_arrInputHandlers[k]->HandleInputEvent( iCode, iValue );
|
||||
if ( uiResult & ISOUIrenderInputHandler::INPUT_EVENT_RESULT_CLOSEOVERLAY )
|
||||
return false;
|
||||
if ( uiResult & ISOUIrenderInputHandler::INPUT_EVENT_RESULT_HANDLED )
|
||||
return true;
|
||||
}
|
||||
|
||||
// End the overlay when unhandled SELECT key or CANCEL key
|
||||
if ( ( SOUIGetBaseButtonCode( iCode ) == KEY_XBUTTON_BACK ) && iValue )
|
||||
return false;
|
||||
if ( ( SOUIGetBaseButtonCode( iCode ) == KEY_XBUTTON_B ) && iValue )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#include "souirender_pch.h"
|
||||
// additional #includes must be here
|
||||
#include "souirender_pchend.h"
|
||||
|
||||
static ConVar soui_notification_time( "soui_notification_time", "10", FCVAR_DEVELOPMENTONLY );
|
||||
static ConVar soui_notification_fade( "soui_notification_fade", "1", FCVAR_DEVELOPMENTONLY );
|
||||
class SOUIrenderPanel_Notification : public ISOUIrenderInputHandler
|
||||
{
|
||||
public:
|
||||
virtual void Render()
|
||||
{
|
||||
if ( !m_flTimestamp )
|
||||
return;
|
||||
|
||||
float flTime = Plat_FloatTime();
|
||||
if ( flTime >= m_flTimestamp + soui_notification_time.GetFloat() )
|
||||
{
|
||||
m_flTimestamp = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
float flFadeFactor = 255;
|
||||
if ( flTime < m_flTimestamp + soui_notification_fade.GetFloat() )
|
||||
flFadeFactor = ( flTime - m_flTimestamp ) * 255 / soui_notification_fade.GetFloat();
|
||||
else if ( flTime > m_flTimestamp + soui_notification_time.GetFloat() - soui_notification_fade.GetFloat() )
|
||||
flFadeFactor = ( m_flTimestamp + soui_notification_time.GetFloat() - flTime ) * 255 / soui_notification_fade.GetFloat();
|
||||
|
||||
enum Consts_t
|
||||
{
|
||||
kMarginEdgeX = 40,
|
||||
kMarginEdgeY = 25,
|
||||
kMargin = 20,
|
||||
kLineHeight = 20,
|
||||
kLineWidth = 200,
|
||||
|
||||
kNumLines = 2,
|
||||
kLine0y = kMarginEdgeY + kNumLines * kLineHeight,
|
||||
kLine1y = kLine0y - kLineHeight,
|
||||
kLineLeft = kLineWidth + kMarginEdgeX,
|
||||
|
||||
kImageSize = 40,
|
||||
kImageLeft = kLineLeft + kMargin + kImageSize,
|
||||
|
||||
kTotalHeight = kLine0y + kMargin,
|
||||
kTotalWidth = kImageLeft + kMargin,
|
||||
};
|
||||
|
||||
// Render background
|
||||
g_pISteamOverlayRenderHost->FillSetColor( SteamOverlayColor_t( 0, 0, 0, flFadeFactor ) );
|
||||
g_pISteamOverlayRenderHost->FillRect( SteamOverlayRect_t(
|
||||
AdjustUiPosX( -kTotalWidth, true, 1 ), AdjustUiPosY( -kTotalHeight, true, 1 ),
|
||||
AdjustUiPosX( 0, false, 1 ), AdjustUiPosY( 0, false, 1 )
|
||||
) );
|
||||
|
||||
// Render texture
|
||||
g_pISteamOverlayRenderHost->FillSetColor( SteamOverlayColor_t( 255, 255, 255, flFadeFactor ) );
|
||||
g_pISteamOverlayRenderHost->TextureBind( m_iTextureHandle );
|
||||
g_pISteamOverlayRenderHost->TextureRect( SteamOverlayRect_t(
|
||||
AdjustUiPosX( -kImageLeft, true, 1 ), AdjustUiPosY( -kLine0y, true, 1 ),
|
||||
AdjustUiPosX( -kImageLeft + kImageSize, true, 1 ), AdjustUiPosY( -kLine0y + kImageSize, true, 1 )
|
||||
) );
|
||||
|
||||
// Render text
|
||||
g_pISteamOverlayRenderHost->TextSetFont( SOUIrenderGetFontHandle( kSOUIrenderFont_DefaultFixedOutline ) );
|
||||
g_pISteamOverlayRenderHost->TextSetColor( SteamOverlayColor_t( 0, 255, 0, 255 ) );
|
||||
|
||||
g_pISteamOverlayRenderHost->TextSetPos( AdjustUiPosX( -kLineLeft, true, 1 ), AdjustUiPosY( -kLine0y, true, 1 ) );
|
||||
g_pISteamOverlayRenderHost->TextDrawStringW( m_wszNameBuf );
|
||||
|
||||
g_pISteamOverlayRenderHost->TextSetPos( AdjustUiPosX( -kLineLeft, true, 1 ), AdjustUiPosY( -kLine1y, true, 1 ) );
|
||||
g_pISteamOverlayRenderHost->TextDrawStringW( m_wszBuf );
|
||||
}
|
||||
|
||||
void AddNotification( XUID xuid, wchar_t const *wszText )
|
||||
{
|
||||
m_flTimestamp = Plat_FloatTime();
|
||||
m_xuid = xuid;
|
||||
Q_wcsncpy( m_wszBuf, wszText, sizeof( m_wszBuf ) );
|
||||
|
||||
// Get name string
|
||||
char const *szName = steamapicontext->SteamFriends()->GetFriendPersonaName( xuid );
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode( szName, m_wszNameBuf, sizeof( m_wszNameBuf ) );
|
||||
|
||||
// Get image
|
||||
if ( !m_iTextureHandle || !g_pISteamOverlayRenderHost->TextureIsValid( m_iTextureHandle ) )
|
||||
{
|
||||
m_iTextureHandle = g_pISteamOverlayRenderHost->TextureCreate();
|
||||
}
|
||||
bool bTextureValid = false;
|
||||
uint32 iWidth = 0, iHeight = 0;
|
||||
int iAvatar = steamapicontext->SteamFriends()->GetMediumFriendAvatar( xuid );
|
||||
if ( steamapicontext->SteamUtils()->GetImageSize( iAvatar, &iWidth, &iHeight ) &&
|
||||
(iWidth>0) && (iHeight>0) )
|
||||
{
|
||||
CUtlBuffer bufRGBA;
|
||||
bufRGBA.EnsureCapacity( iWidth * iHeight * 4 );
|
||||
if ( steamapicontext->SteamUtils()->GetImageRGBA( iAvatar, (uint8*) bufRGBA.Base(), iWidth * iHeight * 4 ) )
|
||||
{
|
||||
bTextureValid = true;
|
||||
g_pISteamOverlayRenderHost->TextureSetRGBA( m_iTextureHandle, (uint8*) bufRGBA.Base(), iWidth, iHeight );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !bTextureValid )
|
||||
{
|
||||
g_pISteamOverlayRenderHost->TextureSetFile( m_iTextureHandle, "icon_lobby" );
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
float m_flTimestamp;
|
||||
int m_iTextureHandle;
|
||||
XUID m_xuid;
|
||||
wchar_t m_wszNameBuf[64];
|
||||
wchar_t m_wszBuf[256];
|
||||
};
|
||||
SOUIrenderDeclarePanel( SOUIrenderPanel_Notification );
|
||||
|
||||
void SOUIrender_AddNotification( XUID xuid, wchar_t const *wszText )
|
||||
{
|
||||
SOUIrenderReferencePanel( SOUIrenderPanel_Notification ).AddNotification( xuid, wszText );
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#ifndef SOUIRENDER_PCH_H
|
||||
#define SOUIRENDER_PCH_H
|
||||
|
||||
#include "cbase.h"
|
||||
#include "steam/steam_api.h"
|
||||
#include "cdll_int.h"
|
||||
#include "eiface.h"
|
||||
#include "matchmaking/imatchframework.h"
|
||||
#include "tier1/fmtstr.h"
|
||||
#include "vgui/ILocalize.h"
|
||||
#include "steam/steam_platform_ps3/isteamps3overlayrenderer.h"
|
||||
|
||||
|
||||
#endif // SOUIRENDER_PCH_H
|
||||
@@ -0,0 +1,8 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#ifndef SOUIRENDER_PCHEND_H
|
||||
#define SOUIRENDER_PCHEND_H
|
||||
|
||||
#include "memdbgon.h"
|
||||
|
||||
#endif // SOUIRENDER_PCHEND_H
|
||||
@@ -0,0 +1,6 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#include "souirender_pch.h"
|
||||
// additional #includes must be here
|
||||
#include "souirender_pchend.h"
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
|
||||
#ifndef SOUIRENDER_UTILS_H
|
||||
#define SOUIRENDER_UTILS_H
|
||||
|
||||
enum SOUIrenderFont_t
|
||||
{
|
||||
kSOUIrenderFont_DefaultFixedOutline,
|
||||
kSOUIrenderFont_Count
|
||||
};
|
||||
|
||||
#define SOUIrenderDeclarePanel( classname ) static classname s_souirenderpanel_##classname; ISOUIrenderInputHandler *g_psouirenderpanel_##classname = &s_souirenderpanel_##classname;
|
||||
#define SOUIrenderReferencePanel( classname ) s_souirenderpanel_##classname
|
||||
#define SOUIrenderDeclareExternPanel( classname ) extern ISOUIrenderInputHandler *g_psouirenderpanel_##classname;
|
||||
#define SOUIrenderReferenceExternPanel( classname ) g_psouirenderpanel_##classname
|
||||
|
||||
extern SteamOverlayFontHandle_t *g_ISteamOverlayRenderHost_FontHandles;
|
||||
inline SteamOverlayFontHandle_t SOUIrenderGetFontHandle( SOUIrenderFont_t eFont )
|
||||
{
|
||||
return g_ISteamOverlayRenderHost_FontHandles[eFont];
|
||||
}
|
||||
|
||||
|
||||
#endif // SOUIRENDER_UTILS_H
|
||||
93
game/client/cstrike15/gameui/customtabexplanationdialog.cpp
Normal file
93
game/client/cstrike15/gameui/customtabexplanationdialog.cpp
Normal file
@@ -0,0 +1,93 @@
|
||||
//====== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. =======
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#include "customtabexplanationdialog.h"
|
||||
#include "basepanel.h"
|
||||
#include "convar.h"
|
||||
#include "engineinterface.h"
|
||||
#include "gameui_interface.h"
|
||||
#include "vgui/ISurface.h"
|
||||
#include "vgui/IInput.h"
|
||||
#include "modinfo.h"
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CCustomTabExplanationDialog::CCustomTabExplanationDialog(vgui::Panel *parent) : BaseClass(parent, "CustomTabExplanationDialog")
|
||||
{
|
||||
SetDeleteSelfOnClose(true);
|
||||
SetSizeable( false );
|
||||
|
||||
input()->SetAppModalSurface(GetVPanel());
|
||||
|
||||
LoadControlSettings("Resource/CustomTabExplanationDialog.res");
|
||||
|
||||
MoveToCenterOfScreen();
|
||||
|
||||
GameUI().PreventEngineHideGameUI();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CCustomTabExplanationDialog::~CCustomTabExplanationDialog()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCustomTabExplanationDialog::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
|
||||
SetDialogVariable( "game", ModInfo().GetGameName() );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCustomTabExplanationDialog::OnKeyCodePressed(KeyCode code)
|
||||
{
|
||||
if (code == KEY_ESCAPE)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnKeyCodePressed(code);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: handles button commands
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCustomTabExplanationDialog::OnCommand( const char *command )
|
||||
{
|
||||
if ( !stricmp( command, "ok" ) || !stricmp( command, "cancel" ) || !stricmp( command, "close" ) )
|
||||
{
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnCommand( command );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCustomTabExplanationDialog::OnClose( void )
|
||||
{
|
||||
BaseClass::OnClose();
|
||||
GameUI().AllowEngineHideGameUI();
|
||||
}
|
||||
35
game/client/cstrike15/gameui/customtabexplanationdialog.h
Normal file
35
game/client/cstrike15/gameui/customtabexplanationdialog.h
Normal file
@@ -0,0 +1,35 @@
|
||||
//====== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. =======
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef CUSTOMTABEXPLANATIONDIALOG_H
|
||||
#define CUSTOMTABEXPLANATIONDIALOG_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui_controls/Frame.h"
|
||||
#include "utlvector.h"
|
||||
#include <vgui/KeyCode.h>
|
||||
#include "vgui_controls/URLLabel.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Dialog that explains the custom tab
|
||||
//-----------------------------------------------------------------------------
|
||||
class CCustomTabExplanationDialog : public vgui::Frame
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CCustomTabExplanationDialog, vgui::Frame );
|
||||
|
||||
public:
|
||||
explicit CCustomTabExplanationDialog(vgui::Panel *parent);
|
||||
~CCustomTabExplanationDialog();
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
virtual void OnKeyCodePressed(vgui::KeyCode code);
|
||||
virtual void OnCommand( const char *command );
|
||||
virtual void OnClose( void );
|
||||
};
|
||||
|
||||
#endif // CUSTOMTABEXPLANATIONDIALOG_H
|
||||
136
game/client/cstrike15/gameui/cvarnegatecheckbutton.cpp
Normal file
136
game/client/cstrike15/gameui/cvarnegatecheckbutton.cpp
Normal file
@@ -0,0 +1,136 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
#include "cvarnegatecheckbutton.h"
|
||||
#include "engineinterface.h"
|
||||
#include <vgui/IVGui.h>
|
||||
#include "IGameUIFuncs.h"
|
||||
#include "tier1/keyvalues.h"
|
||||
#include "tier1/convar.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
CCvarNegateCheckButton::CCvarNegateCheckButton( Panel *parent, const char *panelName, const char *text,
|
||||
const char *cvarname )
|
||||
: CheckButton( parent, panelName, text )
|
||||
{
|
||||
m_pszCvarName = cvarname ? strdup( cvarname ) : NULL;
|
||||
Reset();
|
||||
AddActionSignalTarget( this );
|
||||
}
|
||||
|
||||
CCvarNegateCheckButton::~CCvarNegateCheckButton()
|
||||
{
|
||||
free( m_pszCvarName );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCvarNegateCheckButton::Paint()
|
||||
{
|
||||
if ( !m_pszCvarName )
|
||||
{
|
||||
BaseClass::Paint();
|
||||
return;
|
||||
}
|
||||
|
||||
// Look up current value
|
||||
// float value = engine->pfnGetCvarFloat( m_pszCvarName );
|
||||
ConVarRef var( m_pszCvarName );
|
||||
if ( !var.IsValid() )
|
||||
return;
|
||||
|
||||
float value = var.GetFloat();
|
||||
|
||||
if ( value < 0 )
|
||||
{
|
||||
if ( !m_bStartState )
|
||||
{
|
||||
SetSelected( true );
|
||||
m_bStartState = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_bStartState )
|
||||
{
|
||||
SetSelected( false );
|
||||
m_bStartState = false;
|
||||
}
|
||||
}
|
||||
BaseClass::Paint();
|
||||
}
|
||||
|
||||
void CCvarNegateCheckButton::Reset()
|
||||
{
|
||||
// Look up current value
|
||||
// float value = engine->pfnGetCvarFloat( m_pszCvarName );
|
||||
ConVarRef var( m_pszCvarName );
|
||||
if ( !var.IsValid() )
|
||||
return;
|
||||
|
||||
float value = var.GetFloat();
|
||||
|
||||
if ( value < 0 )
|
||||
{
|
||||
m_bStartState = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bStartState = false;
|
||||
}
|
||||
SetSelected(m_bStartState);
|
||||
}
|
||||
|
||||
bool CCvarNegateCheckButton::HasBeenModified()
|
||||
{
|
||||
return IsSelected() != m_bStartState;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *panel -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCvarNegateCheckButton::SetSelected( bool state )
|
||||
{
|
||||
BaseClass::SetSelected( state );
|
||||
}
|
||||
|
||||
void CCvarNegateCheckButton::ApplyChanges()
|
||||
{
|
||||
if ( !m_pszCvarName || !m_pszCvarName[ 0 ] )
|
||||
return;
|
||||
|
||||
ConVarRef var( m_pszCvarName );
|
||||
float value = var.GetFloat();
|
||||
|
||||
value = (float)fabs( value );
|
||||
if (value < 0.00001)
|
||||
{
|
||||
// correct the value if it's not set
|
||||
value = 0.022f;
|
||||
}
|
||||
|
||||
m_bStartState = IsSelected();
|
||||
value = -value;
|
||||
|
||||
float ans = m_bStartState ? value : -value;
|
||||
var.SetValue( ans );
|
||||
}
|
||||
|
||||
|
||||
void CCvarNegateCheckButton::OnButtonChecked()
|
||||
{
|
||||
if (HasBeenModified())
|
||||
{
|
||||
PostActionSignal(new KeyValues("ControlModified"));
|
||||
}
|
||||
}
|
||||
39
game/client/cstrike15/gameui/cvarnegatecheckbutton.h
Normal file
39
game/client/cstrike15/gameui/cvarnegatecheckbutton.h
Normal file
@@ -0,0 +1,39 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CVARNEGATECHECKBUTTON_H
|
||||
#define CVARNEGATECHECKBUTTON_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui_controls/CheckButton.h>
|
||||
|
||||
class CCvarNegateCheckButton : public vgui::CheckButton
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CCvarNegateCheckButton, vgui::CheckButton );
|
||||
|
||||
public:
|
||||
CCvarNegateCheckButton( vgui::Panel *parent, const char *panelName, const char *text,
|
||||
char const *cvarname );
|
||||
~CCvarNegateCheckButton();
|
||||
|
||||
virtual void SetSelected( bool state );
|
||||
virtual void Paint();
|
||||
|
||||
void Reset();
|
||||
void ApplyChanges();
|
||||
bool HasBeenModified();
|
||||
|
||||
private:
|
||||
MESSAGE_FUNC( OnButtonChecked, "CheckButtonChecked" );
|
||||
|
||||
char *m_pszCvarName;
|
||||
bool m_bStartState;
|
||||
};
|
||||
|
||||
#endif // CVARNEGATECHECKBUTTON_H
|
||||
317
game/client/cstrike15/gameui/cvarslider.cpp
Normal file
317
game/client/cstrike15/gameui/cvarslider.cpp
Normal file
@@ -0,0 +1,317 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
#include "cvarslider.h"
|
||||
#include <stdio.h>
|
||||
#include "engineinterface.h"
|
||||
#include "tier1/keyvalues.h"
|
||||
#include "tier1/convar.h"
|
||||
#include <vgui/IVGui.h>
|
||||
#include <vgui_controls/PropertyPage.h>
|
||||
|
||||
#define CVARSLIDER_SCALE_FACTOR 100.0f
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
DECLARE_BUILD_FACTORY( CCvarSlider );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CCvarSlider::CCvarSlider( Panel *parent, const char *name ) : Slider( parent, name )
|
||||
{
|
||||
SetupSlider( 0, 1, "", false );
|
||||
m_bCreatedInCode = false;
|
||||
|
||||
AddActionSignalTarget( this );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CCvarSlider::CCvarSlider( Panel *parent, const char *panelName, char const *caption,
|
||||
float minValue, float maxValue, char const *cvarname, bool bAllowOutOfRange )
|
||||
: Slider( parent, panelName )
|
||||
{
|
||||
AddActionSignalTarget( this );
|
||||
|
||||
SetupSlider( minValue, maxValue, cvarname, bAllowOutOfRange );
|
||||
|
||||
// For backwards compatability. Ignore .res file settings for forced setup sliders.
|
||||
m_bCreatedInCode = true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCvarSlider::SetupSlider( float minValue, float maxValue, const char *cvarname, bool bAllowOutOfRange )
|
||||
{
|
||||
m_flMinValue = minValue;
|
||||
m_flMaxValue = maxValue;
|
||||
|
||||
// scale by CVARSLIDER_SCALE_FACTOR
|
||||
SetRange( (int)( CVARSLIDER_SCALE_FACTOR * minValue ), (int)( CVARSLIDER_SCALE_FACTOR * maxValue ) );
|
||||
|
||||
char szMin[ 32 ];
|
||||
char szMax[ 32 ];
|
||||
|
||||
Q_snprintf( szMin, sizeof( szMin ), "%.2f", minValue );
|
||||
Q_snprintf( szMax, sizeof( szMax ), "%.2f", maxValue );
|
||||
|
||||
SetTickCaptions( szMin, szMax );
|
||||
|
||||
Q_strncpy( m_szCvarName, cvarname, sizeof( m_szCvarName ) );
|
||||
|
||||
m_bModifiedOnce = false;
|
||||
m_bAllowOutOfRange = bAllowOutOfRange;
|
||||
|
||||
// Set slider to current value
|
||||
Reset();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CCvarSlider::~CCvarSlider()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCvarSlider::ApplySettings( KeyValues *inResourceData )
|
||||
{
|
||||
BaseClass::ApplySettings( inResourceData );
|
||||
|
||||
if ( !m_bCreatedInCode )
|
||||
{
|
||||
float minValue = inResourceData->GetFloat( "minvalue", 0 );
|
||||
float maxValue = inResourceData->GetFloat( "maxvalue", 1 );
|
||||
const char *cvarname = inResourceData->GetString( "cvar_name", "" );
|
||||
bool bAllowOutOfRange = inResourceData->GetBool( "allowoutofrange", false );
|
||||
SetupSlider( minValue, maxValue, cvarname, bAllowOutOfRange );
|
||||
|
||||
if ( GetParent() )
|
||||
{
|
||||
// HACK: If our parent is a property page, we want the dialog containing it
|
||||
if ( dynamic_cast<vgui::PropertyPage*>(GetParent()) && GetParent()->GetParent() )
|
||||
{
|
||||
GetParent()->GetParent()->AddActionSignalTarget( this );
|
||||
}
|
||||
else
|
||||
{
|
||||
GetParent()->AddActionSignalTarget( this );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Get control settings for editing
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCvarSlider::GetSettings( KeyValues *outResourceData )
|
||||
{
|
||||
BaseClass::GetSettings(outResourceData);
|
||||
|
||||
if ( !m_bCreatedInCode )
|
||||
{
|
||||
outResourceData->SetFloat( "minvalue", m_flMinValue );
|
||||
outResourceData->SetFloat( "maxvalue", m_flMaxValue );
|
||||
outResourceData->SetString( "cvar_name", m_szCvarName );
|
||||
outResourceData->SetBool( "allowoutofrange", m_bAllowOutOfRange );
|
||||
}
|
||||
}
|
||||
|
||||
void CCvarSlider::SetCVarName( char const *cvarname )
|
||||
{
|
||||
Q_strncpy( m_szCvarName, cvarname, sizeof( m_szCvarName ) );
|
||||
|
||||
m_bModifiedOnce = false;
|
||||
|
||||
// Set slider to current value
|
||||
Reset();
|
||||
}
|
||||
|
||||
void CCvarSlider::SetMinMaxValues( float minValue, float maxValue, bool bSetTickDisplay )
|
||||
{
|
||||
SetRange( (int)( CVARSLIDER_SCALE_FACTOR * minValue ), (int)( CVARSLIDER_SCALE_FACTOR * maxValue ) );
|
||||
|
||||
if ( bSetTickDisplay )
|
||||
{
|
||||
char szMin[ 32 ];
|
||||
char szMax[ 32 ];
|
||||
|
||||
Q_snprintf( szMin, sizeof( szMin ), "%.2f", minValue );
|
||||
Q_snprintf( szMax, sizeof( szMax ), "%.2f", maxValue );
|
||||
|
||||
|
||||
SetTickCaptions( szMin, szMax );
|
||||
}
|
||||
|
||||
// Set slider to current value
|
||||
Reset();
|
||||
}
|
||||
|
||||
void CCvarSlider::SetTickColor( Color color )
|
||||
{
|
||||
m_TickColor = color;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCvarSlider::Paint()
|
||||
{
|
||||
// Get engine's current value
|
||||
// float curvalue = engine->pfnGetCvarFloat( m_szCvarName );
|
||||
ConVarRef var( m_szCvarName );
|
||||
if ( !var.IsValid() )
|
||||
return;
|
||||
float curvalue = var.GetFloat();
|
||||
|
||||
// did it get changed from under us?
|
||||
if (curvalue != m_fStartValue)
|
||||
{
|
||||
int val = (int)( CVARSLIDER_SCALE_FACTOR * curvalue );
|
||||
m_fStartValue = curvalue;
|
||||
m_fCurrentValue = curvalue;
|
||||
|
||||
SetValue( val );
|
||||
m_iStartValue = GetValue();
|
||||
}
|
||||
|
||||
BaseClass::Paint();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCvarSlider::ApplyChanges()
|
||||
{
|
||||
if (m_bModifiedOnce)
|
||||
{
|
||||
m_iStartValue = GetValue();
|
||||
if (m_bAllowOutOfRange)
|
||||
{
|
||||
m_fStartValue = m_fCurrentValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fStartValue = (float) m_iStartValue / CVARSLIDER_SCALE_FACTOR;
|
||||
}
|
||||
|
||||
//engine->Cvar_SetValue( m_szCvarName, m_fStartValue );
|
||||
ConVarRef var( m_szCvarName );
|
||||
var.SetValue( (float)m_fStartValue );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
float CCvarSlider::GetSliderValue()
|
||||
{
|
||||
if (m_bAllowOutOfRange)
|
||||
{
|
||||
return m_fCurrentValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((float)GetValue())/ CVARSLIDER_SCALE_FACTOR;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCvarSlider::SetSliderValue(float fValue)
|
||||
{
|
||||
int nVal = (int)( CVARSLIDER_SCALE_FACTOR * fValue );
|
||||
SetValue( nVal, false);
|
||||
|
||||
// remember this slider value
|
||||
m_iLastSliderValue = GetValue();
|
||||
|
||||
if (m_fCurrentValue != fValue)
|
||||
{
|
||||
m_fCurrentValue = fValue;
|
||||
m_bModifiedOnce = true;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCvarSlider::Reset()
|
||||
{
|
||||
// Set slider to current value
|
||||
// m_fStartValue = engine->pfnGetCvarFloat( m_szCvarName );
|
||||
ConVarRef var( m_szCvarName );
|
||||
if ( !var.IsValid() )
|
||||
{
|
||||
m_fCurrentValue = m_fStartValue = 0.0f;
|
||||
SetValue( 0 );
|
||||
m_iStartValue = GetValue();
|
||||
m_iLastSliderValue = m_iStartValue;
|
||||
return;
|
||||
}
|
||||
float m_fStartValue = var.GetFloat();
|
||||
m_fCurrentValue = m_fStartValue;
|
||||
|
||||
int value = (int)( CVARSLIDER_SCALE_FACTOR * m_fStartValue );
|
||||
SetValue( value );
|
||||
|
||||
m_iStartValue = GetValue();
|
||||
m_iLastSliderValue = m_iStartValue;
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CCvarSlider::HasBeenModified()
|
||||
{
|
||||
if (GetValue() != m_iStartValue)
|
||||
{
|
||||
m_bModifiedOnce = true;
|
||||
}
|
||||
|
||||
return m_bModifiedOnce;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : position -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCvarSlider::OnSliderMoved()
|
||||
{
|
||||
if (HasBeenModified())
|
||||
{
|
||||
if (m_iLastSliderValue != GetValue())
|
||||
{
|
||||
m_iLastSliderValue = GetValue();
|
||||
m_fCurrentValue = ((float) m_iLastSliderValue)/CVARSLIDER_SCALE_FACTOR;
|
||||
}
|
||||
|
||||
// tell parent that we've been modified
|
||||
PostActionSignal(new KeyValues("ControlModified"));
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCvarSlider::OnApplyChanges( void )
|
||||
{
|
||||
if ( !m_bCreatedInCode )
|
||||
{
|
||||
ApplyChanges();
|
||||
}
|
||||
}
|
||||
61
game/client/cstrike15/gameui/cvarslider.h
Normal file
61
game/client/cstrike15/gameui/cvarslider.h
Normal file
@@ -0,0 +1,61 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CVARSLIDER_H
|
||||
#define CVARSLIDER_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui_controls/Slider.h>
|
||||
|
||||
class CCvarSlider : public vgui::Slider
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CCvarSlider, vgui::Slider );
|
||||
|
||||
public:
|
||||
|
||||
CCvarSlider( vgui::Panel *parent, const char *panelName );
|
||||
CCvarSlider( vgui::Panel *parent, const char *panelName, char const *caption,
|
||||
float minValue, float maxValue, char const *cvarname, bool bAllowOutOfRange=false );
|
||||
~CCvarSlider();
|
||||
|
||||
void SetupSlider( float minValue, float maxValue, const char *cvarname, bool bAllowOutOfRange );
|
||||
|
||||
void SetCVarName( char const *cvarname );
|
||||
void SetMinMaxValues( float minValue, float maxValue, bool bSetTickdisplay = true );
|
||||
void SetTickColor( Color color );
|
||||
|
||||
virtual void Paint();
|
||||
|
||||
virtual void ApplySettings( KeyValues *inResourceData );
|
||||
virtual void GetSettings( KeyValues *outResourceData );
|
||||
|
||||
void ApplyChanges();
|
||||
float GetSliderValue();
|
||||
void SetSliderValue(float fValue);
|
||||
void Reset();
|
||||
bool HasBeenModified();
|
||||
|
||||
private:
|
||||
MESSAGE_FUNC( OnSliderMoved, "SliderMoved" );
|
||||
MESSAGE_FUNC( OnApplyChanges, "ApplyChanges" );
|
||||
|
||||
bool m_bAllowOutOfRange;
|
||||
bool m_bModifiedOnce;
|
||||
float m_fStartValue;
|
||||
int m_iStartValue;
|
||||
int m_iLastSliderValue;
|
||||
float m_fCurrentValue;
|
||||
char m_szCvarName[ 64 ];
|
||||
|
||||
bool m_bCreatedInCode;
|
||||
float m_flMinValue;
|
||||
float m_flMaxValue;
|
||||
};
|
||||
|
||||
#endif // CVARSLIDER_H
|
||||
112
game/client/cstrike15/gameui/cvartextentry.cpp
Normal file
112
game/client/cstrike15/gameui/cvartextentry.cpp
Normal file
@@ -0,0 +1,112 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cvartextentry.h"
|
||||
#include "engineinterface.h"
|
||||
#include <vgui/IVGui.h>
|
||||
#include "IGameUIFuncs.h"
|
||||
#include "tier1/keyvalues.h"
|
||||
#include "tier1/convar.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
static const int MAX_CVAR_TEXT = 64;
|
||||
|
||||
CCvarTextEntry::CCvarTextEntry( Panel *parent, const char *panelName, char const *cvarname )
|
||||
: TextEntry( parent, panelName)
|
||||
{
|
||||
m_pszCvarName = cvarname ? strdup( cvarname ) : NULL;
|
||||
m_pszStartValue[0] = 0;
|
||||
|
||||
if ( m_pszCvarName )
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
AddActionSignalTarget( this );
|
||||
}
|
||||
|
||||
CCvarTextEntry::~CCvarTextEntry()
|
||||
{
|
||||
if ( m_pszCvarName )
|
||||
{
|
||||
free( m_pszCvarName );
|
||||
}
|
||||
}
|
||||
|
||||
void CCvarTextEntry::ApplySchemeSettings(IScheme *pScheme)
|
||||
{
|
||||
BaseClass::ApplySchemeSettings(pScheme);
|
||||
if (GetMaximumCharCount() < 0 || GetMaximumCharCount() > MAX_CVAR_TEXT)
|
||||
{
|
||||
SetMaximumCharCount(MAX_CVAR_TEXT - 1);
|
||||
}
|
||||
}
|
||||
|
||||
void CCvarTextEntry::ApplyChanges( bool immediate )
|
||||
{
|
||||
if ( !m_pszCvarName )
|
||||
return;
|
||||
|
||||
char szText[ MAX_CVAR_TEXT ];
|
||||
GetText( szText, MAX_CVAR_TEXT );
|
||||
|
||||
if ( !szText[ 0 ] )
|
||||
return;
|
||||
|
||||
if ( immediate )
|
||||
{
|
||||
// set immediately - don't wait for the next frame
|
||||
ConVarRef newCvar( m_pszCvarName );
|
||||
newCvar.SetValue( szText );
|
||||
}
|
||||
else
|
||||
{
|
||||
char szCommand[ 256 ];
|
||||
Q_snprintf( szCommand, 256, "%s \"%s\"\n", m_pszCvarName, szText );
|
||||
engine->ClientCmd_Unrestricted( szCommand );
|
||||
}
|
||||
|
||||
Q_strncpy( m_pszStartValue, szText, sizeof( m_pszStartValue ) );
|
||||
}
|
||||
|
||||
void CCvarTextEntry::Reset()
|
||||
{
|
||||
// char *value = engine->pfnGetCvarString( m_pszCvarName );
|
||||
ConVarRef var( m_pszCvarName );
|
||||
if ( !var.IsValid() )
|
||||
return;
|
||||
const char *value = var.GetString();
|
||||
if ( value && value[ 0 ] )
|
||||
{
|
||||
SetText( value );
|
||||
Q_strncpy( m_pszStartValue, value, sizeof( m_pszStartValue ) );
|
||||
}
|
||||
}
|
||||
|
||||
bool CCvarTextEntry::HasBeenModified()
|
||||
{
|
||||
char szText[ MAX_CVAR_TEXT ];
|
||||
GetText( szText, MAX_CVAR_TEXT );
|
||||
|
||||
return stricmp( szText, m_pszStartValue ) != 0 ? true : false;
|
||||
}
|
||||
|
||||
|
||||
void CCvarTextEntry::OnTextChanged()
|
||||
{
|
||||
if ( !m_pszCvarName )
|
||||
return;
|
||||
|
||||
if (HasBeenModified())
|
||||
{
|
||||
PostActionSignal(new KeyValues("ControlModified"));
|
||||
}
|
||||
}
|
||||
35
game/client/cstrike15/gameui/cvartextentry.h
Normal file
35
game/client/cstrike15/gameui/cvartextentry.h
Normal file
@@ -0,0 +1,35 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CVARTEXTENTRY_H
|
||||
#define CVARTEXTENTRY_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui_controls/TextEntry.h>
|
||||
|
||||
class CCvarTextEntry : public vgui::TextEntry
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CCvarTextEntry, vgui::TextEntry );
|
||||
|
||||
public:
|
||||
CCvarTextEntry( vgui::Panel *parent, const char *panelName, char const *cvarname );
|
||||
~CCvarTextEntry();
|
||||
|
||||
MESSAGE_FUNC( OnTextChanged, "TextChanged" );
|
||||
void ApplyChanges( bool immediate = false );
|
||||
virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
|
||||
void Reset();
|
||||
bool HasBeenModified();
|
||||
|
||||
private:
|
||||
char *m_pszCvarName;
|
||||
char m_pszStartValue[64];
|
||||
};
|
||||
|
||||
#endif // CVARTEXTENTRY_H
|
||||
157
game/client/cstrike15/gameui/cvartogglecheckbutton.cpp
Normal file
157
game/client/cstrike15/gameui/cvartogglecheckbutton.cpp
Normal file
@@ -0,0 +1,157 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cvartogglecheckbutton.h"
|
||||
#include "engineinterface.h"
|
||||
#include <vgui/IVGui.h>
|
||||
#include "tier1/keyvalues.h"
|
||||
#include "tier1/convar.h"
|
||||
#include "IGameUIFuncs.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
vgui::Panel *CvarToggleCheckButton_Factory()
|
||||
{
|
||||
return new CCvarToggleCheckButton( NULL, NULL, "CvarToggleCheckButton", NULL );
|
||||
}
|
||||
DECLARE_BUILD_FACTORY_CUSTOM( CCvarToggleCheckButton, CvarToggleCheckButton_Factory );
|
||||
|
||||
CCvarToggleCheckButton::CCvarToggleCheckButton( Panel *parent, const char *panelName, const char *text,
|
||||
char const *cvarname )
|
||||
: CheckButton( parent, panelName, text )
|
||||
{
|
||||
m_pszCvarName = cvarname ? strdup( cvarname ) : NULL;
|
||||
|
||||
if (m_pszCvarName)
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
AddActionSignalTarget( this );
|
||||
}
|
||||
|
||||
CCvarToggleCheckButton::~CCvarToggleCheckButton()
|
||||
{
|
||||
if ( m_pszCvarName )
|
||||
{
|
||||
free( m_pszCvarName );
|
||||
}
|
||||
}
|
||||
|
||||
void CCvarToggleCheckButton::Paint()
|
||||
{
|
||||
if ( !m_pszCvarName || !m_pszCvarName[ 0 ] )
|
||||
{
|
||||
BaseClass::Paint();
|
||||
return;
|
||||
}
|
||||
|
||||
// Look up current value
|
||||
// bool value = engine->pfnGetCvarFloat( m_pszCvarName ) > 0.0f ? true : false;
|
||||
ConVarRef var( m_pszCvarName );
|
||||
if ( !var.IsValid() )
|
||||
return;
|
||||
bool value = var.GetBool();
|
||||
|
||||
if ( value != m_bStartValue )
|
||||
//if ( value != IsSelected() )
|
||||
{
|
||||
SetSelected( value );
|
||||
m_bStartValue = value;
|
||||
}
|
||||
BaseClass::Paint();
|
||||
}
|
||||
|
||||
void CCvarToggleCheckButton::ApplyChanges()
|
||||
{
|
||||
if ( !m_pszCvarName || !m_pszCvarName[ 0 ] )
|
||||
return;
|
||||
|
||||
m_bStartValue = IsSelected();
|
||||
// engine->Cvar_SetValue( m_pszCvarName, m_bStartValue ? 1.0f : 0.0f );
|
||||
ConVarRef var( m_pszCvarName );
|
||||
var.SetValue( m_bStartValue );
|
||||
}
|
||||
|
||||
void CCvarToggleCheckButton::Reset()
|
||||
{
|
||||
// m_bStartValue = engine->pfnGetCvarFloat( m_pszCvarName ) > 0.0f ? true : false;
|
||||
|
||||
if ( !m_pszCvarName || !m_pszCvarName[ 0 ] )
|
||||
return;
|
||||
|
||||
ConVarRef var( m_pszCvarName );
|
||||
if ( !var.IsValid() )
|
||||
return;
|
||||
m_bStartValue = var.GetBool();
|
||||
SetSelected(m_bStartValue);
|
||||
}
|
||||
|
||||
bool CCvarToggleCheckButton::HasBeenModified()
|
||||
{
|
||||
return IsSelected() != m_bStartValue;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *panel -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCvarToggleCheckButton::SetSelected( bool state )
|
||||
{
|
||||
BaseClass::SetSelected( state );
|
||||
|
||||
if ( !m_pszCvarName || !m_pszCvarName[ 0 ] )
|
||||
return;
|
||||
/*
|
||||
// Look up current value
|
||||
bool value = state;
|
||||
|
||||
engine->Cvar_SetValue( m_pszCvarName, value ? 1.0f : 0.0f );*/
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCvarToggleCheckButton::OnButtonChecked()
|
||||
{
|
||||
if (HasBeenModified())
|
||||
{
|
||||
PostActionSignal(new KeyValues("ControlModified"));
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CCvarToggleCheckButton::ApplySettings( KeyValues *inResourceData )
|
||||
{
|
||||
BaseClass::ApplySettings( inResourceData );
|
||||
|
||||
const char *cvarName = inResourceData->GetString("cvar_name", "");
|
||||
const char *cvarValue = inResourceData->GetString("cvar_value", "");
|
||||
|
||||
if( Q_stricmp( cvarName, "") == 0 )
|
||||
return;// Doesn't have cvar set up in res file, must have been constructed with it.
|
||||
|
||||
if( m_pszCvarName )
|
||||
free( m_pszCvarName );// got a "", not a NULL from the create-control call
|
||||
|
||||
m_pszCvarName = cvarName ? strdup( cvarName ) : NULL;
|
||||
|
||||
if( Q_stricmp( cvarValue, "1") == 0 )
|
||||
m_bStartValue = true;
|
||||
else
|
||||
m_bStartValue = false;
|
||||
|
||||
const ConVar *var = cvar->FindVar( m_pszCvarName );
|
||||
if ( var )
|
||||
{
|
||||
if( var->GetBool() )
|
||||
SetSelected( true );
|
||||
else
|
||||
SetSelected( false );
|
||||
}
|
||||
}
|
||||
41
game/client/cstrike15/gameui/cvartogglecheckbutton.h
Normal file
41
game/client/cstrike15/gameui/cvartogglecheckbutton.h
Normal file
@@ -0,0 +1,41 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CVARTOGGLECHECKBUTTON_H
|
||||
#define CVARTOGGLECHECKBUTTON_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui_controls/CheckButton.h>
|
||||
|
||||
class CCvarToggleCheckButton : public vgui::CheckButton
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CCvarToggleCheckButton, vgui::CheckButton );
|
||||
|
||||
public:
|
||||
CCvarToggleCheckButton( vgui::Panel *parent, const char *panelName, const char *text,
|
||||
char const *cvarname );
|
||||
~CCvarToggleCheckButton();
|
||||
|
||||
virtual void SetSelected( bool state );
|
||||
|
||||
virtual void Paint();
|
||||
|
||||
void Reset();
|
||||
void ApplyChanges();
|
||||
bool HasBeenModified();
|
||||
virtual void ApplySettings( KeyValues *inResourceData );
|
||||
|
||||
private:
|
||||
MESSAGE_FUNC( OnButtonChecked, "CheckButtonChecked" );
|
||||
|
||||
char *m_pszCvarName;
|
||||
bool m_bStartValue;
|
||||
};
|
||||
|
||||
#endif // CVARTOGGLECHECKBUTTON_H
|
||||
61
game/client/cstrike15/gameui/engineinterface.h
Normal file
61
game/client/cstrike15/gameui/engineinterface.h
Normal file
@@ -0,0 +1,61 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Includes all the headers/declarations necessary to access the
|
||||
// engine interface
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef ENGINEINTERFACE_H
|
||||
#define ENGINEINTERFACE_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
// these stupid set of includes are required to use the cdll_int interface
|
||||
#include "mathlib/vector.h"
|
||||
//#include "wrect.h"
|
||||
#define IN_BUTTONS_H
|
||||
|
||||
// engine interface
|
||||
#include "cdll_int.h"
|
||||
#include "eiface.h"
|
||||
#include "icvar.h"
|
||||
#include "tier2/tier2.h"
|
||||
#include "matchmaking/imatchframework.h"
|
||||
|
||||
#ifdef SWARM_DLL
|
||||
#include "matchmaking/swarm/imatchext_swarm.h"
|
||||
extern class IMatchExtSwarm *g_pMatchExtSwarm;
|
||||
#endif
|
||||
|
||||
#ifdef PORTAL2_UITEST_DLL
|
||||
class IMatchExtPortal2
|
||||
{
|
||||
public:
|
||||
inline KeyValues * GetAllMissions() { return NULL; }
|
||||
inline KeyValues * GetMapInfoByBspName( KeyValues *, char const *, KeyValues ** = NULL ) { return NULL; }
|
||||
inline KeyValues * GetMapInfo( KeyValues *, KeyValues ** = NULL ) { return NULL; }
|
||||
};
|
||||
extern class IMatchExtPortal2 *g_pMatchExtPortal2;
|
||||
#endif
|
||||
|
||||
// engine interface singleton accessors
|
||||
extern IVEngineClient *engine;
|
||||
extern class IBik *bik;
|
||||
extern class IEngineVGui *enginevguifuncs;
|
||||
extern class IGameUIFuncs *gameuifuncs;
|
||||
extern class IEngineSound *enginesound;
|
||||
extern class IXboxSystem *xboxsystem;
|
||||
#ifdef _GAMECONSOLE
|
||||
extern class IXOnline *xonline;
|
||||
#endif
|
||||
extern class IAchievementMgr *achievementmgr;
|
||||
extern class CSteamAPIContext *steamapicontext;
|
||||
#ifdef _PS3
|
||||
#include "ps3/saverestore_ps3_api_ui.h"
|
||||
extern class IPS3SaveRestoreToUI *ps3saveuiapi;
|
||||
#endif
|
||||
|
||||
#endif // ENGINEINTERFACE_H
|
||||
0
game/client/cstrike15/gameui/gameapp.cpp
Normal file
0
game/client/cstrike15/gameui/gameapp.cpp
Normal file
0
game/client/cstrike15/gameui/gameapp.h
Normal file
0
game/client/cstrike15/gameui/gameapp.h
Normal file
170
game/client/cstrike15/gameui/gameconsole.cpp
Normal file
170
game/client/cstrike15/gameui/gameconsole.cpp
Normal file
@@ -0,0 +1,170 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gameconsole.h"
|
||||
#include "gameconsoledialog.h"
|
||||
#include "vgui/ISurface.h"
|
||||
|
||||
#include "keyvalues.h"
|
||||
#include "vgui/vgui.h"
|
||||
#include "vgui/IVGui.h"
|
||||
#include "vgui_controls/Panel.h"
|
||||
#include "convar.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
static CGameConsole g_GameConsole;
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: singleton accessor
|
||||
//-----------------------------------------------------------------------------
|
||||
CGameConsole &GameConsole()
|
||||
{
|
||||
return g_GameConsole;
|
||||
}
|
||||
EXPOSE_SINGLE_INTERFACE_GLOBALVAR(CGameConsole, IGameConsole, GAMECONSOLE_INTERFACE_VERSION, g_GameConsole);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CGameConsole::CGameConsole()
|
||||
{
|
||||
m_bInitialized = false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CGameConsole::~CGameConsole()
|
||||
{
|
||||
m_bInitialized = false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: sets up the console for use
|
||||
//-----------------------------------------------------------------------------
|
||||
void CGameConsole::Initialize()
|
||||
{
|
||||
m_pConsole = vgui::SETUP_PANEL( new CGameConsoleDialog() ); // we add text before displaying this so set it up now!
|
||||
|
||||
// set the console to taking up most of the right-half of the screen
|
||||
int swide, stall;
|
||||
vgui::surface()->GetScreenSize(swide, stall);
|
||||
int offset = vgui::scheme()->GetProportionalScaledValue(16);
|
||||
|
||||
m_pConsole->SetBounds(
|
||||
swide / 2 - (offset * 4),
|
||||
offset,
|
||||
(swide / 2) + (offset * 3),
|
||||
stall - (offset * 8));
|
||||
|
||||
m_pConsole->InvalidateLayout( false, true );
|
||||
|
||||
m_bInitialized = true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: activates the console, makes it visible and brings it to the foreground
|
||||
//-----------------------------------------------------------------------------
|
||||
void CGameConsole::Activate()
|
||||
{
|
||||
if (!m_bInitialized)
|
||||
return;
|
||||
|
||||
vgui::surface()->RestrictPaintToSinglePanel(NULL);
|
||||
m_pConsole->Activate();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: hides the console
|
||||
//-----------------------------------------------------------------------------
|
||||
void CGameConsole::Hide()
|
||||
{
|
||||
if (!m_bInitialized)
|
||||
return;
|
||||
|
||||
m_pConsole->Hide();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: skips animation and forces the immediate hiding of the panel
|
||||
//-----------------------------------------------------------------------------
|
||||
void CGameConsole::HideImmediately ( void )
|
||||
{
|
||||
if ( !m_bInitialized )
|
||||
return;
|
||||
|
||||
m_pConsole->SetVisible( false );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: clears the console
|
||||
//-----------------------------------------------------------------------------
|
||||
void CGameConsole::Clear()
|
||||
{
|
||||
if (!m_bInitialized)
|
||||
return;
|
||||
|
||||
m_pConsole->Clear();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: returns true if the console is currently in focus
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CGameConsole::IsConsoleVisible()
|
||||
{
|
||||
if (!m_bInitialized)
|
||||
return false;
|
||||
|
||||
return m_pConsole->IsVisible();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: activates the console after a delay
|
||||
//-----------------------------------------------------------------------------
|
||||
void CGameConsole::ActivateDelayed(float time)
|
||||
{
|
||||
if (!m_bInitialized)
|
||||
return;
|
||||
|
||||
m_pConsole->PostMessage(m_pConsole, new KeyValues("Activate"), time);
|
||||
}
|
||||
|
||||
void CGameConsole::SetParent( int parent )
|
||||
{
|
||||
if (!m_bInitialized)
|
||||
return;
|
||||
|
||||
m_pConsole->SetParent( static_cast<vgui::VPANEL>( parent ));
|
||||
}
|
||||
|
||||
void CGameConsole::Shutdown( void )
|
||||
{
|
||||
if ( m_pConsole && m_bInitialized)
|
||||
{
|
||||
HideImmediately();
|
||||
m_pConsole->MarkForDeletion();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: static command handler
|
||||
//-----------------------------------------------------------------------------
|
||||
void CGameConsole::OnCmdCondump()
|
||||
{
|
||||
g_GameConsole.m_pConsole->DumpConsoleTextToFile();
|
||||
}
|
||||
|
||||
CON_COMMAND( condump, "dump the text currently in the console to condumpXX.log" )
|
||||
{
|
||||
g_GameConsole.OnCmdCondump();
|
||||
}
|
||||
59
game/client/cstrike15/gameui/gameconsole.h
Normal file
59
game/client/cstrike15/gameui/gameconsole.h
Normal file
@@ -0,0 +1,59 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef GAMECONSOLE_H
|
||||
#define GAMECONSOLE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "GameUI/IGameConsole.h"
|
||||
|
||||
class CGameConsoleDialog;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: VGui implementation of the game/dev console
|
||||
//-----------------------------------------------------------------------------
|
||||
class CGameConsole : public IGameConsole
|
||||
{
|
||||
public:
|
||||
CGameConsole();
|
||||
~CGameConsole();
|
||||
|
||||
// sets up the console for use
|
||||
void Initialize();
|
||||
|
||||
// activates the console, makes it visible and brings it to the foreground
|
||||
virtual void Activate();
|
||||
// hides the console
|
||||
virtual void Hide();
|
||||
// clears the console
|
||||
virtual void Clear();
|
||||
|
||||
void HideImmediately( void );
|
||||
|
||||
// returns true if the console is currently in focus
|
||||
virtual bool IsConsoleVisible();
|
||||
|
||||
// activates the console after a delay
|
||||
void ActivateDelayed(float time);
|
||||
|
||||
void SetParent( int parent );
|
||||
|
||||
// hides and deletes panel
|
||||
void Shutdown( void );
|
||||
|
||||
static void OnCmdCondump();
|
||||
private:
|
||||
|
||||
bool m_bInitialized;
|
||||
CGameConsoleDialog *m_pConsole;
|
||||
};
|
||||
|
||||
extern CGameConsole &GameConsole();
|
||||
|
||||
#endif // GAMECONSOLE_H
|
||||
95
game/client/cstrike15/gameui/gameconsoledialog.cpp
Normal file
95
game/client/cstrike15/gameui/gameconsoledialog.cpp
Normal file
@@ -0,0 +1,95 @@
|
||||
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
|
||||
#include "gameconsoledialog.h"
|
||||
#include "gameui_interface.h"
|
||||
#include "vgui/IInput.h"
|
||||
#include "vgui/ISurface.h"
|
||||
#include "vgui/KeyCode.h"
|
||||
#include "IGameUIFuncs.h"
|
||||
#include "CegClientWrapper.h"
|
||||
#include "gameconsole.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CGameConsoleDialog::CGameConsoleDialog() : BaseClass( NULL, "GameConsole", false )
|
||||
{
|
||||
AddActionSignalTarget( this );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: generic vgui command handler
|
||||
//-----------------------------------------------------------------------------
|
||||
void CGameConsoleDialog::OnCommand(const char *command)
|
||||
{
|
||||
if ( !Q_stricmp( command, "Close" ) )
|
||||
{
|
||||
if ( GameUI().IsInBackgroundLevel() )
|
||||
{
|
||||
// Tell the engine we've hid the console, so that it unpauses the game
|
||||
// even though we're still sitting at the menu.
|
||||
engine->ClientCmd_Unrestricted( "unpause" );
|
||||
}
|
||||
}
|
||||
|
||||
BaseClass::OnCommand(command);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// HACK: Allow F key bindings to operate even when typing in the text entry field
|
||||
//-----------------------------------------------------------------------------
|
||||
CEG_NOINLINE void CGameConsoleDialog::OnKeyCodeTyped(KeyCode code)
|
||||
{
|
||||
BaseClass::OnKeyCodeTyped(code);
|
||||
|
||||
// check for processing
|
||||
if ( m_pConsolePanel->TextEntryHasFocus() )
|
||||
{
|
||||
// HACK: Allow F key bindings to operate even here
|
||||
if ( code >= KEY_F1 && code <= KEY_F12 )
|
||||
{
|
||||
// See if there is a binding for the FKey
|
||||
const char *binding = gameuifuncs->GetBindingForButtonCode( code );
|
||||
if ( binding && binding[0] )
|
||||
{
|
||||
// submit the entry as a console commmand
|
||||
char szCommand[256];
|
||||
Q_strncpy( szCommand, binding, sizeof( szCommand ) );
|
||||
engine->ClientCmd_Unrestricted( szCommand, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CEG_PROTECT_VIRTUAL_FUNCTION( CGameConsoleDialog_OnKeyCodeTyped );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Submits a command
|
||||
//-----------------------------------------------------------------------------
|
||||
void CGameConsoleDialog::OnCommandSubmitted( const char *pCommand )
|
||||
{
|
||||
engine->ClientCmd_Unrestricted( pCommand, true );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Submits a command
|
||||
//-----------------------------------------------------------------------------
|
||||
void CGameConsoleDialog::OnClosedByHittingTilde()
|
||||
{
|
||||
GameConsole().HideImmediately();
|
||||
}
|
||||
40
game/client/cstrike15/gameui/gameconsoledialog.h
Normal file
40
game/client/cstrike15/gameui/gameconsoledialog.h
Normal file
@@ -0,0 +1,40 @@
|
||||
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef GAMECONSOLEDIALOG_H
|
||||
#define GAMECONSOLEDIALOG_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui_controls/consoledialog.h"
|
||||
#include <color.h>
|
||||
#include "utlvector.h"
|
||||
#include "engineinterface.h"
|
||||
#include "vgui_controls/Frame.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Game/dev console dialog
|
||||
//-----------------------------------------------------------------------------
|
||||
class CGameConsoleDialog : public vgui::CConsoleDialog
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CGameConsoleDialog, vgui::CConsoleDialog );
|
||||
|
||||
public:
|
||||
CGameConsoleDialog();
|
||||
|
||||
private:
|
||||
MESSAGE_FUNC( OnClosedByHittingTilde, "ClosedByHittingTilde" );
|
||||
MESSAGE_FUNC_CHARPTR( OnCommandSubmitted, "CommandSubmitted", command );
|
||||
|
||||
virtual void OnKeyCodeTyped( vgui::KeyCode code );
|
||||
virtual void OnCommand( const char *command );
|
||||
};
|
||||
|
||||
|
||||
#endif // GAMECONSOLEDIALOG_H
|
||||
25
game/client/cstrike15/gameui/gameui.h
Normal file
25
game/client/cstrike15/gameui/gameui.h
Normal file
@@ -0,0 +1,25 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef GAMEUI_H
|
||||
#define GAMEUI_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class IGameUI;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Accessor function to get game ui interface
|
||||
//-----------------------------------------------------------------------------
|
||||
inline IGameUI *gameui()
|
||||
{
|
||||
extern IGameUI *g_pGameUI;
|
||||
return g_pGameUI;
|
||||
}
|
||||
|
||||
#endif // GAMEUI_H
|
||||
1524
game/client/cstrike15/gameui/gameui_interface.cpp
Normal file
1524
game/client/cstrike15/gameui/gameui_interface.cpp
Normal file
File diff suppressed because it is too large
Load Diff
226
game/client/cstrike15/gameui/gameui_interface.h
Normal file
226
game/client/cstrike15/gameui/gameui_interface.h
Normal file
@@ -0,0 +1,226 @@
|
||||
//========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Defines the interface that the GameUI dll exports
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef GAMEUI_INTERFACE_H
|
||||
#define GAMEUI_INTERFACE_H
|
||||
#pragma once
|
||||
|
||||
#include "GameUI/IGameUI.h"
|
||||
|
||||
#include "vgui_controls/Panel.h"
|
||||
#include "vgui_controls/PHandle.h"
|
||||
#include "convar.h"
|
||||
|
||||
#if defined( INCLUDE_SCALEFORM )
|
||||
#include "scaleformui/scaleformui.h"
|
||||
#endif
|
||||
|
||||
#include "uicomponents/uicomponent_common.h"
|
||||
|
||||
#if defined(_PS3)
|
||||
#define BACKGROUND_MUSIC_FILENAME "gamestartup.ps3.wav"
|
||||
#else
|
||||
#define BACKGROUND_MUSIC_FILENAME "mainmenu.mp3"
|
||||
#endif
|
||||
|
||||
#define MAX_BACKGROUND_MUSIC 3
|
||||
|
||||
class IGameClientExports;
|
||||
class CCommand;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Implementation of GameUI's exposed interface
|
||||
//-----------------------------------------------------------------------------
|
||||
class CGameUI : public IGameUI
|
||||
{
|
||||
public:
|
||||
CGameUI();
|
||||
~CGameUI();
|
||||
|
||||
virtual void Initialize( CreateInterfaceFn appFactory );
|
||||
virtual void Connect( CreateInterfaceFn gameFactory );
|
||||
virtual void Start();
|
||||
virtual void Shutdown();
|
||||
virtual void RunFrame();
|
||||
virtual void PostInit();
|
||||
|
||||
// plays the startup mp3 when GameUI starts
|
||||
void PlayGameStartupSound();
|
||||
|
||||
// Engine wrappers for activating / hiding the gameUI
|
||||
void ActivateGameUI();
|
||||
void HideGameUI();
|
||||
|
||||
// Toggle allowing the engine to hide the game UI with the escape key
|
||||
void PreventEngineHideGameUI();
|
||||
void AllowEngineHideGameUI();
|
||||
|
||||
virtual void SetLoadingBackgroundDialog( vgui::VPANEL panel );
|
||||
|
||||
// notifications
|
||||
virtual void OnGameUIActivated();
|
||||
virtual void OnGameUIHidden();
|
||||
virtual void OLD_OnConnectToServer( const char *game, int IP, int port ); // OLD: use OnConnectToServer2
|
||||
virtual void OnConnectToServer2( const char *game, int IP, int connectionPort, int queryPort );
|
||||
virtual void OnDisconnectFromServer( uint8 eSteamLoginFailure );
|
||||
virtual void OnLevelLoadingStarted( const char *levelName, bool bShowProgressDialog );
|
||||
virtual void OnLevelLoadingFinished( bool bError, const char *failureReason, const char *extendedReason );
|
||||
virtual void OnDisconnectFromServer_OLD( uint8 eSteamLoginFailure, const char *username ) { OnDisconnectFromServer( eSteamLoginFailure ); }
|
||||
virtual void StartLoadingScreenForCommand( const char* command );
|
||||
virtual void StartLoadingScreenForKeyValues( KeyValues* keyValues );
|
||||
|
||||
// progress
|
||||
virtual bool UpdateProgressBar(float progress, const char *statusText, bool showDialog = true );
|
||||
// Shows progress desc, returns previous setting... (used with custom progress bars )
|
||||
virtual bool SetShowProgressText( bool show );
|
||||
virtual bool UpdateSecondaryProgressBar(float progress, const wchar_t *desc );
|
||||
|
||||
// Xbox 360
|
||||
virtual void ShowMessageDialog( const uint nType, vgui::Panel *pOwner = NULL );
|
||||
virtual void ShowMessageDialog( const char* messageID, const char* titleID );
|
||||
|
||||
virtual void CreateCommandMsgBox( const char* pszTitle, const char* pszMessage, bool showOk = true, bool showCancel = false, const char* okCommand = NULL, const char* cancelCommand = NULL, const char* closedCommand = NULL, const char* pszLegend = NULL );
|
||||
virtual void CreateCommandMsgBoxInSlot( ECommandMsgBoxSlot slot, const char* pszTitle, const char* pszMessage, bool showOk = true, bool showCancel = false, const char* okCommand = NULL, const char* cancelCommand = NULL, const char* closedCommand = NULL, const char* pszLegend = NULL );
|
||||
|
||||
|
||||
// Allows the level loading progress to show map-specific info
|
||||
virtual void SetProgressLevelName( const char *levelName );
|
||||
|
||||
virtual void NeedConnectionProblemWaitScreen();
|
||||
|
||||
virtual void ShowPasswordUI( char const *pchCurrentPW );
|
||||
|
||||
virtual bool LoadingProgressWantsIsolatedRender( bool bContextValid );
|
||||
|
||||
virtual void RestoreTopLevelMenu();
|
||||
|
||||
virtual void SetProgressOnStart();
|
||||
|
||||
#if defined( _GAMECONSOLE ) && defined( _DEMO )
|
||||
virtual void OnDemoTimeout();
|
||||
#endif
|
||||
|
||||
// state
|
||||
bool IsInLevel();
|
||||
bool IsInBackgroundLevel();
|
||||
bool IsInMultiplayer();
|
||||
bool IsConsoleUI();
|
||||
bool HasSavedThisMenuSession();
|
||||
void SetSavedThisMenuSession( bool bState );
|
||||
|
||||
void ShowLoadingBackgroundDialog();
|
||||
void HideLoadingBackgroundDialog();
|
||||
bool HasLoadingBackgroundDialog();
|
||||
|
||||
virtual bool IsPlayingFullScreenVideo();
|
||||
|
||||
virtual bool IsTransitionEffectEnabled();
|
||||
|
||||
void SetBackgroundMusicDesired( bool bPlayMusic );
|
||||
|
||||
void SetPreviewBackgroundMusic( const char * pchPreviewMusicPrefix );
|
||||
|
||||
void ReleaseBackgroundMusic( void );
|
||||
|
||||
void StartBackgroundMusicFade( void );
|
||||
|
||||
void PlayQuestAudio( const char * pchAudioFile );
|
||||
void StopQuestAudio( void );
|
||||
bool IsQuestAudioPlaying( void );
|
||||
|
||||
#ifdef PANORAMA_ENABLE
|
||||
void ChangeGameUIState(CSGOGameUIState_t nNewState);
|
||||
CSGOGameUIState_t GetGameUIState();
|
||||
void RegisterGameUIStateListener(ICSGOGameUIStateListener *pListener);
|
||||
void UnregisterGameUIStateListener(ICSGOGameUIStateListener *pListener);
|
||||
#endif // PANORAMA_ENABLE
|
||||
CUtlVector< IUiComponentGlobalInstanceBase * > & GetUiComponents()
|
||||
{
|
||||
return m_arrUiComponents;
|
||||
}
|
||||
|
||||
private:
|
||||
void SendConnectedToGameMessage();
|
||||
|
||||
virtual void StartProgressBar();
|
||||
virtual bool ContinueProgressBar(float progressFraction, bool showDialog = true );
|
||||
virtual void StopProgressBar(bool bError, const char *failureReason, const char *extendedReason = NULL);
|
||||
virtual bool SetProgressBarStatusText(const char *statusText, bool showDialog = true );
|
||||
|
||||
//!! these functions currently not implemented
|
||||
virtual void SetSecondaryProgressBar(float progress /* range [0..1] */);
|
||||
virtual void SetSecondaryProgressBarText( const wchar_t *desc );
|
||||
|
||||
bool FindPlatformDirectory(char *platformDir, int bufferSize);
|
||||
void GetUpdateVersion( char *pszProd, char *pszVer);
|
||||
void ValidateCDKey();
|
||||
|
||||
|
||||
bool IsBackgroundMusicPlaying( void );
|
||||
void UpdateBackgroundMusic( void );
|
||||
|
||||
CreateInterfaceFn m_GameFactory;
|
||||
|
||||
bool m_bTryingToLoadFriends : 1;
|
||||
bool m_bActivatedUI : 1;
|
||||
bool m_bIsConsoleUI : 1;
|
||||
bool m_bHasSavedThisMenuSession : 1;
|
||||
bool m_bOpenProgressOnStart : 1;
|
||||
|
||||
int m_iGameIP;
|
||||
int m_iGameConnectionPort;
|
||||
int m_iGameQueryPort;
|
||||
|
||||
int m_iFriendsLoadPauseFrames;
|
||||
int m_iPlayGameStartupSound;
|
||||
|
||||
char m_szPreviousStatusText[128];
|
||||
char m_szPlatformDir[MAX_PATH];
|
||||
|
||||
vgui::DHANDLE<class CCDKeyEntryDialog> m_hCDKeyEntryDialog;
|
||||
|
||||
int m_nBackgroundMusicGUID;
|
||||
bool m_bBackgroundMusicDesired;
|
||||
int m_nBackgroundMusicVersion;
|
||||
float m_flBackgroundMusicStopTime;
|
||||
const char *m_pMusicExtension;
|
||||
|
||||
const char *m_pPreviewMusicExtension;
|
||||
float m_flMainMenuMusicVolume;
|
||||
float m_flMasterMusicVolume;
|
||||
|
||||
float m_flQuestAudioTimeEnd;
|
||||
float m_flMasterMusicVolumeSavedForMissionAudio;
|
||||
float m_flMenuMusicVolumeSavedForMissionAudio;
|
||||
|
||||
int m_nQuestAudioGUID;
|
||||
|
||||
const char * m_pAudioFile;
|
||||
|
||||
#ifdef PANORAMA_ENABLE
|
||||
CSGOGameUIState_t m_CSGOGameUIState;
|
||||
CUtlVector< ICSGOGameUIStateListener* > m_GameUIStateListeners;
|
||||
|
||||
bool m_bFirstActivationForSession = true;
|
||||
bool m_bInLevelLoading = false;
|
||||
#endif
|
||||
CUtlVector< IUiComponentGlobalInstanceBase * > m_arrUiComponents;
|
||||
|
||||
};
|
||||
|
||||
// Purpose: singleton accessor
|
||||
extern CGameUI &GameUI();
|
||||
|
||||
// expose client interface
|
||||
extern IGameClientExports *GameClientExports();
|
||||
|
||||
#if defined(INCLUDE_SCALEFORM)
|
||||
extern IScaleformUI* ScaleformUI();
|
||||
#endif
|
||||
|
||||
|
||||
#endif // GAMEUI_INTERFACE_H
|
||||
211
game/client/cstrike15/gameui/gameui_util.cpp
Normal file
211
game/client/cstrike15/gameui/gameui_util.cpp
Normal file
@@ -0,0 +1,211 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $Workfile: $
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include <stdarg.h>
|
||||
#include "gameui_util.h"
|
||||
#include "strtools.h"
|
||||
#include "engineinterface.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
static int g_nGameUIActiveSplitscreenPlayerSlot = 0;
|
||||
|
||||
int GetGameUIActiveSplitScreenPlayerSlot()
|
||||
{
|
||||
return g_nGameUIActiveSplitscreenPlayerSlot;
|
||||
}
|
||||
|
||||
void SetGameUIActiveSplitScreenPlayerSlot( int nSlot )
|
||||
{
|
||||
if ( g_nGameUIActiveSplitscreenPlayerSlot != nSlot )
|
||||
{
|
||||
g_nGameUIActiveSplitscreenPlayerSlot = nSlot;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Scans player names
|
||||
//Passes the player name to be checked in a KeyValues pointer
|
||||
//with the keyname "name"
|
||||
// - replaces '&' with '&&' so they will draw in the scoreboard
|
||||
// - replaces '#' at the start of the name with '*'
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void GameUI_MakeSafeName( const char *oldName, char *newName, int newNameBufSize )
|
||||
{
|
||||
if ( !oldName )
|
||||
{
|
||||
newName[0] = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
int newpos = 0;
|
||||
|
||||
for( const char *p=oldName; *p != 0 && newpos < newNameBufSize-1; p++ )
|
||||
{
|
||||
//check for a '#' char at the beginning
|
||||
|
||||
/*
|
||||
if( p == oldName && *p == '#' )
|
||||
{
|
||||
newName[newpos] = '*';
|
||||
newpos++;
|
||||
}
|
||||
else */
|
||||
|
||||
if( *p == '%' )
|
||||
{
|
||||
// remove % chars
|
||||
newName[newpos] = '*';
|
||||
newpos++;
|
||||
}
|
||||
else if( *p == '&' )
|
||||
{
|
||||
//insert another & after this one
|
||||
if ( newpos+2 < newNameBufSize )
|
||||
{
|
||||
newName[newpos] = '&';
|
||||
newName[newpos+1] = '&';
|
||||
newpos+=2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newName[newpos] = *p;
|
||||
newpos++;
|
||||
}
|
||||
}
|
||||
newName[newpos] = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Performs a var args printf into a static return buffer
|
||||
// Input : *format -
|
||||
// ... -
|
||||
// Output : char
|
||||
//-----------------------------------------------------------------------------
|
||||
// Unused :: char *VarArgs( PRINTF_FORMAT_STRING const char *format, ... );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// This version is simply used to make reading convars simpler.
|
||||
// Writing convars isn't allowed in this mode
|
||||
//-----------------------------------------------------------------------------
|
||||
class CEmptyGameUIConVar : public ConVar
|
||||
{
|
||||
public:
|
||||
CEmptyGameUIConVar() : ConVar( "", "0" ) {}
|
||||
// Used for optimal read access
|
||||
virtual void SetValue( const char *pValue ) {}
|
||||
virtual void SetValue( float flValue ) {}
|
||||
virtual void SetValue( int nValue ) {}
|
||||
virtual const char *GetName( void ) const { return ""; }
|
||||
virtual bool IsFlagSet( int nFlags ) const { return false; }
|
||||
};
|
||||
|
||||
static CEmptyGameUIConVar s_EmptyConVar;
|
||||
|
||||
// Helper for splitscreen ConVars
|
||||
CGameUIConVarRef::CGameUIConVarRef( const char *pName )
|
||||
{
|
||||
Init( pName, false );
|
||||
}
|
||||
|
||||
CGameUIConVarRef::CGameUIConVarRef( const char *pName, bool bIgnoreMissing )
|
||||
{
|
||||
Init( pName, bIgnoreMissing );
|
||||
}
|
||||
|
||||
void CGameUIConVarRef::Init( const char *pName, bool bIgnoreMissing )
|
||||
{
|
||||
for ( int i = 0; i < MAX_SPLITSCREEN_CLIENTS; ++i )
|
||||
{
|
||||
cv_t &info = m_Info[ i ];
|
||||
char pchName[ 256 ];
|
||||
if ( i != 0 )
|
||||
{
|
||||
Q_snprintf( pchName, sizeof( pchName ), "%s%d", pName, i + 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_strncpy( pchName, pName, sizeof( pchName ) );
|
||||
}
|
||||
|
||||
info.m_pConVar = g_pCVar ? g_pCVar->FindVar( pchName ) : &s_EmptyConVar;
|
||||
if ( !info.m_pConVar )
|
||||
{
|
||||
info.m_pConVar = &s_EmptyConVar;
|
||||
if ( i > 0 )
|
||||
{
|
||||
// Point at slot zero instead, in case we got in here with a non FCVAR_SS var...
|
||||
info.m_pConVar = m_Info[ 0 ].m_pConVar;
|
||||
}
|
||||
}
|
||||
info.m_pConVarState = static_cast< ConVar * >( info.m_pConVar );
|
||||
}
|
||||
|
||||
if ( !IsValid() )
|
||||
{
|
||||
static bool bFirst = true;
|
||||
if ( g_pCVar || bFirst )
|
||||
{
|
||||
if ( !bIgnoreMissing )
|
||||
{
|
||||
Warning( "CGameUIConVarRef %s doesn't point to an existing ConVar\n", pName );
|
||||
}
|
||||
bFirst = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CGameUIConVarRef::CGameUIConVarRef( IConVar *pConVar )
|
||||
{
|
||||
cv_t &info = m_Info[ 0 ];
|
||||
info.m_pConVar = pConVar ? pConVar : &s_EmptyConVar;
|
||||
info.m_pConVarState = static_cast< ConVar * >( info.m_pConVar );
|
||||
|
||||
for ( int i = 1; i < MAX_SPLITSCREEN_CLIENTS; ++i )
|
||||
{
|
||||
info = m_Info[ i ];
|
||||
char pchName[ 256 ];
|
||||
Q_snprintf( pchName, sizeof( pchName ), "%s%d", pConVar->GetName(), i + 1 );
|
||||
|
||||
info.m_pConVar = g_pCVar ? g_pCVar->FindVar( pchName ) : &s_EmptyConVar;
|
||||
if ( !info.m_pConVar )
|
||||
{
|
||||
info.m_pConVar = &s_EmptyConVar;
|
||||
if ( i > 0 )
|
||||
{
|
||||
// Point at slot zero instead, in case we got in here with a non FCVAR_SS var...
|
||||
info.m_pConVar = m_Info[ 0 ].m_pConVar;
|
||||
}
|
||||
}
|
||||
info.m_pConVarState = static_cast< ConVar * >( info.m_pConVar );
|
||||
}
|
||||
}
|
||||
|
||||
bool CGameUIConVarRef::IsValid() const
|
||||
{
|
||||
return m_Info[ 0 ].m_pConVar != &s_EmptyConVar;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
CGameUiSetActiveSplitScreenPlayerGuard::CGameUiSetActiveSplitScreenPlayerGuard( int slot )
|
||||
{
|
||||
m_nSaveSlot = engine->GetActiveSplitScreenPlayerSlot();
|
||||
engine->SetActiveSplitScreenPlayerSlot( slot );
|
||||
}
|
||||
|
||||
CGameUiSetActiveSplitScreenPlayerGuard::~CGameUiSetActiveSplitScreenPlayerGuard()
|
||||
{
|
||||
engine->SetActiveSplitScreenPlayerSlot( m_nSaveSlot );
|
||||
}
|
||||
|
||||
178
game/client/cstrike15/gameui/gameui_util.h
Normal file
178
game/client/cstrike15/gameui/gameui_util.h
Normal file
@@ -0,0 +1,178 @@
|
||||
//====== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. =======
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef GAMEUI_UTIL_H
|
||||
#define GAMEUI_UTIL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
// Set by the player who "owns" the gameui/settings/etc.
|
||||
void SetGameUIActiveSplitScreenPlayerSlot( int nSlot );
|
||||
int GetGameUIActiveSplitScreenPlayerSlot();
|
||||
|
||||
#include "tier1/convar.h"
|
||||
|
||||
void GameUI_MakeSafeName( const char *oldName, char *newName, int newNameBufSize );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Useful for game ui since game ui has a single active "splitscreen" owner and since
|
||||
// it can gracefully handle non-FCVAR_SS vars without code changes required.
|
||||
//-----------------------------------------------------------------------------
|
||||
class CGameUIConVarRef
|
||||
{
|
||||
public:
|
||||
explicit CGameUIConVarRef( const char *pName );
|
||||
CGameUIConVarRef( const char *pName, bool bIgnoreMissing );
|
||||
explicit CGameUIConVarRef( IConVar *pConVar );
|
||||
|
||||
void Init( const char *pName, bool bIgnoreMissing );
|
||||
bool IsValid() const;
|
||||
bool IsFlagSet( int nFlags ) const;
|
||||
|
||||
// Get/Set value
|
||||
float GetFloat( int iSlot = -1 ) const;
|
||||
int GetInt( int iSlot = -1 ) const;
|
||||
float GetMin( int iSlot = -1 ) const;
|
||||
float GetMax( int iSlot = -1 ) const;
|
||||
bool GetBool( int iSlot = -1 ) const { return !!GetInt(); }
|
||||
const char *GetString( int iSlot = -1 ) const;
|
||||
|
||||
void SetValue( const char *pValue, int iSlot = -1 );
|
||||
void SetValue( float flValue, int iSlot = -1 );
|
||||
void SetValue( int nValue, int iSlot = -1 );
|
||||
void SetValue( bool bValue, int iSlot = -1 );
|
||||
|
||||
const char *GetName( int iSlot = -1 ) const;
|
||||
|
||||
const char *GetDefault() const;
|
||||
|
||||
const char *GetBaseName() const;
|
||||
|
||||
protected:
|
||||
int GetActiveSplitScreenPlayerSlot() const;
|
||||
private:
|
||||
struct cv_t
|
||||
{
|
||||
IConVar *m_pConVar;
|
||||
ConVar *m_pConVarState;
|
||||
};
|
||||
|
||||
cv_t m_Info[ MAX_SPLITSCREEN_CLIENTS ];
|
||||
};
|
||||
|
||||
// In GAMUI we should never use the regular ConVarRef
|
||||
#define ConVarRef CGameUIConVarRef
|
||||
|
||||
FORCEINLINE int CGameUIConVarRef::GetActiveSplitScreenPlayerSlot() const
|
||||
{
|
||||
return GetGameUIActiveSplitScreenPlayerSlot();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Did we find an existing convar of that name?
|
||||
//-----------------------------------------------------------------------------
|
||||
FORCEINLINE bool CGameUIConVarRef::IsFlagSet( int nFlags ) const
|
||||
{
|
||||
return ( m_Info[ 0 ].m_pConVar->IsFlagSet( nFlags ) != 0 );
|
||||
}
|
||||
|
||||
FORCEINLINE const char *CGameUIConVarRef::GetName( int iSlot ) const
|
||||
{
|
||||
int nSlot = iSlot == -1 ? GetActiveSplitScreenPlayerSlot() : iSlot;
|
||||
return m_Info[ nSlot ].m_pConVar->GetName();
|
||||
}
|
||||
|
||||
FORCEINLINE const char *CGameUIConVarRef::GetBaseName() const
|
||||
{
|
||||
return m_Info[ 0 ].m_pConVar->GetBaseName();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Return ConVar value as a float
|
||||
//-----------------------------------------------------------------------------
|
||||
FORCEINLINE float CGameUIConVarRef::GetFloat( int iSlot ) const
|
||||
{
|
||||
int nSlot = iSlot == -1 ? GetActiveSplitScreenPlayerSlot() : iSlot;
|
||||
return m_Info[ nSlot ].m_pConVarState->GetFloat();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Return ConVar value as an int
|
||||
//-----------------------------------------------------------------------------
|
||||
FORCEINLINE int CGameUIConVarRef::GetInt( int iSlot ) const
|
||||
{
|
||||
int nSlot = iSlot == -1 ? GetActiveSplitScreenPlayerSlot() : iSlot;
|
||||
return m_Info[ nSlot ].m_pConVarState->GetInt();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Return ConVar value as a string, return "" for bogus string pointer, etc.
|
||||
//-----------------------------------------------------------------------------
|
||||
FORCEINLINE const char *CGameUIConVarRef::GetString( int iSlot ) const
|
||||
{
|
||||
Assert( !IsFlagSet( FCVAR_NEVER_AS_STRING ) );
|
||||
int nSlot = iSlot == -1 ? GetActiveSplitScreenPlayerSlot() : iSlot;
|
||||
return m_Info[ nSlot ].m_pConVarState->GetString();
|
||||
}
|
||||
|
||||
FORCEINLINE_CVAR float CGameUIConVarRef::GetMax( int iSlot ) const
|
||||
{
|
||||
int nSlot = iSlot == -1 ? GetActiveSplitScreenPlayerSlot() : iSlot;
|
||||
return m_Info[ nSlot ].m_pConVarState->GetMaxValue();
|
||||
}
|
||||
|
||||
// [jbright] - Convenience function for retrieving the min value of the convar
|
||||
FORCEINLINE_CVAR float CGameUIConVarRef::GetMin( int iSlot ) const
|
||||
{
|
||||
int nSlot = iSlot == -1 ? GetActiveSplitScreenPlayerSlot() : iSlot;
|
||||
return m_Info[ nSlot ].m_pConVarState->GetMinValue();
|
||||
}
|
||||
|
||||
|
||||
FORCEINLINE void CGameUIConVarRef::SetValue( const char *pValue, int iSlot )
|
||||
{
|
||||
int nSlot = iSlot == -1 ? GetActiveSplitScreenPlayerSlot() : iSlot;
|
||||
m_Info[ nSlot ].m_pConVar->SetValue( pValue );
|
||||
}
|
||||
|
||||
FORCEINLINE void CGameUIConVarRef::SetValue( float flValue, int iSlot )
|
||||
{
|
||||
int nSlot = iSlot == -1 ? GetActiveSplitScreenPlayerSlot() : iSlot;
|
||||
m_Info[ nSlot ].m_pConVar->SetValue( flValue );
|
||||
}
|
||||
|
||||
FORCEINLINE void CGameUIConVarRef::SetValue( int nValue, int iSlot )
|
||||
{
|
||||
int nSlot = iSlot == -1 ? GetActiveSplitScreenPlayerSlot() : iSlot;
|
||||
m_Info[ nSlot ].m_pConVar->SetValue( nValue );
|
||||
}
|
||||
|
||||
FORCEINLINE void CGameUIConVarRef::SetValue( bool bValue, int iSlot )
|
||||
{
|
||||
int nSlot = iSlot == -1 ? GetActiveSplitScreenPlayerSlot() : iSlot;
|
||||
m_Info[ nSlot ].m_pConVar->SetValue( bValue ? 1 : 0 );
|
||||
}
|
||||
|
||||
FORCEINLINE const char *CGameUIConVarRef::GetDefault() const
|
||||
{
|
||||
return m_Info[ 0 ].m_pConVarState->GetDefault();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class CGameUiSetActiveSplitScreenPlayerGuard
|
||||
{
|
||||
public:
|
||||
explicit CGameUiSetActiveSplitScreenPlayerGuard( int slot );
|
||||
~CGameUiSetActiveSplitScreenPlayerGuard();
|
||||
private:
|
||||
int m_nSaveSlot;
|
||||
};
|
||||
|
||||
#define GAMEUI_ACTIVE_SPLITSCREEN_PLAYER_GUARD( slot ) CGameUiSetActiveSplitScreenPlayerGuard g_UISSGuard( slot );
|
||||
|
||||
#endif // GAMEUI_UTIL_H
|
||||
22
game/client/cstrike15/gameui/gameuipanel.h
Normal file
22
game/client/cstrike15/gameui/gameuipanel.h
Normal file
@@ -0,0 +1,22 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef GAMEUIPANEL_H
|
||||
#define GAMEUIPANEL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
// Retrieve the root panel for the GameUI subsystem
|
||||
namespace vgui
|
||||
{
|
||||
class Panel;
|
||||
};
|
||||
|
||||
vgui::Panel *GetGameUIRootPanel( void );
|
||||
|
||||
#endif // GAMEUIPANEL_H
|
||||
282
game/client/cstrike15/gameui/ironsight_editor.cpp
Normal file
282
game/client/cstrike15/gameui/ironsight_editor.cpp
Normal file
@@ -0,0 +1,282 @@
|
||||
//====== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. =======
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
#include "ienginevgui.h"
|
||||
#include "gameui_interface.h"
|
||||
#include "basepanel.h"
|
||||
|
||||
#include "vgui/ILocalize.h"
|
||||
#include "vgui/ISurface.h"
|
||||
#include "vgui/ISystem.h"
|
||||
#include "vgui/IVGui.h"
|
||||
#include "vgui_controls/PanelListPanel.h"
|
||||
#include "vgui_controls/TextEntry.h"
|
||||
#include "vgui_controls/ListPanel.h"
|
||||
#include "vgui_controls/FileOpenDialog.h"
|
||||
#include "vgui_controls/ComboBox.h"
|
||||
#include "vgui_controls/CheckButton.h"
|
||||
#include "vgui_controls/RadioButton.h"
|
||||
#include "vgui_controls/Slider.h"
|
||||
#include "vgui_controls/MessageBox.h"
|
||||
#include "matsys_controls/colorpickerpanel.h"
|
||||
#include "matsys_controls/vtfpreviewpanel.h"
|
||||
#include "filesystem.h"
|
||||
#include "keyvalues.h"
|
||||
#include "engineinterface.h"
|
||||
#include "gameui_interface.h"
|
||||
#include "vstdlib/random.h"
|
||||
|
||||
#include "ironsight_editor.h"
|
||||
|
||||
#ifdef IRONSIGHT
|
||||
|
||||
CIronSightDialog *g_pIronSightDialog = NULL;
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
extern ConVar ironsight_position;
|
||||
extern ConVar ironsight_angle;
|
||||
extern ConVar ironsight_fov;
|
||||
extern ConVar ironsight_override;
|
||||
extern ConVar ironsight_pivot_forward;
|
||||
extern ConVar ironsight_looseness;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CIronSightDialog::CIronSightDialog(vgui::Panel *parent) : BaseClass(parent, "IronSightDialog")
|
||||
{
|
||||
SetDeleteSelfOnClose(true);
|
||||
SetSizeable( false );
|
||||
|
||||
MoveToCenterOfScreen();
|
||||
|
||||
m_pSliderPosX = new vgui::Slider( this, "SliderPosX" );
|
||||
m_pSliderPosX->AddActionSignalTarget( this );
|
||||
m_pSliderPosX->SetRange( -100, 100 );
|
||||
m_pSliderPosX->SetDragOnRepositionNob( true );
|
||||
|
||||
m_pSliderPosY = new vgui::Slider( this, "SliderPosY" );
|
||||
m_pSliderPosY->AddActionSignalTarget( this );
|
||||
m_pSliderPosY->SetRange( -100, 100 );
|
||||
m_pSliderPosY->SetDragOnRepositionNob( true );
|
||||
|
||||
m_pSliderPosZ = new vgui::Slider( this, "SliderPosZ" );
|
||||
m_pSliderPosZ->AddActionSignalTarget( this );
|
||||
m_pSliderPosZ->SetRange( -100, 100 );
|
||||
m_pSliderPosZ->SetDragOnRepositionNob( true );
|
||||
|
||||
m_pSliderRotX = new vgui::Slider( this, "SliderRotX" );
|
||||
m_pSliderRotX->AddActionSignalTarget( this );
|
||||
m_pSliderRotX->SetRange( -100, 100 );
|
||||
m_pSliderRotX->SetDragOnRepositionNob( true );
|
||||
|
||||
m_pSliderRotY = new vgui::Slider( this, "SliderRotY" );
|
||||
m_pSliderRotY->AddActionSignalTarget( this );
|
||||
m_pSliderRotY->SetRange( -100, 100 );
|
||||
m_pSliderRotY->SetDragOnRepositionNob( true );
|
||||
|
||||
m_pSliderRotZ = new vgui::Slider( this, "SliderRotZ" );
|
||||
m_pSliderRotZ->AddActionSignalTarget( this );
|
||||
m_pSliderRotZ->SetRange( -100, 100 );
|
||||
m_pSliderRotZ->SetDragOnRepositionNob( true );
|
||||
|
||||
m_pSliderFOV = new vgui::Slider( this, "SliderFOV" );
|
||||
m_pSliderFOV->AddActionSignalTarget( this );
|
||||
m_pSliderFOV->SetRange( 10, 90 );
|
||||
m_pSliderFOV->SetDragOnRepositionNob( true );
|
||||
m_pSliderFOV->SetValue(90);
|
||||
|
||||
m_pSliderPivotForward = new vgui::Slider( this, "SliderPivotForward" );
|
||||
m_pSliderPivotForward->AddActionSignalTarget( this );
|
||||
m_pSliderPivotForward->SetRange( -20, 20 );
|
||||
m_pSliderPivotForward->SetDragOnRepositionNob( true );
|
||||
m_pSliderPivotForward->SetValue(0);
|
||||
|
||||
m_pSliderLooseness = new vgui::Slider( this, "SliderLooseness" );
|
||||
m_pSliderLooseness->AddActionSignalTarget( this );
|
||||
m_pSliderLooseness->SetRange( 0, 100 );
|
||||
m_pSliderLooseness->SetDragOnRepositionNob( true );
|
||||
m_pSliderLooseness->SetValue(100);
|
||||
|
||||
m_pSchemaText = new vgui::TextEntry( this, "SchemaText" );
|
||||
m_pSchemaText->AddActionSignalTarget( this );
|
||||
m_pSchemaText->SetMultiline( true );
|
||||
|
||||
LoadControlSettings("Resource/ironsight_dialog.res");
|
||||
|
||||
m_vecPosBackup = Vector(0,0,0);
|
||||
m_vecRotBackup = Vector(0,0,0);
|
||||
|
||||
|
||||
sscanf( ironsight_position.GetString(), "%f %f %f", &m_vecPosBackup.x, &m_vecPosBackup.y, &m_vecPosBackup.z );
|
||||
m_pSliderPosX->SetValue(0);
|
||||
m_pSliderPosY->SetValue(0);
|
||||
m_pSliderPosZ->SetValue(0);
|
||||
|
||||
sscanf( ironsight_angle.GetString(), "%f %f %f", &m_vecRotBackup.x, &m_vecRotBackup.y, &m_vecRotBackup.z );
|
||||
m_pSliderRotX->SetValue(0);
|
||||
m_pSliderRotY->SetValue(0);
|
||||
m_pSliderRotZ->SetValue(0);
|
||||
|
||||
m_pSliderFOV->SetValue( ironsight_fov.GetFloat() );
|
||||
|
||||
m_pSliderPivotForward->SetValue( ironsight_pivot_forward.GetFloat() );
|
||||
|
||||
m_pSliderLooseness->SetValue( ironsight_looseness.GetFloat() * 100.0f );
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CIronSightDialog::~CIronSightDialog()
|
||||
{
|
||||
delete m_pSliderPosX;
|
||||
delete m_pSliderPosY;
|
||||
delete m_pSliderPosZ;
|
||||
|
||||
delete m_pSliderRotX;
|
||||
delete m_pSliderRotY;
|
||||
delete m_pSliderRotZ;
|
||||
|
||||
delete m_pSliderFOV;
|
||||
|
||||
delete m_pSliderPivotForward;
|
||||
|
||||
delete m_pSchemaText;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CIronSightDialog::OnClose( void )
|
||||
{
|
||||
BaseClass::OnClose();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *command -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CIronSightDialog::OnMessage( const KeyValues *pParams, vgui::VPANEL fromPanel )
|
||||
{
|
||||
|
||||
|
||||
if ( !Q_strcmp( "SliderMoved", pParams->GetName() ) )
|
||||
{
|
||||
char szTemp[128];
|
||||
|
||||
V_snprintf( szTemp, 128, "%f %f %f",
|
||||
float( m_vecPosBackup.x + m_pSliderPosX->GetValue() * 0.01f ),
|
||||
float( m_vecPosBackup.y + m_pSliderPosY->GetValue() * 0.01f ),
|
||||
float( m_vecPosBackup.z + m_pSliderPosZ->GetValue() * 0.01f ) );
|
||||
|
||||
//Msg( "ironsight_position: %s\n", szTemp );
|
||||
|
||||
ironsight_position.SetValue( szTemp );
|
||||
|
||||
V_snprintf( szTemp, 128, "%f %f %f",
|
||||
float( m_vecRotBackup.x + m_pSliderRotX->GetValue() * 0.01f ),
|
||||
float( m_vecRotBackup.y + m_pSliderRotY->GetValue() * 0.01f ),
|
||||
float( m_vecRotBackup.z + m_pSliderRotZ->GetValue() * 0.01f ) );
|
||||
|
||||
//Msg( "ironsight_angle: %s\n", szTemp );
|
||||
|
||||
ironsight_angle.SetValue( szTemp );
|
||||
|
||||
ironsight_fov.SetValue( m_pSliderFOV->GetValue() );
|
||||
|
||||
ironsight_pivot_forward.SetValue( m_pSliderPivotForward->GetValue() );
|
||||
|
||||
ironsight_looseness.SetValue( m_pSliderLooseness->GetValue() * 0.01f );
|
||||
|
||||
char szSchemaText[512];
|
||||
V_snprintf(szSchemaText, 512, "\"ironsight eye pos\" \"%s\"\n\"ironsight pivot angle\" \"%s\"\n\"ironsight fov\" \"%s\"\n\"ironsight pivot forward\" \"%s\"\n\"ironsight looseness\" \"%f\"",
|
||||
ironsight_position.GetString(),
|
||||
ironsight_angle.GetString(),
|
||||
ironsight_fov.GetString(),
|
||||
ironsight_pivot_forward.GetString(),
|
||||
ironsight_looseness.GetFloat()
|
||||
);
|
||||
|
||||
m_pSchemaText->SetText( szSchemaText );
|
||||
|
||||
}
|
||||
else if ( !Q_strcmp( "SliderDragEnd", pParams->GetName() ) )
|
||||
{
|
||||
sscanf( ironsight_position.GetString(), "%f %f %f", &m_vecPosBackup.x, &m_vecPosBackup.y, &m_vecPosBackup.z );
|
||||
m_pSliderPosX->SetValue(0);
|
||||
m_pSliderPosY->SetValue(0);
|
||||
m_pSliderPosZ->SetValue(0);
|
||||
|
||||
sscanf( ironsight_angle.GetString(), "%f %f %f", &m_vecRotBackup.x, &m_vecRotBackup.y, &m_vecRotBackup.z );
|
||||
m_pSliderRotX->SetValue(0);
|
||||
m_pSliderRotY->SetValue(0);
|
||||
m_pSliderRotZ->SetValue(0);
|
||||
}
|
||||
else if ( !Q_strcmp( "CloseFrameButtonPressed", pParams->GetName() ) )
|
||||
{
|
||||
Close();
|
||||
}
|
||||
else if ( !Q_strcmp( "CheckButtonChecked", pParams->GetName() ) )
|
||||
{
|
||||
ironsight_override.SetValue( pParams->MakeCopy()->GetInt("state") );
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnMessage( pParams, fromPanel );
|
||||
}
|
||||
|
||||
/*
|
||||
//don't spew these
|
||||
if ( Q_strcmp( "OnMouseFocusTicked", pParams->GetName() ) &&
|
||||
Q_strcmp( "KeyFocusTicked", pParams->GetName() ) &&
|
||||
Q_strcmp( "MouseFocusTicked", pParams->GetName() ) &&
|
||||
Q_strcmp( "CursorMoved", pParams->GetName() ) &&
|
||||
Q_strcmp( "CursorExited", pParams->GetName() ) &&
|
||||
Q_strcmp( "CursorEntered", pParams->GetName() ) &&
|
||||
Q_strcmp( "OnNavigateTo", pParams->GetName() ) &&
|
||||
Q_strcmp( "OnNavigateFrom", pParams->GetName() ) )
|
||||
{
|
||||
Msg( "=========================" );
|
||||
KeyValuesDumpAsDevMsg( pParams->MakeCopy() );
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
//void CIronSightDialog::OnCommand( const char *command )
|
||||
//{
|
||||
// if ( !Q_strcmp( command, "refresh_scheme" ) )
|
||||
// {
|
||||
// LoadControlSettings("Resource/ironsight_dialog.res");
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
CON_COMMAND_F( ironsight_editor, "Edit ironsights.", FCVAR_DONTRECORD | FCVAR_DEVELOPMENTONLY )
|
||||
{
|
||||
g_pIronSightDialog = new CIronSightDialog(NULL);
|
||||
|
||||
vgui::VPANEL parentPanel = enginevgui->GetPanel( PANEL_INGAMESCREENS );
|
||||
g_pIronSightDialog->SetParent( parentPanel );
|
||||
|
||||
g_pIronSightDialog->SetVisible( true );
|
||||
g_pIronSightDialog->Repaint();
|
||||
g_pIronSightDialog->MoveToFront();
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
52
game/client/cstrike15/gameui/ironsight_editor.h
Normal file
52
game/client/cstrike15/gameui/ironsight_editor.h
Normal file
@@ -0,0 +1,52 @@
|
||||
//====== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. =======
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef IRONSIGHTDIALOG_H
|
||||
#define IRONSIGHTDIALOG_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui_controls/Frame.h"
|
||||
#include "cs_shareddefs.h"
|
||||
|
||||
#ifdef IRONSIGHT
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Handles selection of IronSight mode on/off
|
||||
//-----------------------------------------------------------------------------
|
||||
class CIronSightDialog : public vgui::Frame
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CIronSightDialog, vgui::Frame );
|
||||
|
||||
public:
|
||||
CIronSightDialog(vgui::Panel *parent);
|
||||
~CIronSightDialog();
|
||||
|
||||
virtual void OnClose( void );
|
||||
//virtual void OnCommand( const char *command );
|
||||
virtual void OnMessage( const KeyValues *pParams, vgui::VPANEL fromPanel );
|
||||
|
||||
vgui::Slider *m_pSliderPosX;
|
||||
vgui::Slider *m_pSliderPosY;
|
||||
vgui::Slider *m_pSliderPosZ;
|
||||
Vector m_vecPosBackup;
|
||||
|
||||
vgui::Slider *m_pSliderRotX;
|
||||
vgui::Slider *m_pSliderRotY;
|
||||
vgui::Slider *m_pSliderRotZ;
|
||||
Vector m_vecRotBackup;
|
||||
|
||||
vgui::Slider *m_pSliderFOV;
|
||||
|
||||
vgui::Slider *m_pSliderPivotForward;
|
||||
vgui::Slider *m_pSliderLooseness;
|
||||
|
||||
vgui::TextEntry *m_pSchemaText;
|
||||
};
|
||||
#endif //IRONSIGHT
|
||||
|
||||
#endif //IRONSIGHTDIALOG_H
|
||||
118
game/client/cstrike15/gameui/keytogglecheckbutton.cpp
Normal file
118
game/client/cstrike15/gameui/keytogglecheckbutton.cpp
Normal file
@@ -0,0 +1,118 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "keytogglecheckbutton.h"
|
||||
#include "engineinterface.h"
|
||||
#include <vgui/IVGui.h>
|
||||
#include "IGameUIFuncs.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
CKeyToggleCheckButton::CKeyToggleCheckButton( Panel *parent, const char *panelName, const char *text,
|
||||
char const *key, char const *cmdname )
|
||||
: CheckButton( parent, panelName, text )
|
||||
{
|
||||
m_pszKeyName = key ? strdup( key ) : NULL;
|
||||
m_pszCmdName = cmdname ? strdup( cmdname ) : NULL;
|
||||
|
||||
if (m_pszKeyName)
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
//m_bNoCommand = false;
|
||||
}
|
||||
|
||||
CKeyToggleCheckButton::~CKeyToggleCheckButton()
|
||||
{
|
||||
free( m_pszKeyName );
|
||||
free( m_pszCmdName );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CKeyToggleCheckButton::Paint()
|
||||
{
|
||||
BaseClass::Paint();
|
||||
|
||||
if ( !m_pszKeyName )
|
||||
return;
|
||||
|
||||
// Fixme, look up key state
|
||||
bool isdown;
|
||||
if ( gameuifuncs->IsKeyDown( m_pszKeyName, isdown ) )
|
||||
{
|
||||
// if someone changed the value using the consoel
|
||||
if ( m_bStartValue != isdown )
|
||||
{
|
||||
SetSelected( isdown );
|
||||
m_bStartValue = isdown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *panel -
|
||||
//-----------------------------------------------------------------------------
|
||||
/*
|
||||
void CKeyToggleCheckButton::SetSelected( bool state )
|
||||
{
|
||||
BaseClass::SetSelected( state );
|
||||
|
||||
if ( !m_pszCmdName || !m_pszCmdName[ 0 ] )
|
||||
return;
|
||||
|
||||
if ( m_bNoCommand )
|
||||
return;
|
||||
|
||||
char szCommand[ 256 ];
|
||||
|
||||
Q_snprintf( szCommand, sizeof( szCommand ), "%c%s\n", IsSelected() ? '+' : '-',
|
||||
m_pszCmdName );
|
||||
|
||||
engine->pfnClientCmd( szCommand );
|
||||
}*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CKeyToggleCheckButton::Reset()
|
||||
{
|
||||
gameuifuncs->IsKeyDown( m_pszKeyName, m_bStartValue );
|
||||
if ( IsSelected() != m_bStartValue)
|
||||
{
|
||||
SetSelected( m_bStartValue );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CKeyToggleCheckButton::ApplyChanges()
|
||||
{
|
||||
if ( !m_pszCmdName || !m_pszCmdName[ 0 ] )
|
||||
return;
|
||||
|
||||
char szCommand[ 256 ];
|
||||
|
||||
Q_snprintf( szCommand, sizeof( szCommand ), "%c%s\n", IsSelected() ? '+' : '-',
|
||||
m_pszCmdName );
|
||||
|
||||
engine->ClientCmd_Unrestricted( szCommand );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CKeyToggleCheckButton::HasBeenModified()
|
||||
{
|
||||
return IsSelected() != m_bStartValue;
|
||||
}
|
||||
38
game/client/cstrike15/gameui/keytogglecheckbutton.h
Normal file
38
game/client/cstrike15/gameui/keytogglecheckbutton.h
Normal file
@@ -0,0 +1,38 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef KEYTOGGLECHECKBUTTON_H
|
||||
#define KEYTOGGLECHECKBUTTON_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui_controls/CheckButton.h>
|
||||
|
||||
class CKeyToggleCheckButton : public vgui::CheckButton
|
||||
{
|
||||
public:
|
||||
CKeyToggleCheckButton( vgui::Panel *parent, const char *panelName, const char *text,
|
||||
char const *keyname, char const *cmdname );
|
||||
~CKeyToggleCheckButton();
|
||||
|
||||
//virtual void SetSelected( bool state );
|
||||
virtual void Paint();
|
||||
|
||||
void Reset();
|
||||
void ApplyChanges();
|
||||
bool HasBeenModified();
|
||||
|
||||
private:
|
||||
typedef vgui::CheckButton BaseClass;
|
||||
|
||||
char *m_pszKeyName;
|
||||
char *m_pszCmdName;
|
||||
|
||||
bool m_bStartValue;
|
||||
};
|
||||
#endif // KEYTOGGLECHECKBUTTON_H
|
||||
131
game/client/cstrike15/gameui/labeledcommandcombobox.cpp
Normal file
131
game/client/cstrike15/gameui/labeledcommandcombobox.cpp
Normal file
@@ -0,0 +1,131 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "labeledcommandcombobox.h"
|
||||
#include "engineinterface.h"
|
||||
#include <keyvalues.h>
|
||||
#include <vgui/ILocalize.h>
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
CLabeledCommandComboBox::CLabeledCommandComboBox( vgui::Panel *parent, const char *panelName ) : vgui::ComboBox( parent, panelName, 6, false )
|
||||
{
|
||||
AddActionSignalTarget(this);
|
||||
m_iCurrentSelection = -1;
|
||||
m_iStartSelection = -1;
|
||||
}
|
||||
|
||||
CLabeledCommandComboBox::~CLabeledCommandComboBox( void )
|
||||
{
|
||||
}
|
||||
|
||||
void CLabeledCommandComboBox::DeleteAllItems()
|
||||
{
|
||||
BaseClass::DeleteAllItems();
|
||||
m_Items.RemoveAll();
|
||||
}
|
||||
|
||||
void CLabeledCommandComboBox::AddItem( char const *text, char const *engineCommand )
|
||||
{
|
||||
int idx = m_Items.AddToTail();
|
||||
COMMANDITEM *item = &m_Items[ idx ];
|
||||
|
||||
item->comboBoxID = BaseClass::AddItem( text, NULL );
|
||||
|
||||
Q_strncpy( item->name, text, sizeof( item->name ) );
|
||||
|
||||
if (text[0] == '#')
|
||||
{
|
||||
// need to localize the string
|
||||
wchar_t *localized = g_pVGuiLocalize->Find(text);
|
||||
if (localized)
|
||||
{
|
||||
g_pVGuiLocalize->ConvertUnicodeToANSI(localized, item->name, sizeof(item->name));
|
||||
}
|
||||
}
|
||||
|
||||
Q_strncpy( item->command, engineCommand, sizeof( item->command ) );
|
||||
}
|
||||
|
||||
void CLabeledCommandComboBox::ActivateItem(int index)
|
||||
{
|
||||
if ( index< m_Items.Count() )
|
||||
{
|
||||
int comboBoxID = m_Items[index].comboBoxID;
|
||||
BaseClass::ActivateItem(comboBoxID);
|
||||
m_iCurrentSelection = index;
|
||||
}
|
||||
}
|
||||
|
||||
void CLabeledCommandComboBox::SetInitialItem(int index)
|
||||
{
|
||||
if ( index< m_Items.Count() )
|
||||
{
|
||||
m_iStartSelection = index;
|
||||
int comboBoxID = m_Items[index].comboBoxID;
|
||||
ActivateItem(comboBoxID);
|
||||
}
|
||||
}
|
||||
|
||||
void CLabeledCommandComboBox::OnTextChanged( char const *text )
|
||||
{
|
||||
int i;
|
||||
for ( i = 0; i < m_Items.Count(); i++ )
|
||||
{
|
||||
COMMANDITEM *item = &m_Items[ i ];
|
||||
if ( !stricmp( item->name, text ) )
|
||||
{
|
||||
// engine->pfnClientCmd( item->command );
|
||||
m_iCurrentSelection = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (HasBeenModified())
|
||||
{
|
||||
PostActionSignal(new KeyValues("ControlModified"));
|
||||
}
|
||||
// PostMessage( GetParent()->GetVPanel(), new vgui::KeyValues( "TextChanged", "text", text ) );
|
||||
}
|
||||
|
||||
const char *CLabeledCommandComboBox::GetActiveItemCommand()
|
||||
{
|
||||
if (m_iCurrentSelection == -1)
|
||||
return NULL;
|
||||
|
||||
COMMANDITEM *item = &m_Items[ m_iCurrentSelection ];
|
||||
return item->command;
|
||||
}
|
||||
|
||||
void CLabeledCommandComboBox::ApplyChanges()
|
||||
{
|
||||
if (m_iCurrentSelection == -1)
|
||||
return;
|
||||
if (m_Items.Count() < 1)
|
||||
return;
|
||||
|
||||
Assert( m_iCurrentSelection < m_Items.Count() );
|
||||
COMMANDITEM *item = &m_Items[ m_iCurrentSelection ];
|
||||
engine->ClientCmd_Unrestricted( item->command );
|
||||
m_iStartSelection = m_iCurrentSelection;
|
||||
}
|
||||
|
||||
bool CLabeledCommandComboBox::HasBeenModified()
|
||||
{
|
||||
return m_iStartSelection != m_iCurrentSelection;
|
||||
}
|
||||
|
||||
void CLabeledCommandComboBox::Reset()
|
||||
{
|
||||
if (m_iStartSelection != -1)
|
||||
{
|
||||
ActivateItem(m_iStartSelection);
|
||||
}
|
||||
}
|
||||
59
game/client/cstrike15/gameui/labeledcommandcombobox.h
Normal file
59
game/client/cstrike15/gameui/labeledcommandcombobox.h
Normal file
@@ -0,0 +1,59 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef LABELEDCOMMANDCOMBOBOX_H
|
||||
#define LABELEDCOMMANDCOMBOBOX_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui_controls/ComboBox.h>
|
||||
#include <vgui_controls/Label.h>
|
||||
#include <vgui_controls/Panel.h>
|
||||
#include "utlvector.h"
|
||||
|
||||
class CLabeledCommandComboBox : public vgui::ComboBox
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CLabeledCommandComboBox, vgui::ComboBox );
|
||||
|
||||
public:
|
||||
CLabeledCommandComboBox(vgui::Panel *parent, const char *panelName);
|
||||
~CLabeledCommandComboBox();
|
||||
|
||||
virtual void DeleteAllItems();
|
||||
virtual void AddItem(char const *text, char const *engineCommand);
|
||||
virtual void ActivateItem(int itemIndex);
|
||||
const char *GetActiveItemCommand();
|
||||
|
||||
void SetInitialItem(int itemIndex);
|
||||
|
||||
void ApplyChanges();
|
||||
void Reset();
|
||||
bool HasBeenModified();
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_NAME_LEN = 256,
|
||||
MAX_COMMAND_LEN = 256
|
||||
};
|
||||
|
||||
private:
|
||||
MESSAGE_FUNC_CHARPTR( OnTextChanged, "TextChanged", text );
|
||||
|
||||
struct COMMANDITEM
|
||||
{
|
||||
char name[ MAX_NAME_LEN ];
|
||||
char command[ MAX_COMMAND_LEN ];
|
||||
int comboBoxID;
|
||||
};
|
||||
|
||||
CUtlVector< COMMANDITEM > m_Items;
|
||||
int m_iCurrentSelection;
|
||||
int m_iStartSelection;
|
||||
};
|
||||
|
||||
#endif // LABELEDCOMMANDCOMBOBOX_H
|
||||
393
game/client/cstrike15/gameui/loadcommentarydialog.cpp
Normal file
393
game/client/cstrike15/gameui/loadcommentarydialog.cpp
Normal file
@@ -0,0 +1,393 @@
|
||||
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
|
||||
#include "loadcommentarydialog.h"
|
||||
#include "engineinterface.h"
|
||||
#include "IGameUIFuncs.h"
|
||||
|
||||
#include "vgui/ISystem.h"
|
||||
#include "vgui/IVGui.h"
|
||||
#include "tier1/keyvalues.h"
|
||||
#include "tier1/convar.h"
|
||||
#include "filesystem.h"
|
||||
|
||||
#include "vgui_controls/PanelListPanel.h"
|
||||
#include "vgui_controls/Label.h"
|
||||
#include "vgui_controls/ImagePanel.h"
|
||||
#include "vgui_controls/Button.h"
|
||||
#include "vgui_controls/Button.h"
|
||||
#include "vgui_controls/PanelListPanel.h"
|
||||
#include "vgui_controls/QueryBox.h"
|
||||
#include "vgui_controls/tgaimagepanel.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "basepanel.h"
|
||||
|
||||
#include "gameui_interface.h"
|
||||
|
||||
#include "mousemessageforwardingpanel.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
|
||||
void OpenLoadCommentaryDialog( void )
|
||||
{
|
||||
DHANDLE<CLoadCommentaryDialog> hCommentaryDialog;
|
||||
if ( !hCommentaryDialog.Get() )
|
||||
{
|
||||
hCommentaryDialog = new CLoadCommentaryDialog( BasePanel() );
|
||||
}
|
||||
|
||||
GameUI().ActivateGameUI();
|
||||
hCommentaryDialog->Activate();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CC_LoadCommentary_Test( void )
|
||||
{
|
||||
OpenLoadCommentaryDialog();
|
||||
}
|
||||
static ConCommand commentary_testfirstrun("loadcommentary", CC_LoadCommentary_Test, 0 );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Describes the layout of a commentary map list item
|
||||
//-----------------------------------------------------------------------------
|
||||
class CCommentaryItemPanel : public vgui::EditablePanel
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CCommentaryItemPanel, vgui::EditablePanel );
|
||||
public:
|
||||
CCommentaryItemPanel( PanelListPanel *parent, const char *name, int iListItemID ) : BaseClass( parent, name )
|
||||
{
|
||||
m_iListItemID = iListItemID;
|
||||
m_pParent = parent;
|
||||
m_pCommentaryScreenshot = new CTGAImagePanel( this, "CommentaryMapScreenshot" );
|
||||
m_pCommentaryScreenshotBackground = new ImagePanel( this, "CommentaryScreenshotBackground" );
|
||||
|
||||
// map name
|
||||
m_pMapNameLabel = new Label( this, "MapName", "" );
|
||||
|
||||
// description
|
||||
m_pDescriptionLabel = new Label( this, "Description", "" );
|
||||
|
||||
CMouseMessageForwardingPanel *panel = new CMouseMessageForwardingPanel(this, NULL);
|
||||
panel->SetZPos(2);
|
||||
|
||||
SetSize( 200, 140 );
|
||||
|
||||
LoadControlSettings( "resource/CommentaryItem.res" );
|
||||
|
||||
m_FillColor = m_pCommentaryScreenshotBackground->GetFillColor();
|
||||
}
|
||||
|
||||
void SetCommentaryInfo( CommentaryItem_t &item )
|
||||
{
|
||||
// set the bitmap to display
|
||||
char tga[_MAX_PATH];
|
||||
Q_strncpy( tga, item.szMapFileName, sizeof(tga) );
|
||||
char *ext = strstr( tga, ".txt" );
|
||||
if ( ext )
|
||||
{
|
||||
strcpy( ext, ".tga" );
|
||||
}
|
||||
m_pCommentaryScreenshot->SetTGAFilename( tga );
|
||||
|
||||
// set the title text
|
||||
m_pMapNameLabel->SetText( item.szPrintName );
|
||||
m_pDescriptionLabel->SetText( item.szDescription );
|
||||
}
|
||||
|
||||
MESSAGE_FUNC_INT( OnPanelSelected, "PanelSelected", state )
|
||||
{
|
||||
if ( state )
|
||||
{
|
||||
// set the text color to be orange, and the pic border to be orange
|
||||
m_pCommentaryScreenshotBackground->SetFillColor( m_SelectedColor );
|
||||
m_pMapNameLabel->SetFgColor( m_SelectedColor );
|
||||
m_pDescriptionLabel->SetFgColor( m_SelectedColor );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pCommentaryScreenshotBackground->SetFillColor( m_FillColor );
|
||||
m_pMapNameLabel->SetFgColor( m_TextColor );
|
||||
m_pDescriptionLabel->SetFgColor( m_TextColor );
|
||||
}
|
||||
|
||||
PostMessage( m_pParent->GetVParent(), new KeyValues("PanelSelected") );
|
||||
}
|
||||
|
||||
virtual void OnMousePressed( vgui::MouseCode code )
|
||||
{
|
||||
m_pParent->SetSelectedPanel( this );
|
||||
}
|
||||
|
||||
virtual void ApplySchemeSettings( IScheme *pScheme )
|
||||
{
|
||||
m_TextColor = pScheme->GetColor( "NewGame.TextColor", Color(255, 255, 255, 255) );
|
||||
m_SelectedColor = pScheme->GetColor( "NewGame.SelectionColor", Color(255, 255, 255, 255) );
|
||||
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
}
|
||||
|
||||
virtual void OnMouseDoublePressed( vgui::MouseCode code )
|
||||
{
|
||||
// call the panel
|
||||
OnMousePressed( code );
|
||||
PostMessage( m_pParent->GetParent(), new KeyValues("Command", "command", "loadcommentary") );
|
||||
}
|
||||
|
||||
int GetListItemID()
|
||||
{
|
||||
return m_iListItemID;
|
||||
}
|
||||
|
||||
private:
|
||||
vgui::PanelListPanel *m_pParent;
|
||||
|
||||
vgui::Label *m_pMapNameLabel;
|
||||
vgui::Label *m_pDescriptionLabel;
|
||||
CTGAImagePanel *m_pCommentaryScreenshot;
|
||||
ImagePanel *m_pCommentaryScreenshotBackground;
|
||||
|
||||
Color m_TextColor, m_FillColor, m_SelectedColor;
|
||||
|
||||
int m_iListItemID;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CLoadCommentaryDialog::CLoadCommentaryDialog(vgui::Panel *parent) : BaseClass(parent, "LoadCommentaryDialog")
|
||||
{
|
||||
SetDeleteSelfOnClose(true);
|
||||
SetBounds(0, 0, 512, 384);
|
||||
SetMinimumSize( 256, 300 );
|
||||
SetSizeable( true );
|
||||
|
||||
SetTitle("#GameUI_LoadCommentary", true);
|
||||
|
||||
vgui::Button *cancel = new vgui::Button( this, "Cancel", "#GameUI_Cancel" );
|
||||
cancel->SetCommand( "Close" );
|
||||
|
||||
CreateCommentaryItemList();
|
||||
|
||||
new vgui::Button( this, "loadcommentary", "" );
|
||||
SetControlEnabled( "loadcommentary", false );
|
||||
|
||||
LoadControlSettings("resource/LoadCommentaryDialog.res");
|
||||
|
||||
// Look for commentary .txt files in the map directory
|
||||
ScanCommentaryFiles();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CLoadCommentaryDialog::OnCommand( const char *command )
|
||||
{
|
||||
if ( !Q_stricmp( command, "loadcommentary" ) )
|
||||
{
|
||||
int itemIndex = GetSelectedItemIndex();
|
||||
if ( m_CommentaryItems.IsValidIndex(itemIndex) )
|
||||
{
|
||||
const char *mapName = m_CommentaryItems[itemIndex].szMapName;
|
||||
if ( mapName && mapName[ 0 ] )
|
||||
{
|
||||
// Load the game, return to top and switch to engine
|
||||
char sz[ 256 ];
|
||||
Q_snprintf(sz, sizeof( sz ), "progress_enable\ncommentary 1\nmap %s\n", mapName );
|
||||
|
||||
// Close this dialog
|
||||
OnClose();
|
||||
|
||||
engine->ClientCmd_Unrestricted( sz );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnCommand( command );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Creates the load game display list
|
||||
//-----------------------------------------------------------------------------
|
||||
void CLoadCommentaryDialog::CreateCommentaryItemList()
|
||||
{
|
||||
m_pGameList = new vgui::PanelListPanel( this, "listpanel_commentary" );
|
||||
m_pGameList->SetFirstColumnWidth( 0 );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: returns the save file name of the selected item
|
||||
//-----------------------------------------------------------------------------
|
||||
int CLoadCommentaryDialog::GetSelectedItemIndex()
|
||||
{
|
||||
CCommentaryItemPanel *panel = dynamic_cast<CCommentaryItemPanel *>(m_pGameList->GetSelectedPanel());
|
||||
if ( panel )
|
||||
{
|
||||
// find the panel in the list
|
||||
for ( int i = 0; i < m_CommentaryItems.Count(); i++ )
|
||||
{
|
||||
if ( i == panel->GetListItemID() )
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return m_CommentaryItems.InvalidIndex();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: builds save game list from directory
|
||||
//-----------------------------------------------------------------------------
|
||||
void CLoadCommentaryDialog::ScanCommentaryFiles()
|
||||
{
|
||||
// populate list box with all saved games on record:
|
||||
char szDirectory[_MAX_PATH];
|
||||
Q_snprintf( szDirectory, sizeof( szDirectory ), "maps/*commentary.txt" );
|
||||
|
||||
// clear the current list
|
||||
m_pGameList->DeleteAllItems();
|
||||
m_CommentaryItems.RemoveAll();
|
||||
|
||||
// iterate the files
|
||||
FileFindHandle_t handle;
|
||||
const char *pFileName = g_pFullFileSystem->FindFirst( szDirectory, &handle );
|
||||
while (pFileName)
|
||||
{
|
||||
char szFileName[_MAX_PATH];
|
||||
Q_snprintf(szFileName, sizeof( szFileName ), "maps/%s", pFileName);
|
||||
|
||||
// Only load save games from the current mod's save dir
|
||||
if( !g_pFullFileSystem->FileExists( szFileName, "MOD" ) )
|
||||
{
|
||||
pFileName = g_pFullFileSystem->FindNext( handle );
|
||||
continue;
|
||||
}
|
||||
|
||||
ParseCommentaryFile( szFileName, pFileName );
|
||||
|
||||
pFileName = g_pFullFileSystem->FindNext( handle );
|
||||
}
|
||||
|
||||
g_pFullFileSystem->FindClose( handle );
|
||||
|
||||
// sort the save list
|
||||
qsort( m_CommentaryItems.Base(), m_CommentaryItems.Count(), sizeof(CommentaryItem_t), &SaveGameSortFunc );
|
||||
|
||||
// add to the list
|
||||
for ( int saveIndex = 0; saveIndex < m_CommentaryItems.Count() && saveIndex < MAX_LISTED_COMMENTARY_ITEMS; saveIndex++ )
|
||||
{
|
||||
// add the item to the panel
|
||||
AddCommentaryItemToList( saveIndex );
|
||||
}
|
||||
|
||||
// display a message if there are no save games
|
||||
if ( !m_CommentaryItems.Count() )
|
||||
{
|
||||
vgui::Label *pNoCommentaryItemsLabel = SETUP_PANEL(new Label(m_pGameList, "NoCommentaryItemsLabel", "#GameUI_NoCommentaryItemsToDisplay"));
|
||||
pNoCommentaryItemsLabel->SetTextColorState(vgui::Label::CS_DULL);
|
||||
m_pGameList->AddItem( NULL, pNoCommentaryItemsLabel );
|
||||
}
|
||||
|
||||
SetControlEnabled( "loadcommentary", false );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Adds an item to the list
|
||||
//-----------------------------------------------------------------------------
|
||||
void CLoadCommentaryDialog::AddCommentaryItemToList( int itemIndex )
|
||||
{
|
||||
// create the new panel and add to the list
|
||||
CCommentaryItemPanel *commentaryItemPanel = new CCommentaryItemPanel( m_pGameList, "CommentaryItemPanel", itemIndex );
|
||||
commentaryItemPanel->SetCommentaryInfo( m_CommentaryItems[itemIndex] );
|
||||
m_pGameList->AddItem( NULL, commentaryItemPanel );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Parses the save game info out of the .sav file header
|
||||
//-----------------------------------------------------------------------------
|
||||
void CLoadCommentaryDialog::ParseCommentaryFile( char const *pszFileName, char const *pszShortName )
|
||||
{
|
||||
if ( !pszFileName || !pszShortName )
|
||||
return;
|
||||
|
||||
// load the file as keyvalues
|
||||
KeyValues *pData = new KeyValues( "commentary_data" );
|
||||
|
||||
if ( false == pData->LoadFromFile( g_pFullFileSystem, pszFileName, "MOD" ) )
|
||||
{
|
||||
pData->deleteThis();
|
||||
return;
|
||||
}
|
||||
|
||||
// walk the platform menu loading all the interfaces
|
||||
KeyValues *menuKeys = pData->FindKey("trackinfo", false);
|
||||
if ( menuKeys )
|
||||
{
|
||||
for (KeyValues *track = menuKeys->GetFirstSubKey(); track != NULL; track = track->GetNextKey())
|
||||
{
|
||||
//Msg( "track found: %s %s\n", track->GetString("map", "?"), track->GetString( "description", "asdf" ) );
|
||||
|
||||
CommentaryItem_t item;
|
||||
Q_strncpy( item.szMapFileName, pszFileName, sizeof(item.szMapFileName) );
|
||||
Q_strncpy( item.szMapName, track->GetString( "map", "" ), sizeof(item.szMapName) );
|
||||
Q_strncpy( item.szPrintName, track->GetString( "printname", "" ), sizeof(item.szPrintName) );
|
||||
Q_strncpy( item.szDescription, track->GetString( "description", "" ), sizeof(item.szDescription) );
|
||||
|
||||
//item.iChannel = track->GetInt( "channel" );
|
||||
|
||||
m_CommentaryItems.AddToTail( item );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CommentaryItem_t item;
|
||||
Q_strncpy( item.szMapFileName, pszFileName, sizeof(item.szMapFileName) );
|
||||
|
||||
char mapname[_MAX_PATH];
|
||||
Q_strncpy( mapname, pszFileName, sizeof(item.szMapName) );
|
||||
char *ext = strstr( mapname, "_commentary" );
|
||||
*ext = '\0';
|
||||
Q_FileBase( mapname, item.szMapName, sizeof(item.szMapName) );
|
||||
|
||||
Q_strncpy( item.szPrintName, "No trackinfo found.", sizeof(item.szPrintName) );
|
||||
Q_strncpy( item.szDescription, "No trackinfo found.", sizeof(item.szDescription) );
|
||||
m_CommentaryItems.AddToTail( item );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: timestamp sort function for savegames
|
||||
//-----------------------------------------------------------------------------
|
||||
int CLoadCommentaryDialog::SaveGameSortFunc( const void *lhs, const void *rhs )
|
||||
{
|
||||
// Sort by map name
|
||||
const CommentaryItem_t *s1 = (const CommentaryItem_t *)lhs;
|
||||
const CommentaryItem_t *s2 = (const CommentaryItem_t *)rhs;
|
||||
|
||||
return Q_stricmp( s1->szPrintName, s2->szPrintName );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: One item has been selected
|
||||
//-----------------------------------------------------------------------------
|
||||
void CLoadCommentaryDialog::OnPanelSelected()
|
||||
{
|
||||
SetControlEnabled( "loadcommentary", true );
|
||||
}
|
||||
62
game/client/cstrike15/gameui/loadcommentarydialog.h
Normal file
62
game/client/cstrike15/gameui/loadcommentarydialog.h
Normal file
@@ -0,0 +1,62 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef LOADCOMMENTARYDIALOG_H
|
||||
#define LOADCOMMENTARYDIALOG_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui_controls/Frame.h"
|
||||
#include "filesystem.h"
|
||||
#include "utlvector.h"
|
||||
|
||||
|
||||
#define COMMENTARY_MAPFILENAME_MAX_LEN MAX_PATH
|
||||
#define COMMENTARY_MAPNAME_MAX_LEN 32
|
||||
#define COMMENTARY_DESCRIP_MAX_LEN 512
|
||||
#define MAX_LISTED_COMMENTARY_ITEMS 32
|
||||
|
||||
struct CommentaryItem_t
|
||||
{
|
||||
char szMapFileName[COMMENTARY_MAPFILENAME_MAX_LEN]; // file location of the map
|
||||
char szMapName[COMMENTARY_MAPNAME_MAX_LEN]; // clean name of the map, eg "dod_kalt"
|
||||
char szPrintName[COMMENTARY_MAPNAME_MAX_LEN]; // printable name "Kalt"
|
||||
char szDescription[COMMENTARY_DESCRIP_MAX_LEN]; // track description "This map is fun, and people like it!"
|
||||
|
||||
//int iChannel; // TODO: multiple channels within a single map, loaded into separate commentary tracks
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Base class for save & load game dialogs
|
||||
//-----------------------------------------------------------------------------
|
||||
class CLoadCommentaryDialog : public vgui::Frame
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CLoadCommentaryDialog, vgui::Frame );
|
||||
|
||||
public:
|
||||
explicit CLoadCommentaryDialog( vgui::Panel *parent );
|
||||
|
||||
protected:
|
||||
CUtlVector<CommentaryItem_t> m_CommentaryItems;
|
||||
vgui::PanelListPanel *m_pGameList;
|
||||
|
||||
virtual void OnCommand( const char *command );
|
||||
|
||||
void ScanCommentaryFiles();
|
||||
void CreateCommentaryItemList();
|
||||
int GetSelectedItemIndex();
|
||||
void AddCommentaryItemToList( int saveIndex );
|
||||
|
||||
void ParseCommentaryFile( char const *pszFileName, char const *pszShortName );
|
||||
static int __cdecl SaveGameSortFunc( const void *lhs, const void *rhs );
|
||||
|
||||
private:
|
||||
MESSAGE_FUNC( OnPanelSelected, "PanelSelected" );
|
||||
};
|
||||
|
||||
|
||||
#endif // LOADCOMMENTARYDIALOG_H
|
||||
107
game/client/cstrike15/gameui/loadgamedialog.cpp
Normal file
107
game/client/cstrike15/gameui/loadgamedialog.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "loadgamedialog.h"
|
||||
#include "engineinterface.h"
|
||||
|
||||
#include "vgui/ISystem.h"
|
||||
#include "vgui/ISurface.h"
|
||||
#include "vgui/IVGui.h"
|
||||
#include "keyvalues.h"
|
||||
#include "filesystem.h"
|
||||
|
||||
#include "vgui_controls/Button.h"
|
||||
#include "vgui_controls/PanelListPanel.h"
|
||||
#include "vgui_controls/QueryBox.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CLoadGameDialog::CLoadGameDialog(vgui::Panel *parent) : BaseClass(parent, "LoadGameDialog")
|
||||
{
|
||||
SetDeleteSelfOnClose(true);
|
||||
SetBounds(0, 0, 512, 384);
|
||||
SetMinimumSize( 256, 300 );
|
||||
SetSizeable( true );
|
||||
|
||||
SetTitle("#GameUI_LoadGame", true);
|
||||
|
||||
vgui::Button *cancel = new vgui::Button( this, "Cancel", "#GameUI_Cancel" );
|
||||
cancel->SetCommand( "Close" );
|
||||
|
||||
LoadControlSettings("resource/LoadGameDialog.res");
|
||||
|
||||
SetControlEnabled( "delete", false );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CLoadGameDialog::~CLoadGameDialog()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CLoadGameDialog::OnCommand( const char *command )
|
||||
{
|
||||
if ( !stricmp( command, "loadsave" ) )
|
||||
{
|
||||
int saveIndex = GetSelectedItemSaveIndex();
|
||||
if ( m_SaveGames.IsValidIndex(saveIndex) )
|
||||
{
|
||||
const char *shortName = m_SaveGames[saveIndex].szShortName;
|
||||
if ( shortName && shortName[ 0 ] )
|
||||
{
|
||||
// Load the game, return to top and switch to engine
|
||||
char sz[ 256 ];
|
||||
Q_snprintf(sz, sizeof( sz ), "progress_enable\nload %s\n", shortName );
|
||||
|
||||
engine->ClientCmd_Unrestricted( sz );
|
||||
|
||||
// Close this dialog
|
||||
OnClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( !stricmp( command, "Delete" ) )
|
||||
{
|
||||
int saveIndex = GetSelectedItemSaveIndex();
|
||||
if ( m_SaveGames.IsValidIndex(saveIndex) )
|
||||
{
|
||||
// confirm the deletion
|
||||
QueryBox *box = new QueryBox( "#GameUI_ConfirmDeleteSaveGame_Title", "#GameUI_ConfirmDeleteSaveGame_Info" );
|
||||
box->AddActionSignalTarget(this);
|
||||
box->SetOKButtonText("#GameUI_ConfirmDeleteSaveGame_OK");
|
||||
box->SetOKCommand(new KeyValues("Command", "command", "DeleteConfirmed"));
|
||||
box->DoModal();
|
||||
}
|
||||
}
|
||||
else if ( !stricmp( command, "DeleteConfirmed" ) )
|
||||
{
|
||||
int saveIndex = GetSelectedItemSaveIndex();
|
||||
if ( m_SaveGames.IsValidIndex(saveIndex) )
|
||||
{
|
||||
DeleteSaveGame( m_SaveGames[saveIndex].szFileName );
|
||||
|
||||
// reset the list
|
||||
ScanSavedGames();
|
||||
m_pGameList->MoveScrollBarToTop();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnCommand( command );
|
||||
}
|
||||
}
|
||||
|
||||
53
game/client/cstrike15/gameui/loadgamedialog.h
Normal file
53
game/client/cstrike15/gameui/loadgamedialog.h
Normal file
@@ -0,0 +1,53 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef LOADGAMEDIALOG_H
|
||||
#define LOADGAMEDIALOG_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "basesavegamedialog.h"
|
||||
#include "savegamedialog.h"
|
||||
#include "savegamebrowserdialog.h"
|
||||
#include "basepanel.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Displays game loading options
|
||||
//-----------------------------------------------------------------------------
|
||||
class CLoadGameDialog : public CBaseSaveGameDialog
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CLoadGameDialog, CBaseSaveGameDialog );
|
||||
|
||||
public:
|
||||
explicit CLoadGameDialog(vgui::Panel *parent);
|
||||
~CLoadGameDialog();
|
||||
|
||||
virtual void OnCommand( const char *command );
|
||||
};
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
class CLoadGameDialogXbox : public CSaveGameBrowserDialog
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CLoadGameDialogXbox, CSaveGameBrowserDialog );
|
||||
|
||||
public:
|
||||
explicit CLoadGameDialogXbox( vgui::Panel *parent );
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
virtual void OnCommand(const char *command);
|
||||
virtual void PerformSelectedAction( void );
|
||||
virtual void PerformDeletion( void );
|
||||
virtual void UpdateFooterOptions( void );
|
||||
|
||||
private:
|
||||
void DeleteSaveGame( const SaveGameDescription_t *pSaveDesc );
|
||||
};
|
||||
|
||||
#endif // LOADGAMEDIALOG_H
|
||||
217
game/client/cstrike15/gameui/loadgamedialog_xbox.cpp
Normal file
217
game/client/cstrike15/gameui/loadgamedialog_xbox.cpp
Normal file
@@ -0,0 +1,217 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "basepanel.h"
|
||||
#include "loadgamedialog.h"
|
||||
|
||||
#include "winlite.h"
|
||||
#include "vgui/ISurface.h"
|
||||
|
||||
#include "engineinterface.h"
|
||||
#include "gameui_interface.h"
|
||||
#include "ixboxsystem.h"
|
||||
#include "filesystem.h"
|
||||
|
||||
#include "savegamebrowserdialog.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
CLoadGameDialogXbox::CLoadGameDialogXbox( vgui::Panel *parent ) : BaseClass( parent )
|
||||
{
|
||||
m_bFilterAutosaves = false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CLoadGameDialogXbox::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
|
||||
vgui::Label *pTitle = (Label *) FindChildByName( "TitleLabel" );
|
||||
if ( pTitle )
|
||||
{
|
||||
pTitle->SetText( "#GameUI_LoadGame" );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CLoadGameDialogXbox::PerformSelectedAction( void )
|
||||
{
|
||||
BaseClass::PerformSelectedAction();
|
||||
|
||||
if ( !GetNumPanels() )
|
||||
return;
|
||||
|
||||
SetControlDisabled( true );
|
||||
|
||||
// Warn the player if they're already in a map
|
||||
if ( !GameUI().HasSavedThisMenuSession() && GameUI().IsInLevel() && engine->GetMaxClients() == 1 )
|
||||
{
|
||||
BasePanel()->ShowMessageDialog( MD_SAVE_BEFORE_LOAD, this );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise just do it
|
||||
OnCommand( "LoadGame" );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CLoadGameDialogXbox::PerformDeletion( void )
|
||||
{
|
||||
// Cannot delete autosaves!
|
||||
CGameSavePanel *pPanel = GetActivePanel();
|
||||
if ( pPanel == NULL || ( pPanel && pPanel->IsAutoSaveType() ) )
|
||||
return;
|
||||
|
||||
BaseClass::PerformDeletion();
|
||||
|
||||
SetControlDisabled( true );
|
||||
|
||||
vgui::surface()->PlaySound( "UI/buttonclickrelease.wav" );
|
||||
BasePanel()->ShowMessageDialog( MD_DELETE_SAVE_CONFIRM, this );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : bNewSaveSelected -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CLoadGameDialogXbox::UpdateFooterOptions( void )
|
||||
{
|
||||
CFooterPanel *pFooter = GetFooterPanel();
|
||||
|
||||
// Show available buttons
|
||||
pFooter->ClearButtons();
|
||||
|
||||
// Make sure we have panels to show
|
||||
if ( HasActivePanels() )
|
||||
{
|
||||
pFooter->AddNewButtonLabel( "#GameUI_Load", "#GameUI_Icons_A_BUTTON" );
|
||||
|
||||
// Don't allow deletions of autosaves!
|
||||
CGameSavePanel *pPanel = GetActivePanel();
|
||||
if ( pPanel && pPanel->IsAutoSaveType() == false )
|
||||
{
|
||||
pFooter->AddNewButtonLabel( "#GameUI_Delete", "#GameUI_Icons_X_BUTTON" );
|
||||
}
|
||||
}
|
||||
|
||||
// Always allow storage devices changes and cancelling
|
||||
pFooter->AddNewButtonLabel( "#GameUI_Close", "#GameUI_Icons_B_BUTTON" );
|
||||
pFooter->AddNewButtonLabel( "#GameUI_Console_StorageChange", "#GameUI_Icons_Y_BUTTON" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *command -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CLoadGameDialogXbox::OnCommand( const char *command )
|
||||
{
|
||||
if ( !Q_stricmp( command, "LoadGame" ) )
|
||||
{
|
||||
// Must have an active panel to perform this action
|
||||
if ( GetNumPanels() == 0 )
|
||||
{
|
||||
SetControlDisabled( false );
|
||||
return;
|
||||
}
|
||||
|
||||
const SaveGameDescription_t *pSave = GetActivePanelSaveDescription();
|
||||
|
||||
// Load the saved game
|
||||
char szCmd[ 256 ];
|
||||
Q_snprintf( szCmd, sizeof( szCmd ), "xload %s", pSave->szShortName );
|
||||
engine->ClientCmd_Unrestricted( szCmd );
|
||||
|
||||
// Ignore all other input while we're open
|
||||
OnClose();
|
||||
}
|
||||
else if ( !Q_stricmp( command, "DeleteGame" ) )
|
||||
{
|
||||
// Must have an active panel to perform this action
|
||||
if ( GetNumPanels() == 0 )
|
||||
{
|
||||
SetControlDisabled( false );
|
||||
return;
|
||||
}
|
||||
|
||||
// Delete the game they've selected
|
||||
const SaveGameDescription_t *pSave = GetActivePanelSaveDescription();
|
||||
DeleteSaveGame( pSave );
|
||||
RemoveActivePanel();
|
||||
}
|
||||
else if ( !Q_stricmp( command, "RefreshSaveGames" ) )
|
||||
{
|
||||
// FIXME: At this point the rug has been pulled out from undereath us!
|
||||
RefreshSaveGames();
|
||||
}
|
||||
else if ( !Q_stricmp( command, "LoadGameCancelled" ) )
|
||||
{
|
||||
SetControlDisabled( false );
|
||||
}
|
||||
else if ( !Q_stricmp( command, "ReleaseModalWindow" ) )
|
||||
{
|
||||
vgui::surface()->RestrictPaintToSinglePanel( NULL );
|
||||
}
|
||||
else if ( !Q_stricmp( command, "DeleteGameCancelled" ) )
|
||||
{
|
||||
SetControlDisabled( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: deletes an existing save game
|
||||
//-----------------------------------------------------------------------------
|
||||
void CLoadGameDialogXbox::DeleteSaveGame( const SaveGameDescription_t *pSaveDesc )
|
||||
{
|
||||
if ( pSaveDesc == NULL )
|
||||
{
|
||||
SetControlDisabled( false );
|
||||
return;
|
||||
}
|
||||
|
||||
// If we're deleting our more recent save game, we need to make sure we setup the engine to properly load the last most recent
|
||||
if ( Q_stristr( engine->GetMostRecentSaveGame(), pSaveDesc->szShortName ) )
|
||||
{
|
||||
// We must have at least two active save games that we know about
|
||||
if ( GetNumPanels() > 1 )
|
||||
{
|
||||
// The panels are sorted by how recent they are, so the first element is the most recent
|
||||
const SaveGameDescription_t *pDesc = GetPanelSaveDecription( 0 );
|
||||
if ( pDesc == pSaveDesc )
|
||||
{
|
||||
// If we're deleting our most recent, we need to pick the next most recent
|
||||
pDesc = GetPanelSaveDecription( 1 );
|
||||
}
|
||||
|
||||
// Remember this filename for the next time we need to reload
|
||||
if ( pDesc )
|
||||
{
|
||||
engine->SetMostRecentSaveGame( pDesc->szShortName );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Delete the save game file
|
||||
g_pFullFileSystem->RemoveFile( pSaveDesc->szFileName, "MOD" );
|
||||
|
||||
vgui::surface()->PlaySound( "UI/buttonclick.wav" );
|
||||
|
||||
// Return control
|
||||
SetControlDisabled( false );
|
||||
}
|
||||
197
game/client/cstrike15/gameui/loadingtippanel.cpp
Normal file
197
game/client/cstrike15/gameui/loadingtippanel.cpp
Normal file
@@ -0,0 +1,197 @@
|
||||
//===== Copyright <20> 1996-2008, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose: Tip display during level loads.
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#include "loadingtippanel.h"
|
||||
#include "filesystem.h"
|
||||
#include "keyvalues.h"
|
||||
#include "vgui/ISurface.h"
|
||||
#include "engineinterface.h"
|
||||
#include "vstdlib/random.h"
|
||||
#include "fmtstr.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
ConVar ui_loading_tip_refresh( "ui_loading_tip_refresh", "5", FCVAR_DEVELOPMENTONLY );
|
||||
ConVar ui_loading_tip_f1( "ui_loading_tip_f1", "0.05", FCVAR_DEVELOPMENTONLY );
|
||||
ConVar ui_loading_tip_f2( "ui_loading_tip_f2", "0.40", FCVAR_DEVELOPMENTONLY );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
CLoadingTipPanel::CLoadingTipPanel( Panel *pParent ) : EditablePanel( pParent, "loadingtippanel" )
|
||||
{
|
||||
m_flLastTipTime = 0.f;
|
||||
m_iCurrentTip = 0;
|
||||
m_pTipIcon = NULL;
|
||||
|
||||
m_smearColor = Color( 0, 0, 0, 255 );
|
||||
|
||||
SetupTips();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
CLoadingTipPanel::~CLoadingTipPanel()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void CLoadingTipPanel::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
|
||||
m_smearColor = pScheme->GetColor( "Frame.SmearColor", Color( 0, 0, 0, 225 ) );
|
||||
|
||||
ReloadScheme();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void CLoadingTipPanel::ReloadScheme( void )
|
||||
{
|
||||
LoadControlSettings( "Resource/UI/loadingtippanel.res" );
|
||||
|
||||
m_pTipIcon = dynamic_cast< vgui::ImagePanel* >( FindChildByName( "TipIcon" ) );
|
||||
|
||||
NextTip();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void CLoadingTipPanel::SetupTips( void )
|
||||
{
|
||||
#ifdef _DEMO
|
||||
KeyValues *pKV = new KeyValues( "Tips" );
|
||||
KeyValues::AutoDelete autodelete( pKV );
|
||||
if ( !pKV->LoadFromFile( g_pFullFileSystem, "scripts/tips.txt", "GAME" ) )
|
||||
{
|
||||
AssertMsg( false, "failed to load tips!" );
|
||||
return;
|
||||
}
|
||||
|
||||
for ( KeyValues *pKey = pKV->FindKey( "SurvivorTips" )->GetFirstSubKey(); pKey; pKey = pKey->GetNextKey() )
|
||||
{
|
||||
sTipInfo info;
|
||||
V_strncpy( info.szTipTitle, "", MAX_TIP_LENGTH );
|
||||
V_strncpy( info.szTipString, pKey->GetName(), MAX_TIP_LENGTH );
|
||||
V_strncpy( info.szTipImage, "achievements/ACH_SURVIVE_BRIDGE", MAX_TIP_LENGTH );
|
||||
m_Tips.AddToTail( info );
|
||||
}
|
||||
#else
|
||||
TitleAchievementsDescription_t const *desc = g_pMatchFramework->GetMatchTitle()->DescribeTitleAchievements();
|
||||
for ( ; desc->m_szAchievementName; ++desc )
|
||||
{
|
||||
sTipInfo info;
|
||||
V_snprintf( info.szTipTitle, MAX_TIP_LENGTH, "#%s_NAME", desc->m_szAchievementName );
|
||||
V_snprintf( info.szTipString, MAX_TIP_LENGTH, "#%s_DESC", desc->m_szAchievementName );
|
||||
V_snprintf( info.szTipImage, MAX_TIP_LENGTH, "achievements/%s", desc->m_szAchievementName );
|
||||
m_Tips.AddToTail( info );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void CLoadingTipPanel::NextTip( void )
|
||||
{
|
||||
if ( !IsEnabled() )
|
||||
return;
|
||||
|
||||
if ( !m_Tips.Count() )
|
||||
return;
|
||||
|
||||
if ( !m_flLastTipTime )
|
||||
{
|
||||
// Initialize timer on first render
|
||||
m_flLastTipTime = Plat_FloatTime();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( Plat_FloatTime() - m_flLastTipTime < ui_loading_tip_refresh.GetFloat() )
|
||||
return;
|
||||
|
||||
m_flLastTipTime = Plat_FloatTime();
|
||||
|
||||
m_iCurrentTip = RandomInt( 0, m_Tips.Count() - 1 );
|
||||
if ( !m_Tips.IsValidIndex( m_iCurrentTip ) )
|
||||
return;
|
||||
|
||||
sTipInfo info = m_Tips[m_iCurrentTip];
|
||||
|
||||
if ( m_pTipIcon )
|
||||
{
|
||||
m_pTipIcon->SetImage( info.szTipImage );
|
||||
}
|
||||
SetControlString( "TipTitle", info.szTipTitle );
|
||||
SetControlString( "TipText", info.szTipString );
|
||||
|
||||
// Set our control visible
|
||||
SetVisible( true );
|
||||
}
|
||||
|
||||
|
||||
#define TOP_BORDER_HEIGHT 21
|
||||
#define BOTTOM_BORDER_HEIGHT 21
|
||||
int CLoadingTipPanel::DrawSmearBackgroundFade( int x0, int y0, int x1, int y1 )
|
||||
{
|
||||
int wide = x1 - x0;
|
||||
int tall = y1 - y0;
|
||||
|
||||
int topTall = scheme()->GetProportionalScaledValue( TOP_BORDER_HEIGHT );
|
||||
int bottomTall = scheme()->GetProportionalScaledValue( BOTTOM_BORDER_HEIGHT );
|
||||
|
||||
float f1 = ui_loading_tip_f1.GetFloat();
|
||||
float f2 = ui_loading_tip_f2.GetFloat();
|
||||
|
||||
topTall = 1.00f * topTall;
|
||||
bottomTall = 1.00f * bottomTall;
|
||||
|
||||
int middleTall = tall - ( topTall + bottomTall );
|
||||
if ( middleTall < 0 )
|
||||
{
|
||||
middleTall = 0;
|
||||
}
|
||||
|
||||
surface()->DrawSetColor( m_smearColor );
|
||||
|
||||
y0 += topTall;
|
||||
|
||||
if ( middleTall )
|
||||
{
|
||||
// middle
|
||||
surface()->DrawFilledRectFade( x0, y0, x0 + f1*wide, y0 + middleTall, 0, 255, true );
|
||||
surface()->DrawFilledRectFade( x0 + f1*wide, y0, x0 + f2*wide, y0 + middleTall, 255, 255, true );
|
||||
surface()->DrawFilledRectFade( x0 + f2*wide, y0, x0 + wide, y0 + middleTall, 255, 0, true );
|
||||
y0 += middleTall;
|
||||
}
|
||||
|
||||
return topTall + middleTall + bottomTall;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void CLoadingTipPanel::PaintBackground( void )
|
||||
{
|
||||
BaseClass::PaintBackground();
|
||||
|
||||
DrawSmearBackgroundFade(
|
||||
0,
|
||||
-scheme()->GetProportionalScaledValue( 20 ),
|
||||
GetWide(),
|
||||
GetTall() );
|
||||
|
||||
}
|
||||
|
||||
void PrecacheLoadingTipIcons()
|
||||
{
|
||||
TitleAchievementsDescription_t const *desc = g_pMatchFramework->GetMatchTitle()->DescribeTitleAchievements();
|
||||
for ( ; desc->m_szAchievementName; ++desc )
|
||||
{
|
||||
CFmtStr imageString( "vgui/achievements/%s", desc->m_szAchievementName );
|
||||
int nImageId = vgui::surface()->DrawGetTextureId( imageString );
|
||||
if ( nImageId == -1 )
|
||||
{
|
||||
nImageId = vgui::surface()->CreateNewTextureID();
|
||||
vgui::surface()->DrawSetTextureFile( nImageId, imageString, true, false );
|
||||
}
|
||||
}
|
||||
}
|
||||
66
game/client/cstrike15/gameui/loadingtippanel.h
Normal file
66
game/client/cstrike15/gameui/loadingtippanel.h
Normal file
@@ -0,0 +1,66 @@
|
||||
//===== Copyright <20> 1996-2008, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose: Tip display during level loads.
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef LOADING_TIP_PANEL_H
|
||||
#define LOADING_TIP_PANEL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui_controls/ImagePanel.h"
|
||||
#include "vgui_controls/EditablePanel.h"
|
||||
#include "vgui_controls/Label.h"
|
||||
|
||||
#define MAX_TIP_LENGTH 64
|
||||
|
||||
struct sTipInfo
|
||||
{
|
||||
char szTipTitle[MAX_TIP_LENGTH];
|
||||
char szTipString[MAX_TIP_LENGTH];
|
||||
char szTipImage[MAX_TIP_LENGTH];
|
||||
};
|
||||
|
||||
enum eTipMode
|
||||
{
|
||||
TIP_MODE_SURVIVOR,
|
||||
TIP_MODE_INFECTED,
|
||||
TIP_MODE_ACHIEVEMENTS,
|
||||
|
||||
TIP_MODE_COUNT,
|
||||
};
|
||||
|
||||
class CLoadingTipPanel : public vgui::EditablePanel
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CLoadingTipPanel, vgui::EditablePanel )
|
||||
|
||||
public:
|
||||
explicit CLoadingTipPanel( Panel *pParent );
|
||||
~CLoadingTipPanel();
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
virtual void PaintBackground( void );
|
||||
void ReloadScheme( void );
|
||||
|
||||
void NextTip( void );
|
||||
|
||||
private:
|
||||
void SetupTips( void );
|
||||
int DrawSmearBackgroundFade( int x, int y, int wide, int tall );
|
||||
|
||||
Color m_smearColor;
|
||||
|
||||
vgui::ImagePanel *m_pTipIcon;
|
||||
|
||||
CUtlVector< sTipInfo > m_Tips;
|
||||
|
||||
float m_flLastTipTime;
|
||||
int m_iCurrentTip;
|
||||
};
|
||||
|
||||
void PrecacheLoadingTipIcons();
|
||||
|
||||
|
||||
#endif // LOADING_TIP_PANEL_H
|
||||
304
game/client/cstrike15/gameui/logofile.cpp
Normal file
304
game/client/cstrike15/gameui/logofile.cpp
Normal file
@@ -0,0 +1,304 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#if !defined( _GAMECONSOLE )
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include "UtlBuffer.h"
|
||||
#include <vgui/VGUI.h>
|
||||
#include <vgui_controls/Controls.h>
|
||||
#include "FileSystem.h"
|
||||
|
||||
// dgoodenough - select the correct stubs header based on current console
|
||||
// PS3_BUILDFIX
|
||||
#if defined( _PS3 )
|
||||
#include "ps3/ps3_win32stubs.h"
|
||||
#endif
|
||||
#if defined( _X360 )
|
||||
#include "xbox/xbox_win32stubs.h"
|
||||
#endif
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
#define TYP_LUMPY 64 // 64 + grab command number
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char identification[4]; // should be WAD2 or 2DAW
|
||||
int numlumps;
|
||||
int infotableofs;
|
||||
} wadinfo_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int filepos;
|
||||
int disksize;
|
||||
int size; // uncompressed
|
||||
char type;
|
||||
char compression;
|
||||
char pad1, pad2;
|
||||
char name[16]; // must be null terminated
|
||||
} lumpinfo_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char name[16];
|
||||
unsigned width, height;
|
||||
unsigned offsets[4]; // four mip maps stored
|
||||
} miptex_t;
|
||||
|
||||
unsigned char pixdata[256];
|
||||
|
||||
float linearpalette[256][3];
|
||||
float d_red, d_green, d_blue;
|
||||
int colors_used;
|
||||
int color_used[256];
|
||||
float maxdistortion;
|
||||
unsigned char palLogo[768];
|
||||
|
||||
/*
|
||||
=============
|
||||
AveragePixels
|
||||
=============
|
||||
*/
|
||||
unsigned char AveragePixels (int count)
|
||||
{
|
||||
return pixdata[0];
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
GrabMip
|
||||
|
||||
filename MIP x y width height
|
||||
must be multiples of sixteen
|
||||
==============
|
||||
*/
|
||||
int GrabMip ( HANDLE hdib, unsigned char *lump_p, char *lumpname, COLORREF crf, int *width, int *height)
|
||||
{
|
||||
int i,x,y,xl,yl,xh,yh,w,h;
|
||||
unsigned char *screen_p, *source;
|
||||
miptex_t *qtex;
|
||||
int miplevel, mipstep;
|
||||
int xx, yy;
|
||||
int count;
|
||||
int byteimagewidth, byteimageheight;
|
||||
unsigned char *byteimage;
|
||||
LPBITMAPINFO lpbmi; // pointer to BITMAPINFO structure (Win3.0)
|
||||
|
||||
/* get pointer to BITMAPINFO (Win 3.0) */
|
||||
// dgoodenough - GlobalLock is win32 specific, skip using it for now, we'll fix this up later
|
||||
// PS3_BUILDFIX
|
||||
// FIXME FIXME FIXME - This will need help.
|
||||
#if defined( _PS3 )
|
||||
lpbmi = NULL;
|
||||
#else
|
||||
lpbmi = (LPBITMAPINFO)::GlobalLock((HGLOBAL)hdib);
|
||||
#endif
|
||||
unsigned char *lump_start = lump_p;
|
||||
|
||||
xl = yl = 0;
|
||||
w = lpbmi->bmiHeader.biWidth;
|
||||
h = lpbmi->bmiHeader.biHeight;
|
||||
|
||||
*width = w;
|
||||
*height = h;
|
||||
|
||||
byteimage = (unsigned char *)((LPSTR)lpbmi + sizeof( BITMAPINFOHEADER ) + 256 * sizeof( RGBQUAD ) );
|
||||
|
||||
if ( (w & 15) || (h & 15) )
|
||||
return 0; //Error ("line %i: miptex sizes must be multiples of 16", scriptline);
|
||||
|
||||
xh = xl+w;
|
||||
yh = yl+h;
|
||||
|
||||
qtex = (miptex_t *)lump_p;
|
||||
qtex->width = (unsigned)(w);
|
||||
qtex->height = (unsigned)(h);
|
||||
Q_strncpy (qtex->name, lumpname, sizeof( qtex->name) );
|
||||
|
||||
lump_p = (unsigned char *)&qtex->offsets[4];
|
||||
|
||||
byteimagewidth = w;
|
||||
byteimageheight = h;
|
||||
|
||||
source = (unsigned char *)lump_p;
|
||||
qtex->offsets[0] = (unsigned)((unsigned char *)lump_p - (unsigned char *)qtex);
|
||||
|
||||
// We're reading from a dib, so go bottom up
|
||||
screen_p = byteimage + (h - 1) * w;
|
||||
for (y=yl ; y<yh ; y++)
|
||||
{
|
||||
for (x=xl ; x<xh ; x++)
|
||||
*lump_p++ = *screen_p++;
|
||||
|
||||
screen_p -= 2 * w;
|
||||
}
|
||||
|
||||
// calculate gamma corrected linear palette
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
float f = (float)(palLogo[i*3+j] / 255.0);
|
||||
linearpalette[i][j] = f; //pow((double)f, 2); // assume textures are done at 2.2, we want to remap them at 1.0
|
||||
}
|
||||
}
|
||||
|
||||
maxdistortion = 0;
|
||||
// assume palette full if it's a transparent texture
|
||||
colors_used = 256;
|
||||
for (i = 0; i < 256; i++)
|
||||
color_used[i] = 1;
|
||||
|
||||
|
||||
//
|
||||
// subsample for greater mip levels
|
||||
//
|
||||
|
||||
for (miplevel = 1 ; miplevel<4 ; miplevel++)
|
||||
{
|
||||
d_red = d_green = d_blue = 0; // no distortion yet
|
||||
qtex->offsets[miplevel] = (unsigned)(lump_p - (unsigned char *)qtex);
|
||||
|
||||
mipstep = 1<<miplevel;
|
||||
|
||||
for (y=0 ; y<h ; y+=mipstep)
|
||||
{
|
||||
for (x = 0 ; x<w ; x+= mipstep)
|
||||
{
|
||||
count = 0;
|
||||
for (yy=0 ; yy<mipstep ; yy++)
|
||||
{
|
||||
for (xx=0 ; xx<mipstep ; xx++)
|
||||
pixdata[count++] = source[(y+yy)*w + x + xx ];
|
||||
}
|
||||
|
||||
*lump_p++ = AveragePixels (count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// dgoodenough - GlobalUnlock is win32 specific, skip using it for now, we'll fix this up later
|
||||
// PS3_BUILDFIX
|
||||
// FIXME FIXME FIXME - This will need help.
|
||||
#if !defined( _PS3 )
|
||||
::GlobalUnlock(lpbmi);
|
||||
#endif
|
||||
|
||||
// Write out palette in 16bit mode
|
||||
*(unsigned short *) lump_p = 256; // palette size
|
||||
lump_p += sizeof(short);
|
||||
|
||||
memcpy(lump_p, &palLogo[0], 765);
|
||||
lump_p += 765;
|
||||
|
||||
*lump_p++ = (unsigned char)(crf & 0xFF);
|
||||
|
||||
*lump_p++ = (unsigned char)((crf >> 8) & 0xFF);
|
||||
|
||||
*lump_p++ = (unsigned char)((crf >> 16) & 0xFF);
|
||||
|
||||
return lump_p - lump_start;
|
||||
}
|
||||
|
||||
|
||||
void UpdateLogoWAD( void *phdib, int r, int g, int b )
|
||||
{
|
||||
char logoname[ 32 ];
|
||||
char *pszName;
|
||||
Q_strncpy( logoname, "LOGO", sizeof( logoname ) );
|
||||
pszName = &logoname[ 0 ];
|
||||
|
||||
HANDLE hdib = (HANDLE)phdib;
|
||||
COLORREF crf = RGB( r, g, b );
|
||||
|
||||
if ((!pszName) || (pszName[0] == 0) || (hdib == NULL))
|
||||
return;
|
||||
// Generate lump
|
||||
|
||||
unsigned char *buf = (unsigned char *)_alloca( 16384 );
|
||||
|
||||
CUtlBuffer buffer( 0, 16384 );
|
||||
|
||||
int width, height;
|
||||
|
||||
int length = GrabMip (hdib, buf, pszName, crf, &width, &height);
|
||||
if ( length == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool sizevalid = false;
|
||||
|
||||
if ( width == height )
|
||||
{
|
||||
if ( width == 16 ||
|
||||
width == 32 ||
|
||||
width == 64 )
|
||||
{
|
||||
sizevalid = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !sizevalid )
|
||||
return;
|
||||
|
||||
while (length & 3)
|
||||
length++;
|
||||
|
||||
// Write Header
|
||||
wadinfo_t header;
|
||||
header.identification[0] = 'W';
|
||||
header.identification[1] = 'A';
|
||||
header.identification[2] = 'D';
|
||||
header.identification[3] = '3';
|
||||
header.numlumps = 1;
|
||||
header.infotableofs = 0;
|
||||
|
||||
buffer.Put( &header, sizeof( wadinfo_t ) );
|
||||
|
||||
// Fill Ino info table
|
||||
lumpinfo_t info;
|
||||
Q_memset (&info, 0, sizeof(info));
|
||||
Q_strncpy(info.name, pszName, sizeof( info.name ) );
|
||||
info.filepos = (int)sizeof(wadinfo_t);
|
||||
info.size = info.disksize = length;
|
||||
info.type = TYP_LUMPY;
|
||||
info.compression = 0;
|
||||
|
||||
// Write Lump
|
||||
buffer.Put( buf, length );
|
||||
|
||||
// Write info table
|
||||
buffer.Put( &info, sizeof( lumpinfo_t ) );
|
||||
|
||||
int savepos = buffer.TellPut();
|
||||
|
||||
buffer.SeekPut( CUtlBuffer::SEEK_HEAD, 0 );
|
||||
|
||||
header.infotableofs = length + sizeof(wadinfo_t);
|
||||
|
||||
buffer.Put( &header, sizeof( wadinfo_t ) );
|
||||
|
||||
buffer.SeekPut( CUtlBuffer::SEEK_HEAD, savepos );
|
||||
|
||||
// Output to file
|
||||
FileHandle_t file;
|
||||
file = g_pFullFileSystem->Open( "pldecal.wad", "wb" );
|
||||
if ( file != FILESYSTEM_INVALID_HANDLE )
|
||||
{
|
||||
g_pFullFileSystem->Write( buffer.Base(), buffer.TellPut(), file );
|
||||
g_pFullFileSystem->Close( file );
|
||||
}
|
||||
|
||||
}
|
||||
212
game/client/cstrike15/gameui/modinfo.cpp
Normal file
212
game/client/cstrike15/gameui/modinfo.cpp
Normal file
@@ -0,0 +1,212 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
|
||||
#include "modinfo.h"
|
||||
#include "keyvalues.h"
|
||||
#include "vgui_controls/Controls.h"
|
||||
#include "filesystem.h"
|
||||
#include "engineinterface.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: singleton accessor
|
||||
//-----------------------------------------------------------------------------
|
||||
CModInfo &ModInfo()
|
||||
{
|
||||
static CModInfo s_ModInfo;
|
||||
return s_ModInfo;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CModInfo::CModInfo()
|
||||
{
|
||||
m_pModData = new KeyValues("ModData");
|
||||
m_wcsGameTitle[0] = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CModInfo::~CModInfo()
|
||||
{
|
||||
FreeModInfo();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CModInfo::FreeModInfo()
|
||||
{
|
||||
if (m_pModData)
|
||||
{
|
||||
m_pModData->deleteThis();
|
||||
m_pModData = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: data accessor
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CModInfo::IsMultiplayerOnly()
|
||||
{
|
||||
return (stricmp(m_pModData->GetString("type", ""), "multiplayer_only") == 0);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: data accessor
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CModInfo::IsSinglePlayerOnly()
|
||||
{
|
||||
return (stricmp(m_pModData->GetString("type", ""), "singleplayer_only") == 0);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: data accessor
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CModInfo::GetFallbackDir()
|
||||
{
|
||||
return m_pModData->GetString("fallback_dir", "");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: data accessor
|
||||
//-----------------------------------------------------------------------------
|
||||
const wchar_t *CModInfo::GetGameTitle()
|
||||
{
|
||||
if (!m_wcsGameTitle[0])
|
||||
{
|
||||
// for some reason, the standard ILocalize::ConvertANSIToUnicode() strips off
|
||||
// the '<27>' character in 'HALF-LIFE<46>' - so just do a straight upconvert to unicode
|
||||
const char *title = m_pModData->GetString("title", "");
|
||||
int i = 0;
|
||||
for (; title[i] != 0; ++i)
|
||||
{
|
||||
m_wcsGameTitle[i] = (wchar_t)title[i];
|
||||
}
|
||||
m_wcsGameTitle[i] = 0;
|
||||
}
|
||||
|
||||
return m_wcsGameTitle;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: data accessor
|
||||
//-----------------------------------------------------------------------------
|
||||
const wchar_t *CModInfo::GetGameTitle2()
|
||||
{
|
||||
if (!m_wcsGameTitle2[0])
|
||||
{
|
||||
// for some reason, the standard ILocalize::ConvertANSIToUnicode() strips off
|
||||
// the '<27>' character in 'HALF-LIFE<46>' - so just do a straight upconvert to unicode
|
||||
const char *title2 = m_pModData->GetString("title2", "");
|
||||
int i = 0;
|
||||
for (; title2[i] != 0; ++i)
|
||||
{
|
||||
m_wcsGameTitle2[i] = (wchar_t)title2[i];
|
||||
}
|
||||
m_wcsGameTitle2[i] = 0;
|
||||
}
|
||||
|
||||
return m_wcsGameTitle2;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: data accessor
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CModInfo::GetGameName()
|
||||
{
|
||||
return m_pModData->GetString("game", "");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: data accessor
|
||||
//-----------------------------------------------------------------------------
|
||||
KeyValues *CModInfo::GetHiddenMaps()
|
||||
{
|
||||
return m_pModData->FindKey( "hidden_maps" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: data accessor
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CModInfo::HasPortals()
|
||||
{
|
||||
return (stricmp(m_pModData->GetString("hasportals", "0"), "1") == 0);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: data accessor
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CModInfo::NoDifficulty()
|
||||
{
|
||||
return (stricmp(m_pModData->GetString("nodifficulty", "0"), "1") == 0);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: data accessor
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CModInfo::NoModels()
|
||||
{
|
||||
return (stricmp(m_pModData->GetString("nomodels", "0"), "1") == 0);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: data accessor
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CModInfo::NoHiModel()
|
||||
{
|
||||
return (stricmp(m_pModData->GetString("nohimodel", "0"), "1") == 0);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: data accessor
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CModInfo::NoCrosshair()
|
||||
{
|
||||
return (stricmp(m_pModData->GetString("nocrosshair", "1"), "1") == 0);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: data accessor
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CModInfo::AdvCrosshair()
|
||||
{
|
||||
return (stricmp(m_pModData->GetString("advcrosshair", "0"), "1") == 0);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CModInfo::LoadCurrentGameInfo()
|
||||
{
|
||||
// Load up gameinfo for the current mod
|
||||
char const *filename = "gameinfo.txt";
|
||||
m_pModData->LoadFromFile( g_pFullFileSystem, filename );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: loads file from null-terminated buffer
|
||||
//-----------------------------------------------------------------------------
|
||||
void CModInfo::LoadGameInfoFromBuffer( const char *buffer )
|
||||
{
|
||||
// Load up gameinfo.txt for the current mod
|
||||
m_pModData->LoadFromBuffer( "", buffer );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: data accessor
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CModInfo::UseGameLogo()
|
||||
{
|
||||
return ( Q_stricmp( m_pModData->GetString( "gamelogo", "0" ), "1" ) == 0 );
|
||||
}
|
||||
68
game/client/cstrike15/gameui/modinfo.h
Normal file
68
game/client/cstrike15/gameui/modinfo.h
Normal file
@@ -0,0 +1,68 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef MODINFO_H
|
||||
#define MODINFO_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui/vgui.h>
|
||||
|
||||
class KeyValues;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: contains all the data entered about a mod in gameinfo.txt
|
||||
//-----------------------------------------------------------------------------
|
||||
class CModInfo
|
||||
{
|
||||
public:
|
||||
CModInfo();
|
||||
~CModInfo();
|
||||
void FreeModInfo();
|
||||
|
||||
// loads mod info from gameinfo.txt
|
||||
void LoadCurrentGameInfo();
|
||||
|
||||
// loads gameinfo from null-terminated string
|
||||
void LoadGameInfoFromBuffer( const char *buffer );
|
||||
|
||||
// data accessors
|
||||
const wchar_t *GetGameTitle();
|
||||
const wchar_t *GetGameTitle2();
|
||||
const char *GetGameName();
|
||||
|
||||
bool IsMultiplayerOnly();
|
||||
bool IsSinglePlayerOnly();
|
||||
|
||||
bool HasPortals();
|
||||
|
||||
bool NoDifficulty();
|
||||
bool NoModels();
|
||||
bool NoHiModel();
|
||||
bool NoCrosshair();
|
||||
bool AdvCrosshair();
|
||||
const char *GetFallbackDir();
|
||||
bool UseGameLogo();
|
||||
|
||||
KeyValues *GetHiddenMaps();
|
||||
|
||||
private:
|
||||
wchar_t m_wcsGameTitle[128];
|
||||
wchar_t m_wcsGameTitle2[128];
|
||||
KeyValues *m_pModData;
|
||||
|
||||
// Deleted copy operations (rule of 3!)
|
||||
CModInfo( const CModInfo& ); // = delete
|
||||
CModInfo& operator= ( const CModInfo& ); // = delete
|
||||
};
|
||||
|
||||
|
||||
// singleton accessor
|
||||
extern CModInfo &ModInfo();
|
||||
|
||||
#endif // MODINFO_H
|
||||
39
game/client/cstrike15/gameui/mousemessageforwardingpanel.cpp
Normal file
39
game/client/cstrike15/gameui/mousemessageforwardingpanel.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "mousemessageforwardingpanel.h"
|
||||
#include "keyvalues.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
CMouseMessageForwardingPanel::CMouseMessageForwardingPanel( Panel *parent, const char *name ) : BaseClass( parent, name )
|
||||
{
|
||||
// don't draw an
|
||||
SetPaintEnabled(false);
|
||||
SetPaintBackgroundEnabled(false);
|
||||
SetPaintBorderEnabled(false);
|
||||
}
|
||||
|
||||
void CMouseMessageForwardingPanel::PerformLayout()
|
||||
{
|
||||
// fill out the whole area
|
||||
int w, t;
|
||||
GetParent()->GetSize(w, t);
|
||||
SetBounds(0, 0, w, t);
|
||||
}
|
||||
|
||||
void CMouseMessageForwardingPanel::OnMousePressed( vgui::MouseCode code )
|
||||
{
|
||||
CallParentFunction( new KeyValues("MousePressed", "code", code) );
|
||||
}
|
||||
|
||||
void CMouseMessageForwardingPanel::OnMouseDoublePressed( vgui::MouseCode code )
|
||||
{
|
||||
CallParentFunction( new KeyValues("MouseDoublePressed", "code", code) );
|
||||
}
|
||||
29
game/client/cstrike15/gameui/mousemessageforwardingpanel.h
Normal file
29
game/client/cstrike15/gameui/mousemessageforwardingpanel.h
Normal file
@@ -0,0 +1,29 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef MOUSEMESSAGEFORWARDINGPANEL_H
|
||||
#define MOUSEMESSAGEFORWARDINGPANEL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui_controls/Panel.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Invisible panel that forwards up mouse movement
|
||||
//-----------------------------------------------------------------------------
|
||||
class CMouseMessageForwardingPanel : public vgui::Panel
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CMouseMessageForwardingPanel, vgui::Panel );
|
||||
public:
|
||||
CMouseMessageForwardingPanel( Panel *parent, const char *name );
|
||||
|
||||
virtual void PerformLayout( void );
|
||||
virtual void OnMousePressed( vgui::MouseCode code );
|
||||
virtual void OnMouseDoublePressed( vgui::MouseCode code );
|
||||
};
|
||||
|
||||
#endif //MOUSEMESSAGEFORWARDINGPANEL_H
|
||||
446
game/client/cstrike15/gameui/multiplayeradvanceddialog.cpp
Normal file
446
game/client/cstrike15/gameui/multiplayeradvanceddialog.cpp
Normal file
@@ -0,0 +1,446 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "multiplayeradvanceddialog.h"
|
||||
|
||||
#include <vgui/ILocalize.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include <vgui_controls/ListPanel.h>
|
||||
#include <keyvalues.h>
|
||||
#include <vgui_controls/Label.h>
|
||||
#include <vgui_controls/Button.h>
|
||||
#include <vgui_controls/MessageBox.h>
|
||||
#include <vgui_controls/CheckButton.h>
|
||||
#include <vgui_controls/ComboBox.h>
|
||||
#include <vgui_controls/TextEntry.h>
|
||||
#include "panellistpanel.h"
|
||||
#include <vgui/IInput.h>
|
||||
|
||||
#include "filesystem.h"
|
||||
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
#define OPTIONS_DIR "cfg"
|
||||
#define DEFAULT_OPTIONS_FILE OPTIONS_DIR "/user_default.scr"
|
||||
#define OPTIONS_FILE OPTIONS_DIR "/user.scr"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CMultiplayerAdvancedDialog::CMultiplayerAdvancedDialog(vgui::Panel *parent) : BaseClass(NULL, "MultiplayerAdvancedDialog")
|
||||
{
|
||||
SetBounds(0, 0, 372, 160);
|
||||
SetSizeable( false );
|
||||
|
||||
SetTitle("#GameUI_MultiplayerAdvanced", true);
|
||||
|
||||
Button *cancel = new Button( this, "Cancel", "#GameUI_Cancel" );
|
||||
cancel->SetCommand( "Close" );
|
||||
|
||||
Button *ok = new Button( this, "OK", "#GameUI_OK" );
|
||||
ok->SetCommand( "Ok" );
|
||||
|
||||
m_pListPanel = new CPanelListPanel( this, "PanelListPanel" );
|
||||
|
||||
m_pList = NULL;
|
||||
|
||||
m_pDescription = new CInfoDescription( m_pListPanel );
|
||||
m_pDescription->InitFromFile( DEFAULT_OPTIONS_FILE );
|
||||
m_pDescription->InitFromFile( OPTIONS_FILE );
|
||||
m_pDescription->TransferCurrentValues( NULL );
|
||||
|
||||
LoadControlSettings("Resource\\MultiplayerAdvancedDialog.res");
|
||||
CreateControls();
|
||||
|
||||
MoveToCenterOfScreen();
|
||||
SetSizeable( false );
|
||||
SetDeleteSelfOnClose( true );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CMultiplayerAdvancedDialog::~CMultiplayerAdvancedDialog()
|
||||
{
|
||||
delete m_pDescription;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CMultiplayerAdvancedDialog::Activate()
|
||||
{
|
||||
BaseClass::Activate();
|
||||
input()->SetAppModalSurface(GetVPanel());
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CMultiplayerAdvancedDialog::OnClose()
|
||||
{
|
||||
BaseClass::OnClose();
|
||||
MarkForDeletion();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *command -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CMultiplayerAdvancedDialog::OnCommand( const char *command )
|
||||
{
|
||||
if ( !stricmp( command, "Ok" ) )
|
||||
{
|
||||
// OnApplyChanges();
|
||||
SaveValues();
|
||||
OnClose();
|
||||
return;
|
||||
}
|
||||
|
||||
BaseClass::OnCommand( command );
|
||||
}
|
||||
|
||||
void CMultiplayerAdvancedDialog::OnKeyCodeTyped(KeyCode code)
|
||||
{
|
||||
// force ourselves to be closed if the escape key it pressed
|
||||
if (code == KEY_ESCAPE)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnKeyCodeTyped(code);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CMultiplayerAdvancedDialog::GatherCurrentValues()
|
||||
{
|
||||
if ( !m_pDescription )
|
||||
return;
|
||||
|
||||
// OK
|
||||
CheckButton *pBox;
|
||||
TextEntry *pEdit;
|
||||
ComboBox *pCombo;
|
||||
|
||||
mpcontrol_t *pList;
|
||||
|
||||
CScriptObject *pObj;
|
||||
CScriptListItem *pItem;
|
||||
|
||||
char szValue[256];
|
||||
char strValue[ 256 ];
|
||||
|
||||
pList = m_pList;
|
||||
while ( pList )
|
||||
{
|
||||
pObj = pList->pScrObj;
|
||||
|
||||
if ( !pList->pControl )
|
||||
{
|
||||
pObj->SetCurValue( pObj->defValue );
|
||||
pList = pList->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
switch ( pObj->type )
|
||||
{
|
||||
case O_BOOL:
|
||||
pBox = (CheckButton *)pList->pControl;
|
||||
Q_snprintf( szValue, 256, "%s", pBox->IsSelected() ? "1" : "0" );
|
||||
break;
|
||||
case O_NUMBER:
|
||||
pEdit = ( TextEntry * )pList->pControl;
|
||||
pEdit->GetText( strValue, sizeof( strValue ) );
|
||||
Q_snprintf( szValue, 256, "%s", strValue );
|
||||
break;
|
||||
case O_STRING:
|
||||
pEdit = ( TextEntry * )pList->pControl;
|
||||
pEdit->GetText( strValue, sizeof( strValue ) );
|
||||
Q_snprintf( szValue, 256, "%s", strValue );
|
||||
break;
|
||||
case O_LIST:
|
||||
pCombo = (ComboBox *)pList->pControl;
|
||||
// pCombo->GetText( strValue, sizeof( strValue ) );
|
||||
int activeItem = pCombo->GetActiveItem();
|
||||
|
||||
pItem = pObj->pListItems;
|
||||
// int n = (int)pObj->fdefValue;
|
||||
|
||||
while ( pItem )
|
||||
{
|
||||
if (!activeItem--)
|
||||
break;
|
||||
|
||||
pItem = pItem->pNext;
|
||||
}
|
||||
|
||||
if ( pItem )
|
||||
{
|
||||
Q_snprintf( szValue, 256, "%s", pItem->szValue );
|
||||
}
|
||||
else // Couln't find index
|
||||
{
|
||||
//assert(!("Couldn't find string in list, using default value"));
|
||||
Q_snprintf( szValue, 256, "%s", pObj->defValue );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Remove double quotes and % characters
|
||||
UTIL_StripInvalidCharacters( szValue, sizeof(szValue) );
|
||||
|
||||
strcpy( strValue, szValue );
|
||||
|
||||
pObj->SetCurValue( strValue );
|
||||
|
||||
pList = pList->next;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CMultiplayerAdvancedDialog::CreateControls()
|
||||
{
|
||||
DestroyControls();
|
||||
|
||||
// Go through desciption creating controls
|
||||
CScriptObject *pObj;
|
||||
|
||||
pObj = m_pDescription->pObjList;
|
||||
|
||||
mpcontrol_t *pCtrl;
|
||||
|
||||
CheckButton *pBox;
|
||||
TextEntry *pEdit;
|
||||
ComboBox *pCombo;
|
||||
CScriptListItem *pListItem;
|
||||
|
||||
Panel *objParent = m_pListPanel;
|
||||
|
||||
while ( pObj )
|
||||
{
|
||||
if ( pObj->type == O_OBSOLETE )
|
||||
{
|
||||
pObj = pObj->pNext;
|
||||
continue;
|
||||
}
|
||||
|
||||
pCtrl = new mpcontrol_t( objParent, "mpcontrol_t" );
|
||||
pCtrl->type = pObj->type;
|
||||
|
||||
switch ( pCtrl->type )
|
||||
{
|
||||
case O_BOOL:
|
||||
pBox = new CheckButton( pCtrl, "DescCheckButton", pObj->prompt );
|
||||
pBox->SetSelected( pObj->fdefValue != 0.0f ? true : false );
|
||||
|
||||
pCtrl->pControl = (Panel *)pBox;
|
||||
break;
|
||||
case O_STRING:
|
||||
case O_NUMBER:
|
||||
pEdit = new TextEntry( pCtrl, "DescTextEntry");
|
||||
pEdit->InsertString(pObj->defValue);
|
||||
pCtrl->pControl = (Panel *)pEdit;
|
||||
break;
|
||||
case O_LIST:
|
||||
pCombo = new ComboBox( pCtrl, "DescComboBox", 5, false );
|
||||
|
||||
pListItem = pObj->pListItems;
|
||||
while ( pListItem )
|
||||
{
|
||||
pCombo->AddItem( pListItem->szItemText, NULL );
|
||||
pListItem = pListItem->pNext;
|
||||
}
|
||||
|
||||
pCombo->ActivateItemByRow((int)pObj->fdefValue);
|
||||
|
||||
pCtrl->pControl = (Panel *)pCombo;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if ( pCtrl->type != O_BOOL )
|
||||
{
|
||||
pCtrl->pPrompt = new vgui::Label( pCtrl, "DescLabel", "" );
|
||||
pCtrl->pPrompt->SetContentAlignment( vgui::Label::a_west );
|
||||
pCtrl->pPrompt->SetTextInset( 5, 0 );
|
||||
pCtrl->pPrompt->SetText( pObj->prompt );
|
||||
}
|
||||
|
||||
pCtrl->pScrObj = pObj;
|
||||
pCtrl->SetSize( 100, 28 );
|
||||
//pCtrl->SetBorder( scheme()->GetBorder(1, "DepressedButtonBorder") );
|
||||
m_pListPanel->AddItem( pCtrl );
|
||||
|
||||
// Link it in
|
||||
if ( !m_pList )
|
||||
{
|
||||
m_pList = pCtrl;
|
||||
pCtrl->next = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
mpcontrol_t *p;
|
||||
p = m_pList;
|
||||
while ( p )
|
||||
{
|
||||
if ( !p->next )
|
||||
{
|
||||
p->next = pCtrl;
|
||||
pCtrl->next = NULL;
|
||||
break;
|
||||
}
|
||||
p = p->next;
|
||||
}
|
||||
}
|
||||
|
||||
pObj = pObj->pNext;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CMultiplayerAdvancedDialog::DestroyControls()
|
||||
{
|
||||
mpcontrol_t *p, *n;
|
||||
|
||||
p = m_pList;
|
||||
while ( p )
|
||||
{
|
||||
n = p->next;
|
||||
//
|
||||
delete p->pControl;
|
||||
delete p->pPrompt;
|
||||
delete p;
|
||||
p = n;
|
||||
}
|
||||
|
||||
m_pList = NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CMultiplayerAdvancedDialog::SaveValues()
|
||||
{
|
||||
// Get the values from the controls:
|
||||
GatherCurrentValues();
|
||||
|
||||
// Create the game.cfg file
|
||||
if ( m_pDescription )
|
||||
{
|
||||
FileHandle_t fp;
|
||||
|
||||
// Add settings to config.cfg
|
||||
m_pDescription->WriteToConfig();
|
||||
|
||||
g_pFullFileSystem->CreateDirHierarchy( OPTIONS_DIR );
|
||||
fp = g_pFullFileSystem->Open( OPTIONS_FILE, "wb" );
|
||||
if ( fp )
|
||||
{
|
||||
m_pDescription->WriteToScriptFile( fp );
|
||||
g_pFullFileSystem->Close( fp );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor, load/save client settings object
|
||||
//-----------------------------------------------------------------------------
|
||||
CInfoDescription::CInfoDescription( CPanelListPanel *panel )
|
||||
: CDescription( panel )
|
||||
{
|
||||
setHint( "// NOTE: THIS FILE IS AUTOMATICALLY REGENERATED, \r\n\
|
||||
//DO NOT EDIT THIS HEADER, YOUR COMMENTS WILL BE LOST IF YOU DO\r\n\
|
||||
// User options script\r\n\
|
||||
//\r\n\
|
||||
// Format:\r\n\
|
||||
// Version [float]\r\n\
|
||||
// Options description followed by \r\n\
|
||||
// Options defaults\r\n\
|
||||
//\r\n\
|
||||
// Option description syntax:\r\n\
|
||||
//\r\n\
|
||||
// \"cvar\" { \"Prompt\" { type [ type info ] } { default } }\r\n\
|
||||
//\r\n\
|
||||
// type = \r\n\
|
||||
// BOOL (a yes/no toggle)\r\n\
|
||||
// STRING\r\n\
|
||||
// NUMBER\r\n\
|
||||
// LIST\r\n\
|
||||
//\r\n\
|
||||
// type info:\r\n\
|
||||
// BOOL no type info\r\n\
|
||||
// NUMBER min max range, use -1 -1 for no limits\r\n\
|
||||
// STRING no type info\r\n\
|
||||
// LIST "" delimited list of options value pairs\r\n\
|
||||
//\r\n\
|
||||
//\r\n\
|
||||
// default depends on type\r\n\
|
||||
// BOOL is \"0\" or \"1\"\r\n\
|
||||
// NUMBER is \"value\"\r\n\
|
||||
// STRING is \"value\"\r\n\
|
||||
// LIST is \"index\", where index \"0\" is the first element of the list\r\n\r\n\r\n" );
|
||||
|
||||
setDescription( "INFO_OPTIONS" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CInfoDescription::WriteScriptHeader( FileHandle_t fp )
|
||||
{
|
||||
char am_pm[] = "AM";
|
||||
tm newtime;
|
||||
Plat_GetLocalTime( &newtime );
|
||||
|
||||
g_pFullFileSystem->FPrintf( fp, "%s", (char *)getHint() );
|
||||
|
||||
char timeString[64];
|
||||
Plat_GetTimeString( &newtime, timeString, sizeof( timeString ) );
|
||||
|
||||
// Write out the comment and Cvar Info:
|
||||
g_pFullFileSystem->FPrintf( fp, "// Half-Life User Info Configuration Layout Script (stores last settings chosen, too)\r\n" );
|
||||
g_pFullFileSystem->FPrintf( fp, "// File generated: %.19s %s\r\n", timeString, am_pm );
|
||||
g_pFullFileSystem->FPrintf( fp, "//\r\n//\r\n// Cvar\t-\tSetting\r\n\r\n" );
|
||||
g_pFullFileSystem->FPrintf( fp, "VERSION %.1f\r\n\r\n", SCRIPT_VERSION );
|
||||
g_pFullFileSystem->FPrintf( fp, "DESCRIPTION INFO_OPTIONS\r\n{\r\n" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CInfoDescription::WriteFileHeader( FileHandle_t fp )
|
||||
{
|
||||
char am_pm[] = "AM";
|
||||
tm newtime;
|
||||
Plat_GetLocalTime( &newtime );
|
||||
|
||||
char timeString[64];
|
||||
Plat_GetTimeString( &newtime, timeString, sizeof( timeString ) );
|
||||
|
||||
g_pFullFileSystem->FPrintf( fp, "// Half-Life User Info Configuration Settings\r\n" );
|
||||
g_pFullFileSystem->FPrintf( fp, "// DO NOT EDIT, GENERATED BY HALF-LIFE\r\n" );
|
||||
g_pFullFileSystem->FPrintf( fp, "// File generated: %.19s %s\r\n", timeString, am_pm );
|
||||
g_pFullFileSystem->FPrintf( fp, "//\r\n//\r\n// Cvar\t-\tSetting\r\n\r\n" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
50
game/client/cstrike15/gameui/multiplayeradvanceddialog.h
Normal file
50
game/client/cstrike15/gameui/multiplayeradvanceddialog.h
Normal file
@@ -0,0 +1,50 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef MULTIPLAYERADVANCEDDIALOG_H
|
||||
#define MULTIPLAYERADVANCEDDIALOG_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui_controls/Frame.h>
|
||||
#include "scriptobject.h"
|
||||
#include <vgui/KeyCode.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Displays a game-specific list of options
|
||||
//-----------------------------------------------------------------------------
|
||||
class CMultiplayerAdvancedDialog : public vgui::Frame
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CMultiplayerAdvancedDialog, vgui::Frame );
|
||||
|
||||
public:
|
||||
explicit CMultiplayerAdvancedDialog(vgui::Panel *parent);
|
||||
~CMultiplayerAdvancedDialog();
|
||||
|
||||
virtual void Activate();
|
||||
|
||||
private:
|
||||
|
||||
void CreateControls();
|
||||
void DestroyControls();
|
||||
void GatherCurrentValues();
|
||||
void SaveValues();
|
||||
|
||||
CInfoDescription *m_pDescription;
|
||||
|
||||
mpcontrol_t *m_pList;
|
||||
|
||||
CPanelListPanel *m_pListPanel;
|
||||
|
||||
virtual void OnCommand( const char *command );
|
||||
virtual void OnClose();
|
||||
virtual void OnKeyCodeTyped(vgui::KeyCode code);
|
||||
};
|
||||
|
||||
|
||||
#endif // MULTIPLAYERADVANCEDDIALOG_H
|
||||
1574
game/client/cstrike15/gameui/newgamedialog.cpp
Normal file
1574
game/client/cstrike15/gameui/newgamedialog.cpp
Normal file
File diff suppressed because it is too large
Load Diff
114
game/client/cstrike15/gameui/newgamedialog.h
Normal file
114
game/client/cstrike15/gameui/newgamedialog.h
Normal file
@@ -0,0 +1,114 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef NEWGAMEDIALOG_H
|
||||
#define NEWGAMEDIALOG_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui_controls/Frame.h"
|
||||
#include "vgui_controls/footerpanel.h"
|
||||
#include "utlvector.h"
|
||||
|
||||
class CGameChapterPanel;
|
||||
class CSkillSelectionDialog;
|
||||
|
||||
// Slot indices in new game menu
|
||||
#define INVALID_INDEX -1
|
||||
#define SLOT_OFFLEFT 0
|
||||
#define SLOT_LEFT 1
|
||||
#define SLOT_CENTER 2
|
||||
#define SLOT_RIGHT 3
|
||||
#define SLOT_OFFRIGHT 4
|
||||
#define NUM_SLOTS 5
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Handles starting a new game, skill and chapter selection
|
||||
//-----------------------------------------------------------------------------
|
||||
class CNewGameDialog : public vgui::Frame
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CNewGameDialog, vgui::Frame );
|
||||
|
||||
public:
|
||||
MESSAGE_FUNC( FinishScroll, "FinishScroll" );
|
||||
MESSAGE_FUNC( StartGame, "StartGame" );
|
||||
|
||||
CNewGameDialog(vgui::Panel *parent, bool bCommentaryMode );
|
||||
~CNewGameDialog();
|
||||
|
||||
virtual void Activate( void );
|
||||
|
||||
virtual void ApplySettings( KeyValues *inResourceData );
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
virtual void OnCommand( const char *command );
|
||||
virtual void OnClose( void );
|
||||
virtual void PaintBackground();
|
||||
void SetSelectedChapterIndex( int index );
|
||||
void SetSelectedChapter( const char *chapter );
|
||||
void UpdatePanelLockedStatus( int iUnlockedChapter, int i, CGameChapterPanel *pChapterPanel );
|
||||
|
||||
void SetCommentaryMode( bool bCommentary ) { m_bCommentaryMode = bCommentary; }
|
||||
|
||||
// Xbox: Defined values are also used to shift the slot indices
|
||||
enum EScrollDirection
|
||||
{
|
||||
SCROLL_RIGHT = -1,
|
||||
SCROLL_NONE = 0,
|
||||
SCROLL_LEFT = 1
|
||||
};
|
||||
EScrollDirection m_ScrollDirection;
|
||||
|
||||
private:
|
||||
int m_iSelectedChapter;
|
||||
|
||||
CUtlVector<CGameChapterPanel *> m_ChapterPanels;
|
||||
|
||||
vgui::DHANDLE<CSkillSelectionDialog> m_hSkillSelectionDialog;
|
||||
|
||||
vgui::Button *m_pPlayButton;
|
||||
vgui::Button *m_pNextButton;
|
||||
vgui::Button *m_pPrevButton;
|
||||
vgui::Panel *m_pCenterBg;
|
||||
vgui::Label *m_pChapterTitleLabels[2];
|
||||
vgui::Label *m_pBonusSelection;
|
||||
vgui::ImagePanel *m_pBonusSelectionBorder;
|
||||
vgui::CFooterPanel *m_pFooter;
|
||||
bool m_bCommentaryMode;
|
||||
vgui::Label *m_pCommentaryLabel;
|
||||
|
||||
// Xbox
|
||||
void ScrollSelectionPanels( EScrollDirection dir );
|
||||
void ScrollBonusSelection( EScrollDirection dir );
|
||||
void PreScroll( EScrollDirection dir );
|
||||
void PostScroll( EScrollDirection dir );
|
||||
void SetFastScroll( bool fast );
|
||||
void ContinueScrolling( void );
|
||||
void AnimateSelectionPanels( void );
|
||||
void ShiftPanelIndices( int offset );
|
||||
bool IsValidPanel( const int idx );
|
||||
void InitPanelIndexForDisplay( const int idx );
|
||||
void UpdateMenuComponents( EScrollDirection dir );
|
||||
void UpdateBonusSelection( void );
|
||||
|
||||
int m_PanelXPos[ NUM_SLOTS ];
|
||||
int m_PanelYPos[ NUM_SLOTS ];
|
||||
float m_PanelAlpha[ NUM_SLOTS ];
|
||||
int m_PanelIndex[ NUM_SLOTS ];
|
||||
float m_ScrollSpeed;
|
||||
int m_ButtonPressed;
|
||||
int m_ScrollCt;
|
||||
bool m_bScrolling;
|
||||
char m_ActiveTitleIdx;
|
||||
bool m_bMapStarting;
|
||||
int m_iBonusSelection;
|
||||
bool m_bScrollToFirstBonusMap;
|
||||
|
||||
struct BonusMapDescription_t *m_pBonusMapDescription;
|
||||
};
|
||||
|
||||
#endif // NEWGAMEDIALOG_H
|
||||
157
game/client/cstrike15/gameui/optionsdialog.cpp
Normal file
157
game/client/cstrike15/gameui/optionsdialog.cpp
Normal file
@@ -0,0 +1,157 @@
|
||||
//========= Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "basepanel.h"
|
||||
#include "optionsdialog.h"
|
||||
|
||||
#include "vgui_controls/Button.h"
|
||||
#include "vgui_controls/CheckButton.h"
|
||||
#include "vgui_controls/PropertySheet.h"
|
||||
#include "vgui_controls/Label.h"
|
||||
#include "vgui_controls/QueryBox.h"
|
||||
|
||||
#include "vgui/ILocalize.h"
|
||||
#include "vgui/ISurface.h"
|
||||
#include "vgui/ISystem.h"
|
||||
#include "vgui/IVGui.h"
|
||||
|
||||
#include "keyvalues.h"
|
||||
#include "optionssubkeyboard.h"
|
||||
#include "optionssubmouse.h"
|
||||
#include "optionssubaudio.h"
|
||||
#include "optionssubvideo.h"
|
||||
#include "optionssubvoice.h"
|
||||
#include "optionssubmultiplayer.h"
|
||||
#include "optionssubdifficulty.h"
|
||||
#include "optionssubportal.h"
|
||||
#include "modinfo.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Basic help dialog
|
||||
//-----------------------------------------------------------------------------
|
||||
COptionsDialog::COptionsDialog(vgui::Panel *parent, OptionsDialogTabStyle iTabStyle) : PropertyDialog(parent, "OptionsDialog")
|
||||
{
|
||||
SetDeleteSelfOnClose( true );
|
||||
SetBounds(0, 0, 512, 406);
|
||||
|
||||
|
||||
SetSizeable( false );
|
||||
|
||||
// debug timing code, this function takes too long
|
||||
// double s4 = system()->GetCurrentTime();
|
||||
|
||||
if ( iTabStyle == OPTIONS_DIALOG_ALL_TABS )
|
||||
{
|
||||
SetTitle("#GameUI_Options", true);
|
||||
|
||||
if ( ModInfo().IsSinglePlayerOnly() && !ModInfo().NoDifficulty() )
|
||||
{
|
||||
AddPage(new COptionsSubDifficulty(this), "#GameUI_Difficulty");
|
||||
}
|
||||
|
||||
if ( ModInfo().HasPortals() )
|
||||
{
|
||||
AddPage(new COptionsSubPortal(this), "#GameUI_Portal");
|
||||
}
|
||||
|
||||
AddPage(new COptionsSubKeyboard(this), "#GameUI_Keyboard");
|
||||
AddPage(new COptionsSubMouse(this), "#GameUI_Mouse");
|
||||
|
||||
m_pOptionsSubAudio = new COptionsSubAudio(this);
|
||||
AddPage(m_pOptionsSubAudio, "#GameUI_Audio");
|
||||
m_pOptionsSubVideo = new COptionsSubVideo(this);
|
||||
AddPage(m_pOptionsSubVideo, "#GameUI_Video");
|
||||
|
||||
if ( !ModInfo().IsSinglePlayerOnly() )
|
||||
{
|
||||
AddPage(new COptionsSubVoice(this), "#GameUI_Voice");
|
||||
}
|
||||
|
||||
// add the multiplay page last, if we're combo single/multi or just multi
|
||||
if ( (ModInfo().IsMultiplayerOnly() && !ModInfo().IsSinglePlayerOnly()) ||
|
||||
(!ModInfo().IsMultiplayerOnly() && !ModInfo().IsSinglePlayerOnly()) )
|
||||
{
|
||||
AddPage(new COptionsSubMultiplayer(this), "#GameUI_Multiplayer");
|
||||
}
|
||||
}
|
||||
else if ( iTabStyle == OPTIONS_DIALOG_ONLY_BINDING_TABS )
|
||||
{
|
||||
SetTitle("#SFUI_Controller_Edit_Keys_Buttons", true);
|
||||
|
||||
AddPage(new COptionsSubKeyboard(this), "#GameUI_Console_UserSettings");
|
||||
}
|
||||
|
||||
// double s5 = system()->GetCurrentTime();
|
||||
// Msg("COptionsDialog::COptionsDialog(): %.3fms\n", (float)(s5 - s4) * 1000.0f);
|
||||
|
||||
SetApplyButtonVisible(true);
|
||||
GetPropertySheet()->SetTabWidth(84);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
COptionsDialog::~COptionsDialog()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Brings the dialog to the fore
|
||||
//-----------------------------------------------------------------------------
|
||||
void COptionsDialog::Activate()
|
||||
{
|
||||
BaseClass::Activate();
|
||||
EnableApplyButton(false);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Opens the dialog
|
||||
//-----------------------------------------------------------------------------
|
||||
void COptionsDialog::Run()
|
||||
{
|
||||
SetTitle("#GameUI_Options", true);
|
||||
Activate();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Opens the gamma dialog directly
|
||||
//-----------------------------------------------------------------------------
|
||||
void COptionsDialog::OpenGammaDialog()
|
||||
{
|
||||
m_pOptionsSubVideo->OpenGammaDialog();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: To notify BasePanel to restore Scaleform menus, if they are activated.
|
||||
//-----------------------------------------------------------------------------
|
||||
void COptionsDialog::OnFinishedClose( void )
|
||||
{
|
||||
BasePanel()->NotifyVguiDialogClosed();
|
||||
|
||||
BaseClass::OnFinishedClose();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Called when the GameUI is hidden
|
||||
//-----------------------------------------------------------------------------
|
||||
void COptionsDialog::OnGameUIHidden()
|
||||
{
|
||||
// tell our children about it
|
||||
for ( int i = 0 ; i < GetChildCount() ; i++ )
|
||||
{
|
||||
Panel *pChild = GetChild( i );
|
||||
if ( pChild )
|
||||
{
|
||||
PostMessage( pChild, new KeyValues( "GameUIHidden" ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
55
game/client/cstrike15/gameui/optionsdialog.h
Normal file
55
game/client/cstrike15/gameui/optionsdialog.h
Normal file
@@ -0,0 +1,55 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef OPTIONSDIALOG_H
|
||||
#define OPTIONSDIALOG_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui_controls/PropertyDialog.h"
|
||||
|
||||
|
||||
enum OptionsDialogTabStyle
|
||||
{
|
||||
OPTIONS_DIALOG_ALL_TABS,
|
||||
OPTIONS_DIALOG_ONLY_BINDING_TABS,
|
||||
|
||||
OPTIONS_DIALOG_TAB_STYLE_TOTAL
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Holds all the game option pages
|
||||
//-----------------------------------------------------------------------------
|
||||
class COptionsDialog : public vgui::PropertyDialog
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( COptionsDialog, vgui::PropertyDialog );
|
||||
|
||||
public:
|
||||
COptionsDialog(vgui::Panel *parent, OptionsDialogTabStyle iTabStyle = OPTIONS_DIALOG_ALL_TABS );
|
||||
~COptionsDialog();
|
||||
|
||||
void Run();
|
||||
virtual void Activate();
|
||||
void OpenGammaDialog();
|
||||
|
||||
MESSAGE_FUNC( OnGameUIHidden, "GameUIHidden" ); // called when the GameUI is hidden
|
||||
|
||||
protected:
|
||||
// [jason] Overriding to let Scaleform know that a vgui dialog closed
|
||||
virtual void OnFinishedClose( void );
|
||||
|
||||
private:
|
||||
class COptionsSubAudio *m_pOptionsSubAudio;
|
||||
class COptionsSubVideo *m_pOptionsSubVideo;
|
||||
};
|
||||
|
||||
|
||||
struct OptionData_t;
|
||||
|
||||
#endif // OPTIONSDIALOG_H
|
||||
415
game/client/cstrike15/gameui/optionssubaudio.cpp
Normal file
415
game/client/cstrike15/gameui/optionssubaudio.cpp
Normal file
@@ -0,0 +1,415 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "optionssubaudio.h"
|
||||
|
||||
#include "cvarslider.h"
|
||||
#include "engineinterface.h"
|
||||
#include "modinfo.h"
|
||||
#include "vgui_controls/ComboBox.h"
|
||||
#include "vgui_controls/QueryBox.h"
|
||||
#include "tier1/keyvalues.h"
|
||||
#include "tier1/convar.h"
|
||||
#include "vgui/IInput.h"
|
||||
#include "steam/steam_api.h"
|
||||
#include "tier1/strtools.h"
|
||||
#include "gameui_util.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
// This member is static so that the updated audio language can be referenced during shutdown
|
||||
char* COptionsSubAudio::m_pchUpdatedAudioLanguage = (char*)GetLanguageShortName( k_Lang_English );
|
||||
|
||||
enum SoundQuality_e
|
||||
{
|
||||
SOUNDQUALITY_LOW,
|
||||
SOUNDQUALITY_MEDIUM,
|
||||
SOUNDQUALITY_HIGH,
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
COptionsSubAudio::COptionsSubAudio(vgui::Panel *parent) : PropertyPage(parent, NULL)
|
||||
{
|
||||
m_pSFXSlider = new CCvarSlider( this, "SFXSlider", "#GameUI_SoundEffectVolume", 0.0f, 1.0f, "volume" );
|
||||
m_pMusicSlider = new CCvarSlider( this, "MusicSlider", "#GameUI_MusicVolume", 0.0f, 1.0f, "Snd_MusicVolume" );
|
||||
|
||||
m_pCloseCaptionCombo = new ComboBox( this, "CloseCaptionCheck", 6, false );
|
||||
m_pCloseCaptionCombo->AddItem( "#GameUI_NoClosedCaptions", NULL );
|
||||
m_pCloseCaptionCombo->AddItem( "#GameUI_SubtitlesAndSoundEffects", NULL );
|
||||
m_pCloseCaptionCombo->AddItem( "#GameUI_Subtitles", NULL );
|
||||
|
||||
m_pSoundQualityCombo = new ComboBox( this, "SoundQuality", 6, false );
|
||||
m_pSoundQualityCombo->AddItem( "#GameUI_High", new KeyValues("SoundQuality", "quality", SOUNDQUALITY_HIGH) );
|
||||
m_pSoundQualityCombo->AddItem( "#GameUI_Medium", new KeyValues("SoundQuality", "quality", SOUNDQUALITY_MEDIUM) );
|
||||
m_pSoundQualityCombo->AddItem( "#GameUI_Low", new KeyValues("SoundQuality", "quality", SOUNDQUALITY_LOW) );
|
||||
|
||||
m_pSpeakerSetupCombo = new ComboBox( this, "SpeakerSetup", 6, false );
|
||||
m_pSpeakerSetupCombo->AddItem( "#GameUI_Headphones", new KeyValues("SpeakerSetup", "speakers", 0) );
|
||||
m_pSpeakerSetupCombo->AddItem( "#GameUI_2Speakers", new KeyValues("SpeakerSetup", "speakers", 2) );
|
||||
m_pSpeakerSetupCombo->AddItem( "#GameUI_4Speakers", new KeyValues("SpeakerSetup", "speakers", 4) );
|
||||
m_pSpeakerSetupCombo->AddItem( "#GameUI_5Speakers", new KeyValues("SpeakerSetup", "speakers", 5) );
|
||||
m_pSpeakerSetupCombo->AddItem( "#GameUI_7Speakers", new KeyValues("SpeakerSetup", "speakers", 7) );
|
||||
|
||||
m_pSpokenLanguageCombo = new ComboBox (this, "AudioSpokenLanguage", 6, false );
|
||||
|
||||
LoadControlSettings("Resource\\OptionsSubAudio.res");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
COptionsSubAudio::~COptionsSubAudio()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Reloads data
|
||||
//-----------------------------------------------------------------------------
|
||||
void COptionsSubAudio::OnResetData()
|
||||
{
|
||||
m_bRequireRestart = false;
|
||||
m_pSFXSlider->Reset();
|
||||
m_pMusicSlider->Reset();
|
||||
|
||||
|
||||
// reset the combo boxes
|
||||
|
||||
// close captions
|
||||
CGameUIConVarRef closecaption("closecaption");
|
||||
CGameUIConVarRef cc_subtitles("cc_subtitles");
|
||||
if (closecaption.GetBool())
|
||||
{
|
||||
if (cc_subtitles.GetBool())
|
||||
{
|
||||
m_pCloseCaptionCombo->ActivateItem(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pCloseCaptionCombo->ActivateItem(1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pCloseCaptionCombo->ActivateItem(0);
|
||||
}
|
||||
|
||||
// speakers
|
||||
CGameUIConVarRef snd_surround_speakers("Snd_Surround_Speakers");
|
||||
int speakers = snd_surround_speakers.GetInt();
|
||||
{for (int itemID = 0; itemID < m_pSpeakerSetupCombo->GetItemCount(); itemID++)
|
||||
{
|
||||
KeyValues *kv = m_pSpeakerSetupCombo->GetItemUserData(itemID);
|
||||
if (kv && kv->GetInt("speakers") == speakers)
|
||||
{
|
||||
m_pSpeakerSetupCombo->ActivateItem(itemID);
|
||||
}
|
||||
}}
|
||||
|
||||
// sound quality is made up from several cvars
|
||||
CGameUIConVarRef Snd_PitchQuality("Snd_PitchQuality");
|
||||
CGameUIConVarRef dsp_slow_cpu("dsp_slow_cpu");
|
||||
int quality = SOUNDQUALITY_LOW;
|
||||
if (dsp_slow_cpu.GetBool() == false)
|
||||
{
|
||||
quality = SOUNDQUALITY_MEDIUM;
|
||||
}
|
||||
if (Snd_PitchQuality.GetBool())
|
||||
{
|
||||
quality = SOUNDQUALITY_HIGH;
|
||||
}
|
||||
// find the item in the list and activate it
|
||||
{for (int itemID = 0; itemID < m_pSoundQualityCombo->GetItemCount(); itemID++)
|
||||
{
|
||||
KeyValues *kv = m_pSoundQualityCombo->GetItemUserData(itemID);
|
||||
if (kv && kv->GetInt("quality") == quality)
|
||||
{
|
||||
m_pSoundQualityCombo->ActivateItem(itemID);
|
||||
}
|
||||
}}
|
||||
|
||||
//
|
||||
// Audio Languages
|
||||
//
|
||||
char szCurrentLanguage[50] = "";
|
||||
char szAvailableLanguages[512] = "";
|
||||
szAvailableLanguages[0] = NULL;
|
||||
|
||||
// Fallback to current engine language
|
||||
engine->GetUILanguage( szCurrentLanguage, sizeof( szCurrentLanguage ));
|
||||
|
||||
// In a Steam environment we get the current language
|
||||
#if !defined( NO_STEAM )
|
||||
// When Steam isn't running we can't get the language info...
|
||||
if ( steamapicontext->SteamApps() )
|
||||
{
|
||||
Q_strncpy( szCurrentLanguage, steamapicontext->SteamApps()->GetCurrentGameLanguage(), sizeof(szCurrentLanguage) );
|
||||
Q_strncpy( szAvailableLanguages, steamapicontext->SteamApps()->GetAvailableGameLanguages(), sizeof(szAvailableLanguages) );
|
||||
}
|
||||
#endif
|
||||
|
||||
// Get the spoken language and store it for comparison purposes
|
||||
m_nCurrentAudioLanguage = PchLanguageToELanguage( szCurrentLanguage );
|
||||
|
||||
// Check to see if we have a list of languages from Steam
|
||||
if ( V_strlen( szAvailableLanguages ) )
|
||||
{
|
||||
// Populate the combo box with each available language
|
||||
CSplitString languagesList( szAvailableLanguages, "," );
|
||||
|
||||
for ( int i=0; i < languagesList.Count(); i++ )
|
||||
{
|
||||
const ELanguage languageCode = PchLanguageToELanguage( languagesList[i] );
|
||||
m_pSpokenLanguageCombo->AddItem( GetLanguageVGUILocalization( languageCode ), new KeyValues ("Audio Languages", "language", languageCode) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add the current language to the combo
|
||||
m_pSpokenLanguageCombo->AddItem( GetLanguageVGUILocalization( m_nCurrentAudioLanguage ), new KeyValues ("Audio Languages", "language", m_nCurrentAudioLanguage) );
|
||||
}
|
||||
|
||||
// Activate the current language in the combo
|
||||
{for (int itemID = 0; itemID < m_pSpokenLanguageCombo->GetItemCount(); itemID++)
|
||||
{
|
||||
KeyValues *kv = m_pSpokenLanguageCombo->GetItemUserData( itemID );
|
||||
if ( kv && kv->GetInt( "language" ) == m_nCurrentAudioLanguage )
|
||||
{
|
||||
m_pSpokenLanguageCombo->ActivateItem( itemID );
|
||||
break;
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Applies changes
|
||||
//-----------------------------------------------------------------------------
|
||||
void COptionsSubAudio::OnApplyChanges()
|
||||
{
|
||||
m_pSFXSlider->ApplyChanges();
|
||||
m_pMusicSlider->ApplyChanges();
|
||||
|
||||
// set the cvars appropriately
|
||||
// Tracker 28933: Note we can't do this because closecaption is marked
|
||||
// FCVAR_USERINFO and it won't get sent to server is we direct set it, we
|
||||
// need to pass it along to the engine parser!!!
|
||||
// ConVar *closecaption = (ConVar *)cvar->FindVar("closecaption");
|
||||
int closecaption_value = 0;
|
||||
|
||||
CGameUIConVarRef cc_subtitles( "cc_subtitles" );
|
||||
switch (m_pCloseCaptionCombo->GetActiveItem())
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
closecaption_value = 0;
|
||||
cc_subtitles.SetValue( 0 );
|
||||
break;
|
||||
case 1:
|
||||
closecaption_value = 1;
|
||||
cc_subtitles.SetValue( 0 );
|
||||
break;
|
||||
case 2:
|
||||
closecaption_value = 1;
|
||||
cc_subtitles.SetValue( 1 );
|
||||
break;
|
||||
}
|
||||
|
||||
// Stuff the close caption change to the console so that it can be
|
||||
// sent to the server (FCVAR_USERINFO) so that you don't have to restart
|
||||
// the level for the change to take effect.
|
||||
char cmd[ 64 ];
|
||||
Q_snprintf( cmd, sizeof( cmd ), "closecaption %i\n", closecaption_value );
|
||||
engine->ClientCmd_Unrestricted( cmd );
|
||||
|
||||
CGameUIConVarRef snd_surround_speakers( "Snd_Surround_Speakers" );
|
||||
int speakers = m_pSpeakerSetupCombo->GetActiveItemUserData()->GetInt( "speakers" );
|
||||
snd_surround_speakers.SetValue( speakers );
|
||||
|
||||
// quality
|
||||
CGameUIConVarRef Snd_PitchQuality( "Snd_PitchQuality" );
|
||||
CGameUIConVarRef dsp_slow_cpu( "dsp_slow_cpu" );
|
||||
int quality = m_pSoundQualityCombo->GetActiveItemUserData()->GetInt( "quality" );
|
||||
switch ( quality )
|
||||
{
|
||||
case SOUNDQUALITY_LOW:
|
||||
dsp_slow_cpu.SetValue(true);
|
||||
Snd_PitchQuality.SetValue(false);
|
||||
break;
|
||||
case SOUNDQUALITY_MEDIUM:
|
||||
dsp_slow_cpu.SetValue(false);
|
||||
Snd_PitchQuality.SetValue(false);
|
||||
break;
|
||||
default:
|
||||
Assert("Undefined sound quality setting.");
|
||||
case SOUNDQUALITY_HIGH:
|
||||
dsp_slow_cpu.SetValue(false);
|
||||
Snd_PitchQuality.SetValue(true);
|
||||
break;
|
||||
};
|
||||
|
||||
// headphones at high quality get enhanced stereo turned on
|
||||
CGameUIConVarRef dsp_enhance_stereo( "dsp_enhance_stereo" );
|
||||
if (speakers == 0 && quality == SOUNDQUALITY_HIGH)
|
||||
{
|
||||
#ifdef CSTRIKE15
|
||||
dsp_enhance_stereo.SetValue( 0 );
|
||||
#else
|
||||
dsp_enhance_stereo.SetValue( 1 );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
dsp_enhance_stereo.SetValue( 0 );
|
||||
}
|
||||
|
||||
// Audio spoken language
|
||||
KeyValues *kv = m_pSpokenLanguageCombo->GetItemUserData( m_pSpokenLanguageCombo->GetActiveItem() );
|
||||
const ELanguage nUpdatedAudioLanguage = (ELanguage)( kv ? kv->GetInt( "language" ) : k_Lang_English );
|
||||
|
||||
if ( nUpdatedAudioLanguage != m_nCurrentAudioLanguage )
|
||||
{
|
||||
// Store new language in static member so that it can be accessed during shutdown when this instance is gone
|
||||
m_pchUpdatedAudioLanguage = (char *) GetLanguageShortName( nUpdatedAudioLanguage );
|
||||
|
||||
// Inform user that they need to restart in order change language at this time
|
||||
QueryBox *qb = new QueryBox( "#GameUI_ChangeLanguageRestart_Title", "#GameUI_ChangeLanguageRestart_Info", GetParent()->GetParent()->GetParent() );
|
||||
if (qb != NULL)
|
||||
{
|
||||
qb->SetOKCommand( new KeyValues( "Command", "command", "RestartWithNewLanguage" ) );
|
||||
qb->SetOKButtonText( "#GameUI_ChangeLanguageRestart_OkButton" );
|
||||
qb->SetCancelButtonText( "#GameUI_ChangeLanguageRestart_CancelButton" );
|
||||
qb->AddActionSignalTarget( GetParent()->GetParent()->GetParent() );
|
||||
qb->DoModal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Called on controls changing, enables the Apply button
|
||||
//-----------------------------------------------------------------------------
|
||||
void COptionsSubAudio::OnControlModified()
|
||||
{
|
||||
PostActionSignal(new KeyValues("ApplyButtonEnable"));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: returns true if the engine needs to be restarted
|
||||
//-----------------------------------------------------------------------------
|
||||
bool COptionsSubAudio::RequiresRestart()
|
||||
{
|
||||
// nothing in audio requires a restart like now
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void COptionsSubAudio::OnCommand( const char *command )
|
||||
{
|
||||
if ( !stricmp( command, "TestSpeakers" ) )
|
||||
{
|
||||
// ask them if they REALLY want to test the speakers if they're in a game already.
|
||||
if (engine->IsConnected())
|
||||
{
|
||||
QueryBox *qb = new QueryBox("#GameUI_TestSpeakersWarning_Title", "#GameUI_TestSpeakersWarning_Info" );
|
||||
if (qb != NULL)
|
||||
{
|
||||
qb->SetOKCommand(new KeyValues("RunTestSpeakers"));
|
||||
qb->SetOKButtonText("#GameUI_TestSpeakersWarning_OkButton");
|
||||
qb->SetCancelButtonText("#GameUI_TestSpeakersWarning_CancelButton");
|
||||
qb->AddActionSignalTarget( this );
|
||||
qb->DoModal();
|
||||
}
|
||||
else
|
||||
{
|
||||
// couldn't create the warning dialog for some reason, so just test the speakers.
|
||||
RunTestSpeakers();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// player isn't connected to a game so there's no reason to warn them about being disconnected.
|
||||
// create the command to execute
|
||||
RunTestSpeakers();
|
||||
}
|
||||
}
|
||||
else if ( !stricmp( command, "ShowThirdPartyAudioCredits" ) )
|
||||
{
|
||||
OpenThirdPartySoundCreditsDialog();
|
||||
}
|
||||
|
||||
BaseClass::OnCommand( command );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Run the test speakers map.
|
||||
//-----------------------------------------------------------------------------
|
||||
void COptionsSubAudio::RunTestSpeakers()
|
||||
{
|
||||
engine->ClientCmd_Unrestricted( "disconnect\nwait\nwait\nsv_lan 1\nsetmaster enable\nmaxplayers 1\n\nhostname \"Speaker Test\"\nprogress_enable\nmap test_speakers\n" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Open third party audio credits dialog
|
||||
//-----------------------------------------------------------------------------
|
||||
void COptionsSubAudio::OpenThirdPartySoundCreditsDialog()
|
||||
{
|
||||
if (!m_OptionsSubAudioThirdPartyCreditsDlg.Get())
|
||||
{
|
||||
m_OptionsSubAudioThirdPartyCreditsDlg = new COptionsSubAudioThirdPartyCreditsDlg(GetVParent());
|
||||
}
|
||||
m_OptionsSubAudioThirdPartyCreditsDlg->Activate();
|
||||
}
|
||||
|
||||
|
||||
COptionsSubAudioThirdPartyCreditsDlg::COptionsSubAudioThirdPartyCreditsDlg( vgui::VPANEL hParent ) : BaseClass( NULL, NULL )
|
||||
{
|
||||
SetProportional( true );
|
||||
|
||||
#ifdef SWARM_DLL
|
||||
// parent is ignored, since we want look like we're steal focus from the parent (we'll become modal below)
|
||||
SetScheme( "SwarmScheme" );
|
||||
#endif
|
||||
|
||||
SetTitle( "#GameUI_ThirdPartyAudio_Title", true );
|
||||
SetSize(
|
||||
vgui::scheme()->GetProportionalScaledValueEx( GetScheme(), 500 ),
|
||||
vgui::scheme()->GetProportionalScaledValueEx( GetScheme(), 200 ) );
|
||||
|
||||
MoveToCenterOfScreen();
|
||||
SetSizeable( false );
|
||||
SetDeleteSelfOnClose( true );
|
||||
}
|
||||
|
||||
void COptionsSubAudioThirdPartyCreditsDlg::ApplySchemeSettings( IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
LoadControlSettings( "resource/OptionsSubAudioThirdPartyDlg.res" );
|
||||
}
|
||||
|
||||
void COptionsSubAudioThirdPartyCreditsDlg::Activate()
|
||||
{
|
||||
BaseClass::Activate();
|
||||
|
||||
input()->SetAppModalSurface(GetVPanel());
|
||||
}
|
||||
|
||||
void COptionsSubAudioThirdPartyCreditsDlg::OnKeyCodeTyped(vgui::KeyCode code)
|
||||
{
|
||||
// force ourselves to be closed if the escape key it pressed
|
||||
if (code == KEY_ESCAPE)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnKeyCodeTyped(code);
|
||||
}
|
||||
}
|
||||
80
game/client/cstrike15/gameui/optionssubaudio.h
Normal file
80
game/client/cstrike15/gameui/optionssubaudio.h
Normal file
@@ -0,0 +1,80 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef OPTIONS_SUB_AUDIO_H
|
||||
#define OPTIONS_SUB_AUDIO_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui_controls/PropertyPage.h"
|
||||
#include <language.h>
|
||||
#include "vgui_controls/Frame.h"
|
||||
#include "vgui/KeyCode.h"
|
||||
|
||||
class CLabeledCommandComboBox;
|
||||
class CCvarSlider;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Audio Details, Part of OptionsDialog
|
||||
//-----------------------------------------------------------------------------
|
||||
class COptionsSubAudio : public vgui::PropertyPage
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( COptionsSubAudio, vgui::PropertyPage );
|
||||
|
||||
public:
|
||||
explicit COptionsSubAudio(vgui::Panel *parent);
|
||||
~COptionsSubAudio();
|
||||
|
||||
virtual void OnResetData();
|
||||
virtual void OnApplyChanges();
|
||||
virtual void OnCommand( const char *command );
|
||||
bool RequiresRestart();
|
||||
static char* GetUpdatedAudioLanguage() { return m_pchUpdatedAudioLanguage; }
|
||||
|
||||
private:
|
||||
MESSAGE_FUNC( OnControlModified, "ControlModified" );
|
||||
MESSAGE_FUNC( OnTextChanged, "TextChanged" )
|
||||
{
|
||||
OnControlModified();
|
||||
}
|
||||
|
||||
MESSAGE_FUNC( RunTestSpeakers, "RunTestSpeakers" );
|
||||
|
||||
vgui::ComboBox *m_pSpeakerSetupCombo;
|
||||
vgui::ComboBox *m_pSoundQualityCombo;
|
||||
CCvarSlider *m_pSFXSlider;
|
||||
CCvarSlider *m_pMusicSlider;
|
||||
vgui::ComboBox *m_pCloseCaptionCombo;
|
||||
bool m_bRequireRestart;
|
||||
|
||||
vgui::ComboBox *m_pSpokenLanguageCombo;
|
||||
MESSAGE_FUNC( OpenThirdPartySoundCreditsDialog, "OpenThirdPartySoundCreditsDialog" );
|
||||
vgui::DHANDLE<class COptionsSubAudioThirdPartyCreditsDlg> m_OptionsSubAudioThirdPartyCreditsDlg;
|
||||
ELanguage m_nCurrentAudioLanguage;
|
||||
static char *m_pchUpdatedAudioLanguage;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: third-party audio credits dialog
|
||||
//-----------------------------------------------------------------------------
|
||||
class COptionsSubAudioThirdPartyCreditsDlg : public vgui::Frame
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( COptionsSubAudioThirdPartyCreditsDlg, vgui::Frame );
|
||||
public:
|
||||
explicit COptionsSubAudioThirdPartyCreditsDlg( vgui::VPANEL hParent );
|
||||
|
||||
virtual void Activate();
|
||||
void OnKeyCodeTyped(vgui::KeyCode code);
|
||||
|
||||
protected:
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
};
|
||||
|
||||
|
||||
#endif // OPTIONS_SUB_AUDIO_H
|
||||
79
game/client/cstrike15/gameui/optionssubdifficulty.cpp
Normal file
79
game/client/cstrike15/gameui/optionssubdifficulty.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "optionssubdifficulty.h"
|
||||
#include "tier1/convar.h"
|
||||
#include "engineinterface.h"
|
||||
#include "tier1/keyvalues.h"
|
||||
|
||||
#include "vgui_controls/RadioButton.h"
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
COptionsSubDifficulty::COptionsSubDifficulty(vgui::Panel *parent) : BaseClass(parent, NULL)
|
||||
{
|
||||
m_pEasyRadio = new RadioButton(this, "Skill1Radio", "#GameUI_SkillEasy");
|
||||
m_pNormalRadio = new RadioButton(this, "Skill2Radio", "#GameUI_SkillNormal");
|
||||
m_pHardRadio = new RadioButton(this, "Skill3Radio", "#GameUI_SkillHard");
|
||||
|
||||
LoadControlSettings("Resource/OptionsSubDifficulty.res");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: resets controls
|
||||
//-----------------------------------------------------------------------------
|
||||
void COptionsSubDifficulty::OnResetData()
|
||||
{
|
||||
ConVarRef var( "skill" );
|
||||
|
||||
if (var.GetInt() == 1)
|
||||
{
|
||||
m_pEasyRadio->SetSelected(true);
|
||||
}
|
||||
else if (var.GetInt() == 3)
|
||||
{
|
||||
m_pHardRadio->SetSelected(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pNormalRadio->SetSelected(true);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: sets data based on control settings
|
||||
//-----------------------------------------------------------------------------
|
||||
void COptionsSubDifficulty::OnApplyChanges()
|
||||
{
|
||||
ConVarRef var( "skill" );
|
||||
|
||||
if ( m_pEasyRadio->IsSelected() )
|
||||
{
|
||||
var.SetValue( 1 );
|
||||
}
|
||||
else if ( m_pHardRadio->IsSelected() )
|
||||
{
|
||||
var.SetValue( 3 );
|
||||
}
|
||||
else
|
||||
{
|
||||
var.SetValue( 2 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: enables apply button on radio buttons being pressed
|
||||
//-----------------------------------------------------------------------------
|
||||
void COptionsSubDifficulty::OnRadioButtonChecked()
|
||||
{
|
||||
PostActionSignal(new KeyValues("ApplyButtonEnable"));
|
||||
}
|
||||
38
game/client/cstrike15/gameui/optionssubdifficulty.h
Normal file
38
game/client/cstrike15/gameui/optionssubdifficulty.h
Normal file
@@ -0,0 +1,38 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef OPTIONS_SUB_DIFFICULTY_H
|
||||
#define OPTIONS_SUB_DIFFICULTY_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui_controls/PropertyPage.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Difficulty selection options
|
||||
//-----------------------------------------------------------------------------
|
||||
class COptionsSubDifficulty : public vgui::PropertyPage
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( COptionsSubDifficulty, vgui::PropertyPage );
|
||||
|
||||
public:
|
||||
explicit COptionsSubDifficulty(vgui::Panel *parent);
|
||||
|
||||
virtual void OnResetData();
|
||||
virtual void OnApplyChanges();
|
||||
|
||||
MESSAGE_FUNC( OnRadioButtonChecked, "RadioButtonChecked" );
|
||||
|
||||
private:
|
||||
vgui::RadioButton *m_pEasyRadio;
|
||||
vgui::RadioButton *m_pNormalRadio;
|
||||
vgui::RadioButton *m_pHardRadio;
|
||||
};
|
||||
|
||||
|
||||
#endif // OPTIONS_SUB_DIFFICULTY_H
|
||||
43
game/client/cstrike15/gameui/optionssubgame.cpp
Normal file
43
game/client/cstrike15/gameui/optionssubgame.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "optionssubgame.h"
|
||||
#include "basepanel.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
COptionsSubGame::COptionsSubGame( vgui::Panel *parent, const char *name ) : BaseClass( parent, name )
|
||||
{
|
||||
SetDeleteSelfOnClose( true );
|
||||
LoadControlSettings( "Resource/OptionsSubGame.res" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
COptionsSubGame::~COptionsSubGame()
|
||||
{
|
||||
}
|
||||
|
||||
void COptionsSubGame::OnClose( void )
|
||||
{
|
||||
#if defined( BASEPANEL_LEGACY_SOURCE1 )
|
||||
BasePanel()->RunCloseAnimation( "CloseOptionsSubGame" );
|
||||
#endif
|
||||
BaseClass::OnClose();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void COptionsSubGame::OnCommand( const char *command )
|
||||
{
|
||||
BaseClass::OnCommand( command );
|
||||
}
|
||||
35
game/client/cstrike15/gameui/optionssubgame.h
Normal file
35
game/client/cstrike15/gameui/optionssubgame.h
Normal file
@@ -0,0 +1,35 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef OPTIONS_SUB_GAME_H
|
||||
#define OPTIONS_SUB_GAME_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui_controls/Frame.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Game Settings, Part of OptionsDialog
|
||||
//-----------------------------------------------------------------------------
|
||||
class COptionsSubGame : public vgui::Frame
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( COptionsSubGame, vgui::Frame );
|
||||
|
||||
public:
|
||||
COptionsSubGame( vgui::Panel *parent, const char *name );
|
||||
~COptionsSubGame( void );
|
||||
|
||||
virtual void OnCommand( const char *command );
|
||||
virtual void OnClose( void );
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // OPTIONS_SUB_GAME_H
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user