Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Husky on Mon 10/07/2006 16:22:40

Title: Text Box cursor line – change line graphic, blinking?
Post by: Husky on Mon 10/07/2006 16:22:40
Question 1:Ã,  Is there a way to change the graphic of the Text Box cursor line “_”?

Details:Ã,  I made a nice large blocky custom font for my game. (The theme and style of the game require it to be large â€" each letter is 24 pix high in 320x240 rez)Ã,  It looks great, in general.Ã,  However, when I use my custom Save GUI, and I'm typing in letters for the save game name, I just can't help but to notice the difference between the little Text Box cursor line “_” and my large blocky custom font.Ã,  Thoughts?

Question 2:Ã,  Is there a way to make the Text Box cursor line blink?

Details:Ã,  I would like the cursor line to blink in the Save GUI Text Box â€" just because I think it would look more professional and polished, and kind of prompt the user to start typing.

Thank you in advance for your thoughts.
Title: Re: Text Box cursor line – change line graphic, blinking?
Post by: Ashen on Mon 10/07/2006 17:10:08
The short answer to both questions is: Not directly, but you can probably code it...

For example:
As with your Restore GUI (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=27365.0) hide the actual textbox off the side of the GUI. Now add a Label in it's place, set it to your custom font and have repeatedly_execute_always update the Label accordingly, and add the '_':

function repeatedly_execute_always() {
  String SaveName = String.Format("%s_", txtSave.Text);
  lblSave.Text = SaveName;
}


And you could adapt that - using a couple of variables - to alternatively add and remove the '_', making it flash.

int MyCounter;
bool CursOn;
function repeatedly_execute_always () {
// Make rep_ex_always if there isn't one, or paste this in if there is:
  if (MyCounter == 0) {
    if (CursOn == false) CursOn = true;
    else CursOn = false;
    MyCounter = 10;
    // Changes the 'CursOn' variable (whether or not to show the '_') every 10 loops (about 1/4 second).
  }
  else MyCounter --;
  if (CursOn == true) {
    String SaveName = String.Format("%s_", txtSave.Text); // Adds the '_' if needed.
    lblSave.Text = SaveName; // And updates the label.
  }
  else lblSave.Text = txtSave.Text; // Updates the label without the '_'.
 
}

(You could use a Timer (http://www.adventuregamestudio.co.uk/manual/SetTimer.htm), instaead of the MyCounter variable.)
Title: Re: Text Box cursor line – change line graphic, blinking?
Post by: SSH on Mon 10/07/2006 17:17:17
Look at my savegames with screenshots module for an example of just that...
Title: Re: Text Box cursor line – change line graphic, blinking?
Post by: Husky on Mon 10/07/2006 17:39:19
Ashen, SSH:Ã,  You guys Rock!Ã,  Thank you for the responses.

Regarding Question 1:Ã,  Brilliant!Ã,  Works great.Ã,  Thank you, I don't know if I'd ever have thought of linking a Label to a hidden Text Box to sneak that custom cursor line in.

Regarding Question 2:Ã,  More Brilliancy!Ã,  I just copied and pasted the code (in repeatedly_execute not repeatedly_execute_always) and adjusted for my differing text box name.Ã,  My cursor is now blinking perfectly.Ã,  Love it!Ã,  Watch that curser go!!!Ã,  Ah, this is good stuff.