broken_seals/game/ui/windows/ItemContainer.gd

78 lines
2.8 KiB
GDScript3
Raw Normal View History

extends Control
# Copyright (c) 2019-2020 Péter Magyar
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
export(NodePath) var icon_path : NodePath
export(NodePath) var name_label_path : NodePath
#export(NodePath) var description_label_path : NodePath
export(NodePath) var quantity_spinbox_path : NodePath
export(NodePath) var learn_button_path : NodePath
export(NodePath) var spell_button_path : NodePath
export(NodePath) var popup_path : NodePath
export(Color) var known_color : Color = Color.white
export(Color) var not_known_color : Color = Color.gray
export(Color) var unlearnable_color : Color = Color.gray
var _icon : TextureRect
var _name_label : Label
#var _description_label : RichTextLabel
var _item_button : Button
var _popup : Popup
var _vendor_item_data_entry : VendorItemDataEntry
var _player : Entity
func _ready() -> void:
_icon = get_node(icon_path) as TextureRect
_name_label = get_node(name_label_path) as Label
# _description_label = get_node(description_label_path) as RichTextLabel
_item_button = get_node(spell_button_path) as Button
_popup = get_node(popup_path) as Popup
func set_vendor_item(p_player : Entity, p_vide: VendorItemDataEntry) -> void:
_vendor_item_data_entry = p_vide
_player = p_player
# _icon.set_spell(_spell)
_item_button.set_item(_vendor_item_data_entry)
_popup.set_item(_vendor_item_data_entry)
if _vendor_item_data_entry != null && _vendor_item_data_entry.item != null:
_icon.texture = _vendor_item_data_entry.item.icon
_name_label.text = _vendor_item_data_entry.item.text_name
else:
_icon.texture = null
_name_label.text = "....."
update_spell_indicators()
func spell_button_pressed() -> void:
var pos : Vector2 = _item_button.rect_global_position
pos.x += _item_button.rect_size.x
_popup.popup(Rect2(pos, _popup.rect_size))
func update_spell_indicators():
pass