cleaning up and adding radius and energy sliders

This commit is contained in:
konstin 2014-12-30 18:27:24 +01:00
parent 334245183e
commit 531b94a0ac
5 changed files with 52 additions and 32 deletions

View File

@ -2,37 +2,37 @@
<stkgui>
<div x="2%" y="10%" width="96%" height="80%" layout="vertical-row" >
<div proportion="1" width="100%" layout="horizontal-row">
<label id="Red" raw_text="Red"/>
<label id="Red" raw_text="Red" width="200"/>
<spacer width="25"/>
<gauge id="red_slider" min_value="0" max_value="100" proportion="1"/>
</div>
<div proportion="1" width="100%" layout="horizontal-row">
<label id="Green" raw_text="Green"/>
<label id="Green" raw_text="Green" width="200"/>
<spacer width="25"/>
<gauge id="green_slider" min_value="0" max_value="100" proportion="1"/>
</div>
<div proportion="1" width="100%" layout="horizontal-row">
<label id="Blue" raw_text="Blue"/>
<label id="Blue" raw_text="Blue" width="200"/>
<spacer width="25"/>
<gauge id="blue_slider" min_value="0" max_value="100" proportion="1"/>
</div>
<div proportion="1" width="100%" layout="horizontal-row">
<label id="SSAO radius" raw_text="SSAO Radius"/>
<label id="SSAO radius" raw_text="SSAO Radius" width="200"/>
<spacer width="50"/>
<gauge id="ssao_radius" min_value="0" max_value="100" proportion="1" />
</div>
<div proportion="1" width="100%" layout="horizontal-row">
<label id="SSAO k" raw_text="SSAO K"/>
<label id="SSAO k" raw_text="SSAO K" width="200"/>
<spacer width="25"/>
<gauge id="ssao_k" min_value="0" max_value="100" proportion="1"/>
</div>
<div proportion="1" width="100%" layout="horizontal-row">
<label id="SSAO Sigma" raw_text="SSAO sigma"/>
<label id="SSAO Sigma" raw_text="SSAO sigma" width="200"/>
<spacer width="50"/>
<gauge id="ssao_sigma" min_value="0" max_value="100" proportion="1"/>
</div>

View File

@ -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;

View File

@ -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<LabelWidget>(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<SpinnerWidget>(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
}

View File

@ -40,10 +40,11 @@ private:
public:
DebugSliderDialog();
~DebugSliderDialog();
~DebugSliderDialog() {};
#if !defined(__APPLE__)
void setSliderHook(std::string id, unsigned min, unsigned max, std::function<int()> G, std::function<void(int)> S);
#endif
void changeLabel(std::string id, std::string new_label);
virtual void onEnterPressedInternal() OVERRIDE;
virtual void onUpdate(float dt) OVERRIDE;

View File

@ -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
}
}