static void MakeBackground(GraphicsDevice *g, int buildTables) { if (buildTables) { // Automatically pan camera to middle of screen Mission *m = gMission.missionData; Vec2i focusTile = Vec2iScaleDiv(m->Size, 2); // Better yet, if the map has a known start position, focus on that if (m->Type == MAPTYPE_STATIC && !Vec2iEqual(m->u.Static.Start, Vec2iZero())) { focusTile = m->u.Static.Start; } camera = Vec2iCenterOfTile(focusTile); } // Clear background first for (int i = 0; i < GraphicsGetScreenSize(&g->cachedConfig); i++) { g->buf[i] = PixelFromColor(g, colorBlack); } GrafxDrawExtra extra; extra.guideImage = brush.GuideImageSurface; extra.guideImageAlpha = brush.GuideImageAlpha; DrawBufferTerminate(&sDrawBuffer); DrawBufferInit(&sDrawBuffer, Vec2iNew(X_TILES, Y_TILES), &gGraphicsDevice); GrafxMakeBackground( g, &sDrawBuffer, &gCampaign, &gMission, &gMap, tintNone, 1, buildTables, camera, &extra); }
void ClearScreen(GraphicsDevice *g) { color_t color = { 32, 32, 60, 255 }; const Uint32 pixel = COLOR2PIXEL(color); for (int i = 0; i < GraphicsGetScreenSize(&g->cachedConfig); i++) { g->buf[i] = pixel; } }
void ClearScreen(GraphicsDevice *g) { color_t color = { 32, 32, 60, 255 }; Uint32 pixel = PixelFromColor(&gGraphicsDevice, color); for (int i = 0; i < GraphicsGetScreenSize(&g->cachedConfig); i++) { g->buf[i] = pixel; } }
static void Display(GraphicsDevice *g, int yc, HandleInputResult result) { char s[128]; int y = 5; int i; int w = g->cachedConfig.Res.x; int h = g->cachedConfig.Res.y; Mission *mission = CampaignGetCurrentMission(&gCampaign); if (mission) { // Re-make the background if the resolution has changed if (gEventHandlers.HasResolutionChanged) { MakeBackground(g, 0); } if (result.RemakeBg || brush.IsGuideImageNew) { // Clear background first for (i = 0; i < GraphicsGetScreenSize(&g->cachedConfig); i++) { g->buf[i] = PixelFromColor(g, colorBlack); } brush.IsGuideImageNew = false; GrafxDrawExtra extra; extra.guideImage = brush.GuideImageSurface; extra.guideImageAlpha = brush.GuideImageAlpha; GrafxDrawBackground(g, &sDrawBuffer, tintNone, camera, &extra); } GraphicsBlitBkg(g); // Draw brush highlight tiles if (brush.IsActive && IsBrushPosValid(brush.Pos, mission)) { EditorBrushSetHighlightedTiles(&brush); } for (i = 0; i < (int)brush.HighlightedTiles.size; i++) { Vec2i *pos = CArrayGet(&brush.HighlightedTiles, i); Vec2i screenPos = GetScreenPos(*pos); if (screenPos.x >= 0 && screenPos.x < w && screenPos.y >= 0 && screenPos.y < h) { DrawRectangle( g, screenPos, Vec2iNew(TILE_WIDTH, TILE_HEIGHT), colorWhite, DRAW_FLAG_LINE); } } sprintf( s, "Mission %d/%d", gCampaign.MissionIndex + 1, (int)gCampaign.Setting.Missions.size); TextStringMasked(&gTextManager, s, g, Vec2iNew(270, y), yc == YC_MISSIONINDEX ? colorRed : colorWhite); if (brush.LastPos.x) { sprintf(s, "(%d, %d)", brush.Pos.x, brush.Pos.y); TextString(&gTextManager, s, g, Vec2iNew(w - 40, h - 16)); } } else { ClearScreen(g); if (gCampaign.Setting.Missions.size) { sprintf(s, "End/%d", (int)gCampaign.Setting.Missions.size); TextStringMasked(&gTextManager, s, g, Vec2iNew(270, y), yc == YC_MISSIONINDEX ? colorRed : colorWhite); } } if (fileChanged) { DrawTPic(10, y, PicManagerGetOldPic(&gPicManager, 221)); } TextString(&gTextManager, "Press F1 for help", g, Vec2iNew(20, h - 20 - CDogsTextHeight())); y = 150; UIObjectDraw( sObjs, g, Vec2iZero(), gEventHandlers.mouse.currentPos, &sDrawObjs); if (result.WillDisplayAutomap && mission) { AutomapDraw(AUTOMAP_FLAGS_SHOWALL, true); } else { if (sTooltipObj && sTooltipObj->Tooltip) { UITooltipDraw( g, gEventHandlers.mouse.currentPos, sTooltipObj->Tooltip); } MouseDraw(&gEventHandlers.mouse); } BlitFlip(g, &gConfig.Graphics); }
int GraphicsGetMemSize(GraphicsConfig *config) { return GraphicsGetScreenSize(config) * sizeof(Uint32); }
void CameraDraw( Camera *camera, const input_device_e pausingDevice, const bool controllerUnplugged) { Vec2i centerOffset = Vec2iZero(); const int numLocalPlayersAlive = GetNumPlayers(PLAYER_ALIVE_OR_DYING, false, true); const int numLocalPlayers = GetNumPlayers(PLAYER_ANY, false, true); const int w = gGraphicsDevice.cachedConfig.Res.x; const int h = gGraphicsDevice.cachedConfig.Res.y; for (int i = 0; i < GraphicsGetScreenSize(&gGraphicsDevice.cachedConfig); i++) { gGraphicsDevice.buf[i] = COLOR2PIXEL(colorBlack); } const Vec2i noise = ScreenShakeGetDelta(camera->shake); GraphicsResetBlitClip(&gGraphicsDevice); if (numLocalPlayersAlive == 0) { // Count the number of local players with lives left // If there are none, then try to spectate if there are remote players int firstRemotePlayerUID = -1; bool hasLocalPlayerLives = false; CA_FOREACH(const PlayerData, p, gPlayerDatas) if (p->Lives > 0) { if (p->IsLocal) { hasLocalPlayerLives = true; break; } else { firstRemotePlayerUID = p->UID; } } CA_FOREACH_END() if (!hasLocalPlayerLives) { if (camera->spectateMode == SPECTATE_NONE) { // Enter spectator mode // If there are remote players, follow them if (firstRemotePlayerUID != -1) { camera->spectateMode = SPECTATE_FOLLOW; camera->FollowPlayerUID = firstRemotePlayerUID; } else { // Free-look mode camera->spectateMode = SPECTATE_FREE; } } } else { // Don't spectate camera->spectateMode = SPECTATE_NONE; } if (camera->spectateMode == SPECTATE_FOLLOW) { FollowPlayer(&camera->lastPosition, camera->FollowPlayerUID); } DoBuffer( &camera->Buffer, camera->lastPosition, X_TILES, noise, centerOffset); SoundSetEars(camera->lastPosition); }
static void Display(CampaignSettingNew *setting, int idx, int xc, int yc) { int x, y = 10; char s[50]; const Character *b; int i; int tag; for (i = 0; i < GraphicsGetScreenSize(&gGraphicsDevice.cachedConfig); i++) { gGraphicsDevice.buf[i] = LookupPalette(74); } sprintf(s, "%d", setting->characters.otherCount); CDogsTextStringAt(10, 190, s); if (idx >= 0 && idx < setting->characters.otherCount) { b = &setting->characters.others[idx]; DisplayCDogsText(30, y, "Face", yc == YC_APPEARANCE && xc == XC_FACE); DisplayCDogsText(60, y, "Skin", yc == YC_APPEARANCE && xc == XC_SKIN); DisplayCDogsText(90, y, "Hair", yc == YC_APPEARANCE && xc == XC_HAIR); DisplayCDogsText(120, y, "Body", yc == YC_APPEARANCE && xc == XC_BODY); DisplayCDogsText(150, y, "Arms", yc == YC_APPEARANCE && xc == XC_ARMS); DisplayCDogsText(180, y, "Legs", yc == YC_APPEARANCE && xc == XC_LEGS); y += CDogsTextHeight(); sprintf(s, "Speed: %d%%", (100 * b->speed) / 256); DisplayCDogsText(20, y, s, yc == YC_ATTRIBUTES && xc == XC_SPEED); sprintf(s, "Hp: %d", b->maxHealth); DisplayCDogsText(70, y, s, yc == YC_ATTRIBUTES && xc == XC_HEALTH); sprintf(s, "Move: %d%%", b->bot.probabilityToMove); DisplayCDogsText(120, y, s, yc == YC_ATTRIBUTES && xc == XC_MOVE); sprintf(s, "Track: %d%%", b->bot.probabilityToTrack); DisplayCDogsText(170, y, s, yc == YC_ATTRIBUTES && xc == XC_TRACK); sprintf(s, "Shoot: %d%%", b->bot.probabilityToShoot); DisplayCDogsText(220, y, s, yc == YC_ATTRIBUTES && xc == XC_SHOOT); sprintf(s, "Delay: %d", b->bot.actionDelay); DisplayCDogsText(270, y, s, yc == YC_ATTRIBUTES && xc == XC_DELAY); y += CDogsTextHeight(); DisplayFlag(5, y, "Asbestos", (b->flags & FLAGS_ASBESTOS) != 0, yc == YC_FLAGS && xc == XC_ASBESTOS); DisplayFlag(50, y, "Immunity", (b->flags & FLAGS_IMMUNITY) != 0, yc == YC_FLAGS && xc == XC_IMMUNITY); DisplayFlag(95, y, "C-thru", (b->flags & FLAGS_SEETHROUGH) != 0, yc == YC_FLAGS && xc == XC_SEETHROUGH); DisplayFlag(140, y, "Run-away", (b->flags & FLAGS_RUNS_AWAY) != 0, yc == YC_FLAGS && xc == XC_RUNS_AWAY); DisplayFlag(185, y, "Sneaky", (b->flags & FLAGS_SNEAKY) != 0, yc == YC_FLAGS && xc == XC_SNEAKY); DisplayFlag(230, y, "Good guy", (b->flags & FLAGS_GOOD_GUY) != 0, yc == YC_FLAGS && xc == XC_GOOD_GUY); DisplayFlag(275, y, "Asleep", (b->flags & FLAGS_SLEEPALWAYS) != 0, yc == YC_FLAGS && xc == XC_SLEEPING); y += CDogsTextHeight(); DisplayFlag(5, y, "Prisoner", (b->flags & FLAGS_PRISONER) != 0, yc == YC_FLAGS2 && xc == XC_PRISONER); DisplayFlag(50, y, "Invuln.", (b->flags & FLAGS_INVULNERABLE) != 0, yc == YC_FLAGS2 && xc == XC_INVULNERABLE); DisplayFlag(95, y, "Follower", (b->flags & FLAGS_FOLLOWER) != 0, yc == YC_FLAGS2 && xc == XC_FOLLOWER); DisplayFlag(140, y, "Penalty", (b->flags & FLAGS_PENALTY) != 0, yc == YC_FLAGS2 && xc == XC_PENALTY); DisplayFlag(185, y, "Victim", (b->flags & FLAGS_VICTIM) != 0, yc == YC_FLAGS2 && xc == XC_VICTIM); DisplayFlag(230, y, "Awake", (b->flags & FLAGS_AWAKEALWAYS) != 0, yc == YC_FLAGS2 && xc == XC_AWAKE); y += CDogsTextHeight(); DisplayCDogsText(50, y, GunGetName(b->gun), yc == YC_WEAPON); y += CDogsTextHeight() + 5; x = 10; for (i = 0; i < setting->characters.otherCount; i++) { DisplayCharacter( x, y + 20, &setting->characters.others[i], idx == i, 0); x += 20; if (x > gGraphicsDevice.cachedConfig.ResolutionWidth) { x = 10; y += 30; } } } if (MouseTryGetRectTag(&gInputDevices.mouse, &tag)) { int mouseYc = tag & 0xFF; int mouseXc = (tag & 0xFF00) >> 8; Vec2i tooltipPos = Vec2iAdd( gInputDevices.mouse.currentPos, Vec2iNew(10, 10)); DrawTooltips(&gGraphicsDevice, tooltipPos, yc, xc, mouseYc, mouseXc); }