private void displayItemDefinitionBehaviour(itemDefinition.itemBehaviourContainer Behaviour)
        {
            lstBehaviour.Items.Clear();
            lstBehaviour.Items.Add("Wallitem", Behaviour.isWallItem);
            lstBehaviour.Items.Add("Solid", Behaviour.isSolid);
            lstBehaviour.Items.Add("Can sit on top", Behaviour.canSitOnTop);
            lstBehaviour.Items.Add("Can lay on top", Behaviour.canLayOnTop);
            lstBehaviour.Items.Add("Can stand on top", Behaviour.canStandOnTop);
            lstBehaviour.Items.Add("Can stack on top", Behaviour.canStackOnTop);
            lstBehaviour.Items.Add("Roller", Behaviour.isRoller);
            lstBehaviour.Items.Add("Public space object", Behaviour.isPublicSpaceObject);

            lstBehaviour.Items.Add("Requires rights for interaction", Behaviour.requiresRightsForInteraction);
            lstBehaviour.Items.Add("Requires touching for interaction", Behaviour.requiresTouchingForInteraction);

            lstBehaviour.Items.Add("Customdata: TRUE/FALSE", Behaviour.customDataTrueFalse);
            lstBehaviour.Items.Add("Customdata: ON/OFF", Behaviour.customDataOnOff);
            lstBehaviour.Items.Add("Customdata: numeric on/off", Behaviour.customDataNumericOnOff);
            lstBehaviour.Items.Add("Customdata: numeric state", Behaviour.customDataNumericState);

            lstBehaviour.Items.Add("Invisible", Behaviour.isInvisible);
            lstBehaviour.Items.Add("Decoration", Behaviour.isDecoration);
            lstBehaviour.Items.Add("Post.it", Behaviour.isPostIt);
            lstBehaviour.Items.Add("Door", Behaviour.isDoor);
            lstBehaviour.Items.Add("Teleporter", Behaviour.isTeleporter);
            lstBehaviour.Items.Add("Dice", Behaviour.isDice);
            lstBehaviour.Items.Add("Prizetrophy", Behaviour.isPrizeTrophy);
            lstBehaviour.Items.Add("Redeemable", Behaviour.isRedeemable);
            lstBehaviour.Items.Add("Soundmachine", Behaviour.isSoundMachine);
            lstBehaviour.Items.Add("Soundmachine sample set", Behaviour.isSoundMachineSampleSet);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            String entered = "";

            foreach (String line in textBox1.Lines)
            {
                String[] value = line.Split(' ');
                if (!entered.Contains("," + value[1] + ","))
                {
                    entered += "," + value[1] + ",";
                    //a1611 sun_chair 16 11 0 2 2
                    Boolean chair = false;
                    if (value[6] == "2")
                    {
                        chair = true;
                    }

                    itemDefinition editedDefinition = new itemDefinition();
                    editedDefinition.directoryID = 0;
                    editedDefinition.Sprite      = value[1];
                    editedDefinition.Color       = "";
                    editedDefinition.Length      = (byte)1.00F;
                    editedDefinition.Width       = (byte)1.00F;
                    editedDefinition.topHeight   = (float)(chair ? 1.00F : 0.00F);

                    itemDefinition.itemBehaviourContainer newBehaviourContainer = new itemDefinition.itemBehaviourContainer();
                    newBehaviourContainer.isPublicSpaceObject = true;
                    newBehaviourContainer.canSitOnTop         = chair;
                    editedDefinition.Behaviour = newBehaviourContainer;

                    this.saveItemDefinition(editedDefinition);
                }
            }
            Engine.Game.Items.loadDefinitions();
        }
        private void cmdSaveItemDefinition_Click(object sender, EventArgs e)
        {
            int[] selectedItemDefinitionIDs = this.selectedItemDefinitionIDs;

            int dirID = 0;
            if (!int.TryParse(txtDirectoryID.Text, out dirID) || dirID < 0)
            {
                displayMessageBox("Field 'directory ID' holds no valid value. The value has to be numeric and atleast zero.", MessageBoxIcon.Exclamation);
                return;
            }
            if (dirID == 0)
                displayMessageBox("Field 'directory ID' holds the value 0. Most furniture items will appear as PlaceHolder boxes if their cast file cannot be resolved from the DCR directory.\r\nIf you are unsure about the directory ID of this item definition, you might want to use the helper tool Chestnut that will index the directory IDs of all item cast files in your DCR directory.", MessageBoxIcon.Information);

            if (txtSprite.Text == "")
            {
                displayMessageBox("The field 'Sprite' cannot be empty.", MessageBoxIcon.Exclamation);
                return;
            }

            itemDefinition editedDefinition = new itemDefinition();
            editedDefinition.directoryID = dirID;
            editedDefinition.Sprite = txtSprite.Text;
            editedDefinition.Color = txtItemColor.Text;
            editedDefinition.Length = (byte)numItemLength.Value;
            editedDefinition.Width = (byte)numItemWidth.Value;
            editedDefinition.topHeight = (float)numItemTopHeight.Value;

            itemDefinition.itemBehaviourContainer newBehaviourContainer = new itemDefinition.itemBehaviourContainer();
            foreach (string s in lstBehaviour.CheckedItems)
            {
                switch (s)
                {
                    #region Primitive types
                    case "Wallitem":
                        newBehaviourContainer.isWallItem = true;
                        break;
                    case "Solid":
                        newBehaviourContainer.isSolid = true;
                        break;
                    case "Can sit on top":
                        newBehaviourContainer.canSitOnTop = true;
                        break;
                    case "Can lay on top":
                        newBehaviourContainer.canLayOnTop = true;
                        break;
                    case "Can stand on top":
                        newBehaviourContainer.canStandOnTop = true;
                        break;
                    case "Can stack on top":
                        newBehaviourContainer.canStackOnTop = true;
                        break;
                    case "Roller":
                        newBehaviourContainer.isRoller = true;
                        break;
                    case "Public space object":
                        newBehaviourContainer.isPublicSpaceObject = true;
                        break;
                    case "Invisible":
                        newBehaviourContainer.isInvisible = true;
                        break;
                    #endregion

                    #region Interaction requirements
                    case "Requires rights for interaction":
                        newBehaviourContainer.requiresRightsForInteraction = true;
                        break;
                    case "Requires touching for interaction":
                        newBehaviourContainer.requiresTouchingForInteraction = true;
                        break;
                    #endregion

                    #region Custom data usage
                    case "Customdata: TRUE/FALSE":
                        newBehaviourContainer.customDataTrueFalse = true;
                        break;
                    case "Customdata: ON/OFF":
                        newBehaviourContainer.customDataOnOff = true;
                        break;
                    case "Customdata: numeric on/off":
                        newBehaviourContainer.customDataNumericOnOff = true;
                        break;
                    case "Customdata: numeric state":
                        newBehaviourContainer.customDataNumericState = true;
                        break;
                    #endregion

                    #region Item usage
                    case "Decoration":
                        newBehaviourContainer.isDecoration = true;
                        break;
                    case "Post.it":
                        newBehaviourContainer.isPostIt = true;
                        break;
                    case "Door":
                        newBehaviourContainer.isDoor = true;
                        break;
                    case "Teleporter":
                        newBehaviourContainer.isTeleporter = true;
                        break;
                    case "Dice":
                        newBehaviourContainer.isDice = true;
                        break;
                    case "Prizetrophy":
                        newBehaviourContainer.isPrizeTrophy = true;
                        break;
                    case "Redeemable":
                        newBehaviourContainer.isRedeemable = true;
                        break;
                    case "Soundmachine":
                        newBehaviourContainer.isSoundMachine = true;
                        break;
                    case "Soundmachine sample set":
                        newBehaviourContainer.isSoundMachineSampleSet = true;
                        break;
                    #endregion
                }
            }

            editedDefinition.Behaviour = newBehaviourContainer;
            foreach (int definitionID in selectedItemDefinitionIDs)
            {
                editedDefinition.ID = definitionID;
                if (selectedItemDefinitionIDs.Length > 1) // More than one item selected, keep original directory ID/sprite/color/length/width intact
                {
                    itemDefinition oldDefinition = ObjectTree.Game.Items.getItemDefinition(definitionID);
                    if (oldDefinition == null)
                        continue;

                    editedDefinition.directoryID = oldDefinition.directoryID;
                    editedDefinition.Sprite = oldDefinition.Sprite;
                    editedDefinition.Color = oldDefinition.Color;
                    editedDefinition.Length = oldDefinition.Length;
                    editedDefinition.Width = oldDefinition.Width;
                }
                this.saveItemDefinition(editedDefinition);
            }

            this.displayItemDefinitions();
            ObjectTree.Game.Store.loadCataloguePages();

            displayMessageBox("Selected item definitions saved successfully.", MessageBoxIcon.Information);
        }
        private void cmdSaveItemDefinition_Click(object sender, EventArgs e)
        {
            int[] selectedItemDefinitionIDs = this.selectedItemDefinitionIDs;

            int dirID = 0;

            if (!int.TryParse(txtDirectoryID.Text, out dirID) || dirID < 0)
            {
                displayMessageBox("Field 'directory ID' holds no valid value. The value has to be numeric and atleast zero.", MessageBoxIcon.Exclamation);
                return;
            }
            if (dirID == 0)
            {
                displayMessageBox("Field 'directory ID' holds the value 0. Most furniture items will appear as PlaceHolder boxes if their cast file cannot be resolved from the DCR directory.\r\nIf you are unsure about the directory ID of this item definition, you might want to use the helper tool Chestnut that will index the directory IDs of all item cast files in your DCR directory.", MessageBoxIcon.Information);
            }

            if (txtSprite.Text == "")
            {
                displayMessageBox("The field 'Sprite' cannot be empty.", MessageBoxIcon.Exclamation);
                return;
            }

            itemDefinition editedDefinition = new itemDefinition();

            editedDefinition.directoryID = dirID;
            editedDefinition.Sprite      = txtSprite.Text;
            editedDefinition.Color       = txtItemColor.Text;
            editedDefinition.Length      = (byte)numItemLength.Value;
            editedDefinition.Width       = (byte)numItemWidth.Value;
            editedDefinition.topHeight   = (float)numItemTopHeight.Value;

            itemDefinition.itemBehaviourContainer newBehaviourContainer = new itemDefinition.itemBehaviourContainer();
            foreach (string s in lstBehaviour.CheckedItems)
            {
                switch (s)
                {
                    #region Primitive types
                case "Wallitem":
                    newBehaviourContainer.isWallItem = true;
                    break;

                case "Solid":
                    newBehaviourContainer.isSolid = true;
                    break;

                case "Can sit on top":
                    newBehaviourContainer.canSitOnTop = true;
                    break;

                case "Can lay on top":
                    newBehaviourContainer.canLayOnTop = true;
                    break;

                case "Can stand on top":
                    newBehaviourContainer.canStandOnTop = true;
                    break;

                case "Can stack on top":
                    newBehaviourContainer.canStackOnTop = true;
                    break;

                case "Roller":
                    newBehaviourContainer.isRoller = true;
                    break;

                case "Public space object":
                    newBehaviourContainer.isPublicSpaceObject = true;
                    break;

                case "Invisible":
                    newBehaviourContainer.isInvisible = true;
                    break;
                    #endregion

                    #region Interaction requirements
                case "Requires rights for interaction":
                    newBehaviourContainer.requiresRightsForInteraction = true;
                    break;

                case "Requires touching for interaction":
                    newBehaviourContainer.requiresTouchingForInteraction = true;
                    break;
                    #endregion

                    #region Custom data usage
                case "Customdata: TRUE/FALSE":
                    newBehaviourContainer.customDataTrueFalse = true;
                    break;

                case "Customdata: ON/OFF":
                    newBehaviourContainer.customDataOnOff = true;
                    break;

                case "Customdata: numeric on/off":
                    newBehaviourContainer.customDataNumericOnOff = true;
                    break;

                case "Customdata: numeric state":
                    newBehaviourContainer.customDataNumericState = true;
                    break;
                    #endregion

                    #region Item usage
                case "Decoration":
                    newBehaviourContainer.isDecoration = true;
                    break;

                case "Post.it":
                    newBehaviourContainer.isPostIt = true;
                    break;

                case "Door":
                    newBehaviourContainer.isDoor = true;
                    break;

                case "Teleporter":
                    newBehaviourContainer.isTeleporter = true;
                    break;

                case "Dice":
                    newBehaviourContainer.isDice = true;
                    break;

                case "Prizetrophy":
                    newBehaviourContainer.isPrizeTrophy = true;
                    break;

                case "Redeemable":
                    newBehaviourContainer.isRedeemable = true;
                    break;

                case "Soundmachine":
                    newBehaviourContainer.isSoundMachine = true;
                    break;

                case "Soundmachine sample set":
                    newBehaviourContainer.isSoundMachineSampleSet = true;
                    break;
                    #endregion
                }
            }

            editedDefinition.Behaviour = newBehaviourContainer;
            foreach (int definitionID in selectedItemDefinitionIDs)
            {
                editedDefinition.ID = definitionID;
                if (selectedItemDefinitionIDs.Length > 1) // More than one item selected, keep original directory ID/sprite/color/length/width intact
                {
                    itemDefinition oldDefinition = Engine.Game.Items.getItemDefinition(definitionID);
                    if (oldDefinition == null)
                    {
                        continue;
                    }

                    editedDefinition.directoryID = oldDefinition.directoryID;
                    editedDefinition.Sprite      = oldDefinition.Sprite;
                    editedDefinition.Color       = oldDefinition.Color;
                    editedDefinition.Length      = oldDefinition.Length;
                    editedDefinition.Width       = oldDefinition.Width;
                }
                this.saveItemDefinition(editedDefinition);
            }

            this.displayItemDefinitions();
            Engine.Game.Store.loadCataloguePages();

            displayMessageBox("Selected item definitions saved successfully.", MessageBoxIcon.Information);
        }