forked from Shardstone/trail-into-darkness
some cosmetic changes
This commit is contained in:
@@ -62,10 +62,13 @@ namespace Nox.Game.UI {
|
||||
: 0;
|
||||
|
||||
// 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];
|
||||
if(i < memberCount) {
|
||||
if(i < memberCount && trackedParty?.members != null) {
|
||||
var member = trackedParty.members[i];
|
||||
if(member == null) {
|
||||
continue;
|
||||
}
|
||||
slot.gameObject.SetActive(true);
|
||||
|
||||
// Portrait
|
||||
@@ -84,20 +87,18 @@ namespace Nox.Game.UI {
|
||||
activeCount = memberCount;
|
||||
|
||||
// Initialize popup triggers
|
||||
if(popupSystem != null) {
|
||||
popupSystem.InitializeTriggersInChildren(portraitsContainer, (trigger, view) => {
|
||||
var slot = trigger.GetComponentInParent<PartyMemberSlot>();
|
||||
if(slot == null) {
|
||||
return;
|
||||
}
|
||||
var slotIndex = System.Array.IndexOf(slotPool, slot);
|
||||
if(slotIndex < 0 || slotIndex >= activeCount) {
|
||||
return;
|
||||
}
|
||||
var member = trackedParty.members[slotIndex];
|
||||
view.SetContent(builder => BuildCharacterPopup(builder, member));
|
||||
});
|
||||
}
|
||||
popupSystem?.InitializeTriggersInChildren(portraitsContainer, (trigger, view) => {
|
||||
var slot = trigger.GetComponentInParent<PartyMemberSlot>();
|
||||
if(!slot) {
|
||||
return;
|
||||
}
|
||||
var slotIndex = System.Array.IndexOf(slotPool, slot);
|
||||
if(slotIndex < 0 || slotIndex >= activeCount) {
|
||||
return;
|
||||
}
|
||||
var member = trackedParty.members[slotIndex];
|
||||
view.SetContent(builder => BuildCharacterPopup(builder, member));
|
||||
});
|
||||
}
|
||||
|
||||
private void BuildCharacterPopup(PopupContentBuilder builder, CharacterDefinition member) {
|
||||
|
||||
@@ -12,9 +12,9 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: e38e313f3665d464b82b22699b2a4634, type: 3}
|
||||
m_Name: PopupSettings
|
||||
m_EditorClassIdentifier: Jovian.PopupSystem::Jovian.PopupSystem.PopupSettings
|
||||
popupDelay: 0.4
|
||||
popupDelay: 0.2
|
||||
fadeDuration: 0.2
|
||||
defaultAnchorSide: 3
|
||||
defaultAnchorSide: 2
|
||||
screenEdgePadding: 10
|
||||
maxPopupWidth: 400
|
||||
sortingOrder: 100
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Jovian.PopupSystem {
|
||||
/// or convenience methods for common types.
|
||||
/// </summary>
|
||||
public readonly struct PopupContentBuilder {
|
||||
readonly PopupView view;
|
||||
private readonly PopupView view;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a builder targeting the given popup view.
|
||||
@@ -32,7 +32,7 @@ namespace Jovian.PopupSystem {
|
||||
/// </summary>
|
||||
public PopupContentBuilder AddText(string text, PopupElementType elementType) {
|
||||
var go = view.GetElement(elementType);
|
||||
if(go == null) {
|
||||
if(!go) {
|
||||
return this;
|
||||
}
|
||||
var tmp = go.GetComponentInChildren<TMP_Text>();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Jovian.PopupSystem.UI;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Object = UnityEngine.Object;
|
||||
@@ -115,12 +116,7 @@ namespace Jovian.PopupSystem {
|
||||
kvp.Value.animator.Tick(deltaTime);
|
||||
}
|
||||
|
||||
foreach(var kvp in categories) {
|
||||
var state = kvp.Value;
|
||||
if(!state.isPending) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach(var state in categories.Select(kvp => kvp.Value).Where(state => state.isPending)) {
|
||||
state.delayTimer -= deltaTime;
|
||||
if(state.delayTimer > 0f) {
|
||||
continue;
|
||||
@@ -130,11 +126,8 @@ namespace Jovian.PopupSystem {
|
||||
ShowImmediate(state);
|
||||
}
|
||||
|
||||
foreach(var kvp in categories) {
|
||||
var state = kvp.Value;
|
||||
if(state.view != null && state.view.IsVisible && state.isFollowMouse) {
|
||||
state.view.UpdatePosition();
|
||||
}
|
||||
foreach(var state in categories.Select(kvp => kvp.Value).Where(state => state.view is { IsVisible: true } && state.isFollowMouse)) {
|
||||
state.view.UpdatePosition();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +209,7 @@ namespace Jovian.PopupSystem {
|
||||
state.view.SetFixedPosition(state.pendingScreenPos.Value, settings.screenEdgePadding);
|
||||
state.isFollowMouse = false;
|
||||
}
|
||||
else if(state.pendingAnchor != null) {
|
||||
else if(state.pendingAnchor) {
|
||||
state.view.SetAnchorMode(state.pendingAnchor, state.pendingAnchorSide, settings.screenEdgePadding);
|
||||
state.isFollowMouse = false;
|
||||
}
|
||||
@@ -235,15 +228,10 @@ namespace Jovian.PopupSystem {
|
||||
}
|
||||
|
||||
PopupReference popupRef;
|
||||
if(canvasParent != null) {
|
||||
popupRef = Object.Instantiate(viewPrefab, canvasParent);
|
||||
}
|
||||
else {
|
||||
popupRef = Object.Instantiate(viewPrefab);
|
||||
}
|
||||
popupRef = !canvasParent ? Object.Instantiate(viewPrefab) : Object.Instantiate(viewPrefab, canvasParent);
|
||||
|
||||
var canvas = popupRef.GetComponent<Canvas>();
|
||||
if(canvas != null) {
|
||||
if(canvas) {
|
||||
canvas.overrideSorting = true;
|
||||
canvas.sortingOrder = settings.sortingOrder;
|
||||
}
|
||||
@@ -256,12 +244,13 @@ namespace Jovian.PopupSystem {
|
||||
private void DismissLowerPriority(int showingPriority) {
|
||||
foreach(var kvp in categories) {
|
||||
var state = kvp.Value;
|
||||
if(state.priority < showingPriority && state.view != null && state.view.IsVisible) {
|
||||
state.isPending = false;
|
||||
state.animator.Hide(state.view.CanvasGroup, settings.fadeDuration, () => {
|
||||
state.view.SetVisible(false);
|
||||
});
|
||||
if(state.priority >= showingPriority || state.view is not { IsVisible: true }) {
|
||||
continue;
|
||||
}
|
||||
state.isPending = false;
|
||||
state.animator.Hide(state.view.CanvasGroup, settings.fadeDuration, () => {
|
||||
state.view.SetVisible(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user