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(gameengine): pick the monitor, list that monitor's resolutions
Olcay Seygan22400cd4a8bb
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 5cbf573be..a428e53eb 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -780,6 +780,7 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the same- Borderless fullscreen: start with `-borderless` and the game fills the screen at your desktop resolution with no frame and no display mode change, so alt-tab is instant, nothing on the desktop gets shuffled around behind it, and a second monitor stays usable. Screen-edge scrolling works there, the way it does in fullscreen. The loading picture still opens as its own small window with your desktop around it, and the game only takes the screen once it has something to draw.- Borderless and fullscreen keep the mouse on the game's own screen while you are playing. With a second monitor beside it the pointer slid straight over the edge onto the other screen, so edge-scrolling toward that side did nothing and the next click landed on your desktop. The game has asked for the pointer to be held since 2003, but only a mouse driver the game never uses ever did it. Alt-tab still lets go, and coming back takes the pointer only once you move it over the game again. A plain window leaves it free, as before.- Fullscreen, borderless and windowed are one saved setting now, so borderless no longer means adding a switch to your shortcut every time. `WindowMode` in `Options.ini` takes 0, 1 or 2 in that order; a switch on the command line still wins for that one run. Picking a different one applies when you press Accept instead of the next time you start the game: the window loses or gains its frame and the display device is rebuilt on the spot. Borderless takes your desktop resolution and nothing else, so while it is selected the resolution list greys out and the other two modes hand it straight back.+- Play on whichever monitor you like. Options > Display has a Monitor box that lists every screen on your desktop by its number and its name, and the resolution list under it holds the sizes that screen can show rather than the ones the main screen happens to have. Fullscreen changes that monitor's resolution and leaves the others alone, borderless covers it at its own resolution, and a window opens in the middle of it. The game used to go on the main monitor and nowhere else. It moves when you press Accept, and the next launch opens on the same screen.- Antialiasing is a saved setting as well: `MSAA` in `Options.ini`, 0 for off through 4 for sixteen samples. `-msaa 4` still works and still wins for that run. Whatever your card will not give is stepped down instead of refused, so asking for six samples gets you four rather than nothing.- Texture filtering is yours to set. `TextureFilter` in `Options.ini` takes 0 for bilinear, 1 fortrilinear and 2 for anisotropic, and `Anisotropy` takes the sample count, 0 meaning whatever yourdiff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.strindex 6583b7fd0..452eba038 100644--- a/GeneralsMD/Code/Data/Patch.str+++ b/GeneralsMD/Code/Data/Patch.str@@ -563,7 +563,15 @@ GUI:WindowMode2ENDTOOLTIP:WindowMode-"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."+"Fullscreen takes the display mode, borderless covers it with a window and alt-tabs instantly. Borderless takes the monitor's own resolution, so the list above is yours in the other two."+END++GUI:Monitor+"Monitor"+END++TOOLTIP:Monitor+"The monitor the game plays on. The resolution list below holds the sizes this monitor can show. Applied when you Accept."ENDGUI:MSAAdiff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.strindex 4fa016163..bf4a60022 100644--- a/GeneralsMD/Code/Data/Turkish/Generals.str+++ b/GeneralsMD/Code/Data/Turkish/Generals.str@@ -15138,7 +15138,15 @@ GUI:WindowMode2ENDTOOLTIP:WindowMode-"Tam ekran, görüntü modunu devralır; kenarlıksız, ekranı bir pencereyle kaplar ve alt-tab anında gerçekleşir. Kenarlıksız çözünürlüğü kendisi seçer; diğer iki modda soldaki listeden siz seçersiniz."+"Tam ekran, görüntü modunu devralır; kenarlıksız, ekranı bir pencereyle kaplar ve alt-tab anında gerçekleşir. Kenarlıksız monitörün kendi çözünürlüğünü alır; diğer iki modda yukarıdaki listeden siz seçersiniz."+END++GUI:Monitor+"Monitör"+END++TOOLTIP:Monitor+"Oyunun oynandığı monitör. Alttaki çözünürlük listesi bu monitörün gösterebildiği boyutları içerir. Kabul Et'e bastığınızda uygulanır."ENDGUI:MSAAdiff --git a/GeneralsMD/Code/Data/Window/Menus/OptionsMenu.wnd b/GeneralsMD/Code/Data/Window/Menus/OptionsMenu.wndindex 4d0ccb87e..5cf260ab4 100644--- a/GeneralsMD/Code/Data/Window/Menus/OptionsMenu.wnd+++ b/GeneralsMD/Code/Data/Window/Menus/OptionsMenu.wnd@@ -1255,6 +1255,294 @@ WINDOWWINDOWWINDOWTYPE = STATICTEXT;SCREENRECT = UPPERLEFT: 34 182, BOTTOMRIGHT: 258 206, CREATIONRESOLUTION: 800 600;+ NAME = "OptionsMenu.wnd:LabelMonitor";+ TOOLTIPTEXT = "TOOLTIP:Monitor";+ STATUS = ENABLED;+ STYLE = STATICTEXT+MOUSETRACK;+ SYSTEMCALLBACK = "[None]";+ INPUTCALLBACK = "[None]";+ TOOLTIPCALLBACK = "[None]";+ DRAWCALLBACK = "[None]";+ FONT = NAME: "Arial", SIZE: 14, BOLD: 0;+ HEADERTEMPLATE = "MinorTitle";+ TOOLTIPDELAY = -1;+ TEXT = "GUI:Monitor";+ TEXTCOLOR = ENABLED: 255 255 255 255, ENABLEDBORDER: 0 0 0 255,+ DISABLED: 192 192 192 255, DISABLEDBORDER: 64 64 64 255,+ HILITE: 128 128 255 255, HILITEBORDER: 0 0 128 255;+ ENABLEDDRAWDATA = IMAGE: NoImage, COLOR: 0 0 0 0, BORDERCOLOR: 0 0 0 0,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255;+ DISABLEDDRAWDATA = IMAGE: NoImage, COLOR: 64 64 64 255, BORDERCOLOR: 192 192 192 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255;+ HILITEDRAWDATA = IMAGE: NoImage, COLOR: 0 128 0 255, BORDERCOLOR: 128 255 128 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255;+ STATICTEXTDATA = CENTERED: 0;+ END+ CHILD+ WINDOW+ WINDOWTYPE = COMBOBOX;+ SCREENRECT = UPPERLEFT: 40 206, BOTTOMRIGHT: 264 230, CREATIONRESOLUTION: 800 600;+ NAME = "OptionsMenu.wnd:ComboBoxMonitor";+ TOOLTIPTEXT = "TOOLTIP:Monitor";+ STATUS = ENABLED+IMAGE;+ STYLE = MOUSETRACK+COMBOBOX;+ SYSTEMCALLBACK = "[None]";+ INPUTCALLBACK = "[None]";+ TOOLTIPCALLBACK = "[None]";+ DRAWCALLBACK = "[None]";+ FONT = NAME: "Arial", SIZE: 10, BOLD: 0;+ HEADERTEMPLATE = "ComboBoxEntry";+ TOOLTIPDELAY = -1;+ TEXTCOLOR = ENABLED: 254 254 254 255, ENABLEDBORDER: 0 0 0 255,+ DISABLED: 192 192 192 255, DISABLEDBORDER: 64 64 64 255,+ HILITE: 128 128 255 255, HILITEBORDER: 0 0 128 255;+ ENABLEDDRAWDATA = IMAGE: NoImage, COLOR: 255 0 0 255, BORDERCOLOR: 255 128 128 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;+ DISABLEDDRAWDATA = IMAGE: NoImage, COLOR: 128 128 128 255, BORDERCOLOR: 192 192 192 255,+ IMAGE: NoImage, COLOR: 192 192 192 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 255 0 255, BORDERCOLOR: 0 128 0 255,+ IMAGE: ListBoxHiliteSelectedItemLeftEnd, COLOR: 254 254 254 255, BORDERCOLOR: 0 128 0 255,+ IMAGE: ListBoxHiliteSelectedItemRightEnd, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: ListBoxHiliteSelectedItemRepeatingCenter, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: ListBoxHiliteSelectedItemSmallRepeatingCenter, 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;+ COMBOBOXDATA = ISEDITABLE: 0,+ MAXCHARS: 16,+ MAXDISPLAY: 5,+ ASCIIONLY: 0,+ LETTERSANDNUMBERS: 0;+ COMBOBOXDROPDOWNBUTTONENABLEDDRAWDATA = IMAGE: VSliderDownButtonEnabled, COLOR: 255 0 0 255, BORDERCOLOR: 255 128 128 255,+ IMAGE: VSliderDownButtonHiliteSelected, COLOR: 255 255 0 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;+ COMBOBOXDROPDOWNBUTTONDISABLEDDRAWDATA = IMAGE: VSliderDownButtonDisabled, COLOR: 128 128 128 255, BORDERCOLOR: 192 192 192 255,+ IMAGE: NoImage, COLOR: 192 192 192 255, BORDERCOLOR: 128 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;+ COMBOBOXDROPDOWNBUTTONHILITEDRAWDATA = IMAGE: VSliderDownButtonHilite, COLOR: 0 255 0 255, BORDERCOLOR: 0 128 0 255,+ IMAGE: VSliderDownButtonHiliteSelected, COLOR: 255 255 0 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;+ COMBOBOXEDITBOXENABLEDDRAWDATA = IMAGE: TextEntryEnabledLeftEnd, COLOR: 255 0 0 255, BORDERCOLOR: 255 128 128 255,+ IMAGE: TextEntryEnabledRightEnd, COLOR: 255 255 0 255, BORDERCOLOR: 254 254 254 255,+ IMAGE: TextEntryEnabledRepeatingCenter, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: TextEntryEnabledSmallRepeatingCenter, 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;+ COMBOBOXEDITBOXDISABLEDDRAWDATA = IMAGE: TextEntryDisabledLeftEnd, COLOR: 128 128 128 255, BORDERCOLOR: 0 0 0 255,+ IMAGE: TextEntryDisabledRightEnd, COLOR: 192 192 192 255, BORDERCOLOR: 254 254 254 255,+ IMAGE: TextEntryDisabledRepeatingCenter, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: TextEntryDisabledSmallRepeatingCenter, 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;+ COMBOBOXEDITBOXHILITEDRAWDATA = IMAGE: TextEntryHiliteLeftEnd, COLOR: 0 255 0 255, BORDERCOLOR: 0 128 0 255,+ IMAGE: TextEntryHiliteRightEnd, COLOR: 254 254 254 255, BORDERCOLOR: 0 128 0 255,+ IMAGE: TextEntryHiliteRepeatingCenter, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: TextEntryHiliteSmallRepeatingCenter, 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;+ COMBOBOXLISTBOXENABLEDDRAWDATA = IMAGE: BlackSquare, COLOR: 0 0 0 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: ListBoxHiliteItemLeftEnd, COLOR: 255 255 0 255, BORDERCOLOR: 254 254 254 255,+ IMAGE: ListBoxHiliteItemRightEnd, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: ListBoxHiliteItemRepeatingCenter, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: ListBoxHiliteItemSmallRepeatingCenter, 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;+ COMBOBOXLISTBOXDISABLEDDRAWDATA = IMAGE: BlackSquare, COLOR: 0 0 0 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 192 192 192 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;+ COMBOBOXLISTBOXHILITEDRAWDATA = IMAGE: BlackSquare, COLOR: 0 0 0 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: ListBoxHiliteSelectedItemLeftEnd, COLOR: 254 254 254 255, BORDERCOLOR: 0 128 0 255,+ IMAGE: ListBoxHiliteSelectedItemRightEnd, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: ListBoxHiliteSelectedItemRepeatingCenter, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: ListBoxHiliteSelectedItemSmallRepeatingCenter, 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;+ LISTBOXENABLEDUPBUTTONDRAWDATA = IMAGE: VSliderUpButtonEnabled, COLOR: 255 0 0 255, BORDERCOLOR: 255 128 128 255,+ IMAGE: VSliderUpButtonHiliteSelected, COLOR: 255 255 0 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;+ LISTBOXDISABLEDUPBUTTONDRAWDATA = IMAGE: VSliderUpButtonDisabled, COLOR: 128 128 128 255, BORDERCOLOR: 192 192 192 255,+ IMAGE: NoImage, COLOR: 192 192 192 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;+ LISTBOXHILITEUPBUTTONDRAWDATA = IMAGE: VSliderUpButtonHilite, COLOR: 0 255 0 255, BORDERCOLOR: 0 128 0 255,+ IMAGE: VSliderUpButtonHiliteSelected, COLOR: 254 254 254 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;+ LISTBOXENABLEDDOWNBUTTONDRAWDATA = IMAGE: VSliderDownButtonEnabled, COLOR: 255 0 0 255, BORDERCOLOR: 255 128 128 255,+ IMAGE: VSliderDownButtonHiliteSelected, COLOR: 255 255 0 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;+ LISTBOXDISABLEDDOWNBUTTONDRAWDATA = IMAGE: VSliderDownButtonDisabled, COLOR: 128 128 128 255, BORDERCOLOR: 192 192 192 255,+ IMAGE: NoImage, COLOR: 192 192 192 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;+ LISTBOXHILITEDOWNBUTTONDRAWDATA = IMAGE: VSliderDownButtonHilite, COLOR: 0 255 0 255, BORDERCOLOR: 0 128 0 255,+ IMAGE: VSliderDownButtonHiliteSelected, COLOR: 254 254 254 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;+ LISTBOXENABLEDSLIDERDRAWDATA = IMAGE: NoImage, COLOR: 168 255 12 0, 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;+ LISTBOXDISABLEDSLIDERDRAWDATA = IMAGE: NoImage, COLOR: 128 128 128 0, BORDERCOLOR: 148 112 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;+ LISTBOXHILITESLIDERDRAWDATA = IMAGE: NoImage, COLOR: 0 255 0 0, BORDERCOLOR: 49 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;+ SLIDERTHUMBENABLEDDRAWDATA = IMAGE: ScrollBarThumbEnabled, COLOR: 255 4 0 0, BORDERCOLOR: 255 243 28 255,+ IMAGE: ScrollBarThumbHiliteSelected, COLOR: 255 255 0 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;+ SLIDERTHUMBDISABLEDDRAWDATA = IMAGE: ScrollBarThumbDisabled, COLOR: 128 128 128 255, BORDERCOLOR: 192 192 192 255,+ IMAGE: NoImage, COLOR: 192 192 192 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;+ SLIDERTHUMBHILITEDRAWDATA = IMAGE: ScrollBarThumbHilite, COLOR: 0 255 0 255, BORDERCOLOR: 0 128 0 255,+ IMAGE: ScrollBarThumbHiliteSelected, COLOR: 254 254 254 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;+ END+ CHILD+ WINDOW+ WINDOWTYPE = STATICTEXT;+ SCREENRECT = UPPERLEFT: 34 238, BOTTOMRIGHT: 258 262, CREATIONRESOLUTION: 800 600;NAME = "OptionsMenu.wnd:ResolutionLabel";STATUS = ENABLED;STYLE = STATICTEXT+MOUSETRACK;@@ -1301,7 +1589,7 @@ WINDOWCHILDWINDOWWINDOWTYPE = COMBOBOX;- SCREENRECT = UPPERLEFT: 40 206, BOTTOMRIGHT: 264 230, CREATIONRESOLUTION: 800 600;+ SCREENRECT = UPPERLEFT: 40 262, BOTTOMRIGHT: 264 286, CREATIONRESOLUTION: 800 600;NAME = "OptionsMenu.wnd:ComboBoxResolution";STATUS = ENABLED+IMAGE;STYLE = MOUSETRACK+COMBOBOX;@@ -1540,7 +1828,7 @@ WINDOWCHILDWINDOWWINDOWTYPE = STATICTEXT;- SCREENRECT = UPPERLEFT: 34 238, BOTTOMRIGHT: 258 262, CREATIONRESOLUTION: 800 600;+ SCREENRECT = UPPERLEFT: 34 294, BOTTOMRIGHT: 258 318, CREATIONRESOLUTION: 800 600;NAME = "OptionsMenu.wnd:LabelWindowMode";TOOLTIPTEXT = "TOOLTIP:WindowMode";STATUS = ENABLED;@@ -1588,7 +1876,7 @@ WINDOWCHILDWINDOWWINDOWTYPE = COMBOBOX;- SCREENRECT = UPPERLEFT: 40 262, BOTTOMRIGHT: 264 286, CREATIONRESOLUTION: 800 600;+ SCREENRECT = UPPERLEFT: 40 318, BOTTOMRIGHT: 264 342, CREATIONRESOLUTION: 800 600;NAME = "OptionsMenu.wnd:ComboBoxWindowMode";TOOLTIPTEXT = "TOOLTIP:WindowMode";STATUS = ENABLED+IMAGE;@@ -1828,7 +2116,7 @@ WINDOWCHILDWINDOWWINDOWTYPE = CHECKBOX;- SCREENRECT = UPPERLEFT: 40 294, BOTTOMRIGHT: 264 318, CREATIONRESOLUTION: 800 600;+ SCREENRECT = UPPERLEFT: 40 350, BOTTOMRIGHT: 264 374, CREATIONRESOLUTION: 800 600;NAME = "OptionsMenu.wnd:CheckVSync";STATUS = ENABLED+IMAGE+BORDER;STYLE = CHECKBOX+MOUSETRACK;diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.hindex 4934f7e85..876727443 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h@@ -141,6 +141,8 @@ public:Bool m_windowed;Int m_windowMode; ///< WindowModeType: fullscreen, borderless or windowed. m_windowed///< is derived from it and is what the device layer reads.+ AsciiString m_monitor; ///< the monitor the game is on, as its GDI device name ("\\.\DISPLAY2");+ ///< empty is the primary. See Common/Monitors.h.Int m_msaaLevel; ///< multisampling, as an index into the levels the options menu offersBool m_vsync; ///< wait for the monitor; off is the uncapped picture the frame-rate cap removal shippedBool m_direct3D11; ///< draw and present through the Direct3D 11 backend; -d3d9 and -headless turn it offdiff --git a/GeneralsMD/Code/GameEngine/Include/Common/Monitors.h b/GeneralsMD/Code/GameEngine/Include/Common/Monitors.hnew file mode 100644index 000000000..8200cfe14--- /dev/null+++ b/GeneralsMD/Code/GameEngine/Include/Common/Monitors.h@@ -0,0 +1,184 @@+/*+** Command & Conquer Generals Zero Hour(tm)+** Copyright 2025 Electronic Arts Inc.+**+** This program is free software: you can redistribute it and/or modify+** it under the terms of the GNU General Public License as published by+** the Free Software Foundation, either version 3 of the License, or+** (at your option) any later version.+**+** This program is distributed in the hope that it will be useful,+** but WITHOUT ANY WARRANTY; without even the implied warranty of+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+** GNU General Public License for more details.+**+** You should have received a copy of the GNU General Public License+** along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++#pragma once++// Monitors.h+//+// The monitors on the desktop and the sizes each one offers, asked of Windows directly.+//+// The resolution list used to be the first Direct3D 9 adapter's, whichever monitor that was, while+// the display mode was changed on the primary and every window was put at the desktop's origin. So+// the game could only ever be on the primary, and the list described the primary only by luck.+// Everything that places the window or picks its size asks here now: WinMain before the engine+// exists, which is why this is header-only and speaks plain C strings, applyWindowMode for+// borderless, W3DDisplay for the window and the options menu for both of its lists.+//+// A monitor is named by its GDI device, "\\.\DISPLAY2". That is what Options.ini stores under+// Monitor and what ChangeDisplaySettingsEx takes. A name that is empty, or that no monitor answers+// to any more because it was unplugged, means the primary.++#include <windows.h>+#include <stdlib.h>+#include <string.h>++struct MonitorEntry+{+ char device[CCHDEVICENAME]; ///< "\\.\DISPLAY2"+ char name[128]; ///< what the monitor calls itself, "Lenovo Y27-30"; can be empty+ int number; ///< the 2 in DISPLAY2, and what the options menu shows first+ RECT rect; ///< where it sits on the desktop, in pixels+ bool primary;+};++struct DisplayModeEntry+{+ int width;+ int height;+};++enum+{+ MAX_MONITOR_ENTRIES = 16,+ MAX_DISPLAY_MODE_ENTRIES = 128,+};++// The floor the game's layouts are drawn for, and the colour depth the renderer asks for.+enum+{+ MIN_DISPLAY_MODE_WIDTH = 800,+ MIN_DISPLAY_MODE_HEIGHT = 600,+ MIN_DISPLAY_MODE_BITS = 24,+};++struct MonitorCollection+{+ MonitorEntry *entries;+ int capacity;+ int count;+};++inline BOOL CALLBACK collectMonitor( HMONITOR monitor, HDC, LPRECT, LPARAM collectionAddress )+{+ MonitorCollection *collection = (MonitorCollection *)collectionAddress;+ if (collection->count == collection->capacity)+ return FALSE;++ MONITORINFOEXA info;+ info.cbSize = sizeof( info );+ if (!::GetMonitorInfoA( monitor, &info ))+ return TRUE;++ MonitorEntry &entry = collection->entries[collection->count++];+ ::strncpy( entry.device, info.szDevice, sizeof( entry.device ) - 1 );+ entry.device[sizeof( entry.device ) - 1] = 0;+ entry.number = ::atoi( entry.device + ::strcspn( entry.device, "0123456789" ) );+ entry.rect = info.rcMonitor;+ entry.primary = (info.dwFlags & MONITORINFOF_PRIMARY) != 0;++ // Device 0 under an adapter is the monitor plugged into it. A monitor Windows has no driver+ // for calls itself "Generic PnP Monitor", which is why the number goes in front of the name.+ DISPLAY_DEVICEA attached;+ attached.cb = sizeof( attached );+ entry.name[0] = 0;+ if (::EnumDisplayDevicesA( entry.device, 0, &attached, 0 ))+ {+ ::strncpy( entry.name, attached.DeviceString, sizeof( entry.name ) - 1 );+ entry.name[sizeof( entry.name ) - 1] = 0;+ }+ return TRUE;+}++/** Every monitor on the desktop, in the order of their numbers. */+inline int listMonitors( MonitorEntry *entries, int capacity )+{+ MonitorCollection collection = { entries, capacity, 0 };+ ::EnumDisplayMonitors( NULL, NULL, collectMonitor, (LPARAM)&collection );++ for (int sorted = 1; sorted < collection.count; ++sorted)+ {+ const MonitorEntry moving = entries[sorted];+ int at = sorted;+ for (; at > 0 && entries[at - 1].number > moving.number; --at)+ entries[at] = entries[at - 1];+ entries[at] = moving;+ }+ return collection.count;+}++/** The monitor with this device name, or the primary when none has it. */+inline MonitorEntry findMonitor( const char *device )+{+ MonitorEntry monitors[MAX_MONITOR_ENTRIES];+ const int count = listMonitors( monitors, MAX_MONITOR_ENTRIES );++ int primary = -1;+ for (int index = 0; index < count; ++index)+ {+ if (::_stricmp( monitors[index].device, device ) == 0)+ return monitors[index];+ if (monitors[index].primary)+ primary = index;+ }+ if (primary >= 0)+ return monitors[primary];++ // A session with no desktop to enumerate: the screen as GetSystemMetrics sees it, which is+ // what every caller of this used before there was a choice.+ MonitorEntry screen;+ ::ZeroMemory( &screen, sizeof( screen ) );+ screen.rect.right = ::GetSystemMetrics( SM_CXSCREEN );+ screen.rect.bottom = ::GetSystemMetrics( SM_CYSCREEN );+ screen.primary = true;+ return screen;+}++/** The sizes this monitor can be set to, smallest first and each once, whatever refresh rates and+ * colour depths Windows lists it under. Only the modes the monitor itself accepts: without+ * EDS_RAWMODE Windows leaves out what the monitor's own description rules out. */+inline int listDisplayModes( const char *device, DisplayModeEntry *entries, int capacity )+{+ int count = 0;+ DEVMODEA mode;+ ::ZeroMemory( &mode, sizeof( mode ) );+ mode.dmSize = sizeof( mode );++ for (DWORD modeIndex = 0; ::EnumDisplaySettingsA( device, modeIndex, &mode ); ++modeIndex)+ {+ const int width = (int)mode.dmPelsWidth;+ const int height = (int)mode.dmPelsHeight;+ if (mode.dmBitsPerPel < MIN_DISPLAY_MODE_BITS+ || width < MIN_DISPLAY_MODE_WIDTH || height < MIN_DISPLAY_MODE_HEIGHT)+ continue;++ int at = 0;+ while (at < count && (entries[at].width < width+ || (entries[at].width == width && entries[at].height < height)))+ ++at;+ if (at < count && entries[at].width == width && entries[at].height == height)+ continue;+ if (count == capacity)+ break;++ ::memmove( entries + at + 1, entries + at, (count - at) * sizeof( entries[0] ) );+ entries[at].width = width;+ entries[at].height = height;+ ++count;+ }+ return count;+}diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Display.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Display.hindex 502acf8f4..2346ab75a 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/Display.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Display.h@@ -89,8 +89,6 @@ public:virtual void setWindowed( Bool windowed ) { m_windowed = windowed; } ///< set windowd/fullscreen flagvirtual Bool getWindowed( void ) { return m_windowed; } ///< return widowed/fullscreen flagvirtual Bool setDisplayMode( UnsignedInt xres, UnsignedInt yres, UnsignedInt bitdepth, Bool windowed ); ///<sets screen resolution/mode- virtual Int getDisplayModeCount(void) {return 0;} ///<return number of display modes/resolutions supported by video card.- virtual void getDisplayModeDescription(Int modeIndex, Int *xres, Int *yres, Int *bitDepth) {} ///<return description of modevirtual void setGamma(Real gamma, Real bright, Real contrast, Bool calibrate) {};virtual Bool testMinSpecRequirements(Bool *videoPassed, Bool *cpuPassed, Bool *memPassed,StaticGameLODLevel *idealVideoLevel=NULL, Real *cpuTime=NULL) {*videoPassed=*cpuPassed=*memPassed=true; return true;}virtual void doSmartAssetPurgeAndPreload(const char* usageFileName) = 0;diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cppindex 3e47d940d..12dadfa7a 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp@@ -44,6 +44,7 @@#include "Common/FileSystem.h"#include "Common/GameAudio.h"#include "Common/INI.h"+#include "Common/Monitors.h"#include "Common/OptionsCatalog.h"#include "Common/registry.h"#include "Common/UserPreferences.h"@@ -1444,6 +1445,7 @@ void GlobalData::parseGameDataDefinition( INI* ini )TheWritableGlobalData->m_xResolution = xres;TheWritableGlobalData->m_yResolution = yres;+ TheWritableGlobalData->m_monitor = optionPref["Monitor"];// Everything in TheOptionCatalog, in one pass, and last: a row is allowed to overwrite what the// hand-written block above just read. This is also why the catalog is read here and not in@@ -1477,8 +1479,9 @@ void applyWindowMode( void )if( mode == WINDOW_MODE_BORDERLESS ){- TheWritableGlobalData->m_xResolution = ::GetSystemMetrics( SM_CXSCREEN );- TheWritableGlobalData->m_yResolution = ::GetSystemMetrics( SM_CYSCREEN );+ const MonitorEntry monitor = findMonitor( TheWritableGlobalData->m_monitor.str() );+ TheWritableGlobalData->m_xResolution = monitor.rect.right - monitor.rect.left;+ TheWritableGlobalData->m_yResolution = monitor.rect.bottom - monitor.rect.top;// there is no desktop left around a borderless window to park the cursor on, so scrolling at// the edge is the only way the mouse moves the cameradiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cppindex 5a7b19ed7..189bf883f 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp@@ -38,6 +38,7 @@#include "Common/GameEngine.h"#include "Common/UserPreferences.h"#include "Common/GameLOD.h"+#include "Common/Monitors.h"#include "Common/OptionsCatalog.h"#include "Common/Registry.h"#include "Common/Version.h"@@ -94,7 +95,18 @@ static NameKeyType comboBoxAntiAliasingID = NAMEKEY_INVALID;static GameWindow * comboBoxAntiAliasing = NULL;static NameKeyType comboBoxResolutionID = NAMEKEY_INVALID;-static GameWindow * comboBoxResolution = NULL;+static GameWindow * comboBoxResolution = NULL;++static NameKeyType comboBoxMonitorID = NAMEKEY_INVALID;+static GameWindow * comboBoxMonitor = NULL;++// What the two display lists hold, entry for entry: the monitors on the desktop, and the sizes the+// monitor picked in the first list offers. Filled when the menu opens and, for the sizes, again+// whenever another monitor is picked.+static MonitorEntry menuMonitors[MAX_MONITOR_ENTRIES];+static Int menuMonitorCount = 0;+static DisplayModeEntry menuModes[MAX_DISPLAY_MODE_ENTRIES];+static Int menuModeCount = 0;static NameKeyType comboBoxDetailID = NAMEKEY_INVALID;static GameWindow * comboBoxDetail = NULL;@@ -883,24 +895,6 @@ static void setDefaults( void )};}- //-------------------------------------------------------------------------------------------------- // Resolution- //Find index of 800x600 mode.- if (modifyDisplaySettings && ((TheGameLogic->isInGame() == FALSE) || (TheGameLogic->isInShellGame() == TRUE) && !TheGameSpyInfo)) {- Int numResolutions = TheDisplay->getDisplayModeCount();- Int defaultResIndex=0;- for( Int i = 0; i < numResolutions; ++i )- { Int xres,yres,bitDepth;- TheDisplay->getDisplayModeDescription(i,&xres,&yres,&bitDepth);- if (xres == 800 && yres == 600) //keep track of default mode in case we need it.- { defaultResIndex=i;- break;- }- }- GadgetComboBoxSetSelectedPos( comboBoxResolution, defaultResIndex ); //should be 800x600 (our lowest supported mode)- }--//-------------------------------------------------------------------------------------------------// Mouse ModeGadgetCheckBoxSetChecked(checkRetaliation, TRUE );@@ -1106,6 +1100,78 @@ static void readCatalogWidgets( void )}}+static const Color MENU_ENTRY_COLOR = GameMakeColor( 255, 255, 255, 255 );++//-------------------------------------------------------------------------------------------------+/** The monitor picked in the monitor list. */+//-------------------------------------------------------------------------------------------------+static MonitorEntry selectedMonitor( void )+{+ Int index = -1;+ GadgetComboBoxGetSelectedPos( comboBoxMonitor, &index );+ if( index >= 0 && index < menuMonitorCount )+ return menuMonitors[ index ];+ return findMonitor( TheGlobalData->m_monitor.str() );+}++//-------------------------------------------------------------------------------------------------+/** Fill the resolution list with the sizes this monitor offers, and pick the one asked for. A+ * monitor that does not have it gets its own desktop size instead, which is the one size every+ * monitor is sure to show well. */+//-------------------------------------------------------------------------------------------------+static void fillResolutionList( const MonitorEntry &monitor, Int wantedWidth, Int wantedHeight )+{+ const Int desktopWidth = monitor.rect.right - monitor.rect.left;+ const Int desktopHeight = monitor.rect.bottom - monitor.rect.top;++ menuModeCount = listDisplayModes( monitor.device, menuModes, MAX_DISPLAY_MODE_ENTRIES );+ GadgetComboBoxReset( comboBoxResolution );++ Int wanted = -1;+ Int desktop = 0;+ for( Int index = 0; index < menuModeCount; ++index )+ {+ const DisplayModeEntry &mode = menuModes[ index ];+ UnicodeString text;+ text.format( L"%d x %d", mode.width, mode.height );+ GadgetComboBoxAddEntry( comboBoxResolution, text, MENU_ENTRY_COLOR );++ if( mode.width == wantedWidth && mode.height == wantedHeight )+ wanted = index;+ if( mode.width == desktopWidth && mode.height == desktopHeight )+ desktop = index;+ }+ GadgetComboBoxSetSelectedPos( comboBoxResolution, wanted >= 0 ? wanted : desktop );+}++//-------------------------------------------------------------------------------------------------+/** Every monitor on the desktop, by its number and the name it gives itself, with the one the game+ * is on picked. */+//-------------------------------------------------------------------------------------------------+static void fillMonitorList( void )+{+ const MonitorEntry current = findMonitor( TheGlobalData->m_monitor.str() );++ menuMonitorCount = listMonitors( menuMonitors, MAX_MONITOR_ENTRIES );+ GadgetComboBoxReset( comboBoxMonitor );++ Int selected = 0;+ for( Int index = 0; index < menuMonitorCount; ++index )+ {+ const MonitorEntry &monitor = menuMonitors[ index ];+ UnicodeString text;+ if( monitor.name[ 0 ] )+ text.format( L"%d: %hs", monitor.number, monitor.name );+ else+ text.format( L"%d", monitor.number );+ GadgetComboBoxAddEntry( comboBoxMonitor, text, MENU_ENTRY_COLOR );++ if( ::_stricmp( monitor.device, current.device ) == 0 )+ selected = index;+ }+ GadgetComboBoxSetSelectedPos( comboBoxMonitor, selected );+}+//-------------------------------------------------------------------------------------------------/** Borderless fullscreen takes the desktop's resolution and nothing else, so while it is the* selected mode the resolution list has no say and says so by going grey. Fullscreen and@@ -1153,10 +1219,14 @@ static void saveOptions( void )// which of the three the window is wearing right now, before the controls overwrite itconst Int oldWindowMode = TheGlobalData->m_windowMode;const Bool oldVSync = TheGlobalData->m_vsync;+ const MonitorEntry oldMonitor = findMonitor( TheGlobalData->m_monitor.str() );//-------------------------------------------------------------------------------------------------// The catalog's controls, read back into GlobalData before the pass below writes GlobalData out.+ // The monitor goes in with them, because a borderless window takes its size from it.readCatalogWidgets();+ const MonitorEntry monitor = selectedMonitor();+ TheWritableGlobalData->m_monitor = monitor.device;//// A catalog row writes its own GlobalData field and nothing else, so the window mode is a raw@@ -1329,9 +1399,11 @@ static void saveOptions( void )xres = TheGlobalData->m_xResolution;yres = TheGlobalData->m_yResolution;bitDepth = TheDisplay->getBitDepth();- if( TheGlobalData->m_windowMode != WINDOW_MODE_BORDERLESS- && index >= 0 && index < TheDisplay->getDisplayModeCount() )- TheDisplay->getDisplayModeDescription( index, &xres, &yres, &bitDepth );+ if( TheGlobalData->m_windowMode != WINDOW_MODE_BORDERLESS && index >= 0 && index < menuModeCount )+ {+ xres = menuModes[ index ].width;+ yres = menuModes[ index ].height;+ }//// Not the windowed flag: borderless and windowed are both windowed devices, and a switch between@@ -1340,13 +1412,21 @@ static void saveOptions( void )const Bool sizeChanged = ( oldDispSettings.xRes != xres || oldDispSettings.yRes != yres );const Bool modeChanged = ( oldWindowMode != TheGlobalData->m_windowMode );const Bool vsyncChanged = ( oldVSync != TheGlobalData->m_vsync );+ const Bool monitorChanged = ( ::_stricmp( oldMonitor.device, monitor.device ) != 0 );- if( sizeChanged || modeChanged || vsyncChanged )+ if( sizeChanged || modeChanged || vsyncChanged || monitorChanged ){- if (TheDisplay->setDisplayMode(xres,yres,bitDepth,TheGlobalData->m_windowed))+ if( !TheDisplay->setDisplayMode( xres, yres, bitDepth, TheGlobalData->m_windowed ) )+ {+ // the game is still where it was, so the window's next move must not go anywhere else+ TheWritableGlobalData->m_monitor = oldMonitor.device;+ applyWindowMode();+ }+ else{TheWritableGlobalData->m_xResolution = xres;TheWritableGlobalData->m_yResolution = yres;+ (*pref)["Monitor"] = monitor.device;TheHeaderTemplateManager->headerNotifyResolutionChange();TheMouse->mouseNotifyResolutionChange();@@ -1673,19 +1753,22 @@ void ResolutionDrillApply( Int xres, Int yres )const Int wasY = TheDisplay->getHeight();const Int bitDepth = TheDisplay->getBitDepth();- // With no size asked for, take the first mode the device offers that is not the one on screen.+ // The list the options menu is about to show, which is the monitor the game is on.+ DisplayModeEntry modes[ MAX_DISPLAY_MODE_ENTRIES ];+ const Int modeCount = listDisplayModes( findMonitor( TheGlobalData->m_monitor.str() ).device,+ modes, MAX_DISPLAY_MODE_ENTRIES );++ // With no size asked for, take the first mode the monitor offers that is not the one on screen.// A drill that had to be told the monitor's modes would be a drill nobody runs on a new machine.if( xres <= 0 || yres <= 0 ){xres = yres = 0;- for( Int i = 0; i < TheDisplay->getDisplayModeCount(); i++ )+ for( Int i = 0; i < modeCount; i++ ){- Int mx, my, mb;- TheDisplay->getDisplayModeDescription( i, &mx, &my, &mb );- if( mx >= 800 && my >= 600 && ( mx != wasX || my != wasY ) )+ if( modes[ i ].width != wasX || modes[ i ].height != wasY ){- xres = mx;- yres = my;+ xres = modes[ i ].width;+ yres = modes[ i ].height;break;}}@@ -1697,14 +1780,12 @@ void ResolutionDrillApply( Int xres, Int yres )return;}- // which entry of the dropdown that is: the combo is filled straight off the device's mode list,- // so the entry index and the mode index are the same number+ // which entry of the dropdown that is: the combo is filled straight off the same list, so the+ // entry index and the mode index are the same numberInt modeIndex = -1;- for( Int m = 0; m < TheDisplay->getDisplayModeCount(); m++ )+ for( Int m = 0; m < modeCount; m++ ){- Int mx, my, mb;- TheDisplay->getDisplayModeDescription( m, &mx, &my, &mb );- if( mx == xres && my == yres )+ if( modes[ m ].width == xres && modes[ m ].height == yres ){modeIndex = m;break;@@ -1712,7 +1793,7 @@ void ResolutionDrillApply( Int xres, Int yres )}if( modeIndex < 0 ){- DEBUG_LOG(("RESDRILL: %dx%d is not a mode this device offers\n", xres, yres));+ DEBUG_LOG(("RESDRILL: %dx%d is not a mode this monitor offers\n", xres, yres));return;}@@ -2084,6 +2165,8 @@ void OptionsMenuInit( WindowLayout *layout, void *userData )comboBoxAntiAliasing = TheWindowManager->winGetWindowFromId( NULL, comboBoxAntiAliasingID );comboBoxResolutionID = TheNameKeyGenerator->nameToKey( AsciiString( "OptionsMenu.wnd:ComboBoxResolution" ) );comboBoxResolution = TheWindowManager->winGetWindowFromId( NULL, comboBoxResolutionID );+ comboBoxMonitorID = TheNameKeyGenerator->nameToKey( AsciiString( "OptionsMenu.wnd:ComboBoxMonitor" ) );+ comboBoxMonitor = TheWindowManager->winGetWindowFromId( NULL, comboBoxMonitorID );comboBoxDetailID = TheNameKeyGenerator->nameToKey( AsciiString( "OptionsMenu.wnd:ComboBoxDetail" ) );comboBoxDetail = TheWindowManager->winGetWindowFromId( NULL, comboBoxDetailID );@@ -2312,45 +2395,9 @@ void OptionsMenuInit( WindowLayout *layout, void *userData )}GadgetComboBoxSetSelectedPos(comboBoxAntiAliasing, val);- // get resolution from saved preferences file- AsciiString selectedResolution = (*pref) ["Resolution"];- Int selectedXRes=800,selectedYRes=600;- Int selectedResIndex=-1;- Int defaultResIndex=0; //index of default video mode that should always exist- if (!selectedResolution.isEmpty())- { //try to parse 2 integers out of string- if (sscanf(selectedResolution.str(),"%d%d", &selectedXRes, &selectedYRes) != 2)- { selectedXRes=800; selectedYRes=600;- }- }-- // populate resolution modes- GadgetComboBoxReset(comboBoxResolution);- Int numResolutions = TheDisplay->getDisplayModeCount();- // i is used after the loop; VC6 for-scope let it escape.- Int i;- for( i = 0; i < numResolutions; ++i )- { Int xres,yres,bitDepth;- TheDisplay->getDisplayModeDescription(i,&xres,&yres,&bitDepth);- str.format(L"%d x %d",xres,yres);- GadgetComboBoxAddEntry( comboBoxResolution, str, color);- if (xres == 800 && yres == 600) //keep track of default mode in case we need it.- defaultResIndex=i;- if (xres == selectedXRes && yres == selectedYRes)- selectedResIndex=i;- }-- if (selectedResIndex == -1) //check if saved mode no longer available- { //pick default resolution- selectedXRes = 800;- selectedXRes = 600;- selectedResIndex = defaultResIndex;- }-- TheWritableGlobalData->m_xResolution = selectedXRes;- TheWritableGlobalData->m_yResolution = selectedYRes;-- GadgetComboBoxSetSelectedPos( comboBoxResolution, selectedResIndex );+ // the monitor the game is on, and the size it is showing there+ fillMonitorList();+ fillResolutionList( selectedMonitor(), TheDisplay->getWidth(), TheDisplay->getHeight() );// set the display detailGadgetComboBoxReset(comboBoxDetail);@@ -2717,6 +2764,16 @@ WindowMsgHandledType OptionsMenuSystem( GameWindow *window, UnsignedInt msg,GadgetComboBoxGetSelectedPos( comboBoxDetail, &index );showDetailPreset( index );}+ else if( controlID == comboBoxMonitorID )+ {+ // another monitor offers other sizes; keep the picked one where it has it+ Int index = -1;+ GadgetComboBoxGetSelectedPos( comboBoxResolution, &index );+ const Bool picked = ( index >= 0 && index < menuModeCount );+ fillResolutionList( selectedMonitor(),+ picked ? menuModes[ index ].width : TheDisplay->getWidth(),+ picked ? menuModes[ index ].height : TheDisplay->getHeight() );+ }else if( isDetailPresetCatalogControl( control ) ){markDetailCustom();diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DDisplay.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DDisplay.hindex 81ee1bf04..999b137ed 100644--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DDisplay.h+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DDisplay.h@@ -67,8 +67,6 @@ public:virtual void setWidth( UnsignedInt width );virtual void setHeight( UnsignedInt height );virtual Bool setDisplayMode( UnsignedInt xres, UnsignedInt yres, UnsignedInt bitdepth, Bool windowed );- virtual Int getDisplayModeCount(void); ///<return number of display modes/resolutions supported by video card.- virtual void getDisplayModeDescription(Int modeIndex, Int *xres, Int *yres, Int *bitDepth); ///<return description of modevirtual void setGamma(Real gamma, Real bright, Real contrast, Bool calibrate);virtual void doSmartAssetPurgeAndPreload(const char* usageFileName);#if defined(_DEBUG) || defined(_INTERNAL)diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cppindex 1d8dcba55..31220353d 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp@@ -44,6 +44,7 @@ static void drawFramerateBar(void);#include "Common/ThingFactory.h"#include "Common/GameEngine.h"#include "Common/GlobalData.h"+#include "Common/Monitors.h"#include "Common/OptionsCatalog.h"#include "dx8wrapper.h"#include "ffprobe.h"@@ -594,9 +595,6 @@ W3DDisplay::~W3DDisplay()} // end ~W3DDisplay-#define MIN_DISPLAY_RESOLUTION_X 800-#define MIN_DISPLAY_RESOLUTOIN_Y 600-Bool IS_FOUR_BY_THREE_ASPECT( Real x, Real y ){@@ -609,67 +607,6 @@ Bool IS_FOUR_BY_THREE_ASPECT( Real x, Real y )}-/*Return number of screen modes supported by the current device*/-Int W3DDisplay::getDisplayModeCount(void)-{- const RenderDeviceDescClass &devDesc=WW3D::Get_Render_Device_Desc(0);- const DynamicVectorClass <ResolutionDescClass> &resolutions=devDesc.Enumerate_Resolutions();-- Int numResolutions=0;-/* Bool needStencil=false;- Bool needDestinationAlpha=false;- Int minBitDepth=16;-- //Walk through all resolutions and determine which ones are compatible with other settings- //chosen by user. For example, 32-bit may be required for shadows, occlusion, soft water edge, etc.- if (TheGlobalData->m_useShadowVolumes || (TheGlobalData->m_enableBehindBuildingMarkers && TheGameLogic->getShowBehindBuildingMarkers()))- needStencil=true;-- if (TheGlobalData->m_showSoftWaterEdge)- { minBitDepth=32;- }-*/- for (int res = 0; res < resolutions.Count (); res ++)- {- // Is this the resolution we are looking for?- // Widescreen (PLAN.md Phase 6): the 4:3-only filter is gone - the camera- // now widens its FOV per aspect (W3DView::setWidth), so any mode the- // device offers above the floor is playable.- if (resolutions[res].BitDepth >= 24 && resolutions[res].Width >= MIN_DISPLAY_RESOLUTION_X- && resolutions[res].Height >= MIN_DISPLAY_RESOLUTOIN_Y )- {- numResolutions++;- }- }-- return numResolutions;-}--void W3DDisplay::getDisplayModeDescription(Int modeIndex, Int *xres, Int *yres, Int *bitDepth)-{- Int numResolutions=0;- const RenderDeviceDescClass &devDesc=WW3D::Get_Render_Device_Desc(0);- const DynamicVectorClass <ResolutionDescClass> &resolutions=devDesc.Enumerate_Resolutions();-- for (int res = 0; res < resolutions.Count (); res ++)- {- // Is this the resolution we are looking for?- // Same filter as getDisplayModeCount - the two must agree or indices shift.- if ( resolutions[res].BitDepth >= 24 && resolutions[res].Width >= MIN_DISPLAY_RESOLUTION_X- && resolutions[res].Height >= MIN_DISPLAY_RESOLUTOIN_Y )- {- if (numResolutions == modeIndex)- { //found the mode- *xres=resolutions[res].Width;- *yres=resolutions[res].Height;- *bitDepth=resolutions[res].BitDepth;- return;- }- numResolutions++;- }- }-}-void W3DDisplay::setGamma(Real gamma, Real bright, Real contrast, Bool calibrate){if (m_windowed)@@ -713,6 +650,14 @@ void Reset_D3D_Device(bool active)}}+//=============================================================================+/** The monitor Options.ini names, or the primary. */+//=============================================================================+static MonitorEntry chosenMonitor( void )+{+ return findMonitor( TheGlobalData ? TheGlobalData->m_monitor.str() : "" );+}+//=============================================================================/** Dress the application window for one WindowModeType, while the game is running.*@@ -744,19 +689,20 @@ static void applyWindowFrame( Int mode )//// The resize that follows keeps the top left corner where it is (SWP_NOMOVE), so a window that- // is about to cover the display is put at the origin now - otherwise it hangs off the bottom- // right by however far down the screen it happened to be sitting.+ // is about to cover the display is put at the monitor's corner now - otherwise it hangs off the+ // bottom right by however far down the screen it happened to be sitting.//- const UINT move = ( mode == WINDOW_MODE_WINDOWED ) ? SWP_NOMOVE : 0;+ const RECT screen = chosenMonitor().rect;+ const UINT move =( mode == WINDOW_MODE_WINDOWED ) ? SWP_NOMOVE : 0;::SetWindowPos( ApplicationHWnd,( mode == WINDOW_MODE_WINDOWED ) ? HWND_TOP : HWND_TOPMOST,- 0, 0, 0, 0, SWP_NOSIZE | SWP_FRAMECHANGED | move );+ screen.left, screen.top, 0, 0, SWP_NOSIZE | SWP_FRAMECHANGED | move );}//=============================================================================/** Give the window a client area exactly this big, wearing whatever frame it now has. A plain- * window goes back to the middle of the screen, where one is born; a borderless one covers the- * display from the origin. Fullscreen is not our business - D3D owns that window. */+ * window goes back to the middle of its monitor, where one is born; a borderless one covers the+ * monitor from its corner. Fullscreen is not our business - D3D owns that window. *///=============================================================================static void sizeWindowToClient( Int mode, Int width, Int height ){@@ -777,11 +723,12 @@ static void sizeWindowToClient( Int mode, Int width, Int height )const Int outerW = rect.right - rect.left;const Int outerH = rect.bottom - rect.top;- Int x = 0, y = 0;+ const RECT screen = chosenMonitor().rect;+ Int x = screen.left, y = screen.top;if( mode == WINDOW_MODE_WINDOWED ){- x = ( ::GetSystemMetrics( SM_CXSCREEN ) - outerW ) / 2;- y = ( ::GetSystemMetrics( SM_CYSCREEN ) - outerH ) / 2;+ x += ( screen.right - screen.left - outerW ) / 2;+ y += ( screen.bottom - screen.top - outerH ) / 2;}::SetWindowPos( ApplicationHWnd,@@ -810,13 +757,15 @@ Bool W3DDisplay::setDisplayMode( UnsignedInt xres, UnsignedInt yres, UnsignedIntextern Bool ApplicationIsBorderless;// WW3D2 cannot see GlobalData, so a vsync change has to be pushed in before the reset below- // the way the sample count is pushed in before the device exists.+ // the way the sample count is pushed in before the device exists. The monitor too: a fullscreen+ // game changes that monitor's mode and nobody else's.if( TheGlobalData ){DX8Wrapper::Set_Requested_VSync( TheGlobalData->m_vsync != FALSE );Direct3D11_Set_VSync( TheGlobalData->m_vsync != FALSE );pushDirect3D11PostChain();}+ DX8Wrapper::Set_Requested_Monitor( chosenMonitor().device );//// Which of the three the window is wearing, and which it is being asked for. The test cannot be@@ -894,6 +843,9 @@ Bool W3DDisplay::setDisplayMode( UnsignedInt xres, UnsignedInt yres, UnsignedIntif (WW3D_ERROR_OK == WW3D::Set_Device_Resolution(xres,yres,bitdepth,windowed,true)){+ // the resize above keeps the window's corner, which is on the old monitor when the options+ // menu has just picked another one+ sizeWindowToClient( mode, xres, yres );Render2DClass::Set_Screen_Resolution(RectClass(0, 0, xres, yres));Display::setDisplayMode(xres, yres, bitdepth, windowed);return TRUE;@@ -1082,6 +1034,7 @@ void W3DDisplay::init( void )? 0 : msaaSamplesForLevel( TheGlobalData->m_msaaLevel ) );DX8Wrapper::Set_Requested_VSync( TheGlobalData->m_vsync != FALSE );Direct3D11_Set_VSync( TheGlobalData->m_vsync != FALSE );+ DX8Wrapper::Set_Requested_Monitor( chosenMonitor().device );// Same reason: WW3D2 cannot see GlobalData, so the backend choice is pushed in from here. The// fixed-function probe and the generated combiner shaders are always on.diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cppindex 4f141d010..26e79d0c4 100644--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp@@ -877,12 +877,35 @@ static bool GameGammaSet = false;static D3DGAMMARAMP DesktopGammaRamp;static D3DGAMMARAMP GameGammaRamp;+// The monitor all of that happens on, as its GDI device name ("\\.\DISPLAY2"). Empty until the app+// layer pushes one in, and then the primary's DC and the primary's mode are what a null name gets.+static char RequestedMonitor[CCHDEVICENAME] = "";++// A gamma ramp belongs to one monitor. The whole-screen DC GetDC(NULL) hands out sets the primary's,+// so a game on another monitor would move the brightness of the one it is not on.+static HDC create_monitor_dc()+{+ return CreateDCA(RequestedMonitor[0] ? RequestedMonitor : "DISPLAY", NULL, NULL, NULL);+}+static void set_desktop_gamma(D3DGAMMARAMP * ramp){- HDC hdc = GetDC(NULL);+ HDC hdc = create_monitor_dc();if (hdc) {SetDeviceGammaRamp(hdc, ramp);- ReleaseDC(NULL, hdc);+ DeleteDC(hdc);+ }+}++static void save_desktop_gamma()+{+ if (DesktopGammaSaved) {+ return;+ }+ HDC hdc = create_monitor_dc();+ if (hdc) {+ DesktopGammaSaved = GetDeviceGammaRamp(hdc, &DesktopGammaRamp) != FALSE;+ DeleteDC(hdc);}}@@ -897,6 +920,19 @@ static void restore_desktop_display()}}+void DX8Wrapper::Set_Requested_Monitor(const char * device)+{+ if (strcmp(device, RequestedMonitor) == 0) {+ return;+ }+ // The monitor being left gets its own mode and ramp back before the game takes another one, and+ // the next ramp saved is the new monitor's.+ restore_desktop_display();+ DesktopGammaSaved = false;+ strncpy(RequestedMonitor, device, sizeof(RequestedMonitor) - 1);+ RequestedMonitor[sizeof(RequestedMonitor) - 1] = 0;+}+void DX8Wrapper::Apply_Fullscreen_Display(bool shown){const bool owns_display = !IsWindowed && Direct3D11_Present_Is_Enabled();@@ -908,23 +944,36 @@ void DX8Wrapper::Apply_Fullscreen_Display(bool shown)return;}- DEVMODE mode;+ const char * monitor = RequestedMonitor[0] ? RequestedMonitor : NULL;+ DEVMODEA mode;ZeroMemory(&mode, sizeof(mode));mode.dmSize = sizeof(mode);mode.dmPelsWidth = ResolutionWidth;mode.dmPelsHeight = ResolutionHeight;mode.dmBitsPerPel = BitDepth;mode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;- if (ChangeDisplaySettingsEx(NULL, &mode, NULL, CDS_FULLSCREEN, NULL) == DISP_CHANGE_SUCCESSFUL) {+ if (ChangeDisplaySettingsExA(monitor, &mode, NULL, CDS_FULLSCREEN, NULL) == DISP_CHANGE_SUCCESSFUL) {DisplayModeChanged = true;}+ // Only the primary starts at the desktop's origin, and a monitor can move when its mode changes,+ // so where it starts is asked after the change.+ DEVMODEA current;+ ZeroMemory(¤t, sizeof(current));+ current.dmSize = sizeof(current);+ POINT origin = { 0, 0 };+ if (monitor && EnumDisplaySettingsExA(monitor, ENUM_CURRENT_SETTINGS, ¤t, 0)) {+ origin.x = current.dmPosition.x;+ origin.y = current.dmPosition.y;+ }+if (::IsIconic(_Hwnd)) {::ShowWindow(_Hwnd, SW_RESTORE);}- ::SetWindowPos(_Hwnd, HWND_TOPMOST, 0, 0, ResolutionWidth, ResolutionHeight, SWP_SHOWWINDOW);+ ::SetWindowPos(_Hwnd, HWND_TOPMOST, origin.x, origin.y, ResolutionWidth, ResolutionHeight, SWP_SHOWWINDOW);if (GameGammaSet) {+ save_desktop_gamma(); // the monitor may have changed since the game's ramp was last setset_desktop_gamma(&GameGammaRamp);}}@@ -4303,13 +4352,7 @@ void DX8Wrapper::Set_Gamma(float gamma,float bright,float contrast,bool calibrat// A windowed Direct3D 9 device ignores its gamma ramp, so the fullscreen display under the// Direct3D 11 picture sets the desktop's, keeps the desktop's own to give back on the way out,// and puts the game's on again when the game comes back.- if (!DesktopGammaSaved) {- HDC hdc = GetDC(NULL);- if (hdc) {- DesktopGammaSaved = GetDeviceGammaRamp(hdc, &DesktopGammaRamp) != FALSE;- ReleaseDC(NULL, hdc);- }- }+ save_desktop_gamma();GameGammaRamp = ramp;GameGammaSet = true;set_desktop_gamma(&GameGammaRamp);diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.hindex d862a2480..956a00e27 100644--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h@@ -599,6 +599,9 @@ public:// mode and gamma back and minimises the window, which is what leaving the game does; true puts// the game's back. A windowed game, or one Direct3D 9 presents, only gets the desktop restored.static void Apply_Fullscreen_Display(bool shown);+ // The monitor that display mode and window go on, as its GDI device name. WW3D2 cannot see+ // GlobalData, so the app layer pushes it in before the device is made or reset, like the vsync.+ static void Set_Requested_Monitor(const char * device);static const DX8Caps* Get_Current_Caps() { WWASSERT(CurrentCaps); return CurrentCaps; }diff --git a/GeneralsMD/Code/Main/WinMain.cpp b/GeneralsMD/Code/Main/WinMain.cppindex 5e567b078..54a2a16d0 100644--- a/GeneralsMD/Code/Main/WinMain.cpp+++ b/GeneralsMD/Code/Main/WinMain.cpp@@ -52,6 +52,7 @@#include "Common/EarlyCommandLine.h"#include "Common/EarlyOptions.h"#include "Common/Errors.h"+#include "Common/Monitors.h"#include "Common/GameMemory.h"#include "Common/INIException.h"#include "Common/SafeDisc/CdaPfn.h"@@ -498,7 +499,10 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message,// Put it at the origin instead.//if (ApplicationIsBorderless)- ::SetWindowPos(hWnd, NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);+ {+ const RECT screen = findMonitor(TheGlobalData ? TheGlobalData->m_monitor.str() : "").rect;+ ::SetWindowPos(hWnd, NULL, screen.left, screen.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);+ }}break;@@ -818,11 +822,17 @@ static Bool initializeAppWindows( HINSTANCE hInstance, Int nCmdShow, Bool runWingInitializing = true;+ // Born in the middle of the monitor Options.ini names, so the splash and then the game are on it+ // from the first frame. The engine cannot say which that is yet.+ char savedMonitor[CCHDEVICENAME];+ findEarlyOptionValue( "Monitor", savedMonitor, sizeof( savedMonitor ) );+ const RECT screen = findMonitor( savedMonitor ).rect;+HWND hWnd = CreateWindow( TEXT("Game Window"),TEXT("Command and Conquer Generals"),- windowStyle,- (GetSystemMetrics( SM_CXSCREEN ) / 2) - (startWidth / 2), // original position X- (GetSystemMetrics( SM_CYSCREEN ) / 2) - (startHeight / 2),// original position Y+ windowStyle,+ (screen.left + screen.right) / 2 - (startWidth / 2), // original position X+ (screen.top + screen.bottom) / 2 - (startHeight / 2),// original position Y// Lorenzen nudged the window higher// so the constantdebug report would// not get obliterated by assert windows, thank you.diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 9e70dffcb..ac23b622d 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -63,6 +63,7 @@#include "Common/CommandLine.h"#include "Common/GlobalData.h"#include "Common/EarlyOptions.h"+#include "Common/Monitors.h"#include "Common/OptionsCatalog.h"#include "Common/SubsystemInterface.h"#include "GameClient/GameText.h"@@ -11389,6 +11390,60 @@ TEST(window_mode_derives_the_boolean_the_device_layer_reads)delete scratch;}+/* The monitor list and the sizes each monitor offers, read off whatever desktop the test runs on.+ On a machine with one monitor everything below is about that one. */+TEST(borderless_covers_the_monitor_options_ini_names)+{+ MonitorEntry monitors[ MAX_MONITOR_ENTRIES ];+ const int count = listMonitors( monitors, MAX_MONITOR_ENTRIES );+ CHECK( count >= 1 );++ // the one checked below is a secondary where the machine has one+ int primaries = 0;+ MonitorEntry chosen = monitors[ 0 ];+ for( int index = 0; index < count; ++index )+ {+ primaries += monitors[ index ].primary ? 1 : 0;+ if( !monitors[ index ].primary )+ chosen = monitors[ index ];+ if( index > 0 )+ CHECK( monitors[ index - 1 ].number < monitors[ index ].number );+ }+ CHECK_EQ( primaries, 1 );++ // an empty name and a name nothing answers to both mean the primary+ CHECK( findMonitor( "" ).primary );+ CHECK( findMonitor( "\\\\.\\DISPLAY999" ).primary );+ CHECK_STR( findMonitor( chosen.device ).device, chosen.device );++ // every size once, smallest first, none under the floor the layouts are drawn for+ DisplayModeEntry modes[ MAX_DISPLAY_MODE_ENTRIES ];+ const int modeCount = listDisplayModes( chosen.device, modes, MAX_DISPLAY_MODE_ENTRIES );+ CHECK( modeCount >= 1 );+ for( int index = 0; index < modeCount; ++index )+ {+ CHECK( modes[ index ].width >= MIN_DISPLAY_MODE_WIDTH );+ CHECK( modes[ index ].height >= MIN_DISPLAY_MODE_HEIGHT );+ if( index > 0 )+ CHECK( modes[ index - 1 ].width < modes[ index ].width+ || ( modes[ index - 1 ].width == modes[ index ].width+ && modes[ index - 1 ].height < modes[ index ].height ) );+ }++ GlobalData *saved = TheWritableGlobalData;+ GlobalData *scratch = NEW GlobalData;+ TheWritableGlobalData = scratch;++ scratch->m_monitor = chosen.device;+ scratch->m_windowMode = WINDOW_MODE_BORDERLESS;+ applyWindowMode();+ CHECK_EQ( TheGlobalData->m_xResolution, (Int)( chosen.rect.right - chosen.rect.left ) );+ CHECK_EQ( TheGlobalData->m_yResolution, (Int)( chosen.rect.bottom - chosen.rect.top ) );++ TheWritableGlobalData = saved;+ delete scratch;+}+TEST(window_mode_survives_a_round_trip_through_options_ini){GlobalData *saved = TheWritableGlobalData;diff --git a/GeneralsMD/Code/Tools/optionsmenu_layout.py b/GeneralsMD/Code/Tools/optionsmenu_layout.pyindex cc45c4180..e0ddbb2d6 100644--- a/GeneralsMD/Code/Tools/optionsmenu_layout.py+++ b/GeneralsMD/Code/Tools/optionsmenu_layout.py@@ -89,6 +89,10 @@ ADVANCED_KEEP = GRAPHICS_CHECKS + ["CheckUnlockFPS", "LowResSlider", "ParticleCa# swaying trees are a GameLOD.ini field like the popup's boxes, so they save under Custom with them.MENU_CHECKS = ["CheckTreeSway"]+# Combo boxes OptionsMenu.cpp fills in by name for the same reason: the monitors on the desktop are+# not a range a catalog row can describe.+MENU_COMBOS = ["ComboBoxMonitor"]+# The catalog's shadow rows, which stood in GameData.ini with no control until the Effects page.SHADOW_CHECKS = ["Check3DShadows", "Check2DShadows", "CheckInfantryShadows","CheckProjectileShadows", "CheckPropShadows", "CheckParticleShadows"]@@ -125,6 +129,8 @@ CHECK, LABEL, COMBO, SLIDER = "Retaliation", "DetailLabel", "ComboBoxDetail", "S# The fork's own controls. Where they stand is decided below with everything else.# (template, name, text key)NEW_CONTROLS = [+ (LABEL, "LabelMonitor", "GUI:Monitor"),+ (COMBO, "ComboBoxMonitor", None),(LABEL, "LabelWindowMode", "GUI:WindowMode"),(COMBO, "ComboBoxWindowMode", None),(CHECK, "CheckVSync", "GUI:VSync"),@@ -212,6 +218,7 @@ def setting(label, control, readout=None):# (page, column, heading key, items)GROUP_LAYOUT = [("PageDisplay", 0, "GUI:OptionsGroupScreen", [+ setting("LabelMonitor", "ComboBoxMonitor"),setting("ResolutionLabel", "ComboBoxResolution"),setting("LabelWindowMode", "ComboBoxWindowMode"),("check", "CheckVSync")]),@@ -646,9 +653,13 @@ def selfcheck():if key not in keys:problems.append("caption %s is not in Patch.str" % key)- for name in READOUTS + GRAPHICS_CHECKS + MENU_CHECKS:+ for name in READOUTS + GRAPHICS_CHECKS + MENU_CHECKS + MENU_COMBOS:if name not in controls:problems.append("OptionsMenu.wnd has no %s, which OptionsMenu.cpp fills in" % name)+ for name in MENU_COMBOS:+ for key in ("GUI:%s" % setting_of(name), "TOOLTIP:%s" % setting_of(name)):+ if key not in keys:+ problems.append("%s needs %s in Patch.str" % (name, key))if ADVANCED in controls:problems.append("OptionsMenu.wnd still carries %s; its controls are on the Graphics page"% ADVANCED)