Fixed button click state not resetting bug #398

Merged
maverickdgg merged 4 commits from SP3-20-UI-System into main 2023-03-05 14:46:18 +08:00
5 changed files with 13 additions and 4 deletions
Showing only changes of commit 4bc568899d - Show all commits

View File

@ -5193,6 +5193,7 @@
Default Texture: 63979907 Default Texture: 63979907
Hovered Texture: 51379325 Hovered Texture: 51379325
Clicked Texture: 66788278 Clicked Texture: 66788278
current texture: 0
IsActive: true IsActive: true
UI Component: UI Component:
Canvas ID: 458 Canvas ID: 458
@ -5226,6 +5227,7 @@
Default Texture: 61602036 Default Texture: 61602036
Hovered Texture: 58910810 Hovered Texture: 58910810
Clicked Texture: 57786063 Clicked Texture: 57786063
current texture: 0
IsActive: true IsActive: true
UI Component: UI Component:
Canvas ID: 458 Canvas ID: 458
@ -5259,6 +5261,7 @@
Default Texture: 64806384 Default Texture: 64806384
Hovered Texture: 58347825 Hovered Texture: 58347825
Clicked Texture: 63234380 Clicked Texture: 63234380
current texture: 0
IsActive: true IsActive: true
UI Component: UI Component:
Canvas ID: 458 Canvas ID: 458

View File

@ -119,7 +119,7 @@ namespace SHADE_Scripting.UI
return; return;
if (tweening == true && thread != null) if (tweening == true && thread != null)
{ {
Debug.Log("Tweening value " + thread.GetValue());
transform.LocalScale = defaultScale * thread.GetValue(); transform.LocalScale = defaultScale * thread.GetValue();
currentScale = thread.GetValue(); currentScale = thread.GetValue();
if (thread.IsCompleted()) if (thread.IsCompleted())

View File

@ -58,6 +58,7 @@ RTTR_REGISTRATION
.property("Default Texture", &SHButtonComponent::GetDefaultTexture, &SHButtonComponent::SetDefaultTexture) .property("Default Texture", &SHButtonComponent::GetDefaultTexture, &SHButtonComponent::SetDefaultTexture)
.property("Hovered Texture", &SHButtonComponent::GetHoveredTexture, &SHButtonComponent::SetHoveredTexture) .property("Hovered Texture", &SHButtonComponent::GetHoveredTexture, &SHButtonComponent::SetHoveredTexture)
.property("Clicked Texture", &SHButtonComponent::GetClickedTexture, &SHButtonComponent::SetClickedTexture) .property("Clicked Texture", &SHButtonComponent::GetClickedTexture, &SHButtonComponent::SetClickedTexture)
.property("current texture", &SHButtonComponent::currentTexture)
; ;

View File

@ -26,7 +26,7 @@ namespace SHADE
void SetHoveredTexture(AssetID texture) noexcept; void SetHoveredTexture(AssetID texture) noexcept;
void SetClickedTexture(AssetID texture) noexcept; void SetClickedTexture(AssetID texture) noexcept;
AssetID currentTexture;
friend class SHUISystem; friend class SHUISystem;
private: private:
@ -35,7 +35,7 @@ namespace SHADE
AssetID hoveredTexture; AssetID hoveredTexture;
AssetID clickedTexture; AssetID clickedTexture;
AssetID currentTexture;
RTTR_ENABLE() RTTR_ENABLE()

View File

@ -263,6 +263,11 @@ namespace SHADE
return true; return true;
} }
//In case the UI was clicked but the mouse is not held down and the key up frame was missed because of active state.
if (comp.isClicked && !SHInputManager::GetKey(SHInputManager::SH_KEYCODE::LMB))
{
comp.isClicked = false;
}
return false; return false;
@ -318,7 +323,7 @@ namespace SHADE
//SHLOG_INFO("SETTING HOVERED TEXTURE") //SHLOG_INFO("SETTING HOVERED TEXTURE")
} }
} }
if (textureID != 0 && textureID != comp.currentTexture) if (textureID != 0)
{ {
auto material = renderable->GetModifiableMaterial(); auto material = renderable->GetModifiableMaterial();
comp.currentTexture = textureID; comp.currentTexture = textureID;