protected void Initialize(string Title, bool ShowIDs) { SetTitle(Title); MinimumSize = MaximumSize = new Size(600, 469); SetSize(MaximumSize); Center(); Label pickerlabel = new Label(this); pickerlabel.SetText("Maps"); pickerlabel.SetPosition(18, 24); pickerlabel.SetFont(Font.Get("Fonts/Ubuntu-B", 14)); Maps = new ListBox(this); Maps.SetPosition(25, 44); Maps.SetSize(151, 380); List <ListItem> items = new List <ListItem>(); foreach (Map Map in this.MapList) { string Name = ShowIDs ? $"{Utilities.Digits(Map.ID, 3)}: {Map.DevName}" : Map.DevName; items.Add(new ListItem(Name, Map)); } Maps.SetItems(items); Maps.OnSelectionChanged += delegate(BaseEventArgs e) { UpdatePreview(); }; Label previewlabel = new Label(this); previewlabel.SetText("Preview"); previewlabel.SetPosition(192, 24); previewlabel.SetFont(Font.Get("Fonts/Ubuntu-B", 14)); ColoredBox outline = new ColoredBox(this); outline.SetPosition(194, 44); outline.SetSize(380, 380); outline.SetOuterColor(59, 91, 124); outline.SetInnerColor(24, 38, 53); PreviewContainer = new Container(this); PreviewContainer.SetBackgroundColor(17, 27, 38); PreviewContainer.SetPosition(196, 46); PreviewContainer.SetSize(376, 376); MapBox = new PictureBox(PreviewContainer); MapBox.ResizeBox = false; CreateButton("Cancel", Cancel); CreateButton("OK", OK); if (Maps.Items.Count > 0) { Maps.SetSelectedIndex(0); } }
public TilesetPicker(Map Map) { this.Map = Map; SetTitle("Add Tileset"); MinimumSize = MaximumSize = new Size(506, 498); SetSize(MaximumSize); Center(); Label pickerlabel = new Label(this); pickerlabel.SetText("Tilesets"); pickerlabel.SetPosition(18, 24); pickerlabel.SetFont(Font.Get("Fonts/Ubuntu-B", 14)); Tilesets = new ListBox(this); Tilesets.SetPosition(25, 44); Tilesets.SetSize(151, 409); List <ListItem> items = new List <ListItem>(); for (int i = 1; i < Data.Tilesets.Count; i++) { Tileset tileset = Data.Tilesets[i]; items.Add(new ListItem($"{Utilities.Digits(i, 3)}: {tileset?.Name}", tileset)); } Tilesets.SetItems(items); Tilesets.OnSelectionChanged += delegate(BaseEventArgs e) { UpdatePreview(); }; Label previewlabel = new Label(this); previewlabel.SetText("Preview"); previewlabel.SetPosition(192, 24); previewlabel.SetFont(Font.Get("Fonts/Ubuntu-B", 14)); previewbox = new GroupBox(this); previewbox.SetPosition(200, 44); previewbox.SetSize(280, 409); previewbox.Sprites["line"] = new Sprite(previewbox.Viewport, new SolidBitmap(1, 405, new Color(40, 62, 84))); previewbox.Sprites["line"].X = 267; previewbox.Sprites["line"].Y = 2; scroll = new Container(previewbox); scroll.SetPosition(3, 3); scroll.SetSize(263, 403); scroll.SetVScrollBar(new VScrollBar(previewbox)); scroll.VScrollBar.SetPosition(269, 3); scroll.VScrollBar.SetSize(8, 403); scroll.VAutoScroll = true; tileset = new PictureBox(scroll); CreateButton("Cancel", Cancel); CreateButton("OK", OK); Tilesets.SetSelectedIndex(0); }
public MapPropertiesWindow(Map Map) { this.OldMap = Map; this.Map = Map.Clone(); this.SetTitle($"Map Properties - {Utilities.Digits(Map.ID, 3)}: {Map.DevName}"); MinimumSize = MaximumSize = new Size(540, 460); SetSize(MaximumSize); this.Center(); Label settings = new Label(this); settings.SetText("Info"); settings.SetFont(Font.Get("Fonts/Ubuntu-B", 14)); settings.SetPosition(12, 26); GroupBox box1 = new GroupBox(this); box1.SetPosition(19, 47); box1.SetSize(450, 203); Font f = Font.Get("Fonts/ProductSans-M", 12); Label namelabel = new Label(box1); namelabel.SetText("Working Name:"); namelabel.SetFont(f); namelabel.SetPosition(7, 6); MapName = new TextBox(box1); MapName.SetPosition(6, 22); MapName.SetSize(136, 27); MapName.SetInitialText(Map.DevName); MapName.OnTextChanged += delegate(BaseEventArgs e) { this.Map.DevName = MapName.Text; }; Label displaynamelabel = new Label(box1); displaynamelabel.SetText("In-game Name:"); displaynamelabel.SetFont(f); displaynamelabel.SetPosition(7, 52); DisplayName = new TextBox(box1); DisplayName.SetPosition(6, 68); DisplayName.SetSize(136, 27); DisplayName.SetInitialText(Map.DisplayName); DisplayName.OnTextChanged += delegate(BaseEventArgs e) { this.Map.DisplayName = DisplayName.Text; }; Label widthlabel = new Label(box1); widthlabel.SetText("Width:"); widthlabel.SetFont(f); widthlabel.SetPosition(7, 99); Width = new NumericBox(box1); Width.SetPosition(6, 115); Width.MinValue = 1; Width.MaxValue = 255; Width.SetSize(66, 27); Width.SetValue(this.Map.Width); Width.OnValueChanged += delegate(BaseEventArgs e) { this.Map.Width = Width.Value; }; Label heightlabel = new Label(box1); heightlabel.SetText("Height:"); heightlabel.SetFont(f); heightlabel.SetPosition(78, 99); Height = new NumericBox(box1); Height.SetPosition(77, 115); Height.MinValue = 1; Height.MaxValue = 255; Height.SetSize(66, 27); Height.SetValue(this.Map.Height); Height.OnValueChanged += delegate(BaseEventArgs e) { this.Map.Height = Height.Value; }; Tilesets = new ListBox(box1); Tilesets.SetPosition(162, 22); List <ListItem> tilesetitems = new List <ListItem>(); for (int i = 0; i < this.Map.TilesetIDs.Count; i++) { int id = this.Map.TilesetIDs[i]; Tileset tileset = Data.Tilesets[id]; tilesetitems.Add(new ListItem(tileset)); } Tilesets.SetItems(tilesetitems); Tilesets.SetButtonText("Add Tileset"); Tilesets.ListDrawer.OnButtonClicked += AddTileset; Autotiles = new ListBox(box1); Autotiles.SetPosition(312, 22); List <ListItem> autotileitems = new List <ListItem>(); for (int i = 0; i < this.Map.AutotileIDs.Count; i++) { int id = this.Map.AutotileIDs[i]; Autotile autotile = Data.Autotiles[id]; autotileitems.Add(new ListItem(autotile)); } Autotiles.SetItems(autotileitems); Autotiles.SetButtonText("Add Autotile"); Autotiles.ListDrawer.OnButtonClicked += AddAutotile; Label tilesetslabel = new Label(box1); tilesetslabel.SetText("Tilesets:"); tilesetslabel.SetFont(f); tilesetslabel.SetPosition(163, 6); Label autotileslabel = new Label(box1); autotileslabel.SetText("Autotiles:"); autotileslabel.SetFont(f); autotileslabel.SetPosition(313, 6); CreateButton("Cancel", Cancel); CreateButton("OK", OK); }
public AutotilePicker(Map Map) { SetTitle("Change Autotiles"); MinimumSize = MaximumSize = new Size(506, 498); SetSize(MaximumSize); Center(); OldIDs = new List <int>(Map.AutotileIDs); RectSprite bg1 = new RectSprite(this.Viewport); bg1.SetOuterColor(59, 91, 124); bg1.SetSize(280, 409); bg1.X = 200; bg1.Y = 44; Sprites["bg1"] = bg1; RectSprite bg2 = new RectSprite(this.Viewport); bg2.SetSize(278, 407); bg2.X = 201; bg2.Y = 45; bg2.SetOuterColor(17, 27, 38); bg2.SetInnerColor(24, 38, 53); Sprites["bg2"] = bg2; Sprites["preview"] = new Sprite(this.Viewport); Font f = Font.Get("Fonts/Ubuntu-B", 14); Label labelavail = new Label(this); labelavail.SetText("Available"); labelavail.SetPosition(16, 24); labelavail.SetFont(f); Label labelinuse = new Label(this); labelinuse.SetText("In-use"); labelinuse.SetPosition(16, 250); labelinuse.SetFont(f); Label labelprev = new Label(this); labelprev.SetText("Preview"); labelprev.SetPosition(192, 24); labelprev.SetFont(f); ActionButton = new Button(this); ActionButton.SetPosition(52, 225); ActionButton.SetSize(85, 30); ActionButton.OnClicked += ActionButtonClicked; Available = new ListBox(this); Available.SetPosition(25, 44); Available.SetSize(151, 179); Available.OnSelectionChanged += delegate(BaseEventArgs e) { if (Available.SelectedIndex != -1) { InUse.SetSelectedIndex(-1); SelectionChanged(e); } }; Available.ListDrawer.SetContextMenuList(new List <IMenuItem>() { new MenuItem("Add Autotile") { IsClickable = delegate(BoolEventArgs e) { e.Value = !(SelectedAutotile is null); }, OnLeftClick = ActionButtonClicked } });
public GameVariablePicker(int GroupID, int VariableID) : base() { this.GroupID = GroupID; this.VariableID = VariableID; MinimumSize = MaximumSize = new Size(361, 409); SetTitle("Choose Game Variable"); SetSize(MaximumSize); Center(); CategoryLabel = new Label(this); CategoryLabel.SetPosition(10, 28); CategoryLabel.SetText("Categories"); CategoryLabel.SetFont(Font.Get("Fonts/Ubuntu-B", 14)); VariableLabel = new Label(this); VariableLabel.SetPosition(194, 28); VariableLabel.SetText("Variables"); VariableLabel.SetFont(Font.Get("Fonts/Ubuntu-B", 14)); GroupBox = new ListBox(this); GroupBox.SetPosition(6, 48); GroupBox.SetSize(167, 254); RedrawGroupBox(); GroupBox.OnSelectionChanged += delegate(BaseEventArgs e) { GroupNameBox.SetInitialText(Editor.ProjectSettings.Variables[GroupBox.SelectedIndex].Name ?? ""); RedrawVariableBox(); VariableBox.SetSelectedIndex(0, true); VariableBox.MainContainer.VScrollBar.SetValue(0); }; VariableBox = new ListBox(this); VariableBox.SetPosition(185, 48); VariableBox.SetSize(167, 254); VariableBox.OnSelectionChanged += delegate(BaseEventArgs e) { VariableNameBox.SetInitialText(Editor.ProjectSettings.Variables[GroupBox.SelectedIndex].Variables[VariableBox.SelectedIndex].Name ?? ""); }; VariableBox.OnDoubleClicked += delegate(BaseEventArgs e) { this.VariableID = VariableBox.SelectedIndex + 1; OK(new BaseEventArgs()); }; GroupNameLabel = new Label(this); GroupNameLabel.SetPosition(9, 311); GroupNameLabel.SetText("Name:"); GroupNameLabel.SetFont(Font.Get("Fonts/ProductSans-M", 12)); GroupNameBox = new TextBox(this); GroupNameBox.SetPosition(56, 307); GroupNameBox.SetSize(117, 27); GroupNameBox.OnTextChanged += delegate(BaseEventArgs e) { Editor.ProjectSettings.Variables[GroupBox.SelectedIndex].Name = GroupNameBox.Text; GroupBox.Redraw(); }; VariableNameLabel = new Label(this); VariableNameLabel.SetPosition(193, 311); VariableNameLabel.SetText("Name:"); VariableNameLabel.SetFont(Font.Get("Fonts/ProductSans-M", 12)); VariableNameBox = new TextBox(this); VariableNameBox.SetPosition(235, 307); VariableNameBox.SetSize(117, 27); VariableNameBox.OnTextChanged += delegate(BaseEventArgs e) { Editor.ProjectSettings.Variables[GroupBox.SelectedIndex].Variables[VariableBox.SelectedIndex].Name = VariableNameBox.Text; VariableBox.Redraw(); }; ChangeMaxGroups = new Button(this); ChangeMaxGroups.SetPosition(9, 340); ChangeMaxGroups.SetSize(163, 29); ChangeMaxGroups.SetText("Change Maximum"); ChangeMaxGroups.OnClicked += delegate(BaseEventArgs e) { PopupWindow win = new PopupWindow(); win.SetSize(270, 125); win.SetTitle("Set Variable Group capacity"); Label label = new Label(win); label.SetText("Set the maximum available number of groups."); label.SetPosition(5, 35); Label label2 = new Label(win); label2.SetText("Capacity:"); label2.SetPosition(75, 60); NumericBox num = new NumericBox(win); num.SetSize(66, 27); num.SetPosition(130, 55); num.SetValue(Editor.ProjectSettings.VariableGroupCapacity); num.MinValue = 1; win.CreateButton("Cancel", delegate(BaseEventArgs e) { win.Close(); }); win.CreateButton("OK", delegate(BaseEventArgs e) { int NewValue = num.Value; if (NewValue == Editor.ProjectSettings.VariableGroupCapacity) { win.Close(); return; } else if (NewValue > Editor.ProjectSettings.VariableGroupCapacity) { int Extra = NewValue - Editor.ProjectSettings.VariableGroupCapacity; for (int i = 0; i < Extra; i++) { Editor.ProjectSettings.Variables.Add(new GameVariableGroup() { ID = Editor.ProjectSettings.Variables.Count + 1 }); } Editor.ProjectSettings.VariableGroupCapacity = NewValue; RedrawGroupBox(); win.Close(); } else { int Lost = Editor.ProjectSettings.VariableGroupCapacity - NewValue; MessageBox box = new MessageBox("Warning", $"By resizing the Variable Group capacity from {Editor.ProjectSettings.VariableGroupCapacity} to {NewValue}, {Lost} entries will be removed.\n" + "This may cause unforeseen problems if Game Variables from these groups are still in use.\n" + "Would you like to proceed and delete these Variable Groups?", ButtonType.YesNoCancel, IconType.Warning); box.OnButtonPressed += delegate(BaseEventArgs e) { if (box.Result == 0) // Yes -> resize Switch Group capacity and delete Switch Groups { for (int i = Editor.ProjectSettings.Variables.Count - 1; i >= 0; i--) { if (i == NewValue) { break; } Editor.ProjectSettings.Variables[i] = null; } Editor.ProjectSettings.Variables.RemoveRange(NewValue, Lost); Editor.ProjectSettings.VariableGroupCapacity = NewValue; RedrawGroupBox(); win.Close(); } else // No, cancel -> do nothing { win.Close(); } }; } }); win.Center(); }; ChangeMaxVariables = new Button(this); ChangeMaxVariables.SetPosition(188, 340); ChangeMaxVariables.SetSize(163, 29); ChangeMaxVariables.SetText("Change Maximum"); ChangeMaxVariables.OnClicked += delegate(BaseEventArgs e) { PopupWindow win = new PopupWindow(); win.SetSize(270, 125); win.SetTitle("Set Variable capacity"); Label label = new Label(win); label.SetText("Set the maximum available number of variables."); label.SetPosition(5, 35); Label label2 = new Label(win); label2.SetText("Capacity:"); label2.SetPosition(75, 60); NumericBox num = new NumericBox(win); num.SetSize(66, 27); num.SetPosition(130, 55); num.SetValue(Editor.ProjectSettings.Variables[GroupBox.SelectedIndex].VariableCapacity); num.MinValue = 1; win.CreateButton("Cancel", delegate(BaseEventArgs e) { win.Close(); }); win.CreateButton("OK", delegate(BaseEventArgs e) { int NewValue = num.Value; if (NewValue == Editor.ProjectSettings.Variables[GroupBox.SelectedIndex].VariableCapacity) { win.Close(); return; } else if (NewValue > Editor.ProjectSettings.Variables[GroupBox.SelectedIndex].VariableCapacity) { int Extra = NewValue - Editor.ProjectSettings.Variables[GroupBox.SelectedIndex].VariableCapacity; for (int i = 0; i < Extra; i++) { Editor.ProjectSettings.Variables[GroupBox.SelectedIndex].Variables.Add(new GameVariable() { ID = Editor.ProjectSettings.Variables[GroupBox.SelectedIndex].Variables.Count + 1 }); } Editor.ProjectSettings.Variables[GroupBox.SelectedIndex].VariableCapacity = NewValue; RedrawVariableBox(); win.Close(); } else { int Lost = Editor.ProjectSettings.Variables[GroupBox.SelectedIndex].VariableCapacity - NewValue; MessageBox box = new MessageBox("Warning", $"By resizing the Variable capacity from {Editor.ProjectSettings.Variables[GroupBox.SelectedIndex].VariableCapacity} to {NewValue}, {Lost} entries will be removed.\n" + "This may cause unforeseen problems if any of these Variables are still in use.\n" + "Would you like to proceed and delete these Variables?", ButtonType.YesNoCancel, IconType.Warning); box.OnButtonPressed += delegate(BaseEventArgs e) { if (box.Result == 0) // Yes -> resize Switch Group capacity and delete Switch Groups { for (int i = Editor.ProjectSettings.Variables[GroupBox.SelectedIndex].Variables.Count - 1; i >= 0; i--) { if (i == NewValue) { break; } Editor.ProjectSettings.Variables[GroupBox.SelectedIndex].Variables[i] = null; } Editor.ProjectSettings.Variables[GroupBox.SelectedIndex].Variables.RemoveRange(NewValue, Lost); Editor.ProjectSettings.Variables[GroupBox.SelectedIndex].VariableCapacity = NewValue; RedrawVariableBox(); win.Close(); } else // No, cancel -> do nothing { win.Close(); } }; } }); win.Center(); }; GroupBox.SetSelectedIndex(this.GroupID - 1); VariableBox.SetSelectedIndex(this.VariableID - 1); CreateButton("Cancel", Cancel); CreateButton("OK", OK); }
public TilesetPickerMap(Map Map) { SetTitle("Change Tilesets"); MinimumSize = MaximumSize = new Size(506, 498); SetSize(MaximumSize); Center(); OldIDs = new List <int>(Map.AutotileIDs); ColoredBox box1 = new ColoredBox(this); box1.SetOuterColor(59, 91, 124); box1.SetInnerColor(17, 27, 38); box1.SetPosition(200, 44); box1.SetSize(280, 409); ColoredBox box2 = new ColoredBox(this); box2.SetOuterColor(24, 38, 53); box2.SetPosition(201, 45); box2.SetSize(278, 407); TilesetContainer = new Container(this); TilesetContainer.SetPosition(203, 47); TilesetContainer.SetSize(274, 403); TilesetContainer.VAutoScroll = true; VScrollBar vs = new VScrollBar(this); vs.SetPosition(469, 47); vs.SetSize(10, 403); TilesetContainer.SetVScrollBar(vs); TilesetBox = new PictureBox(TilesetContainer); Font f = Font.Get("Fonts/Ubuntu-B", 14); Label labelavail = new Label(this); labelavail.SetText("Available"); labelavail.SetPosition(16, 24); labelavail.SetFont(f); Label labelinuse = new Label(this); labelinuse.SetText("In-use"); labelinuse.SetPosition(16, 250); labelinuse.SetFont(f); Label labelprev = new Label(this); labelprev.SetText("Preview"); labelprev.SetPosition(192, 24); labelprev.SetFont(f); ActionButton = new Button(this); ActionButton.SetPosition(52, 225); ActionButton.SetSize(85, 30); ActionButton.OnClicked += ActionButtonClicked; Available = new ListBox(this); Available.SetPosition(25, 44); Available.SetSize(151, 179); Available.OnSelectionChanged += delegate(BaseEventArgs e) { if (Available.SelectedIndex != -1) { InUse.SetSelectedIndex(-1); SelectionChanged(e); } }; Available.ListDrawer.SetContextMenuList(new List <IMenuItem>() { new MenuItem("Add Tileset") { IsClickable = delegate(BoolEventArgs e) { e.Value = !(SelectedTileset is null); }, OnLeftClick = ActionButtonClicked } });