Пример #1
0
sdword DrawTextBlock(char *s, sdword x, sdword y, sdword width, sdword height, color c)
{
    char *oldpos;
    char oldline[100], line[100];
    bool justified, done;

    if(FirstWordNULL(s))
        return(y);
    done = FALSE;
    while (!done)
    {
        justified = FALSE;
        line[0] = 0;
        while (!justified)
        {
            strcpy(oldline, line);
            oldpos = s;
            s = getWord(line, s);

            if (s[0] == '\n')
            {
                justified = TRUE;
                s++;
                while ( s[0] == ' ' ) s++;
            }
            else
            {
                if (fontWidth(line) > width)
                {
                    strcpy(line, oldline);
                    s = oldpos;
                    while ( s[0] == ' ' ) s++;

                    justified = TRUE;
                }
                if (s[0] == 0)
                {
                    justified = TRUE;
                    done      = TRUE;
                }
            }
        }

        fontPrintf(x, y, c, "%s", line);
        y += fontHeight(" ");
        if (y > (y + height))
            done = TRUE;
    }
    y += fontHeight(" ");
    return(y);
}
Пример #2
0
/*-----------------------------------------------------------------------------
    Name        : spScenarioBitmap
    Description :
    Inputs      :
    Outputs     :
    Return      :
----------------------------------------------------------------------------*/
void spScenarioBitmap(featom *atom, regionhandle region)
{
    rectangle textureRect;
    sdword index, y;
    fonthandle oldFont;

    textureRect.x0 = region->rect.x0 + SCP_TEXTURE_INSET;
    textureRect.y0 = region->rect.y0 + SCP_TEXTURE_INSET;
    textureRect.x1 = region->rect.x1 - SCP_TEXTURE_INSET;
    textureRect.y1 = region->rect.y1 - SCP_TEXTURE_INSET;

    //draw the bitmap...
    if (scenarioTexture != TR_InvalidInternalHandle)
    {
        if (glcActive())
        {
            glcRectSolidTexturedScaled2(&textureRect,
                                        spTextureWidth, spTextureHeight,
                                        spTextureData, NULL, TRUE);
        }
        else
        {
            trRGBTextureMakeCurrent(scenarioTexture);
            rndPerspectiveCorrection(FALSE);
            primRectSolidTextured2(&textureRect);               //draw the bitmap
        }
        feStaticRectangleDraw(region);                      //draw a border
    }
    //draw the description text...
    if (spDescription != NULL)
    {                                                       //if there is description text
        dbgAssert(spDescriptionFont != FONT_InvalidFontHandle);
        oldFont = fontMakeCurrent(spDescriptionFont);       //set the font
        if (spDescriptionShadow)
        {                                                   //optionally enable dropshadow
            fontShadowSet(FS_SE, colBlack);
        }
        for (index = 0, y = textureRect.y0; index < spNDescriptionLines; index++)
        {                                                   //draw each line
            dbgAssert(spDescriptionLines[index] != NULL);
            if (y + fontHeight(" ") >= textureRect.y1)
            {                                               //if this line will extend off bottom of region
                break;
            }
            fontPrint(textureRect.x0, y, spDescriptionColor, spDescriptionLines[index]);
            y += fontHeight(" ") + 1;
        }
        fontShadowSet(FS_NONE, colBlack);
        fontMakeCurrent(oldFont);
    }
}
Пример #3
0
void hrDrawChatBox(featom *atom, regionhandle region)
{
    fonthandle currentfont;
    sdword     x,y,i;
    char       name[128];

    hrChatBoxRegion = region;

    currentfont = fontMakeCurrent(playernamefont);

    primRectSolid2(&region->rect,colRGB(0,0,0));
    feStaticRectangleDraw(region);

    x = region->rect.x0+10;
    y = region->rect.y0;

    for (i=0;i<NUM_CHAT_LINES;i++)
    {
        if (chathistory[i].message[0]!=0)
        {
            x = region->rect.x0;
            sprintf(name,"%s >",tpGameCreated.playerInfo[chathistory[i].packetheader.frame].PersonalName);
            fontPrintf(x,y,tpGameCreated.playerInfo[chathistory[i].packetheader.frame].baseColor,"%s",name);
            x+=fontWidth(name)+10;
            //fontShadowSet(FS_E | FS_SE | FS_S);
            fontPrintf(x,y,hrChatTextColor,"%s",chathistory[i].message);
            //fontShadowSet(FS_NONE);
            y+= fontHeight(" ");
        }
    }

    fontMakeCurrent(currentfont);
}
Пример #4
0
void Graphics::drawText(const char_t* text, ulong_t length, const Point& topLeft, bool inverted)
{
    FontEffects fx = font_.effects();    
    PalmUnderlineSetter setUnderline(convertUnderlineMode(fx.underline()));

    ScalingSetter setScaling(*this);

    uint_t height = fontHeight();
    uint_t top=topLeft.y;
    if (fx.subscript())
        top+=(height/3);
    if (inverted)
        WinDrawInvertedChars(text, length, topLeft.x, top);
    else         
        WinDrawChars(text, length, topLeft.x, top);

    if (fx.strikeOut())
    {
        uint_t baseline = fontBaseline();
        top=topLeft.y + (baseline*2)/3;
        uint_t width = FntCharsWidth(text, length);
        Color_t color=setTextColor(0);
        setTextColor(color); // Quite strange method of querying current text color...
        color=setForegroundColor(color);
        WinDrawOperation old;
        if (inverted)
            old=WinSetDrawMode(winInvert);
        drawLine(topLeft.x, top, topLeft.x+width, top);
        if (inverted)
            WinSetDrawMode(old);
        setForegroundColor(color);
    }
  }
Пример #5
0
	//-------------------------------------------------------------------------------
	// BITMAP TEXT ROUTINE: same as Text, but give 3D coordinates in modelspace.
	//-------------------------------------------------------------------------------
	void glText3D(float x, float y, float z, const char *format, ...) {
		va_list args;
		va_start(args, format);
    
		char* buffer;
		if (!(buffer = makeMessage(format, args)))
			return;

		va_end(args);

		glPushAttrib(GL_LIGHTING_BIT); {
			glDisable(GL_LIGHTING);
			glDisable(GL_COLOR_MATERIAL);
			glPushAttrib(GL_COLOR_BUFFER_BIT); {
				glDisable(GL_DITHER);
				glPushAttrib(GL_DEPTH_BUFFER_BIT); {
					glDisable(GL_DEPTH_TEST);
            
					int height = fontHeight(_currentFont);
            
					glRasterPos3f(x, y, z);
            
					for (char *p = buffer; *p; p++) {
						if (*p == '\n') {
							y -= height;
							glRasterPos3f(x, y, z);
						} else {
							glutBitmapCharacter(_currentFont, *p);
						}
					}
					delete[] buffer;
				} glPopAttrib();
			} glPopAttrib();
		} glPopAttrib();
	}
Пример #6
0
/*-----------------------------------------------------------------------------
    Name        : tmNumberRUsDraw
    Description : Callback to draw number of RU's available
    Inputs      :
    Outputs     :
    Return      :
----------------------------------------------------------------------------*/
void tmNumberRUsDraw(featom *atom, regionhandle region)
{
    sdword width;
    fonthandle oldfont;
    rectangle rect = region->rect;
    tmNumberRUsRegion = region;

    oldfont = fontMakeCurrent(tmTechListFont);
    width = fontWidthf("%d", universe.curPlayerPtr->resourceUnits);//width of number

    primModeSet2();
    primRectSolid2(&rect, colRGB(0, 0, 0));

    glEnable(GL_SCISSOR_TEST);
    glScissor(rect.x0, MAIN_WindowHeight - rect.y1, rect.x1 - rect.x0, rect.y1 - rect.y0);
    glClear(GL_DEPTH_BUFFER_BIT);
    glDisable(GL_SCISSOR_TEST);

    feStaticRectangleDraw(region);                          //draw regular rectangle as backdrop
    fontPrintf(region->rect.x1 - width - TM_RUMarginRight,
               (region->rect.y1 - region->rect.y0 - fontHeight(NULL)) / 2 + region->rect.y0,
               atom->borderColor, "%d", universe.curPlayerPtr->resourceUnits);

    fontMakeCurrent(oldfont);
}
Пример #7
0
	//-------------------------------------------------------------------------------
	// BITMAP TEXT ROUTINE: draws the printf style format string(with args) with
	// the bottom-left corner of the string at pixel position(x,y) in the current
	// window with the current color. The bottom-left corner of the window is at
	//(0,0). Many different fonts are available(see currentFont above):
	// The current raster position is updated to the end of the string; check with:
	//  float CurrentRasterPos[4];
	//  glGetFloatv(GL_CURRENT_RASTER_POSITION,CurrentRasterPos);
	//  x=CurrentRasterPos[0]+0.5;
	//  y=CurrentRasterPos[1]+0.5;
	// Setting negative values for x or y will avoid the update of the raster pos;
	// this is useful for continuing more text on the same line after a previous
	// call to Text(). Newline chars('\n') in the string advance the raster position
	// to the next line down(Newline chars are ignored in string continuing on same line).
	//-------------------------------------------------------------------------------
	void glText(int x, int y, const char *format, ...) {
		va_list args;
		va_start(args, format);
    
		char* buffer;
		if (!(buffer = makeMessage(format, args)))
			return;

		va_end(args);

		int WW = glutGet((GLenum)GLUT_WINDOW_WIDTH);
		int WH = glutGet((GLenum)GLUT_WINDOW_HEIGHT);

		glPushAttrib(GL_LIGHTING_BIT); {
			glDisable(GL_LIGHTING);
			glDisable(GL_COLOR_MATERIAL);
			glPushAttrib(GL_COLOR_BUFFER_BIT); {
				glDisable(GL_DITHER);
				glPushAttrib(GL_DEPTH_BUFFER_BIT); {
					glDisable(GL_DEPTH_TEST);
            
					glPushAttrib(GL_VIEWPORT_BIT); {
						glViewport(0, 0, WW, WH);
						glMatrixMode(GL_PROJECTION);
						glPushMatrix(); {
							glLoadIdentity();
							gluOrtho2D(0, WW, 0, WH);
							glMatrixMode(GL_MODELVIEW);
							glPushMatrix(); {
								glLoadIdentity();
                        
								int height = fontHeight(_currentFont);
                        
								if (x >= 0 && y >= 0)
									glRasterPos2i(x, y);
                        
								for (char *p = buffer; *p; p++) {
									if (*p == '\n') {
										if (x>=0 && y>=0) {
											y -= height;
											glRasterPos2i(x, y);
										}
									} else {
										glutBitmapCharacter(_currentFont, *p);
									}
								}
                            
								delete[] buffer;
                        
								glMatrixMode(GL_PROJECTION);
							} glPopMatrix();
							glMatrixMode(GL_MODELVIEW);
						} glPopMatrix();
					} glPopAttrib();
				} glPopAttrib();
			} glPopAttrib();
		} glPopAttrib();
	}
Пример #8
0
/*-----------------------------------------------------------------------------
    Name        : tmSelectTechType
    Description : Find what type of tech was selected
    Inputs      : reg - region clicked on
                  yClicked - vertical location clicked on.
    Outputs     :
    Return      : type of tech clicked on or -1 if none
----------------------------------------------------------------------------*/
sdword tmSelectTechType(regionhandle region, sdword yClicked)
{
    sdword index, y, numlines, startind;
    fonthandle currentFont;
    bool newline = FALSE;

    currentFont = fontMakeCurrent(tmTechListFont);

    numlines = 0;

    startind = 0;

    y = region->rect.y0 + TM_ASMarginTop;

    for (index=startind; index<TM_NUM_TECHS; index++)
    {
        if (y + fontHeight(" ") >= region->rect.y1)
        {
            break;
        }

        if  (tmTechForSale[index] == TM_TECH_IS_FOR_SALE )

        {
            newline=TRUE;
        }


        if ((yClicked < y + fontHeight(" ") + TM_ASInterSpacing)&&(newline))
        {
                return(index);
        }

        if (newline)
        {
            newline = FALSE;

            y+= fontHeight(" ") + TM_ASInterSpacing;
        }
    }

    fontMakeCurrent(currentFont);

    return (-1);
}
Пример #9
0
void WidgetScroll::construct(FrameType type, Window* client, int cWidth, int cHeight) { start_func
    assert(cWidth >= -1);
    assert(cHeight >= -1);

    frameType = type;
    clientArea = client;
    dragMode = FRAME_DRAG_NONE;
    scrollX = scrollY = 0;
    hScrollLine = vScrollLine = fontHeight();
    scrollRepeatTicks = scrollRepeatDelay = 0;
    haveFocus = 0;
    whyDirty = FRAME_DIRTY_ALL;

    // Calculate our constants
    scrollbarButtonSize = fontHeight();
    scrollbarButtonXPad = (scrollbarButtonSize - fontWidth("f", FONT_WIDGET)) / 2;

    if ((frameType == FRAMETYPE_BEVEL) || (frameType == FRAMETYPE_BEVEL_BK)) {
        frameThickness = FRAME_BEVELTHICKNESS;
    }
    else if (frameType == FRAMETYPE_LINE) {
        frameThickness = FRAME_LINETHICKNESS;
    }
    else {
        frameThickness = 0;
    }

    if (client) {
        client->setParent(this);
        if (cWidth == -1) cWidth = client->getWidth();
        if (cHeight == -1) cHeight = client->getHeight();
    }
    else {
        if (cWidth == -1) cWidth = 0;
        if (cHeight == -1) cHeight = 0;
    }
    
    resize(cWidth + frameThickness * 2, cHeight + frameThickness * 2);
}
Пример #10
0
/*-----------------------------------------------------------------------------
    Name        : spScenarioWindowInit
    Description :
    Inputs      :
    Outputs     :
    Return      :
----------------------------------------------------------------------------*/
void spScenarioWindowInit(char *name, featom *atom)
{
    fonthandle  oldfont;
    sdword      index;

    if (FEFIRSTCALL(atom))
    {
        oldfont = fontMakeCurrent(spListFont);

        spScenarioListWindow = (listwindowhandle)atom->pData;

        uicListWindowInit(spScenarioListWindow,
                          NULL,                             // title draw, no title
                          NULL,                             // title click process, no title
                          0/*fontHeight(" ")*2*/,                // title height, no title
                          spScenarioItemDraw,               // item draw function
                          fontHeight(" ")+SCP_VertSpacing,   // item height
                          UICLW_CanSelect|UICLW_CanHaveFocus);


        //spScenarioListWindow->reg.flags |=

        for (index = 0; index < spNumberScenarios; index++)
        {
            if (index==spCurrentSelected)
                uicListAddItem(spScenarioListWindow, (ubyte *)&spScenarios[index], UICLI_CanSelect|UICLI_Selected, UICLW_AddToTail);
            else
                uicListAddItem(spScenarioListWindow, (ubyte *)&spScenarios[index], UICLI_CanSelect, UICLW_AddToTail);
        }

        fontMakeCurrent(oldfont);
        return;
    }
    else
    {
        switch (spScenarioListWindow->message)
        {
            case CM_AcceptText:
                spDonePicking(NULL,NULL);
                break;
            case CM_DoubleClick:

                spDonePicking(NULL,NULL);
                break;
            case CM_NewItemSelected:
                spNewItem();

        }
    }
}
Пример #11
0
void KateRenderer::paintNonBreakSpace(QPainter &paint, qreal x, qreal y)
{
  QPen penBackup( paint.pen() );
  QPen pen( config()->tabMarkerColor() );
  pen.setWidthF(qMax(1.0, spaceWidth() / 10.0));
  paint.setPen( pen );
  paint.setRenderHint(QPainter::Antialiasing, false);

  const int height = fontHeight();
  const int width = spaceWidth();

  QPoint points[6];
  points[0] = QPoint(x+width/10, y+height/4);
  points[1] = QPoint(x+width/10, y+height/3);
  points[2] = QPoint(x+width/10, y+height/3);
  points[3] = QPoint(x+width-width/10, y+height/3);
  points[4] = QPoint(x+width-width/10, y+height/3);
  points[5] = QPoint(x+width-width/10, y+height/4);
  paint.drawLines(points, 3);
  paint.setPen( penBackup );
}
Пример #12
0
void HelpTask::render()
{
    drawBackground();

    const unsigned int x = (SCREEN_WIDTH - background->width) / 2;
    const unsigned int y = (SCREEN_HEIGHT - background->height) / 2;
    drawTextureOverlay(*background, 0, 0, *screen, x, y, background->width, background->height);
    drawString("Help for Crafti v1.1", 0xFFFF, *screen, x, y - fontHeight());

    drawString("8-4-6-2: Walk around    5: Jump\n"
               "7: Put block down    9: Destroy block\n"
               "1-3: Change inventory slot\n"
               "ESC: Save & Exit\n"
               ".: Open list of blocks\n"
               "    5: Change block in inventory\n"
               "    . or ESC: Close list of blocks\n"
               "Menu: Open menu\n"
               "    2-8: Move cursor\n"
               "    5: Select\n"
               "Ctrl+.: Take screenshot\n"
               "\n"
               "Made by Fabian Vogt", 0xFFFF, *screen, x + 10, y + 8);
}
Пример #13
0
void KateRenderer::paintIndentMarker(QPainter &paint, uint x, uint y /*row*/)
{
  QPen penBackup( paint.pen() );
  QPen myPen(config()->indentationLineColor());
  static const QVector<qreal> dashPattern = QVector<qreal>() << 1 << 1;
  myPen.setDashPattern(dashPattern);
  if (y % 2)
    myPen.setDashOffset(1);
  paint.setPen(myPen);

  const int height = fontHeight();
  const int top = 0;
  const int bottom = height-1;

  QPainter::RenderHints renderHints = paint.renderHints();
  paint.setRenderHints(renderHints, false);

  paint.drawLine(x + 2, top, x + 2, bottom);

  paint.setRenderHints(renderHints, true);

  paint.setPen( penBackup );
}
Пример #14
0
void tmTechInfoDraw(featom *atom, regionhandle region)
{
    fonthandle  currentFont;
    sdword      x,y, width;
    char       *pos, *oldpos;
    char        stringtoprint[650];
    bool        justified, done;

    tmTechInfoRegion = region;

    feStaticRectangleDraw(region); //draw standard rectangle

    currentFont = fontMakeCurrent(tmTechListFont);

    x = region->rect.x0 + 15;
    y = region->rect.y0 + 5 ;

    if (tmtechinfo != -1)
    {
        fontPrintf(x,y,TM_SelectionTextColor,"%s",RaceSpecificTechTypeToNiceString(tmtechinfo, universe.curPlayerPtr->race));

        y += TM_VertSpacing + fontHeight(" ");

        // Bad bad design, my fault [Drew] doh!
        if (tmtechinfo==DDDFDFGFTech)
            if (universe.curPlayerPtr->race==R1)
                strcpy(stringtoprint,strGetString(strR1DDDFTechinfo));
            else
                strcpy(stringtoprint,strGetString(strR2DFGFTechinfo));
        else if (tmtechinfo==CloakDefenseFighter)
            if (universe.curPlayerPtr->race==R1)
                strcpy(stringtoprint,strGetString(strR1CloakFighterinfo));
            else
                strcpy(stringtoprint,strGetString(strR2DefenseFighterTechinfo));
        else
            if (universe.curPlayerPtr->race==R1)
                strcpy(stringtoprint,strGetString(tmtechinfo+strTechInfoOffsetR1));
            else
                strcpy(stringtoprint,strGetString(tmtechinfo+strTechInfoOffsetR2));

        pos = stringtoprint;

        done = FALSE;
        while (!done)
        {
            justified = FALSE;
            tline[0]=0;
            while (!justified)
            {
                strcpy(oldtline, tline);
                oldpos = pos;
                pos = getWord(tline, pos);

                if (pos[0] == '\n')
                {
                    justified = TRUE;
                    pos++;
                    while ( pos[0] == ' ' ) pos++;
                }
                else
                {
                    if ( (width=fontWidth(tline)) > TM_InfoWidth - 15)
                    {
                        strcpy(tline, oldtline);
                        pos = oldpos;
                        while ( pos[0] == ' ' ) pos++;

                        justified = TRUE;
                    }
                    if (pos[0]==0)
                    {
                        justified = TRUE;
                        done      = TRUE;
                    }
                }
            }

            fontPrintf(x,y,TM_StandardTextColor,"%s",tline);
            y += fontHeight(" ");
            if (y > region->rect.y1 + fontHeight(" ")) done=TRUE;
        }
    }

    fontMakeCurrent(currentFont);
}
Пример #15
0
void hrDrawPlayersProgress(featom *atom, regionhandle region)
{
    sdword     index;
    rectangle pos;
    rectangle outline;
    real32 percent;
    fonthandle currentfont;
    bool droppedOut;

    hrProgressRegion = region;

    pos = region->rect;

//  primRectSolid2(&pos, colRGBA(0, 0, 0, 64));

    pos.y0+=fontHeight(" ");
    pos.y1=pos.y0+8;

    currentfont = fontMakeCurrent(playernamefont);

    if (multiPlayerGame)
    {
        dbgAssertOrIgnore(sigsNumPlayers == tpGameCreated.numPlayers);
        for (index=0;index<sigsNumPlayers;index++)
        {
            droppedOut = playerHasDroppedOutOrQuit(index);

            outline = pos;
            outline.x0 -= 5;
            outline.x1 += 10;
            outline.y0 -= 3;
            outline.y1 = outline.y0 + fontHeight(" ")*2 - 2;

            if ((hrBackgroundDirty) || (!PlayersAlreadyDrawnDropped[index]))
            {
                PlayersAlreadyDrawnDropped[index] = droppedOut;

                primRectSolid2(&outline, colBlack);

                if (droppedOut)
                {
                    fontPrintf(pos.x0,pos.y0,colBlack,"%s",tpGameCreated.playerInfo[index].PersonalName);
                    fontPrintf(pos.x0,pos.y0,HorseRaceDropoutColor,"%s",
                               (playersReadyToGo[index] == PLAYER_QUIT) ? strGetString(strQuit) : strGetString(strDroppedOut));
                }
                else
                {
                    fontPrintf(pos.x0,pos.y0,tpGameCreated.playerInfo[index].baseColor,"%s",tpGameCreated.playerInfo[index].PersonalName);

                    if (horseracestatus.hrstatusstr[index][0])
                    {
                        fontPrintf(pos.x0+150,pos.y0,tpGameCreated.playerInfo[index].baseColor,"%s",horseracestatus.hrstatusstr[index]);
                    }
                }
            }

            primRectOutline2(&outline, 1, (droppedOut) ? HorseRaceDropoutColor : tpGameCreated.playerInfo[index].stripeColor);

            pos.y0+=fontHeight(" ");
            pos.y1=pos.y0+4;

            percent = horseracestatus.percent[index];

            hrBarDraw(&pos,hrBackBarColor,(droppedOut) ? HorseRaceDropoutColor : tpGameCreated.playerInfo[index].baseColor,percent);

            pos.y0+=fontHeight(" ");
        }
    }
    else if (singlePlayerGame)
    {
        pos = hrSinglePlayerPos;

        // progress bar
        if (pos.x0 != 0)
        {
            percent = horseracestatus.percent[0];

            //dbgMessagef("percent %f",percent);

            hrBarDraw(&pos, colBlack, hrSinglePlayerLoadingBarColor/*teColorSchemes[0].textureColor.base*/, percent);
        }

        // blinking hyperspace destination (render every other call)
        if (++hrProgressCounter % 2 == 0)
        {
            hrBackgroundDirty = 3;  // 1 - nothing happens as decremented before rendered
                                    // 2 - background is cleared but not redrawn
                                    // 3 - 3's the charm
            
            // hyperspace destination circled in first-person view  
            #define SP_LOADING_HYPERSPACE_DEST_CIRCLE_X  115
            #define SP_LOADING_HYPERSPACE_DEST_CIRCLE_Y  342
            
            // hyperspace destination arrowed in "as the bird flies" view 
            #define SP_LOADING_HYPERSPACE_DEST_ARROWS_X  195
            #define SP_LOADING_HYPERSPACE_DEST_ARROWS_Y  134

            // NB: hrDrawFile deals with coordinate mapping

#ifdef _WIN32
            hrDrawFile("feman\\loadscreen\\ring.lif",
                SP_LOADING_HYPERSPACE_DEST_CIRCLE_X, SP_LOADING_HYPERSPACE_DEST_CIRCLE_Y
            );
            hrDrawFile("feman\\loadscreen\\arrows.lif",
                SP_LOADING_HYPERSPACE_DEST_ARROWS_X, SP_LOADING_HYPERSPACE_DEST_ARROWS_Y
            );
#else
            hrDrawFile("feman/loadscreen/ring.lif",
                SP_LOADING_HYPERSPACE_DEST_CIRCLE_X, SP_LOADING_HYPERSPACE_DEST_CIRCLE_Y
            );
            hrDrawFile("feman/loadscreen/arrows.lif",
                SP_LOADING_HYPERSPACE_DEST_ARROWS_X, SP_LOADING_HYPERSPACE_DEST_ARROWS_Y
            );
#endif
        }
    }
    else
    {
        if (hrBackgroundDirty)
        {
            outline = pos;
            outline.x0 -= 5;
            outline.x1 += 10;
            outline.y0 -= 3;
            outline.y1 = outline.y0 + fontHeight(" ")*2 - 2;

            primRectTranslucent2(&outline, colRGBA(0,0,0,64));
            primRectOutline2(&outline, 1, teColorSchemes[0].textureColor.detail);

            fontPrintf(pos.x0,pos.y0,teColorSchemes[0].textureColor.base,"%s",playerNames[0]);
        }

        pos.y0+=fontHeight(" ");
        pos.y1=pos.y0+4;

        percent = horseracestatus.percent[0];

        hrBarDraw(&pos,hrBackBarColor,teColorSchemes[0].textureColor.base,percent);
    }
    fontMakeCurrent(currentfont);
}
Пример #16
0
/*-----------------------------------------------------------------------------
    Name        : trkTrackValuesDisplayFn
    Description : Renders all the track values
    Inputs      :
    Outputs     :
    Return      :
----------------------------------------------------------------------------*/
void trkTrackValuesDisplayFn(void)
{
    sdword index, range;
    sdword x, y, xMin, xMax, xMed, width, height;
    real32 delta, timeElapsed;
    rectangle rect;

    if (keyIsStuck(TRK_ToggleKey))
    {
        keyClearSticky(TRK_ToggleKey);
        trkTrackingVisual ^= TRUE;
    }

    if (!trkTrackingVisual || trkTrackIndex == 0)
    {
        return;
    }

    /*
    if (timeElapsed == 0.0f)
    {
        return;
    }
    */

    height = fontHeight(" ") + 1;
    y = (MAIN_WindowHeight - (height * trkTrackIndex)) / 2;
    width = fontWidth("+100M") + 1;
    x = MAIN_WindowWidth - width * 2 - TRK_TrackWidth;
    xMin = x + width;
    xMax = xMin + TRK_TrackWidth;
    xMed = (xMin + xMax) / 2;
    for (index = 0; index < trkTrackIndex; index++, y += height)
    {
        timeElapsed = *trkValue[index].timer - trkValue[index].lastTime;
        trkValue[index].lastTime = *trkValue[index].timer;
        if (timeElapsed == 0.0f)
        {
            continue;
        }
        //print the name of the value
        fontPrint(x - fontWidth(trkValue[index].name), y, trkValue[index].c, trkValue[index].name);
        delta = abs(*trkValue[index].value - trkValue[index].lastValue) / timeElapsed;//see how much it has changed
        if (delta == 0.0f)
        {   //don't do anything else if it has not changed
            continue;
        }
        //find what range to print in
        if (delta / trkRangeString[0].base > 10.0f)
        {   //if it's bigger than the biggest range
            continue;
        }
        for (range = 0; trkRangeString[range].minusString; range++)
        {
            if (delta / trkRangeString[range].base >= 1.0f)
            {   //if this is the right range
                //get the real delta and bias it against the base
                delta = (trkValue[index].lastValue - *trkValue[index].value) / timeElapsed / trkRangeString[range].base;
                rect.y0 = y;
                rect.y1 = y + height - 1;
                if (delta < 0.0f)
                {
                    rect.x0 = xMed + (sdword)(delta * (real32)TRK_TrackWidth / 20.0f);
                    rect.x1 = xMed;
                }
                else
                {
                    rect.x0 = xMed;
                    rect.x1 = xMed + (sdword)(delta * (real32)TRK_TrackWidth / 20.0f);
                }
                dbgAssert(rect.x0 != rect.x1);
                primRectSolid2(&rect, trkValue[index].c);
                fontPrint(xMin - fontWidth(trkRangeString[range].minusString) - 1, y, colWhite, trkRangeString[range].minusString);
                fontPrint(xMax + 1, y, colWhite, trkRangeString[range].plusString);
                break;
            }
        }
        trkValue[index].lastValue = *trkValue[index].value;
    }
}
Пример #17
0
/*-----------------------------------------------------------------------------
    Name        : svShipViewRender
    Description : Callback which draws the main ship view.
    Inputs      : standard FE callback
    Outputs     : ..
    Return      : void
----------------------------------------------------------------------------*/
void svShipViewRender(featom* atom, regionhandle region)
{
    rectangle drawRect;
    rectangle* rect;
    rectangle viewRect;
    fonthandle currentFont;
    GLint viewPort[4];
    GLint box[4];
    ShipStaticInfo* info;
    real32 scale;
    sdword width, height;
    sdword x, y;
    keyindex key;
    char* keystring;
    bool resetRender = FALSE;
    char    temp[100];

    // facilitates smooth transition between auto/manual rotation of ship
    static real32 angle_user_rotated_to       = 0.0f;
    static real32 declination_user_rotated_to = 0.0f;
    static real32 time_user_rotated_view      = 0.0f;
           real32 real_time_angle             = 0.0f;
    static real32 user_real_angle_offset      = 0.0f;
    
    rect = &region->rect;
    viewRect.x0 = 0;
    viewRect.y0 = 0;
    viewRect.x1 = MAIN_WindowWidth  - 1;
    viewRect.y1 = MAIN_WindowHeight - 1;
    info = NULL;

    if (svShipType != DefaultShip)
    {
        if (universe.curPlayerPtr)
        {
            info = GetShipStaticInfoSafe(svShipType, universe.curPlayerPtr->race);
        }
        if (info == NULL)
        {
            info = GetShipStaticInfoSafe(svShipType, GetValidRaceForShipType(svShipType));
        }
        if (info == NULL)
        {
            return;
        }
    }

    svShipViewRegion = region;

    if (!resetRender)
    {
        if (svMouseInside)
        {
            ferDrawFocusWindow(region, lw_focus);
        }
        else
        {
            ferDrawFocusWindow(region, lw_normal);
        }
    }

    soundEventUpdate();

    currentFont = fontMakeCurrent(svShipViewFont);

    if (region->flags == 0 || region->flags == RPE_DrawFunctionAdded)
    {                                         //if region not processed yet
        region->flags =
            RPE_Enter | RPE_Exit |
            RPE_WheelDown | RPE_WheelUp |
            RPE_PressLeft | RPE_ReleaseLeft |
            RPE_PressRight | RPE_ReleaseRight;

        regFunctionSet(region, (regionfunction) svReadMouseEvent);               //set new region handler function
    }

    //scale = *svScale[svShipType];
        //svCamera.closestZoom  = *svMinZoom[svShipType];
    //svCamera.farthestZoom = *svMaxZoom[svShipType];

    scale = 1.0f; //*svScale[svShipType];

    if(svShipType != DefaultShip)
    {
        svCamera.closestZoom = info->minimumZoomDistance*svZoomInScalar;
        svCamera.farthestZoom = (svCamera.closestZoom+info->staticheader.staticCollInfo.approxcollspheresize)*svZoomOutScalar;
        if(ReZoom)
        {
            ReZoom=FALSE;
            cameraZoom(&svCamera,1.0f,FALSE);
        }

        if (svMouseInside && (wheel_down || wheel_up))
        {
            cameraControl(&svCamera, FALSE);
        }
        else if (svMouseInside && svMousePressRight)
        {
            camMouseX = (svMouseCentreX - mouseCursorX()) * 4;      //was 2
            camMouseY = (svMouseCentreY - mouseCursorY()) * 4;
            savecamMouseX = savecamMouseX * SPIN_FEEDBACK +
                (real32)camMouseX * (1.0f - SPIN_FEEDBACK);
            cameraControl(&svCamera, FALSE);                         //update the camera

            mouseCursorHide();
            mousePositionSet(svMouseCentreX, svMouseCentreY); // Reset position so it doesn't walk off region

            // keep track of where the user left the camera so we can sync auto-rotation with it
            angle_user_rotated_to       = svCamera.angle;
            declination_user_rotated_to = svCamera.declination;
            time_user_rotated_view      = universe.totaltimeelapsed;
        }
        else // auto rotate ship model
        {
            // continual 360 degree yaw rotation
            real_time_angle = DEG_TO_RAD(remainder(universe.totaltimeelapsed, SV_360_ROTATION_SECS) / SV_360_ROTATION_SECS * 360);

            if (angle_user_rotated_to >= 0.0) {
                user_real_angle_offset = angle_user_rotated_to - real_time_angle;
                angle_user_rotated_to = -1.0;
            }

            svCamera.angle = real_time_angle + user_real_angle_offset;
            
            // collapse pitch to default declination
            if (time_user_rotated_view > 0.0) {
                if (universe.totaltimeelapsed > time_user_rotated_view + SV_PITCH_FLATTEN_SECS) {
                    svCamera.declination = DEG_TO_RAD(svDeclination);
                    time_user_rotated_view = 0.0;
                }
                else {
                    svCamera.declination = declination_user_rotated_to + (DEG_TO_RAD(svDeclination) - declination_user_rotated_to) * ((universe.totaltimeelapsed - time_user_rotated_view) / SV_PITCH_FLATTEN_SECS);
                }
            }
            
            if (svMouseInside) mouseCursorShow();
        }
    }
    //rotation

    drawRect.x0 = rect->x0 + SV_ViewMargin;
    drawRect.y0 = rect->y0 + SV_ViewMargin;
    drawRect.x1 = rect->x1 - SV_ViewMargin;
    drawRect.y1 = rect->y1 - SV_ViewMargin;

    width  = drawRect.x1 - drawRect.x0;
    height = drawRect.y1 - drawRect.y0;

    glGetIntegerv(GL_VIEWPORT, viewPort);
    glViewport(drawRect.x0, MAIN_WindowHeight - drawRect.y1, width, height);

    primModeSet2();
    if (!resetRender)
    {
        primRectSolid2(&viewRect, FEC_Background);
    }
    primModeClear2();

    glEnable(GL_SCISSOR_TEST);
    glGetIntegerv(GL_SCISSOR_BOX, box);
    glScissor(drawRect.x0, MAIN_WindowHeight - drawRect.y1, width, height);
    glClear(GL_DEPTH_BUFFER_BIT);
    glDisable(GL_SCISSOR_TEST);

    rndPerspectiveCorrection(TRUE);

    //svCamera.lookatpoint.x = -info->staticheader.staticCollInfo.collsphereoffset.z * scale;
    //svCamera.lookatpoint.y = -info->staticheader.staticCollInfo.collsphereoffset.x * scale;
    //svCamera.lookatpoint.z = -info->staticheader.staticCollInfo.collsphereoffset.y * scale;
    if (svShipType == DefaultShip)
    {
        svCamera.lookatpoint.x=0.0f;
        svCamera.lookatpoint.y=0.0f;
        svCamera.lookatpoint.z=0.0f;
    }
    else
    {
        svCamera.lookatpoint.x = -info->staticheader.staticCollInfo.collsphereoffset.z;
        svCamera.lookatpoint.y = -info->staticheader.staticCollInfo.collsphereoffset.x;
        svCamera.lookatpoint.z = -info->staticheader.staticCollInfo.collsphereoffset.y;
    }

    cameraSetEyePosition(&svCamera);

    rndLightingEnable(TRUE);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    rgluPerspective(
        svCamera.fieldofview,
        (float)(width) / (float)(height) /*rndAspectRatio*/,    //set projection matrix
        svCamera.clipPlaneNear,
        svCamera.clipPlaneFar);

    glMatrixMode(GL_MODELVIEW);

    glLoadIdentity();

    rgluLookAt(
        svCamera.eyeposition.x,
        svCamera.eyeposition.y,
        svCamera.eyeposition.z,
        svCamera.lookatpoint.x,
        svCamera.lookatpoint.y,
        svCamera.lookatpoint.z,
        svCamera.upvector.x,
        svCamera.upvector.y,
        svCamera.upvector.z);

    glPushMatrix();

    glRotatef(-90.0f, 0.0f, 1.0f, 0.0f);

    glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat *)(&rndCameraMatrix));
    glGetFloatv(GL_PROJECTION_MATRIX, (GLfloat *)(&rndProjectionMatrix));

    glEnable(GL_NORMALIZE);

    glLightfv(GL_LIGHT0, GL_POSITION, lightPosition0);      //position light(s) within world

    glScalef(scale, scale, scale);

    if (svShipType != DefaultShip)
    {
        sdword index;
        //try player index colours first
        index = universe.curPlayerIndex;
        if (info->teamColor[index] == 0)
        {
            //colour scheme doesn't exist, search for something valid
            for (index = 0; index < MAX_MULTIPLAYER_PLAYERS; index++)
            {
                if (info->teamColor[index] != 0)
                {
                    break;
                }
            }
            if (index == MAX_MULTIPLAYER_PLAYERS)
            {
                //this ship doesn't have any colour info,
                //at least avoid a GPF
                index = universe.curPlayerIndex;
            }
        }
        meshRender((meshdata *)info->staticheader.LOD->level[0].pData, index);
    }

    glDisable(GL_NORMALIZE);

    glPopMatrix();

    primModeSet2();

    glScissor(box[0], box[1], box[2], box[3]);
    glViewport(viewPort[0], viewPort[1], viewPort[2], viewPort[3]);

    rndLightingEnable(FALSE);
    rndPerspectiveCorrection(FALSE);

    x = rect->x0 + 2 + SV_ViewMargin;
    y = rect->y0 + 2 + SV_ViewMargin;

    if (svShipType != DefaultShip && !resetRender)
    {
        fontPrintf(
            x,
            y,
            FEC_ListItemStandard,
            "%s",
            ShipTypeToNiceStr(svShipType));

        y += fontHeight(" ");

        sprintf(temp, "%s %d %s",strGetString(strSVCost),info->buildCost, strGetString(strSVRUs));

        fontPrintf(
            x,
            y,
            FEC_ListItemStandard,
            temp);

        if (cmPrintHotKey)
        {
            x = rect->x1 - 2 - SV_ViewMargin;
            y = rect->y0 + 2 + SV_ViewMargin;

            key = cmShipTypeToKey(svShipType);
            keystring = opKeyToNiceString((keyindex)(key & 0x00ff));

            if (key & CM_SHIFT)
            {
                width = fontWidthf("[SHIFT-%s]",keystring);
                fontPrintf(
                    x-width,
                    y,
                    FEC_ListItemStandard,
                    "[SHIFT-%s]",
                    keystring);
            }
            else if (key)
            {
                width = fontWidthf("[%s]",keystring);
                fontPrintf(
                    x-width,
                    y,
                    FEC_ListItemStandard,
                    "[%s]",
                    keystring);
            }
        }
    }
    fontMakeCurrent(currentFont);

    svDirtyShipView();
}
Пример #18
0
void TextRender::paint(QPainter* painter)
{
    if (!iTerm)
        return;

    painter->save();
    painter->setFont(iFont);

    int y=0;
    if (iTerm->backBufferScrollPos() != 0 && iTerm->backBuffer().size()>0) {
        int from = iTerm->backBuffer().size() - iTerm->backBufferScrollPos();
        if(from<0)
            from=0;
        int to = iTerm->backBuffer().size();
        if(to-from > iTerm->termSize().height())
            to = from + iTerm->termSize().height();
        paintFromBuffer(painter, iTerm->backBuffer(), from, to, y);
        if(to-from < iTerm->termSize().height() && iTerm->buffer().size()>0) {
            int to2 = iTerm->termSize().height() - (to-from);
            if(to2 > iTerm->buffer().size())
                to2 = iTerm->buffer().size();
            paintFromBuffer(painter, iTerm->buffer(), 0, to2, y);
        }
    } else {
        int count = qMin(iTerm->termSize().height(), iTerm->buffer().size());
        paintFromBuffer(painter, iTerm->buffer(), 0, count, y);
    }

    // cursor
    if (iTerm->showCursor()) {
        painter->setOpacity(0.5);
        QPoint cursor = cursorPixelPos();
        QSize csize = cursorPixelSize();
        painter->setPen(Qt::transparent);
        painter->setBrush(iColorTable[Terminal::defaultFgColor]);
        painter->drawRect(cursor.x(), cursor.y(), csize.width(), csize.height());
    }

    // selection
    QRect selection = iTerm->selection();
    if (!selection.isNull()) {
        painter->setOpacity(0.5);
        painter->setPen(Qt::transparent);
        painter->setBrush(Qt::blue);
        QPoint start, end;

        if (selection.top() == selection.bottom()) {
            start = charsToPixels(selection.topLeft());
            end = charsToPixels(selection.bottomRight());
            painter->drawRect(start.x(), start.y(),
                              end.x()-start.x()+fontWidth(), end.y()-start.y()+fontHeight());
        } else {
            start = charsToPixels(selection.topLeft());
            end = charsToPixels(QPoint(iTerm->termSize().width(), selection.top()));
            painter->drawRect(start.x(), start.y(),
                              end.x()-start.x()+fontWidth(), end.y()-start.y()+fontHeight());

            start = charsToPixels(QPoint(1, selection.top()+1));
            end = charsToPixels(QPoint(iTerm->termSize().width(), selection.bottom()-1));
            painter->drawRect(start.x(), start.y(),
                              end.x()-start.x()+fontWidth(), end.y()-start.y()+fontHeight());

            start = charsToPixels(QPoint(1, selection.bottom()));
            end = charsToPixels(selection.bottomRight());
            painter->drawRect(start.x(), start.y(),
                              end.x()-start.x()+fontWidth(), end.y()-start.y()+fontHeight());
        }
    }

    painter->restore();
}
Пример #19
0
/*-----------------------------------------------------------------------------
    Name        : pingListDraw
    Description : Draw all pings from farthest to nearest.
    Inputs      : camera - the camera we're rendering from
                  modelView, projection - current matrices
                  viewPort - rectangle we're rending in, for the TO legend
    Outputs     :
    Return      :
    Note        : The renderer should be in 2D mode at this point.
----------------------------------------------------------------------------*/
void pingListDraw(Camera *camera, hmatrix *modelView, hmatrix *projection, rectangle *viewPort)
{
    real32 pingAge, pingCycle, pingMod, pingSize;
    real32 x, y, radius;
    Node *thisNode, *nextNode;
    ping *thisPing;
    vector distSquared;
    sdword nSegments, index, rowHeight, xScreen, yScreen;
    oval o;
    udword TOFlags = 0;
    fonthandle fhSave;
    toicon *icon;
    color col;
    real32 realMargin;
    ShipClass shipClass;
    static real32 lastProximityPing = REALlyBig;
    static real32 lastAnomolyPing = REALlyBig;
    static real32 lastBattlePing = REALlyBig;
    static real32 lastHyperspacePing = REALlyBig;
    static real32 lastNewshipPing = REALlyBig;
    bool pingset;

    //start by sorting the ping list from farthest to nearest
    thisNode = pingList.head;

    while (thisNode != NULL)
    {                                                       //scan all pings
        nextNode = thisNode->next;
        thisPing = listGetStructOfNode(thisNode);

        if (thisPing->owner != NULL)
        {
            thisPing->centre = thisPing->owner->posinfo.position;
        }
        vecSub(distSquared, camera->eyeposition, thisPing->centre);
        thisPing->cameraDistanceSquared = vecMagnitudeSquared(distSquared);
        TOFlags |= thisPing->TOMask;

        thisNode = nextNode;
    }
    listMergeSortGeneral(&pingList, pingListSortCallback);

    //now the list is sorted; proceed to draw all the pings
    thisNode = pingList.head;

    pingset = FALSE;

    while (thisNode != NULL)
    {                                                       //scan all pings
        nextNode = thisNode->next;
        thisPing = listGetStructOfNode(thisNode);

        pingCycle = thisPing->pingDuration + thisPing->interPingPause;
        pingAge = universe.totaltimeelapsed - thisPing->creationTime;
        pingMod = (real32)fmod((double)pingAge, (double)pingCycle);
        if (pingMod <= thisPing->pingDuration)
        {
            pingSize = (thisPing->size - thisPing->minSize) * pingMod / thisPing->pingDuration + thisPing->minSize;
            selCircleComputeGeneral(modelView, projection, &thisPing->centre, max(thisPing->size,thisPing->minSize), &x, &y, &radius);
            if (radius > 0.0f)
            {
                radius = max(radius, thisPing->minScreenSize);
                radius *= pingSize / max(thisPing->size,thisPing->minSize);
                o.centreX = primGLToScreenX(x);
                o.centreY = primGLToScreenY(y);
                o.radiusX = o.radiusY = primGLToScreenScaleX(radius);
                nSegments = pieCircleSegmentsCompute(radius);
                primOvalArcOutline2(&o, 0.0f, 2*PI, 1, nSegments, thisPing->c);

                /* starting to draw a new ping so play the sound */
                if (!smZoomingIn && !smZoomingOut && !pingset)
                {
                    switch (thisPing->TOMask)
                    {
                        case PTOM_Anomaly:
                            if (pingSize <=lastAnomolyPing)
                            {
                                soundEvent(NULL, UI_SensorsPing);
                                pingset = TRUE;
                                lastAnomolyPing = pingSize;
                            }
                            break;
                        case PTOM_Battle:
                            if (pingSize <= lastBattlePing)
                            {
                                soundEvent(NULL, UI_PingBattle);
                                pingset = TRUE;
                                lastBattlePing = pingSize;
                            }
                            break;
                        case PTOM_Hyperspace:
                            if (pingSize <=  lastHyperspacePing)
                            {
                                soundEvent(NULL, UI_PingHyperspace);
                                pingset = TRUE;
                                lastHyperspacePing = pingSize;
                            }
                            break;
                        case PTOM_Proximity:
                            if (pingSize <= lastProximityPing)
                            {
                                soundEvent(NULL, UI_PingProximity);
                                pingset = TRUE;
                                lastProximityPing = pingSize;
                            }
                            break;
                        case PTOM_NewShips:
                            if (pingSize <= lastNewshipPing)
                            {
                                soundEvent(NULL, UI_PingNewShips);
                                pingset = TRUE;
                                lastNewshipPing = pingSize;
                            }
                            break;
                        default:
                            break;
                    }
                }
            }
        }

        thisNode = nextNode;
    }

    //draw the blip TO
    if (smTacticalOverlay)
    {
        realMargin = primScreenToGLScaleX(viewPort->x0);
        fhSave = fontCurrentGet();                          //save the current font
        fontMakeCurrent(selGroupFont2);                     // use a common, fairly small font
        rowHeight = fontHeight("M");                        // used to space the legend
        yScreen = viewPort->y0 + rowHeight;                 //leave some space at the top to start
        radius = primScreenToGLScaleX(rowHeight)/2;
        xScreen = viewPort->x0 + (sdword)(rowHeight * 2.5);

        for (index = 0; index < PTO_NumberTOs; index++)
        {
            if ((TOFlags & pingTOList[index].bitMask))
            {
    //            fontPrint(xScreen, yScreen, *pingTOList[index].c, "O");
                pingTOList[index].lastTimeDrawn = universe.totaltimeelapsed;
            }
            if (universe.totaltimeelapsed - pingTOList[index].lastTimeDrawn <= pingTOLingerTime)
            {
                o.centreX = viewPort->x0 + rowHeight * 3 / 2;
                o.centreY = yScreen + rowHeight / 2;
                o.radiusX = o.radiusY = rowHeight / 2;
                primOvalArcOutline2(&o, 0.0f, TWOPI, 1, pingTONSegments, *pingTOList[index].c);
                fontPrint(xScreen, yScreen, TO_TextColor, strGetString(pingTOList[index].stringEnum));
                yScreen += rowHeight + 1;
            }
        }
        for (shipClass = 0; shipClass < NUM_CLASSES; shipClass++)
        {
            if (!toClassUsed[shipClass][0])
            {
                continue;
            }
            icon = toClassIcon[shipClass];
            fontPrint(xScreen, yScreen + (rowHeight>>2), TO_TextColor, ShipClassToNiceStr(shipClass));
#if TO_STANDARD_COLORS
            col = teFriendlyColor;
#else
            col = teColorSchemes[universe.curPlayerIndex].tacticalColor;
#endif
            col = colRGB(colRed(col)/TO_IconColorFade, colGreen(col)/TO_IconColorFade, colBlue(col)/TO_IconColorFade);
            primLineLoopStart2(1, col);

            for (index = icon->nPoints - 1; index >= 0; index--)
            {
               primLineLoopPoint3F(realMargin + primScreenToGLX(rowHeight*1.5) + icon->loc[index].x * radius,
                                          primScreenToGLY(yScreen + rowHeight/2) + icon->loc[index].y * radius);
            }
            primLineLoopEnd2();
            yScreen += rowHeight + 1;
        }

        fontMakeCurrent(fhSave);
    }
}
Пример #20
0
/*-----------------------------------------------------------------------------
    Name        : gpGameWindowInit
    Description :
    Inputs      :
    Outputs     :
    Return      :
----------------------------------------------------------------------------*/
void gpGameWindowInit(char *name, featom *atom)
{
    fonthandle  oldfont;
    sdword      index;

    if (FEFIRSTCALL(atom))
    {
        if (strcmp(name,"FE_RecordedGameWindowInit") == 0)
        {
            SavedGamesPath = RecordedGamesPath;
        }
        else if (strcmp(name,"FE_TutorialGameWindowInit") == 0)
        {
            SavedGamesPath = TutorialSavedGamesPath;
            tutorial = TUTORIAL_ONLY;
            gpLoadTutorial = TRUE;
            gpLoadSinglePlayerGame = TRUE;
        }
        else
        {
            if (gameIsRunning)
            {
                if (singlePlayerGame)
                {
                    gpLoadSinglePlayerGame = TRUE;
                }
                else
                {
                    gpLoadSinglePlayerGame = FALSE;
                }

                gpLoadTutorial = (tutorial==TUTORIAL_ONLY) ? TRUE : FALSE;
            }
            else
            {
                if (mgRunning)
                {
                    gpLoadSinglePlayerGame = FALSE;
                }
                else
                {
                    gpLoadSinglePlayerGame = TRUE;
                }

                gpLoadTutorial = (tutorial==TUTORIAL_ONLY) ? TRUE : FALSE;
            }

            if (gpLoadSinglePlayerGame)
            {
                SavedGamesPath = gpLoadTutorial ? TutorialSavedGamesPath : SinglePlayerSavedGamesPath;
            }
            else
            {
                SavedGamesPath = MultiPlayerSavedGamesPath;
            }
        }

        gpTitleListLoad();

        oldfont = fontMakeCurrent(gpListFont);

        gpGameListWindow = (listwindowhandle)atom->pData;

        uicListWindowInit(gpGameListWindow,
                          NULL,                             // title draw, no title
                          NULL,                             // title click process, no title
                          0,                                // title height, no title
                          gpGameItemDraw,                   // item draw function
                          fontHeight(" ")+GP_VertSpacing,   // item height
                          UICLW_CanSelect|UICLW_CanHaveFocus);

        for (index = 0; index < gpNumberGames; index++)
        {
            if (index == 0)
            {
                uicListAddItem(gpGameListWindow, (ubyte *)&gpGames[index], UICLI_CanSelect|UICLI_Selected, UICLW_AddToTail);
                gpCurrentSelected = 0;
            }
            else
            {
                uicListAddItem(gpGameListWindow, (ubyte *)&gpGames[index], UICLI_CanSelect, UICLW_AddToTail);
            }
        }

        fontMakeCurrent(oldfont);
        return;
    } else if (FELASTCALL(atom))
    {
        gpGameListWindow = NULL;
        return;
    }
    else if (gpGameListWindow->message == CM_NewItemSelected)
    {
        if (gpNameEntryBox != NULL)
        {
            uicTextEntrySet(gpNameEntryBox, ((gpgame *)gpGameListWindow->CurLineSelected->data)->title,strlen(((gpgame *)gpGameListWindow->CurLineSelected->data)->title));
        }
    }
}
Пример #21
0
void gpDeleteGame(char *name, featom *atom)
{
    char filename[PATH_MAX] = "";
    sdword i;
    sdword index;
    fonthandle  oldfont;

    if (!gpGetGameName(name,atom,filename))
    {
        return;
    }

    // gpCurrentSelected will be set by gpGetGameName

    feScreenDisappear(NULL, NULL);

    char *tmpFilePath = filePathPrepend(filename, FF_UserSettingsPath);
    strcpy(filename, tmpFilePath);
    fileDelete(filename);

    if (SavedGamesPath == RecordedGamesPath)
    {
        char tmpfile[PATH_MAX] = "";
        strcpy(tmpfile,filename);
        strcat(tmpfile,PKTS_EXTENSION);
        fileDelete(tmpfile);
    }

    for (i=gpCurrentSelected;i<gpNumberGames-1;i++)
    {
        gpGames[i] = gpGames[i+1];
    }
    gpNumberGames--;
    if (gpNumberGames == 0)
    {
        gpCurrentSelected = 0;
    }
    else if (gpCurrentSelected >= gpNumberGames)
    {
        gpCurrentSelected--;
        dbgAssertOrIgnore(gpCurrentSelected >= 0);
        dbgAssertOrIgnore(gpCurrentSelected < gpNumberGames);
    }

    dbgAssertOrIgnore(gpNumberGames >= 0);

    oldfont = fontMakeCurrent(gpListFont);      // fontHeight called later on in this function

    uicListCleanUp(gpGameListWindow);

    uicListWindowInit(gpGameListWindow,
                      NULL,                             // title draw, no title
                      NULL,                             // title click process, no title
                      0,                                // title height, no title
                      gpGameItemDraw,                   // item draw function
                      fontHeight(" ")+GP_VertSpacing,   // item height
                      UICLW_CanSelect);

    for (index = 0; index < gpNumberGames; index++)
    {
        if (index==gpCurrentSelected)
            uicListAddItem(gpGameListWindow, (ubyte *)&gpGames[index], UICLI_CanSelect|UICLI_Selected, UICLW_AddToTail);
        else
            uicListAddItem(gpGameListWindow, (ubyte *)&gpGames[index], UICLI_CanSelect, UICLW_AddToTail);
    }

    fontMakeCurrent(oldfont);
}
Пример #22
0
void WorldTask::render()
{
    aabb = {x - player_width/2, y, z - player_width/2, x + player_width/2, y + player_height, z + player_width/2};
    //printf("X: %f Y: %f Z: %f XR: %d YR: %d\n", x.toFloat(), y.toFloat(), z.toFloat(), xr.toInt(), yr.toInt());

    glColor3f(0.4f, 0.6f, 0.8f); //Blue background
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glPushMatrix();

    //Inverted rotation of the world
    nglRotateX((GLFix(359) - xr).normaliseAngle());
    nglRotateY((GLFix(359) - yr).normaliseAngle());
    //Inverted translation of the world
    glTranslatef(-x, -y - eye_pos, -z);

    glBindTexture(terrain_current);

    world.render();

    //Draw indication
    glBindTexture(&blockselection);

    glBegin(GL_QUADS);

    //Do a quick animation
    const unsigned int blockselection_frame_width = blockselection.width / blockselection_frames;
    TextureAtlasEntry tex = textureArea(0, 0, blockselection_frame_width, blockselection.height);
    tex.left += blockselection_frame_width * blockselection_frame;
    tex.right += blockselection_frame_width * blockselection_frame;

    //Only increment the frame nr each 5 frames
    if(++blockselection_frame_fraction == 5)
    {
        blockselection_frame_fraction = 0;

        if(++blockselection_frame == blockselection_frames)
            blockselection_frame = 0;
    }

    const GLFix indicator_x = selection_pos.x * BLOCK_SIZE, indicator_y = selection_pos.y * BLOCK_SIZE, indicator_z = selection_pos.z * BLOCK_SIZE;
    const GLFix selection_offset = 3; //Needed to prevent Z-fighting
    switch(selection_side)
    {
    case AABB::FRONT:
        nglAddVertex({indicator_x, indicator_y, selection_pos_abs.z - selection_offset, tex.left, tex.bottom, TEXTURE_TRANSPARENT});
        nglAddVertex({indicator_x, indicator_y + BLOCK_SIZE, selection_pos_abs.z - selection_offset, tex.left, tex.top, TEXTURE_TRANSPARENT});
        nglAddVertex({indicator_x + BLOCK_SIZE, indicator_y + BLOCK_SIZE, selection_pos_abs.z - selection_offset, tex.right, tex.top, TEXTURE_TRANSPARENT});
        nglAddVertex({indicator_x + BLOCK_SIZE, indicator_y, selection_pos_abs.z - selection_offset, tex.right, tex.bottom, TEXTURE_TRANSPARENT});
        break;
    case AABB::BACK:
        nglAddVertex({indicator_x + BLOCK_SIZE, indicator_y, selection_pos_abs.z + selection_offset, tex.left, tex.bottom, TEXTURE_TRANSPARENT});
        nglAddVertex({indicator_x + BLOCK_SIZE, indicator_y + BLOCK_SIZE, selection_pos_abs.z + selection_offset, tex.left, tex.top, TEXTURE_TRANSPARENT});
        nglAddVertex({indicator_x, indicator_y + BLOCK_SIZE, selection_pos_abs.z + selection_offset, tex.right, tex.top, TEXTURE_TRANSPARENT});
        nglAddVertex({indicator_x, indicator_y, selection_pos_abs.z + selection_offset, tex.right, tex.bottom, TEXTURE_TRANSPARENT});
        break;
    case AABB::RIGHT:
        nglAddVertex({selection_pos_abs.x + selection_offset, indicator_y, indicator_z, tex.right, tex.bottom, TEXTURE_TRANSPARENT});
        nglAddVertex({selection_pos_abs.x + selection_offset, indicator_y + BLOCK_SIZE, indicator_z, tex.right, tex.top, TEXTURE_TRANSPARENT});
        nglAddVertex({selection_pos_abs.x + selection_offset, indicator_y + BLOCK_SIZE, indicator_z + BLOCK_SIZE, tex.left, tex.top, TEXTURE_TRANSPARENT});
        nglAddVertex({selection_pos_abs.x + selection_offset, indicator_y, indicator_z + BLOCK_SIZE, tex.left, tex.bottom, TEXTURE_TRANSPARENT});
        break;
    case AABB::LEFT:
        nglAddVertex({selection_pos_abs.x - selection_offset, indicator_y, indicator_z + BLOCK_SIZE, tex.left, tex.bottom, TEXTURE_TRANSPARENT});
        nglAddVertex({selection_pos_abs.x - selection_offset, indicator_y + BLOCK_SIZE, indicator_z + BLOCK_SIZE, tex.left, tex.top, TEXTURE_TRANSPARENT});
        nglAddVertex({selection_pos_abs.x - selection_offset, indicator_y + BLOCK_SIZE, indicator_z, tex.right, tex.top, TEXTURE_TRANSPARENT});
        nglAddVertex({selection_pos_abs.x - selection_offset, indicator_y, indicator_z, tex.right, tex.bottom, TEXTURE_TRANSPARENT});
        break;
    case AABB::TOP:
        nglAddVertex({indicator_x, selection_pos_abs.y + selection_offset, indicator_z, tex.left, tex.bottom, TEXTURE_TRANSPARENT});
        nglAddVertex({indicator_x, selection_pos_abs.y + selection_offset, indicator_z + BLOCK_SIZE, tex.left, tex.top, TEXTURE_TRANSPARENT});
        nglAddVertex({indicator_x + BLOCK_SIZE, selection_pos_abs.y + selection_offset, indicator_z + BLOCK_SIZE, tex.right, tex.top, TEXTURE_TRANSPARENT});
        nglAddVertex({indicator_x + BLOCK_SIZE, selection_pos_abs.y + selection_offset, indicator_z, tex.right, tex.bottom, TEXTURE_TRANSPARENT});
        break;
    case AABB::BOTTOM:
        nglAddVertex({indicator_x + BLOCK_SIZE, selection_pos_abs.y - selection_offset, indicator_z, tex.left, tex.bottom, TEXTURE_TRANSPARENT});
        nglAddVertex({indicator_x + BLOCK_SIZE, selection_pos_abs.y - selection_offset, indicator_z + BLOCK_SIZE, tex.left, tex.top, TEXTURE_TRANSPARENT});
        nglAddVertex({indicator_x, selection_pos_abs.y - selection_offset, indicator_z + BLOCK_SIZE, tex.right, tex.top, TEXTURE_TRANSPARENT});
        nglAddVertex({indicator_x, selection_pos_abs.y - selection_offset, indicator_z, tex.right, tex.bottom, TEXTURE_TRANSPARENT});
        break;
    case AABB::NONE:
        break;
    }
    glEnd();

    glPopMatrix();

    crosshairPixel(0, 0);
    crosshairPixel(-1, 0);
    crosshairPixel(-2, 0);
    crosshairPixel(0, -1);
    crosshairPixel(0, -2);
    crosshairPixel(1, 0);
    crosshairPixel(2, 0);
    crosshairPixel(0, 1);
    crosshairPixel(0, 2);

    //Don't draw the inventory if the block list will be opened, it will draw the inventory itself
    if(!keyPressed(KEY_NSPIRE_PERIOD) || key_held_down)
    {
        current_inventory.draw(*screen);
        drawStringCenter(global_block_renderer.getName(current_inventory.currentSlot()), 0xFFFF, *screen, SCREEN_WIDTH / 2, SCREEN_HEIGHT - current_inventory.height() - fontHeight());
    }

    if(message_timeout > 0)
    {
        drawString(message, 0xFFFF, *screen, 2, 5);
        --message_timeout;
    }
}
Пример #23
0
//------------------------------------------------------------------------------
GDChart & GDChart::createChart()
{
  create(width_,height_);

  bool isIntergerOnlyValues = true;
  intptr_t i, j, xCount = 0, x, y, x0 = 0, y0 = 0;
  // calc min max
  ldouble minValue = DBL_MAX, maxValue = -DBL_MAX;
  for( i = data_.count() - 1; i >= 0; i-- ){
    j = data_[i].count();
    xCount = tmax(xCount,j);
    const Array<ldouble> & data = data_[i];
    for( j = data.count() - 1; j >= 0; j-- ){
      volatile intmax_t v = intmax_t(data[j]);
      volatile ldouble lv = ldouble(v);
      if( lv != data[j] ) isIntergerOnlyValues = false;
      minValue = tmin(minValue,data[j]);
      maxValue = tmax(maxValue,data[j]);
    }
  }
  ldouble yAxis = (maxValue - minValue) / (height_ - topBorder_ - bottomBorder_);
  intptr_t leftBorderDelta = 0, rightBorderDelta = 0, topBorderDelta = 0, bottomBorderDelta = 0;
  // clear image
  fill(0,0,colorAllocate(255,255,255));
  // draw lines
  intptr_t lineColor = colorAllocate(230,230,230);
  // draw vert grid lines
  for( j = 0; j < xCount; j++ ){
    x = (width_ - leftBorder_ - rightBorder_) * j / (xCount - 1) + leftBorder_;
    line(x,topBorder_,x,height_ - bottomBorder_,lineColor);
  }
  intptr_t yLabelColor = makeColor(ldouble(j),ldouble(j),ldouble(j));
  for( y = topBorder_; uintptr_t(y) <= height_ - bottomBorder_; y += fontHeight(font_) * 2 ){
    ldouble v = maxValue - (y - topBorder_) * yAxis;
    // draw horiz grid line
    line(leftBorder_,y,width_ - rightBorder_,y,lineColor);
    // draw ylabel
    utf8::String label;
    if( isIntergerOnlyValues ){
      label = printTraffic(intmax_t(v),true);//utf8::String::print("%"PRIdPTR,intptr_t(v));
    }
    else {
      label = utf8::String::print("%.2"PRF_LDBL"f",v);
    }
    uintptr_t sz = label.size();
    x = leftBorder_ - sz * fontWidth(font_);
    string(GD::font(font_),x,y,label.c_str(),yLabelColor);
    if( x < 0 && -x > leftBorderDelta ) leftBorderDelta = -x;
  }
  // draw data lines
  for( i = 0; uintptr_t(i) < data_.count(); i++ ){
    intptr_t color = makeColor(ldouble(i + 1),ldouble(i + 1),ldouble(i + 1));
    const Array<ldouble> & data = data_[i];
    for( j = 0; uintptr_t(j) < data.count(); j++ ){
      x = (width_ - leftBorder_ - rightBorder_) * j / (xCount - 1) + leftBorder_;
      y = intptr_t(height_ - topBorder_ - bottomBorder_ - (data[j] - minValue) / yAxis) + topBorder_;
      if( j > 0 ) line(x0,y0,x,y,color);
      x0 = x;
      y0 = y;
    }
  }
  intptr_t xBarSize = 2, yBarSize = 2;
  intptr_t barColor = colorAllocate(255,0,0);
  intptr_t xLabelColor = makeColor(ldouble(i + 1),ldouble(i + 1),ldouble(i + 1));
  for( i = 0; uintptr_t(i) < data_.count(); i++ ){
    const Array<ldouble> & data = data_[i];
    for( j = 0; uintptr_t(j) < data.count(); j++ ){
      x = (width_ - leftBorder_ - rightBorder_) * j / (xCount - 1) + leftBorder_;
      y = intptr_t(height_ - topBorder_ - bottomBorder_ - (data[j] - minValue) / yAxis) + topBorder_;
      // draw bar
      filledRectangle(
        tmax(leftBorder_,uintptr_t(x - xBarSize)),
        tmax(topBorder_,uintptr_t(y - yBarSize)),
        tmin(width_ - rightBorder_,uintptr_t(x + xBarSize)),
        tmin(height_ - bottomBorder_,uintptr_t(y + yBarSize)),
        barColor
      );
      x0 = x;
      y0 = y;
      // draw xlabel
      y = height_ - bottomBorder_ + xBarSize;
      utf8::String label(utf8::String::print("%"PRIdPTR,intptr_t(j + xlvs_)));
      string(GD::font(font_),x + xBarSize,y,label.c_str(),xLabelColor);
      if( y + fontHeight(font_) >= height_ )
        bottomBorderDelta = y + fontHeight(font_) - height_ + 1;
      x = x + xBarSize + fontWidth(font_) * label.size();
      if( uintptr_t(x) >= width_ ) rightBorderDelta = x - width_ + 1;
    }
  }
  if( leftBorderDelta != 0 || rightBorderDelta != 0 || topBorderDelta != 0 || bottomBorderDelta != 0 ){
    GDChart chart(*this);
    chart.leftBorder_ += leftBorderDelta;
    chart.rightBorder_ += rightBorderDelta;
    chart.topBorder_ += topBorderDelta;
    chart.bottomBorder_ += bottomBorderDelta;
    chart.createChart();
    xchg(image_,chart.image_);
    xchg(png_,chart.png_);
    xchg(pngSize_,chart.pngSize_);
  }
  else {
    gdFree(png_);
    png_ = pngPtrEx(&pngSize_,9);
  }
  return *this;
}
Пример #24
0
/*-----------------------------------------------------------------------------
    Name        : gcChatTextDraw
    Description : draws the chat history window and prompts for text entry.
    Inputs      : standard draw callbacks.
    Outputs     : none
    Return      : void
----------------------------------------------------------------------------*/
void gcChatTextDraw(featom *atom, regionhandle region)
{
    fonthandle      oldfont;
    sdword          x,y=region->rect.y0,lines=0;
    char            temp[512], *string;
    Node           *walk=NULL;
    chathistory    *chat;

    if (!mrRenderMainScreen) return;

    oldfont = fontMakeCurrent(chathistoryfont);
    fontShadowSet(FS_SE, colBlack);

    if (InChatMode)
    {
        switch (MessageToAllies)
        {
            case GC_ChatToAllies:
                //sprintf(temp,"To Allies: ");
                string = strGetString(strToAllies);
            break;
            case GC_ChatToAll:
                //sprintf(temp,"Say: ");
                string = strGetString(strSay);
            break;
            case GC_RUTransfer:
                //sprintf(temp,"RU Amount: ");
                string = strGetString(strRUAmount);
            break;
        }

        x = region->rect.x0;
        fontPrint(x,y,colWhite,string);
        y+= fontHeight(" ");
        lines++;
    }

    if (curPosition != NULL)
    {
        walk = curPosition;
    }

    if (walk!=NULL)
    {
        do
        {
            x = region->rect.x0;

            chat = listGetStructOfNode(walk);

            switch (chat->messageType)
            {
                case GC_NORMALMESSAGE:
                {
                    sprintf(temp,"<%s>",playerNames[chat->playerindex]);
                    fontPrint(x,y,tpGameCreated.playerInfo[chat->playerindex].baseColor,temp);
                    x+=fontWidth(temp);

                    sprintf(temp,"  %s",chat->chatstring);
                    fontPrint(x,y,gcGameNormalChatColor,temp);
                }
                break;
                case GC_WHISPEREDMESSAGE:
                {
                    sprintf(temp,"<%s>",playerNames[chat->playerindex]);
                    fontPrint(x,y,tpGameCreated.playerInfo[chat->playerindex].baseColor,temp);
                    x+=fontWidth(temp);

                    sprintf(temp, strGetString(strWhisperedMessage));
                    fontPrint(x,y,gcGameWhisperedColor, temp);
                    x+=fontWidth(temp);

                    sprintf(temp,"  %s",chat->chatstring);
                    fontPrint(x,y,gcGamePrivateChatColor,temp);
                }
                break;
                case GC_TEXTMESSAGE:
                {
                    fontPrint(x,y,chat->col,chat->chatstring);
                }
                break;
                case GC_BUFFERSTART:
                {
                    if (ViewingBuffer)
                    {
                        //sprintf(temp,"^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^");
                        fontPrint(x,y,gcGameNormalChatColor,strGetString(strStartOfBuffer));
                    }
                }
                break;
                case GC_BUFFEREND:
                {
                    if (ViewingBuffer)
                    {
                        //sprintf(temp,"v v v v v v v v v v v v v v v v v v v v v v v v");
                        fontPrint(x,y,gcGameNormalChatColor,strGetString(strEndOfBuffer));
                    }
                }
                break;
                case GC_WRAPMESSAGE:
                {
                    x+= chat->indent;
                    fontPrint(x,y,chat->col,chat->chatstring);
                }
                break;
            }

            y += fontHeight(" ");
            lines++;

            walk = walk->next;
        }
        while ((walk!=NULL) && (lines < maxlines));

        if ((ScrollDownAutoBaby==NULL) && (!ViewingBuffer) && (curPosition->next != NULL))
        {
            ScrollDownAutoBaby = taskCallBackRegister(gcScrollDownAuto, 0, NULL, GC_SCROLL_TIME);
        }
    }

    fontShadowSet(FS_NONE, colBlack);
    fontMakeCurrent(oldfont);
}
Пример #25
0
/*-----------------------------------------------------------------------------
    Name        : tmTechCostsDraw
    Description : Draw the cost of building selected techs.
    Inputs      : feflow callback
    Outputs     : ..
    Return      : void
----------------------------------------------------------------------------*/
void tmCostListDraw(featom *atom, regionhandle region)
{
    udword price;
    sdword x, y, index;
    rectangle *rect = &region->rect;
    bool        newline=FALSE;
    color c;
    fonthandle currentFont;
    sdword  numlines;

    currentFont = fontCurrentGet();
    fontMakeCurrent(tmTechListFont);

    tmCostListRegion = region;

    numlines = 0;


    for (index=0; index<TM_NUM_TECHS; index++)
    {
        if  (tmTechForSale[index] == TM_TECH_IS_FOR_SALE)
            newline=TRUE;
        if (newline)
        {
            newline = FALSE;
            numlines++;
        }
    }

    y = region->rect.y0 + TM_ASMarginTop;

    newline=FALSE;
    numlines=0;

    for (index=0; index < TM_NUM_TECHS; index++)
    {
        price = (tmTechPrice[index] * tmPriceScale) / 100;
        if (y + fontHeight(" ") >= region->rect.y1)
        {
            break;
        }

        if (tmTechForSale[index] == TM_TECH_IS_FOR_SALE)
        {
            if (universe.curPlayerPtr->resourceUnits < price)
            {                                                   //if this tech already selected
                c = TM_CantAffordTextColor;
            }

            else
            {
                c = TM_StandardTextColor;
            }
                        //tech fancy name
            x = rect->x1 - TM_ASMarginLeft - fontWidthf("%d", price);
            fontPrintf(x, y, c, "%d", price);

            newline = TRUE;

            tmDirtyTechInfo();
        }
        if (newline)
        {
            newline = FALSE;

            y+= fontHeight(" ") + TM_ASInterSpacing;

        }
    }

    fontMakeCurrent(currentFont);
}
Пример #26
0
	int fontHeight() {
		return fontHeight(_currentFont);
	}
Пример #27
0
void tmDialogDraw(featom *atom, regionhandle region)
{
    sdword      x,y, width;
    char       *pos, *oldpos;
    char        stringtoprint[650];
    bool        justified, done;
    fonthandle oldfont;

    char tmKASMissing[] = "Hello there, fellow space travellers!  Until somebdoy gives me some new lines in KAS, that is all I can say.";

    tmDialogRegion = region;

    oldfont = fontMakeCurrent(tmFont);

    feStaticRectangleDraw(region);                          //draw regular rectangle as backdrop

    x = region->rect.x0 + 15;
    y = region->rect.y0 + 5 ;

    if (tmKASDialog[tmDialogPhrase])
        strcpy(stringtoprint,tmKASDialog[tmDialogPhrase]);
    else
        strcpy(stringtoprint,tmKASMissing);

    y += TM_VertSpacing + fontHeight(" ");

    pos = stringtoprint;

    done = FALSE;
    while (!done)
    {
        justified = FALSE;
        tline[0]=0;
        while (!justified)
        {
            strcpy(oldtline, tline);
            oldpos = pos;
            pos = getWord(tline, pos);

            if (pos[0] == '\n')
            {
                justified = TRUE;
                pos++;
                while ( pos[0] == ' ' ) pos++;
            }
            else
            {
                if ( (width=fontWidth(tline)) > TM_InfoWidth - 15)
                {
                    strcpy(tline, oldtline);
                    pos = oldpos;
                    while ( pos[0] == ' ' ) pos++;

                    justified = TRUE;
                }
                if (pos[0]==0)
                {
                    justified = TRUE;
                    done      = TRUE;
                }
            }
        }

        fontPrintf(x,y,TM_StandardTextColor,"%s",tline);
        y += fontHeight(" ");
        if (y > region->rect.y1 + fontHeight(" ")) done=TRUE;

    }
    fontMakeCurrent(oldfont);
}
Пример #28
0
void tmTechListDraw(featom *atom, regionhandle region)
{
    sdword x, y, index;
    color c;
    fonthandle currentFont;
    bool       newline = FALSE;
    sdword     numlines, buyable=0;
    sdword     price;

    if (tmTechSelected == -1)
    {
        sdword i, price;

        for (i = 0; i < TM_NUM_TECHS; i++)
        {
            if (tmTechForSale[i] == TM_TECH_IS_FOR_SALE)
            {
                price = (tmTechPrice[i] * tmPriceScale) / 100;
                if (universe.curPlayerPtr->resourceUnits >= price)
                {
                    tmTechSelected = i;
                    tmtechinfo = i;
                    tmDirtyTechInfo();
                    break;
                }
            }
        }
    }

    tmTechListRegion = region;

    currentFont = fontMakeCurrent(tmTechListFont);

    if (region->flags == 0 || region->flags == RPE_DrawFunctionAdded)
    {                                                       //if region not processed yet
        region->flags = RPE_PressLeft | RPE_PressRight |
                        RPE_WheelUp | RPE_WheelDown;        //receive mouse presses from now on
        regFunctionSet(region, (regionfunction)tmSelectAvailable);          //set new region handler function
    }
    feStaticRectangleDraw(region);                          //draw standard rectangle

    numlines = 0;

    for (index=0; index<TM_NUM_TECHS; index++)
    {
        if (tmTechForSale[index] == TM_TECH_IS_FOR_SALE)

        newline=TRUE;
        if (newline)
        {
            newline = FALSE;
            numlines++;
        }
    }


    y = region->rect.y0 + TM_ASMarginTop;

    newline=FALSE;
    numlines=0;

    for (index=0; index < TM_NUM_TECHS; index++)
    {
        price = (tmTechPrice[index] * tmPriceScale) / 100;

        if (y + fontHeight(" ") >= region->rect.y1)
        {
            break;
        }

        if (tmTechForSale[index] == TM_TECH_IS_FOR_SALE)
        {
            if (universe.curPlayerPtr->resourceUnits < price)
            {                                                   //if this tech already selected
                c = TM_CantAffordTextColor;
            }
            else
            {
                c = TM_StandardTextColor;
                buyable++;
            }

            if (index == tmTechSelected)
            {
                c = TM_SelectionTextColor;
            }
                        //tech fancy name
            x = region->rect.x0 + TM_ASMarginLeft;
            fontPrint(x, y, c, RaceSpecificTechTypeToNiceString(index,universe.curPlayerPtr->race));

            newline = TRUE;

            tmDirtyTechInfo();
        }

        if (newline)
        {
            newline = FALSE;

            y+= fontHeight(" ") + TM_ASInterSpacing;
            numlines++;
        }
    }
    tmStuffToBuy = buyable;

    fontMakeCurrent(currentFont);
    //tmDirtyTechInfo();
}