Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

PNGTuber Plus

Get more out of your png tubing experience. · By kaiakairos

File Manager on Linux and possible problem on Mac too

A topic by NeoMyo created Oct 19, 2023 Views: 245 Replies: 3
Viewing posts 1 to 2
(2 edits)

I've wanted to use this for my streams, but the client file manager cant access my local files, haven't tested more since the file manager is one of the core features to have, I've made some research and found this using ChatGPT, seems like in Godot there's a node called OS, making it useful for system wide compatibility with file managers or windows, here's an example: "

gdscriptCopy code
extends Node  
func _ready():
     if OS.has_feature(OS.SYS_X11):
         # Check if the OS is Linux/X11
          # Replace this with the directory or file path you want to open.
         var path_to_open = "/path/to/your/directory_or_file"
          # Open the file or directory with the system's default file manager
         OS.shell_open(path_to_open)
     else:
         print("Operating system not supported for this feature.")

"
This checks what system is from the supported list and opens a file using the default file manager, there has to be some testing so it works so I would recommend to have a linux Virtual Machine to do linux testing, that or see if you can get a linux machine, just get a thinkpad and install kde neon or Debian on it, should be good to go with that. 

Good luck, and ask me anything linux related if you're lost, I think I can help you, that or I'll ask on the forums too, idk

Edit: You might want to add an "assets" folder on the zip with the respective subfolders so people can just add their PNGs there instead of SOMEWHERE IN THE PC, that way you can just add on your client file manager to search in that folder first but still have the option to manually add the files.

Also, for drag and drop you might want to see this:

To add drag-and-drop functionality to your Godot application that is compatible with Linux, you can use the built-in InputEvent system in Godot. Here's a step-by-step guide on how to implement drag-and-drop:

  1. Detect Mouse Events:

    You'll need to detect mouse events to initiate and handle the drag-and-drop action. You can do this in your game scene or any relevant script.

    gdscriptCopy code
    func _input(event):
         if event is InputEventMouseButton:
             if event.pressed:
                 # Mouse button pressed, start dragging
                 start_drag(event.position)
             elif event.button_index == BUTTON_LEFT and dragging:
                 # Mouse button released, stop dragging
                 stop_drag()
    
  2. Implement Drag-and-Drop Methods:

    Next, you'll need to implement the start_drag and stop_drag methods. The start_drag method stores the initial mouse position and the object being dragged, while the stop_drag method clears the stored data.

    gdscriptCopy code
    var dragging = false
    var drag_data = {}
    func start_drag(position):
         if not dragging:
             dragging = true
             drag_data.start_pos = position
             drag_data.dragged_object = get_object_to_drag()  # Implement this function to get the object you want to drag
             drag_data.drag_offset = drag_data.dragged_object.global_position - position  
    func stop_drag():
         if dragging:
             dragging = false
             drag_data = {}
    
  3. Handle Dragging:

    While dragging, you can update the position of the object being dragged based on the mouse movement. This allows the object to follow the mouse cursor.

    gdscriptCopy code
    func _process(delta):
         if dragging:
             drag_data.dragged_object.global_position = get_global_mouse_position() + drag_data.drag_offset 
    
  4. Drop Target:

    Define a drop target where you want to drop the dragged object. For example, if you want to drop it on another object, you can check for collisions or overlaps.

    gdscriptCopy code
    func _on_DropArea_area_entered(area):
         if dragging:
             var dropped_object = drag_data.dragged_object
             # Implement any additional logic to handle the drop, e.g., attaching it to the drop target.
             area.add_child(dropped_object)
             stop_drag()
    
  5. Linux Compatibility:

    Godot's input handling should work on Linux as it does on other platforms. Ensure that you've configured your Godot project to export to Linux if you plan to use this application on Linux.

By following these steps, you can add drag-and-drop functionality to your Godot application that's compatible with Linux. Make sure to customize the code to fit your specific use case, including the object you want to drag and the behavior you want when dropping it on a target. "

Its a handful, but yeah, also, chatgpt is gonna be your friend if you want to make things easier, finding this stuff is hard.

Developer

yeah i already have this implemented 

(1 edit)

Yet it doesn't work on linux, which is the main problem: (I'm using KDE Neon, a system based on ubuntu)

Developer (1 edit)

it does, you just can’t drag images into the program. You can’t do that on the windows version either. Hit the Escape key to open the folder. 


also the code you sent is just. Not accurate to godot at all. Don’t use ChatGPT to tell me how to do my job dumbass