Continue IconSource refactoring

This commit is contained in:
Fingercomp 2025-08-12 15:20:27 +03:00
parent b759846505
commit 9ce89c2b58
No known key found for this signature in database
GPG Key ID: BBC71CEE45D86E37
12 changed files with 127 additions and 123 deletions

View File

@ -14,99 +14,75 @@ case class IconSource(
)
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 SideNoneIcon: IconSource = IconSource("icons/SideNone")
val SideAnyIcon: IconSource = IconSource("icons/SideAny")
val SideUndefinedIcon: IconSource = IconSource("icons/SideUndefined")
val SideIcon: Direction => IconSource = {
case Down => IconSource(s"icons/SideDown")
case Up => IconSource(s"icons/SideUp")
case North => IconSource(s"icons/SideNorth")
case South => IconSource(s"icons/SideSouth")
case West => IconSource(s"icons/SideWest")
case East => IconSource(s"icons/SideEast")
case _ => SideUndefinedIcon
}
object Items {
protected val prefix: String = "items"
val Cpu: Tier => IconSource = { tier =>
IconSource(s"items/CPU${tier.id}")
IconSource(s"$prefix/CPU${tier.id}")
}
val Apu: Tier => IconSource = { tier =>
IconSource(s"items/APU${tier.id}", animation = Some(Animations.Apu))
IconSource(s"$prefix/APU${tier.id}", animation = Some(Animations.Apu))
}
val GraphicsCard: Tier => IconSource = { tier =>
IconSource(s"items/GraphicsCard${tier.id}")
IconSource(s"$prefix/GraphicsCard${tier.id}")
}
val NetworkCard: IconSource = IconSource("items/NetworkCard")
val NetworkCard: IconSource = IconSource(s"$prefix/NetworkCard")
val WirelessNetworkCard: Tier => IconSource = { tier =>
IconSource(s"items/WirelessNetworkCard${tier.id}")
IconSource(s"$prefix/WirelessNetworkCard${tier.id}")
}
val LinkedCard: IconSource = IconSource("items/LinkedCard", animation = Some(Animations.LinkedCard))
val LinkedCard: IconSource = IconSource(s"$prefix/LinkedCard", animation = Some(Animations.LinkedCard))
val InternetCard: IconSource = IconSource("items/InternetCard", animation = Some(Animations.InternetCard))
val InternetCard: IconSource = IconSource(s"$prefix/InternetCard", animation = Some(Animations.InternetCard))
val RedstoneCard: Tier => IconSource = { tier =>
IconSource(s"items/RedstoneCard${tier.id}")
IconSource(s"$prefix/RedstoneCard${tier.id}")
}
val DataCard: Tier => IconSource = { tier =>
IconSource(s"items/DataCard${tier.id}", animation = Some(Animations.DataCard))
IconSource(s"$prefix/DataCard${tier.id}", animation = Some(Animations.DataCard))
}
val SoundCard: IconSource = IconSource("items/SoundCard", animation = Some(Animations.DataCard))
val SoundCard: IconSource = IconSource(s"$prefix/SoundCard", animation = Some(Animations.DataCard))
val SelfDestructingCard: IconSource =
IconSource("items/SelfDestructingCard", animation = Some(Animations.SelfDestructingCard))
IconSource(s"$prefix/SelfDestructingCard", animation = Some(Animations.SelfDestructingCard))
val OcelotCard: IconSource = IconSource("items/OcelotCard", animation = Some(Animations.OcelotCard))
val OcelotCard: IconSource = IconSource(s"$prefix/OcelotCard", animation = Some(Animations.OcelotCard))
val HardDiskDrive: Tier => IconSource = { tier =>
IconSource(s"items/HardDiskDrive${tier.id}")
IconSource(s"$prefix/HardDiskDrive${tier.id}")
}
val Eeprom: IconSource = IconSource("items/EEPROM")
val Eeprom: IconSource = IconSource(s"$prefix/EEPROM")
val FloppyDisk: DyeColor => IconSource = { color =>
IconSource(s"items/FloppyDisk_${color.name}")
IconSource(s"$prefix/FloppyDisk_${color.name}")
}
val Memory: ExtendedTier => IconSource = { tier =>
IconSource(s"items/Memory${tier.id}")
IconSource(s"$prefix/Memory${tier.id}")
}
val Server: Tier => IconSource = { tier =>
IconSource(s"items/Server${tier.id}")
IconSource(s"$prefix/Server${tier.id}")
}
val ComponentBus: Tier => IconSource = { tier =>
IconSource(s"items/ComponentBus${tier.id}")
IconSource(s"$prefix/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")
case kind => IconSource(s"$prefix/Tape$kind")
}
val DiskDriveMountable: IconSource = IconSource("items/DiskDriveMountable")
val DiskDriveMountable: IconSource = IconSource(s"$prefix/DiskDriveMountable")
// noinspection ScalaWeakerAccess
object Animations {
@ -138,11 +114,6 @@ object IconSource {
// ----------------------- Ocelot interface icons -----------------------
object Icons {
val Notification: NotificationType => IconSource = { notificationType =>
IconSource(s"icons/Notification$notificationType")
}
val Loading: IconSource = IconSource(
"Loading",
animation = Some(Animation(
@ -164,49 +135,82 @@ object IconSource {
)),
)
val SettingsKeymap: IconSource = IconSource("icons/SettingsKeymap")
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")
val ButtonRandomize: IconSource = IconSource("icons/ButtonRandomize")
val ButtonClipboard: IconSource = IconSource("icons/ButtonClipboard")
val ButtonCheck: IconSource = IconSource("icons/ButtonCheck")
val Home: IconSource = IconSource("icons/Home")
val Pin: IconSource = IconSource("icons/Pin")
val Unpin: IconSource = IconSource("icons/Unpin")
val Close: IconSource = IconSource("icons/Close")
val Grid: IconSource = IconSource("icons/Grid")
val GridOff: IconSource = IconSource("icons/GridOff")
object Icons {
protected val prefix: String = "icons"
val Card: IconSource = IconSource(s"$prefix/Card")
val Cpu: IconSource = IconSource(s"$prefix/CPU")
val Hdd: IconSource = IconSource(s"$prefix/HDD")
val Eeprom: IconSource = IconSource(s"$prefix/EEPROM")
val Floppy: IconSource = IconSource(s"$prefix/Floppy")
val Memory: IconSource = IconSource(s"$prefix/Memory")
val Server: IconSource = IconSource(s"$prefix/Server")
val ComponentBus: IconSource = IconSource(s"$prefix/ComponentBus")
val Tier: Tier => IconSource = { tier =>
IconSource(s"$prefix/Tier${tier.id}")
}
val SideNone: IconSource = IconSource(s"$prefix/SideNone")
val SideAny: IconSource = IconSource(s"$prefix/SideAny")
val SideUndefined: IconSource = IconSource(s"$prefix/SideUndefined")
val Side: Direction => IconSource = {
case Down => IconSource(s"$prefix/SideDown")
case Up => IconSource(s"$prefix/SideUp")
case North => IconSource(s"$prefix/SideNorth")
case South => IconSource(s"$prefix/SideSouth")
case West => IconSource(s"$prefix/SideWest")
case East => IconSource(s"$prefix/SideEast")
case _ => SideUndefined
}
val Notification: NotificationType => IconSource = { notificationType =>
IconSource(s"$prefix/Notification$notificationType")
}
val SettingsKeymap: IconSource = IconSource(s"$prefix/SettingsKeymap")
val SettingsSystem: IconSource = IconSource(s"$prefix/SettingsSystem")
val SettingsSound: IconSource = IconSource(s"$prefix/SettingsSound")
val SettingsUI: IconSource = IconSource(s"$prefix/SettingsUI")
val Delete: IconSource = IconSource(s"$prefix/Delete")
val Label: IconSource = IconSource(s"$prefix/Label")
val Copy: IconSource = IconSource(s"$prefix/Copy")
val AspectRatio: IconSource = IconSource(s"$prefix/AspectRatio")
val Eject: IconSource = IconSource(s"$prefix/Eject")
val Restart: IconSource = IconSource(s"$prefix/Restart")
val Edit: IconSource = IconSource(s"$prefix/Edit")
val Folder: IconSource = IconSource(s"$prefix/Folder")
val FolderSlash: IconSource = IconSource(s"$prefix/FolderSlash")
val Code: IconSource = IconSource(s"$prefix/Code")
val File: IconSource = IconSource(s"$prefix/File")
val Link: IconSource = IconSource(s"$prefix/Link")
val LinkSlash: IconSource = IconSource(s"$prefix/LinkSlash")
val Power: IconSource = IconSource(s"$prefix/Power")
val Save: IconSource = IconSource(s"$prefix/Save")
val SaveAs: IconSource = IconSource(s"$prefix/SaveAs")
val Plus: IconSource = IconSource(s"$prefix/Plus")
val Cross: IconSource = IconSource(s"$prefix/Cross")
val Microchip: IconSource = IconSource(s"$prefix/Microchip")
val Antenna: IconSource = IconSource(s"$prefix/Antenna")
val Window: IconSource = IconSource(s"$prefix/Window")
val Tiers: IconSource = IconSource(s"$prefix/Tiers")
val LinesHorizontal: IconSource = IconSource(s"$prefix/LinesHorizontal")
val ArrowRight: IconSource = IconSource(s"$prefix/ArrowRight")
val Book: IconSource = IconSource(s"$prefix/Book")
val Help: IconSource = IconSource(s"$prefix/Help")
val Ocelot: IconSource = IconSource(s"$prefix/Ocelot")
val Guitar: IconSource = IconSource(s"$prefix/Guitar")
val Keyboard: IconSource = IconSource(s"$prefix/Keyboard")
val KeyboardOff: IconSource = IconSource(s"$prefix/KeyboardOff")
val ButtonRandomize: IconSource = IconSource(s"$prefix/ButtonRandomize")
val ButtonClipboard: IconSource = IconSource(s"$prefix/ButtonClipboard")
val ButtonCheck: IconSource = IconSource(s"$prefix/ButtonCheck")
val Home: IconSource = IconSource(s"$prefix/Home")
val Pin: IconSource = IconSource(s"$prefix/Pin")
val Unpin: IconSource = IconSource(s"$prefix/Unpin")
val Close: IconSource = IconSource(s"$prefix/Close")
val Grid: IconSource = IconSource(s"$prefix/Grid")
val GridOff: IconSource = IconSource(s"$prefix/GridOff")
}
// ----------------------- Node icons -----------------------

View File

@ -17,8 +17,8 @@ case class NodePort(direction: Option[Direction.Value] = None) extends Ordered[N
}
def getIcon: IconSource = direction match {
case Some(direction) => IconSource.SideIcon(direction)
case None => IconSource.SideAnyIcon
case Some(direction) => IconSource.Icons.Side(direction)
case None => IconSource.Icons.SideAny
}
override def compare(that: NodePort): Int = this.direction.compare(that.direction)

View File

@ -46,7 +46,7 @@ class UpdateCheckerDialog extends ModalDialog with Logging {
// loading screen
container.children :+= new Label("Checking development news...")
container.children :+= new PaddingBox(new Icon(IconSource.Icons.Loading, color = ColorScheme("Label")),
container.children :+= new PaddingBox(new Icon(IconSource.Loading, color = ColorScheme("Label")),
Padding2D(16, 0, 0, 90))
// check the API

View File

@ -6,6 +6,6 @@ import ocelot.desktop.inventory.traits.CardItem
import totoro.ocelot.brain.util.Tier.Tier
class CardSlotWidget(slot: Inventory#Slot, _tier: Tier) extends SlotWidget[CardItem](slot) {
override def ghostIcon: Option[IconSource] = Some(IconSource.CardIcon)
override def ghostIcon: Option[IconSource] = Some(IconSource.Icons.Card)
override def slotTier: Option[Tier] = Some(_tier)
}

View File

@ -6,6 +6,6 @@ import ocelot.desktop.inventory.item.ComponentBusItem
import totoro.ocelot.brain.util.Tier.Tier
class ComponentBusSlotWidget(slot: Inventory#Slot, _tier: Tier) extends SlotWidget[ComponentBusItem](slot) {
override def ghostIcon: Option[IconSource] = Some(IconSource.ComponentBusIcon)
override def ghostIcon: Option[IconSource] = Some(IconSource.Icons.ComponentBus)
override def slotTier: Option[Tier] = Some(_tier)
}

View File

@ -6,6 +6,6 @@ import ocelot.desktop.inventory.traits.CpuLikeItem
import totoro.ocelot.brain.util.Tier.Tier
class CpuSlotWidget(slot: Inventory#Slot, _tier: Tier) extends SlotWidget[CpuLikeItem](slot) {
override def ghostIcon: Option[IconSource] = Some(IconSource.CpuIcon)
override def ghostIcon: Option[IconSource] = Some(IconSource.Icons.Cpu)
override def slotTier: Option[Tier] = Some(_tier)
}

View File

@ -5,5 +5,5 @@ import ocelot.desktop.inventory.Inventory
import ocelot.desktop.inventory.item.EepromItem
class EepromSlotWidget(slot: Inventory#Slot) extends SlotWidget[EepromItem](slot) {
override def ghostIcon: Option[IconSource] = Some(IconSource.EepromIcon)
override def ghostIcon: Option[IconSource] = Some(IconSource.Icons.Eeprom)
}

View File

@ -6,7 +6,7 @@ import ocelot.desktop.inventory.Inventory
import ocelot.desktop.inventory.item.FloppyItem
class FloppySlotWidget(slot: Inventory#Slot) extends SlotWidget[FloppyItem](slot) {
override def ghostIcon: Option[IconSource] = Some(IconSource.FloppyIcon)
override def ghostIcon: Option[IconSource] = Some(IconSource.Icons.Floppy)
override def onItemAdded(): Unit = {
super.onItemAdded()

View File

@ -6,6 +6,6 @@ import ocelot.desktop.inventory.item.HddItem
import totoro.ocelot.brain.util.Tier.Tier
class HddSlotWidget(slot: Inventory#Slot, _tier: Tier) extends SlotWidget[HddItem](slot) {
override def ghostIcon: Option[IconSource] = Some(IconSource.HddIcon)
override def ghostIcon: Option[IconSource] = Some(IconSource.Icons.Hdd)
override def slotTier: Option[Tier] = Some(_tier)
}

View File

@ -6,6 +6,6 @@ import ocelot.desktop.inventory.item.MemoryItem
import totoro.ocelot.brain.util.Tier.Tier
class MemorySlotWidget(slot: Inventory#Slot, _tier: Tier) extends SlotWidget[MemoryItem](slot) {
override def ghostIcon: Option[IconSource] = Some(IconSource.MemoryIcon)
override def ghostIcon: Option[IconSource] = Some(IconSource.Icons.Memory)
override def slotTier: Option[Tier] = Some(_tier)
}

View File

@ -6,7 +6,7 @@ import ocelot.desktop.inventory.item.ServerItem
import ocelot.desktop.inventory.traits.RackMountableItem
class RackMountableSlotWidget(slot: Inventory#Slot) extends SlotWidget[RackMountableItem](slot) {
override def ghostIcon: Option[IconSource] = Some(IconSource.ServerIcon)
override def ghostIcon: Option[IconSource] = Some(IconSource.Icons.Server)
override def onItemRemoved(removedItem: RackMountableItem, replacedBy: Option[RackMountableItem]): Unit = {
super.onItemRemoved(removedItem, replacedBy)

View File

@ -57,7 +57,7 @@ class SlotWidget[I <: Item](private val slot: Inventory#Slot)(implicit slotItemT
def slotTier: Option[Tier] = None
def tierIcon: Option[IconSource] = slotTier.map(IconSource.TierIcon)
def tierIcon: Option[IconSource] = slotTier.map(IconSource.Icons.Tier)
def itemIcon: Option[IconSource] = item.map(_.icon)