Skip to content

Commit 968bdcf

Browse files
feat: v3
resolves #2
1 parent b2eeffb commit 968bdcf

File tree

160 files changed

+28285
-357
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+28285
-357
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
Resources/Cursors/Edited
2-
prefs
2+
prefs.ini

CCS.ps1

Lines changed: 46 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -7,106 +7,77 @@ $ErrorActionPreference = 'Stop'
77
$previousWindowTitle = $Host.UI.RawUI.WindowTitle
88
$Host.UI.RawUI.WindowTitle = 'Cursor Colors Synchronizer'
99

10+
Import-Module -Name "$PSScriptRoot\Functions.psm1" -Force
11+
$PathsProvider = Initialize-PathsProvider
12+
$PrefsManager = Initialize-PrefsManager
13+
1014
$Parameters = @{
1115
BindingVariable = 'Localization'
12-
BaseDirectory = "$PSScriptRoot\Localizations"
16+
BaseDirectory = $PathsProvider::LocalizationsFolder
1317
FileName = 'Strings'
1418
}
1519
Import-LocalizedData @Parameters
16-
17-
Import-Module -Name "$PSScriptRoot\Functions.psm1" -Force
1820
#endregion Preparation
1921

20-
#region Dialogs
22+
#region Preferences
2123
Clear-Host
2224

23-
$Host.UI.RawUI.Flushinputbuffer()
24-
$choice = $Host.UI.PromptForChoice(
25-
'',
26-
$Localization.ChooseDialogPromt,
27-
(
28-
"&1 $($Localization.Small)",
29-
"&2 $($Localization.Regular)",
30-
"&3 $($Localization.Big)"
31-
),
32-
0
33-
)
34-
switch ($choice) {
35-
0 { $cursorSize = 'small' }
36-
1 { $cursorSize = 'regular' }
37-
2 { $cursorSize = 'big' }
25+
$Parameters = @{
26+
Message = $Localization.TailVersionDialogTitle
27+
Variants = [ordered]@{
28+
$true = $Localization.Yes
29+
$false = $Localization.No
30+
}
31+
Default = $false
3832
}
33+
$PrefsManager::UseTailVersion = Read-Choice @Parameters
3934

35+
if (-not ($PrefsManager::UseTailVersion)) {
36+
$Parameters = @{
37+
Message = $Localization.ChooseSizeDialogTitle
38+
Variants = [ordered]@{
39+
small = $Localization.Small
40+
regular = $Localization.Regular
41+
big = $Localization.Big
42+
}
43+
}
44+
$PrefsManager::CursorSize = Read-Choice @Parameters
4045

41-
$Host.UI.RawUI.Flushinputbuffer()
42-
$choice = $Host.UI.PromptForChoice(
43-
'',
44-
$Localization.ChoosePrecisionDialogTitle,
45-
(
46-
"&1 $($Localization.Yes)",
47-
"&2 $($Localization.No)"
48-
),
49-
1
50-
)
51-
switch ($choice) {
52-
0 { $useAlternatePrecision = $true }
53-
1 { $useAlternatePrecision = $false }
46+
$Parameters = @{
47+
Message = $Localization.ChoosePrecisionDialogTitle
48+
Variants = [ordered]@{
49+
$true = $Localization.Yes
50+
$false = $Localization.No
51+
}
52+
Default = $false
53+
}
54+
$PrefsManager::UseAlternatePrecision = Read-Choice @Parameters
5455
}
5556

56-
$Host.UI.RawUI.Flushinputbuffer()
57-
$choice = $Host.UI.PromptForChoice(
58-
'',
59-
$Localization.ListenerDialogTitle,
60-
(
61-
"&1 $($Localization.Yes)",
62-
"&2 $($Localization.No)"
63-
),
64-
0
65-
)
66-
switch ($choice) {
67-
0 { $installListener = $true }
68-
1 { $installListener = $false }
57+
$Parameters = @{
58+
Message = $Localization.ListenerDialogTitle
59+
Variants = [ordered]@{
60+
$true = $Localization.Yes
61+
$false = $Localization.No
62+
}
6963
}
70-
#endregion Dialogs
64+
$installListener = Read-Choice @Parameters
7165

72-
73-
#region Variables
74-
$systemTheme = Get-SystemTheme
75-
$prefsPath = "$PSScriptRoot\prefs"
76-
$resourcesFolderPath = "$PSScriptRoot\Resources"
77-
$diffFolder = "$resourcesFolderPath\Diffs\$cursorSize"
78-
$cursorsFolderPath = "$resourcesFolderPath\Cursors"
79-
$originalCursorFolderPath = "$cursorsFolderPath\Original\$systemTheme\$cursorSize"
80-
$editedCursorFolderPath = "$cursorsFolderPath\Edited"
81-
#endregion Variables
66+
$PrefsManager::Save()
67+
#endregion Preferences
8268

8369
#region Cursor
84-
Copy-Item -Path "$originalCursorFolderPath\default\*" -Destination $editedCursorFolderPath -Recurse -Force
85-
if (($systemTheme -eq 'light') -and ($cursorSize -eq 'big')) {
86-
Edit-Cursors -Path $editedCursorFolderPath -DiffFolderPath $diffFolder -UseAlternateDiff
87-
}
88-
else {
89-
Edit-Cursors -Path $editedCursorFolderPath -DiffFolderPath $diffFolder
90-
}
91-
92-
if ($useAlternatePrecision) {
93-
Copy-Item -Path "$originalCursorFolderPath\alternatives\precision.cur" -Destination $editedCursorFolderPath -Force
94-
}
95-
Install-Cursors -Path $editedCursorFolderPath
96-
Update-Cursor
70+
Copy-Cursors
71+
Edit-Cursors
72+
Install-Cursors
9773
#endregion Cursor
9874

99-
#region Parameters
100-
Set-Content -Path $prefsPath -Value $cursorSize
101-
Add-Content -Path $prefsPath -Value $useAlternatePrecision
102-
#endregion Parameters
103-
10475
#region Listener
10576
if ($installListener) {
10677
$Parameters = @{
10778
TaskName = 'CCS Listener'
10879
Description = $Localization.ListenerTaskDescription
109-
Action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "-ExecutionPolicy Bypass -NoExit -WindowStyle Hidden -File `"$PSScriptRoot\Listener.ps1`""
80+
Action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "-ExecutionPolicy Bypass -NoExit -WindowStyle Hidden -File `"$($PathsProvider::Listener)`""
11081
Trigger = New-ScheduledTaskTrigger -AtLogOn -User (whoami)
11182
Settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -StartWhenAvailable -DontStopIfGoingOnBatteries -ExecutionTimeLimit '00:00:00'
11283
RunLevel = 'Highest'

0 commit comments

Comments
 (0)