mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-01-24 17:26:41 +00:00
Fix uninitialized glLineWidth() when rendering nodes; use green color for nodes that have a script
That would explain why nodes were drawn with thin lines whenever DebugText was on screen...
This commit is contained in:
parent
9cd9601485
commit
69ae4bdb20
4 changed files with 34 additions and 21 deletions
|
@ -222,7 +222,7 @@ Path::~Path()
|
|||
destroy();
|
||||
}
|
||||
|
||||
bool Path::hasScript()
|
||||
bool Path::hasScript() const
|
||||
{
|
||||
return script != 0;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
void song(SongType song);
|
||||
void songNote(int note);
|
||||
void songNoteDone(int note, float len);
|
||||
bool hasScript();
|
||||
bool hasScript() const;
|
||||
std::string name; // full node string
|
||||
std::string label; // first part only (the actual node name)
|
||||
std::vector<PathNode>nodes;
|
||||
|
|
|
@ -36,28 +36,40 @@ void PathRender::onRender(const RenderState& rs) const
|
|||
if (pathcount == 0)
|
||||
return;
|
||||
|
||||
glLineWidth(4);
|
||||
|
||||
const size_t selidx = dsq->game->sceneEditor.selectedIdx;
|
||||
|
||||
for (size_t i = 0; i < pathcount; i++)
|
||||
{
|
||||
Path *p = dsq->game->getPath(i);
|
||||
const Path *p = dsq->game->getPath(i);
|
||||
|
||||
if (dsq->game->sceneEditor.selectedIdx == i)
|
||||
glColor4f(1, 1, 1, 0.75);
|
||||
if (selidx == i)
|
||||
glColor4f(1, 1, 1, 0.75f);
|
||||
else if(p->hasScript())
|
||||
glColor4f(0.5f, 0.8f, 0.5f, 0.75f);
|
||||
else
|
||||
glColor4f(1, 0.5, 0.5, 0.75);
|
||||
glColor4f(1, 0.5f, 0.5f, 0.75f);
|
||||
|
||||
glBegin(GL_LINES);
|
||||
for (size_t n = 0; n < p->nodes.size()-1; n++)
|
||||
{
|
||||
PathNode *nd = &p->nodes[n];
|
||||
PathNode *nd2 = &p->nodes[n+1];
|
||||
const PathNode *nd = &p->nodes[n];
|
||||
const PathNode *nd2 = &p->nodes[n+1];
|
||||
glVertex3f(nd->position.x, nd->position.y, 0);
|
||||
glVertex3f(nd2->position.x, nd2->position.y, 0);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
glLineWidth(1);
|
||||
|
||||
for (size_t i = 0; i < pathcount; i++)
|
||||
{
|
||||
const Path *p = dsq->game->getPath(i);
|
||||
for (size_t n = 0; n < p->nodes.size(); n++)
|
||||
{
|
||||
PathNode *nd = &p->nodes[n];
|
||||
const PathNode *nd = &p->nodes[n];
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
|
@ -85,22 +97,25 @@ void PathRender::onRender(const RenderState& rs) const
|
|||
}
|
||||
else
|
||||
{
|
||||
glColor4f(0.5f, 0.5f, 1, 0.5f);
|
||||
glColor4f(0.5f, 0.5f, 1, 0.4f);
|
||||
glTranslatef(nd->position.x, nd->position.y, 0);
|
||||
drawCircle(p->rect.getWidth()*0.5f, 16);
|
||||
glTranslatef(-nd->position.x, -nd->position.y, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Vector color = p->hasScript() ? Vector(0.5f, 0.8f, 0.5f) : Vector(1, 0.5f, 0.5f);
|
||||
float a = 0.75f;
|
||||
if (!p->active)
|
||||
{
|
||||
a = 0.3f;
|
||||
color *= 0.5f;
|
||||
}
|
||||
|
||||
if (dsq->game->sceneEditor.selectedIdx == i)
|
||||
glColor4f(1, 1, 1, a);
|
||||
else
|
||||
glColor4f(1, 0.5, 0.5, a);
|
||||
if (selidx == i)
|
||||
color.x = color.y = color.z = 1;
|
||||
|
||||
glColor4f(color.x, color.y, color.z, a);
|
||||
glPushMatrix();
|
||||
glTranslatef(nd->position.x, nd->position.y, 0);
|
||||
drawCircle(32);
|
||||
|
|
12
BBGE/Rect.h
12
BBGE/Rect.h
|
@ -31,8 +31,8 @@ public:
|
|||
{
|
||||
x1 = y1 = x2 = y2 = 0;
|
||||
}
|
||||
int getWidth() { return x2-x1; }
|
||||
int getHeight() { return y2-y1; }
|
||||
int getWidth() const { return x2-x1; }
|
||||
int getHeight() const { return y2-y1; }
|
||||
void setWidth(int v)
|
||||
{
|
||||
x1 = -v/2;
|
||||
|
@ -45,8 +45,6 @@ public:
|
|||
}
|
||||
void setCWH(int x, int y, int w, int h)
|
||||
{
|
||||
|
||||
|
||||
const int w2 = w / 2;
|
||||
const int h2 = h / 2;
|
||||
x1 = x - w2;
|
||||
|
@ -54,18 +52,18 @@ public:
|
|||
x2 = x + w2;
|
||||
y2 = y + h2;
|
||||
}
|
||||
void getCWH(int *x, int *y, int *w, int *h)
|
||||
void getCWH(int *x, int *y, int *w, int *h) const
|
||||
{
|
||||
*w = x2 - x1;
|
||||
*h = y2 - y1;
|
||||
*x = x1 + ((*w) / 2);
|
||||
*y = y1 + ((*h) / 2);
|
||||
}
|
||||
bool isCoordinateInside(const Vector &vec, int radius=0)
|
||||
bool isCoordinateInside(const Vector &vec, int radius=0) const
|
||||
{
|
||||
return ((vec.x >= x1-radius && vec.x <= x2+radius) && (vec.y >= y1-radius && vec.y <= y2+radius));
|
||||
}
|
||||
bool isEmpty()
|
||||
bool isEmpty() const
|
||||
{
|
||||
return x1 != 0 || y1 != 0 || x2 != 0 || y2 != 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue