async _updateObject(event, formData) {
        // Make a journal entry to tie fake notes to or find the old one
        // If no "real" journal entry is provided than the map notes fail
        // to show up, hence why this block of code exists.

        // TODO: Investigate better way than adding a random journal entry.
        let azgaarJournal = game.journal.getName("Azgaar FMG");
        if (!azgaarJournal) {
            let fakeJournal = {
                content: "This journal entry is necessary for the azgaar-foundry importer to work properly",
                name: "Azgaar FMG",
                permission: { default: 0 },
            };
            azgaarJournal = await JournalEntry.create(fakeJournal);
        }

        // Make the scene
        let picture = this.element.find('[name="pictureMap"]').val();
        if (!picture) {
            ui.notifications.error("[Azgaar FMG] You must attach a picture and a map file to the form.");
            return;
        }
        let [scene, widthMultiplier, heightMultiplier] = await this.makeScene(picture);

        // get icons to use for notes
        const burgSVG = this.element.find("#burgSVG").attr("src");
        const countrySVG = this.element.find("#countrySVG").attr("src");
        const provinceSVG = this.element.find("#provinceSVG").attr("src");

        // import our data
        await this.importData();

        const [countryMinZoom, countryMaxZoom] = this.element
            .find("#azgaar-pin-fixer-select #countries input")
            .map((i, input) => input.value);

        let useColor = this.element.find("#azgaar-icon-select #countries input#iconColors").is(":checked");
        // Start prepping notes
        let countryData = this.countries.map((country) => {
            if (country.name === "Neutrals") return;
            let journalEntry = this.retrieveJournalByName({
                type: "country",
                name: country.name,
            });

            let xpole,
                ypole = 0;
            if (country.pole) {
                xpole = country.pole[0];
                ypole = country.pole[1];
            }

            // Assemble data required for notes
            return {
                entryId: azgaarJournal.id,
                x: xpole * widthMultiplier,
                y: ypole * heightMultiplier,
                icon: countrySVG,
                iconSize: 32,
                iconTint: useColor ? country.color : "#00FF000",
                text: country.name,
                fontSize: 24,
                textAnchor: CONST.TEXT_ANCHOR_POINTS.CENTER,
                textColor: "#00FFFF",
                "flags.pinfix.minZoomLevel": countryMinZoom,
                "flags.pinfix.maxZoomLevel": countryMaxZoom,
                "flags.azgaar-foundry.journal": { compendium: "world.Countries", journal: journalEntry?.id },
            };
        });

        const [provinceMinZoom, provinceMaxZoom] = this.element
            .find("#azgaar-pin-fixer-select #provinces input")
            .map((i, input) => input.value);

        useColor = this.element.find("#azgaar-icon-select #provinces input#iconColors").is(":checked");
        let provinceData = this.provinces.map((province) => {
            if (province === 0) return; // For some reason there's a 0 at the beginning.
            let journalEntry = this.retrieveJournalByName({
                type: "province",
                name: province.name,
            });

            // Some provinces do not have a burg... For now we skip those.
            if (province.burg === 0) return;
            let centerBurg = this.burgs.find((burg) => burg.i === province.burg);

            // Assemble data required for notes
            return {
                entryId: azgaarJournal.id,
                x: centerBurg.x * widthMultiplier,
                y: centerBurg.y * heightMultiplier,
                icon: provinceSVG,
                iconSize: 32,
                iconTint: useColor ? province.color : "#00FF000",
                text: province.name,
                fontSize: 24,
                textAnchor: CONST.TEXT_ANCHOR_POINTS.CENTER,
                textColor: "#00FFFF",
                "flags.pinfix.minZoomLevel": provinceMinZoom,
                "flags.pinfix.maxZoomLevel": provinceMaxZoom,
                "flags.azgaar-foundry.journal": { compendium: "world.Provinces", journal: journalEntry.id },
            };
        });

        const [burgMinZoom, burgMaxZoom] = this.element
            .find("#azgaar-pin-fixer-select #burgs input")
            .map((i, input) => input.value);

        useColor = this.element.find("#azgaar-icon-select #burgs input#iconColors").is(":checked");
        let burgData = this.burgs.map((burg) => {
            if (jQuery.isEmptyObject(burg)) return; // For some reason there's a {} at the beginning.
            let journalEntry = this.retrieveJournalByName({ name: burg.name });

            // Assemble data required for notes
            return {
                // entryId must be a valid journal entry (NOT from compendium, otherwise things really break.)
                entryId: azgaarJournal.id,
                x: burg.x * widthMultiplier,
                y: burg.y * heightMultiplier,
                icon: burgSVG,
                iconSize: 32,
                iconTint: useColor ? burg.color : "#00FF000",
                text: burg.name,
                fontSize: 24,
                textAnchor: CONST.TEXT_ANCHOR_POINTS.CENTER,
                textColor: "#00FFFF",
                "flags.pinfix.minZoomLevel": burgMinZoom,
                "flags.pinfix.maxZoomLevel": burgMaxZoom,
                "flags.azgaar-foundry.journal": { compendium: "world.Burgs", journal: journalEntry?.id },
            };
        });

        // Remove all falsy values.
        countryData = countryData.filter(Boolean);
        provinceData = provinceData.filter(Boolean);
        burgData = burgData.filter(Boolean);

        // Make all of our notes, in one call to the db.
        await canvas.scene.createEmbeddedDocuments("Note", [...countryData, ...provinceData, ...burgData]);
        return;
    }
/**
     * Automatically called by Foundry upon submission of FormApplication
     * Controls the process of creating everything. Scene, data, notes, etc.
     *
     * @param  {event} event        event that triggered this call, usually a click
     * @param  {String} formData    HTML of the form that was submitted
     * @return {None}               Foundry expects it to return something.
     */
Automatically called by Foundry upon submission of FormApplication
Controls the process of creating everything. Scene, data, notes, etc.

@param  {event} event        event that triggered this call, usually a click
@param  {String} formData    HTML of the form that was submitted
@return {None}               Foundry expects it to return something.
Automatically called by Foundry upon submission of FormApplication Controls the process of creating everything . Scene data notes etc . @param { event } event event that triggered this call usually a click @param { String } formData HTML of the form that was submitted @return { None } Foundry expects it to return something .
async _updateObject(event, formData) {
        let azgaarJournal = game.journal.getName("Azgaar FMG");
        if (!azgaarJournal) {
            let fakeJournal = {
                content: "This journal entry is necessary for the azgaar-foundry importer to work properly",
                name: "Azgaar FMG",
                permission: { default: 0 },
            };
            azgaarJournal = await JournalEntry.create(fakeJournal);
        }
        let picture = this.element.find('[name="pictureMap"]').val();
        if (!picture) {
            ui.notifications.error("[Azgaar FMG] You must attach a picture and a map file to the form.");
            return;
        }
        let [scene, widthMultiplier, heightMultiplier] = await this.makeScene(picture);
        const burgSVG = this.element.find("#burgSVG").attr("src");
        const countrySVG = this.element.find("#countrySVG").attr("src");
        const provinceSVG = this.element.find("#provinceSVG").attr("src");
        await this.importData();
        const [countryMinZoom, countryMaxZoom] = this.element
            .find("#azgaar-pin-fixer-select #countries input")
            .map((i, input) => input.value);
        let useColor = this.element.find("#azgaar-icon-select #countries input#iconColors").is(":checked");
        let countryData = this.countries.map((country) => {
            if (country.name === "Neutrals") return;
            let journalEntry = this.retrieveJournalByName({
                type: "country",
                name: country.name,
            });
            let xpole,
                ypole = 0;
            if (country.pole) {
                xpole = country.pole[0];
                ypole = country.pole[1];
            }
            return {
                entryId: azgaarJournal.id,
                x: xpole * widthMultiplier,
                y: ypole * heightMultiplier,
                icon: countrySVG,
                iconSize: 32,
                iconTint: useColor ? country.color : "#00FF000",
                text: country.name,
                fontSize: 24,
                textAnchor: CONST.TEXT_ANCHOR_POINTS.CENTER,
                textColor: "#00FFFF",
                "flags.pinfix.minZoomLevel": countryMinZoom,
                "flags.pinfix.maxZoomLevel": countryMaxZoom,
                "flags.azgaar-foundry.journal": { compendium: "world.Countries", journal: journalEntry?.id },
            };
        });
        const [provinceMinZoom, provinceMaxZoom] = this.element
            .find("#azgaar-pin-fixer-select #provinces input")
            .map((i, input) => input.value);
        useColor = this.element.find("#azgaar-icon-select #provinces input#iconColors").is(":checked");
        let provinceData = this.provinces.map((province) => {
            if (province === 0) return; 
            let journalEntry = this.retrieveJournalByName({
                type: "province",
                name: province.name,
            });
            if (province.burg === 0) return;
            let centerBurg = this.burgs.find((burg) => burg.i === province.burg);
            return {
                entryId: azgaarJournal.id,
                x: centerBurg.x * widthMultiplier,
                y: centerBurg.y * heightMultiplier,
                icon: provinceSVG,
                iconSize: 32,
                iconTint: useColor ? province.color : "#00FF000",
                text: province.name,
                fontSize: 24,
                textAnchor: CONST.TEXT_ANCHOR_POINTS.CENTER,
                textColor: "#00FFFF",
                "flags.pinfix.minZoomLevel": provinceMinZoom,
                "flags.pinfix.maxZoomLevel": provinceMaxZoom,
                "flags.azgaar-foundry.journal": { compendium: "world.Provinces", journal: journalEntry.id },
            };
        });
        const [burgMinZoom, burgMaxZoom] = this.element
            .find("#azgaar-pin-fixer-select #burgs input")
            .map((i, input) => input.value);
        useColor = this.element.find("#azgaar-icon-select #burgs input#iconColors").is(":checked");
        let burgData = this.burgs.map((burg) => {
            if (jQuery.isEmptyObject(burg)) return; 
            let journalEntry = this.retrieveJournalByName({ name: burg.name });
            return {
                entryId: azgaarJournal.id,
                x: burg.x * widthMultiplier,
                y: burg.y * heightMultiplier,
                icon: burgSVG,
                iconSize: 32,
                iconTint: useColor ? burg.color : "#00FF000",
                text: burg.name,
                fontSize: 24,
                textAnchor: CONST.TEXT_ANCHOR_POINTS.CENTER,
                textColor: "#00FFFF",
                "flags.pinfix.minZoomLevel": burgMinZoom,
                "flags.pinfix.maxZoomLevel": burgMaxZoom,
                "flags.azgaar-foundry.journal": { compendium: "world.Burgs", journal: journalEntry?.id },
            };
        });
        countryData = countryData.filter(Boolean);
        provinceData = provinceData.filter(Boolean);
        burgData = burgData.filter(Boolean);
        await canvas.scene.createEmbeddedDocuments("Note", [...countryData, ...provinceData, ...burgData]);
        return;
    }
async _updateObject ( event , formData ) { let azgaarJournal = game . journal . getName ( "Azgaar FMG" ) ; if ( ! azgaarJournal ) { let fakeJournal = { content : "This journal entry is necessary for the azgaar-foundry importer to work properly" , name : "Azgaar FMG" , permission : { default : 0 } , } ; azgaarJournal = await JournalEntry . create ( fakeJournal ) ; } let picture = this . element . find ( '[name="pictureMap"]' ) . val ( ) ; if ( ! picture ) { ui . notifications . error ( "[Azgaar FMG] You must attach a picture and a map file to the form." ) ; return ; } let [ scene , widthMultiplier , heightMultiplier ] = await this . makeScene ( picture ) ; const burgSVG = this . element . find ( "#burgSVG" ) . attr ( "src" ) ; const countrySVG = this . element . find ( "#countrySVG" ) . attr ( "src" ) ; const provinceSVG = this . element . find ( "#provinceSVG" ) . attr ( "src" ) ; await this . importData ( ) ; const [ countryMinZoom , countryMaxZoom ] = this . element . find ( "#azgaar-pin-fixer-select #countries input" ) . map ( ( i , input ) => input . value ) ; let useColor = this . element . find ( "#azgaar-icon-select #countries input#iconColors" ) . is ( ":checked" ) ; let countryData = this . countries . map ( ( country ) => { if ( country . name === "Neutrals" ) return ; let journalEntry = this . retrieveJournalByName ( { type : "country" , name : country . name , } ) ; let xpole , ypole = 0 ; if ( country . pole ) { xpole = country . pole [ 0 ] ; ypole = country . pole [ 1 ] ; } return { entryId : azgaarJournal . id , x : xpole * widthMultiplier , y : ypole * heightMultiplier , icon : countrySVG , iconSize : 32 , iconTint : useColor ? country . color : "#00FF000" , text : country . name , fontSize : 24 , textAnchor : CONST . TEXT_ANCHOR_POINTS . CENTER , textColor : "#00FFFF" , "flags.pinfix.minZoomLevel" : countryMinZoom , "flags.pinfix.maxZoomLevel" : countryMaxZoom , "flags.azgaar-foundry.journal" : { compendium : "world.Countries" , journal : journalEntry ?. id } , } ; } ) ; const [ provinceMinZoom , provinceMaxZoom ] = this . element . find ( "#azgaar-pin-fixer-select #provinces input" ) . map ( ( i , input ) => input . value ) ; useColor = this . element . find ( "#azgaar-icon-select #provinces input#iconColors" ) . is ( ":checked" ) ; let provinceData = this . provinces . map ( ( province ) => { if ( province === 0 ) return ; let journalEntry = this . retrieveJournalByName ( { type : "province" , name : province . name , } ) ; if ( province . burg === 0 ) return ; let centerBurg = this . burgs . find ( ( burg ) => burg . i === province . burg ) ; return { entryId : azgaarJournal . id , x : centerBurg . x * widthMultiplier , y : centerBurg . y * heightMultiplier , icon : provinceSVG , iconSize : 32 , iconTint : useColor ? province . color : "#00FF000" , text : province . name , fontSize : 24 , textAnchor : CONST . TEXT_ANCHOR_POINTS . CENTER , textColor : "#00FFFF" , "flags.pinfix.minZoomLevel" : provinceMinZoom , "flags.pinfix.maxZoomLevel" : provinceMaxZoom , "flags.azgaar-foundry.journal" : { compendium : "world.Provinces" , journal : journalEntry . id } , } ; } ) ; const [ burgMinZoom , burgMaxZoom ] = this . element . find ( "#azgaar-pin-fixer-select #burgs input" ) . map ( ( i , input ) => input . value ) ; useColor = this . element . find ( "#azgaar-icon-select #burgs input#iconColors" ) . is ( ":checked" ) ; let burgData = this . burgs . map ( ( burg ) => { if ( jQuery . isEmptyObject ( burg ) ) return ; let journalEntry = this . retrieveJournalByName ( { name : burg . name } ) ; return { entryId : azgaarJournal . id , x : burg . x * widthMultiplier , y : burg . y * heightMultiplier , icon : burgSVG , iconSize : 32 , iconTint : useColor ? burg . color : "#00FF000" , text : burg . name , fontSize : 24 , textAnchor : CONST . TEXT_ANCHOR_POINTS . CENTER , textColor : "#00FFFF" , "flags.pinfix.minZoomLevel" : burgMinZoom , "flags.pinfix.maxZoomLevel" : burgMaxZoom , "flags.azgaar-foundry.journal" : { compendium : "world.Burgs" , journal : journalEntry ?. id } , } ; } ) ; countryData = countryData . filter ( Boolean ) ; provinceData = provinceData . filter ( Boolean ) ; burgData = burgData . filter ( Boolean ) ; await canvas . scene . createEmbeddedDocuments ( "Note" , [ ... countryData , ... provinceData , ... burgData ] ) ; return ; }
Automatically called by Foundry upon submission of FormApplication
 Controls the process of creating everything.
Automatically called by Foundry upon submission of FormApplication Controls the process of creating everything .
// Make a journal entry to tie fake notes to or find the old one // If no "real" journal entry is provided than the map notes fail // to show up, hence why this block of code exists. // TODO: Investigate better way than adding a random journal entry. // Make the scene // get icons to use for notes // import our data // Start prepping notes // Assemble data required for notes // For some reason there's a 0 at the beginning. // Some provinces do not have a burg... For now we skip those. // Assemble data required for notes // For some reason there's a {} at the beginning. // Assemble data required for notes // entryId must be a valid journal entry (NOT from compendium, otherwise things really break.) // Remove all falsy values. // Make all of our notes, in one call to the db.