File Dialog failing to work on Build

HaledireHaledire Posts: 31Member
edited August 2 in GUI

Starting to get really discouraged from working with Godot as this is the second project I've worked on that came to a blind failure upon trying to build. But enough of my whining.

I'm making a little dialog reader application. Trying to apply knowledge I've been building up about working with control nodes in godot and making a UI. The project works perfectly fine in the editor, no errors, no particular problems to note. After building the project it just plainly fails to function - no errors, no sensible reason why it might be failing. I've tried seeing if it was the dynamically loaded resources coming to bite me again but it isn't even giving me a sense of that problem (ie: trying to find a file that isn't where it thinks it is).

I am using a FileDialog to open up packed in .txt files in order to load the data and populate the reader. In editor - nothing about seems to pose a problem. Upon build - the Open button seems to absolutely not function. As if the signal completely fails to function.

Is there something I don't know about this node that could cause it to fail? I'm hiding the input portions of the interior vbox to prevent traversing of folders or typing in of other file names, and it doesn't cause any problems in editor.

I have a feeling it might be because I'm using the FileDialog to open up resource files, but if that were the issue why would the list populate? I just don't understand what is going on here. There's no error and there's no response from clicking the Open button (nothing prints to the debug window and it should be printing the path).

I mean - I get I'm not using 'the best application for the job' here, but I'm trying to make tools for people with the Godot engine to try to get a feel for making less-common applications with it and I'm starting to feel like i'm wasting my time.


  • MegalomaniakMegalomaniak Posts: 2,898Admin

    Hard to offer any feedback if we don't get to see any code or anything...

  • HaledireHaledire Posts: 31Member

    Scene tree and File Dialog properties in case something here matters.

    extends VBoxContainer
    var block = preload("res://DialogueBlock.tscn")
    onready var bar = get_parent().get_v_scrollbar()
    var rex =
    var pattern = "(?m)(?:^.*$\\n?){1,3}"   
    onready var dialog = $"../../FileDialog"
    onready var title = $"../../DialogueTitle/Title"
    onready var option = $"../../Panel/MarginContainer/VBoxContainer/Lang"
    onready var actors = $"../../Panel/MarginContainer/VBoxContainer/ActorList/VBoxContainer"
    onready var tree = dialog.get_vbox().get_child(2).get_child(0)
    var current = ""
    var format = "*%s.txt"
    var langs = ['english', 'japanese', 'korean', 'chinesesimplified', 'chinesetraditional']
    var langidx = 0 
    func _ready():
        tree.focus_next = dialog.get_ok().get_path()
        dialog.get_close_button().focus_next = tree.get_path()
        option.connect("item_selected", self, "_change_language")
        for lang in langs.size():
            option.set_item_metadata(lang, format % langs[lang])

    I wound up building almost everything on one script (it's a fairly simple program so there's not a lot of moving parts). As far as I can tell, this is the only part of the code that seems to run. The regex pattern is for splitting up edge cases on the dialogue where it contains more than 3 lines. (I have to come up with a different method fr this anyway).

    func _on_PanelContainer_pressed():
        for child in dialog.get_vbox().get_children():
            if !child is MarginContainer:
                child.visible = false
                child.focus_mode = FOCUS_NONE
        var line = tree.get_item_at_position(Vector2.ZERO)
        while line:
            line.set_text(0, line.get_text(0).trim_suffix('_dialog_%s.txt' % langs[langidx]))
            var character = ''
            var test = line.get_text(0).split('_')
            if test[0] == 'char' and not test[1][0] in ['d', 'f']:
                character = '%s: ' % TranslationServer.translate(test[1])
            line.set_text(0, '%s%s' % [character, TranslationServer.translate(line.get_text(0))])
            line = line.get_next()

    This pops up the FileDialog and changes all of the text from the TreeItems. I decided to use the Translation system as potentially I could switch the language of the program if necessary. I am only working with English in order to associate the name of the file with the name of the contents here.

    This project is setup to work with predefined data pulled from .txt files. I'm working on rebuilding the project to utilize a custom resource rather than trying to create a dictionary from a string pulled from a text file at run time. Mind you - that part of the script is not even reached, which is why I'm not posting it. The FileDialog signal callback just never fires.

    func _on_FileDialog_file_selected(path):
        current = path.get_file().trim_suffix("%s.txt" % langs[langidx])
        get_parent().scroll_vertical = 0
        title.text = path.get_file().trim_suffix("_dialog_%s.txt" % langs[langidx])

    This is supposed to run off of the item_selected signal from the FileDialog. I never get to the point of the FileDialog even printing and it doesn't close and throw an error, so there is nothing beyond this point to really share - it fails before this point.

    By Fail I mean that the Open button does nothing. I can click it, I can double click files. The FileDialog doesn't attempt to close, nor does the print at the start of the callback fire. The Close button is fully functional in closing the FileDialog and I can re-open the dialog, so the project is still in full functioning order. I receive no feedback from the Debug Window about the situation.

    I've made sure that I have included the *.txt files into the export and even looked into the exported file to see that the data in the files is included into it. You can see from the application screenshot it can see the resource folder that holds those files.

    Again, as a reminder - this problem is specific to when I BUILD the project. In editor this program works 100% without issue. I see no reason why between the editor and the BUILD the signal callback would cease to work.

  • HaledireHaledire Posts: 31Member
    edited August 3

    As I can't seem to find another way to post the video of it working.

  • HaledireHaledire Posts: 31Member
    edited August 3

    Updating: I've converted the .txt files to .tres resource files. I've put in a test to tell me if the signal is connected. I've even made _ready() run the connected function to make sure it works.

    'print(dialog,is_connected('file_selected', self, '_on_FileDialog_file_selected'))' prints and returns true
    '_on_FileDialog_file_selected('')' populates the dialog window
    the Open button from FileDialog still doesn't work, but is clearly interact-able.

    STILL - for absolutely no cognitive reason, I can't find why this FileDialog's Open button does not work upon build. I've even tried outright replacing the node with a fresh FileDialog and reconnecting the signal.

    I've even done a minimal reproduction of simply making a file dialog, hiding portions of the dialog, and loading the icon.png file into a TextureRect and it works fine.

    Attaching a minimal reproduction of the problem .

    EDIT: Interesting discovery - it seems that accessing a sub directory of resources is causing the problem. So I guess I can't use FileDialog to access resource files unless they're in the main directory -- lovely

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file