View topic - Unitsync to Java binding



All times are UTC + 1 hour


Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: Unitsync to Java binding
PostPosted: 05 May 2011, 10:21 
User avatar

Joined: 13 Jan 2008, 19:40
Location: New Zealand
Has anyone got a working up to date implementation unitsync to Java binding?

Or is there any information about how to do such a thing.

I did it a while ago, but I forgot how I did, and it is old and broken now.


Top
 Offline Profile  
 
PostPosted: 05 May 2011, 10:36 
User avatar

Joined: 07 Feb 2005, 21:30
Location: Cheese factory
https://github.com/jahwag/cheeselobby/tree/master/lib


Top
 Offline Profile  
 
PostPosted: 05 May 2011, 11:23 
User avatar

Joined: 13 Jan 2008, 19:40
Location: New Zealand
Sweet that works nice.

For anyone else who stumbles accross this thread and wants to know what I did:



Top
 Offline Profile  
 
PostPosted: 05 May 2011, 11:24 
User avatar

Joined: 13 Jan 2008, 19:40
Location: New Zealand
Cheesecan wrote:
https://github.com/jahwag/cheeselobby/tree/master/lib

Nice one

Do you have any wrapper classes for Mods etc?

At the momemt I do:
Code:
UnitsyncLibrary.GetPrimaryModName(i).getString(0)

Which works, but it would be nice to wrap these calls in a better interface.


Top
 Offline Profile  
 
PostPosted: 05 May 2011, 12:06 
User avatar

Joined: 07 Feb 2005, 21:30
Location: Cheese factory
https://github.com/jahwag/cheeselobby/t ... y/unitsync

There's a wrapper mostly written by hoijui, I added some things as well.

If you like you are welcome to create a github project for unitsync for java, and set up maven repo, that way we could develop a better wrapper in cooperation. Not many people use the java unitsync right now but maybe in the future who knows, could be useful to someone.


Top
 Offline Profile  
 
PostPosted: 05 May 2011, 12:10 
User avatar

Joined: 13 Jan 2008, 19:40
Location: New Zealand
Yea cool, I defintally post my results to Github if they are good enough.

Do you know how to read unit information from unitsync?


Top
 Offline Profile  
 
PostPosted: 05 May 2011, 13:42 
User avatar

Joined: 13 Jan 2008, 19:40
Location: New Zealand
I really cant figgure out how to get unit stats:

Ive tried a mixture of the following:

Code:
    public static void main(String[] args) {
        UnitsyncLibrary.Init(false, 0);

        int modCount = UnitsyncLibrary.GetPrimaryModCount();
        System.err.println(UnitsyncLibrary.GetPrimaryModName(0).getString(0));
        System.err.println(UnitsyncLibrary.GetPrimaryModArchiveCount(0));
        System.err.println(UnitsyncLibrary.GetPrimaryModArchive(0).getString(0));
        System.err.println(UnitsyncLibrary.GetArchivePath("BA712.sdd").getString(0));
        int archiveID = UnitsyncLibrary.OpenArchive("D:\\Users\\David\\Documents\\My Games\\Spring\\mods\\BA712.sdd");
        System.err.println(archiveID);
        System.err.println(UnitsyncLibrary.GetUnitCount());
        System.err.println(UnitsyncLibrary.ProcessUnitsNoChecksum());
        UnitsyncLibrary.CloseArchive(archiveID);

        int modCount = UnitsyncLibrary.GetPrimaryModCount();
        for (int i = 0; i < modCount; i++) {
            Mod mod = new Mod();
            mod.setName(UnitsyncLibrary.GetPrimaryModName(i).getString(0));
            mod.setShortName(UnitsyncLibrary.GetPrimaryModShortName(i).getString(0));
            mod.setDescription(UnitsyncLibrary.GetPrimaryModDescription(i).getString(0));
            mod.setVersion(UnitsyncLibrary.GetPrimaryModVersion(i).getString(0));
            System.err.println(UnitsyncLibrary.GetUnitCount());
            System.err.println(UnitsyncLibrary.ProcessUnits());
            System.err.println(UnitsyncLibrary.GetFullUnitName(0));
            int archiveCount = UnitsyncLibrary.GetPrimaryModArchiveCount(i);
            for (int j = 0; j < archiveCount; j++) {
                Pointer archive = UnitsyncLibrary.GetPrimaryModArchive(j);
                System.out.println(archive.getString(0));
                break;
            }
            mods.add(mod);
        }
        UnitsyncLibrary.UnInit();

//        GUI.main(args);
    }


Top
 Offline Profile  
 
PostPosted: 05 May 2011, 16:06 
Spring Developer
User avatar

Joined: 22 Sep 2007, 08:51
i already have a much betteer wrapper locally. it has even OSGi support, which allows, next to other stuff, nice reloading of unityznc at runtime, which means you can load it from a different location. it also generates wrappers at comppiletime with maven plugins, and hides all JNA stuff from the interface.
it is quite as i wanted it, i just have to actualiye it for current master unitsznc.
i am not at home right now, will be soon though. just saying.. dont start somethign new ;-)
i will try to do that son, now that i know there is someone that could use it. will be online later.


Top
 Offline Profile  
 
PostPosted: 06 May 2011, 10:27 
User avatar

Joined: 13 Jan 2008, 19:40
Location: New Zealand
yay, are you online yet?


Top
 Offline Profile  
 
PostPosted: 06 May 2011, 10:57 
Spring Developer
User avatar

Joined: 22 Sep 2007, 08:51
woops! :D yes i am. get into #ai if you can, i am there if i am in the lobby.


Top
 Offline Profile  
 
PostPosted: 06 May 2011, 12:06 
Spring Developer
User avatar

Joined: 22 Sep 2007, 08:51
made it up-to-date now. will just have lunch and then do minor cleanup upload it to github.


Top
 Offline Profile  
 
PostPosted: 06 May 2011, 13:34 
Spring Developer
User avatar

Joined: 22 Sep 2007, 08:51
https://github.com/spring/JUnitSync

no real docu yet. i will upload a Pax-Exam test soon.
Most basic usage instructions:

You may specify the dir containing unitsync like this:
<code>System.setProperty("jna.library.path", unitsyncDir);</code>
or the path to unitsync like this:
<code>Preferences.userRoot().put("unitsync.path", unitsyncPath);</code>

Then start the bundle, and use either the "Unitsync" or "UnitsyncSimple" service (they only differ in one function, getInfoMapSize).

For further help, it may be best to meet me in the lobby.


Top
 Offline Profile  
 
PostPosted: 09 Mar 2012, 20:22 
Cursed Zero-K Developer
User avatar

Joined: 07 Nov 2007, 21:48
Location: Horse
We had success getting this to work in windows but now I need help getting it to work in linux and mac, both failed. Could you guys hang out in lobbydev more? It's not just for meetings anymore!


Top
 Offline Profile  
 
PostPosted: 10 Mar 2012, 12:30 
User avatar

Joined: 07 Feb 2005, 21:30
Location: Cheese factory
See the cheeselobby unitsync code, it should work under linux(unless it broke, I haven't tested it under linux for months).


Top
 Offline Profile  
 
PostPosted: 10 Mar 2012, 17:18 
Cursed Zero-K Developer
User avatar

Joined: 07 Nov 2007, 21:48
Location: Horse
det has been helping me. Turns out I was pointing to unitsync.dll when that's windows only. I will need to detect OS and let user fix OS if necessary, and base the filename on that.

Ironically, we have not gotten it to work right for him on linux but i managed to get it to work on a macbook. So we're close.


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Site layout created by Roflcopter et al.