summaryrefslogtreecommitdiff
path: root/tool.cpp
blob: 83353b44bdc059e5c1cd16df8daf65a369665600 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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";
}