UI临时提交
This commit is contained in:
parent
4ddf77a5b8
commit
a839f2dc36
|
|
@ -135,6 +135,21 @@ class Yosin_BaseWindow extends Layer {
|
|||
Addchild(gChild);
|
||||
// gChild.Parent = this;
|
||||
}
|
||||
|
||||
/*
|
||||
* @函数作用: 移除子对象
|
||||
* @参数 name
|
||||
*/
|
||||
function RemoveUIChild(gChild) {
|
||||
foreach(pos, buf in this.UI_Childrens) {
|
||||
if (buf == gChild) {
|
||||
this.UI_Childrens.remove(pos);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Removechild(gChild);
|
||||
// gChild.Parent = this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -83,6 +83,8 @@ class Yosin_BaseButton extends Yosin_CommonUi {
|
|||
SpriteState = -1;
|
||||
FrameList = null;
|
||||
|
||||
//按下时的模拟偏移
|
||||
DownSimulateOffset = true;
|
||||
|
||||
constructor(X, Y, W, H, Path, Idx) {
|
||||
this.Path = Path;
|
||||
|
|
@ -103,13 +105,15 @@ class Yosin_BaseButton extends Yosin_CommonUi {
|
|||
function ChangeFrame() {
|
||||
//状态更改 刷新精灵帧
|
||||
if (State != SpriteState) {
|
||||
//如果按下 调整Y坐标向下一个单位
|
||||
if (State == 2) {
|
||||
Y += 1;
|
||||
SyncPos(X, Y);
|
||||
} else if (SpriteState == 2) {
|
||||
Y -= 1;
|
||||
SyncPos(X, Y);
|
||||
//按下时模拟偏移的Flag 如果按下 调整Y坐标向下一个单位
|
||||
if (DownSimulateOffset) {
|
||||
if (State == 2) {
|
||||
Y += 1;
|
||||
SyncPos(X, Y);
|
||||
} else if (SpriteState == 2) {
|
||||
Y -= 1;
|
||||
SyncPos(X, Y);
|
||||
}
|
||||
}
|
||||
SpriteState = State;
|
||||
Sprite.SetFrame(FrameList[SpriteState]);
|
||||
|
|
@ -179,4 +183,80 @@ class Yosin_EmeStretch extends Yosin_CommonUi {
|
|||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//拼接按钮
|
||||
class Yosin_SplicingButton extends Yosin_CommonUi {
|
||||
//按钮状态
|
||||
State = 0;
|
||||
Path = null;
|
||||
Idx = null;
|
||||
|
||||
SpriteList = null;
|
||||
SpriteState = -1;
|
||||
FrameList = null;
|
||||
|
||||
//按下时的模拟偏移
|
||||
DownSimulateOffset = true;
|
||||
|
||||
constructor(X, Y, W, H, Path, Idx, Direction = true, UnavailableFlag = true) {
|
||||
this.Path = Path;
|
||||
this.Idx = Idx;
|
||||
base.constructor(X, Y, W, H);
|
||||
|
||||
SpriteList = array(4);
|
||||
|
||||
//普通态
|
||||
SpriteList[0] = Yosin_EmeStretch(0, 0, W, H, Path, Idx, Direction);
|
||||
//悬停态
|
||||
SpriteList[1] = Yosin_EmeStretch(0, 0, W, H, Path, Idx + (UnavailableFlag ? 4 : 3), Direction);
|
||||
//按下态
|
||||
SpriteList[2] = Yosin_EmeStretch(0, 0, W, H, Path, Idx + (UnavailableFlag ? 8 : 3), Direction);
|
||||
if (UnavailableFlag) {
|
||||
//不可用态
|
||||
SpriteList[3] = Yosin_EmeStretch(0, 0, W, H, Path, Idx + 12, Direction);
|
||||
}
|
||||
}
|
||||
|
||||
function ChangeFrame() {
|
||||
//状态更改 刷新精灵帧
|
||||
if (State != SpriteState) {
|
||||
//按下时模拟偏移的Flag 如果按下 调整Y坐标向下一个单位
|
||||
if (DownSimulateOffset) {
|
||||
if (State == 2) {
|
||||
Y += 1;
|
||||
SyncPos(X, Y);
|
||||
} else if (SpriteState == 2) {
|
||||
Y -= 1;
|
||||
SyncPos(X, Y);
|
||||
}
|
||||
}
|
||||
if (SpriteState != -1) {
|
||||
RemoveUIChild(SpriteList[SpriteState]);
|
||||
}
|
||||
SpriteState = State;
|
||||
AddUIChild(SpriteList[SpriteState]);
|
||||
}
|
||||
}
|
||||
|
||||
function Proc(Dt) {
|
||||
//不可用
|
||||
if (State == 3) {
|
||||
|
||||
} else {
|
||||
//按下
|
||||
if (isLBDown) {
|
||||
State = 2;
|
||||
}
|
||||
//悬停
|
||||
else if (isInRect) {
|
||||
State = 1;
|
||||
}
|
||||
//普通
|
||||
else {
|
||||
State = 0;
|
||||
}
|
||||
}
|
||||
ChangeFrame();
|
||||
}
|
||||
}
|
||||
|
|
@ -16,7 +16,7 @@ function TestStage() {
|
|||
|
||||
local Window = Sq_CreateWindow(_Select_Character_Window, "选择角色界面窗口", 0, 0, 1066, 600, 0);
|
||||
local T = {
|
||||
Background = 1
|
||||
Background = 0
|
||||
}
|
||||
Window.Init(T);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
文件名:Drag_Button.nut
|
||||
路径:User/UI/Widget/Drag_Button.nut
|
||||
创建日期:2024-12-14 09:40
|
||||
文件用途:拖动按钮
|
||||
*/
|
||||
class Yosin_DragButton extends Yosin_CommonUi {
|
||||
//路径
|
||||
Path = "";
|
||||
//索引
|
||||
Idx = 0;
|
||||
|
||||
//按钮
|
||||
Button = null;
|
||||
|
||||
|
||||
constructor(X, Y, W, H, Path, Idx, Direction = true, UnavailableFlag = true) {
|
||||
this.Path = Path;
|
||||
this.Idx = Idx;
|
||||
base.constructor(X, Y, W, H);
|
||||
|
||||
Button = Yosin_SplicingButton(0, 0, W, H, Path, Idx, Direction, UnavailableFlag);
|
||||
Button.DownSimulateOffset = false;
|
||||
AddUIChild(Button);
|
||||
}
|
||||
|
||||
//override
|
||||
//鼠标左键按下回调
|
||||
function OnMouseLbDown(MousePos_X, MousePos_Y) {
|
||||
base.OnMouseLbDown(MousePos_X, MousePos_Y);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
文件名:Scroll_Bar.nut
|
||||
路径:User/UI/Widget/Scroll_Bar.nut
|
||||
创建日期:2024-12-13 23:17
|
||||
文件用途:
|
||||
*/
|
||||
//基础按钮
|
||||
class Yosin_ScrollBar extends Yosin_CommonUi {
|
||||
//控制器
|
||||
Controller = null;
|
||||
|
||||
//是否焦点
|
||||
IsFocus = false;
|
||||
|
||||
//上按钮
|
||||
UpButton = null;
|
||||
//下按钮
|
||||
DownButton = null;
|
||||
|
||||
//Path
|
||||
Path = "sprite/interface/lenheartwindowcommon.img";
|
||||
|
||||
constructor(X, Y, H, gSize) {
|
||||
base.constructor(X, Y, 9, H > 26 ? H : 26);
|
||||
|
||||
Controller = {
|
||||
CurPos = 0,
|
||||
Size = gSize
|
||||
}
|
||||
|
||||
//上按钮
|
||||
UpButton = Yosin_BaseButton(0, 0, 9, 13, Path, 16);
|
||||
//点击事件回调
|
||||
UpButton.OnClick = function(Button) {
|
||||
|
||||
}.bindenv(this);
|
||||
AddUIChild(UpButton);
|
||||
|
||||
//滚动条
|
||||
|
||||
//下按钮
|
||||
DownButton = Yosin_BaseButton(0, Height - 13, 9, 13, Path, 22);
|
||||
//点击事件回调
|
||||
DownButton.OnClick = function(Button) {
|
||||
|
||||
}.bindenv(this);
|
||||
AddUIChild(DownButton);
|
||||
|
||||
}
|
||||
|
||||
function Proc(Dt) {
|
||||
base.Proc(Dt);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -82,11 +82,14 @@ class _Select_Character_SettingBackground_Window extends Yosin_Window {
|
|||
//选择背景按钮集合
|
||||
SettingBackgroundButtonList = null;
|
||||
|
||||
Background = null;
|
||||
|
||||
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
|
||||
base.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
|
||||
SettingBackgroundButtonList = [];
|
||||
|
||||
SetClipRect(-gWidth, 0, gWidth, gHeight + 20);
|
||||
// SetClipRect(-gWidth, 0, gWidth, gHeight + 20);
|
||||
// SetClipRect(0, 0, 1066, 600);
|
||||
// ShowBorder(true);
|
||||
// SetLayerOpacity(1);
|
||||
}
|
||||
|
|
@ -98,7 +101,7 @@ class _Select_Character_SettingBackground_Window extends Yosin_Window {
|
|||
|
||||
function RegisterDraw() {
|
||||
//背景
|
||||
local Background = CL_SpriteObject("sprite/interface2/selectcharacter_ver2/setup/setup.img", 17);
|
||||
Background = CL_SpriteObject("sprite/interface2/selectcharacter_ver2/setup/setup.img", 17);
|
||||
Addchild(Background);
|
||||
|
||||
for (local i = 0; i< 24; i++) {
|
||||
|
|
@ -199,6 +202,15 @@ class _Select_Character_Window extends Yosin_Window {
|
|||
}
|
||||
})
|
||||
SettingButton.Addchild(LoginTextActor);
|
||||
|
||||
|
||||
// local TestButton = Yosin_ScrollBar(300, 200, 50, 100);
|
||||
// AddUIChild(TestButton);
|
||||
// local TestButton = Yosin_SplicingButton(200, 200, 77, 68, "sprite/interface/lenheartwindowcommon.img", 184, false, false);
|
||||
// TestButton.DownSimulateOffset = false;
|
||||
local TestButton = Yosin_DragButton(200, 200, 9, 120, "sprite/interface/lenheartwindowcommon.img", 184, false, false);
|
||||
// TestButton.SetScale(5.0, 5.0);
|
||||
AddUIChild(TestButton);
|
||||
}
|
||||
|
||||
//切换背景
|
||||
|
|
@ -209,6 +221,16 @@ class _Select_Character_Window extends Yosin_Window {
|
|||
}
|
||||
BackGround = CL_SpriteObject("sprite/interface2/selectcharacter_ver2/background/large/background_large_event.img", Idx);
|
||||
BackGround.SetZOrder(-10);
|
||||
|
||||
/*
|
||||
|
||||
BackGround = Layer();
|
||||
BackGround.Addchild(CL_SpriteObject("sprite/interface2/selectcharacter_ver2/background/large/background_large_event.img", Idx));
|
||||
BackGround.SetZOrder(-10);
|
||||
BackGround.SetPosition(100, 100);
|
||||
BackGround.SetClipRect(0, 0, 200, 200);
|
||||
|
||||
*/
|
||||
Addchild(BackGround);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue