Example #1
0
void DrawKey(UIObject *o, GraphicsDevice *g, Vec2i pos, void *vData)
{
	UNUSED(g);
	EditorBrushAndCampaign *data = vData;
	PicPaletted *keyPic = PicManagerGetOldPic(
		&gPicManager,
		cGeneralPics[gMission.keyPics[data->Brush.ItemIndex]].picIndex);
	pos = Vec2iAdd(Vec2iAdd(pos, o->Pos), Vec2iScaleDiv(o->Size, 2));
	DrawTPic(pos.x, pos.y, keyPic);
}
Example #2
0
void MenuDisplayItems(MenuSystem *ms)
{
	int d = ms->current->u.normal.displayItems;
	if ((d & MENU_DISPLAY_ITEMS_CREDITS) && ms->creditsDisplayer != NULL)
	{
		ShowCredits(ms->creditsDisplayer);
	}
	if (d & MENU_DISPLAY_ITEMS_AUTHORS)
	{
		PicPaletted *logo = PicManagerGetOldPic(&gPicManager, PIC_LOGO);
		DrawTPic(
			MS_CENTER_X(*ms, logo->w),
			ms->pos.y + ms->size.y / 12,
			logo);
		DrawTextStringSpecial(
			"Version: " CDOGS_SDL_VERSION, TEXT_TOP | TEXT_RIGHT,
			ms->pos,
			ms->size,
			Vec2iNew(20, 20));
	}
}
Example #3
0
static void MenuDisplayItems(const MenuSystem *ms)
{
	int d = ms->current->u.normal.displayItems;
	if ((d & MENU_DISPLAY_ITEMS_CREDITS) && ms->creditsDisplayer != NULL)
	{
		ShowCredits(ms->creditsDisplayer);
	}
	if (d & MENU_DISPLAY_ITEMS_AUTHORS)
	{
		PicPaletted *logo = PicManagerGetOldPic(&gPicManager, PIC_LOGO);
		DrawTPic(
			MS_CENTER_X(*ms, logo->w),
			ms->pos.y + ms->size.y / 12,
			logo);

		FontOpts opts = FontOptsNew();
		opts.HAlign = ALIGN_END;
		opts.Area = ms->size;
		opts.Pad = Vec2iNew(20, 20);
		FontStrOpt("Version: " CDOGS_SDL_VERSION, ms->pos, opts);
	}
}
Example #4
0
void PicManagerGenerateOldPics(PicManager *pm, GraphicsDevice *g)
{
	int i;
	// Convert old pics into new format ones
	// TODO: this is wasteful; better to eliminate old pics altogether
	// Note: always need to reload in editor since colours could change,
	// requiring an updating of palettes
	for (i = 0; i < PIC_MAX; i++)
	{
		PicPaletted *oldPic = PicManagerGetOldPic(pm, i);
		if (PicIsNotNone(&pm->picsFromOld[i]))
		{
			PicFree(&pm->picsFromOld[i]);
		}
		if (oldPic == NULL)
		{
			memcpy(&pm->picsFromOld[i], &picNone, sizeof picNone);
		}
		else
		{
			PicFromPicPaletted(g, &pm->picsFromOld[i], oldPic);
		}
	}
}
Example #5
0
static void DrawObjectiveInfo(
	const struct MissionOptions *mo, const int idx, const Vec2i pos)
{
	const MissionObjective *mobj =
		CArrayGet(&mo->missionData->Objectives, idx);
	const struct Objective *o = CArrayGet(&mo->Objectives, idx);
	const CharacterStore *store = &gCampaign.Setting.characters;

	switch (mobj->Type)
	{
	case OBJECTIVE_KILL:
		{
			const Character *cd = CArrayGet(
				&store->OtherChars, CharacterStoreGetSpecialId(store, 0));
			const int i = cd->looks.face;
			TOffsetPic pic;
			pic.picIndex = cHeadPic[i][DIRECTION_DOWN][STATE_IDLE];
			pic.dx = cHeadOffset[i][DIRECTION_DOWN].dx;
			pic.dy = cHeadOffset[i][DIRECTION_DOWN].dy;
			DrawTTPic(
				pos.x + pic.dx, pos.y + pic.dy,
				PicManagerGetOldPic(&gPicManager, pic.picIndex), &cd->table);
		}
		break;
	case OBJECTIVE_RESCUE:
		{
			const Character *cd = CArrayGet(
				&store->OtherChars, CharacterStoreGetPrisonerId(store, 0));
			const int i = cd->looks.face;
			TOffsetPic pic;
			pic.picIndex = cHeadPic[i][DIRECTION_DOWN][STATE_IDLE];
			pic.dx = cHeadOffset[i][DIRECTION_DOWN].dx;
			pic.dy = cHeadOffset[i][DIRECTION_DOWN].dy;
			DrawTTPic(
				pos.x + pic.dx, pos.y + pic.dy,
				PicManagerGetOldPic(&gPicManager, pic.picIndex), &cd->table);
		}
		break;
	case OBJECTIVE_COLLECT:
		{
			const Pic *p = PicManagerGetFromOld(
				&gPicManager, cGeneralPics[o->pickupItem].picIndex);
			Blit(&gGraphicsDevice, p, Vec2iAdd(pos, p->offset));
		}
		break;
	case OBJECTIVE_DESTROY:
		{
			Vec2i picOffset;
			const Pic *p = MapObjectGetPic(
				MapObjectGet(mobj->Index), &gPicManager, &picOffset);
			Blit(&gGraphicsDevice, p, Vec2iAdd(pos, picOffset));
		}
		break;
	case OBJECTIVE_INVESTIGATE:
		// Don't draw
		return;
	default:
		CASSERT(false, "Unknown objective type");
		return;
	}
}
Example #6
0
void DrawCharacterSimple(
	Character *c, Vec2i pos,
	direction_e dir, int state,
	int gunPic, gunstate_e gunState, TranslationTable *table)
{
	TOffsetPic body, head, gun;
	TOffsetPic pic1, pic2, pic3;
	direction_e headDir = dir;
	int headState = state;
	if (gunState == GUNSTATE_FIRING || gunState == GUNSTATE_RECOIL)
	{
		headState = STATE_COUNT + gunState - GUNSTATE_FIRING;
	}
	if (state == STATE_IDLELEFT)
	{
		headDir = (direction_e)((dir + 7) % 8);
	}
	else if (state == STATE_IDLERIGHT)
	{
		headDir = (direction_e)((dir + 1) % 8);
	}

	int bodyType = gunPic < 0 ? BODY_UNARMED : BODY_ARMED;

	body.dx = cBodyOffset[bodyType][dir].dx;
	body.dy = cBodyOffset[bodyType][dir].dy;
	body.picIndex = cBodyPic[bodyType][dir][state];

	head.dx =
		cNeckOffset[bodyType][headDir].dx +
		cHeadOffset[c->looks.face][headDir].dx;
	head.dy =
		cNeckOffset[bodyType][headDir].dy +
		cHeadOffset[c->looks.face][headDir].dy;
	head.picIndex = cHeadPic[c->looks.face][headDir][headState];

	gun.picIndex = -1;
	if (gunPic >= 0)
	{
		gun.dx =
		    cGunHandOffset[bodyType][dir].dx +
		    cGunPics[gunPic][dir][gunState].dx;
		gun.dy =
		    cGunHandOffset[bodyType][dir].dy +
		    cGunPics[gunPic][dir][gunState].dy;
		gun.picIndex = cGunPics[gunPic][dir][gunState].picIndex;
	}

	switch (dir)
	{
	case DIRECTION_UP:
	case DIRECTION_UPRIGHT:
		pic1 = gun;
		pic2 = head;
		pic3 = body;
		break;

	case DIRECTION_RIGHT:
	case DIRECTION_DOWNRIGHT:
	case DIRECTION_DOWN:
	case DIRECTION_DOWNLEFT:
		pic1 = body;
		pic2 = head;
		pic3 = gun;
		break;

	case DIRECTION_LEFT:
	case DIRECTION_UPLEFT:
		pic1 = gun;
		pic2 = body;
		pic3 = head;
		break;
	default:
		assert(0 && "invalid direction");
		return;
	}

	if (pic1.picIndex >= 0)
	{
		BlitOld(
			pos.x + pic1.dx, pos.y + pic1.dy,
			PicManagerGetOldPic(&gPicManager, pic1.picIndex),
			table, BLIT_TRANSPARENT);
	}
	if (pic2.picIndex >= 0)
	{
		BlitOld(
			pos.x + pic2.dx, pos.y + pic2.dy,
			PicManagerGetOldPic(&gPicManager, pic2.picIndex),
			table, BLIT_TRANSPARENT);
	}
	if (pic3.picIndex >= 0)
	{
		BlitOld(
			pos.x + pic3.dx, pos.y + pic3.dy,
			PicManagerGetOldPic(&gPicManager, pic3.picIndex),
			table, BLIT_TRANSPARENT);
	}
}
Example #7
0
static void DrawWallsAndThings(DrawBuffer *b, Vec2i offset)
{
	Vec2i pos;
	Tile *tile = &b->tiles[0][0];
	pos.y = b->dy + cWallOffset.dy + offset.y;
	for (int y = 0; y < Y_TILES; y++, pos.y += TILE_HEIGHT)
	{
		TTileItem *displayList = NULL;
		pos.x = b->dx + cWallOffset.dx + offset.x;
		for (int x = 0; x < b->Size.x; x++, tile++, pos.x += TILE_WIDTH)
		{
			if (tile->flags & MAPTILE_IS_WALL)
			{
				if (!(tile->flags & MAPTILE_DELAY_DRAW))
				{
					DrawWallColumn(y, pos, tile);
				}
			}
			else if (tile->flags & MAPTILE_OFFSET_PIC)
			{
				// Drawing doors
				BlitMasked(
					&gGraphicsDevice,
					&tile->picAlt,
					pos,
					GetTileLOSMask(tile),
					0);
			}
			if (!(tile->flags & MAPTILE_OUT_OF_SIGHT))
			{
				// Draw the items that are in LOS
				for (int i = 0; i < (int)tile->things.size; i++)
				{
					TTileItem *ti =
						ThingIdGetTileItem(CArrayGet(&tile->things, i));
					if (!(ti->flags & TILEITEM_IS_WRECK))
					{
						AddItemToDisplayList(ti, &displayList);
					}
				}
			}
		}
		for (TTileItem *t = displayList; t; t = t->nextToDisplay)
		{
			Vec2i picPos = Vec2iNew(
				t->x - b->xTop + offset.x, t->y - b->yTop + offset.y);
			if (t->getPicFunc)
			{
				Vec2i picOffset;
				const Pic *pic = t->getPicFunc(t->id, &picOffset);
				Blit(&gGraphicsDevice, pic, Vec2iAdd(picPos, picOffset));
			}
			else if (t->getActorPicsFunc)
			{
				ActorPics pics = t->getActorPicsFunc(t->id);
				if (pics.IsDead)
				{
					if (pics.IsDying)
					{
						int pic = pics.OldPics[0];
						if (pic == 0)
						{
							continue;
						}
						if (pics.IsTransparent)
						{
							DrawBTPic(
								&gGraphicsDevice,
								PicManagerGetFromOld(&gPicManager, pic),
								Vec2iAdd(picPos, pics.Pics[0].offset),
								pics.Tint);
						}
						else
						{
							DrawTTPic(
								picPos.x + pics.Pics[0].offset.x,
								picPos.y + pics.Pics[0].offset.y,
								PicManagerGetOldPic(&gPicManager, pic),
								pics.Table);
						}
					}
				}
				else if (pics.IsTransparent)
				{
					for (int i = 0; i < 3; i++)
					{
						Pic *oldPic = PicManagerGetFromOld(
							&gPicManager, pics.OldPics[i]);
						if (oldPic == NULL)
						{
							continue;
						}
						DrawBTPic(
							&gGraphicsDevice,
							oldPic,
							Vec2iAdd(picPos, pics.Pics[i].offset),
							pics.Tint);
					}
				}
				else
				{
					DrawShadow(&gGraphicsDevice, picPos, Vec2iNew(8, 6));
					for (int i = 0; i < 3; i++)
					{
						PicPaletted *oldPic = PicManagerGetOldPic(
							&gPicManager, pics.OldPics[i]);
						if (oldPic == NULL)
						{
							continue;
						}
						BlitOld(
							picPos.x + pics.Pics[i].offset.x,
							picPos.y + pics.Pics[i].offset.y,
							oldPic,
							pics.Table, BLIT_TRANSPARENT);
					}
				}
			}
			else
			{
				(*(t->drawFunc))(picPos, &t->drawData);
			}
		}
		tile += X_TILES - b->Size.x;
	}
}
Example #8
0
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);
}
Example #9
0
static void DrawActorPics(const TTileItem *t, const Vec2i picPos)
{
    const ActorPics pics = t->getActorPicsFunc(t->id);
    if (pics.IsDead)
    {
        if (pics.IsDying)
        {
            int pic = pics.OldPics[0];
            if (pic == 0)
            {
                return;
            }
            if (pics.IsTransparent)
            {
                DrawBTPic(
                    &gGraphicsDevice,
                    PicManagerGetFromOld(&gPicManager, pic),
                    Vec2iAdd(picPos, pics.Pics[0].offset),
                    pics.Tint);
            }
            else
            {
                DrawTTPic(
                    picPos.x + pics.Pics[0].offset.x,
                    picPos.y + pics.Pics[0].offset.y,
                    PicManagerGetOldPic(&gPicManager, pic),
                    pics.Table);
            }
        }
    }
    else if (pics.IsTransparent)
    {
        for (int i = 0; i < 3; i++)
        {
            Pic *oldPic = PicManagerGetFromOld(
                              &gPicManager, pics.OldPics[i]);
            if (oldPic == NULL)
            {
                continue;
            }
            DrawBTPic(
                &gGraphicsDevice,
                oldPic,
                Vec2iAdd(picPos, pics.Pics[i].offset),
                pics.Tint);
        }
    }
    else
    {
        DrawShadow(&gGraphicsDevice, picPos, Vec2iNew(8, 6));
        for (int i = 0; i < 3; i++)
        {
            PicPaletted *oldPic = PicManagerGetOldPic(
                                      &gPicManager, pics.OldPics[i]);
            if (oldPic == NULL)
            {
                continue;
            }
            BlitOld(
                picPos.x + pics.Pics[i].offset.x,
                picPos.y + pics.Pics[i].offset.y,
                oldPic,
                pics.Table, BLIT_TRANSPARENT);
        }

        const TActor *a = CArrayGet(&gActors, t->id);

        // Draw weapon indicators
        if (ConfigGetEnum(&gConfig, "Game.LaserSight") == LASER_SIGHT_ALL ||
                (ConfigGetEnum(&gConfig, "Game.LaserSight") == LASER_SIGHT_PLAYERS && a->PlayerUID >= 0))
        {
            DrawLaserSight(a, picPos);
        }
    }
}