static void CaptainsWindow (CAPTAIN_STUFF *CSPtr, COORD y, STATUS_FLAGS delta_status_flags, STATUS_FLAGS cur_status_flags, COUNT Pass) { STAMP Stamp; Stamp.origin.x = CAPTAIN_XOFFS; Stamp.origin.y = y + CAPTAIN_YOFFS; if (delta_status_flags & LEFT) { Stamp.frame = CSPtr->turn; if (!(delta_status_flags & RIGHT)) { Stamp.frame = SetRelFrameIndex (Stamp.frame, 3); if (Pass == 2) { if (cur_status_flags & LEFT) Stamp.frame = IncFrameIndex (Stamp.frame); else Stamp.frame = DecFrameIndex (Stamp.frame); } } else if (cur_status_flags & RIGHT) { if (Pass == 1) Stamp.frame = SetRelFrameIndex (Stamp.frame, 3); else Stamp.frame = IncFrameIndex (Stamp.frame); DrawStamp (&Stamp); Stamp.frame = DecFrameIndex (Stamp.frame); } else { if (Pass == 1) Stamp.frame = IncFrameIndex (Stamp.frame); else Stamp.frame = SetRelFrameIndex (Stamp.frame, 3); DrawStamp (&Stamp); Stamp.frame = IncFrameIndex (Stamp.frame); } DrawStamp (&Stamp); } else if (delta_status_flags & RIGHT) { Stamp.frame = CSPtr->turn; Stamp.frame = IncFrameIndex (Stamp.frame); if (Pass == 2) { if (cur_status_flags & RIGHT) Stamp.frame = DecFrameIndex (Stamp.frame); else Stamp.frame = IncFrameIndex (Stamp.frame); } DrawStamp (&Stamp); } if (delta_status_flags & THRUST) { Stamp.frame = CSPtr->thrust; if (Pass == 1) Stamp.frame = IncFrameIndex (Stamp.frame); else if (cur_status_flags & THRUST) Stamp.frame = SetRelFrameIndex (Stamp.frame, 2); DrawStamp (&Stamp); } if (delta_status_flags & WEAPON) { Stamp.frame = CSPtr->weapon; if (Pass == 1) Stamp.frame = IncFrameIndex (Stamp.frame); else if (cur_status_flags & WEAPON) Stamp.frame = SetRelFrameIndex (Stamp.frame, 2); DrawStamp (&Stamp); } if (delta_status_flags & SPECIAL) { Stamp.frame = CSPtr->special; if (Pass == 1) Stamp.frame = IncFrameIndex (Stamp.frame); else if (cur_status_flags & SPECIAL) Stamp.frame = SetRelFrameIndex (Stamp.frame, 2); DrawStamp (&Stamp); } }
void DrawCaptainsWindow (STARSHIP *StarShipPtr) { COORD y; COORD y_offs; RECT r; STAMP s; FRAME Frame; RACE_DESC *RDPtr; RDPtr = StarShipPtr->RaceDescPtr; Frame = RDPtr->ship_data.captain_control.background; if (Frame) { Frame = SetAbsFrameIndex (Frame, 0); RDPtr->ship_data.captain_control.background = Frame; Frame = SetRelFrameIndex (Frame, 1); RDPtr->ship_data.captain_control.turn = Frame; Frame = SetRelFrameIndex (Frame, 5); RDPtr->ship_data.captain_control.thrust = Frame; Frame = SetRelFrameIndex (Frame, 3); RDPtr->ship_data.captain_control.weapon = Frame; Frame = SetRelFrameIndex (Frame, 3); RDPtr->ship_data.captain_control.special = Frame; } BatchGraphics (); // Grey area under and around captain's window. assert (StarShipPtr->playerNr >= 0); y_offs = status_y_offsets[StarShipPtr->playerNr]; r.corner.x = CAPTAIN_XOFFS - RES_STAT_SCALE(4); // JMS_GFX r.corner.y = y_offs + SHIP_INFO_HEIGHT; r.extent.width = STATUS_WIDTH - 2; r.extent.height = SHIP_STATUS_HEIGHT - CAPTAIN_YOFFS + (4 << RESOLUTION_FACTOR); // JMS_GFX SetContextForeGroundColor ( BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x0A), 0x08)); DrawFilledRectangle (&r); // Left border of the status panel. SetContextForeGroundColor ( BUILD_COLOR (MAKE_RGB15 (0x08, 0x08, 0x08), 0x1F)); r.corner.x = 1; r.corner.y = y_offs + SHIP_INFO_HEIGHT; r.extent.width = 1; r.extent.height = (SHIP_STATUS_HEIGHT - SHIP_INFO_HEIGHT - 2); DrawFilledRectangle (&r); r.corner.x = 0; ++r.extent.height; DrawFilledRectangle (&r); // Lower and right border of the status panel. SetContextForeGroundColor ( BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19)); r.corner.x = STATUS_WIDTH - 1; r.corner.y = y_offs + SHIP_INFO_HEIGHT; r.extent.width = 1; r.extent.height = SHIP_STATUS_HEIGHT - SHIP_INFO_HEIGHT; DrawFilledRectangle (&r); r.corner.x = STATUS_WIDTH - 2; DrawFilledRectangle (&r); r.corner.x = 1; r.extent.width = STATUS_WIDTH - 2; r.corner.y = y_offs + (SHIP_STATUS_HEIGHT - 2); r.extent.height = 1; DrawFilledRectangle (&r); r.corner.x = 0; ++r.extent.width; ++r.corner.y; DrawFilledRectangle (&r); y = y_offs + CAPTAIN_YOFFS; // Darker grey rectangle at bottom and right of captain's window SetContextForeGroundColor ( BUILD_COLOR (MAKE_RGB15 (0x08, 0x08, 0x08), 0x1F)); r.corner.x = CAPTAIN_WIDTH + CAPTAIN_XOFFS; r.corner.y = y; r.extent.width = 1; r.extent.height = CAPTAIN_HEIGHT; DrawFilledRectangle (&r); r.corner.x = CAPTAIN_XOFFS - 1; r.corner.y += CAPTAIN_HEIGHT; r.extent.width = CAPTAIN_WIDTH + 2; r.extent.height = 1; DrawFilledRectangle (&r); // Light grey rectangle at top and left of captains window SetContextForeGroundColor ( BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19)); r.corner.x = CAPTAIN_XOFFS - 1; r.extent.width = CAPTAIN_WIDTH + 2; r.corner.y = y - 1; r.extent.height = 1; DrawFilledRectangle (&r); r.corner.x = CAPTAIN_XOFFS - 1; r.extent.width = 1; r.corner.y = y; r.extent.height = CAPTAIN_HEIGHT; DrawFilledRectangle (&r); s.frame = RDPtr->ship_data.captain_control.background; s.origin.x = CAPTAIN_XOFFS; s.origin.y = y; DrawStamp (&s); if (StarShipPtr->captains_name_index == 0 && StarShipPtr->playerNr == RPG_PLAYER_NUM) { // This is SIS TEXT t; t.baseline.x = STATUS_WIDTH >> 1; t.baseline.y = y + RES_CASE(6,-22,-44); // JMS_GFX t.align = ALIGN_CENTER; t.pStr = GLOBAL_SIS (CommanderName); t.CharCount = (COUNT)~0; SetContextForeGroundColor (RES_CASE(BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x00), 0x02), BLACK_COLOR, BLACK_COLOR)); SetContextFont (TinyFont); font_DrawText (&t); }
static void confuse_preprocess (ELEMENT *ElementPtr) { if (!(ElementPtr->state_flags & NONSOLID)) { ElementPtr->next.image.frame = SetAbsFrameIndex ( ElementPtr->current.image.frame, (GetFrameIndex (ElementPtr->current.image.frame) + 1) & 7); ElementPtr->state_flags |= CHANGING; } else if (ElementPtr->hTarget == 0) { ElementPtr->life_span = 0; ElementPtr->state_flags |= DISAPPEARING; } else { ELEMENT *eptr; LockElement (ElementPtr->hTarget, &eptr); ElementPtr->next.location = eptr->next.location; if (ElementPtr->turn_wait) { HELEMENT hEffect; STARSHIP *StarShipPtr; if (GetFrameIndex (ElementPtr->next.image.frame = IncFrameIndex (ElementPtr->current.image.frame)) == 0) ElementPtr->next.image.frame = SetRelFrameIndex (ElementPtr->next.image.frame, -8); GetElementStarShip (eptr, &StarShipPtr); StarShipPtr->ship_input_state = (StarShipPtr->ship_input_state & ~(LEFT | RIGHT | SPECIAL)) | ElementPtr->turn_wait; // Disable Ur-Quan autoturret. if (StarShipPtr && StarShipPtr->SpeciesID == UR_QUAN_ID) ++StarShipPtr->auxiliary_counter; hEffect = AllocElement (); if (hEffect) { LockElement (hEffect, &eptr); eptr->playerNr = ElementPtr->playerNr; eptr->state_flags = FINITE_LIFE | NONSOLID | CHANGING; eptr->life_span = 1; eptr->current = eptr->next = ElementPtr->next; eptr->preprocess_func = confuse_preprocess; SetPrimType (&(GLOBAL (DisplayArray))[eptr->PrimIndex], STAMP_PRIM); GetElementStarShip (ElementPtr, &StarShipPtr); SetElementStarShip (eptr, StarShipPtr); eptr->hTarget = ElementPtr->hTarget; UnlockElement (hEffect); PutElement (hEffect); } } UnlockElement (ElementPtr->hTarget); } }
static void pump_up_postprocess (ELEMENT *ElementPtr) { if (ElementPtr->state_flags & APPEARING) { ZeroVelocityComponents (&ElementPtr->velocity); } else { HELEMENT hPumpUp; ELEMENT *EPtr; ELEMENT *ShipPtr; STARSHIP *StarShipPtr; GetElementStarShip (ElementPtr, &StarShipPtr); LockElement (StarShipPtr->hShip, &ShipPtr); initialize_pump_up (ShipPtr, &hPumpUp); DeltaEnergy (ShipPtr, 0); UnlockElement (StarShipPtr->hShip); LockElement (hPumpUp, &EPtr); EPtr->current.image.frame = ElementPtr->current.image.frame; EPtr->turn_wait = ElementPtr->turn_wait; EPtr->thrust_wait = ElementPtr->thrust_wait; if (--EPtr->thrust_wait == 0) { if ((EPtr->turn_wait & ~REVERSE_DIR) < MAX_PUMP - 1) { ++EPtr->turn_wait; EPtr->current.image.frame = SetRelFrameIndex ( EPtr->current.image.frame, NUM_PUMP_ANIMS); ProcessSound (SetAbsSoundIndex ( StarShipPtr->RaceDescPtr->ship_data.ship_sounds, 2), EPtr); } EPtr->thrust_wait = LEVEL_COUNTER; } EPtr->mass_points = EPtr->hit_points = (PUMPUP_DAMAGE << (ElementPtr->turn_wait & ~REVERSE_DIR)); SetElementStarShip (EPtr, StarShipPtr); if (EPtr->thrust_wait & 1) { COUNT frame_index; frame_index = GetFrameIndex (EPtr->current.image.frame); if (((EPtr->turn_wait & REVERSE_DIR) && (frame_index % NUM_PUMP_ANIMS) != 0) || (!(EPtr->turn_wait & REVERSE_DIR) && ((frame_index + 1) % NUM_PUMP_ANIMS) == 0)) { --frame_index; EPtr->turn_wait |= REVERSE_DIR; } else { ++frame_index; EPtr->turn_wait &= ~REVERSE_DIR; } EPtr->current.image.frame = SetAbsFrameIndex ( EPtr->current.image.frame, frame_index); } if (StarShipPtr->cur_status_flags & StarShipPtr->old_status_flags & WEAPON) { StarShipPtr->weapon_counter = WEAPON_WAIT; } else { SIZE dx, dy; COUNT angle; EPtr->life_span = PUMPUP_LIFE; EPtr->preprocess_func = pump_up_preprocess; EPtr->postprocess_func = 0; angle = FACING_TO_ANGLE (StarShipPtr->ShipFacing); SetVelocityComponents (&EPtr->velocity, COSINE (angle, WORLD_TO_VELOCITY (PUMPUP_SPEED)), SINE (angle, WORLD_TO_VELOCITY (PUMPUP_SPEED))); GetCurrentVelocityComponents (&ShipPtr->velocity, &dx, &dy); dx = dx * 1/2; dy = dy * 1/2; // Add some of the Trader's velocity to its projectiles. DeltaVelocityComponents (&EPtr->velocity, dx, dy); EPtr->current.location.x -= VELOCITY_TO_WORLD (dx); EPtr->current.location.y -= VELOCITY_TO_WORLD (dy); ProcessSound (SetAbsSoundIndex ( StarShipPtr->RaceDescPtr->ship_data.ship_sounds, 3), EPtr); } UnlockElement (hPumpUp); PutElement (hPumpUp); SetPrimType (&(GLOBAL (DisplayArray))[ElementPtr->PrimIndex], NO_PRIM); ElementPtr->state_flags |= NONSOLID; } }
void DrawCaptainsWindow (STARSHIP *StarShipPtr) { COORD y; COORD y_offs; RECT r; STAMP s; FRAME Frame; RACE_DESC *RDPtr; RDPtr = StarShipPtr->RaceDescPtr; Frame = RDPtr->ship_data.captain_control.background; if (Frame) { Frame = SetAbsFrameIndex (Frame, 0); RDPtr->ship_data.captain_control.background = Frame; Frame = SetRelFrameIndex (Frame, 1); RDPtr->ship_data.captain_control.turn = Frame; Frame = SetRelFrameIndex (Frame, 5); RDPtr->ship_data.captain_control.thrust = Frame; Frame = SetRelFrameIndex (Frame, 3); RDPtr->ship_data.captain_control.weapon = Frame; Frame = SetRelFrameIndex (Frame, 3); RDPtr->ship_data.captain_control.special = Frame; } BatchGraphics (); assert (StarShipPtr->playerNr >= 0); y_offs = status_y_offsets[StarShipPtr->playerNr]; r.corner.x = CAPTAIN_XOFFS - 2; r.corner.y = y_offs + SHIP_INFO_HEIGHT; r.extent.width = STATUS_WIDTH - CAPTAIN_XOFFS; r.extent.height = SHIP_STATUS_HEIGHT - CAPTAIN_YOFFS + 2; SetContextForeGroundColor ( BUILD_COLOR (MAKE_RGB15 (0x0A, 0x0A, 0x0A), 0x08)); DrawFilledRectangle (&r); SetContextForeGroundColor ( BUILD_COLOR (MAKE_RGB15 (0x08, 0x08, 0x08), 0x1F)); r.corner.x = 1; r.corner.y = y_offs + SHIP_INFO_HEIGHT; r.extent.width = 1; r.extent.height = (SHIP_STATUS_HEIGHT - SHIP_INFO_HEIGHT - 2); DrawFilledRectangle (&r); r.corner.x = 0; ++r.extent.height; DrawFilledRectangle (&r); SetContextForeGroundColor ( BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19)); r.corner.x = STATUS_WIDTH - 1; r.corner.y = y_offs + SHIP_INFO_HEIGHT; r.extent.width = 1; r.extent.height = SHIP_STATUS_HEIGHT - SHIP_INFO_HEIGHT; DrawFilledRectangle (&r); r.corner.x = STATUS_WIDTH - 2; DrawFilledRectangle (&r); r.corner.x = 1; r.extent.width = STATUS_WIDTH - 2; r.corner.y = y_offs + (SHIP_STATUS_HEIGHT - 2); r.extent.height = 1; DrawFilledRectangle (&r); r.corner.x = 0; ++r.extent.width; ++r.corner.y; DrawFilledRectangle (&r); y = y_offs + CAPTAIN_YOFFS; SetContextForeGroundColor ( BUILD_COLOR (MAKE_RGB15 (0x08, 0x08, 0x08), 0x1F)); r.corner.x = 59; r.corner.y = y; r.extent.width = 1; r.extent.height = 30; DrawFilledRectangle (&r); r.corner.x = 3; r.corner.y += 30; r.extent.width = 57; r.extent.height = 1; DrawFilledRectangle (&r); SetContextForeGroundColor ( BUILD_COLOR (MAKE_RGB15 (0x10, 0x10, 0x10), 0x19)); r.corner.x = 3; r.extent.width = 57; r.corner.y = y - 1; r.extent.height = 1; DrawFilledRectangle (&r); r.corner.x = 3; r.extent.width = 1; r.corner.y = y; r.extent.height = 30; DrawFilledRectangle (&r); s.frame = RDPtr->ship_data.captain_control.background; s.origin.x = CAPTAIN_XOFFS; s.origin.y = y; DrawStamp (&s); if (StarShipPtr->captains_name_index == 0 && StarShipPtr->playerNr == RPG_PLAYER_NUM) { // This is SIS TEXT t; t.baseline.x = STATUS_WIDTH >> 1; t.baseline.y = y + 6; t.align = ALIGN_CENTER; t.pStr = GLOBAL_SIS (CommanderName); t.CharCount = (COUNT)~0; SetContextForeGroundColor ( BUILD_COLOR (MAKE_RGB15 (0x00, 0x14, 0x00), 0x02)); SetContextFont (TinyFont); font_DrawText (&t); }
static void DrawCargoDisplay (void) { STAMP s; TEXT t; RECT r; COORD cy; COUNT i; r.corner.x = 2; r.extent.width = FIELD_WIDTH + 1; r.corner.y = 20; // XXX: Shouldn't the height be 1 less? This draws the bottom border // 1 pixel too low. Or if not, why do we need another box anyway? r.extent.height = 129 - r.corner.y; DrawStarConBox (&r, 1, SHADOWBOX_MEDIUM_COLOR, SHADOWBOX_DARK_COLOR, TRUE, CARGO_BACK_COLOR); // draw the "CARGO" title SetContextFont (StarConFont); t.baseline.x = (STATUS_WIDTH >> 1) - 1; t.baseline.y = 27; t.align = ALIGN_CENTER; t.pStr = GAME_STRING (CARGO_STRING_BASE); t.CharCount = (COUNT)~0; SetContextForeGroundColor (CARGO_SELECTED_AMOUNT_COLOR); font_DrawText (&t); SetContextFont (TinyFont); s.frame = SetAbsFrameIndex (MiscDataFrame, (NUM_SCANDOT_TRANSITIONS * 2) + 3); r.corner.x = ELEMENT_COL_0; r.extent = GetFrameBounds (s.frame); s.origin.x = r.corner.x + (r.extent.width >> 1); cy = ELEMENT_ORG_Y; // print element column headings t.align = ALIGN_RIGHT; t.baseline.y = cy - 1; t.CharCount = (COUNT)~0; SetContextForeGroundColor (CARGO_WORTH_COLOR); t.baseline.x = ELEMENT_COL_1; t.pStr = "$"; font_DrawText (&t); t.baseline.x = ELEMENT_COL_2; t.pStr = "#"; font_DrawText (&t); // draw element icons and print amounts for (i = 0; i < NUM_ELEMENT_CATEGORIES; ++i, cy += ELEMENT_SPACING_Y) { // erase background under an element icon SetContextForeGroundColor (BLACK_COLOR); r.corner.y = cy; DrawFilledRectangle (&r); // draw an element icon s.origin.y = r.corner.y + (r.extent.height >> 1); DrawStamp (&s); s.frame = SetRelFrameIndex (s.frame, 5); DrawElementAmount (i, false); } // erase background under the Bio icon SetContextForeGroundColor (BLACK_COLOR); r.corner.y = BIO_ORG_Y; DrawFilledRectangle (&r); // draw the Bio icon s.origin.y = r.corner.y + (r.extent.height >> 1); s.frame = SetAbsFrameIndex (s.frame, 68); DrawStamp (&s); // print the Bio amount DrawElementAmount (NUM_ELEMENT_CATEGORIES, false); // draw the line over the Bio amount r.corner.x = 4; r.corner.y = BIO_ORG_Y - 2; r.extent.width = FIELD_WIDTH - 3; r.extent.height = 1; SetContextForeGroundColor (CARGO_SELECTED_BACK_COLOR); DrawFilledRectangle (&r); // print "Free" t.baseline.x = 5; t.baseline.y = FREE_ORG_Y + TEXT_BASELINE; t.align = ALIGN_LEFT; t.pStr = GAME_STRING (CARGO_STRING_BASE + 1); t.CharCount = (COUNT)~0; font_DrawText (&t); ShowRemainingCapacity (); }