libtcod
Loading...
Searching...
No Matches
sys.hpp
Go to the documentation of this file.
1/* BSD 3-Clause License
2 *
3 * Copyright © 2008-2025, Jice and the libtcod contributors.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
15 *
16 * 3. Neither the name of the copyright holder nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
34// clang-format off
35#pragma once
36#ifndef TCOD_SYS_HPP_
37#define TCOD_SYS_HPP_
38
39#include "image.hpp"
40#include "mouse.hpp"
41#include "sys.h"
49
50class TCODLIB_API ITCODSDLRenderer {
51public :
52 virtual ~ITCODSDLRenderer() {}
53 virtual void render(void *sdlSurface) = 0;
54};
55
56class TCODLIB_API TCODSystem {
57public :
76 [[deprecated("This function is not compatible with contexts. Use tcod::Timer instead.")]]
77 static void setFps(int val);
78
89 [[deprecated("This function is not compatible with contexts. Use tcod::Timer instead.")]]
90 static int getFps();
91
93 [[deprecated("This function is not compatible with contexts. Use tcod::Timer or SDL timing functions instead.")]]
94 static float getLastFrameLength();
95
107 [[deprecated("Use SDL_Delay instead.")]]
108 static void sleepMilli(uint32_t val);
109
120 [[deprecated("Use SDL_GetTicks instead.")]]
121 static uint32_t getElapsedMilli();
122
133 [[deprecated("Use SDL_GetTicks instead.")]]
134 static float getElapsedSeconds();
135
136 TCODLIB_BEGIN_IGNORE_DEPRECATIONS
172 [[deprecated("This API is deprecated, use SDL_WaitEvent instead.")]]
173 static TCOD_event_t waitForEvent(int eventMask, TCOD_key_t *key, TCOD_mouse_t *mouse, bool flush);
174
207 [[deprecated("This API is deprecated, use SDL_PollEvent instead.")]]
208 static TCOD_event_t checkForEvent(int eventMask, TCOD_key_t *key, TCOD_mouse_t *mouse);
209 TCODLIB_END_IGNORE_DEPRECATIONS
210
223 [[deprecated("This function is not compatible with contexts.")]]
224 static void saveScreenshot(const char *filename);
225
236 TCOD_DEPRECATED_NOMESSAGE
237 static bool createDirectory(const char *path);
238
246 TCOD_DEPRECATED_NOMESSAGE
247 static bool deleteDirectory(const char *path);
248
256 TCOD_DEPRECATED_NOMESSAGE
257 static bool deleteFile(const char *path);
258
266 TCOD_DEPRECATED_NOMESSAGE
267 static bool isDirectory(const char *path);
268
279 TCOD_DEPRECATED_NOMESSAGE
280 static TCOD_list_t getDirectoryContent(const char *path, const char *pattern);
281
299 TCOD_DEPRECATED_NOMESSAGE
300 static bool fileExists(const char * filename, ...);
324 TCOD_DEPRECATED_NOMESSAGE
325 static bool readFile(const char *filename, unsigned char **buf, size_t *size);
340 TCOD_DEPRECATED_NOMESSAGE
341 static bool writeFile(const char *filename, unsigned char *buf, uint32_t size);
384 TCOD_DEPRECATED_NOMESSAGE
385 static void registerSDLRenderer(ITCODSDLRenderer *renderer);
386
396
426 [[deprecated("This function is not compatible with contexts.")]]
427 static void forceFullscreenResolution(int width, int height);
428
439 [[deprecated("This function is not compatible with contexts.")]]
440 static void getCurrentResolution(int *width, int *height);
450 [[deprecated("This function is not compatible with contexts.")]]
451 static void getFullscreenOffsets(int *offset_x, int *offset_y);
452
463 [[deprecated("This function is not compatible with contexts.")]]
464 static void getCharSize(int *w, int *h);
465
478 [[deprecated("This function is not compatible with contexts.")]]
479 static void updateChar(int asciiCode, int font_x, int font_y,const TCODImage *img,int x,int y);
480
495 [[deprecated("This function is not compatible with contexts.")]]
496 static void setRenderer(TCOD_renderer_t renderer);
497
506 [[deprecated("This function is not compatible with contexts.")]]
507 static TCOD_renderer_t getRenderer();
508
521 TCOD_DEPRECATED_NOMESSAGE
522 static bool setClipboard(const char *value);
523
532 TCOD_DEPRECATED_NOMESSAGE
533 static char *getClipboard();
534
535#ifndef TCOD_NO_THREADS
536 // thread stuff
537 TCOD_DEPRECATED_NOMESSAGE
538 static int getNumCores();
539 TCOD_DEPRECATED_NOMESSAGE
540 static TCOD_thread_t newThread(int (*func)(void *), void *data);
541 TCOD_DEPRECATED_NOMESSAGE
542 static void deleteThread(TCOD_thread_t th);
543 TCOD_DEPRECATED_NOMESSAGE
544 static void waitThread(TCOD_thread_t th);
545 // mutex
546 TCOD_DEPRECATED_NOMESSAGE
547 static TCOD_mutex_t newMutex();
548 TCOD_DEPRECATED_NOMESSAGE
549 static void mutexIn(TCOD_mutex_t mut);
550 TCOD_DEPRECATED_NOMESSAGE
551 static void mutexOut(TCOD_mutex_t mut);
552 TCOD_DEPRECATED_NOMESSAGE
553 static void deleteMutex(TCOD_mutex_t mut);
554 // semaphore
555 TCOD_DEPRECATED_NOMESSAGE
556 static TCOD_semaphore_t newSemaphore(int initVal);
557 TCOD_DEPRECATED_NOMESSAGE
558 static void lockSemaphore(TCOD_semaphore_t sem);
559 TCOD_DEPRECATED_NOMESSAGE
560 static void unlockSemaphore(TCOD_semaphore_t sem);
561 TCOD_DEPRECATED_NOMESSAGE
562 static void deleteSemaphore( TCOD_semaphore_t sem);
563 // condition
564 TCOD_DEPRECATED_NOMESSAGE
565 static TCOD_cond_t newCondition();
566 TCOD_DEPRECATED_NOMESSAGE
567 static void signalCondition(TCOD_cond_t sem);
568 TCOD_DEPRECATED_NOMESSAGE
569 static void broadcastCondition(TCOD_cond_t sem);
570 TCOD_DEPRECATED_NOMESSAGE
571 static void waitCondition(TCOD_cond_t sem, TCOD_mutex_t mut);
572 TCOD_DEPRECATED_NOMESSAGE
573 static void deleteCondition( TCOD_cond_t sem);
574#endif // TCOD_NO_THREADS
575};
576
577#endif // TCOD_SYS_HPP_
Definition sys.hpp:50
Definition image.hpp:60
Definition sys.hpp:56
static bool setClipboard(const char *value)
Takes UTF-8 text and copies it into the system clipboard. On Linux, because an application cannot acc...
static bool readFile(const char *filename, unsigned char **buf, size_t *size)
This is a portable function to read the content of a file from disk or from the application apk (andr...
static bool deleteFile(const char *path)
static void updateChar(int asciiCode, int font_x, int font_y, const TCODImage *img, int x, int y)
You can dynamically change the bitmap of a character in the font.
static void setFps(int val)
The setFps function allows you to limit the number of frames per second. If a frame is rendered faste...
static float getLastFrameLength()
Return the duration of the last frame in seconds.
static void setRenderer(TCOD_renderer_t renderer)
As of 1.5.1, libtcod contains 3 different renderers : SDL : historic libtcod renderer.
static char * getClipboard()
Returns the UTF-8 text currently in the system clipboard.
static TCODLIB_END_IGNORE_DEPRECATIONS void saveScreenshot(const char *filename)
This function allows you to save the current game screen in a png file, or possibly a bmp file if you...
static void sleepMilli(uint32_t val)
Use this function to stop the program execution for a specified number of milliseconds.
static bool writeFile(const char *filename, unsigned char *buf, uint32_t size)
This is a portable function to write some data to a file.
static void registerSDLRenderer(ITCODSDLRenderer *renderer)
To disable the custom renderer, call the same method with a NULL parameter. Note that to keep libtcod...
static TCODLIB_BEGIN_IGNORE_DEPRECATIONS TCOD_event_t waitForEvent(int eventMask, TCOD_key_t *key, TCOD_mouse_t *mouse, bool flush)
This function waits for an event from the user.
static uint32_t getElapsedMilli()
This function returns the number of milliseconds since the program has started.
static TCOD_list_t getDirectoryContent(const char *path, const char *pattern)
To get the list of entries in a directory (including sub-directories, except .
static void getCurrentResolution(int *width, int *height)
You can get the current screen resolution with getCurrentResolution.
static bool isDirectory(const char *path)
static void getCharSize(int *w, int *h)
You can get the size of the characters in the font.
static bool createDirectory(const char *path)
static float getElapsedSeconds()
This function returns the number of seconds since the program has started.
static void forceFullscreenResolution(int width, int height)
libtcod is not aware of the part of the screen your SDL renderer has updated.
static bool deleteDirectory(const char *path)
static void getFullscreenOffsets(int *offset_x, int *offset_y)
If the fullscreen resolution does not matches the console size in pixels, black borders are added.
static TCOD_event_t checkForEvent(int eventMask, TCOD_key_t *key, TCOD_mouse_t *mouse)
This function checks if an event from the user is in the buffer.
static bool fileExists(const char *filename,...)
In order to check whether a given file exists in the filesystem.
static int getFps()
The value returned by this function is updated every second.
TCOD_renderer_t
Libtcod rendering modes.
Definition console_types.h:491
Image handling module.
Deprecated mouse functions.
Libtcod key event data, as a keycode or text character.
Definition console_types.h:207
Mouse state provided by the libtcod event system.
Definition mouse_types.h:50
Deprecated low-level functions.