예제 #1
0
        private NewEraWindow(Manager manager, Era era)
            : base(manager)
        {
            Init();

            Width = 950;
            Height = 550;

            _lblEraImage = new ImageBox(manager);
            _lblEraImage.Init();
            _lblEraImage.Left = 4;
            _lblEraImage.Top = 10;          
            _lblEraImage.Width = 924;
            _lblEraImage.Height = 472;
            _lblEraImage.Image = era.Image;
            Add(_lblEraImage);

            _lblDescription = new Label(manager);
            _lblDescription.Init();
            _lblDescription.Left = 4;
            _lblDescription.Top = 482;
            _lblDescription.Width = 924;
            _lblDescription.Height = 16;
            _lblDescription.Text = string.Format(Strings.TXT_KEY_UI_NEWERA_WELCOME, era.Title);
            Add(_lblDescription);

            Manager.Add(this);
        }
예제 #2
0
        public override int AddInformation(Manager manager, Player player, Control control, int yPos)
        {
            var currentHouse = player.House;
            const int spacing = 20;
            int xPos = spacing;
            if (currentHouse == null) {
                var noHouseLabel = new Label(manager) { Text = "You have no house to sell!", Width = 400, Left = xPos, Top = yPos, Name = IgnoreString };
                noHouseLabel.Init();
                control.Add(noHouseLabel);
            } else {
                var houseGraphic = manager.Game.Content.Load<Texture2D>(currentHouse.HouseGraphic);
                yPos += 20;
                // Put the house graphic into an image box
                var imageBox = new ImageBox(manager) {
                    Left = 16,
                    Top = yPos,
                    Image = houseGraphic,
                    Color = Color.White,
                    Width = houseGraphic.Width,
                    Height = houseGraphic.Height,
                    Name = IgnoreString,
                    Parent = control
                };
                imageBox.Init();

                var descriptionText = new Label(manager) {
                    Text =
                        String.Format(
                            "Name : {0}\n\n" +
                            "Average Value: ${1:N0}\n\n" +
                            "Current Value: ${2:N0}\n\n" +
                            "Bought for : ${3:N0}\n\n" +
                            "Total profit :: ${4:N0}",
                            currentHouse.Name, currentHouse.InitialValue, currentHouse.Value, currentHouse.PlayerBuyingValue, currentHouse.PlayerBuyingValue - currentHouse.Value),
                    Top = yPos,
                    Left = imageBox.Width + 60,
                    Height = 130,
                    Width = 200,
                    Parent = control,
                    Name = IgnoreString
                };
                yPos += imageBox.Height + 20;
                var sellHouseButton = new Button(manager) {
                    Text =
                        "Sell House",
                    Width = 400, Left = xPos, Top = yPos,
                    Name = IgnoreString
                };
                sellHouseButton.Click += (sender, args) => {
                    _houseCallback(player, currentHouse);
                    PopulateTab(manager, player, control);
                };
                sellHouseButton.Init();
                control.Add(sellHouseButton);
            }
            return yPos;
        }
예제 #3
0
        private void CreateMessage(Manager manager, GameInfo gameInfo, IGameState waitState)
        {
            var currentPlayer = gameInfo.CurrentPlayer;

            var messageWindow = new Window(manager) { Text = "Pay Day!", AutoScroll = false, CloseButtonVisible = false};
            messageWindow.Init();
            messageWindow.SetSize(400, 230);
            var message = new Label(manager) { Text = "Well Done! you have received your Pay Day! \nBelow are the details.", Width = 400, Height = 40, Left = 5, Top = 10 };
            message.Init();
            message.Parent = messageWindow;
            var careerImage = gameInfo.Content.Load<Texture2D>("Images/career_icons/" +
                                                               gameInfo.CurrentPlayer.CurrentCareer);
            var career = new ImageBox(manager) {
                Image = careerImage,
                Width = careerImage.Width,
                Height = careerImage.Height,
                Top = 50,
                Left = 16,
                StayOnBack = true
            };
            career.Init();
            career.Parent = messageWindow;

            var icon = new ImageBox(manager) {
                Image =
                    gameInfo.Content.Load<Texture2D>("Images/payday"),
                Top = 60,
                Left = career.Left + career.Width + 70
            };
            icon.Init();
            icon.Parent = messageWindow;

            var job = new Label(manager) { Text = "Current Career:\n" + currentPlayer.CurrentCareer.Title, Top = 110, Left = 10, Width = 150, Height = 50 };
            job.Init();
            job.Parent = messageWindow;

            var salary = new Label(manager) {
                Text = String.Format("Level {1} Promotion\nReceived: ${0:N0}",
                currentPlayer.CurrentCareer.Salary[currentPlayer.PromotionLevel],
                currentPlayer.PromotionLevel + 1),
                Top = 110, Left = 140, Width = 140, Height = 50
            };
            salary.Init();
            salary.Parent = messageWindow;

            var close = new Button(manager) { Text = "OK", Top = 160, Left = messageWindow.Width / 2 - 50 };
            close.Init();
            close.Parent = messageWindow;
            close.Click += (sender, args) => { messageWindow.Close(); WindowClosed(gameInfo, waitState); };
            messageWindow.Closed += (sender, args) => WindowClosed(gameInfo, waitState);
            gameInfo.Manager.Add(messageWindow);
            messageWindow.Init();
            gameInfo.Content.Load<SoundEffect>("Sounds/coins").Play();
        }
예제 #4
0
        public override void Add(ScreenManager screenManager)
        {
            Game.CurrentGameState = GameState.Login;
            base.Add(screenManager);
            (Manager.Game as Application).BackgroundImage = ContentPack.Textures["gui\\background"];

            //Add the logo image
            LogoImage = new ImageBox(Manager) { Image = ContentPack.Textures["gui\\logosmall"], SizeMode = SizeMode.Centered };
            LogoImage.SetSize(LogoImage.Image.Width, LogoImage.Image.Height);
            LogoImage.SetPosition((Window.Width / 2) - (LogoImage.Width / 2), 0);
            LogoImage.Init();
            Window.Add(LogoImage);

            //Add github contribute link
            GithubIcon = new ImageBox(Manager) { Image = ContentPack.Textures["gui\\github"], SizeMode = SizeMode.Auto, };
            GithubIcon.ToolTip.Text = "We love open source! Contribute to Bricklayer at our GitHub repo.";
            GithubIcon.SetSize(GithubIcon.Width, GithubIcon.Height);
            GithubIcon.SetPosition(Window.Width - GithubIcon.Width - 8, Window.Height - GithubIcon.Height - 8);
            GithubIcon.Init();
            GithubIcon.Color = Color.White * .6f;
            //Click/Hover events
            GithubIcon.MouseOut += new MouseEventHandler(delegate(object o, MouseEventArgs e)
            {
                GithubIcon.Color = Color.White * .6f;
            });
            GithubIcon.MouseOver += new MouseEventHandler(delegate(object o, MouseEventArgs e)
            {
                GithubIcon.Color = Color.White;
            });
            GithubIcon.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e)
            {
                if (Manager.Game.IsActive) Process.Start(githubLink); //Open the link in a browser
            });
            Window.Add(GithubIcon);

            //Add version tag
            Version = new Label(Manager) { Font = FontSize.Default14 };
            Version.SetSize(200, 16);
            Version.SetPosition(8, Window.Height - Version.Height - 8);
            Version.Init();
            Version.Text = AssemblyVersionName.GetVersion();
            Window.Add(Version);

            //Add the login window
            Login = new ServerWindow(Manager);
            Login.Init();
            if (Login.Top - 24 < LogoImage.Height + LogoImage.Top) //If it is too close to logo, move it down a bit
                Login.Top = LogoImage.Height + LogoImage.Top - 24;
            Window.Add(Login);
            Login.Show();
        }
예제 #5
0
        public override int AddInformation(Manager manager, Player player, Control control, int yPos)
        {
            const int spacing = 16;

            var title = new ImageBox(manager)
                            {
                                Image = manager.Game.Content.Load<Texture2D>("images/assetstitle"),
                                Top = yPos,
                                Left = 150,
                                Parent = control,
                                Width = 150,
                                Name = IgnoreString
                            };
            title.Init();
            yPos += title.Height/2;

            foreach (var assetList in player.Assets)
            {
                foreach (var asset in assetList.Value)
                {
                    var assetName = new Label(manager)
                    {
                        Text = String.Format("Type: {0}   Value: ${1:N0}",
                                             asset.Name, asset.Value),
                        Top = yPos+spacing,
                        Width = 400,
                        Left = 120,
                        Parent = control,
                       Name = IgnoreString
                    };

                    var texture = manager.Game.Content.Load<Texture2D>(asset.AssetPath);
                    var imageBox = new ImageBox(manager)
                    {
                        Image = texture,
                        Parent = control,
                        Left = 40,
                        Top = yPos,
                       Name = IgnoreString,
                       Color = Color.White
                    };

                    assetName.Init();
                    yPos += imageBox.Height + spacing;
                }
            }

            return yPos + 30;
        }
예제 #6
0
 public override IGameState[] PerformLogic(GameTime gameTime, GameInfo gameInfo)
 {
     var waitState = StateFactory.GetState(GameStates.GameStates.Wait);
     var alert = new Alert(gameInfo.Manager,
                           String.Format("You have just started University and \nmust pay ${0:N0} in fees.\nYou will need to pass your exam to start career", +Constants.GameRules.UniversityCost),
                           "Start University");
     var university = new ImageBox(gameInfo.Manager) { Image = gameInfo.Content.Load<Texture2D>("Images/AlertIcons/Graduated" + gameInfo.CurrentPlayer.Gender), Top = 15, Left = 10 };
     university.Init();
     university.Parent = alert;
     gameInfo.Manager.Add(alert);
     alert.Closed += (sender, args) => gameInfo.Fsm.Remove(waitState);
     gameInfo.CurrentPlayer.CareerType = CareerType.CollegeCareer;
     gameInfo.CurrentPlayer.Cash -= Constants.GameRules.UniversityCost;
     return new[] { waitState };
 }
예제 #7
0
        public ScreenManager(MainWindow window)
        {
            Window = window;
            Manager = window.Manager;

            //Setup a solid black image to use for fading
            fadeTexture = new Texture2D(Manager.GraphicsDevice, 1, 1);
            fadeTexture.SetData<Color>(new Color[1] { Color.Black });

            fadeImage = new ImageBox(Manager) { Passive = true, Left = 0, Top = 0, Width = Window.Width, Height = Window.Height, StayOnTop = true, Image = fadeTexture, SizeMode = SizeMode.Stretched };
            fadeImage.Init();
            fadeImage.Image = fadeTexture;
            fadeImage.Alpha = 0;
            fadeImage.Color = Color.White * fadeImage.Alpha;
            window.Add(fadeImage);
            fadeImage.BringToFront();
            //window.Resize += new ResizeEventHandler(delegate(object o, ResizeEventArgs e)
            //{ fadeImage.SetSize(e.Width, e.Height); /* Update fade image size */ });
        }
예제 #8
0
        public LobbyDataControl(Manager manager, LobbySaveData data)
            : base(manager)
        {
            //Setup
            Passive = false;
            Height = 60;
            ClientWidth = (700 / 2) - 16;
            Data = data;

            //Background "gradient" image
            //TODO: Make an actual control. not a statusbar
            Gradient = new StatusBar(manager);
            Gradient.Init();
            Gradient.Alpha = .8f;
            Add(Gradient);

            for (int i = 0; i < 5; i++)
            {
                imgRating[i] = new ImageBox(Manager) { Top = 4, Width = 16, Height = 16, Left = ClientWidth - (((4 - i) * 18) + 48) };
                imgRating[i].Init();
                bool half = data.Rating > i + .25 && data.Rating < i + .75;
                bool whole = data.Rating >= i + .75;
                imgRating[i].Image = whole ? ContentPack.Textures["gui\\icons\\full_star"] : half ? ContentPack.Textures["gui\\icons\\half_star"] : ContentPack.Textures["gui\\icons\\empty_star"];
                Add(imgRating[i]);
            }

            lblStats = new Label(Manager) { Width = 100, Left = ClientWidth - 100 - 16, Top = imgRating[0].Bottom + 4, Alignment = Alignment.TopLeft, TextColor = new Color(160,160,160) };
            lblStats.Init();
            lblStats.Text = string.Format("Online: {0}\nPlays: {1}", data.Online, "N/A" /*data.Plays*/);
            Add(lblStats);

            //Add controls
            lblName = new Label(Manager) { Width = 100, Text = data.Name, Left = 4, Top = 4, Font = FontSize.Default14, Alignment = Alignment.TopLeft };
            lblName.Init();
            Add(lblName);
            lblName.Text = data.Name;

            lblDescription = new Label(Manager) { Width = 200, Text = data.Name, Left = 4, Top = lblName.Bottom + 4, Alignment = Alignment.TopLeft };
            lblDescription.Init();
            Add(lblDescription);
            lblDescription.Text = data.Description;
        }
예제 #9
0
        protected virtual void CreateIcon(String iconPath)
        {
            var loadedIcon = Manager.Game.Content.Load<Texture2D>(iconPath);

            var imageIcon = new ImageBox(Manager) {
                Left = 16,
                Top = yPos,
                Image = loadedIcon,
                Width = loadedIcon.Width,
                Height = loadedIcon.Height,
                Color = Color.White
            };

            Add(imageIcon);
            Icon = imageIcon;
        }
예제 #10
0
        private void createMusicControls()
        {
            musicFileSelected = false;
            selectedMusicFile = null;
            selectAudio.Enabled = false;
            for (int i = 0; i < musicFiles.Count; i++)
            {

                ImageBox box = new ImageBox(manager);

                box.Init();
                box.DoubleClicks = true;
                box.Parent = gp;
                box.Left = 0;

                box.Passive = false;
                box.Top = 0;
                box.Width = window.Width - 50;
                box.Focused = true;
                box.Height = 30;
                box.SetPosition(10, (30 + ((lastDirecPosition) + i * 25 )));

                box.Image = image2;
                box.Text = musicFiles[i].Name;

                Label tx = new Label(manager);
                tx.Init();
                tx.Passive = false;
                string subD = musicFiles[i].Name;
                tx.Text = subD;
                tx.Tag = musicFiles[i].FullName;
                tx.DoubleClicks = true;

                tx.Height = 20;
                tx.Width = window.Width - 50;

                tx.Left = 25;
                tx.Top = 4;
                tx.Parent = box;
                tx.StayOnTop = true;

                tx.MousePress += new TomShane.Neoforce.Controls.MouseEventHandler(SelectAudioFile);

            }
        }
예제 #11
0
        private void createBrowserControls()
        {
            selectAudio.Enabled = false;
            musicFileSelected = false;
            selectedMusicFile = null;
            for (int i = 0; i < subDirectories.Count; i++)
            {

                ImageBox box = new ImageBox(manager);

                box.Init();
                box.DoubleClicks = true;
                box.Parent = gp;
                box.Left = 0;

                box.Passive = false;
                box.Top = 0;
                box.Width = window.Width - 50;
                box.Focused = true;
                box.Height = 30;
                box.SetPosition(10, (30 + (i * 25)));
                lastDirecPosition = (30 + (i * 25));
                box.Image = image;
                box.Text = subDirectories[i];
                box.MousePress += (sender, args) => EnterDirectory(sender, box.Text);

                Label tx = new Label(manager);
                tx.Init();
                tx.Passive = false;
                string subD = (string)subDirectories[i];
                tx.Text = subD;
                tx.DoubleClicks = true;
                //tx.SetPosition(Graphics.GraphicsDevice.Viewport.Width / 2 - 150, (80 + (i * 25)));
                tx.Height = 20;
                tx.Width = window.Width - 50;
                tx.Color = Color.Red;
                tx.BackColor = Color.Red;
                //tx.DoubleClick += (sender, args) => EnterDirectory(sender, box.Text);
                //tx.MouseOver += new TomShane.Neoforce.Controls.MouseEventHandler(EnterDirectory);
                tx.Left = 25;
                tx.Top = 4;
                tx.Parent = box;
                tx.StayOnTop = true;

                tx.MousePress += (sender, args) => EnterDirectory(sender, box.Text);
                tx.MouseOver += (sender, args) => MouseOverDirectory(sender, args);
                tx.MouseOut += (sender, args) => MouseOffDirectory(sender, args);

            }
        }
예제 #12
0
        public void Init()
        {
            texture = new Texture2D(manager.GraphicsDevice, 1, 1);
            texture.SetData<Color>(new Color[] { Color.White });

            #region Window
            window = new Window(manager) ;
            window.Init();
            window.Text = "Tank Creation";
            window.Width = 600;
            window.Height = 500;
            window.Center();
            window.Visible = true;
            window.CloseButtonVisible = false;
            #endregion

            #region ListBoxes

            #region Tank
            tankBoxLbl = new Label(manager);
            tankBoxLbl.Init();
            tankBoxLbl.Text = "Tanks: ";
            tankBoxLbl.Width = 100;
            tankBoxLbl.Height = 10;
            tankBoxLbl.Left = 20;
            tankBoxLbl.Top = 10;
            tankBoxLbl.Anchor = Anchors.Left;
            tankBoxLbl.Parent = window;

            tankBox = new ListBox(manager);
            tankBox.Init();
            tankBox.Width = 200;
            tankBox.Height = 75;
            tankBox.Left = 30;
            tankBox.Top = 30;
            tankBox.Anchor = Anchors.Left;
            tankBox.HideSelection = false;
            tankBox.Parent = window;
            foreach (String s in tanks)
            {
                tankBox.Items.Add(s);
            }
            tankBox.ItemIndexChanged += new TomShane.Neoforce.Controls.EventHandler(tankBox_ItemIndexChanged);
            #endregion

            #region Turret

            turretBoxLbl = new Label(manager);
            turretBoxLbl.Init();
            turretBoxLbl.Text = "Turrets: ";
            turretBoxLbl.Width = 50;
            turretBoxLbl.Height = 10;
            turretBoxLbl.Left = tankBoxLbl.Left;
            turretBoxLbl.Top = tankBox.Top + tankBox.Height + 20;
            turretBoxLbl.Anchor = Anchors.Left;
            turretBoxLbl.Parent = window;

            turretBox = new ListBox(manager);
            turretBox.Init();
            turretBox.Width = 200;
            turretBox.Height = 100;
            turretBox.Left = 30;
            turretBox.Top = turretBoxLbl.Top + turretBoxLbl.Height + 10;
            turretBox.Anchor = Anchors.Left;
            turretBox.HideSelection = false;
            turretBox.Parent = window;
            foreach (String s in tanks)
            {
                turretBox.Items.Add(s);
            }
            turretBox.ItemIndexChanged += new TomShane.Neoforce.Controls.EventHandler(turretBox_ItemIndexChanged);

            tPowerLbl = new Label(manager);
            tPowerLbl.Init();
            tPowerLbl.Text = "Power: ";
            tPowerLbl.Width = 50;
            tPowerLbl.Height = 10;
            tPowerLbl.Left = turretBox.Left;
            tPowerLbl.Top = turretBox.Top + turretBox.Height + 10;
            tPowerLbl.Anchor = Anchors.Left;
            tPowerLbl.Parent = window;

            tPower = new ProgressBar(manager);
            tPower.Init();
            tPower.Width = 75;
            tPower.Height = 10;
            tPower.Left = tPowerLbl.Left + tPowerLbl.Width + 5;
            tPower.Top = tPowerLbl.Top;
            tPower.Anchor = Anchors.Left;
            tPower.Parent = window;
            tPower.Value = 50;

            tRateLbl = new Label(manager);
            tRateLbl.Init();
            tRateLbl.Text = "Rate: ";
            tRateLbl.Width = 50;
            tRateLbl.Height = 10;
            tRateLbl.Left = turretBox.Left;
            tRateLbl.Top = tPowerLbl.Top + tPowerLbl.Height;
            tRateLbl.Anchor = Anchors.Left;
            tRateLbl.Parent = window;

            tRate = new ProgressBar(manager);
            tRate.Init();
            tRate.Width = 75;
            tRate.Height = 10;
            tRate.Left = tRateLbl.Left + tRateLbl.Width + 5;
            tRate.Top = tRateLbl.Top;
            tRate.Anchor = Anchors.Left;
            tRate.Parent = window;
            tRate.Value = 50;

            tRangeLbl = new Label(manager);
            tRangeLbl.Init();
            tRangeLbl.Text = "Range: ";
            tRangeLbl.Width = 50;
            tRangeLbl.Height = 15;
            tRangeLbl.Left = turretBox.Left;
            tRangeLbl.Top = tRateLbl.Top + tRateLbl.Height;
            tRangeLbl.Anchor = Anchors.Left;
            tRangeLbl.Parent = window;

            tRange = new ProgressBar(manager);
            tRange.Init();
            tRange.Width = 75;
            tRange.Height = 10;
            tRange.Left = tRangeLbl.Left + tRangeLbl.Width + 5;
            tRange.Top = tRangeLbl.Top;
            tRange.Anchor = Anchors.Left;
            tRange.Parent = window;
            tRange.Value = 50;

            #endregion

            #endregion

            #region TankStats

            armorLbl = new Label(manager);
            armorLbl.Init();
            armorLbl.Text = "Armor: ";
            armorLbl.Width = 50;
            armorLbl.Height = 24;
            armorLbl.Left = 20;
            armorLbl.Top = window.Height - 160; ;
            armorLbl.Anchor = Anchors.Left;
            armorLbl.Parent = window;

            armorBar = new ProgressBar(manager);
            armorBar.Init();
            armorBar.Width = 150;
            armorBar.Height = 24;
            armorBar.Left = armorLbl.Left + armorLbl.Width + 20; ;
            armorBar.Top = armorLbl.Top;
            armorBar.Anchor = Anchors.Left;
            armorBar.Parent = window;
            armorBar.Value = 50;

            speedLbl = new Label(manager);
            speedLbl.Init();
            speedLbl.Text = "Speed: ";
            speedLbl.Width = 50;
            speedLbl.Height = 24;
            speedLbl.Left = armorLbl.Left;
            speedLbl.Top = armorLbl.Top + armorLbl.Height;
            speedLbl.Anchor = Anchors.Left;
            speedLbl.Parent = window;

            speedBar = new ProgressBar(manager);
            speedBar.Init();
            speedBar.Width = 150;
            speedBar.Height = 24;
            speedBar.Left = speedLbl.Left + speedLbl.Width + 20; ;
            speedBar.Top = speedLbl.Top;
            speedBar.Anchor = Anchors.Left;
            speedBar.Parent = window;
            speedBar.Value = 50;

            ratioLbl = new Label(manager);
            ratioLbl.Init();
            ratioLbl.Text = "Ratio: ";
            ratioLbl.Width = 50;
            ratioLbl.Height = 24;
            ratioLbl.Left = armorLbl.Left;
            ratioLbl.Top = speedLbl.Top + speedLbl.Height + 20;
            ratioLbl.Anchor = Anchors.Left;
            ratioLbl.Parent = window;

            ratioSlide = new SliderBar(manager);
            ratioSlide.Init();
            ratioSlide.Width = 150;
            ratioSlide.Height = 20;
            ratioSlide.Left = ratioLbl.Left + ratioLbl.Width + 20; ;
            ratioSlide.Top = ratioLbl.Top + 3;
            ratioSlide.Anchor = Anchors.Left;
            ratioSlide.Parent = window;
            ratioSlide.Value = 50;
            ratioSlide.ValueChanged += new TomShane.Neoforce.Controls.EventHandler(ratioSlide_ValueChanged);

            #endregion

            #region Render Region
            image = new ImageBox(manager);
            image.Init();
            image.SizeMode = SizeMode.Stretched;
            image.Width = 200;
            image.Height = 150;
            image.Left = window.Width - image.Width - 70;
            image.Top = 40;
            image.Anchor = Anchors.Right;
            image.Parent = window;
            image.Image = texture;
            #endregion

            #region Skin Scrolling (Left/Right)
            ScrollSkinLeft = new Button(manager);
            ScrollSkinLeft.Init();
            ScrollSkinLeft.Width = 25;
            ScrollSkinLeft.Height = 25;
            ScrollSkinLeft.Left = window.Width - image.Width - 70;
            ScrollSkinLeft.Top = image.Top + image.Height + 10;
            ScrollSkinLeft.Text = " < ";
            ScrollSkinLeft.Parent = window;

            ScrollSkinRight = new Button(manager);
            ScrollSkinRight.Init();
            ScrollSkinRight.Width = 25;
            ScrollSkinRight.Height = 25;
            ScrollSkinRight.Left = image.Left + image.Width - ScrollSkinRight.Width;
            ScrollSkinRight.Top = image.Top + image.Height + 10;
            ScrollSkinRight.Text = " > ";
            ScrollSkinRight.Parent = window;
            #endregion

            #region Skin Label
            SkinLabel = new Label(manager);
            SkinLabel.Init();
            SkinLabel.Alignment = Alignment.MiddleCenter;
            SkinLabel.Height = 15;
            SkinLabel.Width = 100;
            SkinLabel.Left = ScrollSkinRight.Left - 120;
            SkinLabel.Top = image.Top + image.Width - 33;
            SkinLabel.Text = "Skin";
            SkinLabel.Parent = window;
            #endregion

            #region Color Choosing
            redLbl = new Label(manager);
            redLbl.Init();
            redLbl.Text = "Red: ";
            redLbl.Width = 50;
            redLbl.Height = 24;
            redLbl.Left = image.Left;
            redLbl.Top = ScrollSkinLeft.Top + ScrollSkinLeft.Height + 20;
            redLbl.Anchor = Anchors.Left;
            redLbl.Parent = window;

            red = new SliderBar(manager);
            red.Init();
            red.Width = 120;
            red.Height = 15;
            red.Left = redLbl.Left + redLbl.Width + 20;
            red.Top = ScrollSkinLeft.Top + ScrollSkinLeft.Height + 25;
            red.Anchor = Anchors.Left;
            red.Parent = window;
            red.Value = 50;
            red.ValueChanged += new TomShane.Neoforce.Controls.EventHandler(Color_Changed);

            greenLbl = new Label(manager);
            greenLbl.Init();
            greenLbl.Text = "Green: ";
            greenLbl.Width = 50;
            greenLbl.Height = 24;
            greenLbl.Left = redLbl.Left;
            greenLbl.Top = redLbl.Top + redLbl.Height;
            greenLbl.Anchor = Anchors.Left;
            greenLbl.Parent = window;

            green = new SliderBar(manager);
            green.Init();
            green.Width = red.Width;
            green.Height = red.Height;
            green.Left = greenLbl.Left + greenLbl.Width + 20;
            green.Top = greenLbl.Top + 5;
            green.Anchor = Anchors.Left;
            green.Parent = window;
            green.Value = 50;
            green.ValueChanged += new TomShane.Neoforce.Controls.EventHandler(Color_Changed);

            blueLbl = new Label(manager);
            blueLbl.Init();
            blueLbl.Text = "Blue: ";
            blueLbl.Width = 50;
            blueLbl.Height = 24;
            blueLbl.Left = redLbl.Left;
            blueLbl.Top = greenLbl.Top + greenLbl.Height;
            blueLbl.Anchor = Anchors.Left;
            blueLbl.Parent = window;

            blue = new SliderBar(manager);
            blue.Init();
            blue.Width = red.Width;
            blue.Height = red.Height;
            blue.Left = blueLbl.Left + blueLbl.Width + 20; ;
            blue.Top = blueLbl.Top + 5;
            blue.Anchor = Anchors.Left;
            blue.Parent = window;
            blue.Value = 50;
            blue.ValueChanged += new TomShane.Neoforce.Controls.EventHandler(Color_Changed);
            #endregion

            #region Tank Name
            name = new Label(manager);
            name.Init();
            name.Text = "Tank Name: ";
            name.Width = 100;
            name.Height = 24;
            name.Left = redLbl.Left;
            name.Top = blueLbl.Top + blueLbl.Height + 20;
            name.Anchor = Anchors.Left;
            name.Parent = window;

            nameBox = new TextBox(manager);
            nameBox.Init();
            nameBox.Text = "";
            nameBox.Width = 180;
            nameBox.Height = 24;
            nameBox.Left = name.Left + 10;
            nameBox.Top = name.Top + name.Height;
            nameBox.Anchor = Anchors.Left;
            nameBox.Parent = window;

            #endregion

            #region Buttons
            create = new Button(manager);
            create.Init();
            create.Text = "Create";
            create.Width = 90;
            create.Height = 24;
            create.Left = window.Width - create.Width - 40; ;
            create.Top = ratioLbl.Top;
            create.Anchor = Anchors.Left;
            create.Parent = window;

            cancel = new Button(manager);
            cancel.Init();
            cancel.Text = "Cancel";
            cancel.Width = 80;
            cancel.Height = 24;
            cancel.Left = create.Left - cancel.Width - 60;
            cancel.Top = create.Top;
            cancel.Anchor = Anchors.Right;
            cancel.Parent = window;
            #endregion
        }
예제 #13
0
        private IGameState[] CardSelected(Manager manager, GameInfo gameInfo, Story story)
        {
            var storyGraphic = gameInfo.Content.Load<Texture2D>(story.StoryGraphic);
            const int spacing = 20;
            const int width = 400;
            var yPos = spacing;

            var window = new Window(manager) {
                Text =
                    String.Format("Your fate has been decided! You spun a {0} story", story.StoryType), AutoScroll = false
            };

            window.Init();

            var storybox = new GroupBox(manager) { Width = 400, Height = 100, Left = 30, Top = yPos, Parent = window, Color = story.StoryType == StoryType.Red ? Color.Red : Color.Black, Text = ""+story.StoryType, TextColor = Color.White };
            storybox.Init();

            var storylabel = new Label(manager)
            {
                Width = storybox.Width,
                Height = storybox.Height,
                Parent = storybox,
                Text = story.DisplayedMessage,
                Left = spacing,
                StayOnTop = true
            };
            storylabel.Init();

            var imageBox = new ImageBox(manager)
            {
                Left = window.Width/2-100,
                Top = 140,
                Image = storyGraphic,
                Color = Color.White,
                Width = storyGraphic.Width,
                Height = storyGraphic.Height
            };
            imageBox.Init();
            window.Add(imageBox);
            var close = new Button(manager) { Text = "OK", Top = window.Height-50-spacing, Left = window.Width / 2 - 50, Parent = window };
            close.Init();
            close.Click += (sender, args) => window.Close();

            window.Closed += (sender, args) => WindowClosed(gameInfo);

            manager.Add(window);

            if (story.Positive)
                gameInfo.Content.Load<SoundEffect>("Sounds/applause").Play();
            else
                gameInfo.Content.Load<SoundEffect>("Sounds/sadtrombone").Play();

            return new[] { story.PureLogic, waitState };
        }
예제 #14
0
        private void OfferToSellHouse(GameInfo gameInfo, IGameState waitState)
        {
            var currentHouse = gameInfo.CurrentPlayer.House;
            var houseGraphic = gameInfo.Content.Load<Texture2D>(currentHouse.HouseGraphic);
            var manager = gameInfo.Manager;

            var container = new Control(manager) { Left = 16, Top = 16, Color = Color.Transparent };
            var firstLine = new Label(manager) { Text = "You have been offered to buy a new house!  \nYou must sell your current house to be able to buy this one. \n\n     Current House:", Width = 400, Height = 60};
            container.Add(firstLine);
            // Put the house graphic into an image box
            var imageBox = new ImageBox(manager)
            {
                Left = 16,
                Top = 60,
                Image = houseGraphic,
                Color = Color.White,
                Width = houseGraphic.Width,
                Height = houseGraphic.Height
            };
            imageBox.Init();
            container.Add(imageBox);

            var descriptionText = new Label(manager)
            {
                Text =
                    String.Format(
                        "Name : {0}\n\n" +
                        "Average Value: ${1:N0}" +
                        "\n\nCurrent Value: ${2:N0}\n\n",
                        currentHouse.Name, currentHouse.InitialValue, currentHouse.Value),
                Top = imageBox.Height / 2,
                Left = imageBox.Width + 60,
                Height = 100,
                Width = 200
            };
            container.Add(descriptionText);

            var newHouse = new Label(gameInfo.Manager)
                               {Text = "     New offered house", Width = 150, Parent = container, Top = 200, Left = 16};
            newHouse.Init();

            var imageBox2 = new ImageBox(manager)
            {
                Left = 16,
                Top = 230,
                Image = gameInfo.Content.Load<Texture2D>(House.HouseGraphic),
                Color = Color.White,
                Width = houseGraphic.Width,
                Height = houseGraphic.Height
            };
            imageBox.Init();
            container.Add(imageBox2);

            var descriptionText2 = new Label(manager)
            {
                Text =
                    String.Format(
                        "Name : {0}\n\n" +
                        "Average Value: ${1:N0}" +
                        "\n\nCurrent Value: ${2:N0}\n\n",
                        House.Name, House.InitialValue, House.Value),
                Top = imageBox.Height*4 / 2,
                Left = imageBox2.Width + 60,
                Height = 100,
                Width = 200
            };
            container.Add(descriptionText2);

            var offerHouseLine = new Label(manager) { Text = "Would you like to sell your current house?", Width = 400, Top = imageBox.Height*2 + 140 };
            container.Add(offerHouseLine);

            container.Width = descriptionText.Left + descriptionText.Width + 16;
            container.Height = offerHouseLine.Top + offerHouseLine.Height;

            //"Would you like to buy this house? \n" + House.Name, "\nDo you want to buy a house""
            var confirmWindow = new ConfirmWindow(manager, String.Empty, title: "Do you want to sell your house?", control: container);
            confirmWindow.AffirmButton.Click += (sender, args) => SellCurrentHouse(confirmWindow, gameInfo, waitState);
            confirmWindow.DenyButton.Click += (sender, args) => CloseWindow(confirmWindow, gameInfo, waitState);
        }
예제 #15
0
        private void CreateMessage(Manager manager, GameInfo gameInfo, IGameState waitState)
        {
            var currentPlayer = gameInfo.CurrentPlayer;
            var previousPromotionLevel = currentPlayer.PromotionLevel;
            currentPlayer.IncreaseSalary();
            var newPromotionLevel = currentPlayer.PromotionLevel;

            gameInfo.Content.Load<SoundEffect>("Sounds/applause").Play();
            var messageWindow = new Window(manager) { Text = "Promotion!", AutoScroll = false, CloseButtonVisible = false};
            messageWindow.SetSize(400, 230);

            if (previousPromotionLevel != newPromotionLevel) {
                var message = new Label(manager) { Text = "Well Done! You have received a  promotion!!\nYou will now receive a higher salary.", Width = 300, Height = 40, Left = 5, Top = 10 };
                message.Init();
                message.Parent = messageWindow;
                var career = new ImageBox(manager) {
                    Image =
                        gameInfo.Content.Load<Texture2D>("Images/career_icons/" +
                                                         gameInfo.CurrentPlayer.CurrentCareer),
                    Top = 50,
                    Left = 10,
                    StayOnBack = true
                };
                career.Init();
                career.Parent = messageWindow;

                var job = new Label(manager) { Text = "Current Career:\n" + currentPlayer.CurrentCareer.Title, Top = 110, Left = 10, Width = 150, Height = 50 };
                job.Init();
                job.Parent = messageWindow;

                var salary = new Label(manager) {
                    Text = String.Format("New Promotion Level : {0}\n\n" +
                                         "Previous Salary : ${1:N0}\n\n" +
                                         "New Salary: ${2:N0}",
                   newPromotionLevel + 1, currentPlayer.CurrentCareer.Salary[previousPromotionLevel], currentPlayer.CurrentCareer.Salary[newPromotionLevel]),
                    Top = 65, Left = 140, Width = 200, Height = 300,
                    Alignment = Alignment.TopLeft
                };
                salary.Init();
                salary.Parent = messageWindow;

            } else {
                var message = new Label(manager) {
                    Text = String.Format("You have reached the maximum promotion level of {0} for being a {1} ",
                    currentPlayer.PromotionLevel, currentPlayer.CurrentCareer),
                    Width = 300,
                    Height = 40,
                    Left = 5,
                    Top = 10
                };
                message.Init();
                message.Parent = messageWindow;
            }

            var close = new Button(manager) { Text = "OK", Top = 150, Left = messageWindow.Width / 2 - 50 };
            close.Init();
            close.Parent = messageWindow;
            close.Click += (sender, args) => { messageWindow.Close(); gameInfo.Fsm.Remove(waitState); };
            gameInfo.Manager.Add(messageWindow);
            messageWindow.Init();
            gameInfo.Content.Load<SoundEffect>("Sounds/coins").Play();
        }
예제 #16
0
        public void Init()
        {
            texture = new Texture2D(manager.GraphicsDevice, 1, 1);
            texture.SetData<Color>(new Color[] { Color.White });

            window = new Window(manager) ;
            window.Init();
            window.Text = "Tank List";
            window.Width = 600;
            window.Height = 500;
            window.Center();
            window.Visible = true;
            window.CloseButtonVisible = false;

            play = new Button(manager);
            play.Init();
            play.Text = "Play";
            play.Width = 100;
            play.Height = 24;
            play.Left = window.Width - play.Width - 40;
            play.Top = window.Height - 90;
            play.Anchor = Anchors.Right;
            play.Parent = window;

            create = new Button(manager);
            create.Init();
            create.Text = "Create New Tank";
            create.Width = 150;
            create.Height = 24;
            create.Left = 30;
            create.Top = window.Height - 160;
            create.Anchor = Anchors.Left;
            create.Parent = window;

            edit = new Button(manager);
            edit.Init();
            edit.Text = "Edit Tank";
            edit.Width = 100;
            edit.Height = 24;
            edit.Left = 30;
            edit.Top = window.Height - 125;
            edit.Anchor = Anchors.Left;
            edit.Parent = window;

            delete = new Button(manager);
            delete.Init();
            delete.Text = "Delete Tank";
            delete.Width = 100;
            delete.Height = 24;
            delete.Left = edit.Left + edit.Width + 30;
            delete.Top = edit.Top;
            delete.Anchor = Anchors.Left;
            delete.Parent = window;

            back = new Button(manager);
            back.Init();
            back.Text = "Back";
            back.Width = 150;
            back.Height = 24;
            back.Left = 30;
            back.Top = play.Top;
            back.Anchor = Anchors.Left;
            back.Parent = window;

            listbox = new ListBox(manager);
            listbox.Init();
            listbox.Width = 225;
            listbox.Height = 275;
            listbox.Left = 30;
            listbox.Top = 40;
            listbox.Anchor = Anchors.Left;
            listbox.HideSelection = false;
            listbox.Parent = window;
            listbox.ItemIndexChanged += new TomShane.Neoforce.Controls.EventHandler(listbox_ItemIndexChanged);

            image = new ImageBox(manager);
            image.Init();
            image.Image = texture;
            image.SizeMode = SizeMode.Stretched;
            image.Width = 200;
            image.Height = 150;
            image.Left = window.Width - image.Width - 70;
            image.Top = 40;
            image.Anchor = Anchors.Right;
            image.Parent = window;

            RankImage = new ImageBox(manager);
            RankImage.Init();
            //RankImage.Image = null;
            RankImage.SizeMode = SizeMode.Stretched;
            RankImage.Width = 32;
            RankImage.Height = 32;
            RankImage.Top = window.Height - 280;
            RankImage.Left = window.Width - RankImage.Width - 240;
            RankImage.Anchor = Anchors.Left;
            RankImage.Parent = window;

            rankLbl = new Label(manager);
            rankLbl.Init();
            rankLbl.Text = "Unknown";
            rankLbl.Top = window.Height - 275;
            rankLbl.Anchor = Anchors.Left;
            rankLbl.Width = 232 - RankImage.Width;
            rankLbl.Left = window.Width - rankLbl.Width - RankImage.Width;
            rankLbl.Height = 24;
            rankLbl.Parent = window;

            RankProgressBar = new ProgressBar(manager);
            RankProgressBar.Init();
            RankProgressBar.Value = 0;
            RankProgressBar.Top = window.Height - 243;
            RankProgressBar.Anchor = Anchors.Left;
            RankProgressBar.Width = 200;
            RankProgressBar.Left = window.Width - rankLbl.Width - 69;
            RankProgressBar.Height = 25;
            RankProgressBar.ToolTip = new ToolTip(manager);
            RankProgressBar.ToolTip.Text = "0 / 0";
            RankProgressBar.Parent = window;

            RankNextLabel = new Label(manager);
            RankNextLabel.Init();
            RankNextLabel.Top = window.Height - 215;
            RankNextLabel.Width = 200;
            RankNextLabel.Height = 15;
            RankNextLabel.Left = window.Width - RankImage.Width - 235;
            RankNextLabel.Text = "Progress is loading...";
            RankNextLabel.Parent = window;

            armorBar = new ProgressBar(manager);
            armorBar.Init();
            armorBar.Width = 150;
            armorBar.Height = 24;
            armorBar.Left = window.Width - armorBar.Width - 50; ;
            armorBar.Top = window.Height - 180;
            armorBar.Anchor = Anchors.Left;
            armorBar.Parent = window;
            armorBar.Value = 50;

            armorLbl = new Label(manager);
            armorLbl.Init();
            armorLbl.Text = "Armor: ";
            armorLbl.Width = 50;
            armorLbl.Height = 24;
            armorLbl.Left = armorBar.Left - armorLbl.Width - 20;
            armorLbl.Top = armorBar.Top;
            armorLbl.Anchor = Anchors.Left;
            armorLbl.Parent = window;

            speedBar = new ProgressBar(manager);
            speedBar.Init();
            speedBar.Width = 150;
            speedBar.Height = 24;
            speedBar.Left = window.Width - speedBar.Width - 50; ;
            speedBar.Top = window.Height - 150;
            speedBar.Anchor = Anchors.Left;
            speedBar.Parent = window;
            speedBar.Value = 50;

            speedLbl = new Label(manager);
            speedLbl.Init();
            speedLbl.Text = "Speed: ";
            speedLbl.Width = 50;
            speedLbl.Height = 24;
            speedLbl.Left = speedBar.Left - speedLbl.Width - 20;
            speedLbl.Top = speedBar.Top;
            speedLbl.Anchor = Anchors.Left;
            speedLbl.Parent = window;
        }
예제 #17
0
        public void Init(Control parent, Manager manager)
        {
            switch (Type)
            {
                case "Container":
                    Container container = new Container(manager);
                    container.Init();

                    SetProperties(container, parent, manager);

                    container.AutoScroll = true;
                    break;
                case "ImageBox":
                    ImageBox box = new ImageBox(manager);
                    box.Init();

                    SetProperties(box, parent, manager);

                    box.SizeMode = ImageMode;

                    if (!string.IsNullOrEmpty(ImageAsset))
                        box.Image = manager.Content.Load<Texture2D>(ImageAsset);
                    else if (AtlasAsset != null)
                    {
                        if (AtlasAsset.Atlas == "IconProvider")
                            box.Image = IconProvider.GetByName(AtlasAsset.Name);
                        else
                            box.Image = Provider.GetAtlas(AtlasAsset.Atlas).GetTexture(AtlasAsset.Name);
                    }

                    if (!string.IsNullOrEmpty(Draw))
                        box.Draw += delegate(object sender, DrawEventArgs e)
                        {
                            if (EventFieldDraw == null)
                            {
                                Type classType = parent.GetType();
                                EventFieldDraw = classType.GetMethod(Draw);
                            }

                            if (EventFieldDraw == null)
                                throw new Exception("Could not find: " + Draw + " method");

                            EventFieldDraw.Invoke(parent, new object[] { sender, e });
                        };
                    break;
                case "Label":
                    Label label = new Label(manager);
                    label.Init();

                    SetProperties(label, parent, manager);

                    label.Text = Text.StartsWith("TXT_KEY_") ? Provider.Instance.Translate(Text) : Text;

                    break;
                case "GameMapBox":
                    GameMapBox mapBox = new GameMapBox(manager);
                    mapBox.Init();

                    SetProperties(mapBox, parent, manager);

                    break;
                case "SideBar":
                    SideBar sideBar = new SideBar(manager);
                    sideBar.Init();

                    SetProperties(sideBar, parent, manager);

                    if (!string.IsNullOrEmpty(Draw))
                        sideBar.Draw += delegate(object sender, DrawEventArgs e)
                        {
                            if (EventFieldDraw == null)
                            {
                                Type classType = parent.GetType();
                                EventFieldDraw = classType.GetMethod(Draw);
                            }

                            if (EventFieldDraw == null)
                                throw new Exception("Could not find: " + Draw + " method");

                            EventFieldDraw.Invoke(parent, new object[] { sender, e });
                        };

                    break;
                case "ContextMenu":
                    ContextMenu contextMenu = new ContextMenu(manager);
                    contextMenu.Init();

                    contextMenu.Name = Name;
                    contextMenu.Tag = this;
                    contextMenu.Passive = Passive;
                    contextMenu.Enabled = Enabled;

                    foreach (MenuItemEntry entry in Items)
                    {
                        MenuItem menuItem = new MenuItem(entry.Title);
                        menuItem.Enabled = entry.Enabled;

                        contextMenu.Items.Add(menuItem);
                    }

                    if (!string.IsNullOrEmpty(Parent))
                        contextMenu.Parent = parent.GetControl(Parent);
                    else
                        parent.Add(contextMenu);

                    break;

                case "ImageListBox":
                    ImageListBox listBox = new ImageListBox(manager);
                    listBox.Init();

                    SetProperties(listBox, parent, manager);

                    listBox.HideSelection = HideSelection;

                    if (!string.IsNullOrEmpty(ContextMenu))
                        listBox.ContextMenu = parent.GetControl(ContextMenu) as ContextMenu;

                    break;

                case "TechInfoButton":
                    TechInfoButton techInfo = new TechInfoButton(manager);
                    techInfo.Init();

                    SetProperties(techInfo, parent, manager);

                    if (!string.IsNullOrEmpty(TechName))
                        techInfo.Tech = Provider.GetTech(TechName);

                    break;
                case "PolicyButton":
                    PolicyButton policyButton = new PolicyButton(manager);
                    policyButton.Init();

                    SetProperties(policyButton, parent, manager);

                    if (!string.IsNullOrEmpty(PolicyName))
                        policyButton.Policy = Provider.GetPolicy(PolicyName);

                    break;
                case "PolicyTypeBox":
                    PolicyTypeBox policyTypeBox = new PolicyTypeBox(manager);
                    policyTypeBox.Init();

                    SetProperties(policyTypeBox, parent, manager);

                    if (!string.IsNullOrEmpty(PolicyTypeName))
                        policyTypeBox.PolicyType = Provider.GetPolicyType(PolicyTypeName);

                    if (!string.IsNullOrEmpty(ImageAsset))
                        policyTypeBox.Image = manager.Content.Load<Texture2D>(ImageAsset);
                    else if (AtlasAsset != null)
                    {
                        if (AtlasAsset.Atlas == "IconProvider")
                            policyTypeBox.Image = IconProvider.GetByName(AtlasAsset.Name);
                        else
                            policyTypeBox.Image = Provider.GetAtlas(AtlasAsset.Atlas).GetTexture(AtlasAsset.Name);
                    }

                    break;
                case "ImageButton":
                    ImageButton button = new ImageButton(manager);
                    button.Init();

                    ApplyStyle(button, manager);
                    SetProperties(button, parent, manager);
                    SetAnimation(button, manager);

                    button.Text = Text;
                    break;
                case "ProgressBar":
                    ProgressBar progress = new ProgressBar(manager);
                    progress.Init();

                    SetProperties(progress, parent, manager);
                    break;
                case "CheckBox":
                    CheckBox check = new CheckBox(manager);
                    check.Init();

                    SetProperties(check, parent, manager);

                    check.Text = Text;
                    break;
                case "Graph":
                    Graph graph = new Graph(manager);
                    graph.Init();

                    SetProperties(graph, parent, manager);

                    break;
                case "RankingRow":
                    RankingRow rank = new RankingRow(manager);
                    rank.Init();

                    SetProperties(rank, parent, manager);
                    break;
                case "Include":
                    List<ControlItem> children = manager.Content.Load<List<ControlItem>>(Import);

                    foreach (ControlItem item in children)
                        item.Init(parent, manager);
                    break;
                default:
                    throw new Exception("No handling for " + Type);
            }
        }
예제 #18
0
		////////////////////////////////////////////////////////////////////////////


		#endregion

		#region //// Constructors //////

		////////////////////////////////////////////////////////////////////////////   
		public TaskDialog(Manager manager)
			: base(manager)
		{
			//Alpha = 200;      
			Height = 520;
			MinimumWidth = 254;
			MinimumHeight = 160;
			Center();

			TopPanel.Height = 80;
			TopPanel.BevelStyle = BevelStyle.None;
			TopPanel.BevelBorder = BevelBorder.None;
			Caption.Visible = false;
			Description.Visible = false;
			Text = "Dialog Template";

			imgTop = new ImageBox(manager);
			imgTop.Init();
			imgTop.Parent = TopPanel;
			imgTop.Top = 0;
			imgTop.Left = 0;
			imgTop.Width = TopPanel.ClientWidth;
			imgTop.Height = TopPanel.ClientHeight;
			imgTop.Anchor = Anchors.Left | Anchors.Top | Anchors.Right | Anchors.Bottom;
			imgTop.SizeMode = SizeMode.Normal;
			imgTop.Image = Manager.Content.Load<Texture2D>("Content\\Images\\Caption");

			tbcMain = new TabControl(manager);
			tbcMain.Init();
			tbcMain.Parent = this;
			tbcMain.Left = 4;
			tbcMain.Top = TopPanel.Height + 4;
			tbcMain.Width = ClientArea.Width - 8;
			tbcMain.Height = ClientArea.Height - 8 - TopPanel.Height - BottomPanel.Height;
			tbcMain.Anchor = Anchors.All;
			tbcMain.AddPage();
			tbcMain.TabPages[0].Text = "First";
			tbcMain.AddPage();
			tbcMain.TabPages[1].Text = "Second";
			tbcMain.AddPage();
			tbcMain.TabPages[2].Text = "Third";

			btnFirst = new Button(manager);
			btnFirst.Init();
			btnFirst.Parent = tbcMain.TabPages[0];
			btnFirst.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;
			btnFirst.Top = 8;
			btnFirst.Left = 8;
			btnFirst.Width = btnFirst.Parent.ClientWidth - 16;
			btnFirst.Text = ">>> First Page Button <<<";

			grpFirst = new GroupPanel(manager);
			grpFirst.Init();
			grpFirst.Parent = tbcMain.TabPages[0];
			grpFirst.Anchor = Anchors.All;
			//grpFirst.Type = GroupBoxType.Flat;
			grpFirst.Left = 8;
			grpFirst.Top = btnFirst.Top + btnFirst.Height + 4;
			grpFirst.Width = btnFirst.Parent.ClientWidth - 16;
			grpFirst.Height = btnFirst.Parent.ClientHeight - grpFirst.Top - 8;

			btnSecond = new Button(manager);
			btnSecond.Init();
			btnSecond.Parent = tbcMain.TabPages[1];
			btnSecond.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;
			btnSecond.Top = 8;
			btnSecond.Left = 8;
			btnSecond.Width = btnSecond.Parent.ClientWidth - 16;
			btnSecond.Text = ">>> Second Page Button <<<";

			btnThird = new Button(manager);
			btnThird.Init();
			btnThird.Parent = tbcMain.TabPages[2];
			btnThird.Anchor = Anchors.Left | Anchors.Top | Anchors.Right;
			btnThird.Top = 8;
			btnThird.Left = 8;
			btnThird.Width = btnThird.Parent.ClientWidth - 16;
			btnThird.Text = ">>> Third Page Button <<<";

			btnOk = new Button(manager);
			btnOk.Init();
			btnOk.Parent = BottomPanel;
			btnOk.Anchor = Anchors.Top | Anchors.Right;
			btnOk.Top = btnOk.Parent.ClientHeight - btnOk.Height - 8;
			btnOk.Left = btnOk.Parent.ClientWidth - 8 - btnOk.Width * 3 - 8;
			btnOk.Text = "OK";
			btnOk.ModalResult = ModalResult.Ok;

			btnApply = new Button(manager);
			btnApply.Init();
			btnApply.Parent = BottomPanel;
			btnApply.Anchor = Anchors.Top | Anchors.Right;
			btnApply.Top = btnOk.Parent.ClientHeight - btnOk.Height - 8;
			btnApply.Left = btnOk.Parent.ClientWidth - 4 - btnOk.Width * 2 - 8;
			btnApply.Text = "Apply";

			btnClose = new Button(manager);
			btnClose.Init();
			btnClose.Parent = BottomPanel;
			btnClose.Anchor = Anchors.Top | Anchors.Right;
			btnClose.Top = btnOk.Parent.ClientHeight - btnClose.Height - 8;
			btnClose.Left = btnOk.Parent.ClientWidth - btnClose.Width - 8;
			btnClose.Text = "Close";
			btnClose.ModalResult = ModalResult.Cancel;

			btnFirst.Focused = true;
		}
예제 #19
0
        public override void Init()
        {
            base.Init();
            window = new Window(Manager);
            window.Init();
            window.Text = title;
            window.Width = 375;
            window.Height = 200;
            window.Center();
            window.Visible = true;

            box = new ImageBox(Manager);
            box.Init();
            box.Height = 32;
            box.Width = 32;

            box.Top = 100-40;
            box.Left = 20;
            box.SizeMode = SizeMode.Stretched;
            box.Parent = window;

            label = new Label(Manager);
            label.Init();
            label.Width = window.Width - 80;
            label.Height = 150;
            label.Top = 0;
            label.Left = box.Left + box.Width + 10;
            label.Text = FormatString(message);
            label.Parent = window;

            if (Type == MessageBoxType.OKAY)
            {
                buttons.Add(new Button(Manager));
                buttons[0].Init();
                buttons[0].Width = 50;
                buttons[0].Height = 24;
                buttons[0].Top = (int)(window.Height * .62);
                buttons[0].Left = (window.Width / 2) - (buttons[0].Width / 2);
                buttons[0].Text = "Okay";
                buttons[0].Parent = window;
                buttons[0].Click += new TomShane.Neoforce.Controls.EventHandler(OkayButtonClick);

                box.Image = Manager.Skin.Images["Icon.Information"].Resource;
            }
            else if (Type == MessageBoxType.ERROR)
            {
                buttons.Add(new Button(Manager));
                buttons[0].Init();
                buttons[0].Width = 50;
                buttons[0].Height = 24;
                buttons[0].Top = (int)(window.Height * .62);
                buttons[0].Left = (window.Width / 2) - (buttons[0].Width / 2);
                buttons[0].Text = "Okay";
                buttons[0].Parent = window;
                buttons[0].Click += new TomShane.Neoforce.Controls.EventHandler(OkayButtonClick);
                box.Image = Manager.Skin.Images["Icon.Error"].Resource;
            }
            else if (Type == MessageBoxType.YES_NO)
            {
                buttons.Add(new Button(Manager));
                buttons[0].Init();
                buttons[0].Width = 50;
                buttons[0].Height = 24;
                buttons[0].Top = (int)(window.Height * .62);
                buttons[0].Left = (window.Width / 2) + 10;
                buttons[0].Text = "No";
                buttons[0].Parent = window;
                buttons[0].Click += new TomShane.Neoforce.Controls.EventHandler(NoButtonClick);

                buttons.Add(new Button(Manager));
                buttons[1].Init();
                buttons[1].Width = 50;
                buttons[1].Height = 24;
                buttons[1].Top = buttons[0].Top;
                buttons[1].Left = (window.Width / 2) - (buttons[1].Width) - 10;
                buttons[1].Text = "Yes";
                buttons[1].Parent = window;
                buttons[1].Click += new TomShane.Neoforce.Controls.EventHandler(YesButtonClick);

                box.Image = Manager.Skin.Images["Icon.Question"].Resource;
            }
            else if (Type == MessageBoxType.YES_NO_CANCEL)
            {
                buttons.Add(new Button(Manager));
                buttons[0].Init();
                buttons[0].Width = 50;
                buttons[0].Height = 24;
                buttons[0].Text = "Yes";
                buttons[0].Top = (int)(window.Height * .62);
                buttons[0].Left = (window.Width / 2) - (buttons[0].Width) - 40;
                buttons[0].Parent = window;
                buttons[0].Click += new TomShane.Neoforce.Controls.EventHandler(YesButtonClick);

                buttons.Add(new Button(Manager));
                buttons[1].Init();
                buttons[1].Width = 50;
                buttons[1].Height = 24;
                buttons[1].Text = "No";
                buttons[1].Top = buttons[0].Top;
                buttons[1].Left = (window.Width / 2) - (buttons[1].Width /2);
                buttons[1].Parent = window;
                buttons[1].Click += new TomShane.Neoforce.Controls.EventHandler(NoButtonClick);

                buttons.Add(new Button(Manager));
                buttons[2].Init();
                buttons[2].Width = 50;
                buttons[2].Height = 24;
                buttons[2].Text = "Cancel";
                buttons[2].Top = buttons[0].Top;
                buttons[2].Left = (window.Width / 2) + 40;

                buttons[2].Parent = window;
                buttons[2].Click += new TomShane.Neoforce.Controls.EventHandler(CancelButtonClick);

                box.Image = Manager.Skin.Images["Icon.Question"].Resource;
            }

            foreach (Button btn in buttons)
            {
                window.Add(btn);
            }
        }
예제 #20
0
        public ServerWindow(Manager manager)
            : base(manager)
        {
            //Setup server pinger/query
            Pinger = new ServerPinger();
            //Setup the window
            CaptionVisible = false;
            Caption.Text = "Welcome to Bricklayer!";
            Description.Text = "An open source, fully moddable and customizable 2D\nbuilding game built with the community in mind.";
            Movable = false;
            Resizable = false;
            Width = 450;
            Height = 350;
            Shadow = true;
            Center();

            //Player config
            NameLbl = new Label(Manager) { Left = 8, Top = TopPanel.Bottom + 10, Width = 64, Text = "Username:"******"Color:" };
            ColorLbl.Init();
            Add(ColorLbl);

            BodyClr = new ColorPicker(Manager) { Left = ColorLbl.Right + 4, Top = TopPanel.Bottom + 8, Width = 128, Saturation = GlobalSettings.ColorSaturation, Value = GlobalSettings.ColorValue };
            BodyClr.Init();
            BodyClr.ValueChanged += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e)
            {
                BodyImg.Color = BodyClr.SelectedColor;
                Game.MyColor = BodyClr.SelectedColor;
                Game.MyHue = BodyClr.Hue;
            });
            Add(BodyClr);

            BodyImg = new ImageBox(Manager) { Left = BodyClr.Right + 6, Top = TopPanel.Bottom + 8, Width = 18, Height = 18, Color = Game.MyColor, Image = ContentPack.Textures["entity\\body"] };
            BodyImg.Init();
            Add(BodyImg);

            SmileyImg = new ImageBox(Manager) { Left = BodyClr.Right + 6, Top = TopPanel.Bottom + 8, Width = 18, Height = 18, Image = ContentPack.Textures["entity\\smileys"], SourceRect = new Rectangle(0, 0, 18, 18) };
            SmileyImg.Init();
            SmileyImg.ToolTip.Text = "I love this color!";
            Add(SmileyImg);

            BodyClr.Hue = Game.MyHue;
            //Create main server list
            ServerListCtrl = new ControlList<ServerDataControl>(manager) { Left = 8, Top = TopPanel.Bottom + 34, Width = ClientWidth - 16, Height = ClientHeight - TopPanel.Height - BottomPanel.Height - 42 };
            ServerListCtrl.Init();
            Add(ServerListCtrl);
            RefreshServerList();

            //Add BottomPanel controls
            JoinBtn = new Button(manager) { Text = "Connect", Left = 24, Top = 8, Width = 100, };
            JoinBtn.Init();
            JoinBtn.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e)
            {
                //Logical place to save name/color settings
                IO.SaveSettings(new Settings() { Username = Game.Username, Color = Game.MyHue, ContentPack = Game.ContentPackName, Resolution = new Point(Game.Resolution.Width, Game.Resolution.Height), UseVSync = Game.MainWindow.Manager.Graphics.SynchronizeWithVerticalRetrace });
                //Connect
                if (ServerListCtrl.Items.Count > 0)
                {
                    if ((ServerListCtrl.Items[ServerListCtrl.ItemIndex] as ServerDataControl).Ping != null && (ServerListCtrl.Items[ServerListCtrl.ItemIndex] as ServerDataControl).Ping.Error)
                        return;
                    //Create a world and connect
                    JoinBtn.Enabled = false;
                    JoinBtn.Text = "Connecting...";
                    Game.NetManager.Connect(Servers[ServerListCtrl.ItemIndex].IP, Servers[ServerListCtrl.ItemIndex].Port);
                }
            });
            BottomPanel.Add(JoinBtn);

            AddBtn = new Button(manager) { Text = "Add", Left = JoinBtn.Right + 8, Top = 8, Width = 64, };
            AddBtn.Init();
            AddBtn.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e)
            {
                AddServerDialog window = new AddServerDialog(manager, this,ServerListCtrl.ItemIndex, false, string.Empty, string.Empty);
                window.Init();
                Manager.Add(window);
                window.Show();
            });
            BottomPanel.Add(AddBtn);

            EditBtn = new Button(manager) { Text = "Edit", Left = AddBtn.Right + 8, Top = 8, Width = 64, };
            EditBtn.Init();
            EditBtn.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e)
            {
                if (ServerListCtrl.Items.Count > 0)
                {
                    AddServerDialog window = new AddServerDialog(manager, this, ServerListCtrl.ItemIndex, true, Servers[ServerListCtrl.ItemIndex].Name, Servers[ServerListCtrl.ItemIndex].GetHostString());
                    window.Init();
                    Manager.Add(window);
                    window.Show();
                }
            });
            BottomPanel.Add(EditBtn);

            RemoveBtn = new Button(manager) { Text = "Remove", Left = EditBtn.Right + 8, Top = 8, Width = 64 };
            RemoveBtn.Init();
            RemoveBtn.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e)
            {
                if (ServerListCtrl.Items.Count > 0)
                {
                    MessageBox confirm = new MessageBox(manager, MessageBoxType.YesNo, "Are you sure you would like to remove\nthis server from your server list?", "[color:Red]Confirm Removal[/color]");
                    confirm.Init();
                    confirm.Closed += new WindowClosedEventHandler(delegate(object sender, WindowClosedEventArgs args)
                    {
                        if ((sender as Dialog).ModalResult == ModalResult.Yes) //If user clicked yes
                        {
                            Servers.RemoveAt(ServerListCtrl.ItemIndex);
                            ServerListCtrl.Items.RemoveAt(ServerListCtrl.ItemIndex);
                            IO.WriteServers(Servers);
                            RefreshServerList();
                        }
                    });
                    Manager.Add(confirm);
                    confirm.Show();
                }
            });
            BottomPanel.Add(RemoveBtn);

            RefreshBtn = new Button(manager) { Text = "Refresh", Left = RemoveBtn.Right + 8, Top = 8, Width = 64 };
            RefreshBtn.Init();
            RefreshBtn.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e)
            {
                RefreshServerList();
            });
            BottomPanel.Add(RefreshBtn);
            MainWindow.ScreenManager.FadeIn();
            validateUsername();
        }
예제 #21
0
    ////////////////////////////////////////////////////////////////////////////    

    #endregion 
    
		#region //// Methods ///////////
			
		////////////////////////////////////////////////////////////////////////////
		protected override void Initialize()
    {
      base.Initialize();
      
      // Load image      
      image = Content.Load<Texture2D>("Content\\Image");
                                                
      // Creates and initializes window
      window = new Window(manager);
      window.Init();      
      window.Text = "ScrollBars";
      window.Width = 360;
      window.Height = 360;      
      window.Center();
      window.Visible = true;      

      // Setup of the vertical scrollbar      
      vert = new ScrollBar(manager, Orientation.Vertical);
      vert.Init();
      vert.Parent = window;
      vert.Top = 0;
      vert.Left = window.ClientWidth - vert.Width ;
      vert.Height = window.ClientHeight - vert.Width;
      vert.Value = 0;
      vert.Anchor = Anchors.Top | Anchors.Right | Anchors.Bottom;

      // Setup of the horizontal scrollbar
      horz = new ScrollBar(manager, Orientation.Horizontal);
      horz.Init();
      horz.Parent = window;
      horz.Left = 0;
      horz.Top = window.ClientHeight - horz.Height;
      horz.Width = window.ClientWidth - vert.Width;
      horz.Value = 0;
      horz.Anchor = Anchors.Left | Anchors.Right | Anchors.Bottom;
      
      // Creates imagebox in the client area
      box = new ImageBox(manager);
      box.Init();
      box.Parent = window;
      box.Left = 0;
      box.Top = 0;
      box.Width = window.ClientWidth - vert.Width;
      box.Height = window.ClientHeight - horz.Height;
      box.Image = image;      
      box.Anchor = Anchors.All;
            
      // Add window to manager processing
      manager.Add(window);

      // Bind events
      window.Resize += new ResizeEventHandler(Recalc);
      vert.ValueChanged += new EventHandler(ValueChanged);
      horz.ValueChanged += new EventHandler(ValueChanged);
      Recalc(this, null); // Calculates initial properties of the scrollbars
    }
예제 #22
0
        private void CreateFirstPage(Manager manager, Player[] playerList, TabPage control)
        {
            var yPos = 16;
            var padding = 10;
            // Get the player that won
            var winningPlayer = playerList.MaxBy(i => i.TotalValue);

            var winningPlayerLabel = new Label(manager) {
                Text = "The current leader is " + winningPlayer.Name,
                Width = 400,
                Alignment = Alignment.MiddleCenter,
                Parent = control,
                Top = yPos,
                Name = IgnoreString
            };
            yPos += winningPlayerLabel.Height + 16;

            var playerAvatar = winningPlayer.Avatar;

            var imageIcon = new Button(manager) {
                Glyph = new Glyph(playerAvatar),
                Height = (int)(playerAvatar.Height / 1.5),
                Width = (int)(playerAvatar.Width / 1.5),
                Left = 16,
                Name = IgnoreString,
                Top = yPos,
                Parent = control,
                Color = winningPlayer.PlayerColor,
            };
            imageIcon.Init();
            imageIcon.FocusGained += (sender, args) => imageIcon.Enabled = false;

            var descriptionText = new Label(manager) {
                Left = imageIcon.Left + imageIcon.Width + 16, Width = 200,
                Height = imageIcon.Height,
                Top = yPos + 9,
                Text = String.Format(
                    "Player Name : {0}\n\n" +
                    "Player Cash : ${1:N0}\n\n" +
                    "Player Total Worth : ${2:N0}\n\n" +
                    "Player Position : {3:N0}\n\n",
                    winningPlayer.Name, winningPlayer.Cash, winningPlayer.TotalValue, 1),
                Alignment = Alignment.TopLeft,
                Parent = control,
                Name = IgnoreString,
            };
            descriptionText.Init();

            yPos = imageIcon.Top + imageIcon.Height + 16;

            int playerCount = 0;

            var leaderBoard = new ImageBox(manager) {
                Image = manager.Game.Content.Load<Texture2D>("images/leaderboard"),
                Top = yPos - padding,
                Left = 200 - 100, Parent = control, Width = 250,
                                Name = IgnoreString
            };
            leaderBoard.Init();
            yPos += leaderBoard.Height / 3;
            foreach (var player in playerList.OrderByDescending(i => i.TotalValue))
            {
                playerCount++;
                var label = new Label(manager)
                                {
                                    Text = String.Format("{0}. {1}\n\n          " +
                                                         "Total Value : ${3:N0}\n          " +
                                                         "Current Cash : ${2:N0}",
                                                         playerCount, player.Name, player.Cash, player.TotalValue),
                                    Height = 50,
                                    Width = 400,
                                    Parent = control,
                                    Left = 80,
                                    Top = yPos,
                                    Name = IgnoreString
                                };
                yPos += label.Height + 10;
            }

            createdPages[control] = yPos + 30;
        }
예제 #23
0
 public ImageButton(Manager manager) : base(manager)
 {
     ImageBox = new ImageBox(manager);
     
 }