Changeset - r21522:b4ce9e6ca733
[Not reviewed]
master
0 1 0
frosch - 10 years ago 2014-06-10 16:29:03
frosch@openttd.org
(svn r26639) -Codechange: Simplify drawing early/late dates in timetable GUI.
1 file changed with 8 insertions and 18 deletions:
0 comments (0 inline, 0 general)
src/timetable_gui.cpp
Show inline comments
 
@@ -47,36 +47,24 @@ struct TimetableArrivalDeparture {
 
void SetTimetableParams(int param1, int param2, Ticks ticks)
 
{
 
	if (_settings_client.gui.timetable_in_ticks) {
 
		SetDParam(param1, STR_TIMETABLE_TICKS);
 
		SetDParam(param2, ticks);
 
	} else {
 
		SetDParam(param1, STR_TIMETABLE_DAYS);
 
		SetDParam(param2, ticks / DAY_TICKS);
 
	}
 
}
 

	
 
/**
 
 * Sets the arrival or departure string and parameters.
 
 * @param param1 the first DParam to fill
 
 * @param param2 the second DParam to fill
 
 * @param ticks  the number of ticks to 'draw'
 
 */
 
static void SetArrivalDepartParams(int param1, int param2, Ticks ticks)
 
{
 
	SetDParam(param1, STR_JUST_DATE_TINY);
 
	SetDParam(param2, _date + (ticks / DAY_TICKS));
 
}
 

	
 
/**
 
 * Check whether it is possible to determine how long the order takes.
 
 * @param order the order to check.
 
 * @param travelling whether we are interested in the travel or the wait part.
 
 * @return true if the travel/wait time can be used.
 
 */
 
static bool CanDetermineTimeTaken(const Order *order, bool travelling)
 
{
 
	/* Current order is conditional */
 
	if (order->IsType(OT_CONDITIONAL) || order->IsType(OT_IMPLICIT)) return false;
 
	/* No travel time and we have not already finished travelling */
 
	if (travelling && !order->IsTravelTimetabled()) return false;
 
	/* No wait time but we are loading at this timetabled station */
 
@@ -453,36 +441,38 @@ struct TimetableWindow : Window {
 
				int abbr_right = rtl ? r.right - WD_FRAMERECT_RIGHT : r.left + WD_FRAMERECT_LEFT + this->deparr_abbr_width;
 
				int time_left  = rtl ? r.left + WD_FRAMERECT_LEFT : r.right - WD_FRAMERECT_RIGHT - this->deparr_time_width;
 
				int time_right = rtl ? r.left + WD_FRAMERECT_LEFT + this->deparr_time_width : r.right - WD_FRAMERECT_RIGHT;
 

	
 
				for (int i = this->vscroll->GetPosition(); i / 2 < v->GetNumOrders(); ++i) { // note: i is also incremented in the loop
 
					/* Don't draw anything if it extends past the end of the window. */
 
					if (!this->vscroll->IsVisible(i)) break;
 

	
 
					if (i % 2 == 0) {
 
						if (arr_dep[i / 2].arrival != INVALID_TICKS) {
 
							DrawString(abbr_left, abbr_right, y, STR_TIMETABLE_ARRIVAL_ABBREVIATION, i == selected ? TC_WHITE : TC_BLACK);
 
							if (this->show_expected && i / 2 == earlyID) {
 
								SetArrivalDepartParams(0, 1, arr_dep[i / 2].arrival);
 
								DrawString(time_left, time_right, y, STR_GREEN_STRING, i == selected ? TC_WHITE : TC_BLACK);
 
								SetDParam(0, _date + arr_dep[i / 2].arrival / DAY_TICKS);
 
								DrawString(time_left, time_right, y, STR_JUST_DATE_TINY, TC_GREEN);
 
							} else {
 
								SetArrivalDepartParams(0, 1, arr_dep[i / 2].arrival + offset);
 
								DrawString(time_left, time_right, y, show_late ? STR_RED_STRING : STR_JUST_STRING, i == selected ? TC_WHITE : TC_BLACK);
 
								SetDParam(0, _date + (arr_dep[i / 2].arrival + offset) / DAY_TICKS);
 
								DrawString(time_left, time_right, y, STR_JUST_DATE_TINY,
 
										show_late ? TC_RED : i == selected ? TC_WHITE : TC_BLACK);
 
							}
 
						}
 
					} else {
 
						if (arr_dep[i / 2].departure != INVALID_TICKS) {
 
							DrawString(abbr_left, abbr_right, y, STR_TIMETABLE_DEPARTURE_ABBREVIATION, i == selected ? TC_WHITE : TC_BLACK);
 
							SetArrivalDepartParams(0, 1, arr_dep[i/2].departure + offset);
 
							DrawString(time_left, time_right, y, show_late ? STR_RED_STRING : STR_JUST_STRING, i == selected ? TC_WHITE : TC_BLACK);
 
							SetDParam(0, _date + (arr_dep[i/2].departure + offset) / DAY_TICKS);
 
							DrawString(time_left, time_right, y, STR_JUST_DATE_TINY,
 
									show_late ? TC_RED : i == selected ? TC_WHITE : TC_BLACK);
 
						}
 
					}
 
					y += FONT_HEIGHT_NORMAL;
 
				}
 
				break;
 
			}
 

	
 
			case WID_VT_SUMMARY_PANEL: {
 
				int y = r.top + WD_FRAMERECT_TOP;
 

	
 
				Ticks total_time = v->orders.list != NULL ? v->orders.list->GetTimetableDurationIncomplete() : 0;
 
				if (total_time != 0) {
0 comments (0 inline, 0 general)