diff --git a/src/SPCoopEmotesConfig.cs b/src/SPCoopEmotesConfig.cs index 38721dc..393b515 100644 --- a/src/SPCoopEmotesConfig.cs +++ b/src/SPCoopEmotesConfig.cs @@ -7,6 +7,12 @@ public class SPCoopEmotesConfig : OptionInterface { public static Configurable PointInput; + // The instruction text explaining how to point in-game. + private OpLabel pointingLabel; + // The keybinder for the pointing emote button. + private OpKeyBinder keyBinder; + // (Both only used in `Update()`) + public SPCoopEmotesConfig() { PointInput = config.Bind("PointInput", KeyCode.Space, new ConfigurableInfo("Input a button to change the pointing keybind. (Note: The map key requires a double-tap and hold)", tags: new object[] @@ -15,7 +21,7 @@ public SPCoopEmotesConfig() })); } - // Pretty much entirely taken from the music announcements config menu. + // This is all mostly just taken from the music announcements config menu. public override void Initialize() { base.Initialize(); @@ -27,9 +33,35 @@ public override void Initialize() AddDivider(593f); AddTitle(); AddDivider(540f); + AddControlsText(); AddKeyBinder(); } + // Updates the text for the pointing instructions based on the current value in `keyBinder`. + // If the player is using the default map key then a double tap is required to start pointing, so this changes to reflect that. + public override void Update() + { + string newText; + + // Default keybind. + if (keyBinder.value == PointInput.defaultValue) + { + newText = "Double tap and hold the Point button with a movement input to start pointing in a direction."; + } + // Custom keybind. + else + { + newText = "Press and hold the Point button with a movement input to start pointing in a direction."; + } + + // Only go through the effort of updating it if the text has actually changed. + if (pointingLabel.text != newText) + { + pointingLabel.text = newText; + } + } + + // Combines two flipped 'LinearGradient200's together to make a fancy looking divider. private void AddDivider(float y) { OpImage dividerLeft = new OpImage(new Vector2(300f, y), "LinearGradient200"); @@ -47,6 +79,7 @@ private void AddDivider(float y) }); } + // Adds the mod name and version to the interface between two dividers. private void AddTitle() { OpLabel title = new OpLabel(new Vector2(150f, 560f), new Vector2(300f, 30f), "Singleplayer Co-op Emotes", bigText: true); @@ -59,14 +92,33 @@ private void AddTitle() }); } + // Adds control instructions for each emote. + private void AddControlsText() + { + OpLabel titleLabel = new OpLabel(new Vector2(150f, 480f), new Vector2(300f, 30f), "Controls:", bigText: true); + + // The text for this is added in `Update()`. + pointingLabel = new OpLabel(new Vector2(150f, titleLabel.pos.y - 25f), new Vector2(300f, 30f)); + + OpLabel sleepingLabel = new OpLabel(new Vector2(150f, titleLabel.pos.y - 45f), new Vector2(300f, 30f), "Hold Down while crawling to curl up into a ball and sleep."); + + Tabs[0].AddItems(new UIelement[] + { + titleLabel, + pointingLabel, + sleepingLabel + }); + } + + // Adds a keybinder (and label) to the interface so that the pointing emote button can be rebound. private void AddKeyBinder() { - OpKeyBinder keyBinder = new OpKeyBinder(PointInput, new Vector2(240, 475f), new Vector2(120f, 50f), false) + keyBinder = new OpKeyBinder(PointInput, new Vector2(240f, 360f), new Vector2(120f, 50f), false) { description = PointInput.info.description }; - OpLabel keyBinderLabel = new OpLabel(new Vector2(150f, 450f), new Vector2(300f, 30f), PointInput.info.Tags[0] as string); + OpLabel keyBinderLabel = new OpLabel(new Vector2(150f, keyBinder.pos.y - 25f), new Vector2(300f, 30f), PointInput.info.Tags[0] as string); Tabs[0].AddItems(new UIelement[] {