Changeset - r13143:ccc9275e2818
[Not reviewed]
master
0 3 0
rubidium - 15 years ago 2009-09-28 12:38:35
rubidium@openttd.org
(svn r17658) -Codechange: remove custom drawing of the signal density in the signal GUI
-Codechange: move the state updates from OnPaint
3 files changed with 25 insertions and 15 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -3996,12 +3996,13 @@ STR_BLACK_CROSS                         
 
STR_SILVER_CROSS                                                :{SILVER}{CROSS}
 
STR_WHITE_DATE_SHORT                                            :{WHITE}{DATE_SHORT}
 
STR_WHITE_DATE_LONG                                             :{WHITE}{DATE_LONG}
 
STR_SHORT_DATE                                                  :{WHITE}{DATE_TINY}
 
STR_DATE_LONG_SMALL                                             :{TINYFONT}{BLACK}{DATE_LONG}
 
STR_TINY_GROUP                                                  :{TINYFONT}{GROUP}
 
STR_ORANGE_INT                                                  :{ORANGE}{NUM}
 
STR_WHITE_SIGN                                                  :{WHITE}{SIGN}
 
STR_TINY_BLACK_STATIONL                                         :{TINYFONT}{BLACK}{STATION}
 
STR_BLACK_STRING                                                :{BLACK}{STRING}
 
STR_BLACK_RAW_STRING                                            :{BLACK}{RAW_STRING}
 
STR_WHITE_STRING                                                :{WHITE}{STRING}
 
STR_TINY_BLACK_VEHICLE                                          :{TINYFONT}{BLACK}{VEHICLE}
src/rail_gui.cpp
Show inline comments
 
@@ -1509,12 +1509,13 @@ enum BuildSignalWidgets {
 
	BSW_ELECTRIC_EXIT,
 
	BSW_ELECTRIC_COMBO,
 
	BSW_ELECTRIC_PBS,
 
	BSW_ELECTRIC_PBS_OWAY,
 
	BSW_CONVERT,
 
	BSW_DRAG_SIGNALS_DENSITY,
 
	BSW_DRAG_SIGNALS_DENSITY_LABEL,
 
	BSW_DRAG_SIGNALS_DENSITY_DECREASE,
 
	BSW_DRAG_SIGNALS_DENSITY_INCREASE,
 
};
 

	
 
struct BuildSignalWindow : public PickerWindowBase {
 
private:
 
@@ -1553,23 +1554,26 @@ private:
 
	}
 

	
 
public:
 
	BuildSignalWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(parent)
 
	{
 
		this->InitNested(desc, TRANSPORT_RAIL);
 
		this->OnInvalidateData();
 
	};
 

	
 
	virtual void SetStringParameters(int widget) const
 
	{
 
		switch (widget) {
 
			case BSW_DRAG_SIGNALS_DENSITY_LABEL:
 
				SetDParam(0, _settings_client.gui.drag_signals_density);
 
				break;
 
		}
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		this->LowerWidget((_cur_signal_variant == SIG_ELECTRIC ? BSW_ELECTRIC_NORM : BSW_SEMAPHORE_NORM) + _cur_signal_type);
 

	
 
		this->SetWidgetLoweredState(BSW_CONVERT, _convert_signal_button);
 

	
 
		this->SetWidgetDisabledState(BSW_DRAG_SIGNALS_DENSITY_DECREASE, _settings_client.gui.drag_signals_density == 1);
 
		this->SetWidgetDisabledState(BSW_DRAG_SIGNALS_DENSITY_INCREASE, _settings_client.gui.drag_signals_density == 20);
 

	
 
		this->DrawWidgets();
 

	
 
		this->DrawSignalSprite(BSW_SEMAPHORE_NORM,     SPR_IMG_SIGNAL_SEMAPHORE_NORM);
 
		this->DrawSignalSprite(BSW_SEMAPHORE_ENTRY,    SPR_IMG_SIGNAL_SEMAPHORE_ENTRY);
 
		this->DrawSignalSprite(BSW_SEMAPHORE_EXIT,     SPR_IMG_SIGNAL_SEMAPHORE_EXIT);
 
		this->DrawSignalSprite(BSW_SEMAPHORE_COMBO,    SPR_IMG_SIGNAL_SEMAPHORE_COMBO);
 
@@ -1578,18 +1582,12 @@ public:
 
		this->DrawSignalSprite(BSW_ELECTRIC_NORM,      SPR_IMG_SIGNAL_ELECTRIC_NORM);
 
		this->DrawSignalSprite(BSW_ELECTRIC_ENTRY,     SPR_IMG_SIGNAL_ELECTRIC_ENTRY);
 
		this->DrawSignalSprite(BSW_ELECTRIC_EXIT,      SPR_IMG_SIGNAL_ELECTRIC_EXIT);
 
		this->DrawSignalSprite(BSW_ELECTRIC_COMBO,     SPR_IMG_SIGNAL_ELECTRIC_COMBO);
 
		this->DrawSignalSprite(BSW_ELECTRIC_PBS,       SPR_IMG_SIGNAL_ELECTRIC_PBS);
 
		this->DrawSignalSprite(BSW_ELECTRIC_PBS_OWAY,  SPR_IMG_SIGNAL_ELECTRIC_PBS_OWAY);
 

	
 
		/* Draw dragging signal density value in the BSW_DRAG_SIGNALS_DENSITY widget */
 
		SetDParam(0, _settings_client.gui.drag_signals_density);
 
		int right = this->GetWidget<NWidgetBase>(BSW_DRAG_SIGNALS_DENSITY)->pos_x + this->GetWidget<NWidgetBase>(BSW_DRAG_SIGNALS_DENSITY)->current_x - 1;
 
		DrawString(this->GetWidget<NWidgetBase>(BSW_DRAG_SIGNALS_DENSITY)->pos_x, right,
 
				this->GetWidget<NWidgetBase>(BSW_DRAG_SIGNALS_DENSITY)->pos_y + 2, STR_JUST_INT, TC_ORANGE, SA_CENTER);
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget)
 
	{
 
		switch (widget) {
 
			case BSW_SEMAPHORE_NORM:
 
@@ -1629,12 +1627,23 @@ public:
 
				break;
 

	
 
			default: break;
 
		}
 

	
 
		this->SetDirty();
 
		this->OnInvalidateData();
 
	}
 

	
 
	virtual void OnInvalidateData(int data = 0)
 
	{
 
		this->LowerWidget((_cur_signal_variant == SIG_ELECTRIC ? BSW_ELECTRIC_NORM : BSW_SEMAPHORE_NORM) + _cur_signal_type);
 

	
 
		this->SetWidgetLoweredState(BSW_CONVERT, _convert_signal_button);
 

	
 
		this->SetWidgetDisabledState(BSW_DRAG_SIGNALS_DENSITY_DECREASE, _settings_client.gui.drag_signals_density == 1);
 
		this->SetWidgetDisabledState(BSW_DRAG_SIGNALS_DENSITY_INCREASE, _settings_client.gui.drag_signals_density == 20);
 
	}
 
};
 

	
 
/** Nested widget definition of the build signal window */
 
static const NWidgetPart _nested_signal_builder_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
@@ -1655,13 +1664,13 @@ static const NWidgetPart _nested_signal_
 
		NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BSW_ELECTRIC_ENTRY), SetMinimalSize(22, 27), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TOOLTIP), EndContainer(),
 
		NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BSW_ELECTRIC_EXIT), SetMinimalSize(22, 27), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_EXIT_TOOLTIP), EndContainer(),
 
		NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BSW_ELECTRIC_COMBO), SetMinimalSize(22, 27), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_COMBO_TOOLTIP), EndContainer(),
 
		NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BSW_ELECTRIC_PBS), SetMinimalSize(22, 27), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_PBS_TOOLTIP), EndContainer(),
 
		NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BSW_ELECTRIC_PBS_OWAY), SetMinimalSize(22, 27), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_PBS_OWAY_TOOLTIP), EndContainer(),
 
		NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BSW_DRAG_SIGNALS_DENSITY), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_TOOLTIP),
 
			NWidget(NWID_SPACER), SetMinimalSize(0, 13),
 
			NWidget(WWT_LABEL, COLOUR_DARK_GREEN, BSW_DRAG_SIGNALS_DENSITY_LABEL), SetMinimalSize(0, 13), SetDataTip(STR_ORANGE_INT, STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_TOOLTIP), SetFill(true, true),
 
			NWidget(NWID_HORIZONTAL), SetPIP(2, 0, 2),
 
				NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, BSW_DRAG_SIGNALS_DENSITY_DECREASE), SetMinimalSize(9, 12), SetDataTip(SPR_ARROW_LEFT, STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_DECREASE_TOOLTIP),
 
				NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, BSW_DRAG_SIGNALS_DENSITY_INCREASE), SetMinimalSize(9, 12), SetDataTip(SPR_ARROW_RIGHT, STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_INCREASE_TOOLTIP),
 
			EndContainer(),
 
			NWidget(NWID_SPACER), SetMinimalSize(0, 2),
 
		EndContainer(),
src/settings.cpp
Show inline comments
 
@@ -748,13 +748,13 @@ static bool TrainAccelerationModelChange
 

	
 
	return true;
 
}
 

	
 
static bool DragSignalsDensityChanged(int32)
 
{
 
	SetWindowDirty(WC_BUILD_SIGNAL, 0);
 
	InvalidateWindowData(WC_BUILD_SIGNAL, 0);
 

	
 
	return true;
 
}
 

	
 
/*
 
 * A: competitors
0 comments (0 inline, 0 general)