From 6e8f8ccfa984e96a730197cbe8097d1423d55427 Mon Sep 17 00:00:00 2001 From: Petr Ohlidal Date: Fri, 22 Sep 2023 02:08:17 +0200 Subject: [PATCH] OGRE14 migration (WIP, build broken) Codechanges: * GUIUtils, InputEngine: `getModifierKeyName()` replaced OIS keycodes with OgreBites/SDL keycodes * ImGuiAngelscript: commented out some dead items, added (ImGuiKey) casts where needed, see https://github.com/ocornut/imgui/issues/4921 * GUI_VehicleButtons: build fix for `ImGui::ImageButton()` - added parameter ID-string. * GUI_RepositorySelector: updated thumbnail downloading to use new OGRE WorkQueue API, see https://github.com/OGRECave/ogre/blob/master/Docs/14-Notes.md#task-based-workqueue * Application.h, main.cpp: added :envelope: `MSG_NET_DOWNLOAD_REPOTHUMB_SUCCESS`, used instead of OGRE WorkQueue's `addMainThreadTask` for consistency across the various background threads in the codebase. * GodRaysManager: build fix - RENDER_QUEUE_9 was removed from OGRE, using 8. * RttManager: rendersystem-specific `getProjectionMatrixRS()` was removed from OGRE, using portable `getProjectionMatrix()` --- cmake/DependenciesConfig.cmake | 2 +- conanfile.py | 8 +-- source/main/Application.h | 1 + source/main/gfx/hydrax/GodRaysManager.cpp | 2 +- source/main/gfx/hydrax/RttManager.cpp | 4 +- source/main/gui/GUIUtils.cpp | 2 +- source/main/gui/GUIUtils.h | 2 +- .../gui/panels/GUI_RepositorySelector.cpp | 33 ++++++------ .../main/gui/panels/GUI_RepositorySelector.h | 11 ++-- source/main/gui/panels/GUI_VehicleButtons.cpp | 50 +++++++++---------- source/main/main.cpp | 8 +++ .../main/physics/collision/PointColDetector.h | 2 + .../scripting/bindings/ImGuiAngelscript.cpp | 14 +++--- source/main/utils/InputEngine.cpp | 14 +++--- source/main/utils/InputEngine.h | 2 +- 15 files changed, 80 insertions(+), 75 deletions(-) diff --git a/cmake/DependenciesConfig.cmake b/cmake/DependenciesConfig.cmake index 681eac49c0..14f7acf47c 100644 --- a/cmake/DependenciesConfig.cmake +++ b/cmake/DependenciesConfig.cmake @@ -3,7 +3,7 @@ set(CMAKE_THREAD_PREFER_PTHREAD YES) find_package(Threads REQUIRED) # --- Ogre 3D graphics engine --- -find_package(OGRE 1.13 REQUIRED COMPONENTS Bites Overlay Paging RTShaderSystem MeshLodGenerator Terrain) +find_package(OGRE 14 REQUIRED COMPONENTS Bites Overlay Paging RTShaderSystem MeshLodGenerator Terrain) # --- Object Oriented Input System --- find_package(OIS REQUIRED) diff --git a/conanfile.py b/conanfile.py index 44d0227bcd..b3af039d13 100644 --- a/conanfile.py +++ b/conanfile.py @@ -13,10 +13,10 @@ def requirements(self): self.requires("discord-rpc/3.4.0@anotherfoxguy/stable") self.requires("fmt/8.0.1") self.requires("libcurl/7.79.1") - self.requires("mygui/3.4.0@anotherfoxguy/stable") - self.requires("ogre3d-caelum/0.6.3.1@anotherfoxguy/stable") - self.requires("ogre3d-pagedgeometry/1.2.0@anotherfoxguy/stable") - self.requires("ogre3d/1.11.6.1@anotherfoxguy/stable", force=True) + self.requires("mygui/3.4.3@anotherfoxguy/stable") + self.requires("ogre3d-caelum/2022.08@anotherfoxguy/stable") + self.requires("ogre3d-pagedgeometry/2023.07@anotherfoxguy/stable") + self.requires("ogre3d/14.1.0@anotherfoxguy/stable", force=True) self.requires("ois/1.4.1@rigsofrods/custom") self.requires("openal-soft/1.22.2") self.requires("openssl/1.1.1s", force=True) diff --git a/source/main/Application.h b/source/main/Application.h index 70a85bbb5d..02dcc41742 100644 --- a/source/main/Application.h +++ b/source/main/Application.h @@ -89,6 +89,7 @@ enum MsgType MSG_NET_OPEN_RESOURCE_SUCCESS, //!< Payload = GUI::ResourcesCollection* (owner) MSG_NET_REFRESH_REPOLIST_FAILURE, //!< Payload = RoR::CurlFailInfo* (owner) MSG_NET_REFRESH_AI_PRESETS, + MSG_NET_DOWNLOAD_REPOTHUMB_SUCCESS, //!< Payload = int* (owner) // Simulation MSG_SIM_PAUSE_REQUESTED, MSG_SIM_UNPAUSE_REQUESTED, diff --git a/source/main/gfx/hydrax/GodRaysManager.cpp b/source/main/gfx/hydrax/GodRaysManager.cpp index b59e1937fd..2a529044f3 100644 --- a/source/main/gfx/hydrax/GodRaysManager.cpp +++ b/source/main/gfx/hydrax/GodRaysManager.cpp @@ -132,7 +132,7 @@ namespace Hydrax mManualGodRays->setVisible(mHydrax->_isCurrentFrameUnderwater()); mManualGodRays->begin(_def_GodRays_Material_Name, Ogre::RenderOperation::OT_TRIANGLE_LIST); - mManualGodRays->setRenderQueueGroup(Ogre::RENDER_QUEUE_9+1); + mManualGodRays->setRenderQueueGroup(Ogre::RENDER_QUEUE_8+1); for(int r = 0; r < mNumberOfRays; r++) { diff --git a/source/main/gfx/hydrax/RttManager.cpp b/source/main/gfx/hydrax/RttManager.cpp index 4e10ccbda7..3427d7c065 100644 --- a/source/main/gfx/hydrax/RttManager.cpp +++ b/source/main/gfx/hydrax/RttManager.cpp @@ -504,7 +504,7 @@ namespace Hydrax && mActive) { mRttManager->mHydrax->getCamera()->disableCustomNearClipPlane(); - Ogre::Root::getSingleton().getRenderSystem()->_setProjectionMatrix(mRttManager->mHydrax->getCamera()->getProjectionMatrixRS()); + Ogre::Root::getSingleton().getRenderSystem()->_setProjectionMatrix(mRttManager->mHydrax->getCamera()->getProjectionMatrix()); } } @@ -518,7 +518,7 @@ namespace Hydrax && mActive) { mRttManager->mHydrax->getCamera()->enableCustomNearClipPlane(mRttManager->mPlanes[RTT_REFLECTION]); - Ogre::Root::getSingleton().getRenderSystem()->_setProjectionMatrix(mRttManager->mHydrax->getCamera()->getProjectionMatrixRS()); + Ogre::Root::getSingleton().getRenderSystem()->_setProjectionMatrix(mRttManager->mHydrax->getCamera()->getProjectionMatrix()); } } diff --git a/source/main/gui/GUIUtils.cpp b/source/main/gui/GUIUtils.cpp index afc937b920..cd32edcfad 100644 --- a/source/main/gui/GUIUtils.cpp +++ b/source/main/gui/GUIUtils.cpp @@ -468,7 +468,7 @@ void RoR::ImDrawEventHighlighted(events input_event) } -void RoR::ImDrawModifierKeyHighlighted(OIS::KeyCode key) +void RoR::ImDrawModifierKeyHighlighted(OgreBites::Keycode key) { ImVec4 col = ImGui::GetStyle().Colors[ImGuiCol_Text]; if (App::GetInputEngine()->isKeyDown(key)) diff --git a/source/main/gui/GUIUtils.h b/source/main/gui/GUIUtils.h index 74aac880e9..dcf8a33d0b 100644 --- a/source/main/gui/GUIUtils.h +++ b/source/main/gui/GUIUtils.h @@ -100,6 +100,6 @@ void ImSetNextWindowPosCenter(ImGuiCond c = 0); // Input engine helpers void ImDrawEventHighlighted(events input_event); -void ImDrawModifierKeyHighlighted(OIS::KeyCode key); +void ImDrawModifierKeyHighlighted(OgreBites::Keycode key); } // namespace RoR diff --git a/source/main/gui/panels/GUI_RepositorySelector.cpp b/source/main/gui/panels/GUI_RepositorySelector.cpp index 42502cc401..627a911c58 100644 --- a/source/main/gui/panels/GUI_RepositorySelector.cpp +++ b/source/main/gui/panels/GUI_RepositorySelector.cpp @@ -373,11 +373,6 @@ void DownloadResourceFile(int resource_id, std::string filename, int id) RepositorySelector::RepositorySelector() { - Ogre::WorkQueue* wq = Ogre::Root::getSingleton().getWorkQueue(); - m_ogre_workqueue_channel = wq->getChannel("RoR/RepoThumbnails"); - wq->addRequestHandler(m_ogre_workqueue_channel, this); - wq->addResponseHandler(m_ogre_workqueue_channel, this); - m_fallback_thumbnail = FetchIcon("ror.png"); } @@ -399,11 +394,11 @@ void RepositorySelector::Draw() ImGui::Begin(_LC("RepositorySelector", "Rigs of Rods Repository"), &keep_open, window_flags); - if (m_resource_view && ImGui::ImageButton(reinterpret_cast(tex4->getHandle()), ImVec2(16, 16))) + if (m_resource_view && ImGui::ImageButton("GoBack", reinterpret_cast(tex4->getHandle()), ImVec2(16, 16))) { m_resource_view = false; } - else if (!m_resource_view && ImGui::ImageButton(reinterpret_cast(tex1->getHandle()), ImVec2(16, 16))) + else if (!m_resource_view && ImGui::ImageButton("Refresh", reinterpret_cast(tex1->getHandle()), ImVec2(16, 16))) { this->Refresh(); } @@ -1255,7 +1250,8 @@ void RepositorySelector::SetVisible(bool visible) // -------------------------------------------- // Async thumbnail download via Ogre::WorkQueue -// see https://wiki.ogre3d.org/How+to+use+the+WorkQueue +// NOTE: The API changed in OGRE 14.0 +// see https://github.com/OGRECave/ogre/blob/master/Docs/14-Notes.md#task-based-workqueue void RepositorySelector::DrawThumbnail(int resource_item_idx) { @@ -1289,7 +1285,11 @@ void RepositorySelector::DrawThumbnail(int resource_item_idx) && !m_data.items[resource_item_idx].thumbnail_dl_queued) { // Image is in visible screen area and not yet downloading. - Ogre::Root::getSingleton().getWorkQueue()->addRequest(m_ogre_workqueue_channel, 1234, Ogre::Any(resource_item_idx)); + Ogre::Root::getSingleton().getWorkQueue()->addTask( + [this, resource_item_idx]() + { + this->DownloadThumbnail(resource_item_idx); + }); m_data.items[resource_item_idx].thumbnail_dl_queued = true; } } @@ -1323,20 +1323,19 @@ void RepositorySelector::DrawThumbnail(int resource_item_idx) } } -Ogre::WorkQueue::Response* RepositorySelector::handleRequest(const Ogre::WorkQueue::Request *req, const Ogre::WorkQueue *srcQ) +bool RepositorySelector::DownloadThumbnail(int item_idx) { // This runs on background worker thread in Ogre::WorkQueue's thread pool. // Purpose: to fetch one thumbnail image using CURL. // ----------------------------------------------------------------------- - int item_idx = Ogre::any_cast(req->getData()); std::string filename = std::to_string(m_data.items[item_idx].resource_id) + ".png"; std::string file = PathCombine(App::sys_thumbnails_dir->getStr(), filename); long response_code = 0; if (FileExists(file)) { - return OGRE_NEW Ogre::WorkQueue::Response(req, /*success:*/false, Ogre::Any(item_idx)); + return /*success:*/false; } else { @@ -1360,11 +1359,12 @@ Ogre::WorkQueue::Response* RepositorySelector::handleRequest(const Ogre::WorkQue << "[RoR|Repository] Failed to download thumbnail;" << " Error: '" << curl_easy_strerror(curl_result) << "'; HTTP status code: " << response_code; - return OGRE_NEW Ogre::WorkQueue::Response(req, /*success:*/false, Ogre::Any(item_idx)); + return /*success:*/false; } else { - return OGRE_NEW Ogre::WorkQueue::Response(req, /*success:*/true, Ogre::Any(item_idx)); + App::GetGameContext()->PushMessage(Message(MSG_NET_DOWNLOAD_REPOTHUMB_SUCCESS, new int(item_idx))); + return /*success:*/true; } } catch (Ogre::Exception& oex) @@ -1374,18 +1374,17 @@ Ogre::WorkQueue::Response* RepositorySelector::handleRequest(const Ogre::WorkQue fmt::format("Repository UI: cannot download thumbnail '{}' - {}", m_data.items[item_idx].icon_url, oex.getFullDescription())); - return OGRE_NEW Ogre::WorkQueue::Response(req, /*success:*/false, Ogre::Any(item_idx)); + return /*success:*/false; } } } -void RepositorySelector::handleResponse(const Ogre::WorkQueue::Response *req, const Ogre::WorkQueue *srcQ) +void RepositorySelector::LoadDownloadedThumbnail(int item_idx) { // This runs on main thread. // It's safe to load the texture and modify GUI data. // -------------------------------------------------- - int item_idx = Ogre::any_cast(req->getData()); std::string filename = std::to_string(m_data.items[item_idx].resource_id) + ".png"; std::string file = PathCombine(App::sys_thumbnails_dir->getStr(), filename); diff --git a/source/main/gui/panels/GUI_RepositorySelector.h b/source/main/gui/panels/GUI_RepositorySelector.h index 64e9b2abe8..ce21717bec 100644 --- a/source/main/gui/panels/GUI_RepositorySelector.h +++ b/source/main/gui/panels/GUI_RepositorySelector.h @@ -82,12 +82,9 @@ struct ResourcesCollection std::vector files; }; -class RepositorySelector: - public Ogre::WorkQueue::RequestHandler, // Processes tasks on background thread - public Ogre::WorkQueue::ResponseHandler // Processes task results on rendering thread +class RepositorySelector { public: - const Ogre::uint16 WORKQUEUE_ROR_REPO_THUMBNAIL = 1; // Work queue request type, named by OGRE convention. RepositorySelector(); ~RepositorySelector(); @@ -103,10 +100,8 @@ class RepositorySelector: void UpdateFiles(ResourcesCollection* data); void ShowError(CurlFailInfo* failinfo); void DrawThumbnail(int resource_item_idx); - - /// Ogre::WorkQueue API - virtual Ogre::WorkQueue::Response* handleRequest(const Ogre::WorkQueue::Request *req, const Ogre::WorkQueue *srcQ) override; //!< Processes tasks on background thread - virtual void handleResponse(const Ogre::WorkQueue::Response *req, const Ogre::WorkQueue *srcQ) override; //!< Processes task results on main thread + bool DownloadThumbnail(int item_idx); //!< To be run on background via Ogre WorkQueue + void LoadDownloadedThumbnail(int item_idx); //!< To be run on main thread private: bool m_is_visible = false; diff --git a/source/main/gui/panels/GUI_VehicleButtons.cpp b/source/main/gui/panels/GUI_VehicleButtons.cpp index d619a036b3..4e21b52bf6 100644 --- a/source/main/gui/panels/GUI_VehicleButtons.cpp +++ b/source/main/gui/panels/GUI_VehicleButtons.cpp @@ -166,7 +166,7 @@ void VehicleButtons::DrawHeadLightButton(RoR::GfxActor* actorx) ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_Button]); } - if (ImGui::ImageButton(reinterpret_cast(m_headlight_icon->getHandle()), ImVec2(24, 24))) + if (ImGui::ImageButton("HeadLight", reinterpret_cast(m_headlight_icon->getHandle()), ImVec2(24, 24))) { actorx->GetActor()->toggleHeadlights(); } @@ -214,7 +214,7 @@ void VehicleButtons::DrawLeftBlinkerButton(RoR::GfxActor* actorx) ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_Button]); } - if (ImGui::ImageButton(reinterpret_cast(m_left_blinker_icon->getHandle()), ImVec2(24, 24))) + if (ImGui::ImageButton("LeftBlinker", reinterpret_cast(m_left_blinker_icon->getHandle()), ImVec2(24, 24))) { actorx->GetActor()->toggleBlinkType(BLINK_LEFT); } @@ -262,7 +262,7 @@ void VehicleButtons::DrawRightBlinkerButton(RoR::GfxActor* actorx) ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_Button]); } - if (ImGui::ImageButton(reinterpret_cast(m_right_blinker_icon->getHandle()), ImVec2(24, 24))) + if (ImGui::ImageButton("RightBlinker", reinterpret_cast(m_right_blinker_icon->getHandle()), ImVec2(24, 24))) { actorx->GetActor()->toggleBlinkType(BLINK_RIGHT); } @@ -310,7 +310,7 @@ void VehicleButtons::DrawWarnBlinkerButton(RoR::GfxActor* actorx) ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_Button]); } - if (ImGui::ImageButton(reinterpret_cast(m_warning_light_icon->getHandle()), ImVec2(24, 24))) + if (ImGui::ImageButton("WarnBlinker", reinterpret_cast(m_warning_light_icon->getHandle()), ImVec2(24, 24))) { actorx->GetActor()->toggleBlinkType(BLINK_WARN); } @@ -351,7 +351,7 @@ void VehicleButtons::DrawHornButton(RoR::GfxActor* actorx) if (actorx->GetActor()->ar_is_police) // Police siren { - if (ImGui::ImageButton(reinterpret_cast(m_horn_icon->getHandle()), ImVec2(24, 24))) + if (ImGui::ImageButton("PoliceSiren", reinterpret_cast(m_horn_icon->getHandle()), ImVec2(24, 24))) { SOUND_TOGGLE(actorx->GetActor(), SS_TRIG_HORN); } @@ -360,7 +360,7 @@ void VehicleButtons::DrawHornButton(RoR::GfxActor* actorx) { // Triggering continuous command every frame is sloppy // Set state and read it in GameContext via GetHornButtonState() - ImGui::ImageButton(reinterpret_cast(m_horn_icon->getHandle()), ImVec2(24, 24)); + ImGui::ImageButton("Horn", reinterpret_cast(m_horn_icon->getHandle()), ImVec2(24, 24)); if (ImGui::IsItemActive()) { m_horn = true; @@ -405,7 +405,7 @@ void VehicleButtons::DrawMirrorButton(RoR::GfxActor* actorx) ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_Button]); } - if (ImGui::ImageButton(reinterpret_cast(m_mirror_icon->getHandle()), ImVec2(24, 24))) + if (ImGui::ImageButton("Mirror", reinterpret_cast(m_mirror_icon->getHandle()), ImVec2(24, 24))) { if (actorx->GetVideoCamState() == VideoCamState::VCSTATE_DISABLED) { @@ -446,7 +446,7 @@ void VehicleButtons::DrawRepairButton(RoR::GfxActor* actorx) ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_Button]); } - if (ImGui::ImageButton(reinterpret_cast(m_repair_icon->getHandle()), ImVec2(24, 24))) + if (ImGui::ImageButton("Repair",reinterpret_cast(m_repair_icon->getHandle()), ImVec2(24, 24))) { ActorModifyRequest* rq = new ActorModifyRequest; rq->amr_actor = actorx->GetActor()->ar_instance_id; @@ -480,7 +480,7 @@ void VehicleButtons::DrawParkingBrakeButton(RoR::GfxActor* actorx) ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_Button]); } - if (ImGui::ImageButton(reinterpret_cast(m_parking_brake_icon->getHandle()), ImVec2(24, 24))) + if (ImGui::ImageButton("ParkingBrake", reinterpret_cast(m_parking_brake_icon->getHandle()), ImVec2(24, 24))) { actorx->GetActor()->parkingbrakeToggle(); } @@ -519,7 +519,7 @@ void VehicleButtons::DrawTractionControlButton(RoR::GfxActor* actorx) ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_Button]); } - if (ImGui::ImageButton(reinterpret_cast(m_traction_control_icon->getHandle()), ImVec2(24, 24))) + if (ImGui::ImageButton("TractionControl", reinterpret_cast(m_traction_control_icon->getHandle()), ImVec2(24, 24))) { actorx->GetActor()->tractioncontrolToggle(); } @@ -558,7 +558,7 @@ void VehicleButtons::DrawAbsButton(RoR::GfxActor* actorx) ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_Button]); } - if (ImGui::ImageButton(reinterpret_cast(m_abs_icon->getHandle()), ImVec2(24, 24))) + if (ImGui::ImageButton("ABS", reinterpret_cast(m_abs_icon->getHandle()), ImVec2(24, 24))) { actorx->GetActor()->antilockbrakeToggle(); } @@ -592,7 +592,7 @@ void VehicleButtons::DrawPhysicsButton() ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_Button]); } - if (ImGui::ImageButton(reinterpret_cast(m_physics_icon->getHandle()), ImVec2(24, 24))) + if (ImGui::ImageButton("Physics", reinterpret_cast(m_physics_icon->getHandle()), ImVec2(24, 24))) { if (App::GetGameContext()->GetActorManager()->IsSimulationPaused()) { @@ -625,7 +625,7 @@ void VehicleButtons::DrawActorPhysicsButton(RoR::GfxActor* actorx) ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_Button]); } - if (ImGui::ImageButton(reinterpret_cast(m_actor_physics_icon->getHandle()), ImVec2(24, 24))) + if (ImGui::ImageButton("ActorPhysics", reinterpret_cast(m_actor_physics_icon->getHandle()), ImVec2(24, 24))) { // NOTE: Syncing with linked actors is done in `SyncLinkedActors()` actorx->GetActor()->ar_physics_paused = !actorx->GetActor()->ar_physics_paused; @@ -657,7 +657,7 @@ void VehicleButtons::DrawAxleDiffButton(RoR::GfxActor* actorx) ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_Button]); } - if (ImGui::ImageButton(reinterpret_cast(m_a_icon->getHandle()), ImVec2(24, 24))) + if (ImGui::ImageButton("AxleDiff", reinterpret_cast(m_a_icon->getHandle()), ImVec2(24, 24))) { actorx->GetActor()->toggleAxleDiffMode(); actorx->GetActor()->displayAxleDiffMode(); @@ -697,7 +697,7 @@ void VehicleButtons::DrawWheelDiffButton(RoR::GfxActor* actorx) ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_Button]); } - if (ImGui::ImageButton(reinterpret_cast(m_w_icon->getHandle()), ImVec2(24, 24))) + if (ImGui::ImageButton("WheelDiff", reinterpret_cast(m_w_icon->getHandle()), ImVec2(24, 24))) { actorx->GetActor()->toggleWheelDiffMode(); actorx->GetActor()->displayWheelDiffMode(); @@ -738,7 +738,7 @@ void VehicleButtons::DrawTransferCaseModeButton(RoR::GfxActor* actorx) ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_Button]); } - if (ImGui::ImageButton(reinterpret_cast(m_m_icon->getHandle()), ImVec2(24, 24))) + if (ImGui::ImageButton("TransferCase", reinterpret_cast(m_m_icon->getHandle()), ImVec2(24, 24))) { actorx->GetActor()->toggleTransferCaseMode(); actorx->GetActor()->displayTransferCaseMode(); @@ -780,7 +780,7 @@ void VehicleButtons::DrawTransferCaseGearRatioButton(RoR::GfxActor* actorx) ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_Button]); } - if (ImGui::ImageButton(reinterpret_cast(m_g_icon->getHandle()), ImVec2(24, 24))) + if (ImGui::ImageButton("GearRatio", reinterpret_cast(m_g_icon->getHandle()), ImVec2(24, 24))) { actorx->GetActor()->toggleTransferCaseGearRatio(); actorx->GetActor()->displayTransferCaseMode(); @@ -821,7 +821,7 @@ void VehicleButtons::DrawParticlesButton(RoR::GfxActor* actorx) ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_Button]); } - if (ImGui::ImageButton(reinterpret_cast(m_particle_icon->getHandle()), ImVec2(24, 24))) + if (ImGui::ImageButton("Particles", reinterpret_cast(m_particle_icon->getHandle()), ImVec2(24, 24))) { actorx->GetActor()->toggleCustomParticles(); } @@ -869,7 +869,7 @@ void VehicleButtons::DrawBeaconButton(RoR::GfxActor* actorx) ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_Button]); } - if (ImGui::ImageButton(reinterpret_cast(m_beacons_icon->getHandle()), ImVec2(24, 24))) + if (ImGui::ImageButton("Beacons", reinterpret_cast(m_beacons_icon->getHandle()), ImVec2(24, 24))) { actorx->GetActor()->beaconsToggle(); } @@ -908,7 +908,7 @@ void VehicleButtons::DrawShiftModeButton(RoR::GfxActor* actorx) ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_Button]); } - if (ImGui::ImageButton(reinterpret_cast(m_shift_icon->getHandle()), ImVec2(24, 24))) + if (ImGui::ImageButton("ShiftMode", reinterpret_cast(m_shift_icon->getHandle()), ImVec2(24, 24))) { if (actorx->GetActor()->ar_engine) { @@ -996,7 +996,7 @@ void VehicleButtons::DrawEngineButton(RoR::GfxActor* actorx) ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_Button]); } - if (ImGui::ImageButton(reinterpret_cast(m_engine_icon->getHandle()), ImVec2(24, 24))) + if (ImGui::ImageButton("Engine", reinterpret_cast(m_engine_icon->getHandle()), ImVec2(24, 24))) { if (actorx->GetActor()->ar_engine && actorx->GetActor()->ar_engine->isRunning()) { @@ -1145,7 +1145,7 @@ void VehicleButtons::DrawCommandButton(RoR::GfxActor* actorx) void VehicleButtons::DrawCameraButton() { - if (ImGui::ImageButton(reinterpret_cast(m_camera_icon->getHandle()), ImVec2(24, 24))) + if (ImGui::ImageButton("Camera", reinterpret_cast(m_camera_icon->getHandle()), ImVec2(24, 24))) { if (App::GetCameraManager()->EvaluateSwitchBehavior()) { @@ -1176,7 +1176,7 @@ void VehicleButtons::DrawLockButton(RoR::GfxActor* actorx) ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_Button]); } - if (ImGui::ImageButton(reinterpret_cast(m_lock_icon->getHandle()), ImVec2(24, 24))) + if (ImGui::ImageButton("Lock", reinterpret_cast(m_lock_icon->getHandle()), ImVec2(24, 24))) { //actorx->GetActor()->hookToggle(-1, HOOK_TOGGLE, -1); ActorLinkingRequest* hook_rq = new ActorLinkingRequest(); @@ -1226,7 +1226,7 @@ void VehicleButtons::DrawSecureButton(RoR::GfxActor* actorx) ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_Button]); } - if (ImGui::ImageButton(reinterpret_cast(m_secure_icon->getHandle()), ImVec2(24, 24))) + if (ImGui::ImageButton("Secure", reinterpret_cast(m_secure_icon->getHandle()), ImVec2(24, 24))) { actorx->GetActor()->ar_toggle_ties = true; } @@ -1265,7 +1265,7 @@ void VehicleButtons::DrawCruiseControlButton(RoR::GfxActor* actorx) ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_Button]); } - if (ImGui::ImageButton(reinterpret_cast(m_cruise_control_icon->getHandle()), ImVec2(24, 24))) + if (ImGui::ImageButton("CruiseControl", reinterpret_cast(m_cruise_control_icon->getHandle()), ImVec2(24, 24))) { actorx->GetActor()->cruisecontrolToggle(); } diff --git a/source/main/main.cpp b/source/main/main.cpp index 9ec4f9a5aa..8322019c64 100644 --- a/source/main/main.cpp +++ b/source/main/main.cpp @@ -550,6 +550,14 @@ int main(int argc, char *argv[]) App::GetGuiManager()->TopMenubar.Refresh(m.description); break; + case MSG_NET_DOWNLOAD_REPOTHUMB_SUCCESS: + { + int* itemidx_ptr = static_cast(m.payload); + App::GetGuiManager()->RepositorySelector.LoadDownloadedThumbnail(*itemidx_ptr); + delete itemidx_ptr; + break; + } + // -- Gameplay events -- case MSG_SIM_PAUSE_REQUESTED: diff --git a/source/main/physics/collision/PointColDetector.h b/source/main/physics/collision/PointColDetector.h index a352eb0f30..0b54a2814f 100644 --- a/source/main/physics/collision/PointColDetector.h +++ b/source/main/physics/collision/PointColDetector.h @@ -21,6 +21,8 @@ #include "Application.h" +#include + namespace RoR { /// @addtogroup Physics diff --git a/source/main/scripting/bindings/ImGuiAngelscript.cpp b/source/main/scripting/bindings/ImGuiAngelscript.cpp index 695407b994..d43277ca41 100644 --- a/source/main/scripting/bindings/ImGuiAngelscript.cpp +++ b/source/main/scripting/bindings/ImGuiAngelscript.cpp @@ -461,7 +461,7 @@ void RoR::RegisterImGuiBindings(AngelScript::asIScriptEngine* engine) engine->RegisterGlobalFunction("vector2 GetItemRectMin()", asFUNCTIONPR([]() { auto v = ImGui::GetItemRectMin(); return Vector2(v.x, v.y); }, (), Vector2), asCALL_CDECL); engine->RegisterGlobalFunction("vector2 GetItemRectMax()", asFUNCTIONPR([]() { auto v = ImGui::GetItemRectMax(); return Vector2(v.x, v.y); }, (), Vector2), asCALL_CDECL); engine->RegisterGlobalFunction("vector2 GetItemRectSize()", asFUNCTIONPR([]() { auto v = ImGui::GetItemRectSize(); return Vector2(v.x, v.y); }, (), Vector2), asCALL_CDECL); - engine->RegisterGlobalFunction("void SetItemAllowOverlap()", asFUNCTIONPR([]() { ImGui::SetItemAllowOverlap(); }, (), void), asCALL_CDECL); + //REMOVED FROM DearIMGUI engine->RegisterGlobalFunction("void SetItemAllowOverlap()", asFUNCTIONPR([]() { ImGui::SetItemAllowOverlap(); }, (), void), asCALL_CDECL); engine->RegisterGlobalFunction("bool IsWindowFocused(int = 0)", asFUNCTIONPR([](int a) { return ImGui::IsWindowFocused(); }, (int), bool), asCALL_CDECL); // TODO: update imgui -- flags omitted engine->RegisterGlobalFunction("bool IsWindowHovered(int = 0)", asFUNCTIONPR([](int a) { return ImGui::IsWindowHovered(); }, (int), bool), asCALL_CDECL); // TODO: update imgui -- flags omitted engine->RegisterGlobalFunction("bool IsRectVisible(const vector2&)", asFUNCTIONPR([](const Vector2& a) { return ImGui::IsRectVisible(ImVec2(a.x, a.y)); }, (const Vector2&), bool), asCALL_CDECL); @@ -476,10 +476,10 @@ void RoR::RegisterImGuiBindings(AngelScript::asIScriptEngine* engine) return ImGui::BeginChildFrame(a, ImVec2(b.x,b.y), (ImGuiWindowFlags)c); }, (unsigned, const Vector2&, int), bool), asCALL_CDECL); engine->RegisterGlobalFunction("void EndChildFrame()", asFUNCTIONPR([]() { ImGui::EndChildFrame(); }, (), void), asCALL_CDECL); - engine->RegisterGlobalFunction("int GetKeyIndex(int)", asFUNCTIONPR([](int a) { return ImGui::GetKeyIndex((ImGuiKey)a); }, (int), int), asCALL_CDECL); - engine->RegisterGlobalFunction("bool IsKeyDown(int)", asFUNCTIONPR([](int a) { return ImGui::IsKeyDown(a); }, (int), bool), asCALL_CDECL); - engine->RegisterGlobalFunction("bool IsKeyPressed(int, bool = true)", asFUNCTIONPR([](int a, bool b) { return ImGui::IsKeyPressed(a, b); }, (int,bool), bool), asCALL_CDECL); - engine->RegisterGlobalFunction("bool IsKeyReleased(int)", asFUNCTIONPR([](int a) { return ImGui::IsKeyReleased(a); }, (int), bool), asCALL_CDECL); + //OBSOLETE IN DearIMGUI engine->RegisterGlobalFunction("int GetKeyIndex(int)", asFUNCTIONPR([](int a) { return ImGui::GetKeyIndex((ImGuiKey)a); }, (int), int), asCALL_CDECL); + engine->RegisterGlobalFunction("bool IsKeyDown(int)", asFUNCTIONPR([](int a) { return ImGui::IsKeyDown((ImGuiKey)a); }, (int), bool), asCALL_CDECL); + engine->RegisterGlobalFunction("bool IsKeyPressed(int, bool = true)", asFUNCTIONPR([](int a, bool b) { return ImGui::IsKeyPressed((ImGuiKey)a, b); }, (int,bool), bool), asCALL_CDECL); + engine->RegisterGlobalFunction("bool IsKeyReleased(int)", asFUNCTIONPR([](int a) { return ImGui::IsKeyReleased((ImGuiKey)a); }, (int), bool), asCALL_CDECL); /*engine->RegisterGlobalFunction("int GetKeyPressedAmount(int, float, float)", asFUNCTIONPR([](int a, float b, float c) { return ImGui::GetKeyPressedAmount(a, b, c); }, (int,float,float), int), asCALL_CDECL);*/ // FIXME update imgui engine->RegisterGlobalFunction("bool IsMouseDown(int)", asFUNCTIONPR([](int a) { return ImGui::IsMouseDown(a); }, (int), bool), asCALL_CDECL); engine->RegisterGlobalFunction("bool IsMouseClicked(int, bool = false)", asFUNCTIONPR([](int a, bool b) { return ImGui::IsMouseClicked(a, b); }, (int,bool), bool), asCALL_CDECL); @@ -494,8 +494,8 @@ void RoR::RegisterImGuiBindings(AngelScript::asIScriptEngine* engine) engine->RegisterGlobalFunction("void ResetMouseDragDelta(int = 0)", asFUNCTIONPR([](int a) { ImGui::ResetMouseDragDelta(a); }, (int), void), asCALL_CDECL); engine->RegisterGlobalFunction("int GetMouseCursor()", asFUNCTIONPR([]() { return ImGui::GetMouseCursor(); }, (), int), asCALL_CDECL); engine->RegisterGlobalFunction("void SetMouseCursor(int)", asFUNCTIONPR([](ImGuiMouseCursor a) { ImGui::SetMouseCursor(a); }, (int), void), asCALL_CDECL); - engine->RegisterGlobalFunction("void CaptureKeyboardFromApp(bool = true)", asFUNCTIONPR([](bool a) { ImGui::CaptureKeyboardFromApp(a); }, (bool), void), asCALL_CDECL); - engine->RegisterGlobalFunction("void CaptureMouseFromApp(bool = true)", asFUNCTIONPR([](bool a) { ImGui::CaptureMouseFromApp(a); }, (bool), void), asCALL_CDECL); + //REMOVED FROM DearIMGUI engine->RegisterGlobalFunction("void CaptureKeyboardFromApp(bool = true)", asFUNCTIONPR([](bool a) { ImGui::CaptureKeyboardFromApp(a); }, (bool), void), asCALL_CDECL); + //REMOVED FROM DearIMGUI engine->RegisterGlobalFunction("void CaptureMouseFromApp(bool = true)", asFUNCTIONPR([](bool a) { ImGui::CaptureMouseFromApp(a); }, (bool), void), asCALL_CDECL); engine->RegisterGlobalFunction("string GetClipboardText()", asFUNCTIONPR([]() { return string(ImGui::GetClipboardText()); }, (), string), asCALL_CDECL); diff --git a/source/main/utils/InputEngine.cpp b/source/main/utils/InputEngine.cpp index 701ce80576..eaa0741cca 100644 --- a/source/main/utils/InputEngine.cpp +++ b/source/main/utils/InputEngine.cpp @@ -1957,17 +1957,17 @@ String InputEngine::getKeyForCommand(int eventID) return this->getKeyNameForKeyCode(it->second.front().keyCode); } -Ogre::String InputEngine::getModifierKeyName(OIS::KeyCode key) +Ogre::String InputEngine::getModifierKeyName(OgreBites::Keycode key) { switch (key) { - case OIS::KC_LMENU: return _LC("ModifierKey", "Left Alt"); - case OIS::KC_LSHIFT: return _LC("ModifierKey", "Left Shift"); - case OIS::KC_LCONTROL: return _LC("ModifierKey", "Left Ctrl"); + case SDLK_LALT: return _LC("ModifierKey", "Left Alt"); + case SDLK_LSHIFT: return _LC("ModifierKey", "Left Shift"); + case SDLK_LCTRL: return _LC("ModifierKey", "Left Ctrl"); - case OIS::KC_RMENU: return _LC("ModifierKey", "Right Alt"); - case OIS::KC_RSHIFT: return _LC("ModifierKey", "Right Shift"); - case OIS::KC_RCONTROL: return _LC("ModifierKey", "Right Ctrl"); + case SDLK_RALT: return _LC("ModifierKey", "Right Alt"); + case SDLK_RSHIFT: return _LC("ModifierKey", "Right Shift"); + case SDLK_RCTRL: return _LC("ModifierKey", "Right Ctrl"); default: return ""; } diff --git a/source/main/utils/InputEngine.h b/source/main/utils/InputEngine.h index 1812831b4d..47ebb8b25b 100644 --- a/source/main/utils/InputEngine.h +++ b/source/main/utils/InputEngine.h @@ -473,7 +473,7 @@ class InputEngine // Event info Ogre::String getKeyForCommand(int eventID); - Ogre::String getModifierKeyName(OIS::KeyCode key); + Ogre::String getModifierKeyName(OgreBites::Keycode key); Ogre::String getDeviceName(event_trigger_t const& evt); Ogre::String getEventCommand(int eventID); std::string getEventCommandTrimmed(int eventID); //!< Omits 'EXPL' modifier