Skip to content

Commit b1b0fe6

Browse files
author
yyyumeniku
committed
feat: macOS DMG improvements, new icon, build script, docs
1 parent 7dca4a6 commit b1b0fe6

File tree

9 files changed

+355
-4
lines changed

9 files changed

+355
-4
lines changed

.github/workflows/release.yml

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,18 +279,92 @@ jobs:
279279
if [ -f "artifacts/HyPrism.app/Contents/MacOS/jre.json" ]; then
280280
cp "artifacts/HyPrism.app/Contents/MacOS/jre.json" "artifacts/HyPrism.app/Contents/Resources/"
281281
fi
282+
if [ -d "artifacts/HyPrism.app/Contents/MacOS/assets" ]; then
283+
cp -R "artifacts/HyPrism.app/Contents/MacOS/assets" "artifacts/HyPrism.app/Contents/Resources/"
284+
fi
282285
283286
cp packaging/macos/Info.plist "artifacts/HyPrism.app/Contents/"
284-
cp packaging/macos/HyPrism.icns "artifacts/HyPrism.app/Contents/Resources/"
287+
cp packaging/macos/hyprism-macos.icns "artifacts/HyPrism.app/Contents/Resources/"
285288
chmod +x "artifacts/HyPrism.app/Contents/MacOS/HyPrism"
286289
echo "APPL????" > "artifacts/HyPrism.app/Contents/PkgInfo"
287290
288291
- name: Create DMG (arm64 only)
289292
run: |
293+
set -e
294+
290295
mkdir -p dmg
291296
cp -R "artifacts/HyPrism.app" "dmg/HyPrism.app"
292297
ln -s /Applications dmg/Applications
293-
hdiutil create -volname "HyPrism" -srcfolder dmg -ov -format UDZO artifacts/HyPrism-macos-arm64.dmg
298+
299+
# Create the "Fix Permissions" command file
300+
cat > "dmg/Fix Permissions (Run First).command" << 'EOF'
301+
#!/bin/bash
302+
# This script removes quarantine attributes from HyPrism
303+
# Run this if macOS says the app is damaged or can't be opened
304+
305+
APP_PATH="$(dirname "$0")/HyPrism.app"
306+
307+
echo "Removing quarantine attributes from HyPrism..."
308+
xattr -cr "$APP_PATH"
309+
310+
echo ""
311+
echo "Done! You can now open HyPrism.app"
312+
echo "Press any key to close this window..."
313+
read -n 1
314+
EOF
315+
chmod +x "dmg/Fix Permissions (Run First).command"
316+
317+
# Use specific background image
318+
SELECTED_BG="packaging/macos/dmg-background.jpg"
319+
320+
if [ -f "$SELECTED_BG" ]; then
321+
echo "Using background: $(basename "$SELECTED_BG")"
322+
mkdir -p dmg/.background
323+
cp "$SELECTED_BG" "dmg/.background/background.jpg"
324+
else
325+
echo "Background image not found: $SELECTED_BG"
326+
fi
327+
328+
# Create temporary read-write DMG
329+
hdiutil create -volname "HyPrism" -srcfolder dmg -ov -format UDRW -fs HFS+ temp.dmg
330+
331+
# Mount and customize
332+
MOUNT_POINT=$(hdiutil attach -readwrite -noverify -noautoopen temp.dmg | grep "/Volumes/HyPrism" | sed 's/.*\(\/Volumes\/.*\)/\1/')
333+
334+
if [ -n "$MOUNT_POINT" ]; then
335+
sleep 2
336+
337+
# Set up DMG appearance with AppleScript
338+
osascript <<EOF
339+
tell application "Finder"
340+
tell disk "HyPrism"
341+
open
342+
set current view of container window to icon view
343+
set toolbar visible of container window to false
344+
set statusbar visible of container window to false
345+
set the bounds of container window to {400, 200, 1040, 680}
346+
set viewOptions to the icon view options of container window
347+
set arrangement of viewOptions to not arranged
348+
set icon size of viewOptions to 128
349+
set background picture of viewOptions to file ".background:background.jpg"
350+
set position of item "HyPrism.app" of container window to {120, 220}
351+
set position of item "Applications" of container window to {500, 220}
352+
set position of item "Fix Permissions.command" of container window to {310, 400}
353+
close
354+
open
355+
update without registering applications
356+
delay 5
357+
end tell
358+
end tell
359+
EOF
360+
361+
sync
362+
hdiutil detach "$MOUNT_POINT"
363+
fi
364+
365+
# Convert to compressed DMG
366+
hdiutil convert temp.dmg -format UDZO -o artifacts/HyPrism-macos-arm64.dmg
367+
rm -f temp.dmg
294368

295369
- name: Upload macOS artifacts
296370
uses: actions/upload-artifact@v4

Backend/AppService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7799,7 +7799,7 @@ public List<string> GetAvailableBackgrounds()
77997799
// CurseForge API constants
78007800
private const string CurseForgeBaseUrl = "https://api.curseforge.com/v1";
78017801
private const int HytaleGameId = 70216; // Hytale game ID on CurseForge
7802-
private const string CurseForgeApiKey = "$2a$10$bL4bIL5pUWqfcO7KQtnMReakwtfHbNKh6v1uTpKlzhwoueEJQnPnm";
7802+
private const string CurseForgeApiKey = "CurseForgeApiKey";
78037803

78047804
// Mod Manager with CurseForge API
78057805
public async Task<ModSearchResult> SearchModsAsync(string query, int page, int pageSize, string[] categories, int sortField, int sortOrder)

assets/Hyprism.svg

Lines changed: 20 additions & 0 deletions
Loading

docs/HOW-GAME-WORKS.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
HOW GAME LAUNCHING AND PATCHING WORKS
2+
3+
When user clicks PLAY:
4+
5+
1. DownloadAndLaunchAsync() in AppService.cs runs
6+
2. Downloads game zip from Hytale servers if not installed, extracts to instances/{branch}/{version}/
7+
3. If already installed, checks for updates and applies .pwr patch files using Butler
8+
9+
Patching (ClientPatcher.cs):
10+
11+
1. EnsureClientPatched() finds the client binary
12+
2. PatchClient() reads the binary, searches for "hytale.com" string
13+
3. Replaces "hytale.com" with "sanasol.ws" (same 10 char length)
14+
4. This makes sessions.hytale.com become sessions.sanasol.ws
15+
5. PatchServerJar() does the same for Server/HytaleServer.jar (needed for singleplayer)
16+
6. Saves backup as .original, creates .patched_custom flag so it doesnt patch again
17+
7. On macOS re-signs with codesign after patching
18+
19+
Launching (LaunchGameAsync in AppService.cs):
20+
21+
1. Gets UUID for username (same username = same UUID always)
22+
2. If online mode: calls AuthService to get identity + session tokens from auth server
23+
3. Starts HytaleClient with args:
24+
--app-dir, --user-dir, --java-exec, --name, --auth-mode, --uuid, --identity-token, --session-token
25+
26+
Thats it.

packaging/macos/HyPrism.icns

2.55 MB
Binary file not shown.

packaging/macos/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<key>CFBundleExecutable</key>
88
<string>HyPrism</string>
99
<key>CFBundleIconFile</key>
10-
<string>HyPrism.icns</string>
10+
<string>hyprism-macos.icns</string>
1111
<key>CFBundleIdentifier</key>
1212
<string>dev.hyprism.HyPrism</string>
1313
<key>CFBundleInfoDictionaryVersion</key>

packaging/macos/dmg-background.jpg

27.7 KB
Loading

packaging/macos/hyprism-macos.icns

1010 KB
Binary file not shown.

scripts/build-macos-local.sh

Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Colors for output
5+
RED='\033[0;31m'
6+
GREEN='\033[0;32m'
7+
YELLOW='\033[1;33m'
8+
NC='\033[0m' # No Color
9+
10+
echo -e "${GREEN}========================================${NC}"
11+
echo -e "${GREEN} HyPrism macOS Build Script (Local)${NC}"
12+
echo -e "${GREEN}========================================${NC}"
13+
14+
# Get the script directory and project root
15+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
16+
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
17+
18+
cd "$PROJECT_ROOT"
19+
20+
# Detect architecture
21+
ARCH=$(uname -m)
22+
if [ "$ARCH" = "arm64" ]; then
23+
RID="osx-arm64"
24+
ARCH_NAME="arm64"
25+
else
26+
RID="osx-x64"
27+
ARCH_NAME="x64"
28+
fi
29+
30+
echo -e "${YELLOW}Building for macOS ${ARCH_NAME}...${NC}"
31+
32+
# Build frontend
33+
echo -e "${YELLOW}Building frontend...${NC}"
34+
cd frontend
35+
npm ci
36+
npm run build
37+
cd ..
38+
39+
# Build .NET app
40+
echo -e "${YELLOW}Building .NET application...${NC}"
41+
dotnet publish ./HyPrism.csproj -c Release -r "$RID" --self-contained true -o "artifacts/$RID"
42+
43+
# Create app bundle
44+
echo -e "${YELLOW}Creating macOS app bundle...${NC}"
45+
APP_NAME="HyPrism.app"
46+
APP_PATH="artifacts/$APP_NAME"
47+
48+
rm -rf "$APP_PATH"
49+
mkdir -p "$APP_PATH/Contents/MacOS"
50+
mkdir -p "$APP_PATH/Contents/Resources"
51+
52+
# Copy all files from publish output
53+
cp -R "artifacts/$RID/"* "$APP_PATH/Contents/MacOS/"
54+
55+
# Copy resources
56+
if [ -d "$APP_PATH/Contents/MacOS/wwwroot" ]; then
57+
cp -R "$APP_PATH/Contents/MacOS/wwwroot" "$APP_PATH/Contents/Resources/"
58+
fi
59+
if [ -f "$APP_PATH/Contents/MacOS/jre.json" ]; then
60+
cp "$APP_PATH/Contents/MacOS/jre.json" "$APP_PATH/Contents/Resources/"
61+
fi
62+
if [ -d "$APP_PATH/Contents/MacOS/assets" ]; then
63+
cp -R "$APP_PATH/Contents/MacOS/assets" "$APP_PATH/Contents/Resources/"
64+
fi
65+
66+
# Copy Info.plist and icon
67+
cp packaging/macos/Info.plist "$APP_PATH/Contents/"
68+
cp packaging/macos/hyprism-macos.icns "$APP_PATH/Contents/Resources/"
69+
70+
# Set executable permission
71+
chmod +x "$APP_PATH/Contents/MacOS/HyPrism"
72+
73+
# Create PkgInfo
74+
echo "APPL????" > "$APP_PATH/Contents/PkgInfo"
75+
76+
# Sign the app locally (ad-hoc signing)
77+
echo -e "${YELLOW}Signing app bundle (ad-hoc)...${NC}"
78+
codesign --force --deep --sign - "$APP_PATH" || echo -e "${YELLOW}Warning: Codesign failed, continuing anyway${NC}"
79+
80+
# Create DMG
81+
echo -e "${YELLOW}Creating DMG...${NC}"
82+
DMG_NAME="HyPrism-macos-${ARCH_NAME}.dmg"
83+
DMG_PATH="artifacts/$DMG_NAME"
84+
DMG_STAGING="artifacts/dmg-staging"
85+
86+
rm -rf "$DMG_STAGING"
87+
rm -f "$DMG_PATH"
88+
rm -f "artifacts/HyPrism-rw.dmg"
89+
mkdir -p "$DMG_STAGING"
90+
91+
# Copy app to staging
92+
cp -R "$APP_PATH" "$DMG_STAGING/"
93+
94+
# Create Applications symlink
95+
ln -s /Applications "$DMG_STAGING/Applications"
96+
97+
# Create the "Fix Permissions" command file
98+
cat > "$DMG_STAGING/Fix Permissions.command" << 'EOF'
99+
#!/bin/bash
100+
# This script removes quarantine attributes from HyPrism
101+
# Run this if macOS says the app is damaged or can't be opened
102+
103+
APP_PATH="$(dirname "$0")/HyPrism.app"
104+
105+
echo "================================"
106+
echo " HyPrism - Fix Permissions"
107+
echo "================================"
108+
echo ""
109+
echo "Removing quarantine attributes..."
110+
xattr -cr "$APP_PATH"
111+
112+
echo ""
113+
echo "✓ Done! You can now open HyPrism.app"
114+
echo ""
115+
echo "Press any key to close..."
116+
read -n 1 -s
117+
EOF
118+
chmod +x "$DMG_STAGING/Fix Permissions.command"
119+
120+
# Use specific background image
121+
echo -e "${YELLOW}Setting up DMG background...${NC}"
122+
SELECTED_BG="$PROJECT_ROOT/packaging/macos/dmg-background.jpg"
123+
BG_EXT="jpg"
124+
125+
if [ -f "$SELECTED_BG" ]; then
126+
BG_FILENAME=$(basename "$SELECTED_BG")
127+
echo -e "${GREEN}Using background: $BG_FILENAME${NC}"
128+
129+
# Create .background directory and copy the background
130+
mkdir -p "$DMG_STAGING/.background"
131+
cp "$SELECTED_BG" "$DMG_STAGING/.background/background.$BG_EXT"
132+
else
133+
echo -e "${RED}Background image not found: $SELECTED_BG${NC}"
134+
SELECTED_BG=""
135+
BG_EXT=""
136+
fi
137+
138+
# Create a temporary read-write DMG
139+
echo -e "${YELLOW}Creating temporary DMG...${NC}"
140+
hdiutil create -volname "HyPrism" -srcfolder "$DMG_STAGING" -ov -format UDRW -fs HFS+ "artifacts/HyPrism-rw.dmg"
141+
142+
# Mount the DMG
143+
echo -e "${YELLOW}Mounting DMG for customization...${NC}"
144+
MOUNT_POINT=$(hdiutil attach -readwrite -noverify -noautoopen "artifacts/HyPrism-rw.dmg" | grep "/Volumes/HyPrism" | sed 's/.*\(\/Volumes\/.*\)/\1/')
145+
146+
if [ -z "$MOUNT_POINT" ]; then
147+
echo -e "${RED}Failed to mount DMG${NC}"
148+
exit 1
149+
fi
150+
151+
echo -e "${GREEN}Mounted at: $MOUNT_POINT${NC}"
152+
153+
# Give the system time to settle
154+
sleep 2
155+
156+
# Set custom icon positions and window settings
157+
echo -e "${YELLOW}Configuring DMG appearance...${NC}"
158+
159+
# Create AppleScript to set up the DMG
160+
cat > /tmp/dmg_setup.applescript << APPLESCRIPT
161+
tell application "Finder"
162+
tell disk "HyPrism"
163+
open
164+
set current view of container window to icon view
165+
set toolbar visible of container window to false
166+
set statusbar visible of container window to false
167+
set the bounds of container window to {400, 200, 1040, 680}
168+
set viewOptions to the icon view options of container window
169+
set arrangement of viewOptions to not arranged
170+
set icon size of viewOptions to 128
171+
set text size of viewOptions to 13
172+
set label position of viewOptions to bottom
173+
set shows icon preview of viewOptions to true
174+
APPLESCRIPT
175+
176+
# Add background picture if available
177+
if [ -n "$SELECTED_BG" ] && [ -f "$MOUNT_POINT/.background/background.$BG_EXT" ]; then
178+
cat >> /tmp/dmg_setup.applescript << APPLESCRIPT
179+
set background picture of viewOptions to file ".background:background.$BG_EXT"
180+
delay 1
181+
APPLESCRIPT
182+
fi
183+
184+
# Position items
185+
cat >> /tmp/dmg_setup.applescript << APPLESCRIPT
186+
set position of item "HyPrism.app" of container window to {120, 220}
187+
set position of item "Applications" of container window to {500, 220}
188+
set position of item "Fix Permissions.command" of container window to {310, 400}
189+
close
190+
open
191+
update without registering applications
192+
delay 5
193+
end tell
194+
end tell
195+
APPLESCRIPT
196+
197+
# Run the AppleScript
198+
osascript /tmp/dmg_setup.applescript
199+
200+
# Wait for changes to take effect
201+
sleep 3
202+
203+
# Make sure .DS_Store is written
204+
sync
205+
206+
# Unmount
207+
echo -e "${YELLOW}Unmounting DMG...${NC}"
208+
hdiutil detach "$MOUNT_POINT" -force || true
209+
sleep 2
210+
211+
# Convert to compressed read-only DMG
212+
echo -e "${YELLOW}Compressing DMG...${NC}"
213+
hdiutil convert "artifacts/HyPrism-rw.dmg" -format UDZO -imagekey zlib-level=9 -o "$DMG_PATH"
214+
215+
# Clean up
216+
rm -f "artifacts/HyPrism-rw.dmg"
217+
rm -f /tmp/dmg_setup.applescript
218+
rm -rf "$DMG_STAGING"
219+
220+
echo ""
221+
echo -e "${GREEN}========================================${NC}"
222+
echo -e "${GREEN} Build Complete!${NC}"
223+
echo -e "${GREEN}========================================${NC}"
224+
echo ""
225+
echo -e "App Bundle: ${YELLOW}$APP_PATH${NC}"
226+
echo -e "DMG: ${YELLOW}$DMG_PATH${NC}"
227+
echo ""
228+
echo -e "${GREEN}To install:${NC}"
229+
echo "1. Open the DMG file"
230+
echo "2. Run 'Fix Permissions (Run First).command'"
231+
echo "3. Drag HyPrism.app to Applications"

0 commit comments

Comments
 (0)