Safe Haskell | None |
---|---|
Language | Haskell2010 |
- systemStartup :: IO ()
- systemShutdown :: IO ()
- withSystem :: IO a -> IO a
- systemElapsedMilli :: IO Word
- systemElapsedSeconds :: IO Double
- systemSleepMilli :: Word -> IO ()
- systemSetFps :: Int -> IO ()
- systemGetFps :: IO Int
- systemGetLastFrameLength :: IO Float
- systemSaveScreenshot :: Maybe FilePath -> IO ()
- systemForceFullscreenResolution :: Int -> Int -> IO ()
- systemSetRenderer :: TCODRenderer -> IO ()
- systemGetRenderer :: IO TCODRenderer
- systemGetCurrentResolution :: IO (Int, Int)
- systemGetFullscreenOffsets :: IO (Int, Int)
- systemGetCharSize :: IO (Int, Int)
- systemUpdateChar :: Char -> Int -> Int -> TCODImage -> Int -> Int -> IO ()
- systemClipboardSet :: String -> IO Bool
- systemClipboardGet :: IO String
- systemGetSDLWindow :: IO Window
- systemGetSDLRenderer :: IO Renderer
- data TCODEvent
- packTCODEvents :: Foldable f => f TCODEvent -> Int
- unpackTCODEvents :: Int -> Set TCODEvent
- data TCODEventInfo = TCODEventInfo {}
- systemWaitForEvent :: Foldable f => f TCODEvent -> Bool -> IO TCODEventInfo
- systemCheckForEvent :: Foldable f => f TCODEvent -> IO TCODEventInfo
- systemCreateDirectory :: FilePath -> IO Bool
- systemDeleteFile :: FilePath -> IO Bool
- systemDeleteDirectory :: FilePath -> IO Bool
- systemIsDirectory :: FilePath -> IO Bool
- systemGetDirectoryContent :: FilePath -> String -> IO (TCODList FilePath)
- systemFileExists :: PrintfArg r => FilePath -> r -> IO Bool
- systemReadFile :: FilePath -> IO (Maybe ByteString)
- systemWriteFile :: FilePath -> ByteString -> IO Bool
- newtype TCODLibrary = TCODLibrary {
- unTCODLibrary :: Ptr ()
- loadLibrary :: FilePath -> IO (Maybe TCODLibrary)
- getFunctionAddress :: TCODLibrary -> String -> IO (Maybe (FunPtr a))
- closeLibrary :: TCODLibrary -> IO ()
Documentation
systemStartup :: IO () Source #
Initialize global TCOD reference for system
systemShutdown :: IO () Source #
Deallocate global TCOD reference for system
withSystem :: IO a -> IO a Source #
Run action with wrapped TCOD system startup/shutdown. Exception safe and intented to be used in main function.
systemElapsedMilli :: IO Word Source #
Get global timer in milliseconds
This function returns the number of milliseconds since the program has started.
systemElapsedSeconds :: IO Double Source #
Get global timer in seconds
This function returns the number of seconds since the program has started.
systemSleepMilli :: Word -> IO () Source #
Pause the program
Use this function to stop the program execution for a specified number of milliseconds.
Note: all haskell threads on the same HEC will be paused too, try to use Haskell side delays instead of the function.
systemSetFps :: Int -> IO () Source #
Limit the frames per second
The setFps function allows you to limit the number of frames per second.
If a frame is rendered faster than expected, the consoleFlush
function will
wait so that the frame rate never exceed this value.
You can call this function during your game initialization.
You can dynamically change the frame rate. Just call this function once again.
bYou should always limit the frame rate, except during benchmarks, else your
game will use 100% of the CPU power/b
systemGetFps :: IO Int Source #
Get the number of frames rendered during the last second
The value returned by this function is updated every second.
systemGetLastFrameLength :: IO Float Source #
Get the duration of the last frame
This function returns the length in seconds of the last rendered frame. You can use this value to update every time dependent object in the world.
:: Maybe FilePath | Name of the file. If empty, a filename is automatically generated with the form "./screenshotNNN.png", NNN being the first free number (if a file named screenshot000.png already exist, screenshot001.png will be used, and so on...). |
-> IO () |
This function allows you to save the current game screen in a png file, or possibly a bmp file if you provide a filename ending with .bmp.
systemForceFullscreenResolution Source #
:: Int | width Resolution to use when switching to fullscreen. |
-> Int | height Resolution to use when switching to fullscreen. |
-> IO () |
Using a custom resolution for the fullscreen mode
This function allows you to force the use of a specific resolution in fullscreen mode. The default resolution depends on the root console size and the font character size.
Will use the smallest available resolution so that : resolution width >= width and resolution width >= root console width * font char width resolution width >= height and resolution height >= root console height * font char height
systemSetRenderer :: TCODRenderer -> IO () Source #
Dynamically change libtcod's internal renderer
As of 1.5.1, libtcod contains 3 different renderers : * SDL : historic libtcod renderer. Should work and be pretty fast everywhere * OpenGL : requires OpenGL compatible video card. Might be much faster or much slower than SDL, depending on the drivers * GLSDL : requires OpenGL 1.4 compatible video card with GL_ARB_shader_objects extension. Blazing fast if you have the proper hardware and drivers. This function switches the current renderer dynamically.
systemGetRenderer :: IO TCODRenderer Source #
Get the current internal renderer
systemGetCurrentResolution :: IO (Int, Int) Source #
Get current resolution
You can get the current screen resolution with getCurrentResolution. You can use it for example to get the desktop resolution before initializing the root console.
systemGetFullscreenOffsets :: IO (Int, Int) Source #
Get fullscreen offset
If the fullscreen resolution does not matches the console size in pixels, black borders are added. This function returns the position in pixels of the console top left corner in the screen.
systemGetCharSize :: IO (Int, Int) Source #
Get the font size
You can get the size of the characters in the font
:: Char | ascii code corresponding to the character to update |
-> Int | font x coordinate of the character in the bitmap font (in characters, not pixels) |
-> Int | font y coordinate of the character in the bitmap font (in characters, not pixels) |
-> TCODImage | img image containing the new character bitmap |
-> Int | x position in pixels of the top-left corner of the character in the image |
-> Int | y position in pixels of the top-left corner of the character in the image |
-> IO () |
Dynamically updating the font bitmap
You can dynamically change the bitmap of a character in the font. All cells using this ascii code will be updated at next flush call.
systemClipboardSet :: String -> IO Bool Source #
Set current clipboard contents
Takes UTF-8 text and copies it into the system clipboard. On Linux, because an application cannot access the system clipboard unless a window is open, if no window is open the call will do nothing.
systemClipboardGet :: IO String Source #
Get current clipboard contents\
Returns the UTF-8 text currently in the system clipboard. On Linux, because an application cannot access the system clipboard unless a window is open, if no window is open an empty string will be returned.
systemGetSDLWindow :: IO Window Source #
Returm reference to SDL window
systemGetSDLRenderer :: IO Renderer Source #
Return reference to SDL renderer
Flags to distinguish supported events
unpackTCODEvents :: Int -> Set TCODEvent Source #
Unpack events flags from bitfield. Note that EventKey
, EventMouse
and EventAny
are in the set
if any of dependent event is occured. EventNone
is never occur in the set (empty set if no events)
and EventAny
is member of the set if any event occurs.
:: Foldable f | |
=> f TCODEvent | event types to wait for (other types are discarded) |
-> Bool | Flush if true, all pending events are flushed from the buffer. Else, return the first available event |
-> IO TCODEventInfo |
Waiting for any event (mouse or keyboard)
This function waits for an event from the user. The eventMask shows what events we're waiting for. The return value indicate what event was actually triggered. Values in key and mouse structures are updated accordingly. If flush is false, the function waits only if there are no pending events, else it returns the first event in the buffer.
:: Foldable f | |
=> f TCODEvent | event types to wait for (other types are discarded) |
-> IO TCODEventInfo |
Checking for any event (mouse or keyboard)
This function checks if an event from the user is in the buffer. The eventMask shows what events we're waiting for. The return value indicate what event was actually found. Values in key and mouse structures are updated accordingly.
systemCreateDirectory Source #
:: FilePath | Directory path. The immediate father directory (path/..) must exist and be writable. |
-> IO Bool |
Create a directory
All those functions return false if an error occurred.
Delete a file
All those functions return false if an error occurred.
systemDeleteDirectory Source #
Delete an empty directory
All those functions return false if an error occurred.
Check if a path is a directory
All those functions return false if an error occurred.
systemGetDirectoryContent Source #
:: FilePath | a path to check |
-> String | pattern. If empty, returns all directory entries. Else returns
only entries matching the pattern. The pattern is NOT a regular
expression. It can only handle one |
-> IO (TCODList FilePath) |
List files in a directory
To get the list of entries in a directory (including sub-directories, except . and ..).
The returned list is allocated by the function and must be deleted by you.
All the const char * inside must be also freed with listClearAndDelete
.
:: PrintfArg r | |
=> FilePath | filename the file name, using printf-like formatting |
-> r | optional arguments for filename formatting |
-> IO Bool |
Check if a given file exists
In order to check whether a given file exists in the filesystem. Useful for detecting errors caused by missing files.
systemReadFile :: FilePath -> IO (Maybe ByteString) Source #
Read the content of a file into memory
This is a portable function to read the content of a file from disk or from the application apk (android).
systemWriteFile :: FilePath -> ByteString -> IO Bool Source #
Write the content of a memory buffer to a file
This is a portable function to write some data to a file.
loadLibrary :: FilePath -> IO (Maybe TCODLibrary) Source #
Dynamic load of .so or .dll library.
:: TCODLibrary | Dynamic library reference |
-> String | Name of function to load |
-> IO (Maybe (FunPtr a)) | If succeded, then return pointer to function |
Dynamic load of function from library. Not safe as type of function is not checked.
closeLibrary :: TCODLibrary -> IO () Source #
Unload dynamic library from memory