summaryrefslogtreecommitdiff
path: root/tool.cpp
blob: d652b16f5a8388fb1651ee251376182ec333a9fc (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
44
45
46
47
48
49
50
51
52
#include "tool.h"

/* Tool */
Tool::Tool(Terrain *terrain) {
	this->terrain = terrain;
}

void Tool::gui_show() {
	gui->show();
}

void Tool::gui_hide() {
	gui->hide();
}

void Tool::gui_update() {
	gui->update();
}

/* RaiseTool */
RaiseTool::RaiseTool(Terrain *terrain) : Tool(terrain) {
	gui = new RaiseWindow();
	gui_hide();
}

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";
}