<commit_before>
module AppData where
#include "Gamgine/Utils.cpp"
import qualified Graphics.UI.GLFW as GLFW
import qualified Data.IORef as R
import qualified Data.List as L
import Data.Maybe (fromMaybe)
import qualified Control.Monad.State as ST
import qualified Gamgine.Utils as GU
import qualified GameData.Data as GD
import qualified GameData.Level as LV
import qualified GameData.Entity as E
import qualified Rendering.Ressources as RR
import qualified Updater as UP
import qualified Defaults as DF
import qualified States.State as S
import qualified States.StateTree as SS
import States.StateTree (enterWhen, leaveWhen, adjacents, StateTree(..), StateTransition(..))
import States.StateTreeZipper as SZ
import qualified States.GameRunning as GR
import qualified States.MovingEntity as ME
import qualified States.CreatingPlatform as CP
import qualified States.ResizingPlatform as RP
import qualified States.KeyInfo as KI
import qualified States.MouseInfo as MI
import qualified States.InputInfo as II
import States.InputInfo (Modifier(..), InputState(..))
IMPORT_LENS

data AppData = AppData {
   windowSize       :: (Int, Int),
   frustumSize      :: (Double, Double),
   orthoScale       :: Double,
   renderRessources :: RR.Ressources,
   updaters         :: [UP.Updater AppData],
   gameData         :: GD.Data,
   stateTree        :: SZ.Zipper GD.Data
   }

LENS(windowSize)
LENS(frustumSize)
LENS(orthoScale)
LENS(renderRessources)
LENS(updaters)
LENS(gameData)
LENS(stateTree)

newAppData :: GD.Data -> AppData
newAppData gameData = AppData {
   windowSize       = (0,0),
   frustumSize      = (0,0),
   orthoScale       = DF.orthoScale,
   renderRessources = RR.Ressources (-1) (-1) (-1),
   updaters         = [],
   gameData         = gameData,
   stateTree        = SZ.zipper $ SS.root GR.mkGameRunningState
      [Branch {state     = ME.mkMovingEntityState,
               enterWhen = ByMouseWithMod GLFW.MouseButton0 Pressed Ctrl,
               leaveWhen = ByMouse GLFW.MouseButton0 Released,
               adjacents = []},
       Branch {state     = RP.mkResizingPlatformState,
               enterWhen = ByMouseWithMod GLFW.MouseButton0 Pressed Shift,
               leaveWhen = ByMouse GLFW.MouseButton0 Released,
               adjacents = []},
       Branch {state     = CP.mkCreatingPlatformState,
               enterWhen = ByMouse GLFW.MouseButton0 Pressed,
               leaveWhen = ByMouse GLFW.MouseButton0 Released,
               adjacents = []}]
   }

data AppMode = GameMode | EditMode deriving Eq

type AppDataRef = R.IORef AppData
type AppST      = ST.StateT AppDataRef IO


runAppST :: AppST a -> AppDataRef -> IO (a, AppDataRef)
runAppST = ST.runStateT

<commit_msg>Remove now unneeded updaters list<commit_after>
module AppData where
#include "Gamgine/Utils.cpp"
import qualified Graphics.UI.GLFW as GLFW
import qualified Data.IORef as R
import qualified Data.List as L
import Data.Maybe (fromMaybe)
import qualified Control.Monad.State as ST
import qualified Gamgine.Utils as GU
import qualified GameData.Data as GD
import qualified GameData.Level as LV
import qualified GameData.Entity as E
import qualified Rendering.Ressources as RR
import qualified Updater as UP
import qualified Defaults as DF
import qualified States.State as S
import qualified States.StateTree as SS
import States.StateTree (enterWhen, leaveWhen, adjacents, StateTree(..), StateTransition(..))
import States.StateTreeZipper as SZ
import qualified States.GameRunning as GR
import qualified States.MovingEntity as ME
import qualified States.CreatingPlatform as CP
import qualified States.ResizingPlatform as RP
import qualified States.KeyInfo as KI
import qualified States.MouseInfo as MI
import qualified States.InputInfo as II
import States.InputInfo (Modifier(..), InputState(..))
IMPORT_LENS

data AppData = AppData {
   windowSize       :: (Int, Int),
   frustumSize      :: (Double, Double),
   orthoScale       :: Double,
   renderRessources :: RR.Ressources,
   gameData         :: GD.Data,
   stateTree        :: SZ.Zipper GD.Data
   }

LENS(windowSize)
LENS(frustumSize)
LENS(orthoScale)
LENS(renderRessources)
LENS(gameData)
LENS(stateTree)

newAppData :: GD.Data -> AppData
newAppData gameData = AppData {
   windowSize       = (0,0),
   frustumSize      = (0,0),
   orthoScale       = DF.orthoScale,
   renderRessources = RR.Ressources (-1) (-1) (-1),
   gameData         = gameData,
   stateTree        = SZ.zipper $ SS.root GR.mkGameRunningState
      [Branch {state     = ME.mkMovingEntityState,
               enterWhen = ByMouseWithMod GLFW.MouseButton0 Pressed Ctrl,
               leaveWhen = ByMouse GLFW.MouseButton0 Released,
               adjacents = []},
       Branch {state     = RP.mkResizingPlatformState,
               enterWhen = ByMouseWithMod GLFW.MouseButton0 Pressed Shift,
               leaveWhen = ByMouse GLFW.MouseButton0 Released,
               adjacents = []},
       Branch {state     = CP.mkCreatingPlatformState,
               enterWhen = ByMouse GLFW.MouseButton0 Pressed,
               leaveWhen = ByMouse GLFW.MouseButton0 Released,
               adjacents = []}]
   }

data AppMode = GameMode | EditMode deriving Eq

type AppDataRef = R.IORef AppData
type AppST      = ST.StateT AppDataRef IO


runAppST :: AppST a -> AppDataRef -> IO (a, AppDataRef)
runAppST = ST.runStateT


{'fraction_non_alphanumeric': 0.07859281437125748, 'fraction_numerical': 0.0048652694610778445, 'mean_word_length': 3.1498447204968945, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3538145', 'n_tokens_mistral': 1612, 'n_tokens_neox': 1579, 'n_words': 477}