ObjectEditor.frmMain.SetProtoGUI C# (CSharp) Method

SetProtoGUI() public method

public SetProtoGUI ( ItemProto Prot, bool ToUI ) : void
Prot ItemProto
ToUI bool
return void
        void SetProtoGUI(ItemProto Prot, bool ToUI)
        {
            if (Prot == null) return;

            // UI<->Data sync
            // Uncommented stuff are not implemented in GUI yet
            #region SetControl
            try
            {
                FOCommon.Utils.SetControl(numPID, ref Prot.ProtoId, ToUI);
                FOCommon.Utils.SetControl(cmbType, ref Prot.Type, Data.ItemTypes, ToUI);
                FOCommon.Utils.SetControl(txtName, ref Prot.Name, ToUI);
                FOCommon.Utils.SetControl(txtProtoFileName, ref Prot.FileName, ToUI);
                FOCommon.Utils.SetControl(txtDescription, ref Prot.Description, ToUI);
                FOCommon.Utils.SetControl(txtScriptModule, ref Prot.ScriptModule, ToUI);
                FOCommon.Utils.SetControl(txtScriptFunction, ref Prot.ScriptFunction, ToUI);
                FOCommon.Utils.SetControl(txtGroundPic, ref Prot.PicMap, ToUI);
                FOCommon.Utils.SetControl(txtInvPic, ref Prot.PicInv, ToUI);
                FOCommon.Utils.SetControl(chkStackable, ref Prot.Stackable, ToUI);
                FOCommon.Utils.SetControl(chkDeteriorable, ref Prot.Deteriorable, ToUI);
                FOCommon.Utils.SetControl(chkGroundLevel, ref Prot.GroundLevel, ToUI);
                //                                = Prot.Dir;
                FOCommon.Utils.SetControl(numSlot, ref Prot.Slot, ToUI);
                FOCommon.Utils.SetControl(numWeight, ref Prot.Weight, ToUI);
                FOCommon.Utils.SetControl(numVolume, ref Prot.Volume, ToUI);
                FOCommon.Utils.SetControl(numCost, ref Prot.Cost, ToUI);
                FOCommon.Utils.SetControl(numStartCount, ref Prot.StartCount, ToUI);
                FOCommon.Utils.SetControl(numSoundId, ref Prot.SoundId, ToUI);
                FOCommon.Utils.SetControl(numLightDistance, ref Prot.LightDistance, ToUI);
                FOCommon.Utils.SetControl(numLightIntensity, ref Prot.LightIntensity, ToUI);
                FOCommon.Utils.SetControl(chkDisableEgg, ref Prot.DisableEgg, ToUI);
                FOCommon.Utils.SetControl(numAnimWaitBase, ref Prot.AnimWaitBase, ToUI);
                FOCommon.Utils.SetControl(numAnimWaitMin, ref Prot.AnimWaitRndMin, ToUI);
                FOCommon.Utils.SetControl(numAnimWaitMax, ref Prot.AnimWaitRndMax, ToUI);
                FOCommon.Utils.SetControl(numAnimStay0, ref Prot.AnimStay_0, ToUI);
                FOCommon.Utils.SetControl(numAnimStay1, ref Prot.AnimStay_1, ToUI);
                FOCommon.Utils.SetControl(numAnimShow0, ref Prot.AnimShow_0, ToUI);
                FOCommon.Utils.SetControl(numAnimShow1, ref Prot.AnimShow_1, ToUI);
                FOCommon.Utils.SetControl(numAnimHide0, ref Prot.AnimHide_0, ToUI);
                FOCommon.Utils.SetControl(numAnimHide1, ref Prot.AnimHide_1, ToUI);
                FOCommon.Utils.SetControl(numDrawOffsetsX, ref Prot.OffsetX, ToUI);
                FOCommon.Utils.SetControl(numDrawOffsetsY, ref Prot.OffsetY, ToUI);
                FOCommon.Utils.SetControl(numDrawOrderOffsetHexY, ref Prot.DrawOrderOffsetHexY, ToUI);
                FOCommon.Utils.SetControl(numRadioChannel, ref Prot.RadioChannel, ToUI);
                FOCommon.Utils.SetControl(numRadioBroadcastSend, ref Prot.RadioBroadcastSend, ToUI);
                FOCommon.Utils.SetControl(numRadioBroadcastReceive, ref Prot.RadioBroadcastRecv, ToUI);
                FOCommon.Utils.SetControl(numIndicatorStart, ref Prot.IndicatorStart, ToUI);
                FOCommon.Utils.SetControl(numIndicatorMax, ref Prot.IndicatorMax, ToUI);
                FOCommon.Utils.SetControl(numHolodiskNum, ref Prot.HolodiskNum, ToUI);
                FOCommon.Utils.SetControl(numStartValue1, ref Prot.StartValue[0], ToUI);
                FOCommon.Utils.SetControl(numStartValue2, ref Prot.StartValue[1], ToUI);
                FOCommon.Utils.SetControl(numStartValue3, ref Prot.StartValue[2], ToUI);
                FOCommon.Utils.SetControl(numStartValue4, ref Prot.StartValue[3], ToUI);
                FOCommon.Utils.SetControl(numStartValue5, ref Prot.StartValue[4], ToUI);
                FOCommon.Utils.SetControl(numStartValue6, ref Prot.StartValue[5], ToUI);
                FOCommon.Utils.SetControl(numStartValue7, ref Prot.StartValue[6], ToUI);
                FOCommon.Utils.SetControl(numStartValue8, ref Prot.StartValue[7], ToUI);
                FOCommon.Utils.SetControl(numStartValue9, ref Prot.StartValue[8], ToUI);
                FOCommon.Utils.SetControl(numStartValue10, ref Prot.StartValue[9], ToUI);
                FOCommon.Utils.SetControl(txtBlockLines, ref Prot.BlockLines, ToUI);
                FOCommon.Utils.SetControl(numChildPid1, ref Prot.ChildPid[0], ToUI);
                FOCommon.Utils.SetControl(numChildPid2, ref Prot.ChildPid[1], ToUI);
                FOCommon.Utils.SetControl(numChildPid3, ref Prot.ChildPid[2], ToUI);
                FOCommon.Utils.SetControl(numChildPid4, ref Prot.ChildPid[3], ToUI);
                FOCommon.Utils.SetControl(numChildPid5, ref Prot.ChildPid[4], ToUI);
                FOCommon.Utils.SetControl(txtChildLines1, ref Prot.ChildLines[0], ToUI);
                FOCommon.Utils.SetControl(txtChildLines2, ref Prot.ChildLines[1], ToUI);
                FOCommon.Utils.SetControl(txtChildLines3, ref Prot.ChildLines[2], ToUI);
                FOCommon.Utils.SetControl(txtChildLines4, ref Prot.ChildLines[3], ToUI);
                FOCommon.Utils.SetControl(txtChildLines5, ref Prot.ChildLines[4], ToUI);
                // Weapon stuff
                FOCommon.Utils.SetControl(chkIsUnarmed, ref Prot.Weapon_IsUnarmed, ToUI);
                FOCommon.Utils.SetControl(numUnarmedTree, ref Prot.Weapon_UnarmedTree, ToUI);
                FOCommon.Utils.SetControl(numUnarmedPriority, ref Prot.Weapon_UnarmedPriority, ToUI);
                FOCommon.Utils.SetControl(numMinAgility, ref Prot.Weapon_UnarmedMinAgility, ToUI);
                FOCommon.Utils.SetControl(numMinUnarmed, ref Prot.Weapon_UnarmedMinUnarmed, ToUI);
                FOCommon.Utils.SetControl(numMinLevel, ref Prot.Weapon_UnarmedMinLevel, ToUI);
                FOCommon.Utils.SetControl(cmbAnim1, ref Prot.Weapon_Anim1, Data.Anim1, ToUI);
                FOCommon.Utils.SetControl(numMaxAmmoCount, ref Prot.Weapon_MaxAmmoCount, ToUI);
                FOCommon.Utils.SetControl(cmbCaliberWeapon, ref Prot.Weapon_Caliber, Data.Calibers, ToUI);
                FOCommon.Utils.SetControl(cmdWeaponDefaultAmmo, ref Prot.Weapon_DefaultAmmoPid, Data.ItemPid, ToUI);
                FOCommon.Utils.SetControl(numMinStrength, ref Prot.Weapon_MinStrength, ToUI);
                FOCommon.Utils.SetControl(cmbWeaponPerk, ref Prot.Weapon_Perk, Data.WeaponPerks, ToUI);
                FOCommon.Utils.SetControl(cmbWeaponSkill1, ref Prot.Weapon_Skill_0, Data.Skills, ToUI);
                FOCommon.Utils.SetControl(cmbWeaponSkill2, ref Prot.Weapon_Skill_1, Data.Skills, ToUI);
                FOCommon.Utils.SetControl(cmbWeaponSkill3, ref Prot.Weapon_Skill_2, Data.Skills, ToUI);
                FOCommon.Utils.SetControl(cmbWeaponAnim2_1, ref Prot.Weapon_Anim2_0, Data.Anim2, ToUI);
                FOCommon.Utils.SetControl(cmbWeaponAnim2_2, ref Prot.Weapon_Anim2_1, Data.Anim2, ToUI);
                FOCommon.Utils.SetControl(cmbWeaponAnim2_3, ref Prot.Weapon_Anim2_2, Data.Anim2, ToUI);
                FOCommon.Utils.SetControl(cmbDmgType1, ref Prot.Weapon_DmgType_0, Data.DamageTypes, ToUI);
                FOCommon.Utils.SetControl(cmbDmgType2, ref Prot.Weapon_DmgType_1, Data.DamageTypes, ToUI);
                FOCommon.Utils.SetControl(cmbDmgType3, ref Prot.Weapon_DmgType_2, Data.DamageTypes, ToUI);
                FOCommon.Utils.SetControl(chkWeaponRemove1, ref Prot.Weapon_Remove_0, ToUI);
                FOCommon.Utils.SetControl(chkWeaponRemove2, ref Prot.Weapon_Remove_1, ToUI);
                FOCommon.Utils.SetControl(chkWeaponRemove3, ref Prot.Weapon_Remove_2, ToUI);
                FOCommon.Utils.SetControl(numWeaponFlyEffect1, ref Prot.Weapon_FlyEffect_0, ToUI);
                FOCommon.Utils.SetControl(numWeaponFlyEffect2, ref Prot.Weapon_FlyEffect_1, ToUI);
                FOCommon.Utils.SetControl(numWeaponFlyEffect3, ref Prot.Weapon_FlyEffect_2, ToUI);
                FOCommon.Utils.SetControl(numWeaponDmgMin1, ref Prot.Weapon_DmgMin_0, ToUI);
                FOCommon.Utils.SetControl(numWeaponDmgMin2, ref Prot.Weapon_DmgMin_1, ToUI);
                FOCommon.Utils.SetControl(numWeaponDmgMin3, ref Prot.Weapon_DmgMin_2, ToUI);
                FOCommon.Utils.SetControl(numWeaponDmgMax1, ref Prot.Weapon_DmgMax_0, ToUI);
                FOCommon.Utils.SetControl(numWeaponDmgMax2, ref Prot.Weapon_DmgMax_1, ToUI);
                FOCommon.Utils.SetControl(numWeaponDmgMax3, ref Prot.Weapon_DmgMax_2, ToUI);
                FOCommon.Utils.SetControl(txtUseGraphics1, ref Prot.Weapon_PicUse_0, ToUI);
                FOCommon.Utils.SetControl(txtUseGraphics2, ref Prot.Weapon_PicUse_1, ToUI);
                FOCommon.Utils.SetControl(txtUseGraphics3, ref Prot.Weapon_PicUse_2, ToUI);
                FOCommon.Utils.SetControl(numDistance1, ref Prot.Weapon_MaxDist_0, ToUI);
                FOCommon.Utils.SetControl(numDistance2, ref Prot.Weapon_MaxDist_1, ToUI);
                FOCommon.Utils.SetControl(numDistance3, ref Prot.Weapon_MaxDist_2, ToUI);
                FOCommon.Utils.SetControl(numBulletsRound1, ref Prot.Weapon_Round_0, ToUI);
                FOCommon.Utils.SetControl(numBulletsRound2, ref Prot.Weapon_Round_1, ToUI);
                FOCommon.Utils.SetControl(numBulletsRound3, ref Prot.Weapon_Round_2, ToUI);
                FOCommon.Utils.SetControl(numAttackAP1, ref Prot.Weapon_ApCost_0, ToUI);
                FOCommon.Utils.SetControl(numAttackAP2, ref Prot.Weapon_ApCost_1, ToUI);
                FOCommon.Utils.SetControl(numAttackAP3, ref Prot.Weapon_ApCost_2, ToUI);
                FOCommon.Utils.SetControl(txtSoundId1, ref Prot.Weapon_SoundId_0, ToUI);
                FOCommon.Utils.SetControl(txtSoundId2, ref Prot.Weapon_SoundId_1, ToUI);
                FOCommon.Utils.SetControl(txtSoundId3, ref Prot.Weapon_SoundId_2, ToUI);
                FOCommon.Utils.SetControl(chkAimAvailable1, ref Prot.Weapon_Aim_0, ToUI);
                FOCommon.Utils.SetControl(chkAimAvailable2, ref Prot.Weapon_Aim_1, ToUI);
                FOCommon.Utils.SetControl(chkAimAvailable3, ref Prot.Weapon_Aim_2, ToUI);
                FOCommon.Utils.SetControl(cmbCaliberAmmo, ref Prot.Ammo_Caliber, Data.Calibers, ToUI);
                FOCommon.Utils.SetControl(numCriticalFailure, ref Prot.Weapon_CriticalFailture, ToUI);
                FOCommon.Utils.SetControl(numAcMod, ref Prot.Ammo_AcMod, ToUI);
                FOCommon.Utils.SetControl(numDrMod, ref Prot.Ammo_DrMod, ToUI);
                FOCommon.Utils.SetControl(numCrTypeMale, ref Prot.Armor_CrTypeMale, ToUI);
                FOCommon.Utils.SetControl(numCrTypeFemale, ref Prot.Armor_CrTypeFemale, ToUI);

                // Misc
                FOCommon.Utils.SetControl(chkDoorNoBlockLight, ref Prot.Door_NoBlockLight, ToUI);
                FOCommon.Utils.SetControl(chkDoorNoBlockShoot, ref Prot.Door_NoBlockShoot, ToUI);
                FOCommon.Utils.SetControl(chkDoorNoBlockMove, ref Prot.Door_NoBlockMove, ToUI);
                FOCommon.Utils.SetControl(numContainerVolume, ref Prot.Container_Volume, ToUI);
                FOCommon.Utils.SetControl(chkContainerChangable, ref Prot.Container_Changeble, ToUI);
                FOCommon.Utils.SetControl(chkContainerCannotPickup, ref Prot.Container_CannotPickUp, ToUI);
                FOCommon.Utils.SetControl(chkContainerMagicHandsGrnd, ref Prot.Container_MagicHandsGrnd, ToUI);

                FOCommon.Utils.SetControl(numCarSpeed, ref Prot.Car_Speed, ToUI);
                FOCommon.Utils.SetControl(numCarPassability, ref Prot.Car_Passability, ToUI);
                FOCommon.Utils.SetControl(numCarDeteriorationRate, ref Prot.Car_DeteriorationRate, ToUI);
                FOCommon.Utils.SetControl(numCarCritterCapacity, ref Prot.Car_CrittersCapacity, ToUI);
                FOCommon.Utils.SetControl(numCarTankVolume, ref Prot.Car_TankVolume, ToUI);
                FOCommon.Utils.SetControl(numCarMaxDeterioration, ref Prot.Car_MaxDeterioration, ToUI);
                FOCommon.Utils.SetControl(numCarFuelConsumption, ref Prot.Car_FuelConsumption, ToUI);
                FOCommon.Utils.SetControl(numCarEntrance, ref Prot.Car_Entrance, ToUI);

                // Parse flags
                FOCommon.Utils.SetControlFlag(chkColorFlagColorize, ref Prot.Flags, (uint)Data.Defines["ITEM_COLORIZE"], ToUI);
                FOCommon.Utils.SetControlFlag(chkColorFlagColorizeInventory, ref Prot.Flags, (uint)Data.Defines["ITEM_COLORIZE_INV"], ToUI);
                FOCommon.Utils.SetControlFlag(chkRadioEnabled, ref Prot.Flags, (uint)Data.Defines["ITEM_RADIO"], ToUI);

                FOCommon.Utils.SetControlFlag(chkHolodiskEnabled, ref Prot.Flags, (uint)Data.Defines["ITEM_HOLODISK"], ToUI);
                FOCommon.Utils.SetControlFlag(chkLight, ref Prot.Flags, (uint)Data.Defines["ITEM_LIGHT"], ToUI);
                FOCommon.Utils.SetControlFlag(chkShowAnim, ref Prot.Flags, (uint)Data.Defines["ITEM_SHOW_ANIM"], ToUI);
                FOCommon.Utils.SetControlFlag(chkShowAnimExt, ref Prot.Flags, (uint)Data.Defines["ITEM_SHOW_ANIM_EXT"], ToUI);

                FOCommon.Utils.SetControlFlag(chkLightFlagDisableDir0, ref Prot.LightFlags, (uint)LIGHT_DISABLE_DIR(0), ToUI);
                FOCommon.Utils.SetControlFlag(chkLightFlagDisableDir1, ref Prot.LightFlags, (uint)LIGHT_DISABLE_DIR(1), ToUI);
                FOCommon.Utils.SetControlFlag(chkLightFlagDisableDir2, ref Prot.LightFlags, (uint)LIGHT_DISABLE_DIR(2), ToUI);
                FOCommon.Utils.SetControlFlag(chkLightFlagDisableDir3, ref Prot.LightFlags, (uint)LIGHT_DISABLE_DIR(3), ToUI);
                FOCommon.Utils.SetControlFlag(chkLightFlagDisableDir4, ref Prot.LightFlags, (uint)LIGHT_DISABLE_DIR(4), ToUI);
                FOCommon.Utils.SetControlFlag(chkLightFlagDisableDir5, ref Prot.LightFlags, (uint)LIGHT_DISABLE_DIR(5), ToUI);
                FOCommon.Utils.SetControlFlag(chkLightFlagGlobal, ref Prot.LightFlags, LIGHT_GLOBAL, ToUI);
                FOCommon.Utils.SetControlFlag(chkLightFlagInverse, ref Prot.LightFlags, LIGHT_INVERSE, ToUI);
                FOCommon.Utils.SetControlFlag(chkRadioFlagDisableSend, ref Prot.RadioFlags, (uint)Data.Defines["RADIO_DISABLE_SEND"], ToUI);
                FOCommon.Utils.SetControlFlag(chkRadioFlagDisableRecv, ref Prot.RadioFlags, (uint)Data.Defines["RADIO_DISABLE_RECV"], ToUI);
                FOCommon.Utils.SetControlFlag(chkRadioFlagDisableShiftRecv, ref Prot.RadioFlags, (uint)Data.Defines["RADIO_DISABLE_SHIFT_RECV"], ToUI);
                FOCommon.Utils.SetControlFlag(chkRadioFlagDisableShiftSend, ref Prot.RadioFlags, (uint)Data.Defines["RADIO_DISABLE_SHIFT_SEND"], ToUI);
                FOCommon.Utils.SetControlFlag(chkRadioFlagDisableShiftBCSend, ref Prot.RadioFlags, (uint)Data.Defines["RADIO_DISABLE_SHIFT_BC_SEND"], ToUI);
                FOCommon.Utils.SetControlFlag(chkRadioFlagDisableShiftBCRecv, ref Prot.RadioFlags, (uint)Data.Defines["RADIO_DISABLE_SHIFT_BC_RECV"], ToUI);
                FOCommon.Utils.SetControlFlag(chkRadioFlagDisableShiftChannel, ref Prot.RadioFlags, (uint)Data.Defines["RADIO_DISABLE_SHIFT_CHANNEL"], ToUI);

                FOCommon.Utils.SetControl(grpCarMovementType, ref Prot.Car_MovementType, ToUI);
                FOCommon.Utils.SetControl(grpExtInfoMaterial, ref Prot.Material, ToUI);
                FOCommon.Utils.SetControl(grpExtInfoCorner, ref Prot.Corner, ToUI);
                FOCommon.Utils.SetControl(grpSpriteCutting, ref Prot.SpriteCut, ToUI);
                FOCommon.Utils.SetControl(grpGridType, ref Prot.Grid_Type, ToUI);

                // Multiline textbox
                if (ToUI)
                    txtDescription.Text = txtDescription.Text.Replace("\n", "\r\n");
                else
                    txtDescription.Text = txtDescription.Text.Replace("\r\n", "\n");
            }
            catch (ArgumentOutOfRangeException Arg)
            {
                Utils.Log(Prot.Name+"["+Prot.ProtoId+"]: "+ Arg.Message + "::" + Arg.Source);
            }
            #endregion

            // Custom flags from Flags.cfg
            foreach (CheckBox chkBox in grpExtInfoFlags.Controls)
            {
                string Define = (String)chkBox.Tag;
                FOCommon.Utils.SetControlFlag(chkBox, ref Prot.Flags, (uint)Data.Defines[Define], ToUI);
            }

            // For Custom.cfg stuff
            SetCustomData(ref Prot, ToUI);

            // Stuff that needs some special handling
            if (ToUI)
            {
                numColorAlpha.Value = (Prot.LightColor >> 24) & 0xFF;
                numColorRed.Value = (Prot.LightColor >> 16) & 0xFF;
                numColorGreen.Value = (Prot.LightColor >> 8) & 0xFF;
                numColorBlue.Value = (Prot.LightColor) & 0xFF;
                chkActive1.Checked = false;
                chkActive2.Checked = false;
                chkActive3.Checked = false;
                for (uint i = 0; i <= Prot.Weapon_ActiveUses; i++)
                {
                    if (i == 1) chkActive1.Checked = true;
                    if (i == 2) chkActive2.Checked = true;
                    if (i == 3) chkActive3.Checked = true;
                }
            }
            else
            {
                uint ActiveCount = 0;
                if (chkActive1.Checked) ActiveCount++;
                if (chkActive2.Checked) ActiveCount++;
                if (chkActive3.Checked) ActiveCount++;
                Prot.Weapon_ActiveUses = ActiveCount;
                Prot.LightColor = ((Int32)numColorAlpha.Value << 24) | ((Int32)numColorRed.Value << 16) | ((Int32)numColorGreen.Value << 8) | ((Int32)numColorBlue.Value);
            }
        }