src/settings_gui.cpp
changeset 9871 57a332d08e74
parent 9793 359d2460833b
child 9872 cd31ad87666e
equal deleted inserted replaced
9870:0aade3ddf995 9871:57a332d08e74
   459 		for (i = 0; i < GAME_DIFFICULTY_NUM; i++, sd++) {
   459 		for (i = 0; i < GAME_DIFFICULTY_NUM; i++, sd++) {
   460 			const SettingDescBase *sdb = &sd->desc;
   460 			const SettingDescBase *sdb = &sd->desc;
   461 			int32 value = (int32)ReadValue(GetVariableAddress(&this->opt_mod_temp, &sd->save), sd->save.conv);
   461 			int32 value = (int32)ReadValue(GetVariableAddress(&this->opt_mod_temp, &sd->save), sd->save.conv);
   462 			bool editable = (_game_mode == GM_MENU || (sdb->flags & SGF_NEWGAME_ONLY) == 0);
   462 			bool editable = (_game_mode == GM_MENU || (sdb->flags & SGF_NEWGAME_ONLY) == 0);
   463 
   463 
   464 			DrawArrowButtons(5, y, 3,
   464 			DrawArrowButtons(5, y, COLOUR_YELLOW,
   465 					(this->clicked_button == i) ? 1 + !!this->clicked_increase : 0,
   465 					(this->clicked_button == i) ? 1 + !!this->clicked_increase : 0,
   466 					editable && sdb->min != value,
   466 					editable && sdb->min != value,
   467 					editable && sdb->max != value);
   467 					editable && sdb->max != value);
   468 
   468 
   469 			value += sdb->str;
   469 			value += sdb->str;
   821 				int32 value;
   821 				int32 value;
   822 
   822 
   823 				value = (int32)ReadValue(var, sd->save.conv);
   823 				value = (int32)ReadValue(var, sd->save.conv);
   824 
   824 
   825 				/* Draw [<][>] boxes for settings of an integer-type */
   825 				/* Draw [<][>] boxes for settings of an integer-type */
   826 				DrawArrowButtons(x, y, 3, this->click - (i * 2), (editable && value != sdb->min), (editable && value != sdb->max));
   826 				DrawArrowButtons(x, y, COLOUR_YELLOW, this->click - (i * 2), (editable && value != sdb->min), (editable && value != sdb->max));
   827 
   827 
   828 				disabled = (value == 0) && (sdb->flags & SGF_0ISDISABLED);
   828 				disabled = (value == 0) && (sdb->flags & SGF_0ISDISABLED);
   829 				if (disabled) {
   829 				if (disabled) {
   830 					SetDParam(0, STR_CONFIG_PATCHES_DISABLED);
   830 					SetDParam(0, STR_CONFIG_PATCHES_DISABLED);
   831 				} else {
   831 				} else {
   999 
   999 
  1000 /**
  1000 /**
  1001  * Draw [<][>] boxes.
  1001  * Draw [<][>] boxes.
  1002  * @param x the x position to draw
  1002  * @param x the x position to draw
  1003  * @param y the y position to draw
  1003  * @param y the y position to draw
  1004  * @param ctab the color of the buttons
  1004  * @param button_colour the colour of the button
  1005  * @param state 0 = none clicked, 1 = first clicked, 2 = second clicked
  1005  * @param state 0 = none clicked, 1 = first clicked, 2 = second clicked
  1006  * @param clickable_left is the left button clickable?
  1006  * @param clickable_left is the left button clickable?
  1007  * @param clickable_right is the right button clickable?
  1007  * @param clickable_right is the right button clickable?
  1008  */
  1008  */
  1009 void DrawArrowButtons(int x, int y, int ctab, byte state, bool clickable_left, bool clickable_right)
  1009 void DrawArrowButtons(int x, int y, Colours c, byte state, bool clickable_left, bool clickable_right)
  1010 {
  1010 {
  1011 	int color = _colour_gradient[COLOUR_YELLOW][2];
  1011 	int colour = _colour_gradient[COLOUR_YELLOW][2];
  1012 
  1012 
  1013 	DrawFrameRect(x,      y + 1, x +  9, y + 9, ctab, (state == 1) ? FR_LOWERED : FR_NONE);
  1013 	DrawFrameRect(x,      y + 1, x +  9, y + 9, button_colour, (state == 1) ? FR_LOWERED : FR_NONE);
  1014 	DrawFrameRect(x + 10, y + 1, x + 19, y + 9, ctab, (state == 2) ? FR_LOWERED : FR_NONE);
  1014 	DrawFrameRect(x + 10, y + 1, x + 19, y + 9, button_colour, (state == 2) ? FR_LOWERED : FR_NONE);
  1015 	DrawStringCentered(x +  5, y + 1, STR_6819, TC_FROMSTRING); // [<]
  1015 	DrawStringCentered(x +  5, y + 1, STR_6819, TC_FROMSTRING); // [<]
  1016 	DrawStringCentered(x + 15, y + 1, STR_681A, TC_FROMSTRING); // [>]
  1016 	DrawStringCentered(x + 15, y + 1, STR_681A, TC_FROMSTRING); // [>]
  1017 
  1017 
  1018 	/* Grey out the buttons that aren't clickable */
  1018 	/* Grey out the buttons that aren't clickable */
  1019 	if (!clickable_left)
  1019 	if (!clickable_left)
  1020 		GfxFillRect(x +  1, y + 1, x +  1 + 8, y + 8, color, FILLRECT_CHECKER);
  1020 		GfxFillRect(x +  1, y + 1, x +  1 + 8, y + 8, colour, FILLRECT_CHECKER);
  1021 	if (!clickable_right)
  1021 	if (!clickable_right)
  1022 		GfxFillRect(x + 11, y + 1, x + 11 + 8, y + 8, color, FILLRECT_CHECKER);
  1022 		GfxFillRect(x + 11, y + 1, x + 11 + 8, y + 8, color, FILLRECT_CHECKER);
  1023 }
  1023 }
  1024 
  1024 
  1025 /** These are not, strickly speaking, widget enums,
  1025 /** These are not, strickly speaking, widget enums,
  1050 		int x;
  1050 		int x;
  1051 		int y = 20;
  1051 		int y = 20;
  1052 		this->DrawWidgets();
  1052 		this->DrawWidgets();
  1053 
  1053 
  1054 		/* exchange rate */
  1054 		/* exchange rate */
  1055 		DrawArrowButtons(10, y, 3, GB(this->click, 0, 2), true, true);
  1055 		DrawArrowButtons(10, y, COLOUR_YELLOW, GB(this->click, 0, 2), true, true);
  1056 		SetDParam(0, 1);
  1056 		SetDParam(0, 1);
  1057 		SetDParam(1, 1);
  1057 		SetDParam(1, 1);
  1058 		DrawString(35, y + 1, STR_CURRENCY_EXCHANGE_RATE, TC_FROMSTRING);
  1058 		DrawString(35, y + 1, STR_CURRENCY_EXCHANGE_RATE, TC_FROMSTRING);
  1059 		y += 12;
  1059 		y += 12;
  1060 
  1060 
  1075 		x = DrawString(35, y + 1, STR_CURRENCY_SUFFIX, TC_FROMSTRING);
  1075 		x = DrawString(35, y + 1, STR_CURRENCY_SUFFIX, TC_FROMSTRING);
  1076 		DoDrawString(_custom_currency.suffix, x + 4, y + 1, TC_ORANGE);
  1076 		DoDrawString(_custom_currency.suffix, x + 4, y + 1, TC_ORANGE);
  1077 		y += 12;
  1077 		y += 12;
  1078 
  1078 
  1079 		/* switch to euro */
  1079 		/* switch to euro */
  1080 		DrawArrowButtons(10, y, 3, GB(this->click, 8, 2), true, true);
  1080 		DrawArrowButtons(10, y, COLOUR_YELLOW, GB(this->click, 8, 2), true, true);
  1081 		SetDParam(0, _custom_currency.to_euro);
  1081 		SetDParam(0, _custom_currency.to_euro);
  1082 		DrawString(35, y + 1, (_custom_currency.to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER, TC_FROMSTRING);
  1082 		DrawString(35, y + 1, (_custom_currency.to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER, TC_FROMSTRING);
  1083 		y += 12;
  1083 		y += 12;
  1084 
  1084 
  1085 		/* Preview */
  1085 		/* Preview */