Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Author Topic: How to check whether the text can fit in a static control  (Read 6222 times)

0 Members and 1 Guest are viewing this topic.

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
How to check whether the text can fit in a static control
« on: January 11, 2016, 10:54:49 PM »

I have a static control that must remain at the preset size. The font I have chosen does not have characters of a standard size e.g. character "1" is much smaller than "0".

I have a large text which I am dividing into chunks which I show on the static control. When user clicks, the next chunk is shown.

My problem is that, because of my font, I can't divide the dialogue into chunks of a particular size. I need some way to check whether the text I set to the static control can fit inside it. There must be some way to know this, since we have access to methods like SizeToFit and HeightToFit.

Is there a way to achieve this?
Logged

eborr

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 196
    • View Profile
Re: How to check whether the text can fit in a static control
« Reply #1 on: January 12, 2016, 04:01:21 PM »

I have investigated something similar to this before, the problem that you have is although though methods appear to be available I think they are only implemented on scene objects and not on window controls. You only option, unless you want to mod the engine is to do the classic character count and when it exceeds you line length go back to the last space and through a carriage return line feed. I note what you are saying about non standard font, in which case the you simply have to allow for less characters than you otherwise might with another font - eg you drop your max characters from 80 to 60
Logged

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
Re: How to check whether the text can fit in a static control
« Reply #2 on: January 13, 2016, 10:24:13 PM »

Hello eborr, thanks for the response.

Currently to solve this I do as you say, I limit the characters and go back to the previous word if the chunk doesn't fit. Because of the uneven font, sometimes the static control seems empty (I have a static control inside a speech balloon of a specific size).

As for the functions I mentioned, those are functions of the Static object http://docs.dead-code.org/wme/generated/scripting_ref_static.html
I wondered, since we have those functions available, whether we have more data available, such as the actual length of the text on the screen or something similar.
Logged

eborr

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 196
    • View Profile
Re: How to check whether the text can fit in a static control
« Reply #3 on: January 14, 2016, 12:47:19 AM »

Don't know if this might help, but I was in my usual bumbling way trying to work out how to fade a single control in a window, didn't work with the static control, but I was able to achieve the result I wanted by using an entity container, and applying my fade method to entity object. As the entity uses a sprite you have full access to all the attributes of a scene object, such as size

Logged

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
Re: How to check whether the text can fit in a static control
« Reply #4 on: January 14, 2016, 09:02:30 PM »

An interesting suggestion eborr, but I am afraid I cannot find how to set text of an entity or an entity container. I think what is needed here is an attribute or function that tells us whether the current text cannot fit in the static control.

It would be possible to achieve what I want if SizeToFit() returned us True when the control is resized or False if no resizing was performed. I would then be able to resize the control back to the original size, reduce the amount of text and try again until the function returned false.
Logged

eborr

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 196
    • View Profile
Re: How to check whether the text can fit in a static control
« Reply #5 on: January 15, 2016, 06:57:52 PM »

you get the entity to "Talk" and set the subtitle.X and subtitle.Y accordingly - you can then set the subtitle width if that would help
Logged

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
Re: How to check whether the text can fit in a static control
« Reply #6 on: January 19, 2016, 06:36:35 PM »

Now I understand what you propose. You are proposing an implementation similar to that of Ghost in the Sheet, which has talking entities where the subtitles are moved.

I guess I should had tried this from the beginning instead of almost completing the game and realising that some dialogue is not displayed properly. I will probably go the way you propose but, for now, I will try to fix my current implementation.

Thank a lot eborr for your time!
Logged
 

Page created in 0.021 seconds with 24 queries.