/// <summary> /// set data for game currently played /// </summary> /// <param name="gamename">name of game</param> /// <param name="epithet">epithet (eg. episodic title)</param> /// <param name="platform">platform game was released</param> /// <param name="year">year game was released</param> /// <param name="url">url pointing to game description (eg. mobygames)</param> public void SetCurrentlyPlayedGame(string gamename, string epithet, string platform, int year, string url) { StringBuilder sb = new StringBuilder(gamename); if (!string.IsNullOrEmpty(epithet)) { sb.Append(": "); sb.Append(epithet); } if (!string.IsNullOrEmpty(platform) || year > 0) { sb.Append(" ("); if (year > 0) { sb.Append(year); } if (!string.IsNullOrEmpty(platform)) { if (year > 0) { sb.Append(", "); } sb.Append(platform); } sb.Append(")"); } if (!string.IsNullOrEmpty(url)) { sb.Append(" -> ").Append(url); } string text = sb.ToString(); context.GetModule <InfoModule>().SetInfo("current", text); game = new CurrentlyPlayedGame { Game = gamename, Epithet = epithet, System = platform, Year = year, MobyGames = url }; context.Settings.Set(this, "game", JSON.WriteString(game)); }
public void ProcessRequest(HttpClient client, HttpRequest request) { float size = 32.0f; if (request.HasParameter("size")) { size = request.GetParameter <float>("size"); } Color textcolor = request.HasParameter("color") ? request.GetParameter <Color>("color") : Color.White; int outlinethickness = request.GetParameter <int>("outlinethickness"); Color outlinecolor = request.HasParameter("outlinecolor") ? request.GetParameter <Color>("outlinecolor") : Color.Black; CurrentlyPlayedGame game = context.GetModule <CurrentlyPlayedModule>().CurrentGame; string gamename = request.Resource.EndsWith("current") ? game.Game : game.Epithet; client.ServeData(context.GetModule <TextModule>().CreateTextImage(gamename, size, textcolor, outlinecolor, outlinethickness), ".png"); }
void IInitializableModule.Initialize() { game = JSON.Read <CurrentlyPlayedGame>(context.Settings.Get <string>(this, "game", null)); }