Skip to content

Commit

Permalink
2172: Add support for a crafting journal (AscensionGameDev#2173)
Browse files Browse the repository at this point in the history
* feat: (Day) Add a journal-mode for crafting. Needs winforms update

* feat: (Day) Winforms work for crafting journal

* remove .resx
  • Loading branch information
AlexVild authored and cydyn committed Mar 11, 2024
1 parent 4bf172f commit 772a90f
Show file tree
Hide file tree
Showing 14 changed files with 161 additions and 85 deletions.
5 changes: 5 additions & 0 deletions Intersect (Core)/GameObjects/Events/Commands/EventCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,11 @@ public partial class OpenCraftingTableCommand : EventCommand
public override EventCommandType Type { get; } = EventCommandType.OpenCraftingTable;

public Guid CraftingTableId { get; set; }

/// <summary>
/// Does not allow crafting, but displays crafts and their requirements.
/// </summary>
public bool JournalMode { get; set; }
}

public partial class SetClassCommand : EventCommand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ public CraftingTablePacket()
{
}

public CraftingTablePacket(string tableData, bool close)
public CraftingTablePacket(string tableData, bool close, bool journalMode)
{
TableData = tableData;
Close = close;
JournalMode = journalMode;
}

[Key(0)]
Expand All @@ -22,6 +23,8 @@ public CraftingTablePacket(string tableData, bool close)
[Key(1)]
public bool Close { get; set; }

[Key(2)]
public bool JournalMode { get; set; }
}

}
14 changes: 12 additions & 2 deletions Intersect.Client/Interface/Game/Crafting/CraftingWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,17 @@ public partial class CraftingWindow

public bool IsCrafting => mRemainingCrafts > 0;

public CraftingWindow(Canvas gameCanvas)
private bool mJournalMode { get; set; }

public CraftingWindow(Canvas gameCanvas, bool journalMode)
{
mCraftWindow = new WindowControl(gameCanvas, Globals.ActiveCraftingTable.Name, false, "CraftingWindow");
mCraftWindow.DisableResizing();

mItemContainer = new ScrollControl(mCraftWindow, "IngredientsContainer");

mJournalMode = journalMode;

//Labels
mLblRecipes = new Label(mCraftWindow, "RecipesTitle");
mLblRecipes.Text = Strings.Crafting.recipes;
Expand Down Expand Up @@ -116,6 +120,12 @@ public CraftingWindow(Canvas gameCanvas)

mCraftWindow.LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString());

if (mJournalMode)
{
mCraft.Hide();
mCraftAll.Hide();
}

Interface.InputBlockingElements.Add(mCraftWindow);

Globals.Me.InventoryUpdatedDelegate = () =>
Expand Down Expand Up @@ -290,7 +300,7 @@ private void LoadCraftItems(Guid id)
}
}

mCraftAll.IsHidden = craftableQuantity < 2;
mCraftAll.IsHidden = mJournalMode || craftableQuantity < 2;
if (!mCraftAll.IsHidden)
{
mCraftAll.SetText(Strings.Crafting.craftall.ToString(craftableQuantity));
Expand Down
8 changes: 6 additions & 2 deletions Intersect.Client/Interface/Game/GameInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public partial class GameInterface : MutableInterface

private string mTradingTarget;

private bool mCraftJournal { get; set; }

private TradingWindow? mTradingWindow;

public EntityBox PlayerBox;
Expand Down Expand Up @@ -235,14 +237,16 @@ public BankWindow GetBankWindow()
}

//Crafting
public void NotifyOpenCraftingTable()
public void NotifyOpenCraftingTable(bool journalMode)
{
mShouldOpenCraftingTable = true;
mCraftJournal = journalMode;
}

public void NotifyCloseCraftingTable()
{
mShouldCloseCraftingTable = true;
mCraftJournal = false;
}

public void OpenCraftingTable()
Expand All @@ -252,7 +256,7 @@ public void OpenCraftingTable()
mCraftingWindow.Close();
}

mCraftingWindow = new CraftingWindow(GameCanvas);
mCraftingWindow = new CraftingWindow(GameCanvas, mCraftJournal);
mShouldOpenCraftingTable = false;
Globals.InCraft = true;
}
Expand Down
2 changes: 1 addition & 1 deletion Intersect.Client/Networking/PacketHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1636,7 +1636,7 @@ public void HandlePacket(IPacketSender packetSender, CraftingTablePacket packet)
{
Globals.ActiveCraftingTable = new CraftingTableBase();
Globals.ActiveCraftingTable.Load(packet.TableData);
Interface.Interface.GameUi.NotifyOpenCraftingTable();
Interface.Interface.GameUi.NotifyOpenCraftingTable(packet.JournalMode);
}
else
{
Expand Down
4 changes: 3 additions & 1 deletion Intersect.Editor/Forms/Editors/Events/CommandPrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,9 @@ private static string GetCommandText(OpenShopCommand command, MapInstance map)

private static string GetCommandText(OpenCraftingTableCommand command, MapInstance map)
{
return Strings.EventCommandList.opencrafting.ToString(CraftingTableBase.GetName(command.CraftingTableId));
return command.JournalMode ?
Strings.EventCommandList.OpenCraftingJournal.ToString(CraftingTableBase.GetName(command.CraftingTableId)) :
Strings.EventCommandList.opencrafting.ToString(CraftingTableBase.GetName(command.CraftingTableId));
}

private static string GetCommandText(SetClassCommand command, MapInstance map)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Windows.Forms;

using Intersect.Editor.Localization;
Expand All @@ -24,6 +24,7 @@ public EventCommandOpenCraftingTable(OpenCraftingTableCommand refCommand, FrmEve
cmbTable.Items.Clear();
cmbTable.Items.AddRange(CraftingTableBase.Names);
cmbTable.SelectedIndex = CraftingTableBase.ListIndex(mMyCommand.CraftingTableId);
chkJournalMode.Checked = mMyCommand.JournalMode;
}

private void InitLocalization()
Expand All @@ -32,6 +33,16 @@ private void InitLocalization()
lblTable.Text = Strings.EventOpenCrafting.label;
btnSave.Text = Strings.EventOpenCrafting.okay;
btnCancel.Text = Strings.EventOpenCrafting.cancel;
chkJournalMode.Text = Strings.EventOpenCrafting.JournalMode;

ToolTip toolTip1 = new ToolTip();

toolTip1.AutoPopDelay = 5000;
toolTip1.InitialDelay = 1000;
toolTip1.ReshowDelay = 500;
toolTip1.ShowAlways = true;

toolTip1.SetToolTip(chkJournalMode, Strings.EventOpenCrafting.JournalModeTooltip);
}

private void btnSave_Click(object sender, EventArgs e)
Expand All @@ -41,6 +52,8 @@ private void btnSave_Click(object sender, EventArgs e)
mMyCommand.CraftingTableId = CraftingTableBase.IdFromList(cmbTable.SelectedIndex);
}

mMyCommand.JournalMode = chkJournalMode.Checked;

mEventEditor.FinishCommandEdit();
}

Expand Down
9 changes: 9 additions & 0 deletions Intersect.Editor/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2068,6 +2068,9 @@ public partial struct EventCommandList

public static LocalizedString opencrafting = @"Open Crafting Table [{00}]";

[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public static LocalizedString OpenCraftingJournal = @"Open Crafting Journal [{00}]";

public static LocalizedString openshop = @"Open Shop [{00}]";

public static LocalizedString playanimation = @"Play Animation {00} {01}";
Expand Down Expand Up @@ -3089,6 +3092,12 @@ public partial struct EventOpenCrafting

public static LocalizedString label = @"Table:";

[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public static LocalizedString JournalMode = @"Journal Mode?";

[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public static LocalizedString JournalModeTooltip = @"Opens the crafting window without the option for the player to actually craft.";

public static LocalizedString okay = @"Ok";

public static LocalizedString title = @"Open Crafting";
Expand Down
2 changes: 1 addition & 1 deletion Intersect.Server.Core/Entities/Events/CommandProcessing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ private static void ProcessCommand(
Stack<CommandInstance> callStack
)
{
player.OpenCraftingTable(CraftingTableBase.Get(command.CraftingTableId));
player.OpenCraftingTable(CraftingTableBase.Get(command.CraftingTableId), command.JournalMode);
callStack.Peek().WaitingForResponse = CommandInstance.EventResponse.Crafting;
}

Expand Down
Loading

0 comments on commit 772a90f

Please sign in to comment.