Input

Mouse

  • Changing cursors .

    • Great video.

    • {2:33}

      • At the end of the video he shows how to change the cursor depending on context, adding variations to the cursor.

    • About cursor scale problem:

      • "I pre-rendered the cursor at integer multiples of the base resolution (640x360 in my case) and then at runtime call "OS.window_size" to see what resolution the game is running at (works for both windowed and fullscreen despite the name) and then pick the cursor that is the closest multiple from the base resolution. Not perfect for screens with odd resolutions, but can cover the most common sizes since 640x360 is a perfect multiple of 720, 1080, 1440, and 4k".

Inventory

  • Without grid:

    • Inventory using Resources .

    • 3D Inventory .

      • Creates a fairly complete inventory.

      • The video author explains poorly and is dull, but created okay systems.

      • I have some random criticisms, but I'm too lazy to explain.

    • Inventory .

      • Bad video, ted-talk style, with a lot of useless content and a confusing system.

  • Grid:

    • Grid inventory, in Unity .

      • It's a very slow tutorial and there is no initial clarification about what is being done. The rest of the video is better.

      • Watch the video from {51:00}.

      • System:

        • Grid / "Slot":

          • The grid visuals are separated from the grid functionality. "Slots" are not used.

          • The 'visual grid' is defined as a stretched tile texture with 'texture repeat' enabled; so it's just a background texture.

          • The 'logical grid' is defined as segmentation of the texture region, using a 'cell_size'.

        • Items:

          • Item placement is done by placing an "item" in an arbitrary region of space within the region defined by the grid. Everything is loose, but it tries to maintain the pseudo-segmentation generated by 'cell_size'.

          • {23:30}

            • Item definition.

        • "scans the grid and marks all slots as occupied".

        • The item's "origin" is stored, so when clicking an occupied tile, the 'grab' is done from that 'origin'.

    • Grid inventory .

      • It's a very long video with questionable dynamic-typed code.

      • System:

        • The grid is built by instancing many "Slot" scenes.

        • A Slot is defined as a Control.

        • Each item is defined as a Node2D, which is odd.

        • "scans the grid and marks all slots as occupied".

      • The video and method are very questionable.

    • Grid inventory, in Flutter .

      • Does not support:

        • Rotation.

        • Placing an item outside the predefined grid.

        • Scroll.

        • Swap items by clicking on top of an item exists.

      • System:

        • Very simple.

      • Not recommended, because it's not in Godot and lacks clarity.

    • Grid inventory .

      • Old video with poor Godot programming.

      • System:

        • The grid is built using a procedural rectangle, disconnected from visuals (as I recall).

        • {16:00} "scans the grid and marks all slots as occupied".

    • Grid inventory .

      • An "inventory manager" is created without using Godot's drag-and-drop functions.

      • Uses very poor code.

      • The video is completely irrelevant and very long.

    • Grid inventory .

      • Just a devlog with no explanation. The shown code is terribly disorganized and very poor.

    • Grid inventory .

      • Just a showcase. The system looks flawed.

    • Grid inventory .

      • Terrible video.

    • Inspirations:

  • Tooltip for items using Godot 4 Popup .

Drag

  • It is not possible to use the function set_drag_preview()  if a "drag" defined by Godot is not being performed.

    • In the example below, the server asks the client to perform a drag, but this cannot be executed by the client since it is not performing the native Godot drag.

    @rpc
    func _request_set_preview(slot_com_item_path : NodePath) -> void:
        var slot_com_item : Slot = get_node(slot_com_item_path)
        if not slot_com_item:
            return
        var preview : ItemPreview = _PREVIEW_SCENE.instantiate()
        preview.set_textura(slot_com_item.get_item().textura, slot_com_item.get_item().tamanho)
        set_drag_preview(preview)
    
  • Drag: Built-in 'Drag and Drop' functions .

    • Godot 4.x: _get_drag_data(), _can_drop_data(), _drop_data().

  • Drag: Differences between drag methods using Control Nodes and 2D Nodes .

    • For Control Nodes use the virtual functions '_get_drag_data()', etc.

    • For 2D Nodes ~'something manual is implemented'.