Description:
Add profanity settings.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r417:ab75bb171839 -

@@ -0,0 +1,9
1 using Encompass;
2
3 namespace isometricparkfna.Components {
4
5 public struct OptionsComponent : IComponent {
6 public ProfanityLevel ProfanitySetting;
7
8 }
9 }
@@ -0,0 +1,10
1 using Microsoft.Xna.Framework;
2 using Encompass;
3
4 namespace isometricparkfna.Messages
5 {
6 public struct SetOptionMessage : IMessage
7 {
8 public ProfanityLevel NewProfanitySetting;
9 }
10 }
@@ -47,6 +47,8
47 47 \#assistantName\#: Hello. I'm \#assistantName\#.
48 48 * [Nice to meet you.]
49 49 You can use the mouse or arrow keys to move around, and the plus and minus keys to zoom in and out. B opens the budget and F lets you adjust Forest Policy.
50
51 -> BadNewsReact ->
50 52
51 53 * * [Got it, thanks.]
52 54
@@ -1,1 +1,1
1 {"inkVersion":20,"root":[[["done",{"#f":5,"#n":"g-0"}],null],"done",{"placeholder":["end",{"#f":1}],"Once":[["^Once upon a time...","\n",["ev",{"^->":"Once.0.2.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-0","flg":18},{"s":["^There were two choices.",{"->":"$r","var":true},null]}],["ev",{"^->":"Once.0.3.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-1","flg":18},{"s":["^There were four lines of content.",{"->":"$r","var":true},null]}],{"c-0":["ev",{"^->":"Once.0.c-0.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.2.s"},[{"#n":"$r2"}],"\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["ev",{"^->":"Once.0.c-1.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.3.s"},[{"#n":"$r2"}],"\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":["^They lived happily ever after.","\n","end",{"#f":5}]}],{"#f":1}],"IntroGovernor":[["^Governor: Welcome to your new park, director!","\n","ev","str","^Okay","/str","/ev",{"*":".^.c-0","flg":20},{"c-0":["\n","^Governor: Make sure that you keep visitors happy and the budget in the black! You're currently getting an annual grant out of my budget—it'd sure be nice if you park were self-sufficient so we could drop that expense!","\n",["ev","str","^And I need to keep the forest healthy, too, right?","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Sounds good!","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["^ ","\n","ev",{"VAR?":"GovernorOpinion"},1,"-","/ev",{"VAR=":"GovernorOpinion","re":true},"^Governor: Ummm, yeah","\n",["ev","str","^...","/str","/ev",{"*":".^.c-0","flg":20},{"c-0":["\n","end",{"#f":5}]}],{"#f":5}],"c-1":["\n","ev",{"VAR?":"GovernorOpinion"},1,"+","/ev",{"VAR=":"GovernorOpinion","re":true},"^Governor: I'll check in soon.","\n","end",{"#f":5}]}],{"#f":5}]}],{"#f":1}],"IntroAssistant":[["^#assistantName#: Hello. I'm #assistantName#.","\n","ev","str","^Nice to meet you.","/str","/ev",{"*":".^.c-0","flg":20},{"c-0":["\n","^You can use the mouse or arrow keys to move around, and the plus and minus keys to zoom in and out. B opens the budget and F lets you adjust Forest Policy.","\n",["ev","str","^Got it, thanks.","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^How are you?","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["\n","^#assistantName#: Bye","\n","end",{"#f":5}],"c-1":["\n","^#assistantName#: #howdoing#","\n","end",{"#f":5}]}],{"#f":5}]}],{"#f":1}],"BadNewsReact":[["ev","str","^Damn.","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Fuck.","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Shoot.","/str","/ev",{"*":".^.c-2","flg":20},{"c-0":["\n","ev","void","/ev","->->",{"#f":5}],"c-1":["\n","ev","void","/ev","->->",{"#f":5}],"c-2":["\n","ev","void","/ev","->->",{"#f":5}]}],{"#f":1}],"global decl":["ev",0,{"VAR=":"GovernorOpinion"},"/ev","end",null],"#f":1}],"listDefs":{}} No newline at end of file
1 {"inkVersion":20,"root":[[["done",{"#f":5,"#n":"g-0"}],null],"done",{"placeholder":["end",{"#f":1}],"Once":[["^Once upon a time...","\n",["ev",{"^->":"Once.0.2.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-0","flg":18},{"s":["^There were two choices.",{"->":"$r","var":true},null]}],["ev",{"^->":"Once.0.3.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-1","flg":18},{"s":["^There were four lines of content.",{"->":"$r","var":true},null]}],{"c-0":["ev",{"^->":"Once.0.c-0.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.2.s"},[{"#n":"$r2"}],"\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["ev",{"^->":"Once.0.c-1.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.3.s"},[{"#n":"$r2"}],"\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":["^They lived happily ever after.","\n","end",{"#f":5}]}],{"#f":1}],"IntroGovernor":[["^Governor: Welcome to your new park, director!","\n","ev","str","^Okay","/str","/ev",{"*":".^.c-0","flg":20},{"c-0":["\n","^Governor: Make sure that you keep visitors happy and the budget in the black! You're currently getting an annual grant out of my budget—it'd sure be nice if you park were self-sufficient so we could drop that expense!","\n",["ev","str","^And I need to keep the forest healthy, too, right?","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Sounds good!","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["^ ","\n","ev",{"VAR?":"GovernorOpinion"},1,"-","/ev",{"VAR=":"GovernorOpinion","re":true},"^Governor: Ummm, yeah","\n",["ev","str","^...","/str","/ev",{"*":".^.c-0","flg":20},{"c-0":["\n","end",{"#f":5}]}],{"#f":5}],"c-1":["\n","ev",{"VAR?":"GovernorOpinion"},1,"+","/ev",{"VAR=":"GovernorOpinion","re":true},"^Governor: I'll check in soon.","\n","end",{"#f":5}]}],{"#f":5}]}],{"#f":1}],"IntroAssistant":[["^#assistantName#: Hello. I'm #assistantName#.","\n","ev","str","^Nice to meet you.","/str","/ev",{"*":".^.c-0","flg":20},{"c-0":["\n","^You can use the mouse or arrow keys to move around, and the plus and minus keys to zoom in and out. B opens the budget and F lets you adjust Forest Policy.","\n",{"->t->":"BadNewsReact"},["ev","str","^Got it, thanks.","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^How are you?","/str","/ev",{"*":".^.c-1","flg":20},{"c-0":["\n","^#assistantName#: Bye","\n","end",{"#f":5}],"c-1":["\n","^#assistantName#: #howdoing#","\n","end",{"#f":5}]}],{"#f":5}]}],{"#f":1}],"BadNewsReact":[["ev","str","^Damn.","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Fuck.","/str","/ev",{"*":".^.c-1","flg":20},"ev","str","^Shoot.","/str","/ev",{"*":".^.c-2","flg":20},{"c-0":["\n","ev","void","/ev","->->",{"#f":5}],"c-1":["\n","ev","void","/ev","->->",{"#f":5}],"c-2":["\n","ev","void","/ev","->->",{"#f":5}]}],{"#f":1}],"global decl":["ev",0,{"VAR=":"GovernorOpinion"},"/ev","end",null],"#f":1}],"listDefs":{}} No newline at end of file
@@ -1,6 +1,7
1 1 using System;
2 2 using System.Text.RegularExpressions;
3 3 using System.Linq;
4 using System.Collections.Generic;
4 5
5 6 using Encompass;
6 7 using Ink.Runtime;
@@ -14,10 +15,18
14 15
15 16 [Receives(typeof(SetDialogMessage),
16 17 typeof(DialogChoiceMessage))]
17 [Reads(typeof(DialogComponent)) ]
18 [Reads(typeof(DialogComponent),
19 typeof(OptionsComponent)) ]
18 20 [Writes( typeof(DialogComponent))]
19 21 class DialogEngine : Engine
20 22 {
23 public static Dictionary<string, string> replacements = new Dictionary<string,string>{{"Damn", "Drat"},
24 {"Fuck", "Fork"}, //Ty michael shur
25 {"Motherfucker", "Motherforker"},
26 {"Shit", "Shitake mushrooms"},
27 {"Hell", "Heck"},
28 {"Oh my God", "Oh my Glob"}, //Ty Pendleton Ward
29 {"Bastard", "Bollocks"}};
21 30 public Story Story;
22 31 public Grammar Grammar;
23 32
@@ -27,9 +36,38
27 36 this.Grammar = grammar;
28 37 }
29 38
39 public string BleepString(string s, ProfanityLevel setting)
40 {
41 switch (setting)
42 {
43 case ProfanityLevel.Uncensored:
44 return s;
45 break;
46 case ProfanityLevel.Minced:
47 foreach (var item in replacements)
48 {
49 s = s.Replace(item.Key, item.Value);
50 }
51 return s;
52 break;
53 case ProfanityLevel.Removed:
54 return Regex.Replace(s, "(?i)((?<=d)amn|(?<=f)uck|(?<=D)amn|(?<=F)uck)", "------");
55 }
56 return s;
57 }
58
30 59 public override void Update(double dt)
31 60 {
32 61
62 ProfanityLevel profanity_setting = default;
63
64 foreach (ref readonly var entity in ReadEntities<OptionsComponent>())
65 {
66 var option_component = GetComponent<OptionsComponent>(entity);
67
68 profanity_setting = option_component.ProfanitySetting;
69 }
70
33 71 foreach (ref readonly var dialogMessage in ReadMessages<SetDialogMessage>())
34 72 {
35 73 if (dialogMessage.newOption != null)
@@ -60,7 +98,8
60 98 CurrentDialog = dialog,
61 99 CurrentSpeaker = speaker,
62 100 Options = this.Story.currentChoices
63 .Select(option => option.text)
101 .Select(option => BleepString(option.text,
102 profanity_setting ))
64 103 .ToList()});}
65 104 else
66 105 {
@@ -18,7 +18,8
18 18 typeof(SetResolutionMessage),
19 19 typeof(SetFontMessage))]
20 20 [Reads(typeof(AreaComponent),
21 typeof(ContractStatusComponent))]
21 typeof(ContractStatusComponent),
22 typeof(OptionsComponent))]
22 23 class GameBridgeEngine : Engine
23 24 {
24 25
@@ -32,6 +33,8
32 33 public override void Update(double dt)
33 34 {
34 35
36 ProfanityLevel profanity_setting = default;
37
35 38 foreach (ref readonly var windowMessage in ReadMessages<ToggleWindowTypeMessage>())
36 39 {
37 40 switch (windowMessage.Window)
@@ -74,10 +77,17
74 77 resolutionMessage.fullscreen);
75 78
76 79 }
80 foreach (ref readonly var entity in ReadEntities<OptionsComponent>())
81 {
82 var component = GetComponent<OptionsComponent>(entity);
83
84 profanity_setting = component.ProfanitySetting;
85 }
77 86 foreach (ref readonly var fontMessage in ReadMessages<SetFontMessage>())
78 87 {
79 88 game.setFont(fontMessage.fontName, fontMessage.fontSize);
80 Options.writeOptions(fontMessage.fontName, fontMessage.fontSize);
89 Options.writeOptions(fontMessage.fontName, fontMessage.fontSize,
90 profanity_setting);
81 91
82 92 }
83 93
@@ -102,4 +112,4
102 112
103 113 }
104 114 }
105 } No newline at end of file
115 }
@@ -24,18 +24,18
24 24 typeof(SpawnGameMessage),
25 25 typeof(SetTextVariableMessage),
26 26 typeof(SetDialogMessage),
27 typeof(DialogChoiceMessage))]
27 typeof(DialogChoiceMessage),
28 typeof(SetOptionMessage))]
28 29 [Reads(typeof(VisibilityComponent),
29 30 typeof(WindowTypeComponent),
30 31 typeof(TrespassingPolicyComponent),
31 32 typeof(ContractStatusComponent),
32 33 typeof(RelatedOrganizationComponent),
33 typeof(NameAndDescriptionComponent)
34 )]
35 // [Writes(typeof(SelectedComponent))]
34 typeof(NameAndDescriptionComponent),
35 typeof(OptionsComponent))]
36 [Writes(typeof(OptionsComponent))]
36 37 public class ImGuiWindowBridgeEngine : Engine
37 38 {
38
39 39 public List<ToggleWindowMessage> messages;
40 40 public List<ToggleWindowTypeMessage> typeMessages;
41 41 public List<ChangeContractStatusMessage> contractStatusMessages;
@@ -49,6 +49,7
49 49 public List<SetTextVariableMessage> setTextVariableMessages;
50 50 public List<SetDialogMessage> setDialogMessages;
51 51 public List<DialogChoiceMessage> dialogChoiceMessages;
52 public List<SetOptionMessage> setOptionMessages;
52 53
53 54 bool showBudget {get;}
54 55 bool showForest {get;}
@@ -88,6 +89,7
88 89 this.setTextVariableMessages = new List<SetTextVariableMessage>();
89 90 this.setDialogMessages = new List<SetDialogMessage>();
90 91 this.dialogChoiceMessages = new List<DialogChoiceMessage>();
92 this.setOptionMessages = new List<SetOptionMessage>();
91 93 this.windowStatuses = new Dictionary<Window, bool>();
92 94
93 95 this.showContractIndicator = false;
@@ -166,12 +168,12
166 168 {
167 169 SendMessage(message);
168 170 }
169
171
170 172 foreach (var message in this.spawnGameMessages)
171 173 {
172 174 SendMessage(message);
173 175 }
174
176
175 177
176 178 foreach (var message in this.setDialogMessages)
177 179 {
@@ -182,6 +184,17
182 184 SendMessage(message);
183 185 }
184 186
187 foreach(var message in this.setOptionMessages)
188 {
189 foreach(var entity in ReadEntities<OptionsComponent>())
190 {
191
192 SetComponent(entity, new OptionsComponent {
193 ProfanitySetting = message.NewProfanitySetting});
194 }
195
196 }
197
185 198
186 199
187 200
@@ -230,6 +243,7
230 243 this.setTextVariableMessages.Clear();
231 244 this.setDialogMessages.Clear();
232 245 this.dialogChoiceMessages.Clear();
246 this.setOptionMessages.Clear();
233 247 }
234 248 }
235 249 }
@@ -198,7 +198,6
198 198 Quad.Initialize(GraphicsDevice, texture);
199 199 Logging.Success("Initialized Quad texture.");
200 200 ContractWindow.LoadContent(this._imGuiRenderer, this.imageMap);
201 OptionsWindow.Initialize(new Vector2(FNAGame.width, FNAGame.height), gdm.IsFullScreen);
202 201
203 202 //Must be done before SetFontMessage is sent
204 203 var bakedMono = TtfFontBaker.Bake(File.OpenRead(@"Content/iosevka-term-extendedmedium.ttf"),
@@ -320,7 +319,12
320 319 this.imGuiWindowBridgeEngine.fontMessages.Add(new SetFontMessage{
321 320 fontSize = options.fontSize,
322 321 fontName = options.fontName});
322
323 WorldBuilder.SetComponent(gameEntity, new OptionsComponent {ProfanitySetting = options.profanitySetting});
324
325 OptionsWindow.Initialize(new Vector2(FNAGame.width, FNAGame.height), gdm.IsFullScreen, options.profanitySetting);
323 326 Logging.Success("Loaded options.");
327
324 328 }
325 329 catch (FileNotFoundException e)
326 330 {
@@ -4,22 +4,34
4 4
5 5 namespace isometricparkfna
6 6 {
7
8 public enum ProfanityLevel
9 {
10 Uncensored,
11 Minced,
12 Removed
13
14 }
15
7 16 public class Options
8 17 {
9 18
10 19 public string fontName;
11 20 public int fontSize;
21 public ProfanityLevel profanitySetting;
12 22
13 public Options(string fontName, int fontSize)
23 public Options(string fontName, int fontSize, ProfanityLevel profanitySetting)
14 24 {
15 25 this.fontName = fontName;
16 26 this.fontSize = fontSize;
27 this.profanitySetting = profanitySetting;
28
17 29 }
18 30
19 public static void writeOptions(string fontName, int fontSize)
31 public static void writeOptions(string fontName, int fontSize, ProfanityLevel profanitySetting)
20 32 {
21 33
22 var options = new Options(fontName, fontSize);
34 var options = new Options(fontName, fontSize, profanitySetting);
23 35
24 36 string json = JsonConvert.SerializeObject(options,
25 37 Formatting.Indented);
@@ -54,6 +54,7
54 54 var area_size = GetComponent<AreaComponent>(entity).squares.Length;
55 55
56 56
57
57 58 if (HasComponent<RelatedOrganizationComponent>(entity))
58 59 {
59 60 var related_organization = GetComponent<RelatedOrganizationComponent>(entity).Entity;
@@ -88,6 +89,12
88 89 Entity dialogEntity = default;
89 90 DialogComponent dialogNode = default;
90 91
92 ProfanityLevel profanityLevel = default;
93
94 foreach (ref readonly var entity in ReadEntities<OptionsComponent>())
95 {
96 profanityLevel = GetComponent<OptionsComponent>(entity).ProfanitySetting;
97 }
91 98
92 99
93 100 foreach (ref readonly var entity in ReadEntities<WindowTypeComponent>())
@@ -127,7 +134,7
127 134 InGameMenu.Render(this.BridgeEngine.font, this.BridgeEngine, width);
128 135 break;
129 136 case Window.Options:
130 OptionsWindow.Render(this.BridgeEngine.font, this.BridgeEngine.italicFont, this.BridgeEngine, width);
137 OptionsWindow.Render(this.BridgeEngine.font, this.BridgeEngine.italicFont, this.BridgeEngine, width, profanityLevel);
131 138 break;
132 139 case Window.NewGame:
133 140 NewGameWindow.Render(this.BridgeEngine.font, this.BridgeEngine.italicFont, this.BridgeEngine);
@@ -21,31 +21,27
21 21
22 22 private static string fontName = "Iosevka";
23 23 private static int fontSize = 15;
24 private static ProfanityLevel profanityLevel = default;
24 25
25 public static void Initialize(Vector2 resolution, bool fullscreen)
26 public static void Initialize(Vector2 resolution, bool fullscreen, ProfanityLevel profanityLevel)
26 27 {
27 28
28 newFullscreen = fullscreen;
29 newResolution = resolution;
29 OptionsWindow.newFullscreen = fullscreen;
30 OptionsWindow.newResolution = resolution;
31 OptionsWindow.profanityLevel = profanityLevel;
30 32 }
31 33
32 public static void Render(ImFontPtr font, ImFontPtr italicFont, ImGuiWindowBridgeEngine bridgeEngine, int width)
34 public static void Render(ImFontPtr font, ImFontPtr italicFont, ImGuiWindowBridgeEngine bridgeEngine, int width, ProfanityLevel profanityLevel)
33 35 {
34 36
35 37 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
36 38 bool newShow = true;
37 39
38 // Num.Vector2 button_size = new Num.Vector2(120, 20);
39
40 40 StyleSets.defaultSet.push();
41 41
42 42
43 // ImGui.SetNextWindowPos(new Num.Vector2(width/2, 200));
43 ImGui.PushFont(font);
44 44
45 ImGui.PushFont(font);
46 // ImGui.PushFont(smallFont);
47 //
48 // ImGui.SetNextWindowSize(new Num.Vector2(320, 320));
49 45 if(OptionsWindow.hadFocus)
50 46 {
51 47 ImGui.PushStyleColor(ImGuiCol.Text, StyleSets.white);
@@ -137,6 +133,31
137 133
138 134 ImGui.Separator();
139 135
136 ImGui.PushFont(italicFont);
137 ImGui.Text("Text:");
138 ImGui.PopFont();
139
140 ImGui.Text("Profanity:");
141 ImGui.SameLine();
142 if (ImGui.BeginCombo("##Profanity", profanityLevel.ToString()))
143 {
144
145 foreach(var level in Enum.GetValues(typeof(ProfanityLevel)))
146 {
147 if(ImGui.Selectable(level.ToString()))
148 {
149 bridgeEngine.setOptionMessages.Add(new SetOptionMessage{ NewProfanitySetting = (ProfanityLevel)level});
150 OptionsWindow.profanityLevel = (ProfanityLevel)level;
151 }
152
153 }
154
155 ImGui.EndCombo();
156 }
157
158
159
160 ImGui.Separator();
140 161
141 162 if (ImGui.Button("Okay"))
142 163 {
You need to be logged in to leave comments. Login now