private void DeleteWorld(LocalWorlds.LocalWorldsParam info)
        {
            try
            {
                //Try to delete the Server directory
                if (Directory.Exists(info.WorldServerRootPath.FullName))
                {
                    Directory.Delete(info.WorldServerRootPath.FullName, true);
                }

                //Try to delete the Client directory
                if (Directory.Exists(info.WorldClientRootPath.FullName))
                {
                    Directory.Delete(info.WorldClientRootPath.FullName, true);
                }

                //Recreate the list of all existing Worlds, as one as been deleted
                LocalWorlds.LocalWorldsParams = LocalWorlds.GetAllSinglePlayerWorldsParams(_vars.ApplicationDataPath);

                RefreshWorldListAsync();
                _currentWorldParameter.Clear();
            }
            catch (Exception e)
            {
                logger.Error("Error while trying to delete the files from the {0} world : {1}", info.WorldParameters.WorldName, e.Message);
                throw;
            }
        }
Exemple #2
0
        //[DebuggerStepThrough]
        private void BtCreate_Pressed(object sender, EventArgs e)
        {
            _currentWorldParameter.Clear();
            //Do parameters validation check.
            if ((string.IsNullOrEmpty(_inputWorldName.Text) ||
                 string.IsNullOrWhiteSpace(_inputWorldName.Text) ||
                 string.IsNullOrEmpty(_inputSeedName.Text) ||
                 string.IsNullOrEmpty(_inputSeedName.Text)) == false)
            {
                //Validate the Name as Directory
                try
                {
                    //Check if this world is not existing
                    if (Directory.Exists(Path.Combine(LocalWorlds.GetSinglePlayerServerRootPath(_vars.ApplicationDataPath), _inputWorldName.Text)) == false)
                    {
                        //Assign to currentWorldParameters the news parameters
                        _currentWorldParameter.WorldName     = _inputWorldName.Text;
                        _currentWorldParameter.SeedName      = _inputSeedName.Text;
                        _currentWorldParameter.Configuration = GetConfigurationObject();

                        //Reset field values
                        _inputWorldName.Text = string.Empty;
                        _inputSeedName.Text  = string.Empty;
                    }
                    else
                    {
                        _guiManager.MessageBox("World's forlder exists. Select different name.", "Error");
                        return;
                    }
                }
                catch (Exception error)
                {
                    logger.Error("Error while loading the configuration file : {0}", error);
                    _guiManager.MessageBox("Unable to load the configuration: " + error.Message);
                    return;
                }
            }

            if (_currentWorldParameter.WorldName == null)
            {
                _guiManager.MessageBox("World parameter(s) incorrect", "Error");
            }
        }
 private void RefreshWorldList()
 {
     LocalWorlds.LocalWorldsParams = LocalWorlds.GetAllSinglePlayerWorldsParams(_vars.ApplicationDataPath);
     NeedShowResults = true;
 }