Add scene debug layer toggles

This commit is contained in:
2026-06-09 15:25:56 +08:00
parent 0a59d20ffa
commit 3a19005bbf
7 changed files with 51 additions and 22 deletions
+28 -17
View File
@@ -34,14 +34,7 @@ void WhiteboxScene::Update(float deltaTime) {
bool WhiteboxScene::OnEvent(const frostbite2D::Event& event) {
if (event.getType() == frostbite2D::EventType::KeyDown) {
const auto& keyEvent = static_cast<const frostbite2D::KeyEvent&>(event);
if (!keyEvent.isRepeat() &&
keyEvent.getKeyCode() == frostbite2D::KeyCode::F1) {
toggleDebugOverlay();
return true;
}
if (!keyEvent.isRepeat() &&
keyEvent.getKeyCode() == frostbite2D::KeyCode::F2) {
clearActiveBattleZone();
if (!keyEvent.isRepeat() && handleDebugKey(keyEvent.getKeyCode())) {
return true;
}
}
@@ -103,16 +96,34 @@ void WhiteboxScene::configureCamera() {
}
}
bool WhiteboxScene::handleDebugKey(frostbite2D::KeyCode keyCode) {
switch (keyCode) {
case frostbite2D::KeyCode::F1:
toggleDebugOverlay();
return true;
case frostbite2D::KeyCode::F2:
clearActiveBattleZone();
return true;
case frostbite2D::KeyCode::F3:
debugFlags_.showCollision = !debugFlags_.showCollision;
debugFlags_.showStageGrid = debugFlags_.showCollision;
return true;
case frostbite2D::KeyCode::F4:
debugFlags_.showActorBounds = !debugFlags_.showActorBounds;
return true;
case frostbite2D::KeyCode::F5:
debugFlags_.showBattleZones = !debugFlags_.showBattleZones;
return true;
case frostbite2D::KeyCode::F6:
debugFlags_.showSpawnPoints = !debugFlags_.showSpawnPoints;
return true;
default:
return false;
}
}
void WhiteboxScene::toggleDebugOverlay() {
const bool enabled = !(debugFlags_.showStageGrid || debugFlags_.showCollision ||
debugFlags_.showActorBounds ||
debugFlags_.showBattleZones ||
debugFlags_.showSpawnPoints);
debugFlags_.showStageGrid = enabled;
debugFlags_.showCollision = enabled;
debugFlags_.showActorBounds = enabled;
debugFlags_.showBattleZones = enabled;
debugFlags_.showSpawnPoints = enabled;
debugFlags_.enabled = !debugFlags_.enabled;
}
void WhiteboxScene::beginCameraBoundsBlend(
+1
View File
@@ -30,6 +30,7 @@ private:
frostbite2D::Camera* activeCamera() const;
std::vector<BattleZoneDebugInfo> buildBattleZoneDebugInfo() const;
void configureCamera();
bool handleDebugKey(frostbite2D::KeyCode keyCode);
void toggleDebugOverlay();
void beginCameraBoundsBlend(const frostbite2D::Rect& targetBounds);
void clearActiveBattleZone();