841 int32 value; |
841 int32 value; |
842 |
842 |
843 value = (int32)ReadValue(var, sd->save.conv); |
843 value = (int32)ReadValue(var, sd->save.conv); |
844 |
844 |
845 /* Draw [<][>] boxes for settings of an integer-type */ |
845 /* Draw [<][>] boxes for settings of an integer-type */ |
846 DrawArrowButtons(x, y, 3, WP(w,def_d).data_2 - (i * 2), (editable && value != sdb->min), (editable && value != sdb->max)); |
846 DrawArrowButtons(x, y, 3, WP(w, def_d).data_2 - (i * 2), (editable && value != sdb->min), (editable && value != sdb->max)); |
847 |
847 |
848 disabled = (value == 0) && (sdb->flags & SGF_0ISDISABLED); |
848 disabled = (value == 0) && (sdb->flags & SGF_0ISDISABLED); |
849 if (disabled) { |
849 if (disabled) { |
850 SetDParam(0, STR_CONFIG_PATCHES_DISABLED); |
850 SetDParam(0, STR_CONFIG_PATCHES_DISABLED); |
851 } else { |
851 } else { |
925 if (value < sdb->min) value = (sdb->flags & SGF_0ISDISABLED) ? 0 : sdb->min; |
925 if (value < sdb->min) value = (sdb->flags & SGF_0ISDISABLED) ? 0 : sdb->min; |
926 } |
926 } |
927 |
927 |
928 /* Set up scroller timeout for numeric values */ |
928 /* Set up scroller timeout for numeric values */ |
929 if (value != oldvalue && !(sd->desc.flags & SGF_MULTISTRING)) { |
929 if (value != oldvalue && !(sd->desc.flags & SGF_MULTISTRING)) { |
930 WP(w,def_d).data_2 = btn * 2 + 1 + ((x >= 10) ? 1 : 0); |
930 WP(w, def_d).data_2 = btn * 2 + 1 + ((x >= 10) ? 1 : 0); |
931 w->flags4 |= 5 << WF_TIMEOUT_SHL; |
931 w->flags4 |= 5 << WF_TIMEOUT_SHL; |
932 _left_button_clicked = false; |
932 _left_button_clicked = false; |
933 } |
933 } |
934 } break; |
934 } break; |
935 default: NOT_REACHED(); |
935 default: NOT_REACHED(); |
943 /* only open editbox for types that its sensible for */ |
943 /* only open editbox for types that its sensible for */ |
944 if (sd->desc.cmd != SDT_BOOLX && !(sd->desc.flags & SGF_MULTISTRING)) { |
944 if (sd->desc.cmd != SDT_BOOLX && !(sd->desc.flags & SGF_MULTISTRING)) { |
945 /* Show the correct currency-translated value */ |
945 /* Show the correct currency-translated value */ |
946 if (sd->desc.flags & SGF_CURRENCY) value *= _currency->rate; |
946 if (sd->desc.flags & SGF_CURRENCY) value *= _currency->rate; |
947 |
947 |
948 WP(w,def_d).data_3 = btn; |
948 WP(w, def_d).data_3 = btn; |
949 SetDParam(0, value); |
949 SetDParam(0, value); |
950 ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_PATCHES_QUERY_CAPT, 10, 100, w, CS_NUMERAL); |
950 ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_PATCHES_QUERY_CAPT, 10, 100, w, CS_NUMERAL); |
951 } |
951 } |
952 } |
952 } |
953 |
953 |
962 break; |
962 break; |
963 } |
963 } |
964 break; |
964 break; |
965 |
965 |
966 case WE_TIMEOUT: |
966 case WE_TIMEOUT: |
967 WP(w,def_d).data_2 = 0; |
967 WP(w, def_d).data_2 = 0; |
968 SetWindowDirty(w); |
968 SetWindowDirty(w); |
969 break; |
969 break; |
970 |
970 |
971 case WE_ON_EDIT_TEXT: { |
971 case WE_ON_EDIT_TEXT: { |
972 if (e->we.edittext.str != NULL) { |
972 if (e->we.edittext.str != NULL) { |
973 const PatchEntry *pe = &_patches_page[WP(w,def_d).data_1].entries[WP(w,def_d).data_3]; |
973 const PatchEntry *pe = &_patches_page[WP(w, def_d).data_1].entries[WP(w,def_d).data_3]; |
974 const SettingDesc *sd = pe->setting; |
974 const SettingDesc *sd = pe->setting; |
975 int32 value = atoi(e->we.edittext.str); |
975 int32 value = atoi(e->we.edittext.str); |
976 |
976 |
977 /* Save the correct currency-translated value */ |
977 /* Save the correct currency-translated value */ |
978 if (sd->desc.flags & SGF_CURRENCY) value /= _currency->rate; |
978 if (sd->desc.flags & SGF_CURRENCY) value /= _currency->rate; |
1050 { |
1050 { |
1051 switch (e->event) { |
1051 switch (e->event) { |
1052 case WE_PAINT: { |
1052 case WE_PAINT: { |
1053 int x; |
1053 int x; |
1054 int y = 20; |
1054 int y = 20; |
1055 int clk = WP(w,def_d).data_1; |
1055 int clk = WP(w, def_d).data_1; |
1056 DrawWindowWidgets(w); |
1056 DrawWindowWidgets(w); |
1057 |
1057 |
1058 // exchange rate |
1058 // exchange rate |
1059 DrawArrowButtons(10, y, 3, GB(clk, 0, 2), true, true); |
1059 DrawArrowButtons(10, y, 3, GB(clk, 0, 2), true, true); |
1060 SetDParam(0, 1); |
1060 SetDParam(0, 1); |
1103 switch (line) { |
1103 switch (line) { |
1104 case 0: // rate |
1104 case 0: // rate |
1105 if (IsInsideMM(x, 10, 30)) { // clicked buttons |
1105 if (IsInsideMM(x, 10, 30)) { // clicked buttons |
1106 if (x < 20) { |
1106 if (x < 20) { |
1107 if (_custom_currency.rate > 1) _custom_currency.rate--; |
1107 if (_custom_currency.rate > 1) _custom_currency.rate--; |
1108 WP(w,def_d).data_1 = 1 << (line * 2 + 0); |
1108 WP(w, def_d).data_1 = 1 << (line * 2 + 0); |
1109 } else { |
1109 } else { |
1110 if (_custom_currency.rate < 5000) _custom_currency.rate++; |
1110 if (_custom_currency.rate < 5000) _custom_currency.rate++; |
1111 WP(w,def_d).data_1 = 1 << (line * 2 + 1); |
1111 WP(w, def_d).data_1 = 1 << (line * 2 + 1); |
1112 } |
1112 } |
1113 } else { // enter text |
1113 } else { // enter text |
1114 SetDParam(0, _custom_currency.rate); |
1114 SetDParam(0, _custom_currency.rate); |
1115 str = STR_CONFIG_PATCHES_INT32; |
1115 str = STR_CONFIG_PATCHES_INT32; |
1116 len = 4; |
1116 len = 4; |
1118 } |
1118 } |
1119 break; |
1119 break; |
1120 |
1120 |
1121 case 1: // separator |
1121 case 1: // separator |
1122 if (IsInsideMM(x, 10, 30)) { // clicked button |
1122 if (IsInsideMM(x, 10, 30)) { // clicked button |
1123 WP(w,def_d).data_1 = 1 << (line * 2 + 1); |
1123 WP(w, def_d).data_1 = 1 << (line * 2 + 1); |
1124 } |
1124 } |
1125 str = BindCString(_str_separator); |
1125 str = BindCString(_str_separator); |
1126 len = 1; |
1126 len = 1; |
1127 break; |
1127 break; |
1128 |
1128 |
1129 case 2: // prefix |
1129 case 2: // prefix |
1130 if (IsInsideMM(x, 10, 30)) { // clicked button |
1130 if (IsInsideMM(x, 10, 30)) { // clicked button |
1131 WP(w,def_d).data_1 = 1 << (line * 2 + 1); |
1131 WP(w, def_d).data_1 = 1 << (line * 2 + 1); |
1132 } |
1132 } |
1133 str = BindCString(_custom_currency.prefix); |
1133 str = BindCString(_custom_currency.prefix); |
1134 len = 12; |
1134 len = 12; |
1135 break; |
1135 break; |
1136 |
1136 |
1137 case 3: // suffix |
1137 case 3: // suffix |
1138 if (IsInsideMM(x, 10, 30)) { // clicked button |
1138 if (IsInsideMM(x, 10, 30)) { // clicked button |
1139 WP(w,def_d).data_1 = 1 << (line * 2 + 1); |
1139 WP(w, def_d).data_1 = 1 << (line * 2 + 1); |
1140 } |
1140 } |
1141 str = BindCString(_custom_currency.suffix); |
1141 str = BindCString(_custom_currency.suffix); |
1142 len = 12; |
1142 len = 12; |
1143 break; |
1143 break; |
1144 |
1144 |
1145 case 4: // to euro |
1145 case 4: // to euro |
1146 if (IsInsideMM(x, 10, 30)) { // clicked buttons |
1146 if (IsInsideMM(x, 10, 30)) { // clicked buttons |
1147 if (x < 20) { |
1147 if (x < 20) { |
1148 _custom_currency.to_euro = (_custom_currency.to_euro <= 2000) ? |
1148 _custom_currency.to_euro = (_custom_currency.to_euro <= 2000) ? |
1149 CF_NOEURO : _custom_currency.to_euro - 1; |
1149 CF_NOEURO : _custom_currency.to_euro - 1; |
1150 WP(w,def_d).data_1 = 1 << (line * 2 + 0); |
1150 WP(w, def_d).data_1 = 1 << (line * 2 + 0); |
1151 } else { |
1151 } else { |
1152 _custom_currency.to_euro = |
1152 _custom_currency.to_euro = |
1153 Clamp(_custom_currency.to_euro + 1, 2000, MAX_YEAR); |
1153 Clamp(_custom_currency.to_euro + 1, 2000, MAX_YEAR); |
1154 WP(w,def_d).data_1 = 1 << (line * 2 + 1); |
1154 WP(w, def_d).data_1 = 1 << (line * 2 + 1); |
1155 } |
1155 } |
1156 } else { // enter text |
1156 } else { // enter text |
1157 SetDParam(0, _custom_currency.to_euro); |
1157 SetDParam(0, _custom_currency.to_euro); |
1158 str = STR_CONFIG_PATCHES_INT32; |
1158 str = STR_CONFIG_PATCHES_INT32; |
1159 len = 4; |
1159 len = 4; |
1173 } |
1173 } |
1174 |
1174 |
1175 case WE_ON_EDIT_TEXT: { |
1175 case WE_ON_EDIT_TEXT: { |
1176 const char *b = e->we.edittext.str; |
1176 const char *b = e->we.edittext.str; |
1177 |
1177 |
1178 switch (WP(w,def_d).data_2) { |
1178 switch (WP(w, def_d).data_2) { |
1179 case 0: /* Exchange rate */ |
1179 case 0: /* Exchange rate */ |
1180 _custom_currency.rate = Clamp(atoi(b), 1, 5000); |
1180 _custom_currency.rate = Clamp(atoi(b), 1, 5000); |
1181 break; |
1181 break; |
1182 |
1182 |
1183 case 1: /* Thousands seperator */ |
1183 case 1: /* Thousands seperator */ |