コード例 #1
0
ファイル: ArgumentsHandler.cs プロジェクト: WildGenie/actools
        private async Task <ArgumentHandleResult> ProcessInputFile(string filename)
        {
            var isDirectory = FileUtils.IsDirectory(filename);

            if (!isDirectory && filename.EndsWith(@".acreplay", StringComparison.OrdinalIgnoreCase) ||
                Path.GetDirectoryName(filename)?.Equals(FileUtils.GetReplaysDirectory(), StringComparison.OrdinalIgnoreCase) == true)
            {
                await GameWrapper.StartReplayAsync(new Game.StartProperties(new Game.ReplayProperties {
                    Filename = filename
                }));

                return(ArgumentHandleResult.Successful);
            }

            if (!isDirectory && filename.EndsWith(@".kn5", StringComparison.OrdinalIgnoreCase))
            {
                await CustomShowroomWrapper.StartAsync(filename);

                return(ArgumentHandleResult.Successful);
            }

            try {
                new InstallAdditionalContentDialog(filename).ShowDialog();
            } catch (Exception e) {
                NonfatalError.Notify(AppStrings.Arguments_CannotInstallAdditionalContent, e);
                return(ArgumentHandleResult.Failed);
            }

            return(ArgumentHandleResult.Successful);
        }
コード例 #2
0
        private static async Task <ArgumentHandleResult> ProcessInputFile(string filename)
        {
            bool isDirectory;

            try {
                if (!FileUtils.Exists(filename))
                {
                    return(ArgumentHandleResult.Failed);
                }
                isDirectory = FileUtils.IsDirectory(filename);
            } catch (Exception) {
                return(ArgumentHandleResult.Failed);
            }

            if (!isDirectory && filename.EndsWith(@".acreplay", StringComparison.OrdinalIgnoreCase) ||
                Path.GetDirectoryName(filename)?.Equals(AcPaths.GetReplaysDirectory(), StringComparison.OrdinalIgnoreCase) == true)
            {
                await GameWrapper.StartReplayAsync(new Game.StartProperties(new Game.ReplayProperties {
                    Filename = filename
                }));

                return(ArgumentHandleResult.Successful);
            }

            if (!isDirectory && filename.EndsWith(@".kn5", StringComparison.OrdinalIgnoreCase))
            {
                await CustomShowroomWrapper.StartAsync(filename);

                return(ArgumentHandleResult.Successful);
            }

            return(ArgumentHandleResult.FailedShow);
        }
コード例 #3
0
        private static async Task <ArgumentHandleResult> ProcessInputFile(string filename)
        {
            bool isDirectory;

            try {
                if (!FileUtils.Exists(filename))
                {
                    return(ArgumentHandleResult.Failed);
                }
                isDirectory = FileUtils.IsDirectory(filename);
            } catch (Exception) {
                return(ArgumentHandleResult.Failed);
            }

            if (!isDirectory && filename.EndsWith(@".acreplay", StringComparison.OrdinalIgnoreCase) ||
                Path.GetDirectoryName(filename)?.Equals(AcPaths.GetReplaysDirectory(), StringComparison.OrdinalIgnoreCase) == true)
            {
                await GameWrapper.StartReplayAsync(new Game.StartProperties(new Game.ReplayProperties {
                    Filename = filename
                }));

                return(ArgumentHandleResult.Successful);
            }

            if (!isDirectory && filename.EndsWith(@".kn5", StringComparison.OrdinalIgnoreCase))
            {
                if ((Keyboard.Modifiers == ModifierKeys.Alt || Keyboard.Modifiers == ModifierKeys.Shift) && SettingsHolder.Common.DeveloperMode)
                {
                    try {
                        Kn5.FbxConverterLocation = PluginsManager.Instance.GetPluginFilename("FbxConverter", "FbxConverter.exe");
                        var kn5         = Kn5.FromFile(filename);
                        var destination = FileUtils.EnsureUnique(Path.Combine(Path.GetDirectoryName(filename) ?? @".",
                                                                              $"unpacked-{Path.GetFileName(filename)}"));
                        var name = kn5.RootNode.Name.StartsWith(@"FBX: ") ? kn5.RootNode.Name.Substring(5) :
                                   @"model.fbx";
                        Directory.CreateDirectory(destination);
                        await kn5.ExportFbxWithIniAsync(Path.Combine(destination, name));

                        var textures = Path.Combine(destination, "texture");
                        Directory.CreateDirectory(textures);
                        await kn5.ExportTexturesAsync(textures);

                        Process.Start(destination);
                    } catch (Exception e) {
                        Logging.Error(e);
                        return(ArgumentHandleResult.FailedShow);
                    }
                }
                else
                {
                    await CustomShowroomWrapper.StartAsync(filename);
                }

                return(ArgumentHandleResult.Successful);
            }

            return(ArgumentHandleResult.FailedShow);
        }
コード例 #4
0
 protected override void OnItemDoubleClick(AcObjectNew obj)
 {
     if (obj is ReplayObject replay)
     {
         GameWrapper.StartReplayAsync(new Game.StartProperties(new Game.ReplayProperties {
             Name               = replay.Id,
             TrackId            = replay.TrackId,
             TrackConfiguration = replay.TrackConfiguration,
             WeatherId          = replay.WeatherId
         }));
     }
 }
コード例 #5
0
        protected override void OnItemDoubleClick(AcObjectNew obj)
        {
            var replay = obj as ReplayObject;

            if (replay == null)
            {
                return;
            }

            GameWrapper.StartReplayAsync(new Game.StartProperties(new Game.ReplayProperties {
                Name               = replay.Id,
                TrackId            = replay.TrackId,
                TrackConfiguration = replay.TrackConfiguration,
                WeatherId          = replay.WeatherId
            }));
        }