-
Notifications
You must be signed in to change notification settings - Fork 0
/
udll_int.cpp
99 lines (84 loc) · 2.65 KB
/
udll_int.cpp
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
/*
dll_int.cpp - dll entry point
Copyright (C) 2010 Uncle Mike
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#include "extdll_menu.h"
#include "BaseMenu.h"
#include "Utils.h"
ui_enginefuncs_t EngFuncs::engfuncs;
ui_extendedfuncs_t EngFuncs::textfuncs;
ui_globalvars_t *gpGlobals;
CMenu gMenu;
static UI_FUNCTIONS gFunctionTable =
{
UI_VidInit,
UI_Init,
UI_Shutdown,
UI_UpdateMenu,
UI_KeyEvent,
UI_MouseMove,
UI_SetActiveMenu,
UI_AddServerToList,
UI_GetCursorPos,
UI_SetCursorPos,
UI_ShowCursor,
UI_CharEvent,
UI_MouseInRect,
UI_IsVisible,
UI_CreditsActive,
UI_FinalCredits
};
//=======================================================================
// GetApi
//=======================================================================
extern "C" EXPORT int GetMenuAPI(UI_FUNCTIONS *pFunctionTable, ui_enginefuncs_t* pEngfuncsFromEngine, ui_globalvars_t *pGlobals)
{
if( !pFunctionTable || !pEngfuncsFromEngine )
{
return FALSE;
}
// copy HUD_FUNCTIONS table to engine, copy engfuncs table from engine
memcpy( pFunctionTable, &gFunctionTable, sizeof( UI_FUNCTIONS ));
memcpy( &EngFuncs::engfuncs, pEngfuncsFromEngine, sizeof( ui_enginefuncs_t ));
memset( &EngFuncs::textfuncs, 0, sizeof( ui_extendedfuncs_t ));
gpGlobals = pGlobals;
return TRUE;
}
static UI_EXTENDED_FUNCTIONS gExtendedTable =
{
AddTouchButtonToList,
UI_MenuResetPing_f,
UI_ConnectionWarning_f,
UI_UpdateDialog,
UI_ShowMessageBox,
UI_ConnectionProgress_Disconnect,
UI_ConnectionProgress_Download,
UI_ConnectionProgress_DownloadEnd,
UI_ConnectionProgress_Precache,
UI_ConnectionProgress_Connect,
UI_ConnectionProgress_ChangeLevel,
UI_ConnectionProgress_ParseServerInfo
};
extern "C" EXPORT int GetExtAPI( int version, UI_EXTENDED_FUNCTIONS *pFunctionTable, ui_extendedfuncs_t *pEngfuncsFromEngine )
{
if( !pFunctionTable || !pEngfuncsFromEngine )
{
return FALSE;
}
if( version != MENU_EXTENDED_API_VERSION )
{
Con_Printf( "Error: failed to initialize extended menu API. Expected by DLL: %d. Got from engine: %d\n", MENU_EXTENDED_API_VERSION, version );
return FALSE;
}
memcpy( &EngFuncs::textfuncs, pEngfuncsFromEngine, sizeof( ui_extendedfuncs_t ) );
memcpy( pFunctionTable, &gExtendedTable, sizeof( UI_EXTENDED_FUNCTIONS ));
return TRUE;
}