Esempio n. 1
0
void TextChar(char c)
{
    int i = CHAR_INDEX(c);
    if (i >= 0 && i <= CHARS_IN_FONT && font[i]) {
        DrawTPic(xText, yText, font[i], compiledFont[i]);
        xText += 1 + PicWidth(font[i]) + dxText;
    } else {
        i = CHAR_INDEX('.');
        DrawTPic(xText, yText, font[i], compiledFont[i]);
        xText += 1 + PicWidth(font[i]) + dxText;
    }
}
Esempio n. 2
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);
}
Esempio n. 3
0
static int SelectMain(int cmd)
{
	static int index = 0;

	if (cmd == CMD_ESC) {
		if (index != MODE_QUIT)
			index = MODE_QUIT;
		else
			return MODE_QUIT;
	}
	if (AnyButton(cmd)) {
		switch (index) {
		case 0:
			gCampaign.dogFight = 0;
			gOptions.twoPlayers = 0;
			return MODE_CAMPAIGN;
		case 1:
			gCampaign.dogFight = 0;
			gOptions.twoPlayers = 1;
			return MODE_CAMPAIGN;
		case 2:
			gCampaign.dogFight = 1;
			return MODE_DOGFIGHT;
		}
		return index;
	}
	if (Left(cmd) || Up(cmd)) {
		index--;
		if (index < 0)
			index = MAIN_COUNT - 1;
		PlaySound(SND_SWITCH, 0, 255);
	} else if (Right(cmd) || Down(cmd)) {
		index++;
		if (index >= MAIN_COUNT)
			index = 0;
		PlaySound(SND_SWITCH, 0, 255);
	}

	DrawTPic((SCREEN_WIDTH - PicWidth(gPics[PIC_LOGO])) / 2, (SCREEN_HEIGHT / 12), gPics[PIC_LOGO], gCompiledPics[PIC_LOGO]);

	TextStringSpecial("Classic: " CDOGS_VERSION, TEXT_TOP | TEXT_LEFT, 20, 20);
	TextStringSpecial("SDL Port:  " CDOGS_SDL_VERSION, TEXT_TOP | TEXT_RIGHT, 20, 20);

	DisplayMenuAtCenter(mainMenu, MAIN_COUNT, index);
	
	return MODE_MAIN;
}
Esempio n. 4
0
void DisplayMapItem(int x, int y, TMapObject * mo, int density, int hilite)
{
	char s[10];

	TOffsetPic *pic = &cGeneralPics[mo->pic];
	DrawTPic(x + pic->dx, y + pic->dy, gPics[pic->picIndex], NULL);

	if (hilite) {
		TextGoto(x - 8, y - 4);
		TextChar('\020');
	}
	sprintf(s, "%d", density);
	TextGoto(x - 8, y + 5);
	TextString(s);

	SetSecondaryMouseRects(localMapItemClicks);
}
Esempio n. 5
0
void MenuDisplayItems(MenuSystem *menu)
{
	int d = menu->current->u.normal.displayItems;
	if ((d & MENU_DISPLAY_ITEMS_CREDITS) && menu->creditsDisplayer != NULL)
	{
		ShowCredits(menu->creditsDisplayer);
	}
	if (d & MENU_DISPLAY_ITEMS_AUTHORS)
	{
		DrawTPic(
			(gGraphicsDevice.cachedConfig.ResolutionWidth - PicWidth(gPics[PIC_LOGO])) / 2,
			gGraphicsDevice.cachedConfig.ResolutionHeight / 12,
			gPics[PIC_LOGO],
			gCompiledPics[PIC_LOGO]);
		CDogsTextStringSpecial(
			"Classic: " CDOGS_VERSION, TEXT_TOP | TEXT_LEFT, 20, 20);
		CDogsTextStringSpecial(
			"SDL Port: " CDOGS_SDL_VERSION, TEXT_TOP | TEXT_RIGHT, 20, 20);
	}
}
Esempio n. 6
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));
	}
}
Esempio n. 7
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);
	}
}
Esempio n. 8
0
void DrawCursor(int x, int y)
{
	DrawTPic(x, y, gPics[145], NULL);
}
Esempio n. 9
0
void Display(int index, int xc, int yc, int key)
{
	char s[128];
	int y = 5;
	int i;

	SetSecondaryMouseRects(NULL);
	memset(GetDstScreen(), 58, 64000);

	sprintf(s, "Key: 0x%x", key);
	TextStringAt(270, 190, s);

	DisplayText(25, y, campaign.title, yc == YC_CAMPAIGNTITLE
		    && xc == XC_CAMPAIGNTITLE, 1);

	if (fileChanged)
		DrawTPic(10, y, gPics[221], NULL);

	if (currentMission) {
		sprintf(s, "Mission %d/%d", index + 1,
			campaign.missionCount);
		DisplayText(270, y, s, yc == YC_MISSIONINDEX, 0);

		y += TextHeight() + 3;
		DisplayText(25, y, currentMission->title,
			    yc == YC_MISSIONTITLE
			    && xc == XC_MISSIONTITLE, 1);

		y += TextHeight() + 2;

		sprintf(s, "Width: %d", currentMission->mapWidth);
		DisplayText(20, y, s, yc == YC_MISSIONPROPS
			    && xc == XC_WIDTH, 0);

		sprintf(s, "Height: %d", currentMission->mapHeight);
		DisplayText(60, y, s, yc == YC_MISSIONPROPS
			    && xc == XC_HEIGHT, 0);

		sprintf(s, "Walls: %d", currentMission->wallCount);
		DisplayText(100, y, s, yc == YC_MISSIONPROPS
			    && xc == XC_WALLCOUNT, 0);

		sprintf(s, "Len: %d", currentMission->wallLength);
		DisplayText(140, y, s, yc == YC_MISSIONPROPS
			    && xc == XC_WALLLENGTH, 0);

		sprintf(s, "Rooms: %d", currentMission->roomCount);
		DisplayText(180, y, s, yc == YC_MISSIONPROPS
			    && xc == XC_ROOMCOUNT, 0);

		sprintf(s, "Sqr: %d", currentMission->squareCount);
		DisplayText(220, y, s, yc == YC_MISSIONPROPS
			    && xc == XC_SQRCOUNT, 0);

		sprintf(s, "Dens: %d", currentMission->baddieDensity);
		DisplayText(260, y, s, yc == YC_MISSIONPROPS
			    && xc == XC_DENSITY, 0);

		y += TextHeight();

		DisplayText(20, y, "Wall", yc == YC_MISSIONLOOKS
			    && xc == XC_WALL, 0);
		DisplayText(50, y, "Floor", yc == YC_MISSIONLOOKS
			    && xc == XC_FLOOR, 0);
		DisplayText(80, y, "Rooms", yc == YC_MISSIONLOOKS
			    && xc == XC_ROOM, 0);
		DisplayText(110, y, "Doors", yc == YC_MISSIONLOOKS
			    && xc == XC_DOORS, 0);
		DisplayText(140, y, "Keys", yc == YC_MISSIONLOOKS
			    && xc == XC_KEYS, 0);
		DisplayText(170, y, "Exit", yc == YC_MISSIONLOOKS
			    && xc == XC_EXIT, 0);

		sprintf(s, "Walls: %s",
			RangeName(currentMission->wallRange));
		DisplayText(200, y, s, yc == YC_MISSIONLOOKS
			    && xc == XC_COLOR1, 0);
		sprintf(s, "Floor: %s",
			RangeName(currentMission->floorRange));
		DisplayText(200, y + TH, s, yc == YC_MISSIONLOOKS
			    && xc == XC_COLOR2, 0);
		sprintf(s, "Rooms: %s",
			RangeName(currentMission->roomRange));
		DisplayText(200, y + 2 * TH, s, yc == YC_MISSIONLOOKS
			    && xc == XC_COLOR3, 0);
		sprintf(s, "Extra: %s",
			RangeName(currentMission->altRange));
		DisplayText(200, y + 3 * TH, s, yc == YC_MISSIONLOOKS
			    && xc == XC_COLOR4, 0);

		DrawPic(20, y + TH,
			gPics[cWallPics
			      [currentMission->wallStyle %
			       WALL_COUNT][WALL_SINGLE]], NULL);
		DrawPic(50, y + TH,
			gPics[cFloorPics
			      [currentMission->floorStyle %
			       FLOOR_COUNT][FLOOR_NORMAL]], NULL);
		DrawPic(80, y + TH,
			gPics[cRoomPics
			      [currentMission->roomStyle %
			       ROOMFLOOR_COUNT][ROOMFLOOR_NORMAL]], NULL);
		DrawPic(110, y + TH,
			gPics[cGeneralPics[gMission.doorPics[0].horzPic].
			      picIndex], NULL);
		DrawTPic(140, y + TH,
			 gPics[cGeneralPics[gMission.keyPics[0]].picIndex],
			 NULL);
		DrawPic(170, y + TH, gPics[gMission.exitPic], NULL);

		y += TH + 25;

		DisplayText(20, y, "Mission description",
			    yc == YC_MISSIONDESC, 0);
		y += TextHeight();

		sprintf(s, "Characters (%d/%d)",
			currentMission->baddieCount, BADDIE_MAX);
		DisplayText(20, y, s, yc == YC_CHARACTERS, 0);
		y += TextHeight();

		sprintf(s, "Mission objective characters (%d/%d)",
			currentMission->specialCount, SPECIAL_MAX);
		DisplayText(20, y, s, yc == YC_SPECIALS, 0);
		y += TextHeight();

		sprintf(s, "Available weapons (%d/%d)",
			gMission.weaponCount, WEAPON_MAX);
		DisplayText(20, y, s, yc == YC_WEAPONS, 0);
		y += TextHeight();

		sprintf(s, "Map items (%d/%d)", gMission.objectCount,
			ITEMS_MAX);
		DisplayText(20, y, s, yc == YC_ITEMS, 0);
		y += TextHeight() + 2;

		if (currentMission->objectiveCount) {
			for (i = 0; i < currentMission->objectiveCount;
			     i++) {
				DisplayText(20, y,
					    currentMission->objectives[i].
					    description,
					    yc - YC_OBJECTIVES == i, 1);
				y += TextHeight();
			}
		} else
			DisplayText(20, y, "-- mission objectives --",
				    yc == YC_OBJECTIVES, 0);
	} else if (campaign.missionCount) {
		sprintf(s, "End/%d", campaign.missionCount);
		DisplayText(270, y, s, yc == YC_MISSIONINDEX, 0);
	}

	y = 170;

	switch (yc) {
	case YC_CAMPAIGNTITLE:
		DisplayText(20, 150, campaign.author,
			    yc == YC_CAMPAIGNTITLE && xc == XC_AUTHOR, 1);
		MissionDescription(150 + TH, campaign.description,
				   yc == YC_CAMPAIGNTITLE
				   && xc == XC_CAMPAIGNDESC);
		SetSecondaryMouseRects(localCampaignClicks);
		break;

	case YC_MISSIONTITLE:
		DisplayText(20, 150, currentMission->song,
			    yc == YC_MISSIONTITLE
			    && xc == XC_MUSICFILE, 1);
		SetSecondaryMouseRects(localMissionClicks);
		break;

	case YC_MISSIONDESC:
		MissionDescription(150, currentMission->description,
				   yc == YC_MISSIONDESC);
		break;

	case YC_CHARACTERS:
		TextStringAt(5, 190,
			     "Use Insert, Delete and PageUp/PageDown");
		if (!currentMission)
			break;
		for (i = 0; i < currentMission->baddieCount; i++)
			DisplayCharacter(20 + 20 * i, y,
					 CHARACTER_OTHERS + i, xc == i);
		SetSecondaryMouseRects(localCharacterClicks);
		break;

	case YC_SPECIALS:
		TextStringAt(5, 190,
			     "Use Insert, Delete and PageUp/PageDown");
		if (!currentMission)
			break;
		for (i = 0; i < currentMission->specialCount; i++)
			DisplayCharacter(20 + 20 * i, y,
					 CHARACTER_OTHERS +
					 currentMission->baddieCount + i,
					 xc == i);
		SetSecondaryMouseRects(localCharacterClicks);
		break;

	case YC_ITEMS:
		TextStringAt(5, 190,
			     "Use Insert, Delete and PageUp/PageDown");
		if (!currentMission)
			break;
		for (i = 0; i < currentMission->itemCount; i++)
			DisplayMapItem(10 + 20 * i, y,
				       gMission.mapObjects[i],
				       currentMission->itemDensity[i],
				       xc == i);
		break;

	case YC_WEAPONS:
		if (!currentMission)
			break;
		ListWeapons(150, xc);
		break;

	default:
		if (currentMission &&
		    yc >= YC_OBJECTIVES
		    && yc - YC_OBJECTIVES <
		    currentMission->objectiveCount) {
			TextStringAt(5, 190,
				     "Use Insert, Delete and PageUp/PageDown");
			DrawObjectiveInfo(yc - YC_OBJECTIVES, y, xc);
		}
		break;
	}

	vsync();
	CopyToScreen();
}
Esempio n. 10
0
void DrawObjectiveInfo(int index, int y, int xc)
{
	TOffsetPic pic;
	TranslationTable *table = NULL;
	int i;
	const char *typeText;
	char s[50];

	switch (currentMission->objectives[index].type) {
	case OBJECTIVE_KILL:
		typeText = "Kill";
		i = characterDesc[currentMission->baddieCount +
				  CHARACTER_OTHERS].facePic;
		table =
		    characterDesc[currentMission->baddieCount +
				  CHARACTER_OTHERS].table;
		pic.picIndex = cHeadPic[i][DIRECTION_DOWN][STATE_IDLE];
		pic.dx = cHeadOffset[i][DIRECTION_DOWN].dx;
		pic.dy = cHeadOffset[i][DIRECTION_DOWN].dy;
		break;
	case OBJECTIVE_RESCUE:
		typeText = "Rescue";
		i = characterDesc[CHARACTER_PRISONER].facePic;
		table = characterDesc[CHARACTER_PRISONER].table;
		pic.picIndex = cHeadPic[i][DIRECTION_DOWN][STATE_IDLE];
		pic.dx = cHeadOffset[i][DIRECTION_DOWN].dx;
		pic.dy = cHeadOffset[i][DIRECTION_DOWN].dy;
		break;
	case OBJECTIVE_COLLECT:
		typeText = "Collect";
		i = gMission.objectives[index].pickupItem;
		pic = cGeneralPics[i];
		break;
	case OBJECTIVE_DESTROY:
		typeText = "Destroy";
		i = gMission.objectives[index].blowupObject->pic;
		pic = cGeneralPics[i];
		break;
	case OBJECTIVE_INVESTIGATE:
		typeText = "Explore";
		break;
	default:
		typeText = "???";
		i = gMission.objectives[i].pickupItem;
		pic = cGeneralPics[i];
	}

	DisplayText(20, y, typeText, xc == XC_TYPE, 0);

	if (currentMission->objectives[index].type !=
	    OBJECTIVE_INVESTIGATE) {
		if (table)
			DrawTTPic(60 + pic.dx, y + 8 + pic.dy,
				  gPics[pic.picIndex], table, NULL);
		else
			DrawTPic(60 + pic.dx, y + 8 + pic.dy,
				 gPics[pic.picIndex], NULL);
	}

	sprintf(s, "%d", currentMission->objectives[index].required);
	DisplayText(90, y, s, xc == XC_REQUIRED, 0);
	sprintf(s, "out of %d", currentMission->objectives[index].count);
	DisplayText(110, y, s, xc == XC_TOTAL, 0);

	sprintf(s, "%s %s %s %s %s",
		(currentMission->objectives[index].
		 flags & OBJECTIVE_HIDDEN) != 0 ? "hidden" : "",
		(currentMission->objectives[index].
		 flags & OBJECTIVE_POSKNOWN) != 0 ? "pos.known" : "",
		(currentMission->objectives[index].
		 flags & OBJECTIVE_HIACCESS) != 0 ? "access" : "",
		(currentMission->objectives[index].
		 flags & OBJECTIVE_UNKNOWNCOUNT) != 0 ? "no-count" : "",
		(currentMission->objectives[index].
		 flags & OBJECTIVE_NOACCESS) != 0 ? "no-access" : "");
	DisplayText(150, y, s, xc == XC_FLAGS, 0);

	SetSecondaryMouseRects(localObjectiveClicks);
}
Esempio n. 11
0
static void DrawKeycard(int x, int y, const TOffsetPic * pic)
{
	DrawTPic(x + pic->dx, y + pic->dy, gPics[pic->picIndex],
		 gCompiledPics[pic->picIndex]);
}
Esempio n. 12
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);
}
Esempio n. 13
0
void MouseDraw(Mouse *mouse)
{
	DrawTPic(mouse->currentPos.x, mouse->currentPos.y, mouse->cursor);
}