Page 1 of 1

Wikied: GameChatBox

Posted: Tue Jan 29, 2008 20:08
by Rackle
I've expanded the GameChatBox code posted by Tonyhnz to include the following features:
  • Support for multiple fonts
  • Height of the chat text Editbox is determined by the active font
  • Ability to limit the number of entries (history size)


The next improvement would be to create a new Listbox item that could display multiple lines of text, which would prevent the Listbox from displaying a horizontal scrollbar.

Posted: Sat Feb 02, 2008 19:52
by Rackle
Incorporated DynamicFont as well as a little panel to control the size of the history, the font size, and the font name. It's quite fun to use the Spinner to increase the font size and see the chat text take up more and more room and the chat history shrink to accordingly.

Another fun feature could be the addition of chat tabs. These are useful when there are multiple channels of communication and each tab displays the contents of some of these channels. However I'd like to program those chat tabs such that if a tab is dragged out a new chat window is created, and moving that external chat window on top of another chat window merges them, with the moved window's contents appearing as tabs in the window receiving it (I hope I'm clear).

Re: Wikied: GameChatBox

Posted: Sat Oct 10, 2009 13:22
by Rincevent
Hi,

I am using your chatbox and I was trying to integrate the word wrapping to the listbox because I was really hating this horizontal scrollbar.
I have seen multiple post about word wrapping with listbox but never found a proper solution so I decided to implement it by myself.
I think I now managed to get the result I wanted by creating my own listboxitem. Here is the code I created, hope this help:

Code: Select all

class LeftWrappedListItem : public CEGUI::ListboxTextItem
{
private:
   CEGUI::FormattedRenderedString * d_formattedRenderedString;

public:
   //! constructor
    LeftWrappedListItem (const CEGUI::String& text)
      : CEGUI::ListboxTextItem(text)
    {
        d_formattedRenderedString =
            new CEGUI::RenderedStringWordWrapper
                <CEGUI::LeftAlignedRenderedString>(d_renderedString);
    }

   //! destructor
    ~LeftWrappedListItem ()
    {
        delete d_formattedRenderedString;
    }

   /*************************************************************************
      Required implementations of pure virtuals from the base class.
   *************************************************************************/
    CEGUI::Size getPixelSize(void) const
   {
      using namespace CEGUI;

      if (!d_renderedStringValid)
         parseTextString();

      CEGUI::Size parentsi = getOwnerWindow()->getInnerRectClipper().getSize();
      parentsi.d_width -= 20; // TODO - change constant by the real value of the scrollbar
      
        d_formattedRenderedString->format(parentsi);
      return CEGUI::Size(parentsi.d_width, d_formattedRenderedString->getVerticalExtent());
   }


    void draw(CEGUI::GeometryBuffer& buffer, const CEGUI::Rect& targetRect, float alpha,
               const CEGUI::Rect* clipper) const
   {
      using namespace CEGUI;

      if (!d_renderedStringValid)
         parseTextString();

        d_formattedRenderedString->format(targetRect.getSize());

      const ColourRect final_colours(
         getModulateAlphaColourRect(ColourRect(0xFFFFFFFF), alpha));

        d_formattedRenderedString->draw(buffer,
                                        targetRect.getPosition(),                           
                              &final_colours, clipper);
   }
};

Re: Wikied: GameChatBox

Posted: Mon Oct 12, 2009 07:32
by scriptkid
Hi,

i have not tested it, but thanks for posting! :)