tooltips for the HUD, grab-fix

Tobias Zwick 2009-12-28 14:12:24 +01:00
parent 72fbce7bad
commit 5b4278979b
10 changed files with 80 additions and 31 deletions

View File

@ -137,7 +137,7 @@ public func UpdateController()
// visibility
SetOwner(crew->GetController());
// name
SetName(crew->GetName());
SetName(Format("$TxtSelect$",crew->GetName()));
}
public func UpdateSelectionStatus()

View File

@ -0,0 +1 @@
TxtSelect=%s auswählen

View File

@ -0,0 +1 @@
TxtSelect=Select %s

View File

@ -148,7 +148,7 @@ public func SetObject(object obj, int type, int pos)
if(!myobject)
{
SetGraphics(nil,nil,1);
SetName(Format("$LabelSlot$ %d",hotkey-1));
SetName(Format("$TxtLabel$",hotkey-1));
}
else
{
@ -160,7 +160,7 @@ public func SetObject(object obj, int type, int pos)
else if(myobject->GetDefCoreVal("Entrance","DefCore",2) != nil) actiontype = ACTIONTYPE_STRUCTURE;
}
SetName(myobject->GetName());
SetName(Format("$TxtSelect$",myobject->GetName()));
// create an effect which monitors whether the object is removed
if(actiontype == ACTIONTYPE_INVENTORY)
@ -241,10 +241,16 @@ public func UpdateSelectionStatus()
SetObjDrawTransform(500,0,16000,0,500,-34000, 12);
if(actiontype == ACTIONTYPE_VEHICLE)
{
SetGraphics("LetGo",GetID(),2,GFXOV_MODE_Base);
SetName(Format("$TxtUnGrab$",myobject->GetName()));
}
if(actiontype == ACTIONTYPE_STRUCTURE)
{
SetGraphics("Exit",GetID(),2,GFXOV_MODE_Base);
SetName(Format("$TxtExit$",myobject->GetName()));
}
}
else
{
@ -252,10 +258,23 @@ public func UpdateSelectionStatus()
SetObjDrawTransform(300,0,16000,0,300,-34000, 12);
if(actiontype == ACTIONTYPE_VEHICLE)
SetGraphics("Grab",GetID(),2,GFXOV_MODE_Base);
{
if(!(myobject->Contained()))
{
SetGraphics("Grab",GetID(),2,GFXOV_MODE_Base);
SetName(Format("$TxtGrab$",myobject->GetName()));
}
else
{
SetGraphics("Exit",GetID(),2,GFXOV_MODE_Base);
SetName(Format("$TxtPushOut$",myobject->GetName()));
}
}
if(actiontype == ACTIONTYPE_STRUCTURE)
{
SetGraphics("Enter",GetID(),2,GFXOV_MODE_Base);
SetName(Format("$TxtEnter$",myobject->GetName()));
}
}
SetObjDrawTransform(IconSize(),0,-16000,0,IconSize(),20000, 2);

View File

@ -1 +1,7 @@
LabelSlot=Slot
TxtSlot=Slot %d auswählen
TxtSelect=%s auswählen
TxtGrab=%s anfassen
TxtUnGrab=%s loslassen
TxtEnter=%s betreten
TxtExit=%s verlassen
TxtPushOut=%s hinausschieben

View File

@ -1 +1,7 @@
LabelSlot=Slot
TxtSlot=Select slot %d
TxtSelect=Select %s
TxtGrab=Grab %s
TxtUnGrab=Let go %s
TxtEnter=Enter %s
TxtExit=Exit %s
TxtPushOut=Push %s out

View File

@ -20,6 +20,8 @@ public func ControlUse(object clonk, int x, int y)
return true;
}
public func HoldingEnabled() { return true; }
public func ControlUseHolding(object clonk, int x, int y)
{

View File

@ -239,8 +239,20 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
//Log(Format("%d, %d, %d, %v, %v", x,y,ctrl, repeat, release));
// aiming
if (ctrl == CON_Aim)
{
if (using)
{
if (alt) ctrl = CON_UseAlt;
else ctrl = CON_Use;
repeat = true;
release = false;
}
}
// Any control resets a previously given command
SetCommand("None");
else SetCommand("None");
// hotkeys (inventory, vehicle and structure control)
var hot = 0;
@ -279,12 +291,12 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
// out of convencience we call Control2Script, even though it handles
// left, right, up and down, too. We don't want that, so this is why we
// check that ctrl is Use.
else if (contents && (ctrl == CON_Use || ( ctrl == CON_Aim && !alt )))
else if (contents && ctrl == CON_Use)
{
if (Control2Script(ctrl, x, y, strength, repeat, release, "Control", contents))
return true;
}
else if (contents2 && (ctrl == CON_UseAlt || ( ctrl == CON_Aim && alt )))
else if (contents2 && ctrl == CON_UseAlt)
{
if (Control2Script(ctrl, x, y, strength, repeat, release, "Control", contents2))
return true;
@ -337,6 +349,7 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
if (ctrl == CON_Drop)
{
return PlayerObjectCommand(plr, false, "Drop", contents);
}
}
// same for contents2 (copypasta)
@ -400,7 +413,7 @@ private func StartUseControl(int ctrl, control, int x, int y, object obj)
return handled;
}
private func StopUseControl(int control, int x, int y, object obj)
private func StopUseControl(control, int x, int y, object obj)
{
var estr = "";
if (alt && !(obj->Contained())) estr = "Alt";
@ -422,8 +435,8 @@ private func Control2Script(int ctrl, int x, int y, int strength, bool repeat, b
// do not use secondary when using primary and the other way round
if (using)
{
if (ctrl == CON_Use && alt) return true;
if (ctrl == CON_UseAlt && !alt) return true;
if (ctrl == CON_Use && alt) return false;
if (ctrl == CON_UseAlt && !alt) return false;
}
// for the use command
@ -437,24 +450,22 @@ private func Control2Script(int ctrl, int x, int y, int strength, bool repeat, b
{
return StopUseControl(control, x, y, obj);
}
}
// for repeated key presses, the x and y are not updated.
// we get our x and y from the MouseMove event.
else if(ctrl == CON_Aim && using == obj)
{
var estr = "";
if (alt && !(obj->Contained())) estr = "Alt";
var handled = obj->Call(Format("~%sUse%sHolding",control,estr),this,x,y);
// if that function returns -1, the control is stopped (*UseStop)
// and no more *UseHolding-calls are made.
if (handled == -1)
else if (repeat && using == obj)
{
handled = StopUseControl(control, x, y, obj);
var estr = "";
if (alt && !(obj->Contained())) estr = "Alt";
var handled = obj->Call(Format("~%sUse%sHolding",control,estr),this,x,y);
// if that function returns -1, the control is stopped (*UseStop)
// and no more *UseHolding-calls are made.
if (handled == -1)
{
handled = StopUseControl(control, x, y, obj);
}
return handled;
}
return handled;
}
// overloads of movement commandos
else if (ctrl == CON_Left || ctrl == CON_Right || ctrl == CON_Down || ctrl == CON_Up)
{
@ -534,11 +545,11 @@ private func ObjectControlPush(int plr, int ctrl)
// disallow if the clonk is still using something
if (using) return false;
// only if there is someting to grab
var obj = FindObject(Find_OCF(OCF_Grab), Find_AtPoint(0,0), Find_Exclude(this));
if (!obj) return false;
// grab
PlayerObjectCommand(plr, false, "Grab", obj);
return true;

View File

@ -300,6 +300,7 @@ global func ShiftCursor(int plr, bool back)
// Helper function to turn CON_*-constants into strings
global func GetPlayerControlName(int ctrl)
{
if (ctrl == CON_Aim) return "Aim";
if (ctrl == CON_Left) return "Left";
if (ctrl == CON_Right) return "Right";
if (ctrl == CON_Up) return "Up";

View File

@ -506,7 +506,7 @@
Control=Hotkey9
[Assignment]
Key=X,0
Key=0
Control=Hotkey0
[Assignment]
@ -577,6 +577,7 @@
[Assignment]
Key=S,GameMouse1ButtonLeft
Priority=150
Control=Drop
[Assignment]
@ -595,6 +596,7 @@
[Assignment]
Key=S,GameMouse1ButtonRight
Priority=150
Control=DropAlt
[ControlSet]