Author Topic: Height of a text to display description  (Read 7629 times)

BibiCmoi

  • Newbie
  • *
  • Posts: 3
    • View Profile
Height of a text to display description
« on: January 16, 2017, 06:52:55 AM »
Hello everybody,

I am new to AM, and I am trying to make a custom layout.
I use the ScrollingText module to display long titles horizontally and it works fine.
But now, I want to display long descriptions vertically, but I don't know how to find the true height of a text.

If the text is not enough long, I don't want the scroll to be active. But when the game has a big description, I want to activate the scroll, and resize the height of the object fe.Text to fit the description inside (otherwise, the text is not totally displayed). I tried to make a fe.Text with a height = height of the screen, but the scroll displays too much empty text (and it wouldn't work if the description is very very long)

Is there a way to do such a thing?

Subsidiary question : I put the description of the game in the filed "Extra" in the rom list. Is there a better solution?

Thank you

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: Height of a text to display description
« Reply #1 on: January 16, 2017, 07:50:17 AM »
Hey there,

Unfortunately scrolling text requires measuring the text width/height and there doesn't seem to be an accurate way to do that. Although there is a msg_width option, when I wrote the ScrollingText module it didn't seem to be accurate so I had to sort of "hack" in a way to make it work - guessing the width of horizontal text. I also built in a fixed_width property to help with the "too much empty space" problem, since sometimes with magic tokens or fonts and charsize it may not judge it correctly. If you don't use fixed_width, the measurement is based on a guess of the number of characters in the text and the charsize. Of course that might be different depending on the font you use.

For vertical text it becomes more of a problem, since descriptions are long and you have word wrap on, you won't know how many lines the text is either. Perhaps I'd need to add a fixed_height also but even that will leave empty space depending on how long the description is.

As far as not scrolling if it is not long enough, I don't think I built a way in to do that due to not having accuracy on the measuring.

It would take a lot of fudging around to get things to work the way we'd want I think. This may need to be an enhancement request for full scrolling on text objects as I think more control might be needed to make this work properly.

You can take a look at the code in scrolling text module and see how I did the measure_width and scroll functions, maybe that will give you some ideas.

qqplayer

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: Height of a text to display description
« Reply #2 on: January 16, 2017, 07:54:57 AM »
Hello everybody,

I am new to AM, and I am trying to make a custom layout.
I use the ScrollingText module to display long titles horizontally and it works fine.
But now, I want to display long descriptions vertically, but I don't know how to find the true height of a text.

If the text is not enough long, I don't want the scroll to be active. But when the game has a big description, I want to activate the scroll, and resize the height of the object fe.Text to fit the description inside (otherwise, the text is not totally displayed). I tried to make a fe.Text with a height = height of the screen, but the scroll displays too much empty text (and it wouldn't work if the description is very very long)

Is there a way to do such a thing?

Subsidiary question : I put the description of the game in the filed "Extra" in the rom list. Is there a better solution?

Thank you

Can you please explain me how did you add game despcriptions?
Where did you put the "extra info" and how did you add to the .nut?
I want to add this feature.
Thanks.


liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: Height of a text to display description
« Reply #3 on: January 16, 2017, 09:20:18 AM »
Can you please explain me how did you add game despcriptions?
Where did you put the "extra info" and how did you add to the .nut?
I want to add this feature.
Thanks.

The Extra field they are referring to is the one in the romlist file (romlist/mame.txt). In that file, you see the delimited columns:
Code: [Select]
#Name;Title;Emulator;CloneOf;Year;Manufacturer;Category;Players;Rotation;Control;Status;DisplayCount;DisplayType;AltRomname;AltTitle;Extra;Buttons
kinst;Killer Instinct (v1.5d);mame;;1994;Rare;Fighter / Versus;2P sim;0;joystick (8-way);good;1;raster;;;Killer Instinct is a great fighting game;6
You can add text in that field, then add the text in your layout like so:
Code: [Select]
local text = fe.add_text("[Extra]", 0, 0, fe.layout.width, 100)
text.charsize = 24
text.word_wrap = true

I'm not sure if there is a better way to do it.. I think you can use your own custom .ini files for Additional Import Files but I'm not sure how that works.

qqplayer

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: Height of a text to display description
« Reply #4 on: January 16, 2017, 02:53:31 PM »
Can you please explain me how did you add game despcriptions?
Where did you put the "extra info" and how did you add to the .nut?
I want to add this feature.
Thanks.

The Extra field they are referring to is the one in the romlist file (romlist/mame.txt). In that file, you see the delimited columns:
Code: [Select]
#Name;Title;Emulator;CloneOf;Year;Manufacturer;Category;Players;Rotation;Control;Status;DisplayCount;DisplayType;AltRomname;AltTitle;Extra;Buttons
kinst;Killer Instinct (v1.5d);mame;;1994;Rare;Fighter / Versus;2P sim;0;joystick (8-way);good;1;raster;;;Killer Instinct is a great fighting game;6
You can add text in that field, then add the text in your layout like so:
Code: [Select]
local text = fe.add_text("[Extra]", 0, 0, fe.layout.width, 100)
text.charsize = 24
text.word_wrap = true

I'm not sure if there is a better way to do it.. I think you can use your own custom .ini files for Additional Import Files but I'm not sure how that works.

Thanks for the replay , but this is not exactly what I´m looking for.
I saw this picture on this post:



http://forum.attractmode.org/index.php?topic=1193.0

I want to add "game descriptions" like on emulationstation for example.
Is this possible?
Thanks.
« Last Edit: January 16, 2017, 02:55:35 PM by qqplayer »

bionictoothpick

  • Sr. Member
  • ****
  • Posts: 320
  • He who laughs lasts.
    • View Profile
Re: Height of a text to display description
« Reply #5 on: January 16, 2017, 03:16:22 PM »
The code for that vertical theme came from Arcadebliss:

http://forum.attractmode.org/index.php?topic=643.0


It's in the history.dat file...check out the layout.nut and you will see the code. I hope this helps.

BibiCmoi

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Height of a text to display description
« Reply #6 on: January 17, 2017, 12:57:03 AM »
Hello liquid,

Thank you for your answer.

That's what I was afraid of :(
It is a pity that the height of a text is mandatory at creation. We shouldn't be obliged to enter this value since it's not necessarily known how much place the text will take (same for the width in some case)
I have already taken a look at the code in scrolling module and made some changes to meet my needs, but nothing that can help me in this particular case.

I will also look at this .dat and .ini history, because modifying the romlist.txt file is not very easy (I don't know why, when I modify my file, it adds me a "game" whose name is Title that comes from the First line which corresponds to the different fields)

Thank you again, and if an idea comes to you, don't hesitate to let me know.

BibiCmoi

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Height of a text to display description
« Reply #7 on: January 17, 2017, 05:17:09 AM »
Oh!! Thank you Liquid!

Thanks to the link you provide to the Arcadebliss' theme, I can see a property : "first_line_hint".
I tried to find some documentation, but failed, so I downloaded the sources of AM, and I found this :
Quote
// this is set to -1 when "no word wrapping" is set.
   // otherwise it is a value of 0+ and corresponds to the first line
   // of text being displayed in the control.  The user can change this
   // to control scrolling text where the text set into the control is
   // larger than the area available to display it.

I think it is possible to make something good with that.
I don't know how right now. I made some test and my text is scrollable but it is not really smooth (and I lost the beginning of my text).
I still need to work on it, but I am sure I am on the right way!

Thank you

qqplayer

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: Height of a text to display description
« Reply #8 on: January 17, 2017, 06:12:02 AM »
The code for that vertical theme came from Arcadebliss:

http://forum.attractmode.org/index.php?topic=643.0


It's in the history.dat file...check out the layout.nut and you will see the code. I hope this helps.

Thank you so much , I`ll check this.