예제 #1
0
        /// <summary>
        /// Creates floating tool window for Lane Arrow controls and adds keyboard hints too.
        /// </summary>
        /// <param name="numLanes">How many groups of buttons.</param>
        private void CreateLaneArrowsWindow(int numLanes)
        {
            var parent = UIView.GetAView();

            ToolWindow = (LaneArrowToolWindow)parent.AddUIComponent(typeof(LaneArrowToolWindow));
            ToolWindow.SetOpacity(
                U.UOpacityValue.FromOpacity(0.01f * GlobalConfig.Instance.Main.GuiOpacity));

            RepositionWindowToNode(); // reposition 1st time to avoid visible window jump

            using (var builder = new U.UiBuilder <LaneArrowToolWindow>(ToolWindow)) {
                builder.ResizeFunction(r => { r.FitToChildren(); });
                builder.SetPadding(UConst.UIPADDING);

                ToolWindow.SetupControls(builder, numLanes);

                // On Delete being pressed
                ToolWindow.eventKeyDown += (component, param) => {
                    if (KeybindSettingsBase.LaneConnectorDelete.IsPressed(param))
                    {
                        OnResetToDefaultPressed();
                    }
                };

                // Resize everything correctly
                // builder.Control.SetTransparency(GlobalConfig.Instance.Main.GuiTransparency);
                builder.Done();
                RepositionWindowToNode(); // reposition again 2nd time now that size is known
            }
        }
        public override void Build(U.UiBuilder <U.Panel.UPanel> builder)
        {
            // Capacity 9 will fit all modifiers and separators and the text
            StringBuilder text = new StringBuilder(capacity: 9);

            text.Append($"<color {UConst.SHORTCUT_TEXT_HEX}>");

            if (this.shift_)
            {
                text.Append(Translation.Options.Get("Shortcut.Modifier:Shift"));
                text.Append("+");
            }
            if (this.ctrl_)
            {
                text.Append(Translation.Options.Get("Shortcut.Modifier:Ctrl"));
                text.Append("+");
            }
            if (this.alt_)
            {
                text.Append(Translation.Options.Get("Shortcut.Modifier:Alt"));
                text.Append("+");
            }

            text.Append(TranslationForMouseButton(this.button_));

            text.Append("</color> ");
            text.Append(this.localizedText_);

            using (UiBuilder <ULabel> labelB = builder.Label <U.Label.ULabel>(text.ToString())) {
                labelB.Control.processMarkup = true;
                labelB.ResizeFunction(
                    r => { r.Stack(mode: UStackMode.NewRowBelow); });
            }
        }
예제 #3
0
        public override void Build(U.UiBuilder <U.UPanel> builder)
        {
            StringBuilder text           = new StringBuilder();
            List <string> keybindStrings = this.keybindSetting_.ToLocalizedStringList();
            bool          firstShortcut  = true; // tracking | separators between multiple keybinds

            using (UiBuilder <ULabel> labelB = builder.Label <U.ULabel>(string.Empty)) {
                labelB.Control.processMarkup = true;
                labelB.ResizeFunction(
                    r => {
                    r.Stack(mode: UStackMode.NewRowBelow);
                });

                foreach (string keybindStr in keybindStrings)
                {
                    if (!firstShortcut)
                    {
                        text.Append("| ");
                    }
                    else
                    {
                        firstShortcut = false;
                    }

                    text.Append($"<color {UConst.SHORTCUT_TEXT_HEX}>{keybindStr}</color>");
                }

                text.Append(" ");
                text.Append(this.localizedText_);
                labelB.Control.text = text.ToString();
            }
        }
 public override void Build(U.UiBuilder <U.Panel.UPanel> builder)
 {
     using (UiBuilder <ULabel> labelB = builder.Label <U.Label.ULabel>(string.Empty)) {
         labelB.ResizeFunction(r => { r.Stack(mode: UStackMode.NewRowBelow); });
         labelB.Control.text    = this.localizedText_;
         labelB.Control.opacity = 0.8f;
     }
 }
예제 #5
0
파일: UIBuilder.cs 프로젝트: pilotMike/TMPE
        /// <summary>
        /// Generic window creation.
        /// Creates a window with generic padding (4px). The size will be "fit to children".
        /// Calls a custom function after the setup is done, there you can populate the window.
        /// </summary>
        /// <typeparam name="TWindow">The window root panel type.</typeparam>
        /// <param name="setupFn">Function called on to perform window post-setup.</param>
        /// <returns>The new window panel.</returns>
        public static TWindow CreateWindow <TWindow>(Action <UiBuilder <TWindow> > setupFn)
            where TWindow : UIComponent, ISmartSizableControl
        {
            var parent = UIView.GetAView();
            var window = (TWindow)parent.AddUIComponent(typeof(TWindow));

            using (var builder = new U.UiBuilder <TWindow>(window)) {
                builder.ResizeFunction(r => { r.FitToChildren(); });
                builder.SetPadding(UConst.UIPADDING);

                setupFn(builder);

                // Resize everything correctly
                builder.Done();
            }

            return(window);
        }
예제 #6
0
        /// <summary>
        /// Called from ModUI when need to create or re-create the MainMenu panel.
        /// </summary>
        /// <returns>The created panel.</returns>
        internal static MainMenuWindow CreateMainMenuWindow()
        {
            UIView         parent = UIView.GetAView();
            MainMenuWindow window = (MainMenuWindow)parent.AddUIComponent(typeof(MainMenuWindow));

            window.gameObject.AddComponent <CustomKeyHandler>();

            using (var builder = new U.UiBuilder <MainMenuWindow>(window)) {
                builder.ResizeFunction(r => { r.FitToChildren(); });
                builder.SetPadding(UConst.UIPADDING);

                window.SetupControls(builder);
                // window.SetTransparency(GlobalConfig.Instance.Main.GuiTransparency);

                // Resize everything correctly
                builder.Done();
            }

            return(window);
        }
예제 #7
0
        /// <summary>
        /// Creates floating tool window for Lane Arrow controls and adds keyboard hints too.
        /// </summary>
        /// <param name="numLanes">How many groups of buttons.</param>
        private void CreateLaneArrowsWindow(int numLanes)
        {
            var parent = UIView.GetAView();

            ToolWindow = (LaneArrowToolWindow)parent.AddUIComponent(typeof(LaneArrowToolWindow));
            ToolWindow.SetOpacity(
                U.UOpacityValue.FromOpacity(0.01f * GlobalConfig.Instance.Main.GuiOpacity));

            RepositionWindowToNode(); // reposition 1st time to avoid visible window jump

            using (var builder = new U.UiBuilder <LaneArrowToolWindow>(ToolWindow)) {
                builder.ResizeFunction(r => { r.FitToChildren(); });
                builder.SetPadding(UConst.UIPADDING);

                ToolWindow.SetupControls(builder, numLanes);

                // Resize everything correctly
                builder.Done();
                RepositionWindowToNode(); // reposition again 2nd time now that size is known
            }
        }
예제 #8
0
 /// <summary>Called by the OnscreenDisplay to add the contents of this item.</summary>
 /// <param name="builder">UI builder used to populate the panel.</param>
 public abstract void Build(U.UiBuilder <U.UPanel> builder);