コード例 #1
0
        public Vector2 GetPosition(IGuiElement element)
        {
            if (!(element is IGuiFrame && element.Parent is ITopLevel))
            {
                throw new ArgumentException("MainFrameSizePosition only works with IGuiFrames that are children of ITopLevels.");
            }

            Vector2 result = Vector2.zero;

            ITopLevel parent = (ITopLevel)element.Parent;

            if (parent.Style != null)
            {
                result.x = parent.Style.InternalMargins.Left;
                result.y = parent.Style.InternalMargins.Top;
            }

            if (parent is Window)
            {
                Window parentWindow = (Window)parent;
                if (parentWindow.HeaderFrame.Key != null)
                {
                    result.y += parentWindow.HeaderFrame.Key.ExternalSize.y;
                    if (parent.Style != null)
                    {
                        result.y += parent.Style.InternalMargins.Top + parent.Style.InternalMargins.Bottom;
                    }
                }
            }

            return(result);
        }
コード例 #2
0
    private void SetupOpenWindowsList(ITopLevel topLevel)
    {
        mOpenWindowsList = topLevel;
        ((Window)mOpenWindowsList).InFront = true;
        mWindowListFrame = mOpenWindowsList.SelectSingleElement <IGuiFrame>("MainFrame/WindowList");
        Button hideShowButton = mOpenWindowsList.SelectSingleElement <Button>("MainFrame/HideShowButton");

        hideShowButton.AddOnPressedAction(delegate()
        {
            Vector2 currentPosition = mManager.GetTopLevelPosition(mOpenWindowsList).GetPosition(mOpenWindowsList);
            float shiftAmount       = mWindowListFrame.ExternalSize.x - (hideShowButton.ExternalSize.x * 0.5f);
            if (!mOpenWindowsListShowing)
            {
                shiftAmount *= -1.0f;
            }

            mManager.SetTopLevelPosition
            (
                mOpenWindowsList,
                new FixedPosition
                (
                    currentPosition - new Vector2(shiftAmount, 0.0f)
                )
            );

            mOpenWindowsListShowing = !mOpenWindowsListShowing;
        });

        mWindowListingPrototype = mWindowListFrame.SelectSingleElement <Button>("WindowListingPrototype");
        mWindowListFrame.RemoveChildWidget(mWindowListingPrototype);
    }
コード例 #3
0
        public Vector2 GetSize(IGuiElement element)
        {
            if (element.Parent == null)
            {
                throw new ArgumentException("MainFrameSizePosition does not work with null parents.");
            }
            if (!(element is IGuiFrame))
            {
                throw new ArgumentException("MainFrameSizePosition only works with IGuiFrames.");
            }
            if (!(element.Parent is ITopLevel))
            {
                throw new ArgumentException("MainFrameSizePosition only works with ITopLevels. (" + element.Parent.Name + ")");
            }

            ITopLevel parent = (ITopLevel)element.Parent;
            Vector2   result = parent.InternalSize;

            if (parent is Window)
            {
                Window parentWindow = (Window)parent;
                if (parentWindow.HeaderFrame.Key != null)
                {
                    result.y -= parentWindow.HeaderFrame.Key.ExternalSize.y;
                    if (parent.Style != null)
                    {
                        result.y -= parent.Style.InternalMargins.Top + parent.Style.InternalMargins.Bottom;
                    }
                }
            }

            return(result);
        }
コード例 #4
0
    private void SetupLoadedGuiWindowList()
    {
        mWindowListFrame.ClearChildWidgets();
        float nextButtonPosition = 0.0f;

        foreach (ITopLevel topLevel in mLoadedGuis)
        {
            Button windowListing = (Button)mWindowListingPrototype.Clone();
            windowListing.Text = topLevel.Name;
            mWindowListFrame.AddChildWidget(windowListing, new FixedPosition(4.0f, nextButtonPosition));
            nextButtonPosition += windowListing.ExternalSize.y + 2.0f;

            ITopLevel closureTopLevel = topLevel;
            windowListing.AddOnPressedAction(delegate()
            {
                closureTopLevel.Showing = !closureTopLevel.Showing;
                if (!closureTopLevel.Showing && !mHiddenWindows.Contains(closureTopLevel.Name))
                {
                    mHiddenWindows.Add(closureTopLevel.Name);
                }
                else if (closureTopLevel.Showing && mHiddenWindows.Contains(closureTopLevel.Name))
                {
                    mHiddenWindows.Remove(closureTopLevel.Name);
                }
            });
        }
    }
コード例 #5
0
        public IGuiPosition GetTopLevelPosition(ITopLevel topLevel)
        {
            if (!mRegisteredGuiList.ContainsKey(topLevel))
            {
                throw new ArgumentException("Unable to get position for unknown ITopLevel(" + topLevel.Name + ")", "topLevel");
            }

            return(mRegisteredGuiList[topLevel]);
        }
コード例 #6
0
        public void SetTopLevelPosition(ITopLevel topLevel, IGuiPosition position)
        {
            if (!mRegisteredGuiList.ContainsKey(topLevel))
            {
                throw new ArgumentException("Unable to set position for unknown ITopLevel(" + topLevel.Name + ")", "topLevel");
            }

            mRegisteredGuiList[topLevel] = position;
        }
コード例 #7
0
        public void RegisterTopLevel(ITopLevel topLevel, IGuiPosition p)
        {
            EditorWindowWrapper wrapper = (EditorWindowWrapper)EditorWindow.GetWindow(typeof(EditorWindowWrapper));

            wrapper.Manager       = this;
            wrapper.InnerTopLevel = topLevel;

            mRegisteredGuiList.Add(wrapper, mDefaultWindowPosition);
        }
コード例 #8
0
    private void SetupToolbar(ITopLevel topLevel)
    {
        mToolbar = topLevel;
        ((Window)mToolbar).InFront = true;
        mLoadedGuiLabel            = mToolbar.SelectSingleElement <Label>("MainFrame/LoadedFileLabel");

        Button openGuiButton = mToolbar.SelectSingleElement <Button>("MainFrame/OpenButton");

        openGuiButton.AddOnPressedAction(ShowLoadGuiDialog);
    }
コード例 #9
0
 public void UnregisterTopLevel(ITopLevel topLevel)
 {
     foreach (EditorWindowWrapper wrapper in mRegisteredGuiList.Keys)
     {
         if (topLevel == wrapper.InnerTopLevel)
         {
             mRegisteredGuiList.Remove(wrapper);
             wrapper.Close();
             return;
         }
     }
 }
コード例 #10
0
ファイル: Widget.cs プロジェクト: lsmolic/hangoutsrc
        public ITopLevel GetContainingTopLevel()
        {
            ITopLevel result = GetContainer <ITopLevel>();

            // Everything should be in an ITopLevel at some point
            if (result == null)
            {
                throw new System.Exception("The parent structure for this GUI Element (" + this.Name + ") is corrupted, Widgets should always be in a TopLevel.");
            }

            return(result);
        }
コード例 #11
0
        public Vector2 GetSize(IGuiElement element)
        {
            if (!(element is IGuiFrame && element.Parent is ITopLevel))
            {
                throw new ArgumentException("HeaderFrameSizePosition only works with IGuiFrames that are children of ITopLevels.");
            }

            ITopLevel parent = (ITopLevel)element.Parent;
            Vector2   result = new Vector2(parent.InternalSize.x, mHeaderHeight);

            return(result);
        }
コード例 #12
0
    private void SetupFileErrorWindow(ITopLevel topLevel)
    {
        mFileErrorWindow = topLevel;
        ((Window)mFileErrorWindow).InFront = true;
        mFileErrorWindow.Showing           = false;

        Button reloadGuiButton = mFileErrorWindow.SelectSingleElement <Button>("MainFrame/ReloadGuiButton");

        reloadGuiButton.AddOnPressedAction(delegate()
        {
            mFileErrorWindow.Showing = false;
            LoadUserGui(GetLastGuiPath());
        });
    }
コード例 #13
0
        public void UpdateChildPosition(IGuiElement element, UnityEngine.Vector2 position)
        {
            if (!(element is ITopLevel))
            {
                throw new ArgumentException("The GUI Manager cannot contain any non-ITopLevel IGuiElements. This happend on element (" + element.Name + ")", "element");
            }
            ITopLevel topLevel = (ITopLevel)element;

            if (!mRegisteredGuiList.ContainsKey(topLevel))
            {
                throw new ArgumentException("Cannot update child topLevel that hasn't been registered. This happend on element (" + element.Name + ")", "element");
            }

            mRegisteredGuiList[topLevel].UpdatePosition(element, position);
        }
コード例 #14
0
    private void SetupLoadGuiDialog(ITopLevel topLevel)
    {
        mLoadGuiDialog = topLevel;
        ((Window)mLoadGuiDialog).InFront = true;
        mLoadGuiDialog.Showing           = false;
        mLoadGuiFilterText = mLoadGuiDialog.SelectSingleElement <Textbox>("MainFrame/FilterText");

        mGuiListFrame           = mLoadGuiDialog.SelectSingleElement <IGuiFrame>("MainFrame/GuiList");
        mLoadGuiButtonPrototype = mGuiListFrame.SelectSingleElement <Button>("OpenGuiPrototype");
        mGuiListFrame.RemoveChildWidget(mLoadGuiButtonPrototype);

        // Keep the load file button disabled until it points to a valid file
        mLoadGuiFilterText.AddTextChangedCallback(LayoutGuiListings);

        LayoutGuiListings();
    }
コード例 #15
0
        public Vector2 GetPosition(IGuiElement element)
        {
            if (!(element is IGuiFrame && element.Parent is ITopLevel))
            {
                throw new ArgumentException("HeaderFrameSizePosition only works with IGuiFrames that are children of ITopLevels.");
            }

            Vector2   result = Vector2.zero;
            ITopLevel parent = (ITopLevel)element.Parent;

            if (parent.Style != null)
            {
                result.x = parent.Style.InternalMargins.Left;
                result.y = parent.Style.InternalMargins.Top;
            }

            return(result);
        }
コード例 #16
0
        private bool IsModelOrStationTopLevel(ITopLevel topLevel, FashionLevel level)
        {
            foreach (FashionGameStation station in level.Stations)
            {
                if (topLevel == station.MainGui)
                {
                    return(true);
                }
            }

            foreach (FashionModel model in level.ActiveModels)
            {
                if (topLevel == model.DesiredClothingWindow || topLevel == model.Nametag)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #17
0
        private Vector2 GetValidInScreenPosition(ITopLevel topLevel, Vector2 currentPosition)
        {
            ScreenEdgeTest edgeTest = new ScreenEdgeTest
                                      (
                new Rect
                (
                    currentPosition.x,
                    currentPosition.y,
                    topLevel.ExternalSize.x,
                    topLevel.ExternalSize.y
                )
                                      );

            // If this window is larger than the screen horizontally or vertically, don't force into viewport... it won't fit
            if (edgeTest.IsEitherDimensionLargerThanScreen())
            {
                return(currentPosition);
            }

            Vector2 result = currentPosition;

            if (!edgeTest.Right)
            {
                result.x = Screen.width - topLevel.ExternalSize.x;
            }
            else if (!edgeTest.Left)
            {
                result.x = 0.0f;
            }

            if (!edgeTest.Bottom)
            {
                result.y = Screen.height - topLevel.ExternalSize.y;
            }
            else if (!edgeTest.Top)
            {
                result.y = 0.0f;
            }

            return(result);
        }
コード例 #18
0
        public SvnGui(IGuiManager manager)
            : base(manager, mSvnGuiXml)
        {
            List <IGuiFrame> toolContextFrames = new List <IGuiFrame>();

            foreach (IGuiElement element in this.AllElements)
            {
                if (element is ITopLevel)
                {
                    mGuiRoot = (ITopLevel)element;
                }
                else if (element is IGuiFrame)
                {
                    toolContextFrames.Add((IGuiFrame)element);
                }
                else
                {
                    Debug.LogWarning("Ignoring unexpected GuiElement (" + element.Name + ") loaded from " + mSvnGuiXml);
                }
            }

            SuppressUnusedVariableWarning(mGuiRoot);
        }
コード例 #19
0
 /// <summary>
 ///	Editor mode TopLevels ignore position (Unity manages them). This function is just a stub
 /// </summary>
 public IGuiPosition GetTopLevelPosition(ITopLevel topLevel)
 {
     return(null);
 }
コード例 #20
0
 /// <summary>
 ///	Editor mode TopLevels ignore position (Unity manages them). This function is just a stub
 /// </summary>
 public void SetTopLevelPosition(ITopLevel topLevel, IGuiPosition position)
 {
 }
コード例 #21
0
 public ShowMeController(ITopLevel toplevel, ILogger <ShowMeController> logger, IEnumerable <ILevel> levels)
 {
     _logger   = logger;
     _toplevel = toplevel;
     _levels   = levels;
 }
コード例 #22
0
 public void RegisterTopLevel(ITopLevel gui, IGuiPosition position)
 {
     mRegisteredGuiList.Add(gui, position);
 }
コード例 #23
0
 public void UnregisterTopLevel(ITopLevel gui)
 {
     mRegisteredGuiList.Remove(gui);
 }
コード例 #24
0
        public RuntimeConsole(IGuiManager guiManager)
            : base(guiManager, mGuiPath)
        {
            if (guiManager == null)
            {
                throw new ArgumentNullException("guiManager");
            }

            mManager               = guiManager;
            mConsoleWindow         = this.MainGui;
            mConsoleWindow.Showing = false;

            IInputManager inputManager = GameFacade.Instance.RetrieveMediator <InputManagerMediator>();

            if (inputManager == null)
            {
                throw new Exception("Cannot construct a RuntimeConsole without having an InputManagerMediator registered in the GameFacade");
            }

            inputManager.RegisterForButtonUp(KeyCode.BackQuote, delegate()
            {
                mConsoleWindow.Showing = !mConsoleWindow.Showing;
            });

            mLogFrame       = mConsoleWindow.SelectSingleElement <IGuiFrame>("MainFrame/DebugLogFrame");
            mMainFrameWidth = mLogFrame.Size.x;
            Button closeButton = mConsoleWindow.SelectSingleElement <Button>("HeaderFrame/CloseButton");

            if (closeButton == null)
            {
                throw new Exception("Cannot find the button expected to be at 'HeaderFrame/CloseButton'");
            }

            closeButton.AddOnPressedAction(delegate()
            {
                mConsoleWindow.Showing = false;
            });

            IGuiStyle defaultLabelStyle = new GuiStyle(mManager.GetDefaultStyle(typeof(Label)), "ConsoleLabel");

            defaultLabelStyle.WordWrap = true;
            //defaultLabelStyle.DefaultFont = (Font)Resources.Load("Fonts/CourierBold");

            IGuiStyle errorStyle = new GuiStyle(defaultLabelStyle, "ConsoleErrorLabel");

            defaultLabelStyle.Normal.TextColor = Color.white;
            errorStyle.Normal.TextColor        = Color.Lerp(Color.black, Color.red, 0.35f);

            mLogLevelStyles.Add(LogLevel.Error, errorStyle);
            mLogLevelStyles.Add(LogLevel.Info, defaultLabelStyle);

            mCommandEntryBox = mConsoleWindow.SelectSingleElement <Textbox>("**/CommandEntryBox");

            inputManager.RegisterForButtonDown(KeyCode.Return, delegate()
            {
                if (this.MainGui.Showing)
                {
                    List <string> lineParsed = new List <string>(mCommandEntryBox.Text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries));
                    Action <ICollection <string> > command;
                    if (lineParsed.Count > 0 && mCommands.TryGetValue(lineParsed[0], out command))
                    {
                        lineParsed.RemoveAt(0);
                        command(lineParsed);
                    }
                }
            });
        }