Implemented the vendor window (buying items are not yet implemented). Also added and spawned a test vendor. Updated ESS to get the required enum value.

This commit is contained in:
Relintai 2020-09-13 17:08:52 +02:00
parent 980725ccd3
commit f68e3e1054
16 changed files with 713 additions and 18 deletions

2
HEADS
View File

@ -1 +1 @@
{"engine": {"3.2": "36b746d90393299b81ecb991f4aa94a8d742fd11", "master": "8c73e813134001e575b6f59e3b0100471c007410"}, "world_generator": {"master": "c7a98e704dd62782b9f8b4a22b74787278574657"}, "entity_spell_system": {"master": "0a1e08f5417cecda5a1163063bf42c325d078cfe"}, "ui_extensions": {"master": "ca7df8435154d1146be36c4fc97e6cc7092d3eb9"}, "voxelman": {"master": "6f8e54879bcab6c628c761b545f6df4cd7534a07"}, "texture_packer": {"master": "f98b7410cd3f2a743cb57456910ad9f93ef89937"}, "fastnoise": {"master": "d0e3f1c759332cf0d9a5d7e0e71d0b0278310651"}, "mesh_data_resource": {"master": "6c99ddcaa6203e77163b4770e7af95bc2a181e3d"}, "procedural_animations": {"master": "ec465a7a683a047cd373959bb022bde1321fb72d"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}, "props": {"master": "bfb60df21570415b1860c25c2dae7722cf158ed9"}, "mesh_utils": {"master": "3365df3faf89a4c29c3b4664b53e9007e4e6267b"}, "broken_seals_module": {"master": "9f89e2a4e7b59351ac4cb4c4dc5f88e5b60a2f15"}, "thread_pool": {"master": "b1030eaf92ba595c56ae8caac90b58081303d16f"}}
{"engine": {"3.2": "36b746d90393299b81ecb991f4aa94a8d742fd11", "master": "8c73e813134001e575b6f59e3b0100471c007410"}, "world_generator": {"master": "c7a98e704dd62782b9f8b4a22b74787278574657"}, "entity_spell_system": {"master": "cf95db4a7571b443ade0b8fa1149354ffd044439"}, "ui_extensions": {"master": "ca7df8435154d1146be36c4fc97e6cc7092d3eb9"}, "voxelman": {"master": "6f8e54879bcab6c628c761b545f6df4cd7534a07"}, "texture_packer": {"master": "f98b7410cd3f2a743cb57456910ad9f93ef89937"}, "fastnoise": {"master": "d0e3f1c759332cf0d9a5d7e0e71d0b0278310651"}, "mesh_data_resource": {"master": "6c99ddcaa6203e77163b4770e7af95bc2a181e3d"}, "procedural_animations": {"master": "ec465a7a683a047cd373959bb022bde1321fb72d"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}, "props": {"master": "bfb60df21570415b1860c25c2dae7722cf158ed9"}, "mesh_utils": {"master": "3365df3faf89a4c29c3b4664b53e9007e4e6267b"}, "broken_seals_module": {"master": "9f89e2a4e7b59351ac4cb4c4dc5f88e5b60a2f15"}, "thread_pool": {"master": "b1030eaf92ba595c56ae8caac90b58081303d16f"}}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,48 @@
[gd_resource type="EntityData" load_steps=11 format=2]
[ext_resource path="res://scripts/entities/EntityDataGD.gd" type="Script" id=1]
[ext_resource path="res://modules/species/species_human.tres" type="EntitySpeciesData" id=2]
[ext_resource path="res://modules/entity_classes/naturalist/1_naturalist.tres" type="EntityClassData" id=3]
[ext_resource path="res://modules/core/item_templates/3_chest_of_the_infinite_wisdom.tres" type="ItemTemplate" id=4]
[ext_resource path="res://modules/core/item_templates/2_test.tres" type="ItemTemplate" id=5]
[sub_resource type="SimpleLevelStatData" id=1]
agility = 3
strength = 2
stamina = 3
intellect = 4
spirit = 5
[sub_resource type="StatData" id=2]
level_stat_data = SubResource( 1 )
stat/agility = 14.0
stat/strength = 15.0
stat/stamina = 13.0
stat/intellect = 13.0
stat/spirit = 10.0
stat/health = 20.0
stat/mana = 20.0
stat/global_cooldown = 1.5
[sub_resource type="VendorItemDataEntry" id=3]
item = ExtResource( 5 )
count = 1
[sub_resource type="VendorItemDataEntry" id=4]
item = ExtResource( 4 )
count = 1
[sub_resource type="VendorItemData" id=5]
vendor_datas = [ SubResource( 3 ), SubResource( 4 ) ]
[resource]
resource_name = "Naturalist Vendor"
id = 3
entity_type = 4
entity_interaction_type = 5
text_name = "Naturalist Vendor"
stat_data = SubResource( 2 )
entity_species_data = ExtResource( 2 )
entity_class_data = ExtResource( 3 )
vendor_item_data = SubResource( 5 )
script = ExtResource( 1 )

View File

@ -1,4 +1,4 @@
[gd_resource type="ESSResourceDBStatic" load_steps=51 format=2]
[gd_resource type="ESSResourceDBStatic" load_steps=52 format=2]
[ext_resource path="res://modules/entity_classes/naturalist/spells/16_close_wounds_rank_1.tres" type="Spell" id=1]
[ext_resource path="res://modules/entity_classes/naturalist/auras/16_ironbark_rank_1.tres" type="Aura" id=2]
@ -50,8 +50,9 @@
[ext_resource path="res://modules/entity_classes/naturalist/specs/melee/talent_strike_r3.tres" type="Aura" id=48]
[ext_resource path="res://modules/entity_classes/naturalist/specs/melee/talent_strike_r2.tres" type="Aura" id=49]
[ext_resource path="res://modules/entity_classes/naturalist/entities/3_naturalist_trainer.tres" type="EntityData" id=50]
[ext_resource path="res://modules/entity_classes/naturalist/entities/4_naturalist_vendor.tres" type="EntityData" id=51]
[resource]
entity_datas = [ ExtResource( 36 ), ExtResource( 35 ), ExtResource( 50 ) ]
entity_datas = [ ExtResource( 36 ), ExtResource( 35 ), ExtResource( 50 ), ExtResource( 51 ) ]
spells = [ ExtResource( 11 ), ExtResource( 5 ), ExtResource( 25 ), ExtResource( 9 ), ExtResource( 23 ), ExtResource( 33 ), ExtResource( 1 ), ExtResource( 13 ), ExtResource( 34 ), ExtResource( 4 ), ExtResource( 30 ), ExtResource( 28 ), ExtResource( 27 ), ExtResource( 31 ), ExtResource( 14 ), ExtResource( 32 ), ExtResource( 26 ), ExtResource( 18 ), ExtResource( 20 ), ExtResource( 19 ), ExtResource( 22 ), ExtResource( 37 ), ExtResource( 38 ) ]
auras = [ ExtResource( 12 ), ExtResource( 8 ), ExtResource( 29 ), ExtResource( 10 ), ExtResource( 3 ), ExtResource( 7 ), ExtResource( 2 ), ExtResource( 6 ), ExtResource( 15 ), ExtResource( 16 ), ExtResource( 17 ), ExtResource( 21 ), ExtResource( 24 ), ExtResource( 39 ), ExtResource( 41 ), ExtResource( 40 ), ExtResource( 43 ), ExtResource( 44 ), ExtResource( 42 ), ExtResource( 46 ), ExtResource( 49 ), ExtResource( 48 ), ExtResource( 47 ), ExtResource( 45 ) ]

View File

@ -1,16 +1,18 @@
extends Dungeon
export (EntityData) var trainer : EntityData
export (EntityData) var vendor : EntityData
func _instance(p_seed, p_instance):
._instance(p_seed, p_instance)
p_instance.trainer = trainer
p_instance.vendor = vendor
return p_instance
func _generate_chunk(chunk : VoxelChunk, spawn_mobs : bool):
if trainer == null:
if trainer == null || vendor == null:
return
if chunk.position_x == 0 && chunk.position_y == 0 && chunk.position_z == 0:
@ -18,3 +20,6 @@ func _generate_chunk(chunk : VoxelChunk, spawn_mobs : bool):
ESS.entity_spawner.spawn_mob(trainer.id, 1, pos)
pos = Vector3(2 * chunk.voxel_scale, 8 * chunk.voxel_scale, 2 * chunk.voxel_scale)
ESS.entity_spawner.spawn_mob(vendor.id, 1, pos)

View File

@ -1,8 +1,10 @@
[gd_resource type="Dungeon" load_steps=3 format=2]
[gd_resource type="Dungeon" load_steps=4 format=2]
[ext_resource path="res://modules/planets/test_planet/villages/village.gd" type="Script" id=1]
[ext_resource path="res://modules/entity_classes/naturalist/entities/3_naturalist_trainer.tres" type="EntityData" id=2]
[ext_resource path="res://modules/entity_classes/naturalist/entities/4_naturalist_vendor.tres" type="EntityData" id=3]
[resource]
script = ExtResource( 1 )
trainer = ExtResource( 2 )
vendor = ExtResource( 3 )

View File

@ -53,6 +53,8 @@ func _notification_cmouse_enter() -> void:
Input.set_default_cursor_shape(Input.CURSOR_ARROW)
elif centity_interaction_type == EntityEnums.ENITIY_INTERACTION_TYPE_TRAIN:
Input.set_default_cursor_shape(Input.CURSOR_HELP)
elif centity_interaction_type == EntityEnums.ENITIY_INTERACTION_TYPE_VENDOR:
Input.set_default_cursor_shape(Input.CURSOR_HELP)
else:
Input.set_default_cursor_shape(Input.CURSOR_MOVE)

View File

@ -53,6 +53,8 @@ func _sinteract(entity: Entity) -> void:
entity.ssend_open_window(EntityEnums.ENTITY_WINDOW_LOOT)
elif target.sentity_interaction_type == EntityEnums.ENITIY_INTERACTION_TYPE_TRAIN:
entity.ssend_open_window(EntityEnums.ENTITY_WINDOW_TRAINER)
elif target.sentity_interaction_type == EntityEnums.ENITIY_INTERACTION_TYPE_VENDOR:
entity.ssend_open_window(EntityEnums.ENTITY_WINDOW_VENDOR)
func _cans_interact(entity):
var target : Entity = entity.gets_target()

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=32 format=2]
[gd_scene load_steps=33 format=2]
[ext_resource path="res://player/GUI.gd" type="Script" id=1]
[ext_resource path="res://ui/ingame_menu/IngameMenu.tscn" type="PackedScene" id=2]
@ -31,6 +31,7 @@
[ext_resource path="res://ui/windows/CharacterWindow.tscn" type="PackedScene" id=29]
[ext_resource path="res://ui/theme/character_icon.tres" type="Texture" id=30]
[ext_resource path="res://ui/windows/TrainerWindow.tscn" type="PackedScene" id=31]
[ext_resource path="res://ui/windows/VendorWindow.tscn" type="PackedScene" id=32]
[node name="GUILayer" type="CanvasLayer"]
script = ExtResource( 28 )
@ -45,7 +46,7 @@ script = ExtResource( 1 )
__meta__ = {
"_edit_lock_": true
}
child_controls = [ NodePath("Unitframes"), NodePath("Actionbars"), NodePath("Windows/SpellBookWindow"), NodePath("Buttons"), NodePath("Castbar"), NodePath("AuraFrame"), NodePath("Windows/Inventory"), NodePath("Windows/LootWindow"), NodePath("Windows/TalentWindow"), NodePath("Windows/CraftingWindow"), NodePath("IngameMenu/KeybindWindow"), NodePath("Windows/CharacterWindow"), NodePath("Windows/TrainerWindow"), NodePath("IngameMenu/InterfaceOptions") ]
child_controls = [ NodePath("Unitframes"), NodePath("Actionbars"), NodePath("Windows/SpellBookWindow"), NodePath("Buttons"), NodePath("Castbar"), NodePath("AuraFrame"), NodePath("Windows/Inventory"), NodePath("Windows/LootWindow"), NodePath("Windows/TalentWindow"), NodePath("Windows/CraftingWindow"), NodePath("IngameMenu/KeybindWindow"), NodePath("Windows/CharacterWindow"), NodePath("Windows/TrainerWindow"), NodePath("IngameMenu/InterfaceOptions"), NodePath("Windows/VendorWindow") ]
[node name="TouchTargetControls" type="MarginContainer" parent="GUI"]
visible = false
@ -425,6 +426,15 @@ margin_top = 50.7239
margin_right = 446.733
margin_bottom = 542.724
[node name="VendorWindow" parent="GUI/Windows" instance=ExtResource( 32 )]
visible = false
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 43.4182
margin_top = 69.8467
margin_right = 524.418
margin_bottom = 502.847
[node name="Unitframes" type="Control" parent="GUI"]
anchor_right = 1.0
anchor_bottom = 1.0

View File

@ -0,0 +1,54 @@
extends PopupPanel
# 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 label_path : NodePath
export(NodePath) var desc_label_path : NodePath
export(NodePath) var quantity_spinbox_path : NodePath
var _label : Label
var _desc_label : RichTextLabel
var _quantity_spinbox : SpinBox
var _item : ItemTemplate
var _item_data_entry : VendorItemDataEntry
func _ready():
_label = get_node(label_path) as Label
_desc_label = get_node(desc_label_path) as RichTextLabel
_quantity_spinbox = get_node(quantity_spinbox_path) as SpinBox
func set_item(item_data_entry : VendorItemDataEntry) -> void:
_item_data_entry = item_data_entry
if _item_data_entry == null:
return
_item = _item_data_entry.item
if _item == null:
return
_label.text = _item.text_name
_desc_label.text = _item.get_description()
_quantity_spinbox.max_value = _item.stack_size
_quantity_spinbox.value = 1

View File

@ -0,0 +1,77 @@
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

View File

@ -0,0 +1,165 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://ui/windows/SpellDragAndDropSpellBook.gd" type="Script" id=1]
[ext_resource path="res://ui/windows/ItemContainer.gd" type="Script" id=2]
[ext_resource path="res://ui/theme/ui_theme.tres" type="Theme" id=3]
[ext_resource path="res://ui/vendor_window/VendorEntryPopup.gd" type="Script" id=4]
[node name="ItemContainer" type="Control"]
margin_left = 290.0
margin_top = 306.0
margin_right = 576.0
margin_bottom = 370.0
size_flags_horizontal = 3
size_flags_vertical = 3
theme = ExtResource( 3 )
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
icon_path = NodePath("PanelContainer/HBoxContainer/Button/CenterContainer/Icon")
name_label_path = NodePath("PanelContainer/HBoxContainer/Name")
quantity_spinbox_path = NodePath("EntryPopup/VBoxContainer/Container/VBoxContainer/HBoxContainer/SpinBox")
learn_button_path = NodePath("EntryPopup/VBoxContainer/HBoxContainer/Button")
spell_button_path = NodePath("../ItemContainer/PanelContainer/HBoxContainer/Button")
popup_path = NodePath("EntryPopup")
not_known_color = Color( 0.596078, 0.596078, 0.596078, 1 )
unlearnable_color = Color( 0.772549, 0.192157, 0.192157, 1 )
[node name="PanelContainer" type="PanelContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
__meta__ = {
"_edit_use_anchors_": false
}
[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer"]
margin_left = 4.0
margin_top = 4.0
margin_right = 282.0
margin_bottom = 60.0
[node name="Button" type="Button" parent="PanelContainer/HBoxContainer"]
margin_right = 55.0
margin_bottom = 56.0
rect_min_size = Vector2( 55, 55 )
script = ExtResource( 1 )
[node name="CenterContainer" type="MarginContainer" parent="PanelContainer/HBoxContainer/Button"]
margin_left = 4.0
margin_top = 4.0
margin_right = 51.0
margin_bottom = 51.0
mouse_filter = 2
size_flags_horizontal = 3
size_flags_vertical = 3
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Icon" type="TextureRect" parent="PanelContainer/HBoxContainer/Button/CenterContainer"]
margin_right = 47.0
margin_bottom = 47.0
mouse_filter = 2
size_flags_horizontal = 3
size_flags_vertical = 3
expand = true
[node name="Name" type="Label" parent="PanelContainer/HBoxContainer"]
margin_left = 59.0
margin_top = 20.0
margin_right = 278.0
margin_bottom = 35.0
size_flags_horizontal = 3
text = "......"
[node name="EntryPopup" type="PopupPanel" parent="."]
margin_left = 64.0
margin_top = 4.0
margin_right = 360.0
margin_bottom = 207.0
script = ExtResource( 4 )
__meta__ = {
"_edit_use_anchors_": false
}
label_path = NodePath("VBoxContainer/HBoxContainer/Label")
desc_label_path = NodePath("VBoxContainer/Container/VBoxContainer/RichTextLabel")
quantity_spinbox_path = NodePath("VBoxContainer/Container/VBoxContainer/HBoxContainer/SpinBox")
[node name="VBoxContainer" type="VBoxContainer" parent="EntryPopup"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 4.0
margin_top = 4.0
margin_right = -4.0
margin_bottom = -4.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="HBoxContainer" type="HBoxContainer" parent="EntryPopup/VBoxContainer"]
margin_right = 288.0
margin_bottom = 26.0
[node name="Label" type="Label" parent="EntryPopup/VBoxContainer/HBoxContainer"]
margin_top = 5.0
margin_right = 254.0
margin_bottom = 20.0
size_flags_horizontal = 3
[node name="Button" type="Button" parent="EntryPopup/VBoxContainer/HBoxContainer"]
margin_left = 258.0
margin_right = 288.0
margin_bottom = 26.5702
rect_min_size = Vector2( 30, 0 )
text = "X"
[node name="HSeparator2" type="HSeparator" parent="EntryPopup/VBoxContainer"]
margin_top = 34.0
margin_right = 288.0
margin_bottom = 38.0
[node name="Container" type="VBoxContainer" parent="EntryPopup/VBoxContainer"]
margin_top = 46.0
margin_right = 288.0
margin_bottom = 195.0
rect_min_size = Vector2( 0, 20 )
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="VBoxContainer" type="VBoxContainer" parent="EntryPopup/VBoxContainer/Container"]
margin_right = 288.0
margin_bottom = 149.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="HBoxContainer" type="HBoxContainer" parent="EntryPopup/VBoxContainer/Container/VBoxContainer"]
margin_right = 288.0
margin_bottom = 26.0
[node name="SpinBox" type="SpinBox" parent="EntryPopup/VBoxContainer/Container/VBoxContainer/HBoxContainer"]
margin_right = 169.47
margin_bottom = 26.0
min_value = 1.0
value = 1.0
rounded = true
align = 1
[node name="LearnButton" type="Button" parent="EntryPopup/VBoxContainer/Container/VBoxContainer/HBoxContainer"]
margin_left = 173.0
margin_right = 288.0
margin_bottom = 26.5702
size_flags_horizontal = 3
text = "Buy"
[node name="RichTextLabel" type="RichTextLabel" parent="EntryPopup/VBoxContainer/Container/VBoxContainer"]
margin_top = 34.0
margin_right = 288.0
margin_bottom = 149.0
size_flags_horizontal = 3
size_flags_vertical = 3
[connection signal="pressed" from="PanelContainer/HBoxContainer/Button" to="." method="spell_button_pressed"]
[connection signal="pressed" from="EntryPopup/VBoxContainer/HBoxContainer/Button" to="EntryPopup" method="hide"]
[connection signal="pressed" from="EntryPopup/VBoxContainer/Container/VBoxContainer/HBoxContainer/LearnButton" to="." method="learn_spell"]

View File

@ -20,17 +20,17 @@ extends Button
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
var spell
var item : VendorItemDataEntry
func set_spell(p_spell):
spell = p_spell
func set_item(p_item):
item = p_item
func get_drag_data(pos):
if spell == null:
if item == null || item.item:
return null
var tr = TextureRect.new()
tr.texture = spell.icon
tr.texture = item.item.icon
tr.expand = true
# tr.rect_size = rect_size
@ -39,7 +39,7 @@ func get_drag_data(pos):
var esd = ESDragAndDrop.new()
esd.type = ESDragAndDrop.ES_DRAG_AND_DROP_TYPE_SPELL
esd.item_path = spell.resource_path
esd.type = ESDragAndDrop.ES_DRAG_AND_DROP_TYPE_ITEM
esd.item_path = item.item.resource_path
return esd

View File

@ -0,0 +1,161 @@
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 opener_button_path : NodePath
var opener_button : BaseButton
export(NodePath) var spell_entry_container_path : NodePath
export(NodePath) var prev_button_path : NodePath
export(NodePath) var next_button_path : NodePath
export(bool) var show_not_learned : bool = true
export(bool) var show_not_learnable : bool = false
var _spell_entry_container : Node
var _item_entries : Array
var _prev_button : Button
var _next_button : Button
var _player : Entity
var _page : int = 0
var _max_pages : int = 0
var _vendor_item_data : VendorItemData
func _ready() -> void:
opener_button = get_node_or_null(opener_button_path) as BaseButton
_item_entries.clear()
_spell_entry_container = get_node(spell_entry_container_path)
for i in range(_spell_entry_container.get_child_count()):
_item_entries.append(_spell_entry_container.get_child(i))
_prev_button = get_node(prev_button_path)
_next_button = get_node(next_button_path)
_prev_button.connect("pressed", self, "dec_page")
_next_button.connect("pressed", self, "inc_page")
connect("visibility_changed", self, "_visibility_changed")
func inc_page() -> void:
if _vendor_item_data == null:
return
_page += 1
if _page > _max_pages:
_page = _max_pages
refresh_entries()
func dec_page() -> void:
if _vendor_item_data == null:
return
_page -= 1
if _page < 0:
_page = 0
refresh_entries()
func refresh_entries() -> void:
if _player == null || _vendor_item_data == null:
return
var i : int = 0
var n : int = 0
# for n in range(len(_item_entries)):
while n < len(_item_entries):
var spindex : int = i + (_page * len(_item_entries))
if spindex >= _vendor_item_data.get_num_vendor_datas():
_item_entries[n].set_vendor_item(_player, null)
i += 1
n += 1
continue
var vide : VendorItemDataEntry = _vendor_item_data.get_vendor_data(spindex)
if !vide:
continue
_item_entries[n].set_vendor_item(_player, vide)
i += 1
n += 1
func refresh_all() -> void:
if _player == null:
return
if _vendor_item_data == null:
return
_max_pages = int(_vendor_item_data.get_num_vendor_datas() / len(_item_entries))
if _page > _max_pages:
_page = _max_pages
refresh_entries()
func _visibility_changed() -> void:
if visible:
if !_player:
return
var t : Entity = _player.ctarget
if !t:
return
_vendor_item_data = t.getc_entity_data().get_vendor_item_data()
_page = 0
refresh_all()
func set_player(p_player: Entity) -> void:
if _player != null:
_player.disconnect("onc_open_winow_request", self, "onc_open_winow_request")
_player = p_player
_player.connect("onc_open_winow_request", self, "onc_open_winow_request")
func onc_open_winow_request(window_id : int) -> void:
if window_id != EntityEnums.ENTITY_WINDOW_VENDOR:
return
show()
# if player.has_signal("player_moved") && !player.is_connected("player_moved", self, "on_player_moved"):
# player.connect("player_moved", self, "on_player_moved", [], CONNECT_ONESHOT)

View File

@ -0,0 +1,168 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://ui/windows/ItemContainer.tscn" type="PackedScene" id=1]
[ext_resource path="res://ui/windows/VendorWindow.gd" type="Script" id=4]
[ext_resource path="res://ui/theme/ui_theme.tres" type="Theme" id=5]
[node name="VendorWindow" type="PanelContainer"]
anchor_right = 1.0
anchor_bottom = 1.0
theme = ExtResource( 5 )
script = ExtResource( 4 )
__meta__ = {
"_edit_use_anchors_": false
}
spell_entry_container_path = NodePath("../VendorWindow/PagedContent/GridContainer")
prev_button_path = NodePath("../VendorWindow/PagedContent/Controls/HBoxContainer/Button2")
next_button_path = NodePath("../VendorWindow/PagedContent/Controls/HBoxContainer/Button")
show_not_learned = false
[node name="PagedContent" type="VBoxContainer" parent="."]
margin_left = 4.0
margin_top = 4.0
margin_right = 1020.0
margin_bottom = 596.0
[node name="Header" type="HBoxContainer" parent="PagedContent"]
margin_right = 1016.0
margin_bottom = 30.0
[node name="Label" type="Label" parent="PagedContent/Header"]
margin_top = 7.0
margin_right = 36.0
margin_bottom = 22.0
text = "Vendor"
[node name="HBoxContainer" type="HBoxContainer" parent="PagedContent/Header"]
margin_left = 40.0
margin_right = 972.0
margin_bottom = 30.0
size_flags_horizontal = 3
size_flags_vertical = 3
alignment = 1
[node name="Button" type="Button" parent="PagedContent/Header"]
margin_left = 976.0
margin_right = 1016.0
margin_bottom = 30.0
rect_min_size = Vector2( 40, 30 )
text = "X"
[node name="GridContainer" type="GridContainer" parent="PagedContent"]
margin_top = 38.0
margin_right = 1016.0
margin_bottom = 554.0
size_flags_horizontal = 3
size_flags_vertical = 3
columns = 2
[node name="ItemContainer" parent="PagedContent/GridContainer" instance=ExtResource( 1 )]
margin_left = 0.0
margin_top = 0.0
margin_right = 506.0
margin_bottom = 82.0
[node name="ItemContainer2" parent="PagedContent/GridContainer" instance=ExtResource( 1 )]
margin_left = 510.0
margin_top = 0.0
margin_right = 1016.0
margin_bottom = 82.0
[node name="ItemContainer3" parent="PagedContent/GridContainer" instance=ExtResource( 1 )]
margin_left = 0.0
margin_top = 86.0
margin_right = 506.0
margin_bottom = 168.0
[node name="ItemContainer4" parent="PagedContent/GridContainer" instance=ExtResource( 1 )]
margin_left = 510.0
margin_top = 86.0
margin_right = 1016.0
margin_bottom = 168.0
[node name="ItemContainer5" parent="PagedContent/GridContainer" instance=ExtResource( 1 )]
margin_left = 0.0
margin_top = 172.0
margin_right = 506.0
margin_bottom = 254.0
[node name="ItemContainer6" parent="PagedContent/GridContainer" instance=ExtResource( 1 )]
margin_left = 510.0
margin_top = 172.0
margin_right = 1016.0
margin_bottom = 254.0
[node name="ItemContainer7" parent="PagedContent/GridContainer" instance=ExtResource( 1 )]
margin_left = 0.0
margin_top = 258.0
margin_right = 506.0
margin_bottom = 340.0
[node name="ItemContainer8" parent="PagedContent/GridContainer" instance=ExtResource( 1 )]
margin_left = 510.0
margin_top = 258.0
margin_right = 1016.0
margin_bottom = 340.0
[node name="ItemContainer9" parent="PagedContent/GridContainer" instance=ExtResource( 1 )]
margin_left = 0.0
margin_top = 344.0
margin_right = 506.0
margin_bottom = 426.0
[node name="ItemContainer10" parent="PagedContent/GridContainer" instance=ExtResource( 1 )]
margin_left = 510.0
margin_top = 344.0
margin_right = 1016.0
margin_bottom = 426.0
[node name="ItemContainer11" parent="PagedContent/GridContainer" instance=ExtResource( 1 )]
margin_left = 0.0
margin_top = 430.0
margin_right = 506.0
margin_bottom = 512.0
[node name="ItemContainer12" parent="PagedContent/GridContainer" instance=ExtResource( 1 )]
margin_left = 510.0
margin_top = 430.0
margin_right = 1016.0
margin_bottom = 512.0
[node name="Controls" type="MarginContainer" parent="PagedContent"]
margin_top = 562.0
margin_right = 1016.0
margin_bottom = 592.0
custom_constants/margin_right = 2
custom_constants/margin_top = 2
custom_constants/margin_left = 2
custom_constants/margin_bottom = 2
[node name="HBoxContainer" type="HBoxContainer" parent="PagedContent/Controls"]
margin_left = 2.0
margin_top = 2.0
margin_right = 1014.0
margin_bottom = 28.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="Button2" type="Button" parent="PagedContent/Controls/HBoxContainer"]
margin_right = 334.0
margin_bottom = 26.5702
size_flags_horizontal = 3
size_flags_vertical = 3
text = "< Previous page"
[node name="Spacer" type="Control" parent="PagedContent/Controls/HBoxContainer"]
margin_left = 338.0
margin_right = 673.0
margin_bottom = 26.0
size_flags_horizontal = 3
[node name="Button" type="Button" parent="PagedContent/Controls/HBoxContainer"]
margin_left = 677.0
margin_right = 1012.0
margin_bottom = 26.5702
size_flags_horizontal = 3
size_flags_vertical = 3
text = "Next page >"
[connection signal="pressed" from="PagedContent/Header/Button" to="." method="hide"]