diff --git a/src/app/app.cpp b/src/app/app.cpp index cfd73787..c097d81b 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -575,8 +575,7 @@ bool CApplication::Create() // GetVideoResolutionList() has to be called here because it is responsible // for list of resolutions in options menu, not calling it results in empty list - std::vector modes; - GetVideoResolutionList(modes); + auto modes = GetVideoResolutionList(); if ( GetConfigFile().GetStringProperty("Setup", "Resolution", sValue) && !m_resolutionOverride ) { @@ -1028,7 +1027,7 @@ void CApplication::UpdateJoystick() void CApplication::UpdateMouse() { - Math::IntPoint pos; + glm::ivec2 pos{}; SDL_GetMouseState(&pos.x, &pos.y); m_input->MouseMove(pos); } @@ -1302,7 +1301,7 @@ Event CApplication::ProcessSystemEvent() { event.type = EVENT_MOUSE_MOVE; - m_input->MouseMove(Math::IntPoint(m_private->currentEvent.button.x, m_private->currentEvent.button.y)); + m_input->MouseMove({ m_private->currentEvent.button.x, m_private->currentEvent.button.y }); } else if (m_private->currentEvent.type == SDL_JOYAXISMOTION) { @@ -1627,19 +1626,21 @@ Gfx::DeviceConfig CApplication::GetVideoConfig() const return m_deviceConfig; } -void CApplication::GetVideoResolutionList(std::vector &resolutions, int display) const +std::vector CApplication::GetVideoResolutionList(int display) const { - resolutions.clear(); + std::vector resolutions; for(int i = 0; i < SDL_GetNumDisplayModes(display); i++) { SDL_DisplayMode mode; SDL_GetDisplayMode(display, i, &mode); - Math::IntPoint resolution = Math::IntPoint(mode.w, mode.h); + glm::ivec2 resolution = { mode.w, mode.h }; if (std::find(resolutions.begin(), resolutions.end(), resolution) == resolutions.end()) resolutions.push_back(resolution); } + + return resolutions; } void CApplication::SetDebugModeActive(DebugMode mode, bool active) @@ -1713,7 +1714,7 @@ MouseMode CApplication::GetMouseMode() const void CApplication::MoveMouse(Math::Point pos) { - Math::IntPoint windowPos = m_engine->InterfaceToWindowCoords(pos); + glm::ivec2 windowPos = m_engine->InterfaceToWindowCoords(pos); m_input->MouseMove(windowPos); SDL_WarpMouseInWindow(m_private->window, windowPos.x, windowPos.y); } diff --git a/src/app/app.h b/src/app/app.h index 14f8d6fb..dc6f95d9 100644 --- a/src/app/app.h +++ b/src/app/app.h @@ -32,7 +32,8 @@ #include "graphics/core/device.h" #include "level/level_category.h" -#include "math/intpoint.h" + +#include #include #include @@ -184,7 +185,7 @@ public: const std::string& GetErrorMessage() const; //! Returns a list of possible video modes - void GetVideoResolutionList(std::vector &resolutions, int display = 0) const; + std::vector GetVideoResolutionList(int display = 0) const; //! Returns the current video mode Gfx::DeviceConfig GetVideoConfig() const; diff --git a/src/object/motion/motiontoto.cpp b/src/object/motion/motiontoto.cpp index 5901a25b..80f1bef9 100644 --- a/src/object/motion/motiontoto.cpp +++ b/src/object/motion/motiontoto.cpp @@ -237,7 +237,7 @@ bool CMotionToto::EventFrame(const Event &event) Math::Vector eye, lookat, dir, perp, nPos, aPos, pos, speed; Math::Vector vibLin, vibCir, dirSpeed, aAntenna; Math::Point dim; - Math::IntPoint wDim; + glm::ivec2 wDim; Gfx::ParticleType type; float progress, focus, distance, shift, verti, level, zoom; float aAngle, nAngle, mAngle, angle, linSpeed, cirSpeed; diff --git a/src/object/task/taskgoto.cpp b/src/object/task/taskgoto.cpp index 0964a2e5..5b55fac8 100644 --- a/src/object/task/taskgoto.cpp +++ b/src/object/task/taskgoto.cpp @@ -114,7 +114,7 @@ bool CTaskGoto::EventProcess(const Event &event) { if (m_bmArray != nullptr) { - std::unique_ptr debugImage = MakeUnique(Math::IntPoint(m_bmSize, m_bmSize)); + std::unique_ptr debugImage = MakeUnique(glm::ivec2(m_bmSize, m_bmSize)); debugImage->Fill(Gfx::IntColor(255, 255, 255, 255)); for (int x = 0; x < m_bmSize; x++) { @@ -126,7 +126,7 @@ bool CTaskGoto::EventProcess(const Event &event) { Gfx::Color c = Gfx::Color(0.0f, 0.0f, 0.0f, 1.0f); if (b) c = Gfx::Color(0.0f, 0.0f, 1.0f, 1.0f); - debugImage->SetPixel(Math::IntPoint(x, y), c); + debugImage->SetPixel({ x, y }, c); } } } diff --git a/src/ui/controls/map.cpp b/src/ui/controls/map.cpp index 386dae49..33c770b2 100644 --- a/src/ui/controls/map.cpp +++ b/src/ui/controls/map.cpp @@ -1031,7 +1031,7 @@ void CMap::UpdateTerrain() { if (! m_fixImage.empty()) return; // still image? - CImage img(Math::IntPoint(256, 256)); + CImage img(glm::ivec2(256, 256)); float scale = m_terrain->GetReliefScale(); float water = m_water->GetLevel(); @@ -1077,7 +1077,7 @@ void CMap::UpdateTerrain() color.b = Math::Norm(m_waterColor.b + (intensity - 0.5f)); } - img.SetPixel(Math::IntPoint(x, y), color); + img.SetPixel({ x, y }, color); } } diff --git a/src/ui/displayinfo.cpp b/src/ui/displayinfo.cpp index 1dfc8bac..2a91e125 100644 --- a/src/ui/displayinfo.cpp +++ b/src/ui/displayinfo.cpp @@ -890,7 +890,6 @@ void CDisplayInfo::ViewDisplayInfo() { Ui::CWindow* pw; Ui::CEdit* edit; - Math::IntPoint dim; pw = static_cast(m_interface->SearchControl(EVENT_WINDOW4)); if ( pw == nullptr ) return; @@ -898,7 +897,7 @@ void CDisplayInfo::ViewDisplayInfo() edit = static_cast(pw->SearchControl(EVENT_EDIT1)); if ( edit == nullptr ) return; - dim = m_engine->GetWindowSize(); + auto dim = m_engine->GetWindowSize(); edit->SetFontSize(CSettings::GetInstancePointer()->GetFontSize()/(dim.x / 640.0f)); } diff --git a/src/ui/mainshort.cpp b/src/ui/mainshort.cpp index 4f5e89e6..dfa5f38d 100644 --- a/src/ui/mainshort.cpp +++ b/src/ui/mainshort.cpp @@ -89,7 +89,7 @@ bool CMainShort::CreateShortcuts() m_shortcuts.clear(); - Math::IntPoint size = m_engine->GetWindowSize(); + glm::ivec2 size = m_engine->GetWindowSize(); float ratio = static_cast(size.y) / static_cast(size.x); // Display pause / movie indicator diff --git a/src/ui/screen/screen_setup_display.cpp b/src/ui/screen/screen_setup_display.cpp index d25c3492..00f86e14 100644 --- a/src/ui/screen/screen_setup_display.cpp +++ b/src/ui/screen/screen_setup_display.cpp @@ -64,8 +64,8 @@ void CScreenSetupDisplay::CreateInterface() pw = static_cast(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == nullptr ) return; - std::vector modes; - m_app->GetVideoResolutionList(modes); + auto modes = m_app->GetVideoResolutionList(); + for (auto it = modes.begin(); it != modes.end(); ++it) { if (it->x == m_app->GetVideoConfig().size.x && it->y == m_app->GetVideoConfig().size.y) @@ -218,10 +218,9 @@ static int GCD(int a, int b) return (b == 0) ? a : GCD(b, a%b); } -static Math::IntPoint AspectRatio(Math::IntPoint resolution) +static glm::ivec2 AspectRatio(const glm::ivec2& resolution) { - int gcd = GCD(resolution.x, resolution.y); - return Math::IntPoint(static_cast(resolution.x) / gcd, static_cast(resolution.y) / gcd); + return resolution / GCD(resolution.x, resolution.y); } void CScreenSetupDisplay::UpdateDisplayMode() @@ -235,14 +234,14 @@ void CScreenSetupDisplay::UpdateDisplayMode() if ( pl == nullptr ) return; pl->Flush(); - std::vector modes; - m_app->GetVideoResolutionList(modes); + auto modes = m_app->GetVideoResolutionList(); + int i = 0; std::stringstream mode_text; - for (Math::IntPoint mode : modes) + for (const auto& mode : modes) { mode_text.str(""); - Math::IntPoint aspect = AspectRatio(mode); + glm::ivec2 aspect = AspectRatio(mode); mode_text << mode.x << "x" << mode.y << " [" << aspect.x << ":" << aspect.y << "]"; pl->SetItemName(i++, mode_text.str()); } @@ -272,8 +271,7 @@ void CScreenSetupDisplay::ChangeDisplay() bFull = pc->TestState(STATE_CHECK); m_setupFull = bFull; - std::vector modes; - m_app->GetVideoResolutionList(modes); + auto modes = m_app->GetVideoResolutionList(); Gfx::DeviceConfig config = m_app->GetVideoConfig(); config.size = modes[m_setupSelMode]; diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp index 39d99ba8..10db1c00 100644 --- a/src/ui/studio.cpp +++ b/src/ui/studio.cpp @@ -1111,7 +1111,6 @@ void CStudio::ViewEditScript() { CWindow* pw; CEdit* edit; - Math::IntPoint dim; pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3)); if ( pw == nullptr ) return; @@ -1119,7 +1118,7 @@ void CStudio::ViewEditScript() edit = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT)); if ( edit == nullptr ) return; - dim = m_engine->GetWindowSize(); + glm::ivec2 dim = m_engine->GetWindowSize(); edit->SetFontSize(m_settings->GetFontSize()/(dim.x/640.0f)); }