mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
Add 'ebitendebug' build tag
EBITEN_INTERNAL_IMAGES_KEY is now disabled by default, and enabled only when a build tag 'ebitendebug' is specified. It is because game developers might want to disable EBITEN_INTERNAL_IMAGES_KEY when they release their games, or anyone can dump the internal images. Fixes #632.
This commit is contained in:
parent
116bba0d37
commit
b1e4c3c8f0
21
debug_ebitendebug.go
Normal file
21
debug_ebitendebug.go
Normal file
@ -0,0 +1,21 @@
|
||||
// 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.
|
||||
|
||||
// +build ebitendebug
|
||||
|
||||
package ebiten
|
||||
|
||||
func isDebug() bool {
|
||||
return true
|
||||
}
|
21
debug_notebitendebug.go
Normal file
21
debug_notebitendebug.go
Normal file
@ -0,0 +1,21 @@
|
||||
// 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.
|
||||
|
||||
// +build !ebitendebug
|
||||
|
||||
package ebiten
|
||||
|
||||
func isDebug() bool {
|
||||
return false
|
||||
}
|
3
doc.go
3
doc.go
@ -43,5 +43,6 @@
|
||||
// by pressing Q key.
|
||||
//
|
||||
// The EBITEN_INTERNAL_IMAGES_KEY environment variable specifies the key
|
||||
// to dump all the internal images.
|
||||
// to dump all the internal images. This is valid only when the build tag
|
||||
// 'ebitendebug' is specified.
|
||||
package ebiten
|
||||
|
14
run.go
14
run.go
@ -109,6 +109,11 @@ type imageDumper struct {
|
||||
}
|
||||
|
||||
func (i *imageDumper) update(screen *Image) error {
|
||||
const (
|
||||
envScreenshotKey = "EBITEN_SCREENSHOT_KEY"
|
||||
envInternalImagesKey = "EBITEN_INTERNAL_IMAGES_KEY"
|
||||
)
|
||||
|
||||
if err := i.f(screen); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -117,17 +122,22 @@ func (i *imageDumper) update(screen *Image) error {
|
||||
if i.keyState == nil {
|
||||
i.keyState = map[Key]int{}
|
||||
|
||||
if keyname := os.Getenv("EBITEN_SCREENSHOT_KEY"); keyname != "" {
|
||||
if keyname := os.Getenv(envScreenshotKey); keyname != "" {
|
||||
if key, ok := keyNameToKey(keyname); ok {
|
||||
i.hasScreenshotKey = true
|
||||
i.screenshotKey = key
|
||||
}
|
||||
}
|
||||
if keyname := os.Getenv("EBITEN_INTERNAL_IMAGES_KEY"); keyname != "" {
|
||||
|
||||
if keyname := os.Getenv(envInternalImagesKey); keyname != "" {
|
||||
if isDebug() {
|
||||
if key, ok := keyNameToKey(keyname); ok {
|
||||
i.hasDumpInternalImagesKey = true
|
||||
i.dumpInternalImagesKey = key
|
||||
}
|
||||
} else {
|
||||
fmt.Fprintf(os.Stderr, "%s is disabled. Specify a build tag 'ebitendebug' to enable it.\n", envInternalImagesKey)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user