Example #1
0
 private void saveCurrentObjTrickData(ObjectTrick ot)
 {
     if (finishedLoading)
     {
         ot.data = getCurrentData(ot.name);
     }
 }
Example #2
0
        private void buildMatBtn(string matName, ObjectTrick mt)
        {
            int    locX = 3, locY = 3;
            string btnName = matName + "_btn";

            if (objTrickListPanel.Controls.Count > 0)
            {
                Button lastMatBtn = (Button)objTrickListPanel.Controls[objTrickListPanel.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.ObjTrickkBtn_Click);

            this.objTrickListPanel.Controls.Add(btn);

            initMatTrickListComboBox(matName);
        }
Example #3
0
        private void newObjTrickBtn_Click(object sender, System.EventArgs e)
        {
            common.UserPrompt uInput = new COH_CostumeUpdater.common.UserPrompt("Object Trick Name", "Please enter New Object Trick Name");

            DialogResult dr = uInput.ShowDialog();

            if (dr == DialogResult.OK && uInput.userInput.Trim().Length > 0)
            {
                string matName = uInput.userInput.Trim().Replace(" ", "_");

                buildObjectTrickProperties();

                ArrayList data = getCurrentData(matName);

                ObjectTrick mt = getNewObjTrick(data, fileName, matName);

                deleteObjTrickBtn.Enabled = true;

                renameObjTrickBtn.Enabled = true;

                dupObjTrickBtn.Enabled = true;

                //saveObjTrickButton.Enabled = true;

                reOrderObjTrickButtons();
            }
        }
Example #4
0
        private void reOrderObjTrickButtons()
        {
            int locX = 3, locY = 3;

            objTrickListPanel.AutoScrollPosition = new Point(0, 0);
            objTrickListPanel.SuspendLayout();

            Button selBtn = (Button)selectdObjTrickBtn;

            deSelectObjTrickBtn(selBtn);

            foreach (object obj in objTrickListPanel.Controls)
            {
                Button      btn = (Button)obj;
                ObjectTrick mt  = (ObjectTrick)btn.Tag;
                if (!mt.deleted)
                {
                    btn.Location = new Point(locX, locY);
                    locX         = btn.Right + 10;
                }
            }

            objTrickListPanel.ResumeLayout(false);

            if (selBtn != null)
            {
                selectObjTrickBtn((Button)selBtn);
            }
        }
Example #5
0
        private void saveObjTrickDataToFileContent(ObjectTrick objectTrick)
        {
            int startInd = objectTrick.startIndex;
            int endInd   = objectTrick.endIndex;

            fileContent.RemoveRange(startInd, objectTrick.data.Count);
            fileContent.InsertRange(startInd, objectTrick.data);
        }
Example #6
0
        private void deleteObjTrickBtn_Click(object sender, System.EventArgs e)
        {
            if (selectdObjTrickBtn != null)
            {
                Button matBtn = (Button)selectdObjTrickBtn;

                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;

                    objListCmboBx.SuspendLayout();

                    objListCmboBx.Items.Remove(matName);

                    objListCmboBx.ResumeLayout(false);

                    ObjectTrick mt = (ObjectTrick)matBtn.Tag;

                    mt.deleted = true;

                    reOrderObjTrickButtons();

                    Button nextMatButton = getFirstVisibleButton(matBtn);

                    if (nextMatButton != null)
                    {
                        selectObjTrickBtn(nextMatButton);
                    }
                    else
                    {
                        selectdObjTrickBtn = null;
                        this.objTrickPropertiesPanel.Controls.Clear();
                        deleteObjTrickBtn.Enabled = false;
                        renameObjTrickBtn.Enabled = false;
                        dupObjTrickBtn.Enabled    = false;
                        objListCmboBx.Text        = "";
                        //saveObjTrickButton.Enabled = false;
                    }
                }
            }
        }
Example #7
0
 private void commentDeletedObjTrick()
 {
     foreach (object obj in objTricksList)
     {
         ObjectTrick mt = (ObjectTrick)obj;
         if (mt.deleted)
         {
             for (int i = 0; i < mt.data.Count; i++)
             {
                 mt.data[i] = string.Format("//{0}", (string)mt.data[i]);
             }
         }
     }
 }
Example #8
0
        private void dupObjTrickBtn_Click(object sender, System.EventArgs e)
        {
            if (selectdObjTrickBtn != null)
            {
                Button matBtn = (Button)selectdObjTrickBtn;

                string matName = matBtn.Text;

                ObjectTrick mt = (ObjectTrick)matBtn.Tag;

                ObjectTrick newMat = getNewObjTrick(mt.data, mt.fileName, mt.name + "_COPY");

                renameObjTrickBtn_Click(selectdObjTrickBtn, new EventArgs());

                reOrderObjTrickButtons();
            }
        }
Example #9
0
        private int removeOtrick(string s, ref ArrayList oTrick)
        {
            int i = 0;

            while (i < oTrick.Count)
            {
                objectTrick.ObjectTrick ot = (objectTrick.ObjectTrick)oTrick[i];

                if (ot.name.Trim().ToLower().Equals(s.Trim().ToLower()))
                {
                    oTrick.Remove(ot);
                    return(1);
                }
                i++;
            }
            return(0);
        }
Example #10
0
        private void renameObjTrick(ref Button oTrickBtn, string newName)
        {
            string matName = oTrickBtn.Text;

            ObjectTrick mt = (ObjectTrick)oTrickBtn.Tag;

            mt.name = newName;

            oTrickBtn.Text = newName;

            oTrickBtn.Name = newName + "_btn";

            objListCmboBx.SuspendLayout();

            objListCmboBx.Items[objListCmboBx.Items.IndexOf(matName)] = newName;

            objListCmboBx.ResumeLayout(false);
        }
Example #11
0
        private void setMatProperties(Button matTrickBtn)
        {
            finishedLoading = false;

            this.SuspendLayout();

            ObjectTrick mt = (ObjectTrick)matTrickBtn.Tag;

            ArrayList data = (ArrayList)mt.data;

            ObjectTrickPanel otPnl = (ObjectTrickPanel)this.objTrickPropertiesPanel.Controls[0];

            otPnl.setData(data);

            this.ResumeLayout(false);

            finishedLoading = true;
        }
Example #12
0
        private ObjectTrick getNewObjTrick(ArrayList data, string fileName, string oTrickName)
        {
            int mCount = objTricksList.Count;

            int startIndex = mCount > 0 ? ((ObjectTrick)objTricksList[mCount - 1]).endIndex + 5000 : 5000;

            int endIndex = startIndex + data.Count;

            ObjectTrick mt = new ObjectTrick(startIndex, endIndex, data, fileName, oTrickName);

            objTricksList.Add(mt);

            buildMatBtn(mt.name, mt);

            reOrderObjTrickButtons();

            objListCmboBx.SelectedItem = objListCmboBx.Items[objListCmboBx.Items.Count - 1];

            matListCmboBx_SelectionChangeCommitted(objListCmboBx, new EventArgs());

            return(mt);
        }
Example #13
0
        public static ArrayList parse(string fileName, ref ArrayList fileContent)
        {
            ArrayList objectTricks = new ArrayList();

            ObjectTrick ot;
            ArrayList   objTrickData = null;

            int    objTrickStartIndex = -1, objTrickEndIndex = -1;
            string objTrickName = "";

            bool isObjTrick     = false;
            bool createObjTrick = false;
            int  endCount       = 0;
            int  maxEndCount    = 0;
            int  i = 0;

            foreach (object obj in fileContent)
            {
                System.Windows.Forms.Application.DoEvents();

                string line = (string)obj;

                line = common.COH_IO.removeExtraSpaceBetweenWords(((string)obj).Replace("\t", " ")).Trim();

                if (line.ToLower().StartsWith("Trick ".ToLower()))
                {
                    objTrickName       = line.Replace("//", "#").Replace("Trick ", "").Replace("trick ", "").Split('#')[0];
                    objTrickStartIndex = i;
                    isObjTrick         = true;
                    createObjTrick     = false;
                    objTrickData       = new ArrayList();
                }
                if (isObjTrick)
                {
                    string dataObj = (string)obj;

                    if (dataObj.ToLower().Contains("Texture_Name".ToLower()))
                    {
                        dataObj = common.COH_IO.fixInnerCamelCase((string)obj, "Texture_Name").Replace("Texture_Name.tga", "none").Replace("Texture_Name", "none");
                    }

                    objTrickData.Add(dataObj);

                    if (line.ToLower().StartsWith("Autolod".ToLower()))
                    {
                        maxEndCount += 1;
                    }

                    if (line.ToLower().StartsWith("End".ToLower()))
                    {
                        endCount++;
                    }

                    if (endCount > maxEndCount || i == (fileContent.Count - 1))
                    {
                        isObjTrick       = false;
                        objTrickEndIndex = i;
                        createObjTrick   = true;
                    }
                    if (createObjTrick)
                    {
                        ot = new ObjectTrick(objTrickStartIndex,
                                             objTrickEndIndex, objTrickData, fileName, objTrickName);

                        objectTricks.Add(ot);
                        endCount    = 0;
                        maxEndCount = 0;
                    }
                }
                i++;
            }

            return(objectTricks);
        }
Example #14
0
        public ObjectBlockForm(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;

            selectdObjTrickBtn = null;

            rTextBox = rtBx;

            updateObjectTrickListComboBx = true;

            fileName = file_name;

            System.Windows.Forms.Application.DoEvents();

            InitializeComponent();

            System.Windows.Forms.Application.DoEvents();

            objListCmboBx.Items.Clear();

            fileContent = (ArrayList)file_content.Clone();

            tgaFilesDictionary = tga_files_dictionary;

            if (objTricksList != null)

            {
                objTricksList.Clear();
            }

            System.Windows.Forms.Application.DoEvents();

            objTricksList = ObjectTrickParser.parse(file_name, ref fileContent);

            foreach (object obj in objTricksList)
            {
                System.Windows.Forms.Application.DoEvents();
                ObjectTrick ot = (ObjectTrick)obj;
                if (!ot.deleted)
                {
                    buildMatBtn(ot.name, ot);
                }
            }

            if (objListCmboBx.Items.Count > 0)
            {
                System.Windows.Forms.Application.DoEvents();

                buildObjectTrickProperties();

                objListCmboBx.SelectedItem = objListCmboBx.Items[0];

                matListCmboBx_SelectionChangeCommitted(objListCmboBx, new EventArgs());
            }
            else
            {
                string fName = System.IO.Path.GetFileName(fileName);

                string warning = string.Format("\"{0}\" is not an Object Trick File.\r\nIt dose not contain (Trick ...End) block.\r\n", fName);

                //MessageBox.Show(warning);

                rTextBox.SelectionColor = Color.Red;

                rTextBox.SelectedText += warning;

                dupObjTrickBtn.Enabled = false;

                deleteObjTrickBtn.Enabled = false;

                renameObjTrickBtn.Enabled = false;
            }

            System.Windows.Forms.Application.DoEvents();

            wia.Close();

            wia.Dispose();

            this.Cursor = Cursors.Arrow;
        }
Example #15
0
        private void saveCurrentMatData(Button btn)
        {
            ObjectTrick ot = (ObjectTrick)btn.Tag;

            saveCurrentObjTrickData(ot);
        }
Example #16
0
        private void saveObjTrickDataToFileContent(Button oTrickBtn)
        {
            ObjectTrick ObjectTrick = (ObjectTrick)oTrickBtn.Tag;

            saveObjTrickDataToFileContent(ObjectTrick);
        }
Example #17
0
        private void saveObjTrickButton_Click(object sender, System.EventArgs e)
        {
            if (finishedLoading)
            {
                commentDeletedObjTrick();

                if (selectdObjTrickBtn != null)
                {
                    saveCurrentMatData((Button)selectdObjTrickBtn);
                }

                ArrayList newFileContent = new ArrayList();

                ObjectTrick mtMA = (ObjectTrick)objTricksList[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 ObjectTrick after copied file content
                newFileContent.AddRange(mtMA.data);

                //go through and merge file content not in matTricl
                for (int i = 1; i < objTricksList.Count; i++)
                {
                    ObjectTrick mtM1 = (ObjectTrick)objTricksList[i - 1];

                    ObjectTrick mtM2 = (ObjectTrick)objTricksList[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!");
            }
        }