summaryrefslogtreecommitdiff
path: root/utils/vgui_panel_zoo/testfile.cpp
blob: 50f052e6b9e680fa11dbfcff88addce137feb2e6 (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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//
//===========================================================================//
#include "interface.h"

#include <windows.h>
//#include "..\..\tracker\common\winlite.h"
#include "vgui_controls/Controls.h"
#include "vgui/vgui.h"
#include "VGUI\IPanel.h"
#include "VGUI\IScheme.h"
#include "VGUI\ISurface.h"
#include "VGUI\ILocalize.h"
#include "VGUI\IVGui.h"
#include "vgui_controls/Panel.h"
#include "filesystem.h"
#include "tier0/icommandline.h"
#include "appframework/tier3app.h"
#include "inputsystem/iinputsystem.h"
#include "CControlCatalog.h"

#include <stdio.h>

//-----------------------------------------------------------------------------
// Purpose: Warning/Msg call back through this API
// Input  : type - 
//			*pMsg - 
// Output : SpewRetval_t
//-----------------------------------------------------------------------------
SpewRetval_t SpewFunc( SpewType_t type, char const *pMsg )
{	
	switch ( type )
	{

	default:
	case SPEW_MESSAGE:
	case SPEW_ASSERT:
	case SPEW_LOG:
		OutputDebugString( pMsg );
		break;
	case SPEW_WARNING:
		OutputDebugString( pMsg );
		break;
	case SPEW_ERROR:
		OutputDebugString( pMsg );
		exit( -1 );
		break;
	}
	
	return SPEW_CONTINUE;
}

//-----------------------------------------------------------------------------
// Purpose: Entry point
//			loads interfaces and initializes dialog
//-----------------------------------------------------------------------------
static CreateInterfaceFn s_pFactoryList[2];

void *VGuiFactory( const char *pName, int *pReturnCode )
{
	for ( int i = 0; i < ARRAYSIZE( s_pFactoryList ); ++i )
	{
		void *pInterface = s_pFactoryList[i]( pName, pReturnCode );
		if ( pInterface )
			return pInterface;
	}
	return NULL;
}


//-----------------------------------------------------------------------------
// The application object
//-----------------------------------------------------------------------------
class CPanelZooApp : 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( CPanelZooApp );


//-----------------------------------------------------------------------------
// The application object
//-----------------------------------------------------------------------------
bool CPanelZooApp::Create()
{
	SpewOutputFunc( SpewFunc );
	SpewActivate( "panelzoo", 2 );

	AppSystemInfo_t appSystems[] = 
	{
		{ "inputsystem.dll",		INPUTSYSTEM_INTERFACE_VERSION },
		{ "vgui2.dll",				VGUI_IVGUI_INTERFACE_VERSION },
		{ "", "" }	// Required to terminate the list
	};

	return AddSystems( appSystems );
}


//-----------------------------------------------------------------------------
// Setup
//-----------------------------------------------------------------------------
bool CPanelZooApp::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( "platform", "PLATFORM" );
	return true;
}


//-----------------------------------------------------------------------------
// Purpose: Entry point
//-----------------------------------------------------------------------------
int CPanelZooApp::Main()
{
	// In order to load resource files the file must be in your vgui filesystem path.
//	g_pFullFileSystem->AddSearchPath("../", "resources");

	// Init the surface
//	vgui::surface()->Init();

	// Make a embedded panel
	vgui::Panel *panel = new vgui::Panel(NULL, "TopPanel");
	vgui::surface()->SetEmbeddedPanel( panel->GetVPanel() );

	// Load the scheme
	if (!vgui::scheme()->LoadSchemeFromFile( "//platform/Resource/SourceScheme.res", "PANELZOO" ))
		return 1;

	// localization
	g_pVGuiLocalize->AddFile( "Resource/platform_english.txt" );
	g_pVGuiLocalize->AddFile( "Resource/valve_%language%.txt" );
	g_pVGuiLocalize->AddFile( "Resource/vgui_%language%.txt" );

	// Start vgui
	vgui::ivgui()->Start();

	// Add our main window
	CControlCatalog *panelZoo = new CControlCatalog();
	panelZoo->Activate();

	// Run app frame loop
	while (vgui::ivgui()->IsRunning())
	{
		vgui::ivgui()->RunFrame();
	}

	delete panelZoo;
//	delete panel;

	return 1;
}