From b8bcf89398572e264eed5f416898d4c1b19f988b Mon Sep 17 00:00:00 2001 From: Alex Uskov Date: Wed, 24 Jul 2024 08:10:30 +0400 Subject: [PATCH] Fix crash on soft restart and improve autonya --- include/ImageView.hpp | 9 ++- include/ModifiersMenu.hpp | 2 +- include/NyaFloatingUI.hpp | 5 +- include/UI/Modals/NSFWConsent.hpp | 24 +++---- qpm.shared.json | 5 +- src/ImageView.cpp | 102 ++++++++++++------------------ src/ModifiersMenu.cpp | 2 +- src/NyaFloatingUI.cpp | 2 +- src/UI/Modals/SettingsMenu.cpp | 6 +- src/main.cpp | 4 +- 10 files changed, 72 insertions(+), 89 deletions(-) diff --git a/include/ImageView.hpp b/include/ImageView.hpp index dc728bc..16acdfb 100644 --- a/include/ImageView.hpp +++ b/include/ImageView.hpp @@ -12,20 +12,24 @@ #include "UnityEngine/Material.hpp" #include -DECLARE_CLASS_CODEGEN(NyaUtils, ImageView, UnityEngine::MonoBehaviour, +DECLARE_CLASS_CODEGEN(Nya, ImageView, UnityEngine::MonoBehaviour, public: std::string lastImageURL; std::string tempName; + // AutoNya + float timeSinceLastNya = 0.0f; + DECLARE_CTOR(ctor); - DECLARE_DTOR(dtor); + DECLARE_SIMPLE_DTOR(); DECLARE_INSTANCE_FIELD(HMUI::ImageView*, imageView); DECLARE_INSTANCE_FIELD(bool, autoNyaRunning); DECLARE_INSTANCE_FIELD(bool, autoNyaNewImage); DECLARE_INSTANCE_FIELD(bool, isLoading); DECLARE_INSTANCE_METHOD(void, Awake); + DECLARE_INSTANCE_METHOD(void, LateUpdate); DECLARE_INSTANCE_METHOD(void, OnEnable); DECLARE_INSTANCE_METHOD(void, OnDisable); DECLARE_INSTANCE_METHOD(void, OnNyaPhysicalClick); @@ -42,7 +46,6 @@ DECLARE_CLASS_CODEGEN(NyaUtils, ImageView, UnityEngine::MonoBehaviour, void SaveImage(); bool HasImageToSave(); void SetErrorImage(); - custom_types::Helpers::Coroutine AutoNyaCoro(); // Event to sub to when image started loading, returns isLoading, meaning that the image is loading UnorderedEventCallback imageLoadingChange; diff --git a/include/ModifiersMenu.hpp b/include/ModifiersMenu.hpp index 46ce709..7200659 100644 --- a/include/ModifiersMenu.hpp +++ b/include/ModifiersMenu.hpp @@ -18,7 +18,7 @@ DECLARE_CLASS_CODEGEN(Nya, ModifiersMenu, UnityEngine::MonoBehaviour, DECLARE_INSTANCE_FIELD(UnityW, NYA); // DECLARE_INSTANCE_FIELD(bool, ); DECLARE_INSTANCE_FIELD(UnityW, nyaButton); - DECLARE_INSTANCE_FIELD(UnityW, imageView); + DECLARE_INSTANCE_FIELD(UnityW, imageView); DECLARE_INSTANCE_FIELD(bool, initialized); diff --git a/include/NyaFloatingUI.hpp b/include/NyaFloatingUI.hpp index 111340a..5eccd49 100644 --- a/include/NyaFloatingUI.hpp +++ b/include/NyaFloatingUI.hpp @@ -16,6 +16,7 @@ #include "UI/Modals/SettingsMenu.hpp" #include "ImageView.hpp" #include "bsml/shared/BSML/FloatingScreen/FloatingScreen.hpp" +#include "bsml/shared/BSML.hpp" using namespace UnityEngine::UI; @@ -34,7 +35,7 @@ DECLARE_CLASS_CODEGEN(Nya, NyaFloatingUI, UnityEngine::MonoBehaviour, void onUnPause(); void onResultsScreenActivate(); void onResultsScreenDeactivate(); - void updateCoordinates(BSML::FloatingScreen* self, const BSML::FloatingScreenHandleEventArgs& args); + void updateCoordinates(UnityW self, const BSML::FloatingScreenHandleEventArgs& args); void updateCoordinates(UnityEngine::Transform* transform); void updateCoordinates(UnityEngine::Vector3 position, UnityEngine::Vector3 eulerRotation); void OnActiveSceneChanged(UnityEngine::SceneManagement::Scene current, UnityEngine::SceneManagement::Scene _); @@ -61,7 +62,7 @@ DECLARE_CLASS_CODEGEN(Nya, NyaFloatingUI, UnityEngine::MonoBehaviour, // NYA DECLARE_INSTANCE_FIELD(UnityW, NYA); - DECLARE_INSTANCE_FIELD(UnityW, imageView); + DECLARE_INSTANCE_FIELD(UnityW, imageView); DECLARE_INSTANCE_FIELD(UnityW, plane); DECLARE_INSTANCE_FIELD(UnityW, nyaButton); diff --git a/include/UI/Modals/NSFWConsent.hpp b/include/UI/Modals/NSFWConsent.hpp index 557f795..e1d0b36 100644 --- a/include/UI/Modals/NSFWConsent.hpp +++ b/include/UI/Modals/NSFWConsent.hpp @@ -53,23 +53,23 @@ DECLARE_CLASS_CODEGEN(Nya::UI::Modals, NSFWConsent, UnityEngine::MonoBehaviour, DECLARE_INSTANCE_METHOD(bool, isShown ); // // Settings buttons and modal - DECLARE_INSTANCE_FIELD(BSML::ModalView*, modal); + DECLARE_INSTANCE_FIELD(UnityW, modal); - DECLARE_INSTANCE_FIELD(VerticalLayoutGroup *, mainLayout); - DECLARE_INSTANCE_FIELD(HorizontalLayoutGroup *, hornyPastryPufferLayout); + DECLARE_INSTANCE_FIELD(UnityW, mainLayout); + DECLARE_INSTANCE_FIELD(UnityW, hornyPastryPufferLayout); - DECLARE_INSTANCE_FIELD(HorizontalLayoutGroup *, buttonsLayout); - DECLARE_INSTANCE_FIELD(HorizontalLayoutGroup *, sliderLayout); + DECLARE_INSTANCE_FIELD(UnityW, buttonsLayout); + DECLARE_INSTANCE_FIELD(UnityW, sliderLayout); - DECLARE_INSTANCE_FIELD(TextMeshProUGUI *, topText); - DECLARE_INSTANCE_FIELD(TextMeshProUGUI *, midText); - DECLARE_INSTANCE_FIELD(ImageView *, midImage); + DECLARE_INSTANCE_FIELD(UnityW, topText); + DECLARE_INSTANCE_FIELD(UnityW, midText); + DECLARE_INSTANCE_FIELD(UnityW, midImage); - DECLARE_INSTANCE_FIELD(Button *, noButton); - DECLARE_INSTANCE_FIELD(Button *, yesButton); + DECLARE_INSTANCE_FIELD(UnityW