Skip to content

Commit 9d96d82

Browse files
dseguinwapcaplet
andcommitted
Expand widget clauses: "phrase" -> "clause"
Co-authored-by: Eric Pierce <[email protected]>
1 parent c07b9c6 commit 9d96d82

File tree

6 files changed

+137
-143
lines changed

6 files changed

+137
-143
lines changed

data/json/ui/bodypart_status.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
{
33
"id": "bodypart_status_indicator_template",
44
"type": "widget",
5-
"style": "phrase",
6-
"phrases": [
5+
"style": "clause",
6+
"clauses": [
77
{ "id": "bitten", "text": "bitten", "sym": "B", "color": "yellow", "condition": { "u_has_effect": "bite" } },
88
{
99
"id": "infected",
@@ -78,7 +78,7 @@
7878
"//": "Base widget for showing body part status; needs bodypart field defined in derived widget.",
7979
"type": "widget",
8080
"style": "text",
81-
"default_phrase": { "text": "--" },
81+
"default_clause": { "text": "--" },
8282
"copy-from": "bodypart_status_indicator_template"
8383
},
8484
{

data/mods/TEST_DATA/widgets.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
{
33
"id": "test_bp_status_indicator_template",
44
"type": "widget",
5-
"style": "phrase",
6-
"phrases": [
5+
"style": "clause",
6+
"clauses": [
77
{ "id": "bitten", "text": "bitten", "sym": "B", "color": "yellow", "condition": { "u_has_effect": "bite" } },
88
{
99
"id": "infected",
@@ -410,7 +410,7 @@
410410
"label": "TORSO STATUS",
411411
"bodypart": "torso",
412412
"style": "text",
413-
"default_phrase": { "text": "--" },
413+
"default_clause": { "text": "--" },
414414
"copy-from": "test_bp_status_indicator_template"
415415
},
416416
{
@@ -419,7 +419,7 @@
419419
"label": "LEFT ARM STATUS",
420420
"bodypart": "arm_l",
421421
"style": "text",
422-
"default_phrase": { "text": "--" },
422+
"default_clause": { "text": "--" },
423423
"copy-from": "test_bp_status_indicator_template"
424424
},
425425
{
@@ -467,12 +467,12 @@
467467
"height": 3
468468
},
469469
{
470-
"id": "test_phrase_number",
470+
"id": "test_clause_number",
471471
"type": "widget",
472472
"style": "number",
473473
"label": "Num Values",
474-
"default_phrase": { "value": 1, "color": "dark_gray" },
475-
"phrases": [
474+
"default_clause": { "value": 1, "color": "dark_gray" },
475+
"clauses": [
476476
{ "value": -20, "color": "red_red", "condition": { "not": "u_can_see" } },
477477
{ "value": -10, "color": "i_yellow", "condition": "u_is_deaf" },
478478
{ "value": 0, "color": "yellow", "condition": "is_day" },
@@ -481,12 +481,12 @@
481481
]
482482
},
483483
{
484-
"id": "test_phrase_text",
484+
"id": "test_clause_text",
485485
"type": "widget",
486486
"style": "text",
487487
"label": "Text Values",
488-
"default_phrase": { "text": "None", "color": "dark_gray" },
489-
"phrases": [
488+
"default_clause": { "text": "None", "color": "dark_gray" },
489+
"clauses": [
490490
{ "text": "blind", "color": "red_red", "condition": { "not": "u_can_see" } },
491491
{ "text": "deaf", "color": "i_yellow", "condition": "u_is_deaf" },
492492
{ "text": "daylight", "color": "yellow", "condition": "is_day" },
@@ -495,12 +495,12 @@
495495
]
496496
},
497497
{
498-
"id": "test_phrase_sym",
498+
"id": "test_clause_sym",
499499
"type": "widget",
500500
"style": "symbol",
501501
"label": "Symbol Values",
502-
"default_phrase": { "sym": ".", "color": "dark_gray" },
503-
"phrases": [
502+
"default_clause": { "sym": ".", "color": "dark_gray" },
503+
"clauses": [
504504
{ "sym": "<", "color": "red_red", "condition": { "not": "u_can_see" } },
505505
{ "sym": "-", "color": "i_yellow", "condition": "u_is_deaf" },
506506
{ "sym": "=", "color": "yellow", "condition": "is_day" },
@@ -509,14 +509,14 @@
509509
]
510510
},
511511
{
512-
"id": "test_phrase_legend",
512+
"id": "test_clause_legend",
513513
"type": "widget",
514514
"style": "legend",
515515
"label": "Legend Values",
516516
"height": 5,
517517
"width": 0,
518-
"default_phrase": { "text": "None", "sym": ".", "color": "dark_gray" },
519-
"phrases": [
518+
"default_clause": { "text": "None", "sym": ".", "color": "dark_gray" },
519+
"clauses": [
520520
{ "text": "blind", "sym": "<", "color": "red_red", "condition": { "not": "u_can_see" } },
521521
{ "text": "deaf", "sym": "-", "color": "i_yellow", "condition": "u_is_deaf" },
522522
{ "text": "daylight", "sym": "=", "color": "yellow", "condition": "is_day" },
@@ -556,7 +556,7 @@
556556
{
557557
"id": "test_text_widget",
558558
"type": "widget",
559-
"label": "PHRASE",
559+
"label": "CLAUSE",
560560
"style": "text",
561561
"strings": [ "Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten" ]
562562
},

doc/SIDEBAR_MOD.md

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
- [alignment](#text_align--label_align)
1515
- [colors](#colors)
1616
- [flags](#flags)
17-
- [Phrases and conditions](#phrases-and-conditions)
17+
- [Clauses and conditions](#clauses-and-conditions)
1818
- [Conditions](#conditions)
19-
- [Default phrase](#default-phrase)
19+
- [Default clause](#default-clause)
2020
- [Variable ranges](#variable-ranges)
2121
- [Variables](#variables)
2222
- [Numeric variables](#numeric-variables)
@@ -77,7 +77,7 @@ Each widget has a "style" field that may be:
7777
- `layout`: Layout container for arranging other widgets in rows or columns
7878
- `sidebar`: Special top-level widget for defining custom sidebars
7979

80-
"style" can also be `symbol` or `legend`, which are specific to [phrases](#phrases-and-conditions).
80+
"style" can also be `symbol` or `legend`, which are specific to [clauses](#clauses-and-conditions).
8181

8282
Let's start at the top, with the "sidebar" widget, composed of several "layout" widgets.
8383

@@ -511,26 +511,20 @@ Here are some flags that can be included:
511511
| `W_DYNAMIC_HEIGHT` | Allows certain multi-line widgets to dynamically adjust their height
512512

513513

514-
# Phrases and conditions
514+
# Clauses and conditions
515515

516-
Widgets can take advantage of "phrases" - definitions for what text/values to display and
516+
Widgets can take advantage of "clauses" - definitions for what text/values to display and
517517
how to display them. These take the form of a nested object containing several optional fields:
518518

519519
```json
520520
{
521521
"id": "bp_status_indicator_template",
522522
"type": "widget",
523523
"style": "text",
524-
"phrases": [
525-
{ "id": "bitten", "text": "bitten", "sym": "B", "color": "yellow", "condition": { ... } },
526-
{ "id": "infected", "text": "infected", "sym": "I", "color": "pink", "condition": { ... } },
527-
{ "id": "broken", "text": "broken", "sym": "%", "color": "magenta", "condition": { ... } },
528-
{ "id": "splinted", "text": "splinted", "sym": "=", "color": "light_gray", "condition": { ... } },
529-
{ "id": "bandaged", "text": "bandaged", "sym": "+", "color": "white", "condition": { ... } },
530-
{ "id": "disinfected", "text": "disinfected", "sym": "$", "color": "light_green", "condition": { ... } },
531-
{ "id": "bleeding", "text": "bleeding", "value": 0, "sym": "b", "color": "light_red", "condition": { ... } },
532-
{ "id": "bleeding", "text": "bleeding", "value": 11, "sym": "b", "color": "red", "condition": { ... } },
533-
{ "id": "bleeding", "text": "bleeding", "value": 21, "sym": "b", "color": "red_red", "condition": { ... } }
524+
"clauses": [
525+
{ "id": "bitten", "text": "bitten", "sym": "B", "color": "yellow", "condition": "..." },
526+
{ "id": "infected", "text": "infected", "sym": "I", "color": "pink", "condition": "..." },
527+
{ "id": "bandaged", "text": "bandaged", "sym": "+", "color": "white", "condition": "..." }
534528
]
535529
}
536530
```
@@ -540,36 +534,36 @@ which provides text and color definitions for different bodypart status conditio
540534

541535
| JSON Field | Description
542536
|--- |---
543-
| `id` | An optional identifier for this phrase
537+
| `id` | An optional identifier for this clause
544538
| `text` | Translated text that may be interpreted and displayed in the widget.
545539
| `sym` | A shortened symbol representing the text.
546-
| `color` | Defines the color for the text derived from this "phrase".
547-
| `value` | A numeric value for this "phrase", which may be interpreted differently based on the context of the parent widget.
548-
| `condition` | A dialogue condition (see [Dialogue conditions](NPCs.md#dialogue-conditions)) that dictates whether this phrase will be used or not. If the condition is true (or when no condition is defined), the phrase can be used to its text/symbol/color in the widget's value.
540+
| `color` | Defines the color for the text derived from this "clause".
541+
| `value` | A numeric value for this "clause", which may be interpreted differently based on the context of the parent widget.
542+
| `condition` | A dialogue condition (see [Dialogue conditions](NPCs.md#dialogue-conditions)) that dictates whether this clause will be used or not. If the condition is true (or when no condition is defined), the clause can be used to its text/symbol/color in the widget's value.
549543

550544

551545
## Conditions
552546

553-
Widget phrases and conditions can be used to define new widgets completely from JSON, using
547+
Widget clauses and conditions can be used to define new widgets completely from JSON, using
554548
[dialogue conditions](NPCs.md#dialogue-conditions). By omitting the widget's `var` field, the
555549
widget is interpreted as either a "text", "number", "symbol", or "legend" depending on the given
556-
`style`. The widget will evaluate each of its phrases to determine which ones to draw values from:
550+
`style`. The widget will evaluate each of its clauses to determine which ones to draw values from:
557551

558-
| Widget style | Phrase field used | Details | Example
552+
| Widget style | Clause field used | Details | Example
559553
|--- |--- |--- |---
560-
| `"number"` | `"value"` | Lists values as comma-separated-values from all phrases that have true conditions. | `Next threshold: 30, 40, 55`
561-
| `"text"` | `"text"` | Lists text as comma-separated-values from all phrases that have true conditions. | `TORSO: bleeding, broken, infected`
562-
| `"symbol"` | `"sym"` | Lists syms sequentially from all phrases that have true conditions. | `TORSO: b%I`
563-
| `"legend"` | `"sym"` and `"text"` | Lists syms and text in a paragraph format, with spaces between pairs, from all phrases that have true conditions. | `b bleeding % broken I infected`
554+
| `"number"` | `"value"` | Lists values as comma-separated-values from all clauses that have true conditions. | `Next threshold: 30, 40, 55`
555+
| `"text"` | `"text"` | Lists text as comma-separated-values from all clauses that have true conditions. | `TORSO: bleeding, broken, infected`
556+
| `"symbol"` | `"sym"` | Lists syms sequentially from all clauses that have true conditions. | `TORSO: b%I`
557+
| `"legend"` | `"sym"` and `"text"` | Lists syms and text in a paragraph format, with spaces between pairs, from all clauses that have true conditions. | `b bleeding % broken I infected`
564558

565559
Widgets using the `legend` style can be multiple lines high using a `height` > 1 (and optionally, the `W_DYNAMIC_HEIGHT` flag), so that the generated list can span the given vertical space.
566560

567-
Some conditions can be specific to certain bodyparts. In order to simplify phrases, these conditions can pull from the parent widget's `bodypart` field (or `bodyparts` field if defining multiple). This allows the same phrases to be `copy-from`'d to multiple widgets, and each widget can display the phrases depending on whether its bodypart(s) passes the condition (assuming the condition relies on a bodypart).
561+
Some conditions can be specific to certain bodyparts. In order to simplify clauses, these conditions can pull from the parent widget's `bodypart` field (or `bodyparts` field if defining multiple). This allows the same clauses to be `copy-from`'d to multiple widgets, and each widget can display the clauses depending on whether its bodypart(s) passes the condition (assuming the condition relies on a bodypart).
568562

569563

570-
## Default phrase
564+
## Default clause
571565

572-
Widgets can define a default phrase that will be used if none of the phrases in the `phrases`
566+
Widgets can define a default clause that will be used if none of the clauses in the `clauses`
573567
array pass their conditions:
574568

575569
```json
@@ -578,7 +572,7 @@ array pass their conditions:
578572
"type": "widget",
579573
"style": "text",
580574
"label": "Observation",
581-
"phrases": [
575+
"clauses": [
582576
{
583577
"text": "Good!",
584578
"color": "light_green",
@@ -590,7 +584,7 @@ array pass their conditions:
590584
"condition": { "u_has_trait": "UNOBSERVANT" }
591585
}
592586
],
593-
"default_phrase": {
587+
"default_clause": {
594588
"text": "Neutral!",
595589
"color": "white"
596590
}

0 commit comments

Comments
 (0)