6 protected CarControllerComponent m_pCarController;
7 protected CarControllerComponent_SA m_pCarController_SA;
9 protected SCR_InfoDisplayExtended m_pParentDisplayExtended;
14 protected int m_iFutureGear;
15 protected int m_iCurrentGear;
17 protected bool m_bAutomaticGearbox;
21 string GetGearSymbol(
bool automatic,
int gear,
int gearCount)
25 else if (gear >= gearCount)
34 return (gear-1).ToString();
39 void GetGearboxModeDisplay(
bool automatic,
int futureGear,
int currentGear)
44 VehicleWheeledSimulation simulation = m_pCarController.GetSimulation();
46 gearCount = simulation.GearboxGearsCount();
50 VehicleWheeledSimulation_SA simulation = m_pCarController_SA.GetSimulation();
52 gearCount = simulation.GearboxGearsCount();
66 int middleGear = lowerGear + 1;
67 int upperGear = middleGear + 1;
69 string lower = GetGearSymbol(automatic, lowerGear, gearCount);
70 string future = GetGearSymbol(automatic, middleGear, gearCount);
71 string upper = GetGearSymbol(automatic, upperGear, gearCount);
73 m_Widgets.m_LowerSelectedText.SetText(lower);
75 m_Widgets.m_MiddleSelectedText.SetText(future);
77 m_Widgets.m_UpperSelectedText.SetText(upper);
80 m_Widgets.m_LowerSelected.SetVisible(currentGear == lowerGear);
81 m_Widgets.m_Lower.SetVisible(currentGear != lowerGear);
82 m_Widgets.m_MiddleSelected.SetVisible(currentGear == middleGear);
83 m_Widgets.m_Middle.SetVisible(currentGear != middleGear);
84 m_Widgets.m_UpperSelected.SetVisible(currentGear == upperGear);
85 m_Widgets.m_Upper.SetVisible(currentGear != upperGear);
87 #ifdef DEBUG_GEARSHIFT
93 if (currentGear == lowerGear)
98 else if (currentGear == middleGear)
103 else if (currentGear == upperGear)
109 PrintFormat(
"%1%2%3%4%5%6%7", spacer1, lower, spacer2, future, spacer3, upper, spacer4);
114 private void ScalePaddings(Widget widget,
float scale)
119 Widget parent = widget.GetParent();
121 if (!(OverlayWidget.Cast(parent) || HorizontalLayoutWidget.Cast(parent) || VerticalLayoutWidget.Cast(parent)))
129 AlignableSlot.GetPadding(widget, left, top, right, bottom);
130 AlignableSlot.SetPadding(widget, left * scale, top * scale, right * scale, bottom * scale);
134 override void Scale(TextWidget widget,
float scale)
142 widget.GetTextSize(width, height);
144 height = Math.Round(height * scale);
147 widget.SetExactFontSize(size);
151 private void ScaleChildren(Widget widget)
153 Widget child = widget.GetChildren();
157 ScaleChildren(child);
159 ScalePaddings(child, m_fWidgetScale);
161 TextWidget text = TextWidget.Cast(child);
162 ImageWidget image = ImageWidget.Cast(child);
165 Scale(text, m_fWidgetScale);
168 Scale(image, m_fWidgetScale);
170 child = child.GetSibling();
176 override event void DisplayUpdate(IEntity owner,
float timeSlice)
183 if (!m_pCarController)
188 bool assistanceChanged = m_eDrivingAssistance != drivingAssistance;
190 if (assistanceChanged)
192 #ifdef DEBUG_GEARSHIFT
193 PrintFormat(
"Gear assistance changed from %1 -> %2", m_eDrivingAssistance, drivingAssistance);
196 m_eDrivingAssistance = drivingAssistance;
202 if (m_pParentDisplayExtended)
203 m_pParentDisplayExtended.Show(show);
211 bool automaticChanged = m_bAutomaticGearbox != automatic;
213 if (automaticChanged)
215 #ifdef DEBUG_GEARSHIFT
216 PrintFormat(
"Gearbox manual vs. automatic changed! automatic: %1", automaticChanged);
219 m_bAutomaticGearbox = automatic;
222 int futureGear = m_pCarController.GetFutureGear();
223 int currentGear = m_pCarController.GetCurrentGear();
226 if (!assistanceChanged && futureGear == m_iFutureGear && currentGear == m_iCurrentGear)
229 m_iFutureGear = futureGear;
230 m_iCurrentGear = currentGear;
232 GetGearboxModeDisplay(automatic, futureGear, currentGear);
236 if (!m_pCarController_SA)
241 bool assistanceChanged = m_eDrivingAssistance != drivingAssistance;
243 if (assistanceChanged)
245 #ifdef DEBUG_GEARSHIFT
246 PrintFormat(
"Gear assistance changed from %1 -> %2", m_eDrivingAssistance, drivingAssistance);
249 m_eDrivingAssistance = drivingAssistance;
255 if (m_pParentDisplayExtended)
256 m_pParentDisplayExtended.Show(show);
264 bool automaticChanged = m_bAutomaticGearbox != automatic;
266 if (automaticChanged)
268 #ifdef DEBUG_GEARSHIFT
269 PrintFormat(
"Gearbox manual vs. automatic changed! automatic: %1", automaticChanged);
272 m_bAutomaticGearbox = automatic;
275 int futureGear = m_pCarController_SA.GetFutureGear();
276 int currentGear = m_pCarController_SA.GetCurrentGear();
279 if (!assistanceChanged && futureGear == m_iFutureGear && currentGear == m_iCurrentGear)
282 m_iFutureGear = futureGear;
283 m_iCurrentGear = currentGear;
285 GetGearboxModeDisplay(automatic, futureGear, currentGear);
291 override bool DisplayStartDrawInit(IEntity owner)
300 if (!m_pCarController)
305 if (!m_pCarController_SA)
310 if (m_LayoutPath ==
"")
311 m_LayoutPath =
"{5FBB1623E3CD1DF2}UI/layouts/HUD/VehicleInfo/VehicleGearShift.layout";
321 override void DisplayStartDraw(IEntity owner)
333 m_eDrivingAssistance = -1;
334 m_bAutomaticGearbox =
false;
339 override void DisplayInit(IEntity owner)
345 m_pCarController = CarControllerComponent.Cast(owner.FindComponent(CarControllerComponent));
347 m_pCarController_SA = CarControllerComponent_SA.Cast(owner.FindComponent(CarControllerComponent_SA));