Skip to content

Commit

Permalink
Merge pull request #83 from RonnChyran/get-flag-values
Browse files Browse the repository at this point in the history
StandardAjax: Implement a method to get all flag values
  • Loading branch information
chyyran committed Feb 23, 2015
2 parents de12332 + ee37b05 commit 35335e3
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Snowflake.StandardAjax/StandardAjax.Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,19 @@ public IJSResponse GetFlagValue(IJSRequest request)
return new JSResponse(request, bridge.ConfigurationFlagStore.GetValue(game, flag.Key, flag.Type));
}

[AjaxMethod(MethodPrefix = "Game")]
[AjaxMethodParameter(ParameterName = "emulator", ParameterType = AjaxMethodParameterType.StringParameter)]
[AjaxMethodParameter(ParameterName = "id", ParameterType = AjaxMethodParameterType.StringParameter)]
public IJSResponse GetFlagValues(IJSRequest request)
{
string emulator = request.GetParameter("emulator");
string id = request.GetParameter("id");
IEmulatorBridge bridge = this.CoreInstance.PluginManager.LoadedEmulators[emulator];
IGameInfo game = this.CoreInstance.GameDatabase.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);
}

[AjaxMethod(MethodPrefix = "Game")]
[AjaxMethodParameter(ParameterName = "emulator", ParameterType = AjaxMethodParameterType.StringParameter)]
[AjaxMethodParameter(ParameterName = "id", ParameterType = AjaxMethodParameterType.StringParameter)]
Expand Down Expand Up @@ -190,6 +203,18 @@ public IJSResponse GetFlagDefaultValue(IJSRequest request)
IConfigurationFlag flag = bridge.ConfigurationFlags[key];
return new JSResponse(request, bridge.ConfigurationFlagStore.GetDefaultValue(flag.Key, flag.Type));
}

[AjaxMethod(MethodPrefix = "Game")]
[AjaxMethodParameter(ParameterName = "emulator", ParameterType = AjaxMethodParameterType.StringParameter)]
public IJSResponse GetFlagDefaultValues(IJSRequest request)
{
string emulator = request.GetParameter("emulator");
string key = request.GetParameter("key");
IEmulatorBridge bridge = this.CoreInstance.PluginManager.LoadedEmulators[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);
}

[AjaxMethod(MethodPrefix = "Game")]
[AjaxMethodParameter(ParameterName = "emulator", ParameterType = AjaxMethodParameterType.StringParameter)]
[AjaxMethodParameter(ParameterName = "id", ParameterType = AjaxMethodParameterType.StringParameter)]
Expand Down

0 comments on commit 35335e3

Please sign in to comment.