Bladeren bron

changed engine_loader to engineLoader lmfaoo

quantumde1 2 maanden geleden
bovenliggende
commit
9f513ba182
10 gewijzigde bestanden met toevoegingen van 52 en 44 verwijderingen
  1. 5 5
      conf/settings.conf
  2. 5 0
      libhpff.def
  3. BIN
      raylib.lib
  4. 1 1
      source/app.d
  5. 14 13
      source/dialogs/dialogbox.d
  6. 6 1
      source/graphics/engine.d
  7. 3 3
      source/graphics/gamelogic.d
  8. 16 14
      source/scripts/lua.d
  9. 0 2
      source/system/config.d
  10. 2 5
      source/variables.d

+ 5 - 5
conf/settings.conf

@@ -1,10 +1,10 @@
 TITLE:Remember11 - Self Chapter
-SCRIPT:scripts/SA00.lua
+SCRIPT:scripts/KO00.lua
 DIALOG_END_INDICATOR:res/misc/circle.png
-DIALOG_BOX:res/misc/TEX#win_01b.PNG
-CHOICE_BOX:res/misc/TEX#win_00b.PNG
+DIALOG_BOX:res/misc/win_01b.PNG
+CHOICE_BOX:res/misc/win_00b.PNG
 FALLBACK_FONT:res/font_en.png
 ICON:res/icon.png
-DEFAULT_SCREEN_WIDTH:1344
-DEFAULT_SCREEN_HEIGHT:1008
+DEFAULT_SCREEN_WIDTH:1024
+DEFAULT_SCREEN_HEIGHT:768
 DEFAULT_FULLSCREEN:false

+ 5 - 0
libhpff.def

@@ -0,0 +1,5 @@
+LIBRARY "libhpff"
+EXPORTS
+    Y
+    M
+    get_file_data_from_archive

BIN
raylib.lib


+ 1 - 1
source/app.d

@@ -12,5 +12,5 @@ void main(string[] args)
     } else {
         SetTraceLogLevel(7);
     }
-    engine_loader();
+    engineLoader();
 }

+ 14 - 13
source/dialogs/dialogbox.d

@@ -68,7 +68,7 @@ void draw9SliceTexture(Texture2D tex, Rectangle dest, int borderSize, Color tint
 void displayDialog(string[] pages, string[] choices, ref int selectedChoice, 
                    int choicePage, Font dialogFont, bool* showDialog, 
                    ref float textSpeed, Texture2D circle, 
-                   Texture2D dialogBackgroundTex, Texture2D choiceWindowTex) {
+                   Texture2D dialogBackgroundTex, float scale) {
     
     immutable int screenWidth = systemSettings.defaultScreenWidth;
     immutable int screenHeight = systemSettings.defaultScreenHeight;
@@ -89,7 +89,7 @@ void displayDialog(string[] pages, string[] choices, ref int selectedChoice,
     immutable float textTopMargin = 20.0f;
     immutable float textRightMargin = 33.0f;
     immutable float textWidth = dialogRect.width - textLeftMargin - textRightMargin;
-    immutable float fontSize = 40.0f;
+    immutable float fontSize = cast(int)(40.0f*scale);
     immutable float spacing = 1.0f;
     string name;
     
@@ -112,7 +112,7 @@ void displayDialog(string[] pages, string[] choices, ref int selectedChoice,
             screenWidth / 12 + MeasureTextEx(dialogFont, name.toStringz(), fontSize, spacing).x,
             screenHeight / 12
         );
-        draw9SliceTexture(choiceWindowTex, nameRect, DIALOG_BORDER, Colors.WHITE);
+        draw9SliceTexture(dialogBackgroundTex, nameRect, DIALOG_BORDER, Colors.WHITE);
         Vector2 nameSize = MeasureTextEx(dialogFont, name.toStringz(), fontSize, spacing);
         
         Vector2 namePos = Vector2(
@@ -120,7 +120,7 @@ void displayDialog(string[] pages, string[] choices, ref int selectedChoice,
             nameRect.y + (nameRect.height - nameSize.y) / 2
         );
         
-        DrawTextEx(dialogFont, name.toStringz(), namePos + Vector2(3, 3), fontSize, spacing, Colors.BLACK);
+        DrawTextEx(dialogFont, name.toStringz(), namePos + Vector2(3*scale, 3*scale), fontSize, spacing, Colors.BLACK);
         DrawTextEx(dialogFont, name.toStringz(), namePos, fontSize, spacing, Colors.WHITE);
     }
 
@@ -174,7 +174,7 @@ void displayDialog(string[] pages, string[] choices, ref int selectedChoice,
     immutable float lineHeight = MeasureTextEx(dialogFont, "A", fontSize, spacing).y * 1.4;
     foreach(i, line; lines) {
         Vector2 pos = Vector2(dialogRect.x + textLeftMargin, dialogRect.y + textTopMargin + i*lineHeight);
-        DrawTextEx(dialogFont, line.toStringz(), pos + Vector2(3, 3), fontSize, spacing, Colors.BLACK);
+        DrawTextEx(dialogFont, line.toStringz(), pos + Vector2(3*scale, 3*scale), fontSize, spacing, Colors.BLACK);
         DrawTextEx(dialogFont, line.toStringz(), pos, fontSize, spacing, Colors.WHITE);
     }
     
@@ -184,15 +184,16 @@ void displayDialog(string[] pages, string[] choices, ref int selectedChoice,
         
         float lastLineWidth = MeasureTextEx(dialogFont, lines[$-1].toStringz(), fontSize, spacing).x;
         Vector2 circlePos = Vector2(
-            dialogRect.x + textLeftMargin + lastLineWidth + 20,
-            dialogRect.y + textTopMargin + (lines.length-1)*lineHeight
+            (dialogRect.x + textLeftMargin + lastLineWidth + 20),
+            (dialogRect.y + textTopMargin + ((lines.length)-1)*lineHeight)
         );
         
+        float circleSize = 30.0f * scale;
         DrawTexturePro(
             circle,
             Rectangle(0, 0, circle.width, circle.height),
-            Rectangle(circlePos.x, circlePos.y+20, 30, 30),
-            Vector2(15, 15),
+            Rectangle(circlePos.x, circlePos.y + (scale*20), circleSize, circleSize),
+            Vector2(circleSize / 2, circleSize / 2),
             circleRotationAngle,
             Colors.WHITE
         );
@@ -211,7 +212,7 @@ void displayDialog(string[] pages, string[] choices, ref int selectedChoice,
             verticalPadding*2 + choices.length*(choiceHeight + choiceSpacing)
         );
         
-        draw9SliceTexture(choiceWindowTex, choiceWindow, CHOICE_BORDER, Colors.WHITE);
+        draw9SliceTexture(dialogBackgroundTex, choiceWindow, CHOICE_BORDER, Colors.WHITE);
         
         Vector2 mousePos = GetMousePosition();
         bool mouseClicked = IsMouseButtonPressed(MouseButton.MOUSE_BUTTON_LEFT);
@@ -227,14 +228,14 @@ void displayDialog(string[] pages, string[] choices, ref int selectedChoice,
             bool hovered = CheckCollisionPointRec(mousePos, choiceRect);
             if (hovered) selectedChoice = cast(int)i;
             
-            Vector2 textSize = MeasureTextEx(dialogFont, choice.toStringz(), 39, spacing);
+            Vector2 textSize = MeasureTextEx(dialogFont, choice.toStringz(), fontSize, spacing);
             Vector2 textPos = Vector2(
                 choiceRect.x + (choiceRect.width - textSize.x)/2,
                 choiceRect.y + (choiceRect.height - textSize.y)/2
             );
             
-            DrawTextEx(dialogFont, choice.toStringz(), textPos + Vector2(3, 3), 39, spacing, Colors.BLACK);
-            DrawTextEx(dialogFont, choice.toStringz(), textPos, 39, spacing, 
+            DrawTextEx(dialogFont, choice.toStringz(), textPos + Vector2(3*scale, 3*scale), fontSize, spacing, Colors.BLACK);
+            DrawTextEx(dialogFont, choice.toStringz(), textPos, fontSize, spacing, 
                       (i == selectedChoice) ? Colors.YELLOW : (hovered ? Colors.LIGHTGRAY : Colors.WHITE));
             
             if (hovered && mouseClicked) {

+ 6 - 1
source/graphics/engine.d

@@ -23,12 +23,17 @@ import system.config;
 import system.abstraction;
 import variables;
 import system.cleanup;
+import std.algorithm;
 
-void engine_loader()
+void engineLoader()
 {
     systemSettings = loadSettingsFromConfigFile("conf/settings.conf");
+    float baseWidth = 1344.0f;
+    float baseHeight = 1008.0f;
     int screenWidth = systemSettings.defaultScreenWidth;
     int screenHeight = systemSettings.defaultScreenHeight;
+    scale = min(cast(float)(screenWidth/baseWidth), cast(float)(screenHeight/baseHeight));
+    debugWriteln("scale: ", scale);
     // Initialization
     SetExitKey(0);
     Image icon = LoadImage(systemSettings.iconPath.toStringz());

+ 3 - 3
source/graphics/gamelogic.d

@@ -17,7 +17,6 @@ void gameInit()
 {
     circle = LoadTexture(systemSettings.dialogBoxEndIndicator.toStringz());
     dialogBackgroundTex = LoadTexture(systemSettings.dialogBoxImage.toStringz());
-    choiceWindowTex = LoadTexture(systemSettings.choiceBoxImage.toStringz());
     if (WindowShouldClose()) {
         currentGameState = GameState.Exit;
     } else {
@@ -44,7 +43,7 @@ void texturesLogic(TextureEngine[] textures) {
             float centeredX = textures[i].x - (textures[i].width * textures[i].scale / 2);
             float centeredY = textures[i].y - (textures[i].height * textures[i].scale / 2);
             
-            Color tint = Colors.WHITE;
+            Color tint = textures[i].color;
             tint.a = cast(ubyte)(255 * textures[i].alpha);
             
             DrawTextureEx(textures[i].texture,
@@ -58,6 +57,7 @@ void texturesLogic(TextureEngine[] textures) {
 }
 
 void effectsLogic() {
+    UpdateMusicStream(music);
     if (isCameraMoving) {
         float delta = GetFrameTime() * cameraMoveSpeed;
         camera.target.x += (cameraTargetX - camera.target.x) * delta;
@@ -84,6 +84,6 @@ void characterLogic() {
 void dialogLogic() {
     if (showDialog) {
         displayDialog(messageGlobal, choices, selectedChoice, choicePage, textFont, &showDialog, typingSpeed, 
-        circle, dialogBackgroundTex, choiceWindowTex);
+        circle, dialogBackgroundTex, scale);
     }
 }

+ 16 - 14
source/scripts/lua.d

@@ -9,6 +9,7 @@ import std.conv;
 import system.abstraction;
 import system.config;
 import std.string;
+import std.algorithm;
 import graphics.engine;
 import graphics.playback;
 import std.file;
@@ -105,7 +106,7 @@ extern (C) nothrow int luaL_drawBackground(lua_State* L)
         backgroundTextures[count].width = backgroundTextures[count].texture.width;
         backgroundTextures[count].x = luaL_checknumber(L, 1);
         backgroundTextures[count].y = luaL_checknumber(L, 2);
-        backgroundTextures[count].scale = luaL_checknumber(L, 3);
+        backgroundTextures[count].scale = luaL_checknumber(L, 3) * scale;
         backgroundTextures[count].drawTexture = true;
         debugWriteln(backgroundTextures[count]);
     }
@@ -180,32 +181,32 @@ extern (C) nothrow int luaL_drawCharacter(lua_State* L)
     try {
         //configuring needed parameters in characterTextures like coordinates, scale and drawTexture(its a boolean value which checks need this texture to be drawn or not)
         int count = to!int(luaL_checkinteger(L, 4));
-        characterTextures[count].scale = luaL_checknumber(L, 3);
-        characterTextures[count].y = cast(int) luaL_checkinteger(L, 2);
-        characterTextures[count].x = cast(int) luaL_checkinteger(L, 1);
+        characterTextures[count].scale = luaL_checknumber(L, 3) * scale;
+        characterTextures[count].y = cast(int) luaL_checknumber(L, 2);
+        characterTextures[count].x = cast(int) luaL_checknumber(L, 1);
         characterTextures[count].drawTexture = true;
         characterTextures[count].justDrawn = true;
         if (lua_gettop(L) == 5) {
             lua_getfield(L, 5, "r");
-            characterColor.r = cast(ubyte)lua_tointeger(L, -1);
+            characterTextures[count].color.r = cast(ubyte)lua_tointeger(L, -1);
             lua_pop(L, 1);
             
             lua_getfield(L, 5, "g");
-            characterColor.g = cast(ubyte)lua_tointeger(L, -1);
+            characterTextures[count].color.g = cast(ubyte)lua_tointeger(L, -1);
             lua_pop(L, 1);
             
             lua_getfield(L, 5, "b");
-            characterColor.b = cast(ubyte)lua_tointeger(L, -1);
+            characterTextures[count].color.b = cast(ubyte)lua_tointeger(L, -1);
             lua_pop(L, 1);
             
             lua_getfield(L, 5, "a");
             //if empty, reset to default
             if (!lua_isnil(L, -1)) {
-                characterColor.a = cast(ubyte)lua_tointeger(L, -1);
+                characterTextures[count].color.a = cast(ubyte)lua_tointeger(L, -1);
             }
             lua_pop(L, 1);
         } else {
-            characterColor = Colors.WHITE;
+            characterTextures[count].color = Colors.WHITE;
         }
         debugWriteln("Count: ", count, " drawTexture cond: ", characterTextures[count].drawTexture);
         debugWriteln("arguments count: ", lua_gettop(L));
@@ -407,7 +408,8 @@ extern (C) nothrow int luaL_loadFont(lua_State* L)
     {
         codepoints[96 + i] = 0x400 + i;
     }
-    textFont = LoadFontEx(x, 40, codepoints.ptr, codepoints.length);
+    int fontSize = max(10, cast(int)(40 * scale));
+    textFont = LoadFontEx(x, fontSize, null, 0);
     return 0;
 }
 
@@ -567,19 +569,19 @@ extern (C) nothrow int luaL_drawTexture(lua_State *L) {
         lua_pop(L, 1);
     }
     
-    DrawTexture(*texture, x, y, color);
+    DrawTextureEx(*texture, Vector2(x, y), 0.0f, scale, color);
     return 0;
 }
 
 extern (C) nothrow int luaL_getTextureWidth(lua_State *L) {
     Texture2D* texture = cast(Texture2D*)luaL_checkudata(L, 1, "Texture");
-    lua_pushinteger(L, texture.width);
+    lua_pushnumber(L, texture.width*variables.scale);
     return 1;
 }
 
 extern (C) nothrow int luaL_getTextureHeight(lua_State *L) {
     Texture2D* texture = cast(Texture2D*)luaL_checkudata(L, 1, "Texture");
-    lua_pushinteger(L, texture.height);
+    lua_pushnumber(L, texture.height*variables.scale);
     return 1;
 }
 
@@ -648,7 +650,7 @@ extern (C) nothrow int luaL_drawTextureEx(lua_State *L) {
         color.a = cast(ubyte)lua_tointeger(L, -1);
         lua_pop(L, 1);
     }
-    DrawTextureEx(*texture, Vector2(x, y), rotation, scale, color);
+    DrawTextureEx(*texture, Vector2(x, y), rotation, scale*variables.scale, color);
     
     return 0;
 }

+ 0 - 2
source/system/config.d

@@ -20,7 +20,6 @@ nothrow string parseConf(string type, string filename) {
             "icon": "ICON:",
             "dialog_end_indicator": "DIALOG_END_INDICATOR:",
             "dialog_box": "DIALOG_BOX:",
-            "choice_box": "CHOICE_BOX:",
             "fallback_font": "FALLBACK_FONT:",
             "default_screen_width": "DEFAULT_SCREEN_WIDTH:",
             "default_screen_height": "DEFAULT_SCREEN_HEIGHT:",
@@ -56,7 +55,6 @@ SystemSettings loadSettingsFromConfigFile(string confName) {
         parseConf("icon", confName),
         parseConf("dialog_end_indicator", confName),
         parseConf("dialog_box", confName),
-        parseConf("choice_box", confName),
         parseConf("fallback_font", confName),
         parseConf("default_screen_width", confName).to!int,
         parseConf("default_screen_height", confName).to!int,

+ 2 - 5
source/variables.d

@@ -31,7 +31,6 @@ struct SystemSettings {
     string iconPath;
     string dialogBoxEndIndicator;
     string dialogBoxImage;
-    string choiceBoxImage;
     string fallbackFont;
     int defaultScreenWidth;
     int defaultScreenHeight;
@@ -47,6 +46,7 @@ struct TextureEngine {
     float y;
     Texture2D texture;
     float scale;
+    Color color = Colors.WHITE;
     float alpha = 0.0f;
     float targetAlpha = 0.0f;
     float fadeSpeed = 9.0f;
@@ -81,8 +81,6 @@ Font textFont;
 
 Music music;
 
-Color characterColor = Color(255, 255, 255);
-
 /* booleans */
 
 bool playAnimation = false;
@@ -121,6 +119,7 @@ float frameDuration = 0.016f;
 
 float typingSpeed = 0.6f;
 
+float scale = 1.0f;
 
 /* textures */
 
@@ -128,8 +127,6 @@ Texture2D[] framesUI;
 
 Texture2D dialogBackgroundTex;
 
-Texture2D choiceWindowTex;
-
 Texture2D circle;
 
 /* integer values */