Compare commits
2 Commits
4a2f6f3caf
...
052f86d102
| Author | SHA1 | Date |
|---|---|---|
|
|
052f86d102 | |
|
|
97721e04a4 |
|
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
文件名:UI_Cursor.nut
|
||||
路径:Core/UI_Class/UI_Cursor.nut
|
||||
创建日期:2024-12-18 13:41
|
||||
文件用途:
|
||||
*/
|
||||
class _Yosin_Cursor extends Actor {
|
||||
|
||||
Object = null;
|
||||
|
||||
_Mouse_Click_Flag = null;
|
||||
|
||||
constructor() {
|
||||
base.constructor();
|
||||
_Mouse_Click_Flag = {};
|
||||
|
||||
getroottable().Yosin_Cursor <- this;
|
||||
}
|
||||
|
||||
//初始化
|
||||
function Init() {
|
||||
//鼠标层级高于一切
|
||||
SetZOrder(20000000);
|
||||
_UiObject_.Addchild(this);
|
||||
}
|
||||
|
||||
//更换鼠标指针
|
||||
function Change(Frame) {
|
||||
if (Object) {
|
||||
Removechild(Object);
|
||||
}
|
||||
Object = Frame;
|
||||
Addchild(Frame);
|
||||
}
|
||||
|
||||
//事件
|
||||
function Event(MouseState, Wheel, MousePos_X, MousePos_Y) {
|
||||
switch (MouseState) {
|
||||
//常规或者拖动事件
|
||||
case 0x305: {
|
||||
SetPosition(MousePos_X, MousePos_Y);
|
||||
OnMouseProc(MousePos_X, MousePos_Y);
|
||||
break;
|
||||
}
|
||||
//左键按下
|
||||
case 0x101: {
|
||||
_Mouse_Click_Flag.LbFlag <- true;
|
||||
OnMouseLbDown(MousePos_X, MousePos_Y);
|
||||
break;
|
||||
}
|
||||
//左键松开
|
||||
case 0x001: {
|
||||
//左键单击
|
||||
if (_Mouse_Click_Flag.LbFlag == true) {
|
||||
_Mouse_Click_Flag.LbFlag <- false;
|
||||
OnMouseLbClick(MousePos_X, MousePos_Y);
|
||||
}
|
||||
OnMouseLbUp(MousePos_X, MousePos_Y);
|
||||
break;
|
||||
}
|
||||
//右键按下
|
||||
case 0x102: {
|
||||
_Mouse_Click_Flag.RbFlag <- true;
|
||||
OnMouseRbDown(MousePos_X, MousePos_Y);
|
||||
break;
|
||||
}
|
||||
//右键松开
|
||||
case 0x002: {
|
||||
//右键单击
|
||||
if (_Mouse_Click_Flag.RbFlag == true) {
|
||||
_Mouse_Click_Flag.RbFlag <- false;
|
||||
OnMouseRbClick(MousePos_X, MousePos_Y);
|
||||
}
|
||||
OnMouseRbUp(MousePos_X, MousePos_Y);
|
||||
break;
|
||||
}
|
||||
//中键按下
|
||||
case 0x103: {
|
||||
_Mouse_Click_Flag.MbFlag <- true;
|
||||
OnMouseMbDown(MousePos_X, MousePos_Y);
|
||||
break;
|
||||
}
|
||||
//中键松开
|
||||
case 0x003: {
|
||||
//中键单击
|
||||
if (_Mouse_Click_Flag.MbFlag == true) {
|
||||
_Mouse_Click_Flag.MbFlag <- false;
|
||||
OnMouseMbClick(MousePos_X, MousePos_Y);
|
||||
}
|
||||
OnMouseMbUp(MousePos_X, MousePos_Y);
|
||||
break;
|
||||
}
|
||||
//滚轮事件
|
||||
case 0x406: {
|
||||
OnMouseWheel(Wheel, MousePos_X, MousePos_Y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//鼠标事件回调
|
||||
function OnMouseProc(MousePos_X, MousePos_Y) {}
|
||||
//鼠标左键按下回调
|
||||
function OnMouseLbDown(MousePos_X, MousePos_Y) {}
|
||||
//鼠标左键单击回调
|
||||
function OnMouseLbClick(MousePos_X, MousePos_Y) {}
|
||||
//鼠标左键弹起回调
|
||||
function OnMouseLbUp(MousePos_X, MousePos_Y) {}
|
||||
//鼠标右键按下回调
|
||||
function OnMouseRbDown(MousePos_X, MousePos_Y) {}
|
||||
//鼠标右键单击回调
|
||||
function OnMouseRbClick(MousePos_X, MousePos_Y) {}
|
||||
//鼠标右键弹起回调
|
||||
function OnMouseRbUp(MousePos_X, MousePos_Y) {}
|
||||
//鼠标中键按下回调
|
||||
function OnMouseMbDown(MousePos_X, MousePos_Y) {}
|
||||
//鼠标中键单击回调
|
||||
function OnMouseMbClick(MousePos_X, MousePos_Y) {}
|
||||
//鼠标中键弹起回调
|
||||
function OnMouseMbUp(MousePos_X, MousePos_Y) {}
|
||||
//鼠标滚轮事件回调
|
||||
function OnMouseWheel(Wheel, MousePos_X, MousePos_Y) {}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
文件名:IMouse.nut
|
||||
路径:User/UI/Widget/IMouse.nut
|
||||
创建日期:2024-12-18 14:03
|
||||
文件用途:
|
||||
*/
|
||||
class _IMouse_ extends _Yosin_Cursor {
|
||||
|
||||
NormalC = null;
|
||||
//普通状态0
|
||||
State = 0;
|
||||
Idx = 0;
|
||||
|
||||
constructor() {
|
||||
NormalC = [];
|
||||
base.constructor();
|
||||
getroottable().IMouse <- this;
|
||||
|
||||
//关闭系统鼠标
|
||||
Sq_ShowCursor(false);
|
||||
|
||||
//调用父类初始化 将自己添加为UI层子对象
|
||||
Init();
|
||||
//初始化所有普通图标
|
||||
InitSprite();
|
||||
|
||||
//更换为0号指针
|
||||
Change(0);
|
||||
}
|
||||
|
||||
//初始化普通鼠标指针
|
||||
function InitSprite() {
|
||||
for (local i = 0; i< 254; i++) {
|
||||
local Sp = CL_SpriteObject("sprite/interface/newstyle/windows/cursor.img", i);
|
||||
NormalC.push(Sp);
|
||||
}
|
||||
}
|
||||
//更换普通鼠标指针
|
||||
function Change(Idx) {
|
||||
State = 0;
|
||||
this.Idx = Idx;
|
||||
local Sp = NormalC[Idx];
|
||||
base.Change(Sp);
|
||||
}
|
||||
|
||||
function OnMouseProc(MousePos_X, MousePos_Y) {
|
||||
|
||||
}
|
||||
|
||||
//按下
|
||||
function OnMouseLbDown(MousePos_X, MousePos_Y) {
|
||||
//普通状态的点击效果
|
||||
if (Idx == 0) {
|
||||
Change(1);
|
||||
}
|
||||
}
|
||||
|
||||
//抬起
|
||||
function OnMouseLbUp(MousePos_X, MousePos_Y) {
|
||||
//普通状态的点击效果
|
||||
if (Idx == 1) {
|
||||
Change(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -229,6 +229,7 @@ class _CreateCharacter extends Yosin_Window {
|
|||
auraAni = null;
|
||||
|
||||
changJobAniClock = null;
|
||||
changNextJobAniClock = null;
|
||||
|
||||
nextJobIndex = null;
|
||||
|
||||
|
|
@ -267,7 +268,7 @@ class _CreateCharacter extends Yosin_Window {
|
|||
|
||||
// 切换职业
|
||||
function changJob(index) {
|
||||
|
||||
if (index == nextJobIndex) return;
|
||||
|
||||
local jobEnum = getJobEnum(index);
|
||||
|
||||
|
|
@ -302,49 +303,87 @@ class _CreateCharacter extends Yosin_Window {
|
|||
|
||||
|
||||
// 开始切换动画
|
||||
changJobAniClock = clock();
|
||||
// 切换动画中不响应点击
|
||||
headList.clickOff = true;
|
||||
if (changJobAniClock == null) {
|
||||
changJobAniClock = clock();
|
||||
}
|
||||
changNextJobAniClock = clock();
|
||||
}
|
||||
|
||||
// 切换动画控制
|
||||
function changJobAniController(progressBlock, doneBlock, next = true) {
|
||||
|
||||
/// 切换职业动画
|
||||
function changJobAni() {
|
||||
if (changJobAniClock == null) return;
|
||||
|
||||
if (next) {
|
||||
if (changNextJobAniClock == null) {
|
||||
print("NextNull");
|
||||
return;
|
||||
}
|
||||
|
||||
}else {
|
||||
if (changJobAniClock == null) {
|
||||
print("NUll");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 动画的前90%,快,后10%,慢
|
||||
local ani_progress = Math.sq_GetAccel(0, 100, clock() - changJobAniClock, 0.3, false);
|
||||
local ani_progress = Math.sq_GetAccel(0, 100, clock() - (next ? changNextJobAniClock : changJobAniClock), 0.3, false);
|
||||
if (ani_progress >= 90){
|
||||
ani_progress = Math.sq_GetAccel(0, 10, clock() - changJobAniClock, 0.7, false) + 90 ;
|
||||
ani_progress = Math.sq_GetAccel(0, 10, clock() - (next ? changNextJobAniClock : changJobAniClock), 0.7, false) + 90 ;
|
||||
}
|
||||
local x = ani_progress * 5.0;
|
||||
jobImg.SetPosition( 0 - x, 0);
|
||||
nextJobImg.SetPosition(500 - x, 0);
|
||||
jobImg.SetOpacity( (100.0 - ani_progress.tofloat()) / 100.0 );
|
||||
|
||||
// 动画的前90%,透明度进度为50%,后10%,透明度进度为剩下的50%
|
||||
local opacity = ani_progress.tofloat() / 180.0;
|
||||
if (opacity > 0.5) opacity = (ani_progress.tofloat() - 90.0) / 20.0 + 0.5;
|
||||
nextJobImg.SetOpacity( opacity );
|
||||
if (progressBlock != null) progressBlock(ani_progress);
|
||||
|
||||
if (ani_progress >= 100){
|
||||
if (doneBlock != null) doneBlock();
|
||||
}
|
||||
}
|
||||
|
||||
/// 切换当前职业动画
|
||||
function changCurrnentJobAni() {
|
||||
if (changJobAniClock == null) return;
|
||||
|
||||
changJobAniController(function(ani_progress) {
|
||||
local x = ani_progress * 5.0;
|
||||
jobImg.SetPosition( 0 - x, 0);
|
||||
jobImg.SetOpacity( (100.0 - ani_progress.tofloat()) / 100.0 );
|
||||
}.bindenv(this), function () {
|
||||
changJobAniClock = null;
|
||||
}.bindenv(this),false );
|
||||
}
|
||||
|
||||
// 切换职业动画
|
||||
function changNextJobAni() {
|
||||
if (changNextJobAniClock == null) return;
|
||||
|
||||
|
||||
changJobAniController(function(ani_progress) {
|
||||
|
||||
local x = ani_progress * 5.0;
|
||||
nextJobImg.SetPosition(500 - x, 0);
|
||||
|
||||
// 动画的前90%,透明度进度为50%,后10%,透明度进度为剩下的50%
|
||||
local opacity = ani_progress.tofloat() / 180.0;
|
||||
if (opacity > 0.5) opacity = (ani_progress.tofloat() - 90.0) / 20.0 + 0.5;
|
||||
nextJobImg.SetOpacity( opacity );
|
||||
|
||||
}.bindenv(this), function () {
|
||||
changNextJobAniClock = null;
|
||||
|
||||
local jobEnum = getJobEnum(nextJobIndex);
|
||||
jobImg.SetFrame(CL_SpriteFrameObject("sprite/interface2/charactercreatever2/basecharctertitle.img", jobEnum ));
|
||||
jobImg.SetOpacity(1);
|
||||
jobImg.SetPosition(0, 0);
|
||||
|
||||
if (nextJobIndex < 16) {
|
||||
nextJobImg.SetFrame(CL_SpriteFrameObject("sprite/interface2/charactercreatever2/basecharctertitle.img", getJobEnum(nextJobIndex + 1)));
|
||||
nextJobImg.SetOpacity(0);
|
||||
nextJobImg.SetPosition(500, 0);
|
||||
}
|
||||
headList.clickOff = false;
|
||||
}
|
||||
}
|
||||
|
||||
}.bindenv(this) );
|
||||
|
||||
}
|
||||
|
||||
function RegisterDraw() {
|
||||
//大背景
|
||||
|
|
@ -399,8 +438,8 @@ class _CreateCharacter extends Yosin_Window {
|
|||
SyncPos(X, Y);
|
||||
base.Proc(Dt);
|
||||
|
||||
changJobAni();
|
||||
|
||||
changCurrnentJobAni();
|
||||
changNextJobAni();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -452,7 +491,7 @@ class _CreateCharacter_SelectBaseInfo extends Yosin_Window {
|
|||
Addchild(jobChangeText);
|
||||
|
||||
//创建角色按钮
|
||||
local createButton = Yosin_EmeStretch(59, jobChangeTextY + 30, 160, 36, "sprite/interface/lenheartwindowcommon.img", 172);
|
||||
local createButton = Yosin_SplicingButton(59, jobChangeTextY + 30, 160, 36, "sprite/interface/lenheartwindowcommon.img", 172, true, false);
|
||||
//点击事件回调
|
||||
createButton.OnClick = function(Button) {
|
||||
if (OnClick) OnClick();
|
||||
|
|
@ -460,6 +499,7 @@ class _CreateCharacter_SelectBaseInfo extends Yosin_Window {
|
|||
// 按钮文本
|
||||
local createText = CL_SpriteObject("sprite/interface2/charactercreatever2/charctertitle.img", 12);
|
||||
createText.SetPosition(42.5, 8);
|
||||
createText.SetZOrder(10000);
|
||||
createButton.Addchild(createText);
|
||||
AddUIChild(createButton);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue