Skip to content

Commit

Permalink
Add WidgetPosition enum
Browse files Browse the repository at this point in the history
  • Loading branch information
araszka committed Aug 10, 2024
1 parent 8f166f9 commit a2005ba
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
18 changes: 18 additions & 0 deletions src/EvoSC.Common/Util/Manialinks/WidgetPosition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using EvoSC.Common.Util.EnumIdentifier;

namespace EvoSC.Common.Util.Manialinks;

public enum WidgetPosition
{
[Identifier(Name = "left", NoPrefix = true)]
Left,

[Identifier(Name = "right", NoPrefix = true)]
Right,

[Identifier(Name = "center", NoPrefix = true)]
Center,

[Identifier(Name = "", NoPrefix = true)]
Undefined,
}
3 changes: 2 additions & 1 deletion src/Modules/LiveRankingModule/Config/ILiveRankingSettings.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.ComponentModel;
using Config.Net;
using EvoSC.Common.Util.Manialinks;
using EvoSC.Modules.Attributes;

namespace EvoSC.Modules.Official.LiveRankingModule.Config;
Expand All @@ -17,5 +18,5 @@ public interface ILiveRankingSettings
public double Width { get; set; }

[Option(DefaultValue = "right"), Description("Specifies on which side the widget is displayed.")]
public string Position { get; set; }
public WidgetPosition Position { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
<component>
<using namespace="EvoSC.Common.Util.Manialinks"/>

<property type="double" name="width" default="36"/>
<property type="string" name="position" default="right"/>
<property type="WidgetPosition" name="position" default="WidgetPosition.Right"/>

<template>
<frame>
<quad pos='{{ position == "right" ? width + 0.7 : 0 }}'
<quad pos='{{ position == WidgetPosition.Right ? width + 0.7 : 0 }}'
bgcolor="{{ Theme.UI_AccentPrimary }}"
size="0.7 9"
halign='{{ position }}'
halign='{{ position == WidgetPosition.Right ? "right" : "left" }}'
/>
<Panel
width="{{ width }}"
height="9"
x='{{ position == "right" ? 0 : 0.7 }}'
x='{{ position == WidgetPosition.Right ? 0 : 0.7 }}'
className="lr-body-primary"
bgColor=""
>
Expand Down
3 changes: 2 additions & 1 deletion src/Modules/LiveRankingModule/Templates/LiveRanking.mt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<component>
<using namespace="EvoSC.Modules.Official.LiveRankingModule.Config"/>
<using namespace="EvoSC.Modules.Official.LiveRankingModule.Models"/>
<using namespace="EvoSC.Common.Util.Manialinks"/>
<using namespace="EvoSC.Common.Models.Callbacks"/>
<using namespace="System.Linq"/>

Expand All @@ -19,7 +20,7 @@
<Widget header="Live Ranking"
height="10"
bodyStyle="unstyled"
position="{{ settings.Position }}"
position='{{ settings.Position == WidgetPosition.Right ? "right" : "left" }}'
y="{{ settings.Y }}"
>
<template slot="body">
Expand Down

0 comments on commit a2005ba

Please sign in to comment.