feat(Steal): 扩展密码框功能并改进锁定机制

- 增加密码字符集支持字母和数字
- 将线性锁定检测改为矩形区域检测
- 添加停止位置偏移量以优化视觉效果
- 实现解锁进度自动计算功能
- 调整默认参数和初始化逻辑
This commit is contained in:
2026-04-09 05:40:23 +08:00
parent 105c9c5d41
commit 8c9c9d718a

View File

@@ -18,7 +18,9 @@ class StealC_Password_Box extends LenheartNewUI_CommonUi {
CorrectIndex = 0; CorrectIndex = 0;
IsStopped = false; IsStopped = false;
IsLockedCorrect = false; IsLockedCorrect = false;
StopSnapOffsetY = 0;
PassStr = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
constructor(X, Y, ...) { constructor(X, Y, ...) {
LenheartNewUI_CommonUi.constructor(X, Y, 30, 120); LenheartNewUI_CommonUi.constructor(X, Y, 30, 120);
@@ -31,7 +33,7 @@ class StealC_Password_Box extends LenheartNewUI_CommonUi {
NumberSeq = []; NumberSeq = [];
for (local i = 0; i < 10; i++) { for (local i = 0; i < 10; i++) {
local Info = { local Info = {
num = sq_getRandom(0, 9), num = PassStr[sq_getRandom(0, PassStr.len() - 1)],
CorrectFlag = false, CorrectFlag = false,
} }
NumberSeq.append(Info); NumberSeq.append(Info);
@@ -100,15 +102,15 @@ class StealC_Password_Box extends LenheartNewUI_CommonUi {
return BestY; return BestY;
} }
function TryLockByLine(LockCenterY, TolerancePx) { function TryLockByRect(LockTopY, LockHeight, SnapExtraOffsetY) {
if (IsStopped) { if (IsStopped) {
return false; return false;
} }
if (!IsStopped) { UpdateScrollByClock();
UpdateScrollByClock(); local LockCenterY = LockTopY + (LockHeight / 2).tointeger();
} local CorrectCenterY = GetCorrectCenterY(LockCenterY);
local Dist = abs(GetCorrectCenterY(LockCenterY) - LockCenterY); if (CorrectCenterY >= LockTopY && CorrectCenterY <= (LockTopY + LockHeight)) {
if (Dist <= TolerancePx) { StopSnapOffsetY = (LockCenterY - CorrectCenterY) + SnapExtraOffsetY;
IsStopped = true; IsStopped = true;
IsLockedCorrect = true; IsLockedCorrect = true;
return true; return true;
@@ -134,13 +136,14 @@ class StealC_Password_Box extends LenheartNewUI_CommonUi {
local Info = NumberSeq[GetLoopIndex(ScrollBaseIndex + i)]; local Info = NumberSeq[GetLoopIndex(ScrollBaseIndex + i)];
local NumStr = Info.num.tostring(); local NumStr = Info.num.tostring();
local Color = Info.CorrectFlag ? sq_RGBA(157, 245, 10, 255) : sq_RGBA(150, 150, 150, 255); local Color = Info.CorrectFlag ? sq_RGBA(157, 245, 10, 255) : sq_RGBA(150, 150, 150, 255);
local DrawY = TextY + i * RowHeight + ScrollPixelOffset + ColumnYOffset; local DrawY = TextY + i * RowHeight + ScrollPixelOffset + ColumnYOffset + StopSnapOffsetY;
L_sq_DrawCode(NumStr, X + 15 - LenheartTextClass.GetStringLength(NumStr) / 2, DrawY, Color, 0, 1); L_sq_DrawCode(NumStr, X + 15 - LenheartTextClass.GetStringLength(NumStr) / 2, DrawY, Color, 0, 1);
} }
} }
} }
class StealC extends LenheartNewUI_Windows { class StealC extends LenheartNewUI_Windows {
//调试模式 //调试模式
// DeBugMode = true; // DeBugMode = true;
@@ -154,9 +157,10 @@ class StealC extends LenheartNewUI_Windows {
Img = Rindro_Image("steal/widget.img"); Img = Rindro_Image("steal/widget.img");
//解锁完成度 //解锁完成度
UnlockComplete = 0.57; UnlockComplete = 0.0;
CorrectLockedCount = 0; CorrectLockedCount = 0;
LockTolerancePx = 8; LockBoxHeight = 24;
LockSnapOffsetY = -6;
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) { constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
Childrens = []; Childrens = [];
@@ -164,6 +168,7 @@ class StealC extends LenheartNewUI_Windows {
RegisterWidget(); RegisterWidget();
LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH); LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
RefreshUnlockComplete();
} }
function RegisterWidget() { function RegisterWidget() {
@@ -182,7 +187,7 @@ class StealC extends LenheartNewUI_Windows {
//绘制主界面 //绘制主界面
function GetLockCenterY() { function GetLockTopY() {
return Y + 268 + 60; return Y + 268 + 60;
} }
@@ -195,6 +200,25 @@ class StealC extends LenheartNewUI_Windows {
return null; return null;
} }
function GetPasswordBoxTotal() {
local Total = 0;
foreach(Child in Childrens) {
if (Child instanceof StealC_Password_Box) {
Total += 1;
}
}
return Total;
}
function RefreshUnlockComplete() {
local Total = GetPasswordBoxTotal();
if (Total <= 0) {
UnlockComplete = 0.0;
return;
}
UnlockComplete = CorrectLockedCount.tofloat() / Total.tofloat();
}
function CheckSpaceLock() { function CheckSpaceLock() {
if (!Visible) { if (!Visible) {
return; return;
@@ -206,8 +230,9 @@ class StealC extends LenheartNewUI_Windows {
if (!FocusBox) { if (!FocusBox) {
return; return;
} }
if (FocusBox.TryLockByLine(GetLockCenterY(), LockTolerancePx)) { if (FocusBox.TryLockByRect(GetLockTopY(), LockBoxHeight, LockSnapOffsetY)) {
CorrectLockedCount += 1; CorrectLockedCount += 1;
RefreshUnlockComplete();
} }
} }