public TilesetEditor(IContainer Parent) : base(Parent) { Submodes = new SubmodeView(this); Submodes.SetHeaderHeight(31); Submodes.SetHeaderWidth(96); Submodes.SetHeaderSelHeight(1); Submodes.SetTextY(6); PassageContainer = Submodes.CreateTab("Passage"); VignetteFade PassageFade = new VignetteFade(PassageContainer); PassageContainer.OnSizeChanged += delegate(BaseEventArgs e) { PassageFade.SetSize(PassageContainer.Size); }; FourDirContainer = Submodes.CreateTab("4-Dir"); VignetteFade FourDirFade = new VignetteFade(FourDirContainer); FourDirContainer.OnSizeChanged += delegate(BaseEventArgs e) { FourDirFade.SetSize(FourDirContainer.Size); }; //PriorityContainer = Submodes.CreateTab("Priority"); //VignetteFade PriorityFade = new VignetteFade(PriorityContainer); //PriorityContainer.OnSizeChanged += delegate (BaseEventArgs e) { PriorityFade.SetSize(PriorityContainer.Size); }; //Submodes.CreateTab("Terrain Tag"); //Submodes.CreateTab("Bush Flag"); //Submodes.CreateTab("Counter Flag"); Container PassageSubContainer = new Container(PassageContainer); PassageList = new TilesetDisplay(PassageSubContainer); PassageList.OnTilesetLoaded += delegate(BaseEventArgs e) { PassageDrawAll(); }; PassageList.OnTileClicked += delegate(MouseEventArgs e) { PassageInput(e); }; Container FourDirSubContainer = new Container(FourDirContainer); FourDirList = new TilesetDisplay(FourDirSubContainer); FourDirList.OnTilesetLoaded += delegate(BaseEventArgs e) { FourDirDrawAll(); }; FourDirList.OnTileClicked += delegate(MouseEventArgs e) { FourDirInput(e); }; PassageContainer.SetBackgroundColor(28, 50, 73); FourDirContainer.SetBackgroundColor(28, 50, 73); //PriorityContainer.SetBackgroundColor(28, 50, 73); SharedContainer = new Container(this); SharedContainer.SetPosition(22, 41); SharedContainer.Sprites["bg"] = new Sprite(SharedContainer.Viewport); SimpleFade fade = new SimpleFade(SharedContainer); fade.SetPosition(4, 4); NameLabel = new Label(SharedContainer); NameLabel.SetText("Name"); NameLabel.SetFont(Font.Get("Fonts/Ubuntu-B", 14)); NameLabel.SetPosition(19, 16); NameBox = new TextBox(SharedContainer); NameBox.SetPosition(19, 40); NameBox.SetSize(156, 21); NameBox.SetSkin(1); // Updates tileset list NameBox.OnTextChanged += delegate(BaseEventArgs e) { if (this.Tileset == null) { return; } this.Tileset.Name = NameBox.Text; ListItem item = DBDataList.DataList.Items[TilesetID - 1]; item.Name = item.Name.Split(':')[0] + ": " + this.Tileset.Name; DBDataList.DataList.Redraw(); }; GraphicLabel = new Label(SharedContainer); GraphicLabel.SetFont(Font.Get("Fonts/Ubuntu-B", 14)); GraphicLabel.SetPosition(19, 79); GraphicLabel.SetText("Tileset Graphic"); GraphicBox = new BrowserBox(SharedContainer); GraphicBox.SetPosition(19, 103); GraphicBox.SetSize(156, 21); GraphicBox.OnDropDownClicked += delegate(BaseEventArgs e) { OpenFileDialog of = new OpenFileDialog(); of.SetFilter(new FileFilter("PNG Image", "png")); of.SetInitialDirectory(Game.Data.ProjectPath + "/gfx/tilesets"); of.SetTitle("Pick a tileset..."); object result = of.Show(); if (result != null) { // Converts path (C:/.../.../tileset_image.png) to filename (tileset_image) string path = result as string; while (path.Contains('\\')) { path = path.Replace('\\', '/'); } string[] folders = path.Split('/'); string file_ext = folders[folders.Length - 1]; string[] dots = file_ext.Split('.'); string file = ""; for (int i = 0; i < dots.Length - 1; i++) { file += dots[i]; if (i != dots.Length - 2) { file += '.'; } } string tilesetsfolder = Game.Data.ProjectPath + "/gfx/tilesets"; // Selected file not in the tilesets folder // Copies source to tilesets folder string chosenparent = System.IO.Directory.GetParent(path).FullName; while (chosenparent.Contains('\\')) { chosenparent = chosenparent.Replace('\\', '/'); } if (chosenparent != tilesetsfolder) { MessageBox box = new MessageBox("Error", "The selected file doesn't exist in the gfx/tilesets folder. Would you like to copy it in?", ButtonType.YesNo); box.OnButtonPressed += delegate(BaseEventArgs e) { if (box.Result == 0) // Yes { string newfilename = null; if (System.IO.File.Exists(tilesetsfolder + "/" + file_ext)) { int iterator = 1; while (string.IsNullOrEmpty(newfilename)) { if (!System.IO.File.Exists(tilesetsfolder + "/" + file + " (" + iterator.ToString() + ")." + dots[dots.Length - 1])) { newfilename = tilesetsfolder + "/" + file + " (" + iterator.ToString() + ")." + dots[dots.Length - 1]; file = file + " (" + iterator.ToString() + ")"; } iterator++; } } else { newfilename = tilesetsfolder + "/" + file_ext; } System.IO.File.Copy(path, newfilename); SetTilesetGraphic(file); } }; } // File is in tilesets folder else { SetTilesetGraphic(file); } } }; // Updates graphic if typed GraphicBox.TextArea.OnWidgetDeselected += delegate(BaseEventArgs e) { string file = GraphicBox.Text; if (!System.IO.File.Exists(Game.Data.ProjectPath + "/gfx/tilesets/" + file + ".png")) { new MessageBox("Error", "No tileset with the name '" + file + "' exists in gfx/tilesets.", IconType.Error); } else { SetTilesetGraphic(file); } }; ClearTilesetButton = new Button(SharedContainer); ClearTilesetButton.SetPosition(25, 150); ClearTilesetButton.SetSize(140, 44); ClearTilesetButton.SetFont(Font.Get("Fonts/Ubuntu-B", 16)); ClearTilesetButton.SetText("Clear Tileset"); ClearTilesetButton.OnClicked += delegate(BaseEventArgs e) { ConfirmClearTileset(); }; Submodes.SelectTab(1); }
public EditEvent(Map map, Event ev, bool NewEvent = false) { this.MapData = map; this.OldEvent = ev; this.EventData = ev.Clone(); SetTitle($"{(NewEvent ? "New" : "Edit")} event (ID: {Utilities.Digits(EventData.ID, 3)})"); MinimumSize = MaximumSize = new Size(752, 690); SetSize(MaximumSize); Center(); EventGroupBox MainPropertyBox = new EventGroupBox(this); MainPropertyBox.SetPosition(8, 25); MainPropertyBox.SetSize(232, 72); Font f = new Font("Fonts/ProductSans-M", 12); Label NameLabel = new Label(MainPropertyBox); NameLabel.SetFont(f); NameLabel.SetText("Name:"); NameLabel.SetPosition(8, 12); TextBox NameBox = new TextBox(MainPropertyBox); NameBox.SetPosition(46, 7); NameBox.TextArea.SetTextY(2); NameBox.TextArea.SetCaretY(4); NameBox.SetSize(180, 27); NameBox.SetInitialText(EventData.Name); NameBox.OnTextChanged += delegate(BaseEventArgs e) { EventData.Name = NameBox.Text; MarkChanges(); }; Label WidthLabel = new Label(MainPropertyBox); WidthLabel.SetFont(f); WidthLabel.SetText("Width:"); WidthLabel.SetPosition(6, 44); NumericBox WidthBox = new NumericBox(MainPropertyBox); WidthBox.SetPosition(46, 38); WidthBox.SetSize(63, 27); WidthBox.MinValue = 1; WidthBox.MaxValue = 999; WidthBox.SetValue(EventData.Width); WidthBox.OnValueChanged += delegate(BaseEventArgs e) { EventData.Width = WidthBox.Value; TabController.Tabs.ForEach(tc => ((EventPageContainer)tc.Widgets[0]).GraphicWidget.ConfigureGrid()); MarkChanges(); }; Label HeightLabel = new Label(MainPropertyBox); HeightLabel.SetFont(f); HeightLabel.SetText("Height:"); HeightLabel.SetPosition(119, 44); NumericBox HeightBox = new NumericBox(MainPropertyBox); HeightBox.SetPosition(163, 38); HeightBox.SetSize(63, 27); HeightBox.MinValue = 1; HeightBox.MaxValue = 999; HeightBox.SetValue(EventData.Height); HeightBox.OnValueChanged += delegate(BaseEventArgs e) { EventData.Height = HeightBox.Value; MarkChanges(); }; Button NewPageButton = new Button(this); NewPageButton.SetPosition(414, 43); NewPageButton.SetSize(67, 59); NewPageButton.SetText("New\nPage"); NewPageButton.OnClicked += delegate(BaseEventArgs e) { NewPage(); }; Button CopyPageButton = new Button(this); CopyPageButton.SetPosition(481, 43); CopyPageButton.SetSize(67, 59); CopyPageButton.SetText("Copy\nPage"); CopyPageButton.OnClicked += delegate(BaseEventArgs e) { CopyPage(); }; Button PastePageButton = new Button(this); PastePageButton.SetPosition(548, 43); PastePageButton.SetSize(67, 59); PastePageButton.SetText("Paste\nPage"); PastePageButton.OnClicked += delegate(BaseEventArgs e) { PastePage(); }; Button ClearPageButton = new Button(this); ClearPageButton.SetPosition(615, 43); ClearPageButton.SetSize(67, 59); ClearPageButton.SetText("Clear\nPage"); ClearPageButton.OnClicked += delegate(BaseEventArgs e) { ClearPage(); }; DeletePageButton = new Button(this); DeletePageButton.SetPosition(682, 43); DeletePageButton.SetSize(67, 59); DeletePageButton.SetText("Delete\nPage"); if (EventData.Pages.Count == 1) { DeletePageButton.SetEnabled(false); } DeletePageButton.OnClicked += delegate(BaseEventArgs e) { DeletePage(); }; TabController = new TabView(this); TabController.SetXOffset(8); TabController.SetPosition(1, 106); TabController.SetSize(750, 544); TabController.SetHeaderColor(59, 91, 124); for (int i = 0; i < EventData.Pages.Count; i++) { TabContainer tc = TabController.CreateTab(string.IsNullOrWhiteSpace(EventData.Pages[i].Name) ? "Untitled" : EventData.Pages[i].Name); EventPageContainer epc = new EventPageContainer(this, EventData, EventData.Pages[i], tc); epc.SetSize(750, 515); EventPageContainers.Add(epc); } CreateButton("Apply", Apply); CreateButton("Cancel", Cancel); CreateButton("OK", OK); ApplyButton.SetEnabled(false); }
public EditConditionsWindow(List <BasicCondition> Conditions) { this.Conditions = Conditions; this.OldConditions = new List <BasicCondition>(); this.Conditions.ForEach(c => this.OldConditions.Add(c.Clone())); SetTitle("Edit Conditions"); MinimumSize = MaximumSize = new Size(610, 469); SetSize(MaximumSize); Center(); ConditionList = new ConditionBox(this); ConditionList.SetPosition(6, 23); ConditionList.SetSize(279, Size.Height - 67); ConditionList.SetConditions(this.Conditions); ConditionList.SetSelectable(true); ConditionList.OnSelectionChanged += delegate(BaseEventArgs e) { ConditionChanged(); }; if (this.Conditions.Count > 0) { ConditionList.SetSelectedIndex(0); } TypeTabs = new TabView(this); TypeTabs.SetPosition(285, 23); TypeTabs.SetSize(324, Size.Height - 67); TypeTabs.SetXOffset(8); TypeTabs.SetHeaderColor(59, 91, 124); ConditionParser.Headers.ForEach(header => { TabContainer tc = TypeTabs.CreateTab(header.Name); int h = 0; for (int i = 0; i < header.Types.Count; i++) { string typeid = header.Types[i]; ConditionType type = ConditionParser.Types.Find(t => t.Identifier == typeid); if (type.UI.Count == 0) { continue; } ConditionHandlerWidget chw = new ConditionHandlerWidget(type, tc); chw.SetPosition(11, 11 + h); chw.SetSize(Convert.ToInt32(type.UI["width"]), Convert.ToInt32(type.UI["height"])); h += Convert.ToInt32(type.UI["height"]); } }); NewConditionButton = new Button(this); NewConditionButton.SetText("New"); NewConditionButton.SetPosition(14, Size.Height - 38); NewConditionButton.SetSize(122, 31); NewConditionButton.OnClicked += delegate(BaseEventArgs e) { NewCondition(); }; RemoveConditionButton = new Button(this); RemoveConditionButton.SetText("Remove"); RemoveConditionButton.SetPosition(155, Size.Height - 38); RemoveConditionButton.SetSize(122, 31); RemoveConditionButton.OnClicked += delegate(BaseEventArgs e) { RemoveCondition(); }; if (this.Conditions.Count == 0) { RemoveConditionButton.SetEnabled(false); } CreateButton("Apply", Apply); CreateButton("Cancel", Cancel); CreateButton("OK", OK); ApplyButton.SetEnabled(false); ConditionChanged(); if (this.Conditions.Count == 0) { SetAllEnabled(false); } }