Beispiel #1
0
    /// <summary>
    /// 显示对话框
    /// </summary>
    private void ShowMessageBox(string content, System.Action clickCallback)
    {
        // 尝试获取一个可用的对话框
        MessageBox msgBox = null;

        for (int i = 0; i < _msgBoxList.Count; i++)
        {
            var item = _msgBoxList[i];
            if (item.ActiveSelf == false)
            {
                msgBox = item;
                break;
            }
        }

        // 如果没有可用的对话框,则创建一个新的对话框
        if (msgBox == null)
        {
            msgBox = new MessageBox();
            var cloneObject = GameObject.Instantiate(_messageBoxObj, _messageBoxObj.transform.parent);
            msgBox.Create(cloneObject);
            _msgBoxList.Add(msgBox);
        }

        // 显示对话框
        msgBox.Show(content, clickCallback);
    }
Beispiel #2
0
        internal static void Prefix(TransformWrapper __instance, IVisitor visitor)
        {
            if (!(visitor is Serializers.Serializer) && !(visitor is Serializers.Deserializer))
            {
                Transform ObjectTransform = __instance.tComponent_;

                if (!ObjectTransform.IsRoot())
                {
                    visitor.VisitAction("Inspect Parent", () =>
                    {
                        var Editor    = G.Sys.LevelEditor_;
                        var Selection = Editor.SelectedObjects_;

                        if (Selection.Count == 1)
                        {
                            EditorUtil.Inspect(ObjectTransform.parent.gameObject);
                        }
                        else
                        {
                            MessageBox.Create("You must select only 1 object to use this tool.", "ERROR")
                            .SetButtons(MessageButtons.Ok)
                            .Show();
                        }
                    }, null);
                }
            }
        }
Beispiel #3
0
 static public void ShowEthics()
 {
     RunInMainThrad(() => {
         MessageBox.Create("你的道德指数为" + runtime.Player.Pinde, Next);
     });
     Wait();
 }
        private void DisplayMenu()
        {
            MenuTree currentTree = MenuTree.GetItems(MenuSystem.GetCurrentDisplayMode());

            if (currentTree.Any())
            {
                for (int i = CurrentPageIndex * MaxEntriesPerPage; i < (CurrentPageIndex * MaxEntriesPerPage) + MaxEntriesPerPage; i++)
                {
                    if (i < currentTree.Count)
                    {
                        currentTree[i]?.Tweak(this);
                    }
                    else
                    {
                        break;
                    }
                }
            }
            else
            {
                MessageBox.Create(InternalResources.Strings.MenuSystem.UnavailableMenuError, InternalResources.Strings.MenuSystem.UnavailableMenuErrorTitle)
                .SetButtons(MessageButtons.Ok)
                .OnConfirm(() => PanelManager.TopPanel_.onPanelPop_ += () => MenuPanel.Pop())
                .Show();
            }
        }
Beispiel #5
0
 //-----------------------------------------------------------------------------------
 void Disconnect()
 {
     Game.instance.netMan.Disconnect();
     Unsubscribe();
     MessageBox.Create(GetCanvas(), "Connection lost", MessageBox.EType.OK,
                       () => { Game.instance.ui.SwitchToState(new MainMenuParams()); });
 }
Beispiel #6
0
        //-----------------------------------------------------------------------------------
        public void OnExitMatch()
        {
            m_player.glass.Pause(true);

            MessageBox.Create(GetCanvas(), "Exit Match?", MessageBox.EType.YES_NO,
                              () => { OnExitMatch(true); },
                              () => { OnExitMatch(false); });
        }
Beispiel #7
0
 static public void ShowRepute()
 {
     RunInMainThrad(() =>
     {
         MessageBox.Create("你的声望指数为" + runtime.Player.Shengwang, Next);
     });
     Wait();
 }
Beispiel #8
0
 static public void Dead()
 {
     RunInMainThrad(() => {
         //TODO..
         MessageBox.Create("GAME OVER", () =>
         {
             LevelMaster.Instance.QuitToMainMenu();
         });
     });
 }
Beispiel #9
0
 public static void show(string _content = "", string _title = "提示", UnityAction _callBack = null)
 {
     MessageBox.Create();
     instance.title            = _title;
     instance.content          = _content;
     instance.titleText.text   = instance.title;
     instance.contentText.text = instance.content;
     instance.showHide(true);
     instance.callBack = _callBack;
 }
        public async Task <MessageBox> GetOrCreateAsync(Guid userId)
        {
            var box = await context.MessageBoxes.FirstOrDefaultAsync(x => x.Uid == userId);

            if (box == null)
            {
                box = MessageBox.Create(userId);
                context.MessageBoxes.Add(box);
            }
            return(box);
        }
Beispiel #11
0
        public void Show()
        {
            if (this.Any())
            {
                string message = Count < 15 ? string.Join(Environment.NewLine, ToArray()) : "There were too many errors when loading custom cars to be displayed here, please check the logs in your mod installation directory.";

                MessageBox.Create($"Can't load the cars correctly: {Count} error(s)\n{message}", "CUSTOM CARS - ERRORS")
                .SetButtons(MessageButtons.Ok)
                .Show();
            }
        }
        static void AskPermissionMessage(ScreenManager screenManager, string command, Permissions permissionFlags)
        {
            if (!permissionFlags.HasFlag(Permissions.Auto) &&
                (permissionFlags.HasFlag(Permissions.Enabled) || permissionFlags.HasFlag(Permissions.Goal)))
            {
                var messageBox = MessageBox.Create(screenManager, $"Press OK to {command} remaining item checks", _ => {
                    Client.Say($"!{command}");
                });

                screenManager.AddScreen(messageBox.Screen, null);
            }
        }
        public void Update(Level level, ScreenManager screenManager)
        {
            if (!settings.DeathLink.Value || level.MainHero == null)
            {
                return;
            }

            if (rip)
            {
                rip = false;

                if (level.ID == 17 || (level.ID == 16 && level.RoomID == 27))
                {
                    lastState = level.MainHero.CurrentState;
                    return;                     //Do not kill the player during the ending.
                }

                ScreenManager.Console.AddLine(
                    !string.IsNullOrEmpty(lastDeathLink.Cause)
                                                ? $"DeathLink received from {lastDeathLink.Source}, Reason: {lastDeathLink.Cause}"
                                                : $"DeathLink received from {lastDeathLink.Source}");

                var message = $"Your soul was linked across time to {lastDeathLink.Source} who has perished, and so have you!";

                if (!string.IsNullOrEmpty(lastDeathLink.Cause))
                {
                    message += $"\nThey died of: {lastDeathLink.Cause}";
                }

                var messageBox = MessageBox.Create(screenManager, message);

                screenManager.AddScreen(messageBox.Screen, null);

                level.MainHero.Kill();
            }
            else
            {
                if (level.MainHero.CurrentState == EAFSM.Dying && lastState != EAFSM.Dying)
                {
                    var deathLink = new DeathLink(Client.GetCurrentPlayerName());

                    lastDeathLink = deathLink;

                    try
                    {
                        service.SendDeathLink(deathLink);
                    }
                    catch {}
                }

                lastState = level.MainHero.CurrentState;
            }
        }
        private void CreateSettingsMenu()
        {
            MenuTree settingsMenu = new MenuTree("menu.mod.customwheelhologram", "Wheel Hologram Settings")
            {
                new ActionButton(MenuDisplayMode.Both, "setting:select_image", "SELECT IMAGE")
                .WhenClicked(() =>
                {
                    var dlgOpen = new System.Windows.Forms.OpenFileDialog
                    {
                        Filter = "Image file (*.png, *.jpg, *.jpeg *.bmp)|*.png;*.jpg;*.jpeg;*.bmp|All Files (*.*)|*.*",
                        SupportMultiDottedExtensions = true,
                        RestoreDirectory             = true,
                        Title           = "Select an image file",
                        CheckFileExists = true,
                        CheckPathExists = true
                    };

                    if (dlgOpen.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        FileInfo image = new FileInfo(dlgOpen.FileName);

                        if (image.Exists)
                        {
                            Config.FileName = Path.GetFileName(image.CopyTo(Path.Combine(FileSystem.VirtualFileSystemRoot, Path.GetFileName(image.FullName)), true).FullName);
                            Config.Enabled  = true;
                        }
                    }
                })
                .WithDescription("Select the image file displayed on the wheel hologram."),

                new ActionButton(MenuDisplayMode.Both, "setting:reset_image", "RESET IMAGE")
                .WhenClicked(() =>
                {
                    MessageBox.Create("Are you sure you want to reset the hologram to its default image?", "RESET WHEEL IMAGE")
                    .SetButtons(MessageButtons.YesNo)
                    .OnConfirm(() =>
                    {
                        Config.Enabled  = false;
                        Config.FileName = string.Empty;

                        if (WheelImage.Exists)
                        {
                            WheelImage.Delete();
                        }
                    })
                    .Show();
                })
                .WithDescription("Resets the wheel hologram to the game's default.")
            };

            Menus.AddNew(MenuDisplayMode.Both, settingsMenu, "CUSTOM WHEEL HOLOGRAM", "Change settings of the Custom Wheel Hologram mod and customize your vehicle's wheel image (works only with vanilla cars).");
        }
Beispiel #15
0
 void OnGUI()
 {
     if (GUILayout.Button("Message show"))
     {
         box.Create(messageBoxBack);
         //box.Show();
         box.Show(Vector3.zero);
         box.MoveTo(Vector3.zero, 0.5f);
     }
     if (GUILayout.Button("Message Close"))
     {
         box.Close();
     }
 }
Beispiel #16
0
        public override bool Run()
        {
            var Editor    = G.Sys.LevelEditor_;
            var Selection = Editor.activeObject_;

            if (Selection)
            {
                EditorUtil.SetQuickMemory(QuickAccessIndex, Selection);
            }
            else
            {
                MessageBox.Create("You must select only 1 object to use this tool.", "ERROR")
                .SetButtons(MessageButtons.Ok)
                .Show();
            }

            return(true);
        }
Beispiel #17
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="callback">装备物品回调</param>
    /// <param name="unquipCallback">卸物品回调</param>
    /// <param name="filter">过滤器</param>
    void SelectFromBag(Action <int> callback, Action unquipCallback, Func <Jyx2Item, bool> filter)
    {
        //BagPanel.Create(this.transform, runtime.Items, (itemId) =>
        //{
        //    if(itemId != -1 && !_role.CanUseItem(itemId))
        //    {
        //        MessageBox.Create("该角色不满足使用条件", null);
        //        return;
        //    }

        //    //卸下现有
        //    unquipCallback();

        //    if (itemId != -1)
        //    {
        //        unquipCallback();
        //        runtime.AddItem(itemId, -1);
        //        callback(itemId);
        //    }

        //    Refresh();
        //},filter);
        Jyx2_UIManager.Instance.ShowUI("BagUIPanel", new Action <int>((itemId) =>
        {
            if (itemId != -1 && !_role.CanUseItem(itemId))
            {
                MessageBox.Create("该角色不满足使用条件", null);
                return;
            }

            //卸下现有
            unquipCallback();

            if (itemId != -1)
            {
                unquipCallback();
                runtime.AddItem(itemId, -1);
                callback(itemId);
            }

            Refresh();
        }), filter);
    }
Beispiel #18
0
        private void CreateSettingsMenu()
        {
            MenuTree settingsMenu = new MenuTree("menu.mod.anolytics", "Anolytics Settings")
            {
                new CheckBox(MenuDisplayMode.Both, "setting:shutdown_analytics", "DISABLE ANALYTICS")
                .WithGetter(() => Config.ShutDownAnalytics)
                .WithSetter((x) => Config.ShutDownAnalytics = x)
                .WithDescription("Disables connection with Google analytics services.\n(Avoids requests to \"https://www.google-analytics.com/__utm.gif?\")"),

                new CheckBox(MenuDisplayMode.Both, "setting:log_analytics", "LOG ANALYTICS ACTIVITY")
                .WithGetter(() => Config.LogAnalytics)
                .WithSetter((x) => Config.LogAnalytics = x)
                .WithDescription("Outputs analytics events to the console."),

                new CheckBox(MenuDisplayMode.Both, "setting:disable_playtest_logging", "DISABLE PLAYTESTING LOG FILE")
                .WithGetter(() => Config.DisablePlaytestingDataLogging)
                .WithSetter((x) => Config.DisablePlaytestingDataLogging = x)
                .WithDescription("Blocks file write attempts to \"playtesting_data.txt\"."),

                new ActionButton(MenuDisplayMode.Both, "setting:delete_playtest_log", "DELETE PLAYTEST LOG FILE")
                .WhenClicked(() =>
                {
                    MessageBox.Create("Are you sure you want to delete \"playtesting_data.txt\" ?", "REMOVE FILE")
                    .SetButtons(MessageButtons.YesNo)
                    .OnConfirm(() =>
                    {
                        FileInfo file = new FileInfo(Path.Combine(Application.dataPath, "playtesting_data.txt"));

                        if (file.Exists)
                        {
                            file.Delete();
                        }
                    })
                    .Show();
                })
                .WithDescription("Removes the playtesting log file from the disk.")
            };

            Menus.AddNew(MenuDisplayMode.Both, settingsMenu, "ANOLYTICS", "Change settings of the Anolytics mod.");
        }
        internal static void Postfix(LevelGridGrid __instance)
        {
            if (!Mod.Instance.Config.EnableDeletePlaylistButton)
            {
                return;
            }

            LevelPlaylist playlist = __instance.playlist_;

            LevelPlaylistCompoundData data = playlist.GetComponent <LevelPlaylistCompoundData>();

            if (data && !playlist.IsResourcesPlaylist() && G.Sys.InputManager_.GetKeyUp(InternalResources.Constants.INPUT_DELETE_PLAYLIST))
            {
                MessageBox.Create($"Are you sure you want to remove [u]{playlist.Name_}[/u]?", "DELETE PLAYLIST")
                .SetButtons(MessageButtons.YesNo)
                .OnConfirm(() =>
                {
                    try
                    {
                        FileEx.Delete(data.FilePath);
                        playlist.Destroy();
                        Object.DestroyImmediate(data.gameObject);
                    }
                    catch (System.Exception e)
                    {
                        Mod.Instance.Logger.Exception(e);
                    }
                    finally
                    {
                        G.Sys.MenuPanelManager_.Pop();
                        __instance.levelGridMenu_.CreateEntries();
                    }
                })
                .Show();
            }
        }
 public static void PrintToolInspectionStackError()
 {
     MessageBox.Create("You can't run this tool while inspecting a group stack.\nPlease select a root level object.", "ERROR")
     .SetButtons(MessageButtons.Ok)
     .Show();
 }
Beispiel #21
0
        public void CreateSettingsMenu()
        {
            // TODO: Write menu docs in instructions.html

            MenuTree advancedDisplayMenu = new MenuTree("menu.mod.nitronichud#interface.advanced", "Advanced Interface Options")
            {
                new FloatSlider(MenuDisplayMode.Both, "setting:heat_blink_start_amount", "HEAT BLINK START AMOUNT")
                .LimitedByRange(0.0f, 1.0f)
                .WithDefaultValue(0.7f)
                .WithGetter(() => Config.HeatBlinkStartAmount)
                .WithSetter(x => Config.HeatBlinkStartAmount = x)
                .WithDescription("Set the heat treshold after which the hud starts to blink."),

                new FloatSlider(MenuDisplayMode.Both, "setting:heat_blink_frequence", "HEAT BLINK FREQUENCE")
                .LimitedByRange(0.0f, 10.0f)
                .WithDefaultValue(2.0f)
                .WithGetter(() => Config.HeatBlinkFrequence)
                .WithSetter(x => Config.HeatBlinkFrequence = x)
                .WithDescription("Set the hud blink rate (per second)."),

                new FloatSlider(MenuDisplayMode.Both, "setting:heat_blink_frequence_boost", "HEAT BLINK FREQUENCE BOOST")
                .LimitedByRange(0.0f, 10.0f)
                .WithDefaultValue(1.15f)
                .WithGetter(() => Config.HeatBlinkFrequenceBoost)
                .WithSetter(x => Config.HeatBlinkFrequenceBoost = x)
                .WithDescription("Sets the blink rate boost.\nThe blink rate at 100% heat is the blink rate times this value (set this to 1 to keep the rate constant)."),

                new FloatSlider(MenuDisplayMode.Both, "setting:heat_blink_amount", "HEAT BLINK AMOUNT")
                .LimitedByRange(0.0f, 1.0f)
                .WithDefaultValue(0.7f)
                .WithGetter(() => Config.HeatBlinkAmount)
                .WithSetter(x => Config.HeatBlinkAmount = x)
                .WithDescription("Sets the color intensity of the overheat blink animation (lower values means smaller color changes)."),

                new FloatSlider(MenuDisplayMode.Both, "setting:heat_flame_amount", "HEAT FLAME AMOUNT")
                .WithDefaultValue(0.5f)
                .LimitedByRange(0.0f, 1.0f)
                .WithGetter(() => Config.HeatFlameAmount)
                .WithSetter(x => Config.HeatFlameAmount = x)
                .WithDescription("Sets the color intensity of the overheat flame animation (lower values means smaller color changes).")
            };

            MenuTree displayMenu = new MenuTree("menu.mod.nitronichud#interface", "Interface Options")
            {
                new CheckBox(MenuDisplayMode.Both, "setting:display_countdown", "SHOW COUNTDOWN")
                .WithGetter(() => Config.DisplayCountdown)
                .WithSetter(x => Config.DisplayCountdown = x)
                .WithDescription("Displays the 3... 2... 1... RUSH countdown when playing a level."),

                new CheckBox(MenuDisplayMode.Both, "setting:display_overheat", "SHOW OVERHEAT METERS")
                .WithGetter(() => Config.DisplayHeatMeters)
                .WithSetter(x => Config.DisplayHeatMeters = x)
                .WithDescription("Displays overheat indicator bars in the lower screen corners."),

                new CheckBox(MenuDisplayMode.Both, "setting:display_timer", "SHOW TIMER")
                .WithGetter(() => Config.DisplayTimer)
                .WithSetter(x => Config.DisplayTimer = x)
                .WithDescription("Displays the timer at the bottom of the screen."),

                new IntegerSlider(MenuDisplayMode.Both, "setting:overheat_scale", "OVERHEAT SCALE")
                .WithDefaultValue(20)
                .WithGetter(() => Mathf.RoundToInt(Config.HeatMetersScale * 20.0f))
                .WithSetter(x => Config.HeatMetersScale = x / 20.0f)
                .LimitedByRange(1, 50)
                .WithDescription("Set the size of the overheat bars."),

                new IntegerSlider(MenuDisplayMode.Both, "setting:overheat_horizontal_offset", "OVERHEAT HORIZONTAL POSITION")
                .WithDefaultValue(0)
                .WithGetter(() => Config.HeatMetersHorizontalOffset)
                .WithSetter(x => Config.HeatMetersHorizontalOffset = x)
                .LimitedByRange(-200, 200)
                .WithDescription("Set the horizontal position offset of the overheat bars."),

                new IntegerSlider(MenuDisplayMode.Both, "setting:overheat_vertical_offset", "OVERHEAT VERTICAL POSITION")
                .WithDefaultValue(0)
                .WithGetter(() => Config.HeatMetersVerticalOffset)
                .WithSetter(x => Config.HeatMetersVerticalOffset = x)
                .LimitedByRange(-100, 100)
                .WithDescription("Set the vertical position offset of the overheat bars."),

                new IntegerSlider(MenuDisplayMode.Both, "setting:timer_scale", "TIMER SCALE")
                .WithDefaultValue(20)
                .WithGetter(() => Mathf.RoundToInt(Config.TimerScale * 20.0f))
                .WithSetter(x => Config.TimerScale = x / 20.0f)
                .LimitedByRange(1, 50)
                .WithDescription("Set the size of the timer."),

                new IntegerSlider(MenuDisplayMode.Both, "setting:timer_vertical_offset", "TIMER VERTICAL OFFSET")
                .WithDefaultValue(0)
                .WithGetter(() => Config.TimerVerticalOffset)
                .WithSetter(x => Config.TimerVerticalOffset = x)
                .LimitedByRange(-100, 100)
                .WithDescription("Set the vertical position of the timer."),

                new SubMenu(MenuDisplayMode.Both, "menu:interface.advanced", "ADVANCED SETTINGS")
                .NavigatesTo(advancedDisplayMenu)
                .WithDescription("Configure advanced settings for the hud."),

                new ActionButton(MenuDisplayMode.Both, "action:preview_hud", "PREVIEW HUD")
                .WhenClicked(() => VisualDisplay.ForceDisplay = !VisualDisplay.ForceDisplay)
                .WithDescription("Show the hud to preview changes.")
            };

            MenuTree audioMenu = new MenuTree("menu.mod.nitronichud#audio", "Audio Options");

            MenuTree settingsMenu = new MenuTree("menu.mod.nitronichud", "Nitronic HUD Settings");

            settingsMenu.Add(
                new SubMenu(MenuDisplayMode.Both, "menu:interface", "DISPLAY")
                .NavigatesTo(displayMenu)
                .WithDescription("Configure settings for the visual interface."));

            if (Application.platform != RuntimePlatform.LinuxPlayer)
            {
                settingsMenu.Add(
                    new SubMenu(MenuDisplayMode.Both, "menu:interface", "AUDIO".Colorize(Colors.gray))
                    .NavigatesTo(audioMenu)
                    .WithDescription("Configure audio settings for the countdown announcer."));
            }

            settingsMenu.Add(
                new ActionButton(MenuDisplayMode.MainMenu, "menu:interface", "PREVIEW SETTINGS".Colorize(Colors.gray))
                .WhenClicked(() =>
            {
                MessageBox.Create("This feature isn't implemented yet but will be in a future release.", "ERROR")
                .SetButtons(MessageButtons.Ok)
                .Show();
            })
                .WithDescription("Start the animation sequence thet plays when a level starts to preview the settings."));

            //Menus.AddNew(MenuDisplayMode.Both, settingsMenu, "NITRONIC HUD [1E90FF](BETA)[-]", "Settings for the Nitronic HUD mod.");
            Menus.AddNew(MenuDisplayMode.Both, settingsMenu, "NITRONIC HUD [FFBF1E](RELEASE CANDIDATE)[-]", "Settings for the Nitronic HUD mod.");
        }
 public static void ShowUnavailableMessage()
 {
     MessageBox.Create(InternalResources.Strings.MenuSystem.UnavailableMenuError, InternalResources.Strings.MenuSystem.UnavailableMenuErrorTitle)
     .SetButtons(Distance.Data.MessageButtons.Ok)
     .Show();
 }
        internal static bool Prefix(ZEventListener __instance, IVisitor visitor)
        {
            Mod mod = Mod.Instance;

            if (!(visitor is NGUIComponentInspector))
            {
                return(true);
            }

            NGUIComponentInspector inspector = visitor as NGUIComponentInspector;

            if (!__instance.eventName_.StartsWith(CustomDataInfo.GetPrefix <MusicTrack>()))
            {
                return(true);
            }

            visitor.Visit("eventName_", ref __instance.eventName_, false, null);
            visitor.Visit("delay_", ref __instance.delay_, false, null);

            var isEditing = inspector.isEditing_;

            var data = mod.Variables.CachedMusicTrack.GetOrCreate(__instance, () => new MusicTrack());

            if (data.LastWrittenData != __instance.eventName_)
            {
                data.ReadObject(__instance);
                data.LastWrittenData = __instance.eventName_;
                data.EmbedFile       = (data.Embedded.Length > 0 ? "Embedded" : "");
                data.LastWritten     = data.Clone();
            }
            else if (!isEditing)
            {
                var anyChanges = false;
                var old        = data.LastWritten;

                if (data.Name != old.Name || data.DownloadUrl != old.DownloadUrl || data.FileType != old.FileType)
                {
                    anyChanges = true;
                }

                if (data.EmbedFile != old.EmbedFile)
                {
                    var newRef = data.EmbedFile;
                    if (newRef?.Length == 0)
                    {
                        data.Embedded = new byte[0];
                        anyChanges    = true;
                    }
                    else
                    {
                        try
                        {
                            newRef = newRef.Trim('"', '\'');
                            var extension = Path.GetExtension(newRef);
                            var file      = FileEx.ReadAllBytes(newRef);
                            data.Embedded    = file ?? throw new Exception("Missing file");
                            data.FileType    = extension;
                            data.DownloadUrl = "";
                            anyChanges       = true;
                        }
                        catch (Exception e)
                        {
                            data.Embedded = new byte[0];
                            data.FileType = ".mp3";
                            anyChanges    = true;

                            MessageBox.Create($"Failed to embed {newRef} because {e}", "TRACK MUSIC ERROR")
                            .SetButtons(MessageButtons.Ok)
                            .Show();

                            Mod.Instance.Logger.Error($"Failed to embed {newRef} because {e}");
                        }
                    }
                }
                if (anyChanges)
                {
                    data.FileLocation = null;
                    data.Attempted    = false;
                    data.EmbedFile    = (data.Embedded.Length > 0 ? "Embedded" : "");
                    data.NewVersion();
                    data.WriteObject(__instance);
                    data.LastWrittenData = __instance.eventName_;
                    data.LastWritten     = data.Clone();
                    var lastTrackName = mod.Variables.CurrentTrackName;

                    if (lastTrackName == old.Name)
                    {
                        mod.SoundPlayer.StopCustomMusic();
                    }

                    mod.SoundPlayer.DownloadAllTracks();

                    if (lastTrackName == data.Name || mod.SoundPlayer.GetMusicChoiceValue(G.Sys.LevelEditor_.WorkingSettings_.gameObject, "Level") == data.Name)
                    {
                        mod.SoundPlayer.PlayTrack(data.Name, 0f);
                    }
                }
            }

            visitor.Visit("Name", ref data.Name, null);
            visitor.Visit("Type", ref data.FileType, null);
            visitor.Visit("Embed File", ref data.EmbedFile, mod.Variables.MusicTrackOptions);

            visitor.VisitAction("Select File", () =>
            {
                var dlgOpen = new System.Windows.Forms.OpenFileDialog
                {
                    Filter = "Music file (*.mp3, *.wav, *.aiff)|*.mp3;*.wav;*.aiff|All Files (*.*)|*.*",
                    SupportMultiDottedExtensions = true,
                    RestoreDirectory             = true,
                    Title           = "Select a music file",
                    CheckFileExists = true,
                    CheckPathExists = true
                };

                if (dlgOpen.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    data.EmbedFile = dlgOpen.FileName;
                }
            }, mod.Variables.MusicTrackButtonOptions);

            visitor.Visit("Download URL", ref data.DownloadUrl, null);

            var Error = data.GetError();

            if (Error == null)
            {
                Error = "None".Colorize(Colors.white);
            }
            else
            {
                Error = Error.Colorize(Colors.red);
            }
            //visitor.Visit("Error", ref Error, null);

            visitor.VisualLabel($"Error: {Error}".Colorize(Colors.white));

            return(false);
        }
        public void CreateSettingsMenu()
        {
            Menus.AddNew(MenuDisplayMode.Both, new MenuTree("menu.r&d.main", "Research and Development Test Mod")
            {
                new ActionButton(MenuDisplayMode.Both, "gc_collect", "System.GC.Collect()")
                .WhenClicked(() => GC.Collect())
                .WithDescription("Forces immediate garbage collection by the .Net runtime"),

                new ActionButton(MenuDisplayMode.Both, "resources_unload", "UnityEngine.Resources.UnloadUnusedAssets()")
                .WhenClicked(() => Resources.UnloadUnusedAssets())
                .WithDescription("Forces the Unity engine to unload any asset that is loaded and unused at the moment"),

                new ActionButton(MenuDisplayMode.Both, "print_alloc", "System.GC.GetTotalMemory(false)")
                .WhenClicked(() => MessageBox.Create(GC.GetTotalMemory(false).ToString(), "").SetButtons(MessageButtons.Ok).Show())
                .WithDescription("Print the number of bytes of managed memory allocated to the .Net runtime (for this process only)")
            });

            /*
             * MenuTree advancedDisplayMenu = new MenuTree("menu.mod.nitronichud#interface.advanced", "Advanced Interface Options")
             * {
             *      new FloatSlider(MenuDisplayMode.Both, "setting:heat_blink_start_amount", "HEAT BLINK START AMOUNT")
             *      .LimitedByRange(0.0f, 1.0f)
             *      .WithDefaultValue(0.7f)
             *      .WithGetter(() => Config.HeatBlinkStartAmount)
             *      .WithSetter(x => Config.HeatBlinkStartAmount = x)
             *      .WithDescription("Set the heat treshold after which the hud starts to blink."),
             *
             *      new FloatSlider(MenuDisplayMode.Both, "setting:heat_blink_frequence", "HEAT BLINK FREQUENCE")
             *      .LimitedByRange(0.0f, 10.0f)
             *      .WithDefaultValue(2.0f)
             *      .WithGetter(() => Config.HeatBlinkFrequence)
             *      .WithSetter(x => Config.HeatBlinkFrequence = x)
             *      .WithDescription("Set the hud blink rate (per second)."),
             *
             *      new FloatSlider(MenuDisplayMode.Both, "setting:heat_blink_frequence_boost", "HEAT BLINK FREQUENCE BOOST")
             *      .LimitedByRange(0.0f, 10.0f)
             *      .WithDefaultValue(1.15f)
             *      .WithGetter(() => Config.HeatBlinkFrequenceBoost)
             *      .WithSetter(x => Config.HeatBlinkFrequenceBoost = x)
             *      .WithDescription("Sets the blink rate boost.\nThe blink rate at 100% heat is the blink rate times this value (set this to 1 to keep the rate constant)."),
             *
             *      new FloatSlider(MenuDisplayMode.Both, "setting:heat_blink_amount", "HEAT BLINK AMOUNT")
             *      .LimitedByRange(0.0f, 1.0f)
             *      .WithDefaultValue(0.7f)
             *      .WithGetter(() => Config.HeatBlinkAmount)
             *      .WithSetter(x => Config.HeatBlinkAmount = x)
             *      .WithDescription("Sets the color intensity of the overheat blink animation (lower values means smaller color changes)."),
             *
             *      new FloatSlider(MenuDisplayMode.Both, "setting:heat_flame_amount", "HEAT FLAME AMOUNT")
             *      .WithDefaultValue(0.5f)
             *      .LimitedByRange(0.0f, 1.0f)
             *      .WithGetter(() => Config.HeatFlameAmount)
             *      .WithSetter(x => Config.HeatFlameAmount = x)
             *      .WithDescription("Sets the color intensity of the overheat flame animation (lower values means smaller color changes).")
             * };
             *
             * MenuTree displayMenu = new MenuTree("menu.mod.nitronichud#interface", "Interface Options")
             * {
             *      new CheckBox(MenuDisplayMode.Both, "setting:display_countdown", "SHOW COUNTDOWN")
             *      .WithGetter(() => Config.DisplayCountdown)
             *      .WithSetter(x => Config.DisplayCountdown = x)
             *      .WithDescription("Displays the 3... 2... 1... RUSH countdown when playing a level."),
             *
             *      new CheckBox(MenuDisplayMode.Both, "setting:display_overheat", "SHOW OVERHEAT METERS")
             *      .WithGetter(() => Config.DisplayHeatMeters)
             *      .WithSetter(x => Config.DisplayHeatMeters = x)
             *      .WithDescription("Displays overheat indicator bars in the lower screen corners."),
             *
             *      new CheckBox(MenuDisplayMode.Both, "setting:display_timer", "SHOW TIMER")
             *      .WithGetter(() => Config.DisplayTimer)
             *      .WithSetter(x => Config.DisplayTimer = x)
             *      .WithDescription("Displays the timer at the bottom of the screen."),
             *
             *      new IntegerSlider(MenuDisplayMode.Both, "setting:overheat_scale", "OVERHEAT SCALE")
             *      .WithDefaultValue(20)
             *      .WithGetter(() => Mathf.RoundToInt(Config.HeatMetersScale * 20.0f))
             *      .WithSetter(x => Config.HeatMetersScale = x / 20.0f)
             *      .LimitedByRange(1, 50)
             *      .WithDescription("Set the size of the overheat bars."),
             *
             *      new IntegerSlider(MenuDisplayMode.Both, "setting:overheat_horizontal_offset", "OVERHEAT HORIZONTAL POSITION")
             *      .WithDefaultValue(0)
             *      .WithGetter(() => Config.HeatMetersHorizontalOffset)
             *      .WithSetter(x => Config.HeatMetersHorizontalOffset = x)
             *      .LimitedByRange(-200, 200)
             *      .WithDescription("Set the horizontal position offset of the overheat bars."),
             *
             *      new IntegerSlider(MenuDisplayMode.Both, "setting:overheat_vertical_offset", "OVERHEAT VERTICAL POSITION")
             *      .WithDefaultValue(0)
             *      .WithGetter(() => Config.HeatMetersVerticalOffset)
             *      .WithSetter(x => Config.HeatMetersVerticalOffset = x)
             *      .LimitedByRange(-100, 100)
             *      .WithDescription("Set the vertical position offset of the overheat bars."),
             *
             *      new IntegerSlider(MenuDisplayMode.Both, "setting:timer_scale", "TIMER SCALE")
             *      .WithDefaultValue(20)
             *      .WithGetter(() => Mathf.RoundToInt(Config.TimerScale * 20.0f))
             *      .WithSetter(x => Config.TimerScale = x / 20.0f)
             *      .LimitedByRange(1, 50)
             *      .WithDescription("Set the size of the timer."),
             *
             *      new IntegerSlider(MenuDisplayMode.Both, "setting:timer_vertical_offset", "TIMER VERTICAL OFFSET")
             *      .WithDefaultValue(0)
             *      .WithGetter(() => Config.TimerVerticalOffset)
             *      .WithSetter(x => Config.TimerVerticalOffset = x)
             *      .LimitedByRange(-100, 100)
             *      .WithDescription("Set the vertical position of the timer."),
             *
             *      new SubMenu(MenuDisplayMode.Both, "menu:interface.advanced", "ADVANCED SETTINGS")
             *      .NavigatesTo(advancedDisplayMenu)
             *      .WithDescription("Configure advanced settings for the hud."),
             *
             *      new ActionButton(MenuDisplayMode.Both, "action:preview_hud", "PREVIEW HUD")
             *      .WhenClicked(() => VisualDisplay.ForceDisplay = !VisualDisplay.ForceDisplay)
             *      .WithDescription("Show the hud to preview changes.")
             * };
             *
             * MenuTree audioMenu = new MenuTree("menu.mod.nitronichud#audio", "Audio Options");
             *
             * MenuTree settingsMenu = new MenuTree("menu.mod.nitronichud", "Nitronic HUD Settings");
             *
             * settingsMenu.Add(
             *      new SubMenu(MenuDisplayMode.Both, "menu:interface", "DISPLAY")
             *      .NavigatesTo(displayMenu)
             *      .WithDescription("Configure settings for the visual interface."));
             *
             * if (Application.platform != RuntimePlatform.LinuxPlayer)
             * {
             *      settingsMenu.Add(
             *      new SubMenu(MenuDisplayMode.Both, "menu:interface", "AUDIO".Colorize(Colors.gray))
             *      .NavigatesTo(audioMenu)
             *      .WithDescription("Configure audio settings for the countdown announcer."));
             * }
             *
             * settingsMenu.Add(
             *      new ActionButton(MenuDisplayMode.MainMenu, "menu:interface", "PREVIEW SETTINGS".Colorize(Colors.gray))
             *      .WhenClicked(() =>
             *      {
             *              MessageBox.Create("This feature isn't implemented yet but will be in a future release.", "ERROR")
             *              .SetButtons(MessageButtons.Ok)
             *              .Show();
             *      })
             *      .WithDescription("Start the animation sequence thet plays when a level starts to preview the settings."));
             *
             * //Menus.AddNew(MenuDisplayMode.Both, settingsMenu, "NITRONIC HUD [1E90FF](BETA)[-]", "Settings for the Nitronic HUD mod.");
             * Menus.AddNew(MenuDisplayMode.Both, settingsMenu, "NITRONIC HUD [FFBF1E](RELEASE CANDIDATE)[-]", "Settings for the Nitronic HUD mod.");
             */
        }
Beispiel #25
0
 //-----------------------------------------------------------------------------------
 public void OnExitMatch()
 {
     MessageBox.Create(GetCanvas(), "Exit Match?", MessageBox.EType.YES_NO,
                       () => { OnExitMatch(true); },
                       () => { OnExitMatch(false); });
 }
Beispiel #26
0
 //-----------------------------------------------------------------------------------
 public void OnQuit()
 {
     MessageBox.Create(GetCanvas(), "Are you sure?", MessageBox.EType.OK_CANCEL, () => { Application.Quit(); });
 }