Loading
#openttdcoop - Paste
Archives
Trending
Docs
Login
ABAP
ActionScript
ActionScript 3
Ada
AIMMS3
ALGOL 68
Apache configuration
AppleScript
Apt sources
ARM ASSEMBLER
ASM
ASP
asymptote
Autoconf
Autohotkey
AutoIt
AviSynth
awk
BASCOM AVR
Bash
Basic4GL
BibTeX
BlitzBasic
bnf
Boo
Brainfuck
C
C#
C (LoadRunner)
C (Mac)
C (WinAPI)
C++
C++ (Qt)
C++ (WinAPI)
CAD DCL
CAD Lisp
CFDG
ChaiScript
Chapel
CIL
Clojure
CMake
COBOL
CoffeeScript
ColdFusion
CSS
Cuesheet
D
Dart
DCL
DCPU-16 Assembly
DCS
Delphi
Diff
DIV
DOS
dot
E
ECMAScript
Eiffel
eMail (mbox)
EPC
Erlang
Euphoria
EZT
F#
Falcon
FO (abas-ERP)
Formula One
Fortran
FreeBasic
FreeSWITCH
GADV 4CS
GAMBAS
GDB
genero
Genie
glSlang
GML
GNU/Octave
GNU Gettext
GNU make
Gnuplot
Go
Groovy
GwBasic
Haskell
Haxe
HicEst
HQ9+
HTML
HTML5
Icon
INI
Inno
INTERCAL
Io
ISPF Panel
J
Java
Java(TM) 2 Platform Standard Edition 5.0
Javascript
JCL
jQuery
KiXtart
KLone C
KLone C++
LaTeX
LDIF
Liberty BASIC
Lisp
LLVM Intermediate Representation
Locomotive Basic
Logtalk
LOLcode
Lotus Notes @Formulas
LotusScript
LScript
LSL2
Lua
MagikSF
MapBasic
Matlab M
Microchip Assembler
Microsoft Registry
mIRC Scripting
MMIX
Modula-2
Modula-3
MOS 6502 (6510) ACME Cross Assembler format
MOS 6502 (6510) Kick Assembler format
MOS 6502 (6510) TASM/64TASS 1.46 Assembler format
Motorola 68000 - HiSoft Devpac ST 2 Assembler format
Motorola 68000 Assembler
MXML
MySQL
Nagios
NetRexx
newlisp
nginx
Nimrod
NML NewGRF Meta Language
NSIS
Oberon-2
Objeck Programming Language
Objective-C
OCaml
OCaml (brief)
ooRexx
OpenBSD Packet Filter
OpenOffice.org Basic
Oracle 8 SQL
Oracle 11 SQL
Oxygene
OZ
ParaSail
PARI/GP
Pascal
PCRE
per
Perl
Perl 6
PHP
PHP (brief)
PIC16
Pike
Pixel Bender 1.0
PL/I
PL/SQL
PostgreSQL
PostScript
POVRAY
PowerBuilder
PowerShell
ProFTPd configuration
Progress
Prolog
PROPERTIES
ProvideX
Puppet
PureBasic
Python
Python for S60
q/kdb+
QBasic/QuickBASIC
QML
R / S+
Racket
Rails
RBScript
REBOL
rexx
robots.txt
RPM Specification File
Ruby
Rust
SAS
Scala
Scheme
SciLab
SCL
sdlBasic
Smalltalk
Smarty
SPARK
SPARQL
SQL
Squirrel Script
Squirrel Script with OpenTTD AI/GS
StandardML
StoneScript
SystemVerilog
T-SQL
TCL
Tera Term Macro
Text
thinBasic
TypoScript
Unicon (Unified Extended Dialect of Icon)
Uno Idl
Unreal Script
UPC
Urbi
Vala
vb.net
VBScript
Vedit macro language
Verilog
VHDL
Vim Script
Visual Basic
Visual Fox Pro
Visual Prolog
Whitespace
Whois (RPSL format)
Winbatch
X++
XBasic
XML
Xorg configuration
YAML
ZiLOG Z80 Assembler
ZXBasic
Index: src/autoreplace_gui.cpp =================================================================== --- src/autoreplace_gui.cpp (revision 27682) +++ src/autoreplace_gui.cpp (working copy) @@ -87,7 +87,7 @@ byte sort_criteria; ///< Criteria of sorting vehicles. bool descending_sort_order; ///< Order of sorting vehicles. bool show_hidden_engines; ///< Whether to show the hidden engines. - RailType sel_railtype; ///< Type of rail tracks selected. + RailType sel_railtype; ///< Type of rail tracks selected. INVALID_RAILTYPE to show all. Scrollbar *vscroll[2]; /** @@ -106,7 +106,7 @@ if (draw_left && show_engines) { /* Ensure that the railtype is specific to the selected one */ - if (rvi->railtype != this->sel_railtype) return false; + if (this->sel_railtype != INVALID_RAILTYPE && rvi->railtype != this->sel_railtype) return false; } return true; } @@ -211,24 +211,7 @@ public: ReplaceVehicleWindow(WindowDesc *desc, VehicleType vehicletype, GroupID id_g) : Window(desc) { - if (vehicletype == VEH_TRAIN) { - /* For rail vehicles find the most used vehicle type, which is usually - * better than 'just' the first/previous vehicle type. */ - uint type_count[RAILTYPE_END]; - memset(type_count, 0, sizeof(type_count)); - - const Engine *e; - FOR_ALL_ENGINES_OF_TYPE(e, VEH_TRAIN) { - if (e->u.rail.railveh_type == RAILVEH_WAGON) continue; - type_count[e->u.rail.railtype] += GetGroupNumEngines(_local_company, id_g, e->index); - } - - this->sel_railtype = RAILTYPE_BEGIN; - for (RailType rt = RAILTYPE_BEGIN; rt < RAILTYPE_END; rt++) { - if (type_count[this->sel_railtype] < type_count[rt]) this->sel_railtype = rt; - } - } - + this->sel_railtype = INVALID_RAILTYPE; this->replace_engines = true; // start with locomotives (all other vehicles will not read this bool) this->engines[0].ForceRebuild(); this->engines[1].ForceRebuild(); @@ -288,12 +271,9 @@ break; } - case WID_RV_TRAIN_ENGINEWAGON_TOGGLE: { - StringID str = this->GetWidget<NWidgetCore>(widget)->widget_data; - SetDParam(0, STR_REPLACE_ENGINES); - Dimension d = GetStringBoundingBox(str); - SetDParam(0, STR_REPLACE_WAGONS); - d = maxdim(d, GetStringBoundingBox(str)); + case WID_RV_TRAIN_ENGINEWAGON_DROPDOWN: { + Dimension d = GetStringBoundingBox(STR_REPLACE_ENGINES); + d = maxdim(d, GetStringBoundingBox(STR_REPLACE_WAGONS)); d.width += padding.width; d.height += padding.height; *size = maxdim(*size, d); @@ -367,7 +347,7 @@ break; } - case WID_RV_TRAIN_ENGINEWAGON_TOGGLE: + case WID_RV_TRAIN_ENGINEWAGON_DROPDOWN: SetDParam(0, this->replace_engines ? STR_REPLACE_ENGINES : STR_REPLACE_WAGONS); break; } @@ -432,12 +412,8 @@ this->SetWidgetDisabledState(WID_RV_STOP_REPLACE, this->sel_engine[0] == INVALID_ENGINE || !EngineHasReplacementForCompany(c, this->sel_engine[0], this->sel_group)); if (this->window_number == VEH_TRAIN) { - /* sets the colour of that art thing */ - this->GetWidget<NWidgetCore>(WID_RV_TRAIN_FLUFF_LEFT)->colour = _company_colours[_local_company]; - this->GetWidget<NWidgetCore>(WID_RV_TRAIN_FLUFF_RIGHT)->colour = _company_colours[_local_company]; - /* Show the selected railtype in the pulldown menu */ - this->GetWidget<NWidgetCore>(WID_RV_TRAIN_RAILTYPE_DROPDOWN)->widget_data = GetRailTypeInfo(sel_railtype)->strings.replace_text; + this->GetWidget<NWidgetCore>(WID_RV_TRAIN_RAILTYPE_DROPDOWN)->widget_data = sel_railtype == INVALID_RAILTYPE ? STR_REPLACE_ALL_RAILTYPE : GetRailTypeInfo(sel_railtype)->strings.replace_text; } this->DrawWidgets(); @@ -483,15 +459,21 @@ DisplayVehicleSortDropDown(this, static_cast<VehicleType>(this->window_number), this->sort_criteria, WID_RV_SORT_DROPDOWN); break; - case WID_RV_TRAIN_ENGINEWAGON_TOGGLE: - this->replace_engines = !(this->replace_engines); - this->engines[0].ForceRebuild(); - this->reset_sel_engine = true; - this->SetDirty(); + case WID_RV_TRAIN_ENGINEWAGON_DROPDOWN: { + DropDownList *list = new DropDownList(); + + DropDownListStringItem *item = new DropDownListStringItem(STR_REPLACE_ENGINES, 1, false); + *list->Append() = item; + + item = new DropDownListStringItem(STR_REPLACE_WAGONS, 0, false); + *list->Append() = item; + + ShowDropDownList(this, list, this->replace_engines ? 1 : 0, WID_RV_TRAIN_ENGINEWAGON_DROPDOWN); break; + } case WID_RV_TRAIN_RAILTYPE_DROPDOWN: // Railtype selection dropdown menu - ShowDropDownList(this, GetRailTypeDropDownList(true), sel_railtype, WID_RV_TRAIN_RAILTYPE_DROPDOWN); + ShowDropDownList(this, GetRailTypeDropDownList(true, true), sel_railtype, WID_RV_TRAIN_RAILTYPE_DROPDOWN); break; case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: // toggle renew_keep_length @@ -566,6 +548,14 @@ break; } + case WID_RV_TRAIN_ENGINEWAGON_DROPDOWN: { + this->replace_engines = index != 0; + this->engines[0].ForceRebuild(); + this->reset_sel_engine = true; + this->SetDirty(); + break; + } + case WID_RV_START_REPLACE: this->ReplaceClick_StartReplace(index != 0); break; @@ -611,9 +601,15 @@ EndContainer(), EndContainer(), NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), - NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), EndContainer(), NWidget(NWID_VERTICAL), NWidget(NWID_HORIZONTAL), + NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_TRAIN_RAILTYPE_DROPDOWN), SetMinimalSize(136, 12), SetDataTip(0x0, STR_REPLACE_HELP_RAILTYPE), SetFill(1, 0), SetResize(1, 0), + NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_TRAIN_ENGINEWAGON_DROPDOWN), SetDataTip(STR_BLACK_STRING, STR_REPLACE_ENGINE_WAGON_SELECT_HELP), + EndContainer(), + NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), EndContainer(), + EndContainer(), + NWidget(NWID_VERTICAL), + NWidget(NWID_HORIZONTAL), NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_SORT_ASCENDING_DESCENDING), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER), SetFill(1, 1), NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_SORT_DROPDOWN), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_SORT_CRITERIA), EndContainer(), @@ -631,7 +627,10 @@ EndContainer(), NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_LEFT_DETAILS), SetMinimalSize(240, 122), SetResize(1, 0), EndContainer(), - NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_RIGHT_DETAILS), SetMinimalSize(240, 122), SetResize(1, 0), EndContainer(), + NWidget(NWID_VERTICAL), + NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_RIGHT_DETAILS), SetMinimalSize(240, 122), SetResize(1, 0), EndContainer(), + NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_TRAIN_WAGONREMOVE_TOGGLE), SetMinimalSize(138, 12), SetDataTip(STR_REPLACE_REMOVE_WAGON, STR_REPLACE_REMOVE_WAGON_HELP), SetFill(1, 0), SetResize(1, 0), + EndContainer(), EndContainer(), NWidget(NWID_HORIZONTAL), NWidget(NWID_PUSHBUTTON_DROPDOWN, COLOUR_GREY, WID_RV_START_REPLACE), SetMinimalSize(139, 12), SetDataTip(STR_REPLACE_VEHICLES_START, STR_REPLACE_HELP_START_BUTTON), @@ -638,13 +637,6 @@ NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_INFO_TAB), SetMinimalSize(167, 12), SetDataTip(0x0, STR_REPLACE_HELP_REPLACE_INFO_TAB), SetResize(1, 0), EndContainer(), NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_STOP_REPLACE), SetMinimalSize(150, 12), SetDataTip(STR_REPLACE_VEHICLES_STOP, STR_REPLACE_HELP_STOP_BUTTON), - EndContainer(), - NWidget(NWID_HORIZONTAL), - NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_TRAIN_ENGINEWAGON_TOGGLE), SetMinimalSize(139, 12), SetDataTip(STR_REPLACE_ENGINE_WAGON_SELECT, STR_REPLACE_ENGINE_WAGON_SELECT_HELP), - NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_TRAIN_FLUFF_LEFT), SetMinimalSize(15, 12), EndContainer(), - NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_TRAIN_RAILTYPE_DROPDOWN), SetMinimalSize(136, 12), SetDataTip(0x0, STR_REPLACE_HELP_RAILTYPE), SetResize(1, 0), - NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_TRAIN_FLUFF_RIGHT), SetMinimalSize(16, 12), EndContainer(), - NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_TRAIN_WAGONREMOVE_TOGGLE), SetMinimalSize(138, 12), SetDataTip(STR_REPLACE_REMOVE_WAGON, STR_REPLACE_REMOVE_WAGON_HELP), NWidget(WWT_RESIZEBOX, COLOUR_GREY), EndContainer(), }; Index: src/lang/english.txt =================================================================== --- src/lang/english.txt (revision 27682) +++ src/lang/english.txt (working copy) @@ -3557,10 +3557,10 @@ STR_REPLACE_VEHICLES_STOP :{BLACK}Stop Replacing Vehicles STR_REPLACE_HELP_STOP_BUTTON :{BLACK}Press to stop the replacement of the engine type selected on the left -STR_REPLACE_ENGINE_WAGON_SELECT :{BLACK}Replacing: {ORANGE}{STRING} STR_REPLACE_ENGINE_WAGON_SELECT_HELP :{BLACK}Switch between engine and wagon replacement windows STR_REPLACE_ENGINES :Engines STR_REPLACE_WAGONS :Wagons +STR_REPLACE_ALL_RAILTYPE :All rail vehicles STR_REPLACE_HELP_RAILTYPE :{BLACK}Choose the rail type you want to replace engines for STR_REPLACE_HELP_REPLACE_INFO_TAB :{BLACK}Displays which engine the left selected engine is being replaced with, if any Index: src/rail_gui.cpp =================================================================== --- src/rail_gui.cpp (revision 27682) +++ src/rail_gui.cpp (working copy) @@ -1981,9 +1981,10 @@ /** * Create a drop down list for all the rail types of the local company. * @param for_replacement Whether this list is for the replacement window. + * @param all_option Whether to add an 'all types' item. * @return The populated and sorted #DropDownList. */ -DropDownList *GetRailTypeDropDownList(bool for_replacement) +DropDownList *GetRailTypeDropDownList(bool for_replacement, bool all_option) { RailTypes used_railtypes = RAILTYPES_NONE; @@ -2000,6 +2001,12 @@ const Company *c = Company::Get(_local_company); DropDownList *list = new DropDownList(); + + if (all_option) { + DropDownListStringItem *item = new DropDownListStringItem(STR_REPLACE_ALL_RAILTYPE, INVALID_RAILTYPE, false); + *list->Append() = item; + } + RailType rt; FOR_ALL_SORTED_RAILTYPES(rt) { /* If it's not used ever, don't show it to the user. */ Index: src/rail_gui.h =================================================================== --- src/rail_gui.h (revision 27682) +++ src/rail_gui.h (working copy) @@ -19,6 +19,6 @@ void ReinitGuiAfterToggleElrail(bool disable); bool ResetSignalVariant(int32 = 0); void InitializeRailGUI(); -DropDownList *GetRailTypeDropDownList(bool for_replacement = false); +DropDownList *GetRailTypeDropDownList(bool for_replacement = false, bool all_option = false); #endif /* RAIL_GUI_H */ Index: src/widgets/autoreplace_widget.h =================================================================== --- src/widgets/autoreplace_widget.h (revision 27682) +++ src/widgets/autoreplace_widget.h (working copy) @@ -35,10 +35,8 @@ WID_RV_STOP_REPLACE, ///< Stop Replacing button. /* Train only widgets. */ - WID_RV_TRAIN_ENGINEWAGON_TOGGLE, ///< Button to toggle engines and/or wagons. - WID_RV_TRAIN_FLUFF_LEFT, ///< The fluff on the left. + WID_RV_TRAIN_ENGINEWAGON_DROPDOWN, ///< Dropdown to select engines and/or wagons. WID_RV_TRAIN_RAILTYPE_DROPDOWN, ///< Dropdown menu about the railtype. - WID_RV_TRAIN_FLUFF_RIGHT, ///< The fluff on the right. WID_RV_TRAIN_WAGONREMOVE_TOGGLE, ///< Button to toggle removing wagons. };
Mark as private
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
forever