csgo-2018-source/vgui2/vlocalize/main.cpp
2021-07-24 21:11:47 -07:00

115 lines
2.9 KiB
C++

//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
// $NoKeywords: $
//
//===========================================================================//
#include "windows.h"
#include "vgui_controls/Panel.h"
#include "vgui/IScheme.h"
#include "vgui/ISurface.h"
#include "vgui/IVGui.h"
#include "FileSystem.h"
#include "tier0/icommandline.h"
#include "inputsystem/iinputsystem.h"
#include "appframework/tier3app.h"
#include "LocalizationDialog.h"
#include <stdio.h>
//-----------------------------------------------------------------------------
// The application object
//-----------------------------------------------------------------------------
class CVLocalizeApp : public CVguiSteamApp
{
typedef CVguiSteamApp BaseClass;
public:
// Methods of IApplication
virtual bool Create();
virtual bool PreInit();
virtual int Main();
virtual void Destroy() {}
};
DEFINE_WINDOWED_STEAM_APPLICATION_OBJECT( CVLocalizeApp );
//-----------------------------------------------------------------------------
// The application object
//-----------------------------------------------------------------------------
bool CVLocalizeApp::Create()
{
AppSystemInfo_t appSystems[] =
{
{ "inputsystem.dll", INPUTSYSTEM_INTERFACE_VERSION },
{ "vgui2.dll", VGUI_IVGUI_INTERFACE_VERSION },
{ "", "" } // Required to terminate the list
};
return AddSystems( appSystems );
}
//-----------------------------------------------------------------------------
// Purpose: Entry point
//-----------------------------------------------------------------------------
bool CVLocalizeApp::PreInit()
{
if ( !BaseClass::PreInit() )
return false;
if ( !BaseClass::SetupSearchPaths( NULL, false, true ) )
{
::MessageBox( NULL, "Error", "Unable to initialize file system\n", MB_OK );
return false;
}
g_pFullFileSystem->AddSearchPath("../game/platform", "PLATFORM");
return true;
}
//-----------------------------------------------------------------------------
// Purpose: Entry point
//-----------------------------------------------------------------------------
int CVLocalizeApp::Main()
{
// load the scheme
if (!vgui::scheme()->LoadSchemeFromFile("Resource/TrackerScheme.res", "Tracker" ))
return 1;
// Init the surface
vgui::Panel *panel = new vgui::Panel(NULL, "TopPanel");
vgui::surface()->SetEmbeddedPanel(panel->GetVPanel());
// Start vgui
vgui::ivgui()->Start();
// add our main window
if ( CommandLine()->ParmCount() < 2 )
{
Warning( "Must specify a localization file!\n" );
return 0;
}
const char *pFileName = CommandLine()->GetParm( 1 );
CLocalizationDialog *dlg = new CLocalizationDialog( pFileName );
dlg->SetParent( panel->GetVPanel() );
dlg->MakePopup();
// dlg->SetBounds( 0, 0, 800, 600 );
dlg->SetVisible( true );
// Run app frame loop
while (vgui::ivgui()->IsRunning())
{
vgui::ivgui()->RunFrame();
vgui::surface()->PaintTraverseEx( panel->GetVPanel(), true );
}
return 1;
}