2019-10-24 09:31:59 -04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-11-02 16:15:16 -04:00
|
|
|
"image"
|
2019-10-24 09:31:59 -04:00
|
|
|
"log"
|
|
|
|
|
2019-11-02 16:15:16 -04:00
|
|
|
"github.com/hajimehoshi/ebiten/ebitenutil"
|
|
|
|
|
|
|
|
"github.com/essial/OpenDiablo2/Common"
|
|
|
|
|
2019-10-27 17:24:21 -04:00
|
|
|
"github.com/essial/OpenDiablo2/Core"
|
2019-10-25 19:37:04 -04:00
|
|
|
"github.com/essial/OpenDiablo2/MPQ"
|
2019-10-24 09:31:59 -04:00
|
|
|
"github.com/hajimehoshi/ebiten"
|
|
|
|
)
|
|
|
|
|
2019-11-02 16:15:16 -04:00
|
|
|
var GitBranch string
|
|
|
|
var GitCommit string
|
2019-10-26 17:30:00 -04:00
|
|
|
var d2Engine *Core.Engine
|
2019-10-24 09:31:59 -04:00
|
|
|
|
|
|
|
func main() {
|
2019-11-02 16:15:16 -04:00
|
|
|
if len(GitBranch) == 0 {
|
|
|
|
GitBranch = "Local Build"
|
|
|
|
GitCommit = ""
|
|
|
|
}
|
|
|
|
Common.SetBuildInfo(GitBranch, GitCommit)
|
2019-11-02 11:15:02 -04:00
|
|
|
log.SetFlags(log.Ldate | log.LUTC | log.Lmicroseconds | log.Llongfile)
|
2019-10-24 09:31:59 -04:00
|
|
|
log.Println("OpenDiablo2 - Open source Diablo 2 engine")
|
2019-11-02 16:15:16 -04:00
|
|
|
_, iconImage, err := ebitenutil.NewImageFromFile("d2logo.png", ebiten.FilterLinear)
|
|
|
|
if err == nil {
|
|
|
|
ebiten.SetWindowIcon([]image.Image{iconImage})
|
|
|
|
}
|
2019-10-25 19:37:04 -04:00
|
|
|
MPQ.InitializeCryptoBuffer()
|
2019-10-26 17:30:00 -04:00
|
|
|
d2Engine = Core.CreateEngine()
|
2019-10-24 09:31:59 -04:00
|
|
|
ebiten.SetCursorVisible(false)
|
|
|
|
ebiten.SetFullscreen(d2Engine.Settings.FullScreen)
|
|
|
|
ebiten.SetRunnableInBackground(d2Engine.Settings.RunInBackground)
|
|
|
|
ebiten.SetVsyncEnabled(d2Engine.Settings.VsyncEnabled)
|
|
|
|
ebiten.SetMaxTPS(d2Engine.Settings.TicksPerSecond)
|
2019-11-02 16:15:16 -04:00
|
|
|
if err := ebiten.Run(update, 800, 600, d2Engine.Settings.Scale, "OpenDiablo 2 ("+GitBranch+")"); err != nil {
|
2019-10-24 09:31:59 -04:00
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func update(screen *ebiten.Image) error {
|
|
|
|
d2Engine.Update()
|
|
|
|
if ebiten.IsDrawingSkipped() {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
d2Engine.Draw(screen)
|
2019-11-02 11:15:02 -04:00
|
|
|
//ebitenutil.DebugPrint(screen, "FPS:"+strconv.Itoa(int(ebiten.CurrentFPS())))
|
2019-10-24 09:31:59 -04:00
|
|
|
return nil
|
|
|
|
}
|