From eecfe82abd172ff1ce91ced197bc86c4edd969f1 Mon Sep 17 00:00:00 2001 From: nek0 Date: Fri, 18 Feb 2022 21:34:02 +0100 Subject: [PATCH] follow NanoVG changes --- src/Init.hs | 2 +- src/Load.hs | 82 +++++++++++++++++++++++++++-------------------------- src/Util.hs | 2 +- 3 files changed, 44 insertions(+), 42 deletions(-) diff --git a/src/Init.hs b/src/Init.hs index 150b966..baed08e 100644 --- a/src/Init.hs +++ b/src/Init.hs @@ -77,7 +77,7 @@ loadPlayerSprite fp w h nvg rids = do mapM (\(num, i) -> do let cr = crop (num * w) (row * h) w h img mresimg <- - createImageMem nvg ImagePremultiplied (toStrict $ encodePng cr) + createImageMem nvg (S.singleton ImagePremultiplied) (toStrict $ encodePng cr) case mresimg of Nothing -> do logIO diff --git a/src/Load.hs b/src/Load.hs index 3f447b8..0a9d6f0 100644 --- a/src/Load.hs +++ b/src/Load.hs @@ -13,11 +13,13 @@ import qualified Data.Map as M import qualified Data.Text as T import Data.Ecstasy import Data.Maybe +import qualified Data.Set as S import Data.String import System.Exit (exitFailure) import NanoVG hiding (V2(..)) +import NanoVG.Internal.Image -- internal imports @@ -69,202 +71,202 @@ loadFork ws win glc nvg future progress = do ( p + increment , "Loading icon \"conntroller_blue\"" ))) - mcontrblue <- createImage nvg (FileName "assets/icons/controller_blue.png") 0 + mcontrblue <- createImage nvg (FileName "assets/icons/controller_blue.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading icon \"controller_blue\"" ))) - mcontrgreen <- createImage nvg (FileName "assets/icons/controller_green.png") 0 + mcontrgreen <- createImage nvg (FileName "assets/icons/controller_green.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading icon \"controller_green\"" ))) - mkbdblue <- createImage nvg (FileName "assets/icons/keyboard_blue.png") 0 + mkbdblue <- createImage nvg (FileName "assets/icons/keyboard_blue.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading icon \"keyboard_blue\"" ))) - mkbdgreen <- createImage nvg (FileName "assets/icons/keyboard_green.png") 0 + mkbdgreen <- createImage nvg (FileName "assets/icons/keyboard_green.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading icon \"keyboard_green\"" ))) - marrow <- createImage nvg (FileName "assets/icons/arrow.png") 0 + marrow <- createImage nvg (FileName "assets/icons/arrow.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"wall_asc\"" ))) - mwallasc <- createImage nvg (FileName "assets/walls/wall_asc.png") 0 + mwallasc <- createImage nvg (FileName "assets/walls/wall_asc.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"wall_desc\"" ))) - mwalldesc <- createImage nvg (FileName "assets/walls/wall_desc.png") 0 + mwalldesc <- createImage nvg (FileName "assets/walls/wall_desc.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"wall_corner_n\"" ))) - mwallcornern <- createImage nvg (FileName "assets/walls/wall_corner_n.png") 0 + mwallcornern <- createImage nvg (FileName "assets/walls/wall_corner_n.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"wall_corner_e\"" ))) - mwallcornere <- createImage nvg (FileName "assets/walls/wall_corner_e.png") 0 + mwallcornere <- createImage nvg (FileName "assets/walls/wall_corner_e.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"wall_corner_s\"" ))) - mwallcorners <- createImage nvg (FileName "assets/walls/wall_corner_s.png") 0 + mwallcorners <- createImage nvg (FileName "assets/walls/wall_corner_s.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"wall_corner_w\"" ))) - mwallcornerw <- createImage nvg (FileName "assets/walls/wall_corner_w.png") 0 + mwallcornerw <- createImage nvg (FileName "assets/walls/wall_corner_w.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"wall_t_ne\"" ))) - mwalltne <- createImage nvg (FileName "assets/walls/wall_t_ne.png") 0 + mwalltne <- createImage nvg (FileName "assets/walls/wall_t_ne.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"wall_t_se\"" ))) - mwalltse <- createImage nvg (FileName "assets/walls/wall_t_se.png") 0 + mwalltse <- createImage nvg (FileName "assets/walls/wall_t_se.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"wall_t_sw\"" ))) - mwalltsw <- createImage nvg (FileName "assets/walls/wall_t_sw.png") 0 + mwalltsw <- createImage nvg (FileName "assets/walls/wall_t_sw.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"wall_t_nw\"" ))) - mwalltnw <- createImage nvg (FileName "assets/walls/wall_t_nw.png") 0 + mwalltnw <- createImage nvg (FileName "assets/walls/wall_t_nw.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"wall_cross\"" ))) - mwallcross <- createImage nvg (FileName "assets/walls/wall_cross.png") 0 + mwallcross <- createImage nvg (FileName "assets/walls/wall_cross.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"box1\"" ))) - mmiscbox1 <- createImage nvg (FileName "assets/misc/box1.png") 0 + mmiscbox1 <- createImage nvg (FileName "assets/misc/box1.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"tableSW\"" ))) - mtableSW <- createImage nvg (FileName "assets/table/tableSW.png") 0 + mtableSW <- createImage nvg (FileName "assets/table/tableSW.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"tableSE\"" ))) - mtableSE <- createImage nvg (FileName "assets/table/tableSE.png") 0 + mtableSE <- createImage nvg (FileName "assets/table/tableSE.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"tableNE\"" ))) - mtableNE <- createImage nvg (FileName "assets/table/tableNE.png") 0 + mtableNE <- createImage nvg (FileName "assets/table/tableNE.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"tableNW\"" ))) - mtableNW <- createImage nvg (FileName "assets/table/tableNW.png") 0 + mtableNW <- createImage nvg (FileName "assets/table/tableNW.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"tableC1\"" ))) - mtablec1 <- createImage nvg (FileName "assets/table/tablec1.png") 0 + mtablec1 <- createImage nvg (FileName "assets/table/tablec1.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"tableC2\"" ))) - mtablec2 <- createImage nvg (FileName "assets/table/tablec2.png") 0 + mtablec2 <- createImage nvg (FileName "assets/table/tablec2.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"tableC3\"" ))) - mtablec3 <- createImage nvg (FileName "assets/table/tablec3.png") 0 + mtablec3 <- createImage nvg (FileName "assets/table/tablec3.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"tableC4\"" ))) - mtablec4 <- createImage nvg (FileName "assets/table/tablec4.png") 0 + mtablec4 <- createImage nvg (FileName "assets/table/tablec4.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"tableCorner\"" ))) - mtableC <- createImage nvg (FileName "assets/table/tableCorner.png") 0 + mtableC <- createImage nvg (FileName "assets/table/tableCorner.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"flipchart\"" ))) - mmiscFlipchart <- createImage nvg (FileName "assets/misc/flipchart.png") 0 + mmiscFlipchart <- createImage nvg (FileName "assets/misc/flipchart.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"plant1\"" ))) - mmiscPlant1 <- createImage nvg (FileName "assets/misc/plant1.png") 0 + mmiscPlant1 <- createImage nvg (FileName "assets/misc/plant1.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"plant2\"" ))) - mmiscPlant2 <- createImage nvg (FileName "assets/misc/plant2.png") 0 + mmiscPlant2 <- createImage nvg (FileName "assets/misc/plant2.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"watercooler\"" ))) - mmiscWatercooler <- createImage nvg (FileName "assets/misc/watercooler.png") 0 + mmiscWatercooler <- createImage nvg (FileName "assets/misc/watercooler.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"vending machine\"" ))) - mmiscVending <- createImage nvg (FileName "assets/misc/vending.png") 0 + mmiscVending <- createImage nvg (FileName "assets/misc/vending.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"Cabinet with Coffee machine SW\"" ))) - mcabCoffeeSW <- createImage nvg (FileName "assets/cabinet/cabCoffeeSW.png") 0 + mcabCoffeeSW <- createImage nvg (FileName "assets/cabinet/cabCoffeeSW.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"Cabinet with Coffee machine SE\"" ))) - mcabCoffeeSE <- createImage nvg (FileName "assets/cabinet/cabCoffeeSE.png") 0 + mcabCoffeeSE <- createImage nvg (FileName "assets/cabinet/cabCoffeeSE.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"Cabinet with sink SW\"" ))) - mcabSinkSW <- createImage nvg (FileName "assets/cabinet/cabSinkSW.png") 0 + mcabSinkSW <- createImage nvg (FileName "assets/cabinet/cabSinkSW.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"Cabinet with sink SE\"" ))) - mcabSinkSE <- createImage nvg (FileName "assets/cabinet/cabSinkSE.png") 0 + mcabSinkSE <- createImage nvg (FileName "assets/cabinet/cabSinkSE.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"Cabinet with stove SW\"" ))) - mcabStoveSW <- createImage nvg (FileName "assets/cabinet/cabStoveSW.png") 0 + mcabStoveSW <- createImage nvg (FileName "assets/cabinet/cabStoveSW.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"Cabinet with stove SE\"" ))) - mcabStoveSE <- createImage nvg (FileName "assets/cabinet/cabStoveSE.png") 0 + mcabStoveSE <- createImage nvg (FileName "assets/cabinet/cabStoveSE.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"cabinet SW\"" ))) - mcabinetSW <- createImage nvg (FileName "assets/cabinet/cabinetSW.png") 0 + mcabinetSW <- createImage nvg (FileName "assets/cabinet/cabinetSW.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"cabinet SE\"" ))) - mcabinetSE <- createImage nvg (FileName "assets/cabinet/cabinetSE.png") 0 + mcabinetSE <- createImage nvg (FileName "assets/cabinet/cabinetSE.png") (S.singleton ImagePremultiplied) modifyMVar_ progress (return . (\(p, _) -> ( p + increment , "Loading asset \"cabinet corner\"" ))) - mcabinetCorner <- createImage nvg (FileName "assets/cabinet/cabinetCorner.png") 0 + mcabinetCorner <- createImage nvg (FileName "assets/cabinet/cabinetCorner.png") (S.singleton ImagePremultiplied) let micons = [ mcontrblue, mcontrgreen, mkbdblue, mkbdgreen, marrow ] diff --git a/src/Util.hs b/src/Util.hs index 9ade31f..2c23b59 100644 --- a/src/Util.hs +++ b/src/Util.hs @@ -257,7 +257,7 @@ loadAnimationSprites fp nvg idconfs = do mresimgs <- mapM (\cr -> createImageMem nvg - ImagePremultiplied (toStrict $ encodePng cr)) + (S.singleton ImagePremultiplied) (toStrict $ encodePng cr)) crs imgs <- if any isNothing mresimgs then do