Compare commits

..

4 Commits

Author SHA1 Message Date
Josiah Glosson
a47af1b37d With *an* admin prompt 2025-08-06 21:41:15 -05:00
Josiah Glosson
3777373d71 Properly remove old shortcuts 2025-08-06 20:52:35 -05:00
Josiah Glosson
ef32c23a5d Add ShellExecuteWait credit 2025-08-06 20:47:31 -05:00
Josiah Glosson
e07d389759 Make Windows app installations per-user once again 2025-08-06 20:46:55 -05:00
7 changed files with 81 additions and 77 deletions

View File

@@ -4,7 +4,7 @@ root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
@@ -13,6 +13,3 @@ max_line_length = 100
[*.md]
max_line_length = off
trim_trailing_whitespace = false
[*.{rs,java,kts}]
indent_size = 4

View File

@@ -1,41 +1,67 @@
!macro NSIS_HOOK_POSTINSTALL
SetShellVarContext current
IfFileExists "$LOCALAPPDATA${PRODUCTNAME}\theseus_gui.exe" file_found file_not_found
file_found:
Delete "$LOCALAPPDATA${PRODUCTNAME}\theseus_gui.exe"
Delete "$LOCALAPPDATA${PRODUCTNAME}\uninstall.exe"
RMDir "$LOCALAPPDATA${PRODUCTNAME}"
!insertmacro DeleteAppUserModelId
; Remove start menu shortcut
!insertmacro MUI_STARTMENU_GETFOLDER Application $AppStartMenuFolder
!insertmacro IsShortcutTarget "$SMPROGRAMS$AppStartMenuFolder${PRODUCTNAME}.lnk" "$LOCALAPPDATA${PRODUCTNAME}\theseus_gui.exe"
Pop $0
${If} $0 = 1
!insertmacro UnpinShortcut "$SMPROGRAMS$AppStartMenuFolder${PRODUCTNAME}.lnk"
Delete "$SMPROGRAMS$AppStartMenuFolder${PRODUCTNAME}.lnk"
RMDir "$SMPROGRAMS$AppStartMenuFolder"
${EndIf}
!insertmacro IsShortcutTarget "$SMPROGRAMS${PRODUCTNAME}.lnk" "$LOCALAPPDATA${PRODUCTNAME}\theseus_gui.exe"
Pop $0
${If} $0 = 1
!insertmacro UnpinShortcut "$SMPROGRAMS${PRODUCTNAME}.lnk"
Delete "$SMPROGRAMS${PRODUCTNAME}.lnk"
${EndIf}
!insertmacro IsShortcutTarget "$DESKTOP${PRODUCTNAME}.lnk" "$LOCALAPPDATA${PRODUCTNAME}\theseus_gui.exe"
Pop $0
${If} $0 = 1
!insertmacro UnpinShortcut "$DESKTOP${PRODUCTNAME}.lnk"
Delete "$DESKTOP${PRODUCTNAME}.lnk"
${EndIf}
DeleteRegKey HKCU "${UNINSTKEY}"
goto end_of_test ;<== important for not continuing on the else branch
file_not_found:
end_of_test:
; https://nsis.sourceforge.io/ShellExecWait
!macro ShellExecWait verb app param workdir show exitoutvar ;only app and show must be != "", every thing else is optional
#define SEE_MASK_NOCLOSEPROCESS 0x40
System::Store S
!if "${NSIS_PTR_SIZE}" > 4
!define /ReDef /math SYSSIZEOF_SHELLEXECUTEINFO 14 * ${NSIS_PTR_SIZE}
!else ifndef SYSSIZEOF_SHELLEXECUTEINFO
!define SYSSIZEOF_SHELLEXECUTEINFO 60
!endif
System::Call '*(&i${SYSSIZEOF_SHELLEXECUTEINFO})i.r0'
System::Call '*$0(i ${SYSSIZEOF_SHELLEXECUTEINFO},i 0x40,p $hwndparent,t "${verb}",t $\'${app}$\',t $\'${param}$\',t "${workdir}",i ${show})p.r0'
System::Call 'shell32::ShellExecuteEx(t)(pr0)i.r1 ?e' ; (t) to trigger A/W selection
${If} $1 <> 0
System::Call '*$0(is,i,p,p,p,p,p,p,p,p,p,p,p,p,p.r1)' ;stack value not really used, just a fancy pop ;)
System::Call 'kernel32::WaitForSingleObject(pr1,i-1)'
System::Call 'kernel32::GetExitCodeProcess(pr1,*i.s)'
System::Call 'kernel32::CloseHandle(pr1)'
${EndIf}
System::Free $0
!if "${exitoutvar}" == ""
pop $0
!endif
System::Store L
!if "${exitoutvar}" != ""
pop ${exitoutvar}
!endif
!macroend
; --------------------------------------------------------------------------------
Var /GLOBAL OldInstallDir
!macro NSIS_HOOK_PREINSTALL
SetShellVarContext all
${If} ${FileExists} "$SMPROGRAMS\${PRODUCTNAME}.lnk"
UserInfo::GetAccountType
Pop $0
${If} $0 != "Admin"
MessageBox MB_ICONINFORMATION|MB_OK "An old installation of the Modrinth App was detected that requires administrator permission to update from. You will be prompted with an admin prompt shortly."
${EndIf}
ReadRegStr $4 SHCTX "${MANUPRODUCTKEY}" ""
ReadRegStr $R1 SHCTX "${UNINSTKEY}" "UninstallString"
ReadRegStr $OldInstallDir SHCTX "${UNINSTKEY}" "InstallLocation"
StrCpy $OldInstallDir $OldInstallDir "" 1
StrCpy $OldInstallDir $OldInstallDir -1 ""
DetailPrint "Executing $R1"
!insertmacro ShellExecWait "runas" '$R1' '/P _?=$4' "" ${SW_SHOW} $3
${If} $3 <> 0
SetErrorLevel $3
MessageBox MB_ICONEXCLAMATION|MB_OK "Failed to uninstall old global installation"
Abort
${EndIf}
${EndIf}
SetShellVarContext current
!macroend
!macro NSIS_HOOK_POSTINSTALL
!insertmacro IsShortcutTarget "$DESKTOP\${PRODUCTNAME}.lnk" "$OldInstallDir\${MAINBINARYNAME}.exe"
Pop $0
${If} $0 = 1
!insertmacro SetShortcutTarget "$DESKTOP\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
Return
${EndIf}
!macroend

View File

@@ -15,7 +15,6 @@
"icon": ["icons/128x128.png", "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico"],
"windows": {
"nsis": {
"installMode": "perMachine",
"installerHooks": "./nsis/hooks.nsi"
}
},

View File

@@ -50,35 +50,13 @@
</div>
<div v-else-if="generatedMessage">
<div>
<ButtonStyled>
<button class="mb-2" @click="useSimpleEditor = !useSimpleEditor">
<template v-if="!useSimpleEditor">
<ToggleLeftIcon aria-hidden="true" />
Use simple mode
</template>
<template v-else>
<ToggleRightIcon aria-hidden="true" />
Use advanced mode
</template>
</button>
</ButtonStyled>
<MarkdownEditor
v-if="!useSimpleEditor"
v-model="message"
:max-height="400"
placeholder="No message generated."
:disabled="false"
:heading-buttons="false"
/>
<textarea
v-else
v-model="message"
type="text"
class="bg-bg-input h-[400px] w-full rounded-lg border border-solid border-divider px-3 py-2 font-mono text-base"
placeholder="No message generated."
autocomplete="off"
@input="persistState"
/>
</div>
</div>
<div v-else-if="isModpackPermissionsStage">
@@ -346,8 +324,6 @@ import {
CheckIcon,
KeyboardIcon,
EyeOffIcon,
ToggleLeftIcon,
ToggleRightIcon,
} from "@modrinth/assets";
import {
checklist,
@@ -392,6 +368,7 @@ import {
type Stage,
finalPermissionMessages,
} from "@modrinth/moderation";
import * as prettier from "prettier";
import ModpackPermissionsFlow from "./ModpackPermissionsFlow.vue";
import KeybindsModal from "./ChecklistKeybindsModal.vue";
import { useModerationStore } from "~/store/moderation.ts";
@@ -415,7 +392,6 @@ const isModpackPermissionsStage = computed(() => {
return currentStageObj.value.id === "modpack-permissions";
});
const useSimpleEditor = ref(false);
const message = ref("");
const generatedMessage = ref(false);
const loadingMessage = ref(false);
@@ -1142,7 +1118,19 @@ async function generateMessage() {
}
}
message.value = fullMessage;
try {
const formattedMessage = await prettier.format(fullMessage, {
parser: "markdown",
printWidth: 80,
proseWrap: "always",
tabWidth: 2,
useTabs: false,
});
message.value = formattedMessage;
} catch (formattingError) {
console.warn("Failed to format markdown, using original:", formattingError);
message.value = fullMessage;
}
generatedMessage.value = true;
} catch (error) {

View File

@@ -169,8 +169,6 @@ import _TerminalSquareIcon from './icons/terminal-square.svg?component'
import _TestIcon from './icons/test.svg?component'
import _TextQuoteIcon from './icons/text-quote.svg?component'
import _TimerIcon from './icons/timer.svg?component'
import _ToggleLeftIcon from './icons/toggle-left.svg?component'
import _ToggleRightIcon from './icons/toggle-right.svg?component'
import _TransferIcon from './icons/transfer.svg?component'
import _TrashIcon from './icons/trash.svg?component'
import _TriangleAlertIcon from './icons/triangle-alert.svg?component'
@@ -364,8 +362,6 @@ export const TerminalSquareIcon = _TerminalSquareIcon
export const TestIcon = _TestIcon
export const TextQuoteIcon = _TextQuoteIcon
export const TimerIcon = _TimerIcon
export const ToggleLeftIcon = _ToggleLeftIcon
export const ToggleRightIcon = _ToggleRightIcon
export const TransferIcon = _TransferIcon
export const TrashIcon = _TrashIcon
export const TriangleAlertIcon = _TriangleAlertIcon

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-toggle-left-icon lucide-toggle-left"><circle cx="9" cy="12" r="3"/><rect width="20" height="14" x="2" y="5" rx="7"/></svg>

Before

Width:  |  Height:  |  Size: 324 B

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-toggle-right-icon lucide-toggle-right"><circle cx="15" cy="12" r="3"/><rect width="20" height="14" x="2" y="5" rx="7"/></svg>

Before

Width:  |  Height:  |  Size: 327 B