diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2019-03-16 17:45:16 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2019-03-16 17:45:16 -0400 |
commit | 4a03d938451763dfb95b534f9002865e72ea7ec5 (patch) | |
tree | 9f2a0f074869009760fc33af5032c6de13da897e /src/editor.cpp | |
parent | 57fe8f3c4124819b95164547333a33f4c45eac8d (diff) | |
download | dispatcher-master.tar.gz dispatcher-master.tar.bz2 dispatcher-master.zip |
Diffstat (limited to 'src/editor.cpp')
-rw-r--r-- | src/editor.cpp | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/src/editor.cpp b/src/editor.cpp index 30dde45..8ca850a 100644 --- a/src/editor.cpp +++ b/src/editor.cpp | |||
@@ -63,7 +63,7 @@ void Editor::tick( | |||
63 | } | 63 | } |
64 | 64 | ||
65 | // Check for keypress changes since the last tick. | 65 | // Check for keypress changes since the last tick. |
66 | input_.tick(keystate); | 66 | input_.tick(); |
67 | 67 | ||
68 | if (input_.wasPressed(SDL_SCANCODE_Z)) | 68 | if (input_.wasPressed(SDL_SCANCODE_Z)) |
69 | { | 69 | { |
@@ -130,10 +130,45 @@ void Editor::tick( | |||
130 | mapFocus_ = !mapFocus_; | 130 | mapFocus_ = !mapFocus_; |
131 | } | 131 | } |
132 | 132 | ||
133 | bool newlyTabbed = false; | ||
134 | |||
135 | if (input_.wasClicked(SDL_BUTTON_LEFT)) | ||
136 | { | ||
137 | if (EDITOR_MAP_AREA.contains(input_.getMousePos())) | ||
138 | { | ||
139 | if (!mapFocus_) | ||
140 | { | ||
141 | newlyTabbed = true; | ||
142 | } | ||
143 | |||
144 | mapFocus_ = true; | ||
145 | } else if (EDITOR_TILESET_AREA.contains(input_.getMousePos())) | ||
146 | { | ||
147 | if (mapFocus_) | ||
148 | { | ||
149 | newlyTabbed = true; | ||
150 | } | ||
151 | |||
152 | mapFocus_ = false; | ||
153 | |||
154 | selectedTile_ = | ||
155 | (input_.getMousePos() - EDITOR_TILESET_AREA.pos).y() / TILE_SIZE.h(); | ||
156 | } | ||
157 | } | ||
158 | |||
133 | if (mapFocus_) | 159 | if (mapFocus_) |
134 | { | 160 | { |
161 | if (EDITOR_MAP_AREA.contains(input_.getMousePos()) && | ||
162 | ( input_.hasMouseMoved() || newlyTabbed )) | ||
163 | { | ||
164 | cursor_ = (input_.getMousePos() - EDITOR_MAP_AREA.pos) / TILE_SIZE; | ||
165 | } | ||
166 | |||
135 | if (keystate[SDL_SCANCODE_RETURN] || | 167 | if (keystate[SDL_SCANCODE_RETURN] || |
136 | keystate[SDL_SCANCODE_SPACE]) | 168 | keystate[SDL_SCANCODE_SPACE] || |
169 | ( input_.isClicked(SDL_BUTTON_LEFT) && | ||
170 | EDITOR_MAP_AREA.contains(input_.getMousePos()) && | ||
171 | !newlyTabbed )) | ||
137 | { | 172 | { |
138 | level_.at(cursor_.x(), cursor_.y(), layer_) = selectedTile_; | 173 | level_.at(cursor_.x(), cursor_.y(), layer_) = selectedTile_; |
139 | 174 | ||