Ejemplo n.º 1
0
/**
 * Let drivers to drive.
 * Only one driver can drive at the same time.
 * @param input wrapped input
 * @return true when a fish has moved (switch does not count)
 */
    bool
Controls::driving(const InputProvider *input)
{
    bool moved = false;
    if (!useSwitch()) {
        if (!useStroke()) {
            moved = driveUnit(input);
        }
        else {
            moved = true;
        }
    }
    return moved;
}
Ejemplo n.º 2
0
// Draw a fragment of text.  Assumes graphics origin and scaling are correct.
static float drawChars(const string& str, int start, int end, const Font& font, const GFXColor& color, float inRasterPos) {
    // Make sure the graphics state is right.
    glColor4f(color.r, color.g, color.b, color.a);
    if (useStroke()) 
      glLineWidth(font.strokeWidth());
    else {
      static bool setRasterPos= XMLSupport::parse_bool(vs_config->getVariable("graphics","set_raster_text_color","true"));
      if (setRasterPos)
        glRasterPos2f(inRasterPos/(g_game.x_resolution/2),0);
    }

  
    // Draw all the characters.
    for(int charPos=start; charPos<=end; charPos++) {
      inRasterPos+=font.drawChar(str[charPos]);
    }
    return inRasterPos;
}
Ejemplo n.º 3
0
// Draw specified lines of text.
void PaintText::drawLines(int start, int count) const {
    // Make sure we hav a display list.
    calcLayoutIfNeeded();
    // Make sure we have something to do.
    if(m_lines.empty()) {
        return;
    }

    // Initialize the graphics state.
    GFXToggleTexture(false,0);
    if(gl_options.smooth_lines)
    {
	    glEnable(GL_LINE_SMOOTH);
    }
    GFXPushBlendMode();
    GFXBlendMode(SRCALPHA,INVSRCALPHA);
    glPushMatrix();

    // Keep track of line position.
    float lineTop = m_rect.top();

    // Figure ending line index.
    const int end = guiMin(start + count, m_lines.size());

    // Loop through the display list lines.
    for(int i=start; i<end; i++) {
        const TextLine& line = m_lines[i];
        // Make sure we can paint this line in the vertical space we have left.
        if(lineTop - line.height*LINE_HEIGHT_EPSILON < m_rect.origin.y) {
            // Not enough space to draw this line.
            break;
        }

        // Position at the start of the line.
        glLoadIdentity();
        glTranslatef(m_rect.origin.x+line.x, lineTop-line.baseLine, 0.0);
        if (line.fragments.size()) {
          GFXColorf(line.fragments[0].color);
        }        
        if (!useStroke()){
          glRasterPos2f(0,0);
        }else
          glScaled(m_horizontalScaling, m_verticalScaling, 1.0);
        float rasterpos=0;
        // Draw each fragment.
        for(vector<TextFragment>::const_iterator frag=line.fragments.begin(); frag!=line.fragments.end(); frag++) {
            if(frag->start == ELLIPSIS_FRAGMENT) {
                // We have a special-case for the ellipsis at the end of a line.
                drawChars(ELLIPSIS_STRING, 0, 2, frag->font, frag->color,rasterpos);
            } else {
                rasterpos=drawChars(m_text, frag->start, frag->end, frag->font, frag->color,rasterpos);
            }
        }

        // Top of next line.
        lineTop -= line.height;
    }
    glRasterPos2f(0,0);
    // Undo graphics state
    GFXPopBlendMode();
    if(gl_options.smooth_lines)
    {
	    glDisable(GL_LINE_SMOOTH);
    }
    glPopMatrix();
    GFXToggleTexture(true,0);
}