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 }; }
private void CreateFirstDisplayWindow(Manager manager, GameInfo gameInfo, Story red, Story black) { const int spacing = 20; const int width = 500; int yPos = spacing; var window = new Window(manager) { Text = "Story card", Width = 600 }; window.Init(); var descriptionlabel = new Label(manager) { Text = red.DisplayedMessage, Top = yPos, Width = width, Height = 70, Left = 30}; descriptionlabel.Text = "When this window closes you will be required to spin the spinner.\n" + "If the spinner lands on a black spot you will undergo what the black card says.\n" + "If the spinner lands on a red spot you will undergo what the red card says.\n\n" + "These are stories you are spinning for!"; yPos += descriptionlabel.Height + spacing / 2; var redstorybox = new GroupBox(manager) { Width = 500, Height = 100, Left = 30, Top = 100, Parent = window, Color = Color.Red, Text = "Red Story", TextColor = Color.White}; redstorybox.Init(); yPos += redstorybox.Height; var redstorylabel = new Label(manager) { Width = redstorybox.Width, Height = redstorybox.Height, Parent = redstorybox, Text = red.DisplayedMessage, Left = spacing, StayOnTop = true }; redstorylabel.Init(); var blackstorybox = new GroupBox(manager) { Width = 500, Height = 100, Left = 30, Top = 200, Parent = window, Color = Color.Black, Text = "Black Story", TextColor = Color.White }; blackstorybox.Init(); yPos += blackstorybox.Height+spacing/2; var blackstorylabel = new Label(manager) { Width = blackstorybox.Width, Height = blackstorybox.Height, Parent = blackstorybox, Text = black.DisplayedMessage, Left = spacing, StayOnTop = true }; blackstorylabel.Init(); var close = new Button(manager) { Text = "OK", Top = yPos, Left = window.Width / 2 - 50, Parent = window }; close.Init(); close.Click += (sender, args) => window.Close(); yPos += close.Height + spacing; window.Add(descriptionlabel); window.Height = blackstorybox.Height + redstorybox.Height + yPos/2; manager.Add(window); window.Closed += (sender, args) => WindowClosed(gameInfo); gameInfo.CreateMessage("Click the spinner to see your story!"); }
/// <summary> /// Initializes UI elements /// </summary> private void InitControls() { //Map MapControl = new MapWindow(Manager); MapControl.Init(); MapControl.SetPosition(201, 0); MapControl.Environment = Environment; MapControl.Renderer = Renderers[0]; MapControl.SetSize(Height, Height); MapControl.Resizable = true; MapControl.Movable = true; Add(MapControl); //Left side bar SideBar = new SideBar(Manager); SideBar.Init(); SideBar.StayOnBack = true; SideBar.Passive = true; SideBar.SetSize(200, Height); SideBar.Anchor = Anchors.Left | Anchors.Top | Anchors.Bottom; Add(SideBar); NewMapBtn = new Button(Manager); NewMapBtn.Init(); NewMapBtn.Text = "New Map"; NewMapBtn.SetPosition(25, 10); NewMapBtn.SetSize(150, 25); NewMapBtn.Anchor = Anchors.Top | Anchors.Left; NewMapBtn.Click += new EventHandler(NewMapBtn_Click); SideBar.Add(NewMapBtn); SelectMapBtn = new Button(Manager); SelectMapBtn.Init(); SelectMapBtn.Text = "Select Map"; SelectMapBtn.Click += new EventHandler(selectMapBtn_Click); SelectMapBtn.SetPosition(25, 40); SelectMapBtn.SetSize(150, 25); SelectMapBtn.Anchor = Anchors.Top | Anchors.Left; SideBar.Add(SelectMapBtn); DoOneStepBtn = new Button(Manager); DoOneStepBtn.Init(); DoOneStepBtn.Text = "Do One Step"; DoOneStepBtn.SetPosition(25, 90); DoOneStepBtn.SetSize(150, 25); DoOneStepBtn.Anchor = Anchors.Top | Anchors.Left; DoOneStepBtn.Click += new EventHandler(DoOneStepBtn_Click); SideBar.Add(DoOneStepBtn); DoOneRunBtn = new Button(Manager); DoOneRunBtn.Init(); DoOneRunBtn.Text = "Do One Run"; DoOneRunBtn.SetPosition(25, 120); DoOneRunBtn.SetSize(150, 25); DoOneRunBtn.Anchor = Anchors.Top | Anchors.Left; DoOneRunBtn.Click += new EventHandler(DoOneRunBtn_Click); SideBar.Add(DoOneRunBtn); NextRunBtn = new Button(Manager); NextRunBtn.Init(); NextRunBtn.Text = "Next Run"; NextRunBtn.SetPosition(25, 150); NextRunBtn.SetSize(150, 25); NextRunBtn.Anchor = Anchors.Top | Anchors.Left; NextRunBtn.Click += new EventHandler(NextRunBtn_Click); SideBar.Add(NextRunBtn); DoAllRunBtn = new Button(Manager); DoAllRunBtn.Init(); DoAllRunBtn.Text = "Do All Run"; DoAllRunBtn.SetPosition(25, 180); DoAllRunBtn.SetSize(150, 25); DoAllRunBtn.Anchor = Anchors.Top | Anchors.Left; DoAllRunBtn.Click += new EventHandler(DoAllRunBtn_Click); SideBar.Add(DoAllRunBtn); GrpBox = new GroupBox(Manager); GrpBox.Init(); GrpBox.SetSize(SideBar.Width - 30, 135); GrpBox.SetPosition(5, 220); GrpBox.ClientWidth = 180; GrpBox.Text = "Display Options"; GrpBox.TextColor = Color.Wheat; SideBar.Add(GrpBox); Label stepsLbl = new Label(Manager); stepsLbl.Init(); stepsLbl.Text = "Steps:"; stepsLbl.SetPosition(5, 25); GrpBox.Add(stepsLbl); StepsTxt = new TextBox(Manager); StepsTxt.Init(); StepsTxt.Text = "100"; StepsTxt.SetSize(100, 25); StepsTxt.SetPosition(5 + stepsLbl.Width, 20); StepsTxt.TextColor = Color.WhiteSmoke; StepsTxt.TextChanged += new EventHandler(TimeTxt_TextChanged); GrpBox.Add(StepsTxt); Label timeLbl = new Label(Manager); timeLbl.Init(); timeLbl.Text = "Time:"; timeLbl.SetPosition(5, 60); GrpBox.Add(timeLbl); TimeTxt = new TextBox(Manager); TimeTxt.Init(); TimeTxt.Text = "20"; TimeTxt.SetSize(100, 25); TimeTxt.SetPosition(5 + stepsLbl.Width, 55); TimeTxt.TextChanged += new EventHandler(TimeTxt_TextChanged); TimeTxt.TextColor = Color.WhiteSmoke; GrpBox.Add(TimeTxt); DisplayBtn = new Button(Manager); DisplayBtn.Init(); DisplayBtn.Text = "Display"; DisplayBtn.Click += new EventHandler(displayBtn_Click); DisplayBtn.SetSize(120, 25); DisplayBtn.SetPosition(50, 90); GrpBox.Add(DisplayBtn); Label rendererLbl = new Label(Manager); rendererLbl.Init(); rendererLbl.Text = "Renderer:"; rendererLbl.SetPosition(25, 360); Add(rendererLbl); RenderersComboBox = new ComboBox(Manager); RenderersComboBox.Init(); RenderersComboBox.SetPosition(25, 385); RenderersComboBox.Width = 150; RenderersComboBox.TextColor = Color.Wheat; RenderersComboBox.Items.AddRange(Renderers); RenderersComboBox.ItemIndex = 0; RenderersComboBox.TextChanged += new EventHandler(RenderersComboBox_TextChanged); Add(RenderersComboBox); Button makeFullScreenBtn = new Button(Manager); makeFullScreenBtn.Init(); makeFullScreenBtn.Text = "Fullscreen"; makeFullScreenBtn.SetPosition(25, 475); makeFullScreenBtn.SetSize(150, 25); makeFullScreenBtn.Click += new EventHandler(makeFullScreenBtn_Click); makeFullScreenBtn.Anchor = Anchors.Top | Anchors.Left; SideBar.Add(makeFullScreenBtn); Button exitBtn = new Button(Manager); exitBtn.Init(); exitBtn.Text = "Quit"; exitBtn.SetPosition(25, 510); exitBtn.SetSize(150, 25); exitBtn.Click += new EventHandler(exitBtn_Click); exitBtn.Anchor = Anchors.Top | Anchors.Left; SideBar.Add(exitBtn); ExitDlg = new ExitDialog(Manager); ExitDlg.Init(); ExitDlg.Closed += new WindowClosedEventHandler(ExitDlg_Closed); Manager.Add(ExitDlg); ExitDlg.Hide(); //Right side bar SideBarRight = new SideBar(Manager); SideBarRight.Init(); SideBarRight.StayOnBack = true; SideBarRight.Resizable = true; SideBarRight.ResizeEdge = Anchors.Left; SideBarRight.SetSize(200, Height); SideBarRight.SetPosition(Width - SideBarRight.Width, 0); SideBarRight.Anchor = Anchors.Right | Anchors.Top | Anchors.Bottom; Add(SideBarRight); GroupBox runParamsGrpBox = new GroupBox(Manager); runParamsGrpBox.Init(); runParamsGrpBox.SetSize(SideBarRight.Width - 30, 155); runParamsGrpBox.SetPosition(5, 10); runParamsGrpBox.ClientWidth = 38; runParamsGrpBox.Text = "Run Statistics"; runParamsGrpBox.TextColor = Color.Wheat; runParamsGrpBox.Anchor = Anchors.Left | Anchors.Right | Anchors.Top; SideBarRight.Add(runParamsGrpBox); Label runLbl1 = new Label(Manager); runLbl1.Init(); runLbl1.Text = "Run:"; runLbl1.SetPosition(10, 20); runLbl1.Width = 120; runParamsGrpBox.Add(runLbl1); Label runLbl2 = new Label(Manager); runLbl2.Init(); runLbl2.Text = "0"; runLbl2.SetPosition(runLbl1.Left + runLbl1.Width + 10, 20); runParamsGrpBox.Add(runLbl2); RunStatsLbls.Add(runLbl2); Label timeStepLbl1 = new Label(Manager); timeStepLbl1.Init(); timeStepLbl1.Text = "Time step:"; timeStepLbl1.SetPosition(10, 35); timeStepLbl1.Width = 120; runParamsGrpBox.Add(timeStepLbl1); Label timeStepLbl2 = new Label(Manager); timeStepLbl2.Init(); timeStepLbl2.Text = "0"; timeStepLbl2.SetPosition(timeStepLbl1.Left + timeStepLbl1.Width + 10, 35); runParamsGrpBox.Add(timeStepLbl2); RunStatsLbls.Add(timeStepLbl2); Label actionLbl1 = new Label(Manager); actionLbl1.Init(); actionLbl1.Text = "Action:"; actionLbl1.SetPosition(10, 60); actionLbl1.Width = 120; runParamsGrpBox.Add(actionLbl1); Label actionLbl2 = new Label(Manager); actionLbl2.Init(); actionLbl2.Text = "0"; actionLbl2.SetPosition(actionLbl1.Left + actionLbl1.Width + 10, 60); runParamsGrpBox.Add(actionLbl2); RunStatsLbls.Add(actionLbl2); Label dirtyOnMapLbl1 = new Label(Manager); dirtyOnMapLbl1.Init(); dirtyOnMapLbl1.Text = "Dirty on map:"; dirtyOnMapLbl1.SetPosition(10, 85); dirtyOnMapLbl1.Width = 120; runParamsGrpBox.Add(dirtyOnMapLbl1); Label dirtyOnMapLbl2 = new Label(Manager); dirtyOnMapLbl2.Init(); dirtyOnMapLbl2.Text = "0"; dirtyOnMapLbl2.SetPosition(dirtyOnMapLbl1.Left + dirtyOnMapLbl1.Width + 10, 85); runParamsGrpBox.Add(dirtyOnMapLbl2); RunStatsLbls.Add(dirtyOnMapLbl2); Label overAllDirtyLbl1 = new Label(Manager); overAllDirtyLbl1.Init(); overAllDirtyLbl1.Text = "Overall dirty:"; overAllDirtyLbl1.SetPosition(10, 100); overAllDirtyLbl1.Width = 120; runParamsGrpBox.Add(overAllDirtyLbl1); Label overAllDirtyLbl2 = new Label(Manager); overAllDirtyLbl2.Init(); overAllDirtyLbl2.Text = "0"; overAllDirtyLbl2.SetPosition(overAllDirtyLbl1.Left + overAllDirtyLbl1.Width + 10, 100); runParamsGrpBox.Add(overAllDirtyLbl2); RunStatsLbls.Add(overAllDirtyLbl2); Label cleanedDirtyLbl1 = new Label(Manager); cleanedDirtyLbl1.Init(); cleanedDirtyLbl1.Text = "Cleaned dirty:"; cleanedDirtyLbl1.SetPosition(10, 115); cleanedDirtyLbl1.Width = 120; runParamsGrpBox.Add(cleanedDirtyLbl1); Label cleanedDirtyLbl2 = new Label(Manager); cleanedDirtyLbl2.Init(); cleanedDirtyLbl2.Text = "0"; cleanedDirtyLbl2.SetPosition(cleanedDirtyLbl1.Left + cleanedDirtyLbl1.Width + 10, 115); runParamsGrpBox.Add(cleanedDirtyLbl2); RunStatsLbls.Add(cleanedDirtyLbl2); Label consumedEnergyLbl1 = new Label(Manager); consumedEnergyLbl1.Init(); consumedEnergyLbl1.Text = "Consumed energy:"; consumedEnergyLbl1.SetPosition(10, 130); consumedEnergyLbl1.Width = 120; runParamsGrpBox.Add(consumedEnergyLbl1); Label consumedEnergyLbl2 = new Label(Manager); consumedEnergyLbl2.Init(); consumedEnergyLbl2.Text = "0"; consumedEnergyLbl2.SetPosition(consumedEnergyLbl1.Left + consumedEnergyLbl1.Width + 10, 130); runParamsGrpBox.Add(consumedEnergyLbl2); RunStatsLbls.Add(consumedEnergyLbl2); //// GroupBox totalParamsGrpBox = new GroupBox(Manager); totalParamsGrpBox.Init(); totalParamsGrpBox.SetSize(SideBarRight.Width - 30, 215); totalParamsGrpBox.SetPosition(5, runParamsGrpBox.Top + runParamsGrpBox.Height + 10); totalParamsGrpBox.ClientWidth = 38; totalParamsGrpBox.Text = "Total Statistics"; totalParamsGrpBox.TextColor = Color.Wheat; totalParamsGrpBox.Anchor = Anchors.Left | Anchors.Right | Anchors.Top; SideBarRight.Add(totalParamsGrpBox); Label completedRunsLbl1 = new Label(Manager); completedRunsLbl1.Init(); completedRunsLbl1.Text = "Completed Runs:"; completedRunsLbl1.SetPosition(10, 20); completedRunsLbl1.Width = 120; totalParamsGrpBox.Add(completedRunsLbl1); Label completedRunsLbl2 = new Label(Manager); completedRunsLbl2.Init(); completedRunsLbl2.Text = "0"; completedRunsLbl2.SetPosition(completedRunsLbl1.Left + completedRunsLbl1.Width + 10, 20); totalParamsGrpBox.Add(completedRunsLbl2); TotalStatsLbls.Add(completedRunsLbl2); Label totalDirtyLbl1 = new Label(Manager); totalDirtyLbl1.Init(); totalDirtyLbl1.Text = "Total dirty degree:"; totalDirtyLbl1.SetPosition(10, 35); totalDirtyLbl1.Width = 120; totalParamsGrpBox.Add(totalDirtyLbl1); Label totalDirtyLbl2 = new Label(Manager); totalDirtyLbl2.Init(); totalDirtyLbl2.Text = "0"; totalDirtyLbl2.SetPosition(totalDirtyLbl1.Left + totalDirtyLbl1.Width + 10, 35); totalParamsGrpBox.Add(totalDirtyLbl2); TotalStatsLbls.Add(totalDirtyLbl2); Label totalCleanedLbl1 = new Label(Manager); totalCleanedLbl1.Init(); totalCleanedLbl1.Text = "Total cleaned dirty:"; totalCleanedLbl1.SetPosition(10, 60); totalCleanedLbl1.Width = 120; totalParamsGrpBox.Add(totalCleanedLbl1); Label totalCleanedLbl2 = new Label(Manager); totalCleanedLbl2.Init(); totalCleanedLbl2.Text = "0"; totalCleanedLbl2.SetPosition(totalCleanedLbl1.Left + totalCleanedLbl1.Width + 10, 60); totalParamsGrpBox.Add(totalCleanedLbl2); TotalStatsLbls.Add(totalCleanedLbl2); Label totalConsumedLbl1 = new Label(Manager); totalConsumedLbl1.Init(); totalConsumedLbl1.Text = "Total consumed\nenergy:"; totalConsumedLbl1.SetPosition(10, 85); totalConsumedLbl1.SetSize(120, 30); totalParamsGrpBox.Add(totalConsumedLbl1); Label totalConsumedLbl2 = new Label(Manager); totalConsumedLbl2.Init(); totalConsumedLbl2.Text = "0"; totalConsumedLbl2.SetPosition(totalConsumedLbl1.Left + totalConsumedLbl1.Width + 10, 85); totalParamsGrpBox.Add(totalConsumedLbl2); TotalStatsLbls.Add(totalConsumedLbl2); Label avarageDirtyLbl1 = new Label(Manager); avarageDirtyLbl1.Init(); avarageDirtyLbl1.Text = "Average dirty\ndegree:"; avarageDirtyLbl1.SetPosition(10, 115); avarageDirtyLbl1.SetSize(120, 30); totalParamsGrpBox.Add(avarageDirtyLbl1); Label avarageDirtyLbl2 = new Label(Manager); avarageDirtyLbl2.Init(); avarageDirtyLbl2.Text = "0"; avarageDirtyLbl2.SetPosition(avarageDirtyLbl1.Left + avarageDirtyLbl1.Width + 10, 115); totalParamsGrpBox.Add(avarageDirtyLbl2); TotalStatsLbls.Add(avarageDirtyLbl2); Label avarageCleanedLbl1 = new Label(Manager); avarageCleanedLbl1.Init(); avarageCleanedLbl1.Text = "Average cleaned\ndirty:"; avarageCleanedLbl1.SetPosition(10, 145); avarageCleanedLbl1.SetSize(120, 30); totalParamsGrpBox.Add(avarageCleanedLbl1); Label avarageCleanedLbl2 = new Label(Manager); avarageCleanedLbl2.Init(); avarageCleanedLbl2.Text = "0"; avarageCleanedLbl2.SetPosition(avarageCleanedLbl1.Left + avarageCleanedLbl1.Width + 10, 145); totalParamsGrpBox.Add(avarageCleanedLbl2); TotalStatsLbls.Add(avarageCleanedLbl2); Label avarageConsumedLbl1 = new Label(Manager); avarageConsumedLbl1.Init(); avarageConsumedLbl1.Text = "Average consumed\nenergy:"; avarageConsumedLbl1.SetPosition(10, 175); avarageConsumedLbl1.Width = 120; avarageConsumedLbl1.Height = 30; totalParamsGrpBox.Add(avarageConsumedLbl1); Label avarageConsumedLbl2 = new Label(Manager); avarageConsumedLbl2.Init(); avarageConsumedLbl2.Text = "0"; avarageConsumedLbl2.SetPosition(avarageConsumedLbl1.Left + avarageConsumedLbl1.Width + 10, 175); totalParamsGrpBox.Add(avarageConsumedLbl2); TotalStatsLbls.Add(avarageConsumedLbl2); ///// //Select map OpenFileDialog = new Dialog(Manager); OpenFileDialog.Init(); OpenFileDialog.Text = "Select map file"; OpenFileDialog.Description.Visible = false; OpenFileDialog.Caption.Text = ""; OpenFileDialog.Width = 600; OpenFileDialog.Resize += new ResizeEventHandler(OpenFileDialog_Resize); Manager.Add(OpenFileDialog); OpenFileDialog.Hide(); FilesList = new ListBox(Manager); FilesList.Init(); FilesList.Tag = System.Environment.CurrentDirectory; FilesList.SetPosition(0, 40); FilesList.ClientWidth = OpenFileDialog.Width - 15; FilesList.ClientHeight = OpenFileDialog.ClientHeight - 40; FilesList.TextColor = Color.Wheat; FilesList.DoubleClick += new EventHandler(FilesList_DoubleClick); GetFilesAndFolders(); OpenFileDialog.Add(FilesList); LifeTimeLbl = new Label(Manager); LifeTimeLbl.Init(); LifeTimeLbl.Text = "Life Time:"; LifeTimeLbl.SetPosition(5, 10); OpenFileDialog.Add(LifeTimeLbl); LifeTimeTxt = new TextBox(Manager); LifeTimeTxt.Init(); LifeTimeTxt.Text = "2000"; LifeTimeTxt.SetSize(100, 25); LifeTimeTxt.SetPosition(5 + stepsLbl.Width, 5); LifeTimeTxt.TextColor = Color.WhiteSmoke; LifeTimeTxt.TextChanged += new EventHandler(TimeTxt_TextChanged); OpenFileDialog.Add(LifeTimeTxt); TestCaseLbl = new Label(Manager); TestCaseLbl.Init(); TestCaseLbl.Text = "Test Case:"; TestCaseLbl.SetPosition(LifeTimeTxt.Left + LifeTimeTxt.Width + 5, 10); OpenFileDialog.Add(TestCaseLbl); TestCaseTxt = new TextBox(Manager); TestCaseTxt.Init(); TestCaseTxt.Text = "10"; TestCaseTxt.SetSize(100, 25); TestCaseTxt.SetPosition(TestCaseLbl.Left + TestCaseLbl.Width + 5, 5); TestCaseTxt.TextColor = Color.WhiteSmoke; TestCaseTxt.TextChanged += new EventHandler(TimeTxt_TextChanged); OpenFileDialog.Add(TestCaseTxt); AgentLbl = new Label(Manager); AgentLbl.Init(); AgentLbl.Text = "Agent:"; AgentLbl.SetPosition(TestCaseTxt.Left + TestCaseTxt.Width + 5, 10); OpenFileDialog.Add(AgentLbl); AgentsComboBox = new ComboBox(Manager); AgentsComboBox.Init(); AgentsComboBox.SetPosition(AgentLbl.Left + AgentLbl.Width - 10, 5); AgentsComboBox.Width = 150; AgentsComboBox.Height = 25; AgentsComboBox.TextColor = Color.Wheat; AgentsComboBox.Items.Add("RandomAgent"); AgentsComboBox.Items.Add("ModelAgent"); AgentsComboBox.Items.Add("ModelAgentNoIdle"); AgentsComboBox.ItemIndex = 0; OpenFileDialog.Add(AgentsComboBox); NewGameDialog = new Dialog(Manager); NewGameDialog.Init(); NewGameDialog.Text = "Start new tests"; NewGameDialog.Description.Visible = false; NewGameDialog.BottomPanel.Visible = false; NewGameDialog.Caption.Text = ""; NewGameDialog.Width = 600; NewGameDialog.Height = 130; NewGameDialog.TopPanel.Height = 100; Manager.Add(NewGameDialog); NewGameDialog.Hide(); Button newGameOk = new Button(Manager); newGameOk.Init(); newGameOk.SetPosition(20, 50); newGameOk.Text = "Confirm"; newGameOk.Click += new EventHandler(newGameOk_Click); NewGameDialog.Add(newGameOk); EnableDisableMapControls(false); }
public override void Init(bool damage, bool range, bool interval) { base.Init(damage, range, interval); Height = DesiredHeight; Width = DesiredWidth; lblDescription.Visible = false; Passive = false; if ((DesiredLeft + DesiredWidth < CurrGame.CreepFieldWidth) || (DesiredLeft - DesiredWidth) < 0) { Left = DesiredLeft; } else { Left = DesiredLeft - DesiredWidth; } if (DesiredTop + DesiredHeight < CurrGame.CreepFieldHeight) { Top = DesiredTop; } else { Top = DesiredTop - DesiredHeight; } infoBox = new GroupBox(Manager); infoBox.Init(); Add(infoBox); infoBox.Left = 2; infoBox.Top = 2; infoBox.Width = infoBox.Parent.Width - 4; infoBox.Height = 160; infoBox.Text = "Eigenschaften"; infoBox.TextColor = Microsoft.Xna.Framework.Color.LightGray; InitializeControls(infoBox, 14); InitializeCustomLabels(); UpdateTowerInformation(); var sellButton = new Button(Manager); sellButton.Init(); infoBox.Add(sellButton); sellButton.Text = "Verkaufen"; sellButton.ToolTip = new ToolTip(Manager) { Text = "Verkaufpreis: Preis * 75%" }; sellButton.Left = 220; sellButton.Top = 14; sellButton.Width = sellButton.Parent.Width - sellButton.Left - 5; sellButton.Click += delegate { Tower.Sell(); Close(); }; InitializeUpgradeButtons(); Closing += TowerInfoWindow_Closing; CloseButtonVisible = true; Passive = false; Resizable = false; Movable = true; GamePlayScreen.MoneyManager.MoneyChanged += MoneyManager_MoneyChanged; }
private void InitializeUpgradeButtons() { Remove(UpgradeBox); UpgradeBox = new GroupBox(Manager); Add(UpgradeBox); UpgradeBox.Init(); UpgradeBox.Left = 2; UpgradeBox.Top = infoBox.Top + infoBox.Height + 2; UpgradeBox.Width = UpgradeBox.Parent.Width - 4; UpgradeBox.Height = UpgradeBox.Parent.Height - UpgradeBox.Top - 2; UpgradeBox.Text = "Upgrades"; UpgradeBox.TextColor = Microsoft.Xna.Framework.Color.LightGray; UpgradeBox.AutoScroll = false; foreach (Button button in Buttons) { UpgradeBox.Remove(button); Remove(button); button.Visible = false; button.Invalidate(); } Buttons.Clear(); lastWidth = 0; SpriteFont cFont = Skin.Layers[0].Text.Font.Resource; UpgradeBox.Enabled = Tower.PossibleUpgrades.Count > 0; foreach (var upgrade in Tower.PossibleUpgrades) { var button = new Button(Manager); button.Init(); UpgradeBox.Add(button); Buttons.Add(button); button.Text = upgrade.Value.Name; button.Width = (int)cFont.MeasureString(button.Text).X + 15; button.Left = 6 + lastWidth; button.Top = 14; button.Tag = upgrade.Value.Key; button.Enabled = GamePlayScreen.MoneyManager.Money >= upgrade.Value.Price; button.Click += button_Click; button.ToolTip = new ToolTip(Manager) { Text = string.Format("Neuer Wert: {0}\nPreis: {1}", upgrade.Value.Value, upgrade.Value.Price) }; if (upgrade.Value.Description.Length > 0) { button.ToolTip.Text += string.Format("\nBeschreibung: {0}", upgrade.Value.Description); } lastWidth = button.Left + button.Width; } UpgradeBox.AutoScroll = true; UpgradeBox.Refresh(); }
public void InitializeSecondPage() { stackview = new StackView(); TabPage second = tbcMain.TabPages[1]; second.Text = "Links"; backPanel = new Panel(manager); backPanel.Height = second.Height; backPanel.Width = second.Width; //backPanel.Width = second.Width + 20; backPanel.AutoScroll = true; backPanel.Init(); //backPanel.Color = master.BackColor; second.Add(backPanel); HeightCounter3 = 0; VertPadding3 = 0; SourceTarget = new CollapsePanel(manager, backPanel, "Source | Target"); stackview.AddPanel(SourceTarget); LinkPalette = new CollapsePanel(manager, backPanel, "Link Palette"); stackview.AddPanel(LinkPalette); //c3 = new CollapsePanel(manager, backPanel, "third", extended: false); stackview.AddPanel(c3); //c4 = new CollapsePanel(manager, backPanel, "fourth", extended: false); stackview.AddPanel(c4); //c5 = new CollapsePanel(manager, backPanel, "fifth", extended: false); stackview.AddPanel(c5); //c6 = new CollapsePanel(manager, backPanel, "sixth", extended: false); stackview.AddPanel(c6); //c7 = new CollapsePanel(manager, backPanel, "seventh", extended: false); stackview.AddPanel(c7); //c8 = new CollapsePanel(manager, backPanel, "eighth", extended: false); stackview.AddPanel(c8); backPanel.Color = UserInterface.TomDark; tbcMain.SelectedPage = tbcMain.TabPages[1]; #region /// Source | Target /// int left = backPanel.Left; int middle = backPanel.Left + backPanel.Width / 2 - 15; int right = backPanel.Width - 15; SourceTarget.ExpandedHeight += 60; #region /// Source Side /// lblSource = new Label(manager); lblSource.Init(); lblSource.Left = left; lblSource.Top = HeightCounter3; HeightCounter3 += lblSource.Height + VertPadding3; lblSource.Text = " Source"; lblSource.Parent = SourceTarget.panel; lblGroupS = new Label(manager); lblGroupS.Init(); lblGroupS.Left = left; lblGroupS.Top = HeightCounter3; HeightCounter3 += lblGroupS.Height + VertPadding3; lblGroupS.Text = "Group"; lblGroupS.Parent = SourceTarget.panel; cbGroupS = new ComboBox(manager); cbGroupS.Init(); cbGroupS.Left = left; cbGroupS.Top = HeightCounter3; HeightCounter3 += cbGroupS.Height + VertPadding3; cbGroupS.Width = middle; cbGroupS.Parent = SourceTarget.panel; cbGroupS.ItemIndexChanged += cbGroupS_ItemIndexChanged; cbGroupS.MaxItems = 100; lblNodeS = new Label(manager); lblNodeS.Init(); lblNodeS.Left = left; lblNodeS.Top = HeightCounter3; HeightCounter3 += lblNodeS.Height + VertPadding3; lblNodeS.Text = "Node"; lblNodeS.Parent = SourceTarget.panel; cbNodeS = new ComboBox(manager); cbNodeS.Init(); cbNodeS.Left = left; cbNodeS.Top = HeightCounter3; HeightCounter3 += cbNodeS.Height + VertPadding3; cbNodeS.Width = middle; cbNodeS.Parent = SourceTarget.panel; GroupBox radioBoxSource = new GroupBox(manager); radioBoxSource.Init(); radioBoxSource.Left = left; radioBoxSource.Top = HeightCounter3 - 7; radioBoxSource.Width = middle; radioBoxSource.Height = 75; radioBoxSource.Text = ""; radioBoxSource.Parent = SourceTarget.panel; HeightCounter3 = 5; rdGroupS = new RadioButton(manager); rdGroupS.Init(); rdGroupS.Left = left; rdGroupS.Top = HeightCounter3; HeightCounter3 += rdGroupS.Height + VertPadding3; rdGroupS.Width = middle; rdGroupS.Text = "Group"; rdGroupS.Parent = radioBoxSource; rdGroupS.Click += rdGroupS_Click; rdNodeS = new RadioButton(manager); rdNodeS.Init(); rdNodeS.Left = left; rdNodeS.Top = HeightCounter3; HeightCounter3 += rdNodeS.Height + VertPadding3; rdNodeS.Width = middle; rdNodeS.Text = "Node"; rdNodeS.Parent = radioBoxSource; rdNodeS.Click += rdNodeS_Click; chSelectionS = new CheckBox(manager); chSelectionS.Init(); chSelectionS.Left = left; chSelectionS.Top = HeightCounter3; HeightCounter3 += chSelectionS.Height + VertPadding3; chSelectionS.Width = middle; chSelectionS.Text = "Selection"; chSelectionS.Parent = radioBoxSource; chSelectionS.Click += chSelectionS_Click; #endregion #region /// Target Side /// HeightCounter3 = 0; lblTarget = new Label(manager); lblTarget.Init(); lblTarget.Left = middle; lblTarget.Top = HeightCounter3; HeightCounter3 += lblTarget.Height + VertPadding3; lblTarget.Text = "| Target"; lblTarget.Parent = SourceTarget.panel; lblGroupT = new Label(manager); lblGroupT.Init(); lblGroupT.Left = middle; lblGroupT.Top = HeightCounter3; HeightCounter3 += lblGroupT.Height + VertPadding3; lblGroupT.Text = "Group"; lblGroupT.Parent = SourceTarget.panel; cbGroupT = new ComboBox(manager); cbGroupT.Init(); cbGroupT.Left = middle; cbGroupT.Top = HeightCounter3; HeightCounter3 += cbGroupT.Height + VertPadding3; cbGroupT.Width = middle; cbGroupT.Parent = SourceTarget.panel; cbGroupT.ItemIndexChanged += cbGroupT_ItemIndexChanged; cbGroupT.MaxItems = 100; lblNodeT = new Label(manager); lblNodeT.Init(); lblNodeT.Left = middle; lblNodeT.Top = HeightCounter3; HeightCounter3 += lblNodeT.Height + VertPadding3; lblNodeT.Text = "Node"; lblNodeT.Parent = SourceTarget.panel; cbNodeT = new ComboBox(manager); cbNodeT.Init(); cbNodeT.Left = middle; cbNodeT.Top = HeightCounter3; HeightCounter3 += cbNodeT.Height + VertPadding3; cbNodeT.Width = middle; cbNodeT.Parent = SourceTarget.panel; GroupBox radioBoxTarget = new GroupBox(manager); radioBoxTarget.Init(); radioBoxTarget.Left = middle; radioBoxTarget.Top = HeightCounter3 - 7; radioBoxTarget.Width = middle; radioBoxTarget.Height = 75; radioBoxTarget.Text = ""; radioBoxTarget.Parent = SourceTarget.panel; HeightCounter3 = 5; rdGroupT = new RadioButton(manager); rdGroupT.Init(); rdGroupT.Left = left; rdGroupT.Top = HeightCounter3; HeightCounter3 += rdGroupT.Height + VertPadding3; rdGroupT.Width = middle; rdGroupT.Text = "Group"; rdGroupT.Parent = radioBoxTarget; rdGroupT.Click += rdGroupT_Click; rdNodeT = new RadioButton(manager); rdNodeT.Init(); rdNodeT.Left = left; rdNodeT.Top = HeightCounter3; HeightCounter3 += rdNodeT.Height + VertPadding3; rdNodeT.Width = middle; rdNodeT.Text = "Node"; rdNodeT.Parent = radioBoxTarget; rdNodeT.Click += rdNodeT_Click; chSelectionT = new CheckBox(manager); chSelectionT.Init(); chSelectionT.Left = left; chSelectionT.Top = HeightCounter3; HeightCounter3 += chSelectionT.Height + VertPadding3; chSelectionT.Width = middle; chSelectionT.Text = "Selection"; chSelectionT.Parent = radioBoxTarget; chSelectionT.Click += chSelectionT_Click; #endregion #endregion #region /// Link Palette /// LinkPalette.ExpandedHeight += 130; HeightCounter3 = 5; GroupPanel parent3 = LinkPalette.panel; cbLinkList = new ComboBox(manager); cbLinkList.Init(); cbLinkList.Top = HeightCounter3; HeightCounter3 += cbLinkList.Height; cbLinkList.Left = 0; cbLinkList.Width = 150; cbLinkList.Parent = parent3; cbLinkList.Items.AddRange(new List<object>() { "Palette Links", "Source's Links", "Target's Links", "All Active Links" }); cbLinkList.ItemIndexChanged += cbLinkList_ItemIndexChanged; btnCreateLink = new Button(manager); btnCreateLink.Init(); btnCreateLink.Top = HeightCounter3; //HeightCounter3 += btnCreateLink.Height; btnCreateLink.Left = 0; btnCreateLink.Width = (parent3.Width - 10) / 2; btnCreateLink.Text = "Create Link"; btnCreateLink.Parent = parent3; btnCreateLink.Click += btnCreateLink_Click; btnOpenGenerator = new Button(manager); btnOpenGenerator.Init(); btnOpenGenerator.Top = HeightCounter3; HeightCounter3 += btnOpenGenerator.Height; btnOpenGenerator.Left = btnCreateLink.Width; btnOpenGenerator.Width = btnCreateLink.Width; btnOpenGenerator.Text = "Generator"; btnOpenGenerator.Parent = parent3; btnOpenGenerator.Click += btnOpenGenerator_Click; insArea2 = new InspectorArea(this, parent3, 0, HeightCounter3); //insArea2.backPanel.AutoScroll = true; LinkPalette.ExpandedHeight = HeightCounter3 + insArea2.Height + 20; cbLinkList.ItemIndex = 0; rdGroupS.Checked = true; rdGroupT.Checked = true; rdGroupS_Click(null, null); rdGroupT_Click(null, null); #endregion backPanel.Refresh(); tbcMain.SelectedPage = tbcMain.TabPages[0]; }
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); }