mirror of
https://github.com/Kapendev/parin.git
synced 2025-04-25 20:49:57 +03:00
Made viewport and mouse stuff faster.
This commit is contained in:
parent
62046365b0
commit
f21a8f8f32
5 changed files with 34 additions and 29 deletions
|
@ -70,12 +70,12 @@ bool isX(IStr path) {
|
|||
|
||||
bool isF(IStr path) {
|
||||
import std.file;
|
||||
return path.exists;
|
||||
return path.isX && path.isFile;
|
||||
}
|
||||
|
||||
bool isD(IStr path) {
|
||||
import std.file;
|
||||
return path.isDir;
|
||||
return path.isX && path.isDir;
|
||||
}
|
||||
|
||||
void echo(A...)(A args) {
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
// [Noby Script]
|
||||
|
||||
enum assetsDir = join(".", "assets");
|
||||
enum webDir = join(".", "web");
|
||||
enum readmeFile = join(".", "README.md");
|
||||
enum gitFile = join(".", ".gitignore");
|
||||
enum dubFile = join(".", "dub.json");
|
||||
enum dubLockFile = join(".", "dub.selections.json");
|
||||
enum assetsDir = "assets";
|
||||
enum webDir = "web";
|
||||
enum readmeFile = "README.md";
|
||||
enum gitFile = ".gitignore";
|
||||
enum dubFile = "dub.json";
|
||||
enum dubLockFile = "dub.selections.json";
|
||||
|
||||
enum readmeFileContent = `
|
||||
# Title
|
||||
|
@ -133,13 +133,13 @@ int runDubSetup(string[] args, bool isFirstRun) {
|
|||
}
|
||||
makeBasicSetup();
|
||||
// Find the main file and replace its content.
|
||||
auto appDir = join(".", "src");
|
||||
if (!appDir.isX) appDir = join(".", "source");
|
||||
auto appDir = "src";
|
||||
if (!appDir.isX) appDir = "source";
|
||||
auto appFile = join(appDir, "main.d");
|
||||
if (!appFile.isX) appFile = join(appDir, "app.d");
|
||||
paste(appFile, appFileContent, !isFirstRun);
|
||||
// Get a yes or no and download the raylib libraries.
|
||||
if (readYesNo("Would you like to download raylib?", args.length > 1 ? args[1] : "?").isYes) {
|
||||
if (readYesNo("Would you like to download raylib?", args.length >= 2 ? args[1] : "?").isYes) {
|
||||
echo("Downloading...");
|
||||
auto hasDubLockFileNow = dubLockFile.isX;
|
||||
auto dub1 = cmd("dub", "add", "raylib-d", "--verror");
|
||||
|
@ -165,9 +165,9 @@ int main(string[] args) {
|
|||
auto isFirstRun = !assetsDir.isX;
|
||||
auto isSimpProject = !dubFile.isX;
|
||||
if (isSimpProject) {
|
||||
result = runSimpSetup(args[1 .. $], isFirstRun);
|
||||
result = runSimpSetup(args, isFirstRun);
|
||||
} else {
|
||||
result = runDubSetup(args[1 .. $], isFirstRun);
|
||||
result = runDubSetup(args, isFirstRun);
|
||||
}
|
||||
if (result == 0) echo("Done!");
|
||||
return result;
|
||||
|
@ -198,12 +198,12 @@ bool isX(IStr path) {
|
|||
|
||||
bool isF(IStr path) {
|
||||
import std.file;
|
||||
return path.exists;
|
||||
return path.isX && path.isFile;
|
||||
}
|
||||
|
||||
bool isD(IStr path) {
|
||||
import std.file;
|
||||
return path.isDir;
|
||||
return path.isX && path.isDir;
|
||||
}
|
||||
|
||||
void echo(A...)(A args) {
|
||||
|
|
|
@ -10,12 +10,12 @@ version (Windows) {
|
|||
enum emccName = "emcc";
|
||||
}
|
||||
|
||||
enum sourceDir = join(".", "source");
|
||||
enum assetsDir = join(".", "assets");
|
||||
enum outputFile = join(".", "web", "index.html");
|
||||
enum shellFile = join(".", ".__default_shell__.html");
|
||||
enum libFile = join(".", "web", "libraylib.a");
|
||||
enum dubFile = join(".", "dub.json");
|
||||
enum sourceDir = "source";
|
||||
enum assetsDir = "assets";
|
||||
enum outputFile = join("web", "index.html");
|
||||
enum libFile = join("web", "libraylib.a");
|
||||
enum shellFile = ".__default_shell__.html";
|
||||
enum dubFile = "dub.json";
|
||||
enum dubConfig = "web";
|
||||
enum dubLibName = "webgame";
|
||||
enum dflags = ["-i", "-betterC", "--release"];
|
||||
|
@ -174,12 +174,12 @@ bool isX(IStr path) {
|
|||
|
||||
bool isF(IStr path) {
|
||||
import std.file;
|
||||
return path.exists;
|
||||
return path.isX && path.isFile;
|
||||
}
|
||||
|
||||
bool isD(IStr path) {
|
||||
import std.file;
|
||||
return path.isDir;
|
||||
return path.isX && path.isDir;
|
||||
}
|
||||
|
||||
void echo(A...)(A args) {
|
||||
|
|
|
@ -20,7 +20,7 @@ static assert(headerStart == headerEnd, "The header should start and end with th
|
|||
|
||||
int main(string[] args) {
|
||||
// Basic error checking.
|
||||
if (args.length == 1 || (!args[1].isX || !args[1].isD)) {
|
||||
if (args.length == 1 || !args[1].isD) {
|
||||
echof("Provide a folder containing `%s` files.", fileExt);
|
||||
return 1;
|
||||
}
|
||||
|
@ -63,12 +63,12 @@ bool isX(IStr path) {
|
|||
|
||||
bool isF(IStr path) {
|
||||
import std.file;
|
||||
return path.exists;
|
||||
return path.isX && path.isFile;
|
||||
}
|
||||
|
||||
bool isD(IStr path) {
|
||||
import std.file;
|
||||
return path.isDir;
|
||||
return path.isX && path.isDir;
|
||||
}
|
||||
|
||||
void echo(A...)(A args) {
|
||||
|
|
|
@ -892,6 +892,7 @@ struct EngineFullscreenState {
|
|||
struct EngineState {
|
||||
EngineFlags flags;
|
||||
EngineFullscreenState fullscreenState;
|
||||
EngineViewportInfo viewportInfoBuffer;
|
||||
|
||||
Sz tickCount;
|
||||
Color borderColor;
|
||||
|
@ -1287,6 +1288,7 @@ void openWindow(int width, int height, const(IStr)[] args, IStr title = "Parin")
|
|||
engineState.fullscreenState.previousWindowHeight = height;
|
||||
engineState.viewport.data.color = gray;
|
||||
engineState.viewport.data.blend = Blend.init;
|
||||
engineViewportInfo(true);
|
||||
// Ready resources.
|
||||
if (args.length) {
|
||||
foreach (arg; args) engineState.envArgsBuffer.append(arg);
|
||||
|
@ -1368,6 +1370,7 @@ void updateWindow(bool function(float dt) updateFunc) {
|
|||
engineState.viewport.data.resize(engineState.viewport.lockWidth, engineState.viewport.lockHeight);
|
||||
}
|
||||
engineState.viewport.isChanging = false;
|
||||
engineViewportInfo(true);
|
||||
}
|
||||
// Fullscreen code.
|
||||
if (engineState.fullscreenState.isChanging) {
|
||||
|
@ -1563,8 +1566,9 @@ Fault setWindowIconFromFiles(IStr path) {
|
|||
}
|
||||
|
||||
/// Returns information about the engine viewport, including its area.
|
||||
EngineViewportInfo engineViewportInfo() {
|
||||
auto result = EngineViewportInfo();
|
||||
EngineViewportInfo engineViewportInfo(bool isRecalculationForced = false) {
|
||||
auto result = &engineState.viewportInfoBuffer;
|
||||
if (!isRecalculationForced && !isWindowResized) return *result;
|
||||
if (isResolutionLocked) {
|
||||
result.minSize = resolution;
|
||||
result.maxSize = windowSize;
|
||||
|
@ -1588,7 +1592,7 @@ EngineViewportInfo engineViewportInfo() {
|
|||
result.minRatio = 1.0f;
|
||||
result.area = Rect(result.minSize);
|
||||
}
|
||||
return result;
|
||||
return *result;
|
||||
}
|
||||
|
||||
/// Returns the default engine font. This font should not be freed.
|
||||
|
@ -1643,6 +1647,7 @@ void lockResolution(int width, int height) {
|
|||
engineState.viewport.isChanging = true;
|
||||
} else {
|
||||
engineState.viewport.data.resize(width, height);
|
||||
engineViewportInfo(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue