home *** CD-ROM | disk | FTP | other *** search
/ 3D Game Programming All in One / 3D Game Programming All in One Disc.iso / 3D2E / RESOURCES / KOOB / control / client / misc / chatbox.cs next >
Encoding:
Text File  |  2006-09-25  |  1.5 KB  |  54 lines

  1.  
  2.  
  3.  
  4. new MessageVector(MsgBoxMessageVector);///***KCF CHAT
  5. $LastframeTarget = 0;///***KCF CHAT
  6.  
  7.  
  8. function onChatMessage(%message, %voice, %pitch)
  9. {
  10.     echo("*****************************************");
  11.     echo("GetWordCount(%message):",GetWordCount(%message));
  12.     echo("%message:",%message);
  13.    if (GetWordCount(%message)) {
  14.       ChatBox.AddLine(%message);
  15.    }
  16. }
  17. function onServerMessage(%message)
  18. {
  19.    if (GetWordCount(%message)) {
  20.       ChatBox.AddLine(%message);
  21.    }
  22. }
  23.  
  24. new MessageVector(MsgBoxMessageVector);
  25. $LastframeTarget = 0;
  26. function ChatBox::addLine(%this,%text)
  27. {
  28.    %textHeight = %this.profile.fontSize;
  29.    if (%textHeight <= 0)
  30.       %textHeight = 12;
  31.    %chatScrollHeight = getWord(%this.getGroup().getGroup().extent, 1);
  32.    %chatPosition = getWord(%this.extent, 1) - %chatScrollHeight +
  33.         getWord(%this.position, 1);
  34.    %linesToScroll = mFloor((%chatPosition / %textHeight) + 0.5);
  35.    if (%linesToScroll > 0)
  36.       %origPosition = %this.position;
  37.    while( !chatPageDown.isVisible() && MsgBoxMessageVector.getNumLines() &&
  38.          (MsgBoxMessageVector.getNumLines() >= $pref::frameMessageLogSize))
  39.    {
  40.       %tag = MsgBoxMessageVector.getLineTag(0);
  41.       if(%tag != 0)
  42.          %tag.delete();
  43.       MsgBoxMessageVector.popFrontLine();
  44.    }
  45.    MsgBoxMessageVector.pushBackLine(%text, $LastframeTarget);
  46.    $LastframeTarget = 0;
  47.    if (%linesToScroll > 0)
  48.    {
  49.       chatPageDown.setVisible(true);
  50.       %this.position = %origPosition;
  51.    }
  52.    else
  53.       chatPageDown.setVisible(false);
  54. }