Skip to content

Commit

Permalink
v0.3.3 (#36)
Browse files Browse the repository at this point in the history
* Fixed editable inputs cutting off text after double quotation character
* Added popup when attempting to close the Quest Form window without submitting.
* Added option to link quests in rich text environments with `@Quest[id]` and `@Quest[quest name]`. Hacky way, might be unstable.
* Added Configuration setting that allows GM turn off displaying Welcome Screen to players. Enabled by default
* Added "Help" button in Quest Log's header that allows to open Welcome Screen at any time.
  • Loading branch information
Forien committed Jun 23, 2020
1 parent ffc6c78 commit f7b42bc
Show file tree
Hide file tree
Showing 18 changed files with 208 additions and 25 deletions.
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## v0.3.X

### v0.3.3
* Fixed editable inputs cutting off text after double quotation character
* Added popup when attempting to close the Quest Form window without submitting.
* Added option to link quests in rich text environments with `@Quest[id]` and `@Quest[quest name]`. Hacky way, might be unstable.
* Added Configuration setting that allows GM turn off displaying Welcome Screen to players. Enabled by default
* Added "Help" button in Quest Log's header that allows to open Welcome Screen at any time.

### v0.3.2
* Added French translation provided by Discord members rectulo and Naoki
* Abstract Rewards now are a little transparent (0.9 opacity) and their text is in italic
Expand Down
12 changes: 12 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@
"Cancel": "Cancel"
},

"CloseDialog": {
"Title": "Leave Form",
"Header": "Are you sure?",
"Body": "Are you sure you want to close the form? Unsaved data will be lost.",
"Discard": "Discard changes",
"Cancel": "Cancel"
},

"Notifications": {
"CannotOpen": "Cannot open Quest Details. You may lack permissions, Quest might not exist anymore, or provided ID was invalid.",
"UserCantOpen": "User {user} doesn't have permission to open this quest.",
Expand Down Expand Up @@ -115,6 +123,10 @@
"EnableHint": "Decide how to position quests' titles in Quest Log's table.",
"left": "Aligned to left",
"center": "Centered"
},
"playersWelcomeScreen": {
"Enable": "Display Welcome Screen to Players",
"EnableHint": "Uncheck to prevent players from seeing Welcome Screen on log in after an update. They might still see it by clicking 'help' icon in Quest Log."
}
},

Expand Down
11 changes: 9 additions & 2 deletions lang/missing/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"ForienQuestLog.Api.hooks.createOpenQuestMacro.name": "",
"ForienQuestLog.Notifications.CannotOpen": "",
"ForienQuestLog.Api.create.title": "",
"ForienQuestLog.CloseDialog.Title": "",
"ForienQuestLog.CloseDialog.Header": "",
"ForienQuestLog.CloseDialog.Body": "",
"ForienQuestLog.CloseDialog.Cancel": "",
"ForienQuestLog.CloseDialog.Discard": "",
"ForienQuestLog.QuestPreview.InvalidQuestId": "",
"ForienQuestLog.QuestPreview.HeaderButtons.Show": "",
"ForienQuestLog.SampleReward": "",
Expand All @@ -11,12 +16,14 @@
"ForienQuestLog.Api.reward.create.type": "",
"ForienQuestLog.Api.reward.create.data": "",
"ForienQuestLog.Api.task.create.name": "",
"ForienQuestLog.Settings.showFolder.Enable": "",
"ForienQuestLog.Settings.showFolder.EnableHint": "",
"ForienQuestLog.Settings.availableQuests.Enable": "",
"ForienQuestLog.Settings.availableQuests.EnableHint": "",
"ForienQuestLog.Settings.allowPlayersDrag.Enable": "",
"ForienQuestLog.Settings.allowPlayersDrag.EnableHint": "",
"ForienQuestLog.Settings.playersWelcomeScreen.Enable": "",
"ForienQuestLog.Settings.playersWelcomeScreen.EnableHint": "",
"ForienQuestLog.Settings.showFolder.Enable": "",
"ForienQuestLog.Settings.showFolder.EnableHint": "",
"ForienQuestLog.Notifications.UserCantOpen": "",
"ForienQuestLog.Tooltips.SetAvailable": "",
"ForienQuestLog.Tooltips.TaskHidden": "",
Expand Down
10 changes: 9 additions & 1 deletion lang/missing/fr.json
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
{}
{
"ForienQuestLog.CloseDialog.Title": "",
"ForienQuestLog.CloseDialog.Header": "",
"ForienQuestLog.CloseDialog.Body": "",
"ForienQuestLog.CloseDialog.Cancel": "",
"ForienQuestLog.CloseDialog.Discard": "",
"ForienQuestLog.Settings.playersWelcomeScreen.Enable": "",
"ForienQuestLog.Settings.playersWelcomeScreen.EnableHint": ""
}
11 changes: 9 additions & 2 deletions lang/missing/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"ForienQuestLog.Api.hooks.createOpenQuestMacro.name": "",
"ForienQuestLog.Notifications.CannotOpen": "",
"ForienQuestLog.Api.create.title": "",
"ForienQuestLog.CloseDialog.Title": "",
"ForienQuestLog.CloseDialog.Header": "",
"ForienQuestLog.CloseDialog.Body": "",
"ForienQuestLog.CloseDialog.Cancel": "",
"ForienQuestLog.CloseDialog.Discard": "",
"ForienQuestLog.QuestPreview.InvalidQuestId": "",
"ForienQuestLog.QuestPreview.HeaderButtons.Show": "",
"ForienQuestLog.SampleReward": "",
Expand All @@ -11,12 +16,14 @@
"ForienQuestLog.Api.reward.create.type": "",
"ForienQuestLog.Api.reward.create.data": "",
"ForienQuestLog.Api.task.create.name": "",
"ForienQuestLog.Settings.showFolder.Enable": "",
"ForienQuestLog.Settings.showFolder.EnableHint": "",
"ForienQuestLog.Settings.availableQuests.Enable": "",
"ForienQuestLog.Settings.availableQuests.EnableHint": "",
"ForienQuestLog.Settings.allowPlayersDrag.Enable": "",
"ForienQuestLog.Settings.allowPlayersDrag.EnableHint": "",
"ForienQuestLog.Settings.playersWelcomeScreen.Enable": "",
"ForienQuestLog.Settings.playersWelcomeScreen.EnableHint": "",
"ForienQuestLog.Settings.showFolder.Enable": "",
"ForienQuestLog.Settings.showFolder.EnableHint": "",
"ForienQuestLog.Notifications.UserCantOpen": "",
"ForienQuestLog.Tooltips.SetAvailable": "",
"ForienQuestLog.Tooltips.TaskHidden": "",
Expand Down
10 changes: 9 additions & 1 deletion lang/missing/ko.json
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
{}
{
"ForienQuestLog.CloseDialog.Title": "",
"ForienQuestLog.CloseDialog.Header": "",
"ForienQuestLog.CloseDialog.Body": "",
"ForienQuestLog.CloseDialog.Cancel": "",
"ForienQuestLog.CloseDialog.Discard": "",
"ForienQuestLog.Settings.playersWelcomeScreen.Enable": "",
"ForienQuestLog.Settings.playersWelcomeScreen.EnableHint": ""
}
9 changes: 9 additions & 0 deletions lang/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
"ForienQuestLog.Settings.titleAlign.left": "Wyrównaj do lewej",
"ForienQuestLog.Settings.titleAlign.center": "Wyśrodkuj",

"ForienQuestLog.Settings.playersWelcomeScreen.Enable": "Pokazuj graczom Ekran Powitalny",
"ForienQuestLog.Settings.playersWelcomeScreen.EnableHint": "Odznacz, aby graczom nie wyświetlać po zalogowaniu Ekranu Powitalnego z każdą nową wersją. Gracze wciąż mogą go wyświetlić klikając na ikonę \"pomocy\" w Dzienniku Misji.",",",

"ForienQuestLog.QuestForm.Title": "Stwórz nową Misję",
"ForienQuestLog.QuestForm.QuestGiver": "Zleceniodawca",
"ForienQuestLog.QuestForm.QuestGiverPlaceholder": "Imię lub ID Aktora",
Expand Down Expand Up @@ -81,6 +84,12 @@
"ForienQuestLog.DeleteDialog.Delete": "Usuń",
"ForienQuestLog.DeleteDialog.Cancel": "Anuluj",

"ForienQuestLog.CloseDialog.Title": "Opuszczasz formularz",
"ForienQuestLog.CloseDialog.Header": "Czy na pewno?",
"ForienQuestLog.CloseDialog.Body": "Opuszczasz formularz bez zapisania go. Jeśli to zrobisz, utracisz niezapisane zmiany.",
"ForienQuestLog.CloseDialog.Cancel": "Anuluj",
"ForienQuestLog.CloseDialog.Discard": "Odrzuć zmiany",

"ForienQuestLog.Tooltips.ToggleImage": "Przełącz obraz Aktora/Tokenu",
"ForienQuestLog.Tooltips.SetActive": "Ustaw na Aktywną",
"ForienQuestLog.Tooltips.SetCompleted": "Ustaw jako Zakończoną",
Expand Down
8 changes: 4 additions & 4 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
"url": "https://www.patreon.com/forien"
}
],
"version": "0.3.2",
"version": "0.3.3",
"minimumCoreVersion": "0.6.0",
"compatibleCoreVersion": "0.6.3",
"url": "https://github.com/Forien/foundryvtt-forien-quest-log",
"manifest": "https://raw.githubusercontent.com/Forien/foundryvtt-forien-quest-log/master/module.json",
"download": "https://github.com/Forien/foundryvtt-forien-quest-log/releases/download/v0.3.2/v0.3.2.zip",
"readme": "https://github.com/Forien/foundryvtt-forien-quest-log/blob/v0.3.2/README.md",
"changelog": "https://github.com/Forien/foundryvtt-forien-quest-log/blob/v0.3.2/changelog.md",
"download": "https://github.com/Forien/foundryvtt-forien-quest-log/releases/download/v0.3.3/v0.3.3.zip",
"readme": "https://github.com/Forien/foundryvtt-forien-quest-log/blob/v0.3.3/README.md",
"changelog": "https://github.com/Forien/foundryvtt-forien-quest-log/blob/v0.3.3/changelog.md",
"bugs": "https://github.com/Forien/foundryvtt-forien-quest-log/issues",
"languages": [
{
Expand Down
11 changes: 11 additions & 0 deletions modules/api/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,15 @@ export default function registerApiHooks() {
}
return false;
});

// open quest details on link click
$('body').on("click", "a.entity-link[data-entity='Quest']", function (event) {
event.preventDefault();
event.stopImmediatePropagation();
const a = event.currentTarget;

Quests.open(a.dataset.id);

return false;
});
}
39 changes: 36 additions & 3 deletions modules/apps/quest-form.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import Quest from "../entities/quest.mjs";
import Socket from "../utility/socket.mjs";

export default class QuestForm extends FormApplication {
submitted = false;

/**
* Default Application options
*
Expand Down Expand Up @@ -49,7 +51,6 @@ export default class QuestForm extends FormApplication {
*
* @param event
* @param formData
* @returns {Promise<void>}
* @private
*/
async _updateObject(event, formData) {
Expand Down Expand Up @@ -88,17 +89,49 @@ export default class QuestForm extends FormApplication {

let folder = this.getHiddenFolder();

JournalEntry.create({
return JournalEntry.create({
name: title,
content: JSON.stringify(data),
folder: folder._id
}).then(() => {
}).then((promise) => {
QuestLog.render(true);
// players don't see Hidden tab, but assistant GM can, so emit anyway
Socket.refreshQuestLog();
this.submitted = true;
return promise;
});
}


async close() {
if (this.submitted) {
return super.close();
}

new Dialog({
title: game.i18n.localize("ForienQuestLog.CloseDialog.Title"),
content: `<h3>${game.i18n.localize("ForienQuestLog.CloseDialog.Header")}</h3>
<p>${game.i18n.localize("ForienQuestLog.CloseDialog.Body")}</p>`,
buttons: {
no: {
icon: `<i class="fas fa-undo"></i>`,
label: game.i18n.localize("ForienQuestLog.CloseDialog.Cancel")
},
yes: {
icon: `<i class="far fa-trash-alt"></i>`,
label: game.i18n.localize("ForienQuestLog.CloseDialog.Discard"),
callback: () => {
this.submitted = true;
this.close();
}
}
},
default: "no"
}).render(true);


}

/**
* Fired whenever any of TinyMCE editors is saved.
* Just pass data to object's property, we handle save in one go after submit
Expand Down
14 changes: 14 additions & 0 deletions modules/apps/quest-log.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Quest from "../entities/quest.mjs";
import QuestPreview from "./quest-preview.mjs";
import QuestForm from "./quest-form.mjs";
import renderWelcomeScreen from "../versioning/welcome-screen.mjs";

export default class QuestLog extends Application {
sortBy = null;
Expand All @@ -25,6 +26,19 @@ export default class QuestLog extends Application {
});
}

_getHeaderButtons() {
const buttons = super._getHeaderButtons();

buttons.unshift({
label: "",
class: "help",
icon: "fas fa-question-circle",
onclick: ev => renderWelcomeScreen()
});

return buttons
}

/**
* Retrieves Data to be used in rendering template.
*
Expand Down
1 change: 1 addition & 0 deletions modules/apps/quest-preview.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ export default class QuestPreview extends FormApplication {
value = this.quest.tasks[index].name;
}

value = value.replace(/"/g, '&quot;');
let input = $(`<input type="text" class="editable-input" value="${value}" data-target="${target}" ${index !== undefined ? `data-index="${index}"` : ``}/>`);
let parent = $(event.target).parent('.editable-container');

Expand Down
28 changes: 28 additions & 0 deletions modules/entities/collection/quests-collection.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Class that acts "kind of" like Entity, to help Manage everything Quest Related
* in a more structured way, than to call JournalEntry every time.
*/
import Quest from "../quest.mjs";

export default class QuestsCollection {
constructor() {
let quests = Quest.getQuests();
let entities = [...quests.active, ...quests.completed, ...quests.failed, ...quests.hidden];

this.entities = entities.map(e => {
let data = e;
data.name = data.title;

return {
_id: e.id,
id: e.id,
name: e.title,
data: data
}
})
}

get(questId) {
return Quest.get(questId);
}
}
11 changes: 11 additions & 0 deletions modules/entities/quest.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Utils from "../utility/utils.mjs";
import QuestFolder from "./quest-folder.mjs";
import Reward from "./reward.mjs";
import Task from "./task.mjs";
import QuestsCollection from "./collection/quests-collection.mjs";

/**
* Class that acts "kind of" like Entity, to help Manage everything Quest Related
Expand Down Expand Up @@ -535,6 +536,14 @@ export default class Quest {
this._personal = (value === true);
}

static get collection() {
return new QuestsCollection();
}

get name() {
return this._title;
}

toJSON() {
return {
actor: this._actor,
Expand All @@ -548,3 +557,5 @@ export default class Quest {
}
}
}

window.Quest = Quest;
11 changes: 10 additions & 1 deletion modules/init.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@ import Socket from "./utility/socket.mjs";
import Utils from "./utility/utils.mjs";
import VersionCheck from "./versioning/version-check.mjs";
import renderWelcomeScreen from "./versioning/welcome-screen.mjs";
import Quest from "./entities/quest.mjs";


Hooks.once('init', () => {
ModuleSettings.register();

CONST.ENTITY_LINK_TYPES.push("Quest");
CONFIG["Quest"] = {
entityClass: Quest,
sidebarIcon: 'far fa-question-circle',
};

Utils.preloadTemplates();

Hooks.callAll("ForienQuestLog.afterInit");
Expand All @@ -29,7 +36,9 @@ Hooks.once("ready", () => {
QuestFolder.initializeJournals();

if (VersionCheck.check(constants.moduleName)) {
renderWelcomeScreen();
if (game.user.isGM || game.settings.get('forien-quest-log', 'playersWelcomeScreen')) {
renderWelcomeScreen();
}
Utils.updateMacros();
}

Expand Down
Loading

0 comments on commit f7b42bc

Please sign in to comment.