Skip to content

Commit fa082bd

Browse files
committed
fixes to predicate merging
1 parent 08e307d commit fa082bd

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

src/exporting.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,27 @@ interface PredicateModel {
209209
}
210210
}
211211

212-
let predicateIDMap = {}
212+
function throwPredicateMergingError(reason: string) {
213+
throw new CustomError('Predicate Missing Overrides List', {
214+
intentional: true,
215+
dialog: {
216+
id: 'animatedJava.predicateMergeFailed',
217+
title: tl(
218+
'animatedJava.dialogs.errors.predicateMergeFailed.title',
219+
{
220+
reason,
221+
}
222+
),
223+
lines: [
224+
tl('animatedJava.dialogs.errors.predicateMergeFailed.body', {
225+
reason,
226+
}),
227+
],
228+
width: 512 + 256,
229+
singleButton: true,
230+
},
231+
})
232+
}
213233

214234
async function exportPredicate(
215235
models: aj.ModelObject,
@@ -245,6 +265,21 @@ async function exportPredicate(
245265
)
246266
console.log(oldPredicate)
247267
// @ts-ignore
268+
if (oldPredicate) {
269+
if (!oldPredicate?.aj) {
270+
throwPredicateMergingError(
271+
tl(
272+
'animatedJava.dialogs.errors.predicateMergeFailed.reasons.ajMetaMissing'
273+
)
274+
)
275+
} else if (!oldPredicate.overrides) {
276+
throwPredicateMergingError(
277+
tl(
278+
'animatedJava.dialogs.errors.predicateMergeFailed.reasons.overridesMissing'
279+
)
280+
)
281+
}
282+
}
248283
const data = oldPredicate?.aj?.includedRigs || {}
249284
if (!oldPredicate?.aj?.includedRigs) {
250285
data.preExistingIds = {

src/lang/en.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,16 @@ animatedJava:
181181
body:
182182
- All cubes must be inside of a group.
183183

184+
predicateMergeFailed:
185+
title: Predicate Failed to Merge
186+
body:
187+
- "%reason"
188+
- Animated Java only supports merging into Animated Java controlled predicate models.
189+
- Please make sure you are attempting to merge your predicate item model with a valid pre-existing Animated Java predicate item model.
190+
reasons:
191+
overridesMissing: Model overrides list missing.
192+
ajMetaMissing: Model file to merge into is not an Animated Java predicate file.
193+
184194
invalidAnimationSnappingValue:
185195
title: Invalid Animation Snapping Value
186196
body:

0 commit comments

Comments
 (0)