Inheritance: MonoBehaviour
Exemple #1
0
        public override void Load()
        {
            base.Load();

            //this.BackgroundColor = Color.Black;

            Entity title = new Entity(new PointF(0, -100), new Size(512, 250), new Texture(Resources.Logo));
            title.Parallax = new PointF(0, 0);
            this.Add(title);

            GUITextField portBox = new GUITextField(new PointF(0, 90), new Size(300, 30), " ");
            portBox.InitTexture();
            portBox.TextColor = Color.White;
            this.Add(portBox);

            GUIButton start = new GUIButton(new Size(150, 30), "Start Server");
            start.BackgroundColor = Color.Crimson;
            start.TextColor = Color.DarkRed;
            start.Y = 140;
            this.Add(start);
            start.Pressed += (object sender, EventArgs e) =>
            {
                GV.Engine.SetWorld(new ServerUI());
            };

            portBox.OnEnter += (object sender, EventArgs e) => {
                start.SetState(ButtonState.Pressed);
            };
        }
    void Start()
    {
        // We copy the GUIAssets to prevent permenant changes to the assets.
        titleScreen_Splash = titleScreen_Splash.Copy();
        titleScreen_Menu = titleScreen_Menu.Copy();

        // Get the GUIDrawTexture control using the Find<T> method.
        textureControl = titleScreen_Splash.Find<GUIDrawTexture>("Texture");
        // Set the first splash image.
        textureControl.image = splashes[0];

        // Get the buttons using Find<T>.
        buttonNew = titleScreen_Menu.Find<GUIButton>("New Button");
        buttonLoad = titleScreen_Menu.Find<GUIButton>("Load Button");
        buttonQuit = titleScreen_Menu.Find<GUIButton>("Quit Button");

        // Prepare to display the splash screen.
        splashCounter = 0;
        splashID = 0;
        showSplash = true;

        // Prepare the menu to move from below the screen to the center.
        menuEndPosition = titleScreen_Menu.position;
        titleScreen_Menu.position.x = menuEndPosition.x = (Screen.width - titleScreen_Menu.position.width) / 2;
        titleScreen_Menu.position.y = Screen.height;
        menuEndPosition.y = (Screen.height - titleScreen_Menu.position.height) / 2;

        // Set the splash screen to the center.
        titleScreen_Splash.position.x = (Screen.width - titleScreen_Splash.position.width) / 2;
        titleScreen_Splash.position.y = (Screen.height - titleScreen_Splash.position.height) / 2;
    }
        /// <inheritdoc/>
        protected internal override void Initialize()
        {
            ScriptCode scriptCode = InspectedObject as ScriptCode;
            if (scriptCode == null)
                return;

            importOptions = GetImportOptions();

            isEditorField.OnChanged += x =>
            {
                importOptions.EditorScript = x;
            };

            GUIPanel textPanel = Layout.AddPanel();
            GUILayout textLayoutY = textPanel.AddLayoutY();
            textLayoutY.AddSpace(5);
            GUILayout textLayoutX = textLayoutY.AddLayoutX();
            textLayoutX.AddSpace(5);
            textLayoutX.AddElement(textLabel);
            textLayoutX.AddSpace(5);
            textLayoutY.AddSpace(5);

            GUIPanel textBgPanel = textPanel.AddPanel(1);
            textBgPanel.AddElement(textBg);

            Layout.AddElement(isEditorField);

            GUIButton reimportButton = new GUIButton(new LocEdString("Reimport"));
            reimportButton.OnClick += TriggerReimport;

            GUILayout reimportButtonLayout = Layout.AddLayoutX();
            reimportButtonLayout.AddElement(reimportButton);
            reimportButtonLayout.AddFlexibleSpace();
        }
    void Start()
    {
        // Enable guiTexture (but keep it faded out if button disabled)
        guiTexture.enabled = true;

        // Set initial alpha to minimum
        SetAlpha(normalAlpha);

        // Get attached button
        button = GetComponent<GUIButton>();
        if (button != null && !button.enabled)
        {
            SetAlpha(0);
        }
    }
	private void Start()
	{
		var Controls = GetComponents<GUIControl>().ToList();
		GUIArea_1157020965 = (GUIArea)Controls.First(Control => Control.Name == "GUIArea_1157020965");
		GUIArea_977234804 = (GUIArea)Controls.First(Control => Control.Name == "GUIArea_977234804");
		GUIButton_2085473440 = (GUIButton)Controls.First(Control => Control.Name == "GUIButton_2085473440");
		GUIButton_955361902 = (GUIButton)Controls.First(Control => Control.Name == "GUIButton_955361902");
		GUIButton_1226782659 = (GUIButton)Controls.First(Control => Control.Name == "GUIButton_1226782659");
		GUIButton_444708301 = (GUIButton)Controls.First(Control => Control.Name == "GUIButton_444708301");
		GUIButton_444708301.Click += Multiplayer;
		GUIButton_790021684 = (GUIButton)Controls.First(Control => Control.Name == "GUIButton_790021684");
		GUIButton_520576317 = (GUIButton)Controls.First(Control => Control.Name == "GUIButton_520576317");
		GUIButton_520576317.Click += Quit;
		Initialize();
	}
Exemple #6
0
        public void AddGuiButton()
        {
            _guiGameOverText = new GUIText("Game Over!", _guiLatoBlack, Instances.Main.Width / 2 - 50, 150);
            _guiHandler.Add(_guiGameOverText);

            _guiFuseeLink = new GUIButton("Reset", _guiLatoBlack, Instances.Main.Width /2 -150, 300, 300, 87);

            _guiFuseeLink.ButtonColor = new float4(0, 0, 0, 0);
            _guiFuseeLink.BorderColor = new float4(0, 0.6f, 0.2f, 1);
            _guiFuseeLink.BorderWidth = 0;
            _guiFuseeLink.OnGUIButtonDown += _guiFuseeLink_OnGUIButtonDown;
            _guiFuseeLink.OnGUIButtonEnter += _guiFuseeLink_OnGUIButtonEnter;

            _guiHandler.Add(_guiFuseeLink);
            gameOverScreen = true;
        }
	private void Start()
	{
		var Controls = GetComponents<GUIControl>().ToList();
		MainArea = (GUIArea)Controls.First(Control => Control.Name == "MainArea");
		CenterArea = (GUIArea)Controls.First(Control => Control.Name == "CenterArea");
		ButtonsArea = (GUIArea)Controls.First(Control => Control.Name == "ButtonsArea");
		JoinRoomButton = (GUIButton)Controls.First(Control => Control.Name == "JoinRoomButton");
		JoinRoomButton.Click += JoinRoom;
		CreateRoomButton = (GUIButton)Controls.First(Control => Control.Name == "CreateRoomButton");
		CreateRoomButton.Click += CreateRoom;
		ListArea = (GUIArea)Controls.First(Control => Control.Name == "ListArea");
		GamesTable = (MultiplayerGUITable)Controls.First(Control => Control.Name == "GamesTable");
		BottomArea = (GUIArea)Controls.First(Control => Control.Name == "BottomArea");
		BackButton = (GUIButton)Controls.First(Control => Control.Name == "BackButton");
		BackButton.Click += SwitchBack;
		Initialize();
	}
        public static void hide()
        {
            if (!_isShown)
                return;

            Debug.Log("Hiding Main Page.");

            _pageTitle.destroy();
            _pageTitle = null;

            _backButton.destroy();
            _backButton = null;

            _levelsContainer.destroy();
            _levelsContainer = null;

            _isShown = false;
        }
Exemple #9
0
        private void CreateThirdPartyGUI(GUILayoutY layout, string name, string webURL, string licenseFile)
        {
            GUILabel label = new GUILabel(new LocEdString(name), GUIOption.FixedWidth(150));
            GUIButton linkBtn = new GUIButton(new LocEdString("Website"), GUIOption.FixedWidth(50));
            GUIButton licenseBtn = new GUIButton(new LocEdString("License"), GUIOption.FixedWidth(50));

            string licensePath = "..\\..\\..\\License\\Third Party\\" + licenseFile;

            GUILayoutX horzLayout = layout.AddLayoutX();
            horzLayout.AddSpace(10);
            horzLayout.AddElement(label);
            horzLayout.AddSpace(10);
            horzLayout.AddElement(linkBtn);
            horzLayout.AddSpace(5);
            horzLayout.AddElement(licenseBtn);
            horzLayout.AddSpace(10);

            linkBtn.OnClick += () => { System.Diagnostics.Process.Start(webURL); };
            licenseBtn.OnClick += () => { System.Diagnostics.Process.Start(licensePath); };
        }
Exemple #10
0
        public void Resize()
        {
            if(_guiGameOverText != null && gameOverScreen)
            {
                _guiHandler.Remove(_guiGameOverText);
                _guiGameOverText = new GUIText("Game Over!", _guiLatoBlack, Instances.Main.Width / 2 - 50, 150);
                _guiHandler.Add(_guiGameOverText);

            }

            if (_guiFuseeLink != null && gameOverScreen)
            {
                _guiHandler.Remove(_guiFuseeLink);
                _guiFuseeLink = new GUIButton("Reset", _guiLatoBlack, Instances.Main.Width / 2 - 150, 300, 300, 87);

                _guiFuseeLink.ButtonColor = new float4(0, 0, 0, 0);
                _guiFuseeLink.BorderColor = new float4(0, 0.6f, 0.2f, 1);
                _guiFuseeLink.BorderWidth = 0;
                _guiFuseeLink.OnGUIButtonDown += _guiFuseeLink_OnGUIButtonDown;
                _guiFuseeLink.OnGUIButtonEnter += _guiFuseeLink_OnGUIButtonEnter;

                _guiHandler.Add(_guiFuseeLink);
            }

            if(_guiPoints != null)
            {
                _guiHandler.Remove(_guiPoints);
                _guiPoints = new GUIText("SCORE" + " " + Instances.Main.score, _guiLatoBlack, Instances.Main.Width - 150, 57);
                _guiHandler.Add(_guiPoints);
            }

            _guiHandler.Refresh();
        }
Exemple #11
0
 void _guiFuseeLink_OnGUIButtonDown(GUIButton sender, GUIButtonEventArgs mea)
 {
     Debug.WriteLine("Button wurde geklickt");
     Instances.Main.RestartGame();
     RemoveGuiButton();
     //OpenLink("http://fusee3d.org");
 }
Exemple #12
0
 public void _guiFuseeLink_OnGUIButtonEnter(GUIButton sender, GUIButtonEventArgs mea)
 {
     _guiFuseeLink.ButtonColor = new float4(0, 0.6f, 0.2f, 0.4f);
     _guiFuseeLink.BorderWidth = 1;
 }
    static FlowControl()
    {
        // Draw Panel

        // Draw buttons:
        // Create "Start a Lesson" Button
        GUIButton startALessonButton = new GUIButton();
        startALessonButton
            .SetText("Pick A Lesson")
                .OnClick(FlowControl.GoToLessonScreen)
                .SetBox((new Box())
                        .SetMarginTop (0.0f)
                        .SetMarginRight (0.0f)
                        .SetMarginBottom (0.80f)
                        .SetMarginLeft (0.0f));

        // Create "Visit Mantaray AR Website" Button
        GUIButton getARTargets = new GUIButton();
        getARTargets
            .SetText(GUIConst.getARTargets)
                .OnClick(FlowControl.GetTargets)
                .SetBox((new Box())
                        .SetMarginTop (0.25f)
                        .SetMarginRight (0.0f)
                        .SetMarginBottom (0.55f)
                        .SetMarginLeft (0.0f));

        // Create "Visit Mantaray AR Website" Button
        GUIButton visitMantarayARWebsiteButton = new GUIButton();
        visitMantarayARWebsiteButton
            .SetText(GUIConst.visitMantarayARWebsiteText)
                .OnClick(FlowControl.GoToWebsite)
                .SetBox((new Box())
                        .SetMarginTop (0.50f)
                        .SetMarginRight (0.0f)
                        .SetMarginBottom (0.30f)
                        .SetMarginLeft (0.0f));

        // Create "Return" Button
        GUIButton exitMenuButton = new GUIButton();
        exitMenuButton
            .SetText("Go Back")
                .OnClick(FlowControl.ExitMenu)
                .SetBox((new Box())
                        .SetMarginTop (0.75f)
                        .SetMarginRight (0.0f)
                        .SetMarginBottom (0.05f)
                        .SetMarginLeft (0.0f));

        // Build the GUI
        GUIFactory factory = new GUIFactory ();

        factory
            .Append(new GUIImage("dark-transparent-swatch").SetScaleMode(ScaleMode.StretchToFill));

        factory
            .CreateContainer ()
                .SetBox ((new Box ())
                         .SetMarginTop (0.2f)
                         .SetMarginRight (0.2f)
                         .SetMarginBottom (0.2f)
                         .SetMarginLeft (0.2f))
                .Append (startALessonButton)
                .Append (getARTargets)
                .Append (visitMantarayARWebsiteButton)
                .Append (exitMenuButton);

        FlowControl.gui = factory.Build();
    }
        private void OnInitialize()
        {
            Title = "Project Manager";

            Width = 500;
            Height = 290;

            GUILayout vertLayout = GUI.AddLayoutY();

            vertLayout.AddSpace(5);
            GUILayout firstRow = vertLayout.AddLayoutX();
            vertLayout.AddFlexibleSpace();
            GUILayout secondRow = vertLayout.AddLayoutX();
            vertLayout.AddSpace(5);
            GUILayout thirdRow = vertLayout.AddLayoutX();
            vertLayout.AddFlexibleSpace();
            GUILayout fourthRow = vertLayout.AddLayoutX();
            vertLayout.AddSpace(5);

            projectInputBox = new GUITextField(new LocEdString("Project path"), 70, false, "", GUIOption.FixedWidth(398));
            projectInputBox.Value = EditorSettings.LastOpenProject;

            GUIButton openBtn = new GUIButton(new LocEdString("Open"), GUIOption.FixedWidth(75));
            openBtn.OnClick += OpenProject;

            firstRow.AddSpace(5);
            firstRow.AddElement(projectInputBox);
            firstRow.AddSpace(15);
            firstRow.AddElement(openBtn);
            firstRow.AddSpace(5);

            GUILabel recentProjectsLabel = new GUILabel(new LocEdString("Recent projects:"));

            secondRow.AddSpace(5);
            secondRow.AddElement(recentProjectsLabel);
            secondRow.AddFlexibleSpace();
            GUIButton browseBtn = new GUIButton(new LocEdString("Browse"), GUIOption.FixedWidth(75));
            browseBtn.OnClick += BrowseClicked;
            secondRow.AddElement(browseBtn);
            secondRow.AddSpace(5);

            thirdRow.AddSpace(5);
            GUIPanel recentProjectsPanel = thirdRow.AddPanel();
            thirdRow.AddSpace(15);
            GUILayoutY thirdRowVertical = thirdRow.AddLayoutY();
            GUIButton createBtn = new GUIButton(new LocEdString("Create new"), GUIOption.FixedWidth(75));
            createBtn.OnClick += CreateClicked;
            thirdRowVertical.AddElement(createBtn);
            thirdRowVertical.AddFlexibleSpace();
            thirdRow.AddSpace(5);

            recentProjectsArea = new GUIScrollArea(GUIOption.FixedWidth(385), GUIOption.FixedHeight(170));
            GUILayoutX recentProjectsLayout = recentProjectsPanel.AddLayoutX();
            recentProjectsLayout.AddSpace(10);
            GUILayoutY recentProjectsPanelY = recentProjectsLayout.AddLayoutY();
            recentProjectsPanelY.AddSpace(5);
            recentProjectsPanelY.AddElement(recentProjectsArea);
            recentProjectsPanelY.AddSpace(5);
            recentProjectsLayout.AddFlexibleSpace();

            GUIPanel scrollAreaBgPanel = recentProjectsPanel.AddPanel(1);
            GUITexture scrollAreaBgTex = new GUITexture(null, true, EditorStylesInternal.ScrollAreaBg);
            scrollAreaBgPanel.AddElement(scrollAreaBgTex);

            autoLoadToggle = new GUIToggle("");
            autoLoadToggle.Value = EditorSettings.AutoLoadLastProject;

            GUILabel autoLoadLabel = new GUILabel(new LocEdString("Automatically load last open project"));

            GUIButton cancelBtn = new GUIButton(new LocEdString("Cancel"), GUIOption.FixedWidth(75));
            cancelBtn.OnClick += CancelClicked;

            fourthRow.AddSpace(5);
            fourthRow.AddElement(autoLoadToggle);
            fourthRow.AddElement(autoLoadLabel);
            fourthRow.AddFlexibleSpace();
            fourthRow.AddElement(cancelBtn);
            fourthRow.AddSpace(5);

            RefreshRecentProjects();
        }
Exemple #15
0
        protected override void CreateGUI()
        {
            controlContainer = new GUIFrame(new RectTransform(new Vector2(Sonar.controlBoxSize.X, 1 - Sonar.controlBoxSize.Y * 2), GuiFrame.RectTransform, Anchor.CenterLeft), "ItemUI");
            var paddedControlContainer = new GUIFrame(new RectTransform(controlContainer.Rect.Size - GUIStyle.ItemFrameMargin, controlContainer.RectTransform, Anchor.Center)
            {
                AbsoluteOffset = GUIStyle.ItemFrameOffset
            }, style: null);

            var steeringModeArea = new GUIFrame(new RectTransform(new Vector2(1, 0.4f), paddedControlContainer.RectTransform, Anchor.TopLeft), style: null);

            steeringModeSwitch = new GUIButton(new RectTransform(new Vector2(0.2f, 1), steeringModeArea.RectTransform), string.Empty, style: "SwitchVertical")
            {
                Selected   = autoPilot,
                Enabled    = true,
                ClickSound = GUISoundType.UISwitch,
                OnClicked  = (button, data) =>
                {
                    button.Selected = !button.Selected;
                    AutoPilot       = button.Selected;
                    if (GameMain.Client != null)
                    {
                        unsentChanges = true;
                        user          = Character.Controlled;
                    }
                    return(true);
                }
            };
            var steeringModeRightSide = new GUIFrame(new RectTransform(new Vector2(1.0f - steeringModeSwitch.RectTransform.RelativeSize.X, 0.8f), steeringModeArea.RectTransform, Anchor.CenterLeft)
            {
                RelativeOffset = new Vector2(steeringModeSwitch.RectTransform.RelativeSize.X, 0)
            }, style: null);

            manualPilotIndicator = new GUITickBox(new RectTransform(new Vector2(1, 0.45f), steeringModeRightSide.RectTransform, Anchor.TopLeft),
                                                  TextManager.Get("SteeringManual"), font: GUI.SubHeadingFont, style: "IndicatorLightRedSmall")
            {
                Selected = !autoPilot,
                Enabled  = false
            };
            autopilotIndicator = new GUITickBox(new RectTransform(new Vector2(1, 0.45f), steeringModeRightSide.RectTransform, Anchor.BottomLeft),
                                                TextManager.Get("SteeringAutoPilot"), font: GUI.SubHeadingFont, style: "IndicatorLightRedSmall")
            {
                Selected = autoPilot,
                Enabled  = false
            };
            manualPilotIndicator.TextBlock.OverrideTextColor(GUI.Style.TextColor);
            autopilotIndicator.TextBlock.OverrideTextColor(GUI.Style.TextColor);
            GUITextBlock.AutoScaleAndNormalize(manualPilotIndicator.TextBlock, autopilotIndicator.TextBlock);

            var autoPilotControls       = new GUIFrame(new RectTransform(new Vector2(0.75f, 0.62f), paddedControlContainer.RectTransform, Anchor.BottomCenter), "OutlineFrame");
            var paddedAutoPilotControls = new GUIFrame(new RectTransform(new Vector2(0.92f, 0.88f), autoPilotControls.RectTransform, Anchor.Center), style: null);

            maintainPosTickBox = new GUITickBox(new RectTransform(new Vector2(1, 0.333f), paddedAutoPilotControls.RectTransform, Anchor.TopCenter),
                                                TextManager.Get("SteeringMaintainPos"), font: GUI.SmallFont, style: "GUIRadioButton")
            {
                Enabled    = autoPilot,
                Selected   = maintainPos,
                OnSelected = tickBox =>
                {
                    if (maintainPos != tickBox.Selected)
                    {
                        unsentChanges = true;
                        user          = Character.Controlled;
                        maintainPos   = tickBox.Selected;
                        if (maintainPos)
                        {
                            if (controlledSub == null)
                            {
                                posToMaintain = null;
                            }
                            else
                            {
                                posToMaintain = controlledSub.WorldPosition;
                            }
                        }
                        else if (!LevelEndSelected && !LevelStartSelected)
                        {
                            AutoPilot = false;
                        }
                        if (!maintainPos)
                        {
                            posToMaintain = null;
                        }
                    }
                    return(true);
                }
            };
            int textLimit = (int)(MathHelper.Clamp(25 * GUI.xScale, 15, 35));

            levelStartTickBox = new GUITickBox(new RectTransform(new Vector2(1, 0.333f), paddedAutoPilotControls.RectTransform, Anchor.Center),
                                               GameMain.GameSession?.StartLocation == null ? "" : ToolBox.LimitString(GameMain.GameSession.StartLocation.Name, textLimit),
                                               font: GUI.SmallFont, style: "GUIRadioButton")
            {
                Enabled    = autoPilot,
                Selected   = levelStartSelected,
                OnSelected = tickBox =>
                {
                    if (levelStartSelected != tickBox.Selected)
                    {
                        unsentChanges      = true;
                        user               = Character.Controlled;
                        levelStartSelected = tickBox.Selected;
                        levelEndSelected   = !levelStartSelected;
                        if (levelStartSelected)
                        {
                            UpdatePath();
                        }
                        else if (!MaintainPos && !LevelEndSelected)
                        {
                            AutoPilot = false;
                        }
                    }
                    return(true);
                }
            };

            levelEndTickBox = new GUITickBox(new RectTransform(new Vector2(1, 0.333f), paddedAutoPilotControls.RectTransform, Anchor.BottomCenter),
                                             (GameMain.GameSession?.EndLocation == null || Level.IsLoadedOutpost) ? "" : ToolBox.LimitString(GameMain.GameSession.EndLocation.Name, textLimit),
                                             font: GUI.SmallFont, style: "GUIRadioButton")
            {
                Enabled    = autoPilot,
                Selected   = levelEndSelected,
                Visible    = GameMain.GameSession?.EndLocation != null,
                OnSelected = tickBox =>
                {
                    if (levelEndSelected != tickBox.Selected)
                    {
                        unsentChanges      = true;
                        user               = Character.Controlled;
                        levelEndSelected   = tickBox.Selected;
                        levelStartSelected = !levelEndSelected;
                        if (levelEndSelected)
                        {
                            UpdatePath();
                        }
                        else if (!MaintainPos && !LevelStartSelected)
                        {
                            AutoPilot = false;
                        }
                    }
                    return(true);
                }
            };
            maintainPosTickBox.RectTransform.IsFixedSize = levelStartTickBox.RectTransform.IsFixedSize = levelEndTickBox.RectTransform.IsFixedSize = false;
            maintainPosTickBox.RectTransform.MaxSize     = levelStartTickBox.RectTransform.MaxSize = levelEndTickBox.RectTransform.MaxSize =
                new Point(int.MaxValue, paddedAutoPilotControls.Rect.Height / 3);
            maintainPosTickBox.RectTransform.MinSize = levelStartTickBox.RectTransform.MinSize = levelEndTickBox.RectTransform.MinSize =
                Point.Zero;

            GUITextBlock.AutoScaleAndNormalize(scaleHorizontal: false, scaleVertical: true, maintainPosTickBox.TextBlock, levelStartTickBox.TextBlock, levelEndTickBox.TextBlock);

            GUIRadioButtonGroup destinations = new GUIRadioButtonGroup();

            destinations.AddRadioButton((int)Destination.MaintainPos, maintainPosTickBox);
            destinations.AddRadioButton((int)Destination.LevelStart, levelStartTickBox);
            destinations.AddRadioButton((int)Destination.LevelEnd, levelEndTickBox);
            destinations.Selected = (int)(maintainPos ? Destination.MaintainPos :
                                          levelStartSelected ? Destination.LevelStart : Destination.LevelEnd);

            // Status ->
            statusContainer = new GUIFrame(new RectTransform(Sonar.controlBoxSize, GuiFrame.RectTransform, Anchor.BottomLeft)
            {
                RelativeOffset = Sonar.controlBoxOffset
            }, "ItemUI");
            var paddedStatusContainer = new GUIFrame(new RectTransform(statusContainer.Rect.Size - GUIStyle.ItemFrameMargin, statusContainer.RectTransform, Anchor.Center, isFixedSize: false)
            {
                AbsoluteOffset = GUIStyle.ItemFrameOffset
            }, style: null);

            var elements = GUI.CreateElements(3, new Vector2(1f, 0.333f), paddedStatusContainer.RectTransform, rt => new GUIFrame(rt, style: null), Anchor.TopCenter, relativeSpacing: 0.01f);
            List <GUIComponent> leftElements = new List <GUIComponent>(), centerElements = new List <GUIComponent>(), rightElements = new List <GUIComponent>();

            for (int i = 0; i < elements.Count; i++)
            {
                var e     = elements[i];
                var group = new GUILayoutGroup(new RectTransform(Vector2.One, e.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft)
                {
                    RelativeSpacing = 0.01f,
                    Stretch         = true
                };
                var left   = new GUIFrame(new RectTransform(new Vector2(0.45f, 1), group.RectTransform), style: null);
                var center = new GUIFrame(new RectTransform(new Vector2(0.15f, 1), group.RectTransform), style: null);
                var right  = new GUIFrame(new RectTransform(new Vector2(0.4f, 0.8f), group.RectTransform), style: null);
                leftElements.Add(left);
                centerElements.Add(center);
                rightElements.Add(right);
                string leftText = string.Empty, centerText = string.Empty;
                GUITextBlock.TextGetterHandler rightTextGetter = null;
                switch (i)
                {
                case 0:
                    leftText        = TextManager.Get("DescentVelocity");
                    centerText      = $"({TextManager.Get("KilometersPerHour")})";
                    rightTextGetter = () =>
                    {
                        Vector2 vel          = controlledSub == null ? Vector2.Zero : controlledSub.Velocity;
                        var     realWorldVel = ConvertUnits.ToDisplayUnits(vel.Y * Physics.DisplayToRealWorldRatio) * 3.6f;
                        return(((int)(-realWorldVel)).ToString());
                    };
                    break;

                case 1:
                    leftText        = TextManager.Get("Velocity");
                    centerText      = $"({TextManager.Get("KilometersPerHour")})";
                    rightTextGetter = () =>
                    {
                        Vector2 vel          = controlledSub == null ? Vector2.Zero : controlledSub.Velocity;
                        var     realWorldVel = ConvertUnits.ToDisplayUnits(vel.X * Physics.DisplayToRealWorldRatio) * 3.6f;
                        return(((int)realWorldVel).ToString());
                    };
                    break;

                case 2:
                    leftText        = TextManager.Get("Depth");
                    centerText      = $"({TextManager.Get("Meter")})";
                    rightTextGetter = () =>
                    {
                        Vector2 pos            = controlledSub == null ? Vector2.Zero : controlledSub.Position;
                        float   realWorldDepth = Level.Loaded == null ? 0.0f : Math.Abs(pos.Y - Level.Loaded.Size.Y) * Physics.DisplayToRealWorldRatio;
                        return(((int)realWorldDepth).ToString());
                    };
                    break;
                }
                new GUITextBlock(new RectTransform(Vector2.One, left.RectTransform), leftText, font: GUI.SubHeadingFont, wrap: leftText.Contains(' '), textAlignment: Alignment.CenterRight);
                new GUITextBlock(new RectTransform(Vector2.One, center.RectTransform), centerText, font: GUI.Font, textAlignment: Alignment.Center)
                {
                    Padding = Vector4.Zero
                };
                var digitalFrame = new GUIFrame(new RectTransform(Vector2.One, right.RectTransform), style: "DigitalFrameDark");
                new GUITextBlock(new RectTransform(Vector2.One * 0.85f, digitalFrame.RectTransform, Anchor.Center), "12345", GUI.Style.TextColorDark, GUI.DigitalFont, Alignment.CenterRight)
                {
                    TextGetter = rightTextGetter
                };
            }
            GUITextBlock.AutoScaleAndNormalize(leftElements.SelectMany(e => e.GetAllChildren <GUITextBlock>()));
            GUITextBlock.AutoScaleAndNormalize(centerElements.SelectMany(e => e.GetAllChildren <GUITextBlock>()));
            GUITextBlock.AutoScaleAndNormalize(rightElements.SelectMany(e => e.GetAllChildren <GUITextBlock>()));

            //docking interface ----------------------------------------------------
            float dockingButtonSize = 1.1f;
            float elementScale      = 0.6f;

            dockingContainer = new GUIFrame(new RectTransform(Sonar.controlBoxSize, GuiFrame.RectTransform, Anchor.BottomLeft, scaleBasis: ScaleBasis.Smallest)
            {
                RelativeOffset = new Vector2(Sonar.controlBoxOffset.X + 0.05f, Sonar.controlBoxOffset.Y)
            }, style: null);

            dockText      = TextManager.Get("label.navterminaldock", fallBackTag: "captain.dock");
            undockText    = TextManager.Get("label.navterminalundock", fallBackTag: "captain.undock");
            dockingButton = new GUIButton(new RectTransform(new Vector2(elementScale), dockingContainer.RectTransform, Anchor.Center), dockText, style: "PowerButton")
            {
                OnClicked = (btn, userdata) =>
                {
                    if (GameMain.GameSession?.Campaign is CampaignMode campaign)
                    {
                        if (Level.IsLoadedOutpost &&
                            DockingSources.Any(d => d.Docked && (d.DockingTarget?.Item.Submarine?.Info?.IsOutpost ?? false)))
                        {
                            // Undocking from an outpost
                            campaign.CampaignUI.SelectTab(CampaignMode.InteractionType.Map);
                            campaign.ShowCampaignUI = true;
                            return(false);
                        }
                        else if (!Level.IsLoadedOutpost && DockingModeEnabled && ActiveDockingSource != null &&
                                 !ActiveDockingSource.Docked && DockingTarget?.Item?.Submarine == Level.Loaded.StartOutpost && (DockingTarget?.Item?.Submarine?.Info.IsOutpost ?? false))
                        {
                            // Docking to an outpost
                            var subsToLeaveBehind = campaign.GetSubsToLeaveBehind(Item.Submarine);
                            if (subsToLeaveBehind.Any())
                            {
                                enterOutpostPrompt = new GUIMessageBox(
                                    TextManager.GetWithVariable("enterlocation", "[locationname]", DockingTarget.Item.Submarine.Info.Name),
                                    TextManager.Get(subsToLeaveBehind.Count == 1 ? "LeaveSubBehind" : "LeaveSubsBehind"),
                                    new string[] { TextManager.Get("yes"), TextManager.Get("no") });
                            }
                            else
                            {
                                enterOutpostPrompt = new GUIMessageBox("",
                                                                       TextManager.GetWithVariable("campaignenteroutpostprompt", "[locationname]", DockingTarget.Item.Submarine.Info.Name),
                                                                       new string[] { TextManager.Get("yes"), TextManager.Get("no") });
                            }
                            enterOutpostPrompt.Buttons[0].OnClicked += (btn, userdata) =>
                            {
                                SendDockingSignal();
                                enterOutpostPrompt.Close();
                                return(true);
                            };
                            enterOutpostPrompt.Buttons[1].OnClicked += enterOutpostPrompt.Close;
                            return(false);
                        }
                    }
                    SendDockingSignal();

                    return(true);
                }
            };
            void SendDockingSignal()
            {
                if (GameMain.Client == null)
                {
                    item.SendSignal(0, "1", "toggle_docking", sender: null);
                }
                else
                {
                    dockingNetworkMessagePending = true;
                    item.CreateClientEvent(this);
                }
            }

            dockingButton.Font = GUI.SubHeadingFont;
            dockingButton.TextBlock.RectTransform.MaxSize = new Point((int)(dockingButton.Rect.Width * 0.7f), int.MaxValue);
            dockingButton.TextBlock.AutoScaleHorizontal   = true;

            var    style        = GUI.Style.GetComponentStyle("DockingButtonUp");
            Sprite buttonSprite = style.Sprites.FirstOrDefault().Value.FirstOrDefault()?.Sprite;
            Point  buttonSize   = buttonSprite != null?buttonSprite.size.ToPoint() : new Point(149, 52);

            Point horizontalButtonSize = buttonSize.Multiply(elementScale * GUI.Scale * dockingButtonSize);
            Point verticalButtonSize   = horizontalButtonSize.Flip();
            var   leftButton           = new GUIButton(new RectTransform(verticalButtonSize, dockingContainer.RectTransform, Anchor.CenterLeft), "", style: "DockingButtonLeft")
            {
                OnClicked = NudgeButtonClicked,
                UserData  = -Vector2.UnitX
            };
            var rightButton = new GUIButton(new RectTransform(verticalButtonSize, dockingContainer.RectTransform, Anchor.CenterRight), "", style: "DockingButtonRight")
            {
                OnClicked = NudgeButtonClicked,
                UserData  = Vector2.UnitX
            };
            var upButton = new GUIButton(new RectTransform(horizontalButtonSize, dockingContainer.RectTransform, Anchor.TopCenter), "", style: "DockingButtonUp")
            {
                OnClicked = NudgeButtonClicked,
                UserData  = Vector2.UnitY
            };
            var downButton = new GUIButton(new RectTransform(horizontalButtonSize, dockingContainer.RectTransform, Anchor.BottomCenter), "", style: "DockingButtonDown")
            {
                OnClicked = NudgeButtonClicked,
                UserData  = -Vector2.UnitY
            };

            // Sonar area
            steerArea = new GUICustomComponent(new RectTransform(Sonar.GUISizeCalculation, GuiFrame.RectTransform, Anchor.CenterRight, scaleBasis: ScaleBasis.Smallest),
                                               (spriteBatch, guiCustomComponent) => { DrawHUD(spriteBatch, guiCustomComponent.Rect); }, null);
            steerRadius = steerArea.Rect.Width / 2;

            pressureWarningText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.25f), steerArea.RectTransform, Anchor.Center, Pivot.TopCenter),
                                                   TextManager.Get("SteeringDepthWarning"), Color.Red, GUI.LargeFont, Alignment.Center)
            {
                Visible = false
            };
            // Tooltip/helper text
            tipContainer = new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.1f), steerArea.RectTransform, Anchor.BottomCenter, Pivot.TopCenter)
                                            , "", font: GUI.Font, wrap: true, style: "GUIToolTip", textAlignment: Alignment.Center)
            {
                AutoScaleHorizontal = true
            };
            noPowerTip = TextManager.Get("SteeringNoPowerTip");
            autoPilotMaintainPosTip = TextManager.Get("SteeringAutoPilotMaintainPosTip");
            autoPilotLevelStartTip  = TextManager.GetWithVariable("SteeringAutoPilotLocationTip", "[locationname]",
                                                                  GameMain.GameSession?.StartLocation == null ? "Start" : GameMain.GameSession.StartLocation.Name);
            autoPilotLevelEndTip = TextManager.GetWithVariable("SteeringAutoPilotLocationTip", "[locationname]",
                                                               GameMain.GameSession?.EndLocation == null ? "End" : GameMain.GameSession.EndLocation.Name);
        }
Exemple #16
0
        private void CreateGUI()
        {
            var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.9f), GuiFrame.RectTransform, Anchor.Center), childAnchor: Anchor.TopCenter);

            // === LABEL === //
            new GUITextBlock(new RectTransform(new Vector2(1f, 0.05f), paddedFrame.RectTransform), item.Name, font: GUI.SubHeadingFont)
            {
                TextAlignment     = Alignment.Center,
                AutoScaleVertical = true
            };

            var mainFrame = new GUILayoutGroup(new RectTransform(new Vector2(1f, 1f), paddedFrame.RectTransform, Anchor.Center), childAnchor: Anchor.TopCenter)
            {
                RelativeSpacing = 0.02f
            };

            // === TOP AREA ===
            var topFrame = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.65f), mainFrame.RectTransform), style: "InnerFrameDark");

            // === ITEM LIST ===
            var itemListFrame   = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), topFrame.RectTransform), childAnchor: Anchor.Center);
            var paddedItemFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.9f), itemListFrame.RectTransform))
            {
                Stretch         = true,
                RelativeSpacing = 0.03f
            };
            var filterArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.15f), paddedItemFrame.RectTransform), isHorizontal: true)
            {
                Stretch         = true,
                RelativeSpacing = 0.03f,
                UserData        = "filterarea"
            };

            new GUITextBlock(new RectTransform(new Vector2(0.2f, 1f), filterArea.RectTransform), TextManager.Get("serverlog.filter"), font: GUI.SubHeadingFont)
            {
                Padding           = Vector4.Zero,
                AutoScaleVertical = true
            };
            itemFilterBox = new GUITextBox(new RectTransform(new Vector2(0.8f, 1.0f), filterArea.RectTransform), createClearButton: true);
            itemFilterBox.OnTextChanged += (textBox, text) =>
            {
                FilterEntities(text);
                return(true);
            };
            filterArea.RectTransform.MaxSize = new Point(int.MaxValue, itemFilterBox.Rect.Height);

            itemList = new GUIListBox(new RectTransform(new Vector2(1f, 0.9f), paddedItemFrame.RectTransform), style: null)
            {
                OnSelected = (component, userdata) =>
                {
                    selectedItem = userdata as FabricationRecipe;
                    if (selectedItem != null)
                    {
                        SelectItem(Character.Controlled, selectedItem);
                    }
                    return(true);
                }
            };

            // === SEPARATOR === //
            new GUIFrame(new RectTransform(new Vector2(0.01f, 0.9f), topFrame.RectTransform, Anchor.Center), style: "VerticalLine");

            // === OUTPUT AREA === //
            var outputArea       = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1f), topFrame.RectTransform, Anchor.TopRight), childAnchor: Anchor.Center);
            var paddedOutputArea = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.9f), outputArea.RectTransform));
            var outputTopArea    = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.5F), paddedOutputArea.RectTransform, Anchor.Center), isHorizontal: true);

            // === OUTPUT SLOT === //
            outputSlot            = new GUIFrame(new RectTransform(new Vector2(0.4f, 1f), outputTopArea.RectTransform), style: null);
            outputInventoryHolder = new GUIFrame(new RectTransform(new Vector2(1f, 1.2f), outputSlot.RectTransform, Anchor.BottomCenter), style: null);
            new GUICustomComponent(new RectTransform(Vector2.One, outputInventoryHolder.RectTransform), DrawOutputOverLay)
            {
                CanBeFocused = false
            };
            // === DESCRIPTION === //
            selectedItemFrame = new GUIFrame(new RectTransform(new Vector2(0.6f, 1f), outputTopArea.RectTransform), style: null);
            // === REQUIREMENTS === //
            selectedItemReqsFrame = new GUIFrame(new RectTransform(new Vector2(1f, 0.5f), paddedOutputArea.RectTransform), style: null);

            // === BOTTOM AREA === //
            var bottomFrame = new GUIFrame(new RectTransform(new Vector2(1f, 0.3f), mainFrame.RectTransform), style: null);

            // === SEPARATOR === //
            var separatorArea = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.15f), bottomFrame.RectTransform, Anchor.TopCenter), childAnchor: Anchor.CenterLeft, isHorizontal: true)
            {
                Stretch         = true,
                RelativeSpacing = 0.03f
            };
            var inputLabel = new GUITextBlock(new RectTransform(Vector2.One, separatorArea.RectTransform), TextManager.Get("uilabel.input"), font: GUI.SubHeadingFont)
            {
                Padding = Vector4.Zero
            };

            inputLabel.RectTransform.Resize(new Point((int)inputLabel.Font.MeasureString(inputLabel.Text).X, inputLabel.RectTransform.Rect.Height));
            new GUIFrame(new RectTransform(Vector2.One, separatorArea.RectTransform), style: "HorizontalLine");

            // === INPUT AREA === //
            var inputArea = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 1f), bottomFrame.RectTransform, Anchor.BottomCenter), isHorizontal: true, childAnchor: Anchor.BottomLeft);

            // === INPUT SLOTS === //
            inputInventoryHolder = new GUIFrame(new RectTransform(new Vector2(0.7f, 1f), inputArea.RectTransform), style: null);
            new GUICustomComponent(new RectTransform(Vector2.One, inputInventoryHolder.RectTransform), DrawInputOverLay)
            {
                CanBeFocused = false
            };

            // === ACTIVATE BUTTON === //
            var buttonFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.3f, 0.8f), inputArea.RectTransform), childAnchor: Anchor.CenterRight);

            activateButton = new GUIButton(new RectTransform(new Vector2(1f, 0.6f), buttonFrame.RectTransform),
                                           TextManager.Get("FabricatorCreate"), style: "DeviceButton")
            {
                OnClicked = StartButtonClicked,
                UserData  = selectedItem,
                Enabled   = false
            };
            // === POWER WARNING === //
            inSufficientPowerWarning = new GUITextBlock(new RectTransform(Vector2.One, activateButton.RectTransform),
                                                        TextManager.Get("FabricatorNoPower"), textColor: GUI.Style.Orange, textAlignment: Alignment.Center, color: Color.Black, style: "OuterGlow", wrap: true)
            {
                HoverColor         = Color.Black,
                IgnoreLayoutGroups = true,
                Visible            = false,
                CanBeFocused       = false
            };
            CreateRecipes();
        }
        /// <summary>
        /// Rebuilds the GUI dictionary header if needed.
        /// </summary>
        protected void UpdateHeaderGUI()
        {
            Action BuildEmptyGUI = () =>
            {
                guiInternalTitleLayout = guiTitleLayout.InsertLayoutX(0);

                guiInternalTitleLayout.AddElement(new GUILabel(title));
                guiInternalTitleLayout.AddElement(new GUILabel("Empty", GUIOption.FixedWidth(100)));

                GUIContent createIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Create),
                                                       new LocEdString("Create"));
                GUIButton createBtn = new GUIButton(createIcon, GUIOption.FixedWidth(30));
                createBtn.OnClick += OnCreateButtonClicked;
                guiInternalTitleLayout.AddElement(createBtn);
            };

            Action BuildFilledGUI = () =>
            {
                guiInternalTitleLayout = guiTitleLayout.InsertLayoutX(0);

                GUIToggle guiFoldout = new GUIToggle(title, EditorStyles.Foldout);
                guiFoldout.Value      = isExpanded;
                guiFoldout.OnToggled += ToggleFoldout;

                GUIContent clearIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Clear),
                                                      new LocEdString("Clear"));
                GUIButton guiClearBtn = new GUIButton(clearIcon, GUIOption.FixedWidth(30));
                guiClearBtn.OnClick += OnClearButtonClicked;

                GUIContent addIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Add),
                                                    new LocEdString("Add"));
                GUIButton guiAddBtn = new GUIButton(addIcon, GUIOption.FixedWidth(30));
                guiAddBtn.OnClick += OnAddButtonClicked;

                guiInternalTitleLayout.AddElement(guiFoldout);
                guiInternalTitleLayout.AddElement(guiAddBtn);
                guiInternalTitleLayout.AddElement(guiClearBtn);

                guiChildLayout = guiLayout.AddLayoutX();
                guiChildLayout.AddSpace(IndentAmount);

                GUIPanel   guiContentPanel  = guiChildLayout.AddPanel();
                GUILayoutX guiIndentLayoutX = guiContentPanel.AddLayoutX();
                guiIndentLayoutX.AddSpace(IndentAmount);
                GUILayoutY guiIndentLayoutY = guiIndentLayoutX.AddLayoutY();
                guiIndentLayoutY.AddSpace(IndentAmount);
                guiContentLayout = guiIndentLayoutY.AddLayoutY();
                guiIndentLayoutY.AddSpace(IndentAmount);
                guiIndentLayoutX.AddSpace(IndentAmount);
                guiChildLayout.AddSpace(IndentAmount);

                short  backgroundDepth = (short)(Inspector.START_BACKGROUND_DEPTH - depth - 1);
                string bgPanelStyle    = depth % 2 == 0
                    ? EditorStyles.InspectorContentBgAlternate
                    : EditorStyles.InspectorContentBg;

                GUIPanel   backgroundPanel    = guiContentPanel.AddPanel(backgroundDepth);
                GUITexture inspectorContentBg = new GUITexture(null, bgPanelStyle);
                backgroundPanel.AddElement(inspectorContentBg);

                ToggleFoldout(isExpanded);
            };

            if (state == State.None)
            {
                if (!IsNull())
                {
                    BuildFilledGUI();
                    state = State.Filled;
                }
                else
                {
                    BuildEmptyGUI();

                    state = State.Empty;
                }
            }
            else if (state == State.Empty)
            {
                if (!IsNull())
                {
                    guiInternalTitleLayout.Destroy();
                    BuildFilledGUI();
                    state = State.Filled;
                }
            }
            else if (state == State.Filled)
            {
                if (IsNull())
                {
                    guiInternalTitleLayout.Destroy();
                    guiChildLayout.Destroy();
                    BuildEmptyGUI();

                    state = State.Empty;
                }
            }
        }
Exemple #18
0
        private SceneContainer CreateGui()
        {
            var vsTex  = AssetStorage.Get <string>("texture.vert");
            var psTex  = AssetStorage.Get <string>("texture.frag");
            var psText = AssetStorage.Get <string>("text.frag");

            var canvasWidth  = Width / 100f;
            var canvasHeight = Height / 100f;

            var btnFuseeLogo = new GUIButton
            {
                Name = "Canvas_Button"
            };

            btnFuseeLogo.OnMouseEnter += BtnLogoEnter;
            btnFuseeLogo.OnMouseExit  += BtnLogoExit;
            btnFuseeLogo.OnMouseDown  += BtnLogoDown;

            var guiFuseeLogo = new Texture(AssetStorage.Get <ImageData>("FuseeText.png"));
            var fuseeLogo    = new TextureNode(
                "fuseeLogo",
                vsTex,
                psTex,
                //Set the albedo texture you want to use.
                guiFuseeLogo,
                //Define anchor points. They are given in percent, seen from the lower left corner, respectively to the width/height of the parent.
                //In this setup the element will stretch horizontally but stay the same vertically if the parent element is scaled.
                UIElementPosition.GetAnchors(AnchorPos.TopTopLeft),
                //Define Offset and therefor the size of the element.
                UIElementPosition.CalcOffsets(AnchorPos.TopTopLeft, new float2(0, canvasHeight - 0.5f), canvasHeight, canvasWidth, new float2(1.75f, 0.5f)),
                float2.One
                );

            fuseeLogo.AddComponent(btnFuseeLogo);

            var fontLato     = AssetStorage.Get <Font>("Lato-Black.ttf");
            var guiLatoBlack = new FontMap(fontLato, 24);

            var text = new TextNode(
                "FUSEE Simple Example",
                "ButtonText",
                vsTex,
                psText,
                UIElementPosition.GetAnchors(AnchorPos.StretchHorizontal),
                UIElementPosition.CalcOffsets(AnchorPos.StretchHorizontal, new float2(canvasWidth / 2 - 4, 0), canvasHeight, canvasWidth, new float2(8, 1)),
                guiLatoBlack,
                (float4)ColorUint.Greenery,
                HorizontalTextAlignment.Center,
                VerticalTextAlignment.Center);

            var canvas = new CanvasNode(
                "Canvas",
                _canvasRenderMode,
                new MinMaxRect
            {
                Min = new float2(-canvasWidth / 2, -canvasHeight / 2f),
                Max = new float2(canvasWidth / 2, canvasHeight / 2f)
            })
            {
                Children = new ChildList()
                {
                    //Simple Texture Node, contains the fusee logo.
                    fuseeLogo,
                    text
                }
            };

            return(new SceneContainer
            {
                Children = new List <SceneNode>
                {
                    //Add canvas.
                    canvas
                }
            });
        }
Exemple #19
0
        protected override void OnPropertyChanged(string propertyName, object oldValue)
        {
            if (propertyName == "Name")
            {
                object objectBeingChanged = _gui;
                string newName            = _gui.Name;
                if (_selectedControl != null)
                {
                    objectBeingChanged = _selectedControl;
                    newName            = _selectedControl.Name;
                }
                Game game      = Factory.AGSEditor.CurrentGame;
                bool nameInUse = game.IsScriptNameAlreadyUsed(newName, objectBeingChanged);
                if (newName.StartsWith("g") && newName.Length > 1)
                {
                    nameInUse |= game.IsScriptNameAlreadyUsed(newName.Substring(1).ToUpper(), objectBeingChanged);
                }

                if (nameInUse)
                {
                    Factory.GUIController.ShowMessage("This script name is already used by another item.", MessageBoxIcon.Warning);
                    if (_selectedControl != null)
                    {
                        _selectedControl.Name = (string)oldValue;
                    }
                    else
                    {
                        _gui.Name = (string)oldValue;
                    }
                }
                else if (_selectedControl == null)
                {
                    RaiseOnGuiNameChanged();
                }
            }
            else if (propertyName == "Image")
            {
                if ((_selectedControl != null) && (_selectedControl is GUIButton))
                {
                    GUIButton selectedButton = (GUIButton)_selectedControl;
                    if (selectedButton.Image > 0)
                    {
                        int newWidth, newHeight;
                        Utilities.GetSizeSpriteWillBeRenderedInGame(selectedButton.Image, out newWidth, out newHeight);
                        selectedButton.Width  = newWidth;
                        selectedButton.Height = newHeight;
                    }
                }
            }
            else if (propertyName == "Width" || propertyName == "Height")
            {
                UpdateScrollableWindowSize();
            }
            else if (propertyName == "PopupStyle")
            {
                NormalGUI normalGui = (NormalGUI)_gui;
                if (normalGui != null)
                {
                    // Force Modal GUIs not visible by default
                    if (normalGui.PopupStyle == GUIPopupStyle.PopupModal)
                    {
                        normalGui.Visible = false;
                    }
                }
            }
        }
Exemple #20
0
        private void CreateNewControl()
        {
            int left, top, width, height;

            GetSelectionRectangle(out left, out top, out width, out height);
            left   = _state.WindowXToGUI(left);
            top    = _state.WindowYToGUI(top);
            width  = _state.WindowSizeToGUI(width);
            height = _state.WindowSizeToGUI(height);

            if ((width < 2) || (height < 2))
            {
                return;
            }

            GUIControl newControl = null;

            switch (_controlAddMode)
            {
            case GUIAddType.Button:
                newControl = new GUIButton(left, top, width, height);
                break;

            case GUIAddType.Label:
                newControl = new GUILabel(left, top, width, height);
                break;

            case GUIAddType.TextBox:
                newControl = new GUITextBox(left, top, width, height);
                break;

            case GUIAddType.ListBox:
                newControl = new GUIListBox(left, top, width, height);
                break;

            case GUIAddType.Slider:
                newControl = new GUISlider(left, top, width, height);
                break;

            case GUIAddType.InvWindow:
                newControl = new GUIInventory(left, top, width, height);
                break;

            default:
                throw new AGSEditorException("Unknown control type added: " + _controlAddMode.ToString());
            }

            newControl.Name   = Factory.AGSEditor.GetFirstAvailableScriptName(newControl.ControlType);
            newControl.ZOrder = _gui.Controls.Count;
            newControl.ID     = _gui.Controls.Count;
            _gui.Controls.Add(newControl);
            _selectedControl = newControl;
            _selected.Clear();
            _selected.Add(newControl);

            RaiseOnControlsChanged();
            Factory.AGSEditor.CurrentGame.NotifyClientsGUIControlAddedOrRemoved(_gui, newControl);

            Factory.GUIController.SetPropertyGridObject(newControl);

            bgPanel.Invalidate();
            UpdateCursorImage();
            // Revert back to Select cursor
            OnCommandClick(Components.GuiComponent.MODE_SELECT_CONTROLS);
        }
Exemple #21
0
        private void OnInitialize()
        {
            guiOK     = new GUIButton(new LocEdString("OK"));
            guiCancel = new GUIButton(new LocEdString("Cancel"));

            guiOK.OnClick     += OnOK;
            guiCancel.OnClick += OnCancel;

            GUILayout mainVertLayout = GUI.AddLayoutY();

            mainVertLayout.AddSpace(10);

            GUILayout editorHorzLayout = mainVertLayout.AddLayoutX();

            editorHorzLayout.AddSpace(EDITOR_HORZ_PADDING);
            GUIPanel gradientEditorPanel = editorHorzLayout.AddPanel();

            editorHorzLayout.AddSpace(EDITOR_HORZ_PADDING);

            mainVertLayout.AddSpace(15);

            GUILayout buttonHorzLayout = mainVertLayout.AddLayoutX();

            buttonHorzLayout.AddFlexibleSpace();
            buttonHorzLayout.AddElement(guiOK);
            buttonHorzLayout.AddSpace(10);
            buttonHorzLayout.AddElement(guiCancel);
            buttonHorzLayout.AddFlexibleSpace();

            mainVertLayout.AddFlexibleSpace();

            editorPanel = gradientEditorPanel.AddPanel(0);
            GUIPanel editorOverlay = gradientEditorPanel.AddPanel(-1);

            overlayCanvas = new GUICanvas();
            editorOverlay.AddElement(overlayCanvas);

            GUILayout editorVertLayout = editorPanel.AddLayoutY();

            GUILayout guiGradientLayout = editorVertLayout.AddLayoutX();

            guiGradientLayout.AddSpace(GradientKeyEditor.RECT_WIDTH / 2);

            texture       = Texture.Create2D(TEX_WIDTH, TEX_HEIGHT);
            spriteTexture = new SpriteTexture(texture);

            guiGradientTexture = new GUITexture(spriteTexture, GUITextureScaleMode.ScaleToFit);
            guiGradientTexture.SetHeight(30);

            UpdateTexture();

            guiGradientLayout.AddElement(guiGradientTexture);
            guiGradientLayout.AddSpace(GradientKeyEditor.RECT_WIDTH / 2);

            editorVertLayout.AddSpace(10);

            editor = new GradientKeyEditor(editorVertLayout, gradient.GetKeys(), Width - EDITOR_HORZ_PADDING * 2, 20);
            editor.OnGradientModified += colorGradient =>
            {
                gradient = colorGradient;

                UpdateTexture();
                UpdateKeyLines();
            };

            editorVertLayout.AddFlexibleSpace();

            GUITexture containerBg     = new GUITexture(null, EditorStylesInternal.ContainerBg);
            Rect2I     containerBounds = editor.GetBounds(GUI);

            containerBounds.x      -= 2;
            containerBounds.y      -= 2;
            containerBounds.width  += 4;
            containerBounds.height += 6;
            containerBg.Bounds      = containerBounds;

            GUIPanel editorUnderlay = GUI.AddPanel(1);

            editorUnderlay.AddElement(containerBg);

            UpdateKeyLines();

            EditorInput.OnPointerPressed     += OnPointerPressed;
            EditorInput.OnPointerDoubleClick += OnPointerDoubleClicked;
            EditorInput.OnPointerMoved       += OnPointerMoved;
            EditorInput.OnPointerReleased    += OnPointerReleased;
            EditorInput.OnButtonUp           += OnButtonUp;
        }
        /// <summary>
        /// Positions the GUI elements. Must be called after construction, but only after all content area entries have
        /// been constructed so that entry's final bounds are known.
        /// </summary>
        public void Initialize()
        {
            Rect2I iconBounds = icon.Bounds;

            bounds = iconBounds;
            Rect2I labelBounds = label.Bounds;

            if (owner.GridLayout)
            {
                bounds.x      = labelBounds.x;
                bounds.y     -= VERT_PADDING;
                bounds.width  = labelBounds.width;
                bounds.height = (labelBounds.y + labelBounds.height + VERT_PADDING) - bounds.y;
            }
            else
            {
                bounds.y      -= VERT_PADDING;
                bounds.width   = width;
                bounds.height += VERT_PADDING;
            }

            string hoistedPath = path;

            GUIButton overlayBtn = new GUIButton("", EditorStyles.Blank);

            overlayBtn.Bounds         = bounds;
            overlayBtn.OnClick       += () => OnEntryClicked(hoistedPath);
            overlayBtn.OnDoubleClick += () => OnEntryDoubleClicked(hoistedPath);
            overlayBtn.SetContextMenu(owner.Window.ContextMenu);
            overlayBtn.AcceptsKeyFocus = false;

            owner.Overlay.AddElement(overlayBtn);

            if (groupUnderlay != null)
            {
                if (owner.GridLayout)
                {
                    int offsetToNext = BG_HORZ_PADDING + owner.HorzElementSpacing;
                    if (type == LibraryGUIEntryType.MultiLast)
                    {
                        offsetToNext = BG_HORZ_PADDING * 2;
                    }

                    Rect2I bgBounds = new Rect2I(bounds.x - BG_HORZ_PADDING, bounds.y,
                                                 bounds.width + offsetToNext, bounds.height);
                    groupUnderlay.Bounds = bgBounds;
                }
                else
                {
                    int offsetToNext = BG_VERT_PADDING + LibraryGUIContent.LIST_ENTRY_SPACING;
                    if (type == LibraryGUIEntryType.MultiLast)
                    {
                        offsetToNext = BG_VERT_PADDING * 2;
                    }

                    Rect2I bgBounds = new Rect2I(bounds.x, bounds.y - BG_VERT_PADDING,
                                                 bounds.width, bounds.height + offsetToNext);

                    groupUnderlay.Bounds = bgBounds;
                }
            }
        }
 public void ButtonHoveringTest(GUIButton button, CSpriteRenderer sr01)
 {
 }
Exemple #24
0
        /// <summary>
        /// Rebuilds the library window GUI. Should be called any time the active folder or contents change.
        /// </summary>
        private void Refresh()
        {
            requiresRefresh = false;

            LibraryEntry[] entriesToDisplay = new LibraryEntry[0];
            if (IsSearchActive)
            {
                entriesToDisplay = ProjectLibrary.Search("*" + searchQuery + "*");
            }
            else
            {
                DirectoryEntry entry = ProjectLibrary.GetEntry(CurrentFolder) as DirectoryEntry;
                if (entry == null)
                {
                    CurrentFolder = ProjectLibrary.Root.Path;
                    entry = ProjectLibrary.GetEntry(CurrentFolder) as DirectoryEntry;
                }

                if(entry != null)
                    entriesToDisplay = entry.Children;
            }

            inProgressRenameElement = null;

            RefreshDirectoryBar();

            SortEntries(entriesToDisplay);

            Rect2I visibleContentBounds = GetScrollAreaBounds();
            content.Refresh(viewType, entriesToDisplay, visibleContentBounds);

            foreach (var path in cutPaths)
                content.MarkAsCut(path, true);

            foreach (var path in selectionPaths)
                content.MarkAsSelected(path, true);

            content.MarkAsPinged(pingPath, true);

            Rect2I contentBounds = content.Bounds;

            contentBounds.height = Math.Max(contentBounds.height, visibleContentBounds.height);

            GUIButton catchAll = new GUIButton("", EditorStyles.Blank);
            catchAll.Bounds = contentBounds;
            catchAll.OnClick += OnCatchAllClicked;
            catchAll.SetContextMenu(entryContextMenu);

            content.Underlay.AddElement(catchAll);

            Rect2I focusBounds = contentBounds; // Contents + Folder bar
            Rect2I scrollBounds = contentScrollArea.Bounds;
            focusBounds.x += scrollBounds.x;
            focusBounds.y += scrollBounds.y;

            Rect2I folderBarBounds = folderListLayout.Bounds;
            focusBounds.y -= folderBarBounds.height;
            focusBounds.height += folderBarBounds.height;

            GUIButton focusCatcher = new GUIButton("", EditorStyles.Blank);
            focusCatcher.Blocking = false;
            focusCatcher.OnFocusGained += () => hasContentFocus = true;
            focusCatcher.OnFocusLost += () => hasContentFocus = false;
            focusCatcher.Bounds = focusBounds;

            GUIPanel focusPanel = GUI.AddPanel(-3);
            focusPanel.AddElement(focusCatcher);

            UpdateDragSelection(dragSelectionEnd);
        }
    public Slides(string currentSceneName)
    {
        this.currentSceneName = currentSceneName;
        this.slides = new List<Slide>();

        // -------------------------   Build no background ------------------------ \\
        // Create Go Back to Menu Button
        GUIButton goBack = new GUIButton ();
        goBack
            .SetText(GUIConst.goBack)
            .OnClick(FlowControl.GoToLessonScreen)
                .SetBox((new Box())
                .SetMarginTop (0.0f)
                .SetMarginRight (0.0f)
                .SetMarginBottom (0.0f)
                .SetMarginLeft (0.0f));

        GUIFactory factory = new GUIFactory ();

        // Create "Help" Button
        GUIButton helpButton = new GUIButton ();
        helpButton
            .SetText(GUIConst.helpButtonText)
            .OnClick(FlowControl.ShowHelpMenu)
                .SetBox((new Box())
                .SetMarginTop (0.0f)
                .SetMarginRight (0.0f)
                .SetMarginBottom (0.0f)
                .SetMarginLeft (0.0f));

        factory.CreateContainer()
            .SetBox ((new Box())
                .SetMarginTop ("auto")
                .SetMarginLeft ("5px")
                .SetMarginBottom ("5px")
                .SetMarginRight ("auto")
                .SetHeight (0.08f)
                .SetWidth(0.4f)).Append (goBack);

        factory
            .CreateContainer ()
                .SetBox ((new Box())
                    .SetMarginTop ("auto")
                    .SetMarginLeft ("auto")
                    .SetMarginBottom ("5px")
                    .SetMarginRight ("5px")
                    .SetHeight (0.08f)
                    .SetWidth("32px"))
                .Append(helpButton);

        guiNoBackground = factory.Build();
        // ------------------------------------------------------------------------ //
        // -------------------------   Build Regular GUI -------------------------- \\
        // Create Go Back to Menu Button
        goBack = new GUIButton ();
        goBack
            .SetText(GUIConst.goBack)
            .OnClick(FlowControl.GoToLessonScreen)
                .SetBox((new Box())
                .SetMarginTop (0.0f)
                .SetMarginRight (0.0f)
                .SetMarginBottom (0.0f)
                .SetMarginLeft (0.0f));

        factory = new GUIFactory ();

        // Create "Help" Button
        helpButton = new GUIButton ();
        helpButton
            .SetText(GUIConst.helpButtonText)
            .OnClick(FlowControl.ShowHelpMenu)
                .SetBox((new Box())
                .SetMarginTop (0.0f)
                .SetMarginRight (0.0f)
                .SetMarginBottom (0.0f)
                .SetMarginLeft (0.0f));

        factory.CreateContainer()
            .SetBox ((new Box())
                .SetMarginTop ("auto")
                .SetMarginLeft ("5px")
                .SetMarginBottom ("5px")
                .SetMarginRight ("auto")
                .SetHeight (0.08f)
                .SetWidth(0.4f)).Append (goBack);

        factory
            .CreateContainer ()
                .SetBox ((new Box())
                    .SetMarginTop ("auto")
                    .SetMarginLeft ("auto")
                    .SetMarginBottom ("5px")
                    .SetMarginRight ("5px")
                    .SetHeight (0.08f)
                    .SetWidth("32px"))
                .Append(helpButton);

        factory
            .Prepend(new GUIImage("splash-background"));

        // Build
        gui = factory.Build();

        FlowControl.SetCurrentSlides(this);
    }
Exemple #26
0
        public void CreatePreviewWindow(GUIFrame frame)
        {
            frame.ClearChildren();

            if (frame == null)
            {
                return;
            }

            var previewContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.98f), frame.RectTransform, Anchor.Center))
            {
                Stretch = true
            };

            var title = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), previewContainer.RectTransform, Anchor.CenterLeft), ServerName, font: GUI.LargeFont)
            {
                ToolTip = ServerName
            };

            title.Text = ToolBox.LimitString(title.Text, title.Font, (int)(title.Rect.Width * 0.85f));

            GUITickBox favoriteTickBox = new GUITickBox(new RectTransform(new Vector2(0.15f, 0.8f), title.RectTransform, Anchor.CenterRight),
                                                        "", null, "GUIServerListFavoriteTickBox")
            {
                Selected   = Favorite,
                ToolTip    = TextManager.Get(Favorite ? "removefromfavorites" : "addtofavorites"),
                OnSelected = (tickbox) =>
                {
                    if (tickbox.Selected)
                    {
                        GameMain.ServerListScreen.AddToFavoriteServers(this);
                    }
                    else
                    {
                        GameMain.ServerListScreen.RemoveFromFavoriteServers(this);
                    }
                    tickbox.ToolTip = TextManager.Get(tickbox.Selected ? "removefromfavorites" : "addtofavorites");
                    return(true);
                }
            };

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), previewContainer.RectTransform),
                             TextManager.AddPunctuation(':', TextManager.Get("ServerListVersion"), string.IsNullOrEmpty(GameVersion) ? TextManager.Get("Unknown") : GameVersion));

            PlayStyle playStyle = PlayStyle ?? Networking.PlayStyle.Serious;

            Sprite playStyleBannerSprite      = ServerListScreen.PlayStyleBanners[(int)playStyle];
            float  playStyleBannerAspectRatio = playStyleBannerSprite.SourceRect.Width / playStyleBannerSprite.SourceRect.Height;
            var    playStyleBanner            = new GUIImage(new RectTransform(new Point(previewContainer.Rect.Width, (int)(previewContainer.Rect.Width / playStyleBannerAspectRatio)), previewContainer.RectTransform),
                                                             playStyleBannerSprite, null, true);

            var playStyleName = new GUITextBlock(new RectTransform(new Vector2(0.15f, 0.0f), playStyleBanner.RectTransform)
            {
                RelativeOffset = new Vector2(0.01f, 0.06f)
            },
                                                 TextManager.AddPunctuation(':', TextManager.Get("serverplaystyle"), TextManager.Get("servertag." + playStyle)), textColor: Color.White,
                                                 font: GUI.SmallFont, textAlignment: Alignment.Center,
                                                 color: ServerListScreen.PlayStyleColors[(int)playStyle], style: "GUISlopedHeader");

            playStyleName.RectTransform.NonScaledSize = (playStyleName.Font.MeasureString(playStyleName.Text) + new Vector2(20, 5) * GUI.Scale).ToPoint();
            playStyleName.RectTransform.IsFixedSize   = true;

            var content = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.6f), previewContainer.RectTransform))
            {
                Stretch = true
            };
            // playstyle tags -----------------------------------------------------------------------------

            var playStyleContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.15f), content.RectTransform), isHorizontal: true)
            {
                Stretch         = true,
                RelativeSpacing = 0.01f,
                CanBeFocused    = true
            };

            var playStyleTags = GetPlayStyleTags();

            foreach (string tag in playStyleTags)
            {
                if (!ServerListScreen.PlayStyleIcons.ContainsKey(tag))
                {
                    continue;
                }

                new GUIImage(new RectTransform(Vector2.One, playStyleContainer.RectTransform),
                             ServerListScreen.PlayStyleIcons[tag], scaleToFit: true)
                {
                    ToolTip = TextManager.Get("servertagdescription." + tag),
                    Color   = ServerListScreen.PlayStyleIconColors[tag]
                };
            }

            playStyleContainer.Recalculate();

            // -----------------------------------------------------------------------------

            float elementHeight = 0.075f;

            // Spacing
            new GUIFrame(new RectTransform(new Vector2(1.0f, 0.025f), content.RectTransform), style: null);

            var serverMsg = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.3f), content.RectTransform))
            {
                ScrollBarVisible = true
            };
            var msgText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), serverMsg.Content.RectTransform), ServerMessage, font: GUI.SmallFont, wrap: true)
            {
                CanBeFocused = false
            };

            serverMsg.Content.RectTransform.SizeChanged += () => { msgText.CalculateHeightFromText(); };
            msgText.RectTransform.SizeChanged           += () => { serverMsg.UpdateScrollBarSize(); };

            var gameMode = new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), content.RectTransform), TextManager.Get("GameMode"));

            new GUITextBlock(new RectTransform(Vector2.One, gameMode.RectTransform),
                             TextManager.Get(string.IsNullOrEmpty(GameMode) ? "Unknown" : "GameMode." + GameMode, returnNull: true) ?? GameMode,
                             textAlignment: Alignment.Right);

            /*var traitors = new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), bodyContainer.RectTransform), TextManager.Get("Traitors"));
             * new GUITextBlock(new RectTransform(Vector2.One, traitors.RectTransform), TextManager.Get(!TraitorsEnabled.HasValue ? "Unknown" : TraitorsEnabled.Value.ToString()), textAlignment: Alignment.Right);*/

            var subSelection = new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), content.RectTransform), TextManager.Get("ServerListSubSelection"));

            new GUITextBlock(new RectTransform(Vector2.One, subSelection.RectTransform), TextManager.Get(!SubSelectionMode.HasValue ? "Unknown" : SubSelectionMode.Value.ToString()), textAlignment: Alignment.Right);

            var modeSelection = new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), content.RectTransform), TextManager.Get("ServerListModeSelection"));

            new GUITextBlock(new RectTransform(Vector2.One, modeSelection.RectTransform), TextManager.Get(!ModeSelectionMode.HasValue ? "Unknown" : ModeSelectionMode.Value.ToString()), textAlignment: Alignment.Right);

            if (gameMode.TextSize.X + gameMode.GetChild <GUITextBlock>().TextSize.X > gameMode.Rect.Width ||
                subSelection.TextSize.X + subSelection.GetChild <GUITextBlock>().TextSize.X > subSelection.Rect.Width ||
                modeSelection.TextSize.X + modeSelection.GetChild <GUITextBlock>().TextSize.X > modeSelection.Rect.Width)
            {
                gameMode.Font = subSelection.Font = modeSelection.Font = GUI.SmallFont;
                gameMode.GetChild <GUITextBlock>().Font = subSelection.GetChild <GUITextBlock>().Font = modeSelection.GetChild <GUITextBlock>().Font = GUI.SmallFont;
            }

            var allowSpectating = new GUITickBox(new RectTransform(new Vector2(1, elementHeight), content.RectTransform), TextManager.Get("ServerListAllowSpectating"))
            {
                CanBeFocused = false
            };

            if (!AllowSpectating.HasValue)
            {
                new GUITextBlock(new RectTransform(new Vector2(0.8f, 0.8f), allowSpectating.Box.RectTransform, Anchor.Center), "?", textAlignment: Alignment.Center);
            }
            else
            {
                allowSpectating.Selected = AllowSpectating.Value;
            }

            var allowRespawn = new GUITickBox(new RectTransform(new Vector2(1, elementHeight), content.RectTransform), TextManager.Get("ServerSettingsAllowRespawning"))
            {
                CanBeFocused = false
            };

            if (!AllowRespawn.HasValue)
            {
                new GUITextBlock(new RectTransform(new Vector2(0.8f, 0.8f), allowRespawn.Box.RectTransform, Anchor.Center), "?", textAlignment: Alignment.Center);
            }
            else
            {
                allowRespawn.Selected = AllowRespawn.Value;
            }

            /*var voipEnabledTickBox = new GUITickBox(new RectTransform(new Vector2(1.0f, elementHeight), bodyContainer.RectTransform), TextManager.Get("serversettingsvoicechatenabled"))
             * {
             *  CanBeFocused = false
             * };
             * if (!VoipEnabled.HasValue)
             *  new GUITextBlock(new RectTransform(new Vector2(0.8f, 0.8f), voipEnabledTickBox.Box.RectTransform, Anchor.Center), "?", textAlignment: Alignment.Center);
             * else
             *  voipEnabledTickBox.Selected = VoipEnabled.Value;*/

            var usingWhiteList = new GUITickBox(new RectTransform(new Vector2(1, elementHeight), content.RectTransform), TextManager.Get("ServerListUsingWhitelist"))
            {
                CanBeFocused = false
            };

            if (!UsingWhiteList.HasValue)
            {
                new GUITextBlock(new RectTransform(new Vector2(0.8f, 0.8f), usingWhiteList.Box.RectTransform, Anchor.Center), "?", textAlignment: Alignment.Center);
            }
            else
            {
                usingWhiteList.Selected = UsingWhiteList.Value;
            }


            content.RectTransform.SizeChanged += () =>
            {
                GUITextBlock.AutoScaleAndNormalize(allowSpectating.TextBlock, allowRespawn.TextBlock, usingWhiteList.TextBlock);
            };

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), content.RectTransform),
                             TextManager.Get("ServerListContentPackages"), textAlignment: Alignment.Center, font: GUI.SubHeadingFont);

            var contentPackageList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.2f), content.RectTransform))
            {
                ScrollBarVisible = true
            };

            if (ContentPackageNames.Count == 0)
            {
                new GUITextBlock(new RectTransform(Vector2.One, contentPackageList.Content.RectTransform), TextManager.Get("Unknown"), textAlignment: Alignment.Center)
                {
                    CanBeFocused = false
                };
            }
            else
            {
                List <string> availableWorkshopUrls = new List <string>();
                for (int i = 0; i < ContentPackageNames.Count; i++)
                {
                    var packageText = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.15f), contentPackageList.Content.RectTransform)
                    {
                        MinSize = new Point(0, 15)
                    },
                                                     ContentPackageNames[i])
                    {
                        Enabled = false
                    };
                    if (i < ContentPackageHashes.Count)
                    {
                        if (GameMain.Config.SelectedContentPackages.Any(cp => cp.MD5hash.Hash == ContentPackageHashes[i]))
                        {
                            packageText.Selected = true;
                            continue;
                        }

                        //matching content package found, but it hasn't been enabled
                        if (ContentPackage.List.Any(cp => cp.MD5hash.Hash == ContentPackageHashes[i]))
                        {
                            packageText.TextColor = GUI.Style.Orange;
                            packageText.ToolTip   = TextManager.GetWithVariable("ServerListContentPackageNotEnabled", "[contentpackage]", ContentPackageNames[i]);
                        }
                        //workshop download link found
                        else if (i < ContentPackageWorkshopUrls.Count && !string.IsNullOrEmpty(ContentPackageWorkshopUrls[i]))
                        {
                            availableWorkshopUrls.Add(ContentPackageWorkshopUrls[i]);
                            packageText.TextColor = Color.Yellow;
                            packageText.ToolTip   = TextManager.GetWithVariable("ServerListIncompatibleContentPackageWorkshopAvailable", "[contentpackage]", ContentPackageNames[i]);
                        }
                        else //no package or workshop download link found, tough luck
                        {
                            packageText.TextColor = GUI.Style.Red;
                            packageText.ToolTip   = TextManager.GetWithVariables("ServerListIncompatibleContentPackage",
                                                                                 new string[2] {
                                "[contentpackage]", "[hash]"
                            }, new string[2] {
                                ContentPackageNames[i], ContentPackageHashes[i]
                            });
                        }
                    }
                }
                if (availableWorkshopUrls.Count > 0)
                {
                    var workshopBtn = new GUIButton(new RectTransform(new Vector2(1.0f, 0.1f), content.RectTransform), TextManager.Get("ServerListSubscribeMissingPackages"))
                    {
                        ToolTip   = TextManager.Get(SteamManager.IsInitialized ? "ServerListSubscribeMissingPackagesTooltip" : "ServerListSubscribeMissingPackagesTooltipNoSteam"),
                        Enabled   = SteamManager.IsInitialized,
                        OnClicked = (btn, userdata) =>
                        {
                            GameMain.SteamWorkshopScreen.SubscribeToPackages(availableWorkshopUrls);
                            GameMain.SteamWorkshopScreen.Select();
                            return(true);
                        }
                    };
                    workshopBtn.TextBlock.AutoScaleHorizontal = true;
                }
            }

            // -----------------------------------------------------------------------------

            foreach (GUIComponent c in content.Children)
            {
                if (c is GUITextBlock textBlock)
                {
                    textBlock.Padding = Vector4.Zero;
                }
            }
        }
Exemple #27
0
 void Start()
 {
     EButton = GameObject.Find("EBut").GetComponent<GUIButton>();
 }
Exemple #28
0
    private void Awake()
    {
        button = GetComponent <GUIButton>();

        button.onClick.AddListener(() =>
        {
            InventoryGUIObject item = PlayerInfo.CurrentLocal.CursorItem;

            if (item != null)
            {
                PlayerInfo.CurrentLocal.CursorItem  = PlayerInfo.CurrentLocal.AugmentItem;
                PlayerInfo.CurrentLocal.AugmentItem = item;
                Refresh();
                Messaging.GUI.HoverBox.Invoke(item.GetShortStats);
            }
            else
            {
                if (HotkeyAssigment.InventoryKey)
                {
                    switch (Stash.LeftStashMode)
                    {
                    default:
                    case Stash.StashMode.Disabled:
                        return;

                    case Stash.StashMode.Loadout:
                        if (PlayerInfo.CurrentLocal.AugmentItem is Weapon)
                        {
                            for (int i = 0; i < PlayerInfo.CurrentLocal.PlayerWeapons.Length; i++)
                            {
                                if (PlayerInfo.CurrentLocal.PlayerWeapons[i] == null)
                                {
                                    PlayerInfo.CurrentLocal.PlayerWeapons[i] = (Weapon)PlayerInfo.CurrentLocal.AugmentItem;
                                    PlayerInfo.CurrentLocal.AugmentItem      = null;
                                    Refresh();
                                    Messaging.Player.EquipPlayerItems.Invoke();
                                    Messaging.Player.LoadoutRefresh.Invoke();
                                    Messaging.GUI.HoverBox.Invoke("");
                                    return;
                                }
                            }
                        }
                        else if (PlayerInfo.CurrentLocal.AugmentItem is Skill)
                        {
                            for (int i = 0; i < PlayerInfo.CurrentLocal.PlayerSkills.Length; i++)
                            {
                                if (PlayerInfo.CurrentLocal.PlayerSkills[i] == null)
                                {
                                    PlayerInfo.CurrentLocal.PlayerSkills[i] = (Skill)PlayerInfo.CurrentLocal.AugmentItem;
                                    PlayerInfo.CurrentLocal.AugmentItem     = null;
                                    Refresh();
                                    Messaging.Player.EquipPlayerItems.Invoke();
                                    Messaging.Player.LoadoutRefresh.Invoke();
                                    Messaging.GUI.HoverBox.Invoke("");
                                    return;
                                }
                            }
                        }
                        else if (PlayerInfo.CurrentLocal.AugmentItem is Accessory)
                        {
                            for (int i = 0; i < PlayerInfo.CurrentLocal.PlayerAccessories.Length; i++)
                            {
                                if (PlayerInfo.CurrentLocal.PlayerAccessories[i] == null)
                                {
                                    PlayerInfo.CurrentLocal.PlayerAccessories[i] = (Accessory)PlayerInfo.CurrentLocal.AugmentItem;
                                    PlayerInfo.CurrentLocal.AugmentItem          = null;
                                    Refresh();
                                    Messaging.Player.ActivateAccessory.Invoke(i);
                                    Messaging.Player.LoadoutRefresh.Invoke();
                                    Messaging.GUI.HoverBox.Invoke("");
                                    return;
                                }
                            }
                        }
                        return;

                    case Stash.StashMode.Stash:
                        Stash.AddItemToFirstEmpty(PlayerInfo.CurrentLocal.AugmentItem, out int slot);
                        Messaging.Player.RefreshStash.Invoke(slot);
                        break;
                    }
                }
                else
                {
                    PlayerInfo.CurrentLocal.CursorItem = PlayerInfo.CurrentLocal.AugmentItem;
                }

                PlayerInfo.CurrentLocal.AugmentItem = null;
                Refresh();
                Messaging.GUI.HoverBox.Invoke("");
            }
        });

        button.OnCursorEnter.AddListener(() =>
        {
            if (PlayerInfo.CurrentLocal.AugmentItem == null)
            {
                Messaging.GUI.HoverBox.Invoke("");
            }
            else
            {
                Messaging.GUI.HoverBox.Invoke(PlayerInfo.CurrentLocal.AugmentItem.GetShortStats);
            }
        });

        button.OnCursorExit.AddListener(() => { Messaging.GUI.HoverBox.Invoke(""); });


        Messaging.Crafting.RefreshAssembler.AddListener(() => { Refresh(); });
    }
        /// <summary>
        /// Recreates the entire curve editor GUI depending on the currently selected scene object.
        /// </summary>
        private void RebuildGUI()
        {
            GUI.Clear();
            guiCurveEditor = null;
            guiFieldDisplay = null;

            if (selectedSO == null)
            {
                GUILabel warningLbl = new GUILabel(new LocEdString("Select an object to animate in the Hierarchy or Scene windows."));

                GUILayoutY vertLayout = GUI.AddLayoutY();
                vertLayout.AddFlexibleSpace();
                GUILayoutX horzLayout = vertLayout.AddLayoutX();
                vertLayout.AddFlexibleSpace();

                horzLayout.AddFlexibleSpace();
                horzLayout.AddElement(warningLbl);
                horzLayout.AddFlexibleSpace();

                return;
            }

            // Top button row
            GUIContent playIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.Play),
                new LocEdString("Play"));
            GUIContent recordIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.Record),
                new LocEdString("Record"));

            GUIContent prevFrameIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.FrameBack),
                new LocEdString("Previous frame"));
            GUIContent nextFrameIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.FrameForward),
                new LocEdString("Next frame"));

            GUIContent addKeyframeIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.AddKeyframe),
                new LocEdString("Add keyframe"));
            GUIContent addEventIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.AddEvent),
                new LocEdString("Add event"));

            GUIContent optionsIcon = new GUIContent(EditorBuiltin.GetLibraryWindowIcon(LibraryWindowIcon.Options),
                new LocEdString("Options"));

            playButton = new GUIToggle(playIcon, EditorStyles.Button);
            recordButton = new GUIToggle(recordIcon, EditorStyles.Button);

            prevFrameButton = new GUIButton(prevFrameIcon);
            frameInputField = new GUIIntField();
            nextFrameButton = new GUIButton(nextFrameIcon);

            addKeyframeButton = new GUIButton(addKeyframeIcon);
            addEventButton = new GUIButton(addEventIcon);

            optionsButton = new GUIButton(optionsIcon);

            playButton.OnToggled += x =>
            {
                if(x)
                    SwitchState(State.Playback);
                else
                    SwitchState(State.Normal);
            };

            recordButton.OnToggled += x =>
            {
                if (x)
                    SwitchState(State.Recording);
                else
                    SwitchState(State.Normal);
            };

            prevFrameButton.OnClick += () =>
            {
                SetCurrentFrame(currentFrameIdx - 1);

                switch (state)
                {
                    case State.Recording:
                    case State.Normal:
                        PreviewFrame(currentFrameIdx);
                        break;
                    default:
                        SwitchState(State.Normal);
                        break;
                }
            };

            frameInputField.OnChanged += x =>
            {
                SetCurrentFrame(x);

                switch (state)
                {
                    case State.Recording:
                    case State.Normal:
                        PreviewFrame(currentFrameIdx);
                        break;
                    default:
                        SwitchState(State.Normal);
                        break;
                }
            };

            nextFrameButton.OnClick += () =>
            {
                SetCurrentFrame(currentFrameIdx + 1);

                switch (state)
                {
                    case State.Recording:
                    case State.Normal:
                        PreviewFrame(currentFrameIdx);
                        break;
                    default:
                        SwitchState(State.Normal);
                        break;
                }
            };

            addKeyframeButton.OnClick += () =>
            {
                SwitchState(State.Normal);
                guiCurveEditor.AddKeyFrameAtMarker();
            };

            addEventButton.OnClick += () =>
            {
                SwitchState(State.Normal);
                guiCurveEditor.AddEventAtMarker();
            };

            optionsButton.OnClick += () =>
            {
                Vector2I openPosition = ScreenToWindowPos(Input.PointerPosition);
                AnimationOptions dropDown = DropDownWindow.Open<AnimationOptions>(this, openPosition);
                dropDown.Initialize(this);
            };

            // Property buttons
            addPropertyBtn = new GUIButton(new LocEdString("Add property"));
            delPropertyBtn = new GUIButton(new LocEdString("Delete selected"));

            addPropertyBtn.OnClick += () =>
            {
                Action openPropertyWindow = () =>
                {
                    Vector2I windowPos = ScreenToWindowPos(Input.PointerPosition);
                    FieldSelectionWindow fieldSelection = DropDownWindow.Open<FieldSelectionWindow>(this, windowPos);
                    fieldSelection.OnFieldSelected += OnFieldAdded;
                };

                if (clipInfo.clip == null)
                {
                    LocEdString title = new LocEdString("Warning");
                    LocEdString message =
                        new LocEdString("Selected object doesn't have an animation clip assigned. Would you like to create" +
                                        " a new animation clip?");

                    DialogBox.Open(title, message, DialogBox.Type.YesNoCancel, type =>
                    {
                        if (type == DialogBox.ResultType.Yes)
                        {
                            string clipSavePath;
                            if (BrowseDialog.SaveFile(ProjectLibrary.ResourceFolder, "*.asset", out clipSavePath))
                            {
                                SwitchState(State.Empty);
                                clipSavePath = Path.ChangeExtension(clipSavePath, ".asset");

                                AnimationClip newClip = new AnimationClip();

                                ProjectLibrary.Create(newClip, clipSavePath);
                                LoadAnimClip(newClip);

                                Animation animation = selectedSO.GetComponent<Animation>();
                                if (animation == null)
                                    animation = selectedSO.AddComponent<Animation>();

                                animation.DefaultClip = newClip;
                                EditorApplication.SetSceneDirty();

                                SwitchState(State.Normal);
                                openPropertyWindow();
                            }
                        }
                    });
                }
                else
                {
                    if (clipInfo.isImported)
                    {
                        LocEdString title = new LocEdString("Warning");
                        LocEdString message =
                            new LocEdString("You cannot add/edit/remove curves from animation clips that" +
                                            " are imported from an external file.");

                        DialogBox.Open(title, message, DialogBox.Type.OK);
                    }
                    else
                    {
                        SwitchState(State.Normal);
                        openPropertyWindow();
                    }
                }
            };

            delPropertyBtn.OnClick += () =>
            {
                if (clipInfo.clip == null)
                    return;

                SwitchState(State.Normal);

                if (clipInfo.isImported)
                {
                    LocEdString title = new LocEdString("Warning");
                    LocEdString message =
                        new LocEdString("You cannot add/edit/remove curves from animation clips that" +
                                        " are imported from an external file.");

                    DialogBox.Open(title, message, DialogBox.Type.OK);
                }
                else
                {
                    LocEdString title = new LocEdString("Warning");
                    LocEdString message = new LocEdString("Are you sure you want to remove all selected fields?");

                    DialogBox.Open(title, message, DialogBox.Type.YesNo, x =>
                    {
                        if (x == DialogBox.ResultType.Yes)
                        {
                            RemoveSelectedFields();
                            ApplyClipChanges();
                        }
                    });
                }
            };

            GUIPanel mainPanel = GUI.AddPanel();
            GUIPanel backgroundPanel = GUI.AddPanel(1);

            GUILayout mainLayout = mainPanel.AddLayoutY();

            buttonLayout = mainLayout.AddLayoutX();
            buttonLayout.AddSpace(5);
            buttonLayout.AddElement(playButton);
            buttonLayout.AddElement(recordButton);
            buttonLayout.AddSpace(5);
            buttonLayout.AddElement(prevFrameButton);
            buttonLayout.AddElement(frameInputField);
            buttonLayout.AddElement(nextFrameButton);
            buttonLayout.AddSpace(5);
            buttonLayout.AddElement(addKeyframeButton);
            buttonLayout.AddElement(addEventButton);
            buttonLayout.AddSpace(5);
            buttonLayout.AddElement(optionsButton);
            buttonLayout.AddFlexibleSpace();

            buttonLayoutHeight = playButton.Bounds.height;

            GUITexture buttonBackground = new GUITexture(null, EditorStyles.HeaderBackground);
            buttonBackground.Bounds = new Rect2I(0, 0, Width, buttonLayoutHeight);
            backgroundPanel.AddElement(buttonBackground);

            GUILayout contentLayout = mainLayout.AddLayoutX();
            GUILayout fieldDisplayLayout = contentLayout.AddLayoutY(GUIOption.FixedWidth(FIELD_DISPLAY_WIDTH));

            guiFieldDisplay = new GUIAnimFieldDisplay(fieldDisplayLayout, FIELD_DISPLAY_WIDTH,
                Height - buttonLayoutHeight * 2, selectedSO);
            guiFieldDisplay.OnEntrySelected += OnFieldSelected;

            GUILayout bottomButtonLayout = fieldDisplayLayout.AddLayoutX();
            bottomButtonLayout.AddElement(addPropertyBtn);
            bottomButtonLayout.AddElement(delPropertyBtn);

            horzScrollBar = new GUIResizeableScrollBarH();
            horzScrollBar.OnScrollOrResize += OnHorzScrollOrResize;

            vertScrollBar = new GUIResizeableScrollBarV();
            vertScrollBar.OnScrollOrResize += OnVertScrollOrResize;

            GUITexture separator = new GUITexture(null, EditorStyles.Separator, GUIOption.FixedWidth(3));
            contentLayout.AddElement(separator);

            GUILayout curveLayout = contentLayout.AddLayoutY();
            GUILayout curveLayoutHorz = curveLayout.AddLayoutX();
            GUILayout horzScrollBarLayout = curveLayout.AddLayoutX();
            horzScrollBarLayout.AddElement(horzScrollBar);
            horzScrollBarLayout.AddFlexibleSpace();

            editorPanel = curveLayoutHorz.AddPanel();
            curveLayoutHorz.AddElement(vertScrollBar);
            curveLayoutHorz.AddFlexibleSpace();

            scrollBarHeight = horzScrollBar.Bounds.height;
            scrollBarWidth = vertScrollBar.Bounds.width;

            Vector2I curveEditorSize = GetCurveEditorSize();
            guiCurveEditor = new GUICurveEditor(this, editorPanel, curveEditorSize.x, curveEditorSize.y);
            guiCurveEditor.OnFrameSelected += OnFrameSelected;
            guiCurveEditor.OnEventAdded += OnEventsChanged;
            guiCurveEditor.OnEventModified += EditorApplication.SetProjectDirty;
            guiCurveEditor.OnEventDeleted += OnEventsChanged;
            guiCurveEditor.OnCurveModified += () =>
            {
                SwitchState(State.Normal);

                ApplyClipChanges();
                PreviewFrame(currentFrameIdx);

                EditorApplication.SetProjectDirty();
            };
            guiCurveEditor.OnClicked += () =>
            {
                if(state != State.Recording)
                    SwitchState(State.Normal);
            };
            guiCurveEditor.Redraw();

            horzScrollBar.SetWidth(curveEditorSize.x);
            vertScrollBar.SetHeight(curveEditorSize.y);

            UpdateScrollBarSize();
        }
        public MainMenuScreen(MainWindow mainWindow)
            : base(mainWindow, "MainMenu")
        {
            theme = AssetManager.CreateDefaultGameTheme();
            theme.SetField("SmallFont", AssetManager.LoadFont("arial-bold-14"));
            theme.SetField("Font", AssetManager.LoadFont("arial-16"));
            theme.SetField("BigFont", AssetManager.LoadFont("arial-20"));

            popup         = new MessageWindow(GUISystem, theme, new UDim2(0.1f, 0, 0.3f, 0), "Alert!");
            popup.MinSize = new UDim2(0, 215, 0, 200);
            popup.MaxSize = new UDim2(1f, 0, 0, 275);

            connectWindow                   = new ConnectWindow(GUISystem, theme, new UDim2(1f, 0, 1f, 0));
            connectWindow.MinSize           = new UDim2(0, 375, 0, 200);
            connectWindow.MaxSize           = new UDim2(0, 700, 0, 200);
            connectWindow.OnConnectPressed += ConnectWindow_OnConnectPressed;

            GUIFrame title = new GUIFrame(new UDim2(0.5f, -260, 0.2f, -40), new UDim2(0, 520, 0, 80),
                                          new Image(GLoader.LoadTexture("Textures/title.png")));

            GUIFrame btnFrame = new GUIFrame(new UDim2(0.5f, -200, 0.5f, -50), new UDim2(0, 400, 0, 110), theme);

            btnFrame.Image = null;

            GUIButton connectBtn = new GUIButton(new UDim2(0, 0, 0, 0), new UDim2(1f, 0, 0, 30), "Connect to a Server",
                                                 TextAlign.Center, theme)
            {
                Parent = btnFrame
            };

            connectBtn.OnMouseClick += (btn, mbtn) =>
            {
                if (mbtn == MouseButton.Left)
                {
                    connectWindow.Visible = true;
                }
            };

            GUIButton controlsBtn = new GUIButton(new UDim2(0, 0, 0, 40), new UDim2(1f, 0, 0, 30), "View Controls",
                                                  TextAlign.Center, theme)
            {
                Parent = btnFrame
            };

            controlsBtn.OnMouseClick += (btn, mbtn) =>
            {
                if (mbtn == MouseButton.Left)
                {
                    Window.StaticGui.ToggleControlsWindow(true);
                }
            };

            GUIButton spBtn = new GUIButton(new UDim2(0, 0, 0, 80), new UDim2(1f, 0, 0, 30), "Start Singleplayer Test",
                                            TextAlign.Center, theme)
            {
                Parent = btnFrame
            };

            spBtn.OnMouseClick += (btn, mbtn) =>
            {
                if (mbtn == MouseButton.Left)
                {
                    Window.SwitchScreen("Singleplayer");
                }
            };

            GUIButton randomImageButton = new GUIButton(new UDim2(1f, -160, 1f, -40), new UDim2(0, 150, 0, 30),
                                                        "Random Image", theme);

            randomImageButton.OnMouseClick += (btn, mbtn) => { Window.StaticGui.ShowRandomBackgroundImage(); };

            GUIArea.AddTopLevel(title, randomImageButton, btnFrame);
            GUISystem.Add(connectWindow, popup);
            Windows.Add(connectWindow);
            Windows.Add(popup);
        }
        /// <summary>
        /// Recreates all the GUI elements used by this inspector.
        /// </summary>
        private void BuildGUI()
        {
            Layout.Clear();

            fontSizes = GUIArrayField<int, FontSizeArrayRow>.Create(
                new LocEdString("Font sizes"), importOptions.FontSizes, Layout);
            fontSizes.OnChanged += x => importOptions.FontSizes = x;
            fontSizes.IsExpanded = Persistent.GetBool("fontSizes_Expanded");
            fontSizes.OnExpand += x => Persistent.SetBool("fontSizes_Expanded", x);

            charRanges = GUIArrayField<CharRange, CharRangeArrayRow>.Create(
                new LocEdString("Character ranges"), importOptions.CharRanges, Layout);
            charRanges.OnChanged += x => importOptions.CharRanges = x;
            charRanges.IsExpanded = Persistent.GetBool("charRanges_Expanded");
            charRanges.OnExpand += x => Persistent.SetBool("charRanges_Expanded", x);

            renderModeField = new GUIEnumField(typeof(FontRenderMode), new LocEdString("Render mode"));
            renderModeField.OnSelectionChanged += x => importOptions.RenderMode = (FontRenderMode)x;

            boldField = new GUIToggleField(new LocEdString("Bold"));
            boldField.OnChanged += x => importOptions.Bold = x;

            italicField = new GUIToggleField(new LocEdString("Italic"));
            italicField.OnChanged += x => importOptions.Italic = x;

            dpiField = new GUIIntField(new LocEdString("DPI"));
            dpiField.OnChanged += x => importOptions.DPI = x;

            reimportButton = new GUIButton(new LocEdString("Reimport"));
            reimportButton.OnClick += TriggerReimport;

            Layout.AddElement(renderModeField);
            Layout.AddElement(boldField);
            Layout.AddElement(italicField);
            Layout.AddElement(dpiField);
            Layout.AddSpace(10);

            GUILayout reimportButtonLayout = Layout.AddLayoutX();
            reimportButtonLayout.AddFlexibleSpace();
            reimportButtonLayout.AddElement(reimportButton);
        }
Exemple #32
0
        partial void InitProjSpecific(XElement element)
        {
            foreach (XElement subElement in element.Elements())
            {
                switch (subElement.Name.ToString().ToLowerInvariant())
                {
                case "fissionratemeter":
                    fissionRateMeter = new Sprite(subElement);
                    break;

                case "turbineoutputmeter":
                    turbineOutputMeter = new Sprite(subElement);
                    break;

                case "meterpointer":
                    meterPointer = new Sprite(subElement);
                    break;

                case "sectorsprite":
                    sectorSprite = new Sprite(subElement);
                    break;

                case "tempmeterframe":
                    tempMeterFrame = new Sprite(subElement);
                    break;

                case "tempmeterbar":
                    tempMeterBar = new Sprite(subElement);
                    break;

                case "temprangeindicator":
                    tempRangeIndicator = new Sprite(subElement);
                    break;

                case "graphline":
                    graphLine = new Sprite(subElement);
                    break;
                }
            }

            var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.85f), GuiFrame.RectTransform, Anchor.Center), isHorizontal: true)
            {
                RelativeSpacing = 0.012f,
                Stretch         = true
            };

            GUIFrame columnLeft = new GUIFrame(new RectTransform(new Vector2(0.25f, 1.0f), paddedFrame.RectTransform), style: null);

            leftHUDColumn = columnLeft;
            GUIFrame columnMid   = new GUIFrame(new RectTransform(new Vector2(0.45f, 1.0f), paddedFrame.RectTransform), style: null);
            GUIFrame columnRight = new GUIFrame(new RectTransform(new Vector2(0.3f, 1.0f), paddedFrame.RectTransform), style: null);

            //----------------------------------------------------------
            //left column
            //----------------------------------------------------------

            int buttonsPerRow = 2;
            int spacing       = 5;
            int buttonWidth   = columnLeft.Rect.Width / buttonsPerRow - (spacing * (buttonsPerRow - 1));
            int buttonHeight  = (int)(columnLeft.Rect.Height * 0.5f) / 4;

            for (int i = 0; i < warningTexts.Length; i++)
            {
                var warningBtn = new GUIButton(new RectTransform(new Point(buttonWidth, buttonHeight), columnLeft.RectTransform)
                {
                    AbsoluteOffset = new Point((i % buttonsPerRow) * (buttonWidth + spacing), (int)Math.Floor(i / (float)buttonsPerRow) * (buttonHeight + spacing))
                },
                                               TextManager.Get(warningTexts[i]), style: "IndicatorButton")
                {
                    CanBeFocused = false
                };

                var btnText = warningBtn.GetChild <GUITextBlock>();
                btnText.Font = GUI.Font;
                btnText.Wrap = true;
                btnText.SetTextPos();
                warningButtons.Add(warningTexts[i], warningBtn);
            }
            GUITextBlock.AutoScaleAndNormalize(warningButtons.Values.Select(b => b.TextBlock));

            inventoryContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.45f), columnLeft.RectTransform, Anchor.BottomLeft), style: null);

            //----------------------------------------------------------
            //mid column
            //----------------------------------------------------------

            criticalHeatWarning = new GUITickBox(new RectTransform(new Point(columnMid.Rect.Width / 3, (int)(30 * GUI.Scale)), columnMid.RectTransform),
                                                 TextManager.Get("ReactorWarningCriticalTemp"), font: GUI.SmallFont, style: "IndicatorLightRed")
            {
                CanBeFocused = false
            };
            lowTemperatureWarning = new GUITickBox(new RectTransform(new Point(columnMid.Rect.Width / 3, (int)(30 * GUI.Scale)), columnMid.RectTransform)
            {
                RelativeOffset = new Vector2(0.27f, 0.0f)
            },
                                                   TextManager.Get("ReactorWarningCriticalLowTemp"), font: GUI.SmallFont, style: "IndicatorLightRed")
            {
                CanBeFocused = false
            };
            criticalOutputWarning = new GUITickBox(new RectTransform(new Point(columnMid.Rect.Width / 3, (int)(30 * GUI.Scale)), columnMid.RectTransform)
            {
                RelativeOffset = new Vector2(0.66f, 0.0f)
            },
                                                   TextManager.Get("ReactorWarningCriticalOutput"), font: GUI.SmallFont, style: "IndicatorLightRed")
            {
                CanBeFocused = false
            };

            GUITextBlock.AutoScaleAndNormalize(criticalHeatWarning.TextBlock, lowTemperatureWarning.TextBlock, criticalOutputWarning.TextBlock);

            float gaugeOffset = criticalHeatWarning.Rect.Height / (float)columnMid.Rect.Height + 0.05f * GUI.Scale;

            new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.05f), columnMid.RectTransform)
            {
                RelativeOffset = new Vector2(0.0f, gaugeOffset)
            },
                             TextManager.Get("ReactorFissionRate"));
            new GUICustomComponent(new RectTransform(new Vector2(0.5f, 0.5f), columnMid.RectTransform)
            {
                RelativeOffset = new Vector2(0.0f, gaugeOffset + 0.05f)
            },
                                   DrawFissionRateMeter, null)
            {
                ToolTip = TextManager.Get("ReactorTipFissionRate")
            };

            new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.05f), columnMid.RectTransform, Anchor.TopRight)
            {
                RelativeOffset = new Vector2(0.0f, gaugeOffset)
            },
                             TextManager.Get("ReactorTurbineOutput"));
            new GUICustomComponent(new RectTransform(new Vector2(0.5f, 0.5f), columnMid.RectTransform, Anchor.TopRight)
            {
                RelativeOffset = new Vector2(0.0f, gaugeOffset + 0.05f)
            },
                                   DrawTurbineOutputMeter, null)
            {
                ToolTip = TextManager.Get("ReactorTipTurbineOutput")
            };

            new GUITextBlock(new RectTransform(new Point(0, (int)(20 * GUI.Scale)), columnMid.RectTransform, Anchor.BottomLeft)
            {
                AbsoluteOffset = new Point(0, (int)(90 * GUI.Scale))
            },
                             TextManager.Get("ReactorFissionRate"));
            fissionRateScrollBar = new GUIScrollBar(new RectTransform(new Point(columnMid.Rect.Width, (int)(30 * GUI.Scale)), columnMid.RectTransform, Anchor.BottomCenter)
            {
                AbsoluteOffset = new Point(0, (int)(60 * GUI.Scale))
            },
                                                    style: "GUISlider", barSize: 0.1f)
            {
                OnMoved = (GUIScrollBar bar, float scrollAmount) =>
                {
                    LastUser          = Character.Controlled;
                    unsentChanges     = true;
                    targetFissionRate = scrollAmount * 100.0f;

                    return(false);
                }
            };

            new GUITextBlock(new RectTransform(new Point(0, (int)(20 * GUI.Scale)), columnMid.RectTransform, Anchor.BottomLeft)
            {
                AbsoluteOffset = new Point(0, (int)(30 * GUI.Scale))
            },
                             TextManager.Get("ReactorTurbineOutput"));
            turbineOutputScrollBar = new GUIScrollBar(new RectTransform(new Point(columnMid.Rect.Width, (int)(30 * GUI.Scale)), columnMid.RectTransform, Anchor.BottomCenter),
                                                      style: "GUISlider", barSize: 0.1f, isHorizontal: true)
            {
                OnMoved = (GUIScrollBar bar, float scrollAmount) =>
                {
                    LastUser            = Character.Controlled;
                    unsentChanges       = true;
                    targetTurbineOutput = scrollAmount * 100.0f;

                    return(false);
                }
            };

            //----------------------------------------------------------
            //right column
            //----------------------------------------------------------

            new GUITextBlock(new RectTransform(new Vector2(0.7f, 0.1f), columnRight.RectTransform), TextManager.Get("ReactorAutoTemp"))
            {
                ToolTip   = TextManager.Get("ReactorTipAutoTemp"),
                AutoScale = true
            };
            autoTempSlider = new GUIScrollBar(new RectTransform(new Vector2(0.6f, 0.15f), columnRight.RectTransform)
            {
                RelativeOffset = new Vector2(0.0f, 0.1f)
            },
                                              barSize: 0.55f, style: "OnOffSlider", isHorizontal: true)
            {
                ToolTip         = TextManager.Get("ReactorTipAutoTemp"),
                IsBooleanSwitch = true,
                BarScroll       = 1.0f,
                OnMoved         = (scrollBar, scrollAmount) =>
                {
                    LastUser      = Character.Controlled;
                    unsentChanges = true;
                    return(true);
                }
            };
            var sliderSprite = autoTempSlider.Frame.Style.Sprites[GUIComponent.ComponentState.None].First();

            autoTempSlider.RectTransform.MaxSize = new Point((int)(sliderSprite.Sprite.SourceRect.Size.X * GUI.Scale), (int)(sliderSprite.Sprite.SourceRect.Size.Y * GUI.Scale));

            onOffSwitch = new GUIScrollBar(new RectTransform(new Vector2(0.4f, 0.3f), columnRight.RectTransform, Anchor.TopRight),
                                           barSize: 0.2f, style: "OnOffLever", isHorizontal: false)
            {
                IsBooleanSwitch = true,
                MinValue        = 0.25f,
                MaxValue        = 0.75f,
                OnMoved         = (scrollBar, scrollAmount) =>
                {
                    LastUser      = Character.Controlled;
                    unsentChanges = true;
                    return(true);
                }
            };
            var switchSprite = onOffSwitch.Frame.Style.Sprites[GUIComponent.ComponentState.None].First();

            onOffSwitch.RectTransform.MaxSize = new Point((int)(switchSprite.Sprite.SourceRect.Size.X * GUI.Scale), (int)(switchSprite.Sprite.SourceRect.Size.Y * GUI.Scale));

            var lever = onOffSwitch.GetChild <GUIButton>();

            lever.RectTransform.NonScaledSize = new Point(lever.Rect.Width + (int)(30 * GUI.Scale), lever.Rect.Height);

            var graphArea = new GUICustomComponent(new RectTransform(new Vector2(1.0f, 0.5f), columnRight.RectTransform, Anchor.BottomCenter)
            {
                AbsoluteOffset = new Point(0, 30)
            },
                                                   DrawGraph, null);

            Point textSize = new Point((int)(100 * GUI.Scale), (int)(30 * GUI.Scale));

            var loadText = new GUITextBlock(new RectTransform(textSize, graphArea.RectTransform, Anchor.TopLeft, Pivot.BottomLeft),
                                            "Load", textColor: Color.LightBlue, textAlignment: Alignment.CenterLeft)
            {
                ToolTip = TextManager.Get("ReactorTipLoad")
            };
            string loadStr = TextManager.Get("ReactorLoad");

            loadText.TextGetter += () => { return(loadStr.Replace("[kw]", ((int)load).ToString())); };

            var outputText = new GUITextBlock(new RectTransform(textSize, graphArea.RectTransform, Anchor.BottomLeft, Pivot.TopLeft),
                                              "Output", textColor: Color.LightGreen, textAlignment: Alignment.CenterLeft)
            {
                ToolTip = TextManager.Get("ReactorTipPower")
            };
            string outputStr = TextManager.Get("ReactorOutput");

            outputText.TextGetter += () => { return(outputStr.Replace("[kw]", ((int)-currPowerConsumption).ToString())); };
        }
Exemple #33
0
        protected GUIComponent CreateInfoFrame(string title, string text, int width = 300, int height = 80, string anchorStr = "", bool hasButton = false, Action callback = null, Action showVideo = null)
        {
            if (hasButton)
            {
                height += 60;
            }

            Anchor anchor = Anchor.TopRight;

            if (anchorStr != string.Empty)
            {
                Enum.TryParse(anchorStr, out anchor);
            }

            width  = (int)(width * GUI.Scale);
            height = (int)(height * GUI.Scale);

            string wrappedText = ToolBox.WrapText(text, width, GUI.Font);

            height += (int)GUI.Font.MeasureString(wrappedText).Y;

            if (title.Length > 0)
            {
                height += (int)GUI.Font.MeasureString(title).Y + (int)(150 * GUI.Scale);
            }

            var background = new GUIFrame(new RectTransform(new Point(GameMain.GraphicsWidth, GameMain.GraphicsHeight), GUI.Canvas, Anchor.Center), style: "GUIBackgroundBlocker");

            var infoBlock = new GUIFrame(new RectTransform(new Point(width, height), background.RectTransform, anchor));

            infoBlock.Flash(GUI.Style.Green);

            var infoContent = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.9f), infoBlock.RectTransform, Anchor.Center))
            {
                Stretch         = true,
                AbsoluteSpacing = 5
            };

            if (title.Length > 0)
            {
                var titleBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), infoContent.RectTransform),
                                                  title, font: GUI.LargeFont, textAlignment: Alignment.Center, textColor: new Color(253, 174, 0));
                titleBlock.RectTransform.IsFixedSize = true;
            }

            List <RichTextData> richTextData = RichTextData.GetRichTextData(text, out text);
            GUITextBlock        textBlock;

            if (richTextData == null)
            {
                textBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), infoContent.RectTransform), " " + text, wrap: true);
            }
            else
            {
                textBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), infoContent.RectTransform), richTextData, " " + text, wrap: true);
            }

            textBlock.RectTransform.IsFixedSize = true;
            infoBoxClosedCallback = callback;

            if (hasButton)
            {
                var buttonContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.15f), infoContent.RectTransform), isHorizontal: true)
                {
                    RelativeSpacing = 0.1f
                };
                buttonContainer.RectTransform.IsFixedSize = true;

                if (showVideo != null)
                {
                    buttonContainer.Stretch = true;
                    var videoButton = new GUIButton(new RectTransform(new Vector2(0.4f, 1.0f), buttonContainer.RectTransform),
                                                    TextManager.Get("Video"), style: "GUIButtonLarge")
                    {
                        OnClicked = (GUIButton button, object obj) =>
                        {
                            showVideo();
                            return(true);
                        }
                    };
                }
                else
                {
                    buttonContainer.Stretch     = false;
                    buttonContainer.ChildAnchor = Anchor.Center;
                }

                var okButton = new GUIButton(new RectTransform(new Vector2(0.4f, 1.0f), buttonContainer.RectTransform),
                                             TextManager.Get("OK"), style: "GUIButtonLarge")
                {
                    OnClicked = CloseInfoFrame
                };
            }

            infoBlock.RectTransform.NonScaledSize = new Point(infoBlock.Rect.Width, (int)(infoContent.Children.Sum(c => c.Rect.Height + infoContent.AbsoluteSpacing) / infoContent.RectTransform.RelativeSize.Y));

            GUI.PlayUISound(GUISoundType.UIMessage);

            return(background);
        }
        /// <summary>
        /// Updates contents of the scene object specific fields (name, position, rotation, etc.)
        /// </summary>
        /// <param name="forceUpdate">If true, the GUI elements will be updated regardless of whether a change was
        ///                           detected or not.</param>
        internal void RefreshSceneObjectFields(bool forceUpdate)
        {
            if (activeSO == null)
            {
                return;
            }

            soNameInput.Text     = activeSO.Name;
            soActiveToggle.Value = activeSO.Active;
            soMobility.Value     = (ulong)activeSO.Mobility;

            SceneObject prefabParent = PrefabUtility.GetPrefabParent(activeSO);

            // Ignore prefab parent if scene root, we only care for non-root prefab instances
            bool hasPrefab = prefabParent != null && prefabParent.Parent != null;

            if (soHasPrefab != hasPrefab || forceUpdate)
            {
                int numChildren = soPrefabLayout.ChildCount;
                for (int i = 0; i < numChildren; i++)
                {
                    soPrefabLayout.GetChild(0).Destroy();
                }

                GUILabel prefabLabel = new GUILabel(new LocEdString("Prefab"), GUIOption.FixedWidth(50));
                soPrefabLayout.AddElement(prefabLabel);

                if (hasPrefab)
                {
                    GUIButton btnApplyPrefab  = new GUIButton(new LocEdString("Apply"), GUIOption.FixedWidth(60));
                    GUIButton btnRevertPrefab = new GUIButton(new LocEdString("Revert"), GUIOption.FixedWidth(60));
                    GUIButton btnBreakPrefab  = new GUIButton(new LocEdString("Break"), GUIOption.FixedWidth(60));

                    btnApplyPrefab.OnClick += () =>
                    {
                        PrefabUtility.ApplyPrefab(activeSO);
                    };
                    btnRevertPrefab.OnClick += () =>
                    {
                        GameObjectUndo.RecordSceneObject(activeSO, true, "Reverting \"" + activeSO.Name + "\" to prefab.");
                        PrefabUtility.RevertPrefab(activeSO);

                        GameObjectUndo.ResolveDiffs();
                        EditorApplication.SetSceneDirty();
                    };
                    btnBreakPrefab.OnClick += () =>
                    {
                        UndoRedo.BreakPrefab(activeSO, "Breaking prefab link for " + activeSO.Name);

                        EditorApplication.SetSceneDirty();
                    };

                    soPrefabLayout.AddElement(btnApplyPrefab);
                    soPrefabLayout.AddElement(btnRevertPrefab);
                    soPrefabLayout.AddElement(btnBreakPrefab);
                }
                else
                {
                    GUILabel noPrefabLabel = new GUILabel("None");
                    soPrefabLayout.AddElement(noPrefabLabel);
                }

                soHasPrefab = hasPrefab;
            }

            Vector3    position;
            Quaternion rotation;

            if (EditorApplication.ActiveCoordinateMode == HandleCoordinateMode.World)
            {
                position = activeSO.Position;
                rotation = activeSO.Rotation;
            }
            else
            {
                position = activeSO.LocalPosition;
                rotation = activeSO.LocalRotation;
            }

            Vector3 scale = activeSO.LocalScale;

            if (!soPos.HasInputFocus || forceUpdate)
            {
                soPos.Value = position;
            }

            // Avoid updating the rotation unless actually changed externally, since switching back and forth between
            // quaternion and euler angles can cause weird behavior
            if ((!soRot.HasInputFocus && rotation != lastRotation) || forceUpdate)
            {
                soRot.Value  = rotation.ToEuler();
                lastRotation = rotation;
            }

            if (!soScale.HasInputFocus || forceUpdate)
            {
                soScale.Value = scale;
            }
        }
Exemple #35
0
 public void _guiFuseeLink_OnGUIButtonLeave(GUIButton sender, GUIButtonEventArgs mea)
 {
     _guiFuseeLink.ButtonColor = new float4(0, 0, 0, 0);
     _guiFuseeLink.BorderWidth = 0;
 }
        private void OnInitialize()
        {
            mainLayout = GUI.AddLayoutY();

            GUIContent viewIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.View),
                                                 new LocEdString("View"));
            GUIContent moveIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Move),
                                                 new LocEdString("Move"));
            GUIContent rotateIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Rotate),
                                                   new LocEdString("Rotate"));
            GUIContent scaleIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Scale),
                                                  new LocEdString("Scale"));

            GUIContent localIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Local),
                                                  new LocEdString("Local"));
            GUIContent worldIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.World),
                                                  new LocEdString("World"));

            GUIContent pivotIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Pivot),
                                                  new LocEdString("Pivot"));
            GUIContent centerIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Center),
                                                   new LocEdString("Center"));

            GUIContent moveSnapIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.MoveSnap),
                                                     new LocEdString("Move snap"));
            GUIContent rotateSnapIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.RotateSnap),
                                                       new LocEdString("Rotate snap"));

            GUIToggleGroup handlesTG = new GUIToggleGroup();

            viewButton   = new GUIToggle(viewIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            moveButton   = new GUIToggle(moveIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            rotateButton = new GUIToggle(rotateIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            scaleButton  = new GUIToggle(scaleIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));

            GUIToggleGroup coordModeTG = new GUIToggleGroup();

            localCoordButton = new GUIToggle(localIcon, coordModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(75));
            worldCoordButton = new GUIToggle(worldIcon, coordModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(75));

            GUIToggleGroup pivotModeTG = new GUIToggleGroup();

            pivotButton  = new GUIToggle(pivotIcon, pivotModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            centerButton = new GUIToggle(centerIcon, pivotModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));

            moveSnapButton = new GUIToggle(moveSnapIcon, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            moveSnapInput  = new GUIFloatField("", GUIOption.FlexibleWidth(35));

            rotateSnapButton = new GUIToggle(rotateSnapIcon, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            rotateSnapInput  = new GUIFloatField("", GUIOption.FlexibleWidth(35));

            viewButton.OnClick   += () => OnSceneToolButtonClicked(SceneViewTool.View);
            moveButton.OnClick   += () => OnSceneToolButtonClicked(SceneViewTool.Move);
            rotateButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.Rotate);
            scaleButton.OnClick  += () => OnSceneToolButtonClicked(SceneViewTool.Scale);

            localCoordButton.OnClick += () => OnCoordinateModeButtonClicked(HandleCoordinateMode.Local);
            worldCoordButton.OnClick += () => OnCoordinateModeButtonClicked(HandleCoordinateMode.World);

            pivotButton.OnClick  += () => OnPivotModeButtonClicked(HandlePivotMode.Pivot);
            centerButton.OnClick += () => OnPivotModeButtonClicked(HandlePivotMode.Center);

            moveSnapButton.OnToggled += (bool active) => OnMoveSnapToggled(active);
            moveSnapInput.OnChanged  += (float value) => OnMoveSnapValueChanged(value);

            rotateSnapButton.OnToggled += (bool active) => OnRotateSnapToggled(active);
            rotateSnapInput.OnChanged  += (float value) => OnRotateSnapValueChanged(value);

            GUILayout handlesLayout = mainLayout.AddLayoutX();

            handlesLayout.AddElement(viewButton);
            handlesLayout.AddElement(moveButton);
            handlesLayout.AddElement(rotateButton);
            handlesLayout.AddElement(scaleButton);
            handlesLayout.AddSpace(10);
            handlesLayout.AddElement(localCoordButton);
            handlesLayout.AddElement(worldCoordButton);
            handlesLayout.AddSpace(10);
            handlesLayout.AddElement(pivotButton);
            handlesLayout.AddElement(centerButton);
            handlesLayout.AddFlexibleSpace();
            handlesLayout.AddElement(moveSnapButton);
            handlesLayout.AddElement(moveSnapInput);
            handlesLayout.AddSpace(10);
            handlesLayout.AddElement(rotateSnapButton);
            handlesLayout.AddElement(rotateSnapInput);

            GUIPanel mainPanel = mainLayout.AddPanel();

            rtPanel = mainPanel.AddPanel();

            selectionPanel = mainPanel.AddPanel(-1);

            GUIPanel sceneAxesPanel = mainPanel.AddPanel(-1);

            sceneAxesGUI = new SceneAxesGUI(this, sceneAxesPanel, HandleAxesGUISize, HandleAxesGUISize, ProjectionType.Perspective);

            focusCatcher = new GUIButton("", EditorStyles.Blank);
            focusCatcher.OnFocusGained += () => hasContentFocus = true;
            focusCatcher.OnFocusLost   += () => hasContentFocus = false;

            GUIPanel focusPanel = GUI.AddPanel(-2);

            focusPanel.AddElement(focusCatcher);

            toggleProfilerOverlayKey = new VirtualButton(ToggleProfilerOverlayBinding);
            viewToolKey   = new VirtualButton(ViewToolBinding);
            moveToolKey   = new VirtualButton(MoveToolBinding);
            rotateToolKey = new VirtualButton(RotateToolBinding);
            scaleToolKey  = new VirtualButton(ScaleToolBinding);
            frameKey      = new VirtualButton(FrameBinding);

            UpdateRenderTexture(Width, Height - HeaderHeight);
            UpdateProfilerOverlay();
        }
Exemple #37
0
        partial void InitProjSpecific(XElement element)
        {
            var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.85f), GuiFrame.RectTransform, Anchor.Center), childAnchor: Anchor.TopCenter)
            {
                Stretch         = true,
                RelativeSpacing = 0.05f
            };

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.15f), paddedFrame.RectTransform),
                             header, textAlignment: Alignment.TopCenter, font: GUI.LargeFont);

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedFrame.RectTransform),
                             Description, font: GUI.SmallFont, wrap: true);

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.15f), paddedFrame.RectTransform),
                             TextManager.Get("RequiredRepairSkills"));
            for (int i = 0; i < requiredSkills.Count; i++)
            {
                var skillText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.15f), paddedFrame.RectTransform),
                                                 "   - " + TextManager.AddPunctuation(':', TextManager.Get("SkillName." + requiredSkills[i].Identifier), ((int)requiredSkills[i].Level).ToString()),
                                                 font: GUI.SmallFont)
                {
                    UserData = requiredSkills[i]
                };
            }

            progressBar = new GUIProgressBar(new RectTransform(new Vector2(1.0f, 0.15f), paddedFrame.RectTransform),
                                             color: Color.Green, barSize: 0.0f);

            repairButtonText = TextManager.Get("RepairButton");
            repairingText    = TextManager.Get("Repairing");
            RepairButton     = new GUIButton(new RectTransform(new Vector2(0.8f, 0.15f), paddedFrame.RectTransform, Anchor.TopCenter), repairButtonText)
            {
                OnClicked = (btn, obj) =>
                {
                    requestStartFixAction = FixActions.Repair;
                    item.CreateClientEvent(this);
                    return(true);
                }
            };
            sabotageButtonText = TextManager.Get("SabotageButton");
            sabotagingText     = TextManager.Get("Sabotaging");
            SabotageButton     = new GUIButton(new RectTransform(new Vector2(0.8f, 0.15f), paddedFrame.RectTransform, Anchor.BottomCenter), sabotageButtonText)
            {
                OnClicked = (btn, obj) =>
                {
                    requestStartFixAction = FixActions.Sabotage;
                    item.CreateClientEvent(this);
                    return(true);
                }
            };

            foreach (XElement subElement in element.Elements())
            {
                switch (subElement.Name.ToString().ToLowerInvariant())
                {
                case "emitter":
                case "particleemitter":
                    particleEmitters.Add(new ParticleEmitter(subElement));
                    particleEmitterConditionRanges.Add(new Vector2(
                                                           subElement.GetAttributeFloat("mincondition", 0.0f),
                                                           subElement.GetAttributeFloat("maxcondition", 100.0f)));
                    break;
                }
            }
        }
Exemple #38
0
        private void OnInitialize()
        {
            GUILayoutX splitLayout        = GUI.AddLayoutX();
            GUIPanel   platformPanel      = splitLayout.AddPanel();
            GUIPanel   platformForeground = platformPanel.AddPanel();
            GUILayoutY platformLayout     = platformForeground.AddLayoutY();
            GUIPanel   platformBackground = platformPanel.AddPanel(1);
            GUITexture background         = new GUITexture(Builtin.WhiteTexture);

            background.SetTint(PLATFORM_BG_COLOR);

            splitLayout.AddSpace(5);
            GUILayoutY optionsLayout = splitLayout.AddLayoutY();

            GUILabel platformsLabel = new GUILabel(new LocEdString("Platforms"), EditorStyles.LabelCentered);

            platformLayout.AddSpace(5);
            platformLayout.AddElement(platformsLabel);
            platformLayout.AddSpace(5);

            GUIToggleGroup platformToggleGroup = new GUIToggleGroup();

            PlatformType[] availablePlatforms = BuildManager.AvailablePlatforms;
            platformButtons = new GUIToggle[availablePlatforms.Length];
            for (int i = 0; i < availablePlatforms.Length; i++)
            {
                PlatformType currentPlatform = availablePlatforms[i];
                bool         isActive        = currentPlatform == BuildManager.ActivePlatform;

                string platformName = Enum.GetName(typeof(PlatformType), currentPlatform);
                if (isActive)
                {
                    platformName += " (Active)";
                }

                GUIToggle platformToggle = new GUIToggle(new LocEdString(platformName), platformToggleGroup, EditorStyles.Button);
                platformToggle.OnToggled += x => OnSelectedPlatformChanged(currentPlatform, x);
                platformLayout.AddElement(platformToggle);

                platformButtons[i] = platformToggle;

                if (isActive)
                {
                    platformToggle.Value = true;
                    selectedPlatform     = currentPlatform;
                }
            }

            platformLayout.AddFlexibleSpace();

            GUIButton changePlatformBtn = new GUIButton(new LocEdString("Set active"));

            platformLayout.AddElement(changePlatformBtn);
            changePlatformBtn.OnClick += ChangeActivePlatform;

            platformBackground.AddElement(background);

            optionsScrollArea = new GUIScrollArea();
            optionsLayout.AddElement(optionsScrollArea);

            GUIButton buildButton = new GUIButton(new LocEdString("Build"));

            optionsLayout.AddFlexibleSpace();
            optionsLayout.AddElement(buildButton);

            buildButton.OnClick += TryStartBuild;

            BuildPlatformOptionsGUI();
        }
Exemple #39
0
        private void OnInitialize()
        {
            ProjectLibrary.OnEntryAdded += OnEntryChanged;
            ProjectLibrary.OnEntryImported += OnEntryChanged;
            ProjectLibrary.OnEntryRemoved += OnEntryChanged;

            GUILayoutY contentLayout = GUI.AddLayoutY();

            searchBarLayout = contentLayout.AddLayoutX();
            searchField = new GUITextField();
            searchField.OnChanged += OnSearchChanged;
            searchField.OnFocusGained += StopRename;

            GUIContent clearIcon = new GUIContent(EditorBuiltin.GetLibraryWindowIcon(LibraryWindowIcon.Clear),
                new LocEdString("Clear"));
            GUIButton clearSearchBtn = new GUIButton(clearIcon);
            clearSearchBtn.OnClick += OnClearClicked;
            clearSearchBtn.SetWidth(40);

            GUIContent optionsIcon = new GUIContent(EditorBuiltin.GetLibraryWindowIcon(LibraryWindowIcon.Options),
                new LocEdString("Options"));
            optionsButton = new GUIButton(optionsIcon);
            optionsButton.OnClick += OnOptionsClicked;
            optionsButton.SetWidth(40);
            searchBarLayout.AddElement(searchField);
            searchBarLayout.AddElement(clearSearchBtn);
            searchBarLayout.AddElement(optionsButton);

            folderBarLayout = contentLayout.AddLayoutX();

            GUIContent homeIcon = new GUIContent(EditorBuiltin.GetLibraryWindowIcon(LibraryWindowIcon.Home),
                new LocEdString("Home"));
            GUIButton homeButton = new GUIButton(homeIcon, GUIOption.FixedWidth(FOLDER_BUTTON_WIDTH));
            homeButton.OnClick += OnHomeClicked;

            GUIContent upIcon = new GUIContent(EditorBuiltin.GetLibraryWindowIcon(LibraryWindowIcon.Up),
                new LocEdString("Up"));
            GUIButton upButton = new GUIButton(upIcon, GUIOption.FixedWidth(FOLDER_BUTTON_WIDTH));
            upButton.OnClick += OnUpClicked;

            folderBarLayout.AddElement(homeButton);
            folderBarLayout.AddElement(upButton);
            folderBarLayout.AddSpace(10);

            contentScrollArea = new GUIScrollArea(GUIOption.FlexibleWidth(), GUIOption.FlexibleHeight());
            contentLayout.AddElement(contentScrollArea);
            contentLayout.AddFlexibleSpace();

            entryContextMenu = LibraryMenu.CreateContextMenu(this);
            content = new LibraryGUIContent(this, contentScrollArea);

            Refresh();

            dropTarget = new LibraryDropTarget(this);
            dropTarget.Bounds = GetScrollAreaBounds();
            dropTarget.OnStart += OnDragStart;
            dropTarget.OnDrag += OnDragMove;
            dropTarget.OnLeave += OnDragLeave;
            dropTarget.OnDropResource += OnResourceDragDropped;
            dropTarget.OnDropSceneObject += OnSceneObjectDragDropped;
            dropTarget.OnEnd += OnDragEnd;

            Selection.OnSelectionChanged += OnSelectionChanged;
            Selection.OnResourcePing += OnPing;
        }
        partial void InitProjSpecific(XElement element)
        {
            // TODO: need to recreate the gui when the resolution changes

            fissionRateMeter   = new Sprite(element.GetChildElement("fissionratemeter")?.GetChildElement("sprite"));
            turbineOutputMeter = new Sprite(element.GetChildElement("turbineoutputmeter")?.GetChildElement("sprite"));
            meterPointer       = new Sprite(element.GetChildElement("meterpointer")?.GetChildElement("sprite"));
            sectorSprite       = new Sprite(element.GetChildElement("sectorsprite")?.GetChildElement("sprite"));
            tempMeterFrame     = new Sprite(element.GetChildElement("tempmeterframe")?.GetChildElement("sprite"));
            tempMeterBar       = new Sprite(element.GetChildElement("tempmeterbar")?.GetChildElement("sprite"));
            tempRangeIndicator = new Sprite(element.GetChildElement("temprangeindicator")?.GetChildElement("sprite"));
            graphLine          = new Sprite(element.GetChildElement("graphline")?.GetChildElement("sprite"));

            var paddedFrame = new GUILayoutGroup(new RectTransform(
                                                     GuiFrame.Rect.Size - GUIStyle.ItemFrameMargin, GuiFrame.RectTransform, Anchor.Center)
            {
                AbsoluteOffset = GUIStyle.ItemFrameOffset
            },
                                                 isHorizontal: true)
            {
                RelativeSpacing = 0.012f,
                Stretch         = true
            };

            GUILayoutGroup columnLeft = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), paddedFrame.RectTransform))
            {
                RelativeSpacing = 0.012f,
                Stretch         = true
            };
            GUILayoutGroup columnRight = new GUILayoutGroup(new RectTransform(new Vector2(0.4f, 1.0f), paddedFrame.RectTransform))
            {
                CanBeFocused    = true,
                RelativeSpacing = 0.012f,
                Stretch         = true
            };

            //----------------------------------------------------------
            //left column
            //----------------------------------------------------------

            GUIFrame inventoryWindow = new GUIFrame(new RectTransform(new Vector2(0.1f, 0.75f), GuiFrame.RectTransform, Anchor.TopLeft, Pivot.TopRight)
            {
                MinSize        = new Point(85, 220),
                RelativeOffset = new Vector2(-0.02f, 0)
            }, style: "ItemUI");

            GUILayoutGroup inventoryContent = new GUILayoutGroup(new RectTransform(inventoryWindow.Rect.Size - GUIStyle.ItemFrameMargin, inventoryWindow.RectTransform, Anchor.Center)
            {
                AbsoluteOffset = GUIStyle.ItemFrameOffset
            },
                                                                 childAnchor: Anchor.TopCenter)
            {
                Stretch = true
            };

            /*new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), inventoryContent.RectTransform), "",
             *  textAlignment: Alignment.Center, font: GUI.SubHeadingFont, wrap: true);*/
            inventoryContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.9f), inventoryContent.RectTransform), style: null);

            //----------------------------------------------------------
            //mid column
            //----------------------------------------------------------

            var topLeftArea = new GUILayoutGroup(new RectTransform(new Vector2(1, 0.2f), columnLeft.RectTransform),
                                                 isHorizontal: true, childAnchor: Anchor.CenterLeft)
            {
                Stretch = true
            };


            Point maxIndicatorSize = new Point(int.MaxValue, (int)(40 * GUI.Scale));

            criticalHeatWarning = new GUITickBox(new RectTransform(new Vector2(0.33f, 1.0f), topLeftArea.RectTransform)
            {
                MaxSize = maxIndicatorSize
            },
                                                 TextManager.Get("ReactorWarningCriticalTemp"), font: GUI.SubHeadingFont, style: "IndicatorLightRed")
            {
                Selected = false,
                Enabled  = false,
                ToolTip  = TextManager.Get("ReactorHeatTip")
            };
            lowTemperatureWarning = new GUITickBox(new RectTransform(new Vector2(0.33f, 1.0f), topLeftArea.RectTransform)
            {
                MaxSize = maxIndicatorSize
            },
                                                   TextManager.Get("ReactorWarningCriticalLowTemp"), font: GUI.SubHeadingFont, style: "IndicatorLightRed")
            {
                Selected = false,
                Enabled  = false,
                ToolTip  = TextManager.Get("ReactorTempTip")
            };
            criticalOutputWarning = new GUITickBox(new RectTransform(new Vector2(0.33f, 1.0f), topLeftArea.RectTransform)
            {
                MaxSize = maxIndicatorSize
            },
                                                   TextManager.Get("ReactorWarningCriticalOutput"), font: GUI.SubHeadingFont, style: "IndicatorLightRed")
            {
                Selected = false,
                Enabled  = false,
                ToolTip  = TextManager.Get("ReactorOutputTip")
            };
            List <GUITickBox> indicatorLights = new List <GUITickBox>()
            {
                criticalHeatWarning, lowTemperatureWarning, criticalOutputWarning
            };

            indicatorLights.ForEach(l => l.TextBlock.OverrideTextColor(GUI.Style.TextColor));
            topLeftArea.Recalculate();

            new GUIFrame(new RectTransform(new Vector2(1.0f, 0.01f), columnLeft.RectTransform), style: "HorizontalLine");

            float   relativeYMargin  = 0.02f;
            Vector2 relativeTextSize = new Vector2(0.9f, 0.2f);
            Vector2 sliderSize       = new Vector2(1.0f, 0.125f);
            Vector2 meterSize        = new Vector2(1, 1 - relativeTextSize.Y - relativeYMargin - sliderSize.Y - 0.1f);

            var meterArea = new GUIFrame(new RectTransform(new Vector2(1, 0.6f - relativeYMargin * 2), columnLeft.RectTransform), style: null);
            var leftArea  = new GUIFrame(new RectTransform(new Vector2(0.49f, 1), meterArea.RectTransform), style: null);
            var rightArea = new GUIFrame(new RectTransform(new Vector2(0.49f, 1), meterArea.RectTransform, Anchor.TopCenter, Pivot.TopLeft), style: null);

            var fissionRateTextBox = new GUITextBlock(new RectTransform(relativeTextSize, leftArea.RectTransform, Anchor.TopCenter),
                                                      TextManager.Get("ReactorFissionRate"), textColor: GUI.Style.TextColor, textAlignment: Alignment.Center, font: GUI.SubHeadingFont)
            {
                AutoScaleHorizontal = true
            };
            var fissionMeter = new GUICustomComponent(new RectTransform(meterSize, leftArea.RectTransform, Anchor.TopCenter)
            {
                RelativeOffset = new Vector2(0.0f, relativeTextSize.Y + relativeYMargin)
            },
                                                      DrawFissionRateMeter, null)
            {
                ToolTip = TextManager.Get("ReactorTipFissionRate")
            };

            var turbineOutputTextBox = new GUITextBlock(new RectTransform(relativeTextSize, rightArea.RectTransform, Anchor.TopCenter),
                                                        TextManager.Get("ReactorTurbineOutput"), textColor: GUI.Style.TextColor, textAlignment: Alignment.Center, font: GUI.SubHeadingFont)
            {
                AutoScaleHorizontal = true
            };

            GUITextBlock.AutoScaleAndNormalize(turbineOutputTextBox, fissionRateTextBox);

            var turbineMeter = new GUICustomComponent(new RectTransform(meterSize, rightArea.RectTransform, Anchor.TopCenter)
            {
                RelativeOffset = new Vector2(0.0f, relativeTextSize.Y + relativeYMargin)
            },
                                                      DrawTurbineOutputMeter, null)
            {
                ToolTip = TextManager.Get("ReactorTipTurbineOutput")
            };

            FissionRateScrollBar = new GUIScrollBar(new RectTransform(sliderSize, leftArea.RectTransform, Anchor.TopCenter)
            {
                RelativeOffset = new Vector2(0, fissionMeter.RectTransform.RelativeOffset.Y + meterSize.Y)
            },
                                                    style: "DeviceSlider", barSize: 0.15f)
            {
                Enabled = false,
                Step    = 1.0f / 255,
                OnMoved = (GUIScrollBar bar, float scrollAmount) =>
                {
                    LastUser          = Character.Controlled;
                    unsentChanges     = true;
                    targetFissionRate = scrollAmount * 100.0f;

                    return(false);
                }
            };

            TurbineOutputScrollBar = new GUIScrollBar(new RectTransform(sliderSize, rightArea.RectTransform, Anchor.TopCenter)
            {
                RelativeOffset = new Vector2(0, turbineMeter.RectTransform.RelativeOffset.Y + meterSize.Y)
            },
                                                      style: "DeviceSlider", barSize: 0.15f, isHorizontal: true)
            {
                Enabled = false,
                Step    = 1.0f / 255,
                OnMoved = (GUIScrollBar bar, float scrollAmount) =>
                {
                    LastUser            = Character.Controlled;
                    unsentChanges       = true;
                    targetTurbineOutput = scrollAmount * 100.0f;

                    return(false);
                }
            };

            var buttonArea = new GUILayoutGroup(new RectTransform(new Vector2(1, 0.2f), columnLeft.RectTransform))
            {
                Stretch         = true,
                RelativeSpacing = 0.02f
            };
            var upperButtons = new GUILayoutGroup(new RectTransform(new Vector2(1, 0.5f), buttonArea.RectTransform), isHorizontal: true)
            {
                Stretch         = true,
                RelativeSpacing = 0.01f
            };
            var lowerButtons = new GUILayoutGroup(new RectTransform(new Vector2(1, 0.5f), buttonArea.RectTransform), isHorizontal: true)
            {
                Stretch         = true,
                RelativeSpacing = 0.01f
            };
            int buttonCount = warningTexts.Length;

            for (int i = 0; i < buttonCount; i++)
            {
                string text = warningTexts[i];
                var    b    = new GUIButton(new RectTransform(Vector2.One, (i < 4) ? upperButtons.RectTransform : lowerButtons.RectTransform),
                                            TextManager.Get(text), style: "IndicatorButton")
                {
                    Font         = GUI.SubHeadingFont,
                    CanBeFocused = false
                };
                warningButtons.Add(text, b);
            }
            upperButtons.Recalculate();
            lowerButtons.Recalculate();
            //only wrap texts that consist of multiple words and are way too big to fit otherwise
            warningButtons.Values.ForEach(b => b.TextBlock.Wrap = b.Text.Contains(' ') && b.TextBlock.TextSize.X > b.TextBlock.Rect.Width * 1.5f);
            GUITextBlock.AutoScaleAndNormalize(warningButtons.Values.Select(b => b.TextBlock));

            //----------------------------------------------------------
            //right column
            //----------------------------------------------------------

            // Auto temp
            var topRightArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.25f), columnRight.RectTransform),
                                                  isHorizontal: true, childAnchor: Anchor.CenterLeft)
            {
                Stretch         = true,
                RelativeSpacing = 0.02f
            };

            topRightArea.RectTransform.MinSize = new Point(0, topLeftArea.Rect.Height);
            topRightArea.RectTransform.MaxSize = new Point(int.MaxValue, topLeftArea.Rect.Height);

            new GUIFrame(new RectTransform(new Vector2(0.01f, 1.0f), topRightArea.RectTransform), style: "VerticalLine");

            AutoTempSwitch = new GUIButton(new RectTransform(new Vector2(0.15f, 0.9f), topRightArea.RectTransform),
                                           style: "SwitchVertical")
            {
                Enabled    = false,
                Selected   = AutoTemp,
                ClickSound = GUISoundType.UISwitch,
                OnClicked  = (button, data) =>
                {
                    AutoTemp      = !AutoTemp;
                    LastUser      = Character.Controlled;
                    unsentChanges = true;
                    return(true);
                }
            };
            AutoTempSwitch.RectTransform.MaxSize = new Point((int)(AutoTempSwitch.Rect.Height * 0.4f), int.MaxValue);

            autoTempLight = new GUITickBox(new RectTransform(new Vector2(0.4f, 1.0f), topRightArea.RectTransform),
                                           TextManager.Get("ReactorAutoTemp"), font: GUI.SubHeadingFont, style: "IndicatorLightYellow")
            {
                ToolTip      = TextManager.Get("ReactorTipAutoTemp"),
                CanBeFocused = false,
                Selected     = AutoTemp
            };
            autoTempLight.RectTransform.MaxSize = new Point(int.MaxValue, criticalHeatWarning.Rect.Height);
            autoTempLight.TextBlock.OverrideTextColor(GUI.Style.TextColor);

            new GUIFrame(new RectTransform(new Vector2(0.01f, 1.0f), topRightArea.RectTransform), style: "VerticalLine");

            // Power button
            var powerArea       = new GUIFrame(new RectTransform(new Vector2(0.4f, 1.0f), topRightArea.RectTransform), style: null);
            var paddedPowerArea = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.9f), powerArea.RectTransform, Anchor.Center, scaleBasis: ScaleBasis.BothHeight), style: "PowerButtonFrame");

            powerLight = new GUITickBox(new RectTransform(new Vector2(0.87f, 0.3f), paddedPowerArea.RectTransform, Anchor.TopCenter, Pivot.Center),
                                        TextManager.Get("PowerLabel"), font: GUI.SubHeadingFont, style: "IndicatorLightPower")
            {
                CanBeFocused = false,
                Selected     = _powerOn
            };
            powerLight.TextBlock.Padding             = new Vector4(5.0f, 0.0f, 0.0f, 0.0f);
            powerLight.TextBlock.AutoScaleHorizontal = true;
            powerLight.TextBlock.OverrideTextColor(GUI.Style.TextColor);
            PowerButton = new GUIButton(new RectTransform(new Vector2(0.8f, 0.75f), paddedPowerArea.RectTransform, Anchor.BottomCenter)
            {
                RelativeOffset = new Vector2(0, 0.1f)
            }, style: "PowerButton")
            {
                OnClicked = (button, data) =>
                {
                    PowerOn       = !PowerOn;
                    LastUser      = Character.Controlled;
                    unsentChanges = true;
                    return(true);
                }
            };

            topRightArea.Recalculate();
            autoTempLight.TextBlock.Wrap = true;
            indicatorLights.Add(autoTempLight);
            GUITextBlock.AutoScaleAndNormalize(indicatorLights.Select(l => l.TextBlock));

            // right bottom (graph area) -----------------------

            new GUIFrame(new RectTransform(new Vector2(0.95f, 0.01f), columnRight.RectTransform), style: "HorizontalLine");

            var bottomRightArea = new GUILayoutGroup(new RectTransform(Vector2.One, columnRight.RectTransform), isHorizontal: true)
            {
                Stretch         = true,
                CanBeFocused    = true,
                RelativeSpacing = 0.02f
            };

            new GUIFrame(new RectTransform(new Vector2(0.01f, 1.0f), bottomRightArea.RectTransform), style: "VerticalLine");

            new GUICustomComponent(new RectTransform(new Vector2(0.1f, 1), bottomRightArea.RectTransform, Anchor.Center), DrawTempMeter, null);

            var graphArea = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 1.0f), bottomRightArea.RectTransform))
            {
                Stretch         = true,
                RelativeSpacing = 0.02f
            };

            relativeTextSize = new Vector2(1.0f, 0.15f);
            var loadText = new GUITextBlock(new RectTransform(relativeTextSize, graphArea.RectTransform),
                                            "Load", textColor: loadColor, font: GUI.SubHeadingFont, textAlignment: Alignment.CenterLeft)
            {
                ToolTip = TextManager.Get("ReactorTipLoad")
            };
            string loadStr = TextManager.Get("ReactorLoad");
            string kW      = TextManager.Get("kilowatt");

            loadText.TextGetter += () => $"{loadStr.Replace("[kw]", ((int)load).ToString())} {kW}";

            var graph = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.9f), graphArea.RectTransform), style: "InnerFrameRed");

            new GUICustomComponent(new RectTransform(new Vector2(0.9f, 0.98f), graph.RectTransform, Anchor.Center), DrawGraph, null);

            var outputText = new GUITextBlock(new RectTransform(relativeTextSize, graphArea.RectTransform),
                                              "Output", textColor: outputColor, font: GUI.SubHeadingFont, textAlignment: Alignment.CenterLeft)
            {
                ToolTip = TextManager.Get("ReactorTipPower")
            };
            string outputStr = TextManager.Get("ReactorOutput");

            outputText.TextGetter += () => $"{outputStr.Replace("[kw]", ((int)-currPowerConsumption).ToString())} {kW}";
        }
Exemple #41
0
        /// <summary>
        /// Updates GUI for the directory bar. Should be called whenever the active folder changes.
        /// </summary>
        private void RefreshDirectoryBar()
        {
            if (folderListLayout != null)
            {
                folderListLayout.Destroy();
                folderListLayout = null;
            }

            folderListLayout = folderBarLayout.AddLayoutX();

            string[] folders = null;
            string[] fullPaths = null;

            if (IsSearchActive)
            {
                folders = new[] {searchQuery};
                fullPaths = new[] { searchQuery };
            }
            else
            {
                string currentDir = Path.Combine("Resources", CurrentFolder);

                folders = currentDir.Split(new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar },
                    StringSplitOptions.RemoveEmptyEntries);

                fullPaths = new string[folders.Length];
                for (int i = 0; i < folders.Length; i++)
                {
                    if (i == 0)
                        fullPaths[i] = "";
                    else
                        fullPaths[i] = Path.Combine(fullPaths[i - 1], folders[i]);
                }
            }

            int availableWidth = folderBarLayout.Bounds.width - FOLDER_BUTTON_WIDTH * 2;
            int numFolders = 0;
            for (int i = folders.Length - 1; i >= 0; i--)
            {
                GUIButton folderButton = new GUIButton(folders[i]);

                if (!IsSearchActive)
                {
                    string fullPath = fullPaths[i];
                    folderButton.OnClick += () => OnFolderButtonClicked(fullPath);
                }

                GUIButton separator = new GUIButton("/", GUIOption.FixedWidth(FOLDER_SEPARATOR_WIDTH));

                folderListLayout.InsertElement(0, separator);
                folderListLayout.InsertElement(0, folderButton);
                numFolders++;

                Rect2I folderListBounds = folderListLayout.Bounds;
                if (folderListBounds.width > availableWidth)
                {
                    if (numFolders > 2)
                    {
                        separator.Destroy();
                        folderButton.Destroy();
                        break;
                    }
                }
            }
        }
 public bool StartGameClicked(GUIButton button, object obj)
 {
     return(StartGame());
 }
    /**
     * Initialization code.
     *
     * Set up distances and origin points.
     */
    void Start()
    {
        controller = GetComponent<CharacterController>();

        // Adjust the collider size to fit a fish
        controller.height = colliderHeight;
        controller.radius = colliderRadius;

        model = this.GetComponent<ARModel>();
        cam = Camera.main;

        float componentMaxDistance = maxDistance / 2;
        float x = Random.Range(-componentMaxDistance, componentMaxDistance);
        float y = Random.Range(0, componentMaxDistance * 2);
        float z = Random.Range(-componentMaxDistance, componentMaxDistance);
        Vector3 startPoint = origin + new Vector3(x, y, z);

        transform.Translate(startPoint);
        centerPoint = origin;

        affected = gameObject.name.Contains("affected");

        //  ------------------------ Set up GUI ----------------------------------- \\
        // Create affected button
        GUIButton isAffected = new GUIButton ();
        isAffected.SetText("Yes");
        isAffected.SetBox (new Box()
            .SetMarginTop("auto")
            .SetMarginRight(0.01f)
            .SetMarginLeft("auto")
            .SetMarginBottom(0.01f)
            .SetWidth(Screen.width * 0.2 + "px")
            .SetHeight (0.4f));

        isAffected.OnClick (this.IThinkItsAffected);

        // Create not affected button
        GUIButton isNotAffected = new GUIButton ();
        isNotAffected.SetText("No");
        isNotAffected.SetBox (new Box()
            .SetMarginTop("auto")
            .SetMarginRight("auto")
            .SetMarginLeft(0.01f)
            .SetMarginBottom(0.01f)
            .SetWidth(Screen.width * 0.2 + "px")
            .SetHeight (0.4f));

        isNotAffected.OnClick (this.IThinkItsNotAffected);

        GUIFactory factory = new GUIFactory ();

        factory.CreateLabel ("Has this fish been affected by oil?")
            .SetBox(new Box()
                .SetMarginBottom(0.1f)
                .SetMarginTop(0.6f)
                .SetMarginLeft(0.1f)
                .SetMarginRight(0.1f))
                        .Append(isAffected)
                        .Append(isNotAffected);

        gui = factory.Build ();

        // -------------------- Look closely GUI Set up ----------------------------------- \\
        // Create Confirm button
        GUIButton confirm = new GUIButton ();
        confirm.SetText("Okay");
        confirm.SetBox (new Box()
                           .SetMarginTop("auto")
                           .SetMarginRight(0.01f)
                           .SetMarginLeft("auto")
                           .SetMarginBottom(0.01f)
                           .SetWidth(Screen.width * 0.2 + "px")
                           .SetHeight (0.4f));

        confirm.OnClick (this.Confirm);

        GUIFactory lookCloselyGUIFactory = new GUIFactory ();

        GUIComponent gc = lookCloselyGUIFactory.CreateLabel ("Look closely! Fish affected by pollution will have splotches of oil across their scales.")
            .SetBox (new Box ()
                    .SetMarginBottom (0.1f)
                    .SetMarginTop (0.6f)
                    .SetMarginLeft (0.1f)
                     .SetMarginRight (0.1f));

        GUILabel gl = (GUILabel)gc;
        GUIStyle gs = GUIStyles.GetInstance ().DEFAULT_WHITE_STYLE;
        gs.wordWrap = true;
        gl.SetStyle (gs);
        gc.Append (confirm);

        lookCloselyGUI = lookCloselyGUIFactory.Build ();

        // --------------------- alreadyExaminedGUI -------------------------------------- \\
        // Create Confirm button
        GUIButton confirmAlreadyExamined = new GUIButton ();
        confirmAlreadyExamined.SetText("Okay");
        confirmAlreadyExamined.SetBox (new Box()
                           .SetMarginTop("auto")
                           .SetMarginRight(0.01f)
                           .SetMarginLeft("auto")
                           .SetMarginBottom(0.01f)
                           .SetWidth(Screen.width * 0.2 + "px")
                           .SetHeight (0.4f));

        confirmAlreadyExamined.OnClick (this.ConfirmAlreadyExamined);

        GUIFactory alreadyExaminedGUIFactory = new GUIFactory ();

        alreadyExaminedGUIFactory.CreateLabel ("You have already examined this fish.")
            .SetBox (new Box ()
                     .SetMarginBottom (0.1f)
                     .SetMarginTop (0.6f)
                     .SetMarginLeft (0.1f)
                     .SetMarginRight (0.1f))
                .Append (confirmAlreadyExamined);

        alreadyExaminedGUI = alreadyExaminedGUIFactory.Build ();
    }
Exemple #44
0
        public void CreatePreviewWindow(GUIMessageBox messageBox)
        {
            var title = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), messageBox.Content.RectTransform), ServerName, textAlignment: Alignment.Center, font: GUI.LargeFont, wrap: true);

            var serverMsg = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.2f), messageBox.Content.RectTransform));

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), serverMsg.Content.RectTransform), ServerMessage, wrap: true);

            var columnContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.5f), messageBox.Content.RectTransform), isHorizontal: true)
            {
                Stretch         = true,
                RelativeSpacing = 0.05f
            };

            var columnLeft = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), columnContainer.RectTransform))
            {
                RelativeSpacing = 0.02f,
                Stretch         = true
            };
            var columnRight = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), columnContainer.RectTransform))
            {
                RelativeSpacing = 0.02f,
                Stretch         = true
            };

            float elementHeight = 0.1f;

            // left column -----------------------------------------------------------------------------

            //new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), columnLeft.RectTransform), IP + ":" + Port);
            new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), columnLeft.RectTransform),
                             TextManager.Get("ServerListVersion") + ": " + (string.IsNullOrEmpty(GameVersion) ? TextManager.Get("Unknown") : GameVersion));
            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), columnLeft.RectTransform),
                             TextManager.Get("ServerListContentPackages"));

            var contentPackageList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.7f), columnLeft.RectTransform));

            if (ContentPackageNames.Count == 0)
            {
                new GUITextBlock(new RectTransform(Vector2.One, contentPackageList.Content.RectTransform), TextManager.Get("Unknown"), textAlignment: Alignment.Center)
                {
                    CanBeFocused = false
                };
            }
            else
            {
                List <string> availableWorkshopUrls = new List <string>();
                for (int i = 0; i < ContentPackageNames.Count; i++)
                {
                    var packageText = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.15f), contentPackageList.Content.RectTransform)
                    {
                        MinSize = new Point(0, 15)
                    },
                                                     ContentPackageNames[i])
                    {
                        Enabled = false
                    };
                    if (i < ContentPackageHashes.Count)
                    {
                        if (GameMain.Config.SelectedContentPackages.Any(cp => cp.MD5hash.Hash == ContentPackageHashes[i]))
                        {
                            packageText.Selected = true;
                            continue;
                        }

                        //matching content package found, but it hasn't been enabled
                        if (ContentPackage.List.Any(cp => cp.MD5hash.Hash == ContentPackageHashes[i]))
                        {
                            packageText.TextColor = Color.Orange;
                            packageText.ToolTip   = TextManager.Get("ServerListContentPackageNotEnabled")
                                                    .Replace("[contentpackage]", ContentPackageNames[i]);
                        }
                        //workshop download link found
                        else if (i < ContentPackageWorkshopUrls.Count && !string.IsNullOrEmpty(ContentPackageWorkshopUrls[i]))
                        {
                            availableWorkshopUrls.Add(ContentPackageWorkshopUrls[i]);
                            packageText.TextColor = Color.Yellow;
                            packageText.ToolTip   = TextManager.Get("ServerListIncompatibleContentPackageWorkshopAvailable")
                                                    .Replace("[contentpackage]", ContentPackageNames[i]);
                        }
                        else //no package or workshop download link found, tough luck
                        {
                            packageText.TextColor = Color.Red;
                            packageText.ToolTip   = TextManager.Get("ServerListIncompatibleContentPackage")
                                                    .Replace("[contentpackage]", ContentPackageNames[i])
                                                    .Replace("[hash]", ContentPackageHashes[i]);
                        }
                    }
                }
                if (availableWorkshopUrls.Count > 0)
                {
                    var workshopBtn = new GUIButton(new RectTransform(new Vector2(1.0f, 0.15f), columnLeft.RectTransform), TextManager.Get("ServerListSubscribeMissingPackages"))
                    {
                        ToolTip   = TextManager.Get(SteamManager.IsInitialized ? "ServerListSubscribeMissingPackagesTooltip" : "ServerListSubscribeMissingPackagesTooltipNoSteam"),
                        Enabled   = SteamManager.IsInitialized,
                        OnClicked = (btn, userdata) =>
                        {
                            GameMain.SteamWorkshopScreen.SubscribeToPackages(availableWorkshopUrls);
                            GameMain.SteamWorkshopScreen.Select();
                            return(true);
                        }
                    };
                    workshopBtn.TextBlock.AutoScale = true;
                }
            }

            // right column -----------------------------------------------------------------------------

            var playerCount = new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), columnRight.RectTransform), TextManager.Get("ServerListPlayers"));

            new GUITextBlock(new RectTransform(Vector2.One, playerCount.RectTransform), PlayerCount + "/" + MaxPlayers, textAlignment: Alignment.Right);


            new GUITickBox(new RectTransform(new Vector2(1, elementHeight), columnRight.RectTransform), "Round running")
            {
                Selected     = GameStarted,
                CanBeFocused = false
            };

            var gameMode = new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), columnRight.RectTransform), TextManager.Get("GameMode"));

            new GUITextBlock(new RectTransform(Vector2.One, gameMode.RectTransform), string.IsNullOrEmpty(GameMode) ? "Unknown" : GameMode, textAlignment: Alignment.Right);

            var traitors = new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), columnRight.RectTransform), TextManager.Get("Traitors"));

            new GUITextBlock(new RectTransform(Vector2.One, traitors.RectTransform), !TraitorsEnabled.HasValue ? "Unknown" : TraitorsEnabled.Value.ToString(), textAlignment: Alignment.Right);


            var subSelection = new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), columnRight.RectTransform), TextManager.Get("ServerListSubSelection"));

            new GUITextBlock(new RectTransform(Vector2.One, subSelection.RectTransform), !SubSelectionMode.HasValue ? "Unknown" : SubSelectionMode.Value.ToString(), textAlignment: Alignment.Right);

            var modeSelection = new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), columnRight.RectTransform), TextManager.Get("ServerListModeSelection"));

            new GUITextBlock(new RectTransform(Vector2.One, modeSelection.RectTransform), (!ModeSelectionMode.HasValue ? "Unknown" : ModeSelectionMode.Value.ToString()), textAlignment: Alignment.Right);

            var allowSpectating = new GUITickBox(new RectTransform(new Vector2(1, elementHeight), columnRight.RectTransform), TextManager.Get("ServerListAllowSpectating"))
            {
                CanBeFocused = false
            };

            if (!AllowSpectating.HasValue)
            {
                new GUITextBlock(new RectTransform(new Vector2(0.8f, 0.8f), allowSpectating.Box.RectTransform, Anchor.Center), "?", textAlignment: Alignment.Center);
            }
            else
            {
                allowSpectating.Selected = AllowSpectating.Value;
            }

            var allowRespawn = new GUITickBox(new RectTransform(new Vector2(1, elementHeight), columnRight.RectTransform), "Allow respawn")
            {
                CanBeFocused = false
            };

            if (!AllowRespawn.HasValue)
            {
                new GUITextBlock(new RectTransform(new Vector2(0.8f, 0.8f), allowRespawn.Box.RectTransform, Anchor.Center), "?", textAlignment: Alignment.Center);
            }
            else
            {
                allowRespawn.Selected = AllowRespawn.Value;
            }

            new GUITickBox(new RectTransform(new Vector2(1.0f, elementHeight), columnRight.RectTransform), TextManager.Get("ServerListHasPassword"))
            {
                Selected     = HasPassword,
                CanBeFocused = false
            };

            var usingWhiteList = new GUITickBox(new RectTransform(new Vector2(1, elementHeight), columnRight.RectTransform), TextManager.Get("ServerListUsingWhitelist"))
            {
                CanBeFocused = false
            };

            if (!UsingWhiteList.HasValue)
            {
                new GUITextBlock(new RectTransform(new Vector2(0.8f, 0.8f), usingWhiteList.Box.RectTransform, Anchor.Center), "?", textAlignment: Alignment.Center);
            }
            else
            {
                usingWhiteList.Selected = UsingWhiteList.Value;
            }

            // -----------------------------------------------------------------------------

            foreach (GUIComponent c in columnLeft.Children)
            {
                if (c is GUITextBlock textBlock)
                {
                    textBlock.Padding = Vector4.Zero;
                }
            }
            foreach (GUIComponent c in columnRight.Children)
            {
                if (c is GUITextBlock textBlock)
                {
                    textBlock.Padding = Vector4.Zero;
                }
            }
        }
Exemple #45
0
    void GenerateButton()
    {
        UnitTower[] towerList=BuildManager.GetTowerList();

        buildButtonList=new GUIButton[towerList.Length];

        for(int i=0; i<towerList.Length; i++){
            UnitTower tower=towerList[i];

            buildButtonList[i]=new GUIButton(tower.icon, null, OnBuildButton, OnShowSampleTower, i);
            buildButtonList[i].buttonObj.pixelInset=new Rect(0, 0, buildButtonSize, buildButtonSize);
            buildButtonList[i].buttonObj.transform.localScale=new Vector3(0, 0, 1);

            StartCoroutine(buildButtonList[i].Update());
        }

        DisableBuildMenu();
    }
        partial void InitProjSpecific(XElement element)
        {
            uiElements.Clear();

            var visibleElements = customInterfaceElementList.Where(ciElement => !string.IsNullOrEmpty(ciElement.Label));

            GUILayoutGroup paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.8f), GuiFrame.RectTransform, Anchor.Center),
                                                            childAnchor: customInterfaceElementList.Count > 1 ? Anchor.TopCenter : Anchor.Center)
            {
                RelativeSpacing = 0.05f,
                Stretch         = visibleElements.Count() > 2
            };

            float elementSize = Math.Min(1.0f / visibleElements.Count(), 0.5f);

            foreach (CustomInterfaceElement ciElement in visibleElements)
            {
                if (ciElement.ContinuousSignal)
                {
                    var tickBox = new GUITickBox(new RectTransform(new Vector2(1.0f, elementSize), paddedFrame.RectTransform),
                                                 TextManager.Get(ciElement.Label, returnNull: true) ?? ciElement.Label)
                    {
                        UserData = ciElement
                    };
                    tickBox.TextBlock.AutoScale = true;
                    tickBox.OnSelected         += (tBox) =>
                    {
                        if (GameMain.Client == null)
                        {
                            TickBoxToggled(tBox.UserData as CustomInterfaceElement, tBox.Selected);
                        }
                        else
                        {
                            item.CreateClientEvent(this);
                        }
                        return(true);
                    };
                    uiElements.Add(tickBox);
                }
                else
                {
                    var btn = new GUIButton(new RectTransform(new Vector2(1.0f, elementSize), paddedFrame.RectTransform),
                                            TextManager.Get(ciElement.Label, returnNull: true) ?? ciElement.Label, style: "GUIButtonLarge")
                    {
                        UserData = ciElement
                    };
                    btn.TextBlock.AutoScale = true;
                    btn.OnClicked          += (_, userdata) =>
                    {
                        if (GameMain.Client == null)
                        {
                            ButtonClicked(userdata as CustomInterfaceElement);
                        }
                        else
                        {
                            GameMain.Client.CreateEntityEvent(item, new object[] { NetEntityEvent.Type.ComponentState, item.GetComponentIndex(this), userdata as CustomInterfaceElement });
                        }
                        return(true);
                    };
                    uiElements.Add(btn);
                }
            }
        }
    // Use this for initialization
    void Start()
    {
        // Create a list of lessons
        List<Lesson> lessons = CustomLessons.GetInstance().GetLessons();

        // Create Go Back to Menu Button
        GUIButton goBack = new GUIButton ();
        goBack
            .SetText("Go Back to Main Menu")
            .OnClick(FlowControl.ShowMainMenu)
                .SetBox((new Box())
                .SetMarginTop (0.0f)
                .SetMarginRight (0.0f)
                .SetMarginBottom (0.0f)
                .SetMarginLeft (0.0f));

        // Create "Help" Button
        GUIButton helpButton = new GUIButton ();
        helpButton
            .SetText(GUIConst.helpButtonText)
            .OnClick(FlowControl.ShowHelpMenu)
                .SetBox((new Box())
                .SetMarginTop (0.0f)
                .SetMarginRight (0.0f)
                .SetMarginBottom (0.0f)
                .SetMarginLeft (0.0f));

        GUIFactory factory = new GUIFactory ();

        factory
            .Append(new GUIImage("splash-background"));

        // Attach them to a "Lesson Scroll Area"
        factory
            .CreateScrollArea ()
                .SetBox((new Box())
                    .SetMarginBottom(0.1f)
                    .SetMarginTop(0.1f)
                    .SetMarginLeft(0.1f)
                    .SetMarginRight(0.1f))
                .Append(new GUILessonList(lessons));

        factory.CreateContainer()
            .SetBox ((new Box())
                .SetMarginTop ("auto")
                .SetMarginLeft ("5px")
                .SetMarginBottom ("5px")
                .SetMarginRight ("auto")
                .SetHeight (0.08f)
                .SetWidth(0.4f)).Append (goBack);

        factory
            .CreateContainer ()
                .SetBox ((new Box())
                    .SetMarginTop ("auto")
                    .SetMarginLeft ("auto")
                    .SetMarginBottom ("5px")
                    .SetMarginRight ("5px")
                    .SetHeight (0.08f)
                    .SetWidth("32px"))
                .Append(helpButton);

        // Build
        gui = factory.Build();
    }
Exemple #48
0
 private void _guiFuseeLink_OnGUIButtonLeave(GUIButton sender, GUIButtonEventArgs mea)
 {
     _guiFuseeLink.ButtonColor = new float4(0, 0, 0, 0);
     _guiFuseeLink.BorderWidth = 0;
     SetCursor(CursorType.Standard);
 }
Exemple #49
0
        protected override void InitUI(UIWidget layout)
        {
            UIFloatFieldWidget distance = new UIFloatFieldWidget("Distance", _distance);

            distance.OnValueChanged = (object value) =>
            {
                _distance = (float)value;
            };
            layout.Add(distance);

            layout.Add(new EditorHorizontalLine());

            UITextFieldWidget axis = new UITextFieldWidget("AXIS:", GetText());

            layout.Add(axis);

            EditorHorizontalLayout hlayout1 = new EditorHorizontalLayout();

            layout.Add(hlayout1);
            GUIButton axisX = new GUIButton();

            axisX.Text           = "X";
            axisX.TriggerHandler = (Widget w) =>
            {
                this.OrderBy(OrderAxis.X);
                this.SetText(axis);
            };
            hlayout1.Add(axisX);

            GUIButton axisY = new GUIButton();

            axisY.Text           = "Y";
            axisY.TriggerHandler = (Widget w) =>
            {
                this.OrderBy(OrderAxis.Y);
                this.SetText(axis);
            };
            hlayout1.Add(axisY);

            GUIButton axisZ = new GUIButton();

            axisZ.Text           = "Z";
            axisZ.TriggerHandler = (Widget w) =>
            {
                this.OrderBy(OrderAxis.Z);
                this.SetText(axis);
            };
            hlayout1.Add(axisZ);

            EditorPrefixLabel alignment = new EditorPrefixLabel();

            alignment.Text = "Alignment:";
            layout.Add(alignment);

            EditorHorizontalLayout hlayout2 = new EditorHorizontalLayout();

            layout.Add(hlayout2);

            GUIButton left = new GUIButton();

            left.ImagePath      = EditorAssets.GetResourcePath("Icons/layout_alignment_left.png");
            left.TriggerHandler = (Widget w) =>
            {
                this.OrderBy(TextAlignment.Left);
            };
            hlayout2.Add(left);

            GUIButton center = new GUIButton();

            center.ImagePath      = EditorAssets.GetResourcePath("Icons/layout_alignment_center.png");
            center.TriggerHandler = (Widget w) =>
            {
                this.OrderBy(TextAlignment.Center);
            };
            hlayout2.Add(center);

            GUIButton right = new GUIButton();

            right.ImagePath      = EditorAssets.GetResourcePath("Icons/layout_alignment_right.png");
            right.TriggerHandler = (Widget w) =>
            {
                this.OrderBy(TextAlignment.Right);
            };
            hlayout2.Add(right);
        }
        private void OnInitialize()
        {
            GUILayoutX splitLayout = GUI.AddLayoutX();
            GUIPanel platformPanel = splitLayout.AddPanel();
            GUIPanel platformForeground = platformPanel.AddPanel();
            GUILayoutY platformLayout = platformForeground.AddLayoutY();
            GUIPanel platformBackground = platformPanel.AddPanel(1);
            GUITexture background = new GUITexture(Builtin.WhiteTexture);
            background.SetTint(PLATFORM_BG_COLOR);

            splitLayout.AddSpace(5);
            GUILayoutY optionsLayout = splitLayout.AddLayoutY();

            GUILabel platformsLabel = new GUILabel(new LocEdString("Platforms"), EditorStyles.LabelCentered);
            platformLayout.AddSpace(5);
            platformLayout.AddElement(platformsLabel);
            platformLayout.AddSpace(5);

            GUIToggleGroup platformToggleGroup = new GUIToggleGroup();

            PlatformType[] availablePlatforms = BuildManager.AvailablePlatforms;
            platformButtons = new GUIToggle[availablePlatforms.Length];
            for (int i = 0; i < availablePlatforms.Length; i++)
            {
                PlatformType currentPlatform = availablePlatforms[i];
                bool isActive = currentPlatform == BuildManager.ActivePlatform;

                string platformName = Enum.GetName(typeof(PlatformType), currentPlatform);
                if (isActive)
                    platformName += " (Active)";

                GUIToggle platformToggle = new GUIToggle(new LocEdString(platformName), platformToggleGroup, EditorStyles.Button);
                platformToggle.OnToggled += x => OnSelectedPlatformChanged(currentPlatform, x);
                platformLayout.AddElement(platformToggle);

                platformButtons[i] = platformToggle;

                if (isActive)
                {
                    platformToggle.Value = true;
                    selectedPlatform = currentPlatform;
                }
            }

            platformLayout.AddFlexibleSpace();

            GUIButton changePlatformBtn = new GUIButton(new LocEdString("Set active"));
            platformLayout.AddElement(changePlatformBtn);
            changePlatformBtn.OnClick += ChangeActivePlatform;

            platformBackground.AddElement(background);

            optionsScrollArea = new GUIScrollArea();
            optionsLayout.AddElement(optionsScrollArea);

            GUIButton buildButton = new GUIButton(new LocEdString("Build"));
            optionsLayout.AddFlexibleSpace();
            optionsLayout.AddElement(buildButton);

            buildButton.OnClick += TryStartBuild;

            BuildPlatformOptionsGUI();
        }
    public Slide(string text)
    {
        state     = SlideState.TEXT;
        this.text = text;
        GUIFactory factory = new GUIFactory();

        // Go Back Button
        GUIButton backButton = new GUIButton();

        backButton.SetText("Go Back");
        backButton.SetBox(new Box()
                          .SetMarginTop("auto")
                          .SetMarginRight("auto")
                          .SetMarginLeft(0.01f)
                          .SetMarginBottom(0.01f)
                          .SetWidth(Screen.width * 0.2 + "px")
                          .SetHeight(0.1f));

        backButton.OnClick(FlowControl.PreviousSlide);

        // Go Forward Button
        GUIButton nextButton = new GUIButton();

        nextButton.SetText("Continue");
        nextButton.SetBox(new Box()
                          .SetMarginTop("auto")
                          .SetMarginLeft("auto")
                          .SetMarginRight(0.01f)
                          .SetMarginBottom(0.01f)
                          .SetWidth(Screen.width * 0.2 + "px")
                          .SetHeight(0.1f));

        nextButton.OnClick(FlowControl.NextSlide);

        GUIComponent c = factory
                         .CreateLabel(text)
                         .SetBox((new Box())
                                 .SetMarginTop(0.1f)
                                 .SetMarginRight(0.1f)
                                 .SetMarginBottom(0.1f)
                                 .SetMarginLeft(0.1f));

        GUILabel l = (GUILabel)c;

        l.SetStyle(GUIStyles.GetInstance().DEFAULT_SLIDE_STYLE);


        l.Append(nextButton);
        l.Append(backButton);

        gui = factory.Build();

        questionBoxes = new Box[4];

        questionBoxes [0] = new Box();
        questionBoxes [0]
        .SetMarginTop(0.55f)
        .SetMarginRight(0.51f)
        .SetMarginBottom("auto")
        .SetMarginLeft(0.01f)
        .SetHeight(0.1f);

        questionBoxes [1] = new Box();
        questionBoxes [1]
        .SetMarginTop(0.55f)
        .SetMarginRight(0.01f)
        .SetMarginBottom("auto")
        .SetMarginLeft(0.51f)
        .SetHeight(0.1f);

        questionBoxes [2] = new Box();
        questionBoxes [2]
        .SetMarginTop(0.7f)
        .SetMarginRight(0.51f)
        .SetMarginBottom("auto")
        .SetMarginLeft(0.01f)
        .SetHeight(0.1f);

        questionBoxes [3] = new Box();
        questionBoxes [3]
        .SetMarginTop(0.7f)
        .SetMarginRight(0.01f)
        .SetMarginBottom("auto")
        .SetMarginLeft(0.51f)
        .SetHeight(0.1f);
    }
    public void DoGUI(GameObject gameObject)
    {
        switch (this.state)
        {
        case SlideState.AR:
            this.experience.OnGUI(gameObject);

            // Check if we have found a target!
            GameObject         targetGameObject    = this.experience.GetTarget();
            bool               found               = false;
            TrackableBehaviour mTrackableBehaviour = targetGameObject.GetComponent <TrackableBehaviour> ();

            ImageTargetAbstractBehaviour b = this.experience.GetTarget().GetComponent <ImageTargetAbstractBehaviour> ();
            if (b != null && b.ImageTarget != null)
            {
                String name = b.ImageTarget.Name;

                foreach (GameObject o in this.experience.GetGameObjects())
                {
                    foreach (Renderer component in targetGameObject.GetComponentsInChildren <Renderer>(true))
                    {
                        if (component.enabled && mTrackableBehaviour.TrackableName == name)
                        {
                            found = true;
                        }
                    }

                    foreach (Collider component in targetGameObject.GetComponentsInChildren <Collider>(true))
                    {
                        if (component.enabled && mTrackableBehaviour.TrackableName == name)
                        {
                            found = true;
                        }
                    }
                }
            }

            // If NOT found, show GUI text
            if (!found)
            {
                GUIFactory factory = new GUIFactory();
                factory.CreateLabel(this.text)
                .SetBox(new Box()
                        .SetMarginTop(0.01f)
                        .SetMarginLeft(0.3f)
                        .SetMarginRight(0.3f)
                        .SetHeight(0.1f));

                factory.Build().OnGUI(gameObject);
            }

            break;

        case SlideState.QUESTION:
            // ------------------- Construct GUI for Question ---------------------- \\

            // -------------------------------- QUESTION GUI --------------------------------- \\
            GUIFactory qFactory = new GUIFactory();

            // Go Back Button
            GUIButton backButton = new GUIButton();

            backButton.SetText("Go Back");
            backButton.SetBox(new Box()
                              .SetMarginTop("auto")
                              .SetMarginRight("auto")
                              .SetMarginLeft(0.01f)
                              .SetMarginBottom(0.01f)
                              .SetWidth(Screen.width * 0.2 + "px")
                              .SetHeight(0.1f));

            backButton.OnClick(FlowControl.PreviousSlide);

            GUIComponent c;
            if (this.showDescriptionOfRightAnswer)
            {
                c = new GUILabel(question.GetDescriptionOfRightAnswer());
                qFactory.Append(c);
                c.SetBox((new Box())
                         .SetMarginTop(0.1f)
                         .SetMarginRight(0.1f)
                         .SetMarginBottom(0.1f)
                         .SetMarginLeft(0.1f));

                GUILabel z = (GUILabel)c;
                z.SetStyle(GUIStyles.GetInstance().DEFAULT_SLIDE_STYLE);

                GUIButton continueButton = new GUIButton();
                continueButton.SetText("Continue");
                continueButton.SetBox(new Box()
                                      .SetMarginTop("auto")
                                      .SetMarginLeft("auto")
                                      .SetMarginRight(0.01f)
                                      .SetMarginBottom(0.01f)
                                      .SetWidth(Screen.width * 0.2 + "px")
                                      .SetHeight(0.1f));

                continueButton.OnClick(Continue);

                c.Append(continueButton);
            }
            else
            {
                if (this.showHint)
                {
                    c = new GUIButton();
                    qFactory.Append(c);
                    c.SetBox((new Box())
                             .SetMarginTop(0.1f)
                             .SetMarginRight(0.1f)
                             .SetMarginBottom(0.1f)
                             .SetMarginLeft(0.1f));

                    GUIButton z = (GUIButton)c;
                    z.SetStyle(GUIStyles.GetInstance().DEFAULT_SLIDE_STYLE);
                    z.SetText(question.GetHint() + "\n\n(Click to hide hint)");
                    z.OnClick(HideHint);
                }
                else
                {
                    c = qFactory
                        .CreateLabel(question.GetText())
                        .SetBox((new Box())
                                .SetMarginTop(0.1f)
                                .SetMarginRight(0.1f)
                                .SetMarginBottom(0.1f)
                                .SetMarginLeft(0.1f));

                    GUILabel l = (GUILabel)c;

                    l.SetStyle(GUIStyles.GetInstance().DEFAULT_SLIDE_STYLE);
                }
                if (currentAnswer != -1)
                {
                    // We have a selected answer, show the "next" button
                    GUIButton submitAnswerButton = new GUIButton();
                    submitAnswerButton.SetText("Submit Answer");
                    submitAnswerButton.SetBox(new Box()
                                              .SetMarginTop("auto")
                                              .SetMarginLeft("auto")
                                              .SetMarginRight(0.01f)
                                              .SetMarginBottom(0.01f)
                                              .SetWidth(Screen.width * 0.2 + "px")
                                              .SetHeight(0.1f));

                    submitAnswerButton.OnClick(SubmitAnswer);

                    c.Append(submitAnswerButton);
                }

                for (int i = 0; i < this.question.GetAnswers().Length; i++)
                {
                    GUIButton button = new GUIButton();

                    button.SetText(this.question.GetAnswers() [i]);
                    button.SetBox(questionBoxes [i]);

                    if (currentAnswer == i)
                    {
                        button.SetPressed(true);
                    }

                    switch (i)
                    {
                    case 0:
                        button.OnClick(QuestionAnswerA);
                        break;

                    case 1:
                        button.OnClick(QuestionAnswerB);
                        break;

                    case 2:
                        button.OnClick(QuestionAnswerC);
                        break;

                    case 3:
                        button.OnClick(QuestionAnswerD);
                        break;

                    default:
                        break;
                    }

                    c.Append(button);
                }

                c.Append(backButton);
            }

            GUIStructure questionGUI = qFactory.Build();
            questionGUI.OnGUI(gameObject);

            break;

        case SlideState.TEXT:
            gui.OnGUI(gameObject);
            break;

        case SlideState.DONE:
            FlowControl.NextSlide();
            break;

        default:
            break;
        }
    }
        private void OnInitialize()
        {
            guiColor = new GUIColorField("", GUIOption.FixedWidth(100));
            guiSlider2DTex = new GUITexture(null, GUIOption.FixedHeight(ColorBoxHeight), GUIOption.FixedWidth(ColorBoxWidth));
            guiSliderVertTex = new GUITexture(null, GUIOption.FixedHeight(SliderSideHeight), GUIOption.FixedWidth(SliderSideWidth));
            guiSliderRHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight));
            guiSliderGHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight));
            guiSliderBHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight));
            guiSliderAHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight));

            guiColorBoxBtn = new GUIButton(colorBoxMode.ToString());
            guiColorModeBtn = new GUIButton(sliderMode.ToString());

            guiSliderVert = new GUISliderV(EditorStylesInternal.ColorSliderVert);
            guiSliderRHorz = new GUISliderH(EditorStylesInternal.ColorSliderHorz);
            guiSliderGHorz = new GUISliderH(EditorStylesInternal.ColorSliderHorz);
            guiSliderBHorz = new GUISliderH(EditorStylesInternal.ColorSliderHorz);
            guiSliderAHorz = new GUISliderH(EditorStylesInternal.ColorSliderHorz);
            guiSlider2DHandle = new GUITexture(null, EditorStylesInternal.ColorSlider2DHandle);

            guiLabelR = new GUILabel(new LocEdString("R"));
            guiLabelG = new GUILabel(new LocEdString("G"));
            guiLabelB = new GUILabel(new LocEdString("B"));
            guiLabelA = new GUILabel(new LocEdString("A"));

            guiInputR = new GUIIntField();
            guiInputG = new GUIIntField();
            guiInputB = new GUIIntField();
            guiInputA = new GUIIntField();

            guiOK = new GUIButton(new LocEdString("OK"));
            guiCancel = new GUIButton(new LocEdString("Cancel"));

            guiColorBoxBtn.OnClick += OnColorBoxModeChanged;
            guiColorModeBtn.OnClick += OnSliderModeChanged;

            guiSliderVert.OnChanged += OnSliderVertChanged;
            guiSliderRHorz.OnChanged += OnSliderRHorzChanged;
            guiSliderGHorz.OnChanged += OnSliderGHorzChanged;
            guiSliderBHorz.OnChanged += OnSliderBHorzChanged;
            guiSliderAHorz.OnChanged += OnSliderAHorzChanged;

            guiInputR.OnChanged += OnInputRChanged;
            guiInputG.OnChanged += OnInputGChanged;
            guiInputB.OnChanged += OnInputBChanged;
            guiInputA.OnChanged += OnInputAChanged;

            guiOK.OnClick += OnOK;
            guiCancel.OnClick += OnCancel;

            GUIPanel mainPanel = GUI.AddPanel(0);
            GUILayout v0 = mainPanel.AddLayoutY();

            v0.AddSpace(5);

            GUILayout h0 = v0.AddLayoutX();
            h0.AddSpace(10);
            h0.AddElement(guiColor);
            h0.AddFlexibleSpace();
            h0.AddElement(guiColorBoxBtn);
            h0.AddElement(guiColorModeBtn);
            h0.AddSpace(10);

            v0.AddSpace(10);

            GUILayout h1 = v0.AddLayoutX();
            h1.AddSpace(10);
            h1.AddElement(guiSlider2DTex);
            h1.AddFlexibleSpace();
            h1.AddElement(guiSliderVertTex);
            h1.AddSpace(10);

            v0.AddSpace(10);

            GUILayout h2 = v0.AddLayoutX();
            h2.AddSpace(10);
            h2.AddElement(guiLabelR);
            h2.AddFlexibleSpace();
            h2.AddElement(guiSliderRHorzTex);
            h2.AddFlexibleSpace();
            h2.AddElement(guiInputR);
            h2.AddSpace(10);

            v0.AddSpace(5);

            GUILayout h3 = v0.AddLayoutX();
            h3.AddSpace(10);
            h3.AddElement(guiLabelG);
            h3.AddFlexibleSpace();
            h3.AddElement(guiSliderGHorzTex);
            h3.AddFlexibleSpace();
            h3.AddElement(guiInputG);
            h3.AddSpace(10);

            v0.AddSpace(5);

            GUILayout h4 = v0.AddLayoutX();
            h4.AddSpace(10);
            h4.AddElement(guiLabelB);
            h4.AddFlexibleSpace();
            h4.AddElement(guiSliderBHorzTex);
            h4.AddFlexibleSpace();
            h4.AddElement(guiInputB);
            h4.AddSpace(10);

            v0.AddSpace(5);

            GUILayout h5 = v0.AddLayoutX();
            h5.AddSpace(10);
            h5.AddElement(guiLabelA);
            h5.AddFlexibleSpace();
            h5.AddElement(guiSliderAHorzTex);
            h5.AddFlexibleSpace();
            h5.AddElement(guiInputA);
            h5.AddSpace(10);

            v0.AddSpace(10);

            GUILayout h6 = v0.AddLayoutX();
            h6.AddFlexibleSpace();
            h6.AddElement(guiOK);
            h6.AddSpace(10);
            h6.AddElement(guiCancel);
            h6.AddFlexibleSpace();

            v0.AddSpace(5);

            GUIPanel overlay = GUI.AddPanel(-1);
            overlay.SetWidth(Width);
            overlay.SetHeight(Height);

            overlay.AddElement(guiSliderVert);
            overlay.AddElement(guiSliderRHorz);
            overlay.AddElement(guiSliderGHorz);
            overlay.AddElement(guiSliderBHorz);
            overlay.AddElement(guiSliderAHorz);
            overlay.AddElement(guiSlider2DHandle);

            colorBox = new ColorSlider2D(guiSlider2DTex, guiSlider2DHandle, ColorBoxWidth, ColorBoxHeight);
            sideSlider = new ColorSlider1DVert(guiSliderVertTex, guiSliderVert, SliderSideWidth, SliderSideHeight);

            sliderR = new ColorSlider1DHorz(guiSliderRHorzTex, guiSliderRHorz, SliderIndividualWidth, SliderIndividualHeight);
            sliderG = new ColorSlider1DHorz(guiSliderGHorzTex, guiSliderGHorz, SliderIndividualWidth, SliderIndividualHeight);
            sliderB = new ColorSlider1DHorz(guiSliderBHorzTex, guiSliderBHorz, SliderIndividualWidth, SliderIndividualHeight);
            sliderA = new ColorSlider1DHorz(guiSliderAHorzTex, guiSliderAHorz, SliderIndividualWidth, SliderIndividualHeight);

            colorBox.OnValueChanged += OnColorBoxValueChanged;

            Color startA = new Color(0, 0, 0, 1);
            Color stepA = new Color(1, 1, 1, 0);
            sliderA.UpdateTexture(startA, stepA, false);
            guiInputA.SetRange(0, 255);
            guiInputA.Value = 255;
            guiSliderAHorz.Percent = 1.0f;

            guiColor.Value = SelectedColor;
            UpdateInputBoxValues();
            Update2DSliderValues();
            Update1DSliderValues();
            UpdateSliderMode();
            Update2DSliderTextures();
            Update1DSliderTextures();
        }
Exemple #54
0
 protected bool Restart(GUIButton button, object obj)
 {
     GUI.PreventPauseMenuToggle = false;
     TutorialMode.StartTutorial(this);
     return(true);
 }
    public IEnumerator Start()
    {
        tutorialEnabled = true;

        points = new List<TutorialPoint>();

        nextButton = GameObject.Find("TutorialNext").GetComponent<GUIButton>();
        lastButton = GameObject.Find("TutorialBack").GetComponent<GUIButton>();
        skipButton = GameObject.Find("TutorialSkip").GetComponent<GUIButton>();

        lastButton.enabled = false;
        nextButton.enabled = false;
        skipButton.enabled = false;

        if (level != "")
        {
            //Application.LoadLevelAdditive(level);
            //StartCoroutine(LoadDummyLevel(level));
            AsyncOperation async = Application.LoadLevelAdditiveAsync(level);
            yield return async;
        }

        nextButton.enabled = true;
        skipButton.enabled = true;

        // Disable camera
        theCamera = GameObject.Find("TheCamera");
        if (theCamera != null)
        {
            theCamera.active = false;
        }

        // Freeze player
        GameObject player = GameObject.Find("Player");
        if (player != null)
        {
            player.rigidbody.constraints = RigidbodyConstraints.FreezeAll;
        }

        if (parent != null)
        {
            LoadPoints(parent);
        }

        init = true;

        //Tutorial.ShowText("Tap", "Tap to continue", 0, TextAlignment.Center, TextAnchor.LowerLeft, 0.0f, 0.0f);
    }
Exemple #56
0
        /// <summary>
        /// Creates all of the GUI elements required for the specified type of dialog box.
        /// </summary>
        private void SetupGUI()
        {
            messageLabel = new GUILabel("", EditorStyles.MultiLineLabel,
                GUIOption.FixedWidth(260), GUIOption.FlexibleHeight(0, 600));

            GUILayoutY layoutY = GUI.AddLayoutY();

            layoutY.AddSpace(10);
            GUILayoutX messageLayout = layoutY.AddLayoutX();
            messageLayout.AddFlexibleSpace();
            messageLayout.AddElement(messageLabel);
            messageLayout.AddFlexibleSpace();

            layoutY.AddSpace(10);

            GUILayoutX btnLayout = layoutY.AddLayoutX();
            btnLayout.AddFlexibleSpace();

            switch (type)
            {
                case Type.OK:
                    {
                        GUIButton okBtn = new GUIButton(new LocEdString("OK"));
                        okBtn.OnClick += () => ButtonClicked(ResultType.OK);

                        btnLayout.AddElement(okBtn);
                    }
                    break;
                case Type.OKCancel:
                    {
                        GUIButton okBtn = new GUIButton(new LocEdString("OK"));
                        okBtn.OnClick += () => ButtonClicked(ResultType.OK);

                        GUIButton cancelBtn = new GUIButton(new LocEdString("Cancel"));
                        cancelBtn.OnClick += () => ButtonClicked(ResultType.Cancel);

                        btnLayout.AddElement(okBtn);
                        btnLayout.AddSpace(20);
                        btnLayout.AddElement(cancelBtn);
                    }
                    break;
                case Type.RetryAbortIgnore:
                    {
                        GUIButton retryBtn = new GUIButton(new LocEdString("Retry"));
                        retryBtn.OnClick += () => ButtonClicked(ResultType.Retry);

                        GUIButton abortBtn = new GUIButton(new LocEdString("Abort"));
                        abortBtn.OnClick += () => ButtonClicked(ResultType.Abort);

                        GUIButton ignoreBtn = new GUIButton(new LocEdString("Ignore"));
                        ignoreBtn.OnClick += () => ButtonClicked(ResultType.Ignore);

                        btnLayout.AddElement(retryBtn);
                        btnLayout.AddSpace(20);
                        btnLayout.AddElement(abortBtn);
                        btnLayout.AddSpace(20);
                        btnLayout.AddElement(ignoreBtn);
                    }
                    break;
                case Type.RetryCancel:
                    {
                        GUIButton retryBtn = new GUIButton(new LocEdString("Retry"));
                        retryBtn.OnClick += () => ButtonClicked(ResultType.Retry);

                        GUIButton cancelBtn = new GUIButton(new LocEdString("Cancel"));
                        cancelBtn.OnClick += () => ButtonClicked(ResultType.Cancel);

                        btnLayout.AddElement(retryBtn);
                        btnLayout.AddSpace(20);
                        btnLayout.AddElement(cancelBtn);
                    }
                    break;
                case Type.TryCancelContinue:
                    {
                        GUIButton tryBtn = new GUIButton(new LocEdString("Try"));
                        tryBtn.OnClick += () => ButtonClicked(ResultType.Try);

                        GUIButton cancelBtn = new GUIButton(new LocEdString("Cancel"));
                        cancelBtn.OnClick += () => ButtonClicked(ResultType.Cancel);

                        GUIButton continueBtn = new GUIButton(new LocEdString("Continue"));
                        continueBtn.OnClick += () => ButtonClicked(ResultType.Continue);

                        btnLayout.AddElement(tryBtn);
                        btnLayout.AddSpace(20);
                        btnLayout.AddElement(cancelBtn);
                        btnLayout.AddSpace(20);
                        btnLayout.AddElement(continueBtn);
                    }
                    break;
                case Type.YesNo:
                    {
                        GUIButton yesBtn = new GUIButton(new LocEdString("Yes"));
                        yesBtn.OnClick += () => ButtonClicked(ResultType.Yes);

                        GUIButton noBtn = new GUIButton(new LocEdString("No"));
                        noBtn.OnClick += () => ButtonClicked(ResultType.No);

                        btnLayout.AddElement(yesBtn);
                        btnLayout.AddSpace(20);
                        btnLayout.AddElement(noBtn);
                    }
                    break;
                case Type.YesNoCancel:
                    {
                        GUIButton yesBtn = new GUIButton(new LocEdString("Yes"));
                        yesBtn.OnClick += () => ButtonClicked(ResultType.Yes);

                        GUIButton noBtn = new GUIButton(new LocEdString("No"));
                        noBtn.OnClick += () => ButtonClicked(ResultType.No);

                        GUIButton cancelBtn = new GUIButton(new LocEdString("Cancel"));
                        cancelBtn.OnClick += () => ButtonClicked(ResultType.Cancel);

                        btnLayout.AddElement(yesBtn);
                        btnLayout.AddSpace(20);
                        btnLayout.AddElement(noBtn);
                        btnLayout.AddSpace(20);
                        btnLayout.AddElement(cancelBtn);
                    }
                    break;
            }

            btnLayout.AddFlexibleSpace();
            layoutY.AddFlexibleSpace();
        }
Exemple #57
0
 private void _guiFuseeLink_OnGUIButtonEnter(GUIButton sender, GUIButtonEventArgs mea)
 {
     _guiFuseeLink.ButtonColor = new float4(0, 0.6f, 0.2f, 0.4f);
     _guiFuseeLink.BorderWidth = 1;
     SetCursor(CursorType.Hand);
 }
Exemple #58
0
 protected bool CloseInfoFrame(GUIButton button, object userData)
 {
     infoBox = null;
     infoBoxClosedCallback?.Invoke();
     return(true);
 }
        private void OnInitialize()
        {
            mainLayout = GUI.AddLayoutY();

            GUIContent viewIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.View),
                new LocEdString("View"));
            GUIContent moveIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Move),
                new LocEdString("Move"));
            GUIContent rotateIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Rotate),
                new LocEdString("Rotate"));
            GUIContent scaleIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Scale),
                new LocEdString("Scale"));

            GUIContent localIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Local),
                new LocEdString("Local"));
            GUIContent worldIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.World),
                new LocEdString("World"));

            GUIContent pivotIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Pivot),
                new LocEdString("Pivot"));
            GUIContent centerIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Center),
                new LocEdString("Center"));

            GUIContent moveSnapIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.MoveSnap),
                new LocEdString("Move snap"));
            GUIContent rotateSnapIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.RotateSnap),
                new LocEdString("Rotate snap"));

            GUIToggleGroup handlesTG = new GUIToggleGroup();
            viewButton = new GUIToggle(viewIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            moveButton = new GUIToggle(moveIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            rotateButton = new GUIToggle(rotateIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            scaleButton = new GUIToggle(scaleIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));

            GUIToggleGroup coordModeTG = new GUIToggleGroup();
            localCoordButton = new GUIToggle(localIcon, coordModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(75));
            worldCoordButton = new GUIToggle(worldIcon, coordModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(75));

            GUIToggleGroup pivotModeTG = new GUIToggleGroup();
            pivotButton = new GUIToggle(pivotIcon, pivotModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            centerButton = new GUIToggle(centerIcon, pivotModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));

            moveSnapButton = new GUIToggle(moveSnapIcon, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            moveSnapInput = new GUIFloatField("", GUIOption.FlexibleWidth(35));

            rotateSnapButton = new GUIToggle(rotateSnapIcon, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            rotateSnapInput = new GUIFloatField("", GUIOption.FlexibleWidth(35));

            viewButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.View);
            moveButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.Move);
            rotateButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.Rotate);
            scaleButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.Scale);

            localCoordButton.OnClick += () => OnCoordinateModeButtonClicked(HandleCoordinateMode.Local);
            worldCoordButton.OnClick += () => OnCoordinateModeButtonClicked(HandleCoordinateMode.World);

            pivotButton.OnClick += () => OnPivotModeButtonClicked(HandlePivotMode.Pivot);
            centerButton.OnClick += () => OnPivotModeButtonClicked(HandlePivotMode.Center);

            moveSnapButton.OnToggled += (bool active) => OnMoveSnapToggled(active);
            moveSnapInput.OnChanged += (float value) => OnMoveSnapValueChanged(value);

            rotateSnapButton.OnToggled += (bool active) => OnRotateSnapToggled(active);
            rotateSnapInput.OnChanged += (float value) => OnRotateSnapValueChanged(value);

            GUILayout handlesLayout = mainLayout.AddLayoutX();
            handlesLayout.AddElement(viewButton);
            handlesLayout.AddElement(moveButton);
            handlesLayout.AddElement(rotateButton);
            handlesLayout.AddElement(scaleButton);
            handlesLayout.AddSpace(10);
            handlesLayout.AddElement(localCoordButton);
            handlesLayout.AddElement(worldCoordButton);
            handlesLayout.AddSpace(10);
            handlesLayout.AddElement(pivotButton);
            handlesLayout.AddElement(centerButton);
            handlesLayout.AddFlexibleSpace();
            handlesLayout.AddElement(moveSnapButton);
            handlesLayout.AddElement(moveSnapInput);
            handlesLayout.AddSpace(10);
            handlesLayout.AddElement(rotateSnapButton);
            handlesLayout.AddElement(rotateSnapInput);

            GUIPanel mainPanel = mainLayout.AddPanel();
            rtPanel = mainPanel.AddPanel();

            selectionPanel = mainPanel.AddPanel(-1);

            GUIPanel sceneAxesPanel = mainPanel.AddPanel(-1);
            sceneAxesGUI = new SceneAxesGUI(this, sceneAxesPanel, HandleAxesGUISize, HandleAxesGUISize, ProjectionType.Perspective);

            focusCatcher = new GUIButton("", EditorStyles.Blank);
            focusCatcher.OnFocusGained += () => hasContentFocus = true;
            focusCatcher.OnFocusLost += () => hasContentFocus = false;

            GUIPanel focusPanel = GUI.AddPanel(-2);
            focusPanel.AddElement(focusCatcher);

            toggleProfilerOverlayKey = new VirtualButton(ToggleProfilerOverlayBinding);
            viewToolKey = new VirtualButton(ViewToolBinding);
            moveToolKey = new VirtualButton(MoveToolBinding);
            rotateToolKey = new VirtualButton(RotateToolBinding);
            scaleToolKey = new VirtualButton(ScaleToolBinding);
            frameKey = new VirtualButton(FrameBinding);

            UpdateRenderTexture(Width, Height - HeaderHeight);
            UpdateProfilerOverlay();
        }
Exemple #60
0
 void _guiFuseeLink_OnGUIButtonDown(GUIButton sender, GUIButtonEventArgs mea)
 {
     OpenLink("http://fusee3d.org");
 }