Skip to content

Commit

Permalink
welcome back screen
Browse files Browse the repository at this point in the history
  • Loading branch information
ultrakorne committed Jun 27, 2020
1 parent f646d45 commit bf0acfc
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 1 deletion.
10 changes: 9 additions & 1 deletion scripts/brt-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import { BetterRT } from './better-table-view.js';
import { BRTCONFIG } from './core/config.js';
import { i18n } from './core/utils.js';
import { BetterTables } from './better-tables.js';
import VersionCheck from './versioning/version-check.mjs';
import renderWelcomeScreen from "./versioning/welcome-screen.mjs";

// CONFIG.debug.hooks = true;

Hooks.on("init", function () {
Hooks.on("init", () => {
/** checks if the first argument is equal to any of the subsequent arguments */
Handlebars.registerHelper('ifcontain', function () {
let options = arguments[arguments.length - 1];
Expand All @@ -19,6 +21,12 @@ Hooks.on("init", function () {
game.betterTables = new BetterTables();
});

Hooks.on("ready", () => {
if (VersionCheck.check(BRTCONFIG.NAMESPACE) && game.user.isGM) {
renderWelcomeScreen();
}
});

Hooks.on("renderRollTableConfig", BetterRT.enhanceRollTableView);
Hooks.on("preUpdateRollTable", BetterRT.preUpdateRollTable);

Expand Down
38 changes: 38 additions & 0 deletions scripts/versioning/version-check.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Version check function from Forien Unedintified item module
*/
export default class VersionCheck {
static _r = false;

static _reg(mN) {
if (this._r) return;

game.settings.register(mN, 'version', {
name: `${mN} Version`,
default: "0.0.0",
type: String,
scope: 'client',
});

this._r = true;
}

static check(mN) {
if (!this._r) this._reg(mN);

let mV = this.get(mN);
let oV = game.settings.get(mN, "version");

return isNewerVersion(mV, oV);
};

static set(mN, v) {
if (!this._r) this._reg(mN);

game.settings.set(mN, "version", v);
}

static get(mN) {
return game.modules.get(mN).data.version;
}
}
41 changes: 41 additions & 0 deletions scripts/versioning/welcome-screen.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { BRTCONFIG } from '../core/config.js';
import VersionCheck from "./version-check.mjs";

/**
* Based on https://github.com/Moerill/mess
* modified by Forien
*/
class WelcomeScreen extends Application {
static get defaultOptions() {
let title = game.modules.get(BRTCONFIG.NAMESPACE).data.title;
return mergeObject(super.defaultOptions, {
template: `modules/${BRTCONFIG.NAMESPACE}/templates/welcome-screen.html`,
resizable: true,
width: 450,
height: 636,
classes: ["welcome-screen"],
title: `${title} - Welcome Screen`
});
}

getData(options = {}) {
options = super.getData(options);;
options.isChecked = !VersionCheck.check(BRTCONFIG.NAMESPACE);
return options;
}

activateListeners(html) {
super.activateListeners(html);

html.find('.show-again').on('change', event => {
let version = "0.0.0";
if (event.currentTarget.checked)
version = VersionCheck.get(BRTCONFIG.NAMESPACE);
VersionCheck.set(BRTCONFIG.NAMESPACE, version)
})
}
}

export default function renderWelcomeScreen() {
(new WelcomeScreen()).render(true);
}
37 changes: 37 additions & 0 deletions templates/welcome-screen.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!--
/**
* Based on https://github.com/Moerill/mess
*/
-->
<style>
.welcome-screen a[href] {
color: #4a52ca;
}
.welcome-screen .window-content > * {
flex: 0;
}
</style>

<h1>Welcome to Better RollTables!</h1>
<p>Check the <a href="https://github.com/ultrakorne/better-rolltables/blob/master/README.md">README</a> or <a href="https://github.com/ultrakorne/better-rolltables/wiki">wiki</a> for more info on the module features</p>
<h3><a href="https://www.youtube.com/watch?v=TRg4y0joOKA&feature=youtu.be"> Youtube Better Tables Overview! </a></h3>
<h2>Bugs or Suggestions?</h2>
<p>Add an <a href="https://github.com/ultrakorne/better-rolltables/issues">issue on Github</a> or drop me a line on Discord!</p>

<p style="font-weight: bold; text-align: right;">Ultrakorne#6240</p>

<p style="display: flex; flex-flow: row nowrap; align-items: center; justify-content: flex-start;"><input type="checkbox" class='show-again' id="welcome-screen-show-again" {{checked isChecked}}/> <label for="welcome-screen-show-again">Don't show this screen again until next update.</label></p>
<p style="text-align: right"><strong>My Tip Jar: <a href="paypal.me/ultrakorne">Paypal</a></strong></p>

<h1>Patchnotes</h1>
<h2 id="v140">v1.4.0</h2>
<ul>
<li>New Welcome screen with patchnotes!</li>
<li>New Tables with a lot of Human names, Orc names and surnames (check inside the Story Tables). They will be used in NPC Generators in future releases</li>
<li>Localized in Portoguese (thanks to rinnocenti)</li>
<li>Korean Localization updated (thanks KLO)</li>
</ul>
<h2 id="v130">v1.3.0</h2>
<ul>
<li>new API to generate Tables from compendia! (check how in the <a href="https://github.com/ultrakorne/better-rolltables/wiki/API-for-macros-and-modules#how-to-generate-tables-from-compendia"> wiki</a>)</li>
</ul>

0 comments on commit bf0acfc

Please sign in to comment.