Editor: Allow using doodad settings buttons in Pan Tool
This commit is contained in:
parent
cbc8682406
commit
06dd30893c
2
.dockerignore
Normal file
2
.dockerignore
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bin/*
|
||||||
|
dist/*
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -6,11 +6,13 @@ bin/
|
||||||
dist/
|
dist/
|
||||||
rtp/
|
rtp/
|
||||||
guidebook/
|
guidebook/
|
||||||
|
docker-artifacts/
|
||||||
wasm/assets/
|
wasm/assets/
|
||||||
*.wasm
|
*.wasm
|
||||||
*.doodad
|
*.doodad
|
||||||
*.level
|
*.level
|
||||||
*.levelpack
|
*.levelpack
|
||||||
|
*.AppImage
|
||||||
docker/ubuntu
|
docker/ubuntu
|
||||||
docker/debian
|
docker/debian
|
||||||
docker/fedora
|
docker/fedora
|
||||||
|
|
|
@ -25,7 +25,7 @@ ENV PATH /opt/go/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/go/bin
|
||||||
RUN apt update && apt -y install git zip tar libsdl2-dev libsdl2-ttf-dev \
|
RUN apt update && apt -y install git zip tar libsdl2-dev libsdl2-ttf-dev \
|
||||||
libsdl2-mixer-dev gcc-mingw-w64-x86-64 gcc make wget \
|
libsdl2-mixer-dev gcc-mingw-w64-x86-64 gcc make wget \
|
||||||
flatpak-builder ruby-dev gcc rpm libffi-dev \
|
flatpak-builder ruby-dev gcc rpm libffi-dev \
|
||||||
ruby-dev ruby-rubygems rpm libffi-dev rsync
|
ruby-dev ruby-rubygems rpm libffi-dev rsync file
|
||||||
RUN gem install fpm; exit 0
|
RUN gem install fpm; exit 0
|
||||||
|
|
||||||
# Download and install modern Go.
|
# Download and install modern Go.
|
||||||
|
@ -80,7 +80,7 @@ ENV PATH /opt/go/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/go/bin
|
||||||
RUN apt update && apt -y install git zip tar libsdl2-dev libsdl2-ttf-dev \
|
RUN apt update && apt -y install git zip tar libsdl2-dev libsdl2-ttf-dev \
|
||||||
libsdl2-mixer-dev gcc-mingw-w64-i686 gcc make wget \
|
libsdl2-mixer-dev gcc-mingw-w64-i686 gcc make wget \
|
||||||
flatpak-builder ruby-dev gcc rpm libffi-dev \
|
flatpak-builder ruby-dev gcc rpm libffi-dev \
|
||||||
ruby-dev ruby-rubygems rpm libffi-dev
|
ruby-dev ruby-rubygems rpm libffi-dev rsync file
|
||||||
RUN gem install fpm; exit 0
|
RUN gem install fpm; exit 0
|
||||||
|
|
||||||
# Download and install modern Go.
|
# Download and install modern Go.
|
||||||
|
|
4
Makefile
4
Makefile
|
@ -171,7 +171,7 @@ dist: doodads build __dist-common
|
||||||
.PHONY: docker
|
.PHONY: docker
|
||||||
docker:
|
docker:
|
||||||
mkdir -p docker-artifacts
|
mkdir -p docker-artifacts
|
||||||
podman build -t doodle_docker .
|
podman build --cap-add SYS_ADMIN --device /dev/fuse -t doodle_docker .
|
||||||
podman run --rm --mount type=bind,src=$(shell pwd)/docker-artifacts,dst=/mnt/export doodle_docker
|
podman run --rm --mount type=bind,src=$(shell pwd)/docker-artifacts,dst=/mnt/export doodle_docker
|
||||||
|
|
||||||
# `make dist-free` builds and tars up a release in shareware mode.
|
# `make dist-free` builds and tars up a release in shareware mode.
|
||||||
|
@ -193,4 +193,4 @@ __dist-common:
|
||||||
# `make clean` cleans everything up.
|
# `make clean` cleans everything up.
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm -rf bin dist docker/ubuntu docker/debian docker/fedora
|
rm -rf bin dist docker-artifacts
|
||||||
|
|
|
@ -39,8 +39,8 @@ repos_github = {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Software dependencies.
|
# Software dependencies.
|
||||||
dep_fedora = ["make", "golang", "SDL2-devel", "SDL2_ttf-devel", "SDL2_mixer-devel"]
|
dep_fedora = ["make", "golang", "SDL2-devel", "SDL2_ttf-devel", "SDL2_mixer-devel", "zip", "rsync"]
|
||||||
dep_debian = ["make", "golang", "libsdl2-dev", "libsdl2-ttf-dev", "libsdl2-mixer-dev"]
|
dep_debian = ["make", "golang", "libsdl2-dev", "libsdl2-ttf-dev", "libsdl2-mixer-dev", "zip", "rsync"]
|
||||||
dep_macos = ["golang", "sdl2", "sdl2_ttf", "sdl2_mixer", "pkg-config"]
|
dep_macos = ["golang", "sdl2", "sdl2_ttf", "sdl2_mixer", "pkg-config"]
|
||||||
dep_arch = ["go", "sdl2", "sdl2_ttf", "sdl2_mixer"]
|
dep_arch = ["go", "sdl2", "sdl2_ttf", "sdl2_mixer"]
|
||||||
|
|
||||||
|
|
|
@ -154,13 +154,14 @@ func (w *Canvas) loopEditable(ev *event.State) error {
|
||||||
switch w.Tool {
|
switch w.Tool {
|
||||||
case drawtool.PanTool:
|
case drawtool.PanTool:
|
||||||
// Pan tool = click to pan the level.
|
// Pan tool = click to pan the level.
|
||||||
|
var delta render.Point
|
||||||
if keybind.LeftClick(ev) || keybind.MiddleClick(ev) {
|
if keybind.LeftClick(ev) || keybind.MiddleClick(ev) {
|
||||||
if !w.scrollDragging {
|
if !w.scrollDragging {
|
||||||
w.scrollDragging = true
|
w.scrollDragging = true
|
||||||
w.scrollStartAt = shmem.Cursor
|
w.scrollStartAt = shmem.Cursor
|
||||||
w.scrollWasAt = w.Scroll
|
w.scrollWasAt = w.Scroll
|
||||||
} else {
|
} else {
|
||||||
delta := shmem.Cursor.Compare(w.scrollStartAt)
|
delta = shmem.Cursor.Compare(w.scrollStartAt)
|
||||||
w.Scroll = w.scrollWasAt
|
w.Scroll = w.scrollWasAt
|
||||||
w.Scroll.Subtract(delta)
|
w.Scroll.Subtract(delta)
|
||||||
|
|
||||||
|
@ -176,6 +177,65 @@ func (w *Canvas) loopEditable(ev *event.State) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// All the Pan tool to still interact with the Settings button on mouse-over
|
||||||
|
// of an actor. On touch devices it's difficult to access an actor's settings
|
||||||
|
// without accidentally dragging the actor, so the Pan Tool allows safe access.
|
||||||
|
// NOTE: code copied from Actor Tool but with delete and drag/drop hooks removed.
|
||||||
|
var WP = w.WorldIndexAt(cursor)
|
||||||
|
for _, actor := range w.actors {
|
||||||
|
|
||||||
|
// Compute the bounding box on screen where this doodad
|
||||||
|
// visually appears.
|
||||||
|
var scrollBias = render.Point{
|
||||||
|
X: w.Scroll.X,
|
||||||
|
Y: w.Scroll.Y,
|
||||||
|
}
|
||||||
|
if w.Zoom != 0 {
|
||||||
|
scrollBias.X = w.ZoomDivide(scrollBias.X)
|
||||||
|
scrollBias.Y = w.ZoomDivide(scrollBias.Y)
|
||||||
|
}
|
||||||
|
box := render.Rect{
|
||||||
|
X: actor.Actor.Point.X - scrollBias.X - w.ZoomDivide(P.X),
|
||||||
|
Y: actor.Actor.Point.Y - scrollBias.Y - w.ZoomDivide(P.Y),
|
||||||
|
W: actor.Canvas.Size().W,
|
||||||
|
H: actor.Canvas.Size().H,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mouse hover?
|
||||||
|
if WP.Inside(box) {
|
||||||
|
actor.Canvas.Configure(ui.Config{
|
||||||
|
BorderSize: 1,
|
||||||
|
BorderColor: render.RGBA(153, 153, 153, 255),
|
||||||
|
BorderStyle: ui.BorderSolid,
|
||||||
|
Background: render.White, // TODO: cuz the border draws a bgcolor
|
||||||
|
})
|
||||||
|
|
||||||
|
// Show doodad buttons.
|
||||||
|
actor.Canvas.ShowDoodadButtons = true
|
||||||
|
|
||||||
|
// Check for a mouse down event to begin dragging this
|
||||||
|
// canvas around.
|
||||||
|
if keybind.LeftClick(ev) && delta == render.Origin {
|
||||||
|
// Did they click onto the doodad buttons?
|
||||||
|
if shmem.Cursor.Inside(actor.Canvas.doodadButtonRect()) {
|
||||||
|
keybind.ClearLeftClick(ev)
|
||||||
|
if w.OnDoodadConfig != nil {
|
||||||
|
w.OnDoodadConfig(actor)
|
||||||
|
} else {
|
||||||
|
log.Error("OnDoodadConfig: handler not defined for parent canvas")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
actor.Canvas.SetBorderSize(0)
|
||||||
|
actor.Canvas.SetBackground(render.RGBA(0, 0, 1, 0)) // TODO
|
||||||
|
actor.Canvas.ShowDoodadButtons = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case drawtool.PencilTool:
|
case drawtool.PencilTool:
|
||||||
// If no swatch is active, do nothing with mouse clicks.
|
// If no swatch is active, do nothing with mouse clicks.
|
||||||
if w.Palette.ActiveSwatch == nil {
|
if w.Palette.ActiveSwatch == nil {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user