浏览代码

Merge pull request #61 from ArseniyShestakov/fixMapDescription

Fixes for two visual map description bugs
Ivan Savenko 11 年之前
父节点
当前提交
2dd5145796
共有 4 个文件被更改,包括 18 次插入3 次删除
  1. 4 0
      client/CPreGame.cpp
  2. 5 0
      client/widgets/Buttons.cpp
  3. 1 0
      client/widgets/Buttons.h
  4. 8 3
      client/widgets/TextControls.cpp

+ 4 - 0
client/CPreGame.cpp

@@ -2171,6 +2171,10 @@ void InfoCard::changeSelection( const CMapInfo *to )
 		else
 			mapDescription->setText(to->mapHeader->description);
 
+		mapDescription->label->scrollTextTo(0);
+		if (mapDescription->slider)
+			mapDescription->slider->moveToMin();
+
 		if(SEL->screenType != CMenuScreen::newGame && SEL->screenType != CMenuScreen::campaignList) {
 			//difficulty->block(true);
 			difficulty->setSelected(SEL->sInfo.difficulty);

+ 5 - 0
client/widgets/Buttons.cpp

@@ -744,6 +744,11 @@ void CSlider::keyPressed(const SDL_KeyboardEvent & key)
 	moveTo(moveDest);
 }
 
+void CSlider::moveToMin()
+{
+	moveTo(0);
+}
+
 void CSlider::moveToMax()
 {
 	moveTo(amount);

+ 1 - 0
client/widgets/Buttons.h

@@ -230,6 +230,7 @@ public:
 	void moveRight();
 	void moveTo(int value);
 	void moveBy(int amount);
+	void moveToMin();
 	void moveToMax();
 
 	/// Amount modifier

+ 8 - 3
client/widgets/TextControls.cpp

@@ -280,15 +280,20 @@ void CTextBox::resize(Point newSize)
 
 void CTextBox::setText(const std::string &text)
 {
+	label->pos.w = pos.w; // reset to default before textSize.y check
 	label->setText(text);
-	if (label->textSize.y <= label->pos.h && slider)
+	if(label->textSize.y <= label->pos.h && slider)
 	{
 		// slider is no longer needed
 		vstd::clear_pointer(slider);
-		label->pos.w = pos.w;
+	}
+	else if(slider)
+	{
+		// decrease width again if slider still used
+		label->pos.w = pos.w - 32;
 		label->setText(text);
 	}
-	else if (label->textSize.y > label->pos.h && !slider)
+	else if(label->textSize.y > label->pos.h)
 	{
 		// create slider and update widget
 		label->pos.w = pos.w - 32;