|
Name input question |
Raf Vermeulen
Member #7,166
April 2006
|
So, my game runs smoothly, the highscore table works fine (except that for some reason, it shows 1 entry too much... last entry's always double, but that left aside), but now I want the player to enter his/her name, so it can store that into the highscore table instead of a standard string. Anybody here know how I can get around to do this? preferably, it'd be an input-field that's drawn on the screen. I simply have no idea how to start on this:-X |
Matthew Dalrymple
Member #7,922
October 2006
|
This thread is going on right now with someone creating a text input class. Basic concept: =-----===-----===-----= |
vbovio
Member #8,283
January 2007
|
try looking at d_edit_proc, otherwise consider writing it yourself, is not that hard, also there is a small routine on the code gallery, look at it and go from there. --------------- |
julian_boolean
Member #8,201
January 2007
|
Yes hehe I was just going to post that. I have a couple of threads made dealing with text input. Here's the other one: http://www.allegro.cc/forums/thread/589667 |
Raf Vermeulen
Member #7,166
April 2006
|
Ack, compiling error I can't figure out. DIALOG the_dialog[] = { { d_agup_edit_proc, 15, 75, 125, 8, 0, 0, 0, 0, 100, 0, name, NULL, name }, { d_agup_push_proc, 90, 115, 100, 18, 0, 0, 0, 0, 0, 0, (void*)"Done", 0, edit_high(pos, name, count) }, /* the next two elements don't draw anything */ { d_yield_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }, { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL } };
That gives this error: void value not ignored as it ought to be |
Tobias Dammers
Member #2,604
August 2002
|
That means that you assigned the result of a statement that evaluates to void (typically a function with return type void) to something, or passed it to a function as a parameter. void my_func() { // do some stuff here } int main() { int a = my_func(); // <- This line will trigger an error. return 0; }
--- EDIT --- --- |
Raf Vermeulen
Member #7,166
April 2006
|
The line number it gives, is the last line of the upper code. If I comment out the d_agup_push_proc line, it works fine, so there must be something with the call to the function edit_high in there, but it all seems in order to me. |
Tobias Dammers
Member #2,604
August 2002
|
It is not, I already explained. --- |
Kitty Cat
Member #2,815
October 2002
|
The dialog is initted at load-time, and as you have it, to fill in the dialog it has to run your function to get its return value. However, your function returns a void, and the place your're putting it wants a void*. What you want to do is pass a function pointer, not call the function. Do that by omitting the parameters and (). The dialog code will run your function, not you. And as a result, it can only take the parameters the dialog code gives it, not the ones you want it to have. Same with its return value. -- |
Tobias Dammers
Member #2,604
August 2002
|
Good explanation. --- |
Raf Vermeulen
Member #7,166
April 2006
|
Sweet, it compiles now:D Can't actually click it or edit the text in the textfield, but it's progress:D |
|