コード例 #1
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);
    }
コード例 #2
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);
    }
コード例 #3
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();
    }
コード例 #4
0
    private void ShowError(string errorMessage)
    {
        mFileErrorWindow.Showing = true;
        ITextGuiElement errorText = mFileErrorWindow.SelectSingleElement <ITextGuiElement>("MainFrame/ErrorFrame/ErrorMessage");

        errorText.Text = errorMessage;
    }
コード例 #5
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());
        });
    }
コード例 #6
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);
                    }
                }
            });
        }