Skip to content

Commit 0886191

Browse files
authored
2172: Add support for a crafting journal (#2173)
* feat: (Day) Add a journal-mode for crafting. Needs winforms update * feat: (Day) Winforms work for crafting journal * remove .resx
1 parent 116dd44 commit 0886191

File tree

14 files changed

+161
-85
lines changed

14 files changed

+161
-85
lines changed

Intersect (Core)/GameObjects/Events/Commands/EventCommands.cs

+5
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,11 @@ public partial class OpenCraftingTableCommand : EventCommand
726726
public override EventCommandType Type { get; } = EventCommandType.OpenCraftingTable;
727727

728728
public Guid CraftingTableId { get; set; }
729+
730+
/// <summary>
731+
/// Does not allow crafting, but displays crafts and their requirements.
732+
/// </summary>
733+
public bool JournalMode { get; set; }
729734
}
730735

731736
public partial class SetClassCommand : EventCommand

Intersect (Core)/Network/Packets/Server/CraftingTablePacket.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ public CraftingTablePacket()
1010
{
1111
}
1212

13-
public CraftingTablePacket(string tableData, bool close)
13+
public CraftingTablePacket(string tableData, bool close, bool journalMode)
1414
{
1515
TableData = tableData;
1616
Close = close;
17+
JournalMode = journalMode;
1718
}
1819

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

26+
[Key(2)]
27+
public bool JournalMode { get; set; }
2528
}
2629

2730
}

Intersect.Client/Interface/Game/Crafting/CraftingWindow.cs

+12-2
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,17 @@ public partial class CraftingWindow
7171

7272
public bool IsCrafting => mRemainingCrafts > 0;
7373

74-
public CraftingWindow(Canvas gameCanvas)
74+
private bool mJournalMode { get; set; }
75+
76+
public CraftingWindow(Canvas gameCanvas, bool journalMode)
7577
{
7678
mCraftWindow = new WindowControl(gameCanvas, Globals.ActiveCraftingTable.Name, false, "CraftingWindow");
7779
mCraftWindow.DisableResizing();
7880

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

83+
mJournalMode = journalMode;
84+
8185
//Labels
8286
mLblRecipes = new Label(mCraftWindow, "RecipesTitle");
8387
mLblRecipes.Text = Strings.Crafting.recipes;
@@ -116,6 +120,12 @@ public CraftingWindow(Canvas gameCanvas)
116120

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

123+
if (mJournalMode)
124+
{
125+
mCraft.Hide();
126+
mCraftAll.Hide();
127+
}
128+
119129
Interface.InputBlockingElements.Add(mCraftWindow);
120130

121131
Globals.Me.InventoryUpdatedDelegate = () =>
@@ -290,7 +300,7 @@ private void LoadCraftItems(Guid id)
290300
}
291301
}
292302

293-
mCraftAll.IsHidden = craftableQuantity < 2;
303+
mCraftAll.IsHidden = mJournalMode || craftableQuantity < 2;
294304
if (!mCraftAll.IsHidden)
295305
{
296306
mCraftAll.SetText(Strings.Crafting.craftall.ToString(craftableQuantity));

Intersect.Client/Interface/Game/GameInterface.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ public partial class GameInterface : MutableInterface
8383

8484
private string mTradingTarget;
8585

86+
private bool mCraftJournal { get; set; }
87+
8688
private TradingWindow? mTradingWindow;
8789

8890
public EntityBox PlayerBox;
@@ -235,14 +237,16 @@ public BankWindow GetBankWindow()
235237
}
236238

237239
//Crafting
238-
public void NotifyOpenCraftingTable()
240+
public void NotifyOpenCraftingTable(bool journalMode)
239241
{
240242
mShouldOpenCraftingTable = true;
243+
mCraftJournal = journalMode;
241244
}
242245

243246
public void NotifyCloseCraftingTable()
244247
{
245248
mShouldCloseCraftingTable = true;
249+
mCraftJournal = false;
246250
}
247251

248252
public void OpenCraftingTable()
@@ -252,7 +256,7 @@ public void OpenCraftingTable()
252256
mCraftingWindow.Close();
253257
}
254258

255-
mCraftingWindow = new CraftingWindow(GameCanvas);
259+
mCraftingWindow = new CraftingWindow(GameCanvas, mCraftJournal);
256260
mShouldOpenCraftingTable = false;
257261
Globals.InCraft = true;
258262
}

Intersect.Client/Networking/PacketHandler.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1636,7 +1636,7 @@ public void HandlePacket(IPacketSender packetSender, CraftingTablePacket packet)
16361636
{
16371637
Globals.ActiveCraftingTable = new CraftingTableBase();
16381638
Globals.ActiveCraftingTable.Load(packet.TableData);
1639-
Interface.Interface.GameUi.NotifyOpenCraftingTable();
1639+
Interface.Interface.GameUi.NotifyOpenCraftingTable(packet.JournalMode);
16401640
}
16411641
else
16421642
{

Intersect.Editor/Forms/Editors/Events/CommandPrinter.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,9 @@ private static string GetCommandText(OpenShopCommand command, MapInstance map)
12031203

12041204
private static string GetCommandText(OpenCraftingTableCommand command, MapInstance map)
12051205
{
1206-
return Strings.EventCommandList.opencrafting.ToString(CraftingTableBase.GetName(command.CraftingTableId));
1206+
return command.JournalMode ?
1207+
Strings.EventCommandList.OpenCraftingJournal.ToString(CraftingTableBase.GetName(command.CraftingTableId)) :
1208+
Strings.EventCommandList.opencrafting.ToString(CraftingTableBase.GetName(command.CraftingTableId));
12071209
}
12081210

12091211
private static string GetCommandText(SetClassCommand command, MapInstance map)

Intersect.Editor/Forms/Editors/Events/Event Commands/EventCommand_OpenCrafting.Designer.cs

+89-70
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Intersect.Editor/Forms/Editors/Events/Event Commands/EventCommand_OpenCrafting.cs

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Windows.Forms;
33

44
using Intersect.Editor.Localization;
@@ -24,6 +24,7 @@ public EventCommandOpenCraftingTable(OpenCraftingTableCommand refCommand, FrmEve
2424
cmbTable.Items.Clear();
2525
cmbTable.Items.AddRange(CraftingTableBase.Names);
2626
cmbTable.SelectedIndex = CraftingTableBase.ListIndex(mMyCommand.CraftingTableId);
27+
chkJournalMode.Checked = mMyCommand.JournalMode;
2728
}
2829

2930
private void InitLocalization()
@@ -32,6 +33,16 @@ private void InitLocalization()
3233
lblTable.Text = Strings.EventOpenCrafting.label;
3334
btnSave.Text = Strings.EventOpenCrafting.okay;
3435
btnCancel.Text = Strings.EventOpenCrafting.cancel;
36+
chkJournalMode.Text = Strings.EventOpenCrafting.JournalMode;
37+
38+
ToolTip toolTip1 = new ToolTip();
39+
40+
toolTip1.AutoPopDelay = 5000;
41+
toolTip1.InitialDelay = 1000;
42+
toolTip1.ReshowDelay = 500;
43+
toolTip1.ShowAlways = true;
44+
45+
toolTip1.SetToolTip(chkJournalMode, Strings.EventOpenCrafting.JournalModeTooltip);
3546
}
3647

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

55+
mMyCommand.JournalMode = chkJournalMode.Checked;
56+
4457
mEventEditor.FinishCommandEdit();
4558
}
4659

Intersect.Editor/Localization/Strings.cs

+9
Original file line numberDiff line numberDiff line change
@@ -2068,6 +2068,9 @@ public partial struct EventCommandList
20682068

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

2071+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
2072+
public static LocalizedString OpenCraftingJournal = @"Open Crafting Journal [{00}]";
2073+
20712074
public static LocalizedString openshop = @"Open Shop [{00}]";
20722075

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

30903093
public static LocalizedString label = @"Table:";
30913094

3095+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
3096+
public static LocalizedString JournalMode = @"Journal Mode?";
3097+
3098+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
3099+
public static LocalizedString JournalModeTooltip = @"Opens the crafting window without the option for the player to actually craft.";
3100+
30923101
public static LocalizedString okay = @"Ok";
30933102

30943103
public static LocalizedString title = @"Open Crafting";

Intersect.Server.Core/Entities/Events/CommandProcessing.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,7 @@ private static void ProcessCommand(
12381238
Stack<CommandInstance> callStack
12391239
)
12401240
{
1241-
player.OpenCraftingTable(CraftingTableBase.Get(command.CraftingTableId));
1241+
player.OpenCraftingTable(CraftingTableBase.Get(command.CraftingTableId), command.JournalMode);
12421242
callStack.Peek().WaitingForResponse = CommandInstance.EventResponse.Crafting;
12431243
}
12441244

0 commit comments

Comments
 (0)