-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSettings.xaml.cs
234 lines (197 loc) · 7.21 KB
/
Settings.xaml.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows;
using Microsoft.Win32;
using Newtonsoft.Json;
using System.Windows.Controls;
using Microsoft.VisualBasic;
namespace Concursus
{
public partial class Settings : Window
{
public Settings()
{
InitializeComponent();
Themes.UpdateForm(Themes.CURRENT_THEME, this);
foreach (Themes.ThemeOption theme_option in Enum.GetValues(typeof(Themes.ThemeOption)))
{
if (theme_option == Themes.ThemeOption.Invalid)
continue;
cboThemes.Items.Add(Themes.GetStringFromOption(theme_option));
}
cboThemes.SelectedItem = Themes.GetStringFromOption(Themes.CURRENT_THEME);
}
private void cboThemes_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Themes.CURRENT_THEME = Themes.GetOptionFromString(cboThemes.SelectedItem.ToString());
Themes.UpdateForm(Themes.CURRENT_THEME, this);
if (this.Owner != null)
Themes.UpdateForm(Themes.CURRENT_THEME, this.Owner);
}
private void btnSave_Click(object sender, RoutedEventArgs e)
{
Properties.Settings.Default.App_Theme = Themes.GetStringFromOption(Themes.CURRENT_THEME);
Properties.Settings.Default.Save();
this.Close();
}
private Dictionary<string, int> knownGameIDs = new Dictionary<string, int>
{
{ "SonicSuperstars.exe", 1965917 },
{ "SOUL HACKERS2.exe", 45 },
{ "Persona 5 Tactica.exe", 10 },
{ "Bomb Rush Cyberfunk.exe", 11 },
// Add more entries for other known games as needed
};
private Dictionary<string, int> GBRSSValues = new Dictionary<string, int>
{
{ "SonicSuperstars.exe", 18552 },
{ "SOUL HACKERS2.exe", 17065 },
{ "Etrian Odyssey.exe", 18479 },
{ "Etrian Odyssey 2.exe", 18480 },
{ "Etrian Odyssey 3.exe", 18481 },
{ "Persona 5 Tactica.exe", 18918 },
{ "Bomb Rush Cyberfunk.exe", 18955 },
// Add more entries for other known games as needed
};
private Dictionary<string, string> GBONECLICKValues = new Dictionary<string, string>
{
{ "SonicSuperstars.exe", "SUPERSTARS" },
{ "SOUL HACKERS2.exe", "SH2" },
{ "Etrian Odyssey.exe", "EOHD" },
{ "Etrian Odyssey 2.exe", "EO2HD" },
{ "Etrian Odyssey 3.exe", "EO3HD" },
{ "Persona 5 Tactica.exe", "P5T" },
{ "Bomb Rush Cyberfunk.exe", "BRC" }
// Add more entries for other known games as needed
};
private void btnAddGame_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() != true)
return;
string exePath = ofd.FileName;
string dataDir = "";
foreach (string dir in Directory.GetDirectories(Path.GetDirectoryName(exePath)))
{
if (dir.Contains("_Data"))
{
dataDir = dir;
break;
}
}
string key = Path.GetFileNameWithoutExtension(exePath); // Remove ".exe" extension
string gameName = Path.GetFileName(Path.GetDirectoryName(exePath)); // Get the parent folder name
int gameID = 0; // Default to 0
if (knownGameIDs.ContainsKey(Path.GetFileName(exePath)))
{
gameID = knownGameIDs[Path.GetFileName(exePath)]; // Set the GameID if it's a known game
}
int GBRSS = 0; // Initialize GBRSS as an int
string GBONECLICK = ""; // Initialize GBONECLICK as a string
if (GBRSSValues.ContainsKey(Path.GetFileName(exePath)))
{
GBRSS = GBRSSValues[Path.GetFileName(exePath)]; // Set GBRSS as an int
}
else
{
// GBRSS not found, prompt user for manual input
GBRSS = PromptForGBRSS();
}
if (GBONECLICKValues.ContainsKey(Path.GetFileName(exePath)))
{
GBONECLICK = GBONECLICKValues[Path.GetFileName(exePath)]; // Set GBONECLICK as a string
}
List<Game> games = new List<Game>();
games.Add(new Game()
{
key = key,
GameName = gameName,
GameFolderDataName = Path.GetFileName(dataDir),
GamePath = Path.GetDirectoryName(exePath),
GameExecutable = exePath,
GameID = gameID,
GBRSS = GBRSS, // Set GBRSS as an int
GBONECLICK = GBONECLICK // Set GBONECLICK as a string
});
string gameJson = JsonConvert.SerializeObject(games, Formatting.Indented);
string gameDataFolderPath = "GameData";
if (!Directory.Exists(gameDataFolderPath))
{
Directory.CreateDirectory(gameDataFolderPath);
}
string jsonFileName = Path.Combine(gameDataFolderPath, $"{key}.json");
File.WriteAllText(jsonFileName, gameJson);
MessageBox.Show("Game added and JSON data saved!");
}
private int PromptForGBRSS()
{
string input = Interaction.InputBox("Enter GB Game ID (0 if you don't know):", "Add Game (Manual)", "");
if (int.TryParse(input, out int result))
{
return result;
}
else
{
MessageBox.Show("Invalid GBRSS value. Please enter a valid integer.");
return PromptForGBRSS(); // Recursive call until a valid input is provided
}
}
private void btnManualAdd_Click(object sender, RoutedEventArgs e)
{
string gamePath = Interaction.InputBox("Enter Game Path (the folder your mods will install into):", "Add Game (Manual)", "");
string gameFolderDataName = Interaction.InputBox("Enter Game Folder Data Name (if you don't know what this is type something random):", "Add Game (Manual)", "");
if (string.IsNullOrWhiteSpace(gamePath) || string.IsNullOrWhiteSpace(gameFolderDataName))
{
MessageBox.Show("Please provide valid input for Game Path and Game Folder Data Name.");
return;
}
string gameName = Interaction.InputBox("Enter Game Name:", "Add Game (Manual)", "");
if (string.IsNullOrWhiteSpace(gameName))
{
MessageBox.Show("Please provide a valid input for Game Name.");
return;
}
string GameFolderDataName = Path.GetFileName(gamePath); // Get the last folder name as Game Folder Data Name
string key = Path.GetFileName(gamePath); // Get the folder name as key
int gameID = 0; // Default to 0
string gameIDInput = Interaction.InputBox("Enter Game ID (0 if you don't know):", "Add Game (Manual)", "");
if (!string.IsNullOrWhiteSpace(gameIDInput) && int.TryParse(gameIDInput, out int parsedGameID))
{
gameID = parsedGameID;
}
// Prompt the user for GBRSSFEED ID
string gbrssFeedInput = Interaction.InputBox("Enter GB Game ID (0 if you don't know):", "Add Game (Manual)", "");
if (int.TryParse(gbrssFeedInput, out int gbrssFeed))
{
// Continue with game creation
List<Game> games = new List<Game>();
games.Add(new Game()
{
key = key,
GameName = gameName,
GameFolderDataName = GameFolderDataName,
GamePath = gamePath,
GameExecutable = Path.Combine(gamePath, $"{key}.exe"), // Assuming the executable is named after the folder
GameID = gameID, // Set the GameID here with the desired value or user input
GBRSS = gbrssFeed // Set GBRSSFEED as an int
});
string gameJson = JsonConvert.SerializeObject(games, Formatting.Indented);
// Create the GameData folder if it doesn't exist
string gameDataFolderPath = "GameData";
if (!Directory.Exists(gameDataFolderPath))
{
Directory.CreateDirectory(gameDataFolderPath);
}
// Save the game's data in a separate JSON file named after the key
string jsonFileName = Path.Combine(gameDataFolderPath, $"{key}.json");
File.WriteAllText(jsonFileName, gameJson);
MessageBox.Show("Game added and JSON data saved!");
}
else
{
MessageBox.Show("Invalid GBRSSFEED ID. Please enter a valid integer.");
}
}
}
}