├── .github ├── CODEOWNERS ├── templates │ ├── BuildAndTest │ │ └── action.yml │ └── ReleaseAndPublish │ │ └── action.yml └── workflows │ ├── PR.yml │ ├── ReleaseVersion.yml │ └── UpdateVersion.yml ├── .gitignore ├── .gitmodules ├── .idea └── .idea.PenumbraModForwarder │ └── .idea │ ├── .gitignore │ ├── encodings.xml │ ├── git_toolbox_blame.xml │ ├── indexLayout.xml │ └── vcs.xml ├── .run └── Publish PenumbraModForwarder to folder.run.xml ├── PenumbraModForwarder.Common ├── Interfaces │ ├── IAdminService.cs │ ├── IArchiveHelperService.cs │ ├── IArkService.cs │ ├── IAssociateFileTypeService.cs │ ├── IConfigurationService.cs │ ├── IErrorWindowService.cs │ ├── IFileHandlerService.cs │ ├── IFileSelector.cs │ ├── IFileWatcher.cs │ ├── IPenumbraApi.cs │ ├── IPenumbraInstallerService.cs │ ├── IProcessHelperService.cs │ ├── IProgressWindowService.cs │ ├── IRegistryHelper.cs │ ├── ISystemTrayManager.cs │ └── ITexToolsHelper.cs ├── Interop │ └── Imports.cs ├── Models │ ├── AdvancedConfigrationModel.cs │ ├── ArkModel.cs │ ├── ConfigurationModel.cs │ ├── ExtractionOperation.cs │ ├── FileDownloadInfo.cs │ ├── MappingProfile.cs │ └── OldConfigurationModel.cs ├── PenumbraModForwarder.Common.csproj └── Services │ ├── ArchiveHelperService.cs │ ├── ArkService.cs │ ├── AssociateFileTypesService.cs │ ├── ConfigurationService.cs │ ├── FileHandlerService.cs │ ├── FileWatcher.cs │ ├── PenumbraApi.cs │ ├── PenumbraInstallerService.cs │ ├── ProcessHelperService.cs │ ├── RegistryHelper.cs │ └── TexToolsHelper.cs ├── PenumbraModForwarder.Test ├── PenumbraModForwarder.Test.csproj └── Services │ ├── ArchiveHelperTests.cs │ └── ConfigurationTest.cs ├── PenumbraModForwarder.UI ├── Extensions │ ├── ServiceExtensions.cs │ └── WindowFlash.cs ├── FodyWeavers.xml ├── Interfaces │ ├── IResourceManager.cs │ ├── IShortcutService.cs │ ├── IStartupService.cs │ └── IUpdateService.cs ├── Models │ └── FileItem.cs ├── PenumbraModForwarder.UI.csproj ├── Program.cs ├── Resources │ ├── PMFI.ico │ ├── ffxiv2-1.png │ └── icon.png ├── Services │ ├── AdminService.cs │ ├── ErrorWindowService.cs │ ├── FileSelector.cs │ ├── ProgressWindowService.cs │ ├── ResourceManager.cs │ ├── ShortcutService.cs │ ├── StartupService.cs │ ├── SystemTrayManager.cs │ └── UpdateService.cs ├── ViewModels │ ├── ErrorWindowViewModel.cs │ ├── FileSelectViewModel.cs │ ├── MainWindowViewModel.cs │ └── ProgressWindowViewModel.cs └── Views │ ├── ErrorWindow.Designer.cs │ ├── ErrorWindow.cs │ ├── ErrorWindow.resx │ ├── FileSelect.Designer.cs │ ├── FileSelect.cs │ ├── FileSelect.resx │ ├── MainWindow.Designer.cs │ ├── MainWindow.cs │ ├── MainWindow.resx │ ├── ProgressWindow.Designer.cs │ ├── ProgressWindow.cs │ └── ProgressWindow.resx ├── PenumbraModForwarder.sln ├── README.md ├── repo.json └── update.xml /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @ErrorDodo @Sebane1 2 | 3 | /.github/ @ErrorDodo 4 | 5 | *.yml @ErrorDodo -------------------------------------------------------------------------------- /.github/templates/BuildAndTest/action.yml: -------------------------------------------------------------------------------- 1 | name: "Build and Test" 2 | description: "Build and test on .NET 9" 3 | 4 | runs: 5 | using: "composite" 6 | steps: 7 | - name: Checkout 8 | uses: actions/checkout@v3 9 | 10 | - name: Setup .NET 11 | uses: actions/setup-dotnet@v4 12 | with: 13 | dotnet-version: '9.x.x' 14 | 15 | - name: Restore Dependencies 16 | run: dotnet restore 17 | shell: bash 18 | 19 | # - name: Test 20 | # run: dotnet test 21 | # shell: bash 22 | 23 | - name: Build 24 | run: dotnet build --configuration Release --no-restore 25 | shell: bash 26 | -------------------------------------------------------------------------------- /.github/templates/ReleaseAndPublish/action.yml: -------------------------------------------------------------------------------- 1 | name: "Build and Publish" 2 | description: "Build and publish on .NET 9" 3 | 4 | runs: 5 | using: "composite" 6 | steps: 7 | - name: Checkout 8 | uses: actions/checkout@v3 9 | 10 | - name: Setup .NET 11 | uses: actions/setup-dotnet@v4 12 | with: 13 | dotnet-version: '9.x.x' 14 | 15 | - name: Restore Dependencies 16 | run: dotnet restore 17 | shell: bash 18 | 19 | - name: Publish 20 | run: dotnet publish PenumbraModForwarder.UI/ -c Release -p:PublishSingleFile=true --self-contained true -r win-x64 -o ./publish -f net9.0-windows 21 | shell: bash 22 | 23 | - name: Archive 24 | run: Compress-Archive -Path ./publish/* -DestinationPath ./publish/PenumbraModForwarder.zip 25 | shell: pwsh -------------------------------------------------------------------------------- /.github/workflows/PR.yml: -------------------------------------------------------------------------------- 1 | name: Automatic Build Pull Request 2 | 3 | on: 4 | pull_request: 5 | types: [opened, synchronize, reopened] 6 | paths: 7 | - '**/*.cs' 8 | - '**/*.csproj' 9 | - '**/*.sln' 10 | - '**/*.resx' 11 | - '**/*.config' 12 | - '**/*.xml' 13 | - '**/*.json' 14 | 15 | jobs: 16 | Build: 17 | runs-on: windows-latest 18 | steps: 19 | - name: Checkout Repository 20 | uses: actions/checkout@v3 21 | with: 22 | submodules: 'true' 23 | 24 | - name: Build and Test 25 | uses: ./.github/templates/BuildAndTest 26 | -------------------------------------------------------------------------------- /.github/workflows/ReleaseVersion.yml: -------------------------------------------------------------------------------- 1 | name: Release on PR Merge 2 | 3 | on: 4 | pull_request: 5 | types: 6 | - closed 7 | 8 | workflow_dispatch: 9 | inputs: 10 | tagName: 11 | description: "Tag Name" 12 | required: true 13 | default: "vX.X.X.X" 14 | createArtifact: 15 | description: "Create Artifact" 16 | required: false 17 | default: false 18 | type: boolean 19 | betaRelease: 20 | description: "Beta Release" 21 | required: false 22 | default: false 23 | type: boolean 24 | 25 | permissions: 26 | contents: write 27 | packages: write 28 | 29 | jobs: 30 | validate-tag: 31 | if: ${{ github.event_name == 'workflow_dispatch' }} 32 | runs-on: ubuntu-latest 33 | steps: 34 | - name: Validate Tag Name 35 | shell: bash 36 | run: | 37 | if [[ ! "${{ github.event.inputs.tagName }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then 38 | echo "Invalid tag name format. Please use the format vX.X.X.X" 39 | exit 1 40 | fi 41 | 42 | release: 43 | if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) }} 44 | runs-on: windows-latest 45 | needs: [validate-tag] 46 | environment: Release 47 | steps: 48 | - name: Checkout Repository 49 | uses: actions/checkout@v3 50 | with: 51 | submodules: 'true' 52 | 53 | - name: Set Release Variables 54 | id: set_vars 55 | shell: bash 56 | env: 57 | EVENT_NAME: ${{ github.event_name }} 58 | TAG_NAME_INPUT: ${{ github.event.inputs.tagName }} 59 | BETA_RELEASE_INPUT: ${{ github.event.inputs.betaRelease }} 60 | CREATE_ARTIFACT_INPUT: ${{ github.event.inputs.createArtifact }} 61 | PR_HEAD_REF: ${{ github.event.pull_request.head.ref || '' }} 62 | PR_BASE_REF: ${{ github.event.pull_request.base.ref || '' }} 63 | run: | 64 | # Initialize variables 65 | IS_BETA="false" 66 | UPLOAD_ARTIFACT="false" 67 | 68 | if [ "$EVENT_NAME" == "workflow_dispatch" ]; then 69 | TAG_NAME="$TAG_NAME_INPUT" 70 | IS_BETA="$BETA_RELEASE_INPUT" 71 | if [ "$CREATE_ARTIFACT_INPUT" == "true" ]; then 72 | UPLOAD_ARTIFACT="true" 73 | fi 74 | elif [ "$EVENT_NAME" == "pull_request" ]; then 75 | TAG_NAME="$PR_HEAD_REF" 76 | if [ "$PR_BASE_REF" == "beta" ]; then 77 | IS_BETA="true" 78 | fi 79 | # Check if 'create-artifact' label is present 80 | if grep -q '"name": "create-artifact"' "$GITHUB_EVENT_PATH"; then 81 | UPLOAD_ARTIFACT="true" 82 | fi 83 | else 84 | echo "Unsupported event type: $EVENT_NAME" 85 | exit 1 86 | fi 87 | 88 | # Append '-b' to tag name if beta release 89 | if [ "$IS_BETA" == "true" ]; then 90 | TAG_NAME="${TAG_NAME}-b" 91 | fi 92 | 93 | # Validate Tag Name 94 | if [[ ! "$TAG_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+(-b)?$ ]]; then 95 | echo "Tag name does not match version pattern. Skipping release." 96 | echo "should_release=false" >> "$GITHUB_OUTPUT" 97 | else 98 | echo "should_release=true" >> "$GITHUB_OUTPUT" 99 | echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT" 100 | echo "is_beta=$IS_BETA" >> "$GITHUB_OUTPUT" 101 | echo "upload_artifact=$UPLOAD_ARTIFACT" >> "$GITHUB_OUTPUT" 102 | fi 103 | 104 | - name: Build and Publish 105 | if: ${{ steps.set_vars.outputs.should_release == 'true' }} 106 | uses: ./.github/templates/ReleaseAndPublish 107 | 108 | - name: Generate SHA256 and MD5 hashes for .zip 109 | if: ${{ steps.set_vars.outputs.should_release == 'true' }} 110 | shell: bash 111 | run: | 112 | sha256sum ./publish/PenumbraModForwarder.zip > ./publish/PenumbraModForwarder.zip.sha256 113 | md5sum ./publish/PenumbraModForwarder.zip > ./publish/PenumbraModForwarder.zip.md5 114 | 115 | - name: Read SHA256 and MD5 hashes 116 | if: ${{ steps.set_vars.outputs.should_release == 'true' }} 117 | id: read_hashes 118 | shell: bash 119 | run: | 120 | echo "sha256=$(cut -d ' ' -f1 ./publish/PenumbraModForwarder.zip.sha256)" >> "$GITHUB_ENV" 121 | echo "md5=$(cut -d ' ' -f1 ./publish/PenumbraModForwarder.zip.md5)" >> "$GITHUB_ENV" 122 | 123 | - name: Get latest commit message 124 | if: ${{ steps.set_vars.outputs.should_release == 'true' }} 125 | id: get_commit_message 126 | shell: bash 127 | run: | 128 | # Fetch the 'master' branch without tags 129 | git fetch --no-tags origin master 130 | 131 | # Get the latest commit message from 'origin/master' 132 | latest_commit=$(git log origin/master -1 --pretty=%B) 133 | 134 | # Set the commit_message as an output 135 | echo "commit_message<> "$GITHUB_OUTPUT" 136 | echo "$latest_commit" >> "$GITHUB_OUTPUT" 137 | echo "EOF" >> "$GITHUB_OUTPUT" 138 | 139 | 140 | - name: Upload Artifact 141 | if: ${{ steps.set_vars.outputs.should_release == 'true' && steps.set_vars.outputs.upload_artifact == 'true' }} 142 | uses: actions/upload-artifact@v4 143 | with: 144 | path: ./publish/PenumbraModForwarder.zip 145 | retention-days: 3 146 | name: "artifact" 147 | 148 | - name: Prepare Release Assets 149 | if: ${{ steps.set_vars.outputs.should_release == 'true' }} 150 | id: prepare_assets 151 | shell: bash 152 | env: 153 | REPO_OWNER: ${{ github.repository_owner }} 154 | REPO_NAME: ${{ github.event.repository.name }} 155 | TAG_NAME: ${{ steps.set_vars.outputs.tag_name }} 156 | run: | 157 | BODY="## Release Notes 158 | 159 | ${{ steps.get_commit_message.outputs.commit_message }} 160 | 161 | ## Hashes: 162 | - **SHA256 Hash**: \`${{ env.sha256 }}\` 163 | - **MD5 Hash**: \`${{ env.md5 }}\` 164 | 165 | ## Download Link 166 | [Download the zip](https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/download/${TAG_NAME}/PenumbraModForwarder.zip) 167 | " 168 | 169 | FILES="./publish/PenumbraModForwarder.zip 170 | ./publish/PenumbraModForwarder.zip.sha256 171 | ./publish/PenumbraModForwarder.zip.md5" 172 | 173 | echo "body<> "$GITHUB_OUTPUT" 174 | echo "$BODY" >> "$GITHUB_OUTPUT" 175 | echo "EOF" >> "$GITHUB_OUTPUT" 176 | 177 | echo "files<> "$GITHUB_OUTPUT" 178 | echo "$FILES" >> "$GITHUB_OUTPUT" 179 | echo "EOF" >> "$GITHUB_OUTPUT" 180 | 181 | - name: Create Release 182 | if: ${{ steps.set_vars.outputs.should_release == 'true' }} 183 | uses: softprops/action-gh-release@v2.0.8 184 | with: 185 | tag_name: ${{ steps.set_vars.outputs.tag_name }} 186 | body: ${{ steps.prepare_assets.outputs.body }} 187 | files: ${{ steps.prepare_assets.outputs.files }} 188 | prerelease: ${{ steps.set_vars.outputs.is_beta }} 189 | env: 190 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -------------------------------------------------------------------------------- /.github/workflows/UpdateVersion.yml: -------------------------------------------------------------------------------- 1 | name: Manual Release 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | tagName: 7 | description: "Tag Name" 8 | required: true 9 | default: "vX.X.X.X" 10 | 11 | permissions: 12 | contents: write 13 | packages: write 14 | pull-requests: write 15 | 16 | jobs: 17 | validate-tag: 18 | runs-on: ubuntu-latest 19 | steps: 20 | - name: Validate Tag Name 21 | run: | 22 | if [[ ! "${{ github.event.inputs.tagName }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then 23 | echo "Invalid tag name format. Please use the format vX.X.X.X" 24 | exit 1 25 | fi 26 | 27 | update-version: 28 | runs-on: ubuntu-latest 29 | needs: validate-tag 30 | steps: 31 | - name: Checkout Repository 32 | uses: actions/checkout@v3 33 | with: 34 | submodules: 'true' 35 | 36 | - name: Update XML and Update URL 37 | run: | 38 | version="${{ github.event.inputs.tagName }}" 39 | version_stripped="${version#v}" # Strip the leading 'v' 40 | xml_file="./update.xml" 41 | xml=$(cat "$xml_file") 42 | xml=$(echo "$xml" | sed "s|.*|${version_stripped}|") 43 | xml=$(echo "$xml" | sed "s|.*|https://github.com/Sebane1/PenumbraModForwarder/releases/download/${version}/PenumbraModForwarder.zip|") 44 | echo "$xml" > "$xml_file" 45 | shell: bash 46 | 47 | - name: Update .csproj Version 48 | run: | 49 | version="${{ github.event.inputs.tagName }}" 50 | version="${version#v}" # Strip the leading 'v' 51 | csproj_file="./PenumbraModForwarder.UI/PenumbraModForwarder.UI.csproj" 52 | sed -i "s|.*|${version}|" "$csproj_file" 53 | shell: bash 54 | 55 | - name: Commit Changes 56 | uses: devops-infra/action-commit-push@master 57 | with: 58 | github_token: ${{ secrets.GITHUB_TOKEN }} 59 | commit_message: "[AUTO-COMMIT] Update Version Number" 60 | target_branch: ${{ github.event.inputs.tagName }} 61 | 62 | - name: Create a PR with the changes 63 | uses: devops-infra/action-pull-request@master 64 | with: 65 | github_token: ${{ secrets.GITHUB_TOKEN }} 66 | title: "Update Version Number" 67 | source_branch: ${{ github.event.inputs.tagName }} 68 | target_branch: "master" 69 | get_diff: 'true' 70 | label: 'release' 71 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### VisualStudio template 2 | ## Ignore Visual Studio temporary files, build results, and 3 | ## files generated by popular Visual Studio add-ons. 4 | ## 5 | ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore 6 | 7 | # User-specific files 8 | *.rsuser 9 | *.suo 10 | *.user 11 | *.userosscache 12 | *.sln.docstates 13 | 14 | # User-specific files (MonoDevelop/Xamarin Studio) 15 | *.userprefs 16 | 17 | # Mono auto generated files 18 | mono_crash.* 19 | 20 | # Build results 21 | [Dd]ebug/ 22 | [Dd]ebugPublic/ 23 | [Rr]elease/ 24 | [Rr]eleases/ 25 | x64/ 26 | x86/ 27 | [Ww][Ii][Nn]32/ 28 | [Aa][Rr][Mm]/ 29 | [Aa][Rr][Mm]64/ 30 | bld/ 31 | [Bb]in/ 32 | [Oo]bj/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Publish Results 37 | .publish/ 38 | publish 39 | 40 | # Visual Studio 2015/2017 cache/options directory 41 | .vs/ 42 | # Uncomment if you have tasks that create the project's static files in wwwroot 43 | #wwwroot/ 44 | 45 | # Visual Studio 2017 auto generated files 46 | Generated\ Files/ 47 | 48 | # MSTest test Results 49 | [Tt]est[Rr]esult*/ 50 | [Bb]uild[Ll]og.* 51 | 52 | # NUnit 53 | *.VisualState.xml 54 | TestResult.xml 55 | nunit-*.xml 56 | 57 | # Build Results of an ATL Project 58 | [Dd]ebugPS/ 59 | [Rr]eleasePS/ 60 | dlldata.c 61 | 62 | # Benchmark Results 63 | BenchmarkDotNet.Artifacts/ 64 | 65 | # .NET Core 66 | project.lock.json 67 | project.fragment.lock.json 68 | artifacts/ 69 | 70 | # ASP.NET Scaffolding 71 | ScaffoldingReadMe.txt 72 | 73 | # StyleCop 74 | StyleCopReport.xml 75 | 76 | # Files built by Visual Studio 77 | *_i.c 78 | *_p.c 79 | *_h.h 80 | *.ilk 81 | *.meta 82 | *.obj 83 | *.iobj 84 | *.pch 85 | *.pdb 86 | *.ipdb 87 | *.pgc 88 | *.pgd 89 | *.rsp 90 | *.sbr 91 | *.tlb 92 | *.tli 93 | *.tlh 94 | *.tmp 95 | *.tmp_proj 96 | *_wpftmp.csproj 97 | *.log 98 | *.tlog 99 | *.vspscc 100 | *.vssscc 101 | .builds 102 | *.pidb 103 | *.svclog 104 | *.scc 105 | 106 | # Chutzpah Test files 107 | _Chutzpah* 108 | 109 | # Visual C++ cache files 110 | ipch/ 111 | *.aps 112 | *.ncb 113 | *.opendb 114 | *.opensdf 115 | *.sdf 116 | *.cachefile 117 | *.VC.db 118 | *.VC.VC.opendb 119 | 120 | # Visual Studio profiler 121 | *.psess 122 | *.vsp 123 | *.vspx 124 | *.sap 125 | 126 | # Visual Studio Trace Files 127 | *.e2e 128 | 129 | # TFS 2012 Local Workspace 130 | $tf/ 131 | 132 | # Guidance Automation Toolkit 133 | *.gpState 134 | 135 | # ReSharper is a .NET coding add-in 136 | _ReSharper*/ 137 | *.[Rr]e[Ss]harper 138 | *.DotSettings.user 139 | 140 | # TeamCity is a build add-in 141 | _TeamCity* 142 | 143 | # DotCover is a Code Coverage Tool 144 | *.dotCover 145 | 146 | # AxoCover is a Code Coverage Tool 147 | .axoCover/* 148 | !.axoCover/settings.json 149 | 150 | # Coverlet is a free, cross platform Code Coverage Tool 151 | coverage*.json 152 | coverage*.xml 153 | coverage*.info 154 | 155 | # Visual Studio code coverage results 156 | *.coverage 157 | *.coveragexml 158 | 159 | # NCrunch 160 | _NCrunch_* 161 | .*crunch*.local.xml 162 | nCrunchTemp_* 163 | 164 | # MightyMoose 165 | *.mm.* 166 | AutoTest.Net/ 167 | 168 | # Web workbench (sass) 169 | .sass-cache/ 170 | 171 | # Installshield output folder 172 | [Ee]xpress/ 173 | 174 | # DocProject is a documentation generator add-in 175 | DocProject/buildhelp/ 176 | DocProject/Help/*.HxT 177 | DocProject/Help/*.HxC 178 | DocProject/Help/*.hhc 179 | DocProject/Help/*.hhk 180 | DocProject/Help/*.hhp 181 | DocProject/Help/Html2 182 | DocProject/Help/html 183 | 184 | # Click-Once directory 185 | publish/ 186 | 187 | # Publish Web Output 188 | *.[Pp]ublish.xml 189 | *.azurePubxml 190 | # Note: Comment the next line if you want to checkin your web deploy settings, 191 | # but database connection strings (with potential passwords) will be unencrypted 192 | *.pubxml 193 | *.publishproj 194 | 195 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 196 | # checkin your Azure Web App publish settings, but sensitive information contained 197 | # in these scripts will be unencrypted 198 | PublishScripts/ 199 | 200 | # NuGet Packages 201 | *.nupkg 202 | # NuGet Symbol Packages 203 | *.snupkg 204 | # The packages folder can be ignored because of Package Restore 205 | **/[Pp]ackages/* 206 | # except build/, which is used as an MSBuild target. 207 | !**/[Pp]ackages/build/ 208 | # Uncomment if necessary however generally it will be regenerated when needed 209 | #!**/[Pp]ackages/repositories.config 210 | # NuGet v3's project.json files produces more ignorable files 211 | *.nuget.props 212 | *.nuget.targets 213 | 214 | # Microsoft Azure Build Output 215 | csx/ 216 | *.build.csdef 217 | 218 | # Microsoft Azure Emulator 219 | ecf/ 220 | rcf/ 221 | 222 | # Windows Store app package directories and files 223 | AppPackages/ 224 | BundleArtifacts/ 225 | Package.StoreAssociation.xml 226 | _pkginfo.txt 227 | *.appx 228 | *.appxbundle 229 | *.appxupload 230 | 231 | # Visual Studio cache files 232 | # files ending in .cache can be ignored 233 | *.[Cc]ache 234 | # but keep track of directories ending in .cache 235 | !?*.[Cc]ache/ 236 | 237 | # Others 238 | ClientBin/ 239 | ~$* 240 | *~ 241 | *.dbmdl 242 | *.dbproj.schemaview 243 | *.jfm 244 | *.pfx 245 | *.publishsettings 246 | orleans.codegen.cs 247 | 248 | # Including strong name files can present a security risk 249 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 250 | #*.snk 251 | 252 | # Since there are multiple workflows, uncomment next line to ignore bower_components 253 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 254 | #bower_components/ 255 | 256 | # RIA/Silverlight projects 257 | Generated_Code/ 258 | 259 | # Backup & report files from converting an old project file 260 | # to a newer Visual Studio version. Backup files are not needed, 261 | # because we have git ;-) 262 | _UpgradeReport_Files/ 263 | Backup*/ 264 | UpgradeLog*.XML 265 | UpgradeLog*.htm 266 | ServiceFabricBackup/ 267 | *.rptproj.bak 268 | 269 | # SQL Server files 270 | *.mdf 271 | *.ldf 272 | *.ndf 273 | 274 | # Business Intelligence projects 275 | *.rdl.data 276 | *.bim.layout 277 | *.bim_*.settings 278 | *.rptproj.rsuser 279 | *- [Bb]ackup.rdl 280 | *- [Bb]ackup ([0-9]).rdl 281 | *- [Bb]ackup ([0-9][0-9]).rdl 282 | 283 | # Microsoft Fakes 284 | FakesAssemblies/ 285 | 286 | # GhostDoc plugin setting file 287 | *.GhostDoc.xml 288 | 289 | # Node.js Tools for Visual Studio 290 | .ntvs_analysis.dat 291 | node_modules/ 292 | 293 | # Visual Studio 6 build log 294 | *.plg 295 | 296 | # Visual Studio 6 workspace options file 297 | *.opt 298 | 299 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 300 | *.vbw 301 | 302 | # Visual Studio 6 auto-generated project file (contains which files were open etc.) 303 | *.vbp 304 | 305 | # Visual Studio 6 workspace and project file (working project files containing files to include in project) 306 | *.dsw 307 | *.dsp 308 | 309 | # Visual Studio 6 technical files 310 | 311 | # Visual Studio LightSwitch build output 312 | **/*.HTMLClient/GeneratedArtifacts 313 | **/*.DesktopClient/GeneratedArtifacts 314 | **/*.DesktopClient/ModelManifest.xml 315 | **/*.Server/GeneratedArtifacts 316 | **/*.Server/ModelManifest.xml 317 | _Pvt_Extensions 318 | 319 | # Paket dependency manager 320 | .paket/paket.exe 321 | paket-files/ 322 | 323 | # FAKE - F# Make 324 | .fake/ 325 | 326 | # CodeRush personal settings 327 | .cr/personal 328 | 329 | # Python Tools for Visual Studio (PTVS) 330 | __pycache__/ 331 | *.pyc 332 | 333 | # Cake - Uncomment if you are using it 334 | # tools/** 335 | # !tools/packages.config 336 | 337 | # Tabs Studio 338 | *.tss 339 | 340 | # Telerik's JustMock configuration file 341 | *.jmconfig 342 | 343 | # BizTalk build output 344 | *.btp.cs 345 | *.btm.cs 346 | *.odx.cs 347 | *.xsd.cs 348 | 349 | # OpenCover UI analysis results 350 | OpenCover/ 351 | 352 | # Azure Stream Analytics local run output 353 | ASALocalRun/ 354 | 355 | # MSBuild Binary and Structured Log 356 | *.binlog 357 | 358 | # NVidia Nsight GPU debugger configuration file 359 | *.nvuser 360 | 361 | # MFractors (Xamarin productivity tool) working folder 362 | .mfractor/ 363 | 364 | # Local History for Visual Studio 365 | .localhistory/ 366 | 367 | # Visual Studio History (VSHistory) files 368 | .vshistory/ 369 | 370 | # BeatPulse healthcheck temp database 371 | healthchecksdb 372 | 373 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 374 | MigrationBackup/ 375 | 376 | # Ionide (cross platform F# VS Code tools) working folder 377 | .ionide/ 378 | 379 | # Fody - auto-generated XML schema 380 | FodyWeavers.xsd 381 | 382 | # VS Code files for those working on multiple tools 383 | .vscode/* 384 | !.vscode/settings.json 385 | !.vscode/tasks.json 386 | !.vscode/launch.json 387 | !.vscode/extensions.json 388 | *.code-workspace 389 | 390 | # Local History for Visual Studio Code 391 | .history/ 392 | 393 | # Windows Installer files from build outputs 394 | *.cab 395 | *.msi 396 | *.msix 397 | *.msm 398 | *.msp 399 | 400 | # JetBrains Rider 401 | *.sln.iml 402 | 403 | ### Rider template 404 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider 405 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 406 | 407 | # User-specific stuff 408 | .idea/**/workspace.xml 409 | .idea/**/tasks.xml 410 | .idea/**/usage.statistics.xml 411 | .idea/**/dictionaries 412 | .idea/**/shelf 413 | 414 | # AWS User-specific 415 | .idea/**/aws.xml 416 | 417 | # Generated files 418 | .idea/**/contentModel.xml 419 | 420 | # Sensitive or high-churn files 421 | .idea/**/dataSources/ 422 | .idea/**/dataSources.ids 423 | .idea/**/dataSources.local.xml 424 | .idea/**/sqlDataSources.xml 425 | .idea/**/dynamic.xml 426 | .idea/**/uiDesigner.xml 427 | .idea/**/dbnavigator.xml 428 | 429 | # Gradle 430 | .idea/**/gradle.xml 431 | .idea/**/libraries 432 | 433 | # Gradle and Maven with auto-import 434 | # When using Gradle or Maven with auto-import, you should exclude module files, 435 | # since they will be recreated, and may cause churn. Uncomment if using 436 | # auto-import. 437 | # .idea/artifacts 438 | # .idea/compiler.xml 439 | # .idea/jarRepositories.xml 440 | # .idea/modules.xml 441 | # .idea/*.iml 442 | # .idea/modules 443 | # *.iml 444 | # *.ipr 445 | 446 | # CMake 447 | cmake-build-*/ 448 | 449 | # Mongo Explorer plugin 450 | .idea/**/mongoSettings.xml 451 | 452 | # File-based project format 453 | *.iws 454 | 455 | # IntelliJ 456 | out/ 457 | 458 | # mpeltonen/sbt-idea plugin 459 | .idea_modules/ 460 | 461 | # JIRA plugin 462 | atlassian-ide-plugin.xml 463 | 464 | # Cursive Clojure plugin 465 | .idea/replstate.xml 466 | 467 | # SonarLint plugin 468 | .idea/sonarlint/ 469 | 470 | # Crashlytics plugin (for Android Studio and IntelliJ) 471 | com_crashlytics_export_strings.xml 472 | crashlytics.properties 473 | crashlytics-build.properties 474 | fabric.properties 475 | 476 | # Editor-based Rest Client 477 | .idea/httpRequests 478 | 479 | # Android studio 3.1+ serialized cache file 480 | .idea/caches/build_file_checksums.ser 481 | 482 | .codiumai -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "SevenZipExtractor"] 2 | path = SevenZipExtractor 3 | url = https://github.com/CollapseLauncher/SevenZipExtractor.git 4 | -------------------------------------------------------------------------------- /.idea/.idea.PenumbraModForwarder/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Rider ignored files 5 | /.idea.PenumbraModForwarder.iml 6 | /modules.xml 7 | /contentModel.xml 8 | /projectSettingsUpdater.xml 9 | # Editor-based HTTP Client requests 10 | /httpRequests/ 11 | # Datasource local storage ignored files 12 | /dataSources/ 13 | /dataSources.local.xml 14 | -------------------------------------------------------------------------------- /.idea/.idea.PenumbraModForwarder/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/.idea.PenumbraModForwarder/.idea/git_toolbox_blame.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/.idea.PenumbraModForwarder/.idea/indexLayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/.idea.PenumbraModForwarder/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.run/Publish PenumbraModForwarder to folder.run.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Interfaces/IAdminService.cs: -------------------------------------------------------------------------------- 1 | namespace PenumbraModForwarder.Common.Interfaces; 2 | 3 | public interface IAdminService 4 | { 5 | public void PromptForAdminRestart(); 6 | 7 | public void PromptForUserRestart(); 8 | public bool IsAdmin(); 9 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Interfaces/IArchiveHelperService.cs: -------------------------------------------------------------------------------- 1 | namespace PenumbraModForwarder.Common.Interfaces; 2 | 3 | public interface IArchiveHelperService 4 | { 5 | public Task QueueExtractionAsync(string filePath); 6 | public string[] GetFilesInArchive(string filePath); 7 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Interfaces/IArkService.cs: -------------------------------------------------------------------------------- 1 | namespace PenumbraModForwarder.Common.Interfaces; 2 | 3 | public interface IArkService 4 | { 5 | public void InstallArkFile(string filePath); 6 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Interfaces/IAssociateFileTypeService.cs: -------------------------------------------------------------------------------- 1 | namespace PenumbraModForwarder.Common.Interfaces; 2 | 3 | public interface IAssociateFileTypeService 4 | { 5 | void AssociateFileTypes(string applicationPath); 6 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Interfaces/IConfigurationService.cs: -------------------------------------------------------------------------------- 1 | using PenumbraModForwarder.Common.Models; 2 | 3 | namespace PenumbraModForwarder.Common.Interfaces; 4 | 5 | public interface IConfigurationService 6 | { 7 | public T GetConfigValue(Func getValue); 8 | public void SetConfigValue(Action setValue, T value); 9 | public bool IsAdvancedOptionEnabled(Func advancedOption); 10 | public event EventHandler ConfigChanged; 11 | public void MigrateOldConfig(); 12 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Interfaces/IErrorWindowService.cs: -------------------------------------------------------------------------------- 1 | namespace PenumbraModForwarder.Common.Interfaces; 2 | 3 | public interface IErrorWindowService 4 | { 5 | public void ShowError(string message); 6 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Interfaces/IFileHandlerService.cs: -------------------------------------------------------------------------------- 1 | namespace PenumbraModForwarder.Common.Interfaces; 2 | 3 | public interface IFileHandlerService 4 | { 5 | public void HandleFile(string filePath); 6 | public void CleanUpTempFiles(); 7 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Interfaces/IFileSelector.cs: -------------------------------------------------------------------------------- 1 | namespace PenumbraModForwarder.Common.Interfaces; 2 | 3 | public interface IFileSelector 4 | { 5 | string[] SelectFiles(string[] files, string archiveFileName); 6 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Interfaces/IFileWatcher.cs: -------------------------------------------------------------------------------- 1 | namespace PenumbraModForwarder.Common.Interfaces; 2 | 3 | public interface IFileWatcher 4 | { 5 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Interfaces/IPenumbraApi.cs: -------------------------------------------------------------------------------- 1 | namespace PenumbraModForwarder.Common.Interfaces; 2 | 3 | public interface IPenumbraApi 4 | { 5 | public Task InstallAsync(string modPath); 6 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Interfaces/IPenumbraInstallerService.cs: -------------------------------------------------------------------------------- 1 | namespace PenumbraModForwarder.Common.Interfaces; 2 | 3 | public interface IPenumbraInstallerService 4 | { 5 | public bool InstallMod(string modPath); 6 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Interfaces/IProcessHelperService.cs: -------------------------------------------------------------------------------- 1 | namespace PenumbraModForwarder.Common.Interfaces; 2 | 3 | public interface IProcessHelperService 4 | { 5 | void OpenLogFolder(); 6 | bool IsApplicationAlreadyOpen(); 7 | void OpenSupportDiscord(); 8 | void OpenXivArchive(); 9 | void OpenHelios(); 10 | void OpenDonate(); 11 | void OpenGlamourDresser(); 12 | void OpenNexusMods(); 13 | void OpenAetherLink(); 14 | void OpenPrettyKitty(); 15 | void OpenArk(); 16 | void CrossGenPorting(); 17 | void XivModResources(); 18 | void TexToolsDiscord(); 19 | void SoundAndTextureResources(); 20 | void PixelatedAssistance(); 21 | void PenumbraResources(); 22 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Interfaces/IProgressWindowService.cs: -------------------------------------------------------------------------------- 1 | namespace PenumbraModForwarder.Common.Interfaces; 2 | 3 | public interface IProgressWindowService 4 | { 5 | public void ShowProgressWindow(); 6 | public void UpdateProgress(string fileName, string operation, int progress); 7 | public void CloseProgressWindow(); 8 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Interfaces/IRegistryHelper.cs: -------------------------------------------------------------------------------- 1 | namespace PenumbraModForwarder.Common.Interfaces; 2 | 3 | public interface IRegistryHelper 4 | { 5 | public void CreateFileAssociation(IEnumerable extensions, string applicationPath); 6 | public void RemoveFileAssociation(IEnumerable extensions); 7 | public void AddApplicationToStartup(string appName, string appPath); 8 | public void RemoveApplicationFromStartup(string appName); 9 | public string GetTexToolRegistryValue(string keyValue); 10 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Interfaces/ISystemTrayManager.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace PenumbraModForwarder.Common.Interfaces; 3 | 4 | public interface ISystemTrayManager : IDisposable 5 | { 6 | void ShowNotification(string title, string message); 7 | event Action OnExitRequested; 8 | void TriggerExit(); 9 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Interfaces/ITexToolsHelper.cs: -------------------------------------------------------------------------------- 1 | namespace PenumbraModForwarder.Common.Interfaces; 2 | 3 | public interface ITexToolsHelper 4 | { 5 | public void SetTexToolsConsolePath(); 6 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Interop/Imports.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace PenumbraModForwarder.Common.Interop; 4 | 5 | public class Imports 6 | { 7 | [DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = true)] 8 | public static extern void SHChangeNotify(long wEventId, uint uFlags, IntPtr dwItem1, IntPtr dwItem2); 9 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Models/AdvancedConfigrationModel.cs: -------------------------------------------------------------------------------- 1 | namespace PenumbraModForwarder.Common.Models 2 | { 3 | public class AdvancedConfigurationModel 4 | { 5 | public bool HideWindowOnStartup { get; set; } = true; 6 | public int PenumbraTimeOutInSeconds { get; set; } = 60; // This is in Seconds 7 | } 8 | } 9 | 10 | -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Models/ArkModel.cs: -------------------------------------------------------------------------------- 1 | namespace PenumbraModForwarder.Common.Models; 2 | 3 | public class ArkModel 4 | { 5 | public string CacheFolder { get; set; } 6 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Models/ConfigurationModel.cs: -------------------------------------------------------------------------------- 1 | namespace PenumbraModForwarder.Common.Models 2 | { 3 | public class ConfigurationModel 4 | { 5 | public bool AutoLoad { get; set; } 6 | public bool AutoDelete { get; set; } 7 | public bool ExtractAll { get; set; } 8 | public bool NotificationEnabled { get; set; } 9 | public bool FileLinkingEnabled { get; set; } 10 | public bool StartOnBoot { get; set; } 11 | public string DownloadPath { get; set; } = string.Empty; 12 | public string TexToolPath { get; set; } = string.Empty; 13 | public AdvancedConfigurationModel AdvancedOptions { get; set; } = new(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Models/ExtractionOperation.cs: -------------------------------------------------------------------------------- 1 | namespace PenumbraModForwarder.Common.Models; 2 | 3 | public class ExtractionOperation 4 | { 5 | public string FilePath { get; } 6 | 7 | public ExtractionOperation(string filePath) 8 | { 9 | FilePath = filePath; 10 | } 11 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Models/FileDownloadInfo.cs: -------------------------------------------------------------------------------- 1 | namespace PenumbraModForwarder.Common.Models; 2 | 3 | public class FileDownloadInfo 4 | { 5 | public long LastSize { get; set; } 6 | public DateTime LastProgressTime { get; set; } 7 | public DateTime StartTime { get; set; } 8 | public int StabilityCount { get; set; } 9 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Models/MappingProfile.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | 3 | namespace PenumbraModForwarder.Common.Models; 4 | 5 | public class MappingProfile : Profile 6 | { 7 | public MappingProfile() 8 | { 9 | CreateMap() 10 | .ForMember(dest => dest.DownloadPath, opt => opt.MapFrom(src => src.DownloadPath)) 11 | .ForMember(dest => dest.AutoLoad, opt => opt.MapFrom(src => src.AutoLoad)) 12 | .ForMember(dest => dest.AutoDelete, opt => opt.MapFrom(src => src.AutoDelete)) 13 | .ForMember(dest => dest.TexToolPath, opt => opt.MapFrom(src => src.TexToolPath)); 14 | } 15 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Models/OldConfigurationModel.cs: -------------------------------------------------------------------------------- 1 | namespace PenumbraModForwarder.Common.Models; 2 | 3 | public class OldConfigurationModel 4 | { 5 | public bool AutoLoad { get; set; } 6 | public bool AutoDelete { get; set; } 7 | public bool AllowChoicesBeforeExtractingArchive { get; set; } 8 | public string DownloadPath { get; set; } = string.Empty; 9 | public string TexToolPath { get; set; } = string.Empty; 10 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/PenumbraModForwarder.Common.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net9.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | x64 11 | 12 | 13 | 14 | x64 15 | none 16 | true 17 | true 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Services/ArkService.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | using Newtonsoft.Json; 3 | using PenumbraModForwarder.Common.Interfaces; 4 | using PenumbraModForwarder.Common.Models; 5 | 6 | namespace PenumbraModForwarder.Common.Services; 7 | 8 | public class ArkService : IArkService 9 | { 10 | private readonly ILogger _logger; 11 | private readonly IErrorWindowService _errorWindowService; 12 | private readonly IProcessHelperService _processHelperService; 13 | private string _cacheFolder; 14 | private readonly string _arkPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\XIVLauncher\pluginConfigs\RoleplayingVoiceDalamud.json"; 15 | 16 | public ArkService(ILogger logger, IErrorWindowService errorWindowService, IProcessHelperService processHelperService) 17 | { 18 | _logger = logger; 19 | _errorWindowService = errorWindowService; 20 | _processHelperService = processHelperService; 21 | } 22 | 23 | private void CheckArkInstallation() 24 | { 25 | if (!File.Exists(_arkPath)) 26 | { 27 | _logger.LogError("Ark installation not found at {ArkPath}", _arkPath); 28 | _errorWindowService.ShowError($"Ark installation not found at: {_arkPath}"); 29 | } 30 | 31 | var file = File.ReadAllText(_arkPath); 32 | var config = JsonConvert.DeserializeObject(file); 33 | _cacheFolder = config.CacheFolder; 34 | } 35 | 36 | public void InstallArkFile(string filePath) 37 | { 38 | CheckArkInstallation(); 39 | 40 | if (string.IsNullOrEmpty(_cacheFolder)) 41 | { 42 | _logger.LogError("Ark cache folder not found in config"); 43 | _errorWindowService.ShowError("Ark cache folder not found in config, this could be because the plugin is not installed."); 44 | _processHelperService.OpenArk(); 45 | } 46 | 47 | var arkFolder = Path.Combine(_cacheFolder, "VoicePack", Path.GetFileNameWithoutExtension(filePath)); 48 | File.Copy(filePath, Path.Combine(arkFolder, Path.GetFileName(filePath)), true); 49 | File.Delete(filePath); 50 | } 51 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Services/AssociateFileTypesService.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using Microsoft.Extensions.Logging; 3 | using PenumbraModForwarder.Common.Interfaces; 4 | using PenumbraModForwarder.Common.Interop; 5 | 6 | namespace PenumbraModForwarder.Common.Services; 7 | 8 | public class AssociateFileTypesService : IAssociateFileTypeService 9 | { 10 | private readonly ILogger _logger; 11 | private readonly IRegistryHelper _registryHelper; 12 | private readonly IConfigurationService _configurationService; 13 | private readonly IErrorWindowService _errorWindowService; 14 | 15 | public AssociateFileTypesService(ILogger logger, IRegistryHelper registryHelper, IConfigurationService configurationService, IErrorWindowService errorWindowService) 16 | { 17 | _logger = logger; 18 | _registryHelper = registryHelper; 19 | _configurationService = configurationService; 20 | _errorWindowService = errorWindowService; 21 | } 22 | 23 | public void AssociateFileTypes(string applicationPath) 24 | { 25 | var allowedExtensions = new[] {".pmp", ".ttmp2", ".ttmp", ".rpvsp"}; 26 | try 27 | { 28 | if (_configurationService.GetConfigValue(c => c.FileLinkingEnabled)) 29 | { 30 | _logger.LogInformation("Associating file types"); 31 | _registryHelper.CreateFileAssociation(allowedExtensions, applicationPath); 32 | } 33 | else 34 | { 35 | _logger.LogInformation("Disassociating file types"); 36 | _registryHelper.RemoveFileAssociation(allowedExtensions); 37 | } 38 | 39 | // Let the computer know a change as occurred. 40 | Imports.SHChangeNotify(0x08000000, 0x0000, IntPtr.Zero, IntPtr.Zero); 41 | 42 | } 43 | catch (Exception e) 44 | { 45 | _logger.LogError(e, "Failed to associate file types"); 46 | _errorWindowService.ShowError(e.ToString()); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Services/ConfigurationService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using AutoMapper; 4 | using Microsoft.Extensions.Logging; 5 | using Newtonsoft.Json; 6 | using PenumbraModForwarder.Common.Interfaces; 7 | using PenumbraModForwarder.Common.Models; 8 | 9 | namespace PenumbraModForwarder.Common.Services 10 | { 11 | public sealed class ConfigurationService : IConfigurationService 12 | { 13 | private string _configPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\PenumbraModForwarder\config.json"; 14 | private ConfigurationModel _config; 15 | private readonly object _lock = new(); 16 | private readonly ILogger _logger; 17 | private readonly IErrorWindowService _errorWindowService; 18 | private readonly IMapper _mapper; 19 | 20 | public ConfigurationService(ILogger logger, IMapper mapper, IErrorWindowService errorWindowService) 21 | { 22 | _logger = logger; 23 | _mapper = mapper; 24 | _errorWindowService = errorWindowService; 25 | if (!File.Exists(_configPath)) 26 | { 27 | Directory.CreateDirectory(Path.GetDirectoryName(_configPath)); 28 | _config = new ConfigurationModel 29 | { 30 | AdvancedOptions = new AdvancedConfigurationModel() 31 | }; 32 | SaveConfig(); 33 | } 34 | else 35 | { 36 | LoadConfig(); 37 | } 38 | } 39 | 40 | // Event to notify subscribers when the configuration changes 41 | public event EventHandler ConfigChanged; 42 | 43 | public T GetConfigValue(Func getValue) 44 | { 45 | _logger.LogDebug("Getting config value"); 46 | lock (_lock) 47 | { 48 | return getValue(_config); 49 | } 50 | } 51 | 52 | public void SetConfigValue(Action setValue, T value) 53 | { 54 | _logger.LogDebug("Setting config value"); 55 | lock (_lock) 56 | { 57 | setValue(_config, value); 58 | SaveConfig(); 59 | OnConfigChanged(); 60 | } 61 | } 62 | 63 | public bool IsAdvancedOptionEnabled(Func advancedOption) 64 | { 65 | _logger.LogDebug("Checking advanced config option"); 66 | lock (_lock) 67 | { 68 | return advancedOption(_config.AdvancedOptions); 69 | } 70 | } 71 | 72 | public void MigrateOldConfig() 73 | { 74 | var filesToMigrate = new[] 75 | { 76 | Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\PenumbraModForwarder\PenumbraModForwarder\DownloadPath.config", 77 | Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\PenumbraModForwarder\PenumbraModForwarder\AutoLoad.config", 78 | Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\PenumbraModForwarder\PenumbraModForwarder\Config.json" 79 | }; 80 | 81 | foreach (var file in filesToMigrate) 82 | { 83 | _logger.LogDebug($"Checking for old config file: {file}"); 84 | if (!File.Exists(file)) 85 | { 86 | _logger.LogDebug("Old config file not found"); 87 | continue; 88 | } 89 | 90 | try 91 | { 92 | var oldConfig = File.ReadAllText(file); 93 | 94 | if (file.Contains("DownloadPath")) 95 | { 96 | _logger.LogDebug("Migrating DownloadPath"); 97 | SetConfigValue((config, value) => config.DownloadPath = value, oldConfig); 98 | } 99 | else if (file.Contains("AutoLoad")) 100 | { 101 | _logger.LogDebug("Migrating AutoLoad"); 102 | SetConfigValue((config, value) => config.AutoLoad = value, bool.Parse(oldConfig)); 103 | } 104 | else if (file.Contains("Config.json")) 105 | { 106 | _logger.LogDebug("Migrating Config.json"); 107 | if (string.IsNullOrWhiteSpace(oldConfig) || !oldConfig.StartsWith("{")) 108 | { 109 | _logger.LogError("Old config file is empty or invalid JSON"); 110 | return; 111 | } 112 | 113 | var oldConfigModel = JsonConvert.DeserializeObject(oldConfig); 114 | if (oldConfigModel == null) 115 | { 116 | _logger.LogError("Failed to deserialize old config model"); 117 | // If we get this error here, we are in some serious trouble. 118 | _errorWindowService.ShowError("Failed to deserialize old config model"); 119 | return; 120 | } 121 | 122 | var newConfigModel = _mapper.Map(oldConfigModel); 123 | _config = newConfigModel; 124 | SaveConfig(); 125 | _logger.LogInformation("Migrated Config.json"); 126 | } 127 | } 128 | catch (Exception ex) 129 | { 130 | _logger.LogError(ex, $"Error processing file: {file}"); 131 | _errorWindowService.ShowError(ex.ToString()); 132 | } 133 | } 134 | 135 | var oldConfigDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + 136 | @"\PenumbraModForwarder\PenumbraModForwarder"; 137 | if (Directory.Exists(oldConfigDirectory)) 138 | { 139 | _logger.LogDebug("Deleting old config directory"); 140 | Directory.Delete(oldConfigDirectory, true); 141 | } 142 | } 143 | 144 | 145 | private void SaveConfig() 146 | { 147 | _logger.LogDebug("Saving config"); 148 | lock (_lock) 149 | { 150 | File.WriteAllText(_configPath, JsonConvert.SerializeObject(_config, Formatting.Indented)); 151 | } 152 | } 153 | 154 | private void LoadConfig() 155 | { 156 | lock (_lock) 157 | { 158 | var rawJson = File.ReadAllText(_configPath); 159 | 160 | _config = JsonConvert.DeserializeObject(rawJson); 161 | 162 | if (_config == null) 163 | { 164 | _logger.LogWarning("Configuration deserialization failed. Creating a new configuration with default values."); 165 | _config = new ConfigurationModel(); 166 | } 167 | 168 | if (_config.AdvancedOptions == null) 169 | { 170 | _logger.LogInformation("AdvancedOptions is missing in the configuration file, adding default values."); 171 | _config.AdvancedOptions = new AdvancedConfigurationModel(); 172 | } 173 | 174 | PopulateDefaultValues(_config.AdvancedOptions); 175 | SaveConfig(); 176 | } 177 | } 178 | 179 | private void PopulateDefaultValues(T obj) where T : class, new() 180 | { 181 | var defaultInstance = new T(); 182 | 183 | var properties = typeof(T).GetProperties(); 184 | 185 | foreach (var property in properties) 186 | { 187 | var currentValue = property.GetValue(obj); 188 | var defaultValue = property.GetValue(defaultInstance); 189 | 190 | // If current value is null or default (like 0 for int), replace it with the default value. 191 | if (currentValue == null || (property.PropertyType.IsValueType && currentValue.Equals(Activator.CreateInstance(property.PropertyType)))) 192 | { 193 | property.SetValue(obj, defaultValue); 194 | } 195 | } 196 | } 197 | 198 | private void OnConfigChanged() 199 | { 200 | ConfigChanged?.Invoke(this, EventArgs.Empty); 201 | } 202 | } 203 | } 204 | -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Services/FileHandlerService.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | using PenumbraModForwarder.Common.Interfaces; 3 | 4 | namespace PenumbraModForwarder.Common.Services; 5 | 6 | public class FileHandlerService : IFileHandlerService 7 | { 8 | private readonly ILogger _logger; 9 | private readonly IArchiveHelperService _archiveHelperService; 10 | private readonly IPenumbraInstallerService _penumbraInstallerService; 11 | private readonly IConfigurationService _configurationService; 12 | private readonly IErrorWindowService _errorWindowService; 13 | private readonly IArkService _arkService; 14 | 15 | public FileHandlerService(ILogger logger, IArchiveHelperService archiveHelperService, IPenumbraInstallerService penumbraInstallerService, IConfigurationService configurationService, IErrorWindowService errorWindowService, IArkService arkService) 16 | { 17 | _logger = logger; 18 | _archiveHelperService = archiveHelperService; 19 | _penumbraInstallerService = penumbraInstallerService; 20 | _configurationService = configurationService; 21 | _errorWindowService = errorWindowService; 22 | _arkService = arkService; 23 | } 24 | 25 | public void HandleFile(string filePath) 26 | { 27 | _logger.LogInformation($"Handling file: {filePath}"); 28 | 29 | if (IsArchive(filePath)) 30 | { 31 | _logger.LogInformation($"File '{filePath}' is an archive. Initiating extraction."); 32 | _archiveHelperService.QueueExtractionAsync(filePath); 33 | } 34 | else if (IsModFile(filePath)) 35 | { 36 | _logger.LogInformation($"File '{filePath}' is a mod file. Installing mod."); 37 | try 38 | { 39 | _penumbraInstallerService.InstallMod(filePath); 40 | _logger.LogInformation($"Mod file '{filePath}' installed successfully."); 41 | } 42 | catch (Exception ex) 43 | { 44 | _logger.LogError(ex, $"Failed to install mod: {filePath}"); 45 | _errorWindowService.ShowError($"Failed to install mod: {filePath}"); 46 | } 47 | } 48 | else if (IsRPVSFile(filePath)) 49 | { 50 | _logger.LogInformation($"File '{filePath}' is a RolePlayVoice file. Installing file."); 51 | try 52 | { 53 | _arkService.InstallArkFile(filePath); 54 | _logger.LogInformation($"RolePlayVoice file '{filePath}' installed successfully."); 55 | } 56 | catch (Exception ex) 57 | { 58 | _logger.LogError(ex, $"Failed to install RolePlayVoice file: {filePath}"); 59 | _errorWindowService.ShowError($"Failed to install RolePlayVoice file: {filePath}"); 60 | } 61 | } 62 | else 63 | { 64 | _logger.LogWarning($"File '{filePath}' does not match any known types (archive, mod, or RolePlayVoice file)."); 65 | } 66 | } 67 | 68 | public void CleanUpTempFiles() 69 | { 70 | _logger.LogInformation("Starting cleanup of temporary files."); 71 | 72 | if (_configurationService.GetConfigValue(config => config.AutoDelete) == false) 73 | { 74 | _logger.LogInformation("Temp files cleanup is disabled by configuration."); 75 | return; 76 | } 77 | 78 | var extractionPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\PenumbraModForwarder\Extraction"; 79 | var dtConversionPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\PenumbraModForwarder\DTConversion"; 80 | 81 | try 82 | { 83 | CleanDirectory(extractionPath); 84 | CleanDirectory(dtConversionPath); 85 | 86 | var downloadPath = _configurationService.GetConfigValue(config => config.DownloadPath); 87 | _logger.LogInformation($"Checking for mod files in download path: {downloadPath}"); 88 | 89 | if (Directory.Exists(downloadPath)) 90 | { 91 | foreach (var file in Directory.GetFiles(downloadPath)) 92 | { 93 | if (IsModFile(file)) 94 | { 95 | _logger.LogDebug($"Deleting mod file: {file}"); 96 | File.Delete(file); 97 | } 98 | } 99 | } 100 | 101 | _logger.LogInformation("Temp files cleaned up successfully."); 102 | } 103 | catch (Exception e) 104 | { 105 | _logger.LogError(e, "Error cleaning up temp files."); 106 | _errorWindowService.ShowError(e.ToString()); 107 | } 108 | } 109 | 110 | private void CleanDirectory(string path) 111 | { 112 | if (Directory.Exists(path)) 113 | { 114 | _logger.LogInformation($"Cleaning directory: {path}"); 115 | foreach (var file in Directory.GetFiles(path)) 116 | { 117 | _logger.LogDebug($"Deleting file: {file}"); 118 | File.Delete(file); 119 | } 120 | foreach (var dir in Directory.GetDirectories(path)) 121 | { 122 | _logger.LogDebug($"Deleting directory: {dir}"); 123 | Directory.Delete(dir, true); 124 | } 125 | } 126 | else 127 | { 128 | _logger.LogInformation($"Directory '{path}' does not exist, skipping cleanup."); 129 | } 130 | } 131 | 132 | private bool IsArchive(string filePath) 133 | { 134 | var extension = Path.GetExtension(filePath).ToLower(); 135 | _logger.LogInformation($"Checking if file '{filePath}' is an archive with extension: {extension}"); 136 | 137 | var allowedExtensions = new[] { ".zip", ".rar", ".7z" }; 138 | return allowedExtensions.Contains(extension); 139 | } 140 | 141 | private bool IsModFile(string filePath) 142 | { 143 | var extension = Path.GetExtension(filePath).ToLower(); 144 | _logger.LogInformation($"Checking if file '{filePath}' is a mod file with extension: {extension}"); 145 | 146 | var allowedExtensions = new[] { ".pmp", ".ttmp2", ".ttmp" }; 147 | return allowedExtensions.Contains(extension); 148 | } 149 | 150 | private bool IsRPVSFile(string filePath) 151 | { 152 | var extension = Path.GetExtension(filePath).ToLower(); 153 | _logger.LogInformation($"Checking if file '{filePath}' is a RolePlayVoice file with extension: {extension}"); 154 | 155 | var allowedExtensions = new[] { ".rpvsp" }; 156 | return allowedExtensions.Contains(extension); 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Services/PenumbraApi.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http.Headers; 2 | using System.Text; 3 | using Microsoft.Extensions.Logging; 4 | using Newtonsoft.Json; 5 | using PenumbraModForwarder.Common.Interfaces; 6 | 7 | namespace PenumbraModForwarder.Common.Services 8 | { 9 | public class PenumbraApi : IPenumbraApi 10 | { 11 | private const string BaseUrl = "http://localhost:42069/api"; 12 | private HttpClient HttpClient; 13 | private static bool _warningShown; 14 | private readonly IErrorWindowService _errorWindowService; 15 | private readonly ILogger _logger; 16 | private readonly ISystemTrayManager _systemTrayManager; 17 | private readonly IConfigurationService _configurationService; 18 | 19 | public PenumbraApi(ILogger logger, IErrorWindowService errorWindowService, ISystemTrayManager systemTrayManager, IConfigurationService configurationService) 20 | { 21 | _logger = logger ?? throw new ArgumentNullException(nameof(logger)); 22 | _errorWindowService = errorWindowService; 23 | _systemTrayManager = systemTrayManager; 24 | _configurationService = configurationService; 25 | 26 | HttpClient = new HttpClient 27 | { 28 | Timeout = TimeSpan.FromSeconds(_configurationService.GetConfigValue(o => o.AdvancedOptions.PenumbraTimeOutInSeconds)) 29 | }; 30 | } 31 | 32 | public async Task InstallAsync(string modPath) 33 | { 34 | var data = new ModInstallData(modPath); 35 | 36 | try 37 | { 38 | _logger.LogDebug("Sending install request for mod at {ModPath}", modPath); 39 | var result = await PostAsync("/installmod", data); 40 | 41 | if (result) 42 | { 43 | _logger.LogDebug("Install request sent successfully for mod at {ModPath}", modPath); 44 | _systemTrayManager.ShowNotification("Mod Installed", $"Mod installed successfully: {Path.GetFileName(modPath)}"); 45 | return true; 46 | } 47 | } 48 | catch (Exception ex) 49 | { 50 | _logger.LogError(ex, "Failed to install mod at {ModPath}", modPath); 51 | // throw; // Re-throw to allow higher-level handlers to process it 52 | } 53 | 54 | return false; 55 | } 56 | 57 | // TODO: Create a function to poll the /reloadmod endpoint to check if our mod has been installed correctly, give it a retry count of 15 58 | private async Task IsModInstalledAsync(string modPath, string modName) 59 | { 60 | throw new NotImplementedException(); 61 | } 62 | 63 | private async Task PostAsync(string route, object content) 64 | { 65 | try 66 | { 67 | var response = await PostRequestAsync(route, content); 68 | 69 | if (!response.IsSuccessStatusCode) 70 | { 71 | var responseBody = await response.Content.ReadAsStringAsync(); 72 | _logger.LogError("HTTP request error: {StatusCode} - {ReasonPhrase}. Response body: {ResponseBody}", 73 | response.StatusCode, response.ReasonPhrase, responseBody); 74 | response.EnsureSuccessStatusCode(); 75 | return false; 76 | } 77 | 78 | _logger.LogDebug("Successfully posted to {Route}", route); 79 | return true; 80 | } 81 | catch (HttpRequestException httpEx) 82 | { 83 | _logger.LogError(httpEx, "HTTP request error while posting to {Route}", route); 84 | HandleWarning(httpEx); 85 | } 86 | catch (Exception ex) 87 | { 88 | _logger.LogError(ex, "Unexpected error occurred while posting to {Route}", route); 89 | HandleWarning(ex); 90 | } 91 | 92 | return false; 93 | } 94 | 95 | private async Task PostRequestAsync(string route, object content) 96 | { 97 | // Ensure that the route starts with "/api" 98 | if (!route.StartsWith("/api")) 99 | route = "/api" + route; 100 | 101 | var json = JsonConvert.SerializeObject(content); 102 | var byteContent = new ByteArrayContent(Encoding.UTF8.GetBytes(json)) 103 | { 104 | Headers = 105 | { 106 | ContentType = new MediaTypeHeaderValue("application/json") 107 | } 108 | }; 109 | 110 | var requestUri = new Uri(new Uri(BaseUrl), route); 111 | _logger.LogDebug("Posting request to {RequestUri} with content: {Content}", requestUri, json); 112 | return await HttpClient.PostAsync(requestUri, byteContent); 113 | } 114 | 115 | 116 | private void HandleWarning(Exception ex) 117 | { 118 | if (!_warningShown) 119 | { 120 | _logger.LogWarning(ex, "Error communicating with Penumbra. Please ensure the HTTP API is enabled in Penumbra under 'Settings -> Advanced'."); 121 | // _errorWindowService.ShowError(ex.ToString()); 122 | _warningShown = true; 123 | } 124 | } 125 | 126 | private record ModInstallData(string Path) 127 | { 128 | public ModInstallData() : this(string.Empty) { } 129 | } 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Services/PenumbraInstallerService.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using Microsoft.Extensions.Logging; 3 | using PenumbraModForwarder.Common.Interfaces; 4 | 5 | namespace PenumbraModForwarder.Common.Services; 6 | 7 | public class PenumbraInstallerService : IPenumbraInstallerService 8 | { 9 | private readonly ILogger _logger; 10 | private readonly IPenumbraApi _penumbraApi; 11 | private readonly ISystemTrayManager _systemTrayManager; 12 | private readonly IConfigurationService _configurationService; 13 | private readonly IProgressWindowService _progressWindowService; 14 | private readonly string _dtConversionPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\PenumbraModForwarder\DTConversion"; 15 | 16 | public PenumbraInstallerService(ILogger logger, IPenumbraApi penumbraApi, ISystemTrayManager systemTrayManager, IConfigurationService configurationService, IProgressWindowService progressWindowService) 17 | { 18 | _logger = logger; 19 | _penumbraApi = penumbraApi; 20 | _systemTrayManager = systemTrayManager; 21 | _configurationService = configurationService; 22 | _progressWindowService = progressWindowService; 23 | 24 | if (!Directory.Exists(_dtConversionPath)) 25 | { 26 | Directory.CreateDirectory(_dtConversionPath); 27 | } 28 | } 29 | 30 | public bool InstallMod(string modPath) 31 | { 32 | var dtPath = UpdateToDt(modPath); 33 | _logger.LogInformation($"Installing mod: {dtPath}"); 34 | 35 | var result = Task.Run(async () => await _penumbraApi.InstallAsync(dtPath)).GetAwaiter().GetResult(); 36 | 37 | return result; 38 | } 39 | 40 | 41 | private string UpdateToDt(string modPath) 42 | { 43 | if (!IsConversionNeeded(modPath)) 44 | { 45 | _logger.LogInformation($"Converted mod already exists: {modPath}"); 46 | return GetConvertedModPath(modPath); 47 | } 48 | 49 | var textToolPath = _configurationService.GetConfigValue(config => config.TexToolPath); 50 | if (!string.IsNullOrEmpty(textToolPath) && File.Exists(textToolPath)) return ConvertToDt(modPath); 51 | _logger.LogWarning("TexTools not found. Aborting Conversion."); 52 | return modPath; 53 | } 54 | 55 | private string ConvertToDt(string modPath) 56 | { 57 | _logger.LogInformation($"Converting mod to DT: {modPath}"); 58 | var dtPath = GetConvertedModPath(modPath); 59 | 60 | _progressWindowService.ShowProgressWindow(); 61 | 62 | var process = new Process 63 | { 64 | StartInfo = new ProcessStartInfo 65 | { 66 | FileName = _configurationService.GetConfigValue(config => config.TexToolPath), 67 | Arguments = $"/upgrade \"{modPath}\" \"{dtPath}\"", 68 | RedirectStandardOutput = true, 69 | RedirectStandardError = true, 70 | UseShellExecute = false, 71 | CreateNoWindow = true 72 | } 73 | }; 74 | 75 | try 76 | { 77 | var fileName = Path.GetFileName(modPath); 78 | using (process) 79 | { 80 | process.Start(); 81 | 82 | var progress = 0.0; // Use double for smoother transitions 83 | var maxProgress = 88.0; 84 | 85 | while (!process.HasExited) 86 | { 87 | // Parabolic easing to slow down as we approach maxProgress 88 | // The closer progress gets to maxProgress, the smaller the increments become 89 | var easedIncrement = (1.0 - (progress / maxProgress)) * 1.2; // Slow down as progress increases 90 | 91 | progress += easedIncrement; 92 | 93 | // Cap progress at maxProgress to ensure it never reaches 100% 94 | if (progress >= maxProgress) 95 | { 96 | progress = maxProgress; 97 | } 98 | 99 | _progressWindowService.UpdateProgress(fileName, "Converting to DawnTrail", (int)progress); 100 | 101 | Thread.Sleep(50); 102 | } 103 | 104 | process.WaitForExit(); 105 | 106 | // The process doesn't exit correctly because of reasons, so let's have a 1-second wait 107 | Thread.Sleep(1); 108 | 109 | if (process.ExitCode != 0 || !File.Exists(dtPath)) 110 | { 111 | _logger.LogWarning($"Error converting mod to DT or conversion isn't needed: {modPath}"); 112 | return modPath; 113 | } 114 | 115 | _progressWindowService.UpdateProgress(fileName, "Conversion Complete", 100); 116 | 117 | _logger.LogInformation($"Mod converted to DT: {dtPath}"); 118 | _systemTrayManager.ShowNotification("Mod Conversion", $"Mod converted to DT: {Path.GetFileName(modPath)}"); 119 | 120 | if (!_configurationService.GetConfigValue(config => config.AutoDelete)) return dtPath; 121 | 122 | File.Delete(modPath); 123 | _logger.LogInformation($"Deleted original mod: {modPath}"); 124 | 125 | return dtPath; 126 | } 127 | } 128 | finally 129 | { 130 | _progressWindowService.CloseProgressWindow(); 131 | } 132 | } 133 | 134 | private bool IsConversionNeeded(string modPath) 135 | { 136 | var convertedModPath = GetConvertedModPath(modPath); 137 | return !File.Exists(convertedModPath); 138 | } 139 | 140 | private string GetConvertedModPath(string modPath) 141 | { 142 | return Path.Combine(_dtConversionPath, Path.GetFileNameWithoutExtension(modPath) + "_dt" + Path.GetExtension(modPath)); 143 | } 144 | 145 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Services/ProcessHelperService.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using Microsoft.Extensions.Logging; 3 | using PenumbraModForwarder.Common.Interfaces; 4 | 5 | namespace PenumbraModForwarder.Common.Services; 6 | 7 | public class ProcessHelperService : IProcessHelperService 8 | { 9 | private readonly ILogger _logger; 10 | 11 | public ProcessHelperService(ILogger logger) 12 | { 13 | _logger = logger; 14 | } 15 | 16 | private void OpenUrl(string url, string logMessage) 17 | { 18 | _logger.LogInformation(logMessage); 19 | Process.Start(new ProcessStartInfo(url) { UseShellExecute = true }); 20 | } 21 | 22 | public void OpenLogFolder() 23 | { 24 | var logFolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "PenumbraModForwarder", "logs"); 25 | _logger.LogInformation("Opening log folder at {LogFolderPath}.", logFolderPath); 26 | Process.Start(new ProcessStartInfo("explorer.exe", logFolderPath) { UseShellExecute = true }); 27 | } 28 | 29 | public bool IsApplicationAlreadyOpen() 30 | { 31 | var processName = Process.GetCurrentProcess().ProcessName; 32 | return Process.GetProcessesByName(processName).Length > 1; 33 | } 34 | 35 | public void OpenSupportDiscord() => OpenUrl("https://discord.gg/rtGXwMn7pX", "Opening Discord."); 36 | 37 | public void OpenXivArchive() => OpenUrl("https://www.xivmodarchive.com/", "Opening XivArchive."); 38 | 39 | public void OpenHelios() => OpenUrl("https://heliosphere.app/", "Opening Helios."); 40 | 41 | public void OpenDonate() => OpenUrl("https://ko-fi.com/sebastina", "Opening Donate."); 42 | 43 | public void OpenGlamourDresser() => OpenUrl("https://www.glamourdresser.com/", "Opening Glamour Dresser."); 44 | public void OpenNexusMods() => OpenUrl("https://www.nexusmods.com/finalfantasy14", "Opening Nexus Mods."); 45 | public void OpenAetherLink() => OpenUrl("https://beta.aetherlink.app/", "Opening Aether Link."); 46 | public void OpenPrettyKitty() => OpenUrl("https://prettykittyemporium.blogspot.com/?zx=67bbd385fd16c2ff", "Opening Pretty Kitty."); 47 | public void OpenArk() => OpenUrl("https://github.com/Sebane1/RoleplayingVoiceDalamud", "Opening Ark."); 48 | 49 | public void CrossGenPorting() => OpenUrl("https://www.xivmodarchive.com/modid/56505", "Opening CrossGen Porting."); 50 | public void XivModResources() => OpenUrl("https://discord.gg/8x2G75D46w", "Opening Xiv Mod Resources."); 51 | public void TexToolsDiscord() => OpenUrl("https://discord.gg/ffxivtextools", "Opening TexTools Discord."); 52 | public void SoundAndTextureResources() => OpenUrl("https://discord.gg/rtGXwMn7pX", "Opening Sound and Texture Resources."); 53 | // TODO: This discord invite is invalid. Update it. 54 | public void PixelatedAssistance() => OpenUrl("https://discord.gg/9XtTqws2cJ", "Opening Pixelated Assistance."); 55 | public void PenumbraResources() => OpenUrl("https://github.com/xivdev/Penumbra", "Opening Penumbra Resources."); 56 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Services/RegistryHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | using Microsoft.Win32; 3 | using PenumbraModForwarder.Common.Interfaces; 4 | using System; 5 | using System.IO; 6 | 7 | public class RegistryHelper : IRegistryHelper 8 | { 9 | private readonly IErrorWindowService _errorWindowService; 10 | private readonly ILogger _logger; 11 | private const string HKLMOpenCommandPath = @"SOFTWARE\Classes\PenumbraModpackFile\shell\open\command"; 12 | private const string HKCUClassesPath = @"Software\Classes\"; 13 | private const string RegistryPath = @"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FFXIV_TexTools"; 14 | 15 | public RegistryHelper(IErrorWindowService errorWindowService, ILogger logger) 16 | { 17 | _errorWindowService = errorWindowService; 18 | _logger = logger; 19 | } 20 | 21 | public string GetTexToolRegistryValue(string keyValue) 22 | { 23 | try 24 | { 25 | using var key = Registry.LocalMachine.OpenSubKey(RegistryPath); 26 | return key?.GetValue(keyValue)?.ToString(); 27 | } 28 | catch (Exception e) 29 | { 30 | _logger.LogError(e, "Error reading registry"); 31 | _errorWindowService.ShowError(e.ToString()); 32 | return null; 33 | } 34 | } 35 | 36 | public void CreateFileAssociation(IEnumerable extensions, string applicationPath) 37 | { 38 | try 39 | { 40 | foreach (var extension in extensions) 41 | { 42 | var extensionKeyPath = $@"{HKCUClassesPath}.{extension}"; 43 | using (var key = Registry.CurrentUser.CreateSubKey(extensionKeyPath)) 44 | { 45 | key?.SetValue("", "PenumbraModpackFile"); 46 | } 47 | } 48 | 49 | using (var iconKey = Registry.CurrentUser.CreateSubKey($@"{HKCUClassesPath}PenumbraModpackFile\DefaultIcon")) 50 | { 51 | iconKey?.SetValue("", $"{applicationPath},0"); 52 | } 53 | 54 | using (var commandKey = Registry.CurrentUser.CreateSubKey($@"{HKCUClassesPath}PenumbraModpackFile\shell\open\command")) 55 | { 56 | commandKey?.SetValue("", $"\"{applicationPath}\" \"%1\""); 57 | } 58 | 59 | _logger.LogInformation("File association created successfully."); 60 | } 61 | catch (Exception e) 62 | { 63 | _logger.LogError(e, "Error creating file association in registry"); 64 | _errorWindowService.ShowError(e.ToString()); 65 | } 66 | } 67 | 68 | public void RemoveFileAssociation(IEnumerable extensions) 69 | { 70 | try 71 | { 72 | foreach (var extension in extensions) 73 | { 74 | var extensionKeyPath = $@"{HKCUClassesPath}.{extension}"; 75 | Registry.CurrentUser.DeleteSubKeyTree(extensionKeyPath, false); 76 | } 77 | 78 | Registry.CurrentUser.DeleteSubKeyTree($@"{HKCUClassesPath}PenumbraModpackFile", false); 79 | 80 | _logger.LogInformation("File association removed successfully."); 81 | } 82 | catch (Exception e) 83 | { 84 | _logger.LogError(e, "Error removing file association from registry"); 85 | _errorWindowService.ShowError(e.ToString()); 86 | } 87 | } 88 | 89 | public void AddApplicationToStartup(string appName, string appPath) 90 | { 91 | try 92 | { 93 | using var registryKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true); 94 | registryKey?.SetValue(appName, $"\"{appPath}\""); 95 | 96 | _logger.LogInformation("Application added to startup."); 97 | } 98 | catch (Exception e) 99 | { 100 | _logger.LogError(e, "Error adding application to startup"); 101 | _errorWindowService.ShowError(e.ToString()); 102 | } 103 | } 104 | 105 | public void RemoveApplicationFromStartup(string appName) 106 | { 107 | try 108 | { 109 | using var registryKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true); 110 | registryKey?.DeleteValue(appName, false); 111 | 112 | _logger.LogInformation("Application removed from startup."); 113 | } 114 | catch (Exception e) 115 | { 116 | _logger.LogError(e, "Error removing application from startup"); 117 | _errorWindowService.ShowError(e.ToString()); 118 | } 119 | } 120 | 121 | private bool IsApplicationInStartup(string appName) 122 | { 123 | try 124 | { 125 | using var key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run"); 126 | var value = key?.GetValue(appName); 127 | return value != null; 128 | } 129 | catch (Exception e) 130 | { 131 | _logger.LogError(e, "Error checking if application is in startup"); 132 | return false; 133 | } 134 | } 135 | 136 | private bool IsFileAssociationSetCorrectly(string applicationPath) 137 | { 138 | try 139 | { 140 | using var key = Registry.LocalMachine.OpenSubKey(HKLMOpenCommandPath); 141 | if (key == null) 142 | { 143 | _logger.LogWarning($"Registry key not found: {HKLMOpenCommandPath}"); 144 | return false; 145 | } 146 | 147 | var currentValue = key.GetValue("")?.ToString(); 148 | if (currentValue == null) 149 | { 150 | _logger.LogWarning($"Registry value not found at path: {HKLMOpenCommandPath}"); 151 | return false; 152 | } 153 | 154 | currentValue = Environment.ExpandEnvironmentVariables(currentValue); 155 | var expectedValue = $"\"{applicationPath}\" \"%1\""; 156 | return string.Equals(currentValue, expectedValue, StringComparison.OrdinalIgnoreCase); 157 | } 158 | catch (Exception e) 159 | { 160 | _logger.LogError(e, "Error checking registry for existing file association"); 161 | return false; 162 | } 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /PenumbraModForwarder.Common/Services/TexToolsHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | using PenumbraModForwarder.Common.Interfaces; 3 | 4 | namespace PenumbraModForwarder.Common.Services; 5 | 6 | public class TexToolsHelper : ITexToolsHelper 7 | { 8 | private readonly ILogger _logger; 9 | private readonly IConfigurationService _configurationService; 10 | private readonly IErrorWindowService _errorWindowService; 11 | private readonly IRegistryHelper _registryHelper; 12 | 13 | public TexToolsHelper(ILogger logger, IConfigurationService configurationService, IErrorWindowService errorWindowService, IRegistryHelper registryHelper) 14 | { 15 | _logger = logger; 16 | _configurationService = configurationService; 17 | _errorWindowService = errorWindowService; 18 | _registryHelper = registryHelper; 19 | } 20 | 21 | public void SetTexToolsConsolePath() 22 | { 23 | if (_configurationService.GetConfigValue(config => !string.IsNullOrEmpty(config.TexToolPath))) 24 | { 25 | _logger.LogInformation("TexTools Console path already set"); 26 | return; 27 | } 28 | 29 | var path = _registryHelper.GetTexToolRegistryValue("InstallLocation"); 30 | 31 | if (string.IsNullOrEmpty(path)) 32 | { 33 | _logger.LogWarning("TexTools Console not found in registry"); 34 | _configurationService.SetConfigValue((config, texToolPath) => config.TexToolPath = texToolPath, string.Empty); 35 | return; 36 | } 37 | 38 | // Strip the path of "" 39 | if (path.StartsWith("\"") && path.EndsWith("\"")) 40 | { 41 | path = path[1..^1]; 42 | } 43 | 44 | var combinedPath = Path.Combine(path, "FFXIV_TexTools", "ConsoleTools.exe"); 45 | 46 | if (!File.Exists(combinedPath)) 47 | { 48 | _logger.LogWarning("TexTools Console not found at {TexToolsConsolePath}", combinedPath); 49 | _configurationService.SetConfigValue((config, texToolPath) => config.TexToolPath = texToolPath, string.Empty); 50 | return; 51 | } 52 | 53 | _logger.LogInformation("Setting TexTools Console path to {TexToolsConsolePath}", combinedPath); 54 | 55 | _configurationService.SetConfigValue((config, texToolPath) => config.TexToolPath = texToolPath, combinedPath); 56 | } 57 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.Test/PenumbraModForwarder.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net9.0 5 | enable 6 | enable 7 | 8 | false 9 | true 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /PenumbraModForwarder.Test/Services/ArchiveHelperTests.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | using Moq; 3 | using PenumbraModForwarder.Common.Interfaces; 4 | using PenumbraModForwarder.Common.Models; 5 | using PenumbraModForwarder.Common.Services; 6 | using Xunit; 7 | using System; 8 | using System.IO; 9 | using System.Threading.Tasks; 10 | 11 | public class ArchiveHelperTests 12 | { 13 | private readonly Mock> _loggerMock; 14 | private readonly Mock _fileSelectorMock; 15 | private readonly Mock _penumbraInstallerServiceMock; 16 | private readonly Mock _configurationServiceMock; 17 | private readonly Mock _errorWindowServiceMock; 18 | private readonly Mock _arkServiceMock; 19 | private readonly Mock _progressWindowServiceMock; 20 | private readonly ArchiveHelperService _service; 21 | 22 | public ArchiveHelperTests() 23 | { 24 | _loggerMock = new Mock>(); 25 | _fileSelectorMock = new Mock(); 26 | _penumbraInstallerServiceMock = new Mock(); 27 | _configurationServiceMock = new Mock(); 28 | _errorWindowServiceMock = new Mock(); 29 | _arkServiceMock = new Mock(); 30 | _progressWindowServiceMock = new Mock(); 31 | 32 | // Create the actual service instance with mocked dependencies 33 | _service = new ArchiveHelperService( 34 | _loggerMock.Object, 35 | _fileSelectorMock.Object, 36 | _penumbraInstallerServiceMock.Object, 37 | _configurationServiceMock.Object, 38 | _errorWindowServiceMock.Object, 39 | _arkServiceMock.Object, 40 | _progressWindowServiceMock.Object 41 | ); 42 | } 43 | 44 | [Fact] 45 | public async Task ExtractArchive_ShouldThrowArgumentNullException_WhenFilePathIsNullOrEmpty() 46 | { 47 | string filePath = null; 48 | await Assert.ThrowsAsync(() => _service.QueueExtractionAsync(filePath)); 49 | VerifyLoggerMessageAtLeastOnce(_loggerMock, LogLevel.Error, "File path is null or empty."); 50 | } 51 | 52 | [Fact] 53 | public async Task ExtractArchive_ShouldCallInstallArkFile_WhenArchiveContainsRolePlayVoiceFile() 54 | { 55 | var filePath = "test.rpvsp"; 56 | var files = new[] { "test.rpvsp" }; 57 | // Directly mock GetFilesInArchive method using Moq for dependency control 58 | var serviceWithMockedFiles = CreateArchiveHelperServiceWithMockedFiles(files); 59 | 60 | await serviceWithMockedFiles.QueueExtractionAsync(filePath); 61 | 62 | _arkServiceMock.Verify(ark => ark.InstallArkFile(filePath), Times.Once); 63 | } 64 | 65 | [Fact] 66 | public async Task ExtractArchive_ShouldExtractAndInstallFile_WhenSingleFileInArchive() 67 | { 68 | var files = new[] { "mod.ttmp2" }; 69 | var tempZipPath = CreateDummyZipFile("mod.ttmp2"); 70 | var serviceWithMockedFiles = CreateArchiveHelperServiceWithMockedFiles(files); 71 | 72 | await serviceWithMockedFiles.QueueExtractionAsync(tempZipPath); 73 | 74 | _penumbraInstallerServiceMock.Verify(install => install.InstallMod(It.IsAny()), Times.Once); 75 | CleanUpFile(tempZipPath); 76 | } 77 | 78 | [Fact] 79 | public async Task ExtractArchive_ShouldShowFileSelector_WhenMultipleFilesInArchiveAndExtractAllIsFalse() 80 | { 81 | var files = new[] { "mod1.ttmp2", "mod2.ttmp2" }; 82 | var tempZipPath = CreateDummyZipFile("mod1.ttmp2", "mod2.ttmp2"); 83 | var serviceWithMockedFiles = CreateArchiveHelperServiceWithMockedFiles(files); 84 | 85 | _configurationServiceMock.Setup(config => config.GetConfigValue(It.IsAny>())).Returns(false); 86 | _fileSelectorMock.Setup(selector => selector.SelectFiles(It.IsAny(), It.IsAny())).Returns(new[] { "mod1.ttmp2" }); 87 | 88 | await serviceWithMockedFiles.QueueExtractionAsync(tempZipPath); 89 | 90 | _fileSelectorMock.Verify(selector => selector.SelectFiles(It.IsAny(), It.IsAny()), Times.Once); 91 | _penumbraInstallerServiceMock.Verify(install => install.InstallMod(It.IsAny()), Times.Once); 92 | CleanUpFile(tempZipPath); 93 | } 94 | 95 | [Fact] 96 | public async Task ExtractArchive_ShouldDeleteArchive_WhenAutoDeleteIsTrue() 97 | { 98 | var files = new[] { "mod.ttmp2" }; 99 | var tempZipPath = CreateDummyZipFile("mod.ttmp2"); 100 | var serviceWithMockedFiles = CreateArchiveHelperServiceWithMockedFiles(files); 101 | 102 | _configurationServiceMock.Setup(config => config.GetConfigValue(It.IsAny>())).Returns(true); 103 | 104 | await serviceWithMockedFiles.QueueExtractionAsync(tempZipPath); 105 | 106 | Assert.False(File.Exists(tempZipPath), "The archive file should be deleted after extraction."); 107 | } 108 | 109 | // Helper method to create a service with mocked GetFilesInArchive method 110 | private ArchiveHelperService CreateArchiveHelperServiceWithMockedFiles(string[] files) 111 | { 112 | var serviceMock = new Mock( 113 | _loggerMock.Object, 114 | _fileSelectorMock.Object, 115 | _penumbraInstallerServiceMock.Object, 116 | _configurationServiceMock.Object, 117 | _errorWindowServiceMock.Object, 118 | _arkServiceMock.Object, 119 | _progressWindowServiceMock.Object 120 | ) { CallBase = true }; 121 | 122 | serviceMock.Setup(service => service.GetFilesInArchive(It.IsAny())).Returns(files); 123 | return serviceMock.Object; 124 | } 125 | 126 | private string CreateDummyZipFile(params string[] entryNames) 127 | { 128 | var tempFile = Path.GetTempFileName(); 129 | var tempZipPath = Path.ChangeExtension(tempFile, ".zip"); 130 | using (var archive = System.IO.Compression.ZipFile.Open(tempZipPath, System.IO.Compression.ZipArchiveMode.Create)) 131 | { 132 | foreach (var entryName in entryNames) 133 | { 134 | var entry = archive.CreateEntry(entryName); 135 | using (var entryStream = entry.Open()) 136 | using (var writer = new StreamWriter(entryStream)) 137 | { 138 | writer.Write("Dummy content"); 139 | } 140 | } 141 | } 142 | return tempZipPath; 143 | } 144 | 145 | private void CleanUpFile(string filePath) 146 | { 147 | if (File.Exists(filePath)) 148 | { 149 | File.Delete(filePath); 150 | } 151 | } 152 | 153 | private void VerifyLoggerMessageAtLeastOnce(Mock> loggerMock, LogLevel level, string expectedMessage) 154 | { 155 | loggerMock.Verify( 156 | logger => logger.Log( 157 | level, 158 | It.IsAny(), 159 | It.Is((v, t) => v.ToString().Contains(expectedMessage)), 160 | It.IsAny(), 161 | It.Is>((v, t) => true)), 162 | Times.AtLeastOnce, $"Expected the log message '{expectedMessage}' to be logged at least once, but it was not logged."); 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /PenumbraModForwarder.Test/Services/ConfigurationTest.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | using Moq; 3 | using AutoMapper; 4 | using Microsoft.Extensions.Logging; 5 | using PenumbraModForwarder.Common.Services; 6 | using PenumbraModForwarder.Common.Interfaces; 7 | using System.IO; 8 | 9 | public class ConfigurationTest : IDisposable 10 | { 11 | private readonly Mock> _loggerMock; 12 | private readonly Mock _errorWindowServiceMock; 13 | private readonly Mock _mapperMock; 14 | private readonly string _tempDirectory; 15 | 16 | public ConfigurationTest() 17 | { 18 | _loggerMock = new Mock>(); 19 | _errorWindowServiceMock = new Mock(); 20 | _mapperMock = new Mock(); 21 | _tempDirectory = Path.Combine(Path.GetTempPath(), "PenumbraModForwarderTest"); 22 | 23 | if (Directory.Exists(_tempDirectory)) 24 | { 25 | Directory.Delete(_tempDirectory, true); 26 | } 27 | Directory.CreateDirectory(_tempDirectory); 28 | } 29 | 30 | [Fact] 31 | public void GetConfigValue_ShouldReturnCorrectValue() 32 | { 33 | // Arrange 34 | var service = new ConfigurationService(_loggerMock.Object, _mapperMock.Object, _errorWindowServiceMock.Object); 35 | service.SetConfigValue((config, value) => config.DownloadPath = value, "test/path"); 36 | 37 | // Act 38 | var result = service.GetConfigValue(config => config.DownloadPath); 39 | 40 | // Assert 41 | Assert.Equal("test/path", result); 42 | } 43 | 44 | [Fact] 45 | public void SetConfigValue_ShouldSaveConfigAndTriggerConfigChangedEvent() 46 | { 47 | // Arrange 48 | var service = new ConfigurationService(_loggerMock.Object, _mapperMock.Object, _errorWindowServiceMock.Object); 49 | bool configChangedEventTriggered = false; 50 | service.ConfigChanged += (sender, args) => configChangedEventTriggered = true; 51 | 52 | // Act 53 | service.SetConfigValue((config, value) => config.AutoLoad = value, true); 54 | 55 | // Assert 56 | Assert.True(configChangedEventTriggered); 57 | Assert.True(service.GetConfigValue(config => config.AutoLoad)); 58 | } 59 | 60 | [Fact] 61 | public void MigrateOldConfig_ShouldMigrateOldConfigFiles() 62 | { 63 | var oldConfigDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "PenumbraModForwarder", "PenumbraModForwarder"); 64 | var oldDownloadPathConfig = Path.Combine(oldConfigDirectory, "DownloadPath.config"); 65 | 66 | if (!Directory.Exists(oldConfigDirectory)) 67 | { 68 | Directory.CreateDirectory(oldConfigDirectory); 69 | } 70 | 71 | File.WriteAllText(oldDownloadPathConfig, "old/path"); 72 | 73 | var service = new ConfigurationService(_loggerMock.Object, _mapperMock.Object, _errorWindowServiceMock.Object); 74 | 75 | service.MigrateOldConfig(); 76 | 77 | var newConfigValue = service.GetConfigValue(config => config.DownloadPath); 78 | Assert.Equal("old/path", newConfigValue); 79 | 80 | // Clean up 81 | if (File.Exists(oldDownloadPathConfig)) 82 | { 83 | File.Delete(oldDownloadPathConfig); 84 | } 85 | if (Directory.Exists(oldConfigDirectory)) 86 | { 87 | Directory.Delete(oldConfigDirectory, true); 88 | } 89 | } 90 | 91 | [Fact] 92 | public void MigrateOldConfig_ShouldHandleInvalidJsonInOldConfigFile() 93 | { 94 | var oldConfigDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "PenumbraModForwarder", "PenumbraModForwarder"); 95 | var oldConfigPath = Path.Combine(oldConfigDirectory, "Config.json"); 96 | 97 | if (!Directory.Exists(oldConfigDirectory)) 98 | { 99 | Directory.CreateDirectory(oldConfigDirectory); 100 | } 101 | 102 | File.WriteAllText(oldConfigPath, "Invalid JSON"); 103 | 104 | var service = new ConfigurationService(_loggerMock.Object, _mapperMock.Object, _errorWindowServiceMock.Object); 105 | 106 | service.MigrateOldConfig(); 107 | 108 | _loggerMock.Verify( 109 | logger => logger.Log( 110 | LogLevel.Error, 111 | It.IsAny(), 112 | It.Is((v, t) => v.ToString().Contains("Old config file is empty or invalid JSON")), 113 | It.IsAny(), 114 | It.Is>((v, t) => true)), 115 | Times.Once); 116 | 117 | // Clean up 118 | if (File.Exists(oldConfigPath)) 119 | { 120 | File.Delete(oldConfigPath); 121 | } 122 | if (Directory.Exists(oldConfigDirectory)) 123 | { 124 | Directory.Delete(oldConfigDirectory, true); 125 | } 126 | } 127 | 128 | public void Dispose() 129 | { 130 | if (Directory.Exists(_tempDirectory)) 131 | { 132 | Directory.Delete(_tempDirectory, true); 133 | } 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Extensions/ServiceExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using PenumbraModForwarder.Common.Interfaces; 3 | using PenumbraModForwarder.Common.Services; 4 | using PenumbraModForwarder.UI.ViewModels; 5 | using PenumbraModForwarder.UI.Views; 6 | using Microsoft.Extensions.Logging; 7 | using PenumbraModForwarder.Common.Models; 8 | using PenumbraModForwarder.UI.Interfaces; 9 | using PenumbraModForwarder.UI.Services; 10 | using Serilog; 11 | using Serilog.Events; 12 | 13 | namespace PenumbraModForwarder.UI.Extensions; 14 | 15 | public static class ServiceExtensions 16 | { 17 | public static IServiceProvider Configuration() 18 | { 19 | var services = new ServiceCollection(); 20 | ConfigureServices(services); 21 | ConfigureViews(services); 22 | ConfigureLogging(services); 23 | ConfigureAutoMapper(services); 24 | 25 | return services.BuildServiceProvider(); 26 | } 27 | 28 | private static void ConfigureServices(IServiceCollection services) 29 | { 30 | // Registering services 31 | services.AddSingleton(); 32 | services.AddSingleton(); 33 | services.AddSingleton(); 34 | services.AddSingleton(); 35 | services.AddSingleton(); 36 | services.AddTransient(); 37 | services.AddSingleton(); 38 | services.AddSingleton(); 39 | services.AddTransient(); 40 | services.AddSingleton(); 41 | services.AddSingleton(); 42 | services.AddSingleton(); 43 | services.AddSingleton(); 44 | services.AddSingleton(); 45 | services.AddSingleton(); 46 | services.AddSingleton(); 47 | services.AddSingleton(); 48 | services.AddSingleton(); 49 | services.AddSingleton(); 50 | services.AddSingleton(); 51 | } 52 | 53 | private static void ConfigureViews(IServiceCollection services) 54 | { 55 | // Registering ViewModels and Views as transient 56 | services.AddTransient(); 57 | services.AddTransient(); 58 | services.AddTransient(); 59 | services.AddTransient(); 60 | services.AddTransient(); 61 | services.AddTransient(); 62 | services.AddTransient(); 63 | services.AddTransient(); 64 | } 65 | 66 | private static void ConfigureLogging(IServiceCollection services) 67 | { 68 | var appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "PenumbraModForwarder", "logs"); 69 | Directory.CreateDirectory(appDataPath); 70 | 71 | #if DEBUG 72 | var minimumLevel = LogEventLevel.Debug; 73 | #else 74 | var minimumLevel = LogEventLevel.Information; 75 | #endif 76 | 77 | var logFilePath = Path.Combine(appDataPath, "log.txt"); 78 | 79 | Log.Logger = new LoggerConfiguration() 80 | .MinimumLevel.Is(minimumLevel) 81 | .WriteTo.Console() 82 | .WriteTo.File(logFilePath, 83 | restrictedToMinimumLevel: LogEventLevel.Information, 84 | rollingInterval: RollingInterval.Day, 85 | retainedFileCountLimit: 7, 86 | fileSizeLimitBytes: 10 * 1024 * 1024, 87 | rollOnFileSizeLimit: true 88 | ) 89 | .CreateLogger(); 90 | 91 | services.AddLogging(builder => 92 | { 93 | builder.ClearProviders(); 94 | builder.AddSerilog(); 95 | }); 96 | } 97 | 98 | 99 | 100 | private static void ConfigureAutoMapper(IServiceCollection services) 101 | { 102 | // AutoMapper configuration 103 | services.AddAutoMapper(typeof(MappingProfile)); 104 | } 105 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Extensions/WindowFlash.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace PenumbraModForwarder.UI.Extensions; 4 | 5 | public static class WindowFlash 6 | { 7 | [DllImport("user32.dll")] 8 | [return: MarshalAs(UnmanagedType.Bool)] 9 | private static extern bool FlashWindowEx(ref FLASHWINFO pwfi); 10 | 11 | // Flash both window and taskbar 12 | private const uint FLASHW_ALL = 3; 13 | // Flash the window until focus 14 | private const uint FLASHW_TIMERNOFG = 12; 15 | 16 | [StructLayout(LayoutKind.Sequential)] 17 | private struct FLASHWINFO 18 | { 19 | public uint cbSize; 20 | public IntPtr hwnd; 21 | public uint dwFlags; 22 | public uint uCount; 23 | public uint dwTimeout; 24 | } 25 | 26 | public static bool FlashNotification(this Form form) 27 | { 28 | IntPtr hWnd = form.Handle; 29 | FLASHWINFO fInfo = new FLASHWINFO(); 30 | 31 | fInfo.cbSize = Convert.ToUInt32(Marshal.SizeOf(fInfo)); 32 | fInfo.hwnd = hWnd; 33 | fInfo.dwFlags = FLASHW_ALL | FLASHW_TIMERNOFG; 34 | fInfo.uCount = uint.MaxValue; 35 | fInfo.dwTimeout = 0; 36 | 37 | return FlashWindowEx(ref fInfo); 38 | } 39 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Interfaces/IResourceManager.cs: -------------------------------------------------------------------------------- 1 | namespace PenumbraModForwarder.UI.Interfaces; 2 | 3 | public interface IResourceManager 4 | { 5 | Icon LoadIcon(string resourceName); 6 | Image LoadImage(string resourceName); 7 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Interfaces/IShortcutService.cs: -------------------------------------------------------------------------------- 1 | namespace PenumbraModForwarder.UI.Interfaces; 2 | 3 | public interface IShortcutService 4 | { 5 | void CreateShortcutInStartMenus(); 6 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Interfaces/IStartupService.cs: -------------------------------------------------------------------------------- 1 | namespace PenumbraModForwarder.UI.Interfaces; 2 | 3 | public interface IStartupService 4 | { 5 | void RunOnStartup(); 6 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Interfaces/IUpdateService.cs: -------------------------------------------------------------------------------- 1 | namespace PenumbraModForwarder.UI.Interfaces; 2 | 3 | public interface IUpdateService 4 | { 5 | public void CheckForUpdates(); 6 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Models/FileItem.cs: -------------------------------------------------------------------------------- 1 | namespace PenumbraModForwarder.UI.Models; 2 | 3 | public class FileItem 4 | { 5 | public string FullPath { get; set; } 6 | public string FileName { get; set; } 7 | 8 | public FileItem() { } 9 | 10 | public FileItem(string fullPath, string fileName) 11 | { 12 | FullPath = fullPath; 13 | FileName = fileName; 14 | } 15 | 16 | public override string ToString() => FileName; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/PenumbraModForwarder.UI.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | net9.0-windows 6 | enable 7 | true 8 | enable 9 | 1.0.1.6 10 | Penumbra Mod Forwarder 11 | PenumbraModForwarder 12 | PenumbraModForwarder 13 | PenumbraModForwarder 14 | PenumbraModForwarder 15 | PenumbraModForwarder 16 | Resources\PMFI.ico 17 | 18 | 19 | 20 | x64 21 | 22 | 23 | 24 | x64 25 | none 26 | true 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | Form 47 | 48 | 49 | Form 50 | 51 | 52 | Form 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using PenumbraModForwarder.Common.Interfaces; 3 | using PenumbraModForwarder.UI.Interfaces; 4 | using PenumbraModForwarder.UI.Views; 5 | using Serilog; 6 | 7 | namespace PenumbraModForwarder.UI; 8 | 9 | static class Program 10 | { 11 | private static IServiceProvider _serviceProvider; 12 | 13 | public static bool IsExiting { get; private set; } = false; 14 | 15 | [STAThread] 16 | static void Main(string[] args) 17 | { 18 | _serviceProvider = Extensions.ServiceExtensions.Configuration(); 19 | 20 | Application.EnableVisualStyles(); 21 | Application.SetCompatibleTextRenderingDefault(false); 22 | 23 | if (args.Length > 0) 24 | { 25 | var filePath = args[0]; 26 | HandleFileArgs(filePath); 27 | return; 28 | } 29 | 30 | Application.ApplicationExit += OnApplicationExit; 31 | 32 | IsProgramAlreadyRunning(); 33 | 34 | CheckForUpdates(); 35 | 36 | if (IsExiting) 37 | { 38 | return; 39 | } 40 | 41 | MigrateOldConfigIfExists(); 42 | CreateStartMenuShortcut(); 43 | SetTexToolsPath(); 44 | Application.Run(_serviceProvider.GetRequiredService()); 45 | } 46 | 47 | private static void OnApplicationExit(object sender, EventArgs e) 48 | { 49 | // Optional: Additional cleanup if needed 50 | } 51 | 52 | public static void ExitApplication() 53 | { 54 | IsExiting = true; 55 | 56 | Log.Information("Application is exiting."); 57 | Log.CloseAndFlush(); 58 | 59 | var fileHandlerService = _serviceProvider.GetRequiredService(); 60 | fileHandlerService.CleanUpTempFiles(); 61 | 62 | if (_serviceProvider is IDisposable disposable) 63 | { 64 | disposable.Dispose(); 65 | } 66 | 67 | Application.Exit(); 68 | } 69 | 70 | private static void HandleFileArgs(string filePath) 71 | { 72 | try 73 | { 74 | Log.Information($"Running application with file: {filePath}"); 75 | 76 | var allowedExtensions = new[] { ".pmp", ".ttmp2", ".ttmp" }; 77 | if (!allowedExtensions.Contains(Path.GetExtension(filePath))) 78 | { 79 | Log.Error($"File '{filePath}' is not a valid mod file. Aborting."); 80 | return; 81 | } 82 | 83 | var installService = _serviceProvider.GetRequiredService(); 84 | 85 | Log.Information("Starting mod installation..."); 86 | var result = installService.InstallMod(filePath); 87 | 88 | if (!result) 89 | { 90 | Log.Error("Mod installation failed."); 91 | return; 92 | } 93 | 94 | Log.Information("Mod installed successfully."); 95 | 96 | var systemTrayService = _serviceProvider.GetRequiredService(); 97 | Log.Information("Triggering exit process..."); 98 | systemTrayService.TriggerExit(); 99 | 100 | Log.Information("Exiting application..."); 101 | ExitApplication(); 102 | } 103 | catch (Exception ex) 104 | { 105 | Log.Error(ex, "An error occurred during the file handling process."); 106 | MessageBox.Show($"An unexpected error occurred: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 107 | ExitApplication(); 108 | } 109 | } 110 | 111 | private static void MigrateOldConfigIfExists() 112 | { 113 | var configurationService = _serviceProvider.GetRequiredService(); 114 | configurationService.MigrateOldConfig(); 115 | } 116 | 117 | private static void CheckForUpdates() 118 | { 119 | var updateService = _serviceProvider.GetRequiredService(); 120 | updateService.CheckForUpdates(); 121 | } 122 | 123 | private static void CreateStartMenuShortcut() 124 | { 125 | var shortcutService = _serviceProvider.GetRequiredService(); 126 | shortcutService.CreateShortcutInStartMenus(); 127 | } 128 | 129 | private static void SetTexToolsPath() 130 | { 131 | var texToolsHelper = _serviceProvider.GetRequiredService(); 132 | texToolsHelper.SetTexToolsConsolePath(); 133 | } 134 | 135 | private static void IsProgramAlreadyRunning() 136 | { 137 | var processHelperService = _serviceProvider.GetRequiredService(); 138 | var result = processHelperService.IsApplicationAlreadyOpen(); 139 | if (!result) return; 140 | MessageBox.Show("An instance of Penumbra Mod Forwarder is already running.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 141 | ExitApplication(); 142 | } 143 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Resources/PMFI.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sebane1/PenumbraModForwarder/14c009fbf7d96c4e7cb3fcb0ec35eb8285195cfb/PenumbraModForwarder.UI/Resources/PMFI.ico -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Resources/ffxiv2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sebane1/PenumbraModForwarder/14c009fbf7d96c4e7cb3fcb0ec35eb8285195cfb/PenumbraModForwarder.UI/Resources/ffxiv2-1.png -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sebane1/PenumbraModForwarder/14c009fbf7d96c4e7cb3fcb0ec35eb8285195cfb/PenumbraModForwarder.UI/Resources/icon.png -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Services/AdminService.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Security.Principal; 3 | using PenumbraModForwarder.Common.Interfaces; 4 | 5 | public class AdminService : IAdminService 6 | { 7 | public void PromptForAdminRestart() 8 | { 9 | var result = MessageBox.Show( 10 | "The application needs to restart with administrator privileges to update the registry. Do you want to restart as administrator?", 11 | "Administrator Privileges Required", 12 | MessageBoxButtons.YesNo, 13 | MessageBoxIcon.Warning); 14 | 15 | if (result == DialogResult.Yes) 16 | { 17 | RestartAsAdmin(); 18 | } 19 | } 20 | 21 | private void RestartAsAdmin(string argument = "--admin") 22 | { 23 | try 24 | { 25 | var proc = new Process 26 | { 27 | StartInfo = new ProcessStartInfo 28 | { 29 | FileName = Application.ExecutablePath, 30 | UseShellExecute = true, 31 | Verb = "runas", 32 | Arguments = argument 33 | } 34 | }; 35 | proc.Start(); 36 | Environment.Exit(0); 37 | } 38 | catch (Exception e) 39 | { 40 | MessageBox.Show("Failed to restart the application as administrator. Please manually restart it with elevated privileges."); 41 | } 42 | } 43 | 44 | 45 | public void PromptForUserRestart() 46 | { 47 | MessageBox.Show("Registry changes have been made. Please restart the application in normal user mode.", "Restart Required", MessageBoxButtons.OK, MessageBoxIcon.Information); 48 | } 49 | 50 | public bool IsAdmin() 51 | { 52 | using var identity = WindowsIdentity.GetCurrent(); 53 | var principal = new WindowsPrincipal(identity); 54 | return principal.IsInRole(WindowsBuiltInRole.Administrator); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Services/ErrorWindowService.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | using PenumbraModForwarder.Common.Interfaces; 3 | using PenumbraModForwarder.UI.Extensions; 4 | using PenumbraModForwarder.UI.ViewModels; 5 | using PenumbraModForwarder.UI.Views; 6 | 7 | namespace PenumbraModForwarder.UI.Services; 8 | 9 | public class ErrorWindowService : IErrorWindowService 10 | { 11 | private readonly ILogger _errorWindowLogger; 12 | private readonly ILogger _logger; 13 | private readonly IProcessHelperService _processHelperService; 14 | 15 | public ErrorWindowService(ILogger errorWindowLogger, ILogger logger, IProcessHelperService processHelperService) 16 | { 17 | _errorWindowLogger = errorWindowLogger; 18 | _logger = logger; 19 | _processHelperService = processHelperService; 20 | } 21 | 22 | public void ShowError(string message) 23 | { 24 | if (Application.OpenForms.Count > 0) 25 | { 26 | // Ensure we use the UI thread for showing the form 27 | Application.OpenForms[0].Invoke(() => ShowErrorInternal(message)); 28 | } 29 | else 30 | { 31 | ShowErrorInternal(message); 32 | } 33 | } 34 | 35 | private void ShowErrorInternal(string message) 36 | { 37 | // We need to manually pass in _processHelperService here, as the constructor of ErrorWindowViewModel won't have access to it. 38 | using var errorWindow = new ErrorWindow(new ErrorWindowViewModel(_errorWindowLogger, _processHelperService)); 39 | errorWindow.ViewModel.ErrorMessage = message; 40 | // Flash the window - it shouldn't really get to this as the window is forced focus 41 | errorWindow.FlashNotification(); 42 | errorWindow.ShowDialog(); 43 | } 44 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Services/FileSelector.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | using PenumbraModForwarder.Common.Interfaces; 3 | using PenumbraModForwarder.UI.Views; 4 | 5 | namespace PenumbraModForwarder.UI.Services 6 | { 7 | public class FileSelector : IFileSelector 8 | { 9 | private readonly ILogger _fileLogger; 10 | private readonly ILogger _logger; 11 | 12 | public FileSelector(ILogger fileLogger, ILogger logger) 13 | { 14 | _fileLogger = fileLogger; 15 | _logger = logger; 16 | } 17 | 18 | public string[] SelectFiles(string[] files, string archiveFileName) 19 | { 20 | if (Application.OpenForms.Count > 0) 21 | { 22 | // Ensure we use the UI thread for showing the form 23 | return Application.OpenForms[0].Invoke(() => SelectFilesInternal(files, archiveFileName)); 24 | } 25 | 26 | return SelectFilesInternal(files, archiveFileName); 27 | } 28 | 29 | private string[] SelectFilesInternal(string[] files, string archiveName) 30 | { 31 | using var fileSelectForm = new FileSelect(new FileSelectViewModel(_fileLogger)); 32 | fileSelectForm.ViewModel.LoadFiles(files); 33 | fileSelectForm.ViewModel.ArchiveFileName = archiveName; 34 | 35 | var result = fileSelectForm.ShowDialog(); 36 | 37 | if (result == DialogResult.OK) 38 | { 39 | _logger.LogInformation("Files selected: {0}", string.Join(", ", fileSelectForm.ViewModel.SelectedFiles)); 40 | return fileSelectForm.ViewModel.SelectedFiles; 41 | } 42 | 43 | _logger.LogWarning("File selection was canceled."); 44 | return []; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Services/ProgressWindowService.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | using PenumbraModForwarder.Common.Interfaces; 3 | using PenumbraModForwarder.UI.ViewModels; 4 | using PenumbraModForwarder.UI.Views; 5 | 6 | namespace PenumbraModForwarder.UI.Services 7 | { 8 | public class ProgressWindowService : IProgressWindowService 9 | { 10 | private readonly ILogger _progressWindowLogger; 11 | private readonly ILogger _logger; 12 | private ProgressWindow _progressWindow; 13 | private readonly object _lock = new object(); 14 | 15 | public ProgressWindowService(ILogger progressWindowLogger, ILogger logger) 16 | { 17 | _progressWindowLogger = progressWindowLogger; 18 | _logger = logger; 19 | } 20 | 21 | public void ShowProgressWindow() 22 | { 23 | lock (_lock) 24 | { 25 | if (IsProgressWindowAvailable()) 26 | { 27 | return; 28 | } 29 | 30 | ShowProgressWindowInternal(); 31 | } 32 | } 33 | 34 | public void UpdateProgress(string fileName, string operation, int progress) 35 | { 36 | lock (_lock) 37 | { 38 | if (!IsProgressWindowAvailable()) 39 | { 40 | // These logs just spam the log file and make it harder to debug. 41 | // _logger.LogWarning("Progress window is null or disposed, cannot update progress."); 42 | return; 43 | } 44 | 45 | UpdateProgressInternal(fileName, operation, progress); 46 | } 47 | } 48 | 49 | public void CloseProgressWindow() 50 | { 51 | lock (_lock) 52 | { 53 | if (!IsProgressWindowAvailable()) 54 | { 55 | return; 56 | } 57 | 58 | CloseProgressWindowInternal(); 59 | } 60 | } 61 | 62 | private bool IsProgressWindowAvailable() 63 | { 64 | return _progressWindow is {IsDisposed: false}; 65 | } 66 | 67 | private void ShowProgressWindowInternal() 68 | { 69 | _logger.LogDebug("ShowProgressWindowInternal"); 70 | if (Application.OpenForms.Count > 0) 71 | { 72 | Application.OpenForms[0].Invoke(CreateAndShowProgressWindow); 73 | } 74 | else 75 | { 76 | CreateAndShowProgressWindow(); 77 | } 78 | } 79 | 80 | private void CreateAndShowProgressWindow() 81 | { 82 | _progressWindow = new ProgressWindow(new ProgressWindowViewModel(_progressWindowLogger)); 83 | _progressWindow.Show(); 84 | } 85 | 86 | private void UpdateProgressInternal(string fileName, string operation, int progress) 87 | { 88 | _logger.LogDebug($"Updating progress for {fileName}: {operation} ({progress})"); 89 | try 90 | { 91 | if (_progressWindow.InvokeRequired) 92 | { 93 | _progressWindow.Invoke(() => SetProgress(fileName, operation, progress)); 94 | } 95 | else 96 | { 97 | SetProgress(fileName, operation, progress); 98 | } 99 | } 100 | catch (ObjectDisposedException ex) 101 | { 102 | // These logs just spam the log file and make it harder to debug. 103 | // _logger.LogWarning(ex, "Progress window was disposed while attempting to update progress."); 104 | } 105 | } 106 | 107 | private void SetProgress(string fileName, string operation, int progress) 108 | { 109 | if (!_progressWindow.IsDisposed) 110 | { 111 | _progressWindow.ViewModel.FileName = fileName; 112 | _progressWindow.ViewModel.Operation = operation; 113 | _progressWindow.ViewModel.Progress = progress; 114 | } 115 | } 116 | 117 | private void CloseProgressWindowInternal() 118 | { 119 | try 120 | { 121 | if (_progressWindow.InvokeRequired) 122 | { 123 | _progressWindow.Invoke(() => 124 | { 125 | if (!_progressWindow.IsDisposed) 126 | { 127 | _progressWindow.Close(); 128 | _progressWindow = null; 129 | } 130 | }); 131 | } 132 | else 133 | { 134 | _progressWindow.Close(); 135 | _progressWindow = null; 136 | } 137 | } 138 | catch (ObjectDisposedException ex) 139 | { 140 | // These logs just spam the log file and make it harder to debug. 141 | // _logger.LogWarning(ex, "Progress window was disposed while attempting to close it."); 142 | } 143 | } 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Services/ResourceManager.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using Microsoft.Extensions.Logging; 3 | using PenumbraModForwarder.Common.Interfaces; 4 | using PenumbraModForwarder.UI.Interfaces; 5 | 6 | namespace PenumbraModForwarder.UI.Services; 7 | 8 | public class ResourceManager : IResourceManager 9 | { 10 | private readonly ILogger _logger; 11 | private readonly IErrorWindowService _errorWindowService; 12 | 13 | public ResourceManager(ILogger logger, IErrorWindowService errorWindowService) 14 | { 15 | _logger = logger; 16 | _errorWindowService = errorWindowService; 17 | } 18 | 19 | public Icon LoadIcon(string resourceName) 20 | { 21 | var assembly = Assembly.GetExecutingAssembly(); 22 | using var stream = assembly.GetManifestResourceStream(resourceName); 23 | if (stream != null) return new Icon(stream); 24 | _logger.LogError($"Resource {resourceName} not found."); 25 | _errorWindowService.ShowError($"Resource {resourceName} not found."); 26 | throw new Exception($"Resource {resourceName} not found."); 27 | } 28 | 29 | public Image LoadImage(string resourceName) 30 | { 31 | var assembly = Assembly.GetExecutingAssembly(); 32 | using var stream = assembly.GetManifestResourceStream(resourceName); 33 | if (stream != null) return new Bitmap(stream); 34 | _logger.LogError($"Resource {resourceName} not found."); 35 | _errorWindowService.ShowError($"Resource {resourceName} not found."); 36 | throw new Exception($"Resource {resourceName} not found."); 37 | } 38 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Services/ShortcutService.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices.ComTypes; 3 | using Microsoft.Extensions.Logging; 4 | using PenumbraModForwarder.Common.Interfaces; 5 | using PenumbraModForwarder.Common.Services; 6 | using PenumbraModForwarder.UI.Interfaces; 7 | using WindowsShortcutFactory; 8 | 9 | namespace PenumbraModForwarder.UI.Services; 10 | 11 | public class ShortcutService : IShortcutService 12 | { 13 | private readonly ILogger _logger; 14 | private readonly IErrorWindowService _errorWindowService; 15 | 16 | public ShortcutService(ILogger logger, IErrorWindowService errorWindowService) 17 | { 18 | _logger = logger; 19 | _errorWindowService = errorWindowService; 20 | } 21 | 22 | public void CreateShortcutInStartMenus() 23 | { 24 | try 25 | { 26 | // Define the path for the Start Menu Programs folder 27 | var startMenuPath = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu); 28 | 29 | var appFolderPath = Path.Combine(startMenuPath, "Programs", "Penumbra Mod Forwarder"); 30 | var shortcutPath = Path.Combine(appFolderPath, "Penumbra Mod Forwarder.lnk"); 31 | 32 | var appPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "PenumbraModForwarder.exe"); 33 | 34 | if (!Directory.Exists(appFolderPath)) 35 | { 36 | Directory.CreateDirectory(appFolderPath); 37 | } 38 | 39 | using var shortcut = new WindowsShortcut(); 40 | shortcut.Path = appPath; 41 | shortcut.WorkingDirectory = Path.GetDirectoryName(appPath); 42 | shortcut.Description = "Penumbra Mod Forwarder"; 43 | 44 | // Save the shortcut inside the application folder 45 | shortcut.Save(shortcutPath); 46 | 47 | _logger.LogInformation("Created shortcut in start menu folder at: " + shortcutPath); 48 | } 49 | catch (Exception e) 50 | { 51 | _logger.LogError(e, "Failed to create shortcut in start menu"); 52 | _errorWindowService.ShowError(e.ToString()); 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Services/StartupService.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using Microsoft.Extensions.Logging; 3 | using PenumbraModForwarder.Common.Interfaces; 4 | using PenumbraModForwarder.UI.Interfaces; 5 | 6 | namespace PenumbraModForwarder.UI.Services; 7 | 8 | public class StartupService : IStartupService 9 | { 10 | private readonly ILogger _logger; 11 | private readonly IRegistryHelper _registryHelper; 12 | private readonly IConfigurationService _configurationService; 13 | private readonly IErrorWindowService _errorWindowService; 14 | private const string appName = "Penumbra Mod Forwarder"; 15 | 16 | public StartupService(ILogger logger, IRegistryHelper registryHelper, IConfigurationService configurationService, IErrorWindowService errorWindowService) 17 | { 18 | _logger = logger; 19 | _registryHelper = registryHelper; 20 | _configurationService = configurationService; 21 | _errorWindowService = errorWindowService; 22 | } 23 | 24 | public void RunOnStartup() 25 | { 26 | var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "PenumbraModForwarder.exe"); 27 | 28 | try 29 | { 30 | if (!_configurationService.GetConfigValue(c => c.StartOnBoot)) 31 | { 32 | _logger.LogInformation("Removing application from startup"); 33 | RemoveApplicationFromStartup(); 34 | return; 35 | } 36 | 37 | _logger.LogInformation("Adding application to startup"); 38 | AddApplicationToStartup(path); 39 | } 40 | catch (Exception e) 41 | { 42 | _logger.LogError(e, "Failed to run on startup"); 43 | _errorWindowService.ShowError(e.ToString()); 44 | } 45 | } 46 | 47 | private void AddApplicationToStartup(string appPath) 48 | { 49 | _registryHelper.AddApplicationToStartup(appName, appPath); 50 | } 51 | 52 | private void RemoveApplicationFromStartup() 53 | { 54 | _registryHelper.RemoveApplicationFromStartup(appName); 55 | } 56 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Services/SystemTrayManager.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using Microsoft.Extensions.Logging; 3 | using PenumbraModForwarder.Common.Interfaces; 4 | using PenumbraModForwarder.UI.Interfaces; 5 | using PenumbraModForwarder.UI.Views; 6 | 7 | namespace PenumbraModForwarder.UI.Services; 8 | 9 | public class SystemTrayManager : ISystemTrayManager 10 | { 11 | private readonly NotifyIcon _notifyIcon; 12 | private readonly ILogger _logger; 13 | private readonly IErrorWindowService _errorWindowService; 14 | private readonly IConfigurationService _configurationService; 15 | private readonly IProcessHelperService _processHelperService; 16 | private readonly IResourceManager _resourceManager; 17 | private readonly IUpdateService _updateService; 18 | 19 | private Icon _icon; 20 | 21 | public event Action OnExitRequested; 22 | 23 | public SystemTrayManager(ILogger logger, IErrorWindowService errorWindowService, IConfigurationService configurationService, IProcessHelperService processHelperService, IResourceManager resourceManager, IUpdateService updateService) 24 | { 25 | _logger = logger; 26 | _errorWindowService = errorWindowService; 27 | _configurationService = configurationService; 28 | _processHelperService = processHelperService; 29 | _resourceManager = resourceManager; 30 | _updateService = updateService; 31 | _icon = _resourceManager.LoadIcon("PenumbraModForwarder.UI.Resources.PMFI.ico"); 32 | _notifyIcon = new NotifyIcon 33 | { 34 | Icon = _icon, 35 | Visible = true, 36 | Text = "Penumbra Mod Fowarder", 37 | }; 38 | 39 | var contextMenu = new ContextMenuStrip(); 40 | AddItemsToContextMenu(contextMenu); 41 | _notifyIcon.ContextMenuStrip = contextMenu; 42 | 43 | _notifyIcon.DoubleClick += OnTrayIconDoubleClick; 44 | } 45 | 46 | private void AddItemsToContextMenu(ContextMenuStrip contextMenu) 47 | { 48 | contextMenu.Items.Add("Open Configuration", null, (sender, args) => 49 | { 50 | _logger.LogInformation("Opening configuration window."); 51 | var mainWindow = Application.OpenForms.OfType().FirstOrDefault(); 52 | 53 | if (mainWindow == null) return; 54 | 55 | if (mainWindow.WindowState == FormWindowState.Minimized) 56 | { 57 | mainWindow.WindowState = FormWindowState.Normal; 58 | } 59 | 60 | if (!mainWindow.Visible) 61 | { 62 | mainWindow.Show(); 63 | } 64 | 65 | mainWindow.Activate(); 66 | }); 67 | 68 | contextMenu.Items.Add("Check For Updates", null, (sender, args) => 69 | { 70 | _updateService.CheckForUpdates(); 71 | }); 72 | 73 | contextMenu.Items.Add(new ToolStripSeparator()); 74 | 75 | contextMenu.Items.Add(CreateDebuggingSubMenu()); 76 | 77 | contextMenu.Items.Add(new ToolStripSeparator()); 78 | 79 | contextMenu.Items.Add(CreateQuickLinksSubmenu()); 80 | contextMenu.Items.Add(CreateResourcesSubmenu()); 81 | 82 | contextMenu.Items.Add(new ToolStripSeparator()); 83 | 84 | var donateButton = ColouredMenuItem("Donate", Color.Green); 85 | donateButton.Click += (sender, args) => _processHelperService.OpenDonate(); 86 | contextMenu.Items.Add(donateButton); 87 | 88 | contextMenu.Items.Add(new ToolStripSeparator()); 89 | 90 | var exitButton = ColouredMenuItem("Exit", Color.Red); 91 | exitButton.Click += (sender, args) => TriggerExit(); 92 | contextMenu.Items.Add(exitButton); 93 | } 94 | 95 | 96 | public void TriggerExit() 97 | { 98 | _logger.LogInformation("Exit triggered from SystemTrayManager."); 99 | OnExitRequested?.Invoke(); 100 | } 101 | 102 | private static ToolStripMenuItem ColouredMenuItem(string text, Color colour) 103 | { 104 | var item = new ToolStripMenuItem(text); 105 | item.ForeColor = colour; 106 | return item; 107 | } 108 | 109 | private ToolStripMenuItem CreateDebuggingSubMenu() 110 | { 111 | var debugging = new ToolStripMenuItem("Debugging"); 112 | debugging.DropDownItems.Add("Open Log Folder", null, (sender, args) => _processHelperService.OpenLogFolder()); 113 | debugging.DropDownItems.Add("Cleanup Temp Files", null, (sender, args) => 114 | { 115 | // Save us from having to deal with circular dependencies 116 | var serviceProvider = Extensions.ServiceExtensions.Configuration(); 117 | var fileHandlerService = serviceProvider.GetRequiredService(); 118 | fileHandlerService.CleanUpTempFiles(); 119 | }); 120 | return debugging; 121 | } 122 | 123 | private ToolStripMenuItem CreateResourcesSubmenu() 124 | { 125 | var resources = new ToolStripMenuItem("Resources"); 126 | resources.DropDownItems.Add("CrossGenPorting", null, (sender, args) => _processHelperService.CrossGenPorting()); 127 | resources.DropDownItems.Add("Xiv Mod Resources", null, (sender, args) => _processHelperService.XivModResources()); 128 | resources.DropDownItems.Add("TexTools Discord", null, (sender, args) => _processHelperService.TexToolsDiscord()); 129 | resources.DropDownItems.Add("Sound and Texture Resources", null, (sender, args) => _processHelperService.SoundAndTextureResources()); 130 | // resources.DropDownItems.Add("Pixelated Assistance", null, (sender, args) => _processHelperService.PixelatedAssistance()); 131 | resources.DropDownItems.Add("Penumbra Resources", null, (sender, args) => _processHelperService.PenumbraResources()); 132 | 133 | return resources; 134 | } 135 | 136 | private ToolStripMenuItem CreateQuickLinksSubmenu() 137 | { 138 | var quickLinks = new ToolStripMenuItem("Quick Links"); 139 | quickLinks.DropDownItems.Add("Xiv Mod Archive", null, (sender, args) => _processHelperService.OpenXivArchive()); 140 | quickLinks.DropDownItems.Add("Glamour Dresser", null, (sender, args) => _processHelperService.OpenGlamourDresser()); 141 | quickLinks.DropDownItems.Add("Nexus Mods", null, (sender, args) => _processHelperService.OpenNexusMods()); 142 | quickLinks.DropDownItems.Add("Aetherlink", null, (sender, args) => _processHelperService.OpenAetherLink()); 143 | quickLinks.DropDownItems.Add("Heliosphere", null, (sender, args) => _processHelperService.OpenHelios()); 144 | quickLinks.DropDownItems.Add("The Pretty Kitty Emporium", null, (sender, args) => _processHelperService.OpenPrettyKitty()); 145 | 146 | return quickLinks; 147 | } 148 | 149 | public void ShowNotification(string title, string message) 150 | { 151 | if (!_configurationService.GetConfigValue(o => o.NotificationEnabled)) return; 152 | try 153 | { 154 | _logger.LogInformation("Showing notification: {title} - {message}", title, message); 155 | _notifyIcon.ShowBalloonTip(5000, title, message, ToolTipIcon.Info); 156 | } 157 | catch (Exception e) 158 | { 159 | _logger.LogError(e, "Failed to show notification."); 160 | _errorWindowService.ShowError(e.ToString()); 161 | } 162 | } 163 | 164 | private void OnTrayIconDoubleClick(object sender, EventArgs e) 165 | { 166 | Application.OpenForms.OfType().FirstOrDefault()?.Show(); 167 | Application.OpenForms.OfType().FirstOrDefault()?.Activate(); 168 | } 169 | 170 | public void Dispose() 171 | { 172 | _notifyIcon.Dispose(); 173 | } 174 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Services/UpdateService.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | using PenumbraModForwarder.UI.Interfaces; 3 | using AutoUpdaterDotNET; 4 | 5 | namespace PenumbraModForwarder.UI.Services; 6 | 7 | public class UpdateService : IUpdateService 8 | { 9 | private readonly ILogger _logger; 10 | private readonly string _updateUrl = "https://raw.githubusercontent.com/Sebane1/PenumbraModForwarder/master/update.xml"; 11 | 12 | public UpdateService(ILogger logger) 13 | { 14 | _logger = logger; 15 | 16 | AutoUpdater.ApplicationExitEvent += OnApplicationExit; 17 | AutoUpdater.DownloadPath = Application.StartupPath; 18 | AutoUpdater.Synchronous = true; 19 | AutoUpdater.Mandatory = true; 20 | AutoUpdater.UpdateMode = Mode.ForcedDownload; 21 | 22 | AutoUpdater.InstalledVersion = GetInstalledVersion(); 23 | } 24 | 25 | public void CheckForUpdates() 26 | { 27 | _logger.LogInformation("Checking for updates..."); 28 | _logger.LogInformation($"Current version: {AutoUpdater.InstalledVersion}"); 29 | 30 | AutoUpdater.Start(_updateUrl); 31 | } 32 | 33 | private Version GetInstalledVersion() 34 | { 35 | var versionString = Application.ProductVersion.Split("+")[0]; 36 | return new Version(versionString); 37 | } 38 | 39 | private void OnApplicationExit() 40 | { 41 | _logger.LogInformation("Application is exiting due to an update"); 42 | Program.ExitApplication(); 43 | } 44 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/ViewModels/ErrorWindowViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Reactive; 3 | using Microsoft.Extensions.Logging; 4 | using PenumbraModForwarder.Common.Interfaces; 5 | using ReactiveUI; 6 | 7 | namespace PenumbraModForwarder.UI.ViewModels; 8 | 9 | public class ErrorWindowViewModel : ReactiveObject 10 | { 11 | private readonly ILogger _logger; 12 | private readonly IProcessHelperService _processHelperService; 13 | 14 | private string _errorMessage = string.Empty; 15 | public string ErrorMessage 16 | { 17 | get => _errorMessage; 18 | set => this.RaiseAndSetIfChanged(ref _errorMessage, value); 19 | } 20 | 21 | public ReactiveCommand OpenLogFolderCommand { get; } 22 | public ReactiveCommand OpenDiscordCommand { get; } 23 | 24 | public ErrorWindowViewModel(ILogger logger, IProcessHelperService processHelperService) 25 | { 26 | _logger = logger; 27 | _processHelperService = processHelperService; 28 | OpenLogFolderCommand = ReactiveCommand.Create(OpenLogFolder); 29 | OpenDiscordCommand = ReactiveCommand.Create(OpenDiscord); 30 | } 31 | 32 | private void OpenLogFolder() 33 | { 34 | _processHelperService.OpenLogFolder(); 35 | } 36 | 37 | private void OpenDiscord() 38 | { 39 | _processHelperService.OpenSupportDiscord(); 40 | } 41 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/ViewModels/FileSelectViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.ObjectModel; 2 | using System.Reactive; 3 | using System.Reactive.Concurrency; 4 | using System.Text.RegularExpressions; 5 | using Microsoft.Extensions.Logging; 6 | using PenumbraModForwarder.UI.Models; 7 | using ReactiveUI; 8 | 9 | public partial class FileSelectViewModel : ReactiveObject 10 | { 11 | private readonly ILogger _logger; 12 | 13 | public ObservableCollection Files { get; } = new(); 14 | 15 | private string[] _selectedFiles = Array.Empty(); 16 | private string _archiveFileName = string.Empty; 17 | private bool _showAllSelectedVisible = true; 18 | private bool _showAllSelectedEnabled = true; 19 | private bool _showDtTextVisible; 20 | 21 | public bool ShowDtTextVisible 22 | { 23 | get => _showDtTextVisible; 24 | set => this.RaiseAndSetIfChanged(ref _showDtTextVisible, value); 25 | } 26 | 27 | public bool ShowAllSelectedVisible 28 | { 29 | get => _showAllSelectedVisible; 30 | set => this.RaiseAndSetIfChanged(ref _showAllSelectedVisible, value); 31 | } 32 | 33 | public bool ShowAllSelectedEnabled 34 | { 35 | get => _showAllSelectedEnabled; 36 | set => this.RaiseAndSetIfChanged(ref _showAllSelectedEnabled, value); 37 | } 38 | 39 | public string ArchiveFileName 40 | { 41 | get => _archiveFileName; 42 | set => this.RaiseAndSetIfChanged(ref _archiveFileName, value); 43 | } 44 | 45 | public string[] SelectedFiles 46 | { 47 | get => _selectedFiles; 48 | set => this.RaiseAndSetIfChanged(ref _selectedFiles, value); 49 | } 50 | 51 | public ReactiveCommand ConfirmSelectionCommand { get; } 52 | public ReactiveCommand CancelSelectionCommand { get; } 53 | public ReactiveCommand SelectAllCommand { get; } 54 | public Action CloseAction { get; set; } 55 | 56 | public FileSelectViewModel(ILogger logger) 57 | { 58 | _logger = logger; 59 | ConfirmSelectionCommand = ReactiveCommand.Create( 60 | ConfirmSelection, 61 | outputScheduler: RxApp.MainThreadScheduler 62 | ); 63 | 64 | CancelSelectionCommand = ReactiveCommand.Create( 65 | CancelSelection, 66 | outputScheduler: RxApp.MainThreadScheduler 67 | ); 68 | 69 | SelectAllCommand = ReactiveCommand.Create( 70 | SelectAll, 71 | outputScheduler: RxApp.MainThreadScheduler 72 | ); 73 | } 74 | 75 | public void LoadFiles(IEnumerable files) 76 | { 77 | Files.Clear(); 78 | 79 | var fileNameCounts = new Dictionary(); 80 | var enumerable = files as string[] ?? files.ToArray(); 81 | 82 | var preDtPattern = PreDtRegex(); // Matches both with and without brackets 83 | 84 | foreach (var file in enumerable) 85 | { 86 | var fileName = Path.GetFileName(file); 87 | 88 | if (fileNameCounts.TryGetValue(fileName, out var value)) 89 | { 90 | fileNameCounts[fileName] = ++value; 91 | } 92 | else 93 | { 94 | fileNameCounts[fileName] = 1; 95 | } 96 | } 97 | 98 | foreach (var file in enumerable) 99 | { 100 | var fileName = Path.GetFileName(file); 101 | 102 | var displayName = fileNameCounts[fileName] > 1 ? $"{fileName} ({file})" : fileName; 103 | 104 | // Check if the file matches the "Pre-DT" pattern and append '*' if true 105 | if (preDtPattern.IsMatch(file)) 106 | { 107 | displayName += " *"; 108 | ShowDtTextVisible = true; 109 | } 110 | 111 | var fileItem = new FileItem 112 | { 113 | FullPath = file, 114 | FileName = displayName 115 | }; 116 | 117 | Files.Add(fileItem); 118 | } 119 | } 120 | 121 | private void SelectAll() 122 | { 123 | var preDtPattern = PreDtRegex(); 124 | 125 | if (SelectedFiles.Length == Files.Count) 126 | { 127 | SelectedFiles = Files 128 | .Where(file => preDtPattern.IsMatch(file.FileName) || file.FileName.EndsWith(" *")) 129 | .Select(file => file.FullPath) 130 | .ToArray(); 131 | } 132 | else 133 | { 134 | SelectedFiles = Files 135 | .Select(file => file.FullPath) 136 | .ToArray(); 137 | } 138 | } 139 | 140 | 141 | 142 | private void CancelSelection() 143 | { 144 | _logger.LogWarning("File selection was canceled."); 145 | // We should clear the selected files array here too, just in case 146 | SelectedFiles = []; 147 | CloseAction?.Invoke(); 148 | } 149 | 150 | private void ConfirmSelection() 151 | { 152 | // This should already be on the UI thread due to the scheduler 153 | if (SelectedFiles.Any()) 154 | { 155 | _logger.LogInformation($"Confirming selection of {SelectedFiles.Length} files."); 156 | _logger.LogInformation($"Selected files: {string.Join(", ", SelectedFiles)}"); 157 | 158 | CloseAction?.Invoke(); 159 | } 160 | else 161 | { 162 | _logger.LogWarning("No files selected."); 163 | } 164 | } 165 | 166 | private static Regex PreDtRegex() 167 | { 168 | return new Regex(@"\[?(?i)pre[\s\-]?dt\]?", RegexOptions.Compiled); 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/ViewModels/MainWindowViewModel.cs: -------------------------------------------------------------------------------- 1 | using ReactiveUI; 2 | using System.Reactive; 3 | using Microsoft.Extensions.Logging; 4 | using PenumbraModForwarder.Common.Interfaces; 5 | using PenumbraModForwarder.Common.Models; 6 | using PenumbraModForwarder.UI.Interfaces; 7 | 8 | namespace PenumbraModForwarder.UI.ViewModels; 9 | 10 | public class MainWindowViewModel : ReactiveObject 11 | { 12 | private readonly IConfigurationService _configurationService; 13 | private readonly ILogger _logger; 14 | private readonly IProcessHelperService _processHelperService; 15 | private readonly IFileWatcher _fileWatcher; 16 | private readonly IAssociateFileTypeService _associateFileTypeService; 17 | private readonly IStartupService _startupService; 18 | private string _selectedFolderPath; 19 | private bool _autoDelete; 20 | private bool _autoLoad; 21 | private bool _extractAll; 22 | private bool _notificationEnabled; 23 | private bool _selectBoxEnabled; 24 | private string _versionNumber; 25 | private bool _fileLinkingEnabled; 26 | private bool _runOnStartup; 27 | 28 | public bool RunOnStartup 29 | { 30 | get => _runOnStartup; 31 | set => this.RaiseAndSetIfChanged(ref _runOnStartup, value); 32 | } 33 | 34 | public bool FileLinkingEnabled 35 | { 36 | get => _fileLinkingEnabled; 37 | set => this.RaiseAndSetIfChanged(ref _fileLinkingEnabled, value); 38 | } 39 | 40 | public string SelectedFolderPath 41 | { 42 | get => _selectedFolderPath; 43 | set => this.RaiseAndSetIfChanged(ref _selectedFolderPath, value); 44 | } 45 | 46 | public string VersionNumber 47 | { 48 | get => _versionNumber; 49 | set => this.RaiseAndSetIfChanged(ref _versionNumber, value); 50 | } 51 | 52 | public bool NotificationEnabled 53 | { 54 | get => _notificationEnabled; 55 | set => this.RaiseAndSetIfChanged(ref _notificationEnabled, value); 56 | } 57 | 58 | public bool AutoDelete 59 | { 60 | get => _autoDelete; 61 | set => this.RaiseAndSetIfChanged(ref _autoDelete, value); 62 | } 63 | 64 | public bool AutoLoad 65 | { 66 | get => _autoLoad; 67 | set 68 | { 69 | this.RaiseAndSetIfChanged(ref _autoLoad, value); 70 | SelectBoxEnabled = value; 71 | } 72 | } 73 | 74 | public bool ExtractAll 75 | { 76 | get => _extractAll; 77 | set => this.RaiseAndSetIfChanged(ref _extractAll, value); 78 | } 79 | 80 | public bool SelectBoxEnabled 81 | { 82 | get => _selectBoxEnabled; 83 | set => this.RaiseAndSetIfChanged(ref _selectBoxEnabled, value); 84 | } 85 | 86 | public ReactiveCommand OpenFolderDialog { get; } 87 | public ReactiveCommand UpdateAutoDeleteCommand { get; } 88 | public ReactiveCommand UpdateAutoLoadCommand { get; } 89 | public ReactiveCommand UpdateExtractAllCommand { get; } 90 | public ReactiveCommand UpdateNotificationCommand { get; } 91 | public ReactiveCommand EnableFileLinkingCommand { get; } 92 | public ReactiveCommand UpdateStartupCommand { get; } 93 | 94 | #region Link Buttons 95 | 96 | public ReactiveCommand OpenXivArchiveCommand { get; } 97 | public ReactiveCommand OpenGlamourDresserCommand { get; } 98 | public ReactiveCommand OpenNexusModsCommand { get; } 99 | public ReactiveCommand OpenAetherLinkCommand { get; } 100 | public ReactiveCommand OpenHelioSphereCommand { get; } 101 | public ReactiveCommand OpenPrettyKittyCommand { get; } 102 | public ReactiveCommand OpenDiscordCommand { get; } 103 | public ReactiveCommand OpenDonateCommand { get; } 104 | 105 | #endregion 106 | 107 | 108 | public MainWindowViewModel(IConfigurationService configurationService, ILogger logger, IProcessHelperService processHelperService, IAssociateFileTypeService associateFileTypeService, IStartupService startupService, IFileWatcher fileWatcher) 109 | { 110 | _configurationService = configurationService; 111 | _logger = logger; 112 | _processHelperService = processHelperService; 113 | _associateFileTypeService = associateFileTypeService; 114 | _startupService = startupService; 115 | // This will start the file watcher 116 | _fileWatcher = fileWatcher; 117 | SetAllConfigValues(); 118 | SetVersionNumber(); 119 | 120 | _logger.LogInformation("MainWindowViewModel initialized"); 121 | OpenFolderDialog = ReactiveCommand.Create(OpenFolder); 122 | UpdateAutoDeleteCommand = ReactiveCommand.Create(UpdateAutoDelete); 123 | UpdateAutoLoadCommand = ReactiveCommand.Create(UpdateAutoLoad); 124 | UpdateExtractAllCommand = ReactiveCommand.Create(UpdateExtractAll); 125 | UpdateNotificationCommand = ReactiveCommand.Create(UpdateNotification); 126 | EnableFileLinkingCommand = ReactiveCommand.Create(EnableFileLinking); 127 | UpdateStartupCommand = ReactiveCommand.Create(UpdateStartup); 128 | 129 | #region Link Buttons 130 | 131 | OpenXivArchiveCommand = ReactiveCommand.Create(OpenXivArchive); 132 | OpenGlamourDresserCommand = ReactiveCommand.Create(OpenGlamourDresser); 133 | OpenNexusModsCommand = ReactiveCommand.Create(OpenNexusMods); 134 | OpenAetherLinkCommand = ReactiveCommand.Create(OpenAetherLink); 135 | OpenHelioSphereCommand = ReactiveCommand.Create(OpenHelioSphere); 136 | OpenPrettyKittyCommand = ReactiveCommand.Create(OpenPrettyKitty); 137 | OpenDiscordCommand = ReactiveCommand.Create(OpenDiscord); 138 | OpenDonateCommand = ReactiveCommand.Create(OpenDonate); 139 | 140 | #endregion 141 | } 142 | 143 | private void SetAllConfigValues() 144 | { 145 | SelectedFolderPath = _configurationService.GetConfigValue(config => config.DownloadPath); 146 | AutoDelete = _configurationService.GetConfigValue(config => config.AutoDelete); 147 | AutoLoad = _configurationService.GetConfigValue(config => config.AutoLoad); 148 | ExtractAll = _configurationService.GetConfigValue(config => config.ExtractAll); 149 | NotificationEnabled = _configurationService.GetConfigValue(config => config.NotificationEnabled); 150 | FileLinkingEnabled = _configurationService.GetConfigValue(config => config.FileLinkingEnabled); 151 | RunOnStartup = _configurationService.GetConfigValue(config => config.StartOnBoot); 152 | 153 | RunConfigLogic(); 154 | } 155 | 156 | private void RunConfigLogic() 157 | { 158 | _logger.LogInformation("Setting config logic"); 159 | var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "PenumbraModForwarder.exe"); 160 | 161 | if (_configurationService.GetConfigValue(o => o.StartOnBoot)) 162 | { 163 | _startupService.RunOnStartup(); 164 | } 165 | 166 | if (_configurationService.GetConfigValue(o => o.FileLinkingEnabled)) 167 | { 168 | _associateFileTypeService.AssociateFileTypes(path); 169 | } 170 | } 171 | 172 | private void SetVersionNumber() 173 | { 174 | VersionNumber = $"Version: {Application.ProductVersion.Split("+")[0]}"; 175 | } 176 | 177 | #region Link Buttons 178 | 179 | private void OpenXivArchive() 180 | { 181 | _processHelperService.OpenXivArchive(); 182 | } 183 | 184 | private void OpenGlamourDresser() 185 | { 186 | _processHelperService.OpenGlamourDresser(); 187 | } 188 | 189 | private void OpenNexusMods() 190 | { 191 | _processHelperService.OpenNexusMods(); 192 | } 193 | 194 | private void OpenAetherLink() 195 | { 196 | _processHelperService.OpenAetherLink(); 197 | } 198 | 199 | private void OpenHelioSphere() 200 | { 201 | if (MessageBox.Show("Heliosphere requires a separate dalamud plugin to use.") == DialogResult.OK) 202 | { 203 | _processHelperService.OpenHelios(); 204 | } 205 | } 206 | 207 | private void OpenPrettyKitty() 208 | { 209 | _processHelperService.OpenPrettyKitty(); 210 | } 211 | 212 | private void OpenDiscord() 213 | { 214 | _processHelperService.OpenSupportDiscord(); 215 | } 216 | 217 | private void OpenDonate() 218 | { 219 | _processHelperService.OpenDonate(); 220 | } 221 | 222 | #endregion 223 | 224 | private void UpdateStartup(bool value) 225 | { 226 | _logger.LogInformation($"RunOnStartup: {value}"); 227 | _configurationService.SetConfigValue( 228 | (config, startup) => config.StartOnBoot = startup, 229 | value 230 | ); 231 | _startupService.RunOnStartup(); 232 | } 233 | 234 | private void UpdateNotification(bool value) 235 | { 236 | _logger.LogInformation($"NotificationEnabled: {value}"); 237 | _configurationService.SetConfigValue( 238 | (config, notification) => config.NotificationEnabled = notification, 239 | value 240 | ); 241 | } 242 | 243 | private void UpdateAutoDelete(bool value) 244 | { 245 | _logger.LogInformation($"AutoDelete: {value}"); 246 | _configurationService.SetConfigValue( 247 | (config, delete) => config.AutoDelete = delete, 248 | value 249 | ); 250 | } 251 | 252 | private void EnableFileLinking(bool value) 253 | { 254 | _logger.LogInformation($"FileLinkingEnabled: {value}"); 255 | _configurationService.SetConfigValue( 256 | (config, linking) => config.FileLinkingEnabled = linking, 257 | value 258 | ); 259 | var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "PenumbraModForwarder.exe"); 260 | _associateFileTypeService.AssociateFileTypes(path); 261 | } 262 | 263 | private void UpdateAutoLoad(bool value) 264 | { 265 | _logger.LogInformation($"AutoLoad: {value}"); 266 | _configurationService.SetConfigValue( 267 | (config, forward) => config.AutoLoad = forward, 268 | value 269 | ); 270 | } 271 | 272 | private void UpdateExtractAll(bool value) 273 | { 274 | _logger.LogInformation($"ExtractAll: {value}"); 275 | _configurationService.SetConfigValue( 276 | (config, extract) => config.ExtractAll = extract, 277 | value 278 | ); 279 | } 280 | 281 | private void OpenFolder() 282 | { 283 | using var dialog = new FolderBrowserDialog(); 284 | if (dialog.ShowDialog() != DialogResult.OK) return; 285 | SelectedFolderPath = dialog.SelectedPath; 286 | 287 | _logger.LogInformation($"Selected folder: {SelectedFolderPath}"); 288 | 289 | _configurationService.SetConfigValue( 290 | (config, path) => config.DownloadPath = path, 291 | SelectedFolderPath 292 | ); 293 | } 294 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/ViewModels/ProgressWindowViewModel.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | using ReactiveUI; 3 | 4 | namespace PenumbraModForwarder.UI.ViewModels; 5 | 6 | public class ProgressWindowViewModel : ReactiveObject 7 | { 8 | private readonly ILogger _logger; 9 | 10 | private string _fileName = string.Empty; 11 | public string FileName 12 | { 13 | get => _fileName; 14 | set => this.RaiseAndSetIfChanged(ref _fileName, value); 15 | } 16 | 17 | private string _operation = string.Empty; 18 | public string Operation 19 | { 20 | get => _operation; 21 | set => this.RaiseAndSetIfChanged(ref _operation, value); 22 | } 23 | 24 | private int _progress; 25 | public int Progress 26 | { 27 | get => _progress; 28 | set => this.RaiseAndSetIfChanged(ref _progress, value); 29 | } 30 | 31 | public ProgressWindowViewModel(ILogger logger) 32 | { 33 | _logger = logger; 34 | } 35 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Views/ErrorWindow.Designer.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace PenumbraModForwarder.UI.Views; 4 | 5 | partial class ErrorWindow 6 | { 7 | /// 8 | /// Required designer variable. 9 | /// 10 | private IContainer components = null; 11 | 12 | /// 13 | /// Clean up any resources being used. 14 | /// 15 | /// true if managed resources should be disposed; otherwise, false. 16 | protected override void Dispose(bool disposing) 17 | { 18 | if (disposing && (components != null)) 19 | { 20 | components.Dispose(); 21 | } 22 | 23 | base.Dispose(disposing); 24 | } 25 | 26 | #region Windows Form Designer generated code 27 | 28 | /// 29 | /// Required method for Designer support - do not modify 30 | /// the contents of this method with the code editor. 31 | /// 32 | private void InitializeComponent() 33 | { 34 | error_TextBox = new RichTextBox(); 35 | openlog_Button = new Button(); 36 | openDiscord_Button = new Button(); 37 | SuspendLayout(); 38 | // 39 | // error_TextBox 40 | // 41 | error_TextBox.CausesValidation = false; 42 | error_TextBox.Location = new Point(12, 12); 43 | error_TextBox.Name = "error_TextBox"; 44 | error_TextBox.ReadOnly = true; 45 | error_TextBox.Size = new Size(776, 365); 46 | error_TextBox.TabIndex = 0; 47 | error_TextBox.Text = ""; 48 | // 49 | // openlog_Button 50 | // 51 | openlog_Button.Location = new Point(263, 394); 52 | openlog_Button.Name = "openlog_Button"; 53 | openlog_Button.Size = new Size(112, 44); 54 | openlog_Button.TabIndex = 1; 55 | openlog_Button.Text = "Open Log"; 56 | openlog_Button.UseVisualStyleBackColor = true; 57 | // 58 | // openDiscord_Button 59 | // 60 | openDiscord_Button.Location = new Point(435, 394); 61 | openDiscord_Button.Name = "openDiscord_Button"; 62 | openDiscord_Button.Size = new Size(112, 44); 63 | openDiscord_Button.TabIndex = 2; 64 | openDiscord_Button.Text = "Open Discord"; 65 | openDiscord_Button.UseVisualStyleBackColor = true; 66 | // 67 | // ErrorWindow 68 | // 69 | AutoScaleDimensions = new SizeF(7F, 15F); 70 | AutoScaleMode = AutoScaleMode.Font; 71 | ClientSize = new Size(800, 450); 72 | Controls.Add(openDiscord_Button); 73 | Controls.Add(openlog_Button); 74 | Controls.Add(error_TextBox); 75 | MaximizeBox = false; 76 | MinimizeBox = false; 77 | Name = "ErrorWindow"; 78 | ShowIcon = false; 79 | Text = "Error Window"; 80 | ResumeLayout(false); 81 | } 82 | 83 | #endregion 84 | 85 | private RichTextBox error_TextBox; 86 | private Button openlog_Button; 87 | private Button openDiscord_Button; 88 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Views/ErrorWindow.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Reactive.Disposables; 3 | using PenumbraModForwarder.UI.ViewModels; 4 | using ReactiveUI; 5 | using ReactiveUI.Fody.Helpers; 6 | 7 | namespace PenumbraModForwarder.UI.Views; 8 | 9 | public partial class ErrorWindow : Form, IViewFor 10 | { 11 | [DefaultValue(null)] public ErrorWindowViewModel ViewModel { get; set; } 12 | 13 | object IViewFor.ViewModel 14 | { 15 | get => ViewModel; 16 | set => ViewModel = (ErrorWindowViewModel)value; 17 | } 18 | 19 | public ErrorWindow(ErrorWindowViewModel viewModel) 20 | { 21 | InitializeComponent(); 22 | ViewModel = viewModel; 23 | 24 | this.WhenActivated(disposables => 25 | { 26 | this.Bind(ViewModel, vm => vm.ErrorMessage, v => v.error_TextBox.Text) 27 | .DisposeWith(disposables); 28 | 29 | this.BindCommand(ViewModel, vm => vm.OpenLogFolderCommand, v => v.openlog_Button) 30 | .DisposeWith(disposables); 31 | 32 | this.BindCommand(ViewModel, vm => vm.OpenDiscordCommand, v => v.openDiscord_Button) 33 | .DisposeWith(disposables); 34 | }); 35 | } 36 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Views/ErrorWindow.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Views/FileSelect.Designer.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace PenumbraModForwarder.UI.Views; 4 | 5 | partial class FileSelect 6 | { 7 | /// 8 | /// Required designer variable. 9 | /// 10 | private IContainer components = null; 11 | 12 | /// 13 | /// Clean up any resources being used. 14 | /// 15 | /// true if managed resources should be disposed; otherwise, false. 16 | protected override void Dispose(bool disposing) 17 | { 18 | if (disposing && (components != null)) 19 | { 20 | components.Dispose(); 21 | } 22 | 23 | base.Dispose(disposing); 24 | } 25 | 26 | #region Windows Form Designer generated code 27 | private System.Windows.Forms.CheckedListBox fileCheckedListBox; 28 | 29 | /// 30 | /// Required method for Designer support - do not modify 31 | /// the contents of this method with the code editor. 32 | /// 33 | private void InitializeComponent() { 34 | ComponentResourceManager resources = new ComponentResourceManager(typeof(FileSelect)); 35 | fileCheckedListBox = new CheckedListBox(); 36 | confirmButton = new Button(); 37 | archivefile_Label = new Label(); 38 | cancel_Button = new Button(); 39 | selectall_Button = new Button(); 40 | predt_Label = new Label(); 41 | SuspendLayout(); 42 | // 43 | // fileCheckedListBox 44 | // 45 | fileCheckedListBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; 46 | fileCheckedListBox.FormattingEnabled = true; 47 | fileCheckedListBox.Location = new Point(12, 28); 48 | fileCheckedListBox.MinimumSize = new Size(150, 50); 49 | fileCheckedListBox.Name = "fileCheckedListBox"; 50 | fileCheckedListBox.Size = new Size(270, 76); 51 | fileCheckedListBox.TabIndex = 1; 52 | // 53 | // confirmButton 54 | // 55 | confirmButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; 56 | confirmButton.Location = new Point(163, 140); 57 | confirmButton.Name = "confirmButton"; 58 | confirmButton.Size = new Size(119, 37); 59 | confirmButton.TabIndex = 4; 60 | confirmButton.Text = "Confirm Selection"; 61 | confirmButton.UseVisualStyleBackColor = true; 62 | // 63 | // archivefile_Label 64 | // 65 | archivefile_Label.AutoSize = true; 66 | archivefile_Label.Dock = DockStyle.Left; 67 | archivefile_Label.Font = new Font("Segoe UI", 14.25F, FontStyle.Bold); 68 | archivefile_Label.Location = new Point(0, 0); 69 | archivefile_Label.Name = "archivefile_Label"; 70 | archivefile_Label.Size = new Size(47, 25); 71 | archivefile_Label.TabIndex = 0; 72 | archivefile_Label.Text = "text"; 73 | archivefile_Label.TextAlign = ContentAlignment.MiddleCenter; 74 | // 75 | // cancel_Button 76 | // 77 | cancel_Button.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; 78 | cancel_Button.Location = new Point(12, 140); 79 | cancel_Button.Name = "cancel_Button"; 80 | cancel_Button.Size = new Size(119, 37); 81 | cancel_Button.TabIndex = 5; 82 | cancel_Button.Text = "Cancel"; 83 | cancel_Button.UseVisualStyleBackColor = true; 84 | // 85 | // selectall_Button 86 | // 87 | selectall_Button.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; 88 | selectall_Button.Enabled = false; 89 | selectall_Button.Location = new Point(12, 111); 90 | selectall_Button.Name = "selectall_Button"; 91 | selectall_Button.Size = new Size(75, 23); 92 | selectall_Button.TabIndex = 2; 93 | selectall_Button.Text = "Select All"; 94 | selectall_Button.UseVisualStyleBackColor = true; 95 | selectall_Button.Visible = false; 96 | // 97 | // predt_Label 98 | // 99 | predt_Label.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; 100 | predt_Label.AutoSize = true; 101 | predt_Label.Location = new Point(128, 115); 102 | predt_Label.Name = "predt_Label"; 103 | predt_Label.Size = new Size(154, 15); 104 | predt_Label.TabIndex = 3; 105 | predt_Label.Text = "* Pre DT version of the mod"; 106 | predt_Label.Visible = false; 107 | // 108 | // FileSelect 109 | // 110 | AutoScaleDimensions = new SizeF(96F, 96F); 111 | AutoScaleMode = AutoScaleMode.Dpi; 112 | ClientSize = new Size(300, 181); 113 | Controls.Add(selectall_Button); 114 | Controls.Add(predt_Label); 115 | Controls.Add(cancel_Button); 116 | Controls.Add(archivefile_Label); 117 | Controls.Add(confirmButton); 118 | Controls.Add(fileCheckedListBox); 119 | Icon = (Icon)resources.GetObject("$this.Icon"); 120 | MaximizeBox = false; 121 | MinimizeBox = false; 122 | MinimumSize = new Size(300, 200); 123 | Name = "FileSelect"; 124 | StartPosition = FormStartPosition.CenterScreen; 125 | Text = "Select Files"; 126 | TopMost = true; 127 | ResumeLayout(false); 128 | PerformLayout(); 129 | } 130 | 131 | #endregion 132 | 133 | private Button confirmButton; 134 | private Label archivefile_Label; 135 | private Button cancel_Button; 136 | private Button selectall_Button; 137 | private Label predt_Label; 138 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Views/FileSelect.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.ObjectModel; 2 | using System.ComponentModel; 3 | using System.Reactive.Disposables; 4 | using System.Reactive.Linq; 5 | using PenumbraModForwarder.UI.Models; 6 | using ReactiveUI; 7 | using ReactiveUI.Fody.Helpers; 8 | 9 | namespace PenumbraModForwarder.UI.Views 10 | { 11 | public partial class FileSelect : Form, IViewFor 12 | { 13 | [DefaultValue(null)] public FileSelectViewModel ViewModel { get; set; } 14 | 15 | object IViewFor.ViewModel 16 | { 17 | get => ViewModel; 18 | set => ViewModel = (FileSelectViewModel)value; 19 | } 20 | 21 | public FileSelect(FileSelectViewModel viewModel) 22 | { 23 | InitializeComponent(); 24 | ViewModel = viewModel; 25 | ViewModel.CloseAction = () => 26 | { 27 | DialogResult = DialogResult.OK; 28 | Close(); 29 | }; 30 | 31 | this.WhenActivated(disposables => 32 | { 33 | BindListBox(ViewModel, vm => vm.Files, fileCheckedListBox); 34 | 35 | this.BindCommand(ViewModel, vm => vm.ConfirmSelectionCommand, v => v.confirmButton) 36 | .DisposeWith(disposables); 37 | 38 | this.BindCommand(ViewModel, vm => vm.CancelSelectionCommand, v => v.cancel_Button) 39 | .DisposeWith(disposables); 40 | 41 | this.BindCommand(ViewModel, vm => vm.SelectAllCommand, v => v.selectall_Button) 42 | .DisposeWith(disposables); 43 | 44 | this.Bind(ViewModel, vm => vm.ShowAllSelectedEnabled, v => v.selectall_Button.Enabled) 45 | .DisposeWith(disposables); 46 | 47 | this.Bind(ViewModel, vm => vm.ShowAllSelectedVisible, v => v.selectall_Button.Visible) 48 | .DisposeWith(disposables); 49 | 50 | this.Bind(ViewModel, vm => vm.ArchiveFileName, v => v.archivefile_Label.Text) 51 | .DisposeWith(disposables); 52 | 53 | this.Bind(ViewModel, vm => vm.ShowDtTextVisible, v => v.predt_Label.Visible) 54 | .DisposeWith(disposables); 55 | 56 | fileCheckedListBox.ItemCheck += FileCheckedListBox_ItemCheck; 57 | 58 | // Observe changes to the SelectedFiles array and update the UI 59 | ViewModel.WhenAnyValue(vm => vm.SelectedFiles) 60 | .ObserveOn(RxApp.MainThreadScheduler) 61 | .Subscribe(selectedFiles => 62 | { 63 | BeginInvoke(() => 64 | { 65 | for (var i = 0; i < fileCheckedListBox.Items.Count; i++) 66 | { 67 | var fileItem = (FileItem)fileCheckedListBox.Items[i]; 68 | fileCheckedListBox.SetItemChecked(i, selectedFiles.Contains(fileItem.FullPath)); 69 | } 70 | }); 71 | }) 72 | .DisposeWith(disposables); 73 | 74 | // Dispose event handler 75 | Disposable.Create(() => fileCheckedListBox.ItemCheck -= FileCheckedListBox_ItemCheck) 76 | .DisposeWith(disposables); 77 | }); 78 | } 79 | 80 | private void FileCheckedListBox_ItemCheck(object sender, ItemCheckEventArgs e) 81 | { 82 | BeginInvoke(() => 83 | { 84 | var checkedItems = fileCheckedListBox.Items.Cast() 85 | .Where((item, index) => 86 | (index == e.Index ? e.NewValue == CheckState.Checked : fileCheckedListBox.GetItemChecked(index))) 87 | .Select(item => item.FullPath) 88 | .ToArray(); 89 | 90 | ViewModel.SelectedFiles = checkedItems; 91 | }); 92 | } 93 | 94 | private void BindListBox(FileSelectViewModel viewModel, 95 | System.Linq.Expressions.Expression>> vmProperty, 96 | CheckedListBox listBox) 97 | { 98 | viewModel.WhenAnyValue(vmProperty) 99 | .ObserveOn(RxApp.MainThreadScheduler) 100 | .Subscribe(files => 101 | { 102 | BeginInvoke(() => 103 | { 104 | listBox.Items.Clear(); 105 | foreach (var file in files) 106 | { 107 | listBox.Items.Add(file, false); 108 | } 109 | }); 110 | }); 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Views/MainWindow.Designer.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace PenumbraModForwarder.UI.Views; 4 | 5 | partial class MainWindow 6 | { 7 | /// 8 | /// Required designer variable. 9 | /// 10 | private IContainer components = null; 11 | 12 | /// 13 | /// Clean up any resources being used. 14 | /// 15 | /// true if managed resources should be disposed; otherwise, false. 16 | protected override void Dispose(bool disposing) 17 | { 18 | if (disposing && (components != null)) 19 | { 20 | components.Dispose(); 21 | } 22 | 23 | base.Dispose(disposing); 24 | } 25 | 26 | #region Windows Form Designer generated code 27 | 28 | /// 29 | /// Required method for Designer support - do not modify 30 | /// the contents of this method with the code editor. 31 | /// 32 | private void InitializeComponent() 33 | { 34 | select_directory = new Button(); 35 | directory_text = new TextBox(); 36 | autoforward_checkbox = new CheckBox(); 37 | autodelete_checkbox = new CheckBox(); 38 | extractall_checkbox = new CheckBox(); 39 | xivarchive_Button = new Button(); 40 | glamourdressor_Button = new Button(); 41 | nexusmods_Button = new Button(); 42 | aetherlink_Button = new Button(); 43 | heliosphere_Button = new Button(); 44 | prettykitty_Button = new Button(); 45 | discord_Button = new Button(); 46 | donate_Button = new Button(); 47 | label1 = new Label(); 48 | notification_checkbox = new CheckBox(); 49 | version_Label = new Label(); 50 | associate_Checkbox = new CheckBox(); 51 | startup_Checkboxx = new CheckBox(); 52 | SuspendLayout(); 53 | // 54 | // select_directory 55 | // 56 | select_directory.Location = new Point(226, 7); 57 | select_directory.Name = "select_directory"; 58 | select_directory.Size = new Size(75, 23); 59 | select_directory.TabIndex = 0; 60 | select_directory.Text = "Select"; 61 | select_directory.UseVisualStyleBackColor = true; 62 | // 63 | // directory_text 64 | // 65 | directory_text.Enabled = false; 66 | directory_text.Location = new Point(12, 8); 67 | directory_text.Name = "directory_text"; 68 | directory_text.ReadOnly = true; 69 | directory_text.Size = new Size(208, 23); 70 | directory_text.TabIndex = 1; 71 | // 72 | // autoforward_checkbox 73 | // 74 | autoforward_checkbox.AutoSize = true; 75 | autoforward_checkbox.Location = new Point(170, 37); 76 | autoforward_checkbox.Name = "autoforward_checkbox"; 77 | autoforward_checkbox.Size = new Size(131, 19); 78 | autoforward_checkbox.TabIndex = 2; 79 | autoforward_checkbox.Text = "Auto Forward Mods"; 80 | autoforward_checkbox.UseVisualStyleBackColor = true; 81 | // 82 | // autodelete_checkbox 83 | // 84 | autodelete_checkbox.AutoSize = true; 85 | autodelete_checkbox.Location = new Point(170, 87); 86 | autodelete_checkbox.Name = "autodelete_checkbox"; 87 | autodelete_checkbox.Size = new Size(121, 19); 88 | autodelete_checkbox.TabIndex = 3; 89 | autodelete_checkbox.Text = "Auto Delete Mods"; 90 | autodelete_checkbox.UseVisualStyleBackColor = true; 91 | // 92 | // extractall_checkbox 93 | // 94 | extractall_checkbox.AutoSize = true; 95 | extractall_checkbox.Location = new Point(170, 62); 96 | extractall_checkbox.Name = "extractall_checkbox"; 97 | extractall_checkbox.Size = new Size(112, 19); 98 | extractall_checkbox.TabIndex = 4; 99 | extractall_checkbox.Text = "Extract All Mods"; 100 | extractall_checkbox.UseVisualStyleBackColor = true; 101 | // 102 | // xivarchive_Button 103 | // 104 | xivarchive_Button.Location = new Point(1, 148); 105 | xivarchive_Button.Name = "xivarchive_Button"; 106 | xivarchive_Button.Size = new Size(104, 23); 107 | xivarchive_Button.TabIndex = 5; 108 | xivarchive_Button.Text = "XIV Mod Archive"; 109 | xivarchive_Button.UseVisualStyleBackColor = true; 110 | // 111 | // glamourdressor_Button 112 | // 113 | glamourdressor_Button.Location = new Point(105, 148); 114 | glamourdressor_Button.Name = "glamourdressor_Button"; 115 | glamourdressor_Button.Size = new Size(124, 23); 116 | glamourdressor_Button.TabIndex = 6; 117 | glamourdressor_Button.Text = "The Glamour Dresser"; 118 | glamourdressor_Button.UseVisualStyleBackColor = true; 119 | // 120 | // nexusmods_Button 121 | // 122 | nexusmods_Button.Location = new Point(229, 148); 123 | nexusmods_Button.Name = "nexusmods_Button"; 124 | nexusmods_Button.Size = new Size(84, 23); 125 | nexusmods_Button.TabIndex = 7; 126 | nexusmods_Button.Text = "Nexus Mods"; 127 | nexusmods_Button.UseVisualStyleBackColor = true; 128 | // 129 | // aetherlink_Button 130 | // 131 | aetherlink_Button.Location = new Point(1, 172); 132 | aetherlink_Button.Name = "aetherlink_Button"; 133 | aetherlink_Button.Size = new Size(72, 23); 134 | aetherlink_Button.TabIndex = 8; 135 | aetherlink_Button.Text = "Aetherlink"; 136 | aetherlink_Button.UseVisualStyleBackColor = true; 137 | // 138 | // heliosphere_Button 139 | // 140 | heliosphere_Button.Location = new Point(73, 172); 141 | heliosphere_Button.Name = "heliosphere_Button"; 142 | heliosphere_Button.Size = new Size(84, 23); 143 | heliosphere_Button.TabIndex = 9; 144 | heliosphere_Button.Text = "Heliosphere"; 145 | heliosphere_Button.UseVisualStyleBackColor = true; 146 | // 147 | // prettykitty_Button 148 | // 149 | prettykitty_Button.Location = new Point(157, 172); 150 | prettykitty_Button.Name = "prettykitty_Button"; 151 | prettykitty_Button.Size = new Size(156, 23); 152 | prettykitty_Button.TabIndex = 10; 153 | prettykitty_Button.Text = "The Pretty Kitty Emporium"; 154 | prettykitty_Button.UseVisualStyleBackColor = true; 155 | // 156 | // discord_Button 157 | // 158 | discord_Button.BackColor = Color.SlateBlue; 159 | discord_Button.ForeColor = Color.White; 160 | discord_Button.Location = new Point(1, 196); 161 | discord_Button.Name = "discord_Button"; 162 | discord_Button.Size = new Size(156, 28); 163 | discord_Button.TabIndex = 11; 164 | discord_Button.Text = "Discord"; 165 | discord_Button.UseVisualStyleBackColor = false; 166 | // 167 | // donate_Button 168 | // 169 | donate_Button.BackColor = Color.LightCoral; 170 | donate_Button.ForeColor = Color.White; 171 | donate_Button.Location = new Point(157, 196); 172 | donate_Button.Name = "donate_Button"; 173 | donate_Button.Size = new Size(156, 28); 174 | donate_Button.TabIndex = 12; 175 | donate_Button.Text = "Donate"; 176 | donate_Button.UseVisualStyleBackColor = false; 177 | // 178 | // label1 179 | // 180 | label1.AutoSize = true; 181 | label1.Font = new Font("Segoe UI", 14.25F, FontStyle.Bold); 182 | label1.Location = new Point(1, 120); 183 | label1.Name = "label1"; 184 | label1.Size = new Size(109, 25); 185 | label1.TabIndex = 13; 186 | label1.Text = "Quick links"; 187 | // 188 | // notification_checkbox 189 | // 190 | notification_checkbox.AutoSize = true; 191 | notification_checkbox.Location = new Point(12, 37); 192 | notification_checkbox.Name = "notification_checkbox"; 193 | notification_checkbox.Size = new Size(126, 19); 194 | notification_checkbox.TabIndex = 14; 195 | notification_checkbox.Text = "Show Notifications"; 196 | notification_checkbox.UseVisualStyleBackColor = true; 197 | // 198 | // version_Label 199 | // 200 | version_Label.AutoSize = true; 201 | version_Label.Font = new Font("Segoe UI", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); 202 | version_Label.Location = new Point(1, 227); 203 | version_Label.Name = "version_Label"; 204 | version_Label.Size = new Size(45, 13); 205 | version_Label.TabIndex = 15; 206 | version_Label.Text = "Version"; 207 | // 208 | // associate_Checkbox 209 | // 210 | associate_Checkbox.AutoSize = true; 211 | associate_Checkbox.Location = new Point(12, 62); 212 | associate_Checkbox.Name = "associate_Checkbox"; 213 | associate_Checkbox.Size = new Size(129, 19); 214 | associate_Checkbox.TabIndex = 16; 215 | associate_Checkbox.Text = "Associate File Types"; 216 | associate_Checkbox.UseVisualStyleBackColor = true; 217 | // 218 | // startup_Checkboxx 219 | // 220 | startup_Checkboxx.AutoSize = true; 221 | startup_Checkboxx.Location = new Point(12, 87); 222 | startup_Checkboxx.Name = "startup_Checkboxx"; 223 | startup_Checkboxx.Size = new Size(107, 19); 224 | startup_Checkboxx.TabIndex = 17; 225 | startup_Checkboxx.Text = "Run On Startup"; 226 | startup_Checkboxx.UseVisualStyleBackColor = true; 227 | // 228 | // MainWindow 229 | // 230 | AutoScaleDimensions = new SizeF(96F, 96F); 231 | AutoScaleMode = AutoScaleMode.Dpi; 232 | ClientSize = new Size(313, 242); 233 | Controls.Add(startup_Checkboxx); 234 | Controls.Add(associate_Checkbox); 235 | Controls.Add(version_Label); 236 | Controls.Add(notification_checkbox); 237 | Controls.Add(label1); 238 | Controls.Add(donate_Button); 239 | Controls.Add(discord_Button); 240 | Controls.Add(prettykitty_Button); 241 | Controls.Add(heliosphere_Button); 242 | Controls.Add(aetherlink_Button); 243 | Controls.Add(nexusmods_Button); 244 | Controls.Add(glamourdressor_Button); 245 | Controls.Add(xivarchive_Button); 246 | Controls.Add(extractall_checkbox); 247 | Controls.Add(autodelete_checkbox); 248 | Controls.Add(autoforward_checkbox); 249 | Controls.Add(directory_text); 250 | Controls.Add(select_directory); 251 | FormBorderStyle = FormBorderStyle.FixedDialog; 252 | MaximizeBox = false; 253 | Name = "MainWindow"; 254 | Text = "Penumbra Mod Forwarder"; 255 | ResumeLayout(false); 256 | PerformLayout(); 257 | } 258 | 259 | #endregion 260 | private Button select_directory; 261 | private TextBox directory_text; 262 | private CheckBox autoforward_checkbox; 263 | private CheckBox autodelete_checkbox; 264 | private CheckBox extractall_checkbox; 265 | private Button xivarchive_Button; 266 | private Button glamourdressor_Button; 267 | private Button nexusmods_Button; 268 | private Button aetherlink_Button; 269 | private Button heliosphere_Button; 270 | private Button prettykitty_Button; 271 | private Button discord_Button; 272 | private Button donate_Button; 273 | private Label label1; 274 | private CheckBox notification_checkbox; 275 | private Label version_Label; 276 | private CheckBox associate_Checkbox; 277 | private CheckBox startup_Checkboxx; 278 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Views/MainWindow.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Reactive.Disposables; 3 | using System.Reactive.Linq; 4 | using PenumbraModForwarder.Common.Interfaces; 5 | using PenumbraModForwarder.UI.Interfaces; 6 | using PenumbraModForwarder.UI.Services; 7 | using PenumbraModForwarder.UI.ViewModels; 8 | using ReactiveUI; 9 | using ReactiveUI.Fody.Helpers; 10 | 11 | namespace PenumbraModForwarder.UI.Views; 12 | 13 | public partial class MainWindow : Form, IViewFor 14 | { 15 | private readonly ISystemTrayManager _systemTrayManager; 16 | private readonly ToolTip _toolTip; 17 | private readonly IResourceManager _resourceManager; 18 | private readonly IConfigurationService _configurationService; 19 | private bool _isExiting = false; 20 | [DefaultValue(null)] public MainWindowViewModel ViewModel { get; set; } 21 | 22 | object IViewFor.ViewModel 23 | { 24 | get => ViewModel; 25 | set => ViewModel = (MainWindowViewModel) value; 26 | } 27 | 28 | public MainWindow(MainWindowViewModel viewModel, ISystemTrayManager systemTrayManager, IResourceManager resourceManager, IConfigurationService configurationService) 29 | { 30 | InitializeComponent(); 31 | 32 | ViewModel = viewModel; 33 | _systemTrayManager = systemTrayManager; 34 | _resourceManager = resourceManager; 35 | _configurationService = configurationService; 36 | 37 | _toolTip = new ToolTip(); 38 | 39 | Icon = _resourceManager.LoadIcon("PenumbraModForwarder.UI.Resources.PMFI.ico"); 40 | 41 | _systemTrayManager.OnExitRequested += () => 42 | { 43 | _isExiting = true; 44 | Close(); 45 | }; 46 | 47 | 48 | this.WhenActivated(disposables => 49 | { 50 | this.Bind(ViewModel, vm => vm.VersionNumber, v => v.version_Label.Text) 51 | .DisposeWith(disposables); 52 | 53 | this.Bind(ViewModel, vm => vm.SelectedFolderPath, v => v.directory_text.Text) 54 | .DisposeWith(disposables); 55 | 56 | this.BindCommand(ViewModel, vm => vm.OpenFolderDialog, v => v.select_directory) 57 | .DisposeWith(disposables); 58 | 59 | this.Bind(ViewModel, vm => vm.RunOnStartup, v => v.startup_Checkboxx.Checked) 60 | .DisposeWith(disposables); 61 | 62 | startup_Checkboxx.CheckedChanged += (s, e) => 63 | { 64 | ViewModel.UpdateStartupCommand.Execute(startup_Checkboxx.Checked).Subscribe(); 65 | }; 66 | 67 | this.Bind(ViewModel, vm => vm.FileLinkingEnabled, v => v.associate_Checkbox.Checked) 68 | .DisposeWith(disposables); 69 | 70 | associate_Checkbox.CheckedChanged += (s, e) => 71 | { 72 | ViewModel.EnableFileLinkingCommand.Execute(associate_Checkbox.Checked).Subscribe(); 73 | }; 74 | 75 | this.Bind(ViewModel, vm => vm.NotificationEnabled, v => v.notification_checkbox.Checked) 76 | .DisposeWith(disposables); 77 | 78 | notification_checkbox.CheckedChanged += (s, e) => 79 | { 80 | ViewModel.UpdateNotificationCommand.Execute(notification_checkbox.Checked).Subscribe(); 81 | }; 82 | 83 | this.Bind(ViewModel, vm => vm.AutoDelete, v => v.autodelete_checkbox.Checked) 84 | .DisposeWith(disposables); 85 | 86 | autodelete_checkbox.CheckedChanged += (s, e) => 87 | { 88 | ViewModel.UpdateAutoDeleteCommand.Execute(autodelete_checkbox.Checked).Subscribe(); 89 | }; 90 | 91 | this.Bind(ViewModel, vm => vm.AutoLoad, v => v.autoforward_checkbox.Checked) 92 | .DisposeWith(disposables); 93 | 94 | autoforward_checkbox.CheckedChanged += (s, e) => 95 | { 96 | ViewModel.UpdateAutoLoadCommand.Execute(autoforward_checkbox.Checked).Subscribe(); 97 | }; 98 | 99 | this.Bind(ViewModel, vm => vm.ExtractAll, v => v.extractall_checkbox.Checked) 100 | .DisposeWith(disposables); 101 | 102 | extractall_checkbox.CheckedChanged += (s, e) => 103 | { 104 | ViewModel.UpdateExtractAllCommand.Execute(extractall_checkbox.Checked).Subscribe(); 105 | }; 106 | 107 | this.Bind(ViewModel, vm => vm.SelectBoxEnabled, v => v.select_directory.Enabled) 108 | .DisposeWith(disposables); 109 | 110 | #region Tool Tips 111 | 112 | _toolTip.SetToolTip(select_directory, "Select the folder where mods are downloaded to."); 113 | _toolTip.SetToolTip(notification_checkbox, "Show a notification when a mod is forwarded."); 114 | _toolTip.SetToolTip(autodelete_checkbox, "Automatically delete the mod after forwarding to penumbra."); 115 | _toolTip.SetToolTip(autoforward_checkbox, "Automatically forward the mod to penumbra."); 116 | _toolTip.SetToolTip(extractall_checkbox, "Extract all files from the mod archive."); 117 | _toolTip.SetToolTip(xivarchive_Button, "Open the XIV Archive Website."); 118 | _toolTip.SetToolTip(glamourdressor_Button, "Open the Glamour Dresser Website."); 119 | _toolTip.SetToolTip(nexusmods_Button, "Open the Nexus Mods Website."); 120 | _toolTip.SetToolTip(aetherlink_Button, "Open the Aether Link Website."); 121 | _toolTip.SetToolTip(heliosphere_Button, "Open the Heliosphere Website."); 122 | _toolTip.SetToolTip(prettykitty_Button, "Open the Pretty Kitty Website."); 123 | _toolTip.SetToolTip(discord_Button, "Open the Discord Support Server."); 124 | _toolTip.SetToolTip(donate_Button, "Donate to the Developer."); 125 | _toolTip.SetToolTip(version_Label, "Current Version of Penumbra Mod Forwarder."); 126 | _toolTip.SetToolTip(associate_Checkbox, "Let Penumbra Mod Forwarder handle mod files when double clicked."); 127 | _toolTip.SetToolTip(startup_Checkboxx, "Start Penumbra Mod Forwarder on Windows Startup."); 128 | 129 | #endregion 130 | 131 | #region Handling Window State 132 | 133 | Observable.FromEventPattern(this, nameof(Load)) 134 | .Subscribe(_ => 135 | { 136 | var hideWindowOnStartup = _configurationService.IsAdvancedOptionEnabled(p => p.HideWindowOnStartup); 137 | var runOnStartup = _configurationService.GetConfigValue(p => p.StartOnBoot); 138 | 139 | if (!hideWindowOnStartup || !runOnStartup) return; 140 | 141 | WindowState = FormWindowState.Minimized; 142 | ShowInTaskbar = false; 143 | _systemTrayManager.ShowNotification("Penumbra Mod Forwarder", "Minimized to tray."); 144 | }) 145 | .DisposeWith(disposables); 146 | 147 | Observable.FromEventPattern(this, nameof(FormClosing)) 148 | .Subscribe(e => 149 | { 150 | if (_isExiting) 151 | { 152 | return; 153 | } 154 | 155 | e.EventArgs.Cancel = true; 156 | Hide(); 157 | _systemTrayManager.ShowNotification("Penumbra Mod Forwarder", "Minimized to tray."); 158 | }) 159 | .DisposeWith(disposables); 160 | 161 | #endregion 162 | 163 | #region Link Buttons 164 | 165 | this.BindCommand(ViewModel, vm => vm.OpenXivArchiveCommand, v => v.xivarchive_Button) 166 | .DisposeWith(disposables); 167 | 168 | this.BindCommand(ViewModel, vm => vm.OpenGlamourDresserCommand, v => v.glamourdressor_Button) 169 | .DisposeWith(disposables); 170 | 171 | this.BindCommand(ViewModel, vm => vm.OpenNexusModsCommand, v => v.nexusmods_Button) 172 | .DisposeWith(disposables); 173 | 174 | this.BindCommand(ViewModel, vm => vm.OpenAetherLinkCommand, v => v.aetherlink_Button) 175 | .DisposeWith(disposables); 176 | 177 | this.BindCommand(ViewModel, vm => vm.OpenHelioSphereCommand, v => v.heliosphere_Button) 178 | .DisposeWith(disposables); 179 | 180 | this.BindCommand(ViewModel, vm => vm.OpenPrettyKittyCommand, v => v.prettykitty_Button) 181 | .DisposeWith(disposables); 182 | 183 | this.BindCommand(ViewModel, vm => vm.OpenDiscordCommand, v => v.discord_Button) 184 | .DisposeWith(disposables); 185 | 186 | this.BindCommand(ViewModel, vm => vm.OpenDonateCommand, v => v.donate_Button) 187 | .DisposeWith(disposables); 188 | 189 | #endregion 190 | 191 | }); 192 | } 193 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Views/MainWindow.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Views/ProgressWindow.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace PenumbraModForwarder.UI.Views 2 | { 3 | partial class ProgressWindow 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | progress_Bar = new ProgressBar(); 32 | file_Label = new Label(); 33 | operation_Label = new Label(); 34 | SuspendLayout(); 35 | // 36 | // progress_Bar 37 | // 38 | progress_Bar.Location = new Point(12, 107); 39 | progress_Bar.Name = "progress_Bar"; 40 | progress_Bar.Size = new Size(345, 23); 41 | progress_Bar.TabIndex = 0; 42 | // 43 | // file_Label 44 | // 45 | file_Label.AutoSize = true; 46 | file_Label.Font = new Font("Segoe UI", 12F, FontStyle.Bold, GraphicsUnit.Point, 0); 47 | file_Label.Location = new Point(12, 20); 48 | file_Label.Name = "file_Label"; 49 | file_Label.Size = new Size(57, 21); 50 | file_Label.TabIndex = 1; 51 | file_Label.Text = "label1"; 52 | // 53 | // operation_Label 54 | // 55 | operation_Label.AutoSize = true; 56 | operation_Label.Location = new Point(12, 64); 57 | operation_Label.Name = "operation_Label"; 58 | operation_Label.Size = new Size(38, 15); 59 | operation_Label.TabIndex = 2; 60 | operation_Label.Text = "label1"; 61 | // 62 | // ProgressWindow 63 | // 64 | AutoScaleDimensions = new SizeF(96F, 96F); 65 | AutoScaleMode = AutoScaleMode.Dpi; 66 | ClientSize = new Size(369, 174); 67 | ControlBox = false; 68 | Controls.Add(operation_Label); 69 | Controls.Add(file_Label); 70 | Controls.Add(progress_Bar); 71 | MaximizeBox = false; 72 | MinimizeBox = false; 73 | Name = "ProgressWindow"; 74 | ShowIcon = false; 75 | ShowInTaskbar = false; 76 | StartPosition = FormStartPosition.CenterScreen; 77 | TopMost = true; 78 | ResumeLayout(false); 79 | PerformLayout(); 80 | } 81 | 82 | #endregion 83 | 84 | private ProgressBar progress_Bar; 85 | private Label file_Label; 86 | private Label operation_Label; 87 | } 88 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Views/ProgressWindow.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Reactive.Disposables; 3 | using PenumbraModForwarder.UI.ViewModels; 4 | using ReactiveUI; 5 | 6 | namespace PenumbraModForwarder.UI.Views 7 | { 8 | public partial class ProgressWindow : Form, IViewFor 9 | { 10 | [DefaultValue(null)] public ProgressWindowViewModel ViewModel { get; set; } 11 | 12 | object IViewFor.ViewModel 13 | { 14 | get => ViewModel; 15 | set => ViewModel = (ProgressWindowViewModel)value; 16 | } 17 | 18 | public ProgressWindow(ProgressWindowViewModel viewModel) 19 | { 20 | InitializeComponent(); 21 | ViewModel = viewModel; 22 | 23 | this.WhenActivated(disposables => 24 | { 25 | this.Bind(ViewModel, vm => vm.FileName, v => v.file_Label.Text) 26 | .DisposeWith(disposables); 27 | 28 | this.Bind(ViewModel, vm => vm.Progress, v => v.progress_Bar.Value) 29 | .DisposeWith(disposables); 30 | 31 | this.Bind(ViewModel, vm => vm.Operation, v => v.operation_Label.Text) 32 | .DisposeWith(disposables); 33 | }); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /PenumbraModForwarder.UI/Views/ProgressWindow.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /PenumbraModForwarder.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.4.33205.214 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PenumbraModForwarder.UI", "PenumbraModForwarder.UI\PenumbraModForwarder.UI.csproj", "{613AF580-A194-482A-81FC-34F026ED940E}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PenumbraModForwarder.Common", "PenumbraModForwarder.Common\PenumbraModForwarder.Common.csproj", "{6E435B0C-CEB8-42AB-926F-916693E67C39}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PenumbraModForwarder.Test", "PenumbraModForwarder.Test\PenumbraModForwarder.Test.csproj", "{ABBCAE7A-8213-4A54-B5D3-782CB63354EF}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SevenZipExtractor", "SevenZipExtractor\SevenZipExtractor\SevenZipExtractor.csproj", "{C123A38D-F9A0-4F58-8F92-C8FDE7669EA1}" 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Release|Any CPU = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {613AF580-A194-482A-81FC-34F026ED940E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {613AF580-A194-482A-81FC-34F026ED940E}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {613AF580-A194-482A-81FC-34F026ED940E}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {613AF580-A194-482A-81FC-34F026ED940E}.Release|Any CPU.Build.0 = Release|Any CPU 24 | {6E435B0C-CEB8-42AB-926F-916693E67C39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {6E435B0C-CEB8-42AB-926F-916693E67C39}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {6E435B0C-CEB8-42AB-926F-916693E67C39}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {6E435B0C-CEB8-42AB-926F-916693E67C39}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {ABBCAE7A-8213-4A54-B5D3-782CB63354EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {ABBCAE7A-8213-4A54-B5D3-782CB63354EF}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {ABBCAE7A-8213-4A54-B5D3-782CB63354EF}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {ABBCAE7A-8213-4A54-B5D3-782CB63354EF}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {C123A38D-F9A0-4F58-8F92-C8FDE7669EA1}.Debug|Any CPU.ActiveCfg = Debug|x64 33 | {C123A38D-F9A0-4F58-8F92-C8FDE7669EA1}.Debug|Any CPU.Build.0 = Debug|x64 34 | {C123A38D-F9A0-4F58-8F92-C8FDE7669EA1}.Release|Any CPU.ActiveCfg = Release|x64 35 | {C123A38D-F9A0-4F58-8F92-C8FDE7669EA1}.Release|Any CPU.Build.0 = Release|x64 36 | EndGlobalSection 37 | GlobalSection(SolutionProperties) = preSolution 38 | HideSolutionNode = FALSE 39 | EndGlobalSection 40 | GlobalSection(ExtensibilityGlobals) = postSolution 41 | SolutionGuid = {68E8C647-4E1F-442D-8F5B-495DB053C443} 42 | EndGlobalSection 43 | EndGlobal 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Penumbra Mod Forwarder 2 | # Important 3 | Work on this project has been moved to a separate repository, this one will continue to exist but will no longer be maintained 4 | 5 | ### Updater 6 | Has been moved to: https://github.com/CouncilOfTsukuyomi/Updater 7 | 8 | ### PMF 9 | Has been renamed and moved to: https://github.com/CouncilOfTsukuyomi/ModForwarder 10 | 11 | ### Common Library 12 | Has been extracted out of PMF and moved to: https://github.com/CouncilOfTsukuyomi/PMF.CommonLib 13 | 14 | --- 15 | 16 | Forwards `.pmp`, `.ttmp`, and `.ttmp2` files to be automatically opened by Penumbra. 17 | 18 | ### In Action Preview: 19 | [Watch the video](https://youtu.be/_kv6DzqoyX4) 20 | 21 | --- 22 | 23 | ## Features 24 | 25 | - **Convenient Mod Downloading:** Simplify your mod downloading process by automatically forwarding mods to Penumbra. 26 | - **Automatic Opening in Penumbra:** Mods you download can be set to automatically open in Penumbra. This option can be disabled if preferred. 27 | - **Double-Click to Open Mods:** Set Penumbra Mod Forwarder as your default program to allow double-clicking or multi-selecting mods, which will then automatically open in Penumbra. 28 | 29 | Penumbra Mod Forwarder, as the name suggests, will notify Penumbra to install new mods that are downloaded to a specified folder. Additionally, it allows Penumbra to install mods that you double-click or multi-select, provided you've set Penumbra Mod Forwarder as the default program for opening supported mod files in Windows. 30 | 31 | --- 32 | 33 | ## Instructions 34 | 35 | 1. **Enable Auto Forward Mods:** Check the "Auto Forward Mods" option in the application. 36 | 2. **Set Default Downloads Folder:** Select your default downloads folder where mods are saved. 37 | 3. **Download Mods:** Download mods from your favorite sites, and they will be automatically forwarded to Penumbra. 38 | 39 | *(Optional)* 40 | 4. **Install and Configure TexTools:** If you want mods to be automatically converted from Endwalker to Dawntrail, ensure you have installed and configured TexTools at least once. 41 | 42 | --- 43 | 44 | ## Requirements 45 | 46 | This program requires the .NET 8.0 desktop runtime to be installed. You can download it here: 47 | 48 | - **64-bit:** [Download .NET 8.0 SDK for Windows x64](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/sdk-8.0.401-windows-x64-installer) 49 | - **32-bit:** [Download .NET 8.0 SDK for Windows x86](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/sdk-8.0.401-windows-x86-installer) 50 | 51 | --- 52 | 53 | ## Documentation 54 | 55 | ### Viewing Logs 56 | The application will generate logs based on what is currently happening, these can be found at `%appdata%/PenumbraModForwarder/logs` 57 | 58 | ### Configuration 59 | The application uses json files to handle all user configuration, this can be found at `%appdata%/PenumbraModForwarder/config.json` the application will handle all of these settings automatically, except for Advanced Options 60 | 61 | The default settings will look like this 62 | ```json 63 | { 64 | "AutoLoad": false, 65 | "AutoDelete": false, 66 | "ExtractAll": false, 67 | "NotificationEnabled": false, 68 | "FileLinkingEnabled": false, 69 | "StartOnBoot": false, 70 | "DownloadPath": "", 71 | "TexToolPath": "", 72 | "AdvancedOptions": { 73 | "HideWindowOnStartup": true, 74 | "PenumbraTimeOutInSeconds": 60 75 | } 76 | } 77 | ``` 78 | 79 | ### Advanced Options 80 | These options are for advanced users who are after specific things from the application. 81 | 82 | Right now all they do is make it so the Main Window will show even if you have StartOnBoot enabled & handle how long the timeout is for when installing a mod via Penumbra Web Api 83 | 84 | --- 85 | 86 | ## Building from Source 87 | 88 | To build Penumbra Mod Forwarder from source, follow these steps: 89 | 90 | 1. **Clone the Repository with Submodules:** 91 | Clone the repository and its submodules to your local machine using the following commands: 92 | 93 | ```bash 94 | git clone --recurse-submodules https://github.com/Sebane1/PenumbraModForwarder.git 95 | ``` 96 | 97 | If you have already cloned the repository without submodules, you can initialize and update the submodules with: 98 | ```bash 99 | git submodule update --init --recursive 100 | ``` 101 | 102 | 103 | 2. **Install .NET 8.0 SDK:** 104 | Ensure that you have the .NET 8.0 SDK installed on your machine. You can download it from the official .NET website: 105 | - **64-bit:** [Download .NET 8.0 SDK for Windows x64](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/sdk-8.0.401-windows-x64-installer) 106 | - **32-bit:** [Download .NET 8.0 SDK for Windows x86](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/sdk-8.0.401-windows-x86-installer) 107 | 108 | 3. **Build the Solution:** 109 | Navigate to the root directory of the repository and run the following command: 110 | 111 | ```bash 112 | dotnet publish PenumbraModForwarder.UI/ -c Release -p:PublishSingleFile=true --self-contained false -r win-x64 -o ./publish -f net8.0-windows 113 | ``` 114 | 115 | 4. **Run the Application:** 116 | Once the build is successful, navigate to the `publish` directory and run the executable file to start the application. 117 | 118 | -------------------------------------------------------------------------------- /repo.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "Author": "Ottermandias, Adam, Wintermute", 4 | "Name": "Penumbra", 5 | "Description": "Runtime mod loader and manager.", 6 | "InternalName": "Penumbra", 7 | "AssemblyVersion": "1.0.0.0", 8 | "TestingAssemblyVersion": "1.0.0.0", 9 | "RepoUrl": "https://github.com/xivdev/Penumbra", 10 | "ApplicableVersion": "any", 11 | "DalamudApiLevel": 8, 12 | "IsHide": "False", 13 | "IsTestingExclusive": "False", 14 | "DownloadCount": 0, 15 | "LastUpdate": 0, 16 | "LoadPriority": 69420, 17 | "LoadRequiredState": 2, 18 | "LoadSync": true, 19 | "DownloadLinkInstall": "https://github.com/Sebane1/PenumbraModForwarder/releases/download/v0.0.0.1/Penumbra_ONLY.FOR.TESTING.zip", 20 | "DownloadLinkTesting": "https://github.com/Sebane1/PenumbraModForwarder/releases/download/v0.0.0.1/Penumbra_ONLY.FOR.TESTING.zip", 21 | "DownloadLinkUpdate": "https://github.com/Sebane1/PenumbraModForwarder/releases/download/v0.0.0.1/Penumbra_ONLY.FOR.TESTING.zip", 22 | "IconUrl": "https://raw.githubusercontent.com/xivdev/Penumbra/master/images/icon.png" 23 | } 24 | ] 25 | -------------------------------------------------------------------------------- /update.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1.0.1.6 4 | https://github.com/Sebane1/PenumbraModForwarder/releases/download/v1.0.1.6/PenumbraModForwarder.zip 5 | 6 | true 7 | 8 | --------------------------------------------------------------------------------