src/industry_gui.cpp
changeset 9116 f2491d3c321b
parent 9111 48ce04029fe4
child 9127 14f21c5954ee
equal deleted inserted replaced
9115:47ae980bace3 9116:f2491d3c321b
   267 					if (y >= 0 && y < _fund_gui.count) { // Is it within the boundaries of available data?
   267 					if (y >= 0 && y < _fund_gui.count) { // Is it within the boundaries of available data?
   268 						WP(w, fnd_d).index = y;
   268 						WP(w, fnd_d).index = y;
   269 						WP(w, fnd_d).select = _fund_gui.index[WP(w, fnd_d).index];
   269 						WP(w, fnd_d).select = _fund_gui.index[WP(w, fnd_d).index];
   270 						indsp = (WP(w, fnd_d).select == INVALID_INDUSTRYTYPE) ? NULL : GetIndustrySpec(WP(w, fnd_d).select);
   270 						indsp = (WP(w, fnd_d).select == INVALID_INDUSTRYTYPE) ? NULL : GetIndustrySpec(WP(w, fnd_d).select);
   271 
   271 
   272 						SetWindowDirty(w);
   272 						w->SetDirty();
   273 
   273 
   274 						if ((_game_mode != GM_EDITOR && _patches.raw_industry_construction == 2 && indsp != NULL && indsp->IsRawIndustry()) ||
   274 						if ((_game_mode != GM_EDITOR && _patches.raw_industry_construction == 2 && indsp != NULL && indsp->IsRawIndustry()) ||
   275 								WP(w, fnd_d).select == INVALID_INDUSTRYTYPE) {
   275 								WP(w, fnd_d).select == INVALID_INDUSTRYTYPE) {
   276 							/* Reset the button state if going to prospecting or "build many industries" */
   276 							/* Reset the button state if going to prospecting or "build many industries" */
   277 							w->RaiseButtons();
   277 							w->RaiseButtons();
   355 					bool call_back_result = CheckIfCallBackAllowsAvailability(WP(w, fnd_d).select, IACT_USERCREATION);
   355 					bool call_back_result = CheckIfCallBackAllowsAvailability(WP(w, fnd_d).select, IACT_USERCREATION);
   356 
   356 
   357 					/* Only if result does match the previous state would it require a redraw. */
   357 					/* Only if result does match the previous state would it require a redraw. */
   358 					if (call_back_result != _fund_gui.enabled[WP(w, fnd_d).index]) {
   358 					if (call_back_result != _fund_gui.enabled[WP(w, fnd_d).index]) {
   359 						_fund_gui.enabled[WP(w, fnd_d).index] = call_back_result;
   359 						_fund_gui.enabled[WP(w, fnd_d).index] = call_back_result;
   360 						SetWindowDirty(w);
   360 						w->SetDirty();
   361 					}
   361 					}
   362 				}
   362 				}
   363 			}
   363 			}
   364 			break;
   364 			break;
   365 
   365 
   522 					}
   522 					}
   523 				}
   523 				}
   524 			}
   524 			}
   525 
   525 
   526 			if (y > w->widget[IVW_INFO].bottom) {
   526 			if (y > w->widget[IVW_INFO].bottom) {
   527 				SetWindowDirty(w);
   527 				w->SetDirty();
   528 				ResizeWindowForWidget(w, IVW_INFO, 0, y - w->widget[IVW_INFO].top);
   528 				ResizeWindowForWidget(w, IVW_INFO, 0, y - w->widget[IVW_INFO].top);
   529 				SetWindowDirty(w);
   529 				w->SetDirty();
   530 				return;
   530 				return;
   531 			}
   531 			}
   532 
   532 
   533 			DrawWindowViewport(w);
   533 			DrawWindowViewport(w);
   534 		} break;
   534 		} break;
   558 								if (IsProductionMaximum(i, line)) return;
   558 								if (IsProductionMaximum(i, line)) return;
   559 								i->production_rate[line] = minu(new_prod, 255);
   559 								i->production_rate[line] = minu(new_prod, 255);
   560 							}
   560 							}
   561 
   561 
   562 							UpdateIndustryProduction(i);
   562 							UpdateIndustryProduction(i);
   563 							SetWindowDirty(w);
   563 							w->SetDirty();
   564 							w->flags4 |= 5 << WF_TIMEOUT_SHL;
   564 							w->flags4 |= 5 << WF_TIMEOUT_SHL;
   565 							WP(w, indview_d).clicked_line = line + 1;
   565 							WP(w, indview_d).clicked_line = line + 1;
   566 							WP(w, indview_d).clicked_button = (x < 15 ? 1 : 2);
   566 							WP(w, indview_d).clicked_button = (x < 15 ? 1 : 2);
   567 						} else if (IsInsideMM(x, 34, 160)) {
   567 						} else if (IsInsideMM(x, 34, 160)) {
   568 							/* clicked the text */
   568 							/* clicked the text */
   585 		} break;
   585 		} break;
   586 
   586 
   587 		case WE_TIMEOUT:
   587 		case WE_TIMEOUT:
   588 			WP(w, indview_d).clicked_line = 0;
   588 			WP(w, indview_d).clicked_line = 0;
   589 			WP(w, indview_d).clicked_button = 0;
   589 			WP(w, indview_d).clicked_button = 0;
   590 			SetWindowDirty(w);
   590 			w->SetDirty();
   591 			break;
   591 			break;
   592 
   592 
   593 		case WE_ON_EDIT_TEXT:
   593 		case WE_ON_EDIT_TEXT:
   594 			if (e->we.edittext.str[0] != '\0') {
   594 			if (e->we.edittext.str[0] != '\0') {
   595 				Industry* i = GetIndustry(w->window_number);
   595 				Industry* i = GetIndustry(w->window_number);
   596 				int line = WP(w, indview_d).editbox_line;
   596 				int line = WP(w, indview_d).editbox_line;
   597 
   597 
   598 				i->production_rate[line] = ClampU(atoi(e->we.edittext.str), 0, 255);
   598 				i->production_rate[line] = ClampU(atoi(e->we.edittext.str), 0, 255);
   599 				UpdateIndustryProduction(i);
   599 				UpdateIndustryProduction(i);
   600 				SetWindowDirty(w);
   600 				w->SetDirty();
   601 			}
   601 			}
   602 	}
   602 	}
   603 }
   603 }
   604 
   604 
   605 static void UpdateIndustryProduction(Industry *i)
   605 static void UpdateIndustryProduction(Industry *i)
   840 		case WE_CLICK:
   840 		case WE_CLICK:
   841 			switch (e->we.click.widget) {
   841 			switch (e->we.click.widget) {
   842 				case IDW_SORTBYNAME: {
   842 				case IDW_SORTBYNAME: {
   843 					_industry_sort_order = _industry_sort_order == 0 ? 1 : 0;
   843 					_industry_sort_order = _industry_sort_order == 0 ? 1 : 0;
   844 					_industry_sort_dirty = true;
   844 					_industry_sort_dirty = true;
   845 					SetWindowDirty(w);
   845 					w->SetDirty();
   846 				} break;
   846 				} break;
   847 
   847 
   848 				case IDW_SORTBYTYPE: {
   848 				case IDW_SORTBYTYPE: {
   849 					_industry_sort_order = _industry_sort_order == 2 ? 3 : 2;
   849 					_industry_sort_order = _industry_sort_order == 2 ? 3 : 2;
   850 					_industry_sort_dirty = true;
   850 					_industry_sort_dirty = true;
   851 					SetWindowDirty(w);
   851 					w->SetDirty();
   852 				} break;
   852 				} break;
   853 
   853 
   854 				case IDW_SORTBYPROD: {
   854 				case IDW_SORTBYPROD: {
   855 					_industry_sort_order = _industry_sort_order == 4 ? 5 : 4;
   855 					_industry_sort_order = _industry_sort_order == 4 ? 5 : 4;
   856 					_industry_sort_dirty = true;
   856 					_industry_sort_dirty = true;
   857 					SetWindowDirty(w);
   857 					w->SetDirty();
   858 				} break;
   858 				} break;
   859 
   859 
   860 				case IDW_SORTBYTRANSPORT: {
   860 				case IDW_SORTBYTRANSPORT: {
   861 					_industry_sort_order = _industry_sort_order == 6 ? 7 : 6;
   861 					_industry_sort_order = _industry_sort_order == 6 ? 7 : 6;
   862 					_industry_sort_dirty = true;
   862 					_industry_sort_dirty = true;
   863 					SetWindowDirty(w);
   863 					w->SetDirty();
   864 				} break;
   864 				} break;
   865 
   865 
   866 				case IDW_INDUSRTY_LIST: {
   866 				case IDW_INDUSRTY_LIST: {
   867 					int y = (e->we.click.pt.y - 28) / 10;
   867 					int y = (e->we.click.pt.y - 28) / 10;
   868 					uint16 p;
   868 					uint16 p;
   879 				} break;
   879 				} break;
   880 			}
   880 			}
   881 			break;
   881 			break;
   882 
   882 
   883 		case WE_4:
   883 		case WE_4:
   884 			SetWindowDirty(w);
   884 			w->SetDirty();
   885 			break;
   885 			break;
   886 
   886 
   887 		case WE_RESIZE:
   887 		case WE_RESIZE:
   888 			w->vscroll.cap += e->we.sizing.diff.y / 10;
   888 			w->vscroll.cap += e->we.sizing.diff.y / 10;
   889 			break;
   889 			break;
   905 
   905 
   906 	if (w != NULL) {
   906 	if (w != NULL) {
   907 		w->vscroll.cap = 16;
   907 		w->vscroll.cap = 16;
   908 		w->resize.height = w->height - 6 * 10; // minimum 10 items
   908 		w->resize.height = w->height - 6 * 10; // minimum 10 items
   909 		w->resize.step_height = 10;
   909 		w->resize.step_height = 10;
   910 		SetWindowDirty(w);
   910 		w->SetDirty();
   911 	}
   911 	}
   912 }
   912 }