Use this space for questions related to what you're learning. For any other type of support (website, learning platform, payments, etc...) please get in touch using the contact form.
Blueprint inventory/world size when hovering over quickbarmoashourI had an issue where when you hover over the quickbar with a selected (mouse-owned) blueprint, the blueprint displays its world state/size, not the inventory's. I fixed it using the following:
\`\`\`
\# In GUI.gd
func _process(_delta: float) -> void:
var mouse_position := get_global_mouse_position()
mouse_in_gui = (
(is_open and _gui_rect.get_global_rect().has_point(mouse_position))
or quickbar.get_global_rect().has_point(mouse_position)
)
\`\`\`
Notice that I'm using get_global_rect() not get_rect(). This is because while _gui.get_rect() and _gui.get_global_rect() are equivalent, their quickbar counterparts are not.
_gui refers to the outer HBoxContainer which happens to take up the whole viewport. The quickbar doesn't, of course. And get_rect() returns a the rectangle _relative to the control node's parent_. The mouse position, however, is the _global position_, relative to the whole viewport. So quickbar.get_rect().has_point(mouse_position) would be off here. quickbar.get_global_rect().has_point(mouse_position) seems to get the job done just fine, however. 10Jun. 16, 2023
Quickbar out of viewportandreasvolzIf you size the viewport to small the hard coded margin_top=900 forces the quickbar out of the window. I suggest in GUI.gd _process():
var height = int(get_viewport().size.y)
quickbar_container.add_constant_override("margin_top", height - 200) 10Apr. 09, 2023
blueprint snapped to the grid of the quickbarandreasvolzThere is a bug that the blueprint doesn't snap to the grid of the quickbar when moving over it. This might be a fix for it in GUI.gd:
func _process(delta: float) -> void:
var mouse_position := get_global_mouse_position()
\# if the mouse is inside the GUI rect and the GUI is open, set it true.
mouse_in_gui = (is_open and _gui_rect.get_rect().has_point(mouse_position)) or (not is_open and quickbar_container.get_rect().has_point(mouse_position))
20Apr. 06, 2023
Calling a private method from another scriptJJWhen adding the keyboard shortcuts for the quick-bar, there is this code in GUI.gd
```gdscript
func _simulate_input(panel: InventoryPanel) -> void:
var input := InputEventMouseButton.new()
input.button_index = MOUSE_BUTTON_LEFT
input.pressed = true
panel._gui_input(input)
```
In the last line, it is calling a private method from InventoryPanel.gd, isn't that something we should avoid? 20Mar. 22, 2023
Typo with the first scene name, QuickbarInventoryPanel should be QuickBarInventoryPanelJJMissing the capital B 10Mar. 22, 2023
Little bugMathieu01I opened the inventory, clicked on a blueprint, maintained one of the quickbar button and I saw it going instantly from the mouse position to the quickbar panel.
The problem comes from here:
```gdscript
if InputMap.event_is_action(event, QUICKBAR_ACTIONS[i]) and event.is_pressed():
```
I don't know why but when I replace it by that, that solve it.
```gdscript
if InputMap.event_is_action(event, QUICKBAR_ACTIONS[i]) and event.is_action_pressed(QUICKBAR_ACTIONS[i]):
```
I don't know if it is the right thing to do. Maybe there's another way.
I want some explanation.20Mar. 04, 2021
Wrong display of the blueprints in the quickbarbenjamin-audrenHi,
I'm not sure what I got wrong, but in my setup, when trying to dock blueprints in the sidebar (when the inventory is closed), I get the same bug that we had earlier on the inventory, meaning that the blueprints are offset and the wrong size.
Somehow the "mouse_in_gui" variable does not work as expected for this. I think the fix would be to change
```gdscript
mouse_in_gui = _is_open and _gui_rect.get_rect().has_point(mouse_position)
```
```gdscript
mouse_in_gui = _is_open and _gui_rect.get_rect().has_point(mouse_position) or quickbar_container.get_rect().has_point(mouse_position)
```20Feb. 23, 2021
Lesson Q&A
Use this space for questions related to what you're learning. For any other type of support (website, learning platform, payments, etc...) please get in touch using the contact form.