示例#1
0
 private void CloseMenu()
 {
     Audio.Play(SFX.ui_game_unpause);
     Audio.Resume(sfx);
     menu?.RemoveSelf();
     menu = null;
 }
示例#2
0
        /// <summary>
        /// Add an Enter and Leave handler, displaying a description if selected.
        /// </summary>
        /// <param name="option">The input TextMenu.Item option.</param>
        /// <param name="containingMenu">The menu containing the TextMenu.Item option.</param>
        /// <param name="description"></param>
        /// <returns>The passed option.</returns>
        public static TextMenu.Item AddDescription(this TextMenu.Item option, TextMenu containingMenu, string description)
        {
            // build the description menu entry
            TextMenuExt.EaseInSubHeaderExt descriptionText = new TextMenuExt.EaseInSubHeaderExt(description, false, containingMenu)
            {
                TextColor   = Color.Gray,
                HeightExtra = 0f
            };

            List <TextMenu.Item> items = containingMenu.GetItems();

            if (items.Contains(option))
            {
                // insert the description after the option.
                containingMenu.Insert(items.IndexOf(option) + 1, descriptionText);
            }

            option.OnEnter += delegate {
                // make the description appear.
                descriptionText.FadeVisible = true;
            };
            option.OnLeave += delegate {
                // make the description disappear.
                descriptionText.FadeVisible = false;
            };

            return(option);
        }
示例#3
0
        private void ReloadMenu()
        {
            Vector2 position = Vector2.Zero;

            int selected = -1;

            if (menu != null)
            {
                position = menu.Position;
                selected = menu.Selection;
                Scene.Remove(menu);
            }

            menu = CreateMenu(false, null);

            if (selected >= 0)
            {
                menu.Selection = selected;
                menu.Position  = position;
            }
            IEnumerable <TextMenu> menus = Scene.Entities.OfType <TextMenu>();

            Scene.Remove(menus);
            Scene.Add(menu);
        }
示例#4
0
        public override void CreateModMenuSection(TextMenu menu, bool inGame, EventInstance snapshot)
        {
            // Optional - reload mod settings when entering the mod options.
            LoadSettings();

            if (!inGame)
            {
                if (Everest.Updater.HasUpdate)
                {
                    menu.Add(new TextMenu.Button(Dialog.Clean("modoptions_coremodule_update").Replace("((version))", Everest.Updater.Newest.Version.ToString())).Pressed(() => {
                        Everest.Updater.Update(OuiModOptions.Instance.Overworld.Goto <OuiLoggedProgress>());
                    }));
                }

                // Allow downgrading travis / dev builds.
                if (Celeste.PlayMode == Celeste.PlayModes.Debug || Everest.VersionSuffix.StartsWith("travis-") || Everest.VersionSuffix == "dev")
                {
                    menu.Add(new TextMenu.Button(Dialog.Clean("modoptions_coremodule_versionlist")).Pressed(() => {
                        OuiModOptions.Instance.Overworld.Goto <OuiVersionList>();
                    }));
                }
            }

            base.CreateModMenuSection(menu, inGame, snapshot);

            if (!inGame)
            {
                menu.Add(new TextMenu.Button(Dialog.Clean("modoptions_coremodule_soundtest")).Pressed(() => {
                    OuiModOptions.Instance.Overworld.Goto <OuiSoundTest>();
                }));
            }
        }
        private void EndlessCantRestartSnarky(On.Celeste.Level.orig_GiveUp orig, Level self, int returnIndex, bool restartArea, bool minimal, bool showHint)
        {
            var settings = this.InRandomizerSettings;

            if (settings == null || settings.Algorithm != LogicType.Endless || !restartArea)
            {
                orig(self, returnIndex, restartArea, minimal, showHint);
                return;
            }

            self.Paused = true;
            var menu = new TextMenu()
            {
                new TextMenu.Header(Dialog.Clean("MENU_CANTRESTART_HEADER")),
            };

            menu.AutoScroll = false;
            menu.OnPause    = menu.OnESC = () => {
                menu.RemoveSelf();
                self.Paused        = false;
                Engine.FreezeTimer = 0.15f;
                Audio.Play("event:/ui/game/unpause");
            };
            menu.OnCancel = () => {
                Audio.Play("event:/ui/main/button_back");
                menu.RemoveSelf();
                self.Pause(returnIndex, minimal);
            };
            self.Add(menu);
        }
示例#6
0
        public static EaseInSubMenu CreateSubMenu(TextMenu menu, bool inGame)
        {
            subMenuItem = new EaseInSubMenu("Show Hitboxes".ToDialogText(), false).Apply(subMenu => {
                subMenu.Add(new TextMenu.OnOff("Enabled".ToDialogText(), Settings.ShowHitboxes).Change(value => Settings.ShowHitboxes = value));
                subMenu.Add(new TextMenu.OnOff("Show Trigger Hitboxes".ToDialogText(), Settings.ShowTriggerHitboxes).Change(value =>
                                                                                                                            Settings.ShowTriggerHitboxes = value));
                subMenu.Add(new TextMenu.OnOff("Show Unloaded Rooms Hitboxes".ToDialogText(), Settings.ShowUnloadedRoomsHitboxes).Change(value =>
                                                                                                                                         Settings.ShowUnloadedRoomsHitboxes = value));
                subMenu.Add(new TextMenu.Option <ActualCollideHitboxType>("Actual Collide Hitboxes".ToDialogText()).Apply(option => {
                    Array enumValues = Enum.GetValues(typeof(ActualCollideHitboxType));
                    foreach (ActualCollideHitboxType value in enumValues)
                    {
                        option.Add(value.ToString().SpacedPascalCase().ToDialogText(), value, value.Equals(Settings.ShowActualCollideHitboxes));
                    }

                    option.Change(value => Settings.ShowActualCollideHitboxes = value);
                }));
                subMenu.Add(new TextMenu.OnOff("Simplified Hitboxes".ToDialogText(), Settings.SimplifiedHitboxes).Change(value =>
                                                                                                                         Settings.SimplifiedHitboxes = value));
                subMenu.Add(HitboxColor.CreateEntityHitboxColorButton(menu, inGame));
                subMenu.Add(HitboxColor.CreateTriggerHitboxColorButton(menu, inGame));
                subMenu.Add(HitboxColor.CreatePlatformHitboxColorButton(menu, inGame));
            });
            return(subMenuItem);
        }
示例#7
0
        public override void CreateModMenuSection(TextMenu menu, bool inGame, EventInstance snapshot)
        {
            // Optional - reload mod settings when entering the mod options.
            LoadSettings();

            base.CreateModMenuSection(menu, inGame, snapshot);

            if (!inGame)
            {
                menu.Add(new TextMenu.Button(Dialog.Clean("modoptions_coremodule_oobe")).Pressed(() => {
                    OuiModOptions.Instance.Overworld.Goto <OuiOOBE>();
                }));

                menu.Add(new TextMenu.Button(Dialog.Clean("modoptions_coremodule_soundtest")).Pressed(() => {
                    OuiModOptions.Instance.Overworld.Goto <OuiSoundTest>();
                }));

                menu.Add(new TextMenu.Button(Dialog.Clean("modoptions_coremodule_versionlist")).Pressed(() => {
                    OuiModOptions.Instance.Overworld.Goto <OuiVersionList>();
                }));

                menu.Add(new TextMenu.Button(Dialog.Clean("modoptions_coremodule_modupdates")).Pressed(() => {
                    OuiModOptions.Instance.Overworld.Goto <OuiModUpdateList>();
                }));

                menu.Add(new TextMenu.Button(Dialog.Clean("modoptions_coremodule_togglemods")).Pressed(() => {
                    OuiModOptions.Instance.Overworld.Goto <OuiModToggler>();
                }));
            }
        }
示例#8
0
        private void GiveUp(int returnIndex, bool restartArea, bool minimal, bool showHint)
        {
            GiveUpHint hint = null;

            if (!Everest.Flags.IsDisabled && !restartArea && !showHint)
            {
                // The game originally doesn't show a hint when exiting to the map.
                Add(hint = new GiveUpHint());
            }

            orig_GiveUp(returnIndex, restartArea, minimal, showHint);

            TextMenu menu = Entities.GetToAdd().LastOrDefault(e => e is TextMenu) as TextMenu;

            if (menu == null)
            {
                return;
            }

            Action removeHint = () => hint?.RemoveSelf();

            menu.OnPause  += removeHint;
            menu.OnESC    += removeHint;
            menu.OnCancel += removeHint;
        }
示例#9
0
        static void Main(string[] args)
        {
            IStmt stmt1 = new CompStmt(new CompStmt(
                                           new OpenRFile("varf", "read.txt"),
                                           new ReadFile(new VarExp("varf"), "varc")
                                           ),
                                       new CompStmt(
                                           new PrintStmt(new VarExp("varc")),
                                           new CloseRFile("varf")
                                           )

                                       );
            IMyStack <IStmt>            exec    = new MyStack <IStmt>();
            IMyDictionary <String, int> symbolT = new MyDictionary <String, int>();
            IMyList <int> msg = new MyList <int>();
            IMyFileTable <int, FileData> filet = new MyFileTable <int, FileData>();
            PrgState prg1 = new PrgState(exec, symbolT, msg, filet, stmt1);

            IRepository repo1 = new Repository("log1.txt");
            Controller  ctr1  = new Controller(repo1);

            repo1.AddPrgState(prg1);
            TextMenu menu = new TextMenu();

            menu.AddCommand(new ExitCommand("0", "exit"));
            menu.AddCommand(new RunExample("1", stmt1.ToString(), ctr1));
            menu.Show();
        }
示例#10
0
        protected virtual void CreateModMenuSectionHeader(TextMenu menu, bool inGame, EventInstance snapshot)
        {
            Type type = SettingsType;
            EverestModuleSettings settings = _Settings;

            if (type == null || settings == null)
            {
                return;
            }

            string typeName = type.Name.ToLowerInvariant();

            if (typeName.EndsWith("settings"))
            {
                typeName = typeName.Substring(0, typeName.Length - 8);
            }
            string nameDefaultPrefix = $"modoptions_{typeName}_";

            string name; // We lazily reuse this field for the props later on.

            name = type.GetCustomAttribute <SettingNameAttribute>()?.Name ?? $"{nameDefaultPrefix}title";
            name = name.DialogCleanOrNull() ?? ModUpdaterHelper.FormatModName(Metadata.Name);

            menu.Add(new patch_TextMenu.patch_SubHeader(name + " | v." + Metadata.VersionString));
        }
 private static void TrySetNeedRelaunch(TextMenu textMenu, TextMenu.Item item)
 {
     if (item is TextMenu.OnOff onOffItem && needRelaunchItemLabels.Contains(onOffItem.Label))
     {
         item.NeedsRelaunch(textMenu);
     }
 }
示例#12
0
        protected override void OnStart()
        {
            _background = Content.Load <Texture2D>("Textures/Background");

            _menu               = new TextMenu(AppContents.DefaultFont);
            _menu.ItemHovered  += (item) => { _soundsManager.PlaySound(SoundName.Blip5); };
            _menu.Pos           = new Vector2(100, 150);
            _menu.Padding       = AppConstants.MenuPadding;
            _menu.Color         = AppColors.MenuItems;
            _menu.ColorDisabled = AppColors.MenuItemsDisabled;
            _menu.ColorHover    = AppColors.MenuItemsHover;

            var itemNew = _menu.CreateItem("New game");

            itemNew.Clicked += ItemNew_Clicked;

            var itemContinueLast = _menu.CreateItem("Continue");

            itemContinueLast.Clicked += ItemContinueLast_Clicked;

            var itemHighscore = _menu.CreateItem("Highscores");

            itemHighscore.Clicked += ItemHighscore_Clicked;
            itemHighscore.Margin   = new Padding(0, 15, 0, 0);

            var itemSettings = _menu.CreateItem("Settings");

            itemSettings.Clicked += ItemSettings_Clicked;
            itemSettings.Margin   = new Padding(0, 15, 0, 0);

            var itemEnd = _menu.CreateItem("Exit");

            itemEnd.Margin   = new Padding(0, 45, 0, 0);
            itemEnd.Clicked += ItemEnd_Clicked;
        }
示例#13
0
        public override IEnumerator Leave(Oui next)
        {
            Audio.SetMusic(audioPrevMusic);
            Audio.SetAmbience(audioPrevAmbience);
            Audio.Play(SFX.ui_main_whoosh_large_out);

            if (playing != null)
            {
                Audio.Stop(playing);
            }

            Focused = false;

            Vector2 posFrom = Position;
            Vector2 posTo   = new Vector2(0f, 1080f);

            for (float t = 0f; t < 1f; t += Engine.DeltaTime * 2f)
            {
                ease     = 1f - Ease.CubeIn(t);
                Position = posFrom + (posTo - posFrom) * Ease.CubeInOut(t);
                yield return(null);
            }

            Visible = false;

            musicParamMenu = null;
            playingPath    = null;
        }
 private static void ToggleMoreOptionsMenuItem(TextMenu textMenu, bool visible)
 {
     foreach (TextMenu.Item item in hiddenOptions)
     {
         item.Visible = visible;
     }
 }
示例#15
0
        /// <summary>
        /// Add an Enter and Leave handler, notifying the user that a relaunch is required to apply the changes.
        /// </summary>
        /// <param name="option">The input TextMenu.Item option.</param>
        /// <param name="containingMenu">The menu containing the TextMenu.Item option.</param>
        /// <param name="needsRelaunch">This method does nothing if this is set to false.</param>
        /// <returns>The passed option.</returns>
        public static TextMenu.Item NeedsRelaunch(this TextMenu.Item option, TextMenu containingMenu, bool needsRelaunch = true)
        {
            if (!needsRelaunch)
            {
                return(option);
            }

            // build the "Restart is required" text menu entry
            TextMenuExt.EaseInSubHeaderExt needsRelaunchText = new TextMenuExt.EaseInSubHeaderExt(Dialog.Clean("MODOPTIONS_NEEDSRELAUNCH"), false, containingMenu)
            {
                TextColor   = Color.OrangeRed,
                HeightExtra = 0f
            };

            List <TextMenu.Item> items = containingMenu.GetItems();

            if (items.Contains(option))
            {
                // insert the text after the option that needs relaunch.
                containingMenu.Insert(items.IndexOf(option) + 1, needsRelaunchText);
            }

            option.OnEnter += delegate {
                // make the description appear.
                needsRelaunchText.FadeVisible = true;
            };
            option.OnLeave += delegate {
                // make the description disappear.
                needsRelaunchText.FadeVisible = false;
            };

            return(option);
        }
示例#16
0
        private void addFileToMenu(TextMenu menu, string file)
        {
            TextMenu.OnOff option;

            bool enabled = !Everest.Loader._Blacklist.Contains(file);

            menu.Add(option = (TextMenu.OnOff) new TextMenu.OnOff(file.Length > 40 ? file.Substring(0, 40) + "..." : file, enabled)
                              .Change(b => {
                if (b)
                {
                    removeFromBlacklist(file);
                }
                else
                {
                    addToBlacklist(file);
                }

                updateHighlightedMods();
            }));

            allMods.Add(file);
            if (!enabled)
            {
                blacklistedMods.Add(file);
            }

            modToggles[file] = option;
        }
        public void CreateEnabledEntry(TextMenu menu, bool inGame)
        {
            TextMenu.OnOff button = new TextMenu.OnOff(DialogIds.Enabled.DialogClean(), Enabled)
            {
                OnValueChange = value => {
                    Enabled = value;

                    bool mineItem       = false;
                    int  mineItemsCount = 2;
                    foreach (TextMenu.Item item in menu.Items)
                    {
                        if (item == menu.Current && !mineItem)
                        {
                            mineItem = true;
                            continue;
                        }

                        if (!mineItem || mineItemsCount <= 0)
                        {
                            continue;
                        }

                        mineItemsCount--;
                        item.Visible = value;
                    }
                }
            };

            menu.Add(button);
        }
示例#18
0
 public override void CreateModMenuSection(TextMenu menu, bool inGame, EventInstance snapshot)
 {
     if (!inGame)
     {
         base.CreateModMenuSection(menu, inGame, snapshot);
     }
 }
        static void Main(string[] args)
        {
            IStatement ex1 = new CompoundStatement(new AssignStatement("v", new ConstantExpression(2)),
                                                   new PrintStatement(new VariableExpression("v")));

            IStatement ex2 = new CompoundStatement(new AssignStatement("a", new ArithmeticExpression(new ConstantExpression(2), new
                                                                                                     ArithmeticExpression(new ConstantExpression(3), new ConstantExpression(5), Operation.MULTIPLY), Operation.ADD)),
                                                   new CompoundStatement(new AssignStatement("b", new ArithmeticExpression(new VariableExpression("a"), new
                                                                                                                           ConstantExpression(1), Operation.ADD)), new PrintStatement(new VariableExpression("b"))));

            IStatement ex3 = new CompoundStatement(new AssignStatement("a", new ArithmeticExpression(new ConstantExpression(2), new ConstantExpression(2), Operation.SUBTRACT)),
                                                   new CompoundStatement(new IfStatement(new VariableExpression("a"), new AssignStatement("v", new ConstantExpression(2)),
                                                                                         new AssignStatement("v", new ConstantExpression(3))), new PrintStatement(new VariableExpression("v"))));

            IStatement ex4 = new CompoundStatement(new OpenStatement("var_f", "test1.in"),
                                                   new CompoundStatement(new ReadStatement(new VariableExpression("var_f"), "var_c"),
                                                                         new CompoundStatement(new PrintStatement(new VariableExpression("var_c")),
                                                                                               new CompoundStatement(new IfStatement(new VariableExpression("var_c"),
                                                                                                                                     new CompoundStatement(new ReadStatement(new VariableExpression("var_f"), "var_c"),
                                                                                                                                                           new PrintStatement(new VariableExpression("var_c"))), new PrintStatement(new ConstantExpression(0))),
                                                                                                                     new CloseStatement(new VariableExpression("var_f"))))));

            TextMenu menu = new TextMenu(new MyDictionary <string, Command>(new Dictionary <string, Command>()));

            menu.AddCommand(new ExitCommand("0", "exit"));
            menu.AddCommand(new RunCommand("1", ex1.ToString(), CreateController(ex1, "log1.txt")));
            menu.AddCommand(new RunCommand("2", ex2.ToString(), CreateController(ex2, "log2.txt")));
            menu.AddCommand(new RunCommand("3", ex3.ToString(), CreateController(ex3, "log3.txt")));
            menu.AddCommand(new RunCommand("4", ex4.ToString(), CreateController(ex4, "log4.txt")));

            menu.show();
        }
示例#20
0
        private void ModifyLevelMenu(Level level, TextMenu pausemenu, bool minimal)
        {
            if (this.InRandomizer)
            {
                foreach (var item in new System.Collections.Generic.List <TextMenu.Item>(pausemenu.GetItems()))
                {
                    if (item.GetType() == typeof(TextMenu.Button))
                    {
                        var btn = (TextMenu.Button)item;
                        if (btn.Label == Dialog.Clean("MENU_PAUSE_SAVEQUIT") || btn.Label == Dialog.Clean("MENU_PAUSE_RETURN"))
                        {
                            pausemenu.Remove(item);
                        }
                        if (btn.Label == Dialog.Clean("MENU_PAUSE_RESTARTAREA"))
                        {
                            btn.Label = Dialog.Clean("MENU_PAUSE_RESTARTRANDO");
                        }
                    }
                }

                int returnIdx = pausemenu.GetItems().Count;
                pausemenu.Add(new TextMenu.Button(Dialog.Clean("MENU_PAUSE_QUITRANDO")).Pressed(() => {
                    level.PauseMainMenuOpen = false;
                    pausemenu.RemoveSelf();

                    TextMenu menu   = new TextMenu();
                    menu.AutoScroll = false;
                    menu.Position   = new Vector2((float)Engine.Width / 2f, (float)((double)Engine.Height / 2.0 - 100.0));
                    menu.Add(new TextMenu.Header(Dialog.Clean("MENU_QUITRANDO_TITLE")));
                    menu.Add(new TextMenu.Button(Dialog.Clean("MENU_QUITRANDO_CONFIRM")).Pressed((Action)(() => {
                        Engine.TimeRate = 1f;
                        menu.Focused = false;
                        level.Session.InArea = false;
                        Audio.SetMusic((string)null, true, true);
                        Audio.BusStopAll("bus:/gameplay_sfx", true);
                        level.DoScreenWipe(false, (Action)(() => Engine.Scene = (Scene) new LevelExit(LevelExit.Mode.SaveAndQuit, level.Session, level.HiresSnow)), true);
                        foreach (LevelEndingHook component in level.Tracker.GetComponents <LevelEndingHook>())
                        {
                            if (component.OnEnd != null)
                            {
                                component.OnEnd();
                            }
                        }
                    })));
                    menu.Add(new TextMenu.Button(Dialog.Clean("MENU_QUITRANDO_CANCEL")).Pressed((Action)(() => menu.OnCancel())));
                    menu.OnPause = menu.OnESC = (Action)(() => {
                        menu.RemoveSelf();
                        level.Paused = false;
                        Engine.FreezeTimer = 0.15f;
                        Audio.Play("event:/ui/game/unpause");
                    });
                    menu.OnCancel = (Action)(() => {
                        Audio.Play("event:/ui/main/button_back");
                        menu.RemoveSelf();
                        level.Pause(returnIdx, minimal, false);
                    });
                    level.Add((Entity)menu);
                }));
            }
        }
        private static void onCreatePauseMenuButtons(Level level, TextMenu menu, bool minimal)
        {
            if (CollabModule.Instance.Session.LobbySID != null)
            {
                // find the position just under "Return to Map".
                int returnToMapIndex = menu.GetItems().FindIndex(item =>
                                                                 item.GetType() == typeof(TextMenu.Button) && ((TextMenu.Button)item).Label == Dialog.Clean("MENU_PAUSE_RETURN"));

                if (returnToMapIndex == -1)
                {
                    // fall back to the bottom of the menu.
                    returnToMapIndex = menu.GetItems().Count - 1;
                }

                // add the "Return to Lobby" button
                TextMenu.Button returnToLobbyButton = new TextMenu.Button(Dialog.Clean("collabutils2_returntolobby"));
                returnToLobbyButton.Pressed(() => {
                    level.PauseMainMenuOpen = false;
                    menu.RemoveSelf();
                    openReturnToLobbyConfirmMenu(level, menu.Selection);
                });
                returnToLobbyButton.ConfirmSfx = "event:/ui/main/message_confirm";
                menu.Insert(returnToMapIndex + 1, returnToLobbyButton);
            }
        }
示例#22
0
 private Entity CreateButtonConfigUI(TextMenu menu)
 {
     return(new ModuleSettingsButtonConfigUI(this)
     {
         OnClose = () => menu.Focused = true
     });
 }
示例#23
0
        // ================ Mod options setup ================

        public override void CreateModMenuSection(TextMenu menu, bool inGame, EventInstance snapshot)
        {
            base.CreateModMenuSection(menu, inGame, snapshot);

            if (Settings.OptionsOutOfModOptionsMenuEnabled && inGame)
            {
                // build the menu with only the master switch
                new ModOptionsEntries().CreateAllOptions(ModOptionsEntries.VariantCategory.None, true, false, false, false,
                                                         null /* don't care, no submenu */, menu, inGame, triggerIsHooked);
            }
            else if (Settings.SubmenusForEachCategoryEnabled)
            {
                // build the menu with the master switch + submenus + randomizer options
                new ModOptionsEntries().CreateAllOptions(ModOptionsEntries.VariantCategory.None, true, true, true, false,
                                                         () => OuiModOptions.Instance.Overworld.Goto <OuiModOptions>(), menu, inGame, triggerIsHooked);
            }
            else if (Settings.OptionsOutOfModOptionsMenuEnabled)
            {
                // build the menu with the master switch + the button to open the submenu
                new ModOptionsEntries().CreateAllOptions(ModOptionsEntries.VariantCategory.None, true, false, false, true,
                                                         null /* don't care, no submenu */, menu, inGame, triggerIsHooked);
            }
            else
            {
                // build the good old full menu directly in Mod Options (master switch + all variant categories + randomizer)
                new ModOptionsEntries().CreateAllOptions(ModOptionsEntries.VariantCategory.All, true, false, true, false,
                                                         () => OuiModOptions.Instance.Overworld.Goto <OuiModOptions>(), menu, inGame, triggerIsHooked);
            }
        }
        public static void Main(string[] args)
        {
            IExeStack <IStatement> stack = new ExeStack <IStatement>();

            Utils.IDictionary <string, int> dict = new MyDictionary <string, int>();
            IMyList <int>             output     = new MyList <int>();
            FileTable <int, FileData> fileTable  = new FileTable <int, FileData>();

            IStatement s1     = new OpenRFile("var_f", "C:\\Users\\Emy\\RiderProjects\\lab7\\text1.txt");
            IStatement s2     = new ReadFile(new VarExp("var_f"), "var_c");
            IStatement thenS1 = new ReadFile(new VarExp("var_f"), "var_c");
            IStatement thenS2 = new PrintStmt(new VarExp("var_c"));
            IStatement thenS  = new CompStmt(thenS1, thenS2);
            IStatement elseS  = new PrintStmt(new ConstExp(0));

            IStatement s3 = new IfStmt(new VarExp("var_c"), thenS, elseS);
            IStatement s4 = new CloseRFile(new VarExp("var_f"));

            IStatement s5 = new CompStmt(s1, s2);
            IStatement s6 = new CompStmt(s3, s4);
            IStatement s7 = new CompStmt(s5, s6);

            stack.push(s7);

            PrgState state = new PrgState(dict, stack, output, fileTable);

            Controller.Controller ctrl = new Controller.Controller(state);


            TextMenu menu = new TextMenu();

            menu.addCommand(new ExitCommand("0", "exit"));
            menu.addCommand(new RunExample("1", "example_1", ctrl));
            menu.show();
        }
示例#25
0
        public override IEnumerator Enter(Oui from)
        {
            Everest.Loader.AutoLoadNewMods = false;

            menu = new TextMenu();

            // display the title and a dummy "Fetching" button
            menu.Add(new TextMenu.Header(Dialog.Clean("MODUPDATECHECKER_MENU_TITLE")));

            menu.Add(subHeader = new TextMenuExt.SubHeaderExt(Dialog.Clean("MODUPDATECHECKER_MENU_HEADER")));

            fetchingButton          = new TextMenu.Button(Dialog.Clean("MODUPDATECHECKER_FETCHING"));
            fetchingButton.Disabled = true;
            menu.Add(fetchingButton);

            Scene.Add(menu);

            currentCheckForUpdates = new CheckForUpdates();
            task = new Task(() => currentCheckForUpdates.Fetch());
            task.Start();

            menu.Visible = Visible = true;
            menu.Focused = false;

            for (float p = 0f; p < 1f; p += Engine.DeltaTime * 4f)
            {
                menu.X = offScreenX + -1920f * Ease.CubeOut(p);
                alpha  = Ease.CubeOut(p);
                yield return(null);
            }

            menu.Focused = true;
            menuOnScreen = true;
        }
示例#26
0
        public override void CreateModMenuSection(TextMenu menu, bool inGame, EventInstance snapshot)
        {
            base.CreateModMenuSection(menu, inGame, snapshot);

            // this could maybe be refactored into a helper function with some generics magic
            foreach (var item in menu.Items)
            {
                if (!(item is TextMenu.Button btn) || !btn.Label.StartsWith(Dialog.Clean("modoptions_bingoclient_playername")))
                {
                    continue;
                }

                var messageHeader = new TextMenuExt.EaseInSubHeaderExt(Dialog.Clean("modoptions_bingoclient_playername_about"), false, menu)
                {
                    HeightExtra = 17f,
                    Offset      = new Vector2(30, -5),
                };

                menu.Insert(menu.Items.IndexOf(item) + 1, messageHeader);
                btn.OnEnter = () => messageHeader.FadeVisible = true;
                btn.OnLeave = () => messageHeader.FadeVisible = false;
                break;
            }

            foreach (var item in menu.Items)
            {
                if (!(item is TextMenu.OnOff btn) || !btn.Label.StartsWith(Dialog.Clean("modoptions_bingoclient_claimassist")))
                {
                    continue;
                }

                var messageHeader = new TextMenuExt.EaseInSubHeaderExt(Dialog.Clean("modoptions_bingoclient_claimassist_about"), false, menu)
                {
                    HeightExtra = 17f,
                    Offset      = new Vector2(30, -5),
                };

                menu.Insert(menu.Items.IndexOf(item) + 1, messageHeader);
                btn.OnEnter = () => messageHeader.FadeVisible = true;
                btn.OnLeave = () => messageHeader.FadeVisible = false;
                break;
            }

            if (this.Password != null && !this.Connected)
            {
                var retryBtn = new TextMenu.Button(Dialog.Clean("modoptions_bingoclient_reconnect"));
                retryBtn.OnPressed = () => {
                    this.Connect();
                };
                menu.Add(retryBtn);
            }
            if (this.Connected)
            {
                var disconnectBtn = new TextMenu.Button(Dialog.Clean("modoptions_bingoclient_disconnect"));
                disconnectBtn.OnPressed = () => {
                    this.Disconnect();
                };
                menu.Add(disconnectBtn);
            }
        }
示例#27
0
        public TextMenu CreateMenu(bool inGame, EventInstance snapshot)
        {
            menu = new TextMenu();
            items.Clear();

            menu.Add(new TextMenu.Header(Dialog.Clean("maplist_title")));

            if (menu.Height > menu.ScrollableMinSize)
            {
                menu.Position.Y = menu.ScrollTargetY;
            }

            menu.Add(new TextMenu.SubHeader(Dialog.Clean("maplist_filters")));

            sets.Clear();
            foreach (AreaData area in AreaData.Areas)
            {
                string levelSet = area.GetLevelSet();
                if (string.IsNullOrEmpty(levelSet))
                {
                    continue;
                }
                if (levelSet == "Celeste")
                {
                    continue;
                }
                if (sets.Contains(levelSet))
                {
                    continue;
                }
                sets.Add(levelSet);
            }

            menu.Add(new TextMenu.Slider(Dialog.Clean("maplist_type"), value => {
                if (value == 0)
                {
                    return(Dialog.Clean("levelset_celeste"));
                }
                if (value == 1)
                {
                    return(Dialog.Clean("maplist_type_allmods"));
                }
                return(DialogExt.CleanLevelSet(sets[value - 2]));
            }, 0, 1 + sets.Count, type).Change(value => {
                type = value;
                ReloadItems();
            }));

            menu.Add(new TextMenu.Slider(Dialog.Clean("maplist_side"), value => ((char)('A' + value)).ToString(), 0, Enum.GetValues(typeof(AreaMode)).Length - 1, side).Change(value => {
                side = value;
                ReloadItems();
            }));

            menu.Add(new TextMenu.SubHeader(Dialog.Clean("maplist_list")));

            ReloadItems();

            return(menu);
        }
示例#28
0
        static void Main(string[] args)
        {
            Statement s = new CompStatement(new VarDeclStatement("v", new IntType()),
                                            new CompStatement(new AssignStatement("v", new ValueExpression(new IntValue(2))),
                                                              new PrintStatement(new VariableExpression("v"))));
            List <ProgramState> l = new List <ProgramState>();

            l.Add(new ProgramState(new Stack <Statement>(), new ConcurrentDictionary <string, Value>(), new List <Value>(), s));
            RepositoryInterface r = new Repository(l);
            ControllerInterface c = new Controller(r);

            Statement           s2 = ex1();
            List <ProgramState> l1 = new List <ProgramState>();

            l1.Add(new ProgramState(new Stack <Statement>(), new ConcurrentDictionary <string, Value>(), new List <Value>(), s2));
            RepositoryInterface r1 = new Repository(l1);
            ControllerInterface c1 = new Controller(r1);


            Statement           s3 = ex2();
            List <ProgramState> l2 = new List <ProgramState>();

            l2.Add(new ProgramState(new Stack <Statement>(), new ConcurrentDictionary <string, Value>(), new List <Value>(), s3));
            RepositoryInterface r2 = new Repository(l2);
            ControllerInterface c2 = new Controller(r2);

            Statement           s4 = ex4();
            List <ProgramState> l4 = new List <ProgramState>();

            l4.Add(new ProgramState(new Stack <Statement>(), new ConcurrentDictionary <string, Value>(), new List <Value>(), s4));
            RepositoryInterface r4 = new Repository(l4);
            ControllerInterface c4 = new Controller(r4);

            Statement           s5 = ex5();
            List <ProgramState> l5 = new List <ProgramState>();

            l5.Add(new ProgramState(new Stack <Statement>(), new ConcurrentDictionary <string, Value>(), new List <Value>(), s5));
            RepositoryInterface r5 = new Repository(l5);
            ControllerInterface c5 = new Controller(r5);

            Statement           s6 = ex6();
            List <ProgramState> l6 = new List <ProgramState>();

            l6.Add(new ProgramState(new Stack <Statement>(), new ConcurrentDictionary <string, Value>(), new List <Value>(), s6));
            RepositoryInterface r6 = new Repository(l6);
            ControllerInterface c6 = new Controller(r6);

            TextMenu menu = new TextMenu(new ConcurrentDictionary <string, Command>());

            menu.addCommand(new ExitCommand("x", "Exit"));
            menu.addCommand(new RunCommand("1", s.ToString(), c));
            menu.addCommand(new RunCommand("2", s2.ToString(), c1));
            menu.addCommand(new RunCommand("3", s3.ToString(), c2));
            menu.addCommand(new RunCommand("4", s4.ToString(), c4));
            menu.addCommand(new RunCommand("5", s5.ToString(), c5));
            menu.addCommand(new RunCommand("6", s6.ToString(), c6));

            menu.runTextMenu();
        }
示例#29
0
        public void CreateMenu(TextMenu menu, bool inGame)
        {
            currentPreset      = 0;
            enabledText        = new TextMenu.OnOff(Dialog.Clean("MODOPTIONS_HYPERLINE_ENABLED"), Settings.Enabled).Change(EnabledToggled);
            allowMapHairText   = new TextMenu.OnOff(Dialog.Clean("MODOPTIONS_HYPERLINE_ALLOWMAPHAIR"), Settings.AllowMapHairColors).Change(v => Settings.AllowMapHairColors = v);
            maddyCrownText     = new TextMenu.OnOff("Maddy Crown Support:", Settings.DoMaddyCrown).Change(v => { Settings.DoMaddyCrown = v; });
            doFeatherColorText = new TextMenu.OnOff("Do Feather Color", Settings.DoFeatherColor).Change(v => { Settings.DoFeatherColor = v; });
            doDashFlashText    = new TextMenu.OnOff("Do Dash Flash", Settings.DoDashFlash).Change(v => { Settings.DoDashFlash = v; });
            menu.Add(enabledText);
            menu.Add(allowMapHairText);
            menu.Add(maddyCrownText);
            menu.Add(doFeatherColorText);
            menu.Add(doDashFlashText);
            CreatePresetMenu(menu);

            colorMenus    = new List <List <List <TextMenu.Item> > >(); //dashes
            dashCountMenu = new TextMenuExt.OptionSubMenu("Dashes");
            dashCountMenu.SetInitialSelection(lastDash);

            dashCountMenu.Change(v => { UpdateHairType(v, Settings.hairTypeList[v]); });
            for (int counterd = 0; counterd < Hyperline.MAX_DASH_COUNT; counterd++)
            {
                int r = counterd;
                List <TextMenu.Item> Menu = new List <TextMenu.Item>();
                TextMenuExt.EnumerableSlider <uint> HairTypeMenu;
                colorMenus.Add(CreateDashCountMenu(menu, inGame, counterd, out HairTypeMenu));
                if (!inGame)
                {
                    Menu.Add(new TextMenu.Button("Custom Texture: " + Settings.hairTextureSource[counterd]).Pressed(() =>
                    {
                        Audio.Play(SFX.ui_main_savefile_rename_start);
                        menu.SceneAs <Overworld>().Goto <OuiModOptionString>().Init <OuiModOptions>(Settings.hairTextureSource[r], v => { Settings.hairTextureSource[r] = v; Settings.LoadCustomTexture(r); }, 12);
                    }));
                    Menu.Add(new TextMenu.Button("Custom Bangs: " + Settings.hairBangsSource[counterd]).Pressed(() =>
                    {
                        Audio.Play(SFX.ui_main_savefile_rename_start);
                        menu.SceneAs <Overworld>().Goto <OuiModOptionString>().Init <OuiModOptions>(Settings.hairBangsSource[r], v => { Settings.hairBangsSource[r] = v; Settings.LoadCustomBangs(r); }, 12);
                    }));
                }

                Menu.Add(new TextMenu.Slider("Speed:", StringFromInt, HyperlineSettings.MIN_HAIR_SPEED, HyperlineSettings.MAX_HAIR_SPEED, Settings.hairSpeedList[counterd]).Change(v => { SetHairSpeed(r, v); }));
                Menu.Add(new TextMenu.Slider("Length:", StringFromInt, HyperlineSettings.MIN_HAIR_LENGTH, Settings.HairLengthSoftCap, Settings.hairLengthList[counterd]).Change(v => { SetHairLength(r, v); }));
                Menu.Add(HairTypeMenu);
                if (!inGame)
                {
                    for (int i = 0; i < colorMenus[counterd].Count; i++)
                    {
                        for (int j = 0; j < colorMenus[counterd][i].Count; j++)
                        {
                            Menu.Add(colorMenus[counterd][i][j]);
                        }
                    }
                }
                dashCountMenu.Add(counterd.ToString(), Menu);
            }
            menu.Add(dashCountMenu);
            UpdateHairType(lastDash, Settings.hairTypeList[lastDash]);
            EnabledToggled(Settings.Enabled);
        }
示例#30
0
 public static TextMenu.Item CreateTriggerHitboxColorButton(TextMenu textMenu, bool inGame)
 {
     return(new TextMenu.Button($"Trigger Hitbox Color ARGB: {ColorToHex(Settings.TriggerHitboxColor)}").Pressed(() => {
         Audio.Play("event:/ui/main/savefile_rename_start");
         textMenu.SceneAs <Overworld>().Goto <OuiModOptionString>()
         .Init <OuiModOptions>(ColorToHex(Settings.TriggerHitboxColor), value => Settings.TriggerHitboxColor = HexToColor(value), 9);
     }));
 }
	void Page_Load(object sender, System.EventArgs e)
	{
		// declare the menu and set its properties
		TextMenu tm = new TextMenu();
		tm.ID = "TextMenu1";
		
		// add the menu to page
		Page.Controls.Add(tm);

		string sConnectionString;
		OleDbDataReader oReader;
		
		// set the connection string
		sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../App_Data/DBDEMO.mdb");
		OleDbConnection Cn = new OleDbConnection(sConnectionString);
		
		// The database has one table called items containing both parent items and menu items
		// LEVEL shows what level the item is at (0 - parent item, 1 - belongs to menu attached to parent item, etc)
		// ORDER sets what is the item's order in the current menu (1 - first item, 2 - second item, etc.)
		// it is very important to add parent elements first, then level 1 items, then level 2 items, etc.
		string SQL = "SELECT * FROM Items ORDER BY [LEVEL], [ORDER]";
		OleDbCommand Com = new OleDbCommand(SQL,Cn);
		Cn.Open();
		oReader = Com.ExecuteReader();

		// Populate TM.
		while (oReader.Read()) 
		{
			// if PARENTID is null, we're adding a parent element, otherwise it's a menu item
			tm.Add(oReader.IsDBNull(oReader.GetOrdinal("PARENTID")) ? null : oReader.GetString(oReader.GetOrdinal("PARENTID")), 
					oReader.GetString(oReader.GetOrdinal("ID")),
					oReader.IsDBNull(oReader.GetOrdinal("HTML")) ? "" : oReader.GetString(oReader.GetOrdinal("HTML")),
					oReader.IsDBNull(oReader.GetOrdinal("URL")) ? null : oReader.GetString(oReader.GetOrdinal("URL")),
					oReader.IsDBNull(oReader.GetOrdinal("URLTARGET")) ? null : oReader.GetString(oReader.GetOrdinal("URLTARGET")));
		}

		oReader.Close();
		Cn.Close();
	}
	private void Page_Load(object sender, System.EventArgs e)
	{
		TextMenu tm1 = new TextMenu();
		tm1.ID = "tm1";
		tm1.StyleFolder = "styles/submenuicon";
		tm1.SubMenuText = "";

		tm1.Add(null, "brands", "Brands", null, null);
			tm1.Add("brands", "ibm", "IBM");
			tm1.Add("brands", "microsoft", "MICROSOFT");
			tm1.Add("brands", "obout", "OBOUT", "http://www.obout.com/", "_top");
				tm1.Add("obout", "treeview", "TreeView", "http://www.obout.com/t2/edraganddrop.aspx", "_top");
				tm1.Add("obout", "slidemenu", "Slide Menu", "http://www.obout.com/sm3/whatisnew.aspx", "_top");
				tm1.Add("obout", "calendar", "Calendar", "http://www.obout.com/calendar/", "_top");
				tm1.Add("obout", "postback", "AJAXPage", "http://www.obout.com/AJAXPage/", "_top");
				tm1.Add("obout", "splitter", "Splitter", "http://www.obout.com/splitter/", "_top");
				tm1.Add("obout", "easymenu", "EasyMenu", "http://www.obout.com/em/", "_top");
				tm1.Add("obout", "combobox", "Combobox", "http://www.obout.com/combobox/", "_top");
				tm1.Add("obout", "editor", "HTML Editor", "http://www.obout.com/editor_new/", "_top");
				tm1.Add("obout", "treedb", "Tree_DB", "http://www.obout.com/t_db/index.aspx", "_top");
				tm1.Add("obout", "textmenu", "TextMenu", "http://www.obout.com/tm/tm.aspx", "_top");
		tm1.Add(null, "systems", "Systems");
			tm1.Add("systems", "desktops", "Desktops");
			tm1.Add("systems", "handhelds", "Handhelds");
			tm1.Add("systems", "notebooks", "Notebooks");
			tm1.Add("systems", "servers", "Servers");
		tm1.Add(null, "hardware", "Hardware");
			tm1.Add("hardware", "accessories", "Accessories");
			tm1.Add("hardware", "keyboards", "Keyboards");
			tm1.Add("hardware", "memory", "Memory");
			tm1.Add("hardware", "printers", "Printers");
			tm1.Add("hardware", "videocards", "Video Cards");
		tm1.Add(null, "software", "Software");
			tm1.Add("software", "applications", "Applications");
			tm1.Add("software", "licensing", "Licensing");

		this.Controls.Add(tm1);
	}
	private void Page_Load(object sender, System.EventArgs e)
	{
		System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
		xmlDoc.Load(Server.MapPath("TextMenuXML.xml"));

		System.Xml.XmlNodeList menuNodes = xmlDoc.SelectNodes("/TextMenu");

		foreach (System.Xml.XmlNode menuNode in menuNodes)
		{
			string menuID = menuNode.Attributes["ID"].Value;

			// create new TextMenu object ...
			TextMenu tmpMenu = new TextMenu();
			tmpMenu.ID = menuID;
			
			// take the childs and create the menu items ...
			System.Xml.XmlNodeList menuItemsNodes = menuNode.SelectNodes("//Item");

			foreach (System.Xml.XmlNode menuItemNode in menuItemsNodes)
			{
				string menuItemID = menuItemNode.Attributes["ID"].Value;
				string InnerHTML = menuItemNode.Attributes["InnerHTML"].Value;
				string parentMenuItemID = null;
				if (menuItemNode.Attributes["ParentID"] != null)
					parentMenuItemID = menuItemNode.Attributes["ParentID"].Value;
				string menuUrl = null;
				if (menuItemNode.Attributes["Url"] != null)
					menuUrl = menuItemNode.Attributes["Url"].Value;

				// create new Menu item object and add it to the created menu ...
				tmpMenu.Add(parentMenuItemID, menuItemID, InnerHTML, menuUrl, null);
			}
			
			placeHolder1.Controls.Add(tmpMenu);
		}
	}
示例#34
0
        //--- Menu item callbacks
        // Root menu:
        private void ShowCelestialMenu(int index, TextMenu.Item ti)
        {
            currentMenu = MenuList.Celestials;

            // MOARdV: Bug warning: rightColumnWidth for ShowCelestialMenu and
            // ShowVesselMenu is hard-coded to 8, which fits the default format
            // string.  It really needs to be sized appropriately, which isn't
            // easy if the format string is configured with non-fixed size.
            // Maybe the format string should be non-configurable?
            //
            // Mihara: Well, why not make it another module parameter then and
            // let the modder who uses it worry about that? Most won't change it.
            activeMenu = new TextMenu();
            activeMenu.rightColumnWidth = distanceColumnWidth;

            activeMenu.labelColor = nameColorTag;
            activeMenu.selectedColor = selectedColorTag;
            activeMenu.disabledColor = unavailableColorTag;
            activeMenu.rightTextColor = distanceColorTag;

            UpdateLists();

            if (selectedCelestial != null)
            {
                int idx = celestialsList.FindIndex(x => x.body == selectedCelestial);
                activeMenu.currentSelection = idx;
            }
        }
 private void SmartASS_Node(int index, TextMenu.Item tmi)
 {
     SetSmartassMode(JSIMechJeb.Target.NODE);
 }
示例#36
0
 // Filters Menu
 private void ToggleFilter(int index, TextMenu.Item ti)
 {
     vesselFilter[vesselFilter.ElementAt(index).Key] = !vesselFilter[vesselFilter.ElementAt(index).Key];
     persistence.SetVar(persistentVarName, VesselFilterToBitmask(vesselFilter));
     ti.isSelected = !ti.isSelected;
     ti.labelText = vesselFilter.ElementAt(index).Key.ToString().PadRight(9) + (ti.isSelected ? "- On" : "- Off");
 }
示例#37
0
        // Space Object Menu
        private void TargetSpaceObject(int index, TextMenu.Item ti)
        {
            spaceObjectsList[index].SetTarget();
            selectedCelestial = null;
            selectedPort = null;

            activeMenu.SetSelected(index, true);
        }
示例#38
0
        // Celestial Menu
        private void TargetCelestial(int index, TextMenu.Item ti)
        {
            celestialsList[index].SetTarget();
            selectedVessel = null;
            selectedPort = null;

            activeMenu.SetSelected(index, true);
        }
示例#39
0
        private void ShowUndockMenu(int index, TextMenu.Item ti)
        {
            currentMenu = MenuList.Undock;

            activeMenu = new TextMenu();

            activeMenu.labelColor = nameColorTag;
            activeMenu.selectedColor = selectedColorTag;
            activeMenu.disabledColor = unavailableColorTag;
            activeMenu.rightTextColor = distanceColorTag;
            UpdateLists();
        }
        private void ShowCrewEVA(int index, TextMenu.Item ti)
        {
            currentMenu = MenuList.CrewEVA;

            activeMenu = new TextMenu();
            activeMenu.labelColor = nameColorTag;
            activeMenu.selectedColor = selectedColorTag;
            activeMenu.disabledColor = unavailableColorTag;
            activeMenu.rightTextColor = distanceColorTag;

            var vesselCrew = vessel.GetVesselCrew();
            for (int crewIdx = 0; crewIdx < vesselCrew.Count; ++crewIdx)
            {
                if (vesselCrew[crewIdx] != null)
                {
                    var tmi = new TextMenu.Item();
                    tmi.action = CrewEVA;
                    tmi.labelText = vesselCrew[crewIdx].name;
                    tmi.rightText = vesselCrew[crewIdx].experienceTrait.Title;
                    tmi.isSelected = false;
                    tmi.id = crewIdx;
                    activeMenu.Add(tmi);
                }
            }
        }
 // EVA Menu
 private void CrewEVA(int index, TextMenu.Item ti)
 {
     var vesselCrew = vessel.GetVesselCrew();
     float acLevel = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.AstronautComplex);
     bool evaUnlocked = GameVariables.Instance.UnlockedEVA(acLevel);
     bool evaPossible = GameVariables.Instance.EVAIsPossible(evaUnlocked, vessel);
     if (evaPossible && ti.id < vesselCrew.Count && vesselCrew[ti.id] != null && HighLogic.CurrentGame.Parameters.Flight.CanEVA)
     {
         FlightEVA.SpawnEVA(vesselCrew[ti.id].KerbalRef);
         CameraManager.Instance.SetCameraFlight();
     }
 }
        public void Start()
        {
            if (!HighLogic.LoadedSceneIsFlight)
                return;

            rpmComp = RasterPropMonitorComputer.Instantiate(internalProp, true);

            // Grrrrrr.
            if (!string.IsNullOrEmpty(nameColor))
                nameColorValue = ConfigNode.ParseColor32(nameColor);
            if (!string.IsNullOrEmpty(distanceColor))
                distanceColorValue = ConfigNode.ParseColor32(distanceColor);
            if (!string.IsNullOrEmpty(selectedColor))
                selectedColorValue = ConfigNode.ParseColor32(selectedColor);
            if (!string.IsNullOrEmpty(unavailableColor))
                unavailableColorValue = ConfigNode.ParseColor32(unavailableColor);

            persistentVarName = "targetfilter" + internalProp.propID;

            // 7 is the bitmask for ship-station-probe;
            VesselFilterFromBitmask(rpmComp.GetPersistentVariable(persistentVarName, defaultFilter, false).MassageToInt());

            nameColorTag = JUtil.ColorToColorTag(nameColorValue);
            distanceColorTag = JUtil.ColorToColorTag(distanceColorValue);
            selectedColorTag = JUtil.ColorToColorTag(selectedColorValue);
            unavailableColorTag = JUtil.ColorToColorTag(unavailableColorValue);
            distanceFormatString = distanceFormatString.UnMangleConfigText();
            menuTitleFormatString = menuTitleFormatString.UnMangleConfigText();

            topMenu.labelColor = nameColorTag;
            topMenu.selectedColor = selectedColorTag;
            topMenu.disabledColor = unavailableColorTag;

            if (!string.IsNullOrEmpty(pageTitle))
                pageTitle = pageTitle.UnMangleConfigText();

            foreach (CelestialBody body in FlightGlobals.Bodies)
            {
                celestialsList.Add(new Celestial(body, vessel.transform.position));
            }

            FindReferencePoints();
            UpdateUndockablesList();

            var menuActions = new List<Action<int, TextMenu.Item>>();
            menuActions.Add(ShowCelestialMenu);
            menuActions.Add(ShowVesselMenu);
            menuActions.Add(ShowSpaceObjectMenu);
            menuActions.Add(ShowReferenceMenu);
            menuActions.Add(ShowUndockMenu);
            menuActions.Add(ArmGrapple);
            menuActions.Add(ShowFiltersMenu);
            menuActions.Add(ClearTarget);
            menuActions.Add(ShowCrewEVA);

            for (int i = 0; i < rootMenu.Count; ++i)
            {
                var menuitem = new TextMenu.Item();
                menuitem.labelText = rootMenu[i];
                menuitem.action = menuActions[i];
                topMenu.Add(menuitem);
                switch (menuitem.labelText)
                {
                    case clearTargetItemText:
                        clearTarget = topMenu[i];
                        break;
                    case undockItemText:
                        undockMenuItem = topMenu[i];
                        break;
                    case armGrappleText:
                        grappleMenuItem = topMenu[i];
                        break;
                    case crewEvaText:
                        float acLevel = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.AstronautComplex);
                        bool evaUnlocked = GameVariables.Instance.UnlockedEVA(acLevel);
                        menuitem.isDisabled = !GameVariables.Instance.EVAIsPossible(evaUnlocked, vessel);
                        break;
                }
            }

            activeMenu = topMenu;
        }
 private void ToggleForceRoll(int index, TextMenu.Item tmi)
 {
     bool newForceRollState = !ForceRollState();
     forceRollMenuItem.isSelected = newForceRollState;
     ForceRoll(newForceRollState);
 }
        private void TargetMenu(int index, TextMenu.Item tmi)
        {
            currentMenu = MJMenu.TargetMenu;

            activeMenu = new TextMenu();
            activeMenu.labelColor = JUtil.ColorToColorTag(itemColorValue);
            activeMenu.selectedColor = JUtil.ColorToColorTag(selectedColorValue);
            activeMenu.disabledColor = JUtil.ColorToColorTag(unavailableColorValue);

            foreach (JSIMechJeb.Target target in targetTargets)
            {
                activeMenu.Add(new TextMenu.Item(JSIMechJeb.TargetTexts[(int)target].Replace('\n', ' '), SelectTarget));
            }
        }
 private void SmartASS_Off(int index, TextMenu.Item tmi)
 {
     SetSmartassMode(JSIMechJeb.Target.OFF);
 }
示例#46
0
        private void ShowFiltersMenu(int index, TextMenu.Item ti)
        {
            currentMenu = MenuList.Filters;

            activeMenu = new TextMenu();

            activeMenu.labelColor = nameColorTag;
            activeMenu.selectedColor = selectedColorTag;
            activeMenu.disabledColor = unavailableColorTag;
            activeMenu.rightTextColor = distanceColorTag;
            for (int i = 0; i < vesselFilter.Count; i++)
            {
                var filter = vesselFilter.ElementAt(i);
                var tmi = new TextMenu.Item();
                tmi.labelText = filter.Key.ToString().PadRight(9) + (filter.Value ? "- On" : "- Off");
                tmi.isSelected = filter.Value;
                tmi.action = ToggleFilter;
                activeMenu.Add(tmi);
            }
        }
示例#47
0
        private void ShowReferenceMenu(int index, TextMenu.Item ti)
        {
            currentMenu = MenuList.Reference;

            activeMenu = new TextMenu();

            activeMenu.labelColor = nameColorTag;
            activeMenu.selectedColor = selectedColorTag;
            activeMenu.disabledColor = unavailableColorTag;
            activeMenu.rightTextColor = distanceColorTag;

            UpdateLists();

            activeMenu.currentSelection = referencePoints.FindIndex(x => x.part == vessel.GetReferenceTransformPart());
        }
示例#48
0
 public void ButtonProcessor(int buttonID)
 {
     if (buttonID == buttonUp)
     {
         activeMenu.PreviousItem();
     }
     if (buttonID == buttonDown)
     {
         activeMenu.NextItem();
     }
     if (buttonID == buttonEnter)
     {
         activeMenu.SelectItem();
     }
     if (buttonID == buttonEsc)
     {
         if (currentMenu == MenuList.Ports)
         {
             // Take advantage of the fact that ShowVesselMenu does not
             // care about the parameters.
             ShowVesselMenu(0, null);
         }
         else
         {
             activeMenu = topMenu;
             currentMenu = MenuList.Root;
         }
     }
     if (buttonID == buttonHome)
     {
         sortMode = sortMode == SortMode.Alphabetic ? SortMode.Distance : SortMode.Alphabetic;
         UpdateLists();
     }
 }
示例#49
0
        private void ShowVesselMenu(int index, TextMenu.Item ti)
        {
            currentMenu = MenuList.Vessels;

            activeMenu = new TextMenu();
            activeMenu.rightColumnWidth = distanceColumnWidth;

            activeMenu.labelColor = nameColorTag;
            activeMenu.selectedColor = selectedColorTag;
            activeMenu.disabledColor = unavailableColorTag;
            activeMenu.rightTextColor = distanceColorTag;

            UpdateLists();

            if (selectedVessel != null)
            {
                int idx = vesselsList.FindIndex(x => x.vessel == selectedVessel);
                activeMenu.currentSelection = idx;
            }
        }
示例#50
0
        public void Start()
        {
            if (!HighLogic.LoadedSceneIsFlight)
                return;

            // Grrrrrr.
            if (!string.IsNullOrEmpty(nameColor))
                nameColorValue = ConfigNode.ParseColor32(nameColor);
            if (!string.IsNullOrEmpty(distanceColor))
                distanceColorValue = ConfigNode.ParseColor32(distanceColor);
            if (!string.IsNullOrEmpty(selectedColor))
                selectedColorValue = ConfigNode.ParseColor32(selectedColor);
            if (!string.IsNullOrEmpty(unavailableColor))
                unavailableColorValue = ConfigNode.ParseColor32(unavailableColor);

            persistentVarName = "targetfilter" + internalProp.propID;
            persistence = new PersistenceAccessor(internalProp);
            // 7 is the bitmask for ship-station-probe;
            VesselFilterFromBitmask(persistence.GetVar(persistentVarName, defaultFilter));

            nameColorTag = JUtil.ColorToColorTag(nameColorValue);
            distanceColorTag = JUtil.ColorToColorTag(distanceColorValue);
            selectedColorTag = JUtil.ColorToColorTag(selectedColorValue);
            unavailableColorTag = JUtil.ColorToColorTag(unavailableColorValue);
            distanceFormatString = distanceFormatString.UnMangleConfigText();
            menuTitleFormatString = menuTitleFormatString.UnMangleConfigText();

            topMenu.labelColor = nameColorTag;
            topMenu.selectedColor = selectedColorTag;
            topMenu.disabledColor = unavailableColorTag;

            if (!string.IsNullOrEmpty(pageTitle))
                pageTitle = pageTitle.UnMangleConfigText();

            foreach (CelestialBody body in FlightGlobals.Bodies)
            {
                celestialsList.Add(new Celestial(body, vessel.transform.position));
            }

            FindReferencePoints();
            UpdateUndockablesList();

            var menuActions = new List<Action<int, TextMenu.Item>>();
            menuActions.Add(ShowCelestialMenu);
            menuActions.Add(ShowVesselMenu);
            menuActions.Add(ShowSpaceObjectMenu);
            menuActions.Add(ShowReferenceMenu);
            menuActions.Add(ShowUndockMenu);
            menuActions.Add(ArmGrapple);
            menuActions.Add(ShowFiltersMenu);
            menuActions.Add(ClearTarget);

            for (int i = 0; i < rootMenu.Count; ++i)
            {
                var menuitem = new TextMenu.Item();
                menuitem.labelText = rootMenu[i];
                menuitem.action = menuActions[i];
                topMenu.Add(menuitem);
                switch (menuitem.labelText)
                {
                    case clearTargetItemText:
                        clearTarget = topMenu[i];
                        break;
                    case undockItemText:
                        undockMenuItem = topMenu[i];
                        break;
                    case armGrappleText:
                        grappleMenuItem = topMenu[i];
                        break;
                }
            }

            activeMenu = topMenu;
        }
示例#51
0
        // Port Menu
        private void TargetPort(int index, TextMenu.Item ti)
        {
            if (selectedVessel != null && selectedVessel.loaded && portsList[index] != null)
            {
                FlightGlobals.fetch.SetVesselTarget(portsList[index]);
            }
            selectedCelestial = null;

            activeMenu.SetSelected(index, true);
        }
示例#52
0
 private static void ClearTarget(int index, TextMenu.Item ti)
 {
     FlightGlobals.fetch.SetVesselTarget((ITargetable)null);
 }
示例#53
0
        // Vessel Menu
        private void TargetVessel(int index, TextMenu.Item ti)
        {
            if (selectedVessel == vesselsList[index].vessel)
            {
                // Already selected.  Are there ports?
                UpdatePortsList();
                if (portsList.Count > 0)
                {
                    currentMenu = MenuList.Ports;

                    activeMenu = new TextMenu();
                    activeMenu.rightColumnWidth = 8;

                    activeMenu.labelColor = nameColorTag;
                    activeMenu.selectedColor = selectedColorTag;
                    activeMenu.disabledColor = unavailableColorTag;
                    activeMenu.rightTextColor = distanceColorTag;

                    UpdateLists();

                    if (selectedPort != null)
                    {
                        int idx = portsList.FindIndex(x => x == selectedPort);
                        activeMenu.currentSelection = idx;
                    }
                }
            }
            else
            {
                vesselsList[index].SetTarget();
                selectedCelestial = null;
                selectedPort = null;

                activeMenu.SetSelected(index, true);
            }
        }
示例#54
0
        private void ArmGrapple(int index, TextMenu.Item ti)
        {
            ModuleGrappleNode thatClaw = null;
            foreach (PartModule thatModule in vessel.GetReferenceTransformPart().Modules)
            {
                thatClaw = thatModule as ModuleGrappleNode;
                if (thatClaw != null)
                {
                    break;
                }
            }

            if (thatClaw != null)
            {
                try
                {
                    ModuleAnimateGeneric clawAnimation = (vessel.GetReferenceTransformPart().Modules[thatClaw.deployAnimationController] as ModuleAnimateGeneric);
                    if (clawAnimation != null)
                    {
                        clawAnimation.Toggle();
                    }
                }
                catch (Exception e)
                {
                    JUtil.LogErrorMessage(this, "Exception trying to arm/disarm Grapple Node: {0}", e.Message);
                }

            }
        }
示例#55
0
 // Decouple port menu...
 private void DecouplePort(int index, TextMenu.Item ti)
 {
     var thatPort = undockablesList[index] as ModuleDockingNode;
     var thatClaw = undockablesList[index] as ModuleGrappleNode;
     if (thatPort != null)
     {
         switch (thatPort.state)
         {
             case "Docked (docker)":
                 thatPort.Undock();
                 break;
             case "PreAttached":
                 thatPort.Decouple();
                 break;
         }
     }
     // Mihara: Claws require multiple different calls depending on state --
     // Release releases the claw that grabbed something else, while Decouple releases the claw that grabbed your own vessel.
     // FIXME: This needs further research.
     if (thatClaw != null)
     {
         thatClaw.Release();
     }
     UpdateUndockablesList();
     activeMenu = topMenu;
     currentMenu = MenuList.Root;
     UpdateLists();
 }
示例#56
0
 // Reference Menu
 private void SetReferencePoint(int index, TextMenu.Item ti)
 {
     // This is going to get complicated...
     if (referencePoints[index].part != vessel.GetReferenceTransformPart())
     {
         referencePoints[index].part.MakeReferencePart();
     }
     activeMenu.SetSelected(index, true);
 }
        private void SelectTarget(int index, TextMenu.Item tmi)
        {
            JSIMechJeb.Target[] activeTargets = null;
            switch (currentMenu)
            {
                case MJMenu.OrbitMenu:
                    activeTargets = orbitalTargets;
                    break;
                case MJMenu.SurfaceMenu:
                    activeTargets = surfaceTargets;
                    break;
                case MJMenu.TargetMenu:
                    activeTargets = targetTargets;
                    break;
            }

            if (activeTargets != null)
            {
                SetSmartassMode(activeTargets[index]);
            }
        }
示例#58
0
 private void SAS_Mode(int arg1, TextMenu.Item arg2)
 {
     vessel.Autopilot.SetMode(modes[arg1]);
     // find the UI object on screen
     RUIToggleButton[] SASbtns = UnityEngine.Object.FindObjectOfType<VesselAutopilotUI>().modeButtons;
     // set our mode, note it takes the mode as an int, generally top to bottom, left to right, as seen on the screen. Maneuver node being the exception, it is 9
     SASbtns.ElementAt<RUIToggleButton>((int)modes[arg1]).SetTrue(true, true);
 }
示例#59
0
 private void SAS_Toggle(int arg1, TextMenu.Item arg2)
 {
     vessel.ActionGroups.ToggleGroup(KSPActionGroup.SAS);
 }
 private void SmartASS_KillRot(int index, TextMenu.Item tmi)
 {
     SetSmartassMode(JSIMechJeb.Target.KILLROT);
 }