mirror of
https://gitlab.com/cc-ru/ocelot/ocelot-desktop.git
synced 2026-01-08 04:02:39 +01:00
parent
88f6870aa1
commit
b248c4beeb
@ -76,7 +76,9 @@ case class Rect2D(x: Float, y: Float, w: Float, h: Float) {
|
||||
this
|
||||
}
|
||||
|
||||
def inflate(addition: Float): Rect2D = Rect2D(x - addition, y - addition, w + addition * 2, h + addition * 2)
|
||||
def inflated(dx: Float, dy: Float): Rect2D = Rect2D(x - dx, y - dy, w + dx * 2, h + dy * 2)
|
||||
|
||||
def inflated(delta: Float): Rect2D = inflated(delta, delta)
|
||||
|
||||
def center: Vector2D = {
|
||||
min + (size * 0.5f).toVector
|
||||
|
||||
@ -118,7 +118,7 @@ abstract class LogWidget extends Widget {
|
||||
def border: RGBAColorNorm
|
||||
|
||||
override def draw(g: Graphics): Unit = {
|
||||
val innerBounds = absoluteBounds.inflate(-BorderThickness)
|
||||
val innerBounds = absoluteBounds.inflated(-BorderThickness)
|
||||
g.rect(innerBounds, background)
|
||||
DrawUtils.ring(
|
||||
g,
|
||||
|
||||
@ -462,7 +462,7 @@ class WorkspaceView extends Widget with Persistable with MouseHandler with Hover
|
||||
val validTargets = {
|
||||
nodes.iterator
|
||||
.filter(_ != node)
|
||||
.filter(_.bounds.inflate(20).contains(endpoint))
|
||||
.filter(_.bounds.inflated(20).contains(endpoint))
|
||||
.filter(_.ports.nonEmpty)
|
||||
}
|
||||
|
||||
@ -495,8 +495,8 @@ class WorkspaceView extends Widget with Persistable with MouseHandler with Hover
|
||||
|
||||
for ((node, port) <- Some((node, port)) ++ newConnectionTarget) {
|
||||
val iconBoundsInflate = -(node.bounds.w - 22) / 2
|
||||
g.rect(node.bounds.inflate(-10), RGBAColor(0, 0, 0, 150))
|
||||
g.sprite(port.getIcon, node.bounds.inflate(iconBoundsInflate), port.getColor)
|
||||
g.rect(node.bounds.inflated(-10), RGBAColor(0, 0, 0, 150))
|
||||
g.sprite(port.getIcon, node.bounds.inflated(iconBoundsInflate), port.getColor)
|
||||
drawCenteredConnectionHintLabel(
|
||||
g,
|
||||
node.bounds,
|
||||
|
||||
@ -22,7 +22,7 @@ class ContextMenuSubmenu(
|
||||
override def update(): Unit = {
|
||||
super.update()
|
||||
if (
|
||||
!isClosing && !bounds.inflate(4).contains(UiHandler.mousePosition)
|
||||
!isClosing && !bounds.inflated(4).contains(UiHandler.mousePosition)
|
||||
&& !parentEntry.isHovered
|
||||
) close()
|
||||
}
|
||||
|
||||
@ -218,7 +218,7 @@ class SlotWidget[I <: Item](private val slot: Inventory#Slot)(implicit slotItemT
|
||||
|
||||
case evt @ DragEvent(DragEvent.State.Start, MouseEvent.Button.Left, _) =>
|
||||
val pos = evt.start
|
||||
val iconBounds = bounds.inflate(-2)
|
||||
val iconBounds = bounds.inflated(-2)
|
||||
|
||||
if (iconBounds.contains(pos)) {
|
||||
for (item <- item) {
|
||||
@ -232,7 +232,7 @@ class SlotWidget[I <: Item](private val slot: Inventory#Slot)(implicit slotItemT
|
||||
override final def draw(g: Graphics): Unit = {
|
||||
g.sprite("EmptySlot", bounds)
|
||||
|
||||
val iconBounds = bounds.inflate(-2)
|
||||
val iconBounds = bounds.inflated(-2)
|
||||
|
||||
itemIcon match {
|
||||
case Some(itemIcon) => g.sprite(itemIcon, iconBounds)
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package ocelot.desktop.ui.widget.traits
|
||||
|
||||
import ocelot.desktop.color.Color
|
||||
import ocelot.desktop.geometry.Rect2D
|
||||
import ocelot.desktop.graphics.Graphics
|
||||
import ocelot.desktop.ui.Const.{SlotHighlightAlpha, SlotHighlightAnimationSpeedEnter, SlotHighlightAnimationSpeedLeave}
|
||||
import ocelot.desktop.ui.event.HoverEvent
|
||||
@ -21,11 +22,16 @@ trait HoverHighlight extends Widget with HoverHandler with Updatable {
|
||||
highlightAlpha.goto(0f)
|
||||
}
|
||||
|
||||
protected def highlightBounds: Rect2D = bounds.inflated(-2)
|
||||
|
||||
override def draw(g: Graphics): Unit = {
|
||||
super.draw(g)
|
||||
drawHighlight(g)
|
||||
}
|
||||
|
||||
protected def drawHighlight(g: Graphics): Unit = {
|
||||
if (highlightAlpha.value > 0.005f) {
|
||||
g.rect(bounds.inflate(-2), Color.White.mapA(_ => highlightAlpha.value))
|
||||
g.rect(highlightBounds, Color.White.mapA(_ => highlightAlpha.value))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ package ocelot.desktop.windows
|
||||
import ocelot.desktop.ColorScheme
|
||||
import ocelot.desktop.audio.{ClickSoundSource, SoundSource}
|
||||
import ocelot.desktop.color.Color
|
||||
import ocelot.desktop.geometry.{Padding2D, Size2D}
|
||||
import ocelot.desktop.geometry.{Padding2D, Rect2D, Size2D}
|
||||
import ocelot.desktop.graphics.Graphics
|
||||
import ocelot.desktop.inventory.item.{NetworkCardItem, ServerItem}
|
||||
import ocelot.desktop.node.nodes.RackNode
|
||||
@ -180,10 +180,12 @@ class RackWindow(rackNode: RackNode) extends PanelWindow {
|
||||
val connectableIndex = i
|
||||
val isNetwork = connectableIndex > 0
|
||||
|
||||
children :+= new Button {
|
||||
children :+= new Button with HoverHighlight {
|
||||
override def enabled: Boolean =
|
||||
shouldConnectionBeVisible(mountableSlotWidget, connectableIndex)
|
||||
|
||||
override protected def highlightBounds: Rect2D = bounds.inflated(-2, 0)
|
||||
|
||||
override def minimumSize: Size2D = Size2D(
|
||||
nodeButtonsWidth,
|
||||
if (isNetwork) lineNetworkHeight else lineSideHeight,
|
||||
@ -212,6 +214,7 @@ class RackWindow(rackNode: RackNode) extends PanelWindow {
|
||||
directionToSpriteName("window/rack/Node", direction),
|
||||
bounds,
|
||||
)
|
||||
drawHighlight(g)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -300,4 +303,4 @@ class RackWindow(rackNode: RackNode) extends PanelWindow {
|
||||
),
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user