Slick Forums

Discuss the Slick 2D Library
It is currently Sun Dec 17, 2017 6:19 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Thu Jun 17, 2010 8:14 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1242
Integrating TWL into StateBasedGame

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
PostPosted: Thu Feb 06, 2014 12:03 pm 
Offline

Joined: Mon Feb 03, 2014 6:00 pm
Posts: 6
Thank you for this great library.
The wiki is down but I found this old cached version, I bet someone may have use of this. I bet its the same information but accessible:
http://webcache.googleusercontent.com/s ... eBasedGame

Text copy from the link:
Quote:
This approach should be easier to use together with Slick's StateBasedGame.

As the source code is a larger for this approach it is provided as zip [Note this: http://twl.l33tlabs.org/TWLSlick.zip] file

Instead of directly using StateBasedGame you subclass TWLStateBasedGame and override getThemeURL() like this:

public class MyGame extends TWLStateBasedGame {
/**
* Implement this method and return the URL for the TWL theme.
*
* @return the URL for the TWL theme. Must not be null.
*/
@Override
protected URL getThemeURL() {
return MyGame.class.getResource("ui/theme.xml");
}

//
// init game states etc ....
//
}

All game states needs to be subclasses of BasicTWLGameState. This allows them to provide their own UI when desired:

public class MainMenuState extends BasicTWLGameState {
private Button btn;

@Override
protected RootPane createRootPane() {
RootPane rp = super.createRootPane();
rp.setTheme("mainMenu");

btn = new Button("Hello World");
btn.addCallback(new Runnable() {
public void run() {
System.out.println("It works!");
}
});

rp.add(btn);
return rp;
}

@Override
protected void layoutRootPane() {
btn.adjustSize();
btn.setPosition(100, 100);
}
}

These classes will replace the normal Slick input handling and use TWL's event routing instead. All input events which are not consumed by an UI widget (like the Button above) are forwarded to the game state's input handling methods. But no other InputListeners are called.


Top
 Profile  
 
PostPosted: Tue Mar 03, 2015 8:52 pm 
Offline

Joined: Sun Oct 05, 2014 10:55 am
Posts: 15
Is this wiki or any version of it still accessable somewhere?


Top
 Profile  
 
PostPosted: Wed Mar 18, 2015 12:37 am 
Offline
Oldbie

Joined: Thu Mar 15, 2012 12:38 am
Posts: 290
raLa wrote:
Is this wiki or any version of it still accessable somewhere?


I do not know the status of TWL or the wiki but their home page is this:
http://twl.l33tlabs.org/

It is still up - maybe there is a link to the wiki there.

I did find this on the wayback machine:
http://web.archive.org/web/201309172046 ... eme+Editor


Top
 Profile  
 
PostPosted: Thu Mar 19, 2015 11:34 am 
Offline

Joined: Sun Oct 05, 2014 10:55 am
Posts: 15
This helps a lot, cheers!


Top
 Profile  
 
PostPosted: Tue Mar 24, 2015 12:50 am 
Offline
Oldbie

Joined: Thu Mar 15, 2012 12:38 am
Posts: 290
raLa wrote:
This helps a lot, cheers!


You're welcome, I'm glad I could help.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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:  
cron
Powered by phpBB® Forum Software © phpBB Group