Esempio n. 1
0
        public static void GetInput(NativeOSWindow parent, Browser browser, bool modal, SendResult <BrowseType> sendResult, Action <String, Action <String> > importCallback, String prompt, String wildcard, String extension)
        {
            BrowserWindow <BrowseType> inputBox = createInputBox(browser, modal, sendResult);

            inputBox.importButton.MouseButtonClick += (source, e) =>
            {
                FileOpenDialog openDialog = new FileOpenDialog(parent, prompt, wildcard: wildcard);
                openDialog.showModal((result, paths) =>
                {
                    if (result == NativeDialogResult.OK)
                    {
                        String path = paths.First();
                        String ext  = Path.GetExtension(path);
                        if (ext.Equals(extension, StringComparison.OrdinalIgnoreCase))
                        {
                            importCallback(path, previewPath =>
                            {
                                ThreadManager.invoke(new Action(() =>
                                {
                                    BrowserNode node = new BrowserNode(Path.GetFileName(previewPath), previewPath);
                                    inputBox.browserTree.Nodes.First().Children.add(inputBox.addNodes(node, node));
                                    inputBox.browserTree.layout();
                                }));
                            });
                        }
                        else
                        {
                            MessageBox.show(String.Format("Cannot open a file with extension '{0}'.", extension), "Can't Load File", MessageBoxStyle.IconWarning | MessageBoxStyle.Ok);
                        }
                    }
                });
            };
        }
Esempio n. 2
0
        public CursorManager(NativeOSWindow window, PointerManager pointerManager)
        {
            this.window         = window;
            this.pointerManager = pointerManager;
            window.Disposed    += window_Disposed;

            pointerManager.ChangeMousePointer += pointerManager_ChangeMousePointer;
        }
        public SingleViewCloneWindow(NativeOSWindow parentWindow, WindowInfo windowInfo, SceneViewController controller, CameraMover cameraMover, String name, BackgroundScene background, int zIndexStart, bool floatOnParent)
            : base(controller, cameraMover, name, background, zIndexStart)
        {
            IntVector2 location = SystemInfo.getDisplayLocation(windowInfo.MonitorIndex);

            location.y          = -1;
            osWindow            = new NativeOSWindow(parentWindow, "Clone Window", location, new IntSize2(windowInfo.Width, windowInfo.Height), floatOnParent);
            this.rendererWindow = (OgreWindow)OgreInterface.Instance.createRendererWindow(new WindowInfo(osWindow, "CloneWindow"));
            this.createBackground(rendererWindow.OgreRenderTarget, true);
            this.RendererWindow = rendererWindow;
            osWindow.show();
            osWindow.Closed += osWindow_Closed;

            transparencyStateName           = controller.ActiveWindow.CurrentTransparencyState;
            controller.ActiveWindowChanged += controller_ActiveWindowChanged;
        }
 public void createCloneWindow(NativeOSWindow parentWindow, WindowInfo windowInfo, bool floatOnParent)
 {
     if (cloneWindow == null)
     {
         CloneCamera cloneCamera = new CloneCamera(this, mainTimer);
         cloneWindow         = new SingleViewCloneWindow(parentWindow, windowInfo, this, cloneCamera, "Clone", background, 0, floatOnParent);
         cloneWindow.Closed += new EventHandler(cloneWindow_Closed);
         if (WindowCreated != null)
         {
             WindowCreated.Invoke(cloneWindow);
         }
         if (camerasCreated)
         {
             cloneWindow.createSceneView(currentScene);
         }
     }
 }
Esempio n. 5
0
        public TextureCompilerGUI(PluginManager pluginManager, NativeOSWindow parent)
            : base("OgreModelEditor.GUI.TextureCompiler.TextureCompilerGUI.layout")
        {
            this.parent        = parent;
            this.pluginManager = pluginManager;

            Button browseSource = window.findWidget("SourceFileBrowser") as Button;

            browseSource.MouseButtonClick += BrowseSource_MouseButtonClick;

            Button browseDest = window.findWidget("DestFileBrowser") as Button;

            browseDest.MouseButtonClick += BrowseDest_MouseButtonClick;

            Button compileButton = window.findWidget("Compile") as Button;

            compileButton.MouseButtonClick += CompileButton_MouseButtonClick;

            Button cleanButton = window.findWidget("Clean") as Button;

            cleanButton.MouseButtonClick += CleanButton_MouseButtonClick;

            source = window.findWidget("SourceFolder") as EditBox;
            dest   = window.findWidget("DestFolder") as EditBox;

            dxt          = new CheckButton(window.findWidget("DXT") as Button);
            bc5          = new CheckButton(window.findWidget("BC5Normal") as Button);
            etc2         = new CheckButton(window.findWidget("ETC2") as Button);
            uncompressed = new CheckButton(window.findWidget("Uncompressed") as Button);

            maxSize            = new NumericEdit(window.findWidget("MaxSize") as EditBox);
            maxSize.AllowFloat = false;
            maxSize.MinValue   = 128;
            maxSize.MaxValue   = int.MaxValue;
            maxSize.IntValue   = 8192;

            uncompressed.Checked = true;
        }
        public ObfuscateArchiveWindow(NativeOSWindow parentWindow)
            : base("Anomaly.GUI.ObfuscateArchive.ObfuscateArchiveWindow.layout")
        {
            this.parentWindow = parentWindow;

            sourceTextBox = window.findWidget("Source") as EditBox;
            destTextBox   = window.findWidget("Destination") as EditBox;

            Button obfuscate = window.findWidget("Obfuscate") as Button;

            obfuscate.MouseButtonClick += obfuscate_MouseButtonClick;

            Button deobfuscate = window.findWidget("Deobfuscate") as Button;

            deobfuscate.MouseButtonClick += deobfuscate_MouseButtonClick;

            Button browseSource = window.findWidget("BrowseSource") as Button;

            browseSource.MouseButtonClick += browseSource_MouseButtonClick;

            Button browseDestination = window.findWidget("BrowseDestination") as Button;

            browseDestination.MouseButtonClick += browseDestination_MouseButtonClick;
        }
Esempio n. 7
0
        private void BuildPluginManager()
        {
            mainWindow = new NativeOSWindow(startup.Title,
                                            new IntVector2(-1, -1),
                                            new IntSize2(CoreConfig.EngineConfig.HorizontalRes, CoreConfig.EngineConfig.VerticalRes));

            services.TryAddSingleton <OSWindow>(mainWindow);       //This is externally owned
            services.TryAddSingleton <NativeOSWindow>(mainWindow); //This is externally owned

            mainWindow.Closed += w =>
            {
                if (PlatformConfig.CloseMainWindowOnShutdown)
                {
                    mainWindow.close();
                }
                this.exit();
            };

            //Setup DPI
            float pixelScale = mainWindow.WindowScaling;

            switch (CoreConfig.ExtraScaling)
            {
            case UIExtraScale.Smaller:
                pixelScale -= .15f;
                break;

            case UIExtraScale.Larger:
                pixelScale += .25f;
                break;
            }

            ScaleHelper._setScaleFactor(pixelScale);

            pluginManager = new PluginManager(CoreConfig.ConfigFile, services);

            services.TryAddSingleton <SystemTimer, NativeSystemTimer>();

            services.TryAddSingleton <UpdateTimer, NativeUpdateTimer>();

            services.TryAddSingleton <InputHandler>(s =>
            {
                return(new NativeInputHandler(s.GetRequiredService <NativeOSWindow>(), CoreConfig.EnableMultitouch));
            });

            services.TryAddSingleton <EventManager>(s =>
            {
                return(new EventManager(s.GetRequiredService <InputHandler>(), Enum.GetValues(typeof(EventLayers))));
            });

            MyGUIInterface.EventLayerKey     = EventLayers.Gui;
            MyGUIInterface.CreateGuiGestures = CoreConfig.EnableMultitouch && PlatformConfig.TouchType == TouchType.Screen;

            OgreInterface.CompressedTextureSupport = CompressedTextureSupport.None;
            OgreInterface.TrackMemoryLeaks         = true;

            //Configure plugins
            pluginManager.OnConfigureDefaultWindow = delegate(out WindowInfo defaultWindow)
            {
                //Setup main window
                defaultWindow              = new WindowInfo(mainWindow, "Primary");
                defaultWindow.Fullscreen   = CoreConfig.EngineConfig.Fullscreen;
                defaultWindow.MonitorIndex = 0;

                if (CoreConfig.EngineConfig.Fullscreen)
                {
                    mainWindow.setSize(CoreConfig.EngineConfig.HorizontalRes, CoreConfig.EngineConfig.VerticalRes);
                    mainWindow.ExclusiveFullscreen = true;
                    defaultWindow.Width            = CoreConfig.EngineConfig.HorizontalRes;
                    defaultWindow.Height           = CoreConfig.EngineConfig.VerticalRes;
                }
                else
                {
                    mainWindow.Maximized = true;
                }
                mainWindow.show();
            };

            //GuiFrameworkCamerasInterface.CameraTransitionTime = MedicalConfig.CameraTransitionTime;
            //GuiFrameworkCamerasInterface.DefaultCameraButton = MedicalConfig.CameraMouseButton;
            GuiFrameworkCamerasInterface.MoveCameraEventLayer   = EventLayers.Cameras;
            GuiFrameworkCamerasInterface.SelectWindowEventLayer = EventLayers.AfterGui;
            GuiFrameworkCamerasInterface.ShortcutEventLayer     = EventLayers.AfterGui;
            GuiFrameworkCamerasInterface.TouchType = PlatformConfig.TouchType;
            GuiFrameworkCamerasInterface.PanKey    = PlatformConfig.PanKey;

            pluginManager.addPluginAssembly(typeof(OgreInterface).Assembly());
            pluginManager.addPluginAssembly(typeof(BulletInterface).Assembly());
            pluginManager.addPluginAssembly(typeof(NativePlatformPlugin).Assembly());
            pluginManager.addPluginAssembly(typeof(MyGUIInterface).Assembly());
            pluginManager.addPluginAssembly(typeof(RocketInterface).Assembly());
            pluginManager.addPluginAssembly(typeof(SoundPluginInterface).Assembly());
            pluginManager.addPluginAssembly(typeof(GuiFrameworkInterface).Assembly());
            pluginManager.addPluginAssembly(typeof(RocketWidgetInterface).Assembly());
            pluginManager.addPluginAssembly(typeof(GuiFrameworkCamerasInterface).Assembly());
            foreach (var assembly in startup.AdditionalPluginAssemblies)
            {
                pluginManager.addPluginAssembly(assembly);
            }
            pluginManager.initializePlugins();

            var scope = pluginManager.GlobalScope;

            var systemTimer  = scope.ServiceProvider.GetRequiredService <SystemTimer>();
            var mainTimer    = scope.ServiceProvider.GetRequiredService <UpdateTimer>();
            var inputHandler = this.InputHandler = scope.ServiceProvider.GetRequiredService <InputHandler>();
            var eventManager = scope.ServiceProvider.GetRequiredService <EventManager>();

            //Intialize the platform
            BulletInterface.Instance.ShapeMargin = 0.005f;

            //Setup framerate cap
            if (PlatformConfig.FpsCap.HasValue)
            {
                //Use platform cap if it is set always
                mainTimer.FramerateCap = PlatformConfig.FpsCap.Value;
            }
            else if (OgreConfig.VSync)
            {
                //Use a unlimited framerate cap if vsync is on since it will cap our
                //framerate for us. If the user has requested a higher rate use it anyway.
                mainTimer.FramerateCap = 0;
            }
            else
            {
                //Otherwise config cap
                mainTimer.FramerateCap = CoreConfig.EngineConfig.FPSCap;
            }

            mainTimer.addUpdateListener(new EventUpdateListener(eventManager));

            pluginManager.setPlatformInfo(mainTimer, eventManager);

            GuiFrameworkInterface.Instance.handleCursors(mainWindow);

            SoundConfig.initialize(CoreConfig.ConfigFile);

            GuiFrameworkInterface.Instance.handleCursors(mainWindow);
            SoundPluginInterface.Instance.setResourceWindow(mainWindow);

            var touchMouseGuiForwarder = new TouchMouseGuiForwarder(eventManager, inputHandler, systemTimer, mainWindow, EventLayers.Last);

            touchMouseGuiForwarder.ForwardTouchesAsMouse = PlatformConfig.ForwardTouchAsMouse;
            var myGuiKeyboard  = new MyGUIOnscreenKeyboardManager(touchMouseGuiForwarder);
            var rocketKeyboard = new RocketWidgetOnscreenKeyboardManager(touchMouseGuiForwarder);
        }
Esempio n. 8
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public AnomalyController(App app, Solution solution, IAnomalyImplementation implementation)
        {
            this.app            = app;
            this.solution       = solution;
            this.implementation = implementation;

            //Create the log.
            logListener = new LogFileListener();
            logListener.openLogFile(AnomalyConfig.DocRoot + "/log.log");
            Log.Default.addLogListener(logListener);

            mainWindow         = new NativeOSWindow(String.Format("{0} - Anomaly", solution.Name), new IntVector2(-1, -1), new IntSize2(AnomalyConfig.EngineConfig.HorizontalRes, AnomalyConfig.EngineConfig.VerticalRes));
            mainWindow.Closed += mainWindow_Closed;

            //Setup DPI
            float pixelScale = mainWindow.WindowScaling;

            ScaleHelper._setScaleFactor(pixelScale);

            var builder = new ServiceCollection();

            //Initialize the plugins
            pluginManager   = new PluginManager(AnomalyConfig.ConfigFile, builder);
            sceneController = new SceneController(pluginManager);
            //Hardcoded assemblies
            MyGUIInterface.EventLayerKey = EventLayers.Main;

            GuiFrameworkCamerasInterface.MoveCameraEventLayer   = EventLayers.Cameras;
            GuiFrameworkCamerasInterface.SelectWindowEventLayer = EventLayers.AfterMain;
            GuiFrameworkCamerasInterface.ShortcutEventLayer     = EventLayers.Main;

            GuiFrameworkEditorInterface.ToolsEventLayers = EventLayers.Tools;

            //Setup microcode cache load
            OgreInterface.MicrocodeCachePath      = Path.Combine(AnomalyConfig.DocRoot, "ShaderCache.mcc");
            OgreInterface.AllowMicrocodeCacheLoad = AnomalyConfig.LastShaderVersion == UnifiedMaterialBuilder.Version;
            AnomalyConfig.LastShaderVersion       = UnifiedMaterialBuilder.Version;

            implementation.AddPlugins(pluginManager);
            pluginManager.OnConfigureDefaultWindow = createWindow;

            //Create core classes
            systemTimer = new NativeSystemTimer();

            mainTimer = new NativeUpdateTimer(systemTimer);
            mainTimer.FramerateCap = AnomalyConfig.EngineConfig.MaxFPS;
            idleHandler            = new IdleHandler(mainTimer.OnIdle);
            inputHandler           = new NativeInputHandler(mainWindow, false);
            eventManager           = new EventManager(inputHandler, Enum.GetValues(typeof(EventLayers)));
            eventUpdate            = new EventUpdateListener(eventManager);

            builder.TryAddSingleton <EventManager>(eventManager); //This is externally owned

            pluginManager.initializePlugins();
            frameClearManager = new FrameClearManager(OgreInterface.Instance.OgrePrimaryWindow.OgreRenderTarget, new Color(0.2f, 0.2f, 0.2f));

            lightManager = pluginManager.RendererPlugin.createSceneViewLightManager();

            //Core resources
            MyGUIInterface.Instance.CommonResourceGroup.addResource(this.GetType().AssemblyQualifiedName, "EmbeddedResource", true);
            OgreResourceGroupManager.getInstance().initializeAllResourceGroups();

            //Intialize the platform
            mainTimer.addUpdateListener(eventUpdate);
            mainTimer.addUpdateListener(updateEventListener);
            pluginManager.setPlatformInfo(mainTimer, eventManager);

            GuiFrameworkInterface.Instance.handleCursors(mainWindow);

            //Layout Chain
            mdiLayout = new MDILayoutManager();

            //Scene views
            sceneViewController      = new SceneViewController(mdiLayout, eventManager, mainTimer, pluginManager.RendererPlugin.PrimaryWindow, MyGUIInterface.Instance.OgrePlatform.RenderManager, null);
            sceneStatsDisplayManager = new SceneStatsDisplayManager(sceneViewController, OgreInterface.Instance.OgrePrimaryWindow.OgreRenderTarget);
            sceneStatsDisplayManager.StatsVisible = true;
            sceneViewController.createWindow("Camera 1", AnomalyConfig.CameraConfig.MainCameraPosition, AnomalyConfig.CameraConfig.MainCameraLookAt, Vector3.Min, Vector3.Max, 0.0f, float.MaxValue, 100);

            virtualTextureLink = new VirtualTextureSceneViewLink(this);

            //Tools
            selectionMovementTools         = new SimObjectMover("SelectionMover", PluginManager.Instance.RendererPlugin, eventManager, sceneViewController);
            selectionMovementTools.Visible = true;
            selectionMovementTools.addMovableObject("Selection", new SelectionMovableObject(selectionController));

            mainForm = new AnomalyMain(this);

            LayoutChain layoutChain = new LayoutChain();

            layoutChain.addLink(new SingleChildChainLink(GUILocationNames.Taskbar, mainForm.LayoutContainer), true);
            layoutChain.addLink(new PopupAreaChainLink(GUILocationNames.FullscreenPopup), true);
            layoutChain.SuppressLayout = true;
            layoutChain.addLink(new MDIChainLink(GUILocationNames.MDI, mdiLayout), true);
            layoutChain.addLink(new PopupAreaChainLink(GUILocationNames.ContentAreaPopup), true);
            layoutChain.addLink(new FinalChainLink("SceneViews", mdiLayout.DocumentArea), true);
            layoutChain.SuppressLayout = false;

            guiManager = new GUIManager();
            guiManager.createGUI(mdiLayout, layoutChain, mainWindow);

            layoutChain.layout();

            splashScreen                = new SplashScreen(mainWindow, 100, "Anomaly.GUI.SplashScreen.SplashScreen.layout", "Anomaly.GUI.SplashScreen.SplashScreen.xml");
            splashScreen.Hidden        += splashScreen_Hidden;
            splashScreen.StatusUpdated += splashScreen_StatusUpdated;
            splashScreen.updateStatus(0, "Loading...");

            idleHandler.runTemporaryIdle(finishInitialization());
        }
        public OgreModelEditorController(App app, String defaultModel)
        {
            this.app = app;

            //Create the log.
            logListener = new LogFileListener();
            logListener.openLogFile(OgreModelEditorConfig.DocRoot + "/log.log");
            Log.Default.addLogListener(logListener);

            //Main window
            mainWindow         = new NativeOSWindow("Ogre Model Editor", new IntVector2(-1, -1), new IntSize2(OgreModelEditorConfig.EngineConfig.HorizontalRes, OgreModelEditorConfig.EngineConfig.VerticalRes));
            mainWindow.Closed += mainWindow_Closed;

            //Setup DPI
            ScaleHelper._setScaleFactor(mainWindow.WindowScaling);

            //Initailize plugins
            MyGUIInterface.EventLayerKey = EventLayers.Main;

            GuiFrameworkCamerasInterface.MoveCameraEventLayer   = EventLayers.Cameras;
            GuiFrameworkCamerasInterface.SelectWindowEventLayer = EventLayers.AfterMain;
            GuiFrameworkCamerasInterface.ShortcutEventLayer     = EventLayers.Main;

            GuiFrameworkEditorInterface.ToolsEventLayers = EventLayers.Tools;

            //Setup microcode cache load
            OgreInterface.MicrocodeCachePath        = Path.Combine(OgreModelEditorConfig.DocRoot, "ShaderCache.mcc");
            OgreInterface.AllowMicrocodeCacheLoad   = OgreModelEditorConfig.LastShaderVersion == UnifiedMaterialBuilder.Version;
            OgreModelEditorConfig.LastShaderVersion = UnifiedMaterialBuilder.Version;
            OgreInterface.TrackMemoryLeaks          = true;
            OgreInterface.CompressedTextureSupport  = OgreModelEditorConfig.CompressedTextureSupport;

            RuntimePlatformInfo.addPath(OgreModelEditorConfig.OpenGLESEmulatorPath);

            pluginManager = new PluginManager(OgreModelEditorConfig.ConfigFile, new ServiceCollection());
            pluginManager.OnConfigureDefaultWindow = createWindow;
            pluginManager.addPluginAssembly(typeof(OgreInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(NativePlatformPlugin).Assembly);
            pluginManager.addPluginAssembly(typeof(MyGUIInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(GuiFrameworkInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(GuiFrameworkCamerasInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(GuiFrameworkEditorInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(GuiFrameworkDebuggingInterface).Assembly);
            pluginManager.initializePlugins();
            frameClearManager = new FrameClearManager(OgreInterface.Instance.OgrePrimaryWindow.OgreRenderTarget, new Color(0.2f, 0.2f, 0.2f));

            lightManager = pluginManager.RendererPlugin.createSceneViewLightManager();

            //Core resources
            MyGUIInterface.Instance.CommonResourceGroup.addResource(this.GetType().AssemblyQualifiedName, "EmbeddedResource", true);
            OgreResourceGroupManager.getInstance().addResourceLocation(GetType().AssemblyQualifiedName, "EmbeddedResource", "DebugShaders", true);
            OgreResourceGroupManager.getInstance().initializeAllResourceGroups();

            //Intialize the platform
            systemTimer = new NativeSystemTimer();

            mainTimer = new NativeUpdateTimer(systemTimer);
            mainTimer.FramerateCap = OgreModelEditorConfig.EngineConfig.MaxFPS;
            idleHandler            = new IdleHandler(mainTimer.OnIdle);

            inputHandler = new NativeInputHandler(mainWindow, false);
            eventManager = new EventManager(inputHandler, Enum.GetValues(typeof(EventLayers)));
            eventUpdate  = new EventUpdateListener(eventManager);
            mainTimer.addUpdateListener(eventUpdate);
            mainTimer.addUpdateListener(updateEventListener);
            pluginManager.setPlatformInfo(mainTimer, eventManager);
            GuiFrameworkInterface.Instance.handleCursors(mainWindow);

            //Layout Chain
            mdiLayout = new MDILayoutManager();

            //Scene views
            sceneViewController      = new SceneViewController(mdiLayout, eventManager, mainTimer, pluginManager.RendererPlugin.PrimaryWindow, MyGUIInterface.Instance.OgrePlatform.RenderManager, null);
            sceneStatsDisplayManager = new SceneStatsDisplayManager(sceneViewController, OgreInterface.Instance.OgrePrimaryWindow.OgreRenderTarget);
            sceneStatsDisplayManager.StatsVisible = true;
            sceneViewController.createWindow("Camera 1", OgreModelEditorConfig.CameraConfig.MainCameraPosition, OgreModelEditorConfig.CameraConfig.MainCameraLookAt, Vector3.Min, Vector3.Max, 0.0f, float.MaxValue, 100);

            virtualTextureLink = new VirtualTextureSceneViewLink(this);

            materialController = new MaterialController(this);

            //Tools
            objectMover = new SimObjectMover("ModelMover", PluginManager.Instance.RendererPlugin, eventManager, sceneViewController);

            mainForm = new OgreModelEditorMain(this);

            LayoutChain layoutChain = new LayoutChain();

            layoutChain.addLink(new SingleChildChainLink(GUILocationNames.Taskbar, mainForm.LayoutContainer), true);
            layoutChain.addLink(new PopupAreaChainLink(GUILocationNames.FullscreenPopup), true);
            layoutChain.SuppressLayout = true;
            layoutChain.addLink(new MDIChainLink(GUILocationNames.MDI, mdiLayout), true);
            layoutChain.addLink(new PopupAreaChainLink(GUILocationNames.ContentAreaPopup), true);
            layoutChain.addLink(new FinalChainLink("SceneViews", mdiLayout.DocumentArea), true);
            layoutChain.SuppressLayout = false;

            guiManager = new GUIManager(mdiLayout, mainWindow);
            guiManager.createGUILayout(layoutChain);

            layoutChain.layout();

            splashScreen                = new SplashScreen(mainWindow, 100, "OgreModelEditor.GUI.SplashScreen.SplashScreen.layout", "OgreModelEditor.GUI.SplashScreen.SplashScreen.xml");
            splashScreen.Hidden        += splashScreen_Hidden;
            splashScreen.StatusUpdated += splashScreen_StatusUpdated;
            splashScreen.updateStatus(0, "Loading...");

            idleHandler.runTemporaryIdle(finishInitialization(defaultModel));
        }
        public MedicalController(NativeOSWindow mainWindow)
        {
            //Create the log.
            logListener = new LogFileListener();
            logListener.openLogFile(MedicalConfig.LogFile);
            Log.Default.addLogListener(logListener);
            Log.ImportantInfo("Running from directory {0}", FolderFinder.ExecutableFolder);

            //Create pluginmanager
            pluginManager = new PluginManager(MedicalConfig.ConfigFile, services);

            //Configure the filesystem
            VirtualFileSystem archive = VirtualFileSystem.Instance;

            //Setup microcode cache load
            OgreInterface.MicrocodeCachePath      = Path.Combine(FolderFinder.LocalPrivateDataFolder, "ShaderCache.mcc");
            OgreInterface.AllowMicrocodeCacheLoad = MedicalConfig.LastShaderVersion == UnifiedMaterialBuilder.Version;
            OgreInterface.TrackMemoryLeaks        = MedicalConfig.TrackMemoryLeaks;
            MedicalConfig.LastShaderVersion       = UnifiedMaterialBuilder.Version;

            MyGUIInterface.EventLayerKey     = EventLayers.Gui;
            MyGUIInterface.CreateGuiGestures = MedicalConfig.EnableMultitouch && PlatformConfig.TouchType == TouchType.Screen;
            MyGUIInterface.TrackMemoryLeaks  = MedicalConfig.TrackMemoryLeaks;

            RuntimePlatformInfo.addPath(MedicalConfig.OpenGLESEmulatorPath);

            //Configure plugins
            pluginManager.OnConfigureDefaultWindow = delegate(out WindowInfo defaultWindow)
            {
                //Setup main window
                defaultWindow              = new WindowInfo(mainWindow, "Primary");
                defaultWindow.Fullscreen   = MedicalConfig.EngineConfig.Fullscreen;
                defaultWindow.MonitorIndex = 0;

                if (MedicalConfig.EngineConfig.Fullscreen)
                {
                    mainWindow.setSize(MedicalConfig.EngineConfig.HorizontalRes, MedicalConfig.EngineConfig.VerticalRes);
                    mainWindow.ExclusiveFullscreen = true;
                    defaultWindow.Width            = MedicalConfig.EngineConfig.HorizontalRes;
                    defaultWindow.Height           = MedicalConfig.EngineConfig.VerticalRes;
                }
                else
                {
                    mainWindow.Maximized = true;
                }
                mainWindow.show();
            };

            GuiFrameworkCamerasInterface.CameraTransitionTime   = MedicalConfig.CameraTransitionTime;
            GuiFrameworkCamerasInterface.DefaultCameraButton    = MedicalConfig.CameraMouseButton;
            GuiFrameworkCamerasInterface.MoveCameraEventLayer   = EventLayers.Cameras;
            GuiFrameworkCamerasInterface.SelectWindowEventLayer = EventLayers.AfterGui;
            GuiFrameworkCamerasInterface.ShortcutEventLayer     = EventLayers.Gui;
            GuiFrameworkCamerasInterface.TouchType = PlatformConfig.TouchType;
            GuiFrameworkCamerasInterface.PanKey    = PlatformConfig.PanKey;

            GuiFrameworkEditorInterface.ToolsEventLayers = EventLayers.Tools;

            pluginManager.addPluginAssembly(typeof(OgreInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(BulletInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(NativePlatformPlugin).Assembly);
            pluginManager.addPluginAssembly(typeof(MyGUIInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(RocketInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(SoundPluginInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(BEPUikInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(SimulationPlugin).Assembly);
            pluginManager.addPluginAssembly(typeof(GuiFrameworkInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(RocketWidgetInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(GuiFrameworkCamerasInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(GuiFrameworkEditorInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(GuiFrameworkDebuggingInterface).Assembly);
            pluginManager.initializePlugins();

            performanceMetricTimer = new NativeSystemTimer();
            PerformanceMonitor.setupEnabledState(performanceMetricTimer);

            //Intialize the platform
            BulletInterface.Instance.ShapeMargin = 0.005f;
            systemTimer = new NativeSystemTimer();

            mainTimer = new NativeUpdateTimer(systemTimer);

            if (OgreConfig.VSync && MedicalConfig.EngineConfig.FPSCap < 300)
            {
                //Use a really high framerate cap if vsync is on since it will cap our
                //framerate for us. If the user has requested a higher rate use it anyway.
                mainTimer.FramerateCap = 300;
            }
            else
            {
                mainTimer.FramerateCap = MedicalConfig.EngineConfig.FPSCap;
            }

            inputHandler = new NativeInputHandler(mainWindow, MedicalConfig.EnableMultitouch);
            eventManager = new EventManager(inputHandler, Enum.GetValues(typeof(EventLayers)));
            eventUpdate  = new EventUpdateListener(eventManager);
            mainTimer.addUpdateListener(eventUpdate);
            pluginManager.setPlatformInfo(mainTimer, eventManager);
            medicalUpdate = new MedicalUpdate(this);
            mainTimer.addUpdateListener(medicalUpdate);

            //Initialize controllers
            medicalScene      = new MedicalSceneController(pluginManager);
            frameClearManager = new FrameClearManager(OgreInterface.Instance.OgrePrimaryWindow.OgreRenderTarget);

            SoundConfig.initialize(MedicalConfig.ConfigFile);

            GuiFrameworkInterface.Instance.handleCursors(mainWindow);
            SoundPluginInterface.Instance.setResourceWindow(mainWindow);

            TouchMouseGuiForwarder = new TouchMouseGuiForwarder(eventManager, inputHandler, systemTimer, mainWindow, EventLayers.Last);
            TouchMouseGuiForwarder.ForwardTouchesAsMouse = PlatformConfig.ForwardTouchAsMouse;
            var myGuiKeyboard  = new MyGUIOnscreenKeyboardManager(TouchMouseGuiForwarder);
            var rocketKeyboard = new RocketWidgetOnscreenKeyboardManager(TouchMouseGuiForwarder);
        }
 /// <summary>
 /// Handle changing the cursors for a given NativeOSWindow automatically. This will stop managing cursors
 /// when the window is disposed.
 /// </summary>
 /// <param name="osWindow"></param>
 public void handleCursors(NativeOSWindow osWindow)
 {
     new CursorManager(osWindow, PointerManager.Instance);
 }