Appearance
App API
Application-level controls: name, version, paths, quit and relaunch.
Methods
getName()
Get the configured application name.
javascript
const name = await gemshell.app.getName();Returns: Promise<string>
getVersion()
Get the application version (from app.version in gemshell.config.json).
javascript
const version = await gemshell.app.getVersion();Returns: Promise<string>
isPackaged()
Check if the app is running as a packaged build (production) or in development.
javascript
const packaged = await gemshell.app.isPackaged();Returns: Promise<boolean>
getPath(name)
Look up a system path. Useful for save directories, downloads, screenshots, etc.
javascript
const userData = await gemshell.app.getPath('userData');
const downloads = await gemshell.app.getPath('downloads');Parameters:
name- Path name (string). Defaults to'userData'.
Supported names:
| Name | Description |
|---|---|
userData | Per-user app data directory (default save location) |
home | User's home directory |
appData | Per-user application data directory |
temp | Temporary directory |
desktop | The current user's Desktop |
documents | The user's Documents folder |
downloads | The user's Downloads folder |
music | The user's Music folder |
pictures | The user's Pictures folder |
videos | The user's Videos folder |
logs | App-specific log directory |
Returns: Promise<string> - Empty string if the name is invalid.
quit()
Quit the application gracefully.
javascript
await gemshell.app.quit();Returns: Promise<boolean>
relaunch()
Restart the application. The current instance exits and a fresh one is started.
javascript
await gemshell.app.relaunch();Returns: Promise<boolean>
Examples
About Dialog
javascript
async function showAbout() {
const name = await gemshell.app.getName();
const version = await gemshell.app.getVersion();
await gemshell.dialog.message(name, `Version ${version}`);
}Open Save Folder
javascript
async function openSaveFolder() {
const userData = await gemshell.app.getPath('userData');
await gemshell.os.showInFolder(userData);
}Apply Settings and Restart
javascript
async function applyLanguage(lang) {
await gemshell.file.save('settings', { language: lang });
const confirmed = await gemshell.dialog.confirm(
'Restart required',
'Restart the game now to apply the new language?'
);
if (confirmed) {
await gemshell.app.relaunch();
}
}Confirm Before Quitting
javascript
async function quitWithConfirm() {
const confirmed = await gemshell.dialog.confirm('Quit Game?', 'Unsaved progress will be lost.');
if (confirmed) {
await gemshell.app.quit();
}
}Dev-only Logging
javascript
async function log(...args) {
if (!(await gemshell.app.isPackaged())) {
console.log('[dev]', ...args);
}
}