-
-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Revano of the asset viewer: it now supports grouping your assets wi…
…th categories, as well as displays handy information in forms of small icons. Besides that, every tab now supports three display modes: list/table view, regular cards, and large grid of cards.
- Loading branch information
1 parent
f4922c3
commit e9c1fcf
Showing
40 changed files
with
709 additions
and
277 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
interface IAsset { | ||
readonly type: resourceType; | ||
readonly uid: string; | ||
lastmod: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
type resourceType = 'type' | 'room' | 'sound' | 'style' | 'skeleton' | 'texture' | 'tandem'; | ||
|
||
type fontWeight = '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900'; | ||
|
||
type assetRef = -1 | string; // Either an empty string or a UID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
type canvasPatternRepeat = 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat'; | ||
|
||
interface IRoomBackground { | ||
depth: number, | ||
texture: assetRef, | ||
extends: { | ||
parallaxX?: number, | ||
parallaxY?: number, | ||
shiftX?: number, | ||
shiftY?: number, | ||
repeat: canvasPatternRepeat | ||
[key: string]: unknown | ||
} | ||
} | ||
|
||
interface IRoomCopy { | ||
x: number, | ||
y: number, | ||
uid: assetRef, | ||
tx?: number, | ||
ty?: number, | ||
exts: { | ||
[key: string]: unknown | ||
} | ||
} | ||
|
||
interface ITileTemplate { | ||
x: number; | ||
y: number; | ||
} | ||
|
||
interface ITileLayerTemplate { | ||
depth: number; | ||
tiles: Array<ITileTemplate> | ||
} | ||
|
||
interface IRoom extends IAsset { | ||
// Currently just stick to the old structure | ||
width: number, | ||
height: number, | ||
backgrounds: Array<IRoomBackground>, | ||
copies: Array<IRoomCopy>, | ||
tiles: Array<ITileLayerTemplate> | ||
gridX: number, | ||
gridY: number, | ||
oncreate: string, | ||
onstep: string, | ||
ondraw: string, | ||
onleave: string, | ||
thumbnail: string, | ||
extends: { | ||
[key: string]: unknown | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const generateGUID = require('./../../generateGUID'); | ||
|
||
const room = { | ||
type: 'room' as resourceType, | ||
oncreate: '', | ||
onstep: '', | ||
ondraw: '', | ||
onleave: '', | ||
gridX: 64, | ||
gridY: 64, | ||
width: 1280, | ||
height: 720 | ||
}; | ||
|
||
const get = function (): IRoom { | ||
const uid = generateGUID(); | ||
const newRoom = Object.assign({}, room, { | ||
name: 'Room_' + uid.slice(-6), | ||
backgrounds: [], | ||
copies: [], | ||
tiles: [], | ||
extends: {}, | ||
lastmod: Number(new Date()), | ||
thumbnail: uid, | ||
uid | ||
}); | ||
return newRoom; | ||
}; | ||
|
||
export {get}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const getDefaultRoom = require('./defaultRoom').get; | ||
const fs = require('fs-extra'); | ||
const path = require('path'); | ||
|
||
const createNewRoom = async function createNewRoom(name: string): Promise<IRoom> { | ||
const room = getDefaultRoom(); | ||
await fs.copy('./data/img/notexture.png', path.join((global as any).projdir, '/img/r' + room.uid + '.png')); | ||
if (name) { | ||
room.name = String(name); | ||
} | ||
window.currentProject.rooms.push(room); | ||
window.signals.trigger('roomsChanged'); | ||
return room; | ||
}; | ||
|
||
/** | ||
* Gets the ct.js room object by its id. | ||
* @param {string} id The id of the ct.js room | ||
* @returns {IRoom} The ct.js room object | ||
*/ | ||
const getRoomFromId = function getRoomFromId(id: string): IRoom { | ||
const room = global.currentProject.rooms.find((r: IRoom) => r.uid === id); | ||
if (!room) { | ||
throw new Error(`Attempt to get a non-existent room with ID ${id}`); | ||
} | ||
return room; | ||
}; | ||
|
||
/** | ||
* Retrieves the full path to a thumbnail of a given room. | ||
* @param {string|IRoom} room Either the id of the room, or its ct.js object | ||
* @param {boolean} [x2] If set to true, returns a 340x256 image instead of 64x64. | ||
* (Not implemented, actually!) | ||
* @param {boolean} [fs] If set to true, returns a file system path, not a URI. | ||
* @returns {string} The full path to the thumbnail. | ||
*/ | ||
const getRoomPreview = (room: assetRef | IRoom, x2: boolean, fs: boolean): string => { | ||
void x2; | ||
if (room === -1) { | ||
return 'data/img/notexture.png'; | ||
} | ||
if (typeof room === 'string') { | ||
room = getRoomFromId(room); | ||
} | ||
if (fs) { | ||
return `${(global as any).projdir}/img/r${room.thumbnail}.png`; | ||
} | ||
return `file://${(global as any).projdir}/img/r${room.thumbnail}.png?${room.lastmod}`; | ||
}; | ||
|
||
export { | ||
createNewRoom, | ||
getRoomFromId, | ||
getRoomPreview | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.