예제 #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
            }
        }
예제 #2
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);
        }
예제 #3
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);
        }
예제 #4
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
            }
        }