forked from Mirrors/openclonk
interaction menu: allow transfer of items only into IsContainer (#1484)
parent
6bcb6bb53e
commit
c02cce2c0c
|
@ -254,6 +254,9 @@ public func IsWalking(){return GetProcedure() == "WALK";}
|
|||
public func IsSwimming(){return GetProcedure() == "SWIM";}
|
||||
public func IsBridging(){return WildcardMatch(GetAction(), "Bridge*");}
|
||||
|
||||
// Clonks act as containers for the interaction menu as long as they are alive.
|
||||
public func IsContainer() { return GetAlive(); }
|
||||
|
||||
/* Carry items on the clonk */
|
||||
|
||||
local iHandMesh;
|
||||
|
|
|
@ -413,8 +413,8 @@ func OpenMenuForObject(object obj, int slot, bool forced)
|
|||
// Show "put/take all items" buttons if applicable. Also update tooltip.
|
||||
var show_grab_all = current_menus[0] && current_menus[1];
|
||||
show_grab_all = show_grab_all
|
||||
&& (current_menus[0].target->~IsContainer() || current_menus[0].target->~IsClonk())
|
||||
&& (current_menus[1].target->~IsContainer() || current_menus[1].target->~IsClonk());
|
||||
&& (current_menus[0].target->~IsContainer())
|
||||
&& (current_menus[1].target->~IsContainer());
|
||||
if (show_grab_all)
|
||||
{
|
||||
current_center_column_target.Visibility = VIS_Owner;
|
||||
|
@ -499,7 +499,7 @@ public func OnMoveAllToClicked(int menu_id)
|
|||
{
|
||||
if (!current_menus[i] || !current_menus[i].target)
|
||||
return;
|
||||
if (!current_menus[i].target->~IsContainer() && !current_menus[i].target->~IsClonk())
|
||||
if (!current_menus[i].target->~IsContainer())
|
||||
return;
|
||||
}
|
||||
// Take all from the other object and try to put into the target.
|
||||
|
@ -681,7 +681,7 @@ func CreateMainMenu(object obj, int slot)
|
|||
var menus = obj->~GetInteractionMenus(cursor) ?? [];
|
||||
// get all interaction info from the object and put it into a menu
|
||||
// contents first
|
||||
if (obj->~IsContainer() || obj->~IsClonk())
|
||||
if (obj->~IsContainer())
|
||||
{
|
||||
var info =
|
||||
{
|
||||
|
@ -858,6 +858,14 @@ private func OnContentsSelection(symbol, extra_data)
|
|||
var other_target = current_menus[1 - extra_data.slot].target;
|
||||
if (!other_target) return;
|
||||
|
||||
// Allow transfer only into containers.
|
||||
if (!other_target->~IsContainer())
|
||||
{
|
||||
// Todo: other sound for "nope".
|
||||
Sound("LightMetalHit*", nil, 10, GetController(), nil, nil, -50);
|
||||
return;
|
||||
}
|
||||
|
||||
var transfer_only_one = GetPlayerControlState(GetOwner(), CON_ModifierMenu1) == 0; // Transfer ONE object of the stack?
|
||||
var to_transfer = nil;
|
||||
|
||||
|
|
|
@ -34,6 +34,9 @@ public func NoConstructionFlip() { return true; }
|
|||
|
||||
/*-- Interaction --*/
|
||||
|
||||
// The flag can take valuables which are then auto-sold.
|
||||
public func IsContainer() { return true; }
|
||||
|
||||
public func GetInteractionMenus(object clonk)
|
||||
{
|
||||
var menus = _inherited() ?? [];
|
||||
|
|
|
@ -25,8 +25,8 @@ public func Initialize()
|
|||
|
||||
/*-- Interaction --*/
|
||||
|
||||
// Sawmill can't be accessed as a container.
|
||||
public func IsContainer() { return false; }
|
||||
// Sawmill acts as a container to be able to collect wooden objects.
|
||||
public func IsContainer() { return true; }
|
||||
|
||||
// Sawmill can't be interacted with.
|
||||
public func IsInteractable() { return false; }
|
||||
|
|
Loading…
Reference in New Issue