Ejemplo n.º 1
0
static int TemplateSelection(int loadFlag, int x, int index,
			     struct PlayerData *data, int cmd)
{
	int i;
	int y;
	static int selection[2] = { 0, 0 };

	if (cmd & CMD_BUTTON1)
	{
		if (loadFlag)
		{
			UseTemplate(index, data, &templates[selection[index]]);
		}
		else
		{
			SaveTemplate(data, &templates[selection[index]]);
		}
		SoundPlay(&gSoundDevice, rand() % SND_COUNT);
		return 0;
	}
	else if (cmd & CMD_BUTTON2)
	{
		SoundPlay(&gSoundDevice, rand() % SND_COUNT);
		return 0;
	} else if (cmd & (CMD_LEFT | CMD_UP)) {
		if (selection[index] > 0) {
			selection[index]--;
			SoundPlay(&gSoundDevice, SND_SWITCH);
		}
		else if (selection[index] == 0)
		{
			selection[index] = MAX_TEMPLATE - 1;
			SoundPlay(&gSoundDevice, SND_SWITCH);
		}
	} else if (cmd & (CMD_RIGHT | CMD_DOWN)) {
		if (selection[index] < MAX_TEMPLATE - 1) {
			selection[index]++;
			SoundPlay(&gSoundDevice, SND_SWITCH);
		}
		else if (selection[index] == MAX_TEMPLATE - 1)
		{
			selection[index] = 0;
			SoundPlay(&gSoundDevice, SND_SWITCH);
		}
	}

	y = CenterY((CDogsTextHeight() * MAX_TEMPLATE));

	if (!loadFlag) {
		CDogsTextStringAt(x, y - 4 - CDogsTextHeight(), "Save ");
		CDogsTextString(data->name);
		CDogsTextString("...");
	}

	for (i = 0; i < MAX_TEMPLATE; i++)
		DisplayMenuItem(x, y + i * CDogsTextHeight(),
				templates[i].name, i == selection[index]);

	return 1;
}
Ejemplo n.º 2
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");
}
Ejemplo n.º 3
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);
		}
	}
}
Ejemplo n.º 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;
	}
}