Skip to content

Commit

Permalink
Merge pull request #25 from OpenShock/ui
Browse files Browse the repository at this point in the history
The UI + various other fixes and reworks
  • Loading branch information
LucHeart authored May 10, 2024
2 parents fb354de + 4095507 commit 7ca02ee
Show file tree
Hide file tree
Showing 125 changed files with 6,207 additions and 1,365 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
types: [opened, reopened, synchronize]
workflow_call:
workflow_dispatch:

name: ci-windows

env:
DOTNET_VERSION: 8.0.x
REGISTRY: ghcr.io

jobs:

build:
runs-on: windows-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup .NET SDK ${{ env.DOTNET_VERSION }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Cache NuGet packages
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Publish ShockOSC Windows
run: dotnet publish ShockOsc/ShockOsc.csproj -c Release -f net8.0-windows10.0.19041.0 -o ./publish/ShockOsc

- name: Upload ShockOSC Windows artifacts
uses: actions/upload-artifact@v4
with:
name: ShockOsc
path: publish/ShockOsc/*
retention-days: 1
if-no-files-found: error

instller:
runs-on: windows-latest
needs: build

steps:
- name: Checkout
uses: actions/checkout@v4
with:
sparse-checkout: |
Installer
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: ShockOsc
path: publish/


- name: Create nsis installer
uses: joncloud/makensis-action@publish
with:
script-file: ${{ github.workspace }}/Installer/installer.nsi
additional-plugin-paths: ${{ github.workspace }}/Installer/Plugins

- name: Upload ShockOSC Windows Setup
uses: actions/upload-artifact@v4
with:
name: ShockOsc_Setup
path: Installer/ShockOsc_Setup.exe
retention-days: 7
if-no-files-found: error
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ bin/
obj/
.idea
*.DotSettings.user
.vs
.vs
ShockOsc_Setup.exe
Binary file added Installer/Plugins/x86-unicode/ApplicationID.dll
Binary file not shown.
Binary file added Installer/Plugins/x86-unicode/INetC.dll
Binary file not shown.
Binary file not shown.
Binary file added Installer/Plugins/x86-unicode/nsProcess.dll
Binary file not shown.
2 changes: 2 additions & 0 deletions Installer/build-installer.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"C:\Program Files (x86)\NSIS\makensis.exe" installer.nsi
pause
208 changes: 208 additions & 0 deletions Installer/installer.nsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
;--------------------------------
;Plugins
;https://nsis.sourceforge.io/ApplicationID_plug-in
;https://nsis.sourceforge.io/ShellExecAsUser_plug-in
;https://nsis.sourceforge.io/NsProcess_plugin
;https://nsis.sourceforge.io/Inetc_plug-in

;--------------------------------
;Version

!define PRODUCT_VERSION "1.0.0.0"
!define VERSION "1.0.0.0"
VIProductVersion "${PRODUCT_VERSION}"
VIFileVersion "${VERSION}"
VIAddVersionKey "FileVersion" "${VERSION}"
VIAddVersionKey "ProductName" "ShockOSC"
VIAddVersionKey "ProductVersion" "${PRODUCT_VERSION}"
VIAddVersionKey "LegalCopyright" "Copyright OpenShock"
VIAddVersionKey "FileDescription" ""

;--------------------------------
;Include Modern UI

!include "MUI2.nsh"
!include "FileFunc.nsh"
!include "LogicLib.nsh"

;--------------------------------
;General

Unicode True
Name "ShockOSC"
OutFile "ShockOSC_Setup.exe"
InstallDir "$LocalAppdata\ShockOSC"
InstallDirRegKey HKLM "Software\ShockOSC" "InstallDir"
RequestExecutionLevel admin
ShowInstDetails show

;--------------------------------
;Variables

VAR upgradeInstallation

;--------------------------------
;Interface Settings

!define MUI_ABORTWARNING

;--------------------------------
;Icons

!define MUI_ICON "..\publish\Resources\openshock-icon.ico"
!define MUI_UNICON "..\publish\Resources\openshock-icon.ico"

;--------------------------------
;Pages

!insertmacro MUI_PAGE_LICENSE "..\LICENSE"
!define MUI_PAGE_CUSTOMFUNCTION_PRE dirPre
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES

;------------------------------
; Finish Page

; Checkbox to launch ShockOSC.
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_TEXT "Launch ShockOSC"
!define MUI_FINISHPAGE_RUN_FUNCTION launchShockOSC

; Checkbox to create desktop shortcut.
!define MUI_FINISHPAGE_SHOWREADME
!define MUI_FINISHPAGE_SHOWREADME_TEXT "Create desktop shortcut"
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION createDesktopShortcut
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH

;--------------------------------
;Languages

!insertmacro MUI_LANGUAGE "English"

;--------------------------------
;Macros

;--------------------------------
;Functions

Function dirPre
StrCmp $upgradeInstallation "true" 0 +2
Abort
FunctionEnd

Function .onInit
StrCpy $upgradeInstallation "false"

ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ShockOSC" "UninstallString"
StrCmp $R0 "" done

; If ShockOSC is already running, display a warning message
StrCpy $1 "OpenShock.ShockOsc.exe"
nsProcess::_FindProcess "$1"
Pop $R1
${If} $R1 = 0
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "ShockOSC is still running. $\n$\nClick `OK` to kill the running process or `Cancel` to cancel this installer." /SD IDOK IDCANCEL cancel
nsExec::ExecToStack "taskkill /IM OpenShock.ShockOsc.exe"
${EndIf}

MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "ShockOSC is already installed. $\n$\nClick `OK` to upgrade the existing installation or `Cancel` to cancel this upgrade." /SD IDOK IDCANCEL cancel
Goto next
cancel:
Abort
next:
StrCpy $upgradeInstallation "true"
done:
FunctionEnd

Function createDesktopShortcut
CreateShortcut "$DESKTOP\ShockOSC.lnk" "$INSTDIR\OpenShock.ShockOsc.exe"
FunctionEnd

Function launchShockOSC
SetOutPath $INSTDIR
ShellExecAsUser::ShellExecAsUser "" "$INSTDIR\OpenShock.ShockOsc.exe" ""
FunctionEnd

;--------------------------------
;Installer Sections

Section "Install" SecInstall

StrCmp $upgradeInstallation "true" 0 noupgrade
DetailPrint "Uninstall previous version..."
ExecWait '"$INSTDIR\Uninstall.exe" /S _?=$INSTDIR'
Delete $INSTDIR\Uninstall.exe
Goto afterupgrade

noupgrade:

afterupgrade:

ReadRegStr $R0 HKLM "SOFTWARE\Classes\Installer\Dependencies\Microsoft.VS.VC_RuntimeMinimumVSU_amd64,v14" "Version"
IfErrors 0 VSRedistInstalled

inetc::get "https://aka.ms/vs/17/release/vc_redist.x64.exe" $TEMP\vcredist_x64.exe
ExecWait "$TEMP\vcredist_x64.exe /install /quiet /norestart"
Delete "$TEMP\vcredist_x64.exe"
VSRedistInstalled:

SetOutPath "$INSTDIR"

File /r /x *.log /x *.pdb /x *.mui "..\publish\*.*"

WriteRegStr HKLM "Software\ShockOSC" "InstallDir" $INSTDIR
WriteUninstaller "$INSTDIR\Uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ShockOSC" "DisplayName" "ShockOSC"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ShockOSC" "UninstallString" "$\"$INSTDIR\Uninstall.exe$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ShockOSC" "DisplayIcon" "$\"$INSTDIR\Resources\openshock-icon.ico$\""

${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
IntFmt $0 "0x%08X" $0
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ShockOSC" "EstimatedSize" "$0"

CreateShortCut "$SMPROGRAMS\ShockOSC.lnk" "$INSTDIR\OpenShock.ShockOsc.exe"
ApplicationID::Set "$SMPROGRAMS\ShockOSC.lnk" "ShockOSC"

WriteRegStr HKCU "Software\Classes\ShockOSC" "" "URL:ShockOSC"
WriteRegStr HKCU "Software\Classes\ShockOSC" "FriendlyTypeName" "ShockOSC"
WriteRegStr HKCU "Software\Classes\ShockOSC" "URL Protocol" ""
WriteRegExpandStr HKCU "Software\Classes\ShockOSC\DefaultIcon" "" "$INSTDIR\Resources\openshock-icon.ico"
WriteRegStr HKCU "Software\Classes\ShockOSC\shell" "" "open"
WriteRegStr HKCU "Software\Classes\ShockOSC\shell\open" "FriendlyAppName" "ShockOSC"
WriteRegStr HKCU "Software\Classes\ShockOSC\shell\open\command" "" '"$INSTDIR\OpenShock.ShockOsc.exe" --uri="%1"'

${If} ${Silent}
SetOutPath $INSTDIR
ShellExecAsUser::ShellExecAsUser "" "$INSTDIR\OpenShock.ShockOsc.exe" ""
${EndIf}

SectionEnd

;--------------------------------
;Uninstaller Section

Section "Uninstall"
; If ShockOSC is already running, display a warning message and exit
StrCpy $1 "OpenShock.ShockOsc.exe"
nsProcess::_FindProcess "$1"
Pop $R1
${If} $R1 = 0
MessageBox MB_OK|MB_ICONEXCLAMATION "ShockOSC is still running. Cannot uninstall this software.$\nPlease close ShockOSC and try again." /SD IDOK
Abort
${EndIf}

RMDir /r "$INSTDIR"

DeleteRegKey HKLM "Software\ShockOSC"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ShockOSC"
DeleteRegKey HKCU "Software\Classes\ShockOSC"

${IfNot} ${Silent}
Delete "$SMPROGRAMS\ShockOSC.lnk"
Delete "$DESKTOP\ShockOSC.lnk"
${EndIf}
SectionEnd
9 changes: 8 additions & 1 deletion ShockOsc.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShockOsc", "ShockOsc\ShockOsc.csproj", "{D3C13FCF-0FF6-45E1-AA57-0EDF1AB8C48B}"
# Visual Studio Version 17
VisualStudioVersion = 17.9.34622.214
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShockOsc", "ShockOsc\ShockOsc.csproj", "{D3C13FCF-0FF6-45E1-AA57-0EDF1AB8C48B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -10,7 +13,11 @@ Global
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D3C13FCF-0FF6-45E1-AA57-0EDF1AB8C48B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D3C13FCF-0FF6-45E1-AA57-0EDF1AB8C48B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D3C13FCF-0FF6-45E1-AA57-0EDF1AB8C48B}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{D3C13FCF-0FF6-45E1-AA57-0EDF1AB8C48B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D3C13FCF-0FF6-45E1-AA57-0EDF1AB8C48B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
8 changes: 8 additions & 0 deletions ShockOsc/Backend/AuthState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace OpenShock.ShockOsc.Backend;

public enum AuthState
{
NotAuthenticated,
Authenticating,
Authenticated
}
Loading

0 comments on commit 7ca02ee

Please sign in to comment.