Skip to content

Commit cf2ca91

Browse files
committed
fix: update progress handling and refactor node attachment attributes
- Removed null conditional operator from progress update calls in ModDataCloudManualCoordinator to ensure consistent behavior. - Simplified prefix generation in CardPngExporter and CompendiumDetailPngExporter by removing unnecessary conditional checks. - Refactored node attachment attributes to replace references to RitsuScene with ConvertedScene, enhancing clarity in the registration process. - Updated documentation to reflect changes in node attachment registration methods and improved overall code organization.
1 parent 05b78d1 commit cf2ca91

10 files changed

Lines changed: 32 additions & 31 deletions

Diagnostics/CardExport/CardPngExporter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ private static async Task<bool> TryCaptureWithRetriesAsync(SceneTree tree, CardM
267267
{
268268
for (var attempt = 1; attempt <= MaxCaptureAttemptsPerFile; attempt++)
269269
{
270-
var prefix = MaxCaptureAttemptsPerFile > 1 ? $"[{attempt}/{MaxCaptureAttemptsPerFile}] " : null;
270+
var prefix = $"[{attempt}/{MaxCaptureAttemptsPerFile}] ";
271271
if (await TryCaptureAsync(tree, card, absolutePath, request, scale, log, prefix, fileLabel))
272272
return true;
273273
if (attempt >= MaxCaptureAttemptsPerFile)

Diagnostics/CompendiumExport/CompendiumDetailPngExporter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ private static async Task<bool> TryCaptureRelicWithRetriesAsync(SceneTree tree,
247247
{
248248
for (var attempt = 1; attempt <= MaxCaptureAttemptsPerFile; attempt++)
249249
{
250-
var prefix = MaxCaptureAttemptsPerFile > 1 ? $"[{attempt}/{MaxCaptureAttemptsPerFile}] " : null;
250+
var prefix = $"[{attempt}/{MaxCaptureAttemptsPerFile}] ";
251251
if (await TryCaptureRelicAsync(tree, relic, path, scale, includeRelicHover, log, prefix, fileLabel))
252252
return true;
253253
if (attempt >= MaxCaptureAttemptsPerFile)
@@ -266,7 +266,7 @@ private static async Task<bool> TryCapturePotionWithRetriesAsync(SceneTree tree,
266266
{
267267
for (var attempt = 1; attempt <= MaxCaptureAttemptsPerFile; attempt++)
268268
{
269-
var prefix = MaxCaptureAttemptsPerFile > 1 ? $"[{attempt}/{MaxCaptureAttemptsPerFile}] " : null;
269+
var prefix = $"[{attempt}/{MaxCaptureAttemptsPerFile}] ";
270270
if (await TryCapturePotionAsync(tree, potion, path, scale, log, prefix, fileLabel))
271271
return true;
272272
if (attempt >= MaxCaptureAttemptsPerFile)

Diagnostics/DevConsole/DevConsoleAutocompleteCandidateSources.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using MegaCrit.Sts2.Core.Entities.Ancients;
21
using MegaCrit.Sts2.Core.Localization;
32
using MegaCrit.Sts2.Core.Models;
43
using MegaCrit.Sts2.Core.Timeline;

Diagnostics/ModDataCloudManualCoordinator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ private static async Task RunPushWithProgressAsync(ModCloudSyncScope scope)
278278
cloud,
279279
paths,
280280
tree,
281-
(done, total, cur) => overlay?.SetProgress(done, total, cur));
281+
(done, total, cur) => overlay.SetProgress(done, total, cur));
282282

283283
var body = string.Format(
284284
ModSettingsLocalization.Get(
@@ -371,7 +371,7 @@ private static async Task RunPullWithProgressAsync(ModCloudSyncScope scope)
371371
cloud,
372372
paths,
373373
tree,
374-
(done, total, cur) => overlay?.SetProgress(done, total, cur));
374+
(done, total, cur) => overlay.SetProgress(done, total, cur));
375375

376376
var body = failed == 0
377377
? string.Format(

Interop/AutoRegistration/AttributeAutoRegistrationTypeDiscoveryContributor.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -617,20 +617,20 @@ void Append(Attribute attribute, bool inherited)
617617
});
618618
break;
619619
}
620-
case RegisterNodeAttachmentFromRitsuSceneAttribute nodeAttachmentRitsuScene:
620+
case RegisterNodeAttachmentFromConvertedSceneAttribute nodeAttachmentConvertedScene:
621621
{
622-
var nodeType = ResolveNodeAttachmentNodeType(type, nodeAttachmentRitsuScene.NodeType);
622+
var nodeType = ResolveNodeAttachmentNodeType(type, nodeAttachmentConvertedScene.NodeType);
623623
RegisterCase(
624-
$"RegisterNodeAttachmentFromRitsuScene:{nodeAttachmentRitsuScene.ParentType.FullName}->{nodeType.FullName}:{nodeAttachmentRitsuScene.LocalId}:{nodeAttachmentRitsuScene.ScenePath}",
624+
$"RegisterNodeAttachmentFromConvertedScene:{nodeAttachmentConvertedScene.ParentType.FullName}->{nodeType.FullName}:{nodeAttachmentConvertedScene.LocalId}:{nodeAttachmentConvertedScene.ScenePath}",
625625
() =>
626626
{
627627
operations.Add(CreateOperation(ownerModId, type,
628628
AutoRegistrationPhase.NodeAttachments,
629-
nodeAttachmentRitsuScene.Order,
630-
$"RegisterNodeAttachmentFromRitsuScene:{nodeAttachmentRitsuScene.ParentType.FullName}->{nodeType.FullName}:{nodeAttachmentRitsuScene.LocalId}:{nodeAttachmentRitsuScene.ScenePath}",
631-
nameof(RegisterNodeAttachmentFromRitsuSceneAttribute),
629+
nodeAttachmentConvertedScene.Order,
630+
$"RegisterNodeAttachmentFromConvertedScene:{nodeAttachmentConvertedScene.ParentType.FullName}->{nodeType.FullName}:{nodeAttachmentConvertedScene.LocalId}:{nodeAttachmentConvertedScene.ScenePath}",
631+
nameof(RegisterNodeAttachmentFromConvertedSceneAttribute),
632632
() => RegisterSceneNodeAttachment(ownerModId, type, nodeType,
633-
nodeAttachmentRitsuScene,
633+
nodeAttachmentConvertedScene,
634634
true),
635635
[TypeDependencyKey(type)]));
636636
});
@@ -1246,14 +1246,14 @@ private static void RegisterFactoryNodeAttachment(string ownerModId, Type declar
12461246
}
12471247

12481248
private static void RegisterSceneNodeAttachment(string ownerModId, Type declaringType, Type nodeType,
1249-
RegisterNodeAttachmentAttributeBase attr, bool ritsuFactory)
1249+
RegisterNodeAttachmentAttributeBase attr, bool convertedScene)
12501250
{
12511251
EnsureConcreteSubtype(attr.ParentType, typeof(Node), nameof(attr.ParentType));
12521252
var scenePath = attr switch
12531253
{
12541254
RegisterNodeAttachmentFromSceneAttribute scene => ValidateNonEmpty(scene.ScenePath,
12551255
nameof(scene.ScenePath)),
1256-
RegisterNodeAttachmentFromRitsuSceneAttribute scene => ValidateNonEmpty(scene.ScenePath,
1256+
RegisterNodeAttachmentFromConvertedSceneAttribute scene => ValidateNonEmpty(scene.ScenePath,
12571257
nameof(scene.ScenePath)),
12581258
_ => throw new ArgumentException("Unsupported node attachment scene attribute.", nameof(attr)),
12591259
};
@@ -1264,12 +1264,12 @@ private static void RegisterSceneNodeAttachment(string ownerModId, Type declarin
12641264
ValidateNonEmpty(attr.LocalId, nameof(attr.LocalId)),
12651265
attr.ParentType,
12661266
nodeType,
1267-
_ => ritsuFactory
1268-
? CreateNodeViaRitsuFactory(nodeType, scenePath)
1267+
_ => convertedScene
1268+
? CreateNodeViaConvertedSceneFactory(nodeType, scenePath)
12691269
: InstantiateSceneNode(nodeType, scenePath),
12701270
ComposeNodeAttachmentSetup(setup),
12711271
options,
1272-
ritsuFactory ? "attribute-ritsulib-scene-factory" : "attribute-scene",
1272+
convertedScene ? "attribute-converted-scene" : "attribute-scene",
12731273
scenePath);
12741274
}
12751275

@@ -1359,7 +1359,7 @@ private static Node InstantiateSceneNode(Type nodeType, string scenePath)
13591359
$"Scene '{scenePath}' instantiated {node.GetType().FullName}, expected {nodeType.FullName}.");
13601360
}
13611361

1362-
private static Node CreateNodeViaRitsuFactory(Type nodeType, string scenePath)
1362+
private static Node CreateNodeViaConvertedSceneFactory(Type nodeType, string scenePath)
13631363
{
13641364
var method = typeof(RitsuGodotNodeFactories).GetMethods(BindingFlags.Public | BindingFlags.Static)
13651365
.Single(method => method is

Interop/AutoRegistration/RegistrationAttributes.NodeAttachments.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,13 @@ public sealed class RegisterNodeAttachmentFromSceneAttribute(Type parentType, st
102102
}
103103

104104
/// <summary>
105-
/// Declaratively registers a ready-time node attachment created by RitsuLib scene factories.
105+
/// Declaratively registers a ready-time node attachment created from a scene converted by RitsuLib node factories.
106106
/// </summary>
107107
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
108-
public sealed class RegisterNodeAttachmentFromRitsuSceneAttribute(Type parentType, string localId, string scenePath)
108+
public sealed class RegisterNodeAttachmentFromConvertedSceneAttribute(
109+
Type parentType,
110+
string localId,
111+
string scenePath)
109112
: RegisterNodeAttachmentAttributeBase(parentType, localId)
110113
{
111114
/// <summary>
@@ -114,7 +117,7 @@ public sealed class RegisterNodeAttachmentFromRitsuSceneAttribute(Type parentTyp
114117
public Type? NodeType { get; set; }
115118

116119
/// <summary>
117-
/// Godot scene path loaded through RitsuLib factories.
120+
/// Godot scene path loaded and converted through RitsuLib node factories.
118121
/// </summary>
119122
public string ScenePath { get; } = scenePath;
120123
}

Scaffolding/Characters/IModColorfulPhilosophersCardPool.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@ namespace STS2RitsuLib.Scaffolding.Characters
33
/// <summary>
44
/// Implement on a character card pool to let Colorful Philosophers offer that pool as a reward color.
55
/// </summary>
6-
public interface IModColorfulPhilosophersCardPool
7-
{
8-
}
6+
public interface IModColorfulPhilosophersCardPool;
97
}

Scaffolding/Godot/NodeAttachments/ModNodeAttachmentRegistry.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,10 @@ public NodeAttachmentDefinition RegisterReadyChildFromScene<TParent, TNode>(
9898
}
9999

100100
/// <summary>
101-
/// Registers a child created by <see cref="RitsuGodotNodeFactories.CreateFromScenePath{TNode}(string)" />.
101+
/// Registers a child created from a scene converted by
102+
/// <see cref="RitsuGodotNodeFactories.CreateFromScenePath{TNode}(string)" />.
102103
/// </summary>
103-
public NodeAttachmentDefinition RegisterReadyChildFromRitsuScene<TParent, TNode>(
104+
public NodeAttachmentDefinition RegisterReadyChildFromConvertedScene<TParent, TNode>(
104105
string localId,
105106
string scenePath,
106107
Action<TParent, TNode>? setup = null,
@@ -114,7 +115,7 @@ public NodeAttachmentDefinition RegisterReadyChildFromRitsuScene<TParent, TNode>
114115
_ => RitsuGodotNodeFactories.CreateFromScenePath<TNode>(scenePath),
115116
setup,
116117
options,
117-
"ritsulib-scene-factory",
118+
"converted-scene",
118119
scenePath);
119120
}
120121

@@ -274,7 +275,7 @@ private static TNode InstantiateScene<TNode>(string scenePath) where TNode : Nod
274275

275276
throw new InvalidOperationException(
276277
$"Scene '{scenePath}' instantiated {node.GetType().FullName}, expected {typeof(TNode).FullName}. " +
277-
$"Use {nameof(RegisterReadyChildFromRitsuScene)} when the scene root must be converted by RitsuLib factories.");
278+
$"Use {nameof(RegisterReadyChildFromConvertedScene)} when the scene root must be converted by RitsuLib factories.");
278279
}
279280
}
280281
}

Scaffolding/Godot/NodeAttachments/NodeAttachmentDefinition.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ internal NodeAttachmentDefinition(
6464
public NodeAttachmentOptions Options { get; }
6565

6666
/// <summary>
67-
/// Creation source label such as factory, scene, or ritsulib-scene-factory.
67+
/// Creation source label such as factory, scene, or converted-scene.
6868
/// </summary>
6969
public string SourceKind { get; }
7070

Settings/ModSettingsUi/Controls/ModSettingsUiFactory.ModCloudScope.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ void Finish(ModCloudSyncScope? scope)
183183

184184
void FitModalShieldToViewport()
185185
{
186-
if (canvasLayer == null || canvasLayer.GetChildCount() == 0)
186+
if (canvasLayer.GetChildCount() == 0)
187187
return;
188188
var shield = canvasLayer.GetChild(0) as Control;
189189
if (!GodotObject.IsInstanceValid(shield))

0 commit comments

Comments
 (0)