From 531b94a0acd07016d86ebd6828f4073a2022c79b Mon Sep 17 00:00:00 2001 From: konstin Date: Tue, 30 Dec 2014 18:27:24 +0100 Subject: [PATCH] cleaning up and adding radius and energy sliders --- data/gui/debug_slider.stkgui | 22 +++++------ src/graphics/light.hpp | 6 ++- src/states_screens/dialogs/debug_slider.cpp | 12 +++--- src/states_screens/dialogs/debug_slider.hpp | 3 +- src/utils/debug.cpp | 41 +++++++++++++++------ 5 files changed, 52 insertions(+), 32 deletions(-) diff --git a/data/gui/debug_slider.stkgui b/data/gui/debug_slider.stkgui index a0285405c..c1764f484 100644 --- a/data/gui/debug_slider.stkgui +++ b/data/gui/debug_slider.stkgui @@ -2,37 +2,37 @@
-
- +
-
- +
-
- +
-
- +
-
- +
-
diff --git a/src/graphics/light.hpp b/src/graphics/light.hpp index 1ecb3c119..c3a830e30 100644 --- a/src/graphics/light.hpp +++ b/src/graphics/light.hpp @@ -62,7 +62,11 @@ public: void setColor(float r, float g, float b) { m_color[0] = r; m_color[1] = g; m_color[2] = b; } float getEnergyMultiplier() const { return m_energy_multiplier; } - void setEnergyMultiplier(float newval) { m_energy_multiplier = newval; } + void setEnergyMultiplier(float newval) { m_energy_multiplier = newval; } + + // For the debug menu + void setEnergy(float energy) { m_energy = energy; } + void setRadius(float radius) { m_radius = radius; } protected: static core::aabbox3df box; diff --git a/src/states_screens/dialogs/debug_slider.cpp b/src/states_screens/dialogs/debug_slider.cpp index 38a210b51..2e16c817e 100644 --- a/src/states_screens/dialogs/debug_slider.cpp +++ b/src/states_screens/dialogs/debug_slider.cpp @@ -51,12 +51,9 @@ void DebugSliderDialog::setSliderHook(std::string id, unsigned min, unsigned max // ------------------------------------------------------------------------------------------------------ -DebugSliderDialog::~DebugSliderDialog() +void DebugSliderDialog::changeLabel(std::string id, std::string new_label) { - //if (StateManager::get()->getGameState() == GUIEngine::GAME) - //{ - // World::getWorld()->scheduleUnpause(); - //} + getWidget(id.c_str())->setText(stringw(new_label.c_str()), true); } // ------------------------------------------------------------------------------------------------------ @@ -71,13 +68,14 @@ GUIEngine::EventPropagation DebugSliderDialog::processEvent(const std::string& e { #if !defined(__APPLE__) if (Setters.find(eventSource) == Setters.end()) -#endif return GUIEngine::EVENT_LET; -#if !defined(__APPLE__) + int value = getWidget(eventSource.c_str())->getValue(); Log::info("DebugSlider", "Value for <%s> : %i", eventSource.c_str(), value); Setters[eventSource](value); return GUIEngine::EVENT_BLOCK; +#else + return GUIEngine::EVENT_LET; #endif } diff --git a/src/states_screens/dialogs/debug_slider.hpp b/src/states_screens/dialogs/debug_slider.hpp index 8cd01acbc..ea3dcf011 100644 --- a/src/states_screens/dialogs/debug_slider.hpp +++ b/src/states_screens/dialogs/debug_slider.hpp @@ -40,10 +40,11 @@ private: public: DebugSliderDialog(); - ~DebugSliderDialog(); + ~DebugSliderDialog() {}; #if !defined(__APPLE__) void setSliderHook(std::string id, unsigned min, unsigned max, std::function G, std::function S); #endif + void changeLabel(std::string id, std::string new_label); virtual void onEnterPressedInternal() OVERRIDE; virtual void onUpdate(float dt) OVERRIDE; diff --git a/src/utils/debug.cpp b/src/utils/debug.cpp index 45da6db7a..2c66d4d52 100644 --- a/src/utils/debug.cpp +++ b/src/utils/debug.cpp @@ -101,7 +101,7 @@ enum DebugMenuCommand DEBUG_THROTTLE_FPS, DEBUG_VISUAL_VALUES, DEBUG_PRINT_START_POS, - DEBUG_LIGHT_SETTINGS, + DEBUG_ADJUST_LIGHTS, }; // DebugMenuCommand // ----------------------------------------------------------------------------- @@ -157,8 +157,7 @@ float distance(core::vector3df one, core::vector3df two) // ----------------------------------------------------------------------------- /** returns the light node with the lowest distance to the player kart (excluding - * nitro emitters) - */ + * nitro emitters) */ LightNode* findNearestLight() { World* world = World::getWorld(); @@ -276,11 +275,11 @@ bool onEvent(const SEvent &event) mnu->addItem(L"Toggle capture profiler report", DEBUG_PROFILER_GENERATE_REPORT); mnu->addItem(L"Do not limit FPS", DEBUG_THROTTLE_FPS); - mnu->addItem(L"FPS", DEBUG_FPS); + mnu->addItem(L"Show FPS", DEBUG_FPS); mnu->addItem(L"Save replay", DEBUG_SAVE_REPLAY); mnu->addItem(L"Save history", DEBUG_SAVE_HISTORY); mnu->addItem(L"Print position", DEBUG_PRINT_START_POS); - mnu->addItem(L"Debug Light Setting", DEBUG_LIGHT_SETTINGS); + mnu->addItem(L"Adjust Lights", DEBUG_ADJUST_LIGHTS); g_debug_menu_visible = true; irr_driver->showPointer(); @@ -599,45 +598,63 @@ bool onEvent(const SEvent &event) ); #endif } - else if (cmdID == DEBUG_LIGHT_SETTINGS) + else if (cmdID == DEBUG_ADJUST_LIGHTS) { +#if !defined(__APPLE__) + // Some sliders use multipliers because the spinner widget + // only supports integers DebugSliderDialog *dsd = new DebugSliderDialog(); + dsd->changeLabel("Red", "Red (x10)"); dsd->setSliderHook("red_slider", 0, 100, []() { - return findNearestLight()->getColor().X*100; + return findNearestLight()->getColor().X * 100; }, [](int intensity) { LightNode* nearest = findNearestLight(); core::vector3df color = nearest->getColor(); - nearest->setColor(intensity/100.0, color.Y, color.Z); + nearest->setColor(intensity / 100.0, color.Y, color.Z); } ); + dsd->changeLabel("Green", "Green (x10)"); dsd->setSliderHook("green_slider", 0, 100, []() { - return findNearestLight()->getColor().Y*100; + return findNearestLight()->getColor().Y * 100; }, [](int intensity) { LightNode* nearest = findNearestLight(); core::vector3df color = nearest->getColor(); - nearest->setColor(color.X, intensity/100.0, color.Z); + nearest->setColor(color.X, intensity / 100.0, color.Z); } ); + dsd->changeLabel("Blue", "Blue (x10)"); dsd->setSliderHook("blue_slider", 0, 100, []() { - return findNearestLight()->getColor().Z*100; + return findNearestLight()->getColor().Z * 100; }, [](int intensity) { LightNode* nearest = findNearestLight(); core::vector3df color = nearest->getColor(); - nearest->setColor(color.X, color.Y, intensity/100.0); + nearest->setColor(color.X, color.Y, intensity / 100.0); } ); + dsd->changeLabel("SSAO radius", "energy (x10)"); + dsd->setSliderHook("ssao_radius", 0, 100, + []() { return findNearestLight()->getEnergy() * 10; }, + [](int v){ findNearestLight()->setEnergy(v / 10.0); } + ); + dsd->changeLabel("SSAO k", "radius"); + dsd->setSliderHook("ssao_k", 0, 100, + []() { return findNearestLight()->getRadius(); }, + [](int v){ findNearestLight()->setRadius(v); } + ); + dsd->changeLabel("SSAO Sigma", "[None]"); +#endif } }