DOF/sqr/Core/BaseTool/BaseTool.nut

53 lines
1.1 KiB
Plaintext

/*
* @函数作用: 输出函数
* @参数 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
*/
// function sq_DeepCopy(original) {
// local Ret = Json.Encode(original);
// Ret = Json.Decode(Ret);
// return Ret;
// }
function sq_DeepCopy(original) {
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;
}
/*
* @函数作用: 返回颜色的十六进制数
*/
function sq_RGBA(R, G, B, A) {
R = R.tointeger();
G = G.tointeger();
B = B.tointeger();
A = A.tointeger();
return (A << 24) + (R << 16) + (G << 8) + B;
}