Exemplo n.º 1
0
        private void readCommand(string cmd)
        {
            _originalCmd = cmd;

            if (!MainMenuUtils.FindCommandByPath(cmd, out _cmds, out _commandIndex))
            {
                throw new ArgumentException($"Command {cmd} not found.");
            }
        }
Exemplo n.º 2
0
        public void testFindCommandByPath()
        {
            CMainMenuCommands cmds;
            uint index;

            AssertEquals(MainMenuUtils.FindCommandByPath("Playback/Order/Random", out cmds, out index), true);
            AssertEquals(MainMenuUtils.FindCommandByPath("nocommand/nocommand/nocommand", out cmds, out index), false);
            AssertEquals(MainMenuUtils.FindCommandByPath("Help/About", out cmds, out index), true);
            AssertEquals(MainMenuUtils.FindCommandByPath("File/Preferences", out cmds, out index), true);
            AssertEquals(MainMenuUtils.FindCommandByPath("File/nocommand", out cmds, out index), false);
            AssertEquals(MainMenuUtils.FindCommandByPath("Playback/Order/Random/nocommand", out cmds, out index), false);
            AssertEquals(MainMenuUtils.FindCommandByPath("Playback/Order/nocommand", out cmds, out index), false);
        }
Exemplo n.º 3
0
        public static void CreateError(string error, bool doAbort = true)
        {
            SRCallbacks.OnMainMenuLoaded += ((u) =>
            {
                var mainmen = MainMenuUtils.DisplayBlankPanelWithTranslation <BaseUI>(u, "ErrorUI", "t.srml_error", () => Application.Quit());
                var panel = mainmen.transform.GetChild(0);
                var title = panel.Find("Title").gameObject;
                var g = GameObject.Instantiate(title);
                g.name = "ErrorText";
                MonoBehaviour.Destroy(g.GetComponent <XlateText>());
                g.GetComponent <TMP_Text>().text = error;
                g.GetComponent <TMP_Text>().alignment = TextAlignmentOptions.Top;
                g.GetComponent <TMP_Text>().fontSize *= .8f;
                g.GetComponent <TMP_Text>().enableWordWrapping = true;
                if (doAbort)
                {
                    var h = GameObject.Instantiate(title);
                    h.name = "AbortText";
                    h.GetComponent <TMP_Text>().enableWordWrapping = true;

                    h.GetComponent <XlateText>().SetKey("t.srml_abort");
                    h.GetComponent <TMP_Text>().alignment = TextAlignmentOptions.Bottom;

                    h.transform.SetParent(panel, false);
                    var rect2 = h.GetComponent <RectTransform>();
                    rect2.anchorMin = new Vector2(0, 0);
                    rect2.anchorMax = new Vector2(1, 1);
                    rect2.offsetMax = new Vector2(-50, -100);
                    rect2.offsetMin = new Vector2(50, 30);
                }

                g.transform.SetParent(panel, false);
                var rect = g.GetComponent <RectTransform>();
                rect.anchorMin = new Vector2(0, 0);
                rect.anchorMax = new Vector2(1, 1);
                rect.offsetMax = new Vector2(-50, -100);
                rect.offsetMin = new Vector2(50, 30);
            });
        }
Exemplo n.º 4
0
        internal static void OnMainMenuLoaded(MainMenuUI ui)
        {
            MainMenuUtils.AddMainMenuButton(ui, "Mods", () =>
            {
                var g = MainMenuUtils.DisplayBlankPanel <BaseUI>(ui, "Mods");
                GameObject.Instantiate(mainMenuUIPrefab)
                .transform.SetParent(g.transform.GetChild(0), false);
            }).transform.SetSiblingIndex(5);

            if (mainMenuUIPrefab)
            {
                return;
            }

            var bundle = AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly()
                                                    .GetManifestResourceStream(typeof(ModMenuUIHandler), "srml"));
            var h = bundle.LoadAsset <GameObject>("ModPanel");

            h.AddComponent <ModMenuUI>().infoButtonPrefab = bundle.LoadAsset <GameObject>("ModInfoButton");
            FixStyles(h);
            h.GetComponent <Image>().color = Color.green;
            mainMenuUIPrefab = h;
        }