notebook实装功能,galgame继续,一些bug修复
This commit is contained in:
@@ -146,7 +146,7 @@ MonoBehaviour:
|
||||
m_Calls: []
|
||||
m_FontData:
|
||||
m_Font: {fileID: 12800000, guid: cc180dff846d13a4d88ddaed6f77e5cd, type: 3}
|
||||
m_FontSize: 18
|
||||
m_FontSize: 21
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 0
|
||||
m_MinSize: 1
|
||||
@@ -271,7 +271,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 8.26, y: -19.259}
|
||||
m_AnchoredPosition: {x: 8.26, y: -21.82}
|
||||
m_SizeDelta: {x: 513.73, y: 217.76}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &6335537327971292952
|
||||
@@ -304,7 +304,7 @@ MonoBehaviour:
|
||||
m_Calls: []
|
||||
m_FontData:
|
||||
m_Font: {fileID: 12800000, guid: bd4be44636ad6c24a9b117a7108a75e9, type: 3}
|
||||
m_FontSize: 13
|
||||
m_FontSize: 15
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 0
|
||||
m_MinSize: 0
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Linq;
|
||||
|
||||
public class loadDetailsPrefab : MonoBehaviour
|
||||
{
|
||||
@@ -37,7 +39,7 @@ public class loadDetailsPrefab : MonoBehaviour
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
public void ShowDetails(string type, string name, string status, string description, Vector3 position)
|
||||
public void ShowDetails(string type, string name, string status, string description, Vector3 position, int heroLevel = 0)
|
||||
{
|
||||
HideDetails();
|
||||
|
||||
@@ -45,10 +47,10 @@ public class loadDetailsPrefab : MonoBehaviour
|
||||
|
||||
isAbove = (type == "技能"); // Documentation text normalized.
|
||||
|
||||
showCoroutine = StartCoroutine(ShowDetailsDelayed(type, name, status, description, position));
|
||||
showCoroutine = StartCoroutine(ShowDetailsDelayed(type, name, status, description, position, heroLevel));
|
||||
}
|
||||
|
||||
private System.Collections.IEnumerator ShowDetailsDelayed(string type, string name, string status, string description, Vector3 position)
|
||||
private System.Collections.IEnumerator ShowDetailsDelayed(string type, string name, string status, string description, Vector3 position, int heroLevel)
|
||||
{
|
||||
yield return new WaitForSeconds(hoverDelay);
|
||||
|
||||
@@ -66,7 +68,11 @@ public class loadDetailsPrefab : MonoBehaviour
|
||||
if (currentController.item_nameText != null) currentController.item_nameText.text = name;
|
||||
if (currentController.item_typeText != null) currentController.item_typeText.text = type;
|
||||
if (currentController.item_statusText != null) currentController.item_statusText.text = status;
|
||||
if (currentController.item_detailInformationText != null) currentController.item_detailInformationText.text = description;
|
||||
|
||||
if (currentController.item_detailInformationText != null)
|
||||
{
|
||||
currentController.item_detailInformationText.text = ProcessDescription(description, heroLevel);
|
||||
}
|
||||
|
||||
if (currentController.item_statusText != null)
|
||||
{
|
||||
@@ -105,6 +111,77 @@ public class loadDetailsPrefab : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private string ProcessDescription(string desc, int level)
|
||||
{
|
||||
if (string.IsNullOrEmpty(desc)) return desc;
|
||||
|
||||
// 定义数值组匹配模式:由斜杠分割的数值(数字、小数点、百分号)
|
||||
// 使用更严谨的正则,确保匹配整个连续的斜杠组,避免被拆分成多个匹配
|
||||
// (?<!/) 和 (?!/) 确保匹配的组前后没有斜杠,即匹配最长的完整链
|
||||
string groupPattern = @"(?<!/)[\d\.%]+(\s*/\s*[\d\.%]+)+(?!/)";
|
||||
|
||||
// 如果描述中包含斜杠数值组
|
||||
if (Regex.IsMatch(desc, groupPattern))
|
||||
{
|
||||
// 使用 Regex.Replace 进行处理,但增加一层验证,确保不重复处理已加粗的内容
|
||||
return Regex.Replace(desc, groupPattern, m => {
|
||||
string val = m.Value;
|
||||
// 分割出数值和分隔符
|
||||
string[] parts = Regex.Split(val, @"(\s*/\s*)");
|
||||
|
||||
// 实际的数值在 0, 2, 4, 6... 索引位置
|
||||
int actualValueCount = (parts.Length + 1) / 2;
|
||||
int highlightIndex = -1;
|
||||
|
||||
// 根据数值总数判断映射规则 (CBAS/BAS/AS)
|
||||
if (actualValueCount == 4) // CBAS
|
||||
{
|
||||
if (level >= 1 && level <= 4) highlightIndex = (level - 1) * 2;
|
||||
}
|
||||
else if (actualValueCount == 3) // BAS
|
||||
{
|
||||
if (level >= 2 && level <= 4) highlightIndex = (level - 2) * 2;
|
||||
}
|
||||
else if (actualValueCount == 2) // AS
|
||||
{
|
||||
if (level >= 3 && level <= 4) highlightIndex = (level - 3) * 2;
|
||||
}
|
||||
|
||||
// 只加粗目标索引对应的数值
|
||||
for (int i = 0; i < parts.Length; i += 2)
|
||||
{
|
||||
string rawValue = parts[i];
|
||||
string trimmedValue = rawValue.Trim();
|
||||
|
||||
if (i == highlightIndex)
|
||||
{
|
||||
// 加粗当前等级对应的数值
|
||||
int firstIdx = rawValue.IndexOf(trimmedValue);
|
||||
if (firstIdx >= 0)
|
||||
{
|
||||
string leading = rawValue.Substring(0, firstIdx);
|
||||
string trailing = rawValue.Substring(firstIdx + trimmedValue.Length);
|
||||
parts[i] = leading + "<b>" + trimmedValue + "</b>" + trailing;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 确保其他索引位置的数值没有加粗标签(防止重复处理的情况)
|
||||
parts[i] = rawValue.Replace("<b>", "").Replace("</b>", "");
|
||||
}
|
||||
}
|
||||
|
||||
return string.Concat(parts);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果没找到斜杠数值组,就把段落中所有独立数值加粗
|
||||
string singlePattern = @"[\d\.%]+";
|
||||
return Regex.Replace(desc, singlePattern, m => "<b>" + m.Value + "</b>");
|
||||
}
|
||||
}
|
||||
|
||||
private void SetupPosition(Vector3 position)
|
||||
{
|
||||
RectTransform rt = currentDetailsInstance.GetComponent<RectTransform>();
|
||||
|
||||
@@ -216,7 +216,7 @@ public class slots_skillSlots : MonoBehaviour, IPointerClickHandler, IPointerEnt
|
||||
|
||||
string description = group.skillDescriptionsText ?? "无描述";
|
||||
|
||||
loadDetailsPrefab.Instance.ShowDetails(type, name, status, description, Input.mousePosition);
|
||||
loadDetailsPrefab.Instance.ShowDetails(type, name, status, description, Input.mousePosition, currentLevel);
|
||||
}
|
||||
|
||||
// Documentation text normalized.
|
||||
|
||||
Reference in New Issue
Block a user