Skip to content

Commit 2aecbb9

Browse files
committed
[ZZZ GSP] Fix wrong index on resolution list
1 parent a331303 commit 2aecbb9

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

CollapseLauncher/XAMLs/MainApp/Pages/GameSettingsPages/ZenlessGameSettingsPage.xaml.cs

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -164,17 +164,16 @@ private void InitializeSettings(object sender, RoutedEventArgs e)
164164

165165
var resList = new List<string>();
166166
SizeProp = ScreenProp.CurrentResolution;
167-
//SizeProp = new System.Drawing.Size(2560, 1600);
168167

169168
// Get the native resolution first
170169
var nativeResSize = GetNativeDefaultResolution();
171170
var nativeResString = string.Format(Lang._GameSettingsPage.Graphics_ResPrefixFullscreen, nativeResSize.Width, nativeResSize.Height) + $" [{Lang._Misc.Default}]";
172171

173172
// Then get the rest of the list
174-
List<string> resFullscreen = GetResPairs_Fullscreen();
175-
List<string> resWindowed = GetResPairs_Windowed();
173+
List<string> resFullscreen = GetResPairs_Fullscreen(nativeResSize);
174+
List<string> resWindowed = GetResPairs_Windowed();
176175

177-
ScreenResolutionIsFullscreenIdx.Add(true); // Add first for the native resolution.
176+
// Add the index of fullscreen and windowed resolution booleans
178177
ScreenResolutionIsFullscreenIdx.AddRange(Enumerable.Range(0, resFullscreen.Count).Select(_ => true));
179178
ScreenResolutionIsFullscreenIdx.AddRange(Enumerable.Range(0, resWindowed.Count).Select(_ => false));
180179

@@ -188,12 +187,12 @@ private void InitializeSettings(object sender, RoutedEventArgs e)
188187

189188
if (CurrentGameProperty.IsGameRunning)
190189
{
191-
#if !GSPBYPASSGAMERUNNING
190+
#if !GSPBYPASSGAMERUNNING
192191
Overlay.Visibility = Visibility.Visible;
193192
PageContent.Visibility = Visibility.Collapsed;
194193
OverlayTitle.Text = Lang._GameSettingsPage.OverlayGameRunningTitle;
195194
OverlaySubtitle.Text = Lang._GameSettingsPage.OverlayGameRunningSubtitle;
196-
#endif
195+
#endif
197196
}
198197
else if (GameInstallationState == GameInstallStateEnum.NotInstalled
199198
|| GameInstallationState == GameInstallStateEnum.NeedsUpdate
@@ -207,9 +206,9 @@ private void InitializeSettings(object sender, RoutedEventArgs e)
207206
}
208207
else
209208
{
210-
#if !DISABLEDISCORD
209+
#if !DISABLEDISCORD
211210
InnerLauncherConfig.AppDiscordPresence.SetActivity(ActivityType.GameSettings);
212-
#endif
211+
#endif
213212
}
214213
}
215214
catch (Exception ex)
@@ -252,23 +251,39 @@ private System.Drawing.Size GetNativeDefaultResolution()
252251
return currentAcceptedRes.LastOrDefault(x => x.Width == maxAcceptedResW);
253252
}
254253

255-
private List<string> GetResPairs_Fullscreen()
254+
private List<string> GetResPairs_Fullscreen(System.Drawing.Size defaultResolution)
256255
{
257256
var nativeAspRatio = (double)SizeProp.Width / SizeProp.Height;
258257
var acH = acceptableHeight;
259258
var acceptedMaxHeight = ScreenProp.GetMaxHeight();
260259

261260
acH.RemoveAll(h => h > acceptedMaxHeight);
262261
//acH.RemoveAll(h => h > 1600);
263-
262+
263+
// Get the resolution pairs and initialize default resolution index
264264
List<string> resPairs = new List<string>();
265+
int indexOfDefaultRes = -1;
265266

266-
foreach (var h in acH)
267+
for (int i = 0; i < acH.Count; i++)
267268
{
269+
// Get height and calculate width
270+
int h = acH[i];
268271
int w = (int)(h * nativeAspRatio);
272+
273+
// If the resolution is the same as default, set the index
274+
if (h == defaultResolution.Height && w == defaultResolution.Width)
275+
indexOfDefaultRes = i;
276+
277+
// Add the resolution pair to the list
269278
resPairs.Add(string.Format(Lang._GameSettingsPage.Graphics_ResPrefixFullscreen, w, h));
270279
}
271280

281+
// If the index of default resolution is found, remove it from the list
282+
if (indexOfDefaultRes != -1)
283+
{
284+
resPairs.RemoveAt(indexOfDefaultRes);
285+
}
286+
272287
return resPairs;
273288
}
274289

0 commit comments

Comments
 (0)