mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
Change the screenshot location
This commit is contained in:
parent
3600c8aa6c
commit
e6d385133a
19
run.go
19
run.go
@ -21,6 +21,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/internal/clock"
|
"github.com/hajimehoshi/ebiten/internal/clock"
|
||||||
"github.com/hajimehoshi/ebiten/internal/png"
|
"github.com/hajimehoshi/ebiten/internal/png"
|
||||||
@ -199,12 +200,26 @@ func (i *imageDumper) update(screen *Image) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := os.Rename(name, name+".png"); err != nil {
|
|
||||||
|
newname := fmt.Sprintf("%s.png", time.Now().Format("20060102030405"))
|
||||||
|
for i := 1; ; i++ {
|
||||||
|
if _, err := os.Stat(newname); err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if !os.IsNotExist(err) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newname = fmt.Sprintf("%s_%d.png", time.Now().Format("20060102030405"), i)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := os.Rename(name, newname); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
i.toTakeScreenshot = false
|
i.toTakeScreenshot = false
|
||||||
fmt.Fprintf(os.Stderr, "Saved screenshot: %s.png\n", name)
|
fmt.Fprintf(os.Stderr, "Saved screenshot: %s\n", newname)
|
||||||
}
|
}
|
||||||
|
|
||||||
if i.toDumpInternalImages {
|
if i.toDumpInternalImages {
|
||||||
|
Loading…
Reference in New Issue
Block a user