blob: 38801fbf76f66086a1a69e1c65692ba55cd28f34 (
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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#include "dme_controls/AttributeDetailTypePickerPanel.h"
#include "dme_controls/AttributeTextEntry.h"
#include "tier1/KeyValues.h"
#include "filesystem.h"
using namespace vgui;
const char *DETAILTYPE_FILE = "detail.vbsp";
//-----------------------------------------------------------------------------
// Constructor
//-----------------------------------------------------------------------------
CAttributeDetailTypePickerPanel::CAttributeDetailTypePickerPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info ) :
BaseClass( parent, info )
{
}
CAttributeDetailTypePickerPanel::~CAttributeDetailTypePickerPanel()
{
}
//-----------------------------------------------------------------------------
// Reads the detail types
//-----------------------------------------------------------------------------
void CAttributeDetailTypePickerPanel::AddDetailTypesToList( PickerList_t &list )
{
KeyValues *pDetailTypes = new KeyValues( DETAILTYPE_FILE );
if ( pDetailTypes->LoadFromFile( g_pFullFileSystem, DETAILTYPE_FILE, "GAME" ) )
{
for ( KeyValues *sub = pDetailTypes->GetFirstTrueSubKey(); sub != NULL; sub = sub->GetNextTrueSubKey() )
{
int i = list.AddToTail( );
list[i].m_pChoiceString = sub->GetName();
list[i].m_pChoiceValue = sub->GetName();
}
}
else
{
Warning( "Unable to load detail prop file '%s'\n", DETAILTYPE_FILE );
}
pDetailTypes->deleteThis();
}
//-----------------------------------------------------------------------------
// Called when it's time to show the picker
//-----------------------------------------------------------------------------
void CAttributeDetailTypePickerPanel::ShowPickerDialog()
{
CPickerFrame *pDetailTypePickerDialog = new CPickerFrame( this, "Select Detail Type", "Detail Type", "detailTypeName" );
PickerList_t detailTypeList;
AddDetailTypesToList( detailTypeList );
pDetailTypePickerDialog->AddActionSignalTarget( this );
pDetailTypePickerDialog->DoModal( detailTypeList );
}
//-----------------------------------------------------------------------------
// Called by the picker dialog if a asset was selected
//-----------------------------------------------------------------------------
void CAttributeDetailTypePickerPanel::OnPicked( KeyValues *pKeyValues )
{
// Get the detail type name back
const char *pDetailTypeName = pKeyValues->GetString( "choice", NULL );
if ( !pDetailTypeName || !pDetailTypeName[ 0 ] )
return;
// Apply to text panel
m_pData->SetText( pDetailTypeName );
SetDirty(true);
if ( IsAutoApply() )
{
Apply();
}
}
|