Minor fix

This commit is contained in:
yangzhi 2019-05-13 22:38:15 +08:00
parent c8f1bdc245
commit 8839cfe262
8 changed files with 129 additions and 15 deletions

View File

@ -18,12 +18,13 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>TRACE;DEBUG;HAVE_LINQ PORTABLE40</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<LangVersion>7.2</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CodeAnalysisRuleSet />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@ -34,6 +35,7 @@
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<LangVersion>7.2</LangVersion>
<CodeAnalysisRuleSet />
</PropertyGroup>
<ItemGroup>
<Compile Include="Harmony\Attributes.cs" />
@ -199,6 +201,7 @@
<Compile Include="Mono\Security\Cryptography\CryptoConvert.cs" />
<Compile Include="Mono\Security\Cryptography\CryptoService.cs" />
<Compile Include="Mono\Type.cs" />
<Compile Include="GameConsole.cs" />
<Compile Include="Newtonsoft.Json\Bson\BsonBinaryType.cs" />
<Compile Include="Newtonsoft.Json\Bson\BsonBinaryWriter.cs" />
<Compile Include="Newtonsoft.Json\Bson\BsonObjectId.cs" />
@ -426,7 +429,6 @@
<Compile Include="Newtonsoft.Json\Utilities\TypeExtensions.cs" />
<Compile Include="Newtonsoft.Json\Utilities\ValidationUtils.cs" />
<Compile Include="Newtonsoft.Json\WriteState.cs" />
<Compile Include="GameConsole.cs" />
<Compile Include="Options\ModOptionsCheckbox.cs" />
<Compile Include="Options\ModOptionsSlider.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@ -797,7 +799,8 @@
<HintPath>..\Mods\assemblies\mscorlib.dll</HintPath>
</Reference>
<Reference Include="System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e">
<HintPath>..\Mods\assemblies\System.dll</HintPath>
<Private>True</Private>
<HintPath>..\Mods\assemblies\System</HintPath>
</Reference>
<Reference Include="System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e">
<HintPath>..\Mods\assemblies\System.Xml</HintPath>
@ -811,7 +814,8 @@
<HintPath>..\Mods\assemblies\System.Net.Http.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e">
<HintPath>..\Mods\assemblies\System.Runtime.Serialization.dll</HintPath>
<Private>True</Private>
<HintPath>..\Mods\assemblies\System.Runtime.Serialization</HintPath>
</Reference>
<Reference Include="Xamarin.Android.Arch.Core.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
@ -858,15 +862,14 @@
<HintPath>..\Mods\assemblies\xTile.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="Newtonsoft.Json\Dynamic.snk" />
<None Include="Newtonsoft.Json\Newtonsoft.Json.ruleset" />
</ItemGroup>
<ItemGroup>
<Content Include="Newtonsoft.Json\Newtonsoft.Json.csproj" />
<Content Include="SMAPI\icon.ico" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<None Include="Newtonsoft.Json\Dynamic.snk" />
<None Include="Newtonsoft.Json\Newtonsoft.Json.ruleset" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -5,16 +5,44 @@ VisualStudioVersion = 15.0.28307.572
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mod", "Mod.csproj", "{23B6885E-0282-435B-A854-D49ABF1391D6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModLoader", "..\ModLoader\ModLoader.csproj", "{02768074-8BCB-4445-A9C8-AFDA367EC8D6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JarBinding", "..\JarBinding\JarBinding.csproj", "{A8FBE3C3-BDE1-42C5-A4B9-F34CE5A68F46}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
DebugLegacy|Any CPU = DebugLegacy|Any CPU
Release|Any CPU = Release|Any CPU
ReleaseLegacy|Any CPU = ReleaseLegacy|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{23B6885E-0282-435B-A854-D49ABF1391D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{23B6885E-0282-435B-A854-D49ABF1391D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{23B6885E-0282-435B-A854-D49ABF1391D6}.DebugLegacy|Any CPU.ActiveCfg = Debug|Any CPU
{23B6885E-0282-435B-A854-D49ABF1391D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{23B6885E-0282-435B-A854-D49ABF1391D6}.Release|Any CPU.Build.0 = Release|Any CPU
{23B6885E-0282-435B-A854-D49ABF1391D6}.ReleaseLegacy|Any CPU.ActiveCfg = Release|Any CPU
{02768074-8BCB-4445-A9C8-AFDA367EC8D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{02768074-8BCB-4445-A9C8-AFDA367EC8D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{02768074-8BCB-4445-A9C8-AFDA367EC8D6}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{02768074-8BCB-4445-A9C8-AFDA367EC8D6}.DebugLegacy|Any CPU.ActiveCfg = Debug|Any CPU
{02768074-8BCB-4445-A9C8-AFDA367EC8D6}.DebugLegacy|Any CPU.Build.0 = Debug|Any CPU
{02768074-8BCB-4445-A9C8-AFDA367EC8D6}.DebugLegacy|Any CPU.Deploy.0 = Debug|Any CPU
{02768074-8BCB-4445-A9C8-AFDA367EC8D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{02768074-8BCB-4445-A9C8-AFDA367EC8D6}.Release|Any CPU.Build.0 = Release|Any CPU
{02768074-8BCB-4445-A9C8-AFDA367EC8D6}.Release|Any CPU.Deploy.0 = Release|Any CPU
{02768074-8BCB-4445-A9C8-AFDA367EC8D6}.ReleaseLegacy|Any CPU.ActiveCfg = Release|Any CPU
{02768074-8BCB-4445-A9C8-AFDA367EC8D6}.ReleaseLegacy|Any CPU.Build.0 = Release|Any CPU
{02768074-8BCB-4445-A9C8-AFDA367EC8D6}.ReleaseLegacy|Any CPU.Deploy.0 = Release|Any CPU
{A8FBE3C3-BDE1-42C5-A4B9-F34CE5A68F46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A8FBE3C3-BDE1-42C5-A4B9-F34CE5A68F46}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A8FBE3C3-BDE1-42C5-A4B9-F34CE5A68F46}.DebugLegacy|Any CPU.ActiveCfg = Debug|Any CPU
{A8FBE3C3-BDE1-42C5-A4B9-F34CE5A68F46}.DebugLegacy|Any CPU.Build.0 = Debug|Any CPU
{A8FBE3C3-BDE1-42C5-A4B9-F34CE5A68F46}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A8FBE3C3-BDE1-42C5-A4B9-F34CE5A68F46}.Release|Any CPU.Build.0 = Release|Any CPU
{A8FBE3C3-BDE1-42C5-A4B9-F34CE5A68F46}.ReleaseLegacy|Any CPU.ActiveCfg = Release|Any CPU
{A8FBE3C3-BDE1-42C5-A4B9-F34CE5A68F46}.ReleaseLegacy|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -15,7 +15,6 @@ namespace SMDroid
{
public class ModEntry : ModHooks
{
private SCore core;
/// <summary>Whether the next content manager requested by the game will be for <see cref="Game1.content"/>.</summary>
private bool NextContentManagerIsMain;
@ -40,6 +39,10 @@ namespace SMDroid
// NOTE: this method is called before the SGame constructor runs. Don't depend on anything being initialised at this point.
if (this.ContentCore == null)
{
//if (Constants.PackageName == "com.zane.smdroid")
//{
// rootDirectory = Constants.AssetsPath;
//}
this.ContentCore = new ContentCoordinator(serviceProvider, rootDirectory, Thread.CurrentThread.CurrentUICulture, SGame.ConstructorHack.Monitor, SGame.ConstructorHack.Reflection, SGame.ConstructorHack.JsonHelper, SGame.OnLoadingFirstAsset ?? SGame.ConstructorHack?.OnLoadingFirstAsset);
this.NextContentManagerIsMain = true;
__result = this.ContentCore.CreateGameContentManager("Game1._temporaryContent");

View File

@ -2,6 +2,7 @@ using System;
using System.IO;
using System.Linq;
using System.Reflection;
using Android.App;
using StardewModdingAPI.Enums;
using StardewModdingAPI.Framework;
using StardewModdingAPI.Framework.ModLoading;
@ -34,6 +35,10 @@ namespace StardewModdingAPI
/// <summary>The path to the game folder.</summary>
public static string ExecutionPath { get; } = Path.Combine(Android.OS.Environment.ExternalStorageDirectory.Path , "SMDroid");
/// <summary>The path to the Assets folder.</summary>
public static string AssetsPath { get; } = Path.Combine(ExecutionPath, "Game/assets/Content");
/// <summary>The directory path containing Stardew Valley's app data.</summary>
public static string DataPath { get; } = Path.Combine(Android.OS.Environment.ExternalStorageDirectory.Path, "SMDroid");
@ -58,6 +63,9 @@ namespace StardewModdingAPI
/// <summary>The absolute path to the folder containing SMAPI's internal files.</summary>
internal static readonly string InternalFilesPath = Path.Combine(Android.OS.Environment.ExternalStorageDirectory.Path, "SMDroid/smapi-internal");
/// <summary>The absolute path to the folder containing SMAPI's internal files.</summary>
internal static readonly string GameAssembliesPath = Path.Combine(Android.OS.Environment.ExternalStorageDirectory.Path, "SMDroid/Game/assemblies");
/// <summary>The file path for the SMAPI configuration file.</summary>
internal static string ApiConfigPath => Path.Combine(Constants.InternalFilesPath, "StardewModdingAPI.config.json");
@ -97,6 +105,9 @@ namespace StardewModdingAPI
/// <summary>The game's assembly name.</summary>
internal static string GameAssemblyName = "StardewValley";
/// <summary>The game's package name.</summary>
internal static string PackageName { get; } = Application.Context.PackageName;
/*********
** Internal methods

View File

@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using Microsoft.Xna.Framework.Content;
using StardewModdingAPI.Framework.Content;
using StardewModdingAPI.Framework.Exceptions;
using StardewModdingAPI.Framework.Reflection;
@ -75,7 +77,9 @@ namespace StardewModdingAPI.Framework.ContentManagers
// get from cache
if (this.IsLoaded(assetName))
{
return base.Load<T>(assetName, language);
}
// get managed asset
if (this.Coordinator.TryParseManagedAssetKey(assetName, out string contentManagerID, out string relativePath))
@ -119,6 +123,65 @@ namespace StardewModdingAPI.Framework.ContentManagers
}
public T ModedLoad<T>(string assetName, LanguageCode language)
{
if (language != LanguageCode.en)
{
string key = assetName + "." + this.LanguageCodeString(language);
Dictionary<string, bool> _localizedAsset = this.Reflector.GetField<Dictionary<string, bool>>(this, "_localizedAsset").GetValue();
if (!_localizedAsset.TryGetValue(key, out bool flag) | flag)
{
try
{
_localizedAsset[key] = true;
return this.ModedLoad<T>(key);
}
catch (ContentLoadException)
{
_localizedAsset[key] = false;
}
}
}
return this.ModedLoad<T>(assetName);
}
public T ModedLoad<T>(string assetName)
{
if (string.IsNullOrEmpty(assetName))
{
throw new ArgumentNullException("assetName");
}
T local = default(T);
string key = assetName.Replace('\\', '/');
Dictionary<string, object> loadedAssets = this.Reflector.GetField<Dictionary<string, object>>(this, "loadedAssets").GetValue();
if (loadedAssets.TryGetValue(key, out object obj2) && (obj2 is T))
{
return (T)obj2;
}
local = this.ReadAsset<T>(assetName, null);
loadedAssets[key] = local;
return local;
}
protected override Stream OpenStream(string assetName)
{
Stream stream;
try
{
stream = new FileStream(Path.Combine(Constants.ExecutionPath, "Game/assets", this.RootDirectory, assetName) + ".xnb", FileMode.Open, FileAccess.Read);
MemoryStream destination = new MemoryStream();
stream.CopyTo(destination);
destination.Seek(0L, SeekOrigin.Begin);
stream.Close();
stream = destination;
}
catch (Exception exception3)
{
throw new ContentLoadException("Opening stream error.", exception3);
}
return stream;
}
/*********
** Private methods
*********/

View File

@ -52,6 +52,7 @@ namespace StardewModdingAPI.Framework.ModLoading
this.AssemblyDefinitionResolver = this.TrackForDisposal(new AssemblyDefinitionResolver());
this.AssemblyDefinitionResolver.AddSearchDirectory(Constants.ExecutionPath);
this.AssemblyDefinitionResolver.AddSearchDirectory(Constants.InternalFilesPath);
this.AssemblyDefinitionResolver.AddSearchDirectory(Constants.GameAssembliesPath);
// generate type => assembly lookup for types which should be rewritten
this.TypeAssemblies = new Dictionary<string, Assembly>();

View File

@ -11,6 +11,8 @@ using System.Security;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using Android.App;
using Android.Content.PM;
using Microsoft.Xna.Framework.Graphics;
#if SMAPI_FOR_WINDOWS
using System.Windows.Forms;
@ -161,7 +163,7 @@ namespace StardewModdingAPI.Framework
// init logging
this.Monitor.Log($"SMAPI {Constants.ApiVersion} with Stardew Valley {Constants.GameVersion} on {EnvironmentUtility.GetFriendlyPlatformName(Constants.Platform)}", LogLevel.Info);
this.Monitor.Log($"SMDroid 1.4.0 for Stardew Valley Android release {MainActivity.instance.GetBuild()}", LogLevel.Info);
this.Monitor.Log($"SMDroid 1.4.0 for Stardew Valley Android release {Application.Context.PackageManager.GetPackageInfo(Application.Context.PackageName, (PackageInfoFlags)0).VersionCode}", LogLevel.Info);
this.Monitor.Log($"Mods go here: {modsPath}", LogLevel.Info);
if (modsPath != Constants.DefaultModsPath)
this.Monitor.Log("(Using custom --mods-path argument.)", LogLevel.Trace);

View File

@ -1949,10 +1949,7 @@ namespace StardewModdingAPI.Framework
string s = Game1.content.LoadString(@"Strings\StringsFromCSFiles:DayTimeMoneyBox.cs.10378");
SpriteText.drawStringWithScrollBackground(Game1.spriteBatch, s, 0x60, 0x20, "", 1f, -1, 0.088f);
}
events.Rendered.RaiseEmpty();
#if !SMAPI_3_0_STRICT
events.Legacy_OnPostRenderEvent.Raise();
#endif
_spriteBatchEnd.Invoke();
drawOverlays.Invoke(Game1.spriteBatch);
renderScreenBuffer.Invoke(BlendState.Opaque);
@ -1997,6 +1994,12 @@ namespace StardewModdingAPI.Framework
DrawUnscaledActiveClickableMenuForPinchZoom.Invoke();
DrawNativeScaledActiveClickableMenuForPinchZoom.Invoke();
}
SpriteBatchBegin.Invoke(Game1.options.zoomLevel);
events.Rendered.RaiseEmpty();
#if !SMAPI_3_0_STRICT
events.Legacy_OnPostRenderEvent.Raise();
#endif
_spriteBatchEnd.Invoke();
if ((_drawHUD.GetValue() && (Game1.hudMessages.Count > 0)) && (!Game1.eventUp || Game1.isFestival()))
{
Game1.SetSpriteBatchBeginNextID("A-F");