forked from Mirrors/openclonk
Production/ConstructionMenu: Show components when hovering instead of rightclick
parent
d8f852b56a
commit
4cc20755fe
|
@ -38,17 +38,6 @@ public func MouseSelection(int plr)
|
|||
return item_menu->OnItemSelection(this, plr);
|
||||
}
|
||||
|
||||
// Called when this object is selected with the right mouse button.
|
||||
public func MouseSelectionAlt(int plr)
|
||||
{
|
||||
// Check if this belongs to a menu.
|
||||
if (!item_menu)
|
||||
return;
|
||||
|
||||
// Transfer result to menu.
|
||||
return item_menu->OnItemSelectionAlt(this, plr);
|
||||
}
|
||||
|
||||
// Called to determine which object is dragged.
|
||||
public func MouseDrag(int plr)
|
||||
{
|
||||
|
|
|
@ -188,7 +188,7 @@ private func GetItemPosition(int n, int total)
|
|||
}
|
||||
}
|
||||
|
||||
// Packing 19 or less circles.
|
||||
// Packing 37 or less circles.
|
||||
if (total <= 37)
|
||||
{
|
||||
if (n == 1)
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include GUI_Menu
|
||||
|
||||
local constructinfo_shown;
|
||||
|
||||
/** Creates a consruction menu for the calling object. This is supposed to be a crew member,
|
||||
controlled by a player.
|
||||
@param producer the producer for which to create the production menu.
|
||||
|
@ -63,12 +65,21 @@ private func ShowConstructionInfo(object item)
|
|||
while (comp = GetComponent(nil, index++, nil, structure_id))
|
||||
cost_msg = Format("%s %dx {{%i}}", cost_msg, GetComponent(comp, nil, nil, structure_id), comp);
|
||||
CustomMessage(cost_msg, this, GetOwner(), 250, 270, nil, nil, nil, 1);
|
||||
constructinfo_shown = item;
|
||||
return;
|
||||
}
|
||||
|
||||
public func HideConstructionInfo()
|
||||
{
|
||||
CustomMessage("", this, GetOwner());
|
||||
constructinfo_shown = false;
|
||||
}
|
||||
|
||||
/* Menu properties */
|
||||
|
||||
public func IsProductionMenu() { return true; }
|
||||
// UpdateCursor is called
|
||||
public func CursorUpdatesEnabled() { return true; }
|
||||
|
||||
public func Close()
|
||||
{
|
||||
|
@ -84,6 +95,21 @@ public func HasCommander(object producer)
|
|||
return false;
|
||||
}
|
||||
|
||||
// Callback if the mouse is moved
|
||||
public func UpdateCursor(int dx, int dy)
|
||||
{
|
||||
var item = FindObject(Find_AtPoint(dx, dy), Find_ID(GUI_MenuItem));
|
||||
if (!item || item->GetMenu() != this)
|
||||
{
|
||||
if (constructinfo_shown)
|
||||
HideConstructionInfo();
|
||||
return;
|
||||
}
|
||||
if (item == constructinfo_shown)
|
||||
return;
|
||||
ShowConstructionInfo(item);
|
||||
}
|
||||
|
||||
/* Callbacks from the menu items, to be translated into commands for the producer. */
|
||||
|
||||
// Called when an item has been selected (left mouse button).
|
||||
|
@ -98,17 +124,6 @@ public func OnItemSelection(object item)
|
|||
return _inherited(item, ...);
|
||||
}
|
||||
|
||||
// Called when an item has been selected (right mouse button).
|
||||
public func OnItemSelectionAlt(object item)
|
||||
{
|
||||
if (menu_commander)
|
||||
{
|
||||
// Show construction properties of this structure.
|
||||
ShowConstructionInfo(item);
|
||||
}
|
||||
return _inherited(item, ...);
|
||||
}
|
||||
|
||||
// Called when an object is dragged onto the menu
|
||||
public func MouseDrop(int plr, obj)
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include GUI_Menu
|
||||
|
||||
local menu_queue;
|
||||
local productinfo_shown;
|
||||
|
||||
/** Creates a production menu for the calling object. This is supposed to be a crew member,
|
||||
controlled by a player.
|
||||
|
@ -94,12 +95,21 @@ public func ShowProductInfo(object item)
|
|||
cost_msg = Format("%s %dx {{%i}}", cost_msg, comp[1], comp[0]);
|
||||
|
||||
CustomMessage(cost_msg, this, GetOwner(), 250, 270, nil, nil, nil, 1);
|
||||
productinfo_shown = item;
|
||||
return;
|
||||
}
|
||||
|
||||
public func HideProductInfo()
|
||||
{
|
||||
CustomMessage("", this, GetOwner());
|
||||
productinfo_shown = false;
|
||||
}
|
||||
|
||||
/* Menu properties */
|
||||
|
||||
public func IsProductionMenu() { return true; }
|
||||
// UpdateCursor is called
|
||||
public func CursorUpdatesEnabled() { return true; }
|
||||
|
||||
public func AddQueueItem(object item)
|
||||
{
|
||||
|
@ -200,6 +210,21 @@ public func HasCommander(object producer)
|
|||
return false;
|
||||
}
|
||||
|
||||
// Callback if the mouse is moved
|
||||
public func UpdateCursor(int dx, int dy)
|
||||
{
|
||||
var item = FindObject(Find_AtPoint(dx, dy), Find_ID(GUI_MenuItem));
|
||||
if (!item || item->GetMenu() != this)
|
||||
{
|
||||
if (productinfo_shown)
|
||||
HideProductInfo();
|
||||
return;
|
||||
}
|
||||
if (item == productinfo_shown)
|
||||
return;
|
||||
ShowProductInfo(item);
|
||||
}
|
||||
|
||||
/* Callbacks from the menu items, to be translated into commands for the producer. */
|
||||
|
||||
// Called when an item has been selected (left mouse button).
|
||||
|
@ -224,7 +249,7 @@ public func OnItemSelectionAlt(object item)
|
|||
// Show the production cost of the selected production item.
|
||||
if (IsProductItem(item))
|
||||
{
|
||||
ShowProductInfo(item);
|
||||
// Nothing to do here?
|
||||
}
|
||||
// Show production status of the selected queue item.
|
||||
if (IsQueueItem(item))
|
||||
|
|
Loading…
Reference in New Issue