Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Entering Character Names > Moving to Next Menu
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Leftover




PostPosted: Sun Jan 23, 2005 5:25 pm   Post subject: Entering Character Names > Moving to Next Menu

I'm trying to think of a way without using mouse I can make the user enter in names for the characters, and then when he hits enter again once all the names are entered, it moves on to my next menu.

The user has to enter in 4 names for 4 characters in 4 different GUI text boxes in the window.

I was thinking making it so on the 4th pressing of Enter, the menu moved on, but then I ran into complications with, what if the user wanted to go back, modify a name, and then hit enter again to move onto the next GUI text box... It would still move to next menu, but requiring all 4 names, it would crash.

For now, I'm going to make a GUI button so I can keep working, but can anyone else think of a different way of doing this?
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Sun Jan 23, 2005 5:42 pm   Post subject: (No subject)

Turing:

fcn namesEntered : boolean
    for i : 1 .. upper (names)
        if names (i) = "" then
            result false
        end if
    end for
    result true
end namesEntered

loop %main loop
    getch (keystroke)
    if keystroke = chr (10) and namesEntered then %chr (10) = ENTER
        exit %move on to the next part of the program
    end if
    %have all the code to input character names here.  Make sure that it's AFTER the first if statement that contains the namesEntered line.
end loop
Leftover




PostPosted: Sun Jan 23, 2005 6:08 pm   Post subject: (No subject)

That mostly made sence. I don't get the names part though...

What I have:
code:

import GUI
setscreen ("graphics:500;400,position:center;center,nobuttonbar")
var font2, skip_button, continue_bl, new_bl, logo, hand_up, hand_dwn, new_fighter, new_thief, new_whmage, new_blmage : int
var enter, mnu_dwn, names : string (1)
GUI.SetBackgroundColor (255)

font2 := Font.New ("BankGothic Md BT:16:bold")
assert font2 > 0

Font.Draw ("FIGHTER", 85, 340, font2, 0)

Font.Draw ("THIEF", 315, 340, font2, 0)

Font.Draw ("Wh. MAGE", 80, 140, font2, 0)

Font.Draw ("Bl. MAGE", 290, 140, font2, 0)

var fightername, thiefname, whmagename, blmagename : int  % The Text Field IDs.

procedure FighterNameEntered (text : string)
    GUI.SetSelection (thiefname, 0, 0)
    GUI.SetActive (thiefname)
end FighterNameEntered

procedure ThiefNameEntered (text : string)
    GUI.SetSelection (whmagename, 0, 0)
    GUI.SetActive (whmagename)
end ThiefNameEntered

procedure WhMageNameEntered (text : string)
    GUI.SetSelection (blmagename, 0, 0)
    GUI.SetActive (blmagename)
end WhMageNameEntered

procedure BlMageNameEntered (text : string)
    GUI.SetSelection (fightername, 0, 0)
    GUI.SetActive (fightername)
end BlMageNameEntered

fightername := GUI.CreateTextFieldFull (116, 240, 50, "",
            FighterNameEntered, GUI.INDENT, 0, 0)
thiefname := GUI.CreateTextFieldFull (326, 240, 50, "",
            ThiefNameEntered, GUI.INDENT, 0, 0)
whmagename := GUI.CreateTextFieldFull (116, 40, 50, "",
            WhMageNameEntered, GUI.INDENT, 0, 0)
blmagename := GUI.CreateTextFieldFull (326, 40, 50, "",
            BlMageNameEntered, GUI.INDENT, 0, 0)

loop
    exit when GUI.ProcessEvent
end loop

((Few useless variables in there I know, I cut out all the pictures and what not so you can run it for your self))

What I think you explained to do:
code:

import GUI
setscreen ("graphics:500;400,position:center;center,nobuttonbar")
var font2, skip_button, continue_bl, new_bl, logo, hand_up, hand_dwn, new_fighter, new_thief, new_whmage, new_blmage : int
var enter, mnu_dwn, names : string (1)
GUI.SetBackgroundColor (255)

font2 := Font.New ("BankGothic Md BT:16:bold")
assert font2 > 0

Font.Draw ("FIGHTER", 85, 340, font2, 0)

Font.Draw ("THIEF", 315, 340, font2, 0)

Font.Draw ("Wh. MAGE", 80, 140, font2, 0)

Font.Draw ("Bl. MAGE", 290, 140, font2, 0)

var fightername, thiefname, whmagename, blmagename : int  % The Text Field IDs.

procedure FighterNameEntered (text : string)
    GUI.SetSelection (thiefname, 0, 0)
    GUI.SetActive (thiefname)
end FighterNameEntered

procedure ThiefNameEntered (text : string)
    GUI.SetSelection (whmagename, 0, 0)
    GUI.SetActive (whmagename)
end ThiefNameEntered

procedure WhMageNameEntered (text : string)
    GUI.SetSelection (blmagename, 0, 0)
    GUI.SetActive (blmagename)
end WhMageNameEntered

procedure BlMageNameEntered (text : string)
    GUI.SetSelection (fightername, 0, 0)
    GUI.SetActive (fightername)
end BlMageNameEntered

function namesEntered : boolean
    for i : 1 .. upper (names)
        if names (i) = "" then
            result false
        end if
    end for
    result true
end namesEntered

    loop
        getch (enter)
        if enter = chr (10) and namesEntered then
            exit %move on to the next part of the program
        end if
        fightername := GUI.CreateTextFieldFull (116, 240, 50, "",
            FighterNameEntered, GUI.INDENT, 0, 0)
        thiefname := GUI.CreateTextFieldFull (326, 240, 50, "",
            ThiefNameEntered, GUI.INDENT, 0, 0)
        whmagename := GUI.CreateTextFieldFull (116, 40, 50, "",
            WhMageNameEntered, GUI.INDENT, 0, 0)
        blmagename := GUI.CreateTextFieldFull (326, 40, 50, "",
            BlMageNameEntered, GUI.INDENT, 0, 0)
    end loop

loop
    exit when GUI.ProcessEvent
end loop


Now whatever I've tried to put in for names (in function) is comming back errored, and I'm not 100% sure what to do there, as I haven't used a few of those commands yet.
Cervantes




PostPosted: Sun Jan 23, 2005 6:26 pm   Post subject: (No subject)

I thought you said without using the mouse? GUI is using the mouse. But anyways, names is an array 1 .. 4 of string that is initialized such that each element = "", not a string of length 1.
I wasn't thinking at all that you were using GUI. I don't know if that's the best idea. Personally, I dislike it. It's up to you, though Smile
-Cervantes
Leftover




PostPosted: Sun Jan 23, 2005 7:21 pm   Post subject: (No subject)

Well I know of no other way to make text boxes appear below pictures like that Very Happy. I'm trying to avoid the "command line" feel in this game, and have it all in pictures and such.

And I know you can use the mouse to click on different text boxes, just I want to be able to hit enter to switch to them and then move on to next Confused

If it's hopeless this way, tell me now Smile
Leftover




PostPosted: Sun Jan 23, 2005 7:45 pm   Post subject: (No subject)

To add: The way I wanted to do it originally was like Final Fantasy 1 character naming, having a big screen full of letters, moving a pointer over the letter, hitting a key to select it, then repeat for each letter, but I thought about it and it seems like it would take a LONG time. I have about 16 hours or so that I plan on working on this for, sleepless, and there's still a good hunk that needs to be done, so unless it's reasonably easy to make what I originally wanted, or what I was looking for in this post, I'll have to stick with a button Confused
Cervantes




PostPosted: Sun Jan 23, 2005 8:52 pm   Post subject: (No subject)

Leftover wrote:

If it's hopeless this way, tell me now

Can't be! But, if it fails with GUI, you could make your own boxes. Mind you, that might take a bit more time, so if time is a constraint, you might want to stick with GUI. In any case, I do my best to avoid GUI, so I can't help you out too much.
Leftover




PostPosted: Sun Jan 23, 2005 10:46 pm   Post subject: (No subject)

Ahh... It's only really being used for background color (as colorback wasn't working for all my cases but GUI.SetBackgroundColor was) and for a skip button to skip my intro. I only recently thought of it this way.

I just didn't want to go from the nice picture style background and such all niceness, to a blank box asking to enter in 4 character names, then back again, just doesn't look nice Razz...

Is there any way you think it could work with GUI's? All it's doing is drawing the text boxes and making it so when you hit enter in 1, it goes in order to the next and next until you are done, and saves the info entered to text box to the variable.
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: