mirror of
https://gitlab.com/cc-ru/ocelot/ocelot-desktop.git
synced 2025-12-20 11:09:20 +01:00
parent
633a0e0c4c
commit
8089a17fb6
@ -17,6 +17,8 @@ class SoundBuffer(val file: String) extends Resource with Logging {
|
|||||||
} else {
|
} else {
|
||||||
initFallback()
|
initFallback()
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
logger.debug(s"Skipping loading sound buffer from '$file' because audio is not available")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,28 +1,34 @@
|
|||||||
package ocelot.desktop.ui.widget.slot
|
package ocelot.desktop.ui.widget.slot
|
||||||
|
|
||||||
import ocelot.desktop.audio.{SoundBuffers, SoundCategory, SoundSource}
|
import ocelot.desktop.audio.{Audio, SoundBuffers, SoundCategory, SoundSource}
|
||||||
import ocelot.desktop.graphics.{IconDef, Icons}
|
import ocelot.desktop.graphics.{IconDef, Icons}
|
||||||
import ocelot.desktop.inventory.Inventory
|
import ocelot.desktop.inventory.Inventory
|
||||||
import ocelot.desktop.inventory.item.FloppyItem
|
import ocelot.desktop.inventory.item.FloppyItem
|
||||||
|
|
||||||
class FloppySlotWidget(slot: Inventory#Slot) extends SlotWidget[FloppyItem](slot) {
|
class FloppySlotWidget(slot: Inventory#Slot) extends SlotWidget[FloppyItem](slot) {
|
||||||
private val soundFloppyInsert = SoundSource.fromBuffer(SoundBuffers.MachineFloppyInsert, SoundCategory.Environment)
|
private lazy val soundFloppyInsert =
|
||||||
private val soundFloppyEject = SoundSource.fromBuffer(SoundBuffers.MachineFloppyEject, SoundCategory.Environment)
|
SoundSource.fromBuffer(SoundBuffers.MachineFloppyInsert, SoundCategory.Environment)
|
||||||
|
private lazy val soundFloppyEject = SoundSource.fromBuffer(SoundBuffers.MachineFloppyEject, SoundCategory.Environment)
|
||||||
|
|
||||||
override def ghostIcon: Option[IconDef] = Some(Icons.FloppyIcon)
|
override def ghostIcon: Option[IconDef] = Some(Icons.FloppyIcon)
|
||||||
|
|
||||||
override def onItemAdded(): Unit = {
|
override def onItemAdded(): Unit = {
|
||||||
super.onItemAdded()
|
super.onItemAdded()
|
||||||
// TODO: don't play the sound when loading a workspace
|
// TODO: don't play the sound when loading a workspace
|
||||||
|
if (!Audio.isDisabled) {
|
||||||
soundFloppyInsert.play()
|
soundFloppyInsert.play()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override def onItemRemoved(
|
override def onItemRemoved(
|
||||||
removedItem: FloppyItem,
|
removedItem: FloppyItem,
|
||||||
replacedBy: Option[FloppyItem]
|
replacedBy: Option[FloppyItem],
|
||||||
): Unit = {
|
): Unit = {
|
||||||
super.onItemRemoved(removedItem, replacedBy)
|
super.onItemRemoved(removedItem, replacedBy)
|
||||||
|
|
||||||
// TODO: don't play the sound when loading a workspace
|
// TODO: don't play the sound when loading a workspace
|
||||||
|
if (!Audio.isDisabled) {
|
||||||
soundFloppyEject.play()
|
soundFloppyEject.play()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user