Allow entering decimal day/minute timetable values
This commit is contained in:
@@ -2988,6 +2988,7 @@ public:
|
|||||||
case WID_O_COND_VALUE: {
|
case WID_O_COND_VALUE: {
|
||||||
const Order *order = this->vehicle->GetOrder(this->OrderGetSel());
|
const Order *order = this->vehicle->GetOrder(this->OrderGetSel());
|
||||||
uint value;
|
uint value;
|
||||||
|
CharSetFilter charset_filter = CS_NUMERAL;
|
||||||
switch (order->GetConditionVariable()) {
|
switch (order->GetConditionVariable()) {
|
||||||
case OCV_CARGO_LOAD_PERCENTAGE:
|
case OCV_CARGO_LOAD_PERCENTAGE:
|
||||||
case OCV_TIME_DATE:
|
case OCV_TIME_DATE:
|
||||||
@@ -2996,7 +2997,10 @@ public:
|
|||||||
|
|
||||||
case OCV_TIMETABLE:
|
case OCV_TIMETABLE:
|
||||||
value = order->GetXData();
|
value = order->GetXData();
|
||||||
if (!_settings_client.gui.timetable_in_ticks) value /= DATE_UNIT_SIZE;
|
if (!_settings_client.gui.timetable_in_ticks) {
|
||||||
|
value /= DATE_UNIT_SIZE;
|
||||||
|
charset_filter = CS_NUMERAL_DECIMAL;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OCV_CARGO_WAITING_AMOUNT:
|
case OCV_CARGO_WAITING_AMOUNT:
|
||||||
@@ -3012,7 +3016,7 @@ public:
|
|||||||
if (order->GetConditionVariable() == OCV_CARGO_WAITING_AMOUNT) value = ConvertCargoQuantityToDisplayQuantity(order->GetConditionValue(), value);
|
if (order->GetConditionVariable() == OCV_CARGO_WAITING_AMOUNT) value = ConvertCargoQuantityToDisplayQuantity(order->GetConditionValue(), value);
|
||||||
this->query_text_widget = widget;
|
this->query_text_widget = widget;
|
||||||
SetDParam(0, value);
|
SetDParam(0, value);
|
||||||
ShowQueryString(STR_JUST_INT, STR_ORDER_CONDITIONAL_VALUE_CAPT, (order->GetConditionVariable() == OCV_CARGO_WAITING_AMOUNT) ? 12 : 6, this, CS_NUMERAL, QSF_NONE);
|
ShowQueryString(STR_JUST_INT, STR_ORDER_CONDITIONAL_VALUE_CAPT, (order->GetConditionVariable() == OCV_CARGO_WAITING_AMOUNT) ? 12 : 6, this, charset_filter, QSF_NONE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3118,10 +3122,10 @@ public:
|
|||||||
value = Clamp(value, 0, 0xFFFF);
|
value = Clamp(value, 0, 0xFFFF);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OCV_TIMETABLE:
|
case OCV_TIMETABLE: {
|
||||||
if (!_settings_client.gui.timetable_in_ticks) value *= DATE_UNIT_SIZE;
|
value = Clamp(ParseTimetableDuration(str), 0, 0xFFFF);
|
||||||
value = Clamp(value, 0, 0xFFFF);
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
value = Clamp(value, 0, 2047);
|
value = Clamp(value, 0, 2047);
|
||||||
|
@@ -699,8 +699,9 @@ struct SchdispatchWindow : GeneralVehicleWindow {
|
|||||||
|
|
||||||
case WID_SCHDISPATCH_SET_DURATION: {
|
case WID_SCHDISPATCH_SET_DURATION: {
|
||||||
if (!this->IsScheduleSelected()) break;
|
if (!this->IsScheduleSelected()) break;
|
||||||
|
CharSetFilter charset_filter = _settings_client.gui.timetable_in_ticks ? CS_NUMERAL : CS_NUMERAL_DECIMAL;
|
||||||
SetDParam(0, ProcessDurationForQueryString(this->GetSelectedSchedule().GetScheduledDispatchDuration()));
|
SetDParam(0, ProcessDurationForQueryString(this->GetSelectedSchedule().GetScheduledDispatchDuration()));
|
||||||
ShowQueryString(STR_JUST_INT, STR_SCHDISPATCH_DURATION_CAPTION_MINUTE + this->GetQueryStringCaptionOffset(), 31, this, CS_NUMERAL, QSF_NONE);
|
ShowQueryString(STR_JUST_INT, STR_SCHDISPATCH_DURATION_CAPTION_MINUTE + this->GetQueryStringCaptionOffset(), 31, this, charset_filter, QSF_NONE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -722,8 +723,9 @@ struct SchdispatchWindow : GeneralVehicleWindow {
|
|||||||
|
|
||||||
case WID_SCHDISPATCH_SET_DELAY: {
|
case WID_SCHDISPATCH_SET_DELAY: {
|
||||||
if (!this->IsScheduleSelected()) break;
|
if (!this->IsScheduleSelected()) break;
|
||||||
|
CharSetFilter charset_filter = _settings_client.gui.timetable_in_ticks ? CS_NUMERAL : CS_NUMERAL_DECIMAL;
|
||||||
SetDParam(0, ProcessDurationForQueryString(this->GetSelectedSchedule().GetScheduledDispatchDelay()));
|
SetDParam(0, ProcessDurationForQueryString(this->GetSelectedSchedule().GetScheduledDispatchDelay()));
|
||||||
ShowQueryString(STR_JUST_INT, STR_SCHDISPATCH_DELAY_CAPTION_MINUTE + this->GetQueryStringCaptionOffset(), 31, this, CS_NUMERAL, QSF_NONE);
|
ShowQueryString(STR_JUST_INT, STR_SCHDISPATCH_DELAY_CAPTION_MINUTE + this->GetQueryStringCaptionOffset(), 31, this, charset_filter, QSF_NONE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -769,8 +771,9 @@ struct SchdispatchWindow : GeneralVehicleWindow {
|
|||||||
|
|
||||||
case WID_SCHDISPATCH_ADJUST:
|
case WID_SCHDISPATCH_ADJUST:
|
||||||
if (!this->IsScheduleSelected()) break;
|
if (!this->IsScheduleSelected()) break;
|
||||||
|
CharSetFilter charset_filter = _settings_client.gui.timetable_in_ticks ? CS_NUMERAL_SIGNED : CS_NUMERAL_DECIMAL_SIGNED;
|
||||||
SetDParam(0, 0);
|
SetDParam(0, 0);
|
||||||
ShowQueryString(STR_JUST_INT, STR_SCHDISPATCH_ADJUST_CAPTION_MINUTE + this->GetQueryStringCaptionOffset(), 31, this, CS_NUMERAL_SIGNED, QSF_NONE);
|
ShowQueryString(STR_JUST_INT, STR_SCHDISPATCH_ADJUST_CAPTION_MINUTE + this->GetQueryStringCaptionOffset(), 31, this, charset_filter, QSF_NONE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -885,11 +888,9 @@ struct SchdispatchWindow : GeneralVehicleWindow {
|
|||||||
|
|
||||||
case WID_SCHDISPATCH_SET_DURATION: {
|
case WID_SCHDISPATCH_SET_DURATION: {
|
||||||
if (!this->IsScheduleSelected()) break;
|
if (!this->IsScheduleSelected()) break;
|
||||||
int32 val = StrEmpty(str) ? 0 : strtoul(str, nullptr, 10);
|
Ticks val = ParseTimetableDuration(str);
|
||||||
|
|
||||||
if (val > 0) {
|
if (val > 0) {
|
||||||
if (!_settings_client.gui.timetable_in_ticks) val *= DATE_UNIT_SIZE;
|
|
||||||
|
|
||||||
DoCommandP(0, v->index | (this->schedule_index << 20), val, CMD_SCHEDULED_DISPATCH_SET_DURATION | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE));
|
DoCommandP(0, v->index | (this->schedule_index << 20), val, CMD_SCHEDULED_DISPATCH_SET_DURATION | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -900,13 +901,7 @@ struct SchdispatchWindow : GeneralVehicleWindow {
|
|||||||
|
|
||||||
if (StrEmpty(str)) break;
|
if (StrEmpty(str)) break;
|
||||||
|
|
||||||
char *end;
|
DoCommandP(0, v->index | (this->schedule_index << 20), ParseTimetableDuration(str), CMD_SCHEDULED_DISPATCH_SET_DELAY | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE));
|
||||||
int32 val = strtoul(str, &end, 10);
|
|
||||||
if (val >= 0 && end != nullptr && *end == 0) {
|
|
||||||
if (!_settings_client.gui.timetable_in_ticks) val *= DATE_UNIT_SIZE;
|
|
||||||
|
|
||||||
DoCommandP(0, v->index | (this->schedule_index << 20), val, CMD_SCHEDULED_DISPATCH_SET_DELAY | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -919,11 +914,9 @@ struct SchdispatchWindow : GeneralVehicleWindow {
|
|||||||
|
|
||||||
case WID_SCHDISPATCH_ADJUST: {
|
case WID_SCHDISPATCH_ADJUST: {
|
||||||
if (!this->IsScheduleSelected()) break;
|
if (!this->IsScheduleSelected()) break;
|
||||||
int32 val = StrEmpty(str) ? 0 : strtol(str, nullptr, 10);
|
Ticks val = ParseTimetableDuration(str);
|
||||||
|
|
||||||
if (val != 0) {
|
if (val != 0) {
|
||||||
if (!_settings_client.gui.timetable_in_ticks) val *= DATE_UNIT_SIZE;
|
|
||||||
|
|
||||||
DoCommandP(0, v->index | (this->schedule_index << 20), val, CMD_SCHEDULED_DISPATCH_ADJUST | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE));
|
DoCommandP(0, v->index | (this->schedule_index << 20), val, CMD_SCHEDULED_DISPATCH_ADJUST | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
void ShowTimetableWindow(const Vehicle *v);
|
void ShowTimetableWindow(const Vehicle *v);
|
||||||
void UpdateVehicleTimetable(Vehicle *v, bool travelling);
|
void UpdateVehicleTimetable(Vehicle *v, bool travelling);
|
||||||
void SetTimetableParams(int first_param, Ticks ticks, bool long_mode = false);
|
void SetTimetableParams(int first_param, Ticks ticks, bool long_mode = false);
|
||||||
|
Ticks ParseTimetableDuration(const char *str);
|
||||||
void SetTimetableWindowsDirty(const Vehicle *v, bool include_scheduled_dispatch = false);
|
void SetTimetableWindowsDirty(const Vehicle *v, bool include_scheduled_dispatch = false);
|
||||||
|
|
||||||
struct TimetableProgress {
|
struct TimetableProgress {
|
||||||
|
@@ -62,6 +62,20 @@ void SetTimetableParams(int first_param, Ticks ticks, bool long_mode)
|
|||||||
SetDParam(first_param + 1, ticks);
|
SetDParam(first_param + 1, ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ticks ParseTimetableDuration(const char *str)
|
||||||
|
{
|
||||||
|
if (StrEmpty(str)) return 0;
|
||||||
|
|
||||||
|
if (_settings_client.gui.timetable_in_ticks) {
|
||||||
|
return strtoul(str, nullptr, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
char tmp_buffer[64];
|
||||||
|
strecpy(tmp_buffer, str, lastof(tmp_buffer));
|
||||||
|
str_replace_wchar(tmp_buffer, lastof(tmp_buffer), GetDecimalSeparatorChar(), '.');
|
||||||
|
return atof(tmp_buffer) * DATE_UNIT_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether it is possible to determine how long the order takes.
|
* Check whether it is possible to determine how long the order takes.
|
||||||
* @param order the order to check.
|
* @param order the order to check.
|
||||||
@@ -392,8 +406,6 @@ struct TimetableWindow : GeneralVehicleWindow {
|
|||||||
{
|
{
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
case WID_VT_ARRIVAL_DEPARTURE_PANEL:
|
case WID_VT_ARRIVAL_DEPARTURE_PANEL:
|
||||||
SetDParamMaxValue(0, MAX_YEAR * DAYS_IN_YEAR, 0, FS_SMALL);
|
|
||||||
this->deparr_time_width = GetStringBoundingBox(STR_JUST_DATE_TINY).width;
|
|
||||||
SetDParamMaxValue(0, _settings_time.time_in_minutes ? 0 : MAX_YEAR * DAYS_IN_YEAR);
|
SetDParamMaxValue(0, _settings_time.time_in_minutes ? 0 : MAX_YEAR * DAYS_IN_YEAR);
|
||||||
this->deparr_time_width = GetStringBoundingBox(STR_JUST_DATE_WALLCLOCK_TINY).width + 4;
|
this->deparr_time_width = GetStringBoundingBox(STR_JUST_DATE_WALLCLOCK_TINY).width + 4;
|
||||||
this->deparr_abbr_width = std::max(GetStringBoundingBox(STR_TIMETABLE_ARRIVAL_ABBREVIATION).width, GetStringBoundingBox(STR_TIMETABLE_DEPARTURE_ABBREVIATION).width);
|
this->deparr_abbr_width = std::max(GetStringBoundingBox(STR_TIMETABLE_ARRIVAL_ABBREVIATION).width, GetStringBoundingBox(STR_TIMETABLE_DEPARTURE_ABBREVIATION).width);
|
||||||
@@ -925,7 +937,8 @@ struct TimetableWindow : GeneralVehicleWindow {
|
|||||||
|
|
||||||
this->query_is_speed_query = false;
|
this->query_is_speed_query = false;
|
||||||
this->change_timetable_all = (order != nullptr) && (selected % 2 == 0) && _ctrl_pressed;
|
this->change_timetable_all = (order != nullptr) && (selected % 2 == 0) && _ctrl_pressed;
|
||||||
ShowQueryString(current, STR_TIMETABLE_CHANGE_TIME, 31, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
|
CharSetFilter charset_filter = _settings_client.gui.timetable_in_ticks ? CS_NUMERAL : CS_NUMERAL_DECIMAL;
|
||||||
|
ShowQueryString(current, STR_TIMETABLE_CHANGE_TIME, 31, this, charset_filter, QSF_ACCEPT_UNCHANGED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1089,14 +1102,13 @@ struct TimetableWindow : GeneralVehicleWindow {
|
|||||||
|
|
||||||
case WID_VT_CHANGE_SPEED:
|
case WID_VT_CHANGE_SPEED:
|
||||||
case WID_VT_CHANGE_TIME: {
|
case WID_VT_CHANGE_TIME: {
|
||||||
uint64 val = StrEmpty(str) ? 0 : strtoul(str, nullptr, 10);
|
|
||||||
uint32 p2;
|
uint32 p2;
|
||||||
if (this->query_is_speed_query) {
|
if (this->query_is_speed_query) {
|
||||||
val = ConvertDisplaySpeedToKmhishSpeed(val, v->type);
|
uint64 display_speed = StrEmpty(str) ? 0 : strtoul(str, nullptr, 10);
|
||||||
|
uint64 val = ConvertDisplaySpeedToKmhishSpeed(display_speed, v->type);
|
||||||
p2 = std::min<uint>(val, UINT16_MAX);
|
p2 = std::min<uint>(val, UINT16_MAX);
|
||||||
} else {
|
} else {
|
||||||
if (!_settings_client.gui.timetable_in_ticks) val *= DATE_UNIT_SIZE;
|
p2 = ParseTimetableDuration(str);
|
||||||
p2 = val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ExecuteTimetableCommand(v, this->change_timetable_all, this->sel_index, (this->sel_index % 2 == 1) ? (this->query_is_speed_query ? MTF_TRAVEL_SPEED : MTF_TRAVEL_TIME) : MTF_WAIT_TIME, p2, false);
|
ExecuteTimetableCommand(v, this->change_timetable_all, this->sel_index, (this->sel_index % 2 == 1) ? (this->query_is_speed_query ? MTF_TRAVEL_SPEED : MTF_TRAVEL_TIME) : MTF_WAIT_TIME, p2, false);
|
||||||
|
Reference in New Issue
Block a user