Replace all usage of "bool released" with "int status"

qteditor^2
Lukas Werling 2016-02-23 22:19:39 +01:00
parent 19caa65b7b
commit 0afa589286
11 changed files with 83 additions and 81 deletions

View File

@ -21,9 +21,9 @@ public func FixTo(object station)
SetCursor(GetOwner(), this, true); SetCursor(GetOwner(), this, true);
} }
public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool repeat, bool release) public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool repeat, int status)
{ {
if (release) return false; if (status != CONS_Down) return false;
if (ctrl == CON_Left) if (ctrl == CON_Left)
return cable_car->ShiftSelection(-1, this); return cable_car->ShiftSelection(-1, this);
@ -40,4 +40,4 @@ protected func FxParticlesTimer(object target, effect, int time)
{ {
var angle = time*10 % 360; var angle = time*10 % 360;
CreateParticle("SphereSpark", Sin(angle, 13), -Cos(angle, 13), 0, 0, PV_Random(20, 30), Particles_Spark()); CreateParticle("SphereSpark", Sin(angle, 13), -Cos(angle, 13), 0, 0, PV_Random(20, 30), Particles_Spark());
} }

View File

@ -167,8 +167,10 @@ public func OnRopeBreak()
/*-- Grapple rope controls --*/ /*-- Grapple rope controls --*/
public func FxIntGrappleControlControl(object target, proplist effect, int ctrl, int x, int y, int strength, repeat, release) public func FxIntGrappleControlControl(object target, proplist effect, int ctrl, int x, int y, int strength, bool repeat, int status)
{ {
if (status == CONS_Moved) return false;
var release = status == CONS_Up;
// Cancel this effect if clonk is now attached to something. // Cancel this effect if clonk is now attached to something.
if (target->GetProcedure() == "ATTACH") if (target->GetProcedure() == "ATTACH")
{ {

View File

@ -178,13 +178,13 @@ public func GetExtraInteractions()
/* +++++++++++++++++++++++++++ Clonk Control +++++++++++++++++++++++++++ */ /* +++++++++++++++++++++++++++ Clonk Control +++++++++++++++++++++++++++ */
/* Main control function */ /* Main control function */
public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool repeat, bool release) public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool repeat, int status)
{ {
if (!this) if (!this)
return false; return false;
// Contents menu // Contents menu
if (ctrl == CON_Contents && !release) if (ctrl == CON_Contents && status == CONS_Down)
{ {
// Close any menu if open. // Close any menu if open.
if (GetMenu()) if (GetMenu())
@ -221,10 +221,11 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
else ctrl = CON_Use; else ctrl = CON_Use;
repeat = true; repeat = true;
release = false; status = CONS_Down;
} }
// controls except a few reset a previously given command // controls except a few reset a previously given command
else SetCommand("None"); else if (status != CONS_Moved)
SetCommand("None");
/* aiming with analog pad or keys: /* aiming with analog pad or keys:
This works completely different. There are CON_AimAxis* and CON_Aim*, This works completely different. There are CON_AimAxis* and CON_Aim*,
@ -241,7 +242,7 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
if (ctrl == CON_AimAxisUp || ctrl == CON_AimAxisDown || ctrl == CON_AimAxisLeft || ctrl == CON_AimAxisRight if (ctrl == CON_AimAxisUp || ctrl == CON_AimAxisDown || ctrl == CON_AimAxisLeft || ctrl == CON_AimAxisRight
|| ctrl == CON_AimUp || ctrl == CON_AimDown || ctrl == CON_AimLeft || ctrl == CON_AimRight) || ctrl == CON_AimUp || ctrl == CON_AimDown || ctrl == CON_AimLeft || ctrl == CON_AimRight)
{ {
var success = VirtualCursor()->Aim(ctrl,this,strength,repeat,release); var success = VirtualCursor()->Aim(ctrl,this,strength,repeat,status);
// in any case, CON_Aim* is called but it is only successful if the virtual cursor is aiming // in any case, CON_Aim* is called but it is only successful if the virtual cursor is aiming
return success && VirtualCursor()->IsAiming(); return success && VirtualCursor()->IsAiming();
} }
@ -269,7 +270,7 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
// menu // menu
if (this.control.menu) if (this.control.menu)
{ {
return Control2Menu(ctrl, x,y,strength, repeat, release); return Control2Menu(ctrl, x,y,strength, repeat, status);
} }
var contents = this->GetHandItem(0); var contents = this->GetHandItem(0);
@ -280,12 +281,12 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
{ {
if (house) if (house)
{ {
return ControlUse2Script(ctrl, x, y, strength, repeat, release, house); return ControlUse2Script(ctrl, x, y, strength, repeat, status, house);
} }
// control to grabbed vehicle // control to grabbed vehicle
else if (vehicle && proc == "PUSH") else if (vehicle && proc == "PUSH")
{ {
return ControlUse2Script(ctrl, x, y, strength, repeat, release, vehicle); return ControlUse2Script(ctrl, x, y, strength, repeat, status, vehicle);
} }
else if (vehicle && proc == "ATTACH") else if (vehicle && proc == "ATTACH")
{ {
@ -301,7 +302,7 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
usage via CancelUse(). usage via CancelUse().
*/ */
if (ControlUse2Script(ctrl, x, y, strength, repeat, release, vehicle)) if (ControlUse2Script(ctrl, x, y, strength, repeat, status, vehicle))
return true; return true;
else else
{ {
@ -310,16 +311,16 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
// object returns true on that callback. Exactly what we want) // object returns true on that callback. Exactly what we want)
if (this.control.current_object == vehicle) return true; if (this.control.current_object == vehicle) return true;
// has been cancelled (it is not the start of the usage but no object is used) // has been cancelled (it is not the start of the usage but no object is used)
if (!this.control.current_object && (repeat || release)) return true; if (!this.control.current_object && (repeat || status == CONS_Up)) return true;
} }
} }
// releasing the use-key always cancels shelved commands (in that case no this.control.current_object exists) // releasing the use-key always cancels shelved commands (in that case no this.control.current_object exists)
if(release) StopShelvedCommand(); if(status == CONS_Up) StopShelvedCommand();
// Release commands are always forwarded even if contents is 0, in case we // Release commands are always forwarded even if contents is 0, in case we
// need to cancel use of an object that left inventory // need to cancel use of an object that left inventory
if (contents || (release && this.control.current_object)) if (contents || (status == CONS_Up && this.control.current_object))
{ {
if (ControlUse2Script(ctrl, x, y, strength, repeat, release, contents)) if (ControlUse2Script(ctrl, x, y, strength, repeat, status, contents))
return true; return true;
} }
} }
@ -327,7 +328,7 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
// A click on throw can also just abort usage without having any other effects. // A click on throw can also just abort usage without having any other effects.
// todo: figure out if wise. // todo: figure out if wise.
var currently_in_use = this.control.current_object != nil; var currently_in_use = this.control.current_object != nil;
if ((ctrl == CON_Throw || ctrl == CON_ThrowDelayed) && currently_in_use && !release) if ((ctrl == CON_Throw || ctrl == CON_ThrowDelayed) && currently_in_use && status == CONS_Down)
{ {
CancelUse(); CancelUse();
return true; return true;
@ -336,7 +337,7 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
// Throwing and dropping // Throwing and dropping
// only if not in house, not grabbing a vehicle and an item selected // only if not in house, not grabbing a vehicle and an item selected
// only act on press, not release // only act on press, not release
if ((ctrl == CON_Throw || ctrl == CON_ThrowDelayed) && !house && (!vehicle || proc == "ATTACH") && !release) if ((ctrl == CON_Throw || ctrl == CON_ThrowDelayed) && !house && (!vehicle || proc == "ATTACH") && status == CONS_Down)
{ {
if (contents) if (contents)
{ {
@ -368,7 +369,7 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
if (ctrl == CON_ThrowDelayed) if (ctrl == CON_ThrowDelayed)
{ {
CancelUse(); CancelUse();
if (release) if (status == CONS_Up)
{ {
VirtualCursor()->StopAim(); VirtualCursor()->StopAim();
@ -392,14 +393,14 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
// forward to script... // forward to script...
if (house) if (house)
{ {
return ControlMovement2Script(ctrl, x, y, strength, repeat, release, house); return ControlMovement2Script(ctrl, x, y, strength, repeat, status, house);
} }
else if (vehicle) else if (vehicle)
{ {
if (ControlMovement2Script(ctrl, x, y, strength, repeat, release, vehicle)) return true; if (ControlMovement2Script(ctrl, x, y, strength, repeat, status, vehicle)) return true;
} }
return ObjectControlMovement(plr, ctrl, strength, release); return ObjectControlMovement(plr, ctrl, strength, status);
} }
// Do a roll on landing or when standing. This means that the CON_Down was not handled previously. // Do a roll on landing or when standing. This means that the CON_Down was not handled previously.
@ -423,7 +424,7 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
// Fall through half-solid mask // Fall through half-solid mask
if (ctrl == CON_FallThrough) if (ctrl == CON_FallThrough)
{ {
if(!release) if(status == CONS_Down)
{ {
if (this->IsWalking()) if (this->IsWalking())
{ {
@ -459,7 +460,7 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
} }
// Unhandled control // Unhandled control
return _inherited(plr, ctrl, x, y, strength, repeat, release, ...); return _inherited(plr, ctrl, x, y, strength, repeat, status, ...);
} }
// A wrapper to SetCommand to catch special behaviour for some actions. // A wrapper to SetCommand to catch special behaviour for some actions.
@ -866,16 +867,16 @@ func FxItemRemovalCheckStop(object target, proplist effect, int reason, bool tem
// Control use redirected to script // Control use redirected to script
func ControlUse2Script(int ctrl, int x, int y, int strength, bool repeat, bool release, object obj) func ControlUse2Script(int ctrl, int x, int y, int strength, bool repeat, int status, object obj)
{ {
// standard use // standard use
if (ctrl == CON_Use || ctrl == CON_UseAlt) if (ctrl == CON_Use || ctrl == CON_UseAlt)
{ {
if (!release && !repeat) if (status == CONS_Down && !repeat)
{ {
return StartUseControl(ctrl,x, y, obj); return StartUseControl(ctrl,x, y, obj);
} }
else if (release && obj == this.control.current_object) else if (status == CONS_Up && obj == this.control.current_object)
{ {
return StopUseControl(x, y, obj); return StopUseControl(x, y, obj);
} }
@ -883,11 +884,11 @@ func ControlUse2Script(int ctrl, int x, int y, int strength, bool repeat, bool r
// gamepad use // gamepad use
else if (ctrl == CON_UseDelayed || ctrl == CON_UseAltDelayed) else if (ctrl == CON_UseDelayed || ctrl == CON_UseAltDelayed)
{ {
if (!release && !repeat) if (status == CONS_Down && !repeat)
{ {
return StartUseDelayedControl(ctrl, obj); return StartUseDelayedControl(ctrl, obj);
} }
else if (release && obj == this.control.current_object) else if (status == CONS_Up && obj == this.control.current_object)
{ {
return StopUseDelayedControl(obj); return StopUseDelayedControl(obj);
} }
@ -896,7 +897,7 @@ func ControlUse2Script(int ctrl, int x, int y, int strength, bool repeat, bool r
// more use (holding) // more use (holding)
if (ctrl == CON_Use || ctrl == CON_UseAlt || ctrl == CON_UseDelayed || ctrl == CON_UseAltDelayed) if (ctrl == CON_Use || ctrl == CON_UseAlt || ctrl == CON_UseDelayed || ctrl == CON_UseAltDelayed)
{ {
if (release) if (status == CONS_Up)
{ {
// leftover use release // leftover use release
CancelUse(); CancelUse();
@ -912,7 +913,7 @@ func ControlUse2Script(int ctrl, int x, int y, int strength, bool repeat, bool r
} }
// Control use redirected to script // Control use redirected to script
func ControlMovement2Script(int ctrl, int x, int y, int strength, bool repeat, bool release, object obj) func ControlMovement2Script(int ctrl, int x, int y, int strength, bool repeat, int status, object obj)
{ {
// overloads of movement commandos // overloads of movement commandos
if (ctrl == CON_Left || ctrl == CON_Right || ctrl == CON_Down || ctrl == CON_Up || ctrl == CON_Jump) if (ctrl == CON_Left || ctrl == CON_Right || ctrl == CON_Down || ctrl == CON_Up || ctrl == CON_Jump)
@ -921,7 +922,7 @@ func ControlMovement2Script(int ctrl, int x, int y, int strength, bool repeat, b
if (Contained() == obj) if (Contained() == obj)
control_string = "Contained"; control_string = "Contained";
if (release) if (status == CONS_Up)
{ {
// if any movement key has been released, ControlStop is called // if any movement key has been released, ControlStop is called
if (obj->Call(Format("~%sStop", control_string), this, ctrl)) if (obj->Call(Format("~%sStop", control_string), this, ctrl))

View File

@ -19,7 +19,7 @@ local virtual_cursor;
/* This part of gamepad control handles only object-style menus. /* This part of gamepad control handles only object-style menus.
Fullscreen menus are handled differently. */ Fullscreen menus are handled differently. */
func Control2Menu(int ctrl, int x, int y, int strength, bool repeat, bool release) func Control2Menu(int ctrl, int x, int y, int strength, bool repeat, int status)
{ {
/* all this stuff is already done on a higher layer - in playercontrol.c /* all this stuff is already done on a higher layer - in playercontrol.c
@ -40,7 +40,7 @@ func Control2Menu(int ctrl, int x, int y, int strength, bool repeat, bool releas
this->GetMenu()->~UpdateCursor(mex,mey); this->GetMenu()->~UpdateCursor(mex,mey);
} }
// click on menu // click on menu
if (release) if (status == CONS_Up)
{ {
// select // select
if (ctrl == CON_UseDelayed) if (ctrl == CON_UseDelayed)
@ -50,13 +50,13 @@ func Control2Menu(int ctrl, int x, int y, int strength, bool repeat, bool releas
return true; return true;
} }
public func ObjectControlMovement(int plr, int ctrl, int strength, bool release) public func ObjectControlMovement(int plr, int ctrl, int strength, int status)
{ {
// from PlayerControl.c // from PlayerControl.c
var result = inherited(plr,ctrl,strength,release,...); var result = inherited(plr,ctrl,strength,status,...);
// do the following only if strength >= CON_Gamepad_Deadzone // do the following only if strength >= CON_Gamepad_Deadzone
if(!release) if(status == CONS_Down)
if(strength != nil && strength < CON_Gamepad_Deadzone) if(strength != nil && strength < CON_Gamepad_Deadzone)
return result; return result;
@ -66,7 +66,7 @@ public func ObjectControlMovement(int plr, int ctrl, int strength, bool release)
if(!virtual_cursor) return result; if(!virtual_cursor) return result;
// change direction of virtual_cursor // change direction of virtual_cursor
if(!release) if(status == CONS_Down)
virtual_cursor->Direction(ctrl); virtual_cursor->Direction(ctrl);
return result; return result;
@ -143,4 +143,4 @@ func RemoveVirtualCursor()
{ {
if (virtual_cursor) if (virtual_cursor)
virtual_cursor->StopAim(); virtual_cursor->StopAim();
} }

View File

@ -26,13 +26,13 @@ public func OnShiftCursor(object new_cursor)
return _inherited(new_cursor, ...); return _inherited(new_cursor, ...);
} }
public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool repeat, bool release) public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool repeat, int status)
{ {
if (!this) if (!this)
return inherited(plr, ctrl, x, y, strength, repeat, release, ...); return inherited(plr, ctrl, x, y, strength, repeat, status, ...);
// Begin interaction. // Begin interaction.
if (ctrl == CON_Interact && !release) if (ctrl == CON_Interact && status == CONS_Down)
{ {
this->CancelUse(); this->CancelUse();
BeginInteract(); BeginInteract();
@ -50,7 +50,7 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
} }
// Finish picking up (aka "collect"). // Finish picking up (aka "collect").
if (ctrl == CON_Interact && release) if (ctrl == CON_Interact && status == CONS_Up)
{ {
EndInteract(); EndInteract();
return true; return true;
@ -71,7 +71,7 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
} }
} }
return inherited(plr, ctrl, x, y, strength, repeat, release, ...); return inherited(plr, ctrl, x, y, strength, repeat, status, ...);
} }
private func FxIntHighlightInteractionStart(object target, proplist fx, temp, proplist interaction, proplist interaction_help) private func FxIntHighlightInteractionStart(object target, proplist fx, temp, proplist interaction, proplist interaction_help)

View File

@ -46,17 +46,17 @@ func RejectCollect(id objid, object obj)
return false; return false;
} }
public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool repeat, bool release) public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool repeat, int status)
{ {
if (!this) if (!this)
return inherited(plr, ctrl, x, y, strength, repeat, release, ...); return inherited(plr, ctrl, x, y, strength, repeat, status, ...);
// Quickswitch changes the active slot to the last selected one // Quickswitch changes the active slot to the last selected one
if (ctrl == CON_QuickSwitch) if (ctrl == CON_QuickSwitch)
{ {
// but ignore quickswitch if we have more than 1 hand-slot // but ignore quickswitch if we have more than 1 hand-slot
if(this.HandObjects > 1) if(this.HandObjects > 1)
return inherited(plr, ctrl, x, y, strength, repeat, release, ...);; return inherited(plr, ctrl, x, y, strength, repeat, status, ...);;
// select last slot // select last slot
SetHandItemPos(0, this.inventory.last_slot); // last_slot is updated in SetHandItemPos SetHandItemPos(0, this.inventory.last_slot); // last_slot is updated in SetHandItemPos
@ -67,7 +67,7 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
if (!Contained()) if (!Contained())
{ {
// Quick-pickup item via click? Note that this relies on being executed after the normal Clonk controls // Quick-pickup item via click? Note that this relies on being executed after the normal Clonk controls
if (ctrl == CON_Use && !this->GetHandItem(0) && !release) if (ctrl == CON_Use && !this->GetHandItem(0) && status == CONS_Down)
{ {
var sort = Sort_Distance(x, y); var sort = Sort_Distance(x, y);
var items = FindAllPickupItems(sort); var items = FindAllPickupItems(sort);
@ -78,7 +78,7 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
} }
// Begin picking up objects. // Begin picking up objects.
if (ctrl == CON_PickUp && !release) if (ctrl == CON_PickUp && status == CONS_Down)
{ {
this->CancelUse(); this->CancelUse();
BeginPickingUp(); BeginPickingUp();
@ -86,7 +86,7 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
} }
// Drop the mouse item? // Drop the mouse item?
if (ctrl == CON_Drop && !release) if (ctrl == CON_Drop && status == CONS_Down)
{ {
// Do not immediately collect another thing unless chosen with left/right. // Do not immediately collect another thing unless chosen with left/right.
if (this.inventory.is_picking_up) if (this.inventory.is_picking_up)
@ -120,7 +120,7 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
} }
// Finish picking up (aka "collect"). // Finish picking up (aka "collect").
if (ctrl == CON_PickUp && release) if (ctrl == CON_PickUp && status == CONS_Up)
{ {
EndPickingUp(); EndPickingUp();
return true; return true;
@ -208,7 +208,7 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
return true; return true;
} }
return inherited(plr, ctrl, x, y, strength, repeat, release, ...); return inherited(plr, ctrl, x, y, strength, repeat, status, ...);
} }
private func FxIntHighlightItemStart(object target, proplist fx, temp, object item) private func FxIntHighlightItemStart(object target, proplist fx, temp, object item)
@ -424,4 +424,4 @@ func Selected(object mnu, object mnu_item)
mnu_item->SetSymbol(show_new_item); mnu_item->SetSymbol(show_new_item);
// swap index with backpack index // swap index with backpack index
this->Switch2Items(hands_index, backpack_index); this->Switch2Items(hands_index, backpack_index);
} }

View File

@ -68,12 +68,12 @@ public func FxControlConstructionPreviewStart(object clonk, effect, int temp, id
} }
// Called by Control2Effect // Called by Control2Effect
public func FxControlConstructionPreviewControl(object clonk, effect, int ctrl, int x, int y, int strength, bool repeat, bool release) public func FxControlConstructionPreviewControl(object clonk, effect, int ctrl, int x, int y, int strength, bool repeat, int status)
{ {
if (ctrl != CON_Aim) if (ctrl != CON_Aim)
{ {
// CON_Use is accept, but don't remove the preview, this is done on releasing the button. // CON_Use is accept, but don't remove the preview, this is done on releasing the button.
if (ctrl == CON_Use && !release) if (ctrl == CON_Use && status == CONS_Down)
{ {
var ok = CreateConstructionSite(clonk, effect.structure, AbsX(effect.preview->GetX()), AbsY(effect.preview->GetY() + effect.preview.dimension_y/2), effect.preview.blocked, effect.preview.direction, effect.preview.stick_to); var ok = CreateConstructionSite(clonk, effect.structure, AbsX(effect.preview->GetX()), AbsY(effect.preview->GetY() + effect.preview.dimension_y/2), effect.preview.blocked, effect.preview.direction, effect.preview.stick_to);
if (ok) if (ok)
@ -90,7 +90,7 @@ public func FxControlConstructionPreviewControl(object clonk, effect, int ctrl,
// (yes, this means that actionbar-hotkeys wont work for it. However clicking the button will.) // (yes, this means that actionbar-hotkeys wont work for it. However clicking the button will.)
else if (IsInteractionControl(ctrl)) else if (IsInteractionControl(ctrl))
{ {
if (release) if (status == CONS_Up)
effect.preview->Flip(); effect.preview->Flip();
return true; return true;
} }

View File

@ -311,13 +311,13 @@ public func FxIntClimbControlStop(target, effect)
SetHandAction(0); SetHandAction(0);
} }
public func FxIntClimbControlControl(object target, proplist effect, int ctrl, int x, int y, int strength, bool repeat, bool release) public func FxIntClimbControlControl(object target, proplist effect, int ctrl, int x, int y, int strength, bool repeat, int status)
{ {
// Only handle movement controls. // Only handle movement controls.
if (ctrl != CON_Up && ctrl != CON_Down && ctrl != CON_Right && ctrl != CON_Left) if (ctrl != CON_Up && ctrl != CON_Down && ctrl != CON_Right && ctrl != CON_Left)
return false; return false;
// Perform actions on key down and not on release. // Perform actions on key down and not on release.
if (release) if (status != CONS_Down)
return false; return false;
if (ctrl == CON_Up) if (ctrl == CON_Up)

View File

@ -18,12 +18,11 @@ global func PlayerControl(int plr, int ctrl, id spec_id, int x, int y, int stren
{ {
var release = status == CONS_Up; var release = status == CONS_Up;
//Log("%d, %s, %i, %d, %d, %d, %v, %v", plr, GetPlayerControlName(ctrl), spec_id, x,y,strength, repeat, status); //Log("%d, %s, %i, %d, %d, %d, %v, %v", plr, GetPlayerControlName(ctrl), spec_id, x,y,strength, repeat, status);
if (status == CONS_Moved) return false;
// Control handled by definition? Forward // Control handled by definition? Forward
if (spec_id) return spec_id->PlayerControl(plr, ctrl, x, y, strength, repeat, release); if (spec_id) return spec_id->PlayerControl(plr, ctrl, x, y, strength, repeat, status);
// Forward control to player // Forward control to player
if (Control2Player(plr,ctrl, x, y, strength, repeat, release)) return true; if (Control2Player(plr,ctrl, x, y, strength, repeat, status)) return true;
// Forward control to cursor // Forward control to cursor
var cursor = GetCursor(plr); var cursor = GetCursor(plr);
@ -34,7 +33,7 @@ global func PlayerControl(int plr, int ctrl, id spec_id, int x, int y, int stren
// menu controls: // menu controls:
if (cursor->~GetMenu()) if (cursor->~GetMenu() && status != CONS_Moved)
{ {
// direction keys are always forwarded to the menu // direction keys are always forwarded to the menu
// (because the clonk shall not move while the menu is open) // (because the clonk shall not move while the menu is open)
@ -83,11 +82,11 @@ global func PlayerControl(int plr, int ctrl, id spec_id, int x, int y, int stren
} }
// Overload by effect? // Overload by effect?
if (cursor->Control2Effect(plr, ctrl, cursorX, cursorY, strength, repeat, release)) return true; if (cursor->Control2Effect(plr, ctrl, cursorX, cursorY, strength, repeat, status)) return true;
if (cursor->ObjectControl(plr, ctrl, cursorX, cursorY, strength, repeat, release)) if (cursor->ObjectControl(plr, ctrl, cursorX, cursorY, strength, repeat, status))
{ {
if (cursor && !release && !repeat) if (cursor && status == CONS_Down && !repeat)
{ {
// non-mouse controls reset view // non-mouse controls reset view
if (!x && !y) ResetCursorView(plr); if (!x && !y) ResetCursorView(plr);
@ -127,7 +126,7 @@ global func PlayerHasVirtualCursor(int plr)
// Control2Player // Control2Player
// Player-wide controls // Player-wide controls
global func Control2Player(int plr, int ctrl, int x, int y, int strength, bool repeat, bool release) global func Control2Player(int plr, int ctrl, int x, int y, int strength, bool repeat, int status)
{ {
// select previous or next // select previous or next
if (ctrl == CON_PreviousCrew) if (ctrl == CON_PreviousCrew)
@ -202,7 +201,7 @@ global func StopSelected(int plr)
// Control2Effect // Control2Effect
// Call control function in all effects that have "Control" in their name // Call control function in all effects that have "Control" in their name
global func Control2Effect(int plr, int ctrl, int x, int y, int strength, bool repeat, bool release) global func Control2Effect(int plr, int ctrl, int x, int y, int strength, bool repeat, int status)
{ {
// x and y are local coordinates // x and y are local coordinates
if (!this) return false; if (!this) return false;
@ -213,7 +212,7 @@ global func Control2Effect(int plr, int ctrl, int x, int y, int strength, bool r
{ {
iEffect = GetEffect("*Control*", this, i); iEffect = GetEffect("*Control*", this, i);
if (iEffect) if (iEffect)
if (EffectCall(this, iEffect, "Control", ctrl, x,y,strength, repeat, release)) if (EffectCall(this, iEffect, "Control", ctrl, x,y,strength, repeat, status))
return true; return true;
} }
// No effect handled the control // No effect handled the control
@ -224,7 +223,7 @@ global func Control2Effect(int plr, int ctrl, int x, int y, int strength, bool r
// Called from PlayerControl when a control is issued to the cursor // Called from PlayerControl when a control is issued to the cursor
// Return whether handled // Return whether handled
// To be overloaded by specific objects to enable additional controls // To be overloaded by specific objects to enable additional controls
global func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool repeat, bool release) global func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool repeat, int status)
{ {
if (!this) return false; if (!this) return false;
@ -233,7 +232,7 @@ global func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
// Movement controls // Movement controls
if (ctrl == CON_Left || ctrl == CON_Right || ctrl == CON_Up || ctrl == CON_Down || ctrl == CON_Jump) if (ctrl == CON_Left || ctrl == CON_Right || ctrl == CON_Up || ctrl == CON_Down || ctrl == CON_Jump)
return ObjectControlMovement(plr, ctrl, strength, release, repeat); return ObjectControlMovement(plr, ctrl, strength, status, repeat);
// Unhandled control // Unhandled control
return false; return false;
@ -276,7 +275,7 @@ global func NameComDir(comdir)
} }
// Called when CON_Left/Right/Up/Down controls are issued/released // Called when CON_Left/Right/Up/Down controls are issued/released
// Return whether handled // Return whether handled
global func ObjectControlMovement(int plr, int ctrl, int strength, bool release, bool repeat) global func ObjectControlMovement(int plr, int ctrl, int strength, int status, bool repeat)
{ {
if (!this) return false; if (!this) return false;
@ -284,13 +283,13 @@ global func ObjectControlMovement(int plr, int ctrl, int strength, bool release,
if (Contained()) return false; if (Contained()) return false;
// this is for controlling movement with Analogpad // this is for controlling movement with Analogpad
if(!release) if(status == CONS_Down)
if(strength != nil && strength < CON_Gamepad_Deadzone) if(strength != nil && strength < CON_Gamepad_Deadzone)
return true; return true;
var proc = GetProcedure(); var proc = GetProcedure();
// Some specific movement controls // Some specific movement controls
if (!release) if (status == CONS_Down)
{ {
// Jump control // Jump control
if (ctrl == CON_Jump) if (ctrl == CON_Jump)

View File

@ -2,13 +2,13 @@
#appendto Library_ClonkControl #appendto Library_ClonkControl
public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool repeat, bool release) public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool repeat, int status)
{ {
if (!this) if (!this)
return false; return false;
// Spawn menu // Spawn menu
if (ctrl == CON_SpawnMenu && !release) if (ctrl == CON_SpawnMenu && status == CONS_Down)
{ {
// Close any menu if open. // Close any menu if open.
if (GetMenu()) if (GetMenu())
@ -31,5 +31,5 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
} }
// Unhandled control will be handled by the library itself. // Unhandled control will be handled by the library itself.
return _inherited(plr, ctrl, x, y, strength, repeat, release, ...); return _inherited(plr, ctrl, x, y, strength, repeat, status, ...);
} }

View File

@ -1,9 +1,9 @@
// Shows and hides the tutorial guide if the [H] button is pressed. // Shows and hides the tutorial guide if the [H] button is pressed.
global func PlayerControl(int plr, int ctrl, id spec_id, int x, int y, int strength, bool repeat, bool release) global func PlayerControl(int plr, int ctrl, id spec_id, int x, int y, int strength, bool repeat, int status)
{ {
if (ctrl != CON_TutorialGuide) if (ctrl != CON_TutorialGuide)
return _inherited(plr, ctrl, spec_id, x, y, strength, repeat, release, ...); return _inherited(plr, ctrl, spec_id, x, y, strength, repeat, status, ...);
// Don't do anything if the player is a sequence. // Don't do anything if the player is a sequence.
if (GetActiveSequence()) if (GetActiveSequence())
return; return;
@ -17,4 +17,4 @@ global func PlayerControl(int plr, int ctrl, id spec_id, int x, int y, int stren
else else
guide->HideGuide(); guide->HideGuide();
return; return;
} }