Implemented right click and shift right click functionality for custom objects.
This commit is contained in:
parent
11fca7dd6a
commit
23d964d861
|
@ -1,5 +1,6 @@
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using Microsoft.Xna.Framework.Input;
|
||||||
using PyTK.CustomElementHandler;
|
using PyTK.CustomElementHandler;
|
||||||
using Revitalize.Framework.Graphics;
|
using Revitalize.Framework.Graphics;
|
||||||
using StardewValley;
|
using StardewValley;
|
||||||
|
@ -63,10 +64,25 @@ namespace Revitalize.Framework.Objects
|
||||||
|
|
||||||
public override bool checkForAction(Farmer who, bool justCheckingForActivity = false)
|
public override bool checkForAction(Farmer who, bool justCheckingForActivity = false)
|
||||||
{
|
{
|
||||||
|
var mState = Microsoft.Xna.Framework.Input.Mouse.GetState();
|
||||||
|
var keyboardState = Game1.GetKeyboardState();
|
||||||
|
|
||||||
|
if (mState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && (keyboardState.IsKeyDown(Keys.LeftShift) || keyboardState.IsKeyDown(Keys.RightShift))==false)
|
||||||
|
{
|
||||||
|
Revitalize.ModCore.log("Right clicked!");
|
||||||
|
return rightClicked(who);
|
||||||
|
}
|
||||||
|
else if(mState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && (keyboardState.IsKeyDown(Keys.LeftShift) || keyboardState.IsKeyDown(Keys.RightShift)))
|
||||||
|
{
|
||||||
|
return shiftRightClicked(who);
|
||||||
|
}
|
||||||
|
|
||||||
if (justCheckingForActivity)
|
if (justCheckingForActivity)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
Revitalize.ModCore.ModMonitor.Log("Interact with core object!");
|
}
|
||||||
return true;
|
Revitalize.ModCore.log("Left clicked!");
|
||||||
|
return this.clicked(who);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
||||||
|
@ -76,6 +92,36 @@ namespace Revitalize.Framework.Objects
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public virtual bool rightClicked(Farmer who)
|
||||||
|
{
|
||||||
|
// Game1.showRedMessage("YOOO");
|
||||||
|
//do some stuff when the right button is down
|
||||||
|
// rotate();
|
||||||
|
if (this.heldObject.Value != null)
|
||||||
|
{
|
||||||
|
// Game1.player.addItemByMenuIfNecessary(this.heldObject);
|
||||||
|
// this.heldObject = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// this.heldObject = Game1.player.ActiveObject;
|
||||||
|
// Game1.player.removeItemFromInventory(heldObject);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool shiftRightClicked(Farmer who)
|
||||||
|
{
|
||||||
|
Revitalize.ModCore.log("Shift right clicked!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool clicked(Farmer who)
|
||||||
|
{
|
||||||
|
Revitalize.ModCore.log("Clicky click!");
|
||||||
|
return base.clicked(who);
|
||||||
|
}
|
||||||
|
|
||||||
public override Color getCategoryColor()
|
public override Color getCategoryColor()
|
||||||
{
|
{
|
||||||
return info.categoryColor;
|
return info.categoryColor;
|
||||||
|
|
|
@ -58,6 +58,9 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Analyzer Include="..\packages\Pathoschild.Stardew.ModBuildConfig.2.2.0\analyzers\dotnet\cs\StardewModdingAPI.ModBuildConfig.Analyzer.dll" />
|
<Analyzer Include="..\packages\Pathoschild.Stardew.ModBuildConfig.2.2.0\analyzers\dotnet\cs\StardewModdingAPI.ModBuildConfig.Analyzer.dll" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Framework\Objects\Furniture\" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="..\packages\Pathoschild.Stardew.ModBuildConfig.2.2.0\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.2.0\build\Pathoschild.Stardew.ModBuildConfig.targets')" />
|
<Import Project="..\packages\Pathoschild.Stardew.ModBuildConfig.2.2.0\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.2.0\build\Pathoschild.Stardew.ModBuildConfig.targets')" />
|
||||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
|
Loading…
Reference in New Issue