Description:
Refactor out magic variable.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -18,7 +18,8 | |||
|
18 | 18 | private MouseState mousePrev; |
|
19 | 19 | |
|
20 | 20 | private static int bar_height = 25; |
|
21 | ||
|
21 | private static int height = 500; | |
|
22 | private static int width = 700; | |
|
22 | 23 | |
|
23 | 24 | public BudgetWindow(Budget budget, SpriteFont font, int start_x, int start_y) |
|
24 | 25 | { |
@@ -34,7 +35,7 | |||
|
34 | 35 | this.budget = budget; |
|
35 | 36 | |
|
36 | 37 | if ((mouseCur.LeftButton == ButtonState.Pressed) |
|
37 |
&& MathUtils.Between(mouseCur.X, |
|
|
38 | && MathUtils.Between(mouseCur.X, width+x-20, width+x) | |
|
38 | 39 | && MathUtils.Between(mouseCur.Y, y+bar_height, y+bar_height+20) |
|
39 | 40 | ) { |
|
40 | 41 | |
@@ -42,7 +43,7 | |||
|
42 | 43 | |
|
43 | 44 | } |
|
44 | 45 | else if ((mouseCur.LeftButton == ButtonState.Pressed) |
|
45 |
&& MathUtils.Between(mouseCur.X, x, |
|
|
46 | && MathUtils.Between(mouseCur.X, x, width+x) | |
|
46 | 47 | && MathUtils.Between(mouseCur.Y, y, 500 + y)) |
|
47 | 48 | { |
|
48 | 49 | if (mousePrev.LeftButton == ButtonState.Released) |
@@ -53,7 +54,7 | |||
|
53 | 54 | else |
|
54 | 55 | { |
|
55 | 56 | this.mouseEnd = new Vector2(mouseCur.X, mouseCur.Y); |
|
56 |
this.x = MathUtils.Clamp(this.x + (int)(this.mouseEnd.X - this.mouseStart.X), 0, |
|
|
57 | this.x = MathUtils.Clamp(this.x + (int)(this.mouseEnd.X - this.mouseStart.X), 0, width); | |
|
57 | 58 | this.y = MathUtils.Clamp(this.y + (int)(this.mouseEnd.Y - this.mouseStart.Y), 0, 400); |
|
58 | 59 | } |
|
59 | 60 | } |
@@ -62,27 +63,23 | |||
|
62 | 63 | |
|
63 | 64 | this.mousePrev = mouseCur; |
|
64 | 65 | |
|
65 | // Console.Write(mouseCur.ToString()); | |
|
66 | ||
|
67 | 66 | return true; |
|
68 | ||
|
69 | 67 | } |
|
70 | 68 | |
|
71 | 69 | public void draw(SpriteBatch batch) |
|
72 | 70 | { |
|
73 | 71 | |
|
74 | 72 | |
|
75 | int height = 500; | |
|
76 | 73 | |
|
77 | 74 | FilledRectangle.drawFilledRectangle(batch, new Rectangle(x - 20, y+bar_height, 20, height), Color.White); |
|
78 | 75 | Line.drawLine(batch, new Vector2(x, y + bar_height), new Vector2(x, y + bar_height + height), Color.Gray); |
|
79 |
FilledRectangle.drawFilledRectangle(batch, new Rectangle(x + |
|
|
80 |
Line.drawLine(batch, new Vector2(x + |
|
|
76 | FilledRectangle.drawFilledRectangle(batch, new Rectangle(x + width, y+bar_height, 20, height), Color.White); | |
|
77 | Line.drawLine(batch, new Vector2(x + width, y + bar_height), new Vector2(x + width, y + bar_height + height), Color.Gray); | |
|
81 | 78 | |
|
82 | 79 | for (int i = 1; i <= (height / bar_height); i++) |
|
83 | 80 | { |
|
84 | 81 | Rectangle position = new Rectangle(this.x, bar_height * i + this.y, |
|
85 |
|
|
|
82 | width, bar_height); | |
|
86 | 83 | |
|
87 | 84 | if ((i % 2) == 0) |
|
88 | 85 | { |
@@ -94,9 +91,9 | |||
|
94 | 91 | } |
|
95 | 92 | } |
|
96 | 93 | |
|
97 |
FilledRectangle.drawFilledRectangle(batch, new Rectangle(x + |
|
|
94 | FilledRectangle.drawFilledRectangle(batch, new Rectangle(x + width - 20, y+bar_height, 20, 20), Color.LightGray); | |
|
98 | 95 | Vector2 dimensions = font.MeasureString("X"); |
|
99 |
batch.DrawString(font, "X", new Vector2(x+ |
|
|
96 | batch.DrawString(font, "X", new Vector2(x+width -20 + (dimensions.X/2), y+bar_height), Color.Black); | |
|
100 | 97 | |
|
101 | 98 | batch.DrawString(font, String.Format("BUDGET REPORT FOR {0:MMMMM yyyy}", this.budget.DateTime), new Vector2(x, bar_height * 1 + y), Color.Black); |
|
102 | 99 |
You need to be logged in to leave comments.
Login now