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"); }
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; }