public override void SetupViews(Grid grid, MainWindow main) { var mainEntries = new ObservableCollection <MultiStructItemCustomView>(); var statusBuildups = new ObservableCollection <IStatusBuildup>(); var theRest = new List <MhwStructDataContainer>(); foreach (var entry in data) { if (entry.type.Is(typeof(IStatusBuildup))) { foreach (var item in entry.GetEnumerable <IStatusBuildup>()) { statusBuildups.Add(item); } } else if (entry.type.IsGeneric(typeof(IHasCustomView <>))) { var list = (IHasCustomView <MultiStructItemCustomView>)entry.First(); foreach (var view in list.GetCustomView()) { mainEntries.Add(view); } } else if (entry.type == typeof(Monster_Damage_Attributes_1_)) { entry.SetupView(grid, main); } else { theRest.Add(entry); } } grid.AddControl(new Label { Content = "Monster Damage Attributes (2)", FontSize = MainWindow.FONT_SIZE }); main.AddDataGrid(mainEntries); grid.AddControl(new Label { Content = "Status Buildups", FontSize = MainWindow.FONT_SIZE }); main.AddDataGrid(statusBuildups); foreach (var entry in theRest) { entry.SetupView(grid, main); } }
public override void SetupViews(Grid grid, MainWindow main) { mainEntries = new ObservableCollection <ItemPools>(); foreach (var entry in GetAllEnumerableOfType <Entries>()) { var items = entry.Items_raw; var counts = entry.Counts_raw; var weights = entry.Percents_raw; var carveAnimations = entry.Carve_Animations_raw; var innerItems = new ObservableCollection <InnerItem>(); for (var i = 0; i < items.Count; i++) { innerItems.Add(new InnerItem((ulong)i, items[i], counts[i], weights[i], carveAnimations[i])); } mainEntries.Add(new ItemPools(entry.Index, innerItems).Init(targetFile)); } grid.AddControl(new Label { Content = "Item Pools", FontSize = MainWindow.FONT_SIZE }); main.AddDataGrid(mainEntries); }
private void AddLabeledControl(Grid grid, String name, Control c) { grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Auto }); grid.AddControl(new Label(Manager) { Text = name }, 0, grid.Rows.Count - 1); grid.AddControl(c, 1, grid.Rows.Count - 1); grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Fixed, Height = 10 }); }
public void SetupViews(Grid grid, MainWindow main) { grid.AddControl(new Label { Content = "Weapons", FontSize = MainWindow.FONT_SIZE }); main.AddDataGrid(weapons); grid.AddControl(new Label { Content = "Armors", FontSize = MainWindow.FONT_SIZE }); main.AddDataGrid(armors); grid.AddControl(new Label { Content = "Pendants", FontSize = MainWindow.FONT_SIZE }); main.AddDataGrid(pendants); grid.AddControl(new Label { Content = "Items", FontSize = MainWindow.FONT_SIZE }); main.AddDataGrid(items); grid.AddControl(new Label { Content = "Unk1", FontSize = MainWindow.FONT_SIZE }); main.AddDataGrid(unk1); grid.AddControl(new Label { Content = "Unk2", FontSize = MainWindow.FONT_SIZE }); main.AddDataGrid(unk2); grid.AddControl(new Label { Content = "Unk3", FontSize = MainWindow.FONT_SIZE }); main.AddDataGrid(unk3); }
public static void SetupViews(TimeGate timeGate, Grid grid, MainWindow main) { grid.AddControl(new Label { Content = "Weapons", FontSize = MainWindow.FONT_SIZE }); main.AddDataGrid(timeGate.weapons); grid.AddControl(new Label { Content = "Armors", FontSize = MainWindow.FONT_SIZE }); main.AddDataGrid(timeGate.armors); grid.AddControl(new Label { Content = "Pendants", FontSize = MainWindow.FONT_SIZE }); main.AddDataGrid(timeGate.pendants); grid.AddControl(new Label { Content = "Items", FontSize = MainWindow.FONT_SIZE }); main.AddDataGrid(timeGate.items); grid.AddControl(new Label { Content = "Unk1", FontSize = MainWindow.FONT_SIZE }); main.AddDataGrid(timeGate.unk1); grid.AddControl(new Label { Content = "Unk2", FontSize = MainWindow.FONT_SIZE }); main.AddDataGrid(timeGate.unk2); grid.AddControl(new Label { Content = "Unk3", FontSize = MainWindow.FONT_SIZE }); main.AddDataGrid(timeGate.unk3); }
public static void SetupViews(Models.Collision collision, Grid grid, MainWindow main) { if (MainWindow.showAll) { grid.AddControl(new Label { Content = "Collision", FontSize = FONT_SIZE }); main.AddDataGrid(new List <Models.Collision> { collision }); grid.AddControl(new Label { Content = "CLND", FontSize = FONT_SIZE }); main.AddDataGrid(new List <Clnd> { collision.clnd }); for (var i = 0; i < collision.clnd.clgm.Count; i++) { grid.AddControl(new Label { Content = $"CLGM {i + 1}", FontSize = FONT_SIZE }); main.AddDataGrid(new List <Clgm> { collision.clnd.clgm[i] }); if (collision.clnd.clgm[i].clgmInner.Any()) { grid.AddControl(new Label { Content = $"CLGM {i + 1}: Inner Array", FontSize = FONT_SIZE }); main.AddDataGrid(collision.clnd.clgm[i].clgmInner); } } } foreach (var name in collision.names.Where(name => name.moveId > -1).OrderBy(name => name.moveId)) { var nameString = $"Name & Move [{name.TranslatedName}{(string.IsNullOrEmpty(name.Description) ? "" : $", {name.Description}")}]"
public override void SetupViews(Grid grid, MainWindow main) { var customViews = new List <QuestRewardCustomView>((int)Items.FixedSizeCount); for (var i = 0; i < (int)Items.FixedSizeCount; i++) { customViews.Add(new QuestRewardCustomView()); } foreach (var entry in data) { if (!entry.type.Is(typeof(Items), typeof(Counts), typeof(Weights))) { continue; } for (var i = 0; i < (int)Items.FixedSizeCount; i++) { var customView = customViews[i]; var entryItem = ((dynamic)entry).list[i]; if (entry.type.Is(typeof(Items))) { customView.itemIdEntry = (Items)entryItem; } else if (entry.type.Is(typeof(Counts))) { customView.itemCountEntry = (Counts)entryItem; } else if (entry.type.Is(typeof(Weights))) { customView.itemWeightEntry = (Weights)entryItem; } } } grid.AddControl(new Label { Content = "Quest Rewards", FontSize = MainWindow.FONT_SIZE }); main.AddDataGrid(customViews); }
public InventoryScreen(ScreenComponent manager) : base(manager) { assets = manager.Game.Assets; foreach (var item in manager.Game.DefinitionManager.GetDefinitions()) { Texture2D texture = manager.Game.Assets.LoadTexture(item.GetType(), item.Icon); toolTextures.Add(item.GetType().FullName, texture); } player = manager.Player; IsOverlay = true; Background = new BorderBrush(Color.Black * 0.3f); backgroundBrush = new BorderBrush(Color.Black); hoverBrush = new BorderBrush(Color.Brown); Texture2D panelBackground = assets.LoadTexture(typeof(ScreenComponent), "panel"); Grid grid = new Grid(manager) { Width = 800, Height = 500, }; grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Fixed, Width = 600 }); grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Fixed, Width = 200 }); grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Parts, Height = 1 }); grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Fixed, Height = 100 }); Controls.Add(grid); inventory = new InventoryControl(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Background = NineTileBrush.FromSingleTexture(panelBackground, 30, 30), Padding = Border.All(20), }; grid.AddControl(inventory, 0, 0); StackPanel infoPanel = new StackPanel(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Background = NineTileBrush.FromSingleTexture(panelBackground, 30, 30), Padding = Border.All(20), Margin = Border.All(10, 0, 0, 0), }; nameLabel = new Label(manager); infoPanel.Controls.Add(nameLabel); massLabel = new Label(manager); infoPanel.Controls.Add(massLabel); volumeLabel = new Label(manager); infoPanel.Controls.Add(volumeLabel); grid.AddControl(infoPanel, 1, 0); Grid toolbar = new Grid(manager) { Margin = Border.All(0, 10, 0, 0), Height = 100, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Background = NineTileBrush.FromSingleTexture(panelBackground, 30, 30), }; toolbar.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 }); for (int i = 0; i < ToolBarComponent.TOOLCOUNT; i++) { toolbar.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Fixed, Width = 50 }); } toolbar.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 }); toolbar.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Parts, Height = 1 }); images = new Image[ToolBarComponent.TOOLCOUNT]; for (int i = 0; i < ToolBarComponent.TOOLCOUNT; i++) { Image image = images[i] = new Image(manager) { Width = 42, Height = 42, Background = backgroundBrush, HorizontalAlignment = HorizontalAlignment.Center, Tag = i, Padding = Border.All(2), }; image.StartDrag += (e) => { InventorySlot slot = player.Toolbar.Tools[(int)image.Tag]; if (slot != null) { e.Handled = true; e.Icon = toolTextures[slot.Definition.GetType().FullName]; e.Content = slot; e.Sender = toolbar; } }; image.DropEnter += (e) => { image.Background = hoverBrush; }; image.DropLeave += (e) => { image.Background = backgroundBrush; }; image.EndDrop += (e) => { e.Handled = true; if (e.Sender is Grid) // && ShiftPressed { // Swap int targetIndex = (int)image.Tag; InventorySlot targetSlot = player.Toolbar.Tools[targetIndex]; InventorySlot sourceSlot = e.Content as InventorySlot; int sourceIndex = player.Toolbar.GetSlotIndex(sourceSlot); player.Toolbar.SetTool(sourceSlot, targetIndex); player.Toolbar.SetTool(targetSlot, sourceIndex); } else { // Inventory Drop InventorySlot slot = e.Content as InventorySlot; player.Toolbar.SetTool(slot, (int)image.Tag); } }; toolbar.AddControl(image, i + 1, 0); } grid.AddControl(toolbar, 0, 1, 2); Title = Languages.OctoClient.Inventory; }
public LoadScreen(ScreenComponent manager) : base(manager) { Manager = manager; settings = manager.Game.Settings; 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(); settings.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 (settings.KeyExists("LastUniverse") && settings.Get <string>("LastUniverse") != null && settings.Get <string>("LastUniverse") != "") { var lastlevel = levelList.Items.FirstOrDefault(u => u.Id == Guid.Parse(settings.Get <string>("LastUniverse"))); if (lastlevel != null) { levelList.SelectedItem = lastlevel; } } }
public ToolbarControl(ScreenComponent screenManager) : base(screenManager) { Player = screenManager.Player; toolTextures = new Dictionary <string, Texture2D>(); buttonBackgroud = new BorderBrush(Color.Black); activeBackground = new BorderBrush(Color.Red); foreach (var item in DefinitionManager.Instance.GetItemDefinitions()) { Texture2D texture = screenManager.Game.Assets.LoadTexture(item.GetType(), item.Icon); toolTextures.Add(item.GetType().FullName, texture); } Grid grid = new Grid(screenManager) { Margin = new Border(0, 0, 0, 0), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Bottom }; Controls.Add(grid); grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Auto, Height = 1 }); grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Fixed, Height = 50 }); for (int i = 0; i < OctoAwesome.Player.TOOLCOUNT; i++) { grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Fixed, Width = 50 }); } activeToolLabel = new Label(screenManager); activeToolLabel.VerticalAlignment = VerticalAlignment.Top; activeToolLabel.HorizontalAlignment = HorizontalAlignment.Center; activeToolLabel.Background = new BorderBrush(Color.Black * 0.3f); activeToolLabel.TextColor = Color.White; grid.AddControl(activeToolLabel, 0, 0, OctoAwesome.Player.TOOLCOUNT); for (int i = 0; i < OctoAwesome.Player.TOOLCOUNT; i++) { buttons[i] = new Button(screenManager) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Background = buttonBackgroud, HoveredBackground = null, PressedBackground = null, }; buttons[i].Content = images[i] = new Image(screenManager) { Width = 42, Height = 42, }; grid.AddControl(buttons[i], i, 1); } }
public InventoryControl(ScreenComponent manager, int columns = COLUMNS) : base(manager) { ScrollContainer scroll = new ScrollContainer(manager) { Margin = new Border(0, 0, 0, 0), HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, }; Controls.Add(scroll); Grid grid = new Grid(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, }; for (int i = 0; i < columns; i++) { grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 }); } int rows = (int)System.Math.Ceiling((float)manager.Game.Player.ActorHost.Player.Inventory.Count / columns); for (int i = 0; i < rows; i++) { grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Fixed, Height = 50 }); } int column = 0; int row = 0; foreach (var item in manager.Game.Player.ActorHost.Player.Inventory) { Texture2D texture = manager.Game.Assets.LoadTexture(item.Definition.GetType(), item.Definition.Icon); var image = new Image(manager) { Texture = texture, Width = 42, Height = 42, VerticalAlignment = VerticalAlignment.Center }; image.MouseEnter += (s, e) => { HoveredSlot = item; }; image.MouseLeave += (s, e) => { HoveredSlot = null; }; image.StartDrag += (e) => { e.Handled = true; e.Icon = texture; e.Content = item; e.Sender = image; }; var label = new Label(manager) { Text = item.Amount.ToString(), HorizontalAlignment = HorizontalAlignment.Right, VerticalTextAlignment = VerticalAlignment.Bottom, Background = new BorderBrush(Color.White) }; grid.AddControl(image, column, row); grid.AddControl(label, column, row); column++; if (column >= columns) { row++; column = 0; } } scroll.Content = grid; }
public ConnectionScreen(ScreenComponent manager) : base(manager) { game = Manager.Game; Padding = new Border(0, 0, 0, 0); Title = Languages.OctoClient.CreateUniverse; SetDefaultBackground(); var panel = new StackPanel(manager) { VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch, Margin = Border.All(50), Background = new BorderBrush(Color.White * 0.5f), Padding = Border.All(10) }; Controls.Add(panel); var grid = new Grid(manager) { VerticalAlignment = VerticalAlignment.Stretch, 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 }); var serverNameInput = new Textbox(manager) { Text = game.Settings.Get("server", "localhost"), HorizontalAlignment = HorizontalAlignment.Stretch, Background = new BorderBrush(Color.LightGray, LineType.Solid, Color.Black) }; AddLabeledControl(grid, "Host:", serverNameInput); var playerNameInput = new Textbox(manager) { Text = game.Settings.Get("player", "USERNAME"), HorizontalAlignment = HorizontalAlignment.Stretch, Background = new BorderBrush(Color.LightGray, LineType.Solid, Color.Black) }; AddLabeledControl(grid, "Username:"******"server", serverNameInput.Text); game.Settings.Set("player", playerNameInput.Text); ((ContainerResourceManager)game.ResourceManager) .CreateManager(game.ExtensionLoader, game.DefinitionManager, game.Settings, true); PlayMultiplayer(manager, playerNameInput.Text); }; grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Auto, }); grid.AddControl(createButton, 1, grid.Rows.Count - 1); }
public ExtensionsOptionControl(ScreenComponent manager) : base(manager) { Grid grid = new Grid(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Margin = Border.All(15), }; Controls.Add(grid); grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 }); grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Fixed, Width = 100 }); grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 }); grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Parts, Height = 1 }); grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Auto, Height = 1 }); grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Auto, Height = 1 }); StackPanel buttons = new StackPanel(manager) { VerticalAlignment = VerticalAlignment.Stretch, }; grid.AddControl(buttons, 1, 0); #region Manipulationsbuttons enableButton = new TextButton(manager, Languages.OctoClient.Enable); enableButton.HorizontalAlignment = HorizontalAlignment.Stretch; enableButton.Visible = false; buttons.Controls.Add(enableButton); disableButton = new TextButton(manager, Languages.OctoClient.Disable); disableButton.HorizontalAlignment = HorizontalAlignment.Stretch; disableButton.Visible = false; buttons.Controls.Add(disableButton); #endregion applyButton = new TextButton(manager, Languages.OctoClient.Apply); applyButton.HorizontalAlignment = HorizontalAlignment.Right; applyButton.VerticalAlignment = VerticalAlignment.Bottom; grid.AddControl(applyButton, 0, 2, 3); infoLabel = new Label(ScreenManager) { HorizontalTextAlignment = HorizontalAlignment.Left, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Top, WordWrap = true, }; grid.AddControl(infoLabel, 0, 1, 3); #region Listen loadedExtensionsList = new Listbox <IExtension>(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, SelectedItemBrush = new BorderBrush(Color.SaddleBrown * 0.7f), TemplateGenerator = ListTemplateGenerator, }; grid.AddControl(loadedExtensionsList, 0, 0); activeExtensionsList = new Listbox <IExtension>(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, SelectedItemBrush = new BorderBrush(Color.SaddleBrown * 0.7f), TemplateGenerator = ListTemplateGenerator, }; grid.AddControl(activeExtensionsList, 2, 0); #endregion loadedExtensionsList.SelectedItemChanged += loadedList_SelectedItemChanged; activeExtensionsList.SelectedItemChanged += activeList_SelectedItemChanged; enableButton.LeftMouseClick += (s, e) => { IExtension ext = loadedExtensionsList.SelectedItem; loadedExtensionsList.Items.Remove(ext); activeExtensionsList.Items.Add(ext); activeExtensionsList.SelectedItem = ext; }; disableButton.LeftMouseClick += (s, e) => { IExtension ext = activeExtensionsList.SelectedItem; activeExtensionsList.Items.Remove(ext); loadedExtensionsList.Items.Add(ext); loadedExtensionsList.SelectedItem = ext; }; applyButton.LeftMouseClick += (s, e) => { //TODO: Apply manager.Game.ExtensionLoader.ApplyExtensions(loadedExtensionsList.Items); Program.Restart(); }; // Daten laden var loader = manager.Game.ExtensionLoader; foreach (var item in loader.LoadedExtensions) { loadedExtensionsList.Items.Add(item); } foreach (var item in loader.ActiveExtensions) { activeExtensionsList.Items.Add(item); if (loadedExtensionsList.Items.Contains(item)) { loadedExtensionsList.Items.Remove(item); } } }
public LoadingScreen(ScreenComponent manager) : base(manager) { Padding = new Border(0, 0, 0, 0); tokenSource = new CancellationTokenSource(); Title = "Loading"; SetDefaultBackground(); //Main Panel var mainStack = new Grid(manager); mainStack.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 4 }); 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); var backgroundStack = new Panel(manager) { Background = new BorderBrush(Color.White * 0.5f), VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch, Margin = Border.All(10) }; mainStack.AddControl(backgroundStack, 0, 0, 1, 1); var mainGrid = new Grid(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }; mainGrid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 }); mainGrid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 3 }); mainGrid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 }); mainGrid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Parts, Height = 4 }); mainGrid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Parts, Height = 1 }); mainGrid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Parts, Height = 1 }); mainGrid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Parts, Height = 4 }); backgroundStack.Controls.Add(mainGrid); var text = new Label(manager) { Text = "Konfuzius sagt: Das hier lädt...", HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Padding = Border.All(10), }; quoteUpdate = Task.Run(async() => await UpdateLabel(text, loadingQuoteProvider, TimeSpan.FromSeconds(1.5), tokenSource.Token)); mainGrid.AddControl(text, 1, 1); //Buttons var buttonStack = new StackPanel(manager) { VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, Orientation = Orientation.Horizontal }; mainGrid.AddControl(buttonStack, 1, 2); Button cancelButton = GetButton(Languages.OctoClient.Cancel); buttonStack.Controls.Add(cancelButton); Debug.WriteLine("Create GameScreen"); gameScreen = new GameScreen(manager); gameScreen.Update(new GameTime()); gameScreen.OnCenterChanged += SwitchToGame; cancelButton.LeftMouseClick += (s, e) => { tokenSource.Cancel(); tokenSource.Dispose(); manager.Player.SetEntity(null); manager.Game.Simulation.ExitGame(); gameScreen.Unload(); manager.NavigateBack(); }; }
public ResourcePacksOptionControl(ScreenComponent manager) : base(manager) { Grid grid = new Grid(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Margin = Border.All(15), }; Controls.Add(grid); grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 }); grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Fixed, Width = 100 }); grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 }); grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Parts, Height = 1 }); grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Auto, Height = 1 }); grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Auto, Height = 1 }); StackPanel buttons = new StackPanel(manager) { VerticalAlignment = VerticalAlignment.Stretch, }; grid.AddControl(buttons, 1, 0); #region Manipulationsbuttons addButton = Button.TextButton(manager, Languages.OctoClient.Add); addButton.HorizontalAlignment = HorizontalAlignment.Stretch; addButton.Visible = false; buttons.Controls.Add(addButton); removeButton = Button.TextButton(manager, Languages.OctoClient.Remove); removeButton.HorizontalAlignment = HorizontalAlignment.Stretch; removeButton.Visible = false; buttons.Controls.Add(removeButton); moveUpButton = Button.TextButton(manager, Languages.OctoClient.Up); moveUpButton.HorizontalAlignment = HorizontalAlignment.Stretch; moveUpButton.Visible = false; buttons.Controls.Add(moveUpButton); moveDownButton = Button.TextButton(manager, Languages.OctoClient.Down); moveDownButton.HorizontalAlignment = HorizontalAlignment.Stretch; moveDownButton.Visible = false; buttons.Controls.Add(moveDownButton); #endregion applyButton = Button.TextButton(manager, Languages.OctoClient.Apply); applyButton.HorizontalAlignment = HorizontalAlignment.Right; applyButton.VerticalAlignment = VerticalAlignment.Bottom; grid.AddControl(applyButton, 0, 2, 3); infoLabel = new Label(ScreenManager) { HorizontalTextAlignment = HorizontalAlignment.Left, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Top, WordWrap = true, }; grid.AddControl(infoLabel, 0, 1, 3); #region Listen loadedPacksList = new Listbox <ResourcePack>(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, SelectedItemBrush = new BorderBrush(Color.SaddleBrown * 0.7f), TemplateGenerator = ListTemplateGenerator, }; grid.AddControl(loadedPacksList, 0, 0); activePacksList = new Listbox <ResourcePack>(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, SelectedItemBrush = new BorderBrush(Color.SaddleBrown * 0.7f), TemplateGenerator = ListTemplateGenerator, }; grid.AddControl(activePacksList, 2, 0); #endregion #region Info Grid //Grid infoGrid = new Grid(ScreenManager) //{ // HorizontalAlignment = HorizontalAlignment.Stretch, //}; //infoGrid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Auto, Width = 1 }); //infoGrid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 }); //infoGrid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Auto, Height = 1 }); //infoGrid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Auto, Height = 1 }); //infoGrid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Auto, Height = 1 }); //Label nameLabel = new Label(ScreenManager) //{ // Text = "Name:", //}; //infoGrid.AddControl(nameLabel, 0, 0); //Label authorLabel = new Label(ScreenManager) //{ // Text = "Author:", //}; //infoGrid.AddControl(authorLabel, 0, 1); //Label descriptionLabel = new Label(ScreenManager) //{ // Text = "Description:", //}; //infoGrid.AddControl(descriptionLabel, 0, 2); //grid.AddControl(infoGrid, 0, 1, 3); #endregion loadedPacksList.SelectedItemChanged += loadedList_SelectedItemChanged; activePacksList.SelectedItemChanged += activeList_SelectedItemChanged; addButton.LeftMouseClick += (s, e) => { ResourcePack pack = loadedPacksList.SelectedItem; loadedPacksList.Items.Remove(pack); activePacksList.Items.Add(pack); activePacksList.SelectedItem = pack; }; removeButton.LeftMouseClick += (s, e) => { ResourcePack pack = activePacksList.SelectedItem; activePacksList.Items.Remove(pack); loadedPacksList.Items.Add(pack); loadedPacksList.SelectedItem = pack; }; moveUpButton.LeftMouseClick += (s, e) => { ResourcePack pack = activePacksList.SelectedItem; if (pack == null) { return; } int index = activePacksList.Items.IndexOf(pack); if (index > 0) { activePacksList.Items.Remove(pack); activePacksList.Items.Insert(index - 1, pack); activePacksList.SelectedItem = pack; } }; moveDownButton.LeftMouseClick += (s, e) => { ResourcePack pack = activePacksList.SelectedItem; if (pack == null) { return; } int index = activePacksList.Items.IndexOf(pack); if (index < activePacksList.Items.Count - 1) { activePacksList.Items.Remove(pack); activePacksList.Items.Insert(index + 1, pack); activePacksList.SelectedItem = pack; } }; applyButton.LeftMouseClick += (s, e) => { manager.Game.Assets.ApplyResourcePacks(activePacksList.Items); Program.Restart(); }; // Daten laden AssetComponent assets = manager.Game.Assets; foreach (var item in assets.LoadedResourcePacks) { loadedPacksList.Items.Add(item); } foreach (var item in manager.Game.Assets.ActiveResourcePacks) { activePacksList.Items.Add(item); if (loadedPacksList.Items.Contains(item)) { loadedPacksList.Items.Remove(item); } } }
public DragDropScreen(BaseScreenComponent manager) : base(manager) { Button backButton = Button.TextButton(manager, "Back"); backButton.HorizontalAlignment = HorizontalAlignment.Left; backButton.VerticalAlignment = VerticalAlignment.Top; backButton.LeftMouseClick += (s, e) => { manager.NavigateBack(); }; Controls.Add(backButton); dragIcon = manager.Content.Load <Texture2D>("drag"); Grid grid = new Grid(manager) { Width = 600, Height = 400, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Background = new BorderBrush(Color.Red) }; Controls.Add(grid); grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 }); grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 }); grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Parts, Height = 1 }); StackPanel buttons = new StackPanel(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, }; Button button1 = Button.TextButton(manager, "Button 1"); button1.StartDrag += (args) => { args.Handled = true; args.Content = "Button 1"; args.Sender = button1; args.Icon = dragIcon; args.IconSize = new Point(16, 16); }; Button button2 = Button.TextButton(manager, "Button 2"); Button button3 = Button.TextButton(manager, "Button 3"); button3.StartDrag += (args) => { args.Handled = true; args.Content = "Button 3"; args.Sender = button3; args.Icon = dragIcon; }; Button button4 = Button.TextButton(manager, "Button 4"); buttons.Controls.Add(button1); buttons.Controls.Add(button2); buttons.Controls.Add(button3); buttons.Controls.Add(button4); grid.AddControl(buttons, 0, 0); Panel panel = new Panel(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Background = defaultBrush }; Label output = new Label(manager) { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, }; panel.Controls.Add(output); panel.EndDrop += (args) => { args.Handled = true; output.Text = args.Content.ToString(); }; panel.DropEnter += (args) => { panel.Background = dragTargetBrush; }; panel.DropLeave += (args) => { panel.Background = defaultBrush; }; grid.AddControl(panel, 1, 0); }