static void displayChannelState(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours) { UDWORD player = psWidget->UserData; if (openchannels[player]) { psWidget->UserData = PACKDWORD_TRI(0, IMAGE_MULTI_CHAN, IMAGE_MULTI_CHAN); } else { psWidget->UserData = PACKDWORD_TRI(0, IMAGE_MULTI_NOCHAN, IMAGE_MULTI_NOCHAN); } intDisplayImageHilight(psWidget, xOffset, yOffset, pColours); psWidget->UserData = player; }
static void displayAllianceState(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours) { UDWORD a, b, c, player = psWidget->UserData; switch(alliances[selectedPlayer][player]) { case ALLIANCE_BROKEN: a = 0; b = IMAGE_MULTI_NOAL_HI; c = IMAGE_MULTI_NOAL; // replace with real gfx break; case ALLIANCE_FORMED: a = 0; b = IMAGE_MULTI_AL_HI; c = IMAGE_MULTI_AL; // replace with real gfx break; case ALLIANCE_REQUESTED: case ALLIANCE_INVITATION: a = 0; b = IMAGE_MULTI_OFFAL_HI; c = IMAGE_MULTI_OFFAL; // replace with real gfx break; default: a = 0; b = IMAGE_MULTI_NOAL_HI; c = IMAGE_MULTI_NOAL; break; } psWidget->UserData = PACKDWORD_TRI(a,b,c); intDisplayImageHilight(psWidget, xOffset, yOffset, pColours); psWidget->UserData = player; }
bool intAddMultiMenu(void) { UDWORD i; //check for already open. if(widgGetFromID(psWScreen,MULTIMENU_FORM)) { intCloseMultiMenu(); return true; } if (intMode != INT_INTELMAP) { intResetScreen(false); } WIDGET *parent = psWScreen->psForm; // add form IntFormAnimated *multiMenuForm = new IntFormAnimated(parent); multiMenuForm->id = MULTIMENU_FORM; multiMenuForm->setGeometry(MULTIMENU_FORM_X, MULTIMENU_FORM_Y, MULTIMENU_FORM_W, MULTIMENU_PLAYER_H*game.maxPlayers + MULTIMENU_PLAYER_H + 7); // add any players for(i=0;i<MAX_PLAYERS;i++) { if(isHumanPlayer(i) || (game.type == SKIRMISH && i<game.maxPlayers && game.skDiff[i] ) ) { addMultiPlayer(i,NetPlay.players[i].position); } } // Add the close button. W_BUTINIT sButInit; sButInit.formID = MULTIMENU_FORM; sButInit.id = MULTIMENU_CLOSE; sButInit.x = MULTIMENU_FORM_W - CLOSE_WIDTH; sButInit.y = 0; sButInit.width = CLOSE_WIDTH; sButInit.height = CLOSE_HEIGHT; sButInit.pTip = _("Close"); sButInit.pDisplay = intDisplayImageHilight; sButInit.UserData = PACKDWORD_TRI(0,IMAGE_CLOSEHILIGHT , IMAGE_CLOSE); if (!widgAddButton(psWScreen, &sButInit)) { return false; } intShowPowerBar(); // add power bar if (intMode != INT_INTELMAP) { intMode = INT_MULTIMENU; // change interface mode. } MultiMenuUp = true; return true; }
static void displayChannelState(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours) { UDWORD a, b, c, player = psWidget->UserData; switch(openchannels[player]) { case 1: a = 0; b = IMAGE_MULTI_CHAN; c = IMAGE_MULTI_CHAN; break; case 0: default: a = 0; b = IMAGE_MULTI_NOCHAN; c = IMAGE_MULTI_NOCHAN; break; } psWidget->UserData = PACKDWORD_TRI(a,b,c); intDisplayImageHilight(psWidget, xOffset, yOffset, pColours); psWidget->UserData = player; }
BOOL intAddMultiMenu(void) { W_FORMINIT sFormInit; W_BUTINIT sButInit; UDWORD i; //check for already open. if(widgGetFromID(psWScreen,MULTIMENU_FORM)) { intCloseMultiMenu(); return true; } if (intMode != INT_INTELMAP) { intResetScreen(false); } // add form memset(&sFormInit, 0, sizeof(W_FORMINIT)); sFormInit.formID = 0; sFormInit.id = MULTIMENU_FORM; sFormInit.style = WFORM_PLAIN; sFormInit.x =(SWORD)(MULTIMENU_FORM_X); sFormInit.y =(SWORD)(MULTIMENU_FORM_Y); sFormInit.width = MULTIMENU_FORM_W; sFormInit.height = (UWORD)(MULTIMENU_PLAYER_H*game.maxPlayers + MULTIMENU_PLAYER_H+7); //MULTIMENU_FORM_H; sFormInit.pDisplay = intOpenPlainForm; sFormInit.disableChildren = true; if (!widgAddForm(psWScreen, &sFormInit)) { return false; } // add any players for(i=0;i<MAX_PLAYERS;i++) { if(isHumanPlayer(i) || (game.type == SKIRMISH && i<game.maxPlayers && game.skDiff[i] ) ) { addMultiPlayer(i,NetPlay.players[i].position); } } // Add the close button. memset(&sButInit, 0, sizeof(W_BUTINIT)); sButInit.formID = MULTIMENU_FORM; sButInit.id = MULTIMENU_CLOSE; sButInit.style = WBUT_PLAIN; sButInit.x = MULTIMENU_FORM_W - CLOSE_WIDTH; sButInit.y = 0; sButInit.width = CLOSE_WIDTH; sButInit.height = CLOSE_HEIGHT; sButInit.pTip = _("Close"); sButInit.FontID = font_regular; sButInit.pDisplay = intDisplayImageHilight; sButInit.UserData = PACKDWORD_TRI(0,IMAGE_CLOSEHILIGHT , IMAGE_CLOSE); if (!widgAddButton(psWScreen, &sButInit)) { return false; } intShowPowerBar(); // add power bar if (intMode != INT_INTELMAP) { intMode = INT_MULTIMENU; // change interface mode. } MultiMenuUp = true; return true; }
static void addMultiPlayer(UDWORD player,UDWORD pos) { UDWORD y,id; W_BUTINIT sButInit; W_FORMINIT sFormInit; y = MULTIMENU_PLAYER_H*(pos+1); // this is the top of the pos. id = MULTIMENU_PLAYER+player; // add the whole thing. memset(&sFormInit, 0, sizeof(W_FORMINIT)); sFormInit.formID = MULTIMENU_FORM; sFormInit.id = id; sFormInit.style = WFORM_PLAIN; sFormInit.x = 2; sFormInit.y = (short)y; sFormInit.width = MULTIMENU_FORM_W -4; sFormInit.height = MULTIMENU_PLAYER_H; sFormInit.pDisplay = displayMultiPlayer; sFormInit.UserData = player; widgAddForm(psWScreen, &sFormInit); //name, //score, //kills, //ping //ALL DONE IN THE DISPLAY FUNC. // add channel opener. if(player != selectedPlayer) { memset(&sButInit, 0, sizeof(W_BUTINIT)); sButInit.formID = id; sButInit.style = WBUT_PLAIN; sButInit.x = MULTIMENU_C0; sButInit.y = 5; sButInit.width = 35; sButInit.height = 24; sButInit.FontID = font_regular; sButInit.id = MULTIMENU_CHANNEL + player; sButInit.pTip = _("Channel"); sButInit.pDisplay = displayChannelState; sButInit.UserData = player; widgAddButton(psWScreen, &sButInit); } if(game.alliance!=NO_ALLIANCES && player!=selectedPlayer) { //alliance sButInit.x = MULTIMENU_C3; sButInit.y = 5; sButInit.width = 35; sButInit.height = 24; sButInit.FontID = font_regular; sButInit.id = MULTIMENU_ALLIANCE_BASE + player; sButInit.pTip = _("Toggle Alliance State"); sButInit.pDisplay = displayAllianceState; sButInit.UserData = player; //can't break alliances in 'Locked Teams' mode if(game.alliance != ALLIANCES_TEAMS) { widgAddButton(psWScreen, &sButInit); } sButInit.pDisplay = intDisplayImageHilight; // add the gift buttons. sButInit.y += 1; // move down a wee bit. if (game.alliance != ALLIANCES_TEAMS) { sButInit.id = MULTIMENU_GIFT_RAD+ player; sButInit.x = MULTIMENU_C4; sButInit.pTip = _("Give Visibility Report"); sButInit.UserData = PACKDWORD_TRI(0,IMAGE_MULTI_VIS_HI, IMAGE_MULTI_VIS); widgAddButton(psWScreen, &sButInit); sButInit.id = MULTIMENU_GIFT_RES + player; sButInit.x = MULTIMENU_C5; sButInit.pTip = _("Leak Technology Documents"); sButInit.UserData = PACKDWORD_TRI(0,IMAGE_MULTI_TEK_HI , IMAGE_MULTI_TEK); widgAddButton(psWScreen, &sButInit); } sButInit.id = MULTIMENU_GIFT_DRO + player; sButInit.x = MULTIMENU_C6; sButInit.pTip = _("Hand Over Selected Units"); sButInit.UserData = PACKDWORD_TRI(0,IMAGE_MULTI_DRO_HI , IMAGE_MULTI_DRO); widgAddButton(psWScreen, &sButInit); sButInit.id = MULTIMENU_GIFT_POW + player; sButInit.x = MULTIMENU_C7; sButInit.pTip = _("Give Power To Player"); sButInit.UserData = PACKDWORD_TRI(0,IMAGE_MULTI_POW_HI , IMAGE_MULTI_POW); widgAddButton(psWScreen, &sButInit); giftsUp[player] = true; // note buttons are up! } }
// //////////////////////////////////////////////////// static BOOL _addLoadSave(BOOL bLoad,CHAR *sSearchPath,CHAR *sExtension, CHAR *title) { W_FORMINIT sFormInit; W_BUTINIT sButInit; W_LABINIT sLabInit; UDWORD slotCount; static STRING sSlots[10][64]; STRING sTemp[255]; WIN32_FIND_DATA found; HANDLE dir; mode = bLoad; if(GetCurrentDirectory(255,(char*)&sTemp) == 0) { return FALSE; // failed, directory probably didn't exist. } if ((bLoadSaveMode == LOAD_INGAME) || (bLoadSaveMode == SAVE_INGAME)) { if (!bMultiPlayer || (NetPlay.bComms ==0)) { gameTimeStop(); if(GetGameMode() == GS_NORMAL) { BOOL radOnScreen = radarOnScreen; // Only do this in main game. bRender3DOnly = TRUE; radarOnScreen = FALSE; displayWorld(); // Just display the 3d, no interface pie_UploadDisplayBuffer(DisplayBuffer); // Upload the current display back buffer into system memory. iV_ScaleBitmapRGB(DisplayBuffer,iV_GetDisplayWidth(), iV_GetDisplayHeight(),2,2,2); // Make it darker. radarOnScreen = radOnScreen; bRender3DOnly = FALSE; } setGamePauseStatus( TRUE ); setGameUpdatePause(TRUE); setScriptPause(TRUE); setScrollPause(TRUE); setConsolePause(TRUE); } forceHidePowerBar(); intRemoveReticule(); } CreateDirectory(sSearchPath,NULL); // create the directory required... fails if already there, so no problem. widgCreateScreen(&psRequestScreen); // init the screen. widgSetTipFont(psRequestScreen,WFont); /* add a form to place the tabbed form on */ memset(&sFormInit, 0, sizeof(W_FORMINIT)); sFormInit.formID = 0; sFormInit.id = LOADSAVE_FORM; sFormInit.style = WFORM_PLAIN; sFormInit.x = (SWORD)(LOADSAVE_X); sFormInit.y = (SWORD)(LOADSAVE_Y); sFormInit.width = LOADSAVE_W; sFormInit.height = LOADSAVE_H; sFormInit.disableChildren = TRUE; sFormInit.pDisplay = intOpenPlainForm; widgAddForm(psRequestScreen, &sFormInit); // Add Banner sFormInit.formID = LOADSAVE_FORM; sFormInit.id = LOADSAVE_BANNER; sFormInit.x = LOADSAVE_HGAP; sFormInit.y = LOADSAVE_VGAP; sFormInit.width = LOADSAVE_W-(2*LOADSAVE_HGAP); sFormInit.height = LOADSAVE_BANNER_DEPTH; sFormInit.disableChildren = FALSE; sFormInit.pDisplay = displayLoadBanner; sFormInit.pUserData = (VOID *)bLoad; widgAddForm(psRequestScreen, &sFormInit); // Add Banner Label memset(&sLabInit, 0, sizeof(W_LABINIT)); sLabInit.formID = LOADSAVE_BANNER; sLabInit.id = LOADSAVE_LABEL; sLabInit.style = WLAB_ALIGNCENTRE; sLabInit.x = 0; sLabInit.y = 4; sLabInit.width = LOADSAVE_W-(2*LOADSAVE_HGAP); //LOADSAVE_W; sLabInit.height = 20; sLabInit.pText = title; sLabInit.FontID = WFont; widgAddLabel(psRequestScreen, &sLabInit); // add cancel. memset(&sButInit, 0, sizeof(W_BUTINIT)); sButInit.formID = LOADSAVE_BANNER; sButInit.x = 4; sButInit.y = 3; sButInit.width = iV_GetImageWidth(IntImages,IMAGE_NRUTER); sButInit.height = iV_GetImageHeight(IntImages,IMAGE_NRUTER); sButInit.pUserData = (void*)PACKDWORD_TRI(0,IMAGE_NRUTER , IMAGE_NRUTER); sButInit.id = LOADSAVE_CANCEL; sButInit.style = WBUT_PLAIN; sButInit.pTip = strresGetString(psStringRes, STR_MISC_CLOSE); sButInit.FontID = WFont; sButInit.pDisplay = intDisplayImageHilight; widgAddButton(psRequestScreen, &sButInit); // add slots memset(&sButInit, 0, sizeof(W_BUTINIT)); sButInit.formID = LOADSAVE_FORM; sButInit.style = WBUT_PLAIN; sButInit.width = LOADENTRY_W; sButInit.height = LOADENTRY_H; sButInit.pDisplay = displayLoadSlot; sButInit.FontID = WFont; for(slotCount = 0; slotCount< 10 ; slotCount++) { sButInit.id = slotCount+LOADENTRY_START; if(slotCount<5) { sButInit.x = LOADSAVE_HGAP; sButInit.y = (SWORD)((LOADSAVE_BANNER_DEPTH +(2*LOADSAVE_VGAP)) + ( slotCount*(LOADSAVE_VGAP+LOADENTRY_H))); } else { sButInit.x = (2*LOADSAVE_HGAP)+LOADENTRY_W; sButInit.y = (SWORD)((LOADSAVE_BANNER_DEPTH +(2* LOADSAVE_VGAP)) + ( (slotCount-5) *(LOADSAVE_VGAP+LOADENTRY_H))); } widgAddButton(psRequestScreen, &sButInit); } // fill slots. slotCount = 0; sprintf(sTemp,"%s*.%s",sSearchPath,sExtension); // form search string. strcpy(sPath,sSearchPath); // setup locals. strcpy(sExt,sExtension); dir =FindFirstFile(sTemp,&found); if(dir != INVALID_HANDLE_VALUE) { while( TRUE ) { /* Set the tip and add the button */ found.cFileName[strlen(found.cFileName) -4 ] = '\0'; // chop extension strcpy(sSlots[slotCount],found.cFileName); //store it! ((W_BUTTON *)widgGetFromID(psRequestScreen,LOADENTRY_START+slotCount))->pTip = sSlots[slotCount]; ((W_BUTTON *)widgGetFromID(psRequestScreen,LOADENTRY_START+slotCount))->pText = sSlots[slotCount]; slotCount++; // goto next but. if(!FindNextFile(dir,&found ) || slotCount == 10 )// only show upto 10 entrys. { break; } } } FindClose(dir); bLoadSaveUp = TRUE; return TRUE; }
// Add the droid order screen. // Returns true if the form was displayed ok. // //changed to a BASE_OBJECT to accomodate the factories - AB 21/04/99 bool intAddOrder(BASE_OBJECT *psObj) { bool Animate = true; SECONDARY_STATE State; UWORD OrdIndex; UWORD Height, NumDisplayedOrders; UWORD NumButs; UWORD NumJustifyButs, NumCombineButs, NumCombineBefore; bool bLastCombine, bHidden; DROID *Droid; STRUCTURE *psStructure; if (bInTutorial) { // No RMB orders in tutorial!! return (false); } // Is the form already up? if (widgGetFromID(psWScreen, IDORDER_FORM) != NULL) { intRemoveOrderNoAnim(); Animate = false; } // Is the stats window up? if (widgGetFromID(psWScreen, IDSTAT_FORM) != NULL) { intRemoveStatsNoAnim(); Animate = false; } if (psObj) { if (psObj->type == OBJ_DROID) { Droid = (DROID *)psObj; psStructure = NULL; } else if (psObj->type == OBJ_STRUCTURE) { Droid = NULL; psStructure = (STRUCTURE *)psObj; psSelectedFactory = psStructure; ASSERT_OR_RETURN(false, StructIsFactory(psSelectedFactory), "Trying to select a %s as a factory!", objInfo((BASE_OBJECT *)psSelectedFactory)); } else { ASSERT(false, "Invalid object type"); Droid = NULL; psStructure = NULL; } } else { Droid = NULL; psStructure = NULL; } setWidgetsStatus(true); AvailableOrders.clear(); SelectedDroids.clear(); // Selected droid is a command droid? if ((Droid != NULL) && (Droid->droidType == DROID_COMMAND)) { // displaying for a command droid - ignore any other droids SelectedDroids.push_back(Droid); } else if (psStructure != NULL) { AvailableOrders = buildStructureOrderList(psStructure); if (AvailableOrders.empty()) { return false; } } // Otherwise build a list of selected droids. else if (!BuildSelectedDroidList()) { // If no droids selected then see if we were given a specific droid. if (Droid != NULL) { // and put it in the list. SelectedDroids.push_back(Droid); } } // Build a list of orders available for the list of selected droids. - if a factory has not been selected if (psStructure == NULL) { AvailableOrders = buildDroidOrderList(); if (AvailableOrders.empty()) { // If no orders then return; return false; } } WIDGET *parent = psWScreen->psForm; /* Create the basic form */ IntFormAnimated *orderForm = new IntFormAnimated(parent, Animate); // Do not animate the opening, if the window was already open. orderForm->id = IDORDER_FORM; orderForm->setGeometry(ORDER_X, ORDER_Y, ORDER_WIDTH, ORDER_HEIGHT); // Add the close button. W_BUTINIT sButInit; sButInit.formID = IDORDER_FORM; sButInit.id = IDORDER_CLOSE; sButInit.x = ORDER_WIDTH - CLOSE_WIDTH; sButInit.y = 0; sButInit.width = CLOSE_WIDTH; sButInit.height = CLOSE_HEIGHT; sButInit.pTip = _("Close"); sButInit.pDisplay = intDisplayImageHilight; sButInit.UserData = PACKDWORD_TRI(0, IMAGE_CLOSEHILIGHT , IMAGE_CLOSE); if (!widgAddButton(psWScreen, &sButInit)) { return false; } sButInit = W_BUTINIT(); sButInit.formID = IDORDER_FORM; sButInit.id = IDORDER_CLOSE + 1; sButInit.pDisplay = intDisplayButtonHilight; sButInit.y = ORDER_BUTY; Height = 0; NumDisplayedOrders = 0; for (unsigned j = 0; j < AvailableOrders.size() && NumDisplayedOrders < MAX_DISPLAYABLE_ORDERS; ++j) { OrdIndex = AvailableOrders[j].OrderIndex; // Get current order state. State = GetSecondaryStates(OrderButtons[OrdIndex].Order); // Get number of buttons. NumButs = OrderButtons[OrdIndex].NumButs; // Set actual number of buttons. OrderButtons[OrdIndex].AcNumButs = NumButs; // Handle special case for factory -> command droid assignment buttons. switch (OrderButtons[OrdIndex].Class) { case ORDBUTCLASS_FACTORY: NumButs = countAssignableFactories((UBYTE)selectedPlayer, FACTORY_FLAG); break; case ORDBUTCLASS_CYBORGFACTORY: NumButs = countAssignableFactories((UBYTE)selectedPlayer, CYBORG_FLAG); break; case ORDBUTCLASS_VTOLFACTORY: NumButs = countAssignableFactories((UBYTE)selectedPlayer, VTOL_FLAG); break; default: break; } sButInit.id = OrderButtons[OrdIndex].ButBaseID; NumJustifyButs = NumButs; bLastCombine = false; switch (OrderButtons[OrdIndex].ButJustify & ORD_JUSTIFY_MASK) { case ORD_JUSTIFY_LEFT: sButInit.x = ORDER_BUTX; break; case ORD_JUSTIFY_RIGHT: sButInit.x = orderForm->width() - ORDER_BUTX - (NumJustifyButs * GetImageWidth(IntImages, OrderButtons[OrdIndex].ButImageID[0]) + (NumJustifyButs - 1) * ORDER_BUTGAP); break; case ORD_JUSTIFY_CENTER: sButInit.x = (orderForm->width() - (NumJustifyButs * GetImageWidth(IntImages, OrderButtons[OrdIndex].ButImageID[0]) + (NumJustifyButs - 1) * ORDER_BUTGAP)) / 2; break; case ORD_JUSTIFY_COMBINE: // see how many are on this line before the button NumCombineBefore = 0; for (unsigned i = 0; i < j; ++i) { if ((OrderButtons[AvailableOrders[i].OrderIndex].ButJustify & ORD_JUSTIFY_MASK) == ORD_JUSTIFY_COMBINE) { NumCombineBefore += 1; } } NumCombineButs = (UWORD)(NumCombineBefore + 1); // now see how many in total for (unsigned i = j + 1; i < AvailableOrders.size(); ++i) { if ((OrderButtons[AvailableOrders[i].OrderIndex].ButJustify & ORD_JUSTIFY_MASK) == ORD_JUSTIFY_COMBINE) { NumCombineButs += 1; } } // get position on line NumCombineButs = (UWORD)(NumCombineButs - (NumCombineBefore - (NumCombineBefore % ORD_MAX_COMBINE_BUTS))); if (NumCombineButs >= ORD_MAX_COMBINE_BUTS) { // the buttons will fill the line sButInit.x = (SWORD)(ORDER_BUTX + (GetImageWidth(IntImages, OrderButtons[OrdIndex].ButImageID[0]) + ORDER_BUTGAP) * NumCombineBefore); } else { // center the buttons sButInit.x = orderForm->width() / 2 - (NumCombineButs * GetImageWidth(IntImages, OrderButtons[OrdIndex].ButImageID[0]) + (NumCombineButs - 1) * ORDER_BUTGAP) / 2; sButInit.x = (SWORD)(sButInit.x + (GetImageWidth(IntImages, OrderButtons[OrdIndex].ButImageID[0]) + ORDER_BUTGAP) * NumCombineBefore); } // see if need to start a new line of buttons if ((NumCombineBefore + 1) == (NumCombineButs % ORD_MAX_COMBINE_BUTS)) { bLastCombine = true; } break; } for (unsigned i = 0; i < OrderButtons[OrdIndex].AcNumButs; ++i) { sButInit.pTip = getDORDDescription(OrderButtons[OrdIndex].ButTips[i]); sButInit.width = (UWORD)GetImageWidth(IntImages, OrderButtons[OrdIndex].ButImageID[i]); sButInit.height = (UWORD)GetImageHeight(IntImages, OrderButtons[OrdIndex].ButImageID[i]); sButInit.UserData = PACKDWORD_TRI(OrderButtons[OrdIndex].ButGreyID[i], OrderButtons[OrdIndex].ButHilightID[i], OrderButtons[OrdIndex].ButImageID[i]); if (!widgAddButton(psWScreen, &sButInit)) { return false; } // Set the default state for the button. switch (OrderButtons[OrdIndex].ButType) { case ORD_BTYPE_RADIO: case ORD_BTYPE_BOOLEAN: if ((State & OrderButtons[OrdIndex].StateMask) == (UDWORD)OrderButtons[OrdIndex].States[i]) { widgSetButtonState(psWScreen, sButInit.id, WBUT_CLICKLOCK); } else { widgSetButtonState(psWScreen, sButInit.id, 0); } break; case ORD_BTYPE_BOOLEAN_DEPEND: if ((State & OrderButtons[OrdIndex].StateMask) == (UDWORD)OrderButtons[OrdIndex].States[i]) { widgSetButtonState(psWScreen, sButInit.id, WBUT_CLICKLOCK); } else { if (i == 0) { widgSetButtonState(psWScreen, sButInit.id, 0); } else { widgSetButtonState(psWScreen, sButInit.id, WBUT_DISABLE); } } break; case ORD_BTYPE_BOOLEAN_COMBINE: if (State & (UDWORD)OrderButtons[OrdIndex].States[i]) { widgSetButtonState(psWScreen, sButInit.id, WBUT_CLICKLOCK); } break; } // may not add a button if the factory doesn't exist bHidden = false; switch (OrderButtons[OrdIndex].Class) { case ORDBUTCLASS_FACTORY: if (!checkFactoryExists(selectedPlayer, FACTORY_FLAG, i)) { widgHide(psWScreen, sButInit.id); bHidden = true; } break; case ORDBUTCLASS_CYBORGFACTORY: if (!checkFactoryExists(selectedPlayer, CYBORG_FLAG, i)) { widgHide(psWScreen, sButInit.id); bHidden = true; } break; case ORDBUTCLASS_VTOLFACTORY: if (!checkFactoryExists(selectedPlayer, VTOL_FLAG, i)) { widgHide(psWScreen, sButInit.id); bHidden = true; } break; default: break; } if (!bHidden) { sButInit.x = (SWORD)(sButInit.x + sButInit.width + ORDER_BUTGAP); } sButInit.id++; } if (((OrderButtons[OrdIndex].ButJustify & ORD_JUSTIFY_MASK) != ORD_JUSTIFY_COMBINE) || bLastCombine) { sButInit.y = (SWORD)(sButInit.y + sButInit.height + ORDER_BUTGAP); Height = (UWORD)(Height + sButInit.height + ORDER_BUTGAP); } NumDisplayedOrders ++; } // Now we know how many orders there are we can resize the form accordingly. int newHeight = Height + CLOSE_HEIGHT + ORDER_BUTGAP; orderForm->setGeometry(orderForm->x(), ORDER_BOTTOMY - newHeight, orderForm->width(), newHeight); OrderUp = true; return true; }
// Add the main Transporter Contents Interface bool intAddTransporterContents(void) { bool Animate = true; // Is the form already up? if (widgGetFromID(psWScreen, IDTRANS_CONTENTFORM) != NULL) { intRemoveTransContentNoAnim(); Animate = false; } if (intIsRefreshing()) { Animate = false; } WIDGET *parent = psWScreen->psForm; IntFormAnimated *transContentForm = new IntFormAnimated(parent, Animate); // Do not animate the opening, if the window was already open. transContentForm->id = IDTRANS_CONTENTFORM; transContentForm->setGeometry(TRANSCONT_X, TRANSCONT_Y, TRANSCONT_WIDTH, TRANSCONT_HEIGHT); /* Add the close button */ W_BUTINIT sButInit; sButInit.formID = IDTRANS_CONTENTFORM; sButInit.id = IDTRANS_CONTCLOSE; sButInit.x = STAT_WIDTH - CLOSE_WIDTH; sButInit.y = 0; sButInit.width = CLOSE_WIDTH; sButInit.height = CLOSE_HEIGHT; sButInit.pTip = _("Close"); sButInit.pDisplay = intDisplayImageHilight; sButInit.UserData = PACKDWORD_TRI(0, IMAGE_CLOSEHILIGHT , IMAGE_CLOSE); if (!widgAddButton(psWScreen, &sButInit)) { return false; } if (bMultiPlayer) { //add the capacity label W_LABINIT sLabInit; sLabInit.formID = IDTRANS_CONTENTFORM; sLabInit.id = IDTRANS_CAPACITY; sLabInit.x = (SWORD)sButInit.x - 40; sLabInit.y = 0; sLabInit.width = 16; sLabInit.height = 16; sLabInit.pText = "00/10"; sLabInit.pCallback = intUpdateTransCapacity; if (!widgAddLabel(psWScreen, &sLabInit)) { return false; } } //add the Launch button if on a mission if (onMission) { W_FORMINIT sButFInit; sButFInit.formID = IDTRANS_CONTENTFORM; sButFInit.id = IDTRANS_LAUNCH; sButFInit.style = WFORM_CLICKABLE | WFORM_NOCLICKMOVE; sButFInit.x = OBJ_STARTX; sButFInit.y = (UWORD)(STAT_SLDY - 1); sButFInit.width = iV_GetImageWidth(IntImages, IMAGE_LAUNCHUP); sButFInit.height = iV_GetImageHeight(IntImages, IMAGE_LAUNCHUP); sButFInit.pTip = _("Launch Transport"); sButFInit.pDisplay = intDisplayImageHilight; sButFInit.UserData = PACKDWORD_TRI(0, IMAGE_LAUNCHDOWN, IMAGE_LAUNCHUP); if (!widgAddForm(psWScreen, &sButFInit)) { return false; } } if (!intAddTransContentsForm()) { return false; } return true; }
/*Add the Transporter Interface*/ static bool _intAddTransporter(DROID *psSelected, bool offWorld) { bool Animate = true; onMission = offWorld; psCurrTransporter = psSelected; /*if transporter has died - close the interface - this can only happen in multiPlayer where the transporter can be killed*/ if (bMultiPlayer) { if (psCurrTransporter && isDead((BASE_OBJECT *)psCurrTransporter)) { intRemoveTransNoAnim(); return true; } } // Add the main Transporter form // Is the form already up? if (widgGetFromID(psWScreen, IDTRANS_FORM) != NULL) { intRemoveTransNoAnim(); Animate = false; } if (intIsRefreshing()) { Animate = false; } WIDGET *parent = psWScreen->psForm; IntFormAnimated *transForm = new IntFormAnimated(parent, Animate); // Do not animate the opening, if the window was already open. transForm->id = IDTRANS_FORM; transForm->setGeometry(TRANS_X, TRANS_Y, TRANS_WIDTH, TRANS_HEIGHT); /* Add the close button */ W_BUTINIT sButInit; sButInit.formID = IDTRANS_FORM; sButInit.id = IDTRANS_CLOSE; sButInit.x = TRANS_WIDTH - CLOSE_WIDTH; sButInit.y = 0; sButInit.width = CLOSE_WIDTH; sButInit.height = CLOSE_HEIGHT; sButInit.pTip = _("Close"); sButInit.pDisplay = intDisplayImageHilight; sButInit.UserData = PACKDWORD_TRI(0, IMAGE_CLOSEHILIGHT , IMAGE_CLOSE); if (!widgAddButton(psWScreen, &sButInit)) { return false; } if (!intAddTransButtonForm()) { return false; } // Add the Transporter Contents form (and buttons) if (!intAddTransporterContents()) { return false; } //if on a mission - add the Droids back at home base form if (onMission) { if (!intAddDroidsAvailForm()) { return false; } } return true; }
/* Add the Droids back at home form */ bool intAddDroidsAvailForm(void) { UDWORD numButtons, i, butPerForm; SDWORD BufferID; DROID *psDroid; bool Animate = true; // Is the form already up? if (widgGetFromID(psWScreen, IDTRANS_DROIDS) != NULL) { intRemoveTransDroidsAvailNoAnim(); Animate = false; } if (intIsRefreshing()) { Animate = false; } /* Add the droids available form */ W_FORMINIT sFormInit; sFormInit.formID = 0; sFormInit.id = IDTRANS_DROIDS; sFormInit.style = WFORM_PLAIN; sFormInit.width = TRANSDROID_WIDTH; sFormInit.height = TRANSDROID_HEIGHT; sFormInit.x = (SWORD)TRANSDROID_X; sFormInit.y = (SWORD)TRANSDROID_Y; // If the window was closed then do open animation. if (Animate) { sFormInit.pDisplay = intOpenPlainForm; sFormInit.disableChildren = true; } else { // otherwise just recreate it. sFormInit.pDisplay = intDisplayPlainForm; } if (!widgAddForm(psWScreen, &sFormInit)) { return false; } /* Add the close button */ W_BUTINIT sButInit; sButInit.formID = IDTRANS_DROIDS; sButInit.id = IDTRANS_DROIDCLOSE; sButInit.x = TRANSDROID_WIDTH - CLOSE_WIDTH; sButInit.y = 0; sButInit.width = CLOSE_WIDTH; sButInit.height = CLOSE_HEIGHT; sButInit.pTip = _("Close"); sButInit.pDisplay = intDisplayImageHilight; sButInit.UserData = PACKDWORD_TRI(0, IMAGE_CLOSEHILIGHT , IMAGE_CLOSE); if (!widgAddButton(psWScreen, &sButInit)) { return false; } //now add the tabbed droids available form sFormInit = W_FORMINIT(); sFormInit.formID = IDTRANS_DROIDS; sFormInit.id = IDTRANS_DROIDTAB; sFormInit.style = WFORM_TABBED; sFormInit.width = TRANSDROID_TABWIDTH; sFormInit.height = TRANSDROID_TABHEIGHT; sFormInit.x = TRANSDROID_TABX; sFormInit.y = TRANSDROID_TABY; sFormInit.majorPos = WFORM_TABTOP; sFormInit.minorPos = WFORM_TABNONE; sFormInit.majorSize = (OBJ_TABWIDTH / 2); sFormInit.majorOffset = OBJ_TABOFFSET; sFormInit.tabVertOffset = (OBJ_TABHEIGHT / 2); sFormInit.tabMajorThickness = OBJ_TABHEIGHT; sFormInit.tabMajorGap = OBJ_TABOFFSET; //calc num buttons numButtons = 0; //look through the list of droids that were built before the mission for (psDroid = mission.apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext) { //ignore any Transporters! if (psDroid->droidType != DROID_TRANSPORTER && psDroid->droidType != DROID_SUPERTRANSPORTER) { numButtons++; } //quit when reached max can cope with if (numButtons == MAX_DROIDS) { break; } } butPerForm = ((TRANSDROID_TABWIDTH - OBJ_GAP) / (OBJ_BUTWIDTH + OBJ_GAP)) * ((TRANSDROID_TABHEIGHT - OBJ_GAP) / (OBJ_BUTHEIGHT + OBJ_GAP)); sFormInit.numMajor = numForms(numButtons, butPerForm); if (sFormInit.numMajor > MAX_TAB_SMALL_SHOWN) { // we DO use smallTab icons here, so be safe and only display max # of // small sized tab icons. No scrolltabs here. sFormInit.numMajor = MAX_TAB_SMALL_SHOWN; } //set minor tabs to 1 for (i = 0; i < sFormInit.numMajor; i++) { sFormInit.aNumMinors[i] = 1; } sFormInit.pUserData = &SmallTab; sFormInit.pTabDisplay = intDisplayTab; if (!widgAddForm(psWScreen, &sFormInit)) { return false; } /* Add the droids available buttons */ W_FORMINIT sBFormInit; sBFormInit.formID = IDTRANS_DROIDTAB; sBFormInit.id = IDTRANS_DROIDSTART; sBFormInit.majorID = 0; sBFormInit.minorID = 0; sBFormInit.style = WFORM_CLICKABLE; sBFormInit.x = OBJ_STARTX; sBFormInit.y = AVAIL_STARTY; sBFormInit.width = OBJ_BUTWIDTH; sBFormInit.height = OBJ_BUTHEIGHT; ClearSystem0Buffers(); /* Add the state of repair bar for each droid*/ W_BARINIT sBarInit; sBarInit.id = IDTRANS_REPAIRBARSTART; sBarInit.x = STAT_TIMEBARX; sBarInit.y = STAT_TIMEBARY; sBarInit.width = STAT_PROGBARWIDTH; sBarInit.height = STAT_PROGBARHEIGHT; sBarInit.size = 50; sBarInit.sCol = WZCOL_ACTION_PROGRESS_BAR_MAJOR; sBarInit.sMinorCol = WZCOL_ACTION_PROGRESS_BAR_MINOR; //add droids built before the mission for (psDroid = mission.apsDroidLists[selectedPlayer]; psDroid != NULL; psDroid = psDroid->psNext) { //stop adding the buttons once MAX_DROIDS has been reached if (sBFormInit.id == (IDTRANS_DROIDSTART + MAX_DROIDS)) { break; } //don't add Transporter Droids! if ((psDroid->droidType != DROID_TRANSPORTER && psDroid->droidType != DROID_SUPERTRANSPORTER)) { /* Set the tip and add the button */ sBFormInit.pTip = droidGetName(psDroid); BufferID = GetSystem0Buffer(); ASSERT(BufferID >= 0, "Unable to acquire stat buffer."); RENDERBUTTON_INUSE(&System0Buffers[BufferID]); System0Buffers[BufferID].Data = (void *)psDroid; sBFormInit.pUserData = &System0Buffers[BufferID]; sBFormInit.pDisplay = intDisplayTransportButton; if (!widgAddForm(psWScreen, &sBFormInit)) { return false; } //add bar to indicate stare of repair sBarInit.size = (UWORD) PERCENT(psDroid->body, psDroid->originalBody); if (sBarInit.size > 100) { sBarInit.size = 100; } sBarInit.formID = sBFormInit.id; //sBarInit.iRange = TBAR_MAX_REPAIR; if (!widgAddBarGraph(psWScreen, &sBarInit)) { return false; } /* Update the init struct for the next button */ sBFormInit.id += 1; ASSERT(sBFormInit.id < IDTRANS_DROIDEND, "Too many Droids Built buttons"); sBFormInit.x += OBJ_BUTWIDTH + OBJ_GAP; if (sBFormInit.x + OBJ_BUTWIDTH + OBJ_GAP > TRANSDROID_TABWIDTH) { sBFormInit.x = OBJ_STARTX; sBFormInit.y += OBJ_BUTHEIGHT + OBJ_GAP; } if (sBFormInit.y + OBJ_BUTHEIGHT + OBJ_GAP > TRANSDROID_TABHEIGHT) { sBFormInit.y = AVAIL_STARTY; sBFormInit.majorID += 1; } //and bar sBarInit.id += 1; } } //reset which tab we were on if (objMajor > (UWORD)(sFormInit.numMajor - 1)) { //set to last if have lost a tab widgSetTabs(psWScreen, IDTRANS_DROIDTAB, (UWORD)(sFormInit.numMajor - 1), objMinor); } else { //set to same tab we were on previously widgSetTabs(psWScreen, IDTRANS_DROIDTAB, objMajor, objMinor); } return true; }
// Add the main Transporter Contents Interface bool intAddTransporterContents(void) { bool Animate = true; // Is the form already up? if (widgGetFromID(psWScreen, IDTRANS_CONTENTFORM) != NULL) { intRemoveTransContentNoAnim(); Animate = false; } if (intIsRefreshing()) { Animate = false; } W_FORMINIT sFormInit; sFormInit.formID = 0; sFormInit.id = IDTRANS_CONTENTFORM; sFormInit.style = WFORM_PLAIN; sFormInit.x = (SWORD)TRANSCONT_X; sFormInit.y = (SWORD)TRANSCONT_Y; sFormInit.width = TRANSCONT_WIDTH; sFormInit.height = TRANSCONT_HEIGHT; // If the window was closed then do open animation. if (Animate) { sFormInit.pDisplay = intOpenPlainForm; sFormInit.disableChildren = true; } else { // otherwise just recreate it. sFormInit.pDisplay = intDisplayPlainForm; } if (!widgAddForm(psWScreen, &sFormInit)) { return false; } /* Add the close button */ W_BUTINIT sButInit; sButInit.formID = IDTRANS_CONTENTFORM; sButInit.id = IDTRANS_CONTCLOSE; sButInit.x = STAT_WIDTH - CLOSE_WIDTH; sButInit.y = 0; sButInit.width = CLOSE_WIDTH; sButInit.height = CLOSE_HEIGHT; sButInit.pTip = _("Close"); sButInit.pDisplay = intDisplayImageHilight; sButInit.UserData = PACKDWORD_TRI(0, IMAGE_CLOSEHILIGHT , IMAGE_CLOSE); if (!widgAddButton(psWScreen, &sButInit)) { return false; } if (bMultiPlayer) { //add the capacity label W_LABINIT sLabInit; sLabInit.formID = IDTRANS_CONTENTFORM; sLabInit.id = IDTRANS_CAPACITY; sLabInit.x = (SWORD)sButInit.x - 40; sLabInit.y = 0; sLabInit.width = 16; sLabInit.height = 16; sLabInit.pText = "00/10"; sLabInit.pCallback = intUpdateTransCapacity; if (!widgAddLabel(psWScreen, &sLabInit)) { return false; } } //add the Launch button if on a mission if (onMission) { W_FORMINIT sButFInit; sButFInit.formID = IDTRANS_CONTENTFORM; sButFInit.id = IDTRANS_LAUNCH; sButFInit.style = WFORM_CLICKABLE | WFORM_NOCLICKMOVE; sButFInit.x = OBJ_STARTX; sButFInit.y = (UWORD)(STAT_SLDY - 1); sButFInit.width = iV_GetImageWidth(IntImages, IMAGE_LAUNCHUP); sButFInit.height = iV_GetImageHeight(IntImages, IMAGE_LAUNCHUP); sButFInit.pTip = _("Launch Transport"); //sButInit.pText = "Launch"; sButFInit.pDisplay = intDisplayImageHilight; sButFInit.UserData = PACKDWORD_TRI(0, IMAGE_LAUNCHDOWN, IMAGE_LAUNCHUP); if (!widgAddForm(psWScreen, &sButFInit)) { return false; } } if (!intAddTransContentsForm()) { return false; } return true; }
/*Add the Transporter Interface*/ static bool _intAddTransporter(DROID *psSelected, bool offWorld) { bool Animate = true; onMission = offWorld; psCurrTransporter = psSelected; /*if transporter has died - close the interface - this can only happen in multiPlayer where the transporter can be killed*/ if (bMultiPlayer) { if (psCurrTransporter && isDead((BASE_OBJECT *)psCurrTransporter)) { intRemoveTransNoAnim(); return true; } } // Add the main Transporter form // Is the form already up? if (widgGetFromID(psWScreen, IDTRANS_FORM) != NULL) { intRemoveTransNoAnim(); Animate = false; } if (intIsRefreshing()) { Animate = false; } W_FORMINIT sFormInit; sFormInit.formID = 0; sFormInit.id = IDTRANS_FORM; sFormInit.style = WFORM_PLAIN; sFormInit.x = (SWORD)TRANS_X; sFormInit.y = (SWORD)TRANS_Y; sFormInit.width = TRANS_WIDTH; sFormInit.height = TRANS_HEIGHT; // If the window was closed then do open animation. if (Animate) { sFormInit.pDisplay = intOpenPlainForm; sFormInit.disableChildren = true; } else { // otherwise just recreate it. sFormInit.pDisplay = intDisplayPlainForm; } if (!widgAddForm(psWScreen, &sFormInit)) { return false; } /* Add the close button */ W_BUTINIT sButInit; sButInit.formID = IDTRANS_FORM; sButInit.id = IDTRANS_CLOSE; sButInit.x = TRANS_WIDTH - CLOSE_WIDTH; sButInit.y = 0; sButInit.width = CLOSE_WIDTH; sButInit.height = CLOSE_HEIGHT; sButInit.pTip = _("Close"); sButInit.pDisplay = intDisplayImageHilight; sButInit.UserData = PACKDWORD_TRI(0, IMAGE_CLOSEHILIGHT , IMAGE_CLOSE); if (!widgAddButton(psWScreen, &sButInit)) { return false; } if (!intAddTransButtonForm()) { return false; } // Add the Transporter Contents form (and buttons) if (!intAddTransporterContents()) { return false; } //if on a mission - add the Droids back at home base form if (onMission) { if (!intAddDroidsAvailForm()) { return false; } } return true; }
/*Add the 3D world view for the particular message (only research nmessages now) */ BOOL intAddMessageView(MESSAGE * psMessage) { BOOL Animate = true; RESEARCH *psResearch; // Is the form already up? if(widgGetFromID(psWScreen,IDINTMAP_MSGVIEW) != NULL) { intRemoveMessageView(false); Animate = false; } if (MultiMenuUp) { intCloseMultiMenuNoAnim(); } /* Add the base form */ W_FORMINIT sFormInit; sFormInit.formID = 0; sFormInit.id = IDINTMAP_MSGVIEW; sFormInit.style = WFORM_PLAIN; //size and position depends on the type of message - ONLY RESEARCH now sFormInit.width = INTMAP_RESEARCHWIDTH; sFormInit.height = INTMAP_RESEARCHHEIGHT; sFormInit.x = (SWORD)INTMAP_RESEARCHX; sFormInit.y = (SWORD)INTMAP_RESEARCHY; // If the window was closed then do open animation. if(Animate) { sFormInit.pDisplay = intOpenPlainForm; sFormInit.disableChildren = true; } else { // otherwise just display it. sFormInit.pDisplay = intDisplayPlainForm; } if (!widgAddForm(psWScreen, &sFormInit)) { return false; } /* Add the close box */ W_BUTINIT sButInit; sButInit.formID = IDINTMAP_MSGVIEW; sButInit.id = IDINTMAP_CLOSE; sButInit.x = (SWORD)(sFormInit.width - OPT_GAP - CLOSE_SIZE); sButInit.y = OPT_GAP; sButInit.width = CLOSE_SIZE; sButInit.height = CLOSE_SIZE; sButInit.pTip = _("Close"); sButInit.pDisplay = intDisplayImageHilight; sButInit.UserData = PACKDWORD_TRI(0,IMAGE_CLOSEHILIGHT , IMAGE_CLOSE); if (!widgAddButton(psWScreen, &sButInit)) { return false; } if (psMessage->type != MSG_RESEARCH && ((VIEWDATA*)psMessage->pViewData)->type == VIEW_RPL) { VIEW_REPLAY *psViewReplay; size_t i, cur_seq, cur_seqpage; psViewReplay = (VIEW_REPLAY *)((VIEWDATA *)psMessage->pViewData)->pData; /* Add a big tabbed text box for the subtitle text */ sFormInit = W_FORMINIT(); sFormInit.id = IDINTMAP_SEQTEXT; sFormInit.formID = IDINTMAP_MSGVIEW; sFormInit.style = WFORM_TABBED; sFormInit.x = INTMAP_SEQTEXTX; sFormInit.y = INTMAP_SEQTEXTY; sFormInit.width = INTMAP_SEQTEXTWIDTH; sFormInit.height = INTMAP_SEQTEXTHEIGHT; sFormInit.majorPos = WFORM_TABBOTTOM; sFormInit.minorPos = WFORM_TABNONE; sFormInit.majorSize = OBJ_TABWIDTH; sFormInit.majorOffset = OBJ_TABOFFSET; sFormInit.tabVertOffset = (OBJ_TABHEIGHT/2); sFormInit.tabMajorThickness = OBJ_TABHEIGHT; sFormInit.numMajor = 0; cur_seq = cur_seqpage = 0; do { sFormInit.aNumMinors[sFormInit.numMajor] = 1; sFormInit.numMajor++; } while (!intDisplaySeqTextViewPage(psViewReplay, 0, 0, sFormInit.width, sFormInit.height, false, &cur_seq, &cur_seqpage)); sFormInit.pUserData = &StandardTab; sFormInit.pTabDisplay = intDisplayTab; if (!widgAddForm(psWScreen, &sFormInit)) { return false; } W_FORMINIT sTabForm; sTabForm.formID = IDINTMAP_SEQTEXT; sTabForm.id = IDINTMAP_SEQTEXTSTART; sTabForm.majorID = 0; sTabForm.minorID = 0; sTabForm.style = WFORM_PLAIN; sTabForm.x = INTMAP_SEQTEXTTABX; sTabForm.y = INTMAP_SEQTEXTTABY; sTabForm.width = INTMAP_SEQTEXTTABWIDTH; sTabForm.height = INTMAP_SEQTEXTTABHEIGHT; sTabForm.pDisplay = intDisplaySeqTextView; sTabForm.pUserData = psViewReplay; for (i = 0; i < sFormInit.numMajor; i++) { sTabForm.id = IDINTMAP_SEQTEXTSTART + i; sTabForm.majorID = i; if (!widgAddForm(psWScreen, &sTabForm)) { return false; } } return true; } /*add the Label for the title box*/ W_LABINIT sLabInit; sLabInit.id = IDINTMAP_TITLELABEL; sLabInit.formID = IDINTMAP_MSGVIEW; sLabInit.x = INTMAP_TITLEX + TEXT_XINDENT; sLabInit.y = INTMAP_TITLEY + TEXT_YINDENT; sLabInit.width = INTMAP_TITLEWIDTH; sLabInit.height = INTMAP_TITLEHEIGHT; //print research name in title bar ASSERT( psMessage->type != MSG_PROXIMITY, "intAddMessageView:Invalid message type for research" ); psResearch = getResearchForMsg((VIEWDATA *)psMessage->pViewData); ASSERT( psResearch!=NULL,"Research not found" ); //sLabInit.pText=psResearch->pName; sLabInit.pText = getStatName(psResearch); sLabInit.FontID = font_regular; if (!widgAddLabel(psWScreen, &sLabInit)) { return false; } /*Add the PIE box*/ sFormInit = W_FORMINIT(); sFormInit.formID = IDINTMAP_MSGVIEW; sFormInit.id = IDINITMAP_PIEVIEW; sFormInit.style = WFORM_PLAIN; sFormInit.x = INTMAP_PIEX; sFormInit.y = INTMAP_PIEY; sFormInit.width = INTMAP_PIEWIDTH; sFormInit.height = INTMAP_PIEHEIGHT; sFormInit.pDisplay = intDisplayPIEView; sFormInit.pUserData = psMessage; if (!widgAddForm(psWScreen, &sFormInit)) { return false; } #ifndef NO_VIDEO /*Add the Flic box */ sFormInit = W_FORMINIT(); sFormInit.formID = IDINTMAP_MSGVIEW; sFormInit.id = IDINTMAP_FLICVIEW; sFormInit.style = WFORM_PLAIN; sFormInit.x = INTMAP_FLICX; sFormInit.y = INTMAP_FLICY; sFormInit.width = INTMAP_FLICWIDTH; sFormInit.height = INTMAP_FLICHEIGHT; sFormInit.pDisplay = intDisplayFLICView; sFormInit.pUserData = psMessage; if (!widgAddForm(psWScreen, &sFormInit)) { return false; } #endif /*Add the text box*/ sFormInit = W_FORMINIT(); sFormInit.formID = IDINTMAP_MSGVIEW; sFormInit.id = IDINTMAP_TEXTVIEW; sFormInit.style = WFORM_PLAIN; sFormInit.x = INTMAP_TEXTX; sFormInit.y = INTMAP_TEXTY; sFormInit.width = INTMAP_TEXTWIDTH; sFormInit.height = INTMAP_TEXTHEIGHT; sFormInit.pDisplay = intDisplayTEXTView; sFormInit.pUserData = psMessage; if (!widgAddForm(psWScreen, &sFormInit)) { return false; } return true; }
/** Searches in the given search directory for files ending with the * given extension. Then will create a window with buttons for each * found file. * \param searchDir the directory to search in * \param fileExtension the extension files should end with, if the * extension has a dot (.) then this dot _must_ be present as * the first char in this parameter * \param mode (purpose unknown) * \param numPlayers (purpose unknown) */ void addMultiRequest(const char* searchDir, const char* fileExtension, UDWORD mode, UBYTE mapCam, UBYTE numPlayers) { W_FORMINIT sFormInit; W_BUTINIT sButInit; UDWORD players; char** fileList; char** currFile; const unsigned int extensionLength = strlen(fileExtension); const unsigned int buttonsX = (mode == MULTIOP_MAP) ? 22 : 17; unsigned int numButtons, count, butPerForm, i; static char tips[NBTIPS][MAX_STR_LENGTH]; context = mode; if(mode == MULTIOP_MAP) { // only save these when they select MAP button current_tech = mapCam; current_numplayers = numPlayers; } fileList = PHYSFS_enumerateFiles(searchDir); if (!fileList) { debug(LOG_FATAL, "addMultiRequest: Out of memory"); abort(); return; } // Count number of required buttons numButtons = 0; for (currFile = fileList; *currFile != NULL; ++currFile) { const unsigned int fileNameLength = strlen(*currFile); // Check to see if this file matches the given extension if (fileNameLength > extensionLength && strcmp(&(*currFile)[fileNameLength - extensionLength], fileExtension) == 0) ++numButtons; } if(mode == MULTIOP_MAP) // if its a map, also look in the predone stuff. { char* map; if ((map = enumerateMultiMaps(&players, true, mapCam, numPlayers))) { free(map); numButtons++; while ((map = enumerateMultiMaps(&players, false, mapCam, numPlayers))) { free(map); numButtons++; } } } psRScreen = widgCreateScreen(); ///< move this to intinit or somewhere like that.. (close too.) widgSetTipFont(psRScreen,font_regular); /* Calculate how many buttons will go on a single form */ butPerForm = ((M_REQUEST_W - 0 - 4) / (R_BUT_W +4)) * ((M_REQUEST_H - 0- 4) / (R_BUT_H+ 4)); /* add a form to place the tabbed form on */ memset(&sFormInit, 0, sizeof(W_FORMINIT)); sFormInit.formID = 0; sFormInit.id = M_REQUEST; sFormInit.style = WFORM_PLAIN; sFormInit.x = (SWORD)(M_REQUEST_X+D_W); sFormInit.y = (SWORD)(M_REQUEST_Y+D_H); sFormInit.width = M_REQUEST_W; sFormInit.height = M_REQUEST_H; sFormInit.disableChildren = true; sFormInit.pDisplay = intOpenPlainForm; widgAddForm(psRScreen, &sFormInit); /* Add the tabs */ memset(&sFormInit, 0, sizeof(W_FORMINIT)); sFormInit.formID = M_REQUEST; sFormInit.id = M_REQUEST_TAB; sFormInit.style = WFORM_TABBED; sFormInit.x = 2; sFormInit.y = 2; sFormInit.width = M_REQUEST_W; sFormInit.height = M_REQUEST_H-4; sFormInit.numMajor = numForms(numButtons, butPerForm); sFormInit.majorPos = WFORM_TABTOP; sFormInit.minorPos = WFORM_TABNONE; sFormInit.majorSize = OBJ_TABWIDTH+2; sFormInit.majorOffset = OBJ_TABOFFSET; sFormInit.tabVertOffset = (OBJ_TABHEIGHT/2); sFormInit.tabMajorThickness = OBJ_TABHEIGHT; sFormInit.pUserData = &StandardTab; sFormInit.pTabDisplay = intDisplayTab; // TABFIXME: // This appears to be the map pick screen, when we have lots of maps // this will need to change. if (sFormInit.numMajor > MAX_TAB_STD_SHOWN) { ASSERT(sFormInit.numMajor < MAX_TAB_SMALL_SHOWN,"Too many maps! Need scroll tabs here."); sFormInit.pUserData = &SmallTab; sFormInit.majorSize /= 2; } for (i = 0; i < sFormInit.numMajor; ++i) { sFormInit.aNumMinors[i] = 2; } widgAddForm(psRScreen, &sFormInit); // Add the close button. memset(&sButInit, 0, sizeof(W_BUTINIT)); sButInit.formID = M_REQUEST; sButInit.id = M_REQUEST_CLOSE; sButInit.style = WBUT_PLAIN; sButInit.x = M_REQUEST_W - CLOSE_WIDTH - 3; sButInit.y = 0; sButInit.width = CLOSE_WIDTH; sButInit.height = CLOSE_HEIGHT; sButInit.pTip = _("Close"); sButInit.FontID = font_regular; sButInit.pDisplay = intDisplayImageHilight; sButInit.UserData = PACKDWORD_TRI(0,IMAGE_CLOSEHILIGHT , IMAGE_CLOSE); widgAddButton(psRScreen, &sButInit); /* Put the buttons on it *//* Set up the button struct */ memset(&sButInit, 0, sizeof(W_BUTINIT)); sButInit.formID = M_REQUEST_TAB; sButInit.id = M_REQUEST_BUT; sButInit.style = WBUT_PLAIN; sButInit.x = buttonsX; sButInit.y = 4; sButInit.width = R_BUT_W; sButInit.height = R_BUT_H; sButInit.pUserData = NULL; sButInit.pDisplay = displayRequestOption; sButInit.FontID = font_regular; for (currFile = fileList, count = 0; *currFile != NULL && count < (butPerForm * 4); ++currFile) { const unsigned int tip_index = check_tip_index(sButInit.id - M_REQUEST_BUT); const unsigned int fileNameLength = strlen(*currFile); const unsigned int tipStringLength = fileNameLength - extensionLength; // Check to see if this file matches the given extension if (!(fileNameLength > extensionLength) || strcmp(&(*currFile)[fileNameLength - extensionLength], fileExtension) != 0) continue; // Set the tip and add the button // Copy all of the filename except for the extension into the tiptext string strlcpy(tips[tip_index], *currFile, MIN(tipStringLength + 1, sizeof(tips[tip_index]))); sButInit.pTip = tips[tip_index]; sButInit.pText = tips[tip_index]; if(mode == MULTIOP_MAP) // if its a map, set player flag. { const char* mapText; unsigned int mapTextLength; sButInit.UserData = (*currFile)[0] - '0'; if( (*currFile)[1] != 'c') { continue; } // Chop off description mapText = strrchr(*currFile, '-') + 1; if (mapText - 1 == NULL) continue; mapTextLength = tipStringLength - (mapText - *currFile); strlcpy(tips[tip_index], mapText, MIN(mapTextLength + 1, sizeof(tips[tip_index]))); } ++count; widgAddButton(psRScreen, &sButInit); /* Update the init struct for the next button */ sButInit.id += 1; sButInit.x = (SWORD)(sButInit.x + (R_BUT_W+ 4)); if (sButInit.x + R_BUT_W+ 2 > M_REQUEST_W) { sButInit.x = buttonsX; sButInit.y = (SWORD)(sButInit.y +R_BUT_H + 4); } if (sButInit.y +R_BUT_H + 4 > M_REQUEST_H) { sButInit.y = 4; sButInit.majorID += 1; } } // Make sure to return memory back to PhyscisFS PHYSFS_freeList(fileList); if(mode == MULTIOP_MAP) { char* mapName; if ((mapName = enumerateMultiMaps(&players, true, mapCam, numPlayers))) { do { unsigned int tip_index = check_tip_index(sButInit.id-M_REQUEST_BUT); // add number of players to string. sstrcpy(tips[tip_index], mapName); free(mapName); sButInit.pTip = tips[tip_index]; sButInit.pText = tips[tip_index]; sButInit.UserData = players; widgAddButton(psRScreen, &sButInit); sButInit.id += 1; sButInit.x = (SWORD)(sButInit.x + (R_BUT_W+ 4)); if (sButInit.x + R_BUT_W+ 2 > M_REQUEST_W) { sButInit.x = buttonsX; sButInit.y = (SWORD)(sButInit.y +R_BUT_H + 4); } if (sButInit.y +R_BUT_H + 4 > M_REQUEST_H) { sButInit.y = 4; sButInit.majorID += 1; } } while ((mapName = enumerateMultiMaps(&players, false, mapCam, numPlayers))); } } multiRequestUp = true; // if it's map select then add the cam style buttons. if(mode == MULTIOP_MAP) { memset(&sButInit, 0, sizeof(W_BUTINIT)); sButInit.formID = M_REQUEST; sButInit.id = M_REQUEST_C1; sButInit.style = WBUT_PLAIN; sButInit.x = 4; sButInit.y = 258; sButInit.width = 17; sButInit.height = 17; sButInit.UserData = 1; sButInit.FontID = font_regular; sButInit.pTip = _("Technology level 1"); sButInit.pDisplay = displayCamTypeBut; widgAddButton(psRScreen, &sButInit); sButInit.id = M_REQUEST_C2; sButInit.y += 22; sButInit.UserData = 2; sButInit.pTip = _("Technology level 2"); widgAddButton(psRScreen, &sButInit); sButInit.id = M_REQUEST_C3; sButInit.y += 22; sButInit.UserData = 3; sButInit.pTip = _("Technology level 3"); widgAddButton(psRScreen, &sButInit); sButInit.id = M_REQUEST_AP; sButInit.y = 17; sButInit.UserData = 0; sButInit.pTip = _("Any number of players"); sButInit.pDisplay = displayNumPlayersBut; widgAddButton(psRScreen, &sButInit); sButInit.id = M_REQUEST_2P; sButInit.y += 22; sButInit.UserData = 2; sButInit.pTip = _("2 players"); widgAddButton(psRScreen, &sButInit); sButInit.id = M_REQUEST_3P; sButInit.y += 22; sButInit.UserData = 3; sButInit.pTip = _("3 players"); widgAddButton(psRScreen, &sButInit); sButInit.id = M_REQUEST_4P; sButInit.y += 22; sButInit.UserData = 4; sButInit.pTip = _("4 players"); widgAddButton(psRScreen, &sButInit); sButInit.id = M_REQUEST_5P; sButInit.y += 22; sButInit.UserData = 5; sButInit.pTip = _("5 players"); widgAddButton(psRScreen, &sButInit); sButInit.id = M_REQUEST_6P; sButInit.y += 22; sButInit.UserData = 6; sButInit.pTip = _("6 players"); widgAddButton(psRScreen, &sButInit); sButInit.id = M_REQUEST_7P; sButInit.y += 22; sButInit.UserData = 7; sButInit.pTip = _("7 players"); widgAddButton(psRScreen, &sButInit); sButInit.id = M_REQUEST_8P; sButInit.y += 22; sButInit.UserData = 8; sButInit.pTip = _("8 players"); widgAddButton(psRScreen, &sButInit); } }
//**************************************************************************************** // Load menu/save menu? //***************************************************************************************** static BOOL _addLoadSave(BOOL bLoad, const char *sSearchPath, const char *sExtension, const char *title) { W_FORMINIT sFormInit; W_BUTINIT sButInit; W_LABINIT sLabInit; UDWORD slotCount; // removed hardcoded values! change with the defines above! -Q static char sSlotCaps[totalslots][totalslotspace]; static char sSlotTips[totalslots][totalslotspace]; char **i, **files; const char* checkExtension; mode = bLoad; debug(LOG_SAVE, "called (%d, %s, %s, %s)", bLoad, sSearchPath, sExtension, title); if ((bLoadSaveMode == LOAD_INGAME) || (bLoadSaveMode == SAVE_INGAME)) { if (!bMultiPlayer || (NetPlay.bComms ==0)) { gameTimeStop(); if(GetGameMode() == GS_NORMAL) { BOOL radOnScreen = radarOnScreen; // Only do this in main game. bRender3DOnly = true; radarOnScreen = false; displayWorld(); // Just display the 3d, no interface pie_UploadDisplayBuffer(); // Upload the current display back buffer into system memory. radarOnScreen = radOnScreen; bRender3DOnly = false; } setGamePauseStatus( true ); setGameUpdatePause(true); setScriptPause(true); setScrollPause(true); setConsolePause(true); } forceHidePowerBar(); intRemoveReticule(); } (void) PHYSFS_mkdir(sSearchPath); // just in case psRequestScreen = widgCreateScreen(); // init the screen widgSetTipFont(psRequestScreen,font_regular); /* add a form to place the tabbed form on */ memset(&sFormInit, 0, sizeof(W_FORMINIT)); sFormInit.formID = 0; //this adds the blue background, and the "box" behind the buttons -Q sFormInit.id = LOADSAVE_FORM; sFormInit.style = WFORM_PLAIN; sFormInit.x = (SWORD) LOADSAVE_X; sFormInit.y = (SWORD) LOADSAVE_Y; sFormInit.width = LOADSAVE_W; // we need the form to be long enough for all resolutions, so we take the total number of items * height // and * the gaps, add the banner, and finally, the fudge factor ;) sFormInit.height = (slotsInColumn * LOADENTRY_H + LOADSAVE_HGAP* slotsInColumn)+ LOADSAVE_BANNER_DEPTH+20; sFormInit.disableChildren = true; sFormInit.pDisplay = intOpenPlainForm; widgAddForm(psRequestScreen, &sFormInit); // Add Banner sFormInit.formID = LOADSAVE_FORM; sFormInit.id = LOADSAVE_BANNER; sFormInit.x = LOADSAVE_HGAP; sFormInit.y = LOADSAVE_VGAP; sFormInit.width = LOADSAVE_W-(2*LOADSAVE_HGAP); sFormInit.height = LOADSAVE_BANNER_DEPTH; sFormInit.disableChildren = false; sFormInit.pDisplay = displayLoadBanner; sFormInit.UserData = bLoad; widgAddForm(psRequestScreen, &sFormInit); // Add Banner Label memset(&sLabInit, 0, sizeof(W_LABINIT)); sLabInit.formID = LOADSAVE_BANNER; sLabInit.id = LOADSAVE_LABEL; sLabInit.style = WLAB_ALIGNCENTRE; sLabInit.x = 0; sLabInit.y = 3; sLabInit.width = LOADSAVE_W-(2*LOADSAVE_HGAP); //LOADSAVE_W; sLabInit.height = LOADSAVE_BANNER_DEPTH; //This looks right -Q sLabInit.pText = title; sLabInit.FontID = font_regular; widgAddLabel(psRequestScreen, &sLabInit); // add cancel. memset(&sButInit, 0, sizeof(W_BUTINIT)); sButInit.formID = LOADSAVE_BANNER; sButInit.x = 8; sButInit.y = 8; sButInit.width = iV_GetImageWidth(IntImages,IMAGE_NRUTER); sButInit.height = iV_GetImageHeight(IntImages,IMAGE_NRUTER); sButInit.UserData = PACKDWORD_TRI(0,IMAGE_NRUTER , IMAGE_NRUTER); sButInit.id = LOADSAVE_CANCEL; sButInit.style = WBUT_PLAIN; sButInit.pTip = _("Close"); sButInit.FontID = font_regular; sButInit.pDisplay = intDisplayImageHilight; widgAddButton(psRequestScreen, &sButInit); // add slots memset(&sButInit, 0, sizeof(W_BUTINIT)); sButInit.formID = LOADSAVE_FORM; sButInit.style = WBUT_PLAIN; sButInit.width = LOADENTRY_W; sButInit.height = LOADENTRY_H; sButInit.pDisplay = displayLoadSlot; sButInit.FontID = font_regular; for(slotCount = 0; slotCount< totalslots; slotCount++) { sButInit.id = slotCount+LOADENTRY_START; if(slotCount < slotsInColumn) { sButInit.x = 22 + LOADSAVE_HGAP; sButInit.y = (SWORD)((LOADSAVE_BANNER_DEPTH +(2*LOADSAVE_VGAP)) + ( slotCount*(LOADSAVE_VGAP+LOADENTRY_H))); } else if (slotCount >= slotsInColumn && (slotCount < (slotsInColumn *2))) { sButInit.x = 22 + (2*LOADSAVE_HGAP + LOADENTRY_W); sButInit.y = (SWORD)((LOADSAVE_BANNER_DEPTH +(2* LOADSAVE_VGAP)) + ( (slotCount % slotsInColumn)*(LOADSAVE_VGAP+LOADENTRY_H))); } else { sButInit.x = 22 + (3*LOADSAVE_HGAP + (2*LOADENTRY_W)); sButInit.y = (SWORD)((LOADSAVE_BANNER_DEPTH +(2* LOADSAVE_VGAP)) + ( (slotCount % slotsInColumn)*(LOADSAVE_VGAP+LOADENTRY_H))); } widgAddButton(psRequestScreen, &sButInit); } // fill slots. slotCount = 0; sstrcpy(sPath, sSearchPath); // setup locals. sstrcpy(sExt, sExtension); debug(LOG_SAVE, "Searching \"%s\" for savegames", sSearchPath); // Check for an extension like ".ext", not "ext" sasprintf((char**)&checkExtension, ".%s", sExtension); // add savegame filenames minus extensions to buttons files = PHYSFS_enumerateFiles(sSearchPath); for (i = files; *i != NULL; ++i) { W_BUTTON *button; char savefile[256]; time_t savetime; // See if this filename contains the extension we're looking for if (!strstr(*i, checkExtension)) { // If it doesn't, move on to the next filename continue; } button = (W_BUTTON*)widgGetFromID(psRequestScreen, LOADENTRY_START + slotCount); debug(LOG_SAVE, "We found [%s]", *i); /* Figure save-time */ snprintf(savefile, sizeof(savefile), "%s/%s", sSearchPath, *i); savetime = PHYSFS_getLastModTime(savefile); sstrcpy(sSlotTips[slotCount], ctime(&savetime)); /* Set the button-text */ (*i)[strlen(*i) - 4] = '\0'; // remove .gam extension sstrcpy(sSlotCaps[slotCount], *i); //store it! /* Add button */ button->pTip = sSlotTips[slotCount]; button->pText = sSlotCaps[slotCount]; slotCount++; // goto next but... if (slotCount == totalslots) { break; } } PHYSFS_freeList(files); bLoadSaveUp = true; return true; }
/*This is used to display the transporter button and capacity when at the home base ONLY*/ bool intAddTransporterLaunch(DROID *psDroid) { UDWORD capacity; DROID *psCurr, *psNext; if (bMultiPlayer) { return true; } //do this first so that if the interface is already up it syncs with this transporter //set up the static transporter psCurrTransporter = psDroid; //check the button is not already up if (widgGetFromID(psWScreen, IDTRANS_LAUNCH) != NULL) { return true; } W_FORMINIT sButInit; //needs to be a clickable form now sButInit.formID = 0; sButInit.id = IDTRANS_LAUNCH; sButInit.style = WFORM_CLICKABLE | WFORM_NOCLICKMOVE; sButInit.x = RET_X; sButInit.y = (SWORD)TIMER_Y; sButInit.width = (UWORD)(10 + iV_GetImageWidth(IntImages, IMAGE_LAUNCHUP)); sButInit.height = iV_GetImageHeight(IntImages, IMAGE_LAUNCHUP); sButInit.pTip = _("Launch Transport"); sButInit.pDisplay = intDisplayImageHilight; sButInit.UserData = PACKDWORD_TRI(0, IMAGE_LAUNCHDOWN, IMAGE_LAUNCHUP); if (!widgAddForm(psWScreen, &sButInit)) { return false; } //add the capacity label W_LABINIT sLabInit; sLabInit.formID = IDTRANS_LAUNCH; sLabInit.id = IDTRANS_CAPACITY; sLabInit.x = (SWORD)(sButInit.x + 20); sLabInit.y = 0; sLabInit.width = 16; sLabInit.height = 16; sLabInit.pText = "00/10"; sLabInit.pCallback = intUpdateTransCapacity; if (!widgAddLabel(psWScreen, &sLabInit)) { return false; } //when full flash the transporter button if (psCurrTransporter && psCurrTransporter->psGroup) { capacity = TRANSPORTER_CAPACITY; for (psCurr = psCurrTransporter->psGroup->psList; psCurr != NULL; psCurr = psNext) { psNext = psCurr->psGrpNext; if (psCurr != psCurrTransporter) { capacity -= transporterSpaceRequired(psCurr); } } if (capacity <= 0) { flashMissionButton(IDTRANS_LAUNCH); } } return true; }
// //////////////////////////////////////////////////////////////////////////// bool addLoadSave(LOADSAVE_MODE savemode, const char *title) { bool bLoad = true; char NewSaveGamePath[PATH_MAX] = {'\0'}; bLoadSaveMode = savemode; UDWORD slotCount; static char sSlotCaps[totalslots][totalslotspace]; static char sSlotTips[totalslots][totalslotspace]; char **i, **files; switch(savemode) { case LOAD_FRONTEND_MISSION: case LOAD_INGAME_MISSION: case LOAD_MISSIONEND: ssprintf(NewSaveGamePath, "%s%s/", SaveGamePath, "campaign"); break; case LOAD_FRONTEND_SKIRMISH: case LOAD_INGAME_SKIRMISH: ssprintf(NewSaveGamePath, "%s%s/", SaveGamePath, "skirmish"); break; case SAVE_MISSIONEND: case SAVE_INGAME_MISSION: ssprintf(NewSaveGamePath, "%s%s/", SaveGamePath, "campaign"); bLoad = false; break; case SAVE_INGAME_SKIRMISH: ssprintf(NewSaveGamePath, "%s%s/", SaveGamePath, "skirmish"); bLoad = false; break; default: ASSERT("Invalid load/save mode!", "Invalid load/save mode!"); ssprintf(NewSaveGamePath, "%s%s/", SaveGamePath, "campaign"); break; } mode = bLoad; debug(LOG_SAVE, "called (%d, %s)", bLoad, title); if ((bLoadSaveMode == LOAD_INGAME_MISSION) || (bLoadSaveMode == SAVE_INGAME_MISSION) || (bLoadSaveMode == LOAD_INGAME_SKIRMISH) || (bLoadSaveMode == SAVE_INGAME_SKIRMISH)) { if (!bMultiPlayer || (NetPlay.bComms ==0)) { gameTimeStop(); if(GetGameMode() == GS_NORMAL) { bool radOnScreen = radarOnScreen; // Only do this in main game. bRender3DOnly = true; radarOnScreen = false; displayWorld(); // Just display the 3d, no interface radarOnScreen = radOnScreen; bRender3DOnly = false; } setGamePauseStatus( true ); setGameUpdatePause(true); setScriptPause(true); setScrollPause(true); setConsolePause(true); } forceHidePowerBar(); intRemoveReticule(); } psRequestScreen = new W_SCREEN; WIDGET *parent = psRequestScreen->psForm; /* add a form to place the tabbed form on */ // we need the form to be long enough for all resolutions, so we take the total number of items * height // and * the gaps, add the banner, and finally, the fudge factor ;) IntFormAnimated *loadSaveForm = new IntFormAnimated(parent); loadSaveForm->id = LOADSAVE_FORM; loadSaveForm->setGeometry(LOADSAVE_X, LOADSAVE_Y, LOADSAVE_W, slotsInColumn*(LOADENTRY_H + LOADSAVE_HGAP) + LOADSAVE_BANNER_DEPTH + 20); // Add Banner W_FORMINIT sFormInit; sFormInit.formID = LOADSAVE_FORM; sFormInit.id = LOADSAVE_BANNER; sFormInit.x = LOADSAVE_HGAP; sFormInit.y = LOADSAVE_VGAP; sFormInit.width = LOADSAVE_W-(2*LOADSAVE_HGAP); sFormInit.height = LOADSAVE_BANNER_DEPTH; sFormInit.pDisplay = displayLoadBanner; sFormInit.UserData = bLoad; widgAddForm(psRequestScreen, &sFormInit); // Add Banner Label W_LABINIT sLabInit; sLabInit.formID = LOADSAVE_BANNER; sLabInit.FontID = font_large; sLabInit.id = LOADSAVE_LABEL; sLabInit.style = WLAB_ALIGNCENTRE; sLabInit.x = 0; sLabInit.y = 0; sLabInit.width = LOADSAVE_W-(2*LOADSAVE_HGAP); //LOADSAVE_W; sLabInit.height = LOADSAVE_BANNER_DEPTH; //This looks right -Q sLabInit.pText = title; widgAddLabel(psRequestScreen, &sLabInit); // add cancel. W_BUTINIT sButInit; sButInit.formID = LOADSAVE_BANNER; sButInit.x = 8; sButInit.y = 10; sButInit.width = iV_GetImageWidth(IntImages,IMAGE_NRUTER); sButInit.height = iV_GetImageHeight(IntImages,IMAGE_NRUTER); sButInit.UserData = PACKDWORD_TRI(0,IMAGE_NRUTER , IMAGE_NRUTER); sButInit.id = LOADSAVE_CANCEL; sButInit.style = WBUT_PLAIN; sButInit.pTip = _("Close"); sButInit.pDisplay = intDisplayImageHilight; widgAddButton(psRequestScreen, &sButInit); // add slots sButInit = W_BUTINIT(); sButInit.formID = LOADSAVE_FORM; sButInit.style = WBUT_PLAIN; sButInit.width = LOADENTRY_W; sButInit.height = LOADENTRY_H; sButInit.pDisplay = displayLoadSlot; for(slotCount = 0; slotCount< totalslots; slotCount++) { sButInit.id = slotCount+LOADENTRY_START; if(slotCount < slotsInColumn) { sButInit.x = 22 + LOADSAVE_HGAP; sButInit.y = (SWORD)((LOADSAVE_BANNER_DEPTH +(2*LOADSAVE_VGAP)) + ( slotCount*(LOADSAVE_VGAP+LOADENTRY_H))); } else if (slotCount >= slotsInColumn && (slotCount < (slotsInColumn *2))) { sButInit.x = 22 + (2*LOADSAVE_HGAP + LOADENTRY_W); sButInit.y = (SWORD)((LOADSAVE_BANNER_DEPTH +(2* LOADSAVE_VGAP)) + ( (slotCount % slotsInColumn)*(LOADSAVE_VGAP+LOADENTRY_H))); } else { sButInit.x = 22 + (3*LOADSAVE_HGAP + (2*LOADENTRY_W)); sButInit.y = (SWORD)((LOADSAVE_BANNER_DEPTH +(2* LOADSAVE_VGAP)) + ( (slotCount % slotsInColumn)*(LOADSAVE_VGAP+LOADENTRY_H))); } widgAddButton(psRequestScreen, &sButInit); } // fill slots. slotCount = 0; debug(LOG_SAVE, "Searching \"%s\" for savegames", NewSaveGamePath); // add savegame filenames minus extensions to buttons files = PHYSFS_enumerateFiles(NewSaveGamePath); for (i = files; *i != NULL; ++i) { W_BUTTON *button; char savefile[256]; time_t savetime; struct tm *timeinfo; // See if this filename contains the extension we're looking for if (!strstr(*i, sExt)) { // If it doesn't, move on to the next filename continue; } button = (W_BUTTON*)widgGetFromID(psRequestScreen, LOADENTRY_START + slotCount); debug(LOG_SAVE, "We found [%s]", *i); /* Figure save-time */ snprintf(savefile, sizeof(savefile), "%s/%s", NewSaveGamePath, *i); savetime = PHYSFS_getLastModTime(savefile); timeinfo = localtime(&savetime); strftime(sSlotTips[slotCount], sizeof(sSlotTips[slotCount]), "%x %X", timeinfo); /* Set the button-text */ (*i)[strlen(*i) - 4] = '\0'; // remove .gam extension sstrcpy(sSlotCaps[slotCount], *i); //store it! /* Add button */ button->pTip = sSlotTips[slotCount]; button->pText = sSlotCaps[slotCount]; slotCount++; // goto next but... if (slotCount == totalslots) { break; } } PHYSFS_freeList(files); bLoadSaveUp = true; return true; }
/* Add the Droids back at home form */ bool intAddDroidsAvailForm(void) { // Is the form already up? bool Animate = true; if (widgGetFromID(psWScreen, IDTRANS_DROIDS) != NULL) { intRemoveTransDroidsAvailNoAnim(); Animate = false; } if (intIsRefreshing()) { Animate = false; } WIDGET *parent = psWScreen->psForm; /* Add the droids available form */ IntFormAnimated *transDroids = new IntFormAnimated(parent, Animate); // Do not animate the opening, if the window was already open. transDroids->id = IDTRANS_DROIDS; transDroids->setGeometry(TRANSDROID_X, TRANSDROID_Y, TRANSDROID_WIDTH, TRANSDROID_HEIGHT); /* Add the close button */ W_BUTINIT sButInit; sButInit.formID = IDTRANS_DROIDS; sButInit.id = IDTRANS_DROIDCLOSE; sButInit.x = TRANSDROID_WIDTH - CLOSE_WIDTH; sButInit.y = 0; sButInit.width = CLOSE_WIDTH; sButInit.height = CLOSE_HEIGHT; sButInit.pTip = _("Close"); sButInit.pDisplay = intDisplayImageHilight; sButInit.UserData = PACKDWORD_TRI(0, IMAGE_CLOSEHILIGHT , IMAGE_CLOSE); if (!widgAddButton(psWScreen, &sButInit)) { return false; } //now add the tabbed droids available form IntListTabWidget *droidList = new IntListTabWidget(transDroids); droidList->id = IDTRANS_DROIDTAB; droidList->setChildSize(OBJ_BUTWIDTH, OBJ_BUTHEIGHT); droidList->setChildSpacing(OBJ_GAP, OBJ_GAP); int droidListWidth = OBJ_BUTWIDTH*2 + OBJ_GAP; droidList->setGeometry((TRANSDROID_WIDTH - droidListWidth)/2, AVAIL_STARTY + 15, droidListWidth, TRANSDROID_HEIGHT - (AVAIL_STARTY + 15)); /* Add the droids available buttons */ int nextButtonId = IDTRANS_DROIDSTART; /* Add the state of repair bar for each droid*/ W_BARINIT sBarInit; sBarInit.id = IDTRANS_REPAIRBARSTART; sBarInit.x = STAT_TIMEBARX; sBarInit.y = STAT_TIMEBARY; sBarInit.width = STAT_PROGBARWIDTH; sBarInit.height = STAT_PROGBARHEIGHT; sBarInit.size = 50; sBarInit.sCol = WZCOL_ACTION_PROGRESS_BAR_MAJOR; sBarInit.sMinorCol = WZCOL_ACTION_PROGRESS_BAR_MINOR; //add droids built before the mission for (DROID *psDroid = mission.apsDroidLists[selectedPlayer]; psDroid != nullptr; psDroid = psDroid->psNext) { //stop adding the buttons once IDTRANS_DROIDEND has been reached if (nextButtonId == IDTRANS_DROIDEND) { break; } //don't add Transporter Droids! if ((psDroid->droidType != DROID_TRANSPORTER && psDroid->droidType != DROID_SUPERTRANSPORTER)) { /* Set the tip and add the button */ IntTransportButton *button = new IntTransportButton(droidList); button->id = nextButtonId; button->setTip(droidGetName(psDroid)); button->setObject(psDroid); droidList->addWidgetToLayout(button); //add bar to indicate stare of repair sBarInit.size = (UWORD) PERCENT(psDroid->body, psDroid->originalBody); if (sBarInit.size > 100) { sBarInit.size = 100; } sBarInit.formID = nextButtonId; //sBarInit.iRange = TBAR_MAX_REPAIR; if (!widgAddBarGraph(psWScreen, &sBarInit)) { return false; } /* Update the init struct for the next button */ ++nextButtonId; ASSERT(nextButtonId < IDTRANS_DROIDEND, "Too many Droids Built buttons"); //and bar sBarInit.id += 1; } } //reset which tab we were on droidList->setCurrentPage(objMajor); return true; }
//**************************************************************************************** // Challenge menu //***************************************************************************************** bool addChallenges() { char sPath[PATH_MAX]; const char *sSearchPath = "challenges"; UDWORD slotCount; static char sSlotCaps[totalslots][totalslotspace]; static char sSlotTips[totalslots][totalslotspace]; static char sSlotFile[totalslots][totalslotspace]; char **i, **files; (void) PHYSFS_mkdir(sSearchPath); // just in case psRequestScreen = widgCreateScreen(); // init the screen widgSetTipFont(psRequestScreen, font_regular); /* add a form to place the tabbed form on */ W_FORMINIT sFormInit; sFormInit.formID = 0; //this adds the blue background, and the "box" behind the buttons -Q sFormInit.id = CHALLENGE_FORM; sFormInit.style = WFORM_PLAIN; sFormInit.x = (SWORD) CHALLENGE_X; sFormInit.y = (SWORD) CHALLENGE_Y; sFormInit.width = CHALLENGE_W; // we need the form to be long enough for all resolutions, so we take the total number of items * height // and * the gaps, add the banner, and finally, the fudge factor ;) sFormInit.height = (slotsInColumn * CHALLENGE_ENTRY_H + CHALLENGE_HGAP * slotsInColumn) + CHALLENGE_BANNER_DEPTH + 20; sFormInit.disableChildren = true; sFormInit.pDisplay = intOpenPlainForm; widgAddForm(psRequestScreen, &sFormInit); // Add Banner sFormInit.formID = CHALLENGE_FORM; sFormInit.id = CHALLENGE_BANNER; sFormInit.x = CHALLENGE_HGAP; sFormInit.y = CHALLENGE_VGAP; sFormInit.width = CHALLENGE_W - (2 * CHALLENGE_HGAP); sFormInit.height = CHALLENGE_BANNER_DEPTH; sFormInit.disableChildren = false; sFormInit.pDisplay = displayLoadBanner; sFormInit.UserData = 0; widgAddForm(psRequestScreen, &sFormInit); // Add Banner Label W_LABINIT sLabInit; sLabInit.formID = CHALLENGE_BANNER; sLabInit.id = CHALLENGE_LABEL; sLabInit.style = WLAB_ALIGNCENTRE; sLabInit.x = 0; sLabInit.y = 3; sLabInit.width = CHALLENGE_W - (2 * CHALLENGE_HGAP); //CHALLENGE_W; sLabInit.height = CHALLENGE_BANNER_DEPTH; //This looks right -Q sLabInit.pText = "Challenge"; widgAddLabel(psRequestScreen, &sLabInit); // add cancel. W_BUTINIT sButInit; sButInit.formID = CHALLENGE_BANNER; sButInit.x = 8; sButInit.y = 8; sButInit.width = iV_GetImageWidth(IntImages, IMAGE_NRUTER); sButInit.height = iV_GetImageHeight(IntImages, IMAGE_NRUTER); sButInit.UserData = PACKDWORD_TRI(0, IMAGE_NRUTER , IMAGE_NRUTER); sButInit.id = CHALLENGE_CANCEL; sButInit.pTip = _("Close"); sButInit.pDisplay = intDisplayImageHilight; widgAddButton(psRequestScreen, &sButInit); // add slots sButInit = W_BUTINIT(); sButInit.formID = CHALLENGE_FORM; sButInit.width = CHALLENGE_ENTRY_W; sButInit.height = CHALLENGE_ENTRY_H; sButInit.pDisplay = displayLoadSlot; for (slotCount = 0; slotCount < totalslots; slotCount++) { sButInit.id = slotCount + CHALLENGE_ENTRY_START; if (slotCount < slotsInColumn) { sButInit.x = 22 + CHALLENGE_HGAP; sButInit.y = (SWORD)((CHALLENGE_BANNER_DEPTH + (2 * CHALLENGE_VGAP)) + ( slotCount * (CHALLENGE_VGAP + CHALLENGE_ENTRY_H))); } else if (slotCount >= slotsInColumn && (slotCount < (slotsInColumn *2))) { sButInit.x = 22 + (2 * CHALLENGE_HGAP + CHALLENGE_ENTRY_W); sButInit.y = (SWORD)((CHALLENGE_BANNER_DEPTH + (2 * CHALLENGE_VGAP)) + ( (slotCount % slotsInColumn) * (CHALLENGE_VGAP + CHALLENGE_ENTRY_H))); } else { sButInit.x = 22 + (3 * CHALLENGE_HGAP + (2 * CHALLENGE_ENTRY_W)); sButInit.y = (SWORD)((CHALLENGE_BANNER_DEPTH + (2 * CHALLENGE_VGAP)) + ( (slotCount % slotsInColumn) * (CHALLENGE_VGAP + CHALLENGE_ENTRY_H))); } widgAddButton(psRequestScreen, &sButInit); } // fill slots. slotCount = 0; sstrcpy(sPath, sSearchPath); sstrcat(sPath, "/*.ini"); debug(LOG_SAVE, "Searching \"%s\" for challenges", sPath); // add challenges to buttons files = PHYSFS_enumerateFiles(sSearchPath); for (i = files; *i != NULL; ++i) { W_BUTTON *button; char description[totalslotspace]; char highscore[totalslotspace]; const char *name, *difficulty, *map, *givendescription; inifile *inif; // See if this filename contains the extension we're looking for if (!strstr(*i, ".ini")) { // If it doesn't, move on to the next filename continue; } /* First grab any high score associated with this challenge */ inif = inifile_load(CHALLENGE_SCORES); sstrcpy(sPath, *i); sPath[strlen(sPath) - 4] = '\0'; // remove .ini sstrcpy(highscore, "no score"); if (inif) { char key[64]; bool victory; int seconds; ssprintf(key, "%s:Player", sPath); name = inifile_get(inif, key, "NO NAME"); ssprintf(key, "%s:Victory", sPath); victory = inifile_get_as_bool(inif, key, false); ssprintf(key, "%s:Seconds", sPath); seconds = inifile_get_as_int(inif, key, -1); if (seconds > 0) { getAsciiTime(key, seconds * GAME_TICKS_PER_SEC); ssprintf(highscore, "%s by %s (%s)", key, name, victory ? "Victory" : "Survived"); } inifile_delete(inif); } ssprintf(sPath, "%s/%s", sSearchPath, *i); inif = inifile_load(sPath); inifile_set_current_section(inif, "challenge"); if (!inif) { debug(LOG_ERROR, "Could not open \"%s\"", sPath); continue; } name = inifile_get(inif, "Name", "BAD NAME"); map = inifile_get(inif, "Map", "BAD MAP"); difficulty = inifile_get(inif, "difficulty", "BAD DIFFICULTY"); givendescription = inifile_get(inif, "description", ""); ssprintf(description, "%s, %s, %s. %s", map, difficulty, highscore, givendescription); button = (W_BUTTON*)widgGetFromID(psRequestScreen, CHALLENGE_ENTRY_START + slotCount); debug(LOG_SAVE, "We found [%s]", *i); /* Set the button-text */ sstrcpy(sSlotCaps[slotCount], name); // store it! sstrcpy(sSlotTips[slotCount], description); // store it, too! sstrcpy(sSlotFile[slotCount], sPath); // store filename inifile_delete(inif); /* Add button */ button->pTip = sSlotTips[slotCount]; button->pText = sSlotCaps[slotCount]; button->pUserData = (void *)sSlotFile[slotCount]; slotCount++; // go to next button... if (slotCount == totalslots) { break; } } PHYSFS_freeList(files); challengesUp = true; return true; }
/** Searches in the given search directory for files ending with the * given extension. Then will create a window with buttons for each * found file. * \param searchDir the directory to search in * \param fileExtension the extension files should end with, if the * extension has a dot (.) then this dot _must_ be present as * the first char in this parameter * \param mode (purpose unknown) * \param numPlayers (purpose unknown) */ void addMultiRequest(const char* searchDir, const char* fileExtension, UDWORD mode, UBYTE mapCam, UBYTE numPlayers) { const unsigned int extensionLength = strlen(fileExtension); const unsigned int buttonsX = (mode == MULTIOP_MAP) ? 22 : 17; context = mode; if(mode == MULTIOP_MAP) { // only save these when they select MAP button current_tech = mapCam; current_numplayers = numPlayers; } char **fileList = PHYSFS_enumerateFiles(searchDir); psRScreen = new W_SCREEN; ///< move this to intinit or somewhere like that.. (close too.) WIDGET *parent = psRScreen->psForm; /* add a form to place the tabbed form on */ IntFormAnimated *requestForm = new IntFormAnimated(parent); requestForm->id = M_REQUEST; requestForm->setGeometry(M_REQUEST_X + D_W, M_REQUEST_Y + D_H, M_REQUEST_W, M_REQUEST_H); // Add the button list. IntListTabWidget *requestList = new IntListTabWidget(requestForm); requestList->setChildSize(R_BUT_W, R_BUT_H); requestList->setChildSpacing(4, 4); requestList->setGeometry(2 + buttonsX, 2, M_REQUEST_W - buttonsX, M_REQUEST_H - 4); // Add the close button. W_BUTINIT sButInit; sButInit.formID = M_REQUEST; sButInit.id = M_REQUEST_CLOSE; sButInit.x = M_REQUEST_W - CLOSE_WIDTH - 3; sButInit.y = 0; sButInit.width = CLOSE_WIDTH; sButInit.height = CLOSE_HEIGHT; sButInit.pTip = _("Close"); sButInit.pDisplay = intDisplayImageHilight; sButInit.UserData = PACKDWORD_TRI(0,IMAGE_CLOSEHILIGHT , IMAGE_CLOSE); widgAddButton(psRScreen, &sButInit); // Put the buttons on it. int nextButtonId = M_REQUEST_BUT; for (char **currFile = fileList; *currFile != NULL; ++currFile) { const unsigned int fileNameLength = strlen(*currFile); // Check to see if this file matches the given extension if (fileNameLength <= extensionLength || strcmp(&(*currFile)[fileNameLength - extensionLength], fileExtension) != 0) continue; char *withoutExtension = strdup(*currFile); withoutExtension[fileNameLength - extensionLength] = '\0'; // Set the tip and add the button W_BUTTON *button = new W_BUTTON(requestList); button->id = nextButtonId; button->setTip(withoutExtension); button->setString(withoutExtension); button->displayFunction = displayRequestOption; requestList->addWidgetToLayout(button); free(withoutExtension); /* Update the init struct for the next button */ ++nextButtonId; } // Make sure to return memory back to PhyscisFS PHYSFS_freeList(fileList); multiRequestUp = true; hoverPreviewId = 0; if(mode == MULTIOP_MAP) { LEVEL_DATASET *mapData; bool first = true; while ((mapData = enumerateMultiMaps(first, mapCam, numPlayers)) != NULL) { first = false; // add number of players to string. W_BUTTON *button = new W_BUTTON(requestList); button->id = nextButtonId; button->setTip(mapData->pName); button->setString(mapData->pName); button->pUserData = mapData; button->displayFunction = displayRequestOption; requestList->addWidgetToLayout(button); ++nextButtonId; } // if it's map select then add the cam style buttons. sButInit = W_BUTINIT(); sButInit.formID = M_REQUEST; sButInit.id = M_REQUEST_C1; sButInit.x = 3; sButInit.y = 254; sButInit.width = 17; sButInit.height = 17; sButInit.UserData = 1; sButInit.pTip = _("Technology level 1"); sButInit.pDisplay = displayCamTypeBut; widgAddButton(psRScreen, &sButInit); sButInit.id = M_REQUEST_C2; sButInit.y += 22; sButInit.UserData = 2; sButInit.pTip = _("Technology level 2"); widgAddButton(psRScreen, &sButInit); sButInit.id = M_REQUEST_C3; sButInit.y += 22; sButInit.UserData = 3; sButInit.pTip = _("Technology level 3"); widgAddButton(psRScreen, &sButInit); sButInit.id = M_REQUEST_AP; sButInit.y = 17; sButInit.UserData = 0; sButInit.pTip = _("Any number of players"); sButInit.pDisplay = displayNumPlayersBut; widgAddButton(psRScreen, &sButInit); STATIC_ASSERT(MAX_PLAYERS_IN_GUI <= ARRAY_SIZE(M_REQUEST_NP) + 1); for (unsigned numPlayers = 2; numPlayers <= MAX_PLAYERS_IN_GUI; ++numPlayers) { static char ttip[MAX_PLAYERS_IN_GUI + 1][20]; sButInit.id = M_REQUEST_NP[numPlayers - 2]; sButInit.y += 22; sButInit.UserData = numPlayers; ssprintf(ttip[numPlayers], ngettext("%d player", "%d players", numPlayers), numPlayers); sButInit.pTip = ttip[numPlayers]; widgAddButton(psRScreen, &sButInit); } } }