diff --git a/l2-unity/Assets/Scenes/Menu.unity b/l2-unity/Assets/Scenes/Menu.unity index 308095fc1..9daf233ef 100644 --- a/l2-unity/Assets/Scenes/Menu.unity +++ b/l2-unity/Assets/Scenes/Menu.unity @@ -23,7 +23,7 @@ RenderSettings: m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} - m_AmbientIntensity: 0.2 + m_AmbientIntensity: 0.6 m_AmbientMode: 0 m_SubtractiveShadowColor: {r: 0, g: 0, b: 0, a: 1} m_SkyboxMaterial: {fileID: 2100000, guid: 74e09fc0417b6f94c95b3a55ae362ec9, type: 2} @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 0.245 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 1061591418} - m_IndirectSpecularColor: {r: 0.009567419, g: 0.010123216, b: 0.010156483, a: 0.245} + m_IndirectSpecularColor: {r: 0.029895507, g: 0.06798504, b: 0.08975239, a: 0.245} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -182,7 +182,7 @@ PrefabInstance: m_Modifications: - target: {fileID: 842763773635486120, guid: 2bc6245aea0342f4f8c76719bfe12012, type: 3} propertyPath: _autoLogin - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 4644061901774829026, guid: 2bc6245aea0342f4f8c76719bfe12012, type: 3} propertyPath: m_LocalPosition.x @@ -253,41 +253,6 @@ PrefabInstance: m_AddedGameObjects: [] m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 2bc6245aea0342f4f8c76719bfe12012, type: 3} ---- !u!21 &493864232 -Material: - serializedVersion: 8 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: Height Fog Global - m_Shader: {fileID: 4800000, guid: 3a7ef1b66bafb7a448a880ef76d2e6e6, type: 3} - m_Parent: {fileID: 0} - m_ModifiedSerializedProperties: 0 - m_ValidKeywords: [] - m_InvalidKeywords: [] - m_LightmapFlags: 4 - m_EnableInstancingVariants: 0 - m_DoubleSidedGI: 0 - m_CustomRenderQueue: 3000 - stringTagMap: {} - disabledShaderPasses: [] - m_LockedProperties: - m_SavedProperties: - serializedVersion: 3 - m_TexEnvs: [] - m_Ints: [] - m_Floats: - - _AdvancedCat: 1 - - _Banner: 1 - - _DirectionalCat: 1 - - _FogCat: 1 - - _HeightFogGlobal: 1 - - _IsHeightFogShader: 1 - - _NoiseCat: 1 - - _SkyboxCat: 1 - m_Colors: [] - m_BuildTextureStacks: [] --- !u!1 &803395386 GameObject: m_ObjectHideFlags: 0 @@ -600,6 +565,41 @@ PrefabInstance: m_AddedGameObjects: [] m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 824ee6870a432f9439e35ee4e771a1f5, type: 3} +--- !u!21 &1041848965 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Height Fog Global + m_Shader: {fileID: 4800000, guid: 3a7ef1b66bafb7a448a880ef76d2e6e6, type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: 3000 + stringTagMap: {} + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: [] + m_Ints: [] + m_Floats: + - _AdvancedCat: 1 + - _Banner: 1 + - _DirectionalCat: 1 + - _FogCat: 1 + - _HeightFogGlobal: 1 + - _IsHeightFogShader: 1 + - _NoiseCat: 1 + - _SkyboxCat: 1 + m_Colors: [] + m_BuildTextureStacks: [] --- !u!108 &1061591418 stripped Light: m_CorrespondingSourceObject: {fileID: 4181994143891002370, guid: 824ee6870a432f9439e35ee4e771a1f5, type: 3} @@ -662,41 +662,6 @@ PrefabInstance: m_AddedGameObjects: [] m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: de4c4ef119bfe89408906f06fbd31d49, type: 3} ---- !u!21 &1136183139 -Material: - serializedVersion: 8 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: Height Fog Global - m_Shader: {fileID: 4800000, guid: 3a7ef1b66bafb7a448a880ef76d2e6e6, type: 3} - m_Parent: {fileID: 0} - m_ModifiedSerializedProperties: 0 - m_ValidKeywords: [] - m_InvalidKeywords: [] - m_LightmapFlags: 4 - m_EnableInstancingVariants: 0 - m_DoubleSidedGI: 0 - m_CustomRenderQueue: 3000 - stringTagMap: {} - disabledShaderPasses: [] - m_LockedProperties: - m_SavedProperties: - serializedVersion: 3 - m_TexEnvs: [] - m_Ints: [] - m_Floats: - - _AdvancedCat: 1 - - _Banner: 1 - - _DirectionalCat: 1 - - _FogCat: 1 - - _HeightFogGlobal: 1 - - _IsHeightFogShader: 1 - - _NoiseCat: 1 - - _SkyboxCat: 1 - m_Colors: [] - m_BuildTextureStacks: [] --- !u!1001 &1147827734 PrefabInstance: m_ObjectHideFlags: 0 @@ -712,7 +677,7 @@ PrefabInstance: - target: {fileID: 14083907825353274, guid: 8742fc349ac4f354d9cfb98ebb79a0e3, type: 3} propertyPath: m_Materials.Array.data[0] value: - objectReference: {fileID: 493864232} + objectReference: {fileID: 1041848965} - target: {fileID: 2134954596300280144, guid: 8742fc349ac4f354d9cfb98ebb79a0e3, type: 3} propertyPath: m_Name value: Height Fog Global @@ -1071,7 +1036,7 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!21 &2048170547 +--- !u!21 &1615823495 Material: serializedVersion: 8 m_ObjectHideFlags: 0 diff --git a/l2-unity/Assets/Scripts/Database/ItemTable.cs b/l2-unity/Assets/Scripts/Database/ItemTable.cs index 43628bdfd..b40a8ab47 100644 --- a/l2-unity/Assets/Scripts/Database/ItemTable.cs +++ b/l2-unity/Assets/Scripts/Database/ItemTable.cs @@ -146,4 +146,18 @@ public EtcItem GetEtcItem(int id) { return item; } + + public AbstractItem GetItem(int id) { + if(_weapons.TryGetValue(id, out Weapon weapon)) { + return weapon; + } + if(_armors.TryGetValue(id, out Armor armor)) { + return armor; + } + if(_etcItems.TryGetValue(id, out EtcItem etcItem)) { + return etcItem; + } + + return null; + } } diff --git a/l2-unity/Assets/Scripts/Game/Item/PlayerInventory.cs b/l2-unity/Assets/Scripts/Game/Item/PlayerInventory.cs index 6527eb1f9..63644ee02 100644 --- a/l2-unity/Assets/Scripts/Game/Item/PlayerInventory.cs +++ b/l2-unity/Assets/Scripts/Game/Item/PlayerInventory.cs @@ -23,8 +23,6 @@ private void Awake() { Destroy(this); } - Debug.LogWarning("Init PlayerInventory"); - _playerInventory = new List(); } @@ -49,7 +47,6 @@ public void SetInventory(ItemInstance[] items, bool openInventory) { public void UpdateInventory(ItemInstance[] items) { for(int i = 0; i < items.Length; i++) { ItemInstance item = items[i]; - Debug.Log(item.ToString()); if(item.LastChange == (int) InventoryChange.ADDED) { _playerInventory.Add(item); } else if (item.LastChange == (int) InventoryChange.MODIFIED) { diff --git a/l2-unity/Assets/Scripts/UI/Game/Chat/ChatTab.cs b/l2-unity/Assets/Scripts/UI/Game/Chat/ChatTab.cs index b366638ae..8aee61449 100644 --- a/l2-unity/Assets/Scripts/UI/Game/Chat/ChatTab.cs +++ b/l2-unity/Assets/Scripts/UI/Game/Chat/ChatTab.cs @@ -5,7 +5,6 @@ [System.Serializable] public class ChatTab : L2Tab { - private Label _content; public Label Content { get { return _content; } } @@ -26,12 +25,19 @@ protected override void OnSwitchTab() { AudioManager.Instance.PlayUISound("window_open"); } } + + public void AddMessage(string message) { + ConcatMessage(message.ToString()); + } + + private void ConcatMessage(string message) { + if(_content.text.Length > 0) { + _content.text += "\r\n"; + } + _content.text += message; - protected override void RegisterAutoScrollEvent() { - _content.RegisterValueChangedCallback(evt => { - if(_autoscroll) { - ChatWindow.Instance.ScrollDown(_scroller); - } - }); + if(_autoscroll) { + ChatWindow.Instance.ScrollDown(_scroller); + } } } diff --git a/l2-unity/Assets/Scripts/UI/Game/Chat/ChatWindow.cs b/l2-unity/Assets/Scripts/UI/Game/Chat/ChatWindow.cs index 6838005c2..8553dce34 100644 --- a/l2-unity/Assets/Scripts/UI/Game/Chat/ChatWindow.cs +++ b/l2-unity/Assets/Scripts/UI/Game/Chat/ChatWindow.cs @@ -225,7 +225,7 @@ public void ReceiveChatMessage(ChatMessage message) { // ConcatMessage(_tabs[i].Content, message.ToString()); // } //} - ConcatMessage(_tabs[i].Content, message.ToString()); + _tabs[i].AddMessage(message.ToString()); } } @@ -240,17 +240,10 @@ public void ReceiveSystemMessage(SystemMessage message) { // ConcatMessage(_tabs[i].Content, message.ToString()); // } //} - ConcatMessage(_tabs[i].Content, message.ToString()); + _tabs[i].AddMessage(message.ToString()); } } - private void ConcatMessage(Label chatContent, string message) { - if(chatContent.text.Length > 0) { - chatContent.text += "\r\n"; - } - chatContent.text += message; - } - internal void ScrollDown(Scroller scroller) { StartCoroutine(ScrollDownWithDelay(scroller)); } diff --git a/l2-unity/Assets/Scripts/UI/Game/Chat/MessageTypes/SystemMessage.cs b/l2-unity/Assets/Scripts/UI/Game/Chat/MessageTypes/SystemMessage.cs index 573b1b026..62a0c4de8 100644 --- a/l2-unity/Assets/Scripts/UI/Game/Chat/MessageTypes/SystemMessage.cs +++ b/l2-unity/Assets/Scripts/UI/Game/Chat/MessageTypes/SystemMessage.cs @@ -31,6 +31,13 @@ public override string ToString() { value = value.Replace($"$s{i}", param.GetLongValue().ToString()); break; case SMParamType.TYPE_ITEM_NAME: + AbstractItem item = ItemTable.Instance.GetItem(param.GetIntValue()); + string itemName = "Unknown"; + if(item != null) { + itemName = item.ItemName.Name; + } + value = value.Replace($"$s{i}", itemName); + break; case SMParamType.TYPE_CASTLE_NAME: case SMParamType.TYPE_INT_NUMBER: case SMParamType.TYPE_NPC_NAME: diff --git a/l2-unity/Assets/Scripts/UI/Game/Inventory/GearSlot.cs b/l2-unity/Assets/Scripts/UI/Game/Inventory/GearSlot.cs index 7c7306347..221f197cc 100644 --- a/l2-unity/Assets/Scripts/UI/Game/Inventory/GearSlot.cs +++ b/l2-unity/Assets/Scripts/UI/Game/Inventory/GearSlot.cs @@ -9,6 +9,8 @@ public GearSlot(int position, VisualElement slotElement, InventoryGearTab tab) : } protected override void HandleRightClick() { - GameClient.Instance.ClientPacketHandler.UnEquipItem(_position); + if(!_empty) { + GameClient.Instance.ClientPacketHandler.UnEquipItem(_position); + } } } diff --git a/l2-unity/Assets/Scripts/UI/Game/Inventory/InventoryGearTab.cs b/l2-unity/Assets/Scripts/UI/Game/Inventory/InventoryGearTab.cs index 70c149022..9346eeaa9 100644 --- a/l2-unity/Assets/Scripts/UI/Game/Inventory/InventoryGearTab.cs +++ b/l2-unity/Assets/Scripts/UI/Game/Inventory/InventoryGearTab.cs @@ -42,7 +42,20 @@ public override void Initialize(VisualElement chatWindowEle, VisualElement tabCo public void UpdateItemList(List items) { Debug.Log("Update gear slots"); + + // Clean up slot callbacks and manipulators + if(_gearSlots != null) { + foreach (KeyValuePair kvp in _gearSlots) { + if (kvp.Value != null) { + kvp.Value.UnregisterCallbacks(); + kvp.Value.ClearSlot(); + } + } + _gearSlots.Clear(); + } _gearSlots = new Dictionary(); + + // Clean up gear anchors from any child visual element foreach (KeyValuePair kvp in _gearAnchors) { if (kvp.Value == null) { Debug.LogWarning($"Inventory gear slot {kvp.Key} is null."); diff --git a/l2-unity/Assets/Scripts/UI/Game/Inventory/InventorySlot.cs b/l2-unity/Assets/Scripts/UI/Game/Inventory/InventorySlot.cs index 52825f912..2fb970d2f 100644 --- a/l2-unity/Assets/Scripts/UI/Game/Inventory/InventorySlot.cs +++ b/l2-unity/Assets/Scripts/UI/Game/Inventory/InventorySlot.cs @@ -10,6 +10,7 @@ public class InventorySlot : L2Slot private long _remainingTime; private TooltipManipulator _tooltipManipulator; private int _objectId; + protected bool _empty = true; public int Count { get { return _count; } } public long RemainingTime { get { return _remainingTime; } } @@ -18,6 +19,7 @@ public InventorySlot(int position, VisualElement slotElement, L2Tab tab) : base(slotElement, position) { _currentTab = tab; _slotElement.AddToClassList("inventory-slot"); + _empty = true; } public void AssignItem(ItemInstance item) { @@ -27,6 +29,7 @@ public void AssignItem(ItemInstance item) { _description = item.ItemData.ItemName.Description; _icon = item.ItemData.Icon; _objectId = item.ObjectId; + _empty = false; } else { Debug.LogWarning($"Item data is null for item {item.ItemId}."); _id = 0; @@ -35,17 +38,24 @@ public void AssignItem(ItemInstance item) { _icon = ""; _objectId = -1; } + _count = item.Count; _remainingTime = item.RemainingTime; StyleBackground background = new StyleBackground(IconManager.Instance.GetIcon(_id)); _slotBg.style.backgroundImage = background; + AddTooltip(item); + } + + private void AddTooltip(ItemInstance item) { string tooltipText = $"{_name} ({_count})"; - if(item.Category == ItemCategory.Weapon || item.Category == ItemCategory.Jewel || item.Category == ItemCategory.ShieldArmor) { + if(item.Category == ItemCategory.Weapon || + item.Category == ItemCategory.Jewel || + item.Category == ItemCategory.ShieldArmor) { tooltipText = _name; } - + if(_tooltipManipulator == null) { _tooltipManipulator = new TooltipManipulator(_slotElement, tooltipText); _slotElement.AddManipulator(_tooltipManipulator); @@ -54,13 +64,23 @@ public void AssignItem(ItemInstance item) { } } + public void ClearSlot() { + if(_tooltipManipulator != null) { + _tooltipManipulator.Clear(); + _slotElement.RemoveManipulator(_tooltipManipulator); + _tooltipManipulator = null; + } + } + protected override void HandleLeftClick() { AudioManager.Instance.PlayUISound("click_03"); _currentTab.SelectSlot(_position); } protected override void HandleRightClick() { - GameClient.Instance.ClientPacketHandler.UseItem(_objectId); + if(!_empty) { + GameClient.Instance.ClientPacketHandler.UseItem(_objectId); + } } public void SetSelected() { diff --git a/l2-unity/Assets/Scripts/UI/Game/Inventory/InventoryTab.cs b/l2-unity/Assets/Scripts/UI/Game/Inventory/InventoryTab.cs index 0aa5acf2b..2566e7506 100644 --- a/l2-unity/Assets/Scripts/UI/Game/Inventory/InventoryTab.cs +++ b/l2-unity/Assets/Scripts/UI/Game/Inventory/InventoryTab.cs @@ -21,6 +21,12 @@ public override void Initialize(VisualElement chatWindowEle, VisualElement tabCo public void UpdateItemList(List items) { // Clear slots + if(_inventorySlots != null) { + foreach(InventorySlot slot in _inventorySlots) { + slot.ClearSlot(); + } + } + _contentContainer.Clear(); _itemCount = 0; diff --git a/l2-unity/Assets/Scripts/UI/L2Slot.cs b/l2-unity/Assets/Scripts/UI/L2Slot.cs index cf117611c..79bda89b9 100644 --- a/l2-unity/Assets/Scripts/UI/L2Slot.cs +++ b/l2-unity/Assets/Scripts/UI/L2Slot.cs @@ -52,7 +52,7 @@ protected void RegisterCallbacks() { _slotElement.RegisterCallback(HandleSlotClick, TrickleDown.TrickleDown); } - protected void UnregisterCallbacks() { + public void UnregisterCallbacks() { _slotElement.UnregisterCallback(HandleSlotClick, TrickleDown.TrickleDown); } diff --git a/l2-unity/Assets/Scripts/UI/L2Tab.cs b/l2-unity/Assets/Scripts/UI/L2Tab.cs index 75ab100e3..f8d8f325e 100644 --- a/l2-unity/Assets/Scripts/UI/L2Tab.cs +++ b/l2-unity/Assets/Scripts/UI/L2Tab.cs @@ -6,7 +6,7 @@ [System.Serializable] public abstract class L2Tab { [SerializeField] string _tabName = "Tab"; - protected bool _autoscroll = true; + [SerializeField] protected bool _autoscroll = true; private ScrollView _scrollView; protected Scroller _scroller; private VisualElement _tabContainer; diff --git a/l2-unity/Assets/Scripts/UI/Manipulators/TooltipManipulator.cs b/l2-unity/Assets/Scripts/UI/Manipulators/TooltipManipulator.cs index fb2a9e633..af5dc3630 100644 --- a/l2-unity/Assets/Scripts/UI/Manipulators/TooltipManipulator.cs +++ b/l2-unity/Assets/Scripts/UI/Manipulators/TooltipManipulator.cs @@ -6,6 +6,7 @@ public class TooltipManipulator : PointerManipulator { private string _text; + private bool _pointerOver; public TooltipManipulator(VisualElement target, string text) { this.target = target; @@ -29,13 +30,21 @@ private void PointerInHandler(PointerEnterEvent evt) { } private void PointerOverHandler(MouseOverEvent evt) { + _pointerOver = true; } private void PointerOutHandler(PointerOutEvent evt) { + _pointerOver = false; L2ToolTip.Instance.HideWindow(target); } public void SetText(string text) { _text = text; } + + public void Clear() { + if(_pointerOver) { + L2ToolTip.Instance.HideWindow(target); + } + } }