Exemplo n.º 1
0
        /* Delete selected */
        private void deleteInstance_Click(object sender, EventArgs e)
        {
            if (instanceList.SelectedIndex == -1)
            {
                return;
            }
            DialogResult shouldDo = MessageBox.Show("Are you sure you wish to delete this " + loadedTypeString + "?\nDeleting a " + loadedTypeString + " can have SERIOUS implications.\nEdit this " + loadedTypeString + " and tag as deprecated instead!", "Confirmation...", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (shouldDo != DialogResult.Yes)
            {
                return;
            }
            if (Directory.Exists(FilePaths.PathToUnityPropResources + instanceList.Items[instanceList.SelectedIndex] + "/"))
            {
                Directory.Delete(FilePaths.PathToUnityPropResources + instanceList.Items[instanceList.SelectedIndex] + "/", true);
            }
            if (Directory.Exists(FilePaths.PathToUnityStreaming + folderPath + "/" + instanceList.Items[instanceList.SelectedIndex] + "/"))
            {
                Directory.Delete(FilePaths.PathToUnityStreaming + folderPath + "/" + instanceList.Items[instanceList.SelectedIndex] + "/", true);
            }
            switch (loadedType)
            {
            case ManagerType.PROPS:
                PropFileInterface.RemoveDataAt(instanceList.SelectedIndex);
                PropFileInterface.SaveData();
                break;

            case ManagerType.TILES:
                TileFileInterface.RemoveDataAt(instanceList.SelectedIndex);
                TileFileInterface.SaveData();
                break;
            }
            ReloadList();
            MessageBox.Show(loadedTypeString[0].ToString().ToUpper() + loadedTypeString.Substring(1) + " deleted!", "Complete.", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemplo n.º 2
0
        /* Show preview */
        private void instanceList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (instanceList.SelectedIndex == -1)
            {
                return;
            }

            DataStruct thisInstanceSelected = new DataStruct();

            switch (loadedType)
            {
            case ManagerType.PROPS:
                thisInstanceSelected = PropFileInterface.GetData()[instanceList.SelectedIndex];
                break;

            case ManagerType.TILES:
                thisInstanceSelected = TileFileInterface.GetData()[instanceList.SelectedIndex];
                break;
            }
            isHidden.Checked = thisInstanceSelected.hideInEditor;
        }
Exemplo n.º 3
0
        private void ReloadList()
        {
            instanceList.Items.Clear();
            switch (loadedType)
            {
            case ManagerType.PROPS:
                PropFileInterface.LoadData();
                foreach (PropData prop in PropFileInterface.GetData())
                {
                    instanceList.Items.Add(prop.propName);
                }
                break;

            case ManagerType.TILES:
                TileFileInterface.LoadData();
                foreach (TileData tile in TileFileInterface.GetData())
                {
                    instanceList.Items.Add(tile.tileName);
                }
                break;
            }
        }
Exemplo n.º 4
0
        /* On editor launch */
        public PropEditor(int _propIndex)
        {
            InitializeComponent();

            for (int i = 0; i < PropParams.waypointTypes.Length; i++)
            {
                waypointFor.Items.Add(PropParams.waypointTypes[i]);
            }
            for (int i = 0; i < PropParams.poiTypes.Length; i++)
            {
                poiType.Items.Add(PropParams.poiTypes[i]);
            }

            //If in editor, setup pre-existing data
            if (_propIndex == -1)
            {
                return;
            }
            thisProp  = PropFileInterface.GetData()[_propIndex];
            propIndex = _propIndex;

            propName.Text      = thisProp.propName;
            propDesc.Text      = thisProp.propDesc;
            isWaypoint.Checked = thisProp.isWaypoint;
            WaypointCheckChange();
            isStartPoint.Checked       = (thisProp.waypointType == 0);
            isMidPoint.Checked         = (thisProp.waypointType == 1);
            isEndPoint.Checked         = (thisProp.waypointType == 2);
            waypointFor.SelectedIndex  = thisProp.waypointFor;
            isEvent.Checked            = thisProp.isEventSpawn;
            eventScriptName.Text       = thisProp.eventType;
            isPOI.Checked              = thisProp.isPOI;
            poiType.SelectedIndex      = thisProp.poiType;
            poiGoonCount.Value         = thisProp.poiGoonCount;
            useageInterior.Checked     = thisProp.isInside;
            useageExterior.Checked     = !thisProp.isInside;
            makeTileUnpathable.Checked = thisProp.makesTileUnpathable;
            hideInEditor.Checked       = thisProp.hideInEditor;
            zBias.Value = thisProp.zBias;

            string formattedPropName = propName.Text.Trim().ToUpper().Replace(' ', '_');

            propSprites.Front = Environment.CurrentDirectory + "/" + FilePaths.PathToUnityPropResources + formattedPropName + "/FRONT_FACING.png";
            LoadSavedSprite(tilePreviewFrontFacing, propSprites.Front);
            frontSpriteInUse.Checked = !(tilePreviewFrontFacing.Image == null);
            propSprites.Left         = Environment.CurrentDirectory + "/" + FilePaths.PathToUnityPropResources + formattedPropName + "/LEFT_FACING.png";
            LoadSavedSprite(tilePreviewLeftFacing, propSprites.Left);
            leftSpriteInUse.Checked = !(tilePreviewLeftFacing.Image == null);
            propSprites.Right       = Environment.CurrentDirectory + "/" + FilePaths.PathToUnityPropResources + formattedPropName + "/RIGHT_FACING.png";
            LoadSavedSprite(tilePreviewRightFacing, propSprites.Right);
            rightSpriteInUse.Checked = !(tilePreviewRightFacing.Image == null);
            propSprites.Back         = Environment.CurrentDirectory + "/" + FilePaths.PathToUnityPropResources + formattedPropName + "/BACK_FACING.png";
            LoadSavedSprite(tilePreviewBackFacing, propSprites.Back);
            backSpriteInUse.Checked = !(tilePreviewBackFacing.Image == null);
            propSprites.EditorUI    = Environment.CurrentDirectory + "/" + FilePaths.PathToUnityPropResources + formattedPropName + "/EDITOR_UI.png";
            LoadSavedSprite(tilePreviewIconUI, propSprites.EditorUI);

            if (frontSpriteInUse.Checked)
            {
                NESW_CalculateFromSprite(tilePreviewFrontFacing, frontNorthCoverage, frontEastCoverage, frontSouthCoverage, frontWestCoverage, true, "FRONT_FACING");
            }
            if (leftSpriteInUse.Checked)
            {
                NESW_CalculateFromSprite(tilePreviewLeftFacing, leftNorthCoverage, leftEastCoverage, leftSouthCoverage, leftWestCoverage, true, "LEFT_FACING");
            }
            if (backSpriteInUse.Checked)
            {
                NESW_CalculateFromSprite(tilePreviewBackFacing, backNorthCoverage, backEastCoverage, backSouthCoverage, backWestCoverage, true, "BACK_FACING");
            }
            if (rightSpriteInUse.Checked)
            {
                NESW_CalculateFromSprite(tilePreviewRightFacing, rightNorthCoverage, rightEastCoverage, rightSouthCoverage, rightWestCoverage, true, "RIGHT_FACING");
            }

            propName.ReadOnly = true;
        }
Exemplo n.º 5
0
        /* Save the prop */
        private void saveProp_Click(object sender, EventArgs e)
        {
            //Validation
            if (propName.Text == "")
            {
                MessageBox.Show("Prop must have a name!", "No prop name.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (propDesc.Text == "")
            {
                MessageBox.Show("Prop must have a description!", "No prop description.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (isWaypoint.Checked && (!(isStartPoint.Checked || isMidPoint.Checked || isEndPoint.Checked) || waypointFor.SelectedIndex == 0))
            {
                MessageBox.Show("Waypoint data must all be selected if waypoint!", "Missing waypoint data.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (isEvent.Checked && eventScriptName.Text == "")
            {
                MessageBox.Show("Enter a script class name, or uncheck scripted object checkbox!", "Invalid scripted prop setup.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (!ImageIsValid(tilePreviewFrontFacing, frontSpriteInUse.Checked) ||
                !ImageIsValid(tilePreviewLeftFacing, leftSpriteInUse.Checked) ||
                !ImageIsValid(tilePreviewRightFacing, rightSpriteInUse.Checked) ||
                !ImageIsValid(tilePreviewBackFacing, backSpriteInUse.Checked))
            {
                MessageBox.Show("Prop sprites MUST be square and a division of 200 pixels.\nPlease follow the guidlines for irregular size props!", "Invalid prop size.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult shouldDo = MessageBox.Show("Would you like to see an example?", "Example prop sizing offer", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (shouldDo == DialogResult.Yes && File.Exists("TileExample.png"))
                {
                    Process.Start("TileExample.png");
                }
                return;
            }
            if (tilePreviewIconUI.Image == null || (tilePreviewIconUI.Image.Width != tilePreviewIconUI.Image.Height))
            {
                MessageBox.Show("UI sprite not assigned, or is not square!", "Invalid UI sprite.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (!frontSpriteInUse.Checked && !leftSpriteInUse.Checked && !rightSpriteInUse.Checked && !backSpriteInUse.Checked)
            {
                MessageBox.Show("Prop requires at least one sprite!", "No in-use sprites.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if ((frontSpriteInUse.Checked && tilePreviewFrontFacing.Image == null) ||
                (leftSpriteInUse.Checked && tilePreviewLeftFacing.Image == null) ||
                (rightSpriteInUse.Checked && tilePreviewRightFacing.Image == null) ||
                (backSpriteInUse.Checked && tilePreviewBackFacing.Image == null))
            {
                MessageBox.Show("An in-use sprite has been unassigned!", "Unassigned sprite.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //Create and check prop name
            string formattedPropName = propName.Text.Trim().ToUpper().Replace(' ', '_');

            if (propIndex == -1)
            {
                for (int i = 0; i < PropFileInterface.GetData().Count; i++)
                {
                    if (PropFileInterface.GetData()[i].propName == formattedPropName)
                    {
                        MessageBox.Show("Prop name must be unique!", "Prop already exists.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
            }
            Directory.CreateDirectory(FilePaths.PathToUnityPropResources + formattedPropName);

            //Save sprites
            spriteBounds.Clear();
            if (frontSpriteInUse.Checked)
            {
                SaveSprite(tilePreviewFrontFacing, formattedPropName + "/FRONT_FACING", true, frontNorthCoverage.Value, frontEastCoverage.Value, frontSouthCoverage.Value, frontWestCoverage.Value);
            }
            if (leftSpriteInUse.Checked)
            {
                SaveSprite(tilePreviewLeftFacing, formattedPropName + "/LEFT_FACING", true, leftNorthCoverage.Value, leftEastCoverage.Value, leftSouthCoverage.Value, leftWestCoverage.Value);
            }
            if (rightSpriteInUse.Checked)
            {
                SaveSprite(tilePreviewRightFacing, formattedPropName + "/RIGHT_FACING", true, rightNorthCoverage.Value, rightEastCoverage.Value, rightSouthCoverage.Value, rightWestCoverage.Value);
            }
            if (backSpriteInUse.Checked)
            {
                SaveSprite(tilePreviewBackFacing, formattedPropName + "/BACK_FACING", true, backNorthCoverage.Value, backEastCoverage.Value, backSouthCoverage.Value, backWestCoverage.Value);
            }
            SaveSprite(tilePreviewIconUI, formattedPropName + "/EDITOR_UI");

            //Work out complete bounds from all rotations
            SpriteBounds allBounds = new SpriteBounds();

            for (int i = 0; i < spriteBounds.Count; i++)
            {
                if (allBounds.from_origin_north < spriteBounds[i].from_origin_north)
                {
                    allBounds.from_origin_north = spriteBounds[i].from_origin_north;
                }
                if (allBounds.from_origin_east < spriteBounds[i].from_origin_east)
                {
                    allBounds.from_origin_east = spriteBounds[i].from_origin_east;
                }
                if (allBounds.from_origin_south < spriteBounds[i].from_origin_south)
                {
                    allBounds.from_origin_south = spriteBounds[i].from_origin_south;
                }
                if (allBounds.from_origin_west < spriteBounds[i].from_origin_west)
                {
                    allBounds.from_origin_west = spriteBounds[i].from_origin_west;
                }
            }
            SpriteAnalysis.SaveData(FilePaths.PathToUnityStreaming + "PROPCONFIGS/" + formattedPropName + "/" + formattedPropName + ".dwb", allBounds);

            //Save data
            thisProp.propName   = formattedPropName;
            thisProp.propDesc   = propDesc.Text;
            thisProp.isWaypoint = isWaypoint.Checked;
            if (thisProp.isWaypoint)
            {
                thisProp.waypointType = (Int16)((isStartPoint.Checked) ? 0 : (isMidPoint.Checked) ? 1 : (isEndPoint.Checked) ? 2 : -1);
                thisProp.waypointFor  = (Int16)waypointFor.SelectedIndex;
            }
            thisProp.isEventSpawn = isEvent.Checked;
            if (thisProp.isEventSpawn)
            {
                thisProp.eventType = eventScriptName.Text;
            }
            thisProp.isPOI = isPOI.Checked;
            if (thisProp.isPOI)
            {
                thisProp.poiType      = (Int16)poiType.SelectedIndex;
                thisProp.poiGoonCount = (int)poiGoonCount.Value;
            }
            thisProp.isInside            = useageInterior.Checked;
            thisProp.makesTileUnpathable = makeTileUnpathable.Checked;
            thisProp.hideInEditor        = hideInEditor.Checked;
            thisProp.zBias = (int)zBias.Value;
            if (propIndex == -1)
            {
                PropFileInterface.GetData().Add(thisProp);
            }
            PropFileInterface.SaveData();

            MessageBox.Show("Saved!", "Complete.", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }