mirror of
https://github.com/jmarshall23/CnC_Remastered_Collection.git
synced 2026-08-12 08:00:55 +02:00
* Fixed input loops/too much callbacks.
This commit is contained in:
@@ -1638,7 +1638,7 @@ void Color_Cycle(void)
|
||||
*=============================================================================================*/
|
||||
void Call_Back(void)
|
||||
{
|
||||
WWSDL_ProcessEvents(g_globalKeyNumType, g_globalKeyFlags);
|
||||
Device_Present();
|
||||
|
||||
/*
|
||||
** Music and speech maintenance
|
||||
|
||||
@@ -859,9 +859,9 @@ void Show_Who_Was_Responsible (void)
|
||||
** If user hits escape then break.
|
||||
*/
|
||||
|
||||
KeyNumType _key = KN_NONE;
|
||||
int _flags;
|
||||
WWSDL_ProcessEvents(_key, _flags);
|
||||
g_globalKeyNumType = KN_NONE;
|
||||
g_globalKeyFlags = 0;
|
||||
UserInput.Process_Input();
|
||||
|
||||
key = Keyboard->Check();
|
||||
|
||||
|
||||
@@ -501,6 +501,8 @@ KeyNumType GadgetClass::Input(void)
|
||||
*/
|
||||
// jmarshall
|
||||
int flags = g_globalKeyFlags;
|
||||
UserInput.Process_Input( g_globalKeyNumType, flags );
|
||||
|
||||
// jmarshall end
|
||||
|
||||
/*
|
||||
|
||||
+13
-12
@@ -652,9 +652,9 @@ int MapEditClass::Pick_Scenario(char const * caption, int & scen_nump, ScenarioP
|
||||
*/
|
||||
bool display = true;
|
||||
while (pickscenerio_process) {
|
||||
KeyNumType _key;
|
||||
int _flags;
|
||||
WWSDL_ProcessEvents(_key, _flags);
|
||||
g_globalKeyNumType = KN_NONE;
|
||||
g_globalKeyFlags = 0;
|
||||
UserInput.Process_Input();
|
||||
}
|
||||
|
||||
Imgui_Dialog_Function = nullptr;
|
||||
@@ -1117,9 +1117,10 @@ int MapEditClass::Size_Map(int x, int y, int w, int h)
|
||||
// }
|
||||
//
|
||||
// Show_Mouse();
|
||||
KeyNumType _key;
|
||||
int _types;
|
||||
WWSDL_ProcessEvents(_key, _types);
|
||||
|
||||
g_globalKeyNumType = KN_NONE;
|
||||
g_globalKeyFlags = 0;
|
||||
UserInput.Process_Input();
|
||||
|
||||
// display = REDRAW_NONE;
|
||||
|
||||
@@ -1957,9 +1958,9 @@ int MapEditClass::Scenario_Dialog(void)
|
||||
*/
|
||||
KeyNumType input = KN_NONE; //commands->Input();
|
||||
|
||||
KeyNumType _key;
|
||||
int _flags;
|
||||
WWSDL_ProcessEvents(_key, _flags);
|
||||
g_globalKeyNumType = KN_NONE;
|
||||
g_globalKeyFlags = 0;
|
||||
UserInput.Process_Input();
|
||||
|
||||
/*
|
||||
** Process input
|
||||
@@ -2549,9 +2550,9 @@ int MapEditClass::Select_Trigger(void)
|
||||
//// LogicPage->Unlock();
|
||||
// }
|
||||
|
||||
KeyNumType _key;
|
||||
int _flags;
|
||||
WWSDL_ProcessEvents(_key, _flags);
|
||||
g_globalKeyNumType = KN_NONE;
|
||||
g_globalKeyFlags = 0;
|
||||
UserInput.Process_Input();
|
||||
|
||||
/*
|
||||
** Get user input
|
||||
|
||||
@@ -1584,11 +1584,16 @@ void MapEditClass::Main_Menu(void)
|
||||
*/
|
||||
Hide_Mouse(); // Do_Menu assumes the mouse is already hidden
|
||||
selection = mainmenu_selection;
|
||||
KeyNumType _key;
|
||||
int _flags;
|
||||
WWSDL_ProcessEvents(_key, _flags);
|
||||
|
||||
g_globalKeyNumType = KN_NONE;
|
||||
g_globalKeyFlags = 0;
|
||||
UserInput.Process_Input();
|
||||
|
||||
Call_Back();
|
||||
|
||||
Show_Mouse();
|
||||
if (UnknownKey==KN_ESC || _key == KN_RMOUSE) {
|
||||
|
||||
if (UnknownKey==KN_ESC || g_globalKeyNumType == KN_RMOUSE) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1702,7 +1707,9 @@ void MapEditClass::Main_Menu(void)
|
||||
case 7:
|
||||
if (Changed) {
|
||||
Imgui_Dialog_Function = nullptr;
|
||||
WWSDL_ProcessEvents(_key, _flags);
|
||||
|
||||
UserInput.Process_Input();
|
||||
|
||||
rc = WWMessageBox().Process("Save Changes?", TXT_YES, TXT_NO, TXT_CANCEL);
|
||||
HidPage.Clear();
|
||||
Flag_To_Redraw(true);
|
||||
@@ -1779,12 +1786,16 @@ void MapEditClass::AI_Menu(void)
|
||||
*/
|
||||
Call_Back();
|
||||
|
||||
UserInput.Process_Input();
|
||||
|
||||
/*
|
||||
** Invoke menu
|
||||
*/
|
||||
Hide_Mouse(); // Do_Menu assumes the mouse is already hidden
|
||||
|
||||
selection = Do_Menu(&_menus[0], true);
|
||||
Show_Mouse();
|
||||
|
||||
if (UnknownKey==KN_ESC || UnknownKey==KN_LMOUSE || UnknownKey==KN_RMOUSE) {
|
||||
break;
|
||||
}
|
||||
|
||||
+17
-15
@@ -228,9 +228,12 @@ char const * Map_Selection(void)
|
||||
bool done = 0;
|
||||
MouseType shape = MOUSE_NORMAL;
|
||||
while (!done) {
|
||||
KeyNumType _key;
|
||||
int _flags = 0;
|
||||
WWSDL_ProcessEvents(_key, _flags);
|
||||
g_globalKeyNumType = KN_NONE;
|
||||
g_globalKeyFlags = 0;
|
||||
|
||||
UserInput.Process_Input();
|
||||
|
||||
Call_Back();
|
||||
|
||||
#ifdef WIN32
|
||||
/*
|
||||
@@ -259,24 +262,23 @@ char const * Map_Selection(void)
|
||||
timer = delay;
|
||||
Set_Mouse_Cursor(xspot, yspot, start + frame);
|
||||
}
|
||||
if (_flags == KN_LMOUSE) {
|
||||
{
|
||||
choice = 0;
|
||||
if (choice != -1) {
|
||||
done = 1;
|
||||
selection = choice;
|
||||
if (g_globalKeyFlags == KN_LMOUSE)
|
||||
{
|
||||
choice = 0;
|
||||
if (choice != -1) {
|
||||
done = 1;
|
||||
selection = choice;
|
||||
#ifdef WIN32
|
||||
Play_Sample(country1, 255, Options.Normalize_Volume(170));
|
||||
Play_Sample(country1, 255, Options.Normalize_Volume(170));
|
||||
#else
|
||||
Play_Sample(country1, 255, Options.Normalize_Volume(50));
|
||||
Play_Sample(country1, 255, Options.Normalize_Volume(50));
|
||||
#endif
|
||||
} else {
|
||||
} else {
|
||||
#ifdef WIN32
|
||||
Play_Sample(scold1, 255, Options.Normalize_Volume(170));
|
||||
Play_Sample(scold1, 255, Options.Normalize_Volume(170));
|
||||
#else
|
||||
Play_Sample(scold1, 255, Options.Normalize_Volume(50));
|
||||
Play_Sample(scold1, 255, Options.Normalize_Volume(50));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,13 +443,14 @@ int Do_Menu(char const ** strings, bool )
|
||||
UnknownKey = 0;
|
||||
while (selection == -1) {
|
||||
// jmarshall
|
||||
KeyNumType _key = KN_NONE;
|
||||
int _flags;
|
||||
WWSDL_ProcessEvents(_key, _flags);
|
||||
Show_Mouse(true);
|
||||
// jmarshall end
|
||||
g_globalKeyNumType = KN_NONE;
|
||||
g_globalKeyFlags = 0;
|
||||
|
||||
Call_Back();
|
||||
selection = Check_Menu(0, strings, NULL, 0xFFL, 0, _key);
|
||||
|
||||
Show_Mouse(true);
|
||||
|
||||
selection = Check_Menu(0, strings, NULL, 0xFFL, 0, (KeyNumType)g_globalKeyFlags);
|
||||
if (UnknownKey != 0 || UnknownKey == KN_ESC || UnknownKey==KN_LMOUSE || UnknownKey==KN_RMOUSE) break;
|
||||
}
|
||||
Keyboard->Clear();
|
||||
|
||||
@@ -1427,9 +1427,9 @@ void ScoreClass::Input_Name(char str[], int xpos, int ypos, char const pal[])
|
||||
// jmarshall - temp disable high school writing.
|
||||
// do {
|
||||
//// jmarshall
|
||||
// KeyNumType _key;
|
||||
// int flags;
|
||||
// WWSDL_ProcessEvents(_key, flags);
|
||||
// g_globalKeyNumType = KN_NONE;
|
||||
// g_globalKeyFlags = 0;
|
||||
// UserInput.Process_Input();
|
||||
//// jmarshall end
|
||||
// Call_Back();
|
||||
// Animate_Score_Objs();
|
||||
|
||||
@@ -684,9 +684,10 @@ int PASCAL WinMain ( HINSTANCE instance , HINSTANCE , char * command_line , int
|
||||
{
|
||||
Keyboard->Check();
|
||||
|
||||
KeyNumType _key = KN_NONE;
|
||||
int _flags;
|
||||
WWSDL_ProcessEvents(_key, _flags);
|
||||
g_globalKeyNumType = KN_NONE;
|
||||
g_globalKeyFlags = 0;
|
||||
|
||||
UserInput.Process_Input();
|
||||
} while (ReadyToQuit == 1);
|
||||
|
||||
return (EXIT_SUCCESS);
|
||||
@@ -866,10 +867,10 @@ void Emergency_Exit ( int code )
|
||||
{
|
||||
Keyboard->Check();
|
||||
|
||||
KeyNumType _key = KN_NONE;
|
||||
int _flags;
|
||||
WWSDL_ProcessEvents(_key, _flags);
|
||||
}while (ReadyToQuit == 3);
|
||||
g_globalKeyNumType = KN_NONE;
|
||||
g_globalKeyFlags = 0;
|
||||
UserInput.Process_Input();
|
||||
} while (ReadyToQuit == 3);
|
||||
|
||||
|
||||
#else //WIN32
|
||||
|
||||
@@ -886,7 +886,7 @@ void __cdecl SetPalette(unsigned char *palette, long, unsigned long)
|
||||
|
||||
|
||||
void WWSDL_ProcessEvents(KeyNumType& key, int& flags, bool presentBuffer) {
|
||||
UserInput.Process_Input(key, flags, presentBuffer);
|
||||
//UserInput.Process_Input(key, flags);
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
extern KeyboardClass * Keyboard;
|
||||
|
||||
void UserInputClass::Process_Input(KeyNumType& key, int& flags, bool presentBuffer)
|
||||
void UserInputClass::Process_Input(KeyNumType& key, int& flags)
|
||||
{
|
||||
bool leftMouseProcessed = false;
|
||||
SDL_GetMouseState(&Mouse.X, &Mouse.Y);
|
||||
@@ -50,17 +50,23 @@ void UserInputClass::Process_Input(KeyNumType& key, int& flags, bool presentBuff
|
||||
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++;
|
||||
key = KN_LMOUSE;
|
||||
}
|
||||
else if (event.button.button == SDL_BUTTON_RIGHT) {
|
||||
Mouse.Button_Right == MouseButtonState::MOUSE_BUTTON_DOWN;
|
||||
|
||||
numFramesLMouse = 0;
|
||||
flags = GadgetClass::RIGHTPRESS;
|
||||
Keyboard->Put_Element(KN_RMOUSE);
|
||||
|
||||
key = KN_RMOUSE;
|
||||
flags = GadgetClass::RIGHTPRESS;
|
||||
|
||||
numFramesLMouse = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -138,9 +144,4 @@ void UserInputClass::Process_Input(KeyNumType& key, int& flags, bool presentBuff
|
||||
Mouse.Button_Left == MouseButtonState::MOUSE_BUTTON_HOLD;
|
||||
flags = GadgetClass::LEFTHELD;
|
||||
}
|
||||
|
||||
if (presentBuffer)
|
||||
{
|
||||
Device_Present();
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,9 @@
|
||||
|
||||
#include "examples/imgui_impl_sdl.h"
|
||||
|
||||
extern KeyNumType g_globalKeyNumType;
|
||||
extern int g_globalKeyFlags;
|
||||
|
||||
// Mapping of SDL KeyCode values to internal KeyNumType
|
||||
std::map<SDL_KeyCode, KeyNumType> const sdl_keyMapping = {
|
||||
{ SDLK_a, KN_A },
|
||||
@@ -101,7 +104,7 @@ class UserInputClass
|
||||
INPUT_ACTION_MOUSE,
|
||||
} InputAction;
|
||||
|
||||
void UserInputClass::Process_Input(KeyNumType& key, int& flags, bool presentBuffer = true);
|
||||
void UserInputClass::Process_Input(KeyNumType& key = g_globalKeyNumType, int& flags = g_globalKeyFlags);
|
||||
|
||||
InputAction LastAction;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user