forked from Mirrors/openclonk
Add config option for automatic windowed/fullscreen switching
parent
e6d89b078d
commit
023aa90c0e
|
@ -747,6 +747,7 @@ IDS_MSG_ALLOWSYOUTOJOINADIFFERENT=Erlaubt die Auswahl eines anderen Teams.
|
|||
IDS_MSG_ALLPLAYERDATA=Sollen die aktuellen Werte für alle Spieler übernommen werden?
|
||||
IDS_MSG_ANTIALIASING_DESC=FSAA (MultiSampling)-Level einstellen
|
||||
IDS_MSG_ANUPDATETOVERSIONISAVAILA=Ein neues Update ist verfügbar. Soll das Update heruntergeladen und installiert werden?
|
||||
IDS_MSG_AUTOWINDOWED=Automagisch
|
||||
IDS_MSG_BACKTOPLAYERDLG=Zurück zur Spielerauswahl.
|
||||
IDS_MSG_BLITOFFSET=Blit offset
|
||||
IDS_MSG_BLITOFFSET_DESC=Gibt das für jede Zeichenoperation benutze Offset zwecks hochgenauer Pixeloperationen an. Wert erhöhen, wenn schwarze Linien unter/rechts von Grafiken auftauchen. Verringern, wenn Linien über/links von Grafiken auftauchen.
|
||||
|
@ -936,6 +937,7 @@ IDS_MSG_NEWRELEASEAVAILABLE=Für die neue Version ist kein Update-Paket verfügb
|
|||
IDS_MSG_USINGPLR=Mit %s spielen
|
||||
IDS_MSG_USINGPLR_DESC=Diesen Spieler benutzen um das Spiel fortzusetzen
|
||||
IDS_MSG_WASKICKEDFROMTHECHANNEL=%s wurde aus dem Chat-Kanal geworfen (%s).
|
||||
IDS_MSG_WINDOWED=Fenstermodus
|
||||
IDS_MSG_YOUAREABOUTTOCONNECTTOAPU=Hiermit wird die Verbindung zu einem öffentlichen Chat-Server (%s) erstellt. Fortfahren?
|
||||
IDS_MSG_YOUHAVEJOINEDCHANNEL=Du bist Chat-Kanal %s beigetreten.
|
||||
IDS_MSG_YOUHAVELEFTCHANNEL=Du hast Chat-Kanal %s verlassen (%s).
|
||||
|
|
|
@ -746,6 +746,7 @@ IDS_MSG_ALLOWSYOUTOJOINADIFFERENT=Allows you to join a different team.
|
|||
IDS_MSG_ALLPLAYERDATA=Use current values for all players?
|
||||
IDS_MSG_ANTIALIASING_DESC=Set FSAA (MultiSampling) level
|
||||
IDS_MSG_ANUPDATETOVERSIONISAVAILA=A new update is available. Do you want to download and install this update?
|
||||
IDS_MSG_AUTOWINDOWED=Automatic
|
||||
IDS_MSG_BACKTOPLAYERDLG=Back to player selection.
|
||||
IDS_MSG_BLITOFFSET=Blit offset
|
||||
IDS_MSG_BLITOFFSET_DESC=Determines the offset used for every drawing operation to ensure exact pixels are drawn. Increase this value if you see black borders below/to the right of some graphics. Deacrease it if you see borders above/to the left of some graphics.
|
||||
|
@ -935,6 +936,7 @@ IDS_MSG_NEWRELEASEAVAILABLE=For the new version there is no update package avail
|
|||
IDS_MSG_USINGPLR=Using %s
|
||||
IDS_MSG_USINGPLR_DESC=Use this player to continue the savegame
|
||||
IDS_MSG_WASKICKEDFROMTHECHANNEL=%s was kicked from the channel (%s).
|
||||
IDS_MSG_WINDOWED=Window mode
|
||||
IDS_MSG_YOUAREABOUTTOCONNECTTOAPU=You are about to connect to a public chat server (%s). Proceed?
|
||||
IDS_MSG_YOUHAVEJOINEDCHANNEL=You have joined channel %s.
|
||||
IDS_MSG_YOUHAVELEFTCHANNEL=You have left channel %s (%s).
|
||||
|
|
|
@ -38,6 +38,7 @@ class C4ClientList;
|
|||
class C4ClientPlayerInfos;
|
||||
class C4Command;
|
||||
class C4Config;
|
||||
class C4ConfigGraphics;
|
||||
class C4Console;
|
||||
class C4Control;
|
||||
class C4Def;
|
||||
|
|
|
@ -101,7 +101,7 @@ public:
|
|||
int32_t ResX,ResY;
|
||||
int32_t WindowX,WindowY;
|
||||
int32_t RefreshRate; // monitor vertical refresh rate
|
||||
int32_t Windowed;
|
||||
int32_t Windowed; // 0: fullscreen, 1: windowed, 2: fullscreen in game, windowed in menu
|
||||
int32_t ShowAllResolutions;
|
||||
int32_t ShowCrewNames; // show player name above clonks?
|
||||
int32_t ShowCrewCNames; // show clonk names above clonks?
|
||||
|
@ -121,8 +121,6 @@ public:
|
|||
int32_t MultiSampling; // multisampling samples
|
||||
|
||||
void CompileFunc(StdCompiler *pComp);
|
||||
int GetWidth() { return Windowed ? WindowX : ResX; }
|
||||
int GetHeight() { return Windowed ? WindowY : ResY; }
|
||||
};
|
||||
|
||||
class C4ConfigSound
|
||||
|
|
|
@ -175,13 +175,13 @@ bool C4Application::DoInit(int argc, char * argv[])
|
|||
LogF("Version: %s %s (%s)", C4VERSION, C4_OS, Revision.getData());
|
||||
|
||||
// Initialize D3D/OpenGL
|
||||
bool success = DDrawInit(this, isEditor, false, Config.Graphics.GetWidth(), Config.Graphics.GetHeight(), Config.Graphics.BitDepth, Config.Graphics.Engine, Config.Graphics.Monitor);
|
||||
bool success = DDrawInit(this, isEditor, false, GetConfigWidth(), GetConfigHeight(), Config.Graphics.BitDepth, Config.Graphics.Engine, Config.Graphics.Monitor);
|
||||
if (!success) { LogFatal(LoadResStr("IDS_ERR_DDRAW")); Clear(); ShowGfxErrorDialog(); return false; }
|
||||
|
||||
if (!isEditor)
|
||||
{
|
||||
if (!SetVideoMode(Config.Graphics.GetWidth(), Config.Graphics.GetHeight(), Config.Graphics.BitDepth, Config.Graphics.RefreshRate, Config.Graphics.Monitor, !Config.Graphics.Windowed))
|
||||
pWindow->SetSize(Config.Graphics.GetWidth(), Config.Graphics.GetHeight());
|
||||
if (!SetVideoMode(Application.GetConfigWidth(), Application.GetConfigHeight(), Config.Graphics.BitDepth, Config.Graphics.RefreshRate, Config.Graphics.Monitor, !Config.Graphics.Windowed))
|
||||
pWindow->SetSize(Application.GetConfigWidth(), Application.GetConfigHeight());
|
||||
}
|
||||
|
||||
// Initialize gamepad
|
||||
|
@ -639,10 +639,14 @@ void C4Application::GameTick()
|
|||
QuitGame();
|
||||
break;
|
||||
}
|
||||
if(Config.Graphics.Windowed == 2)
|
||||
Application.SetVideoMode(GetConfigWidth(), GetConfigHeight(), Config.Graphics.BitDepth, Config.Graphics.RefreshRate, Config.Graphics.Monitor, true);
|
||||
break;
|
||||
case C4AS_AfterGame:
|
||||
// stop game
|
||||
Game.Clear();
|
||||
if(Config.Graphics.Windowed == 2 && !NextMission)
|
||||
Application.SetVideoMode(GetConfigWidth(), GetConfigHeight(), Config.Graphics.BitDepth, Config.Graphics.RefreshRate, Config.Graphics.Monitor, false);
|
||||
AppState = C4AS_PreInit;
|
||||
// if a next mission is desired, set to start it
|
||||
if (NextMission)
|
||||
|
|
|
@ -79,7 +79,10 @@ public:
|
|||
// set by ParseCommandLine, for manually applying downloaded update packs
|
||||
StdStrBuf IncomingUpdate;
|
||||
// set by ParseCommandLine, for manually invoking an update check by command line or url
|
||||
int CheckForUpdates;
|
||||
int CheckForUpdates;
|
||||
|
||||
int GetConfigWidth() { return (Config.Graphics.Windowed == 2 && AppState == C4AS_Game) || Config.Graphics.Windowed ? Config.Graphics.WindowX : Config.Graphics.ResX; }
|
||||
int GetConfigHeight() { return (Config.Graphics.Windowed == 2 && AppState == C4AS_Game) || Config.Graphics.Windowed ? Config.Graphics.WindowY : Config.Graphics.ResY; }
|
||||
protected:
|
||||
enum State { C4AS_None, C4AS_PreInit, C4AS_Startup, C4AS_StartGame, C4AS_Game, C4AS_AfterGame, C4AS_Quit } AppState;
|
||||
C4ApplicationGameTimer *pGameTimer;
|
||||
|
|
|
@ -58,7 +58,7 @@ C4FullScreen::~C4FullScreen()
|
|||
|
||||
C4Window * C4FullScreen::Init(C4AbstractApp * pApp)
|
||||
{
|
||||
C4Rect r(0, 0, Config.Graphics.GetWidth(), Config.Graphics.GetHeight());
|
||||
C4Rect r(0, 0, Application.GetConfigWidth(), Application.GetConfigHeight());
|
||||
return Init(C4Window::W_Fullscreen, pApp, C4ENGINECAPTION, &r);
|
||||
}
|
||||
|
||||
|
|
|
@ -329,7 +329,7 @@ bool C4Game::PreInit()
|
|||
{ LogFatal(LoadResStr("IDS_ERR_NOGFXSYS")); return false; }
|
||||
|
||||
// load GUI
|
||||
pGUI->Init(0, 0, Config.Graphics.GetWidth(), Config.Graphics.GetHeight());
|
||||
pGUI->Init(0, 0, Application.GetConfigWidth(), Application.GetConfigHeight());
|
||||
|
||||
fPreinited = true;
|
||||
|
||||
|
@ -618,7 +618,7 @@ void C4Game::Clear()
|
|||
PlayerControlDefaultAssignmentSets.Clear();
|
||||
PlayerControlDefs.Clear();
|
||||
::MeshMaterialManager.Clear();
|
||||
Application.SoundSystem.Init(); // clear it up and re-init it for normal use
|
||||
Application.SoundSystem.Init(); // clear it up and re-init it for startup menu use
|
||||
|
||||
// global fullscreen class is not cleared, because it holds the carrier window
|
||||
// but the menu must be cleared (maybe move Fullscreen.Menu somewhere else?)
|
||||
|
@ -644,6 +644,7 @@ void C4Game::Clear()
|
|||
|
||||
fPreinited = false;
|
||||
C4PropListNumbered::ResetEnumerationIndex();
|
||||
|
||||
// FIXME: remove this
|
||||
Default();
|
||||
}
|
||||
|
|
|
@ -540,8 +540,8 @@ namespace C4GUI
|
|||
Mouse.x = tx+twdt/2;
|
||||
Mouse.y = ty+thgt/2;
|
||||
// calculate zoom
|
||||
float fZoomX = float(Config.Graphics.GetWidth()) / twdt;
|
||||
float fZoomY = float(Config.Graphics.GetHeight()) / thgt;
|
||||
float fZoomX = float(Application.GetConfigWidth()) / twdt;
|
||||
float fZoomY = float(Application.GetConfigHeight()) / thgt;
|
||||
fZoom = Min<float>(fZoomX, fZoomY);
|
||||
// set size - calcs client area as well
|
||||
SetBounds(C4Rect(tx,ty,twdt,thgt));
|
||||
|
|
|
@ -894,12 +894,21 @@ C4StartupOptionsDlg::C4StartupOptionsDlg() : C4StartupDlg(LoadResStrNoAmp("IDS_D
|
|||
pCheckGfxClrDepth[iBitDepthIdx]->SetToolTip(LoadResStr("IDS_CTL_BITDEPTH"));
|
||||
pGroupResolution->AddElement(pCheckGfxClrDepth[iBitDepthIdx]);
|
||||
}
|
||||
// fullscreen checkbox
|
||||
pCheck = new C4GUI::CheckBox(caGroupResolution.GetGridCell(0,1,3,4,-1,iCheckHgt,true), LoadResStr("IDS_MSG_FULLSCREEN"), !Config.Graphics.Windowed);
|
||||
pCheck->SetOnChecked(new C4GUI::CallbackHandler<C4StartupOptionsDlg>(this, &C4StartupOptionsDlg::OnFullscreenChange));
|
||||
pCheck->SetToolTip(LoadResStr("IDS_MSG_FULLSCREEN_DESC"));
|
||||
pCheck->SetFont(pUseFont, C4StartupFontClr, C4StartupFontClrDisabled);
|
||||
pGroupResolution->AddElement(pCheck);
|
||||
// fullscreen combobox
|
||||
uint32_t wmax = 0;
|
||||
for(int i = 0; i < 3; ++i)
|
||||
{
|
||||
pUseFont->GetTextExtent(GetWindowedName(i),w,q,true);
|
||||
wmax = Max<int32_t>(w, wmax);
|
||||
}
|
||||
C4GUI::ComboBox * pCombo = new C4GUI::ComboBox(caGroupResolution.GetGridCell(0,1,3,4,wmax+40,C4GUI::ComboBox::GetDefaultHeight(), true));
|
||||
pCombo->SetComboCB(new C4GUI::ComboBox_FillCallback<C4StartupOptionsDlg>(this, &C4StartupOptionsDlg::OnWindowedModeComboFill, &C4StartupOptionsDlg::OnWindowedModeComboSelChange));
|
||||
pCombo->SetToolTip(LoadResStr("IDS_MSG_FULLSCREEN_DESC"));
|
||||
pCombo->SetColors(C4StartupFontClr, C4StartupEditBGColor, C4StartupEditBorderColor);
|
||||
pCombo->SetFont(pUseFont);
|
||||
pCombo->SetDecoration(&(C4Startup::Get()->Graphics.fctContext));
|
||||
pCombo->SetText(GetWindowedName());
|
||||
pGroupResolution->AddElement(pCombo);
|
||||
// --subgroup troubleshooting
|
||||
pGroupTrouble = new C4GUI::GroupBox(caSheetGraphics.GetGridCell(0,1,1,3));
|
||||
pGroupTrouble->SetTitle(LoadResStrNoAmp("IDS_CTL_TROUBLE"));
|
||||
|
@ -1323,10 +1332,27 @@ void C4StartupOptionsDlg::OnGfxClrDepthCheck(C4GUI::Element *pCheckBox)
|
|||
GetScreen()->ShowMessage(LoadResStr("IDS_MSG_RESTARTCHANGECFG"), sTitle.getData(), C4GUI::Ico_Notify, &Config.Startup.HideMsgGfxBitDepthChange);
|
||||
}
|
||||
|
||||
void C4StartupOptionsDlg::OnFullscreenChange(C4GUI::Element *pCheckBox)
|
||||
const char * C4StartupOptionsDlg::GetWindowedName(int32_t mode /* = -1*/)
|
||||
{
|
||||
Config.Graphics.Windowed = !static_cast<C4GUI::CheckBox *>(pCheckBox)->GetChecked();
|
||||
if(mode == -1)
|
||||
mode = Config.Graphics.Windowed;
|
||||
if(mode == 0) return LoadResStr("IDS_MSG_FULLSCREEN");
|
||||
else if(mode == 1) return LoadResStr("IDS_MSG_WINDOWED");
|
||||
else if(mode == 2) return LoadResStr("IDS_MSG_AUTOWINDOWED");
|
||||
}
|
||||
|
||||
void C4StartupOptionsDlg::OnWindowedModeComboFill(C4GUI::ComboBox_FillCB *pFiller)
|
||||
{
|
||||
pFiller->ClearEntries();
|
||||
for(int32_t i = 0; i < 3; ++i)
|
||||
pFiller->AddEntry(GetWindowedName(i), i);
|
||||
}
|
||||
|
||||
bool C4StartupOptionsDlg::OnWindowedModeComboSelChange(C4GUI::ComboBox *pForCombo, int32_t idNewSelection)
|
||||
{
|
||||
Config.Graphics.Windowed = idNewSelection;
|
||||
Application.SetVideoMode(Config.Graphics.ResX, Config.Graphics.ResY, Config.Graphics.BitDepth, Config.Graphics.RefreshRate, Config.Graphics.Monitor, !Config.Graphics.Windowed);
|
||||
pForCombo->SetText(GetWindowedName(idNewSelection));
|
||||
}
|
||||
|
||||
void C4StartupOptionsDlg::OnGfxAllResolutionsChange(C4GUI::Element *pCheckBox)
|
||||
|
|
|
@ -125,7 +125,8 @@ private:
|
|||
virtual const char *GetID() { return "ResChangeConfirmDialog"; }
|
||||
};
|
||||
|
||||
void OnFullscreenChange(C4GUI::Element *pCheckBox);
|
||||
void OnWindowedModeComboFill(C4GUI::ComboBox_FillCB *pFiller);
|
||||
bool OnWindowedModeComboSelChange(C4GUI::ComboBox *pForCombo, int32_t idNewSelection);
|
||||
void OnGfxAllResolutionsChange(C4GUI::Element *pCheckBox);
|
||||
void OnGfxEngineCheck(C4GUI::Element *pCheckBox);
|
||||
void OnGfxTroubleCheck(C4GUI::Element *pCheckBox)
|
||||
|
@ -137,6 +138,7 @@ private:
|
|||
bool TryNewResolution(int32_t iResX, int32_t iResY);
|
||||
void OnGfxClrDepthCheck(C4GUI::Element *pCheckBox);
|
||||
StdStrBuf GetGfxResString(int32_t iResX, int32_t iResY); // convert resolution to string to be displayed in resolution choice combobox
|
||||
const char * GetWindowedName(int32_t mode = -1);
|
||||
void OnEffectsSliderChange(int32_t iNewVal);
|
||||
|
||||
C4GUI::CheckBox *pCheckGfxEngines[3], *pCheckGfxClrDepth[2];
|
||||
|
|
|
@ -457,7 +457,7 @@ static bool fullscreen_needs_restore = false;
|
|||
static gboolean fullscreen_restore(gpointer data)
|
||||
{
|
||||
if (fullscreen_needs_restore)
|
||||
Application.SetVideoMode(Config.Graphics.GetWidth(), Config.Graphics.GetHeight(), Config.Graphics.BitDepth, Config.Graphics.RefreshRate, Config.Graphics.Monitor, !Config.Graphics.Windowed);
|
||||
Application.SetVideoMode(Application.GetConfigWidth(), Application.GetConfigHeight(), Config.Graphics.BitDepth, Config.Graphics.RefreshRate, Config.Graphics.Monitor, !Config.Graphics.Windowed);
|
||||
fullscreen_needs_restore = false;
|
||||
return FALSE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue