From dc99e19ed95fe24f2e7817bcba57cf2c41f5ed62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kapu=C5=9Bci=C5=84ski?= Date: Fri, 24 Dec 2021 19:02:25 +0100 Subject: [PATCH] Refactored Math::Point in CPhysics, CDisplayInfo, CFileDialog, CMainDialog, CMainMap, CMainShort and CStudio --- src/physics/physics.cpp | 16 ++++++++-------- src/ui/displayinfo.cpp | 14 +++++++------- src/ui/displayinfo.h | 16 ++++++++-------- src/ui/filedialog.cpp | 24 ++++++++++++------------ src/ui/filedialog.h | 14 +++++++------- src/ui/maindialog.cpp | 14 +++++++------- src/ui/maindialog.h | 8 ++++---- src/ui/mainmap.cpp | 6 +++--- src/ui/mainmap.h | 4 ++-- src/ui/mainshort.cpp | 10 +++++----- src/ui/mainshort.h | 6 +++--- src/ui/studio.cpp | 6 +++--- src/ui/studio.h | 16 ++++++++-------- 13 files changed, 77 insertions(+), 77 deletions(-) diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp index 56df3d29..d7c0abdb 100644 --- a/src/physics/physics.cpp +++ b/src/physics/physics.cpp @@ -1746,7 +1746,7 @@ void CPhysics::WaterFrame(float aTime, float rTime) { ObjectType type; Math::Vector pos, speed; - Math::Point dim; + glm::vec2 dim; float level; level = m_water->GetLevel(); @@ -1962,7 +1962,7 @@ void CPhysics::SoundMotorSlow(float rTime, ObjectType type) { Math::Matrix* mat; Math::Vector pos, speed; - Math::Point dim; + glm::vec2 dim; SoundType sound; float amplitude; int i, max; @@ -2128,7 +2128,7 @@ void CPhysics::SoundReactorFull(float rTime, ObjectType type) SoundType sound; Math::Matrix* mat; Math::Vector pos, speed; - Math::Point dim; + glm::vec2 dim; float freq; int i; @@ -2963,7 +2963,7 @@ void CPhysics::PowerParticle(float factor, bool bBreak) { Math::Matrix* mat; Math::Vector pos, ppos, eye, speed; - Math::Point dim; + glm::vec2 dim; bool bCarryPower; bCarryPower = false; @@ -3024,7 +3024,7 @@ void CPhysics::PowerParticle(float factor, bool bBreak) void CPhysics::CrashParticle(float crash) { Math::Vector pos, ppos, speed; - Math::Point dim; + glm::vec2 dim; float len; int i, max; @@ -3058,9 +3058,9 @@ void CPhysics::MotorParticle(float aTime, float rTime) { Math::Matrix* mat; Math::Vector pos, speed; - Math::Point dim; + glm::vec2 dim; ObjectType type; - Math::Point c, p; + glm::vec2 c, p; float h, a, delay, level; int r, i, nb; @@ -3582,7 +3582,7 @@ void CPhysics::WaterParticle(float aTime, Math::Vector pos, ObjectType type, float floor, float advance, float turn) { Math::Vector ppos, speed; - Math::Point dim; + glm::vec2 dim; float delay, level, min, max, force, volume, diam; int i, nb; diff --git a/src/ui/displayinfo.cpp b/src/ui/displayinfo.cpp index 2a91e125..588a6f6f 100644 --- a/src/ui/displayinfo.cpp +++ b/src/ui/displayinfo.cpp @@ -73,8 +73,8 @@ CDisplayInfo::CDisplayInfo() m_bInfoMaximized = true; m_bInfoMinimized = false; - m_infoFinalPos = m_infoActualPos = m_infoNormalPos = Math::Point(0.00f, 0.00f); - m_infoFinalDim = m_infoActualPos = m_infoNormalDim = Math::Point(1.00f, 1.00f); + m_infoFinalPos = m_infoActualPos = m_infoNormalPos = { 0.00f, 0.00f }; + m_infoFinalDim = m_infoActualPos = m_infoNormalDim = { 1.00f, 1.00f }; m_lightSuppl = -1; m_toto = nullptr; @@ -340,7 +340,7 @@ void CDisplayInfo::HyperUpdate() void CDisplayInfo::StartDisplayInfo(std::string filename, int index, bool bSoluce) { Gfx::Light light; - Math::Point pos, dim; + glm::vec2 pos, dim; Ui::CWindow* pw; Ui::CEdit* edit; Ui::CButton* button; @@ -373,7 +373,7 @@ void CDisplayInfo::StartDisplayInfo(std::string filename, int index, bool bSoluc //? pw->SetClosable(true); //? GetResource(RES_TEXT, RT_DISINFO_TITLE, res); //? pw->SetName(res); -//? pw->SetMinDim(Math::Point(0.56f, 0.40f)); +//? pw->SetMinDim(glm::vec2(0.56f, 0.40f)); //? pw->SetMaximized(m_bInfoMaximized); //? pw->SetMinimized(m_bInfoMinimized); //? m_main->SetEditFull(m_bInfoMaximized); @@ -466,14 +466,14 @@ void CDisplayInfo::StartDisplayInfo(std::string filename, int index, bool bSoluc // Repositions all controls editing. -void CDisplayInfo::AdjustDisplayInfo(Math::Point wpos, Math::Point wdim) +void CDisplayInfo::AdjustDisplayInfo(glm::vec2 wpos, glm::vec2 wdim) { CWindow* pw; CEdit* edit; CButton* button; CSlider* slider; CGroup* group; - Math::Point pos, dim; + glm::vec2 pos, dim; wpos.x = 50.0f / 640.0f; wpos.y = 30.0f / 480.0f; @@ -682,7 +682,7 @@ void CDisplayInfo::UpdateIndexButton() Ui::CButton* button; Ui::CGroup* group; Ui::CEdit* edit; - Math::Point pos, dim; + glm::vec2 pos, dim; char* filename; static int table[SATCOM_MAX] = diff --git a/src/ui/displayinfo.h b/src/ui/displayinfo.h index 4ea5acf6..d7b56870 100644 --- a/src/ui/displayinfo.h +++ b/src/ui/displayinfo.h @@ -19,7 +19,7 @@ #pragma once -#include "math/point.h" +#include #include @@ -60,7 +60,7 @@ public: protected: bool EventFrame(const Event &event); void HyperUpdate(); - void AdjustDisplayInfo(Math::Point wpos, Math::Point wdim); + void AdjustDisplayInfo(glm::vec2 wpos, glm::vec2 wdim); void ChangeIndexButton(int index); void UpdateIndexButton(); void UpdateCopyButton(); @@ -81,12 +81,12 @@ protected: bool m_bInfoMinimized; int m_index; - Math::Point m_infoNormalPos; - Math::Point m_infoNormalDim; - Math::Point m_infoActualPos; - Math::Point m_infoActualDim; - Math::Point m_infoFinalPos; - Math::Point m_infoFinalDim; + glm::vec2 m_infoNormalPos; + glm::vec2 m_infoNormalDim; + glm::vec2 m_infoActualPos; + glm::vec2 m_infoActualDim; + glm::vec2 m_infoFinalPos; + glm::vec2 m_infoFinalDim; int m_lightSuppl; bool m_bEditLock; ActivePause* m_satcomPause = nullptr; diff --git a/src/ui/filedialog.cpp b/src/ui/filedialog.cpp index 76340d39..591621f0 100644 --- a/src/ui/filedialog.cpp +++ b/src/ui/filedialog.cpp @@ -201,8 +201,8 @@ std::string CFileDialog::GetFilename() void CFileDialog::StartFileDialog() { m_captureClick = false; - Math::Point pos = m_windowPos; - Math::Point dim = m_windowDim; + glm::vec2 pos = m_windowPos; + glm::vec2 dim = m_windowDim; int icon = (m_dialogtype == CFileDialog::Type::Open) ? 14 : 13 ; CWindow* pw = m_interface->CreateWindows(pos, dim, icon, m_windowEvent); @@ -216,7 +216,7 @@ void CFileDialog::StartFileDialog() pw->SetState(STATE_SHADOW); pw->SetMovable(true); pw->SetClosable(true); - pw->SetMinDim(Math::Point(320.0f/640.0f, (121.0f+18.0f*4)/480.0f)); + pw->SetMinDim({ 320.0f / 640.0f, (121.0f + 18.0f * 4) / 480.0f }); if ( m_title.empty() ) { @@ -232,8 +232,8 @@ void CFileDialog::StartFileDialog() pw->SetName(m_title); std::string name; - pos = Math::Point(0.0f, 0.0f); - dim = Math::Point(0.0f, 0.0f); + pos = { 0.0f, 0.0f }; + dim = { 0.0f, 0.0f }; GetResource(RES_TEXT, RT_IO_LIST, name); CLabel* pla = pw->CreateLabel(pos, dim, 0, EVENT_DIALOG_LABEL1, name); // path label @@ -355,14 +355,14 @@ void CFileDialog::AdjustDialog() CWindow* pw = static_cast< CWindow* >(m_interface->SearchControl(m_windowEvent)); if ( pw == nullptr ) return; - Math::Point wpos = m_windowPos = pw->GetPos(); - Math::Point wdim = m_windowDim = pw->GetDim(); + glm::vec2 wpos = m_windowPos = pw->GetPos(); + glm::vec2 wdim = m_windowDim = pw->GetDim(); pw->SetPos(wpos); // to move the buttons on the titlebar pw->SetDim(wdim); - Math::Point ppos(wpos.x+10.0f/640.0f, wpos.y+wdim.y-55.0f/480.0f); - Math::Point ddim(wdim.x-150.0f/640.0f, 20.0f/480.0f); + glm::vec2 ppos(wpos.x+10.0f/640.0f, wpos.y+wdim.y-55.0f/480.0f); + glm::vec2 ddim(wdim.x-150.0f/640.0f, 20.0f/480.0f); CLabel* pla = static_cast< CLabel* >(pw->SearchControl(EVENT_DIALOG_LABEL1)); // path label if ( pla != nullptr ) @@ -692,13 +692,13 @@ bool CFileDialog::StartNewFolderMode() CList* pli = static_cast< CList* >(pw->SearchControl(EVENT_DIALOG_LIST)); // file list if ( pli == nullptr ) return false; - Math::Point dim = pli->GetDim(); + glm::vec2 dim = pli->GetDim(); dim.y -= 17.5f/480.0f; pli->SetDim(dim); pli->SetSelect(-1); pli->ShowSelect(false); - Math::Point pos = pli->GetPos(); + glm::vec2 pos = pli->GetPos(); pos.y += dim.y-3.0f/480.0f; dim.y = 20.0f/480.0f; @@ -1025,7 +1025,7 @@ void CFileDialog::UpdatePathLabel() CLabel* pl = static_cast< CLabel* >(pw->SearchControl(EVENT_DIALOG_LABEL1)); if ( pl != nullptr ) { - Math::Point dim = pl->GetDim(); + glm::vec2 dim = pl->GetDim(); size_t nch = static_cast< size_t >((dim.x*640.0f)/5.75f); std::string text = SearchDirectory(false); if (text.length() > nch) diff --git a/src/ui/filedialog.h b/src/ui/filedialog.h index 67622dfc..1ed38d22 100644 --- a/src/ui/filedialog.h +++ b/src/ui/filedialog.h @@ -21,7 +21,7 @@ #include "common/event.h" -#include "math/point.h" +#include #include #include @@ -148,22 +148,22 @@ public: /** * \brief Set the initial position of the window. */ - void SetWindowPos(Math::Point pos) { m_windowPos = pos; } + void SetWindowPos(const glm::vec2& pos) { m_windowPos = pos; } /** * \brief Get the position of the window. */ - Math::Point GetWindowPos() { return m_windowPos; } + glm::vec2 GetWindowPos() { return m_windowPos; } /** * \brief Set the initial size of the window. */ - void SetWindowDim(Math::Point dim) { m_windowDim = dim; } + void SetWindowDim(const glm::vec2& dim) { m_windowDim = dim; } /** * \brief Get the size of the window. */ - Math::Point GetWindowDim() { return m_windowDim; } + glm::vec2 GetWindowDim() { return m_windowDim; } /** * \brief Set the text for the title bar of the dialog. @@ -332,8 +332,8 @@ private: // With EVENT_NULL, a unique EventType will be used. EventType m_windowEvent = EVENT_NULL; - Math::Point m_windowPos; - Math::Point m_windowDim; + glm::vec2 m_windowPos; + glm::vec2 m_windowDim; std::string m_title = ""; float m_time; diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 264344fe..f94c578c 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -169,10 +169,10 @@ void CMainDialog::StartPauseMenu() { CWindow* pw; CButton* pb; - Math::Point pos, dim; + glm::vec2 pos, dim; std::string name; - StartDialog(Math::Point(0.3f, 0.8f), true); + StartDialog({ 0.3f, 0.8f }, true); m_dialogType = DialogType::PauseMenu; pw = static_cast(m_interface->SearchControl(EVENT_WINDOW9)); @@ -244,7 +244,7 @@ void CMainDialog::StartQuestion(const std::string& text, bool warningYes, bool w { CWindow* pw; CButton* pb; - Math::Point pos, dim, ddim; + glm::vec2 pos, dim, ddim; std::string name; dim.x = 0.7f; @@ -303,7 +303,7 @@ void CMainDialog::StartInformation(const std::string& title, const std::string& CWindow* pw; CButton* pb; CLabel* pl; - Math::Point pos, dim, ddim; + glm::vec2 pos, dim, ddim; std::string name; dim.x = 0.7f; @@ -346,10 +346,10 @@ void CMainDialog::StartInformation(const std::string& title, const std::string& // Beginning of displaying a dialog. -void CMainDialog::StartDialog(Math::Point dim, bool fireParticles) +void CMainDialog::StartDialog(const glm::vec2& dim, bool fireParticles) { CWindow* pw; - Math::Point pos, ddim; + glm::vec2 pos, ddim; m_main->StartSuspend(); @@ -405,7 +405,7 @@ void CMainDialog::FrameDialog(float rTime) { CWindow* pw; Math::Vector pos, speed; - Math::Point dim, dpos, ddim; + glm::vec2 dim, dpos, ddim; float zoom; int i; diff --git a/src/ui/maindialog.h b/src/ui/maindialog.h index 1ea18084..043e7ab2 100644 --- a/src/ui/maindialog.h +++ b/src/ui/maindialog.h @@ -21,7 +21,7 @@ #include "common/restext.h" -#include "math/point.h" +#include #include #include @@ -72,7 +72,7 @@ public: bool IsDialog(); protected: - void StartDialog(Math::Point dim, bool fireParticles); + void StartDialog(const glm::vec2& dim, bool fireParticles); void FrameDialog(float rTime); protected: @@ -92,8 +92,8 @@ protected: bool m_dialogOpen; DialogType m_dialogType; bool m_dialogFireParticles; - Math::Point m_dialogPos; - Math::Point m_dialogDim; + glm::vec2 m_dialogPos; + glm::vec2 m_dialogDim; float m_dialogTime; float m_dialogParti; diff --git a/src/ui/mainmap.cpp b/src/ui/mainmap.cpp index 4f98cca6..3f155a56 100644 --- a/src/ui/mainmap.cpp +++ b/src/ui/mainmap.cpp @@ -62,7 +62,7 @@ CMainMap::~CMainMap() void CMainMap::CreateMap() { CWindow* pw; - Math::Point pos, dim; + glm::vec2 pos, dim; pw = static_cast(m_interface->SearchControl(EVENT_WINDOW1)); if (pw == nullptr) @@ -158,7 +158,7 @@ void CMainMap::DimMap() CWindow* pw; CMap* pm; CSlider* ps; - Math::Point pos, dim; + glm::vec2 pos, dim; float value; pw = static_cast(m_interface->SearchControl(EVENT_WINDOW1)); @@ -361,7 +361,7 @@ bool CMainMap::GetFixImage() // The object is detected in the mini-map. -CObject* CMainMap::DetectMap(Math::Point pos, bool &bInMap) +CObject* CMainMap::DetectMap(const glm::vec2& pos, bool &bInMap) { CWindow* pw; CMap* pm; diff --git a/src/ui/mainmap.h b/src/ui/mainmap.h index d38b5b43..ce84f218 100644 --- a/src/ui/mainmap.h +++ b/src/ui/mainmap.h @@ -21,7 +21,7 @@ #include "graphics/core/color.h" -#include "math/point.h" +#include class CObject; class CEventQueue; @@ -53,7 +53,7 @@ public: void ZoomMap(); void MapEnable(bool bEnable); bool GetFixImage(); - CObject* DetectMap(Math::Point pos, bool &bInMap); + CObject* DetectMap(const glm::vec2& pos, bool &bInMap); void SetHighlight(CObject* pObj); void SetToy(bool bToy); void SetFixParam(float zoom, float ox, float oy, float angle, int mode, bool bDebug); diff --git a/src/ui/mainshort.cpp b/src/ui/mainshort.cpp index dfa5f38d..29652971 100644 --- a/src/ui/mainshort.cpp +++ b/src/ui/mainshort.cpp @@ -73,7 +73,7 @@ void CMainShort::SetMode(bool bBuilding) bool CMainShort::CreateShortcuts() { - Math::Point pos, dim; + glm::vec2 pos, dim; if ( m_main->GetFixScene() ) return false; @@ -139,7 +139,7 @@ bool CMainShort::CreateShortcuts() } std::sort(teams.begin(), teams.end()); - std::vector positions; + std::vector positions; for(unsigned int i = 0; i < teams.size(); i++) { positions.push_back(pos); @@ -336,15 +336,15 @@ void CMainShort::SelectNext() // The object detected by the mouse hovers over. -CObject* CMainShort::DetectShort(Math::Point pos) +CObject* CMainShort::DetectShort(const glm::vec2& pos) { for (unsigned int i = 0; i < m_shortcuts.size(); i++) { CControl* pc = m_interface->SearchControl(static_cast(EVENT_OBJECT_SHORTCUT+i)); if ( pc != nullptr ) { - Math::Point cpos = pc->GetPos(); - Math::Point cdim = pc->GetDim(); + glm::vec2 cpos = pc->GetPos(); + glm::vec2 cdim = pc->GetDim(); if ( pos.x >= cpos.x && pos.x <= cpos.x+cdim.x && diff --git a/src/ui/mainshort.h b/src/ui/mainshort.h index 40c9d73b..b7e2f23f 100644 --- a/src/ui/mainshort.h +++ b/src/ui/mainshort.h @@ -21,10 +21,10 @@ #include "common/event.h" -#include "math/point.h" - #include "object/object_type.h" +#include + #include class CRobotMain; @@ -51,7 +51,7 @@ public: bool UpdateShortcuts(); void SelectShortcut(EventType event); void SelectNext(); - CObject* DetectShort(Math::Point pos); + CObject* DetectShort(const glm::vec2& pos); void SetHighlight(CObject* pObj); protected: diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp index 10db1c00..fe646688 100644 --- a/src/ui/studio.cpp +++ b/src/ui/studio.cpp @@ -557,7 +557,7 @@ void CStudio::ColorizeScript(CEdit* edit) void CStudio::StartEditScript(CScript *script, std::string name, Program* program) { - Math::Point pos, dim; + glm::vec2 pos, dim; CWindow* pw; CEdit* edit; CButton* button; @@ -615,7 +615,7 @@ void CStudio::StartEditScript(CScript *script, std::string name, Program* progra GetResource(RES_TEXT, RT_STUDIO_TITLE, res); pw->SetName(res); - pw->SetMinDim(Math::Point(0.49f, 0.50f)); + pw->SetMinDim({ 0.49f, 0.50f }); pw->SetMaximized(m_bEditMaximized); pw->SetMinimized(m_bEditMinimized); @@ -710,7 +710,7 @@ void CStudio::AdjustEditScript() CGroup* group; CSlider* slider; CList* list; - Math::Point wpos, wdim, pos, dim, ppos, ddim; + glm::vec2 wpos, wdim, pos, dim, ppos, ddim; float hList; wpos = m_editActualPos; diff --git a/src/ui/studio.h b/src/ui/studio.h index c54f7a26..ddd89d52 100644 --- a/src/ui/studio.h +++ b/src/ui/studio.h @@ -84,14 +84,14 @@ protected: bool m_bEditMaximized; bool m_bEditMinimized; - Math::Point m_editActualPos; - Math::Point m_editActualDim; - Math::Point m_editFinalPos; - Math::Point m_editFinalDim; - Math::Point m_windowPos; - Math::Point m_windowDim; - Math::Point m_dialogPos; - Math::Point m_dialogDim; + glm::vec2 m_editActualPos; + glm::vec2 m_editActualDim; + glm::vec2 m_editFinalPos; + glm::vec2 m_editFinalDim; + glm::vec2 m_windowPos; + glm::vec2 m_windowDim; + glm::vec2 m_dialogPos; + glm::vec2 m_dialogDim; float m_time; float m_fixInfoTextTime;