Here is a simple demo that causes slick "freeze" on my computer:
Code:
public class ThingleTestState extends BasicGameState {
/** The UI page being displayed */
private Page page;
/** The image to display in the background */
private Image image;
int id = 1;
ThingleController thingleController = null;
public ThingleTestState() {
}
@Override
public int getID() {
// TODO Auto-generated method stub
return id;
}
@Override
public void init(GameContainer container, StateBasedGame game)
throws SlickException {
Thingle.init(new SlickThinletFactory(container));
container.setShowFPS(false);
//container.setVSync(true);
//container.setTargetFrameRate(100);
image = new Image("resources/logo.png");
container.getGraphics().setBackground(Color.white);
try {
page = new Page("resources/login.xml", new LoginController("resources/login.xml"));
} catch (ThingleException e) {
e.printStackTrace();
}
Theme theme = new Theme();
theme.setBackground(Thingle.createColor(0.6f,0.6f,1f,1f));
theme.setBorder(Thingle.createColor(0,0,0.5f));
theme.setFocus(Thingle.createColor(0,0,0));
page.setTheme(theme);
page.setDrawDesktop(false);
page.enable();
Widget loginName = page.getWidget("login_name");
System.out.println(loginName);
loginName.setText("Test");
}
@Override
public void render(GameContainer container, StateBasedGame game, Graphics g)
throws SlickException {
image.draw(100,200);
page.render();
g.setColor(Color.black);
g.drawString("FPS: "+container.getFPS(), 530, 2);
}
@Override
public void update(GameContainer container, StateBasedGame game, int delta)
throws SlickException {
}
@Override
public void keyPressed(int key, char c) {
if(c == 'w') {
System.out.println("enabled");
page.enable();
} else if(c == 'e') {
System.out.println("disabled");
page.disable();
}
}
}
The bug occurs when page is disabled.
I am trying to use thingle for ingame menu that is shown when the player presses esc button. Simply adding and removing the diaglog doesn't work, because then input isn't let through to the game itself.