Skip to content

Commit

Permalink
Merge commit '9e188b214f2c0ee6c91e05c6bda68f0b709ca7af'
Browse files Browse the repository at this point in the history
  • Loading branch information
CosmoMyzrailGorynych committed Nov 3, 2024
2 parents 1736f4c + 9e188b2 commit 73ea77b
Show file tree
Hide file tree
Showing 28 changed files with 409 additions and 131 deletions.
30 changes: 30 additions & 0 deletions app/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
## v5.2.1

*Mon Nov 04 2024*

### ⚡️ General Improvements

* Catnip: Add mutators to timer blocks
* Catnip: Add mutators for "action is down/pressed/released" blocks
* Ct.js now checks whether recovery file actually differs from the regular project file
* Room editor: you can now navigate around with Spacebar + Left mouse button (Closes #526)
* :globe_with_meridians: Catnip: Improve Russian translations for ct.place
* :globe_with_meridians: Catnip: Translate Pointer catmod to Russian and add more human-readable English names
* :globe_with_meridians: Catnip: Translate the Random catmod's blocks to Russian

### 🐛 Bug Fixes

* Catnip: Add missing translation keys to Math operators
* Catnip: Fix catnip blocks ignoring translations when there was a translated name without a translated label
* Catnip: Fix inability to compile Script assets with Catnip code
* Catnip: Properly mark the required arguments in the Logic category
* Fields with invalid values should be outlined red
* Fix ct.js saving projects' scripts with CRLF sequence instead of LF, which caused them to be one-lined in the .ict file, making merging changes harder for Git users. You can fix the existing scripts by cutting and pasting their contents back.
* Fix minor styling issues on the homepage
* Fix `random.dice` trying to convert string values to floats (Closes #544)
* Make sure there are no special characters in the project name when creating one (Closes #543)

### 📝 Docs

* :bug: Fix brainless translation with room.append in Russian version of the JettyCat tutorial (Closes #141)

## v5.2.0

*Sun Oct 13 2024*
Expand Down
4 changes: 2 additions & 2 deletions app/data/ct.libs/place/blocks.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = [{
name: 'Move this copy along a line stopping at',
name_Ru: 'Переместить эту копию по линии, останавливаясь перед',
name_Ru: 'Переместиться по линии, останавливаясь перед группой',
type: 'command',
code: 'move template bullet',
icon: 'move',
Expand Down Expand Up @@ -29,7 +29,7 @@ module.exports = [{
}
}, {
name: 'Move this copy stopping at',
name_Ru: 'Переместить эту копию, останавливаясь перед',
name_Ru: 'Переместиться, останавливаясь перед группой',
type: 'command',
code: 'move template smart',
icon: 'move',
Expand Down
14 changes: 8 additions & 6 deletions app/data/ct.libs/place/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ declare namespace place {
*
* @param {Copy} me The object to check collisions on
* @param {String} [cgroup] The collision group to check against
* @catnipName place is free for copy
* @catnipName_Ru место для копии свободно
*/
function free(me: Copy, cgroup?: string): boolean;

Expand Down Expand Up @@ -131,6 +133,8 @@ declare namespace place {
* @param {String} [cgroup] The collision group to check against
* @returns {Copy|PIXI.Sprite|false} The collided copy, or `false`
* if there were no collisions.
* @catnipName occupying object for
* @catnipName_Ru занимает место для
*/
function occupied(me: Copy, cgroup?: string): Copy | false;
/**
Expand Down Expand Up @@ -168,6 +172,8 @@ declare namespace place {
* @param {String} [template] The name of the template to check agains
* @catnipAsset template:template
* @returns {Copy|Array<Copy>} The collided copy or `false`, if there was no collision.
* @catnipName occupied by a template
* @catnipName_Ru занято шаблоном
*/
function meet(me: Copy, template: string): Copy | false;
/**
Expand Down Expand Up @@ -275,9 +281,7 @@ declare namespace place {
* returns `false`. If a copy met an obstacle as another copy, returns this copy.
* If there was a tile, returns `true`.
*
* @catnipSaveReturn
* @catnipName Move a copy along a line
* @catnipName_Ru Передвинуть копию вдоль линии
* @catnipIgnore
*/
function moveAlong(
me: Copy, direction: number, maxLength: number, cgroup?: string, stepSize?: number
Expand All @@ -299,9 +303,7 @@ declare namespace place {
* @returns {false|ISeparateMovementResult} `false` if it reached its target,
* an object with each axis specified otherwise.
*
* @catnipSaveReturn
* @catnipName Move a copy by distance
* @catnipName_Ru Передвинуть копию на расстояние
* @catnipIgnore
*/
function moveByAxes(me: Copy, dx: number, dy: number, cgroup?: string, stepSize?: number):
false | ISeparateMovementResult;
Expand Down
90 changes: 86 additions & 4 deletions app/data/ct.libs/pointer/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,101 +101,150 @@ declare namespace pointer {
* @catnipIgnore
*/
var released: IPointer[];
/** The horizontal position at which the primary pointer is positioned. */
/**
* The horizontal position at which the primary pointer is positioned.
* @catnipName pointer's x
* @catnipName_Ru x указателя
*/
var x: number;
/** The vertical position at which the primary pointer is positioned. */
/**
* The vertical position at which the primary pointer is positioned.
* @catnipName pointer's y
* @catnipName_Ru y указателя
*/
var y: number;
/** The horizontal position at which the primary pointer is positioned, in UI space.*/
/**
* The horizontal position at which the primary pointer is positioned, in UI space.
* @catnipName pointer's x for ui
* @catnipName_Ru x указателя для ui
*/
var xui: number;
/** The vertical position at which the primary pointer is positioned, in UI space.*/
/**
* The vertical position at which the primary pointer is positioned, in UI space.
* @catnipName pointer's y for ui
* @catnipName_Ru y указателя для ui
*/
var yui: number;
/**
* The horizontal position of the primary pointer in the previous frame,
* in gameplay coordinates.
* @catnipName pointer's previous x
* @catnipName_Ru предыдущий x указателя
*/
var xprev: number;
/**
* The vertical position of the primary pointer in the previous frame,
* in gameplay coordinates.
* @catnipName pointer's previous y
* @catnipName_Ru предыдущий y указателя
*/
var yprev: number;
/**
*
* The horizontal position of the primary pointer in the previous frame, in UI coordinates.
* @catnipName pointer's previous x in ui
* @catnipName_Ru предыдущий x указателя в ui
*/
var xuiprev: number;
/**
* The vertical position of the primary pointer in the previous frame, in UI coordinates.
* @catnipName pointer's previous y in ui
* @catnipName_Ru предыдущий y указателя в ui
*/
var yuiprev: number;
/**
* The current tracked position of a locked pointer in UI space.
* Note that it only changes when ct.pointer works in the locking mode.
* The initial value of the locked pointer is set to the last known position
* of the unlocked primary pointer.
* @catnipName locked pointer's x
* @catnipName_Ru x захвач. указателя
*/
var xlocked: number;
/**
* The current tracked position of a locked pointer in UI space.
* Note that it only changes when ct.pointer works in the locking mode.
* The initial value of the locked pointer is set to the last known position
* of the unlocked primary pointer.
* @catnipName locked pointer's y
* @catnipName_Ru y захвач. указателя
*/
var ylocked: number;
/**
* The current movement speed of a locked pointer relative to UI space.
* Note that it only changes when ct.pointer works in the locking mode.
* @catnipName locked pointer's x movement
* @catnipName_Ru движение по x захвач. указателя
*/
var xmovement: number;
/**
* The current movement speed of a locked pointer relative to UI space.
* Note that it only changes when ct.pointer works in the locking mode.
* @catnipName locked pointer's y movement
* @catnipName_Ru движение по y захвач. указателя
*/
var ymovement: number;
/**
* The current pressure made onto the primary pointer.
* Note that this property is usually defined for special pointer types,
* e.g. for graphic tablet's digital pens.
* You will usually get 0.5 for mouse and touch events of regular devices.
* @catnipName pointer's pressure
* @catnipName_Ru нажим указателя
*/
var pressure: number;
/**
* A number that, with a proper bitmask, tells which buttons are currently pressed.
* Use ct.pointer.isButtonPressed(buttonName, ct.pointer.buttons) to check
* for specific buttons.
* @catnipName pressed buttons
* @catnipName_Ru нажатые кнопки
*/
var buttons: number;
/**
* The plane angle (in degrees, in the range of -90 to 90)
* between the Y–Z plane and the plane containing both the pointer
* (e.g. pen stylus) axis and the Y axis.
* @catnipName pointer's x tilt
* @catnipName_Ru наклон указателя по x
*/
var tiltX: number;
/**
* the plane angle (in degrees, in the range of -90 to 90)
* between the X–Z plane and the plane containing both the pointer
* (e.g. pen stylus) axis and the X axis.
* @catnipName pointer's y tilt
* @catnipName_Ru наклон указателя по y
*/
var tiltY: number;
/**
* The clockwise rotation of the pointer (e.g. pen stylus) around its major axis in degrees,
* with a value in the range 0 to 359.
* @catnipName pointer's twist
* @catnipName_Ru поворот указателя
*/
var twist: number;
/**
* The size of the primary pointer, in UI coordinates.
* Depending on the type of the pointer, this property may not be available
* and will be equal to 0 or something close to 1.
* @catnipName pointer's width
* @catnipName_Ru ширина указателя
*/
var width: number;
/**
* The size of the primary pointer, in UI coordinates.
* Depending on the type of the pointer, this property may not be available
* and will be equal to 0 or something close to 1.
* @catnipName pointer's height
* @catnipName_Ru высота указателя
*/
var height: number;
/**
* The type of the pointer used most recently (the one that was pressed).
* It usually equals to either 'mouse', 'touch', or 'pen'.
* @catnipName pointer's type
* @catnipName_Ru тип указателя
*/
var type: string;

Expand All @@ -204,16 +253,25 @@ declare namespace pointer {
* It can be used to reset the state of ct.pointer, but note that hover events
* are reset as well meaning that pointers (like mouse) will report them only
* when they become active again (for example, with a mouse click).
*
* @catnipName Clear pointers' events
* @catnipName_Ru Очистить события указателей
*/
function clear(): void;
/**
* Clears all the memorized pointer events that were released in the current frame.
*
* @catnipName Clear pointers' "released" event
* @catnipName_Ru Очистить события отпущенных указателей
*/
function clearReleased(): void;
/**
* Either returns the pointer that is currently colliding with the passed copy that exists
* in gameplay coordinates, or returns `false` if there is no collision.
* Collisions happen only if the pointer is currently held down.
*
* @catnipName pointer touches
* @catnipName_Ru указатель касается
*/
function collides(
copy: Copy,
Expand All @@ -224,6 +282,9 @@ declare namespace pointer {
* Either returns the pointer that is currently colliding with the passed copy that exists
* in UI coordinates, or returns `false` if there is no collision.
* Collisions happen only if the pointer is currently held down.
*
* @catnipName pointer touches ui
* @catnipName_Ru указатель касается ui
*/
function collidesUi(
copy: Copy,
Expand All @@ -233,20 +294,41 @@ declare namespace pointer {
/**
* Either returns the pointer that is currently hovering over the passed copy that exists
* in gameplay coordinates, or returns `false` if there is no such pointers.
*
* @catnipName pointer hovers
* @catnipName_Ru указатель над
*/
function hovers(copy: Copy, pointer?: IPointer): false | IPointer;
/**
* Either returns the pointer that is currently hovering over the passed copy that exists
* in UI coordinates, or returns `false` if there is no such pointers.
*
* @catnipName pointer hovers ui
* @catnipName_Ru указатель над ui
*/
function hoversUi(copy: Copy, pointer?: IPointer): false | IPointer;
/**
* @catnipName is pointer's button pressed
* @catnipName_Ru кнопка указателя нажата
*/
function isButtonPressed(button: PointerButtonName, pointer: IPointer): boolean;
/**
* @catnipName Lock the pointer
* @catnipName_Ru Заблокировать указатель
*/
function lock(): void;
/**
* @catnipName Unlock the pointer
* @catnipName_Ru Разблокировать указатель
*/
function unlock(): void;
/**
* Equals to `true` when the pointer is locked.
* Note that the pointer can still be unlocked while the locking mode is on,
* for example after a player pressed ESC key or switched to a different window.
*
* @catnipName is pointer locked
* @catnipName_Ru указатель заблокирован
*/
var locked: boolean;
}
1 change: 1 addition & 0 deletions app/data/ct.libs/random/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Returns a random float value between 0 and x, exclusive.

### `random.dice(dice1,dice2,...diceN)`
Returns a random given argument.
When given just one string value, the string will be split by `,` separator and a random item will be returned.

### `random.range(x1, x2)`
Returns a random float value between `x1` and `x2`, exclusive.
Expand Down
18 changes: 10 additions & 8 deletions app/data/ct.libs/random/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@
const random = function random(x) {
return Math.random() * x;
};
function processRandomInput(input) {
if (input.length === 1 && typeof input[0] === "string") {
return input[0].split(",");
const processRandomInput = function (input) {
if (input.length === 1 && typeof input[0] === 'string') {
return input[0].split(',');
}
return input;
}
};
Object.assign(random, {
dice(...variants) {
const dices = processRandomInput(variants);
if (Array.isArray(dices) && dices.length > 0) {
const result = dices[Math.floor(Math.random() * dices.length)];
const parsedResult = parseFloat(result);
return isNaN(parsedResult) ? result : parsedResult;
return dices[Math.floor(Math.random() * dices.length)];
}
return null;
},
histogram(...histogram) {
const coeffs = [...processRandomInput(histogram)];
Expand Down Expand Up @@ -50,7 +49,10 @@ Object.assign(random, {
return Math.random() * 360;
},
coord() {
return [Math.floor(Math.random() * camera.width), Math.floor(Math.random() * camera.height)];
return [
Math.floor(Math.random() * camera.width),
Math.floor(Math.random() * camera.height)
];
},
chance(x, y) {
if (y) {
Expand Down
Loading

0 comments on commit 73ea77b

Please sign in to comment.