Need help on the feud Gui

Started by zammbi, August 29, 2008, 06:50:54 AM

Previous topic - Next topic

zammbi

I have been using the feud gui for my game but having a little trouble.
Window prints/moves fine but I'm unable to setup labels or text boxes right, no text is printing. I have imported all needed files and I am using the needed font.gif image.
Heres my setup method, I don't see any problems here.

    private void setupGui(){
   
        SimpleStream ss = new SimpleStream("Models/chatgui.png");
        Texture backDrop = new Texture(ss.getStream());
        try {
ss.close();
} catch (IOException e) {}
TextField field = new TextField(1, 100, 100, 10);
field.setVisible(true);
Label chatlabel = new Label(1,1);

        try {
window = new Window(backDrop, 50, 50);
window.add(field);
window.add(chatlabel);
window.setVisible(true);

} catch (Exception e) {
e.printStackTrace();
}
field.setText("Chat");
chatlabel.setText("Welcome to Casters of Fate");
    }


Also another problem is when I'm in window mode using frames Window isn't printed right. Its about 15 pixels out of place in the y direction, which also messes up when trying to move it, since you can only move 15 pixels below the gui image.
If I wanted to fix this problem where in the code this change needs to happen.

EgonOlsen

Looks fine to me. Are you sure that the font.gif is loaded correctly? About the 15 offset...that's the window title. When rendering into a frame, 0,0 is below the window title. You can get the insets of the frame and add that to your components' positions.

zammbi

Yep font.gif is loaded correctly, if I change its name it will complain about it.

zammbi

#3
Ah I didn't notice the letters was white and being painted on a white background  :o.
I haven't found a simple solution that fixes both the wrong location and the location to move the window.

EgonOlsen

If you have a frame, you can get its insets. You either add them to the position of your window, so that 10,10 becomes 10+left_inset, 10+top_inset or you subtract the insets from the mouse coordinates in the the MouseMapper or the evaluateInput-methods. The GUI-stuff in that demo wasn't meant to be complete. It's a just a quick hack to show something. It needs some adjustments and enhancements for sure.

zammbi

Well I quickly hacked every time I use a gui object I add inserts to it and then I removed the inserts from the MouseMapper class. That solves the problems for now.