summary refs log tree commit diff stats
path: root/tools/assign_ids/CMakeLists.txt
Commit message (Collapse)AuthorAgeFilesLines
* Added support for masteriesStar Rauchenberger2025-08-091-2/+2
| | | | | Also assigned IDs for the_butterfly, as well as already configured letters.
* Assign AP IDs to doors and panels protoStar Rauchenberger2025-08-071-0/+9
#n55'>55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
using AnodyneSharp.Input;
using AnodyneSharp.Registry;
using AnodyneSharp.Sounds;
using AnodyneSharp.UI;
using AnodyneSharp.UI.PauseMenu;
using AnodyneSharp.UI.PauseMenu.Config;
using Microsoft.Xna.Framework;

namespace AnodyneArchipelago.Menu
{
    internal class MenuState : AnodyneSharp.States.State
    {
        private MenuSelector _selector;
        private UILabel _versionLabel1;
        private UILabel _versionLabel2;
        private UILabel _serverLabel;
        private UILabel _serverValue;
        private UILabel _slotLabel;
        private UILabel _slotValue;
        private UILabel _passwordLabel;
        private UILabel _passwordValue;
        private TextSelector _connectionSwitcher;
        private UILabel _connectLabel;
        private UILabel _settingsLabel;
        private UILabel _quitLabel;

        private string _apServer = "";
        private string _apSlot = "";
        private string _apPassword = "";

        private int _selectorIndex = 0;

        public override void Create()
        {
            _selector = new();
            _selector.Play("enabledRight");

            _versionLabel1 = new(new Vector2(10f, 7f), false, "AnodyneArchipelago", new Color(116, 140, 144));
            _versionLabel2 = new(new Vector2(10f, 15f), false, $"v{Plugin.GetVersion()}", new Color(116, 140, 144));
            _serverLabel = new(new Vector2(10f, 31f), false, $"Server:", new Color(226, 226, 226));
            _serverValue = new(new Vector2(18f, 39f), false, "", new Color());
            _slotLabel = new(new Vector2(10f, 51f), false, $"Slot:", new Color(226, 226, 226));
            _slotValue = new(new Vector2(18f, 59f), false, "", new Color());
            _passwordLabel = new(new Vector2(10f, 71f), false, $"Password:", new Color(226, 226, 226));
            _passwordValue = new(new Vector2(18f, 79f), false, "", new Color());
            _connectLabel = new(new Vector2(60f, 115f), false, $"Connect", new Color(116, 140, 144));
            _settingsLabel = new(new Vector2(60f, 131f), false, $"Config", new Color(116, 140, 144));
            _quitLabel = new(new Vector2(60f, 147f), false, $"Quit", new Color(116, 140, 144));

            _connectionSwitcher = new(new Vector2(60f, 95f), 32f, 0, true, new string[1] { "1/1" });
            _connectionSwitcher.noConfirm = true;
            _connectionSwitcher.noLoop = true;
            _connectionSwitcher.ValueChangedEvent = PageValueChanged;

            SetCursorPosition(0);
            UpdateLabels();
        }

        public override void Initialize()
        {
        }

        public override void Update()
        {
            _selector.Update();
            _selector.PostUpdate();

            if (_selectorIndex == 3)
            {
                _connectionSwitcher.Update();
            }

            BrowseInput();
        }

        public override void Draw()
        {
        }

        public override void DrawUI()
        {
            _selector.Draw();
            _versionLabel1.Draw();
            _versionLabel2.Draw();
            _serverLabel.Draw();
            _serverValue.Draw();
            _slotLabel.Draw();
            _slotValue.Draw();
            _passwordLabel.Draw();
            _passwordValue.Draw();
            _connectionSwitcher.Draw();
            _connectLabel.Draw();
            _settingsLabel.Draw();
            _quitLabel.Draw();
        }

        private void SetCursorPosition(int i)
        {
            _selectorIndex = i;

            if (_selectorIndex == 0)
            {
                _selector.Position = new(2f, 34f);
            }
            else if (_selectorIndex == 1)
            {
                _selector.Position = new(2f, 54f);
            }
            else if (_selectorIndex == 2)
            {
                _selector.Position = new(2f, 74f);
            }
            else if (_selectorIndex == 4)
            {
                _selector.Position = new(52f, 118f);
            }
            else if (_selectorIndex == 5)
            {
                _selector.Position = new(52f, 134f);
            }
            else if (_selectorIndex == 6)
            {
                _selector.Position = new(52f, 150f);
            }

            if (_selectorIndex == 3)
            {
                _selector.visible = false;
                _connectionSwitcher.GetControl();
            }
            else
            {
                _selector.visible = true;
                _connectionSwitcher.LoseControl();
            }
        }

        private void UpdateLabels()
        {
            UpdateLabel(_serverValue, _apServer);
            UpdateLabel(_slotValue, _apSlot);
            UpdateLabel(_passwordValue, _apPassword);
        }

        private void UpdateLabel(UILabel label, string text)
        {
            if (text.Length == 0)
            {
                label.SetText("[empty]");
                label.Color = new Color(116, 140, 144);
            }
            else
            {
                if (text.Length > 20)
                {
                    label.SetText(text.Substring(0, 17) + "...");
                }
                else
                {
                    label.SetText(text);
                }
                
                label.Color = new Color(184, 32, 0);
            }
        }

        private void BrowseInput()
        {
            if (KeyInput.JustPressedRebindableKey(KeyFunctions.Up))
            {
                SoundManager.PlaySoundEffect("menu_move");
                if (_selectorIndex > 0)
                {
                    SetCursorPosition(_selectorIndex - 1);
                }
            }
            else if (KeyInput.JustPressedRebindableKey(KeyFunctions.Down))
            {
                SoundManager.PlaySoundEffect("menu_move");
                if (_selectorIndex < 6)
                {
                    SetCursorPosition(_selectorIndex + 1);
                }
            }
            else if (KeyInput.JustPressedRebindableKey(KeyFunctions.Accept))
            {
                switch (_selectorIndex)
                {
                    case 6:
                        GlobalState.ClosingGame = true;
                        break;
                    default:
                        // Hi
                        break;
                }
            }
        }

        private void PageValueChanged(string value, int index)
        {

        }
    }
}