From 105c9c5d4190100ddd6d2ea08e36696460a3fcb7 Mon Sep 17 00:00:00 2001 From: Lenheart <947330670@qq.com> Date: Wed, 8 Apr 2026 23:36:24 +0800 Subject: [PATCH] =?UTF-8?q?feat(Steal):=20=E6=B7=BB=E5=8A=A0=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E6=A1=86=E9=94=81=E5=AE=9A=E5=8A=9F=E8=83=BD=E5=8F=8A?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E9=94=81=E5=AE=9A=E8=AE=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 实现密码框滚动停止和锁定功能,当用户按下空格时尝试锁定当前焦点密码框 新增正确锁定计数功能,用于追踪成功锁定的次数 添加相关状态变量和方法支持锁定逻辑 --- Project/Steal/Steal.nut | 79 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 2 deletions(-) diff --git a/Project/Steal/Steal.nut b/Project/Steal/Steal.nut index d1c364a..9decee4 100644 --- a/Project/Steal/Steal.nut +++ b/Project/Steal/Steal.nut @@ -15,6 +15,9 @@ class StealC_Password_Box extends LenheartNewUI_CommonUi { RowDurationMs = 500; RowHeight = 24; ColumnYOffset = 0; + CorrectIndex = 0; + IsStopped = false; + IsLockedCorrect = false; constructor(X, Y, ...) { @@ -34,7 +37,7 @@ class StealC_Password_Box extends LenheartNewUI_CommonUi { NumberSeq.append(Info); } - local CorrectIndex = sq_getRandom(0, 9); + CorrectIndex = sq_getRandom(0, 9); NumberSeq[CorrectIndex].CorrectFlag = true; local SeqLen = NumberSeq.len(); @@ -75,6 +78,44 @@ class StealC_Password_Box extends LenheartNewUI_CommonUi { ScrollBaseIndex = GetLoopIndex(InitBaseIndex - PassedRows); } + function GetCorrectCenterY(RefY) { + local SeqLen = NumberSeq.len(); + if (SeqLen <= 0) { + return Y; + } + local Delta = GetLoopIndex(CorrectIndex - ScrollBaseIndex); + local TextY = Y + 10; + local BaseY = TextY + Delta * RowHeight + ScrollPixelOffset + ColumnYOffset + 8; + local CycleHeight = SeqLen * RowHeight; + local BestY = BaseY; + local BestDist = abs(BestY - RefY); + for (local k = -2; k <= 2; k++) { + local CY = BaseY + (k * CycleHeight); + local Dist = abs(CY - RefY); + if (Dist < BestDist) { + BestY = CY; + BestDist = Dist; + } + } + return BestY; + } + + function TryLockByLine(LockCenterY, TolerancePx) { + if (IsStopped) { + return false; + } + if (!IsStopped) { + UpdateScrollByClock(); + } + local Dist = abs(GetCorrectCenterY(LockCenterY) - LockCenterY); + if (Dist <= TolerancePx) { + IsStopped = true; + IsLockedCorrect = true; + return true; + } + return false; + } + function Show(obj) { Parent.Img.DrawExPng(10, X, Y, 0, sq_RGBA(255, 255, 255, 90), 1.0, 1.0); @@ -83,7 +124,9 @@ class StealC_Password_Box extends LenheartNewUI_CommonUi { return; } - UpdateScrollByClock(); + if (!IsStopped) { + UpdateScrollByClock(); + } local DrawCount = (Height / RowHeight).tointeger() + 4; local TextY = Y + 10; @@ -112,6 +155,8 @@ class StealC extends LenheartNewUI_Windows { //解锁完成度 UnlockComplete = 0.57; + CorrectLockedCount = 0; + LockTolerancePx = 8; constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) { Childrens = []; @@ -137,6 +182,35 @@ class StealC extends LenheartNewUI_Windows { //绘制主界面 + function GetLockCenterY() { + return Y + 268 + 60; + } + + function GetFocusPasswordBox() { + foreach(Child in Childrens) { + if ((Child instanceof StealC_Password_Box) && !Child.IsStopped) { + return Child; + } + } + return null; + } + + function CheckSpaceLock() { + if (!Visible) { + return; + } + if (!KeyPressNB.isKeyPress(7, "StealC")) { + return; + } + local FocusBox = GetFocusPasswordBox(); + if (!FocusBox) { + return; + } + if (FocusBox.TryLockByLine(GetLockCenterY(), LockTolerancePx)) { + CorrectLockedCount += 1; + } + } + function DrawMain(obj) { //灰色背景 DrawNineBoxAlpha(X, Y, 800, 600, "interface2/common/mypopup/popup.img", 0, 150); @@ -176,6 +250,7 @@ class StealC extends LenheartNewUI_Windows { //逻辑入口 function Proc(obj) { LenheartNewUI_Windows.SyncPos(X, Y); + CheckSpaceLock(); } }