From 1a899ba0dbd62709d2a67712c1aa3ff36c74d2f6 Mon Sep 17 00:00:00 2001 From: Ken Date: Thu, 6 Apr 2023 23:13:22 -0700 Subject: [PATCH] update gurps Import GCA5. Added a button to delete repeating sections/tables before importing a character. --- GURPS/gurps.css | 10 +++++- GURPS/gurps.html | 82 +++++++++++++++++++++++++++++++++++++++++- GURPS/translation.json | 2 ++ 3 files changed, 92 insertions(+), 2 deletions(-) diff --git a/GURPS/gurps.css b/GURPS/gurps.css index d9aa7ca36b..442b4ba463 100644 --- a/GURPS/gurps.css +++ b/GURPS/gurps.css @@ -5438,4 +5438,12 @@ input[name="attr_armor_show_back"][value="on"] ~ .repcontainer .repitem .sheet-h display: block; height: 0; clear: both; - } \ No newline at end of file +} + +input[name="attr_import_confirm_delete_tables"][value="0"] ~ button[name="act_import_delete_tables"] { + background-color: gray; +} + +input[name="attr_import_confirm_delete_tables"][value="1"] ~ button[name="act_import_delete_tables"] { + background-color: var(--highlight-text); +} \ No newline at end of file diff --git a/GURPS/gurps.html b/GURPS/gurps.html index 4fda6b8e50..3159232d2e 100644 --- a/GURPS/gurps.html +++ b/GURPS/gurps.html @@ -4365,6 +4365,9 @@ Inventory Tab. Added a Sort & Indent button. The button will sort the inventory alphabetically and then update the indent level of a child item. +
  • + Import GCA5. Added a button to delete repeating secdtions/tables before importing a character. +
  • @@ -14731,6 +14734,9 @@ Select the indent level of the inventory item. This is handy to help show the it Inventory Tab. Added a Sort & Indent button. The button will sort the inventory alphabetically and then update the indent level of a child item. +
  • + Import GCA5. Added a button to delete repeating secdtions/tables before importing a character. +
  • Version: 2.9.7

    @@ -17219,6 +17225,23 @@ Diffuse: Max 2HP (Exception: Area-effect, cone, and explosion attacks cause norm +
    + + + +
    +
    @@ -19811,6 +19834,7 @@ Diffuse: Max 2HP (Exception: Area-effect, cone, and explosion attacks cause norm self.dispatchEvent(ev); return oldAcid; } + var _sIn = setInterval; setInterval = function (callback, timeout) { var acid = getActiveCharacterId(); @@ -19822,6 +19846,7 @@ Diffuse: Max 2HP (Exception: Area-effect, cone, and explosion attacks cause norm } , timeout); } + var _sto = setTimeout setTimeout = function (callback, timeout) { var acid = getActiveCharacterId(); @@ -19833,6 +19858,7 @@ Diffuse: Max 2HP (Exception: Area-effect, cone, and explosion attacks cause norm } , timeout); } + function getAttrsAsync(props) { var acid = getActiveCharacterId(); //save the current activeCharacterID in case it has changed when the promise runs var prevAcid = null; //local variable defined here, because it needs to be shared across the promise callbacks defined below @@ -19846,6 +19872,7 @@ Diffuse: Max 2HP (Exception: Area-effect, cone, and explosion attacks cause norm setActiveCharacterId(prevAcid); //restore activeCharcterId to what it was when the promise first ran }); } + //use the same pattern for each of the following... function setAttrsAsync(propObj, options) { var acid = getActiveCharacterId(); @@ -19874,6 +19901,7 @@ Diffuse: Max 2HP (Exception: Area-effect, cone, and explosion attacks cause norm setActiveCharacterId(prevAcid); }); } + function getSingleAttrAsync(prop) { var acid = getActiveCharacterId(); var prevAcid = null; @@ -36368,6 +36396,32 @@ B378 }); + on("clicked:import_delete_tables", async (event) => { + + const values = await getAttrsAsync(["import_confirm_delete_tables"]); + + const canDelete = values.import_confirm_delete_tables === "1"; + + if (canDelete) { + await clearRepeatingSectionAsync("repeating_languages"); + await clearRepeatingSectionAsync("repeating_cultures"); + await clearRepeatingSectionAsync("repeating_traits"); + await clearRepeatingSectionAsync("repeating_perks"); + await clearRepeatingSectionAsync("repeating_quirks"); + await clearRepeatingSectionAsync("repeating_disadvantages"); + await clearRepeatingSectionAsync("repeating_racial"); + await clearRepeatingSectionAsync("repeating_skills"); + await clearRepeatingSectionAsync("repeating_techniquesrevised"); + await clearRepeatingSectionAsync("repeating_defense"); + await clearRepeatingSectionAsync("repeating_melee"); + await clearRepeatingSectionAsync("repeating_ranged"); + await clearRepeatingSectionAsync("repeating_item"); + await clearRepeatingSectionAsync("repeating_spells"); + setAttrsAsync({import_confirm_delete_tables: 0}); + } + + }); + on("clicked:import_json_reset", (event) => { setAttrs({ @@ -36380,7 +36434,9 @@ B378 let importCharacterJson = async () => { - let values = await getAttrsAsync(["character_json_data"]); + let values = await getAttrsAsync(["character_json_data", "import_delete_tables"]); + + const deleteTables = values.import_delete_tables === "1"; let data = String(values.character_json_data).trim(); @@ -36469,6 +36525,30 @@ B378 } + /** + * Delete all rows from a repeating section + * + * @param string table Example: repeating_item + * + */ + let clearRepeatingSectionAsync = async (table) => { + + let ids = await getSectionIDsAsync(table); + + if (ids.length === 0) { + return; + } + + // loop through the rows + for (let i = 0; i < ids.length; i++) { + + let rowId = ids[i]; + + removeRepeatingRow(`${table}_${rowId}`); + } + + } + let getUniqueKeysForCharacter = async () => { let uniqueKeys = {}; diff --git a/GURPS/translation.json b/GURPS/translation.json index 3a0163b14d..ea575d7202 100644 --- a/GURPS/translation.json +++ b/GURPS/translation.json @@ -1271,6 +1271,8 @@ "language-talent-tooltip": "If checked, you can learn languages at the next-highest level, if you spend 2 points on a langauge, instead of broken, you know the language at Accented level. This changes the available options in the drop-down and related costs. See B65.", "tips-label": "Tips", "import-tips-description": "

    After importing, compare your Roll20 sheet to GCA5 character sheet.

    Roll20 doesn't support parent/child relationship, repeating tables will be imported alphabetically.

    For GCA Roll20 Exporter Tool Version 1.0.1.9 or later, Rital Magic Spells will be added to the Grimoire with difficult set to T/H and points set to 0. The spell will also be added to the Techniques table with the actual character point cost.

    GCA5 Export to Roll20. Update 1.0.1.10. Fixes bug so item inventory uses base cost and weight instead of total cost and weight.

    ", + "delete-repeating-tables-question": "Delete tables?", + "delete-repeating-tables-question-tooltip": "If checked, the delete button will become active. This can be helpful if items were re-added or removed in the original application. The system is unable to delete tables and import them at the same time, so you have to delete the tables before importing.", "attribute-stress": "Stress", "attribute-stress-tooltip": "Stress level from GURPS Fourth Edition Edition.pdf page 141-142.
    On failed fright check, add -1 to Stress, on Critical Failure add -3!
    GM could add Stress for other reasons besides failed fright checks.
    Stress can be recovered by one for every ten minutes spent in mental relaxation.
    GM may rule that certain indulgences can erase an extra point of Stress.
    Important: If you go over the maximum stress level, apply the Stress to Derangement!", "abbreviation-derangement": "Derange",