예제 #1
0
        /* Save the new level */
        private void saveLevel_Click(object sender, EventArgs e)
        {
            if (levelName.Text == "")
            {
                MessageBox.Show("Level must have a name!", "No level name.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            for (int i = 0; i < LevelFile.GetData().Count; i++)
            {
                if (LevelFile.GetData()[i].levelName == levelName.Text)
                {
                    MessageBox.Show("Level name must be unique!", "Level name already exists.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            string pathToEnv = "ENV/PRODUCTION/" + levelName.Text.Trim().ToUpper().Replace(' ', '_') + "/";

            LevelFile.GetData().Add(new Level(levelName.Text, "DATA/" + pathToEnv, (LevelType)levelType.SelectedIndex));
            LevelFile.SaveData();

            Directory.CreateDirectory(pathToEnv);
            File.WriteAllBytes(pathToEnv + "COMMANDS.BIN", Properties.Resources.COMMANDS_BIN);
            File.WriteAllBytes(pathToEnv + "COMMANDS.JSON", Properties.Resources.COMMANDS_JSON);
            ModelsFile.GetFiles().Clear();
            ModelsFile.Save(pathToEnv);
            TexturesFile.GetFiles().Clear();
            TexturesFile.Save(pathToEnv);

            MessageBox.Show("Saved!", "Complete.", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }
예제 #2
0
 private void ReloadList()
 {
     levelList.Items.Clear();
     LevelFile.LoadData();
     foreach (Level level in LevelFile.GetData())
     {
         levelList.Items.Add(level.levelName);
     }
 }
예제 #3
0
        /* Manage assets for a selected existing level */
        private void manageLevel_Click(object sender, EventArgs e)
        {
            if (levelList.SelectedIndex == -1)
            {
                return;
            }

            AssetManager assetEditor = new AssetManager(LevelFile.GetData()[levelList.SelectedIndex].levelPath);

            assetEditor.FormClosed += new FormClosedEventHandler(ReloadList);
            assetEditor.Show();
        }
예제 #4
0
        /* Delete a selected level */
        private void deleteLevel_Click(object sender, EventArgs e)
        {
            if (levelList.SelectedIndex == -1)
            {
                return;
            }
            DialogResult shouldDo = MessageBox.Show("Are you sure you wish to delete this level?", "Confirmation...", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (shouldDo != DialogResult.Yes)
            {
                return;
            }

            Level toRemove = LevelFile.GetData()[levelList.SelectedIndex];

            LevelFile.GetData().Remove(toRemove);
            if (toRemove.levelPath.Substring(0, 5) == "DATA/")
            {
                toRemove.levelPath = toRemove.levelPath.Substring(5);
            }
            Directory.Delete(toRemove.levelPath, true);

            MessageBox.Show("Successfully deleted!", "Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }