DOF/sqr/Core/BaseTool/BaseTool.nut

53 lines
1.1 KiB
Plaintext
Raw Normal View History

2024-12-11 15:08:57 +08:00
/*
* @函数作用: 输出函数
* @参数 any
*/
function print(Object) {
switch (typeof Object) {
case "table":
case "array": {
local str = Json.Encode(Object);
OutPutTable(str);
break;
}
case "string":
case "integer": {
output(Object);
break;
}
default:
output(Object);
break;
}
}
/*
* @函数作用: 深拷贝Table
*/
2024-12-15 20:15:48 +08:00
// function sq_DeepCopy(original) {
// local Ret = Json.Encode(original);
// Ret = Json.Decode(Ret);
// return Ret;
// }
2024-12-11 15:08:57 +08:00
function sq_DeepCopy(original) {
2024-12-15 20:15:48 +08:00
local RetTable = clone(original);
foreach(Key, Value in original) {
if (typeof Value == "table") {
RetTable[Key] = sq_DeepCopy(Value);
} else if (typeof Value == "array") {
RetTable[Key] = sq_DeepCopy(Value);
}
}
return RetTable;
2024-12-11 15:08:57 +08:00
}
/*
* @函数作用: 返回颜色的十六进制数
*/
function sq_RGBA(R, G, B, A) {
2025-02-20 13:53:36 +08:00
R = R.tointeger();
G = G.tointeger();
B = B.tointeger();
A = A.tointeger();
2024-12-11 15:08:57 +08:00
return (A << 24) + (R << 16) + (G << 8) + B;
}