Skip to content

Commit 306bfa6

Browse files
committed
Clean up settings
1 parent 4edeff3 commit 306bfa6

File tree

2 files changed

+49
-14
lines changed

2 files changed

+49
-14
lines changed

Source/AnalogInputDisplay.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,23 @@ public AnalogInputDisplay()
1313

1414
public override void Render()
1515
{
16+
AnalogInputDisplayModuleSettings settings = AnalogInputDisplayModule.Settings;
17+
if (!settings.Enabled) return;
18+
1619
Player player = Scene.Tracker.GetEntity<Player>();
1720
Level level = SceneAs<Level>();
1821
if (level == null) return;
1922
if (player == null) return;
2023

21-
AnalogInputDisplayModuleSettings settings = AnalogInputDisplayModule.Settings;
2224
float radius = settings.Radius * 5f;
2325
Vector2 pos = level.WorldToScreen(player.Center);
2426

2527
GamePadState gamepad = GamePad.GetState(0, GamePadDeadZone.None);
2628
if (gamepad.ThumbSticks.Left.Length() > settings.MinDisplayThreshold)
2729
{
2830
Vector2 thumbstick = new Vector2(gamepad.ThumbSticks.Left.X, -gamepad.ThumbSticks.Left.Y);
29-
drawIndicator(pos, thumbstick, settings.IndicatorLength, radius, Color.Red, settings.InputThickness);
30-
drawIndicator(pos, Input.LastAim, settings.IndicatorLength, radius, Color.White, settings.ActualDirectionThickness);
31+
drawIndicator(pos, thumbstick, radius, settings.InputIndicator);
32+
drawIndicator(pos, Input.LastAim, radius, settings.DashIndicator);
3133
}
3234
}
3335

@@ -37,10 +39,10 @@ private static Vector2 translateVec(Vector2 initial, float angleRad, float dista
3739
return initial + offset;
3840
}
3941

40-
private void drawIndicator(Vector2 origin, Vector2 direction, float length, float radius, Color color, float thickness = 1)
42+
private void drawIndicator(Vector2 origin, Vector2 direction, float radius, AnalogInputDisplayModuleSettings.Indicator indicator)
4143
{
42-
Vector2 start = translateVec(origin, direction.Angle(), radius - length);
44+
Vector2 start = translateVec(origin, direction.Angle(), radius - indicator.Length);
4345
Vector2 end = translateVec(origin, direction.Angle(), radius);
44-
Draw.Line(start, end, color, thickness);
46+
Draw.Line(start, end, indicator.GetXNAColor(), indicator.Thickness);
4547
}
4648
}
Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
using System;
2+
using Microsoft.Xna.Framework;
3+
14
namespace Celeste.Mod.AnalogInputDisplay;
25

36
public class AnalogInputDisplayModuleSettings : EverestModuleSettings
@@ -6,15 +9,45 @@ public class AnalogInputDisplayModuleSettings : EverestModuleSettings
69

710
[SettingRange(1, 100, true)]
811
public int Radius { get; set; } = 20;
9-
10-
[SettingRange(1, 20)]
11-
public int IndicatorLength { get; set; } = 10;
1212

1313
public float MinDisplayThreshold { get; set; } = 0.1f;
1414

15-
[SettingRange(1, 10)]
16-
public int InputThickness { get; set; } = 2;
15+
public Indicator InputIndicator { get; set; } = new Indicator(ColorSetting.White);
16+
17+
public Indicator DashIndicator { get; set; } = new Indicator(ColorSetting.Gray);
18+
19+
[SettingSubMenu]
20+
public class Indicator {
21+
public Indicator() {}
22+
public Indicator(ColorSetting defaultColor) {
23+
Color = defaultColor;
24+
}
25+
26+
public Color GetXNAColor() {
27+
string colorName = Enum.GetName(typeof(ColorSetting), Color);
28+
Color color = (Color)(typeof(Color).GetProperty(colorName)).GetValue(null, null);
29+
30+
return color;
31+
}
32+
33+
public ColorSetting Color { get; set;} = ColorSetting.White;
34+
35+
[SettingRange(1, 10)]
36+
public int Thickness { get; set; } = 2;
37+
38+
[SettingRange(1, 20)]
39+
public int Length { get; set; } = 10;
40+
}
41+
}
1742

18-
[SettingRange(1, 10)]
19-
public int ActualDirectionThickness { get; set; } = 3;
20-
}
43+
public enum ColorSetting {
44+
White,
45+
Gray,
46+
Black,
47+
Red,
48+
Green,
49+
Blue,
50+
Cyan,
51+
Magenta,
52+
Yellow,
53+
}

0 commit comments

Comments
 (0)