331 lines
		
	
	
		
			11 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
		
		
			
		
	
	
			331 lines
		
	
	
		
			11 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
|  | /* | ||
|  | 文件名:Exchange_auc.nut | ||
|  | 路径:Project/Exchange/Exchange_auc.nut | ||
|  | 创建日期:2025-07-23	13:13 | ||
|  | 文件用途:交易所拍卖行 | ||
|  | */ | ||
|  | class Exchange_aucC extends LenheartNewUI_Windows { | ||
|  |     //调试模式 | ||
|  |     // DeBugMode = true; | ||
|  | 
 | ||
|  |     //不是窗口 | ||
|  |     // NoWindow = true; | ||
|  | 
 | ||
|  |     //是否可见 | ||
|  |     Visible = false; | ||
|  | 
 | ||
|  |     Img = null; | ||
|  | 
 | ||
|  |     //标题按钮集合 | ||
|  |     TitleButtonList = null; | ||
|  | 
 | ||
|  |     //页面 | ||
|  |     Page = 0; | ||
|  |     //子页面 | ||
|  |     SubPage = 0; | ||
|  |     //总条数 | ||
|  |     Total = 0; | ||
|  | 
 | ||
|  |     //拍卖信息 | ||
|  |     AuctionInfo = null; | ||
|  | 
 | ||
|  |     //选中拍品 | ||
|  |     SelectAuction = null; | ||
|  | 
 | ||
|  |     function QueryExchange() { | ||
|  |         AuctionInfo = []; | ||
|  |         SendPackEx({ | ||
|  |             op = 21001003, | ||
|  |             type = Page + 1, | ||
|  |             offset = SubPage * 7 | ||
|  |         }) | ||
|  |     } | ||
|  | 
 | ||
|  |     constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) { | ||
|  |         Childrens = []; | ||
|  |         TitleButtonList = []; | ||
|  |         AuctionInfo = []; | ||
|  |         //注册控件 | ||
|  |         RegisterWidget(); | ||
|  | 
 | ||
|  |         LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH); | ||
|  | 
 | ||
|  |         Img = {}; | ||
|  |         Img["main"] <- Rindro_Image("interface2/yosin/exchange.img"); | ||
|  | 
 | ||
|  |         //查询拍卖信息回包 | ||
|  |         RegisterPack(21001004, function(Chunk) { | ||
|  |             local Jso = Json.Decode(Chunk); | ||
|  |             Total = Jso.total; | ||
|  |             foreach(infoobj in Jso.info) { | ||
|  |                 infoobj.itemName <- NativePointer(L_sq_I2P(L_sq_RA(L_sq_GetItem(infoobj.itemId) + 0x20))).readUnicodeString() | ||
|  |                 local buf = Exchange_aucC_Item(this, infoobj); | ||
|  |                 AuctionInfo.append(buf); | ||
|  |             } | ||
|  | 
 | ||
|  |         }.bindenv(this)); | ||
|  |     } | ||
|  | 
 | ||
|  |     function RegisterWidget() { | ||
|  |         //关闭按钮 | ||
|  |         local CloseButton = LenheartNewUI_BaseButton(388, 2, 11, 12, "interface/lenheartwindowcommon.img", 276); | ||
|  |         CloseButton.OnClick = function() { | ||
|  |             this.Visible = false; | ||
|  |         }.bindenv(this); | ||
|  |         Childrens.append(CloseButton); | ||
|  | 
 | ||
|  |         local LogicFunc = function(Btn) { | ||
|  |             foreach(Pos, obj in TitleButtonList) { | ||
|  |                 if (obj != Btn) obj.State = 0; | ||
|  |                 else { | ||
|  |                     obj.State = 1; | ||
|  |                     Page = Pos; | ||
|  |                 } | ||
|  |             } | ||
|  |             QueryExchange(); | ||
|  |         }; | ||
|  | 
 | ||
|  |         local UpdateLogic = function(Btn) { | ||
|  |             if (SelectAuction) Btn.Visible = false; | ||
|  |             else Btn.Visible = true; | ||
|  |         } | ||
|  | 
 | ||
|  |         local FuncTabbar1 = LenheartNewUI_TabbarsText(4, 20, "装备"); | ||
|  |         FuncTabbar1.State = 1; | ||
|  |         FuncTabbar1.SetTextOffset(20, 4); | ||
|  |         AddChild(FuncTabbar1); | ||
|  |         FuncTabbar1.OnClickEx = LogicFunc.bindenv(this); | ||
|  |         TitleButtonList.append(FuncTabbar1); | ||
|  | 
 | ||
|  |         // local FuncTabbar2 = LenheartNewUI_TabbarsText(65, 20, "消耗品"); | ||
|  |         // FuncTabbar2.SetTextOffset(13, 3); | ||
|  |         // AddChild(FuncTabbar2); | ||
|  |         // FuncTabbar2.OnClickEx = LogicFunc.bindenv(this); | ||
|  |         // TitleButtonList.append(FuncTabbar2); | ||
|  | 
 | ||
|  |         // local FuncTabbar3 = LenheartNewUI_TabbarsText(126, 20, "材料"); | ||
|  |         // FuncTabbar3.SetTextOffset(20, 3); | ||
|  |         // AddChild(FuncTabbar3); | ||
|  |         // FuncTabbar3.OnClickEx = LogicFunc.bindenv(this); | ||
|  |         // TitleButtonList.append(FuncTabbar3); | ||
|  | 
 | ||
|  |         // local FuncTabbar4 = LenheartNewUI_TabbarsText(187, 20, "副职业"); | ||
|  |         // FuncTabbar4.SetTextOffset(13, 3); | ||
|  |         // AddChild(FuncTabbar4); | ||
|  |         // FuncTabbar4.OnClickEx = LogicFunc.bindenv(this); | ||
|  |         // TitleButtonList.append(FuncTabbar4); | ||
|  | 
 | ||
|  |         // local FuncTabbar5 = LenheartNewUI_TabbarsText(248, 20, "任务"); | ||
|  |         // FuncTabbar5.SetTextOffset(20, 3); | ||
|  |         // AddChild(FuncTabbar5); | ||
|  |         // FuncTabbar5.OnClickEx = LogicFunc.bindenv(this); | ||
|  |         // TitleButtonList.append(FuncTabbar5); | ||
|  | 
 | ||
|  |         local FuncTabbar6 = LenheartNewUI_TabbarsText(340, 20, "我的"); | ||
|  |         FuncTabbar6.SetTextOffset(20, 3); | ||
|  |         AddChild(FuncTabbar6); | ||
|  |         FuncTabbar6.OnClickEx = LogicFunc.bindenv(this); | ||
|  |         TitleButtonList.append(FuncTabbar6); | ||
|  | 
 | ||
|  |         //左翻页按钮 | ||
|  |         local LeftButton = LenheartNewUI_BaseButton(320, 350, 15, 15, "interface/lenheartwindowcommon.img", 34); | ||
|  |         LeftButton.OnClick = function() { | ||
|  |             if (SubPage > 0) SubPage--; | ||
|  |             QueryExchange(); | ||
|  |         }.bindenv(this); | ||
|  |         LeftButton.SetCallBackFunc(UpdateLogic.bindenv(this)); | ||
|  |         AddChild(LeftButton); | ||
|  | 
 | ||
|  |         //右翻页按钮 | ||
|  |         local RightButton = LenheartNewUI_BaseButton(380, 350, 15, 15, "interface/lenheartwindowcommon.img", 38); | ||
|  |         RightButton.OnClick = function() { | ||
|  |             if (SubPage + 1<((Total / 7) + 1)) SubPage++; | ||
|  |             QueryExchange(); | ||
|  |         }.bindenv(this); | ||
|  |         RightButton.SetCallBackFunc(UpdateLogic.bindenv(this)); | ||
|  |         AddChild(RightButton); | ||
|  | 
 | ||
|  | 
 | ||
|  |         local ByCallLogic = function(Btn) { | ||
|  |             if (!SelectAuction) Btn.Visible = false; | ||
|  |             else Btn.Visible = true; | ||
|  |         } | ||
|  | 
 | ||
|  |         local BuyButton = LenheartNewUI_ButtonText(120, 340, 5, "购买"); | ||
|  |         BuyButton.SetTextOffset(0, 1); | ||
|  |         BuyButton.OnClickEx = function(Btn) { | ||
|  |             if (Btn.Visible) { | ||
|  |                 local T = { | ||
|  |                     op = 21001005, | ||
|  |                     uuid = SelectAuction.Info.uid | ||
|  |                 } | ||
|  |                 SendPackEx(T); | ||
|  |                 SelectAuction = null; | ||
|  |                 QueryExchange(); | ||
|  |             } | ||
|  |         }.bindenv(this); | ||
|  |         BuyButton.SetCallBackFunc(ByCallLogic.bindenv(this)); | ||
|  |         AddChild(BuyButton); | ||
|  | 
 | ||
|  |         local CancelButton = LenheartNewUI_ButtonText(230, 340, 5, "取消"); | ||
|  |         CancelButton.SetTextOffset(0, 1); | ||
|  |         CancelButton.OnClick = function() { | ||
|  |             SelectAuction = null; | ||
|  |         }.bindenv(this); | ||
|  |         CancelButton.SetCallBackFunc(ByCallLogic.bindenv(this)); | ||
|  |         AddChild(CancelButton); | ||
|  |     } | ||
|  | 
 | ||
|  |     //绘制主界面 | ||
|  |     function DrawMain(obj) { | ||
|  | 
 | ||
|  |         DrawNineBox(X, Y + 2, 405, 372, "interface/lenheartwindowcommon.img", 213); //背景框 | ||
|  |         Img["main"].DrawPng(2, X + 1, Y); | ||
|  | 
 | ||
|  |         DrawNineBox(X + 2, Y + 39, 400, 332, "interface/lenheartwindowcommon.img", 213); //背景框 | ||
|  |         // SelectAuction = Exchange_aucC_Item(this, { | ||
|  |         //     //唯一id | ||
|  |         //     uid = "1231", | ||
|  |         //     itemId = 2243114, | ||
|  |         //     itemName = "御影法杖", | ||
|  |         //     count = 1, | ||
|  |         //     price = 1000, | ||
|  |         //     name = "Kina" | ||
|  |         // }); | ||
|  | 
 | ||
|  |         if (!SelectAuction) { | ||
|  |             //绘制交易物品 | ||
|  |             if (Page >= 0 && Page< 5) { | ||
|  |                 if (AuctionInfo) { | ||
|  |                     foreach(Pos, Object in AuctionInfo) { | ||
|  |                         Object.Show(X + 4, Y + 44 + Pos * 44); | ||
|  |                     } | ||
|  |                 } | ||
|  |             } | ||
|  | 
 | ||
|  |             //绘制页数 | ||
|  |             local SubPageStr = (SubPage + 1).tostring() + "/" + ((Total / 7) + 1).tostring(); | ||
|  |             L_sq_DrawCode(SubPageStr, X + 359 - LenheartTextClass.GetStringLength(SubPageStr) / 2, Y + 352, sq_RGBA(230, 200, 155, 255), 0, 1); | ||
|  |         } else { | ||
|  |             //绘制交易唯一ID | ||
|  |             L_sq_DrawCode("交易码: " + SelectAuction.Info.uid, X + 8, Y + 60, sq_RGBA(230, 200, 155, 255), 0, 1); | ||
|  |             DrawItemBase(X + 8, Y + 80, SelectAuction.Info.itemId, SelectAuction.Info.count); | ||
|  |             //绘制名称 | ||
|  |             L_sq_DrawCode(SelectAuction.Info.itemName + "x" + SelectAuction.Info.count, X + 48, Y + 88, sq_RGBA(230, 200, 155, 255), 0, 1); | ||
|  |             //绘制价格 | ||
|  |             local Pstr = "售价: " + SelectAuction.Info.price + " 单价: " + (SelectAuction.Info.price / SelectAuction.Info.count + "/件"); | ||
|  |             L_sq_DrawCode(Pstr, X + 8, Y + 120, sq_RGBA(140, 255, 113, 255), 0, 1); | ||
|  |             //绘制卖家名称 | ||
|  |             L_sq_DrawCode("卖家: " + SelectAuction.Info.name, X + 8, Y + 140, sq_RGBA(230, 200, 155, 255), 0, 1); | ||
|  |         } | ||
|  |     } | ||
|  | 
 | ||
|  |     function Show(obj) { | ||
|  |         DrawMain(obj); | ||
|  |         LenheartNewUI_Windows.Show(obj); | ||
|  | 
 | ||
|  |     } | ||
|  | 
 | ||
|  |     function TopShow(obj) { | ||
|  |         LenheartNewUI_Windows.TopShow(obj); | ||
|  |         local MousePos_X = IMouse.GetXPos(); | ||
|  |         local MousePos_Y = IMouse.GetYPos(); | ||
|  |         if (Page >= 0 && Page< 5 && !SelectAuction) { | ||
|  |             if (AuctionInfo) { | ||
|  |                 foreach(Pos, Object in AuctionInfo) { | ||
|  |                     if (sq_IsIntersectRect(MousePos_X, MousePos_Y, 1, 1, X + 4, Y + 44 + Pos * 44, 392, 39)) { | ||
|  |                         Object.HoverShow(X + 4, Y + 44 + Pos * 44); | ||
|  |                     } | ||
|  |                 } | ||
|  |             } | ||
|  |         } | ||
|  |     } | ||
|  | 
 | ||
|  |     //鼠标左键按下回调 | ||
|  |     function OnMouseLbDown(MousePos_X, MousePos_Y) { | ||
|  |         LenheartNewUI_BaseWindow.OnMouseLbDown(MousePos_X, MousePos_Y); | ||
|  |         if (Page >= 0 && Page< 5 && !SelectAuction) { | ||
|  |             if (AuctionInfo) { | ||
|  |                 foreach(Pos, Object in AuctionInfo) { | ||
|  |                     if (sq_IsIntersectRect(MousePos_X, MousePos_Y, 1, 1, X + 4, Y + 44 + Pos * 44, 392, 39)) { | ||
|  |                         Object.OnMouseLbDown(X + 4, Y + 44 + Pos * 44); | ||
|  |                     } | ||
|  |                 } | ||
|  |             } | ||
|  |         } | ||
|  |     } | ||
|  | 
 | ||
|  |     //逻辑入口 | ||
|  |     function Proc(obj) { | ||
|  |         LenheartNewUI_Windows.SyncPos(X, Y); | ||
|  |     } | ||
|  | 
 | ||
|  |     function OpenCallBack() { | ||
|  |         Visible = true; | ||
|  |         QueryExchange(); | ||
|  |     } | ||
|  | } | ||
|  | 
 | ||
|  | function Lenheart_Exchange_auc_Fun(obj) { | ||
|  |     local RootTab = getroottable(); | ||
|  |     if (!RootTab.rawin("Exchange_auc_Obj")) { | ||
|  |         RootTab.rawset("Exchange_auc_Obj", true); | ||
|  |         local Win = LenheartNewUI_CreateWindow(Exchange_aucC, "交易所拍卖行窗口", ((getroottable().Rindro_Scr_Width - 405) / 2).tointeger(), 100, 405, 372, 28); | ||
|  |         EventList_Obj.AddEvent("点券交易所", 43, Win); | ||
|  |     } | ||
|  | } | ||
|  | 
 | ||
|  | getroottable()["LenheartFuncTab"].rawset("Exchange_aucFuncN", Lenheart_Exchange_auc_Fun); | ||
|  | 
 | ||
|  | 
 | ||
|  | class Exchange_aucC_Item { | ||
|  | 
 | ||
|  |     //Img | ||
|  |     Img = null; | ||
|  |     //父对象 | ||
|  |     Parent = null; | ||
|  |     //信息 | ||
|  |     Info = null; | ||
|  | 
 | ||
|  |     constructor(Window, Info) { | ||
|  |         Parent = Window; | ||
|  |         Img = Window.Img["main"]; | ||
|  |         this.Info = Info; | ||
|  |     } | ||
|  | 
 | ||
|  | 
 | ||
|  |     function Show(X, Y) { | ||
|  |         Img.DrawPng(3, X, Y); | ||
|  |         local Xpos = X; | ||
|  |         local Ypos = Y; | ||
|  | 
 | ||
|  |         //绘制交易唯一ID | ||
|  |         L_sq_DrawCode("交易码: " + Info.uid, Xpos + 8, Ypos + 14, sq_RGBA(230, 200, 155, 255), 0, 1); | ||
|  | 
 | ||
|  |         //绘制道具 | ||
|  |         Parent.DrawItemBase(Xpos + 100, Ypos + 5, Info.itemId, Info.count); | ||
|  |         //绘制名称 | ||
|  |         L_sq_DrawCode(Info.itemName + "x" + Info.count, Xpos + 137, Ypos + 14, sq_RGBA(230, 200, 155, 255), 0, 1); | ||
|  | 
 | ||
|  |         //绘制价格 | ||
|  |         local Pstr = "售价: " + Info.price + " 单价: " + (Info.price / Info.count + "/件"); | ||
|  |         L_sq_DrawCode(Pstr, Xpos + 315 - LenheartTextClass.GetStringLength(Pstr) / 2, Ypos + 14, sq_RGBA(140, 255, 113, 255), 0, 1); | ||
|  |     } | ||
|  | 
 | ||
|  |     function HoverShow(X, Y) { | ||
|  |         Img.DrawPng(4, X, Y); | ||
|  |     } | ||
|  | 
 | ||
|  |     function OnMouseLbDown(X, Y) { | ||
|  |         Parent.SelectAuction = this; | ||
|  |     } | ||
|  | } | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  | // L_Windows_List <- []; | ||
|  | // getroottable().rawdelete("LenheartPluginsInitFlag"); | ||
|  | // getroottable().rawdelete("EventList_Obj") | ||
|  | // getroottable().rawdelete("Exchange_auc_Obj"); |