Author Topic: ScrollingText module  (Read 25069 times)

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
ScrollingText module
« on: July 28, 2015, 08:20:56 PM »
Hey all... put together this module because I wanted scrolling text. Still a bit of a WIP, so you'll probably see some goofy things, but feel free to play around with it and give me any feedback..

https://www.youtube.com/watch?v=3YZWja4z7sk

It works by creating a surface and a text object for each scrolling text. Use is basically:
Code: [Select]
fe.load_module("objects/scrollingtext");
local scroller = ScrollingText.add( "[Title]", 25, 50, fe.layout.width - 25, 75, ScrollType.HORIZONTAL_LEFT );

//there is a couple wrapper functions for color:
scroller.set_rgb( 255, 0, 0 );  //the text color
scroller.set_bg_rgb( 0, 0, 0 ); //the surface color (uses a pixel.png to color the surface)
//scroller.set_pos( 0, 0, 100, 100 ); //the surface x, y, w, h

//you can access the surface and text objects directly
//scroller.surface <- the surface
//scroller.text <- the text object

//There are also some settings:
scroller.settings.delay = 500;
scroller.settings.loop = -1;

The module is in my github in modules/objects (make sure to grab the .nut and the folder and put it in modules/objects):
https://github.com/liquid8d/attract-extra/tree/master/modules/objects

A sample layout is available there as well:
https://github.com/liquid8d/attract-extra/tree/master/layouts/sample_objects_scrollingtext

For details on use, look in the modules/objects/scrollingtext.nut file
« Last Edit: July 28, 2015, 08:23:51 PM by liquid8d »

jedione

  • Hero Member
  • *****
  • Posts: 1135
  • punktoe
    • View Profile
Re: ScrollingText module
« Reply #1 on: October 30, 2016, 12:44:24 PM »
thanks this is great

Q: is their a way to change the Font?
help a friend....

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: ScrollingText module
« Reply #2 on: October 30, 2016, 01:35:35 PM »
I sent a direct msg to you, but I'll post here in case anyone is interested:

The scroller object you get is a custom object (composed of multiple objects, a surface and the text object that scrolls). You can access the text object from scroller.text so any properties of an FeText object can be modified there:

scroller.text.font = "font";

jedione

  • Hero Member
  • *****
  • Posts: 1135
  • punktoe
    • View Profile
Re: ScrollingText module
« Reply #3 on: October 30, 2016, 05:21:20 PM »
thanks will be trying this.....
help a friend....

jedione

  • Hero Member
  • *****
  • Posts: 1135
  • punktoe
    • View Profile
Re: ScrollingText module
« Reply #4 on: October 30, 2016, 06:18:25 PM »
so i got it working and is good i also made it work with animation...but with animation
it needs to start behind something and end behind something,,   were as the scrollingtext module
it goes right off the ends hidden witch is good ,  i can put it in tighter spots !


Q:  using "ScrollType.HORIZONTAL_LEFT"  after it disapers out the end of the surface
it takes about 7 sec before it will show up on the right side again for a loop.
 How can i change this so as the last tail end is going of the surface as it is starting at the other end again?


heres both codes..

//*****scrolingtext module******

local scroller1 = ScrollingText.add( "[Title]", 25, 50, 300, 45, ScrollType.HORIZONTAL_LEFT );

scroller1.set_bg_rgb(0, 220, 0, 150);
scroller1.set_rgb( 255, 0, 0 );
scroller1.text.font = "time";
scroller1.text.charsize = 25;
scroller1.set_pos( 200, 500, 400, 30 );



//*****scrolling text anime********

::OBJECTS <- {
    logo = fe.add_text("[Title]", 850, 202, 195, 050 ), 
}

local pac = {
    when = Transition.StartLayout ,property = "x", start = 1150, end = 580, tween = Tween.Linear, time = 7000, delay = 000, loop = true
 }

animation.add( PropertyAnimation( OBJECTS.logo, pac ) );
OBJECTS.logo.font="time";
OBJECTS.logo.set_rgb( 255, 0, 0 );
OBJECTS.logo.charsize = 28;




thanks bro...
help a friend....

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: ScrollingText module
« Reply #5 on: October 31, 2016, 11:03:39 AM »
So the problem here is when I wrote this, there wasn't a way to get accurate length in pixels of the text, based on the font and text size. By default it attempts to guess at the length based on the length of the text and the charsize set. This might not be accurate especially if you are using magic token variables, so you might have to set a fixed width of the actual text object using scroller.fixed_width = ? - Of course, then it may cut off longer text so you will have to decide what works best for you.

There is supposed to be a way now in AM to get a measurement, but when I was testing it I couldn't get it to work properly.

jedione

  • Hero Member
  • *****
  • Posts: 1135
  • punktoe
    • View Profile
Re: ScrollingText module
« Reply #6 on: October 31, 2016, 09:07:40 PM »
thank you..

i noticed the longer the the text the longer the cycle....ok

Q: is their a way when using the "VERTICAL_UP" to have it do
multiple lines.
IE:
one
two
three

instead of,,,,   one two three.
help a friend....

bjose2345

  • Sr. Member
  • ****
  • Posts: 107
    • View Profile
Re: ScrollingText module
« Reply #7 on: June 18, 2017, 09:34:31 AM »
Sorry for resurect this very old thread, but there is a way to do what jedione is asking, multiline "VerticalUP"? There is a way to emulate the same behaviour like in emulastation, where if the text is longest that a certain amount of characters, space, etc, Automatically after a while start to scroll up.

I know maybe we can do this with an animation (a delay to start and some extra var to check the length of the text to call it), but well still I have the problem with a multilne text from a [overview] call.

Thanks.

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: ScrollingText module
« Reply #8 on: June 18, 2017, 07:21:51 PM »
As I mentioned before, there was no way to measure text width/height which you would need to accurately do something like that. With different fonts and font sizes, using number of characters in a string doesn't tell you much. You don't know if the text fits within its constraints, so you don't really know whether to scroll or not. You could set a limit of characters possibly, but with different fonts and font sizes, I don't think it'd be all that reliable.

For reliable scrolling, I think this is something that needs to be added in for text objects - or at least, provide a way in squirrel to accurately measure the virtual width/height of text with a specific font and size.

I'm going to look at some additional objects soon, so I might revisit this at that point. If I see raygun around, I might pester about it a bit more - since it is a lacking feature that is needed :)

bjose2345

  • Sr. Member
  • ****
  • Posts: 107
    • View Profile
Re: ScrollingText module
« Reply #9 on: June 18, 2017, 09:58:44 PM »
First i want to give you the thanks, for all your awesome work liquid8d, you are an amazing person. Second i made some progress with the multiline part,  have 2 options:

1.Set the word_wrap from obj._text = true; but with some strange behaviour (like no real scroll, only by default scroll to horizontal and to the left but the multiline its shows)

2.I add the next piece of code in your scrollingtext.nut (and actually works, but like  you said there is no way to adjust the length, You need to put a random number that will make it look good, but with some strange behaviours too, sometimes  )

//obj._text = ScrollingText.actual_text(obj, var); //instead of call this part
obj._text = ScrollingText.chunk(obj, 5,  var); // i call this

chunk = function (str, n, var)
   {
      local ret = [];
      local i = 0;
      local e = 0;
      local len;
      local actual = ScrollingText.actual_text(str, var);   /* inside actual_text you need to add a reference for the [overview] magic token*/
      len = actual.len()      
      for(i; i < len; i += n) {
         e += n;
         if (e >= len)    e = len;         
         ret.push(actual.slice(i, e)+"\n"); /* i transform the string by adding a break line every n characters */
         
         
      }      
      return ret;
      
   }

well and one last thing, dunno if is because Im using the conveyor.nut in my theme, but when the Transition.FromOldSelection is call from the transition_callback function (when you hit some of the borders of the carousel and need to draw a new image, the [overview] text just Disappears, Nothing is displayed, only the first letter  :o )
« Last Edit: June 18, 2017, 10:10:09 PM by bjose2345 »

qqplayer

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: ScrollingText module
« Reply #10 on: June 21, 2017, 10:09:43 AM »
I made a this , I know is´nt the right way , but works quite good.

https://www.youtube.com/watch?v=rzErov3MQDE

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

bjose2345

  • Sr. Member
  • ****
  • Posts: 107
    • View Profile
Re: ScrollingText module
« Reply #11 on: June 21, 2017, 11:22:36 PM »
I made a this , I know is´nt the right way , but works quite good.

https://www.youtube.com/watch?v=rzErov3MQDE

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

this is a great idea Thanks qqplayer, you are a lifesaver  :)

mikeandbirgit

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: ScrollingText module
« Reply #12 on: July 11, 2017, 09:36:51 PM »
ok dumb question but how do you get the game info text inside the box.like is it a romlist or a gamelist that u need to edit or something?

arthurvalenca

  • Sr. Member
  • ****
  • Posts: 125
    • View Profile
Re: ScrollingText module
« Reply #13 on: June 22, 2018, 07:07:09 AM »
Hello friends, I'm having trouble making the text scroll up, even changing the code it continues to move left, someone could help me with this

Code: [Select]
fe.load_module("objects/scrollingtext");
local scroller = ScrollingText.add( "[OVERVIEW]", 25, 50, fe.layout.width - 25, 75, ScrollType.VERTICAL_UP );

//there is a couple wrapper functions for color:
scroller.set_rgb( 255, 0, 0 );  //the text color
scroller.set_bg_rgb( 0, 0, 0 ); //the surface color (uses a pixel.png to color the surface)
//scroller.set_pos( 0, 0, 100, 100 ); //the surface x, y, w, h

//you can access the surface and text objects directly
//scroller.surface <- the surface
//scroller.text <- the text object

//There are also some settings:
scroller.settings.delay = 500;
scroller.settings.loop = -1;

PS: It has been changed in all ways to VERTICAL_UP, but still continue to the left, please help me.

Dal1980

  • Full Member
  • ***
  • Posts: 54
    • View Profile
Re: ScrollingText module
« Reply #14 on: June 26, 2018, 06:28:32 PM »
Hi arthurvalenca

I would suggest trying the sample https://github.com/liquid8d/attract-extra/tree/master/layouts/sample_objects_scrollingtext and altering that to see if you still have the problem.

If the problem goes away using the sample layout file then I would suspect either something happening in the code before your scrolling text or some issue with updating the file via FTP/Samba (check to make sure your changes are being wrote as I've fell into this trap before. I've also had crazy times where I was updating the wrong file too but that's just my world probably ;D).

Hope this helps