Skip to content

Commit

Permalink
Add minimap manual scaling and show tile search results on map
Browse files Browse the repository at this point in the history
  • Loading branch information
Dregu committed Aug 20, 2024
1 parent 16fa24c commit 7fe751d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 17 deletions.
52 changes: 35 additions & 17 deletions ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,8 +633,8 @@ void UI::DrawMap() {
ImGuiIO &io = ImGui::GetIO();
ImGuiContext &g = *GImGui;

ImVec2 realmapsize{800 * uiScale, 528 * uiScale};
ImVec2 roomsize{40 * uiScale, 22 * uiScale};
ImVec2 realmapsize{800 * uiScale * mapScale, 528 * uiScale * mapScale};
ImVec2 roomsize{40 * uiScale * mapScale, 22 * uiScale * mapScale};

static const std::map<int, std::pair<S32Vec2, S32Vec2>> areas{
//{0, {{2, 4}, {18, 20}}},
Expand Down Expand Up @@ -665,10 +665,11 @@ void UI::DrawMap() {
ImGui::InputInt("Map##MinimapMap", &layer);
layer = (layer + 5) % 5;
ImGui::PopItemWidth();
ImGui::SameLine(mapsize.x - 60.f * uiScale);
if (ImGui::Button("Refresh##MinimapRefresh",
ImVec2(60.f * uiScale + ImGui::GetStyle().WindowPadding.x,
ImGui::GetItemRectSize().y)) ||
ImGui::SameLine(mapsize.x - 60.f * uiScale * mapScale);
if (ImGui::Button(
"Refresh##MinimapRefresh",
ImVec2(60.f * uiScale * mapScale + ImGui::GetStyle().WindowPadding.x,
ImGui::GetItemRectSize().y)) ||
(((options["map_auto"].value ||
ImGui::IsKeyChordDown((ImGuiKey)keys["mouse_warp"])) &&
ImGui::GetFrameCount() > lastMinimapFrame + 15)) ||
Expand Down Expand Up @@ -774,30 +775,30 @@ void UI::DrawMap() {

{
auto px = Max::get().player_room()->x * roomsize.x +
(Max::get().player_position()->x / 320.f * roomsize.x);
((Max::get().player_position()->x + 4.f) / 320.f * roomsize.x);
auto py = Max::get().player_room()->y * roomsize.y +
(Max::get().player_position()->y / 180.f * roomsize.y);
((Max::get().player_position()->y + 4.f) / 180.f * roomsize.y);
ImGui::GetWindowDrawList()->AddCircleFilled(
ImVec2(a.x + d.x + px - c.x - bordersize.x,
a.y + d.y + py - c.y - bordersize.y),
3.f, 0xee0000ee);
3.f * uiScale * mapScale, 0xee0000ee);
}

if (options["map_wheel"].value) {
auto px = Max::get().player_room()->x * roomsize.x +
(Max::get().player_wheel()->x / 320.f * roomsize.x);
auto py = Max::get().player_room()->y * roomsize.y +
(Max::get().player_wheel()->y / 180.f * roomsize.y);
while (px < 80.f * uiScale)
px += 640.f * uiScale;
while (px > 720.f * uiScale)
px -= 640.f * uiScale;
while (py > 440.f * uiScale)
py -= 352.f * uiScale;
while (px < 80.f * uiScale * mapScale)
px += 640.f * uiScale * mapScale;
while (px > 720.f * uiScale * mapScale)
px -= 640.f * uiScale * mapScale;
while (py > 440.f * uiScale * mapScale)
py -= 352.f * uiScale * mapScale;
ImGui::GetWindowDrawList()->AddCircle(
ImVec2(a.x + d.x + px - c.x - bordersize.x,
a.y + d.y + py - c.y - bordersize.y),
4.f, 0xee00ffee, 0, 1.5f);
4.f * uiScale * mapScale, 0xee00ffee, 0, 1.5f * uiScale * mapScale);
}

if (options["map_uv_bunny"].value &&
Expand All @@ -807,7 +808,20 @@ void UI::DrawMap() {
ImGui::GetWindowDrawList()->AddCircleFilled(
ImVec2(a.x + d.x + px - c.x - bordersize.x,
a.y + d.y + py - c.y - bordersize.y),
4.f, rand() | 0xff000000);
4.f * uiScale * mapScale, rand() | 0xff000000);
}

for (auto &tile : searchTiles) {
auto px =
tile.room.x * roomsize.x + (tile.pos.x * 8.f / 320.f * roomsize.x);
auto py =
tile.room.y * roomsize.y + (tile.pos.y * 8.f / 180.f * roomsize.y);
ImGui::GetWindowDrawList()->AddRectFilled(
ImVec2(a.x + d.x + px - c.x - bordersize.x - uiScale * mapScale,
a.y + d.y + py - c.y - bordersize.y - uiScale * mapScale),
ImVec2(a.x + d.x + px - c.x - bordersize.x + uiScale * mapScale,
a.y + d.y + py - c.y - bordersize.y + uiScale * mapScale),
0xffffff33);
}
}
}
Expand Down Expand Up @@ -1009,6 +1023,7 @@ void UI::DrawOptions() {
if (noclip && !options["cheat_noclip"].value)
*Max::get().player_state() = 0;
UpdateOptions();
ImGui::SliderFloat("Minimap scale", &mapScale, 1.f, 5.f, "%.1fx");
if (ImGui::SliderInt("Window scale", &windowScale, 1, 10, "%dx")) {
ScaleWindow();
}
Expand Down Expand Up @@ -2440,6 +2455,8 @@ void UI::SaveINI() {
}
writeData << "scale = " << std::dec << windowScale << " # int, 1 - 10"
<< std::endl;
writeData << "map_scale = " << std::dec << mapScale << " # float, 1 - 5"
<< std::endl;

writeData << "\n[ui_keys] # hex ImGuiKeyChord\n";
for (const auto &[name, key] : keys) {
Expand Down Expand Up @@ -2502,6 +2519,7 @@ void UI::LoadINI() {
options[name].value = (bool)toml::find_or<int>(opts, name, (int)opt.value);
}
windowScale = toml::find_or<int>(opts, "scale", 4);
mapScale = toml::find_or<float>(opts, "map_scale", 1.f);

toml::value custom_keys;
try {
Expand Down
1 change: 1 addition & 0 deletions ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ class UI {
int windowScale = 4;
float dpiScale = 1.0f;
float uiScale = 1.0f;
float mapScale = 1.0f;
std::string screenShotFileName = "MAXWELL";
std::string screenShotNextFrame = "";
std::string screenShotThisFrame = "";
Expand Down

0 comments on commit 7fe751d

Please sign in to comment.