Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
feat(gameclient): make the key binding screen real
Olcay Seyganb4e00e399e15
diff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.strindex cb95bcf9a..ba0eb135a 100644--- a/GeneralsMD/Code/Data/Patch.str+++ b/GeneralsMD/Code/Data/Patch.str@@ -365,7 +365,7 @@ GUI:WindowMode2ENDTOOLTIP:WindowMode-"Fullscreen takes the display mode, borderless covers it with a window and alt-tabs instantly. Takes effect the next time the game starts."+"Fullscreen takes the display mode, borderless covers it with a window and alt-tabs instantly. Borderless picks the resolution itself, so the list on the left is yours in the other two."ENDGUI:MSAA@@ -531,3 +531,47 @@ ENDTOOLTIP:HealthBars"Smart shows a bar over anything hurt, plus the selection and whatever is under the cursor. Selection only is what retail did."END++GUI:Assign+"Assign"+END++GUI:ResetAll+"Reset All"+END++GUI:PressAKey+"Click a command, then press the key you want"+END++GUI:CONTROL+"Unit control"+END++GUI:INFORMATION+"Information"+END++GUI:INTERFACE+"Interface"+END++GUI:SELECTION+"Selection"+END++GUI:TAUNT+"Taunts"+END++GUI:TEAM+"Teams"+END++GUI:MISC+"Miscellaneous"+END++GUI:DEBUG+"Debug"+ENDdiff --git a/GeneralsMD/Code/Data/Window/Menus/KeyboardOptionsMenu.wnd b/GeneralsMD/Code/Data/Window/Menus/KeyboardOptionsMenu.wndnew file mode 100644index 000000000..3d0f145a4--- /dev/null+++ b/GeneralsMD/Code/Data/Window/Menus/KeyboardOptionsMenu.wnd@@ -0,0 +1,366 @@+FILE_VERSION = 2;+STARTLAYOUTBLOCK+ LAYOUTINIT = KeyboardOptionsMenuInit;+ LAYOUTUPDATE = KeyboardOptionsMenuUpdate;+ LAYOUTSHUTDOWN = KeyboardOptionsMenuShutdown;+ENDLAYOUTBLOCK+WINDOW+ WINDOWTYPE = USER;+ SCREENRECT = UPPERLEFT: 120 40,+ BOTTOMRIGHT: 680 560,+ CREATIONRESOLUTION: 800 600;+ NAME = "KeyboardOptionsMenu.wnd:ParentKeyboardOptionsMenu";+ STATUS = ENABLED+BORDER;+ STYLE = USER;+ SYSTEMCALLBACK = "KeyboardOptionsMenuSystem";+ INPUTCALLBACK = "KeyboardOptionsMenuInput";+ TOOLTIPCALLBACK = "[None]";+ DRAWCALLBACK = "[None]";+ FONT = NAME: "Arial", SIZE: 14, BOLD: 0;+ HEADERTEMPLATE = "[NONE]";+ TOOLTIPDELAY = -1;+ TEXTCOLOR = ENABLED: 255 255 255 255, ENABLEDBORDER: 0 0 0 255,+ DISABLED: 192 192 192 255, DISABLEDBORDER: 64 64 64 255,+ HILITE: 255 255 255 255, HILITEBORDER: 0 0 0 255;+ ENABLEDDRAWDATA = IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255;+ DISABLEDDRAWDATA = IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255;+ HILITEDRAWDATA = IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 200, BORDERCOLOR: 49 55 168 255;+ CHILD+ WINDOW+ WINDOWTYPE = STATICTEXT;+ SCREENRECT = UPPERLEFT: 136 52,+ BOTTOMRIGHT: 400 76,+ CREATIONRESOLUTION: 800 600;+ NAME = "KeyboardOptionsMenu.wnd:StaticTextTitle";+ STATUS = ENABLED;+ STYLE = STATICTEXT;+ SYSTEMCALLBACK = "[None]";+ INPUTCALLBACK = "[None]";+ TOOLTIPCALLBACK = "[None]";+ DRAWCALLBACK = "[None]";+ FONT = NAME: "Arial", SIZE: 14, BOLD: 1;+ HEADERTEMPLATE = "MinorTitle";+ TOOLTIPDELAY = -1;+ TEXT = "GUI:KeyboardOptions";+ TEXTCOLOR = ENABLED: 255 255 255 255, ENABLEDBORDER: 0 0 0 255,+ DISABLED: 192 192 192 255, DISABLEDBORDER: 64 64 64 255,+ HILITE: 255 255 255 255, HILITEBORDER: 0 0 0 255;+ END+ CHILD+ WINDOW+ WINDOWTYPE = SCROLLLISTBOX;+ SCREENRECT = UPPERLEFT: 136 84,+ BOTTOMRIGHT: 664 380,+ CREATIONRESOLUTION: 800 600;+ NAME = "KeyboardOptionsMenu.wnd:ListBoxCommandList";+ STATUS = ENABLED+BORDER;+ STYLE = SCROLLLISTBOX+MOUSETRACK;+ SYSTEMCALLBACK = "[None]";+ INPUTCALLBACK = "[None]";+ TOOLTIPCALLBACK = "[None]";+ DRAWCALLBACK = "[None]";+ FONT = NAME: "Arial", SIZE: 10, BOLD: 0;+ HEADERTEMPLATE = "[NONE]";+ TOOLTIPDELAY = -1;+ TEXTCOLOR = ENABLED: 254 254 254 255, ENABLEDBORDER: 0 0 0 255,+ DISABLED: 192 192 192 255, DISABLEDBORDER: 64 64 64 255,+ HILITE: 255 255 128 255, HILITEBORDER: 0 0 0 255;+ ENABLEDDRAWDATA = IMAGE: NoImage, COLOR: 0 0 0 220, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 47 55 168 255, BORDERCOLOR: 254 254 254 255,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ HILITEDRAWDATA = IMAGE: NoImage, COLOR: 0 0 0 220, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 90 100 210 255, BORDERCOLOR: 254 254 254 255,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ LISTBOXDATA = LENGTH: 512,+ AUTOSCROLL: 0,+ SCROLLIFATEND: 0,+ AUTOPURGE: 0,+ SCROLLBAR: 1,+ MULTISELECT: 0,+ COLUMNS: 1,+ FORCESELECT: 1;+ LISTBOXENABLEDUPBUTTONDRAWDATA = IMAGE: VSliderUpButtonEnabled, COLOR: 255 0 0 255, BORDERCOLOR: 255 128 128 255,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ LISTBOXHILITEUPBUTTONDRAWDATA = IMAGE: VSliderUpButtonHilite, COLOR: 0 255 0 255, BORDERCOLOR: 0 128 0 255,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ LISTBOXENABLEDDOWNBUTTONDRAWDATA = IMAGE: VSliderDownButtonEnabled, COLOR: 255 0 0 255, BORDERCOLOR: 255 128 128 255,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ LISTBOXHILITEDOWNBUTTONDRAWDATA = IMAGE: VSliderDownButtonHilite, COLOR: 0 255 0 255, BORDERCOLOR: 0 128 0 255,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ LISTBOXENABLEDSLIDERDRAWDATA = IMAGE: NoImage, COLOR: 0 0 0 160, BORDERCOLOR: 47 55 168 255,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ END+ CHILD+ WINDOW+ WINDOWTYPE = STATICTEXT;+ SCREENRECT = UPPERLEFT: 136 388,+ BOTTOMRIGHT: 664 428,+ CREATIONRESOLUTION: 800 600;+ NAME = "KeyboardOptionsMenu.wnd:StaticTextDescription";+ STATUS = ENABLED+WRAP_CENTERED;+ STYLE = STATICTEXT;+ SYSTEMCALLBACK = "[None]";+ INPUTCALLBACK = "[None]";+ TOOLTIPCALLBACK = "[None]";+ DRAWCALLBACK = "[None]";+ FONT = NAME: "Arial", SIZE: 10, BOLD: 0;+ HEADERTEMPLATE = "[NONE]";+ TOOLTIPDELAY = -1;+ TEXTCOLOR = ENABLED: 220 220 220 255, ENABLEDBORDER: 0 0 0 255,+ DISABLED: 192 192 192 255, DISABLEDBORDER: 64 64 64 255,+ HILITE: 220 220 220 255, HILITEBORDER: 0 0 0 255;+ END+ CHILD+ WINDOW+ WINDOWTYPE = STATICTEXT;+ SCREENRECT = UPPERLEFT: 136 436,+ BOTTOMRIGHT: 320 460,+ CREATIONRESOLUTION: 800 600;+ NAME = "KeyboardOptionsMenu.wnd:StaticTextCurrentHotkey";+ STATUS = ENABLED;+ STYLE = STATICTEXT;+ SYSTEMCALLBACK = "[None]";+ INPUTCALLBACK = "[None]";+ TOOLTIPCALLBACK = "[None]";+ DRAWCALLBACK = "[None]";+ FONT = NAME: "Arial", SIZE: 12, BOLD: 1;+ HEADERTEMPLATE = "[NONE]";+ TOOLTIPDELAY = -1;+ TEXTCOLOR = ENABLED: 255 255 128 255, ENABLEDBORDER: 0 0 0 255,+ DISABLED: 192 192 192 255, DISABLEDBORDER: 64 64 64 255,+ HILITE: 255 255 128 255, HILITEBORDER: 0 0 0 255;+ END+ CHILD+ WINDOW+ WINDOWTYPE = ENTRYFIELD;+ SCREENRECT = UPPERLEFT: 336 436,+ BOTTOMRIGHT: 520 460,+ CREATIONRESOLUTION: 800 600;+ NAME = "KeyboardOptionsMenu.wnd:TextEntryAssignHotkey";+ STATUS = ENABLED+BORDER;+ STYLE = ENTRYFIELD+MOUSETRACK;+ SYSTEMCALLBACK = "[None]";+ INPUTCALLBACK = "[None]";+ TOOLTIPCALLBACK = "[None]";+ DRAWCALLBACK = "[None]";+ FONT = NAME: "Arial", SIZE: 10, BOLD: 0;+ HEADERTEMPLATE = "[NONE]";+ TOOLTIPDELAY = -1;+ TEXT = "Entry";+ TEXTCOLOR = ENABLED: 254 254 254 255, ENABLEDBORDER: 0 0 0 255,+ DISABLED: 128 128 128 255, DISABLEDBORDER: 64 64 64 255,+ HILITE: 255 255 128 255, HILITEBORDER: 0 0 0 255;+ ENABLEDDRAWDATA = IMAGE: NoImage, COLOR: 0 0 0 220, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 220, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 220, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 220, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 220, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 220, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 220, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 220, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 0 0 0 220, BORDERCOLOR: 49 55 168 255;+ DISABLEDDRAWDATA = IMAGE: NoImage, COLOR: 0 0 0 120, BORDERCOLOR: 60 60 60 255,+ IMAGE: NoImage, COLOR: 0 0 0 120, BORDERCOLOR: 60 60 60 255,+ IMAGE: NoImage, COLOR: 0 0 0 120, BORDERCOLOR: 60 60 60 255,+ IMAGE: NoImage, COLOR: 0 0 0 120, BORDERCOLOR: 60 60 60 255,+ IMAGE: NoImage, COLOR: 0 0 0 120, BORDERCOLOR: 60 60 60 255,+ IMAGE: NoImage, COLOR: 0 0 0 120, BORDERCOLOR: 60 60 60 255,+ IMAGE: NoImage, COLOR: 0 0 0 120, BORDERCOLOR: 60 60 60 255,+ IMAGE: NoImage, COLOR: 0 0 0 120, BORDERCOLOR: 60 60 60 255,+ IMAGE: NoImage, COLOR: 0 0 0 120, BORDERCOLOR: 60 60 60 255;+ TEXTENTRYDATA = MAXLEN: 24,+ SECRETTEXT: 0,+ NUMERICALONLY: 0,+ ALPHANUMERICALONLY: 0,+ ASCIIONLY: 0;+ END+ CHILD+ WINDOW+ WINDOWTYPE = PUSHBUTTON;+ SCREENRECT = UPPERLEFT: 536 436,+ BOTTOMRIGHT: 664 460,+ CREATIONRESOLUTION: 800 600;+ NAME = "KeyboardOptionsMenu.wnd:ButtonAssign";+ STATUS = ENABLED+BORDER;+ STYLE = PUSHBUTTON+MOUSETRACK;+ SYSTEMCALLBACK = "[None]";+ INPUTCALLBACK = "[None]";+ TOOLTIPCALLBACK = "[None]";+ DRAWCALLBACK = "[None]";+ FONT = NAME: "Arial", SIZE: 10, BOLD: 0;+ HEADERTEMPLATE = "[NONE]";+ TOOLTIPDELAY = -1;+ TEXT = "GUI:Assign";+ TEXTCOLOR = ENABLED: 255 255 255 255, ENABLEDBORDER: 0 0 0 255,+ DISABLED: 128 128 128 255, DISABLEDBORDER: 64 64 64 255,+ HILITE: 255 255 128 255, HILITEBORDER: 0 0 0 255;+ ENABLEDDRAWDATA = IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255;+ HILITEDRAWDATA = IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255,+ IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255,+ IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255,+ IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255,+ IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255,+ IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255,+ IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255,+ IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255,+ IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255;+ END+ CHILD+ WINDOW+ WINDOWTYPE = PUSHBUTTON;+ SCREENRECT = UPPERLEFT: 136 500,+ BOTTOMRIGHT: 300 532,+ CREATIONRESOLUTION: 800 600;+ NAME = "KeyboardOptionsMenu.wnd:ButtonResetAll";+ STATUS = ENABLED+BORDER;+ STYLE = PUSHBUTTON+MOUSETRACK;+ SYSTEMCALLBACK = "[None]";+ INPUTCALLBACK = "[None]";+ TOOLTIPCALLBACK = "[None]";+ DRAWCALLBACK = "[None]";+ FONT = NAME: "Arial", SIZE: 12, BOLD: 0;+ HEADERTEMPLATE = "[NONE]";+ TOOLTIPDELAY = -1;+ TEXT = "GUI:ResetAll";+ TEXTCOLOR = ENABLED: 255 255 255 255, ENABLEDBORDER: 0 0 0 255,+ DISABLED: 128 128 128 255, DISABLEDBORDER: 64 64 64 255,+ HILITE: 255 255 128 255, HILITEBORDER: 0 0 0 255;+ ENABLEDDRAWDATA = IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255;+ HILITEDRAWDATA = IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255,+ IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255,+ IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255,+ IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255,+ IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255,+ IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255,+ IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255,+ IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255,+ IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255;+ END+ CHILD+ WINDOW+ WINDOWTYPE = PUSHBUTTON;+ SCREENRECT = UPPERLEFT: 500 500,+ BOTTOMRIGHT: 664 532,+ CREATIONRESOLUTION: 800 600;+ NAME = "KeyboardOptionsMenu.wnd:ButtonBack";+ STATUS = ENABLED+BORDER;+ STYLE = PUSHBUTTON+MOUSETRACK;+ SYSTEMCALLBACK = "[None]";+ INPUTCALLBACK = "[None]";+ TOOLTIPCALLBACK = "[None]";+ DRAWCALLBACK = "[None]";+ FONT = NAME: "Arial", SIZE: 12, BOLD: 0;+ HEADERTEMPLATE = "[NONE]";+ TOOLTIPDELAY = -1;+ TEXT = "GUI:Cancel";+ TEXTCOLOR = ENABLED: 255 255 255 255, ENABLEDBORDER: 0 0 0 255,+ DISABLED: 128 128 128 255, DISABLEDBORDER: 64 64 64 255,+ HILITE: 255 255 128 255, HILITEBORDER: 0 0 0 255;+ ENABLEDDRAWDATA = IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 30 36 110 255, BORDERCOLOR: 49 55 168 255;+ HILITEDRAWDATA = IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255,+ IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255,+ IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255,+ IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255,+ IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255,+ IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255,+ IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255,+ IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255,+ IMAGE: NoImage, COLOR: 60 70 190 255, BORDERCOLOR: 209 253 4 255;+ END+ ENDALLCHILDREN+ENDdiff --git a/GeneralsMD/Code/Data/Window/Menus/OptionsMenu.wnd b/GeneralsMD/Code/Data/Window/Menus/OptionsMenu.wndindex d5d9ae5b2..1c176aae6 100644--- a/GeneralsMD/Code/Data/Window/Menus/OptionsMenu.wnd+++ b/GeneralsMD/Code/Data/Window/Menus/OptionsMenu.wnd@@ -536,11 +536,11 @@ WINDOWCHILDWINDOWWINDOWTYPE = PUSHBUTTON;- SCREENRECT = UPPERLEFT: 747 127,- BOTTOMRIGHT: 923 167,+ SCREENRECT = UPPERLEFT: 151 226,+ BOTTOMRIGHT: 351 258,CREATIONRESOLUTION: 800 600;NAME = "OptionsMenu.wnd:ButtonKeyboardOptions";- STATUS = ENABLED+HIDDEN+IMAGE;+ STATUS = ENABLED+IMAGE;STYLE = PUSHBUTTON+MOUSETRACK;SYSTEMCALLBACK = "[None]";INPUTCALLBACK = "[None]";diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/MetaEvent.h b/GeneralsMD/Code/GameEngine/Include/GameClient/MetaEvent.hindex 2bab4ac00..a158107de 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/MetaEvent.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/MetaEvent.h@@ -331,6 +331,10 @@ public:MappableKeyCategories m_category; ///< This is the catagory the key falls underUnicodeString m_description; ///< The description string for the keysUnicodeString m_displayName; ///< The display name of our command++ // What CommandMap.ini said, kept so Reset can put it back after the player has rebound it+ MappableKeyType m_defaultKey;+ MappableKeyModState m_defaultModState;};EMPTY_DTOR(MetaMapRec)@@ -376,6 +380,24 @@ public:static void parseMetaMap(INI* ini);const MetaMapRec *getFirstMetaMapRec() const { return m_metaMaps; }++ //+ // Rebinding. CommandMap.ini is the default set and is in the multiplayer checksum, so a player+ // who moves a key does not edit it: the change goes into Keybinds.ini beside Options.ini, and is+ // applied over the defaults every time the game starts. A binding is a key plus the state of+ // ctrl, alt and shift; the transition, the category and what the command actually does stay the+ // data's business.+ //+ MetaMapRec *findByName( const char *name ); ///< the record a command name belongs to+ const char *getName( const MetaMapRec *rec ) const; ///< ...and back the other way++ /** Point one command at a different key. Answers the record that was already on that key and had+ * to give it up, or NULL - a key can only mean one thing, and the screen says which one moved. */+ MetaMapRec *rebind( MetaMapRec *rec, MappableKeyType key, MappableKeyModState mods );++ void resetBindingsToDefault( void ); ///< back to what CommandMap.ini says, all of them+ void loadUserBindings( void ); ///< read Keybinds.ini over the defaults, at startup+ void saveUserBindings( void ); ///< write out everything that is not on its default key};extern MetaMap *TheMetaMap;diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cppindex 7d99a5d36..61a028e58 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp@@ -752,6 +752,14 @@ void GameEngine::init( int argc, char *argv[] )ini.load("Data\\INI\\CommandMapDemo.ini", INI_LOAD_MULTIFILE, NULL);#endif+ //+ // ... and last, whatever the player has moved. Keybinds.ini sits next to Options.ini and+ // holds only the commands that are not on the key the data gave them, so it survives a patch+ // that adds commands and it is not part of the INI checksum: two players in one match can+ // hold completely different keyboards.+ //+ TheMetaMap->loadUserBindings();+initSubsystem(TheActionManager,"TheActionManager", MSGNEW("GameEngineSubsystem") ActionManager(), NULL);//initSubsystem((CComObject<WebBrowser> *)TheWebBrowser,"(CComObject<WebBrowser> *)TheWebBrowser", (CComObject<WebBrowser> *)createWebBrowser(), NULL);diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/KeyboardOptionsMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/KeyboardOptionsMenu.cppindex bbd4b8fe2..153bdef84 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/KeyboardOptionsMenu.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/KeyboardOptionsMenu.cpp@@ -108,6 +108,20 @@ Bool ctrlDown = false;// shows whether or not a correctly formatted hotkey assignment is in the text areaBool absolute = false;+//+// What the screen is working on: the command whose row is selected, and the key the player has+// pressed into the box but not yet accepted. The box captures a keystroke whole - key and+// modifiers together, on the way down - rather than assembling a string out of the letters typed+// into it, which is what it used to do and which could never produce a binding at the end.+//+static MetaMapRec *theSelectedRec = NULL;+static MappableKeyType thePendingKey = MK_NONE;+static MappableKeyModState thePendingMods = NONE;++static UnicodeString bindingText( const MetaMapRec *rec );+static UnicodeString bindingTextFor( MappableKeyType key, MappableKeyModState mods );+static Bool catchBindingKey( WindowMsgData mData1, WindowMsgData mData2 );+// initialize these, they will be used a lotUnicodeString alt;UnicodeString ctrl;@@ -115,22 +129,16 @@ UnicodeString shift;+//-------------------------------------------------------------------------------------------------+/** There is no category dropdown any more.+ *+ * It was a filter over a list, on a screen whose whole job is to answer "what is bound to what" -+ * so it hid seven eighths of the answer behind a control you had to work. Every command is in+ * the one list now, in category order, with the category written across the row above its+ * commands. This is kept as a no-op because the screen's message handler still names it. */+//-------------------------------------------------------------------------------------------------void populateCategoryBox(){- Int i;- Int index;- Color color = GameMakeColor(255,255,255,255);- AsciiString temp;- UnicodeString str;- GadgetComboBoxReset(comboBoxCategoryList);- for ( i = 0; i < CATEGORY_NUM_CATEGORIES; ++i)- {- temp.format("GUI:%s", CategoryListName[i]);- str = TheGameText->fetch( temp );- index = GadgetComboBoxAddEntry(comboBoxCategoryList, str, color);- }-- GadgetComboBoxSetSelectedPos(comboBoxCategoryList, 0);}// keeps track of whether or not each text modifier is being currently displayed in the text entry field@@ -144,20 +152,159 @@ void setKeyDown( UnicodeString mod, Bool b )altDown = b;}-// initialized the command list box+//-------------------------------------------------------------------------------------------------+/** A binding as a player reads it: "Ctrl+A", "F9", or nothing at all. */+//-------------------------------------------------------------------------------------------------+static UnicodeString bindingTextFor( MappableKeyType key, MappableKeyModState mods )+{+ if( key == MK_NONE )+ return TheGameText->fetch( "GUI:NULL" );++ UnicodeString out;+ if( mods & CTRL )+ out.concat( TheGameText->fetch( "KEYBOARD:Ctrl+" ) );+ if( mods & ALT )+ out.concat( TheGameText->fetch( "KEYBOARD:Alt+" ) );+ if( mods & SHIFT )+ out.concat( TheGameText->fetch( "KEYBOARD:Shift+" ) );++ // the KEY_ names are what the INI spells, and the "KEY_" in front of them is noise on a screen+ for( const LookupListRec *keyName = KeyNames; keyName->name; keyName++ )+ {+ if( keyName->value != (Int)key )+ continue;++ const char *bare = keyName->name;+ if( strncmp( bare, "KEY_", 4 ) == 0 )+ bare += 4;++ UnicodeString uStr;+ uStr.translate( AsciiString( bare ) );+ out.concat( uStr );+ break;+ }++ return out;+}++//-------------------------------------------------------------------------------------------------+static UnicodeString bindingText( const MetaMapRec *rec )+{+ if( rec == NULL )+ return TheGameText->fetch( "GUI:NULL" );+ return bindingTextFor( rec->m_key, rec->m_modState );+}++//-------------------------------------------------------------------------------------------------+/** Take one keystroke as the binding the player wants, and show it in the box.+ *+ * Whole, on the way down: the key and whatever of ctrl, alt and shift was held with it. Both the+ * box and the screen behind it offer their keystrokes here, because which of the two has the+ * keyboard focus is not something a player should have to know - clicking a row is the whole+ * interaction, and the next key you press is the answer to it. */+//-------------------------------------------------------------------------------------------------+static Bool catchBindingKey( WindowMsgData mData1, WindowMsgData mData2 )+{+ if( theSelectedRec == NULL || textEntryAssignHotkey == NULL )+ return FALSE;++ const UnsignedByte key = (UnsignedByte)mData1;+ const UnsignedShort state = (UnsignedShort)mData2;++ if( !BitTest( state, KEY_STATE_DOWN ) || BitTest( state, KEY_STATE_AUTOREPEAT ) )+ return FALSE;++ // escape leaves the screen; the modifier keys are what you hold, not what you bind+ if( key == KEY_ESC )+ return FALSE;+ if( key == KEY_LCTRL || key == KEY_RCTRL || key == KEY_LALT || key == KEY_RALT ||+ key == KEY_LSHIFT || key == KEY_RSHIFT )+ return TRUE;++ Int mods = 0;+ if( BitTest( state, KEY_STATE_CONTROL ) ) mods |= CTRL;+ if( BitTest( state, KEY_STATE_ALT ) ) mods |= ALT;+ if( BitTest( state, KEY_STATE_SHIFT ) ) mods |= SHIFT;++ thePendingKey = (MappableKeyType)key;+ thePendingMods = (MappableKeyModState)mods;++ EntryData *e = (EntryData *)textEntryAssignHotkey->winGetUserData();+ if( e && e->text )+ {+ e->text->setText( bindingTextFor( thePendingKey, thePendingMods ) );+ e->charPos = e->text->getTextLength();+ }++ return TRUE;+}++//-------------------------------------------------------------------------------------------------+/** The category the combo box is showing. Its rows are the CategoryListName table in order, and+ * the row's *value* is the category - not its index, which is only the same by luck. */+//-------------------------------------------------------------------------------------------------+static MappableKeyCategories currentCategory( void )+{+ // every category is in the one list; the argument is only there because the signature is+ return CATEGORY_CONTROL;+}++//-------------------------------------------------------------------------------------------------+/** Every command in this category, each with the key it is on right now.+ *+ * The key is in the row rather than only in the box below, so the screen answers "what is bound+ * to what" at a glance - which is the question somebody opens it with - and the record itself is+ * the row's data, so a selection is exact instead of matched back by display name. */+//-------------------------------------------------------------------------------------------------void fillCommandListBox( MappableKeyCategories cat ){if(!listBoxCommandList)return;GadgetListBoxReset(listBoxCommandList);- Color color = GameMakeColor(255,255,255,255);- for(const MetaMapRec *rec = TheMetaMap->getFirstMetaMapRec(); rec; rec = rec->m_next)+ const Color color = GameMakeColor( 255, 255, 255, 255 );+ const Color heading = GameMakeColor( 255, 220, 120, 255 );++ for( Int c = 0; c < CATEGORY_NUM_CATEGORIES; ++c ){- if(rec->m_category == cat)- GadgetListBoxAddEntryText(listBoxCommandList, rec->m_displayName, color, -1, -1 );+ const MappableKeyCategories thisCat = (MappableKeyCategories)CategoryListName[ c ].value;++ //+ // The debug commands are compiled out of a shipping build, so binding one would be binding a+ // key to nothing at all. Everything else the game answers to is here.+ //+ if( thisCat == CATEGORY_DEBUG )+ continue;++ Bool wroteHeading = FALSE;++ for(const MetaMapRec *rec = TheMetaMap->getFirstMetaMapRec(); rec; rec = rec->m_next)+ {+ if( rec->m_category != thisCat || rec->m_displayName.isEmpty() )+ continue;+ if( !wroteHeading )+ {+ AsciiString key;+ key.format( "GUI:%s", CategoryListName[ c ].name );+ Int head = GadgetListBoxAddEntryText( listBoxCommandList,+ TheGameText->fetch( key ), heading, -1, -1 );+ // a heading is not a command: no record, so a click on it selects nothing+ if( head >= 0 )+ GadgetListBoxSetItemData( listBoxCommandList, NULL, head );+ wroteHeading = TRUE;+ }++ UnicodeString row( L" " );+ row.concat( rec->m_displayName );+ row.concat( UnicodeString( L" - " ) );+ row.concat( bindingText( rec ) );++ Int at = GadgetListBoxAddEntryText(listBoxCommandList, row, color, -1, -1 );+ if( at >= 0 )+ GadgetListBoxSetItemData( listBoxCommandList, (void *)rec, at );+ }}}@@ -433,6 +580,13 @@ void KeyboardOptionsMenuInit( WindowLayout *layout, void *userData )//disable textEntry until specific command is chosentextEntryAssignHotkey->winEnable( false );+ // nothing is selected yet, so say what to do rather than showing an empty panel+ GadgetStaticTextSetText( staticTextDescription, TheGameText->fetch( "GUI:PressAKey" ) );+ GadgetStaticTextSetText( staticTextCurrentHotkey, TheGameText->fetch( "GUI:NULL" ) );+ theSelectedRec = NULL;+ thePendingKey = MK_NONE;+ thePendingMods = NONE;+//clear textEntry fieldEntryData *e = (EntryData *)textEntryAssignHotkey->winGetUserData();e->text->setText( UnicodeString::TheEmptyString );@@ -515,6 +669,10 @@ WindowMsgHandledType KeyboardOptionsMenuInput( GameWindow *window, UnsignedInt m} // end switch( key )+ // with a command picked, the next key you press is the one you want it on+ if( catchBindingKey( mData1, mData2 ) )+ return MSG_HANDLED;+} // end char} // end switch( msg )@@ -566,16 +724,11 @@ WindowMsgHandledType KeyboardOptionsMenuSystem( GameWindow *window, UnsignedIntGameWindow *control = (GameWindow *)mData1;Int controlID = control->winGetWindowId();- if(controlID == comboBoxCategoryListID )+ if( comboBoxCategoryList != NULL && controlID == comboBoxCategoryListID ){- Int selected;- GadgetComboBoxGetSelectedPos(comboBoxCategoryList, &selected);+ // the category dropdown is gone; if a layout still carries one, it just refills the list+ fillCommandListBox( currentCategory() );- LookupListRec rec;- rec = CategoryListName[selected];- MappableKeyCategories cat = (MappableKeyCategories)(rec.value);- fillCommandListBox( cat );-//reset current hotkey descriptionGadgetStaticTextSetText( staticTextDescription, TheGameText->fetch( "GUI:NULL" ) );@@ -603,39 +756,36 @@ WindowMsgHandledType KeyboardOptionsMenuSystem( GameWindow *window, UnsignedIntif( controlID == listBoxCommandListID ){- Int selected;+ Int selected = -1;GadgetListBoxGetSelected( listBoxCommandList, &selected );- UnicodeString str;- str = GadgetListBoxGetText( listBoxCommandList, selected/*, Int column = 0*/ );- for(const MetaMapRec *rec = TheMetaMap->getFirstMetaMapRec(); rec; rec = rec->m_next)++ // the record is the row's own data, so this is exact rather than matched by name -+ // two commands sharing a display name used to both answer to the first one's row+ theSelectedRec = ( selected >= 0 )+ ? (MetaMapRec *)GadgetListBoxGetItemData( listBoxCommandList, selected )+ : NULL;++ thePendingKey = MK_NONE;+ thePendingMods = NONE;++ EntryData *entry = (EntryData *)textEntryAssignHotkey->winGetUserData();+ if( entry ){- if(rec->m_displayName == str)- {- //set text in description window- GadgetStaticTextSetText( staticTextDescription, rec->m_description );- //set text in current hotkey text- MappableKeyType type = rec->m_key;- //enable text entry for assigning different hotkey- textEntryAssignHotkey->winEnable( true );-- for (const LookupListRec* keyName = KeyNames; keyName->name; keyName++)- {- if( keyName->value == type )- {- const char *cptr = keyName->name;- AsciiString aStr;- aStr.format( cptr );- UnicodeString uStr;- uStr.translate( aStr );-- GadgetStaticTextSetText( staticTextCurrentHotkey, uStr );- break;- }- }+ entry->text->setText( UnicodeString::TheEmptyString );+ entry->charPos = 0;+ }- break;- }- } // end if+ if( theSelectedRec )+ {+ GadgetStaticTextSetText( staticTextDescription, theSelectedRec->m_description );+ GadgetStaticTextSetText( staticTextCurrentHotkey, bindingText( theSelectedRec ) );+ textEntryAssignHotkey->winEnable( true );+ TheWindowManager->winSetFocus( textEntryAssignHotkey );+ }+ else+ {+ textEntryAssignHotkey->winEnable( false );+ }} // end selected@@ -658,15 +808,48 @@ WindowMsgHandledType KeyboardOptionsMenuSystem( GameWindow *window, UnsignedInt} // end ifelse if( controlID == buttonAssignID ){- // check grammar in text field+ //+ // Put the command on the key the box caught. Whatever else was on that key gives it+ // up - a key can only mean one thing - and the list is rebuilt so both the command+ // that moved and the one that was displaced show what they answer to now.+ //+ if( theSelectedRec && thePendingKey != MK_NONE )+ {+ MetaMapRec *displaced = TheMetaMap->rebind( theSelectedRec, thePendingKey, thePendingMods );++ fillCommandListBox( currentCategory() );++ GadgetStaticTextSetText( staticTextCurrentHotkey, bindingText( theSelectedRec ) );++ // say which command just went quiet, rather than leaving it to be found in a game+ if( displaced )+ {+ UnicodeString note = displaced->m_displayName;+ note.concat( UnicodeString( L" - " ) );+ note.concat( TheGameText->fetch( "GUI:NULL" ) );+ GadgetStaticTextSetText( staticTextDescription, note );+ }++ thePendingKey = MK_NONE;+ thePendingMods = NONE;+ EntryData *entry = (EntryData *)textEntryAssignHotkey->winGetUserData();+ if( entry )+ {+ entry->text->setText( UnicodeString::TheEmptyString );+ entry->charPos = 0;+ }+ }}else if( controlID == buttonResetAllID ){- // populate category combo box- populateCategoryBox();+ // every key back to what the game shipped with, and the file written out empty+ TheMetaMap->resetBindingsToDefault();++ fillCommandListBox( currentCategory() );- // populate command list- fillCommandListBox(CATEGORY_CONTROL);+ theSelectedRec = NULL;+ thePendingKey = MK_NONE;+ thePendingMods = NONE;//reset current hotkey textGadgetStaticTextSetText( staticTextCurrentHotkey, TheGameText->fetch( "GUI:NULL" ) );@@ -676,11 +859,6 @@ WindowMsgHandledType KeyboardOptionsMenuSystem( GameWindow *window, UnsignedInte->text->setText( UnicodeString::TheEmptyString );e->charPos = e->text->getTextLength();- //set all mods to false- setKeyDown(alt, false );- setKeyDown(ctrl, false );- setKeyDown(shift, false );-//disable text entrytextEntryAssignHotkey->winEnable( false );@@ -715,7 +893,23 @@ WindowMsgHandledType KeyboardTextEntryInput( GameWindow *window, UnsignedInt msgreturn MSG_HANDLED;}- switch( msg )+ //+ // This box does not take text. It takes one keystroke, whole: the key and whatever of ctrl,+ // alt and shift were held with it, on the way down, and it shows what it caught. The several+ // hundred lines below used to assemble a display string out of the characters typed into it,+ // character by character, and never arrived at a key and a modifier that anything could be+ // bound to - which is why the Assign button had nothing to do and said so in a comment.+ //+ // The mouse cases further down still matter (the box highlights and takes focus like any+ // other), so this sits in front of the keyboard ones rather than replacing the function.+ //+ if( msg == GWM_CHAR )+ return catchBindingKey( mData1, mData2 ) ? MSG_HANDLED : MSG_IGNORED;++ if( msg == GWM_IME_CHAR )+ return MSG_HANDLED; // a keystroke is not a character here++ switch( msg ){// ------------------------------------------------------------------------case GWM_IME_CHAR:diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cppindex 246943a81..3d7ba0d8b 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp@@ -36,6 +36,7 @@#include "Common/PlayerList.h"#include "Common/Team.h"#include "Common/ThingTemplate.h"+#include "Common/UserPreferences.h"#include "GameClient/ControlBar.h"#include "GameClient/Drawable.h"@@ -815,6 +816,177 @@ MetaMapRec *MetaMap::getMetaMapRec(GameMessage::Type t)throw INI_INVALID_DATA;ini->initFromINI(map, TheMetaMapFieldParseTable);++ // what the data says, kept so Reset can put it back after a player has moved the key+ map->m_defaultKey = map->m_key;+ map->m_defaultModState = map->m_modState;+}++//-------------------------------------------------------------------------------------------------+// Rebinding ///////////////////////////////////////////////////////////////////////////////////////+//+// CommandMap.ini is the default set and is in the INI checksum every machine in a network game has+// to agree on, so a player who moves a key does not edit it. The change goes in Keybinds.ini next+// to Options.ini, holds only the commands that are not on their default key, and is applied over+// the defaults on the way in. Nothing about the game's rules changes, so nothing here reaches the+// checksum: two players can hold entirely different keyboards and play the same match.+//-------------------------------------------------------------------------------------------------++/// the file, kept open for the life of the game so a rebind is a write and not a reload+static UserPreferences *theKeybindPrefs = NULL;++//-------------------------------------------------------------------------------------------------+const char *MetaMap::getName( const MetaMapRec *rec ) const+{+ return rec ? findGameMessageNameByType( rec->m_meta ) : NULL;+}++//-------------------------------------------------------------------------------------------------+MetaMapRec *MetaMap::findByName( const char *name )+{+ if( name == NULL )+ return NULL;++ for( MetaMapRec *map = m_metaMaps; map; map = map->m_next )+ if( stricmp( findGameMessageNameByType( map->m_meta ), name ) == 0 )+ return map;++ return NULL;+}++//-------------------------------------------------------------------------------------------------+MetaMapRec *MetaMap::rebind( MetaMapRec *rec, MappableKeyType key, MappableKeyModState mods )+{+ if( rec == NULL )+ return NULL;++ //+ // One key, one meaning. Whoever else was on it in the same place loses it - answering with that+ // record is how the screen can say which command just went quiet, rather than leaving the player+ // to discover it in a game.+ //+ MetaMapRec *displaced = NULL;+ if( key != MK_NONE )+ {+ for( MetaMapRec *other = m_metaMaps; other; other = other->m_next )+ {+ if( other == rec || other->m_key != key || other->m_modState != mods )+ continue;+ if( other->m_usableIn != rec->m_usableIn && !( other->m_usableIn & rec->m_usableIn ) )+ continue; // one is a menu key and the other is a game key: they never meet++ other->m_key = MK_NONE;+ displaced = other;+ break;+ }+ }++ rec->m_key = key;+ rec->m_modState = mods;++ saveUserBindings();+ return displaced;+}++//-------------------------------------------------------------------------------------------------+void MetaMap::resetBindingsToDefault( void )+{+ for( MetaMapRec *map = m_metaMaps; map; map = map->m_next )+ {+ map->m_key = map->m_defaultKey;+ map->m_modState = map->m_defaultModState;+ }++ saveUserBindings();+}++//-------------------------------------------------------------------------------------------------+/** "KEY_A CTRL" - the same two words CommandMap.ini spells a binding with, so the file can be read+ * and hand-edited by anybody who already knows the INI. */+//-------------------------------------------------------------------------------------------------+static AsciiString spellBinding( MappableKeyType key, MappableKeyModState mods )+{+ const char *keyName = "KEY_NONE";+ for( const LookupListRec *k = KeyNames; k->name; k++ )+ if( k->value == (Int)key ) { keyName = k->name; break; }++ const char *modName = "NONE";+ for( const LookupListRec *m = ModifierNames; m->name; m++ )+ if( m->value == (Int)mods ) { modName = m->name; break; }++ AsciiString out;+ out.format( "%s %s", keyName, modName );+ return out;+}++//-------------------------------------------------------------------------------------------------+static Bool readBinding( const AsciiString& text, MappableKeyType *key, MappableKeyModState *mods )+{+ char keyName[ 64 ], modName[ 64 ];+ keyName[ 0 ] = modName[ 0 ] = 0;+ if( sscanf( text.str(), "%63s %63s", keyName, modName ) < 1 )+ return FALSE;++ Bool gotKey = FALSE;+ for( const LookupListRec *k = KeyNames; k->name; k++ )+ if( stricmp( k->name, keyName ) == 0 ) { *key = (MappableKeyType)k->value; gotKey = TRUE; break; }+ if( !gotKey )+ return FALSE;++ *mods = NONE;+ for( const LookupListRec *m = ModifierNames; m->name; m++ )+ if( stricmp( m->name, modName ) == 0 ) { *mods = (MappableKeyModState)m->value; break; }++ return TRUE;+}++//-------------------------------------------------------------------------------------------------+void MetaMap::loadUserBindings( void )+{+ if( theKeybindPrefs == NULL )+ theKeybindPrefs = NEW UserPreferences;++ if( !theKeybindPrefs->load( "Keybinds.ini" ) )+ return; // nobody has moved a key yet++ for( UserPreferences::const_iterator it = theKeybindPrefs->begin(); it != theKeybindPrefs->end(); ++it )+ {+ MetaMapRec *rec = findByName( it->first.str() );+ if( rec == NULL )+ continue; // a command from a version that had it, or a typo: leave the default alone++ MappableKeyType key;+ MappableKeyModState mods;+ if( readBinding( it->second, &key, &mods ) )+ {+ rec->m_key = key;+ rec->m_modState = mods;+ }+ }+}++//-------------------------------------------------------------------------------------------------+void MetaMap::saveUserBindings( void )+{+ if( theKeybindPrefs == NULL )+ {+ theKeybindPrefs = NEW UserPreferences;+ theKeybindPrefs->load( "Keybinds.ini" );+ }++ theKeybindPrefs->clear();++ for( MetaMapRec *map = m_metaMaps; map; map = map->m_next )+ {+ if( map->m_key == map->m_defaultKey && map->m_modState == map->m_defaultModState )+ continue; // still where the data put it: nothing to remember++ const char *name = findGameMessageNameByType( map->m_meta );+ if( name )+ (*theKeybindPrefs)[ AsciiString( name ) ] = spellBinding( map->m_key, map->m_modState );+ }++ theKeybindPrefs->write();}//-------------------------------------------------------------------------------------------------