Skip to content

Commit

Permalink
etc
Browse files Browse the repository at this point in the history
  • Loading branch information
aedenthorn committed Nov 6, 2023
1 parent 876828d commit 17db97a
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 43 deletions.
2 changes: 1 addition & 1 deletion MobilePhone/CarpenterPhoneMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class CarpenterPhoneMenu : CarpenterMenu
{
private IModHelper helper;

public CarpenterPhoneMenu(bool magicalConstruction, Farmer farmer, IModHelper helper) : base(magicalConstruction)
public CarpenterPhoneMenu(bool magicalConstruction, Farmer farmer, IModHelper helper) : base(Game1.builder_robin)
{
this.helper = helper;
exitFunction = OnExit;
Expand Down
2 changes: 1 addition & 1 deletion MobilePhone/MobilePhone.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.0.0</Version>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<EnableHarmony>true</EnableHarmony>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
Expand Down
14 changes: 7 additions & 7 deletions MobilePhone/MobilePhoneCall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static void CallDialogueAnswer(Farmer who, string whichAnswer)
}
else if (whichAnswer == "PhoneApp_InCall_GoodBye")
{
Game1.drawDialogue(npc, GetGoodBye(npc));
Game1.DrawDialogue(npc, GetGoodBye(npc));
EndCall();
}
}
Expand Down Expand Up @@ -289,7 +289,7 @@ private static void LocateOnPhone(NPC npc)
{
ShowMainCallDialogue(npc);
}));
Game1.drawDialogue(npc, message);
Game1.DrawDialogue(npc, message);
}
private static void InviteOnPhone(NPC npc)
{
Expand Down Expand Up @@ -437,7 +437,7 @@ private static void DoReminisce(int which, NPC npc)
{
exitLocation = new LocationRequest(Game1.player.currentLocation.Name, Game1.player.currentLocation.isStructure.Value, Game1.player.currentLocation)
};
Vector2 exitPos = Game1.player.getTileLocation();
Vector2 exitPos = Game1.player.Tile;
e.onEventFinished += delegate ()
{
Monitor.Log($"Event finished");
Expand Down Expand Up @@ -470,7 +470,7 @@ private static void DoInvite(int which, NPC npc)
{
exitLocation = new LocationRequest(Game1.player.currentLocation.Name, Game1.player.currentLocation.isStructure.Value, Game1.player.currentLocation)
};
Vector2 exitPos = Game1.player.getTileLocation();
Vector2 exitPos = Game1.player.Tile;
e.onEventFinished += delegate ()
{
Monitor.Log($"Event finished");
Expand Down Expand Up @@ -501,15 +501,15 @@ private static void StartRecruit(NPC npc)

if (ModEntry.npcAdventureModApi?.CanRecruit(Game1.player, npc) == true)
{
Game1.drawDialogue(npc, Helper.Translation.Get("recruit-success"));
Game1.DrawDialogue(npc, Helper.Translation.Get("recruit-success"));
Game1.afterDialogues = delegate ()
{
DoRecruit(npc);
};
}
else
{
Game1.drawDialogue(npc, Helper.Translation.Get("recruit-fail"));
Game1.DrawDialogue(npc, Helper.Translation.Get("recruit-fail"));
Game1.afterDialogues = delegate ()
{
ShowMainCallDialogue(npc);
Expand Down Expand Up @@ -543,7 +543,7 @@ private static void DoRecruit(NPC npc)
if (ModEntry.npcAdventureModApi.IsRecruited(npc))
{
Vector2 targetPos = PhoneUtils.GetOpenSurroundingPosition();
Monitor.Log($"Recruiting {npc.Name} to {targetPos} (player: {Game1.player.getTileLocation()})");
Monitor.Log($"Recruiting {npc.Name} to {targetPos} (player: {Game1.player.Tile})");
Game1.warpCharacter(npc, Game1.player.currentLocation, targetPos);
npc.Sprite.StopAnimation();
EndCall();
Expand Down
22 changes: 11 additions & 11 deletions MobilePhone/ModEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,47 +170,47 @@ public override void Entry(IModHelper helper)
prefix: new HarmonyMethod(typeof(PhonePatches), nameof(PhonePatches.GameLocation_answerDialogue_prefix))
);
harmony.Patch(
original: AccessTools.Method(typeof(Event), nameof(Event.command_awardFestivalPrize)),
original: AccessTools.Method(typeof(Event), nameof(Event.DefaultCommands.AwardFestivalPrize)),
prefix: new HarmonyMethod(typeof(PhonePatches), nameof(PhonePatches.Event_command_prefix))
);
harmony.Patch(
original: AccessTools.Method(typeof(Event), nameof(Event.command_addTool)),
original: AccessTools.Method(typeof(Event), nameof(Event.DefaultCommands.AddTool)),
prefix: new HarmonyMethod(typeof(PhonePatches), nameof(PhonePatches.Event_command_prefix))
);
harmony.Patch(
original: AccessTools.Method(typeof(Event), nameof(Event.command_addConversationTopic)),
original: AccessTools.Method(typeof(Event), nameof(Event.DefaultCommands.AddConversationTopic)),
prefix: new HarmonyMethod(typeof(PhonePatches), nameof(PhonePatches.Event_command_prefix))
);
harmony.Patch(
original: AccessTools.Method(typeof(Event), nameof(Event.command_addCookingRecipe)),
original: AccessTools.Method(typeof(Event), nameof(Event.DefaultCommands.AddCookingRecipe)),
prefix: new HarmonyMethod(typeof(PhonePatches), nameof(PhonePatches.Event_command_prefix))
);
harmony.Patch(
original: AccessTools.Method(typeof(Event), nameof(Event.command_addCraftingRecipe)),
original: AccessTools.Method(typeof(Event), nameof(Event.DefaultCommands.AddCraftingRecipe)),
prefix: new HarmonyMethod(typeof(PhonePatches), nameof(PhonePatches.Event_command_prefix))
);
harmony.Patch(
original: AccessTools.Method(typeof(Event), nameof(Event.command_money)),
original: AccessTools.Method(typeof(Event), nameof(Event.DefaultCommands.Money)),
prefix: new HarmonyMethod(typeof(PhonePatches), nameof(PhonePatches.Event_command_prefix))
);
harmony.Patch(
original: AccessTools.Method(typeof(Event), nameof(Event.command_removeItem)),
original: AccessTools.Method(typeof(Event), nameof(Event.DefaultCommands.RemoveItem)),
prefix: new HarmonyMethod(typeof(PhonePatches), nameof(PhonePatches.Event_command_prefix))
);
harmony.Patch(
original: AccessTools.Method(typeof(Event), nameof(Event.command_friendship)),
original: AccessTools.Method(typeof(Event), nameof(Event.DefaultCommands.Friendship)),
prefix: new HarmonyMethod(typeof(PhonePatches), nameof(PhonePatches.Event_command_prefix))
);
harmony.Patch(
original: AccessTools.Method(typeof(Event), nameof(Event.command_dump)),
original: AccessTools.Method(typeof(Event), nameof(Event.DefaultCommands.Dump)),
prefix: new HarmonyMethod(typeof(PhonePatches), nameof(PhonePatches.Event_command_prefix))
);
harmony.Patch(
original: AccessTools.Method(typeof(Event), nameof(Event.command_addQuest)),
original: AccessTools.Method(typeof(Event), nameof(Event.DefaultCommands.AddQuest)),
prefix: new HarmonyMethod(typeof(PhonePatches), nameof(PhonePatches.Event_command_prefix))
);
harmony.Patch(
original: AccessTools.Method(typeof(Event), nameof(Event.command_cutscene)),
original: AccessTools.Method(typeof(Event), nameof(Event.DefaultCommands.Cutscene)),
prefix: new HarmonyMethod(typeof(PhonePatches), nameof(PhonePatches.Event_command_cutscene_prefix))
);
harmony.Patch(
Expand Down
28 changes: 14 additions & 14 deletions MobilePhone/PhonePatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static void GameLocation_resetLocalState_postfix(GameLocation __instance)
{
Monitor.Log($"Reminiscing at night");
__instance.LightLevel = 0f;
Game1.globalOutdoorLighting = 1f;
//Game1.globalOutdoorLighting = 1f;
float transparency = Math.Min(0.93f, 0.75f + (2400 - Game1.getTrulyDarkTime() + Game1.gameTimeInterval / 7000f * 16.6f) * 0.000625f);
Game1.outdoorLight = Game1.eveningColor * transparency;
if (!(__instance is MineShaft) && !(__instance is Woods))
Expand Down Expand Up @@ -91,7 +91,7 @@ public static void GameLocation_resetLocalState_postfix(GameLocation __instance)
Monitor.Log($"Reminiscing during the day");
return;
__instance.LightLevel = 1f;
Game1.globalOutdoorLighting = 1f;
//Game1.globalOutdoorLighting = 1f;
Game1.outdoorLight = Color.White;
Game1.ambientLight = Color.White;
PropertyValue dayTiles;
Expand Down Expand Up @@ -212,10 +212,10 @@ public static bool Event_namePet_prefix(Event __instance, string name)
Monitor.Log($"Reminiscing, renaming pet to {name}");
if (Game1.player.catPerson)
{
Cat cat = Game1.getFarm().characters.FirstOrDefault(n => n is Cat) as Cat;
Pet cat = Game1.getFarm().characters.FirstOrDefault(n => n is Pet) as Pet;
if(cat == null)
{
cat = Utility.getHomeOfFarmer(Game1.player).characters.FirstOrDefault(n => n is Cat) as Cat;
cat = Utility.getHomeOfFarmer(Game1.player).characters.FirstOrDefault(n => n is Pet) as Pet;
}
if (cat != null)
{
Expand All @@ -225,10 +225,10 @@ public static bool Event_namePet_prefix(Event __instance, string name)
}
else
{
Dog dog = Game1.getFarm().characters.FirstOrDefault(n => n is Dog) as Dog;
Pet dog = Game1.getFarm().characters.FirstOrDefault(n => n is Pet) as Pet;
if (dog == null)
{
dog = Utility.getHomeOfFarmer(Game1.player).characters.FirstOrDefault(n => n is Dog) as Dog;
dog = Utility.getHomeOfFarmer(Game1.player).characters.FirstOrDefault(n => n is Pet) as Pet;
}
if (dog != null)
{
Expand Down Expand Up @@ -278,7 +278,7 @@ public static bool CarpenterMenu_returnToCarpentryMenu_prefix()
{
RefreshView1();
};
Game1.warpFarmer(locationRequest, Game1.player.getTileX(), Game1.player.getTileY(), Game1.player.facingDirection);
Game1.warpFarmer(locationRequest.Location.Name, Game1.player.TilePoint.X, Game1.player.TilePoint.Y, Game1.player.FacingDirection);
return false;
}

Expand All @@ -292,7 +292,7 @@ public static bool CarpenterMenu_returnToCarpentryMenuAfterSuccessfulBuild_prefi
RefreshView2();

};
Game1.warpFarmer(locationRequest, Game1.player.getTileX(), Game1.player.getTileY(), Game1.player.facingDirection);
Game1.warpFarmer(locationRequest.Location.Name, Game1.player.TilePoint.X, Game1.player.TilePoint.Y, Game1.player.FacingDirection);
return false;
}
private static void RefreshView1()
Expand Down Expand Up @@ -331,24 +331,24 @@ private static void RefreshView2()
Game1.viewport.Location = new Location(320, 1536);
Helper.Reflection.GetField<bool>(Game1.activeClickableMenu, "freeze").SetValue(false);
Game1.displayFarmer = true;
robinPhoneConstructionMessage(Game1.activeClickableMenu, (Game1.activeClickableMenu as CarpenterMenu).CurrentBlueprint);
robinPhoneConstructionMessage(Game1.activeClickableMenu, (Game1.activeClickableMenu as CarpenterMenu).Blueprint);
}

private static async void robinPhoneConstructionMessage(IClickableMenu instance, BluePrint CurrentBlueprint)
private static async void robinPhoneConstructionMessage(IClickableMenu instance, CarpenterMenu.BlueprintEntry CurrentBlueprint)
{
Game1.player.forceCanMove();
string dialoguePath = "Data\\ExtraDialogue:Robin_" + (Helper.Reflection.GetField<bool>(instance, "upgrading").GetValue() ? "Upgrade" : "New") + "Construction";
if (Utility.isFestivalDay(Game1.dayOfMonth + 1, Game1.currentSeason))
if (Utility.isFestivalDay(Game1.dayOfMonth + 1, Game1.season))
{
dialoguePath += "_Festival";
}
if (CurrentBlueprint.daysToConstruct <= 0)
if (CurrentBlueprint.BuildDays <= 0)
{
Game1.drawDialogue(Game1.getCharacterFromName("Robin", true), Game1.content.LoadString("Data\\ExtraDialogue:Robin_Instant", (LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.de) ? CurrentBlueprint.displayName : CurrentBlueprint.displayName.ToLower()));
Game1.DrawDialogue(Game1.getCharacterFromName("Robin", true), Game1.content.LoadString("Data\\ExtraDialogue:Robin_Instant", (LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.de) ? CurrentBlueprint.DisplayName : CurrentBlueprint.DisplayName.ToLower()));
}
else
{
Game1.drawDialogue(Game1.getCharacterFromName("Robin", true), Game1.content.LoadString(dialoguePath, (LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.de) ? CurrentBlueprint.displayName : CurrentBlueprint.displayName.ToLower(), (LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.de) ? CurrentBlueprint.displayName.Split(' ').Last().Split('-').Last() : ((LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.pt || LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.es || LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.it) ? CurrentBlueprint.displayName.ToLower().Split(' ').First() : CurrentBlueprint.displayName.ToLower().Split(' ').Last())));
Game1.DrawDialogue(Game1.getCharacterFromName("Robin", true), Game1.content.LoadString(dialoguePath, (LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.de) ? CurrentBlueprint.DisplayName : CurrentBlueprint.DisplayName.ToLower(), (LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.de) ? CurrentBlueprint.DisplayName.Split(' ').Last().Split('-').Last() : ((LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.pt || LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.es || LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.it) ? CurrentBlueprint.DisplayName.ToLower().Split(' ').First() : CurrentBlueprint.DisplayName.ToLower().Split(' ').Last())));
}

while (Game1.activeClickableMenu is DialogueBox)
Expand Down
2 changes: 1 addition & 1 deletion MobilePhone/PhoneUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public static Vector2 GetPhoneIconPosition()

public static Vector2 GetOpenSurroundingPosition()
{
Vector2[] tiles = Utility.getSurroundingTileLocationsArray(Game1.player.getTileLocation());
Vector2[] tiles = Utility.getSurroundingTileLocationsArray(Game1.player.Tile);
foreach(Vector2 tile in tiles)
{
if(!Game1.player.currentLocation.isCollidingPosition(new Rectangle((int)tile.X * Game1.tileSize, (int)tile.Y * Game1.tileSize, Game1.tileSize, Game1.tileSize), Game1.viewport, true, 0, false, Game1.player)){
Expand Down
4 changes: 2 additions & 2 deletions MobilePhone/PhoneVisuals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static void Display_RenderedWorld(object sender, StardewModdingAPI.Events
ModEntry.appRunning = false;
ModEntry.runningApp = null;

if (Config.ShowPhoneIcon && Game1.displayHUD && !Game1.eventUp && Game1.currentBillboard == 0 && Game1.gameMode == 3 && !Game1.freezeControls && !Game1.panMode && !Game1.HostPaused && !Game1.game1.takingMapScreenshot)
if (Config.ShowPhoneIcon && Game1.displayHUD && !Game1.eventUp && Game1.gameMode == 3 && !Game1.freezeControls && !Game1.panMode && !Game1.HostPaused && !Game1.game1.takingMapScreenshot)
{
PhoneUtils.CheckIconOffScreen();
if (ModEntry.clickingPhoneIcon)
Expand Down Expand Up @@ -170,7 +170,7 @@ public static void Display_RenderedWorld(object sender, StardewModdingAPI.Events
ModEntry.iHDPortraitsAPI.DrawPortrait(e.SpriteBatch, ModEntry.callingNPC, 0, destRect);
}

SpriteText.drawStringHorizontallyCenteredAt(e.SpriteBatch, ModEntry.callingNPC.getName(), destRect.X + destRect.Width / 2, destRect.Bottom + 16, 999999, -1, 999999, 1f, 0.88f, false, -1, 99999);
SpriteText.drawStringHorizontallyCenteredAt(e.SpriteBatch, ModEntry.callingNPC.getName(), destRect.X + destRect.Width / 2, destRect.Bottom + 16, 999999, -1, 999999, 1f, 0.88f, false, null, 99999);

if (!ModEntry.inCall)
{
Expand Down
7 changes: 1 addition & 6 deletions MobilePhone/Reminiscence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,8 @@ public void WeedOutUnseen()
for (int i = events.Count - 1; i >= 0; i--)
{
string ids = events[i].eventId;
if(!int.TryParse(ids, out int id))
{
if (!int.TryParse(ids.Split('/')[0], out id))
continue;
}

if (!Game1.player.eventsSeen.Contains(id))
if (!Game1.player.eventsSeen.Contains(ids))
events.RemoveAt(i);
}
}
Expand Down

0 comments on commit 17db97a

Please sign in to comment.