Not logged inOpenClonk Forum
Up Topic Community / German / ControlUse*
- - By ClonkGeist [de] Date 2012-02-01 23:19
Und wieder ein neues Problem. Nach der Lösung mit der Mausposition funktioniert das ganze mit ControlUse* nicht mehr ganz richtig. Mein ObjectControl Scriptteil im Objekt sieht etwa so aus:
public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool repeat, bool release)
{
  if (!this) return false;
 
  if(ctrl == CON_MouseMoved)
  {
    foobar(x, y);
    return true;
  }
 
  return false;
}


ObjectControl im Clonk-Appendto:
public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool repeat, bool release)
{
  if(foo)
    if( foo->ObjectControl(plr, ctrl, x, y, strength, repeat, release) )
      return true;
 
  return _inherited(plr, ctrl, x, y, strength, repeat, release);
}


Mein Problem ist nun, dass ich die ControlUseHolding Aufrufe nicht mehr bekomme. Der ControlUse* Teil sieht so aus:

protected func HoldingEnabled() { return true; }

public func ControlUseStart(object clonk, int x, int y)
{
  return true;
}

public func ControlUseHolding(object clonk, int x, int y)
{
  // ...
}

Wie schon gesagt: Ich bekomme keine ControlUseHolding-Aufrufe mehr. ControlUseStart wird aufgerufen, und soweit ich weiß müssen ControlUseStart und HoldingEnabled beide true zurückgeben, damit ich ControlUseHolding nutzen kann. Wie man in den Scriptausschnitten sehen kann, ist dies vorhanden. Wenn ich die if-Abfrage mit CON_MouseMoved komplett auskommentiere, funktioniert das ganze auch wieder. Wenn ich es drin lasse leider nicht mehr.
Reply
Parent - - By Zapper [de] Date 2012-02-02 00:00
Mh, wenn CON_MouseMoved die selbe Control benutzt (Mouse1Move zB) wie die Controls, die fuer ControlUseHolding benutzt werden, dann "überschreibt" dein Control die alten.
Jeder "Befehl" (zB Mouse1Move) wird nur einmal verarbeitet. Wenn es mehrere gibt, dann werden die solange nacheinander durchgeschickt, bis einmal "true" zurueckgegeben wird.
..Je nachdem was du in foobar() machst, reicht es vielleicht auch bei CON_MouseMoved false zurückzugeben
Parent - - By ClonkGeist [de] Date 2012-02-02 00:24
Demnach würde es also funktionieren:
local use_holding;

public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool repeat, bool release, object clonk)
{
  if (!this) return false;
 
  if(ctrl == CON_Use || ctrl == CON_UseDelayed || ctrl == CON_UseAlt || ctrl == CON_UseAltDelayed)
  {
    use_holding = !use_holding;
    ControlUseHolding(clonk, x, y);
    return false;
  }
 
  if(ctrl == CON_MouseMoved && !use_holding)
  {
    foobar(x, y);
    return true;
  }
 
  return false;
}
Reply
Parent - By Zapper [de] Date 2012-02-02 09:18
oder einfach sowas wie


public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool repeat, bool release)
{
  if(foo)
    if( foo->ObjectControl(plr, ctrl, x, y, strength, repeat, release) )
      return false;

  return _inherited(plr, ctrl, x, y, strength, repeat, release);
}

(und das ObjectControl in deinem foo so lassen, wie du es hattest)
Up Topic Community / German / ControlUse*

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill