~starkingdoms/starkingdoms

a47fd130323b4749087e63c9b591f391dadf0f05 — core 2 years ago 71ce7ed
texture loading
96 files changed, 199 insertions(+), 637 deletions(-)

M .gitignore
A assets/dist/spritesheet-125.png
A assets/dist/spritesheet-125.ron
A assets/dist/spritesheet-375.png
A assets/dist/spritesheet-375.ron
A assets/dist/spritesheet-full.png
R assets/dist/{spritesheet => spritesheet-full}.ron
D assets/dist/spritesheet.png
A assets/final/125/autoplr_cfg.png
A assets/final/125/autoplr_error.png
A assets/final/125/autoplr_on.png
A assets/final/125/cargo_off.png
A assets/final/125/cargo_on.png
A assets/final/125/earth.png
A assets/final/125/ecothruster_on.png
A assets/final/125/hearty.png
A assets/final/125/hub_off.png
A assets/final/125/hub_on.png
A assets/final/125/landingleg.png
A assets/final/125/landingthruster_off.png
A assets/final/125/landingthruster_on.png
A assets/final/125/powerhub_off.png
A assets/final/125/powerhub_on.png
A assets/final/125/superthruster_off.png
A assets/final/125/superthruster_on.png
A assets/final/125/thruster_off.png
A assets/final/125/thruster_on.png
A assets/final/375/autoplr_cfg.png
A assets/final/375/autoplr_error.png
A assets/final/375/autoplr_on.png
A assets/final/375/cargo_off.png
A assets/final/375/cargo_on.png
A assets/final/375/earth.png
A assets/final/375/ecothruster_on.png
A assets/final/375/hearty.png
A assets/final/375/hub_off.png
A assets/final/375/hub_on.png
A assets/final/375/landingleg.png
A assets/final/375/landingthruster_off.png
A assets/final/375/landingthruster_on.png
A assets/final/375/powerhub_off.png
A assets/final/375/powerhub_on.png
A assets/final/375/superthruster_off.png
A assets/final/375/superthruster_on.png
A assets/final/375/thruster_off.png
A assets/final/375/thruster_on.png
D assets/final/autoplr_cfg.png
D assets/final/autoplr_error.png
D assets/final/autoplr_on.png
D assets/final/cargo_off.png
D assets/final/cargo_on.png
D assets/final/earth.png
D assets/final/ecothruster_on.png
A assets/final/full/autoplr_cfg.png
A assets/final/full/autoplr_error.png
A assets/final/full/autoplr_on.png
A assets/final/full/cargo_off.png
A assets/final/full/cargo_on.png
A assets/final/full/earth.png
A assets/final/full/ecothruster_on.png
A assets/final/full/hearty.png
A assets/final/full/hub_off.png
A assets/final/full/hub_on.png
R assets/final/{ => full}/icon_landingthruster.png
R assets/final/{ => full}/landingleg.png
A assets/final/full/landingthruster_off.png
A assets/final/full/landingthruster_on.png
A assets/final/full/powerhub_off.png
A assets/final/full/powerhub_on.png
A assets/final/full/superthruster_off.png
A assets/final/full/superthruster_on.png
A assets/final/full/thruster_off.png
A assets/final/full/thruster_on.png
D assets/final/hearty.png
D assets/final/hub_off.png
D assets/final/hub_on.png
D assets/final/landingthruster_off.png
D assets/final/landingthruster_on.png
D assets/final/powerhub_off.png
D assets/final/powerhub_on.png
D assets/final/superthruster_off.png
D assets/final/superthruster_on.png
D assets/final/thruster_off.png
D assets/final/thruster_on.png
D assets/svg/_shapessvg.svg
D assets/svg/autoplr_on.ink.svg.2023_04_10_16_49_32.0.svg
D assets/svg/hearty.ink.svg.2023_04_10_17_23_18.0.svg
M client/Cargo.toml
M client/src/lib.rs
R client/src/textures/{loader => loader_fast}.rs
A client/src/textures/loader_slow.rs
M client/src/textures/mod.rs
M justfile
A web/assets
M web/index.html
M web/play.html
M .gitignore => .gitignore +2 -1
@@ 1,4 1,5 @@
target
client/pkg
web/dist
.idea
\ No newline at end of file
.idea
assets/svg/*.png
\ No newline at end of file

A assets/dist/spritesheet-125.png => assets/dist/spritesheet-125.png +0 -0
A assets/dist/spritesheet-125.ron => assets/dist/spritesheet-125.ron +1 -0
@@ 0,0 1,1 @@
(texture_width:256,texture_height:1408,sprites:[(name:"earth",x:0,y:0,width:256,height:256,offsets:None,),(name:"autoplr_cfg",x:0,y:256,width:64,height:64,offsets:None,),(name:"autoplr_error",x:0,y:320,width:64,height:64,offsets:None,),(name:"autoplr_on",x:0,y:384,width:64,height:64,offsets:None,),(name:"cargo_off",x:0,y:448,width:64,height:64,offsets:None,),(name:"cargo_on",x:0,y:512,width:64,height:64,offsets:None,),(name:"ecothruster_on",x:0,y:576,width:64,height:64,offsets:None,),(name:"hearty",x:0,y:640,width:64,height:64,offsets:None,),(name:"hub_off",x:0,y:704,width:64,height:64,offsets:None,),(name:"hub_on",x:0,y:768,width:64,height:64,offsets:None,),(name:"landingleg",x:0,y:832,width:64,height:64,offsets:None,),(name:"landingthruster_off",x:0,y:896,width:64,height:64,offsets:None,),(name:"landingthruster_on",x:0,y:960,width:64,height:64,offsets:None,),(name:"powerhub_off",x:0,y:1024,width:64,height:64,offsets:None,),(name:"powerhub_on",x:0,y:1088,width:64,height:64,offsets:None,),(name:"superthruster_off",x:0,y:1152,width:64,height:64,offsets:None,),(name:"superthruster_on",x:0,y:1216,width:64,height:64,offsets:None,),(name:"thruster_off",x:0,y:1280,width:64,height:64,offsets:None,),(name:"thruster_on",x:0,y:1344,width:64,height:64,offsets:None,),],)
\ No newline at end of file

A assets/dist/spritesheet-375.png => assets/dist/spritesheet-375.png +0 -0
A assets/dist/spritesheet-375.ron => assets/dist/spritesheet-375.ron +1 -0
@@ 0,0 1,1 @@
(texture_width:768,texture_height:4224,sprites:[(name:"earth",x:0,y:0,width:768,height:768,offsets:None,),(name:"autoplr_cfg",x:0,y:768,width:192,height:192,offsets:None,),(name:"autoplr_error",x:0,y:960,width:192,height:192,offsets:None,),(name:"autoplr_on",x:0,y:1152,width:192,height:192,offsets:None,),(name:"cargo_off",x:0,y:1344,width:192,height:192,offsets:None,),(name:"cargo_on",x:0,y:1536,width:192,height:192,offsets:None,),(name:"ecothruster_on",x:0,y:1728,width:192,height:192,offsets:None,),(name:"hearty",x:0,y:1920,width:192,height:192,offsets:None,),(name:"hub_off",x:0,y:2112,width:192,height:192,offsets:None,),(name:"hub_on",x:0,y:2304,width:192,height:192,offsets:None,),(name:"landingleg",x:0,y:2496,width:192,height:192,offsets:None,),(name:"landingthruster_off",x:0,y:2688,width:192,height:192,offsets:None,),(name:"landingthruster_on",x:0,y:2880,width:192,height:192,offsets:None,),(name:"powerhub_off",x:0,y:3072,width:192,height:192,offsets:None,),(name:"powerhub_on",x:0,y:3264,width:192,height:192,offsets:None,),(name:"superthruster_off",x:0,y:3456,width:192,height:192,offsets:None,),(name:"superthruster_on",x:0,y:3648,width:192,height:192,offsets:None,),(name:"thruster_off",x:0,y:3840,width:192,height:192,offsets:None,),(name:"thruster_on",x:0,y:4032,width:192,height:192,offsets:None,),],)
\ No newline at end of file

A assets/dist/spritesheet-full.png => assets/dist/spritesheet-full.png +0 -0
R assets/dist/spritesheet.ron => assets/dist/spritesheet-full.ron +0 -0
D assets/dist/spritesheet.png => assets/dist/spritesheet.png +0 -0
A assets/final/125/autoplr_cfg.png => assets/final/125/autoplr_cfg.png +0 -0
A assets/final/125/autoplr_error.png => assets/final/125/autoplr_error.png +0 -0
A assets/final/125/autoplr_on.png => assets/final/125/autoplr_on.png +0 -0
A assets/final/125/cargo_off.png => assets/final/125/cargo_off.png +0 -0
A assets/final/125/cargo_on.png => assets/final/125/cargo_on.png +0 -0
A assets/final/125/earth.png => assets/final/125/earth.png +0 -0
A assets/final/125/ecothruster_on.png => assets/final/125/ecothruster_on.png +0 -0
A assets/final/125/hearty.png => assets/final/125/hearty.png +0 -0
A assets/final/125/hub_off.png => assets/final/125/hub_off.png +0 -0
A assets/final/125/hub_on.png => assets/final/125/hub_on.png +0 -0
A assets/final/125/landingleg.png => assets/final/125/landingleg.png +0 -0
A assets/final/125/landingthruster_off.png => assets/final/125/landingthruster_off.png +0 -0
A assets/final/125/landingthruster_on.png => assets/final/125/landingthruster_on.png +0 -0
A assets/final/125/powerhub_off.png => assets/final/125/powerhub_off.png +0 -0
A assets/final/125/powerhub_on.png => assets/final/125/powerhub_on.png +0 -0
A assets/final/125/superthruster_off.png => assets/final/125/superthruster_off.png +0 -0
A assets/final/125/superthruster_on.png => assets/final/125/superthruster_on.png +0 -0
A assets/final/125/thruster_off.png => assets/final/125/thruster_off.png +0 -0
A assets/final/125/thruster_on.png => assets/final/125/thruster_on.png +0 -0
A assets/final/375/autoplr_cfg.png => assets/final/375/autoplr_cfg.png +0 -0
A assets/final/375/autoplr_error.png => assets/final/375/autoplr_error.png +0 -0
A assets/final/375/autoplr_on.png => assets/final/375/autoplr_on.png +0 -0
A assets/final/375/cargo_off.png => assets/final/375/cargo_off.png +0 -0
A assets/final/375/cargo_on.png => assets/final/375/cargo_on.png +0 -0
A assets/final/375/earth.png => assets/final/375/earth.png +0 -0
A assets/final/375/ecothruster_on.png => assets/final/375/ecothruster_on.png +0 -0
A assets/final/375/hearty.png => assets/final/375/hearty.png +0 -0
A assets/final/375/hub_off.png => assets/final/375/hub_off.png +0 -0
A assets/final/375/hub_on.png => assets/final/375/hub_on.png +0 -0
A assets/final/375/landingleg.png => assets/final/375/landingleg.png +0 -0
A assets/final/375/landingthruster_off.png => assets/final/375/landingthruster_off.png +0 -0
A assets/final/375/landingthruster_on.png => assets/final/375/landingthruster_on.png +0 -0
A assets/final/375/powerhub_off.png => assets/final/375/powerhub_off.png +0 -0
A assets/final/375/powerhub_on.png => assets/final/375/powerhub_on.png +0 -0
A assets/final/375/superthruster_off.png => assets/final/375/superthruster_off.png +0 -0
A assets/final/375/superthruster_on.png => assets/final/375/superthruster_on.png +0 -0
A assets/final/375/thruster_off.png => assets/final/375/thruster_off.png +0 -0
A assets/final/375/thruster_on.png => assets/final/375/thruster_on.png +0 -0
D assets/final/autoplr_cfg.png => assets/final/autoplr_cfg.png +0 -0
D assets/final/autoplr_error.png => assets/final/autoplr_error.png +0 -0
D assets/final/autoplr_on.png => assets/final/autoplr_on.png +0 -0
D assets/final/cargo_off.png => assets/final/cargo_off.png +0 -0
D assets/final/cargo_on.png => assets/final/cargo_on.png +0 -0
D assets/final/earth.png => assets/final/earth.png +0 -0
D assets/final/ecothruster_on.png => assets/final/ecothruster_on.png +0 -0
A assets/final/full/autoplr_cfg.png => assets/final/full/autoplr_cfg.png +0 -0
A assets/final/full/autoplr_error.png => assets/final/full/autoplr_error.png +0 -0
A assets/final/full/autoplr_on.png => assets/final/full/autoplr_on.png +0 -0
A assets/final/full/cargo_off.png => assets/final/full/cargo_off.png +0 -0
A assets/final/full/cargo_on.png => assets/final/full/cargo_on.png +0 -0
A assets/final/full/earth.png => assets/final/full/earth.png +0 -0
A assets/final/full/ecothruster_on.png => assets/final/full/ecothruster_on.png +0 -0
A assets/final/full/hearty.png => assets/final/full/hearty.png +0 -0
A assets/final/full/hub_off.png => assets/final/full/hub_off.png +0 -0
A assets/final/full/hub_on.png => assets/final/full/hub_on.png +0 -0
R assets/final/icon_landingthruster.png => assets/final/full/icon_landingthruster.png +0 -0
R assets/final/landingleg.png => assets/final/full/landingleg.png +0 -0
A assets/final/full/landingthruster_off.png => assets/final/full/landingthruster_off.png +0 -0
A assets/final/full/landingthruster_on.png => assets/final/full/landingthruster_on.png +0 -0
A assets/final/full/powerhub_off.png => assets/final/full/powerhub_off.png +0 -0
A assets/final/full/powerhub_on.png => assets/final/full/powerhub_on.png +0 -0
A assets/final/full/superthruster_off.png => assets/final/full/superthruster_off.png +0 -0
A assets/final/full/superthruster_on.png => assets/final/full/superthruster_on.png +0 -0
A assets/final/full/thruster_off.png => assets/final/full/thruster_off.png +0 -0
A assets/final/full/thruster_on.png => assets/final/full/thruster_on.png +0 -0
D assets/final/hearty.png => assets/final/hearty.png +0 -0
D assets/final/hub_off.png => assets/final/hub_off.png +0 -0
D assets/final/hub_on.png => assets/final/hub_on.png +0 -0
D assets/final/landingthruster_off.png => assets/final/landingthruster_off.png +0 -0
D assets/final/landingthruster_on.png => assets/final/landingthruster_on.png +0 -0
D assets/final/powerhub_off.png => assets/final/powerhub_off.png +0 -0
D assets/final/powerhub_on.png => assets/final/powerhub_on.png +0 -0
D assets/final/superthruster_off.png => assets/final/superthruster_off.png +0 -0
D assets/final/superthruster_on.png => assets/final/superthruster_on.png +0 -0
D assets/final/thruster_off.png => assets/final/thruster_off.png +0 -0
D assets/final/thruster_on.png => assets/final/thruster_on.png +0 -0
D assets/svg/_shapessvg.svg => assets/svg/_shapessvg.svg +0 -56
@@ 1,56 0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   width="210mm"
   height="297mm"
   viewBox="0 0 210 297"
   version="1.1"
   id="svg15950"
   inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
   sodipodi:docname="shapessvg.svg"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:svg="http://www.w3.org/2000/svg">
  <sodipodi:namedview
     id="namedview15952"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageshadow="2"
     inkscape:pageopacity="0.0"
     inkscape:pagecheckerboard="0"
     inkscape:document-units="mm"
     showgrid="false"
     inkscape:zoom="0.77771465"
     inkscape:cx="397.31796"
     inkscape:cy="561.25984"
     inkscape:window-width="1270"
     inkscape:window-height="1412"
     inkscape:window-x="1282"
     inkscape:window-y="20"
     inkscape:window-maximized="1"
     inkscape:current-layer="layer1" />
  <defs
     id="defs15947" />
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1">
    <path
       id="path13665"
       style="fill:#444444;stroke-width:0.0810001"
       d="m 155.43599,47.928935 a 17.743414,15.170624 0 0 0 -17.74362,15.170651 17.743414,15.170624 0 0 0 17.74362,15.17065 z" />
    <path
       id="rect14203"
       style="fill:#444444;stroke-width:0.0810001"
       d="m -0.63032,23.111208 h 118.53333 l 16.93333,33.866667 H 67.10301 Z"
       sodipodi:nodetypes="ccccc" />
    <path
       id="rect14203-3"
       style="fill:#444444;stroke-width:0.0248011"
       d="m 145.63514,25.914092 h 14.81667 l 2.11666,25.4 h -8.46666 z"
       sodipodi:nodetypes="ccccc" />
  </g>
</svg>

D assets/svg/autoplr_on.ink.svg.2023_04_10_16_49_32.0.svg => assets/svg/autoplr_on.ink.svg.2023_04_10_16_49_32.0.svg +0 -254
@@ 1,254 0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   width="512"
   height="512"
   viewBox="0 0 135.46666 135.46667"
   version="1.1"
   id="svg5"
   inkscape:export-filename="/home/tm85/prj/stk_sprites/autoplr_on.png"
   inkscape:export-xdpi="96"
   inkscape:export-ydpi="96"
   inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
   sodipodi:docname="autoplr_on.ink.svg"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:svg="http://www.w3.org/2000/svg">
  <sodipodi:namedview
     id="namedview7"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageshadow="2"
     inkscape:pageopacity="0.0"
     inkscape:pagecheckerboard="0"
     inkscape:document-units="mm"
     showgrid="false"
     units="px"
     width="512px"
     showguides="true"
     inkscape:snap-object-midpoints="true"
     inkscape:snap-global="true"
     inkscape:guide-bbox="true"
     inkscape:zoom="2"
     inkscape:cx="273.75"
     inkscape:cy="255.75"
     inkscape:window-width="2548"
     inkscape:window-height="1412"
     inkscape:window-x="4"
     inkscape:window-y="20"
     inkscape:window-maximized="1"
     inkscape:current-layer="layer1" />
  <defs
     id="defs2">
    <inkscape:path-effect
       effect="fillet_chamfer"
       id="path-effect17083"
       is_visible="true"
       lpeversion="1"
       satellites_param="F,0,0,1,0,2.1166667,0,1 @ F,0,0,1,0,2.1166667,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1"
       unit="px"
       method="auto"
       mode="F"
       radius="8"
       chamfer_steps="1"
       flexible="false"
       use_knot_distance="true"
       apply_no_radius="true"
       apply_with_radius="true"
       only_selected="false"
       hide_knots="false" />
    <inkscape:path-effect
       effect="fillet_chamfer"
       id="path-effect16803"
       is_visible="true"
       lpeversion="1"
       satellites_param="F,0,0,1,0,2.1166667,0,1 @ F,0,0,1,0,2.1166667,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1"
       unit="px"
       method="auto"
       mode="F"
       radius="8"
       chamfer_steps="1"
       flexible="false"
       use_knot_distance="true"
       apply_no_radius="true"
       apply_with_radius="true"
       only_selected="false"
       hide_knots="false" />
    <inkscape:path-effect
       effect="fillet_chamfer"
       id="path-effect15774"
       is_visible="true"
       lpeversion="1"
       satellites_param="F,0,0,1,0,4.2333333,0,1 @ F,0,0,1,0,4.2333333,0,1 @ F,0,0,1,0,4.2333333,0,1 @ F,0,0,1,0,4.2333333,0,1"
       unit="px"
       method="auto"
       mode="F"
       radius="16"
       chamfer_steps="1"
       flexible="false"
       use_knot_distance="true"
       apply_no_radius="true"
       apply_with_radius="true"
       only_selected="false"
       hide_knots="false" />
    <inkscape:path-effect
       effect="fillet_chamfer"
       id="path-effect15612"
       is_visible="true"
       lpeversion="1"
       satellites_param="F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1"
       unit="px"
       method="auto"
       mode="F"
       radius="16"
       chamfer_steps="1"
       flexible="false"
       use_knot_distance="true"
       apply_no_radius="true"
       apply_with_radius="true"
       only_selected="false"
       hide_knots="false" />
    <inkscape:path-effect
       effect="fillet_chamfer"
       id="path-effect15006"
       is_visible="true"
       lpeversion="1"
       satellites_param="F,0,0,1,0,2.1166667,0,1 @ F,0,0,1,0,2.1166667,0,1 @ F,0,0,1,0,2.1166667,0,1 @ F,0,0,1,0,2.1166667,0,1"
       unit="px"
       method="auto"
       mode="F"
       radius="16"
       chamfer_steps="1"
       flexible="false"
       use_knot_distance="true"
       apply_no_radius="true"
       apply_with_radius="true"
       only_selected="false"
       hide_knots="false" />
    <inkscape:path-effect
       effect="fillet_chamfer"
       id="path-effect12397"
       is_visible="true"
       lpeversion="1"
       satellites_param="F,0,0,1,0,2.6458333,0,5 @ F,0,0,1,0,2.6458333,0,5 @ F,0,0,1,0,2.6458333,0,5 | F,0,0,1,0,2.6458333,0,5 @ F,0,0,1,0,2.6458333,0,5 @ F,0,0,1,0,2.6458333,0,5"
       unit="px"
       method="auto"
       mode="F"
       radius="10"
       chamfer_steps="5"
       flexible="false"
       use_knot_distance="true"
       apply_no_radius="true"
       apply_with_radius="true"
       only_selected="false"
       hide_knots="false" />
    <inkscape:path-effect
       effect="fillet_chamfer"
       id="path-effect12289"
       is_visible="true"
       lpeversion="1"
       satellites_param="C,0,0,1,0,2.6458333,0,5 @ C,0,0,1,0,2.6458333,0,5 @ C,0,0,1,0,2.6458333,0,5 | C,0,0,1,0,2.6458333,0,5 @ C,0,0,1,0,2.6458333,0,5 @ C,0,0,1,0,2.6458333,0,5"
       unit="px"
       method="auto"
       mode="F"
       radius="10"
       chamfer_steps="5"
       flexible="false"
       use_knot_distance="true"
       apply_no_radius="true"
       apply_with_radius="true"
       only_selected="false"
       hide_knots="false" />
    <inkscape:path-effect
       effect="fillet_chamfer"
       id="path-effect12074"
       is_visible="true"
       lpeversion="1"
       satellites_param="F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1"
       unit="px"
       method="auto"
       mode="F"
       radius="0"
       chamfer_steps="1"
       flexible="false"
       use_knot_distance="true"
       apply_no_radius="true"
       apply_with_radius="true"
       only_selected="false"
       hide_knots="false" />
    <filter
       inkscape:menu-tooltip="In and out glow with a possible offset and colorizable flood"
       inkscape:menu="Shadows and Glows"
       inkscape:label="Cutout Glow"
       style="color-interpolation-filters:sRGB;"
       id="filter13281"
       x="-0.23629366"
       y="-0.23629366"
       width="1.4725873"
       height="1.4725873">
      <feGaussianBlur
         stdDeviation="29.536707281068317"
         result="blur"
         id="feGaussianBlur13273" />
      <feComposite
         in="flood"
         in2="SourceGraphic"
         operator="in"
         result="composite"
         id="feComposite13277" />
      <feBlend
         in="blur"
         in2="composite"
         mode="normal"
         id="feBlend13279" />
    </filter>
  </defs>
  <g
     inkscape:groupmode="layer"
     id="layer2"
     inkscape:label="Thrusters"
     style="display:inline" />
  <g
     inkscape:label="Body"
     inkscape:groupmode="layer"
     id="layer1"
     style="display:inline">
    <rect
       style="fill:#888888;fill-opacity:1;stroke-width:0.264583"
       id="rect55"
       width="135.467"
       height="135.46666"
       x="0"
       y="0"
       rx="40.216667"
       ry="40.216667" />
    <rect
       style="fill:#444444;fill-opacity:1;stroke-width:0.215;stroke-miterlimit:4;stroke-dasharray:none"
       id="rect55-3"
       width="110.06667"
       height="110.06667"
       x="12.7"
       y="12.7"
       rx="27.516666"
       ry="27.516666" />
    <g
       id="use12910"
       transform="matrix(-0.14028033,-0.14028033,0.14028033,-0.14028033,67.733335,98.694702)"
       style="fill:#ff0000;stroke:none;stroke-width:0">
      <path
         d="M 0,200 V 0 h 200 a 100,100 90 0 1 0,200 100,100 90 0 1 -200,0 z"
         id="path13158" />
    </g>
    <g
       id="use12910-2"
       transform="matrix(-0.14028033,-0.14028033,0.14028033,-0.14028033,67.733335,98.694702)"
       style="display:inline;fill:#ff0000;stroke:none;stroke-width:0;filter:url(#filter13281)">
      <path
         d="M 0,200 V 0 h 200 a 100,100 90 0 1 0,200 100,100 90 0 1 -200,0 z"
         id="path13158-7" />
    </g>
  </g>
</svg>

D assets/svg/hearty.ink.svg.2023_04_10_17_23_18.0.svg => assets/svg/hearty.ink.svg.2023_04_10_17_23_18.0.svg +0 -296
@@ 1,296 0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   width="512"
   height="512"
   viewBox="0 0 135.46666 135.46667"
   version="1.1"
   id="svg5"
   inkscape:export-filename="/home/tm85/prj/stk_sprites/autoplr_on.png"
   inkscape:export-xdpi="96"
   inkscape:export-ydpi="96"
   inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
   sodipodi:docname="hearty.ink.svg"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:svg="http://www.w3.org/2000/svg">
  <sodipodi:namedview
     id="namedview7"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageshadow="2"
     inkscape:pageopacity="0.0"
     inkscape:pagecheckerboard="0"
     inkscape:document-units="mm"
     showgrid="false"
     units="px"
     width="512px"
     showguides="true"
     inkscape:snap-object-midpoints="true"
     inkscape:snap-global="true"
     inkscape:guide-bbox="true"
     inkscape:zoom="2"
     inkscape:cx="256.25"
     inkscape:cy="253.75"
     inkscape:window-width="2548"
     inkscape:window-height="1412"
     inkscape:window-x="4"
     inkscape:window-y="20"
     inkscape:window-maximized="1"
     inkscape:current-layer="layer1" />
  <defs
     id="defs2">
    <inkscape:path-effect
       effect="fillet_chamfer"
       id="path-effect17083"
       is_visible="true"
       lpeversion="1"
       satellites_param="F,0,0,1,0,2.1166667,0,1 @ F,0,0,1,0,2.1166667,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1"
       unit="px"
       method="auto"
       mode="F"
       radius="8"
       chamfer_steps="1"
       flexible="false"
       use_knot_distance="true"
       apply_no_radius="true"
       apply_with_radius="true"
       only_selected="false"
       hide_knots="false" />
    <inkscape:path-effect
       effect="fillet_chamfer"
       id="path-effect16803"
       is_visible="true"
       lpeversion="1"
       satellites_param="F,0,0,1,0,2.1166667,0,1 @ F,0,0,1,0,2.1166667,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1"
       unit="px"
       method="auto"
       mode="F"
       radius="8"
       chamfer_steps="1"
       flexible="false"
       use_knot_distance="true"
       apply_no_radius="true"
       apply_with_radius="true"
       only_selected="false"
       hide_knots="false" />
    <inkscape:path-effect
       effect="fillet_chamfer"
       id="path-effect15774"
       is_visible="true"
       lpeversion="1"
       satellites_param="F,0,0,1,0,4.2333333,0,1 @ F,0,0,1,0,4.2333333,0,1 @ F,0,0,1,0,4.2333333,0,1 @ F,0,0,1,0,4.2333333,0,1"
       unit="px"
       method="auto"
       mode="F"
       radius="16"
       chamfer_steps="1"
       flexible="false"
       use_knot_distance="true"
       apply_no_radius="true"
       apply_with_radius="true"
       only_selected="false"
       hide_knots="false" />
    <inkscape:path-effect
       effect="fillet_chamfer"
       id="path-effect15612"
       is_visible="true"
       lpeversion="1"
       satellites_param="F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1"
       unit="px"
       method="auto"
       mode="F"
       radius="16"
       chamfer_steps="1"
       flexible="false"
       use_knot_distance="true"
       apply_no_radius="true"
       apply_with_radius="true"
       only_selected="false"
       hide_knots="false" />
    <inkscape:path-effect
       effect="fillet_chamfer"
       id="path-effect15006"
       is_visible="true"
       lpeversion="1"
       satellites_param="F,0,0,1,0,2.1166667,0,1 @ F,0,0,1,0,2.1166667,0,1 @ F,0,0,1,0,2.1166667,0,1 @ F,0,0,1,0,2.1166667,0,1"
       unit="px"
       method="auto"
       mode="F"
       radius="16"
       chamfer_steps="1"
       flexible="false"
       use_knot_distance="true"
       apply_no_radius="true"
       apply_with_radius="true"
       only_selected="false"
       hide_knots="false" />
    <inkscape:path-effect
       effect="fillet_chamfer"
       id="path-effect12397"
       is_visible="true"
       lpeversion="1"
       satellites_param="F,0,0,1,0,2.6458333,0,5 @ F,0,0,1,0,2.6458333,0,5 @ F,0,0,1,0,2.6458333,0,5 | F,0,0,1,0,2.6458333,0,5 @ F,0,0,1,0,2.6458333,0,5 @ F,0,0,1,0,2.6458333,0,5"
       unit="px"
       method="auto"
       mode="F"
       radius="10"
       chamfer_steps="5"
       flexible="false"
       use_knot_distance="true"
       apply_no_radius="true"
       apply_with_radius="true"
       only_selected="false"
       hide_knots="false" />
    <inkscape:path-effect
       effect="fillet_chamfer"
       id="path-effect12289"
       is_visible="true"
       lpeversion="1"
       satellites_param="C,0,0,1,0,2.6458333,0,5 @ C,0,0,1,0,2.6458333,0,5 @ C,0,0,1,0,2.6458333,0,5 | C,0,0,1,0,2.6458333,0,5 @ C,0,0,1,0,2.6458333,0,5 @ C,0,0,1,0,2.6458333,0,5"
       unit="px"
       method="auto"
       mode="F"
       radius="10"
       chamfer_steps="5"
       flexible="false"
       use_knot_distance="true"
       apply_no_radius="true"
       apply_with_radius="true"
       only_selected="false"
       hide_knots="false" />
    <inkscape:path-effect
       effect="fillet_chamfer"
       id="path-effect12074"
       is_visible="true"
       lpeversion="1"
       satellites_param="F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1"
       unit="px"
       method="auto"
       mode="F"
       radius="0"
       chamfer_steps="1"
       flexible="false"
       use_knot_distance="true"
       apply_no_radius="true"
       apply_with_radius="true"
       only_selected="false"
       hide_knots="false" />
    <filter
       inkscape:menu-tooltip="In and out glow with a possible offset and colorizable flood"
       inkscape:menu="Shadows and Glows"
       inkscape:label="Cutout Glow"
       style="color-interpolation-filters:sRGB;"
       id="filter13281"
       x="-0.23629366"
       y="-0.23629366"
       width="1.4725873"
       height="1.4725873">
      <feGaussianBlur
         stdDeviation="29.536707281068317"
         result="blur"
         id="feGaussianBlur13273" />
      <feComposite
         in="flood"
         in2="SourceGraphic"
         operator="in"
         result="composite"
         id="feComposite13277" />
      <feBlend
         in="blur"
         in2="composite"
         mode="normal"
         id="feBlend13279" />
    </filter>
  </defs>
  <g
     inkscape:groupmode="layer"
     id="layer2"
     inkscape:label="Thrusters"
     style="display:inline" />
  <g
     inkscape:label="Body"
     inkscape:groupmode="layer"
     id="layer1"
     style="display:inline">
    <rect
       style="fill:#888888;fill-opacity:1;stroke-width:0.264583"
       id="rect55"
       width="135.467"
       height="135.46666"
       x="-188.04745"
       y="62.635887"
       rx="40.216667"
       ry="40.216667" />
    <path
       id="rect14203-6"
       style="display:inline;fill:#444444;stroke-width:0.0640362"
       d="M 345.5593,64.23341 H 210.09263 l 12.7,21.166667 H 332.8593 Z"
       sodipodi:nodetypes="ccccc" />
    <path
       id="rect14203-6-5"
       style="display:inline;fill:#444444;stroke-width:0.0572757"
       d="M 135.46667,4.2333307 H 3.6315917e-8 L 12.7,21.166664 h 110.06667 z"
       sodipodi:nodetypes="ccccc" />
    <path
       id="rect14203-3-7"
       style="display:inline;fill:#444444;stroke-width:0.0382211"
       d="m 214.93032,47.774974 h -22.225 l -3.175,-40.2166699 h 12.69999 z"
       sodipodi:nodetypes="ccccc" />
    <path
       id="path13665"
       style="fill:#444444;stroke-width:0.0810001"
       d="M 184.9065,-26.855329 A 17.743414,15.170624 0 0 0 167.16288,-11.684678 17.743414,15.170624 0 0 0 184.9065,3.4859718 Z" />
    <path
       id="rect14203-6-3"
       style="display:inline;fill:#444444;stroke-width:0.0572757"
       d="M 135.46667,131.23333 H 2.2705078e-7 L 12.7,114.3 h 110.06667 z"
       sodipodi:nodetypes="ccccc" />
    <rect
       style="fill:#777777;fill-opacity:1;stroke-width:0.26428"
       id="rect2738"
       width="110.06667"
       height="110.06667"
       x="12.699998"
       y="12.7"
       rx="9.5249996" />
    <rect
       style="fill:#444444;fill-opacity:1;stroke-width:0.197771;stroke-miterlimit:4;stroke-dasharray:none"
       id="rect55-3"
       width="93.133331"
       height="93.133331"
       x="21.166666"
       y="21.166668"
       rx="16.933332"
       ry="16.933332"
       inkscape:export-filename="/home/tm85/prj/stk_sprites/hearty.png"
       inkscape:export-xdpi="96"
       inkscape:export-ydpi="96" />
    <g
       id="use12910"
       transform="matrix(-0.14028033,-0.14028033,0.14028033,-0.14028033,67.733335,98.694702)"
       style="fill:#ff0000;stroke:none;stroke-width:0">
      <path
         d="M 0,200 V 0 h 200 a 100,100 90 0 1 0,200 100,100 90 0 1 -200,0 z"
         id="path13158" />
    </g>
    <g
       id="use12910-2"
       transform="matrix(-0.14028033,-0.14028033,0.14028033,-0.14028033,67.733335,98.694702)"
       style="display:inline;fill:#ff0000;stroke:none;stroke-width:0;filter:url(#filter13281)">
      <path
         d="M 0,200 V 0 h 200 a 100,100 90 0 1 0,200 100,100 90 0 1 -200,0 z"
         id="path13158-7" />
    </g>
    <rect
       style="fill:#444444;fill-opacity:1;stroke-width:0.203456"
       id="rect3826"
       width="47.067856"
       height="21.166666"
       x="210.09264"
       y="64.233414" />
  </g>
</svg>

M client/Cargo.toml => client/Cargo.toml +9 -4
@@ 25,9 25,9 @@ markdown = "1.0.0-alpha.7" # DO NOT DOWNGRADE
async-recursion = "1"
console_error_panic_hook = "0.1"
async-trait = "0.1.68"
image = "0.24.6"
ron = "0.8"
base64 = "0.21.0"
image = { version = "0.24.6", optional = true }
ron = { version = "0.8", optional = true }
base64 = { version = "0.21.0", optional = true }

[dependencies.web-sys]
version = "0.3.4"


@@ 37,4 37,9 @@ features = [
    'HtmlCanvasElement',
    'Window',
    'CanvasRenderingContext2d'
]
\ No newline at end of file
]

[features]
default = ['textures-slow']
textures-slow = []
textures-fast = ['image', 'ron', 'base64']
\ No newline at end of file

M client/src/lib.rs => client/src/lib.rs +21 -10
@@ 1,4 1,5 @@
use std::error::Error;
use std::str::FromStr;

use futures::stream::{SplitSink, SplitStream};
use futures::StreamExt;


@@ 21,7 22,7 @@ use web_sys::{Window};
use starkingdoms_protocol::GoodbyeReason::PingPongTimeout;
use crate::rendering::renderer::WebRenderer;
use crate::textures::loader::TextureLoader;
use crate::textures::TextureManager;
use crate::textures::{TextureManager, TextureSize};


#[macro_use]


@@ 48,7 49,8 @@ pub struct ClientData {
    pub state: State,
    pub tx: SplitSink<WsStream, WsMessage>,
    pub rx: SplitStream<WsStream>,
    pub pong_timeout: u64
    pub pong_timeout: u64,
    pub textures: TextureLoader
}

pub const PONG_MAX_TIMEOUT: u64 = 5;


@@ 65,7 67,7 @@ lazy_static! {
pub const MAX_CONNECTION_TRIES: i32 = 10;

#[wasm_bindgen]
pub async fn rust_init(gateway: &str, username: &str) -> Result<(), JsValue> {
pub async fn rust_init(gateway: &str, username: &str, texture_size: &str) -> Result<(), JsValue> {
    console_error_panic_hook::set_once();

    set_status("Starting logger...");


@@ 77,11 79,9 @@ pub async fn rust_init(gateway: &str, username: &str) -> Result<(), JsValue> {
    info!("Loading sprites...");
    set_status("Loading sprites..");

    //let textures = TextureLoader::load().map_err(|e| e.to_string())?;
    let textures = TextureLoader::load(TextureSize::from_str(texture_size).unwrap()).map_err(|e| e.to_string())?;



    match main(gateway, username, 1).await {
    match main(gateway, username, 1, textures).await {
        Ok(c) => c,
        Err(e) => {
            error!("Error initializing gateway client: {}", e);


@@ 95,7 95,7 @@ pub async fn rust_init(gateway: &str, username: &str) -> Result<(), JsValue> {
}

#[async_recursion(?Send)]
pub async fn main(gateway: &str, username: &str, backoff: i32) -> Result<(), Box<dyn Error>> {
pub async fn main(gateway: &str, username: &str, backoff: i32, textures: TextureLoader) -> Result<(), Box<dyn Error>> {
    if backoff != 1 {
        info!("Backing off connection: waiting {} seconds", backoff * backoff);
        wait_for(sleep(backoff * backoff * 1000)).await;


@@ 119,7 119,7 @@ pub async fn main(gateway: &str, username: &str, backoff: i32) -> Result<(), Box
        Err(e) => {
            return match e {
                WsErr::ConnectionFailed { .. } => {
                    main(gateway, username, backoff + 1).await
                    main(gateway, username, backoff + 1, textures).await
                },
                _ => {
                    Err(e.into())


@@ 134,7 134,8 @@ pub async fn main(gateway: &str, username: &str, backoff: i32) -> Result<(), Box
        state: State::Handshake,
        tx,
        rx,
        pong_timeout: (js_sys::Date::now() as u64 / 1000) + 5
        pong_timeout: (js_sys::Date::now() as u64 / 1000) + 5,
        textures,
    };

    trace!("Split stream, handshaking with server");


@@ 275,4 276,14 @@ pub async fn wait_for(promise: js_sys::Promise) -> JsFuture {
#[wasm_bindgen]
pub fn version() -> u32 {
    PROTOCOL_VERSION
}

#[wasm_bindgen]
pub fn get_texture(texture_id: &str) -> Option<String> {
    let client = CLIENT.read().unwrap();
    if let Some(client_data) = &client.client_data {
        client_data.textures.get_texture(texture_id)
    } else {
        None
    }
}
\ No newline at end of file

R client/src/textures/loader.rs => client/src/textures/loader_fast.rs +35 -10
@@ 5,10 5,16 @@ use base64::Engine;
use image::ImageOutputFormat;
use log::debug;
use serde::{Deserialize, Serialize};
use crate::textures::TextureManager;
use crate::textures::{TextureManager, TextureSize};

pub const SPRITESHEET_IMAGE_FILE: &[u8] = include_bytes!("../../../assets/dist/spritesheet.png");
pub const SPRITESHEET_DATA_FILE: &str = include_str!("../../../assets/dist/spritesheet.ron");
pub const SPRITESHEET_IMAGE_FILE_FULL: &[u8] = include_bytes!("../../../assets/dist/spritesheet-full.png");
pub const SPRITESHEET_DATA_FILE_FULL: &str = include_str!("../../../assets/dist/spritesheet-full.ron");

pub const SPRITESHEET_IMAGE_FILE_375: &[u8] = include_bytes!("../../../assets/dist/spritesheet-375.png");
pub const SPRITESHEET_DATA_FILE_375: &str = include_str!("../../../assets/dist/spritesheet-375.ron");

pub const SPRITESHEET_IMAGE_FILE_125: &[u8] = include_bytes!("../../../assets/dist/spritesheet-125.png");
pub const SPRITESHEET_DATA_FILE_125: &str = include_str!("../../../assets/dist/spritesheet-125.ron");

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct SpritePosition {


@@ 32,12 38,14 @@ pub struct TextureLoader {
    pub sprites: HashMap<String, String>
}
impl TextureManager for TextureLoader {
    fn load() -> Result<Self, Box<dyn Error>> where Self: Sized {
    fn load(size: TextureSize) -> Result<Self, Box<dyn Error>> where Self: Sized {
        debug!("Loading textures - starting fast texture loader (size: {})", size.to_string());
        let start = js_sys::Date::now() as u64;
        // load the generated spritesheet data
        let spritesheet_data: SerializedSpriteSheet = ron::from_str(SPRITESHEET_DATA_FILE)?;
        let spritesheet_data: SerializedSpriteSheet = ron::from_str(pick_data_file(size))?;

        // load the generated spritesheet image
        let spritesheet_image = image::load_from_memory(SPRITESHEET_IMAGE_FILE)?;
        let spritesheet_image = image::load_from_memory(pick_image_file(size))?;

        if spritesheet_image.width() as f32 != spritesheet_data.texture_width {
            return Err("Image width mismatch between spritesheet and data file".into());


@@ 55,17 63,34 @@ impl TextureManager for TextureLoader {
            sprite_img.write_to(&mut Cursor::new(&mut image_data), ImageOutputFormat::Png)
                .unwrap();
            let res_base64 = base64::engine::general_purpose::STANDARD.encode(image_data);
            sprites.insert(sprite.name, res_base64);
            sprites.insert(sprite.name, format!("data:image/png;base64,{}", res_base64));
        }

        debug!("Loaded {} sprites from spritesheet", sprites.len());
        let end = js_sys::Date::now() as u64;
        debug!("Loaded {} sprites from spritesheet in {} ms", sprites.len(), end - start);

        Ok(Self {
            sprites,
        })
    }

    fn get_texture(&self, texture_id: &str) -> Option<&String> {
        self.sprites.get(texture_id)
    fn get_texture(&self, texture_id: &str) -> Option<String> {
        self.sprites.get(texture_id).map(|u| u.clone())
    }
}

fn pick_data_file(for_size: TextureSize) -> &'static str {
    match for_size {
        TextureSize::Full => SPRITESHEET_DATA_FILE_FULL,
        TextureSize::Scaled375 => SPRITESHEET_DATA_FILE_375,
        TextureSize::Scaled125 => SPRITESHEET_DATA_FILE_125
    }
}

fn pick_image_file(for_size: TextureSize) -> &'static [u8] {
    match for_size {
        TextureSize::Full => SPRITESHEET_IMAGE_FILE_FULL,
        TextureSize::Scaled375 => SPRITESHEET_IMAGE_FILE_375,
        TextureSize::Scaled125 => SPRITESHEET_IMAGE_FILE_125
    }
}
\ No newline at end of file

A client/src/textures/loader_slow.rs => client/src/textures/loader_slow.rs +20 -0
@@ 0,0 1,20 @@
use crate::textures::{TextureManager, TextureSize};
use std::error::Error;
use log::debug;

#[derive(Debug)]
pub struct TextureLoader {
    size: TextureSize
}
impl TextureManager for TextureLoader {
    fn load(size: TextureSize) -> Result<Self, Box<dyn Error>> where Self: Sized {
        debug!("Using slow texture loader, textures will be loaded on-the-fly");
        Ok(TextureLoader {
            size
        })
    }

    fn get_texture(&self, texture_id: &str) -> Option<String> {
        Some(format!("/../assets/final/{}/{}.png", self.size.to_string(), texture_id))
    }
}
\ No newline at end of file

M client/src/textures/mod.rs => client/src/textures/mod.rs +42 -2
@@ 1,8 1,48 @@
use std::error::Error;
use std::str::FromStr;

#[cfg(all(feature = "textures-fast", feature = "textures-slow"))]
compile_error!("You cannot use both texture loaders. Please only enable one of the textures-fast or textures-slow feature.");
#[cfg(not(any(feature = "textures-fast", feature = "textures-slow")))]
compile_error!("You need to enable a texture loader. Please enable one of the textures-fast, textures-slow feature.");

#[cfg(feature = "textures-fast")]
#[path = "loader_fast.rs"]
pub mod loader;

#[cfg(feature = "textures-slow")]
#[path = "loader_slow.rs"]
pub mod loader;

pub trait TextureManager {
    fn load() -> Result<Self, Box<dyn Error>> where Self: Sized;
    fn get_texture(&self, texture_id: &str) -> Option<&String>;
    fn load(size: TextureSize) -> Result<Self, Box<dyn Error>> where Self: Sized;
    fn get_texture(&self, texture_id: &str) -> Option<String>;
}

#[derive(Debug, Copy, Clone)]
pub enum TextureSize {
    Full,
    Scaled375,
    Scaled125
}
impl ToString for TextureSize {
    fn to_string(&self) -> String {
        match self {
            TextureSize::Full => "full".to_string(),
            TextureSize::Scaled375 => "375".to_string(),
            TextureSize::Scaled125 => "125".to_string()
        }
    }
}
impl FromStr for TextureSize {
    type Err = ();

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s {
            "full" => Ok(TextureSize::Full),
            "375" => Ok(TextureSize::Scaled375),
            "125" => Ok(TextureSize::Scaled125),
            _ => Err(())
        }
    }
}
\ No newline at end of file

M justfile => justfile +34 -2
@@ 4,15 4,47 @@ run_server:
run_http: build_client_bundle
    cd web && python3 -m http.server

build_client_bundle:
run_http_prod: build_client_bundle_prod
    cd web && python3 -m http.server

build_client_bundle: build_assets
    rm -rf web/dist
    RUST_BACKTRACE=1 wasm-pack build --target web client
    cp -r client/pkg web/dist

build_client_bundle_prod: build_assets
    rm -rf web/dist
    RUST_BACKTRACE=1 wasm-pack build --target web client --no-default-features --features textures-fast
    cp -r client/pkg web/dist

install_tooling:
    cargo install wasm-pack --no-default-features
    cargo install sheep_cli

clean:
    rm -rf target
    rm -rf client/pkg
    rm -rf web/dist
\ No newline at end of file
    rm -rf web/dist

build_assets: build_assets_full build_assets_375 build_assets_125

build_assets_full:
    mkdir -p assets/final/full
    inkscape -w 512 -h 512 assets/svg/*.svg --export-type "png"
    inkscape -w 2048 -h 2048 assets/svg/earth.svg --export-type "png" # Earth is a different size than all other sprites
    mv assets/svg/*.png assets/final/full/
    sheep pack assets/final/full/*.png -f amethyst_named -o assets/dist/spritesheet-full

build_assets_375:
    mkdir -p assets/final/375
    inkscape -w 192 -h 192 assets/svg/*.svg --export-type "png"
    inkscape -w 768 -h 768 assets/svg/earth.svg --export-type "png" # Earth is a different size than all other sprites
    mv assets/svg/*.png assets/final/375
    sheep pack assets/final/375/*.png -f amethyst_named -o assets/dist/spritesheet-375

build_assets_125:
    mkdir -p assets/final/125
    inkscape -w 64 -h 64 assets/svg/*.svg --export-type "png"
    inkscape -w 256 -h 256 assets/svg/earth.svg --export-type "png" # Earth is a different size than all other sprites
    mv assets/svg/*.png assets/final/125
    sheep pack assets/final/125/*.png -f amethyst_named -o assets/dist/spritesheet-125
\ No newline at end of file

A web/assets => web/assets +1 -0
@@ 0,0 1,1 @@
../assets
\ No newline at end of file

M web/index.html => web/index.html +7 -0
@@ 16,6 16,13 @@
                    <!-- Dynamically filled by the JS later in this file -->
                </select>
                <br>
                <label for="textures">Texture quality</label>
                <select class="joingamecontent" name="textures" id="textures">
                    <option value="full">Full quality (May impact loading times)</option>
                    <option selected value="375">Medium quality (Recommended)</option>
                    <option value="125">Low quality</option>
                </select>
                <br>
                <label for="username">Username</label>
                <br>
                <input class="m-5px" type="text" name="username" id="username" required />

M web/play.html => web/play.html +26 -2
@@ 16,6 16,10 @@
            <input id="chat-value" type="text" placeholder="chat text goes here" />
            <button id="chat-submit">submit</button>
            <p id="status">Loading WASM module...</p>

            <div id="textures">

            </div>
        </div>

        <canvas style="width: 100%; height: 100%" id="canvas"></canvas>


@@ 23,11 27,11 @@
        <script type="module">
            // If you're getting build errors here | you need to run `just build_client_bundle` first, to compile client code
            //                                     v
            import init, { rust_init, send_chat, update_socket, set_status } from "./dist/starkingdoms_client.js";
            import init, { rust_init, send_chat, update_socket, set_status, get_texture } from "./dist/starkingdoms_client.js";
            init().then(() => {
                const urlSearchParams = new URLSearchParams(window.location.search);

                rust_init(urlSearchParams.get("server"), urlSearchParams.get("username")).then(() => {
                rust_init(urlSearchParams.get("server"), urlSearchParams.get("username"), urlSearchParams.get("textures")).then(() => {
                    document.getElementById("chat-submit").addEventListener("click", e => {
                        send_chat(document.getElementById("chat-value").value);
                    });


@@ 40,6 44,26 @@
                            throw e;
                        });
                    }, 5);

                    if (urlSearchParams.has("showTextures")) {
                        let textures = ["autoplr_cfg", "autoplr_error", "autoplr_on", "cargo_off", "cargo_on", "earth", "ecothruster_on", "hearty", "hub_off", "hub_on", "landingleg", "landingthruster_off", "landingthruster_on", "powerhub_off", "powerhub_on", "superthruster_off", "superthruster_on", "thruster_off", "thruster_on"];

                        for (let i = 0; i < textures.length; i++) {
                            let texture = textures[i];

                            let fieldset_elem = document.createElement("fieldset");
                            fieldset_elem.style = "width: min-content;";
                            let legend_elem = document.createElement("legend");
                            legend_elem.innerText = texture;

                            let img_elem = document.createElement("img");
                            img_elem.src = get_texture(texture);

                            fieldset_elem.appendChild(legend_elem);
                            fieldset_elem.appendChild(img_elem);
                            document.body.appendChild(fieldset_elem);
                        }
                    }
                });
            })
        </script>