private void BindingKeyLabel_LeftMouseClick(Control sender, MouseEventArgs args) { object[] data = (object[])sender.Tag; string id = (string)data[0]; Keys oldKey = (Keys)data[1]; Label lbl = (Label)sender; MessageScreen screen = new MessageScreen((ScreenComponent)Manager, "Press key...", "", "Cancel"); screen.KeyDown += (s, a) => { game.KeyMapper.RemoveKey(id, oldKey); game.KeyMapper.AddKey(id, a.Key); data[1] = a.Key; SettingsManager.Set("KeyMapper-" + id, a.Key.ToString()); lbl.Text = a.Key.ToString(); Manager.NavigateBack(); }; Manager.NavigateToScreen(screen); }
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; } } }
private void BindingKeyLabel_LeftMouseClick(Control sender, MouseEventArgs args) { object[] data = (object[])sender.Tag; string id = (string)data[0]; Keys oldKey = (Keys)data[1]; Label lbl = (Label)sender; MessageScreen screen = new MessageScreen(Manager, "Press key...", "", "Cancel"); screen.KeyDown += (s, a) => { Manager.Game.KeyMapper.RemoveKey(id, oldKey); Manager.Game.KeyMapper.AddKey(id, a.Key); data[1] = a.Key; Manager.Game.Settings.Set("KeyMapper-" + id, a.Key.ToString()); lbl.Text = a.Key.ToString(); Manager.NavigateBack(); }; Manager.NavigateToScreen(screen); }
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"))); } }