1.Compatibility fix
2.Update SMAPI to 3.4.1.5 3.Compatible with some of device of Android L
This commit is contained in:
parent
9619e5ecc5
commit
fa8d24962f
|
@ -20,7 +20,7 @@ namespace StardewModdingAPI
|
|||
** Public
|
||||
****/
|
||||
/// <summary>SMAPI's current semantic version.</summary>
|
||||
public static ISemanticVersion ApiVersion { get; } = new Toolkit.SemanticVersion("3.4.1.2", allowNonStandard: true);
|
||||
public static ISemanticVersion ApiVersion { get; } = new Toolkit.SemanticVersion("3.4.1.5", allowNonStandard: true);
|
||||
|
||||
/// <summary>The minimum supported version of Stardew Valley.</summary>
|
||||
public static ISemanticVersion MinimumGameVersion { get; } = new GameVersion("1.4.5");
|
||||
|
@ -109,6 +109,8 @@ namespace StardewModdingAPI
|
|||
/// <summary>The language code for non-translated mod assets.</summary>
|
||||
internal static LocalizedContentManager.LanguageCode DefaultLanguage { get; } = LocalizedContentManager.LanguageCode.en;
|
||||
|
||||
internal static bool MonoModInit { get; set; } = true;
|
||||
|
||||
|
||||
/*********
|
||||
** Internal methods
|
||||
|
|
|
@ -91,6 +91,12 @@ namespace StardewModdingAPI.Framework.ModLoading
|
|||
if (definition.Name != reference.Name)
|
||||
return false;
|
||||
|
||||
// same return type
|
||||
if(definition is MethodInfo methodDefinition)
|
||||
{
|
||||
if(!RewriteHelper.IsSameType(methodDefinition.ReturnType, reference.ReturnType))
|
||||
return false;
|
||||
}
|
||||
// same arguments
|
||||
ParameterInfo[] definitionParameters = definition.GetParameters();
|
||||
ParameterDefinition[] referenceParameters = reference.Parameters.ToArray();
|
||||
|
|
|
@ -29,31 +29,29 @@ namespace StardewModdingAPI.Framework.Patching
|
|||
/// <param name="patches">The patches to apply.</param>
|
||||
public void Apply(params IHarmonyPatch[] patches)
|
||||
{
|
||||
if (Build.VERSION.SdkInt < BuildVersionCodes.M)
|
||||
return;
|
||||
if (!HarmonyDetourBridge.Initialized)
|
||||
if (!HarmonyDetourBridge.Initialized && Constants.MonoModInit)
|
||||
{
|
||||
try {
|
||||
HarmonyDetourBridge.Init();
|
||||
}
|
||||
catch { Constants.MonoModInit = false; }
|
||||
}
|
||||
|
||||
HarmonyInstance harmony = HarmonyInstance.Create("io.smapi");
|
||||
foreach (IHarmonyPatch patch in patches)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(Constants.MonoModInit)
|
||||
patch.Apply(harmony);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Constants.MonoModInit = false;
|
||||
this.Monitor.Log($"Couldn't apply runtime patch '{patch.Name}' to the game. Some SMAPI features may not work correctly. See log file for details.", LogLevel.Error);
|
||||
this.Monitor.Log(ex.GetLogSummary(), LogLevel.Trace);
|
||||
}
|
||||
}
|
||||
|
||||
//Keeping for reference
|
||||
//if (Build.VERSION.SdkInt > BuildVersionCodes.LollipopMr1)
|
||||
//{
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Reflection;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using StardewValley;
|
||||
using StardewValley.Menus;
|
||||
|
@ -106,5 +107,14 @@ namespace StardewModdingAPI.Framework.RewriteFacades
|
|||
}
|
||||
}
|
||||
}
|
||||
public static new void createItemDebris(Item item, Vector2 origin, int direction, GameLocation location = null, int groundLevel = -1)
|
||||
{
|
||||
Game1.createItemDebris(item, origin, direction, location, groundLevel);
|
||||
}
|
||||
|
||||
public static void changeMusicTrack(string newTrackName)
|
||||
{
|
||||
Game1.changeMusicTrack(newTrackName, false, MusicContext.Default);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Netcode;
|
||||
using StardewValley;
|
||||
|
||||
namespace StardewModdingAPI.Framework.RewriteFacades
|
||||
{
|
||||
public class GameLocationMethods : GameLocation
|
||||
{
|
||||
public void playSound(string audioName)
|
||||
{
|
||||
base.playSound(audioName, StardewValley.Network.NetAudio.SoundContext.Default);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -977,7 +977,9 @@ namespace StardewModdingAPI.Framework
|
|||
this.ExitGameImmediately("The game crashed when drawing, and SMAPI was unable to recover the game.");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
// recover sprite batch
|
||||
try
|
||||
{
|
||||
|
|
|
@ -89,6 +89,7 @@ namespace StardewModdingAPI.Metadata
|
|||
yield return new MethodParentRewriter(typeof(Utility), typeof(UtilityMethods));
|
||||
yield return new MethodParentRewriter(typeof(DayTimeMoneyBox), typeof(DayTimeMoneyBoxMethods));
|
||||
yield return new MethodParentRewriter(typeof(SaveGame), typeof(SaveGameMethods));
|
||||
yield return new MethodParentRewriter(typeof(GameLocation), typeof(GameLocationMethods));
|
||||
|
||||
//Constructor Rewrites
|
||||
yield return new MethodParentRewriter(typeof(HUDMessage), typeof(HUDMessageMethods));
|
||||
|
|
|
@ -17,7 +17,9 @@ namespace StardewModdingAPI
|
|||
public bool isVisible;
|
||||
|
||||
private readonly LinkedList<KeyValuePair<ConsoleLogLevel, string>> consoleMessageQueue = new LinkedList<KeyValuePair<ConsoleLogLevel, string>>();
|
||||
private Dictionary<string, LinkedList<string>> parseTextCache = new Dictionary<string, LinkedList<string>>();
|
||||
private MobileScrollbox scrollbox;
|
||||
private MobileScrollbar scrollbar;
|
||||
|
||||
private ClickableTextureComponent commandButton;
|
||||
|
||||
|
@ -29,7 +31,8 @@ namespace StardewModdingAPI
|
|||
|
||||
private int scrollLastY = 0;
|
||||
|
||||
private int MaxScrollBoxHeight => (int)(Game1.graphics.PreferredBackBufferHeight * 20 / Game1.NativeZoomLevel);
|
||||
private int MaxScrollBoxHeight => (int)(Game1.graphics.PreferredBackBufferHeight * 100 / Game1.NativeZoomLevel);
|
||||
private int ScrollBoxHeight => (int)(Game1.graphics.PreferredBackBufferHeight / Game1.NativeZoomLevel);
|
||||
|
||||
private int MaxTextAreaWidth => (int)((Game1.graphics.PreferredBackBufferWidth - 32) / Game1.NativeZoomLevel);
|
||||
|
||||
|
@ -41,9 +44,13 @@ namespace StardewModdingAPI
|
|||
|
||||
internal void InitializeContent(LocalizedContentManager content)
|
||||
{
|
||||
this.scrollbox = new MobileScrollbox(0, 0, this.MaxTextAreaWidth, (int)(Game1.graphics.PreferredBackBufferHeight / Game1.NativeZoomLevel), this.MaxScrollBoxHeight,
|
||||
new Rectangle(0, 0, (int)(Game1.graphics.PreferredBackBufferWidth / Game1.NativeZoomLevel), (int)(Game1.graphics.PreferredBackBufferHeight / Game1.NativeZoomLevel)));
|
||||
this.smallFont = content.Load<SpriteFont>(@"Fonts\SmallFont");
|
||||
Game1.mobileSpriteSheet = content.Load<Texture2D>(@"LooseSprites\\MobileAtlas_manually_made");
|
||||
this.scrollbar = new MobileScrollbar(0, 96, 16, this.ScrollBoxHeight - 192);
|
||||
this.scrollbox = new MobileScrollbox(0, 0, this.MaxTextAreaWidth, this.ScrollBoxHeight, this.MaxScrollBoxHeight,
|
||||
new Rectangle(0, 0, (int)(Game1.graphics.PreferredBackBufferWidth / Game1.NativeZoomLevel), this.ScrollBoxHeight),
|
||||
this.scrollbar
|
||||
);
|
||||
}
|
||||
|
||||
public void Show()
|
||||
|
@ -58,6 +65,12 @@ namespace StardewModdingAPI
|
|||
|
||||
public override void receiveLeftClick(int x, int y, bool playSound = true)
|
||||
{
|
||||
if (this.scrollbar.sliderContains(x, y) || this.scrollbar.sliderRunnerContains(x, y))
|
||||
{
|
||||
float num = this.scrollbar.setY(y);
|
||||
this.scrollbox.setYOffsetForScroll(-((int)((num * this.scrollbox.getMaxYOffset()) / 100f)));
|
||||
Game1.playSound("shwip");
|
||||
}
|
||||
|
||||
if (this.upperRightCloseButton.bounds.Contains(x, y))
|
||||
{
|
||||
|
@ -126,6 +139,7 @@ namespace StardewModdingAPI
|
|||
this.consoleMessageQueue.AddFirst(new KeyValuePair<ConsoleLogLevel, string>(level, consoleMessage));
|
||||
if (this.consoleMessageQueue.Count > 2000)
|
||||
{
|
||||
this.parseTextCache.Remove(this.consoleMessageQueue.Last.Value.Value);
|
||||
this.consoleMessageQueue.RemoveLast();
|
||||
}
|
||||
}
|
||||
|
@ -136,27 +150,39 @@ namespace StardewModdingAPI
|
|||
this.scrollbox.update(time);
|
||||
}
|
||||
|
||||
private string _parseText(string text)
|
||||
private LinkedList<string> _parseText(string text)
|
||||
{
|
||||
if (this.parseTextCache.TryGetValue(text, out LinkedList<string> returnString))
|
||||
{
|
||||
return returnString;
|
||||
}
|
||||
returnString = new LinkedList<string>();
|
||||
string line = string.Empty;
|
||||
string returnString = string.Empty;
|
||||
string[] strings = text.Split("\n");
|
||||
foreach (string t in strings)
|
||||
{
|
||||
if (this.smallFont.MeasureString(t).X < this.MaxTextAreaWidth)
|
||||
{
|
||||
returnString.AddFirst(t);
|
||||
continue;
|
||||
}
|
||||
string[] wordArray = t.Split(' ');
|
||||
Vector2 masureResult = new Vector2(0,0);
|
||||
foreach (string word in wordArray)
|
||||
{
|
||||
if (this.smallFont.MeasureString(line + word).X > this.MaxTextAreaWidth)
|
||||
masureResult += this.smallFont.MeasureString(word + " ");
|
||||
if (masureResult.X > this.MaxTextAreaWidth)
|
||||
{
|
||||
returnString = returnString + line + '\n';
|
||||
returnString.AddFirst(line);
|
||||
line = string.Empty;
|
||||
masureResult = new Vector2(0, 0);
|
||||
}
|
||||
line = line + word + ' ';
|
||||
}
|
||||
returnString = returnString + line + '\n';
|
||||
returnString.AddFirst(line);
|
||||
line = string.Empty;
|
||||
}
|
||||
returnString.TrimEnd('\n');
|
||||
this.parseTextCache.TryAdd(text, returnString);
|
||||
return returnString;
|
||||
}
|
||||
|
||||
|
@ -185,15 +211,27 @@ namespace StardewModdingAPI
|
|||
|
||||
public override void draw(SpriteBatch b)
|
||||
{
|
||||
this.scrollbar.draw(b);
|
||||
this.scrollbox.setUpForScrollBoxDrawing(b);
|
||||
lock (this.consoleMessageQueue)
|
||||
{
|
||||
float offset = 0;
|
||||
Vector2 size = this.smallFont.MeasureString("Aa");
|
||||
foreach (var log in this.consoleMessageQueue)
|
||||
{
|
||||
string text = this._parseText(log.Value);
|
||||
Vector2 size = this.smallFont.MeasureString(text);
|
||||
float y = Game1.game1.screen.Height - size.Y - offset - this.scrollbox.getYOffsetForScroll();
|
||||
LinkedList<string> textArray = this._parseText(log.Value);
|
||||
float baseOffset = Game1.game1.screen.Height - this.scrollbox.getYOffsetForScroll();
|
||||
if (baseOffset - size.Y * textArray.Count - offset > this.ScrollBoxHeight)
|
||||
{
|
||||
offset += size.Y * textArray.Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (string text in textArray)
|
||||
{
|
||||
float y = baseOffset - size.Y - offset;
|
||||
if (y < -16)
|
||||
continue;
|
||||
offset += size.Y;
|
||||
switch (log.Key)
|
||||
{
|
||||
|
@ -217,7 +255,8 @@ namespace StardewModdingAPI
|
|||
b.DrawString(this.smallFont, text, new Vector2(16, y), Color.LightGray);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (offset > this.MaxScrollBoxHeight)
|
||||
{
|
||||
break;
|
||||
|
|
|
@ -21,6 +21,7 @@ using File = Java.IO.File;
|
|||
using Microsoft.AppCenter;
|
||||
using Newtonsoft.Json;
|
||||
using Microsoft.AppCenter.Crashes;
|
||||
using Android.Content;
|
||||
|
||||
namespace StardewModdingAPI
|
||||
{
|
||||
|
@ -177,8 +178,12 @@ namespace StardewModdingAPI
|
|||
}
|
||||
|
||||
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
|
||||
{
|
||||
try
|
||||
{
|
||||
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
catch (ActivityNotFoundException) { }
|
||||
if (this.HasPermissions)
|
||||
this.OnCreatePartTwo();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue