Compare commits
2 Commits
9480d4e2a7
...
e5d90533dd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5d90533dd | ||
|
|
e19a13c354 |
28
src/main.cpp
28
src/main.cpp
@ -1337,8 +1337,6 @@ void change_map_tile(V2 pos, TileKind kind) {
|
|||||||
if (pos_x < 0 || pos_y < 0 || pos_x > current_map.width - 1 || pos_y > current_map.height - 1)
|
if (pos_x < 0 || pos_y < 0 || pos_x > current_map.width - 1 || pos_y > current_map.height - 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SDL_Log("TileKind Change: %d %d", pos_x, pos_y);
|
|
||||||
|
|
||||||
__m128i corner_infos = _mm_setr_epi32(get_corner_info(pos_x, pos_y + 1), get_corner_info(pos_x + 1, pos_y + 1), get_corner_info(pos_x + 1, pos_y), get_corner_info(pos_x, pos_y));
|
__m128i corner_infos = _mm_setr_epi32(get_corner_info(pos_x, pos_y + 1), get_corner_info(pos_x + 1, pos_y + 1), get_corner_info(pos_x + 1, pos_y), get_corner_info(pos_x, pos_y));
|
||||||
__m128i none_mask = _mm_cmpeq_epi8(corner_infos, _mm_set1_epi8(TILEKIND_NONE));
|
__m128i none_mask = _mm_cmpeq_epi8(corner_infos, _mm_set1_epi8(TILEKIND_NONE));
|
||||||
__m128i error_mask = _mm_cmpeq_epi8(corner_infos, _mm_set1_epi8(TILEKIND_ERROR));
|
__m128i error_mask = _mm_cmpeq_epi8(corner_infos, _mm_set1_epi8(TILEKIND_ERROR));
|
||||||
@ -1358,6 +1356,13 @@ void change_map_tile(V2 pos, TileKind kind) {
|
|||||||
update_buffer(current_map.gpu_buffer, 0, current_map.width * current_map.height * sizeof(Uint32), current_map.tiles);
|
update_buffer(current_map.gpu_buffer, 0, current_map.width * current_map.height * sizeof(Uint32), current_map.tiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void SameLineOrWrap(const ImVec2& size) {
|
||||||
|
ImGuiWindow *window = ImGui::GetCurrentWindow();
|
||||||
|
ImVec2 pos = ImVec2(window->DC.CursorPosPrevLine.x + ImGui::GetStyle().ItemSpacing.x, window->DC.CursorPosPrevLine.y);
|
||||||
|
if (window->WorkRect.Contains(ImRect(pos, pos + size)))
|
||||||
|
ImGui::SameLine();
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
setup_memory_functions();
|
setup_memory_functions();
|
||||||
|
|
||||||
@ -1674,9 +1679,8 @@ int main(int argc, char **argv) {
|
|||||||
ImVec2 uv0 = ImVec2(0, 0);
|
ImVec2 uv0 = ImVec2(0, 0);
|
||||||
ImVec2 uv1 = ImVec2(1, 1);
|
ImVec2 uv1 = ImVec2(1, 1);
|
||||||
|
|
||||||
float available = ImGui::GetContentRegionAvail().x - ImGui::GetItemRectMax().x;
|
if (i != 0)
|
||||||
if (available >= 32)
|
SameLineOrWrap(ImVec2(32, 32));
|
||||||
ImGui::SameLine();
|
|
||||||
|
|
||||||
if (SelectableTile("##tile", selected_tile == i, &tile_atlas_texture_binding, i, ImVec2(32, 32), uv0, uv1, SDL_max(selected_rotation, 0))) {
|
if (SelectableTile("##tile", selected_tile == i, &tile_atlas_texture_binding, i, ImVec2(32, 32), uv0, uv1, SDL_max(selected_rotation, 0))) {
|
||||||
selected_tile_kind = -1;
|
selected_tile_kind = -1;
|
||||||
@ -1695,21 +1699,16 @@ int main(int argc, char **argv) {
|
|||||||
if (SelectableTile("##None", selected_rotation == 0, &tile_atlas_texture_binding, selected_tile, ImVec2(32, 32), uv0, uv1, 0))
|
if (SelectableTile("##None", selected_rotation == 0, &tile_atlas_texture_binding, selected_tile, ImVec2(32, 32), uv0, uv1, 0))
|
||||||
selected_rotation = 0;
|
selected_rotation = 0;
|
||||||
|
|
||||||
if (ImGui::GetContentRegionAvail().x - ImGui::GetItemRectMax().x >= 32)
|
|
||||||
ImGui::SameLine();
|
SameLineOrWrap(ImVec2(32, 32));
|
||||||
|
|
||||||
if (SelectableTile("##90", selected_rotation == 1, &tile_atlas_texture_binding, selected_tile, ImVec2(32, 32), uv0, uv1, 1))
|
if (SelectableTile("##90", selected_rotation == 1, &tile_atlas_texture_binding, selected_tile, ImVec2(32, 32), uv0, uv1, 1))
|
||||||
selected_rotation = 1;
|
selected_rotation = 1;
|
||||||
|
|
||||||
if (ImGui::GetContentRegionAvail().x - ImGui::GetItemRectMax().x >= 32)
|
SameLineOrWrap(ImVec2(32, 32));
|
||||||
ImGui::SameLine();
|
|
||||||
|
|
||||||
if (SelectableTile("##180", selected_rotation == 2, &tile_atlas_texture_binding, selected_tile, ImVec2(32, 32), uv0, uv1, 2))
|
if (SelectableTile("##180", selected_rotation == 2, &tile_atlas_texture_binding, selected_tile, ImVec2(32, 32), uv0, uv1, 2))
|
||||||
selected_rotation = 2;
|
selected_rotation = 2;
|
||||||
|
|
||||||
if (ImGui::GetContentRegionAvail().x - ImGui::GetItemRectMax().x >= 32)
|
SameLineOrWrap(ImVec2(32, 32));
|
||||||
ImGui::SameLine();
|
|
||||||
|
|
||||||
if (SelectableTile("##270", selected_rotation == 3, &tile_atlas_texture_binding, selected_tile, ImVec2(32, 32), uv0, uv1, 3))
|
if (SelectableTile("##270", selected_rotation == 3, &tile_atlas_texture_binding, selected_tile, ImVec2(32, 32), uv0, uv1, 3))
|
||||||
selected_rotation = 3;
|
selected_rotation = 3;
|
||||||
|
|
||||||
@ -1902,7 +1901,6 @@ int main(int argc, char **argv) {
|
|||||||
case SDL_EVENT_MOUSE_MOTION: {
|
case SDL_EVENT_MOUSE_MOTION: {
|
||||||
mouse_pos = V2_(event.motion.x, event.motion.y);
|
mouse_pos = V2_(event.motion.x, event.motion.y);
|
||||||
V2 floor_intersection = get_floor_intersection_of_mouse(mouse_pos);
|
V2 floor_intersection = get_floor_intersection_of_mouse(mouse_pos);
|
||||||
SDL_Log("Move: %g %g", floor_intersection.x, floor_intersection.y);
|
|
||||||
|
|
||||||
if (selected_tile_kind != -1 && dragging_tile_change) {
|
if (selected_tile_kind != -1 && dragging_tile_change) {
|
||||||
V2 floor_intersection = get_floor_intersection_of_mouse(mouse_pos);
|
V2 floor_intersection = get_floor_intersection_of_mouse(mouse_pos);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user