bool intDisplayMultiJoiningStatus(UBYTE joinCount) { UDWORD x,y,w,h; char sTmp[6]; w = RET_FORMWIDTH; h = RET_FORMHEIGHT; x = RET_X; y = RET_Y; // cameraToHome(selectedPlayer); // home the camera to the player. RenderWindowFrame(FRAME_NORMAL, x, y ,w, h); // draw a wee blu box. // display how far done.. iV_DrawText(_("Players Still Joining"), x+(w/2)-(iV_GetTextWidth(_("Players Still Joining"))/2), y+(h/2)-8 ); if (!NetPlay.playercount) { return true; } sprintf(sTmp,"%d%%", PERCENT((NetPlay.playercount-joinCount),NetPlay.playercount) ); iV_DrawText(sTmp ,x + (w / 2) - 10, y + (h / 2) + 10); return true; }
// ----------------------------------------------------------------------------------- void dispAdditionalInfo( void ) { /* We now need to display the mission time, game time, average unit experience level an number of artefacts found */ /* Firstly, top of the screen, number of artefacts found */ sprintf( text, _("ARTIFACTS RECOVERED: %d"), missionData.artefactsFound ); iV_DrawText( text, (pie_GetVideoBufferWidth() - iV_GetTextWidth(text))/2, 300 + D_H ); /* Get the mission result time in a string - and write it out */ getAsciiTime( (char*)&text2, gameTime - missionData.missionStarted ); sprintf( text, _("Mission Time - %s"), text2 ); iV_DrawText( text, (pie_GetVideoBufferWidth() - iV_GetTextWidth(text))/2, 320 + D_H); /* Write out total game time so far */ getAsciiTime( (char*)&text2, gameTime ); sprintf( text, _("Total Game Time - %s"), text2 ); iV_DrawText( text, (pie_GetVideoBufferWidth() - iV_GetTextWidth(text))/2, 340 + D_H ); if (Cheated) { // A quick way to flash the text ((gameTime2 / 250) % 2) ? iV_SetTextColour(WZCOL_RED) : iV_SetTextColour(WZCOL_YELLOW); sprintf( text, _("You cheated!")); iV_DrawText( text, (pie_GetVideoBufferWidth() - iV_GetTextWidth(text))/2, 360 + D_H ); iV_SetTextColour(WZCOL_TEXT_BRIGHT); } }
bool intDisplayMultiJoiningStatus(UBYTE joinCount) { UDWORD x,y,w,h; char sTmp[6]; w = RET_FORMWIDTH; h = RET_FORMHEIGHT; x = RET_X; y = RET_Y; // cameraToHome(selectedPlayer); // home the camera to the player. RenderWindowFrame(FRAME_NORMAL, x, y ,w, h); // draw a wee blu box. // display how far done.. iV_SetFont(font_regular); iV_DrawText(_("Players Still Joining"), x+(w/2)-(iV_GetTextWidth(_("Players Still Joining"))/2), y+(h/2)-8 ); unsigned playerCount = 0; // Calculate what NetPlay.playercount should be, which is apparently only non-zero for the host. for (unsigned player = 0; player < game.maxPlayers; ++player) { if (isHumanPlayer(player)) { ++playerCount; } } if (!playerCount) { return true; } iV_SetFont(font_large); sprintf(sTmp, "%d%%", PERCENT(playerCount - joinCount, playerCount)); iV_DrawText(sTmp ,x + (w / 2) - 10, y + (h / 2) + 10); iV_SetFont(font_small); int yStep = iV_GetTextLineSize(); int yPos = RET_Y - yStep*game.maxPlayers; static const std::string statusStrings[3] = {"☐ ", "☑ ", "☒ "}; for (unsigned player = 0; player < game.maxPlayers; ++player) { int status = -1; if (isHumanPlayer(player)) { status = ingame.JoiningInProgress[player]? 0 : 1; // Human player, still joining or joined. } else if (NetPlay.players[player].ai >= 0) { status = 2; // AI player (automatically joined). } if (status >= 0) { iV_DrawText((statusStrings[status] + getPlayerName(player)).c_str(), x + 5, yPos + yStep*NetPlay.players[player].position); } } return true; }
// //////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////// void displayRequestOption(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset) { LEVEL_DATASET *mapData = (LEVEL_DATASET *)psWidget->pUserData; int x = xOffset + psWidget->x(); int y = yOffset + psWidget->y(); char butString[255]; sstrcpy(butString, ((W_BUTTON *)psWidget)->pTip.toUtf8().constData()); drawBlueBox(x, y, psWidget->width(), psWidget->height()); iV_SetFont(font_regular); // font iV_SetTextColour(WZCOL_TEXT_BRIGHT); while (iV_GetTextWidth(butString) > psWidget->width() - 10) { butString[strlen(butString)-1]='\0'; } iV_DrawText(butString, x + 6, y + 12); //draw text if (mapData != NULL) { // Display map hash, so we can see the difference between identically named maps. Sha256 hash = mapData->realFileHash; // levGetFileHash can be slightly expensive. static uint32_t lastHashTime = 0; if (lastHashTime != realTime && hash.isZero()) { hash = levGetFileHash(mapData); if (!hash.isZero()) { lastHashTime = realTime; // We just calculated a hash. Don't calculate any more hashes this frame. } } if (!hash.isZero()) { iV_SetFont(font_small); iV_SetTextColour(WZCOL_TEXT_DARK); sstrcpy(butString, hash.toString().c_str()); while (iV_GetTextWidth(butString) > psWidget->width() - 10 - (8 + mapData->players*6)) { butString[strlen(butString) - 1] = '\0'; } iV_DrawText(butString, x + 6 + 8 + mapData->players*6, y + 26); iV_SetFont(font_regular); } // if map, then draw no. of players. for (int count = 0; count < mapData->players; ++count) { iV_DrawImage(FrontImages, IMAGE_WEE_GUY, x + 6*count + 6, y + 16); } } }
static void displayStructureBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset) { int x = xOffset + psWidget->x(); int y = yOffset + psWidget->y(); int w = psWidget->width(); int h = psWidget->height(); STRUCTURE_STATS *stat = asStructureStats + psWidget->UserData; Position position; Vector3i rotation; char str[20]; UDWORD scale,Radius; drawBlueBox(x,y,w,h); // draw image pie_SetGeometricOffset(x + 35, y + psWidget->height()/2 + 9); rotation.x = -15; rotation.y = ((realTime/45)%360) ; //45 rotation.z = 0; position.x = 0; position.y = 0; position.z = BUTTON_DEPTH*2;//getStructureStatSize(stat) * 38 * OBJECT_RADIUS; Radius = getStructureStatSizeMax(stat); if(Radius <= 128) { scale = SMALL_STRUCT_SCALE; } else if(Radius <= 256) { scale = MED_STRUCT_SCALE; } else { scale = LARGE_STRUCT_SCALE; } pie_SetDepthBufferStatus(DEPTH_CMP_LEQ_WRT_ON); displayStructureStatButton(stat, &rotation, &position, true, scale); pie_SetDepthBufferStatus(DEPTH_CMP_ALWAYS_WRT_ON); // draw name iV_SetFont(font_regular); // font iV_SetTextColour(WZCOL_TEXT_BRIGHT); iV_DrawText(_(getName(stat->pName)), x + 80, y + psWidget->height()/2 + 3); // draw limit ssprintf(str, "%d", ((W_SLIDER *)widgGetFromID(psWScreen, psWidget->id + 1))->pos); iV_DrawText(str, x + 270, y + psWidget->height()/2 + 3); return; }
// //////////////////////////////////////////////////////////////////////////// static void displayLoadSlot(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours) { UDWORD x = xOffset + psWidget->x; UDWORD y = yOffset + psWidget->y; char butString[64]; drawBlueBox(x, y, psWidget->width, psWidget->height); //draw box if (((W_BUTTON *)psWidget)->pText) { sstrcpy(butString, ((W_BUTTON *)psWidget)->pText); iV_SetFont(font_regular); // font iV_SetTextColour(WZCOL_TEXT_BRIGHT); while (iV_GetTextWidth(butString) > psWidget->width) { butString[strlen(butString)-1] = '\0'; } //draw text iV_DrawText(butString, x + 4, y + 17); } }
void W_LABEL::display(int xOffset, int yOffset) { iV_SetTextColour(fontColour); QByteArray text = aText.toUtf8(); int fx; if (style & WLAB_ALIGNCENTRE) { int fw = iV_GetTextWidth(text.constData(), FontID); fx = xOffset + x() + (width() - fw) / 2; } else if (style & WLAB_ALIGNRIGHT) { int fw = iV_GetTextWidth(text.constData(), FontID); fx = xOffset + x() + width() - fw; } else { fx = xOffset + x(); } int fy; if ((style & WLAB_ALIGNTOPLEFT) != 0) // Align top { fy = yOffset + y() - iV_GetTextAboveBase(FontID); } else if ((style & WLAB_ALIGNBOTTOMLEFT) != 0) // Align bottom { fy = yOffset + y() - iV_GetTextAboveBase(FontID) + (height() - iV_GetTextLineSize(FontID)); } else { fy = yOffset + y() - iV_GetTextAboveBase(FontID) + (height() - iV_GetTextLineSize(FontID)) / 2; } iV_DrawText(text.constData(), fx, fy, FontID); }
// //////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////// void displayRequestOption(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours) { UDWORD x = xOffset+psWidget->x; UDWORD y = yOffset+psWidget->y; UDWORD count; char butString[255]; strcpy(butString,((W_BUTTON *)psWidget)->pTip); drawBlueBox(x,y,psWidget->width,psWidget->height); //draw box iV_SetFont(font_regular); // font iV_SetTextColour(WZCOL_TEXT_BRIGHT); while(iV_GetTextWidth(butString) > psWidget->width -10 ) { butString[strlen(butString)-1]='\0'; } iV_DrawText(butString, x + 6, y + 12); //draw text // if map, then draw no. of players. for(count=0;count<psWidget->UserData;count++) { iV_DrawImage(FrontImages,IMAGE_WEE_GUY,(x+(6*count)+6),y+16); } }
/* label display function */ void labelDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, UDWORD *pColours) { SDWORD fx,fy, fw; W_LABEL *psLabel; // PROP_FONT *psFont; int FontID; psLabel = (W_LABEL *)psWidget; // psFont = psLabel->psFont; FontID = psLabel->FontID; iV_SetFont(FontID); // fontSetCacheColour(*(pColours + WCOL_TEXT)); iV_SetTextColour((UWORD)*(pColours + WCOL_TEXT)); if (psLabel->style & WLAB_ALIGNCENTRE) { fw = iV_GetTextWidth(psLabel->aText); fx = xOffset + psLabel->x + (psLabel->width - fw) / 2; } else if (psLabel->style & WLAB_ALIGNRIGHT) { fw = iV_GetTextWidth(psLabel->aText); fx = xOffset + psLabel->x + psLabel->width - fw; } else { fx = xOffset + psLabel->x; } fy = yOffset + psLabel->y + (psLabel->height - iV_GetTextLineSize())/2 - iV_GetTextAboveBase(); // fy = yOffset + psLabel->y + (psLabel->height - // psFont->height + psFont->baseLine) / 2; iV_DrawText(psLabel->aText,fx,fy); // fontPrint(fx,fy, psLabel->aText); }
// //////////////////////////////////////////////////////////////////////////// static void displayLoadSlot(struct _widget *psWidget, UDWORD xOffset, UDWORD yOffset, UDWORD *pColours) { UDWORD x = xOffset+psWidget->x; UDWORD y = yOffset+psWidget->y; UWORD im = (UWORD)UNPACKDWORD_TRI_B((UDWORD)psWidget->pUserData); UWORD im2= (UWORD)(UNPACKDWORD_TRI_C((UDWORD)psWidget->pUserData)); STRING butString[64]; UNUSEDPARAMETER(pColours); drawBlueBox(x,y,psWidget->width,psWidget->height); //draw box if(((W_BUTTON *)psWidget)->pTip ) { strcpy(butString,((W_BUTTON *)psWidget)->pTip); iV_SetFont(WFont); // font iV_SetTextColour(-1); //colour while(iV_GetTextWidth(butString) > psWidget->width) { butString[strlen(butString)-1]='\0'; } //draw text iV_DrawText( butString, x+4, y+17); } }
// //////////////////////////////////////////////////////////////////////////// // show text. static void displayText(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours) { SDWORD fx,fy, fw; W_LABEL *psLab; psLab = (W_LABEL *)psWidget; iV_SetFont(psLab->FontID); fw = iV_GetTextWidth(psLab->aText); fy = yOffset + psWidget->y; if (psWidget->style & WLAB_ALIGNCENTRE) //check for centering, calculate offset. { fx = xOffset + psWidget->x + ((psWidget->width - fw) / 2); } else { fx = xOffset + psWidget->x; } iV_SetTextColour(WZCOL_TEXT_BRIGHT); iV_DrawText( psLab->aText, fx, fy); return; }
/* label display function */ void labelDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours) { SDWORD fx,fy, fw; W_LABEL *psLabel; enum iV_fonts FontID; psLabel = (W_LABEL *)psWidget; FontID = psLabel->FontID; iV_SetFont(FontID); iV_SetTextColour(pColours[WCOL_TEXT]); if (psLabel->style & WLAB_ALIGNCENTRE) { fw = iV_GetTextWidth(psLabel->aText); fx = xOffset + psLabel->x + (psLabel->width - fw) / 2; } else if (psLabel->style & WLAB_ALIGNRIGHT) { fw = iV_GetTextWidth(psLabel->aText); fx = xOffset + psLabel->x + psLabel->width - fw; } else { fx = xOffset + psLabel->x; } fy = yOffset + psLabel->y + (psLabel->height - iV_GetTextLineSize())/2 - iV_GetTextAboveBase(); iV_DrawText(psLabel->aText,fx,fy); }
static void barGraphDisplayText(W_BARGRAPH *barGraph, int x0, int x1, int y1) { if (!barGraph->text.isEmpty()) { QByteArray utf = barGraph->text.toUtf8(); iV_SetFont(font_small); int textWidth = iV_GetTextWidth(utf.constData()); Vector2i pos((x0 + x1 - textWidth) / 2, y1); iV_SetTextColour(WZCOL_BLACK); // Add a shadow, to make it visible against any background. for (int dx = -1; dx <= 1; ++dx) for (int dy = -1; dy <= 1; ++dy) { iV_DrawText(utf.constData(), pos.x + dx * 1.25f, pos.y + dy * 1.25f); } iV_SetTextColour(barGraph->textCol); iV_DrawText(utf.constData(), pos.x, pos.y - 0.25f); iV_DrawText(utf.constData(), pos.x, pos.y + 0.25f); // Draw twice, to make it more visible. } }
void screen_Display() { pie_SetDepthBufferStatus(DEPTH_CMP_ALWAYS_WRT_OFF); // Draw backdrop glColor3f(1, 1, 1); backdropGfx->draw(); if (mappreview) { int s1 = screenWidth / preview_width; int s2 = screenHeight / preview_height; int scale = MIN(s1, s2); int w = preview_width * scale; int h = preview_height * scale; for (int i = 0; i < MAX_PLAYERS; i++) { int x = player_pos[i].x; int y = player_pos[i].y; char text[5]; if (x == 0x77777777) { continue; } x = screenWidth / 2 - w / 2 + x * scale; y = screenHeight / 2 - h / 2 + y * scale; ssprintf(text, "%d", i); iV_SetFont(font_large); iV_SetTextColour(WZCOL_BLACK); iV_DrawText(text, x - 1, y - 1); iV_DrawText(text, x + 1, y - 1); iV_DrawText(text, x - 1, y + 1); iV_DrawText(text, x + 1, y + 1); iV_SetTextColour(WZCOL_WHITE); iV_DrawText(text, x, y); } } pie_SetDepthBufferStatus(DEPTH_CMP_LEQ_WRT_ON); }
// //////////////////////////////////////////////////////////////////////////// // display a keymap on the interface. static void displayKeyMap(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours) { UDWORD x = xOffset+psWidget->x; UDWORD y = yOffset+psWidget->y; UDWORD w = psWidget->width; UDWORD h = psWidget->height; KEY_MAPPING *psMapping = (KEY_MAPPING*)psWidget->pUserData; char sKey[MAX_STR_LENGTH]; if(psMapping == selectedKeyMap) { pie_BoxFill(x, y, x + w, y + h, WZCOL_KEYMAP_ACTIVE); } else if(psMapping->status == KEYMAP_ALWAYS || psMapping->status == KEYMAP_ALWAYS_PROCESS) { // when user can't edit something... pie_BoxFill(x, y , x + w, y + h, WZCOL_KEYMAP_FIXED); } else { drawBlueBox(x,y,w,h); } // draw name iV_SetFont(font_regular); // font type iV_SetTextColour(WZCOL_FORM_TEXT); iV_DrawText(_(psMapping->pName), x + 2, y + (psWidget->height / 2) + 3); // draw binding keyMapToString(sKey, psMapping); // Check to see if key is on the numpad, if so tell user and change color if (psMapping->subKeyCode >= KEY_KP_0 && psMapping->subKeyCode <= KEY_KPENTER) { iV_SetTextColour(WZCOL_YELLOW); sstrcat(sKey, " (numpad)"); } iV_DrawText(sKey, x + 364, y + (psWidget->height / 2) + 3); }
// show a background piccy (currently used for version and mods labels) static void displayTitleBitmap(WZ_DECL_UNUSED WIDGET *psWidget, WZ_DECL_UNUSED UDWORD xOffset, WZ_DECL_UNUSED UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours) { char modListText[MAX_STR_LENGTH] = ""; iV_SetFont(font_regular); iV_SetTextColour(WZCOL_GREY); iV_DrawTextRotated(version_getFormattedVersionString(), pie_GetVideoBufferWidth() - 9, pie_GetVideoBufferHeight() - 14, 270.f); if (*getModList()) { sstrcat(modListText, _("Mod: ")); sstrcat(modListText, getModList()); iV_DrawText(modListText, 9, 14); } iV_SetTextColour(WZCOL_TEXT_BRIGHT); iV_DrawTextRotated(version_getFormattedVersionString(), pie_GetVideoBufferWidth() - 10, pie_GetVideoBufferHeight() - 15, 270.f); if (*getModList()) { iV_DrawText(modListText, 10, 15); } }
static void displayCamTypeBut(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours) { UDWORD x = xOffset+psWidget->x; UDWORD y = yOffset+psWidget->y; char buffer[8]; drawBlueBox(x,y,psWidget->width,psWidget->height); //draw box sprintf(buffer, "T%i", (int)(psWidget->UserData)); if ((unsigned int)(psWidget->UserData) == current_tech) { iV_SetTextColour(WZCOL_TEXT_BRIGHT); } else { iV_SetTextColour(WZCOL_TEXT_MEDIUM); } iV_DrawText(buffer, x+2, y+12); }
static void displayDebugMenu(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours) { char str[128]; UDWORD x = xOffset+psWidget->x; UDWORD y = yOffset+psWidget->y; UDWORD index = psWidget->UserData; iV_SetFont(font_regular); // font iV_SetTextColour(WZCOL_TEXT_BRIGHT); if(strcmp(debugMenuEntry[index],"")) { sprintf(str,"%s", debugMenuEntry[index]); iV_DrawText(str, x, y+MULTIMENU_FONT_OSET); } }
static void displayCamTypeBut(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset) { int x = xOffset + psWidget->x(); int y = yOffset + psWidget->y(); char buffer[8]; iV_SetFont(font_regular); drawBlueBox(x, y, psWidget->width(), psWidget->height()); sprintf(buffer, "T%i", (int)(psWidget->UserData)); if ((unsigned int)(psWidget->UserData) == current_tech) { iV_SetTextColour(WZCOL_TEXT_BRIGHT); } else { iV_SetTextColour(WZCOL_TEXT_MEDIUM); } iV_DrawText(buffer, x+2, y+12); }
// //////////////////////////////////////////////////////////////////////////// // show a text option. void displayTextOption(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours) { SDWORD fx,fy, fw; W_BUTTON *psBut; bool hilight = false; bool greyOut = psWidget->UserData; // if option is unavailable. psBut = (W_BUTTON *)psWidget; iV_SetFont(psBut->FontID); if(widgGetMouseOver(psWScreen) == psBut->id) // if mouse is over text then hilight. { hilight = true; } fw = iV_GetTextWidth(psBut->pText); fy = yOffset + psWidget->y + (psWidget->height - iV_GetTextLineSize())/2 - iV_GetTextAboveBase(); if (psWidget->style & WBUT_TXTCENTRE) //check for centering, calculate offset. { fx = xOffset + psWidget->x + ((psWidget->width - fw) / 2); } else { fx = xOffset + psWidget->x; } if(greyOut) // unavailable { iV_SetTextColour(WZCOL_TEXT_DARK); } else // available { if(hilight) // hilight { iV_SetTextColour(WZCOL_TEXT_BRIGHT); } else // dont highlight { iV_SetTextColour(WZCOL_TEXT_MEDIUM); } } iV_DrawText( psBut->pText, fx, fy); return; }
/** * Displays the TEXT view for the current message. * If this function breaks, please merge it with intDisplaySeqTextViewPage * which presumably does almost the same. */ void intDisplayTEXTView(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours) { W_TABFORM *Form = (W_TABFORM*)psWidget; MESSAGE *psMessage = (MESSAGE *)Form->pUserData; UDWORD x0, y0, x1, y1, i, linePitch; UDWORD ty; x0 = xOffset+Form->x; y0 = yOffset+Form->y; x1 = x0 + Form->width; y1 = y0 + Form->height; ty = y0; RenderWindowFrame(FRAME_NORMAL, x0, y0, x1 - x0, y1 - y0); if (psMessage) { iV_SetFont(font_regular); /* Get the travel to the next line */ linePitch = iV_GetTextLineSize(); /* Fix for spacing.... */ linePitch+=3; ty+=3; /* Fix for spacing.... */ iV_SetTextColour(WZCOL_TEXT_BRIGHT); //add each message for (i = 0; i < ((VIEWDATA *)psMessage->pViewData)->numText; i++) { //check haven't run out of room first! if (i * linePitch > Form->height) { ASSERT( false, "intDisplayTEXTView: Run out of room!" ); return; } //need to check the string will fit! iV_DrawText(_(((VIEWDATA *)psMessage->pViewData)->ppTextMsg[i]), x0 + TEXT_XINDENT, (ty + TEXT_YINDENT*3) + (i * linePitch)); } } }
static void displayNumPlayersBut(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours) { UDWORD x = xOffset+psWidget->x; UDWORD y = yOffset+psWidget->y; char buffer[8]; drawBlueBox(x,y,psWidget->width,psWidget->height); //draw box if ((unsigned int)(psWidget->UserData) == current_numplayers) { iV_SetTextColour(WZCOL_TEXT_BRIGHT); } else { iV_SetTextColour(WZCOL_TEXT_MEDIUM); } if ((unsigned int)(psWidget->UserData) == 0) { sprintf(buffer, " *"); } else { sprintf(buffer, "%iP", (int)(psWidget->UserData)); buffer[2] = '\0'; // Truncate 'P' if 2 digits, since there isn't room. } iV_DrawText(buffer, x+2, y+12); }
// //////////////////////////////////////////////////////////////////////////// static void displayLoadSlot(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset) { int x = xOffset + psWidget->x(); int y = yOffset + psWidget->y(); char butString[64]; drawBlueBox(x, y, psWidget->width(), psWidget->height()); //draw box if (!((W_BUTTON *)psWidget)->pText.isEmpty()) { sstrcpy(butString, ((W_BUTTON *)psWidget)->pText.toUtf8().constData()); iV_SetFont(font_regular); // font iV_SetTextColour(WZCOL_FORM_TEXT); while(iV_GetTextWidth(butString) > psWidget->width()) { butString[strlen(butString)-1]='\0'; } //draw text iV_DrawText( butString, x+4, y+17); } }
void W_BUTTON::display(int xOffset, int yOffset) { int x0 = x() + xOffset; int y0 = y() + yOffset; int x1 = x0 + width(); int y1 = y0 + height(); bool haveText = !pText.isEmpty(); bool isDown = (state & (WBUT_DOWN | WBUT_LOCK | WBUT_CLICKLOCK)) != 0; bool isDisabled = (state & WBUT_DISABLE) != 0; bool isHighlight = (state & WBUT_HIGHLIGHT) != 0; // Display the button. if (!images.normal.isNull()) { iV_DrawImage(images.normal, x0, y0); if (isDown && !images.down.isNull()) { iV_DrawImage(images.down, x0, y0); } if (isDisabled && !images.disabled.isNull()) { iV_DrawImage(images.disabled, x0, y0); } if (isHighlight && !images.highlighted.isNull()) { iV_DrawImage(images.highlighted, x0, y0); } } else { iV_ShadowBox(x0, y0, x1, y1, 0, WZCOL_FORM_LIGHT, isDisabled ? WZCOL_FORM_LIGHT : WZCOL_FORM_DARK, WZCOL_FORM_BACKGROUND); if (isHighlight) { iV_Box(x0 + 2, y0 + 2, x1 - 3, y1 - 3, WZCOL_FORM_HILITE); } } if (haveText) { int fw = iV_GetTextWidth(pText.toUtf8().c_str(), FontID); int fx = x0 + (width() - fw) / 2; int fy = y0 + (height() - iV_GetTextLineSize(FontID)) / 2 - iV_GetTextAboveBase(FontID); if (isDisabled) { iV_SetTextColour(WZCOL_FORM_LIGHT); iV_DrawText(pText.toUtf8().c_str(), fx + 1, fy + 1, FontID); iV_SetTextColour(WZCOL_FORM_DISABLE); } else { iV_SetTextColour(WZCOL_FORM_TEXT); } iV_DrawText(pText.toUtf8().c_str(), fx, fy, FontID); } if (isDisabled && !images.normal.isNull() && images.disabled.isNull()) { // disabled, render something over it! iV_TransBoxFill(x0, y0, x0 + width(), y0 + height()); } }
void W_EDITBOX::display(int xOffset, int yOffset) { int x0 = x() + xOffset; int y0 = y() + yOffset; int x1 = x0 + width(); int y1 = y0 + height(); if (pBoxDisplay != nullptr) { pBoxDisplay(this, xOffset, yOffset); } else { iV_ShadowBox(x0, y0, x1, y1, 0, boxColourFirst, boxColourSecond, boxColourBackground); } int fx = x0 + WEDB_XGAP;// + (psEdBox->width - fw) / 2; iV_SetTextColour(WZCOL_FORM_TEXT); int fy = y0 + (height() - iV_GetTextLineSize(FontID)) / 2 - iV_GetTextAboveBase(FontID); /* If there is more text than will fit into the box, display the bit with the cursor in it */ QString tmp = aText; tmp.remove(0, printStart); // Erase anything there isn't room to display. tmp.remove(printChars, tmp.length()); iV_DrawText(tmp.toUtf8().constData(), fx, fy, FontID); // Display the cursor if editing #if CURSOR_BLINK bool blink = !(((wzGetTicks() - blinkOffset) / WEDB_BLINKRATE) % 2); if ((state & WEDBS_MASK) == WEDBS_INSERT && blink) #else if ((state & WEDBS_MASK) == WEDBS_INSERT) #endif { // insert mode QString tmp = aText; tmp.remove(insPos, tmp.length()); // Erase from the cursor on, to find where the cursor should be. tmp.remove(0, printStart); int cx = x0 + WEDB_XGAP + iV_GetTextWidth(tmp.toUtf8().constData(), FontID); cx += iV_GetTextWidth("-", FontID); int cy = fy; iV_Line(cx, cy + iV_GetTextAboveBase(FontID), cx, cy - iV_GetTextBelowBase(FontID), WZCOL_FORM_CURSOR); } #if CURSOR_BLINK else if ((state & WEDBS_MASK) == WEDBS_OVER && blink) #else else if ((state & WEDBS_MASK) == WEDBS_OVER) #endif { // overwrite mode QString tmp = aText; tmp.remove(insPos, tmp.length()); // Erase from the cursor on, to find where the cursor should be. tmp.remove(0, printStart); int cx = x0 + WEDB_XGAP + iV_GetTextWidth(tmp.toUtf8().constData(), FontID); int cy = fy; iV_Line(cx, cy, cx + WEDB_CURSORSIZE, cy, WZCOL_FORM_CURSOR); } if (pBoxDisplay == nullptr) { if ((state & WEDBS_HILITE) != 0) { /* Display the button hilite */ iV_Box(x0 - 2, y0 - 2, x1 + 2, y1 + 2, WZCOL_FORM_HILITE); } } }
/* Display a button */ void buttonDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours) { W_BUTTON *psButton; SDWORD x0,y0,x1,y1, fx,fy,fw; int CurrFontID; ASSERT(psWidget != NULL && pColours != NULL, "Invalid pointers"); if (!psWidget || !pColours) { return; } psButton = (W_BUTTON *)psWidget; CurrFontID = psButton->FontID; x0=psButton->x + xOffset; y0=psButton->y + yOffset; x1=x0 + psButton->width; y1=y0 + psButton->height; if (psButton->state & (WBUTS_DOWN | WBUTS_LOCKED | WBUTS_CLICKLOCK)) { /* Display the button down */ pie_BoxFill(x0, y0, x1, y1, pColours[WCOL_BKGRND]); iV_Line(x0,y0, x1,y0, pColours[WCOL_DARK]); iV_Line(x0,y0, x0,y1, pColours[WCOL_DARK]); iV_Line(x0,y1, x1,y1, pColours[WCOL_LIGHT]); iV_Line(x1,y1, x1,y0, pColours[WCOL_LIGHT]); if (psButton->pText) { iV_SetFont(psButton->FontID); iV_SetTextColour(pColours[WCOL_TEXT]); fw = iV_GetTextWidth(psButton->pText); if(psButton->style & WBUT_NOCLICKMOVE) { fx = x0 + (psButton->width - fw) / 2 + 1; fy = y0 + 1 + (psButton->height - iV_GetTextLineSize())/2 - iV_GetTextAboveBase(); } else { fx = x0 + (psButton->width - fw) / 2; fy = y0 + (psButton->height - iV_GetTextLineSize())/2 - iV_GetTextAboveBase(); } iV_DrawText(psButton->pText,fx,fy); } if (psButton->state & WBUTS_HILITE) { /* Display the button hilite */ iV_Line(x0+3,y0+3, x1-2,y0+3, pColours[WCOL_HILITE]); iV_Line(x0+3,y0+3, x0+3,y1-2, pColours[WCOL_HILITE]); iV_Line(x0+3,y1-2, x1-2,y1-2, pColours[WCOL_HILITE]); iV_Line(x1-2,y1-2, x1-2,y0+3, pColours[WCOL_HILITE]); } } else if (psButton->state & WBUTS_GREY) { /* Display the disabled button */ pie_BoxFill(x0, y0, x1, y1, pColours[WCOL_BKGRND]); iV_Line(x0,y0, x1,y0, pColours[WCOL_LIGHT]); iV_Line(x0,y0, x0,y1, pColours[WCOL_LIGHT]); iV_Line(x0,y1, x1,y1, pColours[WCOL_DARK]); iV_Line(x1,y1, x1,y0, pColours[WCOL_DARK]); if (psButton->pText) { iV_SetFont(psButton->FontID); fw = iV_GetTextWidth(psButton->pText); fx = x0 + (psButton->width - fw) / 2; fy = y0 + (psButton->height - iV_GetTextLineSize())/2 - iV_GetTextAboveBase(); iV_SetTextColour(pColours[WCOL_LIGHT]); iV_DrawText(psButton->pText, fx+1, fy+1); iV_SetTextColour(pColours[WCOL_DISABLE]); iV_DrawText(psButton->pText, fx, fy); } if (psButton->state & WBUTS_HILITE) { /* Display the button hilite */ iV_Line(x0+2,y0+2, x1-3,y0+2, pColours[WCOL_HILITE]); iV_Line(x0+2,y0+2, x0+2,y1-3, pColours[WCOL_HILITE]); iV_Line(x0+2,y1-3, x1-3,y1-3, pColours[WCOL_HILITE]); iV_Line(x1-3,y1-3, x1-3,y0+2, pColours[WCOL_HILITE]); } } else { /* Display the button up */ pie_BoxFill(x0, y0, x1, y1, pColours[WCOL_BKGRND]); iV_Line(x0,y0, x1,y0, pColours[WCOL_LIGHT]); iV_Line(x0,y0, x0,y1, pColours[WCOL_LIGHT]); iV_Line(x0,y1, x1,y1, pColours[WCOL_DARK]); iV_Line(x1,y1, x1,y0, pColours[WCOL_DARK]); if (psButton->pText) { iV_SetFont(psButton->FontID); iV_SetTextColour(pColours[WCOL_TEXT]); fw = iV_GetTextWidth(psButton->pText); fx = x0 + (psButton->width - fw) / 2; fy = y0 + (psButton->height - iV_GetTextLineSize())/2 - iV_GetTextAboveBase(); iV_DrawText(psButton->pText, fx, fy); } if (psButton->state & WBUTS_HILITE) { /* Display the button hilite */ iV_Line(x0+2,y0+2, x1-3,y0+2, pColours[WCOL_HILITE]); iV_Line(x0+2,y0+2, x0+2,y1-3, pColours[WCOL_HILITE]); iV_Line(x0+2,y1-3, x1-3,y1-3, pColours[WCOL_HILITE]); iV_Line(x1-3,y1-3, x1-3,y0+2, pColours[WCOL_HILITE]); } } }
static void displayExtraGubbins(UDWORD height) { char str[128]; //draw grid iV_Line(MULTIMENU_FORM_X+MULTIMENU_C0 -6 , MULTIMENU_FORM_Y, MULTIMENU_FORM_X+MULTIMENU_C0 -6 , MULTIMENU_FORM_Y+height, WZCOL_BLACK); iV_Line(MULTIMENU_FORM_X+MULTIMENU_C8 -6 , MULTIMENU_FORM_Y, MULTIMENU_FORM_X+MULTIMENU_C8 -6 , MULTIMENU_FORM_Y+height, WZCOL_BLACK); iV_Line(MULTIMENU_FORM_X+MULTIMENU_C9 -6 , MULTIMENU_FORM_Y, MULTIMENU_FORM_X+MULTIMENU_C9 -6 , MULTIMENU_FORM_Y+height, WZCOL_BLACK); iV_Line(MULTIMENU_FORM_X+MULTIMENU_C10 -6 , MULTIMENU_FORM_Y, MULTIMENU_FORM_X+MULTIMENU_C10 -6 , MULTIMENU_FORM_Y+height, WZCOL_BLACK); iV_Line(MULTIMENU_FORM_X+MULTIMENU_C11 -6 , MULTIMENU_FORM_Y, MULTIMENU_FORM_X+MULTIMENU_C11 -6 , MULTIMENU_FORM_Y+height, WZCOL_BLACK); iV_Line(MULTIMENU_FORM_X , MULTIMENU_FORM_Y+MULTIMENU_PLAYER_H, MULTIMENU_FORM_X+MULTIMENU_FORM_W, MULTIMENU_FORM_Y+MULTIMENU_PLAYER_H, WZCOL_BLACK); iV_SetFont(font_regular); // font iV_SetTextColour(WZCOL_TEXT_BRIGHT); // main wz text color // draw timer getAsciiTime(str, gameTime); iV_DrawText(str, MULTIMENU_FORM_X+MULTIMENU_C2, MULTIMENU_FORM_Y+MULTIMENU_FONT_OSET) ; // draw titles. iV_DrawText(_("Alliances"), MULTIMENU_FORM_X+MULTIMENU_C0, MULTIMENU_FORM_Y+MULTIMENU_FONT_OSET); iV_DrawText(_("Score"), MULTIMENU_FORM_X+MULTIMENU_C8, MULTIMENU_FORM_Y+MULTIMENU_FONT_OSET); iV_DrawText(_("Kills"), MULTIMENU_FORM_X+MULTIMENU_C9, MULTIMENU_FORM_Y+MULTIMENU_FONT_OSET); if(getDebugMappingStatus()) { // shows # units for *all* players in debug mode ONLY! iV_DrawText(_("Units"), MULTIMENU_FORM_X+MULTIMENU_C10, MULTIMENU_FORM_Y+MULTIMENU_FONT_OSET); iV_DrawText(_("Power"), MULTIMENU_FORM_X+MULTIMENU_C11, MULTIMENU_FORM_Y+MULTIMENU_FONT_OSET); } else { // shows # units for *yourself* (+ team member?) only. iV_DrawText(_("Units"), MULTIMENU_FORM_X+MULTIMENU_C10, MULTIMENU_FORM_Y+MULTIMENU_FONT_OSET); // ping is useless for non MP games, so display something useful depending on mode. if (runningMultiplayer()) { iV_DrawText(_("Ping"), MULTIMENU_FORM_X+MULTIMENU_C11, MULTIMENU_FORM_Y+MULTIMENU_FONT_OSET); } else { iV_DrawText(_("Structs"), MULTIMENU_FORM_X+MULTIMENU_C11, MULTIMENU_FORM_Y+MULTIMENU_FONT_OSET); } } #ifdef DEBUG { unsigned int width; sprintf(str,"Traf: %u/%u", NETgetBytesSent(), NETgetBytesRecvd()); width = iV_GetTextWidth(str); iV_DrawText(str, MULTIMENU_FORM_X, MULTIMENU_FORM_Y + MULTIMENU_FORM_H); sprintf(str,"Pack: %u/%u", NETgetPacketsSent(), NETgetPacketsRecvd()); iV_DrawText(str, MULTIMENU_FORM_X + 20 + width, MULTIMENU_FORM_Y + MULTIMENU_FORM_H); } #endif return; }
static void displayMultiPlayer(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours) { char str[128]; UDWORD x = xOffset+psWidget->x; UDWORD y = yOffset+psWidget->y; UDWORD player = psWidget->UserData; //get the in game player number. Position position; Vector3i rotation; if( responsibleFor(player,0) ) { displayExtraGubbins(widgGetFromID(psWScreen,MULTIMENU_FORM)->height); } iV_SetFont(font_regular); // font iV_SetTextColour(WZCOL_TEXT_BRIGHT); if(isHumanPlayer(player) || (game.type == SKIRMISH && player<game.maxPlayers) ) { ssprintf(str, "%d: %s", NetPlay.players[player].position, getPlayerName(player)); if (isHumanPlayer(player)) { SetPlayerTextColor(alliances[selectedPlayer][player], player); } else { SetPlayerTextColor(alliances[selectedPlayer][player], player); } while(iV_GetTextWidth(str) >= (MULTIMENU_C0-MULTIMENU_C2-10) ) { str[strlen(str)-1]='\0'; } iV_DrawText(str, x+MULTIMENU_C2, y+MULTIMENU_FONT_OSET); //c3-7 alliance //manage buttons by showing or hiding them. gifts only in campaign, { if(game.alliance != NO_ALLIANCES) { if(alliances[selectedPlayer][player] == ALLIANCE_FORMED) { if(player != selectedPlayer && !giftsUp[player] ) { if (game.alliance != ALLIANCES_TEAMS) { widgReveal(psWScreen,MULTIMENU_GIFT_RAD+ player); widgReveal(psWScreen,MULTIMENU_GIFT_RES+ player); } widgReveal(psWScreen,MULTIMENU_GIFT_DRO+ player); widgReveal(psWScreen,MULTIMENU_GIFT_POW+ player); giftsUp[player] = true; } } else { if(player != selectedPlayer && giftsUp[player]) { if (game.alliance != ALLIANCES_TEAMS) { widgHide(psWScreen,MULTIMENU_GIFT_RAD+ player); widgHide(psWScreen,MULTIMENU_GIFT_RES+ player); } widgHide(psWScreen,MULTIMENU_GIFT_DRO+ player); widgHide(psWScreen,MULTIMENU_GIFT_POW+ player); giftsUp[player] = false; } } } } } if(isHumanPlayer(player)) { SetPlayerTextColor(alliances[selectedPlayer][player], player); // Let's use the real score for MP games if (NetPlay.bComms) { //c8:score, if (Cheated) { sprintf(str,"(cheated)"); } else { sprintf(str,"%d",getMultiStats(player).recentScore); } iV_DrawText(str, x+MULTIMENU_C8, y+MULTIMENU_FONT_OSET); //c9:kills, sprintf(str,"%d",getMultiStats(player).recentKills); iV_DrawText(str, x+MULTIMENU_C9, y+MULTIMENU_FONT_OSET); } else { // estimate of score for skirmish games sprintf(str,"%d",ingame.skScores[player][0]); iV_DrawText(str, x+MULTIMENU_C8, y+MULTIMENU_FONT_OSET); // estimated kills sprintf(str,"%d",ingame.skScores[player][1]); iV_DrawText(str, x+MULTIMENU_C9, y+MULTIMENU_FONT_OSET); } if(!getDebugMappingStatus()) { //only show player's units, and nobody elses. //c10:units if (myResponsibility(player)) { SetPlayerTextColor(alliances[selectedPlayer][player], player); sprintf(str, "%d", getNumDroids(player) + getNumTransporterDroids(player)); iV_DrawText(str, x+MULTIMENU_C10, y+MULTIMENU_FONT_OSET); } if (runningMultiplayer()) { //c11:ping if (player != selectedPlayer) { if (ingame.PingTimes[player] >= 2000) { sprintf(str,"???"); } else { sprintf(str, "%d", ingame.PingTimes[player]); } iV_DrawText(str, x+MULTIMENU_C11, y+MULTIMENU_FONT_OSET); } } else { int num; STRUCTURE *temp; // NOTE, This tallys up *all* the structures you have. Test out via 'start with no base'. for (num = 0, temp = apsStructLists[player]; temp != NULL;num++,temp = temp->psNext); //c11: Structures sprintf(str, "%d", num); iV_DrawText(str, x+MULTIMENU_C11, y+MULTIMENU_FONT_OSET); } } } else { SetPlayerTextColor(alliances[selectedPlayer][player], player); // Let's use the real score for MP games if (NetPlay.bComms) { //c8:score, if (Cheated) { sprintf(str,"(cheated)"); } else { sprintf(str,"%d",getMultiStats(player).recentScore); } iV_DrawText(str, x+MULTIMENU_C8, y+MULTIMENU_FONT_OSET); //c9:kills, sprintf(str,"%d",getMultiStats(player).recentKills); iV_DrawText(str, x+MULTIMENU_C9, y+MULTIMENU_FONT_OSET); } else { // estimate of score for skirmish games sprintf(str,"%d",ingame.skScores[player][0]); iV_DrawText(str, x+MULTIMENU_C8, y+MULTIMENU_FONT_OSET); // estimated kills sprintf(str,"%d",ingame.skScores[player][1]); iV_DrawText(str, x+MULTIMENU_C9, y+MULTIMENU_FONT_OSET); } } /* Display player power instead of number of played games * and number of units instead of ping when in debug mode */ if(getDebugMappingStatus()) //Won't pass this when in both release and multiplayer modes { //c10: Total number of player units in possession sprintf(str,"%d",getNumDroids(player) + getNumTransporterDroids(player)); iV_DrawText(str, x+MULTIMENU_C10, y+MULTIMENU_FONT_OSET); //c11: Player power sprintf(str, "%u", (int)getPower(player)); iV_DrawText(str, MULTIMENU_FORM_X+MULTIMENU_C11, y+MULTIMENU_FONT_OSET); } // a droid of theirs. if(apsDroidLists[player]) { pie_SetGeometricOffset( MULTIMENU_FORM_X+MULTIMENU_C1 ,y+MULTIMENU_PLAYER_H); rotation.x = -15; rotation.y = 45; rotation.z = 0; position.x = 0; position.y = 0; position.z = 2000; //scale them! displayComponentButtonObject(apsDroidLists[player],&rotation,&position,false, 100); } // clean up widgets if player leaves while menu is up. if(!isHumanPlayer(player) && !(game.type == SKIRMISH && player<game.maxPlayers)) { if(widgGetFromID(psWScreen,MULTIMENU_CHANNEL+player)) { widgDelete(psWScreen,MULTIMENU_CHANNEL+ player); } if(widgGetFromID(psWScreen,MULTIMENU_ALLIANCE_BASE+player) ) { widgDelete(psWScreen,MULTIMENU_ALLIANCE_BASE+ player); widgDelete(psWScreen,MULTIMENU_GIFT_RAD+ player); widgDelete(psWScreen,MULTIMENU_GIFT_RES+ player); widgDelete(psWScreen,MULTIMENU_GIFT_DRO+ player); widgDelete(psWScreen,MULTIMENU_GIFT_POW+ player); giftsUp[player] = false; } } }
/* Display a button */ void buttonDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, UDWORD *pColours) { W_BUTTON *psButton; SDWORD x0,y0,x1,y1, fx,fy,fw; // PROP_FONT *psCurrFont; int CurrFontID; ASSERT((PTRVALID(psWidget, sizeof(W_BUTTON)), "buttonDisplay: Invalid widget pointer")); psButton = (W_BUTTON *)psWidget; // psCurrFont = psButton->psFont; CurrFontID = psButton->FontID; x0=psButton->x + xOffset; y0=psButton->y + yOffset; x1=x0 + psButton->width; y1=y0 + psButton->height; if (psButton->state & (WBUTS_DOWN | WBUTS_LOCKED | WBUTS_CLICKLOCK)) { /* Display the button down */ pie_BoxFillIndex(x0,y0,x1,y1,WCOL_BKGRND); iV_Line(x0,y0, x1,y0,*(pColours + WCOL_DARK)); iV_Line(x0,y0, x0,y1,*(pColours + WCOL_DARK)); iV_Line(x0,y1, x1,y1,*(pColours + WCOL_LIGHT)); iV_Line(x1,y1, x1,y0,*(pColours + WCOL_LIGHT)); if (psButton->pText) { iV_SetFont(psButton->FontID); iV_SetTextColour((UWORD)*(pColours + WCOL_TEXT)); fw = iV_GetTextWidth(psButton->pText); if(psButton->style & WBUT_NOCLICKMOVE) { fx = x0 + (psButton->width - fw) / 2 + 1; fy = y0 + 1 + (psButton->height - iV_GetTextLineSize())/2 - iV_GetTextAboveBase(); } else { fx = x0 + (psButton->width - fw) / 2; fy = y0 + (psButton->height - iV_GetTextLineSize())/2 - iV_GetTextAboveBase(); } iV_DrawText(psButton->pText,fx,fy); } if (psButton->state & WBUTS_HILITE) { /* Display the button hilite */ iV_Line(x0+3,y0+3, x1-2,y0+3,*(pColours + WCOL_HILITE)); iV_Line(x0+3,y0+3, x0+3,y1-2,*(pColours + WCOL_HILITE)); iV_Line(x0+3,y1-2, x1-2,y1-2,*(pColours + WCOL_HILITE)); iV_Line(x1-2,y1-2, x1-2,y0+3,*(pColours + WCOL_HILITE)); } } else if (psButton->state & WBUTS_GREY) { /* Display the disabled button */ pie_BoxFillIndex(x0,y0,x1,y1,WCOL_BKGRND); iV_Line(x0,y0, x1,y0,*(pColours + WCOL_LIGHT)); iV_Line(x0,y0, x0,y1,*(pColours + WCOL_LIGHT)); iV_Line(x0,y1, x1,y1,*(pColours + WCOL_DARK)); iV_Line(x1,y1, x1,y0,*(pColours + WCOL_DARK)); if (psButton->pText) { iV_SetFont(psButton->FontID); fw = iV_GetTextWidth(psButton->pText); fx = x0 + (psButton->width - fw) / 2; fy = y0 + (psButton->height - iV_GetTextLineSize())/2 - iV_GetTextAboveBase(); iV_SetTextColour((UWORD)*(pColours + WCOL_LIGHT)); iV_DrawText(psButton->pText,fx+1,fy+1); iV_SetTextColour((UWORD)*(pColours + WCOL_DISABLE)); iV_DrawText(psButton->pText,fx,fy); } if (psButton->state & WBUTS_HILITE) { /* Display the button hilite */ iV_Line(x0+2,y0+2, x1-3,y0+2,*(pColours + WCOL_HILITE)); iV_Line(x0+2,y0+2, x0+2,y1-3,*(pColours + WCOL_HILITE)); iV_Line(x0+2,y1-3, x1-3,y1-3,*(pColours + WCOL_HILITE)); iV_Line(x1-3,y1-3, x1-3,y0+2,*(pColours + WCOL_HILITE)); } } else { /* Display the button up */ pie_BoxFillIndex(x0,y0,x1,y1,WCOL_BKGRND); iV_Line(x0,y0, x1,y0,*(pColours + WCOL_LIGHT)); iV_Line(x0,y0, x0,y1,*(pColours + WCOL_LIGHT)); iV_Line(x0,y1, x1,y1,*(pColours + WCOL_DARK)); iV_Line(x1,y1, x1,y0,*(pColours + WCOL_DARK)); //if (0) if (psButton->pText) { iV_SetFont(psButton->FontID); iV_SetTextColour((UWORD)*(pColours + WCOL_TEXT)); fw = iV_GetTextWidth(psButton->pText); fx = x0 + (psButton->width - fw) / 2; fy = y0 + (psButton->height - iV_GetTextLineSize())/2 - iV_GetTextAboveBase(); iV_DrawText(psButton->pText,fx,fy); } if (psButton->state & WBUTS_HILITE) { /* Display the button hilite */ iV_Line(x0+2,y0+2, x1-3,y0+2,*(pColours + WCOL_HILITE)); iV_Line(x0+2,y0+2, x0+2,y1-3,*(pColours + WCOL_HILITE)); iV_Line(x0+2,y1-3, x1-3,y1-3,*(pColours + WCOL_HILITE)); iV_Line(x1-3,y1-3, x1-3,y0+2,*(pColours + WCOL_HILITE)); } } }
/* The edit box display function */ void editBoxDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours) { W_EDITBOX *psEdBox; SDWORD x0,y0,x1,y1, fx,fy, cx,cy; enum iV_fonts CurrFontID; #if CURSOR_BLINK bool blink; #endif psEdBox = (W_EDITBOX *)psWidget; CurrFontID = psEdBox->FontID; x0=psEdBox->x + xOffset; y0=psEdBox->y + yOffset; x1=x0 + psEdBox->width; y1=y0 + psEdBox->height; if(psEdBox->pBoxDisplay) { psEdBox->pBoxDisplay((WIDGET *)psEdBox, xOffset, yOffset, pColours); } else { pie_BoxFill(x0, y0, x1, y1, pColours[WCOL_BKGRND]); iV_Line(x0,y0, x1,y0, pColours[WCOL_DARK]); iV_Line(x0,y0, x0,y1, pColours[WCOL_DARK]); iV_Line(x0,y1, x1,y1, pColours[WCOL_LIGHT]); iV_Line(x1,y1, x1,y0, pColours[WCOL_LIGHT]); } fx = x0 + WEDB_XGAP;// + (psEdBox->width - fw) / 2; iV_SetFont(CurrFontID); iV_SetTextColour(pColours[WCOL_TEXT]); fy = y0 + (psEdBox->height - iV_GetTextLineSize())/2 - iV_GetTextAboveBase(); /* If there is more text than will fit into the box, display the bit with the cursor in it */ QString tmp = psEdBox->aText; tmp.remove(0, psEdBox->printStart); // Erase anything there isn't room to display. tmp.remove(psEdBox->printChars, tmp.length()); // if(psEdBox->pFontDisplay) { // psEdBox->pFontDisplay(fx,fy, pPrint); // } else { iV_DrawText(tmp.toUtf8().constData(), fx, fy); // } // Display the cursor if editing #if CURSOR_BLINK blink = !(((wzGetTicks() - psEdBox->blinkOffset)/WEDB_BLINKRATE) % 2); if ((psEdBox->state & WEDBS_MASK) == WEDBS_INSERT && blink) #else if ((psEdBox->state & WEDBS_MASK) == WEDBS_INSERT) #endif { // insert mode QString tmp = psEdBox->aText; tmp.remove(psEdBox->insPos, tmp.length()); // Erase from the cursor on, to find where the cursor should be. tmp.remove(0, psEdBox->printStart); cx = x0 + WEDB_XGAP + iV_GetTextWidth(tmp.toUtf8().constData()); cx += iV_GetTextWidth("-"); cy = fy; iV_Line(cx, cy + iV_GetTextAboveBase(), cx, cy - iV_GetTextBelowBase(), pColours[WCOL_CURSOR]); } #if CURSOR_BLINK else if ((psEdBox->state & WEDBS_MASK) == WEDBS_OVER && blink) #else else if ((psEdBox->state & WEDBS_MASK) == WEDBS_OVER) #endif { // overwrite mode QString tmp = psEdBox->aText; tmp.remove(psEdBox->insPos, tmp.length()); // Erase from the cursor on, to find where the cursor should be. tmp.remove(0, psEdBox->printStart); cx = x0 + WEDB_XGAP + iV_GetTextWidth(tmp.toUtf8().constData()); cy = fy; iV_Line(cx, cy, cx + WEDB_CURSORSIZE, cy, pColours[WCOL_CURSOR]); } if(psEdBox->pBoxDisplay == NULL) { if (psEdBox->state & WEDBS_HILITE) { /* Display the button hilite */ iV_Line(x0-2,y0-2, x1+2,y0-2, pColours[WCOL_HILITE]); iV_Line(x0-2,y0-2, x0-2,y1+2, pColours[WCOL_HILITE]); iV_Line(x0-2,y1+2, x1+2,y1+2, pColours[WCOL_HILITE]); iV_Line(x1+2,y1+2, x1+2,y0-2, pColours[WCOL_HILITE]); } } }