Posted: Wed Dec 03, 2008 3:30 pm Post subject: GUI's making my head hurt
Ok so I am working on making some simple GUI's and I'm soooo confused already. I'llpost the code I have then tell you what I am having trouble with.
code:
import GUI
View.Set ("graphics:800;600")
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%NAME CHARACTER SCREEN%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%PICK CHARACTER SCREEN%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%VARIABLES%%%%%%%%%%
%%%%%%%PROCEDURES%%%%%%%%%
%%%%%%%CREATE GUI%%%%%%%%%
var charButton := GUI.CreateButton (maxx div 2 - 30, maxy div 2 - 50, 100, "Rate", GUI.Quit)
%%%%%%%OUTPUT%%%%%%%%%%%%%
%%%%%%%RESET GUI%%%%%%%%%%
%put "Name = ", GUI.GetText (name)
Ok so I have two problems. One, for the textfield GUi...what variable does that name actually get stored in? So If I want to use the name that they entered at any time or place do I need to do that GUI.GetText (name)? Also if I get rid of that "Name =" why does it stop working? How do I put JUST that name?
Questiong two. That second button that says Rate on it...It's driving me nuts. What I want to happen is when you click one of those buttons (there will be 4) it will be linked with a number that is linked with a class (this is part of a group assignment to make an rpg...working on the character selection/creation atm). For example, if you click the button that says Rate your class will become Rate (rate is the archer class for example) and the number for that class is 1, so then I can make a variable that says class = 1 so in the future when I need to refer to my class it knows which one it is. The main problem with this is, the only way it is letting me make a button is if I use that GUI.Quit command thing. If I try to link it with a procedure like the examples do or even my first button, I get an error says "Argument is the wrong type". Anyways I'm not sure how much sense question 2 makes but sorry if it is confusing.
Thanks in advance for the help.
Sponsor Sponsor
TheGuardian001
Posted: Wed Dec 03, 2008 5:50 pm Post subject: Re: GUI's making my head hurt
well, for your first question:
see those lines of code where you said
GUI.Dispose(widget)
That got rid of them. permanently. so there is no text to get from the widget, you just destroyed it.
if you want to hide something without getting rid of it, use
GUI.Hide
hope that helped.
rcbhs
Posted: Wed Dec 03, 2008 6:37 pm Post subject: Re: GUI's making my head hurt
Ok So hide the name instead? Thanks...anybody got anything to help with my second one? It is still saying when I put in a procedure in a create button that the argument is the wrong type. Even if I copy and paste chinks of working code from examples and try to put them into my program they don't work. Randomly it gives me Argument is the wrong type.
SNIPERDUDE
Posted: Wed Dec 03, 2008 7:16 pm Post subject: RE:GUI\'s making my head hurt
For less of a headache you could try testing my Custom GUI...
corriep
Posted: Wed Dec 03, 2008 7:18 pm Post subject: RE:GUI\'s making my head hurt
Sniperdude, how many times have you pluged your LGUI?
SNIPERDUDE
Posted: Wed Dec 03, 2008 9:35 pm Post subject: RE:GUI\'s making my head hurt
Umm, maybe about three times. Only on GUI threads. Hey, I'm helping them.
Shush you.
rcbhs
Posted: Wed Dec 03, 2008 11:29 pm Post subject: Re: GUI's making my head hurt
Ok, while that is all fine and dandy, it really doesn't do anything to help solve my problem, like anything at all...
My goal here is to understand how GUI's work so I can use them in the dozen other spots they will be in my game. Being able to rip a GUI off of somebody else program doesn't help whatsoever. Also, like I said earlier, I can't even use GUI's that work in other code in my code which is like 70% of my problem.
SNIPERDUDE
Posted: Thu Dec 04, 2008 8:02 am Post subject: RE:GUI\'s making my head hurt
It's not a GUI rip off another programme, it is an alternate GUI library.
Well being able to use a different GUI library also doesn't help...anyways I've fixed one of my problems. My problem now is that I don't know where to put the GUI.Hide so it hides them only when I press the button.
code:
import GUI
View.Set ("graphics:800;600")
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%NAME CHARACTER SCREEN%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure assignCharClass
put "Hello User, your class is fighter."
end assignCharClass
procedure assignUserName
username := GUI.GetText (name)
put username
end assignUserName
%%%%%%%%%CREATE GUI%%%%%%%%%%%%%
procedure nameType
var nameLabel := GUI.CreateLabelFull (maxx div 3, maxy div 2 + 40, "Enter Your Name", 300, 0,
GUI.CENTER, 0)
name := GUI.CreateTextFieldFull (maxx div 3, maxy div 2, 300, "", NameEntered, GUI.INDENT, 0, 0)
var doneButton := GUI.CreateButton (maxx div 2 - 30, maxy div 2 - 50, 100, "Done", assignUserName)
end nameType
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%PICK CHARACTER SCREEN%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
nameType
var fighter : int := GUI.CreateButton (maxx div 4, maxx div 2, 0, "Fighter", assignCharClass)
loop
exit when GUI.ProcessEvent
end loop
copthesaint
Posted: Fri Dec 05, 2008 12:31 pm Post subject: RE:GUI\'s making my head hurt
Umm Above you used GUI.Quit
After the disposal you have to use
GUI.ResetQuit or even use this instead of using
Ahead of this make a procedure for what the button will do.
rcbhs
Posted: Fri Dec 05, 2008 4:16 pm Post subject: Re: GUI's making my head hurt
Thanks m8, found out that prob slightly after I posted it actually lols...well slightly after my most recent one. My problem now is button size. I want to make my buttons bigger and have no clue how. Atm this is my button draw proc.
code:
procedure classSel
var fighter : int := GUI.CreateButton (200, 350, 0, "Fighter", classFighter)
var archer : int := GUI.CreateButton (650, 350, 0, "Archer", classArcher)
var mage : int := GUI.CreateButton (200, 100, 0, "Mage", classMage)
var cleric : int := GUI.CreateButton (650, 100, 0, "Cleric", classCleric)
end classSel
They are all the same size and it is bothering me lol.
copthesaint
Posted: Fri Dec 05, 2008 5:32 pm Post subject: RE:GUI\'s making my head hurt
Well this doesn't solve that problem but why not just show the 4 pictures of each charater beside each other and a button uderneth each picture.
rcbhs
Posted: Fri Dec 05, 2008 8:25 pm Post subject: Re: RE:GUI\'s making my head hurt
copthesaint @ Fri Dec 05, 2008 5:32 pm wrote:
Well this doesn't solve that problem but why not just show the 4 pictures of each charater beside each other and a button uderneth each picture.
Yes I already do that with the character select screen, howver with my actal playscreen GUI I need it to fill a certain space properly and well without increasing button size, I can't do that.
copthesaint
Posted: Sat Dec 06, 2008 9:10 am Post subject: Re: GUI's making my head hurt
ok then do you want the button longer or wider?
longer= <-->
^
wider= | (sorry bad arrows ;p
V
I Know Longer that is simply changeing the 3rd value of gui creat box
ex
code:
var fighter : int := GUI.CreateButton (200, 350, 200(this is now longer and at 200), "Fighter", classFighter)
var archer : int := GUI.CreateButton (650, 350, 200(this is now longer and at 200) , "Archer", classArcher)
var mage : int := GUI.CreateButton (200, 100, 200(this is now longer and at 200) , "Mage", classMage)
var cleric : int := GUI.CreateButton (650, 100,200(this is now longer and at 200), "Cleric", classCleric)
Wider I will Try and look that up gimme a little and I will see what It is/ how to do it
edit:
ok I didn't find how to make the button wider but I also found something that may be of interest of you
code:
import GUI
View.Set ("graphics:200;140")
const size : int := 25 % The buttons size.
const border : int := 3
var starButton, mapleButton, starPic, mapleLeafPic : int
procedure StarPressed
Text.Locate (1, 1)
put "Star Pressed "
end StarPressed
procedure MaplePressed
Text.Locate (1, 1)
put "Maple Pressed "
end MaplePressed
With this you could potentionally use your pictures as buttons. Then just lable each of them.
rcbhs
Posted: Sat Dec 06, 2008 2:21 pm Post subject: Re: GUI's making my head hurt
Ty for the help with the picture buttons! Makes what I wanted to do alot easier.
However, it still doesn't entirely fix my problem with button size. The reason I need button size increased is because I need to make a battleGUI. In this battleGUI I need to have 4 buttons (Attack, items, abilities, run) take up a very specific amount of space so they do not cover the actual battle screen and they do not leave ugly white spaces in between buttons because the buttons are too small to touch.