summaryrefslogtreecommitdiff
path: root/src/render
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2012-09-26 00:32:30 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-09-26 15:46:03 (GMT)
commit95cc715d71f6fb1a9887272e9cb5a0dc14e2da4e (patch)
tree0dd953c351bc44b011d962d39de8fbbe047ee94d /src/render
parent0f38fa71ab19db40449cb0b9884899f529f4cc25 (diff)
downloadpowder-95cc715d71f6fb1a9887272e9cb5a0dc14e2da4e.zip
powder-95cc715d71f6fb1a9887272e9cb5a0dc14e2da4e.tar.gz
render preset buttons in render options interface, also shift + 1 life view shortcut
modify it if you don't like how it looks, but it turned out better than I expected
Diffstat (limited to 'src/render')
-rw-r--r--src/render/RenderController.cpp5
-rw-r--r--src/render/RenderController.h1
-rw-r--r--src/render/RenderModel.cpp11
-rw-r--r--src/render/RenderModel.h1
-rw-r--r--src/render/RenderView.cpp128
-rw-r--r--src/render/RenderView.h3
6 files changed, 127 insertions, 22 deletions
diff --git a/src/render/RenderController.cpp b/src/render/RenderController.cpp
index 75227cd..e98200a 100644
--- a/src/render/RenderController.cpp
+++ b/src/render/RenderController.cpp
@@ -45,6 +45,11 @@ void RenderController::SetColourMode(unsigned int renderMode)
renderModel->SetColourMode(renderMode);
}
+void RenderController::LoadRenderPreset(int presetNum)
+{
+ renderModel->LoadRenderPreset(presetNum);
+}
+
void RenderController::Exit()
{
if(ui::Engine::Ref().GetWindow() == renderView)
diff --git a/src/render/RenderController.h b/src/render/RenderController.h
index 37592ac..8ea44a4 100644
--- a/src/render/RenderController.h
+++ b/src/render/RenderController.h
@@ -30,6 +30,7 @@ public:
void SetDisplayMode(unsigned int renderMode);
void UnsetDisplayMode(unsigned int renderMode);
void SetColourMode(unsigned int renderMode);
+ void LoadRenderPreset(int presetNum);
};
#endif /* RENDERCONTROLLER_H_ */
diff --git a/src/render/RenderModel.cpp b/src/render/RenderModel.cpp
index be3b30a..556493c 100644
--- a/src/render/RenderModel.cpp
+++ b/src/render/RenderModel.cpp
@@ -81,6 +81,17 @@ unsigned int RenderModel::GetColourMode()
return 0;
}
+void RenderModel::LoadRenderPreset(int presetNum)
+{
+ RenderPreset preset = renderer->renderModePresets[presetNum];
+ renderer->SetRenderMode(preset.RenderModes);
+ renderer->SetDisplayMode(preset.DisplayModes);
+ renderer->SetColourMode(preset.ColourMode);
+ notifyRenderChanged();
+ notifyDisplayChanged();
+ notifyColourChanged();
+}
+
void RenderModel::SetRenderer(Renderer * ren)
{
renderer = ren;
diff --git a/src/render/RenderModel.h b/src/render/RenderModel.h
index 7d25f50..8a8b1cd 100644
--- a/src/render/RenderModel.h
+++ b/src/render/RenderModel.h
@@ -35,6 +35,7 @@ public:
unsigned int GetDisplayMode();
void SetColourMode(unsigned int colourMode);
unsigned int GetColourMode();
+ void LoadRenderPreset(int presetNum);
virtual ~RenderModel();
};
diff --git a/src/render/RenderView.cpp b/src/render/RenderView.cpp
index 6327ce3..2455447 100644
--- a/src/render/RenderView.cpp
+++ b/src/render/RenderView.cpp
@@ -67,121 +67,194 @@ public:
}
};
+class RenderView::RenderPresetAction: public ui::ButtonAction
+{
+ RenderView * v;
+public:
+ int renderPreset;
+ RenderPresetAction(RenderView * v_, int renderPreset_)
+ {
+ v = v_;
+ renderPreset = renderPreset_;
+ }
+ virtual void ActionCallback(ui::Button * sender)
+ {
+ v->c->LoadRenderPreset(renderPreset);
+ }
+};
+
RenderView::RenderView():
ui::Window(ui::Point(0, 0), ui::Point(XRES, YRES+MENUSIZE)),
toolTip(""),
toolTipPresence(0),
ren(NULL)
{
+ ui::Button * presetButton;
+
+ presetButton = new ui::Button(ui::Point(5, YRES+6), ui::Point(30, 13), "", "Velocity display mode preset");
+ presetButton->SetIcon(IconVelocity);
+ presetButton->SetActionCallback(new RenderPresetAction(this, 1));
+ AddComponent(presetButton);
+
+ presetButton = new ui::Button(ui::Point(5, YRES+6+18), ui::Point(30, 13), "", "Pressure display mode preset");
+ presetButton->SetIcon(IconPressure);
+ presetButton->SetActionCallback(new RenderPresetAction(this, 2));
+ AddComponent(presetButton);
+
+ presetButton = new ui::Button(ui::Point(44, YRES+6), ui::Point(30, 13), "", "Persistant display mode preset");
+ presetButton->SetIcon(IconPersistant);
+ presetButton->SetActionCallback(new RenderPresetAction(this, 3));
+ AddComponent(presetButton);
+
+ presetButton = new ui::Button(ui::Point(44, YRES+6+18), ui::Point(30, 13), "", "Fire display mode preset");
+ presetButton->SetIcon(IconFire);
+ presetButton->SetActionCallback(new RenderPresetAction(this, 4));
+ AddComponent(presetButton);
+
+ presetButton = new ui::Button(ui::Point(83, YRES+6), ui::Point(30, 13), "", "Blob display mode preset");
+ presetButton->SetIcon(IconBlob);
+ presetButton->SetActionCallback(new RenderPresetAction(this, 5));
+ AddComponent(presetButton);
+
+ presetButton = new ui::Button(ui::Point(83, YRES+6+18), ui::Point(30, 13), "", "Heat display mode preset");
+ presetButton->SetIcon(IconHeat);
+ presetButton->SetActionCallback(new RenderPresetAction(this, 6));
+ AddComponent(presetButton);
+
+ presetButton = new ui::Button(ui::Point(122, YRES+6), ui::Point(30, 13), "", "Fancy display mode preset");
+ presetButton->SetIcon(IconBlur);
+ presetButton->SetActionCallback(new RenderPresetAction(this, 7));
+ AddComponent(presetButton);
+
+ presetButton = new ui::Button(ui::Point(122, YRES+6+18), ui::Point(30, 13), "", "Nothing display mode preset");
+ presetButton->SetIcon(IconBasic);
+ presetButton->SetActionCallback(new RenderPresetAction(this, 8));
+ AddComponent(presetButton);
+
+ presetButton = new ui::Button(ui::Point(161, YRES+6), ui::Point(30, 13), "", "Heat gradient display mode preset");
+ presetButton->SetIcon(IconGradient);
+ presetButton->SetActionCallback(new RenderPresetAction(this, 9));
+ AddComponent(presetButton);
+
+ presetButton = new ui::Button(ui::Point(161, YRES+6+18), ui::Point(30, 13), "", "Alternative Velocity display mode preset");
+ presetButton->SetIcon(IconAltAir);
+ presetButton->SetActionCallback(new RenderPresetAction(this, 0));
+ AddComponent(presetButton);
+
+ presetButton = new ui::Button(ui::Point(200, YRES+6), ui::Point(30, 13), "", "Life display mode preset");
+ presetButton->SetIcon(IconLife);
+ presetButton->SetActionCallback(new RenderPresetAction(this, 10));
+ AddComponent(presetButton);
+
ui::Checkbox * tCheckbox;
- tCheckbox = new ui::Checkbox(ui::Point(1, YRES+4), ui::Point(30, 16), "Effects", "Adds Special flare effects to some elements");
+ tCheckbox = new ui::Checkbox(ui::Point(241, YRES+4), ui::Point(30, 16), "Effects", "Adds Special flare effects to some elements");
renderModes.push_back(tCheckbox);
tCheckbox->SetIcon(IconEffect);
tCheckbox->SetActionCallback(new RenderModeAction(this, RENDER_EFFE));
AddComponent(tCheckbox);
- tCheckbox = new ui::Checkbox(ui::Point(1, YRES+4+18), ui::Point(30, 16), "Fire", "Fire effect for gasses");
+ tCheckbox = new ui::Checkbox(ui::Point(241, YRES+4+18), ui::Point(30, 16), "Fire", "Fire effect for gasses");
renderModes.push_back(tCheckbox);
tCheckbox->SetIcon(IconFire);
tCheckbox->SetActionCallback(new RenderModeAction(this, RENDER_FIRE));
AddComponent(tCheckbox);
- tCheckbox = new ui::Checkbox(ui::Point(41, YRES+4), ui::Point(30, 16), "Glow", "Glow effect on some elements");
+ tCheckbox = new ui::Checkbox(ui::Point(281, YRES+4), ui::Point(30, 16), "Glow", "Glow effect on some elements");
renderModes.push_back(tCheckbox);
tCheckbox->SetIcon(IconGlow);
tCheckbox->SetActionCallback(new RenderModeAction(this, RENDER_GLOW));
AddComponent(tCheckbox);
- tCheckbox = new ui::Checkbox(ui::Point(41, YRES+4+18), ui::Point(30, 16), "Blur", "Blur effect for liquids");
+ tCheckbox = new ui::Checkbox(ui::Point(281, YRES+4+18), ui::Point(30, 16), "Blur", "Blur effect for liquids");
renderModes.push_back(tCheckbox);
tCheckbox->SetIcon(IconBlur);
tCheckbox->SetActionCallback(new RenderModeAction(this, RENDER_BLUR));
AddComponent(tCheckbox);
- tCheckbox = new ui::Checkbox(ui::Point(81, YRES+4), ui::Point(30, 16), "Blob", "Makes everything be drawn like a blob");
+ tCheckbox = new ui::Checkbox(ui::Point(321, YRES+4), ui::Point(30, 16), "Blob", "Makes everything be drawn like a blob");
renderModes.push_back(tCheckbox);
tCheckbox->SetIcon(IconBlob);
tCheckbox->SetActionCallback(new RenderModeAction(this, RENDER_BLOB));
AddComponent(tCheckbox);
- tCheckbox = new ui::Checkbox(ui::Point(81, YRES+4+18), ui::Point(30, 16), "Point", "Basic rendering, without this, most things will be invisible");
+ tCheckbox = new ui::Checkbox(ui::Point(321, YRES+4+18), ui::Point(30, 16), "Point", "Basic rendering, without this, most things will be invisible");
renderModes.push_back(tCheckbox);
tCheckbox->SetIcon(IconBasic);
tCheckbox->SetActionCallback(new RenderModeAction(this, RENDER_BASC));
AddComponent(tCheckbox);
- tCheckbox = new ui::Checkbox(ui::Point(136, YRES+4), ui::Point(30, 16), "Alt. Air", "Displays pressure as red and blue, and velocity as white");
+ tCheckbox = new ui::Checkbox(ui::Point(366, YRES+4), ui::Point(30, 16), "Alt. Air", "Displays pressure as red and blue, and velocity as white");
displayModes.push_back(tCheckbox);
tCheckbox->SetIcon(IconAltAir);
tCheckbox->SetActionCallback(new DisplayModeAction(this, DISPLAY_AIRC));
AddComponent(tCheckbox);
- tCheckbox = new ui::Checkbox(ui::Point(136, YRES+4+18), ui::Point(30, 16), "Pressure", "Displays pressure, red is positive and blue is negative");
+ tCheckbox = new ui::Checkbox(ui::Point(366, YRES+4+18), ui::Point(30, 16), "Pressure", "Displays pressure, red is positive and blue is negative");
displayModes.push_back(tCheckbox);
tCheckbox->SetIcon(IconPressure);
tCheckbox->SetActionCallback(new DisplayModeAction(this, DISPLAY_AIRP));
AddComponent(tCheckbox);
- tCheckbox = new ui::Checkbox(ui::Point(176, YRES+4), ui::Point(30, 16), "Velocity", "Displays velocity and positive pressure: up/down adds blue, right/left adds red, still pressure adds green");
+ tCheckbox = new ui::Checkbox(ui::Point(406, YRES+4), ui::Point(30, 16), "Velocity", "Displays velocity and positive pressure: up/down adds blue, right/left adds red, still pressure adds green");
displayModes.push_back(tCheckbox);
tCheckbox->SetIcon(IconVelocity);
tCheckbox->SetActionCallback(new DisplayModeAction(this, DISPLAY_AIRV));
AddComponent(tCheckbox);
- tCheckbox = new ui::Checkbox(ui::Point(176, YRES+4+18), ui::Point(30, 16), "Air-heat", "Displays the temperature of the air like heat display does");
+ tCheckbox = new ui::Checkbox(ui::Point(406, YRES+4+18), ui::Point(30, 16), "Air-heat", "Displays the temperature of the air like heat display does");
displayModes.push_back(tCheckbox);
tCheckbox->SetIcon(IconHeat);
tCheckbox->SetActionCallback(new DisplayModeAction(this, DISPLAY_AIRH));
AddComponent(tCheckbox);
- /*tCheckbox = new ui::Checkbox(ui::Point(216, YRES+4), ui::Point(30, 16), "Air", "");
+ /*tCheckbox = new ui::Checkbox(ui::Point(446, YRES+4), ui::Point(30, 16), "Air", "");
displayModes.push_back(tCheckbox);
tCheckbox->SetIcon(IconAltAir);
tCheckbox->SetActionCallback(new DisplayModeAction(this, DISPLAY_AIR));
AddComponent(tCheckbox);*/
- tCheckbox = new ui::Checkbox(ui::Point(221, YRES+4+18), ui::Point(30, 16), "Warp", "Gravity lensing, Newtonian Gravity bends light with this on");
+ tCheckbox = new ui::Checkbox(ui::Point(451, YRES+4+18), ui::Point(30, 16), "Warp", "Gravity lensing, Newtonian Gravity bends light with this on");
displayModes.push_back(tCheckbox);
tCheckbox->SetIcon(IconWarp);
tCheckbox->SetActionCallback(new DisplayModeAction(this, DISPLAY_WARP));
AddComponent(tCheckbox);
#ifdef OGLR
- tCheckbox = new ui::Checkbox(ui::Point(221, YRES+4), ui::Point(30, 16), "Effect", "I don't know what this does...") //I would remove the whole checkbox, but then there's a large empty space
+ tCheckbox = new ui::Checkbox(ui::Point(451, YRES+4), ui::Point(30, 16), "Effect", "I don't know what this does...") //I would remove the whole checkbox, but then there's a large empty space
#else
- tCheckbox = new ui::Checkbox(ui::Point(221, YRES+4), ui::Point(30, 16), "Effect", "Does nothing");
+ tCheckbox = new ui::Checkbox(ui::Point(451, YRES+4), ui::Point(30, 16), "Effect", "Does nothing");
#endif
displayModes.push_back(tCheckbox);
tCheckbox->SetIcon(IconEffect);
tCheckbox->SetActionCallback(new DisplayModeAction(this, DISPLAY_EFFE));
AddComponent(tCheckbox);
- tCheckbox = new ui::Checkbox(ui::Point(261, YRES+4), ui::Point(30, 16), "Persistent", "Element paths persist on the screen for a while");
+ tCheckbox = new ui::Checkbox(ui::Point(491, YRES+4), ui::Point(30, 16), "Persistent", "Element paths persist on the screen for a while");
displayModes.push_back(tCheckbox);
tCheckbox->SetIcon(IconPersistant);
tCheckbox->SetActionCallback(new DisplayModeAction(this, DISPLAY_PERS));
AddComponent(tCheckbox);
- tCheckbox = new ui::Checkbox(ui::Point(306, YRES+4), ui::Point(30, 16), "Heat", "Displays temperatures of the elements, dark blue is coldest, pink is hotest");
+ tCheckbox = new ui::Checkbox(ui::Point(536, YRES+4), ui::Point(30, 16), "Heat", "Displays temperatures of the elements, dark blue is coldest, pink is hotest");
colourModes.push_back(tCheckbox);
tCheckbox->SetIcon(IconHeat);
tCheckbox->SetActionCallback(new ColourModeAction(this, COLOUR_HEAT));
AddComponent(tCheckbox);
- tCheckbox = new ui::Checkbox(ui::Point(306, YRES+4+18), ui::Point(30, 16), "Life", "Displays the life value of elements in greyscale gradients");
+ tCheckbox = new ui::Checkbox(ui::Point(536, YRES+4+18), ui::Point(30, 16), "Life", "Displays the life value of elements in greyscale gradients");
colourModes.push_back(tCheckbox);
tCheckbox->SetIcon(IconLife);
tCheckbox->SetActionCallback(new ColourModeAction(this, COLOUR_LIFE));
AddComponent(tCheckbox);
- tCheckbox = new ui::Checkbox(ui::Point(346, YRES+4+18), ui::Point(30, 16), "H-Gradient", "Changes colors of elements slightly to show heat diffusing through them");
+ tCheckbox = new ui::Checkbox(ui::Point(576, YRES+4+18), ui::Point(30, 16), "H-Gradient", "Changes colors of elements slightly to show heat diffusing through them");
colourModes.push_back(tCheckbox);
tCheckbox->SetIcon(IconGradient);
tCheckbox->SetActionCallback(new ColourModeAction(this, COLOUR_GRAD));
AddComponent(tCheckbox);
- tCheckbox = new ui::Checkbox(ui::Point(346, YRES+4), ui::Point(30, 16), "Basic", "No special effects at all for anything, overrides all other options and deco");
+ tCheckbox = new ui::Checkbox(ui::Point(576, YRES+4), ui::Point(30, 16), "Basic", "No special effects at all for anything, overrides all other options and deco");
colourModes.push_back(tCheckbox);
tCheckbox->SetIcon(IconBasic);
tCheckbox->SetActionCallback(new ColourModeAction(this, COLOUR_BASC));
@@ -268,9 +341,10 @@ void RenderView::OnDraw()
ren->RenderEnd();
}
g->draw_line(0, YRES, XRES-1, YRES, 200, 200, 200, 255);
- g->draw_line(130, YRES, 130, YRES+MENUSIZE, 200, 200, 200, 255);
- g->draw_line(215, YRES, 215, YRES+MENUSIZE, 200, 200, 200, 255);
- g->draw_line(300, YRES, 300, YRES+MENUSIZE, 200, 200, 200, 255);
+ g->draw_line(235, YRES, 235, YRES+MENUSIZE, 200, 200, 200, 255);
+ g->draw_line(360, YRES, 360, YRES+MENUSIZE, 200, 200, 200, 255);
+ g->draw_line(445, YRES, 445, YRES+MENUSIZE, 200, 200, 200, 255);
+ g->draw_line(530, YRES, 530, YRES+MENUSIZE, 200, 200, 200, 255);
g->draw_line(XRES, 0, XRES, YRES+MENUSIZE, 255, 255, 255, 255);
if(toolTipPresence && toolTip.length())
{
@@ -288,6 +362,16 @@ void RenderView::OnTick(float dt)
}
}
+void RenderView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
+{
+ if (shift && key == '1')
+ c->LoadRenderPreset(10);
+ else if(key >= '0' && key <= '9')
+ {
+ c->LoadRenderPreset(key-'0');
+ }
+}
+
void RenderView::ToolTip(ui::Component * sender, ui::Point mousePosition, std::string toolTip)
{
this->toolTip = toolTip;
diff --git a/src/render/RenderView.h b/src/render/RenderView.h
index 695a342..03a4065 100644
--- a/src/render/RenderView.h
+++ b/src/render/RenderView.h
@@ -15,6 +15,7 @@
#include "RenderModel.h"
#include "graphics/Renderer.h"
#include "interface/Checkbox.h"
+#include "interface/Button.h"
class RenderController;
class RenderModel;
@@ -30,6 +31,7 @@ public:
class RenderModeAction;
class DisplayModeAction;
class ColourModeAction;
+ class RenderPresetAction;
RenderView();
void NotifyRendererChanged(RenderModel * sender);
void NotifyRenderChanged(RenderModel * sender);
@@ -39,6 +41,7 @@ public:
void OnMouseDown(int x, int y, unsigned button);
virtual void OnDraw();
virtual void OnTick(float dt);
+ virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void ToolTip(ui::Component * sender, ui::Point mousePosition, std::string toolTip);
virtual ~RenderView();
};