add selected tile outline for ow editor
This commit is contained in:
@@ -41,6 +41,7 @@ void UpdateSelectedTile16(int selected, gfx::Bitmap &tile16_blockset,
|
||||
void OverworldEditor::SetupROM(ROM &rom) { rom_ = rom; }
|
||||
|
||||
absl::Status OverworldEditor::Update() {
|
||||
// Initialize overworld graphics, maps, and palettes
|
||||
if (rom_.isLoaded() && !all_gfx_loaded_) {
|
||||
LoadGraphics();
|
||||
all_gfx_loaded_ = true;
|
||||
@@ -196,11 +197,11 @@ void OverworldEditor::DrawOverworldCanvas() {
|
||||
}
|
||||
}
|
||||
for (const auto &each : overworld_.Entrances()) {
|
||||
if (each.mapId_ < 64 + (current_world_ * 0x40) &&
|
||||
each.mapId_ >= (current_world_ * 0x40)) {
|
||||
if (each.map_id_ < 64 + (current_world_ * 0x40) &&
|
||||
each.map_id_ >= (current_world_ * 0x40)) {
|
||||
overworld_map_canvas_.DrawRect(each.x_, each.y_, 16, 16,
|
||||
ImVec4(210, 24, 210, 150));
|
||||
std::string str = absl::StrFormat("%#x", each.entranceId_);
|
||||
std::string str = absl::StrFormat("%#x", each.entrance_id_);
|
||||
overworld_map_canvas_.DrawText(str, each.x_ - 4, each.y_ - 2);
|
||||
}
|
||||
}
|
||||
@@ -213,11 +214,11 @@ void OverworldEditor::DrawOverworldCanvas() {
|
||||
|
||||
void OverworldEditor::DrawTileSelector() {
|
||||
if (ImGui::BeginTabBar("##TabBar", ImGuiTabBarFlags_FittingPolicyScroll)) {
|
||||
if (ImGui::BeginTabItem("Tile8")) {
|
||||
ImGuiID child_id = ImGui::GetID((void *)(intptr_t)1);
|
||||
if (ImGui::BeginTabItem("Area Graphics")) {
|
||||
ImGuiID child_id = ImGui::GetID((void *)(intptr_t)3);
|
||||
if (ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
|
||||
ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
|
||||
DrawTile8Selector();
|
||||
DrawAreaGraphics();
|
||||
}
|
||||
ImGui::EndChild();
|
||||
ImGui::EndTabItem();
|
||||
@@ -231,11 +232,11 @@ void OverworldEditor::DrawTileSelector() {
|
||||
ImGui::EndChild();
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem("Area Graphics")) {
|
||||
ImGuiID child_id = ImGui::GetID((void *)(intptr_t)3);
|
||||
if (ImGui::BeginTabItem("Tile8")) {
|
||||
ImGuiID child_id = ImGui::GetID((void *)(intptr_t)1);
|
||||
if (ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
|
||||
ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
|
||||
DrawAreaGraphics();
|
||||
DrawTile8Selector();
|
||||
}
|
||||
ImGui::EndChild();
|
||||
ImGui::EndTabItem();
|
||||
@@ -244,6 +245,19 @@ void OverworldEditor::DrawTileSelector() {
|
||||
}
|
||||
}
|
||||
|
||||
void OverworldEditor::DrawAreaGraphics() {
|
||||
current_gfx_canvas_.DrawBackground(ImVec2(256 + 1, 16 * 64 + 1));
|
||||
current_gfx_canvas_.DrawContextMenu();
|
||||
current_gfx_canvas_.DrawTileSelector(32);
|
||||
current_gfx_canvas_.DrawBitmap(current_gfx_bmp_, 2, overworld_.isLoaded());
|
||||
current_gfx_canvas_.DrawGrid(32.0f);
|
||||
current_gfx_canvas_.DrawOverlay();
|
||||
|
||||
if (!current_gfx_canvas_.Points().empty()) {
|
||||
// TODO(scawful): update selected tile by getting position from canvas
|
||||
}
|
||||
}
|
||||
|
||||
void OverworldEditor::DrawTile16Selector() {
|
||||
blockset_canvas_.DrawBackground(ImVec2(0x100 + 1, (8192 * 2) + 1));
|
||||
blockset_canvas_.DrawContextMenu();
|
||||
@@ -274,14 +288,6 @@ void OverworldEditor::DrawTile8Selector() {
|
||||
graphics_bin_canvas_.DrawOverlay();
|
||||
}
|
||||
|
||||
void OverworldEditor::DrawAreaGraphics() {
|
||||
current_gfx_canvas_.DrawBackground(ImVec2(256 + 1, 16 * 64 + 1));
|
||||
current_gfx_canvas_.DrawContextMenu();
|
||||
current_gfx_canvas_.DrawBitmap(current_gfx_bmp_, 2, overworld_.isLoaded());
|
||||
current_gfx_canvas_.DrawGrid(32.0f);
|
||||
current_gfx_canvas_.DrawOverlay();
|
||||
}
|
||||
|
||||
void OverworldEditor::LoadGraphics() {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
current_palette_[i].x = (i * 0.21f);
|
||||
|
||||
@@ -258,9 +258,9 @@ void Overworld::LoadEntrances() {
|
||||
}
|
||||
|
||||
for (int i = 0; i < 0x13; i++) {
|
||||
short mapId = (short)((rom_[core::OWHoleArea + (i * 2) + 1] << 8) +
|
||||
auto mapId = (short)((rom_[core::OWHoleArea + (i * 2) + 1] << 8) +
|
||||
(rom_[core::OWHoleArea + (i * 2)]));
|
||||
short mapPos = (short)((rom_[core::OWHolePos + (i * 2) + 1] << 8) +
|
||||
auto mapPos = (short)((rom_[core::OWHolePos + (i * 2) + 1] << 8) +
|
||||
(rom_[core::OWHolePos + (i * 2)]));
|
||||
uchar entranceId = (rom_[core::OWHoleEntrance + i]);
|
||||
int p = (mapPos + 0x400) >> 1;
|
||||
@@ -282,8 +282,6 @@ void Overworld::LoadSprites() {
|
||||
all_sprites_.emplace_back(std::vector<Sprite>());
|
||||
}
|
||||
|
||||
// Console.WriteLine(((core::overworldSpritesBegining & 0xFFFF) + (09 <<
|
||||
// 16)).ToString("X6"));
|
||||
for (int i = 0; i < 64; i++) {
|
||||
if (map_parent_[i] == i) {
|
||||
// Beginning Sprites
|
||||
|
||||
@@ -22,53 +22,48 @@ class OverworldEntrance {
|
||||
public:
|
||||
int x_;
|
||||
int y_;
|
||||
ushort mapPos;
|
||||
uchar entranceId_, AreaX, AreaY;
|
||||
short mapId_;
|
||||
bool isHole = false;
|
||||
ushort map_pos_;
|
||||
uchar entrance_id_;
|
||||
uchar area_x_;
|
||||
uchar area_y_;
|
||||
short map_id_;
|
||||
bool is_hole_ = false;
|
||||
bool deleted = false;
|
||||
|
||||
OverworldEntrance(int x, int y, uchar entranceId, short mapId, ushort mapPos,
|
||||
bool hole) {
|
||||
x_ = x;
|
||||
y_ = y;
|
||||
entranceId_ = entranceId;
|
||||
mapId_ = mapId;
|
||||
mapPos = mapPos;
|
||||
bool hole)
|
||||
: x_(x),
|
||||
y_(y),
|
||||
map_pos_(mapPos),
|
||||
entrance_id_(entranceId),
|
||||
map_id_(mapId),
|
||||
is_hole_(hole) {
|
||||
int mapX = (map_id_ - ((map_id_ / 8) * 8));
|
||||
int mapY = (map_id_ / 8);
|
||||
|
||||
int mapX = (mapId_ - ((mapId / 8) * 8));
|
||||
int mapY = (mapId_ / 8);
|
||||
|
||||
AreaX = (uchar)((std::abs(x - (mapX * 512)) / 16));
|
||||
AreaY = (uchar)((std::abs(y - (mapY * 512)) / 16));
|
||||
|
||||
isHole = hole;
|
||||
area_x_ = (uchar)((std::abs(x - (mapX * 512)) / 16));
|
||||
area_y_ = (uchar)((std::abs(y - (mapY * 512)) / 16));
|
||||
}
|
||||
|
||||
auto Copy() {
|
||||
return new OverworldEntrance(x_, y_, entranceId_, mapId_, mapPos, isHole);
|
||||
return new OverworldEntrance(x_, y_, entrance_id_, map_id_, map_pos_,
|
||||
is_hole_);
|
||||
}
|
||||
|
||||
void updateMapStuff(short mapId) {
|
||||
mapId_ = mapId;
|
||||
map_id_ = mapId;
|
||||
|
||||
if (mapId_ >= 64) {
|
||||
mapId_ -= 64;
|
||||
if (map_id_ >= 64) {
|
||||
map_id_ -= 64;
|
||||
}
|
||||
|
||||
int mapX = (mapId_ - ((mapId_ / 8) * 8));
|
||||
int mapY = (mapId_ / 8);
|
||||
int mapX = (map_id_ - ((map_id_ / 8) * 8));
|
||||
int mapY = (map_id_ / 8);
|
||||
|
||||
AreaX = (uchar)((std::abs(x_ - (mapX * 512)) / 16));
|
||||
AreaY = (uchar)((std::abs(y_ - (mapY * 512)) / 16));
|
||||
area_x_ = (uchar)((std::abs(x_ - (mapX * 512)) / 16));
|
||||
area_y_ = (uchar)((std::abs(y_ - (mapY * 512)) / 16));
|
||||
|
||||
int mx = (mapId_ - ((mapId_ / 8) * 8));
|
||||
int my = (mapId_ / 8);
|
||||
|
||||
uchar xx = (uchar)((x_ - (mx * 512)) / 16);
|
||||
uchar yy = (uchar)((y_ - (my * 512)) / 16);
|
||||
|
||||
mapPos = (ushort)((((AreaY) << 6) | (AreaX & 0x3F)) << 1);
|
||||
map_pos_ = (ushort)((((area_y_) << 6) | (area_x_ & 0x3F)) << 1);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user