Unify config files, add capability to remember window position

This commit is contained in:
2021-10-29 19:35:54 +01:00
parent 4df03e59f5
commit 78f91e522b
14 changed files with 43 additions and 104 deletions
+4
View File
@@ -15,6 +15,8 @@ data Configuration = Configuration
, _resolution_factor :: Int -- ^ Higher values divide screen size, i.e. make the resolution worse
, _windowX :: Float
, _windowY :: Float
, _windowPosX :: Int
, _windowPosY :: Int
, _rotate_to_wall :: Bool
, _show_sound :: Bool
, _debug_seconds_frame :: Bool
@@ -41,6 +43,8 @@ defaultConfig = Configuration
, _resolution_factor = 1
, _windowX = 800
, _windowY = 600
, _windowPosX = 0
, _windowPosY = 0
, _rotate_to_wall = True
, _show_sound = False
, _debug_seconds_frame = True
+9
View File
@@ -42,6 +42,7 @@ handleEvent e = case eventPayload e of
MouseButtonEvent mbev -> handleMouseButtonEvent mbev
MouseWheelEvent mwev -> handleMouseWheelEvent mwev
WindowSizeChangedEvent sev -> handleResizeEvent sev
WindowMovedEvent mev -> handleWindowMoveEvent mev
_ -> Just
handleMouseMotionEvent :: MouseMotionEventData -> World -> Maybe World
@@ -58,6 +59,14 @@ handleMouseButtonEvent mbev w = case mouseButtonEventMotion mbev of
where
but = mouseButtonEventButton mbev
{- | Sets window position in config. -}
handleWindowMoveEvent :: WindowMovedEventData -> World -> Maybe World
handleWindowMoveEvent mev w = Just $ w
& config . windowPosX .~ fromIntegral x
& config . windowPosY .~ fromIntegral y
where
P (V2 x y) = windowMovedEventPosition mev
{- | Resets the world window size, and resizes the fbo that gets the light map drawn into it. -}
handleResizeEvent :: WindowSizeChangedEventData -> World -> Maybe World
handleResizeEvent sev w = Just