Wikied: GameChatBox

Forum for general chit-chat or off-topic discussion.

Moderators: CEGUI MVP, CEGUI Team

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Wikied: GameChatBox

Postby Rackle » Tue Jan 29, 2008 20:08

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.

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Sat Feb 02, 2008 19:52

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).

Rincevent
Not too shy to talk
Not too shy to talk
Posts: 22
Joined: Thu Oct 08, 2009 20:42

Re: Wikied: GameChatBox

Postby Rincevent » Sat Oct 10, 2009 13:22

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);
   }
};

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Re: Wikied: GameChatBox

Postby scriptkid » Mon Oct 12, 2009 07:32

Hi,

i have not tested it, but thanks for posting! :)
Check out my released snake game using Cegui!


Return to “Offtopic Discussion”

Who is online

Users browsing this forum: No registered users and 4 guests