|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.ComponentModel; |
| 4 | +using System.Data; |
| 5 | +using System.Drawing; |
| 6 | +using System.IO; |
| 7 | +using System.Text; |
| 8 | +using System.Windows.Forms; |
| 9 | + |
| 10 | +namespace RageMP_VSupport |
| 11 | +{ |
| 12 | + public partial class Form1 : Form |
| 13 | + { |
| 14 | + public Form1() |
| 15 | + { |
| 16 | + InitializeComponent(); |
| 17 | + } |
| 18 | + private protected string inputcontentXml { get; set; } |
| 19 | + private protected string inputSetup2Xml { get; set; } |
| 20 | + private protected string dir { get; set; } |
| 21 | + private protected string newModName { get; set; } |
| 22 | + private protected string gtaUtilPath { get; set; } |
| 23 | + private protected string texturesDir { get; set; } |
| 24 | + //metas |
| 25 | + private protected string metadataPath { get; set; } |
| 26 | + private protected string carcolsPath { get; set; } |
| 27 | + private protected string carvariationsPath { get; set; } |
| 28 | + private protected string handlingPath { get; set; } |
| 29 | + private protected string dlctextPath { get; set; } |
| 30 | + //Enabled |
| 31 | + private protected bool isUsingMeta { get; set; } |
| 32 | + private protected bool isUsingCarcols { get; set; } |
| 33 | + private protected bool isUsingCarvariations { get; set; } |
| 34 | + private protected bool isUsingHandling { get; set; } |
| 35 | + private protected bool isUsingdlctext { get; set; } |
| 36 | + |
| 37 | + private protected void copyFiles(string sourcePath, string targetPath) |
| 38 | + { |
| 39 | + foreach (string newPath in Directory.GetFiles(sourcePath, "*.*", SearchOption.TopDirectoryOnly)) |
| 40 | + { |
| 41 | + File.Copy(newPath, newPath.Replace(sourcePath, targetPath), true); |
| 42 | + } |
| 43 | + } |
| 44 | + |
| 45 | + |
| 46 | + private void Form1_Load(object sender, EventArgs e) |
| 47 | + { |
| 48 | + inputcontentXml = Properties.Resources.content; |
| 49 | + inputSetup2Xml = Properties.Resources.setup2; |
| 50 | + MessageBox.Show("This little sweet thing is still WORK IN PROGRESS! If you see any bugs then report them to my GitHub or on rage.mp -- Phill \nPS: dont ask me why i firstly made it in .NET 4.7.2 and then moved to v3.0", "IMPORTANT MESSAGE"); |
| 51 | + } |
| 52 | + |
| 53 | + private void button2_Click(object sender, EventArgs e) |
| 54 | + { |
| 55 | + if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) |
| 56 | + { |
| 57 | + textBox2.Text = folderBrowserDialog1.SelectedPath; |
| 58 | + dir = folderBrowserDialog1.SelectedPath; |
| 59 | + } |
| 60 | + } |
| 61 | + |
| 62 | + private void button1_Click(object sender, EventArgs e) |
| 63 | + { |
| 64 | + if (folderBrowserDialog2.ShowDialog() == DialogResult.OK) |
| 65 | + { |
| 66 | + textBox1.Text = folderBrowserDialog2.SelectedPath; |
| 67 | + texturesDir = folderBrowserDialog2.SelectedPath; |
| 68 | + } |
| 69 | + } |
| 70 | + |
| 71 | + private void button3_Click(object sender, EventArgs e) |
| 72 | + { |
| 73 | + openFileDialog1.Filter = "GTAUtil.exe|"; |
| 74 | + if (openFileDialog1.ShowDialog() == DialogResult.OK) |
| 75 | + { |
| 76 | + textBox4.Text = openFileDialog1.FileName; |
| 77 | + gtaUtilPath = openFileDialog1.FileName; |
| 78 | + } |
| 79 | + } |
| 80 | + |
| 81 | + private void textBox3_TextChanged(object sender, EventArgs e) |
| 82 | + { |
| 83 | + if (textBox3.Text.Length > 0 && textBox3.Text.Length < 50) foreach (string word in new List<string> { "ä", "ö", "ü", "ß", "@", "<", ".", ",", "-", " " }) newModName = textBox3.Text.Replace(word, ""); |
| 84 | + } |
| 85 | + |
| 86 | + private void checkBox1_CheckedChanged(object sender, EventArgs e) |
| 87 | + {//metadata |
| 88 | + if (checkBox1.Checked) |
| 89 | + { |
| 90 | + button5.Visible = true; |
| 91 | + } |
| 92 | + else |
| 93 | + { |
| 94 | + button5.Visible = false; |
| 95 | + } |
| 96 | + } |
| 97 | + |
| 98 | + private void checkBox2_CheckedChanged(object sender, EventArgs e) |
| 99 | + {//carcols |
| 100 | + if (checkBox2.Checked) |
| 101 | + { |
| 102 | + button6.Visible = true; |
| 103 | + } |
| 104 | + else |
| 105 | + { |
| 106 | + button6.Visible = false; |
| 107 | + } |
| 108 | + |
| 109 | + } |
| 110 | + |
| 111 | + private void checkBox3_CheckedChanged(object sender, EventArgs e) |
| 112 | + {//variation |
| 113 | + if (checkBox3.Checked) |
| 114 | + { |
| 115 | + button7.Visible = true; |
| 116 | + } |
| 117 | + else |
| 118 | + { |
| 119 | + button7.Visible = false; |
| 120 | + } |
| 121 | + |
| 122 | + } |
| 123 | + |
| 124 | + private void checkBox4_CheckedChanged(object sender, EventArgs e) |
| 125 | + {//handling |
| 126 | + if (checkBox4.Checked) |
| 127 | + { |
| 128 | + button8.Visible = true; |
| 129 | + } |
| 130 | + else |
| 131 | + { |
| 132 | + button8.Visible = false; |
| 133 | + } |
| 134 | + |
| 135 | + } |
| 136 | + |
| 137 | + private void checkBox5_CheckedChanged(object sender, EventArgs e) |
| 138 | + {//dlctext |
| 139 | + if (checkBox5.Checked) |
| 140 | + { |
| 141 | + button9.Visible = true; |
| 142 | + } |
| 143 | + else |
| 144 | + { |
| 145 | + button9.Visible = false; |
| 146 | + } |
| 147 | + |
| 148 | + } |
| 149 | + |
| 150 | + private void button5_Click(object sender, EventArgs e) |
| 151 | + {//metadata button |
| 152 | + openFileDialog2.Filter = "vehicles.meta|"; |
| 153 | + if (openFileDialog2.ShowDialog() == DialogResult.OK) |
| 154 | + { |
| 155 | + if (openFileDialog2.FileName.Contains("vehicles.meta")) |
| 156 | + { |
| 157 | + metadataPath = openFileDialog2.FileName; |
| 158 | + button5.Enabled = false; |
| 159 | + checkBox1.Enabled = false; |
| 160 | + isUsingMeta = true; |
| 161 | + } |
| 162 | + } |
| 163 | + |
| 164 | + } |
| 165 | + |
| 166 | + private void button6_Click(object sender, EventArgs e) |
| 167 | + { |
| 168 | + openFileDialog3.Filter = "carcols.meta|"; |
| 169 | + if (openFileDialog3.ShowDialog() == DialogResult.OK) |
| 170 | + { |
| 171 | + if (openFileDialog3.FileName.Contains("carcols.meta")) |
| 172 | + { |
| 173 | + carcolsPath = openFileDialog3.FileName; |
| 174 | + button6.Enabled = false; |
| 175 | + checkBox2.Enabled = false; |
| 176 | + isUsingCarcols = true; |
| 177 | + } |
| 178 | + } |
| 179 | + } |
| 180 | + |
| 181 | + private void button7_Click(object sender, EventArgs e) |
| 182 | + { |
| 183 | + openFileDialog4.Filter = "carvariations.meta|"; |
| 184 | + if (openFileDialog4.ShowDialog() == DialogResult.OK) |
| 185 | + { |
| 186 | + if (openFileDialog4.FileName.Contains("carvariations.meta")) |
| 187 | + { |
| 188 | + carvariationsPath = openFileDialog4.FileName; |
| 189 | + button7.Enabled = false; |
| 190 | + checkBox3.Enabled = false; |
| 191 | + isUsingCarvariations = true; |
| 192 | + } |
| 193 | + } |
| 194 | + } |
| 195 | + |
| 196 | + private void button8_Click(object sender, EventArgs e) |
| 197 | + { |
| 198 | + openFileDialog5.Filter = "handling.meta|"; |
| 199 | + if (openFileDialog5.ShowDialog() == DialogResult.OK) |
| 200 | + { |
| 201 | + if (openFileDialog5.FileName.Contains("handling.meta")) |
| 202 | + { |
| 203 | + handlingPath = openFileDialog5.FileName; |
| 204 | + button8.Enabled = false; |
| 205 | + checkBox4.Enabled = false; |
| 206 | + isUsingHandling = true; |
| 207 | + } |
| 208 | + } |
| 209 | + } |
| 210 | + |
| 211 | + private void button9_Click(object sender, EventArgs e) |
| 212 | + { |
| 213 | + openFileDialog6.Filter = "dlctext.meta|"; |
| 214 | + if (openFileDialog6.ShowDialog() == DialogResult.OK) |
| 215 | + { |
| 216 | + if (openFileDialog6.FileName.Contains("dlctext.meta")) |
| 217 | + { |
| 218 | + dlctextPath = openFileDialog6.FileName; |
| 219 | + button9.Enabled = false; |
| 220 | + checkBox5.Enabled = false; |
| 221 | + isUsingdlctext = true; |
| 222 | + } |
| 223 | + } |
| 224 | + } |
| 225 | + |
| 226 | + private void button4_Click(object sender, EventArgs e) |
| 227 | + { |
| 228 | + if (textBox3.Text.Length > 0 && textBox3.Text.Length < 50) |
| 229 | + { |
| 230 | + try |
| 231 | + { |
| 232 | + if (dir != null) |
| 233 | + { |
| 234 | + DirectoryInfo d = Directory.CreateDirectory(dir + "/" + newModName.ToLower()); |
| 235 | + DirectoryInfo data1 = Directory.CreateDirectory(dir + "/" + d.Name + "/data"); |
| 236 | + DirectoryInfo x64 = Directory.CreateDirectory(dir + "/" + d.Name + "/x64"); |
| 237 | + DirectoryInfo data2 = Directory.CreateDirectory(dir + "/" + d.Name + "/" + x64.Name + "/data"); |
| 238 | + DirectoryInfo lang = Directory.CreateDirectory(dir + "/" + d.Name + "/" + x64.Name + "/" + data2.Name + "/lang"); |
| 239 | + DirectoryInfo vehicles = Directory.CreateDirectory(dir + "/" + d.Name + "/" + x64.Name + "/vehicles.rpf"); |
| 240 | + |
| 241 | + if (texturesDir.Length > 0) |
| 242 | + { |
| 243 | + copyFiles(texturesDir, vehicles.FullName); |
| 244 | + } |
| 245 | + |
| 246 | + if (isUsingMeta) |
| 247 | + { |
| 248 | + inputcontentXml = inputcontentXml.Replace("<!--vehicles<Item>", "<Item>"); |
| 249 | + inputcontentXml = inputcontentXml.Replace("</Item>vehicles-->", "</Item>"); |
| 250 | + inputcontentXml = inputcontentXml.Replace("<!--<Item>dlc_template:/data/vehicles.meta</Item>-->", "<Item>dlc_template:/data/vehicles.meta</Item>"); |
| 251 | + File.Copy(metadataPath, data1.FullName + "\\vehicles.meta"); |
| 252 | + } |
| 253 | + |
| 254 | + |
| 255 | + if (isUsingCarcols) |
| 256 | + { |
| 257 | + inputcontentXml = inputcontentXml.Replace("<!--carcols<Item>", "<Item>"); |
| 258 | + inputcontentXml = inputcontentXml.Replace("</Item>carcols-->", "</Item>"); |
| 259 | + inputcontentXml = inputcontentXml.Replace("<!--<Item>dlc_template:/data/carcols.meta</Item>-->", "<Item>dlc_template:/data/carcols.meta</Item>"); |
| 260 | + File.Copy(carcolsPath, data1.FullName + "\\carcols.meta"); |
| 261 | + } |
| 262 | + |
| 263 | + |
| 264 | + if (isUsingCarvariations) |
| 265 | + { |
| 266 | + inputcontentXml = inputcontentXml.Replace("<!--carvariations<Item>", "<Item>"); |
| 267 | + inputcontentXml = inputcontentXml.Replace("</Item>carvariations-->", "</Item>"); |
| 268 | + inputcontentXml = inputcontentXml.Replace("<!--<Item>dlc_template:/data/carvariations.meta</Item>-->", "<Item>dlc_template:/data/carvariations.meta</Item>"); |
| 269 | + File.Copy(carvariationsPath, data1.FullName + "\\carvariations.meta"); |
| 270 | + } |
| 271 | + |
| 272 | + |
| 273 | + if (isUsingHandling) |
| 274 | + { |
| 275 | + inputcontentXml = inputcontentXml.Replace("<!--handling<Item>", "<Item>"); |
| 276 | + inputcontentXml = inputcontentXml.Replace("</Item>handling-->", "</Item>"); |
| 277 | + inputcontentXml = inputcontentXml.Replace("<!--<Item>dlc_template:/data/handling.meta</Item>-->", "<Item>dlc_template:/data/handling.meta</Item>"); |
| 278 | + File.Copy(handlingPath, data1.FullName + "\\handling.meta"); |
| 279 | + } |
| 280 | + |
| 281 | + |
| 282 | + if (isUsingdlctext) |
| 283 | + { |
| 284 | + inputcontentXml = inputcontentXml.Replace("<!--dlctext<Item>", "<Item>"); |
| 285 | + inputcontentXml = inputcontentXml.Replace("</Item>dlctext-->", "</Item>"); |
| 286 | + inputcontentXml = inputcontentXml.Replace("<!--<Item>dlc_template:/data/dlctext.meta</Item>-->", "<Item>dlc_template:/data/dlctext.meta</Item>"); |
| 287 | + File.Copy(dlctextPath, data1.FullName + "\\dlctext.meta"); |
| 288 | + } |
| 289 | + |
| 290 | + inputcontentXml = inputcontentXml.Replace("dlc_template", "dlc_" + newModName.ToLower()); |
| 291 | + inputcontentXml = inputcontentXml.Replace("TEMPLATE_AUTOGEN", newModName.ToUpper() + "_AUTOGEN"); |
| 292 | + File.WriteAllText(dir + "/" + d.Name + "/content.xml", inputcontentXml, System.Text.Encoding.UTF8); |
| 293 | + |
| 294 | + inputSetup2Xml = inputSetup2Xml.Replace("dlc_template", "dlc_" + newModName.ToLower()); |
| 295 | + inputSetup2Xml = inputSetup2Xml.Replace("template", newModName.ToLower()); |
| 296 | + inputSetup2Xml = inputSetup2Xml.Replace("TEMPLATE_AUTOGEN", newModName.ToUpper() + "_AUTOGEN"); |
| 297 | + File.WriteAllText(dir + "/" + d.Name + "/setup2.xml", inputSetup2Xml, System.Text.Encoding.UTF8); |
| 298 | + |
| 299 | + |
| 300 | + |
| 301 | + |
| 302 | + // GTAUTIL Fuck |
| 303 | + System.Diagnostics.Process.Start(gtaUtilPath, "createarchive --input " + d.FullName.Replace(" / ", "\\") + " --output " + dir.Replace(" / ", "\\") + " --name dlc"); |
| 304 | + |
| 305 | + |
| 306 | + MessageBox.Show(null, "Well done! you can find your files now in the desired folder.", "Such a beast!", MessageBoxButtons.OK); |
| 307 | + } |
| 308 | + } |
| 309 | + catch (NullReferenceException exe) |
| 310 | + { |
| 311 | + MessageBox.Show(null, "There was an error. Reason: \n" + exe.Message, "ERROR"); |
| 312 | + } |
| 313 | + } |
| 314 | + } |
| 315 | + |
| 316 | + private void label2_Click(object sender, EventArgs e) |
| 317 | + { |
| 318 | + |
| 319 | + } |
| 320 | + } |
| 321 | +} |
0 commit comments