~kikoodx/sle

023ff12cb93af564d60e28177af3e827739fd1b1 — KikooDX 3 years ago c5a202a
Feature: middle click in editor to pick a tile

Updated the README in consequence.
3 files changed, 16 insertions(+), 11 deletions(-)

M README
M src/editing_area/draw.c
M src/editing_area/main.c
M README => README +5 -3
@@ 3,7 3,8 @@ SLE
A simple project oriented single screen tilebased level editor.

SLE read and write KBLE level files.
=> https://git.sr.ht/~kikoodx/kble
KBLE format specifications:
=> https://git.sr.ht/~kikoodx/kble/tree/dev/item/kbleformat.md

COMPILATION
===========


@@ 34,6 35,7 @@ Main window - Editing Area
--------------------------
Left click: draw with selected tile
Right click: erase (tile 0)
Middle click: pick a tile

Secondary window - Tile Picker
------------------------------


@@ 50,8 52,8 @@ FLAGS
Mandatory flags
---------------
All these options take a path to a file as argument.
-tileset Tileset image
-level   KBLE file
-tileset : tileset image
-level : KBLE file

Optional flags
--------------

M src/editing_area/draw.c => src/editing_area/draw.c +6 -3
@@ 18,10 18,13 @@ void level_draw(struct Level level, struct Options options,
			/* if tile index is out of bound, skip */
			if (tile_index >= level.width * level.height)
				continue;
			const Tile tile = level.data[tile_index] - options.tile_first;
			const Tile tile =
			    level.data[tile_index] - options.tile_first;
			/* if tile is not in tileset, skip */
			if (tile < 0 || (!tile && !options.tile_first) || tile >= options.tileset_width *
			                         options.tileset_height)
			if (tile < 0 ||
			    (!tile && !options.tile_first) ||
			    tile >= options.tileset_width *
			                options.tileset_height)
				continue;

			const Rectangle tile_rect = {

M src/editing_area/main.c => src/editing_area/main.c +5 -5
@@ 108,17 108,17 @@ static void update_mouse(int *mouse_x, int *mouse_y, struct Level level,
	                      level.height - 1);

	/* set tile */
	if (left_click) {
	if (left_click)
		level.data[*mouse_x + *mouse_y * level.width] =
		    shared_data->selected_tile;
	}
	/* remove tile */
	if (right_click) {
	if (right_click)
		level.data[*mouse_x + *mouse_y * level.width] = 0;
	}
	/* get info about tile */
	/* set tile to pointed cell (pick tile) */
	if (middle_click) {
		INFO_VAR("%d",
		         level.data[*mouse_x + *mouse_y * level.width]);
		shared_data->selected_tile =
		    level.data[*mouse_x + *mouse_y * level.width];
	}
}