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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#include "cbase.h"
#include "GameUI/IGameUI.h"
#include "fmtstr.h"
#include "igameevents.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
// See interface.h/.cpp for specifics: basically this ensures that we actually Sys_UnloadModule the dll and that we don't call Sys_LoadModule
// over and over again.
static CDllDemandLoader g_GameUI( "GameUI" );
#ifndef CLIENT_DLL
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
class CPointBonusMapsAccessor : public CPointEntity
{
public:
DECLARE_CLASS( CPointBonusMapsAccessor, CPointEntity );
DECLARE_DATADESC();
virtual void Activate( void );
void InputUnlock( inputdata_t& inputdata );
void InputComplete( inputdata_t& inputdata );
void InputSave( inputdata_t& inputdata );
private:
string_t m_String_tFileName;
string_t m_String_tMapName;
IGameUI *m_pGameUI;
};
BEGIN_DATADESC( CPointBonusMapsAccessor )
DEFINE_KEYFIELD( m_String_tFileName, FIELD_STRING, "filename" ),
DEFINE_KEYFIELD( m_String_tMapName, FIELD_STRING, "mapname" ),
DEFINE_INPUTFUNC( FIELD_VOID, "Unlock", InputUnlock ),
DEFINE_INPUTFUNC( FIELD_VOID, "Complete", InputComplete ),
DEFINE_INPUTFUNC( FIELD_VOID, "Save", InputSave ),
END_DATADESC()
LINK_ENTITY_TO_CLASS( point_bonusmaps_accessor, CPointBonusMapsAccessor );
void CPointBonusMapsAccessor::Activate( void )
{
BaseClass::Activate();
CreateInterfaceFn gameUIFactory = g_GameUI.GetFactory();
if ( gameUIFactory )
{
m_pGameUI = (IGameUI *) gameUIFactory(GAMEUI_INTERFACE_VERSION, NULL );
}
}
void CPointBonusMapsAccessor::InputUnlock( inputdata_t& inputdata )
{
if ( m_pGameUI )
m_pGameUI->BonusMapUnlock( m_String_tFileName.ToCStr(), m_String_tMapName.ToCStr() );
}
void CPointBonusMapsAccessor::InputComplete( inputdata_t& inputdata )
{
if ( m_pGameUI )
{
m_pGameUI->BonusMapComplete( m_String_tFileName.ToCStr(), m_String_tMapName.ToCStr() );
int iNumAdvancedComplete = m_pGameUI->BonusMapNumAdvancedCompleted();
IGameEvent *event = gameeventmanager->CreateEvent( "advanced_map_complete" );
if ( event )
{
event->SetInt( "numadvanced", iNumAdvancedComplete );
gameeventmanager->FireEvent( event );
}
}
}
void CPointBonusMapsAccessor::InputSave( inputdata_t& inputdata )
{
if ( m_pGameUI )
m_pGameUI->BonusMapDatabaseSave();
}
#endif
void BonusMapChallengeUpdate( const char *pchFileName, const char *pchMapName, const char *pchChallengeName, int iBest )
{
CreateInterfaceFn gameUIFactory = g_GameUI.GetFactory();
if ( gameUIFactory )
{
IGameUI *pGameUI = (IGameUI *) gameUIFactory(GAMEUI_INTERFACE_VERSION, NULL );
if ( pGameUI )
{
pGameUI->BonusMapChallengeUpdate( pchFileName, pchMapName, pchChallengeName, iBest );
int piNumMedals[ 3 ];
pGameUI->BonusMapNumMedals( piNumMedals );
IGameEvent *event = gameeventmanager->CreateEvent( "challenge_map_complete" );
if ( event )
{
event->SetInt( "numbronze", piNumMedals[ 0 ] );
event->SetInt( "numsilver", piNumMedals[ 1 ] );
event->SetInt( "numgold", piNumMedals[ 2 ] );
gameeventmanager->FireEvent( event );
}
}
}
}
void BonusMapChallengeNames( char *pchFileName, char *pchMapName, char *pchChallengeName )
{
CreateInterfaceFn gameUIFactory = g_GameUI.GetFactory();
if ( gameUIFactory )
{
IGameUI *pGameUI = (IGameUI *) gameUIFactory(GAMEUI_INTERFACE_VERSION, NULL );
if ( pGameUI )
{
pGameUI->BonusMapChallengeNames( pchFileName, pchMapName, pchChallengeName );
}
}
}
void BonusMapChallengeObjectives( int &iBronze, int &iSilver, int &iGold )
{
CreateInterfaceFn gameUIFactory = g_GameUI.GetFactory();
if ( gameUIFactory )
{
IGameUI *pGameUI = (IGameUI *) gameUIFactory(GAMEUI_INTERFACE_VERSION, NULL );
if ( pGameUI )
{
pGameUI->BonusMapChallengeObjectives( iBronze, iSilver, iGold );
}
}
}
|