/* 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 Transporter Button form */ bool intAddTransButtonForm(void) { UDWORD numButtons, i; SDWORD BufferID; DROID *psDroid; /* Add the button form */ W_FORMINIT sFormInit; sFormInit.formID = IDTRANS_FORM; sFormInit.id = IDTRANS_TABFORM; sFormInit.style = WFORM_TABBED; sFormInit.width = TRANS_TABWIDTH; sFormInit.height = TRANS_TABHEIGHT; sFormInit.x = TRANS_TABX; sFormInit.y = TRANS_TABY; sFormInit.majorPos = WFORM_TABTOP; sFormInit.minorPos = WFORM_TABNONE; sFormInit.majorSize = OBJ_TABWIDTH; sFormInit.majorOffset = OBJ_TABOFFSET; sFormInit.tabVertOffset = (OBJ_TABHEIGHT / 2); sFormInit.tabMajorThickness = OBJ_TABHEIGHT; numButtons = 0; /*work out the number of buttons */ for (psDroid = transInterfaceDroidList(); psDroid; psDroid = psDroid->psNext) { //only interested in Transporter droids if ((psDroid->droidType == DROID_TRANSPORTER || psDroid->droidType == DROID_SUPERTRANSPORTER) && (psDroid->action != DACTION_TRANSPORTOUT && psDroid->action != DACTION_TRANSPORTIN)) { //set the first Transporter to be the current one if not already set if (psCurrTransporter == NULL) { psCurrTransporter = psDroid; } numButtons++; } } //set the number of tabs required sFormInit.numMajor = numForms((OBJ_BUTWIDTH + OBJ_GAP) * numButtons, OBJ_WIDTH - OBJ_GAP); sFormInit.pUserData = &StandardTab; sFormInit.pTabDisplay = intDisplayTab; if (sFormInit.numMajor > MAX_TAB_STD_SHOWN) { // we do NOT use smallTab icons here, so be safe and only display max # of // standard sized tab icons. sFormInit.numMajor = MAX_TAB_STD_SHOWN; } //set minor tabs to 1 for (i = 0; i < sFormInit.numMajor; i++) { sFormInit.aNumMinors[i] = 1; } if (!widgAddForm(psWScreen, &sFormInit)) { return false; } /* Add the transporter and status buttons */ W_FORMINIT sBFormInit; sBFormInit.formID = IDTRANS_TABFORM; sBFormInit.id = IDTRANS_START; sBFormInit.majorID = 0; sBFormInit.minorID = 0; sBFormInit.style = WFORM_CLICKABLE; sBFormInit.x = OBJ_STARTX; sBFormInit.y = OBJ_STARTY; sBFormInit.width = OBJ_BUTWIDTH; sBFormInit.height = OBJ_BUTHEIGHT; W_FORMINIT sBFormInit2 = sBFormInit; sBFormInit2.id = IDTRANS_STATSTART; sBFormInit2.y = OBJ_STATSTARTY; ClearObjectBuffers(); ClearTopicBuffers(); //add each button for (psDroid = transInterfaceDroidList(); psDroid; psDroid = psDroid->psNext) { if ((psDroid->droidType == DROID_TRANSPORTER || psDroid->droidType == DROID_SUPERTRANSPORTER) && (psDroid->action != DACTION_TRANSPORTOUT && psDroid->action != DACTION_TRANSPORTIN)) { /* Set the tip and add the button */ sBFormInit.pTip = droidGetName(psDroid); BufferID = sBFormInit.id - IDTRANS_START; ASSERT(BufferID < NUM_TOPICBUFFERS, "BufferID > NUM_TOPICBUFFERS"); ClearTopicButtonBuffer(BufferID); RENDERBUTTON_INUSE(&TopicBuffers[BufferID]); TopicBuffers[BufferID].Data = (void *)psDroid; sBFormInit.pUserData = &TopicBuffers[BufferID]; sBFormInit.pDisplay = intDisplayObjectButton; if (!widgAddForm(psWScreen, &sBFormInit)) { return false; } /* if the current droid matches psCurrTransporter lock the button */ if (psDroid == psCurrTransporter) { widgSetButtonState(psWScreen, sBFormInit.id, WBUT_LOCK); widgSetTabs(psWScreen, IDTRANS_TABFORM, sBFormInit.majorID, 0); } //now do status button sBFormInit2.pTip = NULL; BufferID = (sBFormInit2.id - IDTRANS_STATSTART) * 2 + 1; ASSERT(BufferID < NUM_OBJECTBUFFERS, "BufferID > NUM_OBJECTBUFFERS"); ClearObjectButtonBuffer(BufferID); RENDERBUTTON_INUSE(&ObjectBuffers[BufferID]); sBFormInit2.pUserData = &ObjectBuffers[BufferID]; sBFormInit2.pDisplay = intDisplayStatusButton; if (!widgAddForm(psWScreen, &sBFormInit2)) { return false; } /* Update the init struct for the next buttons */ sBFormInit.id += 1; ASSERT(sBFormInit.id < IDTRANS_END, "Too many Transporter buttons"); sBFormInit.x += OBJ_BUTWIDTH + OBJ_GAP; if (sBFormInit.x + OBJ_BUTWIDTH + OBJ_GAP > OBJ_WIDTH) { sBFormInit.x = OBJ_STARTX; sBFormInit.majorID += 1; } sBFormInit2.id += 1; ASSERT(sBFormInit2.id < IDTRANS_STATEND, "Too many Transporter status buttons"); sBFormInit2.x += OBJ_BUTWIDTH + OBJ_GAP; if (sBFormInit2.x + OBJ_BUTWIDTH + OBJ_GAP > OBJ_WIDTH) { sBFormInit2.x = OBJ_STARTX; sBFormInit2.majorID += 1; } } } return true; }
/* Add the Transporter Contents form */ bool intAddTransContentsForm(void) { UDWORD i; SDWORD BufferID; DROID *psDroid, *psNext; /* Add the contents form */ W_FORMINIT sFormInit; sFormInit.formID = IDTRANS_CONTENTFORM; sFormInit.id = IDTRANS_CONTABFORM; sFormInit.style = WFORM_TABBED; sFormInit.width = TRANSCONT_WIDTH; sFormInit.height = TRANSCONT_HEIGHT; sFormInit.x = TRANSCONT_TABX; sFormInit.y = TRANSCONT_TABY; sFormInit.majorPos = WFORM_TABTOP; sFormInit.minorPos = WFORM_TABNONE; sFormInit.majorSize = OBJ_TABWIDTH; sFormInit.majorOffset = OBJ_TABOFFSET; sFormInit.tabVertOffset = (OBJ_TABHEIGHT / 2); sFormInit.tabMajorThickness = OBJ_TABHEIGHT; //set the number of tabs required //sFormInit.numMajor = numForms((OBJ_BUTWIDTH + OBJ_GAP) * numButtons, // OBJ_WIDTH - OBJ_GAP); // TABFIXME: Looks like 10 units is max for this? sFormInit.numMajor = 1; //set minor tabs to 1 for (i = 0; i < sFormInit.numMajor; i++) { sFormInit.aNumMinors[i] = 1; } sFormInit.pUserData = &StandardTab; sFormInit.pTabDisplay = intDisplayTab; if (!widgAddForm(psWScreen, &sFormInit)) { return false; } /* Add the transporter contents buttons */ W_FORMINIT sBFormInit; sBFormInit.formID = IDTRANS_CONTABFORM; sBFormInit.id = IDTRANS_CONTSTART; sBFormInit.majorID = 0; sBFormInit.minorID = 0; sBFormInit.style = WFORM_CLICKABLE; sBFormInit.x = OBJ_STARTX; sBFormInit.y = OBJ_STARTY - OBJ_BUTHEIGHT - OBJ_GAP; sBFormInit.width = OBJ_BUTWIDTH; sBFormInit.height = OBJ_BUTHEIGHT; ClearStatBuffers(); //add each button if (psCurrTransporter != NULL) { for (psDroid = psCurrTransporter->psGroup->psList; psDroid != NULL && psDroid != psCurrTransporter; psDroid = psNext) { psNext = psDroid->psGrpNext; if (psDroid->selected) { continue; // Droid is queued to be ejected from the transport, so don't display it. } /* Set the tip and add the button */ sBFormInit.pTip = droidGetName(psDroid); BufferID = GetStatBuffer(); ASSERT(BufferID >= 0, "Unable to acquire stat buffer."); RENDERBUTTON_INUSE(&StatBuffers[BufferID]); StatBuffers[BufferID].Data = (void *)psDroid; sBFormInit.pUserData = &StatBuffers[BufferID]; sBFormInit.pDisplay = intDisplayTransportButton; if (!widgAddForm(psWScreen, &sBFormInit)) { return false; } /* Update the init struct for the next button */ sBFormInit.id += 1; ASSERT(sBFormInit.id < IDTRANS_CONTEND, "Too many Transporter Droid buttons"); sBFormInit.x += OBJ_BUTWIDTH + OBJ_GAP; if (sBFormInit.x + OBJ_BUTWIDTH + OBJ_GAP > TRANSCONT_WIDTH) { sBFormInit.x = OBJ_STARTX; sBFormInit.y += OBJ_BUTHEIGHT + OBJ_GAP; } if (sBFormInit.y + OBJ_BUTHEIGHT + OBJ_GAP > TRANSCONT_HEIGHT) { sBFormInit.y = OBJ_STARTY; sBFormInit.majorID += 1; } } } return true; }
/* Add the Message sub form */ static BOOL intAddMessageForm(BOOL playCurrent) { UDWORD numButtons, i; MESSAGE *psMessage; RESEARCH *psResearch; SDWORD BufferID; /* Add the Message form */ W_FORMINIT sFormInit; sFormInit.formID = IDINTMAP_FORM; sFormInit.id = IDINTMAP_MSGFORM; sFormInit.style = WFORM_TABBED; sFormInit.width = INTMAP_MSGWIDTH; sFormInit.height = INTMAP_MSGHEIGHT; sFormInit.x = INTMAP_MSGX; sFormInit.y = INTMAP_MSGY; sFormInit.majorPos = WFORM_TABTOP; sFormInit.minorPos = WFORM_TABNONE; sFormInit.majorSize = OBJ_TABWIDTH; sFormInit.majorOffset = OBJ_TABOFFSET; sFormInit.tabVertOffset = (OBJ_TABHEIGHT/2); sFormInit.tabMajorThickness = OBJ_TABHEIGHT; numButtons = 0; /*work out the number of buttons */ for(psMessage = apsMessages[selectedPlayer]; psMessage; psMessage = psMessage->psNext) { //ignore proximity messages here if (psMessage->type != MSG_PROXIMITY) { numButtons++; } // stop adding the buttons once max has been reached if (numButtons > (IDINTMAP_MSGEND - IDINTMAP_MSGSTART)) { break; } } //set the number of tabs required sFormInit.numMajor = numForms((OBJ_BUTWIDTH + OBJ_GAP) * numButtons, (OBJ_WIDTH - OBJ_GAP)*2); sFormInit.pUserData = &StandardTab; sFormInit.pTabDisplay = intDisplayTab; if (sFormInit.numMajor > MAX_TAB_STD_SHOWN) { // we do NOT use smallTab icons here, so be safe and only display max # of // standard sized tab icons. sFormInit.numMajor = MAX_TAB_STD_SHOWN; } //set minor tabs to 1 for (i=0; i< sFormInit.numMajor; i++) { sFormInit.aNumMinors[i] = 1; } if (!widgAddForm(psWScreen, &sFormInit)) { return false; } /* Add the message buttons */ W_FORMINIT sBFormInit; sBFormInit.formID = IDINTMAP_MSGFORM; sBFormInit.id = IDINTMAP_MSGSTART; sBFormInit.majorID = 0; sBFormInit.minorID = 0; sBFormInit.style = WFORM_CLICKABLE; sBFormInit.x = OBJ_STARTX; sBFormInit.y = OBJ_STATSTARTY; sBFormInit.width = OBJ_BUTWIDTH; sBFormInit.height = OBJ_BUTHEIGHT; ClearObjectBuffers(); //add each button messageID = 0; for(psMessage = apsMessages[selectedPlayer]; psMessage; psMessage = psMessage->psNext) { /*if (psMessage->type == MSG_TUTORIAL) { //tutorial cases should never happen ASSERT( false, "Tutorial message in Intelligence screen!" ); continue; }*/ if (psMessage->type == MSG_PROXIMITY) { //ignore proximity messages here continue; } /* Set the tip and add the button */ switch (psMessage->type) { case MSG_RESEARCH: psResearch = getResearchForMsg((VIEWDATA *)psMessage->pViewData); if (psResearch) { sBFormInit.pTip = getStatName(psResearch);; } else { sBFormInit.pTip = _("Research Update"); } break; case MSG_CAMPAIGN: sBFormInit.pTip = _("Project Goals"); break; case MSG_MISSION: sBFormInit.pTip = _("Current Objective"); break; default: break; } BufferID = GetObjectBuffer(); ASSERT( BufferID >= 0,"Unable to acquire object buffer." ); RENDERBUTTON_INUSE(&ObjectBuffers[BufferID]); ObjectBuffers[BufferID].Data = (void*)psMessage; sBFormInit.pUserData = &ObjectBuffers[BufferID]; sBFormInit.pDisplay = intDisplayMessageButton; if (!widgAddForm(psWScreen, &sBFormInit)) { return false; } /* if the current message matches psSelected lock the button */ if (psMessage == psCurrentMsg) { messageID = sBFormInit.id; widgSetButtonState(psWScreen, messageID, WBUT_LOCK); widgSetTabs(psWScreen, IDINTMAP_MSGFORM, sBFormInit.majorID, 0); } /* Update the init struct for the next button */ sBFormInit.id += 1; // stop adding the buttons when at max if (sBFormInit.id > IDINTMAP_MSGEND) { break; } ASSERT( sBFormInit.id < (IDINTMAP_MSGEND+1),"Too many message buttons" ); sBFormInit.x += OBJ_BUTWIDTH + OBJ_GAP; if (sBFormInit.x + OBJ_BUTWIDTH + OBJ_GAP > INTMAP_MSGWIDTH) { sBFormInit.x = OBJ_STARTX; sBFormInit.y += OBJ_BUTHEIGHT + OBJ_GAP; } if (sBFormInit.y + OBJ_BUTHEIGHT + OBJ_GAP > INTMAP_MSGHEIGHT) { sBFormInit.y = OBJ_STATSTARTY; sBFormInit.majorID += 1; } } //check to play current message instantly if (playCurrent) { //is it a proximity message? if (psCurrentMsg->type == MSG_PROXIMITY) { //intIntelButtonPressed(true, messageID); } else { intIntelButtonPressed(false, messageID); } } return true; }