Example #1
0
void DisplayFlag(int x, int y, const char *s, int on, int hilite)
{
	CDogsTextGoto(x, y);
	if (hilite) {
		CDogsTextStringWithTable(s, &tableFlamed);
		CDogsTextCharWithTable(':', &tableFlamed);
	} else {
		CDogsTextString(s);
		CDogsTextChar(':');
	}
	if (on)
		CDogsTextStringWithTable("On", &tablePurple);
	else
		CDogsTextString("Off");
}
Example #2
0
void DisplayCharacter(Vec2i pos, Character *c, int hilite, int showGun)
{
	DrawCharacterSimple(
		c, pos,
		DIRECTION_DOWN, STATE_IDLE, -1, GUNSTATE_READY, &c->table);
	if (hilite)
	{
		CDogsTextGoto(pos.x - 8, pos.y - 16);
		CDogsTextChar('\020');
		if (showGun)
		{
			CDogsTextGoto(pos.x - 8, pos.y + 8);
			CDogsTextString(c->Gun->name);
		}
	}
}
Example #3
0
static int NameSelection(int x, int index, struct PlayerData *data,
			 int cmd)
{
	int i;
	int y;

	//char s[2];
	static char letters[] =
		"ABCDEFGHIJKLMNOPQRSTUVWXYZ !#?:.-0123456789";
	static char smallLetters[] =
		"abcdefghijklmnopqrstuvwxyz !#?:.-0123456789";
	static int selection[2] = { -1, -1 };

	// Kludge since Watcom won't let me initialize selection with a strlen()
	if (selection[0] < 0)
		selection[0] = selection[1] = strlen(letters);

	if (cmd & CMD_BUTTON1)
	{
		if (selection[index] == (int)strlen(letters))
		{
			SoundPlay(&gSoundDevice, SND_LAUNCH);
			return 0;
		}

		if (strlen(data->name) < sizeof(data->name) - 1) {
			int l = strlen(data->name);
			data->name[l + 1] = 0;
			if (l > 0 && data->name[l - 1] != ' ')
				data->name[l] =
				    smallLetters[selection[index]];
			else
				data->name[l] = letters[selection[index]];
			SoundPlay(&gSoundDevice, SND_MACHINEGUN);
		}
		else
		{
			SoundPlay(&gSoundDevice, SND_KILL);
		}
	}
	else if (cmd & CMD_BUTTON2)
	{
		if (data->name[0]) {
			data->name[strlen(data->name) - 1] = 0;
			SoundPlay(&gSoundDevice, SND_BANG);
		}
		else
		{
			SoundPlay(&gSoundDevice, SND_KILL);
		}
	}
	else if (cmd & CMD_LEFT)
	{
		if (selection[index] > 0)
		{
			selection[index]--;
			SoundPlay(&gSoundDevice, SND_DOOR);
		}
	}
	else if (cmd & CMD_RIGHT)
	{
		if (selection[index] < (int)strlen(letters))
		{
			selection[index]++;
			SoundPlay(&gSoundDevice, SND_DOOR);
		}
	} else if (cmd & CMD_UP) {
		if (selection[index] > 9) {
			selection[index] -= 10;
			SoundPlay(&gSoundDevice, SND_DOOR);
		}
	}
	else if (cmd & CMD_DOWN)
	{
		if (selection[index] < (int)strlen(letters) - 9)
		{
			selection[index] += 10;
			SoundPlay(&gSoundDevice, SND_DOOR);
		}
		else if (selection[index] < (int)strlen(letters))
		{
			selection[index] = strlen(letters);
			SoundPlay(&gSoundDevice, SND_DOOR);
		}
	}

	#define ENTRY_COLS	10
	#define	ENTRY_SPACING	12

	y = CenterY(((CDogsTextHeight() * ((strlen(letters) - 1) / ENTRY_COLS) )));

	if (gOptions.twoPlayers && index == CHARACTER_PLAYER1)
	{
		x = CenterOf(
			0,
			gGraphicsDevice.cachedConfig.ResolutionWidth / 2
			,
			(ENTRY_SPACING * (ENTRY_COLS - 1)) + CDogsTextCharWidth('a'));
	}
	else if (gOptions.twoPlayers && index == CHARACTER_PLAYER2)
	{
		x = CenterOf(
			gGraphicsDevice.cachedConfig.ResolutionWidth / 2,
			gGraphicsDevice.cachedConfig.ResolutionWidth,
			(ENTRY_SPACING * (ENTRY_COLS - 1)) + CDogsTextCharWidth('a'));
	}
	else
	{
		x = CenterX((ENTRY_SPACING * (ENTRY_COLS - 1)) + CDogsTextCharWidth('a'));
	}

	// Draw selection

	//s[1] = 0;
	for (i = 0; i < (int)strlen(letters); i++)
	{
		//s[0] = letters[i];

		CDogsTextGoto(x + (i % ENTRY_COLS) * ENTRY_SPACING,
			 y + (i / ENTRY_COLS) * CDogsTextHeight());

		if (i == selection[index])
			CDogsTextCharWithTable(letters[i], &tableFlamed);
		else
			CDogsTextChar(letters[i]);
/*
		DisplayMenuItem(x + (i % 10) * 12,
				80 + (i / 10) * CDogsTextHeight(), s,
				i == selection[index]);
*/
	}

	DisplayMenuItem(x + (i % ENTRY_COLS) * ENTRY_SPACING,
			y + (i / ENTRY_COLS) * CDogsTextHeight(),
			endChoice, i == selection[index]);

	return 1;
}
Example #4
0
static void Save(void)
{
	char filename[CDOGS_PATH_MAX];
	strcpy(filename, lastFile);
	bool doSave = false;
	bool done = false;
	while (!done)
	{
		ClearScreen(&gGraphicsDevice);
		CDogsTextStringAt(125, 50, "Save as:");
		CDogsTextGoto(125, 50 + CDogsTextHeight());
		CDogsTextChar('\020');
		CDogsTextString(filename);
		CDogsTextChar('\021');
		BlitFlip(&gGraphicsDevice, &gConfig.Graphics);

		int c = GetKey(&gEventHandlers);
		switch (c)
		{
		case SDLK_RETURN:
		case SDLK_KP_ENTER:
			if (!filename[0])
			{
				break;
			}
			doSave = true;
			done = true;
			break;

		case SDLK_ESCAPE:
			break;

		case SDLK_BACKSPACE:
			if (filename[0])
				filename[strlen(filename) - 1] = 0;
			break;

		default:
			if (strlen(filename) == sizeof(filename) - 1)
			{
				break;
			}
			c = KeyGetTyped(&gEventHandlers.keyboard);
			if (c && c != '*' &&
				(strlen(filename) > 1 || c != '-') &&
				c != ':' && c != '<' && c != '>' && c != '?' &&
				c != '|')
			{
				size_t si = strlen(filename);
				filename[si + 1] = 0;
				filename[si] = (char)c;
			}
		}
		SDL_Delay(10);
	}
	if (doSave)
	{
		ClearScreen(&gGraphicsDevice);
		DrawTextStringSpecial(
			"Saving...", TEXT_XCENTER | TEXT_YCENTER,
			Vec2iZero(), gGraphicsDevice.cachedConfig.Res, Vec2iZero());
		BlitFlip(&gGraphicsDevice, &gConfig.Graphics);
		MapNewSave(filename, &gCampaign.Setting);
		fileChanged = 0;
		strcpy(lastFile, filename);
		sAutosaveIndex = 0;
	}
}