Skip to content

Commit

Permalink
Changed how program worked to fix licence issue with converter.
Browse files Browse the repository at this point in the history
  • Loading branch information
WesternGamer committed Oct 31, 2021
1 parent 4b9c1b9 commit ed0a239
Show file tree
Hide file tree
Showing 18 changed files with 481 additions and 56 deletions.
2 changes: 1 addition & 1 deletion RDR2TextureToolPackage/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Identity
Name="RDR2TextureToolPackage"
Publisher="CN=WesternGamer"
Version="1.0.1.0" />
Version="1.1.0.0" />

<Properties>
<DisplayName>RDR2 Texture Tool</DisplayName>
Expand Down
3 changes: 1 addition & 2 deletions Tools/TextureTool/App.xaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<Application x:Class="TextureTool.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:TextureTool"
StartupUri="Views/MainView.xaml">
xmlns:local="clr-namespace:TextureTool">
<Application.Resources>

</Application.Resources>
Expand Down
17 changes: 17 additions & 0 deletions Tools/TextureTool/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,28 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

using RDR2TextureTool.Views;
using System.Windows;
using TextureTool.Utill.Config;
using TextureTool.Views;

namespace TextureTool
{
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
if (XMLReader.IsFirstStartUp)
{
FirstStartupView firstStartupView = new FirstStartupView();
firstStartupView.Show();
}
else
{
MainView mainView = new MainView();
mainView.Show();
}
}
}
}
23 changes: 23 additions & 0 deletions Tools/TextureTool/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using TextureTool;
using TextureTool.Utill;
using TextureTool.Utill.Config;


namespace RDR2TextureTool
{
public class Program
{
[STAThread]
static void Main(string[] args)
{
FileSystem.Init();
XMLWriter.Init();
XMLReader.Init();

App app = new App();
app.InitializeComponent();
app.Run();
}
}
}
4 changes: 2 additions & 2 deletions Tools/TextureTool/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
54 changes: 34 additions & 20 deletions Tools/TextureTool/RDR2TextureTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject>TextureTool.App</StartupObject>
<StartupObject>RDR2TextureTool.Program</StartupObject>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
Expand All @@ -80,10 +80,15 @@
<ApplicationIcon>favicon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Ookii.Dialogs.Wpf, Version=4.0.0.0, Culture=neutral, PublicKeyToken=66aa232afad40158, processorArchitecture=MSIL">
<HintPath>..\..\packages\Ookii.Dialogs.Wpf.4.0.0\lib\net45\Ookii.Dialogs.Wpf.dll</HintPath>
</Reference>
<Reference Include="PresentationFramework.Aero2" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.Security" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
Expand All @@ -98,14 +103,18 @@
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Page Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Utill\Config\XMLReader.cs" />
<Compile Include="Utill\Config\XMLWriter.cs" />
<Compile Include="Utill\FileSystem.cs" />
<Compile Include="Models\RgbaBitmapSource.cs" />
<Compile Include="Models\TextureDictionaryModel.cs" />
<Compile Include="Models\TextureModel.cs" />
Expand All @@ -116,9 +125,18 @@
<Compile Include="Views\AboutView.xaml.cs">
<DependentUpon>AboutView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Pages\FirstStartupPart1.xaml.cs">
<DependentUpon>FirstStartupPart1.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Pages\FirstStartupPart2.xaml.cs">
<DependentUpon>FirstStartupPart2.xaml</DependentUpon>
</Compile>
<Compile Include="Views\MainView.xaml.cs">
<DependentUpon>MainView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\FirstStartupView.xaml.cs">
<DependentUpon>FirstStartupView.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Commands\ActionCommand.cs" />
Expand All @@ -130,12 +148,7 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="Converter\CitiCon.com">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Converter\components.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
<None Include="Properties\app.manifest" />
<None Include="RDR2TextureTool_TemporaryKey.pfx" />
</ItemGroup>
Expand All @@ -144,10 +157,22 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Pages\FirstStartupPart1.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Pages\FirstStartupPart2.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\MainView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\FirstStartupView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5">
Expand Down Expand Up @@ -199,17 +224,6 @@
<ItemGroup>
<Resource Include="favicon.ico" />
</ItemGroup>
<ItemGroup>
<Content Include="Converter\CoreRT.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Converter\rage-formats-x.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Converter\tool-formats.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
67 changes: 67 additions & 0 deletions Tools/TextureTool/Utill/Config/XMLReader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
Copyright(c) 2021 WesternGamer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
using System.Xml;

namespace TextureTool.Utill.Config
{
internal class XMLReader
{
public static bool IsFirstStartUp;
public static string ConverterDirectory;

public static void Init()
{
using (XmlReader reader = XmlReader.Create(FileSystem.RootFolderPath + "\\config.xml"))
{
while (reader.Read())
{
if (reader.IsStartElement())
{
//return only when you have START tag
switch (reader.Name.ToString())
{
case "IsFirstStartUp":
IsFirstStartUp = ConvertStringToBool(reader.ReadString());
break;
case "ConverterDirectory":
ConverterDirectory = reader.ReadString();
break;
}
}
}
}
}

private static bool ConvertStringToBool(string str)
{
if (str == "true")
{
return true;
}
if (str == "false")
{
return false;
}
return false;
}
}
}
62 changes: 62 additions & 0 deletions Tools/TextureTool/Utill/Config/XMLWriter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
Copyright(c) 2021 WesternGamer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
using System.IO;
using System.Xml;

namespace TextureTool.Utill.Config
{
internal class XMLWriter
{
public static void Init()
{
if (Directory.GetFiles(FileSystem.RootFolderPath, "config.xml").Length == 0)
{
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.IndentChars = (" ");
settings.CloseOutput = true;
settings.OmitXmlDeclaration = true;
using (XmlWriter writer = XmlWriter.Create(FileSystem.RootFolderPath + "\\config.xml", settings))
{
writer.WriteStartElement("Config");
writer.WriteElementString("IsFirstStartUp", "true");
writer.WriteElementString("ConverterDirectory", "");
writer.WriteEndElement();
writer.Flush();
}
}
}

public static void WriteXMLEntry(string IsFirstStartUpData, string ConverterDirectoryData)
{
XmlTextWriter textWriter = new XmlTextWriter(FileSystem.RootFolderPath + "\\config.xml", null);
textWriter.WriteStartDocument();
textWriter.WriteStartElement("Config");
textWriter.WriteElementString("IsFirstStartUp", IsFirstStartUpData);
textWriter.WriteElementString("ConverterDirectory", ConverterDirectoryData);
textWriter.WriteEndElement();
textWriter.WriteEndDocument();
textWriter.Close();

}
}
}
39 changes: 39 additions & 0 deletions Tools/TextureTool/Utill/FileSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Copyright(c) 2021 WesternGamer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
using System;
using System.IO;

namespace TextureTool.Utill
{
internal class FileSystem
{
public static string RootFolderPath;
public static readonly string UserDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

public static void Init()
{
RootFolderPath = Path.Combine(UserDataPath, "RDR2TextureToolKit");
if (!Directory.Exists(RootFolderPath))
Directory.CreateDirectory(RootFolderPath);
}
}
}
Loading

0 comments on commit ed0a239

Please sign in to comment.