// generates addon info for a project private static void WriteAddonInfo(TextWriter writer, Project proj) { writer.WriteLine("\"AddonInfo\""); writer.WriteLine("{"); writer.WriteLine("\t\"name\"\t\t\"" + proj.Name + "\""); writer.WriteLine("\t\"version\"\t\"" + proj.Version + "\""); writer.WriteLine("\t\"update\"\t\"" + proj.Update + "\""); writer.WriteLine("\t\"author_name\"\t\"" + proj.AuthorName + "\""); writer.WriteLine("\t\"author_email\"\t\"" + proj.AuthorEmail + "\""); writer.WriteLine("\t\"author_url\"\t\"" + proj.AuthorWebsite + "\""); writer.WriteLine(); writer.WriteLine("\t\"info\"\t\t\"" + proj.Description + "\""); writer.WriteLine(); writer.WriteLine("\t// Won't be active unless the following GCFs are available and"); writer.WriteLine("\t// are mounted"); writer.WriteLine("\t\"GCFRequires\""); writer.WriteLine("\t{"); for (int x = 0; x < proj.Requirements.Count; x++) { writer.WriteLine("\t\t\"" + x + "\"\t\t\"" + proj.Requirements[x].AppID + "\""); } writer.WriteLine("\t}"); writer.WriteLine("}"); writer.Close(); }
/// <summary> /// Generates an info file for a specific project /// </summary> /// <param name="filename">The filename to save the info file as</param> /// <param name="proj">The project to generate a file for</param> public static void GenerateInfo(string filename, Project proj) { FileStream fs = null; StreamWriter sw = null; try { fs = File.Create(filename); } catch (Exception ex) { new ErrorDialog(ex).ShowDialog(); } try { sw = new StreamWriter(fs); } catch (Exception ex) { new ErrorDialog(ex).ShowDialog(); } switch (proj.Type) { case ProjectType.Addon: WriteAddonInfo(sw, proj); break; case ProjectType.Gamemode: WriteGamemodeInfo(sw, proj); break; } }
public ProjectProperties(Project proj) { InitializeComponent(); project = proj; textBox1.Text = proj.Name; textBox2.Text = proj.Description; comboBox1.SelectedItem = proj.Type.ToString(); textBox3.Text = proj.Version; textBox4.Text = proj.Update; textBox5.Text = proj.AuthorName; textBox6.Text = proj.AuthorEmail; textBox7.Text = proj.AuthorWebsite; checkBox1.Checked = proj.HideEntry; for ( int x= 0; x < proj.Requirements.Count; x++) { ListViewItem lvi = new ListViewItem( x.ToString() ); lvi.SubItems.Add( new ListViewItem.ListViewSubItem( lvi, proj.Requirements[x].AppID.ToString() ) ); listView1.Items.Add( lvi ); } }
// generates gamemode info for a project private static void WriteGamemodeInfo(TextWriter writer, Project proj) { writer.WriteLine("\"Gamemode\""); writer.WriteLine("{"); writer.WriteLine("\t\"name\"\t\t\"" + proj.Name + "\""); writer.WriteLine("\t\"version\"\t\"" + proj.Version + "\""); writer.WriteLine(); writer.WriteLine("\t\"author_name\"\t\"" + proj.AuthorName + "\""); writer.WriteLine("\t\"author_email\"\t\"" + proj.AuthorEmail + "\""); writer.WriteLine("\t\"author_url\"\t\"" + proj.AuthorWebsite + "\""); writer.WriteLine(); writer.WriteLine("\t\"info\"\t\t\"" + proj.Description + "\""); writer.WriteLine(); writer.WriteLine("\t// Setting this to 0 will hide the gamemode entry"); writer.WriteLine("\t\"hide\"\t\t\"" + (proj.HideEntry ? 1 : 0) + "\""); writer.WriteLine("}"); writer.Close(); }
public void BuildTreeview(Workspace.Workspace work, Project proj) { Project = proj; foreach (Folder f in Folders) { var node = new TreeNode { Text = f.Name, ContextMenuStrip = work.FolderStrip, ImageKey = "project_folder_closed", SelectedImageKey = "project_folder_closed", Tag = f }; f.Node = node; Node.Nodes.Add(node); f.BuildTreeview(work, proj); } foreach (OpenedFile pf in Files) { string filepath = FullName(); filepath += @"\"; if (!File.Exists(filepath + pf.Name)) { pf.Valid = false; pf.Saved = true; pf.Folder = this; var node = new TreeNode { Text = pf.Name, ContextMenuStrip = work.CodeStrip, ImageKey = "file_lost", SelectedImageKey = "file_lost", Tag = pf }; pf.Node = node; Node.Nodes.Add(node); continue; } pf.FullName = filepath + pf.Name; pf.Saved = true; pf.Valid = true; pf.Folder = this; var tn2 = new TreeNode { Text = pf.Name, ContextMenuStrip = work.CodeStrip, ImageKey = "code", SelectedImageKey = "code", Tag = pf }; pf.Node = tn2; Node.Nodes.Add(tn2); } }
/// <summary> /// Saves a project to a file /// </summary> /// <param name="filename">The filename to save the project as</param> /// <param name="proj">The project to save</param> public static void SaveProject(string filename, Project proj) { XmlSerializer xs; FileStream fs; try { xs = new XmlSerializer(typeof (Project)); } catch (Exception ex) { new ErrorDialog(ex).ShowDialog(); return; } try { fs = File.Create(filename); } catch (Exception ex) { new ErrorDialog(ex).ShowDialog(); return; } #if !DEBUG try { #endif xs.Serialize(fs, proj); #if !DEBUG } catch ( Exception ex ) { new ErrorDialog( ex ).ShowDialog(); fs.Close(); return; } #endif fs.Close(); }