better color picker + updated dll + fixed non drawn zone on challenges

This commit is contained in:
Asval 2019-08-04 00:47:53 +02:00
parent 1440c67b78
commit ac40a8c41c
10 changed files with 143 additions and 117 deletions

View File

@ -88,11 +88,14 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>DLLs\csharp-wick.dll</HintPath>
</Reference>
<Reference Include="Cyotek.Windows.Forms.ColorPicker, Version=1.0.0.0, Culture=neutral, PublicKeyToken=58daa28b0b2de221, processorArchitecture=MSIL">
<HintPath>..\packages\Cyotek.Windows.Forms.ColorPicker.1.7.2\lib\net35\Cyotek.Windows.Forms.ColorPicker.dll</HintPath>
</Reference>
<Reference Include="Hammock.ClientProfile, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c148cfba29ed1a4d, processorArchitecture=MSIL">
<HintPath>..\packages\TweetMoaSharp.6.0.0\lib\4.5\Hammock.ClientProfile.dll</HintPath>
</Reference>
<Reference Include="HtmlAgilityPack, Version=1.11.10.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
<HintPath>..\packages\HtmlAgilityPack.1.11.10\lib\Net45\HtmlAgilityPack.dll</HintPath>
<Reference Include="HtmlAgilityPack, Version=1.11.12.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
<HintPath>..\packages\HtmlAgilityPack.1.11.12\lib\Net45\HtmlAgilityPack.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>
@ -156,6 +159,7 @@
<Compile Include="Methods\IconGenerator\Translations\LoadLocRes.cs" />
<Compile Include="Methods\IconGenerator\Translations\SearchResource.cs" />
<Compile Include="Methods\ImagesMerger\ImagesMerger.cs" />
<Compile Include="Methods\PakHelper\CreateBackup.cs" />
<Compile Include="Methods\PakHelper\PakHelper.cs" />
<Compile Include="Methods\Serializer\AssetReader.cs" />
<Compile Include="Methods\Serializer\LocRes\LocResSerializer.cs" />

View File

@ -4,6 +4,7 @@ using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.IO;
using System.Windows.Forms;
using Cyotek.Windows.Forms;
using FModel.Properties;
namespace FModel.Forms
@ -20,11 +21,11 @@ namespace FModel.Forms
public Settings()
{
InitializeComponent();
// Check if watermark exists
Utilities.CheckWatermark();
InitializeComponent();
textBox2.Text = Properties.Settings.Default.PAKsPath;
textBox1.Text = Properties.Settings.Default.ExtractOutput;
@ -55,6 +56,7 @@ namespace FModel.Forms
trackBar1.Value = Properties.Settings.Default.wOpacity;
trackBar2.Value = Properties.Settings.Default.wSize;
//CHALLENGES
button3.Enabled = Properties.Settings.Default.isChallengesTheme;
button4.Enabled = Properties.Settings.Default.isChallengesTheme;
checkBox2.Checked = Properties.Settings.Default.isChallengesTheme;
@ -116,6 +118,7 @@ namespace FModel.Forms
MessageBox.Show(@"Please, restart FModel to apply your new output path", @"FModel Output Path Changed", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
//CHALLENGES
Properties.Settings.Default.challengesWatermark = textBox6.Text;
Properties.Settings.Default.isChallengesTheme = checkBox2.Checked;
Properties.Settings.Default.challengesOpacity = trackBar3.Value;
@ -310,9 +313,7 @@ namespace FModel.Forms
private void Button4_Click(object sender, EventArgs e)
{
ColorDialog MyDialog = new ColorDialog();
MyDialog.FullOpen = true;
MyDialog.AnyColor = true;
ColorPickerDialog MyDialog = new ColorPickerDialog();
if (MyDialog.ShowDialog() == DialogResult.OK)
{

View File

@ -15,11 +15,11 @@ namespace FModel.Forms
public UpdateModeSettings()
{
InitializeComponent();
// Check if watermark exists
Utilities.CheckWatermark();
InitializeComponent();
if (!string.IsNullOrEmpty(Properties.Settings.Default.UMParameters))
{
parameters = Properties.Settings.Default.UMParameters.Split(',');

View File

@ -19,7 +19,6 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Image = System.Drawing.Image;
using Settings = FModel.Properties.Settings;
using System.Text;
namespace FModel
{
@ -31,12 +30,12 @@ namespace FModel
public MainWindow()
{
// Check if watermark exists
Utilities.CheckWatermark();
InitializeComponent();
App.MainFormToUse = this;
// Check if watermark exists
Utilities.CheckWatermark();
//FModel version
toolStripStatusLabel1.Text += @" " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString().Substring(0, 5);
@ -468,86 +467,7 @@ namespace FModel
}
}
}
private void CreateBackupList()
{
PakExtractor extractor = null;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < ThePak.mainPaksList.Count; i++)
{
try
{
extractor = new PakExtractor(Settings.Default.PAKsPath + "\\" + ThePak.mainPaksList[i].thePak, Settings.Default.AESKey);
}
catch (Exception)
{
new UpdateMyConsole("0x" + Settings.Default.AESKey + " doesn't work with the main paks.", Color.Red, true).AppendToConsole();
extractor.Dispose();
break;
}
string[] CurrentUsedPakLines = extractor.GetFileList().ToArray();
if (CurrentUsedPakLines != null)
{
string mountPoint = extractor.GetMountPoint();
for (int ii = 0; ii < CurrentUsedPakLines.Length; ii++)
{
CurrentUsedPakLines[ii] = mountPoint.Substring(9) + CurrentUsedPakLines[ii];
sb.Append(CurrentUsedPakLines[ii] + "\n");
}
new UpdateMyState(".PAK mount point: " + mountPoint.Substring(9), "Waiting").ChangeProcessState();
}
extractor.Dispose();
}
for (int i = 0; i < ThePak.dynamicPaksList.Count; i++)
{
string pakName = DynamicKeysManager.AESEntries.Where(x => x.thePak == ThePak.dynamicPaksList[i].thePak).Select(x => x.thePak).FirstOrDefault();
string pakKey = DynamicKeysManager.AESEntries.Where(x => x.thePak == ThePak.dynamicPaksList[i].thePak).Select(x => x.theKey).FirstOrDefault();
if (!string.IsNullOrEmpty(pakName) && !string.IsNullOrEmpty(pakKey))
{
try
{
extractor = new PakExtractor(Settings.Default.PAKsPath + "\\" + pakName, pakKey);
}
catch (Exception)
{
new UpdateMyConsole("0x" + pakKey + " doesn't work with " + ThePak.dynamicPaksList[i].thePak, Color.Red, true).AppendToConsole();
extractor.Dispose();
continue;
}
string[] CurrentUsedPakLines = extractor.GetFileList().ToArray();
if (CurrentUsedPakLines != null)
{
string mountPoint = extractor.GetMountPoint();
for (int ii = 0; ii < CurrentUsedPakLines.Length; ii++)
{
CurrentUsedPakLines[ii] = mountPoint.Substring(9) + CurrentUsedPakLines[ii];
sb.Append(CurrentUsedPakLines[ii] + "\n");
}
new UpdateMyConsole("Backing up ", Color.Black).AppendToConsole();
new UpdateMyConsole(ThePak.dynamicPaksList[i].thePak, Color.DarkRed, true).AppendToConsole();
}
extractor.Dispose();
}
}
File.WriteAllText(App.DefaultOutputPath + "\\Backup" + Checking.BackupFileName, sb.ToString()); //File will always exist so we check the file size instead
if (new System.IO.FileInfo(App.DefaultOutputPath + "\\Backup" + Checking.BackupFileName).Length > 0)
{
new UpdateMyState("\\Backup" + Checking.BackupFileName + " successfully created", "Success").ChangeProcessState();
}
else
{
File.Delete(App.DefaultOutputPath + "\\Backup" + Checking.BackupFileName);
new UpdateMyState("Can't create " + Checking.BackupFileName.Substring(1), "Error").ChangeProcessState();
}
}
private void UpdateModeExtractSave()
private void UpdateModeHereWeGooooo()
{
// Check if watermark exists
Utilities.CheckWatermark();
@ -608,14 +528,14 @@ namespace FModel
if (differenceModeToolStripMenuItem.Checked && updateModeToolStripMenuItem.Checked)
{
await Task.Run(() => {
UpdateModeExtractSave();
UpdateModeHereWeGooooo();
});
}
}
private async void backupPAKsToolStripMenuItem_Click(object sender, EventArgs e)
{
await Task.Run(() => {
CreateBackupList();
CreateBackup.CreateBackupList();
});
}
@ -664,18 +584,6 @@ namespace FModel
#region FILL LISTBOX & FILTER
//METHODS
public static IEnumerable<TItem> GetAncestors<TItem>(TItem item, Func<TItem, TItem> getParentFunc)
{
if (getParentFunc == null)
{
throw new ArgumentNullException("getParentFunc");
}
if (ReferenceEquals(item, null)) yield break;
for (TItem curItem = getParentFunc(item); !ReferenceEquals(curItem, null); curItem = getParentFunc(curItem))
{
yield return curItem;
}
}
private void GetFilesAndFill(TreeNodeMouseClickEventArgs selectedNode)
{
List<string> itemsNotToDisplay = new List<string>();
@ -687,7 +595,7 @@ namespace FModel
FilterTextBox.Text = string.Empty;
}));
var all = GetAncestors(selectedNode.Node, x => x.Parent).ToList();
var all = Utilities.GetAncestors(selectedNode.Node, x => x.Parent).ToList();
all.Reverse();
var full = string.Join("/", all.Select(x => x.Text)) + "/" + selectedNode.Node.Text + "/";
if (string.IsNullOrEmpty(full))
@ -1400,7 +1308,7 @@ namespace FModel
FilterTextBox.Text = string.Empty;
}));
var all = GetAncestors(node, x => x.Parent).ToList();
var all = Utilities.GetAncestors(node, x => x.Parent).ToList();
all.Reverse();
var full = string.Join("/", all.Select(x => x.Text)) + "/" + node.Text + "/";
if (string.IsNullOrEmpty(full))

View File

@ -79,7 +79,7 @@ namespace FModel
challengeIcon = new Bitmap(bmpTemp);
}
toDrawOn.FillRectangle(new SolidBrush(headerColor), new Rectangle(0, 0, myBitmap.Width, 256));
toDrawOn.FillRectangle(new SolidBrush(headerColor), new Rectangle(-1, -1, myBitmap.Width + 1, 257));
if (Settings.Default.isChallengesTheme)
{
if (File.Exists(Settings.Default.challengesBannerFileName))
@ -111,7 +111,7 @@ namespace FModel
challengeIcon = new Bitmap(bmpTemp);
}
toDrawOn.FillRectangle(new SolidBrush(headerColor), new Rectangle(0, 0, myBitmap.Width, 256));
toDrawOn.FillRectangle(new SolidBrush(headerColor), new Rectangle(-1, -1, myBitmap.Width + 1, 257));
if (Settings.Default.isChallengesTheme)
{
if (File.Exists(Settings.Default.challengesBannerFileName))
@ -127,7 +127,7 @@ namespace FModel
}
else
{
toDrawOn.FillRectangle(new SolidBrush(headerColor), new Rectangle(0, 0, myBitmap.Width, 256));
toDrawOn.FillRectangle(new SolidBrush(headerColor), new Rectangle(-1, -1, myBitmap.Width + 1, 257));
if (Settings.Default.isChallengesTheme)
{
if (File.Exists(Settings.Default.challengesBannerFileName))
@ -152,7 +152,7 @@ namespace FModel
headerColor = getRandomColor();
}
toDrawOn.FillRectangle(new SolidBrush(headerColor), new Rectangle(0, 0, myBitmap.Width, 256));
toDrawOn.FillRectangle(new SolidBrush(headerColor), new Rectangle(-1, -1, myBitmap.Width + 1, 257));
if (Settings.Default.isChallengesTheme)
{
if (File.Exists(Settings.Default.challengesBannerFileName))
@ -189,7 +189,7 @@ namespace FModel
toDrawOn.DrawString(bundleDisplayName, new Font(Settings.Default.IconLanguage == "Japanese" ? FontUtilities.pfc.Families[2] : FontUtilities.pfc.Families[1], 40), new SolidBrush(Color.White), new Point(isSXBanner || displayStyle == null ? 25 : 260, 105));
toDrawOn.FillRectangle(new SolidBrush(ControlPaint.Dark(headerColor, (float)0.1)), new Rectangle(0, 256, myBitmap.Width, myBitmap.Height));
toDrawOn.FillRectangle(new SolidBrush(ControlPaint.Dark(headerColor, (float)0.1)), new Rectangle(-1, 255, myBitmap.Width + 1, myBitmap.Height));
}
public static void drawQuestBackground(Bitmap myBitmap, bool noCompletion = true)

View File

@ -282,7 +282,7 @@ namespace FModel
myGraphic,
text,
Settings.Default.rarityNew ? new Rectangle(5, 405, 512, 55).Size : new Rectangle(5, 395, 512, 49).Size,
new Font(Settings.Default.IconLanguage == "Japanese" ? FontUtilities.pfc.Families[2] : Settings.Default.IconLanguage == "Russian" ? FontUtilities.pfc.Families[1] : FontUtilities.pfc.Families[0], 35)
new Font(Settings.Default.IconLanguage == "Japanese" ? FontUtilities.pfc.Families[2] : Settings.Default.IconLanguage == "Russian" || Settings.Default.IconLanguage == "Chinese (S)" ? FontUtilities.pfc.Families[1] : FontUtilities.pfc.Families[0], 35)
);
myGraphic.DrawString(
@ -442,7 +442,7 @@ namespace FModel
/// <param name="myGraphic"></param>
private static void DrawToLeft(string text, Graphics myGraphic)
{
myGraphic.DrawString(text, new Font(Settings.Default.IconLanguage == "Russian" ? FontUtilities.pfc.Families[1] : FontUtilities.pfc.Families[0], 11), new SolidBrush(Color.White), new Point(5, Settings.Default.IconLanguage == "Russian" ? 500 : 503));
myGraphic.DrawString(text, new Font(Settings.Default.IconLanguage == "Russian" || Settings.Default.IconLanguage == "Chinese (S)" ? FontUtilities.pfc.Families[1] : FontUtilities.pfc.Families[0], 11), new SolidBrush(Color.White), new Point(5, Settings.Default.IconLanguage == "Russian" || Settings.Default.IconLanguage == "Chinese (S)" ? 500 : 503));
}
/// <summary>

View File

@ -0,0 +1,93 @@
using csharp_wick;
using FModel.Properties;
using System;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
namespace FModel
{
static class CreateBackup
{
public static void CreateBackupList()
{
PakExtractor extractor = null;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < ThePak.mainPaksList.Count; i++)
{
try
{
extractor = new PakExtractor(Settings.Default.PAKsPath + "\\" + ThePak.mainPaksList[i].thePak, Settings.Default.AESKey);
}
catch (Exception)
{
new UpdateMyConsole("0x" + Settings.Default.AESKey + " doesn't work with the main paks.", Color.Red, true).AppendToConsole();
extractor.Dispose();
break;
}
string[] CurrentUsedPakLines = extractor.GetFileList().ToArray();
if (CurrentUsedPakLines != null)
{
string mountPoint = extractor.GetMountPoint();
for (int ii = 0; ii < CurrentUsedPakLines.Length; ii++)
{
CurrentUsedPakLines[ii] = mountPoint.Substring(9) + CurrentUsedPakLines[ii];
sb.Append(CurrentUsedPakLines[ii] + "\n");
}
new UpdateMyState(".PAK mount point: " + mountPoint.Substring(9), "Waiting").ChangeProcessState();
}
extractor.Dispose();
}
for (int i = 0; i < ThePak.dynamicPaksList.Count; i++)
{
string pakName = DynamicKeysManager.AESEntries.Where(x => x.thePak == ThePak.dynamicPaksList[i].thePak).Select(x => x.thePak).FirstOrDefault();
string pakKey = DynamicKeysManager.AESEntries.Where(x => x.thePak == ThePak.dynamicPaksList[i].thePak).Select(x => x.theKey).FirstOrDefault();
if (!string.IsNullOrEmpty(pakName) && !string.IsNullOrEmpty(pakKey))
{
try
{
extractor = new PakExtractor(Settings.Default.PAKsPath + "\\" + pakName, pakKey);
}
catch (Exception)
{
new UpdateMyConsole("0x" + pakKey + " doesn't work with " + ThePak.dynamicPaksList[i].thePak, Color.Red, true).AppendToConsole();
extractor.Dispose();
continue;
}
string[] CurrentUsedPakLines = extractor.GetFileList().ToArray();
if (CurrentUsedPakLines != null)
{
string mountPoint = extractor.GetMountPoint();
for (int ii = 0; ii < CurrentUsedPakLines.Length; ii++)
{
CurrentUsedPakLines[ii] = mountPoint.Substring(9) + CurrentUsedPakLines[ii];
sb.Append(CurrentUsedPakLines[ii] + "\n");
}
new UpdateMyConsole("Backing up ", Color.Black).AppendToConsole();
new UpdateMyConsole(ThePak.dynamicPaksList[i].thePak, Color.DarkRed, true).AppendToConsole();
}
extractor.Dispose();
}
}
File.WriteAllText(App.DefaultOutputPath + "\\Backup" + Checking.BackupFileName, sb.ToString()); //File will always exist so we check the file size instead
if (new System.IO.FileInfo(App.DefaultOutputPath + "\\Backup" + Checking.BackupFileName).Length > 0)
{
new UpdateMyState("\\Backup" + Checking.BackupFileName + " successfully created", "Success").ChangeProcessState();
}
else
{
File.Delete(App.DefaultOutputPath + "\\Backup" + Checking.BackupFileName);
new UpdateMyState("Can't create " + Checking.BackupFileName.Substring(1), "Error").ChangeProcessState();
}
}
}
}

View File

@ -7,6 +7,7 @@ using System.IO;
using System.Security.AccessControl;
using System.Security.Principal;
using System.Windows.Forms;
using System.Collections.Generic;
namespace FModel
{
@ -179,6 +180,7 @@ namespace FModel
{
Properties.Settings.Default.wFilename = string.Empty;
Properties.Settings.Default.isWatermark = false;
new UpdateMyConsole("Watermark file not found, watermarking disabled.", Color.Red, true).AppendToConsole();
}
if (!string.IsNullOrEmpty(Properties.Settings.Default.UMFilename) &&
@ -186,6 +188,7 @@ namespace FModel
{
Properties.Settings.Default.UMFilename = string.Empty;
Properties.Settings.Default.UMWatermark = false;
new UpdateMyConsole("Watermark file not found, watermarking in Update Mode disabled.", Color.Red, true).AppendToConsole();
}
if (!string.IsNullOrEmpty(Properties.Settings.Default.challengesBannerFileName) &&
@ -193,6 +196,22 @@ namespace FModel
{
Properties.Settings.Default.challengesBannerFileName = string.Empty;
Properties.Settings.Default.isChallengesTheme = false;
new UpdateMyConsole("Banner file not found, challenges custom theme disabled.", Color.Red, true).AppendToConsole();
}
Properties.Settings.Default.Save();
}
public static IEnumerable<TItem> GetAncestors<TItem>(TItem item, Func<TItem, TItem> getParentFunc)
{
if (getParentFunc == null)
{
throw new ArgumentNullException("getParentFunc");
}
if (ReferenceEquals(item, null)) yield break;
for (TItem curItem = getParentFunc(item); !ReferenceEquals(curItem, null); curItem = getParentFunc(curItem))
{
yield return curItem;
}
}
}

Binary file not shown.

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Autoupdater.NET.Official" version="1.5.4" targetFramework="net471" />
<package id="HtmlAgilityPack" version="1.11.10" targetFramework="net471" />
<package id="Cyotek.Windows.Forms.ColorPicker" version="1.7.2" targetFramework="net471" />
<package id="HtmlAgilityPack" version="1.11.12" targetFramework="net471" />
<package id="jacobslusser.ScintillaNET" version="3.6.3" targetFramework="net471" />
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net471" />
<package id="RestSharp" version="106.6.10" targetFramework="net471" />