private ListViewItem CreateLvi(BinWriterTask task) { ListViewItem lvi = new ListViewItem(new string[] { task.DisplayName, task.MapRect, String.Join(", ", task.Images), }); lvi.Tag = task; return(lvi); }
internal void StoreConfig(BinWriterTask task) { List <string> selectedImages = new List <string>(); foreach (var item in this.ImageListBox.SelectedItems) { selectedImages.Add((string)item); } task.DisplayName = this.NameTextBox.Text; task.MapRect = this.MapRectTextBox.Text; task.Images = selectedImages.ToArray(); }
public BinWriterTaskEditor(BinWriterTask task, string[] availableImages) : this() { this.ImageListBox.Items.AddRange(availableImages); this.NameTextBox.Text = task.DisplayName; this.MapRectTextBox.Text = task.MapRect; for (int i = 0; i < this.ImageListBox.Items.Count; i++) { if (!task.Images.Contains(this.ImageListBox.Items[i])) { continue; } this.ImageListBox.SetSelected(i, true); } }
private void editToolStripMenuItem_Click(object sender, EventArgs e) { foreach (ListViewItem lvi in this.BinWriterTaskList.SelectedItems) { BinWriterTask task = (BinWriterTask)lvi.Tag; var box = new BinWriterTaskEditor(task, this.MainWindow.ImagesUserControl.AvailableImages); var dr = box.ShowDialog(); if (dr != DialogResult.OK) { return; } box.StoreConfig(task); lvi.SubItems[0].Text = task.DisplayName; lvi.SubItems[1].Text = task.MapRect; lvi.SubItems[2].Text = String.Join(", ", task.Images); } }
internal void RenameImage(string oldName, string newName) { foreach (ListViewItem lvi in this.BinWriterTaskList.Items) { BinWriterTask task = (BinWriterTask)lvi.Tag; bool change = false; for (int i = 0; i < task.Images.Length; i++) { if (task.Images[i] == oldName) { task.Images[i] = newName; change = true; } } if (change) { lvi.SubItems[2].Text = String.Join(", ", task.Images); } } }
private void WriteMapVersions() { var dir = new DirectoryInfo(this.Config.OutputDirectory); if (!dir.Exists) { dir.Create(); } foreach (var mapVersion in this.Config.Maps) { Map map = new Map { CoordsFile = mapVersion.CoordsFile, Name = String.Format(mapVersion.Name, this.Config.MapVersion), Type = mapVersion.Type }; foreach (var image in mapVersion.Images) { var imgInfo = this.ImageInfo[image]; BinWriterTask workTask = this.Config.BinWriterTasks.FirstOrDefault(wt => wt.Images.Contains(image)); if (workTask == null) { throw new InvalidDataException(); } MapLayer mapLayer = new MapLayer { File = this.Config.MapDirectory + "/" + this.Config.BinFile, FilePos = this.WrittenLayers[image], Size = imgInfo.Size, Tiles = imgInfo.Tiles, MapRect = workTask.MapRect, TextureSize = Settings.TextureSize, }; map.Layers.Add(mapLayer); } map.WriteTextFile(new FileInfo(Path.Combine(dir.FullName, mapVersion.File))); } }
private void addToolStripMenuItem_Click(object sender, EventArgs e) { var box = new BinWriterTaskEditor(); box.ImageListBox.Items.AddRange(this.MainWindow.ImagesUserControl.AvailableImages); var dr = box.ShowDialog(); if (dr != DialogResult.OK) { return; } BinWriterTask task = new BinWriterTask(); box.StoreConfig(task); ListViewItem lvi = this.CreateLvi(task); this.BinWriterTaskList.BeginUpdate(); this.BinWriterTaskList.Items.Add(lvi); this.AssignOrder(); this.BinWriterTaskList.EndUpdate(); }