2024-09-16 17:09:36 +08:00
|
|
|
/*
|
|
|
|
|
文件名:ServerAuction.nut
|
|
|
|
|
路径:Project/ServerAuction/ServerAuction.nut
|
|
|
|
|
创建日期:2024-08-20 10:02
|
|
|
|
|
文件用途:全服竞拍
|
|
|
|
|
*/
|
|
|
|
|
class ServerAuctionC extends LenheartNewUI_Windows {
|
|
|
|
|
//调试模式
|
|
|
|
|
// DeBugMode = true;
|
|
|
|
|
|
|
|
|
|
//不是窗口
|
|
|
|
|
// NoWindow = true;
|
|
|
|
|
|
|
|
|
|
//是否可见
|
|
|
|
|
Visible = false;
|
|
|
|
|
|
|
|
|
|
//竞拍是否开启状态
|
|
|
|
|
AuctionState = false;
|
|
|
|
|
//竞拍项目列表
|
|
|
|
|
AuctionItemList = null;
|
|
|
|
|
//竞拍名字
|
|
|
|
|
AuctionName = "暂无竞拍开启";
|
|
|
|
|
//当前竞拍信息
|
|
|
|
|
AuctionRealInfo = null;
|
|
|
|
|
|
|
|
|
|
//刷新包时间
|
|
|
|
|
PackTimer = 0;
|
|
|
|
|
|
|
|
|
|
//是否Gm
|
|
|
|
|
IsGm = false;
|
|
|
|
|
//Gm可开启竞拍列表
|
|
|
|
|
AuctionList = null;
|
|
|
|
|
//Gm选择的开启竞拍Item
|
|
|
|
|
SelectAuctionItem = null;
|
|
|
|
|
|
|
|
|
|
//展示时间
|
|
|
|
|
InitTime = 0;
|
|
|
|
|
//竞拍时间
|
|
|
|
|
ContinuityTime = 0;
|
|
|
|
|
|
|
|
|
|
function GetConfigCallBack(Chunk) {
|
|
|
|
|
local Jso = Json.Decode(Chunk);
|
|
|
|
|
AuctionState = true;
|
|
|
|
|
AuctionItemList = Jso.lots;
|
|
|
|
|
AuctionName = Jso.name;
|
|
|
|
|
//展示时间
|
|
|
|
|
InitTime = Jso.initTime;
|
|
|
|
|
//竞拍时间
|
|
|
|
|
ContinuityTime = Jso.continuityTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function GetConfig() {
|
|
|
|
|
local T = {
|
|
|
|
|
op = 20067001
|
|
|
|
|
}
|
|
|
|
|
SendPackEx(T);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function GmCallBack(Chunk) {
|
|
|
|
|
local Jso = Json.Decode(Chunk);
|
|
|
|
|
IsGm = true;
|
|
|
|
|
AuctionList = Jso.nameS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function AuctionRealInfoCallBack(Chunk) {
|
|
|
|
|
local Jso = Json.Decode(Chunk);
|
|
|
|
|
AuctionRealInfo = Jso;
|
|
|
|
|
PackTimer = Clock();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function CloseAuctionCallBack(Chunk) {
|
|
|
|
|
//竞拍是否开启状态
|
|
|
|
|
AuctionState = false;
|
|
|
|
|
//竞拍项目列表
|
|
|
|
|
AuctionItemList = null;
|
|
|
|
|
//竞拍名字
|
|
|
|
|
AuctionName = "暂无竞拍开启";
|
|
|
|
|
//当前竞拍信息
|
|
|
|
|
AuctionRealInfo = null;
|
|
|
|
|
|
|
|
|
|
//刷新包时间
|
|
|
|
|
PackTimer = 0;
|
|
|
|
|
|
|
|
|
|
//是否Gm
|
|
|
|
|
IsGm = false;
|
|
|
|
|
//Gm可开启竞拍列表
|
|
|
|
|
AuctionList = null;
|
|
|
|
|
//Gm选择的开启竞拍Item
|
|
|
|
|
SelectAuctionItem = null;
|
|
|
|
|
|
|
|
|
|
//展示时间
|
|
|
|
|
InitTime = 0;
|
|
|
|
|
//竞拍时间
|
|
|
|
|
ContinuityTime = 0;
|
|
|
|
|
CloseWindow();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
|
|
|
|
|
Childrens = [];
|
|
|
|
|
AuctionList = [];
|
|
|
|
|
//注册控件
|
|
|
|
|
RegisterWidget();
|
|
|
|
|
|
|
|
|
|
LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取竞拍配置
|
|
|
|
|
Pack_Control.rawset(20067010, GetConfigCallBack.bindenv(this));
|
|
|
|
|
//Gm回调包
|
|
|
|
|
Pack_Control.rawset(20067020, GmCallBack.bindenv(this));
|
|
|
|
|
//拍卖实时信息包
|
|
|
|
|
Pack_Control.rawset(20067012, AuctionRealInfoCallBack.bindenv(this));
|
|
|
|
|
//竞拍结束包
|
|
|
|
|
Pack_Control.rawset(20067014, CloseAuctionCallBack.bindenv(this));
|
|
|
|
|
GetConfig();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//输入框
|
|
|
|
|
InputObject = null;
|
|
|
|
|
|
|
|
|
|
function RegisterWidget() {
|
|
|
|
|
//关闭按钮
|
|
|
|
|
local CloseButton = LenheartNewUI_BaseButton(308, 4, 11, 12, "interface/lenheartwindowcommon.img", 276);
|
|
|
|
|
CloseButton.OnClick = function() {
|
|
|
|
|
this.Visible = false;
|
|
|
|
|
}.bindenv(this);
|
|
|
|
|
CloseButton.SetCallBackFunc(function(win) {
|
|
|
|
|
if (AuctionState) {
|
|
|
|
|
win.Localtion_X = 308;
|
|
|
|
|
win.Localtion_Y = 4;
|
|
|
|
|
} else {
|
|
|
|
|
win.Localtion_X = 252;
|
|
|
|
|
win.Localtion_Y = 2;
|
|
|
|
|
}
|
|
|
|
|
}.bindenv(this))
|
|
|
|
|
Childrens.append(CloseButton);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InputObject = LenheartNewUI_BaseInput(26, 340, 130, 20);
|
|
|
|
|
InputObject.SetCallBackFunc(function(win) {
|
|
|
|
|
if (AuctionState) win.Localtion_X = 26;
|
|
|
|
|
else win.Localtion_X = -826;
|
|
|
|
|
}.bindenv(this))
|
|
|
|
|
AddChild(InputObject);
|
|
|
|
|
|
|
|
|
|
local PostButton = LenheartNewUI_ButtonText(220, 338, 5, "提交竞拍");
|
|
|
|
|
PostButton.DWidth = 30;
|
|
|
|
|
PostButton.Width = 86;
|
|
|
|
|
PostButton.SetTextOffset(1, 1);
|
|
|
|
|
PostButton.OnClick = function() {
|
|
|
|
|
if (InputObject.str.len() > 0 && AuctionRealInfo) {
|
|
|
|
|
local Jso = {
|
|
|
|
|
op = 20067005,
|
|
|
|
|
count = InputObject.str.tointeger(),
|
|
|
|
|
}
|
|
|
|
|
print(Jso.count);
|
|
|
|
|
SendPackEx(Jso);
|
|
|
|
|
}
|
|
|
|
|
}.bindenv(this);
|
|
|
|
|
PostButton.SetCallBackFunc(function(win) {
|
|
|
|
|
if (AuctionState) win.Localtion_X = 220;
|
|
|
|
|
else win.Localtion_X = -826;
|
|
|
|
|
//物品展示阶段
|
|
|
|
|
if (AuctionRealInfo && AuctionRealInfo.state == 0) {
|
|
|
|
|
win.State = 8;
|
|
|
|
|
win.TextStr = "展示阶段";
|
|
|
|
|
} else {
|
|
|
|
|
win.State = 0;
|
|
|
|
|
win.TextStr = "提交竞拍";
|
|
|
|
|
}
|
|
|
|
|
}.bindenv(this))
|
|
|
|
|
AddChild(PostButton);
|
|
|
|
|
|
|
|
|
|
local OpenAuctionButton = LenheartNewUI_ButtonText(220, 393, 5, "开启竞拍");
|
|
|
|
|
OpenAuctionButton.DWidth = 30;
|
|
|
|
|
OpenAuctionButton.Width = 86;
|
|
|
|
|
OpenAuctionButton.SetTextOffset(1, 1);
|
|
|
|
|
OpenAuctionButton.OnClick = function() {
|
|
|
|
|
if (SelectAuctionItem != null) {
|
|
|
|
|
local Jso = {
|
|
|
|
|
op = 20067021,
|
|
|
|
|
id = AuctionList[SelectAuctionItem][1]
|
|
|
|
|
}
|
|
|
|
|
SendPackEx(Jso);
|
|
|
|
|
CloseWindow();
|
|
|
|
|
}
|
|
|
|
|
}.bindenv(this);
|
|
|
|
|
OpenAuctionButton.SetCallBackFunc(function(win) {
|
|
|
|
|
if (!AuctionState && IsGm) win.Localtion_X = 95;
|
|
|
|
|
else win.Localtion_X = -826;
|
|
|
|
|
}.bindenv(this))
|
|
|
|
|
AddChild(OpenAuctionButton);
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-27 21:24:22 +08:00
|
|
|
function GetItemName(Id) {
|
|
|
|
|
//读取物品名称
|
|
|
|
|
local ItemObject = L_sq_GetItem(Id);
|
|
|
|
|
local NamePointer = L_sq_RA(ItemObject + 0x20);
|
|
|
|
|
local Name = NativePointer(L_sq_I2P(NamePointer)).readUnicodeString();
|
|
|
|
|
return Name;
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-16 17:09:36 +08:00
|
|
|
//绘制主界面
|
|
|
|
|
function DrawMain(obj) {
|
|
|
|
|
|
|
|
|
|
if (AuctionState && AuctionRealInfo) {
|
|
|
|
|
//绘制背景
|
|
|
|
|
L_sq_DrawImg("interface2/yosin/qfjp.img", 4, X, Y);
|
|
|
|
|
//绘制标题
|
|
|
|
|
L_sq_DrawCode(AuctionName, X + 196 - LenheartTextClass.GetStringLength(AuctionName), Y + 6, sq_RGBA(227, 212, 154, 250), 0, 1);
|
|
|
|
|
// foreach(Pos, Value in AuctionItemList) {
|
|
|
|
|
for (local i = 0; i< 5; i++) {
|
|
|
|
|
if (i< AuctionItemList.len()) {
|
|
|
|
|
local Pos = i;
|
|
|
|
|
local Value = AuctionItemList[i];
|
|
|
|
|
//当前拍品
|
|
|
|
|
if (Pos == AuctionRealInfo.idx && AuctionRealInfo.state == 1) {
|
|
|
|
|
local CostItemId = Value.cost;
|
|
|
|
|
if (Value.cost == -1) CostItemId = 7906;
|
|
|
|
|
if (Value.cost == -2) CostItemId = 133;
|
|
|
|
|
//绘制扣除道具
|
2025-05-27 21:24:22 +08:00
|
|
|
DrawItemEx(X + 40, Y + 284, CostItemId, 1);
|
2024-09-16 17:09:36 +08:00
|
|
|
|
|
|
|
|
local CostName = "";
|
|
|
|
|
if (Value.cost == 0) CostName = "金币";
|
|
|
|
|
else if (Value.cost == -1) CostName = "点券";
|
|
|
|
|
else if (Value.cost == -2) CostName = "代币券";
|
2025-05-27 21:24:22 +08:00
|
|
|
else CostName = GetItemName(CostItemId);
|
2024-09-16 17:09:36 +08:00
|
|
|
//绘制扣除道具名字
|
|
|
|
|
L_sq_DrawCode(CostName, X + 79, Y + 300, sq_RGBA(227, 212, 154, 250), 0, 1);
|
|
|
|
|
//绘制竞品名
|
2025-05-27 21:24:22 +08:00
|
|
|
L_sq_DrawCode(GetItemName(Value.itemId), X + 120, Y + 207, sq_RGBA(227, 212, 154, 250), 0, 1);
|
2024-09-16 17:09:36 +08:00
|
|
|
//绘制最高竞价者
|
|
|
|
|
L_sq_DrawCode(AuctionRealInfo.name, X + 120, Y + 230, sq_RGBA(227, 212, 154, 250), 0, 1);
|
|
|
|
|
//绘制最高竞拍价
|
|
|
|
|
L_sq_DrawCode(AuctionRealInfo.costcount.tostring(), X + 120, Y + 252, sq_RGBA(227, 212, 154, 250), 0, 1);
|
|
|
|
|
|
|
|
|
|
//绘制当前道具显示框
|
|
|
|
|
L_sq_SetDrawImgModel(2, 0);
|
|
|
|
|
L_sq_DrawImg("interface2/yosin/qfjp.img", 3, X + 38 + (Pos * 50), Y + 40);
|
|
|
|
|
L_sq_ReleaseDrawImgModel();
|
|
|
|
|
L_sq_DrawImg("interface2/yosin/qfjp.img", 7, X + 38 + (Pos * 50), Y + 40);
|
|
|
|
|
|
|
|
|
|
//绘制进度条
|
|
|
|
|
local Rate = (Clock() - PackTimer + AuctionRealInfo.remainder).tofloat() / (ContinuityTime * 1000).tofloat();
|
|
|
|
|
setClip(X + 29, Y + 119, X + 29 + 272 - (272.0 * Rate).tointeger(), Y + 119 + 12);
|
|
|
|
|
L_sq_DrawImg("interface2/yosin/qfjp.img", 6, X + 29, Y + 119);
|
|
|
|
|
releaseClip(); //裁切结束
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//绘制拍卖物品
|
|
|
|
|
DrawItemBase(X + 51 + (Pos * 50), Y + 54, Value.itemId, Value.count);
|
|
|
|
|
|
|
|
|
|
if (Pos< AuctionRealInfo.idx) {
|
|
|
|
|
//绘制道具遮罩框
|
|
|
|
|
L_sq_DrawImg("interface2/yosin/qfjp.img", 5, X + 48 + (Pos * 50), Y + 50, 0, sq_RGBA(255, 255, 255, 150), 1.0, 1.0);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// DrawItemBase(X + 51 + (Pos * 50), Y + 54, Value.itemId, Value.count);
|
|
|
|
|
L_sq_DrawImg("interface/lenheartwindowcommon.img", 606, X + 57 + (i * 50), Y + 58);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//展示时间绘制
|
|
|
|
|
if (AuctionRealInfo.state == 0) {
|
|
|
|
|
local Rate = (Clock() - PackTimer + AuctionRealInfo.remainder).tofloat() / (InitTime * 1000).tofloat();
|
|
|
|
|
setClip(X + 29, Y + 119, X + 29 + 272 - (272.0 * Rate).tointeger(), Y + 119 + 12);
|
|
|
|
|
L_sq_DrawImg("interface2/yosin/qfjp.img", 8, X + 29, Y + 119);
|
|
|
|
|
releaseClip(); //裁切结束
|
|
|
|
|
//绘制物品展示中
|
|
|
|
|
L_sq_DrawCode("物品展示中", X + 135, Y + 96, sq_RGBA(185, 148, 96, 250), 0, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//Gm设置页面
|
|
|
|
|
else if (IsGm) {
|
|
|
|
|
//绘制窗口底
|
|
|
|
|
L_sq_DrawWindow(X, Y, 260, 372, "interface/lenheartwindowcommon.img", 97, 11, 12, 11, 13);
|
|
|
|
|
L_sq_DrawWindow(X + 14, Y + 18, 251, 366, "interface/windowcommon.img", 204, 4, 14, 4, 14);
|
|
|
|
|
|
|
|
|
|
foreach(Pos, Value in AuctionList) {
|
|
|
|
|
local Rx = X + 23;
|
|
|
|
|
local Ry = Y + 31 + (Pos * 30);
|
|
|
|
|
L_sq_DrawImg("interface/lenheartwindowcommon.img", 53, Rx, Ry);
|
|
|
|
|
L_sq_DrawCode(Value[0], Rx + 6, Ry + 5, 0xff00b1ff, 0, 1);
|
|
|
|
|
if (sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 1, 1, Rx, Ry, 228, 21)) {
|
|
|
|
|
L_sq_DrawImg("interface/lenheartwindowcommon.img", 54, Rx, Ry);
|
|
|
|
|
if (MouseClickFlag) {
|
|
|
|
|
SelectAuctionItem = Pos;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (Pos == SelectAuctionItem) {
|
|
|
|
|
L_sq_DrawImg("interface/lenheartwindowcommon.img", 54, Rx, Ry);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Show(obj) {
|
|
|
|
|
DrawMain(obj);
|
|
|
|
|
LenheartNewUI_Windows.Show(obj);
|
|
|
|
|
|
|
|
|
|
MouseClickFlag = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//逻辑入口
|
|
|
|
|
function Proc(obj) {
|
|
|
|
|
LenheartNewUI_Windows.SyncPos(X, Y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MouseClickFlag = false;
|
|
|
|
|
//鼠标左键弹起回调
|
|
|
|
|
function OnMouseLbUp(MousePos_X, MousePos_Y) {
|
|
|
|
|
MouseClickFlag = true;
|
|
|
|
|
LenheartNewUI_Windows.OnMouseLbUp(MousePos_X, MousePos_Y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function OpenCallBack() {
|
|
|
|
|
GetConfig();
|
|
|
|
|
this.Visible = true;
|
|
|
|
|
ResetFocus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
getroottable().rawdelete("ServerAuction_Obj");
|
|
|
|
|
|
|
|
|
|
function Lenheart_ServerAuction_Fun(obj) {
|
|
|
|
|
local RootTab = getroottable();
|
|
|
|
|
if (!RootTab.rawin("ServerAuction_Obj")) {
|
|
|
|
|
RootTab.rawset("ServerAuction_Obj", true);
|
|
|
|
|
local Winobj = LenheartNewUI_CreateWindow(ServerAuctionC, "全服竞拍窗口", ((getroottable().Rindro_Scr_Width - 405) / 2).tointeger(), 64, 405, 372, 28);
|
|
|
|
|
EventList_Obj.AddEvent("全服竞拍", 157, Winobj, "interface2/yosin/eventsystemlist.img");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getroottable()["LenheartFuncTab"].rawset("ServerAuctionFuncN", Lenheart_ServerAuction_Fun);
|