Add the start of a view for objects in a set
This commit is contained in:
@@ -15,15 +15,13 @@ import (
|
||||
|
||||
"ur.gs/chaos-gate/internal/maps"
|
||||
"ur.gs/chaos-gate/internal/sets"
|
||||
"ur.gs/chaos-gate/internal/ui"
|
||||
)
|
||||
|
||||
var (
|
||||
gamePath = flag.String("game-path", "./orig", "Path to a WH40K: Chaos Gate installation")
|
||||
mapFile = flag.String("map", "", "Prefix path to a .map file, e.g. ./orig/Maps/Chapter01.MAP")
|
||||
txtFile = flag.String("txt", "", "Prefix path to a .txt file, e.g. ./orig/Maps/Chapter01.txt")
|
||||
|
||||
winX = flag.Int("win-x", 1280, "width of the view-map window")
|
||||
winY = flag.Int("win-y", 1024, "height of the view-map window")
|
||||
)
|
||||
|
||||
type env struct {
|
||||
@@ -69,42 +67,32 @@ func main() {
|
||||
env := &env{gameMap: gameMap, set: mapSet}
|
||||
|
||||
// The main thread now belongs to pixelgl
|
||||
pixelgl.Run(func() { run(env) })
|
||||
pixelgl.Run(env.run)
|
||||
}
|
||||
|
||||
func run(env *env) {
|
||||
// WARE! 0,0 is the *bottom left* of the window
|
||||
cfg := pixelgl.WindowConfig{
|
||||
Title: "View Map " + *mapFile,
|
||||
Bounds: pixel.R(0, 0, float64(*winX), float64(*winY)),
|
||||
VSync: true,
|
||||
}
|
||||
|
||||
win, err := pixelgl.NewWindow(cfg)
|
||||
func (e *env) run() {
|
||||
win, err := ui.NewWindow("View Map " + *mapFile)
|
||||
if err != nil {
|
||||
log.Fatal("Couldn't create window: %v", err)
|
||||
}
|
||||
|
||||
pWin := win.PixelWindow
|
||||
state := &runState{
|
||||
env: env,
|
||||
env: e,
|
||||
autoUpdate: true,
|
||||
|
||||
camPos: pixel.V(0, float64(-*winY)),
|
||||
|
||||
zoom: 8.0,
|
||||
camPos: pixel.V(0, float64(-pWin.Bounds().Size().Y)),
|
||||
zoom: 8.0,
|
||||
}
|
||||
|
||||
for !win.Closed() {
|
||||
win.Run(func() {
|
||||
oldState := *state
|
||||
state = runStep(win, state)
|
||||
state = runStep(pWin, state)
|
||||
|
||||
if oldState != *state {
|
||||
log.Printf("z=%d cellIdx=%d", state.zIdx, state.cellIdx)
|
||||
present(win, state)
|
||||
present(pWin, state)
|
||||
}
|
||||
|
||||
win.Update()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Converts pixel coordinates to cell coordinates
|
||||
|
Reference in New Issue
Block a user