Merge remote-tracking branch 'origin/yi' into dong
This commit is contained in:
commit
223a3d3246
|
|
@ -0,0 +1,284 @@
|
|||
/*
|
||||
文件名:6_Message.nut
|
||||
路径:User/UI/Window/6_Message.nut
|
||||
创建日期:2025-01-17 19:41
|
||||
文件用途: 消息窗口
|
||||
*/
|
||||
|
||||
//主类
|
||||
class _Message extends Yosin_Window {
|
||||
|
||||
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
|
||||
base.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
|
||||
|
||||
local background = Message_Backgournd();
|
||||
Addchild(background);
|
||||
|
||||
RegisterWidget();
|
||||
}
|
||||
|
||||
function RegisterWidget() {
|
||||
|
||||
// 普通
|
||||
local ordinary = Message_SplicingButton(6, 206, 53, 20, 8, "普通", sq_RGBA(255, 255, 255, 255));
|
||||
AddUIChild(ordinary);
|
||||
ordinary.LBDownOnClick = function(btn) {
|
||||
print(111);
|
||||
}
|
||||
ordinary.OnTriangleClick = function(btn) {
|
||||
print(222);
|
||||
}
|
||||
|
||||
// 公会
|
||||
local notice = Message_SplicingButton(60, 206, 53, 20, 47, "公会", sq_RGBA(254, 77, 245, 255));
|
||||
AddUIChild(notice);
|
||||
notice.LBDownOnClick = function(btn) {
|
||||
print(111);
|
||||
}
|
||||
notice.OnTriangleClick = function(btn) {
|
||||
print(222);
|
||||
}
|
||||
|
||||
// 频道
|
||||
local channel = Message_SplicingButton(114, 206, 53, 20, 48, "频道", sq_RGBA(221, 153, 197, 255));
|
||||
AddUIChild(channel);
|
||||
channel.LBDownOnClick = function(btn) {
|
||||
print(111);
|
||||
}
|
||||
channel.OnTriangleClick = function(btn) {
|
||||
print(222);
|
||||
}
|
||||
|
||||
// 募集
|
||||
local raise = Message_SplicingButton(168, 206, 53, 20, 49, "募集", sq_RGBA(105, 212, 238, 255));
|
||||
AddUIChild(raise);
|
||||
raise.LBDownOnClick = function(btn) {
|
||||
print(111);
|
||||
}
|
||||
raise.OnTriangleClick = function(btn) {
|
||||
print(222);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//逻辑入口
|
||||
function Proc(Dt) {
|
||||
SyncPos(X, Y);
|
||||
base.Proc(Dt);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 背景
|
||||
class Message_Backgournd extends CL_CanvasObject {
|
||||
|
||||
constructor() {
|
||||
base.constructor();
|
||||
|
||||
DrawBackground();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 绘制背景
|
||||
function DrawBackground() {
|
||||
|
||||
// 创建画布
|
||||
CL_CanvasObject();
|
||||
// 重设大小并清空
|
||||
ResizeAndClear(332, 600);
|
||||
// 开始绘制
|
||||
BeginDraw();
|
||||
|
||||
|
||||
local topLine = CL_SpriteFrameObject("sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 159);
|
||||
DrawSpriteFrame(topLine, 0, 0);
|
||||
|
||||
local topBg = CL_SpriteObject("sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 160);
|
||||
topBg.SetPosition(0, 2);
|
||||
topBg.SetScale(1, 28);
|
||||
DrawSprite(topBg);
|
||||
|
||||
local bimg = CL_SpriteFrameObject("sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 161);
|
||||
DrawSpriteFrame(bimg, 0, 30);
|
||||
|
||||
local bottomBg = CL_SpriteObject("sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 162);
|
||||
bottomBg.SetPosition(0, 561);
|
||||
bottomBg.SetScale(1, 38);
|
||||
DrawSprite(bottomBg);
|
||||
|
||||
local bottomLine = CL_SpriteFrameObject("sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 163);
|
||||
DrawSpriteFrame(bottomLine, 0, 598);
|
||||
|
||||
// 系统按钮
|
||||
local systemBtnBackground = Yosin_EmeStretch(53, 21, "sprite/interface/lenheartwindowcommon.img", 166);
|
||||
DrawSprite(systemBtnBackground, 6, 15);
|
||||
|
||||
local systemText = FontAssetManager.GenerateNormal("系统", true, {
|
||||
color = sq_RGBA(200, 173, 134, 255)
|
||||
});
|
||||
DrawActor(systemText, 18 , 18);
|
||||
|
||||
// 系统
|
||||
local SystemBround = Yosin_NineBoxStretch( 321, 72, "sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 265);
|
||||
SystemBround.SetPosition(6, 35);
|
||||
DrawSprite(SystemBround);
|
||||
|
||||
// 喇叭按钮
|
||||
local megaphoneBtnBackground = Yosin_EmeStretch(53, 21, "sprite/interface/lenheartwindowcommon.img", 166);
|
||||
DrawSprite(megaphoneBtnBackground, 6, 109);
|
||||
|
||||
// 喇叭
|
||||
local megaphoneext = FontAssetManager.GenerateNormal("喇叭", true, {
|
||||
color = sq_RGBA(255, 239, 1, 255)
|
||||
});
|
||||
DrawActor(megaphoneext, 18 , 112);
|
||||
|
||||
// 喇叭
|
||||
local megaphoneBround = Yosin_NineBoxStretch(321, 72, "sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 265);
|
||||
megaphoneBround.SetPosition(6, 130);
|
||||
DrawSprite(megaphoneBround, 6);
|
||||
|
||||
// 消息
|
||||
local MessageBround = Yosin_NineBoxStretch(321, 345, "sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 265);
|
||||
MessageBround.SetPosition(6, 225);
|
||||
DrawSprite(MessageBround);
|
||||
|
||||
|
||||
// 结束绘制
|
||||
EndDraw();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 消息分类按钮
|
||||
class Message_SplicingButton extends Yosin_CommonUi {
|
||||
|
||||
//按钮状态
|
||||
State = 0;
|
||||
|
||||
Sprite = null;
|
||||
SpriteState = -1;
|
||||
FrameList = null;
|
||||
|
||||
select = false;
|
||||
cacheY = null;
|
||||
|
||||
|
||||
LBDownOnClick = null;
|
||||
OnTriangleClick = null;
|
||||
|
||||
|
||||
constructor(X, Y, W, H, Idx, title, titleColor) {
|
||||
base.constructor(X, Y, W, H);
|
||||
|
||||
cacheY = Y;
|
||||
FrameList = [];
|
||||
Sprite = CL_SpriteObject();
|
||||
Addchild(Sprite);
|
||||
|
||||
for (local i = 0; i< 3; i++) {
|
||||
|
||||
local canvas = Yosin_EmeStretch(W, H, "sprite/interface/lenheartwindowcommon.img", 160 + i *3);
|
||||
local Sf = canvas.ExportSpriteFrame();
|
||||
FrameList.push(Sf);
|
||||
}
|
||||
|
||||
// 文字
|
||||
local Text = FontAssetManager.GenerateNormal(title, true, {
|
||||
color = titleColor
|
||||
});
|
||||
Text.SetPosition(12, 1);
|
||||
Addchild(Text);
|
||||
|
||||
// 三角
|
||||
local triangle = CL_SpriteObject("sprite/interface/newstyle/windows/chatting/chatting_new.img", Idx);
|
||||
triangle.SetPosition(W - 15, 8);
|
||||
Addchild(triangle);
|
||||
|
||||
// 按钮
|
||||
local bigButton = Yosin_BaseButton(0, 0, W - 15, H, "sprite/interface/lenheartwindowcommon.img", 70);
|
||||
AddUIChild(bigButton);
|
||||
bigButton.OnClick = function(btn) {
|
||||
if (LBDownOnClick) {
|
||||
LBDownOnClick(this);
|
||||
};
|
||||
}.bindenv(this);
|
||||
|
||||
// 三角按钮
|
||||
local triangleButton = Yosin_BaseButton(W - 15, 0, 15, H, "sprite/interface/lenheartwindowcommon.img", 70);
|
||||
AddUIChild(triangleButton);
|
||||
triangleButton.OnClick = function(btn) {
|
||||
if (OnTriangleClick) {
|
||||
OnTriangleClick(this);
|
||||
};
|
||||
}.bindenv(this);
|
||||
|
||||
}
|
||||
|
||||
function ChangeFrame() {
|
||||
//状态更改 刷新精灵帧
|
||||
if (State != SpriteState) {
|
||||
if (State == 2) {
|
||||
Y = cacheY - 1;
|
||||
SyncPos(X, Y);
|
||||
} else if (SpriteState == 2) {
|
||||
Y = cacheY;
|
||||
SyncPos(X, Y);
|
||||
}
|
||||
SpriteState = State;
|
||||
Sprite.SetFrame(FrameList[SpriteState]);
|
||||
Sprite.SetPosition(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
function Proc(Dt) {
|
||||
|
||||
if (select) return;
|
||||
|
||||
//不可用
|
||||
if (State == 3) {
|
||||
|
||||
} else {
|
||||
//按下
|
||||
if (isLBDown) {
|
||||
State = 2;
|
||||
select = true;
|
||||
}
|
||||
//悬停
|
||||
else if (isInRect) {
|
||||
State = 1;
|
||||
}
|
||||
//普通
|
||||
else {
|
||||
State = 0;
|
||||
}
|
||||
}
|
||||
ChangeFrame();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (!getroottable().rawin("chongzaiflag")) {
|
||||
getroottable()["chongzaiflag"] <- true;
|
||||
} else {
|
||||
//遍历窗口队列 如果可见则调用Show
|
||||
for (local i = 0; i< _SYS_WINDOW_LIST_.len(); i++) {
|
||||
local Window = _SYS_WINDOW_LIST_[i];
|
||||
Window.Visible = false;
|
||||
Window.RemoveSelf();
|
||||
}
|
||||
TestStage();
|
||||
}
|
||||
Loading…
Reference in New Issue