parent
9383bc9803
commit
a01a0215cd
After Width: | Height: | Size: 293 B |
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/handicons.png-8c76520aab77ec37eaad0980d02800ac.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Graphics/UI/handicons.png"
|
||||
dest_files=[ "res://.import/handicons.png-8c76520aab77ec37eaad0980d02800ac.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=false
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
After Width: | Height: | Size: 177 B |
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/selected.png-edb67f7b3e4969e516febc7f79b42937.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Graphics/UI/selected.png"
|
||||
dest_files=[ "res://.import/selected.png-edb67f7b3e4969e516febc7f79b42937.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=false
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
After Width: | Height: | Size: 8.8 KiB |
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/midnight.png-3d811938da348be9b831f07b37a9d5f1.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Graphics/tgstation/midnight.png"
|
||||
dest_files=[ "res://.import/midnight.png-3d811938da348be9b831f07b37a9d5f1.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=false
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
@ -0,0 +1,64 @@
|
||||
extends TextureRect
|
||||
|
||||
class_name UIItemBox
|
||||
|
||||
signal selected(hand)
|
||||
signal used_in_hand()
|
||||
|
||||
enum CurrentHand {
|
||||
None,
|
||||
Left,
|
||||
Right
|
||||
}
|
||||
|
||||
var hovering = false
|
||||
export var selected = false setget set_selected
|
||||
export(CurrentHand) var current_hand = CurrentHand.None setget set_hand
|
||||
|
||||
const LEFT_Y_OFFSET = 0
|
||||
const RIGHT_Y_OFFSET = 10
|
||||
|
||||
onready var hand_icon = $HandIcon
|
||||
|
||||
func _ready():
|
||||
hand_icon.texture = hand_icon.texture.duplicate()
|
||||
set_hand(current_hand)
|
||||
|
||||
func _mouse_hover(inside: bool) -> void:
|
||||
hovering = inside
|
||||
if hovering:
|
||||
self_modulate.a = 1
|
||||
else:
|
||||
self_modulate.a = 0.86
|
||||
|
||||
func set_selected(val: bool) -> void:
|
||||
selected = val
|
||||
$SelectedOverlay.visible = selected
|
||||
|
||||
func set_hand(hand):
|
||||
current_hand = hand
|
||||
if hand_icon != null:
|
||||
match hand:
|
||||
CurrentHand.None:
|
||||
hand_icon.visible = false
|
||||
CurrentHand.Left:
|
||||
hand_icon.visible = true
|
||||
(hand_icon.texture as AtlasTexture).region.position.y = LEFT_Y_OFFSET
|
||||
CurrentHand.Right:
|
||||
hand_icon.visible = true
|
||||
(hand_icon.texture as AtlasTexture).region.position.y = RIGHT_Y_OFFSET
|
||||
|
||||
func _gui_input(event):
|
||||
if event is InputEventMouseButton:
|
||||
var mouse_event = event as InputEventMouseButton
|
||||
if mouse_event.pressed:
|
||||
if mouse_event.button_index == BUTTON_LEFT:
|
||||
if current_hand != CurrentHand.Left:
|
||||
emit_signal("selected", CurrentHand.Left)
|
||||
else:
|
||||
emit_signal("used_in_hand")
|
||||
elif mouse_event.button_index == BUTTON_RIGHT:
|
||||
if current_hand != CurrentHand.Right:
|
||||
emit_signal("selected", CurrentHand.Right)
|
||||
else:
|
||||
emit_signal("used_in_hand")
|
@ -0,0 +1,53 @@
|
||||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://Graphics/tgstation/midnight.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Scenes/UI/Items/ItemBox.gd" type="Script" id=2]
|
||||
[ext_resource path="res://Graphics/UI/selected.png" type="Texture" id=3]
|
||||
[ext_resource path="res://Graphics/UI/handicons.png" type="Texture" id=4]
|
||||
|
||||
[sub_resource type="AtlasTexture" id=1]
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 32, 32, 32, 32 )
|
||||
margin = Rect2( 2, 2, 4, 4 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=2]
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 1, 0, 21, 9 )
|
||||
margin = Rect2( 2, 2, 4, 4 )
|
||||
|
||||
[node name="ItemBox" type="TextureRect"]
|
||||
self_modulate = Color( 1, 1, 1, 0.862745 )
|
||||
margin_left = -1.0
|
||||
margin_right = 35.0
|
||||
margin_bottom = 53.0
|
||||
mouse_default_cursor_shape = 2
|
||||
texture = SubResource( 1 )
|
||||
stretch_mode = 4
|
||||
script = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="SelectedOverlay" type="TextureRect" parent="."]
|
||||
visible = false
|
||||
modulate = Color( 1, 1, 1, 0.5 )
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
mouse_filter = 2
|
||||
texture = ExtResource( 3 )
|
||||
stretch_mode = 4
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HandIcon" type="TextureRect" parent="."]
|
||||
visible = false
|
||||
anchor_right = 1.0
|
||||
margin_left = -0.176781
|
||||
margin_top = -5.0
|
||||
margin_right = -0.176781
|
||||
mouse_filter = 2
|
||||
texture = SubResource( 2 )
|
||||
stretch_mode = 6
|
||||
[connection signal="mouse_entered" from="." to="." method="_mouse_hover" binds= [ true ]]
|
||||
[connection signal="mouse_exited" from="." to="." method="_mouse_hover" binds= [ false ]]
|
Reference in new issue