2018-12-09 06:36:33 +00:00
|
|
|
//
|
|
|
|
// Created by koncord on 09.12.18.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef OPENMW_TIMER_HPP
|
|
|
|
#define OPENMW_TIMER_HPP
|
|
|
|
|
2019-01-15 11:41:58 +00:00
|
|
|
#include <Script/ScriptFunction.hpp>
|
2019-01-15 12:26:11 +00:00
|
|
|
#include "../api.h"
|
2018-12-09 06:36:33 +00:00
|
|
|
|
2019-01-15 12:26:11 +00:00
|
|
|
NAMESPACE_BEGIN(TimerFunctions)
|
2018-12-09 06:36:33 +00:00
|
|
|
/**
|
|
|
|
* \brief Create a timer that will run a script function after a certain interval.
|
|
|
|
*
|
|
|
|
* \param callback The Lua script function.
|
|
|
|
* \param msec The interval in miliseconds.
|
|
|
|
* \return The ID of the timer thus created.
|
|
|
|
*/
|
2019-01-15 12:26:11 +00:00
|
|
|
API_FUNCTION int CDECL CreateTimer(ScriptFunc callback, int msec) noexcept;
|
2018-12-09 06:36:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Create a timer that will run a script function after a certain interval and pass
|
|
|
|
* certain arguments to it.
|
|
|
|
*
|
|
|
|
* Example usage:
|
|
|
|
* - tes3mp.CreateTimerEx("OnTimerTest1", 250, "i", 90)
|
|
|
|
* - tes3mp.CreateTimerEx("OnTimerTest2", 500, "sif", "Test string", 60, 77.321)
|
|
|
|
*
|
|
|
|
* \param callback The Lua script function.
|
|
|
|
* \param msec The interval in miliseconds.
|
|
|
|
* \param types The argument types.
|
|
|
|
* \param args The arguments.
|
|
|
|
* \return The ID of the timer thus created.
|
|
|
|
*/
|
2019-01-15 12:26:11 +00:00
|
|
|
API_FUNCTION int CDECL CreateTimerEx(ScriptFunc callback, int msec, const char *types, va_list args) noexcept;
|
2018-12-09 06:36:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Start the timer with a certain ID.
|
|
|
|
*
|
|
|
|
* \param timerId The timer ID.
|
|
|
|
* \return void
|
|
|
|
*/
|
2019-01-15 12:26:11 +00:00
|
|
|
API_FUNCTION void CDECL StartTimer(int timerId) noexcept;
|
2018-12-09 06:36:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Stop the timer with a certain ID.
|
|
|
|
*
|
|
|
|
* \param timerId The timer ID.
|
|
|
|
* \return void
|
|
|
|
*/
|
2019-01-15 12:26:11 +00:00
|
|
|
API_FUNCTION void CDECL StopTimer(int timerId) noexcept;
|
2018-12-09 06:36:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Restart the timer with a certain ID for a certain interval.
|
|
|
|
*
|
|
|
|
* \param timerId The timer ID.
|
|
|
|
* \param msec The interval in miliseconds.
|
|
|
|
* \return void
|
|
|
|
*/
|
2019-01-15 12:26:11 +00:00
|
|
|
API_FUNCTION void CDECL RestartTimer(int timerId, int msec) noexcept;
|
2018-12-09 06:36:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Free the timer with a certain ID.
|
|
|
|
*
|
|
|
|
* \param timerId The timer ID.
|
|
|
|
* \return void
|
|
|
|
*/
|
2019-01-15 12:26:11 +00:00
|
|
|
API_FUNCTION void CDECL FreeTimer(int timerId) noexcept;
|
2018-12-09 06:36:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Check whether a timer is elapsed.
|
|
|
|
*
|
|
|
|
* \param timerId The timer ID.
|
|
|
|
* \return Whether the timer is elapsed.
|
|
|
|
*/
|
2019-01-15 12:26:11 +00:00
|
|
|
API_FUNCTION bool CDECL IsTimerElapsed(int timerId) noexcept;
|
|
|
|
NAMESPACE_END()
|
2018-12-09 06:36:33 +00:00
|
|
|
|
|
|
|
#endif //OPENMW_TIMER_HPP
|