Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TTS #375

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft

TTS #375

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ on:
jobs:

linux:
runs-on: ubuntu-16.04
runs-on: ubuntu-18.04
steps:
- name: "Install dependencies"
run: |
sudo apt update -y
sudo apt install -y libsdl2-dev libsdl2-image-dev
sudo apt install -y libsdl2-dev libsdl2-image-dev espeak-ng

- name: "Checkout sources"
uses: actions/checkout@v2
Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
brew install --build-from-source ./macos/sdl2.rb
cp -r $(brew --cellar)/sdl2 sdl2-cellar
fi
brew install sdl2_image dylibbundler
brew install sdl2_image dylibbundler espeak-ng

- name: "Compile"
run: |
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ ifeq ($(GRAPHICS),YES)
sources += $(addprefix src/platform/,sdl2-platform.c tiles.c)
cflags += $(shell $(SDL_CONFIG) --cflags)
cppflags += -DBROGUE_SDL
libs += $(shell $(SDL_CONFIG) --libs) -lSDL2_image
libs += $(shell $(SDL_CONFIG) --libs) -lSDL2_image -lespeak-ng
endif

ifeq ($(SPEECH),YES)
cppflags += -DBROGUE_SPEECH
endif

ifeq ($(WEBBROGUE),YES)
Expand Down
5 changes: 4 additions & 1 deletion config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ SDL_CONFIG := sdl2-config
# Select web brogue mode. Requires POSIX system.
WEBBROGUE := NO

# Add TTS. Requires GRAPHICS for now, just to add SDL.
SPEECH := NO

# Enable debugging mode. See top of Rogue.h for features
DEBUG := NO
DEBUG := YES
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I imagine this line will need to revert dropped before merge.


# Declare this is a release build
RELEASE := NO
Expand Down
28 changes: 14 additions & 14 deletions src/brogue/Combat.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ void splitMonster(creature *monst, short x, short y) {

if (canDirectlySeeMonster(monst)) {
sprintf(buf, "%s splits in two!", monstName);
message(buf, 0);
message(buf, TWO_SPEECH);
}

return;
Expand Down Expand Up @@ -393,7 +393,7 @@ void specialHit(creature *attacker, creature *defender, short damage) {
equipItem(rogue.armor, true, NULL);
itemName(rogue.armor, buf2, false, false, NULL);
sprintf(buf, "your %s weakens!", buf2);
messageWithColor(buf, &itemMessageColor, 0);
messageWithColor(buf, &itemMessageColor, TWO_SPEECH);
checkForDisenchantment(rogue.armor);
}
if (attacker->info.abilityFlags & MA_HIT_HALLUCINATE) {
Expand Down Expand Up @@ -461,7 +461,7 @@ void specialHit(creature *attacker, creature *defender, short damage) {
monsterName(buf2, attacker, true);
itemName(theItem, buf3, false, true, NULL);
sprintf(buf, "%s stole %s!", buf2, buf3);
messageWithColor(buf, &badMessageColor, 0);
messageWithColor(buf, &badMessageColor, TWO_SPEECH);
}
}
}
Expand Down Expand Up @@ -718,7 +718,7 @@ void magicWeaponHit(creature *defender, item *theItem, boolean backstabbed) {
}
updateVision(true);

message(buf, 0);
message(buf, TWO_SPEECH);
autoID = true;
break;
case W_SLOWING:
Expand Down Expand Up @@ -946,7 +946,7 @@ void applyArmorRunicEffect(char returnString[DCOLS], creature *attacker, short *
case A_IMMOLATION:
if (rand_percent(10)) {
sprintf(returnString, "flames suddenly explode out of your %s!", armorName);
message(returnString, runicKnown ? 0 : REQUIRE_ACKNOWLEDGMENT);
message(returnString, runicKnown ? 0 : REQUIRE_ACKNOWLEDGMENT | TWO_SPEECH);
returnString[0] = '\0';
spawnDungeonFeature(player.xLoc, player.yLoc, &(dungeonFeatureCatalog[DF_ARMOR_IMMOLATION]), true, false);
runicDiscovered = true;
Expand All @@ -969,10 +969,10 @@ void decrementWeaponAutoIDTimer() {

rogue.weapon->flags |= ITEM_IDENTIFIED;
updateIdentifiableItems();
messageWithColor("you are now familiar enough with your weapon to identify it.", &itemMessageColor, 0);
messageWithColor("you are now familiar enough with your weapon to identify it.", &itemMessageColor, TWO_SPEECH);
itemName(rogue.weapon, buf2, true, true, NULL);
sprintf(buf, "%s %s.", (rogue.weapon->quantity > 1 ? "they are" : "it is"), buf2);
messageWithColor(buf, &itemMessageColor, 0);
messageWithColor(buf, &itemMessageColor, TWO_SPEECH);
}
}

Expand Down Expand Up @@ -1061,7 +1061,7 @@ boolean attack(creature *attacker, creature *defender, boolean lungeAttack) {
defender->bookkeepingFlags |= MB_SEIZED;
if (canSeeMonster(attacker) || canSeeMonster(defender)) {
sprintf(buf, "%s seizes %s!", attackerName, (defender == &player ? "your legs" : defenderName));
messageWithColor(buf, &white, 0);
messageWithColor(buf, &white, TWO_SPEECH);
}
return false;
}
Expand Down Expand Up @@ -1186,7 +1186,7 @@ boolean attack(creature *attacker, creature *defender, boolean lungeAttack) {
specialHit(attacker, defender, (attacker->info.abilityFlags & MA_POISONS) ? poisonDamage : damage);
}
if (armorRunicString[0]) {
message(armorRunicString, 0);
message(armorRunicString, TWO_SPEECH);
if (rogue.armor && (rogue.armor->flags & ITEM_RUNIC) && rogue.armor->enchant2 == A_BURDEN) {
strengthCheck(rogue.armor, true);
}
Expand Down Expand Up @@ -1221,7 +1221,7 @@ boolean attack(creature *attacker, creature *defender, boolean lungeAttack) {
equipItem(rogue.weapon, true, NULL);
itemName(rogue.weapon, buf2, false, false, NULL);
sprintf(buf, "your %s weakens!", buf2);
messageWithColor(buf, &itemMessageColor, 0);
messageWithColor(buf, &itemMessageColor, TWO_SPEECH);
checkForDisenchantment(rogue.weapon);
}

Expand Down Expand Up @@ -1311,12 +1311,12 @@ void displayCombatText() {
for (end = start; *end != '\0'; end++) {
if (*end == '\n') {
*end = '\0';
message(start, FOLDABLE | (rogue.cautiousMode ? REQUIRE_ACKNOWLEDGMENT : 0));
message(start, FOLDABLE | (rogue.cautiousMode ? REQUIRE_ACKNOWLEDGMENT : 0) | TWO_SPEECH | SPEECH_BLOCKS);
start = end + 1;
}
}

message(start, FOLDABLE | (rogue.cautiousMode ? REQUIRE_ACKNOWLEDGMENT : 0));
message(start, FOLDABLE | (rogue.cautiousMode ? REQUIRE_ACKNOWLEDGMENT : 0) | TWO_SPEECH | SPEECH_BLOCKS);

rogue.cautiousMode = false;
}
Expand Down Expand Up @@ -1647,7 +1647,7 @@ void killCreature(creature *decedent, boolean administrativeDeath) {
monsterName(monstName, decedent, true);
snprintf(buf, DCOLS * 3, "%s %s", monstName, monsterText[decedent->info.monsterID].DFMessage);
resolvePronounEscapes(buf, decedent);
message(buf, 0);
message(buf, TWO_SPEECH);
}
}

Expand All @@ -1661,7 +1661,7 @@ void killCreature(creature *decedent, boolean administrativeDeath) {
&& !(decedent->bookkeepingFlags & MB_BOUND_TO_LEADER)
&& !decedent->carriedMonster) {

messageWithColor("you feel a sense of loss.", &badMessageColor, 0);
messageWithColor("you feel a sense of loss.", &badMessageColor, TWO_SPEECH);
}
x = decedent->xLoc;
y = decedent->yLoc;
Expand Down
2 changes: 1 addition & 1 deletion src/brogue/Globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ const color fireForeColor = {70, 20, 0, 15, 10,
const color lavaForeColor = {20, 20, 20, 100, 10, 0, 0, true};
const color brimstoneForeColor = {100, 50, 10, 0, 50, 40, 0, true};
const color brimstoneBackColor = {18, 12, 9, 0, 0, 5, 0, false};

//Red Green Blue RedRand GreenRand BlueRand Rand Dances
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems unrelated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i'm not sure where this came from, probably the IDE doing something.

const color lavaBackColor = {70, 20, 0, 15, 10, 0, 0, true};
const color acidBackColor = {15, 80, 25, 5, 15, 10, 0, true};

Expand Down
13 changes: 12 additions & 1 deletion src/brogue/IO.c
Original file line number Diff line number Diff line change
Expand Up @@ -2381,6 +2381,7 @@ void exploreKey(const boolean controlKey) {
} else {
x = finalX = player.xLoc + nbDirs[dir][0];
y = finalY = player.yLoc + nbDirs[dir][1];
hideCursor();
}

if (tooDark) {
Expand Down Expand Up @@ -2443,7 +2444,7 @@ void nextBrogueEvent(rogueEvent *returnEvent, boolean textInput, boolean colorsD

if (returnEvent->eventType == EVENT_ERROR) {
rogue.playbackPaused = rogue.playbackMode; // pause if replaying
message("Event error!", REQUIRE_ACKNOWLEDGMENT);
message("Event error!", REQUIRE_ACKNOWLEDGMENT | THREE_SPEECH);
}
}

Expand Down Expand Up @@ -2690,6 +2691,9 @@ void executeKeystroke(signed long keystroke, boolean controlKey, boolean shiftKe
gameOver("Quit", true);
}
break;
case TTS_TOGGLE_KEY:
toggleTTS();
break;
case GRAPHICS_KEY:
if (hasGraphics) {
graphicsMode = setGraphicsMode((graphicsMode + 1) % 3);
Expand Down Expand Up @@ -2974,6 +2978,9 @@ boolean confirm(char *prompt, boolean alsoDuringPlayback) {
return true; // oh yes he did
}

playSpeech(prompt, THREE_SPEECH | SPEECH_BLOCKS);
playSpeech("Yes... No", THREE_SPEECH);

encodeMessageColor(whiteColorEscape, 0, &white);
encodeMessageColor(yellowColorEscape, 0, KEYBOARD_LABELS ? &yellow : &white);

Expand Down Expand Up @@ -3437,6 +3444,8 @@ void temporaryMessage(const char *msg, enum messageFlags flags) {
updateMessageDisplay();
}
restoreRNG;

playSpeech(msg, ONE_SPEECH);
}

void messageWithColor(char *msg, color *theColor, enum messageFlags flags) {
Expand Down Expand Up @@ -3543,6 +3552,8 @@ void message(const char *msg, enum messageFlags flags) {
}

restoreRNG;

playSpeech(msg, 0);
}

// Only used for the "you die..." message, to enable posthumous inventory viewing.
Expand Down
22 changes: 12 additions & 10 deletions src/brogue/Items.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ item *makeItemInto(item *theItem, unsigned long itemCategory, short itemKind) {
break;
default:
theEntry = NULL;
message("something has gone terribly wrong!", REQUIRE_ACKNOWLEDGMENT);
message("something has gone terribly wrong!", REQUIRE_ACKNOWLEDGMENT | SPEECH_BLOCKS);
break;
}
if (theItem
Expand Down Expand Up @@ -389,7 +389,7 @@ item *placeItem(item *theItem, short x, short y) {
}
itemName(theItem, theItemName, false, false, NULL);
sprintf(buf, "a pressure plate clicks underneath the %s!", theItemName);
message(buf, REQUIRE_ACKNOWLEDGMENT);
message(buf, REQUIRE_ACKNOWLEDGMENT | SPEECH_BLOCKS);
}
for (layer = 0; layer < NUMBER_TERRAIN_LAYERS; layer++) {
if (tileCatalog[pmap[x][y].layers[layer]].flags & T_IS_DF_TRAP) {
Expand Down Expand Up @@ -755,7 +755,7 @@ void pickUpItemAt(short x, short y) {
theItem = itemAtLoc(x, y);

if (!theItem) {
message("Error: Expected item; item not found.", REQUIRE_ACKNOWLEDGMENT);
message("Error: Expected item; item not found.", REQUIRE_ACKNOWLEDGMENT | SPEECH_BLOCKS);
return;
}

Expand Down Expand Up @@ -2957,6 +2957,8 @@ char displayInventory(unsigned short categoryMask,
// Yes. Highlight the selected item. Do this by changing the button color and re-displaying it.

overlayDisplayBuffer(dbuf, NULL);

playSpeech(buttons[highlightItemLine].text, THREE_SPEECH);

//buttons[highlightItemLine].buttonColor = interfaceBoxColor;
drawButton(&(buttons[highlightItemLine]), BUTTON_PRESSED, NULL);
Expand Down Expand Up @@ -4508,7 +4510,7 @@ boolean updateBolt(bolt *theBolt, creature *caster, short x, short y,
flashMonster(monst, &confusionGasColor, 100);
monst->status[STATUS_CONFUSED] = staffEntrancementDuration(theBolt->magnitude * FP_FACTOR);
monst->maxStatus[STATUS_CONFUSED] = max(monst->status[STATUS_CONFUSED], monst->maxStatus[STATUS_CONFUSED]);
message("the bolt hits you and you suddenly feel disoriented.", REQUIRE_ACKNOWLEDGMENT);
message("the bolt hits you and you suddenly feel disoriented.", REQUIRE_ACKNOWLEDGMENT | SPEECH_BLOCKS);
if (autoID) {
*autoID = true;
}
Expand Down Expand Up @@ -6704,7 +6706,7 @@ void readScroll(item *theItem) {
case SCROLL_IDENTIFY:
identify(theItem);
updateIdentifiableItems();
messageWithColor("this is a scroll of identify.", &itemMessageColor, REQUIRE_ACKNOWLEDGMENT);
messageWithColor("this is a scroll of identify.", &itemMessageColor, REQUIRE_ACKNOWLEDGMENT | SPEECH_BLOCKS);
if (numberOfMatchingPackItems(ALL_ITEMS, ITEM_CAN_BE_IDENTIFIED, 0, false) == 0) {
message("everything in your pack is already identified.", 0);
break;
Expand Down Expand Up @@ -6748,7 +6750,7 @@ void readScroll(item *theItem) {
break;
case SCROLL_ENCHANTING:
identify(theItem);
messageWithColor("this is a scroll of enchanting.", &itemMessageColor, REQUIRE_ACKNOWLEDGMENT);
messageWithColor("this is a scroll of enchanting.", &itemMessageColor, REQUIRE_ACKNOWLEDGMENT | SPEECH_BLOCKS);
if (!numberOfMatchingPackItems((WEAPON | ARMOR | RING | STAFF | WAND | CHARM), 0, 0, false)) {
confirmMessages();
message("you have nothing that can be enchanted.", 0);
Expand All @@ -6760,7 +6762,7 @@ void readScroll(item *theItem) {
false);
confirmMessages();
if (theItem == NULL || !(theItem->category & (WEAPON | ARMOR | RING | STAFF | WAND | CHARM))) {
message("Can't enchant that.", REQUIRE_ACKNOWLEDGMENT);
message("Can't enchant that.", REQUIRE_ACKNOWLEDGMENT | SPEECH_BLOCKS);
}
if (rogue.gameHasEnded) {
return;
Expand Down Expand Up @@ -7084,7 +7086,7 @@ void drinkPotion(item *theItem) {
message("you shiver as a chill runs up your spine.", 0);
break;
default:
message("you feel very strange, as though your body doesn't know how to react!", REQUIRE_ACKNOWLEDGMENT);
message("you feel very strange, as though your body doesn't know how to react!", REQUIRE_ACKNOWLEDGMENT | SPEECH_BLOCKS);
}
}

Expand Down Expand Up @@ -7348,7 +7350,7 @@ item *itemAtLoc(short x, short y) {
pmap[x][y].flags &= ~HAS_ITEM;
hiliteCell(x, y, &white, 75, true);
rogue.automationActive = false;
message("ERROR: An item was supposed to be here, but I couldn't find it.", REQUIRE_ACKNOWLEDGMENT);
message("ERROR: An item was supposed to be here, but I couldn't find it.", REQUIRE_ACKNOWLEDGMENT | SPEECH_BLOCKS);
refreshDungeonCell(x, y);
}
return theItem;
Expand Down Expand Up @@ -7483,7 +7485,7 @@ boolean equipItem(item *theItem, boolean force, item *unequipHint) {
}

confirmMessages();
messageWithColor(buf1, &itemMessageColor, false);
messageWithColor(buf1, &itemMessageColor, 0);

if (theItem->flags & ITEM_CURSED) {
itemName(theItem, buf2, false, false, NULL);
Expand Down
2 changes: 2 additions & 0 deletions src/brogue/MainMenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ void titleMenu() {
initializeMenuFlames(true, colors, colorStorage, colorSources, flames, mask);
rogue.creaturesWillFlashThisTurn = false; // total unconscionable hack

playSpeech("Welcome to Brogue!", ONE_SPEECH);

do {
if (isApplicationActive()) {
// Revert the display.
Expand Down
Loading