gE Perfect Textbox [Developement Issues & discussion]

Talk about making games.

gE Perfect Textbox [Developement Issues & discussion]

Postby bat78 » Tue Mar 25, 2014 12:40 pm

Hello everyone!
(Hello skydreign)

cooltext1492103526.png

"recently" i was in mood, so i started the Perfect Textbox. Having it on my way.. shall possibly bring great results. So far the textbox accept automatic size (height)
according to the font, crops any size of canvas into a custom text box with custom border/background colors, uses animated indicator (it acts exactly like a regular one here in the topic editor for e.g), you can filter out the characters you wish to be printed, including uppercases. The combination of caps lock and shift works as well as the caps lock apart. Ctrl+backspace to clear all and backspace to clear the last character.
That because we all know how interesting the default gE text boxes are coded.
So i am done with this stuff above in 209 lines (3 functions, 2 function calls in separate actors).. i think its time to seek for ideas, help and discuss that a little, since i might be doing something useful to others finally.
Mine and @DarkParadox's textbox have almost nothing in common, mine should use less memory/size, any font, automatic size, different behavior soo our goals are also a bit different. I would like to create the first fully working, easy-to-use library and probably sky will even include that in the new version of gE if he is ok with that. :D

Image
Code: Select all
Ale of Fiera™ std vegasoft™ - Game Editor - Text Box - Re-up - v1.0 [BETA]
- Ability to create custom width sized text box with a specific color for borders and background in a any canvas actor.
- Automatically height size according to the font actor height size
- Animated indicator, which pauses when typing or clearing text
- Filter of characters to be printed
- Shift, Caps Lock, Caps Lock+Shift fully working
- Backspace feature to delete characters
- Ctrl+Backspace feature to delete the text from the entire tb
- Any font can be used on any size (limited of width ofc)
- 1 Function to create the textbox and one for typing the text in it
- Active/non-active messy system


Image
Code: Select all
Bug 1: static-casted string buffer variable disallow individual function usage.
Bug 2: "The mysterious trigger" Textbox drawing won't work if there is no external text object with code of "textNumber = font.width" [SOLVED]
Note: Even commented the code above just should exist, or the textbox visual won't work. Thats creepy.
Bug 3: I don't think there is bug 3


Image
Ok. Fixing the bugs would be a perfect start. Then.. i can take care for the navigation (left-right) between characters so people can
fit characters in any place in the string or just delete a missed letter.(of course i would love some help.. i'm doing a lot of things tho and i need
some sort of an meditation or else i'm gonna overheat)
And the final step might be the textbox capacity. Writing longer strings then the textbox width size.
_________________________________________________________________________________________________________________________
I'm sorry if the wide fonts used as titles interrupt you on a way.. it because it reminds me of pyrometal. I like pyrometal environment.
_________________________________________________________________________________________________________________________
    transshipment content:
  • data
  • getbox.ged
  • fiera.c
getbox.zip
(480.97 KiB) Downloaded 163 times

_________________________________________________________________________________________________________________________
Last edited by bat78 on Tue Mar 25, 2014 10:49 pm, edited 1 time in total.
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: gE Perfect Textbox [Developement Issues & discussion]

Postby lcl » Tue Mar 25, 2014 2:59 pm

This is quite nice. I can see it is not complete, but what you have done is pretty nice!
I'm working on a text input box system, too. I'll send you what I've managed to put together via a PM.
Is this text box of yours going to support multiple lines? How about scroll bar? And how about selecting? :D
Keep up the good work, I'm waiting to see this finished!
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: gE Perfect Textbox [Developement Issues & discussion]

Postby bat78 » Tue Mar 25, 2014 3:26 pm

Hey lcl!
Copying is easy, scrolling/multiple lines is just as easy as well. Btw you can add a new filter character for return -> '\n'
And the code should work also with lines (haven't tested it but it should work) In this case you gotta disable the auto-height feature h.e
It is not meant to extend after return (easy to fix that tho). The reason why i didn't emphasized on new lines, is because i don't really needed it.
Especially for a first version. Yes, i know other would like new lines and thats what i will change soon ^^
Just want to fix the current bugs.
__________________________________________________________________________________________________________________________
Wow so much lines of code. I am aware you can shorten it, which was my priority in my code as you see i'm using combination of
GetKeyState and getLastKey. Sadly i couldn't navigate up/down using the slider. I missed something.
Reviewing the runtime.. i also noticed a weird behaviour in the indicator(you call cursor) when navigating right back especially.
I understand.. all this is hard which is why exactly i plan to finish this, soon as i get a rid of those two bugs. creepy bugs.
Your project seems nice and i appreciate you shared it with me. Thats how we can manage to succeed if we both wish for the same. :)
I plan to set the indicator with fseek/fgetpos-like functions where the indicator will remember the location and just back/forward ^^
I think i know how to do everything on theory.. Soon after i get a rid of those two bugs i will work on the navigation :)
And just hope someone share my interests, because sometimes i prefer working in team :P
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: gE Perfect Textbox [Developement Issues & discussion]

Postby bat78 » Tue Mar 25, 2014 10:55 pm

Image

Had some time time for bug fixing. I found out what causes the mysterious trigger character bug.
It looks like the old gE problem that you have to comment actor's name to access it. Similar to this, i need to comment
the name of the font actor to make the text box drawing successful. O_O
The real question is.. how to fix it. People will surely disagree to use external chars with commented font name.
Last edited by bat78 on Tue Mar 25, 2014 10:59 pm, edited 1 time in total.
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: gE Perfect Textbox [Developement Issues & discussion]

Postby lcl » Tue Mar 25, 2014 10:58 pm

I took a closer look at your code and I found out that your peculiar bug with having to have "textNumber = font1.width" somewhere in an actor's event is like an evolved version of the bug
where one has to have the name of an actor mentioned in the code that calls a function that directly changes the actor's actor variables.

EDIT:
bat78 wrote:It looks like the old gE problem that you have to comment actor's name to access it.

That's just the thing I was talking about.
EDIT ENDS

In your case the code also works if you remove the whole test actor and just put this to the textBox1's draw actor (or create actor) code:
Code: Select all
font1.width; //writing height instead of width works, too

It's not a fix, but at least it tells us that the problem has something to do with the dimensions of the actor, and no textNumber is needed to be set to anything.

I have a question about your code.

Why do you do this:
Code: Select all
for(; i<2; i++)
{
    erase(0, 0, 0, 1);
}

I mean, why do you need a for loop for using erase? Also, why is there just a ; instead of i = 0; for example?

bat78 wrote:Wow so much lines of code. I am aware you can shorten it, which was my priority in my code as you see i'm using combination of
GetKeyState and getLastKey. Sadly i couldn't navigate up/down using the slider. I missed something.
Reviewing the runtime.. i also noticed a weird behaviour in the indicator(you call cursor) when navigating right back especially.
I understand.. all this is hard which is why exactly i plan to finish this, soon as i get a rid of those two bugs. creepy bugs.
Your project seems nice and i appreciate you shared it with me. Thats how we can manage to succeed if we both wish for the same. :)
I plan to set the indicator with fseek/fgetpos-like functions where the indicator will remember the location and just back/forward ^^
I think i know how to do everything on theory.. Soon after i get a rid of those two bugs i will work on the navigation :)
And just hope someone share my interests, because sometimes i prefer working in team

Yes, I know my code is longer than yours, but I think it's quite logical, as it also does more things.
Sorry about the slider not working, I forgot to mention I haven't actually done any coding on it, just made it be drawn there.
With that weird behaviour of the cursor you mean how the text kind of blinks when moving right?
That is fixed in my newer version, and the cursor actually is done completely in another way this time.
Overall my text input thing is also a work in progress and that's why it may look a lot worse than it actually will be when I get it finished.

What you mean by talking about fseek? It is a file function, you know that, right? :)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: gE Perfect Textbox [Developement Issues & discussion]

Postby lcl » Tue Mar 25, 2014 11:16 pm

bat78 wrote:It looks like the old gE problem that you have to comment actor's name to access it. Similar to this, i need to comment
the name of the font actor to make the text box drawing successful. O_O
The real question is.. how to fix it. People will surely disagree to use external chars with commented font name.

I did some testing on this and found out that the code works, if there is the word width or the word height somewhere in the code that calls the function createBox().
It doesn't matter whether it's commented, or just on it's own line followed by a semicolon or in a function name or an actor name... it just has to be there.
So, what you can do to make everyone have that one necessary word there would be to rename the function to have the word width or the word height in the function name.
I renamed the function to createwidthBox() and it works. XD That's the ugliest fix ever, but I think that might just be the best you can get, since the problem is not in your code, but
in that GE appears to have serious problems when dealing with dimensions of text actors.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: gE Perfect Textbox [Developement Issues & discussion]

Postby bat78 » Tue Mar 25, 2014 11:27 pm

lcl wrote:I took a closer look at your code and I found out that your peculiar bug with having to have "textNumber = font1.width" somewhere in an actor's event is like an evolved version of the bug
where one has to have the name of an actor mentioned in the code that calls a function that directly changes the actor's actor variables.

Yep i already tested and found that out. I knew about that bug but i thought it is fixed in 1.4.1b.

lcl wrote:I have a question about your code.
Why do you do this:
Code: Select all
for(; i<2; i++)
{
    erase(0, 0, 0, 1);
}

I mean, why do you need a for loop for using erase? Also, why is there just a ; instead of i = 0; for example?

That will listen the function only once. Since the code is for draw actor, i'm using a static-casted variable that won't change its value after function end.
I put ; instead of a=0 because a=0 will loose the sense of the static cast, it will set a to 0 but we don't want variable restart right? ^^

lcl wrote:Yes, I know my code is longer than yours, but I think it's quite logical, as it also does more things.
Sorry about the slider not working, I forgot to mention I haven't actually done any coding on it, just made it be drawn there.
With that weird behaviour of the cursor you mean how the text kind of blinks when moving right?
That is fixed in my newer version, and the cursor actually is done completely in another way this time.
Overall my text input thing is also a work in progress and that's why it may look a lot worse than it actually will be when I get it finished.

Yes, the blinking problem was the thing in my mind. It's not that obvious tho.. i might skip it as a test user.
It does a lot of things surely. But there is no problem about the slider thing. As you said you already have it done so..

lcl wrote:What you mean by talking about fseek? It is a file function, you know that, right? :)

Yes, i know those are stream function from stdio, thats why i said fseek-like :) They can act exactly just the same for strings.
Last edited by bat78 on Wed Mar 26, 2014 12:03 am, edited 1 time in total.
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: gE Perfect Textbox [Developement Issues & discussion]

Postby bat78 » Tue Mar 25, 2014 11:37 pm

lcl wrote:
bat78 wrote:It looks like the old gE problem that you have to comment actor's name to access it. Similar to this, i need to comment
the name of the font actor to make the text box drawing successful. O_O
The real question is.. how to fix it. People will surely disagree to use external chars with commented font name.

I did some testing on this and found out that the code works, if there is the word width or the word height somewhere in the code that calls the function createBox().
It doesn't matter whether it's commented, or just on it's own line followed by a semicolon or in a function name or an actor name... it just has to be there.
So, what you can do to make everyone have that one necessary word there would be to rename the function to have the word width or the word height in the function name.
I renamed the function to createwidthBox() and it works. XD That's the ugliest fix ever, but I think that might just be the best you can get, since the problem is not in your code, but
in that GE appears to have serious problems when dealing with dimensions of text actors.


Seriously :D Can't i edit gE source code and find the script editor window and change "Script Editor" to "Script Editor width" xD
Also i need to consider putting invisible text font for use xD
Seems beautiful fix tho..creative i can say. AND it would be nice if it makes sense too .. widthCreateBox ...
____________________________________________________________________________________________________________________________________________
EDIT:
I might be yell fully blind or just missing something but i think it fixed the bug by itself :roll:
I just used Actor variables directly instead of getclone by string, aslo added function parameters for indicator color and size.
Didn't work but lets don't miss the waiting :D i waited 5-10 minutes and it fixed itself e.e ..gE is capable to surprise you on any side he-he.
getbox2.zip
(487.61 KiB) Downloaded 125 times

EDIT2:
No way !! -__-
Just a simple gE restart and it is again bugged. gE wants to be bad, fine. (don't download the attachment except if you want to confirm this xD
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: gE Perfect Textbox [Developement Issues & discussion]

Postby bat78 » Tue Mar 25, 2014 11:58 pm

Code: Select all
#define a //width

will make the effort minimal.
I wish we can do something like
Code: Select all
#define NULL //width

LOL
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: gE Perfect Textbox [Developement Issues & discussion]

Postby lcl » Wed Mar 26, 2014 12:03 am

bat78 wrote:EDIT2:
No way !! -__-
Just a simple gE restart and it is again bugged. gE wants to be bad, fine. (don't download the attachment except if you want to confirm this xD

I was just about to write a post to note you about that. I had this same issue when I was trying to fix it. Sometimes I did something and it seemed to work, but
reloading the project showed that the fix wasn't a proper one. This problem is pretty irritating, because it's something you wouldn't expect from a program like GE.

bat78 wrote:
Code: Select all
#define a //width

will make the effort minimal.
I wish we can do something like
Code: Select all
#define NULL //width

LOL

I already tried something similar to that, but it didn't work. GE needs the actual word, not any other word, even if it would be interpreted as width x.x
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: gE Perfect Textbox [Developement Issues & discussion]

Postby bat78 » Wed Mar 26, 2014 12:09 am

Well i can just leave the function with name createBox........_width xDD
createBox_width is not that that bad tho. There are no other options to take. Thank you :)
Lets consider this bug fixed. Now i need to think of getting rid of the static buffer "string".. so people can use the function for multiple textboxes :)
Code: Select all
lcl.points += 1;
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: gE Perfect Textbox [Developement Issues & discussion]

Postby lcl » Wed Mar 26, 2014 12:27 am

bat78 wrote:Well i can just leave the function with name createBox........_width xDD
createBox_width is not that that bad tho. There are no other options to take. Thank you :)
Haha, no need to thank me for a fix that ugly :lol:
bat78 wrote:Lets consider this bug fixed. Now i need to think of getting rid of the static buffer "string".. so people can use the function for multiple textboxes :)

Well, I don't know about you, but I'd just abandon using that typedef enum thing, and use typedef structs instead (I've kinda fallen in love with them ♥ :mrgreen: ).
The struct could then contain a string variable and so every box would have one of it's own.

Remember that in order to have this support multiple text boxes, you will also have to make it create a clone of the text actor for each text box.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: gE Perfect Textbox [Developement Issues & discussion]

Postby bat78 » Wed Mar 26, 2014 12:35 am

lcl wrote:
bat78 wrote:Well i can just leave the function with name createBox........_width xDD
createBox_width is not that that bad tho. There are no other options to take. Thank you :)
Haha, no need to thank me for a fix that ugly :lol:
bat78 wrote:Lets consider this bug fixed. Now i need to think of getting rid of the static buffer "string".. so people can use the function for multiple textboxes :)

Well, I don't know about you, but I'd just abandon using that typedef enum thing, and use typedef structs instead (I've kinda fallen in love with them ♥ :mrgreen: ).
The struct could then contain a string variable and so every box would have one of it's own.

Remember that in order to have this support multiple text boxes, you will also have to make it create a clone of the text actor for each text box.


Haha yes, so you can use the font multiple times. I actually started to do something like that:
Code: Select all
typedef struct textBox_Database
{
   int h;      //extra height
   int w;      //estra width
   int tp;      //extra transp
   int bc_r;    //border color red
   int bc_g;    //border color green
   int bc_b;    //border color blue
   int R;      //background color red
   int G;      //background color green
   int B;      //background color blue
   int ic_r;   //indicator color red
   int ic_g;   //indicator color green
   int ic_b;   //indicator color blue
   int ic_s;   //indicator animation speed
} *TBox;

And yeah i noticed you are using them quiet often ;D I guess its my time to apply that advantage finally :)
As people says.. "you structure your life"
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: gE Perfect Textbox [Developement Issues & discussion]

Postby lcl » Wed Mar 26, 2014 12:53 am

bat78 wrote:... I actually started to do something like that:
Code: Select all
typedef struct textBox_Database
{
   int h;      //extra height
   int w;      //estra width
   int tp;      //extra transp
   int bc_r;    //border color red
   int bc_g;    //border color green
   int bc_b;    //border color blue
   int R;      //background color red
   int G;      //background color green
   int B;      //background color blue
   int ic_r;   //indicator color red
   int ic_g;   //indicator color green
   int ic_b;   //indicator color blue
   int ic_s;   //indicator animation speed
} *TBox;

And yeah i noticed you are using them quiet often ;D I guess its my time to apply that advantage finally :)
As people says.. "you structure your life"

That looks beautiful! 8)
But one thing, use this instead:
Code: Select all
typedef struct textBox_Database
{
   //all the variables here
}TBox;

This way you won't be fooling yourself so easily. If you define the struct like you did, you've actually made a keyword for creating pointers to structs, instead of creating a keyword for creating structs.
The way I recommended, you can use
Code: Select all
TBox mytextBox1;

to create a text box, and
Code: Select all
TBox * myTextBoxPointer;

to create a pointer to a text box.

Overall, a good decision mate, typedef struct will make your life so much easier! :D
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: gE Perfect Textbox [Developement Issues & discussion]

Postby bat78 » Wed Mar 26, 2014 12:57 am

lcl wrote:
bat78 wrote:... I actually started to do something like that:
Code: Select all
typedef struct textBox_Database
{
   int h;      //extra height
   int w;      //estra width
   int tp;      //extra transp
   int bc_r;    //border color red
   int bc_g;    //border color green
   int bc_b;    //border color blue
   int R;      //background color red
   int G;      //background color green
   int B;      //background color blue
   int ic_r;   //indicator color red
   int ic_g;   //indicator color green
   int ic_b;   //indicator color blue
   int ic_s;   //indicator animation speed
} *TBox;

And yeah i noticed you are using them quiet often ;D I guess its my time to apply that advantage finally :)
As people says.. "you structure your life"

That looks beautiful! 8)
But one thing, use this instead:
Code: Select all
typedef struct textBox_Database
{
   //all the variables here
}TBox;

This way you won't be fooling yourself so easily. If you define the struct like you did, you've actually made a keyword for creating pointers to structs, instead of creating a keyword for creating structs.
The way I recommended, you can use
Code: Select all
TBox mytextBox1;

to create a text box, and
Code: Select all
TBox * myTextBoxPointer;

to create a pointer to a text box.

Overall, a good decision mate, typedef struct will make your life so much easier! :D


No doubts! I am just not used to them.. still making mistakes like the one you got me in :oops:
*figuring out how and where the struct will work in my code*
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Next

Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest