Пример #1
0
 public override void clicked(TaskPositioner taskPositioner)
 {
     if (Plugin.AtlasPluginManager.allDependenciesLoadedFor(this.Plugin))
     {
         String fullContextPath = Path.Combine(Plugin.PluginRootFolder, ContextFile).Replace('\\', '/');
         VirtualFilesystemResourceProvider resourceProvider = new VirtualFilesystemResourceProvider(Path.GetDirectoryName(fullContextPath));
         try
         {
             AnomalousMvcContext context;
             using (Stream stream = resourceProvider.openFile(Path.GetFileName(fullContextPath)))
             {
                 context = Plugin.MvcCore.loadContext(stream);
             }
             context.RuntimeName = UniqueName;
             context.setResourceProvider(resourceProvider);
             Plugin.TimelineController.setResourceProvider(resourceProvider);
             Plugin.MvcCore.startRunningContext(context);
         }
         catch (Exception ex)
         {
             Log.Error("Cannot load context '{0}'\nReason: {1}", ContextFile, ex.Message);
         }
     }
     else
     {
         MessageBox.show("Additional files needed to run this task. Would you like to download them now?", "Files Needed", MessageBoxStyle.IconQuest | MessageBoxStyle.Yes | MessageBoxStyle.No, result =>
         {
             if (result == MessageBoxStyle.Yes)
             {
                 Plugin.AtlasPluginManager.requestDependencyDownloadFor(this.Plugin);
             }
         });
     }
 }
Пример #2
0
 public override void clicked(TaskPositioner taskPositioner)
 {
     if (Plugin.AtlasPluginManager.allDependenciesLoadedFor(this.Plugin))
     {
         VirtualFilesystemResourceProvider resourceProvider = new VirtualFilesystemResourceProvider(Plugin.PluginRootFolder);
         try
         {
             Slideshow slideshow;
             using (Stream stream = resourceProvider.openFile(SlideshowFile))
             {
                 slideshow = SharedXmlSaver.Load <Slideshow>(stream);
             }
             if (slideshow.Version == Slideshow.CurrentVersion)
             {
                 AnomalousMvcContext context = slideshow.createContext(resourceProvider, Plugin.GuiManager);
                 context.RuntimeName = UniqueName;
                 context.setResourceProvider(resourceProvider);
                 Plugin.TimelineController.setResourceProvider(resourceProvider);
                 Plugin.MvcCore.startRunningContext(context);
             }
             else
             {
                 MessageBox.show(String.Format("Cannot run slideshow \"{0}.\" It was created in a different version of Anomalous Medical.\nYou will need to download an updated version.", Name), "Error", MessageBoxStyle.IconError | MessageBoxStyle.Ok);
                 InlineRmlUpgradeCache.removeSlideshowPanels(slideshow);
             }
         }
         catch (Exception ex)
         {
             Log.Error("Cannot load context '{0}'\nReason: {1}", SlideshowFile, ex.Message);
         }
     }
     else
     {
         MessageBox.show("Additional files needed to run this task. Would you like to download them now?", "Files Needed", MessageBoxStyle.IconQuest | MessageBoxStyle.Yes | MessageBoxStyle.No, result =>
         {
             if (result == MessageBoxStyle.Yes)
             {
                 Plugin.AtlasPluginManager.requestDependencyDownloadFor(this.Plugin);
             }
         });
     }
 }
Пример #3
0
        private IEnumerable <IdleStatus> runSplashScreen()
        {
            finishedSplash = false;
            if (String.IsNullOrEmpty(this.PrimaryArchive))
            {
                allowSplashRestarts = true;
                if (DataFileMissing != null)
                {
                    DataFileMissing.Invoke(this, controller);
                }
                else
                {
                    MessageBox.show("Could not find resource archive. Please reinstall Anomalous Medical.", "Resource Archive Error", MessageBoxStyle.Ok | MessageBoxStyle.IconError, result =>
                    {
                        controller.exit();
                    });
                }
                yield break;
            }

            splashScreen.updateStatus(InitializingCorePosition, "Initializing Core");
            yield return(IdleStatus.Ok);

            //Configure the filesystem
            VirtualFileSystem archive = VirtualFileSystem.Instance;
            //Add primary archive
            bool mainArchiveAdded = archive.addArchive(this.PrimaryArchive);

            controller.addWorkingArchive();

            var resourceManager = PluginManager.Instance.createLiveResourceManager("AnomalousMedical"); //We don't ever unload the shaders, so this can be garbage collected after its done here.
            var ogreResources   = resourceManager.getSubsystemResource("Ogre");

            commonResources = ogreResources.addResourceGroup("Common");

            controller.initializeControllers(createBackground(), new LicenseManager(MedicalConfig.LicenseFile));
            controller.LicenseManager.getKey(processKeyResults);
            licenseDisplay.setSceneViewController(controller.SceneViewController);

            //GUI
            splashScreen.updateStatus(CreatingGuiPosition, "Creating GUI");
            yield return(IdleStatus.Ok);

            //Layout Chain
            LayoutChain layoutChain = new LayoutChain();

            layoutChain.addLink(new SingleChildChainLink(GUILocationNames.Notifications, controller.NotificationManager.LayoutContainer), true);
            layoutChain.addLink(new PopupAreaChainLink(GUILocationNames.FullscreenPopup), true);
            layoutChain.SuppressLayout = true;
            editorBorder = new BorderLayoutChainLink(GUILocationNames.EditorBorderLayout);
            layoutChain.addLink(editorBorder, true);
            layoutChain.addLink(new MDIChainLink(GUILocationNames.MDI, controller.MDILayout), true);
            layoutChain.addLink(new PopupAreaChainLink(GUILocationNames.ContentAreaPopup), true);
            contentArea = new BorderLayoutChainLink(GUILocationNames.ContentArea);
            layoutChain.addLink(contentArea, true);
            layoutChain.addLink(new FinalChainLink("SceneViews", controller.MDILayout.DocumentArea), true);
            layoutChain.SuppressLayout = false;
            layoutChain.layout();

            controller.createGUI(layoutChain);
            controller.GUIManager.setMainInterfaceEnabled(false);
            controller.GUIManager.Disposing += GUIManager_Disposing;

            //Scene Load
            uint   currentPosition = LoadingScenePosition;
            String message         = "Loading Scene";
            bool   updateStatus    = true;
            bool   firstOgre       = true;

            splashScreen.updateStatus(currentPosition, message);
            yield return(IdleStatus.Ok);

            String           sceneToLoad           = DefaultScene;
            ResourceProvider sceneResourceProvider = new VirtualFilesystemResourceProvider();

            if (!mainArchiveAdded && !sceneResourceProvider.exists(sceneToLoad))
            {
                //Make sure we have one of our scenes
                sceneToLoad           = "Empty.sim.xml";
                sceneResourceProvider = new EmbeddedResourceProvider(GetType().Assembly, "Medical.Resources.");
                controller.NotificationManager.showNotification("No data files found.\nPlease reinstall.", MyGUIResourceNames.ErrorIcon);
            }

            foreach (var status in controller.openNewSceneStatus(sceneToLoad, sceneResourceProvider))
            {
                switch (status.Subsystem)
                {
                case OgreInterface.PluginName:
                    if (status.NumItems != 0)
                    {
                        currentPosition = LoadingScenePosition + (uint)(status.CurrentPercent * LoadingSceneDelta);
                        message         = "Loading Artwork";
                        updateStatus    = firstOgre || currentPosition > splashScreen.Position;
                        firstOgre       = false;
                    }
                    break;

                default:
                    updateStatus = true;
                    if (status.Message != null)
                    {
                        message = status.Message;
                    }
                    else
                    {
                        message = "Loading Scene";
                    }
                    break;
                }

                if (updateStatus)
                {
                    controller.VirtualTextureManager.update();
                    splashScreen.updateStatus(currentPosition, message);
                }

                yield return(IdleStatus.Ok);
            }

            finishedSplash = true;

            if (!foundLicense)
            {
                splashScreen.updateStatus(WaitingForLicensePosition, "Waiting for License");
            }
            checkCompleteSplash();
            yield return(IdleStatus.Ok);
        }