Edit XML with an external editor

If there is something important you think is missing in the current version of ZGameEditor then you can post a feature request here!

Moderator: Moderators

Post Reply
User avatar
Ats
Posts: 708
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Edit XML with an external editor

Post by Ats »

Hello,

Would it be possible to add the option to edit the XML using an external editor (let say, sublime text) when clicking the "Edit as XML (Ctrl + M)" button, instead of using the built-in editor, and then update the project when the file is saved with the external editor?
User avatar
VilleK
Site Admin
Posts: 2318
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Edit XML with an external editor

Post by VilleK »

I do this sometimes manually by copy paste all into my favorite text editor and then copy it back. But you are right there could be an option for this. ZGE could also autodetect if the zgeproj file have been edited and ask to reload current project.
User avatar
Ats
Posts: 708
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Edit XML with an external editor

Post by Ats »

Hello. My game is slowly becoming huge for only one file, even if I comment everything in order to find what and where things are...

I'm planning to write a simple batch file to append several txt files into one final xml project, and so I was wondering if it would be possible to build a zgeproj without having to open ZGameEditor.exe, and then launch the game.

Something like:

Code: Select all

ZGameEditor.exe -b pathTo/myProject.zgeproject
pathTo/myProject.exe
Or directly open ZGE with a project:

Code: Select all

ZGameEditor.exe -o pathTo/myProject.zgeproject
The classic command functions :wink:
User avatar
Kjell
Posts: 1910
Joined: Sat Feb 23, 2008 11:15 pm

Re: Edit XML with an external editor

Post by Kjell »

Hi Ats,
Ats wrote: Thu Apr 20, 2023 9:08 amMy game is slowly becoming huge for only one file, even if I comment everything in order to find what and where things are...
Can you elaborate on what difficulties you're experiencing because your project is so huge?
Ats wrote: Thu Apr 20, 2023 9:08 amSomething like:

Code: Select all

ZGameEditor.exe -b pathTo/myProject.zgeproject pathTo/myProject.exe
Being able to compile / build a .zgeproj from the command line would be super convenient yes.

K
User avatar
Ats
Posts: 708
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Edit XML with an external editor

Post by Ats »

Kjell wrote:Can you elaborate on what difficulties you're experiencing because your project is so huge?
Mostly, having to deploy the component tree in order to select the right thing to display a lot of lines of code into the little ZGE code editor.
And if I edit anything in the XML editor, it will entirely close the project tree afterward. So I spend a lot of time searching things I could simply edit in a dedicated code editor.
User avatar
Kjell
Posts: 1910
Joined: Sat Feb 23, 2008 11:15 pm

Re: Edit XML with an external editor

Post by Kjell »

Hi Ats,
Ats wrote: Thu Apr 20, 2023 2:02 pmMostly, having to deploy the component tree in order to select the right thing to display a lot of lines of code into the little ZGE code editor.
Gotcha .. would be convenient if there was the option to use a external file with ZExpression / ZLibrary / BitmapFromFile / MeshImport etc. just like you can with ZExternalLibrary ( using DefinitionsFile ). Ideally the editor would then detect any changes made to the external file and automatically update the component.

Anyway, perhaps not as convenient .. but you can roll your own solution pretty easily. Attached is a example project that loads a external script into a ZExpression in App.OnRender. If you want to see changes made to the script while preview is running simply select the "Load Script" ZExpression in App.OnLoaded and press F5. Below is a demonstration of the example ( click the GIF for the MP4 version ) :wink:

Image
Ats wrote: Thu Apr 20, 2023 2:02 pmAnd if I edit anything in the XML editor, it will entirely close the project tree afterward. So I spend a lot of time searching things I could simply edit in a dedicated code editor.
One thing you can do to make this issue a little less annoying is to (ab)use a bunch of CallComponent components as a shortcut / bookmark list. Then using the "click to focus" button you can quickly jump to that component in the project tree.

Image

K
Attachments
Script.zip
(875 Bytes) Downloaded 859 times
User avatar
VilleK
Site Admin
Posts: 2318
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Edit XML with an external editor

Post by VilleK »

That is a very nice example Kjell! You just have to remember to make sure the script is loaded before generating a binary since the setStringProperty function is not available in the runtime.

A build "/b" switch sounds like a good idea.

I can also look in to keeping project tree nodes open after editing the xml.

I don't have time this week but I will try to check this next week.
User avatar
Ats
Posts: 708
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Edit XML with an external editor

Post by Ats »

Hahaha thanks for those overkill examples. I may not directly use them like that, but they could be handy to load some other external data that I get from a spreadsheet :wink:

Edit:
Thanks VilleK. There is no rush. I'm just planning my next moves in order to get motivated to continue!
User avatar
VilleK
Site Admin
Posts: 2318
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Edit XML with an external editor

Post by VilleK »

Please try new build: http://www.zgameeditor.org/files/ZGameEditor_beta.zip

- attempt to keep nodes opened after xml editor is used
- build project from command line using syntax "/b zgeproj-filename exe-filename". Example:

Code: Select all

ZGameEditor.exe /b "C:\MyProjects\NesEmu.zgeproj" C:\Temp\nesemu.exe
User avatar
Ats
Posts: 708
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Edit XML with an external editor

Post by Ats »

Thanks VilleK. I just downloaded and tried on my project.

For starters, I'm not really convinced by the node tree being reopened. It's super slow now. It looks like the whole project is being reopened from scratch. Or maybe it's the same speed as before and I emphasize on it, I'm not sure. Was it that slow before?

The build option is working nicely, with a couple of details:
  • Is it possible to not open/close the whole IDE while building from command, or is it mandatory because of the way the program works?
  • When I run ZGameEditor.exe /b "C:\MyProjects\NesEmu.zgeproj" C:\Temp\nesemu.exe in a bat file, the exe is produced, but the bat doesn't detect that this step is finished and that it can move on to the next line.
User avatar
VilleK
Site Admin
Posts: 2318
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Edit XML with an external editor

Post by VilleK »

Ats wrote: Fri Apr 28, 2023 9:31 am For starters, I'm not really convinced by the node tree being reopened. It's super slow now. It looks like the whole project is being reopened from scratch. Or maybe it's the same speed as before and I emphasize on it, I'm not sure. Was it that slow before?
I did not notice this. Maybe your project is huge? How many seconds does it take?
Ats wrote: Fri Apr 28, 2023 9:31 am [*]Is it possible to not open/close the whole IDE while building from command, or is it mandatory because of the way the program works?[/*]
Kjell noticed this too. Parts of the functionality of generating binaries is built into the main IDE window (and also error reporting if something goes wrong) so yes it has to show the main window. But I hardly notice it here because it runs so quickly. Again maybe it is because your project is so big that things are more noticeable.
Ats wrote: Fri Apr 28, 2023 9:31 am [*]When I run ZGameEditor.exe /b "C:\MyProjects\NesEmu.zgeproj" C:\Temp\nesemu.exe in a bat file, the exe is produced, but the bat doesn't detect that this step is finished and that it can move on to the next line.[/list][/*]
I think it will not wait at all in a batch file unless you use the "start" command. So "start /wait zgameditor" ...
If that is what you are already doing, then please check Task Manager if ZGameEditor process is still loaded. It should not be.
User avatar
Ats
Posts: 708
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Edit XML with an external editor

Post by Ats »

I was searching for the bat discussion in the forum, and I just discovered I never replied to your question... :oops:
Maybe your project is huge? How many seconds does it take?
The project is a blasting 689Ko. Most of the size comes from the 3DS imported objects.
The project tree takes 16 seconds to display after an XML edit, while it takes less than one second to display when loading the project from scratch.
I think it will not wait at all in a batch file unless you use the "start" command. So "start /wait zgameditor" ...
If that is what you are already doing, then please check Task Manager if ZGameEditor process is still loaded. It should not be.
That's super weird. ZGE isn't in process after completion, but the bat doesn't continue it's life after that.

I tried:

Code: Select all

Setlocal EnableDelayedExpansion
C:\Dropbox\Taf\ZGameEditor\ZGameEditor.exe /b Omeganaut.zgeproj Omeganaut.exe
TIMEOUT 0 >nul
Omeganaut.exe
and

Code: Select all

START /WAIT C:\Dropbox\Taf\ZGameEditor\ZGameEditor.exe /b Omeganaut.zgeproj Omeganaut.exe
Omeganaut.exe
I'll continue to dig.

Can the command line compress Windows exe as an option? Or should I call that later in my batch?
From ZGE Github:

Code: Select all

(P:'{$toolpath}upx.exe'; A:'{$exename}'),
(P:'{$toolpath}upx.exe'; A:'--lzma {$exename}'),
(P:'{$toolpath}upx.exe'; A:'--best {$exename}'),
(P:'{$toolpath}upx.exe'; A:'--brute {$exename}'),
And can it compile Linux, Mac and Android too?

Lastly, I found a horrible bug when calling ZGameEditor from command line: it erases the Reopen list, and worst, it erases the Tools/Settings too (packer settings, Android paths...) :shock:
User avatar
VilleK
Site Admin
Posts: 2318
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Edit XML with an external editor

Post by VilleK »

Ats wrote: Sun Aug 20, 2023 9:14 am The project tree takes 16 seconds to display after an XML edit, while it takes less than one second to display when loading the project from scratch.
You could email me this project and I can have a look why it takes so long to reopen after xml-edit.
Ats wrote: Sun Aug 20, 2023 9:14 am That's super weird. ZGE isn't in process after completion, but the bat doesn't continue it's life after that.
...
Lastly, I found a horrible bug when calling ZGameEditor from command line: it erases the Reopen list, and worst, it erases the Tools/Settings too (packer settings, Android paths...) :shock:
I think found out why these two problems happened. Please try to download ZGE again, they should be fixed now.
User avatar
Ats
Posts: 708
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Edit XML with an external editor

Post by Ats »

Thanks. The batch is working nicely now, and it's not erasing the ZGameEditor.ini anymore.
Post Reply