Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Vasilii Kostin committed Feb 25, 2025
2 parents a9e74b4 + eb807d9 commit 732d44e
Show file tree
Hide file tree
Showing 38 changed files with 202 additions and 80 deletions.
3 changes: 0 additions & 3 deletions thing-editor/demo/install.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

import {exec} from 'child_process';
import fs from 'fs';
import * as patcher from '../electron-main/pixi-typings-patch.js';

Expand All @@ -22,5 +21,3 @@ if (!fs.existsSync('./tsconfig.json')) {
fs.cpSync('./thing-editor/demo/example-project', './games/example-project', {recursive: true, force: false});
fs.cpSync('./thing-editor/demo/example-lib', './libs/example-lib', {recursive: true, force: false});


exec('git update-index --assume-unchanged thing-editor/src/editor/current-scene-typings.d.ts thing-editor/src/editor/prefabs-typing.ts');
9 changes: 0 additions & 9 deletions thing-editor/electron-main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ const {
}
}

const {exec} = require('child_process');

const originalLog = console.log.bind(console);

console.log = (txt) => {
Expand Down Expand Up @@ -107,9 +105,6 @@ const {
mainWindow.reload();
}
});
globalShortcut.register('F12', () => { // On windows set HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\UserDebuggerHotKey to '2f' value to make F12 it work
mainWindow.webContents.openDevTools();
});
});
mainWindow.on('blur', () => {
globalShortcut.unregisterAll();
Expand Down Expand Up @@ -165,8 +160,4 @@ const {
console.log('thing-editor exit');
app.quit();
});

exec('git update-index --assume-unchanged thing-editor/src/editor/current-scene-typings.d.ts thing-editor/src/editor/prefabs-typing.ts', {
cwd: __dirname + '/../..'
});
})();
2 changes: 2 additions & 0 deletions thing-editor/electron-main/pixi-typings-patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ patch(
findParentByName(name: string): Container;
_onRenderResize?(): void;
__prefabPivot?: import('thing-editor/src/editor/ui/viewport').PREFAB_PIVOT;
/** search child recursively by it's name */
findChildByName(name: string): Container | undefined;
Expand Down
4 changes: 4 additions & 0 deletions thing-editor/electron-main/server-fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ module.exports = (mainWindow) => {
return fs.statSync(fileNameParsed).mtimeMs;
}, event);
return;
case 'fs/devTools':
mainWindow.webContents.openDevTools();
event.returnValue = true;
return;
case 'fs/log':
console.log('FS-LOG: ' + fileName);
event.returnValue = true;
Expand Down
Binary file added thing-editor/img/pivot/left-top.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added thing-editor/img/pivot/middle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions thing-editor/src/editor/editor-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ interface EditablePropertyDescRaw<T extends import('pixi.js').DisplayObject = im

guideColor?: number;

rectScaleIgnore?: true;

rect_minX?: number;
rect_maxX?: number;
rect_minY?: number;
Expand Down
12 changes: 6 additions & 6 deletions thing-editor/src/editor/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,17 +318,17 @@ class Editor {
chooseProject(notSkipable = false) {
ProjectsList.__chooseProject(notSkipable).then((dir: string) => {
if (dir) {
if (this.askSceneToSaveIfNeed()) {
this.openProject(dir);
}
this.openProject(dir);
}
});
}

openProject(dir:string) {
this.settings.setItem('last-opened-project', dir);
this.restartInProgress = true;
window.document.location.reload();
if (this.askSceneToSaveIfNeed()) {
this.settings.setItem('last-opened-project', dir);
this.restartInProgress = true;
window.document.location.reload();
}
}

pauseGame() {
Expand Down
9 changes: 7 additions & 2 deletions thing-editor/src/editor/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ export default class fs {
return execFs('fs/log', message);
}

static openDevTools() {
return execFs('fs/devTools');
}

static copyFile(from: string, to: string) {
return execFs('fs/copyFile', from, to);
}
Expand Down Expand Up @@ -348,13 +352,14 @@ export default class fs {
const newFileName = file.fileName.replace(file.lib!.assetsDir, game.editor.currentProjectAssetsDir);
OVERRIDDEN_ASSETS.add(newFileName);
fs.copyFile(file.fileName, newFileName);
file.lib = null;
fs.refreshAssetsList();
game.editor.ui.refresh();
}

static moveAssetToFolder(file: FileDesc, lib: null | LibInfo) {
fs.copyFile(file.fileName, file.fileName.replace(file.lib ? file.lib.assetsDir : game.editor.currentProjectAssetsDir, lib ? lib.assetsDir : game.editor.currentProjectAssetsDir));
fs.deleteAsset(file.assetName, file.assetType);
fs.deleteFile(file.fileName);
fs.refreshAssetsList();
game.editor.ui.refresh();
}

Expand Down
11 changes: 7 additions & 4 deletions thing-editor/src/editor/ui/assets-view/asset-view-class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ function findNextOfThisType(c: SourceMappedConstructor, direction: 1 | -1, findA
a.push(game.currentContainer);
}
game.editor.selection.clearSelection();
a = a.filter(o => !o.__nodeExtendData.isolate);
if (strictType) {
a = a.filter(o => o.constructor === c);
}
Expand All @@ -172,10 +173,12 @@ function findNextOfThisType(c: SourceMappedConstructor, direction: 1 | -1, findA
}
} else {
game.editor.ui.sceneTree.findNext((o) => {
if (!strictType) {
return (o instanceof c) && !getParentWhichHideChildren(o);
} else {
return (o.constructor === c) && !getParentWhichHideChildren(o);
if (!o.__nodeExtendData.isolate) {
if (!strictType) {
return (o instanceof c) && !getParentWhichHideChildren(o);
} else {
return (o.constructor === c) && !getParentWhichHideChildren(o);
}
}
}, direction);
}
Expand Down
4 changes: 2 additions & 2 deletions thing-editor/src/editor/ui/assets-view/asset-view-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const showPrefabContextMenu = (file: FileDescScene, ev: PointerEvent) => {
};

const assetItemRendererScene = (file: FileDescScene): ComponentChild => {
assert(file.asset.c, 'scene can not be prefab reference');
assert(file.asset ? file.asset.c : true, 'scene can not be prefab reference'); // asset can be empty if it is equal asset overriding notification popup where overrides asset overridden too

const isCurrent = (file.assetName === game.editor.currentSceneName) || (AssetsView.currentItemName === game.editor.currentSceneName);

Expand All @@ -96,7 +96,7 @@ const assetItemRendererScene = (file: FileDescScene): ComponentChild => {
title: 'click to open scene.'
},
libInfo(file),
R.classIcon(game.classes[file.asset.c!] || __UnknownClass),
R.classIcon(game.classes[file.asset?.c!] || __UnknownClass),
R.span(assetsItemNameProps, file.assetName));
};

Expand Down
4 changes: 3 additions & 1 deletion thing-editor/src/editor/ui/assets-view/assets-view-prefab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const showPrefabContextMenu = (file: FileDescPrefab, ev: PointerEvent) => {
null,
{
name: R.fragment(R.icon('asset-prefab'), 'Duplicate prefab'),
disabled: () => !game.__EDITOR_mode,
onClick: () => {
editorUtils.enterPrefabName(file.assetName, 'Enter name for duplicate prefab: ' + file.assetName).then((enteredName) => {
if (enteredName) {
Expand All @@ -66,6 +67,7 @@ const showPrefabContextMenu = (file: FileDescPrefab, ev: PointerEvent) => {
},
{
name: R.fragment(R.icon('asset-prefab'), 'Inherit prefab'),
disabled: () => !game.__EDITOR_mode,
onClick: () => {
editorUtils.enterPrefabName(file.assetName, 'Enter name for inherited prefab: ' + file.assetName).then((enteredName) => {
if (enteredName) {
Expand Down Expand Up @@ -120,7 +122,7 @@ const showPrefabContextMenu = (file: FileDescPrefab, ev: PointerEvent) => {

const assetItemRendererPrefab = (file: FileDescPrefab) => {
let desc;
if (file.asset.p.__description) {
if (file.asset?.p.__description) {
desc = R.div(descriptionProps, file.asset.p.__description.split('\n')[0]);
}
const Class = getSerializedObjectClass(file.asset);
Expand Down
3 changes: 3 additions & 0 deletions thing-editor/src/editor/ui/language-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,9 @@ class LanguageTableEditor extends ComponentDebounced<ClassAttributes<LanguageTab
langsIdsList.map((langId) => {

const asset = currentDirAssets.get(langId)!;
if (!asset) {
return undefined;
}

let text = asset.asset[id];

Expand Down
7 changes: 7 additions & 0 deletions thing-editor/src/editor/ui/main-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,13 @@ const MAIN_MENU: MainMenuItem[] = [
},
stayAfterClick: true
},
{
name: 'Open dev tools',
hotkey: {key: 'F12'},
onClick: () => {
fs.openDevTools();
}
},
{
name: 'Reset windows layout',
onClick: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default class SpineSequencesEditor extends Component<ClassAttributes<Spin
showAdditionalWindow('spine-sequence', 'Spine sequences', 'Spine sequences',
R.div({ title: '' },
h(SpineSequences, { spine: game.editor.selection[0] as Spine, onCloseClick: this.onToggleClick }),
), 0, 70, 100, 220, 1120, 220);
), 20, 65, 90, 95, 1120, 220);
} else {
this._hideWindow();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,21 +151,9 @@ export default class SpineSequences extends ComponentDebounced<SpineSequencesPro

currentTime = 0;

timeout = 0;

componentWillReceiveProps(): void {
this.timeout = window.setTimeout(() => {
this.setActiveSequence(this.activeSequenceName);
this.timeout = 0;
}, 1);
}

componentWillUnmount(): void {
instance = undefined;
window.removeEventListener('mousemove', this.onMouseMove);
if (this.timeout) {
clearTimeout(this.timeout);
}
}

askForSequenceName(defaultText = '') {
Expand Down Expand Up @@ -282,7 +270,7 @@ export default class SpineSequences extends ComponentDebounced<SpineSequencesPro
}

get activeSequenceName(): string {
return (this.spine.spineContent?.skeleton as any).__activeEditorSequence!;
return (this.spine.spineContent?.skeleton as any)?.__activeEditorSequence!;
}

_activeSequence!: SpineSequence;
Expand Down Expand Up @@ -715,6 +703,14 @@ export default class SpineSequences extends ComponentDebounced<SpineSequencesPro
if (!(game.editor.selection[0] instanceof Spine)) {
return 'No Spine element elected.';
}
if (!(game.editor.selection[0] as Spine)?.spineData) {
return R.btn('spineData is not set.', () => {
game.editor.ui.propsEditor.selectField('spineData');
});
}

this.setActiveSequence(this.activeSequenceName);

let sequenceView;
if (this.activeSequence) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export default class KeyframePropertyEditor extends ComponentDebounced<KeyframeP
let selectableKeyframeTypes: ({
name: string;
value: TimelineKeyFrameType;
}[]) = keyframeTypes!.map((type) => {
}[]) = availableKeyframeTypes!.map((type) => {
return { name: READABLE_KEYFRAME_TYPES[type], value: type };
});

Expand Down Expand Up @@ -285,12 +285,6 @@ export default class KeyframePropertyEditor extends ComponentDebounced<KeyframeP
}
let jumpEditor = h(NumberEditor, { value: kf.j, step: 1, min: -99999999, max: 99999999, onChange: this.onJumpChanged });

if (document.activeElement && document.activeElement.className === 'props-editor-callback') {
window.setTimeout(() => {
(document.querySelector('.keyframe-callback-editor .props-editor-callback') as HTMLInputElement).focus();
});
}

body = R.fragment(
'Action',
R.span({ className: 'keyframe-callback-editor' },
Expand Down
1 change: 1 addition & 0 deletions thing-editor/src/editor/ui/tree-view/tree-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ export default class TreeView extends ComponentDebounced<ClassAttributes<TreeVie
const search = this.state.search.toLowerCase();

if ((o.constructor as SourceMappedConstructor).__className.toLowerCase().includes(search)) return true;
if (o.__nodeExtendData.unknownConstructor?.toLowerCase().includes(search)) return true;

if (o.__nodeExtendData.isPrefabReference && o.__nodeExtendData.isPrefabReference.toLocaleLowerCase().includes(search)) return true;

Expand Down
2 changes: 1 addition & 1 deletion thing-editor/src/editor/ui/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default class UI extends ComponentDebounced<UIProps> {
w: 100,
h: 70,
minW: 64,
minH: 400,
minH: 460,
onResize: () => {
if (game.projectDesc) {
game._onContainerResize();
Expand Down
23 changes: 23 additions & 0 deletions thing-editor/src/editor/ui/viewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@ let prefabLabelProps = {
onMouseDown: copyTextByClick
};

export enum PREFAB_PIVOT {
MIDDLE = 'middle',
LEFT_TOP = 'left-top'
}

export const __SystemBackDropPivots = [
{
name: R.icon('pivot/middle') as any,
value: PREFAB_PIVOT.MIDDLE
},
{
name: R.icon('pivot/left-top') as any,
value: PREFAB_PIVOT.LEFT_TOP
}
];

const ORIENTATION_ICON = R.icon('orientation-toggle');

const SPEED_SELECT = [0.1, 0.25, 0.5, 1, 2, 4, 8, 16, 32].map((value) => {
Expand Down Expand Up @@ -301,6 +317,13 @@ export default class Viewport extends ComponentDebounced<ClassAttributes<Viewpor
value: '#' + PrefabEditor.BGColor.toString(16).padStart(6, '0'),
title: 'Background color'
}),
h(SelectEditor, {select: __SystemBackDropPivots,
onChange: (value: PREFAB_PIVOT) => {
PrefabEditor.pivot = value;
this.refresh();
game.editor.onObjectsPropertyChanged(game.currentContainer, '__prefabPivot', value);
}, value: PrefabEditor.pivot || __SystemBackDropPivots[0].value
})
),
R.span(panelBottomProps,
orientationButton,
Expand Down
6 changes: 4 additions & 2 deletions thing-editor/src/editor/utils/editor-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,10 @@ export namespace editorUtils {
return o.children.length > 0;
};

export const onExportAsPngClick = async () => {
let o = game.editor.selection[0];
export const onExportAsPngClick = async (o?:Container) => {
if (!(o instanceof Container)) {
o = game.editor.selection[0];
}
let blob = await exportAsPng(o);
if (blob) {
let a = document.createElement('a');
Expand Down
10 changes: 6 additions & 4 deletions thing-editor/src/editor/utils/goto-label-consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ const gotoLabelHelper = (context: IGoToLabelConsumer) => {

const l = context.__getLabels();

for (let name in l) {
if (!addedLabels.has(name)) {
labels.push({ name: R.b(null, name), pureName: name });
addedLabels.add(name);
if (l) {
for (let name of l) {
if (!addedLabels.has(name)) {
labels.push({ name: R.b(null, name), pureName: name });
addedLabels.add(name);
}
}
}

Expand Down
Loading

0 comments on commit 732d44e

Please sign in to comment.