Changed panning of map (Ctrl+LMB or MMB instead of LMB).
This commit is contained in:
parent
14454cfd5e
commit
a07d3c1c82
@ -51,25 +51,34 @@ func (r *terrainRenderer) Init(ctx *Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func isControlKeyDown() bool {
|
||||
state := sdl.GetKeyboardState()
|
||||
return state[sdl.SCANCODE_LCTRL] == 1 || state[sdl.SCANCODE_RCTRL] == 1
|
||||
}
|
||||
|
||||
func (r *terrainRenderer) Handle(ctx *Context, event sdl.Event) {
|
||||
switch e := event.(type) {
|
||||
case *sdl.MouseButtonEvent:
|
||||
if r.project.windowInteractRect.IsPointInside(e.X, e.Y) {
|
||||
switch e.Button {
|
||||
case sdl.BUTTON_LEFT:
|
||||
down := e.Type == sdl.MOUSEBUTTONDOWN
|
||||
if down && !r.drag.IsDragging() {
|
||||
r.drag.Start(Pt(e.X, e.Y))
|
||||
} else if !down && r.drag.IsDragging() {
|
||||
r.drag.Cancel()
|
||||
if e.Type == sdl.MOUSEBUTTONDOWN {
|
||||
if e.Button == sdl.BUTTON_MIDDLE || (e.Button == sdl.BUTTON_LEFT && isControlKeyDown()) {
|
||||
if !r.drag.IsDragging() {
|
||||
r.drag.Start(Pt(e.X, e.Y))
|
||||
}
|
||||
}
|
||||
if e.Type == sdl.MOUSEBUTTONUP && !r.drag.HasDragged() {
|
||||
if e.Button == sdl.BUTTON_LEFT {
|
||||
pos := r.project.screenToMapInt(e.X, e.Y)
|
||||
r.game.UserClickedTile(pos)
|
||||
}
|
||||
case sdl.BUTTON_RIGHT:
|
||||
if e.Type == sdl.MOUSEBUTTONDOWN {
|
||||
r.game.CancelTool()
|
||||
if e.Button == sdl.BUTTON_RIGHT {
|
||||
if e.Type == sdl.MOUSEBUTTONDOWN {
|
||||
r.game.CancelTool()
|
||||
}
|
||||
}
|
||||
}
|
||||
if e.Type == sdl.MOUSEBUTTONUP {
|
||||
if r.drag.IsDragging() {
|
||||
r.drag.Cancel()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user