/// <summary> /// Delete rooms button click /// </summary> private void butRoomDelete_Click(object sender, EventArgs e) { // If a project was not selected, return if (lstRooms.SelectedItem == null) { return; } // Get the selected project ExportProject project = (ExportProject)lstRooms.SelectedItem; // If the project is the native one, notify the user an return if (project.Native == true) { MessageBox.Show("You can't remove the native project from the export list. Uncheck the project if you do not want to export it.", "GMare", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } // Remove project and update project list App.Room.Projects.Remove(project); UpdateProjectList(lstRooms.Items.Count == 1 ? -1 : lstRooms.SelectedIndex >= lstRooms.Items.Count - 1 ? lstRooms.Items.Count - 2 : lstRooms.SelectedIndex); // Export projects have changed _changed = _allowChange; }
public WinFormsFileHandler(ExportProject export) { this.export = export; // Listen for button click event EventHandler.Request += ButtonHandler; // Form settings //-------------------------------------------------------------- Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; FormBorderStyle = FormBorderStyle.FixedSingle; Location = new Point(0, -uwfHeaderHeight); // Hide header. MaximizeBox = false; Size = new Size(System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width, uwfHeaderHeight + 24); // + menu height. SizeGripStyle = SizeGripStyle.Hide; StartPosition = FormStartPosition.Manual; uwfMovable = false; }
/// <summary> /// Background numeric property has changed /// </summary> private void background_ValueChanged(object sender, EventArgs e) { // If a project was not selected or the name text box has no focus, return if (lstRooms.SelectedItem == null || !(sender is PyxNumericUpDown)) { return; } // Get the control name ExportProject project = (lstRooms.SelectedItem as ExportProject); string name = (sender as PyxNumericUpDown).Name; // Change background property if (name == nudTileWidth.Name) { project.Background.TileWidth = (int)nudTileWidth.Value; } else if (name == nudTileHeight.Name) { project.Background.TileHeight = (int)nudTileHeight.Value; } else if (name == nudTileOffsetX.Name) { project.Background.OffsetX = (int)nudTileOffsetX.Value; } else if (name == nudTileOffsetY.Name) { project.Background.OffsetY = (int)nudTileOffsetY.Value; } else if (name == nudTileSeparationX.Name) { project.Background.SeparationX = (int)nudTileSeparationX.Value; } else if (name == nudTileSeparationY.Name) { project.Background.SeparationY = (int)nudTileSeparationY.Value; } // Refresh the project list UpdateProjectList(lstRooms.SelectedIndex); // Export projects have changed _changed = _allowChange; }
/// <summary> /// Room selection change /// </summary> private void lstRooms_SelectedIndexChanged(object sender, EventArgs e) { // If the selected item is empty, return if (lstRooms.SelectedItem == null) { txtRoomName.Text = string.Empty; txtProjectPath.Text = string.Empty; txtProjectPath.ToolTipText = ""; txtBackgroundName.Text = "None"; grpBackgrounds.Text = _backgroundHeader; nudTileWidth.Text = "0"; nudTileHeight.Text = "0"; nudTileOffsetX.Text = "0"; nudTileOffsetY.Text = "0"; nudTileSeparationX.Text = "0"; nudTileSeparationY.Text = "0"; grpRoomProperties.Enabled = false; grpBackgrounds.Enabled = false; return; } // Set properties UI ExportProject project = (ExportProject)lstRooms.SelectedItem; txtRoomName.Text = project.Name; txtProjectPath.Text = project.Native ? App.SavePath : project.RoomPath; txtProjectPath.Enabled = project.Native ? false : true; txtProjectPath.ToolTipText = project.RoomPath; txtBackgroundName.Text = (project.Background.Name == "" ? "None" : project.Background.Name); grpBackgrounds.Text = _backgroundHeader + " (ID: " + project.Background.GameMakerId.ToString() + ")"; nudTileWidth.Value = project.Background.TileWidth; nudTileHeight.Value = project.Background.TileHeight; nudTileOffsetX.Value = project.Background.OffsetX; nudTileOffsetY.Value = project.Background.OffsetY; nudTileSeparationX.Value = project.Background.SeparationX; nudTileSeparationY.Value = project.Background.SeparationY; chkWriteTiles.Checked = project.WriteTiles; chkUseFlipped.Checked = project.UseFlipValues; chkUseColor.Checked = project.UseBlendColor; chkWriteInstances.Checked = project.WriteInstances; grpRoomProperties.Enabled = true; grpBackgrounds.Enabled = true; }
/// <summary> /// Constructs a new export binary form /// </summary> public ExportBinaryForm() { InitializeComponent(); // Set base header _backgroundHeader = grpBackgrounds.Text; // If no native project was found, create one if (App.Room.Projects.Find(p => p.Native == true) == null) { ExportProject project = new ExportProject(); project.Native = true; project.Background = App.Room.Backgrounds[0].Clone(); App.Room.Projects.Add(project); // Project changed _changed = true; } // Update the native project ExportProject native = App.Room.Projects.Find(p => p.Native == true); // If project changed if (native.Name != App.Room.Name || native.RoomPath != App.SavePath) { _changed = true; } native.Name = App.Room.Name; native.RoomPath = App.SavePath; // Select first script option cboScripts.SelectedIndex = 0; _allowChange = false; // Update the project list UpdateProjectList(0); _allowChange = true; }
/// <summary> /// Write tiles checkbox check changed /// </summary> private void chkOptions_CheckedChanged(object sender, EventArgs e) { // If the calling object is not a checkbox or the selection is empty, return if (!(sender is CheckBox) || lstRooms.SelectedItem == null) { return; } // Get the calling checkbox name string name = (sender as CheckBox).Name; // Get the export project, and the index ExportProject project = (ExportProject)lstRooms.SelectedItem; // Do action based on checkbox if (chkWriteTiles.Name == name) { // Set UI flags chkUseFlipped.Checked = chkWriteTiles.Checked ? chkUseFlipped.Checked : false; chkUseColor.Checked = chkWriteTiles.Checked ? chkUseFlipped.Checked : false; // Set project flags project.WriteTiles = chkWriteTiles.Checked; } else if (chkUseFlipped.Name == name) { project.UseFlipValues = chkUseFlipped.Checked; } else if (chkUseColor.Name == name) { project.UseBlendColor = chkUseColor.Checked; } else if (chkWriteInstances.Name == name) { project.WriteInstances = chkWriteInstances.Checked; } // Export projects have changed _changed = _allowChange; }
/// <summary> /// Move room down button click /// </summary> private void butMoveDown_Click(object sender, EventArgs e) { // If an item has not been selected, return if (lstRooms.SelectedItem == null) { return; } // Get the index of the selected project, then copy it int index = lstRooms.SelectedIndex; ExportProject swap = (ExportProject)lstRooms.SelectedItem; // If the index is not out of bounds if (index + 1 < lstRooms.Items.Count) { // Remove, insert, and select the swap item App.Room.Projects.RemoveAt(index); App.Room.Projects.Insert(index + 1, swap); UpdateProjectList(index + 1); // Export projects have changed _changed = _allowChange; } }
/// <summary> /// On get text /// </summary> public override string OnGetText(DrawItemEventArgs e) { // Get text based on data type switch (_listboxMode) { case ListboxType.Layers: // Create a custom string for project key value pairs KeyValuePair <string, string> pair = (KeyValuePair <string, string>)Items[e.Index]; return(pair.Value); case ListboxType.Projects: // Get the project ExportProject project = (ExportProject)Items[e.Index]; // Create a string for the project StringBuilder sb = new StringBuilder(); sb.AppendLine(project.Name == "" ? "<No Name>" : project.Name); return(sb.ToString()); default: return(Items[e.Index].ToString()); } }
/// <summary> /// Add rooms button click /// </summary> private void butRoomAdd_Click(object sender, EventArgs e) { // Create a new open file dialog using (OpenFileDialog form = new OpenFileDialog()) { // Set file format filter form.Title = "Add Project(s)"; form.Filter = "GMare Project Files (.gmpx)|*.gmpx;"; form.Multiselect = true; // If ok was not clicked, return if (form.ShowDialog() != DialogResult.OK) { return; } // Iterate through file names, try adding a project for each path foreach (string path in form.FileNames) { // If the path is the same as this project's path, continue if (path == App.SavePath) { continue; } // Get the room data GMareRoom room = App.GetProject(path); // If the room is empty, continue if (room == null) { continue; } // Export project to add ExportProject project = null; // If the native export room is not present, create a new project else clone the existing one if (room.Projects.Find(p => p.Native) == null) { project = new ExportProject(); project.Name = room.Name; project.RoomPath = path; project.Background = App.Room.Backgrounds[0].Clone(); } else { project = room.Projects.Find(p => p.Native).Clone(); } // The project is not native to this project project.Native = false; project.Background = room.Backgrounds[0]; // Add the room to the project list App.Room.Projects.Add(project); } // Update project list UpdateProjectList((lstRooms.Items.Count - 1) + form.FileNames.Length); // Export projects have changed _changed = _allowChange; } }