コード例 #1
0
ファイル: ServerRepository.cs プロジェクト: nojan1/Mineman
        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>();
    }
コード例 #5
0
    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
ファイル: Init.cs プロジェクト: saddamsial/MobileUO
    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
ファイル: DownloadState.cs プロジェクト: Juzzver/MobileUO
    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>();
    }
コード例 #12
0
    private void OnConfigurationFilesDeleted()
    {
        var config = serverConfigurationEditPresenter.ServerConfigurationToEdit;

        ServerConfigurationModel.DeleteConfigurationFiles(config);
    }
コード例 #13
0
 private void OnConfigurationDeleted()
 {
     ServerConfigurationModel.DeleteConfiguration(serverConfigurationEditPresenter.ServerConfigurationToEdit);
     SwitchToList();
 }
コード例 #14
0
    private void OnAddNewConfigurationButtonClicked()
    {
        var serverConfiguration = ServerConfigurationModel.CreateNewServerConfiguration();

        SetConfigurationAndSwitchToEdit(serverConfiguration);
    }