Inheritance: MonoBehaviour
        public StoreScreen()
        {
            background = Game1.Instance.gameContent.Load<Texture2D>("GUI/store_screen");
            sideBG = Game1.Instance.gameContent.Load<Texture2D>("GUI/store_side");

            buttons = new List<GuiButton>();
            abilities = new List<IAbility>();
            pitButton = new GuiButton(new Vector2(200, 100), "Sprites/pit_button", 48, 48, 0);
            pitButton.Enabled = true;
            spikeButton = new GuiButton(new Vector2(156, 172), "Sprites/spikes_button", 48, 48, 1);
            spikeButton.Enabled = false;
            spikeButton.Cost = 50;
            spikeButton.Click += new GuiButton.ClickHandler(buyAbility);
            spikeButton.Hover += new GuiButton.HoverHandler(showCost);
            lionButton = new GuiButton(new Vector2(248, 172), "Sprites/lion_button", 48, 48, 2);
            lionButton.Enabled = false;
            lionButton.Cost = 80;
            lionButton.Click += new GuiButton.ClickHandler(buyAbility);
            lionButton.Hover += new GuiButton.HoverHandler(showCost);
            crocButton = new GuiButton(new Vector2(202, 250), "Sprites/CrocButton", 48, 48, 3);
            crocButton.Enabled = false;
            crocButton.Cost = 130;
            crocButton.Click += new GuiButton.ClickHandler(buyAbility);
            crocButton.Hover += new GuiButton.HoverHandler(showCost);
            nukeButton = new GuiButton(new Vector2(202, 350), "Sprites/nuke_button", 48, 48, 4);
            nukeButton.Enabled = false;
            nukeButton.Cost = 250;
            nukeButton.Click += new GuiButton.ClickHandler(buyAbility);
            nukeButton.Hover += new GuiButton.HoverHandler(showCost);
            gameButton = new GuiButton(new Vector2(550, 550), "Sprites/button", 193, 25, 0);
            gameButton.Enabled = true;
            gameButton.ChangeScreens += new GuiButton.GuiHandler(changeScreens);
            gameButton.Hover += new GuiButton.HoverHandler(gameButton_Hover);
            buttons.Add(pitButton);
            buttons.Add(spikeButton);
            buttons.Add(lionButton);
            buttons.Add(crocButton);
            buttons.Add(nukeButton);

            abilityDesc = new List<string>();

            abilityDesc.Add("Pit:\n\nDig a hole and send the\nzebras to their doom.");
            abilityDesc.Add("Spikes:\n\nLay a bed of spikes to\nimpale the creatures inflicting\nsome damage.");
            abilityDesc.Add("Lion:\n\nUnleash the fury of a lion to\nmaul down the zebras.");
            abilityDesc.Add("Crocodile:\n\nSend the zebras to a deathroll\nas they enter the maw of\nthis creature.");
            abilityDesc.Add("Nuke:\n\nEradicate the zebra race as\nwe know it.");

            for (int i = 0; i < buttons.Count; i++)
            {
                if (buttons[i].Enabled)
                {
                    buttons[i].Click += new GuiButton.ClickHandler(addAbilityToBar);
                    buttons[i].Hover += new GuiButton.HoverHandler(changeText);
                    buttons[i].Drag += new GuiButton.DraggingHandler(dragging);
                    buttons[i].Drop += new GuiButton.DropHandler(dropping);
                }
            }

            input = new StoreInput(buttons);
        }
Beispiel #2
0
        private void Initialize()
        {
            buttonCreate = new GuiButton()
            {
                Size = new Vector2(130, 10), Location = new Vector2(0, 10), Text = "New Game"
            };
            buttonCreate.OnClick += new EventHandler <EventArgs>(button_OnClick);
            AddControl(buttonCreate);

            GuiPanel panel = new GuiPanel()
            {
                Size = new Vector2(110, 10), Location = new Vector2(20, 30)
            };

            label = new GuiLabel()
            {
                Size = new Vector2(0, 0), Location = new Vector2(0, 0), Center = true, Text = "", Color = new Vector4(0.7f, 0.7f, 0.7f, 1)
            };
            panel.AddControl(label);
            AddControl(panel);
            buttonGenerator = new GuiButton()
            {
                Size = new Vector2(10, 10), Location = new Vector2(0, 30), Text = "="
            };
            buttonGenerator.OnClick += new EventHandler <EventArgs>(buttonGenerator_OnClick);
            AddControl(buttonGenerator);

            DataBind();
        }
Beispiel #3
0
        public InventoryScreen(string inventoryFont)
        {
            // Set the font for the inventory
            this.inventoryFont = inventoryFont;

            // Add some buttons to add / delete from player inv
            GuiButton buttonAddSword = GuiButton.createButtonWithLabel(new Point(0, 300), "Add Sword", "testure", "font");

            buttonAddSword.ClickHandler = () => inventory.addItem(Item.getItem("sword"));
            addElement(buttonAddSword);

            GuiButton buttonAddPotion = GuiButton.createButtonWithLabel(new Point(buttonAddSword.Bounds.Right + 16, buttonAddSword.Bounds.Top), "Add Potion", "testure", "font");

            buttonAddPotion.ClickHandler = () => inventory.addItem(Item.getItem("hpPot"));
            addElement(buttonAddPotion);

            GuiButton buttonRemoveSword = GuiButton.createButtonWithLabel(new Point(buttonAddSword.Bounds.Left, buttonAddSword.Bounds.Bottom + 16), "Remove Sword", "testure", "font");

            buttonRemoveSword.ClickHandler = () => inventory.removeItem(Item.getItem("sword"));
            addElement(buttonRemoveSword);

            GuiButton buttonRemovePotion = GuiButton.createButtonWithLabel(new Point(buttonAddPotion.Bounds.Left, buttonAddPotion.Bounds.Bottom + 16), "Remove Potion", "testure", "font");

            buttonRemovePotion.ClickHandler = () => inventory.removeItem(Item.getItem("hpPot"));
            addElement(buttonRemovePotion);
        }
Beispiel #4
0
        public AbilityBar(int x, int y)
        {
            abilityList = new List<IAbility>();
            abilityList.Add(new Pit(new Vector2(0, 0)));
            abilityList.Add(new Spike(new Vector2(0, 0)));
            abilityList.Add(new Lion(new Vector2(0, 0)));
            abilityList.Add(new Croc(new Vector2(0, 0)));
            abilityList.Add(new Nuke(new Vector2(0, 0)));

            abilities = new Dictionary<int,IAbility>();
            position = new Vector2(x, y);
            bar = Game1.Instance.gameContent.Load<Texture2D>("Sprites/abilitybar");
            button1 = new GuiButton(new Vector2(300,550), "Sprites/button_template", 48, 48, 0);
            button1.Enabled = true;
            button2 = new GuiButton(new Vector2(348, 550), "Sprites/button_template", 48, 48, 1);
            button2.Enabled = true;
            button3 = new GuiButton(new Vector2(396, 550), "Sprites/button_template", 48, 48, 2);
            button3.Enabled = true;
            button4 = new GuiButton(new Vector2(444, 550), "Sprites/button_template", 48, 48, 3);
            button4.Enabled = true;
            buttonList = new List<GuiButton>();
            buttonList.Add(button1);
            buttonList.Add(button2);
            buttonList.Add(button3);
            buttonList.Add(button4);
        }
Beispiel #5
0
        /**
         * Creates a new ModalList state.
         *
         * @param title Title to display at top of list
         * @param objects A list of objects that will be selected from
         * @param canCancel If true a cancel button is included which will close the window and return a null result
         */
        public ModalOptionListState(string title, List <T> objects, bool canCancel = true)
            : base(title)
        {
            GuiListBox <T> ListBox = new GuiListBox <T>(10, 10, Window.Width - 20, Window.Height - 80);

            foreach (T item in objects)
            {
                ListBox.Add(item);
            }

            GuiButton ConfirmationButton = new GuiButton("OK", 120, 30);

            ConfirmationButton.OnMouseClicked += delegate {
                Result = ListBox.Selected;
                Close();
            };

            GuiButton CancelButton = new GuiButton("Cancel", 120, 30);

            CancelButton.OnMouseClicked += delegate {
                Result = default(T);
                Close();
            };

            Window.Add(ListBox);
            Window.Add(ConfirmationButton, -20, -20);
            if (canCancel)
            {
                Window.Add(CancelButton, 20, -20);
            }
        }
Beispiel #6
0
Datei: Main.cs Projekt: 7474/SRC
        private void picMain_MouseDown(object eventSender, MouseEventArgs eventArgs)
        {
            Program.Log.LogDebug("picMain_MouseDown {0}", JsonConvert.SerializeObject(eventArgs));

            GuiButton Button = ResolveMouseButton(eventArgs);
            var       X      = eventArgs.X;
            var       Y      = eventArgs.Y;

            // 押されたマウスボタンの種類&カーソルの座標を記録
            GUI.MouseButton = Button;
            GUI.MouseX      = X;
            GUI.MouseY      = Y;

            if (GUI.IsGUILocked)
            {
                return;
            }

            if (Button == GuiButton.Left)
            {
                GUI.PrevMapX     = GUI.MapX;
                GUI.PrevMapY     = GUI.MapY;
                GUI.PrevMouseX   = X;
                GUI.PrevMouseY   = Y;
                IsDragging       = true;
                lastDraggPoint.X = X;
                lastDraggPoint.Y = Y;
            }
        }
Beispiel #7
0
        public MenuScreen()
        {
            heroList = new List <Creature>();
            baddudes = new List <Creature>();

            CreatureStats heroStats = new CreatureStats(100, 5, 0.5);

            hero = new Hero("tester", heroStats);

            CreatureStats baddudeStats = new CreatureStats(100, 5, 0.1);

            baddude = new Enemy("tester", baddudeStats);
            baddudes.Add(baddude);
            heroList.Add(hero);
            newBattle = new Battle(heroList, baddudes);
            OngoingBattles.ongoingBattleList.Add(newBattle);

            // Add the Exit button
            GuiButton buttonExit = new GuiButton(new Rectangle(0, 0, 32, 32), "testure");

            buttonExit.ClickHandler = kill;
            addElement(buttonExit);

            // Add an Inventory button
            GuiButton buttonInventory = new GuiButton(new Rectangle(300, 0, 32, 32), "testure");

            buttonInventory.ClickHandler = () => ScreenManager.Instance.selectScreen("inventory");
            addElement(buttonInventory);

            // Set the font
            font = "font";
        }
Beispiel #8
0
        private void createGUI()
        {
            GuiButton stopButton = new GuiButton(890, 870);

            stopButton.OnClickEvent += new GuiButton.ClickEventHandler(stopButton_OnClickEvent);
            this.addActor(stopButton);

            turnButton = new GuiButton(890, 10);
            turnButton.OnClickEvent += new GuiButton.ClickEventHandler(turnButton_OnClickEvent);
            turnButton.setImage("Images\\turndwarf.png");
            turnButton.setImageActive("Images\\turndwarf_a.png");
            this.addActor(turnButton);

            GuiButton dwarf = new GuiButton(20, 0);

            dwarf.receivesInput(false);
            dwarf.setImage("Images\\dwarf.png");
            this.addActor(dwarf);

            GuiButton troll = new GuiButton(20, 70);

            troll.receivesInput(false);
            troll.setImage("Images\\troll.png");
            this.addActor(troll);

            dwarfScore = new GuiText(90, 0);
            dwarfScore.setText("32");
            this.addActor(dwarfScore);

            trollScore = new GuiText(90, 70);
            trollScore.setText("32");
            this.addActor(trollScore);
        }
Beispiel #9
0
        public void displayWin(SIDE type)
        {
            String str = "Dwarves win!";
            String img = "Images\\dwarfbig.png";

            if (type == SIDE.TROLL)
            {
                str = "Trolls win!";
                img = "Images\\trollbig.png";
            }

            GuiText text = new GuiText(300, 300);

            text.setText(str);
            text.setFontColor(Color.Black);
            text.setFontSize(75);
            text.receivesInput(false);
            this.addActor(text);

            GuiButton image = new GuiButton(400, 500);

            image.setImage(img);
            image.receivesInput(false);
            this.addActor(image);
        }
Beispiel #10
0
        private void buttonClicked(object sender, System.EventArgs e)
        {
            try
            {
                if (sender is Button)
                {
                    Button    b  = sender as Button;
                    GuiButton gb = guiController[b.Name] as GuiButton;

                    foreach (string functionName in gb.GetEventHandlers("onclick"))
                    {
                        this.executioner.ExecuteFunction(functionName, gb);
                    }
                }
            }
            catch (Exception x)
            {
                //ZeusDisplayError formError = new ZeusDisplayError(x);
                //formError.ShowDialog(this);
                if (logger != null)
                {
                    logger.LogException(x);
                }
            }
        }
Beispiel #11
0
        public SelectPartyState(bool allowCreateParty = false)
            : base("SelectPartyState")
        {
            Util.Assert(CoM.CharacterList != null, "Select Party State requires character list to be created before initialization.");

            _allowCreateParty = allowCreateParty;

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

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

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

            GuiWindow buttonsWindow = new GuiWindow(500, 80);

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

            GuiButton BackButton = new GuiButton("Back");

            buttonsWindow.Add(BackButton, 0, 0);

            BackButton.OnMouseClicked += delegate {
                Engine.PopState();
            };
        }
Beispiel #12
0
        // Loading the content and setting up said content
        public void LoadContent(ContentManager Content, GraphicsDevice graphicsDevice)
        {
            backgroundManager.LoadContent(Content, graphicsDevice, @"Backgrounds\Clouds\Cloud-Blue-1", @"Backgrounds\Clouds\Cloud-Blue-2");

            HeaderFont = Content.Load <SpriteFont>(@"Fonts\StartMenuHeaderFont");
            HUDFont    = Content.Load <SpriteFont>(@"Fonts\HUDFont");

            HeaderPosition = new Vector2(Game1.ViewPortWidth / 2 - (HeaderFont.MeasureString("Levi Challenge").X / 2), Game1.ViewPortHeight / 20);
            MadeByPosition = new Vector2(10, Game1.ViewPortHeight - HUDFont.MeasureString("Made by Nathan Todd").Y);

            boxHeaderLine = new GuiBox(new Vector2(Game1.ViewPortWidth / 2 - (float)((HeaderFont.MeasureString("Levi Challenge").X * 1.3) / 2), Game1.ViewPortHeight / 6), (int)(HeaderFont.MeasureString("Levi Challenge").X * 1.3), 2, 0, Color.White * 0.4f, Color.White, graphicsDevice);

            btnNewGame  = new GuiButton(new Vector2(Game1.ViewPortWidth / 2 - 168, Game1.ViewPortHeight / 4), 336, 69, 0, Color.Black * 0.3f, Color.YellowGreen * 0.3f, Color.White, Color.White * 0.6f, "New Game", @"Fonts\StartMenuButtonFont");
            btnContinue = new GuiButton(new Vector2(Game1.ViewPortWidth / 2 - 168, Game1.ViewPortHeight / 4 + 69), 336, 69, 0, Color.Black * 0.15f, Color.YellowGreen * 0.15f, Color.White, Color.White * 0.6f, "Continue", @"Fonts\StartMenuButtonFont");
            btnOptions  = new GuiButton(new Vector2(Game1.ViewPortWidth / 2 - 168, Game1.ViewPortHeight / 4 + 138), 336, 69, 0, Color.Black * 0.3f, Color.YellowGreen * 0.3f, Color.White, Color.White * 0.6f, "Options", @"Fonts\StartMenuButtonFont");
            btnExit     = new GuiButton(new Vector2(Game1.ViewPortWidth / 2 - 168, Game1.ViewPortHeight / 4 + 207), 336, 69, 0, Color.Black * 0.15f, Color.YellowGreen * 0.15f, Color.White, Color.White * 0.6f, "Exit", @"Fonts\StartMenuButtonFont");

            guiSystem.Add(boxHeaderLine);
            guiSystem.Add(btnNewGame);
            guiSystem.Add(btnContinue);
            guiSystem.Add(btnOptions);
            guiSystem.Add(btnExit);

            guiSystem.LoadContent(Content, graphicsDevice);
            guiSystem.ButtonIndexUpdate(0);
        }
Beispiel #13
0
        public OverlayMainMenu()
        {
            // Quit button
            buttonQuit = new GuiButton(new Rectangle(new Point(0, MaxOfEmpires.ScreenSize.Y - 200), new Point(300, 200)), "TitleScreen/QuitButton");
            buttonQuit.ClickHandler = () => { buttonQuit.Visible = false; buttonSure.Visible = true; };
            addElement(buttonQuit);

            // Are you sure? button
            buttonSure = new GuiButton(buttonQuit.Bounds, "TitleScreen/AreYouSureButton");
            buttonSure.ClickHandler = () => { MaxOfEmpires.Quit(); };
            buttonSure.Visible      = false;
            addElement(buttonSure);

            // Settings button
            buttonSettings = new GuiButton(new Rectangle(new Point(0, buttonQuit.Bounds.Y - 150), new Point(300, 200)), "TitleScreen/SettingsButton");
            buttonSettings.ClickHandler = () => GameStateManager.SwitchState("settingsMenu", true);
            addElement(buttonSettings);

            // Start button
            buttonStart = new GuiButton(new Rectangle(new Point(0, buttonSettings.Bounds.Y - 150), new Point(300, 200)), "TitleScreen/StartGameButton");
            buttonStart.ClickHandler = () => GameStateManager.SwitchState("economy", true);
            addElement(buttonStart);

            // Set everything to the center of the screen
            CenterElements();
        }
Beispiel #14
0
        public ModalDecisionState(string title, string text)
            : base(title)
        {
            GuiLabel Text = new GuiLabel(10, 10, text, (int)Window.ContentsBounds.width - 20, (int)Window.Height - 20 - 70);

            Text.TextAlign = TextAnchor.MiddleCenter;
            Text.WordWrap  = true;

            GuiButton YesButton = new GuiButton("Yes", 120, 30);

            YesButton.OnMouseClicked += delegate {
                Result = true;
                Close();
                doYes();
            };

            GuiButton NoButton = new GuiButton("No", 120, 30);

            NoButton.OnMouseClicked += delegate {
                Result = false;
                Close();
                doNo();
            };

            Window.Add(Text);
            Window.Add(YesButton, -20, -20);
            Window.Add(NoButton, 20, -20);
        }
Beispiel #15
0
        public BankState() : base("Bank")
        {
            GoldTransfer = new GuiGold();

            MainWindow.Width  = 600;
            MainWindow.Height = 450;

            BankGoldLabel = new GuiLabel(0, 0, "Gold:");
            MainWindow.Add(BankGoldLabel, 20, 20);

            BankGoldValueLabel = new GuiLabel(0, 0, "");
            BankGoldValueLabel.DragDropEnabled = true;
            BankGoldValueLabel.ForceContent(GoldTransfer);
            MainWindow.Add(BankGoldValueLabel, 100, 20);

            InHandGoldLabel = new GuiLabel(0, 0, "In Hand:");
            MainWindow.Add(InHandGoldLabel, 20, 50);

            InHandGoldValueLabel = new GuiLabel(0, 0, "");
            MainWindow.Add(InHandGoldValueLabel, 100, 50);

            DepositButton = new GuiButton("Deposit");
            MainWindow.Add(DepositButton, 20, 80);

            Inventory = new GuiItemInventory(300, 330);
            MainWindow.Add(Inventory, 200, 10);

            DepositButton.OnMouseClicked += delegate {
                Character.GoldInBank += Character.GoldInHand;
                Character.GoldInHand  = 0;
            };

            RepositionControls();
        }
        public OverlayEconomyState()
        {
            // Add the end turn button
            buttonEndTurn = GuiButton.createButtonWithLabel(MaxOfEmpires.overlayPos.ToPoint(), "End turn", null, "font");
            addElement(buttonEndTurn);

            // Add a label showing whose turn it currently is
            labelCurrentPlayer = GuiLabel.createNewLabel(new Vector2(buttonEndTurn.Bounds.Right + 2, buttonEndTurn.Bounds.Top + 2), "Current player: ", "font");
            addElement(labelCurrentPlayer);

            // Add a label telling the player how much money they have
            labelPlayerMoney = GuiLabel.createNewLabel(new Vector2(labelCurrentPlayer.Bounds.Left, labelCurrentPlayer.Bounds.Bottom + 5), "Money: 0G", "font");
            addElement(labelPlayerMoney);

            labelPlayerMoneyPerTurn = GuiLabel.createNewLabel(new Vector2(labelCurrentPlayer.Bounds.Left, labelPlayerMoney.Bounds.Bottom + 5), "Money per turn: 0G", "font");
            addElement(labelPlayerMoneyPerTurn);

            // Add a label telling the player how much population they have
            labelPlayerPopulation = GuiLabel.createNewLabel(new Vector2(labelCurrentPlayer.Bounds.Left, labelPlayerMoneyPerTurn.Bounds.Bottom + 5), "Free Population: 0", "font");
            addElement(labelPlayerPopulation);

            // Add labels for unit stats
            listArmySoldiers = GuiList.createNewList(new Point(labelPlayerMoneyPerTurn.Bounds.Location.X, labelPlayerPopulation.Bounds.Bottom + 5), 5, new List <GuiElement>(), 300);
            listArmySoldiers.addElement(ElementArmySelection.CreateBuildButton(Point.Zero, "1", null, null)); // Add this so that the size is calculated correctly
            addElement(listArmySoldiers);

            buildingInfoPosition = new Point(buttonEndTurn.Bounds.Left, listArmySoldiers.Bounds.Bottom + listArmySoldiers.MaxHeight + 5);

            // Remove this label so that it doesn't display bullshit :)
            listArmySoldiers.removeElement(0);
        }
Beispiel #17
0
        public EmptyPlanetView(Action onColonizationChange)
        {
            this.onColonizationChange = onColonizationChange;
            this.Background           = new BackgroundTexture(GalaxyTextures.Get.PanelBackground, 6);
            this.Position.FixedSize(360, 116);

            this.title = new GuiText
            {
                Margins    = new Vector2(8, 4),
                TextColor  = Color.Black,
                TextHeight = 12
            };
            this.title.Position.WrapContent().Then.ParentRelative(-1, 1).UseMargins();
            this.AddChild(this.title);

            this.colonizeButton = new GuiButton
            {
                BackgroundHover  = new BackgroundTexture(GalaxyTextures.Get.ButtonHover, 9),
                BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ButtonNormal, 9),
                Padding          = 10,
                Margins          = new Vector2(8, 8),
                TextColor        = Color.Black,
                TextHeight       = 12,
                ClickCallback    = colonizeButton_Click
            };
            this.colonizeButton.Position.FixedSize(88, 88).ParentRelative(-1, -1).UseMargins();
            this.AddChild(this.colonizeButton);
        }
Beispiel #18
0
        public DebugMenuState()
            : base("DebugMenu")
        {
            GuiWindow window = new GuiWindow(400, 500, "DEBUG");

            Add(window, 0, 0);

            int buttonIndex = 0;

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

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

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

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

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

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

            window.Add(Util.CreateBackButton(), 0, -10);
        }
Beispiel #19
0
        public void Execute(ActionContext context)
        {
            Console.WriteLine("Button press action execution");
            GuiSession session = context.GetSession();
            GuiButton  button  = (GuiButton)session.FindById(path);

            button?.Press();
        }
Beispiel #20
0
    /** Creates and returns a button that pops the state */
    public static GuiButton CreateBackButton(string caption = "Back")
    {
        GuiButton result = new GuiButton(caption);

        result.OnMouseClicked += delegate {
            Engine.PopState();
        };
        return(result);
    }
Beispiel #21
0
        public void DesiredSizeShouldBeEmptyByDefault()
        {
            var availableSize = new Size2(800, 480);
            var context       = Substitute.For <IGuiContext>();
            var button        = new GuiButton();
            var desiredSize   = button.GetDesiredSize(context, availableSize);

            Assert.That(desiredSize, Is.EqualTo(Size2.Empty));
        }
        public bool ButtonPressByID(string strControlID)
        {
            GuiSession SapSession = getCurrentSession();
            GuiButton  button     = (GuiButton)SapSession.ActiveWindow.FindById(strControlID, "GuiTextField");

            button.SetFocus();
            button.Press();
            return(true);
        }
Beispiel #23
0
        public void LoadContent(ContentManager Content, GraphicsDevice graphicsDevice)
        {
            btnControlUp = new GuiButton(new Vector2(graphicsDevice.Viewport.Width / 2 - 25, 10), 50, 50, 0, Color.Black * 0.3f, Color.YellowGreen * 0.3f, Color.White, Color.White * 0.6f, Game1.MoveUpKey.ToString(), @"Fonts\StartMenuButtonFont");
            btnReturn    = new GuiButton(new Vector2(graphicsDevice.Viewport.Width / 2 - 168, graphicsDevice.Viewport.Height / 2 + 69), 336, 69, 0, Color.Black * 0.3f, Color.YellowGreen * 0.3f, Color.White, Color.White * 0.6f, "Return", @"Fonts\StartMenuButtonFont");

            guiSystem.Add(btnControlUp);
            guiSystem.Add(btnReturn);
            guiSystem.LoadContent(Content, graphicsDevice);
            guiSystem.ButtonIndexUpdate(0);
        }
Beispiel #24
0
 /** Create global controls */
 private void CreateControls()
 {
     OptionsButton = new GuiButton("Options");
     OptionsButton.OnMouseClicked += delegate {
         if (!(CurrentState is SettingsMenuState))
         {
             PushState(new SettingsMenuState());
         }
     };
 }
Beispiel #25
0
 /// <summary>
 /// Initialise les composants de l'interface graphique.
 /// </summary>
 void CreateGui()
 {
     m_modeButton = new GuiButton(m_baseControler.EnhancedGuiManager)
     {
         Location = new Point(0, 0),
         Title    = "Land",
         Size     = new Point(150, 25)
     };
     m_modeButton.Clicked += OnChangeMode;
 }
Beispiel #26
0
        public UnitStatus()
        {
            this.Background = new BackgroundTexture(GalaxyTextures.Get.PanelBackground, 6);
            this.Position.FixedSize(360, 50);

            this.shipCount = new GuiText
            {
                Margins    = new Vector2(8, 4),
                TextColor  = Color.Black,
                TextHeight = 12
            };
            this.shipCount.Position.WrapContent().Then.ParentRelative(-1, 1).UseMargins();
            this.AddChild(this.shipCount);

            this.movementInfo = new GuiText
            {
                Margins    = new Vector2(0, 4),
                TextColor  = Color.Black,
                TextHeight = 12
            };
            this.movementInfo.Position.WrapContent().Then.RelativeTo(this.shipCount, -1, -1, -1, 1).UseMargins();
            this.AddChild(this.movementInfo);

            this.doneButon = new GuiButton
            {
                BackgroundHover  = new BackgroundTexture(GalaxyTextures.Get.ButtonHover, 9),
                BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ButtonNormal, 9),
                Padding          = 6,
                Margins          = new Vector2(0, 4),
                TextColor        = Color.Black,
                TextHeight       = 12,
                Text             = textFor("UnitDone").Text(),
                ClickCallback    = this.unitDone
            };
            this.doneButon.Position.FixedSize(80, 40).ParentRelative(0, 1).UseMargins().StretchBottomTo(this, -1);
            this.AddChild(this.doneButon);

            this.armorInfo = new GuiText
            {
                Margins    = new Vector2(15, 4),
                TextColor  = Color.Black,
                TextHeight = 12
            };
            this.armorInfo.Position.WrapContent().Then.RelativeTo(this.doneButon, 1, 1, -1, 1).UseMargins();
            this.AddChild(this.armorInfo);

            this.shieldsInfo = new GuiText
            {
                Margins    = new Vector2(0, 4),
                TextColor  = Color.Black,
                TextHeight = 12
            };
            this.shieldsInfo.Position.WrapContent().Then.RelativeTo(this.armorInfo, -1, -1, -1, 1).UseMargins();
            this.AddChild(this.shieldsInfo);
        }
Beispiel #27
0
        public override void Init(Game game)
        {
            base.Init(game);
            loading = false;
            //Button zum erneuten spielen
            GuiButton start = new GuiButton("Restart", Width / 2 - 50, Height / 2, 100, 20)
            {
                Background = Color.White
            };

            start.OnClick += (object sender, MouseEventArgs e) =>
            {
                if (loading || !start.OnHover(e)) //nur ausführen wenn auch über dem Button
                {
                    return;
                }
                //In einem neuen Thread, damit die Form nicht hängt
                new Thread(() =>
                {
                    loadingText = "Loading";
                    loading     = true;
                    game.LoadIngame(hard); //Laden des IngameSpiels
                    game.SetScreen(null);  //Setzten des Ingame-Fokuses
                }).Start();
            };
            //Erstellen eines Buttons für das Beenden des Spieles
            GuiButton quit = new GuiButton("Quit", Width / 2 - 50, Height / 2 + 30, 100, 20)
            {
                Background = Color.White
            };

            quit.OnClick += (object sender, MouseEventArgs e) =>
            {
                if (loading || !quit.OnHover(e))
                {
                    return;
                }
                Application.Exit();
            };
            //Ob der Modus Hard aktiviert werden soll
            GuiCheckbox box = new GuiCheckbox("Hard", false)
            {
                Position = new Vector(Width / 2 - 50, Height / 2 - 30),
                Size     = new Vector(100, 20)
            };

            box.OnClick += (object sender, MouseEventArgs args) =>
            {
                hard = box.State;
            };
            Components.Add(box);
            Components.Add(start);
            Components.Add(quit);
        }
        public bool ButtonPressByID_Using_MainWindowName(string MainWindowName, string strControlID)
        {
            GuiSession SapSession = getCurrentSession(MainWindowName);
            //SapSession.SuppressBackendPopups = true;
            GuiButton button = (GuiButton)SapSession.ActiveWindow.FindById(strControlID, "GuiTextField");

            button.SetFocus();
            button.Press();
            //SapSession.SuppressBackendPopups = false;
            return(true);
        }
        public MultiplayerServerSelectionState(GuiPanoramaSkyBox skyBox) : base()
        {
            _skyBox = skyBox;
            CancellationTokenSource = new CancellationTokenSource();

            _listProvider = GetService <IListStorageProvider <SavedServerEntry> >();

            Title = "Multiplayer";
            TitleTranslationKey = "multiplayer.title";

            Footer.AddRow(row =>
            {
                row.AddChild(JoinServerButton = new GuiButton("Join Server",
                                                              OnJoinServerButtonPressed)
                {
                    TranslationKey = "selectServer.select",
                    Enabled        = false
                });
                row.AddChild(DirectConnectButton = new GuiButton("Direct Connect",
                                                                 () => Alex.GameStateManager.SetActiveState <MultiplayerConnectState>())
                {
                    TranslationKey = "selectServer.direct",
                    Enabled        = false
                });
                row.AddChild(AddServerButton = new GuiButton("Add Server",
                                                             OnAddItemButtonPressed)
                {
                    TranslationKey = "selectServer.add"
                });
            });
            Footer.AddRow(row =>
            {
                row.AddChild(EditServerButton = new GuiButton("Edit", OnEditItemButtonPressed)
                {
                    TranslationKey = "selectServer.edit",
                    Enabled        = false
                });
                row.AddChild(DeleteServerButton = new GuiButton("Delete", OnDeleteItemButtonPressed)
                {
                    TranslationKey = "selectServer.delete",
                    Enabled        = false
                });
                row.AddChild(new GuiButton("Refresh", OnRefreshButtonPressed)
                {
                    TranslationKey = "selectServer.refresh"
                });
                row.AddChild(new GuiBackButton()
                {
                    TranslationKey = "gui.cancel"
                });
            });

            Background = new GuiTexture2D(_skyBox, TextureRepeatMode.Stretch);
        }
        public ProfileSelectionState(GuiPanoramaSkyBox skyBox, Alex alex)
        {
            Alex           = alex;
            _skyBox        = skyBox;
            ProfileService = GetService <IPlayerProfileService>();

            Title = "Select Profile";

            Background = new GuiTexture2D(_skyBox, TextureRepeatMode.Stretch);

            base.ListContainer.ChildAnchor = Alignment.MiddleCenter;
            base.ListContainer.Orientation = Orientation.Horizontal;

            Footer.AddRow(row =>
            {
                row.AddChild(_addBtn = new GuiButton("Add", AddClicked)
                {
                });
                row.AddChild(_editBtn = new GuiButton("Edit", EditClicked)
                {
                    Enabled = false
                });
                row.AddChild(_deleteBtn = new GuiButton("Delete", DeleteClicked)
                {
                    Enabled = false
                });
            });

            Footer.AddRow(row =>
            {
                //   row.ChildAnchor = Alignment.CenterX;
                row.AddChild(_selectBtn = new GuiButton("Select Profile", OnProfileSelect)
                {
                    Enabled = false
                });

                row.AddChild(_cancelBtn = new GuiButton("Cancel", OnCancelButtonPressed)
                {
                });
            });

            if (_defaultSkin == null)
            {
                Alex.Instance.Resources.ResourcePack.TryGetBitmap("entity/alex", out var rawTexture);
                _defaultSkin = new Skin()
                {
                    Slim    = true,
                    Texture = TextureUtils.BitmapToTexture2D(Alex.Instance.GraphicsDevice, rawTexture)
                };
            }

            Reload();
        }
Beispiel #31
0
 private void AddButtonToPanel(GuiButton guiButton, Panel panel)
 {
     if (guiButton != null)
     {
         panel.AddUiObject(guiButton);
     }
     else
     {
         SendDebugMessage("The button was null");
         Debug.WriteLine("The button was null");
     }
 }
Beispiel #32
0
        public void DesiredSizeShouldBeTheSizeOfTheBackgroundRegion()
        {
            var availableSize    = new Size2(800, 480);
            var context          = Substitute.For <IGuiContext>();
            var backgroundRegion = MockTextureRegion();
            var button           = new GuiButton {
                BackgroundRegion = backgroundRegion
            };
            var desiredSize = button.GetDesiredSize(context, availableSize);

            Assert.That(desiredSize, Is.EqualTo(backgroundRegion.Size));
        }
Beispiel #33
0
 private void showCost(GuiButton b, ButtonArgs args)
 {
     currentText = abilityDesc[args.AbilityID] + "\n\nAbility Cost: " + b.Cost + " Store Points\n";
 }
Beispiel #34
0
 private void addAbilityToBar(GuiButton b, ButtonArgs args)
 {
     // This function would fetch the ability in general list and add it to the instantiated bar of the gamescreen
     Console.WriteLine("AbilityID: " + args.AbilityID);
 }
Beispiel #35
0
 private void buyAbility(GuiButton b, ButtonArgs args)
 {
     if (Game1.Instance.StorePoints >= b.Cost)
     {
         Game1.Instance.StorePoints -= b.Cost;
         b.Enabled = true;
         b.Click -= buyAbility;
         b.Hover -= showCost;
         b.Click += new GuiButton.ClickHandler(addAbilityToBar);
         b.Hover += new GuiButton.HoverHandler(changeText);
         b.Drag += new GuiButton.DraggingHandler(dragging);
         b.Drop += new GuiButton.DropHandler(dropping);
     }
     else
     {
         currentText = "Not enough store points!";
     }
 }
Beispiel #36
0
 private void changeScreens(GuiButton b)
 {
     //Game1.Instance.ScreenManager.currentScreen().Block = true;
     //Game1.Instance.ScreenManager.currentScreen().Pause = true;
     //Game1.Instance.ScreenManager.popScreen();
     Game1.Instance.ScreenManager.currentScreen().Pause = true;
     Game1.Instance.ScreenManager.pushScreen(new GamePlayScreen());
 }
Beispiel #37
0
 private void dragging(GuiButton b, ButtonArgs args)
 {
     skillDragged = args.Dragged;
     draggedImage = b.ButtonImage;
 }
Beispiel #38
0
 private void changeText(GuiButton b, ButtonArgs args)
 {
     b.FrameID = new Vector2(1, 0);
     currentText = abilityDesc[args.AbilityID];
 }
Beispiel #39
0
    // *****************************************************
    // UpdateTouchedButtons - update UI buttons behind touch collider
    // -----------------------------------------------------
    private void UpdateTouchedButtons()
    {
        if (mTransFlag && !mTransFlagLast && mTransTransform)
        {
            mTouchedButton = null;

            Vector3 theViewportPt = RayCamera.WorldToViewportPoint(mTransTransform.position);
            Ray theRay = RayCamera.ViewportPointToRay(theViewportPt);
            RaycastHit theRayCastHit;
            mCollider.enabled = false;
            if (Physics.Raycast(theRay, out theRayCastHit, 100))
            {
                GuiButton theButton = theRayCastHit.collider.GetComponent<GuiButton>();
                if (theButton != null)
                    mTouchedButton = theButton;
            }
            mCollider.enabled = true;

            // send OnMouseDown message
            if (mTouchedButton != null)
            {
                mTouchButtonViewportPt = theViewportPt;
                mTouchedButton.SendMessage("OnMouseDown");
            }
        }

        if (mTouchedButton != null)
        {
            if (mTransFlag && mTransTransform)
            {
                Vector3 theDiff = mTouchButtonViewportPt - RayCamera.WorldToViewportPoint(mTransTransform.position);
                if (mFingerOverMap.Count != 1 || theDiff.sqrMagnitude >= (UIBUTTON_VIEWPORT_DIST * UIBUTTON_VIEWPORT_DIST))
                {
                    // send OnMouseExit message -VM
                    mTouchedButton.SendMessage("OnMouseExit");
                    mTouchedButton = null;
                }
            }
            else
            {
                // send OnMouseUp message
                mTouchedButton.SendMessage("OnMouseUp");
                mTouchedButton = null;
            }
        }
    }
Beispiel #40
0
 private void gameButton_Hover(GuiButton b, ButtonArgs args)
 {
     b.FrameID = new Vector2(1, 0);
 }
Beispiel #41
0
 // *****************************************************
 // SetTouchedButton
 // -----------------------------------------------------
 public void SetTouchedButton(GuiButton inButton)
 {
     mTouchedButton = inButton;
 }
Beispiel #42
0
 private void dropping(GuiButton b, ButtonArgs args)
 {
     Rectangle box = new Rectangle(Mouse.GetState().X - 24, Mouse.GetState().Y - 24, 48, 48);
     GuiButton abilityBarButton = Game1.Instance.GameAbilityBar.abilityButton(new Point(Mouse.GetState().X, Mouse.GetState().Y));
     if (abilityBarButton != null)
     {
         skillDragged = args.Dragged;
         if (box.Intersects(abilityBarButton.BoundingBox))
         {
             Console.WriteLine("Collided");
             Game1.Instance.GameAbilityBar.setAbility(args.AbilityID, Game1.Instance.GameAbilityBar.AbilityList[args.AbilityID]);
             Console.WriteLine(args.AbilityID);
             abilityBarButton.AbilityID = args.AbilityID;
             abilityBarButton.ButtonImage = b.ButtonImage;
         }
     }
     else
     {
         skillDragged = false;
     }
 }
        void HandleButton(GuiConfigDB conf, GuiButton gbtn)
        {
            if (!Buttons.ContainsKey(gbtn.name))
            {
                // create a new empty button
                AddButton(gbtn.name, new ctlImageButton());
                Buttons[gbtn.name].BringToFront();
            }
            ctlImageButton butt = Buttons[gbtn.name];
            //            butt.Visible = true;
            butt.Visible = gbtn.visible.GetIfExplicit(true);
            butt.GuiAnchor = gbtn.dock.GetIfExplicit(butt.GuiAnchor);
            butt.Gapx = gbtn.x.GetIfExplicit(butt.Gapx);
            butt.Gapy = gbtn.y.GetIfExplicit(butt.Gapy);
            butt.Width = gbtn.w.GetIfExplicit(butt.Width);
            butt.Height = gbtn.h.GetIfExplicit(butt.Height);
            butt.StyleName = gbtn.style.GetIfExplicit(butt.StyleName);
            butt.OnClickCallback = gbtn.onClickCmd.GetIfExplicit(butt.OnClickCallback);
            GuiControlStyle bstl = conf.GetControlStyle(butt.StyleName);
            if (bstl != null)
            {
                butt.GLVisible = bstl.glMode;
            }
            if (gbtn.image.IsExplicit())
            {
                butt.GLImage = gbtn.image;
                butt.Image = conf.GetImage(gbtn.image, null);
            }
            butt.CheckImage = conf.GetImage(gbtn.checkImage, butt.CheckImage);

            // add the ability to add buttons in various named parents
            // this will allow adding buttons to toolbar from plugins
            if (gbtn.action.IsExplicit())
            {
                string action = gbtn.action;
                if (action.Contains("remove")) // this handles removing a control from it's parent
                {
                    // remove this control from it's parent
                    if (butt.Parent != null)
                    {
                        butt.Parent.Controls.Remove(butt);
                        butt.Parent = null;
                    }
                }
                else if (action.Contains("addto")) // this handles adding a new control to a parent control
                {
                    // Get the name of the parent
                    string parentname = gbtn.parent;
                    if (gbtn.parent.IsExplicit() && (parentname != null) && (parentname.Length != 0))
                    {
                        //find the parent
                        if (Controls.ContainsKey(parentname))
                        {
                            Control ctlParent = Controls[parentname];
                            ctlParent.Controls.Add(butt);
                        }
                        else
                        {
                            DebugLogger.Instance().LogWarning("Button parent not found: " + parentname);
                        }
                    }
                }
            }
        }
Beispiel #44
0
    // *****************************************************
    // Reset
    // -----------------------------------------------------
    public void Reset()
    {
        // cleanup
        for (int i = 0; i < mTouchCurFlags.Length; i++)
        {
            mTouchCurFlags[i] = false;
            mTouchLastFlags[i] = false;
        }
        mFingerOverMap.Clear();
        mFingerOverMapCountLast = 0;
        mTransFlag = false;
        mTransFlagLast = false;
        ResetMomentum();

        // reset touched button
        if (mTouchedButton != null)
        {
            mTouchedButton.SendMessage("OnMouseExit", SendMessageOptions.DontRequireReceiver);
            mTouchedButton = null;
        }
    }
 public void RotatePiece(GuiButton button, INVENTORY_PHASES phase)
 {
 }