Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/runner.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,8 @@ static void rebuildDrawableCacheIfDirty(Runner* runner) {
}

void Runner_draw(Runner* runner) {
if (!runner->drawAutomatic) return;

Room* room = runner->currentRoom;

rebuildDrawableCacheIfDirty(runner);
Expand Down Expand Up @@ -927,6 +929,8 @@ void Runner_draw(Runner* runner) {
}

void Runner_drawGUI(Runner* runner, int32_t windowW, int32_t windowH, int32_t targetW, int32_t targetH) {
if (!runner->drawAutomatic) return;

rebuildDrawableCacheIfDirty(runner);
Drawable* drawables = runner->cachedDrawables;
int32_t drawableCount = (int32_t) arrlen(drawables);
Expand Down Expand Up @@ -1017,6 +1021,8 @@ static void applyFreeCamera(Runner* runner, int32_t* viewX, int32_t* viewY, int3
}

void Runner_drawViews(Runner* runner, int32_t gameW, int32_t gameH, float displayScaleX, float displayScaleY, bool debugShowCollisionMasks) {
if (!runner->drawAutomatic) return;

Renderer* renderer = runner->renderer;
bool anyViewRendered = false;

Expand Down Expand Up @@ -1863,6 +1869,7 @@ Runner* Runner_create(DataWin* dataWin, VMContext* vm, Renderer* renderer, FileS
runner->appSurfaceEnabled = true;
runner->appSurfaceAutoDraw = true;
runner->usingAppSurface = true;
runner->drawAutomatic = true;
runner->applicationWidth = (int32_t) dataWin->gen8.defaultWindowWidth;
runner->applicationHeight = (int32_t) dataWin->gen8.defaultWindowHeight;
runner->oldApplicationWidth = runner->applicationWidth;
Expand Down
2 changes: 2 additions & 0 deletions src/runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,8 @@ struct Runner {
// GameMaker launcher parameters
// Just like the original runner, argv[0] is included in gameArgs
char** gameArgs;

bool drawAutomatic;
};

const char* Runner_getEventName(int32_t eventType, int32_t eventSubtype);
Expand Down
12 changes: 12 additions & 0 deletions src/vm_builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -7946,6 +7946,17 @@ static RValue builtin_psn_setup_trophies(MAYBE_UNUSED VMContext* ctx, RValue* ar
}

// Draw functions

static RValue builtin_draw_enable_drawevent(VMContext* ctx, RValue* args, MAYBE_UNUSED int32_t argCount) {
if (1 > argCount) return RValue_makeUndefined();
Runner* runner = ctx->runner;
if (runner != nullptr) {
runner->drawAutomatic = RValue_toBool(args[0]);
}
return RValue_makeUndefined();
}


static RValue builtin_draw_sprite(VMContext* ctx, RValue* args, MAYBE_UNUSED int32_t argCount) {
Runner* runner = ctx->runner;
if (runner->renderer == nullptr) return RValue_makeUndefined();
Expand Down Expand Up @@ -13753,6 +13764,7 @@ void VMBuiltins_registerAll(VMContext* ctx) {
VM_registerBuiltin(ctx, "psn_setup_trophies", builtin_psn_setup_trophies);

// Draw
VM_registerBuiltin(ctx, "draw_enable_drawevent", builtin_draw_enable_drawevent);
VM_registerBuiltin(ctx, "draw_sprite", builtin_draw_sprite);
VM_registerBuiltin(ctx, "draw_sprite_ext", builtin_draw_sprite_ext);
VM_registerBuiltin(ctx, "draw_sprite_tiled", builtin_draw_sprite_tiled);
Expand Down
Loading