2018-06-13 17:36:52 +08:00
using Microsoft.Xna.Framework ;
using Microsoft.Xna.Framework.Input ;
2017-09-13 02:20:18 +08:00
using StardewModdingAPI ;
using StardewValley ;
using StardewValley.Menus ;
2018-08-08 15:12:31 +08:00
using StardewValley.Network ;
2018-08-23 16:23:42 +08:00
using StardustCore.Menus ;
2017-09-12 14:39:59 +08:00
using StardustCore.ModInfo ;
2018-12-16 12:54:58 +08:00
using StardustCore.NetCode ;
2018-06-13 17:36:52 +08:00
using StardustCore.Objects ;
2018-06-13 09:42:31 +08:00
using StardustCore.Objects.Tools ;
2017-09-14 04:53:12 +08:00
using StardustCore.Serialization ;
2018-06-13 14:25:36 +08:00
using StardustCore.UIUtilities ;
2018-03-30 20:46:24 +08:00
using StardustCore.UIUtilities.SpriteFonts ;
2017-09-05 19:13:42 +08:00
using System ;
2017-07-14 11:27:48 +08:00
using System.Collections.Generic ;
2017-09-14 04:53:12 +08:00
using System.IO ;
2017-07-14 11:27:48 +08:00
using System.Linq ;
2018-08-08 15:12:31 +08:00
using System.Reflection ;
2017-07-14 11:27:48 +08:00
using System.Text ;
using System.Threading.Tasks ;
2018-12-17 13:27:07 +08:00
using System.Xml ;
using System.Xml.Serialization ;
2017-07-14 11:27:48 +08:00
2017-09-05 19:13:42 +08:00
namespace StardustCore
2017-07-14 11:27:48 +08:00
{
2018-12-16 19:14:52 +08:00
/ *
* Known issues :
* Clients have a error on Serialization that says they run across unknown XML elements such as core objects . However , inventories for farmhands and modded objects still get serialized properly .
2018-12-17 16:02:43 +08:00
* Inventories get wiped after being returned home from a festival .
* /
2018-12-16 19:14:52 +08:00
2017-09-05 19:13:42 +08:00
public class ModCore : Mod
2017-07-14 11:27:48 +08:00
{
2017-09-12 09:35:31 +08:00
public static IModHelper ModHelper ;
public static IMonitor ModMonitor ;
2018-08-09 04:18:51 +08:00
public static IManifest Manifest ;
2017-09-14 04:53:12 +08:00
public static Serialization . SerializationManager SerializationManager ;
2018-06-13 17:36:52 +08:00
public static UIUtilities . TextureManager TextureManager ;
2018-08-09 04:18:51 +08:00
public static Dictionary < string , TextureManager > TextureManagers ;
2018-08-08 15:12:31 +08:00
2018-08-09 00:32:02 +08:00
private Type lastMenuType ;
2018-08-21 04:53:56 +08:00
public ModConfig config ;
2018-12-16 16:54:57 +08:00
public bool playerJustDisconnected ;
2018-12-17 13:27:07 +08:00
public bool justWarped ;
2018-02-06 17:27:28 +08:00
public static string ContentDirectory ;
2017-09-12 09:35:31 +08:00
public override void Entry ( IModHelper helper )
{
2018-06-13 09:42:31 +08:00
ModHelper = Helper ;
2018-02-06 17:27:28 +08:00
ModMonitor = Monitor ;
2018-08-09 04:18:51 +08:00
Manifest = ModManifest ;
2017-09-13 07:30:30 +08:00
//Unused MetaData information. Works in player inventory but not in chests. Besides who really care where an object is from anyways. Also doesn't work 100% like I intended since it only gets base mod object that this runs from, not extensions?
2017-09-14 04:53:12 +08:00
// StardewModdingAPI.Events.GraphicsEvents.OnPostRenderGuiEvent += Metadata.GameEvents_UpdateTick;
2018-02-06 17:27:28 +08:00
//StardewModdingAPI.Events.ControlEvents.MouseChanged += ControlEvents_MouseChanged;
2018-12-16 16:54:57 +08:00
2017-09-14 04:53:12 +08:00
StardewModdingAPI . Events . SaveEvents . AfterSave + = SaveEvents_AfterSave ;
StardewModdingAPI . Events . SaveEvents . BeforeSave + = SaveEvents_BeforeSave ;
StardewModdingAPI . Events . SaveEvents . AfterLoad + = SaveEvents_AfterLoad ;
2018-08-09 00:32:02 +08:00
StardewModdingAPI . Events . MenuEvents . MenuChanged + = MenuEvents_MenuChanged ;
StardewModdingAPI . Events . MenuEvents . MenuClosed + = MenuEvents_MenuClosed ;
2017-11-17 15:07:30 +08:00
2018-12-16 12:54:58 +08:00
ModHelper . Events . Multiplayer . PeerContextReceived + = Multiplayer_PeerContextReceived ;
ModHelper . Events . Multiplayer . ModMessageReceived + = Multiplayer_ModMessageReceived ;
2018-12-16 16:54:57 +08:00
ModHelper . Events . Multiplayer . PeerDisconnected + = Multiplayer_PeerDisconnected ;
playerJustDisconnected = false ;
2018-12-16 12:54:58 +08:00
2017-11-17 15:07:30 +08:00
IlluminateFramework . Colors . initializeColors ( ) ;
2018-08-14 03:41:11 +08:00
ContentDirectory = "Content" ;
if ( ! Directory . Exists ( ContentDirectory ) ) Directory . CreateDirectory ( Path . Combine ( ModHelper . DirectoryPath , "Content" ) ) ;
2018-03-30 20:46:24 +08:00
SpriteFonts . initialize ( ) ;
2018-06-13 09:42:31 +08:00
2018-12-16 16:54:57 +08:00
2018-08-09 04:18:51 +08:00
TextureManagers = new Dictionary < string , TextureManager > ( ) ;
2018-06-13 17:36:52 +08:00
TextureManager = new TextureManager ( ) ;
2018-12-16 03:49:56 +08:00
TextureManager . addTexture ( "Test1" , new Texture2DExtended ( ModCore . ModHelper , Manifest , Path . Combine ( "Content" , "Graphics" , "MultiTest" , "Test1.png" ) ) ) ;
TextureManager . addTexture ( "Test2" , new Texture2DExtended ( ModCore . ModHelper , Manifest , Path . Combine ( "Content" , "Graphics" , "MultiTest" , "Test2.png" ) ) ) ;
TextureManager . addTexture ( "Test3" , new Texture2DExtended ( ModCore . ModHelper , Manifest , Path . Combine ( "Content" , "Graphics" , "MultiTest" , "Test3.png" ) ) ) ;
2018-08-09 04:18:51 +08:00
TextureManagers . Add ( ModManifest . UniqueID , TextureManager ) ;
2018-08-08 01:07:33 +08:00
StardewModdingAPI . Events . ControlEvents . KeyPressed + = ControlEvents_KeyPressed ;
2018-12-17 16:02:43 +08:00
ModHelper . Events . World . ObjectListChanged + = World_ObjectListChanged ;
2018-08-21 04:53:56 +08:00
config = ModHelper . ReadConfig < ModConfig > ( ) ;
2018-08-08 01:07:33 +08:00
StardewModdingAPI . Events . GameEvents . UpdateTick + = GameEvents_UpdateTick ;
2018-12-16 18:17:16 +08:00
2018-12-17 13:27:07 +08:00
Helper . Events . Player . Warped + = Player_Warped ;
2018-12-16 18:17:16 +08:00
ModHelper . Events . GameLoop . ReturnedToTitle + = GameLoop_ReturnedToTitle ;
2018-08-08 15:12:31 +08:00
}
2018-12-17 16:02:43 +08:00
private void World_ObjectListChanged ( object sender , StardewModdingAPI . Events . ObjectListChangedEventArgs e )
2018-12-17 13:27:07 +08:00
{
2018-12-17 16:02:43 +08:00
if ( e . Added ! = null )
{
}
else if ( e . Removed ! = null )
{
2018-12-17 13:27:07 +08:00
2018-12-17 16:02:43 +08:00
}
}
private void Player_Warped ( object sender , StardewModdingAPI . Events . WarpedEventArgs e )
{
if ( justWarped ) return ;
2018-12-17 13:27:07 +08:00
SerializationManager . cleanUpInventory ( ) ;
//SerializationManager.cleanUpWorld();
//SerializationManager.cleanUpStorageContainers();
justWarped = true ;
}
2018-12-16 18:17:16 +08:00
private void GameLoop_ReturnedToTitle ( object sender , StardewModdingAPI . Events . ReturnedToTitleEventArgs e )
2018-12-16 16:54:57 +08:00
{
2018-12-16 18:17:16 +08:00
if ( Game1 . player ! = null )
2018-12-16 16:54:57 +08:00
{
SerializationManager . cleanUpInventory ( ) ;
2018-12-17 16:02:43 +08:00
//SerializationManager.cleanUpWorld();
//SerializationManager.cleanUpStorageContainers();
2018-12-18 02:37:23 +08:00
//Monitor.Log("Saved the player data after returning to title!");
2018-12-16 16:54:57 +08:00
}
}
private void Multiplayer_PeerDisconnected ( object sender , StardewModdingAPI . Events . PeerDisconnectedEventArgs e )
{
this . playerJustDisconnected = true ;
2018-12-16 19:14:52 +08:00
2018-12-18 02:37:23 +08:00
//ModMonitor.Log("Peer disconnected! Serializing custom objects");
2018-12-16 19:14:52 +08:00
2018-12-16 16:54:57 +08:00
SerializationManager . cleanUpInventory ( ) ;
2018-12-17 16:02:43 +08:00
//SerializationManager.cleanUpWorld();
//SerializationManager.cleanUpStorageContainers();
2018-12-16 18:17:16 +08:00
2018-12-16 16:54:57 +08:00
}
2018-12-16 12:54:58 +08:00
private void Multiplayer_ModMessageReceived ( object sender , StardewModdingAPI . Events . ModMessageReceivedEventArgs e )
{
2018-12-18 02:37:23 +08:00
//ModMonitor.Log("Get messages from"+e.FromModID);
//ModMonitor.Log("Message type: " + e.Type);
2018-12-17 07:54:59 +08:00
2018-12-16 12:54:58 +08:00
if ( e . FromModID = = this . ModManifest . UniqueID )
{
if ( e . Type = = MultiplayerSupport . CleanUpModObjects )
{
SerializationManager . cleanUpInventory ( ) ;
SerializationManager . cleanUpWorld ( ) ;
SerializationManager . cleanUpStorageContainers ( ) ;
}
else if ( e . Type = = MultiplayerSupport . RestoreModObjects )
{
2018-12-17 16:02:43 +08:00
if ( Game1 . eventUp ) return ; //Prevent item duplication.
2018-12-18 02:37:23 +08:00
//ModMonitor.Log("Restoring custom objects.");
2018-12-16 12:54:58 +08:00
SerializationManager . restoreAllModObjects ( SerializationManager . trackedObjectList ) ;
}
}
}
private void Multiplayer_PeerContextReceived ( object sender , StardewModdingAPI . Events . PeerContextReceivedEventArgs e )
{
2018-12-16 19:14:52 +08:00
2018-12-16 16:54:57 +08:00
if ( SerializationManager = = null ) return ;
2018-12-16 19:14:52 +08:00
2018-12-17 16:02:43 +08:00
if ( Game1 . eventUp )
{
SerializationManager . restoreAllModObjects ( SerializationManager . trackedObjectList ) ; //Force a restore and then a serialize save to prevent deletions.
}
2018-12-18 02:37:23 +08:00
//ModMonitor.Log("Got peer context. Serialize/remove all custom objects really quick to prevent loading errors.");
2018-12-16 19:14:52 +08:00
2018-12-17 16:02:43 +08:00
2018-12-16 12:54:58 +08:00
SerializationManager . cleanUpInventory ( ) ;
2018-12-17 16:02:43 +08:00
//SerializationManager.cleanUpWorld();
//SerializationManager.cleanUpStorageContainers();
2018-12-16 18:17:16 +08:00
2018-12-16 12:54:58 +08:00
}
2018-08-09 00:32:02 +08:00
private void MenuEvents_MenuClosed ( object sender , StardewModdingAPI . Events . EventArgsClickableMenuClosed e )
{
if ( this . lastMenuType = = null )
{
return ;
}
else
{
2018-12-16 16:54:57 +08:00
/ *
if ( lastMenuType = = typeof ( StardewValley . Menus . SaveGameMenu ) | | lastMenuType = = typeof ( StardewValley . Menus . ShippingMenu ) )
2018-08-09 00:32:02 +08:00
{
SerializationManager . restoreAllModObjects ( SerializationManager . trackedObjectList ) ;
2018-12-16 16:54:57 +08:00
List < long > playerIds = new List < long > ( ) ;
foreach ( Farmer f in Game1 . getAllFarmers ( ) )
{
if ( f = = Game1 . player ) continue ;
playerIds . Add ( f . uniqueMultiplayerID ) ;
}
ModHelper . Multiplayer . SendMessage < string > ( MultiplayerSupport . RestoreModObjects , MultiplayerSupport . RestoreModObjects , new string [ ] { ModManifest . UniqueID } , playerIds . ToArray ( ) ) ;
2018-08-09 00:32:02 +08:00
}
2018-12-16 16:54:57 +08:00
* /
//Only fires in multiplayer since ReadyCheckDialogue only appears in multiplayer
if ( lastMenuType = = typeof ( StardewValley . Menus . ReadyCheckDialog ) & & Game1 . player . canMove = = false & & Game1 . player . isInBed )
{
2018-12-18 02:37:23 +08:00
//ModMonitor.Log("Time to sleep/serialize all objects!");
2018-12-16 16:54:57 +08:00
SerializationManager . cleanUpInventory ( ) ;
SerializationManager . cleanUpWorld ( ) ;
SerializationManager . cleanUpStorageContainers ( ) ;
/ *
List < long > playerIds = new List < long > ( ) ;
foreach ( Farmer f in Game1 . getAllFarmers ( ) )
{
if ( f = = null ) continue ;
if ( f = = Game1 . player ) continue ;
playerIds . Add ( f . uniqueMultiplayerID ) ;
}
* /
//ModHelper.Multiplayer.SendMessage<string>(MultiplayerSupport.CleanUpModObjects, MultiplayerSupport.CleanUpModObjects, new string[] { ModManifest.UniqueID }, playerIds.ToArray());
2018-08-09 00:32:02 +08:00
}
}
}
private void MenuEvents_MenuChanged ( object sender , StardewModdingAPI . Events . EventArgsClickableMenuChanged e )
2018-12-16 16:54:57 +08:00
{
2018-08-09 00:32:02 +08:00
lastMenuType = Game1 . activeClickableMenu . GetType ( ) ;
}
2018-08-08 15:12:31 +08:00
/// <summary>
/// Returns the value of the data snagged by reflection.
/// </summary>
/// <param name="type"></param>
/// <param name="instance"></param>
/// <param name="fieldName"></param>
/// <returns></returns>
public static object GetInstanceField ( Type type , object instance , string fieldName )
{
BindingFlags bindFlags = BindingFlags . Instance | BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Static ;
FieldInfo field = type . GetField ( fieldName , bindFlags ) ;
/ *
FieldInfo [ ] meh = type . GetFields ( bindFlags ) ;
foreach ( var v in meh )
{
if ( v . Name = = null )
{
continue ;
}
Monitor . Log ( v . Name ) ;
}
* /
return field . GetValue ( instance ) ;
}
public static void SetInstanceField ( Type type , object instance , object value , string fieldName )
{
BindingFlags bindFlags = BindingFlags . Instance | BindingFlags . Public | BindingFlags . NonPublic
| BindingFlags . Static ;
FieldInfo field = type . GetField ( fieldName , bindFlags ) ;
field . SetValue ( instance , value ) ;
return ;
2017-09-14 04:53:12 +08:00
}
2018-08-08 01:07:33 +08:00
private void GameEvents_UpdateTick ( object sender , EventArgs e )
{
2018-12-16 16:54:57 +08:00
if ( playerJustDisconnected )
2018-08-08 15:12:31 +08:00
{
2018-12-16 16:54:57 +08:00
playerJustDisconnected = false ;
2018-12-16 18:17:16 +08:00
if ( Game1 . activeClickableMenu ! = null )
{
if ( Game1 . activeClickableMenu . GetType ( ) = = typeof ( StardewValley . Menus . TitleMenu ) ) return ;
}
2018-12-18 02:37:23 +08:00
//ModMonitor.Log("Restore objects after peer disconnect!");
2018-12-16 16:54:57 +08:00
SerializationManager . restoreAllModObjects ( SerializationManager . trackedObjectList ) ;
2018-08-08 15:12:31 +08:00
}
2018-12-17 13:27:07 +08:00
else if ( justWarped & & Game1 . eventUp = = false & & Game1 . activeClickableMenu = = null )
{
justWarped = false ;
2018-12-18 02:37:23 +08:00
//ModMonitor.Log("Restore objects after player warping!");
2018-12-17 13:27:07 +08:00
SerializationManager . restoreAllModObjects ( SerializationManager . trackedObjectList , true ) ;
}
2018-08-08 01:07:33 +08:00
}
private void ControlEvents_KeyPressed ( object sender , StardewModdingAPI . Events . EventArgsKeyPressed e )
{
2018-08-23 16:23:42 +08:00
if ( e . KeyPressed . ToString ( ) = = config . modularMenuKey & & Game1 . activeClickableMenu = = null )
{
2018-09-19 09:04:38 +08:00
//Game1.activeClickableMenu = new ModularGameMenu(0);
2018-08-23 16:23:42 +08:00
}
2018-08-08 01:07:33 +08:00
}
2017-11-25 05:12:36 +08:00
2017-09-14 04:53:12 +08:00
private void SaveEvents_AfterLoad ( object sender , EventArgs e )
{
2018-12-16 18:17:16 +08:00
Game1 . game1 . Disposed + = Game1_Disposed ;
2018-12-15 19:00:32 +08:00
2018-12-17 13:27:07 +08:00
string basePath = Path . Combine ( ModCore . ModHelper . DirectoryPath , "PlayerData" , Game1 . player . Name + "_" + Game1 . player . uniqueMultiplayerID ) ;
string invPath = Path . Combine ( basePath , "PlayerInventory" ) ;
string worldPath = Path . Combine ( basePath , "ObjectsInWorld" ) ;
string trashPath = Path . Combine ( basePath , "ModTrashFolder" ) ;
string chestPath = Path . Combine ( basePath , "StorageContainers" ) ;
2018-12-16 16:54:57 +08:00
SerializationManager = new SerializationManager ( invPath , trashPath , worldPath , chestPath ) ;
SerializationManager . initializeDefaultSuportedTypes ( ) ;
2018-12-16 12:54:58 +08:00
2018-12-16 16:54:57 +08:00
SerializationManager . restoreAllModObjects ( SerializationManager . trackedObjectList ) ;
List < long > playerIds = new List < long > ( ) ;
2018-12-17 07:54:59 +08:00
foreach ( Farmer f in Game1 . getOnlineFarmers ( ) )
2018-12-16 16:54:57 +08:00
{
2018-12-17 07:54:59 +08:00
if ( f . uniqueMultiplayerID = = Game1 . player . uniqueMultiplayerID ) continue ;
2018-12-16 16:54:57 +08:00
playerIds . Add ( f . uniqueMultiplayerID ) ;
2018-12-17 07:54:59 +08:00
ModMonitor . Log ( "Sending Message to peer ID: " + f . uniqueMultiplayerID . ToString ( ) ) ;
2018-12-16 16:54:57 +08:00
}
2018-12-18 02:37:23 +08:00
//ModMonitor.Log("Send message to restore mod objects after load!");
2018-12-16 16:54:57 +08:00
ModHelper . Multiplayer . SendMessage < string > ( MultiplayerSupport . RestoreModObjects , MultiplayerSupport . RestoreModObjects , new string [ ] { ModManifest . UniqueID } , playerIds . ToArray ( ) ) ;
2018-12-16 03:49:56 +08:00
/ *
2018-12-15 19:00:32 +08:00
List < KeyValuePair < Vector2 , MultiTileComponent > > objs = new List < KeyValuePair < Vector2 , MultiTileComponent > > ( ) ;
MultiTileComponent tile1 = new MultiTileComponent ( 0 , "Tileobj1" , "A basic tile obj" , new Texture2DExtended ( ModCore . ModHelper , ModCore . Manifest , Path . Combine ( "Content" , "Graphics" , "MultiTest" , "Test1.png" ) ) ) ;
MultiTileComponent tile2 = new MultiTileComponent ( 0 , "Tileobj2" , "A basic tile obj" , new Texture2DExtended ( ModCore . ModHelper , ModCore . Manifest , Path . Combine ( "Content" , "Graphics" , "MultiTest" , "Test2.png" ) ) ) ;
MultiTileComponent tile3 = new MultiTileComponent ( 0 , "Tileobj3" , "A basic tile obj" , new Texture2DExtended ( ModCore . ModHelper , ModCore . Manifest , Path . Combine ( "Content" , "Graphics" , "MultiTest" , "Test3.png" ) ) ) ;
2018-06-13 17:36:52 +08:00
objs . Add ( new KeyValuePair < Vector2 , MultiTileComponent > ( new Vector2 ( 0 , 0 ) , tile1 ) ) ;
objs . Add ( new KeyValuePair < Vector2 , MultiTileComponent > ( new Vector2 ( 1 , 0 ) , tile2 ) ) ;
objs . Add ( new KeyValuePair < Vector2 , MultiTileComponent > ( new Vector2 ( 2 , 0 ) , tile3 ) ) ;
2018-06-13 14:25:36 +08:00
2018-12-15 19:00:32 +08:00
MultiTileObject collection = new MultiTileObject ( "MultiTest" , "Trying to get multi object testing working" , Vector2 . Zero , new Texture2DExtended ( ModCore . ModHelper , ModCore . Manifest , Path . Combine ( "Content" , "Graphics" , "MultiTest" , "Test3.png" ) ) , objs , StardustCore . IlluminateFramework . Colors . invertColor ( StardustCore . IlluminateFramework . LightColorsList . Purple ) , "MultiTest" ) ;
2018-06-13 14:25:36 +08:00
2018-12-15 19:00:32 +08:00
Game1 . player . addItemToInventory ( collection ) ;
2018-08-09 04:18:51 +08:00
* /
2018-12-16 16:54:57 +08:00
2018-12-18 02:37:23 +08:00
/ *
2018-12-16 03:49:56 +08:00
CoreObject testTile = new CoreObject ( new Texture2DExtended ( ModCore . ModHelper , ModCore . Manifest , Path . Combine ( "Content" , "Graphics" , "MultiTest" , "Test3.png" ) ) , 3 , Vector2 . Zero , 9 ) ;
testTile . description = "Hello" ;
testTile . Name = "test" ;
testTile . displayName = "test" ;
Game1 . player . addItemToInventory ( testTile ) ;
2018-12-18 02:37:23 +08:00
* /
2018-12-16 03:49:56 +08:00
2017-09-14 04:53:12 +08:00
}
2018-12-16 18:17:16 +08:00
private void Game1_Disposed ( object sender , EventArgs e )
{
if ( Game1 . player ! = null & & lastMenuType ! = typeof ( StardewValley . Menus . TitleMenu ) )
{
2018-12-18 02:37:23 +08:00
//ModMonitor.Log("Serialize all objects on disposing!");
2018-12-16 18:17:16 +08:00
SerializationManager . cleanUpInventory ( ) ;
2018-12-17 16:02:43 +08:00
//SerializationManager.cleanUpWorld();
//SerializationManager.cleanUpStorageContainers();
2018-12-16 18:17:16 +08:00
}
}
2017-09-14 04:53:12 +08:00
private void SaveEvents_AfterSave ( object sender , EventArgs e )
{
2018-12-16 16:54:57 +08:00
2017-09-14 04:53:12 +08:00
SerializationManager . restoreAllModObjects ( SerializationManager . trackedObjectList ) ;
}
private void SaveEvents_BeforeSave ( object sender , EventArgs e )
{
2018-12-16 16:54:57 +08:00
//Call the serialization if alone since the ReadyCheckDialogue menu never shows with just 1 player online.
if ( Game1 . IsMultiplayer = = false | | ( Game1 . IsMultiplayer & & Game1 . getOnlineFarmers ( ) . Count = = 1 ) )
{
2018-12-18 02:37:23 +08:00
//ModMonitor.Log("Serialize all objects before save when only 1 farmer present!");
2018-12-16 16:54:57 +08:00
SerializationManager . cleanUpInventory ( ) ;
SerializationManager . cleanUpWorld ( ) ;
SerializationManager . cleanUpStorageContainers ( ) ;
}
2017-09-13 02:20:18 +08:00
}
private void ControlEvents_MouseChanged ( object sender , StardewModdingAPI . Events . EventArgsMouseStateChanged e )
{
2018-08-23 16:23:42 +08:00
//???
return ;
2017-09-13 02:20:18 +08:00
if ( Game1 . activeClickableMenu = = null ) return ;
var MouseState = Mouse . GetState ( ) ;
if ( Game1 . activeClickableMenu is StardewValley . Menus . ItemGrabMenu & & MouseState . LeftButton = = ButtonState . Released )
{
( Game1 . activeClickableMenu as StardewValley . Menus . ItemGrabMenu ) . ItemsToGrabMenu . populateClickableComponentList ( ) ;
for ( int index = 0 ; index < ( Game1 . activeClickableMenu as StardewValley . Menus . ItemGrabMenu ) . ItemsToGrabMenu . inventory . Count ; + + index )
{
if ( ( Game1 . activeClickableMenu as StardewValley . Menus . ItemGrabMenu ) . ItemsToGrabMenu . inventory [ index ] ! = null )
{
( Game1 . activeClickableMenu as StardewValley . Menus . ItemGrabMenu ) . ItemsToGrabMenu . inventory [ index ] . myID + = 53910 ;
( Game1 . activeClickableMenu as StardewValley . Menus . ItemGrabMenu ) . ItemsToGrabMenu . inventory [ index ] . upNeighborID + = 53910 ;
( Game1 . activeClickableMenu as StardewValley . Menus . ItemGrabMenu ) . ItemsToGrabMenu . inventory [ index ] . rightNeighborID + = 53910 ;
( Game1 . activeClickableMenu as StardewValley . Menus . ItemGrabMenu ) . ItemsToGrabMenu . inventory [ index ] . downNeighborID = - 7777 ;
( Game1 . activeClickableMenu as StardewValley . Menus . ItemGrabMenu ) . ItemsToGrabMenu . inventory [ index ] . leftNeighborID + = 53910 ;
( Game1 . activeClickableMenu as StardewValley . Menus . ItemGrabMenu ) . ItemsToGrabMenu . inventory [ index ] . fullyImmutable = true ;
}
}
// (Game1.activeClickableMenu as ItemGrabMenu).inventory.playerInventory = false;
// Game1.activeClickableMenu =Game1.activeClickableMenu;//new ItemGrabMenu((Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.actualInventory,true,true,null,null,null,null,false,false,true,true,true,1,null,-1,null);
}
2017-09-12 09:35:31 +08:00
}
2017-07-14 11:27:48 +08:00
}
}