2024-03-11 17:55:13 +01:00

172 lines
6.5 KiB
Scala

package ocelot.desktop.graphics
import ocelot.desktop.geometry.Size2D
import ocelot.desktop.ui.widget.modal.notification.NotificationType.NotificationType
import totoro.ocelot.brain.entity.tape.Tape.{Kind => TapeKind}
import totoro.ocelot.brain.util.DyeColor
import totoro.ocelot.brain.util.ExtendedTier.ExtendedTier
import totoro.ocelot.brain.util.Tier.Tier
case class IconSource(
path: String,
animation: Option[IconSource.Animation] = None
)
object IconSource {
val CardIcon: IconSource = IconSource("icons/Card")
val CpuIcon: IconSource = IconSource("icons/CPU")
val HddIcon: IconSource = IconSource("icons/HDD")
val EepromIcon: IconSource = IconSource("icons/EEPROM")
val FloppyIcon: IconSource = IconSource("icons/Floppy")
val MemoryIcon: IconSource = IconSource("icons/Memory")
val ServerIcon: IconSource = IconSource("icons/Server")
val ComponentBusIcon: IconSource = IconSource("icons/ComponentBus")
val TierIcon: Tier => IconSource = { tier =>
IconSource(s"icons/Tier${tier.id}")
}
val Cpu: Tier => IconSource = { tier =>
IconSource(s"items/CPU${tier.id}")
}
val Apu: Tier => IconSource = { tier =>
IconSource(s"items/APU${tier.id}", animation = Some(Animations.Apu))
}
val GraphicsCard: Tier => IconSource = { tier =>
IconSource(s"items/GraphicsCard${tier.id}")
}
val NetworkCard: IconSource = IconSource("items/NetworkCard")
val WirelessNetworkCard: Tier => IconSource = { tier =>
IconSource(s"items/WirelessNetworkCard${tier.id}")
}
val LinkedCard: IconSource = IconSource("items/LinkedCard", animation = Some(Animations.LinkedCard))
val InternetCard: IconSource = IconSource("items/InternetCard", animation = Some(Animations.InternetCard))
val RedstoneCard: Tier => IconSource = { tier =>
IconSource(s"items/RedstoneCard${tier.id}")
}
val DataCard: Tier => IconSource = { tier =>
IconSource(s"items/DataCard${tier.id}", animation = Some(Animations.DataCard))
}
val SoundCard: IconSource = IconSource("items/SoundCard", animation = Some(Animations.DataCard))
val SelfDestructingCard: IconSource = IconSource("items/SelfDestructingCard", animation = Some(Animations.SelfDestructingCard))
val OcelotCard: IconSource = IconSource("items/OcelotCard", animation = Some(Animations.OcelotCard))
val HardDiskDrive: Tier => IconSource = { tier =>
IconSource(s"items/HardDiskDrive${tier.id}")
}
val Eeprom: IconSource = IconSource("items/EEPROM")
val FloppyDisk: DyeColor => IconSource = { color =>
IconSource(s"items/FloppyDisk_${color.name}")
}
val Memory: ExtendedTier => IconSource = { tier =>
IconSource(s"items/Memory${tier.id}")
}
val Server: Tier => IconSource = { tier =>
IconSource(s"items/Server${tier.id}")
}
val ComponentBus: Tier => IconSource = { tier =>
IconSource(s"items/ComponentBus${tier.id}")
}
val Tape: TapeKind => IconSource = {
case TapeKind.Golder => Tape(TapeKind.Gold)
case TapeKind.NetherStarrer => Tape(TapeKind.NetherStar)
case kind => IconSource(s"items/Tape$kind")
}
val DiskDriveMountable: IconSource = IconSource("items/DiskDriveMountable")
//noinspection ScalaWeakerAccess
object Animations {
val Apu: Animation = Animation(
(0, 3f), (1, 3f), (2, 3f), (3, 3f), (4, 3f), (5, 3f),
(4, 3f), (3, 3f), (2, 3f), (1, 3f), (0, 3f))
val LinkedCard: Animation =
Animation((0, 3f), (1, 3f), (2, 3f), (3, 3f), (4, 3f), (5, 3f))
val InternetCard: Animation = Animation(
(0, 2f), (1, 7f), (0, 5f), (1, 4f), (0, 7f), (1, 2f), (0, 8f),
(1, 9f), (0, 6f), (1, 4f))
val DataCard: Animation = Animation(
(0, 4f), (1, 4f), (2, 4f), (3, 4f), (4, 4f), (5, 4f), (6, 4f), (7, 4f))
val SelfDestructingCard: Animation = Animation((0, 4f), (1, 4f))
val OcelotCard: Animation = Animation(
(0, 12f), (1, 4f), (2, 4f), (3, 4f), (4, 5f), (5, 6f), (0, 9f), (6, 4f), (7, 3f))
val Loading: Animation = Animation(Size2D(48, 32),
(0, 0.7f), (1, 0.7f), (2, 0.7f), (3, 0.7f), (4, 0.7f), (5, 0.7f), (6, 0.7f),
(7, 0.7f), (8, 0.7f), (9, 0.7f), (10, 0.7f), (11, 0.7f), (12, 0.7f), (13, 0.7f)
)
}
case class Animation(frames: Array[(Int, Float)], frameSize: Option[Size2D])
object Animation {
def apply(frames: (Int, Float)*) = new Animation(frames.toArray, None)
def apply(size: Size2D, frames: (Int, Float)*) = new Animation(frames.toArray, Some(size))
def apply(size: Option[Size2D] = None, frames: Array[(Int, Float)]) = new Animation(frames, size)
}
// ----------------------- Ocelot interface icons -----------------------
val Notification: NotificationType => IconSource = { notificationType =>
IconSource(s"icons/Notification$notificationType")
}
val Loading: IconSource = IconSource("Loading", animation = Some(Animations.Loading))
val SettingsSystem: IconSource = IconSource("icons/SettingsSystem")
val SettingsSound: IconSource = IconSource("icons/SettingsSound")
val SettingsUI: IconSource = IconSource("icons/SettingsUI")
val Delete: IconSource = IconSource("icons/Delete")
val Label: IconSource = IconSource("icons/Label")
val Copy: IconSource = IconSource("icons/Copy")
val AspectRatio: IconSource = IconSource("icons/AspectRatio")
val Eject: IconSource = IconSource("icons/Eject")
val Restart: IconSource = IconSource("icons/Restart")
val Edit: IconSource = IconSource("icons/Edit")
val Folder: IconSource = IconSource("icons/Folder")
val FolderSlash: IconSource = IconSource("icons/FolderSlash")
val Code: IconSource = IconSource("icons/Code")
val File: IconSource = IconSource("icons/File")
val Link: IconSource = IconSource("icons/Link")
val LinkSlash: IconSource = IconSource("icons/LinkSlash")
val Power: IconSource = IconSource("icons/Power")
val Save: IconSource = IconSource("icons/Save")
val SaveAs: IconSource = IconSource("icons/SaveAs")
val Plus: IconSource = IconSource("icons/Plus")
val Cross: IconSource = IconSource("icons/Cross")
val Microchip: IconSource = IconSource("icons/Microchip")
val Antenna: IconSource = IconSource("icons/Antenna")
val Window: IconSource = IconSource("icons/Window")
val Tiers: IconSource = IconSource("icons/Tiers")
val LinesHorizontal: IconSource = IconSource("icons/LinesHorizontal")
val ArrowRight: IconSource = IconSource("icons/ArrowRight")
val Book: IconSource = IconSource("icons/Book")
val Help: IconSource = IconSource("icons/Help")
val Ocelot: IconSource = IconSource("icons/Ocelot")
val Guitar: IconSource = IconSource("icons/Guitar")
val Keyboard: IconSource = IconSource("icons/Keyboard")
val KeyboardOff: IconSource = IconSource("icons/KeyboardOff")
}