Open quietbiker opened 3 years ago
Having a tidy up and I can see this routine in the kitchensink demo (main.agc);
Function ReadCodeFile(fileName$ as string) code$ as string : code$ = "" fileID = OpenToRead(fileName$) while (FileEOF(fileID) = 0) code$ = code$ + ReadString(fileID) + chr(10) endwhile code$ = ReplaceString(code$, chr(9), " ", -1) code$ = ReplaceString(code$, ":", "[colon]", -1) code$ = ReplaceString(code$, ";", "[semicolon]", -1) CloseFile(fileID) endfunction code$
I can see it'll build up the definition string, but with [colon]/[semicolon] placeholders.
It looks like there is a start of this already. It looks like it'll only handle a single definition per file (which is a good start, but multiples would work really well). I may see if I can elaborate on this..
This would probably be better if it was written as json data. I had considered xml before but not sure how to convert the xml file in AGK. AGK already works well with json.
The only issue with creating layouts like this is that it works well with pre-defined layouts but not so much with dynamic layouts that change during the app session.
But maybe you can have one file for the screen and small files for parts of the screen that change or small files that are used as templates for example your app might have a floating action button that adds a new text card, and adds one each time one after another. The code that adds a new text card could read just that small template file and maybe replace bits of text within it.
I can see that you'd still use all of the different OryUIUpdate functions alot the same way they are currently used.
It isn't something I feel I can give time to at the moment so if you work on something then feel free to create a new branch
Thanks Kevin, JSON isn't that human readable (XML is better), but it's not something to easily edit by hand. Totally understood on the time issue, I'm really grateful for the toolkit.
I think it's a fair expectation to add the code to provide dynamic widgets/update parameters, but the bulk being created from a text file.
I'm getting some progress, so will leave off here until I've got something that works well.
Thanks again!
More of a suggestion really - I'm finding the fairly long constructs for the widgets fairly untidy and tricky to view. I know I can break them into multiple lines/calls, but this may be an option to consider.
I'm suggesting using a text file that contains the config for buttons/text blocks etc and de-couples the widget config from the AGK code. Expose all the parameters for each widget (where possible). Run time values (user sprite IDs etc) won't really work, but static icon names will, which is probably the most common use.
I know AGK doesn't have a native config file read/writer, but this concept could be any easy to edit/view text format. I don't think it would be an issue to then have code to add/manipulate the widgets (ie add dialog buttons) in AGK code, but to get the basic UI up, positions, colours, icons etc would slim down the amount of code.