mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-05 10:59:02 +01:00
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.
This commit is contained in:
@@ -1121,6 +1121,7 @@ int eu07_application::init_settings(int Argc, char *Argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
// process command line arguments
|
// process command line arguments
|
||||||
|
auto scenerywasasked = false;
|
||||||
for (int i = 1; i < Argc; ++i)
|
for (int i = 1; i < Argc; ++i)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -1131,6 +1132,7 @@ int eu07_application::init_settings(int Argc, char *Argv[])
|
|||||||
if (i + 1 < Argc)
|
if (i + 1 < Argc)
|
||||||
{
|
{
|
||||||
Global.SceneryFile = ToLower(Argv[++i]);
|
Global.SceneryFile = ToLower(Argv[++i]);
|
||||||
|
scenerywasasked = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (token == "-v")
|
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
|
// the editor opens on empty ground unless a scenery was actually asked for. whatever the ini
|
||||||
// just the region, the lighting and the clock, with no rolling stock and no timetables
|
// 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";
|
Global.SceneryFile = "pusta.scn";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -158,8 +158,6 @@ void plan_panel::render_location_dialog()
|
|||||||
ImGui::InvisibleButton("poland_map", mapsize);
|
ImGui::InvisibleButton("poland_map", mapsize);
|
||||||
auto const hovered{ImGui::IsItemHovered()};
|
auto const hovered{ImGui::IsItemHovered()};
|
||||||
|
|
||||||
auto const &places{editor::poland_places()};
|
|
||||||
|
|
||||||
// fit the whole country the first time round; afterwards the wheel decides
|
// fit the whole country the first time round; afterwards the wheel decides
|
||||||
if (m_mapscale <= 0.0)
|
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
|
// 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
|
// request; drawing it against its own box keeps it registered while the new one arrives
|
||||||
auto const &covered{m_topomap.covered()};
|
auto const &covered{m_topomap.covered()};
|
||||||
drawlist->AddImage(reinterpret_cast<ImTextureID>(static_cast<intptr_t>(backdrop)), to_screen(covered.min_x, covered.max_y), to_screen(covered.max_x, covered.min_y));
|
// 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<ImTextureID>(static_cast<intptr_t>(backdrop)), to_screen(covered.min_x, covered.max_y), to_screen(covered.max_x, covered.min_y), ImVec2(0.0f, 1.0f),
|
||||||
for (auto const &place : places)
|
ImVec2(1.0f, 0.0f));
|
||||||
{
|
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const picked{to_screen(m_pickx, m_picky)};
|
auto const picked{to_screen(m_pickx, m_picky)};
|
||||||
@@ -238,22 +232,6 @@ void plan_panel::render_location_dialog()
|
|||||||
ImGui::SetNextItemWidth(180.0f);
|
ImGui::SetNextItemWidth(180.0f);
|
||||||
ImGui::InputDouble("northing", &m_picky, 100.0, 1000.0, "%.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();
|
ImGui::Spacing();
|
||||||
if (ImGui::Button("Use this place", ImVec2(160.0f, 0.0f)))
|
if (ImGui::Button("Use this place", ImVec2(160.0f, 0.0f)))
|
||||||
{
|
{
|
||||||
@@ -374,7 +352,9 @@ void plan_panel::draw_on_scene()
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
drawlist->AddImageQuad(reinterpret_cast<ImTextureID>(static_cast<intptr_t>(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<ImTextureID>(static_cast<intptr_t>(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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,62 +18,26 @@ namespace editor
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
// geographic coordinates, degrees, as (latitude, longitude); projected to EPSG:2180 on first use so
|
// the country's corners in degrees, wide enough to hold all of it: the Odra in the west, the Bug in
|
||||||
// the numbers stay readable and there is a single place where the frame is decided
|
// the east, the Tatras in the south and the coast in the north
|
||||||
struct geo_point
|
double const kSouthLatitude = 49.00;
|
||||||
{
|
double const kNorthLatitude = 54.90;
|
||||||
double latitude;
|
double const kWestLongitude = 14.10;
|
||||||
double longitude;
|
double const kEastLongitude = 24.20;
|
||||||
};
|
|
||||||
|
|
||||||
// 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}}};
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void poland_extent(glm::dvec2 &Min, glm::dvec2 &Max)
|
void poland_extent(glm::dvec2 &Min, glm::dvec2 &Max)
|
||||||
{
|
{
|
||||||
// the projection is not axis-aligned with the graticule, so the extreme corners come from
|
// the projection is not axis-aligned with the graticule, so the extremes come from projecting
|
||||||
// projecting all four of them and taking the outermost values
|
// all four corners and taking the outermost values
|
||||||
auto const sw = puwg1992(kSouthWest.latitude, kSouthWest.longitude);
|
auto const sw = puwg1992(kSouthLatitude, kWestLongitude);
|
||||||
auto const se = puwg1992(kSouthWest.latitude, kNorthEast.longitude);
|
auto const se = puwg1992(kSouthLatitude, kEastLongitude);
|
||||||
auto const nw = puwg1992(kNorthEast.latitude, kSouthWest.longitude);
|
auto const nw = puwg1992(kNorthLatitude, kWestLongitude);
|
||||||
auto const ne = puwg1992(kNorthEast.latitude, kNorthEast.longitude);
|
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})};
|
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})};
|
Max = {std::max({sw.x, se.x, nw.x, ne.x}), std::max({sw.y, se.y, nw.y, ne.y})};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<map_place> const &poland_places()
|
|
||||||
{
|
|
||||||
static std::vector<map_place> const places = []() {
|
|
||||||
std::vector<map_place> 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
|
} // namespace editor
|
||||||
|
|||||||
@@ -9,25 +9,13 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
namespace editor
|
namespace editor
|
||||||
{
|
{
|
||||||
|
|
||||||
// a named point to start a scenery from, in EPSG:2180 metres
|
// the whole country's extent in EPSG:2180 metres, as the opening view of a location picker. from
|
||||||
struct map_place
|
// there the base map itself carries the detail, so nothing else has to be drawn on top of it
|
||||||
{
|
|
||||||
std::string name;
|
|
||||||
glm::dvec2 position;
|
|
||||||
};
|
|
||||||
|
|
||||||
// larger cities, to put the view somewhere recognisable before picking the exact spot
|
|
||||||
std::vector<map_place> const &poland_places();
|
|
||||||
|
|
||||||
// the whole country's extent in EPSG:2180 metres, as the starting view of a location picker
|
|
||||||
void poland_extent(glm::dvec2 &Min, glm::dvec2 &Max);
|
void poland_extent(glm::dvec2 &Min, glm::dvec2 &Max);
|
||||||
|
|
||||||
} // namespace editor
|
} // namespace editor
|
||||||
|
|||||||
Reference in New Issue
Block a user