/* 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 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; }