Example #1
0
void TextNavigation::onUpdate( float t )
{
	WindowText::onUpdate( t );

	if ( visible() && activeTime() > UPDATE_NAV_TEXT )
	{
		setActiveTime( 0 );

		GameDocument * pDoc = (GameDocument *)document();
		ASSERT( pDoc );

		CharString sText;
		if ( pDoc->isTeamValid() )
		{
			GameContext * pContext = pDoc->context();
			ASSERT( pContext );

			Hash< dword, Array<NounPlanet *> >	factionPlanets;
			Hash< dword, Array<NounShip *> >	factionShips;

			int	nStars = 0;
			int	nAsteroids = 0;
			int	nGates = 0;

			// get the players teamId
			int nFactionId = pDoc->factionId();
			// push all detected objects
			for(int z=0;z<pContext->zoneCount();z++)
			{
				NodeZone * pZone = pContext->zone( z );
				for(int i=0;i<pZone->childCount();i++)
				{
					NounGame * pNoun = WidgetCast<NounGame>( pZone->child(i) );
					if (! pNoun )
						continue;

					if ( pNoun->isDetected( nFactionId ) )
					{
						if ( WidgetCast<NounShip>( pNoun ) )
							factionShips[ pNoun->factionId() ].push( (NounShip *)pNoun );
						else if ( WidgetCast<NounPlanet>( pNoun ) )
							factionPlanets[ pNoun->factionId() ].push( (NounPlanet *)pNoun );
						else if ( WidgetCast<NounStar>( pNoun ) )
							nStars++;
						else if ( WidgetCast<NounAsteroid>( pNoun ) )
							nAsteroids++;
						else if ( WidgetCast<NounJumpGate>( pNoun ) )
							nGates++;
					}
				}
			}

			// update navigation text information
			const GameContext::Team & fleet = pContext->team( pDoc->teamId() );
			sText += CharString().format( "<b;l>%s</b;/l>:\n", fleet.name );

			Array< NounShip * > & ships = factionShips[ fleet.factionId ];

			sText += CharString().format("<x;10>Ships:<x;150>%d\n", ships.size() );
			for(int k=0;k<NounShip::TYPE_COUNT;k++)
			{
				// how many ships of this type
				int count = 0;
				for(int j=0;j<ships.size();j++)
					if ( ships[j]->type() == (NounShip::Type)k )
						count++;

				if ( count > 0 )
					sText += CharString().format( "<X;20>%s:<X;150>%d\n", NounShip::typeText( (NounShip::Type)k ), count );
			}

			if ( factionPlanets.find( fleet.factionId ).valid() )
			{
				Array< NounPlanet *> & planets = factionPlanets[ fleet.factionId ];
				sText += CharString().format("<X;10>Planets:<X;150>%d\n", planets.size() );

				int population = 0;
				int ports = 0;
				int depots = 0;
				int yards = 0;
				int units = 0;

				for(int j=0;j<planets.size();j++)
				{
					NounPlanet * pPlanet = planets[ j ];
					population += pPlanet->population();
					units += pPlanet->friendlyUnitCount();

					if ( pPlanet->flags() & NounPlanet::FLAG_HAS_DEPOT )
						depots++;
					if ( pPlanet->flags() & NounPlanet::FLAG_HAS_PORT )
						ports++;
					if ( pPlanet->flags() & NounPlanet::FLAG_HAS_SHIPYARD )
						yards++;
				}

				if ( population > 0 )
					sText += CharString().format( "<X;20>Population:<X;150>%d\n", population );
				if ( units > 0 )
					sText += CharString().format( "<X;20>Units:<X;150>%d\n", units );
				if ( ports > 0 )
					sText += CharString().format( "<X;20>Ports:<X;150>%d\n", ports );
				if ( depots > 0 )
					sText += CharString().format( "<X;20>Depots:<X;150>%d\n", depots );
				if ( yards > 0 )
					sText += CharString().format( "<X;20>Ship Yards:<X;150>%d\n", yards );
			}
		}

		setText( sText );
	}
}
Example #2
0
bool KisBaseNode::isEditable() const
{
    return ( visible() && !userLocked() && !systemLocked() );
}
Example #3
0
void KisBaseNode::setSectionModelProperties(const KoDocumentSectionModel::PropertyList &properties)
{
    setVisible(properties.at(0).state.toBool());
    dbgImage << "visible = " << properties.at(0).state.toBool() << " " << visible();
    setUserLocked(properties.at(1).state.toBool());
}
Example #4
0
// =================
void sphere_chase (edict_t *self, int stupidChase)
{
	vec3_t	dest;
	vec3_t	dir;
	float	dist;

	if(level.time >= self->wait || (self->enemy && self->enemy->health < 1))
	{
		sphere_think_explode(self);
		return;
	}

	VectorCopy (self->enemy->s.origin, dest);
	if(self->enemy->client)
		dest[2] += self->enemy->viewheight;

	if(visible(self, self->enemy) || stupidChase)
	{
		// if moving, hunter sphere uses active sound
		if(!stupidChase)
			self->s.sound = gi.soundindex ("spheres/h_active.wav");

		VectorSubtract (dest, self->s.origin, dir);
		VectorNormalize (dir);
		vectoangles2(dir, self->s.angles);
		VectorScale (dir, 500, self->velocity);
		VectorCopy(dest, self->monsterinfo.saved_goal);
	}
	else if (VectorCompare (self->monsterinfo.saved_goal, vec3_origin))
	{
		VectorSubtract(self->enemy->s.origin, self->s.origin, dir);
		vectoangles2(dir, self->s.angles);

		// if lurking, hunter sphere uses lurking sound
		self->s.sound = gi.soundindex ("spheres/h_lurk.wav");
		VectorClear (self->velocity);
	}
	else
	{
		VectorSubtract(self->monsterinfo.saved_goal, self->s.origin, dir);
		dist = VectorNormalize(dir);

		if(dist > 1)
		{
			vectoangles2(dir, self->s.angles);

			if(dist > 500)			
				VectorScale(dir, 500, self->velocity);
			else if (dist < 20)
				VectorScale(dir, (dist / FRAMETIME), self->velocity);
			else
				VectorScale(dir, dist, self->velocity);

			// if moving, hunter sphere uses active sound
			if(!stupidChase)
				self->s.sound = gi.soundindex ("spheres/h_active.wav");
		}
		else
		{
			VectorSubtract(self->enemy->s.origin, self->s.origin, dir);
			vectoangles2(dir, self->s.angles);

			// if not moving, hunter sphere uses lurk sound
			if(!stupidChase)
				self->s.sound = gi.soundindex ("spheres/h_lurk.wav");

			VectorClear(self->velocity);
		}
	}
}
	void PictureOverlay::draw(const Gfx3D::ShaderProgram::Ptr& shader) const
	{
		if (!visible() || !shader || !shader->valid() || !pTexture)
			return;

		// Set shaders
		shader->activate();
		::glActiveTexture(GL_TEXTURE0);
		::glBindTexture(GL_TEXTURE_2D, pTexture->id());
		shader->bindUniform("Texture0", Yuni::Gfx3D::Vertex<>::vaTexture0);

		const float texWidth = (float)pTexture->width();
		const float texHeight = (float)pTexture->height();
		const float overlayWidth = (float)pWidth;
		const float overlayHeight = (float)pHeight;
		// pDisplay == dmNone
		float offsetX = 0.0f;
		float offsetY = 0.0f;
		if (pDisplay == dmOffset)
		{
			offsetX = (float)pOffsetX;
			offsetY = (float)pOffsetY;
		}
		else if (pDisplay == dmCenter)
		{
			offsetX = (texWidth - overlayWidth) / 2.0f;
			offsetY = (texHeight - overlayHeight) / 2.0f;
		}
		float minTexX = 0.0f;
		float maxTexX = 1.0f;
		float minTexY = 0.0f;
		float maxTexY = 1.0f;
		float xStart = (float)pX;
		float yStart = (float)pY;
		float xEnd = xStart + overlayWidth;
		float yEnd = yStart + overlayHeight;
		switch (pDisplay)
		{
			case dmStretch:
				// Nothing to do, coordinates are perfect
				break;
			case dmNone:
			case dmOffset:
			case dmCenter:
				if (offsetX > 0.0f)
				{
					// Fix texture coordinates
					minTexX = offsetX / texWidth;
					if (minTexX < 0.0f)
						minTexX = 0.0f;
				}
				if (texWidth > overlayWidth + offsetX)
				{
					// Fix texture coordinates
					maxTexX = (overlayWidth + offsetX) / texWidth;
					if (maxTexX > 1.0f)
						maxTexX = 1.0f;
				}
				if (offsetY > 0.0f)
				{
					minTexY = offsetY / texHeight;
					if (minTexY < 0.0f)
						minTexY = 0.0f;
				}
				if (texHeight > overlayHeight + offsetY)
				{
					maxTexY = (overlayHeight + offsetY) / texHeight;
					if (maxTexY > 1.0f)
						maxTexY = 1.0f;
				}
				break;
			case dmFit:
				// TODO
				break;
			case dmFill:
				// TODO
				break;
			default:
				assert(false && "Invalid enum value for PictureOverlay::Display !");
				break;
		}

		shader->bindUniform("Bounds", xStart, yStart, texWidth + xStart, texHeight + yStart);
		shader->bindUniform("FillColor", pFillColor);

		// Set texture coordinates
		const float texCoord[] =
			{
				minTexX, minTexY,
				minTexX, maxTexY,
				maxTexX, minTexY,
				maxTexX, minTexY,
				minTexX, maxTexY,
				maxTexX, maxTexY
			};
		::glEnableVertexAttribArray(Gfx3D::Vertex<>::vaTextureCoord);
		::glVertexAttribPointer(Gfx3D::Vertex<>::vaTextureCoord, 2, GL_FLOAT, 0, 0, texCoord);
		// Set vertex positions
		const float vertices[] =
			{
				xStart, yStart,
				xStart, yEnd,
				xEnd, yStart,
				xEnd, yStart,
				xStart, yEnd,
				xEnd, yEnd
			};
		::glEnableVertexAttribArray(Gfx3D::Vertex<>::vaPosition);
		::glVertexAttribPointer(Gfx3D::Vertex<>::vaPosition, 2, GL_FLOAT, 0, 0, vertices);
		// Draw
		::glDrawArrays(GL_TRIANGLES, 0, 6);

		// Clean-up
		::glDisableVertexAttribArray(Gfx3D::Vertex<>::vaPosition);
		::glDisableVertexAttribArray(Gfx3D::Vertex<>::vaTextureCoord);
		::glBindTexture(GL_TEXTURE_2D, 0);
		shader->deactivate();
	}
Example #6
0
edict_t *LookingAt(edict_t *ent, int filter, vec3_t endpos, float *range)
{
    edict_t *who;
    edict_t *trigger[MAX_EDICTS];
    edict_t *ignore;
    trace_t tr;
    vec_t   r;
    vec3_t  end, forward, start;
    vec3_t  dir, entp, mins, maxs;
    int     i, num;

    if (!ent->client)
    {
        if (endpos)
        {
            VectorClear(endpos);
        }
        if (range)
        {
            *range = 0;
        }
        return NULL;
    }
    VectorClear(end);
    if (ent->client->chasetoggle)
    {
        AngleVectors(ent->client->v_angle, forward, NULL, NULL);
        VectorCopy(ent->client->chasecam->s.origin, start);
        ignore = ent->client->chasecam;
    }
    else if (ent->client->spycam)
    {
        AngleVectors(ent->client->ps.viewangles, forward, NULL, NULL);
        VectorCopy(ent->s.origin, start);
        ignore = ent->client->spycam;
    }
    else
    {
        AngleVectors(ent->client->v_angle, forward, NULL, NULL);
        VectorCopy(ent->s.origin, start);
        start[2] += ent->viewheight;
        ignore    = ent;
    }

    VectorMA(start, 8192, forward, end);

    /* First check for looking directly at a pickup item */
    VectorSet(mins, -4096, -4096, -4096);
    VectorSet(maxs, 4096, 4096, 4096);
    num = gi.BoxEdicts(mins, maxs, trigger, MAX_EDICTS, AREA_TRIGGERS);
    for (i = 0; i < num; i++)
    {
        who = trigger[i];
        if (!who->inuse)
        {
            continue;
        }
        if (!who->item)
        {
            continue;
        }
        if (!visible(ent, who))
        {
            continue;
        }
        if (!infront(ent, who))
        {
            continue;
        }
        VectorSubtract(who->s.origin, start, dir);
        r = VectorLength(dir);
        VectorMA(start, r, forward, entp);
        if (entp[0] < who->s.origin[0] - 17)
        {
            continue;
        }
        if (entp[1] < who->s.origin[1] - 17)
        {
            continue;
        }
        if (entp[2] < who->s.origin[2] - 17)
        {
            continue;
        }
        if (entp[0] > who->s.origin[0] + 17)
        {
            continue;
        }
        if (entp[1] > who->s.origin[1] + 17)
        {
            continue;
        }
        if (entp[2] > who->s.origin[2] + 17)
        {
            continue;
        }
        if (endpos)
        {
            VectorCopy(who->s.origin, endpos);
        }
        if (range)
        {
            *range = r;
        }
        return who;
    }

    tr = gi.trace(start, NULL, NULL, end, ignore, MASK_SHOT);
    if (tr.fraction == 1.0)
    {
        // too far away
        gi.sound(ent, CHAN_AUTO, gi.soundindex("misc/talk1.wav"), 1, ATTN_NORM, 0);
        return NULL;
    }
    if (!tr.ent)
    {
        // no hit
        gi.sound(ent, CHAN_AUTO, gi.soundindex("misc/talk1.wav"), 1, ATTN_NORM, 0);
        return NULL;
    }
    if (!tr.ent->classname)
    {
        // should never happen
        gi.sound(ent, CHAN_AUTO, gi.soundindex("misc/talk1.wav"), 1, ATTN_NORM, 0);
        return NULL;
    }

    if ((strstr(tr.ent->classname, "func_") != NULL) && (filter & LOOKAT_NOBRUSHMODELS))
    {
        // don't hit on brush models
        gi.sound(ent, CHAN_AUTO, gi.soundindex("misc/talk1.wav"), 1, ATTN_NORM, 0);
        return NULL;
    }
    if ((Q_strcasecmp(tr.ent->classname, "worldspawn") == 0) && (filter & LOOKAT_NOWORLD))
    {
        // world brush
        gi.sound(ent, CHAN_AUTO, gi.soundindex("misc/talk1.wav"), 1, ATTN_NORM, 0);
        return NULL;
    }
    if (endpos)
    {
        endpos[0] = tr.endpos[0];
        endpos[1] = tr.endpos[1];
        endpos[2] = tr.endpos[2];
    }
    if (range)
    {
        VectorSubtract(tr.endpos, start, start);
        *range = VectorLength(start);
    }
    return tr.ent;
}
Example #7
0
void UcClassCanvas::draw(QPainter & p) {
  if (! visible()) return;
  p.setRenderHint(QPainter::Antialiasing, true);
  QRect r = rect();
  QFontMetrics fm(the_canvas()->get_font(UmlNormalFont));
  QFontMetrics fim(the_canvas()->get_font(UmlNormalItalicFont));
  QColor bckgrnd = p.backgroundColor();
  double zoom = the_canvas()->zoom();
  FILE * fp = svg();

  if (fp != 0)
    fputs("<g>\n", fp);

  p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode);

  QColor co = color(used_color);
  
  if (used_view_mode == asClass) {
    if (used_color != UmlTransparent) {
      const int shadow = the_canvas()->shadow();

      if (shadow != 0) {
	r.setRight(r.right() - shadow);
	r.setBottom(r.bottom() - shadow);
	
	p.fillRect (r.right(), r.top() + shadow,
		    shadow, r.height() - 1,
		    ::Qt::darkGray);
	p.fillRect (r.left() + shadow, r.bottom(),
		    r.width() - 1, shadow,
		    ::Qt::darkGray);

	if (fp != 0) {
	  fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		  " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		  QColor(::Qt::darkGray).rgb()&0xffffff,
		  r.right(), r.top() + shadow, shadow - 1, r.height() - 1 - 1);

	  fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		  " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		  QColor(::Qt::darkGray).rgb()&0xffffff,
		  r.left() + shadow, r.bottom(), r.width() - 1 - 1, shadow - 1);
	}
      }
    }
    
    p.setBackgroundColor(co);
  
    if (used_color != UmlTransparent) {
      p.fillRect(r, co);

      if (fp != 0)
	fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		svg_color(used_color), 
		r.x(), r.y(), r.width() - 1, r.height() - 1);
    }
    else if (fp != 0)
      fprintf(fp, "\t<rect fill=\"none\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      r.x(), r.y(), r.width() - 1, r.height() - 1);

    p.drawRect(r);
  }
  
  const ClassData * data = ((ClassData *) browser_node->get_data());
  const int two = (int) (2 * zoom);
  int he = fm.height() + two;
  
  if (data->get_n_formalparams() != 0)
    r.setTop(r.top() + fm.height());
  
  switch (used_view_mode) {
  case asInterface:
    draw_interface_icon(p, r, used_color, zoom);
    r.setTop(r.top() + (int) (INTERFACE_SIZE * zoom) + two);
    break;
  case asControl:
    draw_control_icon(p, r, used_color, zoom);
    r.setTop(r.top() + (int) (CONTROL_HEIGHT * zoom) + two);
    break;
  case asBoundary:
    draw_boundary_icon(p, r, used_color, zoom);
    r.setTop(r.top() + (int) (BOUNDARY_HEIGHT * zoom) + two);
    break;
  case asEntity:
    draw_entity_icon(p, r, used_color, zoom);
    r.setTop(r.top() + (int) (ENTITY_SIZE * zoom) + two);
    break;
  case asActor:
    {
      QRect ra = r;
      
      ra.setHeight((int) (ACTOR_SIZE * zoom));
      ra.setLeft(ra.left() + 
		 (int) ((ra.width() - ACTOR_SIZE * zoom)/2));
      ra.setWidth(ra.height());
      draw_actor(&p, ra);
    }
    r.setTop(r.top() + (int) (ACTOR_SIZE * zoom) + two);
    break;
  case Natural:
    {
      const QPixmap * px = 
	ProfiledStereotypes::diagramPixmap(data->get_stereotype(), zoom);
      int lft = (px->width() < width()) ? r.x() + (width() - px->width())/2 : r.x();

      p.drawPixmap(lft, r.y(), *px);
      if (fp != 0)
	// pixmap not really exported in SVG
	fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		svg_color(UmlBlack), lft, r.y(), px->width() - 1, px->height() - 1);

      r.setTop(r.top() + px->height());
    }
    break;
  default:	// class
    r.setTop(r.top() + two);
    if (data->get_stereotype()[0]) {
      p.setFont(the_canvas()->get_font(UmlNormalFont));
      p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop, 
		 QString("<<") + toUnicode(data->get_short_stereotype()) + ">>");
      if (fp != 0)
	draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop, 
		  QString("<<") + toUnicode(data->get_short_stereotype()) + ">>",
		  p.font(), fp);
      r.setTop(r.top() + he + two);
    }
  }
  
  p.setBackgroundMode(::Qt::TransparentMode);
  p.setFont((data->get_is_abstract())
	    ? the_canvas()->get_font(UmlNormalItalicFont)
	    : the_canvas()->get_font(UmlNormalFont));
  p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop, full_name);
  if (fp != 0)
    draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop, full_name, p.font(), fp);

  p.setFont(the_canvas()->get_font(UmlNormalFont));
  
  if (used_view_mode == asClass) {
    r.setTop(r.top() + he);
    p.drawLine(r.topLeft(), r.topRight());
    
    if (fp != 0)
      fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
	      " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
	      r.left(), r.top(), r.right(), r.top());
    
    r.setTop(r.top() + (int) (8 * zoom));
    p.drawLine(r.topLeft(), r.topRight());
    
    if (fp != 0)
      fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
	      " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
	      r.left(), r.top(), r.right(), r.top());
  }
  
  if (fp != 0)
    fputs("</g>\n", fp);
    
  p.setBackgroundColor(bckgrnd);
  
  if (selected())
    show_mark(p, rect());
}
Example #8
0
qboolean hintcheck_monsterlost(edict_t *monster)
{
    edict_t  *ent;
    edict_t  *monster_node_list, *target_node_list, *prev_node;
    edict_t  *closest_node, *start_node, *dest_node;
    int      i;
    float    node_dist, closest_dist;
    qboolean monster_pathchains_listed[MAX_HINT_CHAINS], target_pathchains_listed[MAX_HINT_CHAINS];
    qboolean nodes_found = false;

    // If monster is standing at post, has no enemy,
    // or there are no hint_path chains in this map, get outta here.
    if ((monster->monsterinfo.aiflags & AI_STAND_GROUND) ||
        !monster->enemy || !hint_chains_exist)
    {
        return false;
    }

    monster_node_list = NULL;
    // Create linked list of all hint_path nodes in level
    for (i = 0; i < hint_chain_count; i++)
    {
        ent = hint_chain_starts[i];
        while (ent)
        {               // Clean up previous monster_hint_chain pointers
            if (ent->monster_hint_chain)
            {
                ent->monster_hint_chain = NULL;
            }
            if (!monster_node_list)              // add first node
            {
                monster_node_list = ent;
                prev_node         = ent;
            }
            else
            {
                prev_node->monster_hint_chain = ent;
                prev_node = ent;
            }
            ent = ent->hint_chain;
        }
    }

    // Remove inaccessible to monster nodes from monster_node_list linked list.
    ent       = monster_node_list;
    prev_node = NULL;
    while (ent)
    {
        node_dist = realrange(monster, ent);
        if ((node_dist > HINT_NODE_RANGE) || !visible(monster, ent))
        {
            if (!prev_node)
            {
                edict_t *temp = ent;
                ent = ent->monster_hint_chain;
                temp->monster_hint_chain = NULL;
                // Since there is no previous valid node, move start pointer up to our new position.
                monster_node_list = ent;
                continue;
            }
            else
            {
                prev_node->monster_hint_chain = ent->monster_hint_chain;
                ent->monster_hint_chain       = NULL;
                ent = prev_node->monster_hint_chain;
                continue;
            }
        }
        nodes_found = true;
        prev_node   = ent;
        ent         = ent->monster_hint_chain;
    }

    // If no hint_path nodes are accessible to the monster, get outta here.
    if (!nodes_found)
    {
        return false;
    }

/*
 *      We now have a linked list of all hint_path nodes accessible to the monster.
 *
 *      The next step is to create a list of pathchains that the monster can access.
 */

    // Go through all monster- accessible nodes to see which pathchains have nodes in the linked list.
    for (i = 0; i < hint_chain_count; i++)
    {
        monster_pathchains_listed[i] = false;
    }
    ent = monster_node_list;
    while (ent)
    {           // catch errors
        if ((ent->hint_chain_id < 0) || (ent->hint_chain_id > hint_chain_count))
        {
            return false;
        }
        monster_pathchains_listed[ent->hint_chain_id] = true;
        ent = ent->monster_hint_chain;
    }

    // Build a linked list of all nodes in the pathchains accessible to the monster.
    // This will be used to find nodes that are accessible to the monster's enemy.
    target_node_list = NULL;
    prev_node        = NULL;
    for (i = 0; i < hint_chain_count; i++)
    {
        if (monster_pathchains_listed[i])         // If pathchain is listed, add it to our new linked list.
        {
            ent = hint_chain_starts[i];
            while (ent)
            {
                if (!target_node_list)                 // add first node
                {
                    target_node_list = ent;
                    prev_node        = ent;
                }
                else
                {
                    prev_node->target_hint_chain = ent;
                    prev_node = ent;
                }
                ent = ent->hint_chain;
            }
        }
    }

    // Remove inaccessible to monster's enemy nodes from target_node_list linked list.
    ent         = target_node_list;
    prev_node   = NULL;
    nodes_found = false;
    while (ent)
    {
        node_dist = realrange(monster->enemy, ent);
        if ((node_dist > HINT_NODE_RANGE) || !visible(monster->enemy, ent))
        {
            if (!prev_node)
            {
                edict_t *temp = ent;
                ent = ent->target_hint_chain;
                temp->target_hint_chain = NULL;
                // Since there is no previous valid node, move start pointer up to our new position.
                target_node_list = ent;
                continue;
            }
            else
            {
                prev_node->target_hint_chain = ent->target_hint_chain;
                ent->target_hint_chain       = NULL;
                ent = prev_node->target_hint_chain;
                continue;
            }
        }
        nodes_found = true;
        prev_node   = ent;
        ent         = ent->target_hint_chain;
    }

    // If no hint_path nodes would bring us to our enemy, get outta here.
    if (!nodes_found)
    {
        return false;
    }

/*
 *      We now have two linked lists- one of hint_path nodes accessible to the monster, and one of hint_path nodes
 *      near the monster's enemy that are accessible from nodes near the monster.
 *
 *      The next step is to find the closest node near the monster that will lead it to its enemy,
 */

    // Go through all monster's enemy-accessible nodes to see which pathchains have nodes in the linked list.
    for (i = 0; i < hint_chain_count; i++)
    {
        target_pathchains_listed[i] = false;
    }
    ent = target_node_list;
    while (ent)
    {           // catch errors
        if ((ent->hint_chain_id < 0) || (ent->hint_chain_id > hint_chain_count))
        {
            return false;
        }
        target_pathchains_listed[ent->hint_chain_id] = true;
        ent = ent->target_hint_chain;
    }

    // Go through monster_node_list linked list to find the closest node to us
    // that leads to the monster's enemy (on the list).
    closest_dist = HINT_NODE_RANGE;
    closest_node = NULL;
    ent          = monster_node_list;
    while (ent)
    {
        if (target_pathchains_listed[ent->hint_chain_id])
        {
            node_dist = realrange(monster, ent);
            if (node_dist < closest_dist)
            {
                closest_node = ent;
                closest_dist = node_dist;
            }
        }
        ent = ent->monster_hint_chain;
    }

    // If there are no nodes close enough that take us to our enemy, get outta here.
    if (!closest_node)
    {
        return false;
    }
    start_node = closest_node;

    // Finally we go through target_node_list linked list to find the node closest to
    // our target that is on the pathchain the monster will be using.
    closest_dist = HINT_NODE_RANGE;
    closest_node = NULL;
    ent          = target_node_list;
    while (ent)
    {
        if (ent->hint_chain_id == start_node->hint_chain_id)
        {
            node_dist = realrange(monster->enemy, ent);
            if (node_dist < closest_dist)
            {
                closest_node = ent;
                closest_dist = node_dist;
            }
        }
        ent = ent->target_hint_chain;
    }

    // If there is no node close enough to our enemy, get outta here.
    if (!closest_node)
    {
        return false;
    }
    dest_node = closest_node;

    monster->monsterinfo.goal_hint = dest_node;
    hintpath_start(monster, start_node);
    return true;
}
Example #9
0
void Manager::draw(unsigned width, unsigned height)
{
   auto &io = ImGui::GetIO();
   updateMouseState();
   checkHotKeys();

   // Update some per-frame state information
   io.DisplaySize = ImVec2 { static_cast<float>(width), static_cast<float>(height) };
   io.DeltaTime = 1.0f / 60.0f;

   // Start the frame
   ImGui::NewFrame();
   mPaused = decaf::debug::isPaused();
   if (mPaused) {
      auto initiator = decaf::debug::getPauseInitiatorCoreId();
      auto context = decaf::debug::getPausedContext(initiator);
      if (context->nia != mPausedNia) {
         mWasPaused = false;
      }

      if (!mWasPaused) {
         onPaused();
         mPausedNia = context->nia;
         mWasPaused = true;
      }
   }

   if (mVisible) {
      if (decaf::debug::ready() && !mHasBeenActivated) {
         onFirstActivation();
         mHasBeenActivated = true;
      }

      drawMenu();

      for (auto &itr : mWindows) {
         auto window = itr.second;
         auto flags = window->flags();

         if (flags & Window::BringToFront) {
            // Bring window to front
            ImGui::SetNextWindowFocus();
            window->show();

            // Clear the BringToFront flag
            flags = static_cast<Window::Flags>(flags & ~Window::BringToFront);
            window->setFlags(flags);
         }

         if (window->visible()) {
            window->draw();
         }
      }
   }

   if (!mPaused && mWasPaused) {
      // Check if we have transitioned to resumed.
      mPaused = false;
      onResumed();
      mWasPaused = false;
   }

   ImGui::Render();
}
Example #10
0
void UcUseCaseCanvas::draw(QPainter & p)
{
    if (! visible()) return;

    QRect r = rect();
    UseCaseData * data = (UseCaseData *) browser_node->get_data();
    p.setRenderHint(QPainter::Antialiasing, true);
    used_color = (itscolor == UmlDefaultColor)
                 ? the_canvas()->browser_diagram()->get_color(UmlUseCase)
                 : itscolor;

    QColor col = color(used_color);
    QBrush brsh = p.brush();
    bool realizationp =
        !strcmp(data->get_short_stereotype(), "realization");
    FILE * fp = svg();
    int rx = width() / 2 - 1;
    int ry = height() / 2 - 1;

    if (fp != 0)
        fputs("<g>\n", fp);

    if (used_color != UmlTransparent) {
        const int shadow = the_canvas()->shadow() - 1;

        if (shadow != -1) {
            r.setRight(r.right() - shadow);
            r.setBottom(r.bottom() - shadow);
            p.setPen(::Qt::NoPen);
            p.setBrush(::Qt::darkGray);
            p.drawEllipse(r.left() + shadow, r.top() + shadow, r.width(), r.height());

            if (fp != 0) {
                rx = width() / 2 - 1;
                ry = height() / 2 - 1;

                fprintf(fp, "\t<ellipse fill=\"#%06x\" stroke=\"none\""
                        " cx=\"%d\" cy=\"%d\" rx=\"%d\" ry=\"%d\" />\n",
                        QColor(::Qt::darkGray).rgb() & 0xffffff,
                        r.left() + shadow + rx, r.top() + shadow + ry, rx, ry);
            }
        }

        if (fp != 0)
            fprintf(fp, "\t<ellipse fill=\"%s\" stroke=\"black\"%s stroke-width=\"1\" stroke-opacity=\"1\""
                    " cx=\"%d\" cy=\"%d\" rx=\"%d\" ry=\"%d\" />\n",
                    svg_color(used_color),
                    (realizationp) ? " stroke-dasharray=\"4,4\"" : "",
                    r.left() + rx, r.top() + ry, rx, ry);
    }
    else if (fp != 0)
        fprintf(fp, "\t<ellipse fill=\"none\" stroke=\"black\"%s stroke-width=\"1\" stroke-opacity=\"1\""
                " cx=\"%d\" cy=\"%d\" rx=\"%d\" ry=\"%d\" />\n",
                (realizationp) ? " stroke-dasharray=\"4,4\"" : "",
                r.left() + rx, r.top() + ry, rx, ry);

    p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode);
    p.setBrush(col);

    if (realizationp)
        p.setPen(::Qt::DotLine);
    else
        p.setPen(::Qt::SolidLine);

    p.drawEllipse(r.left(), r.top(), r.width(), r.height());

    if (realizationp)
        p.setPen(::Qt::SolidLine);

    QString ep = data->get_extension_points();

    if (!ep.isEmpty()) {
        QFontMetrics fbm(the_canvas()->get_font(UmlNormalBoldFont));
        const int two = (int)(2 * the_canvas()->zoom());
        int he = fbm.height() + two;
        int py = (int) y() + height() / 4;
        int dx = width() / 15;
        int px = (int) x() + dx;

        p.drawLine(px, py, r.right() - dx, py);

        if (fp != 0)
            fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
                    " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
                    px, py, r.right() - dx, py);

        int h = (height() * 3) / 4 - two;
        int w = width() - dx - dx;
        QColor bckgrnd = p.backgroundColor();

        py += two;
        p.setBackgroundColor(col);
        p.setFont(the_canvas()->get_font(UmlNormalBoldFont));

        p.drawText(px, py, w, h, ::Qt::AlignHCenter + ::Qt::AlignTop,
                   "Extension Points");

        if (fp != 0)
            draw_text(px, py, w, h, ::Qt::AlignHCenter + ::Qt::AlignTop,
                      "Extension Points", p.font(), fp);

        h -= he;

        if (h > he) {
            // at least one line may be written
            py += he;
            p.setFont(the_canvas()->get_font(UmlNormalFont));
            p.drawText(px, py, w, h, ::Qt::AlignCenter, ep);
            p.setBackgroundColor(bckgrnd);

            if (fp != 0)
                draw_text(px, py, w, h, ::Qt::AlignCenter, ep, p.font(), fp);
        }
    }

    if (fp != 0)
        fputs("</g>\n", fp);

    p.setBrush(brsh);

    if (selected())
        show_mark(p, rect());
}
Example #11
0
void PackageCanvas::draw(QPainter & p) {
  if (! visible()) return;
  p.setRenderHint(QPainter::Antialiasing, true);
  QRect r = rect();
  const BasicData * data = browser_node->get_data();  
  const QPixmap * px = 
    ProfiledStereotypes::diagramPixmap(data->get_stereotype(),
				       the_canvas()->zoom());
  FILE * fp = svg();
  
  if (fp != 0)
    fputs("<g>\n", fp);

  if (px != 0) {
    p.setBackgroundMode(::Qt::TransparentMode);
    
    
    int lft = (px->width() < width()) ? r.x() + (width() - px->width())/2 : r.x();
    
    p.drawPixmap(lft, r.y(), *px);
    if (fp != 0)
      // pixmap not really exported in SVG
      fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      svg_color(UmlBlack), lft, r.y(), px->width() - 1, px->height() - 1);
    
    r.moveBy(0, px->height());
    p.setFont(the_canvas()->get_font(UmlNormalBoldFont));
    p.drawText(r, ::Qt::AlignHCenter, browser_node->get_name());
    
    // pixmap not yet exported in SVG
    if (fp != 0)
      draw_text(r, ::Qt::AlignHCenter, browser_node->get_name(),
		p.font(), fp);
    p.setFont(the_canvas()->get_font(UmlNormalFont));
  }
  else {
    QColor bckgrnd = p.backgroundColor();
    QColor co = color(used_color);
    
    p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode);
    p.setBackgroundColor(co);
    p.setFont(the_canvas()->get_font(UmlNormalFont));
    
    QFontMetrics fm(the_canvas()->get_font(UmlNormalFont));
    const int four = (int) (4 * the_canvas()->zoom());
    const int he = fm.height();
    const int shadow = the_canvas()->shadow();
    if ((used_color != UmlTransparent) && (shadow != 0)) {
      r.setRight(r.right() - shadow);
      r.setBottom(r.bottom() - shadow);
    }
    
    r.setWidth(r.width() * 2 / 5);
    r.setHeight(he + four);
    if (used_color != UmlTransparent)
      p.fillRect(r, co);
    
    if (fp != 0)
      fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      svg_color(used_color), 
	      r.x(), r.y(), r.width() - 1, r.height() - 1);
    
    p.drawRect(r);
    
    if ((used_color != UmlTransparent) && (shadow != 0)) {
      p.fillRect (r.right(), r.top() + shadow,
		  shadow, r.height() - 1 - shadow,
		  ::Qt::darkGray);
      
      if (fp != 0)
	fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		QColor(::Qt::darkGray).rgb()&0xffffff,
		r.right(), r.top() + shadow, shadow - 1, r.height() - 1 - shadow - 1);
    }
    
    const char * name = browser_node->get_name();
    
    if (in_tab) {
      p.drawText(r, ::Qt::AlignCenter, name);
      if (fp != 0)
	draw_text(r, ::Qt::AlignCenter, name,
		  p.font(), fp);
    }
    
    r = rect();
    if ((used_color != UmlTransparent) && (shadow != 0)) {
      r.setRight(r.right() - shadow);
      r.setBottom(r.bottom() - shadow);
    }
    
    r.setTop(r.top() + he + four - 1);
    if (used_color != UmlTransparent)
      p.fillRect(r, co);
    
    if (fp != 0)
      fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      svg_color(used_color),
	      r.x(), r.y(), r.width() - 1, r.height() - 1);
    
    p.drawRect(r);
    
    if ((used_color != UmlTransparent) && (shadow != 0)) {
      p.fillRect (r.right(), r.top() + shadow,
		  shadow, r.height() - 1,
		  ::Qt::darkGray);
      p.fillRect (r.left() + shadow, r.bottom(),
		  r.width() - 1, shadow,
		  ::Qt::darkGray);
      
      if (fp != 0) {
	fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		QColor(::Qt::darkGray).rgb()&0xffffff,
		r.right(), r.top() + shadow, shadow - 1, r.height() - 1 - 1);
	
	fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		QColor(::Qt::darkGray).rgb()&0xffffff,
		r.left() + shadow, r.bottom(), r.width() - 1 - 1, shadow - 1);
      }
    }
    
    const int three = (int) (3 * the_canvas()->zoom());
    
    r.setTop(r.top() + three);
    
    if (! in_tab) {
      p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop, name);
      if (fp != 0)
	draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop, name,
		  p.font(), fp);
      r.setTop(r.top() + he + three);
    }
    
    if (data->get_stereotype()[0]) {
      p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop, 
		 QString("<<") + toUnicode(data->get_short_stereotype()) + ">>");
      if (fp != 0)
	draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop, 
		  QString("<<") + toUnicode(data->get_short_stereotype()) + ">>",
		  p.font(), fp);
      r.setTop(r.top() + he + three);
    }
    
    if (full_name != name) {
      p.setFont(the_canvas()->get_font(UmlNormalItalicFont));
      p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop, full_name);
      if (fp != 0)
	draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop, full_name,
		  p.font(), fp);
      p.setFont(the_canvas()->get_font(UmlNormalFont));
    }
  
    p.setBackgroundColor(bckgrnd);
  }
  
  if (fp != 0)
    fputs("</g>\n", fp);
  
  if (selected())
    show_mark(p, rect());
}
qboolean
Pet_FindTarget(edict_t * self)
{
	edict_t * enemy = 0;
	edict_t * PetOwner = self->monsterinfo.PetOwner;
	int radius = 500;
//	int bCammed = false;

	// follow mode means ignore combat
	if (self->monsterinfo.PetState & PET_FOLLOW)
	{
		self->enemy = 0;
		self->goalentity = PetOwner;
		return true;
	}

// optional bonus for a pet actively being cammed
//	if (PetOwner->client->petcam == self)
//	{
//		bCammed = true;
//		radius = 1000;
//	}

	// help master if appropriate
	if (!(self->monsterinfo.PetState & PET_FREETARGET)
		&& PetOwner->enemy)
	{
		vec3_t dir;
		double distance;
		VectorSubtract(self->s.origin,PetOwner->s.origin, dir);
		distance = VectorLength(dir);
		if ( distance < 400)
			enemy = PetOwner->enemy;
	}

	if (!enemy)
		enemy = FindEnemy(self, radius);

	if (enemy)
	{
		self->enemy = enemy;
		FoundTarget (self);

		if (!(self->monsterinfo.aiflags & AI_SOUND_TARGET) && (self->monsterinfo.sight))
			self->monsterinfo.sight (self, self->enemy);
		return true;
	}

	// no enemy, what about following owner ?
	self->enemy = 0; // 2000/05/27
	self->goalentity = 0;
	if (!(self->monsterinfo.PetState & PET_FREE)
			&& visible(self, PetOwner))
	{
		if (DistanceTo(self, PetOwner) > 100)
		{
			self->goalentity = PetOwner;
			self->monsterinfo.pausetime = level.time;
		}
		else
		{
			self->monsterinfo.stand (self);
			self->monsterinfo.pausetime = level.time + 30;
		}
	}
	return false;
}
Example #13
0
void RenderPlugin::setSettings( const QHash<QString,QVariant> &settings )
{
    setEnabled( settings.value( "enabled", enabled() ).toBool() );
    setVisible( settings.value( "visible", visible() ).toBool() );
}
Example #14
0
void StateActionCanvas::draw(QPainter & p) {
  if (! visible()) return;
  
  QRect r = rect();
  const BasicData * data = browser_node->get_data();
  double zoom = the_canvas()->zoom();
  const QPixmap * px = 
    ProfiledStereotypes::diagramPixmap(data->get_stereotype(),
				       the_canvas()->zoom());
  FILE * fp = svg();

  if (fp != 0)
    fputs("<g>\n", fp);
    
  if (px != 0) {
    p.setBackgroundMode(::Qt::TransparentMode);
    
    int lft = (px->width() < width()) ? r.x() + (width() - px->width())/2 : r.x();
    
    p.drawPixmap(lft, r.y(), *px);
    if (fp != 0)
      // pixmap not really exported in SVG
      fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      svg_color(UmlBlack), lft, r.y(), px->width() - 1, px->height() - 1);
  }
  else {
    QColor bckgrnd = p.backgroundColor();
    int mw = min_width;
    QBrush brsh = p.brush();
    QFontMetrics fm(the_canvas()->get_font(UmlNormalFont));
    const char * st = data->get_short_stereotype();
    const int shadow = the_canvas()->shadow();
    
    QColor co = color(used_color);
    
    p.setBackgroundMode((used_color == UmlTransparent)
			? ::Qt::TransparentMode
			: ::Qt::OpaqueMode);

    p.setBackgroundColor(co);
    
    p.setFont(the_canvas()->get_font(UmlNormalFont));
    
    if (!strcmp(st, "send-signal")) {
      QPointArray a(6);
      
      if ((used_color != UmlTransparent) && (shadow != 0)) {
	r.setRight(r.right() - shadow);
	r.setBottom(r.bottom() - shadow);
      }
      
      const int hh = r.height()/2;
      
      a.setPoint(0, r.left(), r.top());
      a.setPoint(1, r.right() - hh, r.top());
      a.setPoint(2, r.right(), r.top() + hh);
      a.setPoint(3, r.right() - hh, r.bottom());
      a.setPoint(4, r.left(), r.bottom());
      a.setPoint(5, r.left(), r.top());
      
      if (used_color == UmlTransparent) {
	p.drawPolyline(a);
	if (fp != 0)
	  draw_poly(fp, a, UmlTransparent);
      }
      else {
	if (shadow != 0) {
	  QPointArray b(6);
	  
	  b.setPoint(0, r.left() + shadow, r.top() + shadow);
	  b.setPoint(1, r.right() - hh + shadow, r.top() + shadow);
	  b.setPoint(2, r.right() + shadow, r.top() + hh + shadow);
	  b.setPoint(3, r.right() - hh + shadow, r.bottom() + shadow);
	  b.setPoint(4, r.left() + shadow, r.bottom() + shadow);
	  b.setPoint(5, r.left() + shadow, r.top() + shadow);
	  p.setBrush(::Qt::darkGray);
	  p.setPen(::Qt::NoPen);
	  p.drawPolygon(b, TRUE, 0, 5);
	  p.setPen(::Qt::SolidLine);
	  
	  if (fp != 0)
	    draw_shadow(fp, b);
	}
	
	p.setBrush(co);
	p.drawPolygon(a, TRUE, 0, 5);
	
	if (fp != 0)
	  draw_poly(fp, a, used_color);
      }
      
      r.setRight(r.right() - hh);
      mw -= hh;
    }
    else if (!strcmp(st, "receive-signal")) {
      QPointArray a(6);
      
      if ((used_color != UmlTransparent) && (shadow != 0)) {
	r.setRight(r.right() - shadow);
	r.setBottom(r.bottom() - shadow);
      }
      
      const int hh = r.height()/2;
      
      a.setPoint(0, r.left(), r.top());
      a.setPoint(1, r.right(), r.top());
      a.setPoint(2, r.right() - hh, r.top() + hh);
      a.setPoint(3, r.right(), r.bottom());
      a.setPoint(4, r.left(), r.bottom());
      a.setPoint(5, r.left(), r.top());
      
      if (used_color == UmlTransparent) {
	p.drawPolyline(a);
	
	if (fp != 0)
	  draw_poly(fp, a, UmlTransparent);
      }
      else {
	if (shadow != 0) {
	  QPointArray b(6);
	  
	  b.setPoint(0, r.left() + shadow, r.top() + shadow);
	  b.setPoint(1, r.right() + shadow, r.top() + shadow);
	  b.setPoint(2, r.right() - hh + shadow, r.top() + hh + shadow);
	  b.setPoint(3, r.right() + shadow, r.bottom() + shadow);
	  b.setPoint(4, r.left() + shadow, r.bottom() + shadow);
	  b.setPoint(5, r.left() + shadow, r.top() + shadow);
	  p.setBrush(::Qt::darkGray);
	  p.setPen(::Qt::NoPen);
	  p.drawPolygon(b, TRUE, 0, 5);
	  p.setPen(::Qt::SolidLine);
	  
	  if (fp != 0)
	    draw_shadow(fp, b);
	}
	
	p.setBrush(co);
	p.drawPolygon(a, TRUE, 0, 5);
	
	if (fp != 0)
	  draw_poly(fp, a, used_color);
      }
      
      r.setRight(r.right() - hh);
      mw -= hh;
    }
    else {
      if (used_color != UmlTransparent) {
	if (shadow != 0) {
	  r.setRight(r.right() - shadow);
	  r.setBottom(r.bottom() - shadow);
	  
	  p.fillRect (r.right(), r.top() + shadow,
		      shadow, r.height() - 1,
		      ::Qt::darkGray);
	  p.fillRect (r.left() + shadow, r.bottom(),
		      r.width() - 1, shadow,
		      ::Qt::darkGray);
	  
	  if (fp != 0) {
	    fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		    " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		    ::Qt::darkGray.rgb()&0xffffff,
		    r.right(), r.top() + shadow, shadow - 1, r.height() - 1 - 1);
	    
	    fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		    " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		    ::Qt::darkGray.rgb()&0xffffff,
		    r.left() + shadow, r.bottom(), r.width() - 1 - 1, shadow - 1);
	  }
	}
      }
      
      p.setBrush(co);
      p.drawRect(r);
      
      if (fp != 0)
	fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		svg_color(used_color), 
		r.x(), r.y(), r.width() - 1, r.height() - 1);
      
      if (st[0] != 0) {
	r.setTop(r.top() + fm.height() / 2);
	p.drawText(r, ::Qt::AlignHCenter, QString("<<") + toUnicode(st) + ">>");
	if (fp != 0)
	  draw_text(r, ::Qt::AlignHCenter, QString("<<") + toUnicode(st) + ">>",
		    p.font(), fp);
	r.setTop(r.top() + 3*fm.height()/2);
      }
    }
    
    r.setLeft(r.left() + (r.width() + (int) (8 * zoom) - mw)/2 + 1);
    p.drawText(r, ::Qt::AlignVCenter, s);
    if (fp != 0) {
      draw_text(r, ::Qt::AlignVCenter, s,
		p.font(), fp);
      fputs("</g>\n", fp);
    }
      
    p.setBrush(brsh);
    p.setBackgroundColor(bckgrnd);
  }
  
  if (selected())
    show_mark(p, rect());
}
Example #15
0
void RenderMeshComponent::AddFromRawData(corgi::EntityRef& entity,
                                         const void* raw_data) {
  auto rendermesh_def = static_cast<const RenderMeshDef*>(raw_data);

  // You need to call asset_manager before you can add from raw data,
  // otherwise it can't load up new meshes!
  assert(asset_manager_ != nullptr);
  assert(rendermesh_def->source_file() != nullptr);
  assert(rendermesh_def->shader() != nullptr);

  RenderMeshData* rendermesh_data = AddEntity(entity);

  rendermesh_data->mesh_filename = rendermesh_def->source_file()->c_str();
  rendermesh_data->shader_filename = rendermesh_def->shader()->c_str();

  rendermesh_data->mesh =
      asset_manager_->LoadMesh(rendermesh_def->source_file()->c_str());
  assert(rendermesh_data->mesh != nullptr);

  // Allocate the array to hold shader default pose's transforms.
  assert(rendermesh_data->shader_transforms == nullptr);
  const uint8_t num_shader_transforms =
      rendermesh_data->mesh->num_shader_bones();
  rendermesh_data->num_shader_transforms = num_shader_transforms;
  if (num_shader_transforms > 0) {
    rendermesh_data->shader_transforms =
        new mathfu::AffineTransform[num_shader_transforms];
    for (uint8_t i = 0; i < num_shader_transforms; ++i) {
      rendermesh_data->shader_transforms[i] = mathfu::kAffineIdentity;
    }
  }

  rendermesh_data->shader =
      asset_manager_->LoadShader(rendermesh_def->shader()->c_str());
  assert(rendermesh_data->shader != nullptr);

  rendermesh_data->visible = rendermesh_def->visible();
  rendermesh_data->default_pose = rendermesh_def->default_pose();

  rendermesh_data->pass_mask = 0;
  if (rendermesh_def->render_pass() != nullptr) {
    for (size_t i = 0; i < rendermesh_def->render_pass()->size(); i++) {
      int render_pass = rendermesh_def->render_pass()->Get(i);
      assert(render_pass < RenderPass_Count);
      rendermesh_data->pass_mask |= 1 << render_pass;
    }
  } else {
    // Anything unspecified is assumed to be opaque.
    rendermesh_data->pass_mask = (1 << RenderPass_Opaque);
  }

  if (rendermesh_def->culling() != nullptr) {
    for (size_t i = 0; i < rendermesh_def->culling()->size(); i++) {
      int culling_test = rendermesh_def->culling()->Get(i);
      assert(culling_test < CullingTest_Count);
      rendermesh_data->culling_mask |= 1 << culling_test;
    }
  }

  // TODO: Load this from a flatbuffer file instead of setting it.
  rendermesh_data->tint = mathfu::kOnes4f;
}
Example #16
0
void Manager::drawMenu()
{
   auto getWindowShortcut = [this](WindowID id) -> const char * {
         auto itr = mWindowHotKeys.find(id);

         if (itr == mWindowHotKeys.end()) {
            return nullptr;
         }

         return itr->second.str.c_str();
      };
   auto config = decaf::config();
   auto gpuConfig = gpu::config();

   ImGui::BeginMainMenuBar();

   // Draw Debug menu
   if (ImGui::BeginMenu("Debug")) {
      if (ImGui::MenuItem("Pause", PauseHotKey, false, !mPaused)) {
         decaf::debug::pause();
      }

      if (ImGui::MenuItem("Resume", ResumeHotKey, false, mPaused)) {
         decaf::debug::resume();
      }

      if (ImGui::MenuItem("Step Over", StepOverHotKey, false, mPaused && mActiveThread.coreId != -1)) {
         decaf::debug::stepOver(mActiveThread.coreId);
      }

      if (ImGui::MenuItem("Step Into", StepIntoHotKey, false, mPaused && mActiveThread.coreId != -1)) {
         decaf::debug::stepInto(mActiveThread.coreId);
      }

      ImGui::Separator();

      if (ImGui::MenuItem("PM4 Capture Next Frame", nullptr, false, true)) {
         decaf::debug::pm4CaptureNextFrame();
      }

      ImGui::Separator();

      if (ImGui::MenuItem("HLE Trace Enabled", nullptr, config->log.hle_trace, true)) {
         auto newConfig = *config;
         newConfig.log.hle_trace = !config->log.hle_trace;
         decaf::setConfig(newConfig);
      }

      auto pm4Enable = false;
      auto pm4Status = false;

      switch (decaf::debug::pm4CaptureState()) {
      case decaf::debug::Pm4CaptureState::Disabled:
         pm4Status = false;
         pm4Enable = true;
         break;
      case decaf::debug::Pm4CaptureState::Enabled:
         pm4Status = true;
         pm4Enable = true;
         break;
      case decaf::debug::Pm4CaptureState::WaitEndNextFrame:
         pm4Status = true;
         pm4Enable = false;
         break;
      case decaf::debug::Pm4CaptureState::WaitStartNextFrame:
         pm4Status = true;
         pm4Enable = false;
         break;
      }

      if (ImGui::MenuItem("PM4 Trace Enabled", nullptr, pm4Status, pm4Enable)) {
         if (!pm4Status) {
            decaf::debug::pm4CaptureBegin();
         } else {
            decaf::debug::pm4CaptureEnd();
         }
      }

      if (ImGui::MenuItem("GX2 Texture Dump Enabled", nullptr, config->gx2.dump_textures, true)) {
         auto newConfig = *config;
         newConfig.gx2.dump_textures = !config->gx2.dump_textures;
         decaf::setConfig(newConfig);
      }

      if (ImGui::MenuItem("GX2 Shader Dump Enabled", nullptr, config->gx2.dump_shaders, true)) {
         auto newConfig = *config;
         newConfig.gx2.dump_shaders = !config->gx2.dump_shaders;
         decaf::setConfig(newConfig);
      }

      if (ImGui::MenuItem("GPU Shader Dump Enabled", nullptr, gpuConfig->debug.dump_shaders, true)) {
         auto newConfig = *gpuConfig;
         newConfig.debug.dump_shaders = !gpuConfig->debug.dump_shaders;
         gpu::setConfig(newConfig);
      }

      if (ImGui::MenuItem("GPU Dump Shader Binaries Only", nullptr, gpuConfig->debug.dump_shader_binaries_only, true)) {
         auto newConfig = *gpuConfig;
         newConfig.debug.dump_shader_binaries_only = !gpuConfig->debug.dump_shader_binaries_only;
         gpu::setConfig(newConfig);
      }

      ImGui::Separator();

      if (ImGui::MenuItem("JIT Profiling Enabled", JitProfileHotKey, mJitProfilingEnabled, true)) {
         mJitProfilingEnabled = !mJitProfilingEnabled;
         cpu::jit::setProfilingMask(mJitProfilingEnabled ? mJitProfilingMask : 0);
      }

      if (ImGui::MenuItem("Profile Core 0", nullptr, mJitProfilingMask & 1, true)) {
         mJitProfilingMask ^= 1;

         if (mJitProfilingEnabled) {
            cpu::jit::setProfilingMask(mJitProfilingMask);
         }
      }

      if (ImGui::MenuItem("Profile Core 1", nullptr, mJitProfilingMask & 2, true)) {
         mJitProfilingMask ^= 2;

         if (mJitProfilingEnabled) {
            cpu::jit::setProfilingMask(mJitProfilingMask);
         }
      }

      if (ImGui::MenuItem("Profile Core 2", nullptr, mJitProfilingMask & 4, true)) {
         mJitProfilingMask ^= 4;

         if (mJitProfilingEnabled) {
            cpu::jit::setProfilingMask(mJitProfilingMask);
         }
      }

      if (ImGui::MenuItem("Reset JIT Profile Data", ResetJitProfileHotKey, false, true)) {
         cpu::jit::resetProfileStats();
      }

      ImGui::EndMenu();
   }

   // Draw Window menu
   if (ImGui::BeginMenu("Windows")) {
      for (auto &itr : mWindows) {
         auto id = itr.first;
         auto window = itr.second;

         if (window->flags() & Window::AlwaysVisible) {
            continue;
         }

         if (ImGui::MenuItem(window->name().c_str(),
                             getWindowShortcut(id),
                             window->visible(), true)) {
            if (window->visible()) {
               window->hide();
            } else {
               window->show();
            }
         }
      }

      ImGui::EndMenu();
   }

   ImGui::EndMainMenuBar();
}
Example #17
0
void
parseMESOptions(
    const manta::Program& prog,
    int argc, char* argv[],
    MESOptions& opt)
{
    namespace po = boost::program_options;
    po::options_description req("configuration");
    req.add_options()
    ("stats-file", po::value(&opt.statsFilename),
     "input sv edge stats file (may be specified multiple times)")
    ("output-file", po::value(&opt.outputFilename),
     "merged output sv edge stats file (required)")
    ("report-file", po::value(&opt.reportFilename),
     "provide a summary report based on the merged edge stats");

    po::options_description help("help");
    help.add_options()
    ("help,h","print this message");

    po::options_description visible("options");
    visible.add(req).add(help);

    bool po_parse_fail(false);
    po::variables_map vm;
    try
    {
        po::store(po::parse_command_line(argc, argv, visible,
                                         po::command_line_style::unix_style ^ po::command_line_style::allow_short), vm);
        po::notify(vm);
    }
    catch (const boost::program_options::error& e)
    {
        // todo:: find out what is the more specific exception class thrown by program options
        log_os << "\nERROR: Exception thrown by option parser: " << e.what() << "\n";
        po_parse_fail=true;
    }

    if ((argc<=1) || (vm.count("help")) || po_parse_fail)
    {
        usage(log_os,prog,visible);
    }

    // fast check of config state:
    if (opt.statsFilename.empty())
    {
        usage(log_os,prog,visible, "Must specify at least 1 input sv edge stats file");
    }
    for (const std::string& statsFilename : opt.statsFilename)
    {
        if (! boost::filesystem::exists(statsFilename))
        {
            std::ostringstream oss;
            oss << "SV edge stats file does not exist: '" << statsFilename << "'";
            usage(log_os,prog,visible,oss.str().c_str());
        }
    }
    if (opt.outputFilename.empty())
    {
        usage(log_os,prog,visible, "Must specify sv edges stats output file");
    }
}
Example #18
0
/*
===========
FindTarget

Self is currently not attacking anything, so try to find a target

Returns true if an enemy was sighted

When a player fires a missile, the point of impact becomes a fakeplayer so
that monsters that see the impact will respond as if they had seen the
player.

To avoid spending too much time, only a single client (or fakeclient) is
checked each frame.  This means multi player games will have slightly
slower noticing monsters.
============
*/
float FindTarget()
{
	gedict_t	*client = NULL;

// if the first spawnflag bit is set, the monster will only wake up on
// really seeing the player, not another monster getting angry

// spawnflags & 3 is a big hack, because zombie crucified used the first
// spawn flag prior to the ambush flag, and I forgot about it, so the second
// spawn flag works as well
	if ( sight_entity_time + 0.1 >= g_globalvars.time && !((int)self->s.v.spawnflags & 3) )
	{
		client = sight_entity; // NOTE: may be NULL, so be careful

		if ( !client || client == world )
			return false;

		if ( client->s.v.enemy == self->s.v.enemy )
			return false; // not sure I understand this, both have same enemy?
	}
	else
	{
		client = checkclient();

		if ( !client || client == world )
			return false;	// current check entity isn't in PVS
	}

	if ( client == PROG_TO_EDICT( self->s.v.enemy ) )
		return false;

	if ( (int)client->s.v.flags & FL_NOTARGET )
		return false;

	if ( (int)client->s.v.items & IT_INVISIBILITY )
		return false;

	// in bloodfest mode monsters spot players always.
	if ( !k_bloodfest )
	{
		float		r = range ( client );

		if ( r == RANGE_FAR )
			return false;

		if ( !visible( client ) )
			return false;

		if ( r == RANGE_NEAR )
		{
			if ( client->show_hostile < g_globalvars.time && !infront( client ) )
				return false;
		}
		else if ( r == RANGE_MID )
		{
			if ( /* client->show_hostile < g_globalvars.time || */ !infront( client ) )
				return false;
		}
	}

//
// got one
//
	self->s.v.enemy = EDICT_TO_PROG( client );

	if ( PROG_TO_EDICT( self->s.v.enemy )->ct != ctPlayer || ( (int)PROG_TO_EDICT( self->s.v.enemy )->s.v.flags & FL_NOTARGET ) )
	{
		self->s.v.enemy = PROG_TO_EDICT( self->s.v.enemy )->s.v.enemy;

		if ( PROG_TO_EDICT( self->s.v.enemy )->ct != ctPlayer || ( (int)PROG_TO_EDICT( self->s.v.enemy )->s.v.flags & FL_NOTARGET ) )
		{
			self->s.v.enemy = EDICT_TO_PROG( world );
			return false;
		}
	}

	FoundTarget ();

	return true;
}
Example #19
0
static void display_changed(struct termios *mode)
{
	int i;
	int empty_line;
	tcflag_t *bitsp;
	unsigned long mask;
	enum mode_type prev_type = control;

	display_speed(mode, 1);
#ifdef HAVE_C_LINE
	wrapf("line = %d;", mode->c_line);
#endif
	putchar('\n');
	current_col = 0;

	empty_line = 1;
	for (i = 0; control_info[i].name != stty_min; ++i) {
		if (mode->c_cc[control_info[i].offset] == control_info[i].saneval)
			continue;
		/* If swtch is the same as susp, don't print both.  */
#if VSWTCH == VSUSP
		if (control_info[i].name == stty_swtch)
			continue;
#endif
		/* If eof uses the same slot as min, only print whichever applies.  */
#if VEOF == VMIN
		if ((mode->c_lflag & ICANON) == 0
			&& (control_info[i].name == stty_eof
				|| control_info[i].name == stty_eol)) continue;
#endif

		empty_line = 0;
		wrapf("%s = %s;", control_info[i].name,
			  visible(mode->c_cc[control_info[i].offset]));
	}
	if ((mode->c_lflag & ICANON) == 0) {
		wrapf("min = %d; time = %d;\n", (int) mode->c_cc[VMIN],
			  (int) mode->c_cc[VTIME]);
	} else if (empty_line == 0)
		putchar('\n');
	current_col = 0;

	empty_line = 1;
	for (i = 0; i < NUM_mode_info; ++i) {
		if (mode_info[i].flags & OMIT)
			continue;
		if (mode_info[i].type != prev_type) {
			if (empty_line == 0) {
				putchar('\n');
				current_col = 0;
				empty_line = 1;
			}
			prev_type = mode_info[i].type;
		}

		bitsp = mode_type_flag(mode_info[i].type, mode);
		mask = mode_info[i].mask ? mode_info[i].mask : mode_info[i].bits;
		if ((*bitsp & mask) == mode_info[i].bits) {
			if (mode_info[i].flags & SANE_UNSET) {
				wrapf("%s", mode_info[i].name);
				empty_line = 0;
			}
		}
			else if ((mode_info[i].flags & (SANE_SET | REV)) ==
					 (SANE_SET | REV)) {
			wrapf("-%s", mode_info[i].name);
			empty_line = 0;
		}
	}
	if (empty_line == 0)
		putchar('\n');
	current_col = 0;
}
Example #20
0
/*
=============
ai_run

The monster has an enemy it is trying to kill
=============
*/
void ai_run( float dist )
{
	vec3_t tmpv;

	if ( k_bloodfest )
	{
		if ( (int)self->s.v.flags & FL_SWIM )
		{
			dist *= 5; // let fish swim faster in bloodfest mode.
		}
		else if ( self->bloodfest_boss )
		{
			dist *= 2; // let boss move faster
		}
	}

	movedist = dist;

	// see if the enemy is dead
	if ( ISDEAD( PROG_TO_EDICT( self->s.v.enemy ) ) || ( (int)PROG_TO_EDICT( self->s.v.enemy )->s.v.flags & FL_NOTARGET ) )
	{
		self->s.v.enemy = EDICT_TO_PROG( world );

		// FIXME: look all around for other targets
		if ( self->oldenemy && ISLIVE( self->oldenemy ) && !( (int)self->oldenemy->s.v.flags & FL_NOTARGET ) )
		{
			self->s.v.enemy = EDICT_TO_PROG( self->oldenemy );
			HuntTarget ();
		}
		else
		{
			if ( !self->movetarget || self->movetarget == world )
			{
				if ( self->th_stand )
					self->th_stand();
			}
			else
			{
				if ( self->th_walk )
					self->th_walk();
			}

			return;
		}
	}

	self->show_hostile = g_globalvars.time + 1;		// wake up other monsters

// check knowledge of enemy
	enemy_vis = visible( PROG_TO_EDICT( self->s.v.enemy ) );
	if ( enemy_vis )
		self->search_time = g_globalvars.time + 5; // does not search for enemy next 5 seconds

// look for other coop players
	if ( coop && self->search_time < g_globalvars.time )
	{
		if ( FindTarget() )
		{
			// this is fix for too frequent enemy sighting, required for bloodfest mode.
			if ( !visible( PROG_TO_EDICT( self->s.v.enemy ) ) )
			{
				self->search_time = g_globalvars.time + 5; // does not search for enemy next 5 seconds
			}
			return;
		}
	}

	enemy_infront = infront( PROG_TO_EDICT( self->s.v.enemy ) );
	enemy_range   = range( PROG_TO_EDICT( self->s.v.enemy ) );
	VectorSubtract( PROG_TO_EDICT( self->s.v.enemy )->s.v.origin, self->s.v.origin, tmpv);
	enemy_yaw     = vectoyaw( tmpv );

	if ( self->attack_state == AS_MISSILE )
	{
		//dprint ("ai_run_missile\n");
		ai_run_missile();
		return;
	}

	if ( self->attack_state == AS_MELEE )
	{
		//dprint ("ai_run_melee\n");
		ai_run_melee();
		return;
	}

	if ( CheckAnyAttack() )
		return;					// beginning an attack

	if ( self->attack_state == AS_SLIDING )
	{
		ai_run_slide();
		return;
	}

	// head straight in
	movetogoal( dist );		// done in C code...
}
void 
GltSkySphere::draw() const
{
	if (!visible())
		return;
		
	GLERROR

	GltViewport viewport(true);

	//
	// Setup perspective camera mode,
	// orthogonal doesn't really work...
	//

	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();

	gluPerspective(_fov,double(viewport.width())/double(viewport.height()), 0.1, 200.0);

	//
	// Twiddle the current modelview matrix
	// to cancel out translation and scale.
	//

	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();

	Matrix      matrix(GL_MODELVIEW_MATRIX);

	// No translation

	matrix[12] = 0.0;
	matrix[13] = 0.0;
	matrix[14] = 0.0;

	// No scale

	const real sf = sqrt( SQ(matrix[0]) + SQ(matrix[1]) + SQ(matrix[2]) ); 
	matrix *= matrixScale(1.0/sf);

	//

	matrix.glLoadMatrix();
	transformation().glMultMatrix();
	
	//
	//
	//

		GLERROR

		glPushAttrib(GL_ENABLE_BIT|GL_POLYGON_BIT|GL_LIGHTING_BIT);

			glDisable(GL_DEPTH_TEST);
			glDisable(GL_LIGHTING);
			glDisable(GL_TEXTURE_2D);
			glEnable(GL_CULL_FACE);

			if (solid())
			{
				glEnable(GL_BLEND);
				glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
				glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
				glShadeModel(GL_SMOOTH);
			}
			else
			{
				glDisable(GL_BLEND);
				glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
				glShadeModel(GL_FLAT);
			}
			
			//

			drawSphere(_map,_slices);

			//

		glPopAttrib();

		GLERROR

	glPopMatrix();
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);

	GLERROR
}
Example #22
0
void greeting(object ob)
{
        if( !ob || !visible(ob) || environment(ob) != environment() ) return;
say(name()+"神秘地说:“想要礼物吗?找我啊!不过,你只有一次机会哦!哈哈!”\n");
}
Example #23
0
void M_ReactToDamage (edict_t *targ, edict_t *attacker)
{
	if (!(attacker->client) && !(attacker->svflags & SVF_MONSTER))
		return;

	if (attacker == targ || attacker == targ->enemy)
		return;

	// if we are a good guy monster and our attacker is a player
	// or another good guy, do not get mad at them
	if (targ->monsterinfo.aiflags & AI_GOOD_GUY)
	{
		if (attacker->client || (attacker->monsterinfo.aiflags & AI_GOOD_GUY))
			return;
	}

	// we now know that we are not both good guys

	// if attacker is a client, get mad at them because he's good and we're not
	if (attacker->client)
	{
		targ->monsterinfo.aiflags &= ~AI_SOUND_TARGET;

		// this can only happen in coop (both new and old enemies are clients)
		// only switch if can't see the current enemy
		if (targ->enemy && targ->enemy->client)
		{
			if (visible(targ, targ->enemy))
			{
				targ->oldenemy = attacker;
				return;
			}
			targ->oldenemy = targ->enemy;
		}
		targ->enemy = attacker;
		if (!(targ->monsterinfo.aiflags & AI_DUCKED))
			FoundTarget (targ);
		return;
	}

	// it's the same base (walk/swim/fly) type and a different classname and it's not a tank
	// (they spray too much), get mad at them
	if (((targ->flags & (FL_FLY|FL_SWIM)) == (attacker->flags & (FL_FLY|FL_SWIM))) &&
		 (strcmp (targ->classname, attacker->classname) != 0) &&
		 (strcmp(attacker->classname, "monster_tank") != 0) &&
		 (strcmp(attacker->classname, "monster_supertank") != 0) &&
		 (strcmp(attacker->classname, "monster_makron") != 0) &&
		 (strcmp(attacker->classname, "monster_jorg") != 0) )
	{
		if (targ->enemy && targ->enemy->client)
			targ->oldenemy = targ->enemy;
		targ->enemy = attacker;
		if (!(targ->monsterinfo.aiflags & AI_DUCKED))
			FoundTarget (targ);
	}
	// if they *meant* to shoot us, then shoot back
	else if (attacker->enemy == targ)
	{
		if (targ->enemy && targ->enemy->client)
			targ->oldenemy = targ->enemy;
		targ->enemy = attacker;
		if (!(targ->monsterinfo.aiflags & AI_DUCKED))
			FoundTarget (targ);
	}
	// otherwise get mad at whoever they are mad at (help our buddy) unless it is us!
	else if (attacker->enemy && attacker->enemy != targ)
	{
		if (targ->enemy && targ->enemy->client)
			targ->oldenemy = targ->enemy;
		targ->enemy = attacker->enemy;
		if (!(targ->monsterinfo.aiflags & AI_DUCKED))
			FoundTarget (targ);
	}
}
Example #24
0
void TrillSegment::draw(QPainter* painter) const
      {
      QRectF b2(symBbox(SymId::wiggleTrill));
      qreal w2   = symWidth(SymId::wiggleTrill);

      qreal x2   = pos2().x();

      QColor color;
      if (flag(ELEMENT_DROP_TARGET))
            color = MScore::dropColor;
      else if (selected() && !(score() && score()->printing()))
            color = MScore::selectColor[0];
      else if (!visible())
            color = Qt::gray;
      else {
            color = trill()->curColor();
            }

      painter->setPen(color);
      if (spannerSegmentType() == SEGMENT_SINGLE || spannerSegmentType() == SEGMENT_BEGIN) {
            SymId sym = SymId::noSym;
            qreal x0 = 0.0, x1 = 0.0, y = 0.0;
            int n = 0;
            QRectF b1;

            switch(trill()->trillType()) {
                  case Trill::TRILL_LINE:
                        sym  = SymId::ornamentTrill;
                        b1   = symBbox(sym);
                        x0   = -b1.x();
                        x1   = x0 + b1.width();
                        n    = int(floor((x2-x1) / w2));
                        y    = 0.0;
                        break;
#if 0 // TODO-smufl
                  case Trill::UPPRALL_LINE:
                        sym  = SymId(upprallSym);
                        b1   = score()->sym(sym).bbox(mag);
                        x0   = -b1.x();
                        x1   = b1.width();
                        n    = int(floor((x2-x1) / w2));
                        y    = -b1.height();
                        break;
                  case Trill::DOWNPRALL_LINE:
                        sym  = SymId(downprallSym);
                        b1   = score()->sym(sym).bbox(mag);
                        x0   = -b1.x();
                        x1   = b1.width();
                        n    = int(floor((x2-x1) / w2));
                        y    = -b1.height();
                        break;
                  case Trill::PRALLPRALL_LINE:
                        sym  = SymId(prallprallSym);
                        b1   = score()->sym(sym).bbox(mag);
                        x0   = -b1.x();
                        x1   = b1.width();
                        n    = int(floor((x2-x1) / w2));
                        y    = -b1.height();
                        break;
#endif
                  case Trill::PURE_LINE:
                        sym = SymId::noSym;
                        x0 = 0;
                        x1 = 0;
                        n    = int(floor((x2-x1) / w2));
                        y = 0.0;
                  }
            if (n <= 0)
                  n = 1;
            if (sym != SymId::noSym)
                  drawSymbol(sym, painter, QPointF(x0, y));
            drawSymbol(SymId::wiggleTrill, painter, QPointF(x1, b2.y() * .9), n);
            }
      else {
            qreal x1 = 0.0;
            int n = int(floor((x2-x1) / w2));
            drawSymbol(SymId::wiggleTrill, painter, QPointF(x1, b2.y() * .9), n);
            }
      }
Example #25
0
void NoteCanvas::draw(QPainter & p) {
  if (! visible()) return;
  p.setRenderHint(QPainter::Antialiasing, true);
  QRect r = rect();
  QBrush brsh = p.brush();
  QColor bckgrnd = p.backgroundColor();
  QPen fgcolor = p.pen();
  Q3PointArray a(7);
  
  used_color = (itscolor == UmlDefaultColor)
    ? the_canvas()->browser_diagram()->get_color(UmlNote)
    : itscolor;
  
  QColor co = color(used_color);
  
  const int corner_size = (int) (NOTE_MARGIN * the_canvas()->zoom());
  
  a.setPoint(0, r.left(), r.top());
  a.setPoint(1, r.right() - corner_size, r.top());
  a.setPoint(2, r.right() - corner_size, r.top() + corner_size);
  a.setPoint(3, r.right(), r.top() + corner_size);
  a.setPoint(4, r.right(), r.bottom());
  a.setPoint(5, r.left(), r.bottom());
  a.setPoint(6, r.left(), r.top());
  
  FILE * fp = svg();

  if (fp != 0)
    fputs("<g>\n", fp);

  if (used_color == UmlTransparent) {
    p.setBackgroundMode(::Qt::TransparentMode);
    p.setBackgroundColor(co);
    p.drawPolyline(a);

    if (fp != 0)
      draw_poly(fp, a, UmlTransparent);
  }
  else {
    p.setBackgroundMode(::Qt::OpaqueMode);
    p.setBrush(co);
    p.drawPolygon(a, TRUE, 0, 6);
    p.setBrush(brsh);
    p.setBackgroundColor(co);

    if (fp != 0)
      draw_poly(fp, a, used_color);
  }
  
  p.drawLine(r.right() - corner_size, r.top(),
	     r.right(), r.top() + corner_size);

  if (fp != 0)
    fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
	    " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
	    r.right() - corner_size, r.top(), r.right(), r.top() + corner_size);
  
  p.setFont(the_canvas()->get_font(itsfont));
  if (fg_c != UmlTransparent)
    p.setPen(color(fg_c));
  
  p.drawText (r.left() + corner_size, r.top() + corner_size,
	      r.width() - 2*corner_size, r.height() - 2*corner_size, 
	      ::Qt::AlignLeft + ::Qt::AlignTop + ::Qt::TextWordWrap,
	      note);

  if (fp != 0) {
    draw_text(r.left() + corner_size, r.top() + corner_size,
	      r.width() - 2*corner_size, r.height() - 2*corner_size, 
	      ::Qt::AlignLeft + ::Qt::AlignTop + ::Qt::TextWordWrap,
	      note, p.font(), fp, fg_c);
    fputs("</g>\n", fp);
  }

  p.setFont(the_canvas()->get_font(UmlNormalFont));
  p.setBackgroundColor(bckgrnd);
  p.setPen(fgcolor);
  
  if (selected())
    show_mark(p, r);
}
/**
 *	This method implements the PyAttachment::draw interface.  Since
 *	this gui component draws in the world, this is where we do our
 *	actual drawing.
 */
void GoboComponent::draw( bool overlay )
{
	CustomMesh<Moo::VertexXYZDUV2> mesh( D3DPT_TRIANGLEFAN );
	float w = 1.f;
	float h = 1.f;

	Moo::VertexXYZDUV2 v;
	v.colour_ = 0xffffffff;

	Vector3 fixup( -0.5f / SimpleGUI::instance().screenWidth(), 0.5f / SimpleGUI::instance().screenHeight(), 0.f );
	
	v.pos_.set(-1.f,-1.f,0.1f);
	v.uv_.set(0.f,0.f);
	v.uv2_.set(0.f,h);
	mesh.push_back(v);

	v.pos_.set(-1.f,1.f,0.1f);
	v.uv_.set(0.f,1.f);
	v.uv2_.set(0.f,0.f);
	mesh.push_back(v);

	v.pos_.set(1.f,1.f,0.1f);
	v.uv_.set(1.f,1.f);
	v.uv2_.set(w,0.f);
	mesh.push_back(v);

	v.pos_.set(1.f,-1.f,0.1f);
	v.uv_.set(1.f,0.f);
	v.uv2_.set(w,h);
	mesh.push_back(v);

	for (size_t i=0; i<4; i++)
	{
		mesh[i].pos_ = mesh[i].pos_ + fixup;
	}

	//Use a custom mesh to blend the linear texture onto the screen
	if ( visible() )
	{
		Moo::rc().push();
		Moo::rc().preMultiply( runTimeTransform() );
		Moo::rc().device()->SetTransform( D3DTS_WORLD, &Moo::rc().world() );

		if ( !momentarilyInvisible() )
		{		
			SimpleGUI::instance().setConstants(runTimeColour(), pixelSnap());
			this->setConstants();
			material_->begin();
			for ( uint32 i=0; i<material_->nPasses(); i++ )
			{
				material_->beginPass(i);
				if ( !overlay )
				{
					Moo::rc().setRenderState( D3DRS_ZENABLE, TRUE );
					Moo::rc().setRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
					Moo::rc().setRenderState( D3DRS_ZFUNC, D3DCMP_LESS );
				}				
				mesh.drawEffect();				
				material_->endPass();
			}
			material_->end();
			Moo::rc().setVertexShader( NULL );
			Moo::rc().setFVF( GUIVertex::fvf() );
		}
		
		SimpleGUIComponent::drawChildren(overlay);

		Moo::rc().pop();
		Moo::rc().device()->SetTransform( D3DTS_WORLD, &Moo::rc().world() );
	}
	
	momentarilyInvisible( false );
}
Example #27
0
KoDocumentSectionModel::PropertyList KisBaseNode::sectionModelProperties() const
{
    KoDocumentSectionModel::PropertyList l;
    l << KoDocumentSectionModel::Property(i18n("Visible"), KIcon("visible"), KIcon("novisible"), visible());
    l << KoDocumentSectionModel::Property(i18n("Locked"), KIcon("locked"), KIcon("unlocked"), userLocked());
    // XXX: Add linked!
    return l;
}
Example #28
0
void Client::onPose(Array<shared_ptr<Surface> >& posedArray, Array<Surface2DRef>& posed2DArray) {
    GuiWindow::onPose(posedArray, posed2DArray);
    if ((m_osWindow != NULL) && visible()) {
        posed2DArray.append(m_display);
    }
}
Example #29
0
//! is the bounding box visible?
bool geometry::Camera::visible(const geometry::BoundingBox &bounds) const {
	return visible(bounds, view());
}
Example #30
0
void medic_continue (edict_t *self)
{
	if (visible (self, self->enemy) )
		if (random() <= 0.95)
			self->monsterinfo.currentmove = &medic_move_attackHyperBlaster;
}