fixed goto being called twice

This commit is contained in:
Asval
2019-06-01 16:06:44 +02:00
parent d524e38269
commit 218e384638
12 changed files with 176 additions and 135 deletions

View File

@@ -128,6 +128,7 @@
<Compile Include="Methods\ChallengeGenerator\DrawingRewards.cs" />
<Compile Include="Methods\DLLImport.cs" />
<Compile Include="Methods\ImagesMerger\ImagesMerger.cs" />
<Compile Include="Methods\Scintilla\MyScintilla.cs" />
<Compile Include="Methods\Utilities\FontUtilities.cs" />
<Compile Include="Methods\IconGenerator\ItemIcon.cs" />
<Compile Include="Methods\IconGenerator\Rarity.cs" />

View File

@@ -1,10 +1,5 @@
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Windows.Forms;
using FModel.Properties;
namespace FModel.Forms
{

View File

@@ -105,7 +105,7 @@
this.toolStripStatusLabel2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(200)))), ((int)(((byte)(200)))), ((int)(((byte)(200)))));
this.toolStripStatusLabel2.Margin = new System.Windows.Forms.Padding(0, 3, 50, 2);
this.toolStripStatusLabel2.Name = "toolStripStatusLabel2";
this.toolStripStatusLabel2.Size = new System.Drawing.Size(963, 17);
this.toolStripStatusLabel2.Size = new System.Drawing.Size(994, 17);
this.toolStripStatusLabel2.Spring = true;
//
// toolStripStatusLabel3
@@ -445,7 +445,6 @@
this.scintilla1.ScrollWidth = 496;
this.scintilla1.Size = new System.Drawing.Size(517, 304);
this.scintilla1.TabIndex = 0;
this.scintilla1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.scintilla1_KeyDown);
//
// pictureBox1
//

View File

@@ -20,8 +20,6 @@ using FModel.Parser.Items;
using FModel.Properties;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using ScintillaNET;
using ScintillaNET_FindReplaceDialog;
using Image = System.Drawing.Image;
using Settings = FModel.Properties.Settings;
@@ -29,36 +27,29 @@ namespace FModel
{
public partial class MainWindow : Form
{
#region EVERYTHING WE NEED
FindReplace _myFindReplace;
public Stopwatch StopWatch;
private static string[] _paksArray;
public static string[] PakAsTxt;
private static Dictionary<string, string> _diffToExtract;
private static string _backupFileName;
private static string[] _backupDynamicKeys;
private static List<string> _itemsToDisplay;
public static string ExtractedFilePath;
public static string[] SelectedItemsArray;
#endregion
private static Stopwatch StopWatch { get; set; }
private static string[] _paksArray { get; set; }
public static string[] PakAsTxt { get; set; }
private static Dictionary<string, string> _diffToExtract { get; set; }
private static string _backupFileName { get; set; }
private static string[] _backupDynamicKeys { get; set; }
private static List<string> _itemsToDisplay { get; set; }
public static string ExtractedFilePath { get; set; }
public static string[] SelectedItemsArray { get; set; }
public MainWindow()
{
InitializeComponent();
//FModel version
toolStripStatusLabel1.Text += @" " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString().Substring(0, 5);
treeView1.Sort();
//REMOVE SPACE CAUSED BY SIZING GRIP
//Remove space caused by SizingGrip
statusStrip1.Padding = new Padding(statusStrip1.Padding.Left, statusStrip1.Padding.Top, statusStrip1.Padding.Left, statusStrip1.Padding.Bottom);
// Create instance of FindReplace with reference to a ScintillaNET control.
_myFindReplace = new FindReplace(scintilla1); // For WinForms
_myFindReplace.Window.StartPosition = FormStartPosition.CenterScreen;
// Tie in FindReplace event
_myFindReplace.KeyPressed += MyFindReplace_KeyPressed;
// Tie in Scintilla event
scintilla1.KeyDown += scintilla1_KeyDown;
MyScintilla.ScintillaInstance(scintilla1);
}
#region USEFUL METHODS
@@ -136,33 +127,6 @@ namespace FModel
}
AESKeyTextBox.Text = @"0x" + Settings.Default.AESKey;
}
private void SetScintillaStyle()
{
if (InvokeRequired)
{
BeginInvoke(new Action(SetScintillaStyle));
return;
}
scintilla1.Styles[Style.Json.Default].ForeColor = Color.Silver;
scintilla1.Styles[Style.Json.BlockComment].ForeColor = Color.FromArgb(0, 128, 0);
scintilla1.Styles[Style.Json.LineComment].ForeColor = Color.FromArgb(0, 128, 0);
scintilla1.Styles[Style.Json.Number].ForeColor = Color.Green;
scintilla1.Styles[Style.Json.PropertyName].ForeColor = Color.SteelBlue;
scintilla1.Styles[Style.Json.String].ForeColor = Color.OrangeRed;
scintilla1.Styles[Style.Json.StringEol].BackColor = Color.OrangeRed;
scintilla1.Styles[Style.Json.Operator].ForeColor = Color.Black;
scintilla1.Styles[Style.LineNumber].ForeColor = Color.DarkGray;
var nums = scintilla1.Margins[1];
nums.Width = 30;
nums.Type = MarginType.Number;
nums.Sensitive = true;
nums.Mask = 0;
scintilla1.ClearCmdKey(Keys.Control | Keys.F);
scintilla1.ClearCmdKey(Keys.Control | Keys.Z);
scintilla1.Lexer = Lexer.Json;
}
//EVENTS
private async void MainWindow_Load(object sender, EventArgs e)
@@ -170,6 +134,7 @@ namespace FModel
AutoUpdater.Start("https://dl.dropbox.com/s/3kv2pukqu6tj1r0/FModel.xml?dl=0");
DLLImport.SetTreeViewTheme(treeView1.Handle);
_backupFileName = "\\FortniteGame_" + DateTime.Now.ToString("MMddyyyy") + ".txt";
// Copy user settings from previous application version if necessary
@@ -187,9 +152,10 @@ namespace FModel
Utilities.SetFolderPermission(App.DefaultOutputPath);
Utilities.JohnWickCheck();
Utilities.CreateDefaultFolders();
SetScintillaStyle();
FontUtilities.SetFont();
});
MyScintilla.SetScintillaStyle(scintilla1);
}
private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
{
@@ -236,44 +202,6 @@ namespace FModel
loadAllToolStripMenuItem.Text = @"Load Difference";
}
}
private void scintilla1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control && e.KeyCode == Keys.F)
{
_myFindReplace.ShowFind();
e.SuppressKeyPress = true;
}
else if (e.Shift && e.KeyCode == Keys.F3)
{
_myFindReplace.Window.FindPrevious();
e.SuppressKeyPress = true;
}
else if (e.KeyCode == Keys.F3)
{
_myFindReplace.Window.FindNext();
e.SuppressKeyPress = true;
}
else if (e.Control && e.KeyCode == Keys.H)
{
_myFindReplace.ShowReplace();
e.SuppressKeyPress = true;
}
else if (e.Control && e.KeyCode == Keys.I)
{
_myFindReplace.ShowIncrementalSearch();
e.SuppressKeyPress = true;
}
else if (e.Control && e.KeyCode == Keys.G)
{
GoTo myGoTo = new GoTo((Scintilla)sender);
myGoTo.ShowGoToDialog();
e.SuppressKeyPress = true;
}
}
private void MyFindReplace_KeyPressed(object sender, KeyEventArgs e)
{
scintilla1_KeyDown(sender, e);
}
//FORMS
private void settingsToolStripMenuItem_Click(object sender, EventArgs e)

View File

@@ -131,7 +131,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABa
CAAAAk1TRnQBSQFMAgEBAgEAAcABAAHAAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
CAAAAk1TRnQBSQFMAgEBAgEAAcgBAAHIAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA

View File

@@ -125,14 +125,7 @@ namespace FModel
DrawingRewards.getRewards(myBundle.BundleCompletionRewards[x].Rewards[i].TemplateId, itemQuantity);
if (compCount == "-1")
{
toDrawOn.DrawString("Complete ALL CHALLENGES to earn the reward item", new Font(FontUtilities.pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, theY + 22));
}
else
{
toDrawOn.DrawString("Complete ANY " + compCount + " CHALLENGES to earn the reward item", new Font(FontUtilities.pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, theY + 22));
}
drawCompletionText(compCount);
}
else
{
@@ -152,20 +145,24 @@ namespace FModel
drawUnknownReward();
}
if (compCount == "-1")
{
toDrawOn.DrawString("Complete ALL CHALLENGES to earn the reward item", new Font(FontUtilities.pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, theY + 22));
}
else
{
toDrawOn.DrawString("Complete ANY " + compCount + " CHALLENGES to earn the reward item", new Font(FontUtilities.pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, theY + 22));
}
drawCompletionText(compCount);
}
}
}
}
}
}
private static void drawCompletionText(string count)
{
if (count == "-1")
{
toDrawOn.DrawString("Complete ALL CHALLENGES to earn the reward item", new Font(FontUtilities.pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, theY + 22));
}
else
{
toDrawOn.DrawString("Complete ANY " + count + " CHALLENGES to earn the reward item", new Font(FontUtilities.pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, theY + 22));
}
}
/// <summary>
/// draw the watermark at the bottom of the bundle of challenges icon

View File

@@ -142,13 +142,17 @@ namespace FModel
}
}
}
catch (JsonSerializationException) { }
catch (JsonSerializationException)
{
//do not crash when JsonSerialization does weird stuff
}
}
}
}
catch (KeyNotFoundException)
{
Console.WriteLine("Can't extract " + questFile);
//do not stop when questFile doesn't exist
//Console.WriteLine("Can't extract " + questFile);
}
}
}

View File

@@ -75,6 +75,14 @@ namespace FModel
}
}
}
/// <summary>
/// "BannerIcons" contains all banners id, their image path and more
/// so basically we export and serialize "BannerIcons", locate where our banner id is, with FindTokens
/// after that we only have what we want with token.ToString() -> "SmallImage", "LargeImage", "asset_path_name", "CategoryRowName", "DisplayName", "DisplayDescription"
/// so we can just parse token.ToString() to properly get the LargeImage's asset_path_name or SmallImage's asset_path_name and draw
/// </summary>
/// <param name="bannerName"></param>
public static void DrawRewardBanner(string bannerName)
{
ItemIcon.ItemIconPath = string.Empty;
@@ -146,12 +154,7 @@ namespace FModel
BundleDesign.toDrawOn.DrawImage(ImageUtilities.ResizeImage(rewardIcon, 75, 75), new Point(2325, BundleDesign.theY + 22));
GraphicsPath p = new GraphicsPath();
Pen myPen = new Pen(Color.FromArgb(255, 143, 74, 32), 5);
myPen.LineJoin = LineJoin.Round; //needed to avoid spikes
p.AddString(quantity, FontUtilities.pfc.Families[1], (int)FontStyle.Regular, 60, new Point(2322, BundleDesign.theY + 25), FontUtilities.rightString);
BundleDesign.toDrawOn.DrawPath(myPen, p);
BundleDesign.toDrawOn.FillPath(new SolidBrush(Color.FromArgb(255, 255, 219, 103)), p);
drawPathAndFill(p, quantity, Color.FromArgb(255, 143, 74, 32), Color.FromArgb(255, 255, 219, 103));
}
private static void drawSeasonalXp(string quantity)
{
@@ -159,12 +162,7 @@ namespace FModel
BundleDesign.toDrawOn.DrawImage(ImageUtilities.ResizeImage(rewardIcon, 75, 75), new Point(2325, BundleDesign.theY + 22));
GraphicsPath p = new GraphicsPath();
Pen myPen = new Pen(Color.FromArgb(255, 81, 131, 15), 5);
myPen.LineJoin = LineJoin.Round; //needed to avoid spikes
p.AddString(quantity, FontUtilities.pfc.Families[1], (int)FontStyle.Regular, 60, new Point(2322, BundleDesign.theY + 25), FontUtilities.rightString);
BundleDesign.toDrawOn.DrawPath(myPen, p);
BundleDesign.toDrawOn.FillPath(new SolidBrush(Color.FromArgb(255, 230, 253, 177)), p);
drawPathAndFill(p, quantity, Color.FromArgb(255, 81, 131, 15), Color.FromArgb(255, 230, 253, 177));
}
private static void drawMtxGiveaway(string quantity)
{
@@ -172,12 +170,24 @@ namespace FModel
BundleDesign.toDrawOn.DrawImage(ImageUtilities.ResizeImage(rewardIcon, 75, 75), new Point(2325, BundleDesign.theY + 22));
GraphicsPath p = new GraphicsPath();
Pen myPen = new Pen(Color.FromArgb(255, 100, 160, 175), 5);
drawPathAndFill(p, quantity, Color.FromArgb(255, 100, 160, 175), Color.FromArgb(255, 220, 230, 255));
}
/// <summary>
/// define a pen to draw the outlines of a string with a color and fill with another color
/// </summary>
/// <param name="p"></param>
/// <param name="quantity"></param>
/// <param name="border"></param>
/// <param name="filled"></param>
private static void drawPathAndFill(GraphicsPath p, string quantity, Color border, Color filled)
{
Pen myPen = new Pen(border, 5);
myPen.LineJoin = LineJoin.Round; //needed to avoid spikes
p.AddString(quantity, FontUtilities.pfc.Families[1], (int)FontStyle.Regular, 60, new Point(2322, BundleDesign.theY + 25), FontUtilities.rightString);
BundleDesign.toDrawOn.DrawPath(myPen, p);
BundleDesign.toDrawOn.FillPath(new SolidBrush(Color.FromArgb(255, 220, 230, 255)), p);
BundleDesign.toDrawOn.FillPath(new SolidBrush(filled), p);
}
}
}

View File

@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace FModel
{
class DLLImport
static class DLLImport
{
/// <summary>
/// used to check if internet is turned on or off

View File

@@ -85,7 +85,10 @@ namespace FModel
}
}
}
catch (JsonSerializationException) { }
catch (JsonSerializationException)
{
//do not crash when JsonSerialization does weird stuff
}
}
}
}
@@ -103,9 +106,13 @@ namespace FModel
string weaponFilePath;
if (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0")
{
weaponFilePath = JohnWick.ExtractAsset(ThePak.CurrentUsedPak, theItem.WeaponDefinition);
}
else
{
weaponFilePath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[theItem.WeaponDefinition], theItem.WeaponDefinition);
}
if (weaponFilePath != null)
{
@@ -132,12 +139,14 @@ namespace FModel
}
}
}
catch (JsonSerializationException) { }
catch (JsonSerializationException)
{
//do not crash when JsonSerialization does weird stuff
}
}
}
}
else
SearchLargeSmallIcon(theItem);
else { SearchLargeSmallIcon(theItem); }
}
/// <summary>
@@ -247,7 +256,10 @@ namespace FModel
}
}
}
catch (JsonSerializationException) { }
catch (JsonSerializationException)
{
//do not crash when JsonSerialization does weird stuff
}
}
}
}

View File

@@ -8,7 +8,7 @@ using System.Windows.Forms;
namespace FModel
{
class ImagesMerger
static class ImagesMerger
{
/// <summary>
/// open a FileDialog to choose our images to merge, add them to the list of images

View File

@@ -0,0 +1,95 @@
using ScintillaNET_FindReplaceDialog;
using ScintillaNET;
using System.Windows.Forms;
using System.Drawing;
namespace FModel
{
static class MyScintilla
{
private static FindReplace _myFindReplace { get; set; }
private static GoTo _myGoTo { get; set; }
/// <summary>
/// Create instance of FindReplace with reference to a ScintillaNET control.
/// </summary>
/// <param name="theBox"></param>
public static void ScintillaInstance(Scintilla theBox)
{
_myFindReplace = new FindReplace(theBox);
_myFindReplace.Window.StartPosition = FormStartPosition.CenterScreen;
_myGoTo = new GoTo(theBox);
theBox.KeyDown += KeyDown;
}
/// <summary>
/// just the allowed keybinds and what they have to do
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private static void KeyDown(object sender, KeyEventArgs e)
{
if (e.Control && e.KeyCode == Keys.F)
{
_myFindReplace.ShowFind();
e.SuppressKeyPress = true;
}
else if (e.Shift && e.KeyCode == Keys.F3)
{
_myFindReplace.Window.FindPrevious();
e.SuppressKeyPress = true;
}
else if (e.KeyCode == Keys.F3)
{
_myFindReplace.Window.FindNext();
e.SuppressKeyPress = true;
}
else if (e.Control && e.KeyCode == Keys.H)
{
_myFindReplace.ShowReplace();
e.SuppressKeyPress = true;
}
else if (e.Control && e.KeyCode == Keys.I)
{
_myFindReplace.ShowIncrementalSearch();
e.SuppressKeyPress = true;
}
else if (e.Control && e.KeyCode == Keys.G)
{
_myGoTo.ShowGoToDialog();
e.SuppressKeyPress = true;
}
}
private static void KeyPressed(object sender, KeyEventArgs e)
{
KeyDown(sender, e);
}
/// <summary>
/// Set styles to a ScintillaNET control and disable some keybinds
/// </summary>
/// <param name="theBox"></param>
public static void SetScintillaStyle(Scintilla theBox)
{
theBox.Styles[Style.Json.Default].ForeColor = Color.Silver;
theBox.Styles[Style.Json.BlockComment].ForeColor = Color.FromArgb(0, 128, 0);
theBox.Styles[Style.Json.LineComment].ForeColor = Color.FromArgb(0, 128, 0);
theBox.Styles[Style.Json.Number].ForeColor = Color.Green;
theBox.Styles[Style.Json.PropertyName].ForeColor = Color.SteelBlue;
theBox.Styles[Style.Json.String].ForeColor = Color.OrangeRed;
theBox.Styles[Style.Json.StringEol].BackColor = Color.OrangeRed;
theBox.Styles[Style.Json.Operator].ForeColor = Color.Black;
theBox.Styles[Style.LineNumber].ForeColor = Color.DarkGray;
var nums = theBox.Margins[1];
nums.Width = 30;
nums.Type = MarginType.Number;
nums.Sensitive = true;
nums.Mask = 0;
theBox.ClearCmdKey(Keys.Control | Keys.F);
theBox.ClearCmdKey(Keys.Control | Keys.Z);
theBox.Lexer = Lexer.Json;
}
}
}