예제 #1
0
        public void Setup(string path, string keyPrefix = "builtin")
        {
            BasePath = path;
            ParseManifest(path);

            if (!ShowAsDashboard && !ShowAsFloating)
            {
                Logger.Fatal("[OVERLAY] Overlay must have show_as_dashboard and/or show_as_floating set to true, both as false is not permitted.");
                return;
            }

            if (!Environment.GetCommandLineArgs().Contains("-debug"))
            {
                DebugMode = false;
            }

            _wkOverlay = new WebKitOverlay(new Uri(EntryPoint), Width, Height, "vrub." + DerivedKey, Name, ShowAsDashboard ? (ShowAsFloating ? OverlayType.Both : OverlayType.Dashboard) : OverlayType.InGame);
            _wkOverlay.BrowserReady            += _wkOverlay_BrowserReady;
            _wkOverlay.BrowserPreInit          += _wkOverlay_BrowserPreInit;
            _wkOverlay.CachePath                = Path.Combine(GetLocalStoragePath(), "Cache");
            _wkOverlay.RequestContextHandler    = new OverlayRequestContextHandler(this);
            _wkOverlay.MouseDeltaTolerance      = MouseDeltaTolerance;
            _wkOverlay.MessageHandler.DebugMode = DebugMode;
            _wkOverlay.FragmentShaderPath       = FragmentShader;

            if (AlphaMask != null)
            {
                SetAlphaMask(AlphaMask);
            }

            _wkOverlay.AllowScrolling = !DisableScrolling;

            _wkOverlay.UpdateInputSettings();

            Attach();
            SetupRenderModels();

            if (Thumbnail != null && _wkOverlay.DashboardOverlay != null)
            {
                string thumbPath = Path.IsPathRooted(Thumbnail) ? Thumbnail : Path.Combine(path, Thumbnail);

                if (File.Exists(thumbPath))
                {
                    _wkOverlay.DashboardOverlay.SetThumbnail(thumbPath);
                }
                else
                {
                    Logger.Warning("[OVERLAY] Failed to locate thumbnail for " + DerivedKey + ": " + thumbPath);
                }
            }

            SetOpacity(Opacity);

            if (ShowAsFloating)
            {
                _wkOverlay.EnableNonDashboardInput = EnableMouseInput;
            }

            _wkOverlay.SchemeHandlers.Add(new CefCustomScheme()
            {
                SchemeName           = "addon",
                SchemeHandlerFactory = new RestrictedPathSchemeHandler("addon", _addon.BasePath),
            });

            _wkOverlay.SchemeHandlers.Add(new CefCustomScheme()
            {
                SchemeName           = "vrub",
                SchemeHandlerFactory = new RestrictedPathSchemeHandler("vrub", PathUtilities.Constants.GlobalStaticResourcesPath),
            });

            _wkOverlay.SchemeHandlers.Add(new CefCustomScheme()
            {
                SchemeName           = "plugin",
                SchemeHandlerFactory = new PluginSchemeHandler(),
            });

            _wkOverlay.EnableKeyboard = EnableKeyboard;

            UpdateWidths();
        }