/* 文件名:MarrySystem.nut 路径:Project/MarrySystem/MarrySystem.nut 创建日期:2024-10-01 00:01 文件用途:结婚系统 */ dofile("sqr/Project/MarrySystem/MarrySystem_Request.nut"); dofile("sqr/Project/MarrySystem/MarrySystem_Response.nut"); dofile("sqr/Project/MarrySystem/MarrySystem_Preparation.nut"); dofile("sqr/Project/MarrySystem/MarrySystem_OpenAuditoriumList.nut"); dofile("sqr/Project/MarrySystem/MarrySystem_ActionAni.nut"); dofile("sqr/Project/MarrySystem/MarrySystem_Room.nut"); class MarrySystemC extends Rindro_BaseToolClass { //调试模式 // DeBugMode = true; //不是窗口 // NoWindow = true; //是否可见 // Visible = false; //包头 OP = 20078000; //配置 Config = null; //结婚状态 MarryState = 0; //申请订婚窗口 RequestWindow = null; //答复窗口 ResponseWindow = null; //准备婚礼窗口 PreparationWindow = null; //礼堂列表窗口 OpenAuditoriumList = null; //婚礼演出脚本对象 MarriageScript = null; //我的结婚时间 MyMarryTime = null; MyMarryTimeFlag = null; //婚房逻辑 MarrySystemRoomObject = null; //请求配置 function GetConfig() { SendPackEx({ op = OP + 777 }); } function GetConfigCallBack(Chunk) { local Jso = Json.Decode(Chunk); Config = {}; Config.Town <- Jso.town; Config.Area <- Jso.area; } //查看自己是否有结婚 function CheckMarryState() { SendPackEx({ op = OP + 9 }); } function CheckMarryStateCallBack(Chunk) { local Jso = Json.Decode(Chunk); MarryState = Jso.Flag; InitNpcEachButton(); } //收到结婚请求 function RequestMarryCallBack(Chunk) { local Jso = Json.Decode(Chunk); ResponseWindow.applicantName = Jso.applicantName; ResponseWindow.applicantCid = Jso.applicantCid; ResponseWindow.applicantUid = Jso.applicantUid; ResponseWindow.Visible = true; ResponseWindow.ResetFocus(); } //打开准备婚礼窗口 function OpenPreparationWindowCallBack(Chunk) { local Jso = Json.Decode(Chunk); PreparationWindow.Name1 = Jso.MyName; PreparationWindow.Name2 = Jso.TargetName; PreparationWindow.Visible = true; PreparationWindow.ResetFocus(); } //打开礼堂列表窗口 function OpenAuditoriumListWindowCallBack(Chunk) { local Jso = Json.Decode(Chunk); OpenAuditoriumList.List = Jso.info; OpenAuditoriumList.Visible = true; OpenAuditoriumList.ResetFocus(); } //进入礼堂信息包 function OnEnterAuditoriumInfoCallBack(Chunk) { local Jso = Json.Decode(Chunk); MyMarryTime = Jso.time; MyMarryTimeFlag = Clock(); } //结婚动画包 function ActionCallBack(Chunk) { local Jso = Json.Decode(Chunk); MarriageScript.Init(Jso.info); } constructor() { RequestWindow = MarrySystem_RequestC("结婚系统_申请订婚窗口", ((getroottable().Rindro_Scr_Width - 329) / 2).tointeger(), 180, 329, 166, 16); ResponseWindow = MarrySystem_ResponseC("结婚系统_订婚答复窗口", ((getroottable().Rindro_Scr_Width - 329) / 2).tointeger(), 180, 329, 166, 16); PreparationWindow = MarrySystem_PreparationC("结婚系统_准备婚礼窗口", ((getroottable().Rindro_Scr_Width - 256) / 2).tointeger(), 100, 260, 374, 28); OpenAuditoriumList = MarrySystem_OpenAuditoriumListC("结婚系统_礼堂列表窗口", ((getroottable().Rindro_Scr_Width - 474) / 2).tointeger(), 100, 474, 354, 28); MarriageScript = MarrySystem_ActionAniC(); MarrySystemRoomObject = MarrySystem_Room(); OnSetCharacter_Control.MarrySystem <- OnSetCharacter.bindenv(this); Pack_Control.rawset(OP + 10, CheckMarryStateCallBack.bindenv(this)); Pack_Control.rawset(OP + 4, RequestMarryCallBack.bindenv(this)); Pack_Control.rawset(OP + 12, OpenPreparationWindowCallBack.bindenv(this)); Pack_Control.rawset(OP + 20, OpenAuditoriumListWindowCallBack.bindenv(this)); Pack_Control.rawset(OP + 22, OnEnterAuditoriumInfoCallBack.bindenv(this)); Pack_Control.rawset(OP + 34, ActionCallBack.bindenv(this)); Pack_Control.rawset(OP + 778, GetConfigCallBack.bindenv(this)); GetConfig(); CheckMarryState(); } 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); } //注册NPC按钮 function InitNpcEachButton() { local EachManager = getroottable()["L_Each_Obj"]; //先清空注册 EachManager.RemoveEachForNpc(20013); //没结婚注册申请结婚按钮 if (MarryState == 0) { EachManager.AddEachForNpc(20013, function(SThis) { //关闭按钮 local ApplyEngagementButton = LenheartNewUI_Each_BaseButton(0, 0, 100, 21, "interface2/popup_menu/popup_back.img", 3); ApplyEngagementButton.Icon = "interface2/popup_menu/popup_icon_cn.img"; ApplyEngagementButton.IconIdx = 10; ApplyEngagementButton.Str = "申请结婚"; ApplyEngagementButton.OnClick = function(Button) { Button.Parent.CloseAllEach(); Button.Parent.CloseWindow(); RequestWindow.Visible = true; RequestWindow.ResetFocus(); }.bindenv(this); ApplyEngagementButton.SetCallBackFunc(function(Button) {}) SThis.AddChild(ApplyEngagementButton); }.bindenv(this)); } //已订婚 未结婚 else if (MarryState == 1) { EachManager.AddEachForNpc(20013, function(SThis) { //关闭按钮 local ApplyEngagementButton = LenheartNewUI_Each_BaseButton(0, 0, 100, 21, "interface2/popup_menu/popup_back.img", 3); ApplyEngagementButton.Icon = "interface2/popup_menu/popup_icon_cn.img"; ApplyEngagementButton.IconIdx = 12; ApplyEngagementButton.Str = "退婚"; ApplyEngagementButton.OnClick = function(Button) { Button.Parent.CloseAllEach(); Button.Parent.CloseWindow(); local T = { op = OP + 7, } SendPackEx(T); }.bindenv(this); ApplyEngagementButton.SetCallBackFunc(function(Button) {}) SThis.AddChild(ApplyEngagementButton); //关闭按钮 local ApplyEngagementButton = LenheartNewUI_Each_BaseButton(0, 0, 100, 21, "interface2/popup_menu/popup_back.img", 3); ApplyEngagementButton.Icon = "interface2/popup_menu/popup_icon_cn.img"; ApplyEngagementButton.IconIdx = 11; ApplyEngagementButton.Str = "举办婚礼"; ApplyEngagementButton.OnClick = function(Button) { Button.Parent.CloseAllEach(); Button.Parent.CloseWindow(); local T = { op = OP + 11, } SendPackEx(T); }.bindenv(this); ApplyEngagementButton.SetCallBackFunc(function(Button) {}) SThis.AddChild(ApplyEngagementButton); }.bindenv(this)); } //等待举行婚礼 else if (MarryState == 2) { EachManager.AddEachForNpc(20013, function(SThis) { //关闭按钮 local ApplyEngagementButton = LenheartNewUI_Each_BaseButton(0, 0, 100, 21, "interface2/popup_menu/popup_back.img", 3); ApplyEngagementButton.Icon = "interface2/popup_menu/popup_icon_cn.img"; ApplyEngagementButton.IconIdx = 13; ApplyEngagementButton.Str = "进入礼堂"; ApplyEngagementButton.OnClick = function(Button) { Button.Parent.CloseAllEach(); Button.Parent.CloseWindow(); local T = { op = OP + 15, room = -1 } SendPackEx(T); }.bindenv(this); ApplyEngagementButton.SetCallBackFunc(function(Button) {}) SThis.AddChild(ApplyEngagementButton); }.bindenv(this)); EachManager.AddEachForNpc(20014, function(SThis) { //关闭按钮 local ApplyEngagementButton = LenheartNewUI_Each_BaseButton(0, 0, 100, 21, "interface2/popup_menu/popup_back.img", 3); ApplyEngagementButton.Icon = "interface2/popup_menu/popup_icon_cn.img"; ApplyEngagementButton.IconIdx = 14; ApplyEngagementButton.Str = "离开礼堂"; ApplyEngagementButton.OnClick = function(Button) { Button.Parent.CloseAllEach(); Button.Parent.CloseWindow(); local T = { op = OP + 17 } SendPackEx(T); }.bindenv(this); ApplyEngagementButton.SetCallBackFunc(function(Button) {}) SThis.AddChild(ApplyEngagementButton); }.bindenv(this)); } //无论如何都添加礼堂列表 EachManager.AddEachForNpc(20013, function(SThis) { //关闭按钮 local ApplyEngagementButton = LenheartNewUI_Each_BaseButton(0, 0, 100, 21, "interface2/popup_menu/popup_back.img", 3); ApplyEngagementButton.Icon = "interface2/popup_menu/popup_icon_cn.img"; ApplyEngagementButton.IconIdx = 23; ApplyEngagementButton.Str = "礼堂列表"; ApplyEngagementButton.OnClick = function(Button) { Button.Parent.CloseAllEach(); Button.Parent.CloseWindow(); local T = { op = OP + 19, } SendPackEx(T); }.bindenv(this); ApplyEngagementButton.SetCallBackFunc(function(Button) {}) SThis.AddChild(ApplyEngagementButton); }.bindenv(this)); } //重选角色回调 function OnSetCharacter() { CheckMarryState(); } //逻辑入口 function Proc(obj) { // print(getroottable().Camera_Pos); //判断在礼堂房间 if (Config && L_sq_GetTownIndex() == Config.Town && L_sq_GetRegionIndex() == Config.Area) { if (MyMarryTimeFlag && MyMarryTime) { L_sq_DrawImg("map/church/chn_church_count_number.img", 0, 720 - getroottable().Camera_Pos.X, 72 - getroottable().Camera_Pos.Y); DrawMarryTime(obj, MyMarryTime - ((Clock() / 1000) - (MyMarryTimeFlag / 1000))); } } MarriageScript.Show(obj); } TimeFlag = Clock(); //攻坚时间 function DrawMarryTime(obj, RealTime) { local X = 720 - getroottable().Camera_Pos.X; local Y = 114 - getroottable().Camera_Pos.Y; local seconds = RealTime; local minutes = seconds / 60; seconds %= 60; if (seconds< 0 && minutes< 0) return; seconds = format("%02d", seconds).slice(-2); minutes = format("%02d", minutes).slice(-2); local X1 = -15; local X2 = X1 + 18; local Offset = 0; Offset += 46; L_sq_DrawImg("map/church/chn_church_count_number.img", minutes.slice(0, 1).tointeger() + 1, X + X1 + Offset, Y + 28); L_sq_DrawImg("map/church/chn_church_count_number.img", minutes.slice(1).tointeger() + 1, X + X2 + Offset, Y + 28); Offset += 46; L_sq_DrawImg("map/church/chn_church_count_number.img", seconds.slice(0, 1).tointeger() + 1, X + X1 + Offset, Y + 28); L_sq_DrawImg("map/church/chn_church_count_number.img", seconds.slice(1).tointeger() + 1, X + X2 + Offset, Y + 28); } } getroottable().rawdelete("MarrySystem_Obj"); // local ReadPath = L_sq_P2I(Memory.allocUtf8String("equipment/equipment.lst").C_Object); // local Reader = Memory.alloc(409600); // local ReadBuffer = L_sq_P2I(Reader.C_Object); // print(format("%02x", ReadBuffer)); // L_Sq_CallFunc(0x11A2030, "int", FFI_FASTCALL, ["int", "int", "int", "int", "int", "int"], 0x1D17638, 0, ReadPath, ReadBuffer, 0x100000, 0x19DAF4); // L_Sq_CallFunc(0x112A9F0, "int", FFI_THISCALL, ["int", "int", "int", "int","int", "int", "int"], L_sq_RA(0x1A5FAE4), AniPath, pATH2, 1,0,0,0); // local ItemObject = L_sq_GetItem(601500069); // print(format("%02x", ItemObject)); // local ThisC = L_Sq_CallFunc(0x11A5990, "int", FFI_THISCALL, ["int"], 508); // print(format("%02x", ThisC)); // local AniPath = L_sq_P2I(Memory.allocUtf8String("character/swordman/animation/attack1.ani").C_Object); //TTTAni <- L_Sq_CallFunc(0x108F8B0, "int", FFI_THISCALL, ["int", "int", "int", "int"], ThisC, AniPath, 1, 0); // local AniPath = L_sq_P2I(Memory.allocUtf8String("character/swordman/animation/attack1.ani").C_Object); // TTTAni <- L_Sq_CallFunc(0x112A9F0, "int", FFI_THISCALL, ["int", "int", "int", "int", "int", "int", "int"], 0x19dc64, AniPath, 1695745, 1, 0, 0, 0); // Rindro_Haker.LoadHook(0x65de50, ["int", "int"], // function(args) { // // print(format("%02x", args[0])); // // local AniPath = NativePointer(L_sq_I2P(args[0])).readUnicodeString(); // print(format("%02x", args[0])); // // print(args[2]); // return null; // }, // function(args) { // // print(666); // // print(format("%02x", args.pop())); // // TTTAni <- args.pop(); // return null; // }); // local ItemObject = R_Utils.GetEquPath(601500069); // print(NativePointer(L_sq_I2P(ItemObject)).readUnicodeString()); function Lenheart_MarrySystem_Fun(obj) { local RootTab = getroottable(); if (!RootTab.rawin("MarrySystem_Obj")) { RootTab.rawset("MarrySystem_Obj", MarrySystemC()); } else { RootTab["MarrySystem_Obj"].Proc(obj); } // if (TTTAni) { // print(format("%02x", TTTAni)); // L_Sq_CallFunc(0x1091890, "char", FFI_THISCALL, ["int"], TTTAni); // L_Sq_CallFunc(0x108B770, "int", FFI_THISCALL, ["int", "int", "int", "int", "int", "int"], TTTAni, L_sq_RA(0x1B45B94), 200, 200, 0, 0); // } } getroottable()["LenheartFuncTab"].rawset("MarrySystemFuncN", Lenheart_MarrySystem_Fun); // local asos = R_Utils.GetCharacByEqu(0, 0, [601550071, 601560067, 601570062, 601520061, 601500069, 601510068, 601530060, 601540069, 601580026, 101010035]); // local asos = sq_CreateAICharacter(900); // asos.setCurrentPos(sq_getMyCharacter().getXPos() + 100, sq_getMyCharacter().getYPos(), 0); // sq_AddObject(sq_getMyCharacter(), asos, OBJECTTYPE_VIRTUALCHARACTER, false); // local ItemObject = L_sq_GetItem(27675); // // local ItemObject = L_sq_GetItem(27582); // L_Sq_CallFunc(0x8265A0, "void", FFI_THISCALL, ["int","int","int"], L_Sq_GetObjectAddress(asos),ItemObject,0xFFFFFFFF);