瀏覽代碼

extend for all selections

Laserlicht 2 年之前
父節點
當前提交
39838fdd3c
共有 2 個文件被更改,包括 8 次插入0 次删除
  1. 7 0
      client/windows/InfoWindows.cpp
  2. 1 0
      client/windows/InfoWindows.h

+ 7 - 0
client/windows/InfoWindows.cpp

@@ -106,6 +106,7 @@ CSelWindow::CSelWindow(const std::string &Text, PlayerColor player, int charperl
 		addChild(comps[i].get());
 		components.push_back(comps[i]);
 		comps[i]->onSelect = std::bind(&CSelWindow::selectionChange,this,i);
+		comps[i]->onChoose = std::bind(&CSelWindow::madeChoiceAndClose,this);
 		if(i<8)
 			comps[i]->assignedKey = vstd::next(EShortcut::SELECT_INDEX_1,i);
 	}
@@ -127,6 +128,12 @@ void CSelWindow::madeChoice()
 	LOCPLINT->cb->selectionMade(ret+1,ID);
 }
 
+void CSelWindow::madeChoiceAndClose()
+{
+	madeChoice();
+	close();
+}
+
 CInfoWindow::CInfoWindow(std::string Text, PlayerColor player, const TCompsInfo & comps, const TButtonsInfo & Buttons)
 {
 	OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);

+ 1 - 0
client/windows/InfoWindows.h

@@ -130,6 +130,7 @@ class CSelWindow : public CInfoWindow
 public:
 	void selectionChange(unsigned to);
 	void madeChoice(); //looks for selected component and calls callback
+	void madeChoiceAndClose();
 	CSelWindow(const std::string & text, PlayerColor player, int charperline, const std::vector<std::shared_ptr<CSelectableComponent>> & comps, const std::vector<std::pair<AnimationPath,CFunctionList<void()> > > &Buttons, QueryID askID);
 
 	//notification - this class inherits important destructor from CInfoWindow