-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGuiDialogBookkeeper.cs
More file actions
471 lines (404 loc) · 25 KB
/
Copy pathGuiDialogBookkeeper.cs
File metadata and controls
471 lines (404 loc) · 25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
using System;
using System.Collections.Generic;
using System.Linq;
using Vintagestory.API.Client;
using Vintagestory.API.Common;
using Vintagestory.API.Config;
using Vintagestory.API.Datastructures;
using Vintagestory.API.MathTools;
namespace Bookkeeper
{
// --- DATA DEFINITIONS ---
[ProtoBuf.ProtoContract(ImplicitFields = ProtoBuf.ImplicitFields.AllPublic)]
public class PacketBookkeeperRequest { }
[ProtoBuf.ProtoContract(ImplicitFields = ProtoBuf.ImplicitFields.AllPublic)]
public class PacketBookkeeperResponse
{
public List<BookkeeperItemDTO> Items = new List<BookkeeperItemDTO>();
}
[ProtoBuf.ProtoContract(ImplicitFields = ProtoBuf.ImplicitFields.AllPublic)]
public class BookkeeperItemDTO
{
public string Code;
public int Count;
public string Type;
public string VariantType;
public string Variant;
public string Material;
// Full attribute tree of a representative stack, so attribute-driven blocks
// (clutter, bookshelves, etc.) render with the exact appearance they had in storage.
public byte[] AttributesData;
public List<SimplePos> Locations = new List<SimplePos>();
}
[ProtoBuf.ProtoContract(ImplicitFields = ProtoBuf.ImplicitFields.AllPublic)]
public class SimplePos { public int X, Y, Z; }
[Flags]
public enum ItemCategory
{
None = 0,
Food = 1,
Tools = 2,
Fuel = 4,
Wood = 8,
Wearables = 16,
Metals = 32,
Building = 64,
Plants = 128,
Decor = 256,
Powders = 512
}
public class BookkeeperEntry
{
public ItemStack Stack;
public List<BlockPos> Locations;
public ItemCategory Category;
}
public class GuiDialogBookkeeper : GuiDialog
{
public override string ToggleKeyCombinationCode => null;
private BookkeeperModSystem modSystem;
private List<BookkeeperEntry> allEntries = new List<BookkeeperEntry>();
private List<BookkeeperEntry> filteredEntries = new List<BookkeeperEntry>();
private List<BookkeeperEntry> currentVisibleEntries = new List<BookkeeperEntry>();
private InventoryGeneric virtualInventory;
private string currentSearchText = "";
private ItemCategory activeCategories = ItemCategory.None;
private int currentPage = 0;
// LAYOUT: 10 Columns, 9 Rows (90 Items)
private const int COLS = 10;
private int itemsPerPage = 90;
private bool isWaitingForServer = false;
private long openTime = 0;
public GuiDialogBookkeeper(ICoreClientAPI capi, BookkeeperModSystem system) : base(capi)
{
this.modSystem = system;
}
public void UpdateDataFromServer(List<BookkeeperItemDTO> data)
{
allEntries.Clear();
foreach (var dto in data)
{
try
{
AssetLocation code = new AssetLocation(dto.Code);
CollectibleObject collectible = (dto.Type == "Block") ? (CollectibleObject)capi.World.GetBlock(code) : (CollectibleObject)capi.World.GetItem(code);
if (collectible != null)
{
ItemStack stack = new ItemStack(collectible, dto.Count);
// Attribute-variant blocks (decorative chests, clutter, bookshelves) share
// one code and encode their appearance in itemstack attributes. Restore the
// full attribute tree of a representative stack so the correct name, icon,
// and mesh render (a bookshelf's "variant", a chest's "type", etc.).
if (dto.AttributesData != null && dto.AttributesData.Length > 0)
stack.Attributes = TreeAttribute.CreateFromBytes(dto.AttributesData);
else
{
if (!string.IsNullOrEmpty(dto.VariantType)) stack.Attributes.SetString("type", dto.VariantType);
if (!string.IsNullOrEmpty(dto.Material)) stack.Attributes.SetString("material", dto.Material);
}
List<BlockPos> locs = dto.Locations.Select(p => new BlockPos(p.X, p.Y, p.Z)).ToList();
allEntries.Add(new BookkeeperEntry() { Stack = stack, Locations = locs, Category = ClassifyCollectible(collectible) });
}
}
catch { }
}
allEntries.Sort((a, b) => string.Compare(a.Stack.GetName(), b.Stack.GetName(), StringComparison.OrdinalIgnoreCase));
isWaitingForServer = false;
FilterItems(currentSearchText);
if (IsOpened()) ComposeDialog();
}
// Food fallback for meal-only ingredients. These have no direct NutritionProps
// (they only gain nutrition once cooked into a meal, via the "nutritionPropsWhenInMeal"
// attribute), so when that attribute check doesn't catch them they'd vanish from the
// Food tab — e.g. raw soybeans/peanuts ("beans"), raw eggs, dough, butter, raw cassava.
// These are matched as code PREFIXES (e.g. "legume-soybean"), not substrings, so they
// don't catch lookalikes like "seeds-soybean", "butterfly-*" or "leggings".
private static readonly string[] FoodCodeParts =
{
"legume", "egg", "dough", "butter", "rawcassava"
};
// Fuel = what players actually stockpile as fuel. NOT "anything flammable":
// in VS planks/sticks/candles burn at 700° (same as firewood) and ferns/grass
// at 600°, so CombustibleProps/burn-temperature can't separate fuel from kindling.
// lignite/anthracite codes don't contain "coal", so they're listed explicitly.
private static readonly string[] FuelCodeParts = { "firewood", "charcoal", "coke", "coal", "lignite", "anthracite", "peat" };
// Wood-material blocks already cover crafted wood (planks, logs, furniture, axles,
// etc.); these catch the wood *items* that aren't blocks (no BlockMaterial to check).
private static readonly string[] WoodItemCodeParts = { "firewood", "plank", "board", "log", "stick" };
// Weapons / ammunition the Tool enum doesn't cover: arrows & sling bullets (class
// ItemArrow), clubs (no tool), plus likely modded weapons. "bow" is omitted on
// purpose (it collides with "bowl") — bows already classify via Tool != null.
private static readonly string[] WeaponCodeParts =
{
"arrow", "bullets", "club", "spear", "javelin", "sword",
"dagger", "mace", "halberd", "crossbow", "bolt"
};
// Plants: growing/harvestable flora and their propagules. Living plant blocks
// (flowers, grass, ferns, mushrooms, reeds, vines) already match via the Plant/Leaves
// block material; these catch the item forms and saplings, which aren't Plant-material
// blocks. "seeds" covers "seeds-*"; mushroom items also gain the Food flag separately.
private static readonly string[] PlantCodeParts =
{
"seeds", "sapling", "flower", "mushroom", "cutting",
"bamboo", "papyrus", "cattail", "reedmace"
};
// Decor: purely decorative, non-functional pieces — paintings/pictures, tapestries,
// and the decorative "clutter" blocks (which share a code and vary by "type").
private static readonly string[] DecorCodeParts =
{
"painting", "picture", "tapestry", "clutter"
};
// Powders: milled/crushed/pulverized substances (flour, crushed ore, bonemeal-style
// powders). Flour is anchored so it doesn't catch unrelated codes.
private static readonly string[] PowderCodeParts =
{
"powder", "crushed", "pulverized"
};
// Classifies a collectible into one or more categories. Food/Tools/Wearables come
// from real collectible properties; Fuel/Wood have no single defining property, so
// they match against curated code lists (Wood also via the block's Wood material).
private static ItemCategory ClassifyCollectible(CollectibleObject collectible)
{
ItemCategory cat = ItemCategory.None;
if (collectible == null) return cat;
// Food: directly edible (NutritionProps), plus ingredients that only gain
// nutrition once cooked/in a meal (raw eggs, beans, etc. carry
// "nutritionPropsWhenInMeal" instead of a direct NutritionProps).
string path = collectible.Code?.Path ?? "";
if (collectible.NutritionProps != null ||
collectible.Attributes?["nutritionPropsWhenInMeal"].Exists == true) cat |= ItemCategory.Food;
else foreach (var part in FoodCodeParts) if (path == part || path.StartsWith(part + "-")) { cat |= ItemCategory.Food; break; }
// Tools: anything with a tool type (covers bow/spear/sling), plus weapons/ammo
// the Tool enum misses (arrows, bullets, clubs, modded swords...).
if (collectible.Tool != null) cat |= ItemCategory.Tools;
else foreach (var part in WeaponCodeParts) if (path.Contains(part)) { cat |= ItemCategory.Tools; break; }
foreach (var part in FuelCodeParts) if (path.Contains(part)) { cat |= ItemCategory.Fuel; break; }
// Wood: any Wood-material block (raw + crafted: planks, furniture, axles...),
// plus the wood items that aren't blocks.
bool isWoodBlock = collectible is Block block && block.BlockMaterial == EnumBlockMaterial.Wood;
if (isWoodBlock) cat |= ItemCategory.Wood;
else foreach (var part in WoodItemCodeParts) if (path.Contains(part)) { cat |= ItemCategory.Wood; break; }
// Wearables: slot-worn items. Clothing/hats/armor/jewelry carry a "clothescategory"
// attribute; bags/backpacks carry a "backpack" attribute (mounts like boat seats
// and saddles have neither, so they stay out). Plus temporal gears.
if (collectible.Attributes?["clothescategory"].Exists == true) cat |= ItemCategory.Wearables;
if (collectible.Attributes?["backpack"].Exists == true) cat |= ItemCategory.Wearables;
if (path.Contains("gear") && path.Contains("temporal")) cat |= ItemCategory.Wearables;
// Metals & Ore: ingots/nuggets/ore. "ore" is anchored (prefix/material) since the
// bare substring hits forest/core/lore/etc.
bool isOreBlock = collectible is Block oreBlock && oreBlock.BlockMaterial == EnumBlockMaterial.Ore;
if (isOreBlock || path.StartsWith("ore-") || path == "ore" ||
path.StartsWith("nugget") || path.StartsWith("ingot") ||
path.Contains("metalbit") || path.Contains("metalplate") ||
path.Contains("looseore") || path.Contains("crystalizedore"))
cat |= ItemCategory.Metals;
// Building: stone & ceramic blocks (rock, cobble, bricks, tiles, fired clay).
if (collectible is Block buildBlock &&
(buildBlock.BlockMaterial == EnumBlockMaterial.Stone || buildBlock.BlockMaterial == EnumBlockMaterial.Ceramic))
cat |= ItemCategory.Building;
// Plants: living Plant/Leaves blocks, plus seed/sapling/cutting items. Flower pots
// are excluded — they're empty decorative containers ("flowerpot" matches "flower").
bool isPlantBlock = collectible is Block plantBlock &&
(plantBlock.BlockMaterial == EnumBlockMaterial.Plant || plantBlock.BlockMaterial == EnumBlockMaterial.Leaves);
if (isPlantBlock) cat |= ItemCategory.Plants;
else if (!path.Contains("flowerpot"))
foreach (var part in PlantCodeParts) if (path.Contains(part)) { cat |= ItemCategory.Plants; break; }
// Decor: paintings/pictures, tapestries, decorative clutter.
foreach (var part in DecorCodeParts) if (path.Contains(part)) { cat |= ItemCategory.Decor; break; }
// Powders: crushed/pulverized substances, plus flour (anchored).
if (path == "flour" || path.StartsWith("flour-")) cat |= ItemCategory.Powders;
else foreach (var part in PowderCodeParts) if (path.Contains(part)) { cat |= ItemCategory.Powders; break; }
return cat;
}
private void FilterItems(string searchText)
{
currentSearchText = searchText.ToLower();
ApplyFilters();
}
// Search text (substring) AND category selection (OR across active categories).
// No active categories means "All".
private void ApplyFilters()
{
IEnumerable<BookkeeperEntry> query = allEntries;
if (!string.IsNullOrEmpty(currentSearchText))
query = query.Where(e => e.Stack.GetName()?.ToLower().Contains(currentSearchText) == true);
if (activeCategories != ItemCategory.None)
query = query.Where(e => (e.Category & activeCategories) != 0);
filteredEntries = query.ToList();
currentPage = 0;
UpdateView();
}
private void OnCategoryToggle(ItemCategory category, bool on)
{
if (on) activeCategories |= category;
else activeCategories &= ~category;
ApplyFilters();
ComposeDialog();
}
private void UpdateView()
{
int skip = currentPage * itemsPerPage;
currentVisibleEntries = filteredEntries.Skip(skip).Take(itemsPerPage).ToList();
virtualInventory = new InventoryGeneric(Math.Max(1, currentVisibleEntries.Count), "bookkeeper-grid", capi, null);
for (int i = 0; i < currentVisibleEntries.Count; i++)
{
virtualInventory[i].Itemstack = currentVisibleEntries[i].Stack;
}
}
public void ComposeDialog()
{
if (virtualInventory == null) virtualInventory = new InventoryGeneric(1, "bookkeeper-init", capi, null);
double windowWidth = 850;
double gridWidth = 480;
double leftMargin = 170;
double windowHeight = 620;
ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterMiddle);
ElementBounds bgBounds = ElementBounds.Fixed(0, 0, windowWidth, windowHeight);
ElementBounds searchBounds = ElementBounds.Fixed(leftMargin, 45, gridWidth, 30);
// Category filter toggles, stacked vertically in the empty right-hand strip.
const double catBtnW = 130, catBtnH = 30, catBtnGap = 8;
double catColX = leftMargin + gridWidth + 45;
double catColY = 85, catStep = catBtnH + catBtnGap;
// Centered over the button column and vertically aligned with the search bar's middle.
ElementBounds catLabelBounds = ElementBounds.Fixed(catColX, 49, catBtnW, 22);
ElementBounds foodBtnBounds = ElementBounds.Fixed(catColX, catColY + 0 * catStep, catBtnW, catBtnH);
ElementBounds toolsBtnBounds = ElementBounds.Fixed(catColX, catColY + 1 * catStep, catBtnW, catBtnH);
ElementBounds fuelBtnBounds = ElementBounds.Fixed(catColX, catColY + 2 * catStep, catBtnW, catBtnH);
ElementBounds woodBtnBounds = ElementBounds.Fixed(catColX, catColY + 3 * catStep, catBtnW, catBtnH);
ElementBounds wearablesBtnBounds = ElementBounds.Fixed(catColX, catColY + 4 * catStep, catBtnW, catBtnH);
ElementBounds metalsBtnBounds = ElementBounds.Fixed(catColX, catColY + 5 * catStep, catBtnW, catBtnH);
ElementBounds buildingBtnBounds = ElementBounds.Fixed(catColX, catColY + 6 * catStep, catBtnW, catBtnH);
ElementBounds plantsBtnBounds = ElementBounds.Fixed(catColX, catColY + 7 * catStep, catBtnW, catBtnH);
ElementBounds decorBtnBounds = ElementBounds.Fixed(catColX, catColY + 8 * catStep, catBtnW, catBtnH);
ElementBounds powdersBtnBounds = ElementBounds.Fixed(catColX, catColY + 9 * catStep, catBtnW, catBtnH);
// HEIGHT: 435px (fits 9 rows) to clear buttons
ElementBounds gridBounds = ElementBounds.Fixed(leftMargin, 85, gridWidth + 5, 435);
ElementBounds prevButtonBounds = ElementBounds.Fixed(leftMargin, 575, 80, 30);
ElementBounds nextButtonBounds = ElementBounds.Fixed(leftMargin + gridWidth - 80, 575, 80, 30);
ElementBounds statusLabelBounds = ElementBounds.Fixed(windowWidth / 2 - 150, 580, 300, 30);
int totalPages = (int)Math.Ceiling((double)filteredEntries.Count / itemsPerPage);
if (totalPages < 1) totalPages = 1;
string statusText = isWaitingForServer ? "Scanning Storage..." : $"Page {currentPage + 1} / {totalPages} ({filteredEntries.Count} Items)";
var centered = CairoFont.WhiteSmallText().WithOrientation(EnumTextOrientation.Center);
SingleComposer = capi.Gui.CreateCompo("bookkeeperdialog", dialogBounds)
.AddShadedDialogBG(bgBounds)
.AddDialogTitleBar("Bookkeeper's Ledger", OnTitleBarClose)
.AddTextInput(searchBounds, OnSearchChanged, CairoFont.WhiteSmallText(), "searchBar")
.AddStaticText("Categories", centered, catLabelBounds)
.AddToggleButton("Food", CairoFont.WhiteSmallText(), on => OnCategoryToggle(ItemCategory.Food, on), foodBtnBounds, "catFood")
.AddToggleButton("Tools", CairoFont.WhiteSmallText(), on => OnCategoryToggle(ItemCategory.Tools, on), toolsBtnBounds, "catTools")
.AddToggleButton("Fuel", CairoFont.WhiteSmallText(), on => OnCategoryToggle(ItemCategory.Fuel, on), fuelBtnBounds, "catFuel")
.AddToggleButton("Wood", CairoFont.WhiteSmallText(), on => OnCategoryToggle(ItemCategory.Wood, on), woodBtnBounds, "catWood")
.AddToggleButton("Wearables", CairoFont.WhiteSmallText(), on => OnCategoryToggle(ItemCategory.Wearables, on), wearablesBtnBounds, "catWearables")
.AddToggleButton("Ores & Metals", CairoFont.WhiteSmallText(), on => OnCategoryToggle(ItemCategory.Metals, on), metalsBtnBounds, "catMetals")
.AddToggleButton("Building", CairoFont.WhiteSmallText(), on => OnCategoryToggle(ItemCategory.Building, on), buildingBtnBounds, "catBuilding")
.AddToggleButton("Plants", CairoFont.WhiteSmallText(), on => OnCategoryToggle(ItemCategory.Plants, on), plantsBtnBounds, "catPlants")
.AddToggleButton("Decor", CairoFont.WhiteSmallText(), on => OnCategoryToggle(ItemCategory.Decor, on), decorBtnBounds, "catDecor")
.AddToggleButton("Powders", CairoFont.WhiteSmallText(), on => OnCategoryToggle(ItemCategory.Powders, on), powdersBtnBounds, "catPowders")
.AddItemSlotGrid(virtualInventory, OnSlotClick, COLS, gridBounds, "itemgrid")
.AddSmallButton("Prev", OnPrevPage, prevButtonBounds)
.AddSmallButton("Next", OnNextPage, nextButtonBounds)
.AddDynamicText(statusText, CairoFont.WhiteSmallText().WithOrientation(EnumTextOrientation.Center), statusLabelBounds, "statusLabel")
// Compose(false): never auto-focus the first element (the search bar). The
// dialog recomposes on server replies, paging and category toggles, and the
// default would silently hand the search bar focus each time — where it eats
// WASD and hotkeys. Typing flow is kept by OnSearchChanged, which refocuses
// the bar explicitly after its recompose.
.Compose(false);
// Disable the grid's built-in click handling so a held cursor item can never be
// moved or destroyed; all clicks are handled in OnMouseDown (locate only).
var slotGrid = SingleComposer.GetSlotGrid("itemgrid");
if (slotGrid != null) slotGrid.CanClickSlot = (slotId) => false;
if (!string.IsNullOrEmpty(currentSearchText))
SingleComposer.GetTextInput("searchBar").SetValue(currentSearchText);
// Recompose rebuilds the toggles in the off state; restore from the active set.
SingleComposer.GetToggleButton("catFood").SetValue(activeCategories.HasFlag(ItemCategory.Food));
SingleComposer.GetToggleButton("catTools").SetValue(activeCategories.HasFlag(ItemCategory.Tools));
SingleComposer.GetToggleButton("catFuel").SetValue(activeCategories.HasFlag(ItemCategory.Fuel));
SingleComposer.GetToggleButton("catWood").SetValue(activeCategories.HasFlag(ItemCategory.Wood));
SingleComposer.GetToggleButton("catWearables").SetValue(activeCategories.HasFlag(ItemCategory.Wearables));
SingleComposer.GetToggleButton("catMetals").SetValue(activeCategories.HasFlag(ItemCategory.Metals));
SingleComposer.GetToggleButton("catBuilding").SetValue(activeCategories.HasFlag(ItemCategory.Building));
SingleComposer.GetToggleButton("catPlants").SetValue(activeCategories.HasFlag(ItemCategory.Plants));
SingleComposer.GetToggleButton("catDecor").SetValue(activeCategories.HasFlag(ItemCategory.Decor));
SingleComposer.GetToggleButton("catPowders").SetValue(activeCategories.HasFlag(ItemCategory.Powders));
}
private void OnSearchChanged(string text)
{
if (capi.World.ElapsedMilliseconds - openTime < 500 && !string.IsNullOrEmpty(text)) return;
if (text == currentSearchText) return;
FilterItems(text);
ComposeDialog();
SingleComposer.FocusElement(SingleComposer.GetTextInput("searchBar").TabIndex);
}
private bool OnPrevPage()
{
if (currentPage > 0) { currentPage--; UpdateView(); ComposeDialog(); }
return true;
}
private bool OnNextPage()
{
int totalPages = (int)Math.Ceiling((double)filteredEntries.Count / itemsPerPage);
if (currentPage < totalPages - 1) { currentPage++; UpdateView(); ComposeDialog(); }
return true;
}
// Grid click handling is disabled (CanClickSlot=false); this no-op satisfies
// AddItemSlotGrid's signature. All clicks are routed through OnMouseDown.
private void OnSlotClick(object packet) { }
public override void OnMouseDown(MouseEvent args)
{
var grid = SingleComposer?.GetSlotGrid("itemgrid");
if (!args.Handled && grid != null && grid.Bounds.PointInside(args.X, args.Y))
{
// Read-only ledger: never move items. If the player is holding something on
// the cursor, do nothing — and crucially never clear the cursor. (The old
// OnSlotClick wiped whatever was on the cursor, which could destroy a held item.)
var mouse = capi.World.Player.InventoryManager.MouseItemSlot;
if (mouse?.Itemstack != null) { args.Handled = true; return; }
// hoverSlotId only refreshes on mouse-move and resets to -1 on recompose, so
// recompute it from the actual click position before reading it.
grid.OnMouseMove(capi, args);
int slotId = grid.hoverSlotId;
if (slotId >= 0 && slotId < currentVisibleEntries.Count)
{
var entry = currentVisibleEntries[slotId];
if (entry.Locations.Count > 0)
{
modSystem.SetHighlights(entry.Locations, entry.Stack.GetName());
TryClose();
}
else
{
capi.ShowChatMessage("Bookkeeper: no known location for that item.");
}
}
args.Handled = true;
return;
}
base.OnMouseDown(args);
}
private void OnTitleBarClose() => TryClose();
public override void OnGuiOpened()
{
openTime = capi.World.ElapsedMilliseconds;
isWaitingForServer = true;
// Start each session with a fresh, empty search and no category filters.
currentSearchText = "";
activeCategories = ItemCategory.None;
currentPage = 0;
FilterItems("");
if (virtualInventory == null) virtualInventory = new InventoryGeneric(1, "bookkeeper-init", capi, null);
ComposeDialog();
BookkeeperModSystem.clientChannel?.SendPacket(new PacketBookkeeperRequest());
SingleComposer.FocusElement(-1);
}
public bool IsLookingAtStation()
{
var blockSel = capi.World.Player.CurrentBlockSelection;
if (blockSel?.Block == null) return false;
string path = blockSel.Block.Code.Path;
// No foundation requirement — the lectern works anywhere.
return path.Contains("bookkeeperlectern") || path.Contains("manifestboard");
}
}
}