summaryrefslogtreecommitdiff
path: root/tool.cpp
blob: d96a45f1c02b5d4495dd775a3a5c3d74b5431634 (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(Terrain *terrain) {
	this->terrain = terrain;
}

void Tool::render_gui() {
	gui->render();
}

/* RaiseTool */
RaiseTool::RaiseTool(Terrain *terrain) : Tool(terrain) {
	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:
					terrain->raise(selected.x, selected.z, wnd->get_radius(), wnd->get_focus(),
							wnd->get_strength());
					return true;
				case SDL_BUTTON_WHEELDOWN:
					terrain->raise(selected.x, selected.z, wnd->get_radius(), wnd->get_focus(),
							wnd->get_strength(), false);
					return true;
			}
	}

	return false;
}

const char* RaiseTool::get_name() {
	return "RaiseTool";
}