-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameFileEditor.cs
142 lines (132 loc) · 5.52 KB
/
GameFileEditor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
using System;
using System.IO;
using System.Windows.Forms;
using ProSwapperFOV.Properties;
using System.Diagnostics;
namespace ProSwapperFOV
{
public static class GameFileEditor
{
public static string fndir
{
get
{
string defaultpath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\FortniteGame\Saved\Config\WindowsClient\GameUserSettings.ini";
if (File.Exists(defaultpath))
{
return defaultpath;
}
else
{
using (OpenFileDialog o = new OpenFileDialog())
{
o.Title = "Select your Fortnite GameUserSettings.ini";
o.Filter = "GameUserSettings.ini (*.ini*)|*.ini";
o.ShowDialog();
if (o.ShowDialog() == DialogResult.OK)
{
return o.FileName;
}
return "null";
}
}
}
}
private static void KillFortnite()
{
foreach (Process a in Process.GetProcessesByName("EpicGamesLauncher"))
{
a.Kill();
}
foreach (Process a in Process.GetProcessesByName("FortniteClient-Win64-Shipping"))
{
a.Kill();
}
}
private static string GameFile { get; set; }
/*
*
*
* LastUserConfirmedDesiredScreenWidth=1920
LastUserConfirmedDesiredScreenHeight=1080
LastRecommendedScreenWidth=-1.000000
LastRecommendedScreenHeight=-1.000000
*
* DesiredScreenWidth=1920
DesiredScreenHeight=1080
*
*/
public static void SetRes(string YRes, string XRes, int fullscreenmode)
{
try
{
KillFortnite();
File.SetAttributes(Settings.Default.GameDir, FileAttributes.Normal);
GameFile = string.Empty;
string line;
using (StreamReader file = new StreamReader(Settings.Default.GameDir))
{
while ((line = file.ReadLine()) != null)//Reads line one by one
{
if (line.StartsWith("ResolutionSizeY="))
{
GameFile += "ResolutionSizeY=" + YRes + Environment.NewLine;
continue;
}
if (line.StartsWith("LastUserConfirmedResolutionSizeY="))
{
GameFile += "LastUserConfirmedResolutionSizeY=" + YRes + Environment.NewLine;
continue;
}
if (line.StartsWith("LastUserConfirmedDesiredScreenHeight="))
{
GameFile += "LastUserConfirmedDesiredScreenHeight=" + YRes + Environment.NewLine;
continue;
}
if (line.StartsWith("DesiredScreenHeight="))
{
GameFile += "DesiredScreenHeight=" + YRes + Environment.NewLine;
continue;
}
if (line.StartsWith("ResolutionSizeX="))
{
GameFile += "ResolutionSizeX=" + XRes + Environment.NewLine;
continue;
}
if (line.StartsWith("LastUserConfirmedResolutionSizeX="))
{
GameFile += "LastUserConfirmedResolutionSizeX=" + XRes + Environment.NewLine;
continue;
}
if (line.StartsWith("LastUserConfirmedDesiredScreenWidth="))
{
GameFile += "LastUserConfirmedDesiredScreenWidth=" + XRes + Environment.NewLine;
continue;
}
if (line.StartsWith("DesiredScreenWidth="))
{
GameFile += "DesiredScreenWidth=" + XRes + Environment.NewLine;
continue;
}
if (line.StartsWith("LastConfirmedFullscreenMode="))
{
GameFile += "LastConfirmedFullscreenMode=" + fullscreenmode + Environment.NewLine;
continue;
}
if (line.StartsWith("FullscreenMode="))
{
GameFile += "FullscreenMode=" + fullscreenmode + Environment.NewLine;
continue;
}
GameFile += line + Environment.NewLine;
}
}
File.WriteAllText(Settings.Default.GameDir, GameFile);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Pro Swapper FOV Changer", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}