Commit towards merge
This commit is contained in:
+2
-1
@@ -174,7 +174,7 @@ data ScreenLayer
|
|||||||
, _scOptionFlag :: OptionScreenFlag
|
, _scOptionFlag :: OptionScreenFlag
|
||||||
}
|
}
|
||||||
| ColumnsScreen String [(String,String)]
|
| ColumnsScreen String [(String,String)]
|
||||||
| InputScreen String
|
| InputScreen String String
|
||||||
| WaitScreen
|
| WaitScreen
|
||||||
{ _scWaitMessage :: Universe -> String
|
{ _scWaitMessage :: Universe -> String
|
||||||
, _scWaitTime :: Int
|
, _scWaitTime :: Int
|
||||||
@@ -616,6 +616,7 @@ data ItemParams
|
|||||||
, _shellThrustDelay :: Int
|
, _shellThrustDelay :: Int
|
||||||
}
|
}
|
||||||
| Refracting {_phaseV :: Float}
|
| Refracting {_phaseV :: Float}
|
||||||
|
| Traction {_power :: Point2}
|
||||||
| BulletShooter -- this should possibly be moved into ammo type
|
| BulletShooter -- this should possibly be moved into ammo type
|
||||||
{ _muzVel :: Float
|
{ _muzVel :: Float
|
||||||
, _rifling :: Float
|
, _rifling :: Float
|
||||||
|
|||||||
+114
-1
@@ -1,14 +1,32 @@
|
|||||||
module Dodge.Debug.Terminal
|
module Dodge.Debug.Terminal
|
||||||
|
<<<<<<< HEAD
|
||||||
( applyTerminalString
|
( applyTerminalString
|
||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Creature
|
import Dodge.Creature
|
||||||
import Dodge.Creature.YourControl
|
import Dodge.Creature.YourControl
|
||||||
import Dodge.Creature.State
|
import Dodge.Creature.State
|
||||||
|
=======
|
||||||
|
where
|
||||||
|
import Dodge.Creature
|
||||||
|
import Dodge.Creature.State
|
||||||
|
import Dodge.Creature.YourControl
|
||||||
|
import Dodge.Data
|
||||||
|
import Dodge.Menu.PushPop
|
||||||
|
import Control.Monad
|
||||||
|
>>>>>>> ross/loop-master
|
||||||
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
|
import Text.Read (readMaybe)
|
||||||
|
import Data.List (isPrefixOf, isInfixOf, intercalate)
|
||||||
|
import Data.Maybe (fromJust)
|
||||||
|
import LensHelp
|
||||||
|
import qualified Debug.Trace
|
||||||
|
import Graphics.Rendering.OpenGL.GL.Shaders (validateProgram)
|
||||||
|
import Dodge.Data (Universe(Universe))
|
||||||
|
|
||||||
applyTerminalString :: String -> Universe -> Universe
|
applyTerminalString :: String -> Universe -> Universe
|
||||||
|
<<<<<<< HEAD
|
||||||
applyTerminalString str = case str of
|
applyTerminalString str = case str of
|
||||||
"NOCLIP" -> config . debug_noclip %~ not
|
"NOCLIP" -> config . debug_noclip %~ not
|
||||||
"LOADME" -> (uvWorld . creatures . ix 0 . crInv .~ stackedInventory)
|
"LOADME" -> (uvWorld . creatures . ix 0 . crInv .~ stackedInventory)
|
||||||
@@ -23,3 +41,98 @@ applyTerminalString str = case str of
|
|||||||
|
|
||||||
loadme :: a -> a
|
loadme :: a -> a
|
||||||
loadme = id
|
loadme = id
|
||||||
|
=======
|
||||||
|
applyTerminalString "NOCLIP" = config . debug_noclip %~ not
|
||||||
|
applyTerminalString "LOADME" = (uvWorld . creatures . ix 0 . crInv .~ stackedInventory)
|
||||||
|
. (uvWorld . creatures . ix 0 . crInvCapacity .~ 50)
|
||||||
|
applyTerminalString "GODON" =
|
||||||
|
uvWorld . creatures . ix 0 . crUpdate .~ stateUpdateDamage clearDamage yourControl
|
||||||
|
applyTerminalString "GODOFF" = uvWorld . creatures . ix 0 . crUpdate .~ stateUpdate yourControl
|
||||||
|
applyTerminalString "LOADTEST" = (uvWorld . creatures . ix 0 . crInv .~ testInventory)
|
||||||
|
. (uvWorld . creatures . ix 0 . crInvCapacity .~ 50)
|
||||||
|
applyTerminalString "LM" = applyTerminalString "LOADME"
|
||||||
|
applyTerminalString "LT" = applyTerminalString "LOADTEST"
|
||||||
|
applyTerminalString ('s': 'e': 't': '_': 'h': 'p': ' ': hp)
|
||||||
|
| (readMaybe hp :: Maybe Int) == Nothing = id
|
||||||
|
| otherwise = uvWorld . creatures . ix 0 . crHP .~ read hp
|
||||||
|
applyTerminalString ('s': 'e': 't': '_': 'i': 'n': 'v': 'c': 'a': 'p': ' ': n)
|
||||||
|
| (readMaybe n :: Maybe Int) == Nothing = id
|
||||||
|
| otherwise = (uvWorld . creatures . ix 0 . crInvCapacity .~ read n)
|
||||||
|
applyTerminalString ('s': 'e': 't': ' ': var)
|
||||||
|
| var /= [] = applySetTerminalString var
|
||||||
|
| otherwise = id
|
||||||
|
applyTerminalString ('g': 'o': 'd': ' ': var)
|
||||||
|
| var == "on" = applyTerminalString "GODON"
|
||||||
|
| var == "off" = applySetTerminalString "GODOFF"
|
||||||
|
| otherwise = showTerminalError ("god "++var) ("Invalid god argument: " ++ var)
|
||||||
|
applyTerminalString ('s': 'p': 'a': 'w': 'n': ' ': var)
|
||||||
|
| var /= [] = id -- work out how to spawn stuff
|
||||||
|
| otherwise = id
|
||||||
|
applyTerminalString _ = id
|
||||||
|
|
||||||
|
showTerminalError :: String -> String -> Universe -> Universe
|
||||||
|
showTerminalError cmd s = menuLayers .:~ InputScreen cmd s
|
||||||
|
|
||||||
|
applySetTerminalString :: String -> Universe -> Universe
|
||||||
|
applySetTerminalString [] = id
|
||||||
|
applySetTerminalString var = case key' of
|
||||||
|
"" -> showTerminalError ("set "++var) ("Unable to read as argument as float: " ++ val)
|
||||||
|
"hp" -> uvWorld . creatures . ix 0 . crHP .~ round (fromJust val')
|
||||||
|
"invcap" -> uvWorld . creatures . ix 0 . crInvCapacity .~ round (fromJust val')
|
||||||
|
"invsel" -> uvWorld . creatures . ix 0 . crInvSel .~ round (fromJust val')
|
||||||
|
"mass" -> uvWorld . creatures . ix 0 . crMass .~ fromJust val'
|
||||||
|
"mvspeed" -> uvWorld . creatures . ix 0 . crMvType .mvSpeed .~ fromJust val'
|
||||||
|
_ -> showTerminalError ("set "++var) ("Invalid set command: " ++ key) -- never reached?
|
||||||
|
where
|
||||||
|
(key, val) = getSplitString var
|
||||||
|
val' = readMaybe val :: Maybe Float
|
||||||
|
key' = if val' == Nothing then "" else key
|
||||||
|
|
||||||
|
autoCompleteTerminal :: String -> String -> Universe -> IO (Maybe Universe)
|
||||||
|
autoCompleteTerminal s help = return . (popScreen' >=> pushScreen' (InputScreen input_str valid_commands))
|
||||||
|
where
|
||||||
|
(key, val) = getSplitString $ tail s
|
||||||
|
command_options = case val of
|
||||||
|
"" -> filter (isInfixOf key) (validTerminalCommands "")
|
||||||
|
_ -> filter (isInfixOf val) (validTerminalCommands key)
|
||||||
|
-- basic autocomplete if single option available (or as far as possible)
|
||||||
|
input_str = case (key, val) of
|
||||||
|
(_, "") -> if length command_options == 1 then ">" ++ head command_options ++ " " else ">" ++ longestCommonPrefix command_options
|
||||||
|
_ -> if length command_options == 1 then ">" ++ key ++ " " ++ head command_options ++ " " else if null command_options then s else ">" ++ key ++ " " ++ longestCommonPrefix command_options
|
||||||
|
|
||||||
|
command_options' = if length command_options > 0 && head command_options == key then validTerminalCommands key else command_options
|
||||||
|
|
||||||
|
--val' = Debug.Trace.trace key tail val
|
||||||
|
valid_commands = "Options: " ++ intercalate ", " command_options'
|
||||||
|
|
||||||
|
getSplitString :: [Char] -> ([Char], [Char])
|
||||||
|
getSplitString str = case break (==' ') str of
|
||||||
|
(a, _:b) -> (a, b)
|
||||||
|
(a, _) -> (a, "")
|
||||||
|
|
||||||
|
isValidCommand :: String -> String -> Bool
|
||||||
|
isValidCommand arg1 arg2
|
||||||
|
| arg2 `elem` v = True
|
||||||
|
| otherwise = False
|
||||||
|
where
|
||||||
|
v = validTerminalCommands arg1
|
||||||
|
|
||||||
|
|
||||||
|
validTerminalCommands :: String -> [String]
|
||||||
|
validTerminalCommands "set" = ["hp", "invcap", "invsel", "mass", "mvspeed"]
|
||||||
|
validTerminalCommands "god" = ["on", "off"]
|
||||||
|
validTerminalCommands _ = ["set", "spawn", "god"]
|
||||||
|
|
||||||
|
|
||||||
|
loadme :: a
|
||||||
|
loadme = undefined
|
||||||
|
|
||||||
|
longestCommonPrefix :: Eq a => [[a]] -> [a]
|
||||||
|
longestCommonPrefix [] = []
|
||||||
|
longestCommonPrefix lists = foldr1 commonPrefix lists
|
||||||
|
|
||||||
|
commonPrefix :: Eq a => [a] -> [a] -> [a]
|
||||||
|
commonPrefix (x:xs) (y:ys)
|
||||||
|
| x == y = x : commonPrefix xs ys
|
||||||
|
commonPrefix _ _ = []
|
||||||
|
>>>>>>> ross/loop-master
|
||||||
|
|||||||
+30
-29
@@ -9,59 +9,60 @@ We cannot handle multiple keys held down at once here,
|
|||||||
because these are separate events.
|
because these are separate events.
|
||||||
Instead we store the events in a set, and deal with the combinations in
|
Instead we store the events in a set, and deal with the combinations in
|
||||||
"Dodge.Update". -}
|
"Dodge.Update". -}
|
||||||
module Dodge.Event
|
module Dodge.Event
|
||||||
( handleEvent
|
( handleEvent
|
||||||
) where
|
) where
|
||||||
import Dodge.Event.Keyboard
|
import Dodge.Combine
|
||||||
import Dodge.Combine
|
import Dodge.Event.Keyboard
|
||||||
--import Dodge.Event.Menu
|
--import Dodge.Event.Menu
|
||||||
import Dodge.Data
|
import Dodge.Base
|
||||||
import Dodge.Base
|
import Dodge.Data
|
||||||
--import Dodge.Base.Window
|
--import Dodge.Base.Window
|
||||||
import Dodge.PreloadData
|
import Dodge.PreloadData
|
||||||
--import Dodge.Creature.Action
|
--import Dodge.Creature.Action
|
||||||
import Dodge.SoundLogic
|
import Dodge.Inventory
|
||||||
import Dodge.Inventory
|
import Dodge.Inventory.Add
|
||||||
import Dodge.Inventory.Add
|
import Dodge.SoundLogic
|
||||||
--import Geometry
|
--import Geometry
|
||||||
--import Preload.Update
|
--import Preload.Update
|
||||||
import qualified IntMapHelp as IM
|
import Dodge.FloorItem
|
||||||
import ListHelp
|
import qualified IntMapHelp as IM
|
||||||
import Dodge.FloorItem
|
import ListHelp
|
||||||
|
|
||||||
--import Data.Monoid
|
--import Data.Monoid
|
||||||
import Data.Maybe
|
import Control.Lens
|
||||||
import Control.Lens
|
import Data.Maybe
|
||||||
--import Data.Maybe
|
--import Data.Maybe
|
||||||
--import Data.Char
|
--import Data.Char
|
||||||
--import Data.List
|
--import Data.List
|
||||||
--import Data.Function (on)
|
--import Data.Function (on)
|
||||||
import qualified Data.Set as S
|
import qualified Data.Set as S
|
||||||
import SDL
|
import SDL
|
||||||
|
|
||||||
handleEvent :: Event -> Universe -> IO (Maybe Universe)
|
handleEvent :: Event -> Universe -> IO (Maybe Universe)
|
||||||
handleEvent e = case eventPayload e of
|
handleEvent e = case eventPayload e of
|
||||||
KeyboardEvent kev -> handleKeyboardEvent kev
|
TextInputEvent tev -> handleTextInputEvent tev
|
||||||
MouseMotionEvent mmev -> return . handleMouseMotionEvent mmev
|
KeyboardEvent kev -> handleKeyboardEvent kev
|
||||||
MouseButtonEvent mbev -> return . handleMouseButtonEvent mbev
|
MouseMotionEvent mmev -> return . handleMouseMotionEvent mmev
|
||||||
MouseWheelEvent mwev -> return . handleMouseWheelEvent mwev
|
MouseButtonEvent mbev -> return . handleMouseButtonEvent mbev
|
||||||
WindowSizeChangedEvent sev -> handleResizeEvent sev
|
MouseWheelEvent mwev -> return . handleMouseWheelEvent mwev
|
||||||
WindowMovedEvent mev -> return . handleWindowMoveEvent mev
|
WindowSizeChangedEvent sev -> handleResizeEvent sev
|
||||||
_ -> return . Just
|
WindowMovedEvent mev -> return . handleWindowMoveEvent mev
|
||||||
|
_ -> return . Just
|
||||||
|
|
||||||
handleMouseMotionEvent :: MouseMotionEventData -> Universe -> Maybe Universe
|
handleMouseMotionEvent :: MouseMotionEventData -> Universe -> Maybe Universe
|
||||||
handleMouseMotionEvent mmev u = Just $ u & uvWorld . mousePos .~ V2
|
handleMouseMotionEvent mmev u = Just $ u & uvWorld . mousePos .~ V2
|
||||||
(fromIntegral x - 0.5*_windowX cfig)
|
(fromIntegral x - 0.5*_windowX cfig)
|
||||||
(0.5*_windowY cfig - fromIntegral y)
|
(0.5*_windowY cfig - fromIntegral y)
|
||||||
where
|
where
|
||||||
cfig = _config u
|
cfig = _config u
|
||||||
P (V2 x y) = mouseMotionEventPos mmev
|
P (V2 x y) = mouseMotionEventPos mmev
|
||||||
|
|
||||||
handleMouseButtonEvent :: MouseButtonEventData -> Universe -> Maybe Universe
|
handleMouseButtonEvent :: MouseButtonEventData -> Universe -> Maybe Universe
|
||||||
handleMouseButtonEvent mbev = case mouseButtonEventMotion mbev of
|
handleMouseButtonEvent mbev = case mouseButtonEventMotion mbev of
|
||||||
Released -> Just . updateButtons S.delete
|
Released -> Just . updateButtons S.delete
|
||||||
Pressed -> handlePressedMouseButton thebutton . updateButtons S.insert
|
Pressed -> handlePressedMouseButton thebutton . updateButtons S.insert
|
||||||
where
|
where
|
||||||
thebutton = mouseButtonEventButton mbev
|
thebutton = mouseButtonEventButton mbev
|
||||||
updateButtons f = uvWorld . mouseButtons %~ f thebutton
|
updateButtons f = uvWorld . mouseButtons %~ f thebutton
|
||||||
|
|
||||||
@@ -81,7 +82,7 @@ handleResizeEvent sev u = return . Just $ u
|
|||||||
& config . windowX .~ fromIntegral x
|
& config . windowX .~ fromIntegral x
|
||||||
& config . windowY .~ fromIntegral y
|
& config . windowY .~ fromIntegral y
|
||||||
& uvWorld . sideEffects %~ sideEffectUpdatePreload divRes x y
|
& uvWorld . sideEffects %~ sideEffectUpdatePreload divRes x y
|
||||||
where
|
where
|
||||||
x = fromIntegral x'
|
x = fromIntegral x'
|
||||||
y = fromIntegral y'
|
y = fromIntegral y'
|
||||||
V2 x' y' = windowSizeChangedEventSize sev
|
V2 x' y' = windowSizeChangedEventSize sev
|
||||||
@@ -136,7 +137,7 @@ wheelEvent y w = case _hudElement $ _hud w of
|
|||||||
| invKeyDown -> stopSoundFrom (CrReloadSound 0) $ changeInvSel yi w
|
| invKeyDown -> stopSoundFrom (CrReloadSound 0) $ changeInvSel yi w
|
||||||
| rbDown -> w & changeTweakParam yi
|
| rbDown -> w & changeTweakParam yi
|
||||||
| otherwise -> w & moveTweakSel yi
|
| otherwise -> w & moveTweakSel yi
|
||||||
DisplayInventory (CombineInventory _) -> w
|
DisplayInventory (CombineInventory _) -> w
|
||||||
& hud . hudElement . subInventory . combineInvSel . _Just %~ ((`mod` numcombs) . subtract yi)
|
& hud . hudElement . subInventory . combineInvSel . _Just %~ ((`mod` numcombs) . subtract yi)
|
||||||
_ -> w
|
_ -> w
|
||||||
where
|
where
|
||||||
@@ -165,7 +166,7 @@ moveTweakSel i w = case yourItem w ^? _Just . itTweaks . tweakParams of
|
|||||||
. itTweaks . tweakSel %~ (`mod` length l) . subtract i
|
. itTweaks . tweakSel %~ (`mod` length l) . subtract i
|
||||||
_ -> w
|
_ -> w
|
||||||
changeTweakParam :: Int -> World -> World
|
changeTweakParam :: Int -> World -> World
|
||||||
changeTweakParam i w = w
|
changeTweakParam i w = w
|
||||||
& creatures . ix (_yourID w) . crInv . ix (_crInvSel (you w)) %~
|
& creatures . ix (_yourID w) . crInv . ix (_crInvSel (you w)) %~
|
||||||
( (itTweaks . tweakParams . ix paramid . curTweak .~ x)
|
( (itTweaks . tweakParams . ix paramid . curTweak .~ x)
|
||||||
. _doTweak params x)
|
. _doTweak params x)
|
||||||
|
|||||||
+45
-32
@@ -1,23 +1,35 @@
|
|||||||
{- | Deals with keyboard events. -}
|
{- | Deals with keyboard events. -}
|
||||||
module Dodge.Event.Keyboard
|
module Dodge.Event.Keyboard
|
||||||
( handleKeyboardEvent
|
( handleKeyboardEvent
|
||||||
|
, handleTextInputEvent
|
||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import qualified Data.IntMap.Strict as IM
|
||||||
import Dodge.Combine
|
import Dodge.Base
|
||||||
import Dodge.Save
|
import Dodge.Combine
|
||||||
import Dodge.Base
|
import Dodge.Creature.Action
|
||||||
import Dodge.Reloading
|
import Dodge.Data
|
||||||
import Dodge.Creature.Action
|
import Dodge.Event.Menu
|
||||||
import Dodge.Event.Test
|
import Dodge.Event.Test
|
||||||
import Dodge.Event.Menu
|
import Dodge.Inventory
|
||||||
import Dodge.Menu
|
import Dodge.Menu
|
||||||
import Dodge.Inventory
|
import Dodge.Reloading
|
||||||
import qualified Data.IntMap.Strict as IM
|
import Dodge.Save
|
||||||
|
|
||||||
import SDL
|
import Control.Lens
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import qualified Data.Set as S
|
import qualified Data.Set as S
|
||||||
import Control.Lens
|
import SDL
|
||||||
|
import Data.Text (unpack)
|
||||||
|
|
||||||
|
handleTextInputEvent :: TextInputEventData -> Universe -> IO (Maybe Universe)
|
||||||
|
handleTextInputEvent tev = handleTextInput text
|
||||||
|
where
|
||||||
|
text = unpack $ textInputEventText tev
|
||||||
|
|
||||||
|
handleTextInput :: String -> Universe -> IO (Maybe Universe)
|
||||||
|
handleTextInput text w
|
||||||
|
| null (_menuLayers w) = return $ Just w
|
||||||
|
| otherwise = handleTextInMenu (head $ _menuLayers w) text w
|
||||||
|
|
||||||
{- | Handles keyboard press and release.
|
{- | Handles keyboard press and release.
|
||||||
On release, remove scancode from the 'Set' of pressed keys.
|
On release, remove scancode from the 'Set' of pressed keys.
|
||||||
@@ -26,20 +38,21 @@ see 'handlePressedKeyInGame'.
|
|||||||
-}
|
-}
|
||||||
handleKeyboardEvent :: KeyboardEventData -> Universe -> IO (Maybe Universe)
|
handleKeyboardEvent :: KeyboardEventData -> Universe -> IO (Maybe Universe)
|
||||||
handleKeyboardEvent kev u = case keyboardEventKeyMotion kev of
|
handleKeyboardEvent kev u = case keyboardEventKeyMotion kev of
|
||||||
Released -> return . Just $ u & uvWorld . keys %~ S.delete kcode
|
Released -> return . Just $ u & uvWorld . keys %~ S.delete scode
|
||||||
Pressed -> handlePressedKey (keyboardEventRepeat kev) kcode
|
Pressed -> handlePressedKey (keyboardEventRepeat kev) scode
|
||||||
(u & uvWorld . keys %~ S.insert kcode)
|
(u & uvWorld . keys %~ S.insert scode)
|
||||||
where
|
where
|
||||||
kcode = (keysymScancode . keyboardEventKeysym) kev
|
scode = (keysymScancode . keyboardEventKeysym) kev
|
||||||
|
|
||||||
handlePressedKey :: Bool -> Scancode -> Universe -> IO (Maybe Universe)
|
handlePressedKey :: Bool -> Scancode -> Universe -> IO (Maybe Universe)
|
||||||
handlePressedKey True _ w = return $ Just w
|
handlePressedKey True _ w = return $ Just w
|
||||||
handlePressedKey _ ScancodeF5 w = return . Just $ doQuicksave w
|
handlePressedKey _ ScancodeF5 w = return . Just $ doQuicksave w
|
||||||
handlePressedKey _ ScancodeF9 w = return . Just $ loadSaveSlot QuicksaveSlot w
|
handlePressedKey _ ScancodeF9 w = return . Just $ loadSaveSlot QuicksaveSlot w
|
||||||
handlePressedKey _ ScancodeSemicolon w = return . Just $ gotoTerminal w
|
handlePressedKey _ ScancodeSemicolon w = return . Just $ gotoTerminal w
|
||||||
handlePressedKey _ scode w
|
handlePressedKey _ scode w
|
||||||
| null (_menuLayers w) = return $ uvWorld (handlePressedKeyInGame scode) w
|
| null (_menuLayers w) = return $ uvWorld (handlePressedKeyInGame scode) w
|
||||||
| otherwise = handlePressedKeyInMenu (head $ _menuLayers w) scode w
|
| otherwise = handlePressedKeyInMenu (head $ _menuLayers w) scode w
|
||||||
|
-- | otherwise = return $ Just w
|
||||||
|
|
||||||
handlePressedKeyInGame :: Scancode -> World -> Maybe World
|
handlePressedKeyInGame :: Scancode -> World -> Maybe World
|
||||||
handlePressedKeyInGame scode w = case scode of
|
handlePressedKeyInGame scode w = case scode of
|
||||||
@@ -67,8 +80,8 @@ toggleInspectInv he = case he of
|
|||||||
|
|
||||||
gotoTerminal :: Universe -> Universe
|
gotoTerminal :: Universe -> Universe
|
||||||
gotoTerminal w = case _menuLayers w of
|
gotoTerminal w = case _menuLayers w of
|
||||||
(InputScreen _ : _ ) -> w
|
(InputScreen _ _ : _ ) -> w
|
||||||
_ -> w & menuLayers %~ (InputScreen [] :)
|
_ -> w & menuLayers %~ (InputScreen [] "Enter command" :)
|
||||||
|
|
||||||
spaceAction :: World -> World
|
spaceAction :: World -> World
|
||||||
spaceAction w = case _hudElement $ _hud w of
|
spaceAction w = case _hudElement $ _hud w of
|
||||||
@@ -76,21 +89,21 @@ spaceAction w = case _hudElement $ _hud w of
|
|||||||
DisplayInventory NoSubInventory -> case selectedCloseObject w of
|
DisplayInventory NoSubInventory -> case selectedCloseObject w of
|
||||||
Just (_,Left flit) -> pickUpItem 0 flit w
|
Just (_,Left flit) -> pickUpItem 0 flit w
|
||||||
Just (_,Right but) -> _btEvent but but w
|
Just (_,Right but) -> _btEvent but but w
|
||||||
_ -> w
|
_ -> w
|
||||||
DisplayInventory DisplayTerminal {} -> w & hud . hudElement .~ DisplayInventory NoSubInventory
|
DisplayInventory DisplayTerminal {} -> w & hud . hudElement .~ DisplayInventory NoSubInventory
|
||||||
_ -> w & hud . hudElement .~ DisplayInventory NoSubInventory
|
_ -> w & hud . hudElement .~ DisplayInventory NoSubInventory
|
||||||
where
|
where
|
||||||
theLoc = fst (_seenLocations w IM.! _selLocation w) w
|
theLoc = fst (_seenLocations w IM.! _selLocation w) w
|
||||||
-- updateTopCloseObject i w' = w' & closeObjects %~ ( Right (_buttons w' IM.! i) : ) . tail
|
-- updateTopCloseObject i w' = w' & closeObjects %~ ( Right (_buttons w' IM.! i) : ) . tail
|
||||||
|
|
||||||
pauseGame :: World -> World
|
pauseGame :: World -> World
|
||||||
pauseGame w = w & sideEffects %~ (. (menuLayers .~ [pauseMenu]))
|
pauseGame w = w & sideEffects %~ (. (menuLayers .~ [pauseMenu]))
|
||||||
|
|
||||||
toggleMap :: World -> World
|
toggleMap :: World -> World
|
||||||
toggleMap w = case _hudElement $ _hud w of
|
toggleMap w = case _hudElement $ _hud w of
|
||||||
DisplayCarte -> w & hud . hudElement .~ DisplayInventory NoSubInventory
|
DisplayCarte -> w & hud . hudElement .~ DisplayInventory NoSubInventory
|
||||||
_ -> w & hud . hudElement .~ DisplayCarte
|
_ -> w & hud . hudElement .~ DisplayCarte
|
||||||
escapeMap :: World -> World
|
escapeMap :: World -> World
|
||||||
escapeMap w = case _hudElement $ _hud w of
|
escapeMap w = case _hudElement $ _hud w of
|
||||||
DisplayCarte -> w & hud . hudElement .~ DisplayInventory NoSubInventory
|
DisplayCarte -> w & hud . hudElement .~ DisplayInventory NoSubInventory
|
||||||
_ -> w
|
_ -> w
|
||||||
|
|||||||
+32
-12
@@ -1,6 +1,7 @@
|
|||||||
module Dodge.Event.Menu
|
module Dodge.Event.Menu
|
||||||
( handlePressedKeyInMenu
|
( handlePressedKeyInMenu
|
||||||
)
|
, handleTextInMenu
|
||||||
|
)
|
||||||
where
|
where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Debug.Terminal
|
import Dodge.Debug.Terminal
|
||||||
@@ -11,25 +12,44 @@ import Data.Maybe
|
|||||||
import Control.Monad
|
import Control.Monad
|
||||||
--import Control.Lens
|
--import Control.Lens
|
||||||
import SDL
|
import SDL
|
||||||
|
import Control.Lens ((%~))
|
||||||
|
import qualified Debug.Trace
|
||||||
|
|
||||||
|
|
||||||
|
handleTextInMenu :: ScreenLayer -> [Char] -> Universe -> IO (Maybe Universe)
|
||||||
|
handleTextInMenu mState text = case mState of
|
||||||
|
InputScreen s help-> return . (popScreen' >=> pushScreen' (InputScreen new_text help))
|
||||||
|
where
|
||||||
|
new_text
|
||||||
|
-- Text events occur after key events so ignore the first
|
||||||
|
-- (key that opened the terminal menu)
|
||||||
|
| s == "" = ">"
|
||||||
|
| otherwise = s ++ text
|
||||||
|
_ -> return . Just
|
||||||
|
|
||||||
|
|
||||||
handlePressedKeyInMenu :: ScreenLayer -> Scancode -> Universe -> IO (Maybe Universe)
|
handlePressedKeyInMenu :: ScreenLayer -> Scancode -> Universe -> IO (Maybe Universe)
|
||||||
handlePressedKeyInMenu mState scode = case mState of
|
handlePressedKeyInMenu mState scode = case mState of
|
||||||
OptionScreen { _scOptions = mos, _scDefaultEff = defeff}
|
OptionScreen { _scOptions = mos, _scDefaultEff = defeff}
|
||||||
-> optionListToEffects mos defeff scode
|
-> optionListToEffects mos defeff scode
|
||||||
DisplayScreen {} -> popScreen
|
DisplayScreen {} -> popScreen
|
||||||
ColumnsScreen {} -> popScreen
|
ColumnsScreen {} -> popScreen
|
||||||
WaitScreen {} -> return . Just
|
WaitScreen {} -> return . Just
|
||||||
InputScreen s -> case scode of
|
InputScreen s help -> case scode of
|
||||||
ScancodeEscape -> popScreen
|
ScancodeEscape -> popScreen
|
||||||
ScancodeReturn -> popScreen . applyTerminalString s
|
-- Remove the menu layer (we readd it in applyTerminalString if the commmand fails)
|
||||||
ScancodeBackspace
|
ScancodeReturn -> return. Just . applyTerminalString (tail s) . (menuLayers %~ tail)
|
||||||
-> return . (popScreen' >=> pushScreen' (InputScreen $ dropLast s))
|
ScancodeTab -> autoCompleteTerminal s help
|
||||||
_ -> return . (popScreen' >=> pushScreen' (InputScreen $ s ++ [scodeToChar scode]))
|
ScancodeBackspace
|
||||||
where
|
-> return . (popScreen' >=> pushScreen' (InputScreen (dropLast s) "Enter command"))
|
||||||
|
-- Ignore (text input now handled by handleText)
|
||||||
|
_ -> return . (popScreen' >=> pushScreen' (InputScreen s help))
|
||||||
|
where
|
||||||
|
dropLast [x] = ['>']
|
||||||
dropLast (x:xs) = init (x:xs)
|
dropLast (x:xs) = init (x:xs)
|
||||||
dropLast _ = []
|
dropLast _ = ['>']
|
||||||
|
|
||||||
optionListToEffects :: [MenuOption] -> (Universe -> IO (Maybe Universe)) -> Scancode
|
optionListToEffects :: [MenuOption] -> (Universe -> IO (Maybe Universe)) -> Scancode
|
||||||
-> Universe -> IO (Maybe Universe)
|
-> Universe -> IO (Maybe Universe)
|
||||||
optionListToEffects mos defaulteff sc = fromMaybe defaulteff .
|
optionListToEffects mos defaulteff sc = fromMaybe defaulteff .
|
||||||
lookup sc $ concatMap menuOptionToEffects mos
|
lookup sc $ concatMap menuOptionToEffects mos
|
||||||
@@ -37,9 +57,9 @@ optionListToEffects mos defaulteff sc = fromMaybe defaulteff .
|
|||||||
menuOptionToEffects :: MenuOption -> [(Scancode,Universe -> IO (Maybe Universe))]
|
menuOptionToEffects :: MenuOption -> [(Scancode,Universe -> IO (Maybe Universe))]
|
||||||
menuOptionToEffects Toggle {_moKey = k, _moEff = eff} = [(k,eff)]
|
menuOptionToEffects Toggle {_moKey = k, _moEff = eff} = [(k,eff)]
|
||||||
menuOptionToEffects InvisibleToggle {_moKey = k, _moEff = eff} = [(k,eff)]
|
menuOptionToEffects InvisibleToggle {_moKey = k, _moEff = eff} = [(k,eff)]
|
||||||
menuOptionToEffects Toggle2
|
menuOptionToEffects Toggle2
|
||||||
{ _moKey1 = k1
|
{ _moKey1 = k1
|
||||||
, _moEff1 = eff1
|
, _moEff1 = eff1
|
||||||
, _moKey2 = k2
|
, _moKey2 = k2
|
||||||
, _moEff2 = eff2
|
, _moEff2 = eff2
|
||||||
} = [(k1,eff1) , (k2,eff2)]
|
} = [(k1,eff1) , (k2,eff2)]
|
||||||
|
|||||||
@@ -145,7 +145,49 @@ tractorGun = lasGun
|
|||||||
& useAim . aimSpeed .~ 0.4
|
& useAim . aimSpeed .~ 0.4
|
||||||
& useAim . aimRange .~ 1
|
& useAim . aimRange .~ 1
|
||||||
& useAim . aimStance .~ TwoHandTwist
|
& useAim . aimStance .~ TwoHandTwist
|
||||||
|
, _itDimension = ItemDimension
|
||||||
|
{ _dimRad = 10
|
||||||
|
, _dimCenter = V3 15 0 0
|
||||||
|
, _dimPortage = HeldItem 5 30
|
||||||
|
, _dimSPic = tractorGunPic
|
||||||
|
}
|
||||||
|
, _itParams = Traction {_power = 1}
|
||||||
|
, _itTweaks = Tweakable
|
||||||
|
{ _tweakParams = IM.fromList [(0,tractorGunTweak)]
|
||||||
|
, _tweakSel = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
tractorGunTweak :: TweakParam
|
||||||
|
tractorGunTweak = TweakParam
|
||||||
|
{ _doTweak = thetweak
|
||||||
|
, _curTweak = 1
|
||||||
|
, _maxTweak = 4
|
||||||
|
, _showTweak = showPower
|
||||||
|
, _nameTweak = "TRACTION POWER"
|
||||||
|
}
|
||||||
|
where
|
||||||
|
thetweak 0 = itParams . power .~ 1
|
||||||
|
thetweak 1 = itParams . power .~ -1
|
||||||
|
thetweak 2 = itParams . power .~ -10
|
||||||
|
thetweak 3 = itParams . power .~ 0
|
||||||
|
thetweak _ = id
|
||||||
|
showPower 0 = "+"
|
||||||
|
showPower 1 = "-"
|
||||||
|
showPower 2 = "#"
|
||||||
|
showPower 3 = "0" -- object should stay in the center of the beam
|
||||||
|
showPower i = "THIS SHOULD NOT BE POSSIBLE" ++ show i
|
||||||
|
|
||||||
|
tractorGunPic :: Item -> SPic
|
||||||
|
tractorGunPic it =
|
||||||
|
( colorSH red $
|
||||||
|
upperPrismPoly 4 (rectNESW 3 30 1 0)
|
||||||
|
<> upperPrismPoly 4 (rectNESW (-1) 30 (-3) 0)
|
||||||
|
<> upperPrismPoly 1 (rectNESW 3 30 (-3) 0)
|
||||||
|
, setLayer 1 . color col . setDepth 1.1 . polygon $ rectNESW 1 30 (-1) 0
|
||||||
|
)
|
||||||
|
where
|
||||||
|
amFrac = fractionLoadedAmmo it
|
||||||
|
col = brightX 2 1.5 $ mixColors amFrac (1-amFrac) green red
|
||||||
|
|
||||||
aTeslaArc :: Creature -> World -> World
|
aTeslaArc :: Creature -> World -> World
|
||||||
aTeslaArc cr w = set randGen g w
|
aTeslaArc cr w = set randGen g w
|
||||||
@@ -191,7 +233,7 @@ mvLaser phasev pos dir w pt
|
|||||||
]
|
]
|
||||||
|
|
||||||
aTractorBeam :: Item -> Creature -> World -> World
|
aTractorBeam :: Item -> Creature -> World -> World
|
||||||
aTractorBeam _ cr w = w & props . at i ?~ tractorBeamAt i spos outpos dir
|
aTractorBeam _ cr w = w & props . at i ?~ tractorBeamAt i spos outpos dir power
|
||||||
where
|
where
|
||||||
i = newProjectileKey w
|
i = newProjectileKey w
|
||||||
cpos = _crPos cr
|
cpos = _crPos cr
|
||||||
@@ -200,9 +242,10 @@ aTractorBeam _ cr w = w & props . at i ?~ tractorBeamAt i spos outpos dir
|
|||||||
dir = _crDir cr
|
dir = _crDir cr
|
||||||
outpos = collidePointWalls cpos xpos
|
outpos = collidePointWalls cpos xpos
|
||||||
$ wallsAlongLine cpos xpos w
|
$ wallsAlongLine cpos xpos w
|
||||||
|
power = _power . _itParams $ _crInv cr IM.! _crInvSel cr
|
||||||
|
|
||||||
tractorBeamAt :: Int -> Point2 -> Point2 -> Float -> Prop
|
tractorBeamAt :: Int -> Point2 -> Point2 -> Float -> Point2 -> Prop
|
||||||
tractorBeamAt i pos outpos dir = ProjectileTimed
|
tractorBeamAt i pos outpos dir power = ProjectileTimed
|
||||||
{ _pjPos = pos
|
{ _pjPos = pos
|
||||||
, _pjStartPos = outpos
|
, _pjStartPos = outpos
|
||||||
, _pjVel = d
|
, _pjVel = d
|
||||||
@@ -212,7 +255,7 @@ tractorBeamAt i pos outpos dir = ProjectileTimed
|
|||||||
, _pjTime = 10
|
, _pjTime = 10
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
d = unitVectorAtAngle dir
|
d = unitVectorAtAngle dir * power
|
||||||
{- |
|
{- |
|
||||||
The interaction of this with objects, walls etc needs more thought. -}
|
The interaction of this with objects, walls etc needs more thought. -}
|
||||||
updateTractor :: Prop -> World -> World
|
updateTractor :: Prop -> World -> World
|
||||||
|
|||||||
+10
-9
@@ -52,7 +52,7 @@ trySeedFromClipboard :: Universe -> IO (Maybe Universe)
|
|||||||
trySeedFromClipboard u = do
|
trySeedFromClipboard u = do
|
||||||
mcstr <- getClipboardString
|
mcstr <- getClipboardString
|
||||||
case mcstr >>= readMaybe of
|
case mcstr >>= readMaybe of
|
||||||
Nothing -> pushScreen (seedStartMenu "CLIPBOARD UNUSABLE, NEED INTEGER")
|
Nothing -> pushScreen (seedStartMenu "CLIPBOARD UNUSABLE, NEED INTEGER")
|
||||||
(u & menuLayers %~ tail)
|
(u & menuLayers %~ tail)
|
||||||
Just i -> return . Just $ startSeedGame i u
|
Just i -> return . Just $ startSeedGame i u
|
||||||
|
|
||||||
@@ -71,8 +71,8 @@ optionsOptions =
|
|||||||
]
|
]
|
||||||
debugMenu :: ScreenLayer
|
debugMenu :: ScreenLayer
|
||||||
debugMenu = slTitleOptions
|
debugMenu = slTitleOptions
|
||||||
"OPTIONS:GAMEPLAY"
|
"OPTIONS:GAMEPLAY"
|
||||||
debugMenuOptions
|
debugMenuOptions
|
||||||
debugMenuOptions :: [MenuOption]
|
debugMenuOptions :: [MenuOption]
|
||||||
debugMenuOptions =
|
debugMenuOptions =
|
||||||
[ doption ScancodeF debug_seconds_frame "SHOW SECONDS/FRAME" _debug_seconds_frame
|
[ doption ScancodeF debug_seconds_frame "SHOW SECONDS/FRAME" _debug_seconds_frame
|
||||||
@@ -82,7 +82,7 @@ debugMenuOptions =
|
|||||||
, doption ScancodeP debug_pathing "SHOW PATHING" _debug_pathing
|
, doption ScancodeP debug_pathing "SHOW PATHING" _debug_pathing
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
doption scode l t rec
|
doption scode l t rec
|
||||||
= Toggle scode (return . Just . (config . l %~ not)) (\w -> t ++ ":" ++ show (rec $ _config w))
|
= Toggle scode (return . Just . (config . l %~ not)) (\w -> t ++ ":" ++ show (rec $ _config w))
|
||||||
gameplayMenu :: ScreenLayer
|
gameplayMenu :: ScreenLayer
|
||||||
gameplayMenu = slTitleOptions
|
gameplayMenu = slTitleOptions
|
||||||
@@ -107,10 +107,10 @@ soundMenuOptions =
|
|||||||
, theoption ScancodeN volume_music ScancodeM "MUSIC VOLUME:" _volume_music
|
, theoption ScancodeN volume_music ScancodeM "MUSIC VOLUME:" _volume_music
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
theoption scod1 stype scod2 str voltype = Toggle2
|
theoption scod1 stype scod2 str voltype = Toggle2
|
||||||
scod1
|
scod1
|
||||||
(change dec stype)
|
(change dec stype)
|
||||||
scod2
|
scod2
|
||||||
(change inc stype)
|
(change inc stype)
|
||||||
(\w -> str ++ show (round $ 10 * voltype (_config w)::Int))
|
(\w -> str ++ show (round $ 10 * voltype (_config w)::Int))
|
||||||
change g vt = return . Just . (config . vt %~ g) . sw
|
change g vt = return . Just . (config . vt %~ g) . sw
|
||||||
@@ -127,7 +127,7 @@ graphicsMenu = slTitleOptions "OPTIONS:GRAPHICS" graphicsMenuOptions
|
|||||||
graphicsMenuOptions :: [MenuOption]
|
graphicsMenuOptions :: [MenuOption]
|
||||||
graphicsMenuOptions =
|
graphicsMenuOptions =
|
||||||
[ makeEnumOption ScancodeS resolution_factor "RESOLUTION" updateFramebufferSize
|
[ makeEnumOption ScancodeS resolution_factor "RESOLUTION" updateFramebufferSize
|
||||||
, makeBoolOption ScancodeW wall_textured "WALL TEXTURES"
|
, makeBoolOption ScancodeW wall_textured "WALL TEXTURES"
|
||||||
, makeBoolOption ScancodeD cloud_shadows "CLOUD SHADOWS"
|
, makeBoolOption ScancodeD cloud_shadows "CLOUD SHADOWS"
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -139,10 +139,11 @@ gameOverMenu = OptionScreen
|
|||||||
, _scOptionFlag = GameOverOptions
|
, _scOptionFlag = GameOverOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
-- | hacky
|
-- | hacky - no longer used
|
||||||
scodeToChar :: Scancode -> Char
|
scodeToChar :: Scancode -> Char
|
||||||
scodeToChar = toEnum . (+ 61) . fromIntegral . unwrapScancode
|
scodeToChar = toEnum . (+ 61) . fromIntegral . unwrapScancode
|
||||||
|
|
||||||
|
|
||||||
--charToScode :: Char -> Scancode
|
--charToScode :: Char -> Scancode
|
||||||
--charToScode = Scancode . fromIntegral . (\x -> x - 61) . fromEnum
|
--charToScode = Scancode . fromIntegral . (\x -> x - 61) . fromEnum
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import Padding
|
|||||||
menuScreen :: Universe -> ScreenLayer -> Picture
|
menuScreen :: Universe -> ScreenLayer -> Picture
|
||||||
menuScreen w screen = case screen of
|
menuScreen w screen = case screen of
|
||||||
OptionScreen {_scTitle = titf, _scOptions = mos}
|
OptionScreen {_scTitle = titf, _scOptions = mos}
|
||||||
-> drawOptions w (titf w) mos
|
-> drawOptions w (titf w) mos "Use keys to navigate the menu"
|
||||||
(WaitScreen sf _) -> drawOptions w (sf w) []
|
(WaitScreen sf _) -> drawOptions w (sf w) [] ""
|
||||||
(InputScreen s) -> drawOptions w ('>':s) []
|
(InputScreen s help) -> drawOptions w (s) [] help
|
||||||
(DisplayScreen sd ) -> sd w
|
(DisplayScreen sd ) -> sd w
|
||||||
(ColumnsScreen title pairs) -> drawTwoColumnsScreen (_config w) title pairs
|
(ColumnsScreen title pairs) -> drawTwoColumnsScreen (_config w) title pairs
|
||||||
|
|
||||||
@@ -47,10 +47,11 @@ drawOptions
|
|||||||
:: Universe
|
:: Universe
|
||||||
-> String -- ^ Title
|
-> String -- ^ Title
|
||||||
-> [MenuOption] -- ^ Options
|
-> [MenuOption] -- ^ Options
|
||||||
|
-> String -- ^ Help Text
|
||||||
-> Picture
|
-> Picture
|
||||||
drawOptions u title ops = pictures $
|
drawOptions u title ops help = pictures $
|
||||||
[darkenBackground cfig
|
[darkenBackground cfig
|
||||||
, drawTitle cfig title] ++
|
, drawTitle cfig title, drawHelpText cfig help red] ++
|
||||||
zipWith (\s vpos -> placeString (-hw + 50) vpos 0.2 s)
|
zipWith (\s vpos -> placeString (-hw + 50) vpos 0.2 s)
|
||||||
(map (menuOptionToString u) ops')
|
(map (menuOptionToString u) ops')
|
||||||
[hh-100,hh-150 ..]
|
[hh-100,hh-150 ..]
|
||||||
@@ -73,6 +74,13 @@ drawTitle cfig = placeString (-hw + 30) (hh - 50) 0.4
|
|||||||
hh = halfHeight cfig
|
hh = halfHeight cfig
|
||||||
hw = halfWidth cfig
|
hw = halfWidth cfig
|
||||||
|
|
||||||
|
drawHelpText :: Configuration -> String -> Color -> Picture
|
||||||
|
drawHelpText cfig col = placeString (-hw + 30) (-hh+10) 0.1 col
|
||||||
|
where
|
||||||
|
placeString x y sc t col = translate x y $ scale sc sc $ color col $ text t
|
||||||
|
hh = halfHeight cfig
|
||||||
|
hw = halfWidth cfig
|
||||||
|
|
||||||
menuOptionToString :: Universe -> MenuOption -> String
|
menuOptionToString :: Universe -> MenuOption -> String
|
||||||
menuOptionToString w mo = theKeys ++ _moString mo w
|
menuOptionToString w mo = theKeys ++ _moString mo w
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ quarterRoomTri w = do
|
|||||||
]
|
]
|
||||||
, _rmBound = [[V2 0 0,V2 w w,V2 (-w) w]]
|
, _rmBound = [[V2 0 0,V2 w w,V2 (-w) w]]
|
||||||
}
|
}
|
||||||
|
|
||||||
quarterRoomSquare :: RandomGen g => Float -> State g Room
|
quarterRoomSquare :: RandomGen g => Float -> State g Room
|
||||||
quarterRoomSquare w = do
|
quarterRoomSquare w = do
|
||||||
b <- takeOne
|
b <- takeOne
|
||||||
@@ -183,8 +184,9 @@ quarterRoomSquare w = do
|
|||||||
, blockLine (V2 0 w) (V2 0 (w*2))
|
, blockLine (V2 0 w) (V2 0 (w*2))
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
let thepoly = [ map toV2 [(0,0),(w,w),(0,2*w),(-w,w)] ]
|
||||||
pure $ defaultRoom
|
pure $ defaultRoom
|
||||||
{ _rmPolys = [ map toV2 [(0,0),(w,w),(0,2*w),(-w,w)] ]
|
{ _rmPolys = thepoly
|
||||||
, _rmLinks = map toBothLnk
|
, _rmLinks = map toBothLnk
|
||||||
[ (V2 (w/2) (3*w/2), negate $ pi/4)
|
[ (V2 (w/2) (3*w/2), negate $ pi/4)
|
||||||
, (V2 (negate $ w/2) (3*w/2), pi/4)
|
, (V2 (negate $ w/2) (3*w/2), pi/4)
|
||||||
@@ -204,7 +206,8 @@ quarterRoomSquare w = do
|
|||||||
, _rmPmnts = b ++ [ blockLine (V2 (w/2) (w/2)) (V2 0 w) ]
|
, _rmPmnts = b ++ [ blockLine (V2 (w/2) (w/2)) (V2 0 w) ]
|
||||||
, _rmPos = [ RoomPos p pi S.empty NotLink 0
|
, _rmPos = [ RoomPos p pi S.empty NotLink 0
|
||||||
| p <- [V2 20 (2*w-40),V2 25 (2*w-45)] ]
|
| p <- [V2 20 (2*w-40),V2 25 (2*w-45)] ]
|
||||||
, _rmBound = [map toV2 [(w,w),(0,2*w),(-w,w)]]
|
--, _rmBound = [map toV2 [(w,w),(0,2*w),(-w,w)]]
|
||||||
|
, _rmBound = thepoly
|
||||||
}
|
}
|
||||||
{- | Randomise the ordering of placements in a room.
|
{- | Randomise the ordering of placements in a room.
|
||||||
Useful for randomising the position of generic placements such as 'PutNothing'. -}
|
Useful for randomising the position of generic placements such as 'PutNothing'. -}
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ posRms :: [ConvexPoly]
|
|||||||
-> [(Int,Tree RoomInt)] -- the list of children, with indices
|
-> [(Int,Tree RoomInt)] -- the list of children, with indices
|
||||||
-> Seq (Tree RoomInt)
|
-> Seq (Tree RoomInt)
|
||||||
-> IO (Maybe [RoomInt])
|
-> IO (Maybe [RoomInt])
|
||||||
posRms bounds (parent,i) [] st = case st of
|
posRms bounds roomi [] st = case st of
|
||||||
Empty -> return $ Just [(parent,i)]
|
Empty -> return $ Just [roomi]
|
||||||
Node childi ts :<| tseq -> fmap ((parent,i):) <$> posRms bounds childi (zipCount ts) tseq
|
Node nextroomi ts :<| tseq -> fmap (roomi:) <$> posRms bounds nextroomi (zipCount ts) tseq
|
||||||
posRms bounds parenti@(parent,_) ( (numChild,t@(Node childi _) ):its) tseq = do
|
posRms bounds parenti@(parent,_) ( (numChild,t@(Node childi _) ):its) tseq = do
|
||||||
printInfoCheckNum parenti numChild childi
|
printInfoCheckNum parenti numChild childi
|
||||||
tryParentLinks outlinks
|
tryParentLinks outlinks
|
||||||
|
|||||||
Reference in New Issue
Block a user