コード例 #1
0
        public override void Add(ScreenManager screenManager)
        {
            base.Add(screenManager);
            Window.Focused = true;
            Bar            = new StatusBar(Manager)
            {
                Top = Window.Height - 24, Width = Window.Width
            };
            Bar.Init();
            Window.Add(Bar);
            StatsLabel = new Label(Manager)
            {
                Top = 4, Left = 8, Width = Window.Width - 16, Text = ""
            };
            StatsLabel.Init();
            Bar.Add(StatsLabel);

            LeaveButton = new Button(Manager)
            {
                Right = Bar.ClientWidth - 4, Top = 4, Height = 16, Text = "Lobby"
            };
            LeaveButton.Init();
            LeaveButton.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e)
            {
                ScreenManager.SwitchScreen(new LobbyScreen());
            });
            Bar.Add(LeaveButton);

            Sidebar = new StatusBar(Manager);
            Sidebar.Init();
            Sidebar.SetSize(SidebarWidth, (int)((Window.Height - Bar.Height)));
            Sidebar.SetPosition(Window.Width - Sidebar.Width, 0);
            Window.Add(Sidebar);

            PlayerList = new ListBox(Manager);
            PlayerList.Init();
            PlayerList.SetSize(SidebarWidth, (int)((Window.Height - Bar.Height - 4) * .25f));
            PlayerList.SetPosition(1, 2);
            Sidebar.Add(PlayerList);

            ChatBox = new Console(Manager);
            Manager.Add(ChatBox);
            ChatBox.Init();
            ChatBox.SetSize(PlayerList.Width, (int)((Window.Height - Bar.Height - 4) * .75f));
            ChatBox.SetPosition(Sidebar.Left + 1, PlayerList.Bottom + 1);
            ChatBox.ChannelsVisible = false;
            ChatBox.MessageSent    += new ConsoleMessageEventHandler(SentChat);
            ChatBox.Channels.Add(new ConsoleChannel(0, "Global", Color.White));
            // Select default channel
            ChatBox.SelectedChannel = 0;
            // Do we want to add timestamp or channel name at the start of every message?
            ChatBox.MessageFormat        = ConsoleMessageFormats.None;
            ChatBox.TextBox.TextChanged += TextBox_TextChanged;

            //Hide them until we recieve the Init packet
            ChatBox.Visible = PlayerList.Visible = Sidebar.Visible = false;
        }
コード例 #2
0
ファイル: GameScreen.cs プロジェクト: Express50/Bricklayer
        public override void Add(ScreenManager screenManager)
        {
            base.Add(screenManager);
            Window.Focused = true;
            Bar = new StatusBar(Manager) { Top = Window.Height - 24, Width = Window.Width };
            Bar.Init();
            Window.Add(Bar);
            StatsLabel = new Label(Manager) { Top = 4, Left = 8, Width = Window.Width - 16, Text = "" };
            StatsLabel.Init();
            Bar.Add(StatsLabel);

            LeaveButton = new Button(Manager) { Right = Bar.ClientWidth - 4, Top = 4, Height = 16, Text = "Lobby" };
            LeaveButton.Init();
            LeaveButton.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e)
            {
                ScreenManager.SwitchScreen(new LobbyScreen());
            });
            Bar.Add(LeaveButton);

            Sidebar = new StatusBar(Manager);
            Sidebar.Init();
            Sidebar.SetSize(SidebarWidth, (int)((Window.Height - Bar.Height)));
            Sidebar.SetPosition(Window.Width - Sidebar.Width, 0);
            Window.Add(Sidebar);

            PlayerList = new ListBox(Manager);
            PlayerList.Init();
            PlayerList.SetSize(SidebarWidth, (int)((Window.Height - Bar.Height - 4) * .25f));
            PlayerList.SetPosition(1, 2);
            Sidebar.Add(PlayerList);

            ChatBox = new Console(Manager);
            Manager.Add(ChatBox);
            ChatBox.Init();
            ChatBox.SetSize(PlayerList.Width, (int)((Window.Height - Bar.Height - 4) * .75f));
            ChatBox.SetPosition(Sidebar.Left + 1, PlayerList.Bottom + 1);
            ChatBox.ChannelsVisible = false;
            ChatBox.MessageSent += new ConsoleMessageEventHandler(SentChat);
            ChatBox.Channels.Add(new ConsoleChannel(0, "Global", Color.White));
            // Select default channel
            ChatBox.SelectedChannel = 0;
            // Do we want to add timestamp or channel name at the start of every message?
            ChatBox.MessageFormat = ConsoleMessageFormats.None;
            ChatBox.TextBox.TextChanged += TextBox_TextChanged;

            //Hide them until we recieve the Init packet
            ChatBox.Visible = PlayerList.Visible = Sidebar.Visible = false;
        }
コード例 #3
0
        public ConsoleControl(StackEngine engine, ConsoleMessageEventHandler messageSent, KeyEventHandler keyUp)
        {
            Manager         = engine.Renderer.GUIManager;
            WindowUIControl = new TomShane.Neoforce.Controls.Window(Manager);
            WindowUIControl.Init();
            WindowUIControl.Text               = "STACK Engine Console";
            WindowUIControl.Width              = 480;
            WindowUIControl.Resizable          = true;
            WindowUIControl.MinimumHeight      = 240;
            WindowUIControl.MinimumWidth       = 320;
            WindowUIControl.Height             = 200;
            WindowUIControl.IconVisible        = false;
            WindowUIControl.Alpha              = 215;
            WindowUIControl.CloseButtonVisible = false;
            WindowUIControl.Closing           += (object sender, WindowClosingEventArgs e) => e.Cancel = true;
            WindowUIControl.Visible            = false;
            WindowUIControl.Color              = Color.Black;
            WindowUIControl.Center(engine.Game.VirtualResolution);

            ConsoleUIControl = new TomShane.Neoforce.Controls.Console(Manager);
            ConsoleUIControl.Channels.Add(new ConsoleChannel((byte)Console.Channel.System, "System", Color.White));
            ConsoleUIControl.Channels.Add(new ConsoleChannel((byte)Console.Channel.Debug, "Debug", Color.LightGray));
            ConsoleUIControl.Channels.Add(new ConsoleChannel((byte)Console.Channel.Error, "Error", Color.IndianRed));
            ConsoleUIControl.Channels.Add(new ConsoleChannel((byte)Console.Channel.Notice, "Notice", Color.DimGray));
            ConsoleUIControl.Channels.Add(new ConsoleChannel((byte)Console.Channel.Warning, "Warning", Color.DeepPink));
            ConsoleUIControl.Channels.Add(new ConsoleChannel((byte)Console.Channel.User, "User", Color.Gray));
            ConsoleUIControl.SelectedChannel       = (byte)Console.Channel.User;
            ConsoleUIControl.ChannelsVisible       = false;
            ConsoleUIControl.ClientArea.Left       = 10;
            ConsoleUIControl.Color                 = Color.Black;
            ConsoleUIControl.MessageFormat         = ConsoleMessageFormats.TimeStamp;
            ConsoleUIControl.TextBox.Color         = Color.Black;
            ConsoleUIControl.Sender                = "User";
            ConsoleUIControl.TextBox.KeyUp        += keyUp;
            ConsoleUIControl.TextBox.AutoSelection = false;
            ConsoleUIControl.Width                 = WindowUIControl.ClientWidth - ConsoleUIControl.Left;
            ConsoleUIControl.Height                = WindowUIControl.ClientHeight;
            ConsoleUIControl.Parent                = WindowUIControl;

            ConsoleUIControl.MessageSent += messageSent;

            WindowUIControl.Resize += new ResizeEventHandler(OnWindowResize);

            Manager.Add(WindowUIControl);
        }
コード例 #4
0
ファイル: DetoxConsole.cs プロジェクト: atom0s/Detox
        /// <summary>
        /// Default Constructor
        /// </summary>
        /// <param name="manager"></param>
        public DetoxConsole(Manager manager)
            : base(manager)
        {
            // Initialize this control..
            base.Init();
            base.Left      = base.Top = 0;
            base.Name      = "frmConsole";
            base.Width     = Terraria.MainGame.Window.ClientBounds.Width;
            base.Height    = 250;
            base.Alpha     = 255;
            base.Resizable = false;
            //
            //
            //
            this._console = new TomShane.Neoforce.Controls.Console(manager)
            {
                Anchor          = Anchors.All,
                Name            = "DetoxConsole",
                Width           = base.ClientArea.Width,
                Height          = base.ClientArea.Height,
                ChannelsVisible = false,
                MessageFormat   = ConsoleMessageFormats.TimeStamp,
                TextColor       = Color.White
            };
            this._console.Channels.AddRange(new[]
            {
                new ConsoleChannel(0, "About", Color.Chartreuse),
                new ConsoleChannel(1, "Default", Color.White),
                new ConsoleChannel(2, "Warning", Color.Yellow),
                new ConsoleChannel(3, "Error", Color.Red)
            });
            this._console.SelectedChannel = 1;
            this._console.MessageSent    += (sender, e) =>
            {
                // Ensure the command is valid..
                if (string.IsNullOrEmpty(e.Message.Text) || !e.Message.Text.StartsWith("/"))
                {
                    return;
                }

                // Attempt to handle the command..
                e.Handled = ConsoleCommands.ProcessCommand(e.Message.Text);
                if (!e.Handled)
                {
                    this.LogConsoleMessage(new DetoxAPI.ConsoleMessage("Invalid command or command error occurred.", ConsoleMessageType.Error));
                    e.Handled = true;
                }
            };
            this._console.Init();
            //
            //
            //
            base.Add(this._console);
            manager.Add(this);

            // Attach device settings event to resize console..
            manager.DeviceSettingsChanged += args =>
            {
                // Adjust the base panel size..
                base.Width  = Terraria.MainGame.Window.ClientBounds.Width;
                base.Height = 250;

                // Adjust the console size..
                this._console.Width  = base.ClientArea.Width;
                this._console.Height = base.ClientArea.Height;
            };

            // Locate the console textbox..
            var consoleEdit = this._console.Controls.SingleOrDefault(c => c.GetType() == typeof(TextBox));

            if (consoleEdit == null)
            {
                return;
            }

            consoleEdit.KeyDown += (sender, e) =>
            {
                // Prevent tilde from being processed..
                if (e.Key == Keys.OemTilde)
                {
                    e.Handled = true;
                }

                // Force escape to remove focus from the console..
                if (e.Key == Keys.Escape)
                {
                    consoleEdit.Focused = false;
                    e.Handled           = true;
                }
            };
            consoleEdit.KeyPress += (sender, e) =>
            {
                if (e.Key == Keys.OemTilde)
                {
                    e.Handled = true;
                }
            };
            consoleEdit.KeyUp += (sender, e) =>
            {
                if (e.Key == Keys.OemTilde)
                {
                    e.Handled = true;
                }
            };
            consoleEdit.TextChanged += (sender, e) =>
            {
                consoleEdit.Suspended = true;
                consoleEdit.Text      = consoleEdit.Text.Replace("`", "");
                consoleEdit.Suspended = false;
                e.Handled             = true;
            };
            consoleEdit.FocusGained += (sender, e) => Terraria.SetMainField("chatMode", false);
            consoleEdit.FocusLost   += (sender, e) => Terraria.SetMainField("chatMode", false);

            // Subscribe to the API console message event..
            DetoxAPI.Console.PrintConsoleMessage += (sender, e) => this.LogConsoleMessage(e);

            // Register some basic console commands..
            DetoxAPI.ConsoleCommands.AddCommnd(new List <string> {
                "help", "info", "h", "?"
            }, "Prints a list of registered console commands.", OnHelpCommand);
            DetoxAPI.ConsoleCommands.AddCommnd(new List <string> {
                "exit", "close", "terminate"
            }, "Exits Terraria immediately.", args => System.Windows.Forms.Application.Exit());
            DetoxAPI.ConsoleCommands.AddCommnd(new List <string> {
                "plugin", "extension", "p"
            }, "Handles a plugin command.", OnPluginCommand);
        }
コード例 #5
0
ファイル: DetoxConsole.cs プロジェクト: 999eagle/Detox
        /// <summary>
        /// Default Constructor
        /// </summary>
        /// <param name="manager"></param>
        public DetoxConsole(Manager manager)
            : base(manager)
        {
            // Initialize this control..
            base.Init();
            base.Left = base.Top = 0;
            base.Name = "frmConsole";
            base.Width = Terraria.MainGame.Window.ClientBounds.Width;
            base.Height = 250;
            base.Alpha = 255;
            base.Resizable = false;
            //
            //
            //
            this._console = new TomShane.Neoforce.Controls.Console(manager)
                {
                    Anchor = Anchors.All,
                    Name = "DetoxConsole",
                    Width = base.ClientArea.Width,
                    Height = base.ClientArea.Height,
                    ChannelsVisible = false,
                    MessageFormat = ConsoleMessageFormats.TimeStamp,
                    TextColor = Color.White
                };
            this._console.Channels.AddRange(new[]
                {
                    new ConsoleChannel(0, "About", Color.Chartreuse),
                    new ConsoleChannel(1, "Default", Color.White),
                    new ConsoleChannel(2, "Warning", Color.Yellow),
                    new ConsoleChannel(3, "Error", Color.Red)
                });
            this._console.SelectedChannel = 1;
            this._console.MessageSent += (sender, e) =>
                {
                    // Ensure the command is valid..
                    if (string.IsNullOrEmpty(e.Message.Text) || !e.Message.Text.StartsWith("/"))
                        return;

                    // Attempt to handle the command..
                    e.Handled = ConsoleCommands.ProcessCommand(e.Message.Text);
                    if (!e.Handled)
                    {
                        this.LogConsoleMessage(new DetoxAPI.ConsoleMessage("Invalid command or command error occurred.", ConsoleMessageType.Error));
                        e.Handled = true;
                    }
                };
            this._console.Init();
            //
            //
            //
            base.Add(this._console);
            manager.Add(this);

            // Attach device settings event to resize console..
            manager.DeviceSettingsChanged += args =>
                {
                    // Adjust the base panel size..
                    base.Width = Terraria.MainGame.Window.ClientBounds.Width;
                    base.Height = 250;

                    // Adjust the console size..
                    this._console.Width = base.ClientArea.Width;
                    this._console.Height = base.ClientArea.Height;
                };

            // Locate the console textbox..
            var consoleEdit = this._console.Controls.SingleOrDefault(c => c.GetType() == typeof(TextBox));
            if (consoleEdit == null) return;

            consoleEdit.KeyDown += (sender, e) =>
                {
                    // Prevent tilde from being processed..
                    if (e.Key == Keys.OemTilde)
                        e.Handled = true;

                    // Force escape to remove focus from the console..
                    if (e.Key == Keys.Escape)
                    {
                        consoleEdit.Focused = false;
                        e.Handled = true;
                    }
                };
            consoleEdit.KeyPress += (sender, e) =>
                {
                    if (e.Key == Keys.OemTilde)
                        e.Handled = true;
                };
            consoleEdit.KeyUp += (sender, e) =>
                {
                    if (e.Key == Keys.OemTilde)
                        e.Handled = true;
                };
            consoleEdit.TextChanged += (sender, e) =>
                {
                    consoleEdit.Suspended = true;
                    consoleEdit.Text = consoleEdit.Text.Replace("`", "");
                    consoleEdit.Suspended = false;
                    e.Handled = true;
                };
            consoleEdit.FocusGained += (sender, e) => Terraria.SetMainField("chatMode", false);
            consoleEdit.FocusLost += (sender, e) => Terraria.SetMainField("chatMode", false);

            // Subscribe to the API console message event..
            DetoxAPI.Console.PrintConsoleMessage += (sender, e) => this.LogConsoleMessage(e);

            // Register some basic console commands..
            DetoxAPI.ConsoleCommands.AddCommnd(new List<string> { "help", "info", "h", "?" }, "Prints a list of registered console commands.", OnHelpCommand);
            DetoxAPI.ConsoleCommands.AddCommnd(new List<string> { "exit", "close", "terminate" }, "Exits Terraria immediately.", args => System.Windows.Forms.Application.Exit());
            DetoxAPI.ConsoleCommands.AddCommnd(new List<string> { "plugin", "extension", "p" }, "Handles a plugin command.", OnPluginCommand);
        }
コード例 #6
0
ファイル: GuiManager.cs プロジェクト: hakanaku2009/svn-dump
        private void InitializeControls()
        {
            manager = new Manager(CurrGame, CurrGame.Graphics, "Green")
            {
                SkinDirectory = CurrGame.ApplicationDirectory + @"\Content\GUI\Skin\"
            };
            try
            {
                manager.Initialize();
            }
            catch (Exception)
            {
                throw;
            }

            manager.AutoCreateRenderTarget = true;

            Console = new Console(manager);
            Console.Init();
            LoadConsoleCommands();
            manager.Add(Console);
            Console.ChannelsVisible = false;
            Console.MessageSent    += Console_MessageSent;
            Console.MessageFormat   = ConsoleMessageFormats.None;
            Console.Width           = manager.ScreenWidth;
            Console.Channels.Add(new ConsoleChannel(0, "[System]", Color.Orange));
            Console.Channels.Add(new ConsoleChannel(1, "[User]", Color.White));
            Console.Channels.Add(new ConsoleChannel(2, "[Error]", Color.DarkRed));
            Console.SelectedChannel = 1;
            Console.Hide();

            tabControl = new TabControl(manager);
            tabControl.Init();
            tabControl.Left   = CurrGame.CreepFieldWidth;
            tabControl.Top    = 0;
            tabControl.Width  = CurrGame.Width - CurrGame.CreepFieldWidth;
            tabControl.Height = CurrGame.Height;

            #region Gameplaypage

            GameplayPage = tabControl.AddPage();
            GameplayPage.Init();
            GameplayPage.Text = "Spiel";

            #region Turmauswahl

            var thumbnailBox = new GroupBox(manager);
            thumbnailBox.Init();
            thumbnailBox.Parent = GameplayPage;
            thumbnailBox.Left   = 2;
            thumbnailBox.Top    = 2;
            thumbnailBox.Width  = thumbnailBox.Parent.Width - 4;
            thumbnailBox.Height = 100;

            int counter = 0;
            foreach (TowerClass towerClass in GamePlayScreen.TowerManager.TowerClassList)
            {
                var towerButton = new ImageButton(manager)
                {
                    Image    = GamePlayScreen.TowerManager.GetThumbnail(towerClass.TowerKey),
                    SizeMode = SizeMode.Stretched,
                    Top      = 14,
                    Tag      = towerClass
                };
                towerButton.Width      = towerButton.Height = 60;
                towerButton.Left       = 6 + counter * (towerButton.Width + 5);
                towerButton.Click     += towerButton_Click;
                towerButton.MouseOver += towerButton_MouseOver;
                towerButton.MouseOut  += towerButton_MouseOut;
                towerButton.Init();
                thumbnailBox.Add(towerButton);
                BuyTowerButtons.Add(towerButton);
                counter++;
            }

            thumbnailBox.AutoScroll = true;

            var scrollBar = new ScrollBar(manager, Orientation.Horizontal);
            scrollBar.Init();
            thumbnailBox.Add(scrollBar);
            scrollBar.Visible = false;

            #endregion

            #region Informationen

            var infoBox = new GroupBox(manager);
            infoBox.Init();
            infoBox.Parent = GameplayPage;
            infoBox.Text   = "Informationen";
            infoBox.Width  = infoBox.Parent.Width - 4;
            infoBox.Height = 110;
            infoBox.Left   = 2;
            infoBox.Top    = thumbnailBox.Top + thumbnailBox.Height + 2;

            CreepNumber = new Label(manager);
            CreepNumber.Init();
            CreepNumber.Parent  = infoBox;
            CreepNumber.Top     = 14;
            CreepNumber.Left    = 4;
            CreepNumber.Width   = CreepNumber.Parent.Width - 4;
            CreepNumber.ToolTip = new ToolTip(manager)
            {
                Text = "So viele Creeps sind momentan\nauf dem Spielfeld"
            };
            CreepNumber.Passive = false;

            CreepHealth = new Label(manager);
            CreepHealth.Init();
            CreepHealth.Parent  = infoBox;
            CreepHealth.Top     = CreepNumber.Top + CreepNumber.Height + 2;
            CreepHealth.Left    = CreepNumber.Left;
            CreepHealth.Width   = CreepHealth.Parent.Width - 4;
            CreepHealth.ToolTip = new ToolTip(manager)
            {
                Text = "Die Gesamtenergie aller auf dem\nSpielfeld befindlicher Creeps"
            };
            CreepHealth.Passive = false;

            Money = new Label(manager);
            Money.Init();
            Money.Parent  = infoBox;
            Money.Top     = CreepHealth.Top + CreepHealth.Height + 2;
            Money.Left    = CreepNumber.Left;
            Money.Width   = Money.Parent.Width - 4;
            Money.ToolTip = new ToolTip(manager)
            {
                Text = "So viel Geld besitzt der Spieler"
            };
            Money.Passive = false;

            OwnHealth = new Label(manager);
            OwnHealth.Init();
            OwnHealth.Parent  = infoBox;
            OwnHealth.Top     = Money.Top + Money.Height + 2;
            OwnHealth.Left    = CreepNumber.Left;
            OwnHealth.Width   = OwnHealth.Parent.Width - 4;
            OwnHealth.ToolTip = new ToolTip(manager)
            {
                Text = "So viel Energie hat der Spieler noch"
            };
            OwnHealth.Passive = false;

            Points = new Label(manager);
            Points.Init();
            Points.Parent  = infoBox;
            Points.Top     = OwnHealth.Top + OwnHealth.Height + 2;
            Points.Left    = CreepNumber.Left;
            Points.Width   = Points.Parent.Width - 4;
            Points.ToolTip = new ToolTip(manager)
            {
                Text = "So viele Punkte hat der Spieler schon.\nDie Punkte setzen sich aus Energie\nund Geschwindigkeit der Creeps zusammen.\nJe näher ein Gegner am Ziel ist, desto mehr\nPunkte gibt er."
            };
            Points.Passive = false;

            #endregion

            #region Waves

            var waveBox = new GroupBox(manager);
            waveBox.Init();
            waveBox.Parent = GameplayPage;
            waveBox.Text   = "Waves";
            waveBox.Left   = 2;
            waveBox.Top    = infoBox.Top + infoBox.Height + 2;
            waveBox.Width  = waveBox.Parent.Width - 4;
            waveBox.Height = 137;

            WaveNumber = new Label(manager);
            WaveNumber.Init();
            WaveNumber.Parent = waveBox;
            WaveNumber.Top    = 14;
            WaveNumber.Left   = 4;
            WaveNumber.Width  = WaveNumber.Parent.Width - 4;

            RealWaveNumber = new Label(manager);
            RealWaveNumber.Init();
            RealWaveNumber.Parent = waveBox;
            RealWaveNumber.Top    = WaveNumber.Top + WaveNumber.Height + 2;
            RealWaveNumber.Left   = WaveNumber.Left;
            RealWaveNumber.Width  = RealWaveNumber.Parent.Width - 4;

            CreepsLeft = new Label(manager);
            CreepsLeft.Init();
            CreepsLeft.Parent  = waveBox;
            CreepsLeft.Top     = RealWaveNumber.Top + RealWaveNumber.Height + 2;
            CreepsLeft.Left    = WaveNumber.Left;
            CreepsLeft.Width   = CreepsLeft.Parent.Width - 4;
            CreepsLeft.Passive = false;
            CreepsLeft.ToolTip = new ToolTip(manager)
            {
                Text = "So viele Creeps werden noch im Level erscheinen,\nbevor die Aktuelle Welle vorbei ist."
            };

            CreepHealthLevel = new Label(manager);
            CreepHealthLevel.Init();
            CreepHealthLevel.Parent  = waveBox;
            CreepHealthLevel.Top     = CreepsLeft.Top + CreepsLeft.Height + 2;
            CreepHealthLevel.Left    = WaveNumber.Left;
            CreepHealthLevel.Width   = CreepHealthLevel.Parent.Width - 4;
            CreepHealthLevel.Passive = false;
            CreepHealthLevel.ToolTip = new ToolTip(manager)
            {
                Text = "Wenn alle Waves eines Levels fertig sind, werden die Waves von Anfang anwiederholt.\nAllerdings steigt die Energie der Creeps dabei.\nDas Gesundheitsniveau liegt dieser Energie zugrunde."
            };

            TimeLeftNextWave = new Label(manager);
            TimeLeftNextWave.Init();
            TimeLeftNextWave.Parent = waveBox;
            TimeLeftNextWave.Top    = CreepHealthLevel.Top + CreepHealthLevel.Height + 2;
            TimeLeftNextWave.Left   = WaveNumber.Left;
            TimeLeftNextWave.Width  = TimeLeftNextWave.Parent.Width - 4;

            var nextWaveButton = new Button(manager);
            nextWaveButton.Init();
            nextWaveButton.Parent = waveBox;
            nextWaveButton.Text   = "Nächste Welle";
            nextWaveButton.Left   = 2;
            nextWaveButton.Top    = TimeLeftNextWave.Top + TimeLeftNextWave.Height + 2;
            nextWaveButton.Width  = nextWaveButton.Parent.Width - 4;
            nextWaveButton.Click += delegate { GamePlayScreen.StartNextWave(); };

            #endregion

            #region Spielsteuerung

            var gameBox = new GroupBox(manager);
            gameBox.Init();
            gameBox.Text   = "Spielsteuerung";
            gameBox.Parent = GameplayPage;
            gameBox.Width  = gameBox.Parent.Width - 4;
            gameBox.Height = 200;
            gameBox.Left   = 2;
            gameBox.Top    = waveBox.Top + waveBox.Height + 2;

            var playButton = new ImageButton(manager)
            {
                Image =
                    CurrGame.Content.Load <Texture2D>(CurrGame.ApplicationDirectory + "\\Content\\GUI\\play"),
                SizeMode = SizeMode.Stretched,
                Top      = 14,
                Left     = 2,
                Width    = 50
            };
            playButton.Height = playButton.Width;
            playButton.Click += ((sender, e) => GamePlayScreen.StartGame());
            playButton.Init();

            var pauseButton = new ImageButton(manager)
            {
                Image =
                    CurrGame.Content.Load <Texture2D>(CurrGame.ApplicationDirectory +
                                                      "\\Content\\GUI\\pause"),
                SizeMode = SizeMode.Stretched,
                Top      = 14,
                Left     = playButton.Left + playButton.Width + 4
            };
            pauseButton.Width  = pauseButton.Height = playButton.Width;
            pauseButton.Click += ((sender, e) => GamePlayScreen.StopGame());
            pauseButton.Init();

            gameBox.Add(playButton);
            gameBox.Add(pauseButton);

            #endregion

            RefreshGameInformation();

            #endregion

            #region Optionspage

            OptionsPage      = tabControl.AddPage();
            OptionsPage.Text = "Optionen";

            #endregion

            #region SaveLoadPage

            #endregion

            manager.Add(tabControl);
        }
コード例 #7
0
ファイル: GuiManager.cs プロジェクト: GodLesZ/svn-dump
        private void InitializeControls()
        {
            manager = new Manager(CurrGame, CurrGame.Graphics, "Green") { SkinDirectory = CurrGame.ApplicationDirectory + @"\Content\GUI\Skin\" };
            try
            {
                manager.Initialize();
            }
            catch (Exception)
            {
                throw;
            }

            manager.AutoCreateRenderTarget = true;

            Console = new Console(manager);
            Console.Init();
            LoadConsoleCommands();
            manager.Add(Console);
            Console.ChannelsVisible = false;
            Console.MessageSent += Console_MessageSent;
            Console.MessageFormat = ConsoleMessageFormats.None;
            Console.Width = manager.ScreenWidth;
            Console.Channels.Add(new ConsoleChannel(0, "[System]", Color.Orange));
            Console.Channels.Add(new ConsoleChannel(1, "[User]", Color.White));
            Console.Channels.Add(new ConsoleChannel(2, "[Error]", Color.DarkRed));
            Console.SelectedChannel = 1;
            Console.Hide();

            tabControl = new TabControl(manager);
            tabControl.Init();
            tabControl.Left = CurrGame.CreepFieldWidth;
            tabControl.Top = 0;
            tabControl.Width = CurrGame.Width - CurrGame.CreepFieldWidth;
            tabControl.Height = CurrGame.Height;

            #region Gameplaypage

            GameplayPage = tabControl.AddPage();
            GameplayPage.Init();
            GameplayPage.Text = "Spiel";

            #region Turmauswahl

            var thumbnailBox = new GroupBox(manager);
            thumbnailBox.Init();
            thumbnailBox.Parent = GameplayPage;
            thumbnailBox.Left = 2;
            thumbnailBox.Top = 2;
            thumbnailBox.Width = thumbnailBox.Parent.Width - 4;
            thumbnailBox.Height = 100;

            int counter = 0;
            foreach (TowerClass towerClass in GamePlayScreen.TowerManager.TowerClassList)
            {
                var towerButton = new ImageButton(manager)
                                      {
                                          Image = GamePlayScreen.TowerManager.GetThumbnail(towerClass.TowerKey),
                                          SizeMode = SizeMode.Stretched,
                                          Top = 14,
                                          Tag = towerClass
                                      };
                towerButton.Width = towerButton.Height = 60;
                towerButton.Left = 6 + counter * (towerButton.Width + 5);
                towerButton.Click += towerButton_Click;
                towerButton.MouseOver += towerButton_MouseOver;
                towerButton.MouseOut += towerButton_MouseOut;
                towerButton.Init();
                thumbnailBox.Add(towerButton);
                BuyTowerButtons.Add(towerButton);
                counter++;
            }

            thumbnailBox.AutoScroll = true;

            var scrollBar = new ScrollBar(manager, Orientation.Horizontal);
            scrollBar.Init();
            thumbnailBox.Add(scrollBar);
            scrollBar.Visible = false;

            #endregion

            #region Informationen

            var infoBox = new GroupBox(manager);
            infoBox.Init();
            infoBox.Parent = GameplayPage;
            infoBox.Text = "Informationen";
            infoBox.Width = infoBox.Parent.Width - 4;
            infoBox.Height = 110;
            infoBox.Left = 2;
            infoBox.Top = thumbnailBox.Top + thumbnailBox.Height + 2;

            CreepNumber = new Label(manager);
            CreepNumber.Init();
            CreepNumber.Parent = infoBox;
            CreepNumber.Top = 14;
            CreepNumber.Left = 4;
            CreepNumber.Width = CreepNumber.Parent.Width - 4;
            CreepNumber.ToolTip = new ToolTip(manager) { Text = "So viele Creeps sind momentan\nauf dem Spielfeld" };
            CreepNumber.Passive = false;

            CreepHealth = new Label(manager);
            CreepHealth.Init();
            CreepHealth.Parent = infoBox;
            CreepHealth.Top = CreepNumber.Top + CreepNumber.Height + 2;
            CreepHealth.Left = CreepNumber.Left;
            CreepHealth.Width = CreepHealth.Parent.Width - 4;
            CreepHealth.ToolTip = new ToolTip(manager) { Text = "Die Gesamtenergie aller auf dem\nSpielfeld befindlicher Creeps" };
            CreepHealth.Passive = false;

            Money = new Label(manager);
            Money.Init();
            Money.Parent = infoBox;
            Money.Top = CreepHealth.Top + CreepHealth.Height + 2;
            Money.Left = CreepNumber.Left;
            Money.Width = Money.Parent.Width - 4;
            Money.ToolTip = new ToolTip(manager) { Text = "So viel Geld besitzt der Spieler" };
            Money.Passive = false;

            OwnHealth = new Label(manager);
            OwnHealth.Init();
            OwnHealth.Parent = infoBox;
            OwnHealth.Top = Money.Top + Money.Height + 2;
            OwnHealth.Left = CreepNumber.Left;
            OwnHealth.Width = OwnHealth.Parent.Width - 4;
            OwnHealth.ToolTip = new ToolTip(manager) { Text = "So viel Energie hat der Spieler noch" };
            OwnHealth.Passive = false;

            Points = new Label(manager);
            Points.Init();
            Points.Parent = infoBox;
            Points.Top = OwnHealth.Top + OwnHealth.Height + 2;
            Points.Left = CreepNumber.Left;
            Points.Width = Points.Parent.Width - 4;
            Points.ToolTip = new ToolTip(manager) { Text = "So viele Punkte hat der Spieler schon.\nDie Punkte setzen sich aus Energie\nund Geschwindigkeit der Creeps zusammen.\nJe näher ein Gegner am Ziel ist, desto mehr\nPunkte gibt er." };
            Points.Passive = false;

            #endregion

            #region Waves

            var waveBox = new GroupBox(manager);
            waveBox.Init();
            waveBox.Parent = GameplayPage;
            waveBox.Text = "Waves";
            waveBox.Left = 2;
            waveBox.Top = infoBox.Top + infoBox.Height + 2;
            waveBox.Width = waveBox.Parent.Width - 4;
            waveBox.Height = 137;

            WaveNumber = new Label(manager);
            WaveNumber.Init();
            WaveNumber.Parent = waveBox;
            WaveNumber.Top = 14;
            WaveNumber.Left = 4;
            WaveNumber.Width = WaveNumber.Parent.Width - 4;

            RealWaveNumber = new Label(manager);
            RealWaveNumber.Init();
            RealWaveNumber.Parent = waveBox;
            RealWaveNumber.Top = WaveNumber.Top + WaveNumber.Height + 2;
            RealWaveNumber.Left = WaveNumber.Left;
            RealWaveNumber.Width = RealWaveNumber.Parent.Width - 4;

            CreepsLeft = new Label(manager);
            CreepsLeft.Init();
            CreepsLeft.Parent = waveBox;
            CreepsLeft.Top = RealWaveNumber.Top + RealWaveNumber.Height + 2;
            CreepsLeft.Left = WaveNumber.Left;
            CreepsLeft.Width = CreepsLeft.Parent.Width - 4;
            CreepsLeft.Passive = false;
            CreepsLeft.ToolTip = new ToolTip(manager) { Text = "So viele Creeps werden noch im Level erscheinen,\nbevor die Aktuelle Welle vorbei ist." };

            CreepHealthLevel = new Label(manager);
            CreepHealthLevel.Init();
            CreepHealthLevel.Parent = waveBox;
            CreepHealthLevel.Top = CreepsLeft.Top + CreepsLeft.Height + 2;
            CreepHealthLevel.Left = WaveNumber.Left;
            CreepHealthLevel.Width = CreepHealthLevel.Parent.Width - 4;
            CreepHealthLevel.Passive = false;
            CreepHealthLevel.ToolTip = new ToolTip(manager) { Text = "Wenn alle Waves eines Levels fertig sind, werden die Waves von Anfang anwiederholt.\nAllerdings steigt die Energie der Creeps dabei.\nDas Gesundheitsniveau liegt dieser Energie zugrunde." };

            TimeLeftNextWave = new Label(manager);
            TimeLeftNextWave.Init();
            TimeLeftNextWave.Parent = waveBox;
            TimeLeftNextWave.Top = CreepHealthLevel.Top + CreepHealthLevel.Height + 2;
            TimeLeftNextWave.Left = WaveNumber.Left;
            TimeLeftNextWave.Width = TimeLeftNextWave.Parent.Width - 4;

            var nextWaveButton = new Button(manager);
            nextWaveButton.Init();
            nextWaveButton.Parent = waveBox;
            nextWaveButton.Text = "Nächste Welle";
            nextWaveButton.Left = 2;
            nextWaveButton.Top = TimeLeftNextWave.Top + TimeLeftNextWave.Height + 2;
            nextWaveButton.Width = nextWaveButton.Parent.Width - 4;
            nextWaveButton.Click += delegate { GamePlayScreen.StartNextWave(); };

            #endregion

            #region Spielsteuerung

            var gameBox = new GroupBox(manager);
            gameBox.Init();
            gameBox.Text = "Spielsteuerung";
            gameBox.Parent = GameplayPage;
            gameBox.Width = gameBox.Parent.Width - 4;
            gameBox.Height = 200;
            gameBox.Left = 2;
            gameBox.Top = waveBox.Top + waveBox.Height + 2;

            var playButton = new ImageButton(manager)
                                 {
                                     Image =
                                         CurrGame.Content.Load<Texture2D>(CurrGame.ApplicationDirectory + "\\Content\\GUI\\play"),
                                     SizeMode = SizeMode.Stretched,
                                     Top = 14,
                                     Left = 2,
                                     Width = 50
                                 };
            playButton.Height = playButton.Width;
            playButton.Click += ((sender, e) => GamePlayScreen.StartGame());
            playButton.Init();

            var pauseButton = new ImageButton(manager)
                                  {
                                      Image =
                                          CurrGame.Content.Load<Texture2D>(CurrGame.ApplicationDirectory +
                                                                           "\\Content\\GUI\\pause"),
                                      SizeMode = SizeMode.Stretched,
                                      Top = 14,
                                      Left = playButton.Left + playButton.Width + 4
                                  };
            pauseButton.Width = pauseButton.Height = playButton.Width;
            pauseButton.Click += ((sender, e) => GamePlayScreen.StopGame());
            pauseButton.Init();

            gameBox.Add(playButton);
            gameBox.Add(pauseButton);

            #endregion

            RefreshGameInformation();

            #endregion

            #region Optionspage

            OptionsPage = tabControl.AddPage();
            OptionsPage.Text = "Optionen";

            #endregion

            #region SaveLoadPage

            #endregion

            manager.Add(tabControl);
        }