Compare commits
6 Commits
v0.1.3-tes
...
v0.1.3-tes
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f9968895ac | ||
|
|
452c7c59b6 | ||
|
|
b059c91388 | ||
|
|
289337f016 | ||
|
|
dadc65065c | ||
|
|
4df1a5d71a |
@@ -25,7 +25,7 @@ jobs:
|
|||||||
- name: Test
|
- name: Test
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
GO111MODULE=on go test ./...
|
GO111MODULE=on go test ./internal/...
|
||||||
|
|
||||||
- name: Build executables
|
- name: Build executables
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|||||||
@@ -89,6 +89,22 @@ type historyExportResult struct {
|
|||||||
SelectedCount int
|
SelectedCount int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type historyRefreshResult struct {
|
||||||
|
Rows []guiWorldVisitRow
|
||||||
|
CalendarCells []historyCalendarCell
|
||||||
|
DetailRows []historyDetailRow
|
||||||
|
DetailHeightPx int32
|
||||||
|
SelectedDate time.Time
|
||||||
|
Month time.Time
|
||||||
|
SelectedKeys map[string]bool
|
||||||
|
Status string
|
||||||
|
Regex string
|
||||||
|
FromDate string
|
||||||
|
ToDate string
|
||||||
|
Err error
|
||||||
|
Elapsed time.Duration
|
||||||
|
}
|
||||||
|
|
||||||
var historyEventsCacheMu sync.Mutex
|
var historyEventsCacheMu sync.Mutex
|
||||||
var historyEventsCache struct {
|
var historyEventsCache struct {
|
||||||
jsonMod time.Time
|
jsonMod time.Time
|
||||||
@@ -106,12 +122,8 @@ func ensureHistoryState(app *guiApp) {
|
|||||||
app.historySelectedKeys = map[string]bool{}
|
app.historySelectedKeys = map[string]bool{}
|
||||||
}
|
}
|
||||||
if app.historySelectedDate.IsZero() {
|
if app.historySelectedDate.IsZero() {
|
||||||
if latest := latestHistoryDate(); !latest.IsZero() {
|
|
||||||
app.historySelectedDate = latest
|
|
||||||
} else {
|
|
||||||
app.historySelectedDate = time.Now()
|
app.historySelectedDate = time.Now()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if app.historyMonth.IsZero() {
|
if app.historyMonth.IsZero() {
|
||||||
app.historyMonth = time.Date(app.historySelectedDate.Year(), app.historySelectedDate.Month(), 1, 0, 0, 0, 0, app.historySelectedDate.Location())
|
app.historyMonth = time.Date(app.historySelectedDate.Year(), app.historySelectedDate.Month(), 1, 0, 0, 0, 0, app.historySelectedDate.Location())
|
||||||
}
|
}
|
||||||
@@ -579,9 +591,11 @@ func exportHistoryDay(app *guiApp, day time.Time, selected map[string]bool) (str
|
|||||||
}
|
}
|
||||||
|
|
||||||
func exportHistoryDayFromRequest(req historyExportRequest) (string, error) {
|
func exportHistoryDayFromRequest(req historyExportRequest) (string, error) {
|
||||||
|
events := historyEventsFromSnapshot()
|
||||||
|
visits := historyVisitSource()
|
||||||
rows := append([]historyDetailRow(nil), req.Rows...)
|
rows := append([]historyDetailRow(nil), req.Rows...)
|
||||||
if len(rows) == 0 {
|
if len(rows) == 0 {
|
||||||
rows = historyVisitsForDayFromData(nil, req.Day, historyVisitSource(), historyEventsFromSnapshot(), req.Query)
|
rows = historyVisitsForDayFromData(nil, req.Day, visits, events, req.Query)
|
||||||
}
|
}
|
||||||
if len(req.Selected) > 0 {
|
if len(req.Selected) > 0 {
|
||||||
filtered := rows[:0]
|
filtered := rows[:0]
|
||||||
@@ -667,6 +681,9 @@ func exportHistoryDayFromRequest(req historyExportRequest) (string, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
appendExportDayVisits(&b, req.Day, visits, req.Query)
|
||||||
|
appendExportDayEvents(&b, req.Day, events, req.Query)
|
||||||
|
appendExportGuestSnapshot(&b, req.Day, req.Query)
|
||||||
exportDir := runtimeDir()
|
exportDir := runtimeDir()
|
||||||
if strings.TrimSpace(req.ExportDir) != "" {
|
if strings.TrimSpace(req.ExportDir) != "" {
|
||||||
exportDir = normalizeHistoryExportDir(req.ExportDir)
|
exportDir = normalizeHistoryExportDir(req.ExportDir)
|
||||||
@@ -684,6 +701,153 @@ func exportHistoryDayFromRequest(req historyExportRequest) (string, error) {
|
|||||||
return path, nil
|
return path, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func appendExportDayVisits(b *strings.Builder, day time.Time, visits []historyVisitRecord, q historyQuery) {
|
||||||
|
if b == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
dayStart, dayEnd := historyDayBounds(day)
|
||||||
|
matched := make([]historyVisitRecord, 0, len(visits))
|
||||||
|
for _, visit := range visits {
|
||||||
|
start := visit.Start
|
||||||
|
if start.IsZero() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
end := visit.End
|
||||||
|
if end.IsZero() {
|
||||||
|
end = time.Now()
|
||||||
|
}
|
||||||
|
if !start.Before(dayEnd) || !end.After(dayStart) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if q.Pattern != nil && !q.Pattern.MatchString(visit.WorldLabel) && !q.Pattern.MatchString(visit.WorldID) && !q.Pattern.MatchString(visit.InstanceID) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
matched = append(matched, visit)
|
||||||
|
}
|
||||||
|
sort.SliceStable(matched, func(i, j int) bool {
|
||||||
|
return matched[i].Start.Before(matched[j].Start)
|
||||||
|
})
|
||||||
|
b.WriteString("\nAll visits:\n")
|
||||||
|
if len(matched) == 0 {
|
||||||
|
b.WriteString("(no visits)\n")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, visit := range matched {
|
||||||
|
b.WriteString("- ")
|
||||||
|
b.WriteString(historyTimeRangeLabel(visit.Start, visit.End, visit.Current))
|
||||||
|
b.WriteString(" ")
|
||||||
|
b.WriteString(strings.TrimSpace(visit.WorldLabel))
|
||||||
|
if strings.TrimSpace(visit.WorldID) != "" {
|
||||||
|
b.WriteString(" world_id=")
|
||||||
|
b.WriteString(strings.TrimSpace(visit.WorldID))
|
||||||
|
}
|
||||||
|
if strings.TrimSpace(visit.InstanceID) != "" {
|
||||||
|
b.WriteString(" instance_id=")
|
||||||
|
b.WriteString(strings.TrimSpace(visit.InstanceID))
|
||||||
|
}
|
||||||
|
b.WriteString("\n")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func appendExportDayEvents(b *strings.Builder, day time.Time, events []historyEventRecord, q historyQuery) {
|
||||||
|
if b == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
dayStart, dayEnd := historyDayBounds(day)
|
||||||
|
matched := make([]historyEventRecord, 0, len(events))
|
||||||
|
for _, ev := range events {
|
||||||
|
if ev.At.IsZero() || ev.At.Before(dayStart) || !ev.At.Before(dayEnd) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
raw := fmt.Sprintf("[%s] %s %s", ev.At.Format("15:04"), ev.Kind, ev.Name)
|
||||||
|
if q.Pattern != nil && !q.Pattern.MatchString(ev.Name) && !q.Pattern.MatchString(raw) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
matched = append(matched, ev)
|
||||||
|
}
|
||||||
|
sort.SliceStable(matched, func(i, j int) bool {
|
||||||
|
if matched[i].At.Equal(matched[j].At) {
|
||||||
|
return strings.ToLower(matched[i].Name) < strings.ToLower(matched[j].Name)
|
||||||
|
}
|
||||||
|
return matched[i].At.Before(matched[j].At)
|
||||||
|
})
|
||||||
|
b.WriteString("\nAll join/leave events:\n")
|
||||||
|
if len(matched) == 0 {
|
||||||
|
b.WriteString("(no events)\n")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, ev := range matched {
|
||||||
|
b.WriteString("- ")
|
||||||
|
b.WriteString(ev.At.Format("15:04"))
|
||||||
|
b.WriteString(" ")
|
||||||
|
b.WriteString(ev.Kind)
|
||||||
|
b.WriteString(" ")
|
||||||
|
b.WriteString(strings.TrimSpace(ev.Name))
|
||||||
|
if ev.Raw != "" {
|
||||||
|
b.WriteString(" | ")
|
||||||
|
b.WriteString(strings.TrimSpace(ev.Raw))
|
||||||
|
}
|
||||||
|
b.WriteString("\n")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func appendExportGuestSnapshot(b *strings.Builder, day time.Time, q historyQuery) {
|
||||||
|
if b == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
guests := readGuestSnapshot()
|
||||||
|
dayStart, dayEnd := historyDayBounds(day)
|
||||||
|
type guestLine struct {
|
||||||
|
name string
|
||||||
|
present bool
|
||||||
|
join time.Time
|
||||||
|
leave time.Time
|
||||||
|
}
|
||||||
|
lines := make([]guestLine, 0, len(guests))
|
||||||
|
for _, guest := range guests {
|
||||||
|
name := strings.TrimSpace(guest.Name)
|
||||||
|
if name == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
inDay := guest.Present ||
|
||||||
|
(!guest.LastJoin.IsZero() && !guest.LastJoin.Before(dayStart) && guest.LastJoin.Before(dayEnd)) ||
|
||||||
|
(!guest.LastLeave.IsZero() && !guest.LastLeave.Before(dayStart) && guest.LastLeave.Before(dayEnd))
|
||||||
|
if !inDay {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if q.Pattern != nil && !q.Pattern.MatchString(name) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
lines = append(lines, guestLine{name: name, present: guest.Present, join: guest.LastJoin, leave: guest.LastLeave})
|
||||||
|
}
|
||||||
|
sort.SliceStable(lines, func(i, j int) bool {
|
||||||
|
return strings.ToLower(lines[i].name) < strings.ToLower(lines[j].name)
|
||||||
|
})
|
||||||
|
b.WriteString("\nGuest snapshot:\n")
|
||||||
|
if len(lines) == 0 {
|
||||||
|
b.WriteString("(no guests)\n")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, line := range lines {
|
||||||
|
b.WriteString("- ")
|
||||||
|
if line.present {
|
||||||
|
b.WriteString("present ")
|
||||||
|
} else {
|
||||||
|
b.WriteString("left ")
|
||||||
|
}
|
||||||
|
b.WriteString(line.name)
|
||||||
|
if !line.join.IsZero() {
|
||||||
|
b.WriteString(" join=")
|
||||||
|
b.WriteString(line.join.Format("15:04"))
|
||||||
|
}
|
||||||
|
if !line.leave.IsZero() {
|
||||||
|
b.WriteString(" leave=")
|
||||||
|
b.WriteString(line.leave.Format("15:04"))
|
||||||
|
}
|
||||||
|
b.WriteString("\n")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func cloneHistorySelection(selected map[string]bool) map[string]bool {
|
func cloneHistorySelection(selected map[string]bool) map[string]bool {
|
||||||
if len(selected) == 0 {
|
if len(selected) == 0 {
|
||||||
return nil
|
return nil
|
||||||
@@ -757,6 +921,124 @@ func refreshHistoryCache(app *guiApp, force bool) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func startHistoryRefresh(app *guiApp, force bool) bool {
|
||||||
|
if app == nil || app.historyRefreshRunning {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if !force && app.historyCacheLoaded && !app.historyReloadPending {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
ensureHistoryState(app)
|
||||||
|
if app.historyRefreshResultCh == nil {
|
||||||
|
app.historyRefreshResultCh = make(chan historyRefreshResult, 1)
|
||||||
|
}
|
||||||
|
work := *app
|
||||||
|
work.historySelectedKeys = cloneHistorySelection(app.historySelectedKeys)
|
||||||
|
work.historyRefreshResultCh = nil
|
||||||
|
work.historyExportResultCh = nil
|
||||||
|
app.historyRefreshRunning = true
|
||||||
|
app.historyReloadPending = true
|
||||||
|
if strings.TrimSpace(app.historyStatus) == "" {
|
||||||
|
app.historyStatus = "reloading..."
|
||||||
|
}
|
||||||
|
hwnd := app.hwnd
|
||||||
|
go func(ch chan<- historyRefreshResult, work guiApp, hwnd uintptr) {
|
||||||
|
start := time.Now()
|
||||||
|
result := historyRefreshResult{
|
||||||
|
SelectedDate: work.historySelectedDate,
|
||||||
|
Month: work.historyMonth,
|
||||||
|
SelectedKeys: cloneHistorySelection(work.historySelectedKeys),
|
||||||
|
Regex: work.historyRegex,
|
||||||
|
FromDate: work.historyFromDate,
|
||||||
|
ToDate: work.historyToDate,
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
result.Elapsed = time.Since(start)
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
result.Err = fmt.Errorf("refresh panic: %v", r)
|
||||||
|
}
|
||||||
|
select {
|
||||||
|
case ch <- result:
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
if postMessageProc != nil && hwnd != 0 {
|
||||||
|
postMessageProc.Call(hwnd, uintptr(wmHistoryRefreshDone), 0, 0)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
refreshHistoryCache(&work, true)
|
||||||
|
result.Rows = append([]guiWorldVisitRow(nil), work.historyRows...)
|
||||||
|
result.CalendarCells = append([]historyCalendarCell(nil), work.historyCalendarCells...)
|
||||||
|
result.DetailRows = cloneHistoryDetailRows(work.historyDetailRows)
|
||||||
|
result.DetailHeightPx = work.historyDetailContentHeightPx
|
||||||
|
result.SelectedDate = work.historySelectedDate
|
||||||
|
result.Month = work.historyMonth
|
||||||
|
result.SelectedKeys = cloneHistorySelection(work.historySelectedKeys)
|
||||||
|
result.Status = work.historyStatus
|
||||||
|
}(app.historyRefreshResultCh, work, hwnd)
|
||||||
|
guiLog("history refresh start")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func drainHistoryRefreshResult(app *guiApp) bool {
|
||||||
|
if app == nil || app.historyRefreshResultCh == nil || !app.historyRefreshRunning {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
handled := false
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case res := <-app.historyRefreshResultCh:
|
||||||
|
handled = true
|
||||||
|
app.historyRefreshRunning = false
|
||||||
|
if res.Err != nil {
|
||||||
|
app.historyStatus = "reload failed: " + res.Err.Error()
|
||||||
|
app.historyReloadPending = true
|
||||||
|
guiLog(fmt.Sprintf("history refresh failed elapsed=%s err=%v", res.Elapsed, res.Err))
|
||||||
|
invalidateHistoryPanes(app)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
stale := !sameDay(app.historySelectedDate, res.SelectedDate) ||
|
||||||
|
!sameHistoryMonth(app.historyMonth, res.Month) ||
|
||||||
|
app.historyRegex != res.Regex ||
|
||||||
|
app.historyFromDate != res.FromDate ||
|
||||||
|
app.historyToDate != res.ToDate
|
||||||
|
if stale {
|
||||||
|
app.historyReloadPending = true
|
||||||
|
guiLog("history refresh stale; scheduling another refresh")
|
||||||
|
invalidateHistoryPanes(app)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
app.historyRows = res.Rows
|
||||||
|
app.historyCalendarCells = res.CalendarCells
|
||||||
|
app.historyDetailRows = res.DetailRows
|
||||||
|
app.historyDetailContentHeightPx = res.DetailHeightPx
|
||||||
|
app.historySelectedDate = res.SelectedDate
|
||||||
|
app.historyMonth = res.Month
|
||||||
|
app.historySelectedKeys = res.SelectedKeys
|
||||||
|
if app.historySelectedKeys == nil {
|
||||||
|
app.historySelectedKeys = map[string]bool{}
|
||||||
|
}
|
||||||
|
app.historyReloadPending = false
|
||||||
|
app.historyCacheLoaded = true
|
||||||
|
if strings.TrimSpace(res.Status) != "" {
|
||||||
|
app.historyStatus = res.Status
|
||||||
|
} else {
|
||||||
|
app.historyStatus = "reloaded: " + time.Now().Format("15:04:05")
|
||||||
|
}
|
||||||
|
guiLog(fmt.Sprintf("history refresh ok elapsed=%s rows=%d details=%d", res.Elapsed, len(res.Rows), len(res.DetailRows)))
|
||||||
|
invalidateHistoryPanes(app)
|
||||||
|
default:
|
||||||
|
return handled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func sameHistoryMonth(a, b time.Time) bool {
|
||||||
|
if a.IsZero() || b.IsZero() {
|
||||||
|
return a.IsZero() && b.IsZero()
|
||||||
|
}
|
||||||
|
return a.Year() == b.Year() && a.Month() == b.Month()
|
||||||
|
}
|
||||||
|
|
||||||
func requestHistoryRefresh(app *guiApp, reason string) {
|
func requestHistoryRefresh(app *guiApp, reason string) {
|
||||||
if app == nil {
|
if app == nil {
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ func normalizeInitialTab(tab string) string {
|
|||||||
switch strings.ToLower(strings.TrimSpace(tab)) {
|
switch strings.ToLower(strings.TrimSpace(tab)) {
|
||||||
case "join", "log", "logs":
|
case "join", "log", "logs":
|
||||||
return "join"
|
return "join"
|
||||||
|
case "history", "hist":
|
||||||
|
return "history"
|
||||||
case "translate", "translation":
|
case "translate", "translation":
|
||||||
return "join"
|
return "join"
|
||||||
case "settings", "setting", "config":
|
case "settings", "setting", "config":
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"runtime"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -52,6 +53,7 @@ const (
|
|||||||
wmCommandGUI = 0x0111
|
wmCommandGUI = 0x0111
|
||||||
wmSetFont = 0x0030
|
wmSetFont = 0x0030
|
||||||
wmHistoryExportDone = 0x0401
|
wmHistoryExportDone = 0x0401
|
||||||
|
wmHistoryRefreshDone = 0x0402
|
||||||
enChange = 0x0300
|
enChange = 0x0300
|
||||||
enKillFocus = 0x0200
|
enKillFocus = 0x0200
|
||||||
bnClicked = 0x0000
|
bnClicked = 0x0000
|
||||||
@@ -119,6 +121,12 @@ const (
|
|||||||
|
|
||||||
const translateTabEnabled = false
|
const translateTabEnabled = false
|
||||||
|
|
||||||
|
const (
|
||||||
|
defaultGUIFontSize = 14
|
||||||
|
minGUIFontSize = 8
|
||||||
|
maxGUIFontSize = 30
|
||||||
|
)
|
||||||
|
|
||||||
var joinLeaveLinePattern = regexp.MustCompile(`^\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\]\s+\[(join|leave)\]\s+(.+?)\s+\((\d+)\)$`)
|
var joinLeaveLinePattern = regexp.MustCompile(`^\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\]\s+\[(join|leave)\]\s+(.+?)\s+\((\d+)\)$`)
|
||||||
var runtimeTimePattern = regexp.MustCompile(`^\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\]`)
|
var runtimeTimePattern = regexp.MustCompile(`^\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\]`)
|
||||||
var worldIdPattern = regexp.MustCompile(`worldId=(wrld_[0-9a-fA-F-]+)`)
|
var worldIdPattern = regexp.MustCompile(`worldId=(wrld_[0-9a-fA-F-]+)`)
|
||||||
@@ -138,6 +146,7 @@ var hwndNoZOrder uintptr = 0x0004
|
|||||||
var hwndNoSize uintptr = 0x0001
|
var hwndNoSize uintptr = 0x0001
|
||||||
var hwndNoActivate uintptr = 0x0010
|
var hwndNoActivate uintptr = 0x0010
|
||||||
var hwndShowWindow uintptr = 0x0040
|
var hwndShowWindow uintptr = 0x0040
|
||||||
|
var swMinimize uintptr = 6
|
||||||
var swRestore uintptr = 9
|
var swRestore uintptr = 9
|
||||||
var swHideControl uintptr = 0
|
var swHideControl uintptr = 0
|
||||||
var swShowControl uintptr = 5
|
var swShowControl uintptr = 5
|
||||||
@@ -251,6 +260,8 @@ type guiApp struct {
|
|||||||
historyReloadRect winRect
|
historyReloadRect winRect
|
||||||
historyExportRect winRect
|
historyExportRect winRect
|
||||||
historyReloadPending bool
|
historyReloadPending bool
|
||||||
|
historyRefreshRunning bool
|
||||||
|
historyRefreshResultCh chan historyRefreshResult
|
||||||
historyCacheLoaded bool
|
historyCacheLoaded bool
|
||||||
historyDetailContentHeightPx int32
|
historyDetailContentHeightPx int32
|
||||||
settingsExportDirEdit uintptr
|
settingsExportDirEdit uintptr
|
||||||
@@ -325,6 +336,9 @@ func guiLog(text string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runNativeGUI(initialTab string) error {
|
func runNativeGUI(initialTab string) error {
|
||||||
|
runtime.LockOSThread()
|
||||||
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
user32 := syscall.NewLazyDLL("user32.dll")
|
user32 := syscall.NewLazyDLL("user32.dll")
|
||||||
kernel32 := syscall.NewLazyDLL("kernel32.dll")
|
kernel32 := syscall.NewLazyDLL("kernel32.dll")
|
||||||
gdi32 := syscall.NewLazyDLL("gdi32.dll")
|
gdi32 := syscall.NewLazyDLL("gdi32.dll")
|
||||||
@@ -442,7 +456,7 @@ func runNativeGUI(initialTab string) error {
|
|||||||
if guiCfg.FontSize > 0 {
|
if guiCfg.FontSize > 0 {
|
||||||
app.fontSize = guiCfg.FontSize
|
app.fontSize = guiCfg.FontSize
|
||||||
} else {
|
} else {
|
||||||
app.fontSize = 18
|
app.fontSize = defaultGUIFontSize
|
||||||
}
|
}
|
||||||
app.refreshIntervalValue = guiCfg.RefreshIntervalValue
|
app.refreshIntervalValue = guiCfg.RefreshIntervalValue
|
||||||
if app.refreshIntervalValue <= 0 {
|
if app.refreshIntervalValue <= 0 {
|
||||||
@@ -466,7 +480,6 @@ func runNativeGUI(initialTab string) error {
|
|||||||
app.historyExportCustom = strings.TrimSpace(guiCfg.HistoryExportCustom)
|
app.historyExportCustom = strings.TrimSpace(guiCfg.HistoryExportCustom)
|
||||||
app.historyReloadPending = true
|
app.historyReloadPending = true
|
||||||
app.hFont = createAppFont(app.fontSize)
|
app.hFont = createAppFont(app.fontSize)
|
||||||
refreshHistoryCache(&app, true)
|
|
||||||
paneWndProc := syscall.NewCallback(func(hwnd uintptr, message uint32, wParam, lParam uintptr) uintptr {
|
paneWndProc := syscall.NewCallback(func(hwnd uintptr, message uint32, wParam, lParam uintptr) uintptr {
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
@@ -742,8 +755,11 @@ func runNativeGUI(initialTab string) error {
|
|||||||
if !allowRapidSettingsAction(&app) {
|
if !allowRapidSettingsAction(&app) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
if app.fontSize > 10 {
|
if app.fontSize > minGUIFontSize {
|
||||||
app.fontSize -= 2
|
app.fontSize -= 2
|
||||||
|
if app.fontSize < minGUIFontSize {
|
||||||
|
app.fontSize = minGUIFontSize
|
||||||
|
}
|
||||||
oldFont := app.hFont
|
oldFont := app.hFont
|
||||||
app.hFont = createAppFont(app.fontSize)
|
app.hFont = createAppFont(app.fontSize)
|
||||||
applyFont(&app)
|
applyFont(&app)
|
||||||
@@ -757,8 +773,11 @@ func runNativeGUI(initialTab string) error {
|
|||||||
if !allowRapidSettingsAction(&app) {
|
if !allowRapidSettingsAction(&app) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
if app.fontSize < 30 {
|
if app.fontSize < maxGUIFontSize {
|
||||||
app.fontSize += 2
|
app.fontSize += 2
|
||||||
|
if app.fontSize > maxGUIFontSize {
|
||||||
|
app.fontSize = maxGUIFontSize
|
||||||
|
}
|
||||||
oldFont := app.hFont
|
oldFont := app.hFont
|
||||||
app.hFont = createAppFont(app.fontSize)
|
app.hFont = createAppFont(app.fontSize)
|
||||||
applyFont(&app)
|
applyFont(&app)
|
||||||
@@ -788,8 +807,25 @@ func runNativeGUI(initialTab string) error {
|
|||||||
width = rc.Right
|
width = rc.Right
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if x >= width-42 && x <= width-22 && y >= 12 && y <= 32 {
|
switch {
|
||||||
guiLog("close button ignored to keep GUI visible")
|
case pointInHeaderDot(x, y, width-92, 22):
|
||||||
|
guiLog("window control minimize")
|
||||||
|
if showWindowProc != nil {
|
||||||
|
showWindowProc.Call(hwnd, swMinimize)
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
case pointInHeaderDot(x, y, width-62, 22):
|
||||||
|
guiLog("window control topmost toggle")
|
||||||
|
app.topMost = !app.topMost
|
||||||
|
saveGUISettings(&app)
|
||||||
|
applyTopMost(hwnd, &app)
|
||||||
|
if invalidateRectProc != nil {
|
||||||
|
invalidateRectProc.Call(hwnd, 0, 1)
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
case pointInHeaderDot(x, y, width-32, 22):
|
||||||
|
guiLog("window control close")
|
||||||
|
postQuitMessage.Call(0)
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
releaseCapture.Call()
|
releaseCapture.Call()
|
||||||
@@ -851,17 +887,31 @@ func runNativeGUI(initialTab string) error {
|
|||||||
}
|
}
|
||||||
case wmTimerGUI:
|
case wmTimerGUI:
|
||||||
drainHistoryExportResult(&app)
|
drainHistoryExportResult(&app)
|
||||||
|
drainHistoryRefreshResult(&app)
|
||||||
reloadData := app.activeTab == "join" || app.activeTab == "translate"
|
reloadData := app.activeTab == "join" || app.activeTab == "translate"
|
||||||
if app.activeTab == "history" && app.historyReloadPending {
|
if app.activeTab == "history" && app.historyReloadPending {
|
||||||
if refreshHistoryCache(&app, true) {
|
startHistoryRefresh(&app, true)
|
||||||
refreshGUI(setWindowText, &app, false)
|
refreshGUI(setWindowText, &app, false)
|
||||||
}
|
|
||||||
refreshSettingsControls(showWindowProc, setWindowPosProc, &app)
|
refreshSettingsControls(showWindowProc, setWindowPosProc, &app)
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
refreshGUI(setWindowText, &app, reloadData)
|
refreshGUI(setWindowText, &app, reloadData)
|
||||||
refreshSettingsControls(showWindowProc, setWindowPosProc, &app)
|
refreshSettingsControls(showWindowProc, setWindowPosProc, &app)
|
||||||
return 0
|
return 0
|
||||||
|
case wmHistoryRefreshDone:
|
||||||
|
drainHistoryRefreshResult(&app)
|
||||||
|
if invalidateRectProc != nil {
|
||||||
|
if app.leftHwnd != 0 {
|
||||||
|
invalidateRectProc.Call(app.leftHwnd, 0, 1)
|
||||||
|
}
|
||||||
|
if app.rightHwnd != 0 {
|
||||||
|
invalidateRectProc.Call(app.rightHwnd, 0, 1)
|
||||||
|
}
|
||||||
|
if app.hwnd != 0 {
|
||||||
|
invalidateRectProc.Call(app.hwnd, 0, 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0
|
||||||
case wmHistoryExportDone:
|
case wmHistoryExportDone:
|
||||||
drainHistoryExportResult(&app)
|
drainHistoryExportResult(&app)
|
||||||
if invalidateRectProc != nil {
|
if invalidateRectProc != nil {
|
||||||
@@ -878,7 +928,8 @@ func runNativeGUI(initialTab string) error {
|
|||||||
postQuitMessage.Call(0)
|
postQuitMessage.Call(0)
|
||||||
return 0
|
return 0
|
||||||
case wmCloseGUI:
|
case wmCloseGUI:
|
||||||
guiLog("wmClose ignored to keep GUI visible")
|
guiLog("wmClose received")
|
||||||
|
postQuitMessage.Call(0)
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
ret, _, _ := defWindowProc.Call(hwnd, uintptr(message), wParam, lParam)
|
ret, _, _ := defWindowProc.Call(hwnd, uintptr(message), wParam, lParam)
|
||||||
@@ -974,6 +1025,10 @@ func refreshGUI(setWindowText *syscall.LazyProc, app *guiApp, reloadData bool) {
|
|||||||
if app == nil {
|
if app == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if app.activeTab == "history" && !reloadData {
|
||||||
|
syncPaneVisibility(app)
|
||||||
|
return
|
||||||
|
}
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
defer func() {
|
defer func() {
|
||||||
if d := time.Since(start); d > 100*time.Millisecond {
|
if d := time.Since(start); d > 100*time.Millisecond {
|
||||||
@@ -984,11 +1039,7 @@ func refreshGUI(setWindowText *syscall.LazyProc, app *guiApp, reloadData bool) {
|
|||||||
instanceCount := app.currentUserCount
|
instanceCount := app.currentUserCount
|
||||||
worldLabel := app.currentWorld
|
worldLabel := app.currentWorld
|
||||||
state := readRuntimeSnapshot()
|
state := readRuntimeSnapshot()
|
||||||
historyDirty := false
|
historyDirty := app.activeTab == "history" && app.historyReloadPending
|
||||||
historyNeedsRefresh := app.activeTab == "history" && (app.historyReloadPending || !app.historyCacheLoaded)
|
|
||||||
if historyNeedsRefresh {
|
|
||||||
historyDirty = refreshHistoryCache(app, false)
|
|
||||||
}
|
|
||||||
if reloadData {
|
if reloadData {
|
||||||
if app.activeTab == "translate" {
|
if app.activeTab == "translate" {
|
||||||
guiLog("refreshGUI activeTab=translate light refresh")
|
guiLog("refreshGUI activeTab=translate light refresh")
|
||||||
@@ -1394,7 +1445,7 @@ func applyJoinLogFont(app *guiApp, presentCount int) {
|
|||||||
size = app.fontSize
|
size = app.fontSize
|
||||||
}
|
}
|
||||||
if size <= 0 {
|
if size <= 0 {
|
||||||
size = 18
|
size = defaultGUIFontSize
|
||||||
}
|
}
|
||||||
if app.joinHFont != 0 && app.joinBoldHFont != 0 && app.joinHeadlineHFont != 0 &&
|
if app.joinHFont != 0 && app.joinBoldHFont != 0 && app.joinHeadlineHFont != 0 &&
|
||||||
app.joinFontSize == size && app.joinBoldFontSize == size && app.joinHeadlineSize == size+2 {
|
app.joinFontSize == size && app.joinBoldFontSize == size && app.joinHeadlineSize == size+2 {
|
||||||
@@ -1469,7 +1520,7 @@ func applyJoinLogFontSize(app *guiApp, size int) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if size <= 0 {
|
if size <= 0 {
|
||||||
size = 18
|
size = defaultGUIFontSize
|
||||||
}
|
}
|
||||||
if app.joinHFont != 0 && app.joinBoldHFont != 0 && app.joinFontSize == size && app.joinBoldFontSize == size {
|
if app.joinHFont != 0 && app.joinBoldHFont != 0 && app.joinFontSize == size && app.joinBoldFontSize == size {
|
||||||
return
|
return
|
||||||
@@ -1499,7 +1550,7 @@ func applyJoinLogFontSize(app *guiApp, size int) {
|
|||||||
func fitJoinLogFontSize(baseSize, lineCount, availableHeight int) int {
|
func fitJoinLogFontSize(baseSize, lineCount, availableHeight int) int {
|
||||||
size := baseSize
|
size := baseSize
|
||||||
if size <= 0 {
|
if size <= 0 {
|
||||||
size = 18
|
size = defaultGUIFontSize
|
||||||
}
|
}
|
||||||
if lineCount <= 0 {
|
if lineCount <= 0 {
|
||||||
lineCount = 1
|
lineCount = 1
|
||||||
@@ -1507,14 +1558,14 @@ func fitJoinLogFontSize(baseSize, lineCount, availableHeight int) int {
|
|||||||
if availableHeight <= 0 {
|
if availableHeight <= 0 {
|
||||||
availableHeight = 300
|
availableHeight = 300
|
||||||
}
|
}
|
||||||
for size > 8 {
|
for size > minGUIFontSize {
|
||||||
if joinPaneContentHeight(size, lineCount) <= availableHeight {
|
if joinPaneContentHeight(size, lineCount) <= availableHeight {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
size -= 2
|
size -= 2
|
||||||
}
|
}
|
||||||
if size < 8 {
|
if size < minGUIFontSize {
|
||||||
size = 8
|
size = minGUIFontSize
|
||||||
}
|
}
|
||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
@@ -1712,6 +1763,10 @@ func paintMainWindow(hwnd uintptr, app *guiApp) uintptr {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func pointInHeaderDot(x, y, cx, cy int32) bool {
|
||||||
|
return x >= cx-11 && x <= cx+11 && y >= cy-11 && y <= cy+11
|
||||||
|
}
|
||||||
|
|
||||||
func paintFooter(hdc uintptr, rc winRect, app *guiApp) {
|
func paintFooter(hdc uintptr, rc winRect, app *guiApp) {
|
||||||
if app == nil {
|
if app == nil {
|
||||||
return
|
return
|
||||||
@@ -1929,15 +1984,21 @@ func handleSettingsPaneClick(app *guiApp, x, y int32, getWindowText, setWindowTe
|
|||||||
applyRefreshTimer(app.hwnd, app)
|
applyRefreshTimer(app.hwnd, app)
|
||||||
}
|
}
|
||||||
case pointInRect(x, y, settingsFontDownRect()):
|
case pointInRect(x, y, settingsFontDownRect()):
|
||||||
if app.fontSize > 10 {
|
if app.fontSize > minGUIFontSize {
|
||||||
app.fontSize -= 2
|
app.fontSize -= 2
|
||||||
|
if app.fontSize < minGUIFontSize {
|
||||||
|
app.fontSize = minGUIFontSize
|
||||||
|
}
|
||||||
app.hFont = createAppFont(app.fontSize)
|
app.hFont = createAppFont(app.fontSize)
|
||||||
applyFont(app)
|
applyFont(app)
|
||||||
saveGUISettings(app)
|
saveGUISettings(app)
|
||||||
}
|
}
|
||||||
case pointInRect(x, y, settingsFontUpRect()):
|
case pointInRect(x, y, settingsFontUpRect()):
|
||||||
if app.fontSize < 30 {
|
if app.fontSize < maxGUIFontSize {
|
||||||
app.fontSize += 2
|
app.fontSize += 2
|
||||||
|
if app.fontSize > maxGUIFontSize {
|
||||||
|
app.fontSize = maxGUIFontSize
|
||||||
|
}
|
||||||
app.hFont = createAppFont(app.fontSize)
|
app.hFont = createAppFont(app.fontSize)
|
||||||
applyFont(app)
|
applyFont(app)
|
||||||
saveGUISettings(app)
|
saveGUISettings(app)
|
||||||
@@ -3267,7 +3328,7 @@ func formatDurationShort(d time.Duration) string {
|
|||||||
func joinLogFontSize(baseSize, presentCount int) int {
|
func joinLogFontSize(baseSize, presentCount int) int {
|
||||||
size := baseSize
|
size := baseSize
|
||||||
if size <= 0 {
|
if size <= 0 {
|
||||||
size = 18
|
size = defaultGUIFontSize
|
||||||
}
|
}
|
||||||
if presentCount <= 32 {
|
if presentCount <= 32 {
|
||||||
return size
|
return size
|
||||||
@@ -3280,8 +3341,8 @@ func joinLogFontSize(baseSize, presentCount int) int {
|
|||||||
case presentCount >= 33:
|
case presentCount >= 33:
|
||||||
size -= 2
|
size -= 2
|
||||||
}
|
}
|
||||||
if size < 8 {
|
if size < minGUIFontSize {
|
||||||
size = 8
|
size = minGUIFontSize
|
||||||
}
|
}
|
||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
@@ -3736,7 +3797,7 @@ func loadGUISettings() config.GUIConfig {
|
|||||||
if err != nil || cfg == nil {
|
if err != nil || cfg == nil {
|
||||||
return config.GUIConfig{
|
return config.GUIConfig{
|
||||||
TopMost: false,
|
TopMost: false,
|
||||||
FontSize: 18,
|
FontSize: defaultGUIFontSize,
|
||||||
RefreshIntervalValue: 2,
|
RefreshIntervalValue: 2,
|
||||||
RefreshIntervalUnit: "sec",
|
RefreshIntervalUnit: "sec",
|
||||||
HistoryExportIncludeTime: true,
|
HistoryExportIncludeTime: true,
|
||||||
@@ -3745,7 +3806,7 @@ func loadGUISettings() config.GUIConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if cfg.GUI.FontSize <= 0 {
|
if cfg.GUI.FontSize <= 0 {
|
||||||
cfg.GUI.FontSize = 18
|
cfg.GUI.FontSize = defaultGUIFontSize
|
||||||
}
|
}
|
||||||
cfg.GUI.RefreshIntervalValue, cfg.GUI.RefreshIntervalUnit = normalizeRefreshIntervalSettings(cfg.GUI.RefreshIntervalValue, cfg.GUI.RefreshIntervalUnit)
|
cfg.GUI.RefreshIntervalValue, cfg.GUI.RefreshIntervalUnit = normalizeRefreshIntervalSettings(cfg.GUI.RefreshIntervalValue, cfg.GUI.RefreshIntervalUnit)
|
||||||
cfg.GUI.HistoryRegex = strings.TrimSpace(cfg.GUI.HistoryRegex)
|
cfg.GUI.HistoryRegex = strings.TrimSpace(cfg.GUI.HistoryRegex)
|
||||||
@@ -4096,7 +4157,7 @@ func formatRightPane(tab string, state map[string]any, worldLabel string, curren
|
|||||||
b.WriteString("\r\nFont size: ")
|
b.WriteString("\r\nFont size: ")
|
||||||
fontSize, _ := state["font_size"].(int)
|
fontSize, _ := state["font_size"].(int)
|
||||||
if fontSize == 0 {
|
if fontSize == 0 {
|
||||||
fontSize = 18
|
fontSize = defaultGUIFontSize
|
||||||
}
|
}
|
||||||
b.WriteString(strconv.Itoa(fontSize))
|
b.WriteString(strconv.Itoa(fontSize))
|
||||||
b.WriteString("\r\nLeave unmute: ")
|
b.WriteString("\r\nLeave unmute: ")
|
||||||
@@ -4134,7 +4195,7 @@ func formatSettingsPane(state map[string]any) string {
|
|||||||
b.WriteString("\r\nFont size: ")
|
b.WriteString("\r\nFont size: ")
|
||||||
fontSize, _ := state["font_size"].(int)
|
fontSize, _ := state["font_size"].(int)
|
||||||
if fontSize == 0 {
|
if fontSize == 0 {
|
||||||
fontSize = 18
|
fontSize = defaultGUIFontSize
|
||||||
}
|
}
|
||||||
b.WriteString(strconv.Itoa(fontSize))
|
b.WriteString(strconv.Itoa(fontSize))
|
||||||
b.WriteString("\r\nLeave unmute: ")
|
b.WriteString("\r\nLeave unmute: ")
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ func Load(path string) (*Config, error) {
|
|||||||
cfg := &Config{
|
cfg := &Config{
|
||||||
OSC: OSCConfig{Host: "127.0.0.1", Port: 9001},
|
OSC: OSCConfig{Host: "127.0.0.1", Port: 9001},
|
||||||
GUI: GUIConfig{
|
GUI: GUIConfig{
|
||||||
FontSize: 18,
|
FontSize: 14,
|
||||||
RefreshIntervalValue: 2,
|
RefreshIntervalValue: 2,
|
||||||
RefreshIntervalUnit: "sec",
|
RefreshIntervalUnit: "sec",
|
||||||
HistoryExportIncludeTime: true,
|
HistoryExportIncludeTime: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user