Inheritance: GUIComponent
    public GUIComponent CreateLabel(string text)
    {
        GUIComponent component = new GUILabel(text);

        this.components.Add(component);

        return component;
    }
	protected void TopPanelInit(DialogMsg dmsg)
	{
		label = Find("npcTitle") as GUILabel;
		if ( label != null )
		{
			if ( interactObject != null )
				label.text = interactObject.Name;
		}
	}
        public GUIAnimMissingEntry(GUIAnimFieldLayouts layouts, string path)
            : base(layouts, path, false, 15)
        {
            missingLabel   = new GUILabel("Missing!", GUIOption.FixedHeight(GetEntryHeight()));
            underlayLayout = layouts.underlay.AddLayoutX();
            underlayLayout.AddFlexibleSpace();
            underlayLayout.AddElement(missingLabel);
            underlayLayout.AddSpace(15);

            overlaySpacing = new GUILabel("", GUIOption.FixedHeight(GetEntryHeight()));
            layouts.overlay.AddElement(overlaySpacing);
        }
Example #4
0
        protected void InitWidget()
        {
            InnerSpace = 0;

            GUILabel label = new GUILabel();

            label.FontSize = 9;
            label.Text     = Name;
            this.AddLabel(label);

            this.InitField();
        }
        /// <summary>
        /// Sets a resource whose GUI is to be displayed in the inspector. Clears any previous contents of the window.
        /// </summary>
        /// <param name="resourcePath">Resource path relative to the project of the resource to inspect.</param>
        private void SetObjectToInspect(String resourcePath)
        {
            activeResource = ProjectLibrary.Load <Resource>(resourcePath);

            if (activeResource == null)
            {
                return;
            }

            currentType = InspectorType.Resource;

            inspectorScrollArea = new GUIScrollArea();
            GUI.AddElement(inspectorScrollArea);
            inspectorLayout = inspectorScrollArea.Layout;

            GUIPanel titlePanel = inspectorLayout.AddPanel();

            titlePanel.SetHeight(RESOURCE_TITLE_HEIGHT);

            GUILayoutY titleLayout = titlePanel.AddLayoutY();

            titleLayout.SetPosition(PADDING, PADDING);

            string name = Path.GetFileNameWithoutExtension(resourcePath);
            string type = activeResource.GetType().Name;

            LocString title      = new LocEdString(name + " (" + type + ")");
            GUILabel  titleLabel = new GUILabel(title);

            titleLayout.AddFlexibleSpace();
            GUILayoutX titleLabelLayout = titleLayout.AddLayoutX();

            titleLabelLayout.AddElement(titleLabel);
            titleLayout.AddFlexibleSpace();

            GUIPanel titleBgPanel = titlePanel.AddPanel(1);

            GUITexture titleBg = new GUITexture(null, EditorStylesInternal.InspectorTitleBg);

            titleBgPanel.AddElement(titleBg);

            inspectorLayout.AddSpace(COMPONENT_SPACING);

            inspectorResource       = new InspectorResource();
            inspectorResource.panel = inspectorLayout.AddPanel();

            var persistentProperties = persistentData.GetProperties(activeResource.UUID.ToString());

            inspectorResource.inspector = InspectorUtility.GetInspector(activeResource.GetType());
            inspectorResource.inspector.Initialize(inspectorResource.panel, activeResource, persistentProperties);

            inspectorLayout.AddFlexibleSpace();
        }
Example #6
0
    public GUILabeledSlotArray(GUIInventorySlot exchangeSlot, Item.ItemType type, String labelText,
                               IntVector2 size, Vector2 slotSpacing, Vector2 labelShift,
                               Func <ItemStack, bool> quickMove = null, Action invUpdate = null, Func <bool> shouldShow = null)
        : base(exchangeSlot, type, size, slotSpacing, quickMove, invUpdate, shouldShow)
    {
        LabelShift = labelShift;

        header = new GUILabel
        {
            Text = labelText
        };
        AddChild(header);
    }
Example #7
0
        public void loadTeamSelect(Vector2 pos, MouseKeyBinding.MouseButton mouseButton)
        {
            menuUnload();

            PlayerSelect = new PlayerSelection(engine, gui);

            PlayerSelect.LoadGuiElements();

            StartLabel = new GUILabel(gui, new Handle(engine.resourceComponent, "Menu/Start.png"));
            StartLabel.mouseClickEvent += startGame;
            StartLabel.pos              = new Vector2(width / 2 - 110, height - 96);
            gui.add(StartLabel);
        }
        public MultiplayerLoadingBar(GUISystem system, GUITheme theme)
            : base(system, new UDim2(0.8f, 0, 0, 120), "", theme, false)
        {
            IsDraggable = false;

            barAnim  = new FloatAnim();
            byteAnim = new FloatAnim();

            statusLabel = new GUILabel(new UDim2(0.5f, 0, 0.4f, 0), UDim2.Zero, "0/0 bytes", theme);
            bar         = new GUIFrame(new UDim2(0, 5, 1f, -35), new UDim2(0, -10, 0, 30), Image.Blank);

            AddTopLevel(statusLabel, bar);
        }
Example #9
0
        private void CreateCollaboratorGUI(GUILayoutY layout, string name, string area)
        {
            GUILabel nameLabel = new GUILabel(new LocEdString(name), GUIOption.FixedWidth(150));
            GUILabel areaLabel = new GUILabel(new LocEdString(area), GUIOption.FixedWidth(220));

            GUILayoutX horzLayout = layout.AddLayoutX();

            horzLayout.AddSpace(10);
            horzLayout.AddElement(nameLabel);
            horzLayout.AddSpace(10);
            horzLayout.AddElement(areaLabel);
            horzLayout.AddSpace(10);
        }
Example #10
0
    public void Initialize(Vector2 northPole)
    {
        Vector2 empty = new Vector2();

        foreach (KeyValuePair <Player.Stats, Color> kvPair in STAT_BAR_COLORS)
        {
            Player.Stats stat = kvPair.Key;
            statBars[stat] = new GUIVerticalBar(empty, BAR_LENGTH, kvPair.Value,
                                                () => player[stat],
                                                () => player[stat] < STAT_LEVEL_MAX_SHOW[stat]);
            AddChild(statBars[stat]);
            Sprite sprite = STAT_BAR_SPRITES[stat]();
            sprite.Scale    = ICON_SCALE;
            sprite.Position = ICON_OFFSET;
            statBars[stat].AddChild(sprite);
        }
        foreach (KeyValuePair <Gas, Color> kvPair in GAS_BAR_COLORS)
        {
            Gas g = kvPair.Key;
            gasBars[g] = new GUIHorizontalBar(empty, ATM_BAR_LENGTH, kvPair.Value,
                                              () => atm.GetGasProgress(g),
                                              () => atm.GetGasProgress(g) > 0 && atm.GetGasProgress(g) < 1);
            AddChild(gasBars[g]);
        }

        // debugSheet = new GUIBox(empty, COMPASS_SIZE);
        // AddChild(debugSheet);
        compass = new GUICompass(empty, COMPASS_SIZE, northPole,
                                 () => new Vector2(player.Translation.x, player.Translation.z) / Block.SIZE,
                                 viewDirSupplier,
                                 () => (player.Translation / Block.SIZE - northMonopole).LengthSquared() >= MIN_RADIUS_FOR_COMPASS * MIN_RADIUS_FOR_COMPASS);
        AddChild(compass);

        // hacky, works for now, TODO: fix
        inHandLabel = new GUILabel(() => {
            bool showLabel = !BackgroundMode && player.ItemInHand != null;
            if (showLabel)
            {
                inHandLabel.Text = "Currently in hand: " + player.ItemInHand.Item.Name + ",    Quantity : " + player.ItemInHand.Count;
            }
            return(showLabel);
        });
        AddChild(inHandLabel);

        Texture tex = Game.guiResourceLoader.GetResource(CROSSHAIR_TEX) as Texture;

        crosshair = new GUIObject(empty, tex.GetSize(), tex, () => !BackgroundMode);
        AddChild(crosshair);
        Visible = true;
    }
Example #11
0
        //bool showGameItems;

        public HUD(MasterRenderer renderer)
        {
            this.renderer = renderer;
            font          = AssetManager.LoadFont("karmasuture-26");

            feed           = new List <FeedItem>();
            hitIndications = new List <HitIndication>();

            if (palletTex == null)
            {
                palletTex = GLoader.LoadTexture("Textures/Gui/palette.png");
                Texture crosshairTex = GLoader.LoadTexture("Textures/Gui/crosshair.png");
                Texture hitmarkerTex = GLoader.LoadTexture("Textures/Gui/hitmarker.png");
                crosshairImage = new Image(crosshairTex);
                hitmarkerImage = new Image(hitmarkerTex);
                hurtRingTex    = GLoader.LoadTexture("Textures/Gui/hurt-ring.png");
                intelTex       = GLoader.LoadTexture("Textures/Gui/intel.png", TextureMinFilter.Nearest, TextureMagFilter.Nearest);
            }

            GUISystem gsys = renderer.Sprites.GUISystem;

            area        = new GUIArea(gsys);
            area.ZIndex = -1;

            theme = GUITheme.Basic;
            theme.SetField("Font", font);
            theme.SetField("SmallFont", AssetManager.LoadFont("arial-bold-14"));
            theme.SetField("Label.TextColor", Color.White);
            theme.SetField("Label.TextShadowColor", new Color(0, 0, 0, 0.6f));

            healthLabel       = new GUILabel(new UDim2(0, 40, 1, -20), UDim2.Zero, "Health: --", TextAlign.BottomLeft, theme);
            ammoLabel         = new GUILabel(new UDim2(1, -50, 1, -25), UDim2.Zero, "", TextAlign.BottomRight, theme);
            crosshair         = new GUIFrame(new UDim2(0.5f, -28, 0.5f, -28), new UDim2(0, 56, 0, 56), crosshairImage);
            hitmarker         = new GUIFrame(new UDim2(0.5f, -43, 0.5f, -43), new UDim2(0, 86, 0, 86), hitmarkerImage);
            hitmarker.Visible = false;

            intelInHand = new GUIFrame(new UDim2(0.5f, -20, 0, 100), new UDim2(0, 40, 0, 40), new Image(intelTex));
            intelPickedUpNotification = new GUILabel(new UDim2(0.5f, 0, 0, 150), UDim2.Zero,
                                                     "You have picked up the intel!", TextAlign.TopCenter, theme);
            intelInHand.Visible = false;
            intelPickedUpNotification.Visible = false;

            crosshair.CapturesMouseClicks   = false;
            hitmarker.CapturesMouseClicks   = false;
            ammoLabel.CapturesMouseClicks   = false;
            healthLabel.CapturesMouseClicks = false;

            area.AddTopLevel(ammoLabel, healthLabel, crosshair, hitmarker, intelInHand, intelPickedUpNotification);
        }
Example #12
0
        private void CreateThirdPartyGUI(GUILayoutY layout, string name, string webURL)
        {
            GUILabel  label   = new GUILabel(new LocEdString(name), GUIOption.FixedWidth(150));
            GUIButton linkBtn = new GUIButton(new LocEdString("Website"), GUIOption.FixedWidth(50));

            GUILayoutX horzLayout = layout.AddLayoutX();

            horzLayout.AddSpace(10);
            horzLayout.AddElement(label);
            horzLayout.AddSpace(10);
            horzLayout.AddElement(linkBtn);
            horzLayout.AddSpace(10);

            linkBtn.OnClick += () => { System.Diagnostics.Process.Start(webURL); };
        }
Example #13
0
        private void CreateNameURLBtnPair(GUILayoutY layout, string name, string webURL, string btnText)
        {
            GUILabel  label   = new GUILabel(new LocEdString(name), GUIOption.FixedWidth(300));
            GUIButton linkBtn = new GUIButton(new LocEdString(btnText), GUIOption.FixedWidth(100));

            GUILayoutX horzLayout = layout.AddLayoutX();

            horzLayout.AddSpace(10);
            horzLayout.AddElement(label);
            horzLayout.AddSpace(10);
            horzLayout.AddElement(linkBtn);
            horzLayout.AddSpace(10);

            linkBtn.OnClick += () => { System.Diagnostics.Process.Start(webURL); };
        }
Example #14
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            graphics.PreferredBackBufferWidth  = 800;
            graphics.PreferredBackBufferHeight = 600;
            RasterizerState customState = new RasterizerState();

            graphics.GraphicsDevice.RasterizerState = customState;

            graphics.ApplyChanges();

            ComponentRecord.RegisterAttribute <Sprite>("Sprite");
            ComponentRecord.RegisterAttribute <AnimatedSprite>("AnimatedSprite");
            ComponentRecord.RegisterAttribute <Transform>("Transform");
            ComponentRecord.RegisterAttribute <GUIButton>("GUIButton");
            ComponentRecord.RegisterAttribute <GUILabel>("GUILabel");
            ComponentRecord.RegisterAttribute <GUITextBox>("GUITextBox");
            ComponentRecord.RegisterAttribute <GUIImage>("GUIImage");
            ComponentRecord.RegisterAttribute <AABBCollider>("AABBCollider");
            ComponentRecord.RegisterAttribute <SATCollider>("SATCollider");
            ComponentRecord.RegisterAttribute <CharacterController>("CharacterController");

            Debug.InitializeDebug(GraphicsDevice, this);
            DebugConsole.DebugConsoleInit(this, graphics);
            GameSerializer.Init(this);
            GameScript.InitGameScript();
            Transform.UpdateGraphicsSize(graphics);
            InputManager.InitInputManager(this);
            Camera.InitCamera(graphics);
            GUILabel.Initialize(this);

            Exiting += new EventHandler <EventArgs>((object obj, EventArgs args) =>
            {
                Debug.CloseDebug();
            });

            DebugConsole.RegisterCommand("reset", (string[] args) =>
            {
                reset();
            });

            w = new World();

            this.IsMouseVisible = true;

            base.Initialize();
        }
Example #15
0
        /// <summary>
        /// Creates a new scene axes GUI.
        /// </summary>
        /// <param name="window">Window in which the GUI is located in.</param>
        /// <param name="panel">Panel onto which to place the GUI element.</param>
        /// <param name="width">Width of the GUI element.</param>
        /// <param name="height">Height of the GUI element.</param>
        /// <param name="projType">Projection type to display on the GUI.</param>
        public SceneAxesGUI(SceneWindow window, GUIPanel panel, int width, int height, ProjectionType projType)
        {
            renderTexture          = new RenderTexture(PixelFormat.RGBA8, width, height);
            renderTexture.Priority = 1;

            SceneObject cameraSO = new SceneObject("SceneAxesCamera", true);

            camera = cameraSO.AddComponent <Camera>();
            camera.Viewport.Target = renderTexture;
            camera.Viewport.Area   = new Rect2(0.0f, 0.0f, 1.0f, 1.0f);

            cameraSO.Position = new Vector3(0, 0, 5);
            cameraSO.LookAt(new Vector3(0, 0, 0));

            camera.Priority            = 2;
            camera.NearClipPlane       = 0.05f;
            camera.FarClipPlane        = 1000.0f;
            camera.Viewport.ClearColor = new Color(0.0f, 0.0f, 0.0f, 0.0f);
            camera.ProjectionType      = ProjectionType.Orthographic;
            camera.Layers      = SceneAxesHandle.LAYER;
            camera.AspectRatio = 1.0f;
            camera.OrthoHeight = 2.0f;
            camera.RenderSettings.EnableHDR    = false;
            camera.RenderSettings.EnableSkybox = false;
            camera.Flags |= CameraFlag.OnDemand;

            renderTextureGUI = new GUIRenderTexture(renderTexture, true);

            GUILayoutY layout        = panel.AddLayoutY();
            GUILayoutX textureLayout = layout.AddLayoutX();

            textureLayout.AddElement(renderTextureGUI);
            textureLayout.AddFlexibleSpace();

            Rect2I bounds = new Rect2I(0, 0, width, height);

            sceneHandles            = new SceneHandles(window, camera);
            renderTextureGUI.Bounds = bounds;

            labelGUI = new GUILabel(projType.ToString(), EditorStyles.LabelCentered);
            layout.AddElement(labelGUI);
            layout.AddFlexibleSpace();

            this.panel  = panel;
            this.bounds = bounds;

            NotifyNeedsRedraw();
        }
Example #16
0
        public void AddLabledCheckbox(string labelText, bool checkboxDefaultState, UDim2 position,
                                      out GUILabel label, out GUICheckbox checkbox)
        {
            label = new GUILabel(position, UDim2.Zero, labelText, TextAlign.Left, Theme);
            Vector2 textSize = label.Font.MeasureString(labelText);

            label.Size = new UDim2(0, textSize.X, 0, textSize.Y + (ElementPadding * 2));

            UDim labelXPos = position.X + new UDim(0, textSize.X + ElementPadding);

            checkbox           = new GUICheckbox(new UDim2(labelXPos, position.Y), label.Size.Y.Offset, Theme);
            checkbox.IsChecked = checkboxDefaultState;

            label.Parent    = this;
            checkbox.Parent = this;
        }
Example #17
0
            public ChatItem(GUITheme theme, float height, int numFeed,
                            string text, BMPFont font)
                : base(UDim2.Zero, UDim2.Zero, image: null)
            {
                Position = new UDim2(0, 0, 0, 20 + (height * numFeed));
                Size     = new UDim2(0, 1f, 0, height);

                label = new GUILabel(UDim2.Zero, new UDim2(0, 1, 1f, 0), text, TextAlign.Left, Color.White, theme)
                {
                    Parent = this
                };

                label.Font = font;

                TimeLeft = 60f;
            }
Example #18
0
        /// <summary>
        /// Creates a new empty list view.
        /// </summary>
        /// <param name="width">Width of the list view, in pixels.</param>
        /// <param name="height">Height of the list view, in pixels.</param>
        /// <param name="entryHeight">Height of a single element in the list, in pixels.</param>
        /// <param name="layout">GUI layout into which the list view will be placed into.</param>
        protected GUIListViewBase(int width, int height, int entryHeight, GUILayout layout)
        {
            scrollArea = new GUIScrollArea(ScrollBarType.ShowIfDoesntFit, ScrollBarType.NeverShow,
                                           GUIOption.FixedWidth(width), GUIOption.FixedHeight(height));
            layout.AddElement(scrollArea);

            topPadding    = new GUILabel(new LocString());
            bottomPadding = new GUILabel(new LocString());

            scrollArea.Layout.AddElement(topPadding);
            scrollArea.Layout.AddElement(bottomPadding);

            this.width       = width;
            this.height      = height;
            this.entryHeight = entryHeight;
        }
Example #19
0
        public void Initialize()
        {
            BackgroundLabel     = new GUILabel(gui, new Handle(engine.resourceComponent, "Menu/PauseMenu/Background.png"));
            BackgroundLabel.pos = new Vector2(125, 200);

            ResumeLabel = new GUILabel(gui, new Handle(engine.resourceComponent, "Menu/PauseMenu/Resume.png"));
            ResumeLabel.mouseClickEvent += ResumeGame;
            ResumeLabel.pos              = new Vector2(165, 400);

            EndTurnLabel = new GUILabel(gui, new Handle(engine.resourceComponent, "Menu/PauseMenu/EndTurn.png"));
            EndTurnLabel.mouseClickEvent += EndTurn;
            EndTurnLabel.pos              = new Vector2(390, 400);

            QuitLabel = new GUILabel(gui, new Handle(engine.resourceComponent, "Menu/PauseMenu/Quit.png"));
            QuitLabel.mouseClickEvent += ExitGame;
            QuitLabel.pos              = new Vector2(615, 400);
        }
Example #20
0
        public TextBox(Rectangle elementRectangle, GameWindow gameWindow, string defaultText = "", bool censoredInput = false, OnTextUpdate onTextUpdateEvent = null) : base(elementRectangle)
        {
            this.censoredInput = censoredInput;
            if (onTextUpdateEvent != null)
            {
                OnTextUpdateEvent += onTextUpdateEvent;
            }

            if (!string.IsNullOrEmpty(defaultText))
            {
                this.defaultText = true;
                textLabel        = new GUILabel(elementRectangle.Center, defaultText, GameButton.TextFont, Color.LightGray, elementRectangle);
                AddElement(textLabel);
            }

            gameWindow.TextInput += GameWindow_TextInput;
        }
        void Setup()
        {
            foreach (GUILabel label in labels)
            {
                RemoveTopLevel(label);
            }
            labels.Clear();

            Image backImage1 = Image.CreateBlank(new Color(80, 80, 80, 128));
            Image backImage2 = Image.CreateBlank(new Color(40, 40, 40, 128));

            float y = 20;
            int   i = 0;

            foreach (KeyValuePair <string, Input.InputBind> bind in Input.Binds)
            {
                Image image = i % 2 == 0 ? backImage1 : backImage2;

                GUILabel label1 = new GUILabel(new UDim2(0, 0, 0, y), new UDim2(0.5f, 0, 0, 22),
                                               bind.Key, TextAlign.Left, Theme)
                {
                    Font = font, BackgroundImage = image
                };
                GUILabel label2 = new GUILabel(new UDim2(0.5f, 0, 0, y), new UDim2(0.5f, 0, 0, 22),
                                               bind.Value.ToString(), TextAlign.Left, Theme)
                {
                    Font = font, BackgroundImage = image
                };
                label1.ZIndex = -1;
                label2.ZIndex = 1;
                labels.Add(label1);
                labels.Add(label2);
                y += label1.Size.Y.Offset;
                i++;

                AddTopLevel(label1, label2);
            }

            Size    = new UDim2(0.5f, 0, 0, y);
            MinSize = new UDim2(0, 300, 0, 0);
            MaxSize = new UDim2(0, 500, 1f, 0);

            Center();
        }
Example #22
0
    public void CreateTextMessage(string message, Color col)
    {
        GameObject button = Instantiate(LabelPrefab) as GameObject;
        GUILabel   label  = button.GetComponent <GUILabel>();

        label.Text = message;
        label.UIDragPanel.draggablePanel = ChatGrid.DragPanel;
        ChatGrid.AddLabel(label);
        try
        {
            ChatGrid.Reposition();
        }
        catch (Exception e)
        {
            Debug.Log(e.Message);
            Debug.Log(e.Source);
            Debug.Log(e.StackTrace);
        }
    }
Example #23
0
        public void initializeInfoBox()
        {
            Engine.GUI tempGUI = engine.graphicsComponent.gui;

            playerInfoLabel        = new GUILabel(tempGUI, new Handle(engine.resourceComponent, "GUI\\PlayerInfoBg.png"));
            playerInfoOutlineLabel = new GUILabel(tempGUI, new Handle(engine.resourceComponent, "GUI\\PlayerInfoOutline.png"));
            healthInfoBox          = new GUITextBox(tempGUI, "");
            attackInfoBox          = new GUITextBox(tempGUI, "");
            levelInfoBox           = new GUITextBox(tempGUI, "");

            tempGUI.add(playerInfoOutlineLabel);
            tempGUI.add(playerInfoLabel);
            tempGUI.add(healthInfoBox);
            tempGUI.add(attackInfoBox);
            tempGUI.add(levelInfoBox);

            teamBox = new GUILabel(tempGUI);
            tempGUI.add(teamBox);
        }
        /// <summary>
        /// Creates a new material parameter GUI.
        /// </summary>
        /// <param name="shaderParam">Shader parameter to create the GUI for. Must be of 4x4 matrix type.</param>
        /// <param name="material">Material the parameter is a part of.</param>
        /// <param name="layout">Layout to append the GUI elements to.</param>
        internal MaterialParamMat4GUI(ShaderParameter shaderParam, Material material, GUILayout layout)
            : base(shaderParam)
        {
            LocString title    = new LocEdString(shaderParam.name);
            GUILabel  guiTitle = new GUILabel(title, GUIOption.FixedWidth(100));

            mainLayout = layout.AddLayoutY();
            GUILayoutX titleLayout = mainLayout.AddLayoutX();

            titleLayout.AddElement(guiTitle);
            titleLayout.AddFlexibleSpace();

            GUILayoutY contentLayout = mainLayout.AddLayoutY();

            GUILayoutX[] rows = new GUILayoutX[MAT_SIZE];
            for (int i = 0; i < rows.Length; i++)
            {
                rows[i] = contentLayout.AddLayoutX();
            }

            for (int row = 0; row < MAT_SIZE; row++)
            {
                for (int col = 0; col < MAT_SIZE; col++)
                {
                    int index = row * MAT_SIZE + col;
                    guiMatFields[index] = new GUIFloatField(row + "," + col, 20, "", GUIOption.FixedWidth(80));

                    GUIFloatField field = guiMatFields[index];
                    rows[row].AddElement(field);
                    rows[row].AddSpace(5);

                    int hoistedRow = row;
                    int hoistedCol = col;
                    field.OnChanged += (x) =>
                    {
                        Matrix4 value = material.GetMatrix4(shaderParam.name);
                        value[hoistedRow, hoistedCol] = x;
                        material.SetMatrix4(shaderParam.name, value);
                        EditorApplication.SetDirty(material);
                    };
                }
            }
        }
Example #25
0
        public GUIWindow(GUISystem system, UDim2 position, UDim2 size, string title, GUITheme theme,
                         bool closable = true, bool createTitleBar = true)
            : base(system, position, size)
        {
            Theme = theme;
            if (createTitleBar)
            {
                TitleBar = new GUILabel(UDim2.Zero, new UDim2(1f, 0, 0, 20), title,
                                        theme.GetField <Color>(Color.White, "Window.TitleBar.TextColor"), theme);
                TitleBar.CapturesMouseClicks = true;
                TitleBar.ZIndex          = 100;
                TitleBar.BackgroundImage = theme.GetField <Image>(Image.CreateBlank(new Color(40, 40, 40)), "Window.TitleBar.BackgroundImage");

                if (closable)
                {
                    ExitButton = new GUIButton(new UDim2(1f, -20, 0, 0), new UDim2(0, 20, 0, 20),
                                               theme.GetField <string>("X", "Window.TitleBar.CloseButton.Text"),
                                               TextAlign.Center,
                                               theme,
                                               theme.GetField <Image>(Image.CreateBlank(new Color(230, 0, 0)), "Window.TitleBar.CloseButton.NormalImage"),
                                               theme.GetField <Image>(Image.CreateBlank(new Color(255, 0, 0)), "Window.TitleBar.CloseButton.HoverImage"),
                                               theme.GetField <Image>(Image.CreateBlank(new Color(200, 0, 0)), "Window.TitleBar.CloseButton.ActiveImage"),
                                               null);
                    ExitButton.Parent        = TitleBar;
                    ExitButton.OnMouseClick += (btn, mbtn) =>
                    {
                        Visible = false;
                    };
                }
            }

            BackgroundFrame = new GUIFrame(new UDim2(0, 0, 0, createTitleBar ? 20 : 0), new UDim2(1f, 0, 1f, createTitleBar ? -20 : 0),
                                           theme.GetField <Image>(Image.CreateBlank(new Color(70, 70, 70, 200)), "Window.BackgroundImage"));
            BackgroundFrame.ZIndex = -100;

            if (createTitleBar)
            {
                SetDragHandle(TitleBar);
                AddTopLevel(TitleBar);
            }
            AddTopLevel(BackgroundFrame);
        }
        public GUIAnimSimpleEntry(GUIAnimFieldLayouts layouts, string path, Color color, bool child = false)
            : base(layouts, path, child, child ? 45 : 30)
        {
            valueDisplay   = new GUILabel("", GUIOption.FixedHeight(GetEntryHeight()));
            underlayLayout = layouts.underlay.AddLayoutX();
            underlayLayout.AddSpace(child ? 30 : 15);

            GUITexture colorSquare = new GUITexture(Builtin.WhiteTexture,
                                                    GUIOption.FixedWidth(10), GUIOption.FixedHeight(10));

            colorSquare.SetTint(color);

            underlayLayout.AddElement(colorSquare);
            underlayLayout.AddFlexibleSpace();
            underlayLayout.AddElement(valueDisplay);
            underlayLayout.AddSpace(50);

            overlaySpacing = new GUILabel("", GUIOption.FixedHeight(GetEntryHeight()));
            layouts.overlay.AddElement(overlaySpacing);
        }
Example #27
0
            /// <inheritdoc/>
            public override void BuildGUI()
            {
                main     = Layout.AddPanel(0, 1, 1, GUIOption.FixedHeight(ENTRY_HEIGHT));
                overlay  = main.AddPanel(-1, 0, 0, GUIOption.FixedHeight(ENTRY_HEIGHT));
                underlay = main.AddPanel(1, 0, 0, GUIOption.FixedHeight(ENTRY_HEIGHT));

                GUILayoutX mainLayout     = main.AddLayoutX();
                GUILayoutY overlayLayout  = overlay.AddLayoutY();
                GUILayoutY underlayLayout = underlay.AddLayoutY();

                icon          = new GUITexture(null, GUIOption.FixedWidth(32), GUIOption.FixedHeight(32));
                messageLabel  = new GUILabel(new LocEdString(""), EditorStyles.MultiLineLabel, GUIOption.FixedHeight(MESSAGE_HEIGHT));
                functionLabel = new GUILabel(new LocEdString(""), GUIOption.FixedHeight(CALLER_LABEL_HEIGHT));

                mainLayout.AddSpace(PADDING);
                GUILayoutY iconLayout = mainLayout.AddLayoutY();

                iconLayout.AddFlexibleSpace();
                iconLayout.AddElement(icon);
                iconLayout.AddFlexibleSpace();

                mainLayout.AddSpace(PADDING);
                GUILayoutY messageLayout = mainLayout.AddLayoutY();

                messageLayout.AddSpace(PADDING);
                messageLayout.AddElement(messageLabel);
                messageLayout.AddElement(functionLabel);
                messageLayout.AddSpace(PADDING);
                mainLayout.AddFlexibleSpace();
                mainLayout.AddSpace(PADDING);

                background = new GUITexture(Builtin.WhiteTexture, GUIOption.FixedHeight(ENTRY_HEIGHT));
                underlayLayout.AddElement(background);

                GUIButton button = new GUIButton(new LocEdString(""), EditorStyles.Blank, GUIOption.FixedHeight(ENTRY_HEIGHT));

                overlayLayout.AddElement(button);

                button.OnClick       += OnClicked;
                button.OnDoubleClick += OnDoubleClicked;
            }
Example #28
0
        private void BuildGUI()
        {
            progressBar           = new GUIProgressBar();
            messageLabel          = new GUILabel("", EditorStyles.MultiLineLabelCentered, GUIOption.FixedHeight(60));
            cancelImport          = new GUIButton(new LocEdString("Cancel import"));
            cancelImport.OnClick += () =>
            {
                ProjectLibrary.CancelImport();
                cancelImport.Disabled = true;
            };

            GUILayoutY layoutY = GUI.AddLayoutY();

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

            messageLayout.AddSpace(15);
            messageLayout.AddElement(messageLabel);
            messageLayout.AddSpace(15);

            layoutY.AddSpace(10);

            GUILayoutX barLayout = layoutY.AddLayoutX();

            barLayout.AddSpace(30);
            barLayout.AddElement(progressBar);
            barLayout.AddSpace(30);

            layoutY.AddSpace(20);

            GUILayoutX buttonLayout = layoutY.AddLayoutX();

            buttonLayout.AddFlexibleSpace();
            buttonLayout.AddElement(cancelImport);
            buttonLayout.AddFlexibleSpace();

            layoutY.AddFlexibleSpace();

            messageLabel.SetContent(new LocEdString("Resource import is still in progress. You can wait until it " +
                                                    "finishes or cancel import. \n\nNote that even when cancelling you will need to wait for active import threads to finish."));
        }
Example #29
0
        public void AddLabledTextField(string labelText, string defaultFieldText, UDim2 position,
                                       out GUILabel label, out GUITextField textField, UDim?fieldXLength = null)
        {
            label = new GUILabel(position, UDim2.Zero, labelText, TextAlign.Left, Theme);
            Vector2 textSize = label.Font.MeasureString(labelText);

            label.Size = new UDim2(0, textSize.X, 0, textSize.Y + (ElementPadding * 2));

            UDim labelXPos = position.X + new UDim(0, textSize.X + ElementPadding);

            if (!fieldXLength.HasValue)
            {
                fieldXLength = new UDim(1f, -(textSize.X + ElementPadding) - ElementPadding);
            }
            textField = new GUITextField(new UDim2(labelXPos, position.Y),
                                         new UDim2(fieldXLength.Value, new UDim(0, label.Size.Y.Offset)),
                                         defaultFieldText, TextAlign.Left, Theme);

            label.Parent     = this;
            textField.Parent = this;
        }
Example #30
0
        public HUD(MasterRenderer renderer, Player player, DashFont font)
        {
            this.renderer = renderer;
            this.player   = player;
            this.font     = font;

            surface = new GUISurface2D(renderer.ScreenWidth, renderer.ScreenHeight);
            renderer.Gui.Add(surface);

            GUITheme theme = new GUITheme()
            {
                Font           = font,
                LabelTextColor = Color.White,
            };

            healthLabel  = new GUILabel(new UDim2(0, 40, 1, -20), UDim2.Zero, theme, "Health: --", TextAlign.BottomLeft);
            ammoLabel    = new GUILabel(new UDim2(1, -50, 1, -25), UDim2.Zero, theme, "", TextAlign.BottomRight);
            crosshairDot = new GUIImage(GUISurface.BlankTexture, new UDim2(0.5f, -1, 0.5f, -1), new UDim2(0, 2, 0, 2), theme);

            surface.Add(ammoLabel, healthLabel, crosshairDot);
        }
        public ConnectWindow(GUISystem system, GUITheme theme, UDim2 size) 
            : base(system, size, "Connect to server", theme)
        {
            GUILabel endPointLabel = new GUILabel(new UDim2(0, 10, 0, 50), UDim2.Zero, "Server Address:",
                TextAlign.Left, theme);
            Vector2 labelSize = endPointLabel.Font.MeasureString(endPointLabel.Text);
            endPointField = new GUITextField(new UDim2(0, labelSize.X + 20, 0, 35),
                new UDim2(1f, -labelSize.X - 30, 0, 30), "", TextAlign.Left, theme);

            GUILabel nameLabel = new GUILabel(new UDim2(0, 10, 0, 100), UDim2.Zero, "Player Name:",
                TextAlign.Left, theme);
            labelSize = nameLabel.Font.MeasureString(nameLabel.Text);
            playerField = new GUITextField(new UDim2(0, labelSize.X + 20, 0, 85),
                new UDim2(1f, -labelSize.X - 30, 0, 30), "Player", TextAlign.Left, theme);
            playerField.MaxLength = 60;

            connectBtn = new GUIButton(new UDim2(0, 10, 1f, -40), new UDim2(0, 100, 0, 30), "Connect", theme);
            connectBtn.OnMouseClick += (btn, mbtn) => { TryConnect(); };

            AddTopLevel(endPointLabel, endPointField, nameLabel, playerField, connectBtn);
        }
Example #32
0
        void TryCreateEditField(EditorObject ob, PropertyInfo prop, EditableField attr)
        {
            float y        = elements.Count * FIELD_Y_AREA;
            UDim2 position = new UDim2(0, 0, 0, y + 25);

            GUILabel label     = null;
            string   labelText = string.Format("{0}:", attr.Name);

            Type type = prop.PropertyType;

            if (type == typeof(bool))
            {
                GUICheckbox checkbox;
                form.AddLabledCheckbox(labelText, (bool)prop.GetValue(ob), position,
                                       out label, out checkbox);
                elements.Add(checkbox);

                checkbox.OnCheckChanged += (sender, e) =>
                {
                    prop.SetValue(ob, e);
                };
            }
            else if (type == typeof(string))
            {
                GUITextField field;
                form.AddLabledTextField(labelText, (string)prop.GetValue(ob), position,
                                        out label, out field);
                elements.Add(field);

                field.OnTextChanged += (sender, e) =>
                {
                    prop.SetValue(ob, e);
                };
            }

            if (label != null)
            {
                elements.Add(label);
            }
        }
    public override void Initialize(ScreenInfo parent)
    {
        // Create the space to make the left and right side menus
        // and add the generated GUIMenu objects into it.
        List<GUIObject> find = FindObjectsOfType(typeof(GUIMenu));
        if (find.Count > 0)
            lmenu = find[0] as GUIMenu;
        find = FindObjectsOfType(typeof(GUIScrollMenu));
        if (find.Count > 0)
            rmenu = find[0] as GUIScrollMenu;
		
		find = FindObjectsOfType(typeof(GUILabel));
		if (find.Count > 0)
		{
			title = find[0] as GUILabel;
        	if (interactObject != null)
        	    title.text = interactObject.prettyname;
		}
		
        find.Clear();
        Elements.Clear();
		
		GUIVerticalCommand vert = new GUIVerticalCommand();
		vert.Elements = new List<GUIObject>();
		Elements.Add(vert);
		
		if (title != null )
			vert.Elements.Add(title);
		
		GUISpace space = new GUISpace();
		space.pixels = 5;
		vert.Elements.Add(space);

        if (lmenu != null && rmenu != null)
        {
            GUIHorizontalCommand hc = new GUIHorizontalCommand();
            hc.Elements = new List<GUIObject>();
            hc.Elements.Add(lmenu);
            hc.Elements.Add(rmenu);
            vert.Elements.Add(hc);
        }
        base.Initialize(parent);

        patient = Patient.FindObjectOfType(typeof(Patient)) as Patient;

        Object[] temp = ObjectInteraction.FindObjectsOfType(typeof(ObjectInteraction));
        foreach (Object obj in temp)
        {
            if (obj == patient)
                continue;
            roomObjects.Add(obj as ObjectInteraction);
        }

        listings = new Listings();
        listings.category = "root";

        current = listings;
    }
	public void BreadcrumbInit()
	{
		if ( bcArea == null )
		{
			bcArea = Find("breadcrumbsHorizontal") as GUIHorizontalCommand;
			if ( bcArea != null )
			{
				bcLeft = Find("bracketLeft") as GUILabel;
				bcRight = Find("bracketRight") as GUILabel;
				bcItem = Find("breadcrumbs.item") as GUILabel;
			}
		}
		if ( bcArea != null )
		{
			bcArea.Elements.Clear();
			
			bcArea.Elements.Add(bcLeft);

			// loop and get category and current level
			List<string> items = new List<string>();			
			Listings temp = current;
			while ( temp != null )
			{
				if ( temp.category != null )
					items.Add(temp.category);
				temp = temp.parent;					
			}
			// add our name
			items.Add(interactObject.name);

			// now go backwards and add strings
			for (int i=items.Count - 1 ; i>=0 ; i--)
			{
				GUILabel bc;
				bc = bcItem.Clone() as GUILabel;
				if ( i != 0 )
					bc.text = items[i] + " >> ";
				else
					bc.text = items[i];
				bcArea.Elements.Add(bc);
			}
			
			bcArea.Elements.Add(bcRight);
		}
	}
    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;
        }
    }
Example #36
0
	public void SetType( string guiName, GUIEditObject.GUITypes guiType )
	{				
		// create based on type
		if ( guiType == GUITypes.Screen )
		{
			guiScreen = new GUIScreen();
			guiScreen.name = guiName;
		}
		if ( guiType == GUITypes.Area )
		{
			guiObject = new GUIArea();
			guiObject.name = guiName;
		}
		if ( guiType == GUITypes.Label )
		{
			guiObject = new GUILabel();
			guiObject.name = guiName;
		}
		if ( guiType == GUITypes.Button )
		{
			guiObject = new GUIButton();
			guiObject.name = guiName;
		}
		if ( guiType == GUITypes.Horizontal )
		{
			guiObject = new GUIHorizontalCommand();
			guiObject.name = guiName;
		}
		if ( guiType == GUITypes.Vertical )
		{
			guiObject = new GUIVerticalCommand();
			guiObject.name = guiName;
		}
		if ( guiType == GUITypes.Scrollview )
		{
			guiObject = new GUIScrollView();
			guiObject.name = guiName;
		}
		if ( guiType == GUITypes.Toggle )
		{
			guiObject = new GUIToggle();
			guiObject.name = guiName;
		}
		if ( guiType == GUITypes.Space )
		{
			guiObject = new GUISpace();
			guiObject.name = guiName;
		}
		if ( guiType == GUITypes.EditBox )
		{
			guiObject = new GUIEditbox();
			guiObject.name = guiName;
		}
		if ( guiType == GUITypes.Box )
		{
			guiObject = new GUIBox();
			guiObject.name = guiName;
		}
		if ( guiType == GUITypes.HorizontalSlider )
		{
			guiObject = new GUIHorizontalSlider();
			guiObject.name = guiName;
		}
		if ( guiType == GUITypes.VerticalSlider )
		{
			guiObject = new GUIVerticalSlider();
			guiObject.name = guiName;
		}
		if ( guiType == GUITypes.Movie )
		{
			guiObject = new GUIMovie();
			guiObject.name = guiName;
		}
	}
 public void AddActionLabel(int mapCategoryId, int actionId, AxisRange axisRange, GUILabel label) {
     list.AddActionLabel(mapCategoryId, actionId, axisRange, label);
 }
 public void SetLabel(GUILabel label) {
     this.label = label;
 }
 public void AddActionCategoryLabel(int mapCategoryId, int actionCategoryId, GUILabel label) {
     list.AddActionCategoryLabel(mapCategoryId, actionCategoryId, label);
 }
    public override void Initialize(ScreenInfo parent)
    {
        base.Initialize(parent);

		// get important areas		
		GUIArea textArea = Find("textArea") as GUIArea;
		contentArea = textArea.Find("contentArea") as GUIScrollView;
		contentText = contentArea.Find("contentText") as GUILabel;
		contentArea.Elements.Remove(contentText);
		
		// save styles
		parentStyle = _style;
		textAreaStyle = textArea.Style;
		textAreaContentStyle = contentArea.Style;		
		
		GUIArea buttonArea = Find("buttonArea") as GUIArea;
		buttonStyle = buttonArea.Style;
		
        GUIObject notice = Find("notice");
        if (notice != null)
        {
            notice.text = newMessages.ToString() + " new messages";
        }		
		maxcount = MaxMessages;
    }
            public void AddActionCategoryLabel(int mapCategoryId, int actionCategoryId, GUILabel label) {
                MapCategoryEntry entry;
                if(!entries.TryGet(mapCategoryId, out entry)) return;

                ActionCategoryEntry actionCategoryEntry = entry.GetActionCategoryEntry(actionCategoryId);
                if(actionCategoryEntry == null) return;

                actionCategoryEntry.SetLabel(label);
            }