[Mod XML Editor] Setting up an XML workspace in Eclipse (free download)

This is only for modders who are willing to get their hands dirty in the XML. Please turn away now if you were wanting a utility to do the code work for you.

Background

I've only really started looking at the games XML looking for examples of how the code works within itself. It looks as though you can control an awful lot of information but it is extremely hard finding specific examples.

What I was contemplating was to look at building city improvements to recruit race-specific units. As an example, allowing Ironeers to build stone golems.

The obvious starting point is to see how the game handles something similar. Kingdom races can build Drath units so lets start searching for how this is handled.

I was planning on using EditPad Pro to look at the game XML files to find the relevant examples but this is only a file editor and won't search through the directory structure. What we really need is an XML editor that will allow us to access all the game XML as a library or reference.

One solution is the free open-source Eclipse editor.

Eclipse can allow us to define a structure for both our mod files and also allow us a searchable reference of the game files. Best of both worlds. :)

Thought I would write this to help modders who aren't used to using Eclipse and want to work their way around a project environment.

Getting and installing Eclipse

Download Eclipse from http://www.eclipse.org/downloads/

You have a range of 'flavours' when downloading Eclipse but you wont need anything fancy for what we are about to do. I just grabbed the Eclipse Classic version when I installed it but it doesn't really matter which one you choose.

Extract the 'eclipse' directory from the zip file (I placed mine in Program Files).

I then created a shortcut of eclipse.exe for easy access from the desk-top. I think the reason Eclipse doesn't have an installer is that you can run multiple versions if you like.

Open eclipse.exe (I create a shortcut of this and have it on my desktop).

Select a workspace location. This is where your files will be stored. I just use the default usually and tell it not to ask again.

Select 'Workbench' from the splash screen

So at this stage you have Eclipse running, but now we need to install the XML plug-in.

Click Help --> Install New Software

In the next screen, Work with: Helios - http://download.eclipse.org/releases/helios from the drop-down list. If you are using a different version then choose that release version. Helios is version 3.6 of Eclipse.

Check box in Web, XML, and Java EE Development

Next

Next

Accept the terms of the license agreement --> Finish

Plug-ins will install (can take a while)

Restart when prompted.

Setting up your work environment

OK. So you've now got Eclipse installed and running.What we want to do is optimise the work area for XML coding. Luckily Eclipse comes with pre-defined layouts (called perspectives) and one of these is for XML.

Select Window --> Open Perspective --> Other --> XML

Setting up your Elemental Project

The project space is really just a collection of files you are working on (or referencing in our case). If I was working on a major mod I would define a project space for that mod, but in this instance I just want to muck around and will most likely end up with a collection of small mod files while I get used to it. I'm just going to set up a project space called 'Elemental'.

Select File --> New --> Project

General --> Project

Title: Elemental

Finish

Now you should see 'Elemental' listed in the Project Explorer within the left hand display.

Preparing your project environment

So far so good. But there is nothing inside the project.

Lets create two folders within the project space. One for our mod files and another for the game's XML reference files.

In the Project Explorer...

Right-click the 'Elemental' project folder and select New --> Folder

Folder name: Mods

Finish

Now make another folder called Resources

Getting your library of XML files

What we want to do is have a copy of the game XML files within the new 'Resources' folder we just created.

Select the newly created 'Resources' folder

Right-click --> Import

General --> File System

Next

From directory: Browse and navigate to the data/English directory (C:\Program Files\Stardock Games\Elemental\data\English)

Into folder should be your Elemental/Resources folder

Select All

Finish

Using the Reference files

Now you have a copy of the XML files used by the game that can be used as references and can be searched. Don't change these. Your changes should be put into your own XML files.

The search facility in Eclipse is nice and powerful. If you know how to use regular expressions you can search using these as well (but regex is not for the faint of heart nor for the easily frustrated!)

Back to our example. I wanted to find how the game files build recruitable Drath units.

I click on Search --> Search and search for the word 'Drath' within the workspace. I get 66 matches within a number of files and can see all the files with the word 'Drath' in them displayed in the bottom panel of the screen.

I'm not interested in the Core Tiles at this stage so I can ignore the files within this folder.

The next file is RecruitableImprovements.xml which contains 10 of the 66 matches. Within the search results I can open the plus symbol to see the context of what it has found. And if I double-click on the file it will open it up into my edit area. This is probably where I would start looking but I won't go into the specific for this tutorial - which is really just to help get modders started using Eclipse. ;)

Tip: There are two ways to look at XML files in the edit area. Below the edit area are two tabs: Design and Source. Design is good you seeing the values within the file structure but I personally find the Source view easier to work with.

When the file is open, all my 'Drath' search results are colour coded for me to find easily.

And so now I'm on my way to working out the method of building recruitable units via city buildings. :)

Hope you enjoyed this tutorial. Please add or comment if you handle searching and referencing a different way.

Screengrabs

The Eclipse work environment. At the top-right, next to the toolbar, is the XML Perspective activated.

In the main window to the left, the Project Explorer shows the various resources and files associated with the project.

Das_Test.xml is a test mod file open in the edit window that I'm currently working on (Note that this is being viewed in Source mode). This file is also the only file currently in the Mods folder in the Project Explorer. The little red boxes to the right show issues with the XML structure - but the game doesn't worry about these. Clicking each of these will take me to the offending line.

Below the edit window is my current search for 'Drath'. Each file lists how many matches as well as showing the lines within each file.

To the right is the Outline window. I use this to quickly navigate to the command I want to change.

 

Here is the search dialog that gave the above search results.

 

Here is my edit window showing what it looks like in Design mode (selected from the tab at the bottom). This may be an easier way to edit the values if you don't want to sift through the source. It is the same file - just displayed differently.

 

I've double clicked one of the results of the search and it has opened up in the edit window. On the right (where the cursor is hovering) I can see the matches within the context of the whole file and clicking will take me to them. On the left are yellow arrows, also pointing to the matches. And in the main window the search results are highlighted.

28,986 views 25 replies
Reply #1 Top

Good writet up, I briefly looked at Eclipse but went back to Notepad++. Might have another look in the future with your post as reference. I use Sadman Software Search, for digging through the Elemental files.

Reply #2 Top

I've been using Eclipse a bit more this morning and it is really solid for doing the XML work. :)

The combination of the search facility, editor and code outline all on one screen is great. I haven't ever bothered with Eclipse in the past for XML but this is a really cool application.

Reply #4 Top

Quoting Novaburst, reply 1
Good writet up, I briefly looked at Eclipse but went back to Notepad++. Might have another look in the future with your post as reference. I use Sadman Software Search, for digging through the Elemental files.

TextPad is another excellent text editor.  Let's you search subfolders.  When you do a search it will show the file name, line number, and text.  You can double click on it to load the file and it will take you right to that line.

TextPad
http://www.textpad.com/

I've been using Visual Studio to view the XML files.  Are there advantages of using Eclipse over Visual Studio?

Reply #5 Top

Quoting Gravedancer, reply 4
I've been using Visual Studio to view the XML files.  Are there advantages of using Eclipse over Visual Studio?

I'd imagine they would be very similar. I'll take a screen grab and post it...

Reply #6 Top

Screenshots added to the OP.

Reply #7 Top

Thank you for the screenshots.  It looks like there are a lot of similarities.  Your search window has more tabs though. :)

Nice write-up about Eclipse.

Reply #8 Top

I must be missing something Big.

I don't have an XML Perspective option.

I have:

CVS Repository Exploring

Debug

Java (default)

Java Browsing

Java Type Hierachy

Plug-in Development

Resource

Team Synchronizing

Help!

Reply #9 Top

Quoting drakonfire, reply 8
I must be missing something Big.

I don't have an XML Perspective option.
Neither do I.

Reply #10 Top

Sorry guys. I'll do some experimenting with what I have set-up. I must have loaded in a plug-in. I use Eclipse for quite a few different programming tasks. Got a feeling it will be the Web Tools plugins but I'll find out for sure and post detailed instructions.

Reply #11 Top

OK. You do need to load in a plug-in. Instructions have been placed in the OP under Getting and installing Eclipse

Apologies again. Forgot I installed this some time ago.

Reply #12 Top

Thank you very much.

With this tool i learned a lot about xml and i have a good view of the moddingopportunities.

It realy helps although i didn't edited xml before.

It is far better than using worldpad or some similar.

Thanks again!!!

Reply #13 Top

Thanks for the fix Das, works perfectly now.

Now I just having to figure out what the frack I'm doing  o_O

Reply #14 Top

[quote quoting="post"]
This is only for modders who are willing to get their hands dirty in the XML. Please turn away now if you were wanting a utility to do the code work for you.
/quote]

 

What do yo mean by a utility that does the code work for you? 

Reply #15 Top

Quoting cr0nic69, reply 14

What do yo mean by a utility that does the code work for you? 

Some programs allow you to build within a visual interface to make the process easier while the XML code is being built underneath. The Tile Editor is a good example. Eclipse is purely a code editor so will mean you need to code the XML structure directly.

Reply #16 Top

I run win Xp.  Do I want the 32 or 64 bit version?

Reply #17 Top

Quoting ElanaAhova, reply 16
I run win Xp.  Do I want the 32 or 64 bit version?

32 bit was what I was running on XP. :)

Reply #18 Top

Downloading Eclipse now.  I have to admit I'm curious why a glorified notepad is 170 Mb.

Reply #20 Top

*****edit*****

I figured it out!  I was running the 64 bit eclipse version, but, apparently I have a 32 bit install of java (eventhough my 64 bit system including IE seems to work fine with it).  I got rid of the 64 bit eclipse files and downloaded the 32 bit version and it seems to be working now without any adjustments.

*****edit*****

I know this is an old thread, but, I just downloaded Eclipse classic from the web site above and when I try to run the eclipse.exe I get an error message that says I don't have java installed.  I go to java site and they auto detect my version and they say I have the latest version. what gives?

I have java version 6 24.

I tried extracting Eclipse zip file directly to the java directory but it still can't find java.  the error message says it is looking in:

C:\Program File (x86)\Java\jre\bin\javaw.exe

but, my install of java is in

C:\Program File (x86)\Java\jre6\bin\javaw.exe

if I change jre6 to jre wont java stop working?  any ideas on how to resolve this?  neither the eclipse website or the java website is any help on this as far as I can tell.

I am using Windows 7 64bit if that matters.

Reply #21 Top

Quoting soldyne, reply 20
*****edit*****

I figured it out!  I was running the 64 bit eclipse version, but, apparently I have a 32 bit install of java (eventhough my 64 bit system including IE seems to work fine with it).  I got rid of the 64 bit eclipse files and downloaded the 32 bit version and it seems to be working now without any adjustments.

*****edit*****

I know this is an old thread, but, I just downloaded Eclipse classic from the web site above and when I try to run the eclipse.exe I get an error message that says I don't have java installed.  I go to java site and they auto detect my version and they say I have the latest version. what gives?

I have java version 6 24.

I tried extracting Eclipse zip file directly to the java directory but it still can't find java.  the error message says it is looking in:

C:\Program File (x86)\Java\jre\bin\javaw.exe

but, my install of java is in

C:\Program File (x86)\Java\jre6\bin\javaw.exe

if I change jre6 to jre wont java stop working?  any ideas on how to resolve this?  neither the eclipse website or the java website is any help on this as far as I can tell.

I am using Windows 7 64bit if that matters.

Make sure you have the JDK (Java Development Kit) installed which is what allows you to actually develop Java apps. The JRE (Java Runtime Environment) only allows you to run Java apps. You'll need the JDK if you want to use Eclipse.

Reply #22 Top

Quoting marlowwe, reply 21

Make sure you have the JDK (Java Development Kit) installed which is what allows you to actually develop Java apps. The JRE (Java Runtime Environment) only allows you to run Java apps. You'll need the JDK if you want to use Eclipse.

Not anymore since about Eclipse 3.0, when they implemented their own Java compiler. That's why the download page says "You will need a Java runtime environment (JRE) to use Eclipse (Java SE 5 or greater is recommended)."

And you wouldn't need the JDK just for editing XML, anyways.

The JDK is still nice for developing Java projects *if you use it in your projects* because you automatically get access to the Javadoc and source available in the JDK. See Window->Preferences->Java->Installed JREs.

Reply #23 Top

Quoting soldyne, reply 20
*****edit*****

I figured it out!  I was running the 64 bit eclipse version, but, apparently I have a 32 bit install of java (even though my 64 bit system including IE seems to work fine with it).  I got rid of the 64 bit eclipse files and downloaded the 32 bit version and it seems to be working now without any adjustments.

*****edit*****

You are likely running the 32bit IE - which is the standard browser even on 64bit Windows.

Easy check: If you can view Flash, it's the 32bit version.

Since the XML editing for EWOM won't ever need more than the 2GB available to 32bit applications, using 32bit Eclipse is OK.

Reply #24 Top

Quoting Das123, reply 15

Quoting cr0nic69, reply 14
What do yo mean by a utility that does the code work for you? 
Some programs allow you to build within a visual interface to make the process easier while the XML code is being built underneath. The Tile Editor is a good example. Eclipse is purely a code editor so will mean you need to code the XML structure directly.

Kael built something like what you describe for FfH's XML in Excel.  It's more work than you would think initially, but if you're going to make a ton of XML changes it saves so much time.  Hopefully we can convince Stardock to build/release a similar XML tool when they have the time ;).

Reply #25 Top

Quoting Sareln, reply 24

Quoting Das123, reply 15
Quoting cr0nic69, reply 14
What do yo mean by a utility that does the code work for you? 
Some programs allow you to build within a visual interface to make the process easier while the XML code is being built underneath. The Tile Editor is a good example. Eclipse is purely a code editor so will mean you need to code the XML structure directly.

Kael built something like what you describe for FfH's XML in Excel.  It's more work than you would think initially, but if you're going to make a ton of XML changes it saves so much time.  Hopefully we can convince Stardock to build/release a similar XML tool when they have the time .

... and there's also one for FE, apparently - see the Fallen Enchantress: Weapons post.