Author Topic: Need help on the feud Gui  (Read 3046 times)

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Need help on the feud Gui
« on: August 29, 2008, 06:50:54 am »
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.
Code: [Select]
    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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Need help on the feud Gui
« Reply #1 on: August 29, 2008, 09:15:27 am »
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.

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Re: Need help on the feud Gui
« Reply #2 on: August 29, 2008, 09:29:06 am »
Yep font.gif is loaded correctly, if I change its name it will complain about it.

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Re: Need help on the feud Gui
« Reply #3 on: August 29, 2008, 09:51:56 am »
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.
« Last Edit: August 29, 2008, 10:00:34 am by zammbi »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Need help on the feud Gui
« Reply #4 on: August 29, 2008, 10:28:48 am »
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.

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Re: Need help on the feud Gui
« Reply #5 on: August 29, 2008, 10:54:02 am »
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.