const char *objInfo(const BASE_OBJECT *psObj) { static char info[PATH_MAX]; if (!psObj) { return "null"; } switch (psObj->type) { case OBJ_DROID: { const DROID *psDroid = (const DROID *)psObj; return droidGetName(psDroid); } case OBJ_STRUCTURE: { const STRUCTURE *psStruct = (const STRUCTURE *)psObj; sstrcpy(info, getName(psStruct->pStructureType)); break; } case OBJ_FEATURE: { const FEATURE *psFeat = (const FEATURE *)psObj; sstrcpy(info, getName(psFeat->psStats)); break; } case OBJ_PROJECTILE: sstrcpy(info, "Projectile"); // TODO break; case OBJ_TARGET: sstrcpy(info, "Target"); // TODO break; default: sstrcpy(info, "Unknown object type"); break; } return info; }
/* Add the Transporter Contents form */ bool intAddTransContentsForm(void) { WIDGET *contForm = widgGetFromID(psWScreen, IDTRANS_CONTENTFORM); /* Add the contents form */ IntListTabWidget *contList = new IntListTabWidget(contForm); contList->setChildSize(OBJ_BUTWIDTH, OBJ_BUTHEIGHT); contList->setChildSpacing(OBJ_GAP, OBJ_GAP); int contListWidth = OBJ_BUTWIDTH*2 + OBJ_GAP; contList->setGeometry((contForm->width() - contListWidth)/2, TRANSCONT_TABY, contListWidth, contForm->height() - TRANSCONT_TABY); /* Add the transporter contents buttons */ int nextButtonId = IDTRANS_CONTSTART; //add each button if (psCurrTransporter == nullptr) { return true; } for (DROID *psDroid = psCurrTransporter->psGroup->psList; psDroid != nullptr && psDroid != psCurrTransporter; psDroid = 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 */ IntTransportButton *button = new IntTransportButton(contList); button->id = nextButtonId; button->setTip(droidGetName(psDroid)); button->setObject(psDroid); contList->addWidgetToLayout(button); /* Update the init struct for the next button */ ++nextButtonId; ASSERT(nextButtonId < IDTRANS_CONTEND, "Too many Transporter Droid buttons"); } return true; }
/* Updates the camera position/angle along with the object movement */ bool processWarCam( void ) { BASE_OBJECT *foundTarget; bool Status = true; /* Get out if the camera isn't active */ if(trackingCamera.status == CAM_INACTIVE) { return(true); } /* Ensure that the camera only ever flips state within this routine! */ switch(trackingCamera.status) { case CAM_REQUEST: /* See if we can find the target to follow */ foundTarget = camFindTarget(); if(foundTarget && !foundTarget->died) { /* We've got one, so store away info */ camAllignWithTarget(foundTarget); /* We're now into tracking status */ trackingCamera.status = CAM_TRACKING; /* Inform via console */ if(foundTarget->type == OBJ_DROID) { if(getWarCamStatus()) { CONPRINTF(ConsoleString,(ConsoleString,"WZ/CAM - %s",droidGetName((DROID*)foundTarget))); } } } else { /* We've requested a track with no droid selected */ trackingCamera.status = CAM_INACTIVE; } break; case CAM_TRACKING: /* Track the droid unless routine comes back false */ if(!camTrackCamera()) { /* Camera track came back false, either because droid died or is no longer selected, so reset to old values */ foundTarget = camFindTarget(); if(foundTarget && !foundTarget->died) { trackingCamera.status = CAM_REQUEST; } else { trackingCamera.status = CAM_RESET; } } processLeaderSelection(); break; case CAM_RESET: /* Reset camera to pre-droid tracking status */ if( (trackingCamera.target==NULL) ||(trackingCamera.target->type!=OBJ_TARGET)) { camSwitchOff(); } /* Switch to inactive mode */ trackingCamera.status = CAM_INACTIVE; Status = false; break; case CAM_INACTIVE: case CAM_TRACK_OBJECT: case CAM_TRACK_LOCATION: ASSERT(false, "Unexpected status for tracking camera"); break; } return Status; }
/* 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; }
/* Add the Transporter Button form */ bool intAddTransButtonForm(void) { WIDGET *transForm = widgGetFromID(psWScreen, IDTRANS_FORM); /* Add the button form */ IntListTabWidget *transList = new IntListTabWidget(transForm); transList->setChildSize(OBJ_BUTWIDTH, OBJ_BUTHEIGHT*2); transList->setChildSpacing(OBJ_GAP, OBJ_GAP); int objListWidth = OBJ_BUTWIDTH*5 + OBJ_GAP*4; transList->setGeometry((OBJ_BACKWIDTH - objListWidth)/2, TRANS_TABY, objListWidth, transForm->height() - TRANS_TABY); /* Add the transporter and status buttons */ int nextObjButtonId = IDTRANS_START; int nextStatButtonId = IDTRANS_STATSTART; //add each button for (DROID *psDroid = transInterfaceDroidList(); psDroid; psDroid = psDroid->psNext) { if ((psDroid->droidType != DROID_TRANSPORTER && psDroid->droidType != DROID_SUPERTRANSPORTER) || psDroid->action == DACTION_TRANSPORTOUT || psDroid->action == DACTION_TRANSPORTIN) { continue; } WIDGET *buttonHolder = new WIDGET(transList); transList->addWidgetToLayout(buttonHolder); IntStatusButton *statButton = new IntStatusButton(buttonHolder); statButton->id = nextStatButtonId; statButton->setGeometry(0, 0, OBJ_BUTWIDTH, OBJ_BUTHEIGHT); IntObjectButton *objButton = new IntObjectButton(buttonHolder); objButton->id = nextObjButtonId; objButton->setGeometry(0, OBJ_STARTY, OBJ_BUTWIDTH, OBJ_BUTHEIGHT); /* Set the tip and add the button */ objButton->setTip(droidGetName(psDroid)); objButton->setObject(psDroid); //set the first Transporter to be the current one if not already set if (psCurrTransporter == nullptr) { psCurrTransporter = psDroid; } /* if the current droid matches psCurrTransporter lock the button */ if (psDroid == psCurrTransporter) { objButton->setState(WBUT_LOCK); transList->setCurrentPage(transList->pages() - 1); } //now do status button statButton->setObject(nullptr); /* Update the init struct for the next buttons */ ++nextObjButtonId; ASSERT(nextObjButtonId < IDTRANS_END, "Too many Transporter buttons"); ++nextStatButtonId; ASSERT(nextStatButtonId < IDTRANS_STATEND, "Too many Transporter status buttons"); } return true; }
/* Updates the camera position/angle along with the object movement */ BOOL processWarCam( void ) { BASE_OBJECT *foundTarget; BOOL Status = true; /* Get out if the camera isn't active */ if(trackingCamera.status == CAM_INACTIVE) { return(true); } /* Ensure that the camera only ever flips state within this routine! */ switch(trackingCamera.status) { case CAM_REQUEST: /* See if we can find the target to follow */ foundTarget = camFindTarget(); if(foundTarget && !foundTarget->died) { /* We've got one, so store away info */ camAllignWithTarget(foundTarget); /* We're now into tracking status */ trackingCamera.status = CAM_TRACKING; /* Inform via console */ if(foundTarget->type == OBJ_DROID) { if(getWarCamStatus()) { CONPRINTF(ConsoleString,(ConsoleString,"WZ/CAM - %s",droidGetName((DROID*)foundTarget))); } } else { // CONPRINTF(ConsoleString,(ConsoleString,"DROID-CAM V0.1 Enabled - Now tracking new location")); } } else { /* We've requested a track with no droid selected */ // addConsoleMessage("Droid-CAM V0.1 ERROR - No targets(s) selected",DEFAULT_JUSTIFY,SYSTEM_MESSAGE); trackingCamera.status = CAM_INACTIVE; } break; case CAM_TRACKING: /* Track the droid unless routine comes back false */ if(!camTrackCamera()) { /* Camera track came back false, either because droid died or is no longer selected, so reset to old values */ foundTarget = camFindTarget(); if(foundTarget && !foundTarget->died) { trackingCamera.status = CAM_REQUEST; } else { trackingCamera.status = CAM_RESET; } } processLeaderSelection(); break; case CAM_RESET: /* Reset camera to pre-droid tracking status */ if( (trackingCamera.target==NULL) ||(trackingCamera.target->type!=OBJ_TARGET)) { camSwitchOff(); } /* Switch to inactive mode */ trackingCamera.status = CAM_INACTIVE; // addConsoleMessage("Droid-CAM V0.1 Disabled",DEFAULT_JUSTIFY,SYSTEM_MESSAGE); Status = false; break; default: debug( LOG_FATAL, "Weirdy status for tracking Camera" ); abort(); break; } return Status; }
/* 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 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 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; }