| !SpecialFX.!Load

Set SFXRes$Dir <Obey$Dir>

| We must ensure that the three support modules required for
| vector anti-aliasing are loaded:

| First, try to load via the standard loading mechanism provided by
| recent versions of AWViewer:
If "<Alias$LoadArtWorksModules>"<>"" Then LoadArtWorksModules
| If that worked, load the module and its choices, then stop:
If "<Alias$LoadArtWorksModules>"<>"" Then RMEnsure SpecialFX 1.03 RMLoad <SFXRes$Dir>.SpecialFX
If "<Alias$LoadArtWorksModules>"<>"" Then Run "<SFXRes$Dir>.IfExists" <Choices$Dir>.SpecialFX Then Obey <Choices$Dir>.SpecialFX
If "<Alias$LoadArtWorksModules>"<>"" Then Obey

| If we've got this far then the above mechanism didn't work.
| So, revert to the old pre-'LoadArtWorksModules' method.

| Try loading the modules from CCShared first (if present):
If "<CCShared$Dir>"="" Then Run "<SFXRes$Dir>.IfExists" System:!CCShared.!Boot Then Obey System:!CCShared.!Boot
RMEnsure GDraw 0.00 Run "<SFXRes$Dir>.IfExists" <CCShared$Dir>.RMStore.GDraw Then RMLoad <CCShared$Dir>.RMStore.GDraw
RMEnsure DitherExtend 0.00 Run "<SFXRes$Dir>.IfExists" <CCShared$Dir>.RMStore.DitherExt Then RMLoad <CCShared$Dir>.RMStore.DitherExt
RMEnsure GSpriteExtend 0.00 Run "<SFXRes$Dir>.IfExists" <CCShared$Dir>.RMStore.SpriteExt Then RMLoad <CCShared$Dir>.RMStore.SpriteExt

| If CCShared is not present, try loading the modules from AWViewer
| (if it doesn't support 'LoadArtWorksModules' then it's out of date!):
RMEnsure GDraw 0.00 Run "<SFXRes$Dir>.IfExists" ArtWorksModules:GDraw Then RMLoad ArtWorksModules:GDraw
RMEnsure DitherExtend 0.00 Run "<SFXRes$Dir>.IfExists" ArtWorksModules:DitherExt Then RMLoad ArtWorksModules:DitherExt
RMEnsure GSpriteExtend 0.00 Run "<SFXRes$Dir>.IfExists" ArtWorksModules:SpriteExt Then RMLoad ArtWorksModules:SpriteExt

| If the modules still haven't been loaded, issue an error:
RMEnsure GDraw 0.00 Error "GDraw support module cannot be found for use with SpecialFX"
RMEnsure DitherExtend 0.00 Error "DitherExtend support module cannot be found for use with SpecialFX"
| Note: GSpriteExtend is *not* essential for the use of SpecialFX,
| and may not be present on all systems, so we don't raise an error
| if it can't be loaded. (It may aid performance if available.)

| Ensure that the SpecialFX module itself is loaded:
RMEnsure SpecialFX 1.03 RMLoad <SFXRes$Dir>.SpecialFX

| Now obey the commands in any choices file
| which has been saved by the SFX Setup application:
Run "<SFXRes$Dir>.IfExists" <Choices$Dir>.SpecialFX Then Obey <Choices$Dir>.SpecialFX