Exemplo n.º 1
0
 private void saveCurrentTextureTrickData(TextureTrick ot)
 {
     if (finishedLoading)
     {
         ot.data = getCurrentData(ot.name);
     }
 }
Exemplo n.º 2
0
        private void buildTextureTrickBtn(string ttName, TextureTrick tt)
        {
            int    locX = 3, locY = 3;
            string btnName = ttName + "_btn";

            if (textureTrickListPanel.Controls.Count > 0)
            {
                Button lastMatBtn = (Button)textureTrickListPanel.Controls[textureTrickListPanel.Controls.Count - 1];
                locX = lastMatBtn.Right + 10;
            }

            Button btn = new Button();

            btn.Tag   = tt;
            btn.Image = global::COH_CostumeUpdater.Properties.Resources.AE_UI_MaterialTrick;
            if (ttName.Contains("/"))
            {
                btn.Image = global::COH_CostumeUpdater.Properties.Resources.OPENFOLD;
            }
            btn.Location   = new System.Drawing.Point(locX, locY);
            btn.Name       = btnName;
            btn.Size       = new System.Drawing.Size(75, 75);
            btn.TabIndex   = 0;
            btn.Text       = ttName;
            btn.ImageAlign = System.Drawing.ContentAlignment.TopCenter;
            btn.TextAlign  = System.Drawing.ContentAlignment.BottomCenter;
            btn.UseVisualStyleBackColor = true;
            btn.Click += new System.EventHandler(this.textureTrickkBtn_Click);

            this.textureTrickListPanel.Controls.Add(btn);

            initTextureTrickListComboBox(ttName);
        }
Exemplo n.º 3
0
        private void reOrderTextureTrickButtons()
        {
            int locX = 3, locY = 3;

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

            Button selBtn = (Button)selectdTextureTrickBtn;

            deSelectTextureTrickBtn(selBtn);

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

            textureTrickListPanel.ResumeLayout(false);

            if (selBtn != null)
            {
                selectTextureTrickBtn((Button)selBtn);
            }
        }
Exemplo n.º 4
0
        private void saveTextureTrickDataToFileContent(TextureTrick textureTrick)
        {
            int startInd = textureTrick.startIndex;
            int endInd   = textureTrick.endIndex;

            fileContent.RemoveRange(startInd, textureTrick.data.Count);
            fileContent.InsertRange(startInd, textureTrick.data);
        }
Exemplo n.º 5
0
        private void duplicateTextureTrick(ArrayList data)
        {
            TextureTrickPanel ttPnl = null;

            if (textureTrickPropertiesPanel.Controls.Count > 0)
            {
                ttPnl = (TextureTrickPanel)textureTrickPropertiesPanel.Controls[0];
            }
            else
            {
                //buildTextureTrickProperties();
                buildTextureTrickSec();
                ttPnl = (TextureTrickPanel)textureTrickPropertiesPanel.Controls[0];
            }

            string tgaPath = ttPnl.getTextureTrickTgaPath();

            if (tgaPath.Length > 1)
            {
                openFileDialog1.InitialDirectory = System.IO.Path.GetDirectoryName(tgaPath);
                openFileDialog1.FileName         = System.IO.Path.GetFileName(tgaPath);
            }

            DialogResult dr = openFileDialog1.ShowDialog();

            if (dr == DialogResult.OK)
            {
                string ttName = System.IO.Path.GetFileName(openFileDialog1.FileName);

                ArrayList newData = new ArrayList();

                newData.Add("Texture " + ttName);

                if (data != null)
                {
                    for (int i = 1; i < data.Count; i++)
                    {
                        newData.Add(data[i]);
                    }
                }
                else
                {
                    newData.Add("End");
                }

                TextureTrick newTT = getNewTextureTrick(newData, fileName, ttName);

                reOrderTextureTrickButtons();

                this.textureTrickPropertiesPanel.SuspendLayout();

                ttPnl.setData(newTT.data);

                this.textureTrickPropertiesPanel.ResumeLayout();
            }
        }
Exemplo n.º 6
0
        private void dupTextureTrickBtn_Click(object sender, System.EventArgs e)
        {
            if (selectdTextureTrickBtn != null)
            {
                Button ttBtn = (Button)selectdTextureTrickBtn;

                TextureTrick tt = (TextureTrick)ttBtn.Tag;

                duplicateTextureTrick(tt.data);
            }
        }
Exemplo n.º 7
0
        private void deleteTextureTrickBtn_Click(object sender, System.EventArgs e)
        {
            if (selectdTextureTrickBtn != null)
            {
                Button ttBtn = (Button)selectdTextureTrickBtn;

                string ttName = ttBtn.Text;

                string deleteWarning = string.Format("Are your sure you want to delete \"{0}\"?", ttName);

                DialogResult dr = MessageBox.Show(deleteWarning, "Warning...",
                                                  MessageBoxButtons.YesNo,
                                                  MessageBoxIcon.Warning,
                                                  MessageBoxDefaultButton.Button2);

                if (dr == DialogResult.Yes)
                {
                    ttBtn.Visible = false;

                    textureListCmboBx.SuspendLayout();

                    textureListCmboBx.Items.Remove(ttName);

                    textureListCmboBx.ResumeLayout(false);

                    TextureTrick mt = (TextureTrick)ttBtn.Tag;

                    mt.deleted = true;

                    reOrderTextureTrickButtons();

                    Button nextTextureButton = getFirstVisibleButton(ttBtn);

                    if (nextTextureButton != null)
                    {
                        selectTextureTrickBtn(nextTextureButton);
                    }
                    else
                    {
                        selectdTextureTrickBtn = null;
                        this.textureTrickPropertiesPanel.Controls.Clear();
                        deleteTextureTrickBtn.Enabled = false;
                        renameTextureTrickBtn.Enabled = false;
                        dupTextureTrickBtn.Enabled    = false;
                        textureListCmboBx.Text        = "";
                        //saveTextureTrickButton.Enabled = false;
                    }
                }
            }
        }
Exemplo n.º 8
0
 private void commentDeletedTextureTrick()
 {
     foreach (object obj in textureTricksList)
     {
         TextureTrick tt = (TextureTrick)obj;
         if (tt.deleted)
         {
             for (int i = 0; i < tt.data.Count; i++)
             {
                 tt.data[i] = string.Format("//{0}", (string)tt.data[i]);
             }
         }
     }
 }
Exemplo n.º 9
0
        private int removeTTrick(string s, ref ArrayList tTrick)
        {
            int i = 0;

            while (i < tTrick.Count)
            {
                textureTrick.TextureTrick tt = (textureTrick.TextureTrick)tTrick[i];

                if (tt.name.Trim().ToLower().Equals(s.Trim().ToLower()))
                {
                    tTrick.Remove(tt);
                    return(1);
                }
                i++;
            }
            return(0);
        }
Exemplo n.º 10
0
        private void renameTextureTrick(ref Button tTrickBtn, string newName)
        {
            string ttName = tTrickBtn.Text;

            TextureTrick tt = (TextureTrick)tTrickBtn.Tag;

            tt.name = newName;

            tTrickBtn.Text = newName;

            tTrickBtn.Name = newName + "_btn";

            textureListCmboBx.SuspendLayout();

            textureListCmboBx.Items[textureListCmboBx.Items.IndexOf(ttName)] = newName;

            textureListCmboBx.ResumeLayout(false);
        }
Exemplo n.º 11
0
        private void setTextureTrickProperties(Button matTrickBtn)
        {
            finishedLoading = false;

            this.SuspendLayout();

            TextureTrick mt = (TextureTrick)matTrickBtn.Tag;

            ArrayList data = (ArrayList)mt.data;

            TextureTrickPanel ttPnl = (TextureTrickPanel)this.textureTrickPropertiesPanel.Controls[0];

            ttPnl.setData(data);

            this.ResumeLayout();

            finishedLoading = true;
        }
Exemplo n.º 12
0
        private TextureTrick getNewTextureTrick(ArrayList data, string fileName, string tTrickName)
        {
            int mCount = textureTricksList.Count;

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

            int endIndex = startIndex + data.Count;

            TextureTrick tt = new TextureTrick(startIndex, endIndex, data, fileName, tTrickName);

            textureTricksList.Add(tt);

            buildTextureTrickBtn(tt.name, tt);

            reOrderTextureTrickButtons();

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

            tTrickListCmboBx_SelectionChangeCommitted(textureListCmboBx, new EventArgs());

            return(tt);
        }
Exemplo n.º 13
0
        public static ArrayList parse(string fileName, ref ArrayList fileContent)
        {
            ArrayList textureTricks = new ArrayList();

            TextureTrick tt;
            ArrayList    textureTrickData = null;

            int    textureTrickStartIndex = -1, textureTrickEndIndex = -1;
            string textureTrickName = "";

            bool isTextureTrick     = false;
            bool createTextureTrick = 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("Texture ".ToLower()) && !MatParser.isMatTrick(fileContent, i))
                //!line.ToLower().StartsWith("Texture X_".ToLower()))
                {
                    textureTrickName       = line.Replace("//", "#").Replace("Texture ", "").Replace("texture ", "").Split('#')[0].Replace(".tga", "").Replace(".TGA", "").Replace(".Txt", "").Replace(".txt", "");
                    textureTrickStartIndex = i;
                    isTextureTrick         = true;
                    createTextureTrick     = false;
                    textureTrickData       = new ArrayList();
                }
                if (isTextureTrick)
                {
                    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");
                    }

                    textureTrickData.Add(dataObj);

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

                    if (endCount > maxEndCount || i == (fileContent.Count - 1))
                    {
                        isTextureTrick       = false;
                        textureTrickEndIndex = i;
                        createTextureTrick   = true;
                    }
                    if (createTextureTrick)
                    {
                        tt = new TextureTrick(textureTrickStartIndex,
                                              textureTrickEndIndex, textureTrickData, fileName, textureTrickName);

                        textureTricks.Add(tt);
                        endCount    = 0;
                        maxEndCount = 0;
                    }
                }
                i++;
            }

            return(textureTricks);
        }
Exemplo n.º 14
0
        public TextureBlockForm(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;

            selectdTextureTrickBtn = null;

            rTextBox = rtBx;

            updateTextureTrickListComboBx = true;

            fileName = file_name;

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

            InitializeComponent();

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

            textureListCmboBx.Items.Clear();

            fileContent = (ArrayList)file_content.Clone();

            tgaFilesDictionary = tga_files_dictionary;

            if (textureTricksList != null)

            {
                textureTricksList.Clear();
            }

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

            textureTricksList = TextureTrickParser.parse(file_name, ref fileContent);


            foreach (object obj in textureTricksList)
            {
                System.Windows.Forms.Application.DoEvents();
                TextureTrick tt = (TextureTrick)obj;
                if (!tt.deleted)
                {
                    buildTextureTrickBtn(tt.name, tt);
                }
            }

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

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

                buildTextureTrickProperties();

                textureListCmboBx.SelectedItem = textureListCmboBx.Items[0];

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

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

                //MessageBox.Show(warning);

                rTextBox.SelectionColor = Color.Red;

                rTextBox.SelectedText += warning;

                dupTextureTrickBtn.Enabled = false;

                deleteTextureTrickBtn.Enabled = false;

                renameTextureTrickBtn.Enabled = false;
            }

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

            wia.Close();

            wia.Dispose();

            renameTextureTrickBtn.Enabled = false;

            this.Cursor = Cursors.Arrow;
        }
Exemplo n.º 15
0
        private void saveCurrentMatData(Button btn)
        {
            TextureTrick tt = (TextureTrick)btn.Tag;

            saveCurrentTextureTrickData(tt);
        }
Exemplo n.º 16
0
        private void saveTextureTrickDataToFileContent(Button oTrickBtn)
        {
            TextureTrick TextureTrick = (TextureTrick)oTrickBtn.Tag;

            saveTextureTrickDataToFileContent(TextureTrick);
        }
Exemplo n.º 17
0
        private void saveObjTrickButton_Click(object sender, System.EventArgs e)
        {
            if (finishedLoading)
            {
                commentDeletedTextureTrick();

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

                ArrayList newFileContent = new ArrayList();

                TextureTrick ttMA = (TextureTrick)textureTricksList[0];

                int sIndM1 = ttMA.startIndex;

                //copy original file content before first edited textureTrick
                for (int j = 0; j < sIndM1; j++)
                {
                    newFileContent.Add(fileContent[j]);
                }

                //insert first edited textureTrick after copied file content
                newFileContent.AddRange(ttMA.data);

                //go through and merge file content not in textureTrick
                for (int i = 1; i < textureTricksList.Count; i++)
                {
                    TextureTrick ttM1 = (TextureTrick)textureTricksList[i - 1];

                    TextureTrick ttM2 = (TextureTrick)textureTricksList[i];

                    int eIndM1 = ttM1.endIndex;

                    int sIndM2 = ttM2.startIndex;

                    for (int j = eIndM1 + 1; j < sIndM2 && j < fileContent.Count; j++)
                    {
                        newFileContent.Add(fileContent[j]);
                    }
                    if (sIndM2 >= fileContent.Count)
                    {
                        newFileContent.Add("");
                    }
                    newFileContent.AddRange(ttM2.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!");
            }
        }