Пример #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);
        }
Пример #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;
        }
Пример #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;
            }
        }
Пример #4
0
        /* On editor launch */
        public TileEditor(int _tileIndex)
        {
            InitializeComponent();

            typeWall.Checked       = true;
            useageInterior.Checked = true;

            //If in editor, setup pre-existing data
            if (_tileIndex == -1)
            {
                return;
            }
            thisTile  = TileFileInterface.GetData()[_tileIndex];
            tileIndex = _tileIndex;

            tileName.Text          = thisTile.tileName;
            tileDesc.Text          = thisTile.tileDesc;
            isFlammable.Checked    = thisTile.isFlammable;
            isPathable.Checked     = thisTile.isPathable;
            allowProps.Checked     = thisTile.allowProps;
            hideInEditor.Checked   = thisTile.hideInEditor;
            typeWall.Checked       = (thisTile.tileType == 0);
            typeFloor.Checked      = (thisTile.tileType == 1);
            useageInterior.Checked = (thisTile.tileUseage == 0);
            useageExterior.Checked = (thisTile.tileUseage == 1);
            zBias.Value            = thisTile.zBias;

            string formattedTileName = tileName.Text.Trim().ToUpper().Replace(' ', '_');

            LoadSavedSprite(tilePreviewIconUI, Environment.CurrentDirectory + "/" + FilePaths.PathToUnityTileResources + formattedTileName + "/" + "EDITOR_UI.png");
            if (typeFloor.Checked)
            {
                floorSprites.Load(formattedTileName);

                LoadSavedSprite(FLOOR_previewCornerNorthEast, floorSprites.CORNER_NorthEast);
                LoadSavedSprite(FLOOR_previewCornerSouthEast, floorSprites.CORNER_SouthEast);
                LoadSavedSprite(FLOOR_previewCornerNorthWest, floorSprites.CORNER_NorthWest);
                LoadSavedSprite(FLOOR_previewCornerSouthWest, floorSprites.CORNER_SouthWest);

                LoadSavedSprite(FLOOR_previewEdgeNorth, floorSprites.EDGING_North);
                LoadSavedSprite(FLOOR_previewEdgeEast, floorSprites.EDGING_East);
                LoadSavedSprite(FLOOR_previewEdgeSouth, floorSprites.EDGING_South);
                LoadSavedSprite(FLOOR_previewEdgeWest, floorSprites.EDGING_West);

                for (int i = 0; i < floorSprites.Fillers.Count; i++)
                {
                    FLOOR_fillSprites.Items.Add(floorSprites.Fillers[i]);
                }
                if (floorSprites.Fillers.Count > 0)
                {
                    LoadSavedSprite(FLOOR_fillPreview, floorSprites.Fillers[floorSprites.Fillers.Count - 1]);
                }
            }
            else if (typeWall.Checked)
            {
                wallSprites.Load(formattedTileName);

                for (int i = 0; i < wallSprites.Horizontals.Count; i++)
                {
                    WALL_horizontalSprites.Items.Add(wallSprites.Horizontals[i]);
                }
                if (wallSprites.Horizontals.Count > 0)
                {
                    LoadSavedSprite(WALL_horizontalPreview, wallSprites.Horizontals[wallSprites.Horizontals.Count - 1]);
                }

                for (int i = 0; i < wallSprites.Verticals.Count; i++)
                {
                    WALL_verticalSprites.Items.Add(wallSprites.Verticals[i]);
                }
                if (wallSprites.Verticals.Count > 0)
                {
                    LoadSavedSprite(WALL_verticalPreview, wallSprites.Verticals[wallSprites.Verticals.Count - 1]);
                }
            }
        }
Пример #5
0
        /* Save the tile */
        private void saveTile_Click(object sender, EventArgs e)
        {
            //Validation
            if (tileName.Text == "")
            {
                MessageBox.Show("Tile must have a name!", "No tile name.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (tileDesc.Text == "")
            {
                MessageBox.Show("Tile must have a description!", "No tile description.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            bool imageValid = false;

            if (typeFloor.Checked)
            {
                imageValid = (ImageIsValid(FLOOR_previewCornerNorthEast) &&
                              ImageIsValid(FLOOR_previewCornerSouthEast) &&
                              ImageIsValid(FLOOR_previewCornerNorthWest) &&
                              ImageIsValid(FLOOR_previewCornerSouthWest) &&
                              ImageIsValid(FLOOR_previewEdgeNorth) &&
                              ImageIsValid(FLOOR_previewEdgeEast) &&
                              ImageIsValid(FLOOR_previewEdgeSouth) &&
                              ImageIsValid(FLOOR_previewEdgeWest) &&
                              ImageIsValid(FLOOR_fillSprites, FLOOR_fillPreview));
            }
            else if (typeWall.Checked)
            {
                imageValid = (ImageIsValid(WALL_horizontalSprites, WALL_horizontalPreview) &&
                              ImageIsValid(WALL_verticalSprites, WALL_verticalPreview));
            }
            if (!imageValid || !ImageIsValid(tilePreviewIconUI))
            {
                MessageBox.Show("Tile images MUST be square and a division of 200 pixels.\nPlease follow the guidlines for irregular size tiles!", "Invalid tile size.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult shouldDo = MessageBox.Show("Would you like to see an example?", "Example tile sizing offer", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (shouldDo == DialogResult.Yes && File.Exists("TileExample.png"))
                {
                    Process.Start("TileExample.png");
                }
                return;
            }

            //Create and check tile name
            string formattedTileName = tileName.Text.Trim().ToUpper().Replace(' ', '_');

            if (tileIndex == -1)
            {
                for (int i = 0; i < TileFileInterface.GetData().Count; i++)
                {
                    if (TileFileInterface.GetData()[i].tileName == formattedTileName)
                    {
                        MessageBox.Show("Tile name must be unique!", "Name already exists.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
            }
            Directory.CreateDirectory(FilePaths.PathToUnityTileResources + formattedTileName);

            //Copy sprites & save Unity metas
            SaveSprite(tilePreviewIconUI, formattedTileName + "/EDITOR_UI");
            if (typeFloor.Checked)
            {
                //Update/create config
                BinaryWriter writer = new BinaryWriter(File.OpenWrite(FilePaths.PathToUnityStreaming + "TILECONFIGS/" + formattedTileName + ".DWB"));
                writer.Write(0);
                writer.Write(FLOOR_fillSprites.Items.Count);
                writer.Close();

                if (changedSprites)
                {
                    //Write out the corners
                    SaveSprite(FLOOR_previewCornerNorthEast, formattedTileName + "/CORNER_NORTH_EAST");
                    SaveSprite(FLOOR_previewCornerSouthEast, formattedTileName + "/CORNER_SOUTH_EAST");
                    SaveSprite(FLOOR_previewCornerNorthWest, formattedTileName + "/CORNER_NORTH_WEST");
                    SaveSprite(FLOOR_previewCornerSouthWest, formattedTileName + "/CORNER_SOUTH_WEST");

                    //Write out the edges
                    SaveSprite(FLOOR_previewEdgeNorth, formattedTileName + "/EDGE_NORTH");
                    SaveSprite(FLOOR_previewEdgeEast, formattedTileName + "/EDGE_EAST");
                    SaveSprite(FLOOR_previewEdgeSouth, formattedTileName + "/EDGE_SOUTH");
                    SaveSprite(FLOOR_previewEdgeWest, formattedTileName + "/EDGE_WEST");

                    //Write out the fillers
                    for (int i = 0; i < FLOOR_fillSprites.Items.Count; i++)
                    {
                        FLOOR_fillSprites.SelectedIndex = i;
                        SaveSprite(FLOOR_fillPreview, formattedTileName + "/FILL_" + i);
                    }
                }
            }
            else if (typeWall.Checked)
            {
                //Update/create config
                BinaryWriter writer = new BinaryWriter(File.OpenWrite(FilePaths.PathToUnityStreaming + "TILECONFIGS/" + formattedTileName + ".DWB"));
                writer.Write(1);
                writer.Write(WALL_verticalSprites.Items.Count);
                writer.Write(WALL_horizontalSprites.Items.Count);
                writer.Close();

                if (changedSprites)
                {
                    //Write out the actual image files
                    for (int i = 0; i < WALL_verticalSprites.Items.Count; i++)
                    {
                        WALL_verticalSprites.SelectedIndex = i;
                        SaveSprite(WALL_verticalPreview, formattedTileName + "/VERTICAL_" + i);
                    }
                    for (int i = 0; i < WALL_horizontalSprites.Items.Count; i++)
                    {
                        WALL_horizontalSprites.SelectedIndex = i;
                        SaveSprite(WALL_horizontalPreview, formattedTileName + "/HORIZONTAL_" + i);
                    }
                }
            }

            //Save data
            thisTile.tileName     = formattedTileName;
            thisTile.tileDesc     = tileDesc.Text;
            thisTile.isFlammable  = isFlammable.Checked;
            thisTile.isPathable   = isPathable.Checked;
            thisTile.allowProps   = allowProps.Checked;
            thisTile.hideInEditor = hideInEditor.Checked;
            thisTile.tileType     = (Int16)(typeWall.Checked ? 0 : 1);
            thisTile.tileUseage   = (Int16)(useageInterior.Checked ? 0 : 1);
            thisTile.zBias        = (int)zBias.Value;
            if (tileIndex == -1)
            {
                TileFileInterface.GetData().Add(thisTile);
            }
            TileFileInterface.SaveData();

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