/*----------------------------------------------------------------------------- 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); }
void hrDrawChatBox(featom *atom, regionhandle region) { fonthandle currentfont; sdword x,y,i; char name[128]; hrChatBoxRegion = region; currentfont = fontMakeCurrent(playernamefont); primRectSolid2(®ion->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); }
/*----------------------------------------------------------------------------- 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); } }
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); }
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); }
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(); }
/*----------------------------------------------------------------------------- Name : tmTechImageDraw Description : Loads in, decompresses and draws the tech picture. Inputs : none Outputs : loads in tmTechImage and creates tmTechTexture Return : void ----------------------------------------------------------------------------*/ void tmTechImageDraw(featom *atom, regionhandle region) { char filename[128]; sdword index, lru = 0; real32 time=(real32)1.0e22; rectangle textureRect; tmTechImageRegion = region; feStaticRectangleDraw(region); //draw standard rectangle if (tmtechinfo != -1) { if (tmtechinfo != tmCurTechTexture) { for (index=0;index<TM_TOTALPICS;index++) // RM_TOTALPICS is the size of the cache { // Find least recently used texture if (pictures[index].timestamp < time) { time = pictures[index].timestamp; lru = index; } // If already cached, use it and exit this routine if ( (pictures[index].tech==tmtechinfo) && (pictures[index].race==universe.curPlayerPtr->race) ) { tmTechTexturePrepare(index); tmCurTechTexture = tmtechinfo; tmCurTechImage = pictures[lru].techImage; tmCurIndex = index; pictures[index].timestamp = universe.totaltimeelapsed; textureRect.x0=region->rect.x0+TM_TEXTURE_INSET; textureRect.y0=region->rect.y0+TM_TEXTURE_INSET; textureRect.x1=region->rect.x1-TM_TEXTURE_INSET; textureRect.y1=region->rect.y1-TM_TEXTURE_INSET; rndPerspectiveCorrection(FALSE); primRectSolidTextured2(&textureRect); //if(tmExtendedInfoActive) //{ // primRectTranslucent2(&textureRect, colRGBA(0, 0, 0, 128)); // tmTechInfoDraw(region); //} return; } } // Build filename for loading texture from file strcpy(filename, TechImagePaths[universe.curPlayerPtr->race]); strcat(filename, TechTypeToString(tmtechinfo)); strcat(filename,".lif"); // Remove oldest (least recently used) texture from memory if (pictures[lru].techImage != NULL) { memFree(pictures[lru].techImage); pictures[lru].techImage = NULL; } if (pictures[lru].techTexture != TR_InvalidInternalHandle) { trRGBTextureDelete(pictures[lru].techTexture); pictures[lru].techTexture = TR_InvalidInternalHandle; } // Load the image into LRU cache pictures[lru].techImage = trLIFFileLoad(filename, NonVolatile); dbgAssertOrIgnore(pictures[lru].techImage->flags & TRF_Paletted); tmTechTexturePrepare(lru); tmCurTechTexture = tmtechinfo; tmCurTechImage = pictures[lru].techImage; pictures[lru].tech = tmtechinfo; pictures[lru].race = universe.curPlayerPtr->race; pictures[lru].timestamp = universe.totaltimeelapsed; } else { trPalettedTextureMakeCurrent(pictures[tmCurIndex].techTexture, pictures[tmCurIndex].techImage->palette); } textureRect.x0=region->rect.x0+TM_TEXTURE_INSET; textureRect.y0=region->rect.y0+TM_TEXTURE_INSET; textureRect.x1=region->rect.x1-TM_TEXTURE_INSET; textureRect.y1=region->rect.y1-TM_TEXTURE_INSET; rndPerspectiveCorrection(FALSE); primRectSolidTextured2(&textureRect); } }