View previous topic - View next topic |
Author |
Message |
Terry Spectral Form
Joined: 16 Jun 2002 Posts: 798 Location: Dublin, Ireland
|
Posted: Fri Jul 22, 2005 8:12 pm Post subject: |
[quote] |
|
I'd really like to try using Tiled with my new project. How would I go about writing a plugin for my own map format? I'm sorry, I've never used Java before.
One tiny little feature that I'd like to see implemented is to be able to quickly move the map by holding down the middle button, i.e. like in big pages on firefox (sorry for the example, I don't think I'm explaining myself very well). _________________ http://www.distractionware.com
|
|
Back to top |
|
|
DrV Wandering Minstrel
Joined: 15 Apr 2003 Posts: 148 Location: Midwest US
|
Posted: Fri Jul 22, 2005 8:56 pm Post subject: |
[quote] |
|
Hey, neat! Just in time for the start of my new project.
You guys wouldn't happen to have an 88x31 web button thingo, would you? _________________ Don't ask no stupid questions and I won't send you away.
If you want to talk fishing, well, I guess that'll be okay.
|
|
Back to top |
|
|
biggerUniverse Mage
Joined: 18 Nov 2003 Posts: 326 Location: A small, b/g planet in the unfashionable arm of the galaxy
|
Posted: Tue Jul 26, 2005 3:32 am Post subject: |
[quote] |
|
Hello, everyone. We don't have a logo, no. Bjørn might have someone to do the job. ;) On map formats, I have planned an XSLT plugin to do things similar to the way TileStudio does them. (Hey! There's an extensible macro language right there!) But I haven't had time(I'm working on other things currently). If there is interest, I might be able to put something together fairly quickly...
EDIT: Oh, yeah. Bjørn's right. There's a ton of things on the list to be added. _________________ We are on the outer reaches of someone else's universe.
|
|
Back to top |
|
|
Modanung Mage
Joined: 20 Jun 2002 Posts: 317 Location: The Netherlands
|
Posted: Sun Jul 31, 2005 8:16 pm Post subject: |
[quote] |
|
biggerUniverse wrote: | We don't have a logo, no. Bjørn might have someone to do the job. ;) |
Then what's that thing in the 'about' window? Looks like a logo to me... pretty neat design if you ask me. It was designed in Ireland last year if I remember well. :,
Bjørn worked it out though.
|
|
Back to top |
|
|
biggerUniverse Mage
Joined: 18 Nov 2003 Posts: 326 Location: A small, b/g planet in the unfashionable arm of the galaxy
|
Posted: Thu Aug 04, 2005 3:03 am Post subject: |
[quote] |
|
You're a lot like your brother. You're also right, though I was referring to a 88x31 logo specifically. _________________ We are on the outer reaches of someone else's universe.
|
|
Back to top |
|
|
biggerUniverse Mage
Joined: 18 Nov 2003 Posts: 326 Location: A small, b/g planet in the unfashionable arm of the galaxy
|
Posted: Fri Aug 05, 2005 9:27 am Post subject: |
[quote] |
|
EDIT: this is a continuation of this thread.
Code: |
public class GuardianMapWriter implements MapWriter
{
public MappyMapWriter() {
//initialization goes here
}
/**
* Writes a map to a file.
*
* @param filename the filename of the map file
*/
public void writeMap(Map map, String filename) throws Exception {
writeMap(map, new FileOutputStream(filename));
}
/**
* Writes a tileset to a file.
*
* @param filename the filename of the tileset file
*/
public void writeTileset(TileSet set, String filename) throws Exception {
System.out.println("Asked to write "+filename);
}
public void writeMap(Map map, OutputStream out) throws Exception {
//warning: using icky tricks
out.write(""+map.getBounds().width+" "+map.getBounds().width+" ".getBytes());
ListIterator itr = map.getLayers();
while(itr.hasNext()) {
TileLayer l = (TileLayer)itr.next();
for(//rows) {
for(//cols) {
out.write(""+l.getTileAt(tx,ty)+" ".getBytes());
}
}
}
}
public void writeTileset(TileSet set, OutputStream out) throws Exception {
System.out.println("Tilesets are not supported!");
}
/**
* @see tiled.io.MapReader#getFilter()
*/
public String getFilter() throws Exception {
return "*.map";
}
public String getDescription() {
return
"+---------------------------------------------+\n" +
"| A simple writer for Guardian |\n" +
"| (c) Chaotic Harmony 2005 |\n" +
"| blah@blah.com |\n" +
"+---------------------------------------------+";
}
public String getPluginPackage() {
return "Guardian output plugin";
}
public String getName() {
return "Guardian Writer";
}
public boolean accept(File pathname) {
try {
String path = pathname.getCanonicalPath().toLowerCase();
if (path.endsWith(".map")) {
return true;
}
} catch (IOException e) {}
return false;
}
public void setErrorStack(Stack es) {
// TODO: implement setErrorStack
}
|
Ok. Very basic, write-only plugin. This should get you started. If I remember correctly (it's been a while) the layers are ordered bottom to top, rather than top to bottom.
Now, since you've never used Java, I recommend Eclipse (yes, it's bulky and it indents weird) because it's a very good open source IDE. If you get it, get the bigger distro. If you decide not to go with an IDE, then good luck to you. If you wish to go the commandline route, I can help there too. There's a steep curve either way.
You'll need at least the tiled-core.jar in your classpath to compile your plugin, but you may need the full tiled.jar as well. _________________ We are on the outer reaches of someone else's universe.
|
|
Back to top |
|
|
Terry Spectral Form
Joined: 16 Jun 2002 Posts: 798 Location: Dublin, Ireland
|
Posted: Fri Aug 05, 2005 1:10 pm Post subject: |
[quote] |
|
That looks simple enough. I'll give it a try on monday when I get back in front of my own computer.
[edit]
Quote: | Eclipse (yes, it's bulky |
Jezz, I thought that meant it was going to be like 10 meg or something. But over a hundred? That is bulky :)
I think I'll try and write that plugin this evening. I'll let you know how I get on. _________________ http://www.distractionware.com
|
|
Back to top |
|
|
Terry Spectral Form
Joined: 16 Jun 2002 Posts: 798 Location: Dublin, Ireland
|
Posted: Sat Aug 13, 2005 10:38 pm Post subject: |
[quote] |
|
So, I guess I'm going the command line route :) I gave up on eclipse and did a websearch, discovered ant, which compiled tiled first time so I think I'll stick with it.
Java seems pretty complex to set up - but in syntax and everything, it looks almost identical to C. I don't think I'll have any problem with it...
So far all I've tried is to copy and rename the mana world plugin to the guardian, and added a few lines to the build.xml files, but I guess I didn't do it properly, because that didn't work. Maybe it's something to do with those mysterious manifest files... hmm...
Say I just added a java file to the source plugin directory : what do I need to do to compile it properly? _________________ http://www.distractionware.com
|
|
Back to top |
|
|
biggerUniverse Mage
Joined: 18 Nov 2003 Posts: 326 Location: A small, b/g planet in the unfashionable arm of the galaxy
|
Posted: Mon Aug 15, 2005 6:12 am Post subject: |
[quote] |
|
Well, the plugins are kinda funky in build.xml to begin with. Can you give the error that ant returned with? _________________ We are on the outer reaches of someone else's universe.
|
|
Back to top |
|
|
Terry Spectral Form
Joined: 16 Jun 2002 Posts: 798 Location: Dublin, Ireland
|
Posted: Tue Aug 23, 2005 11:04 pm Post subject: |
[quote] |
|
Ok - (sorry I took so long, forgot all about this thread) - here's what I'm doing:
I've gotten it to compile - now how do I get it recognise the plugin?
First, I go to the plugins directory, and I make a copy of "tmw", and call it "guard". I go into this directory and change the target name part of the build.xml file to this:
Code: |
<target name="dist" description="Generate the distribution">
<jar
jarfile="${dist}/plugins/guard.jar"
manifest="MANIFEST.MF"
basedir="${build}"
includes="tiled/plugins/guard/*.class"
/>
</target>
|
In the plugins directory itself, I change from the target name to the target clean part in this:
Code: |
<target name="dist" description="Generate the distribution">
<mkdir dir="${dist}/plugins"/>
<ant dir="mappy" target="dist"/>
<ant dir="tmw" target="dist"/>
<ant dir="guard" target="dist"/>
</target>
<target name="nightly" description="Generate a nightly build" >
</target>
<target name="clean" description="Clean up the build directory" >
<ant dir="mappy" target="clean"/>
<ant dir="tmw" target="clean"/>
<ant dir="guard" target="clean"/>
</target>
|
Now I go to the tiled driectory itself, into the plugin sub directory, again copy tmw to guard, change the file inside to GuardMapWriter.java, and do a search replace in that file for tmw->guard.
So that creates a guard plugin when I run ant. In tiled though, it isn't listed as an available plugin... _________________ http://www.distractionware.com
|
|
Back to top |
|
|
biggerUniverse Mage
Joined: 18 Nov 2003 Posts: 326 Location: A small, b/g planet in the unfashionable arm of the galaxy
|
Posted: Wed Aug 24, 2005 3:22 am Post subject: |
[quote] |
|
Looks right. What you're probably missing is to set the tiled.plugin.dir option in tiled.conf to the absolute path where your plugin is located. _________________ We are on the outer reaches of someone else's universe.
|
|
Back to top |
|
|
Terry Spectral Form
Joined: 16 Jun 2002 Posts: 798 Location: Dublin, Ireland
|
Posted: Wed Aug 24, 2005 7:02 am Post subject: |
[quote] |
|
I think that's ok : tiled.conf just has tiled.plugins.dir = plugins, and that's where the plugin is, along with tmw and the mappy one... _________________ http://www.distractionware.com
|
|
Back to top |
|
|
Bjorn Demon Hunter
Joined: 29 May 2002 Posts: 1425 Location: Germany
|
Posted: Wed Aug 24, 2005 9:37 pm Post subject: |
[quote] |
|
And did you modify the MANIFEST.MF file to point to your reader and writer classes? This is what Tiled uses to be able to determine which classes are the reader and writer in the jar file.
And the existing plugins do show?
|
|
Back to top |
|
|
Terry Spectral Form
Joined: 16 Jun 2002 Posts: 798 Location: Dublin, Ireland
|
Posted: Wed Aug 24, 2005 9:38 pm Post subject: |
[quote] |
|
No, I did not. I'll go do that now then, shall I? :)
[edit] oh... that still doesn't fix it, oddly... I'm probably doing something really silly. Here's the current contents of that directory if you'd like to have a look yourself...
[edit] evidence of complete fuckwittage removed _________________ http://www.distractionware.com
Last edited by Terry on Thu Aug 25, 2005 7:46 pm; edited 1 time in total
|
|
Back to top |
|
|
biggerUniverse Mage
Joined: 18 Nov 2003 Posts: 326 Location: A small, b/g planet in the unfashionable arm of the galaxy
|
Posted: Thu Aug 25, 2005 12:05 am Post subject: |
[quote] |
|
Your Manifest.MF says:
Writer-Class: tiled.plugins.tmw.GuardMapWriter
EDIT: Tiled is very picky, and doesn't tell you when it encounters a problem this deep in loading a plugin. I'll put in a small fix to at least notify of failure. _________________ We are on the outer reaches of someone else's universe.
|
|
Back to top |
|
|