adjusting disposing behavs so that we can go back and forth the ingame and titlescr

This commit is contained in:
minjaesong
2019-01-31 00:12:38 +09:00
parent 1475fa08dc
commit b3e323965f
12 changed files with 62 additions and 49 deletions

View File

@@ -4,10 +4,7 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.InputAdapter
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.AppLoader
import net.torvald.terrarum.IngameInstance
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.Yaml
import net.torvald.terrarum.*
import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.gameactors.*
import net.torvald.terrarum.gamecontroller.KeyToggler
@@ -20,7 +17,6 @@ import net.torvald.terrarum.ui.UINSMenu
import net.torvald.terrarum.worlddrawer.LightmapRenderer
import net.torvald.terrarum.worlddrawer.WorldCamera
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
import kotlin.system.measureNanoTime
/**
* Created by minjaesong on 2018-07-06.
@@ -35,6 +31,7 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
- Import…
- Save world…
- Load world…
- Exit to Title : net.torvald.terrarum.modulebasegame.YamlCommandExit
- Tool
- Pencil
- Eyedropper
@@ -135,6 +132,7 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
uiToolbox.setPosition(0, 0)
uiToolbox.isVisible = true
notifier.setPosition(
(Terrarum.WIDTH - notifier.width) / 2, Terrarum.HEIGHT - notifier.height)
@@ -259,4 +257,10 @@ class MovableWorldCamera : ActorHumanoid(0, usePhysics = false) {
override fun onActorValueChange(key: String, value: Any?) {
}
}
class YamlCommandExit : YamlInvokable {
override fun invoke(vararg args: Any?) {
Terrarum.setScreen(TitleScreen(Terrarum.batch))
}
}

View File

@@ -22,8 +22,6 @@ import net.torvald.terrarum.modulebasegame.gameactors.*
import net.torvald.terrarum.modulebasegame.gameactors.physicssolver.CollisionSolver
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
import net.torvald.terrarum.modulebasegame.gameworld.WorldSimulator
import net.torvald.terrarum.modulebasegame.imagefont.Watch7SegMain
import net.torvald.terrarum.modulebasegame.imagefont.WatchDotAlph
import net.torvald.terrarum.modulebasegame.ui.*
import net.torvald.terrarum.modulebasegame.weather.WeatherMixer
import net.torvald.terrarum.modulebasegame.worldgenerator.RoguelikeRandomiser
@@ -890,7 +888,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
}
override fun hide() {
dispose()
uiContainer.forEach { it.handler.dispose() }
}
@@ -943,26 +941,16 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
}
override fun dispose() {
IngameRenderer.dispose()
actorsRenderBehind.forEach { it.dispose() }
actorsRenderMiddle.forEach { it.dispose() }
actorsRenderMidTop.forEach { it.dispose() }
actorsRenderFront.forEach { it.dispose() }
actorsRenderOverlay.forEach { it.dispose() }
uiAliases.forEach { it.dispose() }
uiAliasesPausing.forEach { it.dispose() }
WatchDotAlph.dispose()
Watch7SegMain.dispose()
WatchDotAlph.dispose()
ItemSlotImageFactory.dispose()
MessageWindow.SEGMENT_BLACK.dispose()
MessageWindow.SEGMENT_WHITE.dispose()
uiContainer.forEach {
it.handler.dispose()
it.dispose()
}
}

View File

@@ -135,7 +135,7 @@ class UIInventoryFull(
private var transitionReqSource = SCREEN_INVENTORY
private var transitionReqTarget = SCREEN_INVENTORY
private var transitionTimer = 0f
private val transitionLength = 0.333f
private val transitionLength = 0.212f
private val transitionalUpdateUIs = ArrayList<UIItem>()
@@ -174,6 +174,16 @@ class UIInventoryFull(
addToTransitionalGroup(itemList)
addToTransitionalGroup(equipped)
addToTransitionalGroup(gameMenuButtons)
// make gameMenuButtons work
gameMenuButtons.selectionChangeListener = { old, new ->
if (new == 0) {
Terrarum.setScreen(TitleScreen(Terrarum.batch))
}
else if (new == 1) {
Gdx.app.exit()
}
}
}
private var offsetX = ((Terrarum.WIDTH - internalWidth) / 2).toFloat()