File diff r25256:9aa975c3b919 → r25257:56e3bc921253
src/network/network_gui.cpp
Show inline comments
 
@@ -1746,24 +1746,25 @@ using ClientButton = Button<ClientID>;
 
 */
 
struct NetworkClientListWindow : Window {
 
private:
 
	ClientListWidgets query_widget; ///< During a query this tracks what widget caused the query.
 
	CompanyID join_company; ///< During query for company password, this stores what company we wanted to join.
 

	
 
	ClientID dd_client_id; ///< During admin dropdown, track which client this was for.
 
	CompanyID dd_company_id; ///< During admin dropdown, track which company this was for.
 

	
 
	Scrollbar *vscroll; ///< Vertical scrollbar of this window.
 
	uint line_height; ///< Current lineheight of each entry in the matrix.
 
	uint line_count; ///< Amount of lines in the matrix.
 
	int hover_index; ///< Index of the current line we are hovering over, or -1 if none.
 

	
 
	std::map<uint, std::vector<std::unique_ptr<ButtonCommon>>> buttons; ///< Per line which buttons are available.
 

	
 
	static const int CLIENT_OFFSET_LEFT = 12; ///< Offset of client entries compared to company entries.
 

	
 
	/**
 
	 * Chat button on a Company is clicked.
 
	 * @param w The instance of this window.
 
	 * @param pt The point where this button was clicked.
 
	 * @param company_id The company this button was assigned to.
 
	 */
 
	static void OnClickCompanyChat(NetworkClientListWindow *w, Point pt, CompanyID company_id)
 
@@ -2252,34 +2253,57 @@ public:
 

	
 
			y += this->line_height;
 
			line++;
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	{
 
		switch (widget) {
 
			case WID_CL_MATRIX: {
 
				uint line = 0;
 

	
 
				if (this->hover_index >= 0) {
 
					uint offset = this->hover_index * this->line_height;
 
					GfxFillRect(r.left + 2, r.top + offset, r.right - 1, r.top + offset + this->line_height - 1, GREY_SCALE(9));
 
				}
 

	
 
				for (const Company *c : Company::Iterate()) {
 
					this->DrawCompany(c, r.left, r.right, r.top, line);
 
				}
 
				/* Specators */
 
				this->DrawCompany(nullptr, r.left, r.right, r.top, line);
 

	
 
				break;
 
			}
 
		}
 
	}
 

	
 
	virtual void OnMouseLoop() override
 
	{
 
		if (GetWidgetFromPos(this, _cursor.pos.x - this->left, _cursor.pos.y - this->top) != WID_CL_MATRIX) {
 
			this->hover_index = -1;
 
			this->SetDirty();
 
			return;
 
		}
 

	
 
		NWidgetBase *nwi = this->GetWidget<NWidgetBase>(WID_CL_MATRIX);
 
		int y = _cursor.pos.y - this->top - nwi->pos_y - 2;
 
		int index = y / this->line_height;
 

	
 
		if (index != this->hover_index) {
 
			this->hover_index = index;
 
			this->SetDirty();
 
		}
 
	}
 
};
 

	
 
void ShowClientList()
 
{
 
	AllocateWindowDescFront<NetworkClientListWindow>(&_client_list_desc, 0);
 
}
 

	
 
NetworkJoinStatus _network_join_status; ///< The status of joining.
 
uint8 _network_join_waiting;            ///< The number of clients waiting in front of us.
 
uint32 _network_join_bytes;             ///< The number of bytes we already downloaded.
 
uint32 _network_join_bytes_total;       ///< The total number of bytes to download.