|
|
|
@ -88,9 +88,7 @@ getSingleHex(int32 x, int32 y) |
|
|
|
for (hex_info &hxi : *g_game_state->hex_array) |
|
|
|
for (hex_info &hxi : *g_game_state->hex_array) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (hex_equal(h, hxi.hex)) |
|
|
|
if (hex_equal(h, hxi.hex)) |
|
|
|
{ |
|
|
|
|
|
|
|
return &hxi; |
|
|
|
return &hxi; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
@ -111,34 +109,29 @@ startHexFill(int32 x, int32 y) |
|
|
|
resetHexes(); |
|
|
|
resetHexes(); |
|
|
|
hex_info *hex = getSingleHex(x, y); |
|
|
|
hex_info *hex = getSingleHex(x, y); |
|
|
|
if (hex) |
|
|
|
if (hex) |
|
|
|
{ |
|
|
|
|
|
|
|
setStartHex(hex); |
|
|
|
setStartHex(hex); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
updateHexFill(int32 x, int32 y) |
|
|
|
updateHexFill(int32 x, int32 y) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (g_game_state->is_selecting) |
|
|
|
hex_info *hxi = getSingleHex(x, y); |
|
|
|
|
|
|
|
if (hxi && (hxi != g_game_state->current_hex)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
hex_info *hxi = getSingleHex(x, y); |
|
|
|
g_game_state->current_hex = hxi; |
|
|
|
if (hxi && (hxi != g_game_state->current_hex)) |
|
|
|
int l = hex_distance(g_game_state->start_hex->hex, g_game_state->current_hex->hex); |
|
|
|
{ |
|
|
|
|
|
|
|
g_game_state->current_hex = hxi; |
|
|
|
|
|
|
|
int l = hex_distance(g_game_state->start_hex->hex, g_game_state->current_hex->hex); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (hex_info &h : *g_game_state->hex_array) |
|
|
|
for (hex_info &h : *g_game_state->hex_array) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (hex_distance(g_game_state->start_hex->hex, h.hex) <= l) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (hex_distance(g_game_state->start_hex->hex, h.hex) <= l) |
|
|
|
h.selected = true; |
|
|
|
{ |
|
|
|
h.current_color = g_render_state->selected_fill_color; |
|
|
|
h.selected = true; |
|
|
|
} |
|
|
|
h.current_color = g_render_state->selected_fill_color; |
|
|
|
else |
|
|
|
} |
|
|
|
{ |
|
|
|
else |
|
|
|
h.selected = false; |
|
|
|
{ |
|
|
|
h.current_color = h.stored_color; |
|
|
|
h.selected = false; |
|
|
|
|
|
|
|
h.current_color = h.stored_color; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -150,38 +143,33 @@ startHexLineDraw(int32 x, int32 y) |
|
|
|
resetHexes(); |
|
|
|
resetHexes(); |
|
|
|
hex_info *hex = getSingleHex(x, y); |
|
|
|
hex_info *hex = getSingleHex(x, y); |
|
|
|
if (hex) |
|
|
|
if (hex) |
|
|
|
{ |
|
|
|
|
|
|
|
setStartHex(hex); |
|
|
|
setStartHex(hex); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
updateHexLineDraw(int32 x, int32 y) |
|
|
|
updateHexLineDraw(int32 x, int32 y) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (g_game_state->is_selecting) |
|
|
|
hex_info *hxi = getSingleHex(x, y); |
|
|
|
|
|
|
|
if (hxi && (hxi != g_game_state->current_hex)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
hex_info *hxi = getSingleHex(x, y); |
|
|
|
g_game_state->current_hex = hxi; |
|
|
|
if (hxi && (hxi != g_game_state->current_hex)) |
|
|
|
vector<Hex> hexLine = hex_linedraw(g_game_state->start_hex->hex, hxi->hex); |
|
|
|
{ |
|
|
|
|
|
|
|
g_game_state->current_hex = hxi; |
|
|
|
|
|
|
|
vector<Hex> hexLine = hex_linedraw(g_game_state->start_hex->hex, hxi->hex); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (hex_info &h1 : *g_game_state->hex_array) |
|
|
|
for (hex_info &h1 : *g_game_state->hex_array) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
for (uint i = 0; i < hexLine.size(); i++) |
|
|
|
{
|
|
|
|
{
|
|
|
|
for (uint32 i = 0; i < hexLine.size(); i++) |
|
|
|
Hex h2 = hexLine[i]; |
|
|
|
|
|
|
|
if (hex_equal(h1.hex, h2)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
h1.selected = true; |
|
|
|
|
|
|
|
h1.current_color = g_render_state->selected_fill_color; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (i == hexLine.size() - 1) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Hex h2 = hexLine[i]; |
|
|
|
h1.selected = false; |
|
|
|
if (hex_equal(h1.hex, h2)) |
|
|
|
h1.current_color = h1.stored_color; |
|
|
|
{ |
|
|
|
|
|
|
|
h1.selected = true; |
|
|
|
|
|
|
|
h1.current_color = g_render_state->selected_fill_color; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (i == hexLine.size() - 1) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
h1.selected = false; |
|
|
|
|
|
|
|
h1.current_color = h1.stored_color; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -194,39 +182,33 @@ startHexConeFill(int32 x, int32 y) |
|
|
|
resetHexes(); |
|
|
|
resetHexes(); |
|
|
|
hex_info *hex = getSingleHex(x, y); |
|
|
|
hex_info *hex = getSingleHex(x, y); |
|
|
|
if (hex) |
|
|
|
if (hex) |
|
|
|
{ |
|
|
|
|
|
|
|
setStartHex(hex); |
|
|
|
setStartHex(hex); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
updateHexConeFill(int32 x, int32 y) |
|
|
|
updateHexConeFill(int32 x, int32 y) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (g_game_state->is_selecting) |
|
|
|
hex_info *hxi = getSingleHex(x, y); |
|
|
|
|
|
|
|
if (hxi && (hxi != g_game_state->current_hex)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
hex_info *hxi = getSingleHex(x, y); |
|
|
|
g_game_state->current_hex = hxi; |
|
|
|
if (hxi && (hxi != g_game_state->current_hex)) |
|
|
|
|
|
|
|
|
|
|
|
for (hex_info &h : *g_game_state->hex_array) |
|
|
|
{ |
|
|
|
{ |
|
|
|
g_game_state->current_hex = hxi; |
|
|
|
// TODO: define a system of linear inequalities in hex-space to represent
|
|
|
|
|
|
|
|
// cones/arbitrary polygons
|
|
|
|
|
|
|
|
if (&h == g_game_state->start_hex) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
for (hex_info &h : *g_game_state->hex_array) |
|
|
|
if (hex_equal(h.hex, hxi->hex)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// TODO: define a system of linear inequalities in hex-space to represent
|
|
|
|
h.selected = true; |
|
|
|
// cones/arbitrary polygons
|
|
|
|
h.current_color = g_render_state->selected_fill_color; |
|
|
|
if (&h == g_game_state->start_hex) |
|
|
|
} |
|
|
|
{ |
|
|
|
else |
|
|
|
continue; |
|
|
|
{ |
|
|
|
} |
|
|
|
h.selected = false; |
|
|
|
if (hex_equal(h.hex, hxi->hex)) |
|
|
|
h.current_color = h.stored_color; |
|
|
|
{ |
|
|
|
|
|
|
|
h.selected = true; |
|
|
|
|
|
|
|
h.current_color = g_render_state->selected_fill_color; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
h.selected = false; |
|
|
|
|
|
|
|
h.current_color = h.stored_color; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -370,7 +352,7 @@ processSDLEvents(SDL_Handles &handles) |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case SDL_MOUSEMOTION: |
|
|
|
case SDL_MOUSEMOTION: |
|
|
|
if (!gooey_wants) |
|
|
|
if (!gooey_wants && g_game_state->is_selecting) |
|
|
|
handleMouseMove(e.motion); |
|
|
|
handleMouseMove(e.motion); |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
|