summaryrefslogtreecommitdiff
path: root/tool.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tool.cpp')
-rw-r--r--tool.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/tool.cpp b/tool.cpp
new file mode 100644
index 0000000..83353b4
--- /dev/null
+++ b/tool.cpp
@@ -0,0 +1,43 @@
+#include "tool.h"
+
+/* Tool */
+Tool::Tool(Quadtree *tree) {
+ this->tree = tree;
+}
+
+void Tool::render_gui() {
+ gui->render();
+}
+
+/* RaiseTool */
+RaiseTool::RaiseTool(Quadtree *tree) : Tool(tree) {
+ gui = new RaiseWindow();
+}
+
+RaiseTool::~RaiseTool() {
+ delete gui;
+}
+
+bool RaiseTool::handle_event(SDL_Event& event, Vector3& selected) {
+ RaiseWindow *wnd = static_cast<RaiseWindow*>(gui);
+
+ switch(event.type) {
+ case SDL_MOUSEBUTTONUP:
+ switch(event.button.button) {
+ case SDL_BUTTON_WHEELUP:
+ tree->raise(selected.x, selected.z, wnd->get_radius(), wnd->get_focus(),
+ wnd->get_strength());
+ return true;
+ case SDL_BUTTON_WHEELDOWN:
+ tree->raise(selected.x, selected.z, wnd->get_radius(), wnd->get_focus(),
+ -wnd->get_strength());
+ return true;
+ }
+ }
+
+ return false;
+}
+
+const char* RaiseTool::get_name() {
+ return "RaiseTool";
+}