Преглед изворни кода

Fixed sorting maps breaking after multiple clicks in succession

Ivan Savenko пре 2 година
родитељ
комит
4fd5a2b3ea
2 измењених фајлова са 16 додато и 4 уклоњено
  1. 13 2
      client/lobby/SelectionTab.cpp
  2. 3 2
      client/lobby/SelectionTab.h

+ 13 - 2
client/lobby/SelectionTab.cpp

@@ -457,10 +457,21 @@ void SelectionTab::updateListItems()
 	}
 }
 
-int SelectionTab::getLine()
+bool SelectionTab::receiveEvent(const Point & position, int eventType) const
+{
+	// FIXME: widget should instead have well-defined pos so events will be filtered using standard routine
+	return getLine(position) != -1;
+}
+
+int SelectionTab::getLine() const
 {
-	int line = -1;
 	Point clickPos = GH.getCursorPosition() - pos.topLeft();
+	return getLine(clickPos);
+}
+
+int SelectionTab::getLine(const Point & clickPos) const
+{
+	int line = -1;
 
 	// Ignore clicks on save name area
 	int maxPosY;

+ 3 - 2
client/lobby/SelectionTab.h

@@ -67,8 +67,8 @@ public:
 
 	void clickLeft(tribool down, bool previousState) override;
 	void keyPressed(EShortcut key) override;
-
 	void clickDouble() override;
+	bool receiveEvent(const Point & position, int eventType) const override;
 
 	void filter(int size, bool selectFirst = false); //0 - all
 	void sortBy(int criteria);
@@ -77,7 +77,8 @@ public:
 	void selectAbs(int position); //position: absolute position in curItems vector
 	void sliderMove(int slidPos);
 	void updateListItems();
-	int getLine();
+	int getLine() const;
+	int getLine(const Point & position) const;
 	void selectFileName(std::string fname);
 	std::shared_ptr<CMapInfo> getSelectedMapInfo() const;
 	void rememberCurrentSelection();