src/settings_gui.cpp
changeset 8418 b49fc6be1ab9
parent 8397 81b06437cfab
child 8424 4a488a90ccab
equal deleted inserted replaced
8417:9acf7ac0368a 8418:b49fc6be1ab9
   427 	if (_opt_newgame.diff_level != 3) {
   427 	if (_opt_newgame.diff_level != 3) {
   428 		SetDifficultyLevel(_opt_newgame.diff_level, &_opt_newgame);
   428 		SetDifficultyLevel(_opt_newgame.diff_level, &_opt_newgame);
   429 	} else {
   429 	} else {
   430 		for (uint i = 0; i < GAME_DIFFICULTY_NUM; i++) {
   430 		for (uint i = 0; i < GAME_DIFFICULTY_NUM; i++) {
   431 			GDType *diff = ((GDType*)&_opt_newgame.diff) + i;
   431 			GDType *diff = ((GDType*)&_opt_newgame.diff) + i;
   432 			*diff = clamp(*diff, _game_setting_info[i].min, _game_setting_info[i].max);
   432 			*diff = Clamp(*diff, _game_setting_info[i].min, _game_setting_info[i].max);
   433 			*diff -= *diff % _game_setting_info[i].step;
   433 			*diff -= *diff % _game_setting_info[i].step;
   434 		}
   434 		}
   435 	}
   435 	}
   436 }
   436 }
   437 
   437 
  1147 							_custom_currency.to_euro = (_custom_currency.to_euro <= 2000) ?
  1147 							_custom_currency.to_euro = (_custom_currency.to_euro <= 2000) ?
  1148 								CF_NOEURO : _custom_currency.to_euro - 1;
  1148 								CF_NOEURO : _custom_currency.to_euro - 1;
  1149 							WP(w,def_d).data_1 = 1 << (line * 2 + 0);
  1149 							WP(w,def_d).data_1 = 1 << (line * 2 + 0);
  1150 						} else {
  1150 						} else {
  1151 							_custom_currency.to_euro =
  1151 							_custom_currency.to_euro =
  1152 								clamp(_custom_currency.to_euro + 1, 2000, MAX_YEAR);
  1152 								Clamp(_custom_currency.to_euro + 1, 2000, MAX_YEAR);
  1153 							WP(w,def_d).data_1 = 1 << (line * 2 + 1);
  1153 							WP(w,def_d).data_1 = 1 << (line * 2 + 1);
  1154 						}
  1154 						}
  1155 					} else { // enter text
  1155 					} else { // enter text
  1156 						SetDParam(0, _custom_currency.to_euro);
  1156 						SetDParam(0, _custom_currency.to_euro);
  1157 						str = STR_CONFIG_PATCHES_INT32;
  1157 						str = STR_CONFIG_PATCHES_INT32;
  1174 		case WE_ON_EDIT_TEXT: {
  1174 		case WE_ON_EDIT_TEXT: {
  1175 				const char *b = e->we.edittext.str;
  1175 				const char *b = e->we.edittext.str;
  1176 
  1176 
  1177 				switch (WP(w,def_d).data_2) {
  1177 				switch (WP(w,def_d).data_2) {
  1178 					case 0: /* Exchange rate */
  1178 					case 0: /* Exchange rate */
  1179 						_custom_currency.rate = clamp(atoi(b), 1, 5000);
  1179 						_custom_currency.rate = Clamp(atoi(b), 1, 5000);
  1180 						break;
  1180 						break;
  1181 
  1181 
  1182 					case 1: /* Thousands seperator */
  1182 					case 1: /* Thousands seperator */
  1183 						_custom_currency.separator = (b[0] == '\0') ? ' ' : b[0];
  1183 						_custom_currency.separator = (b[0] == '\0') ? ' ' : b[0];
  1184 						ttd_strlcpy(_str_separator, b, lengthof(_str_separator));
  1184 						ttd_strlcpy(_str_separator, b, lengthof(_str_separator));