Browse Source

Multiplayer: make chat history visible in lobby and improve CTextBox

Now we'll also play sound when new message added.
CTextBox::setText now will automatically change text height for slider.
ArseniyShestakov 10 years ago
parent
commit
67aa869a33
2 changed files with 4 additions and 2 deletions
  1. 3 2
      client/CPreGame.cpp
  2. 1 0
      client/widgets/TextControls.cpp

+ 3 - 2
client/CPreGame.cpp

@@ -1920,6 +1920,7 @@ CChatBox::CChatBox(const Rect &rect)
 	pos += rect;
 	addUsedEvents(KEYBOARD | TEXTINPUT);
 	captureAllKeys = true;
+	type |= REDRAW_PARENT;
 
 	const int height = graphics->fonts[FONT_SMALL]->getLineHeight();
 	inputBox = new CTextInput(Rect(0, rect.h - height, rect.w, height));
@@ -1942,6 +1943,7 @@ void CChatBox::keyPressed(const SDL_KeyboardEvent & key)
 
 void CChatBox::addNewMessage(const std::string &text)
 {
+	CCS->soundh->playSound("CHAT");
 	chatHistory->setText(chatHistory->label->text + text + "\n");
 	if(chatHistory->slider)
 		chatHistory->slider->moveToMax();
@@ -1994,8 +1996,7 @@ InfoCard::InfoCard( bool Network )
 		if(network)
 		{
 			playerListBg = new CPicture("CHATPLUG.bmp", 16, 276);
-			chat = new CChatBox(descriptionRect);
-			chat->chatHistory->addChild(new CPicture(*bg, chat->chatHistory->pos - pos), true); //move subpicture bg to our description control (by default it's our (Infocard) child)
+			chat = new CChatBox(Rect(26, 132, 340, 132));
 
 			chatOn = true;
 			mapDescription->disable();

+ 1 - 0
client/widgets/TextControls.cpp

@@ -292,6 +292,7 @@ void CTextBox::setText(const std::string &text)
 		// decrease width again if slider still used
 		label->pos.w = pos.w - 32;
 		label->setText(text);
+		slider->setAmount(label->textSize.y);
 	}
 	else if(label->textSize.y > label->pos.h)
 	{