Skip to content

Commit

Permalink
skillbar keybind icons
Browse files Browse the repository at this point in the history
  • Loading branch information
shnok committed Aug 31, 2024
1 parent 9a19344 commit d37b81f
Show file tree
Hide file tree
Showing 27 changed files with 205 additions and 150 deletions.
15 changes: 15 additions & 0 deletions l2-unity/Assets/Resources/Data/UI/_Elements/L2StyleSheet.uss
Original file line number Diff line number Diff line change
Expand Up @@ -1819,6 +1819,21 @@
background-image: none;
}

.shortcut-key {
flex-grow: 1;
position: absolute;
height: 16px;
width: 32px;
top: 2px;
left: 2px;
flex-direction: row;
-unity-background-scale-mode: scale-to-fit;
}

.skillbar-slot.empty .shortcut-key {
display: none;
}

.action-slot.empty .slot-bg-container {
border-width: 0;
padding: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<ui:Button name="slot" class="l2-slot skillbar-slot empty">
<ui:VisualElement name="BgContainer" picking-mode="Ignore" class="slot-bg-container">
<ui:VisualElement name="SlotBg" picking-mode="Ignore" class="slot-bg" style="background-color: rgba(0, 0, 0, 0.05); border-left-color: rgba(0, 0, 0, 0.65); border-right-color: rgba(0, 0, 0, 0.65); border-top-color: rgba(0, 0, 0, 0.65); border-bottom-color: rgba(0, 0, 0, 0.65);" />
<ui:VisualElement name="Key" class="shortcut-key" />
</ui:VisualElement>
</ui:Button>
</ui:UXML>
165 changes: 58 additions & 107 deletions l2-unity/Assets/Resources/Scenes/Tests/Test.unity
Original file line number Diff line number Diff line change
Expand Up @@ -225,65 +225,21 @@ GameObject:
m_Component:
- component: {fileID: 149149314}
- component: {fileID: 149149313}
- component: {fileID: 149149312}
- component: {fileID: 149149315}
- component: {fileID: 149149316}
- component: {fileID: 149149317}
- component: {fileID: 149149318}
- component: {fileID: 149149319}
- component: {fileID: 149149320}
- component: {fileID: 149149321}
- component: {fileID: 149149322}
- component: {fileID: 149149326}
- component: {fileID: 149149325}
- component: {fileID: 149149324}
- component: {fileID: 149149323}
- component: {fileID: 149149326}
- component: {fileID: 149149327}
m_Layer: 0
m_Name: UI
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &149149312
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 149149311}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4ecd1a0a0495f174fb7ecee096229e89, type: 3}
m_Name:
m_EditorClassIdentifier:
_expanded: 0
_gearTab:
_tabName: Tab
_autoscroll: 1
_selectedSlot: -1
_tabs:
- _tabName: All
_autoscroll: 1
_selectedSlot: -1
_filteredCategories:
- _tabName: Equip
_autoscroll: 1
_selectedSlot: -1
_filteredCategories: 000102
- _tabName: Supplies
_autoscroll: 1
_selectedSlot: -1
_filteredCategories: 0504
- _tabName: Quest
_autoscroll: 1
_selectedSlot: -1
_filteredCategories: 03
_usedSlots: 0
_slotCount: 0
_currentWeight: 0
_maximumWeight: 0
_adenaCount: 0
--- !u!114 &149149313
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -379,49 +335,6 @@ MonoBehaviour:
m_EditorClassIdentifier:
_defaultSkillbarCount: 2
_expandedSkillbarCount: 0
--- !u!114 &149149319
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 149149311}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 14bf3f2dcfcbba64aade5b0f3ee646a6, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &149149320
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 149149311}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 90c3fb83fa7e05d4e85e87bffbb0b9f4, type: 3}
m_Name:
m_EditorClassIdentifier:
_chatWindowMinWidth: 225
_chatWindowMaxWidth: 500
_chatWindowMinHeight: 175
_chatWindowMaxHeight: 600
_tabs: []
_chatOpened: 0
_chatInputCharacterLimit: 64
--- !u!114 &149149321
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 149149311}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a74cdee76f988fd4aa5bfa3027894c59, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &149149322
MonoBehaviour:
m_ObjectHideFlags: 0
Expand All @@ -434,7 +347,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 2b9275d71bba04749bfde79eeea369f8, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &149149323
--- !u!114 &149149325
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
Expand All @@ -443,10 +356,10 @@ MonoBehaviour:
m_GameObject: {fileID: 149149311}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b94893c878af06c4c9a304dab137ef13, type: 3}
m_Script: {fileID: 11500000, guid: 675288a14a68dc54f875a1c7aa89c846, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &149149324
--- !u!114 &149149326
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
Expand All @@ -455,22 +368,19 @@ MonoBehaviour:
m_GameObject: {fileID: 149149311}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2b9275d71bba04749bfde79eeea369f8, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &149149325
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 149149311}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 675288a14a68dc54f875a1c7aa89c846, type: 3}
m_Script: {fileID: 11500000, guid: 90c3fb83fa7e05d4e85e87bffbb0b9f4, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &149149326
_chatWindowMinWidth: 225
_chatWindowMaxWidth: 500
_chatWindowMinHeight: 175
_chatWindowMaxHeight: 600
_tabs:
- _tabName: All
_autoscroll: 1
_chatOpened: 0
_chatInputCharacterLimit: 64
--- !u!114 &149149327
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
Expand All @@ -479,9 +389,24 @@ MonoBehaviour:
m_GameObject: {fileID: 149149311}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9777a5511b4fe9c439f8b3f3c927ad6c, type: 3}
m_Script: {fileID: 11500000, guid: 4ecd1a0a0495f174fb7ecee096229e89, type: 3}
m_Name:
m_EditorClassIdentifier:
_expanded: 0
_gearTab:
_tabName: Tab
_autoscroll: 1
_selectedSlot: -1
_tabs:
- _tabName: All
_autoscroll: 0
_selectedSlot: 0
_filteredCategories:
_usedSlots: 0
_slotCount: 0
_currentWeight: 0
_maximumWeight: 0
_adenaCount: 0
--- !u!1001 &445805727
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -688,6 +613,8 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 742913640}
- component: {fileID: 742913643}
- component: {fileID: 742913642}
m_Layer: 0
m_Name: Game
m_TagString: Untagged
Expand All @@ -710,6 +637,30 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &742913642
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 742913639}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a74cdee76f988fd4aa5bfa3027894c59, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &742913643
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 742913639}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 14bf3f2dcfcbba64aade5b0f3ee646a6, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &813744334
GameObject:
m_ObjectHideFlags: 0
Expand Down
13 changes: 8 additions & 5 deletions l2-unity/Assets/Scripts/Database/IconManager.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
using System.Collections.Generic;
using UnityEngine;

public class IconManager
public class IconTable
{
private string _iconFolder = "Data\\SysTextures\\Icon";

private Texture2D _noImageIcon;

private Dictionary<int, Texture2D> _icons = new Dictionary<int, Texture2D>();
private Dictionary<string, Texture2D> _keyIcons = new Dictionary<string, Texture2D>();

private static IconManager _instance;
public static IconManager Instance
private static IconTable _instance;
public static IconTable Instance
{
get
{
if (_instance == null)
{
_instance = new IconManager();
_instance = new IconTable();
}

return _instance;
Expand All @@ -26,9 +27,11 @@ public static IconManager Instance
public void Initialize()
{
_noImageIcon = GetNoImageIcon();

CacheIcons();
}

public void CacheIcons()
private void CacheIcons()
{
foreach (Weapon weapon in ItemTable.Instance.Weapons.Values)
{
Expand Down
46 changes: 46 additions & 0 deletions l2-unity/Assets/Scripts/Database/KeyImageTable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System.Collections.Generic;
using UnityEngine;

public class KeyImageTable
{
private string _iconFolder = "Data\\UI\\Assets\\SkillBar\\Shortcuts";
private Dictionary<string, Texture2D> _keyImages = new Dictionary<string, Texture2D>();

private static KeyImageTable _instance;
public static KeyImageTable Instance
{
get
{
if (_instance == null)
{
_instance = new KeyImageTable();
}

return _instance;
}
}

public void Initialize() {
_keyImages = new Dictionary<string, Texture2D>();
}

public Texture2D LoadTextureByKey(string name)
{
if(_keyImages.TryGetValue(name, out Texture2D result)) {
return result;
}

string icon = _iconFolder + "\\ShortcutWnd_DF_Key_" + name;
result = Resources.Load<Texture2D>(icon);

if (result != null)
{
_keyImages.Add(name, result);
return result;
}

Debug.LogWarning($"Missing icon: {name}.");

return null;
}
}
2 changes: 2 additions & 0 deletions l2-unity/Assets/Scripts/Database/KeyImageTable.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions l2-unity/Assets/Scripts/Game/Manager/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,15 @@ void Awake()
Destroy(this);
}

_loadingCamera = GameObject.Find("LoadingCamera").GetComponent<Camera>();
if (_loadingCamera == null)
GameObject camObject = GameObject.Find("LoadingCamera");
if (camObject == null)
{
Debug.LogError("Can't find loading camera");
return;
}

camObject.TryGetComponent(out _loadingCamera);

StartLoading();
}

Expand Down Expand Up @@ -81,8 +84,8 @@ private void LoadTables()
ModelTable.Instance.Initialize();
LogongrpTable.Instance.Initialize();
SystemMessageTable.Instance.Initialize();
IconManager.Instance.Initialize();
IconManager.Instance.CacheIcons();
IconTable.Instance.Initialize();
KeyImageTable.Instance.Initialize();
}

public void LogIn()
Expand Down
Loading

0 comments on commit d37b81f

Please sign in to comment.