Ejemplo n.º 1
0
        public TimeSpan GetTime()
        {
            FutureJSValue result  = View.ExecuteJavascriptWithResult("getMinutes()");
            var           minutes = 0;

            int.TryParse(result.Get().ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out minutes);

            result = View.ExecuteJavascriptWithResult("getSeconds()");
            var seconds = 0;

            int.TryParse(result.Get().ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out seconds);

            return(new TimeSpan(0, minutes, seconds));
        }
Ejemplo n.º 2
0
        public int GetMoves()
        {
            FutureJSValue result = View.ExecuteJavascriptWithResult("getMoves()");
            var           moves  = 0;

            int.TryParse(result.Get().ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out moves);

            return(moves);
        }
Ejemplo n.º 3
0
        public override void OnCallback(string name, JSValue[] args)
        {
            if (name.Equals("MainMenuClick"))
            {
                base.OnCallback(name, args);

                var uiView = UIManager.GetByType(UIType.Main);
                UIManager.SetView(uiView);
            }
            else if (name.Equals("ApplyClick"))
            {
                base.OnCallback(name, args);

                // Get is full screen.
                FutureJSValue result = View.ExecuteJavascriptWithResult("getIsFullScreen()");
                Helpers.GameSettings.FullScreen = result.Get().ToBoolean();

                // Get video mode.
                result = View.ExecuteJavascriptWithResult("getVideoMode()");
                var idx = 0;
                int.TryParse(result.Get().ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out idx);
                Helpers.GameSettings.ScreenMode = videoModes[idx];

                // Get antialiasing value.
                result = View.ExecuteJavascriptWithResult("getAntialiasingValue()");
                var value = 0;
                int.TryParse(result.Get().ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out value);
                Helpers.GameSettings.Antialiasing = value;
                View.SetProperty("antialiasing", new JSValue(Helpers.GameSettings.Antialiasing));

                // Get music volume.
                result = View.ExecuteJavascriptWithResult("getMusicVolume()");
                var musicVolume = 0;
                int.TryParse(result.Get().ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out musicVolume);
                Helpers.GameSettings.MusicVolume = musicVolume;

                // Get fx volume.
                result = View.ExecuteJavascriptWithResult("getFXVolume()");
                var fxVolume = 0;
                int.TryParse(result.Get().ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out fxVolume);
                Helpers.GameSettings.FXVolume = fxVolume;

                // Save settings.
                Helpers.SaveSettings();

                // Apply video changes.
                Core.Settings.ScreenMode      = videoModes[idx];
                Core.Settings.MultisampleType = Helpers.GetMultisample(Helpers.GameSettings.Antialiasing);

                if (Helpers.GameSettings.FullScreen)
                {
                    Core.SwitchFullscreen();
                }
                else
                {
                    Core.SwitchWindowed();
                }

                var uiView = UIManager.GetByType(UIType.Main);
                UIManager.SetView(uiView);
            }
            else if (name.Equals("MusicVolumeChanged"))
            {
                var musicVolume = 0;
                int.TryParse(args[0].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out musicVolume);
                Helpers.GameSettings.MusicVolume = musicVolume;
                ApplySoundChanges();
            }
            else if (name.Equals("FxVolumeChanged"))
            {
                var fxVolume = 0;
                int.TryParse(args[0].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out fxVolume);
                Helpers.GameSettings.FXVolume = fxVolume;
                ApplySoundChanges();
            }
        }