mirror of
https://github.com/jmarshall23/CnC_Remastered_Collection.git
synced 2026-08-12 08:00:55 +02:00
+6
-5
@@ -8,11 +8,12 @@
|
|||||||
/fonts
|
/fonts
|
||||||
/sound
|
/sound
|
||||||
/ui
|
/ui
|
||||||
/*.mix
|
|
||||||
/*.pal
|
|
||||||
/*.ini
|
|
||||||
/*.exe
|
/*.exe
|
||||||
/*.ilk
|
/*.ilk
|
||||||
/*.dat
|
/*.MIX
|
||||||
/savegame*
|
/*.PAL
|
||||||
|
/*.INI
|
||||||
|
/*.DAT
|
||||||
|
/SAVEGAME*
|
||||||
|
|
||||||
|
/cache
|
||||||
|
|||||||
+3
-1
@@ -11,6 +11,8 @@ set(CMAKE_VERBOSE_MAKEFILE ON)
|
|||||||
set(src_io
|
set(src_io
|
||||||
./redalert/io/userinput.cpp
|
./redalert/io/userinput.cpp
|
||||||
./redalert/io/userinput.h
|
./redalert/io/userinput.h
|
||||||
|
./redalert/io/eventqueue.h
|
||||||
|
./redalert/io/eventqueue.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(src_win32lib
|
set(src_win32lib
|
||||||
@@ -742,4 +744,4 @@ if (UNIX)
|
|||||||
set_target_properties(RedAlert PROPERTIES OUTPUT_NAME "RedAlert" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/.." )
|
set_target_properties(RedAlert PROPERTIES OUTPUT_NAME "RedAlert" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/.." )
|
||||||
endif(UNIX)
|
endif(UNIX)
|
||||||
|
|
||||||
target_include_directories(RedAlert PRIVATE ./external/xml/;./external/devil/;./external/;./redalert/win32lib;./external/lua/;./external/imgui;./external/dxsdk/Include;./external/ffmpeg-win32/include;./external/sdl2/include;./win32lib;./external/openal/include)
|
target_include_directories(RedAlert PRIVATE ./external/xml/;./external/devil/;./external/;./redalert/win32lib;./redalert/io;./external/lua/;./external/imgui;./external/dxsdk/Include;./external/ffmpeg-win32/include;./external/sdl2/include;./win32lib;./external/openal/include)
|
||||||
|
|||||||
@@ -743,7 +743,7 @@ void Keyboard_Process(KeyNumType & input)
|
|||||||
** Center the map about the construction yard or construction vehicle
|
** Center the map about the construction yard or construction vehicle
|
||||||
** if one is present.
|
** if one is present.
|
||||||
*/
|
*/
|
||||||
if (key != 0 && key == VK_H) {
|
if (key != 0 && key == Options.KeyBase) {
|
||||||
Unselect_All();
|
Unselect_All();
|
||||||
if (PlayerPtr->CurBuildings) {
|
if (PlayerPtr->CurBuildings) {
|
||||||
for (index = 0; index < Buildings.Count(); index++) {
|
for (index = 0; index < Buildings.Count(); index++) {
|
||||||
@@ -875,19 +875,19 @@ void Keyboard_Process(KeyNumType & input)
|
|||||||
** Scrolls the tactical map in the direction specified.
|
** Scrolls the tactical map in the direction specified.
|
||||||
*/
|
*/
|
||||||
int distance = CELL_LEPTON_W;
|
int distance = CELL_LEPTON_W;
|
||||||
if (key != 0 && key == VK_LEFT) {
|
if (key != 0 && key == KN_LEFT) {
|
||||||
Map.Scroll_Map(DIR_W, distance, true);
|
Map.Scroll_Map(DIR_W, distance, true);
|
||||||
input = KN_NONE;
|
input = KN_NONE;
|
||||||
}
|
}
|
||||||
if (key != 0 && key == VK_RIGHT) {
|
if (key != 0 && key == KN_RIGHT) {
|
||||||
Map.Scroll_Map(DIR_E, distance, true);
|
Map.Scroll_Map(DIR_E, distance, true);
|
||||||
input = KN_NONE;
|
input = KN_NONE;
|
||||||
}
|
}
|
||||||
if (key != 0 && key == VK_UP) {
|
if (key != 0 && key == KN_UP) {
|
||||||
Map.Scroll_Map(DIR_N, distance, true);
|
Map.Scroll_Map(DIR_N, distance, true);
|
||||||
input = KN_NONE;
|
input = KN_NONE;
|
||||||
}
|
}
|
||||||
if (key != 0 && key == VK_DOWN) {
|
if (key != 0 && key == KN_DOWN) {
|
||||||
Map.Scroll_Map(DIR_S, distance, true);
|
Map.Scroll_Map(DIR_S, distance, true);
|
||||||
input = KN_NONE;
|
input = KN_NONE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -277,7 +277,7 @@ class DisplayClass: public MapClass
|
|||||||
*/
|
*/
|
||||||
class TacticalClass : public GadgetClass {
|
class TacticalClass : public GadgetClass {
|
||||||
public:
|
public:
|
||||||
TacticalClass(void) : GadgetClass(0,0,0,0,LEFTPRESS|LEFTRELEASE|LEFTHELD|LEFTUP|RIGHTPRESS,true) {};
|
TacticalClass(void) : GadgetClass(0,0,0,0,KEYBOARD|LEFTPRESS|LEFTRELEASE|LEFTHELD|LEFTUP|RIGHTPRESS,true) {};
|
||||||
|
|
||||||
int Selection_At_Mouse(unsigned flags, KeyNumType & key);
|
int Selection_At_Mouse(unsigned flags, KeyNumType & key);
|
||||||
int Command_Object(unsigned flags, KeyNumType & key);
|
int Command_Object(unsigned flags, KeyNumType & key);
|
||||||
|
|||||||
+21
-48
@@ -253,39 +253,8 @@ int EditClass::Action(unsigned flags, KeyNumType & key)
|
|||||||
} else {
|
} else {
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|
||||||
KeyASCIIType ascii = (KeyASCIIType)(Keyboard->To_ASCII(key) & 0xff);
|
//KeyASCIIType ascii = (KeyASCIIType)(Keyboard->To_ASCII(key) & 0xff);
|
||||||
|
Handle_Key(key, flags);
|
||||||
/*
|
|
||||||
** Allow numeric keypad presses to map to ascii numbers
|
|
||||||
*/
|
|
||||||
if ((key & WWKEY_VK_BIT) && ascii >='0' && ascii <= '9') {
|
|
||||||
|
|
||||||
key = (KeyNumType)(key & ~WWKEY_VK_BIT);
|
|
||||||
if ( (!(flags & LEFTRELEASE)) && (!(flags & RIGHTRELEASE))) {
|
|
||||||
if (Handle_Key (ascii) ) {
|
|
||||||
flags &= ~KEYBOARD;
|
|
||||||
key = KN_NONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
** Filter out all special keys except return and backspace
|
|
||||||
*/ if ((!(key & WWKEY_VK_BIT) && ascii >= ' ' && ascii <= 255)
|
|
||||||
|| key == KN_RETURN || key == KN_BACKSPACE) {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ((!(flags & LEFTRELEASE)) && (!(flags & RIGHTRELEASE))) {
|
|
||||||
if (Handle_Key(Keyboard->To_ASCII(key))) {
|
|
||||||
flags &= ~KEYBOARD;
|
|
||||||
key = KN_NONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
flags &= ~KEYBOARD;
|
|
||||||
key = KN_NONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else //WIN32
|
#else //WIN32
|
||||||
@@ -374,11 +343,11 @@ void EditClass::Draw_Text(char const * text)
|
|||||||
* HISTORY: *
|
* HISTORY: *
|
||||||
* 01/21/1995 JLB : Created. *
|
* 01/21/1995 JLB : Created. *
|
||||||
*=============================================================================================*/
|
*=============================================================================================*/
|
||||||
bool EditClass::Handle_Key(KeyASCIIType ascii)
|
bool EditClass::Handle_Key(KeyNumType key, unsigned flags)
|
||||||
{
|
{
|
||||||
unsigned char testAscii = (unsigned char)ascii;
|
unsigned rawKey = key & 0xff;
|
||||||
|
|
||||||
switch (ascii) {
|
switch (rawKey) {
|
||||||
/*
|
/*
|
||||||
** Handle the special case of a non-keyboard event. It is possible that this
|
** Handle the special case of a non-keyboard event. It is possible that this
|
||||||
** key code might be passed to this routine if this routine has been overridden
|
** key code might be passed to this routine if this routine has been overridden
|
||||||
@@ -387,6 +356,7 @@ bool EditClass::Handle_Key(KeyASCIIType ascii)
|
|||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** If the return key is pressed, then remove the focus from this edit
|
** If the return key is pressed, then remove the focus from this edit
|
||||||
** gadget but otherwise let the normal gadget processing proceed. This
|
** gadget but otherwise let the normal gadget processing proceed. This
|
||||||
@@ -394,14 +364,14 @@ bool EditClass::Handle_Key(KeyASCIIType ascii)
|
|||||||
** so that the controlling program will know that the text can be
|
** so that the controlling program will know that the text can be
|
||||||
** processed.
|
** processed.
|
||||||
*/
|
*/
|
||||||
case KA_RETURN:
|
case KN_RETURN:
|
||||||
Clear_Focus();
|
Clear_Focus();
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** When the BACKSPACE key is pressed, remove the last character in the edit string.
|
** When the BACKSPACE key is pressed, remove the last character in the edit string.
|
||||||
*/
|
*/
|
||||||
case KA_BACKSPACE:
|
case KN_BACKSPACE:
|
||||||
if (Length) {
|
if (Length) {
|
||||||
Length--;
|
Length--;
|
||||||
String[Length] = '\0';
|
String[Length] = '\0';
|
||||||
@@ -414,11 +384,13 @@ bool EditClass::Handle_Key(KeyASCIIType ascii)
|
|||||||
** if it can legally be added to the edit string and do so if possible.
|
** if it can legally be added to the edit string and do so if possible.
|
||||||
*/
|
*/
|
||||||
default:
|
default:
|
||||||
|
unsigned char keyAscii = UserInput.KeyB.ASCII;
|
||||||
|
if (key & KN_SHIFT_BIT || key & KN_CAPSLOCK_BIT) keyAscii = toupper(keyAscii);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Don't add a character if the length is greater than edit width.
|
** Don't add a character if the length is greater than edit width.
|
||||||
*/
|
*/
|
||||||
if (((int)String_Pixel_Width(String) + (int)Char_Pixel_Width(testAscii) ) >= (Width-2)) {
|
if (((int)String_Pixel_Width(String) + (int)Char_Pixel_Width(keyAscii) ) >= (Width-2)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -431,21 +403,21 @@ bool EditClass::Handle_Key(KeyASCIIType ascii)
|
|||||||
** Invisible characters are never added to the string. This is
|
** Invisible characters are never added to the string. This is
|
||||||
** especially true for spaces at the beginning of the string.
|
** especially true for spaces at the beginning of the string.
|
||||||
*/
|
*/
|
||||||
if (!isgraph(testAscii) && testAscii != ' ') break;
|
if (!isgraph(keyAscii) && keyAscii != ' ') break;
|
||||||
if (testAscii == ' ' && Length == 0) break;
|
if (keyAscii == ' ' && Length == 0) break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** If this is an upper case only edit gadget, then force the alphabetic
|
** If this is an upper case only edit gadget, then force the alphabetic
|
||||||
** character to upper case.
|
** character to upper case.
|
||||||
*/
|
*/
|
||||||
if ((EditFlags & UPPERCASE) && isalpha(testAscii)) {
|
if ((EditFlags & UPPERCASE) && isalpha(keyAscii)) {
|
||||||
testAscii = (KeyASCIIType)toupper(testAscii);
|
rawKey = (KeyASCIIType)toupper(keyAscii);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!(EditFlags & NUMERIC) || !isdigit(testAscii)) &&
|
if ((!(EditFlags & NUMERIC) || !isdigit(keyAscii)) &&
|
||||||
(!(EditFlags & ALPHA) || !isalpha(testAscii)) &&
|
(!(EditFlags & ALPHA) || !isalpha(keyAscii)) &&
|
||||||
(!(EditFlags & MISC) || isalnum(testAscii)) &&
|
(!(EditFlags & MISC) || isalnum(keyAscii)) &&
|
||||||
testAscii != ' ') {
|
rawKey != ' ') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -455,8 +427,9 @@ bool EditClass::Handle_Key(KeyASCIIType ascii)
|
|||||||
** because the event flag has been cleared. This prevents the gadget's ID
|
** because the event flag has been cleared. This prevents the gadget's ID
|
||||||
** number from being returned just because the gadget has been edited.
|
** number from being returned just because the gadget has been edited.
|
||||||
*/
|
*/
|
||||||
String[Length++] = testAscii;
|
String[Length++] = keyAscii;
|
||||||
String[Length] = '\0';
|
String[Length] = '\0';
|
||||||
|
|
||||||
Flag_To_Redraw();
|
Flag_To_Redraw();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ class EditClass : public ControlClass
|
|||||||
virtual int Action (unsigned flags, KeyNumType &key);
|
virtual int Action (unsigned flags, KeyNumType &key);
|
||||||
virtual void Draw_Background(void);
|
virtual void Draw_Background(void);
|
||||||
virtual void Draw_Text(char const * text);
|
virtual void Draw_Text(char const * text);
|
||||||
virtual bool Handle_Key(KeyASCIIType ascii);
|
virtual bool Handle_Key(KeyNumType ascii, unsigned flags);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int IsReadOnly;
|
int IsReadOnly;
|
||||||
|
|||||||
@@ -162,6 +162,7 @@ extern PKey SlowKey;
|
|||||||
extern RulesClass Rule;
|
extern RulesClass Rule;
|
||||||
extern KeyboardClass * Keyboard;
|
extern KeyboardClass * Keyboard;
|
||||||
extern UserInputClass UserInput;
|
extern UserInputClass UserInput;
|
||||||
|
extern EventQueueClass EventQueue;
|
||||||
extern RandomStraw CryptRandom;
|
extern RandomStraw CryptRandom;
|
||||||
extern RandomClass NonCriticalRandomNumber;
|
extern RandomClass NonCriticalRandomNumber;
|
||||||
extern CarryoverClass * Carryover;
|
extern CarryoverClass * Carryover;
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
* Functions: *
|
* Functions: *
|
||||||
* fixed::As_ASCII -- Returns a pointer (static) of this number as an ASCII string. *
|
* fixed::As_ASCII -- Returns a pointer (static) of this number as an ASCII string. *
|
||||||
* fixed::To_ASCII -- Convert a fixed point number into an ASCII string. *
|
* fixed::To_ASCII -- Convert a fixed point number into an ASCII string. *
|
||||||
|
* fixed::To_Float -- Convert a fixed point number into a float value *
|
||||||
* fixed::fixed -- Constructor for fixed integral from ASCII initializer. *
|
* fixed::fixed -- Constructor for fixed integral from ASCII initializer. *
|
||||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||||
|
|
||||||
@@ -40,6 +41,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -148,6 +150,33 @@ fixed::fixed(char const * ascii)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************************************
|
||||||
|
* fixed::To_Float -- Convert a fixed point number into a float *
|
||||||
|
* *
|
||||||
|
* Use this routine to convert this fixed point number into a float. This can be lossy for *
|
||||||
|
* fine values. *
|
||||||
|
* *
|
||||||
|
* INPUT: none *
|
||||||
|
* *
|
||||||
|
* OUTPUT: Returns with the float value of this fixed point number *
|
||||||
|
* *
|
||||||
|
* WARNINGS: none *
|
||||||
|
* *
|
||||||
|
* HISTORY: *
|
||||||
|
* 06/27/2020 JJ : Created. *
|
||||||
|
*=============================================================================================*/
|
||||||
|
float fixed::To_Float() const
|
||||||
|
{
|
||||||
|
|
||||||
|
unsigned int whole = Data.Composite.Whole;
|
||||||
|
unsigned int frac = ((unsigned int)Data.Composite.Fraction * 1000U) / PRECISION;
|
||||||
|
|
||||||
|
float this_raw_value = (whole + (frac * .001));
|
||||||
|
|
||||||
|
return floor(this_raw_value * 100.0 + 0.5) / 100.0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************************************
|
/***********************************************************************************************
|
||||||
* fixed::To_ASCII -- Convert a fixed point number into an ASCII string. *
|
* fixed::To_ASCII -- Convert a fixed point number into an ASCII string. *
|
||||||
* *
|
* *
|
||||||
|
|||||||
@@ -206,6 +206,11 @@ class fixed
|
|||||||
int To_ASCII(char * buffer, int maxlen=-1) const;
|
int To_ASCII(char * buffer, int maxlen=-1) const;
|
||||||
char const * As_ASCII(void) const;
|
char const * As_ASCII(void) const;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Helper function to convert fixed point number to float (JJ)
|
||||||
|
*/
|
||||||
|
float To_Float() const;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Helper constants that provide some convenient fixed point values.
|
** Helper constants that provide some convenient fixed point values.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -200,7 +200,8 @@ struct NoInitClass {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "key.h"
|
#include "key.h"
|
||||||
#include "io/UserInput.h"
|
#include "io/userinput.h"
|
||||||
|
#include "io/eventqueue.h"
|
||||||
|
|
||||||
#include <wwlib32.h>
|
#include <wwlib32.h>
|
||||||
#include "mpu.h"
|
#include "mpu.h"
|
||||||
|
|||||||
+50
-106
@@ -58,31 +58,31 @@
|
|||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** This records the current gadget the the gadget system is "stuck on". Such a
|
** This records the current gadget the the gadget system is "stuck on". Such a
|
||||||
** gadget will be processed to the exclusion of all others until the mouse button
|
** gadget will be processed to the exclusion of all others until the mouse button
|
||||||
** is no longer pressed.
|
** is no longer pressed.
|
||||||
*/
|
*/
|
||||||
GadgetClass * GadgetClass::StuckOn = 0;
|
GadgetClass* GadgetClass::StuckOn = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** This is a copy of a pointer to the last list used by the gadget input system.
|
** This is a copy of a pointer to the last list used by the gadget input system.
|
||||||
** If a change of list is detected, then all gadgets are forced to be redrawn.
|
** If a change of list is detected, then all gadgets are forced to be redrawn.
|
||||||
*/
|
*/
|
||||||
GadgetClass * GadgetClass::LastList = 0;
|
GadgetClass* GadgetClass::LastList = 0;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** This points to the gadget that is intercepting all keyboard events.
|
** This points to the gadget that is intercepting all keyboard events.
|
||||||
*/
|
*/
|
||||||
GadgetClass * GadgetClass::Focused = 0;
|
GadgetClass* GadgetClass::Focused = 0;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** This points to the current color scheme for drawing all gadgets.
|
** This points to the current color scheme for drawing all gadgets.
|
||||||
*/
|
*/
|
||||||
static RemapControlType _GreyScheme = {15};
|
static RemapControlType _GreyScheme = { 15 };
|
||||||
RemapControlType * GadgetClass::ColorScheme = &_GreyScheme;
|
RemapControlType* GadgetClass::ColorScheme = &_GreyScheme;
|
||||||
|
|
||||||
/***********************************************************************************************
|
/***********************************************************************************************
|
||||||
* GadgetClass::GadgetClass -- Constructor for gadget object. *
|
* GadgetClass::GadgetClass -- Constructor for gadget object. *
|
||||||
@@ -110,7 +110,7 @@ GadgetClass::GadgetClass(int x, int y, int w, int h, unsigned flags, int sticky)
|
|||||||
X(x), Y(y), Width(w), Height(h), IsToRepaint(false), IsSticky(sticky), IsDisabled(false), Flags(flags)
|
X(x), Y(y), Width(w), Height(h), IsToRepaint(false), IsSticky(sticky), IsDisabled(false), Flags(flags)
|
||||||
{
|
{
|
||||||
if (IsSticky) {
|
if (IsSticky) {
|
||||||
Flags |= LEFTPRESS|LEFTRELEASE;
|
Flags |= LEFTPRESS | LEFTRELEASE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ GadgetClass::GadgetClass(int x, int y, int w, int h, unsigned flags, int sticky)
|
|||||||
* HISTORY: *
|
* HISTORY: *
|
||||||
* 08/01/1996 JLB : Created. *
|
* 08/01/1996 JLB : Created. *
|
||||||
*=============================================================================================*/
|
*=============================================================================================*/
|
||||||
GadgetClass::GadgetClass(GadgetClass const & gadget) :
|
GadgetClass::GadgetClass(GadgetClass const& gadget) :
|
||||||
X(gadget.X),
|
X(gadget.X),
|
||||||
Y(gadget.Y),
|
Y(gadget.Y),
|
||||||
Width(gadget.Width),
|
Width(gadget.Width),
|
||||||
@@ -190,7 +190,7 @@ GadgetClass::~GadgetClass(void)
|
|||||||
* *
|
* *
|
||||||
* HISTORY: 01/03/1995 MML : Created. *
|
* HISTORY: 01/03/1995 MML : Created. *
|
||||||
*=========================================================================*/
|
*=========================================================================*/
|
||||||
int GadgetClass::Clicked_On(KeyNumType & key, unsigned flags, int mousex, int mousey)
|
int GadgetClass::Clicked_On(KeyNumType& key, unsigned flags, int mousex, int mousey)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
** Set flags to match only those events that occur AND are being looked for. If
|
** Set flags to match only those events that occur AND are being looked for. If
|
||||||
@@ -212,7 +212,7 @@ int GadgetClass::Clicked_On(KeyNumType & key, unsigned flags, int mousex, int mo
|
|||||||
*/
|
*/
|
||||||
if (this == StuckOn ||
|
if (this == StuckOn ||
|
||||||
(flags & KEYBOARD) ||
|
(flags & KEYBOARD) ||
|
||||||
(flags && (mousex - X) < Width && (mousey - Y) < Height)) {
|
(flags && (mousex - X) < Width && (mousey - Y) < Height)) {
|
||||||
|
|
||||||
return(Action(flags, key));
|
return(Action(flags, key));
|
||||||
}
|
}
|
||||||
@@ -281,10 +281,10 @@ void GadgetClass::Disable(void)
|
|||||||
* HISTORY: *
|
* HISTORY: *
|
||||||
* 01/15/1995 JLB : Created. *
|
* 01/15/1995 JLB : Created. *
|
||||||
*=============================================================================================*/
|
*=============================================================================================*/
|
||||||
GadgetClass * GadgetClass::Remove(void)
|
GadgetClass* GadgetClass::Remove(void)
|
||||||
{
|
{
|
||||||
Clear_Focus();
|
Clear_Focus();
|
||||||
return(GadgetClass *)LinkClass::Remove();
|
return(GadgetClass*)LinkClass::Remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -303,7 +303,7 @@ GadgetClass * GadgetClass::Remove(void)
|
|||||||
* HISTORY: *
|
* HISTORY: *
|
||||||
* 01/15/1995 JLB : Created. *
|
* 01/15/1995 JLB : Created. *
|
||||||
*=============================================================================================*/
|
*=============================================================================================*/
|
||||||
GadgetClass * GadgetClass::Get_Next(void) const
|
GadgetClass* GadgetClass::Get_Next(void) const
|
||||||
{
|
{
|
||||||
return(GadgetClass*)LinkClass::Get_Next();
|
return(GadgetClass*)LinkClass::Get_Next();
|
||||||
}
|
}
|
||||||
@@ -324,7 +324,7 @@ GadgetClass * GadgetClass::Get_Next(void) const
|
|||||||
* HISTORY: *
|
* HISTORY: *
|
||||||
* 01/15/1995 JLB : Created. *
|
* 01/15/1995 JLB : Created. *
|
||||||
*=============================================================================================*/
|
*=============================================================================================*/
|
||||||
GadgetClass * GadgetClass::Get_Prev(void) const
|
GadgetClass* GadgetClass::Get_Prev(void) const
|
||||||
{
|
{
|
||||||
return(GadgetClass*)LinkClass::Get_Prev();
|
return(GadgetClass*)LinkClass::Get_Prev();
|
||||||
}
|
}
|
||||||
@@ -347,7 +347,7 @@ GadgetClass * GadgetClass::Get_Prev(void) const
|
|||||||
*=============================================================================================*/
|
*=============================================================================================*/
|
||||||
void GadgetClass::Delete_List(void)
|
void GadgetClass::Delete_List(void)
|
||||||
{
|
{
|
||||||
GadgetClass * g = this;
|
GadgetClass* g = this;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Move to head of the list.
|
** Move to head of the list.
|
||||||
@@ -365,7 +365,7 @@ void GadgetClass::Delete_List(void)
|
|||||||
while (g) {
|
while (g) {
|
||||||
g->Clear_Focus();
|
g->Clear_Focus();
|
||||||
|
|
||||||
GadgetClass * temp = g;
|
GadgetClass* temp = g;
|
||||||
g = g->Get_Next();
|
g = g->Get_Next();
|
||||||
delete temp;
|
delete temp;
|
||||||
}
|
}
|
||||||
@@ -391,7 +391,7 @@ void GadgetClass::Delete_List(void)
|
|||||||
* HISTORY: *
|
* HISTORY: *
|
||||||
* 01/15/1995 JLB : Created. *
|
* 01/15/1995 JLB : Created. *
|
||||||
*=============================================================================================*/
|
*=============================================================================================*/
|
||||||
int GadgetClass::Action(unsigned flags, KeyNumType &)
|
int GadgetClass::Action(unsigned flags, KeyNumType&)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
** If any of the event flags are active, then this indicates that something probably
|
** If any of the event flags are active, then this indicates that something probably
|
||||||
@@ -450,7 +450,7 @@ int GadgetClass::Draw_Me(int forced)
|
|||||||
*=============================================================================================*/
|
*=============================================================================================*/
|
||||||
void GadgetClass::Draw_All(bool forced)
|
void GadgetClass::Draw_All(bool forced)
|
||||||
{
|
{
|
||||||
GadgetClass * gadget = this;
|
GadgetClass* gadget = this;
|
||||||
|
|
||||||
while (gadget != NULL) {
|
while (gadget != NULL) {
|
||||||
gadget->Draw_Me(forced);
|
gadget->Draw_Me(forced);
|
||||||
@@ -470,8 +470,10 @@ void GadgetClass::Draw_All(bool forced)
|
|||||||
* HISTORY: 01/03/1995 MML : Created. *
|
* HISTORY: 01/03/1995 MML : Created. *
|
||||||
*=========================================================================*/
|
*=========================================================================*/
|
||||||
KeyNumType GadgetClass::Input(void)
|
KeyNumType GadgetClass::Input(void)
|
||||||
{
|
{
|
||||||
KeyNumType key;
|
EventMessage eventMessage;
|
||||||
|
KeyNumType key = KN_NONE;
|
||||||
|
int flags = 0;
|
||||||
int forced = false;
|
int forced = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -488,111 +490,52 @@ KeyNumType GadgetClass::Input(void)
|
|||||||
/*
|
/*
|
||||||
** Fetch any pending keyboard input.
|
** Fetch any pending keyboard input.
|
||||||
*/
|
*/
|
||||||
key = Keyboard->Check();
|
UserInput.Process_Input(key, flags);
|
||||||
if (key != 0) {
|
|
||||||
key = Keyboard->Get();
|
if (EventQueue.Check()) {
|
||||||
|
eventMessage = EventQueue.Get();
|
||||||
|
eventMessage.Key_Flags(key, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
** For mouse button clicks, the mouse position is actually held in the MouseQ...
|
|
||||||
** globals rather than their normal Mouse... globals. This is because we need to
|
|
||||||
** know the position of the mouse at the exact instant when the click occurred
|
|
||||||
** rather the the mouse position at the time we get around to this function.
|
|
||||||
*/
|
|
||||||
// jmarshall
|
|
||||||
UserInput.Process_Input( g_globalKeyNumType, g_globalKeyFlags);
|
|
||||||
int flags = g_globalKeyFlags;
|
|
||||||
// jmarshall end
|
|
||||||
|
|
||||||
/*
|
|
||||||
** Set the mouse button state flags. These will be passed to the individual
|
|
||||||
** buttons so that they can determine what action to perform (if any).
|
|
||||||
*/
|
|
||||||
//if (key) {
|
|
||||||
// if (key == KN_LMOUSE) {
|
|
||||||
// flags |= LEFTPRESS;
|
|
||||||
// }
|
|
||||||
// if (key == KN_RMOUSE) {
|
|
||||||
// flags |= RIGHTPRESS;
|
|
||||||
// }
|
|
||||||
// if (key == (KN_LMOUSE | KN_RLSE_BIT)) {
|
|
||||||
// flags |= LEFTRELEASE;
|
|
||||||
// }
|
|
||||||
// if (key == (KN_RMOUSE | KN_RLSE_BIT)) {
|
|
||||||
// flags |= RIGHTRELEASE;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
/*
|
|
||||||
** If the mouse wasn't responsible for this key code, then it must be from
|
|
||||||
** the keyboard. Flag this fact.
|
|
||||||
*/
|
|
||||||
if (key && !flags) {
|
|
||||||
flags |= KEYBOARD;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
** Mouse button up or down action is ignored if there is a keyboard event. This
|
|
||||||
** allows keyboard events to fall through normally even if the mouse is over a
|
|
||||||
** gadget that is flagged for LEFTUP or RIGHTUP.
|
|
||||||
*/
|
|
||||||
// jmarshall
|
|
||||||
//if (!key) {
|
|
||||||
//
|
|
||||||
// /*
|
|
||||||
// ** Check for the mouse being held down. We can't use the normal input system
|
|
||||||
// ** for this, so we must examine the actual current state of the mouse
|
|
||||||
// ** buttons. As a side note, if we determine that the mouse button isn't being
|
|
||||||
// ** held down, then we automatically know that it must be up -- set the flag
|
|
||||||
// ** accordingly.
|
|
||||||
// */
|
|
||||||
// if (Keyboard->Down(KN_LMOUSE)) {
|
|
||||||
// flags |= LEFTHELD;
|
|
||||||
// } else {
|
|
||||||
// flags |= LEFTUP;
|
|
||||||
// }
|
|
||||||
// if (Keyboard->Down(KN_RMOUSE)) {
|
|
||||||
// flags |= RIGHTHELD;
|
|
||||||
// } else {
|
|
||||||
// flags |= RIGHTUP;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
// jmarshall end
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** If "sticky" processing is active, then only process the stuck gadget.
|
** If "sticky" processing is active, then only process the stuck gadget.
|
||||||
*/
|
*/
|
||||||
if (StuckOn) {
|
if (StuckOn) {
|
||||||
StuckOn->Draw_Me(false);
|
StuckOn->Draw_Me(false);
|
||||||
GadgetClass * oldstuck = StuckOn;
|
GadgetClass* oldstuck = StuckOn;
|
||||||
StuckOn->Clicked_On(key, flags, UserInput.Mouse.X, UserInput.Mouse.Y);
|
StuckOn->Clicked_On(key, flags, UserInput.Mouse.X, UserInput.Mouse.Y);
|
||||||
if (StuckOn) {
|
|
||||||
|
if (StuckOn)
|
||||||
|
{
|
||||||
StuckOn->Draw_Me(false);
|
StuckOn->Draw_Me(false);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
oldstuck->Draw_Me(false);
|
oldstuck->Draw_Me(false);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
** If there is a gadget that has the keyboard focus, then route all keyboard
|
** If there is a gadget that has the keyboard focus, then route all keyboard
|
||||||
** events to it.
|
** events to it.
|
||||||
*/
|
*/
|
||||||
if (Focused && (flags & KEYBOARD)) {
|
if (Focused && eventMessage.EventType == EventMessageType::EVENT_KEYBOARD) {
|
||||||
Focused->Draw_Me(false);
|
Focused->Draw_Me(false);
|
||||||
Focused->Clicked_On(key, flags, UserInput.Mouse.X, UserInput.Mouse.Y);
|
Focused->Clicked_On(key, flags, UserInput.Mouse.X, UserInput.Mouse.Y);
|
||||||
if (Focused) {
|
if (Focused) {
|
||||||
Focused->Draw_Me(false);
|
Focused->Draw_Me(false);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Sweep through all the buttons in the chain and pass the current button state
|
** Sweep through all the buttons in the chain and pass the current button state
|
||||||
** and keyboard input data to them. These routines will detect whether they should
|
** and keyboard input data to them. These routines will detect whether they should
|
||||||
** perform some action and return a flag to this effect. They also have the option
|
** perform some action and return a flag to this effect. They also have the option
|
||||||
** of changing the key value so that an appropriate return value is use for this
|
** of changing the key value so that an appropriate return value is used for this
|
||||||
** processing routine.
|
** processing routine.
|
||||||
*/
|
*/
|
||||||
GadgetClass * next_button = this;
|
GadgetClass* next_button = this;
|
||||||
while (next_button != NULL) {
|
while (next_button != NULL) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -621,6 +564,7 @@ KeyNumType GadgetClass::Input(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(key);
|
return(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -645,14 +589,14 @@ KeyNumType GadgetClass::Input(void)
|
|||||||
* HISTORY: *
|
* HISTORY: *
|
||||||
* 01/16/1995 JLB : Created. *
|
* 01/16/1995 JLB : Created. *
|
||||||
*=============================================================================================*/
|
*=============================================================================================*/
|
||||||
ControlClass * GadgetClass::Extract_Gadget(unsigned id)
|
ControlClass* GadgetClass::Extract_Gadget(unsigned id)
|
||||||
{
|
{
|
||||||
GadgetClass * g = this;
|
GadgetClass* g = this;
|
||||||
|
|
||||||
if (id != 0) {
|
if (id != 0) {
|
||||||
while (g != NULL) {
|
while (g != NULL) {
|
||||||
if (g->Get_ID() == id) {
|
if (g->Get_ID() == id) {
|
||||||
return((ControlClass *)g);
|
return((ControlClass*)g);
|
||||||
}
|
}
|
||||||
g = g->Get_Next();
|
g = g->Get_Next();
|
||||||
}
|
}
|
||||||
@@ -801,7 +745,7 @@ bool GadgetClass::Has_Focus(void)
|
|||||||
*=============================================================================================*/
|
*=============================================================================================*/
|
||||||
int GadgetClass::Is_List_To_Redraw(void)
|
int GadgetClass::Is_List_To_Redraw(void)
|
||||||
{
|
{
|
||||||
GadgetClass * gadget = this;
|
GadgetClass* gadget = this;
|
||||||
|
|
||||||
while (gadget != NULL) {
|
while (gadget != NULL) {
|
||||||
if (gadget->IsToRepaint) {
|
if (gadget->IsToRepaint) {
|
||||||
|
|||||||
@@ -257,6 +257,7 @@ RulesClass Rule;
|
|||||||
** user input class pointer.
|
** user input class pointer.
|
||||||
*/
|
*/
|
||||||
UserInputClass UserInput;
|
UserInputClass UserInput;
|
||||||
|
EventQueueClass EventQueue;
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
** All keyboard input is routed through the object pointed to by this
|
** All keyboard input is routed through the object pointed to by this
|
||||||
|
|||||||
@@ -0,0 +1,157 @@
|
|||||||
|
#include "../function.h"
|
||||||
|
#include "eventqueue.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Clears the event queue and frees memory
|
||||||
|
*/
|
||||||
|
void EventQueueClass::Clear()
|
||||||
|
{
|
||||||
|
while (this->eventQueue.size() > 0) {
|
||||||
|
this->eventQueue.pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Inserts a new event message event into the FIFO buffer.
|
||||||
|
*/
|
||||||
|
void EventQueueClass::Put(EventMessage input)
|
||||||
|
{
|
||||||
|
if ( Is_Buffer_Full() ) return;
|
||||||
|
this->eventQueue.push( input );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Check if the buffer contains an element
|
||||||
|
*/
|
||||||
|
bool EventQueueClass::Check() const
|
||||||
|
{
|
||||||
|
return !this->Is_Buffer_Empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Get the first (unprocessed) element in the event queue
|
||||||
|
*/
|
||||||
|
EventMessage EventQueueClass::Get()
|
||||||
|
{
|
||||||
|
// wait for buffer
|
||||||
|
while( !this->Check() ) { }
|
||||||
|
|
||||||
|
EventMessage returnVal = this->eventQueue.front();
|
||||||
|
this->eventQueue.pop();
|
||||||
|
|
||||||
|
return returnVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Returns ASCII value of the key in the buffer
|
||||||
|
*/
|
||||||
|
char EventQueueClass::Get_ASCII()
|
||||||
|
{
|
||||||
|
// get the last key from the buffer
|
||||||
|
EventMessage eventMessage = this->Get();
|
||||||
|
return eventMessage.Keyboard.ASCII;
|
||||||
|
}
|
||||||
|
|
||||||
|
EventMessage::EventMessage(KeyNumType key, char ascii, bool shift, bool alt, bool control, bool capsLock) {
|
||||||
|
this->Clear();
|
||||||
|
|
||||||
|
this->Valid = true;
|
||||||
|
this->EventType = EventMessageType::EVENT_KEYBOARD;
|
||||||
|
|
||||||
|
this->Keyboard.Key = key;
|
||||||
|
this->Keyboard.Shift = shift;
|
||||||
|
this->Keyboard.Alt = alt;
|
||||||
|
this->Keyboard.Control = control;
|
||||||
|
this->Keyboard.CapsLock = capsLock;
|
||||||
|
this->Keyboard.ASCII = ascii;
|
||||||
|
}
|
||||||
|
|
||||||
|
EventMessage::EventMessage(int x, int y, unsigned short button, MouseButtonState buttonState)
|
||||||
|
{
|
||||||
|
this->Clear();
|
||||||
|
|
||||||
|
this->Valid = true;
|
||||||
|
this->EventType = EventMessageType::EVENT_MOUSE;
|
||||||
|
|
||||||
|
this->Mouse.x = x;
|
||||||
|
this->Mouse.y = y;
|
||||||
|
this->Mouse.Button = button;
|
||||||
|
this->Mouse.ButtonState = buttonState;
|
||||||
|
|
||||||
|
this->Flags = 0;
|
||||||
|
|
||||||
|
if (buttonState == MouseButtonState::MOUSE_BUTTON_UP) {
|
||||||
|
this->Flags = (button == KN_LMOUSE) ? GadgetClass::LEFTUP : GadgetClass::RIGHTUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buttonState == MouseButtonState::MOUSE_BUTTON_DOWN) {
|
||||||
|
this->Flags = (button == KN_LMOUSE) ? GadgetClass::LEFTPRESS : GadgetClass::RIGHTPRESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buttonState == MouseButtonState::MOUSE_BUTTON_HOLD) {
|
||||||
|
this->Flags = (button == KN_LMOUSE) ? GadgetClass::LEFTHELD : GadgetClass::RIGHTHELD;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buttonState == MouseButtonState::MOUSE_BUTTON_RELEASE) {
|
||||||
|
this->Flags = (button == KN_LMOUSE) ? GadgetClass::LEFTRELEASE : GadgetClass::RIGHTRELEASE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EventMessage::Key_Flags(KeyNumType& key, int& flags)
|
||||||
|
{
|
||||||
|
if (this->EventType == EventMessageType::EVENT_KEYBOARD)
|
||||||
|
{
|
||||||
|
flags = this->Flags;
|
||||||
|
flags |= GadgetClass::KEYBOARD;
|
||||||
|
|
||||||
|
unsigned short outputKey = this->Keyboard.Key;
|
||||||
|
|
||||||
|
if (this->Keyboard.Shift) outputKey |= KN_SHIFT_BIT;
|
||||||
|
if (this->Keyboard.Alt) outputKey |= KN_ALT_BIT;
|
||||||
|
if (this->Keyboard.Control) outputKey |= KN_CTRL_BIT;
|
||||||
|
|
||||||
|
key = (KeyNumType)outputKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->EventType == EventMessageType::EVENT_MOUSE)
|
||||||
|
{
|
||||||
|
key = (KeyNumType)this->Mouse.Button;
|
||||||
|
|
||||||
|
if (key == KN_LMOUSE) {
|
||||||
|
switch (this->Mouse.ButtonState)
|
||||||
|
{
|
||||||
|
case MouseButtonState::MOUSE_BUTTON_UP:
|
||||||
|
flags = GadgetClass::LEFTUP;
|
||||||
|
break;
|
||||||
|
case MouseButtonState::MOUSE_BUTTON_DOWN:
|
||||||
|
flags = GadgetClass::LEFTPRESS;
|
||||||
|
break;
|
||||||
|
case MouseButtonState::MOUSE_BUTTON_RELEASE:
|
||||||
|
flags = GadgetClass::LEFTRELEASE;
|
||||||
|
break;
|
||||||
|
case MouseButtonState::MOUSE_BUTTON_HOLD:
|
||||||
|
flags = GadgetClass::LEFTHELD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key == KN_RMOUSE) {
|
||||||
|
switch (this->Mouse.ButtonState)
|
||||||
|
{
|
||||||
|
case MouseButtonState::MOUSE_BUTTON_UP:
|
||||||
|
flags = GadgetClass::LEFTUP;
|
||||||
|
break;
|
||||||
|
case MouseButtonState::MOUSE_BUTTON_DOWN:
|
||||||
|
flags = GadgetClass::RIGHTPRESS;
|
||||||
|
break;
|
||||||
|
case MouseButtonState::MOUSE_BUTTON_RELEASE:
|
||||||
|
flags = GadgetClass::RIGHTRELEASE;
|
||||||
|
break;
|
||||||
|
case MouseButtonState::MOUSE_BUTTON_HOLD:
|
||||||
|
flags = GadgetClass::RIGHTHELD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* WWKeyboardClass::Buff_Get -- Lowlevel function to get a key from key buffer*
|
||||||
|
* WWKeyboardClass::Check -- Checks to see if a key is in the buffer*
|
||||||
|
* WWKeyboardClass::Down -- Checks to see if the specified key is being held down.*
|
||||||
|
* WWKeyboardClass::Fetch_Element -- Extract the next element in the keyboard buffer.*
|
||||||
|
* WWKeyboardClass::Get -- Logic to get a metakey from the buffer*
|
||||||
|
* WWKeyboardClass::Message_Handler -- Process a windows message as it relates to the keyboar*
|
||||||
|
* WWKeyboardClass::Peek_Element -- Fetches the next element in the keyboard buffer.*
|
||||||
|
* WWKeyboardClass::To_ASCII -- Convert the key value into an ASCII representation.*
|
||||||
|
* WWKeyboardClass::Available_Buffer_Room -- Fetch the quantity of free elements in the keybo*
|
||||||
|
* ----------------------------------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EVENT QUEUE class
|
||||||
|
* Supports pumping of event messages using a FIFO buffer.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern UserInputClass UserInput;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Event type definitions
|
||||||
|
*/
|
||||||
|
typedef enum EventMessageType {
|
||||||
|
EVENT_NONE,
|
||||||
|
EVENT_KEYBOARD,
|
||||||
|
EVENT_MOUSE
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Event types
|
||||||
|
*/
|
||||||
|
class EventMessage {
|
||||||
|
public:
|
||||||
|
EventMessageType EventType;
|
||||||
|
bool Valid;
|
||||||
|
|
||||||
|
EventMessage() {
|
||||||
|
this->EventType == EVENT_NONE;
|
||||||
|
|
||||||
|
this->Keyboard.Key = KN_NONE;
|
||||||
|
this->Keyboard.Shift = false;
|
||||||
|
this->Keyboard.Alt = false;
|
||||||
|
this->Keyboard.Control = false;
|
||||||
|
this->Keyboard.CapsLock = false;
|
||||||
|
|
||||||
|
this->Mouse.x = -1;
|
||||||
|
this->Mouse.y = -1;
|
||||||
|
this->Mouse.Button = 0;
|
||||||
|
this->Mouse.ButtonState = MouseButtonState::MOUSE_BUTTON_UP;
|
||||||
|
|
||||||
|
this->Flags = 0;
|
||||||
|
|
||||||
|
this->Valid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// for keyboard
|
||||||
|
struct {
|
||||||
|
KeyNumType Key;
|
||||||
|
char ASCII;
|
||||||
|
bool Shift;
|
||||||
|
bool Alt;
|
||||||
|
bool Control;
|
||||||
|
bool CapsLock;
|
||||||
|
} Keyboard;
|
||||||
|
|
||||||
|
// for mouse
|
||||||
|
struct {
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
unsigned short Button;
|
||||||
|
MouseButtonState ButtonState;
|
||||||
|
} Mouse;
|
||||||
|
|
||||||
|
// for cascading functions
|
||||||
|
unsigned short Flags;
|
||||||
|
|
||||||
|
EventMessage( KeyNumType key, char asciis, bool shift, bool alt, bool control, bool capsLock );
|
||||||
|
EventMessage( int x, int y, unsigned short button = KN_LMOUSE, MouseButtonState buttonState = MouseButtonState::MOUSE_BUTTON_DOWN );
|
||||||
|
|
||||||
|
void Key_Flags(KeyNumType& key, int& flags);
|
||||||
|
private:
|
||||||
|
void Clear() {
|
||||||
|
this->Keyboard.Key = KN_NONE;
|
||||||
|
this->Keyboard.Shift = false;
|
||||||
|
this->Keyboard.Alt = false;
|
||||||
|
this->Keyboard.Control = false;
|
||||||
|
this->Keyboard.CapsLock = false;
|
||||||
|
|
||||||
|
this->Mouse.x = -1;
|
||||||
|
this->Mouse.y = -1;
|
||||||
|
this->Mouse.Button = 0;
|
||||||
|
this->Mouse.ButtonState = MouseButtonState::MOUSE_BUTTON_UP;
|
||||||
|
|
||||||
|
this->Flags = 0;
|
||||||
|
|
||||||
|
this->Valid = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class EventQueueClass {
|
||||||
|
public:
|
||||||
|
int Get_Mouse_X() const { return UserInput.Mouse.X; }
|
||||||
|
int Get_Mouse_Y() const { return UserInput.Mouse.Y; }
|
||||||
|
|
||||||
|
void Clear();
|
||||||
|
void Put(EventMessage input);
|
||||||
|
bool Check() const;
|
||||||
|
EventMessage Get();
|
||||||
|
char EventQueueClass::Get_ASCII();
|
||||||
|
|
||||||
|
private:
|
||||||
|
const int MaxCapacity = 100;
|
||||||
|
|
||||||
|
std::queue< EventMessage > eventQueue;
|
||||||
|
|
||||||
|
bool Is_Buffer_Full() const { return this->eventQueue.size() == MaxCapacity; }
|
||||||
|
bool Is_Buffer_Empty() const { return this->eventQueue.size() == 0; }
|
||||||
|
};
|
||||||
+194
-111
@@ -1,18 +1,60 @@
|
|||||||
#include "../FUNCTION.H"
|
#include "../function.h"
|
||||||
#include "UserInput.h"
|
#include "userinput.h"
|
||||||
|
|
||||||
extern KeyboardClass * Keyboard;
|
extern KeyboardClass* Keyboard;
|
||||||
|
|
||||||
|
std::map<KeyNumType, SDL_KeyCode> sdl_keyMapping_reverse;
|
||||||
|
|
||||||
|
UserInputClass::UserInputClass()
|
||||||
|
{
|
||||||
|
LastAction = InputAction::INPUT_ACTION_NONE;
|
||||||
|
|
||||||
|
// generate reverse keymapping
|
||||||
|
for (auto it = sdl_keyMapping.begin(); it != sdl_keyMapping.end(); it++)
|
||||||
|
{
|
||||||
|
sdl_keyMapping_reverse[it->second] = it->first;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UserInputClass::KeyboardState::Key_Down(KeyNumType key) const
|
||||||
|
{
|
||||||
|
auto sdl_Key = sdl_keyMapping_reverse.find(key);
|
||||||
|
if (sdl_Key != sdl_keyMapping_reverse.end())
|
||||||
|
{
|
||||||
|
const SDL_Scancode scanCode = SDL_GetScancodeFromKey(sdl_Key->second);
|
||||||
|
const Uint8* keyState = SDL_GetKeyboardState(NULL);
|
||||||
|
return (keyState[scanCode]);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UserInputClass::MouseState::Mouse_Down(KeyNumType key) const
|
||||||
|
{
|
||||||
|
// get mouse state, we are only interested in the buttons
|
||||||
|
const Uint32 MouseState = SDL_GetMouseState(NULL, NULL);
|
||||||
|
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case KN_LMOUSE:
|
||||||
|
return MouseState & SDL_BUTTON(SDL_BUTTON_LEFT);
|
||||||
|
break;
|
||||||
|
case KN_RMOUSE:
|
||||||
|
return MouseState & SDL_BUTTON(SDL_BUTTON_RIGHT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void UserInputClass::Process_Input(KeyNumType& key, int& flags)
|
void UserInputClass::Process_Input(KeyNumType& key, int& flags)
|
||||||
{
|
{
|
||||||
bool leftMouseProcessed = false;
|
bool leftMouseProcessed = false;
|
||||||
SDL_GetMouseState(&Mouse.X, &Mouse.Y);
|
|
||||||
|
const Uint32 MouseState = SDL_GetMouseState(&Mouse.X, &Mouse.Y);
|
||||||
|
|
||||||
|
flags = 0;
|
||||||
|
|
||||||
Keyboard->MouseQX = Mouse.X;
|
Keyboard->MouseQX = Mouse.X;
|
||||||
Keyboard->MouseQY = Mouse.Y;
|
Keyboard->MouseQY = Mouse.Y;
|
||||||
|
|
||||||
flags = 0;
|
|
||||||
|
|
||||||
static SDL_Event event;
|
static SDL_Event event;
|
||||||
memset(&event, 0, sizeof(SDL_Event));
|
memset(&event, 0, sizeof(SDL_Event));
|
||||||
|
|
||||||
@@ -21,119 +63,158 @@ void UserInputClass::Process_Input(KeyNumType& key, int& flags)
|
|||||||
|
|
||||||
switch (event.type)
|
switch (event.type)
|
||||||
{
|
{
|
||||||
case SDL_SYSWMEVENT:
|
case SDL_SYSWMEVENT:
|
||||||
if (event.syswm.msg->msg.win.msg == WM_DESTROY)
|
if (event.syswm.msg->msg.win.msg == WM_DESTROY)
|
||||||
{
|
|
||||||
Invalidate_Cached_Icons();
|
|
||||||
VisiblePage.Un_Init();
|
|
||||||
HiddenPage.Un_Init();
|
|
||||||
AllSurfaces.Release();
|
|
||||||
if (!InDebugger) Reset_Video_Mode();
|
|
||||||
|
|
||||||
PostQuitMessage(0);
|
|
||||||
|
|
||||||
switch (ReadyToQuit) {
|
|
||||||
case 1:
|
|
||||||
ReadyToQuit = 2;
|
|
||||||
break;
|
|
||||||
case 0:
|
|
||||||
ExitProcess(0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_MOUSEMOTION:
|
|
||||||
flags = GadgetClass::LEFTUP;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
|
||||||
if (event.button.button == SDL_BUTTON_LEFT) {
|
|
||||||
Mouse.Button_Left == MouseButtonState::MOUSE_BUTTON_DOWN;
|
|
||||||
|
|
||||||
key = KN_LMOUSE;
|
|
||||||
flags |= GadgetClass::LEFTPRESS;
|
|
||||||
|
|
||||||
Keyboard->Put_Element(KN_LMOUSE);
|
|
||||||
|
|
||||||
leftMouseProcessed = true;
|
|
||||||
numFramesLMouse++;
|
|
||||||
}
|
|
||||||
else if (event.button.button == SDL_BUTTON_RIGHT) {
|
|
||||||
Mouse.Button_Right == MouseButtonState::MOUSE_BUTTON_DOWN;
|
|
||||||
|
|
||||||
Keyboard->Put_Element(KN_RMOUSE);
|
|
||||||
|
|
||||||
key = KN_RMOUSE;
|
|
||||||
flags |= GadgetClass::RIGHTPRESS;
|
|
||||||
|
|
||||||
numFramesLMouse = 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_MOUSEBUTTONUP:
|
|
||||||
if (event.button.button == SDL_BUTTON_LEFT) {
|
|
||||||
Mouse.Button_Left == MouseButtonState::MOUSE_BUTTON_RELEASE;
|
|
||||||
flags &= GadgetClass::LEFTPRESS;
|
|
||||||
flags |= GadgetClass::LEFTRELEASE;
|
|
||||||
numFramesLMouse = 0;
|
|
||||||
}
|
|
||||||
else if (event.button.button == SDL_BUTTON_RIGHT) {
|
|
||||||
Mouse.Button_Right == MouseButtonState::MOUSE_BUTTON_RELEASE;
|
|
||||||
|
|
||||||
flags &= GadgetClass::RIGHTPRESS;
|
|
||||||
flags |= GadgetClass::RIGHTRELEASE;
|
|
||||||
numFramesLMouse = 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_KEYDOWN:
|
|
||||||
{
|
{
|
||||||
if (event.key.keysym.scancode == SDL_SCANCODE_GRAVE) {
|
Invalidate_Cached_Icons();
|
||||||
renderConsole = !renderConsole;
|
VisiblePage.Un_Init();
|
||||||
|
HiddenPage.Un_Init();
|
||||||
|
AllSurfaces.Release();
|
||||||
|
if (!InDebugger) Reset_Video_Mode();
|
||||||
|
|
||||||
if (renderConsole) {
|
PostQuitMessage(0);
|
||||||
ShowCursor(TRUE);
|
|
||||||
Hide_Mouse();
|
switch (ReadyToQuit) {
|
||||||
}
|
case 1:
|
||||||
else {
|
ReadyToQuit = 2;
|
||||||
ShowCursor(FALSE);
|
break;
|
||||||
Show_Mouse();
|
case 0:
|
||||||
}
|
ExitProcess(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int keyFlags = 0x00;
|
break;
|
||||||
if (state[SDL_SCANCODE_RSHIFT] || state[SDL_SCANCODE_LSHIFT]) {
|
|
||||||
KeyB.Shift = true;
|
|
||||||
keyFlags |= KN_SHIFT_BIT;
|
|
||||||
}
|
|
||||||
if (state[SDL_SCANCODE_RALT] || state[SDL_SCANCODE_LALT]) {
|
|
||||||
keyFlags |= KN_ALT_BIT;
|
|
||||||
KeyB.Alt = true;
|
|
||||||
}
|
|
||||||
if (state[SDL_SCANCODE_RCTRL] || state[SDL_SCANCODE_LCTRL]) {
|
|
||||||
keyFlags |= KN_CTRL_BIT;
|
|
||||||
KeyB.Control = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// handle match between SDL and internals (non-text keys)
|
/* Mouse is moving */
|
||||||
auto element = sdl_keyMapping.find((SDL_KeyCode)event.key.keysym.sym);
|
case SDL_MOUSEMOTION:
|
||||||
if (element != sdl_keyMapping.end())
|
if (!(MouseState & SDL_BUTTON(SDL_BUTTON_LEFT)))
|
||||||
{
|
{
|
||||||
Keyboard->Put_Element(element->second | keyFlags);
|
flags |= GadgetClass::LEFTUP;
|
||||||
KeyB.ASCII = element->second;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
|
if (event.button.button == SDL_BUTTON_LEFT) {
|
||||||
|
Mouse.Button_Left == MouseButtonState::MOUSE_BUTTON_DOWN;
|
||||||
|
|
||||||
|
key = KN_LMOUSE;
|
||||||
|
flags |= GadgetClass::LEFTPRESS;
|
||||||
|
|
||||||
|
EventQueue.Put(EventMessage(Mouse.X, Mouse.Y, KN_LMOUSE));
|
||||||
|
|
||||||
|
Keyboard->Put_Element(KN_LMOUSE);
|
||||||
|
|
||||||
|
leftMouseProcessed = true;
|
||||||
|
numFramesLMouse++;
|
||||||
|
|
||||||
|
// after first left-mouse down, abort handling any other SDL events
|
||||||
|
// because game might first need to switch into rubber band mode
|
||||||
|
if (numFramesLMouse == 1) return;
|
||||||
|
}
|
||||||
|
else if (event.button.button == SDL_BUTTON_RIGHT) {
|
||||||
|
Mouse.Button_Right == MouseButtonState::MOUSE_BUTTON_DOWN;
|
||||||
|
|
||||||
|
EventQueue.Put(EventMessage(Mouse.X, Mouse.Y, KN_RMOUSE));
|
||||||
|
|
||||||
|
Keyboard->Put_Element(KN_RMOUSE);
|
||||||
|
|
||||||
|
key = KN_RMOUSE;
|
||||||
|
flags |= GadgetClass::RIGHTPRESS;
|
||||||
|
|
||||||
|
numFramesLMouse = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDL_MOUSEBUTTONUP:
|
||||||
|
if (event.button.button == SDL_BUTTON_LEFT) {
|
||||||
|
Mouse.Button_Left == MouseButtonState::MOUSE_BUTTON_RELEASE;
|
||||||
|
|
||||||
|
EventQueue.Put(EventMessage(Mouse.X, Mouse.Y, KN_LMOUSE, MouseButtonState::MOUSE_BUTTON_RELEASE));
|
||||||
|
|
||||||
|
flags |= GadgetClass::LEFTRELEASE;
|
||||||
|
numFramesLMouse = 0;
|
||||||
|
}
|
||||||
|
else if (event.button.button == SDL_BUTTON_RIGHT) {
|
||||||
|
Mouse.Button_Right == MouseButtonState::MOUSE_BUTTON_RELEASE;
|
||||||
|
|
||||||
|
EventQueue.Put(EventMessage(Mouse.X, Mouse.Y, KN_RMOUSE, MouseButtonState::MOUSE_BUTTON_RELEASE));
|
||||||
|
|
||||||
|
flags |= GadgetClass::RIGHTRELEASE;
|
||||||
|
numFramesLMouse = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Keyboard key lifted up
|
||||||
|
case SDL_KEYUP:
|
||||||
|
flags |= GadgetClass::KEYBOARD;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Keyboard key pressed down
|
||||||
|
case SDL_KEYDOWN:
|
||||||
|
{
|
||||||
|
if (event.key.keysym.scancode == SDL_SCANCODE_GRAVE) {
|
||||||
|
renderConsole = !renderConsole;
|
||||||
|
|
||||||
|
if (renderConsole) {
|
||||||
|
ShowCursor(TRUE);
|
||||||
|
Hide_Mouse();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ShowCursor(FALSE);
|
||||||
|
Show_Mouse();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_TEXTINPUT:
|
|
||||||
// limit to range 0-255
|
flags |= GadgetClass::KEYBOARD;
|
||||||
if (event.text.text[0] == ( event.text.text[0] & 0xFF ) )
|
|
||||||
{
|
int keyFlags = 0x00;
|
||||||
KeyB.ASCII = (char)event.text.text[0];
|
KeyB.Shift = false;
|
||||||
}
|
KeyB.Alt = false;
|
||||||
|
KeyB.Control = false;
|
||||||
|
KeyB.CapsLock = false;
|
||||||
|
|
||||||
|
if (state[SDL_SCANCODE_RSHIFT] || state[SDL_SCANCODE_LSHIFT]) {
|
||||||
|
KeyB.Shift = true;
|
||||||
|
keyFlags |= KN_SHIFT_BIT;
|
||||||
|
}
|
||||||
|
if (state[SDL_SCANCODE_RALT] || state[SDL_SCANCODE_LALT]) {
|
||||||
|
keyFlags |= KN_ALT_BIT;
|
||||||
|
KeyB.Alt = true;
|
||||||
|
}
|
||||||
|
if (state[SDL_SCANCODE_RCTRL] || state[SDL_SCANCODE_LCTRL]) {
|
||||||
|
keyFlags |= KN_CTRL_BIT;
|
||||||
|
KeyB.Control = true;
|
||||||
|
}
|
||||||
|
if (state[SDL_SCANCODE_CAPSLOCK]) {
|
||||||
|
keyFlags |= KN_CAPSLOCK_BIT;
|
||||||
|
KeyB.CapsLock = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle match between SDL and internals ( non-text keys )
|
||||||
|
auto element = sdl_keyMapping.find((SDL_KeyCode)event.key.keysym.sym);
|
||||||
|
if (element != sdl_keyMapping.end())
|
||||||
|
{
|
||||||
|
//EventQueue.Put( element->second | keyFlags );
|
||||||
|
EventQueue.Put(EventMessage((KeyNumType)element->second, element->second, KeyB.Shift, KeyB.Alt, KeyB.Control, KeyB.CapsLock));
|
||||||
|
|
||||||
|
Keyboard->Put_Element(element->second | keyFlags);
|
||||||
|
|
||||||
|
KeyB.LastKey = element->first;
|
||||||
|
KeyB.ASCII = 0x0;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SDL_TEXTINPUT:
|
||||||
|
// limit to range 0-255
|
||||||
|
if (event.text.text[0] == (event.text.text[0] & 0xFF))
|
||||||
|
{
|
||||||
|
KeyB.ASCII = (char)event.text.text[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Debug_Map || renderConsole)
|
if (Debug_Map || renderConsole)
|
||||||
@@ -145,6 +226,8 @@ void UserInputClass::Process_Input(KeyNumType& key, int& flags)
|
|||||||
if (!leftMouseProcessed && numFramesLMouse != 0)
|
if (!leftMouseProcessed && numFramesLMouse != 0)
|
||||||
{
|
{
|
||||||
Mouse.Button_Left == MouseButtonState::MOUSE_BUTTON_HOLD;
|
Mouse.Button_Left == MouseButtonState::MOUSE_BUTTON_HOLD;
|
||||||
flags = GadgetClass::LEFTHELD;
|
flags |= GadgetClass::LEFTHELD;
|
||||||
|
|
||||||
|
EventQueue.Put(EventMessage(Mouse.X, Mouse.Y, KN_LMOUSE, MouseButtonState::MOUSE_BUTTON_HOLD));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
#ifndef USERINPUT_H
|
#pragma once
|
||||||
#define USERINPUT_H
|
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <SDL_syswm.h>
|
#include <SDL_syswm.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <queue>
|
||||||
|
|
||||||
#include "examples/imgui_impl_sdl.h"
|
#include "examples/imgui_impl_sdl.h"
|
||||||
|
|
||||||
@@ -86,65 +86,81 @@ std::map<SDL_KeyCode, KeyNumType> const sdl_keyMapping = {
|
|||||||
{ SDLK_DOWN, KN_DOWN },
|
{ SDLK_DOWN, KN_DOWN },
|
||||||
{ SDLK_LEFT, KN_LEFT },
|
{ SDLK_LEFT, KN_LEFT },
|
||||||
{ SDLK_RIGHT, KN_RIGHT },
|
{ SDLK_RIGHT, KN_RIGHT },
|
||||||
|
|
||||||
|
{ SDLK_LALT, KN_LALT },
|
||||||
|
{ SDLK_RALT, KN_RALT },
|
||||||
|
{ SDLK_LCTRL, KN_LCTRL },
|
||||||
|
{ SDLK_RCTRL, KN_RCTRL },
|
||||||
|
{ SDLK_LSHIFT, KN_LSHIFT },
|
||||||
|
{ SDLK_RSHIFT, KN_RSHIFT },
|
||||||
};
|
};
|
||||||
|
extern std::map<KeyNumType, SDL_KeyCode> sdl_keyMapping_reverse;
|
||||||
|
|
||||||
|
const int USERINPUT_SHIFT_BIT = 0x100;
|
||||||
|
const int USERINPUT_CTRL_BIT = 0x200;
|
||||||
|
const int USERINPUT_ALT_BIT = 0x400;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
MOUSE_BUTTON_UP,
|
||||||
|
MOUSE_BUTTON_DOWN,
|
||||||
|
MOUSE_BUTTON_HOLD,
|
||||||
|
MOUSE_BUTTON_RELEASE,
|
||||||
|
} MouseButtonState;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
INPUT_ACTION_NONE,
|
||||||
|
INPUT_ACTION_KEYBOARD,
|
||||||
|
INPUT_ACTION_MOUSE,
|
||||||
|
} InputAction;
|
||||||
|
|
||||||
class UserInputClass
|
class UserInputClass
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
UserInputClass();
|
||||||
|
void UserInputClass::Process_Input(KeyNumType& key = g_globalKeyNumType, int& flags = g_globalKeyFlags);
|
||||||
|
|
||||||
|
InputAction LastAction;
|
||||||
|
|
||||||
|
class KeyboardState {
|
||||||
public:
|
public:
|
||||||
typedef enum {
|
SDL_KeyCode LastKey;
|
||||||
MOUSE_BUTTON_UP,
|
char ASCII;
|
||||||
MOUSE_BUTTON_DOWN,
|
|
||||||
MOUSE_BUTTON_HOLD,
|
|
||||||
MOUSE_BUTTON_RELEASE,
|
|
||||||
} MouseButtonState;
|
|
||||||
|
|
||||||
typedef enum {
|
bool Shift;
|
||||||
INPUT_ACTION_NONE,
|
bool Control;
|
||||||
INPUT_ACTION_KEYBOARD,
|
bool Alt;
|
||||||
INPUT_ACTION_MOUSE,
|
bool CapsLock;
|
||||||
} InputAction;
|
|
||||||
|
|
||||||
void UserInputClass::Process_Input(KeyNumType& key = g_globalKeyNumType, int& flags = g_globalKeyFlags);
|
bool Key_Down(KeyNumType key) const;
|
||||||
|
|
||||||
InputAction LastAction;
|
void ResetState() {
|
||||||
|
this->Shift = false;
|
||||||
|
this->Control = false;
|
||||||
|
this->Alt = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class KeyboardState {
|
KeyboardState KeyB;
|
||||||
public:
|
|
||||||
SDL_KeyCode LastKey;
|
|
||||||
char ASCII;
|
|
||||||
|
|
||||||
bool Shift;
|
class MouseState {
|
||||||
bool Control;
|
public:
|
||||||
bool Alt;
|
int X;
|
||||||
|
int Y;
|
||||||
|
|
||||||
void ResetState() {
|
MouseButtonState Button_Left;
|
||||||
this->Shift = false;
|
MouseButtonState Button_Middle;
|
||||||
this->Control = false;
|
MouseButtonState Button_Right;
|
||||||
this->Alt = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
KeyboardState KeyB;
|
bool UserInputClass::MouseState::Mouse_Down(KeyNumType key) const;
|
||||||
|
|
||||||
class MouseState {
|
void ResetState() {
|
||||||
public:
|
this->Button_Left = MouseButtonState::MOUSE_BUTTON_UP;
|
||||||
int X;
|
this->Button_Middle = MouseButtonState::MOUSE_BUTTON_UP;
|
||||||
int Y;
|
this->Button_Right = MouseButtonState::MOUSE_BUTTON_UP;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
MouseButtonState Button_Left;
|
MouseState Mouse;
|
||||||
MouseButtonState Button_Middle;
|
private:
|
||||||
MouseButtonState Button_Right;
|
int numFramesLMouse = 0;
|
||||||
|
|
||||||
void ResetState() {
|
|
||||||
this->Button_Left = MouseButtonState::MOUSE_BUTTON_UP;
|
|
||||||
this->Button_Middle = MouseButtonState::MOUSE_BUTTON_UP;
|
|
||||||
this->Button_Right = MouseButtonState::MOUSE_BUTTON_UP;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
MouseState Mouse;
|
|
||||||
private:
|
|
||||||
int numFramesLMouse = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -372,7 +372,7 @@ bool WWKeyboardClass::Down(unsigned short key)
|
|||||||
return g_globalKeyFlags & GadgetClass::RIGHTPRESS;
|
return g_globalKeyFlags & GadgetClass::RIGHTPRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(GetAsyncKeyState(key & 0xFF) == 0 ? false : true);
|
return UserInput.KeyB.Key_Down((KeyNumType)key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+113
-108
@@ -523,121 +523,126 @@ typedef enum KeyASCIIType {
|
|||||||
|
|
||||||
|
|
||||||
typedef enum KeyNumType {
|
typedef enum KeyNumType {
|
||||||
KN_NONE = 0,
|
KN_NONE = 0,
|
||||||
|
|
||||||
KN_0 = VK_0,
|
KN_0,
|
||||||
KN_1 = VK_1,
|
KN_1,
|
||||||
KN_2 = VK_2,
|
KN_2,
|
||||||
KN_3 = VK_3,
|
KN_3,
|
||||||
KN_4 = VK_4,
|
KN_4,
|
||||||
KN_5 = VK_5,
|
KN_5,
|
||||||
KN_6 = VK_6,
|
KN_6,
|
||||||
KN_7 = VK_7,
|
KN_7,
|
||||||
KN_8 = VK_8,
|
KN_8,
|
||||||
KN_9 = VK_9,
|
KN_9,
|
||||||
KN_A = VK_A,
|
KN_A,
|
||||||
KN_B = VK_B,
|
KN_B,
|
||||||
KN_BACKSLASH = VK_NONE_DC,
|
KN_C,
|
||||||
KN_BACKSPACE = VK_BACK,
|
KN_D,
|
||||||
KN_C = VK_C,
|
KN_E,
|
||||||
KN_CAPSLOCK = VK_CAPITAL,
|
KN_F,
|
||||||
KN_CENTER = VK_CLEAR,
|
KN_G,
|
||||||
KN_COMMA = VK_NONE_BC,
|
KN_H,
|
||||||
KN_D = VK_D,
|
KN_I,
|
||||||
KN_DELETE = VK_DELETE,
|
KN_J,
|
||||||
KN_DOWN = VK_DOWN,
|
KN_K,
|
||||||
KN_DOWNLEFT = VK_END,
|
KN_L,
|
||||||
KN_DOWNRIGHT = VK_NEXT,
|
KN_M,
|
||||||
KN_E = VK_E,
|
KN_N,
|
||||||
KN_END = VK_END,
|
KN_O,
|
||||||
KN_EQUAL = VK_NONE_BB,
|
KN_P,
|
||||||
KN_ESC = VK_ESCAPE,
|
KN_Q,
|
||||||
KN_E_DELETE = VK_DELETE,
|
KN_R,
|
||||||
KN_E_DOWN = VK_NUMPAD2,
|
KN_S,
|
||||||
KN_E_END = VK_NUMPAD1,
|
KN_T,
|
||||||
KN_E_HOME = VK_NUMPAD7,
|
KN_U,
|
||||||
KN_E_INSERT = VK_INSERT,
|
KN_V,
|
||||||
KN_E_LEFT = VK_NUMPAD4,
|
KN_W,
|
||||||
KN_E_PGDN = VK_NUMPAD3,
|
KN_X,
|
||||||
KN_E_PGUP = VK_NUMPAD9,
|
KN_Y,
|
||||||
KN_E_RIGHT = VK_NUMPAD6,
|
KN_Z,
|
||||||
KN_E_UP = VK_NUMPAD8,
|
|
||||||
KN_F = VK_F,
|
KN_BACKSLASH,
|
||||||
KN_F1 = VK_F1,
|
KN_BACKSPACE,
|
||||||
KN_F10 = 67,
|
KN_CAPSLOCK,
|
||||||
KN_F11 = 68,
|
KN_CENTER,
|
||||||
KN_F12 = 69,
|
KN_COMMA,
|
||||||
KN_F2 = 59,
|
KN_DELETE,
|
||||||
KN_F3 = 60,
|
KN_DOWN,
|
||||||
KN_F4 = 61,
|
KN_DOWNLEFT,
|
||||||
KN_F5 = 62,
|
KN_DOWNRIGHT,
|
||||||
KN_F6 = 63,
|
KN_END,
|
||||||
KN_F7 = 64,
|
KN_EQUAL,
|
||||||
KN_F8 = 65,
|
KN_ESC,
|
||||||
KN_F9 = 66,
|
KN_E_DELETE,
|
||||||
KN_G = VK_G,
|
KN_E_DOWN,
|
||||||
KN_GRAVE = VK_NONE_C0,
|
KN_E_END,
|
||||||
KN_H = VK_H,
|
KN_E_HOME,
|
||||||
KN_HOME = VK_HOME,
|
KN_E_INSERT,
|
||||||
KN_I = VK_I,
|
KN_E_LEFT,
|
||||||
KN_INSERT = VK_INSERT,
|
KN_E_PGDN,
|
||||||
KN_J = VK_J,
|
KN_E_PGUP,
|
||||||
KN_K = VK_K,
|
KN_E_RIGHT,
|
||||||
KN_KEYPAD_ASTERISK= VK_MULTIPLY,
|
KN_E_UP,
|
||||||
KN_KEYPAD_MINUS = VK_SUBTRACT,
|
KN_GRAVE,
|
||||||
KN_KEYPAD_PLUS = VK_ADD,
|
KN_HOME,
|
||||||
KN_KEYPAD_RETURN = VK_RETURN,
|
KN_INSERT,
|
||||||
KN_KEYPAD_SLASH = VK_DIVIDE,
|
KN_KEYPAD_ASTERISK,
|
||||||
KN_L = VK_L,
|
KN_KEYPAD_MINUS,
|
||||||
KN_LALT = VK_MENU,
|
KN_KEYPAD_PLUS,
|
||||||
KN_LBRACKET = VK_NONE_DB,
|
KN_KEYPAD_RETURN,
|
||||||
KN_LCTRL = VK_CONTROL,
|
KN_KEYPAD_SLASH,
|
||||||
KN_LEFT = VK_LEFT,
|
KN_MINUS,
|
||||||
KN_LMOUSE = VK_LBUTTON,
|
KN_NUMLOCK,
|
||||||
KN_LSHIFT = VK_SHIFT,
|
KN_PAUSE,
|
||||||
KN_M = VK_M,
|
KN_PERIOD,
|
||||||
KN_MINUS = VK_NONE_BD,
|
KN_PGDN,
|
||||||
KN_N = VK_N,
|
KN_PGUP,
|
||||||
KN_NUMLOCK = VK_NUMLOCK,
|
KN_PRNTSCRN,
|
||||||
KN_O = VK_O,
|
KN_SCROLLLOCK,
|
||||||
KN_P = VK_P,
|
KN_SEMICOLON,
|
||||||
KN_PAUSE = VK_PAUSE,
|
KN_SLASH,
|
||||||
KN_PERIOD = VK_NONE_BE,
|
KN_SPACE,
|
||||||
KN_PGDN = VK_NEXT,
|
KN_SQUOTE,
|
||||||
KN_PGUP = VK_PRIOR,
|
KN_TAB,
|
||||||
KN_PRNTSCRN = VK_PRINT,
|
KN_UP,
|
||||||
KN_Q = VK_Q,
|
KN_UPLEFT,
|
||||||
KN_R = VK_R,
|
KN_UPRIGHT,
|
||||||
KN_RALT = VK_MENU,
|
|
||||||
KN_RBRACKET = VK_NONE_DD,
|
KN_LALT,
|
||||||
KN_RCTRL = VK_CONTROL,
|
KN_LBRACKET,
|
||||||
KN_RETURN = VK_RETURN,
|
KN_LCTRL,
|
||||||
KN_RIGHT = VK_RIGHT,
|
KN_LEFT,
|
||||||
KN_RMOUSE = VK_RBUTTON,
|
KN_LMOUSE,
|
||||||
KN_RSHIFT = VK_SHIFT,
|
KN_LSHIFT,
|
||||||
KN_S = VK_S,
|
|
||||||
KN_SCROLLLOCK = VK_SCROLL,
|
KN_RALT,
|
||||||
KN_SEMICOLON = VK_NONE_BA,
|
KN_RBRACKET,
|
||||||
KN_SLASH = VK_NONE_BF,
|
KN_RCTRL,
|
||||||
KN_SPACE = VK_SPACE,
|
KN_RETURN,
|
||||||
KN_SQUOTE = VK_NONE_DE,
|
KN_RIGHT,
|
||||||
KN_T = VK_T,
|
KN_RMOUSE,
|
||||||
KN_TAB = VK_TAB,
|
KN_RSHIFT,
|
||||||
KN_U = VK_U,
|
|
||||||
KN_UP = VK_UP,
|
KN_F1,
|
||||||
KN_UPLEFT = VK_HOME,
|
KN_F2,
|
||||||
KN_UPRIGHT = VK_PRIOR,
|
KN_F3,
|
||||||
KN_V = VK_V,
|
KN_F4,
|
||||||
KN_W = VK_W,
|
KN_F5,
|
||||||
KN_X = VK_X,
|
KN_F6,
|
||||||
KN_Y = VK_Y,
|
KN_F7,
|
||||||
KN_Z = VK_Z,
|
KN_F8,
|
||||||
|
KN_F9,
|
||||||
|
KN_F10,
|
||||||
|
KN_F11,
|
||||||
|
KN_F12,
|
||||||
|
|
||||||
KN_SHIFT_BIT = WWKEY_SHIFT_BIT,
|
KN_SHIFT_BIT = WWKEY_SHIFT_BIT,
|
||||||
KN_CTRL_BIT = WWKEY_CTRL_BIT,
|
KN_CTRL_BIT = WWKEY_CTRL_BIT,
|
||||||
KN_ALT_BIT = WWKEY_ALT_BIT,
|
KN_ALT_BIT = WWKEY_ALT_BIT,
|
||||||
KN_RLSE_BIT = WWKEY_RLS_BIT,
|
KN_RLSE_BIT = WWKEY_RLS_BIT,
|
||||||
KN_BUTTON = WWKEY_BTN_BIT,
|
KN_BUTTON = WWKEY_BTN_BIT,
|
||||||
|
KN_CAPSLOCK_BIT = WWKEY_SHIFT_BIT,
|
||||||
} KeyNumType;
|
} KeyNumType;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+7376
-4057
File diff suppressed because it is too large
Load Diff
+117
-1
@@ -1,4 +1,4 @@
|
|||||||
// MapScript.h
|
// mapscript.h
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef MAPSCRIPT_H
|
#ifndef MAPSCRIPT_H
|
||||||
@@ -15,11 +15,22 @@ extern "C" {
|
|||||||
// Object Cache Item
|
// Object Cache Item
|
||||||
// Stores an id lookup table
|
// Stores an id lookup table
|
||||||
struct MapScriptObject {
|
struct MapScriptObject {
|
||||||
|
|
||||||
|
int UID; // The UID of the object (to prevent ID collisions)
|
||||||
|
|
||||||
int ID=-1; // The object's "Global ID"
|
int ID=-1; // The object's "Global ID"
|
||||||
int classIndex=-1; // The object's "Global ID"
|
int classIndex=-1; // The object's "Global ID"
|
||||||
RTTIType RTTI; // The type of object
|
RTTIType RTTI; // The type of object
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Stores defaults of object attributes whenever they are changed for the first time (for later restoration)
|
||||||
|
struct MapScriptDefaultObjectAttribute {
|
||||||
|
RTTIType RTTI; // The type of object
|
||||||
|
int ID=-1; // The index of the object in its heap
|
||||||
|
int attribute;
|
||||||
|
int value;
|
||||||
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// MapScript Class
|
// MapScript Class
|
||||||
@@ -27,6 +38,7 @@ struct MapScriptObject {
|
|||||||
class MapScript {
|
class MapScript {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
int cUID = 0;
|
||||||
|
|
||||||
~MapScript() { Deinit(); };
|
~MapScript() { Deinit(); };
|
||||||
|
|
||||||
@@ -34,15 +46,114 @@ public:
|
|||||||
bool Init(const char* mapName);
|
bool Init(const char* mapName);
|
||||||
void Deinit();
|
void Deinit();
|
||||||
|
|
||||||
|
MapScriptObject* CreateCacheObject();
|
||||||
|
|
||||||
void CallFunction(const char* functionName);
|
void CallFunction(const char* functionName);
|
||||||
void SetLuaPath(const char* input_path);
|
void SetLuaPath(const char* input_path);
|
||||||
|
|
||||||
std::vector<MapScriptObject*> ObjectCache;
|
std::vector<MapScriptObject*> ObjectCache;
|
||||||
|
std::vector<MapScriptDefaultObjectAttribute*> DefaultObjectTypeAttributeCache;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
lua_State* L;
|
lua_State* L;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Enums
|
||||||
|
typedef enum MapScriptObjectAttributeType : char {
|
||||||
|
|
||||||
|
// Techno types
|
||||||
|
ATTRIBUTE_TYPE=0,
|
||||||
|
ATTRIBUTE_STRENGTH,
|
||||||
|
ATTRIBUTE_MAX_STRENGTH,
|
||||||
|
ATTRIBUTE_COST,
|
||||||
|
ATTRIBUTE_SIGHT_RANGE,
|
||||||
|
ATTRIBUTE_TECH_LEVEL,
|
||||||
|
ATTRIBUTE_ARMOR,
|
||||||
|
ATTRIBUTE_PRIMARY_WEAPON,
|
||||||
|
ATTRIBUTE_SECONDARY_WEAPON,
|
||||||
|
ATTRIBUTE_SPEED,
|
||||||
|
ATTRIBUTE_MAX_SPEED,
|
||||||
|
ATTRIBUTE_MAX_AMMO,
|
||||||
|
ATTRIBUTE_ROTATION_SPEED,
|
||||||
|
ATTRIBUTE_CRUSHABLE,
|
||||||
|
ATTRIBUTE_STEALTHY,
|
||||||
|
ATTRIBUTE_SELECTABLE,
|
||||||
|
ATTRIBUTE_LEGAL_TARGET,
|
||||||
|
ATTRIBUTE_REPAIRABLE,
|
||||||
|
ATTRIBUTE_SELF_HEALING,
|
||||||
|
ATTRIBUTE_EXPLODES,
|
||||||
|
ATTRIBUTE_HAS_CREW,
|
||||||
|
ATTRIBUTE_MAX_PASSENGERS,
|
||||||
|
ATTRIBUTE_IS_REPAIRING,
|
||||||
|
|
||||||
|
// Building Specific
|
||||||
|
ATTRIBUTE_CAPACITY,
|
||||||
|
ATTRIBUTE_POWER,
|
||||||
|
ATTRIBUTE_SELLABLE,
|
||||||
|
|
||||||
|
// Unit Specific
|
||||||
|
ATTRIBUTE_CRATE_GOODIE,
|
||||||
|
ATTRIBUTE_CRUSHER,
|
||||||
|
ATTRIBUTE_HARVEST,
|
||||||
|
ATTRIBUTE_RADAR_EQUIPPED,
|
||||||
|
ATTRIBUTE_JAMMER,
|
||||||
|
ATTRIBUTE_GAPPER,
|
||||||
|
|
||||||
|
// Infantry Specific
|
||||||
|
ATTRIBUTE_FEMALE,
|
||||||
|
ATTRIBUTE_CAPTURE,
|
||||||
|
ATTRIBUTE_FRAIDY_CAT,
|
||||||
|
ATTRIBUTE_CIVILIAN,
|
||||||
|
ATTRIBUTE_BOMBER,
|
||||||
|
ATTRIBUTE_DOG
|
||||||
|
|
||||||
|
|
||||||
|
} MapScriptObjectAttributeType;
|
||||||
|
|
||||||
|
// Enums
|
||||||
|
typedef enum MapScriptHouseAttributeType : char {
|
||||||
|
|
||||||
|
// Techno types
|
||||||
|
HOUSE_ATTRIBUTE_IQ = 0,
|
||||||
|
HOUSE_ATTRIBUTE_TECH_LEVEL,
|
||||||
|
HOUSE_ATTRIBUTE_IS_HUMAN,
|
||||||
|
HOUSE_ATTRIBUTE_FIREPOWER_BIAS,
|
||||||
|
HOUSE_ATTRIBUTE_GROUNDSPEED_BIAS,
|
||||||
|
HOUSE_ATTRIBUTE_ARMOR_BIAS,
|
||||||
|
HOUSE_ATTRIBUTE_ROF_BIAS,
|
||||||
|
HOUSE_ATTRIBUTE_COST_BIAS,
|
||||||
|
HOUSE_ATTRIBUTE_REPAIR_DELAY,
|
||||||
|
HOUSE_ATTRIBUTE_BUILD_DELAY,
|
||||||
|
HOUSE_ATTRIBUTE_STARTED,
|
||||||
|
HOUSE_ATTRIBUTE_ALERTED,
|
||||||
|
HOUSE_ATTRIBUTE_BASE_BUILDING,
|
||||||
|
HOUSE_ATTRIBUTE_DISCOVERED,
|
||||||
|
HOUSE_ATTRIBUTE_CAPACITY,
|
||||||
|
HOUSE_ATTRIBUTE_TIBERIUM,
|
||||||
|
HOUSE_ATTRIBUTE_CREDITS,
|
||||||
|
HOUSE_ATTRIBUTE_ALERT_TIMER,
|
||||||
|
HOUSE_ATTRIBUTE_REPAIR_TIMER,
|
||||||
|
HOUSE_ATTRIBUTE_POINTS,
|
||||||
|
HOUSE_ATTRIBUTE_DESTROYED_BUILDINGS,
|
||||||
|
HOUSE_ATTRIBUTE_DESTROYED_VEHICLES,
|
||||||
|
HOUSE_ATTRIBUTE_DESTROYED_INFANTRY,
|
||||||
|
HOUSE_ATTRIBUTE_DESTROYED_AIRCRAFT,
|
||||||
|
HOUSE_ATTRIBUTE_DESTROYED_VESSELS,
|
||||||
|
HOUSE_ATTRIBUTE_CAPTURED_BUILDINGS,
|
||||||
|
HOUSE_ATTRIBUTE_CRATES,
|
||||||
|
HOUSE_ATTRIBUTE_BUILDING_FACTORIES,
|
||||||
|
HOUSE_ATTRIBUTE_UNIT_FACTORIES,
|
||||||
|
HOUSE_ATTRIBUTE_INFANTRY_FACTORIES,
|
||||||
|
HOUSE_ATTRIBUTE_AIRCRAFT_FACTORIES,
|
||||||
|
HOUSE_ATTRIBUTE_VESSEL_FACTORIES,
|
||||||
|
HOUSE_ATTRIBUTE_POWER,
|
||||||
|
HOUSE_ATTRIBUTE_DRAIN,
|
||||||
|
HOUSE_ATTRIBUTE_LAST_ATTACKER
|
||||||
|
|
||||||
|
} MapScriptHouseAttributeType;
|
||||||
|
|
||||||
// Non-Class-Functions
|
// Non-Class-Functions
|
||||||
bool Script_SetObjectTrigger(int input_object_id, TriggerClass* input_trigger);
|
bool Script_SetObjectTrigger(int input_object_id, TriggerClass* input_trigger);
|
||||||
ObjectClass* Script_GetCacheObject(int input_object_id);
|
ObjectClass* Script_GetCacheObject(int input_object_id);
|
||||||
@@ -53,4 +164,9 @@ int Script_AircraftIndexFromID(int input_object_id);
|
|||||||
int Script_InfantryIndexFromID(int input_object_id);
|
int Script_InfantryIndexFromID(int input_object_id);
|
||||||
int Script_VesselIndexFromID(int input_object_id);
|
int Script_VesselIndexFromID(int input_object_id);
|
||||||
|
|
||||||
|
static int Script_SetObjectTypeAttribute(lua_State* L, TechnoTypeClass* this_type_class, MapScriptObjectAttributeType attribute_type);
|
||||||
|
static int Script_GetObjectTypeAttribute(lua_State* L, TechnoTypeClass* this_type_class, MapScriptObjectAttributeType attribute_type);
|
||||||
|
|
||||||
|
void Script_CacheDefaultObjectTypeAttribute(RTTIType input_rtti, int input_id, MapScriptObjectAttributeType input_attribute, int input_value);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -591,6 +591,7 @@ void OptionsClass::Load_Settings(void)
|
|||||||
SlowPalette = ini.Get_Bool(OPTIONS, "SlowPalette", SlowPalette);
|
SlowPalette = ini.Get_Bool(OPTIONS, "SlowPalette", SlowPalette);
|
||||||
IsPaletteScroll = ini.Get_Bool(OPTIONS, "PaletteScroll", IsPaletteScroll);
|
IsPaletteScroll = ini.Get_Bool(OPTIONS, "PaletteScroll", IsPaletteScroll);
|
||||||
|
|
||||||
|
/*
|
||||||
KeyForceMove1 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyForceMove1", KeyForceMove1);
|
KeyForceMove1 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyForceMove1", KeyForceMove1);
|
||||||
KeyForceMove2 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyForceMove2", KeyForceMove2);
|
KeyForceMove2 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyForceMove2", KeyForceMove2);
|
||||||
KeyForceAttack1 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyForceAttack1", KeyForceAttack1);
|
KeyForceAttack1 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyForceAttack1", KeyForceAttack1);
|
||||||
@@ -641,7 +642,6 @@ void OptionsClass::Load_Settings(void)
|
|||||||
KeyTeam9 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyTeam9", KeyTeam9);
|
KeyTeam9 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyTeam9", KeyTeam9);
|
||||||
KeyTeam10 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyTeam10", KeyTeam10);
|
KeyTeam10 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyTeam10", KeyTeam10);
|
||||||
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
KeyForceMove1 = (KeyNumType)(KeyForceMove1 & ~WWKEY_VK_BIT);
|
KeyForceMove1 = (KeyNumType)(KeyForceMove1 & ~WWKEY_VK_BIT);
|
||||||
KeyForceMove2 = (KeyNumType)(KeyForceMove2 & ~WWKEY_VK_BIT);
|
KeyForceMove2 = (KeyNumType)(KeyForceMove2 & ~WWKEY_VK_BIT);
|
||||||
@@ -693,6 +693,7 @@ void OptionsClass::Load_Settings(void)
|
|||||||
KeyTeam9 = (KeyNumType)(KeyTeam9 & ~WWKEY_VK_BIT);
|
KeyTeam9 = (KeyNumType)(KeyTeam9 & ~WWKEY_VK_BIT);
|
||||||
KeyTeam10 = (KeyNumType)(KeyTeam10 & ~WWKEY_VK_BIT);
|
KeyTeam10 = (KeyNumType)(KeyTeam10 & ~WWKEY_VK_BIT);
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+54
-45
@@ -44,11 +44,11 @@
|
|||||||
#include "function.h"
|
#include "function.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Points to the shape to use for the "desired" power level indicator.
|
** Points to the shape to use for the "desired" power level indicator.
|
||||||
*/
|
*/
|
||||||
void const * PowerClass::PowerShape;
|
void const* PowerClass::PowerShape;
|
||||||
void const * PowerClass::PowerBarShape;
|
void const* PowerClass::PowerBarShape;
|
||||||
|
|
||||||
PowerClass::PowerButtonClass PowerClass::PowerButton;
|
PowerClass::PowerButtonClass PowerClass::PowerButton;
|
||||||
|
|
||||||
@@ -137,8 +137,8 @@ void PowerClass::One_Time(void)
|
|||||||
RadarClass::One_Time();
|
RadarClass::One_Time();
|
||||||
PowerButton.X = ScreenWidth - (640 - (POWER_X * RESFACTOR));
|
PowerButton.X = ScreenWidth - (640 - (POWER_X * RESFACTOR));
|
||||||
PowerButton.Y = POWER_Y * RESFACTOR;
|
PowerButton.Y = POWER_Y * RESFACTOR;
|
||||||
PowerButton.Width = (POWER_WIDTH * RESFACTOR)-1;
|
PowerButton.Width = (POWER_WIDTH * RESFACTOR) - 1;
|
||||||
PowerButton.Height = ScreenHeight - ( POWER_Y * RESFACTOR ) ;// POWER_HEIGHT* RESFACTOR;
|
PowerButton.Height = ScreenHeight - (POWER_Y * RESFACTOR);// POWER_HEIGHT* RESFACTOR;
|
||||||
PowerShape = MFCD::Retrieve("POWER.SHP");
|
PowerShape = MFCD::Retrieve("POWER.SHP");
|
||||||
PowerBarShape = MFCD::Retrieve("POWERBAR.SHP");
|
PowerBarShape = MFCD::Retrieve("POWERBAR.SHP");
|
||||||
}
|
}
|
||||||
@@ -162,13 +162,14 @@ void PowerClass::One_Time(void)
|
|||||||
*=============================================================================================*/
|
*=============================================================================================*/
|
||||||
void PowerClass::Draw_It(bool complete)
|
void PowerClass::Draw_It(bool complete)
|
||||||
{
|
{
|
||||||
static int _modtable[]={
|
static int _modtable[] = {
|
||||||
0, -1, 0, 1, 0, -1, -2, -1, 0, 1, 2, 1 ,0
|
0, -1, 0, 1, 0, -1, -2, -1, 0, 1, 2, 1 ,0
|
||||||
};
|
};
|
||||||
|
|
||||||
// jmarshall - render the world before the power bar.
|
// jmarshall - render the world before the power bar.
|
||||||
RadarClass::Draw_It(complete);
|
RadarClass::Draw_It(complete);
|
||||||
// jmarshall end
|
// jmarshall end
|
||||||
|
|
||||||
{
|
{
|
||||||
BStart(BENCH_POWER);
|
BStart(BENCH_POWER);
|
||||||
|
|
||||||
@@ -176,7 +177,7 @@ void PowerClass::Draw_It(bool complete)
|
|||||||
if (Map.IsSidebarActive) {
|
if (Map.IsSidebarActive) {
|
||||||
IsToRedraw = false;
|
IsToRedraw = false;
|
||||||
ShapeFlags_Type flags = SHAPE_NORMAL;
|
ShapeFlags_Type flags = SHAPE_NORMAL;
|
||||||
void const * remap = NULL;
|
void const* remap = NULL;
|
||||||
|
|
||||||
if (FlashTimer > 1 && ((FlashTimer % 3) & 0x01) != 0) {
|
if (FlashTimer > 1 && ((FlashTimer % 3) & 0x01) != 0) {
|
||||||
flags = flags | SHAPE_FADING;
|
flags = flags | SHAPE_FADING;
|
||||||
@@ -190,25 +191,23 @@ void PowerClass::Draw_It(bool complete)
|
|||||||
|
|
||||||
int bottomOfBar = (88 * RESFACTOR) + 56;
|
int bottomOfBar = (88 * RESFACTOR) + 56;
|
||||||
|
|
||||||
while(bottomOfBar < PowerButton.Height + 34 )
|
while (bottomOfBar < PowerButton.Height + 42)
|
||||||
{
|
{
|
||||||
CC_Draw_Shape(PowerBarShape, 1, ScreenWidth - (640 - (240 * RESFACTOR)), bottomOfBar, WINDOW_MAIN, flags | SHAPE_NORMAL | SHAPE_WIN_REL, remap);
|
CC_Draw_Shape(PowerBarShape, 1, ScreenWidth - (640 - (240 * RESFACTOR)), bottomOfBar, WINDOW_MAIN, flags | SHAPE_NORMAL | SHAPE_WIN_REL, remap);
|
||||||
bottomOfBar += 8 * RESFACTOR;
|
bottomOfBar += 8 * RESFACTOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bottom = ( PowerButton.Y * RESFACTOR ) + PowerButton.Height;
|
int bottom = bottomOfBar + (28 * RESFACTOR);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Determine how much the power production exceeds or falls short
|
** Determine how much the power production exceeds or falls short
|
||||||
** of power demands.
|
** of power demands.
|
||||||
*/
|
*/
|
||||||
int power_height = (PowerHeight == DesiredPowerHeight) ? PowerHeight + (_modtable[PowerBounce] * PowerDir) : PowerHeight;
|
int power_height = (PowerHeight == DesiredPowerHeight) ? PowerHeight + (_modtable[PowerBounce] * PowerDir) : PowerHeight;
|
||||||
int drain_height = (DrainHeight == DesiredDrainHeight) ? DrainHeight + (_modtable[DrainBounce] * DrainDir) : DrainHeight;
|
int drain_height = (DrainHeight == DesiredDrainHeight) ? DrainHeight + (_modtable[DrainBounce] * DrainDir) : DrainHeight;
|
||||||
power_height = Bound(power_height, 0, PowerButton.Height - 2);
|
power_height = Bound(power_height, 0, PowerButton.Height - 2);
|
||||||
drain_height = Bound(drain_height, 0, PowerButton.Height - 2);
|
drain_height = Bound(drain_height, 0, PowerButton.Height - 2);
|
||||||
|
|
||||||
bottom -= (15 * RESFACTOR);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Draw the power output graphic on top of the power bar framework.
|
** Draw the power output graphic on top of the power bar framework.
|
||||||
*/
|
*/
|
||||||
@@ -233,23 +232,26 @@ void PowerClass::Draw_It(bool complete)
|
|||||||
** ST - 5/2/96 11:23AM
|
** ST - 5/2/96 11:23AM
|
||||||
*/
|
*/
|
||||||
|
|
||||||
power_height = (power_height*(76*RESFACTOR+1)) / (53*RESFACTOR+1);
|
power_height = (power_height * (76 * RESFACTOR + 1)) / (53 * RESFACTOR + 1);
|
||||||
drain_height = (drain_height*(76*RESFACTOR+1)) / (53*RESFACTOR+1);
|
drain_height = (drain_height * (76 * RESFACTOR + 1)) / (53 * RESFACTOR + 1);
|
||||||
|
|
||||||
//bottom = (175*RESFACTOR)+1;
|
//bottom = (175*RESFACTOR)+1;
|
||||||
LogicPage->Fill_Rect(ScreenWidth - (640 - (245*RESFACTOR)), bottom - power_height, ScreenWidth - (640 - (245*RESFACTOR+1)), bottom, color2 );
|
LogicPage->Fill_Rect(ScreenWidth - (640 - (245 * RESFACTOR)), bottom - power_height, ScreenWidth - (640 - (245 * RESFACTOR + 1)), bottom, color2);
|
||||||
LogicPage->Fill_Rect(ScreenWidth - (640 - (246*RESFACTOR)), bottom - power_height, ScreenWidth - (640 - (246*RESFACTOR+1)), bottom, color1 );
|
LogicPage->Fill_Rect(ScreenWidth - (640 - (246 * RESFACTOR)), bottom - power_height, ScreenWidth - (640 - (246 * RESFACTOR + 1)), bottom, color1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Draw the power drain threshold marker.
|
** Draw the power drain threshold marker.
|
||||||
*/
|
*/
|
||||||
CC_Draw_Shape(PowerShape, 0, ScreenWidth - (640 - (((POWER_X * RESFACTOR)) +RESFACTOR)), bottom - (drain_height + (2 * RESFACTOR)), WINDOW_MAIN, flags | SHAPE_NORMAL, remap);
|
if (PlayerPtr->Drain > 0)
|
||||||
|
{
|
||||||
|
CC_Draw_Shape(PowerShape, 0, ScreenWidth - (640 - (((POWER_X * RESFACTOR)) + RESFACTOR)), bottom - (drain_height + (2 * RESFACTOR)), WINDOW_MAIN, flags | SHAPE_NORMAL, remap);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
LogicPage->Unlock();
|
LogicPage->Unlock();
|
||||||
}
|
}
|
||||||
BEnd(BENCH_POWER);
|
BEnd(BENCH_POWER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -270,11 +272,11 @@ void PowerClass::Draw_It(bool complete)
|
|||||||
* 12/20/1994 JLB : Created. *
|
* 12/20/1994 JLB : Created. *
|
||||||
* 12/31/1994 JLB : Uses mouse coordinate parameters. *
|
* 12/31/1994 JLB : Uses mouse coordinate parameters. *
|
||||||
*=============================================================================================*/
|
*=============================================================================================*/
|
||||||
void PowerClass::AI(KeyNumType &input, int x, int y)
|
void PowerClass::AI(KeyNumType& input, int x, int y)
|
||||||
{
|
{
|
||||||
if (Map.IsSidebarActive /*IsActive*/) {
|
if (Map.IsSidebarActive /*IsActive*/) {
|
||||||
int olddrain = DrainHeight;
|
int olddrain = DrainHeight;
|
||||||
int oldpower = PowerHeight;
|
int oldpower = PowerHeight;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -283,13 +285,15 @@ void PowerClass::AI(KeyNumType &input, int x, int y)
|
|||||||
*/
|
*/
|
||||||
if (PlayerPtr->Power != RecordedPower) {
|
if (PlayerPtr->Power != RecordedPower) {
|
||||||
DesiredPowerHeight = Power_Height(PlayerPtr->Power);
|
DesiredPowerHeight = Power_Height(PlayerPtr->Power);
|
||||||
RecordedPower = PlayerPtr->Power;
|
RecordedPower = PlayerPtr->Power;
|
||||||
PowerBounce = 12;
|
PowerBounce = 12;
|
||||||
if (PowerHeight > DesiredPowerHeight) {
|
if (PowerHeight > DesiredPowerHeight) {
|
||||||
PowerDir = -1;
|
PowerDir = -1;
|
||||||
} else if (PowerHeight < DesiredPowerHeight) {
|
}
|
||||||
|
else if (PowerHeight < DesiredPowerHeight) {
|
||||||
PowerDir = 1;
|
PowerDir = 1;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
PowerBounce = 0;
|
PowerBounce = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -300,13 +304,15 @@ void PowerClass::AI(KeyNumType &input, int x, int y)
|
|||||||
*/
|
*/
|
||||||
if (PlayerPtr->Drain != RecordedDrain) {
|
if (PlayerPtr->Drain != RecordedDrain) {
|
||||||
DesiredDrainHeight = Power_Height(PlayerPtr->Drain);
|
DesiredDrainHeight = Power_Height(PlayerPtr->Drain);
|
||||||
RecordedDrain = PlayerPtr->Drain;
|
RecordedDrain = PlayerPtr->Drain;
|
||||||
DrainBounce = 12;
|
DrainBounce = 12;
|
||||||
if (DrainHeight > DesiredDrainHeight) {
|
if (DrainHeight > DesiredDrainHeight) {
|
||||||
DrainDir = -1;
|
DrainDir = -1;
|
||||||
} else if (DrainHeight < DesiredDrainHeight) {
|
}
|
||||||
|
else if (DrainHeight < DesiredDrainHeight) {
|
||||||
DrainDir = 1;
|
DrainDir = 1;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
DrainBounce = 0;
|
DrainBounce = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -315,7 +321,8 @@ void PowerClass::AI(KeyNumType &input, int x, int y)
|
|||||||
IsToRedraw = true;
|
IsToRedraw = true;
|
||||||
Flag_To_Redraw(false);
|
Flag_To_Redraw(false);
|
||||||
DrainBounce--;
|
DrainBounce--;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
/*
|
/*
|
||||||
** If we need to move the drain height then do so.
|
** If we need to move the drain height then do so.
|
||||||
*/
|
*/
|
||||||
@@ -328,7 +335,8 @@ void PowerClass::AI(KeyNumType &input, int x, int y)
|
|||||||
IsToRedraw = true;
|
IsToRedraw = true;
|
||||||
Flag_To_Redraw(false);
|
Flag_To_Redraw(false);
|
||||||
PowerBounce--;
|
PowerBounce--;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
/*
|
/*
|
||||||
** If we need to move the power height then do so.
|
** If we need to move the power height then do so.
|
||||||
*/
|
*/
|
||||||
@@ -345,7 +353,7 @@ void PowerClass::AI(KeyNumType &input, int x, int y)
|
|||||||
/*
|
/*
|
||||||
** Flag to redraw if the power bar flash effect has expired.
|
** Flag to redraw if the power bar flash effect has expired.
|
||||||
*/
|
*/
|
||||||
// if (FlashTimer == 1) {
|
// if (FlashTimer == 1) {
|
||||||
if (FlashTimer > 0) {
|
if (FlashTimer > 0) {
|
||||||
IsToRedraw = true;
|
IsToRedraw = true;
|
||||||
Flag_To_Redraw(false);
|
Flag_To_Redraw(false);
|
||||||
@@ -374,7 +382,7 @@ void PowerClass::AI(KeyNumType &input, int x, int y)
|
|||||||
* HISTORY: *
|
* HISTORY: *
|
||||||
* 06/01/1995 JLB : Created. *
|
* 06/01/1995 JLB : Created. *
|
||||||
*=============================================================================================*/
|
*=============================================================================================*/
|
||||||
void PowerClass::Refresh_Cells(CELL cell, short const * list)
|
void PowerClass::Refresh_Cells(CELL cell, short const* list)
|
||||||
{
|
{
|
||||||
if (*list == REFRESH_SIDEBAR) {
|
if (*list == REFRESH_SIDEBAR) {
|
||||||
IsToRedraw = true;
|
IsToRedraw = true;
|
||||||
@@ -398,16 +406,16 @@ void PowerClass::Refresh_Cells(CELL cell, short const * list)
|
|||||||
*=========================================================================*/
|
*=========================================================================*/
|
||||||
int PowerClass::Power_Height(int value)
|
int PowerClass::Power_Height(int value)
|
||||||
{
|
{
|
||||||
int num = value/ POWER_STEP_LEVEL; // figure out the initial num of DRAIN_VALUE's
|
int num = value / POWER_STEP_LEVEL; // figure out the initial num of DRAIN_VALUE's
|
||||||
int retval = 0; // currently there is no power
|
int retval = 0; // currently there is no power
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Loop through the different hundreds figuring out the fractional piece
|
** Loop through the different hundreds figuring out the fractional piece
|
||||||
** of each.
|
** of each.
|
||||||
*/
|
*/
|
||||||
for (int lp = 0; lp < num; lp ++) {
|
for (int lp = 0; lp < num; lp++) {
|
||||||
retval = retval + (((POWER_HEIGHT - 2) - retval) / POWER_STEP_FACTOR);
|
retval = retval + (((POWER_HEIGHT - 2) - retval) / POWER_STEP_FACTOR);
|
||||||
value -= POWER_STEP_LEVEL;
|
value -= POWER_STEP_LEVEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -417,7 +425,7 @@ int PowerClass::Power_Height(int value)
|
|||||||
retval = retval + (((((POWER_HEIGHT - 2) - retval) / POWER_STEP_FACTOR) * value) / POWER_STEP_LEVEL);
|
retval = retval + (((((POWER_HEIGHT - 2) - retval) / POWER_STEP_FACTOR) * value) / POWER_STEP_LEVEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = Bound(retval, 0, POWER_HEIGHT-2);
|
retval = Bound(retval, 0, POWER_HEIGHT - 2);
|
||||||
return(retval);
|
return(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,7 +447,7 @@ int PowerClass::Power_Height(int value)
|
|||||||
* HISTORY: *
|
* HISTORY: *
|
||||||
* 08/07/1995 JLB : Created. *
|
* 08/07/1995 JLB : Created. *
|
||||||
*=============================================================================================*/
|
*=============================================================================================*/
|
||||||
int PowerClass::PowerButtonClass::Action(unsigned flags, KeyNumType & key)
|
int PowerClass::PowerButtonClass::Action(unsigned flags, KeyNumType& key)
|
||||||
{
|
{
|
||||||
if (!Map.IsSidebarActive) {
|
if (!Map.IsSidebarActive) {
|
||||||
return(false);
|
return(false);
|
||||||
@@ -452,7 +460,8 @@ int PowerClass::PowerButtonClass::Action(unsigned flags, KeyNumType & key)
|
|||||||
Map.Override_Mouse_Shape(MOUSE_NORMAL);
|
Map.Override_Mouse_Shape(MOUSE_NORMAL);
|
||||||
if (PlayerPtr->Power_Fraction() < 1 && PlayerPtr->Power > 0) {
|
if (PlayerPtr->Power_Fraction() < 1 && PlayerPtr->Power > 0) {
|
||||||
Map.Help_Text(TXT_POWER_OUTPUT_LOW, -1, -1, GadgetClass::Get_Color_Scheme()->Color);
|
Map.Help_Text(TXT_POWER_OUTPUT_LOW, -1, -1, GadgetClass::Get_Color_Scheme()->Color);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
Map.Help_Text(TXT_POWER_OUTPUT, -1, -1, GadgetClass::Get_Color_Scheme()->Color);
|
Map.Help_Text(TXT_POWER_OUTPUT, -1, -1, GadgetClass::Get_Color_Scheme()->Color);
|
||||||
}
|
}
|
||||||
GadgetClass::Action(flags, key);
|
GadgetClass::Action(flags, key);
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ int ShapeButtonClass::Draw_Me(int forced)
|
|||||||
|
|
||||||
}
|
}
|
||||||
CC_Draw_Shape(ShapeData, shapenum, X, Y, WINDOW_MAIN, SHAPE_NORMAL);
|
CC_Draw_Shape(ShapeData, shapenum, X, Y, WINDOW_MAIN, SHAPE_NORMAL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Display the mouse.
|
** Display the mouse.
|
||||||
*/
|
*/
|
||||||
|
|||||||
+286
-261
File diff suppressed because it is too large
Load Diff
+337
-140
@@ -4,115 +4,148 @@
|
|||||||
-- * *
|
-- * *
|
||||||
-- *=======================================================*
|
-- *=======================================================*
|
||||||
|
|
||||||
|
-- *********************************************************
|
||||||
|
-- * *
|
||||||
|
-- * Houses (players) *
|
||||||
|
-- * *
|
||||||
|
-- *********************************************************
|
||||||
|
Houses={
|
||||||
|
SPAIN=0, -- YELLOW/GOLD
|
||||||
|
GREECE=1, -- BLUE-GREY
|
||||||
|
USSR=2, -- RED
|
||||||
|
ENGLAND=3, -- GREEN
|
||||||
|
UKRAINE=4, -- ORANGE
|
||||||
|
GERMANY=5, -- KHAKI/LIGHT BROWN
|
||||||
|
FRANCE=6, -- AQUA
|
||||||
|
TURKEY=7, -- RED-OCHRE
|
||||||
|
GOODGUY=8, -- BLUE-GREY
|
||||||
|
BADGUY=9, -- RED
|
||||||
|
NEUTRAL=10, -- YELLOW/GOLD
|
||||||
|
SPECIAL=11, -- YELLOW/GOLD
|
||||||
|
MULTI1=12, -- YELLOW/GOLD
|
||||||
|
MULTI2=13, -- BLUE-GREY
|
||||||
|
MULTI3=14, -- RED
|
||||||
|
MULTI4=15, -- GREEN
|
||||||
|
MULTI5=16, -- ORANGE
|
||||||
|
MULTI6=17, -- KHAKI/LIGHT BROWN
|
||||||
|
MULTI7=18, -- AQUA
|
||||||
|
MULTI8=19 -- RED-OCHRE
|
||||||
|
}
|
||||||
|
|
||||||
-- *********************************************************
|
-- *********************************************************
|
||||||
-- * *
|
-- * *
|
||||||
-- * Buildings *
|
-- * Buildings *
|
||||||
-- * *
|
-- * *
|
||||||
-- *********************************************************
|
-- *********************************************************
|
||||||
|
|
||||||
BUILDING_ATEK=0 -- Allied Technology Centre
|
BuildingTypes={
|
||||||
BUILDING_IRON=1 -- Iron Curtain
|
ATEK=0, -- Allied Technology Centre
|
||||||
BUILDING_WEAP=2 -- Weapons Factory
|
IRON=1, -- Iron Curtain
|
||||||
BUILDING_PDOX=3 -- Chronosphere
|
WEAP=2, -- Weapons Factory
|
||||||
BUILDING_PBOX=4 -- Pillbox
|
PDOX=3, -- Chronosphere
|
||||||
BUILDING_HBOX=5 -- Camouflaged Pillbox
|
PBOX=4, -- Pillbox
|
||||||
BUILDING_DOME=6 -- Radar Dome
|
HBOX=5, -- Camouflaged Pillbox
|
||||||
BUILDING_GAP =7 -- Gap Generator
|
DOME=6, -- Radar Dome
|
||||||
BUILDING_GUN =8 -- Gun Turret
|
GAP =7, -- Gap Generator
|
||||||
BUILDING_AGUN=9 -- Anti-Aircraft Gun
|
GUN =8, -- Gun Turret
|
||||||
BUILDING_FTUR=10 -- Flame Turret
|
AGUN=9, -- Anti-Aircraft Gun
|
||||||
BUILDING_FACT=11 -- Construction Yard
|
FTUR=10, -- Flame Turret
|
||||||
BUILDING_PROC=12 -- Ore Refinery
|
FACT=11, -- Construction Yard
|
||||||
BUILDING_SILO=13 -- Ore Silo
|
PROC=12, -- Ore Refinery
|
||||||
BUILDING_HPAD=14 -- Helicopter Pad
|
SILO=13, -- Ore Silo
|
||||||
BUILDING_SAM =15 -- SAM Site
|
HPAD=14, -- Helicopter Pad
|
||||||
BUILDING_AFLD=16 -- Airfield
|
SAM =15, -- SAM Site
|
||||||
BUILDING_POWR=17 -- Power Plant
|
AFLD=16, -- Airfield
|
||||||
BUILDING_APWR=18 -- Advanced Power Plant
|
POWR=17, -- Power Plant
|
||||||
BUILDING_STEK=19 -- Soviet Technology Centre
|
APWR=18, -- Advanced Power Plant
|
||||||
BUILDING_HOSP=20 -- Hospital
|
STEK=19, -- Soviet Technology Centre
|
||||||
BUILDING_BARR=21 -- Barracks (Allied)
|
HOSP=20, -- Hospital
|
||||||
BUILDING_TENT=22 -- Barracks (Soviet)
|
BARR=21, -- Barracks (Allied)
|
||||||
BUILDING_KENN=23 -- Dog Kennel
|
TENT=22, -- Barracks (Soviet)
|
||||||
BUILDING_FIX =24 -- Service Depot
|
KENN=23, -- Dog Kennel
|
||||||
BUILDING_BIO =25 -- Bio-Research Laboratory
|
FIX =24, -- Service Depot
|
||||||
BUILDING_MISS=26 -- Technology Centre/Prison
|
BIO =25, -- Bio-Research Laboratory
|
||||||
BUILDING_SYRD=27 -- Ship Yard
|
MISS=26, -- Technology Centre/Prison
|
||||||
BUILDING_SPEN=28 -- Sub Pen
|
SYRD=27, -- Ship Yard
|
||||||
BUILDING_MSLO=29 -- Missile Silo
|
SPEN=28, -- Sub Pen
|
||||||
BUILDING_FCOM=30 -- Forward Command Post
|
MSLO=29, -- Missile Silo
|
||||||
BUILDING_TSLA=31 -- Tesla Coil
|
FCOM=30, -- Forward Command Post
|
||||||
BUILDING_WEAF=32 -- Fake Weapons Factory
|
TSLA=31, -- Tesla Coil
|
||||||
BUILDING_FACF=33 -- Fake Construction Yard
|
WEAF=32, -- Fake Weapons Factory
|
||||||
BUILDING_SYRF=34 -- Fake Ship Yard
|
FACF=33, -- Fake Construction Yard
|
||||||
BUILDING_SPEF=35 -- Fake Sub Pen
|
SYRF=34, -- Fake Ship Yard
|
||||||
BUILDING_DOMF=36 -- Fake Radar Dome
|
SPEF=35, -- Fake Sub Pen
|
||||||
BUILDING_MINV=43 -- Anti-vehicle mine
|
DOMF=36, -- Fake Radar Dome
|
||||||
BUILDING_MINP=44 -- Anti-personnel mine
|
MINV=43, -- Anti-vehicle mine
|
||||||
|
MINP=44, -- Anti-personnel mine
|
||||||
|
|
||||||
-- Counterstrike
|
-- Counterstrike
|
||||||
|
|
||||||
BUILDING_QUEE=84 -- Queen ant structure
|
QUEE=84, -- Queen ant structure
|
||||||
BUILDING_LAR1=85 -- Ant - single ant larva
|
LAR1=85, -- Ant - single ant larva
|
||||||
BUILDING_LAR2=86 -- Ant - two ant larvae
|
LAR2=86 -- Ant - two ant larvae
|
||||||
|
}
|
||||||
|
|
||||||
-- *********************************************************
|
-- *********************************************************
|
||||||
-- * *
|
-- * *
|
||||||
-- * Infantry *
|
-- * Infantry *
|
||||||
-- * *
|
-- * *
|
||||||
-- *********************************************************
|
-- *********************************************************
|
||||||
|
|
||||||
INFANTRY_E1=0 -- Rifle Infantry
|
InfantryTypes={
|
||||||
INFANTRY_E2=1 -- Grenadier
|
E1=0, -- Rifle Infantry
|
||||||
INFANTRY_E3=2 -- Rocket Soldier
|
E2=1, -- Grenadier
|
||||||
INFANTRY_E4=3 -- Flamethrower
|
E3=2, -- Rocket Soldier
|
||||||
INFANTRY_E6=4 -- Engineer
|
E4=3, -- Flamethrower
|
||||||
INFANTRY_E7=5 -- Tanya
|
E6=4, -- Engineer
|
||||||
INFANTRY_SPY=6 -- Spy
|
E7=5, -- Tanya
|
||||||
INFANTRY_THF=7 -- Thief
|
SPY=6, -- Spy
|
||||||
INFANTRY_MEDI=8 -- Field Medic
|
THF=7, -- Thief
|
||||||
INFANTRY_GNRL=9 -- General
|
MEDI=8, -- Field Medic
|
||||||
INFANTRY_DOG=10 -- Attack Dog
|
GNRL=9, -- General
|
||||||
INFANTRY_C1=11 -- Joe
|
DOG=10, -- Attack Dog
|
||||||
INFANTRY_C2=12 -- Barry
|
C1=11, -- Joe
|
||||||
INFANTRY_C3=13 -- Shelly
|
C2=12, -- Barry
|
||||||
INFANTRY_C4=14 -- Maria
|
C3=13, -- Shelly
|
||||||
INFANTRY_C5=15 -- Karen
|
C4=14, -- Maria
|
||||||
INFANTRY_C6=16 -- Steve
|
C5=15, -- Karen
|
||||||
INFANTRY_C7=17 -- Phil
|
C6=16, -- Steve
|
||||||
INFANTRY_C8=18 -- Dwight
|
C7=17, -- Phil
|
||||||
INFANTRY_C9=19 -- Erik
|
C8=18, -- Dwight
|
||||||
INFANTRY_C10=20 -- Scientist
|
C9=19, -- Erik
|
||||||
INFANTRY_EINSTEIN=21 -- Prof. Einstein
|
C10=20, -- Scientist
|
||||||
INFANTRY_DELPHI=22 -- Special 1
|
EINSTEIN=21, -- Prof. Einstein
|
||||||
INFANTRY_CHAN=23 -- Special 2
|
DELPHI=22, -- Special 1
|
||||||
|
CHAN=23 -- Special 2
|
||||||
|
}
|
||||||
|
|
||||||
-- *********************************************************
|
-- *********************************************************
|
||||||
-- * *
|
-- * *
|
||||||
-- * Vehicle *
|
-- * Vehicle *
|
||||||
-- * *
|
-- * *
|
||||||
-- *********************************************************
|
-- *********************************************************
|
||||||
|
|
||||||
VEHICLE_4TNK=0 -- Mammoth Tank
|
VehicleTypes={
|
||||||
VEHICLE_3TNK=1 -- Heavy Tank
|
_4TNK=0, -- Mammoth Tank
|
||||||
VEHICLE_2TNK=2 -- Medium Tank
|
_3TNK=1, -- Heavy Tank
|
||||||
VEHICLE_1TNK=3 -- Light Tank
|
_2TNK=2, -- Medium Tank
|
||||||
VEHICLE_APC=4 -- Armoured Personnel Carrier
|
_1TNK=3, -- Light Tank
|
||||||
VEHICLE_MNLY=5 -- Mine Layer
|
APC=4, -- Armoured Personnel Carrier
|
||||||
VEHICLE_JEEP=6 -- Ranger
|
MNLY=5, -- Mine Layer
|
||||||
VEHICLE_HARV=7 -- Ore Truck
|
JEEP=6, -- Ranger
|
||||||
VEHICLE_ARTY=8 -- Artillery
|
HARV=7, -- Ore Truck
|
||||||
VEHICLE_MRJ=9 -- Mobile Radar Jammer
|
ARTY=8, -- Artillery
|
||||||
VEHICLE_MGG=10 -- Mobile Gap Generator
|
MRJ=9, -- Mobile Radar Jammer
|
||||||
VEHICLE_MCV=11 -- Mobile Construction Vehicle
|
MGG=10, -- Mobile Gap Generator
|
||||||
VEHICLE_2VRL=12 -- V2 Rocket Launcher
|
MCV=11, -- Mobile Construction Vehicle
|
||||||
VEHICLE_TRUK=13 -- Convoy Truck
|
_2VRL=12, -- V2 Rocket Launcher
|
||||||
|
TRUK=13, -- Convoy Truck
|
||||||
|
|
||||||
-- Counterstrike only:
|
-- Counterstrike only:
|
||||||
VEHICLE_ANT1=14 -- First ant type
|
ANT1=14, -- First ant type
|
||||||
VEHICLE_ANT2=15 -- Second ant type
|
ANT2=15, -- Second ant type
|
||||||
VEHICLE_ANT3=16 -- Third ant type
|
ANT3=16 -- Third ant type
|
||||||
|
}
|
||||||
|
|
||||||
-- *********************************************************
|
-- *********************************************************
|
||||||
-- * *
|
-- * *
|
||||||
@@ -120,77 +153,241 @@
|
|||||||
-- * *
|
-- * *
|
||||||
-- *********************************************************
|
-- *********************************************************
|
||||||
|
|
||||||
AIRCRAFT_TRAN=0 -- Chinook Helicopter
|
AircraftTypes={
|
||||||
AIRCRAFT_BADR=1 -- Badger Bomber
|
TRAN=0, -- Chinook Helicopter
|
||||||
AIRCRAFT_U2=2 -- Spy Plane
|
BADR=1, -- Badger Bomber
|
||||||
AIRCRAFT_MIG=3 -- MIG Attack Plane
|
U2=2, -- Spy Plane
|
||||||
AIRCRAFT_YAK=4 -- Yak Attack Plane
|
MIG=3, -- MIG Attack Plane
|
||||||
AIRCRAFT_HELI=5 -- Longbow Helicopter
|
YAK=4, -- Yak Attack Plane
|
||||||
AIRCRAFT_HIND=6 -- Hind Helicopter
|
HELI=5, -- Longbow Helicopter
|
||||||
|
HIND=6 -- Hind Helicopter
|
||||||
|
}
|
||||||
|
|
||||||
-- *********************************************************
|
-- *********************************************************
|
||||||
-- * *
|
-- * *
|
||||||
-- * Houses (players) *
|
-- * Vessels *
|
||||||
-- * *
|
-- * *
|
||||||
-- *********************************************************
|
-- *********************************************************
|
||||||
|
|
||||||
HOUSE_SPAIN= 0 -- YELLOW/GOLD
|
VesselTypes={
|
||||||
HOUSE_GREECE=1 -- BLUE-GREY
|
SS=0, -- Submarine
|
||||||
HOUSE_USSR=2 -- RED
|
DD=1, -- Destroyer
|
||||||
HOUSE_ENGLAND=3 -- GREEN
|
CA=2, -- Cruiser
|
||||||
HOUSE_UKRAINE=4 -- ORANGE
|
LST=3, -- Land Sea Tank (transport)
|
||||||
HOUSE_GERMANY=5 -- KHAKI/LIGHT BROWN
|
PT=4 -- Gun Boat
|
||||||
HOUSE_FRANCE=6 -- AQUA
|
}
|
||||||
HOUSE_TURKEY=7 -- RED-OCHRE
|
|
||||||
HOUSE_GOODGUY=8 -- BLUE-GREY
|
-- *********************************************************
|
||||||
HOUSE_BADGUY=9 -- RED
|
-- * *
|
||||||
HOUSE_NEUTRAL=10 -- YELLOW/GOLD
|
-- * Armor Types *
|
||||||
HOUSE_SPECIAL=11 -- YELLOW/GOLD
|
-- * *
|
||||||
HOUSE_MULTI1=12 -- YELLOW/GOLD
|
-- *********************************************************
|
||||||
HOUSE_MULTI2=13 -- BLUE-GREY
|
ArmorTypes={
|
||||||
HOUSE_MULTI3=14 -- RED
|
NONE=0,
|
||||||
HOUSE_MULTI4=15 -- GREEN
|
WOOD=1,
|
||||||
HOUSE_MULTI5=16 -- ORANGE
|
ALUMINUM=2,
|
||||||
HOUSE_MULTI6=17 -- KHAKI/LIGHT BROWN
|
STEEL=3,
|
||||||
HOUSE_MULTI7=18 -- AQUA
|
CONCRETE=4
|
||||||
HOUSE_MULTI8=19 -- RED-OCHRE
|
}
|
||||||
|
|
||||||
|
-- *********************************************************
|
||||||
|
-- * *
|
||||||
|
-- * Weapon Types *
|
||||||
|
-- * *
|
||||||
|
-- *********************************************************
|
||||||
|
WeaponTypes={
|
||||||
|
NONE=-1,
|
||||||
|
COLT45=0,
|
||||||
|
ACK_ACK=1,
|
||||||
|
VULCAN=2,
|
||||||
|
MAVERICK=3,
|
||||||
|
CAMERA=4,
|
||||||
|
FIREBALL=5,
|
||||||
|
RIFLE=6,
|
||||||
|
CHAIN_GUN=7,
|
||||||
|
PISTOL=8,
|
||||||
|
M16=9,
|
||||||
|
DRAGON=10,
|
||||||
|
HELLFIRE=11,
|
||||||
|
GRENADE=12,
|
||||||
|
_75MM=13,
|
||||||
|
_90MM=14,
|
||||||
|
_105MM=15,
|
||||||
|
_120MM=16,
|
||||||
|
TURRET_GUN=17,
|
||||||
|
MAMMOTH_TUSK=18,
|
||||||
|
_155MM=19,
|
||||||
|
M60MG=20,
|
||||||
|
NAPALM=21,
|
||||||
|
TESLA_ZAP=22,
|
||||||
|
NIKE=23,
|
||||||
|
_8INCH=24,
|
||||||
|
STINGER=25,
|
||||||
|
TORPEDO=26,
|
||||||
|
_2INCH=27,
|
||||||
|
DEPTH_CHARGE=28,
|
||||||
|
PARA_BOMB=29,
|
||||||
|
DOGJAW=30,
|
||||||
|
HEAL=31,
|
||||||
|
SCUD=32,
|
||||||
|
FLAMER=33,
|
||||||
|
REDEYE=34
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- *********************************************************
|
-- *********************************************************
|
||||||
-- * *
|
-- * *
|
||||||
-- * Special weapons *
|
-- * Special weapons *
|
||||||
-- * *
|
-- * *
|
||||||
-- *********************************************************
|
-- *********************************************************
|
||||||
SPECIAL_WEAPON_SONAR=0
|
SpecialWeapons={
|
||||||
SPECIAL_WEAPON_NUKE=1
|
Sonar=0,
|
||||||
SPECIAL_WEAPON_CHRONO=2
|
Nuke=1,
|
||||||
SPECIAL_WEAPON_PARABOMB=3
|
Chrono=2,
|
||||||
SPECIAL_WEAPON_PARATROOPS=4
|
Parabomb=3,
|
||||||
SPECIAL_WEAPON_SPY_PLANE=5
|
Paratroops=4,
|
||||||
SPECIAL_WEAPON_IRON_CURTAIN=6
|
SpyPlane=5,
|
||||||
SPECIAL_WEAPON_GPS=7
|
IronCurtain=6,
|
||||||
|
GPS=7
|
||||||
|
}
|
||||||
|
|
||||||
-- *********************************************************
|
-- *********************************************************
|
||||||
-- * *
|
-- * *
|
||||||
-- * Target types (for use with DesignatePreferredTarget) *
|
-- * Target types (for use with DesignatePreferredTarget) *
|
||||||
-- * *
|
-- * *
|
||||||
-- *********************************************************
|
-- *********************************************************
|
||||||
TARGET_TYPE_ANYTHING=1
|
TargetTypes={
|
||||||
TARGET_TYPE_BUILDINGS=2
|
Anything=1,
|
||||||
TARGET_TYPE_HARVESTERS=3
|
Buildings=2,
|
||||||
TARGET_TYPE_INFANTRY=4
|
Harvesters=3,
|
||||||
TARGET_TYPE_VEHICLES=5
|
Infantry=4,
|
||||||
TARGET_TYPE_SHIPS=6
|
Vehicles=5,
|
||||||
TARGET_TYPE_FACTORIES=7
|
Ships=6,
|
||||||
TARGET_TYPE_BASE_DEFENCES=8
|
Factories=7,
|
||||||
TARGET_TYPE_BASE_THREATS=9
|
BaseDefences=8,
|
||||||
TARGET_TYPE_POWER=10
|
BaseThreats=9,
|
||||||
TARGET_TYPE_FAKE_BUILDINGS=11
|
Power=10,
|
||||||
|
FakeBuildings=11
|
||||||
|
}
|
||||||
|
|
||||||
-- *********************************************************
|
-- *********************************************************
|
||||||
-- * *
|
-- * *
|
||||||
-- * Trigger persistance *
|
-- * Trigger persistance *
|
||||||
-- * *
|
-- * *
|
||||||
-- *********************************************************
|
-- *********************************************************
|
||||||
TRIGGER_VOLATILE=0
|
PersistenceTypes={
|
||||||
TRIGGER_SEMI_PERSISTENT=1
|
Volatile=0,
|
||||||
TRIGGER_PERSISTENT=2
|
SemiPersistent=1,
|
||||||
|
Persistent=2
|
||||||
|
}
|
||||||
|
|
||||||
|
-- *********************************************************
|
||||||
|
-- * *
|
||||||
|
-- * Obejct Attributes *
|
||||||
|
-- * *
|
||||||
|
-- *********************************************************
|
||||||
|
ObjectAttributes = {
|
||||||
|
Type=0,
|
||||||
|
Strength=1, -- Object attribute
|
||||||
|
MaxStrength=2, -- Definition attribute
|
||||||
|
Cost=3, -- Definition attribute
|
||||||
|
SightRange=4, -- Definition attribute
|
||||||
|
TechLevel=5, -- Definition attribute
|
||||||
|
Armor=6,
|
||||||
|
PrimaryWeapon=7,
|
||||||
|
SecondaryWeapon=8,
|
||||||
|
Speed=9,
|
||||||
|
MaxSpeed=10,
|
||||||
|
MaxAmmo=11,
|
||||||
|
RotationSpeed=12,
|
||||||
|
IsCrushable=13,
|
||||||
|
IsStealthy=14,
|
||||||
|
IsSelectable=15,
|
||||||
|
IsLegalTarget=16,
|
||||||
|
IsRepairable=17,
|
||||||
|
IsSelfHealing=18,
|
||||||
|
Explodes=19,
|
||||||
|
HasCrew=20,
|
||||||
|
MaxPassengers=21,
|
||||||
|
IsRepairing=22,
|
||||||
|
|
||||||
|
-- Building Specific
|
||||||
|
Capacity=23,
|
||||||
|
Power=24,
|
||||||
|
Sellable=25,
|
||||||
|
|
||||||
|
-- Unit Specific
|
||||||
|
IsCrateGoodie=26,
|
||||||
|
IsCrusher=27,
|
||||||
|
IsHarvest=28,
|
||||||
|
IsRadarEquipped=29,
|
||||||
|
IsJammer=30,
|
||||||
|
IsGapper=31,
|
||||||
|
|
||||||
|
-- Infantry Specific
|
||||||
|
IsFemale=32,
|
||||||
|
Capture=33,
|
||||||
|
IsFraidyCat=34,
|
||||||
|
IsCivilian=35,
|
||||||
|
IsBomber=36,
|
||||||
|
IsDog=37
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
-- *********************************************************
|
||||||
|
-- * *
|
||||||
|
-- * House Attributes *
|
||||||
|
-- * *
|
||||||
|
-- *********************************************************
|
||||||
|
HouseAttributes = {
|
||||||
|
IQ = 0,
|
||||||
|
TechLevel =1,
|
||||||
|
IsHuman=2,
|
||||||
|
FirepowerBias=3,
|
||||||
|
GroundspeedBias=4,
|
||||||
|
ArmorBias=5,
|
||||||
|
ROFBias=6,
|
||||||
|
CostBias=7,
|
||||||
|
RepairDelay=8,
|
||||||
|
BuildDelay=9,
|
||||||
|
Started=10,
|
||||||
|
Alerted=11,
|
||||||
|
BaseBuilding=12,
|
||||||
|
Discovered=13,
|
||||||
|
Capacity=14,
|
||||||
|
Tiberium=15,
|
||||||
|
Credits=16,
|
||||||
|
AlertTimer=17,
|
||||||
|
RepairTimer=18,
|
||||||
|
Points=19,
|
||||||
|
DestroyedBuildings=20,
|
||||||
|
DestroyedVehicles=21,
|
||||||
|
DestroyedInfantry=22,
|
||||||
|
DestroyedAircraft=23,
|
||||||
|
DestroyedVessels=24,
|
||||||
|
CapturedBuildings=25,
|
||||||
|
Crates=26,
|
||||||
|
BuildingFactories=27,
|
||||||
|
VehicleFactories=28,
|
||||||
|
InfantryFactories=29,
|
||||||
|
AircraftFactories=30,
|
||||||
|
VesselFactories=31,
|
||||||
|
|
||||||
|
Power=32,
|
||||||
|
Drain=33,
|
||||||
|
LastAttacker=34
|
||||||
|
}
|
||||||
|
|
||||||
|
-- *********************************************************
|
||||||
|
-- * *
|
||||||
|
-- * Fear Type Attribute Values *
|
||||||
|
-- * *
|
||||||
|
-- *********************************************************
|
||||||
|
FearTypes={
|
||||||
|
None=0, -- No fear at all (default state).
|
||||||
|
Anxious=10, -- Something makes them scared.
|
||||||
|
Scared=100, -- Scared enough to take cover.
|
||||||
|
Panic=200, -- Run away! Run away!
|
||||||
|
Maximum=255 -- Scared to death.
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user