From 7c6029f6ce34c4c55a502338ba34a5f3f0742cb7 Mon Sep 17 00:00:00 2001 From: ChapelR Date: Fri, 22 Jan 2021 03:54:01 -0500 Subject: [PATCH] v2.7.1 fixed issue in cycle macros event emitter --- docs/changelog.md | 4 ++++ package.json | 2 +- scripts/cycles.js | 2 +- scripts/minified/articles.min.js | 2 +- scripts/minified/continue.min.js | 2 +- scripts/minified/css-macro.min.js | 2 +- scripts/minified/cycles.min.js | 4 ++-- scripts/minified/dialog-api-macro-set.min.js | 2 +- scripts/minified/disable.min.js | 2 +- scripts/minified/done.min.js | 2 +- scripts/minified/events.min.js | 2 +- scripts/minified/fading-macro-set.min.js | 2 +- scripts/minified/first-macro.min.js | 2 +- scripts/minified/fs.min.js | 2 +- scripts/minified/message-macro.min.js | 2 +- scripts/minified/meters.min.js | 2 +- scripts/minified/mouseover.min.js | 2 +- scripts/minified/notify.min.js | 2 +- scripts/minified/operations.min.js | 2 +- scripts/minified/playtime.min.js | 2 +- scripts/minified/popover.min.js | 2 +- scripts/minified/preload.min.js | 2 +- scripts/minified/pronouns.min.js | 2 +- scripts/minified/simple-inventory.min.js | 2 +- scripts/minified/speech.min.js | 2 +- scripts/minified/swap-macro-set.min.js | 2 +- scripts/minified/type-sim.min.js | 2 +- scripts/minified/ui-macro.min.js | 2 +- 28 files changed, 32 insertions(+), 28 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 30b09be..decb05c 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,10 @@ [Back to the main page](./README.md). +### January 22, 2021 (v2.7.1) + +- **[Update]** Fixed the `:cycle-change` event so that it is now properly emitted. + ### November 24, 2020 (v2.7.0) - **[New]** Added the `<>` macro. diff --git a/package.json b/package.json index df307a7..261576c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "custom-macros-for-sugarcube-2", - "version": "2.7.0", + "version": "2.7.1", "description": "Collection of custom macros and systems for Twine/SugarCube2.", "main": "build.js", "directories": { diff --git a/scripts/cycles.js b/scripts/cycles.js index d90b20a..8f09964 100644 --- a/scripts/cycles.js +++ b/scripts/cycles.js @@ -203,7 +203,7 @@ } if (cache !== this.current()) { // the phase changed - Cycle._emit('change'); + Cycle._emit(this, 'change'); } return this; }, diff --git a/scripts/minified/articles.min.js b/scripts/minified/articles.min.js index 5482b2f..9095153 100644 --- a/scripts/minified/articles.min.js +++ b/scripts/minified/articles.min.js @@ -1,4 +1,4 @@ // articles.min.js, for SugarCube 2, by Chapel -// v1.0.0, 2020-11-24, 9f958db927f80b0101af14e286ea0ad142026739 +// v1.0.0, 2021-01-22, 404cc7678295ca61a8b0b8bc3fa5d54dba6ac858 ;!function(){"use strict";var e=new Map,r=["eunuch","eucalyptus","eugenics","eulogy","euphemism","euphony","euphoria","eureka","european","euphemistic","euphonic","euphoric","euphemistically","euphonically","euphorically","heir","heiress","herb","homage","honesty","honor","honour","hour","honest","honorous","honestly","hourly","one","ouija","once","ubiquitous","ugandan","ukrainian","unanimous","unicameral","unified","unique","unisex","universal","urinal","urological","useful","useless","usurious","usurped","utilitarian","utopic","ubiquitously","unanimously","unicamerally","uniquely","universally","urologically","usefully","uselessly","usuriously"],i=["a","an"],t=/[aeiou8]/i,n=/[A-Z]+$/,u=/[UFHLMNRSX]/,a=/[.,\/#!$%\^&\*;:{}=\-_`~()]/g;function o(e){return"a"===e?"an":"a"}function s(r,t,n){var u;return State.length>0?(u="cannot add article override -> needs to be run in StoryInit special passage or earlier",console.error(u),u):t&&"string"==typeof t?(r&&"string"==typeof r&&(r=r.toLowerCase().trim()),i.includes(r)?(t=t.trim(),void(n?e.set(t,{article:r,caseSensitive:!!n}):e.set(t.toLowerCase(),{article:r,caseSensitive:!!n}))):(u='cannot add article override -> invalid article, must be "a" or "an"',console.error(u),u)):(u="cannot add article override -> invalid word",console.error(u),u)}function l(e){var i;return i=t.test(e.first())?"an":"a",function(e,i){return!!r.includes(e.toLowerCase())&&o(i)}(e,i)||function(e,r){return!(!n.test(e)||!u.test(e.first()))&&o(r)}(e,i)||i}function c(r){if(r&&"string"==typeof r){var i=r.trim().split(" ")[0].trim();return function(r){var i=(r=r.trim()).toLowerCase();if(e.has(i)||e.has(r)){var t=e.get(i)||e.get(r);return t.caseSensitive&&!e.has(r)?null:t.article}return null}(i=i.replace(a,""))||l(i)}}function h(e,r){if(!e||"string"!=typeof e)return e;var i=c(e);return(r?i.toUpperFirst():i)+" "+e}setup.articles={find:c,output:h,override:s},Macro.add("setarticle",{handler:function(){var e=s(this.args[0],this.args[1],this.args[2]);e&&"string"==typeof e&&this.error(e)}}),Macro.add(["a","an","A","An"],{handler:function(){var e=this.name.first()===this.name.first().toUpperCase();this.output.append(h(String(this.args[0]),e))}})}(); // end articles.min.js \ No newline at end of file diff --git a/scripts/minified/continue.min.js b/scripts/minified/continue.min.js index 5c1ebce..83e915d 100644 --- a/scripts/minified/continue.min.js +++ b/scripts/minified/continue.min.js @@ -1,4 +1,4 @@ // continue.min.js, for SugarCube 2, by Chapel -// v1.0.1, 2020-11-24, 9f958db927f80b0101af14e286ea0ad142026739 +// v1.0.1, 2021-01-22, 404cc7678295ca61a8b0b8bc3fa5d54dba6ac858 ;!function(){"use strict";var n=["a",":button",'*[role="button"]',".continue-macro-ignore","#ui-bar","#ui-dialog"],t=0;function o(){$(document).on("click.continue-macro keyup.continue-macro",n.join(", "),(function(n){n.stopPropagation()}))}function e(){if(State.length>0)return!1;var t=[].slice.call(arguments).flatten();return n=n.concat(t),!0}function c(n,o){var e=function(){var n="."+Date.now().toString(36)+"-"+t;return t++,n}();if(o&&"function"==typeof o){var c="click.continue-macro"+e;n&&(c=c+" keyup.continue-macro"+e),$(document).one(c,(function(){o.call(),$(document).off(e)}))}}prehistory["%%continue-expiration"]=function(){t=0},$(document).one(":passagerender",(function(){o()})),Macro.add("ignore",{handler:function(){if(!e(this.args))return this.error("the <> macro should only be run from StoryInit or equivalent.")}}),Macro.add("cont",{tags:null,handler:function(){var n,t=this.args.includes("append"),o=this.args.includesAny("key","keypress","press","button"),e=this.payload[0].contents;t&&(n=$(document.createElement("span")).addClass("macro-"+this.name).appendTo(this.output)),c(o,this.createShadowWrapper((function(){t&&n&&n instanceof $?n.wiki(e):$.wiki(e)})))}}),setup.cont=c,setup.cont.ignore=e,setup.cont.reset=function(){var t=[].slice.call(arguments).flatten();n=n.concat(t),$(document).off(".continue-macro"),o()},window.cont=window.cont||setup.cont}(); // end continue.min.js \ No newline at end of file diff --git a/scripts/minified/css-macro.min.js b/scripts/minified/css-macro.min.js index 8a7bf4a..c480b03 100644 --- a/scripts/minified/css-macro.min.js +++ b/scripts/minified/css-macro.min.js @@ -1,4 +1,4 @@ // css-macro.min.js, for SugarCube 2, by Chapel -// v1.0.0, 2020-11-24, 9f958db927f80b0101af14e286ea0ad142026739 +// v1.0.0, 2021-01-22, 404cc7678295ca61a8b0b8bc3fa5d54dba6ac858 ;!function(){"use strict";function t(t){if(t.length%2!=0)return"Style rules should be a list of key/value pairs; you've passed an odd number.";var r={};return t.forEach((function(e,n){n%2==0&&(r[e]=t[n+1])})),r}function r(t,r){try{return"string"==typeof r?r:(t instanceof jQuery||(t=$(t)),t.css(r))}catch(t){return t.message}}Macro.add("css",{handler:function(){var e=function(){try{var e,n=[].slice.call(arguments).flatten(),s=n.shift();return"string"==typeof n[0]?e=t(n):"object"==typeof n[0]&&(e=clone(n[0])),r(s,e)}catch(t){return t.message}}(this.args);if("string"==typeof e)return this.error(e)}})}(); // end css-macro.min.js \ No newline at end of file diff --git a/scripts/minified/cycles.min.js b/scripts/minified/cycles.min.js index 67bacb0..6116115 100644 --- a/scripts/minified/cycles.min.js +++ b/scripts/minified/cycles.min.js @@ -1,4 +1,4 @@ // cycles.min.js, for SugarCube 2, by Chapel -// v2.1.1, 2020-11-24, 9f958db927f80b0101af14e286ea0ad142026739 -;!function(){"use strict";var e="%%cycles",t=!0,r="cycles.pause",i="cycles.pause.menu",n="cycles.postdisplay";function s(){return State.variables[e]}function a(e,t){if(!(this instanceof a))return new a(e,t);if(!e||"object"!=typeof e)throw new Error("Cycle() -> invalid definition object");if(!e.name||"string"!=typeof e.name||!e.name.trim())throw new Error("Cycle() -> invalid name");if(this.name=e.name,!e.phases||!Array.isArray(e.phases)||e.phases.length<2)throw new Error("Cycle() -> phases should be an array of at least two strings");if(!e.phases.every((function(e){return e&&"string"==typeof e&&e.trim()})))throw new Error("Cycle() -> each phase should be a valid, non-empty string");this.phases=clone(e.phases),e.period=Number(e.period),(Number.isNaN(e.period)||e.period<1)&&(e.period=1),Number.isInteger(e.period)||(e.period=Math.trunc(e.period)),this.period=e.period,e.increment=Number(e.increment),(Number.isNaN(e.increment)||e.increment<1)&&(e.increment=1),Number.isInteger(e.increment)||(e.increment=Math.trunc(e.increment)),this.increment=e.increment,this.active=void 0===e.active||!!e.active,t=Number(t),(Number.isNaN(t)||t<0)&&(t=0),Number.isInteger(t)||(t=Math.trunc(t)),this.stack=t}State.variables[e]={},Object.assign(a,{is:function(e){return e instanceof a},add:function(e,t){if(!t||"object"!=typeof t)throw new Error("Cycle.add() -> invalid definition object");if(e&&"string"==typeof e&&e.trim())t.name=e;else if(!t.name||"string"!=typeof t.name||!t.name.trim())throw new Error("Cycle.add() -> invalid name");var r=new a(t,0);return s()[t.name]=r,r},has:function(e){var t=s();return t.hasOwnProperty(e)&&a.is(t[e])},get:function(e){return a.has(e)?s()[e]:null},del:function(e){return!!a.has(e)&&(delete s()[e],!0)},check:function(e){if(a.has(e)){var t=[].slice.call(arguments).flatten().slice(1);return a.get(e).check(t)}},clear:function(e){s()},_emit:function(e,t){$(document).trigger({type:":cycle-"+t,cycle:e})},_retrieveCycles:s}),Object.assign(a.prototype,{constructor:a,revive:function(){var e={};return Object.keys(this).forEach((function(t){e[t]=clone(this[t])}),this),e},clone:function(){return new a(this.revive(),this.stack)},toJSON:function(){return JSON.reviveWrapper("new setup.Cycle("+JSON.stringify(this.revive())+", "+this.stack+")")},current:function(){return this.phases[Math.trunc(this.stack/this.period)%this.phases.length]},length:function(){return this.period*this.phases.length},turns:function(){return this.period/this.increment},turnsTotal:function(){return this.length()/this.increment},update:function(e){e=Number(e),Number.isNaN(e)&&(e=this.increment);var t=this.current();return this.stack+=e,this.stack<0&&(this.stack=0),Number.isInteger(this.stack)||(this.stack=Math.trunc(this.stack)),t!==this.current()&&a._emit("change"),this},reset:function(){return this.stack=0,a._emit(this,"reset"),this.update(0)},suspend:function(){var e=this.active;return this.active=!1,e!==this.active&&a._emit(this,"suspend"),this},resume:function(){var e=this.active;return this.active=!0,e!==this.active&&a._emit(this,"resume"),this},toggle:function(){return this.active?this.suspend():this.resume(),this},isSuspended:function(){return!this.active},editIncrement:function(e){return e=Number(e),(!Number.isNaN(e)||e>0)&&(Number.isInteger(e)||(e=Math.trunc(e)),this.increment=e),this.increment},check:function(){var e=[].slice.call(arguments).flatten();return e.includes(this.current())}}),postdisplay[n]=function(){var e;tags().includes(r)||e?e=!1:tags().includes(i)?e=!0:Object.keys(s()).forEach((function(e){var t=a.get(e);t.active&&t.update()}))},setup.Cycle=a,t&&(window.Cycle=window.Cycle||a),Macro.add("newcycle",{tags:["phase"],handler:function(){if(this.args.length<1)return this.error("A cycle must at least be given a name.");if(this.payload.length<2)return this.error("A cycle must be given at least two phases.");var e=this.payload.slice(1).map((function(e){return function(e){if(e.args.length<1)return null;var t=e.args.flatten();return t.every((function(e){return"string"==typeof e}))?t:null}(e)})).flatten();if(e.includes(null))return this.error("Each `<>` tag must be given a valid name.");try{a.add(this.args[0],{phases:e,period:this.args[1],increment:this.args[2],active:this.args[3]&&"string"==typeof this.args[3]&&"suspend"!==this.args[3].trim()})}catch(e){var t=e.message&&e.message.split("->")[1];return t=!!t&&t.trim(),this.error(t||e.message)}}}),Macro.add("editcycle",{handler:function(){if(this.args.length<1||"string"!=typeof this.args[0]||!this.args[0].trim())return this.error("You must name the cycle you wish to act on.");if(this.args.length<2)return this.error("You must provide an action to perform.");var e=a.get(this.args[0]);if(null===e)return this.error('Cannot find a cycle named "'+this.args[0]+'".');if(this.args.includes("suspend")?e.suspend():this.args.includes("toggle")?e.toggle():this.args.includes("resume")&&e.resume(),this.args.includes("increment")){var t=this.args[this.args.indexOf("increment")+1];"number"==typeof t&&e.editIncrement(t)}if(this.args.includesAny("reset","clear")&&e.reset(),this.args.includes("change")){var r=this.args[this.args.indexOf("change")+1];r=Number(r),!Number.isNaN(r)&&Number.isInteger(r)&&e.update(r)}}}),Macro.add("showcycle",{handler:function(){if(this.args.length<1||"string"!=typeof this.args[0]||!this.args[0].trim())return this.error("You must name the cycle you wish to act on.");var e=a.get(this.args[0]);if(null===e)return this.error('Cannot find a cycle named "'+this.args[0]+'".');var t=e.current();this.args.includes("uppercase")?t=t.toUpperCase():this.args.includes("lowercase")?t=t.toLowerCase():this.args.includes("upperfirst")&&(t=t.toUpperFirst()),$(document.createElement("span")).addClass("macro-"+this.name).append(t).appendTo(this.output)}})}(); +// v2.1.1, 2021-01-22, 404cc7678295ca61a8b0b8bc3fa5d54dba6ac858 +;!function(){"use strict";var e="%%cycles",t=!0,r="cycles.pause",i="cycles.pause.menu",s="cycles.postdisplay";function n(){return State.variables[e]}function a(e,t){if(!(this instanceof a))return new a(e,t);if(!e||"object"!=typeof e)throw new Error("Cycle() -> invalid definition object");if(!e.name||"string"!=typeof e.name||!e.name.trim())throw new Error("Cycle() -> invalid name");if(this.name=e.name,!e.phases||!Array.isArray(e.phases)||e.phases.length<2)throw new Error("Cycle() -> phases should be an array of at least two strings");if(!e.phases.every((function(e){return e&&"string"==typeof e&&e.trim()})))throw new Error("Cycle() -> each phase should be a valid, non-empty string");this.phases=clone(e.phases),e.period=Number(e.period),(Number.isNaN(e.period)||e.period<1)&&(e.period=1),Number.isInteger(e.period)||(e.period=Math.trunc(e.period)),this.period=e.period,e.increment=Number(e.increment),(Number.isNaN(e.increment)||e.increment<1)&&(e.increment=1),Number.isInteger(e.increment)||(e.increment=Math.trunc(e.increment)),this.increment=e.increment,this.active=void 0===e.active||!!e.active,t=Number(t),(Number.isNaN(t)||t<0)&&(t=0),Number.isInteger(t)||(t=Math.trunc(t)),this.stack=t}State.variables[e]={},Object.assign(a,{is:function(e){return e instanceof a},add:function(e,t){if(!t||"object"!=typeof t)throw new Error("Cycle.add() -> invalid definition object");if(e&&"string"==typeof e&&e.trim())t.name=e;else if(!t.name||"string"!=typeof t.name||!t.name.trim())throw new Error("Cycle.add() -> invalid name");var r=new a(t,0);return n()[t.name]=r,r},has:function(e){var t=n();return t.hasOwnProperty(e)&&a.is(t[e])},get:function(e){return a.has(e)?n()[e]:null},del:function(e){return!!a.has(e)&&(delete n()[e],!0)},check:function(e){if(a.has(e)){var t=[].slice.call(arguments).flatten().slice(1);return a.get(e).check(t)}},clear:function(e){n()},_emit:function(e,t){$(document).trigger({type:":cycle-"+t,cycle:e})},_retrieveCycles:n}),Object.assign(a.prototype,{constructor:a,revive:function(){var e={};return Object.keys(this).forEach((function(t){e[t]=clone(this[t])}),this),e},clone:function(){return new a(this.revive(),this.stack)},toJSON:function(){return JSON.reviveWrapper("new setup.Cycle("+JSON.stringify(this.revive())+", "+this.stack+")")},current:function(){return this.phases[Math.trunc(this.stack/this.period)%this.phases.length]},length:function(){return this.period*this.phases.length},turns:function(){return this.period/this.increment},turnsTotal:function(){return this.length()/this.increment},update:function(e){e=Number(e),Number.isNaN(e)&&(e=this.increment);var t=this.current();return this.stack+=e,this.stack<0&&(this.stack=0),Number.isInteger(this.stack)||(this.stack=Math.trunc(this.stack)),t!==this.current()&&a._emit(this,"change"),this},reset:function(){return this.stack=0,a._emit(this,"reset"),this.update(0)},suspend:function(){var e=this.active;return this.active=!1,e!==this.active&&a._emit(this,"suspend"),this},resume:function(){var e=this.active;return this.active=!0,e!==this.active&&a._emit(this,"resume"),this},toggle:function(){return this.active?this.suspend():this.resume(),this},isSuspended:function(){return!this.active},editIncrement:function(e){return e=Number(e),(!Number.isNaN(e)||e>0)&&(Number.isInteger(e)||(e=Math.trunc(e)),this.increment=e),this.increment},check:function(){var e=[].slice.call(arguments).flatten();return e.includes(this.current())}}),postdisplay[s]=function(){var e;tags().includes(r)||e?e=!1:tags().includes(i)?e=!0:Object.keys(n()).forEach((function(e){var t=a.get(e);t.active&&t.update()}))},setup.Cycle=a,t&&(window.Cycle=window.Cycle||a),Macro.add("newcycle",{tags:["phase"],handler:function(){if(this.args.length<1)return this.error("A cycle must at least be given a name.");if(this.payload.length<2)return this.error("A cycle must be given at least two phases.");var e=this.payload.slice(1).map((function(e){return function(e){if(e.args.length<1)return null;var t=e.args.flatten();return t.every((function(e){return"string"==typeof e}))?t:null}(e)})).flatten();if(e.includes(null))return this.error("Each `<>` tag must be given a valid name.");try{a.add(this.args[0],{phases:e,period:this.args[1],increment:this.args[2],active:this.args[3]&&"string"==typeof this.args[3]&&"suspend"!==this.args[3].trim()})}catch(e){var t=e.message&&e.message.split("->")[1];return t=!!t&&t.trim(),this.error(t||e.message)}}}),Macro.add("editcycle",{handler:function(){if(this.args.length<1||"string"!=typeof this.args[0]||!this.args[0].trim())return this.error("You must name the cycle you wish to act on.");if(this.args.length<2)return this.error("You must provide an action to perform.");var e=a.get(this.args[0]);if(null===e)return this.error('Cannot find a cycle named "'+this.args[0]+'".');if(this.args.includes("suspend")?e.suspend():this.args.includes("toggle")?e.toggle():this.args.includes("resume")&&e.resume(),this.args.includes("increment")){var t=this.args[this.args.indexOf("increment")+1];"number"==typeof t&&e.editIncrement(t)}if(this.args.includesAny("reset","clear")&&e.reset(),this.args.includes("change")){var r=this.args[this.args.indexOf("change")+1];r=Number(r),!Number.isNaN(r)&&Number.isInteger(r)&&e.update(r)}}}),Macro.add("showcycle",{handler:function(){if(this.args.length<1||"string"!=typeof this.args[0]||!this.args[0].trim())return this.error("You must name the cycle you wish to act on.");var e=a.get(this.args[0]);if(null===e)return this.error('Cannot find a cycle named "'+this.args[0]+'".');var t=e.current();this.args.includes("uppercase")?t=t.toUpperCase():this.args.includes("lowercase")?t=t.toLowerCase():this.args.includes("upperfirst")&&(t=t.toUpperFirst()),$(document.createElement("span")).addClass("macro-"+this.name).append(t).appendTo(this.output)}})}(); // end cycles.min.js \ No newline at end of file diff --git a/scripts/minified/dialog-api-macro-set.min.js b/scripts/minified/dialog-api-macro-set.min.js index fc37441..8de3c78 100644 --- a/scripts/minified/dialog-api-macro-set.min.js +++ b/scripts/minified/dialog-api-macro-set.min.js @@ -1,4 +1,4 @@ // dialog-api-macro-set.min.js, for SugarCube 2, by Chapel -// v1.3.0, 2020-11-24, 9f958db927f80b0101af14e286ea0ad142026739 +// v1.3.0, 2021-01-22, 404cc7678295ca61a8b0b8bc3fa5d54dba6ac858 ;Macro.add("dialog",{tags:["onopen","onclose"],handler:function(){var t="",s=null,n=null,o=this.args.length>0?this.args[0]:"",e=this.args.length>1?this.args.slice(1).flatten():[];this.payload.forEach((function(o,e){0===e?t=o.contents:"onopen"===o.name?s=s?s+o.contents:o.contents:n=n?n+o.contents:o.contents})),e.push("macro-"+this.name),Dialog.setup(o,e.join(" ")),Dialog.wiki(t),s&&"string"==typeof s&&s.trim()&&$(document).one(":dialogopened",(function(){$.wiki(s)})),n&&"string"==typeof n&&n.trim()&&$(document).one(":dialogclosed",(function(){$.wiki(n)})),Dialog.open()}}),Macro.add("popup",{handler:function(){if(this.args.length<1)return this.error("need at least one argument; the passage to display");if(!Story.has(this.args[0]))return this.error("the passage "+this.args[0]+"does not exist");var t=this.args[0],s=this.args.length>1?this.args[1]:"",n=this.args.length>2?this.args.slice(2).flatten():[];n.push("macro-"+this.name),Dialog.setup(s,n.join(" ")),Dialog.wiki(Story.get(t).processText()),Dialog.open()}}),Macro.add("dialogclose",{skipArgs:!0,handler:function(){Dialog.close()}}); // end dialog-api-macro-set.min.js \ No newline at end of file diff --git a/scripts/minified/disable.min.js b/scripts/minified/disable.min.js index 446c7e2..1334b0a 100644 --- a/scripts/minified/disable.min.js +++ b/scripts/minified/disable.min.js @@ -1,4 +1,4 @@ // disable.min.js, for SugarCube 2, by Chapel -// v1.0.0, 2020-11-24, 9f958db927f80b0101af14e286ea0ad142026739 +// v1.0.0, 2021-01-22, 404cc7678295ca61a8b0b8bc3fa5d54dba6ac858 ;!function(){"use strict";var a=["button","fieldset","input","menuitem","optgroup","option","select","textarea"];Macro.add("disable",{tags:null,handler:function(){var t,i,e,s=$(document.createElement("span")).addClass("macro-"+this.name).wiki(this.payload[0].contents);try{t=this.args.raw.trim()?!!Scripting.evalJavaScript(this.args.full):void 0}catch(a){return this.error("bad evaluation: "+a.message)}!function(a,t){a instanceof $||(a=$(a)),a.ariaDisabled(void 0===t||!!t),function(a){a.ariaIsDisabled()?a.addClass("disabled"):a.removeClass("disabled")}(a)}((i=s,e=$(i).find(a.join(",")).first(),e[0]||(e=$(i).children().eq(0))[0]?e:$(i)),t),$(this.output).append(s)}})}(); // end disable.min.js \ No newline at end of file diff --git a/scripts/minified/done.min.js b/scripts/minified/done.min.js index 240e213..bed713d 100644 --- a/scripts/minified/done.min.js +++ b/scripts/minified/done.min.js @@ -1,4 +1,4 @@ // done.min.js, for SugarCube 2, by Chapel -// v1.0.1, 2020-11-24, 9f958db927f80b0101af14e286ea0ad142026739 +// v1.0.1, 2021-01-22, 404cc7678295ca61a8b0b8bc3fa5d54dba6ac858 ;!function(){var a=1;Macro.add("done",{skipArgs:!0,tags:null,handler:function(){var n=this.payload[0].contents.trim();""!==n&&(postdisplay[":chapel-done-macro-"+a]=function(a){delete postdisplay[a],$.wiki(n)},a++)}})}(); // end done.min.js \ No newline at end of file diff --git a/scripts/minified/events.min.js b/scripts/minified/events.min.js index a3140e0..8c88ada 100644 --- a/scripts/minified/events.min.js +++ b/scripts/minified/events.min.js @@ -1,4 +1,4 @@ // events.min.js, for SugarCube 2, by Chapel -// v2.0.0, 2020-11-24, 9f958db927f80b0101af14e286ea0ad142026739 +// v2.0.0, 2021-01-22, 404cc7678295ca61a8b0b8bc3fa5d54dba6ac858 ;setup.eventMacroNamespace="macro-event",Macro.add("trigger",{handler:function(){var t;return this.args.length>2||0===this.args.length?this.error("incorrect number of arguments"):"string"!=typeof this.args[0]?this.error("first argument should be a string and a valid event type"):(t=this.args[0],void(1===this.args.length||this.args[1]&&"string"==typeof this.args[1]&&"document"===this.args[1].toLowerCase().trim()?$(document):$(this.args[1])).trigger(t))}}),Macro.add(["event","on","one"],{tags:["which"],handler:function(){var t,r,s=this.payload,e="on",n="",a="";return this.args.length>3||0===this.args.length?this.error("incorrect number of arguments"):"string"!=typeof this.args[0]?this.error("first argument should be a string and a valid event type"):(2===this.args.length&&"string"==typeof this.args[1]&&"once"!==this.args[1]&&(n=this.args[1]),(this.args.includes("once")||"one"===this.name)&&(e="one"),t=this.args[0],void $(document)[e](t+"."+setup.eventMacroNamespace,n,(function(t){if(a=s[0].contents,s.length>1)for(r=1;r2||0===this.args.length?this.error("incorrect number of arguments"):"string"!=typeof this.args[0]?this.error("first argument should be a string and a valid event type or namespace"):(t=this.args[0],void(1===this.args.length||this.args[1]&&"string"==typeof this.args[1]&&"document"===this.args[1].toLowerCase().trim()?$(document):$(this.args[1])).off(t))}}); // end events.min.js \ No newline at end of file diff --git a/scripts/minified/fading-macro-set.min.js b/scripts/minified/fading-macro-set.min.js index e69c67b..ee89f5f 100644 --- a/scripts/minified/fading-macro-set.min.js +++ b/scripts/minified/fading-macro-set.min.js @@ -1,4 +1,4 @@ // fading-macro-set.min.js, for SugarCube 2, by Chapel -// v1.1.0, 2020-11-24, 9f958db927f80b0101af14e286ea0ad142026739 +// v1.1.0, 2021-01-22, 404cc7678295ca61a8b0b8bc3fa5d54dba6ac858 ;Macro.add("fadein",{tags:null,handler:function(){var t,a,s=$(document.createElement("span")),e=this.payload[0].contents;if(0===this.args.length)return this.error("no arguments given");t=Util.fromCssTime(this.args[0]),a=this.args.length>1?Util.fromCssTime(this.args[1]):0,s.wiki(e).addClass("macro-"+this.name).appendTo(this.output).hide().delay(a).fadeIn(t)}}),Macro.add("fadeout",{tags:null,handler:function(){var t,a,s=$(document.createElement("span")),e=this.payload[0].contents;if(0===this.args.length)return this.error("no arguments given");t=Util.fromCssTime(this.args[0]),a=this.args.length>1?Util.fromCssTime(this.args[1]):0,s.wiki(e).addClass("macro-"+this.name).appendTo(this.output).delay(a).fadeOut(t)}}); // end fading-macro-set.min.js \ No newline at end of file diff --git a/scripts/minified/first-macro.min.js b/scripts/minified/first-macro.min.js index 3541d08..a4ea61d 100644 --- a/scripts/minified/first-macro.min.js +++ b/scripts/minified/first-macro.min.js @@ -1,4 +1,4 @@ // first-macro.min.js, for SugarCube 2, by Chapel -// v1.1.1, 2020-11-24, 9f958db927f80b0101af14e286ea0ad142026739 +// v1.1.1, 2021-01-22, 404cc7678295ca61a8b0b8bc3fa5d54dba6ac858 ;Macro.add("first",{skipArgs:!0,tags:["then","finally"],handler:function(){var a,t=$(document.createElement("span")),n=this.payload[this.payload.length-1],s=visited()-1;a=s0&&"btn"!==this.args[0]?this.args[0]:setup.messageMacro.default).ariaClick(this.createShadowWrapper((function(){a.hasClass("open")?t.css("display","none").empty():t.css("display","block").wiki(e),a.toggleClass("open")}))),a.attr("id","macro-"+this.name+"-"+this.args.join("").replace(/[^A-Za-z0-9]/g,"")).addClass("message-text").append(s).append(t).appendTo(this.output)}}); // end message-macro.min.js \ No newline at end of file diff --git a/scripts/minified/meters.min.js b/scripts/minified/meters.min.js index feccac6..f2ad4ed 100644 --- a/scripts/minified/meters.min.js +++ b/scripts/minified/meters.min.js @@ -1,4 +1,4 @@ // meters.min.js, for SugarCube 2, by Chapel -// v1.0.1, 2020-11-24, 9f958db927f80b0101af14e286ea0ad142026739 +// v1.0.1, 2021-01-22, 404cc7678295ca61a8b0b8bc3fa5d54dba6ac858 ;!function(){"use strict";var t=!0,e=!1,s=!1,i={full:"#2ECC40",empty:"#FF4136",back:"#DDDDDD",height:"12px",width:"180px",animate:400,easing:"swing",text:"#111111",label:"",align:"center"},n=["center","left","right"],r=["swing","linear"];function a(t,e){return t&&"string"==typeof t&&(t=t.toLowerCase().trim())?t:e||""}function o(t){return t<.5?2*t*t:(4-2*t)*t-1}function l(t,e){if(!(this instanceof l))return new l(t,e);var s=clone(i);this.settings=Object.assign(s,t),this.settings.align=a(this.settings.align),this.settings.easing=a(this.settings.easing),n.includes(this.settings.align)||(this.settings.align="center"),r.includes(this.settings.easing)||(this.settings.easing="swing"),e=Number(e),Number.isNaN(e)&&(e=1),e=Math.clamp(e,0,1),this.value=e;var h=$(document.createElement("div")).addClass("chapel-meter").attr({"data-val":e,"data-label":this.settings.label}).css({position:"relative","background-color":this.settings.back,height:this.settings.height,width:this.settings.width,overflow:"hidden"}),g=$(document.createElement("div")).addClass("meter-label").css({top:0,right:0,"font-size":this.settings.height,"font-weight":"bold","line-height":"100%",width:"100%",height:"100%","vertical-align":"middle","text-align":this.settings.align,color:this.settings.text,"z-index":1,position:"relative",bottom:"100%"}).wiki(this.settings.label).appendTo(h),u=$(document.createElement("div")).addClass("meter-top").css({"background-color":this.settings.full,opacity:o(this.value),width:"100%",height:"100%","z-index":0}),c=$(document.createElement("div")).addClass("meter-bottom").css({position:"absolute",top:0,left:0,"background-color":this.settings.empty,opacity:1,width:100*this.value+"%",height:"100%","z-index":0}).append(u).appendTo(h);this.$element=h,this.$bars={top:u,bottom:c},this.$label=g,g.css("font-size",parseInt(h.css("height"),10) no valid target"),e&&"object"==typeof e&&(e.classes&&(Array.isArray(e.classes)||"string"==typeof e.classes)&&s.addClass(e.classes),e.attr&&"object"==typeof e.attr&&s.attr(e.attr)),t.append(s.append(this.$element)),this._label(!0),this},on:function(t,e){return"function"!=typeof e?this:t&&"string"==typeof t&&t.trim()?(t=t.split(" ").map((function(t){return(t=t.split(".")[0])+".userland"})).join(" "),this.$element.on(t,e),this):this},one:function(t,e){return"function"!=typeof e?this:t&&"string"==typeof t&&t.trim()?(t=t.split(" ").map((function(t){return(t=t.split(".")[0])+".userland"})).join(" "),this.$element.one(t,e),this):this},off:function(t){return t=t&&"string"==typeof t&&t.trim()?t.split(" ").map((function(t){return(t=t.split(".")[0])+".userland"})).join(" "):".userland",this.$element.off(t),this},click:function(t,e){return this.$element.ariaClick(t,e),this},clone:function(){return new l(this.settings,this.value)},toJSON:function(){return JSON.reviveWrapper("new setup.Meter("+JSON.stringify(this.settings)+", "+this.value+")")}}),setup.Meter=l,t&&(window.Meter=window.Meter||l),Macro.add("newmeter",{tags:["colors","sizing","animation","label"],handler:function(){if(State.length>0&&!s)return this.error("The `<>` macro must be called in your `StoryInit` special passage. Seriously. No excuses. --Love, Chapel");if(this.args.length<1)return this.error("The `<>` macro requires at least one argument: a meter name.");var t=this.args[0],i=null,n=null,r=null,a=null;if("string"!=typeof t)return this.error("Invalid meter name.");if(t=t.trim(),l.has(t)&&!e)return this.error('Cannot clobber the existing meter "'+t+'".');this.payload.length&&(i=this.payload.find((function(t){return"colors"===t.name})),n=this.payload.find((function(t){return"sizing"===t.name})),r=this.payload.find((function(t){return"animation"===t.name})),a=this.payload.find((function(t){return"label"===t.name})));var o={};if(i){if(!i.args.length)return this.error("No arguments passed to the `<>` tag.");switch(i.args.length){case 1:o.empty=i.args[0],o.full="transparent";break;case 2:o.full=i.args[0],o.empty=i.args[1];break;default:o.full=i.args[0],o.empty=i.args[1],o.back=i.args[2]}}if(n){if(!n.args.length)return this.error("No arguments passed to the `<>` tag.");o.width=n.args[0],n.args[1]&&(o.height=n.args[1])}if(r){if(!r.args.length)return this.error("No arguments passed to the `<>` tag.");if("boolean"!=typeof r.args[0]||r.args[0]){if("string"!=typeof r.args[0])return this.error("The argument to the `<>` tag should be `true`, `false`, or a valid CSS time value.");o.animate=Util.fromCssTime(r.args[0])}else o.animate=0;r.args[1]&&["swing","linear"].includes(r.args[1])&&(o.easing=r.args[1])}if(a){var h=a.args[0];if(!h||"string"!=typeof h)return this.error("The labelText argument for the `<