src/misc_gui.cpp
changeset 9115 47ae980bace3
parent 9111 48ce04029fe4
child 9116 f2491d3c321b
equal deleted inserted replaced
9114:032218c1235b 9115:47ae980bace3
   556 			/* Switch back to the normal text ref. stack for NewGRF texts */
   556 			/* Switch back to the normal text ref. stack for NewGRF texts */
   557 			SwitchToNormalRefStack();
   557 			SwitchToNormalRefStack();
   558 			break;
   558 			break;
   559 
   559 
   560 		case WE_MOUSELOOP:
   560 		case WE_MOUSELOOP:
   561 			if (_right_button_down) DeleteWindow(w);
   561 			if (_right_button_down) delete w;
   562 			break;
   562 			break;
   563 
   563 
   564 		case WE_4:
   564 		case WE_4:
   565 			if (--_errmsg_duration == 0) DeleteWindow(w);
   565 			if (--_errmsg_duration == 0) delete w;
   566 			break;
   566 			break;
   567 
   567 
   568 		case WE_DESTROY:
   568 		case WE_DESTROY:
   569 			SetRedErrorSquare(0);
   569 			SetRedErrorSquare(0);
   570 			extern StringID _switch_mode_errorstr;
   570 			extern StringID _switch_mode_errorstr;
   573 
   573 
   574 		case WE_KEYPRESS:
   574 		case WE_KEYPRESS:
   575 			if (e->we.keypress.keycode == WKC_SPACE) {
   575 			if (e->we.keypress.keycode == WKC_SPACE) {
   576 				/* Don't continue. */
   576 				/* Don't continue. */
   577 				e->we.keypress.cont = false;
   577 				e->we.keypress.cont = false;
   578 				DeleteWindow(w);
   578 				delete w;
   579 			}
   579 			}
   580 			break;
   580 			break;
   581 	}
   581 	}
   582 }
   582 }
   583 
   583 
   709 
   709 
   710 		case WE_MOUSELOOP:
   710 		case WE_MOUSELOOP:
   711 			/* We can show tooltips while dragging tools. These are shown as long as
   711 			/* We can show tooltips while dragging tools. These are shown as long as
   712 			 * we are dragging the tool. Normal tooltips work with rmb */
   712 			 * we are dragging the tool. Normal tooltips work with rmb */
   713 			if (WP(w, tooltips_d).paramcount == 0 ) {
   713 			if (WP(w, tooltips_d).paramcount == 0 ) {
   714 				if (!_right_button_down) DeleteWindow(w);
   714 				if (!_right_button_down) delete w;
   715 			} else {
   715 			} else {
   716 				if (!_left_button_down) DeleteWindow(w);
   716 				if (!_left_button_down) delete w;
   717 			}
   717 			}
   718 
   718 
   719 			break;
   719 			break;
   720 	}
   720 	}
   721 }
   721 }
  1169 							HandleOnEditText(qs->text.buf);
  1169 							HandleOnEditText(qs->text.buf);
  1170 						}
  1170 						}
  1171 					}
  1171 					}
  1172 					/* Fallthrough */
  1172 					/* Fallthrough */
  1173 				case QUERY_STR_WIDGET_CANCEL:
  1173 				case QUERY_STR_WIDGET_CANCEL:
  1174 					DeleteWindow(w);
  1174 					delete w;
  1175 					break;
  1175 					break;
  1176 			}
  1176 			}
  1177 			break;
  1177 			break;
  1178 
  1178 
  1179 		case WE_MOUSELOOP:
  1179 		case WE_MOUSELOOP:
  1181 			break;
  1181 			break;
  1182 
  1182 
  1183 		case WE_KEYPRESS:
  1183 		case WE_KEYPRESS:
  1184 			switch (HandleEditBoxKey(w, qs, QUERY_STR_WIDGET_TEXT, e)) {
  1184 			switch (HandleEditBoxKey(w, qs, QUERY_STR_WIDGET_TEXT, e)) {
  1185 				case 1: goto press_ok; // Enter pressed, confirms change
  1185 				case 1: goto press_ok; // Enter pressed, confirms change
  1186 				case 2: DeleteWindow(w); break; // ESC pressed, closes window, abandons changes
  1186 				case 2: delete w; break; // ESC pressed, closes window, abandons changes
  1187 			}
  1187 			}
  1188 			break;
  1188 			break;
  1189 
  1189 
  1190 		case WE_DESTROY: // Call cancellation of query, if we have not handled it before
  1190 		case WE_DESTROY: // Call cancellation of query, if we have not handled it before
  1191 			if (!qs->handled && w->parent != NULL) {
  1191 			if (!qs->handled && w->parent != NULL) {
  1294 				case QUERY_WIDGET_YES:
  1294 				case QUERY_WIDGET_YES:
  1295 					q->calledback = true;
  1295 					q->calledback = true;
  1296 					if (q->proc != NULL) q->proc(w->parent, true);
  1296 					if (q->proc != NULL) q->proc(w->parent, true);
  1297 					/* Fallthrough */
  1297 					/* Fallthrough */
  1298 				case QUERY_WIDGET_NO:
  1298 				case QUERY_WIDGET_NO:
  1299 					DeleteWindow(w);
  1299 					delete w;
  1300 					break;
  1300 					break;
  1301 				}
  1301 				}
  1302 			break;
  1302 			break;
  1303 
  1303 
  1304 		case WE_KEYPRESS: // ESC closes the window, Enter confirms the action
  1304 		case WE_KEYPRESS: // ESC closes the window, Enter confirms the action
  1308 					q->calledback = true;
  1308 					q->calledback = true;
  1309 					if (q->proc != NULL) q->proc(w->parent, true);
  1309 					if (q->proc != NULL) q->proc(w->parent, true);
  1310 					/* Fallthrough */
  1310 					/* Fallthrough */
  1311 				case WKC_ESC:
  1311 				case WKC_ESC:
  1312 					e->we.keypress.cont = false;
  1312 					e->we.keypress.cont = false;
  1313 					DeleteWindow(w);
  1313 					delete w;
  1314 					break;
  1314 					break;
  1315 			}
  1315 			}
  1316 			break;
  1316 			break;
  1317 
  1317 
  1318 		case WE_DESTROY: // Call callback function (if any) on window close if not yet called
  1318 		case WE_DESTROY: // Call callback function (if any) on window close if not yet called
  1579 
  1579 
  1580 							SetFiosType(file->type);
  1580 							SetFiosType(file->type);
  1581 							ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name));
  1581 							ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name));
  1582 							ttd_strlcpy(_file_to_saveload.title, file->title, sizeof(_file_to_saveload.title));
  1582 							ttd_strlcpy(_file_to_saveload.title, file->title, sizeof(_file_to_saveload.title));
  1583 
  1583 
  1584 							DeleteWindow(w);
  1584 							delete w;
  1585 						} else if (_saveload_mode == SLD_LOAD_HEIGHTMAP) {
  1585 						} else if (_saveload_mode == SLD_LOAD_HEIGHTMAP) {
  1586 							SetFiosType(file->type);
  1586 							SetFiosType(file->type);
  1587 							ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name));
  1587 							ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name));
  1588 							ttd_strlcpy(_file_to_saveload.title, file->title, sizeof(_file_to_saveload.title));
  1588 							ttd_strlcpy(_file_to_saveload.title, file->title, sizeof(_file_to_saveload.title));
  1589 
  1589 
  1590 							DeleteWindow(w);
  1590 							delete w;
  1591 							ShowHeightmapLoad();
  1591 							ShowHeightmapLoad();
  1592 						} else {
  1592 						} else {
  1593 							/* SLD_SAVE_GAME, SLD_SAVE_SCENARIO copy clicked name to editbox */
  1593 							/* SLD_SAVE_GAME, SLD_SAVE_SCENARIO copy clicked name to editbox */
  1594 							ttd_strlcpy(WP(w, querystr_d).text.buf, file->title, WP(w, querystr_d).text.maxlength);
  1594 							ttd_strlcpy(WP(w, querystr_d).text.buf, file->title, WP(w, querystr_d).text.maxlength);
  1595 							UpdateTextBufferSize(&WP(w, querystr_d).text);
  1595 							UpdateTextBufferSize(&WP(w, querystr_d).text);
  1618 			}
  1618 			}
  1619 			break;
  1619 			break;
  1620 
  1620 
  1621 		case WE_KEYPRESS:
  1621 		case WE_KEYPRESS:
  1622 			if (e->we.keypress.keycode == WKC_ESC) {
  1622 			if (e->we.keypress.keycode == WKC_ESC) {
  1623 				DeleteWindow(w);
  1623 				delete w;
  1624 				return;
  1624 				return;
  1625 			}
  1625 			}
  1626 
  1626 
  1627 			if ((_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) &&
  1627 			if ((_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) &&
  1628 					HandleEditBoxKey(w, &WP(w, querystr_d), 10, e) == 1) { // Press Enter
  1628 					HandleEditBoxKey(w, &WP(w, querystr_d), 10, e) == 1) { // Press Enter