Skip to content

Commit ea9a8be

Browse files
author
L'In20Cible
committed
- Exported player buttons constants (wrapped as PlayerButtons enumerator).
1 parent c799be8 commit ea9a8be

File tree

5 files changed

+198
-2
lines changed

5 files changed

+198
-2
lines changed

addons/source-python/packages/source-python/players/constants.py

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,32 @@
2525
from _players._constants import FL_CLIENT
2626
from _players._constants import FL_FAKECLIENT
2727
from _players._constants import FL_INWATER
28+
from _players._constants import IN_ATTACK
29+
from _players._constants import IN_JUMP
30+
from _players._constants import IN_DUCK
31+
from _players._constants import IN_FORWARD
32+
from _players._constants import IN_BACK
33+
from _players._constants import IN_USE
34+
from _players._constants import IN_CANCEL
35+
from _players._constants import IN_LEFT
36+
from _players._constants import IN_RIGHT
37+
from _players._constants import IN_MOVELEFT
38+
from _players._constants import IN_MOVERIGHT
39+
from _players._constants import IN_ATTACK2
40+
from _players._constants import IN_RUN
41+
from _players._constants import IN_RELOAD
42+
from _players._constants import IN_ALT1
43+
from _players._constants import IN_ALT2
44+
from _players._constants import IN_SCORE
45+
from _players._constants import IN_SPEED
46+
from _players._constants import IN_WALK
47+
from _players._constants import IN_ZOOM
48+
from _players._constants import IN_WEAPON1
49+
from _players._constants import IN_WEAPON2
50+
from _players._constants import IN_BULLRUSH
51+
from _players._constants import IN_GRENADE1
52+
from _players._constants import IN_GRENADE2
53+
from _players._constants import IN_LOOKSPIN
2854
from _players._constants import LIFE_ALIVE
2955
from _players._constants import LIFE_DYING
3056
from _players._constants import LIFE_DEAD
@@ -36,6 +62,7 @@
3662
# >> ALL DECLARATION
3763
# =============================================================================
3864
__all__ = ('LifeState',
65+
'PlayerButtons',
3966
'PlayerFlags',
4067
)
4168

@@ -67,4 +94,36 @@ class LifeState(IntEnum):
6794
DYING = LIFE_DYING
6895
DEAD = LIFE_DEAD
6996
RESPAWNABLE = LIFE_RESPAWNABLE
70-
DISCARDBODY = LIFE_DISCARDBODY
97+
DISCARDBODY = LIFE_DISCARDBODY
98+
99+
100+
class PlayerButtons(IntEnum):
101+
102+
"""Player buttons wrapper enumerator."""
103+
104+
ATTACK = IN_ATTACK
105+
JUMP = IN_JUMP
106+
DUCK = IN_DUCK
107+
FORWARD = IN_FORWARD
108+
BACK = IN_BACK
109+
USE = IN_USE
110+
CANCEL = IN_CANCEL
111+
LEFT = IN_LEFT
112+
RIGHT = IN_RIGHT
113+
MOVELEFT = IN_MOVELEFT
114+
MOVERIGHT = IN_MOVERIGHT
115+
ATTACK2 = IN_ATTACK2
116+
RUN = IN_RUN
117+
RELOAD = IN_RELOAD
118+
ALT1 = IN_ALT1
119+
ALT2 = IN_ALT2
120+
SCORE = IN_SCORE
121+
SPEED = IN_SPEED
122+
WALK = IN_WALK
123+
ZOOM = IN_ZOOM
124+
WEAPON1 = IN_WEAPON1
125+
WEAPON2 = IN_WEAPON2
126+
BULLRUSH = IN_BULLRUSH
127+
GRENADE1 = IN_GRENADE1
128+
GRENADE2 = IN_GRENADE2
129+
LOOKSPIN = IN_LOOKSPIN

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ Set(SOURCEPYTHON_MESSAGES_MODULE_GAME_SOURCES
312312
# ------------------------------------------------------------------
313313
Set(SOURCEPYTHON_PLAYERS_MODULE_HEADERS
314314
core/modules/players/players_generator_wrap.h
315+
core/modules/entities/${SOURCE_ENGINE}/entities_constants_wrap_python.h
315316
)
316317

317318
Set(SOURCEPYTHON_PLAYERS_MODULE_SOURCES
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* =============================================================================
3+
* Source Python
4+
* Copyright (C) 2015 Source Python Development Team. All rights reserved.
5+
* =============================================================================
6+
*
7+
* This program is free software; you can redistribute it and/or modify it under
8+
* the terms of the GNU General Public License, version 3.0, as published by the
9+
* Free Software Foundation.
10+
*
11+
* This program is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14+
* details.
15+
*
16+
* You should have received a copy of the GNU General Public License along with
17+
* this program. If not, see <http://www.gnu.org/licenses/>.
18+
*
19+
* As a special exception, the Source Python Team gives you permission
20+
* to link the code of this program (as well as its derivative works) to
21+
* "Half-Life 2," the "Source Engine," and any Game MODs that run on software
22+
* by the Valve Corporation. You must obey the GNU General Public License in
23+
* all respects for all other code used. Additionally, the Source.Python
24+
* Development Team grants this exception to all derivative works.
25+
*/
26+
27+
#ifndef _PLAYERS_CONSTANTS_CSGO_WRAP_PYTHON_H
28+
#define _PLAYERS_CONSTANTS_CSGO_WRAP_PYTHON_H
29+
30+
//-----------------------------------------------------------------------------
31+
// Includes.
32+
//-----------------------------------------------------------------------------
33+
#include "utility/wrap_macros.h"
34+
35+
36+
//-----------------------------------------------------------------------------
37+
// Expose damage types.
38+
//-----------------------------------------------------------------------------
39+
template<class T>
40+
void export_engine_specific_player_buttons(T _constants)
41+
{
42+
_constants.attr("IN_LOOKSPIN") = IN_LOOKSPIN;
43+
}
44+
45+
46+
#endif // _PLAYERS_CONSTANTS_CSGO_WRAP_PYTHON_H
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* =============================================================================
3+
* Source Python
4+
* Copyright (C) 2015 Source Python Development Team. All rights reserved.
5+
* =============================================================================
6+
*
7+
* This program is free software; you can redistribute it and/or modify it under
8+
* the terms of the GNU General Public License, version 3.0, as published by the
9+
* Free Software Foundation.
10+
*
11+
* This program is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14+
* details.
15+
*
16+
* You should have received a copy of the GNU General Public License along with
17+
* this program. If not, see <http://www.gnu.org/licenses/>.
18+
*
19+
* As a special exception, the Source Python Team gives you permission
20+
* to link the code of this program (as well as its derivative works) to
21+
* "Half-Life 2," the "Source Engine," and any Game MODs that run on software
22+
* by the Valve Corporation. You must obey the GNU General Public License in
23+
* all respects for all other code used. Additionally, the Source.Python
24+
* Development Team grants this exception to all derivative works.
25+
*/
26+
27+
#ifndef _PLAYERS_CONSTANTS_ORANGEBOX_WRAP_PYTHON_H
28+
#define _PLAYERS_CONSTANTS_ORANGEBOX_WRAP_PYTHON_H
29+
30+
//-----------------------------------------------------------------------------
31+
// Includes.
32+
//-----------------------------------------------------------------------------
33+
#include "utility/wrap_macros.h"
34+
35+
36+
//-----------------------------------------------------------------------------
37+
// Expose damage types.
38+
//-----------------------------------------------------------------------------
39+
template<class T>
40+
void export_engine_specific_player_buttons(T _constants)
41+
{
42+
// Nothing specific to OrangeBox...
43+
}
44+
45+
46+
#endif // _PLAYERS_CONSTANTS_ORANGEBOX_WRAP_PYTHON_H

src/core/modules/players/players_constants_wrap_python.cpp

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,17 @@
3030
#include "modules/export_main.h"
3131
#include "utility/wrap_macros.h"
3232
#include "const.h"
33+
#include "game/shared/in_buttons.h"
34+
35+
#include ENGINE_INCLUDE_PATH(players_constants_wrap_python.h)
3336

3437

3538
//-----------------------------------------------------------------------------
3639
// Forward declarations.
3740
//-----------------------------------------------------------------------------
3841
void export_players_flags(scope);
3942
void export_life_states(scope);
43+
void export_player_buttons(scope);
4044

4145

4246
//-----------------------------------------------------------------------------
@@ -46,6 +50,7 @@ DECLARE_SP_SUBMODULE(_players, _constants)
4650
{
4751
export_players_flags(_constants);
4852
export_life_states(_constants);
53+
export_player_buttons(_constants);
4954
}
5055

5156

@@ -78,4 +83,43 @@ void export_life_states(scope _constants)
7883
_constants.attr("LIFE_DEAD") = LIFE_DEAD;
7984
_constants.attr("LIFE_RESPAWNABLE") = LIFE_RESPAWNABLE;
8085
_constants.attr("LIFE_DISCARDBODY") = LIFE_DISCARDBODY;
81-
}
86+
}
87+
88+
89+
//-----------------------------------------------------------------------------
90+
// Expose life states.
91+
//-----------------------------------------------------------------------------
92+
void export_player_buttons(scope _constants)
93+
{
94+
_constants.attr("IN_ATTACK") = IN_ATTACK;
95+
_constants.attr("IN_JUMP") = IN_JUMP;
96+
_constants.attr("IN_DUCK") = IN_DUCK;
97+
_constants.attr("IN_FORWARD") = IN_FORWARD;
98+
_constants.attr("IN_BACK") = IN_BACK;
99+
_constants.attr("IN_USE") = IN_USE;
100+
_constants.attr("IN_CANCEL") = IN_CANCEL;
101+
_constants.attr("IN_LEFT") = IN_LEFT;
102+
_constants.attr("IN_RIGHT") = IN_RIGHT;
103+
_constants.attr("IN_MOVELEFT") = IN_MOVELEFT;
104+
_constants.attr("IN_MOVERIGHT") = IN_MOVERIGHT;
105+
_constants.attr("IN_ATTACK2") = IN_ATTACK2;
106+
_constants.attr("IN_RUN") = IN_RUN;
107+
_constants.attr("IN_RELOAD") = IN_RELOAD;
108+
_constants.attr("IN_ALT1") = IN_ALT1;
109+
_constants.attr("IN_ALT2") = IN_ALT2;
110+
_constants.attr("IN_SCORE") = IN_SCORE;
111+
_constants.attr("IN_SPEED") = IN_SPEED;
112+
_constants.attr("IN_WALK") = IN_WALK;
113+
_constants.attr("IN_ZOOM") = IN_ZOOM;
114+
_constants.attr("IN_WEAPON1") = IN_WEAPON1;
115+
_constants.attr("IN_WEAPON2") = IN_WEAPON2;
116+
_constants.attr("IN_BULLRUSH") = IN_BULLRUSH;
117+
_constants.attr("IN_GRENADE1") = IN_GRENADE1;
118+
_constants.attr("IN_GRENADE2") = IN_GRENADE2;
119+
120+
// CS:GO specific constants...
121+
_constants.attr("IN_LOOKSPIN") = -1;
122+
123+
// Engine specific stuff...
124+
export_engine_specific_player_buttons(_constants);
125+
}

0 commit comments

Comments
 (0)