From af9904c89251baf7e5afdf2b8dc6e62552551ef1 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Fri, 13 Feb 2026 19:36:59 -0600 Subject: [PATCH] Scripts work again. --- CMakeLists.txt | 25 +++-- assets/init.lua | 3 +- assets/minesweeper/CMakeLists.txt | 9 -- assets/minesweeper/background.png | Bin 2787 -> 0 bytes assets/minesweeper/border.png | Bin 1979 -> 0 bytes assets/minesweeper/cell.png | Bin 2257 -> 0 bytes assets/minesweeper/grid.png | Bin 1783 -> 0 bytes assets/minesweeper/grid_bg.png | Bin 123 -> 0 bytes assets/minesweeper/ui.png | Bin 1981 -> 0 bytes assets/scene/minesweeper.lua | 129 ++++++++++++---------- assets/ui/CMakeLists.txt | 6 - assets/ui/minogram.png | Bin 1260 -> 0 bytes src/asset/asset.c | 2 +- src/asset/type/assetlanguage.c | 77 +------------ src/asset/type/assetlanguage.h | 25 ----- src/asset/type/assettexture.c | 2 +- src/display/text.h | 4 +- src/engine/engine.c | 2 +- src/locale/localemanager.c | 23 ++-- src/script/module/display/moduletileset.c | 46 ++++---- src/script/module/locale/modulelocale.c | 102 ++++++++--------- src/script/module/system/modulesystem.c | 10 +- 22 files changed, 183 insertions(+), 282 deletions(-) delete mode 100644 assets/minesweeper/CMakeLists.txt delete mode 100644 assets/minesweeper/background.png delete mode 100644 assets/minesweeper/border.png delete mode 100644 assets/minesweeper/cell.png delete mode 100644 assets/minesweeper/grid.png delete mode 100644 assets/minesweeper/grid_bg.png delete mode 100644 assets/minesweeper/ui.png delete mode 100644 assets/ui/CMakeLists.txt delete mode 100644 assets/ui/minogram.png diff --git a/CMakeLists.txt b/CMakeLists.txt index d123bd9..ab7c886 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,7 @@ set(DUSK_BUILD_BINARY ${DUSK_BUILD_DIR}/Dusk CACHE INTERNAL ${DUSK_CACHE_TARGET} set(DUSK_ASSETS "" CACHE INTERNAL ${DUSK_CACHE_TARGET}) set(DUSK_LIBRARY_TARGET_NAME "DuskCore" CACHE INTERNAL ${DUSK_CACHE_TARGET}) set(DUSK_BINARY_TARGET_NAME "Dusk" CACHE INTERNAL ${DUSK_CACHE_TARGET}) +set(DUSK_ASSETS_ZIP "${DUSK_BUILD_DIR}/dusk.dsk" CACHE INTERNAL ${DUSK_CACHE_TARGET}) # Create directories file(MAKE_DIRECTORY ${DUSK_GENERATED_HEADERS_DIR}) @@ -176,16 +177,18 @@ if(ENABLE_TESTS) endif() # Build assets -# dusk_run_python( -# DUSK_ASSETS_BUILT -# tools.asset.bundle -# --assets ${DUSK_ASSETS_DIR} -# --output-assets ${DUSK_BUILT_ASSETS_DIR} -# --output-file ${DUSK_BUILD_DIR}/dusk.dsk -# --headers-dir ${DUSK_GENERATED_HEADERS_DIR} -# --input ${DUSK_ASSETS} -# ) -# add_dependencies(${DUSK_LIBRARY_TARGET_NAME} DUSK_ASSETS_BUILT) +file(GLOB_RECURSE DUSK_ASSET_FILES CONFIGURE_DEPENDS "${DUSK_ASSETS_DIR}/*") +add_custom_command( + OUTPUT "${DUSK_ASSETS_ZIP}" + COMMAND ${CMAKE_COMMAND} -E make_directory "${DUSK_ASSETS_DIR}" + COMMAND ${CMAKE_COMMAND} -E rm -f "${DUSK_ASSETS_ZIP}" + COMMAND ${CMAKE_COMMAND} -E tar "cf" "${DUSK_ASSETS_ZIP}" --format=zip -- . + WORKING_DIRECTORY "${DUSK_ASSETS_DIR}" + DEPENDS ${DUSK_ASSET_FILES} + VERBATIM +) +add_custom_target(DUSK_ASSETS_BUILT DEPENDS "${DUSK_ASSETS_ZIP}") +add_dependencies(${DUSK_LIBRARY_TARGET_NAME} DUSK_ASSETS_BUILT) # Include generated headers target_include_directories(${DUSK_LIBRARY_TARGET_NAME} PUBLIC @@ -200,7 +203,7 @@ if(DUSK_TARGET_SYSTEM STREQUAL "psp") BACKGROUND_PATH NULL PREVIEW_PATH NULL TITLE "${DUSK_BINARY_TARGET_NAME}" - PSAR_PATH ${DUSK_BUILD_DIR}/dusk.dsk + PSAR_PATH ${DUSK_ASSETS_ZIP} VERSION 01.00 ) elseif(DUSK_TARGET_SYSTEM STREQUAL "gamecube" OR DUSK_TARGET_SYSTEM STREQUAL "wii") diff --git a/assets/init.lua b/assets/init.lua index 9c63a70..b50800b 100644 --- a/assets/init.lua +++ b/assets/init.lua @@ -56,5 +56,4 @@ else end end -localeSet(DUSK_LOCALE_EN_US) -sceneSet('scene/minesweeper.dsf') \ No newline at end of file +sceneSet('scene/minesweeper.lua') \ No newline at end of file diff --git a/assets/minesweeper/CMakeLists.txt b/assets/minesweeper/CMakeLists.txt deleted file mode 100644 index 575320b..0000000 --- a/assets/minesweeper/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (c) 2026 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -add_asset(TILESET ui.png type=PALETTIZED tileWidth=8 tileHeight=8) -add_asset(TILESET cell.png type=PALETTIZED tileWidth=8 tileHeight=8) -add_asset(TILESET border.png type=PALETTIZED tileWidth=8 tileHeight=8) -add_asset(IMAGE grid_bg.png type=PALETTIZED) \ No newline at end of file diff --git a/assets/minesweeper/background.png b/assets/minesweeper/background.png deleted file mode 100644 index 705b895843fc7fae77ba44a4cc6dcb5877e1ac22..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2787 zcmeAS@N?(olHy`uVBq!ia0y~yU`zmF4GuP-NLrS*FOXs^4sv&5Sa(k5B?AN3Tu&Fr zkcv5P?>J_KWJ)0>%;4|@Yj!@uiw7^cj5c*rJw6=|J(Vkp5eg%smu}&ykrhAgcp@D?60nV zzVpY=pym6|?cQE)r~ms;(Di?RU;a$LfB&|(^1s0NvcB(skN<5xfBvVp)cf+~$KQW@ z_Uz~T@4x%2&o4b6oX);M|9PByo#V~t9p9^erKV5!e*ZnEX~&nzHy)m_U$p7G;QM0_ zcV7;E|MVp9jM|t!AHBbZ(_dG=+N<#({K*QZq~*%@dYSHdGO}CP%+z==SEQhUcgI<_ zJ4+jwfoerQ_;FbrV7rsX{4VGKBcHz-SA{yOOagP>X2x>O2Mp7dg<1DZX5!nxxcz3s zZlKn~lRLp?-DtR-b08L|_2~&0#`jAam~#%~nmy2Cm3i~yn9aMxd(;`Dp)r~^hFVUUGi}=QdC%p=H$30>JW%?>clq!9b;dvTJpMdU zdc*T`&y%;u+tvQ~`e^&Pt2KZAeEn8#|L*U;ynFe#BN>@Llv^|~t~3%+*)7ilu{(27T(TGZmPT^+4>JUtPuczk#gt#~X#FCHt@6*NSKlgLrD8B!B1@Di)vv;%am#n$>@#hKN8^zB*Z@jHP z-|kP<$LQx-c6I-%e(#q5UKelve*4=s4U9jmLCwZT3~W0l)iYkdnYq2_ZQ~qJ!RhJh K=d#Wzp$Py7Q={qt diff --git a/assets/minesweeper/border.png b/assets/minesweeper/border.png deleted file mode 100644 index 1b43d53e3e5094b2f460d5ae95a2d246daa38ef1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1979 zcmeH|+f!3l6vhuljkP5>I$~P`OmznAR0AC}fq(%tir|f6TNOeCvD_0bAtp#jLY*3H zEwls3RWc)Eaf*=81X6Q@mKLfIQc8hH2#2a%qMU^E00+pe2mL2}a6f!|KkQj+?=|0V ztsAkYqdc~Jumu1BkLcr+H~?@?1oCyFhtY}K)XPgGe z*d9a8@a?nq?Nq8u)Hh9(*j$o(f@Wt@a)$qVu^(=Z?v7AYdeI_cB9%YvEj^lq-$VQ! zpWFGTV&&1zkZ?HMtf|mpE+;iDEX+P+YM4(N=pJY)ba8w@4bQ|~a*-xM(*V0hY=E~* zi?53>_p)uqtmU=8{=V;8fnHRb9ra`Ml;Q&~$_uCd%N)Pri8a`WVne^&H+6843~Q;h zQ-j zIMk*uL)eN7c?1Mtw01ny$`Vhu6(#QAfBtmj)5TGU3_IFIwK-W@E^3owrLk3(t zVdT!LgPb}TpJqMu<&oj?$Ji{UYILbKPh`lpiwhBfcei_P?7My0u0m6IaFd{9_m<#h zLCLl^`ubIXXt~p2*L!|6Tk_AS&1!S_eYQ~J{Ue+i zH!gdH=PV%DA9;17_Ew`25Jarf(-eooO^sJ2_HX=%tM})@WSqrP(BI|I6tM4cAcT~4 zi)oquWvEffKTbuR3HrkXJlyn{XIr~_0$<8y%lQ@Rex2!HI);Kb{+>FaJB!6gwZQ^W zdCV?>huw0?k~)9!6``oEbOj=agP}WPH(#C_Q4Y@`{#tn#`i;d6cxiE6)lS3E>|1!h zu@f}un2^~JvS5HK%;-G=ZAnr?_9G5ok;zAFTM6L6v(#~vuSua~HaqMTxXLISQ#7et zOU_Bp&m>OFkjwH_q|A!?3}p?~6XjA8Ld%LOO0aHM4#-7X>o_QlQFCp{f*t!C(G2M> z+R3)+vgJ+%`T+N~%)E(4k*si|eGV45NI333Yu*{2GE1Yj&qEvFVrm$O@r4LrAFEaC z;>cZljvYdLg(;mq&*RJAFZzPQn1qkxx_e&Xm+Zr+Jlh@d_Qr-c`g&HNo;?)r{MEB# zw64V%F@RjC$!W(3Z>%l{TJ9W#0gbAz6K%@g5Zyy@@2K^;F(Y)`ux_lE+;Lb379M#W z0UwYHigJn3YW zBejd(GWXrpj7vf0*^h+R9;f2Eb(FgvJ)4~Dc6QKm000CE!re$erp@INOV-CU5PkGC KrR{LiSN{X|jgOuH diff --git a/assets/minesweeper/cell.png b/assets/minesweeper/cell.png deleted file mode 100644 index c00c9b37abe2e82e78f99832b7e6bd7461cda9ca..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2257 zcmV;?2rl=DP)Px-i%CR5RCt{2TYqd@M;-rMa5uKm;0#S=5(q70RWwE%M4?WbG;v_VRkCitfVB<| zEQO&d4ltT*aY4z%k~BZM4ZE85!x_tnvr)ug#g#)V>aQyuzyl_^@=kNNQ zl0Wy!LrVVebi0xdfBlS-FOEE~Db1v@d2=!d4?u;ALvDEX)b+1;`3KUIsehsgQj&*wY7m#3Q8$HhZSAq-mejv8s~I$dZ)$wT&+ANp&9E7m53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4MPZFj(CaC~z#B)<3M22hG%K>=!uiV%aj28g~! z6nt=S5R_7BAm$1VucwT6+6Xh@#ZW~E!B)4MtA2~qiQ1x~j2TT%!dbNffL>q#NF>wn zlxhRx^Z5{sMtMKj^BXp7xXj|pa113zb)HwuiyC0%m~KxdanzvpN8N624l&cGGGKy> zZQB_R^Oy#(@W#pjB%3$u93cds85`rmvy@%W2A?nU|3a~DyCOjz6AsACID^p#7`K?c zo-(vJouHKJgzuQ1MvK#lqi*?Ipc$;z0k)Wcm7^0KBje2+r04@Wl1bE-mP$ULwfjY7 zCvv(DFsiw+aiaz>4Pn;@-Z;WTA$wK~jWK{bJ1el6CWP2B>mufSsJ)&tC@=sx4+QY9Rhhj4QD6X| zf4Cmx?#!-^C@=s#v-3v$pgQxlM-&(Uy3f6h<|UuvWl>-Ncyj6{{J8LMyetX~0DGsO zLPf!kcv%z}(2mMXY|Q*Qn+ePiec@U79(Zsu3M>vlt~-!xH~?U4`{QsbZqmN%U!R4) zF$dH&EHUy=9~NB+q31+G6!{Pg%2cz)eGuS@)nn?KL<7pC8q z_`Cuw1oL%(C@`R%AFTH8;$=}_Ks!1oo*okg2DGDd@t@qn%c8)5c6LxaL?sFgXeYyt9~jv00000NkvXXu0mjfZmUV; diff --git a/assets/minesweeper/grid.png b/assets/minesweeper/grid.png deleted file mode 100644 index 9db590173b9b8c0d3ccbbfaab256821971629563..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1783 zcmeAS@N?(olHy`uVBq!ia0vp^D;O9UJvi8atRod$n}8H!age(c!@6@aFBurvHhQ`^ zhE&XXd)shTYNllC!>}`R8V(EaxCCr8W^GT*(6eAz_?b`E&AB{m5$`3(=EDU{X-#fZ zL+8d`*&Y7A_Lq(SC)U+vg_d`A|M>Z>-tH$0(0qmmzu&UE|9`Om|IhFL_jSuZiTwNG zxP9dhNx9m(`~UuSxBvftzV7eu_Me;W>%aW``{Chb_P)9u;pbnPWGrzseR26&iImBu z1yWx!i>-L2GA~G*ytplYsOEc$d$XH6?}xL~>uZ1fyu0_|we$b~l-C!q?bTZDy?=pw zz3uvWmoqOU`Ym^Cx17r+3pAx<#^syM^9*ioWbfVMx$EHUCEs`c>M8#|$FJE`Fy@;<1&tX*gK_^vJ3SyvbM&j$L-qd5zt85BhM7Z!xS zmwaz`^WuVuzZbj%dE|NQABfvf9J`s_HgQujzf|Sql4f(y_r+f&-@gMpYXw{FE!0q` zYG&J8b-v;|Cn)|H#*WuK2q^qTg=+{=bjo`TzgF|L4_m{?F<4b-(uhSSz~`=Olp<2{RZYX78})p5M)1mFV}J2Pux=Ccbg>pYi4f zC`PwEzstVYV0ketX`q-03;yqpw?DsYj+=4W5b{W<8YAUZSi8;d-?W%pB_H{{$2H{ub<=h{=6mkWz}eCR~PJ^WQ)_Pz@*|FSo4)|XYESDVM5o_PsapxnI#j&(Pw5^r!~0+wZK`Lix; z_f6bay=gJ9=-KrYoMeGndOIXdAnQ2|E@ePv$TUbcL6(FYs0&V!pz<;rlE#p2(*>7W zAmhQgAOl#4xZRsT<;7ri7&Nqh*{^WfCKIpTF98aDPgg&ebxsLQ0Nvwy ATmS$7 diff --git a/assets/minesweeper/grid_bg.png b/assets/minesweeper/grid_bg.png deleted file mode 100644 index 031a226e36ab188ae382175963600f2b25c29e37..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 123 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`PM$7~Ar*7pUR=n_puppDQCOCv zJ4IeCfq9uz(oGICizA^SUv8`E`<{FDLVU?qe(S>u(;PS+Y%gBj${b+d5W&QEfO%3b V2kWIo?IxgU44$rjF6*2UngHfQB~<_b diff --git a/assets/minesweeper/ui.png b/assets/minesweeper/ui.png deleted file mode 100644 index ba99805d1676b3b467e866a296e4850ca1c4e726..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1981 zcmaKtc{J4PAIHBVWwKWf}=tZnlhJh#6a$XlPm_yX;*e z+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OtiJSKuuOs5RpO$0~@T6J_5czIpot8-53e9D`6Yj%}T3;?u z{S>=d@uB^t4Dy!dtgBOgF(qC3|A*MIw&lkeC)wDcpspg??HO>moL`zjw20 xU9u#6(Lugj_YLpjFZDkp%hLWgFU<6YJa98J;O&hhJMcdS?5rKpb*S@6e*+UeyDR_z diff --git a/assets/scene/minesweeper.lua b/assets/scene/minesweeper.lua index c4d290e..beeb93f 100644 --- a/assets/scene/minesweeper.lua +++ b/assets/scene/minesweeper.lua @@ -18,39 +18,39 @@ CELL_STATE_DISABLED = 3 screenSetBackground(colorBlack()) camera = cameraCreate(CAMERA_PROJECTION_TYPE_ORTHOGRAPHIC) -tilesetUi = tilesetGetByName("ui") -textureUi = textureLoad(tilesetUi.texture) +-- tilesetUi = tilesetGetByName("ui") +-- textureUi = textureLoad(tilesetUi.texture) -tilesetBorder = tilesetGetByName("border") -textureBorder = textureLoad(tilesetBorder.texture) +-- tilesetBorder = tilesetGetByName("border") +-- textureBorder = textureLoad(tilesetBorder.texture) -textureGrid = textureLoad("minesweeper/grid_bg.dpi") +-- textureGrid = textureLoad("minesweeper/grid_bg.dpi") -tilesetCell = tilesetGetByName("cell") -textureCell = textureLoad(tilesetCell.texture) -cellSliceDefault = tilesetPositionGetUV(tilesetCell, 3, 5) -cellSliceHover = tilesetPositionGetUV(tilesetCell, 3, 4) -cellSliceDown = tilesetPositionGetUV(tilesetCell, 3, 6) -cellSliceDisabled = tilesetPositionGetUV(tilesetCell, 3, 7) +-- tilesetCell = tilesetGetByName("cell") +-- textureCell = textureLoad(tilesetCell.texture) +-- cellSliceDefault = tilesetPositionGetUV(tilesetCell, 3, 5) +-- cellSliceHover = tilesetPositionGetUV(tilesetCell, 3, 4) +-- cellSliceDown = tilesetPositionGetUV(tilesetCell, 3, 6) +-- cellSliceDisabled = tilesetPositionGetUV(tilesetCell, 3, 7) -sweepwerCols = 10 -sweeperRows = 14 +-- sweepwerCols = 10 +-- sweeperRows = 14 -mouseX = -1 -mouseY = -1 -centerX = 0 -centerY = 0 -boardWidth = sweepwerCols * tilesetCell.tileWidth -boardHeight = sweeperRows * tilesetCell.tileHeight +-- mouseX = -1 +-- mouseY = -1 +-- centerX = 0 +-- centerY = 0 +-- boardWidth = sweepwerCols * tilesetCell.tileWidth +-- boardHeight = sweeperRows * tilesetCell.tileHeight -i = 0 -cells = {} -for y = 1, sweeperRows do - for x = 1, sweepwerCols do - cells[i] = CELL_STATE_DEFAULT - i = i + 1 - end -end +-- i = 0 +-- cells = {} +-- for y = 1, sweeperRows do +-- for x = 1, sweepwerCols do +-- cells[i] = CELL_STATE_DEFAULT +-- i = i + 1 +-- end +-- end function cellDraw(x, y, type) local slice = cellSliceDefault @@ -189,42 +189,53 @@ function sceneRender() mouseY = inputGetValue(INPUT_ACTION_POINTERY) * screenGetHeight() end - centerX = math.floor(screenGetWidth() / 2) - centerY = math.floor(screenGetHeight() / 2) - - -- Draw elements - backgroundDraw() - borderDraw( - centerX - (boardWidth / 2), centerY - (boardHeight / 2), - boardWidth, boardHeight + -- Draw cursor + spriteBatchPush( + nil, + mouseX - 2, mouseY - 2, + mouseX + 2, mouseY + 2, + colorRed(), + 0, 0, + 1, 1 ) - i = 0 - -- Foreach cell - local offX = centerX - (boardWidth / 2) - local offY = centerY - (boardHeight / 2) - for y = 0, sweeperRows - 1 do - for x = 0, sweepwerCols - 1 do - i = y * sweepwerCols + x + + -- centerX = math.floor(screenGetWidth() / 2) + -- centerY = math.floor(screenGetHeight() / 2) + + -- Draw elements + -- backgroundDraw() + -- borderDraw( + -- centerX - (boardWidth / 2), centerY - (boardHeight / 2), + -- boardWidth, boardHeight + -- ) + + -- i = 0 + -- -- Foreach cell + -- local offX = centerX - (boardWidth / 2) + -- local offY = centerY - (boardHeight / 2) + -- for y = 0, sweeperRows - 1 do + -- for x = 0, sweepwerCols - 1 do + -- i = y * sweepwerCols + x - -- Hovered - if - cells[i] == CELL_STATE_DEFAULT and - mouseX >= x * tilesetCell.tileWidth + offX and mouseX < (x + 1) * tilesetCell.tileWidth + offX and - mouseY >= y * tilesetCell.tileHeight + offY and mouseY < (y + 1) * tilesetCell.tileHeight + offY - then - cells[i] = CELL_STATE_HOVER - else - cells[i] = CELL_STATE_DEFAULT - end + -- -- Hovered + -- if + -- cells[i] == CELL_STATE_DEFAULT and + -- mouseX >= x * tilesetCell.tileWidth + offX and mouseX < (x + 1) * tilesetCell.tileWidth + offX and + -- mouseY >= y * tilesetCell.tileHeight + offY and mouseY < (y + 1) * tilesetCell.tileHeight + offY + -- then + -- cells[i] = CELL_STATE_HOVER + -- else + -- cells[i] = CELL_STATE_DEFAULT + -- end - cellDraw( - x * tilesetCell.tileWidth + offX, - y * tilesetCell.tileHeight + offY, - cells[i] - ) - end - end + -- cellDraw( + -- x * tilesetCell.tileWidth + offX, + -- y * tilesetCell.tileHeight + offY, + -- cells[i] + -- ) + -- end + -- end spriteBatchFlush() cameraPopMatrix() diff --git a/assets/ui/CMakeLists.txt b/assets/ui/CMakeLists.txt deleted file mode 100644 index ffe622f..0000000 --- a/assets/ui/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright (c) 2025 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -add_asset(TILESET minogram.png type=ALPHA tileWidth=6 tileHeight=10 columns=16 rows=6) \ No newline at end of file diff --git a/assets/ui/minogram.png b/assets/ui/minogram.png deleted file mode 100644 index c41f917ac2882308e41c4beb580f5753860562e8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1260 zcmV z?Q*Oj42Gf8`@dz+pVG-m-+Vz3ba`fW++swO5Xp->t=Dyx!#ZlMOV9uHvz5Hy681~w zT3x@ei_^{FHh?dWywYz<`aDpBO;2lf1 ztz&BW+ezGJHmjqAcCA}4A%+O!4D0V0i(A^;y**2td?nkQI9N4GY=K*^M zY|-%z?;JpTJV+r9*=qJyl#p(;mO@5u^hoY5iCJ59Hp1fo){UWx9zU)K_cMr7X>olZGQUZduIRi`)Y zT|&kjVD?4Ks(+S7@F+YwKx3pMdXzx#LQ!vfqSvE|I^MdrOan{tNvR_tYa|WyI1fT= zZ?xkyBFf$tolc>PK}gQ^@YFDvDamfvv0i!}0h*%a9j(^LkFKuq?_R}{M}mx*`j(2H zL_K-&T6Xzu;Ne60I3-Xb`mW&Wk(&kmT>yXEMSBazV~FR^rw34?kq5fwPeWoXBF%f#CUhxRg_)@(9+*MfFA&Wu$r! zgpr?z&jfX}6!xt;4hrp+ut-SHwAVs9IyQ=>>_wJ?UkO(Nsg(Lre5ww>CxP#{s)L)e z7O;?DdnThJ`(KIlMo{E!9M4-io~*(1 z{(yB}scvn*l?iy-BDKeBzYJ+Dpb=RMkm}LwshzZzV6~@}YY{}+?@a^g_4TfmNcKy~ zSPt&Zqch*ji}JDQE+@kQJe|1PjoxkLav4Yoq(l~jqqWK<_Bkp2aJG=U=S@?D|Sr#zYc1euYX`IbVZ>92sFkl|wGz0J z$eiHy?*v}#Q`nYYe8e6ddsjJX=Ye1;fpnjwbTwuRJCYiw**7vWf|bJ6G`#;ZhJJ51 zV)m%YQV)@RPe^}V=ajZo~z$+<7&iTqt%fwOw5!$L2%DuJv(TJ8pJyPtn z`q3OgI*-L`9SQx%5KB(&(fze!G<)<2LVriv?`>C)-Q(C*35;?Szr*2hI2;a#0RI5C W$o0rJ!cj&50000extension, "Asset type definition has NULL extension."); + if(cmp->extension == NULL) continue; if(!stringEndsWithCaseInsensitive(filename, cmp->extension)) continue; def = cmp; break; diff --git a/src/asset/type/assetlanguage.c b/src/asset/type/assetlanguage.c index d2b4782..b895a00 100644 --- a/src/asset/type/assetlanguage.c +++ b/src/asset/type/assetlanguage.c @@ -23,40 +23,7 @@ errorret_t assetLanguageInit( assetlanguage_t *lang, zip_file_t *zipFile ) { - assertNotNull(lang, "Language asset cannot be NULL"); - assertNotNull(zipFile, "Zip file cannot be NULL"); - assertNull(lang->zip, "Language asset zip file must be NULL."); - // I want this but ubuntu isn't compiling with it right now. - // assertTrue(zip_file_is_seekable(zipFile), "Language file must be seekable."); - - // We now own the zip file handle. - lang->zip = zipFile; - - // Read in the header. - zip_int64_t bytesRead = zip_fread( - lang->zip, - &lang->header, - sizeof(assetlanguageheader_t) - ); - if(bytesRead != sizeof(assetlanguageheader_t)) { - zip_fclose(lang->zip); - errorThrow("Failed to read language asset header."); - } - - // Fix the endianness of the header data. - for(uint32_t i = 0; i < LANG_KEY_COUNT; i++) { - lang->header.strings[i].chunk = le32toh(lang->header.strings[i].chunk); - lang->header.strings[i].offset = le32toh(lang->header.strings[i].offset); - lang->header.strings[i].length = le32toh(lang->header.strings[i].length); - } - - lang->chunksOffset = zip_ftell(lang->zip); - if(lang->chunksOffset <= 0) { - zip_fclose(lang->zip); - errorThrow("Failed to get language asset chunks offset."); - } - - errorOk(); + errorThrow("Language asset initialization is not yet implemented."); } errorret_t assetLanguageRead( @@ -66,47 +33,7 @@ errorret_t assetLanguageRead( const uint32_t bufferSize, uint32_t *outLength ) { - assertNotNull(lang, "Language asset cannot be NULL"); - assertNotNull(lang->zip, "Language asset zip file cannot be NULL"); - assertTrue(key < LANG_KEY_COUNT, "Language key out of bounds."); - - // Find the string entry - assetlanguagestring_t *str = &lang->header.strings[LANG_MAP_TEST]; - - // If buffer is NULL, return the string length - if(buffer == NULL) { - assertNotNull(outLength, "Output length pointer cannot be NULL."); - *outLength = str->length; - errorOk(); - } - - // Ensure buffer is large enough - assertTrue( - bufferSize >= str->length + 1, - "Provided buffer is too small for language string." - ); - - // Determine the file position - zip_int64_t seekTo = lang->chunksOffset + ( - (str->chunk * ASSET_LANG_CHUNK_CHAR_COUNT) + str->offset - ); - - // Seek - zip_int64_t result = zip_fseek(lang->zip, seekTo, SEEK_SET); - if(result != 0) { - errorThrow("Failed to seek to language string in asset."); - } - - // Read - zip_int64_t readTest = zip_fread(lang->zip, buffer, str->length); - if(readTest != str->length) { - errorThrow("Failed to read test string from language asset."); - } - buffer[str->length] = '\0'; - - // Set str length if requested - if(outLength != NULL) *outLength = str->length; - errorOk(); + errorThrow("Language string reading is not yet implemented."); } void assetLanguageDispose(assetlanguage_t *lang) { diff --git a/src/asset/type/assetlanguage.h b/src/asset/type/assetlanguage.h index 5ece212..b6a099e 100644 --- a/src/asset/type/assetlanguage.h +++ b/src/asset/type/assetlanguage.h @@ -10,34 +10,9 @@ #include "duskdefs.h" #include -#define ASSET_LANG_CHUNK_CACHE 4 // Number of chunks to cache in memory - -#pragma pack(push, 1) -typedef char assetlanguagechunk_t[ASSET_LANG_CHUNK_CHAR_COUNT]; -#pragma pack(pop) - -#pragma pack(push, 1) -typedef struct { - uint32_t chunk; - uint32_t offset; - uint32_t length; -} assetlanguagestring_t; -#pragma pack(pop) - -#pragma pack(push, 1) -typedef struct { - assetlanguagestring_t strings[LANG_KEY_COUNT]; -} assetlanguageheader_t; -#pragma pack(pop) - typedef struct { zip_file_t *zip; - assetlanguageheader_t header; zip_int64_t chunksOffset; - - // Chunk cache - assetlanguagechunk_t chunks[ASSET_LANG_CHUNK_CACHE]; - uint32_t chunkIndices[ASSET_LANG_CHUNK_CACHE]; } assetlanguage_t; typedef struct assetcustom_s assetcustom_t; diff --git a/src/asset/type/assettexture.c b/src/asset/type/assettexture.c index 4d8a8c5..c371774 100644 --- a/src/asset/type/assettexture.c +++ b/src/asset/type/assettexture.c @@ -9,7 +9,7 @@ #include "assert/assert.h" #include "display/texture.h" -errorret_t assetPaletteImageLoad(void *data, void *output) { +errorret_t assetTextureLoad(void *data, void *output) { assertNotNull(data, "Data pointer cannot be NULL."); assertNotNull(output, "Output pointer cannot be NULL."); diff --git a/src/display/text.h b/src/display/text.h index 4f622ed..963dfb1 100644 --- a/src/display/text.h +++ b/src/display/text.h @@ -12,8 +12,8 @@ #define TEXT_CHAR_START '!' -// extern texture_t DEFAULT_FONT_TEXTURE; -// #define DEFAULT_FONT_TILESET TILESET_MINOGRAM +extern texture_t DEFAULT_FONT_TEXTURE; +extern tileset_t DEFAULT_FONT_TILESET; /** * Initializes the text system. diff --git a/src/engine/engine.c b/src/engine/engine.c index 670fe3b..9dc2cd3 100644 --- a/src/engine/engine.c +++ b/src/engine/engine.c @@ -43,7 +43,7 @@ errorret_t engineInit(const int32_t argc, const char_t **argv) { // Run the initial script. scriptcontext_t ctx; errorChain(scriptContextInit(&ctx)); - errorChain(scriptContextExecFile(&ctx, "init.dsf")); + errorChain(scriptContextExecFile(&ctx, "init.lua")); scriptContextDispose(&ctx); errorOk(); diff --git a/src/locale/localemanager.c b/src/locale/localemanager.c index e92849e..82ae301 100644 --- a/src/locale/localemanager.c +++ b/src/locale/localemanager.c @@ -18,18 +18,19 @@ errorret_t localeManagerInit() { } errorret_t localeManagerSetLocale(const dusklocale_t locale) { - assertTrue(locale < DUSK_LOCALE_COUNT, "Invalid locale."); - assertTrue(locale != DUSK_LOCALE_NULL, "Cannot set locale to NULL."); + errorThrow("Locale setting is not yet implemented."); + // assertTrue(locale < DUSK_LOCALE_COUNT, "Invalid locale."); + // assertTrue(locale != DUSK_LOCALE_NULL, "Cannot set locale to NULL."); - LOCALE.locale = locale; - char_t languageFile[FILENAME_MAX]; - snprintf( - languageFile, FILENAME_MAX, "language/%s.dlf", LOCALE_INFOS[locale].file - ); - assetLanguageDispose(&LOCALE.language); - memoryZero(&LOCALE.language, sizeof(assetlanguage_t)); - errorChain(assetLoad(languageFile, &LOCALE.language)); - errorOk(); + // LOCALE.locale = locale; + // char_t languageFile[FILENAME_MAX]; + // snprintf( + // languageFile, FILENAME_MAX, "language/%s.dlf", LOCALE_INFOS[locale].file + // ); + // assetLanguageDispose(&LOCALE.language); + // memoryZero(&LOCALE.language, sizeof(assetlanguage_t)); + // errorChain(assetLoad(languageFile, &LOCALE.language)); + // errorOk(); } void localeManagerDispose() { diff --git a/src/script/module/display/moduletileset.c b/src/script/module/display/moduletileset.c index 1608152..55f8c60 100644 --- a/src/script/module/display/moduletileset.c +++ b/src/script/module/display/moduletileset.c @@ -25,7 +25,7 @@ void moduleTileset(scriptcontext_t *ctx) { } lua_pop(ctx->luaState, 1); // Pop the metatable - lua_register(ctx->luaState, "tilesetGetByName", moduleTilesetGetByName); + // lua_register(ctx->luaState, "tilesetGetByName", moduleTilesetGetByName); lua_register(ctx->luaState, "tilesetTileGetUV", moduleTilesetTileGetUV); lua_register( ctx->luaState, "tilesetPositionGetUV", moduleTilesetPositionGetUV @@ -76,33 +76,33 @@ int moduleTilesetToString(lua_State *l) { return 1; } -int moduleTilesetGetByName(lua_State *l) { - assertNotNull(l, "Lua state cannot be NULL."); +// int moduleTilesetGetByName(lua_State *l) { +// assertNotNull(l, "Lua state cannot be NULL."); - if(!lua_isstring(l, 1)) { - lua_pushnil(l); - return 1; - } +// if(!lua_isstring(l, 1)) { +// lua_pushnil(l); +// return 1; +// } - const char_t *name = lua_tostring(l, 1); - if(name == NULL || name[0] == '\0') { - luaL_error(l, "Invalid tileset name."); - return 1; - } +// const char_t *name = lua_tostring(l, 1); +// if(name == NULL || name[0] == '\0') { +// luaL_error(l, "Invalid tileset name."); +// return 1; +// } - const tileset_t *ts = tilesetGetByName(name); - if(ts == NULL) { - lua_pushnil(l); - return 1; - } +// const tileset_t *ts = tilesetGetByName(name); +// if(ts == NULL) { +// lua_pushnil(l); +// return 1; +// } - // Lua does not own this reference - lua_pushlightuserdata(l, (void *)ts); - luaL_getmetatable(l, "tileset_mt"); - lua_setmetatable(l, -2); +// // Lua does not own this reference +// lua_pushlightuserdata(l, (void *)ts); +// luaL_getmetatable(l, "tileset_mt"); +// lua_setmetatable(l, -2); - return 1; -} +// return 1; +// } int moduleTilesetTileGetUV(lua_State *l) { assertNotNull(l, "Lua state cannot be NULL."); diff --git a/src/script/module/locale/modulelocale.c b/src/script/module/locale/modulelocale.c index 51b327b..b5f4956 100644 --- a/src/script/module/locale/modulelocale.c +++ b/src/script/module/locale/modulelocale.c @@ -13,66 +13,66 @@ void moduleLocale(scriptcontext_t *context) { assertNotNull(context, "Script context cannot be NULL"); // Execute the locale script definitions. - scriptContextExec(context, LOCALE_SCRIPT); + // scriptContextExec(context, LOCALE_SCRIPT); - lua_register(context->luaState, "localeGet", moduleLocaleGet); - lua_register(context->luaState, "localeSet", moduleLocaleSet); - lua_register(context->luaState, "localeGetName", moduleLocaleGetName); + // lua_register(context->luaState, "localeGet", moduleLocaleGet); + // lua_register(context->luaState, "localeSet", moduleLocaleSet); + // lua_register(context->luaState, "localeGetName", moduleLocaleGetName); } -int moduleLocaleGet(lua_State *L) { - assertNotNull(L, "Lua state cannot be NULL"); +// int moduleLocaleGet(lua_State *L) { +// assertNotNull(L, "Lua state cannot be NULL"); - // No arguments expected - dusklocale_t locale = LOCALE.locale; - lua_pushnumber(L, (lua_Number)locale); - return 1; -} +// // No arguments expected +// dusklocale_t locale = LOCALE.locale; +// lua_pushnumber(L, (lua_Number)locale); +// return 1; +// } -int moduleLocaleSet(lua_State *L) { - assertNotNull(L, "Lua state cannot be NULL"); +// int moduleLocaleSet(lua_State *L) { +// assertNotNull(L, "Lua state cannot be NULL"); - // Requires locale ID - if(!lua_isnumber(L, 1)) { - luaL_error(L, "localeSet: Expected locale ID as first argument"); - return 0; - } +// // Requires locale ID +// if(!lua_isnumber(L, 1)) { +// luaL_error(L, "localeSet: Expected locale ID as first argument"); +// return 0; +// } - errorret_t err; - dusklocale_t locale = (dusklocale_t)lua_tonumber(L, 1); - if(locale >= DUSK_LOCALE_COUNT || locale == DUSK_LOCALE_NULL) { - luaL_error(L, "localeSet: Invalid locale ID"); - return 0; - } +// errorret_t err; +// dusklocale_t locale = (dusklocale_t)lua_tonumber(L, 1); +// if(locale >= DUSK_LOCALE_COUNT || locale == DUSK_LOCALE_NULL) { +// luaL_error(L, "localeSet: Invalid locale ID"); +// return 0; +// } - err = localeManagerSetLocale(locale); - if(err.code != ERROR_OK) { - luaL_error(L, "localeSet: Failed to set locale"); - errorCatch(errorPrint(err)); - return 0; - } +// err = localeManagerSetLocale(locale); +// if(err.code != ERROR_OK) { +// luaL_error(L, "localeSet: Failed to set locale"); +// errorCatch(errorPrint(err)); +// return 0; +// } - return 0; -} +// return 0; +// } -int moduleLocaleGetName(lua_State *L) { - assertNotNull(L, "Lua state cannot be NULL"); +// int moduleLocaleGetName(lua_State *L) { +// assertNotNull(L, "Lua state cannot be NULL"); - // Optional ID, otherwise return current locale name - dusklocale_t locale = LOCALE.locale; - if(lua_gettop(L) >= 1) { - if(!lua_isnumber(L, 1)) { - luaL_error(L, "localeGetName: Expected locale ID as first argument"); - return 0; - } - locale = (dusklocale_t)lua_tonumber(L, 1); - if(locale >= DUSK_LOCALE_COUNT || locale == DUSK_LOCALE_NULL) { - luaL_error(L, "localeGetName: Invalid locale ID"); - return 0; - } - } +// // Optional ID, otherwise return current locale name +// dusklocale_t locale = LOCALE.locale; +// if(lua_gettop(L) >= 1) { +// if(!lua_isnumber(L, 1)) { +// luaL_error(L, "localeGetName: Expected locale ID as first argument"); +// return 0; +// } +// locale = (dusklocale_t)lua_tonumber(L, 1); +// if(locale >= DUSK_LOCALE_COUNT || locale == DUSK_LOCALE_NULL) { +// luaL_error(L, "localeGetName: Invalid locale ID"); +// return 0; +// } +// } - const char_t *localeName = LOCALE_INFOS[locale].file; - lua_pushstring(L, localeName); - return 1; -} \ No newline at end of file +// const char_t *localeName = LOCALE_INFOS[locale].file; +// lua_pushstring(L, localeName); +// return 1; +// } \ No newline at end of file diff --git a/src/script/module/system/modulesystem.c b/src/script/module/system/modulesystem.c index 8261f5a..0206af8 100644 --- a/src/script/module/system/modulesystem.c +++ b/src/script/module/system/modulesystem.c @@ -65,15 +65,15 @@ int moduleSysInclude(lua_State *L) { char_t buffer[1024]; stringCopy(buffer, filename, 1024); - // Ensure it has .dsf extension + // Ensure it has .lua extension size_t len = strlen(buffer); - if(len < 4 || strcmp(&buffer[len - 4], ".dsf") != 0) { - // Append .dsf + if(len < 4 || strcmp(&buffer[len - 4], ".lua") != 0) { + // Append .lua if(len + 4 >= 1024) { - luaL_error(L, "Filename too long to append .dsf"); + luaL_error(L, "Filename too long to append .lua"); return 0; } - stringCopy(&buffer[len], ".dsf", 5); + stringCopy(&buffer[len], ".lua", 5); } // Execute the script file