Skip to content

Commit

Permalink
gutter flash now works
Browse files Browse the repository at this point in the history
  • Loading branch information
miatribe committed Jan 26, 2018
1 parent 2e80d22 commit 0b30d5e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion GutterLines/Window.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 19 additions & 5 deletions GutterLines/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ static void Main()
public Window()
{
InitializeComponent();
flashAlert = GetAlertToggleBool();
CreateContextMenu();
StartPosition = FormStartPosition.Manual;
SetWindowPos();
Expand All @@ -70,7 +71,7 @@ private void CreateContextMenu()
ContextMenu = new ContextMenu(new[]
{
new MenuItem("Reset Window Position", ResetWindowPos),
//alertToggle = new MenuItem($"Show When in Gutter (Current:{GetAlertToggleBool()})", ToggleAlert),
alertToggle = new MenuItem($"Show When in Gutter (Current:{flashAlert})", ToggleAlert),
new MenuItem("-"),
new MenuItem("Exit GutterLines", ExitBtn_Click)
}),
Expand Down Expand Up @@ -101,7 +102,7 @@ private bool GetAlertToggleBool()
{
return Convert.ToBoolean(key?.GetValue("alertToggle"));
}
catch { return true; }
catch { return false; }
}
}

Expand All @@ -115,7 +116,7 @@ private void UpdateWindow(object sender, EventArgs e)
{
lat = gi.Lat;
lon = gi.Lon;
DrawGutters(gi.Lat, gi.Lon);
DrawGutters(gi.Lat, gi.Lon, GutterAlert());
}
}
else
Expand All @@ -124,10 +125,23 @@ private void UpdateWindow(object sender, EventArgs e)
}
}

private void DrawGutters(int playerX, int playerY)
private Color GutterAlert()
{
if (flashAlert)
{
//check both lat and lon to see if the player is in a gutter line, if they are make the backgroud color non white
if (lat % 40 <= 4 || lon % 40 <= 4)
{
return Color.Orange;
}
}
return Color.White;
}

private void DrawGutters(int playerX, int playerY, Color backCol)
{
Graphics g = gridMap.CreateGraphics();
g.Clear(gridMap.BackColor);
g.Clear(backCol);
for (int i = 4; i >= 0; i--)
{
var gutterPosX = GetGutterLinePos(playerX, i) * gridScale;
Expand Down

0 comments on commit 0b30d5e

Please sign in to comment.