src/bridge_gui.cpp
changeset 11036 5e6aacb99732
parent 10979 13c4100d8757
equal deleted inserted replaced
11035:e1ee65151624 11036:5e6aacb99732
    58 };
    58 };
    59 
    59 
    60 class BuildBridgeWindow : public Window {
    60 class BuildBridgeWindow : public Window {
    61 private:
    61 private:
    62 	/* Runtime saved values */
    62 	/* Runtime saved values */
    63 	static uint last_size;
    63 	static uint16 last_size;
    64 	static Listing last_sorting;
    64 	static Listing last_sorting;
    65 
    65 
    66 	/* Constants for sorting the bridges */
    66 	/* Constants for sorting the bridges */
    67 	static const StringID sorter_names[];
    67 	static const StringID sorter_names[];
    68 	static GUIBridgeList::SortFunction *const sorter_funcs[];
    68 	static GUIBridgeList::SortFunction *const sorter_funcs[];
   130 
   130 
   131 		if (this->last_size <= 4) {
   131 		if (this->last_size <= 4) {
   132 			this->vscroll.cap = 4;
   132 			this->vscroll.cap = 4;
   133 		} else {
   133 		} else {
   134 			/* Resize the bridge selection window if we used a bigger one the last time */
   134 			/* Resize the bridge selection window if we used a bigger one the last time */
   135 			this->vscroll.cap = (this->vscroll.count > this->last_size) ? this->last_size : this->vscroll.count;
   135 			this->vscroll.cap = min(this->last_size, this->vscroll.count);
   136 			ResizeWindow(this, 0, (this->vscroll.cap - 4) * this->resize.step_height);
   136 			ResizeWindow(this, 0, (this->vscroll.cap - 4) * this->resize.step_height);
   137 			this->widget[BBSW_BRIDGE_LIST].data = (this->vscroll.cap << 8) + 1;
       
   138 		}
   137 		}
   139 
   138 
   140 		this->FindWindowPlacementAndResize(desc);
   139 		this->FindWindowPlacementAndResize(desc);
   141 	}
   140 	}
   142 
   141 
   220 	{
   219 	{
   221 		this->vscroll.cap += delta.y / (int)this->resize.step_height;
   220 		this->vscroll.cap += delta.y / (int)this->resize.step_height;
   222 		this->widget[BBSW_BRIDGE_LIST].data = (this->vscroll.cap << 8) + 1;
   221 		this->widget[BBSW_BRIDGE_LIST].data = (this->vscroll.cap << 8) + 1;
   223 		SetVScrollCount(this, this->bridges->Length());
   222 		SetVScrollCount(this, this->bridges->Length());
   224 
   223 
   225 		this->last_size = this->vscroll.cap;
   224 		this->last_size = max(this->vscroll.cap, this->last_size);
   226 	}
   225 	}
   227 };
   226 };
   228 
   227 
   229 /* Set the default size of the Build Bridge Window */
   228 /* Set the default size of the Build Bridge Window */
   230 uint BuildBridgeWindow::last_size = 4;
   229 uint16 BuildBridgeWindow::last_size = 4;
   231 /* Set the default sorting for the bridges */
   230 /* Set the default sorting for the bridges */
   232 Listing BuildBridgeWindow::last_sorting = {false, 0};
   231 Listing BuildBridgeWindow::last_sorting = {false, 0};
   233 
   232 
   234 /* Availible bridge sorting functions */
   233 /* Availible bridge sorting functions */
   235 GUIBridgeList::SortFunction* const BuildBridgeWindow::sorter_funcs[] = {
   234 GUIBridgeList::SortFunction* const BuildBridgeWindow::sorter_funcs[] = {