1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "ags/engine/ac/date_time.h"
#include "ags/engine/ac/dynobj/dynobj_manager.h"
#include "ags/engine/platform/base/ags_platform_driver.h"
#include "ags/shared/debugging/out.h"
#include "ags/engine/script/script_api.h"
#include "ags/engine/script/script_runtime.h"
#include "ags/globals.h"
namespace AGS3 {
ScriptDateTime *DateTime_Now_Core() {
ScriptDateTime *sdt = new ScriptDateTime();
_G(platform)->GetSystemTime(sdt);
return sdt;
}
ScriptDateTime *DateTime_Now() {
ScriptDateTime *sdt = DateTime_Now_Core();
ccRegisterManagedObject(sdt, sdt);
return sdt;
}
int DateTime_GetYear(ScriptDateTime *sdt) {
return sdt->year;
}
int DateTime_GetMonth(ScriptDateTime *sdt) {
return sdt->month;
}
int DateTime_GetDayOfMonth(ScriptDateTime *sdt) {
return sdt->day;
}
int DateTime_GetHour(ScriptDateTime *sdt) {
return sdt->hour;
}
int DateTime_GetMinute(ScriptDateTime *sdt) {
return sdt->minute;
}
int DateTime_GetSecond(ScriptDateTime *sdt) {
return sdt->second;
}
int DateTime_GetRawTime(ScriptDateTime *sdt) {
return sdt->rawUnixTime;
}
//=============================================================================
//
// Script API Functions
//
//=============================================================================
// ScriptDateTime* ()
RuntimeScriptValue Sc_DateTime_Now(const RuntimeScriptValue *params, int32_t param_count) {
API_SCALL_OBJAUTO(ScriptDateTime, DateTime_Now);
}
// int (ScriptDateTime *sdt)
RuntimeScriptValue Sc_DateTime_GetYear(void *self, const RuntimeScriptValue *params, int32_t param_count) {
API_OBJCALL_INT(ScriptDateTime, DateTime_GetYear);
}
// int (ScriptDateTime *sdt)
RuntimeScriptValue Sc_DateTime_GetMonth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
API_OBJCALL_INT(ScriptDateTime, DateTime_GetMonth);
}
// int (ScriptDateTime *sdt)
RuntimeScriptValue Sc_DateTime_GetDayOfMonth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
API_OBJCALL_INT(ScriptDateTime, DateTime_GetDayOfMonth);
}
// int (ScriptDateTime *sdt)
RuntimeScriptValue Sc_DateTime_GetHour(void *self, const RuntimeScriptValue *params, int32_t param_count) {
API_OBJCALL_INT(ScriptDateTime, DateTime_GetHour);
}
// int (ScriptDateTime *sdt)
RuntimeScriptValue Sc_DateTime_GetMinute(void *self, const RuntimeScriptValue *params, int32_t param_count) {
API_OBJCALL_INT(ScriptDateTime, DateTime_GetMinute);
}
// int (ScriptDateTime *sdt)
RuntimeScriptValue Sc_DateTime_GetSecond(void *self, const RuntimeScriptValue *params, int32_t param_count) {
API_OBJCALL_INT(ScriptDateTime, DateTime_GetSecond);
}
// int (ScriptDateTime *sdt)
RuntimeScriptValue Sc_DateTime_GetRawTime(void *self, const RuntimeScriptValue *params, int32_t param_count) {
API_OBJCALL_INT(ScriptDateTime, DateTime_GetRawTime);
}
void RegisterDateTimeAPI() {
ScFnRegister datetime_api[] = {
{"DateTime::get_Now", API_FN_PAIR(DateTime_Now)},
{"DateTime::get_DayOfMonth", API_FN_PAIR(DateTime_GetDayOfMonth)},
{"DateTime::get_Hour", API_FN_PAIR(DateTime_GetHour)},
{"DateTime::get_Minute", API_FN_PAIR(DateTime_GetMinute)},
{"DateTime::get_Month", API_FN_PAIR(DateTime_GetMonth)},
{"DateTime::get_RawTime", API_FN_PAIR(DateTime_GetRawTime)},
{"DateTime::get_Second", API_FN_PAIR(DateTime_GetSecond)},
{"DateTime::get_Year", API_FN_PAIR(DateTime_GetYear)},
};
ccAddExternalFunctions361(datetime_api);
}
} // namespace AGS3
|