diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2011-04-18 19:35:48 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2011-04-18 19:35:48 +0200 |
commit | 55e76bdaafa1e2a94fbd717335c1c7bd8c8fc156 (patch) | |
tree | cb9e0b4a9dd9f069098fead2f1b0fd0dd7311a62 /tool.cpp | |
parent | 0986cf8f33df8926dd8da67f98ed18f696141313 (diff) |
Basic tool implementation.
Diffstat (limited to 'tool.cpp')
-rw-r--r-- | tool.cpp | 43 |
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"; +} |