Skip to content

Commit

Permalink
Merge pull request #262 from domeengine/hotfix/1.8.2
Browse files Browse the repository at this point in the history
Hotfixing
  • Loading branch information
avivbeeri authored Mar 15, 2023
2 parents d1357c1 + 45205e1 commit a5c8286
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 122 deletions.
88 changes: 3 additions & 85 deletions .github/workflows/windows-only.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Multi-platform Build Release
name: Windows only test build
on:
workflow_dispatch
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel

jobs:
build-windows:
Expand Down Expand Up @@ -34,92 +35,9 @@ jobs:
name: dome-windows-x32
path: |
dome.exe
main.wren
- uses: actions/upload-artifact@v3
if: ${{ (matrix.msystem == 'MINGW64') }}
with:
name: dome-windows-x64
path: |
dome.exe
main.wren
release-artifacts:
if: ${{ github.event.action == 'published' }}
needs: [ build-linux, build-mac, build-windows, build-web ]
runs-on: ubuntu-latest
name: Upload Release Artifacts
steps:
- uses: actions/download-artifact@v2
- uses: montudor/action-zip@v0.1.0
with:
args: zip -qq -r dome-linux-x64.zip dome-linux-x64
- uses: montudor/action-zip@v0.1.0
with:
args: zip -qq -r dome-linux-x64-shared.zip dome-linux-x64-shared
- uses: montudor/action-zip@v0.1.0
with:
args: zip -qq -r dome-windows-x64.zip dome-windows-x64
- uses: montudor/action-zip@v0.1.0
with:
args: zip -qq -r dome-windows-x32.zip dome-windows-x32
- uses: montudor/action-zip@v0.1.0
with:
args: zip -qq -r dome-macosx-all.zip dome-macosx-all
- uses: montudor/action-zip@v0.1.0
with:
args: zip -qq -r dome-web.zip dome-web
- run: ls -la
- name: Upload Linux Shared
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./dome-linux-x64-shared.zip
asset_name: dome-${{github.event.release.tag_name}}-linux-x64-shared.zip
asset_content_type: application/zip
- name: Upload Linux Static
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./dome-linux-x64.zip
asset_name: dome-${{github.event.release.tag_name}}-linux-x64.zip
asset_content_type: application/zip
- name: Upload Windows x64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./dome-windows-x64.zip
asset_name: dome-${{github.event.release.tag_name}}-windows-x64.zip
asset_content_type: application/zip
- name: Upload Windows x32
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./dome-windows-x32.zip
asset_name: dome-${{github.event.release.tag_name}}-windows-x32.zip
asset_content_type: application/zip
- name: Upload Mac OS X
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./dome-macosx-all.zip
asset_name: dome-${{github.event.release.tag_name}}-macosx-all.zip
asset_content_type: application/zip
- name: Upload Web Engine
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./dome-web.zip
asset_name: dome-${{github.event.release.tag_name}}-web.zip
asset_content_type: application/zip
30 changes: 23 additions & 7 deletions assets/shell.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,32 @@
}

html, body {
background-color: black;
background-color: black;
color: white;
max-width: 100vw;
max-height: 100vh;
width: 100%;
height: 100%;
}

textarea.emscripten { font-family: monospace; width: 80%; display: none; }
div.emscripten { text-align: center; }
div.emscripten_border {
border: 1px solid white;
border: 0px solid white;
width: 100%;
height: 100%;
text-align:center;
margin: 0 auto;
}
/* the canvas *must not* have any border or padding, or mouse coords will be wrong */
canvas.emscripten {
margin: 0;
display:inline;
/*
width: auto;
height: 100%;
height: 100%;
*/
height: 100% !important;
width: auto !important;
border: 0px none;
background-color: black;
outline: none;
-webkit-tap-highlight-color: rgba(255, 255, 255, 0); /* mobile webkit */
image-rendering: -moz-crisp-edges;
Expand All @@ -39,7 +46,14 @@
}
</style>
<script type='text/javascript'>
window.onload = function () { window.focus(); } window.onclick = function () { window.focus(); }
window.onload = function () {
document.getElementById("canvas").focus();
pauseAudio(0);
};
window.onclick = function () {
document.getElementById("canvas").focus();
pauseAudio(0);
}
</script>
</head>
<body>
Expand Down Expand Up @@ -131,6 +145,8 @@
Module.SDL2.audio.scriptProcessorNode['connect'](Module.SDL2.audioContext['destination']);
}
}
document.getElementById('canvas').addEventListener('click', resumeAudio);
document.addEventListener('keydown', resumeAudio);
</script>
</body>
</html>
3 changes: 2 additions & 1 deletion docs/modules/dome.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,5 @@ This is the background color of the window. Note that to this _does not_ affect

#### `static resize(width: Number, height: Number): Void`

This allows you to control the size of DOME's window. The viewport will scale accordingly, but the canvas will NOT resize.
This allows you to control the size of DOME's window. The viewport will scale accordingly, but the canvas will NOT resize. DOME treats high DPI displays with a scaling factor (determined by the operating system) so the
true window size may not match your chosen dimensions.
9 changes: 8 additions & 1 deletion docs/modules/graphics.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ The code snippet above:
* It then rotates it 90 degrees clockwise
* Finally, it scales the tile up by 2 in both the X and Y direction, but it flips the tile vertically.

## SpriteSheet
## SpriteSheet

This class can load in an image and divide it into a fixed-size grid of smaller squares, as a convenience.
It's useful for loading multiple sprites from a single file. This can also be used as the foundation of an
Expand Down Expand Up @@ -300,6 +300,13 @@ Draw tile `index` on the spritesheet at location `(x, y)` on screen.
Draw tile `index` on the spritesheet at location `(x, y)` on screen. This will also apply the given transform `parameterMap` to the tile being drawn.
You can reference the `ImageData.transform` documentation for a list of available parameters.

#### `drawFrom(tileX: Number, tileY: Number, x: Number, y: Number)`
Draw tile `(tileX, tileY)` on the spritesheet at location `(x, y)` on screen.

#### `drawFrom(tileX: Number, tileY: Number, x: Number, y: Number, parameterMap)`
Draw tile `(tileX, tileY)` on the spritesheet at location `(x, y)` on screen. This will also apply the given transform `parameterMap` to the tile being drawn.
You can reference the `ImageData.transform` documentation for a list of available parameters.

### Instance Methods

#### `fg: Color`
Expand Down
Empty file removed docs/modules/image.md
Empty file.
1 change: 1 addition & 0 deletions main.wren
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "graphics" for Canvas, Color

class Main {
construct new() {}
init() {}
Expand Down
9 changes: 6 additions & 3 deletions src/engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,11 @@ ENGINE_start(ENGINE* engine) {
int result = EXIT_SUCCESS;

uint32_t windowFlags = SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE;
#if defined _WIN32
#if defined (_WIN32) || defined (__MINGW32__)
SDL_setenv("SDL_AUDIODRIVER", "directsound", true);
#else
windowFlags |= SDL_WINDOW_ALLOW_HIGHDPI;
#endif
SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, "1");

//Initialize SDL
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
Expand Down Expand Up @@ -1187,17 +1186,21 @@ ENGINE_canvasResize(ENGINE* engine, uint32_t newWidth, uint32_t newHeight, uint3
return false;
}

engine->canvas.pixels = realloc(engine->canvas.pixels, engine->canvas.width * engine->canvas.height * 4);
engine->canvas.pixels = realloc(engine->canvas.pixels, engine->canvas.width * engine->canvas.height * sizeof(uint32_t));
if (engine->canvas.pixels == NULL) {
return false;
}
/*
ENGINE_rectfill(engine, 0, 0, engine->canvas.width, engine->canvas.height, color);
*/
SDL_RenderClear(engine->renderer);
SDL_RenderGetViewport(engine->renderer, &(engine->viewport));
ENGINE_updateTextRegion(engine);

#ifdef __EMSCRIPTEN__
SDL_SetWindowSize(engine->window, engine->canvas.width, engine->canvas.height);
#endif
memset((uint32_t*)engine->canvas.pixels, color, engine->canvas.width * engine->canvas.height);

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ DOME_processInput(LOOP_STATE* state) {
{
if (event.window.event == SDL_WINDOWEVENT_RESIZED ||
event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {

SDL_RenderGetViewport(engine->renderer, &(engine->viewport));
break;
}
Expand Down Expand Up @@ -303,7 +304,6 @@ int DOME_begin(ENGINE* engine, char* entryPath) {
loop.drawMethod = wrenMakeCallHandle(vm, "draw(_)");

SDL_SetRenderDrawColor(engine->renderer, 0x00, 0x00, 0x00, 0xFF);

// Initiate game loop

wrenSetSlotHandle(vm, 0, loop.gameClass);
Expand Down
7 changes: 2 additions & 5 deletions src/modules/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,20 @@ AUDIO_allocate(WrenVM* vm) {
data->spec.freq = freq;
data->spec.format = AUDIO_F32LSB;
data->length = totalFrameCount;
} else if (strncmp(fileBuffer, "ID3", 3) == 0) {
} else {
data->audioType = AUDIO_TYPE_MP3;
drmp3_config config = { 0 };
drmp3_uint64 totalFrameCount;
tempBuffer = drmp3_open_memory_and_read_pcm_frames_s16(fileBuffer, length, &config, &totalFrameCount, NULL);
if (tempBuffer == NULL) {
VM_ABORT(vm, "Invalid MP3 file");
VM_ABORT(vm, "Audio file was of an incompatible format");
return;
}

data->spec.channels = config.channels;
data->spec.freq = config.sampleRate;
data->spec.format = AUDIO_F32LSB;
data->length = totalFrameCount;
} else {
VM_ABORT(vm, "Audio file was of an incompatible format");
return;
}

data->buffer = calloc(data->length, bytesPerSample);
Expand Down
36 changes: 20 additions & 16 deletions src/modules/dome.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,30 +65,34 @@ WINDOW_resize(WrenVM* vm) {
ENGINE* engine = (ENGINE*)wrenGetUserData(vm);
ASSERT_SLOT_TYPE(vm, 1, NUM, "width");
ASSERT_SLOT_TYPE(vm, 2, NUM, "height");

#ifndef __EMSCRIPTEN__
uint32_t width = wrenGetSlotDouble(vm, 1);
uint32_t height = wrenGetSlotDouble(vm, 2);

// Account for High DPI by comparing the current window size
// to the renderer's client output size.
// This is considered more accurate than SDL's built in methods.
int32_t currentWinWidth, currentWinHeight;
int32_t currentRenderWidth, currentRenderHeight;
SDL_GetWindowSize(engine->window, &currentWinWidth, &currentWinHeight);
SDL_GetRendererOutputSize(engine->renderer, &currentRenderWidth, &currentRenderHeight);
#ifndef __EMSCRIPTEN__
SDL_DisplayMode dm;

double factorH = currentRenderWidth / currentWinWidth;
double factorV = currentRenderHeight / currentWinHeight;
if (SDL_GetDesktopDisplayMode(0, &dm) != 0)
{
ENGINE_printLog(engine, "SDL_GetDesktopDisplayMode failed %s", SDL_GetError());
return;
}

SDL_SetWindowSize(engine->window, width / factorH, height / factorV);
int32_t displayWidth = dm.w;
int32_t displayHeight = dm.h;
if (width > displayWidth || height > displayHeight) {
SDL_MaximizeWindow(engine->window);
} else {
SDL_SetWindowSize(engine->window, width, height);
}
// Window may not have resized to the specified value because of
// desktop restraints, but SDL doesn't check this.
// We can fetch the final display size from the renderer output.
// desktop restraints, but SDL doesn't check this and remembers
// the requested size only.
// We can fetch the final display size to set to the correct value
int32_t newWidth, newHeight;
SDL_GetRendererOutputSize(engine->renderer, &newWidth, &newHeight);
SDL_SetWindowSize(engine->window, newWidth / factorH, newHeight/factorV);
SDL_GetWindowSize(engine->window, &newWidth, &newHeight);
SDL_SetWindowSize(engine->window, newWidth, newHeight);
#else
// In web mode, we fix to the canvas size and let the browser scale the window/canvas
SDL_SetWindowSize(engine->window, engine->canvas.width, engine->canvas.height);
#endif
ENGINE_updateTextRegion(engine);
Expand Down
2 changes: 1 addition & 1 deletion src/modules/graphics.wren
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class Canvas {

// These need to be at the bottom to prevent cyclic dependancy
import "color" for Color
import "image" for Drawable, ImageData, SpriteSheet
import "image" for Drawable, ImageData, SpriteSheet, Bitmap, Image
import "vector" for Point, Vec, Vector
import "font" for Font, RasterizedFont

Expand Down
6 changes: 4 additions & 2 deletions src/modules/image.wren
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ class SpriteSheet {
}

static load(path, tileSize, scale) {
var image = ImageData.loadFromFile(path)
var image = ImageData.load(path)
return SpriteSheet.new(image, tileSize, scale)
}
static load(path, tileSize) {
return SpriteSheet.loadFromFile(path, tileSize, 1)
return SpriteSheet.load(path, tileSize, 1)
}

construct new(image, tileSize) {
Expand Down Expand Up @@ -167,6 +167,8 @@ class SpriteSheet {
return _cache[s]
}

drawFrom(sx, sy, x, y, modMap) { draw(sy * _width + sx, x, y, modMap) }
drawFrom(sx, sy, x, y) { draw(sy * _width + sx, x, y) }
draw(s, x, y) { draw(s, x, y, null) }
draw(s, x, y, modMap) {
getTile(s).modify(modMap || {
Expand Down

0 comments on commit a5c8286

Please sign in to comment.