Commit c70ce8cf authored by Leon Arnott's avatar Leon Arnott
Browse files

Some more bug fixes.

 * Fixed a bug where (click:?page) would suppress a gradient background applied to ?Page via (enchant:) or (change:).
 * Fixed an incorrectly-worded error message resulting from a data name containing an error (such as $a's (a: 1 to 2), which is invalid syntax).
 * Debug Mode: fixed a bug where values in the Variables pane would sometimes be truncated incorrectly, causing partial HTML entities like "&am…" to appear.
 * Made the syntax colour of the lambda keywords (where, when, via, each and making) slightly brighter.
parent 47a747897aa7
......@@ -2,7 +2,19 @@
Documentation is at http://twine2.neocities.org/. See below for compilation instructions.
### 3.2.2 changes (unreleased):
### 3.2.3 changes (unreleased):
#### Bugfixes
* Fixed a bug where `(click:?page)` would suppress a gradient background applied to ?Page via `(enchant:)` or `(change:)`.
* Fixed an incorrectly-worded error message resulting from a data name containing an error (such as `$a's (a: 1 to 2)`, which is invalid syntax).
* Debug Mode: fixed a bug where values in the Variables pane would sometimes be truncated incorrectly, causing partial HTML entities like "&am…" to appear.
#### Alterations
* Made the syntax colour of the lambda keywords (`where`, `when`, `via`, `each` and `making`) slightly brighter.
### 3.2.2 changes (May 12, 2021):
#### Bugfixes
......
window.storyFormat({"name":"Harlowe","version":"3.2.2","author":"Leon Arnott","description":"The default story format for Twine 2. Now with an editor toolbar! Consult its <a href='https://twine2.neocities.org/' target='_blank' rel='noopener noreferrer'>documentation</a>.","image":"icon.svg","url":"http://twinery.org/","license":"Zlib","proofing":false,"source":"","setup":""});
\ No newline at end of file
window.storyFormat({"name":"Harlowe","version":"3.2.3","author":"Leon Arnott","description":"The default story format for Twine 2. Now with an editor toolbar! Consult its <a href='https://twine2.neocities.org/' target='_blank' rel='noopener noreferrer'>documentation</a>.","image":"icon.svg","url":"http://twinery.org/","license":"Zlib","proofing":false,"source":"","setup":""});
\ No newline at end of file
......@@ -187,7 +187,13 @@ define(['jquery', 'utils', 'state', 'internaltypes/varref', 'internaltypes/twine
and falls back to the objectName if not. Note that the TwineScript_DebugName can contain HTML structures
(such as a <tw-colour> for colours) but the objectName could contain user-inputted data, so only the latter is escaped.
*/
const val = isObject(value) && value.TwineScript_DebugName ? value.TwineScript_DebugName() : escape(objectName(value));
const tooLong = value && value.length > 48 && !value.TwineScript_DebugName;
const val = isObject(value) && value.TwineScript_DebugName ? value.TwineScript_DebugName() : escape(
/*
If the value is greater than 48 characters, truncate it.
*/
objectName(value).slice(0, 48) + (tooLong ? "" : "")
);
/*
Single variables, like $peas, should be displayed with no trail, as "peas".
Deep object properties, like $arr's 1st's 1st, should be displayed with a trail
......@@ -211,12 +217,7 @@ define(['jquery', 'utils', 'state', 'internaltypes/varref', 'internaltypes/twine
/*
Source code for objects can be viewed with a folddown button.
*/
const tooLong = val.length > 48 && !value.TwineScript_DebugName;
const folddown = typeof value === "object" || tooLong;
/*
If the value is greater than 36 characters, truncate it.
*/
const truncVal = (tooLong ? val.slice(0,48) + "" : val);
/*
Create the <span>s for the variable's name and value.
*/
......@@ -238,7 +239,7 @@ define(['jquery', 'utils', 'state', 'internaltypes/varref', 'internaltypes/twine
// Variable Scope
"<td class='temporary-variable-scope'>" + (tempScope || '') + "</td>",
// Value
"<td class='variable-value'>" + truncVal + "</td><td class='panel-row-buttons'>"
"<td class='variable-value'>" + val + "</td><td class='panel-row-buttons'>"
+ (folddown ? "<tw-folddown tabindex=0>(source:) </tw-folddown>" : '')
+ "</td>"
).add(
......
......@@ -129,7 +129,17 @@ define(['jquery', 'utils', 'internaltypes/changedescriptor', 'datatypes/changerc
if (e.is(Utils.storyElement)) {
const enchantedProperties = Object.keys(Object.assign({},...cd.styles));
e.css(enchantedProperties.reduce((a,e)=>{
a[e] = "inherit";
/*
Backgrounds can be "inherited" through the simple means of
making them visible through the page element. This allows both
background-image and background-color to be "inherited".
*/
if (e === "background-color" || e === "background-image") {
a.background = 'transparent';
}
else {
a[e] = "inherit";
}
return a;
},{}));
/*
......
......@@ -38,6 +38,9 @@ define(['state', 'internaltypes/twineerror', 'utils', 'utils/operationutils', 'd
Check if it's a valid property name.
*/
let error;
if (TwineError.containsError(prop)) {
return error;
}
if (obj instanceof Map &&
(error = TwineError.containsError(isValidDatamapName(obj,prop)))) {
return error;
......@@ -326,7 +329,13 @@ define(['state', 'internaltypes/twineerror', 'utils', 'utils/operationutils', 'd
and before the convertNegativeProp() branch.
*/
if (typeof obj === "string") {
obj = [...obj];
/*
This check should provide a little perf benefit in most cases,
where the string only has basic plane characters.
*/
if (/[^\x0000-\xFFFF]/.test(obj)) {
obj = [...obj];
}
}
if (isSequential(obj) && Number.isFinite(prop)) {
prop = convertNegativeProp(obj,prop);
......
......@@ -1343,7 +1343,7 @@
}${
model.stops ? `background:linear-gradient(${model.angle}deg, ${
model.stops.map(stop => stop.getAttribute('data-colour') + " " + (stop.getAttribute('data-pos')*100) + "%")
})` : changers.background ? `background:${model.backgroundColour}` : ''
})` : changers.bg ? `background:${model.backgroundColour}` : ''
}`);
},
},{
......@@ -1396,7 +1396,7 @@
model(m, el) {
const c = el[$]('[type=color]').value,
a = el[$]('[type=range]').value;
m.changerNamed('background').push(toHarloweColour(c, a));
m.changerNamed('bg').push(toHarloweColour(c, a));
m.backgroundColour = toCSSColour(c, a);
m.valid = true;
},
......@@ -1410,7 +1410,7 @@
const stops = Array.from(el[$$]('.harlowe-3-colourStop')).sort((a,b) => a.getAttribute('data-pos') - b.getAttribute('data-pos'));
if (stops.length > 1) {
m.valid = true;
m.changerNamed('background').push(`(gradient: $deg, ${
m.changerNamed('bg').push(`(gradient: $deg, ${
stops.map(
stop => fourDecimals(stop.getAttribute('data-pos')) + "," + (stop.getAttribute('data-harlowe-colour') || stop.getAttribute('data-colour'))
)
......@@ -1430,7 +1430,7 @@
step: 1,
model(m, elem) {
if (m.valid) {
const bg = m.changerNamed('background');
const bg = m.changerNamed('bg');
m.angle = +elem[$]('input').value;
bg[0] = bg[0].replace("$deg", m.angle);
}
......
"use strict";
define(['utils', 'passages', 'datatypes/changercommand', 'internaltypes/twineerror', 'utils/operationutils', 'markup', 'twinescript/compiler'],
({impossible}, Passages, ChangerCommand, TwineError, {objectName,toSource}, {lex}, compile) => {
const {assign, create} = Object;
const {assign, create, defineProperty} = Object;
/*
This ensures that serialisation of Maps and Sets works as expected.
*/
defineProperty(Map.prototype, 'toJSON', { value: undefined });
defineProperty(Set.prototype, 'toJSON', { value: undefined });
/*
State
Singleton controlling the running game state.
......
......@@ -11,7 +11,7 @@
number: "color:hsla(30,100%,30%,1.0)",
datamap: "color:hsla(60,100%,30%,1.0)",
changer: "color:hsla(90,100%,30%,1.0)",
lambda: "color:hsla(120,100%,30%,1.0)",
lambda: "color:hsla(120,100%,40%,1.0)",
hookName: "color:hsla(160,100%,30%,1.0)",
string: "color:hsla(180,100%,30%,1.0)",
identifier: "color:hsla(200,80%,40%,1.0)",
......
......@@ -24,4 +24,4 @@ And now you get to enjoy all of this, and more.
And, most importantly, a new toolbar has been implemented for the Twine 2 editor that allows common Harlowe code idioms to be quickly created.
For a complete list of changes and outlines of how to use the above features, consult the <a href="#changes_3.2.0-changes">change log</a> section.
For a complete list of changes and outlines of how to use the above features, consult the <a href="#changes_3.2.0-changes-(jan-4,-2021)">change log</a> section.
......@@ -456,7 +456,7 @@ paths.forEach(function(path) {
let defs;
// .md files should be treated as entire single definitions
if (path === "README.md") {
defs = file.match(/### \d\.\d\.\d[^]*?\n(?=###[^#])/g).slice(0,3);
defs = file.match(/### \d\.\d\.\d[^]*?\n(?=###[^#])/g).slice(0,4);
} else if (path.endsWith('.md')) {
defs = [file];
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment