Skip to content

Commit

Permalink
thcrap config handling + button edit
Browse files Browse the repository at this point in the history
Should fix bugs and be more efficient for the settings.
Also the new randomizer select buttons are symmetrical and fit more text.
  • Loading branch information
David-JonesDVN committed Feb 28, 2019
1 parent d9187b7 commit 00638bb
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Touhou Launcher/ConfigForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 8 additions & 11 deletions Touhou Launcher/ConfigForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public partial class ConfigForm : Form
public int game;
bool tr = false;
MainForm main;
string[] crap;

public ConfigForm(int id, MainForm parent)
{
Expand Down Expand Up @@ -54,13 +55,14 @@ private void ConfigForm_Load(object sender, EventArgs e)
crapGame.Items.Add(line.Key);
}
}
foreach (string file in Directory.GetFiles(Path.GetDirectoryName(MainForm.curCfg.crapDir), "*.js").Where(n => n != "games.js" && n != "config.js"))
foreach (string file in Directory.GetFiles(Path.GetDirectoryName(MainForm.curCfg.crapDir), "*.js").Where(n => !n.Contains("games.js") && !n.Contains("config.js")))
{
crapCfg.Items.Add(Path.GetFileName(file));
}
}
crapGame.SelectedItem = MainForm.curCfg.gameCFG[game].crapGame;
crapCfg.SelectedItem = MainForm.curCfg.gameCFG[game].crapCfg;
crap = MainForm.curCfg.gameCFG[game].GameDir[3].Split(new char[] { '/' });
crapGame.SelectedItem = crap[0];
crapCfg.SelectedItem = crap[1];
crapApplocale.Checked = MainForm.curCfg.gameCFG[game].appLocale[3];
defaultExec.SelectedIndex = MainForm.curCfg.gameCFG[game].DefaultDir;
defaultApplocale.Checked = MainForm.curCfg.gameCFG[game].DefaultApplocale;
Expand Down Expand Up @@ -240,10 +242,10 @@ private void launchcrap_Click(object sender, EventArgs e)
{
if (!File.Exists(MainForm.curCfg.crapDir))
MessageBox.Show(MainForm.rm.GetString("errorcrapNotFound"));
else if (MainForm.curCfg.gameCFG[game].crapCfg == "None" || MainForm.curCfg.gameCFG[game].crapGame == "None")
else if (crap[0] == "None" || crap[1] == "None")
MessageBox.Show(MainForm.rm.GetString("errorcrapConfigNotSet"));
else
Process.Start(MainForm.curCfg.crapDir, "\"" + Path.GetDirectoryName(MainForm.curCfg.crapDir) + "\\" + MainForm.curCfg.gameCFG[game].crapCfg + "\" " + MainForm.curCfg.gameCFG[game].crapGame);
Process.Start(MainForm.curCfg.crapDir, "\"" + Path.GetDirectoryName(MainForm.curCfg.crapDir) + "\\" + crap[1] + "\" " + crap[0]);
}

private void defaultApplocale_CheckedChanged(object sender, EventArgs e)
Expand Down Expand Up @@ -428,14 +430,9 @@ private void openAppdata_Click(object sender, EventArgs e)
MessageBox.Show(MainForm.rm.GetString("errorAppdataNotFound"));
}

private void crapGame_SelectedIndexChanged(object sender, EventArgs e)
{
MainForm.curCfg.gameCFG[game].crapGame = (string)crapGame.SelectedItem;
}

private void crapCfg_SelectedIndexChanged(object sender, EventArgs e)
{
MainForm.curCfg.gameCFG[game].crapCfg = (string)crapCfg.SelectedItem;
MainForm.curCfg.gameCFG[game].GameDir[3] = (string)crapGame.SelectedItem + "/" + (string)crapCfg.SelectedItem;
}
}
}
8 changes: 4 additions & 4 deletions Touhou Launcher/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 5 additions & 7 deletions Touhou Launcher/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ public partial class MainForm : Form

public class GameConfig
{
public List<string> GameDir = new List<string>(3);
public string crapGame = "None";
public string crapCfg = "None";
public List<string> GameDir = new List<string>(4);
public List<bool> appLocale = new List<bool>(4);
public int DefaultDir = 0;
public bool DefaultApplocale = false;
Expand Down Expand Up @@ -76,7 +74,7 @@ public Configs()
for (int i = 0; i < gameCFG.Length ; i++)
{
gameCFG[i] = new GameConfig();
gameCFG[i].GameDir = new List<string> { "", "", "" };
gameCFG[i].GameDir = new List<string> { "", "", "", "None/None" };
gameCFG[i].appLocale = new List<bool> { false, false, false, false };
}
}
Expand Down Expand Up @@ -373,9 +371,9 @@ public void RefreshGames()
if (btn.Name != "btnRandom")
{
int game = nameToID[btn.Name.Substring(3)];
bool exists = curCfg.gameCFG[game].crapGame != "None" && curCfg.gameCFG[game].crapCfg != "None";
bool exists = curCfg.gameCFG[game].GameDir[3].Split(new char[] { '/' })[0] != "None" && curCfg.gameCFG[game].GameDir[3].Split(new char[] { '/' })[1] != "None";
foreach (string dir in curCfg.gameCFG[game].GameDir)
if (dir != "")
if (dir != "" && dir != curCfg.gameCFG[game].GameDir[3])
{
exists = true;
break;
Expand Down Expand Up @@ -431,7 +429,7 @@ private void btn_Click(object sender, EventArgs e)
if (File.Exists(curCfg.crapDir))
{
path = curCfg.crapDir;
args = "\"" + Path.GetDirectoryName(MainForm.curCfg.crapDir) + "\\" + curGame.crapCfg + "\" " + curGame.crapGame;
args = "\"" + Path.GetDirectoryName(MainForm.curCfg.crapDir) + "\\" + curGame.GameDir[3].Split(new char[] { '/' })[1] + "\" " + curGame.GameDir[3].Split(new char[] { '/' })[0];
}
else
{
Expand Down

0 comments on commit 00638bb

Please sign in to comment.