Program Listing for File sys.hpp

Return to documentation for file (libtcod/sys.hpp)

/* BSD 3-Clause License
 *
 * Copyright © 2008-2026, Jice and the libtcod contributors.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 *
 * 3. Neither the name of the copyright holder nor the names of its
 *    contributors may be used to endorse or promote products derived from
 *    this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
// clang-format off
#pragma once
#ifndef TCOD_SYS_HPP_
#define TCOD_SYS_HPP_

#include "image.hpp"
#include "mouse.hpp"
#include "sys.h"
class TCODLIB_API ITCODSDLRenderer {
public :
  virtual ~ITCODSDLRenderer() {}
  virtual void render(void *sdlSurface) = 0;
};

class TCODLIB_API TCODSystem {
public :
  [[deprecated("This function is not compatible with contexts.  Use tcod::Timer instead.")]]
  static void setFps(int val);

  [[deprecated("This function is not compatible with contexts.  Use tcod::Timer instead.")]]
  static int getFps();

  [[deprecated("This function is not compatible with contexts.  Use tcod::Timer or SDL timing functions instead.")]]
  static float getLastFrameLength();

  [[deprecated("Use SDL_Delay instead.")]]
  static void sleepMilli(uint32_t val);

  [[deprecated("Use SDL_GetTicks instead.")]]
  static uint32_t getElapsedMilli();

  [[deprecated("Use SDL_GetTicks instead.")]]
  static float getElapsedSeconds();

  TCODLIB_BEGIN_IGNORE_DEPRECATIONS
  [[deprecated("This API is deprecated, use SDL_WaitEvent instead.")]]
  static TCOD_event_t waitForEvent(int eventMask, TCOD_key_t *key, TCOD_mouse_t *mouse, bool flush);

  [[deprecated("This API is deprecated, use SDL_PollEvent instead.")]]
  static TCOD_event_t checkForEvent(int eventMask, TCOD_key_t *key, TCOD_mouse_t *mouse);
  TCODLIB_END_IGNORE_DEPRECATIONS

  [[deprecated("This function is not compatible with contexts.")]]
  static void saveScreenshot(const char *filename);

  TCOD_DEPRECATED_NOMESSAGE
  static bool createDirectory(const char *path);

  TCOD_DEPRECATED_NOMESSAGE
  static bool deleteDirectory(const char *path);

  TCOD_DEPRECATED_NOMESSAGE
  static bool deleteFile(const char *path);

  TCOD_DEPRECATED_NOMESSAGE
  static bool isDirectory(const char *path);

  TCOD_DEPRECATED_NOMESSAGE
  static TCOD_list_t getDirectoryContent(const char *path, const char *pattern);

  TCOD_DEPRECATED_NOMESSAGE
  static bool fileExists(const char * filename, ...);
  TCOD_DEPRECATED_NOMESSAGE
  static bool readFile(const char *filename, unsigned char **buf, size_t *size);
  TCOD_DEPRECATED_NOMESSAGE
  static bool writeFile(const char *filename, unsigned char *buf, uint32_t size);
  TCOD_DEPRECATED_NOMESSAGE
  static void registerSDLRenderer(ITCODSDLRenderer *renderer);

  [[deprecated("This function is not compatible with contexts.")]]
  static void forceFullscreenResolution(int width, int height);

  [[deprecated("This function is not compatible with contexts.")]]
  static void getCurrentResolution(int *width, int *height);
  [[deprecated("This function is not compatible with contexts.")]]
  static void getFullscreenOffsets(int *offset_x, int *offset_y);

  [[deprecated("This function is not compatible with contexts.")]]
  static void getCharSize(int *w, int *h);

  [[deprecated("This function is not compatible with contexts.")]]
  static void updateChar(int asciiCode, int font_x, int font_y,const TCODImage *img,int x,int y);

  [[deprecated("This function is not compatible with contexts.")]]
  static void setRenderer(TCOD_renderer_t renderer);

  [[deprecated("This function is not compatible with contexts.")]]
  static TCOD_renderer_t getRenderer();

  TCOD_DEPRECATED_NOMESSAGE
  static bool setClipboard(const char *value);

  TCOD_DEPRECATED_NOMESSAGE
  static char *getClipboard();

#ifndef TCOD_NO_THREADS
  // thread stuff
  TCOD_DEPRECATED_NOMESSAGE
  static int getNumCores();
  TCOD_DEPRECATED_NOMESSAGE
  static TCOD_thread_t newThread(int (*func)(void *), void *data);
  TCOD_DEPRECATED_NOMESSAGE
  static void deleteThread(TCOD_thread_t th);
  TCOD_DEPRECATED_NOMESSAGE
  static void waitThread(TCOD_thread_t th);
  // mutex
  TCOD_DEPRECATED_NOMESSAGE
  static TCOD_mutex_t newMutex();
  TCOD_DEPRECATED_NOMESSAGE
  static void mutexIn(TCOD_mutex_t mut);
  TCOD_DEPRECATED_NOMESSAGE
  static void mutexOut(TCOD_mutex_t mut);
  TCOD_DEPRECATED_NOMESSAGE
  static void deleteMutex(TCOD_mutex_t mut);
  // semaphore
  TCOD_DEPRECATED_NOMESSAGE
  static TCOD_semaphore_t newSemaphore(int initVal);
  TCOD_DEPRECATED_NOMESSAGE
  static void lockSemaphore(TCOD_semaphore_t sem);
  TCOD_DEPRECATED_NOMESSAGE
  static void unlockSemaphore(TCOD_semaphore_t sem);
  TCOD_DEPRECATED_NOMESSAGE
  static void deleteSemaphore( TCOD_semaphore_t sem);
  // condition
  TCOD_DEPRECATED_NOMESSAGE
  static TCOD_cond_t newCondition();
  TCOD_DEPRECATED_NOMESSAGE
  static void signalCondition(TCOD_cond_t sem);
  TCOD_DEPRECATED_NOMESSAGE
  static void broadcastCondition(TCOD_cond_t sem);
  TCOD_DEPRECATED_NOMESSAGE
  static void waitCondition(TCOD_cond_t sem, TCOD_mutex_t mut);
  TCOD_DEPRECATED_NOMESSAGE
  static void deleteCondition( TCOD_cond_t sem);
#endif  // TCOD_NO_THREADS
};

#endif // TCOD_SYS_HPP_