Skip to content

Commit 748f54e

Browse files
committed
enum for speech priority and flags for blocking speech
1 parent a413c69 commit 748f54e

16 files changed

+359
-318
lines changed

Makefile

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@ ifeq ($(GRAPHICS),YES)
2424
sources += $(addprefix src/platform/,sdl2-platform.c tiles.c)
2525
cflags += $(shell $(SDL_CONFIG) --cflags)
2626
cppflags += -DBROGUE_SDL
27-
libs += $(shell $(SDL_CONFIG) --libs) -lSDL2_image
27+
libs += $(shell $(SDL_CONFIG) --libs) -lSDL2_image -lespeak-ng
2828
endif
2929

3030
ifeq ($(SPEECH),YES)
3131
cppflags += -DBROGUE_SPEECH
32-
libs += -lespeak-ng
3332
endif
3433

3534
ifeq ($(WEBBROGUE),YES)

config.mk

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ SDL_CONFIG := sdl2-config
1313
WEBBROGUE := NO
1414

1515
# Add TTS. Requires GRAPHICS for now, just to add SDL.
16-
SPEECH := YES
16+
SPEECH := NO
1717

1818
# Enable debugging mode. See top of Rogue.h for features
19-
DEBUG := NO
19+
DEBUG := YES
2020

2121
# Declare this is a release build
2222
RELEASE := NO

src/brogue/Architect.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3338,7 +3338,7 @@ boolean spawnDungeonFeature(short x, short y, dungeonFeature *feat, boolean refr
33383338

33393339
if (feat->description[0] && !feat->messageDisplayed && playerCanSee(x, y)) {
33403340
feat->messageDisplayed = true;
3341-
message(feat->description, 0, 0);
3341+
message(feat->description, 0);
33423342
}
33433343

33443344
zeroOutGrid(blockingMap);

src/brogue/Combat.c

+14-14
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ void splitMonster(creature *monst, short x, short y) {
255255

256256
if (canDirectlySeeMonster(monst)) {
257257
sprintf(buf, "%s splits in two!", monstName);
258-
message(buf, 0, 2);
258+
message(buf, TWO_SPEECH);
259259
}
260260

261261
return;
@@ -393,7 +393,7 @@ void specialHit(creature *attacker, creature *defender, short damage) {
393393
equipItem(rogue.armor, true, NULL);
394394
itemName(rogue.armor, buf2, false, false, NULL);
395395
sprintf(buf, "your %s weakens!", buf2);
396-
messageWithColor(buf, &itemMessageColor, 0, 2);
396+
messageWithColor(buf, &itemMessageColor, TWO_SPEECH);
397397
checkForDisenchantment(rogue.armor);
398398
}
399399
if (attacker->info.abilityFlags & MA_HIT_HALLUCINATE) {
@@ -461,7 +461,7 @@ void specialHit(creature *attacker, creature *defender, short damage) {
461461
monsterName(buf2, attacker, true);
462462
itemName(theItem, buf3, false, true, NULL);
463463
sprintf(buf, "%s stole %s!", buf2, buf3);
464-
messageWithColor(buf, &badMessageColor, 0, 2);
464+
messageWithColor(buf, &badMessageColor, TWO_SPEECH);
465465
}
466466
}
467467
}
@@ -718,7 +718,7 @@ void magicWeaponHit(creature *defender, item *theItem, boolean backstabbed) {
718718
}
719719
updateVision(true);
720720

721-
message(buf, 0, 2);
721+
message(buf, TWO_SPEECH);
722722
autoID = true;
723723
break;
724724
case W_SLOWING:
@@ -946,7 +946,7 @@ void applyArmorRunicEffect(char returnString[DCOLS], creature *attacker, short *
946946
case A_IMMOLATION:
947947
if (rand_percent(10)) {
948948
sprintf(returnString, "flames suddenly explode out of your %s!", armorName);
949-
message(returnString, runicKnown ? 0 : REQUIRE_ACKNOWLEDGMENT, 2);
949+
message(returnString, runicKnown ? 0 : REQUIRE_ACKNOWLEDGMENT | TWO_SPEECH);
950950
returnString[0] = '\0';
951951
spawnDungeonFeature(player.xLoc, player.yLoc, &(dungeonFeatureCatalog[DF_ARMOR_IMMOLATION]), true, false);
952952
runicDiscovered = true;
@@ -969,10 +969,10 @@ void decrementWeaponAutoIDTimer() {
969969

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

@@ -1061,7 +1061,7 @@ boolean attack(creature *attacker, creature *defender, boolean lungeAttack) {
10611061
defender->bookkeepingFlags |= MB_SEIZED;
10621062
if (canSeeMonster(attacker) || canSeeMonster(defender)) {
10631063
sprintf(buf, "%s seizes %s!", attackerName, (defender == &player ? "your legs" : defenderName));
1064-
messageWithColor(buf, &white, 0, 2);
1064+
messageWithColor(buf, &white, TWO_SPEECH);
10651065
}
10661066
return false;
10671067
}
@@ -1186,7 +1186,7 @@ boolean attack(creature *attacker, creature *defender, boolean lungeAttack) {
11861186
specialHit(attacker, defender, (attacker->info.abilityFlags & MA_POISONS) ? poisonDamage : damage);
11871187
}
11881188
if (armorRunicString[0]) {
1189-
message(armorRunicString, 0, 2);
1189+
message(armorRunicString, TWO_SPEECH);
11901190
if (rogue.armor && (rogue.armor->flags & ITEM_RUNIC) && rogue.armor->enchant2 == A_BURDEN) {
11911191
strengthCheck(rogue.armor, true);
11921192
}
@@ -1221,7 +1221,7 @@ boolean attack(creature *attacker, creature *defender, boolean lungeAttack) {
12211221
equipItem(rogue.weapon, true, NULL);
12221222
itemName(rogue.weapon, buf2, false, false, NULL);
12231223
sprintf(buf, "your %s weakens!", buf2);
1224-
messageWithColor(buf, &itemMessageColor, 0, 2);
1224+
messageWithColor(buf, &itemMessageColor, TWO_SPEECH);
12251225
checkForDisenchantment(rogue.weapon);
12261226
}
12271227

@@ -1311,12 +1311,12 @@ void displayCombatText() {
13111311
for (end = start; *end != '\0'; end++) {
13121312
if (*end == '\n') {
13131313
*end = '\0';
1314-
message(start, FOLDABLE | (rogue.cautiousMode ? REQUIRE_ACKNOWLEDGMENT : 0), 2);
1314+
message(start, FOLDABLE | (rogue.cautiousMode ? REQUIRE_ACKNOWLEDGMENT : 0) | TWO_SPEECH | SPEECH_BLOCKS);
13151315
start = end + 1;
13161316
}
13171317
}
13181318

1319-
message(start, FOLDABLE | (rogue.cautiousMode ? REQUIRE_ACKNOWLEDGMENT : 0), 2);
1319+
message(start, FOLDABLE | (rogue.cautiousMode ? REQUIRE_ACKNOWLEDGMENT : 0) | TWO_SPEECH | SPEECH_BLOCKS);
13201320

13211321
rogue.cautiousMode = false;
13221322
}
@@ -1647,7 +1647,7 @@ void killCreature(creature *decedent, boolean administrativeDeath) {
16471647
monsterName(monstName, decedent, true);
16481648
snprintf(buf, DCOLS * 3, "%s %s", monstName, monsterText[decedent->info.monsterID].DFMessage);
16491649
resolvePronounEscapes(buf, decedent);
1650-
message(buf, 0, 2);
1650+
message(buf, TWO_SPEECH);
16511651
}
16521652
}
16531653

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

1664-
messageWithColor("you feel a sense of loss.", &badMessageColor, 0, 2);
1664+
messageWithColor("you feel a sense of loss.", &badMessageColor, TWO_SPEECH);
16651665
}
16661666
x = decedent->xLoc;
16671667
y = decedent->yLoc;

src/brogue/IO.c

+24-20
Original file line numberDiff line numberDiff line change
@@ -2381,12 +2381,13 @@ void exploreKey(const boolean controlKey) {
23812381
} else {
23822382
x = finalX = player.xLoc + nbDirs[dir][0];
23832383
y = finalY = player.yLoc + nbDirs[dir][1];
2384+
hideCursor();
23842385
}
23852386

23862387
if (tooDark) {
2387-
message("It's too dark to explore!", 0, 2);
2388+
message("It's too dark to explore!", 0);
23882389
} else if (x == player.xLoc && y == player.yLoc) {
2389-
message("I see no path for further exploration.", 0, 2);
2390+
message("I see no path for further exploration.", 0);
23902391
} else if (proposeOrConfirmLocation(finalX, finalY, "I see no path for further exploration.")) {
23912392
explore(controlKey ? 1 : 20); // Do the exploring until interrupted.
23922393
hideCursor();
@@ -2443,7 +2444,7 @@ void nextBrogueEvent(rogueEvent *returnEvent, boolean textInput, boolean colorsD
24432444

24442445
if (returnEvent->eventType == EVENT_ERROR) {
24452446
rogue.playbackPaused = rogue.playbackMode; // pause if replaying
2446-
message("Event error!", REQUIRE_ACKNOWLEDGMENT, 3);
2447+
message("Event error!", REQUIRE_ACKNOWLEDGMENT | THREE_SPEECH);
24472448
}
24482449
}
24492450

@@ -2598,10 +2599,10 @@ void executeKeystroke(signed long keystroke, boolean controlKey, boolean shiftKe
25982599
refreshSideBar(-1, -1, false);
25992600
if (rogue.trueColorMode) {
26002601
messageWithColor(KEYBOARD_LABELS ? "Color effects disabled. Press '\\' again to enable." : "Color effects disabled.",
2601-
&teal, 0, 0);
2602+
&teal, 0);
26022603
} else {
26032604
messageWithColor(KEYBOARD_LABELS ? "Color effects enabled. Press '\\' again to disable." : "Color effects enabled.",
2604-
&teal, 0, 0);
2605+
&teal, 0);
26052606
}
26062607
break;
26072608
case AGGRO_DISPLAY_KEY:
@@ -2610,10 +2611,10 @@ void executeKeystroke(signed long keystroke, boolean controlKey, boolean shiftKe
26102611
refreshSideBar(-1, -1, false);
26112612
if (rogue.displayAggroRangeMode) {
26122613
messageWithColor(KEYBOARD_LABELS ? "Stealth range displayed. Press ']' again to hide." : "Stealth range displayed.",
2613-
&teal, 0, 0);
2614+
&teal, 0);
26142615
} else {
26152616
messageWithColor(KEYBOARD_LABELS ? "Stealth range hidden. Press ']' again to display." : "Stealth range hidden.",
2616-
&teal, 0, 0);
2617+
&teal, 0);
26172618
}
26182619
break;
26192620
case CALL_KEY:
@@ -2649,7 +2650,7 @@ void executeKeystroke(signed long keystroke, boolean controlKey, boolean shiftKe
26492650
rogue.nextGame = NG_VIEW_RECORDING;
26502651
rogue.gameHasEnded = true;
26512652
} else {
2652-
message("File not found.", 0, 0);
2653+
message("File not found.", 0);
26532654
}
26542655
}
26552656
break;
@@ -2665,7 +2666,7 @@ void executeKeystroke(signed long keystroke, boolean controlKey, boolean shiftKe
26652666
rogue.nextGame = NG_OPEN_GAME;
26662667
rogue.gameHasEnded = true;
26672668
} else {
2668-
message("File not found.", 0, 0);
2669+
message("File not found.", 0);
26692670
}
26702671
}
26712672
break;
@@ -2690,24 +2691,27 @@ void executeKeystroke(signed long keystroke, boolean controlKey, boolean shiftKe
26902691
gameOver("Quit", true);
26912692
}
26922693
break;
2694+
case TTS_TOGGLE_KEY:
2695+
toggleTTS();
2696+
break;
26932697
case GRAPHICS_KEY:
26942698
if (hasGraphics) {
26952699
graphicsMode = setGraphicsMode((graphicsMode + 1) % 3);
26962700
switch (graphicsMode) {
26972701
case TEXT_GRAPHICS:
26982702
messageWithColor(KEYBOARD_LABELS
26992703
? "Switched to text mode. Press 'G' again to enable tiles."
2700-
: "Switched to text mode.", &teal, 0, 1);
2704+
: "Switched to text mode.", &teal, 0);
27012705
break;
27022706
case TILES_GRAPHICS:
27032707
messageWithColor(KEYBOARD_LABELS
27042708
? "Switched to graphical tiles. Press 'G' again to enable hybrid mode."
2705-
: "Switched to graphical tiles.", &teal, 0, 1);
2709+
: "Switched to graphical tiles.", &teal, 0);
27062710
break;
27072711
case HYBRID_GRAPHICS:
27082712
messageWithColor(KEYBOARD_LABELS
27092713
? "Switched to hybrid mode. Press 'G' again to disable tiles."
2710-
: "Switched to hybrid mode.", &teal, 0, 1);
2714+
: "Switched to hybrid mode.", &teal, 0);
27112715
break;
27122716
}
27132717
}
@@ -2974,8 +2978,8 @@ boolean confirm(char *prompt, boolean alsoDuringPlayback) {
29742978
return true; // oh yes he did
29752979
}
29762980

2977-
playSpeech(prompt, 3);
2978-
playSpeech("Yes... No", 3);
2981+
playSpeech(prompt, THREE_SPEECH | SPEECH_BLOCKS);
2982+
playSpeech("Yes... No", THREE_SPEECH);
29792983

29802984
encodeMessageColor(whiteColorEscape, 0, &white);
29812985
encodeMessageColor(yellowColorEscape, 0, KEYBOARD_LABELS ? &yellow : &white);
@@ -3441,17 +3445,17 @@ void temporaryMessage(const char *msg, enum messageFlags flags) {
34413445
}
34423446
restoreRNG;
34433447

3444-
playSpeech(msg, 1);
3448+
playSpeech(msg, ONE_SPEECH);
34453449
}
34463450

3447-
void messageWithColor(char *msg, color *theColor, enum messageFlags flags, short speechPriority) {
3451+
void messageWithColor(char *msg, color *theColor, enum messageFlags flags) {
34483452
char buf[COLS*2] = "";
34493453
short i;
34503454

34513455
i=0;
34523456
i = encodeMessageColor(buf, i, theColor);
34533457
strcpy(&(buf[i]), msg);
3454-
message(buf, flags, speechPriority);
3458+
message(buf, flags);
34553459
}
34563460

34573461
void flavorMessage(char *msg) {
@@ -3479,7 +3483,7 @@ void flavorMessage(char *msg) {
34793483
// arrived on the same turn, they may collapse. Alternately, they may collapse
34803484
// if the older message is the latest one in the archive and the new one is not
34813485
// semi-colon foldable (such as a combat message.)
3482-
void message(const char *msg, enum messageFlags flags, short speechPriority) {
3486+
void message(const char *msg, enum messageFlags flags) {
34833487
short i;
34843488
archivedMessage *archiveEntry;
34853489
boolean newMessage;
@@ -3549,7 +3553,7 @@ void message(const char *msg, enum messageFlags flags, short speechPriority) {
35493553

35503554
restoreRNG;
35513555

3552-
playSpeech(msg, speechPriority);
3556+
playSpeech(msg, 0);
35533557
}
35543558

35553559
// Only used for the "you die..." message, to enable posthumous inventory viewing.
@@ -4478,7 +4482,7 @@ void displayGrid(short **map) {
44784482
void printSeed() {
44794483
char buf[COLS];
44804484
snprintf(buf, COLS, "Dungeon seed #%llu; turn #%lu; version %s", (unsigned long long)rogue.seed, rogue.playerTurnNumber, BROGUE_VERSION_STRING);
4481-
message(buf, 0, 0);
4485+
message(buf, 0);
44824486
}
44834487

44844488
void printProgressBar(short x, short y, const char barLabel[COLS], long amtFilled, long amtMax, color *fillColor, boolean dim) {

0 commit comments

Comments
 (0)