screenshots will take unique name

This commit is contained in:
minjaesong
2020-11-25 13:39:17 +09:00
parent 79114fcbd0
commit bed6f74462
4 changed files with 11 additions and 5 deletions

View File

@@ -557,11 +557,14 @@ public class AppLoader implements ApplicationListener {
try {
Pixmap p = ScreenUtils.getFrameBufferPixmap(0, 0, appConfig.width, appConfig.height);
PixmapIO2.writeTGA(Gdx.files.absolute(defaultDir + "/Screenshot.tga"), p, true);
PixmapIO2.writeTGA(Gdx.files.absolute(defaultDir+"/Screenshot-"+String.valueOf(System.currentTimeMillis())+".tga"), p, true);
p.dispose();
Terrarum.INSTANCE.getIngame().sendNotification("Screenshot taken");
}
catch (Throwable e) {
e.printStackTrace();
Terrarum.INSTANCE.getIngame().sendNotification("Failed to take screenshot: "+e.getMessage());
}
}

View File

@@ -253,6 +253,10 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
data class BlockChangeQueueItem(val old: Int, val new: Int, val posX: Int, val posY: Int)
open fun sendNotification(messages: Array<String>) {}
open fun sendNotification(messages: List<String>) {}
open fun sendNotification(singleMessage: String) {}
}
inline fun Lock.lock(body: () -> Unit) {

View File

@@ -117,7 +117,6 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
// screenshot key
if (keycode == Input.Keys.F12 && !f12Down) {
AppLoader.requestScreenshot()
terrarumIngame.sendNotification("Screenshot taken")
f12Down = true
println("Screenshot taken.")
}

View File

@@ -660,15 +660,15 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
}
/** Send message to notifier UI and toggle the UI as opened. */
fun sendNotification(messages: Array<String>) {
override fun sendNotification(messages: Array<String>) {
(notifier as Notification).sendNotification(messages.toList())
}
fun sendNotification(messages: List<String>) {
override fun sendNotification(messages: List<String>) {
(notifier as Notification).sendNotification(messages)
}
fun sendNotification(singleMessage: String) = sendNotification(listOf(singleMessage))
override fun sendNotification(singleMessage: String) = sendNotification(listOf(singleMessage))
fun wakeDormantActors() {
var actorContainerSize = actorContainerInactive.size