Simplify GUI settings and build flags

This commit is contained in:
every_holiday
2026-06-26 09:16:46 +09:00
parent 4d77e67870
commit ae426244e0
22 changed files with 846 additions and 237 deletions

View File

@@ -5,7 +5,9 @@ package main
import (
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
"syscall"
"unsafe"
)
@@ -55,6 +57,14 @@ func openBrowser(url string) {
_ = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
}
func trayIconPath() string {
exe, err := os.Executable()
if err != nil {
return filepath.Join("doc", "vrcworldtour_new.ico")
}
return filepath.Join(filepath.Dir(exe), "..", "doc", "vrcworldtour_new.ico")
}
func runTray(uiURL string, open func()) error {
user32 := syscall.NewLazyDLL("user32.dll")
shell32 := syscall.NewLazyDLL("shell32.dll")
@@ -72,7 +82,7 @@ func runTray(uiURL string, open func()) error {
setForegroundWindow := user32.NewProc("SetForegroundWindow")
trackPopupMenu := user32.NewProc("TrackPopupMenu")
showWindow := user32.NewProc("ShowWindow")
loadIcon := user32.NewProc("LoadIconW")
loadImage := user32.NewProc("LoadImageW")
shellNotifyIcon := shell32.NewProc("Shell_NotifyIconW")
getModuleHandle := kernel32.NewProc("GetModuleHandleW")
@@ -119,7 +129,13 @@ func runTray(uiURL string, open func()) error {
className, _ := syscall.UTF16PtrFromString("VRC_OSC_TRAY")
windowTitle, _ := syscall.UTF16PtrFromString("VRC OSC Tray")
icon, _, _ := loadIcon.Call(0, 32512) // IDI_APPLICATION
iconPath := trayIconPath()
iconPathPtr, _ := syscall.UTF16PtrFromString(iconPath)
const (
lrLoadFromFile = 0x00000010
imageIcon = 1
)
icon, _, _ := loadImage.Call(0, uintptr(unsafe.Pointer(iconPathPtr)), imageIcon, 0, 0, lrLoadFromFile)
var hwnd uintptr
var menu uintptr