summaryrefslogtreecommitdiff
path: root/src/editor.c
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-01-28 02:26:52 +0500
committerilotterytea <iltsu@alright.party>2025-01-28 02:26:52 +0500
commit0b9ffb82a7309ff7307846862165c2b8e60b3b3c (patch)
tree7f4e9dd63c078ddc459d66366eb8fa347abd6aeb /src/editor.c
parent352cc47d315d262b0114399029fc66f1c65f90f8 (diff)
upd: tile scale
Diffstat (limited to 'src/editor.c')
-rw-r--r--src/editor.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/editor.c b/src/editor.c
index 65476a1..8193a52 100644
--- a/src/editor.c
+++ b/src/editor.c
@@ -173,13 +173,13 @@ void drawBuildTab(Editor *editor, int x, int y, int width, int height,
}
DrawTextureEx(selectedTile->texture,
- (Vector2){x + padding, y + padding * 3.0f}, 0.0f, 2.0f,
+ (Vector2){x + padding, y + padding * 3.0f}, 0.0f, 6.0f,
WHITE);
} else {
selectedTileLabel = "???";
- DrawRectangle(x + padding, y + padding * 3.0f, TEXTURE_WIDTH * 2.0f,
- TEXTURE_HEIGHT * 2.0f, LIGHTGRAY);
+ DrawRectangle(x + padding, y + padding * 3.0f, TEXTURE_WIDTH * 6.0f,
+ TEXTURE_HEIGHT * 6.0f, LIGHTGRAY);
}
GuiLabel((Rectangle){x + padding, y + padding * 2.0f, width - padding * 2.0f,
@@ -187,7 +187,9 @@ void drawBuildTab(Editor *editor, int x, int y, int width, int height,
selectedTileLabel);
// Rendering
- Rectangle controlBounds = {x + padding, y + padding + 20.0f * 4.0f, 200, 200};
+ Rectangle controlBounds = {x + padding, y + padding + 20.0f * 8.0f,
+ width - padding * 2.0f, 200.0f};
+ controlBounds.height = height - controlBounds.y - padding * 4.0f;
Rectangle contentSize = {x + padding, y + padding, 10 * TEXTURE_WIDTH, 1000};
GuiScrollPanel(controlBounds, NULL, contentSize, &editor->state.panelScroll,
@@ -201,6 +203,7 @@ void drawBuildTab(Editor *editor, int x, int y, int width, int height,
// rendering floor tiles in grid
int row = 0, column = 0, texturesPerRow = 10;
+ float scale = 3.0f;
for (int i = 0; i < editor->state.cache.tileDataSize; i++) {
EditorTileData *tile = editor->state.cache.tileData[i];
if (tile == NULL) continue;
@@ -208,21 +211,23 @@ void drawBuildTab(Editor *editor, int x, int y, int width, int height,
row = i / texturesPerRow;
column = i % texturesPerRow;
- int x = controlBounds.x + 5 + TEXTURE_WIDTH * column;
- int y =
- controlBounds.y + editor->state.panelScroll.y + TEXTURE_HEIGHT * row;
+ int x = controlBounds.x + 5 + TEXTURE_WIDTH * column * scale;
+ int y = controlBounds.y + editor->state.panelScroll.y +
+ TEXTURE_HEIGHT * row * scale;
- DrawTexture(tile->texture, x, y, WHITE);
+ DrawTextureEx(tile->texture, (Vector2){x, y}, 0.0f, scale, WHITE);
- bool isHovered = (x <= mousePos.x && mousePos.x <= x + TEXTURE_WIDTH) &&
- (y <= mousePos.y && mousePos.y <= y + TEXTURE_HEIGHT);
+ bool isHovered =
+ (x <= mousePos.x && mousePos.x <= x + TEXTURE_WIDTH * scale) &&
+ (y <= mousePos.y && mousePos.y <= y + TEXTURE_HEIGHT * scale);
bool sameTile = editor->state.selectedTile != NULL &&
editor->state.selectedTile->data.id == tile->data.id;
// hover event
if (isHovered || sameTile) {
- DrawRectangleLines(x, y, TEXTURE_WIDTH, TEXTURE_HEIGHT, YELLOW);
+ DrawRectangleLines(x, y, TEXTURE_WIDTH * scale, TEXTURE_HEIGHT * scale,
+ YELLOW);
}
// select tile