Skip to content

Commit

Permalink
Merge pull request #162 from LoadedCamel/dev
Browse files Browse the repository at this point in the history
3.5.4.12
  • Loading branch information
Metalios authored May 6, 2023
2 parents bd24f90 + 3e4afce commit 1be9529
Show file tree
Hide file tree
Showing 77 changed files with 3,647 additions and 3,521 deletions.
1 change: 0 additions & 1 deletion MRBUpdater/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace MRBUpdater
Expand Down
8 changes: 2 additions & 6 deletions MidsReborn/BuildImportTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1025,12 +1025,8 @@ private string ShortNamesConversion(string sn)
}
}

if (sn.StartsWith("DSyncO:"))
{
sn = sn[7..];
}

return sn;
// Parse D-Sync, Hamidon, Hydra, Titan enhancements
return Regex.Replace(sn, @"^(DSyncO|HO|HY|TN)\:", "");
}

public List<PowerEntry>? Parse()
Expand Down
9 changes: 0 additions & 9 deletions MidsReborn/Controls/PairedListEx.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 17 additions & 27 deletions MidsReborn/Controls/PairedListEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public partial class PairedListEx : UserControl
private int _rows = 5;
private Color _valueColor = Color.WhiteSmoke;
private Color _itemColor = Color.Silver;
private int _hoverIndex = -1;
private bool _setItemsBold;
private int _highlightedItem = -1;
private List<Item>? _items;

public delegate void ItemClickEventHandler(object? sender, Item item, MouseEventArgs e);
public delegate void ItemHoverEventHandler(object? sender, int index, Enums.ShortFX tagId, string tooltip = "");
public delegate void ItemHoverEventHandler(object? sender, int index, Enums.ShortFX tagId, string? tooltip = "");
public delegate void ItemOutEventHandler(object? sender);

public event ItemClickEventHandler? ItemClick;
Expand Down Expand Up @@ -176,22 +176,9 @@ public PairedListEx()

private static void OnItemClick(object? sender, Item item, MouseEventArgs mouseEventArgs) { }

private void OnItemHover(object? sender, int index, Enums.ShortFX tagId, string tooltip = "")
{
if (index != _highlightedItem)
{
if (myTip.GetToolTip(this) == tooltip) return;
myTip.SetToolTip(this, tooltip);
}
private static void OnItemHover(object? sender, int index, Enums.ShortFX tagId, string? tooltip = "") { }

_highlightedItem = index;
}

private void OnItemOut(object? sender)
{
myTip.SetToolTip(this, "");
_highlightedItem = -1;
}
private static void OnItemOut(object? sender) { }

private void OnForeColorChanged(object? sender, EventArgs e)
{
Expand Down Expand Up @@ -223,8 +210,6 @@ private void OnMouseClick(object? sender, MouseEventArgs e)

private void OnMouseLeave(object? sender, EventArgs e)
{
myTip.SetToolTip(this, "");
_highlightedItem = -1;
if (UseHighlighting)
{
Items?.ForEach(i => i.IsHighlightable = false);
Expand All @@ -240,7 +225,7 @@ private void OnMouseMove(object? sender, MouseEventArgs e)
return;
}

var hoveredItem = false;
var hoveredItem = -1;
for (var i = 0; i < Items.Count; i++)
{
var item = Items[i];
Expand All @@ -249,35 +234,40 @@ private void OnMouseMove(object? sender, MouseEventArgs e)
if (UseHighlighting)
{
item.IsHighlightable = true;
Invalidate();
}

if (item.ToolTip == null)
{
continue;
}

ItemHover?.Invoke(this, i, item.TagId, item.ToolTip);
hoveredItem = true;
hoveredItem = i;
}
else
{
item.IsHighlightable = false;
}
}

if (!hoveredItem)
if (_hoverIndex == hoveredItem)
{
ItemOut?.Invoke(this);
return;
}

if (UseHighlighting)
_hoverIndex = hoveredItem;
if (hoveredItem <= -1)
{
Invalidate();
ItemOut?.Invoke(this);
return;
}

if (Items[hoveredItem].ToolTip != null) ItemHover?.Invoke(this, hoveredItem, Items[hoveredItem].TagId, Items[hoveredItem].ToolTip);
}

private void OnLoad(object? sender, EventArgs e)
{
_hoverIndex = -1;
Redraw();
}

Expand Down Expand Up @@ -440,7 +430,7 @@ public class Item
{
public string? Name { get; set; }
public string? Value { get; set; }
public Enums.ShortFX TagId { get; set; }
public Enums.ShortFX TagId { get; }
public string? ToolTip { get; set; }
public bool UseAlternateColor { get; set; }
public bool UseSpecialColor { get; set; }
Expand Down
2 changes: 0 additions & 2 deletions MidsReborn/Controls/clsDrawX.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text;
using System.IO;
using System.Windows.Forms;
using Mids_Reborn.Core;
using Mids_Reborn.Core.Base.Display;
Expand Down
1 change: 0 additions & 1 deletion MidsReborn/Controls/ctlDamageDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Windows.Forms;
using Mids_Reborn.Core;
using Mids_Reborn.Core.Base.Display;
using Mids_Reborn.Core.Utils;

namespace Mids_Reborn.Controls
{
Expand Down
1 change: 0 additions & 1 deletion MidsReborn/Controls/ctlTotalsTabStrip.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
using Mids_Reborn.Controls.Extensions;
Expand Down
11 changes: 4 additions & 7 deletions MidsReborn/Core/Base/Data_Classes/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ namespace Mids_Reborn.Core.Base.Data_Classes
{
public class Character
{
public static List<string> gridEntries = new List<string> { "a", "b", "c", "d", "e", "f", "g", "h" };
private Archetype? _archetype;
private bool? _completeCache;
public Dictionary<string, int> SetSlotLoc = new Dictionary<string, int>();
public HashSet<string> setSlotted = new HashSet<string>();
public event EventHandler<Enums.Alignment>? AlignmentChanged;

internal Character()
Expand All @@ -27,7 +24,7 @@ internal Character()
Totals = new TotalStatistics();
TotalsCapped = new TotalStatistics();
DisplayStats = new Statistics(this);
Build = new Build(this, DatabaseAPI.Database.Levels);
Builds = new Build?[] { new Build(this, DatabaseAPI.Database.Levels) };
PEnhancementsList = new List<string>();
Reset();
}
Expand Down Expand Up @@ -73,9 +70,9 @@ public int Level

public int RequestedLevel { get; set; }

private Build Build { get; set; }
private Build?[] Builds { get; }

public Build CurrentBuild => Build;
public Build? CurrentBuild => Builds.Length > 0 ? Builds[0] : null;

public Archetype? Archetype
{
Expand Down Expand Up @@ -426,7 +423,7 @@ public void Reset(Archetype? iArchetype = null, int iOrigin = 0)

protected void NewBuild()
{
Build = new Build(this, DatabaseAPI.Database.Levels);
Builds[0] = new Build(this, DatabaseAPI.Database.Levels);
AcceleratedActive = false;
ActiveComboLevel = 0;
DelayedActive = false;
Expand Down
2 changes: 1 addition & 1 deletion MidsReborn/Core/Base/Data_Classes/Effect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ public float Mag
}
}

public float BuffedMag => Math_Mag > float.Epsilon ? Math_Mag : Mag;
public float BuffedMag => Math.Abs(Math_Mag) > float.Epsilon ? Math_Mag : Mag;

public float MagPercent => !DisplayPercentage ? BuffedMag : BuffedMag * 100f;

Expand Down
8 changes: 1 addition & 7 deletions MidsReborn/Core/Base/Display/InherentDisplayItem.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mids_Reborn.Core.Base.Display
namespace Mids_Reborn.Core.Base.Display
{
public class InherentDisplayItem
{
Expand Down
8 changes: 4 additions & 4 deletions MidsReborn/Core/Base/Master_Classes/MidsContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ public static class MidsContext
public const string AppName = "Mids' Reborn";
private const int AppMajorVersion = 3;
private const int AppMinorVersion = 5;
private const int AppBuildVersion = 3;
private const int AppRevisionVersion = 6;
private const int AppBuildVersion = 4;
private const int AppRevisionVersion = 12;

public const string AssemblyVersion = "3.5.6";
public const string AssemblyFileVersion = "3.5.3.6";
public const string AssemblyVersion = "3.5.4";
public const string AssemblyFileVersion = "3.5.4.12";
public static Version AppFileVersion { get; set; } = new(AppMajorVersion, AppMinorVersion, AppBuildVersion, AppRevisionVersion);

public const string AppVersionStatus = "";
Expand Down
15 changes: 15 additions & 0 deletions MidsReborn/Core/BooleanExprPreprocessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,11 @@ public static bool Parse(IEffect effect)
mathEngine.AddFunction("AND", (a, b) => a > 0 & b > 0 ? 1 : 0);
mathEngine.AddFunction("OR", (a, b) => a > 0 | b > 0 ? 1 : 0);

if (string.IsNullOrWhiteSpace(prefixExpr))
{
return true;
}

var ret = false;
try
{
Expand Down Expand Up @@ -406,6 +411,11 @@ public static bool Parse(IEffect effect, string cType, string cPowerName)
mathEngine.AddFunction("AND", (a, b) => a > 0 & b > 0 ? 1 : 0);
mathEngine.AddFunction("OR", (a, b) => a > 0 | b > 0 ? 1 : 0);

if (string.IsNullOrWhiteSpace(prefixExpr))
{
return true;
}

var ret = false;
try
{
Expand Down Expand Up @@ -455,6 +465,11 @@ public static bool Parse(IEffect effect, string cPowerName)
mathEngine.AddFunction("AND", (a, b) => a > 0 & b > 0 ? 1 : 0);
mathEngine.AddFunction("OR", (a, b) => a > 0 | b > 0 ? 1 : 0);

if (string.IsNullOrWhiteSpace(prefixExpr))
{
return true;
}

var ret = false;
try
{
Expand Down
5 changes: 1 addition & 4 deletions MidsReborn/Core/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -859,10 +859,7 @@ private void ScanAndCleanAutomaticallyGrantedPowers()
continue;
}

if (power.Chosen ||
power.PowerSet.SetType != Enums.ePowerSetType.Inherent &&
power.PowerSet.SetType != Enums.ePowerSetType.Primary &&
power.PowerSet.SetType != Enums.ePowerSetType.Secondary)
if (power.Chosen || power.PowerSet.SetType != Enums.ePowerSetType.Inherent && power.PowerSet.SetType != Enums.ePowerSetType.Primary && power.PowerSet.SetType != Enums.ePowerSetType.Secondary && power.PowerSet.SetType != Enums.ePowerSetType.Pool)
{
continue;
}
Expand Down
19 changes: 10 additions & 9 deletions MidsReborn/Core/BuildFile/CharacterBuildFile.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using Mids_Reborn.Core.Base.Data_Classes;
using Mids_Reborn.Core.Base.Master_Classes;
using Mids_Reborn.Core.BuildFile.DataModels;
using Mids_Reborn.Core.BuildFile.RestModels;
using Mids_Reborn.Core.Utils;
using Mids_Reborn.Forms.Controls;
using Newtonsoft.Json;
using Newtonsoft.Json.Bson;
using RestSharp;

namespace Mids_Reborn.Core.BuildFile
{
Expand All @@ -21,9 +18,11 @@ public class CharacterBuildFile

private static CharacterBuildFile? _instance;
private static readonly object Mutex = new();

private static int DisplayIndex { get; set; } = -1;
private static List<PowerEntry> InherentPowers { get; set; } = new();

private static CharacterBuildFile CreateInstance(Character characterData, bool refreshData = false)
private static CharacterBuildFile GetInstance(Character characterData, bool refreshData = false)
{
if (_instance != null && !refreshData) return _instance;
lock (Mutex)
Expand All @@ -33,18 +32,17 @@ private static CharacterBuildFile CreateInstance(Character characterData, bool r
return _instance;
}

public static CharacterBuildFile GetInstance()
private static CharacterBuildFile CreateInstance()
{
if (_instance != null) return _instance;
throw new NullReferenceException("Instance was not initialized before access.");
return _instance = new CharacterBuildFile();
}

public MetaData? BuiltWith { get; set; }
public string Class { get; set; }
public string Origin { get; set; }
public string Alignment { get; set; }
public string Name { get; set; }
public string? Comment { get; set; }
public string Comment { get; set; }
public List<string> PowerSets { get; set; }
public int LastPower { get; set; }
public List<PowerData?> PowerEntries { get; set; }
Expand Down Expand Up @@ -264,12 +262,14 @@ private static void WriteAltSlotData(ref SlotData slotData, I9Slot slot)
}
}


private static bool LoadBuild()
{
if (_instance == null)
{
return false;
}
InherentPowers = new List<PowerEntry>();

var atNiD = DatabaseAPI.NidFromUidClass(_instance.Class);
var atOrigin = DatabaseAPI.NidFromUidOrigin(_instance.Origin, atNiD);
Expand Down Expand Up @@ -490,14 +490,15 @@ public static bool Generate(string fileName)
return false;
}

var instance = CreateInstance(MidsContext.Character, true);
var instance = GetInstance(MidsContext.Character, true);
File.WriteAllText(fileName, JsonConvert.SerializeObject(instance, Formatting.Indented));
return true;
}

public static bool Load(string fileName)
{
var returnedVal = false;
_instance = CreateInstance();
_instance = JsonConvert.DeserializeObject<CharacterBuildFile>(File.ReadAllText(fileName));
if (_instance == null) throw new NullReferenceException(nameof(_instance));
var metaData = _instance.BuiltWith;
Expand Down
Loading

0 comments on commit 1be9529

Please sign in to comment.