Detect touchscreen and tweak some behaviors
This commit is contained in:
parent
6631d8d11c
commit
546b5705db
48
Building.md
48
Building.md
|
@ -1,6 +1,7 @@
|
|||
# Building Doodle
|
||||
|
||||
* [Quickstart](#quickstart-with-bootstrap-py)
|
||||
* [Automated Release Scripts](#automated-release-scripts)
|
||||
* [Quickstart with bootstrap.py](#quickstart-with-bootstrap-py)
|
||||
* [Detailed Instructions](#detailed-instructions)
|
||||
* [Linux](#linux)
|
||||
* [Flatpak for Linux](#flatpak-for-linux)
|
||||
|
@ -72,12 +73,10 @@ For building the app the hard way, and in-depth instructions, read
|
|||
this section. You'll need the following git repositories:
|
||||
|
||||
* `git.kirsle.net/SketchyMaze/doodle` - the game engine.
|
||||
* `git.kirsle.net/apps/SketchyMaze/masters` - where built-in level files are kept,
|
||||
as well as master GIMP drawings for sprites and such but only the levels
|
||||
are necessary to build the app properly. Tho even then the app would
|
||||
work fine with no levels built in!
|
||||
* `git.kirsle.net/apps/SketchyMaze/vendor` - vendored libraries for Windows (SDL2.dll etc.)
|
||||
* `git.kirsle.net/apps/SketchyMaze/rtp` - runtime package (sounds and music mostly)
|
||||
* `git.kirsle.net/SketchyMaze/assets` - where built-in level files are kept (optional)
|
||||
* `git.kirsle.net/SketchyMaze/vendor` - vendored libraries for Windows (SDL2.dll etc.)
|
||||
* `git.kirsle.net/SketchyMaze/rtp` - runtime package (sounds and music mostly)
|
||||
* `git.kirsle.net/SketchyMaze/doodads` - sources to compile the built-in doodads.
|
||||
|
||||
The [docker](https://git.kirsle.net/SketchyMaze/docker) repo will
|
||||
be more up-to-date than the instructions below, as that repo actually has
|
||||
|
@ -85,16 +84,17 @@ runnable code in the Dockerfile!
|
|||
|
||||
```bash
|
||||
# Clone all the repos down to your project folder
|
||||
git clone git@git.kirsle.net:apps/SketchyMaze/rtp rtp
|
||||
git clone git@git.kirsle.net:apps/SketchyMaze/vendor vendor
|
||||
git clone git@git.kirsle.net:apps/SketchyMaze/masters masters
|
||||
git clone git@git.kirsle.net:apps/doodle doodle
|
||||
git clone https://git.kirsle.net/SketchyMaze/rtp rtp
|
||||
git clone https://git.kirsle.net/SketchyMaze/vendor vendor
|
||||
git clone https://git.kirsle.net/SketchyMaze/masters masters
|
||||
git clone https://git.kirsle.net/SketchyMaze/doodle doodle
|
||||
git clone https://git.kirsle.net/SketchyMaze/doodads doodle/deps/doodads
|
||||
|
||||
# Enter doodle/ project
|
||||
cd doodle/
|
||||
|
||||
# Copy fonts and levels in
|
||||
cp ../masters/levels assets/levels
|
||||
cp ../assets/levelpacks assets/levelpacks
|
||||
cp ../vendor/fonts assets/fonts
|
||||
mkdir rtp && cp -r ../rtp/* rtp/
|
||||
|
||||
|
@ -121,13 +121,27 @@ make mingw
|
|||
make release
|
||||
```
|
||||
|
||||
The `make setup` command tries to do the above.
|
||||
|
||||
`make build` produces a local binary in the bin/ folder and `make dist`
|
||||
will build an app for distribution in the dist/ folder.
|
||||
|
||||
Levels should be copied in from the doodle-masters repo into the
|
||||
assets/levels/ folder before building the game.
|
||||
The bootstrap.py script does all of the above up to `make dist` so if you need
|
||||
fully release the game by hand (e.g. on a macOS host) you can basically get away
|
||||
with:
|
||||
|
||||
1. Clone the doodle repo and cd into it
|
||||
2. Run `bootstrap.py` to fully set up your OS with dependencies and build a
|
||||
release quality version of the game with all latest assets (the script finishes
|
||||
with a `make dist`).
|
||||
3. Run `make release` to package the dist/ artifact into platform specific
|
||||
release artifacts (.rpm/.deb/.tar.gz bundles for Linux, .zip for Windows,
|
||||
.dmg if running on macOS) which output into the dist/release/ folder.
|
||||
|
||||
Before step 3 you may want to download the latest Guidebook to bundle with
|
||||
the game (optional). Grab and extract the tarball and run `make dist && make release`:
|
||||
|
||||
```bash
|
||||
wget -O - https://download.sketchymaze.com/guidebook.tar.gz | tar -xzvf -
|
||||
```
|
||||
|
||||
## Fonts
|
||||
|
||||
|
@ -195,7 +209,7 @@ brew install golang sdl2 sdl2_ttf sdl2_mixer pkg-config
|
|||
|
||||
## Flatpak for Linux
|
||||
|
||||
The repo for this is at <https://code.sketchymaze.com/game/flatpak>.
|
||||
The repo for this is at <https://git.kirsle.net/SketchyMaze/flatpak>.
|
||||
|
||||
## Windows Cross-Compile from Linux
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
"git.kirsle.net/SketchyMaze/doodle/pkg/gamepad"
|
||||
"git.kirsle.net/SketchyMaze/doodle/pkg/license"
|
||||
"git.kirsle.net/SketchyMaze/doodle/pkg/log"
|
||||
"git.kirsle.net/SketchyMaze/doodle/pkg/native"
|
||||
"git.kirsle.net/SketchyMaze/doodle/pkg/shmem"
|
||||
"git.kirsle.net/SketchyMaze/doodle/pkg/sound"
|
||||
"git.kirsle.net/SketchyMaze/doodle/pkg/sprites"
|
||||
|
@ -199,9 +200,10 @@ func main() {
|
|||
game := doodle.New(c.Bool("debug"), engine)
|
||||
game.SetupEngine()
|
||||
|
||||
// Hide the mouse cursor over the window, we draw our own
|
||||
// sprite image for it.
|
||||
engine.ShowCursor(false)
|
||||
// Hide the mouse cursor over the window, we draw our own sprite image for it.
|
||||
if !native.HasTouchscreen(engine) {
|
||||
engine.ShowCursor(false)
|
||||
}
|
||||
|
||||
// Set the app window icon.
|
||||
if engine, ok := game.Engine.(*sdl.Renderer); ok {
|
||||
|
@ -235,6 +237,10 @@ func main() {
|
|||
// Initialize the developer shell chatbot easter egg.
|
||||
chatbot.Setup()
|
||||
|
||||
// Log some basic environment details.
|
||||
w, h := engine.WindowSize()
|
||||
log.Info("Has touchscreen? %+v Window size: %dx%d", native.HasTouchscreen(engine), w, h)
|
||||
|
||||
game.Run()
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
const (
|
||||
AppName = "Sketchy Maze"
|
||||
Summary = "A drawing-based maze game"
|
||||
Version = "0.13.0"
|
||||
Version = "0.13.1"
|
||||
Website = "https://www.sketchymaze.com"
|
||||
Copyright = "2022 Noah Petherbridge"
|
||||
Byline = "a game by Noah Petherbridge."
|
||||
|
|
|
@ -4,6 +4,7 @@ package cursor
|
|||
import (
|
||||
"git.kirsle.net/SketchyMaze/doodle/pkg/balance"
|
||||
"git.kirsle.net/SketchyMaze/doodle/pkg/log"
|
||||
"git.kirsle.net/SketchyMaze/doodle/pkg/native"
|
||||
"git.kirsle.net/SketchyMaze/doodle/pkg/shmem"
|
||||
"git.kirsle.net/SketchyMaze/doodle/pkg/sprites"
|
||||
"git.kirsle.net/go/render"
|
||||
|
@ -22,8 +23,12 @@ var Current *Cursor
|
|||
// NoCursor hides the cursor entirely.
|
||||
var NoCursor = &Cursor{}
|
||||
|
||||
// Draw the cursor on screen.
|
||||
// Draw the cursor on screen. NOTE: Does not draw on touchscreen devices.
|
||||
func Draw(e render.Engine) {
|
||||
if native.HasTouchscreen(e) {
|
||||
return
|
||||
}
|
||||
|
||||
if Current == nil {
|
||||
Current = NewPointer(e)
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ func (c *Chunker) MigrateZipfile(zf *zip.Writer) error {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
log.Warn("Chunker.MigrateZipfile: the drawing did not give me a zipfile!")
|
||||
log.Debug("Chunker.MigrateZipfile: the drawing did not give me a zipfile!")
|
||||
}
|
||||
|
||||
if len(c.Chunks) == 0 {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
//go:build !js
|
||||
// +build !js
|
||||
|
||||
package native
|
||||
|
@ -14,6 +15,14 @@ import (
|
|||
// Native render engine functions (SDL2 edition),
|
||||
// not for JavaScript/WASM yet.
|
||||
|
||||
// HasTouchscreen checks if the device has at least one SDL_GetNumTouchDevices.
|
||||
func HasTouchscreen(e render.Engine) bool {
|
||||
if _, ok := e.(*sdl.Renderer); ok {
|
||||
return sdl2.GetNumTouchDevices() > 0
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/*
|
||||
TextToImage takes an SDL2_TTF texture and makes it into a Go image.
|
||||
|
||||
|
|
|
@ -8,6 +8,10 @@ import (
|
|||
"git.kirsle.net/go/render"
|
||||
)
|
||||
|
||||
func HasTouchscreen(e render.Engine) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func TextToImage(e render.Engine, text render.Text) (image.Image, error) {
|
||||
return nil, errors.New("not supported on WASM")
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ import (
|
|||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"git.kirsle.net/SketchyMaze/doodle/pkg/native"
|
||||
"git.kirsle.net/SketchyMaze/doodle/pkg/shmem"
|
||||
"git.kirsle.net/SketchyMaze/doodle/pkg/userdir"
|
||||
"git.kirsle.net/go/render"
|
||||
)
|
||||
|
@ -53,7 +55,14 @@ var Current = Defaults()
|
|||
|
||||
// Defaults returns sensible default user settings.
|
||||
func Defaults() *Settings {
|
||||
return &Settings{}
|
||||
settings := &Settings{}
|
||||
|
||||
// If not a touchscreen device, disable touchscreen hints as default.
|
||||
if !native.HasTouchscreen(shmem.CurrentRenderEngine) {
|
||||
settings.HideTouchHints = true
|
||||
}
|
||||
|
||||
return settings
|
||||
}
|
||||
|
||||
// Filepath returns the path to the settings file.
|
||||
|
|
Loading…
Reference in New Issue
Block a user