Skip to content

Commit

Permalink
Bug fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
MeowServer committed Jul 4, 2024
1 parent 5eec0ab commit 0c0f0c3
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 111 deletions.
18 changes: 9 additions & 9 deletions Config/PlayerUIConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ namespace HintServiceMeow.Config
{
public class PlayerUIConfig
{
[Description("The default time to show for each type of common hint.\r\n" +
"Short means that the hint has on title but not decription\r\n")]
[Description("The default time to show for each type of common hint.\n" +
"Short means that the hint has on title but not decription")]
public int ItemHintDisplayTime { get; set; } = 10;
public int ShortItemHintDisplayTime { get; set; } = 5;

Expand All @@ -22,9 +22,9 @@ public class PlayerUIConfig

public int OtherHintDisplayTime { get; set; } = 5;

[Description("The default config to show for each type of common hint.\r\n" +
"Only config for alignment, font size, hint fiel, and priority are valid.\r\n")]
public List<DynamicHintConfig> ItemHints { get; set; } = new List<DynamicHintConfig>()
[Description("The default config to show for each type of common hint.\n" +
"Only config for alignment, font size, hint fiel, and priority are valid.")]
public List<DynamicHintPositionConfig> ItemHints { get; set; } = new List<DynamicHintPositionConfig>()
{
new DynamicHintPositionConfig()
{
Expand All @@ -42,12 +42,12 @@ public class PlayerUIConfig
}
};

public List<DynamicHintConfig> MapHints { get; set; } = new List<DynamicHintConfig>()
public List<DynamicHintPositionConfig> MapHints { get; set; } = new List<DynamicHintPositionConfig>()
{
new DynamicHintPositionConfig()
{
Alignment = HintAlignment.Right,
FontSize = 25,
FontSize = 30,
TopYCoordinate = 0,
BottomYCoordinate = 200
},
Expand All @@ -60,7 +60,7 @@ public class PlayerUIConfig
}
};

public List<DynamicHintConfig> RoleHints { get; set; } = new List<DynamicHintConfig>()
public List<DynamicHintPositionConfig> RoleHints { get; set; } = new List<DynamicHintPositionConfig>()
{
new DynamicHintPositionConfig()
{
Expand Down Expand Up @@ -92,7 +92,7 @@ public class PlayerUIConfig
}
};

public List<DynamicHintConfig> OtherHints { get; set; } = new List<DynamicHintConfig>()
public List<DynamicHintPositionConfig> OtherHints { get; set; } = new List<DynamicHintPositionConfig>()
{
new DynamicHintPositionConfig()
{
Expand Down
2 changes: 1 addition & 1 deletion EventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal static void OnVerified(VerifiedEventArgs ev)
var pd = new PlayerDisplay(ev.Player);
new PlayerUI(ev.Player);

EventHandler.InvokeNewPlayerEvent(pd);
InvokeNewPlayerEvent(pd);
}

internal static void OnLeft(LeftEventArgs ev)
Expand Down
12 changes: 6 additions & 6 deletions PlayerDisplay/Hints/DynamicHintConfigs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

namespace HintServiceMeow
{
[Description("Please be aware that the plugin might not be using all of the config." +
"\r\nIn other words, not all of the following configs are valid")]
[Description("Please be aware that the plugin might not be using all of the config.\n" +
"In other words, not all of the following configs are valid")]
public class DynamicHintConfig
{
[Description("The ID of the hint")]
public string Id { get; set; } = null;

[Description("The priority of the hint. Higher priority means the hint is less likely to be covered by other hint." +
"\r\nnAvailable: Highest, High, Medium, Low, Lowest")]
[Description("The priority of the hint. Higher priority means the hint is less likely to be covered by other hint.\n" +
"Available: Highest, High, Medium, Low, Lowest")]
public HintPriority Priority { get; set; } = HintPriority.Medium;

public DynamicHintPositionConfig Position { get; set; } = new DynamicHintPositionConfig();
Expand All @@ -29,8 +29,8 @@ public DynamicHintConfig()

public class DynamicHintPositionConfig
{
[Description("The alignment of the hint. " +
"\r\nAvailable: Left, Right, Center ")]
[Description("The alignment of the hint.\n" +
"Available: Left, Right, Center ")]
public HintAlignment Alignment { get; set; } = HintAlignment.Center;

[Description("The size of the font, default is 20")]
Expand Down
70 changes: 32 additions & 38 deletions PlayerDisplay/Hints/HintClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,7 @@ public abstract class AbstractHint
public string id
{
get => _id;
set
{
if (_id != value)
return;

_id = value;
if (!hide) OnHintUpdated();

}
set => _id = value;
}

private HintPriority _priority = HintPriority.Medium;
Expand All @@ -46,7 +38,7 @@ public HintAlignment alignment
get => _alignment;
set
{
if (_alignment != value)
if (_alignment == value)
return;

_alignment = value;
Expand All @@ -60,7 +52,7 @@ public int fontSize
get => _fontSize;
set
{
if (_fontSize != value)
if (_fontSize == value)
return;

_fontSize = value;
Expand All @@ -74,7 +66,7 @@ public string message
get => _message;
set
{
if (_message != value)
if (_message == value)
return;

_message = value;
Expand All @@ -88,7 +80,7 @@ public bool hide
get => _hide;
set
{
if (_hide != value)
if (_hide == value)
return;

_hide = value;
Expand Down Expand Up @@ -175,34 +167,21 @@ public class Hint : AbstractHint
private int _yCoordinate = 500;
public int topYCoordinate
{
get
{
return _yCoordinate;
}
get => _yCoordinate;
set
{
if (_yCoordinate != value)
{
_yCoordinate = value;
if (!hide) OnHintUpdated();
}
if (_yCoordinate == value)
return;

_yCoordinate = value;
if (!hide) OnHintUpdated();
}
}

public int bottomYCoordinate
{
get
{
return topYCoordinate + fontSize;
}
set
{
if (_yCoordinate != value - fontSize)
{
_yCoordinate = value - fontSize;
if (!hide) OnHintUpdated();
}
}
get => topYCoordinate + fontSize;
set => topYCoordinate = value - fontSize;
}

#region Constructors
Expand Down Expand Up @@ -270,7 +249,7 @@ public Hint SetTopYCoordinate(int y)

public Hint SetBottomYCoordinate(int y)
{
this.bottomYCoordinate = y;
this.topYCoordinate = y + fontSize;
return this;
}
#endregion
Expand All @@ -297,15 +276,30 @@ public override string GetText()

public class DynamicHint : AbstractHint
{
private DynamicHintField _hintField = new DynamicHintField(300, 700);
private DynamicHintField _hintField = null;
public DynamicHintField hintField
{
get => _hintField;
get
{
if (_hintField == null)
{
_hintField = new DynamicHintField(300, 700);
_hintField.OnUpdate += OnHintUpdated;
}

return _hintField;
}
set
{
if (_hintField != value)
if (_hintField == value)
return;

if (_hintField == null)
_hintField = new DynamicHintField(300, 700);

_hintField.OnUpdate -= OnHintUpdated;
value.OnUpdate += OnHintUpdated;

_hintField = value;

if (!hide) OnHintUpdated();
Expand Down
6 changes: 3 additions & 3 deletions PlayerDisplay/Hints/HintConfigs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class HintConfig
public string Id { get; set; } = null;

[Description("The priority of the hint. Higher priority means the hint is less likely to be covered by other hint." +
"\r\nAvailable: Highest, High, Medium, Low, Lowest")]
"\nAvailable: Highest, High, Medium, Low, Lowest")]
public HintPriority Priority { get; set; } = HintPriority.Medium;

public HintPositionConfig Position { get; set; } = new HintPositionConfig();
Expand All @@ -28,7 +28,7 @@ public HintConfig()
public class HintPositionConfig
{
[Description("The alignment of the hint. " +
"\r\nAvailable: Left, Right, Center ")]
"\nAvailable: Left, Right, Center ")]
public HintAlignment Alignment { get; set; } = HintAlignment.Center;

[Description("The initial YCoordinate of the hint, default is 500")]
Expand All @@ -52,7 +52,7 @@ public class HintContentConfig
public string Message { get; set; } = "This is a default message";

[Description("To hide the hint or not.")]
public bool Hide { get; set; } = false;
public bool Hide { get; set; } = true;

public static implicit operator HintConfig(HintContentConfig v)
{
Expand Down
4 changes: 4 additions & 0 deletions PlayerDisplay/Hints/HintParameters .cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine.AI;

namespace HintServiceMeow
{
Expand All @@ -24,6 +25,9 @@ public enum HintAlignment

public class DynamicHintField
{
internal delegate void UpdateHandler();
internal event UpdateHandler OnUpdate;

public int topYCoordinate;
public int bottomYCoordinate;

Expand Down
Loading

0 comments on commit 0c0f0c3

Please sign in to comment.