Exemple #1
0
        protected override async Task <IProject> ReadFromLocationAsync(string location)
        {
            try
            {
                var fi = new FileInfo(location);
                if (!fi.Exists)
                {
                    return(null);
                }

                EditorProject project = null;
                switch (fi.Extension)
                {
                case ".w3modproj":
                {
                    project = new Tw3Project(location);
                    MainController.Get().ActiveMod = project.Data;
                    await MainController.SetGame(new Tw3Controller()).ContinueWith(t => _notificationService.Success("Project " + Path.GetFileNameWithoutExtension(location) +
                                                                                                                     " loaded!"), TaskContinuationOptions.OnlyOnRanToCompletion);

                    break;
                }

                case ".cpmodproj":
                {
                    project = new Cp77Project(location);
                    MainController.Get().ActiveMod = project.Data;
                    await MainController.SetGame(new Cp77Controller()).ContinueWith(t => _notificationService.Success("Project " + Path.GetFileNameWithoutExtension(location) + " loaded!"), TaskContinuationOptions.OnlyOnRanToCompletion);

                    break;
                }
                }

                return(await Task.FromResult <IProject>(project));
            }
            catch (IOException ex)
            {
                _notificationService.Error(ex.Message);
            }

            return(null);
        }
Exemple #2
0
        protected override Task <IProject> ReadFromLocationAsync(string location)
        {
            try
            {
                var fi = new FileInfo(location);
                if (!fi.Exists)
                {
                    return(null);
                }

                EditorProject project = null;
                switch (fi.Extension)
                {
                case ".w3modproj":
                {
                    project = new Tw3Project(location);
                    MainController.Get().ActiveMod = project.Data;
                    MainController.Get().SetGame(new Tw3Controller());
                    break;
                }

                case ".cpmodproj":
                {
                    project = new Cp77Project(location);
                    MainController.Get().ActiveMod = project.Data;
                    MainController.Get().SetGame(new Cp77Controller());
                    break;
                }
                }
                _notificationService.ShowNotification("Success", "Project " + Path.GetFileNameWithoutExtension(location) +
                                                      " loaded!");
                return(Task.FromResult <IProject>(project));
            } catch (IOException ex)
            {
                _notificationService.ShowNotification("Could not open file", ex.Message);
            }

            return(null);
        }
        protected override async void Execute(object parameter)
        {
            try
            {
                var location  = parameter as string;
                var viewModel = _serviceLocator.ResolveType <ProjectWizardViewModel>();

                var r = await _uIVisualizerService.ShowAsync(viewModel, (sender, args) =>
                {
                    if (args.DataContext is not ProjectWizardViewModel res)
                    {
                        return;
                    }

                    var result = args.Result;
                    if (!result.HasValue || !result.Value)
                    {
                        return;
                    }

                    location = Path.Combine(res.ProjectPath, res.ProjectName);
                    var type = res.ProjectType.First();
                    if (type.Equals(ProjectWizardViewModel.WitcherGameName))
                    {
                        location += ".w3modproj";
                    }
                    else if (type.Equals(ProjectWizardViewModel.CyberpunkGameName))
                    {
                        location += ".cpmodproj";
                    }
                });

                if (string.IsNullOrWhiteSpace(location))
                {
                    return;
                }

                RibbonViewModel.GlobalRibbonVM.StartScreenShown = false;
                RibbonViewModel.GlobalRibbonVM.BackstageIsOpen  = false;
                using (_pleaseWaitService.PushInScope())
                {
                    switch (Path.GetExtension(location))
                    {
                    case ".w3modproj":
                    {
                        var np = new Tw3Project(location)
                        {
                            Name    = Path.GetFileNameWithoutExtension(location),
                            Author  = "WolvenKit",
                            Email   = "",
                            Version = "1.0"
                        };
                        _projectManager.ActiveProject = np;
                        await _projectManager.SaveAsync();

                        np.CreateDefaultDirectories();
                        //saveProjectImg(location);
                        break;
                    }

                    case ".cpmodproj":
                    {
                        var np = new Cp77Project(location)
                        {
                            Name    = Path.GetFileNameWithoutExtension(location),
                            Author  = "WolvenKit",
                            Email   = "",
                            Version = "1.0"
                        };
                        _projectManager.ActiveProject = np;
                        await _projectManager.SaveAsync();

                        np.CreateDefaultDirectories();
                        //saveProjectImg(location);
                        break;
                    }

                    default:
                        _loggerService.LogString("Invalid project path!", Logtype.Error);
                        break;
                    }
                }

                await _projectManager.LoadAsync(location);

                switch (Path.GetExtension(location))
                {
                case ".w3modproj":
                    await _tw3Controller.HandleStartup().ContinueWith(t =>
                    {
                        _notificationService.Success(
                            "Project " + Path.GetFileNameWithoutExtension(location) +
                            " loaded!");
                    }, TaskContinuationOptions.OnlyOnRanToCompletion);

                    break;

                case ".cpmodproj":
                    await _cp77Controller.HandleStartup().ContinueWith(
                        t =>
                    {
                        _notificationService.Success("Project " +
                                                     Path.GetFileNameWithoutExtension(location) +
                                                     " loaded!");
                    },
                        TaskContinuationOptions.OnlyOnRanToCompletion);

                    break;

                default:
                    break;
                }
            }
        /// <summary>
        /// Scoops up the packed files and packs it into a zip in a hierarchy that can be easily unzipped
        /// even if the user is not using our manager
        /// Package.wkp (zip)
        /// |---archive\pc\*.archive
        /// |
        /// |---wkpmeta\<modname>\<modname>.wkmeta (json) + icon
        /// |
        /// |---r6\cache\tweakdbpatches\<modname>.tweakdbpatch
        ///
        /// </summary>
        /// <param name="project">Project to pack</param>
        public void WitcherPublishStrategy(Tw3Project project) =>
        //TODO: I am not sure how to do this until we have packing

        Logger.Write("Packing Witcher 3 mod complete.", LogLevel.Info);
Exemple #5
0
        protected override async void Execute(object parameter)
        {
            try
            {
                var location = parameter as string;
                var filter   = "Witcher 3 Project (*.w3modproj)|*.w3modproj| Cyberpunk 2077 Project (*.cpmodproj)|*.cpmodproj";
                if (location == null && parameter is ProjectWizardModel.TypeAndPath)
                {
                    var res = parameter as ProjectWizardModel.TypeAndPath;
                    location = res.Path;
                    if (res.Type == ProjectWizardModel.WitcherGameName)
                    {
                        filter = "Witcher 3 Project (*.w3modproj)|*.w3modproj";
                    }
                    else if (res.Type == ProjectWizardModel.CyberpunkGameName)
                    {
                        filter = "Cyberpunk 2077 Project (*.cpmodproj)|*.cpmodproj";
                    }
                }

                var result = await _saveFileService.DetermineFileAsync(new DetermineSaveFileContext()
                {
                    Filter           = filter,
                    Title            = "Please select a location to save your WolvenKit project",
                    InitialDirectory = location,
                });

                if (result.Result)
                {
                    location = result.FileName;
                }

                if (!string.IsNullOrWhiteSpace(location) && result.Result)
                {
                    using (_pleaseWaitService.PushInScope())
                    {
                        switch (Path.GetExtension(location))
                        {
                        case ".w3modproj":
                        {
                            var np = new Tw3Project(location)
                            {
                                Name = Path.GetFileNameWithoutExtension(location),
                                Data = new W3Mod()
                                {
                                    FileName = location,
                                    Name     = Path.GetFileNameWithoutExtension(location),
                                    Author   = "WolvenKit",
                                    Email    = "",
                                    Version  = "1.0"
                                }
                            };
                            np.Save(location);
                            np.CreateDefaultDirectories();
                            break;
                        }

                        case ".cpmodproj":
                        {
                            var np = new Cp77Project(location)
                            {
                                Name = Path.GetFileNameWithoutExtension(location),
                                Data = new CP77Mod()
                                {
                                    FileName = location,
                                    Name     = Path.GetFileNameWithoutExtension(location),
                                    Author   = "WolvenKit",
                                    Email    = "",
                                    Version  = "1.0"
                                }
                            };
                            np.Save(location);
                            np.CreateDefaultDirectories();
                            break;
                        }

                        default:
                            _loggerService.LogString("Invalid project path!", Logtype.Error);
                            break;
                        }
                    }
                    await _projectManager.LoadAsync(location);
                }
            }
            catch (Exception ex)
            {
                _loggerService.LogString(ex.Message, Logtype.Error);
                _loggerService.LogString("Failed to create a new project!", Logtype.Error);
            }

            OnCommandCompleted?.Invoke();
        }
Exemple #6
0
        protected override async void Execute(object parameter)
        {
            try
            {
                var location = parameter as string;

                var result = await _saveFileService.DetermineFileAsync(new DetermineSaveFileContext()
                {
                    Filter = "Witcher 3 Project (*.w3modproj)|*.w3modproj| Cyberpunk 2077 Project (*.cpmodproj)|*.cpmodproj",
                    Title  = "Please select a location to save your WolvenKit project"
                });

                if (result.Result)
                {
                    location = result.FileName;
                }

                if (!string.IsNullOrWhiteSpace(location))
                {
                    using (_pleaseWaitService.PushInScope())
                    {
                        switch (Path.GetExtension(location))
                        {
                        case ".w3modproj":
                        {
                            var np = new Tw3Project(location)
                            {
                                Name = Path.GetFileNameWithoutExtension(location),
                                Data = new W3Mod()
                                {
                                    FileName = location,
                                    Name     = Path.GetFileNameWithoutExtension(location),
                                    Author   = "WolvenKit",
                                    Email    = "",
                                    Version  = "1.0"
                                }
                            };
                            np.Save(location);
                            np.CreateDefaultDirectories();
                            break;
                        }

                        case ".cpmodproj":
                        {
                            var np = new Cp77Project(location)
                            {
                                Name = Path.GetFileNameWithoutExtension(location),
                                Data = new CP77Mod()
                                {
                                    FileName = location,
                                    Name     = Path.GetFileNameWithoutExtension(location),
                                    Author   = "WolvenKit",
                                    Email    = "",
                                    Version  = "1.0"
                                }
                            };
                            np.Save(location);
                            np.CreateDefaultDirectories();
                            break;
                        }

                        default:
                            _loggerService.LogString("Invalid project path!", Logtype.Error);
                            break;
                        }
                    }
                    await _projectManager.LoadAsync(location);
                }
            }
            catch (Exception ex)
            {
                _loggerService.LogString("Failed to create a new project!", Logtype.Error);
            }
        }