-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUI.cs
48 lines (43 loc) · 1.68 KB
/
UI.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using SFML.Graphics;
using SFML.System;
namespace LilRogue
{
public class UI : Grid<char>
{
private Grid<char> grid;
public UI(Grid<char> grid, int width, int height)
: base(width, height)
{
this.grid = grid;
this.grid.Width = width;
this.grid.Height = height;
}
public void DrawBorderedBox(int x, int y, int width, int height, Color borderColor, Color fillColor)
{
// Draw top border
grid.SetCell(x, y, '/', borderColor, fillColor, Color.Black, 1);
for (int i = 1; i < width - 1; i++)
{
grid.SetCell(x + i, y, '-', borderColor, fillColor, Color.Black, 1);
}
grid.SetCell(x + width - 1, y, '\\', borderColor, fillColor, Color.Black, 1);
// Draw middle rows
for (int j = 1; j < height - 1; j++)
{
grid.SetCell(x, y + j, '|', borderColor, fillColor, Color.Black, 1);
for (int i = 1; i < width - 1; i++)
{
grid.SetCell(x + i, y + j, ' ', borderColor, fillColor, Color.Black, 1);
}
grid.SetCell(x + width - 1, y + j, '|', borderColor, fillColor, Color.Black, 1);
}
// Draw bottom border
grid.SetCell(x, y + height - 1, '\\', borderColor, fillColor, Color.Black, 1);
for (int i = 1; i < width - 1; i++)
{
grid.SetCell(x + i, y + height - 1, '-', borderColor, fillColor, Color.Black, 1);
}
grid.SetCell(x + width - 1, y + height - 1, '/', borderColor, fillColor, Color.Black, 1);
}
}
}