-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathudll_int.cpp
116 lines (98 loc) · 2.84 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
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"
namespace ui
{
ui_enginefuncs_t EngFuncs::engfuncs;
#ifndef XASH_DISABLE_FWGS_EXTENSIONS
ui_textfuncs_t EngFuncs::textfuncs;
#endif
ui_globalvars_t *gpGlobals;
fs_api_t gFileSystemAPI = { };
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,
#ifdef XASH_IMGUI
UI_OnGUI
#else
nullptr
#endif
};
}
//=======================================================================
// 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, &ui::gFunctionTable, sizeof( UI_FUNCTIONS ));
memcpy( &ui::EngFuncs::engfuncs, pEngfuncsFromEngine, sizeof( ui_enginefuncs_t ));
#ifndef XASH_DISABLE_FWGS_EXTENSIONS
memset( &ui::EngFuncs::textfuncs, 0, sizeof( ui_textfuncs_t ));
#endif
ui::gpGlobals = pGlobals;
return TRUE;
}
#ifndef XASH_DISABLE_FWGS_EXTENSIONS
extern "C" EXPORT int GiveTextAPI( ui_textfuncs_t* pTextfuncsFromEngine )
{
if( !pTextfuncsFromEngine )
{
return FALSE;
}
// copy HUD_FUNCTIONS table to engine, copy engfuncs table from engine
memcpy( &ui::EngFuncs::textfuncs, pTextfuncsFromEngine, sizeof( ui_textfuncs_t ));
return TRUE;
}
extern "C" EXPORT void AddTouchButtonToList( const char *name, const char *texture, const char *command, unsigned char *color, int flags ); // TouchButtons.cpp
#endif
#ifdef XASH_STATIC_GAMELIB
typedef struct dllexport_s
{
const char *name;
void *func;
} dllexport_t;
static dllexport_t switch_mainui_exports[] = {
{ "GetMenuAPI", (void*)GetMenuAPI },
{ "GiveTextAPI", (void*)GiveTextAPI },
{ "AddTouchButtonToList", (void*)AddTouchButtonToList },
{ NULL, NULL }
};
extern "C" int dll_register( const char *name, dllexport_t *exports );
extern "C" int switch_installdll_mainui( void )
{
return dll_register( "menu", switch_mainui_exports );
}
#endif