Added Self-Destruction Card & fixed some Tiered entities tooltips rendering

This commit is contained in:
Igor Timofeev 2023-04-18 16:14:47 +00:00
parent e036542576
commit 98ce517cef
12 changed files with 45 additions and 26 deletions

@ -1 +1 @@
Subproject commit 42dd5a966456654968af777d625c3e2f8b9265fa
Subproject commit d0b1eaf97c5e98e58310ca0759a88d2949eda4cb

Binary file not shown.

After

Width:  |  Height:  |  Size: 391 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 87 KiB

View File

@ -1,16 +1,16 @@
BackgroundPattern 0 0 304 304
BarSegment 329 349 16 4
BarSegment 357 349 16 4
ComputerMotherboard 305 129 79 70
Empty 506 126 1 1
EmptySlot 318 330 18 18
EmptySlot 335 330 18 18
Knob 385 129 50 50
KnobCenter 436 129 50 50
KnobLimits 305 200 50 50
ShadowBorder 505 15 1 24
ShadowCorner 301 305 24 24
TabArrow 502 0 8 14
buttons/BottomDrawerClose 337 330 18 18
buttons/BottomDrawerOpen 356 330 18 18
buttons/BottomDrawerClose 354 330 18 18
buttons/BottomDrawerOpen 373 330 18 18
buttons/OpenFMRadioCloseOff 242 402 7 8
buttons/OpenFMRadioCloseOn 250 402 7 8
buttons/OpenFMRadioRedstoneOff 502 87 8 8
@ -19,20 +19,20 @@ buttons/OpenFMRadioStartOff 326 305 24 24
buttons/OpenFMRadioStartOn 351 305 24 24
buttons/OpenFMRadioStopOff 376 305 24 24
buttons/OpenFMRadioStopOn 401 305 24 24
buttons/OpenFMRadioVolumeDownOff 482 330 10 10
buttons/OpenFMRadioVolumeDownOn 493 330 10 10
buttons/OpenFMRadioVolumeUpOff 501 363 10 10
buttons/OpenFMRadioVolumeUpOn 318 349 10 10
buttons/PowerOff 375 330 18 18
buttons/PowerOn 394 330 18 18
buttons/OpenFMRadioVolumeDownOff 499 330 10 10
buttons/OpenFMRadioVolumeDownOn 501 363 10 10
buttons/OpenFMRadioVolumeUpOff 335 349 10 10
buttons/OpenFMRadioVolumeUpOn 346 349 10 10
buttons/PowerOff 392 330 18 18
buttons/PowerOn 411 330 18 18
icons/ButtonCheck 301 363 17 17
icons/ButtonClipboard 319 363 17 17
icons/ButtonRandomize 337 363 17 17
icons/CPU 301 381 16 16
icons/Card 318 381 16 16
icons/ComponentBus 335 381 16 16
icons/DragLMB 413 330 21 14
icons/DragRMB 435 330 21 14
icons/DragLMB 430 330 21 14
icons/DragRMB 452 330 21 14
icons/EEPROM 352 381 16 16
icons/Floppy 369 381 16 16
icons/HDD 386 381 16 16
@ -54,7 +54,7 @@ icons/WaveNoise 401 363 24 10
icons/WaveSawtooth 426 363 24 10
icons/WaveSine 451 363 24 10
icons/WaveSquare 476 363 24 10
icons/WaveTriangle 457 330 24 10
icons/WaveTriangle 474 330 24 10
icons/WireArrowLeft 507 15 4 8
icons/WireArrowRight 507 24 4 8
items/APU0 233 305 16 96
@ -108,6 +108,7 @@ items/Memory5 424 251 16 16
items/NetworkCard 441 251 16 16
items/RedstoneCard0 458 251 16 16
items/RedstoneCard1 475 251 16 16
items/SelfDestructingCard 318 330 16 32
items/Server0 492 251 16 16
items/Server1 305 268 16 16
items/Server2 322 268 16 16

View File

@ -23,6 +23,7 @@ object SoundBuffers {
val InterfaceClick = new SoundBuffer("/ocelot/desktop/sounds/interface/click.ogg")
val InterfaceTick = new SoundBuffer("/ocelot/desktop/sounds/interface/tick.ogg")
val MinecraftClick = new SoundBuffer("/ocelot/desktop/sounds/minecraft/click.ogg")
val MinecraftExplosion = new SoundBuffer("/ocelot/desktop/sounds/minecraft/explosion.ogg")
val NoteBlock: Map[String, SoundBuffer] = List(
"banjo", "basedrum", "bass", "bell", "bit", "chime", "cow_bell", "didgeridoo", "flute", "guitar",

View File

@ -7,4 +7,5 @@ object SoundSources {
val InterfaceTick = SoundSource.fromBuffer(SoundBuffers.InterfaceTick, SoundCategory.Interface)
val MinecraftClick = SoundSource.fromBuffer(SoundBuffers.MinecraftClick, SoundCategory.Interface)
val MinecraftExplosion = SoundSource.fromBuffer(SoundBuffers.MinecraftExplosion, SoundCategory.Environment)
}

View File

@ -130,10 +130,7 @@ abstract class Node(val entity: Entity with Environment) extends Widget with Dra
disconnectFromAll()
}))
menu.addEntry(new ContextMenuEntry("Delete", () => {
dispose()
workspaceView.nodes = workspaceView.nodes.filter(_ != this)
}))
menu.addEntry(new ContextMenuEntry("Delete", destroy))
}
override def update(): Unit = {
@ -173,6 +170,11 @@ abstract class Node(val entity: Entity with Environment) extends Widget with Dra
node.onConnectionRemoved(portB, this, portA)
}
def destroy() = {
dispose()
workspaceView.nodes = workspaceView.nodes.filter(_ != this)
}
def disconnectFromAll(): Unit = {
for ((a, node, b) <- connections.toArray) {
disconnect(a, node, b)

View File

@ -15,7 +15,7 @@ import totoro.ocelot.brain.Settings
import totoro.ocelot.brain.entity.traits.{Entity, Environment, Floppy, GenericCPU, Inventory}
import totoro.ocelot.brain.entity.{CPU, Case, EEPROM, GraphicsCard, HDDManaged, HDDUnmanaged, Memory}
import totoro.ocelot.brain.event.FileSystemActivityType.Floppy
import totoro.ocelot.brain.event.{BeepEvent, BeepPatternEvent, FileSystemActivityEvent, MachineCrashEvent, SoundCardAudioEvent}
import totoro.ocelot.brain.event.{BeepEvent, BeepPatternEvent, FileSystemActivityEvent, MachineCrashEvent, SelfDestructingCardBoomEvent, SoundCardAudioEvent}
import totoro.ocelot.brain.loot.Loot
import totoro.ocelot.brain.util.Tier
@ -63,6 +63,12 @@ class ComputerNode(val computer: Case) extends Node(computer) with Logging {
}
soundCardStream.enqueue(samples)
soundCardSource.volume = event.volume
case BrainEvent(_: SelfDestructingCardBoomEvent) =>
computer.workspace.runLater(() => {
SoundSources.MinecraftExplosion.play()
destroy()
})
}
override def shouldReceiveEventsFor(address: String): Boolean = super.shouldReceiveEventsFor(address) ||

View File

@ -2,8 +2,8 @@ package ocelot.desktop.ui.widget.slot
import ocelot.desktop.graphics.IconDef
import totoro.ocelot.brain.entity.sound_card.SoundCard
import totoro.ocelot.brain.entity.traits.{Entity, Tiered}
import totoro.ocelot.brain.entity.{DataCard, GraphicsCard, InternetCard, LinkedCard, NetworkCard, Redstone, WirelessNetworkCard}
import totoro.ocelot.brain.entity.traits.{Entity, MultiTiered, Tiered}
import totoro.ocelot.brain.entity.{DataCard, GraphicsCard, InternetCard, LinkedCard, NetworkCard, Redstone, SelfDestructingCard, WirelessNetworkCard}
import scala.collection.mutable
import scala.reflect.{ClassTag, classTag}
@ -28,7 +28,7 @@ object CardRegistry {
def getIcon(entity: Entity): Option[IconDef] = {
val clazz = entity.getClass.getName
entity match {
case t: Tiered => iconByClassAndTier.get((clazz, t.tier))
case t: MultiTiered => iconByClassAndTier.get((clazz, t.tier))
case _ => iconByClass.get(clazz)
}
}
@ -77,5 +77,10 @@ object CardRegistry {
addEntry("Sound Card", 1, new IconDef("items/SoundCard", animation = DataCardAnimation),
() => new SoundCard)
private val SelfDestructingCardAnimation = Some(Array((0, 4f), (1, 4f)))
addEntry("Self-Destructing Card", 1, new IconDef("items/SelfDestructingCard", animation = SelfDestructingCardAnimation),
() => new SelfDestructingCard)
}

View File

@ -9,7 +9,7 @@ import ocelot.desktop.ui.widget.tooltip.Tooltip
import ocelot.desktop.ui.widget.{Label, PaddingBox, Widget}
import ocelot.desktop.util.Orientation
import totoro.ocelot.brain.entity.HDDManaged
import totoro.ocelot.brain.entity.traits.{DeviceInfo, Entity, Environment, Inventory, Tiered}
import totoro.ocelot.brain.entity.traits.{DeviceInfo, Entity, Environment, Inventory, MultiTiered, Tiered}
abstract class InventorySlot[T <: Entity](val owner: Inventory#Slot) extends SlotWidget[T] {
reloadItem()
@ -62,7 +62,10 @@ abstract class InventorySlot[T <: Entity](val owner: Inventory#Slot) extends Slo
def tooltipLine1Text: String = item.get match {
case deviceInfoTiered: DeviceInfo with Tiered =>
getTooltipDeviceInfoText(deviceInfoTiered, deviceInfoTiered.tier)
case _ => ""
case deviceInfo: DeviceInfo =>
deviceInfo.getDeviceInfo(DeviceInfo.DeviceAttribute.Description)
case _ =>
""
}
def tooltipChildrenAdder(inner: Widget): Unit = {

View File

@ -4,7 +4,7 @@ import ocelot.desktop.color.Color
import ocelot.desktop.graphics.IconDef
import ocelot.desktop.ui.widget.contextmenu.{ContextMenu, ContextMenuEntry}
import totoro.ocelot.brain.entity.Memory
import totoro.ocelot.brain.entity.traits.{Inventory, Tiered}
import totoro.ocelot.brain.entity.traits.{Inventory, MultiTiered}
import totoro.ocelot.brain.util.Tier
class MemorySlot(owner: Inventory#Slot, val tier: Int) extends InventorySlot[Memory](owner) {
@ -46,7 +46,7 @@ class MemorySlot(owner: Inventory#Slot, val tier: Int) extends InventorySlot[Mem
override def lmbMenuEnabled: Boolean = true
override def tooltipLine1Color: Color = item.get match {
case tiered: Tiered => tiered.tier match {
case tiered: MultiTiered => tiered.tier match {
case 0 => Color.White
case 1 => Color.White
case 2 => Color.Yellow