-
Notifications
You must be signed in to change notification settings - Fork 95
/
AniYa.go
81 lines (75 loc) · 2.02 KB
/
AniYa.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
70
71
72
73
74
75
76
77
78
79
80
81
package main
import (
"AniYa/core"
"AniYa/themes"
_ "embed"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/cmd/fyne_settings/settings"
"fyne.io/fyne/v2/dialog"
"github.com/flopp/go-findfont"
"os"
"strings"
)
const preferenceCurrentTutorial = "currentTutorial"
const Version = "1.2.0"
var topWindow fyne.Window
//设置中文
func init() {
//os.RemoveAll(core.TEMP_DIR)
fontPaths := findfont.List()
for _, path := range fontPaths {
// 微软雅黑-常规
//println(path)
if strings.Contains(path, "msyh.ttc") {
//println(path)
os.Setenv("FYNE_FONT", path)
println(os.Getenv("FYNE_FONT"))
println("设置中文成功")
break
//兼容win7中文
} else if strings.Contains(path, "msyh.ttf") {
os.Setenv("FYNE_FONT", path)
println(os.Getenv("FYNE_FONT"))
println("设置中文成功")
break
}
}
//println("设置中文失败")
}
func main() {
defer os.Unsetenv("FYNE_FONT")
//退出时
defer os.RemoveAll(core.TempDir)
a := app.NewWithID("io.fyne.demo")
a.SetIcon(themes.Resource2Png)
//a.SetIcon(theme.FyneLogo())
//a := app.New() //新建一个应用
w := a.NewWindow("AniYa") //新建一个窗口
settingsItem := fyne.NewMenuItem("Settings", func() {
w := a.NewWindow("Fyne Settings")
w.SetContent(settings.NewSettings().LoadAppearanceScreen(w))
w.Resize(fyne.NewSize(480, 480))
w.Show()
})
version := fyne.NewMenuItem("VERSION", func() {
v1 := dialog.NewInformation("Version", Version, w)
v1.Show()
})
author := fyne.NewMenuItem("Author", func() {
//author := a.NewWindow("piiperxyz")
v2 := dialog.NewInformation("Author", "piiperxyz\nhttps://github.com/piiperxyz/AniYa", w)
v2.Show()
})
mainMenu := fyne.NewMainMenu(
fyne.NewMenu("FILE", settingsItem),
fyne.NewMenu("ABOUT", version, author),
)
tmp := themes.BypassAV(w)
w.SetContent(tmp)
w.SetMainMenu(mainMenu)
w.SetMaster()
w.Resize(fyne.NewSize(800, 700))
w.ShowAndRun() //显示窗口并运行,后续的窗口只能用show
w.Show() //显示窗口并运行,后续的窗口只能用show
}