Backback and Hands share one Inventory now
New Inventory Display at the left side Inventory fades out if not locked Inventory fades in if something changes, or mouse hovers there Left/Right Mouse Click on an Inventory-Slot selects it for the corresponding hand Icons to show which Slot is selected by left/right hand Inventory can be reordered via Drag&Drop Dragging an Item from a Slot onto the Landscape drops it Changed Shift+Number to Ctrl+Number for selecting crew Changed Number to Shift+Number for using Action-Bar Changed Number to select inventory-slots nowrope
|
@ -225,9 +225,9 @@ func OnSlotFull(int slot)
|
|||
|
||||
public func DetachObject(object obj)
|
||||
{
|
||||
if(GetItem(0) == obj)
|
||||
if(GetHandItem(0) == obj)
|
||||
DetachHandItem(0);
|
||||
if(GetItem(1) == obj)
|
||||
if(GetHandItem(1) == obj)
|
||||
DetachHandItem(1);
|
||||
}
|
||||
|
||||
|
@ -254,8 +254,8 @@ func UpdateAttach()
|
|||
|
||||
func DoUpdateAttach(bool sec)
|
||||
{
|
||||
var obj = GetItem(sec);
|
||||
var other_obj = GetItem(!sec);
|
||||
var obj = GetHandItem(sec);
|
||||
var other_obj = GetHandItem(!sec);
|
||||
if(!obj) return;
|
||||
var iAttachMode = obj->~GetCarryMode(this);
|
||||
if(iAttachMode == CARRY_None) return;
|
||||
|
@ -369,9 +369,9 @@ func DoUpdateAttach(bool sec)
|
|||
|
||||
public func GetHandMesh(object obj)
|
||||
{
|
||||
if(GetItem(0) == obj)
|
||||
if(GetHandItem(0) == obj)
|
||||
return iHandMesh[0];
|
||||
if(GetItem(1) == obj)
|
||||
if(GetHandItem(1) == obj)
|
||||
return iHandMesh[1];
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,10 @@ local deco;
|
|||
local markers;
|
||||
local backpack;
|
||||
|
||||
// Button that locks/unlocks the inventory
|
||||
local lockbutton;
|
||||
local hoverhelper; // the hover-thingie for showing the inventory. a helper.
|
||||
|
||||
// Tubes.
|
||||
local healthtube;
|
||||
local breathtube;
|
||||
|
@ -67,27 +71,174 @@ protected func Construction()
|
|||
// MakeManaTube();
|
||||
|
||||
// backpack display
|
||||
for(var i=0; i<5; i++)
|
||||
|
||||
MakeBackpack();
|
||||
|
||||
// TODO: cleanup
|
||||
// ring inventory
|
||||
/*
|
||||
for(var i=0; i<BackpackSize(); i++)
|
||||
{
|
||||
var bt = CreateObject(GUI_RingMenu_Icon,0,0,GetOwner());
|
||||
bt->SetPosition(74+Sin((i*72)+36,43),-74-Cos((i*72)+36,43));
|
||||
bt->SetExtraData(i+2);
|
||||
bt->SetSize(48000);
|
||||
var step = 360/BackpackSize();
|
||||
//var r = 43;
|
||||
var r = 52;
|
||||
var bt = CreateObject(GUI_Backpack_Slot_Icon,0,0,GetOwner());
|
||||
//bt->SetPosition(74+Sin((i*72)+36,43),-74-Cos((i*72)+36,43)); // 5 slots
|
||||
bt->SetPosition(74+Sin((i*step),r),-74-Cos((i*step),r));
|
||||
bt->SetSlotId(i);
|
||||
//bt->SetSize(48000);
|
||||
//bt->SetShape(bt->GetDefCoreVal());
|
||||
//bt->SetObject(this->GetItem(2+i),0,2+i,0);
|
||||
bt->SetObjDrawTransform(1,0,0,0,1,0,0);
|
||||
//bt->SetObjDrawTransform(1,0,0,0,1,0,0);
|
||||
backpack[GetLength(backpack)] = bt;
|
||||
CustomMessage(Format("@%d.", i+1), bt, nil, -10, 44);
|
||||
}
|
||||
//AddEffect("UpdateBackpack",this,1,1,nil,nil);
|
||||
|
||||
|
||||
// column inventory
|
||||
for(var i=0; i<BackpackSize(); i++)
|
||||
{
|
||||
var d = 60;
|
||||
var y = -225 - d*BackpackSize();
|
||||
var bt = CreateObject(GUI_Backpack_Slot_Icon,0,0,GetOwner());
|
||||
bt->SetPosition(40, y + d*i);
|
||||
bt->SetSlotId(i);
|
||||
|
||||
CustomMessage(Format("@%d.", i+1), bt, nil, -40, 44);
|
||||
backpack[GetLength(backpack)] = bt;
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
// How many slots the inventory has, for overloading
|
||||
private func BackpackSize() { return 7; }
|
||||
|
||||
private func ScheduleUpdateBackpack()
|
||||
{
|
||||
ScheduleCall(this, "UpdateBackpack", 1, 0);
|
||||
}
|
||||
|
||||
/* Inventory-Bar stuff */
|
||||
private func MakeBackpack()
|
||||
{
|
||||
// distance between slots
|
||||
var d = 55;
|
||||
// upper barrier
|
||||
var y = -225-35 - d*BackpackSize();
|
||||
|
||||
// create background
|
||||
hoverhelper = CreateObject(GUI_Backpack_Background,0,0,GetOwner());
|
||||
hoverhelper->SetHUDController(this);
|
||||
hoverhelper->SetPosition(0,y-10);
|
||||
hoverhelper->SetShape(0,0,40+48/2+5, d*BackpackSize() - 48 - 20);
|
||||
hoverhelper.Visibility = VIS_None;
|
||||
|
||||
// create backpack slots
|
||||
for(var i=0; i<BackpackSize(); i++)
|
||||
{
|
||||
var bt = CreateObject(GUI_Backpack_Slot_Icon,0,0,GetOwner());
|
||||
bt->SetHUDController(this);
|
||||
bt->SetPosition(40, y + d*i);
|
||||
bt->SetSlotId(i);
|
||||
|
||||
CustomMessage(Format("@%d.", i+1), bt, nil, -40, 44);
|
||||
backpack[GetLength(backpack)] = bt;
|
||||
}
|
||||
|
||||
// and the lock-button
|
||||
var bt = CreateObject(GUI_Lock_Button,0,0,GetOwner());
|
||||
bt->SetHUDController(this);
|
||||
bt->SetPosition(60,y-55);
|
||||
|
||||
lockbutton = bt;
|
||||
}
|
||||
|
||||
public func ShowInventory()
|
||||
{
|
||||
var effect;
|
||||
if(effect = GetEffect("InventoryTransition", this))
|
||||
effect.position = 40;
|
||||
else
|
||||
AddEffect("InventoryTransition", this, 150, 1, this, GUI_Controller, 40, backpack[0]);
|
||||
|
||||
hoverhelper.Visibility = VIS_None;
|
||||
|
||||
ClearScheduleCall(this, "HideInventory");
|
||||
}
|
||||
|
||||
public func HideInventory()
|
||||
{
|
||||
// don't hide if the inventory is locked
|
||||
if(lockbutton->IsLocked())
|
||||
return;
|
||||
|
||||
var effect;
|
||||
if(effect = GetEffect("InventoryTransition", this))
|
||||
effect.position = 0;
|
||||
else
|
||||
AddEffect("InventoryTransition", this, 150, 1, this, GUI_Controller, 0, backpack[0]);
|
||||
|
||||
hoverhelper.Visibility = VIS_Owner;
|
||||
}
|
||||
|
||||
public func ScheduleHideInventory()
|
||||
{
|
||||
ScheduleCall(this, "HideInventory", 120);
|
||||
}
|
||||
|
||||
|
||||
private func FxInventoryTransitionStart(object target, proplist effect, int tmp, int pos, object ref)
|
||||
{
|
||||
if(tmp != 0)
|
||||
return;
|
||||
|
||||
// make stuff visible. It wants to be seen transitioning!
|
||||
var bt;
|
||||
for(bt in backpack)
|
||||
bt.Visibility = VIS_Owner;
|
||||
|
||||
effect.position = pos;
|
||||
effect.reference = ref;
|
||||
}
|
||||
|
||||
private func FxInventoryTransitionTimer(object target, proplist effect, int time)
|
||||
{
|
||||
// don't move in the initial frame - used if the moving is aborted by hovering
|
||||
if(time < 1)
|
||||
return;
|
||||
|
||||
var dist = effect.position - effect.reference->GetX();
|
||||
var dir = BoundBy(dist, -2,2);
|
||||
|
||||
// if we haven't reached our destination yet, we move everything
|
||||
if(dir != 0)
|
||||
{
|
||||
var bt;
|
||||
for(bt in backpack)
|
||||
bt->MovePosition(dir, 0);
|
||||
|
||||
bt = lockbutton;
|
||||
bt->MovePosition(dir, 0);
|
||||
}
|
||||
// else the effect is allowed to cease existing
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
private func FxInventoryTransitionStop(object target, proplist effect, int reason, int tmp)
|
||||
{
|
||||
if(tmp != 0)
|
||||
return;
|
||||
|
||||
if(effect.position == 0)
|
||||
{
|
||||
var bt;
|
||||
for(bt in backpack)
|
||||
bt.Visibility = VIS_None;
|
||||
}
|
||||
}
|
||||
|
||||
/*-- Wealth --*/
|
||||
|
||||
protected func OnWealthChanged(int plr)
|
||||
|
@ -204,15 +355,21 @@ func UpdateBackpack()
|
|||
{
|
||||
var c = GetCursor(GetOwner());
|
||||
if(!c) return 1;
|
||||
|
||||
ShowInventory();
|
||||
|
||||
for(var i=0; i<GetLength(backpack); i++)
|
||||
{
|
||||
backpack[i]->SetAmount(0);
|
||||
backpack[i]->SetSymbol(c->GetItem(backpack[i]->GetExtraData()));
|
||||
backpack[i]->SetGraphics(nil,nil,9);
|
||||
backpack[i]->SetGraphics(nil,nil,10);
|
||||
backpack[i]->SetGraphics(nil,nil,11);
|
||||
backpack[i]->SetGraphics(nil,nil,12);
|
||||
backpack[i]->SetSymbol(c->GetItem(backpack[i]->GetSlotId()));
|
||||
backpack[i]->SetUnselected();
|
||||
}
|
||||
|
||||
for(var i=0; i < c->HandObjects(); ++i)
|
||||
backpack[c->GetHandItemPos(i)]->SetSelected(i);
|
||||
|
||||
if(!lockbutton->IsLocked())
|
||||
{
|
||||
ScheduleHideInventory();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -473,13 +630,22 @@ public func OnSelectionChanged(int old, int new)
|
|||
actionbar[new]->UpdateSelectionStatus();
|
||||
}
|
||||
|
||||
// call from HUDAdapter or inventory-buttons
|
||||
public func OnHandSelectionChange(int old, int new, int handslot)
|
||||
{
|
||||
backpack[old]->SetUnselected();
|
||||
backpack[new]->SetSelected(handslot);
|
||||
|
||||
OnSlotObjectChanged(handslot);
|
||||
}
|
||||
|
||||
// call from HUDAdapter (Clonk)
|
||||
public func OnSlotObjectChanged(int slot)
|
||||
{
|
||||
//Log("slot %d changed", slot);
|
||||
var cursor = GetCursor(GetOwner());
|
||||
if(!cursor) return;
|
||||
var obj = cursor->GetItem(slot);
|
||||
var obj = cursor->GetHandItem(slot);
|
||||
actionbar[slot]->SetObject(obj, ACTIONTYPE_INVENTORY, slot);
|
||||
|
||||
// refresh backpack
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
[DefCore]
|
||||
id=GUI_Backpack_Background
|
||||
Version=4,10,0,0
|
||||
Category=C4D_StaticBack | C4D_IgnoreFoW | C4D_Foreground | C4D_Parallax | C4D_MouseSelect
|
||||
Width=2
|
||||
Height=2
|
||||
Offset=-1,-1
|
||||
|
After Width: | Height: | Size: 5.4 KiB |
|
@ -0,0 +1,29 @@
|
|||
/**
|
||||
Backpack_Background
|
||||
The background of the backpack area. Also doubles as hover-area for showing the backpack-slots.
|
||||
|
||||
@author boni
|
||||
*/
|
||||
|
||||
local controller;
|
||||
|
||||
public func SetHUDController(object c) { controller = c; }
|
||||
|
||||
public func Initialize()
|
||||
{
|
||||
// Visibility
|
||||
this.Visibility = VIS_Owner;
|
||||
// Parallaxity
|
||||
this.Parallaxity = [0, 0];
|
||||
|
||||
SetName("");
|
||||
}
|
||||
|
||||
public func OnMouseOver(int plr)
|
||||
{
|
||||
if(!controller || GetOwner() == NO_OWNER)
|
||||
return nil;
|
||||
|
||||
controller->ShowInventory();
|
||||
controller->ScheduleHideInventory();
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
[DefCore]
|
||||
id=GUI_Backpack_Slot_Icon
|
||||
Version=5,2,0,1
|
||||
Category=C4D_StaticBack | C4D_IgnoreFoW | C4D_Foreground | C4D_Parallax | C4D_MouseSelect
|
||||
Width=48
|
||||
Height=48
|
||||
Offset=-24,-24
|
||||
StretchGrowth=1
|
||||
Rotate=1
|
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.4 KiB |
|
@ -0,0 +1,162 @@
|
|||
/*
|
||||
Shows an icon for the ringmenu.
|
||||
Author: Mimmo, Clonkonaut
|
||||
*/
|
||||
|
||||
local selected;
|
||||
local position;
|
||||
local controller;
|
||||
|
||||
public func SetHUDController(object c) { controller = c; }
|
||||
|
||||
protected func Initialize()
|
||||
{
|
||||
// Visibility
|
||||
this.Visibility = VIS_Owner;
|
||||
// Parallaxity
|
||||
this.Parallaxity = [0, 0];
|
||||
// Mouse drag image
|
||||
this.MouseDragImage = nil;
|
||||
this.MouseDrag = MD_DragSource | MD_DropTarget;
|
||||
return;
|
||||
}
|
||||
|
||||
public func SetSlotId(int i) { position = i; }
|
||||
public func GetSlotId() { return position; }
|
||||
|
||||
public func SetSelected(int nr)
|
||||
{
|
||||
if(nr == 0)
|
||||
SetGraphics("LeftHand", GUI_Backpack_Slot_Icon, 4, GFXOV_MODE_Base);
|
||||
if(nr == 1)
|
||||
SetGraphics("RightHand", GUI_Backpack_Slot_Icon, 5, GFXOV_MODE_Base);
|
||||
//SetGraphics(nil, nil, MI_SELECTION_LAYER);
|
||||
//SetClrModulation(HSL(255-nr*86, 200, 150));
|
||||
}
|
||||
|
||||
public func SetUnselected()
|
||||
{
|
||||
SetGraphics(nil,nil,4);
|
||||
SetGraphics(nil,nil,5);
|
||||
}
|
||||
|
||||
|
||||
// SetSymbol from GUI_RingMenu_Icon
|
||||
public func SetSymbol(obj)
|
||||
{
|
||||
this.Visibility = VIS_Owner;
|
||||
|
||||
if(!obj)
|
||||
{
|
||||
SetGraphics(nil, nil, MI_ICON_LAYER);
|
||||
SetName("");
|
||||
this.MouseDragImage = nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetType(obj) == C4V_C4Object)
|
||||
SetGraphics(nil, nil, MI_ICON_LAYER, GFXOV_MODE_ObjectPicture, 0, 0, obj);
|
||||
else
|
||||
SetGraphics(nil,obj,MI_ICON_LAYER,GFXOV_MODE_IngamePicture);
|
||||
|
||||
SetName(obj->GetName());
|
||||
this.MouseDragImage = obj->GetID();
|
||||
}
|
||||
}
|
||||
|
||||
// Warning: Mouse-Drag'n'Drop still is really weird here
|
||||
|
||||
// Called when this object is selected with the left mouse button.
|
||||
public func MouseSelection(int plr)
|
||||
{
|
||||
if(plr != GetOwner())
|
||||
return nil;
|
||||
|
||||
var c = GetCursor(GetOwner());
|
||||
if(!c) return 1;
|
||||
|
||||
// set 1st mouse button to this slot/item
|
||||
var old = c->GetHandItemPos(0);
|
||||
c->SetHandItemPos(0, position);
|
||||
controller->OnHandSelectionChange(old, position, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Called when this object is selected with the right mouse button.
|
||||
public func MouseSelectionAlt(int plr)
|
||||
{
|
||||
if(plr != GetOwner())
|
||||
return nil;
|
||||
|
||||
var c = GetCursor(GetOwner());
|
||||
if(!c) return 1;
|
||||
|
||||
// set 2nd mouse button to this slot/item
|
||||
var old = c->GetHandItemPos(1);
|
||||
c->SetHandItemPos(1, position);
|
||||
controller->OnHandSelectionChange(old, position, 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public func MouseDrag(int plr)
|
||||
{
|
||||
if(plr != GetOwner())
|
||||
return;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public func MouseDrop(int plr, object src)
|
||||
{
|
||||
if(src->GetOwner() != GetOwner())
|
||||
return false;
|
||||
|
||||
if(src->GetID() == this->GetID())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Called after this object has been dragged onto another one.
|
||||
public func MouseDragDone(self, object target)
|
||||
{
|
||||
var c = GetCursor(GetOwner());
|
||||
if(!c) return;
|
||||
|
||||
if(target == nil)
|
||||
{
|
||||
var obj = c->GetItem(position);
|
||||
if(obj != nil)
|
||||
obj->Exit();
|
||||
return;
|
||||
}
|
||||
|
||||
if(target->GetOwner() != GetOwner())
|
||||
return;
|
||||
|
||||
if(target->GetID() == this->GetID())
|
||||
c->Switch2Items(position, target->GetSlotId());
|
||||
}
|
||||
|
||||
// highlight and block hiding
|
||||
public func OnMouseOver(int plr)
|
||||
{
|
||||
if(!controller || GetOwner() == NO_OWNER)
|
||||
return nil;
|
||||
|
||||
SetGraphics("Focussed", GUI_Backpack_Slot_Icon);
|
||||
|
||||
controller->ShowInventory();
|
||||
}
|
||||
|
||||
public func OnMouseOut(int plr)
|
||||
{
|
||||
if(!controller || GetOwner() == NO_OWNER)
|
||||
return nil;
|
||||
|
||||
SetGraphics(nil, nil);
|
||||
|
||||
controller->ScheduleHideInventory();
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
[DefCore]
|
||||
id=GUI_Lock_Button
|
||||
Version=5,2,0,1
|
||||
Category=C4D_StaticBack | C4D_IgnoreFoW | C4D_Foreground | C4D_Parallax | C4D_MouseSelect
|
||||
Width=32
|
||||
Height=32
|
||||
Offset=-16,-16
|
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.0 KiB |
|
@ -0,0 +1,79 @@
|
|||
/**
|
||||
ExpandButton
|
||||
Locks/Unlocks the inventory bar.
|
||||
|
||||
@author boni
|
||||
*/
|
||||
|
||||
local Name = "$Name$";
|
||||
local Description = "$Description$";
|
||||
|
||||
local locked;
|
||||
local controller;
|
||||
|
||||
public func SetHUDController(object c) { controller = c; }
|
||||
public func IsLocked() { return locked; }
|
||||
|
||||
public func Initialize()
|
||||
{
|
||||
// Lock-Buttons need an owner for extradata
|
||||
var owner = GetOwner();
|
||||
if(owner == NO_OWNER)
|
||||
return;
|
||||
|
||||
// Visibility
|
||||
this.Visibility = VIS_Owner;
|
||||
// Parallaxity
|
||||
this.Parallaxity = [0, 0];
|
||||
|
||||
locked = !!GetPlrExtraData(owner, "Inventory_Lock");
|
||||
if(!locked)
|
||||
SetGraphics("Released", GetID());
|
||||
}
|
||||
|
||||
public func MouseSelection(int plr)
|
||||
{
|
||||
// we need a controller to report back to
|
||||
if(!controller)
|
||||
return nil;
|
||||
if(plr != GetOwner())
|
||||
return nil;
|
||||
|
||||
if(locked)
|
||||
Unlock();
|
||||
else
|
||||
Lock();
|
||||
}
|
||||
|
||||
public func Lock()
|
||||
{
|
||||
if(!controller || GetOwner() == NO_OWNER)
|
||||
return nil;
|
||||
|
||||
locked = true;
|
||||
|
||||
// tell controller to do its stuff
|
||||
controller->ShowInventory();
|
||||
|
||||
// update graphics
|
||||
SetGraphics(nil, GetID());
|
||||
|
||||
// and save the result.
|
||||
SetPlrExtraData(GetOwner(), "Inventory_Lock", true);
|
||||
}
|
||||
|
||||
public func Unlock()
|
||||
{
|
||||
if(!controller || GetOwner() == NO_OWNER)
|
||||
return nil;
|
||||
|
||||
locked = false;
|
||||
|
||||
// tell controller to do its stuff
|
||||
controller->ScheduleHideInventory();
|
||||
|
||||
// update graphics
|
||||
SetGraphics("Released", GetID());
|
||||
|
||||
SetPlrExtraData(GetOwner(), "Inventory_Lock", false);
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
Name=LockButton
|
||||
Description=Sperrt/Entsperrt die Inventar-Leiste
|
|
@ -0,0 +1,2 @@
|
|||
Name=LockButton
|
||||
Description=Locks/Unlocks the inventory bar.
|
|
@ -43,6 +43,7 @@ local indexed_inventory;
|
|||
local disableautosort;
|
||||
local force_collection;
|
||||
local inventory;
|
||||
local use_objects;
|
||||
|
||||
/* Item limit */
|
||||
|
||||
|
@ -51,7 +52,6 @@ public func MaxContentsCount() { return 7; }
|
|||
public func NoStackedContentMenu() { return true; }
|
||||
|
||||
/* Get the ith item in the inventory */
|
||||
// the first two are in the hands
|
||||
public func GetItem(int i)
|
||||
{
|
||||
if (i >= GetLength(inventory))
|
||||
|
@ -61,6 +61,53 @@ public func GetItem(int i)
|
|||
return inventory[i];
|
||||
}
|
||||
|
||||
/* Get the ith item in hands.
|
||||
These are the items that will be used with use-commands. (Left mouse click, etc...) */
|
||||
public func GetHandItem(int i)
|
||||
{
|
||||
if (i >= GetLength(use_objects))
|
||||
return nil;
|
||||
if (i < 0) return nil;
|
||||
|
||||
return GetItem(use_objects[i]);
|
||||
}
|
||||
|
||||
/* Set the "hand"th use-item to the "inv"th slot */
|
||||
public func SetHandItemPos(int hand, int inv)
|
||||
{
|
||||
if(hand >= HandObjects() || inv >= MaxContentsCount())
|
||||
return nil;
|
||||
if(hand < 0 || inv < 0) return nil;
|
||||
|
||||
use_objects[hand] = inv;
|
||||
|
||||
// call callbacks
|
||||
if(GetItem(inv))
|
||||
this->~OnSlotFull(hand);
|
||||
else
|
||||
this->~OnSlotEmpty(hand);
|
||||
}
|
||||
|
||||
/* Returns the position in the inventory of the ith use item */
|
||||
public func GetHandItemPos(int i)
|
||||
{
|
||||
if (i >= GetLength(use_objects))
|
||||
return nil;
|
||||
if (i < 0) return nil;
|
||||
|
||||
return use_objects[i];
|
||||
}
|
||||
|
||||
/* Returns in which hand-slot the oth inventory-slot is */
|
||||
private func GetHandPosByItemPos(int o)
|
||||
{
|
||||
for(var i=0; i < GetLength(use_objects); i++)
|
||||
if(use_objects[i] == o)
|
||||
return i;
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
// For the HUD: this object shows its items in the HUD (i.e. has the GetItem function)
|
||||
public func HUDShowItems() { return true; }
|
||||
|
||||
|
@ -98,32 +145,38 @@ public func Switch2Items(int one, int two)
|
|||
if (using == inventory[one] || using == inventory[two])
|
||||
CancelUse();
|
||||
|
||||
var handone, handtwo;
|
||||
handone = GetHandPosByItemPos(one);
|
||||
handtwo = GetHandPosByItemPos(two);
|
||||
|
||||
// callbacks: (de)selection
|
||||
if (one < HandObjects())
|
||||
if (handone != nil)
|
||||
if (inventory[two]) inventory[two]->~Deselection(this,one);
|
||||
if (two < HandObjects())
|
||||
if (handtwo != nil)
|
||||
if (inventory[one]) inventory[one]->~Deselection(this,two);
|
||||
|
||||
if (one < HandObjects())
|
||||
if (handone != nil)
|
||||
if (inventory[one]) inventory[one]->~Selection(this,one);
|
||||
if (two < HandObjects())
|
||||
if (handtwo != nil)
|
||||
if (inventory[two]) inventory[two]->~Selection(this,two);
|
||||
|
||||
// callbacks: to self, for HUD
|
||||
if (one < HandObjects())
|
||||
if (handone != nil)
|
||||
{
|
||||
if (inventory[one])
|
||||
this->~OnSlotFull(one);
|
||||
this->~OnSlotFull(handone);
|
||||
else
|
||||
this->~OnSlotEmpty(one);
|
||||
this->~OnSlotEmpty(handone);
|
||||
}
|
||||
if (two < HandObjects())
|
||||
if (handtwo != nil)
|
||||
{
|
||||
if (inventory[two])
|
||||
this->~OnSlotFull(two);
|
||||
this->~OnSlotFull(handtwo);
|
||||
else
|
||||
this->~OnSlotEmpty(two);
|
||||
this->~OnSlotEmpty(handtwo);
|
||||
}
|
||||
|
||||
this->~OnInventoryChange(one, two);
|
||||
}
|
||||
|
||||
/* Overload of Collect function */
|
||||
|
@ -156,8 +209,12 @@ public func Collect(object item, bool ignoreOCF, int pos, bool force)
|
|||
if (success)
|
||||
{
|
||||
inventory[pos] = item;
|
||||
if (pos < HandObjects())
|
||||
this->~OnSlotFull(pos);
|
||||
var handpos = GetHandPosByItemPos(pos);
|
||||
// if the slot was a selected hand slot -> update it
|
||||
if(handpos != nil)
|
||||
{
|
||||
this->~OnSlotFull(handpos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -185,6 +242,10 @@ protected func Construction()
|
|||
// inventory variables
|
||||
indexed_inventory = 0;
|
||||
inventory = CreateArray();
|
||||
use_objects = CreateArray();
|
||||
|
||||
for(var i=0; i < HandObjects(); i++)
|
||||
use_objects[i] = i;
|
||||
|
||||
force_collection = false;
|
||||
|
||||
|
@ -228,8 +289,12 @@ protected func Collection2(object obj)
|
|||
}
|
||||
// callbacks
|
||||
if (success)
|
||||
if (sel < HandObjects())
|
||||
this->~OnSlotFull(sel);
|
||||
{
|
||||
var handpos = GetHandPosByItemPos(sel);
|
||||
// if the slot was a selected hand slot -> update it
|
||||
if(handpos != nil)
|
||||
this->~OnSlotFull(handpos);
|
||||
}
|
||||
|
||||
if (sel == 0 || sel == 1)
|
||||
obj->~Selection(this,sel == 1);
|
||||
|
@ -259,8 +324,12 @@ protected func Ejection(object obj)
|
|||
|
||||
// callbacks
|
||||
if (success)
|
||||
if (i < HandObjects())
|
||||
this->~OnSlotEmpty(i);
|
||||
{
|
||||
var handpos = GetHandPosByItemPos(i);
|
||||
// if the slot was a selected hand slot -> update it
|
||||
if(handpos != nil)
|
||||
this->~OnSlotEmpty(handpos);
|
||||
}
|
||||
|
||||
if (i == 0 || i == 1)
|
||||
obj->~Deselection(this,i == 1);
|
||||
|
@ -278,8 +347,10 @@ protected func Ejection(object obj)
|
|||
inventory[i] = Contents(c);
|
||||
indexed_inventory++;
|
||||
|
||||
if (i < HandObjects())
|
||||
this->~OnSlotFull(i);
|
||||
var handpos = GetHandPosByItemPos(i);
|
||||
// if the slot was a selected hand slot -> update it
|
||||
if(handpos != nil)
|
||||
this->~OnSlotFull(handpos);
|
||||
|
||||
if (i == 0 || i == 1)
|
||||
Contents(c)->~Selection(this,i == 1);
|
||||
|
@ -521,6 +592,25 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
|
|||
|
||||
// hotkeys (inventory, vehicle and structure control)
|
||||
var hot = 0;
|
||||
if (ctrl == CON_InteractionHotkey0) hot = 10;
|
||||
if (ctrl == CON_InteractionHotkey1) hot = 1;
|
||||
if (ctrl == CON_InteractionHotkey2) hot = 2;
|
||||
if (ctrl == CON_InteractionHotkey3) hot = 3;
|
||||
if (ctrl == CON_InteractionHotkey4) hot = 4;
|
||||
if (ctrl == CON_InteractionHotkey5) hot = 5;
|
||||
if (ctrl == CON_InteractionHotkey6) hot = 6;
|
||||
if (ctrl == CON_InteractionHotkey7) hot = 7;
|
||||
if (ctrl == CON_InteractionHotkey8) hot = 8;
|
||||
if (ctrl == CON_InteractionHotkey9) hot = 9;
|
||||
|
||||
if (hot > 0)
|
||||
{
|
||||
this->~ControlInteractionHotkey(hot-1);
|
||||
return true;
|
||||
}
|
||||
|
||||
// inventory
|
||||
hot = 0;
|
||||
if (ctrl == CON_Hotkey0) hot = 10;
|
||||
if (ctrl == CON_Hotkey1) hot = 1;
|
||||
if (ctrl == CON_Hotkey2) hot = 2;
|
||||
|
@ -532,12 +622,13 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
|
|||
if (ctrl == CON_Hotkey8) hot = 8;
|
||||
if (ctrl == CON_Hotkey9) hot = 9;
|
||||
|
||||
if (hot > 0)
|
||||
if (hot > 0 && hot <= MaxContentsCount())
|
||||
{
|
||||
this->~ControlHotkey(hot-1);
|
||||
SetHandItemPos(0, hot-1);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
var proc = GetProcedure();
|
||||
|
||||
// cancel usage
|
||||
|
@ -574,8 +665,8 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
|
|||
return Control2Menu(ctrl, x,y,strength, repeat, release);
|
||||
}
|
||||
|
||||
var contents = GetItem(0);
|
||||
var contents2 = GetItem(1);
|
||||
var contents = GetHandItem(0);
|
||||
var contents2 = GetHandItem(1);
|
||||
|
||||
// usage
|
||||
var use = (ctrl == CON_Use || ctrl == CON_UseDelayed || ctrl == CON_UseAlt || ctrl == CON_UseAltDelayed);
|
||||
|
|
|
@ -148,6 +148,22 @@ protected func OnSlotEmpty(int slot)
|
|||
return _inherited(slot, ...);
|
||||
}
|
||||
|
||||
|
||||
protected func OnHandSelectionChange(int old, int new, int handslot)
|
||||
{
|
||||
if (HUDcontroller)
|
||||
HUDcontroller->OnHandSelectionChange(old, new, handslot);
|
||||
return _inherited(old, new, handslot, ...);
|
||||
}
|
||||
|
||||
// when two items switch place
|
||||
protected func OnInventoryChange(int old, int new)
|
||||
{
|
||||
if (HUDcontroller)
|
||||
HUDcontroller->ScheduleUpdateBackpack();
|
||||
return _inherited(old, new, ...);
|
||||
}
|
||||
|
||||
func Collection2()
|
||||
{
|
||||
if (HUDcontroller)
|
||||
|
|
|
@ -169,6 +169,48 @@
|
|||
GUIDesc=Drop secondary selected inventory item
|
||||
Hold=1
|
||||
|
||||
# Hotkeys (Inventory)
|
||||
|
||||
[ControlDef]
|
||||
Identifier=Hotkey1
|
||||
SendCursorPos=1
|
||||
|
||||
[ControlDef]
|
||||
Identifier=Hotkey2
|
||||
SendCursorPos=1
|
||||
|
||||
[ControlDef]
|
||||
Identifier=Hotkey3
|
||||
SendCursorPos=1
|
||||
|
||||
[ControlDef]
|
||||
Identifier=Hotkey4
|
||||
SendCursorPos=1
|
||||
|
||||
[ControlDef]
|
||||
Identifier=Hotkey5
|
||||
SendCursorPos=1
|
||||
|
||||
[ControlDef]
|
||||
Identifier=Hotkey6
|
||||
SendCursorPos=1
|
||||
|
||||
[ControlDef]
|
||||
Identifier=Hotkey7
|
||||
SendCursorPos=1
|
||||
|
||||
[ControlDef]
|
||||
Identifier=Hotkey8
|
||||
SendCursorPos=1
|
||||
|
||||
[ControlDef]
|
||||
Identifier=Hotkey9
|
||||
SendCursorPos=1
|
||||
|
||||
[ControlDef]
|
||||
Identifier=Hotkey0
|
||||
SendCursorPos=1
|
||||
|
||||
# Controlling (contents, vehicles, structures)
|
||||
|
||||
[ControlDef]
|
||||
|
@ -266,46 +308,46 @@
|
|||
|
||||
|
||||
|
||||
# Hotkeys (lower bar)
|
||||
# Interaction Hotkeys (lower bar)
|
||||
|
||||
[ControlDef]
|
||||
Identifier=Hotkey1
|
||||
Identifier=InteractionHotkey1
|
||||
SendCursorPos=1
|
||||
|
||||
[ControlDef]
|
||||
Identifier=Hotkey2
|
||||
Identifier=InteractionHotkey2
|
||||
SendCursorPos=1
|
||||
|
||||
[ControlDef]
|
||||
Identifier=Hotkey3
|
||||
Identifier=InteractionHotkey3
|
||||
SendCursorPos=1
|
||||
|
||||
[ControlDef]
|
||||
Identifier=Hotkey4
|
||||
Identifier=InteractionHotkey4
|
||||
SendCursorPos=1
|
||||
|
||||
[ControlDef]
|
||||
Identifier=Hotkey5
|
||||
Identifier=InteractionHotkey5
|
||||
SendCursorPos=1
|
||||
|
||||
[ControlDef]
|
||||
Identifier=Hotkey6
|
||||
Identifier=InteractionHotkey6
|
||||
SendCursorPos=1
|
||||
|
||||
[ControlDef]
|
||||
Identifier=Hotkey7
|
||||
Identifier=InteractionHotkey7
|
||||
SendCursorPos=1
|
||||
|
||||
[ControlDef]
|
||||
Identifier=Hotkey8
|
||||
Identifier=InteractionHotkey8
|
||||
SendCursorPos=1
|
||||
|
||||
[ControlDef]
|
||||
Identifier=Hotkey9
|
||||
Identifier=InteractionHotkey9
|
||||
SendCursorPos=1
|
||||
|
||||
[ControlDef]
|
||||
Identifier=Hotkey0
|
||||
Identifier=InteractionHotkey0
|
||||
SendCursorPos=1
|
||||
|
||||
# Crew
|
||||
|
@ -1159,42 +1201,82 @@
|
|||
|
||||
[Assignment]
|
||||
Key=Shift+Hotkey1
|
||||
Control=PlayerHotkey1
|
||||
Control=InteractionHotkey1
|
||||
|
||||
[Assignment]
|
||||
Key=Shift+Hotkey2
|
||||
Control=PlayerHotkey2
|
||||
Control=InteractionHotkey2
|
||||
|
||||
[Assignment]
|
||||
Key=Shift+Hotkey3
|
||||
Control=PlayerHotkey3
|
||||
Control=InteractionHotkey3
|
||||
|
||||
[Assignment]
|
||||
Key=Shift+Hotkey4
|
||||
Control=PlayerHotkey4
|
||||
Control=InteractionHotkey4
|
||||
|
||||
[Assignment]
|
||||
Key=Shift+Hotkey5
|
||||
Control=PlayerHotkey5
|
||||
Control=InteractionHotkey5
|
||||
|
||||
[Assignment]
|
||||
Key=Shift+Hotkey6
|
||||
Control=PlayerHotkey6
|
||||
Control=InteractionHotkey6
|
||||
|
||||
[Assignment]
|
||||
Key=Shift+Hotkey7
|
||||
Control=PlayerHotkey7
|
||||
Control=InteractionHotkey7
|
||||
|
||||
[Assignment]
|
||||
Key=Shift+Hotkey8
|
||||
Control=PlayerHotkey8
|
||||
Control=InteractionHotkey8
|
||||
|
||||
[Assignment]
|
||||
Key=Shift+Hotkey9
|
||||
Control=PlayerHotkey9
|
||||
Control=InteractionHotkey9
|
||||
|
||||
[Assignment]
|
||||
Key=Shift+Hotkey0
|
||||
Control=InteractionHotkey0
|
||||
|
||||
[Assignment]
|
||||
Key=Ctrl+Hotkey1
|
||||
Control=PlayerHotkey1
|
||||
|
||||
[Assignment]
|
||||
Key=Ctrl+Hotkey2
|
||||
Control=PlayerHotkey2
|
||||
|
||||
[Assignment]
|
||||
Key=Ctrl+Hotkey3
|
||||
Control=PlayerHotkey3
|
||||
|
||||
[Assignment]
|
||||
Key=Ctrl+Hotkey4
|
||||
Control=PlayerHotkey4
|
||||
|
||||
[Assignment]
|
||||
Key=Ctrl+Hotkey5
|
||||
Control=PlayerHotkey5
|
||||
|
||||
[Assignment]
|
||||
Key=Ctrl+Hotkey6
|
||||
Control=PlayerHotkey6
|
||||
|
||||
[Assignment]
|
||||
Key=Ctrl+Hotkey7
|
||||
Control=PlayerHotkey7
|
||||
|
||||
[Assignment]
|
||||
Key=Ctrl+Hotkey8
|
||||
Control=PlayerHotkey8
|
||||
|
||||
[Assignment]
|
||||
Key=Ctrl+Hotkey9
|
||||
Control=PlayerHotkey9
|
||||
|
||||
[Assignment]
|
||||
Key=Ctrl+Hotkey0
|
||||
Control=PlayerHotkey0
|
||||
|
||||
# ======================================================================= #
|
||||
|
|