コード例 #1
0
ファイル: Factory.cs プロジェクト: AlexanderKrustev/SoftUni
        public static void GenerateLevelBuildingPanel(ContentManager content)
        {
            var panelTexture = content.Load<Texture2D>("UiTiles/GrayTileTransparency");
            var spriteFont = content.Load<SpriteFont>("Fonts/impact");
            var buttonTexture = content.Load<Texture2D>("UiTiles/Button");

            var panelPosition = new Vector2(100, 100);
            var panelSize = new Rectangle((int)panelPosition.X, (int)panelPosition.Y, 512, 512);
            var levelBuilderPanel = new Panel(panelPosition, panelSize, panelTexture);

            var levelFiles = FileUtils.GetFilenames("Level");
            var levelSelectorObjects = new List<IDrawableGameObject>();
            foreach (string levelFile in levelFiles)
            {
                var objectTexture = content.Load<Texture2D>(levelFile);
                var texturedGameObject = new TexturedGameObject(objectTexture);
                levelSelectorObjects.Add(texturedGameObject);
            }

            var objectSelectorTransform = new Transform2D(levelBuilderPanel.Transform);
            var level = new Level();
            var objectSelector = new ObjectSelector(levelSelectorObjects, objectSelectorTransform, level);

            var nextButton = GenerateButton(spriteFont, buttonTexture, "Next", new Vector2(410, 470));
            nextButton.OnPress += args => objectSelector.SwitchToNextObject();

            var previousButton = GenerateButton(spriteFont, buttonTexture, "Previous", new Vector2(0, 470));
            previousButton.OnPress += args => objectSelector.SwitchToPreviousObject();

            var placeObjectButton = GenerateButton(spriteFont, buttonTexture, "Place", new Vector2(120, 470));
            placeObjectButton.OnPress += args => objectSelector.PlaceGameObjectInLevel();

            levelBuilderPanel.AddChild(objectSelector);
            levelBuilderPanel.AddChild(previousButton);
            levelBuilderPanel.AddChild(nextButton);
            levelBuilderPanel.AddChild(placeObjectButton);

            Repository.GameObjects.Add(level);
            Repository.GameObjects.Add(levelBuilderPanel);
        }
コード例 #2
0
        public GameState(GameManager gameManager, GraphicsDevice graphicsDevice, ContentManager contentManager, bool preserveState) : base(gameManager, graphicsDevice, contentManager)
        {
            this.gameManager    = gameManager;
            this.GraphicsDevice = graphicsDevice;
            this.ContentManager = contentManager;
            if (!preserveState)
            {
                ChapterMaster.Sector.Prepare();
                // idk what minimum distance we should do
                //ChapterMaster.Sector.GridGenerate(50, 100, Constants.SystemSize, Constants.WorldWidth, Constants.WorldHeight);
                ChapterMaster.Sector.clusterGenerate();
                ChapterMaster.Sector.WarpLaneGenerate();
                ChapterMaster.Sector.GenerateSystemNames();
                ChapterMaster.Sector.GeneratePlanets();
                string factionName = ChapterMaster.Sector.CurrentFaction;
                ChapterMaster.Sector.Fleets.Add(new Fleet.Fleet(0, 0, 0));
                ChapterMaster.Sector.Fleets.Add(new Fleet.Fleet(0, 0, 0));
                ChapterMaster.Sector.Fleets.Add(new Fleet.Fleet(2, 0, 1));
                ChapterMaster.Sector.Fleets.Add(new Fleet.Fleet(0, 0, 1));
                ChapterMaster.Sector.Finalize();
            }
            renderer = new SectorRenderer();
            ChapterMaster.ViewController           = new ViewController();
            ChapterMaster.ViewController.gameState = this;
            spriteBatch = new SpriteBatch(graphicsDevice);
            //ChapterMaster.ViewController.viewPortWidth = GameManager.GetWidth();
            //ChapterMaster.ViewController.viewPortHeight = GameManager.GetHeight();
            GameManager.graphics.PreferredBackBufferWidth  = GameManager.window.ClientBounds.Width;
            GameManager.graphics.PreferredBackBufferHeight = GameManager.window.ClientBounds.Height;
            ChapterMaster.ViewController.viewPortWidth     = GameManager.window.ClientBounds.Width;
            ChapterMaster.ViewController.viewPortHeight    = GameManager.window.ClientBounds.Height;
            GameManager.graphics.ApplyChanges(); // I'm not questioning why this works. ;) #relatable
            renderer.Initialize(graphicsDevice, spriteBatch);
            RenderHelper.Initialize(graphicsDevice, spriteBatch);

            _gameUI = new Desktop();

            var Panel = new Panel {
            };

            ChapterMaster.MainScreen = new Screen(0,
                                                  "mapframe",
                                                  new MapFrameAlign(11,
                                                                    61,
                                                                    156,
                                                                    10),
                                                  false); // TODO: The proletariat will rise. Enable advanced occlusion for the map frame.
            //ChapterMaster.MainScreen.AddButton(new Button("ui_but_0",
            //    "End Turn",
            //    new CornerAlign(Corner.BOTTOMRIGHT,
            //        144,
            //        43),
            //    EndTurn));

            var EndTurnTexture = new TextureRegion(Assets.GetButton("ui_but_0"));
            var EndTurnButton  = new ImageTextButton
            {
                Background               = EndTurnTexture,
                OverImage                = EndTurnTexture,
                Text                     = "End Turn",
                TextColor                = Color.White,
                Font                     = Assets.CaslonAntiqueBoldFSS.GetFont(24),
                TextPosition             = ImageTextButton.TextPositionEnum.OverlapsImage,
                LabelHorizontalAlignment = HorizontalAlignment.Center,
                HorizontalAlignment      = HorizontalAlignment.Right,
                VerticalAlignment        = VerticalAlignment.Bottom,
                Width                    = 144,
                Height                   = 43,
                Margin                   = new Thickness(0, 0, 0, 0)
            };

            EndTurnButton.TouchDown += (s, a) =>
            {
                ChapterMaster.Sector.TurnUpdate();
            };
            Panel.AddChild(EndTurnButton);


            Ledger = new Ledger(1, "ledger_background", new CornerAlign(Corner.BOTTOMRIGHT, 120, 280, topMargin: 10, leftMargin: 2, bottomMargin: 58));
            ChapterMaster.MainScreen.AddChildScreen(Ledger);

            _gameUI.Widgets.Add(Panel);
            _gameUI.InvalidateLayout();
            _gameUI.UpdateLayout();
        }
コード例 #3
0
        private void SetupMainUI()
        {
            _compose.Text = "Compose";
            _bodyView.Clear();
            List <string> _subjects = new List <string>();

            switch (_uiState)
            {
            case 0:     //inbox
                _header.Text = "Inbox";
                _inbox.ClearItems();
                foreach (var message in _email.Inbox.OrderByDescending(x => x.Timestamp))
                {
                    if (_subjects.Contains(message.Subject))
                    {
                        continue;
                    }
                    var item = new ListViewItem
                    {
                        Tag   = message.Subject,
                        Value = $"{message.Subject} - {message.From}"
                    };
                    _inbox.AddItem(item);
                    _subjects.Add(message.Subject);
                }
                _bodyView.AddChild(_inbox);
                break;

            case 1:     //outbox
                _header.Text = "Outbox";
                _outbox.ClearItems();
                foreach (var message in _email.Outbox.OrderByDescending(x => x.Timestamp))
                {
                    if (_subjects.Contains(message.Subject))
                    {
                        continue;
                    }
                    var item = new ListViewItem
                    {
                        Tag   = message.Subject,
                        Value = $"{message.Subject} - {message.To}"
                    };
                    _outbox.AddItem(item);
                    _subjects.Add(message.Subject);
                }
                _bodyView.AddChild(_outbox);
                break;

            case 2:     //view message
                _compose.Text = "Reply";
                _header.Text  = _subject;
                _thread.Clear();
                foreach (var message in _email.GetThread(_subject))
                {
                    var panel = new EmailMessagePanel();
                    panel.Subject = message.Subject;
                    panel.From    = message.From;
                    panel.Message = message.Message;
                    _thread.AddChild(panel);
                }
                _bodyView.AddChild(_thread);
                break;

            case 3:     //compose message
                _header.Text         = "Compose message";
                _compose.Text        = "Send";
                _composeMessage.Text = "";
                _composeSubject.Text = "";
                _composeTo.Text      = "";
                _bodyView.AddChild(_composePanel);
                break;

            case 4:     //compose reply
                _header.Text       = _subject;
                _compose.Text      = "Send";
                _replyMessage.Text = "";
                _bodyView.AddChild(_replyPanel);
                var addresses = new List <string>();
                foreach (var message in _email.GetThread(_subject))
                {
                    if (message.From == _email.MyEmailAddress || addresses.Contains(message.From))
                    {
                        continue;
                    }
                    addresses.Add(message.From);
                }
                _addresses = addresses.ToArray();
                break;
            }
        }
コード例 #4
0
        public void Update(GameTime gameTime)
        {
            foreach (Hero h in rm.heroes)
            {
                heroHp.Text = "Health: " + h.health;
                heroMp.Text = "Mana: " + h.mana;
                round.Text  = "Round: " + h.Round;
                if (h.yourTurn)
                {
                    attack.Disabled = false;
                    spells.Disabled = false;
                    if (h.mana >= h.manaCost1)
                    {
                        spell1.Disabled = false;
                    }
                    if (h.mana >= h.manaCost2)
                    {
                        spell2.Disabled = false;
                    }
                    if (h.mana >= h.manaCost3)
                    {
                        spell3.Disabled = false;
                    }
                    if (h.mana >= h.manaCost4)
                    {
                        spell4.Disabled = false;
                    }
                }
                else
                {
                    attack.Disabled = true;
                    spells.Disabled = true;
                    spell1.Disabled = true;
                    spell2.Disabled = true;
                    spell3.Disabled = true;
                    spell4.Disabled = true;
                }

                foreach (Monster m in rm.monstersInCombat)
                {
                    monsterHp.Text = "Health: " + m.Health;

                    if (!m.IsAlive)
                    {
                        if (!doThisOnce)
                        {
                            exitBattle = new Panel(new Vector2(g.Width / 4, g.Height / 4), PanelSkin.Simple, Anchor.Center);
                            UserInterface.Active.AddEntity(exitBattle);
                            exitBattle.FillColor   = Color.DimGray;
                            exitBattle.ShadowColor = Color.Black;
                            exit = new Button("Exit", ButtonSkin.Default, Anchor.Center, new Vector2(g.Width / 8, g.Height / 8));
                            exitBattle.AddChild(exit);
                            exit.FillColor   = Color.DarkRed;
                            exit.ShadowColor = Color.Black;
                            doThisOnce       = true;
                        }

                        exit.OnClick = (Entity start) =>
                        {
                            //attack.Disabled = false;
                            //spells.Disabled = false;
                            panel1.Visible     = false;
                            exitBattle.Visible = false;
                            doThisOnce         = true;
                            h.currentExp      += m.ExpGiven;
                            rm.monstersInCombat.Remove(m);
                            g.state = GameState.Game;
                        };
                    }
                }
            }
        }
コード例 #5
0
        private void CreateScene()
        {
            Panel panel = new Panel(new Point(500, 400));

            panel.Alignment        = Alignment.Center;
            panel.Border.Thickness = 0;
            this.scene.AddChild(panel);

            Label headLine = new Label(GameConfig.Fonts.Large, "Settings Menu");

            headLine.Alignment         = Alignment.Top;
            headLine.PreferredPosition = new Point(0, -60);
            headLine.Border.Thickness  = 0;
            panel.AddChild(headLine);

            this.combobox = new Combobox(GameConfig.Fonts.Medium);
            this.combobox.Selector.TextBlock.Text = "Select";
            //this.combobox.Selector.TextBlock.Alignment = Alignment.Center;
            this.combobox.PreferredSize           = new Point(200, 35);
            this.combobox.Alignment               = Alignment.TopRight;
            this.combobox.PreferredPosition       = new Point(0, 50);
            this.combobox.ElementList.ElementSize = 30;
            foreach (var element in this.resolutions)
            {
                // only add options which are smaller than screensize
                if (element.Value.X < WindowSettings.ScreenResolution.X && element.Value.Y < WindowSettings.ScreenResolution.Y)
                {
                    this.combobox.ElementList.AddElement(this.ToResolutionString(element.Value));
                }
            }
            panel.AddChild(this.combobox);
            // todo: show listbox on top

            this.borderlessCheck                   = new Checkbox(GameConfig.Fonts.Medium, "Disabled");
            this.borderlessCheck.Alignment         = Alignment.TopRight;
            this.borderlessCheck.PreferredPosition = new Point(0, 100);
            panel.AddChild(this.borderlessCheck);

            this.applyChanges           = new Button(GameConfig.Fonts.Medium, "Apply Changes");
            this.applyChanges.Alignment = Alignment.BottomLeft;
            panel.AddChild(this.applyChanges);

            this.back           = new Button(GameConfig.Fonts.Medium, "Back");
            this.back.Alignment = Alignment.Bottom;
            panel.AddChild(this.back);

            this.defaultChanges           = new Button(GameConfig.Fonts.Medium, "Reset to Default");
            this.defaultChanges.Alignment = Alignment.BottomRight;
            panel.AddChild(this.defaultChanges);

            this.currentResLabel = new TextBlock(GameConfig.Fonts.Medium, "Current Resolution:");
            this.currentResLabel.PreferredPosition = new Point(0, 0);
            panel.AddChild(this.currentResLabel);

            this.currentResolutionText                   = new TextBlock(GameConfig.Fonts.Medium, "1289x720");
            this.currentResolutionText.Alignment         = Alignment.TopRight;
            this.currentResolutionText.PreferredPosition = new Point(0, 0);
            panel.AddChild(this.currentResolutionText);

            this.comboboxLabel                   = new TextBlock(GameConfig.Fonts.Medium, "Resolution:");
            this.comboboxLabel.Alignment         = Alignment.TopLeft;
            this.comboboxLabel.PreferredPosition = new Point(0, 50);
            panel.AddChild(this.comboboxLabel);

            this.borderlessLabel = new TextBlock(GameConfig.Fonts.Medium, "Borderless Fullscreen:");
            this.borderlessLabel.PreferredPosition = new Point(0, 100);
            panel.AddChild(this.borderlessLabel);

            this.netServerLabel = new TextBlock(GameConfig.Fonts.Medium, "Network Server:");
            this.netServerLabel.PreferredPosition = new Point(0, 150);
            panel.AddChild(this.netServerLabel);

            this.netServerTextbox = new TextBox(GameConfig.Fonts.Medium, UserConfig.Instance.DefaultServer);
            this.netServerTextbox.PreferredSize     = new Point(200, 35);
            this.netServerTextbox.Alignment         = Alignment.TopRight;
            this.netServerTextbox.PreferredPosition = new Point(0, 150);
            panel.AddChild(this.netServerTextbox);

            this.netPortLabel = new TextBlock(GameConfig.Fonts.Medium, "Network Port:");
            this.netPortLabel.PreferredPosition = new Point(0, 200);
            panel.AddChild(this.netPortLabel);

            this.netPortTextbox = new TextBox(GameConfig.Fonts.Medium, UserConfig.Instance.DefaultPort.ToString());
            this.netPortTextbox.PreferredSize     = new Point(200, 35);
            this.netPortTextbox.Alignment         = Alignment.TopRight;
            this.netPortTextbox.PreferredPosition = new Point(0, 200);
            panel.AddChild(this.netPortTextbox);

            this.unsavedChangesText                   = new TextBlock(GameConfig.Fonts.Small, "Unsaved Changes");
            this.unsavedChangesText.Alignment         = Alignment.BottomLeft;
            this.unsavedChangesText.PreferredPosition = new Point(0, -50);
            this.unsavedChangesText.SetVisible(false);
            panel.AddChild(this.unsavedChangesText);
        }
コード例 #6
0
ファイル: CarBuilder.cs プロジェクト: jo411/CarPrototype
        void addSelectorUI()
        {
            Panel panel = new Panel(new Vector2(1200, 450), PanelSkin.Default, Anchor.BottomCenter);

            this.UserInterface.AddEntity(panel);

            panel.AddChild(new Header("CAR BUILDER"));


            SelectList bodySelect = new SelectList(new Vector2(350, 150), Anchor.Center, new Vector2(0, 0));

            //bodyDrop.DefaultText = ("Choose a Body");
            foreach (string text in gameState.carState.getBodyStrings())
            {
                bodySelect.AddItem(text);
            }

            bodySelect.ToolTipText = ("Choose a Body");

            bodySelect.OnValueChange = (Entity e) =>
            {
                gameState.carState.updateSelectedBody(bodySelect.SelectedIndex);
                addCarModelAndCamera();
                updateStatDisplay();
            };


            SelectList frontWheelSelect = new SelectList(new Vector2(300, 150), Anchor.CenterLeft, new Vector2(0, 0));

            //frontWheelDrop.DefaultText = ("Choose Front Wheels");
            foreach (string text in gameState.carState.getWheelStrings())
            {
                frontWheelSelect.AddItem(text);
            }
            frontWheelSelect.ToolTipText = ("Choose Front Wheels");

            frontWheelSelect.OnValueChange = (Entity e) =>
            {
                gameState.carState.updateSelectedWheel(frontWheelSelect.SelectedIndex, true);
                addCarModelAndCamera();
                updateStatDisplay();
            };

            SelectList backWheelSelect = new SelectList(new Vector2(300, 150), Anchor.CenterRight, new Vector2(0, 0));

            //backWheelDrop.DefaultText = ("Choose Back Wheels");
            foreach (string text in gameState.carState.getWheelStrings())
            {
                backWheelSelect.AddItem(text);
            }
            backWheelSelect.ToolTipText = ("Choose Back Wheels");

            backWheelSelect.OnValueChange = (Entity e) =>
            {
                gameState.carState.updateSelectedWheel(backWheelSelect.SelectedIndex, false);
                addCarModelAndCamera();
                updateStatDisplay();
            };

            int       labelOffsetY = -100;
            int       labelOffsetX = 70;
            Color     labelColor   = Color.Plum;
            Paragraph bodyLabel    = new Paragraph("Body", Anchor.Center, new Vector2(80, 20), new Vector2(0, labelOffsetY));

            bodyLabel.FillColor = labelColor;

            Paragraph fwLabel = new Paragraph("Front Wheels", Anchor.CenterLeft, new Vector2(200, 20), new Vector2(labelOffsetX, labelOffsetY));

            fwLabel.FillColor = labelColor;

            Paragraph bwLabel = new Paragraph("Back Wheels", Anchor.CenterRight, new Vector2(200, 20), new Vector2(labelOffsetX, labelOffsetY));

            bwLabel.FillColor = labelColor;

            panel.AddChild(bodyLabel);
            panel.AddChild(fwLabel);
            panel.AddChild(bwLabel);

            panel.AddChild(bodySelect);
            panel.AddChild(frontWheelSelect);
            panel.AddChild(backWheelSelect);

            Button closeTut = new Button("Click to play!", ButtonSkin.Fancy, Anchor.BottomCenter);

            closeTut.OnClick = (Entity btn) =>
            {
                btn.Parent.Visible = false;
                gameState.changeScene(State.GAME);
            };
            panel.AddChild(closeTut);
            Button randomButton = new Button("Random Car", ButtonSkin.Fancy, Anchor.TopLeft, new Vector2(350, 50));

            randomButton.OnClick = (Entity btn) =>
            {
                gameState.carState.buildRandomCar();
                bodySelect.SelectedIndex       = (int)gameState.carState.body;
                frontWheelSelect.SelectedIndex = (int)gameState.carState.frontWheels;
                backWheelSelect.SelectedIndex  = (int)gameState.carState.backWheels;
                addCarModelAndCamera();
                updateStatDisplay();
            };
            panel.AddChild(randomButton);

            //Panel wip = new Panel(new Vector2(700, 450),PanelSkin.Default, Anchor.CenterLeft,new Vector2(0,-100));

            //wip.AddChild(new Header("--Woah slow down there!--"));
            //panel.AddChild(new HorizontalLine());
            //var tutorialText = new Paragraph("This feature isn't quite ready yet!\n\n Here you would build your car from various parts.\n\nEach part affects how your car handles and how much damage it takes.\n\n For now go ahead and click play, we'll make you a random car.");
            //wip.AddChild(tutorialText);
            //UserInterface.AddEntity(wip);
        }
コード例 #7
0
 private void SetDescriptionPanel(out Panel descriptionPanel, float height)
 {
     descriptionPanel = new Panel(new Vector2(400, height), anchor: Anchor.AutoInline);
     descriptionPanel.AddChild(new Header("Description"));
     descriptionParagraphs.Add((Paragraph)descriptionPanel.AddChild(new Paragraph("Name: ", scale: 0.6f)));
     descriptionParagraphs.Add((Paragraph)descriptionPanel.AddChild(new Paragraph("Map: ", scale: 0.6f)));
     descriptionParagraphs.Add((Paragraph)descriptionPanel.AddChild(new Paragraph("Use fixed start point: ", scale: 0.6f)));
     descriptionParagraphs.Add((Paragraph)descriptionPanel.AddChild(new Paragraph("Live player: ", scale: 0.6f)));
     descriptionParagraphs.Add((Paragraph)descriptionPanel.AddChild(new Paragraph("Use Evolution: ", scale: 0.6f)));
     descriptionParagraphs.Add((Paragraph)descriptionPanel.AddChild(new Paragraph("Can use history: ", scale: 0.6f)));
     descriptionParagraphs.Add((Paragraph)descriptionPanel.AddChild(new Paragraph("Can use player AI: ", scale: 0.6f)));
     descriptionParagraphs.Add((Paragraph)descriptionPanel.AddChild(new Paragraph("Evolution frequency: ", scale: 0.6f)));
     descriptionParagraphs.Add((Paragraph)descriptionPanel.AddChild(new Paragraph("Use RF: ", scale: 0.6f)));
     descriptionParagraphs.Add((Paragraph)descriptionPanel.AddChild(new Paragraph("Is maintaining secrecy: ", scale: 0.6f)));
     descriptionParagraphs.Add((Paragraph)descriptionPanel.AddChild(new Paragraph("Can affect player: ", scale: 0.6f)));
     descriptionParagraphs.Add((Paragraph)descriptionPanel.AddChild(new Paragraph("Resource fitting frequency: ", scale: 0.6f)));
     descriptionParagraphs.Add((Paragraph)descriptionPanel.AddChild(new Paragraph("Build city score: ", scale: 0.6f)));
     descriptionParagraphs.Add((Paragraph)descriptionPanel.AddChild(new Paragraph("Build unit score: ", scale: 0.6f)));
     descriptionParagraphs.Add((Paragraph)descriptionPanel.AddChild(new Paragraph("Discover tile score: ", scale: 0.6f)));
     descriptionParagraphs.Add((Paragraph)descriptionPanel.AddChild(new Paragraph("Destroy city score: ", scale: 0.6f)));
     descriptionParagraphs.Add((Paragraph)descriptionPanel.AddChild(new Paragraph("Destroy unit score: ", scale: 0.6f)));
     descriptionParagraphs.Add((Paragraph)descriptionPanel.AddChild(new Paragraph("Number of turns: ", scale: 0.6f)));
 }
コード例 #8
0
        public void Game(InventoryManager im)
        {
            foreach (Monster m in rm.monstersInCombat)
            {
                if (!m.isAlive)
                {
                    combatPanel.Visible = false;
                    exitBattle.Visible  = false;
                }
            }
            // Stats Panel
            statsPanel = new Panel(new Vector2(g.Width / 6, (g.Height / 9) + 4), PanelSkin.Simple, Anchor.TopLeft);
            UserInterface.Active.AddEntity(statsPanel);
            statsPanel.FillColor   = Color.DimGray;
            statsPanel.ShadowColor = Color.Black;
            // Inventory Panel
            inventoryButton = new Button("(I)nventory", ButtonSkin.Default, Anchor.TopCenter, new Vector2(g.Width / 6, g.Height / 16));
            UserInterface.Active.AddEntity(inventoryButton);
            inventoryButton.FillColor   = Color.DarkRed;
            inventoryButton.ShadowColor = Color.Black;
            inventoryPanel = new Panel(new Vector2(g.Width / 2, g.Height / 2), PanelSkin.Default, Anchor.AutoCenter);
            UserInterface.Active.AddEntity(inventoryPanel);
            inventoryPanel.FillColor   = Color.DimGray;
            inventoryPanel.ShadowColor = Color.Black;
            inventoryPanel.Visible     = false;
            inventoryPanel.Draggable   = true;
            // Death Screen Panel
            gameOverPanel = new Panel(new Vector2(g.Width / 4, (g.Height / 4)), PanelSkin.Simple, Anchor.AutoCenter);
            UserInterface.Active.AddEntity(gameOverPanel);
            gameOver = new Label("Game Over!", Anchor.TopCenter, new Vector2(200, 100));
            gameOverPanel.AddChild(gameOver);
            exitgoButton = new Button("Exit", ButtonSkin.Default, Anchor.BottomCenter, new Vector2(200, 100));
            gameOverPanel.AddChild(exitgoButton);
            gameOverPanel.Visible = false;

            // Stats Panel Extras
            foreach (Hero h in rm.heroes)
            {
                level = new Label("Level: " + h.level, Anchor.TopCenter);
                statsPanel.AddChild(level);
                health = new Label("Health: " + h.health, Anchor.Center);
                statsPanel.AddChild(health);
                mana = new Label("Mana: " + h.mana, Anchor.BottomCenter);
                statsPanel.AddChild(mana);
            }

            // Inventory Panel Extras
            iStats             = new Header("Stats", Anchor.TopLeft, new Vector2(-350, 0));
            iStats.FillColor   = Color.DarkRed;
            iStats.ShadowColor = Color.Black;
            inventoryPanel.AddChild(iStats);
            iEq             = new Header("Equipment", Anchor.TopCenter);
            iEq.FillColor   = Color.DarkRed;
            iEq.ShadowColor = Color.Black;
            inventoryPanel.AddChild(iEq);
            iInv             = new Header("Inventory", Anchor.TopRight, new Vector2(-300, 0));
            iInv.FillColor   = Color.DarkRed;
            iInv.ShadowColor = Color.Black;
            inventoryPanel.AddChild(iInv);
            iHL = new HorizontalLine(Anchor.TopCenter, new Vector2(0, 50));
            inventoryPanel.AddChild(iHL);
            inventoryItems             = new SelectList(new Vector2(300, 300), Anchor.TopRight, new Vector2(0, 100));
            inventoryItems.FillColor   = Color.DimGray;
            inventoryItems.ShadowColor = Color.Black;
            inventoryPanel.AddChild(inventoryItems);
            equipmentItems             = new SelectList(new Vector2(300, 300), Anchor.TopCenter, new Vector2(0, 100));
            equipmentItems.FillColor   = Color.DimGray;
            equipmentItems.ShadowColor = Color.Black;
            inventoryPanel.AddChild(equipmentItems);
            foreach (Hero h in rm.heroes)
            {
                sHealth   = new Label("Health: " + h.health + "/" + h.maxHealth, Anchor.TopLeft, new Vector2(250, 20), new Vector2(0, 100));
                sMana     = new Label("Mana: " + h.mana + "/" + h.maxMana, Anchor.TopLeft, new Vector2(250, 20), new Vector2(0, 120));
                sStr      = new Label("Strength: " + h.strength, Anchor.TopLeft, new Vector2(250, 20), new Vector2(0, 140));
                sInt      = new Label("Intelligence: " + h.intelligence, Anchor.TopLeft, new Vector2(250, 20), new Vector2(0, 160));
                sAgi      = new Label("Agility: " + h.agility, Anchor.TopLeft, new Vector2(250, 20), new Vector2(0, 180));
                attribute = new Label("Attribute points: " + h.attributePoint, Anchor.TopLeft, new Vector2(250, 20), new Vector2(0, 200));
                rank1     = new Label(h.spell1Name + ": " + h.spell1Rank, Anchor.TopLeft, new Vector2(250, 20), new Vector2(0, 270));
                rank2     = new Label(h.spell2Name + ": " + h.spell2Rank, Anchor.TopLeft, new Vector2(250, 20), new Vector2(0, 290));
                rank3     = new Label(h.spell3Name + ": " + h.spell3Rank, Anchor.TopLeft, new Vector2(250, 20), new Vector2(0, 310));
                rank4     = new Label(h.spell4Name + ": " + h.spell4Rank, Anchor.TopLeft, new Vector2(250, 20), new Vector2(0, 330));
                skill     = new Label("Skill points: " + h.skillPoint, Anchor.TopLeft, new Vector2(250, 20), new Vector2(0, 350));
            }
            inventoryPanel.AddChild(sHealth);
            inventoryPanel.AddChild(sMana);
            inventoryPanel.AddChild(sStr);
            inventoryPanel.AddChild(sInt);
            inventoryPanel.AddChild(sAgi);
            inventoryPanel.AddChild(attribute);
            inventoryPanel.AddChild(rank1);
            inventoryPanel.AddChild(rank2);
            inventoryPanel.AddChild(rank3);
            inventoryPanel.AddChild(rank4);
            inventoryPanel.AddChild(skill);


            // Inventory Panel Events
            inventoryButton.OnClick = (Entity start) =>
            {
                if (inventoryPanel.Visible == true)
                {
                    inventoryPanel.Visible = false;
                }
                else
                {
                    inventoryPanel.Visible = true;
                }
            };
            foreach (Hero h in rm.heroes)
            {
                sHealth.OnClick = (Entity entity) =>
                {
                    if (h.attributePoint > 0)
                    {
                        h.health         += 10;
                        h.maxHealth      += 10;
                        h.attributePoint -= 1;
                    }
                };

                sMana.OnClick = (Entity entity) =>
                {
                    if (h.attributePoint > 0)
                    {
                        h.mana           += 10;
                        h.maxMana        += 10;
                        h.attributePoint -= 1;
                    }
                };

                sStr.OnClick = (Entity entity) =>
                {
                    if (h.attributePoint > 0)
                    {
                        h.strength       += 1;
                        h.attributePoint -= 1;
                    }
                };

                sInt.OnClick = (Entity entity) =>
                {
                    if (h.attributePoint > 0)
                    {
                        h.intelligence   += 1;
                        h.attributePoint -= 1;
                    }
                };

                sAgi.OnClick = (Entity entity) =>
                {
                    if (h.attributePoint > 0)
                    {
                        h.agility        += 1;
                        h.attributePoint -= 1;
                    }
                };

                rank1.OnClick = (Entity entity) =>
                {
                    if (h.skillPoint > 0)
                    {
                        h.spell1Rank += 1;
                        h.skillPoint -= 1;
                    }
                };

                rank2.OnClick = (Entity entity) =>
                {
                    if (h.skillPoint > 0)
                    {
                        h.spell2Rank += 1;
                        h.skillPoint -= 1;
                    }
                };

                rank3.OnClick = (Entity entity) =>
                {
                    if (h.skillPoint > 0)
                    {
                        h.spell3Rank += 1;
                        h.skillPoint -= 1;
                    }
                };

                rank4.OnClick = (Entity entity) =>
                {
                    if (h.skillPoint > 0)
                    {
                        h.spell4Rank += 1;
                        h.skillPoint -= 1;
                    }
                };
            }

            //Game Over Screen Events
            exitgoButton.OnClick = (Entity start) =>
            {
                g.Exit();
            };
        }
コード例 #9
0
        public void OpenSystemScreen(ViewController view, int systemId, Desktop desktop)
        {
            if (!view.PlanetScreenOpen)
            {
                //SystemScreen planetsScreen = new SystemScreen(1, "systemscreen", systemId, new SystemScreenAlign(ChapterMaster.MainScreen.align,systemId));
                //ChapterMaster.MainScreen.AddChildScreen(planetsScreen);

                var SystemWindow = new Window
                {
                    Background = new TextureRegion(Assets.GetTexture("systemscreen" + Planets.Count)),
                    Title      = name,
                    Width      = 560,
                    Height     = 560
                };

                SystemWindow.Closed += (s, e) =>
                {
                    view.PlanetScreenOpen = false;
                    view.openSystem       = -1;
                };

                var Panel = new Panel
                {
                };


                var System = new Image
                {
                    Background = new TextureRegion(Assets.SystemTextures[color]),
                    Width      = 128,
                    Height     = 128,
                    Margin     = new Thickness((560 / 320) * 50 - Constants.SystemSize / 2, 138, 0, 0)
                };

                Panel.AddChild(System);

                // Add Planets

                for (int i = 0; i < Planets.Count; i++)
                {
                    var PlanetButton = new ImageButton
                    {
                        Background = new TextureRegion(Assets.PlanetTextures[Planet.TypeToTexture(Planets[i].Type)]),
                        OverImage  = new TextureRegion(Assets.PlanetTextures[Planet.TypeToTexture(Planets[i].Type)]),
                        Width      = 32,
                        Height     = 32,
                        Margin     = new Thickness(222 + 64 * i, 180, 0, 0)
                    };

                    PlanetButton.TouchDown += (s, e) =>
                    {
                        Planets[i - 1].OpenPlanetScreen(view, desktop, this);
                    };

                    var PlanetLabel = new Label
                    {
                        Text   = Constants.PlanetNames[i],
                        Margin = new Thickness(222 + 64 * i + 16, 212)
                    };

                    Debug.WriteLine("planet i: " + i);
                    Panel.AddChild(PlanetLabel);
                    Panel.AddChild(PlanetButton);
                }


                SystemWindow.Content = Panel;

                SystemWindow.ShowModal(desktop);

                //return planetsScreen;
            }
            //return null;
        }
コード例 #10
0
ファイル: Game1.cs プロジェクト: Whoudini/GAME
        protected void InitExamplesAndUI()
        {
            bool initExamples = true;

            // add previous example button
            previousExampleButton         = new Button("Back", ButtonSkin.Default, Anchor.BottomCenter, new Vector2(300, 50));
            previousExampleButton.OnClick = (Entity btn) => { this.PreviousExample(); };
            UserInterface.Active.AddEntity(previousExampleButton);

            // add new scenario button
            nextExampleButton         = new Button("New Scenario", ButtonSkin.Default, Anchor.TopCenter, new Vector2(300, 50));
            nextExampleButton.OnClick = (Entity btn) => { this.NextExample(); };

            // add new hero button
            nextExampleButton1         = new Button("Embark", ButtonSkin.Default, Anchor.BottomCenter, new Vector2(300, 50));
            nextExampleButton1.OnClick = (Entity btn) => { this.NextExample(); };
            spriteBatch.Begin();
            foreach (Tile t in tileset)
            {
                t.Draw(spriteBatch);
            }
            spriteBatch.End();

            // add exit button
            Button exitBtn = new Button("Exit", anchor: Anchor.BottomCenter, size: new Vector2(300, 50));

            exitBtn.OnClick = (Entity entity) => { Exit(); };


            if (initExamples)
            {
                {
                    int   PanelHeight = 400;
                    Panel Panel       = new Panel(new Vector2(500, PanelHeight + 2), PanelSkin.Simple, Anchor.Center);
                    panels.Add(Panel);
                    UserInterface.Active.AddEntity(Panel);

                    Panel.AddChild(nextExampleButton);
                    Panel.AddChild(exitBtn);
                    {
                        var btn = new Button("Credits", ButtonSkin.Default, Anchor.Center, new Vector2(300, 50));
                        btn.OnClick += (GeonBit.UI.Entities.Entity entity) =>
                        {
                            GeonBit.UI.Utils.MessageBox.ShowMsgBox("Hello World!", "This is a simple message box. It doesn't say much, really.");
                        };
                        Panel.AddChild(btn);
                    }
                }

                {
                    int panelWidth = 730;

                    // create panel and add to list of panels and manager
                    Panel panel = new Panel(new Vector2(panelWidth, 550));
                    panels.Add(panel);

                    UserInterface.Active.AddEntity(panel);

                    // add title and text
                    panel.AddChild(new Header("Create New Character"));
                    panel.AddChild(new HorizontalLine());

                    // create an internal panel to align components better - a row that covers the entire width split into 3 columns (left, center, right)
                    // first the container panel
                    Panel entitiesGroup = new Panel(new Vector2(0, 240), PanelSkin.None, Anchor.AutoCenter);
                    entitiesGroup.Padding = Vector2.Zero;
                    panel.AddChild(entitiesGroup);

                    // now left side
                    Panel leftPanel = new Panel(new Vector2(0.33f, 0), PanelSkin.None, Anchor.TopLeft);
                    leftPanel.Padding = Vector2.Zero;
                    entitiesGroup.AddChild(leftPanel);

                    // right side
                    Panel rightPanel = new Panel(new Vector2(0.33f, 0), PanelSkin.None, Anchor.TopRight);
                    rightPanel.Padding = Vector2.Zero;
                    entitiesGroup.AddChild(rightPanel);

                    // center
                    Panel centerPanel = new Panel(new Vector2(0.33f, 0), PanelSkin.None, Anchor.TopCenter);
                    centerPanel.Padding = Vector2.Zero;
                    entitiesGroup.AddChild(centerPanel);

                    // create a character preview panel
                    centerPanel.AddChild(new Label(@"Preview", Anchor.AutoCenter));
                    Panel charPreviewPanel = new Panel(new Vector2(180, 180), PanelSkin.Simple, Anchor.AutoCenter);
                    charPreviewPanel.Padding = Vector2.Zero;
                    centerPanel.AddChild(charPreviewPanel);

                    // create preview pics of character
                    Image previewImage      = new Image(Content.Load <Texture2D>("example/warrior"), Vector2.Zero, anchor: Anchor.Center);
                    Image previewImageColor = new Image(Content.Load <Texture2D>("example/warrior_color"), Vector2.Zero, anchor: Anchor.Center);
                    Image previewImageSkin  = new Image(Content.Load <Texture2D>("example/warrior_skin"), Vector2.Zero, anchor: Anchor.Center);
                    charPreviewPanel.AddChild(previewImage);
                    charPreviewPanel.AddChild(previewImageColor);
                    charPreviewPanel.AddChild(previewImageSkin);

                    // add skin tone slider
                    Slider skin = new Slider(0, 10, new Vector2(0, -1), SliderSkin.Default, Anchor.Auto);
                    skin.OnValueChange = (Entity entity) =>
                    {
                        Slider slider = (Slider)entity;
                        int    alpha  = (int)(slider.GetValueAsPercent() * 255);
                        previewImageSkin.FillColor = new Color(60, 32, 25, alpha);
                    };
                    skin.Value = 5;
                    charPreviewPanel.AddChild(skin);

                    // create the class selection list
                    leftPanel.AddChild(new Label(@"Class", Anchor.AutoCenter));
                    SelectList classTypes = new SelectList(new Vector2(0, 208), Anchor.Auto);
                    classTypes.AddItem("Warrior");
                    classTypes.AddItem("Mage");
                    classTypes.AddItem("Ranger");
                    classTypes.AddItem("Monk");
                    classTypes.SelectedIndex = 0;
                    leftPanel.AddChild(classTypes);
                    classTypes.OnValueChange = (Entity entity) =>
                    {
                        string texture = ((SelectList)(entity)).SelectedValue.ToLower();
                        previewImage.Texture      = Content.Load <Texture2D>("example/" + texture);
                        previewImageColor.Texture = Content.Load <Texture2D>("example/" + texture + "_color");
                        previewImageSkin.Texture  = Content.Load <Texture2D>("example/" + texture + "_skin");
                    };

                    // create color selection buttons
                    rightPanel.AddChild(new Label(@"Color", Anchor.AutoCenter));
                    Color[] colors        = { Color.White, Color.Red, Color.Green, Color.Blue, Color.Yellow, Color.Purple, Color.Cyan, Color.Brown };
                    int     colorPickSize = 24;
                    foreach (Color baseColor in colors)
                    {
                        rightPanel.AddChild(new LineSpace(0));
                        for (int i = 0; i < 8; ++i)
                        {
                            Color            color           = baseColor * (1.0f - (i * 2 / 16.0f)); color.A = 255;
                            ColoredRectangle currColorButton = new ColoredRectangle(color, Vector2.One * colorPickSize, Anchor.AutoInline);
                            currColorButton.Padding = currColorButton.SpaceAfter = currColorButton.SpaceBefore = Vector2.Zero;
                            currColorButton.OnClick = (Entity entity) =>
                            {
                                previewImageColor.FillColor = entity.FillColor;
                            };
                            rightPanel.AddChild(currColorButton);
                        }
                    }
                    panel.AddChild(nextExampleButton1);

                    // add character name, last name, and age
                    // first add the labels
                    entitiesGroup.AddChild(new Label(@"Name: ", Anchor.AutoInline, size: new Vector2(0.4f, -1)));
                    // now add the text inputs

                    // first name
                    TextInput firstName = new TextInput(false, new Vector2(0.4f, -1), anchor: Anchor.Auto);
                    firstName.PlaceholderText = "Name";
                    firstName.Validators.Add(new TextValidatorEnglishCharsOnly(true));
                    firstName.Validators.Add(new OnlySingleSpaces());
                    firstName.Validators.Add(new TextValidatorMakeTitle());
                    entitiesGroup.AddChild(firstName);
                }
                {
                    int   PanelHeight = 400;
                    Panel Panel       = new Panel(new Vector2(500, PanelHeight + 2), PanelSkin.Simple, Anchor.BottomRight);
                    panels.Add(Panel);
                    UserInterface.Active.AddEntity(Panel);
                }
                // init panels and buttons
                UpdateAfterExapmleChange();
            }
            // call base initialize
            base.Initialize();
        }
コード例 #11
0
ファイル: Window.cs プロジェクト: piwi1263/Tinkr
 /// <summary>
 /// Adds a AddChild
 /// </summary>
 /// <param name="child">Control to add</param>
 public override void AddChild(IControl child)
 {
     _pnl.AddChild(child);
 }
コード例 #12
0
        protected override void InitializePreviews()
        {
            Panel.RemoveChildren();
            if (!SelectedCategories.Any())
            {
                return;
            }

            foreach (var a in allActors)
            {
                if (!SelectedCategories.Overlaps(a.Categories))
                {
                    continue;
                }

                if (!string.IsNullOrEmpty(searchFilter) && !a.SearchTerms.Any(s => s.IndexOf(searchFilter, StringComparison.OrdinalIgnoreCase) >= 0))
                {
                    continue;
                }

                var actor = a.Actor;
                var td    = new TypeDictionary();
                td.Add(new OwnerInit(selectedOwner.Name));
                td.Add(new FactionInit(selectedOwner.Faction));
                foreach (var api in actor.TraitInfos <IActorPreviewInitInfo>())
                {
                    foreach (var o in api.ActorPreviewInits(actor, ActorPreviewType.MapEditorSidebar))
                    {
                        td.Add(o);
                    }
                }

                try
                {
                    var item = ScrollItemWidget.Setup(ItemTemplate,
                                                      () => { var brush = Editor.CurrentBrush as EditorActorBrush; return(brush != null && brush.Actor == actor); },
                                                      () => Editor.SetBrush(new EditorActorBrush(Editor, actor, selectedOwner, WorldRenderer)));

                    var preview = item.Get <ActorPreviewWidget>("ACTOR_PREVIEW");
                    preview.SetPreview(actor, td);

                    // Scale templates to fit within the panel
                    var scale = 1f;
                    if (scale * preview.IdealPreviewSize.X > ItemTemplate.Bounds.Width)
                    {
                        scale = (ItemTemplate.Bounds.Width - Panel.ItemSpacing) / (float)preview.IdealPreviewSize.X;
                    }

                    preview.GetScale      = () => scale;
                    preview.Bounds.Width  = (int)(scale * preview.IdealPreviewSize.X);
                    preview.Bounds.Height = (int)(scale * preview.IdealPreviewSize.Y);

                    item.Bounds.Width  = preview.Bounds.Width + 2 * preview.Bounds.X;
                    item.Bounds.Height = preview.Bounds.Height + 2 * preview.Bounds.Y;
                    item.IsVisible     = () => true;

                    item.GetTooltipText = () => a.Tooltip;

                    Panel.AddChild(item);
                }
                catch
                {
                    Log.Write("debug", "Map editor ignoring actor {0}, because of missing sprites for tileset {1}.",
                              actor.Name, World.Map.Rules.TileSet.Id);
                    continue;
                }
            }
        }
コード例 #13
0
ファイル: NPCWeapon.cs プロジェクト: hloiseau/DungeonPlanet
        public void ShowMenu()
        {
            _headerMessage = new Header("R pour quitter", Anchor.AutoCenter);
            UserInterface.Active.AddEntity(_headerMessage);
            NPCPanel = new Panel(size: new Vector2(500, 500), skin: PanelSkin.Golden, anchor: Anchor.Center, offset: new Vector2(10, 10));
            UserInterface.Active.AddEntity(NPCPanel);
            NPCPanel.AddChild(new Header("Magasin", Anchor.AutoCenter));
            _redBullet   = new Icon(IconType.OrbRed, Anchor.Auto);
            _blueBullet  = new Icon(IconType.OrbBlue, Anchor.Auto);
            _greenBullet = new Icon(IconType.OrbGreen, Anchor.Auto);

            HorizontalLine hz1 = new HorizontalLine();
            HorizontalLine hz2 = new HorizontalLine();

            Paragraph redText   = new Paragraph("Emflamme l'ennemi");
            Paragraph blueText  = new Paragraph("Des munitions basiques");
            Paragraph greenText = new Paragraph("Ralenti l'ennemi");

            NPCPanel.AddChild(new Label(" 10 $", Anchor.Auto));
            NPCPanel.AddChild(_blueBullet);
            NPCPanel.AddChild(blueText);
            NPCPanel.AddChild(hz1);
            NPCPanel.AddChild(new Label(" 250 $", Anchor.Auto));
            NPCPanel.AddChild(_redBullet);
            NPCPanel.AddChild(redText);
            NPCPanel.AddChild(hz2);
            NPCPanel.AddChild(new Label(" 100 $", Anchor.Auto));
            NPCPanel.AddChild(_greenBullet);
            NPCPanel.AddChild(greenText);
        }
コード例 #14
0
        public ColourInterpolator2()
        {
            panelMaster    = new Panel(masterSize, PanelSkin.None, anchor: Anchor.AutoInline, offset: new Vector2(0, 0));
            panelInside    = new Panel(new Vector2(GlobalFields.PANEL_EDITOR_INSIDE_SIZE.X, 600), PanelSkin.Simple, anchor: Anchor.AutoInline, offset: new Vector2(0, 0));
            checkboxActive = new CheckBox("Active", isChecked: false)
            {
                OnClick = (Entity btn) => { OnClickCheckboxActive(); }
            };

            panelMaster.AddChild(new RichParagraph("{{GOLD}} Colour Interpolator 2"));
            panelMaster.AddChild(checkboxActive);
            panelMaster.AddChild(panelInside);

            panelInside.Visible = false;
            panelMaster.Size    = masterSizeMinimized;

            panelInside.AddChild(new Paragraph("Color 1", Anchor.AutoInline, new Vector2(0, -1)));
            colour1H       = new Paragraph("Hue");
            sliderColour1H = new Slider(0, 360, SliderSkin.Default);
            panelInside.AddChild(colour1H);
            panelInside.AddChild(sliderColour1H);

            colour1S       = new Paragraph("Saturation");
            sliderColour1S = new Slider(0, 100, SliderSkin.Default);
            panelInside.AddChild(colour1S);
            panelInside.AddChild(sliderColour1S);

            colour1L       = new Paragraph("Lightness");
            sliderColour1L = new Slider(0, 100, SliderSkin.Default);
            panelInside.AddChild(colour1L);
            panelInside.AddChild(sliderColour1L);

            panelInside.AddChild(new Paragraph("Color 2", Anchor.AutoInline, new Vector2(0, -1)));
            colour2H             = new Paragraph("Hue");
            sliderColour2H       = new Slider(0, 360, SliderSkin.Default);
            sliderColour2H.Value = 50;
            panelInside.AddChild(colour2H);
            panelInside.AddChild(sliderColour2H);

            colour2S       = new Paragraph("Saturation");
            sliderColour2S = new Slider(0, 100, SliderSkin.Default);
            panelInside.AddChild(colour2S);
            panelInside.AddChild(sliderColour2S);

            colour2L       = new Paragraph("Lightness");
            sliderColour2L = new Slider(0, 100, SliderSkin.Default);
            panelInside.AddChild(colour2L);
            panelInside.AddChild(sliderColour2L);
        }
コード例 #15
0
        public FactionCreatorState(GameManager gameManager, GraphicsDevice graphicsDevice, ContentManager contentManager) : base(gameManager, graphicsDevice, contentManager)
        {
            this.gameManager    = gameManager;
            this.graphicsDevice = graphicsDevice;
            SpriteBatch         = new SpriteBatch(graphicsDevice);
            viewController      = new MenuViewController();

            GameManager.graphics.PreferredBackBufferWidth  = GameManager.window.ClientBounds.Width;
            GameManager.graphics.PreferredBackBufferHeight = GameManager.window.ClientBounds.Height;
            viewController.viewPortWidth  = GameManager.window.ClientBounds.Width;
            viewController.viewPortHeight = GameManager.window.ClientBounds.Height;
            GameManager.graphics.ApplyChanges(); // I'm not questioning why this works.


            _factionCreator = new Desktop();

            var Panel = new Panel {
                Background = new TextureRegion(Assets.GetTexture("faction_creator_background"))
            };

            var BackButtonTexture = new TextureRegion(Assets.GetButton("back"));
            var BackButton        = new ImageButton
            {
                Background          = BackButtonTexture,
                OverImage           = BackButtonTexture,
                Width               = 128,
                Height              = 32,
                VerticalAlignment   = VerticalAlignment.Bottom,
                HorizontalAlignment = HorizontalAlignment.Left,
                Margin              = new Thickness(20, 0, 0, 20)
            };

            BackButton.TouchDown += (s, a) =>
            {
                gameManager.ChangeState(new CampaignPickerState(gameManager, gameManager.GraphicsDevice, gameManager.Content));
            };
            Panel.AddChild(BackButton);

            var StartButtonTexture = new TextureRegion(Assets.GetButton("ui_but_0"));
            var StartButton        = new TextButton
            {
                //Background = StartButtonTexture,
                //OverImage = StartButtonTexture,
                Text                = "Start",
                TextColor           = Color.White,
                Width               = 128,
                Height              = 32,
                VerticalAlignment   = VerticalAlignment.Bottom,
                HorizontalAlignment = HorizontalAlignment.Right,
                Margin              = new Thickness(0, 0, 20, 20)
            };

            StartButton.TouchDown += (s, a) =>
            {
                // Initialize Sector with Faction information.
                playerFaction      = new Faction();
                playerFaction.Name = "TODO"; // TODO
                ChapterMaster.Sector.Factions.Add(playerFaction.Name, playerFaction);
                ChapterMaster.Sector.CurrentFaction = playerFaction.Name;
                gameManager.ChangeState(new GameState(gameManager, gameManager.GraphicsDevice, gameManager.Content, false));
            };
            Panel.AddChild(StartButton);

            var FactionPickerBackground = new TextureRegion(Assets.GetTexture("campaign_picker"));
            var FactionPicker           = new Panel
            {
                Background          = FactionPickerBackground,
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                //Width = 800,
                //Height = 1000,
            };

            FactionPicker.Layout2d.Expresion = "this.w=W.w*0.45;this.h=W.h*0.95"; // TODO SET THIS UP

            var FactionVertical = new VerticalStackPanel
            {
                //HorizontalAlignment = HorizontalAlignment.Center
            };

            var SelectFactionLabel = new Label
            {
                Text                = "Select Chapter",
                Font                = Assets.CaslonAntiqueBoldFSS.GetFont(32),
                TextColor           = new Color(0, 143, 0),
                HorizontalAlignment = HorizontalAlignment.Center,
                //Width = ,
                Height = 80,
                Margin = new Thickness(0, 40, 0, 0)
            };

            FactionVertical.AddChild(SelectFactionLabel);


            var FoundingChaptersLabel = new Label
            {
                Text                = "Founding Chapters",
                Font                = Assets.CaslonAntiqueBoldFSS.GetFont(32),
                TextColor           = new Color(0, 143, 0),
                HorizontalAlignment = HorizontalAlignment.Left,
                //Width = ,
                Height = 80,
                Margin = new Thickness(20, 0, 0, 0)
            };

            FactionVertical.AddChild(FoundingChaptersLabel);

            var FoundingChapters = new Grid
            {
                ColumnSpacing       = 16,
                RowSpacing          = 30,
                ShowGridLines       = false,
                HorizontalAlignment = HorizontalAlignment.Left,
                Margin = new Thickness(15, 0, 0, 0)
            };

            for (int i = 1; i < 10; i++)
            {
                var ChapterTexture = new TextureRegion(Assets.GetIcon("founding_chapter_" + i));

                var ChapterButton = new ImageButton
                {
                    Background = ChapterTexture,
                    OverImage  = ChapterTexture,
                    GridColumn = i - 1
                                 //Width = 32,
                                 //Height = 32,
                };
                ChapterButton.Layout2d.Expresion = "this.w = W.w*0.04; this.h = W.h*0.04";

                ChapterButton.TouchDown += (s, a) =>
                {
                    // TODO: set up faction chosed by player
                };
                FoundingChapters.AddChild(ChapterButton);
            }
            FactionVertical.AddChild(FoundingChapters);

            var SuccessorChaptersLabel = new Label
            {
                Text                = "Successor Chapters",
                Font                = Assets.CaslonAntiqueBoldFSS.GetFont(32),
                TextColor           = new Color(0, 143, 0),
                HorizontalAlignment = HorizontalAlignment.Left,
                //Width = ,
                Height = 80,
                Margin = new Thickness(20, 0, 0, 0)
            };

            FactionVertical.AddChild(SuccessorChaptersLabel);

            var SuccessorChapters = new Grid
            {
                ColumnSpacing       = 16,
                RowSpacing          = 30,
                ShowGridLines       = false,
                HorizontalAlignment = HorizontalAlignment.Left,
                Margin = new Thickness(15, 0, 0, 0)
            };

            for (int i = 1; i < 5; i++)
            {
                var ChapterTexture = new TextureRegion(Assets.GetIcon("successor_chapter_" + i));

                var ChapterButton = new ImageButton
                {
                    Background = ChapterTexture,
                    OverImage  = ChapterTexture,
                    GridColumn = i - 1,
                    //Width = 32,
                    //Height = 32,
                };
                ChapterButton.Layout2d.Expresion = "this.w = W.w*0.04; this.h = W.h*0.04";

                ChapterButton.TouchDown += (s, a) =>
                {
                    // TODO: set up faction chosed by player
                };
                SuccessorChapters.AddChild(ChapterButton);
            }


            FactionVertical.AddChild(SuccessorChapters);


            var CustomFactionsLabel = new Label
            {
                Text                = "Custom Factions",
                Font                = Assets.CaslonAntiqueBoldFSS.GetFont(32),
                TextColor           = new Color(0, 143, 0),
                HorizontalAlignment = HorizontalAlignment.Left,
                //Width = ,
                Height = 80,
                Margin = new Thickness(20, 0, 0, 0)
            };

            FactionVertical.AddChild(CustomFactionsLabel);

            var CustomFactions = new Grid
            {
                ColumnSpacing       = 16,
                RowSpacing          = 30,
                ShowGridLines       = false,
                HorizontalAlignment = HorizontalAlignment.Left,
                Margin = new Thickness(15, 0, 0, 0)
            };

            var CustomFactionButton = new TextButton
            {
                Text      = "Create Marine Chapter",
                TextColor = Color.White,
                Width     = 128,
                Height    = 32,
                //VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left,
                Margin = new Thickness(20, 0, 0, 0)
            };

            CustomFactionButton.TouchDown += (s, e) =>
            {
            };
            CustomFactions.AddChild(CustomFactionButton);

            FactionVertical.AddChild(CustomFactions);


            var OrkKlansLabel = new Label
            {
                Text                = "Ork Klans",
                Font                = Assets.CaslonAntiqueBoldFSS.GetFont(32),
                TextColor           = new Color(0, 143, 0),
                HorizontalAlignment = HorizontalAlignment.Left,
                //Width = ,
                Height = 80,
                Margin = new Thickness(20, 0, 0, 0)
            };

            FactionVertical.AddChild(OrkKlansLabel);

            var OrkKlans = new Grid
            {
                ColumnSpacing       = 16,
                RowSpacing          = 30,
                ShowGridLines       = false,
                HorizontalAlignment = HorizontalAlignment.Left,
                Margin = new Thickness(15, 0, 0, 0)
            };

            FactionVertical.AddChild(OrkKlans);

            //Button exitButton = new Button("back", "", new CornerAlign(Corner.BOTTOMLEFT, 128, 32, 64), Back); //This button does not want to be put into subAlign. Finish adjusting CornerAlign
            //Button startButton = new Button("ui_but_0", "START", new CornerAlign(Corner.BOTTOMRIGHT, 128, 32, rightMargin:64), Start);
            //TextBox factionNameBox = new TextBox("textbox", "Faction Name", new CornerAlign(Corner.TOPLEFT, 250, 50, leftMargin:64,topMargin:20), outOfFocus:FactionName);
            //TextBox homeWorldNameBox = new TextBox("textbox", "Homeworld Name", new CornerAlign(Corner.TOPLEFT, 250, 50, leftMargin:64,topMargin:100), outOfFocus:HomeWorldName);

            FactionPicker.AddChild(FactionVertical);
            Panel.AddChild(FactionPicker);
            _factionCreator.Widgets.Add(Panel);


            _factionCreator.InvalidateLayout();
            _factionCreator.UpdateLayout();
        }
コード例 #16
0
        public void Initialize(GraphicsDevice graphics)
        {
            UIManager.Initialize();
            spriteBatch = new SpriteBatch(graphics);

            UserInterface.SCALE  = 0.7f;
            UIManager.ShowCursor = false;

            panel           = new Panel(new Vector2(500, 600), PanelSkin.Simple, Anchor.TopRight);
            panel.Draggable = false;
            UIManager.AddEntity(panel);



            panel.AddChild(new Paragraph("Test UI"));
            panel.SetPosition(Anchor.TopRight, new Vector2(0, 0));

            panel.AddChild(fps = new Paragraph("fps :" + GameStats.fps_avg));

            panel.AddChild(toggleShader = new CheckBox("Update Shader", Anchor.Auto, null, null, true));
            toggleShader.Scale          = 0.5f;
            toggleShader.OnValueChange  = (Entity entity) =>
            {
                CheckBox cb = (CheckBox)entity;
                GameSettings.g_UpdateShading = cb.Checked;
            };

            CheckBox seamFixToggle;

            panel.AddChild(seamFixToggle = new CheckBox("Fix Seams", Anchor.Auto, null, null, true));

            panel.AddChild(toggleShader = new CheckBox("Rotate Model", Anchor.Auto, null, null, true));
            toggleShader.Scale          = 0.5f;
            toggleShader.OnValueChange  = (Entity entity) =>
            {
                CheckBox cb = (CheckBox)entity;
                GameSettings.s_rotateModel = cb.Checked;
            };

            panel.AddChild(new LineSpace(1));

            Paragraph sliderValue = new Paragraph("Texture resolution: 512");

            panel.AddChild(sliderValue);


            Slider slider = new Slider(1, 12, SliderSkin.Default);

            slider.Value         = 9;
            slider.StepsCount    = 11;
            slider.OnValueChange = (Entity entity) =>
            {
                Slider slid = (Slider)entity;
                GameSettings.g_texResolution = (int)Math.Pow(2, slid.Value);
                sliderValue.Text             = "Texture resolution: " + GameSettings.g_texResolution;
            };
            panel.AddChild(slider);

            Paragraph environmentMap = new Paragraph("ambient intensity: 1.8");

            panel.AddChild(environmentMap);

            Slider envIntensitySlider = new Slider(0, 400, SliderSkin.Default);

            envIntensitySlider.StepsCount    = 400;
            envIntensitySlider.Value         = 180;
            envIntensitySlider.OnValueChange = (Entity entity) =>
            {
                Slider slid = (Slider)entity;
                GameSettings.g_EnvironmentIntensity = slid.Value / 100.0f;
                environmentMap.Text = "ambient intensity: " + GameSettings.g_EnvironmentIntensity;
            };
            panel.AddChild(envIntensitySlider);

            Paragraph seamFixSteps = new Paragraph("seam dilate pixels: 1");

            panel.AddChild(seamFixSteps);

            Slider seamFixStepsSlider = new Slider(0, 6, SliderSkin.Default);

            seamFixStepsSlider.StepsCount    = 6;
            seamFixStepsSlider.Value         = 1;
            seamFixStepsSlider.OnValueChange = (Entity entity) =>
            {
                Slider slid = (Slider)entity;
                GameSettings.g_SeamSearchSteps = slid.Value;
                seamFixSteps.Text = "seam dilate pixels: " + GameSettings.g_SeamSearchSteps;
            };
            panel.AddChild(seamFixStepsSlider);


            seamFixToggle.OnValueChange = (Entity entity) =>
            {
                CheckBox cb = (CheckBox)entity;
                GameSettings.g_FixSeams     = cb.Checked;
                seamFixStepsSlider.Disabled = !cb.Checked;
            };
        }
コード例 #17
0
        protected void Register()
        {
            topPanel.Visible = false;

            Panel temp = new Panel(new Vector2((scrw / 2 + 20), ((scrh / 5) * 4)), PanelSkin.Default, Anchor.Center);

            temp.Padding = Vector2.Zero;
            UserInterface.Active.AddEntity(temp);

            Label label = new Label("Enter your Email:", offset: new Vector2(20, 20));

            temp.AddChild(label);

            TextInput email = new TextInput(false, size: new Vector2(scrw / 2 - 40, (scrh / 12)), offset: new Vector2(20, 0));

            temp.AddChild(email);

            Label label2 = new Label("Enter your Password:"******"Re-Enter your Password:"******"     Read the terms and conditions", offset: new Vector2(20, 10));
            Icon  icon   = new Icon(IconType.Scroll, Anchor.CenterLeft, offset: new Vector2(-30, 0));

            label4.AddChild(icon, false);
            icon.OnClick = (Entity btn) => { terms(); };
            temp.AddChild(label4);



            CheckBox check = new CheckBox("Agree to the terms and conditions", offset: new Vector2(20, 10));

            temp.AddChild(check);

            //login
            login         = new Button("Register", ButtonSkin.Default, Anchor.BottomLeft, new Vector2(((scrw / 5)), scrh / 14), new Vector2(20, 20));
            login.OnClick = (Entity btn) => { if (pass.Value != pass2.Value)
                                              {
                                                  GeonBit.UI.Utils.MessageBox.ShowMsgBox("Password dones not match!", "Please make sure you entered the same password.");
                                              }
                                              if (pass2.Value.Length < 6)
                                              {
                                                  GeonBit.UI.Utils.MessageBox.ShowMsgBox("Password is too short!", "The password must be equal or greater than 6 characters.");
                                              }
                                              if (check.Checked == false)
                                              {
                                                  GeonBit.UI.Utils.MessageBox.ShowMsgBox("Info", "Please agree to the terms and conditions first.");
                                              }
                                              try
                                              {
                                                  new System.Net.Mail.MailAddress(email.Value);
                                              }
                                              catch
                                              {
                                                  GeonBit.UI.Utils.MessageBox.ShowMsgBox("Email invalid!", "Please make sure you entered the correct email.\nEmail format is: [email protected].");
                                              }
                                              this.Reg(email.Value, pass2.Value); };
            temp.AddChild(login);
            //back
            login         = new Button("Back", ButtonSkin.Default, Anchor.BottomRight, new Vector2(((scrw / 5)), scrh / 14), new Vector2(20, 20));
            login.OnClick = (Entity btn) => { temp.RemoveFromParent(); topPanel.Visible = true; };
            temp.AddChild(login); return;
        }
コード例 #18
0
        public void Combat()
        {
            foreach (Hero h in rm.heroes)
            {
                foreach (Monster m in rm.monstersInCombat)
                {
                    exitBattle = new Panel(new Vector2(g.Width / 4, g.Height / 4), PanelSkin.Simple, Anchor.Center);
                    UserInterface.Active.AddEntity(exitBattle);
                    exitBattle.FillColor   = Color.DimGray;
                    exitBattle.ShadowColor = Color.Black;
                    exit = new Button("Exit", ButtonSkin.Default, Anchor.Center, new Vector2(g.Width / 8, g.Height / 8));
                    exitBattle.AddChild(exit);
                    exit.FillColor     = Color.DarkRed;
                    exit.ShadowColor   = Color.Black;
                    exitBattle.Visible = false;
                    combatPanel        = new Panel(new Vector2(g.Width, (g.Height / 4) + 4), PanelSkin.Simple, Anchor.BottomCenter);
                    UserInterface.Active.AddEntity(combatPanel);
                    combatPanel.FillColor   = Color.DimGray;
                    combatPanel.ShadowColor = Color.Black;
                    attack = new Button("Attack", ButtonSkin.Default, Anchor.TopCenter, new Vector2(g.Width / 6, g.Height / 10));
                    combatPanel.AddChild(attack);
                    attack.FillColor   = Color.DarkRed;
                    attack.ShadowColor = Color.Black;
                    heroHp             = new Label("Health: " + h.health, Anchor.TopLeft, new Vector2(200, 10));
                    combatPanel.AddChild(heroHp);
                    heroMp = new Label("Mana: " + h.mana, Anchor.TopLeft, new Vector2(200, 10), new Vector2(0, 25));
                    combatPanel.AddChild(heroMp);
                    monsterHp = new Label("Health: " + m.Health, Anchor.TopRight, new Vector2(100, 10));
                    combatPanel.AddChild(monsterHp);
                    round = new Label("Round: " + h.Round, Anchor.TopCenter, new Vector2(100, 10), new Vector2(0, -25));
                    combatPanel.AddChild(round);
                    spells = new Button("Spells", ButtonSkin.Default, Anchor.BottomCenter, new Vector2(g.Width / 6, g.Height / 10));
                    combatPanel.AddChild(spells);
                    spells.FillColor   = Color.DarkRed;
                    spells.ShadowColor = Color.Black;
                    spell1             = new Button(h.spell1Name, ButtonSkin.Default, Anchor.TopLeft, new Vector2(g.Width / 6, g.Height / 10), new Vector2(150, 0));
                    combatPanel.AddChild(spell1);
                    spell1.FillColor   = Color.DarkRed;
                    spell1.ShadowColor = Color.Black;
                    spell1.Visible     = false;
                    spell2             = new Button(h.spell2Name, ButtonSkin.Default, Anchor.BottomLeft, new Vector2(g.Width / 6, g.Height / 10), new Vector2(150, 0));
                    combatPanel.AddChild(spell2);
                    spell2.FillColor   = Color.DarkRed;
                    spell2.ShadowColor = Color.Black;
                    spell2.Visible     = false;
                    spell3             = new Button(h.spell3Name, ButtonSkin.Default, Anchor.TopRight, new Vector2(g.Width / 6, g.Height / 10), new Vector2(150, 0));
                    combatPanel.AddChild(spell3);
                    spell3.FillColor   = Color.DarkRed;
                    spell3.ShadowColor = Color.Black;
                    spell3.Visible     = false;
                    spell4             = new Button(h.spell4Name, ButtonSkin.Default, Anchor.BottomRight, new Vector2(g.Width / 6, g.Height / 10), new Vector2(150, 0));
                    combatPanel.AddChild(spell4);
                    spell4.FillColor   = Color.DarkRed;
                    spell4.ShadowColor = Color.Black;
                    spell4.Visible     = false;
                }


                attack.OnClick = (Entity start) =>
                {
                    if (h.yourTurn)
                    {
                        h.ManaCostOnce = true;
                        h.attack       = true;
                        if (com.DoThisOnce1)
                        {
                            h.Round        += 1;
                            com.DoThisOnce1 = false;
                        }
                    }
                };

                spells.OnClick = (Entity start) =>
                {
                    if (h.yourTurn)
                    {
                        spell1.Visible = true;
                        spell2.Visible = true;
                        spell3.Visible = true;
                        spell4.Visible = true;
                    }
                };

                spell1.OnClick = (Entity start) =>
                {
                    if (h.yourTurn)
                    {
                        h.ManaCostOnce = true;
                        h.spell1       = true;
                        if (com.DoThisOnce1)
                        {
                            h.Round        += 1;
                            com.DoThisOnce1 = false;
                        }
                    }
                };

                spell2.OnClick = (Entity start) =>
                {
                    if (h.yourTurn)
                    {
                        h.ManaCostOnce = true;
                        h.spell2       = true;
                        if (com.DoThisOnce1)
                        {
                            h.Round        += 1;
                            com.DoThisOnce1 = false;
                        }
                    }
                };

                spell3.OnClick = (Entity start) =>
                {
                    if (h.yourTurn)
                    {
                        h.ManaCostOnce = true;
                        h.spell3       = true;
                        if (com.DoThisOnce1)
                        {
                            h.Round        += 1;
                            com.DoThisOnce1 = false;
                        }
                    }
                };

                spell4.OnClick = (Entity start) =>
                {
                    if (h.yourTurn)
                    {
                        h.ManaCostOnce = true;
                        h.spell4       = true;
                        if (com.DoThisOnce1)
                        {
                            h.Round        += 1;
                            com.DoThisOnce1 = false;
                        }
                    }
                };
            }
        }
コード例 #19
0
        public SS14Window()
        {
            PanelOverride = new StyleBoxFlat
            {
                BackgroundColor = new Color(37, 37, 42)
            };

            // Setup header. Includes the title label and close button.
            var header = new Panel
            {
                AnchorRight  = 1.0f, MarginBottom = 25.0f,
                MouseFilter  = MouseFilterMode.Ignore,
                StyleClasses = { StyleClassWindowHeader }
            };

            header.AddStyleClass(StyleClassWindowHeader);
            TitleLabel = new Label
            {
                ClipText     = true,
                AnchorRight  = 1.0f,
                AnchorBottom = 1.0f,
                MarginRight  = -25.0f,
                MarginLeft   = 5,
                Text         = "Exemplary Window Title Here",
                VAlign       = Label.VAlignMode.Center,
                StyleClasses = { StyleClassWindowTitle }
            };
            CloseButton = new TextureButton
            {
                AnchorLeft   = 1.0f, AnchorRight = 1.0f, AnchorBottom = 1.0f, MarginLeft = -25.0f,
                StyleClasses = { StyleClassWindowCloseButton }
            };
            CloseButton.OnPressed += CloseButtonPressed;
            header.AddChild(TitleLabel);
            header.AddChild(CloseButton);

            // Setup content area.
            Contents = new MarginContainer
            {
                AnchorRight          = 1.0f,
                AnchorBottom         = 1.0f,
                MarginTop            = 30.0f,
                MarginBottomOverride = 10,
                MarginLeftOverride   = 10,
                MarginRightOverride  = 10,
                MarginTopOverride    = 10,
                RectClipContent      = true,
                MouseFilter          = MouseFilterMode.Ignore
            };
            Contents.OnMinimumSizeChanged += _ => MinimumSizeChanged();
            AddChild(header);
            AddChild(Contents);

            AddStyleClass(StyleClassWindowPanel);
            MarginLeft   = 100.0f;
            MarginTop    = 38.0f;
            MarginRight  = 878.0f;
            MarginBottom = 519.0f;

            if (CustomSize != null)
            {
                Size = CustomSize.Value;
            }
        }
コード例 #20
0
        private void InitUI()
        {
            UserInterface.Initialize(XNAContent, BuiltinThemes.editor);
            UserInterface.Active.ShowCursor = false;

            return;

            var realPanel = new Panel(new Vector2(500, 650));

            realPanel.Draggable = true;
            var tabs = new PanelTabs();

            realPanel.AddChild(tabs);
            var MainPanel = tabs.AddTab("Some Tab").panel;
            var tab2      = tabs.AddTab("Some Other Tab");

            //tab2.button.Enabled = false;
            tab2.button.ToolTipText = "This is tab 2.";
            tab2.panel.AddChild(new TextInput()
            {
                CharactersLimit = 16
            });

            UserInterface.Active.AddEntity(realPanel);

            MainPanel.AddChild(new Header("Some Header Text"));
            MainPanel.AddChild(new HorizontalLine());
            MainPanel.AddChild(new Paragraph("This is a UI test."));
            var b = new Button("This is a button!");

            b.ToolTipText = "Some tooltip!";
            MainPanel.AddChild(b);
            MainPanel.AddChild(new Slider(0, 100, SliderSkin.Default)
            {
                Enabled = false
            });
            var toggle = new GeonBit.UI.Entities.CheckBox("Some Check", Anchor.Auto);

            MainPanel.AddChild(toggle);

            var test = new Panel(new Vector2(300, 140), PanelSkin.Fancy, Anchor.AutoInline);

            test.AddChild(new Label("I am a label"));
            test.AddChild(new CheckBox("I'm a box"));
            test.AdjustHeightAutomatically = true;
            MainPanel.AddChild(test);

            var list = new SelectList();

            list.AddItem("Option A");
            list.AddItem("Option B");
            list.AddItem("Option C");
            list.SetHeightBasedOnChildren();
            var drop = new DropDown();

            drop.AddItem("Something A");
            drop.AddItem("Something B");
            drop.AddItem("Something C");
            MainPanel.AddChild(drop);

            var pan2 = new Panel();

            pan2.AddChild(new Header("Some sub-panel"));
            pan2.AddChild(new CheckBox("Cool?")
            {
                OnValueChange = (e) => { Debug.Log((e as CheckBox).Checked.ToString()); }
            });
            tab2.panel.AddChild(pan2, true);
            //pan2.Anchor = Anchor.AutoInline;
            Debug.Log(MainPanel.Padding.ToString());

            MainPanel.AddChild(list);

            MainPanel.Padding = new Vector2(10, 5);
            MainPanel.SetHeightBasedOnChildren();
        }
コード例 #21
0
ファイル: GUI_Interface.cs プロジェクト: KarsaiTamas/zarodoga
        public void Window_Jatek_Beallitasok_Grafika()
        {
            Panel  panel          = new Panel(new Vector2(800, 500));
            Button grafika_button = new Button("Grafika");

            //grafika_button.Locked=true;
            grafika_button.Locked = true;


            grafika_button.SetPosition(Anchor.TopLeft, new Vector2(0, -40));
            grafika_button.Size = new Vector2(190, 40);
            //grafika_button.
            grafika_button.FillColor = new Color(150, 150, 150);
            Header fent_kozep      = new Header("Beallitasok", Anchor.TopCenter);
            Label  felbontas_label = new Label("Felbontas:", Anchor.CenterLeft, new Vector2(230, 70), new Vector2(50));

            felbontas_label.SetPosition(Anchor.AutoInline, new Vector2(10, 95));
            felbontas_label.Scale = 1.5f;
            //felbontas_label.Size = new Vector2(40);
            DropDown felbontas = new DropDown(new Vector2(300, 200));

            felbontas.Anchor = Anchor.CenterRight;
            string[] felbontasok = new string[4];
            felbontasok[0] = "800x600";
            felbontasok[1] = "1240x640";
            felbontasok[2] = "1366x720";
            felbontasok[3] = "1920x1080";
            for (int i = 0; i < felbontasok.Length; i++)
            {
                string[] adatok = felbontasok[i].Split('x');
                if (int.Parse(adatok[0]) <= GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width &&
                    int.Parse(adatok[1]) <= GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height
                    )
                {
                    felbontas.AddItem(felbontasok[i]);
                }
            }

            felbontas.SelectedIndex = Game1.kijelolt_felbontas;
            CheckBox full_screen_check_box = new CheckBox("Teljes kepernyo");

            full_screen_check_box.Checked = true;
            Button Ment   = new Button("Alkalmaz");
            Button Vissza = new Button("Vissza");

            Game1.felbontas = felbontas.SelectedValue;

            UserInterface.Active.AddEntity(panel);



            panel.AddChild(grafika_button);
            panel.AddChild(fent_kozep);

            panel.AddChild(felbontas_label);

            panel.AddChild(felbontas);
            panel.AddChild(full_screen_check_box);
            panel.AddChild(Ment);
            panel.AddChild(Vissza);


            Ment.OnClick += (Entity entity) => {
                string   sor    = felbontas.SelectedValue;
                string[] adatok = sor.Split('x');
                Game1.x_felbontas = int.Parse(adatok[0]);
                Game1.y_felbontas = int.Parse(adatok[1]);
                Game1.ment        = true;
                Game1.felbontas   = felbontas.SelectedValue;
                if (full_screen_check_box.Checked)
                {
                    Game1.full_screen = true;
                }
                else
                {
                    Game1.full_screen = false;
                }
            };

            Vissza.OnClick += (Entity vissza) =>
            {
                Menu_Manager.Jatek_Menu_Eltuntet(Menu_Manager.Menu.Jatek_Beallitasok);
            };


            Window_Keszites(panel);
        }
コード例 #22
0
 /// <summary>
 /// Add an entity to screen.
 /// </summary>
 /// <param name="entity">Entity to add.</param>
 static public void AddEntity(Entity entity)
 {
     _root.AddChild(entity);
 }
コード例 #23
0
        public CampaignPickerState(GameManager gameManager, GraphicsDevice graphicsDevice, ContentManager contentManager) : base(gameManager, graphicsDevice, contentManager)
        {
            this.gameManager    = gameManager;
            this.graphicsDevice = graphicsDevice;
            SpriteBatch         = new SpriteBatch(graphicsDevice);
            viewController      = new MenuViewController();

            GameManager.graphics.PreferredBackBufferWidth  = GameManager.window.ClientBounds.Width;
            GameManager.graphics.PreferredBackBufferHeight = GameManager.window.ClientBounds.Height;
            viewController.viewPortWidth  = GameManager.window.ClientBounds.Width;
            viewController.viewPortHeight = GameManager.window.ClientBounds.Height;
            GameManager.graphics.ApplyChanges(); // I'm not questioning why this works.

            _campaignPicker = new Desktop();

            var Panel = new Panel {
                Background = new TextureRegion(Assets.GetTexture("faction_creator_background"))
            };

            var BackButtonTexture = new TextureRegion(Assets.GetButton("back"));
            var BackButton        = new ImageButton
            {
                Background          = BackButtonTexture,
                OverImage           = BackButtonTexture,
                Width               = 128,
                Height              = 32,
                VerticalAlignment   = VerticalAlignment.Bottom,
                HorizontalAlignment = HorizontalAlignment.Left,
                Margin              = new Thickness(20, 0, 0, 20)
            };

            BackButton.TouchDown += (s, a) =>
            {
                gameManager.ChangeState(new MenuState(gameManager, gameManager.GraphicsDevice, gameManager.Content));
            };

            Panel.AddChild(BackButton);

            var CampaignPicker = new Panel
            {
                Background          = new TextureRegion(Assets.GetTexture("campaign_picker")),
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                Width  = 400,
                Height = 500
            };

            CampaignPicker.Layout2d.Expresion = "this.w=W.w*0.45;this.h=W.h*0.95";

            var CampaignButtons = new VerticalStackPanel
            {
                HorizontalAlignment = HorizontalAlignment.Left
            };

            var SpaceMarineTexture = new TextureRegion(Assets.GetButton("space_marine"));
            var SpaceMarine        = new ImageButton
            {
                Background = SpaceMarineTexture,
                OverImage  = SpaceMarineTexture,
                Width      = 64,
                Height     = 128,
                Margin     = new Thickness(40, 40, 0, 0)
            };

            SpaceMarine.TouchDown += (s, a) =>
            {
                gameManager.ChangeState(new FactionCreatorState(gameManager, gameManager.GraphicsDevice, gameManager.Content));
            };

            CampaignButtons.AddChild(SpaceMarine);
            CampaignPicker.AddChild(CampaignButtons);
            Panel.AddChild(CampaignPicker);
            _campaignPicker.Widgets.Add(Panel);

            _campaignPicker.InvalidateLayout();
            _campaignPicker.UpdateLayout();
        }
コード例 #24
0
        public EmailViewer(WindowSystem _winsys) : base(_winsys)
        {
            Width  = 750;
            Height = 500;

            AddChild(_sidebar);
            AddChild(_body);
            AddChild(_header);
            AddChild(_compose);

            _compose.Click += (o, a) =>
            {
                switch (_uiState)
                {
                case 0:
                case 1:
                    _uiState = 3;
                    SetupMainUI();
                    break;

                case 2:
                    _uiState = 4;
                    SetupMainUI();
                    break;

                case 3:
                    if (string.IsNullOrWhiteSpace(_composeSubject.Text))
                    {
                        _composeSubject.Text = "(No subject)";
                    }
                    if (string.IsNullOrWhiteSpace(_composeTo.Text))
                    {
                        _infobox.Show("No recipient specified.", "Who should we send this message to? You can't specify a blank recipient!");
                        return;
                    }

                    if (string.IsNullOrWhiteSpace(_composeMessage.Text))
                    {
                        _infobox.Show("Blank reply", "You can't send a blank message. Please try again.");
                        return;
                    }
                    _email.SendMessage(_composeTo.Text, _composeSubject.Text, _composeMessage.Text);
                    _uiState = 1;
                    SetupMainUI();
                    break;

                case 4:
                    if (string.IsNullOrWhiteSpace(_replyMessage.Text))
                    {
                        _infobox.Show("Blank reply", "You can't send a blank message. Please try again.");
                        return;
                    }
                    foreach (var address in _addresses)
                    {
                        _email.SendMessage(address, _subject, _replyMessage.Text);
                    }
                    _uiState = 1;
                    SetupMainUI();
                    break;
                }
            };

            _body.AddChild(_bodyView);
            _sidebar.AddChild(_sidebarView);
            _sidebarView.Layout = ListViewLayout.List;
            _inbox.Layout       = ListViewLayout.List;
            _outbox.Layout      = ListViewLayout.List;
            _sidebarView.AddItem(new ListViewItem
            {
                Value = "Inbox",
                Tag   = 0
            });
            _sidebarView.AddItem(new ListViewItem
            {
                Value = "Sent messages",
                Tag   = 1
            });

            _sidebarView.ItemClicked += (item) =>
            {
                _uiState = (int)item.Tag;
                SetupMainUI();
            };
            _inbox.ItemClicked += (item) =>
            {
                _subject = item.Tag.ToString();
                _uiState = 2;
                SetupMainUI();
            };
            _outbox.ItemClicked += (item) =>
            {
                _subject = item.Tag.ToString();
                _uiState = 2;
                SetupMainUI();
            };
            _header.FontStyle = Plex.Engine.Themes.TextFontStyle.Header1;
            SetupMainUI();

            _composePanel.AutoSize = true;
            _composePanel.AddChild(_composeTo);
            _composePanel.AddChild(_composeSubject);
            _composePanel.AddChild(_composeMessage);
            _replyPanel.AutoSize = true;
            _replyPanel.AddChild(_replyMessage);

            _thread.AutoSize = true;
        }
コード例 #25
0
        /// <inheritdoc/>
        public PeacegateSetup(WindowSystem _winsys, AdvancedAudioPlayer tutorial) : base(_winsys)
        {
            _tutorial = tutorial;
            SetWindowStyle(WindowStyle.NoBorder);
            Width  = _winsys.Width;
            Height = _winsys.Height;
            AddChild(_setupTitle);
            AddChild(_setupMode);
            AddChild(_back);
            AddChild(_next);

            _back.Text          = "Back";
            _next.Text          = "Next";
            _setupMode.AutoSize = true;
            _setupMode.Text     = "Introduction";

            _introPanel.AddChild(_introHeader);
            _introPanel.AddChild(_introText);
            _introPanel.AutoSize = true;

            _introHeader.AutoSize  = true;
            _introText.AutoSize    = true;
            _introHeader.FontStyle = Plex.Engine.Themes.TextFontStyle.Header3;

            _introHeader.Text = "Welcome to Peacegate OS.";
            _introText.Text   = @"Peacegate OS is the gateway to the Peacenet. You will use it to run programs, interact with other members of the network, and perform other tasks. It is your primary user interface.

We will guide you through how to use Peacegate OS and the Peacegate Desktop, but first we must set some things up for first use. This installer program will guide you through the setup process and prepare your new environment for you.

Click 'Next' to get started.";

            _back.Click += (o, a) =>
            {
                if (_animState == 6)
                {
                    return;
                }
                _uiState--;
                _animState = 6;
            };
            _next.Click += (o, a) =>
            {
                if (_animState == 6)
                {
                    return;
                }
                _uiState++;
                _animState = 6;
            };

            var wall1 = new PictureBox();
            var wall2 = new PictureBox();

            wall1.Texture = _plexgate.Content.Load <Texture2D>("Desktop/DesktopBackgroundImage");
            wall2.Texture = _plexgate.Content.Load <Texture2D>("Desktop/DesktopBackgroundImage2");
            _wallpapers.AddChild(wall1);
            _wallpapers.AddChild(wall2);

            _desktopWallpaperPanel.AddChild(_desktopHeader);
            _desktopWallpaperPanel.AddChild(_desktopText);
            _desktopWallpaperPanel.AddChild(_wallpapers);

            _desktopHeader.AutoSize         = true;
            _desktopText.AutoSize           = true;
            _desktopWallpaperPanel.AutoSize = true;

            _desktopHeader.FontStyle = Plex.Engine.Themes.TextFontStyle.Header3;
            _desktopHeader.Text      = "Choose a wallpaper";
            _desktopText.Text        = "A wallpaper is displayed in the background of your desktop. You will see it when there are no windows open or anywhere where a window is not being displayed. Right now you only have a small selection of wallpapers, but you will unlock more as you explore the Peacenet.";

            _save.SetValue("desktop.wallpaper", "DesktopBackgroundImage2");

            _wallpapers.SelectedTextureChanged += (texture) =>
            {
                _loadedWallpaper = texture;
                string name = texture.Name.Remove(0, 8);
                _save.SetValue("desktop.wallpaper", name);
                Invalidate(true);
            };

            _accentHeader.FontStyle = Plex.Engine.Themes.TextFontStyle.Header3;
            _accentHeader.AutoSize  = true;
            _accentHeader.Text      = "Choose an accent color";
            _accentText.Text        = "An accent color defines the general color of your Peacegate user interface. The accent color defines the color of buttons, window borders, the Desktop Panels, and other UI elements. You can change this later in your Terminal.";
            _accentText.AutoSize    = true;
            _accentPanel.AutoSize   = true;
            _accentColors.Layout    = ListViewLayout.List;

            var currentAccent = _save.GetValue("theme.accent", PeacenetAccentColor.Blueberry);

            foreach (var accent in Enum.GetNames(typeof(PeacenetAccentColor)))
            {
                var lvitem = new ListViewItem();
                lvitem.Value = accent.ToString();
                lvitem.Tag   = (PeacenetAccentColor)Enum.Parse(typeof(PeacenetAccentColor), accent);
                _accentColors.AddItem(lvitem);
            }
            _accentColors.SelectedIndex         = Array.IndexOf(_accentColors.Items, _accentColors.Items.FirstOrDefault(x => (PeacenetAccentColor)x.Tag == currentAccent));
            _accentColors.SelectedIndexChanged += (o, a) =>
            {
                if (_accentColors.SelectedItem == null)
                {
                    return;
                }
                _save.SetValue <PeacenetAccentColor>("theme.accent", (PeacenetAccentColor)_accentColors.SelectedItem.Tag);
                _pn.AccentColor = (PeacenetAccentColor)_accentColors.SelectedItem.Tag;
            };
            _accentPanel.AddChild(_accentColors);
            _accentPanel.AddChild(_accentHeader);
            _accentPanel.AddChild(_accentText);

            _completeHead.Text      = "You have successfully completed the Peacegate OS Setup.";
            _completeText.Text      = @"That's all the information we need from you for now. Feel free to go back and change what you have set.

You will also be able to change your desktop wallpaper, accent color and other settings at any time in the Peacegate Settings program.

Press 'Finish' to exit Setup and continue system boot. When the system starts up again, you will have to complete the Peacegate GUI Crash Course. Good luck!";
            _completeHead.AutoSize  = true;
            _completeHead.FontStyle = Plex.Engine.Themes.TextFontStyle.Header3;
            _completeText.AutoSize  = true;
            _setupComplete.AddChild(_completeHead);
            _setupComplete.AddChild(_completeText);

            _setupTitle.Text = "Peacegate OS Setup";

            AddChild(_mainView);
        }