forked from Mirrors/openclonk
production menu: sort items by value; fix minor bug
parent
6466c6d45b
commit
700f332cc0
|
@ -483,9 +483,10 @@ func OnMenuEntrySelected(proplist menu_info, int entry_index, int player)
|
|||
|
||||
var callback_target;
|
||||
if (!(callback_target = info.menu.callback_target)) return;
|
||||
if (!info.menu.callback) return; // The menu can actually decide to handle user interaction itself and not provide a callback.
|
||||
var result = callback_target->Call(info.menu.callback, info.entry.symbol, info.entry.extra_data, cursor);
|
||||
|
||||
// todo: trigger refresh for special value of result
|
||||
// todo: trigger refresh for special value of result?
|
||||
}
|
||||
|
||||
func OnContentsSelection(symbol, extra_data)
|
||||
|
|
|
@ -109,7 +109,7 @@ public func GetProductionMenuEntries()
|
|||
else
|
||||
entry.controls.remove = nil;
|
||||
|
||||
entry.Priority = index;
|
||||
entry.Priority = 1000 * product->GetValue() + index; // Sort by (estimated) value and then by index.
|
||||
entry.Tooltip = product->GetName();
|
||||
entry.image.OnClick = GuiAction_Call(this, "ModifyProduction", {Product = product, Amount = +1});
|
||||
entry.controls.endless.OnClick = GuiAction_Call(this, "ModifyProduction", {Product = product, Infinite = true});
|
||||
|
@ -126,7 +126,7 @@ public func GetInteractionMenus(object clonk)
|
|||
{
|
||||
title = "$Production$",
|
||||
entries_callback = this.GetProductionMenuEntries,
|
||||
callback = "OnProductSelection",
|
||||
callback = nil, // The callback is handled internally. See GetProductionMenuEntries.
|
||||
callback_hover = "OnProductHover",
|
||||
callback_target = this,
|
||||
BackgroundColor = RGB(0, 0, 50),
|
||||
|
@ -174,20 +174,6 @@ private func GetCostString(int amount, bool available)
|
|||
return Format("<c ff0000>%dx</c>", amount);
|
||||
}
|
||||
|
||||
protected func OnProductSelection(id product, int par, bool alt)
|
||||
{
|
||||
if (!product)
|
||||
return;
|
||||
|
||||
var amount = nil;
|
||||
if (!alt)
|
||||
amount = 1;
|
||||
|
||||
AddToQueue(product, amount);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*-- Production properties --*/
|
||||
|
||||
// This function may be overloaded by the actual producer.
|
||||
|
|
Loading…
Reference in New Issue