HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: How to make a chat window with textbox control instead of the label control?  (Read 4646 times)

AWW_boss

  • General Accounts
  • *
  • Posts: 846
  • gdfgd
    • View Profile

Hi!

This morning i argued with some heroengine users (mostly trash talk) that it's sad that heroengine gui doesn't come with an out of the box solution for the chat window that is robust, functional, flawless and most importantly gives a possibility to copy/paste the displayed text. This is my attempt in making one and I am going to present the code i am using in a form of a tutorial.


This is not a beginner nor step by step tutorial; you need to know what you are doing in order to make it work. If you screw something up, most likely i won't have time to troubleshoot your problems.


This chat control is flawed, it has some small scrolling issues that i will let you discover yourselves. My main motivation is to encourage you to fix them if you're smart enough, cause i ain't.


Features:
-you'll be able to copy text in display area of the chat window
-chat window will save its state (window size, window position and the text displayed)
« Last Edit: Aug 19, 13, 07:12:32 AM by AWW_boss »
Logged

AWW_boss

  • General Accounts
  • *
  • Posts: 846
  • gdfgd
    • View Profile

E_ACCC

Create and add new fields:
Field E_GUILayoutSizeXLookupList /lookuplist indexed by string of float/
Field E_GUILayoutSizeYLookupList /lookuplist indexed by string of float/
Field E_GUILayoutPositionXLookupList /lookuplist indexed by string of float/
Field E_GUILayoutPositionYLookupList /lookuplist indexed by string of float/
Field E_GUICLIDisplayBoxCharCounterLookupList /lookuplist indexed by string of integer/
Field E_GUICLIDisplayBoxLineListLookupList /lookuplist indexed by string of list of string/
« Last Edit: Aug 19, 13, 08:35:21 AM by AWW_boss »
Logged

AWW_boss

  • General Accounts
  • *
  • Posts: 846
  • gdfgd
    • View Profile

Create new class:

E_GUICLIDisplayBox (guicontrol), inherits GUITextInputBox
Field E_GUICLIDisplayBoxCharCounter /integer/
Field E_GUICLIDisplayBoxLineList /list of string/


Code: [Select]
method _AddTextDisplayLine(line copies String)
  add back line to me.E_GUICLIDisplayBoxLineList
  me.E_GUICLIDisplayBoxCharCounter = me.E_GUICLIDisplayBoxCharCounter + line.length + 1
  me._CullTextDisplay()
  me._RefreshTextDisplay()
.

method _CullTextDisplay ()
 
  while (me.E_GUICLIDisplayBoxCharCounter > 0.75 * me.maxLen)
    me.E_GUICLIDisplayBoxCharCounter = me.E_GUICLIDisplayBoxCharCounter - me.E_GUICLIDisplayBoxLineList[1].length - 1
    remove me.E_GUICLIDisplayBoxLineList at 1
  .

.


method _RefreshTextDisplay()
 

 
  tempvalue as String
  JoinStrings(tempvalue, me.E_GUICLIDisplayBoxLineList, "$R")

  me.value = tempvalue
 
  me.offset.y = me.maxLen
   
  //  println ("char counter " + me.E_GUICLIDisplayBoxCharCounter)
  //  println ("char limit " + me.maxLen)
  //  println ("real char number " +  tempvalue.length)
  //  println ("offset " +  me.offset.y)
 
 
.

method onKeyDown(args references Class GUIKeyboardEvent)
  if (args.ctrl)
    if (args.keyCode = 67)
      SetKeyboardFocus(None)
      println ("Got ctrl-c")
    .
  else
    SetKeyboardFocus(None)
  .
 
.

method onGotFocus(args references Class GUIFocusChangeEvent)
  if hasMethod(me, "HE_onGotFocus")
    me.HE_onGotFocus(args)
    return
  .
  var parentControl = me.parent
  while parentControl != None and args.handled != true
    if hasMethod(parentControl, "_onTextInputBoxGotFocus")
      parentControl._onTextInputBoxGotFocus(args)
      if args.source == None
        args.handled = true
        return
      .
    .
    parentControl = parentControl.parent
  .
  me.selected = true
 
  me.selectionColor = "#0.80,0.93,1.00,1"
  forceLayout (me.parent)
.

method onLostFocus(args references Class GUIFocusChangeEvent)
  if hasMethod(me, "HE_onLostFocus")
    me.HE_onLostFocus(args)
    return
  .
  var parentControl = me.parent
  while parentControl != None and args.handled != true
    if hasMethod(parentControl, "_onTextInputBoxLostFocus")
      parentControl._onTextInputBoxLostFocus(args)
      if args.source == None
        args.handled = true
        return
      .
    .
    parentControl = parentControl.parent
  .
  me.selected = false
 
  me.selectionColor = "#1.00,1.00,1.00,1"
  forceLayout (me.parent)
.



« Last Edit: Aug 19, 13, 08:35:34 AM by AWW_boss »
Logged

AWW_boss

  • General Accounts
  • *
  • Posts: 846
  • gdfgd
    • View Profile

Create new gui control:

e_guiclidisplaybox.xml

Code: [Select]

<createControlType inheritFrom='_textInputBox' class='E_GUICLIDisplayBox' type='E_GUICLIDisplayBox' description='' treePath='CleanEngine' name="E_GUICLIDisplayBox" isMultiLine="true" historySize="0" textPadding="5" readOnly="true" E_GUICLIDisplayBoxCharCounter="0">
  <size x="314" y="100"/>
  <area x="314" y="37"/>
</createControlType>

<createControlType inheritFrom='_panel' type='E_GUICLIDisplayBoxHolder' description='' treePath='CleanEngine' name="E_GUICLIDisplayBoxHolder">
  <size x="314.0" y="100.0"/>
  <E_GUICLIDisplayBox name="display" dockMode="FILL"/>
  <_scrollbar name="_scrollbar">
    <set name='E_GUICLIDisplayBoxHolder._scrollbar.upButton' attribute='owner' value="display"/>
    <set name='E_GUICLIDisplayBoxHolder._scrollbar.downButton' attribute='owner' value="display"/>
    <set name='E_GUICLIDisplayBoxHolder._scrollbar.scrollPagePanel' attribute='owner' value="display"/>
    <set name='E_GUICLIDisplayBoxHolder._scrollbar.scrollPagePanel.thumb' attribute='owner' value="display"/>
  </_scrollbar>
</createControlType>

« Last Edit: Aug 19, 13, 08:35:49 AM by AWW_boss »
Logged

AWW_boss

  • General Accounts
  • *
  • Posts: 846
  • gdfgd
    • View Profile

Create new class:

E_GUICLIWindow (guicontrol), inherits _GUIBaseWindow
Field E_GUICLIWindowType /string/

Code: [Select]

method HE_onControlBuild ()

  //  println("1")
  me._allowWindowToScroll(me.scrollable)
  //  println("2")
  me._allowWindowToResize(me.resizeable)
  //  println("3")
  me._allowTitlebar(me.allowTitlebar)
  //  println("4")
  me._allowWindowCloseButton(me.allowCloseButton)
  //  println("5")
  me._allowWindowHelpButton(me.allowHelpButton)
  //  println("6")
  me._allowWindowMinimizeButton(me.allowMinimizeButton)
  //  println("6")
  me._allowWindowDragging(me.allowMove)
  //  println("7")
  title as NodeRef of Class GUILabel = findGUIControlByName(me._getTitlebar(), "title")
  if title != None   
    if title.text != ""
      me._changeWindowTitleText(title.text)
    .
  .
 
  me.CLIWindowRestoreState()
 
.



method HE_closeWindow() as Boolean
  me.CLIWindowSaveState ()
  return false
.

method CLIWindowSaveState ()

  $ACCC.E_GUILayoutSizeXLookupList[me.E_GUICLIWindowType] = me.size.x
  $ACCC.E_GUILayoutSizeYLookupList[me.E_GUICLIWindowType] = me.size.y
  $ACCC.E_GUILayoutPositionXLookupList[me.E_GUICLIWindowType] = me.position.x
  $ACCC.E_GUILayoutPositionYLookupList[me.E_GUICLIWindowType] = me.position.y
  displayBox as NodeRef of Class E_GUICLIDisplayBox = FindGUIControlByName(me, "_spacer.E_GUICLIDisplayBoxHolder.display")
  $ACCC.E_GUICLIDisplayBoxCharCounterLookupList[me.E_GUICLIWindowType] = displayBox.E_GUICLIDisplayBoxCharCounter
  $ACCC.E_GUICLIDisplayBoxLineListLookupList[me.E_GUICLIWindowType] = displayBox.E_GUICLIDisplayBoxLineList

.

method CLIWindowRestoreState ()
 
 
  if ($ACCC.E_GUILayoutSizeXLookupList[me.E_GUICLIWindowType] <> 0) or \
    ($ACCC.E_GUILayoutSizeYLookupList[me.E_GUICLIWindowType] <> 0) or \
    ($ACCC.E_GUILayoutPositionXLookupList[me.E_GUICLIWindowType] <> 0) or \
    ($ACCC.E_GUILayoutPositionYLookupList[me.E_GUICLIWindowType] <> 0)
 
    me.size.x = $ACCC.E_GUILayoutSizeXLookupList[me.E_GUICLIWindowType]
    me.size.y = $ACCC.E_GUILayoutSizeYLookupList[me.E_GUICLIWindowType]
    me.position.x = $ACCC.E_GUILayoutPositionXLookupList[me.E_GUICLIWindowType]
    me.position.y = $ACCC.E_GUILayoutPositionYLookupList[me.E_GUICLIWindowType]
  .
 
  displayBox as NodeRef of Class E_GUICLIDisplayBox = FindGUIControlByName(me, "_spacer.E_GUICLIDisplayBoxHolder.display")
  displayBox.E_GUICLIDisplayBoxCharCounter = $ACCC.E_GUICLIDisplayBoxCharCounterLookupList[me.E_GUICLIWindowType]
  displayBox.E_GUICLIDisplayBoxLineList = $ACCC.E_GUICLIDisplayBoxLineListLookupList[me.E_GUICLIWindowType]
 
 
  displayBox._RefreshTextDisplay()

 
.





method AddCLIMessage( message copies String, channel as String )
 
  displayBox as NodeRef of Class E_GUICLIDisplayBox = FindGUIControlByName(me, "_spacer.E_GUICLIDisplayBoxHolder.display")
  displayBox._AddTextDisplayLine(message)
   
.



« Last Edit: Aug 19, 13, 08:36:04 AM by AWW_boss »
Logged

AWW_boss

  • General Accounts
  • *
  • Posts: 846
  • gdfgd
    • View Profile

Create new gui control:

e_guicliwindow.xml

Code: [Select]

<createControlType class='E_GUICLIWindow' type='E_GUICLIWindow' description='E_GUICLIWindow' treePath='CleanEngine' name="E_GUICLIWindow" gotoTopOnMouseDown="true" owner="0" skipTextureAlphaTest="true" allowTitlebar="true" allowCloseButton="true" allowDragging="true" resizeable="ALL" scrollable="VERTICAL">
  <size x="208" y="240"/>
  <minimumSize x="200" y="200"/>
  <defaultStatePresentation>
    <color a="0"/>
  </defaultStatePresentation>
  <_resizeTop name="resizeTop"/>
  <_resizeBottom name="resizeBottom"/>
  <_resizeLeft name="resizeLeft"/>
  <_resizeRight name="resizeRight"/>
  <_titlebar name="titlebar"/>
  <E_GUICLIInputBox name="E_GUICLIInputBox" dockMode="BOTTOM">
    <size x="200"/>
  </E_GUICLIInputBox>
  <_spacer name="_spacer" dockMode="FILL">
    <size x="200" y="184"/>
    <E_GUICLIDisplayBoxHolder name="E_GUICLIDisplayBoxHolder" dockMode="FILL">
      <size x="200" y="184"/>
      <set name="E_GUICLIWindow._spacer.E_GUICLIDisplayBoxHolder.display">
        <area x="200" y="16"/>
        <set name='E_GUICLIWindow._spacer.E_GUICLIDisplayBoxHolder.display' attribute='scrollbarAutoHide' value="true"/>
        <set name='E_GUICLIWindow._spacer.E_GUICLIDisplayBoxHolder.display' attribute='maxLen' value="10000"/>
        <set name='E_GUICLIWindow._spacer.E_GUICLIDisplayBoxHolder.display' attribute='E_GUICLIDisplayBoxCharCounter' value="0"/>
      </set>
      <set name='E_GUICLIWindow._spacer.E_GUICLIDisplayBoxHolder._scrollbar' attribute='visible' value="false"/>
    </E_GUICLIDisplayBoxHolder>
  </_spacer>
</createControlType>

« Last Edit: Aug 19, 13, 08:36:17 AM by AWW_boss »
Logged

AWW_boss

  • General Accounts
  • *
  • Posts: 846
  • gdfgd
    • View Profile

Create new class:

E_GUICLIInputBox (guicontrol), inherits GUITextInputBox

Code: [Select]

method OnKeyDown( args references Class GUIKeyboardEvent ) 

  when args.keyCode
    is 27  //  escape key
      SetKeyboardFocus( None )
      me.value = ""
      args.handled = true
    .
    is 13  //  enter key
      args.handled = true
      msg as String = me.value
      //  Strip leading spaces
      while FindString( msg, " " ) == 1 and msg.length > 1
        msg = SubString( msg, 2, msg.length )
      .
      if msg.length > 0
        first as String = SubString( msg, 1, 1 )
        if first == "/"
          if msg.length > 1
            SendCommand( msg )
          .
        else
          SendChat( msg, "game" )       
        .
      .
    .
  . 
.


« Last Edit: Aug 19, 13, 08:36:41 AM by AWW_boss »
Logged

AWW_boss

  • General Accounts
  • *
  • Posts: 846
  • gdfgd
    • View Profile

Create new gui control:

e_guicliinputbox.xml


Code: [Select]

<createControlType inheritFrom='_textInputBox' class='E_GUICLIInputBox' type='E_GUICLIInputBox' description='E_GUICLIInputBox' treePath='CleanEngine' name="E_GUICLIInputBox">
</createControlType>

« Last Edit: Aug 19, 13, 08:37:00 AM by AWW_boss »
Logged

AWW_boss

  • General Accounts
  • *
  • Posts: 846
  • gdfgd
    • View Profile

Delete everything in E_ChatHandlerClassMethods and update it with this code:

Code: [Select]

method HE_GotChatMessage( chatMessage as String, channelName as String )
 
  cliWindow as NodeRef of Class E_GUICLIWindow = me.GetCLIWindow("Tutorial")
  if (cliWindow <> None)
    me.GetCLIWindow("Tutorial").AddCLIMessage( chatMessage, channelName )
  .

.

method OpenCLIWindow(CLIWindowType as String)

 
  cliWindow as NodeRef of Class E_GUICLIWindow = FindGUIControlByName( None, "E_GUICLIWindow" + CLIWindowType)
  if cliWindow != None
    cliWindow.CLIWindowSaveState()
    destroynode(cliWindow)
    return
  .
 
  cliWindow = CreateNodeFromPrototype( "E_GUICLIWindow" )
  cliWindow.name = "E_GUICLIWindow" + CLIWindowType
  cliWindow.E_GUICLIWindowType = CLIWindowType
 
  cliWindow.build = true
 
  titleBar as NodeRef of Class GUILabel = FindGUIControlByName(cliWindow, "titlebar.title")
  titleBar.text = CLIWindowType
 
 
               
.


method GetCLIWindow(CLIWindowType as String) as NodeRef of Class E_GUICLIWindow
    return FindGUIControlByName( None, "E_GUICLIWindow" + CLIWindowType)
.


« Last Edit: Aug 19, 13, 08:37:16 AM by AWW_boss »
Logged

AWW_boss

  • General Accounts
  • *
  • Posts: 846
  • gdfgd
    • View Profile

Update Input_Command with the following piece of code:


Code: [Select]

function onCmdStop(cmd as String) as Boolean

...

    is "CLIWindow"
      $CHAT.OpenCLIWindow("Tutorial")
    .

...



Some parts will probably give a compile error, you should just comment out those parts:


Code: [Select]


//    is "Chat"
//      $CHAT.OpenChatInput()
//    .
//    is "SlashChat"
//      $CHAT.OpenChatInput()
//      var box = $CHAT.GetChatInputBox()
//      box.value = "/"
//      SetCaret( box, 2, 2 )
//    .

« Last Edit: Aug 19, 13, 08:37:39 AM by AWW_boss »
Logged

AWW_boss

  • General Accounts
  • *
  • Posts: 846
  • gdfgd
    • View Profile

Last thing that remains is to update GameKeyBindings.ini:


[Command] = Input_Command
  PlayMode = CTRL+G
  HotKey1 = 1
  HotKey2 = 2
  HotKey3 = 3
  HotKey4 = 4
  HotKey5 = 5
  Chat = ENTER
  SlashChat = /
  ClearTarget = ESC
  NearestTarget = TAB
  CLIWindow = C


Keyboard letter C will bring up the chat window.


Cheers!
« Last Edit: Aug 19, 13, 08:37:58 AM by AWW_boss »
Logged

Jrome90

  • General Accounts
  • *
  • Posts: 330
    • View Profile

Solution
After some time I was able to figure out a way (Not flawless) to get this to work. Plus a couple additions. (Can be removed if desired) The way I did those additions are not the best way to do it though. (A better way is to use the newer chat system)

After following the above, make the following changes:

Create field: "displayBoxOffsetValue"
Type: integer

This field holds the value of what will eventually be the offset value for the display box.

Add the above field to the "E_GUICLIDisplayBox" Class

And Lastly, change the script for that class to:

Code: [Select]
method OnControlBuild()
  me.allowStickyBottom = true
.
method _AddTextDisplayLine(line copies String)
  add back line to me.E_GUICLIDisplayBoxLineList
  me.E_GUICLIDisplayBoxCharCounter = me.E_GUICLIDisplayBoxCharCounter + line.length + 1
  me._CullTextDisplay()
  me._RefreshTextDisplay()
.


method _CullTextDisplay ()
  while (me.E_GUICLIDisplayBoxCharCounter > 0.75 * me.maxLen)
    me.E_GUICLIDisplayBoxCharCounter = me.E_GUICLIDisplayBoxCharCounter - me.E_GUICLIDisplayBoxLineList[1].length - 1
    remove me.E_GUICLIDisplayBoxLineList at 1
  .

.


method _RefreshTextDisplay()
   
  tempvalue as String
  JoinStrings(tempvalue, me.E_GUICLIDisplayBoxLineList, "$R")

  me.value = tempvalue
 
  me.displayBoxOffsetValue = Truncate(me.area.y - me.size.y)
 
  timer as NodeRef of Class genericTimer = CreateNodeFromClass("genericTimer")
  timer.myTimer.script = SYSTEM.EXEC.THISSCRIPT
  timer.timerData = me
  timer.myTimer.fireRate = TimeInMilliseconds(1)
  timer.myTimer.start()
 
.


function myTimer_tick()
  timer as NodeRef of Class genericTimer = me
 
  displayBox as NodeRef of Class E_GUICLIDisplayBox = timer.timerData
  displayBox.offset.y = displayBox.displayBoxOffsetValue
 
  timer.myTimer.stop()
  DestroyNode(timer)
.


method onKeyDown(args references Class GUIKeyboardEvent)
  if (args.ctrl)
    if (args.keyCode = 67)
//      println ("Got ctrl-c")
    .
  .
.

Change the code in the class "E_GUICLIInputBox" to:

Code: [Select]
method OnKeyDown( args references Class GUIKeyboardEvent ) 

  when args.keyCode
    is 27  //  escape key
      SetKeyboardFocus( None )
      me.value = ""
      args.handled = true
    .
    is 13  //  enter key
      args.handled = true
      msg as String = me.value
      //  Strip leading spaces
      while FindString( msg, " " ) == 1 and msg.length > 1
        msg = SubString( msg, 2, msg.length )
      .
      if msg.length > 0
        first as String = SubString( msg, 1, 1 )
        if first == "/"
          if msg.length > 1
            SendCommand( msg )
          .
        else
          if not me.SendAsQuote(msg)
            SendChat( msg, "game" )       

          .
        .
      .
    .
  . 
.

method SendAsQuote(text as String) as Boolean
  data as List of String = me.SplitNameAndMessage(text)
  if data.length > 0
    name as String = data[1]
    message as String = data[2]
    if $CHAT.ChatNameExists(name)
      newMessage as String = "</Quote- " + name + "$R $Q" + message + "$Q" + "\>"
      SendChat(newMessage,"game")
      return true
    .
  .
  return false
.

method SplitNameAndMessage(message as String) as List of String
  if message.length > 1
    data as List of String
    name as String
    messageText as String
 
    last as Integer = FindString(message,":")
    if last > 0
      name = SubString(message,1,last-1)
      println("Name SubString:" + name)
 
      messageText = SubString(message,last+3,message.length)
      println("message SubString:" + messageText)
      add back name to data
      add back messageText to data
 
    .
    return data
 
  .
.


Change the code in the class "E_GUICLIWindow" to:

Code: [Select]
method OnControlBuild()

  me.CLIWindowRestoreState()

.



method HE_closeWindow() as Boolean
  me.CLIWindowSaveState ()
  return false
.

method CLIWindowSaveState ()

  $ACCC.E_GUILayoutSizeXLookupList[me.E_GUICLIWindowType] = me.size.x
  $ACCC.E_GUILayoutSizeYLookupList[me.E_GUICLIWindowType] = me.size.y
  $ACCC.E_GUILayoutPositionXLookupList[me.E_GUICLIWindowType] = me.position.x
  $ACCC.E_GUILayoutPositionYLookupList[me.E_GUICLIWindowType] = me.position.y
  displayBox as NodeRef of Class E_GUICLIDisplayBox = me.GetDisplayBox()
  $ACCC.E_GUICLIDisplayBoxCharCounterLookupList[me.E_GUICLIWindowType] = displayBox.E_GUICLIDisplayBoxCharCounter
  $ACCC.E_GUICLIDisplayBoxLineListLookupList[me.E_GUICLIWindowType] = displayBox.E_GUICLIDisplayBoxLineList

.

method CLIWindowRestoreState ()
 
 
  if ($ACCC.E_GUILayoutSizeXLookupList[me.E_GUICLIWindowType] <> 0) or \
    ($ACCC.E_GUILayoutSizeYLookupList[me.E_GUICLIWindowType] <> 0) or \
    ($ACCC.E_GUILayoutPositionXLookupList[me.E_GUICLIWindowType] <> 0) or \
    ($ACCC.E_GUILayoutPositionYLookupList[me.E_GUICLIWindowType] <> 0)
   
    me.size.x = $ACCC.E_GUILayoutSizeXLookupList[me.E_GUICLIWindowType]
    me.size.y = $ACCC.E_GUILayoutSizeYLookupList[me.E_GUICLIWindowType]
    me.position.x = $ACCC.E_GUILayoutPositionXLookupList[me.E_GUICLIWindowType]
    me.position.y = $ACCC.E_GUILayoutPositionYLookupList[me.E_GUICLIWindowType]
  .
 
  displayBox as NodeRef of Class E_GUICLIDisplayBox = me.GetDisplayBox()
  displayBox.E_GUICLIDisplayBoxCharCounter = $ACCC.E_GUICLIDisplayBoxCharCounterLookupList[me.E_GUICLIWindowType]
  displayBox.E_GUICLIDisplayBoxLineList = $ACCC.E_GUICLIDisplayBoxLineListLookupList[me.E_GUICLIWindowType]
 
 
  displayBox._RefreshTextDisplay()

 
.





method AddCLIMessage( message copies String, channel as String )
  displayBox as NodeRef of Class E_GUICLIDisplayBox = me.GetDisplayBox()
  displayBox._AddTextDisplayLine(message)
   
.

method GetDisplayBox() as NodeRef of Class E_GUICLIDisplayBox
  return FindGUIControlByName(me, "_spacer.E_GUICLIDisplayBoxHolder.display")
.



Create and add the following fields to the class "E_ChatHandler":

Field: chatNamesLookup
Type: Lookuplist indexed by string of string

Lookup for names of chat participants

Field: lastChatName
Type: string

name of the last player to send a message

Then make the following changes to the code in that class:

Code: [Select]
method HE_GotChatMessage( chatMessage as String, channelName as String )
  message as String = me.ProcessChatMessage(chatMessage,channelName)
  cliWindow as NodeRef of Class E_GUICLIWindow = me.GetCLIWindow("Tutorial")
  if (cliWindow <> None)
   
    me.GetCLIWindow("Tutorial").AddCLIMessage( message, channelName )
  .
 
.

method ProcessChatMessage(chatMessage as String,channelName as  String) as String
  lastChatName as String = me.GetLastChatName()
  data as List of String = me.SplitNameAndMessage(chatMessage)
  name as String = data[1]
  messageText as String = data[2]
   
  if lastChatName != name
    me.LastChatName = name
    newName  as String = "$R"+ "{f:#1,0,0,1}" + name + ":{/}" + "$R"
    messageText = newName + messageText
   
    if not( me.chatNamesLookup has name ) and me.CanStoreChatName(channelName)
      me.chatNamesLookup[name] = name
    .
  .
 
  messageText = ReplaceString(messageText,"</","{f:#0,0,1,1}")
  messageText = ReplaceString(messageText,"\>","{/}")
 
  return messageText
.
 
method SplitNameAndMessage(message as String) as List of String
  name as String
  messageText as String

  data as List of String
  SplitBy(message,":",data)
  name = data[1]
  messageText = data[2]
 
  return data
.

method GetLastChatName() as String
  return me.LastChatName
.

method ChatNameExists(name as String) as Boolean
  if $CHAT.chatNamesLookup has name
    return true
  else
    return false
  .
.

method CanStoreChatName(chatChannel as String) as Boolean
  when chatChannel
    //Only added for testing purposes
    is "game"
      return true
    .
    is "Guild"
      return true
    .
    is "PrivateChat"
      return true
    .
    default
      return false
    .
  .
 
.

method OpenCLIWindow(CLIWindowType as String)

 
  cliWindow as NodeRef of Class E_GUICLIWindow = me.GetCLIWindow("Tutorial")
  if cliWindow != None
    cliWindow.CLIWindowSaveState()
    destroynode(cliWindow)
    return
  .
 
  cliWindow = CreateNodeFromPrototype( "E_GUICLIWindow" )
  cliWindow.name = "E_GUICLIWindow" + CLIWindowType
  cliWindow.E_GUICLIWindowType = CLIWindowType
 
  cliWindow.build = true
 
  //titleBar as NodeRef of Class GUILabel = FindGUIControlByName(cliWindow, "titlebar.title")
  //titleBar.text = CLIWindowType
 
 
               
.


method GetCLIWindow(CLIWindowType as String) as NodeRef of Class E_GUICLIWindow
  return FindGUIControlByName( None, "E_GUICLIWindow" + CLIWindowType)
.

function ResetName()
  $CHAT.LastChatName = ""
.


Try: After entering something into the box: Copy the name in red, and some text. Then paste it into the box below and send it.

Known limitations:
Can't use ":" or "</" or "\>" in chat
« Last Edit: Sep 07, 13, 03:31:13 PM by Jrome90 »
Logged