mirror of
https://gitlab.com/cc-ru/ocelot/ocelot-desktop.git
synced 2025-12-20 02:59:19 +01:00
Add ntoe block particles
This commit is contained in:
parent
a296d56aea
commit
36e60f2892
BIN
sprites/particles/Note.png
Normal file
BIN
sprites/particles/Note.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 573 B |
@ -91,3 +91,29 @@ CheckboxLabel = #333333
|
|||||||
NotificationError = #FF204E
|
NotificationError = #FF204E
|
||||||
NotificationWarning = #ffbf00
|
NotificationWarning = #ffbf00
|
||||||
NotificationInfo = #20A2FF
|
NotificationInfo = #20A2FF
|
||||||
|
|
||||||
|
Note0 = #77D700
|
||||||
|
Note1 = #95C000
|
||||||
|
Note2 = #B2A500
|
||||||
|
Note3 = #CC8600
|
||||||
|
Note4 = #E26500
|
||||||
|
Note5 = #F34100
|
||||||
|
Note6 = #FC1E00
|
||||||
|
Note7 = #FE000F
|
||||||
|
Note8 = #F70033
|
||||||
|
Note9 = #E8005A
|
||||||
|
Note10 = #CF0083
|
||||||
|
Note11 = #AE00A9
|
||||||
|
Note12 = #8600CC
|
||||||
|
Note13 = #5B00E7
|
||||||
|
Note14 = #2D00F9
|
||||||
|
Note15 = #020AFE
|
||||||
|
Note16 = #0037F6
|
||||||
|
Note17 = #0068E0
|
||||||
|
Note18 = #009ABC
|
||||||
|
Note19 = #00C68D
|
||||||
|
Note20 = #00E958
|
||||||
|
Note21 = #00FC21
|
||||||
|
Note22 = #1FFC00
|
||||||
|
Note23 = #59E800
|
||||||
|
Note24 = #94C100
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 64 KiB |
@ -1,5 +1,5 @@
|
|||||||
BackgroundPattern 0 0 304 304
|
BackgroundPattern 0 0 304 304
|
||||||
BarSegment 468 105 16 4
|
BarSegment 476 105 16 4
|
||||||
ComputerMotherboard 305 0 79 70
|
ComputerMotherboard 305 0 79 70
|
||||||
Empty 9 316 1 1
|
Empty 9 316 1 1
|
||||||
EmptySlot 441 147 18 18
|
EmptySlot 441 147 18 18
|
||||||
@ -116,6 +116,7 @@ panel/CornerBR 28 305 4 4
|
|||||||
panel/CornerTL 33 305 4 4
|
panel/CornerTL 33 305 4 4
|
||||||
panel/CornerTR 38 305 4 4
|
panel/CornerTR 38 305 4 4
|
||||||
panel/Fill 6 316 2 2
|
panel/Fill 6 316 2 2
|
||||||
|
particles/Note 468 105 7 10
|
||||||
screen/BorderB 5 305 2 8
|
screen/BorderB 5 305 2 8
|
||||||
screen/BorderT 2 305 2 10
|
screen/BorderT 2 305 2 10
|
||||||
screen/CornerBL 365 236 8 8
|
screen/CornerBL 365 236 8 8
|
||||||
|
|||||||
@ -2,7 +2,6 @@ package ocelot.desktop
|
|||||||
|
|
||||||
import buildinfo.BuildInfo
|
import buildinfo.BuildInfo
|
||||||
import li.flor.nativejfilechooser.NativeJFileChooser
|
import li.flor.nativejfilechooser.NativeJFileChooser
|
||||||
import ocelot.desktop.audio.Audio.NoteBlock
|
|
||||||
import ocelot.desktop.audio.{Audio, SoundCategory, SoundSource}
|
import ocelot.desktop.audio.{Audio, SoundCategory, SoundSource}
|
||||||
import ocelot.desktop.node.nodes.NoteBlockNode
|
import ocelot.desktop.node.nodes.NoteBlockNode
|
||||||
import ocelot.desktop.ui.UiHandler
|
import ocelot.desktop.ui.UiHandler
|
||||||
@ -380,6 +379,9 @@ object OcelotDesktop extends Logging {
|
|||||||
|
|
||||||
EventBus.subscribe[NoteBlockTriggerEvent] { event =>
|
EventBus.subscribe[NoteBlockTriggerEvent] { event =>
|
||||||
new SoundSource(Audio.NoteBlock(event.instrument), SoundCategory.Beep, pitch = NoteBlockNode.pitches(event.pitch)).playAndFree()
|
new SoundSource(Audio.NoteBlock(event.instrument), SoundCategory.Beep, pitch = NoteBlockNode.pitches(event.pitch)).playAndFree()
|
||||||
|
UiHandler.root.workspaceView.nodes.find(_.environment.node.address == event.address).get
|
||||||
|
.asInstanceOf[NoteBlockNode]
|
||||||
|
.addParticle(event.pitch)
|
||||||
}
|
}
|
||||||
|
|
||||||
val soundFloppyAccess = Audio.MachineFloppyAccess.map(buffer => new SoundSource(buffer, SoundCategory.Environment))
|
val soundFloppyAccess = Audio.MachineFloppyAccess.map(buffer => new SoundSource(buffer, SoundCategory.Environment))
|
||||||
|
|||||||
@ -278,6 +278,8 @@ trait Node extends Widget with DragHandler with ClickHandler with HoverHandler {
|
|||||||
g.setNormalFont()
|
g.setNormalFont()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def drawParticles(g: Graphics): Unit = {}
|
||||||
|
|
||||||
def drawPorts(g: Graphics): Unit = {
|
def drawPorts(g: Graphics): Unit = {
|
||||||
for ((port, rects) <- portsBounds) {
|
for ((port, rects) <- portsBounds) {
|
||||||
val color = port.getColor
|
val color = port.getColor
|
||||||
|
|||||||
@ -1,17 +1,23 @@
|
|||||||
package ocelot.desktop.node.nodes
|
package ocelot.desktop.node.nodes
|
||||||
|
|
||||||
|
import ocelot.desktop.ColorScheme
|
||||||
|
import ocelot.desktop.color.Color
|
||||||
|
import ocelot.desktop.geometry.{Size2D, Vector2D}
|
||||||
|
import ocelot.desktop.graphics.Graphics
|
||||||
import ocelot.desktop.node.Node
|
import ocelot.desktop.node.Node
|
||||||
|
import ocelot.desktop.ui.UiHandler
|
||||||
import ocelot.desktop.ui.widget.contextmenu.{ContextMenu, ContextMenuEntry, ContextMenuSubmenu}
|
import ocelot.desktop.ui.widget.contextmenu.{ContextMenu, ContextMenuEntry, ContextMenuSubmenu}
|
||||||
import totoro.ocelot.brain.entity.NoteBlock
|
import totoro.ocelot.brain.entity.NoteBlock
|
||||||
import totoro.ocelot.brain.entity.traits.Environment
|
import totoro.ocelot.brain.entity.traits.Environment
|
||||||
|
|
||||||
|
import scala.collection.mutable
|
||||||
|
|
||||||
class NoteBlockNode(val noteBlock: NoteBlock) extends Node {
|
class NoteBlockNode(val noteBlock: NoteBlock) extends Node {
|
||||||
override def environment: Environment = noteBlock
|
override def environment: Environment = noteBlock
|
||||||
|
|
||||||
override def icon: String = "nodes/NoteBlock"
|
override def icon: String = "nodes/NoteBlock"
|
||||||
|
|
||||||
override def setupContextMenu(menu: ContextMenu): Unit = {
|
override def setupContextMenu(menu: ContextMenu): Unit = {
|
||||||
|
|
||||||
menu.addEntry(new ContextMenuSubmenu("Instrument") {
|
menu.addEntry(new ContextMenuSubmenu("Instrument") {
|
||||||
{
|
{
|
||||||
val maxLen = NoteBlockNode.instruments.map(_._2.length).max
|
val maxLen = NoteBlockNode.instruments.map(_._2.length).max
|
||||||
@ -25,6 +31,23 @@ class NoteBlockNode(val noteBlock: NoteBlock) extends Node {
|
|||||||
menu.addSeparator()
|
menu.addSeparator()
|
||||||
super.setupContextMenu(menu)
|
super.setupContextMenu(menu)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val particles = mutable.ArrayBuffer[(Float, Int)]()
|
||||||
|
|
||||||
|
def addParticle(pitch: Int): Unit = {
|
||||||
|
synchronized {
|
||||||
|
particles += ((0f, pitch))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override def drawParticles(g: Graphics): Unit = synchronized {
|
||||||
|
for ((time, pitch) <- particles.reverseIterator) {
|
||||||
|
val col = ColorScheme("Note" + pitch).withAlpha(1 - (2 * time - 1).min(1).max(0))
|
||||||
|
g.sprite("particles/Note", position + Vector2D(pitch / 24f * 40f + 5, height / 2 - 10 - 100 * time), Size2D(14, 20), col)
|
||||||
|
}
|
||||||
|
particles.mapInPlace { case (t, p) => (t + 1.2f * UiHandler.dt, p) }
|
||||||
|
particles.filterInPlace(_._1 <= 1f)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object NoteBlockNode {
|
object NoteBlockNode {
|
||||||
|
|||||||
@ -469,6 +469,7 @@ class WorkspaceView extends Widget with DragHandler with ClickHandler with Hover
|
|||||||
|
|
||||||
nodes.foreach(_.draw(g))
|
nodes.foreach(_.draw(g))
|
||||||
nodes.foreach(_.drawLabel(g))
|
nodes.foreach(_.drawLabel(g))
|
||||||
|
nodes.foreach(_.drawParticles(g))
|
||||||
|
|
||||||
portsAlpha.update()
|
portsAlpha.update()
|
||||||
portsAlpha.goto(if (newConnection.isDefined) 1 else 0)
|
portsAlpha.goto(if (newConnection.isDefined) 1 else 0)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user