mirror of
https://github.com/Kapendev/parin.git
synced 2025-04-28 14:09:53 +03:00
Worked on touch support.
This commit is contained in:
parent
b91e8e6267
commit
4c75665d35
3 changed files with 8 additions and 5 deletions
|
@ -68,7 +68,7 @@ enum defaultDUBContent = `{
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "web",
|
"name": "web",
|
||||||
"targetType": "library",
|
"targetType": "staticLibrary",
|
||||||
"targetName": "webgame",
|
"targetName": "webgame",
|
||||||
"dflags": ["-mtriple=wasm32-unknown-unknown-wasm", "-checkaction=halt", "-betterC", "--release", "-i"]
|
"dflags": ["-mtriple=wasm32-unknown-unknown-wasm", "-checkaction=halt", "-betterC", "--release", "-i"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -858,12 +858,13 @@ Vec2 mouseScreenPosition() {
|
||||||
auto window = windowSize;
|
auto window = windowSize;
|
||||||
auto minRatio = min(window.x / engineState.viewport.size.x, window.y / engineState.viewport.size.y);
|
auto minRatio = min(window.x / engineState.viewport.size.x, window.y / engineState.viewport.size.y);
|
||||||
auto targetSize = engineState.viewport.size * Vec2(minRatio);
|
auto targetSize = engineState.viewport.size * Vec2(minRatio);
|
||||||
|
// We use touch because it works on desktop, web and phones.
|
||||||
return Vec2(
|
return Vec2(
|
||||||
(ray.GetMouseX() - (window.x - targetSize.x) * 0.5f) / minRatio,
|
(ray.GetTouchX() - (window.x - targetSize.x) * 0.5f) / minRatio,
|
||||||
(ray.GetMouseY() - (window.y - targetSize.y) * 0.5f) / minRatio,
|
(ray.GetTouchY() - (window.y - targetSize.y) * 0.5f) / minRatio,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return Vec2(ray.GetMouseX(), ray.GetMouseY());
|
return Vec2(ray.GetTouchX(), ray.GetTouchY());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -198,7 +198,7 @@ int main(string[] args) {
|
||||||
if (run(command.format(extraFlags, dflags, popkaParentDir, sourceDir, firstFiles))) return 1;
|
if (run(command.format(extraFlags, dflags, popkaParentDir, sourceDir, firstFiles))) return 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
enum command = "dub build --compiler ldc --config %s";
|
enum command = "dub build --compiler ldc --config %s --build release";
|
||||||
if (run(command.format(dubWebConfig))) return 1;
|
if (run(command.format(dubWebConfig))) return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,12 +243,14 @@ int main(string[] args) {
|
||||||
enum command = "emcc -o %s %s %s -Wall -DPLATFORM_WEB %s -s USE_GLFW=3 -s ERROR_ON_UNDEFINED_SYMBOLS=0 --shell-file %s";
|
enum command = "emcc -o %s %s %s -Wall -DPLATFORM_WEB %s -s USE_GLFW=3 -s ERROR_ON_UNDEFINED_SYMBOLS=0 --shell-file %s";
|
||||||
if (run(command.format(output, dubLib, cflags, libraryFile, canUseDefaultShell ? defaultShellFile : shellFile))) {
|
if (run(command.format(output, dubLib, cflags, libraryFile, canUseDefaultShell ? defaultShellFile : shellFile))) {
|
||||||
if (canUseDefaultShell) std.file.remove(defaultShellFile);
|
if (canUseDefaultShell) std.file.remove(defaultShellFile);
|
||||||
|
std.file.remove(dubLib);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
enum command = "emcc -o %s %s %s -Wall -DPLATFORM_WEB %s -s USE_GLFW=3 -s ERROR_ON_UNDEFINED_SYMBOLS=0 --shell-file %s --preload-file %s";
|
enum command = "emcc -o %s %s %s -Wall -DPLATFORM_WEB %s -s USE_GLFW=3 -s ERROR_ON_UNDEFINED_SYMBOLS=0 --shell-file %s --preload-file %s";
|
||||||
if (run(command.format(output, dubLib, cflags, libraryFile, canUseDefaultShell ? defaultShellFile : shellFile, assetsDir))) {
|
if (run(command.format(output, dubLib, cflags, libraryFile, canUseDefaultShell ? defaultShellFile : shellFile, assetsDir))) {
|
||||||
if (canUseDefaultShell) std.file.remove(defaultShellFile);
|
if (canUseDefaultShell) std.file.remove(defaultShellFile);
|
||||||
|
std.file.remove(dubLib);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue