Query the user for pack_code
and cycle_prefix
at runtime
This commit is contained in:
parent
62e9e1ec4f
commit
011962af33
@ -6,16 +6,14 @@
|
||||
|
||||
useLibrary('imageutils');
|
||||
useLibrary('project');
|
||||
useLibrary('uilayout');
|
||||
useLibrary('uicontrols');
|
||||
|
||||
// The resolution (in pixels per inch) of the exported images
|
||||
const RESOLUTION = 200;
|
||||
// The extension of the image file format to use, e.g., png, jpg
|
||||
const FORMAT = ImageUtils.FORMAT_JPEG;
|
||||
|
||||
// TODO: should be defined in strange eons somewhere
|
||||
const pack_code = "kyo_player";
|
||||
const cycle_prefix = "43";
|
||||
|
||||
function getName() {
|
||||
return 'ArkhamDB Export';
|
||||
}
|
||||
@ -119,7 +117,7 @@ function replaceAll(str, search, replace) {
|
||||
return str.split(search).join(replace);
|
||||
}
|
||||
|
||||
function build_card(component) {
|
||||
function build_card(component, pack_code, cycle_prefix) {
|
||||
function substitute_tags(str) {
|
||||
str = str.trim();
|
||||
str = replaceAll(str, "<fullname>", String(component.getName()));
|
||||
@ -139,7 +137,7 @@ function build_card(component) {
|
||||
illustrator: String(component.settings.get('Artist')),
|
||||
is_unique: component.settings.getBoolean('Unique'),
|
||||
name: substitute_tags(String(component.getName())),
|
||||
pack_code: pack_code,
|
||||
pack_code: String(pack_code),
|
||||
position: int_or_null(component.settings.get('CollectionNumber')),
|
||||
quantity: 2, // TODO
|
||||
//restrictions: null, // TODO
|
||||
@ -250,6 +248,20 @@ function exportCard(component, file) {
|
||||
}
|
||||
}
|
||||
|
||||
function settingsDialog() {
|
||||
const pack_code_field = textField("", 15);
|
||||
const cycle_prefix_field = textField("", 3);
|
||||
const panel = new Grid();
|
||||
panel.place(
|
||||
"Pack Code", "",
|
||||
pack_code_field, "grow,span",
|
||||
"Cycle Prefix", "",
|
||||
cycle_prefix_field, "grow"
|
||||
);
|
||||
const close_button = panel.createDialog('ArkhamDB Export').showDialog();
|
||||
return [close_button, pack_code_field.text, cycle_prefix_field.text];
|
||||
}
|
||||
|
||||
function run() {
|
||||
const arkhamDBAction = JavaAdapter(TaskAction, {
|
||||
getLabel: function getLabel() {
|
||||
@ -271,9 +283,16 @@ function run() {
|
||||
},
|
||||
perform: function perform(project, task, member) {
|
||||
member = ProjectUtilities.simplify(project, task, member);
|
||||
const [close_button, pack_code, cycle_prefix] = settingsDialog();
|
||||
|
||||
// User canceled the dialog or closed it without pressing ok
|
||||
if (close_button != 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
Eons.setWaitCursor(true);
|
||||
try {
|
||||
this.performImpl(member);
|
||||
this.performImpl(member, pack_code, cycle_prefix);
|
||||
} catch (ex) {
|
||||
Error.handleUncaught(ex);
|
||||
} finally {
|
||||
@ -281,7 +300,7 @@ function run() {
|
||||
member.synchronize();
|
||||
}
|
||||
},
|
||||
performImpl: function performImpl(member) {
|
||||
performImpl: function performImpl(member, pack_code, cycle_prefix) {
|
||||
const children = member.children.filter(function (child) {
|
||||
return ProjectUtilities.matchExtension(child, 'eon');
|
||||
});
|
||||
@ -293,7 +312,7 @@ function run() {
|
||||
let component = ResourceKit.getGameComponentFromFile(child.file);
|
||||
if (component.getFrontTemplateKey() in card_types) {
|
||||
printf("Generating JSON/PNG for '%s'...\n", child);
|
||||
let card_data = build_card(component);
|
||||
let card_data = build_card(component, pack_code, cycle_prefix);
|
||||
cards.push(card_data);
|
||||
|
||||
let export_dir = new File(member.file, 'export');
|
||||
|
Loading…
Reference in New Issue
Block a user