settings_gui.c
changeset 4211 d8c4c40eba62
parent 4196 8022df2c1328
child 4261 2ec8f5a9747b
equal deleted inserted replaced
4210:2c1a58c727ed 4211:d8c4c40eba62
   732 				DrawFrameRect(x, y, x + 19, y + 8, _bool_ctabs[!!on][!!editable], on ? FR_LOWERED : 0);
   732 				DrawFrameRect(x, y, x + 19, y + 8, _bool_ctabs[!!on][!!editable], on ? FR_LOWERED : 0);
   733 				SetDParam(0, on ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF);
   733 				SetDParam(0, on ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF);
   734 			} else {
   734 			} else {
   735 				int32 value;
   735 				int32 value;
   736 
   736 
       
   737 				value = (int32)ReadValue(var, sd->save.conv);
       
   738 
   737 				/* Draw [<][>] boxes for settings of an integer-type */
   739 				/* Draw [<][>] boxes for settings of an integer-type */
   738 				DrawArrowButtons(x, y, 3, WP(w,def_d).data_2 - (i * 2), editable);
   740 				DrawArrowButtons(x, y, 3, WP(w,def_d).data_2 - (i * 2), (editable && value != sdb->min), (editable && value != sdb->max));
   739 
       
   740 				value = (int32)ReadValue(var, sd->save.conv);
       
   741 
   741 
   742 				disabled = (value == 0) && (sdb->flags & SGF_0ISDISABLED);
   742 				disabled = (value == 0) && (sdb->flags & SGF_0ISDISABLED);
   743 				if (disabled) {
   743 				if (disabled) {
   744 					SetDParam(0, STR_CONFIG_PATCHES_DISABLED);
   744 					SetDParam(0, STR_CONFIG_PATCHES_DISABLED);
   745 				} else {
   745 				} else {
  1047 	w->vscroll.count = count;
  1047 	w->vscroll.count = count;
  1048 	w->vscroll.pos = 0;
  1048 	w->vscroll.pos = 0;
  1049 	w->disabled_state = (1 << 5) | (1 << 6) | (1 << 7);
  1049 	w->disabled_state = (1 << 5) | (1 << 6) | (1 << 7);
  1050 }
  1050 }
  1051 
  1051 
  1052 /** Draw [<][>] boxes
  1052 /**
  1053  * state: 0 = none clicked, 1 = first clicked, 2 = second clicked */
  1053  * Draw [<][>] boxes.
  1054 void DrawArrowButtons(int x, int y, int ctab, byte state, bool enabled)
  1054  * @param x the x position to draw
  1055 {
  1055  * @param y the y position to draw
  1056 	DrawFrameRect(x,    y+1, x + 9, y+9, ctab, (state == 1) ? FR_LOWERED : 0);
  1056  * @param ctab the color of the buttons
  1057 	DrawFrameRect(x+10, y+1, x +19, y+9, ctab, (state == 2) ? FR_LOWERED : 0);
  1057  * @param state 0 = none clicked, 1 = first clicked, 2 = second clicked
  1058 	DrawStringCentered(x+ 5, y+1, STR_6819, 0); // [<]
  1058  * @param clickable_left is the left button clickable?
  1059 	DrawStringCentered(x+15, y+1, STR_681A, 0); // [>]
  1059  * @param clickable_right is the right button clickable?
  1060 
  1060  */
  1061 	if (!enabled) {
  1061 void DrawArrowButtons(int x, int y, int ctab, byte state, bool clickable_left, bool clickable_right)
  1062 		int color = PALETTE_MODIFIER_GREYOUT | _color_list[3].unk2;
  1062 {
  1063 		GfxFillRect(x+ 1, y+1, x+ 1+8, y+8, color);
  1063 	int color = PALETTE_MODIFIER_GREYOUT | _color_list[3].unk2;
  1064 		GfxFillRect(x+11, y+1, x+11+8, y+8, color);
  1064 
  1065 	}
  1065 	DrawFrameRect(x,      y + 1, x +  9, y + 9, ctab, (state == 1) ? FR_LOWERED : 0);
       
  1066 	DrawFrameRect(x + 10, y + 1, x + 19, y + 9, ctab, (state == 2) ? FR_LOWERED : 0);
       
  1067 	DrawStringCentered(x +  5, y + 1, STR_6819, 0); // [<]
       
  1068 	DrawStringCentered(x + 15, y + 1, STR_681A, 0); // [>]
       
  1069 
       
  1070 	/* Grey out the buttons that aren't clickable */
       
  1071 	if (!clickable_left)
       
  1072 		GfxFillRect(x +  1, y + 1, x +  1 + 8, y + 8, color);
       
  1073 	if (!clickable_right)
       
  1074 		GfxFillRect(x + 11, y + 1, x + 11 + 8, y + 8, color);
  1066 }
  1075 }
  1067 
  1076 
  1068 static char _str_separator[2];
  1077 static char _str_separator[2];
  1069 
  1078 
  1070 static void CustCurrencyWndProc(Window *w, WindowEvent *e)
  1079 static void CustCurrencyWndProc(Window *w, WindowEvent *e)
  1074 		int x=35, y=20, i=0;
  1083 		int x=35, y=20, i=0;
  1075 		int clk = WP(w,def_d).data_1;
  1084 		int clk = WP(w,def_d).data_1;
  1076 		DrawWindowWidgets(w);
  1085 		DrawWindowWidgets(w);
  1077 
  1086 
  1078 		// exchange rate
  1087 		// exchange rate
  1079 		DrawArrowButtons(10, y, 3, (clk >> (i*2)) & 0x03, true);
  1088 		DrawArrowButtons(10, y, 3, (clk >> (i*2)) & 0x03, true, true);
  1080 		SetDParam(0, 1);
  1089 		SetDParam(0, 1);
  1081 		SetDParam(1, 1);
  1090 		SetDParam(1, 1);
  1082 		DrawString(x, y + 1, STR_CURRENCY_EXCHANGE_RATE, 0);
  1091 		DrawString(x, y + 1, STR_CURRENCY_EXCHANGE_RATE, 0);
  1083 		x = 35;
  1092 		x = 35;
  1084 		y+=12;
  1093 		y+=12;
  1107 		x = 35;
  1116 		x = 35;
  1108 		y+=12;
  1117 		y+=12;
  1109 		i++;
  1118 		i++;
  1110 
  1119 
  1111 		// switch to euro
  1120 		// switch to euro
  1112 		DrawArrowButtons(10, y, 3, (clk >> (i*2)) & 0x03, true);
  1121 		DrawArrowButtons(10, y, 3, (clk >> (i*2)) & 0x03, true, true);
  1113 		SetDParam(0, _custom_currency.to_euro);
  1122 		SetDParam(0, _custom_currency.to_euro);
  1114 		DrawString(x, y + 1, (_custom_currency.to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER, 0);
  1123 		DrawString(x, y + 1, (_custom_currency.to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER, 0);
  1115 		x = 35;
  1124 		x = 35;
  1116 		y+=12;
  1125 		y+=12;
  1117 		i++;
  1126 		i++;