summaryrefslogtreecommitdiff
path: root/vgui2/vlocalize/main.cpp
blob: a09a1ccaef5c248d5adcb869dc70a9fb5778a0ce (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//
//===========================================================================//

#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 <windows.h>

//#include "..\..\tracker\common\winlite.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;
}