diff --git a/.gitignore b/.gitignore index 1a561b5..7ea87a2 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ /*.DAT /SAVEGAME* +/cache diff --git a/code/redalert/conquer.cpp b/code/redalert/conquer.cpp index 10a55c5..2614ddc 100644 --- a/code/redalert/conquer.cpp +++ b/code/redalert/conquer.cpp @@ -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; } diff --git a/code/redalert/externs.h b/code/redalert/externs.h index da7f00a..45eb9b1 100644 --- a/code/redalert/externs.h +++ b/code/redalert/externs.h @@ -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; diff --git a/code/redalert/gadget.cpp b/code/redalert/gadget.cpp index 71c1d32..6dba2e5 100644 --- a/code/redalert/gadget.cpp +++ b/code/redalert/gadget.cpp @@ -58,31 +58,31 @@ #include -/* -** 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) { diff --git a/code/redalert/globals.cpp b/code/redalert/globals.cpp index 1c04133..54e06db 100644 --- a/code/redalert/globals.cpp +++ b/code/redalert/globals.cpp @@ -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 diff --git a/code/redalert/io/eventqueue.cpp b/code/redalert/io/eventqueue.cpp index eef7a05..512ec54 100644 --- a/code/redalert/io/eventqueue.cpp +++ b/code/redalert/io/eventqueue.cpp @@ -1,5 +1,5 @@ -#include "../FUNCTION.H" -#include "EventQueue.h" +#include "../function.h" +#include "eventqueue.h" /* Clears the event queue and frees memory diff --git a/code/redalert/io/userinput.cpp b/code/redalert/io/userinput.cpp index 088f926..6c05848 100644 --- a/code/redalert/io/userinput.cpp +++ b/code/redalert/io/userinput.cpp @@ -1,18 +1,60 @@ #include "../function.h" #include "userinput.h" -extern KeyboardClass * Keyboard; +extern KeyboardClass* Keyboard; + +std::map 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)); } } \ No newline at end of file diff --git a/code/redalert/io/userinput.h b/code/redalert/io/userinput.h index 314e75b..412e29c 100644 --- a/code/redalert/io/userinput.h +++ b/code/redalert/io/userinput.h @@ -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; -}; \ No newline at end of file + MouseState Mouse; +private: + int numFramesLMouse = 0; +}; diff --git a/code/redalert/key.cpp b/code/redalert/key.cpp index 90626c7..4e80790 100644 --- a/code/redalert/key.cpp +++ b/code/redalert/key.cpp @@ -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); } diff --git a/code/redalert/options.cpp b/code/redalert/options.cpp index cff3732..734ddb1 100644 --- a/code/redalert/options.cpp +++ b/code/redalert/options.cpp @@ -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 + */ } diff --git a/code/redalert/power.cpp b/code/redalert/power.cpp index b9118ba..8c4edea 100644 --- a/code/redalert/power.cpp +++ b/code/redalert/power.cpp @@ -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); diff --git a/code/redalert/sidebar.cpp b/code/redalert/sidebar.cpp index 2a9912e..06d53d2 100644 --- a/code/redalert/sidebar.cpp +++ b/code/redalert/sidebar.cpp @@ -76,19 +76,19 @@ #include "function.h" -//#undef RESFACTOR -//#define RESFACTOR 1 + //#undef RESFACTOR + //#define RESFACTOR 1 -void * SidebarClass::SidebarShape = NULL; -void * SidebarClass::SidebarMiddleShape = NULL; -void * SidebarClass::SidebarBottomShape = NULL; +void* SidebarClass::SidebarShape = NULL; +void* SidebarClass::SidebarMiddleShape = NULL; +void* SidebarClass::SidebarBottomShape = NULL; /*************************************************************************** ** This holds the translucent table for use with the construction clock ** animation. */ -char SidebarClass::StripClass::ClockTranslucentTable[(1+1)*256]; +char SidebarClass::StripClass::ClockTranslucentTable[(1 + 1) * 256]; /*************************************************************************** @@ -121,9 +121,9 @@ SidebarClass::StripClass::SelectButton[COLUMNS][MAX_VISIBLE]; /* ** Shape data pointers */ -void * SidebarClass::StripClass::LogoShapes = NULL; -void const * SidebarClass::StripClass::ClockShapes; -void const * SidebarClass::StripClass::SpecialShapes[SPC_COUNT]; +void* SidebarClass::StripClass::LogoShapes = NULL; +void const* SidebarClass::StripClass::ClockShapes; +void const* SidebarClass::StripClass::SpecialShapes[SPC_COUNT]; /*********************************************************************************************** @@ -169,16 +169,16 @@ SidebarClass::SidebarClass(void) : * HISTORY: * * 08/06/1996 JLB : Created. * *=============================================================================================*/ -SidebarClass::SidebarClass(NoInitClass const & x) : PowerClass(x) +SidebarClass::SidebarClass(NoInitClass const& x) : PowerClass(x) { /* ** Set up the coordinates for the sidebar strips. These coordinates are for ** the upper left corner. */ -// Column[0].X = COLUMN_ONE_X * RESFACTOR; -// Column[0].Y = COLUMN_ONE_Y * RESFACTOR; -// Column[1].X = COLUMN_TWO_X * RESFACTOR; -// Column[1].Y = COLUMN_TWO_Y * RESFACTOR; + // Column[0].X = COLUMN_ONE_X * RESFACTOR; + // Column[0].Y = COLUMN_ONE_Y * RESFACTOR; + // Column[1].X = COLUMN_TWO_X * RESFACTOR; + // Column[1].Y = COLUMN_TWO_Y * RESFACTOR; } @@ -224,25 +224,25 @@ void SidebarClass::One_Time(void) ** code so that as the sidebar buildable buttons scroll, they get properly ** clipped at the top and bottom edges. */ - WindowList[WINDOW_SIDEBAR][WINDOWX] = ((SIDE_X+8)) * RESFACTOR; + WindowList[WINDOW_SIDEBAR][WINDOWX] = ((SIDE_X + 8)) * RESFACTOR; WindowList[WINDOW_SIDEBAR][WINDOWY] = (SIDE_Y + 1 + TOP_HEIGHT) * RESFACTOR; - WindowList[WINDOW_SIDEBAR][WINDOWWIDTH] = (SIDE_WIDTH) * RESFACTOR; + WindowList[WINDOW_SIDEBAR][WINDOWWIDTH] = (SIDE_WIDTH)*RESFACTOR; WindowList[WINDOW_SIDEBAR][WINDOWHEIGHT] = ScreenHeight; -// WindowList[WINDOW_SIDEBAR][WINDOWHEIGHT] = (StripClass::MAX_VISIBLE * StripClass::OBJECT_HEIGHT-1) * RESFACTOR; + // WindowList[WINDOW_SIDEBAR][WINDOWHEIGHT] = (StripClass::MAX_VISIBLE * StripClass::OBJECT_HEIGHT-1) * RESFACTOR; - /* - ** Top of the window seems to be wrong for the new sidebar. ST - 5/2/96 2:49AM - */ - WindowList[WINDOW_SIDEBAR][WINDOWY] -= 1*RESFACTOR; + /* + ** Top of the window seems to be wrong for the new sidebar. ST - 5/2/96 2:49AM + */ + WindowList[WINDOW_SIDEBAR][WINDOWY] -= 1 * RESFACTOR; /* ** Set up the coordinates for the sidebar strips. These coordinates are for ** the upper left corner. */ -// Column[0].X = COLUMN_ONE_X * RESFACTOR; -// Column[0].Y = COLUMN_ONE_Y * RESFACTOR; -// Column[1].X = COLUMN_TWO_X * RESFACTOR; -// Column[1].Y = COLUMN_TWO_Y * RESFACTOR; + // Column[0].X = COLUMN_ONE_X * RESFACTOR; + // Column[0].Y = COLUMN_ONE_Y * RESFACTOR; + // Column[1].X = COLUMN_TWO_X * RESFACTOR; + // Column[1].Y = COLUMN_TWO_Y * RESFACTOR; Column[0].One_Time(0); Column[1].One_Time(1); @@ -307,8 +307,8 @@ void SidebarClass::Init_IO(void) Repair.IsSticky = true; Repair.ID = BUTTON_REPAIR; - Repair.X = ScreenWidth - (640 - (0x1f2/2)*RESFACTOR); - Repair.Y = (0x96/2)*RESFACTOR; + Repair.X = ScreenWidth - (640 - (0x1f2 / 2) * RESFACTOR); + Repair.Y = (0x96 / 2) * RESFACTOR; Repair.IsPressed = false; Repair.IsToggleType = true; Repair.ReflectButtonState = true; @@ -317,7 +317,7 @@ void SidebarClass::Init_IO(void) Upgrade.IsSticky = true; Upgrade.ID = BUTTON_UPGRADE; Upgrade.X = ScreenWidth - (640 - 0x21f); - Upgrade.Y = (0x96/2)*RESFACTOR; + Upgrade.Y = (0x96 / 2) * RESFACTOR; Upgrade.IsPressed = false; Upgrade.IsToggleType = true; Upgrade.ReflectButtonState = true; @@ -325,14 +325,15 @@ void SidebarClass::Init_IO(void) Zoom.IsSticky = true; Zoom.ID = BUTTON_ZOOM; - Zoom.X = ScreenWidth - (640 - ((0x24c/2)*RESFACTOR)); - Zoom.Y = (0x96/2)*RESFACTOR; + Zoom.X = ScreenWidth - (640 - ((0x24c / 2) * RESFACTOR)); + Zoom.Y = (0x96 / 2) * RESFACTOR; Zoom.IsPressed = false; Zoom.Set_Shape(MFCD::Retrieve("MAP.SHP")); if ((IsRadarActive && Is_Zoomable()) || Session.Type != GAME_NORMAL) { Zoom.Enable(); - } else { + } + else { Zoom.Disable(); } Column[0].Init_IO(0); @@ -344,8 +345,8 @@ void SidebarClass::Init_IO(void) if (IsSidebarActive) { IsSidebarActive = false; Activate(1); -// Background.Zap(); -// Add_A_Button(Background); + // Background.Zap(); + // Add_A_Button(Background); } } } @@ -388,7 +389,7 @@ void SidebarClass::Init_Theater(TheaterType theater) *=============================================================================================*/ void SidebarClass::Reload_Sidebar(void) { - static char * sidebarnames[]={ + static char* sidebarnames[] = { "SIDE?NA.SHP", //NATO "SIDE?NA.SHP", "SIDE?US.SHP", //USSR @@ -402,18 +403,18 @@ void SidebarClass::Reload_Sidebar(void) }; int houseloaded = 0; - if(PlayerPtr) { + if (PlayerPtr) { houseloaded = PlayerPtr->ActLike; } /* Don't have write access to the static char array. ST - 5/20/2019 */ #if (0) - char * sidename = sidebarnames[houseloaded]; - *(sidename+4) = '1'; + char* sidename = sidebarnames[houseloaded]; + *(sidename + 4) = '1'; SidebarShape = (void*)MFCD::Retrieve(sidename); - *(sidename+4) = '2'; + *(sidename + 4) = '2'; SidebarMiddleShape = (void*)MFCD::Retrieve(sidename); - *(sidename+4) = '3'; + *(sidename + 4) = '3'; SidebarBottomShape = (void*)MFCD::Retrieve(sidename); #else char sb_name[16]; @@ -506,7 +507,7 @@ bool SidebarClass::Factory_Link(int factory, RTTIType type, int id) * HISTORY: * * 01/19/1995 JLB : Created. * *=============================================================================================*/ -void SidebarClass::Refresh_Cells(CELL cell, short const * list) +void SidebarClass::Refresh_Cells(CELL cell, short const* list) { if (*list == REFRESH_SIDEBAR) { IsToRedraw = true; @@ -544,14 +545,14 @@ bool SidebarClass::Activate_Repair(int control) control = IsRepairActive ? 0 : 1; } switch (control) { - case 1: - IsRepairActive = true; - break; + case 1: + IsRepairActive = true; + break; - default: - case 0: - IsRepairActive = false; - break; + default: + case 0: + IsRepairActive = false; + break; } if (old != IsRepairActive) { Flag_To_Redraw(false); @@ -591,14 +592,14 @@ bool SidebarClass::Activate_Upgrade(int control) control = IsUpgradeActive ? 0 : 1; } switch (control) { - case 1: - IsUpgradeActive = true; - break; + case 1: + IsUpgradeActive = true; + break; - default: - case 0: - IsUpgradeActive = false; - break; + default: + case 0: + IsUpgradeActive = false; + break; } if (old != IsUpgradeActive) { Flag_To_Redraw(false); @@ -637,14 +638,14 @@ bool SidebarClass::Activate_Demolish(int control) control = IsDemolishActive ? 0 : 1; } switch (control) { - case 1: - IsDemolishActive = true; - break; + case 1: + IsDemolishActive = true; + break; - default: - case 0: - IsDemolishActive = false; - break; + default: + case 0: + IsDemolishActive = false; + break; } if (old != IsDemolishActive) { Flag_To_Redraw(false); @@ -759,15 +760,12 @@ bool SidebarClass::Scroll(bool up, int column) *=============================================================================================*/ void SidebarClass::Draw_It(bool complete) { - /* Draw black background */ - GL_FillRect(TBLACK, SIDE_X * RESFACTOR, 8 * RESFACTOR, SIDE_WIDTH * RESFACTOR, ScreenHeight - (8 * RESFACTOR)); - PowerClass::Draw_It(complete); BStart(BENCH_SIDEBAR); if (IsSidebarActive && (IsToRedraw || complete) && !Debug_Map) { - // IsToRedraw = false; + // IsToRedraw = false; if (LogicPage->Lock()) { /* @@ -775,9 +773,9 @@ void SidebarClass::Draw_It(bool complete) */ int shape = complete ? 0 : 1; - CC_Draw_Shape(SidebarShape, 0, SIDE_X * RESFACTOR, 8*RESFACTOR, WINDOW_MAIN, SHAPE_WIN_REL); + CC_Draw_Shape(SidebarShape, 0, SIDE_X * RESFACTOR, 8 * RESFACTOR, WINDOW_MAIN, SHAPE_WIN_REL); - CC_Draw_Shape(SidebarMiddleShape, shape, SIDE_X * RESFACTOR, (8+80)*RESFACTOR, WINDOW_MAIN, SHAPE_WIN_REL); + CC_Draw_Shape(SidebarMiddleShape, shape, SIDE_X * RESFACTOR, (8 + 80) * RESFACTOR, WINDOW_MAIN, SHAPE_WIN_REL); CC_Draw_Shape(SidebarBottomShape, shape, SIDE_X * RESFACTOR, ScreenHeight - (80 * RESFACTOR) + 3, WINDOW_MAIN, SHAPE_WIN_REL); @@ -829,7 +827,7 @@ void SidebarClass::Draw_It(bool complete) * 12/31/1994 JLB : Uses mouse coordinate parameters. * * 06/27/1995 JLB : key toggles sidebar. * *=============================================================================================*/ -void SidebarClass::AI(KeyNumType & input, int x, int y) +void SidebarClass::AI(KeyNumType& input, int x, int y) { bool redraw = true; @@ -893,19 +891,20 @@ void SidebarClass::AI(KeyNumType & input, int x, int y) */ if (PlayerPtr->BScan) { Activate_Repair(true); - } else { + } + else { Activate_Repair(false); } - if (input == (BUTTON_REPAIR|KN_BUTTON)) { + if (input == (BUTTON_REPAIR | KN_BUTTON)) { Repair_Mode_Control(-1); } - if (input == (BUTTON_ZOOM|KN_BUTTON)) { + if (input == (BUTTON_ZOOM | KN_BUTTON)) { Zoom_Mode_Control(); } - if (input == (BUTTON_UPGRADE|KN_BUTTON)) { + if (input == (BUTTON_UPGRADE | KN_BUTTON)) { Sell_Mode_Control(-1); } @@ -1004,18 +1003,18 @@ bool SidebarClass::Activate(int control) ** Determine the new state of the sidebar. */ switch (control) { - case -1: - IsSidebarActive = IsSidebarActive == false; - break; + case -1: + IsSidebarActive = IsSidebarActive == false; + break; - case 1: - IsSidebarActive = true; - break; + case 1: + IsSidebarActive = true; + break; - default: - case 0: - IsSidebarActive = false; - break; + default: + case 0: + IsSidebarActive = false; + break; } /* @@ -1029,7 +1028,7 @@ bool SidebarClass::Activate(int control) ** activate it on the left side of the screen. */ if (IsSidebarActive /*&& X*/) { - Set_View_Dimensions( 0, 8 * RESFACTOR, SeenBuff.Get_Width() - ( SIDE_WIDTH * RESFACTOR ) ); + Set_View_Dimensions(0, 8 * RESFACTOR, SeenBuff.Get_Width() - (SIDE_WIDTH * RESFACTOR)); IsToRedraw = true; Help_Text(TXT_NONE); @@ -1047,7 +1046,8 @@ bool SidebarClass::Activate(int control) Add_A_Button(Map.RadarButton); Map.PowerButton.Zap(); Add_A_Button(Map.PowerButton); - } else { + } + else { Help_Text(TXT_NONE); Set_View_Dimensions(0, 0); Remove_A_Button(Repair); @@ -1085,7 +1085,7 @@ bool SidebarClass::Activate(int control) * HISTORY: * * 12/31/1994 JLB : Created. * *=============================================================================================*/ -SidebarClass::StripClass::StripClass(InitClass const & ) : +SidebarClass::StripClass::StripClass(InitClass const&) : X(0), Y(0), ID(0), @@ -1123,11 +1123,11 @@ SidebarClass::StripClass::StripClass(InitClass const & ) : * HISTORY: * * 12/31/1994 JLB : Created. * *=============================================================================================*/ -void SidebarClass::StripClass::One_Time(int ) +void SidebarClass::StripClass::One_Time(int) { // Sidebar height HEIGHT = ScreenHeight; - MaxButtonsVisible = ( HEIGHT - ( ( SIDE_Y + TOP_HEIGHT + OBJECT_HEIGHT ) * RESFACTOR ) ) / ( OBJECT_HEIGHT * RESFACTOR ); + MaxButtonsVisible = (HEIGHT - ((SIDE_Y + TOP_HEIGHT + OBJECT_HEIGHT) * RESFACTOR)) / (OBJECT_HEIGHT * RESFACTOR); /* ** Sidebar is player team specific in Hires @@ -1138,7 +1138,7 @@ void SidebarClass::StripClass::One_Time(int ) char buffer[_MAX_FNAME]; sprintf(buffer, "%sICON", SpecialWeaponFile[lp]); - char fullname[_MAX_FNAME+_MAX_EXT]; + char fullname[_MAX_FNAME + _MAX_EXT]; _makepath(fullname, NULL, NULL, buffer, ".SHP"); SpecialShapes[lp] = MFCD::Retrieve(fullname); } @@ -1160,7 +1160,7 @@ void SidebarClass::StripClass::One_Time(int ) * HISTORY: * * 05/19/1995 JLB : commented * *=============================================================================================*/ -void const * SidebarClass::StripClass::Get_Special_Cameo(SpecialWeaponType type) +void const* SidebarClass::StripClass::Get_Special_Cameo(SpecialWeaponType type) { if ((unsigned)type < SPC_COUNT) { return(SpecialShapes[type]); @@ -1222,25 +1222,25 @@ void SidebarClass::StripClass::Init_IO(int id) ID = id; UpButton[ID].IsSticky = true; - UpButton[ID].ID = BUTTON_UP+id; + UpButton[ID].ID = BUTTON_UP + id; UpButton[ID].X = X + (UP_X_OFFSET * RESFACTOR); - UpButton[ID].Y = HEIGHT - ( ( OBJECT_HEIGHT + 7 ) * RESFACTOR ); + UpButton[ID].Y = HEIGHT - ((OBJECT_HEIGHT + 7) * RESFACTOR); UpButton[ID].Set_Shape(MFCD::Retrieve("STRIPUP.SHP")); DownButton[ID].IsSticky = true; - DownButton[ID].ID = BUTTON_DOWN+id; + DownButton[ID].ID = BUTTON_DOWN + id; DownButton[ID].X = X + (DOWN_X_OFFSET * RESFACTOR); - DownButton[ID].Y = HEIGHT - ( (OBJECT_HEIGHT + 7 ) * RESFACTOR ); + DownButton[ID].Y = HEIGHT - ((OBJECT_HEIGHT + 7) * RESFACTOR); DownButton[ID].Set_Shape(MFCD::Retrieve("STRIPDN.SHP")); UpButton[ID].Y += 3; DownButton[ID].Y += 3; for (int index = 0; index < MaxButtonsVisible; index++) { - SelectClass & g = SelectButton[ID][index]; + SelectClass& g = SelectButton[ID][index]; g.ID = BUTTON_SELECT; g.X = X; - g.Y = Y + ((OBJECT_HEIGHT*index) * RESFACTOR); + g.Y = Y + ((OBJECT_HEIGHT * index) * RESFACTOR); g.Width = OBJECT_WIDTH * RESFACTOR; g.Height = OBJECT_HEIGHT * RESFACTOR; g.Set_Owner(*this, index); @@ -1265,28 +1265,28 @@ void SidebarClass::StripClass::Init_Theater(TheaterType theater) Reload_LogoShapes(); - if ( (theater != THEATER_NONE) && (theater != ::LastTheater)) { + if ((theater != THEATER_NONE) && (theater != ::LastTheater)) { static TLucentType const ClockCols[1] = { {GREEN, BLACK, 100, 0} -// {GREEN, LTGREY, 180, 0} + // {GREEN, LTGREY, 180, 0} }; /* ** Make sure that remapping doesn't occur on the colors that cycle. */ PaletteClass pal = OriginalPalette; - memset(&pal[CYCLE_COLOR_START*3], 0x3f, CYCLE_COLOR_COUNT*3); + memset(&pal[CYCLE_COLOR_START * 3], 0x3f, CYCLE_COLOR_COUNT * 3); Build_Translucent_Table(pal, &ClockCols[0], 1, (void*)ClockTranslucentTable); -// Mem_Copy(GamePalette, OriginalPalette, 768); -// memset(&GamePalette[CYCLE_COLOR_START*3], 0x3f, CYCLE_COLOR_COUNT*3); + // Mem_Copy(GamePalette, OriginalPalette, 768); + // memset(&GamePalette[CYCLE_COLOR_START*3], 0x3f, CYCLE_COLOR_COUNT*3); - /* - ** Create the translucent table used for the sidebar. - */ -// Build_Translucent_Table(GamePalette, &ClockCols[0], 1, (void*)ClockTranslucentTable); -// GamePalette = OriginalPalette; + /* + ** Create the translucent table used for the sidebar. + */ + // Build_Translucent_Table(GamePalette, &ClockCols[0], 1, (void*)ClockTranslucentTable); + // GamePalette = OriginalPalette; Conquer_Build_Fading_Table(GamePalette, &ClockTranslucentTable[256], BLACK, 100); } @@ -1297,7 +1297,7 @@ void SidebarClass::StripClass::Reload_LogoShapes(void) /* ** Load hi-res strip art here since it is player side specific */ - static char * stripnames[]={ + static char* stripnames[] = { "stripna.shp", //Nato "stripna.shp", "stripus.shp", //USSR @@ -1315,13 +1315,13 @@ void SidebarClass::StripClass::Reload_LogoShapes(void) ** Sidebar art is dependent on the side of the player */ - if(PlayerPtr) { + if (PlayerPtr) { houseloaded = PlayerPtr->ActLike; } -// jmarshall + // jmarshall if (houseloaded >= HOUSE_BAD) return; -// jmarshall end + // jmarshall end LogoShapes = (void*)MFCD::Retrieve(stripnames[houseloaded]); } @@ -1444,8 +1444,9 @@ bool SidebarClass::StripClass::Scroll(bool up) if (up) { if (!TopIndex) return(false); Scroller--; - } else { - if ( TopIndex+ MaxButtonsVisible >= BuildableCount ) return(false); + } + else { + if (TopIndex + MaxButtonsVisible >= BuildableCount) return(false); Scroller++; } return(true); @@ -1496,7 +1497,7 @@ void SidebarClass::StripClass::Flag_To_Redraw(void) * 12/31/1994 JLB : Created. * * 12/31/1994 JLB : Uses mouse coordinate parameters. * *=============================================================================================*/ -bool SidebarClass::StripClass::AI(KeyNumType & input, int , int ) +bool SidebarClass::StripClass::AI(KeyNumType& input, int, int) { bool redraw = false; @@ -1504,13 +1505,13 @@ bool SidebarClass::StripClass::AI(KeyNumType & input, int , int ) ** If this is scroll button for this side strip, then scroll the strip as ** indicated. */ - if (input == (UpButton[ID].ID|KN_BUTTON)) { // && !IsScrolling + if (input == (UpButton[ID].ID | KN_BUTTON)) { // && !IsScrolling UpButton[ID].IsPressed = false; if (!Scroll(true)) { Sound_Effect(VOC_SCOLD); } } - if (input == (DownButton[ID].ID|KN_BUTTON)) { // && !IsScrolling + if (input == (DownButton[ID].ID | KN_BUTTON)) { // && !IsScrolling DownButton[ID].IsPressed = false; if (!Scroll(false)) { Sound_Effect(VOC_SCOLD); @@ -1522,9 +1523,10 @@ bool SidebarClass::StripClass::AI(KeyNumType & input, int , int ) ** logic handler. This might result in up or down scrolling. */ if (!IsScrolling && Scroller) { - if (BuildableCount <= MaxButtonsVisible ) { + if (BuildableCount <= MaxButtonsVisible) { Scroller = 0; - } else { + } + else { /* ** Top of list is moving toward lower ordered entries in the object list. It looks like @@ -1534,7 +1536,8 @@ bool SidebarClass::StripClass::AI(KeyNumType & input, int , int ) if (Scroller < 0) { if (!TopIndex) { Scroller = 0; - } else { + } + else { Scroller++; IsScrollingDown = false; IsScrolling = true; @@ -1542,10 +1545,12 @@ bool SidebarClass::StripClass::AI(KeyNumType & input, int , int ) Slid = 0; } - } else { + } + else { if (TopIndex + MaxButtonsVisible >= BuildableCount) { Scroller = 0; - } else { + } + else { Scroller--; Slid = OBJECT_HEIGHT; IsScrollingDown = true; @@ -1566,7 +1571,8 @@ bool SidebarClass::StripClass::AI(KeyNumType & input, int , int ) Slid = 0; TopIndex++; } - } else { + } + else { Slid += SCROLL_RATE; if (Slid >= OBJECT_HEIGHT) { IsScrolling = false; @@ -1599,7 +1605,7 @@ bool SidebarClass::StripClass::AI(KeyNumType & input, int , int ) int factoryid = Buildables[index].Factory; if (factoryid != -1) { - FactoryClass * factory = Factories.Raw_Ptr(factoryid); + FactoryClass* factory = Factories.Raw_Ptr(factoryid); if (factory && (factory->Has_Changed() || factory->Is_Blocked())) { redraw = true; @@ -1611,28 +1617,28 @@ bool SidebarClass::StripClass::AI(KeyNumType & input, int , int ) ** the main exception to the ability to leave the factory under their own ** power. */ - TechnoClass * pending = factory->Get_Object(); + TechnoClass* pending = factory->Get_Object(); if (pending != NULL) { switch (pending->What_Am_I()) { - case RTTI_VESSEL: - case RTTI_UNIT: - case RTTI_AIRCRAFT: - OutList.Add(EventClass(EventClass::PLACE, pending->What_Am_I(), -1)); - if (!factory->Is_Blocked()) { - Speak(VOX_UNIT_READY); - } - break; + case RTTI_VESSEL: + case RTTI_UNIT: + case RTTI_AIRCRAFT: + OutList.Add(EventClass(EventClass::PLACE, pending->What_Am_I(), -1)); + if (!factory->Is_Blocked()) { + Speak(VOX_UNIT_READY); + } + break; - case RTTI_BUILDING: - Speak(VOX_CONSTRUCTION); - break; + case RTTI_BUILDING: + Speak(VOX_CONSTRUCTION); + break; - case RTTI_INFANTRY: - OutList.Add(EventClass(EventClass::PLACE, pending->What_Am_I(), -1)); - if (!factory->Is_Blocked()) { - Speak(VOX_UNIT_READY); - } - break; + case RTTI_INFANTRY: + OutList.Add(EventClass(EventClass::PLACE, pending->What_Am_I(), -1)); + if (!factory->Is_Blocked()) { + Speak(VOX_UNIT_READY); + } + break; } } } @@ -1673,7 +1679,7 @@ bool SidebarClass::StripClass::AI(KeyNumType & input, int , int ) void SidebarClass::StripClass::Draw_It(bool complete) { if (IsToRedraw || complete) { - // IsToRedraw = false; + // IsToRedraw = false; if (RunningAsDLL) { return; @@ -1688,8 +1694,8 @@ void SidebarClass::StripClass::Draw_It(bool complete) /* ** New sidebar needs to be drawn not filled */ - if ( BuildableCount < MaxButtonsVisible ) { - CC_Draw_Shape( LogoShapes, ID, X+(2*RESFACTOR), Y, WINDOW_MAIN, SHAPE_WIN_REL|SHAPE_NORMAL, 0); + if (BuildableCount < MaxButtonsVisible) { + CC_Draw_Shape(LogoShapes, ID, X + (2 * RESFACTOR), Y, WINDOW_MAIN, SHAPE_WIN_REL | SHAPE_NORMAL, 0); } /* @@ -1707,20 +1713,20 @@ void SidebarClass::StripClass::Draw_It(bool complete) bool completed; int stage; bool darken = false; - void const * shapefile = 0; + void const* shapefile = 0; int shapenum = 0; - void const * remapper = 0; - FactoryClass * factory = 0; - int index = i+TopIndex; + void const* remapper = 0; + FactoryClass* factory = 0; + int index = i + TopIndex; int x = X; - int y = Y + (i*OBJECT_HEIGHT * RESFACTOR); + int y = Y + (i * OBJECT_HEIGHT * RESFACTOR); /* ** If the strip is scrolling, then the offset is adjusted accordingly. */ if (IsScrolling) { - y -= (OBJECT_HEIGHT - Slid) * RESFACTOR; -// y -= OBJECT_HEIGHT - Slid; + y -= (OBJECT_HEIGHT - Slid) * RESFACTOR; + // y -= OBJECT_HEIGHT - Slid; } /* @@ -1728,7 +1734,7 @@ void SidebarClass::StripClass::Draw_It(bool complete) ** slot. This shape pointer is used to draw the underlying graphic there. */ if (index < BuildableCount) { - ObjectTypeClass const * obj = NULL; + ObjectTypeClass const* obj = NULL; SpecialWeaponType spc = SPC_NONE; if (Buildables[index].BuildableType != RTTI_SPECIAL) { @@ -1740,7 +1746,7 @@ void SidebarClass::StripClass::Draw_It(bool complete) ** Fetch the remap table that is appropriate for this object ** type. */ - remapper = PlayerPtr->Remap_Table(false, ((TechnoTypeClass const *)obj)->Remap); + remapper = PlayerPtr->Remap_Table(false, ((TechnoTypeClass const*)obj)->Remap); /* ** If there is already a factory producing this kind of object, then all @@ -1759,28 +1765,31 @@ void SidebarClass::StripClass::Draw_It(bool complete) } shapefile = obj->Get_Cameo_Data(); - shapenum = 0; + shapenum = 0; if (Buildables[index].Factory != -1) { - factory = Factories.Raw_Ptr(Buildables[index].Factory); - production = true; - completed = factory->Has_Completed(); - stage = factory->Completion(); - darken = false; - } else { - production = false; -// darken = IsBuilding; + factory = Factories.Raw_Ptr(Buildables[index].Factory); + production = true; + completed = factory->Has_Completed(); + stage = factory->Completion(); + darken = false; + } + else { + production = false; + // darken = IsBuilding; - /* - ** Darken the imagery if a factory of a matching type is - ** already busy. - */ + /* + ** Darken the imagery if a factory of a matching type is + ** already busy. + */ darken = isbusy; } - } else { + } + else { darken = PlayerPtr->Is_Hack_Prevented(Buildables[index].BuildableType, Buildables[index].BuildableID); } - } else { + } + else { spc = SpecialWeaponType(Buildables[index].BuildableID); shapefile = Get_Special_Cameo(spc); @@ -1801,16 +1810,18 @@ void SidebarClass::StripClass::Draw_It(bool complete) remapper = Map.FadingLight; } - } else { - shapefile = LogoShapes; + } + else { + shapefile = LogoShapes; if (!darken) { - shapenum = SB_BLANK; + shapenum = SB_BLANK; } } - } else { - shapefile = LogoShapes; - shapenum = SB_BLANK; - production = false; + } + else { + shapefile = LogoShapes; + shapenum = SB_BLANK; + production = false; } remapper = 0; @@ -1823,10 +1834,10 @@ void SidebarClass::StripClass::Draw_It(bool complete) */ if (shapenum != SB_BLANK || shapefile != LogoShapes) { CC_Draw_Shape(shapefile, shapenum, - x-(WindowList[WINDOW_SIDEBAR][WINDOWX])+(LEFT_EDGE_OFFSET * RESFACTOR), - y-WindowList[WINDOW_SIDEBAR][WINDOWY], + x - (WindowList[WINDOW_SIDEBAR][WINDOWX]) + (LEFT_EDGE_OFFSET * RESFACTOR), + y - WindowList[WINDOW_SIDEBAR][WINDOWY], WINDOW_SIDEBAR, - SHAPE_NORMAL|SHAPE_WIN_REL| (remapper ? SHAPE_FADING : SHAPE_NORMAL), + SHAPE_NORMAL | SHAPE_WIN_REL | (remapper ? SHAPE_FADING : SHAPE_NORMAL), remapper); /* @@ -1835,11 +1846,11 @@ void SidebarClass::StripClass::Draw_It(bool complete) */ if (darken) { CC_Draw_Shape(ClockShapes, 0, - x-(WindowList[WINDOW_SIDEBAR][WINDOWX])+(LEFT_EDGE_OFFSET * RESFACTOR), - y-WindowList[WINDOW_SIDEBAR][WINDOWY], + x - (WindowList[WINDOW_SIDEBAR][WINDOWX]) + (LEFT_EDGE_OFFSET * RESFACTOR), + y - WindowList[WINDOW_SIDEBAR][WINDOWY], WINDOW_SIDEBAR, - SHAPE_NORMAL|SHAPE_WIN_REL|SHAPE_GHOST, - NULL, ClockTranslucentTable); + SHAPE_NORMAL | SHAPE_WIN_REL | SHAPE_GHOST, + NULL, ClockTranslucentTable); } } @@ -1854,26 +1865,27 @@ void SidebarClass::StripClass::Draw_It(bool complete) ** Display text showing that the object is ready to place. */ CC_Draw_Shape(ObjectTypeClass::PipShapes, PIP_READY, - (x-(WindowList[WINDOW_SIDEBAR][WINDOWX]))+(LEFT_EDGE_OFFSET+15) * RESFACTOR, - (y-WindowList[WINDOW_SIDEBAR][WINDOWY])+(4 * RESFACTOR), - WINDOW_SIDEBAR, SHAPE_CENTER); - } else { + (x - (WindowList[WINDOW_SIDEBAR][WINDOWX])) + (LEFT_EDGE_OFFSET + 15) * RESFACTOR, + (y - WindowList[WINDOW_SIDEBAR][WINDOWY]) + (4 * RESFACTOR), + WINDOW_SIDEBAR, SHAPE_CENTER); + } + else { - CC_Draw_Shape(ClockShapes, stage+1, - x-(WindowList[WINDOW_SIDEBAR][WINDOWX])+(LEFT_EDGE_OFFSET * RESFACTOR), - y-WindowList[WINDOW_SIDEBAR][WINDOWY], - WINDOW_SIDEBAR, - SHAPE_NORMAL|SHAPE_WIN_REL|SHAPE_GHOST, - NULL, ClockTranslucentTable); + CC_Draw_Shape(ClockShapes, stage + 1, + x - (WindowList[WINDOW_SIDEBAR][WINDOWX]) + (LEFT_EDGE_OFFSET * RESFACTOR), + y - WindowList[WINDOW_SIDEBAR][WINDOWY], + WINDOW_SIDEBAR, + SHAPE_NORMAL | SHAPE_WIN_REL | SHAPE_GHOST, + NULL, ClockTranslucentTable); /* ** Display text showing that the construction is temporarily on hold. */ if (factory && !factory->Is_Building()) { CC_Draw_Shape(ObjectTypeClass::PipShapes, PIP_HOLDING, - (x-(WindowList[WINDOW_SIDEBAR][WINDOWX])) + ((LEFT_EDGE_OFFSET+15) * RESFACTOR), - (y-WindowList[WINDOW_SIDEBAR][WINDOWY])+(4 * RESFACTOR), - WINDOW_SIDEBAR, SHAPE_CENTER); + (x - (WindowList[WINDOW_SIDEBAR][WINDOWX])) + ((LEFT_EDGE_OFFSET + 15) * RESFACTOR), + (y - WindowList[WINDOW_SIDEBAR][WINDOWY]) + (4 * RESFACTOR), + WINDOW_SIDEBAR, SHAPE_CENTER); } } } @@ -1919,13 +1931,15 @@ bool SidebarClass::StripClass::Recalc(void) */ bool redraw = false; for (int index = 0; index < BuildableCount; index++) { - TechnoTypeClass const * tech = Fetch_Techno_Type(Buildables[index].BuildableType, Buildables[index].BuildableID); + TechnoTypeClass const* tech = Fetch_Techno_Type(Buildables[index].BuildableType, Buildables[index].BuildableID); if (tech != NULL) { ok = tech->Who_Can_Build_Me(true, false, PlayerPtr->Class->House) != NULL; - } else { + } + else { if ((unsigned)Buildables[index].BuildableID < SPC_COUNT) { ok = PlayerPtr->SuperWeapon[Buildables[index].BuildableID].Is_Present(); - } else { + } + else { ok = false; } } @@ -1935,8 +1949,8 @@ bool SidebarClass::StripClass::Recalc(void) /* ** Removes this entry from the list. */ - if (BuildableCount > 1 && index < BuildableCount-1) { - memcpy(&Buildables[index], &Buildables[index+1], sizeof(Buildables[0])*((BuildableCount-index)-1)); + if (BuildableCount > 1 && index < BuildableCount - 1) { + memcpy(&Buildables[index], &Buildables[index + 1], sizeof(Buildables[0]) * ((BuildableCount - index) - 1)); } TopIndex = 0; IsToRedraw = true; @@ -1975,7 +1989,7 @@ bool SidebarClass::StripClass::Recalc(void) * 01/19/1995 JLB : Created. * *=============================================================================================*/ SidebarClass::StripClass::SelectClass::SelectClass(void) : - ControlClass(0, 0, 0, (OBJECT_WIDTH-1) * RESFACTOR, OBJECT_HEIGHT * RESFACTOR, LEFTPRESS|RIGHTPRESS|LEFTUP), + ControlClass(0, 0, 0, (OBJECT_WIDTH - 1)* RESFACTOR, OBJECT_HEIGHT* RESFACTOR, LEFTPRESS | RIGHTPRESS | LEFTUP), Strip(0), Index(0) { @@ -2001,7 +2015,7 @@ SidebarClass::StripClass::SelectClass::SelectClass(void) : * HISTORY: * * 01/19/1995 JLB : Created. * *=============================================================================================*/ -void SidebarClass::StripClass::SelectClass::Set_Owner(StripClass & strip, int index) +void SidebarClass::StripClass::SelectClass::Set_Owner(StripClass& strip, int index) { Strip = &strip; Index = index; @@ -2028,7 +2042,7 @@ void SidebarClass::StripClass::SelectClass::Set_Owner(StripClass & strip, int in * 01/19/1995 JLB : Created. * * 10/09/1996 JLB : Sonar pulse converted to regular event type. * *=============================================================================================*/ -int SidebarClass::StripClass::SelectClass::Action(unsigned flags, KeyNumType & key) +int SidebarClass::StripClass::SelectClass::Action(unsigned flags, KeyNumType& key) { if (Strip == NULL) return 0; @@ -2036,9 +2050,9 @@ int SidebarClass::StripClass::SelectClass::Action(unsigned flags, KeyNumType & k RTTIType otype = Strip->Buildables[index].BuildableType; int oid = Strip->Buildables[index].BuildableID; int fnumber = Strip->Buildables[index].Factory; - RemapControlType * scheme = GadgetClass::Get_Color_Scheme(); + RemapControlType* scheme = GadgetClass::Get_Color_Scheme(); - ObjectTypeClass const * choice = NULL; + ObjectTypeClass const* choice = NULL; SpecialWeaponType spc = SPC_NONE; /* @@ -2048,14 +2062,15 @@ int SidebarClass::StripClass::SelectClass::Action(unsigned flags, KeyNumType & k ** kind of factory is specified by the "genfactory" value. This can be used to see ** if the factory type is currently busy or not. */ - FactoryClass * factory = PlayerPtr->Fetch_Factory(otype); + FactoryClass* factory = PlayerPtr->Fetch_Factory(otype); Map.Override_Mouse_Shape(MOUSE_NORMAL); if (index < Strip->BuildableCount) { if (otype != RTTI_SPECIAL) { - choice = Fetch_Techno_Type(otype, oid); - } else { + choice = Fetch_Techno_Type(otype, oid); + } + else { spc = SpecialWeaponType(oid); } @@ -2063,9 +2078,10 @@ int SidebarClass::StripClass::SelectClass::Action(unsigned flags, KeyNumType & k factory = Factories.Raw_Ptr(fnumber); } - } else { - Map.Help_Text(TXT_NONE); - } + } + else { + Map.Help_Text(TXT_NONE); + } if (spc != SPC_NONE) { @@ -2096,16 +2112,19 @@ int SidebarClass::StripClass::SelectClass::Action(unsigned flags, KeyNumType & k Map.IsTargettingMode = spc; Unselect_All(); Speak(VOX_SELECT_TARGET); - } else { + } + else { OutList.Add(EventClass(EventClass::SPECIAL_PLACE, SPC_SONAR_PULSE, 0)); } - } else { + } + else { PlayerPtr->SuperWeapon[spc].Impatient_Click(); } } } - } else { + } + else { if (choice != NULL) { @@ -2145,7 +2164,8 @@ int SidebarClass::StripClass::SelectClass::Action(unsigned flags, KeyNumType & k if (!factory->Is_Building()) { Speak(VOX_CANCELED); OutList.Add(EventClass(EventClass::ABANDON, otype, oid)); - } else { + } + else { Speak(VOX_SUSPENDED); OutList.Add(EventClass(EventClass::SUSPEND, otype, oid)); Map.Column[0].IsToRedraw = true; @@ -2175,7 +2195,8 @@ int SidebarClass::StripClass::SelectClass::Action(unsigned flags, KeyNumType & k */ if (factory->Is_Building()) { Speak(VOX_NO_FACTORY); - } else { + } + else { /* ** If production has completed, then attempt to have the object exit @@ -2183,15 +2204,17 @@ int SidebarClass::StripClass::SelectClass::Action(unsigned flags, KeyNumType & k */ if (factory->Has_Completed()) { - TechnoClass * pending = factory->Get_Object(); + TechnoClass* pending = factory->Get_Object(); if (!pending && factory->Get_Special_Item()) { Map.IsTargettingMode = SPC_ANY; - } else { - BuildingClass * builder = pending->Who_Can_Build_Me(false, false); + } + else { + BuildingClass* builder = pending->Who_Can_Build_Me(false, false); if (!builder) { OutList.Add(EventClass(EventClass::ABANDON, otype, oid)); Speak(VOX_NO_FACTORY); - } else { + } + else { /* ** If the completed object is a building, then change the @@ -2200,8 +2223,9 @@ int SidebarClass::StripClass::SelectClass::Action(unsigned flags, KeyNumType & k ** the building is actually placed down. */ if (pending->What_Am_I() == RTTI_BUILDING) { - PlayerPtr->Manual_Place(builder, (BuildingClass *)pending); - } else { + PlayerPtr->Manual_Place(builder, (BuildingClass*)pending); + } + else { /* ** For objects that can leave the factory under their own @@ -2212,18 +2236,21 @@ int SidebarClass::StripClass::SelectClass::Action(unsigned flags, KeyNumType & k } } } - } else { + } + else { if (PlayerPtr->Is_Hack_Prevented(otype, oid)) { // Eva scolds the player here. - } else { + } + else { /* ** The factory must have been in a suspended state. Resume construction ** normally. */ if (otype == RTTI_INFANTRYTYPE) { Speak(VOX_TRAINING); - } else { + } + else { Speak(VOX_BUILDING); } OutList.Add(EventClass(EventClass::PRODUCE, Strip->Buildables[index].BuildableType, Strip->Buildables[index].BuildableID)); @@ -2231,11 +2258,13 @@ int SidebarClass::StripClass::SelectClass::Action(unsigned flags, KeyNumType & k } } - } else { + } + else { if (PlayerPtr->Is_Hack_Prevented(otype, oid)) { // Eva scolds the player here. - } else { + } + else { /* ** If this side strip is already busy with production, then ignore the @@ -2243,14 +2272,16 @@ int SidebarClass::StripClass::SelectClass::Action(unsigned flags, KeyNumType & k */ if (otype == RTTI_INFANTRYTYPE) { Speak(VOX_TRAINING); - } else { + } + else { Speak(VOX_BUILDING); } OutList.Add(EventClass(EventClass::PRODUCE, Strip->Buildables[index].BuildableType, Strip->Buildables[index].BuildableID)); } } } - } else { + } + else { flags = 0; } } @@ -2277,7 +2308,7 @@ int SidebarClass::StripClass::SelectClass::Action(unsigned flags, KeyNumType & k * HISTORY: * * 03/28/1995 JLB : Created. * *=============================================================================================*/ -int SidebarClass::SBGadgetClass::Action(unsigned , KeyNumType & ) +int SidebarClass::SBGadgetClass::Action(unsigned, KeyNumType&) { Map.Help_Text(TXT_NONE); Map.Override_Mouse_Shape(MOUSE_NORMAL, false); @@ -2374,7 +2405,8 @@ bool SidebarClass::StripClass::Abandon_Production(int factory) Factories.Raw_Ptr(factory)->Abandon(); Buildables[index].Factory = -1; abandon = true; - } else { + } + else { if (Buildables[index].Factory != -1) { noprod = false; } @@ -2424,23 +2456,26 @@ void SidebarClass::Zoom_Mode_Control(void) ** radar spying readout => zoomed */ if (IsRadarActive) { - if (Is_Zoomed() || Session.Type==GAME_NORMAL) { + if (Is_Zoomed() || Session.Type == GAME_NORMAL) { if (Is_Zoomed() || !Spy_Next_House()) { Zoom_Mode(Coord_Cell(TacticalCoord)); } - } else { + } + else { if (!Spying_On_House() && !Is_Player_Names()) { Player_Names(1); - } else { + } + else { Player_Names(0); if (!Spy_Next_House()) { Zoom_Mode(Coord_Cell(TacticalCoord)); } } } - } else { - if (Session.Type!=GAME_NORMAL) { - Player_Names(Is_Player_Names()==0); + } + else { + if (Session.Type != GAME_NORMAL) { + Player_Names(Is_Player_Names() == 0); } } #else @@ -2451,23 +2486,26 @@ void SidebarClass::Zoom_Mode_Control(void) ** radar spying readout => not zoomed */ if (IsRadarActive) { - if (Session.Type==GAME_NORMAL) { + if (Session.Type == GAME_NORMAL) { if (!Spy_Next_House()) { Zoom_Mode(Coord_Cell(TacticalCoord)); } - } else { + } + else { if (!Spying_On_House() && !Is_Player_Names()) { Player_Names(1); - } else { + } + else { Player_Names(0); if (!Spy_Next_House()) { Zoom_Mode(Coord_Cell(TacticalCoord)); } } } - } else { - if (Session.Type!=GAME_NORMAL) { - Player_Names(Is_Player_Names()==0); + } + else { + if (Session.Type != GAME_NORMAL) { + Player_Names(Is_Player_Names() == 0); } } #endif