Skip to content

Commit

Permalink
Add exclusive fullscreen toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
Popax21 committed Nov 16, 2023
1 parent 0b53498 commit 2f66748
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Celeste.Mod.mm/Content/Dialog/English.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@
MODOPTIONS_COREMODULE_COMPATMODE_LEGACYFNA_DESCR_A= Reintroduces old FNA's additional input latency
MODOPTIONS_COREMODULE_COMPATMODE_LEGACYFNA_DESCR_B= ONLY RECOMMENDED IF YOU HAVE OLD MUSCLE MEMORY!
MODOPTIONS_COREMODULE_COMPATMODE_INCOMPATIBLE= Warning: Incompatible with your vanilla install's framework!
MODOPTIONS_COREMODULE_D3D11EXCLUSIVEFULLSCREEN= Use Exclusive Fullscreen
MODOPTIONS_COREMODULE_D3D11EXCLUSIVEFULLSCREEN_DESC= Affects the D3D11 renderer on Windows
MODOPTIONS_COREMODULE_AUTOUPDATEMODSONSTARTUP= Auto Update Mods on Startup
MODOPTIONS_COREMODULE_MODUPDATES= Check for Mod Updates
MODOPTIONS_COREMODULE_USEKEYBOARDFORTEXTINPUT= Use Keyboard for Text Input
Expand Down
2 changes: 2 additions & 0 deletions Celeste.Mod.mm/Content/Dialog/German.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@
MODOPTIONS_COREMODULE_COMPATMODE_LEGACYFNA_DESCR_A= Emuliert die Input-Latenz von alten FNA-Installationen
MODOPTIONS_COREMODULE_COMPATMODE_LEGACYFNA_DESCR_B= NUR EMPFOHLEN, WENN MAN AN DIESE GEWÖHNT IST
MODOPTIONS_COREMODULE_COMPATMODE_INCOMPATIBLE= Warnung: Inkompatibel mit dem Vanilla-Framework!
MODOPTIONS_COREMODULE_D3D11EXCLUSIVEFULLSCREEN= Verwende Exclusive Fullscreen
MODOPTIONS_COREMODULE_D3D11EXCLUSIVEFULLSCREEN_DESC= Betrifft den Windows D3D11-Renderer
MODOPTIONS_COREMODULE_AUTOUPDATEMODSONSTARTUP= Mods beim Start automatisch updaten
MODOPTIONS_COREMODULE_MODUPDATES= Auf Mod-Updates prüfen
MODOPTIONS_COREMODULE_USEKEYBOARDFORTEXTINPUT= Tastatur für Texteingabe benutzen
Expand Down
6 changes: 6 additions & 0 deletions Celeste.Mod.mm/Mod/Core/CoreModuleSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ public string MainMenuMode {

public Everest.CompatMode CompatibilityMode { get; set; } = Everest.CompatMode.None; // TODO Better default logic

[SettingNeedsRelaunch]
[SettingName("MODOPTIONS_COREMODULE_D3D11EXCLUSIVEFULLSCREEN")]
[SettingSubText("MODOPTIONS_COREMODULE_D3D11EXCLUSIVEFULLSCREEN_DESC")]
[SettingInGame(false)]
public bool D3D11UseExclusiveFullscreen { get; set; }

[SettingInGame(false)]
public bool UseKeyboardForTextInput { get; set; } = true;

Expand Down
12 changes: 10 additions & 2 deletions Celeste.Mod.mm/Mod/Everest/BOOT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,35 @@ private static void Main(string[] args) {

// Load the compatibility mode setting
Everest.CompatibilityMode = Everest.CompatMode.None;
bool useExclusiveFullscreen = false;
try {
string path = patch_UserIO.GetSaveFilePath("modsettings-Everest");
if (File.Exists(path)) {
using Stream stream = File.OpenRead(path);
using StreamReader reader = new StreamReader(stream);
Dictionary<object, object> settings = new Deserializer().Deserialize<Dictionary<object, object>>(reader);

if (settings.TryGetValue(nameof(CoreModuleSettings.CompatibilityMode), out object val)) {
Everest.CompatibilityMode = Enum.Parse<Everest.CompatMode>((string) val);
Console.WriteLine($"Loaded compatibility mode setting: {Everest.CompatibilityMode}");
}
if (settings.TryGetValue(nameof(CoreModuleSettings.D3D11UseExclusiveFullscreen), out val))
useExclusiveFullscreen = bool.Parse((string) val);
}
} catch (Exception ex) {
LogError("COMPAT-MODE-LOAD", ex);
goto Exit;
}

// Handle the legacy FNA compatibility mode here, so that vanilla is also affected
// Handle the compatibility modes here, so that vanilla is also affected
if (Everest.CompatibilityMode == Everest.CompatMode.LegacyFNA) {
Environment.SetEnvironmentVariable("FNA3D_D3D11_FORCE_BITBLT", "1");
Environment.SetEnvironmentVariable("FNA3D_D3D11_NO_EXCLUSIVE_FULLSCREEN", "1");
}
} else if(!useExclusiveFullscreen)
Environment.SetEnvironmentVariable("FNA3D_D3D11_NO_EXCLUSIVE_FULLSCREEN", "1");

if (useExclusiveFullscreen)
Console.WriteLine("Enabling D3D11 exclusive fullscreen support");

// Start vanilla if instructed to
string vanillaDummy = Path.Combine(Path.GetDirectoryName(everestPath), "nextLaunchIsVanilla.txt");
Expand Down

0 comments on commit 2f66748

Please sign in to comment.