Skip to content

Commit

Permalink
Update for v-24j30
Browse files Browse the repository at this point in the history
  • Loading branch information
david-pfx committed Oct 30, 2024
1 parent f966a18 commit 9e0d9ee
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .build/buildnumber.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1804
1805
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ PuzzleScript Next is a combination of the work of many authors:
* and ongoing development work inspired by its many users (like you).

## New Features and Fixes
The latest version is Release v-24j25.
The latest version is Release v-24j30.
Please try the gallery and examples, and notify any bugs.

Recent fixes/updates:
* Added support for non-square sprite grids (#120 #121)
* Fixed where `again` terminates afx transitions (#110)

Older fixes/updates:
* Fixed `level_select_lock` (#114)
* Fixed `require_player_movement` error on `goto` (#116)
* Fixed problems parsing `text:` sprites (#117)

Older fixes/updates:
* Fix `canvas: transform: rot:` regression (#109).
* Fix GOSUB interactions with late rules (#107).
* Add verbose logging of GOSUB/return.
Expand Down
81 changes: 46 additions & 35 deletions src/standalone_inlined.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6793,7 +6793,7 @@ whitingjp : {
// Functions to create and render text and sprites

// Create and return a graphic sprite canvas
function createSprite(name,spritegrid, colors, size) {
function createSprite(name,spritegrid, colors, size, height) {
colors ||= [state.bgcolor, state.fgcolor];

var canvas = makeSpriteCanvas(name);
Expand All @@ -6802,7 +6802,7 @@ function createSprite(name,spritegrid, colors, size) {
canvas.width = spritegrid.reduce((acc, row) => Math.max(acc, row.length), 0) * pixelSize;
canvas.height = spritegrid.length * pixelSize;

renderSprite(context, spritegrid, colors, 0, 0, 0, size);
renderSprite(context, spritegrid, colors, 0, 0, 0, size, height);

return canvas;
}
Expand Down Expand Up @@ -6880,14 +6880,14 @@ function createSvgSprite(name, vector) {
}

// draw the pixels of the sprite grid data into the context at a cell position,
function renderSprite(context, spritegrid, colors, padding, x, y, size) {
function renderSprite(context, spritegrid, colors, padding, x, y, size, height) {
colors ||= ['#00000000', state.fgcolor];

const rc = {
x: x * cellwidth, // global
y: y * cellheight,
w: size || spritegrid[0].length,
h: size || spritegrid.length,
w: size || spritegrid[0].length,
h: height || size || spritegrid.length,
};

context.clearRect(rc.x, rc.y, rc.w, rc.h);
Expand Down Expand Up @@ -6966,7 +6966,7 @@ function regenSpriteImages() {
}

if (IDE===true) {
textImages['editor_s'] = createSprite('chars', editor_s_grille, undefined, 5);
textImages['editor_s'] = createSprite('chars', editor_s_grille, undefined, 5); //@@?? w,h
}

if (state.levels.length===0) {
Expand All @@ -6979,7 +6979,7 @@ function regenSpriteImages() {
spriteImages[i] =
s.text ? createTextSprite('t' + i.toString(), s.text, s.colors, s.scale)
: s.vector ? createVectorSprite('v' + i.toString(), s.vector)
: createSprite(i.toString(), s.dat, s.colors, state.sprite_size);
: createSprite(i.toString(), s.dat, s.colors, state.sprite_size, state.cell_height);
}
});

Expand Down Expand Up @@ -7373,12 +7373,12 @@ function redrawCellGrid(curlevel) {
const offs = {
x: obj.spriteoffset.x,
y: obj.spriteoffset.y + (obj.vector
? state.sprite_size * (1 - obj.vector.h)
: state.sprite_size - obj.spritematrix.length)
? (state.cell_height || state.sprite_size) * (1 - obj.vector.h)
: (state.cell_height || state.sprite_size) - obj.spritematrix.length)
};
return {
x: xoffset + (ij.x - this.minMax[0]-cameraOffset.x) * cellwidth + offs.x * ~~(cellwidth / state.sprite_size),
y: yoffset + (ij.y - this.minMax[1]-cameraOffset.y) * cellheight + offs.y * ~~(cellheight / state.sprite_size)
y: yoffset + (ij.y - this.minMax[1]-cameraOffset.y) * cellheight + offs.y * ~~(cellheight / ( state.cell_height || state.sprite_size))
};

}
Expand Down Expand Up @@ -7427,8 +7427,8 @@ function redrawCellGrid(curlevel) {
seedsToAnimate = {};

// Decision required whether to follow P:S pivot (top left)
const spriteScaler = state.metadata.sprite_size ? {
scale: state.sprite_size,
const spriteScaler = state.metadata.sprite_size ? { //@@?? w,h does this even work?
scale: state.cell_height || state.sprite_size,
pivotx: 0.0, // todo
pivoty: 1.0
} : null;
Expand Down Expand Up @@ -7482,7 +7482,7 @@ function redrawCellGrid(curlevel) {
const rch = vector && vector.flipy ? -rc.h : rc.h;
ctx.translate(rc.x + rc.w/2, rc.y + rc.h/2);
ctx.rotate(params.angle * Math.PI / 180);
ctx.scale(vector.flipx ? -1 : 1, vector.flipy ? -1 : 1); //@@
ctx.scale(vector.flipx ? -1 : 1, vector.flipy ? -1 : 1);
ctx.drawImage(
spriteImages[k], 0, 0, spriteSize.w, spriteSize.h,
-rcw/2, -rch/2, rcw, rch);
Expand Down Expand Up @@ -7811,9 +7811,11 @@ function drawEditorIcons(mini,minj) {
// show tooltip
if (tooltip_string.length > 0)
{
ctx.fillStyle = state.fgcolor;
ctx.font = `16px "Source Sans Pro", Helvetica, Arial, sans-serif`;
ctx.fillText(tooltip_string, xoffset, yoffset-0.4*cellheight);
ctx.fillStyle = state.fgcolor;
ctx.font = '16px sans-serif';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillText(tooltip_string, xoffset + screenwidth * cellwidth/2, yoffset-0.5*cellheight);//, screenwidth * cellwidth);
}

if (mouseCoordX>=-1&&mouseCoordY>=-1&&mouseCoordX<screenwidth-1&&mouseCoordY<screenheight-1-editorRowCount) {
Expand Down Expand Up @@ -7883,7 +7885,9 @@ function canvasResize(level) {
statusLineHeight = state.metadata.status_line ? canvas.height / TITLE_HEIGHT : 0;

// round the cell size as a multiple of sprite size
let w = h = state.sprite_size || 5;
let h = state.cell_height || state.sprite_size || 5;
let w = state.sprite_size || 5;

if (textMode) {
w= 5 + 1;
const xchar = font['X'].split('\n').map(a=>a.trim());
Expand Down Expand Up @@ -11470,6 +11474,7 @@ function procInp(dir,dontDoWin,dontModify,bak,coord) {
//first have to verify that something's changed
var old_verbose_logging=verbose_logging;
var oldmessagetext = messagetext;
const oldseedsToAnimate = seedsToAnimate;
verbose_logging=false;
if (processInput(-1,true,true)) {
verbose_logging=old_verbose_logging;
Expand All @@ -11488,6 +11493,7 @@ function procInp(dir,dontDoWin,dontModify,bak,coord) {
}
verbose_logging=old_verbose_logging;
messagetext = oldmessagetext;
seedsToAnimate = oldseedsToAnimate;
}
}

Expand Down Expand Up @@ -12530,9 +12536,13 @@ var codeMirrorFn = function() {
soundverbs_movement.push(...mouse_clicks_table);
} else if (ident == 'sprite_size') {
const args = value[1].split('x').map(a => parseInt(a));
if (!(args.length == 1 || args.length == 2))
logError(`MetaData "${errorCase(ident)}" requires an argument of numbers like 8x8 or 10, not ${value[1]}.`, state.lineNumber);
else state.sprite_size = args[0];
if (!(args.length == 1 || args.length == 2) || args.some(a => isNaN(a)))
logError(`Prelude optiton "${errorCase(ident)}" expects an argument of 1 or 2 numbers, like 10 or 4x7, not ${value[1]}.`, state.lineNumber);
else {
state.sprite_size = args[0];
if(args.length == 2)
state.cell_height = args[1];
}
} else if (ident == 'youtube') {
logWarning("Unfortunately, YouTube support hasn't been working properly for a long time - it was always a hack and it hasn't gotten less hacky over time, so I can no longer pretend to support it.",state.lineNumber);
return;
Expand Down Expand Up @@ -12838,10 +12848,10 @@ var codeMirrorFn = function() {
// preserve colors and sprite matrix, not transforms
const newobj = state.objects[candname] || { // doc: array of objects indexed by name
lineNumber: state.lineNumber,
colors: [],
spritematrix: [],
};
delete newobj.canRedef;
newobj.colors = [];
newobj.spritematrix = [];
newobj.transforms = [];
delete state.objects[candname];
state.objects[candname] = newobj;
Expand Down Expand Up @@ -13138,7 +13148,7 @@ var codeMirrorFn = function() {
}
lexer.pushToken(token, kind);

} else if (token = lexer.match(/^canvas:/i)) {//@@
} else if (token = lexer.match(/^canvas:/i)) {
lexer.pushToken(token, 'KEYWORD');
lexer.matchComment();
symbols.vector = {
Expand Down Expand Up @@ -14338,7 +14348,7 @@ function expandObjectDef(state, objid, objvalue) {

// if it exists just return it otherwise create it
if (Object.hasOwn(state.objects, newid))
return [ newid, state.objects[newid] ];
return [ newid, state.objects[newid] ]; //@@ bug in Hebird, fails to redefine object

const newvalue = {
...deepClone(objvalue),
Expand Down Expand Up @@ -14506,7 +14516,7 @@ function createObjectRef(state, ident) {
const parts = ident.split(':');
if (parts.some(e => relativeDirections.includes(e))) {
if (debugSwitch.includes('exp')) console.log(`Create object ref for relative direction: ${ident}`);
for (const forward of simpleAbsoluteDirections) { //@@
for (const forward of simpleAbsoluteDirections) {
const absOf = dir => relativeDirs.includes(dir) ? relativeDict[forward][relativeDirs.indexOf(dir)] : dir;
const id = ident.split(':').map(p => absOf(p)).join(':');
createObjectRef(state, id);
Expand Down Expand Up @@ -14672,7 +14682,9 @@ function generateExtraMembers(state) {
}
if (obj.spritematrix.length == 0) {
obj.spritematrix = Array.from(
{ length: state.sprite_size },
{
length: state.cell_height || state.sprite_size
},
() => (new Array(state.sprite_size).fill(0))
);
}
Expand Down Expand Up @@ -15073,7 +15085,7 @@ function levelFromString(state,level) {
}

////
function levelAllObjects(state) { //@@
function levelAllObjects(state) {
const backgroundlayer = state.backgroundlayer;
const backgroundLayerMask = state.layerMasks[backgroundlayer];
const count = state.objectCount;
Expand Down Expand Up @@ -15169,7 +15181,7 @@ function levelsToArray(state) {
title = null;
}
});
links.forEach(link => { //@@
links.forEach(link => {
let index = -9999;
if ((index = levels.findIndex(level => link.target == level.section)) != -1)
link.targetNo = index;
Expand Down Expand Up @@ -15264,7 +15276,7 @@ function convertSectionNamesToIndices(state) {

// fix gosubs and subroutines to use group number (so must be after created groups)
// will be called twice, for main and late rules
function fixUpGosubs(rules, subroutines) { //@@
function fixUpGosubs(rules, subroutines) {
// rules are now groups. Go figure.
for (const group of rules) {
for (const rule of group) {
Expand Down Expand Up @@ -15668,7 +15680,7 @@ function rulesToArray(state) {
}

// find and filter out start and end loop, subroutines PS>
function parseRulesToArray(state) { //@@
function parseRulesToArray(state) {
const oldrules = state.rules;
var newrules = [];
var loops = [];
Expand Down Expand Up @@ -17826,10 +17838,9 @@ function loadFile(str) {

generateLoopPoints(state);

fixUpGosubs(state.rules, state.subroutines); //@@
fixUpGosubs(state.lateRules, state.subroutines); //@@
//fixUpGosubs(state); //@@

fixUpGosubs(state.rules, state.subroutines);
fixUpGosubs(state.lateRules, state.subroutines);

generateSoundData(state);

formatHomePage(state);
Expand Down Expand Up @@ -19477,7 +19488,7 @@ function update() {
}
}
if (againing) {
if (timer>againinterval && messagetext == "") {
if (timer>againinterval && messagetext == "" && !isAnimating) {
if (processInput(-1)) {
draw = true;
keyRepeatTimer=0;
Expand Down

0 comments on commit 9e0d9ee

Please sign in to comment.