From 32a4df6111ab26b31550099cbfb0935aec8eb4a9 Mon Sep 17 00:00:00 2001 From: maj00r Date: Fri, 31 Jul 2026 19:47:11 +0200 Subject: [PATCH] Fix the base map orientation, drop the city overlay, keep td.scn out of the editor The Geoportal images arrive with their first row at the north edge, which is the opposite of what the default texture coordinates assume - the vertical ones are now swapped, for the picker's base map and the orthophoto alike. With the real map carrying its own detail as the view zooms in, the drawn city markers had nothing to add and are gone, along with the coordinate table behind them. Only the country's extent remains, to open the picker on. -editor no longer inherits the scenery named in eu07.ini. That is whatever was last driven, which has nothing to do with editing; without an explicit -s the editor opens on empty ground. --- application/application.cpp | 9 ++++-- application/planpanel.cpp | 34 +++++---------------- editor/polandmap.cpp | 60 ++++++++----------------------------- editor/polandmap.h | 16 ++-------- 4 files changed, 27 insertions(+), 92 deletions(-) diff --git a/application/application.cpp b/application/application.cpp index 156bb04a..37a8bab6 100644 --- a/application/application.cpp +++ b/application/application.cpp @@ -1121,6 +1121,7 @@ int eu07_application::init_settings(int Argc, char *Argv[]) } // process command line arguments + auto scenerywasasked = false; for (int i = 1; i < Argc; ++i) { @@ -1131,6 +1132,7 @@ int eu07_application::init_settings(int Argc, char *Argv[]) if (i + 1 < Argc) { Global.SceneryFile = ToLower(Argv[++i]); + scenerywasasked = true; } } else if (token == "-v") @@ -1153,10 +1155,11 @@ int eu07_application::init_settings(int Argc, char *Argv[]) } } - if (Global.editor_startup && Global.SceneryFile.empty()) + if (Global.editor_startup && false == scenerywasasked) { - // the editor needs a loaded world, but not necessarily anything in it - an empty scenery gives - // just the region, the lighting and the clock, with no rolling stock and no timetables + // the editor opens on empty ground unless a scenery was actually asked for. whatever the ini + // happens to name is the last thing that was driven, which has nothing to do with editing; an + // empty scenery still gives the region, the lighting and the clock, just nothing standing on it Global.SceneryFile = "pusta.scn"; } diff --git a/application/planpanel.cpp b/application/planpanel.cpp index a92b4b70..03be0607 100644 --- a/application/planpanel.cpp +++ b/application/planpanel.cpp @@ -158,8 +158,6 @@ void plan_panel::render_location_dialog() ImGui::InvisibleButton("poland_map", mapsize); auto const hovered{ImGui::IsItemHovered()}; - auto const &places{editor::poland_places()}; - // fit the whole country the first time round; afterwards the wheel decides if (m_mapscale <= 0.0) { @@ -213,14 +211,10 @@ void plan_panel::render_location_dialog() // the picture on screen is the one that was fetched, which may lag the current view by a // request; drawing it against its own box keeps it registered while the new one arrives auto const &covered{m_topomap.covered()}; - drawlist->AddImage(reinterpret_cast(static_cast(backdrop)), to_screen(covered.min_x, covered.max_y), to_screen(covered.max_x, covered.min_y)); - } - - for (auto const &place : places) - { - auto const point{to_screen(place.position.x, place.position.y)}; - drawlist->AddCircleFilled(point, 3.0f, IM_COL32(200, 200, 200, 255)); - drawlist->AddText(ImVec2(point.x + 5.0f, point.y - 6.0f), IM_COL32(190, 190, 190, 255), place.name.c_str()); + // the image arrives with its first row at the north edge, which is the opposite of what the + // default texture coordinates assume, so the vertical ones are swapped + drawlist->AddImage(reinterpret_cast(static_cast(backdrop)), to_screen(covered.min_x, covered.max_y), to_screen(covered.max_x, covered.min_y), ImVec2(0.0f, 1.0f), + ImVec2(1.0f, 0.0f)); } auto const picked{to_screen(m_pickx, m_picky)}; @@ -238,22 +232,6 @@ void plan_panel::render_location_dialog() ImGui::SetNextItemWidth(180.0f); ImGui::InputDouble("northing", &m_picky, 100.0, 1000.0, "%.0f"); - ImGui::SetNextItemWidth(220.0f); - if (ImGui::BeginCombo("go to", "pick a city")) - { - for (auto const &place : places) - { - if (ImGui::Selectable(place.name.c_str())) - { - m_pickx = place.position.x; - m_picky = place.position.y; - m_mapviewx = m_pickx; - m_mapviewy = m_picky; - } - } - ImGui::EndCombo(); - } - ImGui::Spacing(); if (ImGui::Button("Use this place", ImVec2(160.0f, 0.0f))) { @@ -374,7 +352,9 @@ void plan_panel::draw_on_scene() { continue; } - drawlist->AddImageQuad(reinterpret_cast(static_cast(tile.texture)), corners[0], corners[1], corners[2], corners[3]); + // same north-first row order as the picker's base map, so the same swap applies + drawlist->AddImageQuad(reinterpret_cast(static_cast(tile.texture)), corners[0], corners[1], corners[2], corners[3], ImVec2(0.0f, 1.0f), ImVec2(1.0f, 1.0f), + ImVec2(1.0f, 0.0f), ImVec2(0.0f, 0.0f)); } } diff --git a/editor/polandmap.cpp b/editor/polandmap.cpp index 315611bd..ea3ff16c 100644 --- a/editor/polandmap.cpp +++ b/editor/polandmap.cpp @@ -18,62 +18,26 @@ namespace editor namespace { -// geographic coordinates, degrees, as (latitude, longitude); projected to EPSG:2180 on first use so -// the numbers stay readable and there is a single place where the frame is decided -struct geo_point -{ - double latitude; - double longitude; -}; - -// the country's corners, wide enough to hold all of it: the Odra in the west, the Bug in the east, -// the Tatras in the south and the coast in the north -constexpr geo_point kSouthWest{49.00, 14.10}; -constexpr geo_point kNorthEast{54.90, 24.20}; - -struct named_geo_point -{ - char const *name; - geo_point position; -}; - -constexpr named_geo_point kPlaces[]{ - {"Warszawa", {52.23, 21.01}}, {"Krakow", {50.06, 19.94}}, {"Lodz", {51.77, 19.46}}, - {"Wroclaw", {51.11, 17.03}}, {"Poznan", {52.41, 16.93}}, {"Gdansk", {54.35, 18.65}}, - {"Szczecin", {53.43, 14.55}}, {"Bydgoszcz", {53.12, 18.01}}, {"Lublin", {51.25, 22.57}}, - {"Bialystok", {53.13, 23.16}}, {"Katowice", {50.26, 19.02}}, {"Rzeszow", {50.04, 22.00}}, - {"Olsztyn", {53.78, 20.49}}, {"Kielce", {50.87, 20.63}}, {"Zielona Gora", {51.94, 15.51}}, - {"Opole", {50.67, 17.93}}, {"Torun", {53.02, 18.61}}, {"Gorzow Wlkp.", {52.73, 15.24}}, - {"Koszalin", {54.19, 16.18}}, {"Czestochowa", {50.81, 19.12}}}; +// the country's corners in degrees, wide enough to hold all of it: the Odra in the west, the Bug in +// the east, the Tatras in the south and the coast in the north +double const kSouthLatitude = 49.00; +double const kNorthLatitude = 54.90; +double const kWestLongitude = 14.10; +double const kEastLongitude = 24.20; } // namespace void poland_extent(glm::dvec2 &Min, glm::dvec2 &Max) { - // the projection is not axis-aligned with the graticule, so the extreme corners come from - // projecting all four of them and taking the outermost values - auto const sw = puwg1992(kSouthWest.latitude, kSouthWest.longitude); - auto const se = puwg1992(kSouthWest.latitude, kNorthEast.longitude); - auto const nw = puwg1992(kNorthEast.latitude, kSouthWest.longitude); - auto const ne = puwg1992(kNorthEast.latitude, kNorthEast.longitude); + // the projection is not axis-aligned with the graticule, so the extremes come from projecting + // all four corners and taking the outermost values + auto const sw = puwg1992(kSouthLatitude, kWestLongitude); + auto const se = puwg1992(kSouthLatitude, kEastLongitude); + auto const nw = puwg1992(kNorthLatitude, kWestLongitude); + auto const ne = puwg1992(kNorthLatitude, kEastLongitude); Min = {std::min({sw.x, se.x, nw.x, ne.x}), std::min({sw.y, se.y, nw.y, ne.y})}; Max = {std::max({sw.x, se.x, nw.x, ne.x}), std::max({sw.y, se.y, nw.y, ne.y})}; } -std::vector const &poland_places() -{ - static std::vector const places = []() { - std::vector result; - result.reserve(std::size(kPlaces)); - for (auto const &place : kPlaces) - { - result.push_back({place.name, puwg1992(place.position.latitude, place.position.longitude)}); - } - return result; - }(); - - return places; -} - } // namespace editor diff --git a/editor/polandmap.h b/editor/polandmap.h index 7ee65f63..ded458dc 100644 --- a/editor/polandmap.h +++ b/editor/polandmap.h @@ -9,25 +9,13 @@ http://mozilla.org/MPL/2.0/. #pragma once -#include -#include - #include namespace editor { -// a named point to start a scenery from, in EPSG:2180 metres -struct map_place -{ - std::string name; - glm::dvec2 position; -}; - -// larger cities, to put the view somewhere recognisable before picking the exact spot -std::vector const &poland_places(); - -// the whole country's extent in EPSG:2180 metres, as the starting view of a location picker +// the whole country's extent in EPSG:2180 metres, as the opening view of a location picker. from +// there the base map itself carries the detail, so nothing else has to be drawn on top of it void poland_extent(glm::dvec2 &Min, glm::dvec2 &Max); } // namespace editor