This repository has been archived by the owner on Nov 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
69 lines (60 loc) · 1.46 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package main
import (
"errors"
"fmt"
"log"
"os"
"path/filepath"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/dialog"
"github.com/achhabra2/kqb-json-viewer/icons"
"github.com/achhabra2/kqb-json-viewer/stats"
)
func main() {
setupLogs()
os.Setenv("FYNE_SCALE", "0.9")
mainIcon := fyne.NewStaticResource("logo.png", icons.Logo)
a := app.NewWithID("com.kqb-json-viewer.app")
a.SetIcon(mainIcon)
appTheme := myTheme{}
a.Settings().SetTheme(&appTheme)
w := a.NewWindow("KQB JSON Viewer")
names := stats.ListStatFiles()
if len(names) == 0 {
err := errors.New("No Stat Files Available to Read")
log.Println("No Stat Files Available to Read")
dialog := dialog.NewError(err, w)
dialog.SetOnClosed(func() { os.Exit(1) })
dialog.Show()
w.Resize(fyne.NewSize(500, 850))
w.CenterOnScreen()
w.ShowAndRun()
}
data, err := stats.ReadJson(names[0])
if err != nil {
dialog := dialog.NewError(err, w)
dialog.SetOnClosed(func() { os.Exit(1) })
dialog.Show()
w.Resize(fyne.NewSize(500, 850))
w.CenterOnScreen()
w.ShowAndRun()
} else {
basePath, _ := filepath.Split(names[0])
kqbApp := KQBApp{
files: names,
selectedData: data,
a: a,
w: w,
basePath: basePath,
}
kqbApp.ShowMainWindow()
}
}
func setupLogs() {
f, err := os.OpenFile("./kqb-json-viewer-output.log", os.O_APPEND|os.O_CREATE|os.O_RDWR, 0666)
if err != nil {
fmt.Printf("error opening file: %v", err)
}
log.SetOutput(f)
}