Jump to content


Photo

Html-to-gml: Version 2.3


  • Please log in to reply
48 replies to this topic

#1 Sandro

Sandro

    GMC Member

  • New Member
  • 184 posts

Posted 24 April 2007 - 01:29 AM

HTML-to-GML 2.3

Have you ever tried to make only a single word bold-faced, or add a smiley to you text in you GM game. If you have then you would know that you have to set the font, then draw the first part of the text, set the font to bold, find the end position and call draw text again for one stupid word, and then set the font back to the way it was, find the end position of that and then call draw_text for the rest :D . OK, yea I know that's a huge pain, and it's why I created these scripts. Buy using HTML tags you can easily change the font in the middle of a string multiple times. This extension even comes with an action library so novice users can use it. So what are you waiting for, try it now.

(GM7) HTML-to-GML ver 2.3:

http://gmbase.cubedw...xtension&id=127

- Ultimate Game Arena, my old site was finally removed from the web after 6 months of free web space. Therefore I've have moved the file to a new site wanting to put together a list extensions(And as always I'm happy to help).

- I know I haven't updated this in a while, but I'm working on a new game called World Domination right now. This is first on my list once that's done.

- I have had my name changed from The Shadow to Sandro....I would really like if you would make necessary changes in the credits

- The Example was removed for version 2.3; I'll add it in 2.4 witch I hope to release either tonight or within the next few days.

- The help file has not been updated since version 2.2. You must consider the following change

<font_name>, <font_size>, and <font_color> have been removed. You must now use the <font> tag. You have 4 attributes to chooses from. You may use any number of the attributes and in any order. The attributes are:
face - The Font Name
size - The Font Size
color - The Font Color
align - The Font Align(Left, Right, or Center)

All attributes must be surrounded in single quotes( ' ) and can't contain spaces next to the equal sign( = ).

Good Examples:
<font size='10' color='red' align='left'>
<font size='10'>
<font color='blue' align='center'>
<font align='center'>

Bad Examples:
<size='10'> // Must have the word font
<font size=10> // Must have single quotes
<font size = '10'> // Can't have spaces
<font size="10"> // Must have single quotes, NOT DOUBLE

To-do List
- Make a better help file
- add support for word wrap
- add support for BB code
- add support for <input>
- add support for <table>
- Finish windows API(more on this later)
- add support for XML and XSL (maybe)

I spend a lot of time on this, so comments and suggestion are very much welcome.

http://gmbase.cubedw...xtension&id=127
  • 0

#2 lukesterspy

lukesterspy

    Robofish

  • GMC Member
  • 762 posts
  • Version:Unknown

Posted 24 April 2007 - 01:52 AM

Wow, this is cool. I will probably use this at some point. Good work.

EDIT: First post :D

Edited by lukesterspy, 24 April 2007 - 01:53 AM.

  • 0

#3 szepi1991

szepi1991

    GMC Member

  • New Member
  • 177 posts

Posted 24 April 2007 - 02:03 AM

I have a word wrap script I made, do you need it?

Edited by szepi1991, 24 April 2007 - 02:03 AM.

  • 0

#4 Sandro

Sandro

    GMC Member

  • New Member
  • 184 posts

Posted 24 April 2007 - 02:14 AM

@lukesterspy: thank you, it's good to know that my work has plaided off

@szepi1991: OK well, thats something I have been having problems with. Unfortunately, my HTML scripts draw every character in a different draw_text() function. You scripts probably won't work, but I would like to take a look at it. Maybe ital help me with my problem.
  • 0

#5 T-Bird

T-Bird

    GMC Member

  • New Member
  • 1326 posts

Posted 24 April 2007 - 06:20 AM

Man, I was just working on this exact same thing a couple days ago. I got frustrated not long before I got to a working version though (because I realized I'd have to deal with things like alignment eventually) and quit. Maybe I'll just use yours instead.
  • 0

#6 szepi1991

szepi1991

    GMC Member

  • New Member
  • 177 posts

Posted 24 April 2007 - 10:07 PM

yeah..maybe that would be a problem..
The code is a littlebit messy, I wrote it when I was younger :P

so here it is:

///////////////////////////////////////////////////////////////////
//////////////////////////////creator://///////////////////////////
//                       DAVID SZEPESVARI,                       //
//             WHO A MEMBER OF NEW GENERATION GAMES (N2G)        //
///////////////////////////Description:////////////////////////////
//       This script brakes the text to fit into a box           //
/////////////////////////////arguments:////////////////////////////
//               scr_text_automate(x1, x2, text)                 //
//////////////////////////////return://////////////////////////////
//                 The script returns a string,                  //
// if an error occurs, it gives back -1 (maybe not in all case)  //
////////////////////////////important://///////////////////////////
//      You have to change the font before using this script     //
//       to that one that you will use for drawing the text      //
///////////////////////////////////////////////////////////////////

var kiiras, x1, x2, width, sor, eddig, l, vissza, tesztre, leszed, ugrani;

kiiras=argument2;
if (argument1<argument0) return -1;
x1=argument0;
x2=argument1;

sor_text[0]="";
eddig=0;
do
{
    
    eddig+=1;
    tesztre=kiiras;
    for (l=0; l<=eddig-1; l+=1)
    {
        sor_text[eddig]=string_replace(tesztre, sor_text[l], "");
        if (eddig!=1)
        {
            sor_text[eddig]=string_delete(sor_text[eddig], 1, 1);
        }
        tesztre=sor_text[eddig];
    }
    if (string_width(sor_text[eddig])<=(x2-x1)) ugrani=1; else ugrani=0;
    do 
    {
        if (ugrani==1) break;
        leszed=string_char_at(sor_text[eddig], string_length(sor_text[eddig]));
        sor_text[eddig]=string_delete(sor_text[eddig], string_length(sor_text[eddig]), 1);
    }
    until (string_width(sor_text[eddig])<=(x2-x1) && leszed==" ")
    
}
until (sor_text[eddig]=="")


 vissza="";
 for (l=1; l<=eddig; l+=1)
 {
  vissza+=string(sor_text[l] + chr(13));
 }
 return vissza;

Unfortuantely it is not commented and the names of the varialbes are in my first language. So if you need I can add some comments. Actually I think it could be done better, but you can get an idea how to do it.
  • 0

#7 Sandro

Sandro

    GMC Member

  • New Member
  • 184 posts

Posted 25 April 2007 - 02:08 AM

New Version 2.1 - enjoy

@szepi1991 - great I'll take a closer look at that later(running out of time now)

@T-Bird - yes I know, thats a huge problem. But I'll get it to work somehow :P
  • 0

#8 Rusky

Rusky

    GMC Member

  • New Member
  • 2450 posts

Posted 26 April 2007 - 01:49 PM

cool! that's a really nice way to format text!
  • 0

#9 Ruan games

Ruan games

    GMC Member

  • New Member
  • 8 posts

Posted 29 April 2007 - 11:57 AM

[THE CODE POSTED EARILER]

EXECLENT but were the font? I need to cange it to small fonts

EDIT silly me what am i think i know what to do
:unsure: ^_^ :skull: :(

Edited by Ruan games, 29 April 2007 - 12:05 PM.

  • 0

#10 Sandro

Sandro

    GMC Member

  • New Member
  • 184 posts

Posted 29 April 2007 - 09:13 PM

Great thanks for the replies (I really do appreciate it).

I am wondering what you guy think. I am thinking of making pop-up windows for a new version. Therefor instead of using show_message(), get_string(), ect. you would be able to use html_show(), html_get_string(), ect. The message would use my HTML formatting and support all features the standard HTML script supports. So, post here if you think that would be a good idea.
  • 0

#11 Mr.Chubigans

Mr.Chubigans

    Hot, Sexy Gila Mobster

  • GMC Member
  • 491 posts

Posted 30 April 2007 - 03:36 AM

Sounds great to me!
  • 0

#12 Ruan games

Ruan games

    GMC Member

  • New Member
  • 8 posts

Posted 30 April 2007 - 02:44 PM

The word warp won't work an example of it is
argument0 = 0
argument1 = 182
argument2 = 'this is my personal garden. there's nothing in it'

an it return something like

this is my personal garden.
is is my personal garden.
there's nothing in it

and i have no idea whats going wrong
plz help!
  • 0

#13 szepi1991

szepi1991

    GMC Member

  • New Member
  • 177 posts

Posted 01 May 2007 - 01:08 AM

ok..I guess I know it, it had a bug that means it had a space in front of every line, so I fixed it and it worked for me..maybe I copied the wrong version cause once I had this problem

I'll look at it

///////////////////////////////////////////////////////////////////
//////////////////////////////creator://///////////////////////////
//                       DAVID SZEPESVARI,                       //
//             WHO A MEMBER OF NEW GENERATION GAMES (N2G)        //
///////////////////////////Description:////////////////////////////
//       This script brakes the text to fit into a box           //
/////////////////////////////arguments:////////////////////////////
//               scr_text_automate(x1, x2, text)                 //
//////////////////////////////return://////////////////////////////
//                 The script returns a string,                  //
// if an error occurs, it gives back -1 (maybe not in all case)  //
////////////////////////////important://///////////////////////////
//      You have to change the font before using this script     //
//       to that one that you will use for drawing the text      //
///////////////////////////////////////////////////////////////////

var kiiras, x1, x2, width, sor, eddig, l, vissza, tesztre, leszed, ugrani;

kiiras=argument2;
if (argument1<argument0) return -1;
x1=argument0;
x2=argument1;

sor_text[0]="";
eddig=0;
do
{
    
    eddig+=1;
    tesztre=kiiras;
    for (l=0; l<=eddig-1; l+=1)
    {
        sor_text[eddig]=string_replace(tesztre, sor_text[l], "");
        tesztre=sor_text[eddig];
    }
    if (string_width(sor_text[eddig])<=(x2-x1)) ugrani=1; else ugrani=0;
    do 
    {
        if (ugrani==1) break;
        leszed=string_char_at(sor_text[eddig], string_length(sor_text[eddig]));
        sor_text[eddig]=string_delete(sor_text[eddig], string_length(sor_text[eddig]), 1);
    }
    until (string_width(sor_text[eddig])<=(x2-x1) && leszed==" ")
}
until (sor_text[eddig]=="")


 vissza="";
 for (l=1; l<=eddig; l+=1)
 {
    if (l==1)
    {
        vissza+=string(sor_text[l] + chr(13));
    }
    else
    {
        vissza+=string_delete(sor_text[l], 1, 1) + chr(13);
    }
 }
 return vissza;

Edited by szepi1991, 01 May 2007 - 01:24 AM.

  • 0

#14 Sandro

Sandro

    GMC Member

  • New Member
  • 184 posts

Posted 01 May 2007 - 02:41 AM

OK...well I've started work on Window API, so soon the <input> tag should work.

I really need to finish that help file :D

That word wrap thin is a huge pain ;) so i guess I'll just keep pushing it off

I guess next is font align.

Thanks for the replies

@szepi1991 - Yea, well that script isn't helping me much. Can you at least explain how it works.
  • 0

#15 szepi1991

szepi1991

    GMC Member

  • New Member
  • 177 posts

Posted 04 May 2007 - 10:31 PM

I'll make a flowchart :)
  • 0

#16 Sandro

Sandro

    GMC Member

  • New Member
  • 184 posts

Posted 07 May 2007 - 08:31 PM

New Version 2.3

Updates
- Now supports font align
- Now supports <font> tag

Planned for 2.4
- Rewrite Help File
- Expand Color Names + Add a constant for each HTML color name
- Expand Entities

Planned for Future Version
- Add support for the <table> tags
- Add support for Windows API
- Add support for graphs; bar graphs, line graphs, and pie charts(for status screens)
- Add <img> tag
- and mush more

@szepi1991 I Would really like that, as I'm still not sure how word wrap will work.
  • 0

#17 szepi1991

szepi1991

    GMC Member

  • New Member
  • 177 posts

Posted 08 May 2007 - 10:36 PM

yeah...so do you need it?
  • 0

#18 Sandro

Sandro

    GMC Member

  • New Member
  • 184 posts

Posted 09 May 2007 - 07:38 PM

@szepi1991: k, well I think I know how I'm going to do the word wrap.

@all: I'm re-writing the extension...again ;) . I am doing this for a number of reasons.
1. I want to add word wrap
2. add support for Win API
3. make it expandable

@anyone who can fix this: I having a problem with draw_set_blend_ext()
OK, the HTML engine is draw on to a pink surface and then created into a background. The Pink would be a transparent color. Seems like it works right, wrong. When you set the text to a large font size or make the font bold, the edges blend to the background image to give it a smooth appearance. The problem is that the background is pink, so the edges of the font are a mixture between pink and black. Since these edges are not pink the aren't considered the transparent color, and while the normal pink pixels are removed in transparency, the blended ones aren't, leaving a pink border around the font. So I need you help. I need to know witch arguments I should use in draw_set_blend_ext() to remove the blend and do nothing else.
  • 0

#19 mattb64

mattb64

    GMC Member

  • New Member
  • 137 posts

Posted 11 May 2007 - 02:59 AM

I started learning HTML about a week ago and you should not use the <font> tag. It will not be in the next version of HTML.
Here is a quote from WC3

The <font> Tag Should NOT be Used

The <font> tag is deprecated in the latest versions of HTML (HTML 4 and XHTML).

The World Wide Web Consortium (W3C) has removed the <font> tag from its recommendations. In future versions of HTML, style sheets (CSS) will be used to define the layout and display properties of HTML elements.

Here is the link
  • 0

#20 Ansgar

Ansgar

    OM Studios

  • New Member
  • 333 posts

Posted 11 May 2007 - 12:06 PM

HTML in text editing and HTML in creating websites are two slightly different things. For text editing, using <font> is simpler and more practical than CSS.

And as for the text antialiasing problem - this might solve it:
draw_set_blend_mode_ext(bm_one,bm_zero);
Don't forget to reset the blend mode to bm_normal afterwards.

Edited by Ansgar, 11 May 2007 - 12:31 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users