Sqr/Plugins/CollectBooks/CollectBooks.nut

1003 lines
36 KiB
Plaintext

/*
文件名:CollectBooks.nut
路径:Plugins/CollectBooks/CollectBooks.nut
创建日期:2023-07-22 18:33
文件用途:
*/
//HudPro按钮类
class CollectBooksPro extends BasicsDrawTool // obj -- 按钮名称 -- X坐标 -- Y坐标 -- Ani调用路径 -- 宽度 -- 高度
{
obj = null; //Obj对象
State = 0; //按钮状态
ClickEnble = false; //点击效果
ButtonDynamic = false; //动态按钮效果
BaseFrame = null;
CustomClickEnble = false; //自定义点击效果
CustomClickAnifile = null; //自定义点击效果Ani路径
CustomButtonName = null; //自定义点击效果名称
CustomClickFrame = null; //自定义点击效果Ani编号
CustomClickx = null; //自定义点击效果X坐标
CustomClicky = null; //自定义点击效果Y坐标
RectEnble = false; //悬停效果
RectButtonName = null; //悬停名称
RectBaseAnifile = null; //悬停Ani路径
RectFrame = null; //非动态按钮的悬停调用Ani编号
Rectx = null; //悬停X坐标
Recty = null; //悬停Y坐标
ButtonName = null; //按钮名称
x = null; //X坐标
y = null; //Y坐标
BaseAnifile = null; //调用Ani路径
width = null; //可点击宽度
length = null; //可点击高度
Mobj = null; //鼠标对象
//构造函数
constructor(gButtonName, gX, gY, gAnifile, gWidth, gLength, gBaseFrame) {
ButtonName = gButtonName;
x = gX;
y = gY;
BaseAnifile = gAnifile;
width = gWidth;
length = gLength;
BaseFrame = gBaseFrame;
if (getroottable().rawin("MouseObject")) Mobj = getroottable()["MouseObject"];
}
//绘制按钮
function Show() {
if (ClickEnble) //是否开启点击效果
{
if (isLBDown() && State == 0) //按下左键并且按钮处于弹起状态
{
State = 1; //按键进入按下状态
++y;
}
if (!isLBDown() && State == 1) //按下左键并且按钮处于弹起状态
{
State = 0; //按键进入弹起状态
--y;
}
}
if (CustomClickEnble) //是否开启自定义点击效果
{
if (isLBDown()) //按下左键并且按钮处于弹起状态
{
if (!ButtonDynamic) L_sq_DrawImg(CustomClickAnifile, CustomClickFrame, CustomClickx, CustomClicky);
else T_DrawDynamicAni(obj, CustomClickAnifile, CustomClickx, CustomClicky, CustomButtonName);
}
}
if (RectEnble) //开启悬停效果时
{
if ((isInRect() && !isLBDown()) || (isInRect() && !CustomClickEnble)) //如果鼠标悬停的时候 并且没有点击的时候
{
//IMouse.SetMouseTask(44);
if (!ButtonDynamic) L_sq_DrawImg(RectBaseAnifile, RectFrame, Rectx, Recty);
else T_DrawDynamicAni(obj, RectBaseAnifile, Rectx, Recty, RectButtonName);
}
}
if (!isInRect()) //如果鼠标没有悬停的时候
{
//IMouse.SetMouseTask(0);
if (!ButtonDynamic) L_sq_DrawImg(BaseAnifile, BaseFrame, x, y);
else T_DrawDynamicAni(obj, BaseAnifile, x, y, ButtonName);
}
}
//设置自定义点击效果
function SetCustomClickEnble(bool, gButtonName, gX, gY, gAnifile, gFrame) {
CustomClickEnble = bool; //自定义点击效果
CustomClickAnifile = gAnifile; //自定义点击效果Ani路径
CustomButtonName = gButtonName; //自定义点击效果名称
CustomClickFrame = gFrame; //自定义点击效果Ani编号
CustomClickx = gX; //自定义点击效果X坐标
CustomClicky = gY; //自定义点击效果Y坐标
}
//设置悬停效果
function SetRectEnble(bool, gButtonName, gX, gY, gAnifile, gFrame) {
RectEnble = bool; //悬停效果
RectButtonName = gButtonName; //悬停名称
RectBaseAnifile = gAnifile; //悬停Ani路径
RectFrame = gFrame; //非动态按钮的悬停调用Ani编号
Rectx = gX; //悬停X坐标
Recty = gY; //悬停Y坐标
}
//设置动态按钮
function SetClickEnble(bool) {
ButtonDynamic = bool;
}
//设置点击效果
function SetClickEnble(bool) {
ClickEnble = bool;
}
//悬停状态
function isInRect() {
if (sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 5, 5, x, y, width, length)) return true;
else return false;
}
//左键按下状态
function isLBDown() {
if (isInRect() && Mobj.Lb == 1) return true;
else return false;
}
//左键弹起状态
function isLBUp() {
if (isInRect() && Mobj.Lb == 0) return true;
else return false;
}
//左键单击状态
function isLBActive() {
if (isInRect() && Mobj.LbEvent) return true;
else return false;
}
}
//TabTextButtonPro按钮类
class CollectTabTextButtonPro extends BasicsDrawTool // obj -- 按钮名称 -- X坐标 -- Y坐标 -- Ani调用路径 -- 宽度 -- 高度
{
obj = null; //Obj对象
State = 0; //按钮状态
ClickEnble = false; //点击效果
ButtonDynamic = false; //动态按钮效果
SwitchState = false; //复选框是否选中
str = null;
strx = null;
stry = null;
CustomClickEnble = false; //自定义点击效果
CustomClickAnifile = null; //自定义点击效果Ani路径
CustomButtonName = null; //自定义点击效果名称
CustomClickFrame = null; //自定义点击效果Ani编号
CustomClickx = null; //自定义点击效果X坐标
CustomClicky = null; //自定义点击效果Y坐标
RectEnble = false; //悬停效果
RectButtonName = null; //悬停名称
RectBaseAnifile = null; //悬停Ani路径
RectFrame = null; //非动态按钮的悬停调用Ani编号
Rectx = null; //悬停X坐标
Recty = null; //悬停Y坐标
ButtonName = null; //按钮名称
x = null; //X坐标
y = null; //Y坐标
BaseAnifile = null; //调用Ani路径
BaseAnifileFrame = null; //调用的Ani帧数
width = null; //可点击宽度
length = null; //可点击高度
Mobj = null; //鼠标对象
//构造函数
constructor(gObj, gButtonName, gX, gY, gAnifile, gBaseAnifileFrame, gWidth, gLength, gstr, gstrx, gstry) {
obj = gObj;
ButtonName = gButtonName;
x = gX;
y = gY;
BaseAnifile = gAnifile;
BaseAnifileFrame = gBaseAnifileFrame;
width = gWidth;
length = gLength;
str = gstr;
strx = gstrx;
stry = gstry;
if (getroottable().rawin("MouseObject")) Mobj = getroottable()["MouseObject"];
}
//绘制按钮
function Show() {
if (ClickEnble) //是否开启点击效果
{
if (isLBDown() && State == 0) //按下左键并且按钮处于弹起状态
{
State = 1; //按键进入按下状态
//++y;
}
if (!isLBDown() && State == 1) //按下左键并且按钮处于弹起状态
{
State = 0; //按键进入弹起状态
//--y;
}
}
if (CustomClickEnble) //是否开启自定义点击效果
{
if (isLBDown() && SwitchState == false) //按下左键并且按钮处于弹起状态
{
if (!ButtonDynamic) L_sq_DrawImg(CustomClickAnifile, CustomClickFrame, CustomClickx, CustomClicky);
else T_DrawDynamicAni(obj, CustomClickAnifile, CustomClickx, CustomClicky, CustomButtonName);
L_sq_DrawCode(str, CustomClickx + strx, CustomClicky + stry, sq_RGBA(255, 255, 184, 250), 1, 1);
}
}
if (RectEnble && SwitchState == false) //开启悬停效果时
{
if ((isInRect()) || (isInRect() && !CustomClickEnble)) //如果鼠标悬停的时候 并且没有点击的时候
{
//IMouse.SetMouseTask(44);
if (!ButtonDynamic) L_sq_DrawImg(RectBaseAnifile, RectFrame, Rectx, Recty);
else T_DrawDynamicAni(obj, RectBaseAnifile, Rectx, Recty, RectButtonName);
L_sq_DrawCode(str, CustomClickx + strx, CustomClicky + stry, sq_RGBA(255, 255, 184, 250), 1, 1);
}
}
if (!isInRect() && !SwitchState) //如果鼠标没有悬停的时候
{
//IMouse.SetMouseTask(0);
if (!ButtonDynamic) L_sq_DrawImg(BaseAnifile, BaseAnifileFrame, x, y);
else T_DrawDynamicAni(obj, BaseAnifile, x, y, ButtonName);
L_sq_DrawCode(str, CustomClickx + strx, CustomClicky + stry, sq_RGBA(221, 197, 147, 250), 1, 1);
}
if (SwitchState) {
if (!ButtonDynamic) L_sq_DrawImg(CustomClickAnifile, CustomClickFrame, CustomClickx, CustomClicky);
else T_DrawDynamicAni(obj, CustomClickAnifile, CustomClickx, CustomClicky, CustomButtonName);
L_sq_DrawCode(str, CustomClickx + strx, CustomClicky + stry, sq_RGBA(255, 255, 184, 250), 1, 1);
}
}
//设置自定义点击效果
function SetCustomClickEnble(bool, gButtonName, gX, gY, gAnifile, gFrame) {
CustomClickEnble = bool; //自定义点击效果
CustomClickAnifile = gAnifile; //自定义点击效果Ani路径
CustomButtonName = gButtonName; //自定义点击效果名称
CustomClickFrame = gFrame; //自定义点击效果Ani编号
CustomClickx = gX; //自定义点击效果X坐标
CustomClicky = gY; //自定义点击效果Y坐标
}
//设置悬停效果
function SetRectEnble(bool, gButtonName, gX, gY, gAnifile, gFrame) {
RectEnble = bool; //悬停效果
RectButtonName = gButtonName; //悬停名称
RectBaseAnifile = gAnifile; //悬停Ani路径
RectFrame = gFrame; //非动态按钮的悬停调用Ani编号
Rectx = gX; //悬停X坐标
Recty = gY; //悬停Y坐标
}
//设置动态按钮
function SetClickEnble(bool) {
ButtonDynamic = bool;
}
//设置点击效果
function SetClickEnble(bool) {
ClickEnble = bool;
}
//悬停状态
function isInRect() {
if (sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 5, 5, x, y, width, length)) return true;
else return false;
}
//左键按下状态
function isLBDown() {
if (isInRect() && Mobj.Lb == 1) return true;
else return false;
}
//左键弹起状态
function isLBUp() {
if (isInRect() && Mobj.Lb == 0) return true;
else return false;
}
//左键单击状态
function isLBActive() {
if (isInRect() && Mobj.LbEvent) return true;
else return false;
}
}
class CollectBooksWindow extends BasicsDrawTool {
//宽度
Width = null;
//高度
Height = null;
//标题高度
TitleH = null;
//X坐标
X = null;
B_X = null;
//Y坐标
Y = null;
B_Y = null;
YMouseSw = true;
DeBugMode = false;
Mobj = null;
M_Xpos = null;
M_Ypos = null;
constructor(gX, gY, gWidth, gHeight, gTitleH) {
//宽度
Width = gWidth;
//高度
Height = gHeight;
//标题高度
TitleH = gTitleH;
//X坐标
X = gX;
//Y坐标
Y = gY;
if (getroottable().rawin("MouseObject")) Mobj = getroottable()["MouseObject"];
}
//设定鼠标逻辑
function LockMouse() {
if (sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 1, 1, X, Y, Width, Height)) {
IMouse.LockMouseClick();
YMouseSw = false;
} else {
if (YMouseSw == false && sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 1, 1, 0, 0, 800, 600)) {
IMouse.ReleaseMouseClick();
YMouseSw = true;
}
}
}
//设定窗口拖动逻辑
function MoveWindow() {
if (sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 1, 1, X, Y, Width, TitleH)) {
if (Mobj.Lb == 1) {
if (!M_Xpos) M_Xpos = IMouse.GetXPos(); //原始鼠标位置数据
if (!M_Ypos) M_Ypos = IMouse.GetYPos();
if (!B_X) B_X = X; //原始窗口位置
if (!B_Y) B_Y = Y;
X = B_X - (M_Xpos - IMouse.GetXPos());
Y = B_Y - (M_Ypos - IMouse.GetYPos());
} else if (Mobj.Lb == 0) {
M_Xpos = null;
M_Ypos = null;
B_X = null;
B_Y = null;
}
}
}
function Show(obj) {
if (DeBugMode) sq_DrawBox(X, Y, Width, Height, 0xffffffff);
//设定鼠标逻辑
LockMouse();
//设定窗口拖动逻辑
MoveWindow();
}
}
class CollectBooksLineC extends BasicsDrawTool {
TabName = [
"力量 +",
"体力 +",
"智力 +",
"精神 +",
"独立攻击力 +",
"物理攻击力 +",
"魔法攻击力 +",
"物理防御 +",
"魔法防御 +",
"移动速度 +",
"攻击速度 +",
"释放速度 +",
"物理暴击 +",
"魔法暴击 +",
"命中率 +",
"光属性强化 +",
"暗属性强化 +",
"水属性强化 +",
"火属性强化 +",
"全属性强化 +",
"冷却时间 -",
"技能攻击力 + "
]
Name = null;
ItemArr = null;
Completion = null;
AttributeArr = null;
WarringMessage = false;
constructor(gName, gItemArr, gAttributeArr) {
Name = gName;
ItemArr = gItemArr;
AttributeArr = gAttributeArr;
Completion = true;
foreach(v in gItemArr) {
if (!v.IsHave) Completion = false;
}
}
//高级绘制文字(带换行)
function L_sq_DrawCode_Ex(str, x, y, rgba, mb, jc, hl) {
local strarr = [];
if (str.find("\n") == null) L_sq_DrawCode(str, x, y, rgba, mb, jc);
else {
local Bpos = 0;
while (true) {
local Npos = str.find("\n", Bpos);
if (!Npos) {
local strbuff = str.slice(Bpos, str.len());
strarr.append(strbuff);
break;
}
local strbuff = str.slice(Bpos, Npos);
strarr.append(strbuff);
Bpos = Npos + 1;
}
for (local z = 0; z < strarr.len(); z++) {
L_sq_DrawCode(strarr[z], x, y + (z * 14), rgba, mb, jc);
}
}
}
//绘制装备
function DrawItem(X, Y) {
//12个的时候597
//单个长36
local Spacing = (597 - (ItemArr.len() * 36)) / (ItemArr.len() - 1);
for (local i = 0; i < ItemArr.len(); i++) {
L_sq_DrawImg("interface2/yosin/shoujitujian.img", 7, X + 6 + (i * Spacing + (i * 36)), Y + 27);
L_Sq_DrawItem(X + 9 + (i * Spacing + (i * 36)), Y + 30, ItemArr[i].Id, 1, 0, 0, 0);
if (!ItemArr[i].IsHave) {
L_sq_DrawImg("interface2/yosin/shoujitujian.img", 6, X + 9 + (i * Spacing + (i * 36)), Y + 30);
L_sq_DrawImg("interface2/yosin/shoujitujian.img", 6, X + 9 + (i * Spacing + (i * 36)), Y + 30);
L_sq_DrawImg("interface2/yosin/shoujitujian.img", 6, X + 9 + (i * Spacing + (i * 36)), Y + 30);
// L_sq_DrawImg("interface2/yosin/shoujitujian.img", 6, X + 9 + (i * Spacing + (i * 36)), Y + 30);
}
}
}
//绘制属性信息
function DrawAttribute(X, Y) {
local JumpRealLine = 0;
local StrColor = sq_RGBA(174, 174, 174, 250);
if (Completion) StrColor = sq_RGBA(255, 177, 0, 250)
L_sq_DrawImg("interface2/yosin/shoujitujian.img", 10, X + 320, Y + 100 + 34);
for (local i = 0; i < AttributeArr.len(); i++) {
//空属性 跳过绘制并且-1行
if (AttributeArr[i] == 0) {
JumpRealLine++;
continue;
}
L_sq_DrawImg("interface2/yosin/shoujitujian.img", 11, X + 320, Y + 100 + 34 + 11 + ((i - JumpRealLine) * 14));
L_sq_DrawCode(TabName[i] + " " + AttributeArr[i], X + 330, Y + 100 + 34 + 11 + ((i - JumpRealLine) * 14), StrColor, 1, 1);
}
L_sq_DrawImg("interface2/yosin/shoujitujian.img", 12, X + 320, Y + 100 + 34 + 11 + ((AttributeArr.len() - JumpRealLine) * 14));
}
//绘制收集信息
function DrawCompletionInfo(X, Y) {
if (Completion) L_sq_DrawImg("interface2/yosin/shoujitujian.img", 9, X + 628, Y + 34);
else L_sq_DrawImg("interface2/yosin/shoujitujian.img", 8, X + 628, Y + 34);
}
function Show(X, Y) {
//绘制主界面
L_sq_DrawImg("interface2/yosin/shoujitujian.img", 5, X, Y);
//绘制列数名字
L_sq_DrawCode(Name, X + 5, Y + 6, sq_RGBA(255, 177, 0, 250), 1, 1);
//绘制装备
DrawItem(X, Y);
//绘制收集信息
DrawCompletionInfo(X, Y);
//绘制警告信息
if (WarringMessage) L_sq_DrawCode("警告! 此操作可能会导致您失去不想失去的装备,确认无误后再次点击镶嵌.", X + 215, Y + 6, sq_RGBA(225, 6, 2 250), 1, 1);
//绘制镶嵌按钮
local Button = CollectBooksPro("收集图鉴镶嵌", X + 620, Y + 2, "interface2/yosin/shoujitujian.img", 56, 23, 13);
Button.SetRectEnble(true, "收集图鉴镶嵌", X + 620, Y + 2, "interface2/yosin/shoujitujian.img", 14);
Button.SetCustomClickEnble(true, "收集图鉴镶嵌", X + 620, Y + 2, "interface2/yosin/shoujitujian.img", 15);
Button.Show();
local DownOffset = 0;
if (Button.isLBDown()) DownOffset = 1;
L_sq_DrawCode("镶 嵌", X + 631, Y + 7 + DownOffset, sq_RGBA(230, 200, 155, 250), 1, 1);
if (Button.isLBActive()) {
local obj = sq_GetMyMasterCharacter();
obj.sq_PlaySound("CLICK_BUTTON2");
if (!WarringMessage) WarringMessage = true;
else {
local Arrbuf = [];
local Xbuf = [];
local Ybuf = [];
local Spacing = (597 - (ItemArr.len() * 36)) / (ItemArr.len() - 1);
foreach(pos, v in ItemArr) {
if (!v.IsHave) {
Arrbuf.append(v.Id);
Xbuf.append(X + 9 + (pos * Spacing + (pos * 36)));
Ybuf.append(Y + 30);
}
}
if (Arrbuf.len() > 0) {
local T = {
op = 20026077,
equtab = Arrbuf,
equxtab = Xbuf,
equytab = Ybuf,
Page = getroottable()["CollectBooksCObj"].NowPage,
}
SendPack(T);
}
WarringMessage = false;
}
}
}
function ShowStr(X, Y) {
//悬停属性信息
if (sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 1, 1, X + 628, Y + 34, 77, 21)) {
DrawAttribute(X, Y - 180);
}
}
}
class CollectBooksC extends BasicsDrawTool {
Myop = 20026000;
WindowObj = null; //窗口对象
MainState = false; //主状态
X = 34;
Y = 42;
//他人模式
OtherState = false;
BookButton = null;
AbtiButton = null;
BookButtonState = true;
AbtiButtonState = false;
NowPage = 1;
MaxPage = 1;
//页面标题
PageTitle = null;
//收集行对象
CollectBooksLineBuf = null;
CollectLineObject = null;
CollectLineNameObject = null;
CollectLineAttributeObject = null;
CollectAttributeObject = null;
//附加BUFF判断
DgnAddBuff = false;
//镶嵌回调动画
MosaicAnimotionArr = null;
TabName = [
"力量 +",
"体力 +",
"智力 +",
"精神 +",
"独立攻击力 +",
"物理攻击力 +",
"魔法攻击力 +",
"物理防御 +",
"魔法防御 +",
"移动速度 +",
"攻击速度 +",
"释放速度 +",
"物理暴击 +",
"魔法暴击 +",
"命中率 +",
"光属性强化 +",
"暗属性强化 +",
"水属性强化 +",
"火属性强化 +",
"全属性强化 +",
"冷却时间 -",
"技能攻击力 + "
]
//镶嵌动画回调
function MosaicAnimotionCallBack(Chunk) {
// Sout("收到的包: %L", Chunk);
local Buffer = Json_STL("CollectBooksCObjGetInfoCallBackBuffer");
Buffer.Parse(Chunk, 0, false);
local RootTab = getroottable();
if (RootTab.rawin("CollectBooksCObj")) {
local Tobj = RootTab["CollectBooksCObj"];
Tobj.MosaicAnimotionArr = [];
for (local i = 0; i < 15; i++) {
local X = Buffer.Get("Ani->" + i + "->x")
if (!X) break;
local Y = Buffer.Get("Ani->" + i + "->y")
local T = {
Ax = X,
Ay = Y,
}
Tobj.MosaicAnimotionArr.append(T);
}
}
local obj = sq_GetMyMasterCharacter();
obj.sq_PlaySound("DANJIN_GAMBLE_CLASS_A");
}
//获取收集信息回调
function GetCollectInfoCallBack(Chunk) {
local Buffer = Json_STL("CollectBooksCObjGetInfoCallBackBuffer");
Buffer.Parse(Chunk, 0, false);
local RootTab = getroottable();
if (RootTab.rawin("CollectBooksCObj")) {
local Tobj = RootTab["CollectBooksCObj"];
Tobj.PageTitle = {
Name = Buffer.Get("PageTitleName"),
X = Buffer.Get("PageTitleX"),
Y = Buffer.Get("PageTitleY"),
};
Tobj.CollectLineObject = [];
Tobj.CollectLineNameObject = [];
Tobj.CollectLineAttributeObject = [];
Tobj.CollectBooksLineBuf = [0, 0, 0, 0];
Tobj.MaxPage = Buffer.Get("MaxPage");
local Count = Buffer.Get("CollectLineCount");
for (local i = 0; i < Count; i++) {
local AbArr = [];
for (local q = 0; q < 22; q++) {
local AttributeBuffer = Buffer.Get("CollectLineAttribute->" + i + "->buff->" + q);
AbArr.append(AttributeBuffer);
}
Tobj.CollectLineAttributeObject.append(AbArr);
local EquArr = [];
for (local w = 0; w < 12; w++) {
local gName = Buffer.Get("CollectLineDrawS->" + i + "->collectLineDrawList->" + w + "->ItemName");
if (!gName) break;
local gId = Buffer.Get("CollectLineDrawS->" + i + "->collectLineDrawList->" + w + "->ItemId");
local gIsHave = Buffer.Get("CollectLineDrawS->" + i + "->collectLineDrawList->" + w + "->ItemIsHave");
local T = {
Name = gName,
Id = gId,
IsHave = gIsHave,
};
EquArr.append(T);
}
Tobj.CollectLineObject.append(EquArr);
local gLineName = Buffer.Get("CollectLineDrawS->" + i + "->LineName");
Tobj.CollectLineNameObject.append(gLineName);
}
}
}
//获取收集信息
function GetCollectInfo() {
local T = {
op = Myop + 1,
Page = NowPage,
};
SendPack(T);
}
//获取他人收集属性信息
function CheckOtherPlayerCollectBooksInfo(gname) {
local T = {
op = 20026000 + 7,
name = gname
}
local str = Json.Encode(T);
L_sq_SendPackType(130);
L_sq_SendPackWChar(str);
L_sq_SendPack();
}
//获取他人总属性回调
function GetOtherPlayerAttributeInfoCallBack(Chunk) {
local Buffer = Json_STL("CollectBooksCObjGetAttributeInfoCallBackBuffer");
Buffer.Parse(Chunk, 0, false);
local RootTab = getroottable();
if (RootTab.rawin("CollectBooksCObj")) {
local Tobj = RootTab["CollectBooksCObj"];
Tobj.CollectAttributeObject = [];
for (local i = 0; i < 22; i++) {
Tobj.CollectAttributeObject.append(Buffer.Get("buffs->" + i));
}
Tobj.BookButtonState = false;
Tobj.AbtiButtonState = true;
Tobj.MainState = true;
Tobj.OtherState = true;
L_NewWindows("Lenheart", 170, 0x65535);
local W = sq_GetPopupWindowMainCotrol(170);
W.SetVisible(false);
W.SetEnable(false);
}
}
//获取总属性回调
function GetAttributeInfoCallBack(Chunk) {
local Buffer = Json_STL("CollectBooksCObjGetAttributeInfoCallBackBuffer");
Buffer.Parse(Chunk, 0, false);
local RootTab = getroottable();
if (RootTab.rawin("CollectBooksCObj")) {
local Tobj = RootTab["CollectBooksCObj"];
Tobj.CollectAttributeObject = [];
for (local i = 0; i < 22; i++) {
Tobj.CollectAttributeObject.append(Buffer.Get("buffs->" + i));
}
}
}
//获取总属性
function GetAttributeInfo() {
local T = {
op = Myop + 5,
};
SendPack(T);
}
constructor() {
CollectBooksLineBuf = [0, 0, 0, 0];
//注册获取收集信息回调
Pack_Control.rawset(Myop + 2, GetCollectInfoCallBack);
Pack_Control.rawset(Myop + 6, GetAttributeInfoCallBack);
Pack_Control.rawset(Myop + 8, GetOtherPlayerAttributeInfoCallBack);
Pack_Control.rawset(Myop + 104, MosaicAnimotionCallBack);
//获取收集信息
GetCollectInfo();
//获取属性信息
GetAttributeInfo();
}
//绘制主界面
function DrawMain(obj) {
//绘制主界面
L_sq_DrawImg("interface2/yosin/shoujitujian.img", 0, X, Y);
BookButton = CollectTabTextButtonPro(obj, "收集图鉴收集", X + 5, Y + 10, "interface2/yosin/shoujitujian.img", 1, 70, 20, "收集概览", 10, 5);
BookButton.SwitchState = BookButtonState;
BookButton.SetRectEnble(true, "a收集图鉴收集", X + 5, Y + 10, "interface2/yosin/shoujitujian.img", 2);
BookButton.SetCustomClickEnble(true, "a收集图鉴收集", X + 5, Y + 9, "interface2/yosin/shoujitujian.img", 3);
//收集页
BookButton.Show();
if (BookButton.isLBActive() && !OtherState) {
obj.sq_PlaySound("CLICK_BUTTON2");
BookButtonState = true;
AbtiButtonState = false;
}
AbtiButton = CollectTabTextButtonPro(obj, "收集图鉴属性", X + 75, Y + 10, "interface2/yosin/shoujitujian.img", 1, 70, 20, "属性概览", 10, 5);
AbtiButton.SwitchState = AbtiButtonState;
AbtiButton.SetRectEnble(true, "a收集图鉴属性", X + 75, Y + 10, "interface2/yosin/shoujitujian.img", 2);
AbtiButton.SetCustomClickEnble(true, "a收集图鉴属性", X + 75, Y + 10, "interface2/yosin/shoujitujian.img", 3);
//收集页
AbtiButton.Show();
if (AbtiButton.isLBActive() && !OtherState) {
obj.sq_PlaySound("CLICK_BUTTON2");
BookButtonState = false;
AbtiButtonState = true;
}
//绘制分页线
L_sq_DrawImg("interface2/yosin/shoujitujian.img", 4, X + 3, Y + 30);
//属性显示页
if (AbtiButtonState && CollectAttributeObject) {
for (local r = 0; r < 22; r++) {
L_sq_DrawCode(TabName[r] + " " + CollectAttributeObject[r], X + 20 + ((r / 10) * 170), Y + 64 + ((r % 10) * 17), sq_RGBA(255, 255, 255, 250), 1, 1);
}
}
//收集概览显示页
if (BookButtonState && PageTitle && CollectLineObject) {
L_sq_DrawCode(PageTitle.Name, X + PageTitle.X, Y + PageTitle.Y, sq_RGBA(184, 249, 114, 250), 2, 1);
for (local i = 0; i < CollectLineObject.len(); i++) {
if (CollectBooksLineBuf[i] == 0)
CollectBooksLineBuf[i] = CollectBooksLineC(CollectLineNameObject[i], CollectLineObject[i], CollectLineAttributeObject[i]);
CollectBooksLineBuf[i].Show(X + 14, Y + 60 + (i * 80));
//L_sq_DrawImg("interface2/yosin/shoujitujian.img", 5, X + 14, Y + 60 + (i * 80));
}
local LeftButton = CollectBooksPro("收集图鉴左翻页", X + 310, Y + 370, "interface2/yosin/shoujitujian.img", 23, 23, 16);
LeftButton.SetRectEnble(true, "收集图鉴左翻页", X + 310, Y + 370 - 2, "interface2/yosin/shoujitujian.img", 17);
LeftButton.SetCustomClickEnble(true, "收集图鉴左翻页", X + 310, Y + 370 - 1, "interface2/yosin/shoujitujian.img", 18);
LeftButton.Show();
if (LeftButton.isLBActive()) {
obj.sq_PlaySound("CLICK_BUTTON2");
if (NowPage > 1)
NowPage--;
local T = {
op = Myop + 1,
Page = NowPage,
};
SendPack(T);
}
L_sq_DrawCode(NowPage + " / " + MaxPage, X + 350, Y + 374, sq_RGBA(230, 200, 155, 250), 1, 1);
local RightButton = CollectBooksPro("收集图鉴右翻页", X + 390, Y + 370, "interface2/yosin/shoujitujian.img", 23, 23, 19);
RightButton.SetRectEnble(true, "收集图鉴右翻页", X + 390, Y + 370 - 2, "interface2/yosin/shoujitujian.img", 20);
RightButton.SetCustomClickEnble(true, "收集图鉴右翻页", X + 390, Y + 370 - 1, "interface2/yosin/shoujitujian.img", 21);
RightButton.Show();
if (RightButton.isLBActive()) {
obj.sq_PlaySound("CLICK_BUTTON2");
if (NowPage < MaxPage)
NowPage++;
local T = {
op = Myop + 1,
Page = NowPage,
};
SendPack(T);
}
for (local w = 0; w < 4; w++) {
if (CollectBooksLineBuf[w] != 0) CollectBooksLineBuf[w].ShowStr(X + 14, Y + 60 + (w * 80));
}
//如果镶嵌动画存在
if (MosaicAnimotionArr) {
local AnimotionLen = MosaicAnimotionArr.len();
for (local ai = 0; ai < AnimotionLen; ai++) {
local ani = T_DrawDynamicAni(obj, "common/collectbooks/iconslot_01.ani", MosaicAnimotionArr[ai].Ax, MosaicAnimotionArr[ai].Ay, "CollectBooksAnimotions" + ai);
if (sq_IsEnd(ani)) {
sq_Rewind(ani);
if (ai == AnimotionLen - 1) {
MosaicAnimotionArr = null;
GetCollectInfo();
}
}
}
}
}
}
//附加属性
function AddAb(obj) {
if (sq_GetCurrentModuleType() == 3) {
if (!CollectAttributeObject) return;
if (DgnAddBuff == false) {
DgnAddBuff = true;
local appendage = CNSquirrelAppendage.sq_AppendAppendage(obj, obj, -1, false, "appendage/collectbooks/collectbooks.nut", true);
CNSquirrelAppendage.sq_Append(appendage, obj, obj);
local change_appendage = appendage.sq_getChangeStatus("Yosin_collectbooksDgnBuff");
if (!change_appendage) {
change_appendage = appendage.sq_AddChangeStatusAppendageID(obj, obj, 0,
0,
false, 0, 0);
}
if (change_appendage) {
change_appendage.clearParameter();
//print(WearSlotM.Item.TabName[0]);
foreach(Key, Value in CollectAttributeObject) {
if (Key == 0) change_appendage.addParameter(0, false, Value.tofloat());
else if (Key == 1) change_appendage.addParameter(3, false, Value.tofloat());
else if (Key == 2) change_appendage.addParameter(2, false, Value.tofloat());
else if (Key == 3) change_appendage.addParameter(1, false, Value.tofloat());
else if (Key == 4) change_appendage.addParameter(53, false, Value.tofloat());
else if (Key == 5) change_appendage.addParameter(4, false, Value.tofloat());
else if (Key == 6) change_appendage.addParameter(31, false, Value.tofloat());
else if (Key == 7) change_appendage.addParameter(5, false, Value.tofloat());
else if (Key == 8) change_appendage.addParameter(32, false, Value.tofloat());
else if (Key == 9) change_appendage.addParameter(11, false, Value.tofloat());
else if (Key == 10) change_appendage.addParameter(10, false, Value.tofloat());
else if (Key == 11) change_appendage.addParameter(12, false, Value.tofloat());
else if (Key == 12) change_appendage.addParameter(15, false, Value.tofloat() / 10.0);
else if (Key == 13) change_appendage.addParameter(16, false, Value.tofloat() / 10.0);
else if (Key == 14) change_appendage.addParameter(33, false, 0 - (Value.tofloat() / 10.0));
else if (Key == 15) change_appendage.addParameter(45, false, Value.tofloat());
else if (Key == 16) change_appendage.addParameter(44, false, Value.tofloat());
else if (Key == 17) change_appendage.addParameter(43, false, Value.tofloat());
else if (Key == 18) change_appendage.addParameter(42, false, Value.tofloat());
else if (Key == 19) change_appendage.addParameter(46, false, Value.tofloat());
else if (Key == 20) {
local sss = 0 - ((Value.tofloat() / 100.00));
change_appendage.addParameter(CHANGE_STATUS_TYPE_COOLTIME_DECLINE, false, sss);
} else if (Key == 21) {
if (getroottable().rawin("LenheartCurrentModuleDamageRate")) {
getroottable().rawset("LenheartCurrentModuleDamageRate", getroottable()["LenheartCurrentModuleDamageRate"] + Value);
} else {
getroottable().rawset("LenheartCurrentModuleDamageRate", Value);
}
}
}
}
}
} else {
DgnAddBuff = false;
}
}
//开启界面回调
function OpenClassCallBack() {
local obj = sq_GetMyMasterCharacter();
obj.sq_PlaySound("CLICK_BUTTON1");
L_NewWindows("Lenheart", 170, 0x65535);
local W = sq_GetPopupWindowMainCotrol(170);
W.SetVisible(false);
W.SetEnable(false);
//获取收集信息
GetCollectInfo();
//获取属性信息
GetAttributeInfo();
}
//绘制入口
function Draw(obj) {
if (MainState) {
if (WindowObj) {
DrawMain(obj);
WindowObj.Show(obj);
X = WindowObj.X;
Y = WindowObj.Y;
} else {
WindowObj = CollectBooksWindow(X, Y, 721, 399, 10); //坐标 大小 标题栏高度
//WindowObj.DeBugMode = true;
}
} else {
if (WindowObj && WindowObj.YMouseSw == false) {
IMouse.ReleaseMouseClick();
WindowObj.YMouseSw = true;
WindowObj = null;
}
}
}
//逻辑入口
function Proc(obj) {
AddAb(obj);
if (obj.isDead()) DgnAddBuff = false;
if (KeyPressNB.isKeyPress(48, "CollectBooksCloseKey")) {
MainState = false;
OtherState = false;
}
}
}
function CollectBooks(obj) {
local RootTab = getroottable();
if (!RootTab.rawin("CollectBooksCObj")) {
local Cobj = CollectBooksC();
RootTab.rawset("CollectBooksCObj", Cobj);
EventIcon("收集图鉴", 121, 121, Cobj);
PlayerEachIcon("查看收集信息", Cobj.CheckOtherPlayerCollectBooksInfo);
} else {
RootTab["CollectBooksCObj"].Proc(obj);
RootTab["CollectBooksCObj"].Draw(obj);
}
}
if (getroottable().rawin("LenheartFuncTab")) {
getroottable()["LenheartFuncTab"].rawset("CollectBooksFunc", CollectBooks);
} else {
local T = {};
T.rawset("CollectBooksFunc", CollectBooks);
getroottable().rawset("LenheartFuncTab", T);
}