added documentation, fixed some bugs

This commit is contained in:
Sebastian Bularca
2026-04-06 17:30:09 +02:00
parent 333539eb0e
commit f42885830a
67 changed files with 1963 additions and 151 deletions

View File

@@ -1,8 +1,6 @@
using Jovian.Logger;
using System;
using System.Collections.Generic;
using Jovian.PopupSystem;
using Jovian.PopupSystem.UI;
using Nox.UI;
using UnityEngine;
using Object = UnityEngine.Object;
@@ -72,40 +70,32 @@ namespace Nox.Game.UI {
slot.portrait.sprite = portraitsHolder.portraits[idx];
}
// Name
if(slot.nameText != null) {
slot.nameText.text = member.Name;
}
UpdateSlotStats(slot, member);
activeSlots.Add(slot);
}
// Initialize all popup triggers under the container
if(popupSystem != null) {
popupSystem.InitializeTriggersInChildren(portraitsContainer, trigger => {
var slot = trigger.GetComponentInParent<PartyMemberSlot>();
if(slot == null) {
return;
}
var slotIndex = activeSlots.IndexOf(slot);
if(slotIndex < 0 || slotIndex >= trackedParty.members.Count) {
return;
}
var member = trackedParty.members[slotIndex];
trigger.Initialize(popupSystem, builder => BuildCharacterPopup(builder, member));
});
}
popupSystem?.InitializeTriggersInChildren(portraitsContainer, (trigger, view) => {
var slot = trigger.GetComponentInParent<PartyMemberSlot>();
if(slot == null) {
return;
}
var slotIndex = activeSlots.IndexOf(slot);
if(slotIndex < 0 || slotIndex >= trackedParty.members.Count) {
return;
}
var member = trackedParty.members[slotIndex];
view.SetContent(builder => BuildCharacterPopup(builder, member));
});
}
private void BuildCharacterPopup(PopupContentBuilder builder, CharacterDefinition member) {
GlobalLogger.LogInfo($"Building character popup for {member.Name}", LogCategory.UI);
// Header
builder.AddHeader(member.Name);
builder.AddText($"{member.Race} {member.Class}", "#CCCCCC");
builder.AddText($"Role: {member.Role}");
builder.AddSeparator();
builder
.AddHeader(member.Name)
.AddText($"{member.Race} {member.Class}", "#CCCCCC")
.AddText($"Role: {member.Role}")
.AddSeparator();
// Stats
if(member.Stats?.stats != null) {
@@ -155,16 +145,10 @@ namespace Nox.Game.UI {
if(slot.healthBar != null) {
slot.healthBar.fillAmount = Mathf.Clamp01(health / 100f);
}
if(slot.healthText != null) {
slot.healthText.text = health.ToString();
}
if(slot.manaBar != null) {
slot.manaBar.fillAmount = Mathf.Clamp01(mana / 100f);
}
if(slot.manaText != null) {
slot.manaText.text = mana.ToString();
}
}
public void Dispose() {