コード例 #1
0
ファイル: GUI.cs プロジェクト: highattack30/GPK_RePack
        private void treeMain_AfterSelect(object sender, TreeViewEventArgs e)
        {
            ResetGUI();

            if (e.Node.Level == 0)
            {
                boxGeneralButtons.Enabled = true;
                boxDataButtons.Enabled    = true;

                selectedPackage = loadedGpkPackages[Convert.ToInt32(e.Node.Name)];
                boxInfo.Text    = selectedPackage.ToString();
            }
            else if (e.Node.Level == 1 && Settings.Default.ViewMode == "class")
            {
                selectedPackage = loadedGpkPackages[Convert.ToInt32(e.Node.Parent.Name)];
                selectedClass   = e.Node.Text;

                boxDataButtons.Enabled = true;
            }
            else if (e.Node.Level == 2)
            {
                GpkPackage package  = loadedGpkPackages[Convert.ToInt32(e.Node.Parent.Parent.Name)];
                Object     selected = package.GetObjectByUID(e.Node.Name);

                if (selected is GpkImport)
                {
                    GpkImport imp = (GpkImport)selected;
                    boxInfo.Text = imp.ToString();
                }
                else if (selected is GpkExport)
                {
                    GpkExport exp = (GpkExport)selected;
                    boxInfo.Text = exp.ToString();


                    boxGeneralButtons.Enabled  = true;
                    boxDataButtons.Enabled     = true;
                    boxPropertyButtons.Enabled = true;
                    selectedExport             = exp;
                    selectedPackage            = package;

                    DrawGrid(package, exp);
                }
            }
        }
コード例 #2
0
ファイル: GUI.cs プロジェクト: highattack30/GPK_RePack
        private IProperty readProperty(DataGridViewRow row)
        {
            GpkBaseProperty baseProp = new GpkBaseProperty(row.Cells["name"].Value.ToString(), row.Cells["type"].Value.ToString(), 0, Convert.ToInt32(row.Cells["aIndex"].Value.ToString()));
            IProperty       iProp;

            //Check & Add name to our namelist
            selectedPackage.AddString(baseProp.name);

            string cellValue = row.Cells["value"].Value.ToString();


            switch (baseProp.type)
            {
            case "StructProperty":
                GpkStructProperty tmpStruct = new GpkStructProperty(baseProp);
                tmpStruct.innerType = row.Cells["iType"].Value.ToString();
                tmpStruct.value     = (cellValue).ToBytes();
                iProp = tmpStruct;
                break;

            case "ArrayProperty":
                GpkArrayProperty tmpArray = new GpkArrayProperty(baseProp);
                if (cellValue == "[##TOO_LONG##]")
                {
                    //use row embeeded property instead
                    tmpArray.value = ((GpkArrayProperty)row.Tag).value;
                }
                else
                {
                    tmpArray.value = (cellValue).ToBytes();
                }

                iProp = tmpArray;
                break;

            case "ByteProperty":
                GpkByteProperty tmpByte = new GpkByteProperty(baseProp);

                if (cellValue.Length > 2)
                {
                    selectedPackage.AddString(cellValue);     //just in case

                    tmpByte.nameValue = cellValue;
                }
                else
                {
                    tmpByte.byteValue = Convert.ToByte(cellValue);
                }
                iProp = tmpByte;
                break;

            case "NameProperty":
                GpkNameProperty tmpName = new GpkNameProperty(baseProp);
                selectedPackage.AddString(cellValue);     //just in case
                tmpName.value = cellValue;
                iProp         = tmpName;
                break;

            case "ObjectProperty":
                GpkObjectProperty tmpObj = new GpkObjectProperty(baseProp);
                selectedPackage.GetObjectByUID(cellValue);     //throws ex if uid is not present
                tmpObj.objectName = cellValue;
                iProp             = tmpObj;
                break;

            case "BoolProperty":
                GpkBoolProperty tmpBool = new GpkBoolProperty(baseProp);
                tmpBool.value = Convert.ToBoolean(row.Cells[5].Value);
                iProp         = tmpBool;
                break;

            case "IntProperty":
                GpkIntProperty tmpInt = new GpkIntProperty(baseProp);
                tmpInt.value = Convert.ToInt32(row.Cells[5].Value);
                iProp        = tmpInt;
                break;

            case "FloatProperty":
                GpkFloatProperty tmpFloat = new GpkFloatProperty(baseProp);
                tmpFloat.value = Convert.ToSingle(row.Cells[5].Value);
                iProp          = tmpFloat;
                break;

            case "StrProperty":
                GpkStringProperty tmpStr = new GpkStringProperty(baseProp);
                tmpStr.value = (row.Cells[5].Value.ToString());
                iProp        = tmpStr;
                break;

            case "":
                //new line, nothing selected
                throw new Exception(
                          string.Format("You need to select a Property Type for {0}!", baseProp.name));

            default:
                throw new Exception(
                          string.Format("Unknown Property Type {0}, Prop_Name {1}", baseProp.type, baseProp.name));
            }

            iProp.RecalculateSize();
            return(iProp);
        }
コード例 #3
0
        public IProperty GetIProperty(GpkPackage selectedPackage)
        {
            var       baseProp = new GpkBaseProperty(Name, PropertyType, 0, ArrayIndex);
            IProperty iProp;

            //Check & Add name to our namelist
            selectedPackage.AddString(baseProp.name);

            var cellValue = Value.ToString();//.Cells["value"].Value.ToString();


            switch (baseProp.type)
            {
            case "StructProperty":
                iProp = new GpkStructProperty(baseProp)
                {
                    innerType = InnerType,     //.Cells["iType"].Value.ToString();
                    value     = (cellValue).ToBytes()
                };
                break;

            case "ArrayProperty":
                //if (cellValue == "[##TOO_LONG##]")
                //{
                //    //use row embeeded property instead
                //    tmpArray.value = ((GpkArrayProperty)row.Tag).value;
                //}
                //else
                var tmpArray = new GpkArrayProperty(baseProp)
                {
                    value = (cellValue).ToBytes()
                };
                tmpArray.size = tmpArray.value.Length;
                tmpArray.RecalculateSize();
                iProp = tmpArray;
                break;

            case "ByteProperty":
                var tmpByte = new GpkByteProperty(baseProp);

                if (cellValue.Length > 2)
                {
                    if (selectedPackage.x64)
                    {
                        tmpByte.enumType = InnerType;                //.Cells["iType"].Value.ToString();
                        selectedPackage.AddString(tmpByte.enumType); //just in case
                    }
                    selectedPackage.AddString(cellValue);            //just in case

                    tmpByte.nameValue = cellValue;
                }
                else
                {
                    tmpByte.byteValue = Convert.ToByte(cellValue);
                }
                iProp = tmpByte;
                break;

            case "NameProperty":
                var tmpName = new GpkNameProperty(baseProp);
                selectedPackage.AddString(cellValue);     //just in case
                tmpName.value = cellValue;
                iProp         = tmpName;
                break;

            case "ObjectProperty":
                var tmpObj = new GpkObjectProperty(baseProp);
                selectedPackage.GetObjectByUID(cellValue);     //throws ex if uid is not present
                tmpObj.objectName = cellValue;
                iProp             = tmpObj;
                break;

            case "BoolProperty":
                var tmpBool = new GpkBoolProperty(baseProp)
                {
                    value = Convert.ToBoolean(Value)
                };
                iProp = tmpBool;
                break;

            case "IntProperty":
                var tmpInt = new GpkIntProperty(baseProp)
                {
                    value = Convert.ToInt32(Value)
                };
                iProp = tmpInt;
                break;

            case "FloatProperty":
                var tmpFloat = new GpkFloatProperty(baseProp)
                {
                    value = Convert.ToSingle(Value)
                };
                iProp = tmpFloat;
                break;

            case "StrProperty":
                var tmpStr = new GpkStringProperty(baseProp)
                {
                    value = (Value.ToString())
                };
                iProp = tmpStr;
                break;

            case "":
                //new line, nothing selected
                throw new Exception($"You need to select a Property Type for {baseProp.name}!");

            default:
                throw new Exception($"Unknown Property Type {baseProp.type}, Prop_Name {baseProp.name}");
            }

            iProp.RecalculateSize();
            return(iProp);
        }