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 692f270 + b38e5a3 commit 8c23a3a
Show file tree
Hide file tree
Showing 37 changed files with 4,381 additions and 502 deletions.
50 changes: 45 additions & 5 deletions BTDToolbox/BTDToolbox.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="DotNetZip, Version=1.13.5.0, Culture=neutral, PublicKeyToken=6583c7c814667745, processorArchitecture=MSIL">
<HintPath>..\packages\DotNetZip.1.13.5\lib\net40\DotNetZip.dll</HintPath>
<Reference Include="DotNetZip, Version=1.13.7.0, Culture=neutral, PublicKeyToken=6583c7c814667745, processorArchitecture=MSIL">
<HintPath>..\packages\DotNetZip.1.13.7\lib\net40\DotNetZip.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="Microsoft.WindowsAPICodePack, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\WindowsAPICodePack-Core.1.1.1\lib\Microsoft.WindowsAPICodePack.dll</HintPath>
<Reference Include="Microsoft.WindowsAPICodePack, Version=1.1.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\WindowsAPICodePack-Core.1.1.2\lib\Microsoft.WindowsAPICodePack.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAPICodePack.Shell, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\WindowsAPICodePack-Shell.1.1.1\lib\Microsoft.WindowsAPICodePack.Shell.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="PresentationFramework" />
<Reference Include="System" />
Expand All @@ -65,19 +65,29 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Classes\Announcements.cs" />
<Compile Include="Classes\BattlesPass_Class.cs" />
<Compile Include="Classes\Bloon_Class.cs" />
<Compile Include="Classes\Card_Class.cs" />
<Compile Include="Classes\CrackBTDB_Pass.cs" />
<Compile Include="Classes\ImageProcessing.cs" />
<Compile Include="Classes\JsonEditorHandler.cs" />
<Compile Include="Classes\ModLoader_Handling.cs" />
<Compile Include="Classes\NKHook_Handling.cs" />
<Compile Include="Classes\QuickType.cs" />
<Compile Include="Classes\Spritesheets\SpriteSheet_Handler.cs" />
<Compile Include="Classes\Sprite_Class.cs" />
<Compile Include="Classes\SubTask_Reader.cs" />
<Compile Include="Classes\Tower_Class.cs" />
<Compile Include="Classes\UpdateHandler.cs" />
<Compile Include="Classes\ConsoleHandler.cs" />
<Compile Include="Classes\JSON_Reader.cs" />
<Compile Include="Classes\WebHandler.cs" />
<Compile Include="Extra Forms\BattlesPassManager.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Extra Forms\BattlesPassManager.Designer.cs">
<DependentUpon>BattlesPassManager.cs</DependentUpon>
</Compile>
<Compile Include="Extra Forms\BGForm.cs">
<SubType>Form</SubType>
</Compile>
Expand All @@ -90,6 +100,12 @@
<Compile Include="Extra Forms\CreditViewer.Designer.cs">
<DependentUpon>CreditViewer.cs</DependentUpon>
</Compile>
<Compile Include="Extra Forms\EZ_Base.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Extra Forms\EZ_Base.Designer.cs">
<DependentUpon>EZ_Base.cs</DependentUpon>
</Compile>
<Compile Include="Extra Forms\EZCard_Editor.cs">
<SubType>Form</SubType>
</Compile>
Expand Down Expand Up @@ -132,15 +148,33 @@
<Compile Include="Extra Forms\UpdateChangelog.Designer.cs">
<DependentUpon>UpdateChangelog.cs</DependentUpon>
</Compile>
<Compile Include="JsonEditor_Instance.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="JsonEditor_Instance.Designer.cs">
<DependentUpon>JsonEditor_Instance.cs</DependentUpon>
</Compile>
<Compile Include="New_JsonEditor.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="New_JsonEditor.Designer.cs">
<DependentUpon>New_JsonEditor.cs</DependentUpon>
</Compile>
<Compile Include="ZipForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ZipForm.Designer.cs">
<DependentUpon>ZipForm.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="Extra Forms\BattlesPassManager.resx">
<DependentUpon>BattlesPassManager.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Extra Forms\BGForm.resx">
<DependentUpon>BGForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Extra Forms\EZ_Base.resx">
<DependentUpon>EZ_Base.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Extra Forms\EZCard_Editor.resx">
<DependentUpon>EZCard_Editor.cs</DependentUpon>
</EmbeddedResource>
Expand All @@ -165,6 +199,12 @@
<EmbeddedResource Include="Extra Forms\UpdateChangelog.resx">
<DependentUpon>UpdateChangelog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="JsonEditor_Instance.resx">
<DependentUpon>JsonEditor_Instance.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="New_JsonEditor.resx">
<DependentUpon>New_JsonEditor.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ZipForm.resx">
<DependentUpon>ZipForm.cs</DependentUpon>
</EmbeddedResource>
Expand Down
57 changes: 57 additions & 0 deletions BTDToolbox/Classes/BattlesPass_Class.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using BTDToolbox.Classes;
//
// var battlesPassClass = BattlesPassClass.FromJson(jsonString);

namespace BTDToolbox.Classes
{
using System;
using System.Collections.Generic;

using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

public partial class BattlesPassClass
{
[JsonProperty("Versions")]
public VersionElement[] Versions { get; set; }
}

public partial class VersionElement
{
[JsonProperty("Version")]
public VersionVersion Version { get; set; }
}

public partial class VersionVersion
{
[JsonProperty("version number")]
public string VersionNumber { get; set; }

[JsonProperty("Windows")]
public string Windows { get; set; }

[JsonProperty("Mac")]
public string Mac { get; set; }

[JsonProperty("Android")]
public string Android { get; set; }

[JsonProperty("IOS")]
public string Ios { get; set; }
}

public partial class BattlesPassClass
{
public static BattlesPassClass FromJson(string json) => JsonConvert.DeserializeObject<BattlesPassClass>(json, BTDToolbox.Classes.Converter.Settings);
}

public static class Serialize
{
public static string ToJson(this BattlesPassClass self) => JsonConvert.SerializeObject(self, BTDToolbox.Classes.Converter.Settings);
}
}
91 changes: 91 additions & 0 deletions BTDToolbox/Classes/JsonEditorHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BTDToolbox.Classes
{
class JsonEditorHandler
{
public static New_JsonEditor jeditor;

public static void ValidateEditor()
{
if (jeditor == null)
{
jeditor = new New_JsonEditor();
jeditor.tabPages = new List<TabPage>();
jeditor.tabFilePaths = new List<string>();
jeditor.userControls = new List<JsonEditor_Instance>();
jeditor.Show();
}
else if (jeditor.Visible == false)
{
jeditor.Show();
}
}
public static void OpenFile(string path)
{
if (Serializer.Deserialize_Config().useExternalEditor == false)
{
ValidateEditor();
if(jeditor.tabFilePaths.Contains(path))
{
jeditor.tabControl1.SelectedIndex = jeditor.tabFilePaths.IndexOf(path);
}
else
{
jeditor.NewTab(path);
}
}
}
public static void OpenOriginalFile(string path)
{
string[] split = path.Split('\\');
string filename = split[split.Length - 1];
string backupProj = "";
if (!path.Contains("\\Backups\\" + Main.gameName + "_BackupProject\\"))
backupProj = Environment.CurrentDirectory + "\\Backups\\" + Main.gameName + "_BackupProject\\" + path.Replace(Environment.CurrentDirectory, "").Replace(Serializer.Deserialize_Config().LastProject + "\\", "");
else
{
backupProj = path;
if(jeditor.tabControl1.SelectedTab.Text == filename + New_JsonEditor.readOnlyName)
ConsoleHandler.appendNotice("You are already looking at the original " + filename.Replace(New_JsonEditor.readOnlyName, ""));
}

if (File.Exists(backupProj))
OpenFile(backupProj);
else
ConsoleHandler.appendLog_CanRepeat("Could not find file in backup project... Unable to view original file");
}
public static void CloseFile(string path)
{
jeditor.CloseTab(path);
}
public static bool AreJsonErrors()
{
if(jeditor != null)
{
int i = 0;
bool isError = false;
foreach (var u in jeditor.userControls)
{
if (u.jsonError)
{
isError = true;
jeditor.tabControl1.SelectedIndex = i;
break;
}
i++;
}
if (isError)
return true;
}
return false;
}
}
}
2 changes: 2 additions & 0 deletions BTDToolbox/Classes/ProjectConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class ConfigFile
public bool recentUpdate { get; set; }
public bool useExternalEditor { get; set; }
public string battlesPass { get; set; }
public bool disableUpdates { get; set; }


//Project wide variables
Expand Down Expand Up @@ -60,6 +61,7 @@ public class ConfigFile
public int JSON_Editor_PosX { get; set; }
public int JSON_Editor_PosY { get; set; }
public float JSON_Editor_FontSize { get; set; }
public List<string> JsonEditor_OpenedTabs { get; set; }
}
}
}
39 changes: 36 additions & 3 deletions BTDToolbox/Classes/SerializeOps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using static BTDToolbox.ProjectConfig;
using static BTDToolbox.Main;
using static BTDToolbox.JetForm;
using BTDToolbox.Classes;

namespace BTDToolbox
{
Expand All @@ -35,19 +36,49 @@ public static void SaveSmallSettings(string formName, ConfigFile serialize_confi
{
cfg.battlesPass = ZipForm.rememberedPassword;
}
if (formName == "disableUpdates")
{
cfg.disableUpdates = Main.disableUpdates;
}
string output_Cfg = JsonConvert.SerializeObject(cfg, Formatting.Indented);

StreamWriter serialize = new StreamWriter(Environment.CurrentDirectory + "\\settings.json", false);
serialize.Write(output_Cfg);
serialize.Close();
}
public static void SaveJSONEditor_Instance(JsonEditor_Instance jeditor, ConfigFile serialize_config)
{
var cfg = Serializer.Deserialize_Config();
if(jeditor!= null)
{
cfg.JSON_Editor_FontSize = jeditor.Editor_TextBox.Font.Size;
string output_Cfg = JsonConvert.SerializeObject(cfg, Formatting.Indented);

StreamWriter serialize = new StreamWriter(Environment.CurrentDirectory + "\\settings.json", false);
serialize.Write(output_Cfg);
serialize.Close();
}
}
public static void SaveJSONEditor_Tabs(ConfigFile cfg)
{
if (JsonEditorHandler.jeditor != null)
{
cfg.JsonEditor_OpenedTabs = JsonEditorHandler.jeditor.tabFilePaths;
}
else
cfg.JsonEditor_OpenedTabs = new List<string>();

string output_Cfg = JsonConvert.SerializeObject(cfg, Formatting.Indented);

StreamWriter serialize = new StreamWriter(Environment.CurrentDirectory + "\\settings.json", false);
serialize.Write(output_Cfg);
serialize.Close();
}

public static void SaveConfig(Form frm, string formName, ConfigFile serialize_config)
{
var cfg = Serializer.Deserialize_Config();



if (formName == "game")
{
cfg.CurrentGame = gameName;
Expand Down Expand Up @@ -108,7 +139,6 @@ public static void SaveConfig(Form frm, string formName, ConfigFile serialize_co
cfg.JSON_Editor_SizeY = frm.Size.Height;
cfg.JSON_Editor_PosX = frm.Location.X;
cfg.JSON_Editor_PosY = frm.Location.Y;
cfg.JSON_Editor_FontSize = JsonEditor.jsonEditorFont;//frm.Font.Size;
}

if (formName == "updater")
Expand Down Expand Up @@ -140,6 +170,9 @@ public static ConfigFile Deserialize_Config()
programData.enableSplash = true;
programData.recentUpdate = false;
programData.useExternalEditor = false;
programData.disableUpdates = false;

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


programData.BTD5_Directory = "";
Expand Down
Loading

0 comments on commit 8c23a3a

Please sign in to comment.