-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
159 changed files
with
3,368 additions
and
1,340 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "nuget" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
target-branch: "stable-develop" | ||
labels: | ||
- "stable" | ||
assignees: | ||
- "welles" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using BannerlordCheats.Localization; | ||
using BannerlordCheats.Settings; | ||
using MCM.Common; | ||
using TaleWorlds.Core; | ||
|
||
namespace BannerlordCheats.Extensions | ||
{ | ||
public static class EnumExtensions | ||
{ | ||
public static bool TryGetAgentState(this KnockoutOrKilled state, out AgentState result) | ||
{ | ||
switch (state) | ||
{ | ||
case KnockoutOrKilled.Default: | ||
result = AgentState.None; | ||
return false; | ||
case KnockoutOrKilled.Knockout: | ||
result = AgentState.Unconscious; | ||
return true; | ||
case KnockoutOrKilled.Killed: | ||
result = AgentState.Killed; | ||
return true; | ||
default: | ||
throw new ArgumentOutOfRangeException(nameof(state), state, null); | ||
} | ||
} | ||
|
||
public static T GetValue<T>(this Dropdown<LocalizedDropdownValue<T>> dropdown) | ||
where T : Enum | ||
{ | ||
return (T)(object)dropdown.SelectedIndex; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using MCM.Common; | ||
|
||
namespace BannerlordCheats.Localization | ||
{ | ||
public struct LocalizedDropdownValue<T> : IEquatable<LocalizedDropdownValue<T>> | ||
where T : Enum | ||
{ | ||
public LocalizedDropdownValue(T value) | ||
{ | ||
Value = value; | ||
} | ||
|
||
public T Value { get; set; } | ||
|
||
public string DisplayName | ||
{ | ||
get | ||
{ | ||
var key = $"Enum_{typeof(T).Name}_{Enum.GetName(typeof(T), this.Value)}"; | ||
|
||
return L10N.GetText(key); | ||
} | ||
} | ||
|
||
public override string ToString() => this.DisplayName; | ||
|
||
public bool Equals(T other) | ||
{ | ||
return EqualityComparer<T>.Default.Equals(this.Value, other); | ||
} | ||
|
||
public bool Equals(LocalizedDropdownValue<T> other) | ||
{ | ||
if (ReferenceEquals(null, other)) return false; | ||
if (ReferenceEquals(this, other)) return true; | ||
return EqualityComparer<T>.Default.Equals(Value, other.Value); | ||
} | ||
|
||
public override bool Equals(object obj) | ||
{ | ||
if (ReferenceEquals(null, obj)) return false; | ||
if (ReferenceEquals(this, obj)) return true; | ||
if (obj.GetType() != this.GetType()) return false; | ||
return Equals((LocalizedDropdownValue<T>)obj); | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
return EqualityComparer<T>.Default.GetHashCode(this.Value); | ||
} | ||
|
||
public static bool operator ==(LocalizedDropdownValue<T> left, T right) | ||
{ | ||
return left.Equals(right); | ||
} | ||
|
||
public static bool operator !=(LocalizedDropdownValue<T> left, T right) | ||
{ | ||
return !left.Equals(right); | ||
} | ||
|
||
public static bool operator ==(LocalizedDropdownValue<T> left, LocalizedDropdownValue<T> right) | ||
{ | ||
return Equals(left, right); | ||
} | ||
|
||
public static bool operator !=(LocalizedDropdownValue<T> left, LocalizedDropdownValue<T> right) | ||
{ | ||
return !Equals(left, right); | ||
} | ||
|
||
public static Dropdown<LocalizedDropdownValue<T>> GenerateDropdown(T selected) | ||
{ | ||
var values = Enum.GetValues(typeof(T)).Cast<T>().Select(value => new LocalizedDropdownValue<T>(value)).ToArray(); | ||
|
||
var selectedIndex = Array.IndexOf(values, values.First(x => x.Value.Equals(selected))); | ||
|
||
return new Dropdown<LocalizedDropdownValue<T>>(values, selectedIndex); | ||
} | ||
} | ||
} |
Oops, something went wrong.