private void reOrderMatButtons() { int locX = 3, locY = 3; matTrickListPanel.AutoScrollPosition = new Point(0, 0); matTrickListPanel.SuspendLayout(); Button selBtn = (Button)selectdMatBtn; deSelectMatBtn(selBtn); foreach (object obj in matTrickListPanel.Controls) { Button btn = (Button)obj; MatTrick mt = (MatTrick)btn.Tag; if (!mt.deleted) { btn.Location = new Point(locX, locY); locX = btn.Right + 10; } } matTrickListPanel.ResumeLayout(false); if (selBtn != null) { selectMatBtn((Button)selBtn); } }
private void saveCurrentMatData(MatTrick mat) { if (finishedLoading) { mat.data = getCurrentData(mat.name); } }
private void buildMatBtn(string matName, MatTrick mt) { int locX = 3, locY = 3; string btnName = matName + "_btn"; if (matTrickListPanel.Controls.Count > 0) { Button lastMatBtn = (Button)matTrickListPanel.Controls[matTrickListPanel.Controls.Count - 1]; locX = lastMatBtn.Right + 10; } Button btn = new Button(); btn.Tag = mt; btn.Image = global::COH_CostumeUpdater.Properties.Resources.AE_UI_MaterialTrick; btn.Location = new System.Drawing.Point(locX, locY); btn.Name = btnName; btn.Size = new System.Drawing.Size(75, 75); btn.TabIndex = 0; btn.Text = matName; btn.ImageAlign = System.Drawing.ContentAlignment.TopCenter; btn.TextAlign = System.Drawing.ContentAlignment.BottomCenter; btn.UseVisualStyleBackColor = true; btn.Click += new System.EventHandler(this.matTrickBtn_Click); this.matTrickListPanel.Controls.Add(btn); initMatTrickListComboBox(matName); }
private void deleteMatBtn_Click(object sender, System.EventArgs e) { if (selectdMatBtn != null) { Button matBtn = (Button)selectdMatBtn; string matName = matBtn.Text; string deleteWarning = string.Format("Are your sure you want to delete \"{0}\"?", matName); DialogResult dr = MessageBox.Show(deleteWarning, "Warning...", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); if (dr == DialogResult.Yes) { matBtn.Visible = false; matListCmboBx.SuspendLayout(); matListCmboBx.Items.Remove(matName); matListCmboBx.ResumeLayout(false); MatTrick mt = (MatTrick)matBtn.Tag; mt.deleted = true; reOrderMatButtons(); Button nextMatButton = getFirstVisibleButton(matBtn); if (nextMatButton != null) { selectMatBtn(nextMatButton); } else { selectdMatBtn = null; this.matTrickPropertiesPanel.Controls.Clear(); deleteMatBtn.Enabled = false; renameMatBtn.Enabled = false; dupMatBtn.Enabled = false; matListCmboBx.Text = ""; //saveMatButton.Enabled = false; } } } }
/* * private void saveMatDataToFileContent(Button matBtn) * { * materialTrick.MatTrick matTrick = (materialTrick.MatTrick)matBtn.Tag; * saveMatDataToFileContent(matTrick); * } * * private void saveMatDataToFileContent(MatTrick matTrick) * { * int startInd = matTrick.startIndex; * int endInd = matTrick.endIndex; * * fileContent.RemoveRange(startInd, matTrick.data.Count); * fileContent.InsertRange(startInd, matTrick.data); * } */ private void commentDeletedMat() { foreach (object obj in matTricksList) { MatTrick mt = (MatTrick)obj; if (mt.deleted) { for (int i = 0; i < mt.data.Count; i++) { mt.data[i] = string.Format("//{0}", (string)mt.data[i]); } } } }
private void dupMatBtn_Click(object sender, System.EventArgs e) { if (selectdMatBtn != null) { Button matBtn = (Button)selectdMatBtn; string matName = matBtn.Text; MatTrick mt = (MatTrick)matBtn.Tag; MatTrick newMat = getNewMatTrick(mt.data, mt.fileName, mt.name + "_COPY"); renameMatBtn_Click(selectdMatBtn, new EventArgs()); this.reOrderMatButtons(); } }
private void renameMat(ref Button matBtn, string newName) { string matName = matBtn.Text; MatTrick mt = (MatTrick)matBtn.Tag; mt.name = newName; matBtn.Text = newName; matBtn.Name = newName + "_btn"; matListCmboBx.SuspendLayout(); matListCmboBx.Items[matListCmboBx.Items.IndexOf(matName)] = newName; matListCmboBx.ResumeLayout(false); }
private void newMatBtn_Click(object sender, System.EventArgs e) { if (this.matTrickPropertiesPanel.Controls.Count > 0) { this.matTrickPropertiesPanel.ScrollControlIntoView(this.matTrickPropertiesPanel.Controls[0]); } common.UserPrompt uInput = new COH_CostumeUpdater.common.UserPrompt("Material Name", "Please enter New Material Name"); DialogResult dr = uInput.ShowDialog(); if (dr == DialogResult.OK && uInput.userInput.Trim().Length > 0) { if (tgaFilesDictionary == null) { tgaFilesDictionary = common.COH_IO.getFilesDictionary(getRoot() + @"src\Texture_Library", "*.tga"); } string matName = uInput.userInput.Trim().Replace(" ", "_"); if (!matName.ToLower().StartsWith("X_".ToLower())) { matName = "X_" + matName; } buildMatProperties(); ArrayList data = getCurrentData(matName); MatTrick mt = getNewMatTrick(data, fileName, matName); deleteMatBtn.Enabled = true; renameMatBtn.Enabled = true; dupMatBtn.Enabled = true; //saveMatButton.Enabled = true; reOrderMatButtons(); } }
private MatTrick getNewMatTrick(ArrayList data, string fileName, string matName) { int mCount = matTricksList.Count; int startIndex = mCount > 0 ? ((MatTrick)matTricksList[mCount - 1]).endIndex + 5000 : 5000; int endIndex = startIndex + data.Count; MatTrick mt = new MatTrick(startIndex, endIndex, data, fileName, matName); matTricksList.Add(mt); buildMatBtn(mt.name, mt); reOrderMatButtons(); matListCmboBx.SelectedItem = matListCmboBx.Items[matListCmboBx.Items.Count - 1]; matListCmboBx_SelectionChangeCommitted(matListCmboBx, new EventArgs()); return(mt); }
private int removeMat(string s, ref ArrayList mats) { int i = 0; while (i < mats.Count) { materialTrick.MatTrick mt = (materialTrick.MatTrick)mats[i]; string nameCompare = mt.name.Trim().ToLower(); if (!mt.name.ToLower().StartsWith("x_")) { nameCompare = System.IO.Path.GetFileNameWithoutExtension(mt.name.Trim().ToLower()); } if (nameCompare.Equals(s.Trim().ToLower())) { mats.Remove(mt); return(1); } i++; } return(0); }
private void saveMatButton_Click(object sender, System.EventArgs e) { if (finishedLoading) { commentDeletedMat(); if (selectdMatBtn != null) { saveCurrentMatData((Button)selectdMatBtn); } ArrayList newFileContent = new ArrayList(); MatTrick mtMA = (MatTrick)matTricksList[0]; int sIndM1 = mtMA.startIndex; //copy original file content before first edited matTrick for (int j = 0; j < sIndM1; j++) { newFileContent.Add(fileContent[j]); } //insert first edited matTrick after copied file content newFileContent.AddRange(mtMA.data); //go through and merge file content not in matTricl for (int i = 1; i < matTricksList.Count; i++) { MatTrick mtM1 = (MatTrick)matTricksList[i - 1]; MatTrick mtM2 = (MatTrick)matTricksList[i]; int eIndM1 = mtM1.endIndex; int sIndM2 = mtM2.startIndex; for (int j = eIndM1 + 1; j < sIndM2 && j < fileContent.Count; j++) { newFileContent.Add(fileContent[j]); } if (sIndM2 >= fileContent.Count) { newFileContent.Add(""); } newFileContent.AddRange(mtM2.data); } string results = assetsMangement.CohAssetMang.checkout(fileName); if (results.Contains("can't edit exclusive file")) { MessageBox.Show(results); rTextBox.SelectionColor = Color.Red; rTextBox.SelectedText += results; } else { common.COH_IO.writeDistFile(newFileContent, fileName); } rTextBox.Text += results; } else { MessageBox.Show("Still loading Mat Setting. Can't save!"); } }
public matBlockForm(string file_name, ref RichTextBox rtBx, ref ArrayList file_content, System.Collections.Generic.Dictionary <string, string> tga_files_dictionary) { finishedLoading = true; common.WatingIconAnim wia = new COH_CostumeUpdater.common.WatingIconAnim(); wia.Show(); Application.DoEvents(); this.Cursor = Cursors.WaitCursor; selectdMatBtn = null; rTextBox = rtBx; bumpMap2Indx = -1; updateMatListComboBx = true; fileName = file_name; System.Windows.Forms.Application.DoEvents(); InitializeComponent(); System.Windows.Forms.Application.DoEvents(); matListCmboBx.Items.Clear(); fileContent = (ArrayList)file_content.Clone(); tgaFilesDictionary = tga_files_dictionary; if (matTricksList != null) { matTricksList.Clear(); } System.Windows.Forms.Application.DoEvents(); matTricksList = MatParser.parse(file_name, ref fileContent); foreach (object obj in matTricksList) { System.Windows.Forms.Application.DoEvents(); MatTrick mt = (MatTrick)obj; if (!mt.deleted) { buildMatBtn(mt.name, mt); } } if (matListCmboBx.Items.Count > 0) { System.Windows.Forms.Application.DoEvents(); System.Windows.Forms.Application.DoEvents(); buildMatProperties(); matListCmboBx.SelectedItem = matListCmboBx.Items[0]; matListCmboBx_SelectionChangeCommitted(matListCmboBx, new EventArgs()); } else { string fName = System.IO.Path.GetFileName(fileName); string warning = string.Format("\"{0}\" is not a Material Trick File.\r\nIt dose not contain (Texture X_...End) block.\r\n", fName); //MessageBox.Show(warning); rTextBox.SelectionColor = Color.Red; rTextBox.SelectedText += warning; dupMatBtn.Enabled = false; deleteMatBtn.Enabled = false; renameMatBtn.Enabled = false; } System.Windows.Forms.Application.DoEvents(); wia.Close(); wia.Dispose(); this.Cursor = Cursors.Arrow; }
private void setMatProperties(Button matTrickBtn) { finishedLoading = false; //Addison Delany requested to set multiply 1 defaulr to "c:\game\src\_texture_library\World\Filler\white.tga" // and to if fallback base and bump is empty fill them automatically with base1 and bump1 values without activating fall back checkbox this.SuspendLayout(); matTrickPropertiesPanel.SuspendLayout(); MatTrick mt = (MatTrick)matTrickBtn.Tag; ArrayList data = (ArrayList)mt.data; string base1Texture = ""; string bump1Texture = ""; string tPath = ""; string name = ""; bool isFallb = false; string multiply1DefaultPath = getRoot() + @"src\_texture_library\World\Filler\white.tga"; string [] tgafileNames = tgaFilesDictionary.Values.ToArray(); string [] tgafilePaths = tgaFilesDictionary.Keys.ToArray(); foreach (object obj in this.mats) { switch (obj.GetType().ToString()) { case "COH_CostumeUpdater.assetEditor.aeCommon.MatBlock": aeCommon.MatBlock mb = ((aeCommon.MatBlock)obj); isFallb = mb.isFallBack; mb.setData(ref data, tgafilePaths, tgafileNames); tPath = mb.getTexturePath(); name = mb.getName(); if (name.ToLower().Equals("base1")) { base1Texture = tPath; } else if (name.ToLower().Equals("bumpmap1")) { bump1Texture = tPath; } else if (name.ToLower().Equals("multiply1") && !(tPath.Length > 0)) { mb.setTexturePath(multiply1DefaultPath); } else if (name.ToLower().Equals("base") && isFallb && !(tPath.Length > 0)) { mb.setTexturePath(base1Texture); } else if (name.ToLower().Equals("bumpmap") && isFallb && !(tPath.Length > 0)) { mb.setTexturePath(bump1Texture); } break; case "COH_CostumeUpdater.assetEditor.aeCommon.MatSpecLitCubeMapTintFlags": ((aeCommon.MatSpecLitCubeMapTintFlags)obj).setData(data, tgafilePaths, tgafileNames); break; case "COH_CostumeUpdater.assetEditor.materialTrick.FB_GlobalOptionsPnl": ((FB_GlobalOptionsPnl)obj).setData(data, tgaFilesDictionary); break; } } string k = base1Texture; string m = bump1Texture; setUseFallbackCkBx(data); if (this.matTrickPropertiesPanel.Controls.Count > 0) { this.matTrickPropertiesPanel.ScrollControlIntoView(this.matTrickPropertiesPanel.Controls[0]); } matTrickPropertiesPanel.ResumeLayout(false); this.ResumeLayout(false); finishedLoading = true; }