public IJSResponse GetDeviceInPort(IJSRequest request)
        {
            IPlatformInfo platform = this.CoreInstance.Platforms[request.GetParameter("platform")];
            int port = int.Parse(request.GetParameter("port"));

            return new JSResponse(request, this.CoreInstance.Get<IControllerPortsDatabase>().GetDeviceInPort(platform, port));
        }
Пример #2
0
 public IJSResponse SetPreference(IJSRequest request)
 {
     IPlatformInfo platform = this.CoreInstance.Platforms[request.GetParameter("platform")];
     string preference = request.GetParameter("preference");
     string value = request.GetParameter("value");
     switch (preference)
     {
         case "emulator":
             if (this.CoreInstance.Get<IPluginManager>().Plugins<IEmulatorBridge>().ContainsKey(value))
             {
                 this.CoreInstance.Get<IPlatformPreferenceDatabase>().SetEmulator(platform, value);
                 return new JSResponse(request, "Emulator set to {value}", true); //return emulator that was set
             }
             throw new ArgumentException("Emulator Not Found", new KeyNotFoundException());
         case "scraper":
             if (this.CoreInstance.Get<IPluginManager>().Plugins<IEmulatorBridge>().ContainsKey(value))
             {
                 this.CoreInstance.Get<IPlatformPreferenceDatabase>().SetScraper(platform, value);
                 return new JSResponse(request, $"Scraper set to {value}", true); //return scraper that was set
             }
             throw new ArgumentException("Scraper Not Found", new KeyNotFoundException());
         default:
             throw new ArgumentException("Unknown preference type");
     }
 }
Пример #3
0
 public IJSResponse GetFlagDefaultValue(IJSRequest request)
 {
     string emulator = request.GetParameter("emulator");
     string key = request.GetParameter("key");
     IEmulatorBridge bridge = this.CoreInstance.Get<IPluginManager>().Plugins<IEmulatorBridge>()[emulator];
     IConfigurationFlag flag = bridge.ConfigurationFlags[key];
     return new JSResponse(request, bridge.ConfigurationFlagStore.GetDefaultValue(flag.Key, flag.Type));
 }
Пример #4
0
 public IJSResponse SetGameVideo(IJSRequest request)
 {
     string cacheKey = request.GetParameter("id");
     Uri imageUri = new Uri(request.GetParameter("url"));
     IGameMediaCache gameCache = new GameMediaCache(cacheKey);
     gameCache.SetBoxartBack(imageUri);
     return new JSResponse(request, $"{gameCache.CacheKey}/{gameCache.GameVideoFileName}");
 }
Пример #5
0
 public IJSResponse GetFlagDefaultValues(IJSRequest request)
 {
     string emulator = request.GetParameter("emulator");
     string key = request.GetParameter("key");
     IEmulatorBridge bridge = this.CoreInstance.Get<IPluginManager>().Plugins<IEmulatorBridge>()[emulator];
     IDictionary<string, dynamic> flags = bridge.ConfigurationFlags.ToDictionary(flag => flag.Value.Key, flag => bridge.ConfigurationFlagStore.GetDefaultValue(flag.Value.Key, flag.Value.Type));
     return new JSResponse(request, flags);
 }
 public IJSResponse GetDeviceInPorts(IJSRequest request)
 {
     IPlatformInfo platform = this.CoreInstance.Platforms[request.GetParameter("platform")];
     string[] ports = new string[9];
     for(int i = 1; i <= 8; i++){
         ports[i] = this.CoreInstance.Get<IControllerPortsDatabase>().GetDeviceInPort(platform, i);
     }
     return new JSResponse(request, ports);
 }
Пример #7
0
        public IJSResponse AddGameInfo(IJSRequest request)
        {
            string gameinfo_pre = request.GetParameter("gameinfo");
            IGameInfo game = GameInfo.FromJson(JsonConvert.DeserializeObject(gameinfo_pre));
            var gamePreAddEvent = new GamePreAddEventArgs(this.CoreInstance, game, this.CoreInstance.Get<IGameDatabase>());
            SnowflakeEventManager.EventSource.RaiseEvent(gamePreAddEvent);
            if (!gamePreAddEvent.Cancel)
            {
                game = gamePreAddEvent.GameInfo;
                this.CoreInstance.Get<IGameDatabase>().AddGame(game);
                var gameAddEvent = new GameAddEventArgs(this.CoreInstance, game, this.CoreInstance.Get<IGameDatabase>());
                SnowflakeEventManager.EventSource.RaiseEvent(gameAddEvent);

            }
            return new JSResponse(request, game, true);
        }
Пример #8
0
 public IJSResponse SetFlagValue(IJSRequest request)
 {
     string emulator = request.GetParameter("emulator");
     string id = request.GetParameter("id");
     string key = request.GetParameter("key");
     string value = request.GetParameter("value");
     IEmulatorBridge bridge = this.CoreInstance.Get<IPluginManager>().Plugins<IEmulatorBridge>()[emulator];
     IGameInfo game = this.CoreInstance.Get<IGameDatabase>().GetGameByUUID(id);
     IConfigurationFlag flag = bridge.ConfigurationFlags[key];
     dynamic castedValue = bridge.ConfigurationFlagStore.GetDefaultValue(flag.Key, flag.Type);
     switch (flag.Type)
     {
         case ConfigurationFlagTypes.BOOLEAN_FLAG:
             castedValue = bool.Parse(value);
             break;
         case ConfigurationFlagTypes.INTEGER_FLAG:
             castedValue = int.Parse(value);
             break;
         case ConfigurationFlagTypes.SELECT_FLAG:
             castedValue = int.Parse(value);
             break;
     }
     bridge.ConfigurationFlagStore.SetValue(game, flag.Key, castedValue, flag.Type);
     return new JSResponse(request, bridge.ConfigurationFlagStore.GetValue(game, flag.Key, flag.Type));
 }
Пример #9
0
 public IJSResponse GetGamesByPlatform(IJSRequest request)
 {
     string platform = request.GetParameter("platform");
     return new JSResponse(request, this.CoreInstance.Get<IGameDatabase>().GetGamesByPlatform(platform));
 }
Пример #10
0
        public IJSResponse GetGameResultsUsingScraper(IJSRequest request)
        {
            string filename = request.GetParameter("filename");
            string platform = request.GetParameter("platform");
            string scraperId = request.GetParameter("scraper");

            return new JSResponse(request, new ScrapeService(this.CoreInstance.Platforms[platform], scraperId, this.CoreInstance).GetGameResults(filename));
        }
Пример #11
0
 public IJSResponse GetFlags(IJSRequest request)
 {
     string emulator = request.GetParameter("emulator");
     IEmulatorBridge bridge = this.CoreInstance.Get<IPluginManager>().Plugins<IEmulatorBridge>()[emulator];
     return new JSResponse(request, bridge.ConfigurationFlags);
 }
Пример #12
0
 public IJSResponse SetGamepadAbstraction(IJSRequest request)
 {
     string deviceName = request.GetParameter("device");
     string _profileType = request.GetParameter("profiletype");
     IGamepadAbstraction gamepadAbstraction;
     try
     {
         gamepadAbstraction = this.CoreInstance.Get<IGamepadAbstractionDatabase>()[deviceName];
     }
     catch
     {
         ControllerProfileType profileType;
         gamepadAbstraction = Enum.TryParse(_profileType, true, out profileType) ?
             new GamepadAbstraction(deviceName, profileType) : new GamepadAbstraction(deviceName, ControllerProfileType.GAMEPAD_PROFILE);
     }
     IDictionary<string, string> changes = JsonConvert.DeserializeObject<Dictionary<string, string>>(request.GetParameter("inputconfig"));
     foreach (KeyValuePair<string, string> change in changes)
     {
         gamepadAbstraction[change.Key] = change.Value;
     }
     this.CoreInstance.Get<IGamepadAbstractionDatabase>()[deviceName] = gamepadAbstraction;
     return new JSResponse(request, this.CoreInstance.Get<IGamepadAbstractionDatabase>()[deviceName]);
 }
Пример #13
0
 public IJSResponse GetAbstractionForDevice(IJSRequest request)
 {
     string deviceName = request.GetParameter("device");
     IGamepadAbstraction gamepadAbstraction = this.CoreInstance.Get<IGamepadAbstractionDatabase>()[deviceName];
     return new JSResponse(request, gamepadAbstraction);
 }
Пример #14
0
 public IJSResponse GetScreenshots(IJSRequest request)
 {
     string cacheKey = request.GetParameter("id");
     return new JSResponse(request, new GameScreenshotCache(cacheKey).ScreenshotCollection);
 }
Пример #15
0
        public IJSResponse SetFlagValues(IJSRequest request)
        {
            string emulator = request.GetParameter("emulator");
            string id = request.GetParameter("id");
            string values_pre = request.GetParameter("values");
            IDictionary<string, string> values = JsonConvert.DeserializeObject<IDictionary<string, string>>(values_pre);
            IEmulatorBridge bridge = this.CoreInstance.Get<IPluginManager>().Plugins<IEmulatorBridge>()[emulator];
            IGameInfo game = this.CoreInstance.Get<IGameDatabase>().GetGameByUUID(id);
            foreach (KeyValuePair<string, string> value in values)
            {
                IConfigurationFlag flag = bridge.ConfigurationFlags[value.Key];
                dynamic castedValue = bridge.ConfigurationFlagStore.GetDefaultValue(flag.Key, flag.Type);
                switch (flag.Type)
                {
                    case ConfigurationFlagTypes.BOOLEAN_FLAG:
                        castedValue = bool.Parse(value.Value);
                        break;
                    case ConfigurationFlagTypes.INTEGER_FLAG:
                        castedValue = int.Parse(value.Value);
                        break;
                    case ConfigurationFlagTypes.SELECT_FLAG:
                        castedValue = int.Parse(value.Value);
                        break;
                }
                bridge.ConfigurationFlagStore.SetValue(game, flag.Key, castedValue, flag.Type);
            }
            IDictionary<string, dynamic> flags = bridge.ConfigurationFlags.ToDictionary(flag => flag.Value.Key, flag => bridge.ConfigurationFlagStore.GetValue(game, flag.Value.Key, flag.Value.Type));

            return new JSResponse(request, flags);
        }
Пример #16
0
 public IJSResponse StartGame(IJSRequest request)
 {
     string emulator = request.GetParameter("emulator");
     string id = request.GetParameter("id");
     IEmulatorBridge bridge = this.CoreInstance.Get<IPluginManager>().Plugins<IEmulatorBridge>()[emulator];
     IGameInfo gameInfo = this.CoreInstance.Get<IGameDatabase>().GetGameByUUID(id);
     var gameStartEvent = new GameStartEventArgs(this.CoreInstance, gameInfo, bridge.EmulatorAssembly, bridge);
     SnowflakeEventManager.EventSource.RaiseEvent(gameStartEvent);
     if (!gameStartEvent.Cancel)
     {
         gameStartEvent.GameEmulatorBridge.StartRom(gameStartEvent.GameInfo);
     }
     return new JSResponse(request, gameInfo);
 }
Пример #17
0
 public IJSResponse GetFlagValues(IJSRequest request)
 {
     string emulator = request.GetParameter("emulator");
     string id = request.GetParameter("id");
     IEmulatorBridge bridge = this.CoreInstance.Get<IPluginManager>().Plugins<IEmulatorBridge>()[emulator];
     IGameInfo game = this.CoreInstance.Get<IGameDatabase>().GetGameByUUID(id);
     IDictionary<string, dynamic> flags = bridge.ConfigurationFlags.ToDictionary(flag => flag.Value.Key, flag => bridge.ConfigurationFlagStore.GetValue(game, flag.Value.Key, flag.Value.Type));
     return new JSResponse(request, flags);
 }
Пример #18
0
 public IJSResponse GetGame(IJSRequest request)
 {
     string id = request.GetParameter("id");
     return new JSResponse(request, this.CoreInstance.Get<IGameDatabase>().GetGameByUUID(id));
 }
Пример #19
0
 public IJSResponse GetGameInfo(IJSRequest request)
 {
     string resultid = request.GetParameter("resultid");
     string platform = request.GetParameter("platform");
     string filename = request.GetParameter("filename");
     return new JSResponse(request, new ScrapeService(this.CoreInstance.Platforms[platform], this.CoreInstance).GetGameInfo(resultid, filename));
 }
Пример #20
0
 public IJSResponse GetFlagValue(IJSRequest request)
 {
     string emulator = request.GetParameter("emulator");
     string id = request.GetParameter("id");
     string key = request.GetParameter("key");
     IEmulatorBridge bridge = this.CoreInstance.Get<IPluginManager>().Plugins<IEmulatorBridge>()[emulator];
     IGameInfo game = this.CoreInstance.Get<IGameDatabase>().GetGameByUUID(id);
     IConfigurationFlag flag = bridge.ConfigurationFlags[key];
     return new JSResponse(request, bridge.ConfigurationFlagStore.GetValue(game, flag.Key, flag.Type));
 }
Пример #21
0
 public IJSResponse GetPreferences(IJSRequest request)
 {
     IPlatformInfo platform = this.CoreInstance.Platforms[request.GetParameter("platform")];
     return new JSResponse(request, this.CoreInstance.Get<IPlatformPreferenceDatabase>().GetPreferences(platform));
 }