Skip to content

Commit

Permalink
0.6.0.30 - Set default Graphics Device type on first boot & only show…
Browse files Browse the repository at this point in the history
… supported Graphics Devices per OS (#770)

- Set default Graphics Device type on first boot & only show supported Graphics Devices per OS
  • Loading branch information
DragonRatTiger authored Dec 22, 2024
1 parent fa7bc2a commit d43ff02
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 12 deletions.
24 changes: 23 additions & 1 deletion OpenTaiko/src/Common/ImGuiDebugWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static class ImGuiDebugWindow {
private static int currentStageMemoryUsage = 0;

private static int sortType = -1;
private static readonly string[] sortNames = ["Memory Usage (Highest->Lowest)", "Memory Usage (Lowest->Highest)", "Pointer ID"];
private static readonly string[] sortNames = ["Memory Usage (Highest -> Lowest)", "Memory Usage (Lowest -> Highest)", "Pointer ID"];
private static string reloadTexPath = "";
public static void Draw() {
if (SampleFramework.Game.ImGuiController == null) return;
Expand Down Expand Up @@ -214,6 +214,28 @@ private static void Profile() {
ImGui.EndCombo();
}

if (ImGui.TreeNodeEx("Edit Dan Title")) {

ImGui.InputText("Title", ref OpenTaiko.SaveFileInstances[save].data.Dan, 16);

ImGui.Checkbox("Gold", ref OpenTaiko.SaveFileInstances[save].data.DanGold);

string[] clear_types = ["Clear", "FC", "Perfect"];
int clear_int = OpenTaiko.SaveFileInstances[save].data.DanType;
if (ImGui.BeginCombo("Clear Type", clear_types[clear_int])) {
for (int clear = 0; clear < clear_types.Length; clear++) {
if (ImGui.Selectable(clear_types[clear], clear_int == clear)) OpenTaiko.SaveFileInstances[save].data.DanType = clear;
}
ImGui.EndCombo();
}

if (ImGui.Button("Update")) {
OpenTaiko.SaveFileInstances[save].tApplyHeyaChanges();
OpenTaiko.NamePlate.tNamePlateRefreshTitles(save);
}
ImGui.TreePop();
}

ImGui.NewLine();

ImGui.Text($"Total Plays: {OpenTaiko.SaveFileInstances[save].data.TotalPlaycount}");
Expand Down
36 changes: 32 additions & 4 deletions OpenTaiko/src/Common/OpenTaiko.cs
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,25 @@ protected override void Configuration() {
ConfigIsNew = true;
}

switch (ConfigIni.nGraphicsDeviceType) {
if (ConfigIsNew) {
GraphicsDeviceType_ = Silk.NET.GLFW.AnglePlatformType.OpenGL;

if (OperatingSystem.IsWindows()) {
GraphicsDeviceType_ = Silk.NET.GLFW.AnglePlatformType.OpenGL;
ConfigIni.nGraphicsDeviceType = 0;
}
// While we aren't able to support MacOS, this check is included just in case this changes.
else if (OperatingSystem.IsMacOS()) {
GraphicsDeviceType_ = Silk.NET.GLFW.AnglePlatformType.Metal;
ConfigIni.nGraphicsDeviceType = 3;
}
else if (OperatingSystem.IsLinux()) {
GraphicsDeviceType_ = Silk.NET.GLFW.AnglePlatformType.Vulkan;
ConfigIni.nGraphicsDeviceType = 2;
}
}
else {
switch (ConfigIni.nGraphicsDeviceType) {
case 0:
GraphicsDeviceType_ = Silk.NET.GLFW.AnglePlatformType.OpenGL;
break;
Expand All @@ -492,7 +510,9 @@ protected override void Configuration() {
case 3:
GraphicsDeviceType_ = Silk.NET.GLFW.AnglePlatformType.Metal;
break;
}
}


WindowPosition = new Silk.NET.Maths.Vector2D<int>(ConfigIni.nWindowBaseXPosition, ConfigIni.nWindowBaseYPosition);
WindowSize = new Silk.NET.Maths.Vector2D<int>(ConfigIni.nWindowWidth, ConfigIni.nWindowHeight);
Expand Down Expand Up @@ -1561,6 +1581,14 @@ private void tStartupProcess() {
Trace.TraceInformation("OS Version: " + Environment.OSVersion);
Trace.TraceInformation("Processors: " + Environment.ProcessorCount.ToString());
Trace.TraceInformation("CLR Version: " + Environment.Version.ToString());

if (ConfigIsNew) {
Trace.TraceInformation("----------------------");
Trace.TraceInformation("No Config.ini file was found. This usually means you've launched the game for the first time. A Config.ini file will be generated after safely closing the game.");
Trace.TraceInformation("Thanks for joining us! (≧∇≦)ノ");
Trace.TraceInformation($"{GraphicsDeviceType_} was selected as the recommended Graphics Device for your OS.");
Trace.TraceInformation($"{(CConfigIni.ESoundDeviceTypeForConfig)ConfigIni.nSoundDeviceType} was selected as the recommended Sound Device for your OS.");
}
//---------------------
#endregion

Expand Down Expand Up @@ -1774,7 +1802,7 @@ private void tStartupProcess() {
Trace.TraceInformation("Initialized loudness scanning, song gain control, and sound group level control.");
}

ShowWindowTitleWithSoundType();
ShowWindowTitle();
FDK.SoundManager.bIsTimeStretch = OpenTaiko.ConfigIni.bTimeStretch;
SoundManager.nMasterVolume = OpenTaiko.ConfigIni.nMasterVolume;
Trace.TraceInformation("サウンドデバイスの初期化を完了しました。");
Expand Down Expand Up @@ -1887,13 +1915,13 @@ private void tStartupProcess() {
#endregion
}

public void ShowWindowTitleWithSoundType() {
public void ShowWindowTitle() {
string delay = "";
if (SoundManager.GetCurrentSoundDeviceType() != "DirectSound") {
delay = "(" + SoundManager.GetSoundDelay() + "ms)";
}
AssemblyName asmApp = Assembly.GetExecutingAssembly().GetName();
base.Text = asmApp.Name + " Ver." + VERSION + " (" + SoundManager.GetCurrentSoundDeviceType() + delay + ")";
base.Text = asmApp.Name + " Ver." + VERSION + " - (" + GraphicsDeviceType_ + ") - (" + SoundManager.GetCurrentSoundDeviceType() + delay + ")";
}

private void tExitProcess() {
Expand Down
47 changes: 40 additions & 7 deletions OpenTaiko/src/Stages/04.Config/CActConfigList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,37 @@ public CItemBase ib現在の選択項目 {
}
public int n現在の選択項目;

private static int GraphicsDeviceFromString(string device) {
switch (device) {
case "OpenGL": return 0;
case "DirectX11": return 1;
case "Vulkan": return 2;
case "Metal": return 3;
default: return 0;
}
}
private static string GraphicsDeviceFromInt(int device) {
switch (device) {
case 0: return "OpenGL";
case 1: return "DirectX11";
case 2: return "Vulkan";
case 3: return "Metal";
default: return "OpenGL";
}
}

private static string[] AvailableGraphicsDevices { get {
if (OperatingSystem.IsWindows()) return ["OpenGL", "DirectX11", "Vulkan"];
if (OperatingSystem.IsMacOS()) return ["OpenGL", "Metal"];
if (OperatingSystem.IsLinux()) return ["OpenGL", "Vulkan"];
return ["OpenGL", "DirectX11", "Vulkan", "Metal"];
}
}

private static int GraphicsDeviceIntFromConfigInt() {
return Math.Max(0, Array.IndexOf(AvailableGraphicsDevices, GraphicsDeviceFromInt(OpenTaiko.ConfigIni.nGraphicsDeviceType)));
}


// General system options
#region [ t項目リストの設定_System() ]
Expand Down Expand Up @@ -88,10 +119,9 @@ public void t項目リストの設定_System(bool refresh = true) {
CLangManager.LangInstance.GetString("SETTINGS_SYSTEM_TIMESTRETCH_DESC"));
this.list項目リスト.Add(this.iSystemTimeStretch);

this.iSystemGraphicsType = new CItemList(CLangManager.LangInstance.GetString("SETTINGS_SYSTEM_GRAPHICSAPI"), CItemList.EPanelType.Normal, OpenTaiko.ConfigIni.nGraphicsDeviceType,
this.iSystemGraphicsType = new CItemList(CLangManager.LangInstance.GetString("SETTINGS_SYSTEM_GRAPHICSAPI"), CItemList.EPanelType.Normal, GraphicsDeviceIntFromConfigInt(),
CLangManager.LangInstance.GetString("SETTINGS_SYSTEM_GRAPHICSAPI_DESC"),
//new string[] { "OpenGL", "DirectX9", "DirectX11", "Vulkan", "Metal" });
new string[] { "OpenGL", "DirectX11", "Vulkan", "Metal" });
AvailableGraphicsDevices);
this.list項目リスト.Add(this.iSystemGraphicsType);

this.iSystemFullscreen = new CItemToggle(CLangManager.LangInstance.GetString("SETTINGS_SYSTEM_FULLSCREEN"), OpenTaiko.ConfigIni.bFullScreen,
Expand Down Expand Up @@ -190,10 +220,13 @@ public void t項目リストの設定_System(bool refresh = true) {

// #24820 2013.1.3 yyagi

this.iSystemSoundType = new CItemList(CLangManager.LangInstance.GetString("SETTINGS_SYSTEM_AUDIOPLAYBACK"), CItemList.EPanelType.Normal, OpenTaiko.ConfigIni.nSoundDeviceType,
// Hide this option for non-Windows users since all other sound device options are Windows-exclusive.
if (OperatingSystem.IsWindows()) {
this.iSystemSoundType = new CItemList(CLangManager.LangInstance.GetString("SETTINGS_SYSTEM_AUDIOPLAYBACK"), CItemList.EPanelType.Normal, OpenTaiko.ConfigIni.nSoundDeviceType,
CLangManager.LangInstance.GetString("SETTINGS_SYSTEM_AUDIOPLAYBACK_DESC"),
new string[] { "Bass", "ASIO", "WASAPI Exclusive", "WASAPI Shared" });
this.list項目リスト.Add(this.iSystemSoundType);
this.list項目リスト.Add(this.iSystemSoundType);
}

// #24820 2013.1.15 yyagi
this.iSystemBassBufferSizeMs = new CItemInteger(CLangManager.LangInstance.GetString("SETTINGS_SYSTEM_BASSBUFFER"), 0, 99999, OpenTaiko.ConfigIni.nBassBufferSizeMs,
Expand Down Expand Up @@ -1032,7 +1065,7 @@ public override void DeActivate() {
0,
this.iSystemASIODevice.n現在選択されている項目番号,
this.iSystemSoundTimerType.bON);
OpenTaiko.app.ShowWindowTitleWithSoundType();
OpenTaiko.app.ShowWindowTitle();
OpenTaiko.Skin.ReloadSkin();// 音声の再読み込みをすることによって、音量の初期化を防ぐ
}
#endregion
Expand Down Expand Up @@ -1607,7 +1640,7 @@ private void tConfigIniへ記録する() {
private void tConfigIniへ記録する_System() {
OpenTaiko.ConfigIni.nSongSpeed = this.iCommonPlaySpeed.n現在の値;

OpenTaiko.ConfigIni.nGraphicsDeviceType = this.iSystemGraphicsType.n現在選択されている項目番号;
OpenTaiko.ConfigIni.nGraphicsDeviceType = GraphicsDeviceFromString(AvailableGraphicsDevices[this.iSystemGraphicsType.n現在選択されている項目番号]);
OpenTaiko.ConfigIni.bFullScreen = this.iSystemFullscreen.bON;
OpenTaiko.ConfigIni.bIncludeSubfoldersOnRandomSelect = this.iSystemRandomFromSubBox.bON;

Expand Down

0 comments on commit d43ff02

Please sign in to comment.