Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with Mail Framework Mod #8

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,115 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E508687E-A71D-48F9-8EE0-DDA8F19F38D9}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>StardewMods.ArchaeologyHouseContentManagementHelper</RootNamespace>
<AssemblyName>ArchaeologyHouseContentManagementHelper</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>7.2</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>7.2</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>7.3</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<RootNamespace>StardewMods.ArchaeologyHouseContentManagementHelper</RootNamespace>
<Version>1.3.0</Version>
<TargetFramework>net452</TargetFramework>
<Platforms>x86</Platforms>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>

<EnableHarmony>true</EnableHarmony>
</PropertyGroup>

<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Common\Constants\Translation.cs" />
<Compile Include="Framework\Helpers\LibraryMuseumHelper.cs" />
<Compile Include="Framework\Helpers\MuseumTileClassification.cs" />
<Compile Include="Framework\Menus\CollectionsPage\CollectionsPageEx.cs" />
<Compile Include="Framework\ModConfig.cs" />
<Compile Include="Framework\Services\CollectionPageExMenuService.cs" />
<Compile Include="Framework\Services\DialogServices\LostBookFoundDialogService.cs" />
<Compile Include="Framework\Services\DialogServices\MuseumInteractionDialogService.cs" />
<Compile Include="Framework\Services\DialogServices\MuseumInteractionDialogType.cs" />
<Compile Include="Framework\Menus\MuseumMenu\MuseumMenuEx.cs" />
<Compile Include="Framework\Menus\MuseumMenu\MuseumMenuNoInventory.cs" />
<Compile Include="Common\Constants\Constants.cs" />
<Compile Include="ModEntry.cs" />
<Compile Include="Patches\AddItemToInventoryBoolPatch.cs" />
<Compile Include="Patches\CouldInventoryAcceptThisObjectPatch.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="i18n\de.json" />
<None Include="i18n\default.json" />
<None Include="i18n\es.json" />
<None Include="i18n\ko.json" />
<None Include="i18n\pt.json" />
<None Include="i18n\zh.json" />
<None Include="manifest.json" />
<None Include="README.md" />
<None Include="release-notes.md" />
</ItemGroup>
<ItemGroup>
<Content Include="Assets\CollectionTab_LostBook.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Lib.Harmony">
<Version>1.2.0.1</Version>
</PackageReference>
<PackageReference Include="Pathoschild.Stardew.ModBuildConfig">
<Version>2.2.0</Version>
</PackageReference>
<PackageReference Include="Pathoschild.Stardew.ModBuildConfig" Version="3.0.0-beta.8" />
</ItemGroup>

<Import Project="..\Common\Common.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
<UserProperties manifest_1json__JSONSchema="" />
</VisualStudio>
</ProjectExtensions>
</Project>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Translation = StardewMods.ArchaeologyHouseContentManagementHelper.Common.Translation;

Expand All @@ -19,22 +17,14 @@ namespace StardewMods.ArchaeologyHouseContentManagementHelper.Framework
/// </summary>
internal class CollectionsPageEx : CollectionsPage
{
public const int region_sideTabLostBooks = 7008;
public const int region_sideTabLostBooks = 7100;

private const int LostBooksTab_ItemBaseId = 0x70080000;

public const int lostBooksTab = 7;

private readonly int lostBooksTabPageIndex;
private readonly int lostBooksTab;

private const int sideTabs_FirstIndex = region_sideTabShipped;

// The number of side tabs of the Collection Page.
private readonly int numTabs = 8;

// Indicates whether the [Secret Notes] sidetab is shown or not.
private readonly bool showSecretNotesTab;

// The length of the preview of a book's content.
private const int BOOK_PREVIEW_LENGTH = 22;

Expand All @@ -47,23 +37,24 @@ internal class CollectionsPageEx : CollectionsPage
private readonly IReflectedField<string> descriptionTextRef;
private readonly IReflectedField<int> valueRef;

public CollectionsPageEx(int x, int y, int width, int height,
int selectedTab = organicsTab) : base(x, y, width, height)
public CollectionsPageEx(int x, int y, int width, int height, int selectedTab = organicsTab)
: base(x, y, width, height)
{
hoverTextRef = ModEntry.CommonServices.ReflectionHelper.GetField<string>(this, "hoverText");
descriptionTextRef = ModEntry.CommonServices.ReflectionHelper.GetField<string>(this, "descriptionText");
valueRef = ModEntry.CommonServices.ReflectionHelper.GetField<int>(this, "value");

showSecretNotesTab = Game1.player.secretNotesSeen.Count > 0;
lostBooksTabPageIndex = showSecretNotesTab ? lostBooksTab : lostBooksTab - 1;
var prevSideTab = this.sideTabs.OrderByDescending(p => p.Key).First();

lostBooksTab = prevSideTab.Key + 1;

// Loads the [Lost Books] side-tab texture.
Texture2D bookTabTexture = ModEntry.CommonServices.ContentHelper.Load<Texture2D>("Assets/CollectionTab_LostBook.png", ContentSource.ModFolder);
Texture2D bookTabTexture = ModEntry.CommonServices.ContentHelper.Load<Texture2D>("assets/CollectionTab_LostBook.png", ContentSource.ModFolder);

// Adds the [Lost Books] side-tab to the Collections Page.
ClickableTextureComponent stLostBooks = new ClickableTextureComponent(
name: "",
bounds: new Rectangle(this.xPositionOnScreen - 48, this.yPositionOnScreen + (showSecretNotesTab ? 576 : 512), 64, 64),
bounds: new Rectangle(this.xPositionOnScreen - 48, prevSideTab.Value.bounds.Y + 64, 64, 64),
label: "",
hoverText: ModEntry.CommonServices.TranslationHelper.Get(Translation.GAMEMENU_COLLECTIONSPAGE_TAB_LABEL_LOST_BOOKS),
texture: bookTabTexture,
Expand All @@ -72,19 +63,18 @@ public CollectionsPageEx(int x, int y, int width, int height,
drawShadow: false)
{
myID = region_sideTabLostBooks,
upNeighborID = showSecretNotesTab ? region_sideTabSecretNotes : region_sideTabAchivements,
upNeighborID = prevSideTab.Value.myID,
rightNeighborID = 0
};

this.sideTabs.Add(stLostBooks);
this.collections.Add(lostBooksTabPageIndex, new List<List<ClickableTextureComponent>>());

var prevSideTab = this.sideTabs[showSecretNotesTab ? secretNotesTab : achievementsTab];
prevSideTab.downNeighborID = region_sideTabLostBooks;
this.sideTabs.Add(lostBooksTab, stLostBooks);
this.collections.Add(lostBooksTab, new List<List<ClickableTextureComponent>>());

prevSideTab.Value.downNeighborID = stLostBooks.myID;

// Fill [Lost Book] collection

this.collections[lostBooksTabPageIndex].Add(new List<ClickableTextureComponent>());
this.collections[lostBooksTab].Add(new List<ClickableTextureComponent>());

var lostBooksIndices = LibraryMuseumHelper.GetLostBookIndexList();

Expand All @@ -97,21 +87,15 @@ public CollectionsPageEx(int x, int y, int width, int height,

for (int i = 0; i < LibraryMuseumHelper.TotalLibraryBooks; i++)
{
bool drawShadow = false;

// If the current Lost Book has already been discovered by the player, "enable" it in the collection
if (lostBooksIndices[i] <= LibraryMuseumHelper.LibraryBooks)
{
drawShadow = true;
}
bool drawShadow = lostBooksIndices[i] <= LibraryMuseumHelper.LibraryBooks; // If the current Lost Book has already been discovered by the player, "enable" it in the collection

// Start a new page if the current page has already been filled completely
int x1 = startPosX + booksInCurrentPage % numBooksPerRow * BOOK_OFFSET;
int y1 = startPosY + booksInCurrentPage / numBooksPerRow * BOOK_OFFSET;
if (y1 > this.yPositionOnScreen + height - 128)
{
// Add a new page to the collection.
this.collections[lostBooksTabPageIndex].Add(new List<ClickableTextureComponent>());
this.collections[lostBooksTab].Add(new List<ClickableTextureComponent>());
booksInCurrentPage = 0;
x1 = startPosX;
y1 = startPosY;
Expand All @@ -130,41 +114,39 @@ public CollectionsPageEx(int x, int y, int width, int height,
{
myID = LostBooksTab_ItemBaseId + i,

rightNeighborID = (this.collections[lostBooksTabPageIndex].Last().Count + 1) % numBooksPerRow == 0
rightNeighborID = (this.collections[lostBooksTab].Last().Count + 1) % numBooksPerRow == 0
? -1
: LostBooksTab_ItemBaseId + i + 1,
leftNeighborID = this.collections[lostBooksTabPageIndex].Last().Count % numBooksPerRow == 0
leftNeighborID = this.collections[lostBooksTab].Last().Count % numBooksPerRow == 0
? region_sideTabLostBooks
: LostBooksTab_ItemBaseId + i - 1,
downNeighborID = y1 + BOOK_OFFSET > this.yPositionOnScreen + height - 128
? -7777
: LostBooksTab_ItemBaseId + i + numBooksPerRow,
upNeighborID = this.collections[lostBooksTabPageIndex].Last().Count < numBooksPerRow
upNeighborID = this.collections[lostBooksTab].Last().Count < numBooksPerRow
? 12345
: LostBooksTab_ItemBaseId + i - numBooksPerRow,

fullyImmutable = true
};

this.collections[lostBooksTabPageIndex].Last().Add(lostBookTextureObject);
this.collections[lostBooksTab].Last().Add(lostBookTextureObject);
++booksInCurrentPage;
}

SetCurrentSidetab();

void SetCurrentSidetab()
// Set the current side tab
{
// Set the current side tab
if (selectedTab < 0 || selectedTab >= numTabs)
if (!this.sideTabs.ContainsKey(selectedTab))
{
selectedTab = 0;
selectedTab = CollectionsPage.organicsTab;
}

// [Lost Books] tab has a different Collection Page index depending on the visibility
// of the [Secret Notes] tab.
if (selectedTab == lostBooksTab)
{
selectedTab = lostBooksTabPageIndex;
selectedTab = lostBooksTab;
this.currentlySnappedComponent = snappedItem;
this.snapCursorToCurrentSnappedComponent();
}
Expand Down Expand Up @@ -194,7 +176,7 @@ public override void applyMovementKey(int direction)

private void MoveCursorInDirectionNew(CursorDirection direction)
{
if (this.currentlySnappedComponent == null && this.allClickableComponents != null && this.allClickableComponents.Count<ClickableComponent>() > 0)
if (this.currentlySnappedComponent == null && this.allClickableComponents != null && this.allClickableComponents.Any())
{
this.snapToDefaultClickableComponent();
if (this.currentlySnappedComponent == null)
Expand Down Expand Up @@ -234,7 +216,7 @@ private void MoveCursorInDirectionNew(CursorDirection direction)
// [Lost Book].
else if (this.currentlySnappedComponent.myID >= region_sideTabShipped
&& this.currentlySnappedComponent.myID <= region_sideTabLostBooks
&& ModEntry.CommonServices.ReflectionHelper.GetField<int>(this, "currentTab").GetValue() == lostBooksTabPageIndex)
&& ModEntry.CommonServices.ReflectionHelper.GetField<int>(this, "currentTab").GetValue() == lostBooksTab)
{
this.currentlySnappedComponent = this.getComponentWithID(LostBooksTab_ItemBaseId);
}
Expand All @@ -245,7 +227,7 @@ private void MoveCursorInDirectionNew(CursorDirection direction)
// Since the item offset is the same for every sidetab other than [Lost Books], we simply set the currently snapped item
// to the first item with ID = 0 which is the first item for every original sidetab.
else if (this.currentlySnappedComponent.myID == region_sideTabLostBooks
&& ModEntry.CommonServices.ReflectionHelper.GetField<int>(this, "currentTab").GetValue() != lostBooksTabPageIndex)
&& ModEntry.CommonServices.ReflectionHelper.GetField<int>(this, "currentTab").GetValue() != lostBooksTab)
{
this.currentlySnappedComponent = this.getComponentWithID(0);
}
Expand Down Expand Up @@ -343,7 +325,7 @@ public override void snapToDefaultClickableComponent()

int currentTab = ModEntry.CommonServices.ReflectionHelper.GetField<int>(this, "currentTab").GetValue();

if (currentTab == lostBooksTabPageIndex)
if (currentTab == lostBooksTab)
{
this.currentlySnappedComponent = this.getComponentWithID(LostBooksTab_ItemBaseId);
}
Expand All @@ -368,7 +350,7 @@ public override void performHoverAction(int x, int y)
valueRef.SetValue(-1);
secretNoteImageRef.SetValue(-1);

foreach (ClickableTextureComponent sideTab in this.sideTabs)
foreach (ClickableTextureComponent sideTab in this.sideTabs.Values)
{
if (sideTab.containsPoint(x, y))
{
Expand All @@ -393,7 +375,7 @@ public override void performHoverAction(int x, int y)
}

// Book has already been found -> show book preview
if (currentTab == lostBooksTabPageIndex)
if (currentTab == lostBooksTab)
{
string index = textureComponent.name.Split(' ')[2];
string message = Game1.content.LoadString("Strings\\Notes:" + index).Replace('\n', '^');
Expand Down Expand Up @@ -431,9 +413,12 @@ public override void receiveLeftClick(int x, int y, bool playSound = true)
int currentTab = currentTabRef.GetValue();
int currentPage = currentPageRef.GetValue();

for (int index = 0; index < this.sideTabs.Count; ++index)
foreach (var pair in this.sideTabs)
{
if (this.sideTabs[index].containsPoint(x, y) && currentTab != index)
var index = pair.Key;
var tab = pair.Value;

if (tab.containsPoint(x, y) && currentTab != index)
{
Game1.playSound("smallSelect");
this.sideTabs[currentTab].bounds.X -= CollectionsPage.widthToMoveActiveTab;
Expand All @@ -443,28 +428,23 @@ public override void receiveLeftClick(int x, int y, bool playSound = true)
currentTab = index;
currentPage = 0;

this.sideTabs[index].bounds.X += CollectionsPage.widthToMoveActiveTab;
tab.bounds.X += CollectionsPage.widthToMoveActiveTab;

// On tab switch, we set the currently snapped element to the tab element
currentlySnappedComponent = this.sideTabs[index];
currentlySnappedComponent = tab;

if (index == lostBooksTabPageIndex)
{
currentlySnappedComponent.rightNeighborID = LostBooksTab_ItemBaseId;
}
else
{
currentlySnappedComponent.rightNeighborID = 0;
}
currentlySnappedComponent.rightNeighborID = currentTab == lostBooksTab
? LostBooksTab_ItemBaseId
: 0;

return;
}
}

// Open a book when it has been clicked by the player.
if (currentTab == lostBooksTabPageIndex)
if (currentTab == lostBooksTab)
{
foreach (ClickableTextureComponent textureComponent in collections[lostBooksTabPageIndex][currentPage])
foreach (ClickableTextureComponent textureComponent in collections[lostBooksTab][currentPage])
{
if (textureComponent.containsPoint(x, y))
{
Expand Down
Loading