Skip to content

Commit

Permalink
Ensure a minimum texture size when icon is not ready
Browse files Browse the repository at this point in the history
  • Loading branch information
rsubtil committed Aug 15, 2024
1 parent a7a7596 commit bd83390
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions addons/controller_icons/objects/ControllerIconTexture.gd
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ func _on_input_type_changed(input_type: int, controller: int):
_load_texture_path()

#region "Draw functions"
const _NULL_SIZE := 2

func _get_width() -> int:
if _can_be_shown():
Expand All @@ -195,8 +196,10 @@ func _get_width() -> int:
, 0)
if _label_settings:
ret += max(0, _textures.size()-1) * _text_size.x
return ret
return 2
# If ret is 0, return a size of 2 to prevent triggering engine checks
# for null sizes. The correct size will be set at a later frame.
return ret if ret > 0 else _NULL_SIZE
return _NULL_SIZE

func _get_height() -> int:
if _can_be_shown():
Expand All @@ -207,8 +210,10 @@ func _get_height() -> int:
, 0)
if _label_settings and _textures.size() > 1:
ret = max(ret, _text_size.y)
return ret
return 2
# If ret is 0, return a size of 2 to prevent triggering engine checks
# for null sizes. The correct size will be set at a later frame.
return ret if ret > 0 else _NULL_SIZE
return _NULL_SIZE

func _has_alpha() -> bool:
return _textures.any(func(texture: Texture2D):
Expand Down

0 comments on commit bd83390

Please sign in to comment.