Help with font code?

Community Forums/General Help/Help with font code?

Guy Fawkes(Posted 2015) [#1]
Hi all! :) I've been working on my game for a while now and I needed some old code I had made a while back to change the color of either the whole string of text, a word IN the text, or a character / many characters in a string. I just recently added bold, italics, underline, and center, but something is wrong with this code.

I can get:

to work...

But I can't get multiple:



OR the text to center normally using the "Text" function's "center_x", and "center_y" parameters...

Here's the code...

Colored_Text.bb:



Thank you all so much for your help!

Sincerely,

~GF


Guy Fawkes(Posted 2015) [#2]
Can someone please help?

Thank you!

~GF


Kryzon(Posted 2015) [#3]
Hello. Did you write that code yourself?


Guy Fawkes(Posted 2015) [#4]
Hello, why do you care? Yes, I wrote most of it. It's an old open-domain code.. Please do not argue with me... It's not anyone's business if I made the code or not. I'm already having a bad week. Please don't start with me.


Brucey(Posted 2015) [#5]
Hello, why do you care? Yes, I wrote most of it. It's an old open-domain code.. Please do not argue with me... It's not anyone's business if I made the code or not. I'm already having a bad week. Please don't start with me.


Way to ask for help!


Kryzon(Posted 2015) [#6]
I don't mean to start with you.

Hello, why do you care?

I care because it doesn't feel good to volunteer my free time to help improve something that will not have any educational impact on you (given your previous history).
If you're writing it yourself, if you're working hard, then I'll gladly help.

Right now I suggest this approach, using Types: parse ("process") the entire string at first and build a list of separate string pieces based on the formatting tags. Only after the processing is complete is when you render them.
This way you separate the processing from the rendering: you can process all formatted texts in your game \ application at load time, and only render them at the appropriate time.

These string pieces are Type objects that have fields such as the string value to print and property flags set to True or False (and colour values, coordinates etc.).

Store the formatting properties in a stack structure (like a pile). You can also use Types to make this stack.
When processing the entire text, every time you reach an opening tag like "[ b ]" you add a bold property to the stack and start a new formatted string-piece object with all the properties in the stack (this includes the bold property that you just added).
Every time you reach a closing tag like "[ /b ]", you remove the top-most bold property from the stack and start a new formatted string-piece object with all the properties in the stack.

Then at the end of this process you have a list of formatted string objects, each object knows their formatting properties and you can just render all objects sequentially whenever needed.


Guy Fawkes(Posted 2015) [#7]
Look. I am having a very bad day and don't need any crap.. So lets just cut to the chase. Why is it when there are double bracketed parameters, it doesn't work. But when there are single-bracketed parameters, it DOES work?


Kryzon(Posted 2015) [#8]
Put yourself in my position. Would you spend any time helping a person that just said "I don't need any crap" to you after you've written a genuinely helpful post?

The algorithm that I described is sound, I stand by it. My e-mail address is in my profile if you want me to explain more about it. Best of luck.


Guy Fawkes(Posted 2015) [#9]
As a matter of fact, I WOULD help them. Because I LIKE helping people.


GfK(Posted 2015) [#10]
I can see what's wrong with your code right away. But since you're acting like a total dick, I'm going to do the same and not tell you.

You don't deserve help.


Derron(Posted 2015) [#11]
My advice: do as Kryzon described, it is the most error prone and most manageable way of doing that formatting. Else you will surely run into trouble when things get more and more advanced (effects, font faces, ...).


Why? Because your code just sets the style as soon as the pattern is found:
Bold and bold italic but all in bold!

In your case this happens:
[ b] -> SetFont boldfont
"Bold " (written in bold)
[ i] -> SetFont italicfont
"and bold italic" (written in italic)
[ /i] -> SetFont defaultfont
" but all in bold!" (written in default)
[ /b] -> SetFont defaultftont

Using Kryzons approach of a pile/stack you add styles:
[ b] -> + bold
[ i] -> + italic (now bold AND italic)
[ /i] -> - italic (now only bold)
[ /b] -> - bold (now --- means default)


I wont elaborate more on it, aboves commentators already have spoken out what I was thinking when reading your first response to Kryzon.

bye
Ron


Brucey(Posted 2015) [#12]
Why is it when there are double bracketed parameters, it doesn't work.

Because your code isn't very good?

And with your current attitude, I agree with everything GfK said.


Guy Fawkes(Posted 2015) [#13]
You know what? I'm out this bitch! I'm SICK and TIRED of you, GFK! Mods, please just lock this thread... People aren't a help here, anyway. NONE of you understand my situation.. I'm so SICK and TIRED of being beat up on, just because I have autism...


GfK(Posted 2015) [#14]
You know what? I'm out this bitch! I'm SICK and TIRED of you, GFK!
Oh, well at least Kryzon's off the hook now. Thought it was all his fault at one point.

Mods, please just lock this thread... People aren't a help here, anyway.
Are you surprised nobody wants to help you? Really?

NONE of you understand my situation.. I'm so SICK and TIRED of being beat up on, just because I have autism...
Oh please... plenty of people are autistic but they don't go marching about, waving it in people's faces like a bloody flag that magically excuses everything. Nor do they carry off like complete jackasses then blame everybody else when they get the inevitable response to said behaviour.

Oh, and I don't suppose now would be a good time to mention that you've posted this in the wrong forum? :/


RemiD(Posted 2015) [#15]



Rick Nasher(Posted 2015) [#16]
Ok, ok, ok. Now you mention you have autism: that explains a lot. There are many different forms of autism and people here might in that case be a little bit more understanding, be nice and perhaps do some reading on the subject/be a better man, instead of reacting like as if they know all?

I know people with some forms of autism can come across rude at times, but doesn't mean they don't have feelings or mean to be. Quite the contrary. The problems can vary a lot, but there may be difficulties in relating to other peoples feelings and interacting correctly with them. Doesn´t mean they want to be insulting. It's just not that simple as is to most people.

It's the same as saying to someone who has a hearing problem: hey I know people that have a similar issue that do not talk as loud as you do, so shut up. While it really depends on what the person can still hear.

But hey it's a free world, only felt should mention in all fairness.


Guy Fawkes(Posted 2015) [#17]
I agree with you, TOTALLY, @Rick Nasher! I have the same exact autism that Albert Einstein himself had. That's what the doctors told my parents. And you know what? I'M NOT AFRAID TO HAVE AUTISM! Because I am ALOT braver than most of you people who try to beat me up verbally and call me stupid or call me other names. I only attack when people attack me. Now, can we either please get back on topic or leave the thread alone please?


RemiD(Posted 2015) [#18]
I have also a kind of autism : i have difficulty to tolerate too much stupidity. So don't take all my words seriously.


Guy Fawkes(Posted 2015) [#19]
You know what, get the HELL out of here! I have had ENOUGH of you picking on me! I'm outta' here! MODS! LOCK THIS!


GfK(Posted 2015) [#20]
Albert Einstein never had temper tantrums.