feat(ui): 小地图(左上角地表色图+玩家标记)与物品栏界面(E 键/Q 丢弃)

- 小地图(UI还原.md §3.5):96×96 地表色图(方块注册表→图集中心色,
  植被染色后采样),每 1.5s 重建,玩家标记烘焙进地图图(白点+黑描边);
  覆盖层 quad 批处理末尾颜色异常,标记改走烘焙规避
- 物品栏(UI还原.md §3.3):E 键开关屏幕状态 5,inventory.png 176×166
  窗口 + 27 主物品区 (7,83) + 热键栏行 (7,141),点击与手持栈交换/合并,
  Esc 关闭手持栈自动回收
- Q 丢弃选中槽 1 个物品(掉落在视线前方,UI与输入.md §5)
- cjkfont 多行渲染(设置界面按键教程 4 行列表)
- 动物攻击测试、原版掉落测试(草→泥土/动物掉肉)
This commit is contained in:
NianGao Dev
2026-08-16 20:35:21 +08:00
parent f25ae15077
commit 5da460c9a2
8 changed files with 380 additions and 11 deletions

View File

@@ -31,7 +31,9 @@ type inputState struct {
breakDown bool
breakHeld bool
placeDown bool
selectSlot int // -1 无
selectSlot int // -1 无
toggleInv bool // E 打开/关闭物品栏
dropItem bool // Q 丢弃选中槽 1 个物品
// 鼠标与 UI 事件(UI与输入.md §6 屏幕交互)
cursorX, cursorY float64
@@ -86,6 +88,14 @@ func (in *inputState) keyCallback(_ *glfw.Window, key glfw.Key, _ int, action gl
if action == glfw.Press {
in.selectSlot = int(key) - int(glfw.Key1)
}
case glfw.KeyE:
if action == glfw.Press {
in.toggleInv = true // 物品栏开关(UI还原.md §3.3)
}
case glfw.KeyQ:
if action == glfw.Press {
in.dropItem = true // 丢弃物品(UI与输入.md §5)
}
}
}
@@ -225,6 +235,11 @@ func (in *inputState) apply(s *game.Session) {
}
in.placeDown = false
}
// 丢弃选中槽 1 个物品(UI与输入.md §5 Q 键)
if in.dropItem {
s.DropSelected()
in.dropItem = false
}
}
var _ = physics.Player{} // 保持引用(后续输入扩展用)