void UpdateEditor()
 {
     if (Input.GetMouseButtonDown(0))
     {
         GUIElement element = FindGUIElement(Camera.main, Input.mousePosition);
         if (element)
         {
             if (!wasMouseDownInPrevFrame)
             {
                 wasMouseDownInPrevFrame = true;
                 element.SendMessage("OnMouseDown", null, SendMessageOptions.DontRequireReceiver);
                 prevFrameElement = element;
             }
         }
     }
     else if (wasMouseDownInPrevFrame)
     {
         if (!Input.GetMouseButton(0))
         {
             if (prevFrameElement)
             {
                 prevFrameElement.SendMessage("OnMouseUp", null, SendMessageOptions.DontRequireReceiver);
             }
             wasMouseDownInPrevFrame = false;
         }
     }
 }
示例#2
0
    protected override void Load()
    {
        base.Load();

        Skin = Resources.Load("GUI/UI Skin") as GUISkin;

        UpArrow = Resources.Load("GUI/FullUpArrow") as Texture;
        DisableArrow = Resources.Load("GUI/EmptyUpArrow") as Texture;

        TheCharacter = GameState.Instance.PlayerObject;
        this.Background = Resources.Load("GUI/PlainBackground") as Texture;

        NewImageButton(Alignments.Max, Margin, Alignments.Absolute, Margin, Resources.Load("GUI/CloseBox") as Texture, Close);
        NewLabel(Alignments.Absolute, Margin, Alignments.Absolute, Margin, 256, 32, TheCharacter.Name + ":Stats");
        XPLabel = NewLabel(Alignments.Absolute, Margin, Alignments.Absolute, 54, 256, 32, "XP:" + TheCharacter.XP.ToString());
        NewLabel(Alignments.Max, Margin * 5, Alignments.Absolute, Margin * 2.5f, 64, 32, "Skills").SetFont(Color.white, 24);

        ToolTipElement = NewImage(Alignments.Absolute, 0, Alignments.Max, 0, Resources.Load("GUI/WideToolTip") as Texture);
        ToolTipTextElement = ToolTipElement.NewLabel(Alignments.Absolute, 35, Alignments.Absolute, 15, 450, 32, "Blerg");

        ToolTipTextElement.TextStyle = new GUIStyle();
        ToolTipTextElement.TextStyle.font = Resources.Load("GUI/ALEAWBB_") as Font;
        ToolTipTextElement.TextStyle.normal.textColor = Color.white;
        ToolTipTextElement.TextStyle.fontSize = 12;

        ToolTipElement.Enabled = false;

        SetPlayerData();
    }
示例#3
0
        /// <summary>
        /// Calculates optimal size of a GUI element.
        /// </summary>
        /// <param name="element">GUI element to calculate the optimal size for.</param>
        /// <returns>Size that allows the GUI element to properly display all of its content.</returns>
        public static Vector2I CalculateOptimalSize(GUIElement element)
        {
            Vector2I output;

            Internal_CalculateOptimalSize(element.GetCachedPtr(), out output);
            return(output);
        }
        /// <summary>
        /// Handles who gets the single click event from the options provided.
        /// For use if a container is being used.
        /// </summary>
        /// <param name="clickData"></param>
        private static void Click(MouseEventArgs clickData, List <GUIElement> Options, GUIContainer container)
        {
            int        focus  = -1;
            int        length = Options.Count;
            GUIElement item   = null;

            for (int i = 0; i < length; i++)
            {
                item = Options[i];
                if (focus == -1 && item.MouseBounds.Bounds.Contains(clickData.Position.X + container.DrawingBounds.X, clickData.Position.Y - container.DrawingBounds.Y))
                {
                    item.HasFocus = true;
                    focus         = i;
                }
                else
                {
                    item.HasFocus = false;
                }
            }

            if (focus != -1)
            {
                MasterLog.DebugWriteLine("Clicking on item: " + Options[focus].GetType().FullName);
                Options[focus].Click(clickData, container);
            }
        }
 void LabelBox_KeyDown(GUIElement sender, KeyEventArgs e)
 {
     if (e.InterestingKeys.Contains<Keys>(Keys.LeftShift) ||
         e.InterestingKeys.Contains<Keys>(Keys.RightShift))
         caps = true;
     else caps = false;
 }
示例#6
0
    protected void ItemClick(object sender, EventArgs args)
    {
        GUIElement element = sender as GUIElement;

        if (element == null)
        {
            return;
        }

        GameState.Prefabs.audio.PlayOneShot(Resources.Load("Sounds/sfx_select") as AudioClip);

        int slotID = element.ID;

        Debug.Log("GUI item slot click " + slotID.ToString());

        Item item = Container.Items.GetItem(slotID);

        if (item == null)
        {
            return;
        }

        if (GameState.Instance.PlayerObject.InventoryItems.AddItem(item))
        {
            Container.Items.RemoveItem(slotID);

            Show(Container);
            GameState.Instance.GUI.UpdateInventory();
        }
        CheckEmpty();
    }
        /// <summary>
        /// Handles who gets the double click event.
        /// </summary>
        /// <param name="clickData"></param>
        private static void DoubleClick(MouseEventArgs clickData, List <GUIElement> Options, GUIContainer container)
        {
            int        focus  = -1;
            int        length = Options.Count;
            GUIElement item   = null;

            for (int i = 0; i < length; i++)
            {
                item = Options[i];
                if (focus == -1 && item.MouseBounds.Bounds.Contains(clickData.Position.X, clickData.Position.Y))
                {
                    item.HasFocus = true;
                    focus         = i;
                }
                else
                {
                    item.HasFocus = false;
                }
            }

            if (focus != -1)
            {
                Options[focus].DoubleClick(clickData, container);
            }
        }
示例#8
0
    protected void InventoryClick(object sender, EventArgs args)
    {
        GUIElement element = sender as GUIElement;

        if (element == null)
        {
            return;
        }

        GameState.Prefabs.audio.PlayOneShot(Resources.Load("Sounds/sfx_click") as AudioClip);

        int slotID = element.ID;

        Debug.Log("GUI item slot click " + slotID.ToString());

        Item item = TheCharacter.InventoryItems.GetItem(slotID);

        // GameState.Instance.GUI.SelectItem(item);

        Equipment equipment = item as Equipment;

        if (equipment != null)
        {
            TheCharacter.EquipItem(TheCharacter.InventoryItems.RemoveItem(slotID) as Equipment);
        }
        else
        {
            if (item.OnActivate(TheCharacter))
            {
                TheCharacter.InventoryItems.RemoveItem(slotID);
            }
        }

        SetInventoryItems();
    }
示例#9
0
    // Update is called once per frame
    void Update()
    {
        GUIElement element = gui.HitTest(Input.mousePosition);


        if (Input.GetMouseButtonDown(0))
        {
            if (element == null)
            {
                //if (Input.mousePosition.x >= 150 && Input.mousePosition.x <= 750) {

                if (PlaceStone())
                {
                    SpawnStone();
                    score++;
                    UpdateScore();
                    print("Click");
                }
                else
                {
                    EndGame();
                }
                //}
            }
        }
        MoveStone();
        // move stack
        transform.position = Vector3.Lerp(transform.position, desiredPosition, STACK_MOVING_SPEED * Time.deltaTime);
    }
示例#10
0
        /// <summary>
        /// Handles who gets the scroll event from the options provided.
        /// For use if a container is being used.
        /// </summary>
        private static void Scroll(MouseEventArgs scrollData, List <GUIElement> options, GuiContainer container)
        {
            int        focus  = -1;
            int        length = options.Count;
            GUIElement item   = null;

            MasterLog.DebugWriteLine("Scroll position: " + scrollData.Position.ToString());

            for (int i = 0; i < length; i++)
            {
                item = options[i];

                MasterLog.DebugWriteLine(item.GetType().ToString() + " gui bounds: " + item.MouseBounds.Bounds.ToString());

                if (focus == -1 && item.MouseBounds.Bounds.Contains(scrollData.Position.X - container.DrawingBounds.X, scrollData.Position.Y - container.DrawingBounds.Y))
                {
                    item.HasFocus = true;
                    focus         = i;
                    MasterLog.DebugWriteLine(item.GetType().ToString() + " with a bounds of " + item.MouseBounds.Bounds.ToString() + "was scrolled on");
                }
                else
                {
                    item.HasFocus = false;
                    MasterLog.DebugWriteLine(item.GetType().ToString() + " with a bounds of " + item.MouseBounds.Bounds.ToString() + "was not scrolled on");
                }
            }

            if (focus != -1)
            {
                MasterLog.DebugWriteLine("Scrolling on item: " + options[focus].GetType().FullName);
                options[focus].Scroll(scrollData, container);
            }
        }
示例#11
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            GUIElement hitObj = guiHit.HitTest(Input.mousePosition);
            if (hitObj != null)
            {
                if (hitObj.name == this.name)
                {
                    Debug.Log("Press PDN");
                    process();
                }
            }
        }

        if (Input.GetKeyDown(keyCode) && (this.transform.parent.parent.parent.transform.position.x == -3))
        {
            if (isKeyDown == false)
            {
                isKeyDown = true;
                process();
            }
        }
        else
        {
            isKeyDown = false;
        }
    }
示例#12
0
        public void DrawGUIElement(GUIElement element)
        {
            Transform t = element.Transform;
            Sprite    s = element.Sprite;

            Draw(s.Texture, t.PositionInCameraSpace, s.Source, Color.White, t.Rotation, s.SpriteCenter, t.LocalScale, SpriteEffects.None, s.RenderingOrder + 10);
        }
示例#13
0
    /// <summary>
    /// Will hide 'ele' windows and will show Main Menu Window
    /// </summary>
    /// <param name="wind"></param>
    public void HideWindowShowMain(GUIElement ele)
    {
        RedifineWindows();

        ele.Hide();
        _mainMenuWindow.Show();
    }
 private void GoToChild(GUIElement e, bool addIfComponent)
 {
     if (e is LeafElement)
     {
         var componentElement = e as LeafElement;
         componentElement.element.InvokeCallback();
         OnAnyLeafElementClicked.Invoke(componentElement.element);
     }
     else if (e is WarningElement)
     {
     }
     else if (!hasSearch)
     {
         m_LastTime = System.DateTime.Now.Ticks;
         if (m_AnimTarget == 0)
         {
             m_AnimTarget = 1;
         }
         else if (m_Anim == 1)
         {
             m_Anim = 0;
             m_Stack.Add(e as GroupElement);
         }
     }
 }
示例#15
0
    private static void TextManager_NvlSetPosition(TextManager textManager, GUIElement background, TextManager.NVLPosition position)
    {
        textManager.nvlPosition = position;
        Vector2 size = default;

        switch (position)
        {
        case TextManager.NVLPosition.Center:
        {
            size = new Vector2(14.93f, 9.52f);
            textManager.containerNVL.renderer.PositionX = 0f;
            break;
        }

        case TextManager.NVLPosition.Left:
        {
            size = new Vector2(9f, 9.52f);
            textManager.containerNVL.renderer.PositionX = -3.2f;
            break;
        }

        case TextManager.NVLPosition.Right:
        {
            size = new Vector2(9f, 9.52f);
            textManager.containerNVL.renderer.PositionX = 3.2f;
            break;
        }
        }

        textManager.containerNVL.renderer.size = size + new Vector2(4f);
        textManager.gameTextNVL.UpdateSize(size);
        background.renderer.size = size + new Vector2(0.5f);
    }
示例#16
0
        public static GUIElement AddGUIItem(string _menuName, GUIElement element, int column, int row = -1)
        {
            var menuName = _menuName.ToLowerInvariant();

            if (!RegisteredAPIButtons.ContainsKey(menuName))
            {
                RegisteredAPIButtons.Add(menuName, new List <MenuAPIEventArgs>());
            }

            string           dn   = element.Name.ToLowerInvariant();
            MenuAPIEventArgs info = RegisteredAPIButtons[menuName].Find((x) => x.Element.Name.ToLowerInvariant() == dn);

            if (info != null)
            {
                return(info.Element);
            }

            info = new MenuAPIEventArgs(new MenuButton(new RelativeRect()), menuName);

            info.Element = element;

            info.Row = row;
            info.Col = column;

            RegisteredAPIButtons[menuName].Add(info);

            ControllAdded?.Invoke(info.Element, info);

            return(info.Element);
        }
    GUIElement FindGUIElement(Camera camera, Vector3 mousePosition)
    {
        //	JCsProfilerMethod pm = JCsProfiler.Instance.StartCallStopWatch(gameObject.name, gameObject.name, "FindGUIElement");
        // Is the mouse inside the cameras viewport?
        Rect rect = camera.pixelRect;

        if (!rect.Contains(mousePosition))
        {
            return(null);
        }

        // Did we hit any gui elements?
        GUILayer layer = (GUILayer)camera.GetComponent(typeof(GUILayer));

        if (!layer)
        {
            return(null);
        }

        GUIElement res = layer.HitTest(mousePosition);

        //	pm.CallIsFinished();

        return(res);
    }
示例#18
0
        public LoadMenu(ScreenManager screenManager, Renderer parent) : base(screenManager, parent)
        {
            background = GUIElement.CreateImage(screenContainer.renderer, new Vector3(0f, 0f, 0f), new Vector2(19.2f, 10.8f), "GUI/ConfigureScreen/BackSett");

            var label = GUIElement.CreateEmpty(screenContainer.renderer, new Vector3(0f, 4.5f, -2f), new Vector2(10f, 1.08f));

            label.renderer.name = "Label";
            {
                var textBox = label.Entity.CreateComponent <TextBox>(name);
                textBox.InitFromRenderer();
                textBox.CharHeight = 0.45f;
                textBox.FontName   = "Furore";
                textBox.Text       = "Загрузить";
                textBox.Align      = ODEngine.Core.Text.TextAlign.Center;
            }

            var buttonCancel = GUIElement.CreateContainer(screenContainer.renderer, new Vector3(0f, -4f, -2f), new Vector2(3f, 0.56f), "Game/Color");

            {
                buttonCancel.renderer.name = "Cancel";
                ODEngine.Helpers.GUIHelper.TextButton(buttonCancel, new Vector3(0f, 0.02f, 0f), "Furore", 0.4f, "Вернуться", new Color4(160, 185, 198, 255), Color4.White);
                buttonCancel.MouseClick += ButtonCancel_MouseClick;
            }

            screenContainer.renderer.isVisible = false;
        }
示例#19
0
    private void HideMainMakeWindActive(GUIElement window)
    {
        RedifineWindows();

        _mainMenuWindow.Hide();
        window.Show();
    }
示例#20
0
文件: GUILayout.cs 项目: nanze81/bsf
 /// <summary>
 /// Adds a new element to the layout after all existing elements.
 /// </summary>
 /// <param name="element">GUI element to add.</param>
 public void AddElement(GUIElement element)
 {
     if (element != null)
     {
         Internal_AddElement(mCachedPtr, element.mCachedPtr);
     }
 }
示例#21
0
        /// <summary>
        /// Handles who gets the double click event.
        /// </summary>
        /// <param name="clickData"></param>
        private static void DoubleClick(MouseEventArgs clickData, List <GUIElement> Options, GuiContainer container)
        {
            int        focus  = -1;
            int        length = Options.Count;
            GUIElement item   = null;

            MasterLog.DebugWriteLine("Double click position: " + clickData.Position.ToString());

            for (int i = 0; i < length; i++)
            {
                item = Options[i];

                MasterLog.DebugWriteLine(item.GetType().ToString() + " gui bounds: " + item.MouseBounds.Bounds.ToString());

                if (focus == -1 && item.MouseBounds.Bounds.Contains(clickData.Position.X, clickData.Position.Y))
                {
                    item.HasFocus = true;
                    focus         = i;
                    MasterLog.DebugWriteLine(item.GetType().ToString() + " with a bounds of " + item.MouseBounds.Bounds.ToString() + "was double clicked on");
                }
                else
                {
                    item.HasFocus = false;
                    MasterLog.DebugWriteLine(item.GetType().ToString() + " with a bounds of " + item.MouseBounds.Bounds.ToString() + "was not double clicked on");
                }
            }

            if (focus != -1)
            {
                Options[focus].DoubleClick(clickData, container);
            }
        }
示例#22
0
        //Other methods

        void ExitGame(GUIElement element)
        {
            //Lab 11-2
            currentScene = scenes["Play"];
            // *************
            background = (background == Color.White ? Color.Blue : Color.White);
        }
示例#23
0
    protected override void Load()
    {
        base.Load();

        Skin = Resources.Load("GUI/UI Skin") as GUISkin;

        UpArrow      = Resources.Load("GUI/FullUpArrow") as Texture;
        DisableArrow = Resources.Load("GUI/EmptyUpArrow") as Texture;

        TheCharacter    = GameState.Instance.PlayerObject;
        this.Background = Resources.Load("GUI/PlainBackground") as Texture;

        NewImageButton(Alignments.Max, Margin, Alignments.Absolute, Margin, Resources.Load("GUI/CloseBox") as Texture, Close);
        NewLabel(Alignments.Absolute, Margin, Alignments.Absolute, Margin, 256, 32, TheCharacter.Name + ":Stats");
        XPLabel = NewLabel(Alignments.Absolute, Margin, Alignments.Absolute, 54, 256, 32, "XP:" + TheCharacter.XP.ToString());
        NewLabel(Alignments.Max, Margin * 5, Alignments.Absolute, Margin * 2.5f, 64, 32, "Skills").SetFont(Color.white, 24);

        ToolTipElement     = NewImage(Alignments.Absolute, 0, Alignments.Max, 0, Resources.Load("GUI/WideToolTip") as Texture);
        ToolTipTextElement = ToolTipElement.NewLabel(Alignments.Absolute, 35, Alignments.Absolute, 15, 450, 32, "Blerg");

        ToolTipTextElement.TextStyle                  = new GUIStyle();
        ToolTipTextElement.TextStyle.font             = Resources.Load("GUI/ALEAWBB_") as Font;
        ToolTipTextElement.TextStyle.normal.textColor = Color.white;
        ToolTipTextElement.TextStyle.fontSize         = 12;

        ToolTipElement.Enabled = false;

        SetPlayerData();
    }
示例#24
0
        /// <summary>
        /// Handles who gets the single click event from the options provided.
        /// </summary>
        /// <param name="clickData"></param>
        private static bool Click(MouseEventArgs clickData, List <GUIElement> Options)
        {
            int        focus  = -1;
            int        length = Options.Count;
            GUIElement item   = null;

            for (int i = 0; i < length; i++)
            {
                item = Options[i];
                if (focus == -1 && item.MouseBounds.Bounds.Contains(clickData.Position.X, clickData.Position.Y))
                {
                    item.HasFocus = true;
                    focus         = i;
                }
                else
                {
                    item.HasFocus = false;
                }
            }

            if (focus != -1)
            {
                Options[focus].Click(clickData);
                return(true);
            }
            else
            {
                return(false);
            }
        }
    // Update is called once per frame
    void Update()
    {
        //	JCsProfilerMethod pm = JCsProfiler.Instance.StartCallStopWatch(gameObject.name, gameObject.name, "Update");

        if (OptionsDialog.instance != null)
        {
            if (OptionsDialog.isActive)
            {
                return;
            }
        }

        for (int i = 0; i < MAXTOUCHES; i++)
        {
            currentTouchStates[i] = false;
        }

        foreach (iPhoneTouch touchInfo in iPhoneInput.touches)
        {
            currentTouchStates[touchInfo.fingerId] = true;
        }

        for (int i = 0; i < MAXTOUCHES; i++)
        {
            if (prevTouchStates[i] == false && currentTouchStates[i] == true)
            {
                // touch on
                GUIElement element = FindGUIElement(Camera.main, iPhoneInput.touches[i].position);
                if (element)
                {
                    prevFrameElements[i] = element;
                    element.SendMessage("OnMouseDown", null, SendMessageOptions.DontRequireReceiver);
                }
            }

            else if (prevTouchStates[i] == true && currentTouchStates[i] == false)
            {
                // touch off
                if (prevFrameElements[i] != null)
                {
                    prevFrameElements[i].SendMessage("OnMouseUp", null, SendMessageOptions.DontRequireReceiver);
                    prevFrameElements[i] = null;
                }
            }
        }

        for (int i = 0; i < MAXTOUCHES; i++)
        {
            prevTouchStates[i] = currentTouchStates[i];
        }

        //	pm.CallIsFinished();
        if (Application.isEditor)
        {
            UpdateEditor();
        }
    }
 private void Add(GUIElement element)
 {
     if (null == element)
     {
         return;
     }
     m_InternalElements.Add(element);
     m_Rebuild = true;
 }
示例#27
0
        //private WaveOutEvent menuMusic;

        public SettingsScreen(ScreenManager screenManager, Renderer parent) : base(screenManager, parent)
        {
            screenContainer.renderer.name      = "ConfigurationRenderer";
            screenContainer.renderer.isVisible = false;
            GUIElement.CreateImage(screenContainer.renderer, Vector3.Zero, parent.size, "GUI/ConfigureScreen/BackSett");

            CreateButtons();
            CreateTextBoxes();
        }
示例#28
0
        void DoHitTest()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);

            if (go == null)
            {
                return;
            }

            // cache GUIElement component

            if (go != gameObjectCached)
            {
                guiElement = go.guiTexture ?? (GUIElement)go.guiText;

                gameObjectCached = go;
            }

            if (guiElement == null)
            {
                Finish();
                return;
            }

            // get screen point to test

            var testPoint = screenPoint.IsNone ? new Vector3(0, 0) : screenPoint.Value;

            if (!screenX.IsNone)
            {
                testPoint.x = screenX.Value;
            }

            if (!screenY.IsNone)
            {
                testPoint.y = screenY.Value;
            }

            if (normalized.Value)
            {
                testPoint.x *= Screen.width;
                testPoint.y *= Screen.height;
            }

            // perform hit test

            if (guiElement.HitTest(testPoint, camera))
            {
                storeResult.Value = true;
                Fsm.Event(hitEvent);
            }
            else
            {
                storeResult.Value = false;
            }
        }
示例#29
0
        /// <summary>
        /// Calculates the bounds of a GUI element. This is similar to <see cref="GUIElement.Bounds"/> but allows you to
        /// returns bounds relative to a specific parent GUI panel.
        /// </summary>
        /// <param name="element">Elements to calculate the bounds for.</param>
        /// <param name="relativeTo">GUI panel the bounds will be relative to. If this is null or the provided panel is not
        ///                          a parent of the provided GUI element, the returned bounds will be relative to the 
        ///                          first GUI panel parent instead.</param>
        /// <returns>Bounds of a GUI element relative to the provided GUI panel.</returns>
        public static Rect2I CalculateBounds(GUIElement element, GUIPanel relativeTo = null)
        {
            IntPtr relativeToNative = IntPtr.Zero;
            if (relativeTo != null)
                relativeToNative = relativeTo.GetCachedPtr();

            Rect2I output;
            Internal_CalculateBounds(element.GetCachedPtr(), relativeToNative, out output);
            return output;
        }
 void TextButton_MouseEnter(GUIElement sender, MouseEventArgs e)
 {
     ForeColor = MouseOnColor;
     if (!DeselectsAtLostControl)
     {
         if (Parent is Frame)
             ((Frame)Parent).LoseControl += new FrameEventHandler(TextButton_LoseControl);
         DeselectsAtLostControl = true;
     }
 }
示例#31
0
    static int HitTest(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        GUILayer   obj  = (GUILayer)LuaScriptMgr.GetUnityObjectSelf(L, 1, "GUILayer");
        Vector3    arg0 = LuaScriptMgr.GetVector3(L, 2);
        GUIElement o    = obj.HitTest(arg0);

        LuaScriptMgr.Push(L, o);
        return(1);
    }
示例#32
0
    protected override void Load()
    {
        base.Load();

        SelectedName = NewLabel(Alignments.Absolute, 2, Alignments.Absolute, 2, Bounds.width - 66, 62, string.Empty);

        SelectedImage = NewImage(Alignments.Max, 2, Alignments.Absolute, 2, Resources.Load("GUI/CreatureSelectionIcon") as Texture);

        SelectedInfo = NewLabel(Alignments.Absolute, 2, Alignments.Max, 2, Bounds.width - 4, 32, string.Empty);
    }
示例#33
0
        private void CreateButtonBack()
        {
            var nsr = GPUTextureLoader.LoadAsync("Images/" + "GUI/ConfigureScreen/Buttons/little_notarget" + ".png");

            buttonBack = GUIElement.CreateContainer(screenContainer.renderer, new Vector3(0f, -4f, -1f), new Vector2(6f, 0.6f), "Game/Color");
            GUIHelper.TextButton(buttonBack, new Vector3(0f, 0.02f, 0f), "Furore", 0.45f, "Назад", new Color4(160, 185, 198, 255), Color4.White);
            buttonBack.MouseClick += ButtonBack_MouseClick;

            GUIElement.CreateImage(screenContainer.renderer, buttonBack.renderer.Position + new Vector3(0f, 0.03f, 0.5f), buttonBack.renderer.size, "GUI/ConfigureScreen/desk");
        }
示例#34
0
        static void createToolBox()
        {
            GUIEnvironment env  = device.GUIEnvironment;
            GUIElement     root = env.RootElement;

            // remove tool box if already there
            GUIElement e = root.GetElementFromID((int)guiID.DialogRootWindow, true);

            if (e != null)
            {
                e.Remove();
            }

            // create the toolbox window
            GUIWindow w = env.AddWindow(new Recti(600, 45, 800, 480), false, "Toolset", null, (int)guiID.DialogRootWindow);

            // create tab control and tabs
            GUITabControl tab = env.AddTabControl(new Recti(2, 20, 800 - 602, 480 - 7), w, -1, true, true);

            GUITab t1 = tab.AddTab("Config");

            // add some edit boxes and a button to tab one
            env.AddStaticText("Scale:", new Recti(10, 20, 60, 45), false, false, t1);
            env.AddStaticText("X:", new Recti(22, 48, 40, 66), false, false, t1);
            env.AddEditBox("1.0", new Recti(40, 46, 130, 66), true, t1, (int)guiID.XScale);
            env.AddStaticText("Y:", new Recti(22, 78, 40, 96), false, false, t1);
            env.AddEditBox("1.0", new Recti(40, 76, 130, 96), true, t1, (int)guiID.YScale);
            env.AddStaticText("Z:", new Recti(22, 108, 40, 126), false, false, t1);
            env.AddEditBox("1.0", new Recti(40, 106, 130, 126), true, t1, (int)guiID.ZScale);

            env.AddButton(new Recti(10, 134, 85, 165), t1, (int)guiID.ButtonSetScale, "Set");

            // quick scale buttons
            env.AddButton(new Recti(65, 20, 95, 40), t1, (int)guiID.ButtonScaleMul10, "* 10");
            env.AddButton(new Recti(100, 20, 130, 40), t1, (int)guiID.ButtonScaleDiv10, "* 0.1");

            updateScaleInfo(model);

            // add transparency control
            env.AddStaticText("GUI Transparency Control:", new Recti(10, 200, 150, 225), true, false, t1);
            GUIScrollBar b = env.AddScrollBar(true, new Recti(10, 225, 150, 240), t1, (int)guiID.SkinTransparency);

            b.MaxValue = 255;
            b.Position = 255;

            // add framerate control
            env.AddStaticText("Framerate:", new Recti(10, 240, 150, 265), true, false, t1);
            b          = env.AddScrollBar(true, new Recti(10, 265, 150, 280), t1, (int)guiID.SkinAnimationFPS);
            b.MaxValue = MaxFramerate;
            b.MinValue = -MaxFramerate;
            b.Position = DefaultFramerate;

            // bring irrlicht engine logo to front, because it now may be below the newly created toolbox
            root.BringToFront(root.GetElementFromID((int)guiID.Logo, true));
        }
示例#35
0
        /// <summary>
        /// Creates a new AttackElement for the given parameters.
        /// </summary>
        /// <param name="game">The current Game object.</param>
        /// <param name="attack">The Attack instance to visualize.</param>
        /// <param name="x">The top-left x-coordinate to start the attack box.</param>
        /// <param name="y">The top-left y-coordinate to start the attack box.</param>
        /// <param name="width">The width of the AttackElement.</param>
        /// <param name="height">The height of the AttackElement.</param>
        public AttackElement(Game game, Attack attack, int x, int y, int width, int height)
            : base(game, "attack", x, y, width, height)
        {
            this.attack = attack;

            AddChild(new DicesElement(game, attack.DiceForAttack.ToArray(), Bound.X + (int)(Bound.Width * 0.4), Bound.Y, (int)(Bound.Width * 0.6), Bound.Height / 2));

            List<SurgeAbility> surges = attack.SurgeAbilities;

            int yPos = Bound.Y + Bound.Height / 2;
            int xPos = Bound.X + (int)(Bound.Width * 0.4);
            int surgeHeight = 50;
            int surgeWidth = (int)(Bound.Width * 0.3);
            bool left = true;

            // Surge abilities
            SurgeAbility surge;
            for (int i = 0; i < surges.Count; i++)
            {
                int id = i;
                surge = surges[i];
                GUIElement surgeBox = new GUIElement(game, "surge box", left ? xPos : xPos + surgeWidth, yPos, surgeWidth, surgeHeight);
                surgeBox.SetBackground("boxbg");

                GUIElementFactory.DrawSurgeAbility(surgeBox, surge, 5, 10, false);

                // click event
                surgeBox.SetClickAction(surgeBox.Name, (n, g) =>
                {
                    n.EventManager.QueueEvent(EventType.SurgeAbilityClicked, new SurgeAbilityEventArgs(id));
                });

                AddChild(surgeBox);

                // ready for next ability
                if (!left) yPos += height;
                left = !left;
            }

            // target monster (if any)
            Square square = FullModel.Board[attack.TargetSquare.X, attack.TargetSquare.Y];
            if (square.Figure != null && square.Figure is Monster)
            {
                GUIElement target = new MonsterSummary(game, Bound.X + (int)((Bound.Width * 0.4 - 125) / 2), Bound.Y + Bound.Height / 2 + (int)((Bound.Height / 2 - 175) / 2), (Monster)square.Figure);
                AddChild(target);
            }// target hero
            else if (square.Figure != null && square.Figure is Hero)
            {
                Image picture = new Image(((Hero)square.Figure).Texture);
                AddDrawable(Name, picture, new Vector2(Bound.X + (int)((Bound.Width * 0.4 - picture.Texture.Width) / 2),
                                                       Bound.Y + Bound.Height / 2 + (int)((Bound.Height / 2 - picture.Texture.Height) / 2)));
            }
        }
示例#36
0
    protected override void Load()
    {
        NewImage(GUIPanel.Alignments.Center, 0, GUIPanel.Alignments.Absolute, 0, Logo);

        NewImageButton(GUIPanel.Alignments.Center, 0, GUIPanel.Alignments.Absolute, Logo.height, NewGame, GoToMenu);

        float offset = Logo.height;

        DeadMessage = NewLabel(GUIPanel.Alignments.Center, 275, GUIPanel.Alignments.Absolute, offset + Continue.height, Logo.width, 64, "Congratulations, you have died!");
        DeadMessage.Enabled = false;
        DeadMessage.SetFont(Color.white, 32);

        ContinueButton = NewImageButton(GUIPanel.Alignments.Center, 0, GUIPanel.Alignments.Absolute, offset + Continue.height, Continue, ContinueClick);
        if (Application.platform != RuntimePlatform.OSXWebPlayer && Application.platform != RuntimePlatform.WindowsWebPlayer)
            NewImageButton(GUIPanel.Alignments.Center, 0, GUIPanel.Alignments.Absolute, offset + 2 * Exit.height, Exit, ExitClick);
    }
 void LabelBox_KeyUp(GUIElement sender, KeyEventArgs e)
 {
     if (e.InterestingKeys.Contains(Keys.Back) && this.Text != String.Empty)
             Text = Text.Remove(this.Text.Length - 1);
     else if (e.InterestingKeys[0] == Keys.Space)
         this.Text += " ";
     else if (textKeys.Contains(e.InterestingKeys[0]) && this.Text.Length < MaxLength)
         this.Text += caps ?
             e.InterestingKeys[0].ToString() :
             e.InterestingKeys[0].ToString().ToLower();
     else if (numKeys.Contains(e.InterestingKeys[0]))
     {
         string tempText = e.InterestingKeys[0].ToString();
         this.Text += tempText.Remove(0, tempText.Length -1 );
     }
 }
示例#38
0
        /// <summary>
        /// Creates a new OverlordCardElement to display information about
        /// the given OverlordCard starting from the given position.
        /// </summary>
        /// <param name="game">The current Game object.</param>
        /// <param name="x">The top-left x-coordinate of the hidden mode.</param>
        /// <param name="y">The top-left y-coordinate of the hidden mode.</param>
        /// <param name="card">The OverlordCard to display information for.</param>
        public OverlordCardElement(Game game, int x, int y, OverlordCard card)
            : base(game, "overlord card", x, y, 200, 300)
        {
            if (Font == null) Font = game.Content.Load<SpriteFont>("fontSmall");

            SetBackground("Images/Other/overlordcard");

            // header
            GUIElement header = new GUIElement(game, "overlord header", Bound.X + 48, Bound.Y + 15, 200 - 48 * 2, 100);
            header.AddText(header.Name, card.Name, new Vector2(0, 0));
            header.SetDrawBackground(false);
            header.SetFont(Font);
            AddChild(header);

            // description
            GUIElement description = new GUIElement(game, "overlord desc", Bound.X + 35, Bound.Y + 80, 150, 160);
            description.AddText(description.Name, card.Decription, new Vector2(0, 0));
            description.SetDrawBackground(false);
            description.SetFont(Font);
            AddChild(description);

            // use area
            GUIElement use = new GUIElement(game, "use overlord card", Bound.X + 10, Bound.Y + 250, 50, 40);
            use.SetDrawBackground(false);
            use.SetClickAction(use.Name, (n, g) =>
                                             {
                                                 n.EventManager.QueueEvent(EventType.UseOverlordCard, new OverlordCardEventArgs(card.Id));
                                             });

            string playPrice = "" + card.PlayPrice;
            Vector2 playDisp = GUI.Font.MeasureString(playPrice);
            use.AddText(use.Name, playPrice, new Vector2((use.Bound.Width - playDisp.X) / 2, (use.Bound.Height - playDisp.Y) / 2));
            AddChild(use);

            // sell area
            GUIElement sell = new GUIElement(game, "sell overlord card", Bound.X + 140, Bound.Y + 250, 50, 40);
            sell.SetDrawBackground(false);
            sell.SetClickAction(sell.Name, (n, g) =>
                                               {
                                                   n.EventManager.QueueEvent(EventType.RemoveOverlordCard, new OverlordCardEventArgs(card.Id));
                                               });

            string sellPrice = "" + card.SellPrice;
            Vector2 sellDisp = GUI.Font.MeasureString(sellPrice);
            sell.AddText(sell.Name, sellPrice, new Vector2((sell.Bound.Width - sellDisp.X) / 2, (sell.Bound.Height - sellDisp.Y) / 2));
            AddChild(sell);
        }
示例#39
0
        public ExperienceBar(GUIEnvironment guienv, Recti rectangle, int id = -1, GUIElement parent = null)
            : base(GUIElementType.Unknown, guienv, parent, rectangle)
        {
            xWidth = rectangle.LowerRightCorner.X - rectangle.UpperLeftCorner.X;
            gui = guienv;
            if (Parent != null)
            { bar = new Recti(Parent.RelativePosition.UpperLeftCorner + rectangle.UpperLeftCorner, Parent.RelativePosition.UpperLeftCorner + rectangle.LowerRightCorner); }
            else { bar = rectangle; }

            if (parent != null)
                gui.RootElement.AddChild(this);
            videoDriver = gui.VideoDriver;
            fillcolor = Color.OpaqueGreen;
            emptycolor = Color.OpaqueRed;
            bordercolor = Color.OpaqueBlack;
            border = bar;
            toFill = new Recti();
            empty = new Recti();
            SetProgress(0);
        }
示例#40
0
    public LootScreen()
    {
        Enabled = false;

        Background = Resources.Load("GUI/LootPanel") as Texture;

        Bounds = new Rect(25, 256, 256, 256);
        HAlignement = Alignments.Max;
        VAlignement = Alignments.Max;

        NewImageButton(Alignments.Max, 8, Alignments.Absolute, 8, Resources.Load("GUI/CloseBox") as Texture, Close);

        NameLabel = NewLabel(Alignments.Absolute, 8, Alignments.Absolute, 2, Bounds.width - 24, 32, string.Empty);
        GoldButton = NewButton(Alignments.Absolute, 86, Alignments.Absolute, 49, 100, 24, string.Empty, GoldClick);

        // inventory
        float leftBuffer = 11;
        float yStart = 93;
        float ybuffer = 13;
        float xBuffer = 12;

        float boxSize = 70;

        int id = 0;
        for (int r = 0; r < 2; r++)
        {
            for (int i = 0; i < 3; i++)
            {
                // int id = i + (r*6);

                float x = leftBuffer + (i * (boxSize + xBuffer));
                float y = yStart + (r * (ybuffer + boxSize));
                GUIElement element = NewImageButton(Alignments.Absolute, x, Alignments.Absolute, y, boxSize, boxSize, null, ItemClick);
                element.ID = id;
                element.Tag = null;
                id++;
                Items.Add(element);
            }
        }
    }
示例#41
0
    protected override void Load()
    {
        base.Load();
        TheCharacter = GameState.Instance.PlayerObject;

        HeaderBar = this.NewImage(Alignments.Absolute, 0, Alignments.Absolute, 0, Resources.Load("GUI/PlayerNameOval") as Texture);

        HeaderBar.NewLabel(Alignments.Absolute, 32, Alignments.Absolute, 16, 256-64,64-32,TheCharacter.Name);

        StatsFrame = this.NewImage(Alignments.Absolute, 32, Alignments.Absolute, 60, Resources.Load("GUI/StatusBarBackgrounds") as Texture);
        StatsFrame.Name = "status Frame";

        HealthBar = StatsFrame.NewImage(Alignments.Absolute, 25, Alignments.Absolute, 6, Resources.Load("GUI/HealthStatusFill") as Texture);
        HealthBar.Name = "Health bar";

        ManaBar = StatsFrame.NewImage(Alignments.Absolute, 24, Alignments.Absolute, 26, Resources.Load("GUI/MagicStatusFill") as Texture);
        ManaBar.Name = "Mana bar";

        XPDisplay = NewLabel(Alignments.Absolute, 32, Alignments.Max, 0, 204,30,"XP:0");

        SetHealth(TheCharacter.GetHealthParam());
        SetMana(TheCharacter.GetManaParam());
    }
示例#42
0
    public GUIElement NewImage(GUIPanel.Alignments hAlign, float x, GUIPanel.Alignments vAlign, float y, float width, float height, Texture image)
    {
        GUIElement element = new GUIElement();

        element.HAlignement = hAlign;
        element.VAlignement = vAlign;
        element.Bounds = new Rect(x, y, width, height);
        element.BackgroundImage = image;
        element.ElementType = GUIElement.ElementTypes.Image;

        Children.Add(element);
        return element;
    }
 void TextButton_MouseExit(GUIElement sender, MouseEventArgs e)
 {
     ForeColor = MouseOffColor;
 }
示例#44
0
    public GUIElement NewImageButton(GUIPanel.Alignments hAlign, float x, GUIPanel.Alignments vAlign, float y, float width, float height, Texture image, EventHandler handler)
    {
        GUIElement element = new GUIElement();

        element.HAlignement = hAlign;
        element.VAlignement = vAlign;
        element.Bounds = new Rect(x, y, width, height);
        element.BackgroundImage = image;
        element.ElementType = GUIElement.ElementTypes.Button;

        element.Clicked += handler;

        Children.Add(element);
        return element;
    }
示例#45
0
    public GUIElement NewButton(Alignments hAlign, float x, Alignments vAlign, float y, float width, float height, string text, EventHandler handler)
    {
        GUIElement element = new GUIElement();

        element.HAlignement = hAlign;
        element.VAlignement = vAlign;
        element.Bounds = new Rect(x, y, width, height);
        element.Name = text;
        element.ElementType = GUIElement.ElementTypes.Button;

        element.Clicked += handler;

        Elements.Add(element);
        return element;
    }
示例#46
0
    protected override void Load()
    {
        base.Load();

        SelectedName = NewLabel(Alignments.Absolute, 2, Alignments.Absolute, 2, Bounds.width - 66, 62, string.Empty);

        SelectedImage = NewImage(Alignments.Max, 2, Alignments.Absolute, 2, Resources.Load("GUI/CreatureSelectionIcon") as Texture);

        SelectedInfo = NewLabel(Alignments.Absolute, 2, Alignments.Max, 2, Bounds.width - 4, 32, string.Empty);
    }
示例#47
0
		private static bool INTERNAL_CALL_HitTest(GUIElement self, ref Vector3 screenPosition, Camera camera){}
示例#48
0
        /// <summary>
        /// Inserts a GUI element before the element at the specified index.
        /// </summary>
        /// <param name="index">Index to insert the GUI element at. This must be in range [0, GetNumChildren()).</param>
        /// <param name="element">GUI element to insert.</param>
        public void InsertElement(int index, GUIElement element)
        {
            if(index < 0 || index > ChildCount)
                throw new ArgumentOutOfRangeException("index", index, "Index out of range.");

            if (element != null)
                Internal_InsertElement(mCachedPtr, index, element.mCachedPtr);
        }
示例#49
0
    public GUIElement NewImageButton(Alignments hAlign, float x, Alignments vAlign, float y, Texture image, EventHandler handler)
    {
        GUIElement element = new GUIElement();

        element.HAlignement = hAlign;
        element.VAlignement = vAlign;
        element.Bounds = new Rect(x, y, image.width, image.height);
        element.BackgroundImage = image;
        element.ElementType = GUIElement.ElementTypes.Button;

        element.Clicked += handler;

        Elements.Add(element);
        return element;
    }
示例#50
0
    public GUIElement NewLabel(Alignments hAlign, float x, Alignments vAlign, float y, float width, float height, string text)
    {
        GUIElement element = new GUIElement();

        element.HAlignement = hAlign;
        element.VAlignement = vAlign;
        element.Bounds = new Rect(x, y, width, height);
        element.Name = text;
        element.ElementType = GUIElement.ElementTypes.Label;

        Elements.Add(element);
        return element;
    }
示例#51
0
    public GUIElement NewScrollView(Alignments hAlign, float x, Alignments vAlign, float y, float width, float height, Rect innerSize, bool horizontal)
    {
        GUIElement element = new GUIElement();

        element.HAlignement = hAlign;
        element.VAlignement = vAlign;
        element.Bounds = new Rect(x, y, width, height);
        element.ElementType = horizontal ? GUIElement.ElementTypes.HorizontalScrollFrame : GUIElement.ElementTypes.VerticalScrollFrame;
        element.InnerSize = innerSize;
        Elements.Add(element);
        return element;
    }
 /// <summary>
 /// Adds a GUI element to the field layout.
 /// </summary>
 /// <param name="index">Index into the GUI layout at which the field layout start at.</param>
 /// <param name="element">GUI element to insert into the layout.</param>
 public void AddElement(int index, GUIElement element)
 {
     parentLayout.InsertElement(index + elements.Count, element);
     elements.Add(element);
 }
示例#53
0
 void Start()
 {
     //brak kursora
     Screen.showCursor = !OwnCursor;
     layer = Camera.main.GetComponent<GUIElement>();
 }
示例#54
0
 void ListBox_MouseDown(GUIElement sender, MouseEventArgs e)
 {
     SelectedItem = (int)((e.CurrentMouseState.Y - this.Location.Y) / _cellHeight);
 }
示例#55
0
    public GUIElement NewFrame(Alignments hAlign, float x, Alignments vAlign, float y, float width, float height)
    {
        GUIElement element = new GUIElement();

        element.HAlignement = hAlign;
        element.VAlignement = vAlign;
        element.Bounds = new Rect(x, y, width, height);
        element.ElementType = GUIElement.ElementTypes.Frame;
        Elements.Add(element);
        return element;
    }
示例#56
0
    protected void SetElementImage(GUIElement element, Item item)
    {
        if (item == null || item.InventoryIcon == null)
            element.BackgroundImage = null;
        else
            element.BackgroundImage = item.InventoryIcon;

        element.Tag = item;
    }
 void Awake()
 {
     guiElement = GetComponent<GUIElement>();
 }
示例#58
0
 protected void Awake()
 {
     element = GetComponent<GUIElement>();
 }
示例#59
0
 /// <summary>
 /// Adds a new element to the layout after all existing elements.
 /// </summary>
 /// <param name="element">GUI element to add.</param>
 public void AddElement(GUIElement element)
 {
     if(element != null)
         Internal_AddElement(mCachedPtr, element.mCachedPtr);
 }
示例#60
0
    public GUIElement NewImage(Alignments hAlign, float x, Alignments vAlign, float y, Texture image)
    {
        GUIElement element = new GUIElement();

        element.HAlignement = hAlign;
        element.VAlignement = vAlign;
        element.Bounds = new Rect(x, y, image.width, image.height);
        element.BackgroundImage = image;
        element.ElementType = GUIElement.ElementTypes.Image;

        Elements.Add(element);
        return element;
    }