actionbar completely working, w/ buildings and vehicles too, bugfixes, new icons

Tobias Zwick 2009-12-07 20:11:22 +01:00
parent be53401c54
commit 2397e3009e
8 changed files with 82 additions and 40 deletions

View File

@ -11,7 +11,6 @@
// TODO -
// following callbacks missing:
// OnClonkUnRecruitment - clonk gets de-recruited from a crew
// ...? - entire player is eliminated
local actionbar;
@ -99,8 +98,6 @@ public func OnCrewSelection(object clonk, bool deselect)
// TODO: what if two clonks are selected? Which clonk gets the actionbar?
// fill actionbar
var max = 10;
// inventory
var i;
for(i = 0; i < clonk->MaxContentsCount(); ++i)
@ -110,7 +107,7 @@ public func OnCrewSelection(object clonk, bool deselect)
ClearButtons(i);
// and start effect to monitor vehicles and structures...
AddEffect("IntSearchInteractionObjects",clonk,1,10,this,nil,i,max);
AddEffect("IntSearchInteractionObjects",clonk,1,10,this,nil,i);
}
else
{
@ -121,11 +118,10 @@ public func OnCrewSelection(object clonk, bool deselect)
}
public func FxIntSearchInteractionObjectsStart(object target, int num, int temp, startAt, max)
public func FxIntSearchInteractionObjectsStart(object target, int num, int temp, startAt)
{
if(temp != 0) return;
EffectVar(0,target,num) = startAt;
EffectVar(1,target,num) = max;
EffectCall(target,num,"Timer",target,num,0);
}
@ -135,48 +131,67 @@ public func FxIntSearchInteractionObjectsTimer(object target, int num, int time)
// find vehicles & structures
var startAt = EffectVar(0,target,num);
var i = startAt;
var max = EffectVar(1,target,num);
// target->FindObjects(Find_AtPoint(0,0),Find_OCF(OCF_Grab),Find_NoContainer());
// doesnt work!! -> BUG! (TODO)
var vehicles = CreateArray();
var pushed = nil;
// if contained, don't search for vehicles...
// TODO: change to: list vehicles inside buildings to push out?
var exclusive = false;
// if contained, search for vehicles that are inside the buildings to push out
if((!target->Contained()))
{
// target->FindObjects(Find_AtPoint(0,0),Find_OCF(OCF_Grab),Find_NoContainer());
// doesnt work!! -> BUG! (TODO)
vehicles = FindObjects(Find_AtPoint(target->GetX()-GetX(),target->GetY()-GetY()),Find_OCF(OCF_Grab),Find_NoContainer());
// don't forget the vehicle that the clonk is pushing (might not be found
// by the findobjects because it is not at that point)
if(target->GetProcedure() == "PUSH" && (pushed = target->GetActionTarget()))
{
ActionButton(target,i++,pushed,ACTIONTYPE_VEHICLE);
if(max) if(i >= max) return ClearButtons(i);
// if the pushed vehicle has been found, we can just continue
var inside = false;
for(var vehicle in vehicles)
if(vehicle == pushed)
inside = true;
// otherwise we must add it before the rest
if(!inside)
{
ActionButton(target,i,pushed,ACTIONTYPE_VEHICLE);
if(actionbar[i]->IsSelected()) exclusive = true;
++i;
}
}
}
else
{
vehicles = FindObjects(Find_OCF(OCF_Grab),Find_Container(target->Contained()));
}
for(var vehicle in vehicles)
{
// ...and exclude the pushed one here...
if(vehicle == pushed) continue;
ActionButton(target,i++,vehicle,ACTIONTYPE_VEHICLE);
if(max) if(i >= max) return ClearButtons(i);
ActionButton(target,i,vehicle,ACTIONTYPE_VEHICLE);
if(actionbar[i]->IsSelected()) exclusive = true;
++i;
}
var structures = FindObjects(Find_AtPoint(target->GetX()-GetX(),target->GetY()-GetY()),Find_OCF(OCF_Entrance),Find_NoContainer());
for(var structure in structures)
{
ActionButton(target,i++,structure,ACTIONTYPE_STRUCTURE);
if(max) if(i >= max) return ClearButtons(i);
ActionButton(target,i,structure,ACTIONTYPE_STRUCTURE);
if(actionbar[i]->IsSelected()) exclusive = true;
++i;
}
//Message("found %d vehicles and %d structures",target,GetLength(vehicles),GetLength(structures));
ClearButtons(i);
// if a vehicle or structure is selected, the hands need to be removed
// from the inventory
actionbar[target->GetSelected()]->UpdateHands();
return;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@ -56,10 +56,13 @@ protected func Construction()
public func MouseSelection(int plr)
{
if(!crew) return false;
if(plr != GetOwner()) {
return false;
}
// invisible...
if(this["Visibility"] != VIS_Owner) return false;
// object is in inventory
if(actiontype == ACTIONTYPE_INVENTORY)
{
@ -76,10 +79,21 @@ public func MouseSelection(int plr)
{
var proc = crew->GetProcedure();
// crew is currently pushing my vehicle -> let go
if(proc == "PUSH" && crew->GetActionTarget() == myobject)
// object is inside building -> activate
if(crew->Contained() && myobject->Contained() == crew->Contained())
{
PlayerObjectCommand(plr, false, "Ungrab");
crew->SetCommand("Activate",myobject);
return true;
}
// crew is currently pushing vehicle
else if(proc == "PUSH")
{
// which is mine -> let go
if(crew->GetActionTarget() == myobject)
PlayerObjectCommand(plr, false, "UnGrab");
else
PlayerObjectCommand(plr, false, "Grab", myobject);
return true;
}
// grab
@ -123,10 +137,10 @@ public func SetObject(object obj, int type, int pos)
if(obj == myobject)
if(type == actiontype)
if(pos+1 == hotkey)
return;
return UpdateSelectionStatus();
this["Visibility"] = VIS_Owner;
actiontype = type;
myobject = obj;
hotkey = pos+1;
@ -193,24 +207,31 @@ public func ShowHotkey()
}
}
public func IsSelected()
{
return isSelected;
}
public func UpdateSelectionStatus()
{
// determine...
isSelected = false;
var sel = false;
if(actiontype == ACTIONTYPE_VEHICLE)
if(crew->GetProcedure() == "PUSH" && crew->GetActionTarget() == myobject)
isSelected = true;
sel = true;
if(actiontype == ACTIONTYPE_STRUCTURE)
if(crew->Contained() == myobject)
isSelected = true;
sel = true;
if(actiontype == ACTIONTYPE_INVENTORY)
if(crew->GetSelected() == hotkey-1)
isSelected = true;
sel = true;
isSelected = sel;
// and set the icon...
if(isSelected)
{
@ -236,6 +257,11 @@ public func UpdateSelectionStatus()
}
SetObjDrawTransform(IconSize(),0,-16000,0,IconSize(),20000, 2);
UpdateHands();
}
public func UpdateHands()
{
// the hands...
var hands = isSelected;
// .. are not displayed for inventory if the clonk is inside

View File

@ -52,7 +52,7 @@ public func MaxContentsCount() { return 3; }
public func SelectItem(selection)
{
var item, old;
// selection is given as integer
/*if(GetType(selection) == C4V_Int)
{
@ -264,12 +264,11 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
if (Control2Script(ctrl, x, y, strength, repeat, release, "Contained", house))
return true;
}
else if (vehicle)
else if (vehicle && (proc == "PUSH" || proc == "ATTACH"))
{
// control to grabbed vehicle or riding etc.
if (proc == "PUSH" || proc == "ATTACH")
if (Control2Script(ctrl, x, y, strength, repeat, release, "Control", vehicle))
return true;
if (Control2Script(ctrl, x, y, strength, repeat, release, "Control", vehicle))
return true;
}
else if (contents)
{
@ -356,7 +355,6 @@ private func Control2Script(int ctrl, int x, int y, int strength, bool repeat, b
// for the use command
if (ctrl == CON_Use)
{
var handled = false;
if(!release && !repeat)
@ -413,7 +411,8 @@ public func CanEnter()
{
var proc = GetProcedure();
if (proc != "WALK" && proc != "SWIM" && proc != "SCALE" &&
proc != "HANGLE" && proc != "FLOAT" && proc != "FLIGHT") return false;
proc != "HANGLE" && proc != "FLOAT" && proc != "FLIGHT" &&
proc != "PUSH") return false;
return true;
}
@ -425,6 +424,8 @@ private func ObjectControlEntrance(int plr, int ctrl)
// enter
if (ctrl == CON_Enter)
{
// contained
if(Contained()) return false;
// enter only if... one can
if (!CanEnter()) return false;
@ -485,7 +486,7 @@ private func ObjectControlPush(int plr, int ctrl)
// ungrab only if he pushes
if (proc != "PUSH") return false;
PlayerObjectCommand(plr, false, "Ungrab");
PlayerObjectCommand(plr, false, "UnGrab");
return true;
}

View File

@ -383,7 +383,7 @@ global func PlayerObjectCommand(int plr, bool exclude_cursor, string command, ob
var follow_clonk = GetCursor(plr, i);
if (follow_clonk)
{
this->ObjectCommand(command,target,tx,ty);
follow_clonk->ObjectCommand(command,target,tx,ty);
}
}
return true;