Browse Source

merging windows fix and local changes

master
cinnaboot 8 years ago
parent
commit
1b2c1afb51
  1. 116
      src/hexgame.cpp
  2. 7
      src/hexgame.h
  3. 5
      src/imgui.ini
  4. 2
      src/renderer.h

116
src/hexgame.cpp

@ -88,9 +88,7 @@ getSingleHex(int32 x, int32 y)
for (hex_info &hxi : *g_game_state->hex_array)
{
if (hex_equal(h, hxi.hex))
{
return &hxi;
}
}
return 0;
@ -111,34 +109,29 @@ startHexFill(int32 x, int32 y)
resetHexes();
hex_info *hex = getSingleHex(x, y);
if (hex)
{
setStartHex(hex);
}
}
void
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);
if (hxi && (hxi != g_game_state->current_hex))
{
g_game_state->current_hex = hxi;
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;
}
else
{
h.selected = false;
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;
}
}
}
@ -150,38 +143,33 @@ startHexLineDraw(int32 x, int32 y)
resetHexes();
hex_info *hex = getSingleHex(x, y);
if (hex)
{
setStartHex(hex);
}
}
void
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);
if (hxi && (hxi != g_game_state->current_hex))
{
g_game_state->current_hex = hxi;
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];
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)
{
h1.selected = false;
h1.current_color = h1.stored_color;
}
h1.selected = false;
h1.current_color = h1.stored_color;
}
}
}
@ -194,39 +182,33 @@ startHexConeFill(int32 x, int32 y)
resetHexes();
hex_info *hex = getSingleHex(x, y);
if (hex)
{
setStartHex(hex);
}
}
void
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);
if (hxi && (hxi != g_game_state->current_hex))
g_game_state->current_hex = hxi;
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
// cones/arbitrary polygons
if (&h == g_game_state->start_hex)
{
continue;
}
if (hex_equal(h.hex, hxi->hex))
{
h.selected = true;
h.current_color = g_render_state->selected_fill_color;
}
else
{
h.selected = false;
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;
case SDL_MOUSEMOTION:
if (!gooey_wants)
if (!gooey_wants && g_game_state->is_selecting)
handleMouseMove(e.motion);
break;
default:

7
src/hexgame.h

@ -5,7 +5,11 @@
#include <vector>
#include <cassert>
#include <SDL.h>
#if defined (_WIN32)
#include <SDL.h>
#else
#include <SDL2/SDL.h>
#endif
#include "aixlog.hpp"
#include "hexlib.h"
@ -109,3 +113,4 @@ SafeTruncateToInt32(int64 val)
}
#endif // HEXGAME_H

5
src/imgui.ini

@ -0,0 +1,5 @@
[Window][Debug##Default]
Pos=0,5
Size=400,400
Collapsed=0

2
src/renderer.h

@ -493,7 +493,7 @@ renderDebug(hex_info *start_hex, hex_info *current_hex)
Point p2(current_hex->XPos, current_hex->YPos);
real64 angle = std::atan2(p2.y - p1.y, p2.x - p1.x);
real64 len = std::hypot(p2.y - p1.y, p2.x - p1.x);
real64 coneAngle = 24.5f * M_PI / 180; // M_PI is non-standard and may not be portable
real64 coneAngle = 30.f * M_PI / 180; // M_PI is non-standard and may not be portable
// TODO: add matrix math library for rotation transform?
// |x| | cos(a + b) -sin(a + b) 0 |

Loading…
Cancel
Save