some cosmetic changes

This commit is contained in:
Sebastian Bularca
2026-04-12 17:19:38 +02:00
parent 993929bede
commit 3428f168f9
4 changed files with 34 additions and 44 deletions

View File

@@ -62,10 +62,13 @@ namespace Nox.Game.UI {
: 0; : 0;
// Activate slots for current members, deactivate the rest // Activate slots for current members, deactivate the rest
for(int i = 0; i < PoolSize; i++) { for(var i = 0; i < PoolSize; i++) {
var slot = slotPool[i]; var slot = slotPool[i];
if(i < memberCount) { if(i < memberCount && trackedParty?.members != null) {
var member = trackedParty.members[i]; var member = trackedParty.members[i];
if(member == null) {
continue;
}
slot.gameObject.SetActive(true); slot.gameObject.SetActive(true);
// Portrait // Portrait
@@ -84,10 +87,9 @@ namespace Nox.Game.UI {
activeCount = memberCount; activeCount = memberCount;
// Initialize popup triggers // Initialize popup triggers
if(popupSystem != null) { popupSystem?.InitializeTriggersInChildren(portraitsContainer, (trigger, view) => {
popupSystem.InitializeTriggersInChildren(portraitsContainer, (trigger, view) => {
var slot = trigger.GetComponentInParent<PartyMemberSlot>(); var slot = trigger.GetComponentInParent<PartyMemberSlot>();
if(slot == null) { if(!slot) {
return; return;
} }
var slotIndex = System.Array.IndexOf(slotPool, slot); var slotIndex = System.Array.IndexOf(slotPool, slot);
@@ -98,7 +100,6 @@ namespace Nox.Game.UI {
view.SetContent(builder => BuildCharacterPopup(builder, member)); view.SetContent(builder => BuildCharacterPopup(builder, member));
}); });
} }
}
private void BuildCharacterPopup(PopupContentBuilder builder, CharacterDefinition member) { private void BuildCharacterPopup(PopupContentBuilder builder, CharacterDefinition member) {
// Header // Header

View File

@@ -12,9 +12,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: e38e313f3665d464b82b22699b2a4634, type: 3} m_Script: {fileID: 11500000, guid: e38e313f3665d464b82b22699b2a4634, type: 3}
m_Name: PopupSettings m_Name: PopupSettings
m_EditorClassIdentifier: Jovian.PopupSystem::Jovian.PopupSystem.PopupSettings m_EditorClassIdentifier: Jovian.PopupSystem::Jovian.PopupSystem.PopupSettings
popupDelay: 0.4 popupDelay: 0.2
fadeDuration: 0.2 fadeDuration: 0.2
defaultAnchorSide: 3 defaultAnchorSide: 2
screenEdgePadding: 10 screenEdgePadding: 10
maxPopupWidth: 400 maxPopupWidth: 400
sortingOrder: 100 sortingOrder: 100

View File

@@ -10,7 +10,7 @@ namespace Jovian.PopupSystem {
/// or convenience methods for common types. /// or convenience methods for common types.
/// </summary> /// </summary>
public readonly struct PopupContentBuilder { public readonly struct PopupContentBuilder {
readonly PopupView view; private readonly PopupView view;
/// <summary> /// <summary>
/// Creates a builder targeting the given popup view. /// Creates a builder targeting the given popup view.
@@ -32,7 +32,7 @@ namespace Jovian.PopupSystem {
/// </summary> /// </summary>
public PopupContentBuilder AddText(string text, PopupElementType elementType) { public PopupContentBuilder AddText(string text, PopupElementType elementType) {
var go = view.GetElement(elementType); var go = view.GetElement(elementType);
if(go == null) { if(!go) {
return this; return this;
} }
var tmp = go.GetComponentInChildren<TMP_Text>(); var tmp = go.GetComponentInChildren<TMP_Text>();

View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Jovian.PopupSystem.UI; using Jovian.PopupSystem.UI;
using System.Linq;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using Object = UnityEngine.Object; using Object = UnityEngine.Object;
@@ -115,12 +116,7 @@ namespace Jovian.PopupSystem {
kvp.Value.animator.Tick(deltaTime); kvp.Value.animator.Tick(deltaTime);
} }
foreach(var kvp in categories) { foreach(var state in categories.Select(kvp => kvp.Value).Where(state => state.isPending)) {
var state = kvp.Value;
if(!state.isPending) {
continue;
}
state.delayTimer -= deltaTime; state.delayTimer -= deltaTime;
if(state.delayTimer > 0f) { if(state.delayTimer > 0f) {
continue; continue;
@@ -130,13 +126,10 @@ namespace Jovian.PopupSystem {
ShowImmediate(state); ShowImmediate(state);
} }
foreach(var kvp in categories) { foreach(var state in categories.Select(kvp => kvp.Value).Where(state => state.view is { IsVisible: true } && state.isFollowMouse)) {
var state = kvp.Value;
if(state.view != null && state.view.IsVisible && state.isFollowMouse) {
state.view.UpdatePosition(); state.view.UpdatePosition();
} }
} }
}
/// <inheritdoc /> /// <inheritdoc />
public void ScanTriggers(Transform parent) { public void ScanTriggers(Transform parent) {
@@ -216,7 +209,7 @@ namespace Jovian.PopupSystem {
state.view.SetFixedPosition(state.pendingScreenPos.Value, settings.screenEdgePadding); state.view.SetFixedPosition(state.pendingScreenPos.Value, settings.screenEdgePadding);
state.isFollowMouse = false; state.isFollowMouse = false;
} }
else if(state.pendingAnchor != null) { else if(state.pendingAnchor) {
state.view.SetAnchorMode(state.pendingAnchor, state.pendingAnchorSide, settings.screenEdgePadding); state.view.SetAnchorMode(state.pendingAnchor, state.pendingAnchorSide, settings.screenEdgePadding);
state.isFollowMouse = false; state.isFollowMouse = false;
} }
@@ -235,15 +228,10 @@ namespace Jovian.PopupSystem {
} }
PopupReference popupRef; PopupReference popupRef;
if(canvasParent != null) { popupRef = !canvasParent ? Object.Instantiate(viewPrefab) : Object.Instantiate(viewPrefab, canvasParent);
popupRef = Object.Instantiate(viewPrefab, canvasParent);
}
else {
popupRef = Object.Instantiate(viewPrefab);
}
var canvas = popupRef.GetComponent<Canvas>(); var canvas = popupRef.GetComponent<Canvas>();
if(canvas != null) { if(canvas) {
canvas.overrideSorting = true; canvas.overrideSorting = true;
canvas.sortingOrder = settings.sortingOrder; canvas.sortingOrder = settings.sortingOrder;
} }
@@ -256,14 +244,15 @@ namespace Jovian.PopupSystem {
private void DismissLowerPriority(int showingPriority) { private void DismissLowerPriority(int showingPriority) {
foreach(var kvp in categories) { foreach(var kvp in categories) {
var state = kvp.Value; var state = kvp.Value;
if(state.priority < showingPriority && state.view != null && state.view.IsVisible) { if(state.priority >= showingPriority || state.view is not { IsVisible: true }) {
continue;
}
state.isPending = false; state.isPending = false;
state.animator.Hide(state.view.CanvasGroup, settings.fadeDuration, () => { state.animator.Hide(state.view.CanvasGroup, settings.fadeDuration, () => {
state.view.SetVisible(false); state.view.SetVisible(false);
}); });
} }
} }
}
private sealed class ViewState { private sealed class ViewState {
public PopupView view; public PopupView view;