-
Notifications
You must be signed in to change notification settings - Fork 2
/
mod.cpp
81 lines (59 loc) · 2.12 KB
/
mod.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
#include "mod.h"
#include "config/config.h"
#include "convars/convars.h"
#include "huds/hud.h"
#include "signals/signals.h"
c_photon_mod mod;
EXPOSE_PHOTON_MOD( c_photon_mod, mod );
photon_api::c_shared* photon;
h_font font;
bool c_photon_mod::load( photon_api::c_shared* photon ) {
::photon = photon; // expose photon interface globally.
if ( !signals::initialize( ) )
return false;
if ( !convars::initialize( ) )
return false;
if ( !huds::initialize( ) )
return false;
if ( !config::initialize( ) )
return false;
photon->common->log( "example mod loaded.\n" );
// post example event
// this will look like: "example mod:load" for other mods
photon->common->post_event( &mod, "load" );
photon->render->create_font( font, "Tahoma", 12, false, fontflag_dropshadow );
return true;
}
void c_photon_mod::unload( ) {
photon->render->destruct_font( font );
config::uninitialize( );
huds::uninitialize( );
convars::uninitialize( );
signals::uninitialize( );
photon->common->log( "example mod unloaded.\n" );
}
void c_photon_mod::on_event( const char* msg ) {
if ( !strcmp( msg, "paint" ) ) {
photon->render->draw_text( 2, 2, font, { 255, 255, 255, 255 }, false, "example mod loaded." );
}
if ( !strcmp( msg, "on_screen_size_changed" ) ) {
photon->render->create_font( font, "Tahoma", 12, false, fontflag_dropshadow );
}
}
photon_api::mod_info_t c_photon_mod::get_info( ) {
photon_api::mod_info_t info;
info.name = "Example Mod";
info.author = "hero";
info.version = "0.0.1";
return info;
}
void c_photon_mod::paint_menu( ) {
photon->menu->toggle( config::example_boolean, "Example Toggle" );
photon->menu->slider( config::example_integer, 0, 100, "Example Slider" );
photon->menu->sliderf( config::example_float, 0.f, 10.f, "Example Sliderf" );
photon->menu->colorpicker( config::example_color, "Example Colorpicker" );
photon->menu->separator( "Example Separator" );
static const char* values[] = { "Value 1", "Value 2", "Value 3" };
photon->menu->combo( config::example_combo_value, values, 3, "Example Combo" );
photon->menu->multicombo( config::example_mcombo_value, values, 3, "Example Multicombo" );
}