| 155 | } |
| 156 | |
| 157 | void get_pen(Screen::Pen * tile_pen, int * highlight_tile, |
| 158 | int x, int y, ShapeMap &arr, const std::string &type = "") |
| 159 | { |
| 160 | bool n = false, w = false, e = false, s = false; |
| 161 | if (has_point(x, y)) { |
| 162 | if (y == 0 || !has_point(x, y - 1)) n = true; |
| 163 | if (x == 0 || !has_point(x - 1, y)) w = true; |
| 164 | if (!has_point(x + 1, y)) e = true; // TODO check map size |
| 165 | if (!has_point(x, y + 1)) s = true; // TODO check map size |
| 166 | } |
| 167 | |
| 168 | bool is_drag_point = type == "drag_point"; |
| 169 | bool is_extra = type == "extra_point"; |
| 170 | bool is_in_shape = has_point(x, y); |
| 171 | auto mouse_pos = Gui::getMousePos(); |
| 172 | bool mouse_over = mouse_pos.x == x && mouse_pos.y == y; |
| 173 | |
| 174 | uint32_t pen_key = gen_pen_key(n, s, e, w, is_drag_point, mouse_over, |
| 175 | is_in_shape, is_extra); |
| 176 | |
| 177 | if (CURSORS_MAP.count({n, w, e, s}) > 0 && has_point(x, y)) { |
| 178 | arr[x][y].cursor_coords = CURSORS_MAP.at({n, w, e, s}); |
| 179 | } |
| 180 | |
| 181 | if (PENS.find(pen_key) == PENS.end()) { |
| 182 | std::pair<int, int> cursor{-1, -1}; |
| 183 | |
| 184 | if (type != "") { |
| 185 | *tile_pen = make_pen(CURSORS_MAP.at({n, w, e, s}), is_drag_point, |
| 186 | mouse_over, is_in_shape, is_extra); |
| 187 | if (highlight_tile) |
| 188 | *highlight_tile = mouse_over ? point_hover_highlight_tile : point_highlight_tile; |
| 189 | return; |
| 190 | } |
| 191 | |
| 192 | if (CURSORS_MAP.count({n, w, e, s}) > 0) { |
| 193 | PENS.emplace(pen_key, |
| 194 | make_pen(CURSORS_MAP.at({n, w, e, s}), is_drag_point, |
| 195 | mouse_over, is_in_shape, is_extra)); |
| 196 | if (type == "" && has_point(x, y)) { |
| 197 | arr[x][y].penKey = pen_key; |
| 198 | } |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | *tile_pen = PENS.at(pen_key); |
| 203 | } |
| 204 | |
| 205 | static int design_load_shape(lua_State *L) { |
| 206 | if (lua_istable(L, -1)) { |