示例#1
0
        public async Task <Server> UpdateConfiguration(int id, ServerConfigurationModel configurationModel)
        {
            var server = await Get(id);

            var existingProperties = ServerPropertiesSerializer.Deserialize(server.SerializedProperties);
            var mergedProperties   = ServerPropertiesSerializer.Merge(existingProperties, configurationModel.Properties);

            server.SerializedProperties = ServerPropertiesSerializer.Serialize(mergedProperties);
            server.MainPort             = configurationModel.ServerPort;
            server.MemoryAllocationMB   = configurationModel.MemoryAllocationMB;
            server.Description          = configurationModel.Description;
            server.World = _context.Worlds.FirstOrDefault(w => w.ID == configurationModel.WorldID);
            server.Image = _context.Images.FirstOrDefault(i => i.ID == configurationModel.ImageID);

            if (server.Image.SupportsMods && configurationModel.ModIDs != null)
            {
                server.Mods = configurationModel.ModIDs.Select(i => _context.Mods.FirstOrDefault(m => m.ID == i)).ToList();
            }

            server.NeedsRecreate = true;

            _context.Update(server);
            await _context.SaveChangesAsync();

            return(server);
        }
示例#2
0
        public async Task <IActionResult> UpdateConfiguration(int serverId, [FromBody] ServerConfigurationModel configurationModel)
        {
            if (configurationModel == null || !ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var server = await _serverRepository.UpdateConfiguration(serverId, configurationModel);

            return(Ok(server));
        }
示例#3
0
    private void AddSupportedConfigAndGoBack(ServerConfiguration config)
    {
        if (ServerConfigurationModel.IsServerConfigurationNameValid(config.Name) == false)
        {
            //TODO: Show error saying there already is a config with this name, or something
            return;
        }
        var configClone = config.Clone();

        ServerConfigurationModel.AddServerConfiguration(configClone);
        OnBackButtonClicked();
    }
示例#4
0
文件: Init.cs 项目: Juzzver/MobileUO
    private void Awake()
    {
        ConsoleRedirect.Redirect();
        Application.targetFrameRate = 60;

        StateManager.AddState(new BootState());
        StateManager.AddState(new ServerConfigurationState(serverConfigurationUiParent));
        StateManager.AddState(new DownloadState(downloadPresenter));
        StateManager.AddState(new GameState(unityMain));

        ServerConfigurationModel.Initialize();

        StateManager.GoToState <BootState>();
    }
    private void OnConfigurationEditSaved()
    {
        var config = serverConfigurationEditPresenter.ServerConfigurationToEdit;

        if (ServerConfigurationModel.Contains(config) == false)
        {
            //TODO: Check that a config with the same name doesn't exist, or do this in input field validation in ServerConfigurationEditPresenter
            ServerConfigurationModel.AddServerConfiguration(config);
        }
        else
        {
            //Save changes
            ServerConfigurationModel.SaveServerConfigurations();
        }

        SwitchToList();
    }
示例#6
0
文件: Init.cs 项目: VoxelBoy/MobileUO
    private void Awake()
    {
        ConsoleRedirect.Redirect();

        UserPreferences.Initialize();

        StateManager.AddState(new BootState());
        StateManager.AddState(new ServerConfigurationState(serverConfigurationUiParent));
        StateManager.AddState(new DownloadState(downloadPresenter, inGameDebugConsoleCanvas));
        StateManager.AddState(new GameState(clientRunner, errorPresenter, inGameDebugConsoleCanvas));

        Input.simulateMouseWithTouches = false;

        ServerConfigurationModel.Initialize(supportedServerConfigurations);

        StateManager.GoToState <BootState>();

        ExternalStoragePath = GetAndroidExternalFilesDir();
    }
示例#7
0
文件: Init.cs 项目: binff04/MobileUO
    private void Awake()
    {
        ConsoleRedirect.Redirect();

        UserPreferences.TargetFrameRateChanged  += OnTargetFrameRateChanged;
        UserPreferences.TextureFilteringChanged += UpdateTextureFiltering;
        UserPreferences.Initialize();

        StateManager.AddState(new BootState());
        StateManager.AddState(new ServerConfigurationState(serverConfigurationUiParent));
        StateManager.AddState(new DownloadState(downloadPresenter, forceDownloadsInEditor, inGameDebugConsoleCanvas));
        StateManager.AddState(new GameState(unityMain, errorPresenter, inGameDebugConsoleCanvas));

        inGameDebugConsoleCanvas.enabled = false;

        ServerConfigurationModel.Initialize();

        StateManager.GoToState <BootState>();
    }
示例#8
0
    private IEnumerator DownloadFiles()
    {
        var directoryInfo = new DirectoryInfo(pathToSaveFiles);

        if (directoryInfo.Exists == false)
        {
            directoryInfo.Create();
        }

        while (filesToDownload.Count > 0)
        {
            while (concurrentDownloadCounter < MAX_CONCURRENT_DOWNLOADS && filesToDownload.Count > 0)
            {
                var fileName = filesToDownload[0];
                filesToDownload.RemoveAt(0);
                if (downloadAttemptsPerFile.TryGetValue(fileName, out _) == false)
                {
                    downloadAttemptsPerFile[fileName] = 1;
                }

                DownloadFile(fileName);
            }

            UpdateDownloadProgress();

            yield return(null);
        }

        //Wait until final downloads finish
        while (concurrentDownloadCounter > 0)
        {
            UpdateDownloadProgress();
            yield return(null);
        }

        serverConfiguration.AllFilesDownloaded = true;
        ServerConfigurationModel.SaveServerConfigurations();

        StateManager.GoToState <GameState>();
    }
示例#9
0
    private void Awake()
    {
        ConsoleRedirect.Redirect();

        UserPreferences.Initialize();

        StateManager.AddState(new BootState());
        StateManager.AddState(new ServerConfigurationState(serverConfigurationUiParent));
        StateManager.AddState(new DownloadState(downloadPresenter, forceDownloadsInEditor, inGameDebugConsoleCanvas));
        StateManager.AddState(new GameState(clientRunner, errorPresenter, inGameDebugConsoleCanvas));

        if (hideInGameDebugConsoleOnAwake)
        {
            inGameDebugConsoleCanvas.enabled = false;
        }

        Input.simulateMouseWithTouches = false;

        ServerConfigurationModel.Initialize(supportedServerConfigurations);

        StateManager.GoToState <BootState>();
    }
示例#10
0
    private void Awake()
    {
        ConsoleRedirect.Redirect();

        UserPreferences.Initialize();
        UserPreferences.ShowDebugConsole.ValueChanged += OnShowDebugConsoleChanged;
        OnShowDebugConsoleChanged(UserPreferences.ShowDebugConsole.CurrentValue);

        StateManager.AddState(new BootState());
        StateManager.AddState(new ServerConfigurationState(serverConfigurationUiParent));
        StateManager.AddState(new DownloadState(downloadPresenter, inGameDebugConsoleCanvas));
        StateManager.AddState(new GameState(clientRunner, errorPresenter, inGameDebugConsoleCanvas));

        Input.simulateMouseWithTouches = false;

        ServerConfigurationModel.Initialize(supportedServerConfigurations);

        StateManager.GoToState <BootState>();

        //Commented out for now, will be used later once I have an SD card to test with
        //GetAndroidExternalFilesDir();
    }
示例#11
0
    private IEnumerator DownloadFiles(List <string> filesList)
    {
        int index = 0;

        var pathToSaveFiles = serverConfiguration.GetPathToSaveFiles();
        var directoryInfo   = new DirectoryInfo(pathToSaveFiles);

        if (directoryInfo.Exists == false)
        {
            directoryInfo.Create();
        }

        while (index < filesList.Count)
        {
            while (concurrentDownloadCounter < maxConcurrentDownloads && index < filesList.Count)
            {
                var fileName            = filesList[index++];
                var uriBuilder          = new UriBuilder("http", serverConfiguration.FileDownloadServerUrl, 8080, fileName);
                var request             = UnityWebRequest.Get(uriBuilder.Uri);
                var filePath            = Path.Combine(pathToSaveFiles, fileName);
                var fileDownloadHandler = new DownloadHandlerFile(filePath);
                fileDownloadHandler.removeFileOnAbort = true;
                request.downloadHandler = fileDownloadHandler;
                request.SendWebRequest().completed += operation => SingleFileDownloadFinished(request, fileName);
                ++concurrentDownloadCounter;
            }

            yield return(new WaitUntil(() => concurrentDownloadCounter < maxConcurrentDownloads));
        }

        //Wait until final downloads finish
        yield return(new WaitUntil(() => concurrentDownloadCounter == 0));

        serverConfiguration.AllFilesDownloaded = true;
        ServerConfigurationModel.SaveServerConfigurations();

        StateManager.GoToState <GameState>();
    }
    private void OnConfigurationFilesDeleted()
    {
        var config = serverConfigurationEditPresenter.ServerConfigurationToEdit;

        ServerConfigurationModel.DeleteConfigurationFiles(config);
    }
 private void OnConfigurationDeleted()
 {
     ServerConfigurationModel.DeleteConfiguration(serverConfigurationEditPresenter.ServerConfigurationToEdit);
     SwitchToList();
 }
    private void OnAddNewConfigurationButtonClicked()
    {
        var serverConfiguration = ServerConfigurationModel.CreateNewServerConfiguration();

        SetConfigurationAndSwitchToEdit(serverConfiguration);
    }