Dedicated buttons for local/express mode (#762)
* Vehicle window: add buttons for express/local mode. * Add toggle functionality to new local/express buttons. * Remove local/express from route list. * Drop dashes from local/express buttons.
This commit is contained in:
parent
913d420356
commit
f4c77663b8
|
@ -12,6 +12,7 @@
|
|||
- Fix: [#744] Rendering issues ('Z-fighting') with vehicles over bridges.
|
||||
- Fix: [#766] Performance index is off by a factor of 10 in scenario options window.
|
||||
- Change: [#690] Default saved game directory is now in OpenLoco user directory.
|
||||
- Change: [#762] The vehicle window now uses buttons for local/express mode.
|
||||
|
||||
20.10 (2020-10-25)
|
||||
------------------------------------------------------------------------
|
||||
|
|
|
@ -1243,8 +1243,8 @@ strings:
|
|||
1213: "{COLOUR WINDOW_2}{STRINGID})"
|
||||
1214: Es können keine Aufträge für Fahrzeuge mehr angenommen werden!
|
||||
1215: Für dieses Fahrzeug liegen zu viele Aufträge vor!
|
||||
1216: "- - Lokal - -"
|
||||
1217: "- - Express - -"
|
||||
1216: "Lokal"
|
||||
1217: "Express"
|
||||
1218: "{COLOUR BLACK}- - Keine Strecke definiert - -"
|
||||
1219: "{COLOUR BLACK}- - Ende der Streckenliste - -"
|
||||
1220: Halt bei {STRINGID}
|
||||
|
|
|
@ -1243,8 +1243,8 @@ strings:
|
|||
1213: "{COLOUR WINDOW_2}{STRINGID})"
|
||||
1214: No space for more vehicle orders!
|
||||
1215: Too many orders for this vehicle!
|
||||
1216: "- - Local - -"
|
||||
1217: "- - Express - -"
|
||||
1216: "Local"
|
||||
1217: "Express"
|
||||
1218: "{COLOUR BLACK}- - No route defined - -"
|
||||
1219: "{COLOUR BLACK}- - End of route list - -"
|
||||
1220: Stop at {STRINGID}
|
||||
|
|
|
@ -1244,8 +1244,8 @@ strings:
|
|||
1213: "{COLOUR WINDOW_2}{STRINGID})"
|
||||
1214: No space for more vehicle orders!
|
||||
1215: Too many orders for this vehicle!
|
||||
1216: "- - Local - -"
|
||||
1217: "- - Express - -"
|
||||
1216: "Local"
|
||||
1217: "Express"
|
||||
1218: "{COLOUR BLACK}- - No route defined - -"
|
||||
1219: "{COLOUR BLACK}- - End of route list - -"
|
||||
1220: Stop at {STRINGID}
|
||||
|
|
|
@ -1243,8 +1243,8 @@ strings:
|
|||
1213: "{COLOUR WINDOW_2}{STRINGID})"
|
||||
1214: ¡No hay sitio para más pedidos de vehículos!
|
||||
1215: ¡Hay demasiados pedidos para este vehículo!
|
||||
1216: "- - Local - -"
|
||||
1217: "- - Expreso - -"
|
||||
1216: "Local"
|
||||
1217: "Expreso"
|
||||
1218: "{COLOUR BLACK}- - Sin ruta definida - -"
|
||||
1219: "{COLOUR BLACK}- - Fin de la lista de rutas - -"
|
||||
1220: Parada en {STRINGID}
|
||||
|
|
|
@ -1243,8 +1243,8 @@ strings:
|
|||
1213: "{COLOUR WINDOW_2}{STRINGID})"
|
||||
1214: Pas assez de place pour d'autres ordres !
|
||||
1215: Trop d'ordres pour ce véhicule !
|
||||
1216: "- - Local - -"
|
||||
1217: "- - Express - -"
|
||||
1216: "Local"
|
||||
1217: "Express"
|
||||
1218: "{COLOUR BLACK}- - Aucun itinéraire défini - -"
|
||||
1219: "{COLOUR BLACK}- - Fin de la liste des itinéraires - -"
|
||||
1220: Arrêt à {STRINGID}
|
||||
|
|
|
@ -1243,8 +1243,8 @@ strings:
|
|||
1213: "{COLOUR WINDOW_2}{STRINGID})"
|
||||
1214: Non c'è spazio per altri ordini!
|
||||
1215: Troppi ordini per questo veicolo!
|
||||
1216: "- - Locale - -"
|
||||
1217: "- - Espresso - -"
|
||||
1216: "Locale"
|
||||
1217: "Espresso"
|
||||
1218: "{COLOUR BLACK}- - Percorso non definito - -"
|
||||
1219: "{COLOUR BLACK}- - Fine del percorso - -"
|
||||
1220: Ferma a {STRINGID}
|
||||
|
|
|
@ -1243,8 +1243,8 @@ strings:
|
|||
1213: "{COLOUR WINDOW_2}{STRINGID})"
|
||||
1214: No space for more vehicle orders!
|
||||
1215: Too many orders for this vehicle!
|
||||
1216: "- - Local - -"
|
||||
1217: "- - Express - -"
|
||||
1216: "Local"
|
||||
1217: "Express"
|
||||
1218: "{COLOUR BLACK}- - No route defined - -"
|
||||
1219: "{COLOUR BLACK}- - End of route list - -"
|
||||
1220: Stop at {STRINGID}
|
||||
|
|
|
@ -1243,8 +1243,8 @@ strings:
|
|||
1213: "{COLOUR WINDOW_2}{STRINGID})"
|
||||
1214: 차량 경로를 지정할 공간이 더 이상 없습니다!
|
||||
1215: 이 차량에 경로가 너무 많습니다!
|
||||
1216: "- - 완행 - -"
|
||||
1217: "- - 급행 - -"
|
||||
1216: "완행"
|
||||
1217: "급행"
|
||||
1218: "{COLOUR BLACK}- - 경로 없음 - -"
|
||||
1219: "{COLOUR BLACK}- - 경로 목록 끝 - -"
|
||||
1220: Stop at {STRINGID}
|
||||
|
|
|
@ -1243,8 +1243,8 @@ strings:
|
|||
1213: "{COLOUR WINDOW_2}{STRINGID})"
|
||||
1214: No space for more vehicle orders!
|
||||
1215: Too many orders for this vehicle!
|
||||
1216: "- - Lokaal - -"
|
||||
1217: "- - Express - -"
|
||||
1216: "Lokaal"
|
||||
1217: "Express"
|
||||
1218: "{COLOUR BLACK}- - Geen route gedefinieerd - -"
|
||||
1219: "{COLOUR BLACK}- - Einde van routelijst - -"
|
||||
1220: Stop op {STRINGID}
|
||||
|
|
|
@ -1236,8 +1236,8 @@ strings:
|
|||
1213: '{COLOUR WINDOW_2}{STRINGID})'
|
||||
1214: Brak miejsca na więcej poleceń pojazdu!
|
||||
1215: Zbyt wiele poleceń dla tego pojazdu!
|
||||
1216: '- - Normalny - -'
|
||||
1217: '- - Pospieszny - -'
|
||||
1216: 'Normalny'
|
||||
1217: 'Pospieszny'
|
||||
1218: '{COLOUR BLACK}- - Brak poleceń - -'
|
||||
1219: '{COLOUR BLACK}- - Koniec poleceń - -'
|
||||
1220: Zatrzymaj przy {STRINGID}
|
||||
|
|
|
@ -1243,8 +1243,8 @@ strings:
|
|||
1213: "{COLOUR WINDOW_2}{STRINGID})"
|
||||
1214: Sem espaço para mais ordens do veículo!
|
||||
1215: Muitas ordens para esse veículo!
|
||||
1216: "- - Local - -"
|
||||
1217: "- - Expresso - -"
|
||||
1216: "Local"
|
||||
1217: "Expresso"
|
||||
1218: "{COLOUR BLACK}- - Sem rota definida - -"
|
||||
1219: "{COLOUR BLACK}- - Fim da lista de rotas - -"
|
||||
1220: Parar em {STRINGID}
|
||||
|
|
|
@ -1220,8 +1220,8 @@ strings:
|
|||
1213: "{COLOUR WINDOW_2}{STRINGID})"
|
||||
1214: "Нет места для новых распоряжений!"
|
||||
1215: "Слишком много распоряжений для данного транспортного средства!"
|
||||
1216: "- - Местный - -"
|
||||
1217: "- - Экспресс - -"
|
||||
1216: "Местный"
|
||||
1217: "Экспресс"
|
||||
1218: "{COLOUR BLACK}- - Маршрут не определен - -"
|
||||
1219: "{COLOUR BLACK}- - Конец списка маршрутов - -"
|
||||
1220: "Остановка: {STRINGID}"
|
||||
|
|
|
@ -1244,8 +1244,8 @@ strings:
|
|||
1213: "{COLOUR WINDOW_2}{STRINGID})"
|
||||
1214: Nie je priestor pre viac príkazov vozidiel!
|
||||
1215: Príliš veľa príkazov pre toto vozidlo!
|
||||
1216: "- - Normálny - -"
|
||||
1217: "- - Rýchlik - -"
|
||||
1216: "Normálny"
|
||||
1217: "Rýchlik"
|
||||
1218: "{COLOUR BLACK}- - Nie je definovaná žiadna trasa - -"
|
||||
1219: "{COLOUR BLACK}- - Koniec zoznamu trás - -"
|
||||
1220: "Zastávka v: {STRINGID}"
|
||||
|
|
|
@ -699,8 +699,8 @@ namespace OpenLoco::StringIds
|
|||
constexpr string_id station_cargo_en_route_end = 1213;
|
||||
constexpr string_id no_space_for_more_vehicle_orders = 1214;
|
||||
|
||||
constexpr string_id local_seperator = 1216;
|
||||
constexpr string_id express_seperator = 1217;
|
||||
constexpr string_id local_mode_button = 1216;
|
||||
constexpr string_id express_mode_button = 1217;
|
||||
constexpr string_id no_route_defined = 1218;
|
||||
constexpr string_id orders_end = 1219;
|
||||
constexpr string_id orders_stop_at = 1220;
|
||||
|
|
|
@ -159,6 +159,8 @@ namespace OpenLoco::Ui::Vehicle
|
|||
enum widx
|
||||
{
|
||||
tool = Common::widx::tabRoute + 1, // Only used to hold the tool does nothing
|
||||
localMode,
|
||||
expressMode,
|
||||
routeList,
|
||||
orderForceUnload,
|
||||
orderWait,
|
||||
|
@ -174,9 +176,11 @@ namespace OpenLoco::Ui::Vehicle
|
|||
constexpr uint64_t holdableWidgets = 0;
|
||||
|
||||
static widget_t widgets[] = {
|
||||
commonWidgets(265, 177, StringIds::title_vehicle_route),
|
||||
commonWidgets(265, 189, StringIds::title_vehicle_route),
|
||||
makeWidget({ 0, 0 }, { 1, 1 }, widget_type::none, 0),
|
||||
makeWidget({ 3, 44 }, { 237, 120 }, widget_type::scrollview, 1, vertical, StringIds::tooltip_route_scrollview),
|
||||
makeWidget({ 3, 44 }, { 118, 12 }, widget_type::wt_11, 1, StringIds::local_mode_button),
|
||||
makeWidget({ 121, 44 }, { 119, 12 }, widget_type::wt_11, 1, StringIds::express_mode_button),
|
||||
makeWidget({ 3, 58 }, { 237, 120 }, widget_type::scrollview, 1, vertical, StringIds::tooltip_route_scrollview),
|
||||
makeWidget({ 240, 44 }, { 24, 24 }, widget_type::wt_9, 1, ImageIds::route_force_unload, StringIds::tooltip_route_insert_force_unload),
|
||||
makeWidget({ 240, 68 }, { 24, 24 }, widget_type::wt_9, 1, ImageIds::route_wait, StringIds::tooltip_route_insert_wait_full_cargo),
|
||||
makeWidget({ 240, 92 }, { 24, 24 }, widget_type::wt_9, 1, ImageIds::route_skip, StringIds::tooltip_route_skip_next_order),
|
||||
|
@ -2299,18 +2303,12 @@ namespace OpenLoco::Ui::Vehicle
|
|||
return;
|
||||
}
|
||||
|
||||
// First item on the list is the local/express button
|
||||
if (orderId == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// orderId can be -1 at this point for none selected
|
||||
auto i = 0;
|
||||
Vehicles::Order* last = nullptr;
|
||||
for (auto& order : getOrderTable(head))
|
||||
{
|
||||
if (i == orderId - 1)
|
||||
if (i == orderId)
|
||||
{
|
||||
orderDeleteCommand(head, order.getOffset());
|
||||
return;
|
||||
|
@ -2349,11 +2347,11 @@ namespace OpenLoco::Ui::Vehicle
|
|||
// No moveable orders
|
||||
if (head->sizeOfOrderTable <= 1)
|
||||
return false;
|
||||
// Null orderId and item 0 (local/express) no action
|
||||
if (orderId <= 0)
|
||||
// Valid orderId should be positive (avoid -1 / null)
|
||||
if (orderId < 0)
|
||||
return false;
|
||||
|
||||
auto* order = getOrderTable(head).atIndex(orderId - 1);
|
||||
auto* order = getOrderTable(head).atIndex(orderId);
|
||||
if (order != nullptr)
|
||||
{
|
||||
return orderMoveFunc(head, order->getOffset());
|
||||
|
@ -2389,7 +2387,7 @@ namespace OpenLoco::Ui::Vehicle
|
|||
}
|
||||
|
||||
// Refresh selection (check if we are now at no order selected)
|
||||
auto* order = getOrderTable(Common::getVehicle(self)).atIndex(self->var_842 - 1);
|
||||
auto* order = getOrderTable(Common::getVehicle(self)).atIndex(self->var_842);
|
||||
|
||||
// If no order selected anymore
|
||||
if (order == nullptr)
|
||||
|
@ -2398,6 +2396,34 @@ namespace OpenLoco::Ui::Vehicle
|
|||
}
|
||||
break;
|
||||
}
|
||||
case widx::localMode:
|
||||
{
|
||||
auto head = Common::getVehicle(self);
|
||||
if (!isPlayerCompany(head->owner))
|
||||
return;
|
||||
|
||||
Vehicles::Vehicle train(head);
|
||||
if (train.veh1->var_48 & (1 << 1))
|
||||
{
|
||||
gGameCommandErrorTitle = StringIds::empty;
|
||||
GameCommands::do12(head->id, 2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case widx::expressMode:
|
||||
{
|
||||
auto head = Common::getVehicle(self);
|
||||
if (!isPlayerCompany(head->owner))
|
||||
return;
|
||||
|
||||
Vehicles::Vehicle train(head);
|
||||
if (!(train.veh1->var_48 & (1 << 1)))
|
||||
{
|
||||
gGameCommandErrorTitle = StringIds::empty;
|
||||
GameCommands::do12(head->id, 2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case widx::orderSkip:
|
||||
gGameCommandErrorTitle = StringIds::empty;
|
||||
GameCommands::do_37(self->number);
|
||||
|
@ -2405,7 +2431,7 @@ namespace OpenLoco::Ui::Vehicle
|
|||
case widx::orderUp:
|
||||
if (onOrderMove(Common::getVehicle(self), self->var_842, orderUpCommand))
|
||||
{
|
||||
if (self->var_842 <= 1)
|
||||
if (self->var_842 <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -2415,7 +2441,7 @@ namespace OpenLoco::Ui::Vehicle
|
|||
case widx::orderDown:
|
||||
if (onOrderMove(Common::getVehicle(self), self->var_842, orderDownCommand))
|
||||
{
|
||||
if (self->var_842 <= 0)
|
||||
if (self->var_842 < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -2697,36 +2723,27 @@ namespace OpenLoco::Ui::Vehicle
|
|||
static void getScrollSize(Ui::window* const self, const uint32_t scrollIndex, uint16_t* const width, uint16_t* const height)
|
||||
{
|
||||
auto head = Common::getVehicle(self);
|
||||
|
||||
// Space for the end of orders and express/local item
|
||||
*height = 10 * 2;
|
||||
|
||||
auto table = getOrderTable(head);
|
||||
*height += 10 * std::distance(table.begin(), table.end());
|
||||
*height = 10 * std::distance(table.begin(), table.end());
|
||||
|
||||
// Space for the 'end of orders' item
|
||||
*height += 10;
|
||||
}
|
||||
|
||||
static void scrollMouseDown(window* const self, const int16_t x, const int16_t y, const uint8_t scrollIndex)
|
||||
{
|
||||
auto head = Common::getVehicle(self);
|
||||
auto item = y / 10;
|
||||
Vehicles::Order* selectedOrder = nullptr;
|
||||
if (item != 0)
|
||||
Vehicles::Order* selectedOrder = getOrderTable(head).atIndex(item);
|
||||
if (selectedOrder == nullptr)
|
||||
{
|
||||
selectedOrder = getOrderTable(head).atIndex(item - 1);
|
||||
if (selectedOrder == nullptr)
|
||||
{
|
||||
item = -1;
|
||||
}
|
||||
item = -1;
|
||||
}
|
||||
|
||||
auto toolWindow = Input::toolGetActiveWindow();
|
||||
// If another vehicle window is open and has focus (tool)
|
||||
if (toolWindow != nullptr && toolWindow->type == self->type && toolWindow->number != self->number)
|
||||
{
|
||||
if (item == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (item == -1)
|
||||
{
|
||||
// Copy complete order list
|
||||
|
@ -2753,17 +2770,6 @@ namespace OpenLoco::Ui::Vehicle
|
|||
return;
|
||||
}
|
||||
|
||||
// If Express/Local item
|
||||
if (item == 0)
|
||||
{
|
||||
if (head->owner != CompanyManager::getControllingId())
|
||||
return;
|
||||
gGameCommandErrorTitle = StringIds::empty;
|
||||
GameCommands::do12(head->id, 2);
|
||||
self->var_842 = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (item != self->var_842)
|
||||
{
|
||||
self->var_842 = item;
|
||||
|
@ -2895,6 +2901,14 @@ namespace OpenLoco::Ui::Vehicle
|
|||
self->disabled_widgets &= ~((1 << widx::orderWait) | (1 << widx::orderForceUnload));
|
||||
}
|
||||
|
||||
// Express / local
|
||||
self->activated_widgets = 0;
|
||||
Vehicles::Vehicle train(head);
|
||||
if (train.veh1->var_48 & (1 << 1))
|
||||
self->activated_widgets |= (1 << widx::expressMode);
|
||||
else
|
||||
self->activated_widgets |= (1 << widx::localMode);
|
||||
|
||||
widget_type type = head->owner == CompanyManager::getControllingId() ? widget_type::wt_9 : widget_type::none;
|
||||
self->widgets[widx::orderForceUnload].type = type;
|
||||
self->widgets[widx::orderWait].type = type;
|
||||
|
@ -2905,7 +2919,16 @@ namespace OpenLoco::Ui::Vehicle
|
|||
if (type == widget_type::none)
|
||||
{
|
||||
self->widgets[widx::routeList].right += 22;
|
||||
self->enabled_widgets &= ~(1 << widx::expressMode | 1 << widx::localMode);
|
||||
}
|
||||
else
|
||||
{
|
||||
self->enabled_widgets |= (1 << widx::expressMode | 1 << widx::localMode);
|
||||
}
|
||||
|
||||
self->widgets[widx::expressMode].right = self->widgets[widx::routeList].right;
|
||||
self->widgets[widx::expressMode].left = (self->widgets[widx::expressMode].right - 3) / 2 + 3;
|
||||
self->widgets[widx::localMode].right = self->widgets[widx::expressMode].left - 1;
|
||||
|
||||
self->disabled_widgets |= (1 << widx::orderUp) | (1 << widx::orderDown);
|
||||
if (self->var_842 != -1)
|
||||
|
@ -3032,23 +3055,11 @@ namespace OpenLoco::Ui::Vehicle
|
|||
|
||||
auto head = Common::getVehicle(self);
|
||||
Vehicles::Vehicle train(head);
|
||||
auto strFormat = StringIds::black_stringid;
|
||||
if (self->row_hover == 0)
|
||||
{
|
||||
Gfx::fillRect(pDrawpixelinfo, 0, 0, self->width, 9, 0x2000030);
|
||||
strFormat = StringIds::wcolour2_stringid;
|
||||
}
|
||||
|
||||
auto rowNum = 0;
|
||||
{
|
||||
FormatArguments args{};
|
||||
args.push(train.veh1->var_48 & (1 << 1) ? StringIds::express_seperator : StringIds::local_seperator);
|
||||
Gfx::drawString_494B3F(*pDrawpixelinfo, 8, -1, Colour::black, strFormat, &args);
|
||||
rowNum++;
|
||||
}
|
||||
if (head->sizeOfOrderTable == 1)
|
||||
{
|
||||
Gfx::drawString_494B3F(*pDrawpixelinfo, 8, 9, Colour::black, StringIds::no_route_defined);
|
||||
Gfx::drawString_494B3F(*pDrawpixelinfo, 8, 0, Colour::black, StringIds::no_route_defined);
|
||||
rowNum++; // Used to move down the text
|
||||
}
|
||||
|
||||
|
@ -3056,7 +3067,7 @@ namespace OpenLoco::Ui::Vehicle
|
|||
for (auto& order : getOrderTable(head))
|
||||
{
|
||||
int16_t y = rowNum * 10;
|
||||
strFormat = StringIds::black_stringid;
|
||||
auto strFormat = StringIds::black_stringid;
|
||||
if (self->var_842 == rowNum)
|
||||
{
|
||||
Gfx::fillRect(pDrawpixelinfo, 0, y, self->width, y + 9, Colour::aquamarine);
|
||||
|
@ -3104,16 +3115,16 @@ namespace OpenLoco::Ui::Vehicle
|
|||
|
||||
// Output the end of orders
|
||||
Gfx::point_t loc = { 8, static_cast<int16_t>(rowNum * 10) };
|
||||
strFormat = StringIds::black_stringid;
|
||||
auto strFormat = StringIds::black_stringid;
|
||||
if (self->var_842 == rowNum)
|
||||
{
|
||||
Gfx::fillRect(pDrawpixelinfo, 0, loc.y, self->width, loc.y + 9, Colour::aquamarine);
|
||||
Gfx::fillRect(pDrawpixelinfo, 0, loc.y, self->width, loc.y + 10, Colour::aquamarine);
|
||||
strFormat = StringIds::white_stringid;
|
||||
}
|
||||
if (self->row_hover == rowNum)
|
||||
{
|
||||
strFormat = StringIds::wcolour2_stringid;
|
||||
Gfx::fillRect(pDrawpixelinfo, 0, loc.y, self->width, loc.y + 9, 0x2000030);
|
||||
Gfx::fillRect(pDrawpixelinfo, 0, loc.y, self->width, loc.y + 10, 0x2000030);
|
||||
}
|
||||
|
||||
loc.y -= 1;
|
||||
|
|
Loading…
Reference in New Issue