Repository navigation
feat: 统一游戏目录与输入并持久化个人纪录(beta7) - #6
Conversation
| int availableH = this.height - 120; | ||
| gamesPerPage = Math.max(4, availableH / cardH); | ||
| controlsWidth = -1; | ||
| gamesPerPage = Math.max(1, (height - listStartY() - 46) / 28); |
There was a problem hiding this comment.
WARNING: init() calls listStartY() before controls() has been computed for the new width. listStartY() invokes controls(), which recomputes the layout, so the call is not redundant, but the result is computed twice per init() (once here, again at the top of render()). More importantly, gamesPerPage is derived from listStartY() before the controls row has actually been laid out for this width — the layout is correct because controls() recomputes on demand, but the page count is sensitive to the final control bottom edge. If controls() ever started caching by width without recomputation (it already guards on controlsWidth == width), listStartY() would read a stale row and gamesPerPage would be wrong. Consider computing the control row once in init() and deriving both listStartY() and gamesPerPage from that single layout.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
|
|
||
| // ─── 导入设置按钮 ─── | ||
| GameRenderHelper.drawButton(g, font, "导入设置", 5, height - 24, 60, 18, mouseX, mouseY, | ||
| GameRenderHelper.drawButton(g, font, GameText.text("gui.game_console.import"), 5, height - 46, 60, 18, mouseX, mouseY, |
There was a problem hiding this comment.
WARNING: The Import button is drawn at y = height - 46 but the click handler tests my >= height - 46 && my <= height - 28 (line 315), while the import status message is drawn at y = height - 40 (line 188). The message row overlaps the button row, so a success/failure toast renders directly on top of the Import button. On short windows the toast can also collide with the pagination bar at navY = height - 24. Consider separating the message row from the button row (e.g. move the toast above the bottom bar or reserve a distinct band).
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
|
|
||
| protected boolean handleExitKey(int key, boolean inGame) { | ||
| if (key == GLFW.GLFW_KEY_ESCAPE) { | ||
| if (input.press(key) != EXIT) return true; |
There was a problem hiding this comment.
WARNING: In handleExitKey, pressing ESC while the exit confirmation is showing calls input.press(key) and then input.clear(). press() registers the key in the pressed set and increments the EXIT action counter, and clear() then blocks that key until release. This is harmless for ESC because the confirmation path immediately clears and returns, but any non-ESC key pressed while the confirm overlay is up (or while the window is unfocused) is swallowed and blocked until release. If the user presses a movement key during the confirm overlay and the overlay is dismissed, that keypress is permanently lost and will not retrigger on the next tick — consistent with the design, but worth documenting so future contributors do not "fix" it by removing the block.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
| root.add("players", jsonPlayers); | ||
| Path temp = null; | ||
| try { | ||
| byte[] content = new GsonBuilder().setPrettyPrinting().create().toJson(root).getBytes(StandardCharsets.UTF_8); |
There was a problem hiding this comment.
SUGGESTION: new GsonBuilder().setPrettyPrinting().create() is allocated on every save() call. Gson JsonWriter instances are not thread-safe but the Gson instance itself is, so the builder (and the resulting Gson) could be created once as a static final and reused, avoiding per-save allocation and instance creation on the hot save path.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (3 files)
Fix these issues in Kilo Cloud Previous Review Summary (commit 7045efc)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 7045efc)Status: 4 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (25 files)
Reviewed by free · Input: 249.9K · Output: 8.5K · Cached: 82.1K |
| if (available <= 0) return; | ||
| String message = importMessage; | ||
| boolean shortened = font.width(message) > available; | ||
| if (shortened) { |
There was a problem hiding this comment.
SUGGESTION: Silent return when available space < ellipsis width
If available < font.width(suffix) (i.e., window too narrow for "..."), the method returns without drawing anything. The import status message silently disappears, which could confuse users. Consider drawing a minimal indicator or at least the ellipsis when space permits.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
| }; | ||
| private void renderImportMessage(GuiGraphics g, int mouseX, int mouseY) { | ||
| // Keep the status beside the import button and above the pagination row. | ||
| int x = 73, y = height - 40; |
There was a problem hiding this comment.
SUGGESTION: Hardcoded positioning couples message to button layout
x = 73 and available = width - x - 8 use magic numbers that assume the Import button stays at x=5, width=60. If the button position/size changes (e.g., localization, layout tweaks), the message position becomes inconsistent. Consider computing position relative to the button's actual bounds.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
选择器和联机大厅分别维护游戏清单,键盘操作受系统重复事件影响,部分小游戏最高分在关闭界面后丢失。本次统一目录和输入处理,并为四款游戏增加个人纪录持久化,构建产物更新为 beta7。
改动
设计参考 Tejty/GameDiscs 的 NeoForge 1.21.1 分支,按本项目行为重新实现。
验证
Java 21 / Minecraft 1.21.1 / NeoForge 21.1.241:
gradlew.bat test --rerun build --no-build-cache --no-daemon --offline --max-workers=1 --console=plain成功,38 套件、258 项测试,失败/错误/跳过均为 0。以下全局压力数据来自初始功能提交
7045efc;本次审查修复的当前代码另外通过下述完整回归及专项客户端/并发验证。初始成品全局压力:20,790 次回归方法检查、2,000 局斗地主、640 万次会话序列逐调用断言、50,000 次推箱子生成与 2,000 张盘面独立 BFS 求解;中国象棋 128 局、五子棋 120 局,无崩溃或非法落子。
RTX 2060:30,720 次并发推理与 CPU 比较通过,60 次原生上下文生命周期、360 个变长批次、120 次训练更新通过。
新功能压力:600,000 次分数更新、320 次并发保存,重载核验 8,192 个隔离键;2,000,000 次随机输入与独立模型对照,50,000 个布局边界检查通过。
真实客户端:32 款游戏共 640 次创建/关闭,三种窗口尺寸、1,920 次渲染、57,600 tick;另 12 款游戏累计 300,000 tick。关闭后的 Screen 弱引用全部回收,20 轮线程数稳定,预热后保留堆增长 23,856 bytes。
Tetris/Flappy 输入各 1,000 轮及双语菜单压力通过;9 款游戏按正常客户端节奏运行共 1,800 tick,无音频通道耗尽警告。
beta7 JAR 审计通过,252 个产品 class 与客户端输出逐项字节一致,SHA-256:
cf2631f54cc0f486fc449453165492011f932b10bd8e268236a8b7f0f5119409。当前审查修复还通过真实 NeoForge 客户端的 30 个中英文提示场景(960×540、480×270、240×180),覆盖成功/失败颜色、长文本、完整悬停提示和 3 秒过期,另验证极窄宽度边界。共享 Gson 由 16 个存储实例并发执行 1,024 次保存,重载核验通过。暂停/失焦按键必须先释放才能重新触发的设计已在代码中说明。
压测脚本最初把随机 Tetris 方块的初始横坐标写死,改为相对位移后复测通过。一次 NeoForge 早期窗口交接超时发生在检查执行前,仅在隔离测试目录关闭早期窗口后重试成功。加速 tick 的音频通道警告在正常节奏复核中未复现。
本轮为有界压力测试,未覆盖数小时耐久运行、双客户端真实网络对局或真实 KataGo/Pikafish 外部引擎;客户端检查没有进入玩家世界,分数并发压力覆盖存储层。