Skip to content

Commit

Permalink
✨ Bitmap fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
CosmoMyzrailGorynych committed Aug 3, 2020
1 parent 9705517 commit d138931
Show file tree
Hide file tree
Showing 35 changed files with 913 additions and 87 deletions.
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# EditorConfig: https://EditorConfig.org

root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

[*.{js,ts,styl,pug}]
indent_style = space
indent_size = 4
charset = utf-8

[{package.json,.travis.yml}]
indent_style = space
indent_size = 2
charset = utf-8
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ app/export
*.ict.recovery

# editor-specific
/.vscode
.vscode/settings.json

# docs
docs/db.json
Expand Down
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "nwjs",
"request": "launch",
"name": "Launch ct.js",
"nwjsVersion": "0.34.5",
"webRoot": "${workspaceFolder}/app",
"reloadAfterAttached": true
}
]
}
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ gulp -f devSetup.gulpfile.js
gulp
```

VSCode can use [this extension](https://marketplace.visualstudio.com/items?itemName=ruakr.vsc-nwjs) to run ct.js with an attached debugger. Use `gulp dev` instead of just `gulp` to run a dev service with live-reloading without opening ct.js in its default manner.

## Releasing ct.js

This is left for emergencies only, as Travis should prepare binaries for github and send them to itch.io as well
Expand All @@ -91,4 +93,4 @@ The first run will be slow as it will download nw.js binaries. Next runs will us

## Naming conventions for commits

Use [Gitmoji-flavored Comigoji](https://comigo.gitlab.io/comigoji/#gitmoji) for naming your commits.
Use [Gitmoji-flavored Comigoji](https://comigo.gitlab.io/comigoji/#gitmoji) for naming your commits.
2 changes: 2 additions & 0 deletions app/data/ct.release/inputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ class CtAction {
if (ind !== -1) {
this.methodMultipliers[ind] = multiplier;
} else {
// eslint-disable-next-line no-console
console.warning(`[ct.inputs] An attempt to change multiplier of a non-existent method "${code}" at event ${this.name}`);
// eslint-disable-next-line no-console
console.trace();
}
}
Expand Down
29 changes: 24 additions & 5 deletions app/data/i18n/English.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,16 @@
},
"menu": {
"ctIDE": "ct.IDE",
"exportDesktop": "Export for desktop",
"exportDesktop": "Export for desktop",
"texture": "Textures",
"launch": "Compile and run",
"launch": "Launch",
"launchHotkeys": "(F5; Alt+F5 to run in your default browser)",
"license": "License",
"min": "Windowed",
"modules": "Catmods",
"patrons": "Patrons",
"recentProjects": "Recent projects",
"restart": "Restart",
"rooms": "Rooms",
"save": "Save project",
"startScreen": "Return to the starting screen",
Expand Down Expand Up @@ -170,7 +171,9 @@
"disableAcceleration": "Disable graphics acceleration (needs restart)",
"disableBuiltInDebugger": "Disable built-in debugger",
"visitDiscordForGamedevSupport": "Join Discord server for gamedev support",
"postAnIssue": "Post an issue on Github"
"postAnIssue": "Post an issue on Github…",
"openProject": "Open a project…",
"openExample": "Open an example project…"
},
"onboarding": {
"hoorayHeader": "Wow! You've just created a project!",
Expand Down Expand Up @@ -349,7 +352,23 @@
"typefacename": "Typeface name:",
"fontweight": "Font weight:",
"italic": "Is italic?",
"reimport": "Reimport"
"reimport": "Reimport",
"generateBitmapFont": "Also generate a bitmap font",
"bitmapFont": "Bitmap font",
"bitmapFontSize": "Font size:",
"bitmapFontLineHeight": "Line height:",
"resultingBitmapFontName": "Resource name",
"charset": "Charset:",
"charsets": {
"punctuation": "Digits and punctuation (you usually do need this)",
"basicLatin": "Basic Latin",
"latinExtended": "Latin extended",
"cyrillic": "Cyrillic",
"greekCoptic": "Greek and Coptic",
"custom": "Custom",
"allInFont": "Draw everything the font supports"
},
"customCharsetHint": "Type all the letters you want to include, both in upper and lower case."
},
"particleEmitters": {
"emittersHeading": "Particle emitters",
Expand Down Expand Up @@ -543,4 +562,4 @@
"is elegant and beautiful 🎩"
]
}
}
}
21 changes: 20 additions & 1 deletion app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"monaco-editor": "^0.20.0",
"monaco-themes": "^0.3.3",
"node-static": "^0.7.11",
"opentype.js": "^1.3.3",
"pixi-particles": "^4.2.1",
"pixi.js-legacy": "5.1.2",
"png2icons": "^2.0.1",
Expand Down
20 changes: 17 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const path = require('path'),

spawnise = require('./node_requires/spawnise');

const nwVersion = '0.34.5',
const nwVersion = '0.45.6',
platforms = ['osx64', 'win32', 'win64', 'linux32', 'linux64'],
nwFiles = ['./app/**', '!./app/export/**', '!./app/projects/**', '!./app/exportDesktop/**', '!./app/cache/**', '!./app/.vscode/**', '!./app/JamGames/**'];

Expand Down Expand Up @@ -118,7 +118,9 @@ const concatScripts = () =>
gulp.src(['./src/js/**', '!./src/js/3rdparty/riot.min.js']),
gulp.src('./temp/riot.js')
)
.pipe(sourcemaps.init())
.pipe(sourcemaps.init({
largeFile: true
}))
.pipe(concat('bundle.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest('./app/data/'))
Expand All @@ -135,12 +137,18 @@ const concatScripts = () =>
.on('change', fileChangeNotifier);
const copyRequires = () =>
gulp.src('./src/node_requires/**/*')
.pipe(sourcemaps.init())
// ¯\_(ツ)_/¯
.pipe(sourcemaps.mapSources((sourcePath) => '../../src/' + sourcePath))
.pipe(sourcemaps.write())
.pipe(gulp.dest('./app/data/node_requires'));

const compileScripts = gulp.series(compileRiot, concatScripts);

const icons = () =>
gulp.src('./src/icons/**/*.svg')
gulp.src('./src/icons/**/*.svg', {
base: './src/icons'
})
.pipe(sprite())
.pipe(gulp.dest('./app/data'));

Expand Down Expand Up @@ -528,7 +536,12 @@ const launchDevMode = done => {
launchApp();
done();
};
const launchDevModeNoNW = done => {
watch();
done();
};
const defaultTask = gulp.series(build, launchDevMode);
const devNoNW = gulp.series(build, launchDevModeNoNW);

exports.lintJS = lintJS;
exports.lintTags = lintTags;
Expand All @@ -542,5 +555,6 @@ exports.build = build;
exports.deploy = deploy;
exports.deployOnly = deployOnly;
exports.default = defaultTask;
exports.dev = devNoNW;
exports.bakeCompletions = bakeCompletions;
exports.bakeTypedefs = bakeTypedefs;
8 changes: 7 additions & 1 deletion src/js/gulpWatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
const reload = () => {
if (!reloading) {
reloading = true;
nw.App.quit();
if (nw.App.fullArgv.find(arg => arg.indexOf('--remote-debugging-port') !== -1)) {
// Seems that we have an external debugger attached. Reload.
nw.Window.get().reload();
} else {
// Quit and let gulp handle the reload.
nw.App.quit();
}
}
};
gulp.watch(['./data/theme*.css', './index.html', './data/bundle.js', './data/js/**.js', './data/node_requires/**/*.js'], reload);
Expand Down
6 changes: 6 additions & 0 deletions src/js/loadProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@
};

window.loadProject = proj => {
if (!proj) {
const baseMessage = 'An attempt to open a project with an empty path.';
alertify.error(baseMessage + ' See the console for the call stack.');
const err = new Error(baseMessage);
throw err;
}
sessionStorage.projname = path.basename(proj);
global.projdir = path.dirname(proj) + path.sep + path.basename(proj, '.ict');

Expand Down
11 changes: 11 additions & 0 deletions src/js/migration/1.3.2.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ window.migrationProcess.push({
}
}

/**
* Fonts can now be exported as bitmap fonts
*/
for (const font of project.fonts) {
font.bitmapFont = font.bitmapFont || false;
font.bitmapFontSize = font.bitmapFontSize || 16;
font.bitmapFontLineHeight = font.bitmapFontLineHeight || 18;
font.charsets = font.charsets || ['allInFont'];
font.customCharset = font.customCharset || '';
}

resolve();
})
});
Loading

0 comments on commit d138931

Please sign in to comment.