Tiberian Technologies Scripts Reference Revision: 9000
Loading...
Searching...
No Matches
ControlClass.h
1/* Renegade Scripts.dll
2 Copyright 2013 Tiberian Technologies
3
4 This file is part of the Renegade scripts.dll
5 The Renegade scripts.dll is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 2, or (at your option) any later
8 version. See the file COPYING for more details.
9 In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence.
10 Only the source code to the module(s) containing the licenced code has to be released.
11*/
12#ifndef TT_INCLUDE__CONTROLCLASS_H
13#define TT_INCLUDE__CONTROLCLASS_H
14#include "Vector4.h"
15class BitStreamClass;
16class ChunkLoadClass;
17class ChunkSaveClass;
18class ControlClass
19{
20
21public:
22
23 typedef enum {
24 BOOLEAN_ONE_TIME_FIRST,
25 BOOLEAN_JUMP = BOOLEAN_ONE_TIME_FIRST,
26 BOOLEAN_WEAPON_NEXT,
27 BOOLEAN_WEAPON_PREV,
28 BOOLEAN_WEAPON_RELOAD,
29 BOOLEAN_WEAPON_USE,
30 BOOLEAN_DIVE_FORWARD,
31 BOOLEAN_DIVE_BACKWARD,
32 BOOLEAN_DIVE_LEFT,
33 BOOLEAN_DIVE_RIGHT,
34 BOOLEAN_ACTION,
35 BOOLEAN_SELECT_NO_WEAPON,
36 BOOLEAN_SELECT_WEAPON_0,
37 BOOLEAN_SELECT_WEAPON_1,
38 BOOLEAN_SELECT_WEAPON_2,
39 BOOLEAN_SELECT_WEAPON_3,
40 BOOLEAN_SELECT_WEAPON_4,
41 BOOLEAN_SELECT_WEAPON_5,
42 BOOLEAN_SELECT_WEAPON_6,
43 BOOLEAN_SELECT_WEAPON_7,
44 BOOLEAN_SELECT_WEAPON_8,
45 BOOLEAN_SELECT_WEAPON_9,
46 BOOLEAN_DROP_FLAG,
47 BOOLEAN_VEHICLE_TOGGLE_GUNNER,
48 BOOLEAN_CONTINUOUS_FIRST,
49 BOOLEAN_WEAPON_FIRE_PRIMARY = BOOLEAN_CONTINUOUS_FIRST,
50 BOOLEAN_WEAPON_FIRE_SECONDARY,
51 BOOLEAN_WALK,
52 BOOLEAN_CROUCH,
53 BOOLEAN_TOTAL,
54 NUM_BOOLEAN_ONE_TIME = BOOLEAN_CONTINUOUS_FIRST - BOOLEAN_ONE_TIME_FIRST,
55 NUM_BOOLEAN_CONTINUOUS = BOOLEAN_TOTAL - BOOLEAN_CONTINUOUS_FIRST,
56 } BooleanControl;
57 typedef enum {
58 ANALOG_MOVE_FORWARD,
59 ANALOG_MOVE_LEFT,
60 ANALOG_MOVE_UP,
61 ANALOG_TURN_LEFT,
62 ANALOG_CONTROL_COUNT
63 } AnalogControl;
64 ControlClass() : PendingOneTimeBooleanBits( 0 ), ActionTrigger(false)
65 {
66 Clear_Control();
67 }
68 ~ControlClass()
69 {
70 }
71 bool Save( ChunkSaveClass & csave );
72 bool Load( ChunkLoadClass & cload );
73 void Clear_Control( void );
74 void Clear_Boolean( void );
75 void Set_Action_Trigger(bool trigger) {ActionTrigger = trigger;}
76 bool Get_Action_Trigger() {return ActionTrigger;}
77 ControlClass & operator = (const ControlClass & src)
78 {
79 OneTimeBooleanBits = src.OneTimeBooleanBits;
80 ContinuousBooleanBits = src.ContinuousBooleanBits;
81 AnalogValues[0] = src.AnalogValues[0];
82 AnalogValues[1] = src.AnalogValues[1];
83 AnalogValues[2] = src.AnalogValues[2];
84 AnalogValues[3] = src.AnalogValues[3];
85 return *this;
86 }
87 void Set_Boolean( BooleanControl control, bool state = true );
88 bool Get_Boolean( BooleanControl control );
89 void Clear_One_Time_Boolean( void ) {OneTimeBooleanBits = 0;}
90 void Clear_Analog() {AnalogValues[0] = 0;AnalogValues[1] = 0;AnalogValues[2] = 0;AnalogValues[3] = 0;}
91 unsigned long Get_One_Time_Boolean_Bits(void) {return OneTimeBooleanBits;}
92 unsigned char Get_Continuous_Boolean_Bits(void) {return ContinuousBooleanBits;}
93 void Set_Analog( AnalogControl control, float value );
94 float Get_Analog( AnalogControl control );
95 void Import_Cs( BitStreamClass & packet );
96 void Export_Cs( BitStreamClass & packet );
97 void Import_Sc( BitStreamClass & packet );
98 void Export_Sc( BitStreamClass & packet );
99 static void Set_Precision(void);
100private:
101 unsigned long OneTimeBooleanBits;
102 unsigned long PendingOneTimeBooleanBits;
103 unsigned char ContinuousBooleanBits;
104 unsigned char PendingContinuousBooleanBits;
105 bool ActionTrigger;
106 float AnalogValues[ ANALOG_CONTROL_COUNT ];
107}; // size: 28
108
109inline void ControlClass::Set_Analog( AnalogControl control, float value )
110{
111 AnalogValues[ control ] = value;
112}
113inline float ControlClass::Get_Analog( AnalogControl control )
114{
115 return AnalogValues[ control ];
116}
117
118#endif