tooltip and notifier moved to the base ingame

This commit is contained in:
minjaesong
2021-09-07 17:15:35 +09:00
parent 85ba7a357c
commit bbd7878630
5 changed files with 161 additions and 140 deletions

View File

@@ -100,7 +100,6 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
override var actorNowPlaying: ActorHumanoid? = MovableWorldCamera(this)
val uiToolbox = UINSMenu("Menu", 100, menuYaml)
val notifier = Notification()
val uiPaletteSelector = UIPaletteSelector(this)
val uiPalette = UIBuildingMakerBlockChooser(this)
val uiPenMenu = UIBuildingMakerPenMenu(this)

View File

@@ -47,6 +47,8 @@ import net.torvald.terrarum.worlddrawer.BlocksDrawer
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
import net.torvald.terrarum.worlddrawer.WorldCamera
import net.torvald.util.CircularArray
import org.khelekore.prtree.MBRConverter
import org.khelekore.prtree.PRTree
import java.util.concurrent.locks.ReentrantLock
import kotlin.math.roundToInt
@@ -143,9 +145,6 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
}
lateinit var notifier: UICanvas
lateinit var uiPieMenu: UICanvas
lateinit var uiQuickBar: UICanvas
lateinit var uiInventoryPlayer: UICanvas
@@ -182,9 +181,6 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
private lateinit var uiBasicInfo: UICanvas
private lateinit var uiWatchTierOne: UICanvas
/** For in-world text overlays? e.g. cursor on the ore block and tooltip will say "Malachite" or something */
private lateinit var uiTooltip: UITooltip
lateinit var uiCheatMotherfuckerNootNoot: UICheatDetected
@@ -349,14 +345,6 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
//consoleHandler.setPosition(0, 0)
// init notifier
notifier = Notification()
notifier.setPosition(
(AppLoader.screenSize.screenW - notifier.width) / 2,
AppLoader.screenSize.screenH - notifier.height - AppLoader.screenSize.tvSafeGraphicsHeight
)
// >- queue up game UIs that should pause the world -<
@@ -396,8 +384,6 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
uiBasicInfo.setPosition((uiQuickBar.posX - uiBasicInfo.width - AppLoader.screenSize.tvSafeActionWidth) / 2 + AppLoader.screenSize.tvSafeActionWidth, uiWatchTierOne.posY)
uiTooltip = UITooltip()
uiCheatMotherfuckerNootNoot = UICheatDetected()
@@ -447,7 +433,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
var uiOpened = false
// TODO actorsUnderMouse: support ROUNDWORLD
val actorsUnderMouse: List<FixtureBase> = WorldSimulator.getActorsAt(Terrarum.mouseX, Terrarum.mouseY).filterIsInstance<FixtureBase>()
val actorsUnderMouse: List<FixtureBase> = getActorsAt(Terrarum.mouseX, Terrarum.mouseY).filterIsInstance<FixtureBase>()
if (actorsUnderMouse.size > 1) {
AppLoader.printdbgerr(this, "Multiple fixtures at world coord ${Terrarum.mouseX}, ${Terrarum.mouseY}")
}
@@ -580,29 +566,6 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
WorldSimulator.resetForThisFrame()
///////////////////////////
// world-related updates //
///////////////////////////
BlockPropUtil.dynamicLumFuncTickClock()
world.updateWorldTime(delta)
measureDebugTime("WorldSimulator.update") {
WorldSimulator.invoke(actorNowPlaying, delta)
}
measureDebugTime("WeatherMixer.update") {
WeatherMixer.update(delta, actorNowPlaying, world)
}
measureDebugTime("BlockStats.update") {
BlockStats.update()
}
// fill up visibleActorsRenderFront for wires, if:
// 1. something is cued on the wire change queue
// 2. wire renderclass changed
if (newWorldLoadedLatch || wireChangeQueue.isNotEmpty() || selectedWireRenderClass != oldSelectedWireRenderClass) {
measureDebugTime("Ingame.FillUpWiresBuffer") {
fillUpWiresBuffer()
}
}
////////////////////////////
// camera-related updates //
@@ -624,7 +587,32 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
// TODO thread pool(?)
CollisionSolver.process()
//WorldCamera.update(gameworld, actorNowPlaying)
///////////////////////////
// world-related updates //
///////////////////////////
actorsRTree = PRTree(actorMBRConverter, 24)
actorsRTree.load(actorContainerActive.filterIsInstance<ActorWithBody>())
BlockPropUtil.dynamicLumFuncTickClock()
world.updateWorldTime(delta)
measureDebugTime("WorldSimulator.update") {
WorldSimulator.invoke(actorNowPlaying, delta)
}
measureDebugTime("WeatherMixer.update") {
WeatherMixer.update(delta, actorNowPlaying, world)
}
measureDebugTime("BlockStats.update") {
BlockStats.update()
}
// fill up visibleActorsRenderFront for wires, if:
// 1. something is cued on the wire change queue
// 2. wire renderclass changed
if (newWorldLoadedLatch || wireChangeQueue.isNotEmpty() || selectedWireRenderClass != oldSelectedWireRenderClass) {
measureDebugTime("Ingame.FillUpWiresBuffer") {
fillUpWiresBuffer()
}
}
}
@@ -779,17 +767,6 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
changePossession(getActorByID(refid) as ActorHumanoid)
}
/** Send message to notifier UI and toggle the UI as opened. */
override fun sendNotification(messages: Array<String>) {
(notifier as Notification).sendNotification(messages.toList())
}
override fun sendNotification(messages: List<String>) {
(notifier as Notification).sendNotification(messages)
}
override fun sendNotification(singleMessage: String) = sendNotification(listOf(singleMessage))
fun wakeDormantActors() {
var actorContainerSize = actorContainerInactive.size
var i = 0
@@ -1034,18 +1011,6 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
}
}
fun setTooltipMessage(message: String?) {
if (message == null) {
uiTooltip.setAsClose()
}
else {
if (uiTooltip.isClosed || uiTooltip.isClosing) {
uiTooltip.setAsOpen()
}
uiTooltip.message = message
}
}
override fun pause() {
// TODO no pause when off-focus on desktop
}
@@ -1057,7 +1022,6 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
uiContainer.forEach { it?.handler?.dispose() }
}
/**
* @param width same as AppLoader.terrarumAppConfig.screenW
* @param height same as AppLoader.terrarumAppConfig.screenH