public static void ShowMainCallDialogue(NPC npc) { Monitor.Log($"Showing Main Call Dialogue"); if (!ModEntry.inCall) { Monitor.Log($"Not in call, exiting"); return; } List <Response> answers = new List <Response>(); if (npc.CurrentDialogue != null && npc.CurrentDialogue.Count > 0) { answers.Add(new Response("PhoneApp_InCall_Chat", Helper.Translation.Get("chat"))); } if (inCallReminiscence == null) { Reminiscence r = Helper.Data.ReadJsonFile <Reminiscence>(Path.Combine("assets", "events", $"{npc.Name}.json")) ?? new Reminiscence(); Monitor.Log($"Total Reminisces: {r.events.Count}"); r.WeedOutUnseen(); Monitor.Log($"Seen Reminisces: {r.events.Count}"); inCallReminiscence = new List <Reminisce>(r.events); } if (inCallReminiscence != null && inCallReminiscence.Count > 0) { answers.Add(new Response("PhoneApp_InCall_Reminisce", Helper.Translation.Get("reminisce"))); } if (eventInvites.Count > 0) { foreach (EventInvite ei in eventInvites) { if (ei.CanInvite(npc)) { answers.Add(new Response("PhoneApp_InCall_Invite", Helper.Translation.Get("invite"))); break; } } } if (ModEntry.npcAdventureModApi != null && ModEntry.npcAdventureModApi.IsPossibleCompanion(npc) && ModEntry.npcAdventureModApi.CanAskToFollow(npc) && !npc.isSleeping) { answers.Add(new Response("PhoneApp_InCall_Recruit", Helper.Translation.Get("recruit"))); } if (npc.Name == "Robin" && Game1.player.daysUntilHouseUpgrade < 0 && !Game1.getFarm().isThereABuildingUnderConstruction()) { if (Game1.player.houseUpgradeLevel < 3) { answers.Add(new Response("PhoneApp_InCall_Upgrade", Helper.Translation.Get("upgrade-house"))); } answers.Add(new Response("PhoneApp_InCall_Build", Helper.Translation.Get("build-buildings"))); } answers.Add(new Response("PhoneApp_InCall_GoodBye", Helper.Translation.Get("goodbye"))); Game1.player.currentLocation.createQuestionDialogue(GetCallGreeting(npc), answers.ToArray(), "PhoneApp_InCall_Begin"); Game1.objectDialoguePortraitPerson = npc; }
public static void GameLoop_GameLaunched(object sender, StardewModdingAPI.Events.GameLaunchedEventArgs e) { foreach (IContentPack contentPack in Helper.ContentPacks.GetOwned()) { Monitor.Log($"Reading content pack: {contentPack.Manifest.Name} {contentPack.Manifest.Version} from {contentPack.DirectoryPath}"); try { MobilePhonePackJSON json = contentPack.ReadJsonFile <MobilePhonePackJSON>("content.json") ?? null; if (json != null) { if (json.apps != null && json.apps.Any()) { foreach (AppJSON app in json.apps) { Texture2D tex = contentPack.LoadAsset <Texture2D>(app.iconPath); if (tex == null) { continue; } ModEntry.apps.Add(app.id, new MobileApp(app.name, app.keyPress, app.closePhone, tex)); Monitor.Log($"Added app {app.name} from {contentPack.DirectoryPath}"); } } else if (json.iconPath != null) { Texture2D icon = contentPack.LoadAsset <Texture2D>(json.iconPath); if (icon == null) { continue; } ModEntry.apps.Add(json.id, new MobileApp(json.name, json.keyPress, json.closePhone, icon)); Monitor.Log($"Added app {json.name} from {contentPack.DirectoryPath}"); } if (json.invites != null && json.invites.Any()) { foreach (EventInvite invite in json.invites) { MobilePhoneCall.eventInvites.Add(invite); Monitor.Log($"Added event invite {invite.name} from {contentPack.DirectoryPath}"); } } } } catch (Exception ex) { Monitor.Log($"error reading content.json file in content pack {contentPack.Manifest.Name}.\r\n{ex}", LogLevel.Error); } if (Directory.Exists(Path.Combine(contentPack.DirectoryPath, "assets", "events"))) { Monitor.Log($"Adding events"); string[] events = Directory.GetFiles(Path.Combine(contentPack.DirectoryPath, "assets", "events"), "*.json"); Monitor.Log($"CP has {events.Length} events"); foreach (string eventFile in events) { try { string eventPath = Path.Combine("assets", "events", Path.GetFileName(eventFile)); Monitor.Log($"Adding events {Path.GetFileName(eventFile)} from {contentPack.DirectoryPath}"); Reminiscence r = contentPack.ReadJsonFile <Reminiscence>(eventPath); var key = Path.GetFileName(eventFile).Replace(".json", ""); MobilePhoneCall.contentPackReminiscences.TryAdd(key, new Reminiscence()); MobilePhoneCall.contentPackReminiscences[key].events.AddRange(r.events); Monitor.Log($"Added event {Path.GetFileName(eventFile)} from {contentPack.DirectoryPath}"); } catch { } } } if (Directory.Exists(Path.Combine(contentPack.DirectoryPath, "assets", "skins"))) { Monitor.Log($"Adding skins"); string[] skins = Directory.GetFiles(Path.Combine(contentPack.DirectoryPath, "assets", "skins"), "*_landscape.png"); Monitor.Log($"CP has {skins.Length} skins"); foreach (string skinFile in skins) { try { string skinPath = Path.Combine("assets", "skins", Path.GetFileName(skinFile)); Monitor.Log($"Adding skin {Path.GetFileName(skinFile).Replace("_landscape.png", "")} from {contentPack.DirectoryPath}"); Texture2D skin = contentPack.LoadAsset <Texture2D>(skinPath.Replace("_landscape.png", ".png")); Texture2D skinl = contentPack.LoadAsset <Texture2D>(skinPath); ThemeApp.skinList.Add(contentPack.Manifest.UniqueID + ":" + Path.GetFileName(skinFile).Replace("_landscape.png", "")); ThemeApp.skinDict.Add(contentPack.Manifest.UniqueID + ":" + Path.GetFileName(skinFile).Replace("_landscape.png", ""), new Texture2D[] { skin, skinl }); Monitor.Log($"Added skin {Path.GetFileName(skinFile).Replace("_landscape.png", "")} from {contentPack.DirectoryPath}"); } catch { } } } if (Directory.Exists(Path.Combine(contentPack.DirectoryPath, "assets", "backgrounds"))) { Monitor.Log($"Adding backgrounds"); string[] backgrounds = Directory.GetFiles(Path.Combine(contentPack.DirectoryPath, "assets", "backgrounds"), "*_landscape.png"); Monitor.Log($"CP has {backgrounds.Length} backgrounds"); foreach (string backFile in backgrounds) { try { string backPath = Path.Combine("assets", "backgrounds", Path.GetFileName(backFile)); Monitor.Log($"Adding background {Path.GetFileName(backFile).Replace("_landscape.png", "")} from {contentPack.DirectoryPath}"); Texture2D back = contentPack.LoadAsset <Texture2D>(backPath.Replace("_landscape.png", ".png")); Texture2D backl = contentPack.LoadAsset <Texture2D>(backPath); ThemeApp.backgroundDict.Add(contentPack.Manifest.UniqueID + ":" + Path.GetFileName(backFile).Replace("_landscape.png", ""), new Texture2D[] { back, backl }); ThemeApp.backgroundList.Add(contentPack.Manifest.UniqueID + ":" + Path.GetFileName(backFile).Replace("_landscape.png", "")); Monitor.Log($"Added background {Path.GetFileName(backFile).Replace("_landscape.png", "")} from {contentPack.DirectoryPath}"); } catch { } } } if (Directory.Exists(Path.Combine(contentPack.DirectoryPath, "assets", "ringtones"))) { Monitor.Log($"Adding ringtones"); string[] rings = Directory.GetFiles(Path.Combine(contentPack.DirectoryPath, "assets", "ringtones"), "*.wav"); Monitor.Log($"CP has {rings.Length} ringtones"); foreach (string path in rings) { try { object ring; try { var type = Type.GetType("System.Media.SoundPlayer, System"); ring = Activator.CreateInstance(type, new object[] { path }); } catch { ring = SoundEffect.FromStream(new FileStream(path, FileMode.Open)); } if (ring != null) { ThemeApp.ringDict.Add(string.Concat(contentPack.Manifest.UniqueID, ":", Path.GetFileName(path).Replace(".wav", "")), ring); ThemeApp.ringList.Add(string.Concat(contentPack.Manifest.UniqueID, ":", Path.GetFileName(path).Replace(".wav", ""))); Monitor.Log($"loaded ring {path}"); } else { Monitor.Log($"Couldn't load ring {path}"); } } catch (Exception ex) { Monitor.Log($"Couldn't load ring {path}:\r\n{ex}", LogLevel.Error); } } } } ModEntry.listHeight = Config.IconMarginY + (int)Math.Ceiling(ModEntry.apps.Count / (float)ModEntry.gridWidth) * (Config.IconHeight + Config.IconMarginY); PhoneVisuals.CreatePhoneTextures(); PhoneUtils.RefreshPhoneLayout(); if (Helper.ModRegistry.IsLoaded("purrplingcat.npcadventure")) { INpcAdventureModApi api = Helper.ModRegistry.GetApi <INpcAdventureModApi>("purrplingcat.npcadventure"); if (api != null) { Monitor.Log("Loaded NpcAdventureModApi successfully"); ModEntry.npcAdventureModApi = api; } } if (Helper.ModRegistry.IsLoaded("tlitookilakin.HDPortraits")) { IHDPortraitsAPI api = Helper.ModRegistry.GetApi <IHDPortraitsAPI>("tlitookilakin.HDPortraits"); if (api != null) { Monitor.Log("Loaded HD Portraits api successfully"); ModEntry.iHDPortraitsAPI = api; } } }