Browse Source

remove current_color, stored_color from hex_info

master
cinnaboot 8 years ago
parent
commit
6b30acd386
  1. 11
      src/hexgame.cpp
  2. 17
      src/hexgrid.cpp
  3. 2
      src/hexgrid.h

11
src/hexgame.cpp

@ -179,7 +179,6 @@ void
setStartHex(hex_info *hex)
{
hex->selected = true;
hex->current_color = g_game_state->grid.selected_fill_color;
g_game_state->grid.start_hex = g_game_state->grid.current_hex = hex;
g_game_state->grid.is_selecting = true;
}
@ -225,17 +224,7 @@ handleMouseDown(SDL_MouseButtonEvent &e)
v2f v = cameraUnproject(g_render_state->cam, coords.x, coords.y, dims.x, dims.y);
hex_info *hex = hgGetSingleHex(g_game_state->grid, v.x, v.y);
if (hex)
{
hex->selected = !hex->selected;
if (hex->selected)
{
hex->current_color = g_game_state->grid.selected_fill_color;
}
else
{
hex->current_color = hex->stored_color;
}
}
}break;
}
}

17
src/hexgrid.cpp

@ -44,7 +44,6 @@ hgResetHexes(hexgrid& hg)
for (hex_info &hxi : *hg.hex_array) {
hxi.selected = false;
hxi.current_color = hxi.stored_color;
}
}
@ -60,15 +59,9 @@ hgUpdateHexFill(hexgrid& hg, int32 x, int32 y)
for (hex_info &h : *hg.hex_array)
{
if (hex_distance(hg.start_hex->hex, h.hex) <= l)
{
h.selected = true;
h.current_color = hg.selected_fill_color;
}
else
{
h.selected = false;
h.current_color = h.stored_color;
}
}
}
}
@ -90,13 +83,11 @@ hgUpdateHexLineDraw(hexgrid& hg, int32 x, int32 y)
if (hex_equal(h1.hex, h2))
{
h1.selected = true;
h1.current_color = hg.selected_fill_color;
break;
}
else if (i == hexLine.size() - 1)
{
h1.selected = false;
h1.current_color = h1.stored_color;
}
}
}
@ -138,15 +129,9 @@ hgUpdateHexConeFill(hexgrid& hg, int32 x, int32 y, float cone_angle, std::vector
test_p.y = h.YPos;
if (crossingTest(vertices, test_p))
{
h.selected = true;
h.current_color = hg.selected_fill_color;
}
else
{
h.selected = false;
h.current_color = h.stored_color;
}
}
debug_vertices[0] = p1;
@ -202,8 +187,6 @@ createHexagonGrid(hexgrid hg)
Point p = hex_to_pixel(hg.hexlib_layout, hxi.hex);
hxi.XPos = p.x;
hxi.YPos = p.y;
hxi.current_color = hg.fill_color;
hxi.stored_color = hg.fill_color;
hxi.vertices = polygon_corners(hg.hexlib_layout, hxi.hex);
hxi.vertices.shrink_to_fit();
hg.hex_array->push_back(hxi);

2
src/hexgrid.h

@ -33,8 +33,6 @@ struct hex_info
Hex hex = {};
real64 XPos = 0;
real64 YPos = 0;
uint32 current_color = 0; // RGBA
uint32 stored_color = 0; // RGBA
bool selected = false;
std::vector<Point> vertices;
};

Loading…
Cancel
Save