Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
jhett12321 committed Oct 22, 2021
2 parents 5c5b911 + cf7d358 commit bf388a1
Show file tree
Hide file tree
Showing 47 changed files with 198 additions and 110 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## 8193.33.1
https://github.com/nwn-dotnet/Anvil/compare/v8193.33.0...v8193.33.1

### Changed
- Update to NWN.Core 8193.33.1

### Fixed
- Fixed an issue when retrieving bind values for certain class/structures (NuiRect, NuiVector, etc.) would return the default value.
- Fixed an incorrect API/object mapping for NuiDrawList.

## 8193.33.0
https://github.com/nwn-dotnet/Anvil/compare/v8193.26.3...v8193.33.0

Expand Down
2 changes: 1 addition & 1 deletion NWN.Anvil.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<PackageReference Include="LightInject" Version="6.4.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NLog" Version="4.7.11" />
<PackageReference Include="NWN.Core" Version="8193.33.0" PrivateAssets="compile" />
<PackageReference Include="NWN.Core" Version="8193.33.1" PrivateAssets="compile" />
<PackageReference Include="NWN.Native" Version="8193.33.0" PrivateAssets="compile" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions NWN.Anvil.csproj.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=src_005Cmain_005Canvil_005Capi_005Cnui_005Celements/@EntryIndexedValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=src_005Cmain_005Canvil_005Capi_005Cnui_005Clayout/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=src_005Cmain_005Canvil_005Capi_005Cnui_005Cwidgets/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=src_005Cmain_005Canvil_005Capi_005Cnui_005Cwidgets_005Cdrawlist/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=src_005Cmain_005Canvil_005Capi_005Cobject/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=src_005Cmain_005Canvil_005Capi_005Cscripts/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=src_005Cmain_005Canvil_005Capi_005Cserver/@EntryIndexedValue">True</s:Boolean>
Expand Down
2 changes: 1 addition & 1 deletion dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Configure nwserver to run with nwnx
FROM nwnxee/unified:c3e95f6
FROM nwnxee/unified:843fad9
ARG BINARY_PATH
COPY ${BINARY_PATH} /nwn/anvil/

Expand Down
2 changes: 1 addition & 1 deletion src/main/Anvil/API/Color.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Anvil.API
{
/// <summary>
/// Represents an 8 bit Color structure.
/// A 8 bit Color structure.
/// </summary>
public readonly struct Color
{
Expand Down
2 changes: 1 addition & 1 deletion src/main/Anvil/API/EngineStructure/EngineStructure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Anvil.API
{
/// <summary>
/// Represents a pointer-type VM structure.
/// A pointer-type VM structure.
/// </summary>
public abstract class EngineStructure : IDisposable
{
Expand Down
2 changes: 1 addition & 1 deletion src/main/Anvil/API/EngineStructure/SQLQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace Anvil.API
{
/// <summary>
/// Represents a SQL Query.
/// A SQL Query.
/// </summary>
public sealed class SQLQuery : EngineStructure
{
Expand Down
33 changes: 32 additions & 1 deletion src/main/Anvil/API/Extensions/CollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,32 @@

namespace Anvil.API
{
internal static class CollectionExtensions
/// <summary>
/// Various class extensions for generic collections.
/// </summary>
public static class CollectionExtensions
{
/// <summary>
/// Inserts an item into an already sorted list.
/// </summary>
/// <param name="sortedList">The sorted list.</param>
/// <param name="item">The item to insert.</param>
/// <param name="comparer">A custom comparer to use when comparing the item against elements in the collection.</param>
/// <typeparam name="T">The type of item to insert.</typeparam>
public static void InsertOrdered<T>(this List<T> sortedList, T item, IComparer<T> comparer = null)
{
int binaryIndex = sortedList.BinarySearch(item, comparer);
int index = binaryIndex < 0 ? ~binaryIndex : binaryIndex;
sortedList.Insert(index, item);
}

/// <summary>
/// Adds an element to a mutable lookup table<br/>
/// (E.g. Dictionary&lt;Key,List&lt;Value&gt;&gt;)
/// </summary>
/// <param name="mutableLookup">The lookup to modify.</param>
/// <param name="key">The key that the element should be added to.</param>
/// <param name="value">The value that should be added.</param>
public static void AddElement<TKey, TValue, TCollection>(this IDictionary<TKey, TCollection> mutableLookup, TKey key, TValue value) where TCollection : ICollection<TValue>, new()
{
if (!mutableLookup.TryGetValue(key, out TCollection values))
Expand All @@ -24,6 +41,13 @@ public static void InsertOrdered<T>(this List<T> sortedList, T item, IComparer<T
values.Add(value);
}

/// <summary>
/// Removes an element from a mutable lookup table<br/>
/// (E.g. Dictionary&lt;Key,List&lt;Value&gt;&gt;)
/// </summary>
/// <param name="mutableLookup">The lookup to modify.</param>
/// <param name="key">The key that the element should be removed from.</param>
/// <param name="value">The value that should be removed.</param>
public static bool RemoveElement<TKey, TValue, TCollection>(this IDictionary<TKey, TCollection> mutableLookup, TKey key, TValue value) where TCollection : ICollection<TValue>, new()
{
bool retVal = false;
Expand All @@ -40,6 +64,13 @@ public static void InsertOrdered<T>(this List<T> sortedList, T item, IComparer<T
return retVal;
}

/// <summary>
/// Queries if a certain value exists in a mutable lookup table<br/>
/// (E.g. Dictionary&lt;Key,List&lt;Value&gt;&gt;)
/// </summary>
/// <param name="mutableLookup">The lookup to query.</param>
/// <param name="key">The key to lookup.</param>
/// <param name="value">The value to be searched.</param>
public static bool ContainsElement<TKey, TValue, TCollection>(this IDictionary<TKey, TCollection> mutableLookup, TKey key, TValue value) where TCollection : ICollection<TValue>
{
return mutableLookup.TryGetValue(key, out TCollection values) && values.Contains(value);
Expand Down
1 change: 1 addition & 0 deletions src/main/Anvil/API/Nui/Bindings/NuiBind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public sealed class NuiBind<T> : NuiProperty<T>
[JsonProperty("bind")]
public string Key { get; init; }

[JsonConstructor]
public NuiBind(string key)
{
Key = key;
Expand Down
4 changes: 4 additions & 0 deletions src/main/Anvil/API/Nui/Bindings/NuiValue.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using JetBrains.Annotations;
using Newtonsoft.Json;

namespace Anvil.API
Expand All @@ -23,5 +24,8 @@ public NuiValue(T value)
{
Value = value;
}

[UsedImplicitly]
internal NuiValue() {}
}
}
19 changes: 0 additions & 19 deletions src/main/Anvil/API/Nui/DrawList/NuiDrawList.cs

This file was deleted.

24 changes: 0 additions & 24 deletions src/main/Anvil/API/Nui/DrawList/NuiDrawListCircle.cs

This file was deleted.

13 changes: 0 additions & 13 deletions src/main/Anvil/API/Nui/DrawList/NuiDrawListItem.cs

This file was deleted.

1 change: 1 addition & 0 deletions src/main/Anvil/API/Nui/NuiColor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public sealed class NuiColor
/// <param name="green">The green value.</param>
/// <param name="blue">The blue value.</param>
/// <param name="alpha">The alpha value.</param>
[JsonConstructor]
public NuiColor(byte red, byte green, byte blue, byte alpha = 255)
{
Red = red;
Expand Down
2 changes: 1 addition & 1 deletion src/main/Anvil/API/Nui/NuiElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Anvil.API
{
/// <summary>
/// A NUI widget/element.
/// A dynamic NUI element with style support.
/// </summary>
public abstract class NuiElement
{
Expand Down
1 change: 1 addition & 0 deletions src/main/Anvil/API/Nui/NuiRect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public readonly struct NuiRect
[JsonProperty("h")]
public float Height { get; }

[JsonConstructor]
public NuiRect(float x, float y, float width, float height)
{
X = x;
Expand Down
1 change: 1 addition & 0 deletions src/main/Anvil/API/Nui/NuiVector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Anvil.API
[JsonProperty("y")]
public readonly float Y;

[JsonConstructor]
public NuiVector(float x, float y)
{
X = x;
Expand Down
1 change: 1 addition & 0 deletions src/main/Anvil/API/Nui/NuiWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Anvil.API
/// </summary>
public sealed class NuiWindow
{
[JsonConstructor]
public NuiWindow(NuiLayout root, NuiProperty<string> title)
{
Title = title;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@ public override NuiDrawListItemType Type
get => NuiDrawListItemType.Arc;
}

[JsonProperty("color")]
public NuiProperty<NuiColor> Color { get; set; }

[JsonProperty("fill")]
public NuiProperty<bool> Fill { get; set; }

[JsonProperty("line_thickness")]
public NuiProperty<float> LineThickness { get; set; }

[JsonProperty("c")]
public NuiProperty<NuiVector> Center { get; set; }

Expand All @@ -29,5 +20,15 @@ public override NuiDrawListItemType Type

[JsonProperty("amax")]
public NuiProperty<float> AngleMax { get; set; }

[JsonConstructor]
public NuiDrawListArc(NuiProperty<NuiColor> color, NuiProperty<bool> fill, NuiProperty<float> lineThickness, NuiProperty<NuiVector> center, NuiProperty<float> radius,
NuiProperty<float> angleMin, NuiProperty<float> angleMax) : base(color, fill, lineThickness)
{
Center = center;
Radius = radius;
AngleMin = angleMin;
AngleMax = angleMax;
}
}
}
21 changes: 21 additions & 0 deletions src/main/Anvil/API/Nui/Widgets/DrawList/NuiDrawListCircle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Newtonsoft.Json;

namespace Anvil.API
{
public sealed class NuiDrawListCircle : NuiDrawListItem
{
public override NuiDrawListItemType Type
{
get => NuiDrawListItemType.Circle;
}

[JsonProperty("rect")]
public NuiProperty<NuiRect> Rect { get; set; }

[JsonConstructor]
public NuiDrawListCircle(NuiProperty<NuiColor> color, NuiProperty<bool> fill, NuiProperty<float> lineThickness, NuiProperty<NuiRect> rect) : base(color, fill, lineThickness)
{
Rect = rect;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ public override NuiDrawListItemType Type
get => NuiDrawListItemType.Curve;
}

[JsonProperty("color")]
public NuiProperty<NuiColor> Color { get; set; }

[JsonProperty("line_thickness")]
public NuiProperty<float> LineThickness { get; set; }

[JsonProperty("a")]
public NuiProperty<NuiVector> PointA { get; set; }

Expand All @@ -26,5 +20,14 @@ public override NuiDrawListItemType Type

[JsonProperty("ctrl1")]
public NuiProperty<NuiVector> Control1 { get; set; }

[JsonConstructor]
public NuiDrawListCurve(NuiProperty<NuiColor> color, NuiProperty<float> lineThickness, NuiProperty<NuiVector> pointA, NuiProperty<NuiVector> pointB, NuiProperty<NuiVector> control0, NuiProperty<NuiVector> control1) : base(color, false, lineThickness)
{
PointA = pointA;
PointB = pointB;
Control0 = control0;
Control1 = control1;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,19 @@ public override NuiDrawListItemType Type
public NuiProperty<NuiRect> Rect { get; set; }

[JsonProperty("image_aspect")]
public NuiProperty<NuiAspect> Aspect { get; set; }
public NuiProperty<NuiAspect> Aspect { get; set; } = NuiAspect.Exact;

[JsonProperty("image_halign")]
public NuiProperty<NuiHAlign> HorizontalAlign { get; set; }
public NuiProperty<NuiHAlign> HorizontalAlign { get; set; } = NuiHAlign.Left;

[JsonProperty("image_valign")]
public NuiProperty<NuiVAlign> VerticalAlign { get; set; }
public NuiProperty<NuiVAlign> VerticalAlign { get; set; } = NuiVAlign.Top;

[JsonConstructor]
public NuiDrawListImage(NuiProperty<string> resRef, NuiProperty<NuiRect> rect) : base(null, null, null)
{
ResRef = resRef;
Rect = rect;
}
}
}
29 changes: 29 additions & 0 deletions src/main/Anvil/API/Nui/Widgets/DrawList/NuiDrawListItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Newtonsoft.Json;

namespace Anvil.API
{
public abstract class NuiDrawListItem
{
[JsonProperty("type")]
public abstract NuiDrawListItemType Type { get; }

protected NuiDrawListItem(NuiProperty<NuiColor> color, NuiProperty<bool> fill, NuiProperty<float> lineThickness)
{
Color = color;
Fill = fill;
LineThickness = lineThickness;
}

[JsonProperty("enabled")]
public NuiProperty<bool> Enabled { get; set; } = true;

[JsonProperty("color")]
public NuiProperty<NuiColor> Color { get; set; }

[JsonProperty("fill")]
public NuiProperty<bool> Fill { get; set; }

[JsonProperty("line_thickness")]
public NuiProperty<float> LineThickness { get; set; }
}
}
Loading

0 comments on commit bf388a1

Please sign in to comment.