Question about layers

Discuss any general programming issues here
Post Reply
User avatar
Allanon
Posts: 732
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Question about layers

Post by Allanon »

Hello,
I was wondering if there is a way to check if layers are enabled or not.
I've looked through the docs but the only thing I've found is query GetAttribute to know how many layers are currently attached to the associated bgpic of a given display, but of course this solution is not safe, for example if the layers have been enabled just before my check.

Any hints?

Thank in advance
:D
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

Re: Question about layers

Post by Bugala »

Dont know actual command, but program wise in normal cases it shouldnt be hard to put a variable my_islayerson=0 or 1 and keep changing it depending if you took layers on or off.
User avatar
Allanon
Posts: 732
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: Question about layers

Post by Allanon »

Hi Bugala and thank you for your suggestion but it doesn't help :)
That's why I'm actually enhancing ScuiLib and I need to know if layer are enabled from Hollywood because the ScuiLib user may use layers or not and I cannot know this information in advance ;)
Strictly talking I've to make a floating object and if user is using layers I will build this object using layers, if the user is not using layers I will make this floating object using a sprite.
I'd like to give the freedom to switch layers on/off to the final user.
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Question about layers

Post by airsoftsoftwair »

I'm afraid that's currently not possible. I'll add a new attribute for this for the next version. Until then, you can use the following workaround:

Code: Select all

Function p_LayersEnabled()

ExitOnError(False)
GetAttribute(#LAYER, 1, #ATTRWIDTH)
Local code = GetLastError()
ExitOnError(True)

Return(IIf(code = 1078, False, True))
EndFunction
This should do the job :)
User avatar
Allanon
Posts: 732
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: Question about layers

Post by Allanon »

Thank you Andreas!
Your sample code is really helpful, I'll try it ASAP :)
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Question about layers

Post by airsoftsoftwair »

By the way, keep in mind that layers enabled/disabled is a setting that is local to each display. So if you have multiple displays opened, there could be differences between them, e.g. layers enabled in display 1, but disabled in display 2, etc.
User avatar
Allanon
Posts: 732
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: Question about layers

Post by Allanon »

Oki, thank you ;)
User avatar
Allanon
Posts: 732
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: Question about layers

Post by Allanon »

Andreas wrote:I'm afraid that's currently not possible. I'll add a new attribute for this for the next version. Until then, you can use the following workaround:

Code: Select all

Function p_LayersEnabled()

ExitOnError(False)
GetAttribute(#LAYER, 1, #ATTRWIDTH)
Local code = GetLastError()
ExitOnError(True)

Return(IIf(code = 1078, False, True))
EndFunction
This should do the job :)
Hi Andreas,
I was thinking that if the Layer have been enabled just before the check this function will fail... but better then nothing... 8-)
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Question about layers

Post by airsoftsoftwair »

Hmm, I don't get that, why do you think should this fail?
User avatar
Allanon
Posts: 732
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: Question about layers

Post by Allanon »

Sorry Andreas,
I've misread your example, you have included a check with the specific error code and not against a generic error, wrongly I was thinking that a generic error check could have caused the function failing...
I'm a bit out of phase in this period, sorry again :D
Post Reply