This commit is contained in:
Bitl 2019-10-11 11:03:30 -07:00
parent aef3b56f4b
commit 77d03c9649
10 changed files with 1209 additions and 1041 deletions

View File

@ -8,7 +8,7 @@
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<RootNamespace>NovetusCMD</RootNamespace> <RootNamespace>NovetusCMD</RootNamespace>
<AssemblyName>NovetusCMD</AssemblyName> <AssemblyName>NovetusCMD</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<NoWin32Manifest>False</NoWin32Manifest> <NoWin32Manifest>False</NoWin32Manifest>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
@ -17,6 +17,7 @@
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath> <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<ApplicationIcon>Resources\NovetusIcon.ico</ApplicationIcon> <ApplicationIcon>Resources\NovetusIcon.ico</ApplicationIcon>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' "> <PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
@ -43,6 +44,12 @@
<DefineConstants>TRACE;NOVETUS_APPS</DefineConstants> <DefineConstants>TRACE;NOVETUS_APPS</DefineConstants>
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath> <BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.CSharp"> <Reference Include="Microsoft.CSharp">
<RequiredTargetFramework>4.0</RequiredTargetFramework> <RequiredTargetFramework>4.0</RequiredTargetFramework>
@ -59,6 +66,8 @@
<RequiredTargetFramework>3.5</RequiredTargetFramework> <RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq"> <Reference Include="System.Xml.Linq">

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup> </startup>
</configuration> </configuration>

View File

@ -0,0 +1,73 @@
using System;
using System.IO;
using System.Windows.Forms;
using System.IO.Compression;
using System.Linq;
public class AddonLoader
{
private OpenFileDialog openFileDialog1;
public string installOutcome = "";
public int fileListDisplay = 0;
public AddonLoader()
{
openFileDialog1 = new OpenFileDialog()
{
FileName = "Select an addon .zip file",
Filter = "Compressed zip files (*.zip)|*.zip",
Title = "Open addon .zip"
};
}
public void LoadAddon()
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
try
{
int filecount = 0;
string filelist = "";
using (Stream str = openFileDialog1.OpenFile())
{
using (ZipArchive archive = new ZipArchive(str))
{
filecount = archive.Entries.Count;
ZipArchiveEntry[] entries = archive.Entries.Take(fileListDisplay).ToArray();
foreach (ZipArchiveEntry entry in entries)
{
filelist += entry.FullName + Environment.NewLine;
}
archive.ExtractToDirectory(GlobalVars.BasePath, true);
}
}
if (filecount > fileListDisplay)
{
installOutcome = "Addon " + openFileDialog1.SafeFileName + " installed! " + filecount + " files copied!" + Environment.NewLine + "Files added/modified:" + Environment.NewLine + Environment.NewLine + filelist + Environment.NewLine + "and " + (filecount - fileListDisplay) + " more files!";
}
else
{
installOutcome = "Addon " + openFileDialog1.SafeFileName + " installed! " + filecount + " files copied!" + Environment.NewLine + "Files added/modified:" + Environment.NewLine + Environment.NewLine + filelist;
}
}
catch (Exception ex)
{
installOutcome = "Error when installing addon: " + ex.Message;
}
}
}
void CopyStream(Stream source, Stream dest)
{
int n;
var buf = new byte[2048];
while ((n = source.Read(buf, 0, buf.Length)) > 0)
{
dest.Write(buf, 0, n);
}
}
}

View File

@ -11,6 +11,8 @@ using System;
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using System.Diagnostics; using System.Diagnostics;
using System.IO.Compression;
using System.IO;
public static class RichTextBoxExtensions public static class RichTextBoxExtensions
{ {
@ -49,3 +51,35 @@ public static class StringExtensions
return source.IndexOf(toCheck, comp) >= 0; return source.IndexOf(toCheck, comp) >= 0;
} }
} }
public static class ZipArchiveExtensions
{
public static void ExtractToDirectory(this ZipArchive archive, string destinationDirectoryName, bool overwrite)
{
if (!overwrite)
{
archive.ExtractToDirectory(destinationDirectoryName);
return;
}
DirectoryInfo di = Directory.CreateDirectory(destinationDirectoryName);
string destinationDirectoryFullPath = di.FullName;
foreach (ZipArchiveEntry file in archive.Entries)
{
string completeFileName = Path.GetFullPath(Path.Combine(destinationDirectoryFullPath, file.FullName));
if (!completeFileName.StartsWith(destinationDirectoryFullPath, StringComparison.OrdinalIgnoreCase))
{
throw new IOException("Trying to extract file outside of destination directory. See this link for more info: https://snyk.io/research/zip-slip-vulnerability");
}
if (file.Name == "")
{// Assuming Empty for Directory
Directory.CreateDirectory(Path.GetDirectoryName(completeFileName));
continue;
}
file.ExtractToFile(completeFileName, true);
}
}
}

View File

@ -9,6 +9,7 @@
<Import_RootNamespace>NovetusFuncs</Import_RootNamespace> <Import_RootNamespace>NovetusFuncs</Import_RootNamespace>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)AddonLoader.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ClientScript.cs" /> <Compile Include="$(MSBuildThisFileDirectory)ClientScript.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CodeExtensions.cs" /> <Compile Include="$(MSBuildThisFileDirectory)CodeExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CryptoRandom.cs" /> <Compile Include="$(MSBuildThisFileDirectory)CryptoRandom.cs" />

View File

@ -91,6 +91,7 @@ namespace NovetusLauncher
this.tabPage8 = new System.Windows.Forms.TabPage(); this.tabPage8 = new System.Windows.Forms.TabPage();
this.richTextBox2 = new System.Windows.Forms.RichTextBox(); this.richTextBox2 = new System.Windows.Forms.RichTextBox();
this.tabPage5 = new System.Windows.Forms.TabPage(); this.tabPage5 = new System.Windows.Forms.TabPage();
this.label7 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label(); this.label9 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label();
@ -116,7 +117,8 @@ namespace NovetusLauncher
this.label11 = new System.Windows.Forms.Label(); this.label11 = new System.Windows.Forms.Label();
this.label12 = new System.Windows.Forms.Label(); this.label12 = new System.Windows.Forms.Label();
this.label16 = new System.Windows.Forms.Label(); this.label16 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label(); this.label18 = new System.Windows.Forms.Label();
this.button25 = new System.Windows.Forms.Button();
this.tabControl1.SuspendLayout(); this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout(); this.tabPage1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
@ -755,6 +757,8 @@ namespace NovetusLauncher
// //
// tabPage5 // tabPage5
// //
this.tabPage5.Controls.Add(this.button25);
this.tabPage5.Controls.Add(this.label18);
this.tabPage5.Controls.Add(this.label7); this.tabPage5.Controls.Add(this.label7);
this.tabPage5.Controls.Add(this.label10); this.tabPage5.Controls.Add(this.label10);
this.tabPage5.Controls.Add(this.label9); this.tabPage5.Controls.Add(this.label9);
@ -773,6 +777,14 @@ namespace NovetusLauncher
this.tabPage5.Text = "SETTINGS"; this.tabPage5.Text = "SETTINGS";
this.tabPage5.UseVisualStyleBackColor = true; this.tabPage5.UseVisualStyleBackColor = true;
// //
// label7
//
this.label7.Location = new System.Drawing.Point(274, 237);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(121, 19);
this.label7.TabIndex = 54;
this.label7.Text = "PROJECT STARLIGHT";
//
// label10 // label10
// //
this.label10.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.label10.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
@ -811,9 +823,9 @@ namespace NovetusLauncher
// //
// button21 // button21
// //
this.button21.Location = new System.Drawing.Point(74, 26); this.button21.Location = new System.Drawing.Point(12, 3);
this.button21.Name = "button21"; this.button21.Name = "button21";
this.button21.Size = new System.Drawing.Size(87, 30); this.button21.Size = new System.Drawing.Size(77, 19);
this.button21.TabIndex = 44; this.button21.TabIndex = 44;
this.button21.Text = "Install URI"; this.button21.Text = "Install URI";
this.button21.UseVisualStyleBackColor = true; this.button21.UseVisualStyleBackColor = true;
@ -830,17 +842,17 @@ namespace NovetusLauncher
// button9 // button9
// //
this.button9.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.button9.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button9.Location = new System.Drawing.Point(274, 26); this.button9.Location = new System.Drawing.Point(355, 19);
this.button9.Name = "button9"; this.button9.Name = "button9";
this.button9.Size = new System.Drawing.Size(83, 30); this.button9.Size = new System.Drawing.Size(43, 29);
this.button9.TabIndex = 37; this.button9.TabIndex = 37;
this.button9.Text = "Reset Config"; this.button9.Text = "Reset";
this.button9.UseVisualStyleBackColor = true; this.button9.UseVisualStyleBackColor = true;
this.button9.Click += new System.EventHandler(this.Button9Click); this.button9.Click += new System.EventHandler(this.Button9Click);
// //
// checkBox3 // checkBox3
// //
this.checkBox3.Location = new System.Drawing.Point(238, 3); this.checkBox3.Location = new System.Drawing.Point(119, 25);
this.checkBox3.Name = "checkBox3"; this.checkBox3.Name = "checkBox3";
this.checkBox3.Size = new System.Drawing.Size(114, 19); this.checkBox3.Size = new System.Drawing.Size(114, 19);
this.checkBox3.TabIndex = 22; this.checkBox3.TabIndex = 22;
@ -852,7 +864,7 @@ namespace NovetusLauncher
// //
this.checkBox1.Checked = true; this.checkBox1.Checked = true;
this.checkBox1.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBox1.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBox1.Location = new System.Drawing.Point(50, 4); this.checkBox1.Location = new System.Drawing.Point(119, 3);
this.checkBox1.Name = "checkBox1"; this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(182, 17); this.checkBox1.Size = new System.Drawing.Size(182, 17);
this.checkBox1.TabIndex = 5; this.checkBox1.TabIndex = 5;
@ -864,11 +876,11 @@ namespace NovetusLauncher
// button5 // button5
// //
this.button5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.button5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button5.Location = new System.Drawing.Point(191, 26); this.button5.Location = new System.Drawing.Point(307, 19);
this.button5.Name = "button5"; this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(77, 30); this.button5.Size = new System.Drawing.Size(42, 29);
this.button5.TabIndex = 10; this.button5.TabIndex = 10;
this.button5.Text = "Save Config"; this.button5.Text = "Save";
this.button5.UseVisualStyleBackColor = true; this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.Button5Click); this.button5.Click += new System.EventHandler(this.Button5Click);
// //
@ -1011,13 +1023,24 @@ namespace NovetusLauncher
this.label16.Size = new System.Drawing.Size(2, 65); this.label16.Size = new System.Drawing.Size(2, 65);
this.label16.TabIndex = 51; this.label16.TabIndex = 51;
// //
// label7 // label18
// //
this.label7.Location = new System.Drawing.Point(274, 237); this.label18.AutoSize = true;
this.label7.Name = "label7"; this.label18.Location = new System.Drawing.Point(334, 3);
this.label7.Size = new System.Drawing.Size(121, 19); this.label18.Name = "label18";
this.label7.TabIndex = 54; this.label18.Size = new System.Drawing.Size(37, 13);
this.label7.Text = "PROJECT STARLIGHT"; this.label18.TabIndex = 55;
this.label18.Text = "Config";
//
// button25
//
this.button25.Location = new System.Drawing.Point(13, 24);
this.button25.Name = "button25";
this.button25.Size = new System.Drawing.Size(76, 19);
this.button25.TabIndex = 56;
this.button25.Text = "Install Addon";
this.button25.UseVisualStyleBackColor = true;
this.button25.Click += new System.EventHandler(this.button25_Click);
// //
// MainForm // MainForm
// //
@ -1064,6 +1087,7 @@ namespace NovetusLauncher
this.tabPage7.ResumeLayout(false); this.tabPage7.ResumeLayout(false);
this.tabPage8.ResumeLayout(false); this.tabPage8.ResumeLayout(false);
this.tabPage5.ResumeLayout(false); this.tabPage5.ResumeLayout(false);
this.tabPage5.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -1150,5 +1174,7 @@ namespace NovetusLauncher
private System.Windows.Forms.TabControl tabControl1; private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TreeView _fieldsTreeCache; private System.Windows.Forms.TreeView _fieldsTreeCache;
private System.Windows.Forms.Button button24; private System.Windows.Forms.Button button24;
private System.Windows.Forms.Button button25;
private System.Windows.Forms.Label label18;
} }
} }

View File

@ -1473,5 +1473,22 @@ namespace NovetusLauncher
treeView1.SelectedNode = TreeNodeHelper.SearchTreeView(GlobalVars.Map, treeView1.Nodes); treeView1.SelectedNode = TreeNodeHelper.SearchTreeView(GlobalVars.Map, treeView1.Nodes);
treeView1.Focus(); treeView1.Focus();
} }
private void button25_Click(object sender, EventArgs e)
{
AddonLoader addon = new AddonLoader();
addon.fileListDisplay = 10;
try
{
addon.LoadAddon();
ConsolePrint("AddonLoader - " + addon.installOutcome, 3);
}
catch (Exception)
{
ConsolePrint("AddonLoader - " + addon.installOutcome, 2);
}
MessageBox.Show(addon.installOutcome);
}
} }
} }

View File

@ -7,7 +7,7 @@
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<RootNamespace>NovetusLauncher</RootNamespace> <RootNamespace>NovetusLauncher</RootNamespace>
<AssemblyName>Novetus</AssemblyName> <AssemblyName>Novetus</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile> <TargetFrameworkProfile>
</TargetFrameworkProfile> </TargetFrameworkProfile>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
@ -48,6 +48,12 @@
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath> <BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
<StartAction>Project</StartAction> <StartAction>Project</StartAction>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Mono.Nat"> <Reference Include="Mono.Nat">
<HintPath>..\packages\Mono.Nat.1.2.24.0\lib\net40\Mono.Nat.dll</HintPath> <HintPath>..\packages\Mono.Nat.1.2.24.0\lib\net40\Mono.Nat.dll</HintPath>
@ -61,6 +67,8 @@
<RequiredTargetFramework>3.5</RequiredTargetFramework> <RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq"> <Reference Include="System.Xml.Linq">

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup> </startup>
</configuration> </configuration>