public CreateUniverseScreen(ScreenComponent manager) : base(manager) { Manager = manager; settings = manager.Game.Settings; Padding = new Border(0, 0, 0, 0); Title = Languages.OctoClient.CreateUniverse; SetDefaultBackground(); Panel panel = new Panel(manager); panel.VerticalAlignment = VerticalAlignment.Stretch; panel.HorizontalAlignment = HorizontalAlignment.Stretch; panel.Margin = Border.All(50); panel.Background = new BorderBrush(Color.White * 0.5f); panel.Padding = Border.All(10); Controls.Add(panel); Grid grid = new Grid(manager); grid.VerticalAlignment = VerticalAlignment.Stretch; grid.HorizontalAlignment = HorizontalAlignment.Stretch; panel.Controls.Add(grid); grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Auto }); grid.Columns.Add(new ColumnDefinition() { Width = 1,ResizeMode = ResizeMode.Parts }); nameInput = GetTextbox(); nameInput.TextChanged += (s, e) => { createButton.Visible = !string.IsNullOrEmpty(e.NewValue); }; AddLabeledControl(grid, string.Format("{0}: ", Languages.OctoClient.Name), nameInput); seedInput = GetTextbox(); AddLabeledControl(grid, string.Format("{0}: ", Languages.OctoClient.Seed), seedInput); createButton = Button.TextButton(manager, Languages.OctoClient.Create); createButton.HorizontalAlignment = HorizontalAlignment.Right; createButton.VerticalAlignment = VerticalAlignment.Bottom; createButton.Visible = false; createButton.LeftMouseClick += (s, e) => { if (string.IsNullOrEmpty(nameInput.Text)) return; int? seed = null; int textseed; if (int.TryParse(seedInput.Text, out textseed)) seed = textseed; manager.Player.RemovePlayer(); Guid guid = Manager.Game.Simulation.NewGame(nameInput.Text, seed); settings.Set("LastUniverse", guid.ToString()); manager.Game.Player.InsertPlayer(); manager.NavigateToScreen(new GameScreen(manager)); }; panel.Controls.Add(createButton); }
public MessageScreen(ScreenComponent manager, string title, string content, string buttonText = "OK", Action<Control, MouseEventArgs> buttonClick = null) : base(manager) { IsOverlay = true; Background = new BorderBrush(Color.Black * 0.5f); Title = title; Texture2D panelBackground = manager.Game.Content.LoadTexture2DFromFile("./Assets/OctoAwesome.Client/panel.png", manager.GraphicsDevice); Panel panel = new Panel(manager) { Background = NineTileBrush.FromSingleTexture(panelBackground, 30, 30), Padding = Border.All(20), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; Controls.Add(panel); StackPanel spanel = new StackPanel(manager); panel.Controls.Add(spanel); Label headLine = new Label(manager) { Text = title, Font = Skin.Current.HeadlineFont, HorizontalAlignment = HorizontalAlignment.Stretch }; spanel.Controls.Add(headLine); Label contentLabel = new Label(manager) { Text = content, Font = Skin.Current.TextFont, HorizontalAlignment = HorizontalAlignment.Stretch }; spanel.Controls.Add(contentLabel); Button closeButton = Button.TextButton(manager, buttonText); closeButton.HorizontalAlignment = HorizontalAlignment.Stretch; closeButton.LeftMouseClick += (s, e) => { if (buttonClick != null) buttonClick(s, e); else manager.NavigateBack(); }; spanel.Controls.Add(closeButton); }
public CrewMemberScreen(ScreenComponent manager, CrewMember member) : base(manager) { VerticalAlignment = VerticalAlignment.Stretch; HorizontalAlignment = HorizontalAlignment.Stretch; SpriteFont boldFont = manager.Content.Load<SpriteFont>("BoldFont"); Padding = new Border(0, 0, 0, 0); SetDefaultBackground(); //The Panel Texture2D panelBackground = manager.Content.LoadTexture2DFromFile("./Assets/OctoAwesome.Client/panel.png", manager.GraphicsDevice); Panel panel = new Panel(manager) { MaxWidth = 750, Background = NineTileBrush.FromSingleTexture(panelBackground, 30, 30), Padding = new Border(15, 15, 15, 15), }; Controls.Add(panel); //The Vertical Stack - Split the Panel in half Vertical StackPanel verticalStack = new StackPanel(manager) { VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch, Orientation = Orientation.Vertical, }; // panel.Controls.Add(verticalStack); //The Main Stack - Split the Panel in half Horizontal StackPanel horizontalStack = new StackPanel(manager) { HorizontalAlignment = HorizontalAlignment.Center, Orientation = Orientation.Horizontal }; panel.Controls.Add(horizontalStack); //The Profile Image Image profileImage = new Image(manager) { Height = 200, Width = 200, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, Padding = new Border(0, 0, 10, 0) }; if (member.PictureFilename == null) profileImage.Texture = manager.Content.LoadTexture2DFromFile("./Assets/OctoAwesome.Client/Crew/base.png", manager.GraphicsDevice); else profileImage.Texture = manager.Content.LoadTexture2DFromFile(member.PictureFilename, manager.GraphicsDevice); horizontalStack.Controls.Add(profileImage); //The Text Stack StackPanel textStack = new StackPanel(manager); textStack.VerticalAlignment = VerticalAlignment.Stretch; textStack.HorizontalAlignment = HorizontalAlignment.Left; textStack.Width = 430; horizontalStack.Controls.Add(textStack); //The Username Label username = new Label(manager) { Text = member.Username, Font = manager.Content.Load<SpriteFont>("HeadlineFont"), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }; textStack.Controls.Add(username); //The Alias Label alias = new Label(manager) { Text = member.Alias, HorizontalAlignment = HorizontalAlignment.Left }; textStack.Controls.Add(alias); //Achievements string achievementString = ""; foreach (CrewMember.Achievements achievement in member.AchievementList) { achievementString += " " + achievement.ToString(); if (member.AchievementList.IndexOf(achievement) != member.AchievementList.Count - 1) achievementString += ", "; } StackPanel achievementStack = new StackPanel(manager); achievementStack.VerticalAlignment = VerticalAlignment.Top; achievementStack.HorizontalAlignment = HorizontalAlignment.Left; achievementStack.Orientation = Orientation.Horizontal; textStack.Controls.Add(achievementStack); Label achievementsTitle = new Label(manager) { Text = Languages.OctoClient.Achievements + ": ", Font = boldFont, HorizontalAlignment = HorizontalAlignment.Left }; Label achievements = new Label(manager) { Text = achievementString, HorizontalAlignment = HorizontalAlignment.Left }; achievementStack.Controls.Add(achievementsTitle); achievementStack.Controls.Add(achievements); Panel DescriptionPanel = new Panel(manager) { VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch, }; textStack.Controls.Add(DescriptionPanel); Label Description = new Label(manager) { Text = member.Description, WordWrap = true, VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Left, HorizontalTextAlignment = HorizontalAlignment.Left, VerticalTextAlignment = VerticalAlignment.Top, }; Description.InvalidateDimensions(); DescriptionPanel.Controls.Add(Description); panel.Width = 700; }
public CrewMemberScreen(ScreenComponent manager, CrewMember member) : base(manager) { assets = manager.Game.Assets; VerticalAlignment = VerticalAlignment.Stretch; HorizontalAlignment = HorizontalAlignment.Stretch; Title = Languages.OctoClient.CreditsCrew + ": " + member.Username; SpriteFont boldFont = manager.Content.Load<SpriteFont>("BoldFont"); Padding = new Border(0, 0, 0, 0); SetDefaultBackground(); //The Panel Texture2D panelBackground = assets.LoadTexture(typeof(ScreenComponent), "panel"); Panel panel = new Panel(manager) { MaxWidth = 750, Background = NineTileBrush.FromSingleTexture(panelBackground, 30, 30), Padding = new Border(15, 15, 15, 15), }; Controls.Add(panel); //The Main Stack - Split the Panel in half Horizontal StackPanel horizontalStack = new StackPanel(manager) { HorizontalAlignment = HorizontalAlignment.Center, Orientation = Orientation.Horizontal }; panel.Controls.Add(horizontalStack); //The Profile Image Image profileImage = new Image(manager) { Height = 200, Width = 200, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, Padding = new Border(0, 0, 10, 0) }; if (member.PictureFilename == null) profileImage.Texture = assets.LoadTexture(typeof(CrewMember), "base"); else profileImage.Texture = assets.LoadTexture(typeof(CrewMember), member.PictureFilename); horizontalStack.Controls.Add(profileImage); //The Text Stack StackPanel textStack = new StackPanel(manager); textStack.VerticalAlignment = VerticalAlignment.Stretch; textStack.HorizontalAlignment = HorizontalAlignment.Left; textStack.Width = 430; horizontalStack.Controls.Add(textStack); //The Username Label username = new Label(manager) { Text = member.Username, Font = manager.Content.Load<SpriteFont>("HeadlineFont"), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }; textStack.Controls.Add(username); //The Alias Label alias = new Label(manager) { Text = member.Alias, HorizontalAlignment = HorizontalAlignment.Left }; textStack.Controls.Add(alias); //Achievements string achievementString = string.Join(", ", member.AchievementList.Select(a => a.ToString())); StackPanel achievementStack = new StackPanel(manager) { VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Left, Orientation = Orientation.Horizontal, }; textStack.Controls.Add(achievementStack); Label achievementsTitle = new Label(manager) { Text = Languages.OctoClient.Achievements + ": ", Font = boldFont, HorizontalAlignment = HorizontalAlignment.Left }; achievementStack.Controls.Add(achievementsTitle); Label achievements = new Label(manager) { Text = achievementString, HorizontalAlignment = HorizontalAlignment.Left }; achievementStack.Controls.Add(achievements); // Links string linkString = string.Join(", ", member.Links.Select(a => a.Title)); StackPanel linkStack = new StackPanel(manager) { VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Left, Orientation = Orientation.Horizontal, }; textStack.Controls.Add(linkStack); Label linkTitle = new Label(manager) { Text = Languages.OctoClient.Links + ": ", Font = boldFont, HorizontalAlignment = HorizontalAlignment.Left }; linkStack.Controls.Add(linkTitle); foreach (var link in member.Links) { if (CheckHttpUrl(link.Url)) { Button linkButton = Button.TextButton(manager, link.Title); linkButton.LeftMouseClick += (s, e) => Process.Start(link.Url); linkStack.Controls.Add(linkButton); } } Panel descriptionPanel = new Panel(manager) { VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch, }; textStack.Controls.Add(descriptionPanel); Label description = new Label(manager) { Text = member.Description, WordWrap = true, VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Left, HorizontalTextAlignment = HorizontalAlignment.Left, VerticalTextAlignment = VerticalAlignment.Top, }; description.InvalidateDimensions(); descriptionPanel.Controls.Add(description); panel.Width = 700; }
public CreditsScreen(ScreenComponent manager) : base(manager) { Padding = new Border(0, 0, 0, 0); Title = "Credits"; Image background = new Image(manager); background.Texture = Manager.Content.LoadTexture2DFromFile("./Assets/OctoAwesome.Client/background_notext.png", Manager.GraphicsDevice); background.VerticalAlignment = VerticalAlignment.Stretch; background.HorizontalAlignment = HorizontalAlignment.Stretch; Controls.Add(background); Button backButton = Button.TextButton(manager, "Back"); backButton.VerticalAlignment = VerticalAlignment.Top; backButton.HorizontalAlignment = HorizontalAlignment.Left; backButton.LeftMouseClick += (s, e) => { manager.NavigateBack(); }; backButton.Margin = new Border(10, 10, 10, 10); Controls.Add(backButton); List<CrewMember> crew = CrewMember.getCrew(manager); ScrollContainer crewScroll = new ScrollContainer(manager) { VerticalAlignment = VerticalAlignment.Stretch, Margin = new Border(10, 10, 10, 10), CanFocus = false }; StackPanel crewList = new StackPanel(manager) { MinWidth = 700, VerticalAlignment = VerticalAlignment.Stretch, Orientation = Orientation.Vertical, }; crewScroll.Content = crewList; foreach(CrewMember member in crew) { Panel memberPanel = new Panel(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, MinHeight = 30, Background = new BorderBrush(Color.White), Margin = new Border(5, 5, 5, 5), HoveredBackground = new BorderBrush(Color.LightGray) }; memberPanel.LeftMouseClick += (s, e) => { manager.NavigateToScreen(new CrewMemberScreen(manager, member)); }; Label name = new Label(manager) { Text = member.Username, VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Center, Padding = new Border(5, 5, 5, 5) }; memberPanel.Controls.Add(name); crewList.Controls.Add(memberPanel); } Controls.Add(crewScroll); }
public TargetScreen(ScreenComponent manager, Action<int, int> tp, int x, int y) : base(manager) { IsOverlay = true; Background = new BorderBrush(Color.Black * 0.5f); Title = "Select target"; Texture2D panelBackground = manager.Game.Content.LoadTexture2DFromFile("./Assets/OctoAwesome.Client/panel.png", manager.GraphicsDevice); Panel panel = new Panel(manager) { Background = NineTileBrush.FromSingleTexture(panelBackground, 30, 30), Padding = Border.All(20), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; Controls.Add(panel); StackPanel spanel = new StackPanel(manager); panel.Controls.Add(spanel); Label headLine = new Label(manager) { Text = Title, Font = Skin.Current.HeadlineFont, HorizontalAlignment = HorizontalAlignment.Stretch }; spanel.Controls.Add(headLine); StackPanel vstack = new StackPanel(manager); vstack.Orientation = Orientation.Vertical; spanel.Controls.Add(vstack); Textbox xText = new Textbox(manager) { Background = new BorderBrush(Color.Gray), Width = 150, Margin = new Border(10, 10, 10, 10), Text = x.ToString() }; vstack.Controls.Add(xText); Textbox yText = new Textbox(manager) { Background = new BorderBrush(Color.Gray), Width = 150, Margin = new Border(10, 10, 10, 10), Text = y.ToString() }; vstack.Controls.Add(yText); Button closeButton = Button.TextButton(manager, "Teleport"); closeButton.HorizontalAlignment = HorizontalAlignment.Stretch; closeButton.LeftMouseClick += (s, e) => { if (tp != null) tp(int.Parse(xText.Text), int.Parse(yText.Text)); else manager.NavigateBack(); }; spanel.Controls.Add(closeButton); }
public LoadScreen(ScreenComponent manager) : base(manager) { Manager = manager; Padding = new Border(0, 0, 0, 0); Title = Languages.OctoClient.SelectUniverse; SetDefaultBackground(); //Main Panel mainStack = new Grid(manager); mainStack.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 3 }); mainStack.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 }); mainStack.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Parts, Height = 1 }); mainStack.Margin = Border.All(50); mainStack.HorizontalAlignment = HorizontalAlignment.Stretch; mainStack.VerticalAlignment = VerticalAlignment.Stretch; Controls.Add(mainStack); //Level Stack levelList = new Listbox<IUniverse>(manager); levelList.Background = new BorderBrush(Color.White * 0.5f); levelList.VerticalAlignment = VerticalAlignment.Stretch; levelList.HorizontalAlignment = HorizontalAlignment.Stretch; levelList.Margin = Border.All(10); levelList.SelectedItemBrush = new BorderBrush(Color.SaddleBrown * 0.7f); levelList.TemplateGenerator += (x) => { return new Label(manager) { Text = string.Format("{0} ({1})", x.Name, x.Seed), HorizontalAlignment = HorizontalAlignment.Stretch, Padding = Border.All(10), }; }; mainStack.AddControl(levelList, 0, 0); //Sidebar Panel sidebar = new Panel(manager); sidebar.Padding = Border.All(20); sidebar.VerticalAlignment = VerticalAlignment.Stretch; sidebar.HorizontalAlignment = HorizontalAlignment.Stretch; sidebar.Background = new BorderBrush(Color.White * 0.5f); sidebar.Margin = Border.All(10); mainStack.AddControl(sidebar, 1, 0); //Universe Info Label l = new Label(manager); l.Text = " Placeholder "; l.VerticalAlignment = VerticalAlignment.Top; l.HorizontalAlignment = HorizontalAlignment.Left; sidebar.Controls.Add(l); //Buttons StackPanel buttonStack = new StackPanel(manager); buttonStack.VerticalAlignment = VerticalAlignment.Bottom; buttonStack.HorizontalAlignment = HorizontalAlignment.Stretch; sidebar.Controls.Add(buttonStack); //renameButton = getButton("Rename"); //buttonStack.Controls.Add(renameButton); deleteButton = GetButton(Languages.OctoClient.Delete); buttonStack.Controls.Add(deleteButton); deleteButton.LeftMouseClick += (s, e) => { if (levelList.SelectedItem == null) { MessageScreen msg = new MessageScreen(manager, Languages.OctoClient.Error, Languages.OctoClient.SelectUniverseFirst); manager.NavigateToScreen(msg); return; } // Sicherstellen, dass universe nicht geladen ist if (ResourceManager.Instance.CurrentUniverse != null && ResourceManager.Instance.CurrentUniverse.Id == levelList.SelectedItem.Id) return; ResourceManager.Instance.DeleteUniverse(levelList.SelectedItem.Id); levelList.Items.Remove(levelList.SelectedItem); levelList.SelectedItem = null; levelList.InvalidateDimensions(); SettingsManager.Set("LastUniverse", ""); }; createButton = GetButton(Languages.OctoClient.Create); createButton.LeftMouseClick += (s, e) => manager.NavigateToScreen(new CreateUniverseScreen(manager)); buttonStack.Controls.Add(createButton); playButton = GetButton(Languages.OctoClient.Play); playButton.LeftMouseClick += (s, e) => { if (levelList.SelectedItem == null) { MessageScreen msg = new MessageScreen(manager, Languages.OctoClient.Error, Languages.OctoClient.SelectUniverseFirst); manager.NavigateToScreen(msg); return; } Play(); }; buttonStack.Controls.Add(playButton); foreach (var universe in ResourceManager.Instance.ListUniverses()) levelList.Items.Add(universe); // Erstes Element auswählen, oder falls vorhanden das letzte gespielte Universum if (levelList.Items.Count >= 1) levelList.SelectedItem = levelList.Items[0]; if (SettingsManager.KeyExists("LastUniverse") && SettingsManager.Get("LastUniverse") != null && SettingsManager.Get("LastUniverse") != "") { levelList.SelectedItem = levelList.Items.First(u => u.Id == Guid.Parse(SettingsManager.Get("LastUniverse"))); } }
public LoadScreen(ScreenComponent manager) : base(manager) { Manager = manager; Padding = new Border(0, 0, 0, 0); SetDefaultBackground(); //Main Panel mainStack = new Grid(manager); mainStack.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 3 }); mainStack.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 }); mainStack.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Parts, Height = 1 }); mainStack.Margin = Border.All(50); mainStack.HorizontalAlignment = HorizontalAlignment.Stretch; mainStack.VerticalAlignment = VerticalAlignment.Stretch; Controls.Add(mainStack); //Level Stack Listbox<IUniverse> levelList = new Listbox<IUniverse>(manager); levelList.Background = new BorderBrush(Color.White * 0.5f); levelList.VerticalAlignment = VerticalAlignment.Stretch; levelList.HorizontalAlignment = HorizontalAlignment.Stretch; levelList.Margin = Border.All(10); levelList.TemplateGenerator += (x) => { return new Label(manager) { Text = string.Format("{0} ({1})", x.Name, x.Seed), HorizontalAlignment = HorizontalAlignment.Stretch, Padding = Border.All(10), }; }; levelList.SelectedItemChanged += (s, e) => { playButton.Enabled = e.NewItem != null; deleteButton.Enabled = e.NewItem != null; }; mainStack.AddControl(levelList, 0, 0); //Sidebar Panel sidebar = new Panel(manager); sidebar.Padding = Border.All(20); sidebar.VerticalAlignment = VerticalAlignment.Stretch; sidebar.HorizontalAlignment = HorizontalAlignment.Stretch; sidebar.Background = new BorderBrush(Color.White * 0.5f); sidebar.Margin = Border.All(10); mainStack.AddControl(sidebar, 1, 0); //Universe Info Label l = new Label(manager); l.Text = " Placeholder "; l.VerticalAlignment = VerticalAlignment.Top; l.HorizontalAlignment = HorizontalAlignment.Left; sidebar.Controls.Add(l); //Buttons StackPanel buttonStack = new StackPanel(manager); buttonStack.VerticalAlignment = VerticalAlignment.Bottom; buttonStack.HorizontalAlignment = HorizontalAlignment.Stretch; sidebar.Controls.Add(buttonStack); //renameButton = getButton("Rename"); //buttonStack.Controls.Add(renameButton); deleteButton = getButton("Delete"); buttonStack.Controls.Add(deleteButton); deleteButton.LeftMouseClick += (s, e) => { if (levelList.SelectedItem == null) return; // Sicherstellen, dass universe nicht geladen ist if (ResourceManager.Instance.CurrentUniverse != null && ResourceManager.Instance.CurrentUniverse.Id == levelList.SelectedItem.Id) return; ResourceManager.Instance.DeleteUniverse(levelList.SelectedItem.Id); levelList.Items.Remove(levelList.SelectedItem); levelList.SelectedItem = null; levelList.InvalidateDimensions(); }; createButton = getButton("Create"); createButton.LeftMouseClick += (s, e) => manager.NavigateToScreen(new CreateUniverseScreen(manager)); buttonStack.Controls.Add(createButton); playButton = getButton("Play"); playButton.LeftMouseClick += (s, e) => { if (levelList.SelectedItem == null) return; manager.Player.RemovePlayer(); manager.Game.Simulation.LoadGame(levelList.SelectedItem.Id); manager.Game.Player.InsertPlayer(); manager.NavigateToScreen(new GameScreen(manager)); }; buttonStack.Controls.Add(playButton); foreach (var universe in ResourceManager.Instance.ListUniverses()) levelList.Items.Add(universe); }