Skip to content

Commit

Permalink
✨ Project templates functionality; debuting with a platformer template!
Browse files Browse the repository at this point in the history
  • Loading branch information
CosmoMyzrailGorynych committed Feb 12, 2022
1 parent ad68393 commit 3d81647
Show file tree
Hide file tree
Showing 44 changed files with 4,321 additions and 9 deletions.
2 changes: 2 additions & 0 deletions app/data/i18n/English.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@
"browse": "Browse",
"latest": "Latest projects",
"examples": "Examples",
"templates": "Templates",
"templatesInfo": "You can kickstart your game development by using one of these templates. They contain placeholder graphics only but have working mechanics. Selecting a project will open a save directory selector for your new project.",
"unableToWriteToFolders": "Ct.js could not find an appropriate place for projects! Make sure you store ct.js app inside a folder you have access to write to.",
"twitter": "Twitter channel",
"discord": "Discord community",
Expand Down
14 changes: 10 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,9 @@ if ((/^win/).test(process.platform)) {
const examples = () => gulp.src('./src/examples/**/*')
.pipe(gulp.dest('./app/examples'));

const templates = () => gulp.src('./src/projectTemplates/**/*')
.pipe(gulp.dest('./app/templates'));

// eslint-disable-next-line valid-jsdoc
/**
* @see https://stackoverflow.com/a/22907134
Expand All @@ -614,10 +617,13 @@ const patronsCache = done => {
const packages = gulp.series([
lint,
abortOnWindows,
build,
docs,
patronsCache,
examples,
gulp.parallel([
build,
docs,
patronsCache,
examples,
templates
]),
bakePackages,
// fixSymlinks,
// fixPermissions,
Expand Down
1 change: 1 addition & 0 deletions src/js/roomTileTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@
hidden: false
};
this.room.tiles.push(layer);
this.resortRoom();
}
for (const tile of this.selectedTiles) {
const ind = this.currentTileLayer.tiles.indexOf(tile);
Expand Down
18 changes: 17 additions & 1 deletion src/node_requires/resources/projects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@ const getExamplesDir = function (): string {
}
};

const getTemplatesDir = function (): string {
const path = require('path');
try {
require('gulp');
// Most likely, we are in a dev environment
return path.join((nw.App as any).startPath, 'src/projectTemplates');
} catch (e) {
const {isMac} = require('./../../platformUtils');
if (isMac) {
return path.join(process.cwd(), 'templates');
}
return path.join((nw.App as any).startPath, 'templates');
}
};

/**
* Returns a path that does not end with `.ict`
* @param {string} projPath
Expand Down Expand Up @@ -65,5 +80,6 @@ export {
getProjectThumbnail,
getProjectIct,
getProjectDir,
getExamplesDir
getExamplesDir,
getTemplatesDir
};
Loading

0 comments on commit 3d81647

Please sign in to comment.