Rindro-Sqr/Project/AradPass/AradPass_Quest.nut

431 lines
13 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
文件名:AradPass_Quest.nut
路径:Project/AradPass/AradPass_Quest.nut
创建日期:2024-08-18 22:57
文件用途:战令任务页
*/
class AradPass_Quest_ItemC extends LenheartNewUI_Windows {
//调试模式
// DeBugMode = true;
//不是窗口
// NoWindow = true;
//是否可见
Visible = false;
//信息
Info = null;
//任务奖励
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
Childrens = [];
LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
//注册控件
RegisterWidget();
}
function ResetFocus() {
}
function RegisterWidget() {
//完成按钮
local ActiveButton = LenheartNewUI_ButtonText(458, 3, 15, "完成");
ActiveButton.OnClick = function() {
Info.op <- 20059033;
SendPackEx(Info);
}.bindenv(this);
ActiveButton.SetCallBackFunc(function(Button) {
//判断是否完成
if (Info.SuccessState) {
Button.TextStr = "已完成";
Button.State = 8;
Button.SetTextOffset(0, 1);
Button.SetTextColor(sq_RGBA(185, 148, 96, 150));
} else {
if (Info.NowSuccessCount >= Info.MaxSuccessCount) {
Button.State = 0;
} else Button.State = 8;
Button.TextStr = "完 成";
Button.SetTextOffset(3, 1);
Button.SetTextColor(sq_RGBA(185, 148, 96, 255));
}
}.bindenv(this))
AddChild(ActiveButton);
}
//绘制主界面
function DrawMain(obj) {
if (!Info) return;
local Ala = 250;
if (Info.SuccessState) Ala = 150;
//绘制任务名字
L_sq_DrawCode(Info.QuestExplain, X + 20, Y + 8, sq_RGBA(179, 169, 135, Ala), 1, 1);
//绘制完成次数
local SuccessStr = Info.NowSuccessCount + " / " + Info.MaxSuccessCount;
L_sq_DrawCode(SuccessStr, X + 296 - LenheartTextClass.GetStringLength(SuccessStr) / 2, Y + 8, sq_RGBA(179, 169, 135, Ala), 1, 1);
//绘制经验值
L_sq_DrawCode(Info.Experience.tostring(), X + 394 - LenheartTextClass.GetStringLength(Info.Experience.tostring()) / 2, Y + 8, sq_RGBA(179, 169, 135, Ala), 1, 1);
}
function Show(obj) {
DrawMain(obj);
//动态设置这里要先刷新一下坐标
LenheartNewUI_Windows.SyncPos(X, Y)
LenheartNewUI_Windows.Show(obj);
}
//逻辑入口
function Proc(obj) {
LenheartNewUI_Windows.SyncPos(X, Y);
}
}
class AradPass_QuestC extends LenheartNewUI_Windows {
//调试模式
// DeBugMode = true;
//不是窗口
// NoWindow = true;
//是否可见
Visible = false;
QuestTitle = null;
//页面
Page = 0;
//任务集合
QuestItemList = null;
//每日任务数组
DailyTasks = null;
//重复任务数组
RepeatingTasks = null;
//赛季任务数组
SeasonTasks = null;
//任务完成提示
QuestSuccessTips = null;
QuestTips = false;
QuestWheelNow = 0;
QuestWheelMax = 0;
ExpLimitMax = 0;
ExpLimit = 0;
function GetPlayerQuest() {
local T = {
op = 20059031
}
SendPackEx(T);
}
function GetPlayerQuestCallBack(Chunk) {
local Jso = Json.Decode(Chunk);
DailyTasks = Jso.task[0];
RepeatingTasks = Jso.task[1];
SeasonTasks = Jso.task[2];
ExpLimitMax = Jso.ExpLimitMax;
ExpLimit = Jso.ExpLimit;
QuestSuccessTips = [0, 0, 0];
if (Parent && Parent.TabSuccessTips) Parent.TabSuccessTips[1] = 0;
foreach(Pos, Value in Jso.task) {
foreach(QuestObject in Value) {
if (QuestObject.SuccessState == 0) {
if (QuestObject.NowSuccessCount >= QuestObject.MaxSuccessCount) {
QuestSuccessTips[Pos] = 1;
if (Parent && Parent.TabSuccessTips)Parent.TabSuccessTips[1] = 1;
break;
}
}
}
}
InitQuestItem();
}
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
Childrens = [];
QuestTitle = [];
QuestItemList = [
[],
[],
[]
];
//注册控件
RegisterWidget();
Pack_Control.rawset(20059032, GetPlayerQuestCallBack.bindenv(this));
LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
}
//因为要重载LenheartNewUI_Windows的构造函数
function ResetFocus() {
}
function ChangePage(ToPage) {
//如果就是当前页面直接返回
// if (ToPage == Page) return;
foreach(ButtonObj in QuestTitle) {
ButtonObj.State = 0;
}
Page = ToPage;
QuestTitle[ToPage].State = 1;
//先移除所有
for (local i = 0; i< 3; i++) {
foreach(winobj in QuestItemList[i]) {
winobj.Visible = false;
RemoveChild(winobj.ObjectId);
}
}
//添加该页应该显示的
for (local i = 0; i< 3; i++) {
if (i == ToPage) {
foreach(winobj in QuestItemList[ToPage]) {
winobj.Visible = true;
AddChild(winobj);
}
}
}
//设定页面滚轮阈值
{
local QuestTasks = null;
//每日
if (Page == 0) {
//每日任务数组
QuestTasks = DailyTasks;
}
//重复
else if (Page == 1) {
//重复任务数组
QuestTasks = RepeatingTasks;
}
//赛季
else {
//赛季任务数组
QuestTasks = SeasonTasks;
}
QuestWheelMax = QuestTasks.len();
}
}
function RegisterWidget() {
// //关闭按钮
// local CloseButton = LenheartNewUI_BaseButton(278, 0, 11, 12, "interface/lenheartwindowcommon.img", 276);
// CloseButton.OnClick = function() {
// this.Visible = false;
// }.bindenv(this);
// Childrens.append(CloseButton);
local Tabbars1 = LenheartNewUI_TabbarsText(12, 213, "每日任务");
Tabbars1.State = 1;
Tabbars1.SetTextOffset(9, 3);
AddChild(Tabbars1);
Tabbars1.OnClick = function() {
ChangePage(0);
}.bindenv(this);
QuestTitle.append(Tabbars1);
local Tabbars2 = LenheartNewUI_TabbarsText(74, 213, "重复任务");
AddChild(Tabbars2);
Tabbars2.SetTextOffset(9, 3);
Tabbars2.OnClick = function() {
ChangePage(1);
}.bindenv(this);
QuestTitle.append(Tabbars2);
local Tabbars3 = LenheartNewUI_TabbarsText(136, 213, "赛季任务");
AddChild(Tabbars3);
Tabbars3.SetTextOffset(9, 3);
Tabbars3.OnClick = function() {
ChangePage(2);
}.bindenv(this);
QuestTitle.append(Tabbars3);
//全部领取按钮
local ClaimAllButton = LenheartNewUI_ButtonText(472, 452, 15, "全部领取");
ClaimAllButton.SetFrame(null, 323);
ClaimAllButton.SetTextOffset(-7, 1);
ClaimAllButton.OnClick = function() {
local T = {
op = 20059035
}
SendPackEx(T);
}.bindenv(this);
AddChild(ClaimAllButton);
}
function OpenCallBack() {
GetPlayerQuest();
}
//创建任务Item
function InitQuestItem() {
//清除原有项目
foreach(ItemList in QuestItemList) {
foreach(Window in ItemList) {
RemoveChild(Window.ObjectId);
Window.DestroyWindow();
}
}
//先移除所有
for (local i = 0; i< 3; i++) {
foreach(winobj in QuestItemList[i]) {
winobj.Visible = false;
RemoveChild(winobj.ObjectId);
}
}
//清空缓存
QuestItemList = [
[],
[],
[]
];
for (local i = 0; i< 3; i++) {
local QuestTasks = null;
//每日
if (i == 0) {
//每日任务数组
QuestTasks = DailyTasks;
}
//重复
else if (i == 1) {
//重复任务数组
QuestTasks = RepeatingTasks;
}
//赛季
else {
//赛季任务数组
QuestTasks = SeasonTasks;
}
foreach(Pos, Value in QuestTasks) {
local QuestItem = AradPass_Quest_ItemC("AradPassQuestItem_" + i + "_" + Pos, X - 5000, Y, 536, 31, 0);
QuestItem.Info = Value;
QuestItemList[i].append(QuestItem);
}
}
ChangePage(Page);
}
//绘制主界面
function DrawMain(obj) {
L_sq_DrawImg("interface2/ui/aradpass/chn/aradpass.img", 43, X + 11, Y - 210 + 50 + 162);
L_sq_DrawImg("interface2/ui/aradpass/chn/aradpass.img", 38, X + 13, Y - 210 + 50 + 184);
L_sq_DrawCode("任务内容", X + 120, Y + 7 + 21, sq_RGBA(179, 169, 135, 255), 1, 1);
L_sq_DrawCode("完成次数", X + 288, Y + 7 + 21, sq_RGBA(179, 169, 135, 255), 1, 1);
L_sq_DrawCode("经验值", X + 388, Y + 7 + 21, sq_RGBA(179, 169, 135, 255), 1, 1);
L_sq_DrawCode("状态", X + 492, Y + 7 + 21, sq_RGBA(179, 169, 135, 255), 1, 1);
//绘制悬停提示
if (sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 1, 1, X + 25, Y - 210 + 456, 16, 16)) {
L_sq_DrawImg("interface/lenheartwindowcommon.img", 240, X + 25, Y - 210 + 456);
QuestTips = true;
} else {
L_sq_DrawImg("interface/lenheartwindowcommon.img", 239, X + 25, Y - 210 + 456);
QuestTips = false;
}
// 周获取的经验
L_sq_DrawCode("每周重复任务经验获取上限 " + ExpLimit + "/" + ExpLimitMax, X + 40 + 7, Y - 210 + 7 + 451, sq_RGBA(179, 169, 135, 255), 1, 1);
}
//上层绘制
function DrawTop(obj) {
//绘制标签栏的感叹号
foreach(Pos, Value in QuestTitle) {
if (QuestSuccessTips && QuestSuccessTips.len() == 3) {
if (QuestSuccessTips[Pos] == 1) {
L_sq_DrawImg("interface/Lenheartwindowcommon.img", 301, X + 64 + (Pos * 62), Y + 6, 0, sq_RGBA(255, 255, 255, 210), 0.8, 0.8);
}
}
}
//任务提示
if (QuestTips) {
L_sq_DrawWindow(X + 40, Y - 210 + 350, 224, 100, "interface/lenheartwindowcommon.img", 97, 11, 12, 11, 13);
local QuestTipsStr = "每周可以通过完成重复任务获得的最大经验值。\n达到每周经验获取上限后无法进行重复任务。\n通过每日任务以及赛季任务获得的经验值不受每周经验获取上限的限制。\n每周星期四将初始化每周经验获取量。\n每周四凌晨6点初始化重复任务的进度并删除未领取的重复任务经验值。";
local QuestTipsArray = L_sq_GetStringDrawArray(QuestTipsStr, 251);
foreach(Pos, va in QuestTipsArray) {
// Sout("文本内容嗯: %L", va);
L_sq_DrawCode(va, X + 40 + 7, Y - 210 + 7 + 350 + (Pos * 16), 0xFFFFFFFF, 1, 1);
}
}
}
function Show(obj) {
DrawMain(obj);
LenheartNewUI_Windows.Show(obj);
DrawTop(obj);
}
//override
//鼠标滚轮事件回调
function OnMouseWheel(Flag, MousePos_X, MousePos_Y) {
if (Flag) {
if (QuestWheelNow > 0) QuestWheelNow--;
}
if (!Flag) {
if (QuestWheelNow< QuestWheelMax - 6) QuestWheelNow++;
}
//调用原生方法
LenheartNewUI_Windows.OnMouseWheel(Flag, MousePos_X, MousePos_Y);
}
//逻辑入口
function Proc(obj) {
LenheartNewUI_Windows.SyncPos(X, Y - 210);
if (Parent && Parent.Visible && Parent.PageSelectM == 1) {
Visible = true;
X = Parent.X;
Y = Parent.Y + 210;
} else {
Visible = false;
}
foreach(Pos, winobj in QuestItemList[Page]) {
if (Pos >= QuestWheelNow && Pos <= QuestWheelNow + 5) {
local OffsetPos = Pos - QuestWheelNow;
winobj.X = X + 12;
winobj.Y = Y - 210 + 50 + 184 + 25 + (OffsetPos * 31);
} else {
winobj.X = X + 12 - 5000;
}
}
//主动调用子对象窗口的Proc
foreach(Object in Childrens) {
if (Object instanceof LenheartNewUI_Windows)
Object.Proc(obj);
}
}
}
// getroottable().rawdelete("AradPass_Obj");