-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support custom attributes defined in scenarios (#1058)
closes #1034 ## Demo scripts/play.sh --scenario data/scenarios/Testing/1034-custom-attributes.yaml ![Screenshot from 2023-01-28 01-24-38](https://user-images.githubusercontent.com/261693/215258494-cf4cb365-ec8c-4820-9308-b374e5da9c3c.png)
- Loading branch information
Showing
11 changed files
with
248 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,4 @@ | |
961-custom-capabilities.yaml | ||
956-GPS.yaml | ||
958-isempty.yaml | ||
1034-custom-attributes.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
version: 1 | ||
name: Rainbow color custom attributes | ||
description: | | ||
Custom attributes with rainbow colors | ||
creative: false | ||
attrs: | ||
- name: rainbow1 | ||
fg: "#ffadad" | ||
- name: rainbow2 | ||
fg: "#ffd6a5" | ||
- name: rainbow3 | ||
fg: "#ffff96" | ||
- name: rainbow4 | ||
fg: "#caffbf" | ||
- name: rainbow5 | ||
fg: "#9bf6ff" | ||
- name: rainbow6 | ||
fg: "#a0c4ff" | ||
- name: rainbow7 | ||
fg: "#bdb2ff" | ||
- name: redOnYellow | ||
fg: "#ff0000" | ||
bg: ffff00 | ||
- name: cyanOnMagenta | ||
fg: 00ffff | ||
bg: "#ff00ff" | ||
- name: italicAndUnderline | ||
style: | ||
- Italic | ||
- Underline | ||
- name: boldAndStrikethrough | ||
style: | ||
- Bold | ||
- Strikethrough | ||
entities: | ||
- name: color1 | ||
display: | ||
char: '▒' | ||
attr: rainbow1 | ||
description: | ||
- c1 | ||
properties: [known] | ||
- name: color2 | ||
display: | ||
char: '▒' | ||
attr: rainbow2 | ||
description: | ||
- c2 | ||
properties: [known] | ||
- name: color3 | ||
display: | ||
char: '▒' | ||
attr: rainbow3 | ||
description: | ||
- c3 | ||
properties: [known] | ||
- name: color4 | ||
display: | ||
char: '▒' | ||
attr: rainbow4 | ||
description: | ||
- c4 | ||
properties: [known] | ||
- name: color5 | ||
display: | ||
char: '▒' | ||
attr: rainbow5 | ||
description: | ||
- c5 | ||
properties: [known] | ||
- name: color6 | ||
display: | ||
char: '▒' | ||
attr: rainbow6 | ||
description: | ||
- c6 | ||
properties: [known] | ||
- name: color7 | ||
display: | ||
char: '▒' | ||
attr: rainbow7 | ||
description: | ||
- c7 | ||
properties: [known] | ||
- name: redYellow | ||
display: | ||
char: 'R' | ||
attr: redOnYellow | ||
description: | ||
- Red on Yellow | ||
properties: [known] | ||
- name: cyanMagenta | ||
display: | ||
char: 'C' | ||
attr: cyanOnMagenta | ||
description: | ||
- Cyan on Magenta | ||
properties: [known] | ||
- name: italicUnderline | ||
display: | ||
char: 'X' | ||
attr: italicAndUnderline | ||
description: | ||
- Italic and Underline | ||
properties: [known] | ||
- name: boldStrikethrough | ||
display: | ||
char: 'X' | ||
attr: boldAndStrikethrough | ||
description: | ||
- Bold and Strikethrough | ||
properties: [known] | ||
robots: [] | ||
world: | ||
default: [blank] | ||
palette: | ||
'.': [blank] | ||
'1': [blank, color1] | ||
'2': [blank, color2] | ||
'3': [blank, color3] | ||
'4': [blank, color4] | ||
'5': [blank, color5] | ||
'6': [blank, color6] | ||
'7': [blank, color7] | ||
'R': [blank, redYellow] | ||
'C': [blank, cyanMagenta] | ||
'I': [blank, italicUnderline] | ||
'B': [blank, boldStrikethrough] | ||
upperleft: [0, 0] | ||
map: |- | ||
.1234567..R.....II. | ||
.1234567..R........ | ||
.1234567.....C..BB. | ||
.1234567.....C..... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module Swarm.Game.Scenario.Style where | ||
|
||
import Data.Aeson | ||
import Data.Set (Set) | ||
import Data.Text (Text) | ||
import GHC.Generics (Generic) | ||
|
||
data StyleFlag | ||
= Standout | ||
| Italic | ||
| Strikethrough | ||
| Underline | ||
| ReverseVideo | ||
| Blink | ||
| Dim | ||
| Bold | ||
deriving (Eq, Ord, Show, Generic) | ||
|
||
styleFlagJsonOptions :: Options | ||
styleFlagJsonOptions = | ||
defaultOptions | ||
{ sumEncoding = UntaggedValue | ||
} | ||
|
||
instance FromJSON StyleFlag where | ||
parseJSON = genericParseJSON styleFlagJsonOptions | ||
|
||
newtype HexColor = HexColor Text | ||
deriving (Eq, Show, Generic, FromJSON) | ||
|
||
data CustomAttr = CustomAttr | ||
{ name :: String | ||
, fg :: Maybe HexColor | ||
, bg :: Maybe HexColor | ||
, style :: Maybe (Set StyleFlag) | ||
} | ||
deriving (Eq, Show, Generic, FromJSON) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.