Allow smaller GUI font sizes
All checks were successful
build-windows-exe / build (push) Successful in 1m31s

This commit is contained in:
messypy
2026-07-27 23:57:57 +09:00
parent 452c7c59b6
commit f9968895ac
2 changed files with 37 additions and 19 deletions

View File

@@ -121,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-]+)`)
@@ -450,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 {
@@ -749,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)
@@ -764,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)
@@ -1433,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 {
@@ -1508,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
@@ -1538,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
@@ -1546,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
} }
@@ -1972,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)
@@ -3310,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
@@ -3323,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
} }
@@ -3779,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,
@@ -3788,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)
@@ -4139,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: ")
@@ -4177,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: ")

View File

@@ -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,