Add client setting to enable shared order group window for single vehicles

pull/26/head
Jonathan G Rennison 7 years ago
parent 2a3f59dc8a
commit ac016eae5e

@ -1397,6 +1397,8 @@ STR_CONFIG_SETTING_OSK_ACTIVATION_SINGLE_CLICK :Single click (i
STR_CONFIG_SETTING_SHOW_VEHICLE_ROUTE_STEPS :Show the vehicle's route steps: {STRING2}
STR_CONFIG_SETTING_SHOW_VEHICLE_LIST_COMPANY_COLOUR :Mark other companies' vehicles in lists with their company colour: {STRING2}
STR_CONFIG_SETTING_SHOW_VEHICLE_LIST_COMPANY_COLOUR_HELPTEXT :Vehicles in a vehicle list window which are owned by a different company than the owner of the vehicle list are marked with a coloured square in the vehicle's company colour.
STR_CONFIG_SETTING_ENABLE_SINGLE_VEH_SHARED_ORDER_GUI :Enable single vehicles in shared order group window: {STRING2}
STR_CONFIG_SETTING_ENABLE_SINGLE_VEH_SHARED_ORDER_GUI_HELPTEXT :Allow using the shared order group window with single vehicles, without shared orders.
STR_CONFIG_SETTING_VIEWPORT_MAP_SCAN_SURROUNDINGS :Scan surroundings (better for high zoom out levels): {STRING2}
STR_CONFIG_SETTING_VIEWPORT_MAP_SHOW_SLOPES :Show slopes: {STRING2}

@ -37,6 +37,7 @@
#include "cheat_type.h"
#include "viewport_func.h"
#include "order_cmd.h"
#include "vehiclelist.h"
#include "table/strings.h"
@ -1909,7 +1910,7 @@ CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
for (const auto& slot : src->orders.list->GetScheduledDispatch()) {
dst->orders.list->AddScheduledDispatch(slot);
}
Date start_date;
uint16 start_full_date_fract;
SchdispatchConvertToFullDateFract(
@ -2157,10 +2158,13 @@ void DeleteVehicleOrders(Vehicle *v, bool keep_orderlist, bool reset_order_indic
/* Remove ourself from the shared order list. */
v->RemoveFromShared();
v->orders.list = NULL;
} else if (v->orders.list != NULL) {
/* Remove the orders */
v->orders.list->FreeChain(keep_orderlist);
if (!keep_orderlist) v->orders.list = NULL;
} else {
DeleteWindowById(GetWindowClassForVehicleType(v->type), VehicleListIdentifier(VL_SHARED_ORDERS, v->type, v->owner, v->index).Pack());
if (v->orders.list != NULL) {
/* Remove the orders */
v->orders.list->FreeChain(keep_orderlist);
if (!keep_orderlist) v->orders.list = NULL;
}
}
if (reset_order_indices) {

@ -1658,7 +1658,7 @@ public:
}
/* Disable list of vehicles with the same shared orders if there is no list */
this->SetWidgetDisabledState(WID_O_SHARED_ORDER_LIST, !shared_orders);
this->SetWidgetDisabledState(WID_O_SHARED_ORDER_LIST, !(shared_orders || _settings_client.gui.enable_single_veh_shared_order_gui));
this->GetWidget<NWidgetStacked>(WID_O_SEL_OCCUPANCY)->SetDisplayedPlane(IsWidgetLowered(WID_O_OCCUPANCY_TOGGLE) ? 0 : SZSP_NONE);

@ -1169,6 +1169,17 @@ static bool SimulatedWormholeSignalsChanged(int32 p1)
return true;
}
static bool EnableSingleVehSharedOrderGuiChanged(int32)
{
for (VehicleType type = VEH_BEGIN; type < VEH_COMPANY_END; type++) {
InvalidateWindowClassesData(GetWindowClassForVehicleType(type), 0);
}
SetWindowClassesDirty(WC_VEHICLE_TIMETABLE);
InvalidateWindowClassesData(WC_VEHICLE_ORDERS, 0);
return true;
}
/** Checks if any settings are set to incorrect values, and sets them to correct values in that case. */
static void ValidateSettings()
{

@ -1599,6 +1599,7 @@ static SettingsContainer &GetSettingsTree()
interface->Add(new SettingEntry("gui.show_vehicle_group_in_details"));
interface->Add(new SettingEntry("gui.show_vehicle_list_company_colour"));
interface->Add(new SettingEntry("gui.show_adv_tracerestrict_features"));
interface->Add(new SettingEntry("gui.enable_single_veh_shared_order_gui"));
}
SettingsPage *advisors = main->Add(new SettingsPage(STR_CONFIG_SETTING_ADVISORS));

@ -176,6 +176,7 @@ struct GUISettings {
uint8 osk_activation; ///< Mouse gesture to trigger the OSK.
bool show_vehicle_route_steps; ///< when a window related to a specific vehicle is focused, show route steps
bool show_vehicle_list_company_colour; ///< show the company colour of vehicles which have an owner different to the owner of the vehicle list
bool enable_single_veh_shared_order_gui; ///< enable showing a single vehicle in the shared order GUI window
uint16 console_backlog_timeout; ///< the minimum amount of time items should be in the console backlog before they will be removed in ~3 seconds granularity.
uint16 console_backlog_length; ///< the minimum amount of items in the console backlog before items will be removed.

@ -45,6 +45,7 @@ static bool MaxVehiclesChanged(int32 p1);
static bool ImprovedBreakdownsSettingChanged(int32 p1);
static bool DayLengthChanged(int32 p1);
static bool SimulatedWormholeSignalsChanged(int32 p1);
static bool EnableSingleVehSharedOrderGuiChanged(int32 p1);
#ifdef ENABLE_NETWORK
static bool UpdateClientName(int32 p1);
@ -4089,6 +4090,15 @@ strhelp = STR_CONFIG_SETTING_SHOW_ADV_TRACE_RESTRICT_FEATURES_HELPTEXT
proc = RedrawScreen
cat = SC_EXPERT
[SDTC_BOOL]
var = gui.enable_single_veh_shared_order_gui
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
def = false
str = STR_CONFIG_SETTING_ENABLE_SINGLE_VEH_SHARED_ORDER_GUI
strhelp = STR_CONFIG_SETTING_ENABLE_SINGLE_VEH_SHARED_ORDER_GUI_HELPTEXT
proc = EnableSingleVehSharedOrderGuiChanged
cat = SC_EXPERT
; For the dedicated build we'll enable dates in logs by default.
[SDTC_BOOL]
ifdef = DEDICATED

@ -356,7 +356,7 @@ struct TimetableWindow : Window {
this->SetWidgetDisabledState(WID_VT_CLEAR_TIME, disable || HasBit(v->vehicle_flags, VF_AUTOMATE_TIMETABLE));
this->SetWidgetDisabledState(WID_VT_CHANGE_SPEED, disable_speed);
this->SetWidgetDisabledState(WID_VT_CLEAR_SPEED, disable_speed);
this->SetWidgetDisabledState(WID_VT_SHARED_ORDER_LIST, !v->IsOrderListShared());
this->SetWidgetDisabledState(WID_VT_SHARED_ORDER_LIST, !(v->IsOrderListShared() || _settings_client.gui.enable_single_veh_shared_order_gui));
this->SetWidgetDisabledState(WID_VT_START_DATE, v->orders.list == NULL || HasBit(v->vehicle_flags, VF_TIMETABLE_SEPARATION) || HasBit(v->vehicle_flags, VF_SCHEDULED_DISPATCH));
this->SetWidgetDisabledState(WID_VT_RESET_LATENESS, v->orders.list == NULL);
@ -380,7 +380,7 @@ struct TimetableWindow : Window {
this->SetWidgetLoweredState(WID_VT_AUTOMATE, HasBit(v->vehicle_flags, VF_AUTOMATE_TIMETABLE));
this->SetWidgetLoweredState(WID_VT_AUTO_SEPARATION, HasBit(v->vehicle_flags, VF_TIMETABLE_SEPARATION));
this->SetWidgetLoweredState(WID_VT_SCHEDULED_DISPATCH, HasBit(v->vehicle_flags, VF_SCHEDULED_DISPATCH));
this->SetWidgetDisabledState(WID_VT_SCHEDULED_DISPATCH, v->orders.list == NULL);
this->DrawWidgets();

@ -3346,10 +3346,11 @@ void Vehicle::RemoveFromShared()
if (this->next_shared != NULL) this->next_shared->previous_shared = this->previous_shared;
if (this->orders.list->GetNumVehicles() == 1) {
if (this->orders.list->GetNumVehicles() == 1) InvalidateVehicleOrder(this->FirstShared(), 0);
if (this->orders.list->GetNumVehicles() == 1 && !_settings_client.gui.enable_single_veh_shared_order_gui) {
/* When there is only one vehicle, remove the shared order list window. */
DeleteWindowById(GetWindowClassForVehicleType(this->type), vli.Pack());
InvalidateVehicleOrder(this->FirstShared(), 0);
} else if (were_first) {
/* If we were the first one, update to the new first one.
* Note: FirstShared() is already the new first */

@ -1923,6 +1923,9 @@ public:
if (data == 0) {
/* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */
this->vehicles.ForceRebuild();
if (this->vli.type == VL_SHARED_ORDERS && !_settings_client.gui.enable_single_veh_shared_order_gui && this->vehicles.Length() == 1) {
delete this;
}
} else {
this->vehicles.ForceResort();
}

Loading…
Cancel
Save