2024-03-25 12:12:08 +01:00
|
|
|
/*
|
|
|
|
|
Copyright © 2024 Thomas von Dein
|
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"log"
|
|
|
|
|
"os"
|
|
|
|
|
|
|
|
|
|
"log/slog"
|
|
|
|
|
|
|
|
|
|
"github.com/hajimehoshi/ebiten/v2"
|
|
|
|
|
"github.com/tlinden/yadu"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
// parse config file and command line parameters, if any
|
|
|
|
|
conf, err := InitConfig()
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if conf.Showversion {
|
2024-03-26 18:22:48 +01:00
|
|
|
fmt.Printf("This is kageviewer version %s\n", VERSION)
|
2024-03-25 12:12:08 +01:00
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// enable debugging, if needed. We only use log/slog for
|
|
|
|
|
// debugging, so there's no need to configure it outside debugging
|
|
|
|
|
if conf.Debug {
|
|
|
|
|
logLevel := &slog.LevelVar{}
|
|
|
|
|
// we're using a more verbose logger in debug mode
|
|
|
|
|
opts := &yadu.Options{
|
|
|
|
|
Level: logLevel,
|
|
|
|
|
AddSource: true,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
logLevel.Set(slog.LevelDebug)
|
|
|
|
|
|
|
|
|
|
handler := yadu.NewHandler(os.Stdout, opts)
|
2024-03-25 18:03:02 +01:00
|
|
|
debuglogger := slog.New(handler)
|
2024-03-25 12:12:08 +01:00
|
|
|
slog.SetDefault(debuglogger)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
game := &Game{Conf: conf}
|
|
|
|
|
if err := game.Init(); err != nil {
|
|
|
|
|
log.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ebiten.SetWindowSize(game.Conf.Width, game.Conf.Height)
|
|
|
|
|
ebiten.SetWindowTitle("Kage shader viewer")
|
|
|
|
|
ebiten.SetWindowResizable(true)
|
|
|
|
|
|
|
|
|
|
if err := ebiten.RunGame(game); err != nil {
|
|
|
|
|
log.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|