ebiten: implement imageDumper for mobiles

This is a provisional implementation to clean up the code.
This commit is contained in:
Hajime Hoshi 2022-10-14 03:16:02 +09:00
parent f15536e8de
commit 44c90b42d4
2 changed files with 18 additions and 34 deletions

View File

@ -12,14 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !android && !ios
// +build !android,!ios
package ebiten
import (
"fmt"
"os"
"path/filepath"
"runtime"
"time"
"github.com/hajimehoshi/ebiten/v2/internal/debug"
@ -34,6 +33,14 @@ func datetimeForFilename() string {
func takeScreenshot(screen *Image) error {
name := "screenshot_" + datetimeForFilename() + ".png"
// Use the home directory for mobiles as a provisional implementation.
if runtime.GOOS == "android" || runtime.GOOS == "ios" {
home, err := os.UserHomeDir()
if err != nil {
return err
}
name = filepath.Join(home, name)
}
blackbg := !IsScreenTransparent()
dumpedName, err := screen.image.DumpScreenshot(name, blackbg)
if err != nil {
@ -50,6 +57,14 @@ func dumpInternalImages() error {
if err != nil {
return err
}
// Use the home directory for mobiles as a provisional implementation.
if runtime.GOOS == "android" || runtime.GOOS == "ios" {
home, err := os.UserHomeDir()
if err != nil {
return err
}
dumpedDir = filepath.Join(home, dumpedDir)
}
if _, err := fmt.Fprintf(os.Stderr, "Dumped the internal images at: %s\n", dumpedDir); err != nil {
return err
}

View File

@ -1,31 +0,0 @@
// Copyright 2018 The Ebiten Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build android || ios
// +build android ios
package ebiten
type imageDumper struct {
}
func (i *imageDumper) update() error {
// Do nothing
return nil
}
func (i *imageDumper) dump(screen *Image) error {
// Do nothing
return nil
}