void WindowFunc(int windowId)
        {
            // ...add the controls....

            // Allow the window to be dragged by its title bar.
            GuiWindow.DragWindow(ref windowRect, titleBarRect);
        }
Exemple #2
0
        public SelectPartyState(bool allowCreateParty = false)
            : base("SelectPartyState")
        {
            Util.Assert(CoM.CharacterList != null, "Select Party State requires character list to be created before initialization.");

            _allowCreateParty = allowCreateParty;

            GuiWindow window = new GuiWindow(GuiPartySpan.WIDTH + 40, 400);

            window.WindowStyle       = GuiWindowStyle.Titled;
            window.Background.Sprite = ResourceManager.GetSprite("Gui/InnerWindow");
            window.Background.Color  = Colors.BackgroundGray;
            window.Title             = "Select Party";
            Add(window, 0, 100);

            partyList       = new GuiScrollableArea(100, 100, ScrollMode.VerticalOnly);
            partyList.Align = GuiAlignment.Full;
            window.Add(partyList);

            GuiWindow buttonsWindow = new GuiWindow(500, 80);

            buttonsWindow.Y = (int)window.Bounds.yMax - 5;
            Add(buttonsWindow, 0);

            GuiButton BackButton = new GuiButton("Back");

            buttonsWindow.Add(BackButton, 0, 0);

            BackButton.OnMouseClicked += delegate {
                Engine.PopState();
            };
        }
Exemple #3
0
 private void CreateWindow()
 {
     _engine.GuiLoader.Load("statusPane.xml", _engine.Gui.Desktop);
     _ammoTextWidget   = _engine.Gui.GetWidgetByName <Label>(AmmoTextName);
     _hungerTextWidget = _engine.Gui.GetWidgetByName <Label>(HungerTextName);
     _window           = _engine.Gui.GetWidgetByName <GuiWindow>(AmmoWindowName);
 }
        public void ShowMessageBox(GuiDefinitions.Callback callback, string title, string text)
        {
            GuiGameOverWindow window = new GuiGameOverWindow(new GuiDefinitions.Callback(WindowCallback), title, text);

            this.window         = window;
            this.windowCallback = callback;
        }
Exemple #5
0
        public DebugMenuState()
            : base("DebugMenu")
        {
            GuiWindow window = new GuiWindow(400, 500, "DEBUG");

            Add(window, 0, 0);

            int buttonIndex = 0;

            GuiButton testSerializationButton = new GuiButton("Serialization", -1);

            window.Add(testSerializationButton, 0, 50 + 40 * buttonIndex++);

            GuiButton ResetButton = new GuiButton("Reset", -1);

            ResetButton.ColorTransform = ColorTransform.BlackAndWhite;
            ResetButton.Color          = new Color(1f, 0.4f, 0.3f);
            window.Add(ResetButton, 0, 50 + 40 * buttonIndex++);

            testSerializationButton.OnMouseClicked += delegate {
                testDataSerialization();
            };

            ResetButton.OnMouseClicked += delegate {
                CoM.ConfirmAction(performGameReset, "Are you sure you want to reset the game?");
            };

            window.Add(Util.CreateBackButton(), 0, -10);
        }
Exemple #6
0
        private void CreateWindow()
        {
            _engine.GuiLoader.Load("progress.xml", _engine.Gui.Desktop);
            _progressWindow = _engine.Gui.GetWidgetByName <GuiWindow>(ProgressWindowName);
            _progressBar    = _engine.Gui.GetWidgetByName <ProgressBar>(ProgressBarName);

            _progressWindow.Visible = false;
        }
Exemple #7
0
        public TimeOfDayHud(GameClient gameClient)
        {
            _gameClient = gameClient;
            _engine     = gameClient.Engine;

            _timeOfDayWindow = (GuiWindow)(_engine.GuiLoader.Load("timeOfDay.xml", _engine.Gui.Desktop));
            _label           = _engine.Gui.GetWidgetByName <Label>(LabelName);
        }
 public PurchaseCompleteState(Window guiWindow, Hangout.Shared.Action backToStoreSelector)
     : base(guiWindow)
 {
     mPurchaseCompleteFrame = GuiWindow.SelectSingleElement <GuiFrame>("MainFrame/PurchaseCompleteFrame");
     mOkButton = GuiWindow.SelectSingleElement <Button>("MainFrame/PurchaseCompleteFrame/OkButton");
     mOkButton.AddOnPressedAction(delegate()
     {
         backToStoreSelector();
     });
 }
Exemple #9
0
        /// <summary>Activates the given window.</summary>
        public async Task ActivateWindowAsync(GuiWindow guiWindow)
        {
            var method = new ParameteredMethodMessage <GuiWindowParameters>
            {
                Method     = "GUI.ActivateWindow",
                Parameters = new GuiWindowParameters {
                    Window = guiWindow.ToString()
                }
            };

            await _request.SendRequestAsync <BasicResponseMessage <string> >(method);
        }
Exemple #10
0
        public StoreSelectionState(Window guiWindow, Action <string> openStore, Hangout.Shared.Action closeInventoryGui)
            : base(guiWindow)
        {
            mOpenStore = openStore;

            mStoreSelectorFrame = guiWindow.SelectSingleElement <GuiFrame>("MainFrame/StoreSelector");
            mCategorySideBar    = GuiWindow.SelectSingleElement <GuiFrame>("MainFrame/CategorySideBarFrame");
            mStoreSelectorGrid  = guiWindow.SelectSingleElement <GridView>("MainFrame/StoreSelector/StoreSelectorGrid");
            //mShopLabel = guiWindow.SelectSingleElement<Label>("MainFrame/StoreSelector/ShopLabel");
            mStoreButton = GuiWindow.SelectSingleElement <Button>("MainFrame/StoreSelector/StoreSelectorGrid/StoreButton");
            mStoreSelectorGrid.RemoveChildWidget(mStoreButton);
            mCloseInventoryGuiButton = guiWindow.SelectSingleElement <Button>("MainFrame/StoreSelector/CancelButton");
            //mCloseInventoryGui = closeInventoryGui;
            mCloseInventoryGuiButton.AddOnPressedAction(closeInventoryGui);
        }
Exemple #11
0
 public void Show(GuiWindow prev, DebugMenu.OnDoneFunc onDone)
 {
     if (this.menuRoot == null)
     {
         this.Setup();
     }
     this.onDone = onDone;
     this.ignoreFirstFramesDestroyUnity = 2;
     this.currentText = string.Empty;
     this.dirListener = this._input.RegisterMoveDir(new MappedInput.MoveDirEventFunc(this.GotKeyDir), -1);
     this.menuRoot.Show(null, prev);
     this.UpdateValue(true);
     this.blinkTimer = this._blinkTime;
     this.ShowTextInput();
 }
Exemple #12
0
    void Setup()
    {
        GuiBindInData inData      = new GuiBindInData(null, null);
        GuiBindData   guiBindData = GuiNode.Connect(this._layout, inData);

        this.menuRoot = guiBindData.GetTracker <GuiWindow>("debugRoot");
        guiBindData.GetTrackerEvent <IGuiOnclick>("debug.done").onclick = new GuiNode.OnVoidFunc(this.ClickedDone);
        guiBindData.GetTrackerEvent <IGuiOnclick>("debug.back").onclick = new GuiNode.OnVoidFunc(this.ClickedCancel);
        GuiContentData guiContentData = new GuiContentData();

        guiContentData.SetValue("version", this._version.GetVersion());
        this.menuRoot.ApplyContent(guiContentData, true);

        // Modify the HUD to make it better
        ModifyUI();
    }
Exemple #13
0
        /** Creates a new game state.  To be made active it must be pushed to the top of the game state stack (Game.push(x)) */
        public ModalState(string title)
            : base(title)
        {
            TransparentDraw = true;

            GuiFillRect background = new GuiFillRect(0, 0, 0, 0, new Color(0.0f, 0.0f, 0.0f, 0.75f));

            background.Align = GuiAlignment.Full;

            Window = new GuiWindow(400, 400, title);

            Window.Background.Color = Color.gray;

            Add(background);
            Add(Window, 0, 0, true);
        }
Exemple #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()
        {
            fEngine = new GuiEngine(this, fOptions, fGraphics);
            //fEngine.Theme = new MonoGUI.Themes.TestTheme();

            fWindow1 = new MainWindow(fEngine);
            fWindow2 = new MainWindow2(fEngine);
            fWindow3 = new MainWindow3(fEngine);

            fEngine.AddWindow(fWindow1);
            fEngine.AddWindow(fWindow2);
            fEngine.AddWindow(fWindow3);

            this.Components.Add(fEngine);

            base.Initialize();
        }
Exemple #15
0
        /// <summary>Shows a window that displays the recorded logs.</summary>
        /// <param name="windowId">Window ID.</param>
        void ConsoleWindowFunc(int windowId)
        {
            // Only show the logs snapshot when it's safe to change the GUI layout.
            if (guiActions.ExecutePendingGuiActions())
            {
                UpdateLogsView();
                // Check if the toolbar goes out of the screen.
                isToolbarAtTheBottom = windowRect.yMax < Screen.height;
            }

            if (!isToolbarAtTheBottom)
            {
                GUICreateToolbar();
            }

            // Main scrolling view.
            using (var logsScrollView = new GUILayout.ScrollViewScope(scrollPosition)) {
                scrollPosition = logsScrollView.scrollPosition;

                // Report conditions.
                if (!LogInterceptor.isStarted)
                {
                    using (new GuiColorScope(contentColor: errorLogColor)) {
                        GUILayout.Label("KSPDev is not handling system logs. Open standard in-game debug console"
                                        + " to see the current logs");
                    }
                }
                if (quickFilterInputEnabled)
                {
                    using (new GuiColorScope(contentColor: Color.gray)) {
                        GUILayout.Label("<i>Logs update is PAUSED due to the quick filter editing is active."
                                        + " Hit ENTER to accept the filter, or ESC to discard.</i>");
                    }
                }

                GUIShowLogRecords();
            }

            if (isToolbarAtTheBottom)
            {
                GUICreateToolbar();
            }

            // Allow the window to be dragged by its title bar.
            GuiWindow.DragWindow(ref windowRect, titleBarRect);
        }
Exemple #16
0
    void Start()
    {
        // Enable Unity debug logging
        DebugManager.EnableDebugging();

        // TEMP
        Utility.LoadLevel("MainMenu");

        GuiBindInData guiBindInData = new GuiBindInData(null, null);

        guiBindInData.Content.SetValue("gameLoading", false);
        MainMenu.ApplyUIData(PlatformInfo.Current.GetDataForUI("splash"), guiBindInData.Content);
        GuiBindData guiBindData = GuiNode.Connect(this._layout, guiBindInData);

        this.mainWnd = guiBindData.GetTracker <GuiWindow>("startRoot");
        this.mainWnd.Show(null, null);
        this.timer = this._time;
    }
Exemple #17
0
        public TownBuildingState(string name)
            : base(name)
        {
            int uiMargin = 10;

            GuiImage Background = new GuiImage(0, 0, ResourceManager.GetSprite("Backgrounds/Town"));

            Background.BestFit(ContentsFrame);
            Add(Background, 0, 0);

            LeftTwoThirds = new GuiContainer(Width - 340, Height);
            Add(LeftTwoThirds);

            LowerSection = new GuiWindow(0, 0);
            LowerSection.Background.Color = new Color(0.4f, 0.4f, 0.4f);
            LeftTwoThirds.Add(LowerSection);

            MainWindow = new GuiWindow(600, 500, name);
            LeftTwoThirds.Add(MainWindow, 0, 0);

            BackButton = new GuiButton("Back");
            BackButton.OnMouseClicked += delegate {
                Engine.PopState();
            };
            LowerSection.Add(BackButton);

            // UI

            Party       = new GuiPartyInfo(0, 0);
            Party.Party = CoM.Party;
            Add(Party, -uiMargin, -uiMargin);

            CharacterInfo = new GuiCharacterTabControl();
            Add(CharacterInfo, -uiMargin, uiMargin);

            ItemInventory = new GuiItemInventory();
            Add(ItemInventory, -uiMargin, CharacterInfo.Height + uiMargin);

            RepositionControls();
        }
        void ConsoleWindow(int windowID, GuiWindow guiWindow)
        {
            if (configAutoScroll)
            {
                if (lines.Count > lastLineCount)
                {
                    lastLineCount    = lines.Count;
                    scrollPosition.y = 1024f * 1024f;
                }
            }

            if (logStyle == null)
            {
                buttonStyle      = new GUIStyle(GUI.skin.GetStyle("Button"));
                toggleStyle      = new GUIStyle(GUI.skin.GetStyle("Toggle"));
                logStyle         = new GUIStyle(GUI.skin.GetStyle("Label"));
                logStyle.margin  = new RectOffset(0, 0, 0, 0);
                logStyle.padding = new RectOffset(0, 0, 0, 0);
            }

            scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            {
                for (int i = 0; i < lines.Count; ++i)
                {
                    GUILayout.Label(lines[i], logStyle);
                }
            }
            GUILayout.EndScrollView();

            GUILayout.BeginHorizontal();
            {
                if (GUILayout.Button(clearLabel, buttonStyle))
                {
                    lines.Clear();
                }
                configAutoScroll = GUILayout.Toggle(configAutoScroll, autoScrollLabel, toggleStyle, GUILayout.ExpandWidth(false));
                GUILayout.Space(guiWindow.HandleSize);
            }
            GUILayout.EndHorizontal();
        }
Exemple #19
0
        /// <summary>
        /// Charge les ressources dont a besoin la console.
        /// </summary>
        public void LoadContent()
        {
            int       width        = (int)GameClient.GetScreenSize().X;
            int       screenHeight = (int)GameClient.GetScreenSize().Y;
            const int h1           = 75;
            const int h2           = 25;
            const int bar          = 15;

            m_window           = new GuiWindow(Manager);
            m_window.Location  = new Point(0, (int)(screenHeight - 125));
            m_window.Size      = new Point(width, h1 + h2 + bar);
            m_window.Title     = "Developer Console";
            m_window.BackColor = new Color(0, 0, 0, 0);
            // Expand
            m_expandButton          = new GuiButton(Manager);
            m_expandButton.Parent   = m_window;
            m_expandButton.Location = new Point(m_window.Size.X - 15, 1);
            m_expandButton.Size     = new Point(15, 15);
            m_expandButton.Title    = "+";

            // Console input
            m_consoleInput                = new GuiTextInput(Manager);
            m_consoleInput.Parent         = m_window;
            m_consoleInput.Location       = new Point(0, bar + h1);
            m_consoleInput.Size           = new Point(width, h2);
            m_consoleInput.TextValidated += m_consoleInput_TextValidated;
            m_consoleInput.Opacity        = 200;

            // Console output
            m_consoleOutput          = new GuiMultilineTextDisplay(Manager);
            m_consoleOutput.Parent   = m_window;
            m_consoleOutput.Location = new Point(0, bar);
            m_consoleOutput.Size     = new Point(width, h1);
            m_consoleOutput.Opacity  = 200;

            m_expandButton.Clicked += m_expandButton_Clicked;
            Server.GameServer.GetScene().GameInterpreter.OnPuts = new PonyCarpetExtractor.Interpreter.PutsDelegate((string s) => { m_consoleOutput.AppendLine(s); m_consoleOutput.ScrollDown(); });
            Server.GameServer.GetScene().GameInterpreter.OnError = new PonyCarpetExtractor.Interpreter.PutsDelegate((string s) => { m_consoleOutput.AppendLine("error: " + s); m_consoleOutput.ScrollDown(); });
        }
Exemple #20
0
        public AboutMenuState()
            : base("AboutState")
        {
            var window = new GuiWindow(420, 400, "About");

            Add(window, 0, 0);

            window.Add(Util.CreateBackButton("Done"), 0, -10);

            window.Background.Sprite = ResourceManager.GetSprite("Gui/InnerWindow");
            window.Background.Color  = new Color(0.4f, 0.42f, 0.62f);

            var scrollBox = new GuiScrollableArea((int)window.ContentsFrame.width, (int)window.ContentsFrame.height - 40, ScrollMode.VerticalOnly);

            window.Add(scrollBox);

            var label = new GuiLabel(0, 20, AboutString, (int)window.ContentsBounds.width - 30);

            label.WordWrap  = true;
            label.TextAlign = TextAnchor.UpperCenter;
            scrollBox.Add(label);

            scrollBox.FitToChildren();
        }
Exemple #21
0
        public TempleState()
            : base("Temple")
        {
            MainWindow.Width  = 650;
            MainWindow.Height = 400;

            // Background:
            MainWindow.InnerShadow       = true;
            MainWindow.Background.Align  = GuiAlignment.None;
            MainWindow.Background.Sprite = ResourceManager.GetSprite("Backgrounds/TownTemple");
            MainWindow.Background.Color  = Color.white;
            MainWindow.Background.BestFit(MainWindow.ContentsFrame, true);
            MainWindow.PositionComponent(MainWindow.Background, 0, 0);

            // Bodies list:
            deadCharactersList = new GuiListBox <MDRCharacter>(0, 0, 250, 200);
            var deadCharactersListFrame = GuiWindow.CreateFrame(deadCharactersList, "Characters");

            deadCharactersListFrame.Style            = Engine.GetStyleCopy("Box50");
            deadCharactersListFrame.Background.Color = Colors.BackgroundYellow.Faded(0.75f);
            MainWindow.Add(deadCharactersListFrame, 10, 0);

            noDeadCharacters            = new GuiLabel("There are no dead\ncharacters here.", 250);
            noDeadCharacters.TextAlign  = TextAnchor.MiddleCenter;
            noDeadCharacters.DropShadow = true;
            MainWindow.Add(noDeadCharacters, 10, 150);

            // Info:
            raiseInfo               = new GuiLabel(0, 0, "", 300, 200);
            raiseInfo.WordWrap      = true;
            raiseInfo.Color         = new Color(0.9f, 0.9f, 0.9f, 0.9f);
            raiseInfo.Style.padding = new RectOffset(10, 10, 10, 4);
            var raiseInfoFrame = GuiWindow.CreateFrame(raiseInfo, "Details");

            raiseInfoFrame.Style            = Engine.GetStyleCopy("Box50");
            raiseInfoFrame.Background.Color = Color.white.Faded(0.75f);
            MainWindow.Add(raiseInfoFrame, (int)deadCharactersList.Bounds.xMax + 40, (int)deadCharactersList.Bounds.yMin);

            // Buttons:
            raiseCharacterButton = new GuiButton("Raise", 120);
            MainWindow.Add(raiseCharacterButton, raiseInfoFrame.X + 70, (int)raiseInfoFrame.Bounds.yMax + 5);

            costLabel = new GuiCoinAmount();

            MainWindow.Add(costLabel, (int)raiseCharacterButton.Bounds.xMax + 20, raiseCharacterButton.Y + 3);

            // Triggers
            deadCharactersList.OnSelectedChanged += delegate {
                doUpdateRaiseInfo();
            };
            PopulateDeadCharacterList();

            raiseCharacterButton.OnMouseClicked += delegate {
                if (deadCharactersList.Selected != null)
                {
                    doRaiseCharacter(deadCharactersList.Selected);
                }
            };

            RepositionControls();
        }
        void ConsoleWindow(int windowID, GuiWindow guiWindow)
        {
            if (configAutoScroll)
            {
                if (lines.Count > lastLineCount)
                {
                    lastLineCount = lines.Count;
                    scrollPosition.y = 1024f * 1024f;
                }
            }

            if (logStyle == null)
            {
                buttonStyle = new GUIStyle(GUI.skin.GetStyle("Button"));
                toggleStyle = new GUIStyle(GUI.skin.GetStyle("Toggle"));
                logStyle = new GUIStyle(GUI.skin.GetStyle("Label"));
                logStyle.margin = new RectOffset(0, 0, 0, 0);
                logStyle.padding = new RectOffset(0, 0, 0, 0);
            }

            scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            {
                for (int i = 0; i < lines.Count; ++i)
                {
                    GUILayout.Label(lines[i], logStyle);
                }
            }
            GUILayout.EndScrollView();

            GUILayout.BeginHorizontal();
            {
                if (GUILayout.Button(clearLabel, buttonStyle))
                {
                    lines.Clear();
                }
                configAutoScroll = GUILayout.Toggle(configAutoScroll, autoScrollLabel, toggleStyle, GUILayout.ExpandWidth(false));
                GUILayout.Space(guiWindow.HandleSize);
            }
            GUILayout.EndHorizontal();
        }
        public StoreDisplayState(Window guiWindow, Window overlayWindow, Hangout.Shared.Action closeInventoryGui)
            : base(guiWindow)
        {
            mCloseInventoryGui = closeInventoryGui;


            mItemDisplayFrame = GuiWindow.SelectSingleElement <GuiFrame>("MainFrame/ItemDisplayFrame");

            // Item grid display
            mItemDisplayGrid     = GuiWindow.SelectSingleElement <GridView>("MainFrame/ItemDisplayFrame/ItemDisplayGrid");
            mItemGridButtonFrame = GuiWindow.SelectSingleElement <GuiFrame>("MainFrame/ItemDisplayFrame/ItemDisplayGrid/GridButtonFrame");

            // Item Info Detail Panel
            mItemInfoFrame             = GuiWindow.SelectSingleElement <GuiFrame>("MainFrame/ItemDisplayFrame/InfoFrame");
            mItemInfoTitleLabel        = mItemInfoFrame.SelectSingleElement <Label>("DescriptionScrollFrame/TitleLabel");
            mItemInfoExpirationLabel   = mItemInfoFrame.SelectSingleElement <Label>("ExpirationLabel");
            mItemInfoDescriptionLabel  = mItemInfoFrame.SelectSingleElement <Label>("DescriptionScrollFrame/DescriptionLabel");
            mItemInfoNumAvailableLabel = mItemInfoFrame.SelectSingleElement <Label>("NumAvailableLabel");

            // Tab Sidebar
            mCategorySideBar = GuiWindow.SelectSingleElement <GuiFrame>("MainFrame/CategorySideBarFrame");

            // Close button
            mCloseInventoryGuiButton = GuiWindow.SelectSingleElement <Button>("MainFrame/ItemDisplayFrame/CloseInventoryButton");
            mCloseInventoryGuiButton.AddOnPressedAction(delegate()
            {
                mCloseInventoryGui();
            });


            // Item Info Overlay
            mOverlayWindow = overlayWindow;
            GuiFrame overlayFrame = mOverlayWindow.SelectSingleElement <GuiFrame>("MainFrame/OverlayFrame");

            mItemOverlayActionButton = overlayFrame.SelectSingleElement <Button>("GridButtonTopBar/Action");
            mItemOverlayPrice        = overlayFrame.SelectSingleElement <Label>("GridButtonTopBar/PriceFrame/Price");
            mItemOverlayCoinIcon     = overlayFrame.SelectSingleElement <Image>("GridButtonTopBar/PriceFrame/CoinIcon");
            mItemOverlayCashIcon     = overlayFrame.SelectSingleElement <Image>("GridButtonTopBar/PriceFrame/CashIcon");
            //mItemOverlayOwnedImage = overlayFrame.SelectSingleElement<Image>("Owned");
            mItemOverlayImage  = overlayFrame.SelectSingleElement <Image>("Image");
            mRemoveButton      = overlayFrame.SelectSingleElement <Button>("RemoveButton");
            mRemoveButton.Text = Translation.REMOVEIT;

            mRealMoneyIcon    = (Texture)Resources.Load(InventoryGlobals.CashIconPath);
            mGameCurrencyIcon = (Texture)Resources.Load(InventoryGlobals.CoinIconPath);

            mItemOverlayActionButton.Text = Translation.PURCHASE;

            mOverlayWindow.Showing = false;

            // Page forward/back panel
            mPaginationFrame    = GuiWindow.SelectSingleElement <GuiFrame>("MainFrame/ItemDisplayFrame/PaginationFrame");
            mNextPageButton     = GuiWindow.SelectSingleElement <Button>("MainFrame/ItemDisplayFrame/PaginationFrame/PaginationControlFrame/NextPageButton");
            mPreviousPageButton = GuiWindow.SelectSingleElement <Button>("MainFrame/ItemDisplayFrame/PaginationFrame/PaginationControlFrame/PreviousPageButton");
            mPaginationLabel    = GuiWindow.SelectSingleElement <Label>("MainFrame/ItemDisplayFrame/PaginationFrame/PaginationControlFrame/PaginationLabel");
            mNextPageButton.AddOnPressedAction(delegate()
            {
                NextPage();
            });
            mPreviousPageButton.AddOnPressedAction(delegate()
            {
                PreviousPage();
            });
            mLastPageButton  = GuiWindow.SelectSingleElement <Button>("MainFrame/ItemDisplayFrame/PaginationFrame/PaginationControlFrame/LastPageButton");
            mFirstPageButton = GuiWindow.SelectSingleElement <Button>("MainFrame/ItemDisplayFrame/PaginationFrame/PaginationControlFrame/FirstPageButton");
            mLastPageButton.Disable();
            mLastPageButton.AddOnPressedAction(delegate()
            {
                LastPage();
            });
            mFirstPageButton.Disable();
            mFirstPageButton.AddOnPressedAction(delegate()
            {
                FirstPage();
            });

            //          mBackToStoreSelectorButton = GuiWindow.SelectSingleElement<Button>("MainFrame/ItemDisplayFrame/PaginationFrame/BackToStoreSelectorButton");
            //          mBackToStoreSelectorButton.AddOnPressedAction(delegate()
            //                                                          {
            //                                                              mBackToStoreSelectorCallback();
            //                                                          });
            mItemDisplayGrid.RemoveChildWidget(mItemGridButtonFrame);
        }
 public GuiWindowBorder(GuiWindow nParentWindow, GuiWindow.Border nBorder)
 {
     parentWindow = nParentWindow;
     border       = nBorder;
     Visible      = false;
 }
Exemple #25
0
 public void Awake()
 {
     instance = this;
     NGuiWindow.Closed += OnPopupClose;
 }
Exemple #26
0
        public TownState()
            : base("TownState")
        {
            GuiImage Background = new GuiImage(0, 0, ResourceManager.GetSprite("Backgrounds/Town"));

            Background.BestFit(ContentsFrame);
            Add(Background, 0, 0);

            GuiWindow window = new GuiWindow(400, 260, "Town");

            window.Background.Color = Colors.BackgroundGray;
            Add(window, 0, 0);

            GuiButton MainMenuButton = new GuiButton("Exit", 150);

            MainMenuButton.ColorTransform  = ColorTransform.BlackAndWhite;
            MainMenuButton.ColorTransform += ColorTransform.Multiply(1.2f, 1.2f, 1.2f);
            MainMenuButton.Color           = new Color(1f, 0.4f, 0.3f);

            GuiButton storeButton  = new GuiButton("General Store", 150);
            GuiButton templeButton = new GuiButton("Temple", 150);
            GuiButton guildButton  = new GuiButton("Guild", 150);

            GuiButton tavernButton  = new GuiButton("Tavern", 150);
            GuiButton libraryButton = new GuiButton("Library", 150);
            GuiButton bankButton    = new GuiButton("Bank", 150);
            GuiButton dungeonButton = new GuiButton("Dungeon", 150);

            int buttonY = 25;

            window.Add(MainMenuButton, 0, buttonY - 5);

            window.Add(storeButton, 20, buttonY + 40 * 1);
            window.Add(templeButton, 20, buttonY + 40 * 2);
            window.Add(guildButton, 20, buttonY + 40 * 3);

            window.Add(tavernButton, -20, buttonY + 40 * 1);
            window.Add(libraryButton, -20, buttonY + 40 * 2);
            window.Add(bankButton, -20, buttonY + 40 * 3);

            window.Add(dungeonButton, 0, -20);

            storeButton.OnMouseClicked += delegate {
                Engine.PushState(new StoreState());
            };

            guildButton.OnMouseClicked += delegate {
                Engine.PushState(new GuildState());
            };

            templeButton.OnMouseClicked += delegate {
                Engine.PushState(new TempleState());
            };

            bankButton.OnMouseClicked += delegate {
                Engine.PushState(new BankState());
            };

            libraryButton.OnMouseClicked += delegate {
                Engine.PushState(new LibraryState());
            };


            MainMenuButton.OnMouseClicked += CoM.ReturnToMainMenu;

            OnStateShow += delegate {
                SoundManager.PlayMusicPlaylist("City");
            };

            // these are not implemented yet.
            tavernButton.SelfEnabled = false;
            bankButton.SelfEnabled   = false;

            dungeonButton.OnMouseClicked += delegate {
                if (CoM.Party.LivingMembers == 0)
                {
                    Engine.ShowModal("Can Not Enter Dungeon.", "All party memebers are dead.");
                }
                else
                {
                    CoM.Party.Depth = 1;
                    PartyController.Instance.SyncCamera();
                    Engine.PopState();
                }
            };
        }
Exemple #27
0
        /** Creates the UI componenets required to display the gui */
        private void CreateUIComponents()
        {
            var window = new GuiWindow(800, 560);

            window.Background.Sprite = ResourceManager.GetSprite("Gui/InnerWindow");
            window.Background.Color  = new Color(0.5f, 0.5f, 0.5f);
            PositionComponent(window, 0, 0);
            Add(window);

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

            nameInput               = new GuiTextField(0, 0, 200);
            nameInput.Value         = CharacterNameGenerator.GenerateName();
            nameInput.LabelText     = "Name";
            nameInput.LabelPosition = LabelPosition.Left;
            window.Add(nameInput, 0, 20);

            var randomButton = new GuiButton("random", -1, 20);

            window.Add(randomButton, (int)nameInput.Bounds.xMax + 10, 25);

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

            var genderListFrame = new FramedListBox <MDRGender>(200, 100, "Gender");

            window.Add(genderListFrame, 260, 100);

            portraitSelector          = new GuiPictureSeletor();
            portraitSelector.Pictures = CoM.Instance.Portraits.GetEntries().ToArray();
            window.Add(portraitSelector, 460, 70 + 18 + 20);

            allRacesToggle                 = new GuiToggleButton();
            allRacesToggle.LabelText       = "Show All";
            allRacesToggle.LabelPosition   = LabelPosition.Right;
            allRacesToggle.X               = (int)portraitSelector.Bounds.xMax + 10;
            allRacesToggle.Y               = (int)portraitSelector.Bounds.y + 30;
            allRacesToggle.Value           = false;
            allRacesToggle.OnValueChanged += delegate {
                updatePortraits();
            };
            window.Add(allRacesToggle);

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

            var raceListFrame = new FramedListBox <MDRRace>(200, 240, "Race");

            window.Add(raceListFrame, 20, 240);

            statList = new GuiStatList(new MDRStats());
            window.Add(statList, 220 + 20, 240);

            var characterInfo = new GuiWindow(250, 240, "Info");

            window.Add(characterInfo, 470 + 40, 240);

            characterInfoText          = new GuiLabel(0, 0, "");
            characterInfoText.Align    = GuiAlignment.Full;
            characterInfoText.WordWrap = true;
            characterInfo.Add(characterInfoText);

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

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

            GuiButton cancelButton = new GuiButton("Cancel", 100);

            window.Add(cancelButton, 20, -20);

            GuiButton doneButton = new GuiButton("Save", 100);

            window.Add(doneButton, -20, -20);


            raceList = raceListFrame.ListBox;
            foreach (MDRRace race in CoM.Races)
            {
                raceList.Add(race);
            }

            genderList = genderListFrame.ListBox;
            genderList.Add(MDRGender.Male);
            genderList.Add(MDRGender.Female);

            genderList.OnSelectedChanged += delegate {
                updateGender();
            };
            raceList.OnSelectedChanged += delegate {
                updateRace();
            };

            doneButton.OnMouseClicked += delegate {
                if (statList.FreePoints != 0)
                {
                    Engine.ConfirmAction(saveAndClose, "This character still has " + Util.Colorise(statList.FreePoints, Color.green) + " stat points left to spend.\nAre you sure you want to save the character without spending them?");
                }
                else
                {
                    saveAndClose();
                }
            };

            cancelButton.OnMouseClicked += delegate {
                Engine.PopState();
            };
            randomButton.OnMouseClicked += delegate {
                nameInput.Value = CharacterNameGenerator.GenerateName();
            };

            updateRace();
            updateGender();
        }
Exemple #28
0
 private void CreateWindow()
 {
     _engine.GuiLoader.Load("playerInventory.xml", _engine.Gui.Desktop);
     _inventoryWindow = (GuiWindow)_engine.Gui.GetWidgetByName(InventoryWindowName);
     BindGuiEventHandlers();
 }
Exemple #29
0
 private void CreateWindow()
 {
     _engine.GuiLoader.Load("health.xml", _engine.Gui.Desktop);
     _healthWindow = _engine.Gui.GetWidgetByName <GuiWindow>(HealthWindowName);
     _healthBar    = _engine.Gui.GetWidgetByName <HealthBar>(HealthBarName);
 }
Exemple #30
0
        public MainMenuState()
            : base("Main Menu")
        {
            CoM.EnableCamera = true;

            window = new GuiWindow(350, 280);
            window.Background.Sprite = ResourceManager.GetSprite("Gui/InnerWindow");
            window.Background.Color  = Colors.BackgroundRed;

            Add(window, 0, 50);

            GuiLabel title = new GuiLabel(0, 0, "ENDURANCE");

            title.Font           = CoM.Instance.TextFont;
            title.FontSize       = 48;
            title.FontColor      = new Color(1, 1, 1, 0.5f);
            title.DropShadow     = true;
            title.ShadowDistance = 2;
            title.Interactive    = true;
            window.Add(title, 0, 22);

            int       currentButtonPosition = 100;
            const int buttonSpacing         = 50;

            bool needsExitButton  = Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.LinuxPlayer;
            bool needsDebugButton = Settings.Advanced.PowerMode;

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

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

            GuiButton PlayButton = new GuiButton("Play");

            window.PositionComponent(PlayButton, 0, currentButtonPosition);
            window.Add(PlayButton);
            currentButtonPosition += buttonSpacing;

            GuiButton SettingsButtton = new GuiButton("Settings");

            window.PositionComponent(SettingsButtton, 0, currentButtonPosition);
            window.Add(SettingsButtton);
            currentButtonPosition += buttonSpacing;

            GuiButton AboutButton = new GuiButton("About");

            window.PositionComponent(AboutButton, 0, currentButtonPosition);
            window.Add(AboutButton);
            currentButtonPosition += buttonSpacing;

            GuiButton ExitButton = new GuiButton("Exit");

            if (needsExitButton)
            {
                window.PositionComponent(ExitButton, 0, currentButtonPosition);
                window.Add(ExitButton);
                currentButtonPosition += buttonSpacing;
                window.Height         += buttonSpacing;
            }

            GuiButton DebugButton = new GuiButton("Debug", 140);

            DebugButton.ColorTransform = ColorTransform.BlackAndWhite;
            DebugButton.Color          = new Color(0.6f, 1.0f, 0.7f);

            if (needsDebugButton)
            {
                window.PositionComponent(DebugButton, 0, currentButtonPosition);
                window.Add(DebugButton);
                window.Height += buttonSpacing;
            }

            title.OnDoubleClicked += delegate {
                if (Settings.Advanced.PowerMode == false)
                {
                    Settings.Advanced.PowerMode = true;
                    window.Add(DebugButton, 0, currentButtonPosition + (4 * buttonSpacing));
                    window.Height += buttonSpacing;
                }
            };

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

            if (Engine.isWeb)
            {
                GuiWindow WebWarningWindow = new GuiWindow(500, 90);
                WebWarningWindow.Add(
                    new GuiLabel(Util.Colorise("Browser preview.\nFor the best experience download the standalone version.", new Color(1f, 0.75f, 0.45f)))
                {
                    TextAlign = TextAnchor.MiddleCenter
                },
                    0, 0);
                Add(WebWarningWindow, 0, -50);
            }

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

            VersionLabel           = new GuiLabel("");
            VersionLabel.FontColor = Color.yellow;
            Add(VersionLabel, -20, 10, true);

            PlayButton.OnMouseClicked += delegate {
                Engine.PushState(new SelectPartyState(true));
            };
            SettingsButtton.OnMouseClicked += delegate {
                Engine.PushState(new SettingsMenuState());
            };
            AboutButton.OnMouseClicked += delegate {
                Engine.PushState(new AboutMenuState());
            };
            ExitButton.OnMouseClicked += delegate {
                Application.Quit();
            };
            DebugButton.OnMouseClicked += delegate {
                Engine.PushState(new DebugMenuState());
            };
            OnStateShow += delegate {
                SoundManager.PlayMusicPlaylist("Intro");
            };

            DefaultControl = PlayButton;

            CoM.Instance.StartCoroutine(updateFadeIn(2f));
        }
        /// <summary>Shows a window that displays the resource transfer controls.</summary>
        /// <param name="windowId">Window ID.</param>
        void TransferResourcesWindowFunc(int windowId)
        {
            // Allow the window to be dragged by its title bar.
            GuiWindow.DragWindow(ref windowRect, titleBarRect);

            MakeGuiStyles();

            // In the docked mode the players must use the stock transfer mechanism.
            if (vessel == linkTarget.part.vessel)
            {
                GUILayout.Label(NotAvailableInDockedMode, new GUIStyle(GUI.skin.label)
                {
                    wordWrap = false
                });
                if (GUILayout.Button(CloseDialogBtn, MinSizeLayout))
                {
                    isGUIOpen = false;
                }
                SetPendingTransferOption(null); // Cancel all transfers.
                return;
            }

            if (guiActions.ExecutePendingGuiActions())
            {
                MaybeUpdateResourceOptionList();
                guiResourcesTable.UpdateFrame();
                if (pendingOption != null)
                {
                    if (!DoTransfer())
                    {
                        SetPendingTransferOption(null); // Cancel all transfers.
                    }
                }
                UpdateResourcesTransferGui();
            }

            GUILayout.Label(OwnerVesselTxt.Format(vessel.vesselName), GUI.skin.box);
            GUILayout.Label(ConnectedVesselTxt.Format(linkTarget.part.vessel.vesselName), GUI.skin.box);
            for (var i = resourceRows.Length - 1; i >= 0; i--)
            {
                var row = resourceRows[i];
                guiResourcesTable.StartNewRow();
                using (new GUILayout.HorizontalScope()) {
                    guiResourcesTable.AddTextColumn(
                        row.caption, guiResourceStyle, minWidth: resourceName.guiTags.minWidth);
                    guiResourcesTable.AddTextColumn(
                        row.leftInfo, guiNoWrapCenteredStyle, minWidth: resourceAmounts.guiTags.minWidth);
                    using (new GuiEnabledStateScope(row.canMoveRightToLeft)) {
                        row.rightToLeftTransferToggle = GUILayoutButtons.Toggle(
                            row.rightToLeftTransferToggle, leftToRigthToggleCnt, guiTransferBtnStyle, null,
                            GuiActionUpdateTransferItem, GuiActionUpdateTransferItem, guiActions);
                        row.rightToLeftTransferPress = GUILayoutButtons.Push(
                            row.rightToLeftTransferPress, leftToRigthButtonCnt, guiTransferBtnStyle, null,
                            GuiActionUpdateTransferItem, GuiActionUpdateTransferItem, guiActions);
                    }
                    using (new GuiEnabledStateScope(row.canMoveLeftToRight)) {
                        row.leftToRightTransferPress = GUILayoutButtons.Push(
                            row.leftToRightTransferPress, rightToLeftButtonCnt, guiTransferBtnStyle, null,
                            GuiActionUpdateTransferItem, GuiActionUpdateTransferItem, guiActions);
                        row.leftToRightTransferToggle = GUILayoutButtons.Toggle(
                            row.leftToRightTransferToggle, rightToLeftToggleCnt, guiTransferBtnStyle, null,
                            GuiActionUpdateTransferItem, GuiActionUpdateTransferItem, guiActions);
                    }
                    guiResourcesTable.AddTextColumn(
                        row.rightInfo, guiNoWrapCenteredStyle, minWidth: resourceAmounts.guiTags.minWidth);
                    guiResourcesTable.AddTextColumn(
                        row.caption, guiResourceStyle, minWidth: resourceName.guiTags.minWidth);
                }
            }

            // Resource transfer speed.
            autoScaleSpeed = GUILayoutButtons.Toggle(
                autoScaleSpeed, autoScaleToggleCnt, GUI.skin.toggle, null,
                MaybeAutoScaleSpeed, null, guiActions);
            using (new GuiEnabledStateScope(!autoScaleSpeed)) {
                transferSpeed = GUILayout.HorizontalSlider(transferSpeed, 0f, maxTransferSpeed);
                if (transferSpeed < float.Epsilon && pendingOption != null)
                {
                    guiActions.Add(() => SetPendingTransferOption(null)); // Cancel all transfers.
                }
            }
            GUILayout.Label(TransferSpeedTxt.Format(transferSpeed));

            using (new GUILayout.HorizontalScope()) {
                if (GUILayout.Button(CloseDialogBtn, MinSizeLayout))
                {
                    guiActions.Add(() => isGUIOpen = false);
                }
                GUILayout.Label("");
                GUI.Label(GUILayoutUtility.GetLastRect(), GUI.tooltip);
            }
        }
Exemple #32
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()
        {
            fEngine           = new GuiEngine(this, fOptions, fGraphics);
            fEngine.OnResize += FEngine_OnResize;
            fLabelDisplayMode = new GuiLabel();
            fAdapterSize      = new GuiLabel()
            {
                HorizontalAlignment = GuiHorizontalAlignment.Right, BackgroundColor = Color.Orange
            };
            fWindowSize  = new GuiLabel();
            fAspectRatio = new GuiLabel();
            fFPS         = new GuiLabel()
            {
                HorizontalAlignment = GuiHorizontalAlignment.Right
            };
            fInfo       = new GuiLabel();
            lblDrawMode = new GuiLabel()
            {
                HorizontalAlignment = GuiHorizontalAlignment.Left, BackgroundColor = Color.Blue, ForegroundColor = Color.Yellow
            };
            lblShaderMode = new GuiLabel()
            {
                HorizontalAlignment = GuiHorizontalAlignment.Left, BackgroundColor = Color.Blue, ForegroundColor = Color.Yellow
            };
            lblRenderObjects = new GuiLabel()
            {
                HorizontalAlignment = GuiHorizontalAlignment.Left, BackgroundColor = Color.Blue, ForegroundColor = Color.Yellow
            };
            fCurrentElement = new GuiLabel();

            fWindow = new GuiWindow()
            {
                Dragable  = true,
                Clickable = true,
                Title     = new GuiDockChild()
                {
                    Dock    = GuiDock.Top,
                    Control = new GuiLabel()
                    {
                        Text = "Lines! (Click, Size or Drag)",
                        //VerticalAlignment = GuiVerticalAlignment.Stretch,
                        //HorizontalAlignment = GuiHorizontalAlignment.Stretch,
                        BackgroundColor = Color.Black,
                        ForegroundColor = Color.Yellow,
                    }
                },
                Border = new GuiBorder()
                {
                    Border      = new GuiThickness(15),
                    BorderColor = new Color(Color.Black, 0.3f),
                },
                //BackgroundColor = new Color(Color.Red, 0.9f),
                HorizontalAlignment = GuiHorizontalAlignment.Left,
                //VerticalAlignment = GuiVerticalAlignment.Top,
                WindowState = GuiWindowState.Normal,
                X           = 100,
                Y           = 100,
                Width       = 600,
                Height      = 500,

                Content = new GuiPanel()
                {
                    Margin  = new GuiThickness(20),
                    Content = new GuiStackPanel()
                    {
                        Childs = new List <GuiStackChild>()
                        {
                            new GuiStackChild()
                            {
                                Control = fFPS
                            },
                            new GuiStackChild()
                            {
                                Control = fLabelDisplayMode
                            },
                            new GuiStackChild()
                            {
                                Control = fAdapterSize
                            },
                            new GuiStackChild()
                            {
                                Control = fWindowSize
                            },
                            new GuiStackChild()
                            {
                                Control = fAspectRatio
                            },
                            new GuiStackChild()
                            {
                                Control = fInfo
                            },
                            new GuiStackChild()
                            {
                                Control = fCurrentElement
                            },
                            new GuiStackChild()
                            {
                                Control = lblDrawMode
                            },
                            new GuiStackChild()
                            {
                                Control = lblShaderMode
                            },
                            new GuiStackChild()
                            {
                                Control = lblRenderObjects
                            }
                        },
                        HorizontalAlignment = GuiHorizontalAlignment.Left,
                        VerticalAlignment   = GuiVerticalAlignment.Top,
                        BackgroundColor     = new Color(Color.White, 0.2f),
                    },
                    BackgroundColor = new Color(Color.Red, 0.7f),
                }
            };

            fEngine.AddWindow(fWindow);

            if (fWindow.Title != null)
            {
                fWindow.Title.Control.OnClick += WindowTitle_OnClick;
            }
            lblDrawMode.OnClick      += lblDrawMode_OnClick;
            lblShaderMode.OnClick    += lblShaderMode_OnClick;
            lblRenderObjects.OnClick += LblRenderObjects_OnClick;
            this.Components.Add(fEngine);

            UpdateScale();

            base.Initialize();
        }