mirror of
https://github.com/jmarshall23/CnC_Remastered_Collection.git
synced 2026-08-12 08:00:55 +02:00
Sidebar fixes, power fix, input fixes.
This commit is contained in:
@@ -16,3 +16,4 @@
|
||||
/*.DAT
|
||||
/SAVEGAME*
|
||||
|
||||
/cache
|
||||
|
||||
@@ -743,7 +743,7 @@ void Keyboard_Process(KeyNumType & input)
|
||||
** Center the map about the construction yard or construction vehicle
|
||||
** if one is present.
|
||||
*/
|
||||
if (key != 0 && key == VK_H) {
|
||||
if (key != 0 && key == Options.KeyBase) {
|
||||
Unselect_All();
|
||||
if (PlayerPtr->CurBuildings) {
|
||||
for (index = 0; index < Buildings.Count(); index++) {
|
||||
@@ -875,19 +875,19 @@ void Keyboard_Process(KeyNumType & input)
|
||||
** Scrolls the tactical map in the direction specified.
|
||||
*/
|
||||
int distance = CELL_LEPTON_W;
|
||||
if (key != 0 && key == VK_LEFT) {
|
||||
if (key != 0 && key == KN_LEFT) {
|
||||
Map.Scroll_Map(DIR_W, distance, true);
|
||||
input = KN_NONE;
|
||||
}
|
||||
if (key != 0 && key == VK_RIGHT) {
|
||||
if (key != 0 && key == KN_RIGHT) {
|
||||
Map.Scroll_Map(DIR_E, distance, true);
|
||||
input = KN_NONE;
|
||||
}
|
||||
if (key != 0 && key == VK_UP) {
|
||||
if (key != 0 && key == KN_UP) {
|
||||
Map.Scroll_Map(DIR_N, distance, true);
|
||||
input = KN_NONE;
|
||||
}
|
||||
if (key != 0 && key == VK_DOWN) {
|
||||
if (key != 0 && key == KN_DOWN) {
|
||||
Map.Scroll_Map(DIR_S, distance, true);
|
||||
input = KN_NONE;
|
||||
}
|
||||
|
||||
@@ -162,6 +162,7 @@ extern PKey SlowKey;
|
||||
extern RulesClass Rule;
|
||||
extern KeyboardClass * Keyboard;
|
||||
extern UserInputClass UserInput;
|
||||
extern EventQueueClass EventQueue;
|
||||
extern RandomStraw CryptRandom;
|
||||
extern RandomClass NonCriticalRandomNumber;
|
||||
extern CarryoverClass * Carryover;
|
||||
|
||||
+50
-106
@@ -58,31 +58,31 @@
|
||||
#include <SDL.h>
|
||||
|
||||
|
||||
/*
|
||||
** 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
|
||||
** is no longer pressed.
|
||||
*/
|
||||
GadgetClass * GadgetClass::StuckOn = 0;
|
||||
/*
|
||||
** 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
|
||||
** is no longer pressed.
|
||||
*/
|
||||
GadgetClass* GadgetClass::StuckOn = 0;
|
||||
|
||||
/*
|
||||
** 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.
|
||||
*/
|
||||
GadgetClass * GadgetClass::LastList = 0;
|
||||
GadgetClass* GadgetClass::LastList = 0;
|
||||
|
||||
|
||||
/*
|
||||
** 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.
|
||||
*/
|
||||
static RemapControlType _GreyScheme = {15};
|
||||
RemapControlType * GadgetClass::ColorScheme = &_GreyScheme;
|
||||
static RemapControlType _GreyScheme = { 15 };
|
||||
RemapControlType* GadgetClass::ColorScheme = &_GreyScheme;
|
||||
|
||||
/***********************************************************************************************
|
||||
* 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)
|
||||
{
|
||||
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: *
|
||||
* 08/01/1996 JLB : Created. *
|
||||
*=============================================================================================*/
|
||||
GadgetClass::GadgetClass(GadgetClass const & gadget) :
|
||||
GadgetClass::GadgetClass(GadgetClass const& gadget) :
|
||||
X(gadget.X),
|
||||
Y(gadget.Y),
|
||||
Width(gadget.Width),
|
||||
@@ -190,7 +190,7 @@ GadgetClass::~GadgetClass(void)
|
||||
* *
|
||||
* 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
|
||||
@@ -212,7 +212,7 @@ int GadgetClass::Clicked_On(KeyNumType & key, unsigned flags, int mousex, int mo
|
||||
*/
|
||||
if (this == StuckOn ||
|
||||
(flags & KEYBOARD) ||
|
||||
(flags && (mousex - X) < Width && (mousey - Y) < Height)) {
|
||||
(flags && (mousex - X) < Width && (mousey - Y) < Height)) {
|
||||
|
||||
return(Action(flags, key));
|
||||
}
|
||||
@@ -281,10 +281,10 @@ void GadgetClass::Disable(void)
|
||||
* HISTORY: *
|
||||
* 01/15/1995 JLB : Created. *
|
||||
*=============================================================================================*/
|
||||
GadgetClass * GadgetClass::Remove(void)
|
||||
GadgetClass* GadgetClass::Remove(void)
|
||||
{
|
||||
Clear_Focus();
|
||||
return(GadgetClass *)LinkClass::Remove();
|
||||
return(GadgetClass*)LinkClass::Remove();
|
||||
}
|
||||
|
||||
|
||||
@@ -303,7 +303,7 @@ GadgetClass * GadgetClass::Remove(void)
|
||||
* HISTORY: *
|
||||
* 01/15/1995 JLB : Created. *
|
||||
*=============================================================================================*/
|
||||
GadgetClass * GadgetClass::Get_Next(void) const
|
||||
GadgetClass* GadgetClass::Get_Next(void) const
|
||||
{
|
||||
return(GadgetClass*)LinkClass::Get_Next();
|
||||
}
|
||||
@@ -324,7 +324,7 @@ GadgetClass * GadgetClass::Get_Next(void) const
|
||||
* HISTORY: *
|
||||
* 01/15/1995 JLB : Created. *
|
||||
*=============================================================================================*/
|
||||
GadgetClass * GadgetClass::Get_Prev(void) const
|
||||
GadgetClass* GadgetClass::Get_Prev(void) const
|
||||
{
|
||||
return(GadgetClass*)LinkClass::Get_Prev();
|
||||
}
|
||||
@@ -347,7 +347,7 @@ GadgetClass * GadgetClass::Get_Prev(void) const
|
||||
*=============================================================================================*/
|
||||
void GadgetClass::Delete_List(void)
|
||||
{
|
||||
GadgetClass * g = this;
|
||||
GadgetClass* g = this;
|
||||
|
||||
/*
|
||||
** Move to head of the list.
|
||||
@@ -365,7 +365,7 @@ void GadgetClass::Delete_List(void)
|
||||
while (g) {
|
||||
g->Clear_Focus();
|
||||
|
||||
GadgetClass * temp = g;
|
||||
GadgetClass* temp = g;
|
||||
g = g->Get_Next();
|
||||
delete temp;
|
||||
}
|
||||
@@ -391,7 +391,7 @@ void GadgetClass::Delete_List(void)
|
||||
* HISTORY: *
|
||||
* 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
|
||||
@@ -450,7 +450,7 @@ int GadgetClass::Draw_Me(int forced)
|
||||
*=============================================================================================*/
|
||||
void GadgetClass::Draw_All(bool forced)
|
||||
{
|
||||
GadgetClass * gadget = this;
|
||||
GadgetClass* gadget = this;
|
||||
|
||||
while (gadget != NULL) {
|
||||
gadget->Draw_Me(forced);
|
||||
@@ -470,8 +470,10 @@ void GadgetClass::Draw_All(bool forced)
|
||||
* HISTORY: 01/03/1995 MML : Created. *
|
||||
*=========================================================================*/
|
||||
KeyNumType GadgetClass::Input(void)
|
||||
{
|
||||
KeyNumType key;
|
||||
{
|
||||
EventMessage eventMessage;
|
||||
KeyNumType key = KN_NONE;
|
||||
int flags = 0;
|
||||
int forced = false;
|
||||
|
||||
/*
|
||||
@@ -488,111 +490,52 @@ KeyNumType GadgetClass::Input(void)
|
||||
/*
|
||||
** Fetch any pending keyboard input.
|
||||
*/
|
||||
key = Keyboard->Check();
|
||||
if (key != 0) {
|
||||
key = Keyboard->Get();
|
||||
UserInput.Process_Input(key, flags);
|
||||
|
||||
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 (StuckOn) {
|
||||
StuckOn->Draw_Me(false);
|
||||
GadgetClass * oldstuck = StuckOn;
|
||||
GadgetClass* oldstuck = StuckOn;
|
||||
StuckOn->Clicked_On(key, flags, UserInput.Mouse.X, UserInput.Mouse.Y);
|
||||
if (StuckOn) {
|
||||
|
||||
if (StuckOn)
|
||||
{
|
||||
StuckOn->Draw_Me(false);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
oldstuck->Draw_Me(false);
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
** If there is a gadget that has the keyboard focus, then route all keyboard
|
||||
** events to it.
|
||||
*/
|
||||
if (Focused && (flags & KEYBOARD)) {
|
||||
if (Focused && eventMessage.EventType == EventMessageType::EVENT_KEYBOARD) {
|
||||
Focused->Draw_Me(false);
|
||||
Focused->Clicked_On(key, flags, UserInput.Mouse.X, UserInput.Mouse.Y);
|
||||
if (Focused) {
|
||||
Focused->Draw_Me(false);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
|
||||
/*
|
||||
** 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
|
||||
** 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.
|
||||
*/
|
||||
GadgetClass * next_button = this;
|
||||
GadgetClass* next_button = this;
|
||||
while (next_button != NULL) {
|
||||
|
||||
/*
|
||||
@@ -621,6 +564,7 @@ KeyNumType GadgetClass::Input(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(key);
|
||||
}
|
||||
|
||||
@@ -645,14 +589,14 @@ KeyNumType GadgetClass::Input(void)
|
||||
* HISTORY: *
|
||||
* 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) {
|
||||
while (g != NULL) {
|
||||
if (g->Get_ID() == id) {
|
||||
return((ControlClass *)g);
|
||||
return((ControlClass*)g);
|
||||
}
|
||||
g = g->Get_Next();
|
||||
}
|
||||
@@ -801,7 +745,7 @@ bool GadgetClass::Has_Focus(void)
|
||||
*=============================================================================================*/
|
||||
int GadgetClass::Is_List_To_Redraw(void)
|
||||
{
|
||||
GadgetClass * gadget = this;
|
||||
GadgetClass* gadget = this;
|
||||
|
||||
while (gadget != NULL) {
|
||||
if (gadget->IsToRepaint) {
|
||||
|
||||
@@ -257,6 +257,7 @@ RulesClass Rule;
|
||||
** user input class pointer.
|
||||
*/
|
||||
UserInputClass UserInput;
|
||||
EventQueueClass EventQueue;
|
||||
|
||||
/***************************************************************************
|
||||
** All keyboard input is routed through the object pointed to by this
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../FUNCTION.H"
|
||||
#include "EventQueue.h"
|
||||
#include "../function.h"
|
||||
#include "eventqueue.h"
|
||||
|
||||
/*
|
||||
Clears the event queue and frees memory
|
||||
|
||||
+193
-107
@@ -1,18 +1,60 @@
|
||||
#include "../function.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)
|
||||
{
|
||||
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->MouseQY = Mouse.Y;
|
||||
|
||||
flags = 0;
|
||||
|
||||
static SDL_Event event;
|
||||
memset(&event, 0, sizeof(SDL_Event));
|
||||
|
||||
@@ -21,119 +63,161 @@ void UserInputClass::Process_Input(KeyNumType& key, int& flags)
|
||||
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_SYSWMEVENT:
|
||||
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:
|
||||
case SDL_SYSWMEVENT:
|
||||
if (event.syswm.msg->msg.win.msg == WM_DESTROY)
|
||||
{
|
||||
if (event.key.keysym.scancode == SDL_SCANCODE_GRAVE) {
|
||||
renderConsole = !renderConsole;
|
||||
Invalidate_Cached_Icons();
|
||||
VisiblePage.Un_Init();
|
||||
HiddenPage.Un_Init();
|
||||
AllSurfaces.Release();
|
||||
if (!InDebugger) Reset_Video_Mode();
|
||||
|
||||
if (renderConsole) {
|
||||
ShowCursor(TRUE);
|
||||
Hide_Mouse();
|
||||
}
|
||||
else {
|
||||
ShowCursor(FALSE);
|
||||
Show_Mouse();
|
||||
}
|
||||
PostQuitMessage(0);
|
||||
|
||||
switch (ReadyToQuit) {
|
||||
case 1:
|
||||
ReadyToQuit = 2;
|
||||
break;
|
||||
case 0:
|
||||
ExitProcess(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int keyFlags = 0x00;
|
||||
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;
|
||||
}
|
||||
break;
|
||||
|
||||
// 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())
|
||||
{
|
||||
Keyboard->Put_Element(element->second | keyFlags);
|
||||
KeyB.ASCII = element->second;
|
||||
}
|
||||
/* Mouse is moving */
|
||||
case SDL_MOUSEMOTION:
|
||||
if (!(MouseState & SDL_BUTTON(SDL_BUTTON_LEFT)))
|
||||
{
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
case SDL_TEXTINPUT:
|
||||
// limit to range 0-255
|
||||
if (event.text.text[0] == ( event.text.text[0] & 0xFF ) )
|
||||
|
||||
flags |= GadgetClass::KEYBOARD;
|
||||
|
||||
int keyFlags = 0x00;
|
||||
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;
|
||||
if (event.text.text[0] == (event.text.text[0] & 0xFF))
|
||||
{
|
||||
KeyB.ASCII = (char)event.text.text[0];
|
||||
KeyB.ASCII = element->second;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
@@ -145,6 +229,8 @@ void UserInputClass::Process_Input(KeyNumType& key, int& flags)
|
||||
if (!leftMouseProcessed && numFramesLMouse != 0)
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -115,53 +115,52 @@ typedef enum {
|
||||
|
||||
class UserInputClass
|
||||
{
|
||||
public:
|
||||
UserInputClass();
|
||||
void UserInputClass::Process_Input(KeyNumType& key = g_globalKeyNumType, int& flags = g_globalKeyFlags);
|
||||
|
||||
InputAction LastAction;
|
||||
|
||||
class KeyboardState {
|
||||
public:
|
||||
UserInputClass(void);
|
||||
SDL_KeyCode LastKey;
|
||||
char ASCII;
|
||||
|
||||
void UserInputClass::Process_Input( KeyNumType& key = g_globalKeyNumType, int& flags = g_globalKeyFlags );
|
||||
bool Shift;
|
||||
bool Control;
|
||||
bool Alt;
|
||||
bool CapsLock;
|
||||
|
||||
InputAction LastAction;
|
||||
bool Key_Down(KeyNumType key) const;
|
||||
|
||||
class KeyboardState {
|
||||
public:
|
||||
SDL_KeyCode LastKey;
|
||||
char ASCII;
|
||||
void ResetState() {
|
||||
this->Shift = false;
|
||||
this->Control = false;
|
||||
this->Alt = false;
|
||||
}
|
||||
};
|
||||
|
||||
bool Shift;
|
||||
bool Control;
|
||||
bool Alt;
|
||||
bool CapsLock;
|
||||
KeyboardState KeyB;
|
||||
|
||||
bool Key_Down(KeyNumType key) const;
|
||||
class MouseState {
|
||||
public:
|
||||
int X;
|
||||
int Y;
|
||||
|
||||
void ResetState() {
|
||||
this->Shift = false;
|
||||
this->Control = false;
|
||||
this->Alt = false;
|
||||
}
|
||||
};
|
||||
MouseButtonState Button_Left;
|
||||
MouseButtonState Button_Middle;
|
||||
MouseButtonState Button_Right;
|
||||
|
||||
KeyboardState KeyB;
|
||||
bool UserInputClass::MouseState::Mouse_Down(KeyNumType key) const;
|
||||
|
||||
class MouseState {
|
||||
public:
|
||||
int X;
|
||||
int Y;
|
||||
void ResetState() {
|
||||
this->Button_Left = MouseButtonState::MOUSE_BUTTON_UP;
|
||||
this->Button_Middle = MouseButtonState::MOUSE_BUTTON_UP;
|
||||
this->Button_Right = MouseButtonState::MOUSE_BUTTON_UP;
|
||||
}
|
||||
};
|
||||
|
||||
MouseButtonState Button_Left;
|
||||
MouseButtonState Button_Middle;
|
||||
MouseButtonState Button_Right;
|
||||
|
||||
bool UserInputClass::MouseState::Mouse_Down(KeyNumType key) const;
|
||||
|
||||
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;
|
||||
};
|
||||
MouseState Mouse;
|
||||
private:
|
||||
int numFramesLMouse = 0;
|
||||
};
|
||||
|
||||
@@ -372,7 +372,7 @@ bool WWKeyboardClass::Down(unsigned short key)
|
||||
return g_globalKeyFlags & GadgetClass::RIGHTPRESS;
|
||||
}
|
||||
|
||||
return(GetAsyncKeyState(key & 0xFF) == 0 ? false : true);
|
||||
return UserInput.KeyB.Key_Down((KeyNumType)key);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -591,6 +591,7 @@ void OptionsClass::Load_Settings(void)
|
||||
SlowPalette = ini.Get_Bool(OPTIONS, "SlowPalette", SlowPalette);
|
||||
IsPaletteScroll = ini.Get_Bool(OPTIONS, "PaletteScroll", IsPaletteScroll);
|
||||
|
||||
/*
|
||||
KeyForceMove1 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyForceMove1", KeyForceMove1);
|
||||
KeyForceMove2 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyForceMove2", KeyForceMove2);
|
||||
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);
|
||||
KeyTeam10 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyTeam10", KeyTeam10);
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
KeyForceMove1 = (KeyNumType)(KeyForceMove1 & ~WWKEY_VK_BIT);
|
||||
KeyForceMove2 = (KeyNumType)(KeyForceMove2 & ~WWKEY_VK_BIT);
|
||||
@@ -693,6 +693,7 @@ void OptionsClass::Load_Settings(void)
|
||||
KeyTeam9 = (KeyNumType)(KeyTeam9 & ~WWKEY_VK_BIT);
|
||||
KeyTeam10 = (KeyNumType)(KeyTeam10 & ~WWKEY_VK_BIT);
|
||||
#endif
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
+54
-45
@@ -44,11 +44,11 @@
|
||||
#include "function.h"
|
||||
|
||||
|
||||
/*
|
||||
** Points to the shape to use for the "desired" power level indicator.
|
||||
*/
|
||||
void const * PowerClass::PowerShape;
|
||||
void const * PowerClass::PowerBarShape;
|
||||
/*
|
||||
** Points to the shape to use for the "desired" power level indicator.
|
||||
*/
|
||||
void const* PowerClass::PowerShape;
|
||||
void const* PowerClass::PowerBarShape;
|
||||
|
||||
PowerClass::PowerButtonClass PowerClass::PowerButton;
|
||||
|
||||
@@ -137,8 +137,8 @@ void PowerClass::One_Time(void)
|
||||
RadarClass::One_Time();
|
||||
PowerButton.X = ScreenWidth - (640 - (POWER_X * RESFACTOR));
|
||||
PowerButton.Y = POWER_Y * RESFACTOR;
|
||||
PowerButton.Width = (POWER_WIDTH * RESFACTOR)-1;
|
||||
PowerButton.Height = ScreenHeight - ( POWER_Y * RESFACTOR ) ;// POWER_HEIGHT* RESFACTOR;
|
||||
PowerButton.Width = (POWER_WIDTH * RESFACTOR) - 1;
|
||||
PowerButton.Height = ScreenHeight - (POWER_Y * RESFACTOR);// POWER_HEIGHT* RESFACTOR;
|
||||
PowerShape = MFCD::Retrieve("POWER.SHP");
|
||||
PowerBarShape = MFCD::Retrieve("POWERBAR.SHP");
|
||||
}
|
||||
@@ -162,13 +162,14 @@ void PowerClass::One_Time(void)
|
||||
*=============================================================================================*/
|
||||
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
|
||||
};
|
||||
|
||||
// jmarshall - render the world before the power bar.
|
||||
// jmarshall - render the world before the power bar.
|
||||
RadarClass::Draw_It(complete);
|
||||
// jmarshall end
|
||||
// jmarshall end
|
||||
|
||||
{
|
||||
BStart(BENCH_POWER);
|
||||
|
||||
@@ -176,7 +177,7 @@ void PowerClass::Draw_It(bool complete)
|
||||
if (Map.IsSidebarActive) {
|
||||
IsToRedraw = false;
|
||||
ShapeFlags_Type flags = SHAPE_NORMAL;
|
||||
void const * remap = NULL;
|
||||
void const* remap = NULL;
|
||||
|
||||
if (FlashTimer > 1 && ((FlashTimer % 3) & 0x01) != 0) {
|
||||
flags = flags | SHAPE_FADING;
|
||||
@@ -190,25 +191,23 @@ void PowerClass::Draw_It(bool complete)
|
||||
|
||||
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);
|
||||
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
|
||||
** of power demands.
|
||||
*/
|
||||
int power_height = (PowerHeight == DesiredPowerHeight) ? PowerHeight + (_modtable[PowerBounce] * PowerDir) : PowerHeight;
|
||||
int drain_height = (DrainHeight == DesiredDrainHeight) ? DrainHeight + (_modtable[DrainBounce] * DrainDir) : DrainHeight;
|
||||
int power_height = (PowerHeight == DesiredPowerHeight) ? PowerHeight + (_modtable[PowerBounce] * PowerDir) : PowerHeight;
|
||||
int drain_height = (DrainHeight == DesiredDrainHeight) ? DrainHeight + (_modtable[DrainBounce] * DrainDir) : DrainHeight;
|
||||
power_height = Bound(power_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.
|
||||
*/
|
||||
@@ -233,23 +232,26 @@ void PowerClass::Draw_It(bool complete)
|
||||
** ST - 5/2/96 11:23AM
|
||||
*/
|
||||
|
||||
power_height = (power_height*(76*RESFACTOR+1)) / (53*RESFACTOR+1);
|
||||
drain_height = (drain_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);
|
||||
|
||||
//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 - (246*RESFACTOR)), bottom - power_height, ScreenWidth - (640 - (246*RESFACTOR+1)), bottom, color1 );
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
** 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();
|
||||
}
|
||||
BEnd(BENCH_POWER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -270,11 +272,11 @@ void PowerClass::Draw_It(bool complete)
|
||||
* 12/20/1994 JLB : Created. *
|
||||
* 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*/) {
|
||||
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) {
|
||||
DesiredPowerHeight = Power_Height(PlayerPtr->Power);
|
||||
RecordedPower = PlayerPtr->Power;
|
||||
PowerBounce = 12;
|
||||
RecordedPower = PlayerPtr->Power;
|
||||
PowerBounce = 12;
|
||||
if (PowerHeight > DesiredPowerHeight) {
|
||||
PowerDir = -1;
|
||||
} else if (PowerHeight < DesiredPowerHeight) {
|
||||
}
|
||||
else if (PowerHeight < DesiredPowerHeight) {
|
||||
PowerDir = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
PowerBounce = 0;
|
||||
}
|
||||
}
|
||||
@@ -300,13 +304,15 @@ void PowerClass::AI(KeyNumType &input, int x, int y)
|
||||
*/
|
||||
if (PlayerPtr->Drain != RecordedDrain) {
|
||||
DesiredDrainHeight = Power_Height(PlayerPtr->Drain);
|
||||
RecordedDrain = PlayerPtr->Drain;
|
||||
DrainBounce = 12;
|
||||
RecordedDrain = PlayerPtr->Drain;
|
||||
DrainBounce = 12;
|
||||
if (DrainHeight > DesiredDrainHeight) {
|
||||
DrainDir = -1;
|
||||
} else if (DrainHeight < DesiredDrainHeight) {
|
||||
}
|
||||
else if (DrainHeight < DesiredDrainHeight) {
|
||||
DrainDir = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
DrainBounce = 0;
|
||||
}
|
||||
}
|
||||
@@ -315,7 +321,8 @@ void PowerClass::AI(KeyNumType &input, int x, int y)
|
||||
IsToRedraw = true;
|
||||
Flag_To_Redraw(false);
|
||||
DrainBounce--;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/*
|
||||
** 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;
|
||||
Flag_To_Redraw(false);
|
||||
PowerBounce--;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/*
|
||||
** 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.
|
||||
*/
|
||||
// if (FlashTimer == 1) {
|
||||
// if (FlashTimer == 1) {
|
||||
if (FlashTimer > 0) {
|
||||
IsToRedraw = true;
|
||||
Flag_To_Redraw(false);
|
||||
@@ -374,7 +382,7 @@ void PowerClass::AI(KeyNumType &input, int x, int y)
|
||||
* HISTORY: *
|
||||
* 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) {
|
||||
IsToRedraw = true;
|
||||
@@ -398,16 +406,16 @@ void PowerClass::Refresh_Cells(CELL cell, short const * list)
|
||||
*=========================================================================*/
|
||||
int PowerClass::Power_Height(int value)
|
||||
{
|
||||
int num = value/ POWER_STEP_LEVEL; // figure out the initial num of DRAIN_VALUE's
|
||||
int retval = 0; // currently there is no power
|
||||
int num = value / POWER_STEP_LEVEL; // figure out the initial num of DRAIN_VALUE's
|
||||
int retval = 0; // currently there is no power
|
||||
|
||||
/*
|
||||
** Loop through the different hundreds figuring out the fractional piece
|
||||
** of each.
|
||||
*/
|
||||
for (int lp = 0; lp < num; lp ++) {
|
||||
retval = retval + (((POWER_HEIGHT - 2) - retval) / POWER_STEP_FACTOR);
|
||||
value -= POWER_STEP_LEVEL;
|
||||
for (int lp = 0; lp < num; lp++) {
|
||||
retval = retval + (((POWER_HEIGHT - 2) - retval) / POWER_STEP_FACTOR);
|
||||
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 = Bound(retval, 0, POWER_HEIGHT-2);
|
||||
retval = Bound(retval, 0, POWER_HEIGHT - 2);
|
||||
return(retval);
|
||||
}
|
||||
|
||||
@@ -439,7 +447,7 @@ int PowerClass::Power_Height(int value)
|
||||
* HISTORY: *
|
||||
* 08/07/1995 JLB : Created. *
|
||||
*=============================================================================================*/
|
||||
int PowerClass::PowerButtonClass::Action(unsigned flags, KeyNumType & key)
|
||||
int PowerClass::PowerButtonClass::Action(unsigned flags, KeyNumType& key)
|
||||
{
|
||||
if (!Map.IsSidebarActive) {
|
||||
return(false);
|
||||
@@ -452,7 +460,8 @@ int PowerClass::PowerButtonClass::Action(unsigned flags, KeyNumType & key)
|
||||
Map.Override_Mouse_Shape(MOUSE_NORMAL);
|
||||
if (PlayerPtr->Power_Fraction() < 1 && PlayerPtr->Power > 0) {
|
||||
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);
|
||||
}
|
||||
GadgetClass::Action(flags, key);
|
||||
|
||||
+279
-241
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user