Skip to content

Commit

Permalink
Merge pull request #12 from Disquse/master
Browse files Browse the repository at this point in the history
Fix bar position and width
  • Loading branch information
thers committed Aug 18, 2017
2 parents 51b02f2 + d09f9f2 commit bf59a9f
Showing 1 changed file with 38 additions and 3 deletions.
41 changes: 38 additions & 3 deletions HUD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class HUD
{
protected Scaleform buttons = new Scaleform("instructional_buttons");

protected float fuelBarWidth = 180f;
protected float fuelBarWidth = GetBarWidth();
protected float fuelBarHeight = 6f;

protected Color fuelBarColourNormal;
Expand Down Expand Up @@ -123,10 +123,12 @@ public void RenderBar(float currentFuelLevel, float maxFuelLevel)
public static PointF GetSafezoneBounds()
{
float t = Function.Call<float>(Hash.GET_SAFE_ZONE_SIZE);
float w = Screen.Width;
float h = Screen.Height;

return new PointF(
(int) Math.Round((1280 - (1280 * t)) / 2),
(int) Math.Round((720 - (720 * t)) / 2)
(int) Math.Round((w - (w * t)) / 2 + 1),
(int) Math.Round((h - (h * t)) / 2 - 2)
);
}

Expand All @@ -144,6 +146,39 @@ public void InstructTurnOffEngine()
buttons.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
}

/// <summary>
/// Returns resolution specified bar width
/// </summary>
/// <returns></returns>
public static float GetBarWidth()
{
float width;
double aspect = Screen.AspectRatio;

switch (aspect)
{
case (float)1.5: // 3:2
width = 212f;
break;
case (float)1.33333337306976: // 4:3
width = 240f;
break;
case (float)1.66666662693024: // 5:3
width = 191f;
break;
case (float)1.25: // 5:4
width = 255f;
break;
case (float)1.60000002384186: // 16:10
width = 200f;
break;
default:
width = 180f; // 16:9
break;
}
return width;
}

/// <summary>
/// Change instructions for refueling and engine spin up
/// </summary>
Expand Down

0 comments on commit bf59a9f

Please sign in to comment.