Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Core/GameEngine/Include/Common/OptionPreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ class OptionPreferences : public UserPreferences
Real getGammaValue();
Int getTextureReduction();
void getResolution(Int *xres, Int *yres);
Bool getWindowed() const;
void setWindowed(Bool windowed);
Bool get3DShadowsEnabled();
Bool get2DShadowsEnabled();
Bool getCloudShadowsEnabled();
Expand Down
7 changes: 4 additions & 3 deletions Core/GameEngine/Include/GameClient/ControlBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,10 @@ class ControlBar : public SubsystemInterface
void showPurchaseScience();
void hidePurchaseScience();
void togglePurchaseScience();
Bool isPurchaseScienceVisible() const;

/// show rally point at world location, a nullptr location will hide any visible rally point marker
void showRallyPoint( const Coord3D *loc );

Bool hasAnyShortcutSelection() const;
Bool canShowSpecialPowerShortcut() const;
Expand Down Expand Up @@ -825,9 +829,6 @@ class ControlBar : public SubsystemInterface
/// show/hide the portrait window image using the image from the object
void setPortraitByObject( Object *obj );

/// show rally point at world location, a nullptr location will hide any visible rally point marker
void showRallyPoint( const Coord3D *loc );

/// post process step, after all commands and command sets are loaded
void postProcessCommands();

Expand Down
17 changes: 17 additions & 0 deletions Core/GameEngine/Source/Common/OptionPreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,23 @@ void OptionPreferences::getResolution(Int *xres, Int *yres)
*yres=selectedYRes;
}

Bool OptionPreferences::getWindowed() const
{
OptionPreferences::const_iterator it = find("Windowed");
if (it == end())
return FALSE;

if (stricmp(it->second.str(), "yes") == 0) {
return TRUE;
}
return FALSE;
}

void OptionPreferences::setWindowed(Bool windowed)
{
setBool("Windowed", windowed);
}

Real OptionPreferences::getMusicVolume()
{
OptionPreferences::const_iterator it = find("MusicVolume");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3016,6 +3016,11 @@ void ControlBar::togglePurchaseScience()
hidePurchaseScience();
}

Bool ControlBar::isPurchaseScienceVisible() const
{
return m_contextParent[ CP_PURCHASE_SCIENCE ] && !m_contextParent[ CP_PURCHASE_SCIENCE ]->winIsHidden();
}

void ControlBar::toggleControlBarStage()
{
if(m_currentControlBarStage == CONTROL_BAR_STAGE_DEFAULT )
Expand Down
18 changes: 5 additions & 13 deletions Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1244,20 +1244,12 @@ const char * DX8Wrapper::Get_Render_Device_Name(int device_index)
bool DX8Wrapper::Set_Device_Resolution(int width,int height,int bits,int windowed, bool resize_window)
{
if (D3DDevice != nullptr) {
int w = (width == -1) ? ResolutionWidth : width;
int h = (height == -1) ? ResolutionHeight : height;
int b = (bits == -1) ? BitDepth : bits;
int win = (windowed == -1) ? IsWindowed : windowed;

if (width != -1) {
_PresentParameters.BackBufferWidth = ResolutionWidth = width;
}
if (height != -1) {
_PresentParameters.BackBufferHeight = ResolutionHeight = height;
}
if (resize_window)
{
Resize_And_Position_Window();
}
#pragma message("TODO: support changing windowed status and changing the bit depth")
WWDEBUG_SAY(("DX8Wrapper::Set_Device_Resolution is resetting the device."));
return Reset_Device();
return Set_Render_Device(CurRenderDevice, w, h, b, win, resize_window, true, true);
} else {
return false;
}
Expand Down
4 changes: 3 additions & 1 deletion GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,20 @@ constexpr const Int MAX_GLOBAL_LIGHTS = 3;
constexpr const Int SIMULATE_REPLAYS_SEQUENTIAL = -1;

//-------------------------------------------------------------------------------------------------
class CommandLineData
struct CommandLineData
{
friend class CommandLine;
friend class GlobalData;

CommandLineData()
: m_hasParsedCommandLineForStartup(false)
, m_hasParsedCommandLineForEngineInit(false)
, m_windowedCommandLineSpecified(false)
{}

Bool m_hasParsedCommandLineForStartup;
Bool m_hasParsedCommandLineForEngineInit;
Bool m_windowedCommandLineSpecified;
};

//-------------------------------------------------------------------------------------------------
Expand Down
13 changes: 13 additions & 0 deletions GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ class WindowLayoutInfo
std::list<GameWindow *> windows; ///< list of top-level windows in the layout
};

struct WindowLayoutRules
{
Int unscaledScreenX;
Int unscaledScreenY;
Int unscaledScreenWidth;
Int unscaledScreenHeight;
Int createResX;
Int createResY;
};

extern std::map<GameWindow*, WindowLayoutRules> g_windowLayoutRegistry;


//-------------------------------------------------------------------------------------------------
/** There exists a singleton GameWindowManager that defines how we can
* interact with the game windowing system */
Expand Down
6 changes: 6 additions & 0 deletions GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "Common/CommandLine.h"
#include "Common/CRCDebug.h"
#include "Common/LocalFileSystem.h"
#include "Common/OptionPreferences.h"
#include "Common/Recorder.h"
#include "Common/version.h"
#include "GameClient/ClientInstance.h"
Expand Down Expand Up @@ -118,6 +119,7 @@ Int parseNoLogOrCrash(char *args[], int)
Int parseWin(char *args[], int)
{
TheWritableGlobalData->m_windowed = true;
TheWritableGlobalData->m_commandLineData.m_windowedCommandLineSpecified = true;

return 1;
}
Expand Down Expand Up @@ -377,6 +379,7 @@ Int parseNoAudio(char *args[], int)
Int parseNoWin(char *args[], int)
{
TheWritableGlobalData->m_windowed = false;
TheWritableGlobalData->m_commandLineData.m_windowedCommandLineSpecified = true;

return 1;
}
Expand Down Expand Up @@ -1435,6 +1438,9 @@ void CommandLine::parseCommandLineForStartup()
return;
TheWritableGlobalData->m_commandLineData.m_hasParsedCommandLineForStartup = true;

OptionPreferences optionPref;
TheWritableGlobalData->m_windowed = optionPref.getWindowed();

parseCommandLine(paramsForStartup, ARRAY_SIZE(paramsForStartup));
}

Expand Down
11 changes: 11 additions & 0 deletions GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,8 @@ void GlobalData::reset()
//-------------------------------------------------------------------------------------------------
void GlobalData::parseGameDataDefinition( INI* ini )
{
Bool cmdWindowed = TheGlobalData->m_windowed;

if( TheWritableGlobalData && ini->getLoadType() != INI_LOAD_MULTIFILE)
{

Expand Down Expand Up @@ -1227,6 +1229,15 @@ void GlobalData::parseGameDataDefinition( INI* ini )
TheWritableGlobalData->m_showMoneyPerMinute = optionPref.getShowMoneyPerMinute();
TheWritableGlobalData->m_gameWindowTransitionSpeedMultiplier = optionPref.getGameWindowTransitionSpeedMultiplier();

if (TheGlobalData->m_commandLineData.m_windowedCommandLineSpecified)
{
TheWritableGlobalData->m_windowed = cmdWindowed;
}
else
{
TheWritableGlobalData->m_windowed = optionPref.getWindowed();
}

TheWritableGlobalData->m_antiAliasLevel = optionPref.getAntiAliasing();
TheWritableGlobalData->m_textureFilteringMode = optionPref.getTextureFilterMode();
TheWritableGlobalData->m_textureAnisotropyLevel = optionPref.getTextureAnisotropyLevel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1407,9 +1407,6 @@ void OptionsMenuInit( WindowLayout *layout, void *userData )
if (comboBoxDetail)
comboBoxDetail->winEnable(FALSE);

if (comboBoxResolution)
comboBoxResolution->winEnable(FALSE);

if (textEntryFirewallPortOverride)
textEntryFirewallPortOverride->winEnable(FALSE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,8 @@ Int GameWindowManager::winDestroy( GameWindow *window )
if( window == nullptr )
return WIN_ERR_INVALID_WINDOW;

g_windowLayoutRegistry.erase(window);

//
// we should never have edit data allocated in the window code, it's
// completely handled by the editor ONLY
Expand Down Expand Up @@ -4063,5 +4065,56 @@ GameWindowDummy::~GameWindowDummy()
{
}

void reflowWindowTree(GameWindow *win, Int newScreenWidth, Int newScreenHeight)
{
while (win)
{
std::map<GameWindow*, WindowLayoutRules>::iterator it = g_windowLayoutRegistry.find(win);
if (it != g_windowLayoutRegistry.end())
{
const WindowLayoutRules &rules = it->second;

Real scaleX = (rules.createResX > 0) ? ((Real)newScreenWidth / (Real)rules.createResX) : 1.0f;
Real scaleY = (rules.createResY > 0) ? ((Real)newScreenHeight / (Real)rules.createResY) : 1.0f;

Int newScreenX = (Int)(rules.unscaledScreenX * scaleX);
Int newScreenY = (Int)(rules.unscaledScreenY * scaleY);
Int newWidth = (Int)(rules.unscaledScreenWidth * scaleX);
Int newHeight = (Int)(rules.unscaledScreenHeight * scaleY);

Int newRelX = newScreenX;
Int newRelY = newScreenY;

GameWindow *parent = win->winGetParent();
if (parent)
{
Int parentScreenX = 0, parentScreenY = 0;
parent->winGetScreenPosition(&parentScreenX, &parentScreenY);
newRelX = newScreenX - parentScreenX;
newRelY = newScreenY - parentScreenY;
}

win->winSetPosition(newRelX, newRelY);
win->winSetSize(newWidth, newHeight);
}

if (win->winGetChild())
{
reflowWindowTree(win->winGetChild(), newScreenWidth, newScreenHeight);
}

win = win->winGetNext();
}
}

void reflowAllWindows(Int newScreenWidth, Int newScreenHeight)
{
if (TheWindowManager)
{
GameWindow *head = TheWindowManager->winGetWindowList();
reflowWindowTree(head, newScreenWidth, newScreenHeight);
}
}



Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,22 @@
#include "GameClient/GadgetSlider.h"
#include "GameClient/GameText.h"
#include "GameClient/HeaderTemplate.h"
#include <map>

std::map<GameWindow*, WindowLayoutRules> g_windowLayoutRegistry;

struct TempParsedRect
{
Int x;
Int y;
Int w;
Int h;
Int resX;
Int resY;
Bool valid;
};

static TempParsedRect g_tempParsedRect = { 0, 0, 0, 0, 0, 0, FALSE };

// DEFINES ////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -520,6 +534,13 @@ static Bool parseScreenRect( const char *token, char *buffer,
scanInt( c, createRes.x );
c = strtok( nullptr, seps ); // y creation resolution
scanInt( c, createRes.y );
g_tempParsedRect.x = screenRegion.lo.x;
g_tempParsedRect.y = screenRegion.lo.y;
g_tempParsedRect.w = screenRegion.hi.x - screenRegion.lo.x;
g_tempParsedRect.h = screenRegion.hi.y - screenRegion.lo.y;
g_tempParsedRect.resX = createRes.x;
g_tempParsedRect.resY = createRes.y;
g_tempParsedRect.valid = TRUE;

//
// shrink or expand the screen region by the ratio of the current
Expand Down Expand Up @@ -2129,6 +2150,19 @@ static GameWindow *createWindow( char *type,
if( window && parent )
TheWindowManager->winSendInputMsg( parent, GWM_SCRIPT_CREATE, id, 0 );

if (window && g_tempParsedRect.valid)
{
WindowLayoutRules rules;
rules.unscaledScreenX = g_tempParsedRect.x;
rules.unscaledScreenY = g_tempParsedRect.y;
rules.unscaledScreenWidth = g_tempParsedRect.w;
rules.unscaledScreenHeight = g_tempParsedRect.h;
rules.createResX = g_tempParsedRect.resX;
rules.createResY = g_tempParsedRect.resY;
g_windowLayoutRegistry[window] = rules;
g_tempParsedRect.valid = FALSE;
}

return window;

}
Expand Down
45 changes: 43 additions & 2 deletions GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6001,8 +6001,25 @@ void InGameUI::resetIdleWorker()

void InGameUI::recreateControlBar()
{
GameWindow *win = TheWindowManager->winGetWindowFromId(nullptr, TheNameKeyGenerator->nameToKey("ControlBar.wnd"));
deleteInstance(win);
GameWindow *win = TheWindowManager->winGetWindowFromId(nullptr, TheNameKeyGenerator->nameToKey("ControlBar.wnd:ControlBarParent"));
if (!win)
{
return;
}

Bool wasHidden = win->winIsHidden();
Bool wasScienceVisible = FALSE;

if (TheControlBar)
{
if (TheControlBar->isPurchaseScienceVisible())
{
wasScienceVisible = TRUE;
}
TheControlBar->showRallyPoint(nullptr);
}

TheWindowManager->winDestroy(win);

m_idleWorkerWin = nullptr;

Expand All @@ -6011,6 +6028,30 @@ void InGameUI::recreateControlBar()
delete TheControlBar;
TheControlBar = NEW ControlBar;
TheControlBar->init();

if (ThePlayerList)
{
Player *localPlayer = ThePlayerList->getLocalPlayer();
if (localPlayer)
{
TheControlBar->setControlBarSchemeByPlayer(localPlayer);
TheControlBar->initSpecialPowershortcutBar(localPlayer);
}
}

if (wasHidden)
{
HideControlBar(TRUE);
}
else
{
ShowControlBar(TRUE);
}

if (wasScienceVisible && TheControlBar)
{
TheControlBar->showPurchaseScience();
}
}

void InGameUI::refreshCustomUiResources()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ void Win32GameEngine::update()
// allow windows to perform regular windows maintenance stuff like msgs
serviceWindowsOS();

extern void checkAndApplyDeferredResize();
checkAndApplyDeferredResize();

}

//-------------------------------------------------------------------------------------------------
Expand Down
Loading
Loading