Question about layers

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

Question about layers

Post by Allanon » Thu Feb 24, 2011 11:34 am

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
----------------------------
[Allanon] Fabio Falcucci
AMC - Creative Development // Docs Site // Support Forum
Support me on Patreon for Hollywood libraries!

Bugala
Posts: 784
Joined: Sun Feb 14, 2010 7:11 pm

Re: Question about layers

Post by Bugala » Thu Feb 24, 2011 2:03 pm

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: 461
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: Question about layers

Post by Allanon » Thu Feb 24, 2011 5:48 pm

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.
----------------------------
[Allanon] Fabio Falcucci
AMC - Creative Development // Docs Site // Support Forum
Support me on Patreon for Hollywood libraries!

User avatar
airsoftsoftwair
Posts: 3113
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Question about layers

Post by airsoftsoftwair » Sat Feb 26, 2011 11:38 am

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: 461
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: Question about layers

Post by Allanon » Sat Feb 26, 2011 3:22 pm

Thank you Andreas!
Your sample code is really helpful, I'll try it ASAP :)
----------------------------
[Allanon] Fabio Falcucci
AMC - Creative Development // Docs Site // Support Forum
Support me on Patreon for Hollywood libraries!

User avatar
airsoftsoftwair
Posts: 3113
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Question about layers

Post by airsoftsoftwair » Sat Feb 26, 2011 10:07 pm

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: 461
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: Question about layers

Post by Allanon » Sat Feb 26, 2011 10:50 pm

Oki, thank you ;)
----------------------------
[Allanon] Fabio Falcucci
AMC - Creative Development // Docs Site // Support Forum
Support me on Patreon for Hollywood libraries!

User avatar
Allanon
Posts: 461
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: Question about layers

Post by Allanon » Sun Feb 27, 2011 12:04 am

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-)
----------------------------
[Allanon] Fabio Falcucci
AMC - Creative Development // Docs Site // Support Forum
Support me on Patreon for Hollywood libraries!

User avatar
airsoftsoftwair
Posts: 3113
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Question about layers

Post by airsoftsoftwair » Sun Feb 27, 2011 12:07 pm

Hmm, I don't get that, why do you think should this fail?

User avatar
Allanon
Posts: 461
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: Question about layers

Post by Allanon » Sun Feb 27, 2011 9:41 pm

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
----------------------------
[Allanon] Fabio Falcucci
AMC - Creative Development // Docs Site // Support Forum
Support me on Patreon for Hollywood libraries!

Post Reply