Skip to content

Commit

Permalink
Merge pull request #1382 from pau-tomas/default_scene_types
Browse files Browse the repository at this point in the history
Use default scene types if there's none in engine.json
  • Loading branch information
chrismaltby authored Apr 10, 2024
2 parents cc6b2c0 + edfd070 commit 27fbc98
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
2 changes: 1 addition & 1 deletion appData/src/gb/engine.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "3.2.0-e4",
"version": "3.3.0-e0",
"fields": [
{
"key": "INPUT_PLATFORM_JUMP",
Expand Down
10 changes: 10 additions & 0 deletions src/lib/project/ejectEngineChangelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,16 @@ const changes: EngineChange[] = [
].join("\n"),
modifiedFiles: ["include/sio.h", "src/core/sio.c"],
},
{
version: "3.3.0-e0",
description:
"Updates\n" + [" * Added scene types to engine.json"].join("\n"),
modifiedFiles: [
"engine.json",
"src/gb/include/data/scene_types.h",
"src/gb/include/gbs_types.h",
],
},
];

const ejectEngineChangelog = (currentVersion: string) => {
Expand Down
31 changes: 31 additions & 0 deletions src/lib/project/sceneTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,33 @@ export interface SceneTypeSyncResult {

export const sceneTypesEmitter = new EventEmitter.EventEmitter();

const defaultSceneTypes = [
{
key: "TOPDOWN",
label: "GAMETYPE_TOP_DOWN",
},
{
key: "PLATFORM",
label: "GAMETYPE_PLATFORMER",
},
{
key: "ADVENTURE",
label: "GAMETYPE_ADVENTURE",
},
{
key: "SHMUP",
label: "GAMETYPE_SHMUP",
},
{
key: "POINTNCLICK",
label: "GAMETYPE_POINT_N_CLICK",
},
{
key: "LOGO",
label: "GAMETYPE_LOGO",
},
];

export const loadSceneTypes = async (
projectRoot: string
): Promise<SceneTypeSchema[]> => {
Expand Down Expand Up @@ -44,6 +71,10 @@ export const loadSceneTypes = async (
sceneTypes = defaultEngine.sceneTypes;
}

if (!sceneTypes || (sceneTypes && sceneTypes.length === 0)) {
sceneTypes = defaultSceneTypes;
}

const enginePlugins = glob.sync(`${pluginsPath}/*/engine`);
for (const enginePluginPath of enginePlugins) {
const enginePluginJsonPath = Path.join(enginePluginPath, "engine.json");
Expand Down
1 change: 0 additions & 1 deletion src/store/features/engine/engineState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export type EngineFieldSchema = {
export type SceneTypeSchema = {
key: string;
label: string;
file: string;
};

export interface EngineState {
Expand Down

0 comments on commit 27fbc98

Please sign in to comment.