Fix a lot of porting issues
This commit is contained in:
parent
1449a73d2c
commit
cdb4bc2d69
32 changed files with 604 additions and 353 deletions
13
character_window/resources/abilities/ability_tooltip.xml
Normal file
13
character_window/resources/abilities/ability_tooltip.xml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml-model href="../../../../../gui.xsd" type="application/xml" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||||
|
<root>
|
||||||
|
<grid x_dim="4" y_dim="1">
|
||||||
|
<label id="equip" x_slot="0" y_slot="0" text_color="black"
|
||||||
|
background='{"background_color":"#835219","border_color":"#543919","border_thickness":{"Pixel":5}}'>Equip</label>
|
||||||
|
<label id="upgrade" x_slot="1" y_slot="0" text_color="black"
|
||||||
|
background='{"background_color":"#835219","border_color":"#543919","border_thickness":{"Pixel":5}}'>Upgrade</label>
|
||||||
|
<label id="salvage" x_slot="2" y_slot="0" text_color="black"
|
||||||
|
background='{"background_color":"#835219","border_color":"#543919","border_thickness":{"Pixel":5}}'>Salvage</label>
|
||||||
|
<label id="switch_mode" x_slot="3" y_slot="0" text_color="black"
|
||||||
|
background='{"background_color":"#835219","border_color":"#543919","border_thickness":{"Pixel":5}}'>Switch</label>
|
||||||
|
</grid>
|
||||||
|
</root>
|
11
character_window/resources/abilities/addon_tooltip.xml
Normal file
11
character_window/resources/abilities/addon_tooltip.xml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml-model href="../../../../../gui.xsd" type="application/xml" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||||
|
<root>
|
||||||
|
<grid x_dim="3" y_dim="1">
|
||||||
|
<label id="socket" x_slot="0" y_slot="0" text_color="black"
|
||||||
|
background='{"background_color":"#835219","border_color":"#543919","border_thickness":{"Pixel":5}}'>Socket</label>
|
||||||
|
<label id="salvage" x_slot="1" y_slot="0" text_color="black"
|
||||||
|
background='{"background_color":"#835219","border_color":"#543919","border_thickness":{"Pixel":5}}'>Salvage</label>
|
||||||
|
<label id="switch_mode" x_slot="2" y_slot="0" text_color="black"
|
||||||
|
background='{"background_color":"#835219","border_color":"#543919","border_thickness":{"Pixel":5}}'>Switch</label>
|
||||||
|
</grid>
|
||||||
|
</root>
|
|
@ -0,0 +1,9 @@
|
||||||
|
<root>
|
||||||
|
<grid x_dim="1" y_dim="1" padding="2">
|
||||||
|
<grid x_slot="0" y_slot="0" x_dim="6" y_dim="1" background="#919191">
|
||||||
|
<icon id="addon_icon" x_slot="0" y_slot="0"></icon>
|
||||||
|
<label id="addon_type" x_slot="1" y_slot="0" x_size="3" text_color="black" text_alignment="left">StatType</label>
|
||||||
|
<label id="addon_value" x_slot="4" y_slot="0" x_size="2" text_color="black">StatValue</label>
|
||||||
|
</grid>
|
||||||
|
</grid>
|
||||||
|
</root>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<root>
|
||||||
|
<grid x_dim="1" y_dim="1" padding="2">
|
||||||
|
<grid x_slot="0" y_slot="0" x_dim="6" y_dim="1" background="#919191">
|
||||||
|
<icon x_slot="0" y_slot="0" icon="textures/abilities/circle.png"></icon>
|
||||||
|
<label id="info" x_slot="1" y_slot="0" x_size="3" text_color="black"></label>
|
||||||
|
</grid>
|
||||||
|
</grid>
|
||||||
|
</root>
|
16
character_window/resources/abilities/left_side.xml
Normal file
16
character_window/resources/abilities/left_side.xml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml-model href="../../../../../gui.xsd" type="application/xml" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||||
|
<root>
|
||||||
|
<grid x_dim="1" y_dim="10" margin="4" padding="4"
|
||||||
|
background='{"background_color":"#945b09","border_color":"#543919","border_thickness":{"Pixel":2}}'>
|
||||||
|
<grid x_slot="0" y_slot="0" x_dim="6" y_dim="1"
|
||||||
|
button_normal='{"background_color":"#835219","border_color":"#543919","border_thickness":{"Pixel":5}}'
|
||||||
|
button_selected='{"background_color":"#835219","border_color":"#c37417","border_thickness":{"Pixel":5}}'>
|
||||||
|
<button id="abilities" x_slot="1" y_slot="0" x_size="2" text_color="black">Abilities</button>
|
||||||
|
<button id="addons" x_slot="3" y_slot="0" x_size="2" text_color="black">Addons</button>
|
||||||
|
</grid>
|
||||||
|
|
||||||
|
<grid id="content" x_slot="0" y_slot="1" x_dim="1" y_dim="1" y_size="8"></grid>
|
||||||
|
|
||||||
|
<grid id="tooltip" x_slot="0" y_slot="9" x_dim="1" y_dim="1"></grid>
|
||||||
|
</grid>
|
||||||
|
</root>
|
35
character_window/resources/abilities/right_side.xml
Normal file
35
character_window/resources/abilities/right_side.xml
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
<?xml-model href="../../../../../gui.xsd" type="application/xml" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||||
|
<root>
|
||||||
|
<grid x_dim="1" y_dim="10" padding="5" margin="5"
|
||||||
|
background='{"background_color":"#945b09","border_color":"#543919","border_thickness":{"Pixel":2}}'
|
||||||
|
button_normal='{"background_color":"#945b09","border_color":"#543919","border_thickness":{"Pixel":2}}'
|
||||||
|
button_selected='{"background_color":"#945b09","border_color":"#543919","border_thickness":{"Pixel":2}}'>
|
||||||
|
<grid x_slot="0" y_slot="0" x_dim="1" y_dim="9" y_size="9" padding="0" margin="0">
|
||||||
|
<grid x_slot="0" y_slot="0" x_dim="4" y_dim="1" padding="0" margin="0">
|
||||||
|
<button id="first_ability" x_slot="0" y_slot="0" fill_type="square" select_mode="none">0</button>
|
||||||
|
<button id="second_ability" x_slot="1" y_slot="0" fill_type="square" select_mode="none">0</button>
|
||||||
|
<button id="third_ability" x_slot="2" y_slot="0" fill_type="square" select_mode="none">0</button>
|
||||||
|
<button id="fourth_ability" x_slot="3" y_slot="0" fill_type="square" select_mode="none">0</button>
|
||||||
|
</grid>
|
||||||
|
|
||||||
|
<grid id="ability_content" x_slot="0" y_slot="1" x_dim="1" y_dim="8" y_size="8"
|
||||||
|
background='{"background_color":"#945b09","border_color":"#543919","border_thickness":{"Pixel":2}}'></grid>
|
||||||
|
</grid>
|
||||||
|
|
||||||
|
<grid x_slot="0" y_slot="9" x_dim="6" y_dim="1"
|
||||||
|
background='{"background_color":"#945b09","border_color":"#543919","border_thickness":{"Pixel":2}}'>
|
||||||
|
<icon id="common" x_slot="0" y_slot="0" fill_type="square"
|
||||||
|
background='{"background_color":"white","border_color":"black","border_thickness":{"Pixel":2}}'>0</icon>
|
||||||
|
<icon id="uncommon" x_slot="1" y_slot="0" fill_type="square"
|
||||||
|
background='{"background_color":"white","border_color":"black","border_thickness":{"Pixel":2}}'>0</icon>
|
||||||
|
<icon id="magical" x_slot="2" y_slot="0" fill_type="square"
|
||||||
|
background='{"background_color":"white","border_color":"black","border_thickness":{"Pixel":2}}'>0</icon>
|
||||||
|
<icon id="rare" x_slot="3" y_slot="0" fill_type="square"
|
||||||
|
background='{"background_color":"white","border_color":"black","border_thickness":{"Pixel":2}}'>0</icon>
|
||||||
|
<icon id="epic" x_slot="4" y_slot="0" fill_type="square"
|
||||||
|
background='{"background_color":"white","border_color":"black","border_thickness":{"Pixel":2}}'>0</icon>
|
||||||
|
<icon id="legendary" x_slot="5" y_slot="0" fill_type="square"
|
||||||
|
background='{"background_color":"white","border_color":"black","border_thickness":{"Pixel":2}}'>0</icon>
|
||||||
|
</grid>
|
||||||
|
</grid>
|
||||||
|
</root>
|
14
character_window/resources/content.xml
Normal file
14
character_window/resources/content.xml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml-model href="../../../../gui.xsd" type="application/xml" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||||
|
<root>
|
||||||
|
<grid x_dim="1" y_dim="7" margin="0" padding="0">
|
||||||
|
<grid x_slot="0" y_slot="0" x_dim="3" y_dim="1"
|
||||||
|
button_normal='{"background_color":"#835219","border_color":"#543919","border_thickness":{"Pixel":5}}'
|
||||||
|
button_selected='{"background_color":"#835219","border_color":"#c37417","border_thickness":{"Pixel":5}}'>
|
||||||
|
<button id="left" x_slot="0" y_slot="0" text_color="black" isolate="true">prev</button>
|
||||||
|
<label id="tab_info" x_slot="1" y_slot="0" text_color="black">1 / 1</label>
|
||||||
|
<button id="right" x_slot="2" y_slot="0" text_color="black" isolate="true">next</button>
|
||||||
|
</grid>
|
||||||
|
|
||||||
|
<grid id="content" x_slot="0" y_slot="1" x_dim="4" y_dim="4" y_size="6"></grid>
|
||||||
|
</grid>
|
||||||
|
</root>
|
8
character_window/resources/content_button.xml
Normal file
8
character_window/resources/content_button.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml-model href="../../../../gui.xsd" type="application/xml" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||||
|
<root>
|
||||||
|
<grid x_dim="1" y_dim="1" margin="0" padding="0"
|
||||||
|
button_normal='{"background_color":"#945b09","border_color":"#543919","border_thickness":{"Pixel":0}}'
|
||||||
|
button_selected='{"background_color":"#bd7000","border_color":"#c37417","border_thickness":{"Pixel":0}}'>
|
||||||
|
<button id="button" x_slot="0" y_slot="0" select_mode="none" fill_type="square"></button>
|
||||||
|
</grid>
|
||||||
|
</root>
|
45
character_window/resources/inventory.xml
Normal file
45
character_window/resources/inventory.xml
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
<?xml-model href="../../../../gui.xsd" type="application/xml" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||||
|
<root reference_width="1280" reference_height="720" layer="10">
|
||||||
|
<grid x_dim="2" y_dim="1" x_offset="-400" y_offset="-240" width="800" height="540" vert_align="middle" hori_align="middle" background="#919191" padding="10">
|
||||||
|
<grid id="inventory" x_slot="0" y_slot="0" x_dim="1" y_dim="8" background="#aaaaaa" padding="2" margin="2">
|
||||||
|
<grid x_slot="0" y_slot="0" x_dim="3" y_dim="1" background="#919191" button_normal="#919191" button_selected="#919191">
|
||||||
|
<button id="left" x_slot="0" y_slot="0" select_mode="none"></button>
|
||||||
|
<label id="tab_info" x_slot="1" y_slot="0" text_color="black" text_ratio="0.5">1 / 1</label>
|
||||||
|
<button id="right" x_slot="2" y_slot="0" select_mode="none"></button>
|
||||||
|
</grid>
|
||||||
|
</grid>
|
||||||
|
|
||||||
|
<grid id="equipment" x_slot="1" y_slot="0" x_dim="3" y_dim="5" background="#aaaaaa" button_normal="#aaaaaa" button_selected="#919191" padding="2">
|
||||||
|
<!-- amulets -->
|
||||||
|
<button id="amulet_0" x_slot="0" y_slot="0" icon="textures/items/amulet_placeholder.png" icon_margin="5" select_mode="none"></button>
|
||||||
|
<button id="amulet_1" x_slot="2" y_slot="0" icon="textures/items/amulet_placeholder.png" icon_margin="5" select_mode="none"></button>
|
||||||
|
|
||||||
|
<!-- helmet -->
|
||||||
|
<button id="helmet" x_slot="1" y_slot="0" icon="textures/items/helmet_placeholder.png" icon_margin="5" select_mode="none"></button>
|
||||||
|
|
||||||
|
<!-- chest plate -->
|
||||||
|
<button id="chest" x_slot="1" y_slot="1" icon="textures/items/chest_placeholder.png" icon_margin="5" select_mode="none"></button>
|
||||||
|
|
||||||
|
<!-- gloves -->
|
||||||
|
<button id="gloves" x_slot="0" y_slot="1" icon="textures/items/gloves_placeholder.png" icon_margin="5" select_mode="none"></button>
|
||||||
|
|
||||||
|
<!-- belt -->
|
||||||
|
<button id="belt" x_slot="1" y_slot="2" icon="textures/items/belt_placeholder.png" icon_margin="5" select_mode="none"></button>
|
||||||
|
|
||||||
|
<!-- boots -->
|
||||||
|
<button id="boots" x_slot="1" y_slot="4" icon="textures/items/boots_placeholder.png" icon_margin="5" select_mode="none"></button>
|
||||||
|
|
||||||
|
<!-- main hand -->
|
||||||
|
<button id="main hand" x_slot="0" y_slot="4" icon="textures/items/sword_placeholder.png" icon_margin="5" select_mode="none"></button>
|
||||||
|
|
||||||
|
<!-- off hand -->
|
||||||
|
<button id="off hand" x_slot="2" y_slot="4" icon="textures/items/shield_placeholder.png" icon_margin="5" select_mode="none"></button>
|
||||||
|
|
||||||
|
<!-- rings -->
|
||||||
|
<button id="ring_0" x_slot="0" y_slot="2" icon="textures/items/ring_placeholder.png" icon_margin="5" select_mode="none"></button>
|
||||||
|
<button id="ring_1" x_slot="2" y_slot="2" icon="textures/items/ring_placeholder.png" icon_margin="5" select_mode="none"></button>
|
||||||
|
<button id="ring_2" x_slot="0" y_slot="3" icon="textures/items/ring_placeholder.png" icon_margin="5" select_mode="none"></button>
|
||||||
|
<button id="ring_3" x_slot="2" y_slot="3" icon="textures/items/ring_placeholder.png" icon_margin="5" select_mode="none"></button>
|
||||||
|
</grid>
|
||||||
|
</grid>
|
||||||
|
</root>
|
38
character_window/resources/inventory/items/right_side.xml
Normal file
38
character_window/resources/inventory/items/right_side.xml
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<?xml-model href="../../../../../../gui.xsd" type="application/xml" schematypes="http://www.w3.org/2001/XMLSchema"?>
|
||||||
|
<root>
|
||||||
|
<grid id="equipment" x_dim="3" y_dim="5" padding="7" margin="5"
|
||||||
|
background='{"background_color":"#945b09","border_color":"#543919","border_thickness":{"Pixel":2}}'
|
||||||
|
button_normal='{"background_color":"#945b09","border_color":"#543919","border_thickness":{"Pixel":2}}'
|
||||||
|
button_selected='{"background_color":"#6c440b","border_color":"#543919","border_thickness":{"Pixel":2}}'>
|
||||||
|
<!-- amulets -->
|
||||||
|
<button id="amulet_0" x_slot="0" y_slot="0" icon="textures/items/amulet_placeholder.png" icon_margin="5" fill_type="square" select_mode="none"></button>
|
||||||
|
<button id="amulet_1" x_slot="2" y_slot="0" icon="textures/items/amulet_placeholder.png" icon_margin="5" fill_type="square" select_mode="none"></button>
|
||||||
|
|
||||||
|
<!-- helmet -->
|
||||||
|
<button id="helmet" x_slot="1" y_slot="0" icon="textures/items/helmet_placeholder.png" icon_margin="5" fill_type="square" select_mode="none"></button>
|
||||||
|
|
||||||
|
<!-- chest plate -->
|
||||||
|
<button id="chest" x_slot="1" y_slot="1" icon="textures/items/chest_placeholder.png" icon_margin="5" fill_type="square" select_mode="none"></button>
|
||||||
|
|
||||||
|
<!-- gloves -->
|
||||||
|
<button id="gloves" x_slot="0" y_slot="1" icon="textures/items/gloves_placeholder.png" icon_margin="5" fill_type="square" select_mode="none"></button>
|
||||||
|
|
||||||
|
<!-- belt -->
|
||||||
|
<button id="belt" x_slot="1" y_slot="2" icon="textures/items/belt_placeholder.png" icon_margin="5" fill_type="square" select_mode="none"></button>
|
||||||
|
|
||||||
|
<!-- boots -->
|
||||||
|
<button id="boots" x_slot="1" y_slot="4" icon="textures/items/boots_placeholder.png" icon_margin="5" fill_type="square" select_mode="none"></button>
|
||||||
|
|
||||||
|
<!-- main hand -->
|
||||||
|
<button id="main hand" x_slot="0" y_slot="4" icon="textures/items/sword_placeholder.png" icon_margin="5" fill_type="square" select_mode="none"></button>
|
||||||
|
|
||||||
|
<!-- off hand -->
|
||||||
|
<button id="off hand" x_slot="2" y_slot="4" icon="textures/items/shield_placeholder.png" icon_margin="5" fill_type="square" select_mode="none"></button>
|
||||||
|
|
||||||
|
<!-- rings -->
|
||||||
|
<button id="ring_0" x_slot="0" y_slot="2" icon="textures/items/ring_placeholder.png" icon_margin="5" fill_type="square" select_mode="none"></button>
|
||||||
|
<button id="ring_1" x_slot="2" y_slot="2" icon="textures/items/ring_placeholder.png" icon_margin="5" fill_type="square" select_mode="none"></button>
|
||||||
|
<button id="ring_2" x_slot="0" y_slot="3" icon="textures/items/ring_placeholder.png" icon_margin="5" fill_type="square" select_mode="none"></button>
|
||||||
|
<button id="ring_3" x_slot="2" y_slot="3" icon="textures/items/ring_placeholder.png" icon_margin="5" fill_type="square" select_mode="none"></button>
|
||||||
|
</grid>
|
||||||
|
</root>
|
13
character_window/resources/inventory/items/tooltip.xml
Normal file
13
character_window/resources/inventory/items/tooltip.xml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml-model href="../../../../../../gui.xsd" type="application/xml" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||||
|
<root>
|
||||||
|
<grid x_dim="4" y_dim="1">
|
||||||
|
<label id="equip" x_slot="0" y_slot="0" text_color="black"
|
||||||
|
background='{"background_color":"#835219","border_color":"#543919","border_thickness":{"Pixel":5}}'>Equip</label>
|
||||||
|
<label id="salvage" x_slot="1" y_slot="0" text_color="black"
|
||||||
|
background='{"background_color":"#835219","border_color":"#543919","border_thickness":{"Pixel":5}}'>Salvage</label>
|
||||||
|
<label id="socket" x_slot="2" y_slot="0" text_color="black"
|
||||||
|
background='{"background_color":"#835219","border_color":"#543919","border_thickness":{"Pixel":5}}'>Socket</label>
|
||||||
|
<label id="switch_mode" x_slot="3" y_slot="0" text_color="black"
|
||||||
|
background='{"background_color":"#835219","border_color":"#543919","border_thickness":{"Pixel":5}}'>Switch</label>
|
||||||
|
</grid>
|
||||||
|
</root>
|
23
character_window/resources/inventory/jewels/right_side.xml
Normal file
23
character_window/resources/inventory/jewels/right_side.xml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml-model href="../../../../../../gui.xsd" type="application/xml" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||||
|
<root>
|
||||||
|
<grid x_dim="1" y_dim="10" padding="5" margin="5"
|
||||||
|
background='{"background_color":"#945b09","border_color":"#543919","border_thickness":{"Pixel":2}}'
|
||||||
|
button_normal='{"background_color":"#945b09","border_color":"#543919","border_thickness":{"Pixel":2}}'
|
||||||
|
button_selected='{"background_color":"#c47503","border_color":"#543919","border_thickness":{"Pixel":2}}'>
|
||||||
|
|
||||||
|
<grid x_slot="0" y_slot="0" x_dim="5" y_dim="5" y_size="9">
|
||||||
|
<button id="reference" x_slot="2" y_slot="1" fill_type="square"></button>
|
||||||
|
|
||||||
|
<button id="first" x_slot="1" y_slot="3" fill_type="square"></button>
|
||||||
|
<button id="second" x_slot="2" y_slot="3" fill_type="square"></button>
|
||||||
|
<button id="third" x_slot="3" y_slot="3" fill_type="square"></button>
|
||||||
|
</grid>
|
||||||
|
|
||||||
|
<grid x_slot="0" y_slot="9" x_dim="3" y_dim="1">
|
||||||
|
<label id="combine" x_slot="1" y_slot="0" text_color="black"
|
||||||
|
background='{"background_color":"#835219","border_color":"#543919","border_thickness":{"Pixel":5}}'>Combine</label>
|
||||||
|
</grid>
|
||||||
|
|
||||||
|
|
||||||
|
</grid>
|
||||||
|
</root>
|
11
character_window/resources/inventory/jewels/tooltip.xml
Normal file
11
character_window/resources/inventory/jewels/tooltip.xml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml-model href="../../../../../../gui.xsd" type="application/xml" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||||
|
<root>
|
||||||
|
<grid x_dim="3" y_dim="1">
|
||||||
|
<label id="socket" x_slot="0" y_slot="0" text_color="black"
|
||||||
|
background='{"background_color":"#835219","border_color":"#543919","border_thickness":{"Pixel":5}}'>Socket</label>
|
||||||
|
<label id="combine" x_slot="1" y_slot="0" text_color="black"
|
||||||
|
background='{"background_color":"#835219","border_color":"#543919","border_thickness":{"Pixel":5}}'>Combine</label>
|
||||||
|
<label id="switch_mode" x_slot="2" y_slot="0" text_color="black"
|
||||||
|
background='{"background_color":"#835219","border_color":"#543919","border_thickness":{"Pixel":5}}'>Switch</label>
|
||||||
|
</grid>
|
||||||
|
</root>
|
17
character_window/resources/inventory/left_side.xml
Normal file
17
character_window/resources/inventory/left_side.xml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml-model href="../../../../../gui.xsd" type="application/xml" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||||
|
<root>
|
||||||
|
<grid x_dim="1" y_dim="10" margin="4" padding="4"
|
||||||
|
background='{"background_color":"#945b09","border_color":"#543919","border_thickness":{"Pixel":2}}'>
|
||||||
|
<grid x_slot="0" y_slot="0" x_dim="3" y_dim="1"
|
||||||
|
button_normal='{"background_color":"#835219","border_color":"#543919","border_thickness":{"Pixel":5}}'
|
||||||
|
button_selected='{"background_color":"#835219","border_color":"#c37417","border_thickness":{"Pixel":5}}'>
|
||||||
|
<button id="items" x_slot="0" y_slot="0" text_color="black" isolate="true">Items</button>
|
||||||
|
<button id="jewels" x_slot="1" y_slot="0" text_color="black" isolate="true">Jewels</button>
|
||||||
|
<button id="maps" x_slot="2" y_slot="0" text_color="black" isolate="true">Maps</button>
|
||||||
|
</grid>
|
||||||
|
|
||||||
|
<grid id="content" x_slot="0" y_slot="1" x_dim="1" y_dim="1" y_size="8"></grid>
|
||||||
|
|
||||||
|
<grid id="tooltip" x_slot="0" y_slot="9" x_dim="1" y_dim="1"></grid>
|
||||||
|
</grid>
|
||||||
|
</root>
|
7
character_window/resources/inventory/maps/right_side.xml
Normal file
7
character_window/resources/inventory/maps/right_side.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml-model href="../../../../../../gui.xsd" type="application/xml" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||||
|
<root>
|
||||||
|
<grid x_dim="1" y_dim="1"
|
||||||
|
background='{"background_color":"#945b09","border_color":"#543919","border_thickness":{"Pixel":2}}'>
|
||||||
|
<label x_slot="0" y_slot="0" text_color="black">work in progress</label>
|
||||||
|
</grid>
|
||||||
|
</root>
|
11
character_window/resources/inventory/maps/tooltip.xml
Normal file
11
character_window/resources/inventory/maps/tooltip.xml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml-model href="../../../../../../gui.xsd" type="application/xml" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||||
|
<root>
|
||||||
|
<grid x_dim="3" y_dim="1">
|
||||||
|
<label id="select" x_slot="0" y_slot="0" text_color="black"
|
||||||
|
background='{"background_color":"#835219","border_color":"#543919","border_thickness":{"Pixel":5}}'>Select</label>
|
||||||
|
<label id="start" x_slot="1" y_slot="0" text_color="black"
|
||||||
|
background='{"background_color":"#835219","border_color":"#543919","border_thickness":{"Pixel":5}}'>Start</label>
|
||||||
|
<label id="switch_mode" x_slot="2" y_slot="0" text_color="black"
|
||||||
|
background='{"background_color":"#835219","border_color":"#543919","border_thickness":{"Pixel":5}}'>Switch</label>
|
||||||
|
</grid>
|
||||||
|
</root>
|
15
character_window/resources/inventory_item_snippet.xml
Normal file
15
character_window/resources/inventory_item_snippet.xml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<root>
|
||||||
|
<!-- loot slot -->
|
||||||
|
<grid x_dim="1" y_dim="1" padding="5">
|
||||||
|
<grid id="snippet_grid" x_slot="0" y_slot="0" x_dim="5" y_dim="1" background="#919191" button_normal="#919191" button_selected="#aaaaaa" margin="0">
|
||||||
|
<button id="item_icon" x_slot="0" y_slot="0" select_mode="none"></button>
|
||||||
|
|
||||||
|
<!-- stats -->
|
||||||
|
<label id="strength_info" x_slot="1" y_slot="0" text_ratio="0.7" text_color="#C23519">0</label>
|
||||||
|
<label id="agility_info" x_slot="2" y_slot="0" text_ratio="0.7" text_color="#65D01E">0</label>
|
||||||
|
<label id="intelligence_info" x_slot="3" y_slot="0" text_ratio="0.7" text_color="#1D63B3">0</label>
|
||||||
|
|
||||||
|
<button id="disassemble" x_slot="4" y_slot="0" icon="textures/icons/crafting.png" select_mode="none"></button>
|
||||||
|
</grid>
|
||||||
|
</grid>
|
||||||
|
</root>
|
|
@ -25,15 +25,16 @@ impl AbilityPageRightSide {
|
||||||
];
|
];
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
game_handle: &GameHandle,
|
engine: &Arc<Engine>,
|
||||||
reference: &Weak<CharacterWindow>,
|
reference: &Weak<CharacterWindow>,
|
||||||
hero: Entity,
|
hero: Entity,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let snippet =
|
let snippet = GuiSnippet::from_str(
|
||||||
game_handle.gui_snippet("gui/xml/ingame/character_menu/abilities/right_side.xml")?;
|
engine.gui_handler(),
|
||||||
|
include_str!("../../resources/abilities/right_side.xml"),
|
||||||
|
)?;
|
||||||
|
|
||||||
let game = game_handle.upgrade();
|
let color_settings = &engine.item_settings.rarity_color_settings;
|
||||||
let color_settings = &game.item_settings.rarity_color_settings;
|
|
||||||
|
|
||||||
Self::rarity_icon_background(&snippet, "common", color_settings.common)?;
|
Self::rarity_icon_background(&snippet, "common", color_settings.common)?;
|
||||||
Self::rarity_icon_background(&snippet, "uncommon", color_settings.uncommon)?;
|
Self::rarity_icon_background(&snippet, "uncommon", color_settings.uncommon)?;
|
||||||
|
@ -45,7 +46,7 @@ impl AbilityPageRightSide {
|
||||||
for (index, name) in Self::ABILITY_BUTTON_NAMES.iter().enumerate() {
|
for (index, name) in Self::ABILITY_BUTTON_NAMES.iter().enumerate() {
|
||||||
let button: Arc<Button> = snippet.element(name)?;
|
let button: Arc<Button> = snippet.element(name)?;
|
||||||
|
|
||||||
button.set_info_icon(&game_handle.controller_icon(ControllerButton::RightStick)?)?;
|
button.set_info_icon(&engine.controller_icon(ControllerButton::RightStick)?)?;
|
||||||
|
|
||||||
button.set_callback({
|
button.set_callback({
|
||||||
let reference = reference.clone();
|
let reference = reference.clone();
|
||||||
|
@ -64,14 +65,14 @@ impl AbilityPageRightSide {
|
||||||
});
|
});
|
||||||
|
|
||||||
button.set_select_callback({
|
button.set_select_callback({
|
||||||
let game_handle = game_handle.clone();
|
let engine = engine.clone();
|
||||||
let reference = reference.clone();
|
let reference = reference.clone();
|
||||||
let weak_button = Arc::downgrade(&button);
|
let weak_button = Arc::downgrade(&button);
|
||||||
|
|
||||||
move |selected| {
|
move |selected| {
|
||||||
if let Some(menu) = reference.upgrade() {
|
if let Some(menu) = reference.upgrade() {
|
||||||
if selected {
|
if selected {
|
||||||
game_handle.upgrade().engine().on_scene(|scene| {
|
engine.on_scene(|scene| {
|
||||||
let entity = scene.entity(hero)?;
|
let entity = scene.entity(hero)?;
|
||||||
let abilities = entity.get_component::<AbilitySlots>()?;
|
let abilities = entity.get_component::<AbilitySlots>()?;
|
||||||
|
|
||||||
|
@ -85,7 +86,7 @@ impl AbilityPageRightSide {
|
||||||
let statistics = entity.get_component::<Statistics>()?;
|
let statistics = entity.get_component::<Statistics>()?;
|
||||||
|
|
||||||
let gui = book.create_tooltip(
|
let gui = book.create_tooltip(
|
||||||
&game_handle,
|
engine.gui_handler(),
|
||||||
statistics,
|
statistics,
|
||||||
(target_x, target_y),
|
(target_x, target_y),
|
||||||
)?;
|
)?;
|
||||||
|
@ -107,12 +108,12 @@ impl AbilityPageRightSide {
|
||||||
});
|
});
|
||||||
|
|
||||||
button.set_custom_callback({
|
button.set_custom_callback({
|
||||||
let game_handle = game_handle.clone();
|
let engine = engine.clone();
|
||||||
let reference = reference.clone();
|
let reference = reference.clone();
|
||||||
|
|
||||||
move |button| match button {
|
move |button| match button {
|
||||||
ControllerButton::Y => {
|
ControllerButton::Y => {
|
||||||
game_handle.upgrade().engine().on_scene_mut(|scene| {
|
engine.on_scene_mut(|scene| {
|
||||||
let entity = scene.entity_mut(hero)?;
|
let entity = scene.entity_mut(hero)?;
|
||||||
let mut multi_mut = entity.multi_mut();
|
let mut multi_mut = entity.multi_mut();
|
||||||
|
|
||||||
|
@ -127,7 +128,7 @@ impl AbilityPageRightSide {
|
||||||
menu.tabs_mut()
|
menu.tabs_mut()
|
||||||
.abilities()
|
.abilities()
|
||||||
.right_side
|
.right_side
|
||||||
.refresh(&game_handle, hero)?;
|
.refresh(&engine, hero)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,11 +184,7 @@ impl AbilityPageRightSide {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_active_ability(
|
fn update_active_ability(&self, engine: &Engine, abilities: &AbilitySlots) -> Result<()> {
|
||||||
&self,
|
|
||||||
game_handle: &GameHandle,
|
|
||||||
abilities: &AbilitySlots,
|
|
||||||
) -> Result<()> {
|
|
||||||
let grid: Arc<Grid> = self.snippet.element("ability_content")?;
|
let grid: Arc<Grid> = self.snippet.element("ability_content")?;
|
||||||
let (_, rows) = grid.dimensions();
|
let (_, rows) = grid.dimensions();
|
||||||
|
|
||||||
|
@ -199,8 +196,9 @@ impl AbilityPageRightSide {
|
||||||
for (index, addon) in ability.addons().iter().enumerate() {
|
for (index, addon) in ability.addons().iter().enumerate() {
|
||||||
match addon.as_ref() {
|
match addon.as_ref() {
|
||||||
Some(addon) => {
|
Some(addon) => {
|
||||||
let addon_type_snippet = game_handle.gui_snippet(
|
let addon_type_snippet = GuiSnippet::from_str(
|
||||||
"gui/xml/ingame/character_menu/abilities/addon_type_snippet.xml",
|
engine.gui_handler(),
|
||||||
|
include_str!("../../resources/abilities/addon_type_snippet.xml"),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let addon_icon: Arc<Icon> = addon_type_snippet.element("addon_icon")?;
|
let addon_icon: Arc<Icon> = addon_type_snippet.element("addon_icon")?;
|
||||||
|
@ -214,8 +212,9 @@ impl AbilityPageRightSide {
|
||||||
grid.attach(addon_type_snippet, 0, index, 1, 1)?;
|
grid.attach(addon_type_snippet, 0, index, 1, 1)?;
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let empty_addon = game_handle.gui_snippet(
|
let empty_addon = GuiSnippet::from_str(
|
||||||
"gui/xml/ingame/character_menu/abilities/empty_addon_snippet.xml",
|
engine.gui_handler(),
|
||||||
|
include_str!("../../resources/abilities/empty_addon_snippet.xml"),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
grid.attach(empty_addon, 0, index, 1, 1)?;
|
grid.attach(empty_addon, 0, index, 1, 1)?;
|
||||||
|
@ -227,15 +226,15 @@ impl AbilityPageRightSide {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn next_ability(&mut self, game_handle: &GameHandle, hero: Entity) -> Result<()> {
|
pub fn next_ability(&mut self, engine: &Arc<Engine>, hero: Entity) -> Result<()> {
|
||||||
self.ability_index = (self.ability_index + 1) % 4;
|
self.ability_index = (self.ability_index + 1) % 4;
|
||||||
self.refresh(game_handle, hero)
|
self.refresh(engine, hero)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RightSide for AbilityPageRightSide {
|
impl RightSide for AbilityPageRightSide {
|
||||||
fn refresh(&mut self, game_handle: &GameHandle, hero: Entity) -> Result<()> {
|
fn refresh(&mut self, engine: &Engine, hero: Entity) -> Result<()> {
|
||||||
game_handle.upgrade().engine().on_scene(|scene| {
|
engine.on_scene(|scene| {
|
||||||
let entity = scene.entity(hero)?;
|
let entity = scene.entity(hero)?;
|
||||||
|
|
||||||
let crafting = entity.get_component::<CraftingMaterials>()?;
|
let crafting = entity.get_component::<CraftingMaterials>()?;
|
||||||
|
@ -253,7 +252,7 @@ impl RightSide for AbilityPageRightSide {
|
||||||
self.update_ability_icon(name, abilities.book(index).map(|book| book.icon()))?;
|
self.update_ability_icon(name, abilities.book(index).map(|book| book.icon()))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.update_active_ability(game_handle, abilities)?;
|
self.update_active_ability(engine, abilities)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
|
|
|
@ -17,13 +17,13 @@ use super::AbilityPage;
|
||||||
|
|
||||||
impl Content<AbilityAddon> {
|
impl Content<AbilityAddon> {
|
||||||
fn show_addon_tooltip(
|
fn show_addon_tooltip(
|
||||||
game_handle: &GameHandle,
|
engine: &Arc<Engine>,
|
||||||
hero: Entity,
|
hero: Entity,
|
||||||
addon_index: usize,
|
addon_index: usize,
|
||||||
reference: &Weak<CharacterWindow>,
|
reference: &Weak<CharacterWindow>,
|
||||||
(x, y, w, _h): (i32, i32, u32, u32),
|
(x, y, w, _h): (i32, i32, u32, u32),
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
game_handle.upgrade().engine().on_scene(|scene| {
|
engine.on_scene(|scene| {
|
||||||
let entity = scene.entity(hero)?;
|
let entity = scene.entity(hero)?;
|
||||||
let inventory = entity.get_component::<Inventory>()?;
|
let inventory = entity.get_component::<Inventory>()?;
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ impl Content<AbilityAddon> {
|
||||||
let target_y = y;
|
let target_y = y;
|
||||||
|
|
||||||
let addon = inventory.addon_at(addon_index);
|
let addon = inventory.addon_at(addon_index);
|
||||||
let gui = addon.create_tooltip(game_handle, (target_x, target_y))?;
|
let gui = addon.create_tooltip(engine.gui_handler(), (target_x, target_y))?;
|
||||||
gui.enable()?;
|
gui.enable()?;
|
||||||
gui.perform_single_check(x, y)?;
|
gui.perform_single_check(x, y)?;
|
||||||
|
|
||||||
|
@ -43,12 +43,12 @@ impl Content<AbilityAddon> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn insert_addon(
|
fn insert_addon(
|
||||||
game_handle: &GameHandle,
|
engine: &Arc<Engine>,
|
||||||
hero: Entity,
|
hero: Entity,
|
||||||
addon_index: usize,
|
addon_index: usize,
|
||||||
ability_page: &AbilityPage,
|
ability_page: &AbilityPage,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
game_handle.upgrade().engine().on_scene_mut(|scene| {
|
engine.on_scene_mut(|scene| {
|
||||||
let entity = scene.entity_mut(hero)?;
|
let entity = scene.entity_mut(hero)?;
|
||||||
let mut multi_mut = entity.multi_mut();
|
let mut multi_mut = entity.multi_mut();
|
||||||
|
|
||||||
|
@ -68,21 +68,19 @@ impl Content<AbilityAddon> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ContentUpdate for Content<AbilityAddon> {
|
impl ContentUpdate for Content<AbilityAddon> {
|
||||||
fn update(&mut self, game_handle: &GameHandle, hero: Entity) -> Result<()> {
|
fn update(&mut self, engine: &Arc<Engine>, hero: Entity) -> Result<()> {
|
||||||
let reference = self.reference.clone();
|
let reference = self.reference.clone();
|
||||||
|
|
||||||
self.update_base(game_handle, |button, t, index| {
|
self.update_base(engine, |button, t, index| {
|
||||||
button.set_icon(&t.icon())?;
|
button.set_icon(&t.icon())?;
|
||||||
|
|
||||||
button.set_custom_callback({
|
button.set_custom_callback({
|
||||||
let game_handle = game_handle.clone();
|
let engine = engine.clone();
|
||||||
let reference = reference.clone();
|
let reference = reference.clone();
|
||||||
|
|
||||||
move |controller_button| {
|
move |controller_button| {
|
||||||
if let ControllerButton::X = controller_button {
|
if let ControllerButton::X = controller_button {
|
||||||
let game = game_handle.upgrade();
|
CharacterWindow::salvage_from_inventory(&engine, hero, |inventory| {
|
||||||
|
|
||||||
CharacterWindow::salvage_from_inventory(&game, hero, |inventory| {
|
|
||||||
inventory.remove_addon(index)
|
inventory.remove_addon(index)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
@ -101,7 +99,7 @@ impl ContentUpdate for Content<AbilityAddon> {
|
||||||
});
|
});
|
||||||
|
|
||||||
button.set_callback({
|
button.set_callback({
|
||||||
let game_handle = game_handle.clone();
|
let engine = engine.clone();
|
||||||
let reference = reference.clone();
|
let reference = reference.clone();
|
||||||
|
|
||||||
move || {
|
move || {
|
||||||
|
@ -109,7 +107,7 @@ impl ContentUpdate for Content<AbilityAddon> {
|
||||||
let mut tabs = menu.tabs_mut();
|
let mut tabs = menu.tabs_mut();
|
||||||
let abilities = tabs.abilities();
|
let abilities = tabs.abilities();
|
||||||
|
|
||||||
Self::insert_addon(&game_handle, hero, index, abilities)?;
|
Self::insert_addon(&engine, hero, index, abilities)?;
|
||||||
|
|
||||||
abilities.update_page()?;
|
abilities.update_page()?;
|
||||||
}
|
}
|
||||||
|
@ -120,20 +118,14 @@ impl ContentUpdate for Content<AbilityAddon> {
|
||||||
|
|
||||||
button.set_select_callback({
|
button.set_select_callback({
|
||||||
let weak_button = Arc::downgrade(&button);
|
let weak_button = Arc::downgrade(&button);
|
||||||
let game_handle = game_handle.clone();
|
let engine = engine.clone();
|
||||||
let reference = reference.clone();
|
let reference = reference.clone();
|
||||||
|
|
||||||
move |selected| {
|
move |selected| {
|
||||||
if selected {
|
if selected {
|
||||||
let button_pos = weak_button.upgrade().unwrap().position_extent();
|
let button_pos = weak_button.upgrade().unwrap().position_extent();
|
||||||
|
|
||||||
Self::show_addon_tooltip(
|
Self::show_addon_tooltip(&engine, hero, index, &reference, button_pos)?;
|
||||||
&game_handle,
|
|
||||||
hero,
|
|
||||||
index,
|
|
||||||
&reference,
|
|
||||||
button_pos,
|
|
||||||
)?;
|
|
||||||
} else {
|
} else {
|
||||||
let window = reference.upgrade().unwrap();
|
let window = reference.upgrade().unwrap();
|
||||||
|
|
||||||
|
@ -155,12 +147,12 @@ impl ContentUpdate for Content<AbilityAddon> {
|
||||||
|
|
||||||
impl Content<AbilityBook> {
|
impl Content<AbilityBook> {
|
||||||
fn equip_book(
|
fn equip_book(
|
||||||
game_handle: &GameHandle,
|
engine: &Arc<Engine>,
|
||||||
hero: Entity,
|
hero: Entity,
|
||||||
book_index: usize,
|
book_index: usize,
|
||||||
ability_page: &AbilityPage,
|
ability_page: &AbilityPage,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
game_handle.upgrade().engine().on_scene_mut(|scene| {
|
engine.on_scene_mut(|scene| {
|
||||||
let entity = scene.entity_mut(hero)?;
|
let entity = scene.entity_mut(hero)?;
|
||||||
let mut multi_mut = entity.multi_mut();
|
let mut multi_mut = entity.multi_mut();
|
||||||
|
|
||||||
|
@ -179,13 +171,13 @@ impl Content<AbilityBook> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show_book_tooltip(
|
fn show_book_tooltip(
|
||||||
game_handle: &GameHandle,
|
engine: &Arc<Engine>,
|
||||||
hero: Entity,
|
hero: Entity,
|
||||||
book_index: usize,
|
book_index: usize,
|
||||||
reference: &Weak<CharacterWindow>,
|
reference: &Weak<CharacterWindow>,
|
||||||
(x, y, w, _h): (i32, i32, u32, u32),
|
(x, y, w, _h): (i32, i32, u32, u32),
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
game_handle.upgrade().engine().on_scene(|scene| {
|
engine.on_scene(|scene| {
|
||||||
let entity = scene.entity(hero)?;
|
let entity = scene.entity(hero)?;
|
||||||
let inventory = entity.get_component::<Inventory>()?;
|
let inventory = entity.get_component::<Inventory>()?;
|
||||||
let statistics = entity.get_component::<Statistics>()?;
|
let statistics = entity.get_component::<Statistics>()?;
|
||||||
|
@ -194,7 +186,8 @@ impl Content<AbilityBook> {
|
||||||
let target_y = y;
|
let target_y = y;
|
||||||
|
|
||||||
let book = inventory.book_at(book_index);
|
let book = inventory.book_at(book_index);
|
||||||
let gui = book.create_tooltip(game_handle, statistics, (target_x, target_y))?;
|
let gui =
|
||||||
|
book.create_tooltip(engine.gui_handler(), statistics, (target_x, target_y))?;
|
||||||
gui.enable()?;
|
gui.enable()?;
|
||||||
|
|
||||||
let window = reference.upgrade().unwrap();
|
let window = reference.upgrade().unwrap();
|
||||||
|
@ -208,7 +201,7 @@ impl Content<AbilityBook> {
|
||||||
let target_y = button_pos.1;
|
let target_y = button_pos.1;
|
||||||
|
|
||||||
let compare_gui = selected_book.create_tooltip(
|
let compare_gui = selected_book.create_tooltip(
|
||||||
game_handle,
|
engine.gui_handler(),
|
||||||
statistics,
|
statistics,
|
||||||
(target_x, target_y),
|
(target_x, target_y),
|
||||||
)?;
|
)?;
|
||||||
|
@ -230,21 +223,19 @@ impl Content<AbilityBook> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ContentUpdate for Content<AbilityBook> {
|
impl ContentUpdate for Content<AbilityBook> {
|
||||||
fn update(&mut self, game_handle: &GameHandle, hero: Entity) -> Result<()> {
|
fn update(&mut self, engine: &Arc<Engine>, hero: Entity) -> Result<()> {
|
||||||
let reference = self.reference.clone();
|
let reference = self.reference.clone();
|
||||||
|
|
||||||
self.update_base(game_handle, |button, t, index| {
|
self.update_base(engine, |button, t, index| {
|
||||||
button.set_icon(&t.icon())?;
|
button.set_icon(&t.icon())?;
|
||||||
|
|
||||||
button.set_custom_callback({
|
button.set_custom_callback({
|
||||||
let game_handle = game_handle.clone();
|
let engine = engine.clone();
|
||||||
let reference = reference.clone();
|
let reference = reference.clone();
|
||||||
|
|
||||||
move |controller_button| {
|
move |controller_button| {
|
||||||
if let ControllerButton::X = controller_button {
|
if let ControllerButton::X = controller_button {
|
||||||
let game = game_handle.upgrade();
|
CharacterWindow::salvage_from_inventory(&engine, hero, |inventory| {
|
||||||
|
|
||||||
CharacterWindow::salvage_from_inventory(&game, hero, |inventory| {
|
|
||||||
inventory.remove_book(index)
|
inventory.remove_book(index)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
@ -263,7 +254,7 @@ impl ContentUpdate for Content<AbilityBook> {
|
||||||
});
|
});
|
||||||
|
|
||||||
button.set_callback({
|
button.set_callback({
|
||||||
let game_handle = game_handle.clone();
|
let engine = engine.clone();
|
||||||
let reference = reference.clone();
|
let reference = reference.clone();
|
||||||
|
|
||||||
move || {
|
move || {
|
||||||
|
@ -271,7 +262,7 @@ impl ContentUpdate for Content<AbilityBook> {
|
||||||
let mut tabs = menu.tabs_mut();
|
let mut tabs = menu.tabs_mut();
|
||||||
let abilities = tabs.abilities();
|
let abilities = tabs.abilities();
|
||||||
|
|
||||||
Self::equip_book(&game_handle, hero, index, abilities)?;
|
Self::equip_book(&engine, hero, index, abilities)?;
|
||||||
|
|
||||||
abilities.update_page()?;
|
abilities.update_page()?;
|
||||||
}
|
}
|
||||||
|
@ -282,14 +273,14 @@ impl ContentUpdate for Content<AbilityBook> {
|
||||||
|
|
||||||
button.set_select_callback({
|
button.set_select_callback({
|
||||||
let weak_button = Arc::downgrade(&button);
|
let weak_button = Arc::downgrade(&button);
|
||||||
let game_handle = game_handle.clone();
|
let engine = engine.clone();
|
||||||
let reference = reference.clone();
|
let reference = reference.clone();
|
||||||
|
|
||||||
move |selected| {
|
move |selected| {
|
||||||
if selected {
|
if selected {
|
||||||
let button_pos = weak_button.upgrade().unwrap().position_extent();
|
let button_pos = weak_button.upgrade().unwrap().position_extent();
|
||||||
|
|
||||||
Self::show_book_tooltip(&game_handle, hero, index, &reference, button_pos)?;
|
Self::show_book_tooltip(&engine, hero, index, &reference, button_pos)?;
|
||||||
} else {
|
} else {
|
||||||
let window = reference.upgrade().unwrap();
|
let window = reference.upgrade().unwrap();
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ use crate::*;
|
||||||
pub struct AbilityPage {
|
pub struct AbilityPage {
|
||||||
close: Weak<Button>,
|
close: Weak<Button>,
|
||||||
|
|
||||||
game_handle: GameHandle,
|
engine: Arc<Engine>,
|
||||||
hero: Entity,
|
hero: Entity,
|
||||||
|
|
||||||
grid: Arc<Grid>,
|
grid: Arc<Grid>,
|
||||||
|
@ -36,16 +36,17 @@ pub struct AbilityPage {
|
||||||
|
|
||||||
impl AbilityPage {
|
impl AbilityPage {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
game: GameHandle,
|
engine: &Arc<Engine>,
|
||||||
hero: Entity,
|
hero: Entity,
|
||||||
reference: Weak<CharacterWindow>,
|
reference: Weak<CharacterWindow>,
|
||||||
close: &Arc<Button>,
|
close: &Arc<Button>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let base = "gui/xml/ingame/character_menu/abilities/".to_string();
|
let grid = Grid::new(engine.gui_handler().clone(), 2, 1, false)?;
|
||||||
|
|
||||||
let grid = Grid::new(game.upgrade().engine().gui_handler().clone(), 2, 1, false)?;
|
let left_base = GuiSnippet::from_str(
|
||||||
|
engine.gui_handler(),
|
||||||
let left_base = game.gui_snippet((base.clone() + "left_side.xml").as_str())?;
|
include_str!("../../resources/abilities/left_side.xml"),
|
||||||
|
)?;
|
||||||
grid.attach(left_base.clone(), 0, 0, 1, 1)?;
|
grid.attach(left_base.clone(), 0, 0, 1, 1)?;
|
||||||
|
|
||||||
Self::setup_content_switch(&left_base, reference.clone())?;
|
Self::setup_content_switch(&left_base, reference.clone())?;
|
||||||
|
@ -55,15 +56,14 @@ impl AbilityPage {
|
||||||
|
|
||||||
// abilities
|
// abilities
|
||||||
let ability_mode = PageContent::new(
|
let ability_mode = PageContent::new(
|
||||||
Content::new(&game, reference.clone(), {
|
Content::new(&engine, reference.clone(), {
|
||||||
let game_handle = game.clone();
|
let engine = engine.clone();
|
||||||
let hero = hero.clone();
|
let hero = hero.clone();
|
||||||
|
|
||||||
move || {
|
move || {
|
||||||
let game = game_handle.upgrade();
|
|
||||||
let mut data = Vec::new();
|
let mut data = Vec::new();
|
||||||
|
|
||||||
game.engine().on_scene(|scene| {
|
engine.on_scene(|scene| {
|
||||||
let hero_object = scene.entity(hero)?;
|
let hero_object = scene.entity(hero)?;
|
||||||
let inventory = hero_object.get_component::<Inventory>()?;
|
let inventory = hero_object.get_component::<Inventory>()?;
|
||||||
|
|
||||||
|
@ -76,19 +76,22 @@ impl AbilityPage {
|
||||||
}
|
}
|
||||||
})?,
|
})?,
|
||||||
{
|
{
|
||||||
let ui = game.gui_snippet((base.clone() + "ability_tooltip.xml").as_str())?;
|
let ui = GuiSnippet::from_str(
|
||||||
|
engine.gui_handler(),
|
||||||
|
include_str!("../../resources/abilities/ability_tooltip.xml"),
|
||||||
|
)?;
|
||||||
|
|
||||||
let equip: Arc<Label> = ui.element("equip")?;
|
let equip: Arc<Label> = ui.element("equip")?;
|
||||||
equip.set_info_icon(&game.controller_icon(ControllerButton::A)?)?;
|
equip.set_info_icon(&engine.controller_icon(ControllerButton::A)?)?;
|
||||||
|
|
||||||
let upgrade: Arc<Label> = ui.element("upgrade")?;
|
let upgrade: Arc<Label> = ui.element("upgrade")?;
|
||||||
upgrade.set_info_icon(&game.controller_icon(ControllerButton::Y)?)?;
|
upgrade.set_info_icon(&engine.controller_icon(ControllerButton::Y)?)?;
|
||||||
|
|
||||||
let salvage: Arc<Label> = ui.element("salvage")?;
|
let salvage: Arc<Label> = ui.element("salvage")?;
|
||||||
salvage.set_info_icon(&game.controller_icon(ControllerButton::X)?)?;
|
salvage.set_info_icon(&engine.controller_icon(ControllerButton::X)?)?;
|
||||||
|
|
||||||
let switch_mode: Arc<Label> = ui.element("switch_mode")?;
|
let switch_mode: Arc<Label> = ui.element("switch_mode")?;
|
||||||
switch_mode.set_info_icon(&game.controller_icon(ControllerButton::LeftStick)?)?;
|
switch_mode.set_info_icon(&engine.controller_icon(ControllerButton::LeftStick)?)?;
|
||||||
|
|
||||||
ui
|
ui
|
||||||
},
|
},
|
||||||
|
@ -97,15 +100,14 @@ impl AbilityPage {
|
||||||
|
|
||||||
// addons
|
// addons
|
||||||
let addons_mode = PageContent::new(
|
let addons_mode = PageContent::new(
|
||||||
Content::new(&game, reference.clone(), {
|
Content::new(&engine, reference.clone(), {
|
||||||
let game_handle = game.clone();
|
let engine = engine.clone();
|
||||||
let hero = hero.clone();
|
let hero = hero.clone();
|
||||||
|
|
||||||
move || {
|
move || {
|
||||||
let game = game_handle.upgrade();
|
|
||||||
let mut data = Vec::new();
|
let mut data = Vec::new();
|
||||||
|
|
||||||
game.engine().on_scene(|scene| {
|
engine.on_scene(|scene| {
|
||||||
let hero_object = scene.entity(hero)?;
|
let hero_object = scene.entity(hero)?;
|
||||||
let inventory = hero_object.get_component::<Inventory>()?;
|
let inventory = hero_object.get_component::<Inventory>()?;
|
||||||
|
|
||||||
|
@ -118,28 +120,31 @@ impl AbilityPage {
|
||||||
}
|
}
|
||||||
})?,
|
})?,
|
||||||
{
|
{
|
||||||
let ui = game.gui_snippet((base.clone() + "addon_tooltip.xml").as_str())?;
|
let ui = GuiSnippet::from_str(
|
||||||
|
engine.gui_handler(),
|
||||||
|
include_str!("../../resources/abilities/addon_tooltip.xml"),
|
||||||
|
)?;
|
||||||
|
|
||||||
let equip: Arc<Label> = ui.element("socket")?;
|
let equip: Arc<Label> = ui.element("socket")?;
|
||||||
equip.set_info_icon(&game.controller_icon(ControllerButton::A)?)?;
|
equip.set_info_icon(&engine.controller_icon(ControllerButton::A)?)?;
|
||||||
|
|
||||||
let salvage: Arc<Label> = ui.element("salvage")?;
|
let salvage: Arc<Label> = ui.element("salvage")?;
|
||||||
salvage.set_info_icon(&game.controller_icon(ControllerButton::X)?)?;
|
salvage.set_info_icon(&engine.controller_icon(ControllerButton::X)?)?;
|
||||||
|
|
||||||
let switch_mode: Arc<Label> = ui.element("switch_mode")?;
|
let switch_mode: Arc<Label> = ui.element("switch_mode")?;
|
||||||
switch_mode.set_info_icon(&game.controller_icon(ControllerButton::LeftStick)?)?;
|
switch_mode.set_info_icon(&engine.controller_icon(ControllerButton::LeftStick)?)?;
|
||||||
|
|
||||||
ui
|
ui
|
||||||
},
|
},
|
||||||
EmptyRightSide,
|
EmptyRightSide,
|
||||||
);
|
);
|
||||||
|
|
||||||
let right_side = AbilityPageRightSide::new(&game, &reference, hero)?;
|
let right_side = AbilityPageRightSide::new(&engine, &reference, hero)?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
close: Arc::downgrade(close),
|
close: Arc::downgrade(close),
|
||||||
|
|
||||||
game_handle: game,
|
engine: engine.clone(),
|
||||||
hero,
|
hero,
|
||||||
|
|
||||||
grid,
|
grid,
|
||||||
|
@ -164,13 +169,13 @@ impl AbilityPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mode = &mut self.modes[self.current_mode];
|
let mode = &mut self.modes[self.current_mode];
|
||||||
mode.content_mut().update(&self.game_handle, self.hero)?;
|
mode.content_mut().update(&self.engine, self.hero)?;
|
||||||
|
|
||||||
self.tooltip.attach(mode.tooltip().clone(), 0, 0, 1, 1)?;
|
self.tooltip.attach(mode.tooltip().clone(), 0, 0, 1, 1)?;
|
||||||
self.content
|
self.content
|
||||||
.attach(mode.content_mut().base().clone(), 0, 0, 1, 1)?;
|
.attach(mode.content_mut().base().clone(), 0, 0, 1, 1)?;
|
||||||
|
|
||||||
self.right_side.refresh(&self.game_handle, self.hero)?;
|
self.right_side.refresh(&self.engine, self.hero)?;
|
||||||
self.grid
|
self.grid
|
||||||
.attach(self.right_side.base().clone(), 1, 0, 1, 1)?;
|
.attach(self.right_side.base().clone(), 1, 0, 1, 1)?;
|
||||||
|
|
||||||
|
@ -252,13 +257,13 @@ impl Page for AbilityPage {
|
||||||
fn next_tab(&mut self) -> Result<()> {
|
fn next_tab(&mut self) -> Result<()> {
|
||||||
self.modes[self.current_mode]
|
self.modes[self.current_mode]
|
||||||
.content_mut()
|
.content_mut()
|
||||||
.next_tab(&self.game_handle, self.hero)
|
.next_tab(&self.engine, self.hero)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn previous_tab(&mut self) -> Result<()> {
|
fn previous_tab(&mut self) -> Result<()> {
|
||||||
self.modes[self.current_mode]
|
self.modes[self.current_mode]
|
||||||
.content_mut()
|
.content_mut()
|
||||||
.previous_tab(&self.game_handle, self.hero)
|
.previous_tab(&self.engine, self.hero)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn event(&mut self, button: ControllerButton) -> Result<bool> {
|
fn event(&mut self, button: ControllerButton) -> Result<bool> {
|
||||||
|
@ -271,7 +276,7 @@ impl Page for AbilityPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
ControllerButton::RightStick => {
|
ControllerButton::RightStick => {
|
||||||
self.right_side.next_ability(&self.game_handle, self.hero)?;
|
self.right_side.next_ability(&self.engine, self.hero)?;
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ impl CharacterPage {
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let snippet = GuiSnippet::from_str(
|
let snippet = GuiSnippet::from_str(
|
||||||
engine.gui_handler(),
|
engine.gui_handler(),
|
||||||
include_str!("../../resources/statistics.xml"),
|
include_str!("../../resources/character/statistics.xml"),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let grid: Arc<Grid> = snippet.element("statistic_tab")?;
|
let grid: Arc<Grid> = snippet.element("statistic_tab")?;
|
||||||
|
@ -38,7 +38,7 @@ impl CharacterPage {
|
||||||
|
|
||||||
let strength: Arc<Button> = snippet.element("strength_field")?;
|
let strength: Arc<Button> = snippet.element("strength_field")?;
|
||||||
strength.set_callback({
|
strength.set_callback({
|
||||||
let update_stats = Self::create_update_stats(hero, game_handle, reference);
|
let update_stats = Self::create_update_stats(hero, engine, reference);
|
||||||
|
|
||||||
move || {
|
move || {
|
||||||
update_stats(|attributes| {
|
update_stats(|attributes| {
|
||||||
|
@ -49,7 +49,7 @@ impl CharacterPage {
|
||||||
|
|
||||||
let agility: Arc<Button> = snippet.element("agility_field")?;
|
let agility: Arc<Button> = snippet.element("agility_field")?;
|
||||||
agility.set_callback({
|
agility.set_callback({
|
||||||
let update_stats = Self::create_update_stats(hero, game_handle, reference);
|
let update_stats = Self::create_update_stats(hero, engine, reference);
|
||||||
|
|
||||||
move || {
|
move || {
|
||||||
update_stats(|attributes| {
|
update_stats(|attributes| {
|
||||||
|
@ -60,7 +60,7 @@ impl CharacterPage {
|
||||||
|
|
||||||
let intelligence: Arc<Button> = snippet.element("intelligence_field")?;
|
let intelligence: Arc<Button> = snippet.element("intelligence_field")?;
|
||||||
intelligence.set_callback({
|
intelligence.set_callback({
|
||||||
let update_stats = Self::create_update_stats(hero, game_handle, reference);
|
let update_stats = Self::create_update_stats(hero, engine, reference);
|
||||||
|
|
||||||
move || {
|
move || {
|
||||||
update_stats(|attributes| {
|
update_stats(|attributes| {
|
||||||
|
@ -70,7 +70,7 @@ impl CharacterPage {
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
engine,
|
engine: engine.clone(),
|
||||||
hero,
|
hero,
|
||||||
|
|
||||||
snippet,
|
snippet,
|
||||||
|
@ -156,7 +156,7 @@ impl CharacterPage {
|
||||||
|
|
||||||
attributes_label.set_text(format!(
|
attributes_label.set_text(format!(
|
||||||
"Attributes ({})",
|
"Attributes ({})",
|
||||||
Self::available_attribute_points(&game, attributes, level)
|
Self::available_attribute_points(&self.engine, attributes, level)
|
||||||
))?;
|
))?;
|
||||||
|
|
||||||
strength.set_text(attributes.strength().raw())?;
|
strength.set_text(attributes.strength().raw())?;
|
||||||
|
@ -167,7 +167,11 @@ impl CharacterPage {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn available_attribute_points(game: &Game, attributes: &Attributes, level: &Level) -> u32 {
|
fn available_attribute_points(
|
||||||
|
engine: &Arc<Engine>,
|
||||||
|
attributes: &Attributes,
|
||||||
|
level: &Level,
|
||||||
|
) -> u32 {
|
||||||
let total_attribute_points = game.attribute_settings.meta_settings.starting_skill_points
|
let total_attribute_points = game.attribute_settings.meta_settings.starting_skill_points
|
||||||
+ level.level() * game.attribute_settings.meta_settings.skill_points_per_level
|
+ level.level() * game.attribute_settings.meta_settings.skill_points_per_level
|
||||||
+ game.attribute_settings.starting_attributes.sum();
|
+ game.attribute_settings.starting_attributes.sum();
|
||||||
|
@ -198,13 +202,13 @@ impl CharacterPage {
|
||||||
let level = multi_mut.get::<Level>()?;
|
let level = multi_mut.get::<Level>()?;
|
||||||
let attributes = multi_mut.get::<Attributes>()?;
|
let attributes = multi_mut.get::<Attributes>()?;
|
||||||
|
|
||||||
if Self::available_attribute_points(&game, attributes, level) > 0 {
|
if Self::available_attribute_points(&engine, attributes, level) > 0 {
|
||||||
upgrade(attributes);
|
upgrade(attributes);
|
||||||
|
|
||||||
let statistics = multi_mut.get::<Statistics>()?;
|
let statistics = multi_mut.get::<Statistics>()?;
|
||||||
let items = multi_mut.get::<ItemSlotContainer>()?;
|
let items = multi_mut.get::<ItemSlotContainer>()?;
|
||||||
|
|
||||||
statistics.update(attributes, &game.attribute_settings, &*items);
|
statistics.update(attributes, &engine.attribute_settings, &*items);
|
||||||
|
|
||||||
upgraded = true;
|
upgraded = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,14 +4,14 @@ use crate::*;
|
||||||
|
|
||||||
pub trait ContentWrapper: ContentUpdate + Send + Sync {
|
pub trait ContentWrapper: ContentUpdate + Send + Sync {
|
||||||
fn refresh(&mut self) -> Result<()>;
|
fn refresh(&mut self) -> Result<()>;
|
||||||
fn next_tab(&mut self, game_handle: &GameHandle, hero: Entity) -> Result<()>;
|
fn next_tab(&mut self, engine: &Arc<Engine>, hero: Entity) -> Result<()>;
|
||||||
fn previous_tab(&mut self, game_handle: &GameHandle, hero: Entity) -> Result<()>;
|
fn previous_tab(&mut self, engine: &Arc<Engine>, hero: Entity) -> Result<()>;
|
||||||
fn base(&self) -> &Arc<GuiSnippet>;
|
fn base(&self) -> &Arc<GuiSnippet>;
|
||||||
fn is_empty(&self) -> bool;
|
fn is_empty(&self) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ContentUpdate {
|
pub trait ContentUpdate {
|
||||||
fn update(&mut self, game_handle: &GameHandle, hero: Entity) -> Result<()>;
|
fn update(&mut self, engine: &Arc<Engine>, hero: Entity) -> Result<()>;
|
||||||
fn select(&self) -> Result<()>;
|
fn select(&self) -> Result<()>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,18 +27,25 @@ pub struct Content<T: Send + Sync> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Send + Sync> Content<T> {
|
impl<T: Send + Sync> Content<T> {
|
||||||
pub fn new<F>(game: &GameHandle, reference: Weak<CharacterWindow>, on_enable: F) -> Result<Self>
|
pub fn new<F>(
|
||||||
|
engine: &Arc<Engine>,
|
||||||
|
reference: Weak<CharacterWindow>,
|
||||||
|
on_enable: F,
|
||||||
|
) -> Result<Self>
|
||||||
where
|
where
|
||||||
F: Fn() -> Result<Vec<T>> + Send + Sync + 'static,
|
F: Fn() -> Result<Vec<T>> + Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
let base = game.gui_snippet("gui/xml/ingame/character_menu/content.xml")?;
|
let base = GuiSnippet::from_str(
|
||||||
|
engine.gui_handler(),
|
||||||
|
include_str!("../resources/content.xml"),
|
||||||
|
)?;
|
||||||
|
|
||||||
let left: Arc<Button> = base.element("left")?;
|
let left: Arc<Button> = base.element("left")?;
|
||||||
left.set_text("<")?;
|
left.set_text("<")?;
|
||||||
left.set_info_icon(&game.controller_icon(ControllerButton::LeftTrigger)?)?;
|
left.set_info_icon(&engine.controller_icon(ControllerButton::LeftTrigger)?)?;
|
||||||
let right: Arc<Button> = base.element("right")?;
|
let right: Arc<Button> = base.element("right")?;
|
||||||
right.set_text(">")?;
|
right.set_text(">")?;
|
||||||
right.set_info_icon(&game.controller_icon(ControllerButton::RightTrigger)?)?;
|
right.set_info_icon(&engine.controller_icon(ControllerButton::RightTrigger)?)?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
reference,
|
reference,
|
||||||
|
@ -68,7 +75,7 @@ impl<T: Send + Sync> Content<T> {
|
||||||
label.set_text(format!("{} / {}", self.page + 1, self.pages))
|
label.set_text(format!("{} / {}", self.page + 1, self.pages))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_base<F>(&mut self, game_handle: &GameHandle, setup: F) -> Result<()>
|
pub fn update_base<F>(&mut self, engine: &Arc<Engine>, setup: F) -> Result<()>
|
||||||
where
|
where
|
||||||
Self: ContentWrapper,
|
Self: ContentWrapper,
|
||||||
F: Fn(&Arc<Button>, &T, usize) -> Result<()>,
|
F: Fn(&Arc<Button>, &T, usize) -> Result<()>,
|
||||||
|
@ -89,8 +96,10 @@ impl<T: Send + Sync> Content<T> {
|
||||||
|
|
||||||
match self.data.get(index) {
|
match self.data.get(index) {
|
||||||
Some(t) => {
|
Some(t) => {
|
||||||
let snippet = game_handle
|
let snippet = GuiSnippet::from_str(
|
||||||
.gui_snippet("gui/xml/ingame/character_menu/content_button.xml")?;
|
engine.gui_handler(),
|
||||||
|
include_str!("../resources/content_button.xml"),
|
||||||
|
)?;
|
||||||
|
|
||||||
let button: Arc<Button> = snippet.element("button")?;
|
let button: Arc<Button> = snippet.element("button")?;
|
||||||
setup(&button, t, index)?;
|
setup(&button, t, index)?;
|
||||||
|
@ -130,19 +139,19 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn next_tab(&mut self, game_handle: &GameHandle, hero: Entity) -> Result<()> {
|
fn next_tab(&mut self, engine: &Arc<Engine>, hero: Entity) -> Result<()> {
|
||||||
if self.page < (self.pages - 1) {
|
if self.page < (self.pages - 1) {
|
||||||
self.page += 1;
|
self.page += 1;
|
||||||
self.update(game_handle, hero)?;
|
self.update(engine, hero)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn previous_tab(&mut self, game_handle: &GameHandle, hero: Entity) -> Result<()> {
|
fn previous_tab(&mut self, engine: &Arc<Engine>, hero: Entity) -> Result<()> {
|
||||||
if self.page > 0 {
|
if self.page > 0 {
|
||||||
self.page -= 1;
|
self.page -= 1;
|
||||||
self.update(game_handle, hero)?;
|
self.update(engine, hero)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -16,8 +16,8 @@ use crate::{
|
||||||
use super::jewel_right_side::{LowerJewels, ReferenceItemSource, ReferenceObject};
|
use super::jewel_right_side::{LowerJewels, ReferenceItemSource, ReferenceObject};
|
||||||
|
|
||||||
impl Content<Item> {
|
impl Content<Item> {
|
||||||
fn salvage_item(game: &Game, hero: Entity, item_index: usize) -> Result<()> {
|
fn salvage_item(engine: &Arc<Engine>, hero: Entity, item_index: usize) -> Result<()> {
|
||||||
CharacterWindow::salvage_from_inventory(game, hero, |inventory| {
|
CharacterWindow::salvage_from_inventory(engine, hero, |inventory| {
|
||||||
let mut item = inventory.remove_item(item_index);
|
let mut item = inventory.remove_item(item_index);
|
||||||
|
|
||||||
// unsocket jewels and add them into inventory
|
// unsocket jewels and add them into inventory
|
||||||
|
@ -35,10 +35,10 @@ impl Content<Item> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select_to_socket(game: &Game, hero: Entity, item_index: usize) -> Result<bool> {
|
fn select_to_socket(engine: &Arc<Engine>, hero: Entity, item_index: usize) -> Result<bool> {
|
||||||
let mut has_empty_sockets = true;
|
let mut has_empty_sockets = true;
|
||||||
|
|
||||||
game.engine().on_scene_mut(|scene| {
|
engine.on_scene_mut(|scene| {
|
||||||
let entity = scene.entity(hero)?;
|
let entity = scene.entity(hero)?;
|
||||||
let inventory = entity.get_component::<Inventory>()?;
|
let inventory = entity.get_component::<Inventory>()?;
|
||||||
let item = inventory.item_at(item_index).clone();
|
let item = inventory.item_at(item_index).clone();
|
||||||
|
@ -66,8 +66,8 @@ impl Content<Item> {
|
||||||
Ok(has_empty_sockets)
|
Ok(has_empty_sockets)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn equip_item(game: &Game, hero: Entity, item_index: usize) -> Result<()> {
|
fn equip_item(engine: &Arc<Engine>, hero: Entity, item_index: usize) -> Result<()> {
|
||||||
game.engine().on_scene_mut(|scene| {
|
engine.on_scene_mut(|scene| {
|
||||||
let entity = scene.entity_mut(hero)?;
|
let entity = scene.entity_mut(hero)?;
|
||||||
|
|
||||||
let mut multi_mut = entity.multi_mut();
|
let mut multi_mut = entity.multi_mut();
|
||||||
|
@ -87,20 +87,20 @@ impl Content<Item> {
|
||||||
// update hero stats
|
// update hero stats
|
||||||
let statistics = multi_mut.get::<Statistics>()?;
|
let statistics = multi_mut.get::<Statistics>()?;
|
||||||
|
|
||||||
statistics.update(attributes, &game.attribute_settings, &*hero_items);
|
statistics.update(attributes, &engine.attribute_settings, &*hero_items);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show_item_tooltip(
|
fn show_item_tooltip(
|
||||||
game_handle: &GameHandle,
|
engine: &Arc<Engine>,
|
||||||
hero: Entity,
|
hero: Entity,
|
||||||
item_index: usize,
|
item_index: usize,
|
||||||
reference: &Weak<CharacterWindow>,
|
reference: &Weak<CharacterWindow>,
|
||||||
(x, y, w, _h): (i32, i32, u32, u32),
|
(x, y, w, _h): (i32, i32, u32, u32),
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
game_handle.upgrade().engine().on_scene(|scene| {
|
engine.on_scene(|scene| {
|
||||||
let entity = scene.entity(hero)?;
|
let entity = scene.entity(hero)?;
|
||||||
|
|
||||||
let inventory = entity.get_component::<Inventory>()?;
|
let inventory = entity.get_component::<Inventory>()?;
|
||||||
|
@ -110,7 +110,8 @@ impl Content<Item> {
|
||||||
let target_y = y;
|
let target_y = y;
|
||||||
|
|
||||||
let item = inventory.item_at(item_index);
|
let item = inventory.item_at(item_index);
|
||||||
let gui = item.create_tooltip(game_handle, attributes, (target_x, target_y))?;
|
let gui =
|
||||||
|
item.create_tooltip(engine.gui_handler(), attributes, (target_x, target_y))?;
|
||||||
gui.enable()?;
|
gui.enable()?;
|
||||||
|
|
||||||
let window = reference.upgrade().unwrap();
|
let window = reference.upgrade().unwrap();
|
||||||
|
@ -124,8 +125,11 @@ impl Content<Item> {
|
||||||
let start_x = grid_pos.0 + grid_pos.2 as i32 + spacing;
|
let start_x = grid_pos.0 + grid_pos.2 as i32 + spacing;
|
||||||
let start_y = grid_pos.1;
|
let start_y = grid_pos.1;
|
||||||
|
|
||||||
let compare_gui =
|
let compare_gui = equipped.create_tooltip(
|
||||||
equipped.create_tooltip(game_handle, attributes, (start_x, start_y))?;
|
engine.gui_handler(),
|
||||||
|
attributes,
|
||||||
|
(start_x, start_y),
|
||||||
|
)?;
|
||||||
compare_gui.enable()?;
|
compare_gui.enable()?;
|
||||||
gui.perform_double_check(&compare_gui, x, spacing as u32)?;
|
gui.perform_double_check(&compare_gui, x, spacing as u32)?;
|
||||||
|
|
||||||
|
@ -146,22 +150,20 @@ impl Content<Item> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ContentUpdate for Content<Item> {
|
impl ContentUpdate for Content<Item> {
|
||||||
fn update(&mut self, game_handle: &GameHandle, hero: Entity) -> Result<()> {
|
fn update(&mut self, engine: &Arc<Engine>, hero: Entity) -> Result<()> {
|
||||||
let reference = self.reference.clone();
|
let reference = self.reference.clone();
|
||||||
|
|
||||||
self.update_base(game_handle, |button, t, index| {
|
self.update_base(engine, |button, t, index| {
|
||||||
button.set_icon(&t.icon)?;
|
button.set_icon(&t.icon)?;
|
||||||
|
|
||||||
button.set_custom_callback({
|
button.set_custom_callback({
|
||||||
let game_handle = game_handle.clone();
|
|
||||||
let reference = reference.clone();
|
let reference = reference.clone();
|
||||||
|
let engine = engine.clone();
|
||||||
|
|
||||||
move |controller_button| {
|
move |controller_button| {
|
||||||
Ok(match controller_button {
|
Ok(match controller_button {
|
||||||
ControllerButton::X => {
|
ControllerButton::X => {
|
||||||
let game = game_handle.upgrade();
|
Self::salvage_item(&engine, hero, index)?;
|
||||||
|
|
||||||
Self::salvage_item(&game, hero, index)?;
|
|
||||||
|
|
||||||
if let Some(menu) = reference.upgrade() {
|
if let Some(menu) = reference.upgrade() {
|
||||||
let mut tabs = menu.tabs_mut();
|
let mut tabs = menu.tabs_mut();
|
||||||
|
@ -174,9 +176,7 @@ impl ContentUpdate for Content<Item> {
|
||||||
}
|
}
|
||||||
|
|
||||||
ControllerButton::Y => {
|
ControllerButton::Y => {
|
||||||
let game = game_handle.upgrade();
|
if Self::select_to_socket(&engine, hero, index)? {
|
||||||
|
|
||||||
if Self::select_to_socket(&game, hero, index)? {
|
|
||||||
if let Some(menu) = reference.upgrade() {
|
if let Some(menu) = reference.upgrade() {
|
||||||
let mut tabs = menu.tabs_mut();
|
let mut tabs = menu.tabs_mut();
|
||||||
let inventory = tabs.inventory();
|
let inventory = tabs.inventory();
|
||||||
|
@ -194,13 +194,11 @@ impl ContentUpdate for Content<Item> {
|
||||||
});
|
});
|
||||||
|
|
||||||
button.set_callback({
|
button.set_callback({
|
||||||
let game_handle = game_handle.clone();
|
|
||||||
let reference = reference.clone();
|
let reference = reference.clone();
|
||||||
|
let engine = engine.clone();
|
||||||
|
|
||||||
move || {
|
move || {
|
||||||
let game = game_handle.upgrade();
|
Self::equip_item(&engine, hero, index)?;
|
||||||
|
|
||||||
Self::equip_item(&game, hero, index)?;
|
|
||||||
|
|
||||||
if let Some(menu) = reference.upgrade() {
|
if let Some(menu) = reference.upgrade() {
|
||||||
let mut tabs = menu.tabs_mut();
|
let mut tabs = menu.tabs_mut();
|
||||||
|
@ -215,14 +213,14 @@ impl ContentUpdate for Content<Item> {
|
||||||
|
|
||||||
button.set_select_callback({
|
button.set_select_callback({
|
||||||
let weak_button = Arc::downgrade(&button);
|
let weak_button = Arc::downgrade(&button);
|
||||||
let game_handle = game_handle.clone();
|
|
||||||
let reference = reference.clone();
|
let reference = reference.clone();
|
||||||
|
let engine = engine.clone();
|
||||||
|
|
||||||
move |selected| {
|
move |selected| {
|
||||||
if selected {
|
if selected {
|
||||||
let button_pos = weak_button.upgrade().unwrap().position_extent();
|
let button_pos = weak_button.upgrade().unwrap().position_extent();
|
||||||
|
|
||||||
Self::show_item_tooltip(&game_handle, hero, index, &reference, button_pos)?;
|
Self::show_item_tooltip(&engine, hero, index, &reference, button_pos)?;
|
||||||
} else {
|
} else {
|
||||||
let window = reference.upgrade().unwrap();
|
let window = reference.upgrade().unwrap();
|
||||||
|
|
||||||
|
@ -245,13 +243,13 @@ impl ContentUpdate for Content<Item> {
|
||||||
|
|
||||||
impl Content<Jewel> {
|
impl Content<Jewel> {
|
||||||
fn show_jewel_tooltip(
|
fn show_jewel_tooltip(
|
||||||
game_handle: &GameHandle,
|
engine: &Arc<Engine>,
|
||||||
hero: Entity,
|
hero: Entity,
|
||||||
item_index: usize,
|
item_index: usize,
|
||||||
reference: &Weak<CharacterWindow>,
|
reference: &Weak<CharacterWindow>,
|
||||||
(x, y, w, _h): (i32, i32, u32, u32),
|
(x, y, w, _h): (i32, i32, u32, u32),
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
game_handle.upgrade().engine().on_scene(|scene| {
|
engine.on_scene(|scene| {
|
||||||
let entity = scene.entity(hero)?;
|
let entity = scene.entity(hero)?;
|
||||||
let inventory = entity.get_component::<Inventory>()?;
|
let inventory = entity.get_component::<Inventory>()?;
|
||||||
|
|
||||||
|
@ -260,8 +258,8 @@ impl Content<Jewel> {
|
||||||
|
|
||||||
let jewel = inventory.jewel_at(item_index);
|
let jewel = inventory.jewel_at(item_index);
|
||||||
let gui = jewel.create_tooltip(
|
let gui = jewel.create_tooltip(
|
||||||
game_handle,
|
engine.gui_handler(),
|
||||||
&game_handle.upgrade().item_settings,
|
&engine.upgrade().item_settings,
|
||||||
(target_x, target_y),
|
(target_x, target_y),
|
||||||
)?;
|
)?;
|
||||||
gui.enable()?;
|
gui.enable()?;
|
||||||
|
@ -278,8 +276,8 @@ impl Content<Jewel> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select_to_combine(game: &Game, hero: Entity, jewel_index: usize) -> Result<()> {
|
fn select_to_combine(engine: &Arc<Engine>, hero: Entity, jewel_index: usize) -> Result<()> {
|
||||||
game.engine().on_scene_mut(|scene| {
|
engine.on_scene_mut(|scene| {
|
||||||
let entity = scene.entity(hero)?;
|
let entity = scene.entity(hero)?;
|
||||||
let inventory = entity.get_component::<Inventory>()?;
|
let inventory = entity.get_component::<Inventory>()?;
|
||||||
let jewel = inventory.jewel_at(jewel_index).clone();
|
let jewel = inventory.jewel_at(jewel_index).clone();
|
||||||
|
@ -305,8 +303,8 @@ impl Content<Jewel> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select_to_lower(game: &Game, hero: Entity, jewel_index: usize) -> Result<()> {
|
fn select_to_lower(engine: &Arc<Engine>, hero: Entity, jewel_index: usize) -> Result<()> {
|
||||||
game.engine().on_scene_mut(|scene| {
|
engine.on_scene_mut(|scene| {
|
||||||
let entity = scene.entity(hero)?;
|
let entity = scene.entity(hero)?;
|
||||||
let inventory = entity.get_component::<Inventory>()?;
|
let inventory = entity.get_component::<Inventory>()?;
|
||||||
let jewel = inventory.jewel_at(jewel_index).clone();
|
let jewel = inventory.jewel_at(jewel_index).clone();
|
||||||
|
@ -339,28 +337,22 @@ impl Content<Jewel> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ContentUpdate for Content<Jewel> {
|
impl ContentUpdate for Content<Jewel> {
|
||||||
fn update(&mut self, game_handle: &GameHandle, hero: Entity) -> Result<()> {
|
fn update(&mut self, engine: &Arc<Engine>, hero: Entity) -> Result<()> {
|
||||||
let reference = self.reference.clone();
|
let reference = self.reference.clone();
|
||||||
|
|
||||||
self.update_base(game_handle, |button, t, index| {
|
self.update_base(engine, |button, t, index| {
|
||||||
button.set_icon(&t.icon())?;
|
button.set_icon(&t.icon())?;
|
||||||
|
|
||||||
button.set_select_callback({
|
button.set_select_callback({
|
||||||
let weak_button = Arc::downgrade(&button);
|
let weak_button = Arc::downgrade(&button);
|
||||||
let game_handle = game_handle.clone();
|
let engine = engine.clone();
|
||||||
let reference = reference.clone();
|
let reference = reference.clone();
|
||||||
|
|
||||||
move |selected| {
|
move |selected| {
|
||||||
if selected {
|
if selected {
|
||||||
let button_pos = weak_button.upgrade().unwrap().position_extent();
|
let button_pos = weak_button.upgrade().unwrap().position_extent();
|
||||||
|
|
||||||
Self::show_jewel_tooltip(
|
Self::show_jewel_tooltip(&engine, hero, index, &reference, button_pos)?;
|
||||||
&game_handle,
|
|
||||||
hero,
|
|
||||||
index,
|
|
||||||
&reference,
|
|
||||||
button_pos,
|
|
||||||
)?;
|
|
||||||
} else {
|
} else {
|
||||||
let window = reference.upgrade().unwrap();
|
let window = reference.upgrade().unwrap();
|
||||||
|
|
||||||
|
@ -372,13 +364,11 @@ impl ContentUpdate for Content<Jewel> {
|
||||||
});
|
});
|
||||||
|
|
||||||
button.set_callback({
|
button.set_callback({
|
||||||
let game_handle = game_handle.clone();
|
let engine = engine.clone();
|
||||||
let reference = reference.clone();
|
let reference = reference.clone();
|
||||||
|
|
||||||
move || {
|
move || {
|
||||||
let game = game_handle.upgrade();
|
Self::select_to_lower(&engine, hero, index)?;
|
||||||
|
|
||||||
Self::select_to_lower(&game, hero, index)?;
|
|
||||||
|
|
||||||
if let Some(menu) = reference.upgrade() {
|
if let Some(menu) = reference.upgrade() {
|
||||||
let mut tabs = menu.tabs_mut();
|
let mut tabs = menu.tabs_mut();
|
||||||
|
@ -392,15 +382,13 @@ impl ContentUpdate for Content<Jewel> {
|
||||||
});
|
});
|
||||||
|
|
||||||
button.set_custom_callback({
|
button.set_custom_callback({
|
||||||
let game_handle = game_handle.clone();
|
let engine = engine.clone();
|
||||||
let reference = reference.clone();
|
let reference = reference.clone();
|
||||||
|
|
||||||
move |controller_button| {
|
move |controller_button| {
|
||||||
Ok(match controller_button {
|
Ok(match controller_button {
|
||||||
ControllerButton::Y => {
|
ControllerButton::Y => {
|
||||||
let game = game_handle.upgrade();
|
Self::select_to_combine(&engine, hero, index)?;
|
||||||
|
|
||||||
Self::select_to_combine(&game, hero, index)?;
|
|
||||||
|
|
||||||
if let Some(menu) = reference.upgrade() {
|
if let Some(menu) = reference.upgrade() {
|
||||||
let mut tabs = menu.tabs_mut();
|
let mut tabs = menu.tabs_mut();
|
||||||
|
@ -427,8 +415,8 @@ impl ContentUpdate for Content<Jewel> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ContentUpdate for Content<MapItem> {
|
impl ContentUpdate for Content<MapItem> {
|
||||||
fn update(&mut self, game_handle: &GameHandle, _hero: Entity) -> Result<()> {
|
fn update(&mut self, engine: &Arc<Engine>, _hero: Entity) -> Result<()> {
|
||||||
self.update_base(game_handle, |_button, _t, _index| {
|
self.update_base(engine, |_button, _t, _index| {
|
||||||
// button.set_icon(&t.icon)?;
|
// button.set_icon(&t.icon)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -23,12 +23,12 @@ pub struct ItemRightSide {
|
||||||
|
|
||||||
impl ItemRightSide {
|
impl ItemRightSide {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
game_handle: &GameHandle,
|
engine: &Arc<Engine>,
|
||||||
path: &str,
|
file: &str,
|
||||||
reference: &Weak<CharacterWindow>,
|
reference: &Weak<CharacterWindow>,
|
||||||
hero: Entity,
|
hero: Entity,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let snippet = game_handle.gui_snippet(path)?;
|
let snippet = GuiSnippet::from_str(engine.gui_handler(), file)?;
|
||||||
let icons = InventoryEmptyIcons::new(&snippet)?;
|
let icons = InventoryEmptyIcons::new(&snippet)?;
|
||||||
|
|
||||||
let me = Self {
|
let me = Self {
|
||||||
|
@ -36,40 +36,40 @@ impl ItemRightSide {
|
||||||
empty_icons: icons,
|
empty_icons: icons,
|
||||||
};
|
};
|
||||||
|
|
||||||
me.setup(game_handle, reference, hero)?;
|
me.setup(engine, reference, hero)?;
|
||||||
|
|
||||||
Ok(me)
|
Ok(me)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup(
|
fn setup(
|
||||||
&self,
|
&self,
|
||||||
game_handle: &GameHandle,
|
engine: &Arc<Engine>,
|
||||||
reference: &Weak<CharacterWindow>,
|
reference: &Weak<CharacterWindow>,
|
||||||
hero: Entity,
|
hero: Entity,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
button_setup!(self, game_handle, reference, hero, helmet, "helmet");
|
button_setup!(self, engine, reference, hero, helmet, "helmet");
|
||||||
button_setup!(self, game_handle, reference, hero, chest, "chest");
|
button_setup!(self, engine, reference, hero, chest, "chest");
|
||||||
button_setup!(self, game_handle, reference, hero, gloves, "gloves");
|
button_setup!(self, engine, reference, hero, gloves, "gloves");
|
||||||
button_setup!(self, game_handle, reference, hero, belt, "belt");
|
button_setup!(self, engine, reference, hero, belt, "belt");
|
||||||
button_setup!(self, game_handle, reference, hero, boots, "boots");
|
button_setup!(self, engine, reference, hero, boots, "boots");
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
button_setup!(self, game_handle, reference, hero, primary_hand, "main hand");
|
button_setup!(self, engine, reference, hero, primary_hand, "main hand");
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
button_setup!(self, game_handle, reference, hero, secondary_hand, "off hand");
|
button_setup!(self, engine, reference, hero, secondary_hand, "off hand");
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
button_setup!(self, game_handle, reference, hero, amulet, "amulet_0", 0);
|
button_setup!(self, engine, reference, hero, amulet, "amulet_0", 0);
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
button_setup!(self, game_handle, reference, hero, amulet, "amulet_1", 1);
|
button_setup!(self, engine, reference, hero, amulet, "amulet_1", 1);
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
button_setup!(self, game_handle, reference, hero, ring, "ring_0", 0);
|
button_setup!(self, engine, reference, hero, ring, "ring_0", 0);
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
button_setup!(self, game_handle, reference, hero, ring, "ring_1", 1);
|
button_setup!(self, engine, reference, hero, ring, "ring_1", 1);
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
button_setup!(self, game_handle, reference, hero, ring, "ring_2", 2);
|
button_setup!(self, engine, reference, hero, ring, "ring_2", 2);
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
button_setup!(self, game_handle, reference, hero, ring, "ring_3", 3);
|
button_setup!(self, engine, reference, hero, ring, "ring_3", 3);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ impl ItemRightSide {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_tooltip(
|
fn create_tooltip(
|
||||||
game_handle: &GameHandle,
|
engine: &Arc<Engine>,
|
||||||
item: &Item,
|
item: &Item,
|
||||||
attributes: &Attributes,
|
attributes: &Attributes,
|
||||||
(x, y, w, _h): (i32, i32, u32, u32),
|
(x, y, w, _h): (i32, i32, u32, u32),
|
||||||
|
@ -107,7 +107,7 @@ impl ItemRightSide {
|
||||||
let target_x = x + w as i32;
|
let target_x = x + w as i32;
|
||||||
let target_y = y;
|
let target_y = y;
|
||||||
|
|
||||||
let gui = item.create_tooltip(game_handle, attributes, (target_x, target_y))?;
|
let gui = item.create_tooltip(engine.gui_handler(), attributes, (target_x, target_y))?;
|
||||||
gui.enable()?;
|
gui.enable()?;
|
||||||
gui.perform_single_check(x, y)?;
|
gui.perform_single_check(x, y)?;
|
||||||
|
|
||||||
|
@ -116,10 +116,8 @@ impl ItemRightSide {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RightSide for ItemRightSide {
|
impl RightSide for ItemRightSide {
|
||||||
fn refresh(&mut self, game_handle: &GameHandle, hero: Entity) -> Result<()> {
|
fn refresh(&mut self, engine: &Engine, hero: Entity) -> Result<()> {
|
||||||
let game = game_handle.upgrade();
|
engine.on_scene(|scene| {
|
||||||
|
|
||||||
game.engine().on_scene(|scene| {
|
|
||||||
let hero_object = scene.entity(hero)?;
|
let hero_object = scene.entity(hero)?;
|
||||||
|
|
||||||
let items = hero_object.get_component::<ItemSlotContainer>()?;
|
let items = hero_object.get_component::<ItemSlotContainer>()?;
|
||||||
|
@ -184,18 +182,18 @@ impl InventoryEmptyIcons {
|
||||||
mod macros {
|
mod macros {
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! button_setup {
|
macro_rules! button_setup {
|
||||||
($self:ident, $game_handle:ident, $reference:ident, $hero:ident, $item:ident, $button:literal) => {
|
($self:ident, $engine:ident, $reference:ident, $hero:ident, $item:ident, $button:literal) => {
|
||||||
paste::expr! {
|
paste::expr! {
|
||||||
let [<$item _button>]: Arc<Button> = $self.snippet.element($button)?;
|
let [<$item _button>]: Arc<Button> = $self.snippet.element($button)?;
|
||||||
|
|
||||||
[<$item _button>].set_select_callback({
|
[<$item _button>].set_select_callback({
|
||||||
let game_handle = $game_handle.clone();
|
let engine = $engine.clone();
|
||||||
let reference = $reference.clone();
|
let reference = $reference.clone();
|
||||||
let weak_button = Arc::downgrade(&[<$item _button>]);
|
let weak_button = Arc::downgrade(&[<$item _button>]);
|
||||||
|
|
||||||
move |selected| {
|
move |selected| {
|
||||||
if selected {
|
if selected {
|
||||||
game_handle.upgrade().engine().on_scene(|scene| {
|
engine.on_scene(|scene| {
|
||||||
let entity = scene.entity($hero)?;
|
let entity = scene.entity($hero)?;
|
||||||
|
|
||||||
let attributes = entity.get_component::<Attributes>()?;
|
let attributes = entity.get_component::<Attributes>()?;
|
||||||
|
@ -207,7 +205,7 @@ mod macros {
|
||||||
weak_button.upgrade().unwrap().position_extent();
|
weak_button.upgrade().unwrap().position_extent();
|
||||||
|
|
||||||
let gui = Self::create_tooltip(
|
let gui = Self::create_tooltip(
|
||||||
&game_handle,
|
&engine,
|
||||||
$item,
|
$item,
|
||||||
attributes,
|
attributes,
|
||||||
button_pos,
|
button_pos,
|
||||||
|
@ -231,13 +229,13 @@ mod macros {
|
||||||
});
|
});
|
||||||
|
|
||||||
[<$item _button>].set_callback({
|
[<$item _button>].set_callback({
|
||||||
let game_handle = $game_handle.clone();
|
let engine = $engine.clone();
|
||||||
let reference = $reference.clone();
|
let reference = $reference.clone();
|
||||||
|
|
||||||
move || {
|
move || {
|
||||||
let mut found_item = false;
|
let mut found_item = false;
|
||||||
|
|
||||||
game_handle.upgrade().engine().on_scene_mut(|scene| {
|
engine.on_scene_mut(|scene| {
|
||||||
let entity = scene.entity_mut($hero)?;
|
let entity = scene.entity_mut($hero)?;
|
||||||
let mut multi_mut = entity.multi_mut();
|
let mut multi_mut = entity.multi_mut();
|
||||||
|
|
||||||
|
@ -257,7 +255,7 @@ mod macros {
|
||||||
|
|
||||||
statistics.update(
|
statistics.update(
|
||||||
attributes,
|
attributes,
|
||||||
&game_handle.upgrade().attribute_settings,
|
&engine.upgrade().attribute_settings,
|
||||||
&*items
|
&*items
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -285,7 +283,7 @@ mod macros {
|
||||||
});
|
});
|
||||||
|
|
||||||
[<$item _button>].set_custom_callback({
|
[<$item _button>].set_custom_callback({
|
||||||
let game_handle = $game_handle.clone();
|
let engine = $engine.clone();
|
||||||
let reference = $reference.clone();
|
let reference = $reference.clone();
|
||||||
|
|
||||||
move |controller_button| {
|
move |controller_button| {
|
||||||
|
@ -293,7 +291,7 @@ mod macros {
|
||||||
ControllerButton::Y => {
|
ControllerButton::Y => {
|
||||||
let mut empty_affixes_found = false;
|
let mut empty_affixes_found = false;
|
||||||
|
|
||||||
game_handle.upgrade().engine().on_scene_mut(|scene| {
|
engine.on_scene_mut(|scene| {
|
||||||
let entity = scene.entity_mut($hero)?;
|
let entity = scene.entity_mut($hero)?;
|
||||||
let items = entity.get_component::<ItemSlotContainer>()?;
|
let items = entity.get_component::<ItemSlotContainer>()?;
|
||||||
|
|
||||||
|
@ -336,18 +334,18 @@ mod macros {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
($self:ident, $game_handle:ident, $reference:ident, $hero:ident, $item:ident, $button:literal, $index:literal) => {
|
($self:ident, $engine:ident, $reference:ident, $hero:ident, $item:ident, $button:literal, $index:literal) => {
|
||||||
paste::expr! {
|
paste::expr! {
|
||||||
let [<$item _button>]: Arc<Button> = $self.snippet.element($button)?;
|
let [<$item _button>]: Arc<Button> = $self.snippet.element($button)?;
|
||||||
|
|
||||||
[<$item _button>].set_select_callback({
|
[<$item _button>].set_select_callback({
|
||||||
let game_handle = $game_handle.clone();
|
let engine = $engine.clone();
|
||||||
let reference = $reference.clone();
|
let reference = $reference.clone();
|
||||||
let weak_button = Arc::downgrade(&[<$item _button>]);
|
let weak_button = Arc::downgrade(&[<$item _button>]);
|
||||||
|
|
||||||
move |selected| {
|
move |selected| {
|
||||||
if selected {
|
if selected {
|
||||||
game_handle.upgrade().engine().on_scene(|scene| {
|
engine.on_scene(|scene| {
|
||||||
let entity = scene.entity($hero)?;
|
let entity = scene.entity($hero)?;
|
||||||
|
|
||||||
let attributes = entity.get_component::<Attributes>()?;
|
let attributes = entity.get_component::<Attributes>()?;
|
||||||
|
@ -359,7 +357,7 @@ mod macros {
|
||||||
weak_button.upgrade().unwrap().position_extent();
|
weak_button.upgrade().unwrap().position_extent();
|
||||||
|
|
||||||
let gui = Self::create_tooltip(
|
let gui = Self::create_tooltip(
|
||||||
&game_handle,
|
&engine,
|
||||||
$item,
|
$item,
|
||||||
attributes,
|
attributes,
|
||||||
button_pos,
|
button_pos,
|
||||||
|
@ -383,13 +381,13 @@ mod macros {
|
||||||
});
|
});
|
||||||
|
|
||||||
[<$item _button>].set_callback({
|
[<$item _button>].set_callback({
|
||||||
let game_handle = $game_handle.clone();
|
let engine = $engine.clone();
|
||||||
let reference = $reference.clone();
|
let reference = $reference.clone();
|
||||||
|
|
||||||
move || {
|
move || {
|
||||||
let mut found_item = false;
|
let mut found_item = false;
|
||||||
|
|
||||||
game_handle.upgrade().engine().on_scene_mut(|scene| {
|
engine.on_scene_mut(|scene| {
|
||||||
let entity = scene.entity_mut($hero)?;
|
let entity = scene.entity_mut($hero)?;
|
||||||
let mut multi_mut = entity.multi_mut();
|
let mut multi_mut = entity.multi_mut();
|
||||||
|
|
||||||
|
@ -409,7 +407,7 @@ mod macros {
|
||||||
|
|
||||||
statistics.update(
|
statistics.update(
|
||||||
attributes,
|
attributes,
|
||||||
&game_handle.upgrade().attribute_settings,
|
&engine.upgrade().attribute_settings,
|
||||||
&*items
|
&*items
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -437,7 +435,7 @@ mod macros {
|
||||||
});
|
});
|
||||||
|
|
||||||
[<$item _button>].set_custom_callback({
|
[<$item _button>].set_custom_callback({
|
||||||
let game_handle = $game_handle.clone();
|
let engine = $engine.clone();
|
||||||
let reference = $reference.clone();
|
let reference = $reference.clone();
|
||||||
|
|
||||||
move |controller_button| {
|
move |controller_button| {
|
||||||
|
@ -445,7 +443,7 @@ mod macros {
|
||||||
ControllerButton::Y => {
|
ControllerButton::Y => {
|
||||||
let mut empty_affixes_found = false;
|
let mut empty_affixes_found = false;
|
||||||
|
|
||||||
game_handle.upgrade().engine().on_scene_mut(|scene| {
|
engine.on_scene_mut(|scene| {
|
||||||
let entity = scene.entity_mut($hero)?;
|
let entity = scene.entity_mut($hero)?;
|
||||||
let items = entity.get_component::<ItemSlotContainer>()?;
|
let items = entity.get_component::<ItemSlotContainer>()?;
|
||||||
|
|
||||||
|
|
|
@ -46,17 +46,17 @@ pub struct JewelRightSide {
|
||||||
|
|
||||||
impl JewelRightSide {
|
impl JewelRightSide {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
game_handle: &GameHandle,
|
engine: &Arc<Engine>,
|
||||||
path: &str,
|
file: &str,
|
||||||
hero: Entity,
|
hero: Entity,
|
||||||
reference: &Weak<CharacterWindow>,
|
reference: &Weak<CharacterWindow>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let snippet = game_handle.gui_snippet(path)?;
|
let snippet = GuiSnippet::from_str(engine.gui_handler(), file)?;
|
||||||
|
|
||||||
let combine: Arc<Label> = snippet.element("combine")?;
|
let combine: Arc<Label> = snippet.element("combine")?;
|
||||||
combine.set_info_icon(&game_handle.controller_icon(ControllerButton::RightStick)?)?;
|
combine.set_info_icon(&engine.controller_icon(ControllerButton::RightStick)?)?;
|
||||||
|
|
||||||
game_handle.upgrade().engine().on_scene_mut(|scene| {
|
engine.on_scene_mut(|scene| {
|
||||||
scene
|
scene
|
||||||
.resources
|
.resources
|
||||||
.insert_if_not_exists::<Option<ReferenceObject>>();
|
.insert_if_not_exists::<Option<ReferenceObject>>();
|
||||||
|
@ -66,21 +66,21 @@ impl JewelRightSide {
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let me = Self { snippet };
|
let me = Self { snippet };
|
||||||
me.setup_select(game_handle, hero, reference)?;
|
me.setup_select(engine, hero, reference)?;
|
||||||
|
|
||||||
Ok(me)
|
Ok(me)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup_select(
|
fn setup_select(
|
||||||
&self,
|
&self,
|
||||||
game_handle: &GameHandle,
|
engine: &Arc<Engine>,
|
||||||
hero: Entity,
|
hero: Entity,
|
||||||
reference: &Weak<CharacterWindow>,
|
reference: &Weak<CharacterWindow>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let (top, bottom) = self.elements()?;
|
let (top, bottom) = self.elements()?;
|
||||||
|
|
||||||
top.set_select_callback({
|
top.set_select_callback({
|
||||||
let game_handle = game_handle.clone();
|
let engine = engine.clone();
|
||||||
let weak_top = Arc::downgrade(&top);
|
let weak_top = Arc::downgrade(&top);
|
||||||
let reference = reference.clone();
|
let reference = reference.clone();
|
||||||
|
|
||||||
|
@ -94,21 +94,20 @@ impl JewelRightSide {
|
||||||
|
|
||||||
let (x, y, w, _h) = button.position_extent();
|
let (x, y, w, _h) = button.position_extent();
|
||||||
|
|
||||||
let game = game_handle.upgrade();
|
let scene = engine.scene();
|
||||||
let scene = game.engine().scene();
|
|
||||||
|
|
||||||
let reference_info = scene.resources.get::<Option<ReferenceObject>>();
|
let reference_info = scene.resources.get::<Option<ReferenceObject>>();
|
||||||
|
|
||||||
if let Some(reference_info) = reference_info {
|
if let Some(reference_info) = reference_info {
|
||||||
let tooltip = match reference_info {
|
let tooltip = match reference_info {
|
||||||
ReferenceObject::Item { item, .. } => item.create_tooltip(
|
ReferenceObject::Item { item, .. } => item.create_tooltip(
|
||||||
&game_handle,
|
engine.gui_handler(),
|
||||||
scene.entity(hero)?.get_component::<Attributes>()?,
|
scene.entity(hero)?.get_component::<Attributes>()?,
|
||||||
(x + w as i32, y),
|
(x + w as i32, y),
|
||||||
)?,
|
)?,
|
||||||
ReferenceObject::Jewel { jewel, .. } => jewel.create_tooltip(
|
ReferenceObject::Jewel { jewel, .. } => jewel.create_tooltip(
|
||||||
&game_handle,
|
engine.gui_handler(),
|
||||||
&game_handle.upgrade().item_settings,
|
&engine.upgrade().item_settings,
|
||||||
(x + w as i32, y),
|
(x + w as i32, y),
|
||||||
)?,
|
)?,
|
||||||
};
|
};
|
||||||
|
@ -128,7 +127,7 @@ impl JewelRightSide {
|
||||||
|
|
||||||
for (index, lower) in bottom.iter().enumerate() {
|
for (index, lower) in bottom.iter().enumerate() {
|
||||||
lower.set_select_callback({
|
lower.set_select_callback({
|
||||||
let game_handle = game_handle.clone();
|
let engine = engine.clone();
|
||||||
let weak_top = Arc::downgrade(&lower);
|
let weak_top = Arc::downgrade(&lower);
|
||||||
let reference = reference.clone();
|
let reference = reference.clone();
|
||||||
|
|
||||||
|
@ -142,15 +141,14 @@ impl JewelRightSide {
|
||||||
|
|
||||||
let (x, y, w, _h) = button.position_extent();
|
let (x, y, w, _h) = button.position_extent();
|
||||||
|
|
||||||
let game = game_handle.upgrade();
|
let scene = engine.scene();
|
||||||
let scene = game.engine().scene();
|
|
||||||
|
|
||||||
let lower_info = scene.resources.get::<LowerJewels>();
|
let lower_info = scene.resources.get::<LowerJewels>();
|
||||||
|
|
||||||
if let Some((lower_jewel, _)) = &lower_info.jewels[index] {
|
if let Some((lower_jewel, _)) = &lower_info.jewels[index] {
|
||||||
let tooltip = lower_jewel.create_tooltip(
|
let tooltip = lower_jewel.create_tooltip(
|
||||||
&game_handle,
|
engine.gui_handler(),
|
||||||
&game_handle.upgrade().item_settings,
|
&engine.upgrade().item_settings,
|
||||||
(x + w as i32, y),
|
(x + w as i32, y),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
@ -168,12 +166,11 @@ impl JewelRightSide {
|
||||||
});
|
});
|
||||||
|
|
||||||
lower.set_callback({
|
lower.set_callback({
|
||||||
let game_handle = game_handle.clone();
|
let engine = engine.clone();
|
||||||
let reference = reference.clone();
|
let reference = reference.clone();
|
||||||
|
|
||||||
move || {
|
move || {
|
||||||
let game = game_handle.upgrade();
|
let scene = engine.scene_mut();
|
||||||
let scene = game.engine().scene_mut();
|
|
||||||
|
|
||||||
let lower_info = scene.resources.get_mut::<LowerJewels>();
|
let lower_info = scene.resources.get_mut::<LowerJewels>();
|
||||||
|
|
||||||
|
@ -209,9 +206,8 @@ impl JewelRightSide {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clear(game_handle: &GameHandle) {
|
pub fn clear(engine: &Arc<Engine>) {
|
||||||
let game = game_handle.upgrade();
|
let scene = engine.scene_mut();
|
||||||
let scene = game.engine().scene_mut();
|
|
||||||
|
|
||||||
*scene.resources.get_mut::<Option<ReferenceObject>>() = None;
|
*scene.resources.get_mut::<Option<ReferenceObject>>() = None;
|
||||||
scene
|
scene
|
||||||
|
@ -222,9 +218,8 @@ impl JewelRightSide {
|
||||||
.for_each(|j| *j = None);
|
.for_each(|j| *j = None);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn combine(game_handle: &GameHandle, hero: Entity) -> Result<bool> {
|
pub fn combine(engine: &Arc<Engine>, hero: Entity) -> Result<bool> {
|
||||||
let game = game_handle.upgrade();
|
let scene = engine.scene_mut();
|
||||||
let scene = game.engine().scene_mut();
|
|
||||||
let mut resources = unsafe { remove_life_time_mut(scene) }.resources.multi_mut();
|
let mut resources = unsafe { remove_life_time_mut(scene) }.resources.multi_mut();
|
||||||
|
|
||||||
let reference_info = resources.get::<Option<ReferenceObject>>();
|
let reference_info = resources.get::<Option<ReferenceObject>>();
|
||||||
|
@ -308,7 +303,7 @@ impl JewelRightSide {
|
||||||
let statistics = multi_mut.get::<Statistics>()?;
|
let statistics = multi_mut.get::<Statistics>()?;
|
||||||
let attributes = multi_mut.get::<Attributes>()?;
|
let attributes = multi_mut.get::<Attributes>()?;
|
||||||
|
|
||||||
statistics.update(attributes, &game.attribute_settings, &*item_slots);
|
statistics.update(attributes, &engine.attribute_settings, &*item_slots);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -334,7 +329,7 @@ impl JewelRightSide {
|
||||||
}
|
}
|
||||||
|
|
||||||
upper_jewel.level += 1;
|
upper_jewel.level += 1;
|
||||||
upper_jewel.update_stat(&game.item_settings);
|
upper_jewel.update_stat(&engine.item_settings);
|
||||||
upper_jewel.icon = Some(game.item_system().jewel_icon(
|
upper_jewel.icon = Some(game.item_system().jewel_icon(
|
||||||
upper_jewel.rarity,
|
upper_jewel.rarity,
|
||||||
upper_jewel.level,
|
upper_jewel.level,
|
||||||
|
@ -360,8 +355,8 @@ impl JewelRightSide {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RightSide for JewelRightSide {
|
impl RightSide for JewelRightSide {
|
||||||
fn refresh(&mut self, game_handle: &GameHandle, _hero: Entity) -> Result<()> {
|
fn refresh(&mut self, engine: &Engine, _hero: Entity) -> Result<()> {
|
||||||
game_handle.upgrade().engine().on_scene(|scene| {
|
engine.on_scene(|scene| {
|
||||||
let (reference, lower) = self.elements()?;
|
let (reference, lower) = self.elements()?;
|
||||||
|
|
||||||
let reference_info = scene.resources.get::<Option<ReferenceObject>>();
|
let reference_info = scene.resources.get::<Option<ReferenceObject>>();
|
||||||
|
@ -390,9 +385,8 @@ impl RightSide for JewelRightSide {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn disable(&mut self, game_handle: &GameHandle, _hero: Entity) -> Result<()> {
|
fn disable(&mut self, engine: &Engine, _hero: Entity) -> Result<()> {
|
||||||
let game = game_handle.upgrade();
|
let scene = engine.scene_mut();
|
||||||
let scene = game.engine().scene_mut();
|
|
||||||
|
|
||||||
*scene.resources.get_mut::<Option<ReferenceObject>>() = None;
|
*scene.resources.get_mut::<Option<ReferenceObject>>() = None;
|
||||||
scene
|
scene
|
||||||
|
|
|
@ -9,15 +9,15 @@ pub struct MapRightSide {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MapRightSide {
|
impl MapRightSide {
|
||||||
pub fn new(game_handle: &GameHandle, path: &str) -> Result<Self> {
|
pub fn new(engine: &Arc<Engine>, file: &str) -> Result<Self> {
|
||||||
let snippet = game_handle.gui_snippet(path)?;
|
let snippet = GuiSnippet::from_str(engine.gui_handler(), file)?;
|
||||||
|
|
||||||
Ok(Self { snippet })
|
Ok(Self { snippet })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RightSide for MapRightSide {
|
impl RightSide for MapRightSide {
|
||||||
fn refresh(&mut self, _game_handle: &GameHandle, _hero: Entity) -> Result<()> {
|
fn refresh(&mut self, _engine: &Engine, _hero: Entity) -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ use rpg_components::components::inventory::Inventory;
|
||||||
use super::page_content::PageContent;
|
use super::page_content::PageContent;
|
||||||
use super::traits::*;
|
use super::traits::*;
|
||||||
use super::{content::Content, CharacterWindow, Page};
|
use super::{content::Content, CharacterWindow, Page};
|
||||||
use crate::GameHandle;
|
|
||||||
use item_right_side::ItemRightSide;
|
use item_right_side::ItemRightSide;
|
||||||
use jewel_right_side::JewelRightSide;
|
use jewel_right_side::JewelRightSide;
|
||||||
use map_right_side::MapRightSide;
|
use map_right_side::MapRightSide;
|
||||||
|
@ -20,7 +19,7 @@ use map_right_side::MapRightSide;
|
||||||
pub struct InventoryPage {
|
pub struct InventoryPage {
|
||||||
close: Weak<Button>,
|
close: Weak<Button>,
|
||||||
|
|
||||||
game_handle: GameHandle,
|
engine: Arc<Engine>,
|
||||||
hero: Entity,
|
hero: Entity,
|
||||||
|
|
||||||
grid: Arc<Grid>,
|
grid: Arc<Grid>,
|
||||||
|
@ -35,18 +34,19 @@ pub struct InventoryPage {
|
||||||
|
|
||||||
impl InventoryPage {
|
impl InventoryPage {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
game: GameHandle,
|
engine: &Arc<Engine>,
|
||||||
hero: Entity,
|
hero: Entity,
|
||||||
reference: Weak<CharacterWindow>,
|
reference: Weak<CharacterWindow>,
|
||||||
close: &Arc<Button>,
|
close: &Arc<Button>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let base = "gui/xml/ingame/character_menu/inventory/".to_string();
|
let grid = Grid::new(engine.gui_handler().clone(), 2, 1, false)?;
|
||||||
|
|
||||||
let grid = Grid::new(game.upgrade().engine().gui_handler().clone(), 2, 1, false)?;
|
let left_base = GuiSnippet::from_str(
|
||||||
|
engine.gui_handler(),
|
||||||
|
include_str!("../../resources/inventory/left_side.xml"),
|
||||||
|
)?;
|
||||||
|
|
||||||
let left_base = game.gui_snippet((base.clone() + "left_side.xml").as_str())?;
|
|
||||||
grid.attach(left_base.clone(), 0, 0, 1, 1)?;
|
grid.attach(left_base.clone(), 0, 0, 1, 1)?;
|
||||||
|
|
||||||
Self::setup_content_switch(&left_base, reference.clone())?;
|
Self::setup_content_switch(&left_base, reference.clone())?;
|
||||||
|
|
||||||
let tooltip = left_base.element("tooltip")?;
|
let tooltip = left_base.element("tooltip")?;
|
||||||
|
@ -54,15 +54,14 @@ impl InventoryPage {
|
||||||
|
|
||||||
// items
|
// items
|
||||||
let item_mode = PageContent::new(
|
let item_mode = PageContent::new(
|
||||||
Content::new(&game, reference.clone(), {
|
Content::new(engine, reference.clone(), {
|
||||||
let game_handle = game.clone();
|
let engine = engine.clone();
|
||||||
let hero = hero.clone();
|
let hero = hero.clone();
|
||||||
|
|
||||||
move || {
|
move || {
|
||||||
let game = game_handle.upgrade();
|
|
||||||
let mut data = Vec::new();
|
let mut data = Vec::new();
|
||||||
|
|
||||||
game.engine().on_scene(|scene| {
|
engine.on_scene(|scene| {
|
||||||
let hero_object = scene.entity(hero)?;
|
let hero_object = scene.entity(hero)?;
|
||||||
let inventory = hero_object.get_component::<Inventory>()?;
|
let inventory = hero_object.get_component::<Inventory>()?;
|
||||||
|
|
||||||
|
@ -75,25 +74,28 @@ impl InventoryPage {
|
||||||
}
|
}
|
||||||
})?,
|
})?,
|
||||||
{
|
{
|
||||||
let ui = game.gui_snippet((base.clone() + "items/tooltip.xml").as_str())?;
|
let ui = GuiSnippet::from_str(
|
||||||
|
engine.gui_handler(),
|
||||||
|
include_str!("../../resources/inventory/items/tooltip.xml"),
|
||||||
|
)?;
|
||||||
|
|
||||||
let equip: Arc<Label> = ui.element("equip")?;
|
let equip: Arc<Label> = ui.element("equip")?;
|
||||||
equip.set_info_icon(&game.controller_icon(ControllerButton::A)?)?;
|
equip.set_info_icon(&engine.controller_icon(ControllerButton::A)?)?;
|
||||||
|
|
||||||
let salvage: Arc<Label> = ui.element("salvage")?;
|
let salvage: Arc<Label> = ui.element("salvage")?;
|
||||||
salvage.set_info_icon(&game.controller_icon(ControllerButton::X)?)?;
|
salvage.set_info_icon(&engine.controller_icon(ControllerButton::X)?)?;
|
||||||
|
|
||||||
let socket: Arc<Label> = ui.element("socket")?;
|
let socket: Arc<Label> = ui.element("socket")?;
|
||||||
socket.set_info_icon(&game.controller_icon(ControllerButton::Y)?)?;
|
socket.set_info_icon(&engine.controller_icon(ControllerButton::Y)?)?;
|
||||||
|
|
||||||
let switch_mode: Arc<Label> = ui.element("switch_mode")?;
|
let switch_mode: Arc<Label> = ui.element("switch_mode")?;
|
||||||
switch_mode.set_info_icon(&game.controller_icon(ControllerButton::LeftStick)?)?;
|
switch_mode.set_info_icon(&engine.controller_icon(ControllerButton::LeftStick)?)?;
|
||||||
|
|
||||||
ui
|
ui
|
||||||
},
|
},
|
||||||
ItemRightSide::new(
|
ItemRightSide::new(
|
||||||
&game,
|
engine,
|
||||||
(base.clone() + "items/right_side.xml").as_str(),
|
include_str!("../../resources/inventory/items/right_side.xml"),
|
||||||
&reference,
|
&reference,
|
||||||
hero,
|
hero,
|
||||||
)?,
|
)?,
|
||||||
|
@ -101,15 +103,14 @@ impl InventoryPage {
|
||||||
|
|
||||||
// jewels
|
// jewels
|
||||||
let jewel_mode = PageContent::new(
|
let jewel_mode = PageContent::new(
|
||||||
Content::new(&game, reference.clone(), {
|
Content::new(engine, reference.clone(), {
|
||||||
let game_handle = game.clone();
|
let engine = engine.clone();
|
||||||
let hero = hero.clone();
|
let hero = hero.clone();
|
||||||
|
|
||||||
move || {
|
move || {
|
||||||
let game = game_handle.upgrade();
|
|
||||||
let mut data = Vec::new();
|
let mut data = Vec::new();
|
||||||
|
|
||||||
game.engine().on_scene(|scene| {
|
engine.on_scene(|scene| {
|
||||||
let hero_object = scene.entity(hero)?;
|
let hero_object = scene.entity(hero)?;
|
||||||
let inventory = hero_object.get_component::<Inventory>()?;
|
let inventory = hero_object.get_component::<Inventory>()?;
|
||||||
|
|
||||||
|
@ -122,22 +123,25 @@ impl InventoryPage {
|
||||||
}
|
}
|
||||||
})?,
|
})?,
|
||||||
{
|
{
|
||||||
let ui = game.gui_snippet((base.clone() + "jewels/tooltip.xml").as_str())?;
|
let ui = GuiSnippet::from_str(
|
||||||
|
engine.gui_handler(),
|
||||||
|
include_str!("../../resources/inventory/jewels/tooltip.xml"),
|
||||||
|
)?;
|
||||||
|
|
||||||
let socket: Arc<Label> = ui.element("socket")?;
|
let socket: Arc<Label> = ui.element("socket")?;
|
||||||
socket.set_info_icon(&game.controller_icon(ControllerButton::A)?)?;
|
socket.set_info_icon(&engine.controller_icon(ControllerButton::A)?)?;
|
||||||
|
|
||||||
let combine: Arc<Label> = ui.element("combine")?;
|
let combine: Arc<Label> = ui.element("combine")?;
|
||||||
combine.set_info_icon(&game.controller_icon(ControllerButton::Y)?)?;
|
combine.set_info_icon(&engine.controller_icon(ControllerButton::Y)?)?;
|
||||||
|
|
||||||
let switch_mode: Arc<Label> = ui.element("switch_mode")?;
|
let switch_mode: Arc<Label> = ui.element("switch_mode")?;
|
||||||
switch_mode.set_info_icon(&game.controller_icon(ControllerButton::LeftStick)?)?;
|
switch_mode.set_info_icon(&engine.controller_icon(ControllerButton::LeftStick)?)?;
|
||||||
|
|
||||||
ui
|
ui
|
||||||
},
|
},
|
||||||
JewelRightSide::new(
|
JewelRightSide::new(
|
||||||
&game,
|
engine,
|
||||||
(base.clone() + "jewels/right_side.xml").as_str(),
|
include_str!("../../resources/inventory/jewels/right_side.xml"),
|
||||||
hero,
|
hero,
|
||||||
&reference,
|
&reference,
|
||||||
)?,
|
)?,
|
||||||
|
@ -145,15 +149,14 @@ impl InventoryPage {
|
||||||
|
|
||||||
// maps
|
// maps
|
||||||
let map_mode = PageContent::new(
|
let map_mode = PageContent::new(
|
||||||
Content::new(&game, reference.clone(), {
|
Content::new(engine, reference.clone(), {
|
||||||
let game_handle = game.clone();
|
let engine = engine.clone();
|
||||||
let hero = hero.clone();
|
let hero: Entity = hero.clone();
|
||||||
|
|
||||||
move || {
|
move || {
|
||||||
let game = game_handle.upgrade();
|
|
||||||
let mut data = Vec::new();
|
let mut data = Vec::new();
|
||||||
|
|
||||||
game.engine().on_scene(|scene| {
|
engine.on_scene(|scene| {
|
||||||
let hero_object = scene.entity(hero)?;
|
let hero_object = scene.entity(hero)?;
|
||||||
let inventory = hero_object.get_component::<Inventory>()?;
|
let inventory = hero_object.get_component::<Inventory>()?;
|
||||||
|
|
||||||
|
@ -166,26 +169,32 @@ impl InventoryPage {
|
||||||
}
|
}
|
||||||
})?,
|
})?,
|
||||||
{
|
{
|
||||||
let ui = game.gui_snippet((base.clone() + "maps/tooltip.xml").as_str())?;
|
let ui = GuiSnippet::from_str(
|
||||||
|
engine.gui_handler(),
|
||||||
|
include_str!("../../resources/inventory/maps/tooltip.xml"),
|
||||||
|
)?;
|
||||||
|
|
||||||
let select: Arc<Label> = ui.element("select")?;
|
let select: Arc<Label> = ui.element("select")?;
|
||||||
select.set_info_icon(&game.controller_icon(ControllerButton::A)?)?;
|
select.set_info_icon(&engine.controller_icon(ControllerButton::A)?)?;
|
||||||
|
|
||||||
let start: Arc<Label> = ui.element("start")?;
|
let start: Arc<Label> = ui.element("start")?;
|
||||||
start.set_info_icon(&game.controller_icon(ControllerButton::X)?)?;
|
start.set_info_icon(&engine.controller_icon(ControllerButton::X)?)?;
|
||||||
|
|
||||||
let switch_mode: Arc<Label> = ui.element("switch_mode")?;
|
let switch_mode: Arc<Label> = ui.element("switch_mode")?;
|
||||||
switch_mode.set_info_icon(&game.controller_icon(ControllerButton::LeftStick)?)?;
|
switch_mode.set_info_icon(&engine.controller_icon(ControllerButton::LeftStick)?)?;
|
||||||
|
|
||||||
ui
|
ui
|
||||||
},
|
},
|
||||||
MapRightSide::new(&game, (base.clone() + "maps/right_side.xml").as_str())?,
|
MapRightSide::new(
|
||||||
|
engine,
|
||||||
|
include_str!("../../resources/inventory/maps/right_side.xml"),
|
||||||
|
)?,
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
close: Arc::downgrade(close),
|
close: Arc::downgrade(close),
|
||||||
|
|
||||||
game_handle: game,
|
engine: engine.clone(),
|
||||||
hero,
|
hero,
|
||||||
|
|
||||||
grid,
|
grid,
|
||||||
|
@ -226,9 +235,8 @@ impl InventoryPage {
|
||||||
self.grid
|
self.grid
|
||||||
.attach(mode.right_side_mut().base().clone(), 1, 0, 1, 1)?;
|
.attach(mode.right_side_mut().base().clone(), 1, 0, 1, 1)?;
|
||||||
|
|
||||||
mode.content_mut().update(&self.game_handle, self.hero)?;
|
mode.content_mut().update(&self.engine, self.hero)?;
|
||||||
mode.right_side_mut()
|
mode.right_side_mut().refresh(&self.engine, self.hero)?;
|
||||||
.refresh(&self.game_handle, self.hero)?;
|
|
||||||
|
|
||||||
if select {
|
if select {
|
||||||
mode.content_mut().select()?;
|
mode.content_mut().select()?;
|
||||||
|
@ -361,7 +369,7 @@ impl Page for InventoryPage {
|
||||||
fn disable(&mut self) -> Result<()> {
|
fn disable(&mut self) -> Result<()> {
|
||||||
self.modes[self.current_mode]
|
self.modes[self.current_mode]
|
||||||
.right_side_mut()
|
.right_side_mut()
|
||||||
.disable(&self.game_handle, self.hero)
|
.disable(&self.engine, self.hero)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select(&self) -> Result<()> {
|
fn select(&self) -> Result<()> {
|
||||||
|
@ -382,7 +390,7 @@ impl Page for InventoryPage {
|
||||||
{
|
{
|
||||||
let mode = &mut self.modes[self.current_mode];
|
let mode = &mut self.modes[self.current_mode];
|
||||||
|
|
||||||
mode.content_mut().next_tab(&self.game_handle, self.hero)?;
|
mode.content_mut().next_tab(&self.engine, self.hero)?;
|
||||||
mode.content_mut().select()?;
|
mode.content_mut().select()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,8 +401,7 @@ impl Page for InventoryPage {
|
||||||
{
|
{
|
||||||
let mode = &mut self.modes[self.current_mode];
|
let mode = &mut self.modes[self.current_mode];
|
||||||
|
|
||||||
mode.content_mut()
|
mode.content_mut().previous_tab(&self.engine, self.hero)?;
|
||||||
.previous_tab(&self.game_handle, self.hero)?;
|
|
||||||
mode.content_mut().select()?;
|
mode.content_mut().select()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,7 +413,7 @@ impl Page for InventoryPage {
|
||||||
ControllerButton::LeftStick => {
|
ControllerButton::LeftStick => {
|
||||||
self.modes[self.current_mode]
|
self.modes[self.current_mode]
|
||||||
.right_side_mut()
|
.right_side_mut()
|
||||||
.disable(&self.game_handle, self.hero)?;
|
.disable(&self.engine, self.hero)?;
|
||||||
|
|
||||||
self.current_mode = (self.current_mode + 1) % self.modes.len();
|
self.current_mode = (self.current_mode + 1) % self.modes.len();
|
||||||
|
|
||||||
|
@ -416,8 +423,8 @@ impl Page for InventoryPage {
|
||||||
ControllerButton::RightStick => {
|
ControllerButton::RightStick => {
|
||||||
// check if jewel page is open
|
// check if jewel page is open
|
||||||
if self.current_mode == 1 {
|
if self.current_mode == 1 {
|
||||||
if JewelRightSide::combine(&self.game_handle, self.hero)? {
|
if JewelRightSide::combine(&self.engine, self.hero)? {
|
||||||
JewelRightSide::clear(&self.game_handle);
|
JewelRightSide::clear(&self.engine);
|
||||||
self.update_page(true)?;
|
self.update_page(true)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -158,28 +158,9 @@ impl CharacterWindow {
|
||||||
tooltips: Mutex::default(),
|
tooltips: Mutex::default(),
|
||||||
|
|
||||||
tabs: RwLock::new([
|
tabs: RwLock::new([
|
||||||
Box::new(
|
Box::new(CharacterPage::new(&engine, hero, name, me).unwrap()),
|
||||||
CharacterPage::new(&ingame.game, ingame.hero.entity(), ingame.hero.name(), me)
|
Box::new(InventoryPage::new(&engine, hero, me.clone(), &close_button).unwrap()),
|
||||||
.unwrap(),
|
Box::new(AbilityPage::new(&engine, hero, me.clone(), &close_button).unwrap()),
|
||||||
),
|
|
||||||
Box::new(
|
|
||||||
InventoryPage::new(
|
|
||||||
ingame.game.clone(),
|
|
||||||
ingame.hero.entity(),
|
|
||||||
me.clone(),
|
|
||||||
&close_button,
|
|
||||||
)
|
|
||||||
.unwrap(),
|
|
||||||
),
|
|
||||||
Box::new(
|
|
||||||
AbilityPage::new(
|
|
||||||
ingame.game.clone(),
|
|
||||||
ingame.hero.entity(),
|
|
||||||
me.clone(),
|
|
||||||
&close_button,
|
|
||||||
)
|
|
||||||
.unwrap(),
|
|
||||||
),
|
|
||||||
]),
|
]),
|
||||||
tab: AtomicUsize::new(0),
|
tab: AtomicUsize::new(0),
|
||||||
|
|
||||||
|
@ -314,39 +295,13 @@ impl TopLevelGui for CharacterWindow {
|
||||||
self.tab().select()?;
|
self.tab().select()?;
|
||||||
|
|
||||||
let close_button: Arc<Button> = self.menu_gui.element("close")?;
|
let close_button: Arc<Button> = self.menu_gui.element("close")?;
|
||||||
close_button.set_info_icon(&self.game_handle.controller_icon(ControllerButton::B)?)?;
|
close_button.set_info_icon(&self.engine.controller_icon(ControllerButton::B)?)?;
|
||||||
|
|
||||||
let left_info: Arc<Icon> = self.menu_gui.element("left_info")?;
|
let left_info: Arc<Icon> = self.menu_gui.element("left_info")?;
|
||||||
match self
|
left_info.set_icon(&self.engine.controller_icon(ControllerButton::LeftButton)?)?;
|
||||||
.engine
|
|
||||||
.settings()
|
|
||||||
.controller_button(&self.engine, ControllerButton::LeftButton)?
|
|
||||||
{
|
|
||||||
Some(icon) => {
|
|
||||||
left_info.set_icon(&icon)?;
|
|
||||||
left_info.set_text("")?;
|
|
||||||
}
|
|
||||||
None => {
|
|
||||||
left_info.clear_icon()?;
|
|
||||||
left_info.set_text("")?;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let right_info: Arc<Icon> = self.menu_gui.element("right_info")?;
|
let right_info: Arc<Icon> = self.menu_gui.element("right_info")?;
|
||||||
match self
|
right_info.set_icon(&self.engine.controller_icon(ControllerButton::RightButton)?)?;
|
||||||
.engine
|
|
||||||
.settings()
|
|
||||||
.controller_button(&self.engine, ControllerButton::RightButton)?
|
|
||||||
{
|
|
||||||
Some(icon) => {
|
|
||||||
right_info.set_icon(&icon)?;
|
|
||||||
right_info.set_text("")?;
|
|
||||||
}
|
|
||||||
None => {
|
|
||||||
right_info.clear_icon()?;
|
|
||||||
right_info.set_text("")?;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -420,6 +420,13 @@ impl Engine {
|
||||||
self.context().set_active_controller(controller);
|
self.context().set_active_controller(controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn controller_icon(&self, button: ControllerButton) -> Result<Arc<Image>> {
|
||||||
|
Ok(self.settings().controller_icon(self, button)?.unwrap_or(
|
||||||
|
self.settings()
|
||||||
|
.controller_button_for(self, button, ControllerType::XBox)?,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn context(&self) -> &Arc<Context> {
|
pub fn context(&self) -> &Arc<Context> {
|
||||||
&self.graphical.context
|
&self.graphical.context
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,9 +189,9 @@ impl EngineSettings {
|
||||||
&self.light_key
|
&self.light_key
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn controller_button(
|
pub fn controller_icon(
|
||||||
&self,
|
&self,
|
||||||
engine: &Arc<Engine>,
|
engine: &Engine,
|
||||||
button: ControllerButton,
|
button: ControllerButton,
|
||||||
) -> Result<Option<Arc<Image>>> {
|
) -> Result<Option<Arc<Image>>> {
|
||||||
// TODO: don't check it every time we request a button
|
// TODO: don't check it every time we request a button
|
||||||
|
|
|
@ -140,7 +140,7 @@ impl LootStash {
|
||||||
match game
|
match game
|
||||||
.engine()
|
.engine()
|
||||||
.settings()
|
.settings()
|
||||||
.controller_button(game.engine(), ControllerButton::DPadUp)?
|
.controller_icon(game.engine(), ControllerButton::DPadUp)?
|
||||||
{
|
{
|
||||||
Some(pic) => {
|
Some(pic) => {
|
||||||
icon.set_icon(&pic)?;
|
icon.set_icon(&pic)?;
|
||||||
|
|
Loading…
Reference in a new issue