@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 951431146bbe5a84d933b96356015306
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -1,21 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59265260dbcad204286a1340a54e79bb
|
||||
IHVImageFormatImporter:
|
||||
externalObjects: {}
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
isReadable: 0
|
||||
sRGBTexture: 1
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
ignoreMipmapLimit: 0
|
||||
mipmapLimitGroupName:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c52f626a55d9f1d4b8cdaeae57cad2b1
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -198,25 +198,38 @@ namespace PerfectWorld.Scripts.Managers
|
||||
});
|
||||
}
|
||||
|
||||
private int FindEmptyInventorySlot()
|
||||
{
|
||||
// Determine inventory capacity from assigned buttons
|
||||
int capacity = inventoryPackButtons != null ? inventoryPackButtons.Count : 0;
|
||||
if (capacity <= 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
// Get current inventory items for package 0
|
||||
var invItems = model != null ? model.GetInventoryData(PKG_INVENTORY) : null;
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (invItems == null || !invItems.ContainsKey(i))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
private byte GetDefaultEquipLocation(int templateId)
|
||||
{
|
||||
// Basic equip location mapping based on template ID
|
||||
// Adjust these ranges based on your game's item system
|
||||
if (templateId >= 1000 && templateId < 2000) return 0; // Weapon
|
||||
if (templateId >= 2000 && templateId < 3000) return 2; // Armor
|
||||
if (templateId >= 3000 && templateId < 4000) return 3; // Accessory
|
||||
if (templateId >= 4000 && templateId < 5000) return 4; // Ring
|
||||
if (templateId >= 5000 && templateId < 6000) return 5; // Necklace
|
||||
|
||||
// Default to slot 1 if no specific mapping
|
||||
Debug.Log($"[InventoryUI] Using default equip location 1 for template {templateId}");
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int FindEmptyInventorySlot()
|
||||
{
|
||||
var inventoryData = model.GetInventoryData(PKG_INVENTORY);
|
||||
if (inventoryData == null) return -1;
|
||||
|
||||
// Find first empty slot (assuming slots are numbered 0, 1, 2, ...)
|
||||
for (int i = 0; i < 100; i++) // Assuming max 100 inventory slots
|
||||
{
|
||||
if (!inventoryData.ContainsKey(i))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Equipment indices and resolution helpers moved to EC_IvtrType
|
||||
|
||||
@@ -281,19 +294,17 @@ namespace PerfectWorld.Scripts.Managers
|
||||
var image = button.GetComponent<Image>();
|
||||
if (image != null)
|
||||
{
|
||||
if (hasItem && itemData != null)
|
||||
if (hasItem && itemData != null && itemData.State != 0)
|
||||
{
|
||||
// Set sprite based on icon atlas
|
||||
var sprite = IconAtlasProvider.GetSpriteForTemplateId(itemData.TemplateId);
|
||||
image.sprite = sprite;
|
||||
image.color = (itemData.State != 0) ? Color.yellow : Color.white;
|
||||
image.enabled = sprite != null;
|
||||
image.color = Color.yellow;
|
||||
}
|
||||
else if (!hasItem)
|
||||
{
|
||||
image.color = Color.white;
|
||||
}
|
||||
else
|
||||
{
|
||||
image.sprite = null;
|
||||
image.color = Color.white;
|
||||
image.enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,195 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using ModelRenderer.Scripts.Common;
|
||||
using UnityEngine;
|
||||
|
||||
namespace PerfectWorld.Scripts.Managers
|
||||
{
|
||||
public static class IconAtlasProvider
|
||||
{
|
||||
private const string IconsFolder = "UI/Icons"; // under Resources
|
||||
private const string IconListFileName = "iconlist_ivtrm"; // .txt
|
||||
private const string IconAtlasTexName = "iconlist_ivtrm"; // .dds
|
||||
|
||||
private static readonly Dictionary<string, Sprite> _iconNameToSprite = new Dictionary<string, Sprite>(StringComparer.OrdinalIgnoreCase);
|
||||
private static readonly Dictionary<int, string> _templateIdToIconName = new Dictionary<int, string>();
|
||||
|
||||
private static bool _initialized;
|
||||
private static Texture2D _atlasTexture;
|
||||
private static string _fallbackIconName = "unknown";
|
||||
|
||||
public static void EnsureInitialized()
|
||||
{
|
||||
if (_initialized) return;
|
||||
_initialized = true;
|
||||
try
|
||||
{
|
||||
LoadAtlasAndIcons();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"[IconAtlas] Failed to initialize: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public static Sprite GetSpriteByIconName(string iconName)
|
||||
{
|
||||
EnsureInitialized();
|
||||
if (string.IsNullOrEmpty(iconName)) return GetFallback();
|
||||
if (_iconNameToSprite.TryGetValue(iconName, out var sprite) && sprite != null) return sprite;
|
||||
iconName = Path.GetFileNameWithoutExtension(iconName);
|
||||
if (_iconNameToSprite.TryGetValue(iconName, out sprite) && sprite != null) return sprite;
|
||||
return GetFallback();
|
||||
}
|
||||
|
||||
public static Sprite GetSpriteForTemplateId(int templateId)
|
||||
{
|
||||
EnsureInitialized();
|
||||
if (templateId <= 0) return GetFallback();
|
||||
|
||||
if (_templateIdToIconName.TryGetValue(templateId, out var name))
|
||||
{
|
||||
var s = GetSpriteByIconName(name);
|
||||
if (s != null) return s;
|
||||
}
|
||||
|
||||
string guessed = GuessIconNameFromTemplateId(templateId);
|
||||
if (!string.IsNullOrEmpty(guessed))
|
||||
{
|
||||
_templateIdToIconName[templateId] = guessed;
|
||||
var s = GetSpriteByIconName(guessed);
|
||||
if (s != null) return s;
|
||||
}
|
||||
|
||||
return GetFallback();
|
||||
}
|
||||
|
||||
private static void LoadAtlasAndIcons()
|
||||
{
|
||||
_atlasTexture = Resources.Load<Texture2D>($"{IconsFolder}/{IconAtlasTexName}");
|
||||
if (_atlasTexture == null)
|
||||
{
|
||||
Debug.LogWarning($"[IconAtlas] Could not load atlas texture '{IconAtlasTexName}' from Resources/{IconsFolder}");
|
||||
return;
|
||||
}
|
||||
|
||||
var textAsset = Resources.Load<TextAsset>($"{IconsFolder}/{IconListFileName}");
|
||||
if (textAsset == null)
|
||||
{
|
||||
Debug.LogWarning($"[IconAtlas] Could not load icon list '{IconListFileName}.txt' from Resources/{IconsFolder}");
|
||||
return;
|
||||
}
|
||||
|
||||
ParseIconListAndCreateSprites(textAsset.bytes, _atlasTexture);
|
||||
}
|
||||
|
||||
private static void ParseIconListAndCreateSprites(byte[] rawBytes, Texture2D atlas)
|
||||
{
|
||||
if (rawBytes == null || rawBytes.Length == 0 || atlas == null) return;
|
||||
|
||||
string fullText = ByteToStringUtils.ByteArrayToCP936String(rawBytes);
|
||||
if (string.IsNullOrEmpty(fullText))
|
||||
{
|
||||
fullText = Encoding.UTF8.GetString(rawBytes);
|
||||
}
|
||||
|
||||
var lines = fullText.Replace("\r\n", "\n").Replace("\r", "\n").Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (lines.Length < 4)
|
||||
{
|
||||
Debug.LogWarning("[IconAtlas] icon list too short");
|
||||
return;
|
||||
}
|
||||
|
||||
int tileWidth = SafeParseInt(lines[0]);
|
||||
int tileHeight = SafeParseInt(lines[1]);
|
||||
int columns = SafeParseInt(lines[2]);
|
||||
int count = SafeParseInt(lines[3]);
|
||||
|
||||
if (tileWidth <= 0 || tileHeight <= 0 || columns <= 0)
|
||||
{
|
||||
Debug.LogWarning($"[IconAtlas] Invalid header: w={tileWidth} h={tileHeight} cols={columns} count={count}");
|
||||
return;
|
||||
}
|
||||
|
||||
int created = 0;
|
||||
for (int i = 4; i < lines.Length; i++)
|
||||
{
|
||||
string fileName = lines[i].Trim();
|
||||
if (string.IsNullOrEmpty(fileName)) continue;
|
||||
|
||||
string nameNoExt = Path.GetFileNameWithoutExtension(fileName);
|
||||
|
||||
int index = i - 4;
|
||||
int col = index % columns;
|
||||
int row = index / columns;
|
||||
|
||||
int x = col * tileWidth;
|
||||
int y = atlas.height - ((row + 1) * tileHeight);
|
||||
if (y < 0) y = 0;
|
||||
|
||||
var rect = new Rect(x, y, tileWidth, tileHeight);
|
||||
var pivot = new Vector2(0.5f, 0.5f);
|
||||
|
||||
try
|
||||
{
|
||||
var sprite = Sprite.Create(atlas, rect, pivot, 100.0f, 0, SpriteMeshType.FullRect);
|
||||
_iconNameToSprite[nameNoExt] = sprite;
|
||||
|
||||
int tidPrefix = ExtractLeadingInt(nameNoExt);
|
||||
if (tidPrefix > 0 && !_templateIdToIconName.ContainsKey(tidPrefix))
|
||||
{
|
||||
_templateIdToIconName[tidPrefix] = nameNoExt;
|
||||
}
|
||||
|
||||
if (string.Equals(nameNoExt, "unknown", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_fallbackIconName = nameNoExt;
|
||||
}
|
||||
|
||||
created++;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"[IconAtlas] Failed to create sprite for '{fileName}': {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log($"[IconAtlas] Loaded {created} sprites from atlas '{IconAtlasTexName}' ({atlas.width}x{atlas.height}), tile {tileWidth}x{tileHeight}, cols {columns}, listed {count}");
|
||||
}
|
||||
|
||||
private static Sprite GetFallback()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_fallbackIconName)) return null;
|
||||
_iconNameToSprite.TryGetValue(_fallbackIconName, out var s);
|
||||
return s;
|
||||
}
|
||||
|
||||
private static int SafeParseInt(string s)
|
||||
{
|
||||
if (string.IsNullOrEmpty(s)) return 0;
|
||||
if (int.TryParse(s.Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out var v)) return v;
|
||||
if (int.TryParse(s.Trim(), out v)) return v;
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static int ExtractLeadingInt(string s)
|
||||
{
|
||||
if (string.IsNullOrEmpty(s)) return 0;
|
||||
int i = 0;
|
||||
while (i < s.Length && char.IsDigit(s[i])) i++;
|
||||
if (i == 0) return 0;
|
||||
if (int.TryParse(s.Substring(0, i), NumberStyles.Integer, CultureInfo.InvariantCulture, out var v)) return v;
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static string GuessIconNameFromTemplateId(int templateId)
|
||||
{
|
||||
string tidStr = templateId.ToString(CultureInfo.InvariantCulture);
|
||||
return _iconNameToSprite.Keys.FirstOrDefault(k => k.StartsWith(tidStr, StringComparison.Ordinal));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c2229016f304bb948a31d9c82cb2d9d0
|
||||
@@ -36,8 +36,10 @@ GraphicsSettings:
|
||||
- {fileID: 10783, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_PreloadedShaders: []
|
||||
m_PreloadShadersBatchTimeLimit: -1
|
||||
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_CustomRenderPipeline: {fileID: 11400000, guid: 4b83569d67af61e458304325a23e5dfd, type: 2}
|
||||
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
|
||||
type: 0}
|
||||
m_CustomRenderPipeline: {fileID: 11400000, guid: 4b83569d67af61e458304325a23e5dfd,
|
||||
type: 2}
|
||||
m_TransparencySortMode: 0
|
||||
m_TransparencySortAxis: {x: 0, y: 0, z: 1}
|
||||
m_DefaultRenderingPath: 1
|
||||
@@ -58,8 +60,9 @@ GraphicsSettings:
|
||||
m_FogKeepExp2: 1
|
||||
m_AlbedoSwatchInfos: []
|
||||
m_RenderPipelineGlobalSettingsMap:
|
||||
UnityEngine.Rendering.Universal.UniversalRenderPipeline: {fileID: 11400000, guid: 18dc0cd2c080841dea60987a38ce93fa, type: 2}
|
||||
m_LightsUseLinearIntensity: 0
|
||||
UnityEngine.Rendering.Universal.UniversalRenderPipeline: {fileID: 11400000, guid: 18dc0cd2c080841dea60987a38ce93fa,
|
||||
type: 2}
|
||||
m_LightsUseLinearIntensity: 1
|
||||
m_LightsUseColorTemperature: 1
|
||||
m_LogWhenShaderIsCompiled: 0
|
||||
m_LightProbeOutsideHullStrategy: 0
|
||||
|
||||
Reference in New Issue
Block a user