init
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
using Sirenix.Utilities;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using VOID.Generic.Dict;
|
||||
using VOID.UserInterface.Game.Util;
|
||||
using VOID.ScriptableObjects.Abilities;
|
||||
|
||||
namespace VOID.UserInterface.Game.Tooltip
|
||||
{
|
||||
public class AbilityTooltipUI : ITooltip
|
||||
{
|
||||
|
||||
// VisualElement - Container
|
||||
private readonly VisualElement _templateElement;
|
||||
|
||||
// VisualElements - Sections
|
||||
private readonly VisualElement _titleSection;
|
||||
private readonly VisualElement _descriptionSection;
|
||||
private readonly VisualElement _footSection;
|
||||
|
||||
// VisualElements - Data
|
||||
private readonly SlotUI _abilityIcon = new();
|
||||
private readonly Label _abilityName;
|
||||
private readonly Label _abilityDescription;
|
||||
|
||||
public AbilityTooltipUI(VisualElement templateElement)
|
||||
{
|
||||
// Tooltip for this type
|
||||
_templateElement = templateElement.Q(null, "tooltip");
|
||||
|
||||
// Sections
|
||||
_titleSection = templateElement.Q("title-section");
|
||||
_descriptionSection = templateElement.Q("description-section");
|
||||
_footSection = templateElement.Q("foot-section");
|
||||
|
||||
// Elements
|
||||
_abilityIcon.Init(templateElement.Q("ability-icon"), SlotType.None, -1);
|
||||
_abilityName = templateElement.Q<Label>("ability-name");
|
||||
_abilityDescription = templateElement.Q<Label>("ability-description");
|
||||
}
|
||||
|
||||
public void Show(BasicAbility ability)
|
||||
{
|
||||
_abilityIcon.Set(ability);
|
||||
_templateElement.style.display = DisplayStyle.Flex;
|
||||
|
||||
FillBasicInfo(ability);
|
||||
}
|
||||
|
||||
public void Hide()
|
||||
{
|
||||
_templateElement.style.display = DisplayStyle.None;
|
||||
}
|
||||
|
||||
public Vector2 GetSize()
|
||||
{
|
||||
return new Vector2(_templateElement.worldBound.width, _templateElement.worldBound.height);
|
||||
}
|
||||
|
||||
private void FillBasicInfo(BasicAbility ability)
|
||||
{
|
||||
_abilityName.text = ability.displayName;
|
||||
_abilityDescription.text = ability.displayDescription;
|
||||
_descriptionSection.style.display = _abilityDescription.text.IsNullOrWhitespace() ? DisplayStyle.None : DisplayStyle.Flex;
|
||||
|
||||
// TODO: temporary ability description for tooltip
|
||||
_abilityDescription.text += "<br><br>TODO: TEMPORARY:";
|
||||
_abilityDescription.text += "<br>isMelee: " + ability.isRanged;
|
||||
_abilityDescription.text += "<br>range: " + ability.range;
|
||||
_abilityDescription.text += "<br>castingType: " + ability.castingType;
|
||||
_abilityDescription.text += "<br>aimingType: " + ability.aimingType;
|
||||
_abilityDescription.text += "<br>castUsages: " + ability.castUsages;
|
||||
_abilityDescription.text += "<br>applyOnCaster: ";
|
||||
ability.applyOnCaster.ForEach(effect => _abilityDescription.text += "<br> " + effect.GetSimpleDescription());
|
||||
_abilityDescription.text += "<br>applyOnTarget: ";
|
||||
ability.applyOnTarget.ForEach(effect => _abilityDescription.text += "<br> " + effect.GetSimpleDescription());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5a0cc9871814b689269c6cbd3dfe193
|
||||
timeCreated: 1691011853
|
||||
@@ -0,0 +1,20 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
engine="UnityEngine.UIElements" editor="UnityEditor.UIElements"
|
||||
noNamespaceSchemaLocation="../../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
||||
<ui:Template name="TooltipBackground" src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Tooltip/TooltipBackground.uxml?fileID=9197481963319205126&guid=547e49bedfdd22d459cd34398a254d83&type=3#TooltipBackground" />
|
||||
<ui:Template name="Slot" src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Utility/Slot.uxml?fileID=9197481963319205126&guid=5a74e2b56bbc27c4ab7a5d0c1de93f00&type=3#Slot" />
|
||||
<Style src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Tooltip/TooltipStyle.uss?fileID=7433441132597879392&guid=90349be0ccc48354eae60e7bc8cf5d07&type=3#TooltipStyle" />
|
||||
<Style src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Utility/SlotOuter.uss?fileID=7433441132597879392&guid=760aa0b2431a11e46a81be0018d225b1&type=3#SlotOuter" />
|
||||
<ui:VisualElement name="ability-tooltip" class="tooltip">
|
||||
<ui:Instance template="TooltipBackground" name="tooltip-background" />
|
||||
<ui:VisualElement class="tooltip-content" style="flex-grow: 1;">
|
||||
<ui:VisualElement name="title-section" style="flex-direction: row;">
|
||||
<ui:Label tabindex="-1" text="ABILITY_NAME" display-tooltip-when-elided="true" name="ability-name" style="margin-right: 2px; margin-top: 2px; padding-left: 2px; padding-right: 2px; padding-top: 2px; padding-bottom: 2px; flex-grow: 1;" />
|
||||
<ui:Instance template="Slot" name="ability-icon" class="slot slot-medium" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="description-section" class="section" style="flex-grow: 1;">
|
||||
<ui:Label tabindex="-1" text="ABILITY_DESCRIPTION" display-tooltip-when-elided="true" name="ability-description" style="-unity-text-align: upper-left; white-space: normal; text-overflow: clip;" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5cbd5b544b7a6c44ab5fccaf212eb7ce
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
@@ -0,0 +1,28 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace VOID.UserInterface.Game.Tooltip
|
||||
{
|
||||
public class DetailsElement
|
||||
{
|
||||
public DetailsElement(VisualElement container, Sprite icon, string[] text)
|
||||
{
|
||||
var detailsElement = new VisualElement();
|
||||
detailsElement.AddToClassList("details-element");
|
||||
detailsElement.pickingMode = PickingMode.Ignore;
|
||||
container.Add(detailsElement);
|
||||
|
||||
var detailsIcon = new VisualElement();
|
||||
detailsIcon.AddToClassList("details-icon");
|
||||
detailsIcon.style.backgroundImage = new StyleBackground(icon);
|
||||
detailsIcon.pickingMode = PickingMode.Ignore;
|
||||
detailsElement.Add(detailsIcon);
|
||||
|
||||
var detailsLabel = new Label();
|
||||
detailsLabel.AddToClassList("details-label");
|
||||
detailsLabel.text = string.Join("<br>", text);
|
||||
detailsLabel.pickingMode = PickingMode.Ignore;
|
||||
detailsElement.Add(detailsLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f75b8214991427892d0485b3ca4a941
|
||||
timeCreated: 1690828989
|
||||
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace VOID.UserInterface.Game.Tooltip
|
||||
{
|
||||
public interface ITooltip
|
||||
{
|
||||
public Vector2 GetSize();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ef487d6cf754cf38bb8ad55a77c6b39
|
||||
timeCreated: 1691085349
|
||||
@@ -0,0 +1,77 @@
|
||||
using System.Globalization;
|
||||
using Sirenix.Utilities;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using VOID.Generic.Dict;
|
||||
using VOID.Generic.Objects.Item;
|
||||
using VOID.UserInterface.Game.Util;
|
||||
|
||||
namespace VOID.UserInterface.Game.Tooltip
|
||||
{
|
||||
public class ItemTooltipUI : ITooltip
|
||||
{
|
||||
|
||||
// VisualElement - Container
|
||||
private readonly VisualElement _templateElement;
|
||||
|
||||
// VisualElements - Sections
|
||||
private readonly VisualElement _titleSection;
|
||||
private readonly VisualElement _descriptionSection;
|
||||
private readonly VisualElement _footSection;
|
||||
|
||||
// VisualElements - Data
|
||||
private readonly SlotUI _itemIcon = new();
|
||||
private readonly Label _itemName;
|
||||
private readonly Label _itemQuality;
|
||||
private readonly Label _itemDescription;
|
||||
private readonly Label _itemValue;
|
||||
private readonly Label _itemWeight;
|
||||
|
||||
public ItemTooltipUI(VisualElement templateElement)
|
||||
{
|
||||
// Tooltip for this type
|
||||
_templateElement = templateElement.Q(null, "tooltip");
|
||||
|
||||
// Sections
|
||||
_titleSection = templateElement.Q("title-section");
|
||||
_descriptionSection = templateElement.Q("description-section");
|
||||
_footSection = templateElement.Q("foot-section");
|
||||
|
||||
// Elements
|
||||
_itemIcon.Init(templateElement.Q("item-icon"), SlotType.None, -1);
|
||||
_itemName = templateElement.Q<Label>("item-name");
|
||||
_itemQuality = templateElement.Q<Label>("item-quality");
|
||||
_itemDescription = templateElement.Q<Label>("item-description");
|
||||
_itemValue = templateElement.Q<Label>("item-value");
|
||||
_itemWeight = templateElement.Q<Label>("item-weight");
|
||||
}
|
||||
|
||||
public void Show(ItemObject item)
|
||||
{
|
||||
_itemIcon.Set(item);
|
||||
_templateElement.style.display = DisplayStyle.Flex;
|
||||
|
||||
FillBasicInfo(item);
|
||||
}
|
||||
|
||||
public void Hide()
|
||||
{
|
||||
_templateElement.style.display = DisplayStyle.None;
|
||||
}
|
||||
|
||||
public Vector2 GetSize()
|
||||
{
|
||||
return new Vector2(_templateElement.worldBound.width, _templateElement.worldBound.height);
|
||||
}
|
||||
|
||||
private void FillBasicInfo(ItemObject item)
|
||||
{
|
||||
_itemName.text = item.basicData.finalName;
|
||||
_itemQuality.text = item.itemData.quality.displayName;
|
||||
_itemDescription.text = item.basicData.description;
|
||||
_descriptionSection.style.display = _itemDescription.text.IsNullOrWhitespace() ? DisplayStyle.None : DisplayStyle.Flex;
|
||||
_itemValue.text = item.itemData.finalValue.ToString(CultureInfo.InvariantCulture);
|
||||
_itemWeight.text = item.itemData.finalWeight.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9bd9f2103054d79bc090297d882bedd
|
||||
timeCreated: 1691010045
|
||||
@@ -0,0 +1,27 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
engine="UnityEngine.UIElements" editor="UnityEditor.UIElements"
|
||||
noNamespaceSchemaLocation="../../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
||||
<ui:Template name="TooltipBackground" src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Tooltip/TooltipBackground.uxml?fileID=9197481963319205126&guid=547e49bedfdd22d459cd34398a254d83&type=3#TooltipBackground" />
|
||||
<ui:Template name="Slot" src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Utility/Slot.uxml?fileID=9197481963319205126&guid=5a74e2b56bbc27c4ab7a5d0c1de93f00&type=3#Slot" />
|
||||
<Style src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Tooltip/TooltipStyle.uss?fileID=7433441132597879392&guid=90349be0ccc48354eae60e7bc8cf5d07&type=3#TooltipStyle" />
|
||||
<Style src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Utility/SlotOuter.uss?fileID=7433441132597879392&guid=760aa0b2431a11e46a81be0018d225b1&type=3#SlotOuter" />
|
||||
<ui:VisualElement name="item-tooltip" class="tooltip">
|
||||
<ui:Instance template="TooltipBackground" name="tooltip-background" />
|
||||
<ui:VisualElement class="tooltip-content" style="flex-grow: 1;">
|
||||
<ui:VisualElement name="title-section" style="flex-direction: row;">
|
||||
<ui:VisualElement style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); flex-shrink: 0;">
|
||||
<ui:Label tabindex="-1" text="ITEM_NAME" display-tooltip-when-elided="true" name="item-name" style="margin-right: 2px; margin-top: 2px; padding-left: 2px; padding-right: 2px; padding-top: 2px; padding-bottom: 2px;" />
|
||||
<ui:Label tabindex="-1" text="ITEM_QUALITY" display-tooltip-when-elided="true" name="item-quality" style="margin-right: 2px; margin-top: 2px; padding-left: 2px; padding-right: 2px; padding-top: 2px; padding-bottom: 2px; font-size: 12px;" />
|
||||
</ui:VisualElement>
|
||||
<ui:Instance template="Slot" name="item-icon" class="slot slot-medium" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="description-section" class="section" style="flex-grow: 1;">
|
||||
<ui:Label tabindex="-1" text="ITEM_DESCRIPTION" display-tooltip-when-elided="true" name="item-description" style="-unity-text-align: upper-left; white-space: normal; text-overflow: clip;" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="foot-section" class="section" style="flex-grow: 1; flex-direction: row-reverse;">
|
||||
<ui:Label tabindex="-1" text="ITEM_VALUE" display-tooltip-when-elided="true" name="item-value" />
|
||||
<ui:Label tabindex="-1" text="ITEM_WEIGHT" display-tooltip-when-elided="true" name="item-weight" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b294a69b27ae2642829fa60b051881b
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
@@ -0,0 +1,71 @@
|
||||
using Sirenix.Utilities;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using VOID.ScriptableObjects;
|
||||
|
||||
namespace VOID.UserInterface.Game.Tooltip
|
||||
{
|
||||
public class StatusTooltipUI : ITooltip
|
||||
{
|
||||
// VisualElement - Container
|
||||
private readonly VisualElement _templateElement;
|
||||
|
||||
// VisualElements - Sections
|
||||
private readonly VisualElement _titleSection;
|
||||
private readonly VisualElement _descriptionSection;
|
||||
|
||||
// VisualElements - Data
|
||||
private readonly VisualElement _statusIcon;
|
||||
private readonly Label _statusName;
|
||||
private readonly Label _statusDescription;
|
||||
private readonly Label _statusTimeRemaining;
|
||||
|
||||
public StatusTooltipUI(VisualElement templateElement)
|
||||
{
|
||||
// Tooltip for this type
|
||||
_templateElement = templateElement.Q(null, "tooltip");
|
||||
|
||||
// Sections
|
||||
_titleSection = templateElement.Q("title-section");
|
||||
_descriptionSection = templateElement.Q("description-section");
|
||||
|
||||
// Elements
|
||||
_statusIcon = templateElement.Q("status-icon");
|
||||
_statusName = templateElement.Q<Label>("status-name");
|
||||
_statusDescription = templateElement.Q<Label>("status-description");
|
||||
_statusTimeRemaining = templateElement.Q<Label>("status-time-remaining");
|
||||
}
|
||||
|
||||
public void Show(BasicStatus status)
|
||||
{
|
||||
_statusIcon.style.backgroundImage = status.displayIcon;
|
||||
_templateElement.style.display = DisplayStyle.Flex;
|
||||
|
||||
FillBasicInfo(status);
|
||||
}
|
||||
|
||||
public void Hide()
|
||||
{
|
||||
_templateElement.style.display = DisplayStyle.None;
|
||||
}
|
||||
|
||||
public Vector2 GetSize()
|
||||
{
|
||||
return new Vector2(_templateElement.worldBound.width, _templateElement.worldBound.height);
|
||||
}
|
||||
|
||||
private void FillBasicInfo(BasicStatus status)
|
||||
{
|
||||
_statusName.text = status.displayName;
|
||||
_statusDescription.text = status.description;
|
||||
_descriptionSection.style.display = _statusDescription.text.IsNullOrWhitespace() ? DisplayStyle.None : DisplayStyle.Flex;
|
||||
|
||||
// TODO: temporary status description for tooltip
|
||||
_statusDescription.text += "<br><br>TODO: TEMPORARY:";
|
||||
_statusDescription.text += "<br>effects: ";
|
||||
status.effects.ForEach(effect => _statusDescription.text += "<br> " + effect.GetSimpleDescription());
|
||||
|
||||
_statusTimeRemaining.text = $"Remaining {status.durationLeftInTurns} turns (~{status.durationLeft:0} seconds)";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 895fc55c48ee4475bd6069981de2bd54
|
||||
timeCreated: 1696177912
|
||||
@@ -0,0 +1,20 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
engine="UnityEngine.UIElements" editor="UnityEditor.UIElements"
|
||||
noNamespaceSchemaLocation="../../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
||||
<ui:Template name="TooltipBackground" src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Tooltip/TooltipBackground.uxml?fileID=9197481963319205126&guid=547e49bedfdd22d459cd34398a254d83&type=3#TooltipBackground" />
|
||||
<Style src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Tooltip/TooltipStyle.uss?fileID=7433441132597879392&guid=90349be0ccc48354eae60e7bc8cf5d07&type=3#TooltipStyle" />
|
||||
<Style src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Utility/StatusOuter.uss?fileID=7433441132597879392&guid=6eb1ae18d8fd2c541be09b7ecad6e722&type=3#StatusOuter" />
|
||||
<ui:VisualElement name="status-tooltip" class="tooltip">
|
||||
<ui:Instance template="TooltipBackground" name="tooltip-background" />
|
||||
<ui:VisualElement class="tooltip-content" style="flex-grow: 1;">
|
||||
<ui:VisualElement name="title-section" style="flex-direction: row;">
|
||||
<ui:Label tabindex="-1" text="{ABILITY_NAME}" display-tooltip-when-elided="true" name="status-name" style="margin-right: 2px; margin-top: 2px; padding-left: 2px; padding-right: 2px; padding-top: 2px; padding-bottom: 2px; flex-grow: 1;" />
|
||||
<ui:VisualElement name="status-icon" class="status status-big" style="background-image: url('project://database/Assets/5%20-%20Textures/Generic/Icons/status_placeholder_icon.png?fileID=2800000&guid=f386e7ee1fbaf804396fd2b5d6176a56&type=3#status_placeholder_icon');" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="description-section" class="section" style="flex-grow: 1;">
|
||||
<ui:Label tabindex="-1" text="{ABILITY_DESCRIPTION}" display-tooltip-when-elided="true" name="status-description" style="-unity-text-align: upper-left; white-space: normal; text-overflow: clip;" />
|
||||
<ui:Label tabindex="-1" text="{TIME_REMAINING}" display-tooltip-when-elided="true" name="status-time-remaining" style="-unity-text-align: upper-left; white-space: normal; text-overflow: clip;" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8bf62e0c5dd842a40b80528ff7c153ad
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
@@ -0,0 +1,7 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
engine="UnityEngine.UIElements" editor="UnityEditor.UIElements"
|
||||
noNamespaceSchemaLocation="../../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
||||
<Style src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Tooltip/TooltipStyle.uss?fileID=7433441132597879392&guid=90349be0ccc48354eae60e7bc8cf5d07&type=3#TooltipStyle" />
|
||||
<ui:VisualElement name="background" />
|
||||
<ui:VisualElement name="border" />
|
||||
</ui:UXML>
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 547e49bedfdd22d459cd34398a254d83
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
@@ -0,0 +1,157 @@
|
||||
using Sirenix.Utilities;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.UIElements;
|
||||
using VOID.Generic.Objects.Usable;
|
||||
using VOID.Generic.Objects.Weapon;
|
||||
using VOID.Generic.Objects.Wearable;
|
||||
using VOID.UserInterface.Game.Util;
|
||||
using VOID.ScriptableObjects.Abilities;
|
||||
|
||||
namespace VOID.UserInterface.Game.Tooltip
|
||||
{
|
||||
|
||||
public class TooltipManagerUI : MonoBehaviour
|
||||
{
|
||||
public static TooltipManagerUI current { get; private set; }
|
||||
|
||||
// Tooltip elements
|
||||
private VisualElement _rootElement;
|
||||
private WeaponTooltipUI _weaponTooltip;
|
||||
private WearableTooltipUI _wearableTooltip;
|
||||
private UsableTooltipUI _usableTooltip;
|
||||
private ItemTooltipUI _itemTooltip;
|
||||
private AbilityTooltipUI _abilityTooltip;
|
||||
private StatusTooltipUI _statusTooltip;
|
||||
|
||||
// Size
|
||||
private ITooltip _currentTooltip;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
current = this;
|
||||
|
||||
// Tooltip elements init
|
||||
var uiDocument = gameObject.GetComponent<UIDocument>();
|
||||
var templateElement = uiDocument.rootVisualElement;
|
||||
|
||||
// SAFEGUARD - tooltips should never be clickable, if somehow UI was built weird then this should fix it
|
||||
templateElement.Query<VisualElement>().ForEach(element => element.pickingMode = PickingMode.Ignore);
|
||||
|
||||
_rootElement = templateElement.Q("root-tooltip");
|
||||
_weaponTooltip = new WeaponTooltipUI(_rootElement.Q("weapon-tooltip"));
|
||||
_wearableTooltip = new WearableTooltipUI(_rootElement.Q("wearable-tooltip"));
|
||||
_usableTooltip = new UsableTooltipUI(_rootElement.Q("usable-tooltip"));
|
||||
_itemTooltip = new ItemTooltipUI(_rootElement.Q("item-tooltip"));
|
||||
_abilityTooltip = new AbilityTooltipUI(_rootElement.Q("ability-tooltip"));
|
||||
_statusTooltip = new StatusTooltipUI(_rootElement.Q("status-tooltip"));
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// Events - cursor entering and leaving slotUI
|
||||
GameUI.current.ElementsUnderCursorChanged += OnElementsUnderCursorChanged;
|
||||
|
||||
Hide();
|
||||
}
|
||||
|
||||
private void OnElementsUnderCursorChanged()
|
||||
{
|
||||
switch (GameUI.current.PickTopComponentUI())
|
||||
{
|
||||
case SlotUI slotUI:
|
||||
Show(slotUI);
|
||||
break;
|
||||
case StatusUI statusUI:
|
||||
Show(statusUI);
|
||||
break;
|
||||
default:
|
||||
Hide();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update() => MoveTooltip();
|
||||
|
||||
private void MoveTooltip()
|
||||
{
|
||||
var size = _currentTooltip.GetSize() / GameUI.current.scale;
|
||||
var minPos = Vector2.zero;
|
||||
var maxPos = new Vector2(Screen.width - size.x, Screen.height - size.y);
|
||||
var pos = Mouse.current.position.ReadValue().Clamp(minPos, maxPos);
|
||||
|
||||
var panelPos = RuntimePanelUtils.ScreenToPanel(_rootElement.panel, pos);
|
||||
_rootElement.style.bottom = new StyleLength(panelPos.y);
|
||||
_rootElement.style.left = new StyleLength(panelPos.x);
|
||||
}
|
||||
|
||||
private void Show(SlotUI slotUI)
|
||||
{
|
||||
if (slotUI.isEmpty) return;
|
||||
|
||||
Hide();
|
||||
|
||||
_rootElement.style.display = DisplayStyle.Flex;
|
||||
enabled = true;
|
||||
|
||||
switch (slotUI.item)
|
||||
{
|
||||
case WeaponObject weapon:
|
||||
_weaponTooltip.Show(weapon);
|
||||
_currentTooltip = _weaponTooltip;
|
||||
return;
|
||||
case WearableObject wearable:
|
||||
_wearableTooltip.Show(wearable);
|
||||
_currentTooltip = _wearableTooltip;
|
||||
return;
|
||||
case UsableObject usable:
|
||||
_usableTooltip.Show(usable);
|
||||
_currentTooltip = _usableTooltip;
|
||||
return;
|
||||
case { } item:
|
||||
_itemTooltip.Show(item);
|
||||
_currentTooltip = _itemTooltip;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (slotUI.ability)
|
||||
{
|
||||
// TODO: tutaj może będzie inny tooltip dla podstawowego ataku
|
||||
case BasicAttackAbility attackAbility:
|
||||
_abilityTooltip.Show(attackAbility);
|
||||
_currentTooltip = _abilityTooltip;
|
||||
return;
|
||||
case { } ability:
|
||||
_abilityTooltip.Show(ability);
|
||||
_currentTooltip = _abilityTooltip;
|
||||
return;
|
||||
}
|
||||
|
||||
Hide();
|
||||
var itemType = slotUI.item ? slotUI.item.GetType().GetNiceName() : "-----";
|
||||
var abilityType = slotUI.ability ? slotUI.ability.GetType().GetNiceName() : "-----";
|
||||
Debug.LogWarning("No valid tooltip for '" + itemType + "' or '" + abilityType + "'.");
|
||||
}
|
||||
|
||||
private void Show(StatusUI statusUI)
|
||||
{
|
||||
Hide();
|
||||
_rootElement.style.display = DisplayStyle.Flex;
|
||||
enabled = true;
|
||||
_statusTooltip.Show(statusUI.status);
|
||||
_currentTooltip = _statusTooltip;
|
||||
}
|
||||
|
||||
private void Hide()
|
||||
{
|
||||
_weaponTooltip.Hide();
|
||||
_wearableTooltip.Hide();
|
||||
_usableTooltip.Hide();
|
||||
_itemTooltip.Hide();
|
||||
_abilityTooltip.Hide();
|
||||
_statusTooltip.Hide();
|
||||
_rootElement.style.display = DisplayStyle.None;
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f3aa172db4e746da9f9acf12899bc925
|
||||
timeCreated: 1690751590
|
||||
@@ -0,0 +1,19 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
engine="UnityEngine.UIElements" editor="UnityEditor.UIElements"
|
||||
noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
||||
<ui:Template name="ItemTooltip" src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Tooltip/WeaponTooltipUI.uxml?fileID=9197481963319205126&guid=8e8fcf90331937b459b3c65b1dc8ce3f&type=3#WeaponTooltipUI" />
|
||||
<ui:Template name="WearableTooltipUI" src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Tooltip/WearableTooltipUI.uxml?fileID=9197481963319205126&guid=6f886a4e210c1074ca6787dcbf9ecf2e&type=3#WearableTooltipUI" />
|
||||
<ui:Template name="UsableTooltipUI" src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Tooltip/UsableTooltipUI.uxml?fileID=9197481963319205126&guid=01c82ae900b976d4f8f770f0c804093c&type=3#UsableTooltipUI" />
|
||||
<ui:Template name="ItemTooltipUI" src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Tooltip/ItemTooltipUI.uxml?fileID=9197481963319205126&guid=5b294a69b27ae2642829fa60b051881b&type=3#ItemTooltipUI" />
|
||||
<ui:Template name="AbilityTooltip" src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Tooltip/AbilityTooltipUI.uxml?fileID=9197481963319205126&guid=5cbd5b544b7a6c44ab5fccaf212eb7ce&type=3#AbilityTooltipUI" />
|
||||
<ui:Template name="StatusTooltipUI" src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Tooltip/StatusTooltipUI.uxml?fileID=9197481963319205126&guid=8bf62e0c5dd842a40b80528ff7c153ad&type=3#StatusTooltipUI" />
|
||||
<Style src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Tooltip/TooltipStyle.uss?fileID=7433441132597879392&guid=90349be0ccc48354eae60e7bc8cf5d07&type=3#TooltipStyle" />
|
||||
<ui:VisualElement name="root-tooltip">
|
||||
<ui:Instance template="ItemTooltip" name="weapon-tooltip" />
|
||||
<ui:Instance template="WearableTooltipUI" name="wearable-tooltip" />
|
||||
<ui:Instance template="UsableTooltipUI" name="usable-tooltip" />
|
||||
<ui:Instance template="ItemTooltipUI" name="item-tooltip" />
|
||||
<ui:Instance template="AbilityTooltip" name="ability-tooltip" />
|
||||
<ui:Instance template="StatusTooltipUI" name="status-tooltip" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7171581139e93b446bce602c33e2b6f1
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
@@ -0,0 +1,89 @@
|
||||
#root-tooltip {
|
||||
background-color: rgba(0, 0, 0, 0);
|
||||
position: absolute;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.tooltip {
|
||||
width: 300px;
|
||||
min-height: 50px;
|
||||
color: rgb(187, 187, 187);
|
||||
}
|
||||
|
||||
.tooltip-content {
|
||||
padding-left: 7px;
|
||||
padding-right: 7px;
|
||||
padding-top: 7px;
|
||||
padding-bottom: 7px;
|
||||
}
|
||||
|
||||
.details-element {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.details-icon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
flex-shrink: 0;
|
||||
background-color: rgba(255, 0, 0, 0.27);
|
||||
margin-left: 2px;
|
||||
margin-right: 2px;
|
||||
margin-top: 2px;
|
||||
margin-bottom: 2px;
|
||||
padding-left: 2px;
|
||||
padding-right: 2px;
|
||||
padding-top: 2px;
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
|
||||
.details-label {
|
||||
flex-grow: 1;
|
||||
margin-left: 2px;
|
||||
margin-right: 2px;
|
||||
margin-top: 2px;
|
||||
margin-bottom: 2px;
|
||||
padding-left: 2px;
|
||||
padding-right: 2px;
|
||||
padding-top: 2px;
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
|
||||
#title-section {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.section {
|
||||
border-top-color: rgba(0, 0, 0, 0.39);
|
||||
border-top-width: 1px;
|
||||
margin-top: 5px;
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
#foot-section {
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
|
||||
#tooltip-background {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
#background {
|
||||
background-color: rgb(33, 33, 33);
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
#border {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-image: url('project://database/Assets/_ADDONS/MedievalKingdomUI/Artworks/White_gold_Skin/UI_elements_W/Main_bar_frame.png?fileID=2800000&guid=f3e73c26aa3a97547bc7b96427ec4084&type=3#Main_bar_frame');
|
||||
-unity-slice-left: 32;
|
||||
-unity-slice-top: 32;
|
||||
-unity-slice-right: 32;
|
||||
-unity-slice-bottom: 32;
|
||||
-unity-slice-scale: 0.3px;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 90349be0ccc48354eae60e7bc8cf5d07
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
|
||||
disableValidation: 0
|
||||
@@ -0,0 +1,93 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Sirenix.Utilities;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using VOID.Generic.Dict;
|
||||
using VOID.Generic.Objects.Usable;
|
||||
using VOID.UserInterface.Game.Util;
|
||||
|
||||
namespace VOID.UserInterface.Game.Tooltip
|
||||
{
|
||||
public class UsableTooltipUI : ITooltip
|
||||
{
|
||||
// VisualElement - Container
|
||||
private readonly VisualElement _templateElement;
|
||||
|
||||
// VisualElements - Sections
|
||||
private readonly VisualElement _titleSection;
|
||||
private readonly VisualElement _detailsSection;
|
||||
private readonly VisualElement _descriptionSection;
|
||||
private readonly VisualElement _footSection;
|
||||
|
||||
// VisualElements - Data
|
||||
private readonly SlotUI _usableIcon = new();
|
||||
private readonly List<DetailsElement> _details = new();
|
||||
private readonly Label _usableName;
|
||||
private readonly Label _usableQuality;
|
||||
private readonly Label _usableDescription;
|
||||
private readonly Label _usableValue;
|
||||
private readonly Label _usableWeight;
|
||||
|
||||
public UsableTooltipUI(VisualElement templateElement)
|
||||
{
|
||||
// Tooltip for this type
|
||||
_templateElement = templateElement.Q(null, "tooltip");
|
||||
|
||||
// Sections
|
||||
_titleSection = templateElement.Q("title-section");
|
||||
_detailsSection = templateElement.Q("details-section");
|
||||
_descriptionSection = templateElement.Q("description-section");
|
||||
_footSection = templateElement.Q("foot-section");
|
||||
|
||||
// Elements
|
||||
_usableIcon.Init(templateElement.Q("usable-icon"), SlotType.None, -1);
|
||||
_usableName = templateElement.Q<Label>("usable-name");
|
||||
_usableQuality = templateElement.Q<Label>("usable-quality");
|
||||
_usableDescription = templateElement.Q<Label>("usable-description");
|
||||
_usableValue = templateElement.Q<Label>("usable-value");
|
||||
_usableWeight = templateElement.Q<Label>("usable-weight");
|
||||
}
|
||||
|
||||
public void Show(UsableObject usable)
|
||||
{
|
||||
_usableIcon.Set(usable);
|
||||
_templateElement.style.display = DisplayStyle.Flex;
|
||||
|
||||
FillBasicInfo(usable);
|
||||
FillDetails(usable);
|
||||
}
|
||||
|
||||
public void Hide()
|
||||
{
|
||||
_templateElement.style.display = DisplayStyle.None;
|
||||
}
|
||||
|
||||
public Vector2 GetSize()
|
||||
{
|
||||
return new Vector2(_templateElement.worldBound.width, _templateElement.worldBound.height);
|
||||
}
|
||||
|
||||
private void FillBasicInfo(UsableObject usable)
|
||||
{
|
||||
_usableName.text = usable.basicData.finalName;
|
||||
_usableQuality.text = usable.itemData.quality.displayName;
|
||||
_usableDescription.text = usable.basicData.description;
|
||||
_descriptionSection.style.display = _usableDescription.text.IsNullOrWhitespace() ? DisplayStyle.None : DisplayStyle.Flex;
|
||||
_usableValue.text = usable.itemData.finalValue.ToString(CultureInfo.InvariantCulture);
|
||||
_usableWeight.text = usable.itemData.finalWeight.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
private void FillDetails(UsableObject usable)
|
||||
{
|
||||
_detailsSection.Clear();
|
||||
|
||||
// All effects provided by usable item
|
||||
var effects = usable.usableData.applyOnUse
|
||||
.Select(effect => effect.GetSimpleDescription())
|
||||
.ToArray();
|
||||
if (!effects.IsNullOrEmpty()) _details.Add(new DetailsElement(_detailsSection, null, effects));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c53066e09fd4791a89ad4ba866036b6
|
||||
timeCreated: 1691010341
|
||||
@@ -0,0 +1,33 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
engine="UnityEngine.UIElements" editor="UnityEditor.UIElements"
|
||||
noNamespaceSchemaLocation="../../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
||||
<ui:Template name="TooltipBackground" src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Tooltip/TooltipBackground.uxml?fileID=9197481963319205126&guid=547e49bedfdd22d459cd34398a254d83&type=3#TooltipBackground" />
|
||||
<ui:Template name="Slot" src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Utility/Slot.uxml?fileID=9197481963319205126&guid=5a74e2b56bbc27c4ab7a5d0c1de93f00&type=3#Slot" />
|
||||
<Style src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Tooltip/TooltipStyle.uss?fileID=7433441132597879392&guid=90349be0ccc48354eae60e7bc8cf5d07&type=3#TooltipStyle" />
|
||||
<Style src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Utility/SlotOuter.uss?fileID=7433441132597879392&guid=760aa0b2431a11e46a81be0018d225b1&type=3#SlotOuter" />
|
||||
<ui:VisualElement name="usable-tooltip" class="tooltip">
|
||||
<ui:Instance template="TooltipBackground" name="tooltip-background" />
|
||||
<ui:VisualElement class="tooltip-content" style="flex-grow: 1;">
|
||||
<ui:VisualElement name="title-section" style="flex-direction: row;">
|
||||
<ui:VisualElement style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); flex-shrink: 0;">
|
||||
<ui:Label tabindex="-1" text="ITEM_NAME" display-tooltip-when-elided="true" name="usable-name" style="margin-right: 2px; margin-top: 2px; padding-left: 2px; padding-right: 2px; padding-top: 2px; padding-bottom: 2px;" />
|
||||
<ui:Label tabindex="-1" text="ITEM_QUALITY" display-tooltip-when-elided="true" name="usable-quality" style="margin-right: 2px; margin-top: 2px; padding-left: 2px; padding-right: 2px; padding-top: 2px; padding-bottom: 2px; font-size: 12px;" />
|
||||
</ui:VisualElement>
|
||||
<ui:Instance template="Slot" name="usable-icon" class="slot slot-medium" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="details-section" class="section" style="flex-grow: 1;">
|
||||
<ui:VisualElement class="details-element">
|
||||
<ui:VisualElement class="details-icon" />
|
||||
<ui:Label tabindex="-1" text="place holder<br>ITEM_EFFECT_1<br>ITEM_EFFECT_2<br>ITEM_EFFECT_3" display-tooltip-when-elided="true" class="details-label" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="description-section" class="section" style="flex-grow: 1;">
|
||||
<ui:Label tabindex="-1" text="ITEM_DESCRIPTION" display-tooltip-when-elided="true" name="usable-description" style="-unity-text-align: upper-left; white-space: normal; text-overflow: clip;" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="foot-section" class="section" style="flex-grow: 1; flex-direction: row-reverse;">
|
||||
<ui:Label tabindex="-1" text="ITEM_VALUE" display-tooltip-when-elided="true" name="usable-value" />
|
||||
<ui:Label tabindex="-1" text="ITEM_WEIGHT" display-tooltip-when-elided="true" name="usable-weight" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01c82ae900b976d4f8f770f0c804093c
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
@@ -0,0 +1,117 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Sirenix.Utilities;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using VOID.Generic.Dict;
|
||||
using VOID.Generic.Objects.Weapon;
|
||||
using VOID.UserInterface.Game.Util;
|
||||
|
||||
namespace VOID.UserInterface.Game.Tooltip
|
||||
{
|
||||
public class WeaponTooltipUI : ITooltip
|
||||
{
|
||||
// VisualElement - Container
|
||||
private readonly VisualElement _templateElement;
|
||||
|
||||
// VisualElements - Sections
|
||||
private readonly VisualElement _titleSection;
|
||||
private readonly VisualElement _mainDetailsSection;
|
||||
private readonly VisualElement _detailsSection;
|
||||
private readonly VisualElement _descriptionSection;
|
||||
private readonly VisualElement _footSection;
|
||||
|
||||
// VisualElements - Data
|
||||
private readonly SlotUI _weaponIcon = new();
|
||||
private readonly List<DetailsElement> _mainDetails = new();
|
||||
private readonly List<DetailsElement> _details = new();
|
||||
private readonly Label _weaponName;
|
||||
private readonly Label _weaponQuality;
|
||||
private readonly Label _weaponType;
|
||||
private readonly Label _weaponDescription;
|
||||
private readonly Label _weaponValue;
|
||||
private readonly Label _weaponWeight;
|
||||
|
||||
public WeaponTooltipUI(VisualElement templateElement)
|
||||
{
|
||||
// Tooltip for this type
|
||||
_templateElement = templateElement.Q(null, "tooltip");
|
||||
|
||||
// Sections
|
||||
_titleSection = templateElement.Q("title-section");
|
||||
_mainDetailsSection = templateElement.Q("main-details-section");
|
||||
_detailsSection = templateElement.Q("details-section");
|
||||
_descriptionSection = templateElement.Q("description-section");
|
||||
_footSection = templateElement.Q("foot-section");
|
||||
|
||||
// Elements
|
||||
_weaponIcon.Init(templateElement.Q("weapon-icon"), SlotType.None, -1);
|
||||
_weaponName = templateElement.Q<Label>("weapon-name");
|
||||
_weaponQuality = templateElement.Q<Label>("weapon-quality");
|
||||
_weaponType = templateElement.Q<Label>("weapon-type");
|
||||
_weaponDescription = templateElement.Q<Label>("weapon-description");
|
||||
_weaponValue = templateElement.Q<Label>("weapon-value");
|
||||
_weaponWeight = templateElement.Q<Label>("weapon-weight");
|
||||
}
|
||||
|
||||
public void Show(WeaponObject weapon)
|
||||
{
|
||||
_weaponIcon.Set(weapon);
|
||||
_templateElement.style.display = DisplayStyle.Flex;
|
||||
|
||||
FillBasicInfo(weapon);
|
||||
FillMainDetails(weapon);
|
||||
FillDetails(weapon);
|
||||
}
|
||||
|
||||
public void Hide()
|
||||
{
|
||||
_templateElement.style.display = DisplayStyle.None;
|
||||
}
|
||||
|
||||
public Vector2 GetSize()
|
||||
{
|
||||
return new Vector2(_templateElement.worldBound.width, _templateElement.worldBound.height);
|
||||
}
|
||||
|
||||
private void FillBasicInfo(WeaponObject weapon)
|
||||
{
|
||||
_weaponName.text = weapon.basicData.finalName;
|
||||
_weaponQuality.text = weapon.itemData.quality.displayName;
|
||||
_weaponType.text = weapon.weaponData.weaponType + " (" + weapon.weaponData.weaponCarryType + ")";
|
||||
_weaponDescription.text = weapon.basicData.description;
|
||||
_descriptionSection.style.display = _weaponDescription.text.IsNullOrWhitespace() ? DisplayStyle.None : DisplayStyle.Flex;
|
||||
_weaponValue.text = weapon.itemData.finalValue.ToString(CultureInfo.InvariantCulture);
|
||||
_weaponWeight.text = weapon.itemData.finalWeight.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
private void FillMainDetails(WeaponObject weapon)
|
||||
{
|
||||
_mainDetailsSection.Clear();
|
||||
|
||||
// Weapon's damage
|
||||
var weaponDamage = $"Damage: {weapon.weaponData.damageMin} - {weapon.weaponData.damageMax} ({weapon.weaponData.damageType})";
|
||||
_mainDetails.Add(new DetailsElement(_mainDetailsSection, null, new[] { weaponDamage }));
|
||||
|
||||
// Weapons's Critical Damage Chance
|
||||
var criticalChance = $"Crit chance: {weapon.weaponData.criticalDamageChange * 100}%";
|
||||
_mainDetails.Add(new DetailsElement(_mainDetailsSection, null, new[] { criticalChance }));
|
||||
|
||||
// Weapons's Critical Damage Multiplier
|
||||
var criticalMultiplier = $"Crit multiplier: {weapon.weaponData.criticalDamageMultiplier * 100}%";
|
||||
_mainDetails.Add(new DetailsElement(_mainDetailsSection, null, new[] { criticalMultiplier }));
|
||||
}
|
||||
|
||||
private void FillDetails(WeaponObject weapon)
|
||||
{
|
||||
_detailsSection.Clear();
|
||||
|
||||
// All effects except damage
|
||||
var simpleDescriptions = weapon.wearableData.effects
|
||||
.Select(effect => effect.GetSimpleDescription())
|
||||
.ToArray();
|
||||
_details.Add(new DetailsElement(_detailsSection, null, simpleDescriptions));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44793433cbb545f594f36f8f027d68aa
|
||||
timeCreated: 1690814317
|
||||
@@ -0,0 +1,42 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
engine="UnityEngine.UIElements" editor="UnityEditor.UIElements"
|
||||
noNamespaceSchemaLocation="../../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
||||
<ui:Template name="TooltipBackground" src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Tooltip/TooltipBackground.uxml?fileID=9197481963319205126&guid=547e49bedfdd22d459cd34398a254d83&type=3#TooltipBackground" />
|
||||
<ui:Template name="Slot" src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Utility/Slot.uxml?fileID=9197481963319205126&guid=5a74e2b56bbc27c4ab7a5d0c1de93f00&type=3#Slot" />
|
||||
<Style src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Tooltip/TooltipStyle.uss?fileID=7433441132597879392&guid=90349be0ccc48354eae60e7bc8cf5d07&type=3#TooltipStyle" />
|
||||
<Style src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Utility/SlotOuter.uss?fileID=7433441132597879392&guid=760aa0b2431a11e46a81be0018d225b1&type=3#SlotOuter" />
|
||||
<ui:VisualElement name="weapon-tooltip" class="tooltip" style="background-color: rgba(100, 100, 100, 0.87);">
|
||||
<ui:Instance template="TooltipBackground" name="tooltip-background" />
|
||||
<ui:VisualElement class="tooltip-content" style="flex-grow: 1;">
|
||||
<ui:VisualElement name="title-section" style="flex-direction: row;">
|
||||
<ui:VisualElement style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); flex-shrink: 0;">
|
||||
<ui:Label tabindex="-1" text="ITEM_NAME" display-tooltip-when-elided="true" name="weapon-name" style="margin-right: 2px; margin-top: 2px; padding-left: 2px; padding-right: 2px; padding-top: 2px; padding-bottom: 2px;" />
|
||||
<ui:VisualElement style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); flex-direction: row;">
|
||||
<ui:Label tabindex="-1" text="ITEM_QUALITY" display-tooltip-when-elided="true" name="weapon-quality" style="margin-right: 2px; margin-top: 2px; padding-left: 2px; padding-right: 2px; padding-top: 2px; padding-bottom: 2px; font-size: 12px;" />
|
||||
<ui:Label tabindex="-1" text="ITEM_TYPE" display-tooltip-when-elided="true" name="weapon-type" style="margin-right: 2px; margin-top: 2px; padding-left: 2px; padding-right: 2px; padding-top: 2px; padding-bottom: 2px; font-size: 12px;" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
<ui:Instance template="Slot" name="weapon-icon" class="slot slot-medium" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="main-details-section" class="section" style="flex-grow: 1;">
|
||||
<ui:VisualElement class="details-element">
|
||||
<ui:VisualElement class="details-icon" />
|
||||
<ui:Label tabindex="-1" text="place holders<br>MAIN_ITEM_EFFECT_1<br>MAIN_ITEM_EFFECT_2<br>MAIN_ITEM_EFFECT_3" display-tooltip-when-elided="true" class="details-label" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="details-section" class="section" style="flex-grow: 1;">
|
||||
<ui:VisualElement class="details-element">
|
||||
<ui:VisualElement class="details-icon" />
|
||||
<ui:Label tabindex="-1" text="place holder<br>ITEM_EFFECT_1<br>ITEM_EFFECT_2<br>ITEM_EFFECT_3" display-tooltip-when-elided="true" class="details-label" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="description-section" class="section" style="flex-grow: 1;">
|
||||
<ui:Label tabindex="-1" text="ITEM_DESCRIPTION" display-tooltip-when-elided="true" name="weapon-description" style="-unity-text-align: upper-left; white-space: normal; text-overflow: clip;" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="foot-section" class="section" style="flex-grow: 1; flex-direction: row-reverse;">
|
||||
<ui:Label tabindex="-1" text="ITEM_VALUE" display-tooltip-when-elided="true" name="weapon-value" />
|
||||
<ui:Label tabindex="-1" text="ITEM_WEIGHT" display-tooltip-when-elided="true" name="weapon-weight" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e8fcf90331937b459b3c65b1dc8ce3f
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
@@ -0,0 +1,98 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Sirenix.Utilities;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using VOID.Generic.Dict;
|
||||
using VOID.Generic.Objects.Wearable;
|
||||
using VOID.UserInterface.Game.Util;
|
||||
|
||||
namespace VOID.UserInterface.Game.Tooltip
|
||||
{
|
||||
public class WearableTooltipUI : ITooltip
|
||||
{
|
||||
// VisualElement - Container
|
||||
private readonly VisualElement _templateElement;
|
||||
|
||||
// VisualElements - Sections
|
||||
private readonly VisualElement _titleSection;
|
||||
private readonly VisualElement _detailsSection;
|
||||
private readonly VisualElement _descriptionSection;
|
||||
private readonly VisualElement _footSection;
|
||||
|
||||
// VisualElements - Data
|
||||
private readonly SlotUI _wearableIcon = new();
|
||||
private readonly List<DetailsElement> _details = new();
|
||||
private readonly Label _wearableName;
|
||||
private readonly Label _wearableQuality;
|
||||
private readonly Label _wearableType;
|
||||
private readonly Label _wearableDescription;
|
||||
private readonly Label _wearableValue;
|
||||
private readonly Label _wearableWeight;
|
||||
|
||||
public WearableTooltipUI(VisualElement templateElement)
|
||||
{
|
||||
// Tooltip for this type
|
||||
_templateElement = templateElement.Q(null, "tooltip");
|
||||
|
||||
// Sections
|
||||
_titleSection = templateElement.Q("title-section");
|
||||
_detailsSection = templateElement.Q("details-section");
|
||||
_descriptionSection = templateElement.Q("description-section");
|
||||
_footSection = templateElement.Q("foot-section");
|
||||
|
||||
// Elements
|
||||
_wearableIcon.Init(templateElement.Q("wearable-icon"), SlotType.None, -1);
|
||||
_wearableName = templateElement.Q<Label>("wearable-name");
|
||||
_wearableQuality = templateElement.Q<Label>("wearable-quality");
|
||||
_wearableType = templateElement.Q<Label>("wearable-type");
|
||||
_wearableDescription = templateElement.Q<Label>("wearable-description");
|
||||
_wearableValue = templateElement.Q<Label>("wearable-value");
|
||||
_wearableWeight = templateElement.Q<Label>("wearable-weight");
|
||||
}
|
||||
|
||||
public void Show(WearableObject wearable)
|
||||
{
|
||||
_wearableIcon.Set(wearable);
|
||||
_templateElement.style.display = DisplayStyle.Flex;
|
||||
|
||||
FillBasicInfo(wearable);
|
||||
FillDetails(wearable);
|
||||
}
|
||||
|
||||
public void Hide()
|
||||
{
|
||||
_templateElement.style.display = DisplayStyle.None;
|
||||
}
|
||||
|
||||
public Vector2 GetSize()
|
||||
{
|
||||
return new Vector2(_templateElement.worldBound.width, _templateElement.worldBound.height);
|
||||
}
|
||||
|
||||
private void FillBasicInfo(WearableObject wearable)
|
||||
{
|
||||
_wearableName.text = wearable.basicData.finalName;
|
||||
_wearableQuality.text = wearable.itemData.quality.displayName;
|
||||
_wearableType.text = wearable.GetType().Name;
|
||||
_wearableDescription.text = wearable.basicData.description;
|
||||
_descriptionSection.style.display = _wearableDescription.text.IsNullOrWhitespace() ? DisplayStyle.None : DisplayStyle.Flex;
|
||||
_wearableValue.text = wearable.itemData.finalValue.ToString(CultureInfo.InvariantCulture);
|
||||
_wearableWeight.text = wearable.itemData.finalWeight.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
private void FillDetails(WearableObject wearable)
|
||||
{
|
||||
_detailsSection.Clear();
|
||||
|
||||
// All effects provided by wearable item
|
||||
var effects = wearable.wearableData.effects
|
||||
.Select(effect => effect.GetSimpleDescription())
|
||||
.ToArray();
|
||||
if (!effects.IsNullOrEmpty()) _details.Add(new DetailsElement(_detailsSection, null, effects));
|
||||
|
||||
_detailsSection.style.display = _detailsSection.childCount == 0 ? DisplayStyle.None : DisplayStyle.Flex;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc9eb08950bd4b95a268367e96b8c011
|
||||
timeCreated: 1691008134
|
||||
@@ -0,0 +1,36 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
engine="UnityEngine.UIElements" editor="UnityEditor.UIElements"
|
||||
noNamespaceSchemaLocation="../../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
||||
<ui:Template name="TooltipBackground" src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Tooltip/TooltipBackground.uxml?fileID=9197481963319205126&guid=547e49bedfdd22d459cd34398a254d83&type=3#TooltipBackground" />
|
||||
<ui:Template name="Slot" src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Utility/Slot.uxml?fileID=9197481963319205126&guid=5a74e2b56bbc27c4ab7a5d0c1de93f00&type=3#Slot" />
|
||||
<Style src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Tooltip/TooltipStyle.uss?fileID=7433441132597879392&guid=90349be0ccc48354eae60e7bc8cf5d07&type=3#TooltipStyle" />
|
||||
<Style src="project://database/Assets/92%20-%20UserInterface/Generic/Game/Utility/SlotOuter.uss?fileID=7433441132597879392&guid=760aa0b2431a11e46a81be0018d225b1&type=3#SlotOuter" />
|
||||
<ui:VisualElement name="wearable-tooltip" class="tooltip" style="background-color: rgba(100, 100, 100, 0.87);">
|
||||
<ui:Instance template="TooltipBackground" name="tooltip-background" />
|
||||
<ui:VisualElement class="tooltip-content">
|
||||
<ui:VisualElement name="title-section">
|
||||
<ui:VisualElement style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); flex-shrink: 0;">
|
||||
<ui:Label tabindex="-1" text="ITEM_NAME" display-tooltip-when-elided="true" name="wearable-name" style="margin-right: 2px; margin-top: 2px; padding-left: 2px; padding-right: 2px; padding-top: 2px; padding-bottom: 2px;" />
|
||||
<ui:VisualElement style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); flex-direction: row;">
|
||||
<ui:Label tabindex="-1" text="ITEM_QUALITY" display-tooltip-when-elided="true" name="wearable-quality" style="margin-right: 2px; margin-top: 2px; padding-left: 2px; padding-right: 2px; padding-top: 2px; padding-bottom: 2px; font-size: 12px;" />
|
||||
<ui:Label tabindex="-1" text="ITEM_TYPE" display-tooltip-when-elided="true" name="wearable-type" style="margin-right: 2px; margin-top: 2px; padding-left: 2px; padding-right: 2px; padding-top: 2px; padding-bottom: 2px; font-size: 12px;" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
<ui:Instance template="Slot" name="wearable-icon" class="slot slot-medium" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="details-section" class="section">
|
||||
<ui:VisualElement class="details-element">
|
||||
<ui:VisualElement class="details-icon" />
|
||||
<ui:Label tabindex="-1" text="place holder<br>ITEM_EFFECT_1<br>ITEM_EFFECT_2<br>ITEM_EFFECT_3" display-tooltip-when-elided="true" class="details-label" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="description-section" class="section">
|
||||
<ui:Label tabindex="-1" text="ITEM_DESCRIPTION" display-tooltip-when-elided="true" name="wearable-description" style="-unity-text-align: upper-left; white-space: normal; text-overflow: clip;" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="foot-section" class="section">
|
||||
<ui:Label tabindex="-1" text="ITEM_VALUE" display-tooltip-when-elided="true" name="wearable-value" />
|
||||
<ui:Label tabindex="-1" text="ITEM_WEIGHT" display-tooltip-when-elided="true" name="wearable-weight" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f886a4e210c1074ca6787dcbf9ecf2e
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
Reference in New Issue
Block a user