Skip to content

Commit

Permalink
make menu looks better
Browse files Browse the repository at this point in the history
  • Loading branch information
LozenChen committed Jan 23, 2024
1 parent bc98b91 commit 09c7dad
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 42 deletions.
4 changes: 2 additions & 2 deletions Dialog/English.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ TAS_HELPER_PREDICTOR_MAIN_SWITCH= Main Switch
TAS_HELPER_PREDICTOR_DESCRIPTION= Predict your future track, when tas is paused or frame-stepping,{n}
AND any selected conditions of the following is satisfied.
TAS_HELPER_TIMELINE_LENGTH= Timeline Length
TAS_HELPER_PREDICT_START_CONDITIONS= ----------------------- Conditions: -----------------------
TAS_HELPER_PREDICT_START_CONDITIONS= Conditions
TAS_HELPER_PREDICT_ON_FILE_CHANGE= Predict on Tas File Changed
TAS_HELPER_PREDICT_ON_HOTKEY_PRESSED= Predict on Hotkey Pressed
TAS_HELPER_PREDICT_ON_FRAME_STEP= Predict on Frame Stepping
Expand Down Expand Up @@ -202,7 +202,7 @@ TAS_HELPER_STOP_PREDICT_WHEN_DEATH= Stop Prediction when
TAS_HELPER_STOP_PREDICT_WHEN_KEYFRAME= Stop Prediction when Keyframe
TAS_HELPER_USE_KEY_FRAME= Keyframe Main Switch
TAS_HELPER_USE_KEY_FRAME_TIME= Show Index of Keyframe
TAS_HELPER_KEY_FRAME_FLAGS= ----------------------- Flags: -----------------------
TAS_HELPER_KEY_FRAME_FLAGS= Flags
TAS_HELPER_PREDICTOR_LINE_WIDTH= Polygonal Line Width
TAS_HELPER_PREDICTOR_POINT_SIZE= Dot Size

Expand Down
5 changes: 2 additions & 3 deletions Dialog/Simplified Chinese.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ TAS_HELPER_TIMELINE_LENGTH= 时间线的长度
TAS_HELPER_PREDICT_ON_FILE_CHANGE= 条件: 当 TAS 文件内容变动
TAS_HELPER_PREDICT_ON_HOTKEY_PRESSED= 条件: 当按下快捷键
TAS_HELPER_PREDICT_ON_FRAME_STEP= 条件: 当 TAS 步进
TAS_HELPER_PREDICT_START_CONDITIONS= ----------------------- 条件: -----------------------

TAS_HELPER_PREDICT_START_CONDITIONS= 条件
TAS_HELPER_PREDICTOR_FINISHED= 完成
TAS_HELPER_PREDICTOR_ONOFF= 开关
TAS_HELPER_PREDICTOR_KEYFRAME_1= 关键帧/1
Expand Down Expand Up @@ -190,7 +189,7 @@ TAS_HELPER_STOP_PREDICT_WHEN_DEATH= 死亡时终止预测
TAS_HELPER_STOP_PREDICT_WHEN_KEYFRAME= 关键帧处终止预测
TAS_HELPER_USE_KEY_FRAME= 关键帧的主开关
TAS_HELPER_USE_KEY_FRAME_TIME= 显示关键帧对应的时间点
TAS_HELPER_KEY_FRAME_FLAGS= ----------------------- Flags: -----------------------
TAS_HELPER_KEY_FRAME_FLAGS= Flags
TAS_HELPER_PREDICTOR_LINE_WIDTH= 折线宽度
TAS_HELPER_PREDICTOR_POINT_SIZE= 点的大小

Expand Down
18 changes: 12 additions & 6 deletions Source/Module/Menu/CustomColors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ public static void ResetPredictorColor() {
public static Color CameraTriggerColor { get => TasHelperSettings.CameraTriggerColor; set => TasHelperSettings.CameraTriggerColor = value; }

public static TextMenu.Item CreateChangeColorItem(Func<Color> getter, Action<Color> setter, string name, TextMenu textMenu, bool inGame) {
TextMenu.Item item = new ButtonColorExt(name.ToDialogText(), getter).Pressed(
TextMenu.Item item = new ButtonColorExt(name.ToDialogText(), getter, inGame).Pressed(inGame ? () => { }
:
() => {
Audio.Play("event:/ui/main/savefile_rename_start");
textMenu.SceneAs<Overworld>().Goto<OuiModOptionStringHexColor>()
.Init<OuiModOptions>(ColorToHex(getter()),
value => setter(HexToColor(value, getter())), 9);
});
item.Disabled = inGame;
return item;
}

Expand Down Expand Up @@ -162,6 +162,7 @@ public static void AddItemWithDescriptionAndCMD(TextMenu menu, List<TextMenu.Ite
HeightExtra = 0f
};
page.Add(descriptionText);
page.Add(new HLine(Color.Gray));
return page;

}
Expand All @@ -187,6 +188,7 @@ public static void AddItemWithDescriptionAndCMD(TextMenu menu, List<TextMenu.Ite
AddItemWithDescriptionAndCMD(menu, page, inGame, () => Predictor_CoarseScaleColor, value => Predictor_CoarseScaleColor = value, nameof(Predictor_CoarseScaleColor), defaultPredictorCoarseScaleColor);
AddItemWithDescriptionAndCMD(menu, page, inGame, () => Predictor_EndpointColor, value => Predictor_EndpointColor = value, nameof(Predictor_EndpointColor), defaultPredictorEndpointColor);
AddItemWithDescriptionAndCMD(menu, page, inGame, () => Predictor_KeyframeColor, value => Predictor_KeyframeColor = value, nameof(Predictor_KeyframeColor), defaultPredictorKeyframeColor);
page.Add(new HLine(Color.Gray));
return page;

}
Expand All @@ -211,6 +213,7 @@ public static void AddItemWithDescriptionAndCMD(TextMenu menu, List<TextMenu.Ite
AddItemWithDescriptionAndCMD(menu, page, inGame, () => LoadRangeColliderColor, value => LoadRangeColliderColor = value, nameof(LoadRangeColliderColor), defaultLoadRangeColliderColor);
AddItemWithDescriptionAndCMD(menu, page, inGame, () => CameraTargetColor, value => CameraTargetColor = value, nameof(CameraTargetColor), defaultCameraTargetColor);
AddItemWithDescriptionAndCMD(menu, page, inGame, () => CameraTriggerColor, value => CameraTriggerColor = value, nameof(CameraTriggerColor), defaultCameraTriggerColor);
page.Add(new HLine(Color.Gray));
return page;
}

Expand All @@ -234,6 +237,7 @@ public static void AddItemWithDescriptionAndCMD(TextMenu menu, List<TextMenu.Ite
}
);
page.Add(resetButton);
page.Add(new HLine(Color.Gray));
return page;
}

Expand Down Expand Up @@ -890,6 +894,7 @@ public class ButtonColorExt : TextMenu.Button, IItemExt {
public string name;
public Color TextColorDisabled { get; set; } = Color.DarkSlateGray;

public Color TextColorHighlightDisabled { get; set; } = Color.SlateGray;

public string Icon { get; set; }

Expand All @@ -904,6 +909,7 @@ public class ButtonColorExt : TextMenu.Button, IItemExt {

public Vector2 Scale { get; set; } = Vector2.One;

public bool InGame;

public override float Height() {
return base.Height() * Scale.Y;
Expand All @@ -914,19 +920,20 @@ public override float LeftWidth() {
}

#pragma warning disable CS8625
public ButtonColorExt(string label, Func<Color> cubecolorGetter, string icon = null)
public ButtonColorExt(string label, Func<Color> cubecolorGetter, bool inGame = false)
#pragma warning restore CS8625
: base(label) {
CubeColorGetter = cubecolorGetter;
Icon = icon;
Icon = "";
name = label;
InGame = inGame;
}

public override void Render(Vector2 position, bool highlighted) {
Label = name + $": {ColorToHex(CubeColorGetter())}";
position += Offset;
float num = Container.Alpha * Alpha;
Color color = (Disabled ? TextColorDisabled : highlighted ? Container.HighlightColor : TextColor) * num;
Color color = (InGame ? (highlighted ? TextColorHighlightDisabled : TextColorDisabled) : (highlighted ? Container.HighlightColor : TextColor)) * num;
Color strokeColor = Color.Black * (num * num * num);
bool flag = Container.InnerContent == TextMenu.InnerContentMode.TwoColumn && !AlwaysCenter;
Vector2 textPosition = position + (flag ? Vector2.Zero : new Vector2(Container.Width * 0.5f, 0f));
Expand All @@ -935,7 +942,6 @@ public override void Render(Vector2 position, bool highlighted) {
Vector2 cubePosition = textPosition + new Vector2(ActiveFont.Measure(Label).X + 30f, -height / 2f);
Draw.Rect(cubePosition - new Vector2(4f, 4f), height + 8f, height + 8f, Color.Black);
Draw.Rect(cubePosition, height, height, CubeColorGetter());
DrawIcon(position, Icon, IconWidth, Height(), IconOutline, (Disabled ? Color.DarkSlateGray : highlighted ? Color.White : Color.LightSlateGray) * num, ref textPosition);
ActiveFont.DrawOutline(Label, textPosition, justify, Scale, color, 2f, strokeColor);
}
}
Expand Down
39 changes: 17 additions & 22 deletions Source/Module/Menu/PredictorMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ private static void AddDescriptionBothControl(this List<TextMenu.Item> page, Tex
itemBelow.OnLeave += () => descriptionText.FadeVisible = false;
}

private static Color hlineColor = Color.Lerp(Color.Gray, Color.Black, 0.2f);

private static HLine CreateHLine() {
return new HLine(Color.Gray);
}
private static HLine CreateHLine(string text) {
return new HLine(hlineColor, 20f, 0f, text, 0.4f);
}

internal static List<TextMenu.Item> Create_PageOnOff(TextMenu menu, bool inGame) {
List<TextMenu.Item> page = new List<TextMenu.Item>();
TextMenu.Item PredictItem;
Expand All @@ -35,14 +44,11 @@ private static void AddDescriptionBothControl(this List<TextMenu.Item> page, Tex
TasHelperSettings.TimelineLength = value;
Predictor.PredictorCore.InitializeCachePeriod();
}));

page.Add(new SubHeaderExt("Predict Start Conditions".ToDialogText()) {
TextColor = Color.Gray,
HeightExtra = 0f
});
page.Add(CreateHLine("Predict Start Conditions".ToDialogText()));
page.Add(new TextMenu.OnOff("Predict On Frame Step".ToDialogText(), TasHelperSettings.PredictOnFrameStep).Change(value => TasHelperSettings.PredictOnFrameStep = value));
page.Add(new TextMenu.OnOff("Predict On File Change".ToDialogText(), TasHelperSettings.PredictOnFileChange).Change(value => TasHelperSettings.PredictOnFileChange = value));
page.Add(new TextMenu.OnOff("Predict On Hotkey Pressed".ToDialogText(), TasHelperSettings.PredictOnHotkeyPressed).Change(value => TasHelperSettings.PredictOnHotkeyPressed = value));
page.Add(CreateHLine());
return page;
}

Expand All @@ -52,10 +58,7 @@ private static void AddDescriptionBothControl(this List<TextMenu.Item> page, Tex
page.Add(mainSwitchItem);
page.AddDescriptionOnEnter(menu, mainSwitchItem, "Keyframe Description".ToDialogText());
page.Add(new TextMenu.OnOff("Use Key Frame Time".ToDialogText(), TasHelperSettings.UseKeyFrameTime).Change(value => TasHelperSettings.UseKeyFrameTime = value));
page.Add(new SubHeaderExt("Key Frame Flags".ToDialogText()) {
TextColor = Color.Gray,
HeightExtra = 0f
});
page.Add(CreateHLine("Key Frame Flags".ToDialogText()));
TextMenu.Item gainLevelControlItem = new TextMenu.OnOff("Gain Level Control", TasHelperSettings.UseFlagGainLevelControl).Change(value => TasHelperSettings.UseFlagGainLevelControl = value);
TextMenu.Item loseLevelControlItem = new TextMenu.OnOff("Lose Level Control", TasHelperSettings.UseFlagLoseLevelControl).Change(value => TasHelperSettings.UseFlagLoseLevelControl = value);

Expand All @@ -70,26 +73,17 @@ private static void AddDescriptionBothControl(this List<TextMenu.Item> page, Tex
page.Add(losePlayerControlItem);
page.Add(new TextMenu.OnOff("Begin Engine Freeze", TasHelperSettings.UseFlagGainFreeze).Change(value => TasHelperSettings.UseFlagGainFreeze = value));
page.Add(new TextMenu.OnOff("End Engine Freeze", TasHelperSettings.UseFlagLoseFreeze).Change(value => TasHelperSettings.UseFlagLoseFreeze = value));

page.Add(CreateHLine());
return page;
}

internal static List<TextMenu.Item> Create_PageKeyframe_2(TextMenu menu, bool inGame) {
List<TextMenu.Item> page = new List<TextMenu.Item>();
page.Add(new SubHeaderExt("Key Frame Flags".ToDialogText()) {
TextColor = Color.Gray,
HeightExtra = 0f
});

page.Add(CreateHLine("Key Frame Flags".ToDialogText()));
page.Add(new TextMenu.OnOff("Gain On Ground", TasHelperSettings.UseFlagGainOnGround).Change(value => TasHelperSettings.UseFlagGainOnGround = value));

page.Add(new TextMenu.OnOff("Lose On Ground", TasHelperSettings.UseFlagLoseOnGround).Change(value => TasHelperSettings.UseFlagLoseOnGround = value));


page.Add(new TextMenu.OnOff("Gain Ultra", TasHelperSettings.UseFlagGainUltra).Change(value => TasHelperSettings.UseFlagGainUltra = value));

page.Add(new TextMenu.OnOff("On Bounce", TasHelperSettings.UseFlagOnBounce).Change(value => TasHelperSettings.UseFlagOnBounce = value));

TextMenu.Item onEntityStateItem = new TextMenu.OnOff("On Entity State", TasHelperSettings.UseFlagOnEntityState).Change(value => TasHelperSettings.UseFlagOnEntityState = value);
page.Add(onEntityStateItem);
page.AddDescriptionOnEnter(menu, onEntityStateItem, "Predictor On Entity State Description".ToDialogText());
Expand All @@ -104,7 +98,7 @@ private static void AddDescriptionBothControl(this List<TextMenu.Item> page, Tex
page.Add(new TextMenu.OnOff("Refill Dash", TasHelperSettings.UseFlagRefillDash).Change(value => TasHelperSettings.UseFlagRefillDash = value));
page.Add(new TextMenu.OnOff("Respawn Point Change", TasHelperSettings.UseFlagRespawnPointChange).Change(value => TasHelperSettings.UseFlagRespawnPointChange = value));
page.Add(new TextMenu.OnOff("Dead", TasHelperSettings.UseFlagDead).Change(value => TasHelperSettings.UseFlagDead = value));

page.Add(CreateHLine());
return page;
}

Expand All @@ -118,6 +112,7 @@ private static void AddDescriptionBothControl(this List<TextMenu.Item> page, Tex
page.AddDescriptionOnEnter(menu, fadeoutItem, "Only Apply To Hitbox".ToDialogText());
page.Add(new IntSlider("Predictor Line Width".ToDialogText(), 0, 20, TasHelperSettings.PredictorLineWidth).Change(value => TasHelperSettings.PredictorLineWidth = value));
page.Add(new IntSlider("Predictor Point Size".ToDialogText(), 0, 20, TasHelperSettings.PredictorPointSize).Change(value => TasHelperSettings.PredictorPointSize = value));
page.Add(CreateHLine());
return page;
}

Expand All @@ -144,7 +139,7 @@ private static void AddDescriptionBothControl(this List<TextMenu.Item> page, Tex
TextMenu.Item ultraSpeedItem = new IntSlider("Ultra Speed Lower Limit".ToDialogText(), 0, 325, TasHelperSettings.UltraSpeedLowerLimit).Change((value) => TasHelperSettings.UltraSpeedLowerLimit = value);
page.Add(ultraSpeedItem);
page.AddDescriptionOnEnter(menu, ultraSpeedItem, "Ultra Speed Lower Limit Description".ToDialogText());

page.Add(CreateHLine());

return page;
}
Expand Down
39 changes: 32 additions & 7 deletions Source/Module/Menu/TASHelperMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private static EaseInSubMenu CreateSimplifiedGraphicSubMenu(TextMenu menu) {
subMenu.Add(new TextMenu.OnOff("Spinner Dashed Border".ToDialogText(), TasHelperSettings.SimplifiedSpinnerDashedBorder).Change(value => TasHelperSettings.SimplifiedSpinnerDashedBorder = value));
subMenu.Add(new TextMenu.OnOff("Spinner_Ignore_TAS_UncollidableAlpha".ToDialogText(), TasHelperSettings.Ignore_TAS_UnCollidableAlpha).Change(value => TasHelperSettings.Ignore_TAS_UnCollidableAlpha = value));
subMenu.Add(new TextMenu.OnOff("ACH For Spinner".ToDialogText(), TasHelperSettings.ApplyActualCollideHitboxForSpinner).Change(value => TasHelperSettings.ApplyActualCollideHitboxForSpinner = value));
subMenu.Add(new HLine());
subMenu.Add(new HLine(Color.Gray));
TextMenu.Item simplifiedLightning;
subMenu.Add(simplifiedLightning = new TextMenuExt.EnumerableSlider<SimplifiedGraphicsMode>("Simplified Lightning".ToDialogText(), CreateSimplifiedGraphicsModeOptions(), TasHelperSettings.EnableSimplifiedLightningMode).Change(value => TasHelperSettings.EnableSimplifiedLightningMode = value));
subMenu.AddDescription(menu, simplifiedLightning, "Simplified Lightning Description".ToDialogText());
Expand All @@ -106,11 +106,12 @@ private static EaseInSubMenu CreateSimplifiedGraphicSubMenu(TextMenu menu) {
TextMenu.Item ACH_LightningItem;
subMenu.Add(ACH_LightningItem = new TextMenu.OnOff("ACH For Lightning".ToDialogText(), TasHelperSettings.ApplyActualCollideHitboxForLightning).Change(value => TasHelperSettings.ApplyActualCollideHitboxForLightning = value));
subMenu.AddDescription(menu, ACH_LightningItem, "ACH Warn Lightning".ToDialogText());
subMenu.Add(new HLine());
subMenu.Add(new HLine(Color.Gray));
TextMenu.Item simplifiedTrigger;
subMenu.Add(simplifiedTrigger = new TextMenuExt.EnumerableSlider<SimplifiedGraphicsMode>("Simplified Triggers".ToDialogText(), CreateSimplifiedGraphicsModeOptions(), TasHelperSettings.EnableSimplifiedTriggersMode).Change(value => TasHelperSettings.EnableSimplifiedTriggersMode = value));
subMenu.Add(new TextMenu.OnOff("Hide Camera Trigger".ToDialogText(), TasHelperSettings.HideCameraTriggers).Change(value => TasHelperSettings.HideCameraTriggers = value));
subMenu.Add(new TextMenu.OnOff("Hide Gold Berry".ToDialogText(), TasHelperSettings.HideGoldBerryCollectTrigger).Change(value => TasHelperSettings.HideGoldBerryCollectTrigger = value));
subMenu.Add(new HLine(Color.Gray));
});
}

Expand Down Expand Up @@ -405,7 +406,6 @@ public override float Height() {
public override void Update() {
base.Update();
TitleLerp = Calc.Clamp(TitleLerp + 10f * Math.Sign(TitleLerpTarget - TitleLerp) * Engine.DeltaTime, 0, 1);

}
}

Expand Down Expand Up @@ -593,10 +593,23 @@ public override void Update() {
}

public class HLine : TextMenu.Item {
public float margins;
public HLine(float margins = 0f) {
public Color lineColor;

public float leftMargin;

public float rightMargin;

public string text;

public float textHorizontalAlign;

public HLine(Color color, float leftMargin = 20f, float rightMargin = 0f, string label = "", float textAlign = 0.5f) {
Selectable = false;
this.margins = margins;
lineColor = color;
this.leftMargin = leftMargin;
this.rightMargin = rightMargin;
text = label;
textHorizontalAlign = textAlign;
}

public override float LeftWidth() {
Expand All @@ -612,6 +625,18 @@ public override float Height() {
}

public override void Render(Vector2 position, bool highlighted) {
Monocle.Draw.Line(new Vector2(Container.X - Container.Width / 2f + margins, position.Y), new Vector2(Container.X + Container.Width / 2f - margins, position.Y), Color.Gray, 4f);
float left = Container.X - Container.Width / 2f + leftMargin;
float right = Container.X + Container.Width / 2f - rightMargin;
float y = position.Y;
if (text.IsNullOrEmpty()) {
Monocle.Draw.Line(new Vector2(left, y), new Vector2(right, y), lineColor, 4f);
}
else {
float textCenter = MathHelper.Lerp(left, right, textHorizontalAlign);
float haldWidth = ActiveFont.Measure(text).X / 2f * 0.6f + 10f;
ActiveFont.DrawOutline(text, new Vector2(textCenter, y), new Vector2(0.5f, 0.5f), Vector2.One * 0.6f, Color.Gray, 2f, Color.Black);
Monocle.Draw.Line(new Vector2(left, y), new Vector2(textCenter - haldWidth, y), lineColor, 4f);
Monocle.Draw.Line(new Vector2(textCenter + haldWidth, y), new Vector2(right, y), lineColor, 4f);
}
}
}
Loading

0 comments on commit 09c7dad

Please sign in to comment.