Esempio n. 1
0
        private void updatePart()
        {
            ArrayList data = getData();

            Partical part = ParticalParser.parse(fileName, ref data);

            foreach (KeyValuePair <string, object> kvp in part.pParameters)
            {
                this.Tag.pParameters[kvp.Key] = kvp.Value;
            }
        }
        private string getComboBoxSelectedItemFilePath()
        {
            string fileName = null;

            int pOrB_index = eventsBhvrFilesMComboBx.SelectedIndex;

            int eIndex = eventsComboBx.SelectedIndex;

            if (eIndex > -1 &&
                eventsComboBx.Tag != null &&
                eIndex < ((ArrayList)eventsComboBx.Tag).Count)
            {
                Event ev = (Event)((ArrayList)eventsComboBx.Tag)[eIndex];

                if (ownerName.Equals("Behavior"))
                {
                    Behavior bhvr = (Behavior)ev.eBhvrsObject[pOrB_index];
                    if (bhvr != null)
                    {
                        fileName = bhvr.fileName;
                    }
                }
                else
                {
                    Partical part = (Partical)ev.epartsObject[pOrB_index];
                    if (part != null)
                    {
                        fileName = part.fileName;
                    }
                }
            }
            else
            {
                if (ownerName.Equals("Behavior"))
                {
                    Behavior bhvr = (Behavior)bhvrStandAloneFile[pOrB_index];
                    if (bhvr != null)
                    {
                        fileName = bhvr.fileName;
                    }
                }
                else
                {
                    Partical part = (Partical)partStandAloneFile[pOrB_index];
                    if (part != null)
                    {
                        fileName = part.fileName;
                    }
                }
            }
            return(fileName);
        }
Esempio n. 3
0
        private void initPartWin(string root_path, ref Dictionary <string, string> tgaDic, ImageList imgList)
        {
            rootPath = root_path;

            isLocked = true;

            isDirty = false;

            partPanels = new ArrayList();

            InitializeComponent();

            Tag = null;

            bpcfPanel = new BhvrNPartCommonFunctionPanel(this, "Part", imgList);

            bpcfPanel.PartOrBhvrComboBoxChanged -= new EventHandler(bpcfPanel_partOrBhvrComboBoxChanged);
            bpcfPanel.PartOrBhvrComboBoxChanged += new EventHandler(bpcfPanel_partOrBhvrComboBoxChanged);

            buildKeyPanel();

            this.Controls.Add(bpcfPanel);

            bpcfPanel.Dock = DockStyle.Top;

            if (tgaDic != null)
            {
                tgaFilesDictionary = tgaDic.ToDictionary(k => k.Key, k => k.Value);
            }
            else
            {
                MessageBox.Show("Building TGA texture Dictionary...\r\nThis may take few seconds!");

                tgaFilesDictionary = common.COH_IO.getFilesDictionary(rootPath.Replace(@"\data", "") + @"src\Texture_Library", "*.tga");

                tgaDic = tgaFilesDictionary.ToDictionary(k => k.Key, k => k.Value);
            }

            ArrayList ctlList = buildToolTipsObjList();

            fToolTip = common.COH_htmlToolTips.intilizeToolTips(ctlList, @"assetEditor/objectTrick/PartToolTips.html");
        }
        private void setStatus()
        {
            if (ownerName.Equals("Behavior"))
            {
                BehaviorWin bWin = (BehaviorWin)ownerDockablePanel;

                Behavior bhvr = (Behavior)(bWin).BhvrTag;

                bhvr.refreshP4ROAttributes();

                save_btn.Enabled = !bhvr.isReadOnly;

                bool lockCtl = bhvr.isReadOnly;

                if (Path.GetFileName(bhvr.fileName).ToLower().Equals("null.bhvr"))
                {
                    lockCtl = false;
                }


                bWin.enable(!lockCtl);

                bWin.isLocked = lockCtl;
            }
            else
            {
                ParticalsWin pWin = (ParticalsWin)ownerDockablePanel;

                Partical part = (Partical)(pWin).Tag;

                part.refreshP4ROAttributes();

                save_btn.Enabled = !part.isReadOnly;

                pWin.enable(!part.isReadOnly);

                pWin.isLocked = part.isReadOnly;
            }

            eventsBhvrFilesMComboBx_SelectedIndexChanged(eventsBhvrFilesMComboBx, new EventArgs());
        }
        private void updatePart(string fileName, ArrayList data)
        {
            Partical part = ParticalParser.parse(fileName, ref data);

            ParticalsWin pWin = (ParticalsWin)ownerDockablePanel;

            foreach (KeyValuePair <string, object> kvp in part.pParameters)
            {
                pWin.Tag.pParameters[kvp.Key] = kvp.Value;
            }

            pWin.Tag.fileName = part.fileName;

            pWin.Tag.isCommented = part.isCommented;

            pWin.Tag.isDirty = part.isDirty;

            pWin.Tag.isP4 = part.isP4;

            pWin.Tag.isReadOnly = part.isReadOnly;

            ((ParticalsWin)ownerDockablePanel).setIsDirty(false);
        }
Esempio n. 6
0
        public void loadStandAlonePartFile(string file_name)
        {
            ArrayList partData = new ArrayList();

            common.COH_IO.fillList(partData, file_name);

            Partical part = ParticalParser.parse(file_name, ref partData);

            bpcfPanel.partStandAloneFile.Add(part);

            if (!bpcfPanel.eventsComboBx.Items.Contains("StandAloneFiles"))
            {
                this.bpcfPanel.eventsComboBx.Items.Add("StandAloneFiles");
            }

            if (standAloneWindow)
            {
                bpcfPanel.initializeComboBxs(null);
            }

            bpcfPanel.eventsComboBx.SelectedIndex = bpcfPanel.eventsComboBx.Items.Count - 1;

            //bpcfPanel.eventsBhvrFilesMComboBx.SelectedIndex = bpcfPanel.eventsBhvrFilesMComboBx.Items.Count - 1;
        }
Esempio n. 7
0
        public void setPartPanels(Partical part)
        {
            if (this.Tag != null)
            {
                updatePart();
            }

            this.Tag = part;

            fileName = part.fileName;

            isLocked = part.isReadOnly;

            isDirty = part.isDirty;

            foreach (TabPage tp in part_tabControl.Controls)
            {
                tp.SuspendLayout();
                foreach (ParticalKeyPanel pkeyPanel in tp.Controls)
                {
                    pkeyPanel.SuspendLayout();
                }
            }

            this.part_tabControl.SuspendLayout();

            this.SuspendLayout();

            foreach (TabPage tp in part_tabControl.Controls)
            {
                foreach (ParticalKeyPanel pkeyPanel in tp.Controls)
                {
                    string pKey = pkeyPanel.Name.Replace("_ParticalKeyPanel", "");

                    string pVal = null;

                    if (part.pParameters.ContainsKey(pKey) &&
                        part.pParameters[pKey] != null)
                    {
                        pVal = (string)part.pParameters[pKey];

                        if (pVal.ToLower().EndsWith(".tga"))
                        {
                            string tmpVal = getTexturePath(pVal);
                            if (tmpVal != null)
                            {
                                pVal = tmpVal;
                            }
                        }
                    }
                    pkeyPanel.Tag = part;

                    pkeyPanel.setVal(this, pVal, isLocked);
                }
            }

            //fixPanelLayout();

            setFileStatus();

            foreach (TabPage tp in part_tabControl.Controls)
            {
                foreach (ParticalKeyPanel pkeyPanel in tp.Controls)
                {
                    pkeyPanel.ResumeLayout(false);
                }

                tp.ResumeLayout(false);
            }

            part_tabControl.ResumeLayout(false);

            this.ResumeLayout(false);

            enable(true);
        }
        private void eventsBhvrFilesMComboBx_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            string fileName = null;

            int pOrB_index = eventsBhvrFilesMComboBx.SelectedIndex;

            int eIndex = eventsComboBx.SelectedIndex;

            if (eIndex > -1 &&
                eventsComboBx.Tag != null &&
                eIndex < ((ArrayList)eventsComboBx.Tag).Count)
            {
                Event ev = (Event)((ArrayList)eventsComboBx.Tag)[eIndex];

                if (ownerName.Equals("Behavior") &&
                    pOrB_index < ev.eBhvrsObject.Count)
                {
                    Behavior bhvr = (Behavior)ev.eBhvrsObject[pOrB_index];

                    selectedBhvrOrPartObject = bhvr;

                    if (bhvr != null)
                    {
                        bhvr.Tag = ev;

                        ((BehaviorWin)ownerDockablePanel).setBhvrPanels(bhvr);

                        fileName = bhvr.fileName;
                        enableBtns(!Path.GetFileName(fileName).ToLower().Equals("null.bhvr"));
                    }
                }
                else if (ownerName.Equals("Part") &&
                         pOrB_index < ev.epartsObject.Count)
                {
                    Partical part = (Partical)ev.epartsObject[pOrB_index];

                    if (selectedBhvrOrPartObject != part)
                    {
                        selectedBhvrOrPartObject = part;

                        if (part != null)
                        {
                            part.Tag = ev;

                            ((ParticalsWin)ownerDockablePanel).setPartPanels(part);

                            fileName = part.fileName;
                        }
                    }
                }

                invokeSelectionChanged();
            }

            //stand alone file not part of fx file
            else
            {
                common.MComboBoxItem item = (common.MComboBoxItem)eventsBhvrFilesMComboBx.SelectedItem;

                if (ownerName.Equals("Behavior"))
                {
                    Behavior bhvr = (Behavior)item.Tag;

                    selectedBhvrOrPartObject = bhvr;

                    if (bhvr != null)
                    {
                        ((BehaviorWin)ownerDockablePanel).setBhvrPanels(bhvr);
                        fileName = bhvr.fileName;
                    }
                }
                else
                {
                    Partical part = (Partical)item.Tag;

                    selectedBhvrOrPartObject = part;

                    if (part != null)
                    {
                        ((ParticalsWin)ownerDockablePanel).setPartPanels(part);
                        fileName = part.fileName;
                    }
                }
            }

            if (fileName != null)
            {
                FileInfo fi = new FileInfo(fileName);
                save_btn.Enabled = !((fi.Attributes & FileAttributes.ReadOnly) != 0);
            }
        }
Esempio n. 9
0
        public static Partical parse(string fileName, ref ArrayList fileContent)
        {
            Partical part = null;

            int partStartIndex = -1, partEndIndex = -1;

            string partName = System.IO.Path.GetFileNameWithoutExtension(fileName);

            bool isPart     = false;
            bool createPart = false;
            bool isComment  = false;

            int endCount    = 0;
            int maxEndCount = 0;

            for (int j = 0; j < fileContent.Count; j++)
            {
                System.Windows.Forms.Application.DoEvents();

                string line = (string)fileContent[j];
                line = common.COH_IO.removeExtraSpaceBetweenWords(line.Replace("\t", " ")).Trim();
                line = line.Replace("//", "#");

                //don't skip last empty line
                if (line.Trim().Length < 1 && j != fileContent.Count - 1)
                {
                    continue;
                }

                if (line.StartsWith("#"))
                {
                    isComment = true;
                    line      = line.Substring(1);
                }
                else
                {
                    isComment = false;
                }


                if (isPart != true && line.ToLower().StartsWith("System".ToLower()))
                {
                    partStartIndex = j;
                    isPart         = true;
                    createPart     = false;
                    part           = new Partical(fileName, false);
                }

                else if (isPart)
                {
                    if (line.IndexOf(' ') > -1)
                    {
                        string tagStr = fixPartKeys(line.Substring(0, line.IndexOf(' ')).Trim());

                        if (tagStr.Equals("Flags"))
                        {
                            string flagsStr = line.Substring("Flags ".Length).Split('#')[0];

                            string[] flags = flagsStr.Split(' ');

                            foreach (string flagStr in flags)
                            {
                                string flagKey = fixPartKeys(flagStr.Trim());

                                if (part.pParameters.ContainsKey(flagKey))
                                {
                                    if (!isComment)
                                    {
                                        part.pParameters[flagKey] = "1";
                                    }

                                    //to avoid overwriting a value line by a commented line
                                    else if (part.pParameters[flagKey] == null)
                                    {
                                        part.pParameters[flagKey] = "#1";
                                    }
                                }
                            }
                        }
                        else
                        {
                            string tagVal = line.Substring(tagStr.Length).Trim();
                            tagVal = isComment ? string.Format("#{0}", tagVal) : tagVal;

                            if (part.pParameters.ContainsKey(tagStr))
                            {
                                if (!isComment)
                                {
                                    part.pParameters[tagStr] = tagVal;
                                }

                                //to avoid overwriting a value line by a commented line
                                else if (part.pParameters[tagStr] == null)
                                {
                                    part.pParameters[tagStr] = tagVal;
                                }
                            }
                        }
                    }

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

                    if (endCount > maxEndCount || j == (fileContent.Count - 1))
                    {
                        isPart       = false;
                        partEndIndex = j;
                        createPart   = true;
                    }

                    if (createPart)
                    {
                        endCount    = 0;
                        maxEndCount = 0;
                        return(part);
                    }
                }
            }
            return(null);
        }