Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
Merge branch 'gurrenm3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Gurrenm3 authored and Gurrenm3 committed Mar 31, 2020
2 parents 8c23a3a + 52e8576 commit a649f25
Show file tree
Hide file tree
Showing 8 changed files with 289 additions and 78 deletions.
181 changes: 146 additions & 35 deletions BTDToolbox/Classes/GeneralMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,37 @@ public static void CreateBackup(string game)
ConsoleHandler.appendLog("Unable to create backup for " + game + ".");
}
}
public static void SteamValidateBTD5()
{
Process.Start("steam://validate/306020");
}
public static void SteamValidateBTDB()
{
Process.Start("steam://validate/444640");
}
public static void BackupLOC(string game)
{
string backupDir = Environment.CurrentDirectory + "\\Backups";
string backupLocName = game + "_Original_LOC.xml";

if (!Directory.Exists(backupDir))
{
ConsoleHandler.appendLog("Backup directory does not exist. Creating directory...");
Directory.CreateDirectory(backupDir);
}

string gameDir = "";
if (game == "BTD5")
gameDir = DeserializeConfig().BTD5_Directory;
else
gameDir = DeserializeConfig().BTDB_Directory;

string steamJetPath = GetJetPath(game);
if (steamJetPath != null)
CopyFile(gameDir + "\\Assets\\Loc\\English.xml", backupDir + "\\" + backupLocName);
else
ConsoleHandler.appendLog("Unable to create backup for " + game + ".");
}
public static void RestoreGame_ToBackup(string game)
{
string gameDir = "";
Expand Down Expand Up @@ -516,56 +547,136 @@ public static string OutputJet()
}
public static void CompileJet(string switchCase)
{
if (JsonEditor.jsonError != true)
if (New_JsonEditor.isJsonError != true)
{
if (JetProps.get().Count == 1)
{
string dest = "";
bool isOutputting = false;
string gameDir = "";
string gameNameTemp = "";

var zip = new ZipForm();
if (Serializer.Deserialize_Config().CurrentGame != "" && Serializer.Deserialize_Config() != null)
gameNameTemp = Serializer.Deserialize_Config().CurrentGame;
else if (Main.gameName != "" && Main.gameName != null)
{
gameNameTemp = Main.gameName;
Serializer.SaveConfig(Main.getInstance(), "main", Serializer.Deserialize_Config());
}

if(gameNameTemp != "" && gameNameTemp != null)
{
if (Main.gameName == "BTD5")
gameDir = Serializer.Deserialize_Config().BTD5_Directory;
else
gameDir = Serializer.Deserialize_Config().BTDB_Directory;

if (switchCase.Contains("output"))
if (JetProps.get().Count == 1)
{
isOutputting = true;
ConsoleHandler.appendLog("Select where you want to export your jet file. Make sure to give it a name..");
dest = OutputJet();
zip.destPath = dest;
}
if (switchCase.Contains("launch"))
{
zip.launch = true;
}
if (isOutputting)
{
if (dest != null && dest != "")
string dest = "";
bool isOutputting = false;
bool abort = false;

var zip = new ZipForm();

if (switchCase.Contains("output"))
{
zip.Show();
zip.Compile();
isOutputting = true;
string exPath = programData.ExportPath;
if (exPath != "" && exPath != null)
{
DialogResult diag = MessageBox.Show("Do you want export to the same place as last time?", "Export to the same place?", MessageBoxButtons.YesNo);
if (diag == DialogResult.Yes)
dest = exPath;
else
exPath = "";
}
if (exPath == "" || exPath == null)
{
ConsoleHandler.appendLog("Select where you want to export your jet file. Make sure to give it a name..");
dest = OutputJet();
ZipForm.savedExportPath = dest;
Serializer.SaveSmallSettings("export path", Serializer.Deserialize_Config());
}
zip.destPath = dest;
}
else
else if (switchCase.Contains("launch"))
{
ConsoleHandler.appendLog("Export cancelled...");
if (gameDir != null && gameDir != "")
zip.launch = true;
else
{
ConsoleHandler.force_appendNotice("Unable to find your game directory, and therefore, unable to launch. Do you want to try browsing for your game?");
DialogResult diag = MessageBox.Show("Unable to find your game directory, and therefore, unable to launch. Do you want to try browsing for your game?", "Browse for game?", MessageBoxButtons.YesNoCancel);
if (diag == DialogResult.Yes)
{
browseForExe(gameNameTemp);
}
if (diag == DialogResult.No)
{
DialogResult diag2 = MessageBox.Show("Do you want to just save your jet file instead?", "Save jet instead?", MessageBoxButtons.YesNo);
{
if (diag2 == DialogResult.Yes)
{
isOutputting = true;
string exPath = programData.ExportPath;
if (exPath != "" && exPath != null)
{
DialogResult diagz = MessageBox.Show("Do you want export to the same place as last time?", "Export to the same place?", MessageBoxButtons.YesNo);
if (diagz == DialogResult.Yes)
dest = exPath;
else
exPath = "";
}
if (exPath == "" || exPath == null)
{
ConsoleHandler.appendLog("Select where you want to export your jet file. Make sure to give it a name..");
dest = OutputJet();
ZipForm.savedExportPath = dest;
Serializer.SaveSmallSettings("export path", Serializer.Deserialize_Config());
}
zip.destPath = dest;
}
}
}
else
abort = true;
}
}
if(!abort)
{
if (isOutputting)
{
if (dest != null && dest != "")
{
zip.Show();
zip.Compile();
}
else
{
ConsoleHandler.appendLog("Export cancelled...");
}
}
else
{
zip.Show();
zip.Compile();
}
}
}
else
{
zip.Show();
zip.Compile();
if (JetProps.get().Count < 1)
{
MessageBox.Show("You have no .jets or projects open, you need one to launch.");
ConsoleHandler.appendLog("You need to open a project to continue...");
}
else
{
MessageBox.Show("You have multiple .jets or projects open, only one can be launched.");
ConsoleHandler.appendLog("You need to close projects to continue...");
}
}
}
else
{
if (JetProps.get().Count < 1)
{
MessageBox.Show("You have no .jets or projects open, you need one to launch.");
ConsoleHandler.appendLog("You need to open a project to continue...");
}
else
{
MessageBox.Show("You have multiple .jets or projects open, only one can be launched.");
ConsoleHandler.appendLog("You need to close projects to continue...");
}
ConsoleHandler.force_appendNotice("There was an issue detecting your current game! Please restart toolbox and try again...");
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions BTDToolbox/Classes/SerializeOps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public static void SaveSmallSettings(string formName, ConfigFile serialize_confi
{
var cfg = Serializer.Deserialize_Config();

if (formName == "export path")
{
cfg.ExportPath = ZipForm.savedExportPath;
}
if (formName == "updater")
{
cfg.recentUpdate = UpdateChangelog.recentUpdate;
Expand Down Expand Up @@ -174,6 +178,8 @@ public static ConfigFile Deserialize_Config()

programData.JsonEditor_OpenedTabs = new List<string>();

programData.ExportPath = "";
programData.battlesPass = "";

programData.BTD5_Directory = "";
programData.BTDB_Directory = "";
Expand Down
48 changes: 43 additions & 5 deletions BTDToolbox/Extra Forms/EasyTowerEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public partial class EasyTowerEditor : Form
string[] loc_upgradeDescs = new string[] { };

string game = Serializer.Deserialize_Config().CurrentGame;

string gameDir = "";
string[] loc_Text = new string[] { };
string loc_Path = "";
string loc_towerName = "";
Expand Down Expand Up @@ -199,7 +199,31 @@ private void PopulateUI()
TowerDesc_TextBox.Text = loc_towerDesc;
}
}
ReadLoc();
if(game == "BTD5")
{
if(File.Exists(loc_Path))
ReadLoc();
else
{
if(Serializer.Deserialize_Config().BTD5_Directory == null || Serializer.Deserialize_Config().BTD5_Directory == "")
{
ConsoleHandler.force_appendNotice("You haven't browsed for your BTD5 Game so you will not be able to edit the tower and upgrade descriptions");
this.Focus();
}
else
{
ConsoleHandler.force_appendNotice("Unable to find your LOC file...");
DialogResult diag = MessageBox.Show("Unable to find BTD5's LOC file. Do you want toolbox to make Steam validate BTD5 so it can reaquire it? If you have any mods applied to btd5 steam, they will be lost. Do you want to continue?", "Continue?", MessageBoxButtons.YesNo);
if (diag == DialogResult.Yes)
GeneralMethods.SteamValidateBTD5();
else
{
ConsoleHandler.force_appendNotice("Valdation cancelled. You will not be able to mod the tower or upgrade descriptions...");
this.Focus();
}
}
}
}

if (upgradenames != null)
{
Expand Down Expand Up @@ -397,7 +421,16 @@ private void PopulateUpgrades()
RankToUnlockUpgrade_TextBox.Text = upgradeRanks[Upgrades_ListBox.SelectedIndex].ToString();
XpToUnlockUpgrade_TextBox.Text = upgradeXPs[Upgrades_ListBox.SelectedIndex].ToString();

UpgradeDesc_TextBox.Text = loc_upgradeDescs[Upgrades_ListBox.SelectedIndex].ToString();
if (game == "BTD5")
{
if (File.Exists(loc_Path))
UpgradeDesc_TextBox.Text = loc_upgradeDescs[Upgrades_ListBox.SelectedIndex].ToString();
}
else if (game != "" && game != null)
UpgradeDesc_TextBox.Text = loc_upgradeDescs[Upgrades_ListBox.SelectedIndex].ToString();
else
ConsoleHandler.force_appendNotice("Something went wrong and your current game was not detected. Please reload BTD Toolbox, otherwise you may encounter errors");

}
}
private void ResetUI()
Expand Down Expand Up @@ -601,7 +634,7 @@ private void SaveLoc()
}
private void ReadLoc()
{
if (Serializer.Deserialize_Config().CurrentGame == "BTD5")
if(File.Exists(loc_Path))
{
loc_Text = File.ReadAllLines(loc_Path);
string towerName = "LOC_" + TowerType_Label.Text + "_TOWER";
Expand Down Expand Up @@ -669,6 +702,10 @@ private void ReadLoc()
}
}
}
else
{

}
}


Expand Down Expand Up @@ -722,7 +759,8 @@ private void UpgradeName_TextBox_TextChanged(object sender, EventArgs e)
private void Save_Button_Click(object sender, EventArgs e)
{
SaveFile();
SaveLoc();
if (File.Exists(loc_Path))
SaveLoc();
ConsoleHandler.appendLog_CanRepeat("Saved " + AllTowerFiles_ComboBox.SelectedItem.ToString());
}
private void UpgradeIcon_TextBox_TextChanged(object sender, EventArgs e)
Expand Down
16 changes: 16 additions & 0 deletions BTDToolbox/Get_BTDB_Password.Designer.cs

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

Loading

0 comments on commit a649f25

Please sign in to comment.