# HG changeset patch # User Alys Brooks # Date 2021-07-30 20:48:30 # Node ID 6205f6d5b5e941d55a1f5a00deb5080f0e38c9d6 # Parent 8db748d8d30457b48c198b7c39bc87046e1c6530 Update variables based on game settings. diff --git a/TODO.taskpaper b/TODO.taskpaper --- a/TODO.taskpaper +++ b/TODO.taskpaper @@ -117,7 +117,7 @@ - Add a create park dialog @milestone(4: Beginning) - Procgen park names (that player can override) - Button to generate new name? - - Allow player to choose title @maybe + - Allow player to choose title @maybe @done(2021-07-29) Some possibilities: Mr., Ms., Mx., Director, Dr., Professor, Miss, Col., Herr Dr. Dr. nothing, custom Might be fun to have tiny acknowledgement of choice — probably dialog only, no mechanical change. (E.g., a researcher might allude to you having a PhD. or an enby character might say something comiserating.) - Allow player to choose difficulty diff --git a/isometric-park-fna/Content/grammar.json b/isometric-park-fna/Content/grammar.json --- a/isometric-park-fna/Content/grammar.json +++ b/isometric-park-fna/Content/grammar.json @@ -32,6 +32,8 @@ "Milton", "Coltrane", "Kim", "Lindgren", "Kerry", "Harris"], "greeting": [ "Hi", "Hello", "Greetings" ], "addressGreeting": "#greeting#, #name#", + "addressGreetingFormal": "#greeting#, #playerTitle# #playerFormal#", + "addressGreetingCasual": "#greeting#, #playerCasual#", "howdoing": [ "I'm good.", "Fine", "Alright, I guess." ], "city": ["Milwaukee", "Chicago", "Washington", "Minneapolis", "Dallas", "Oklahoma City", "Boston", "Los Angeles", "Portland", "Santa Fe", diff --git a/isometric-park-fna/Engines/ImGuiWindowBridgeEngine.cs b/isometric-park-fna/Engines/ImGuiWindowBridgeEngine.cs --- a/isometric-park-fna/Engines/ImGuiWindowBridgeEngine.cs +++ b/isometric-park-fna/Engines/ImGuiWindowBridgeEngine.cs @@ -20,7 +20,8 @@ typeof(SetResolutionMessage), typeof(SetFontMessage), typeof(SetTrespassingPolicyMessage), - typeof(SpawnGameMessage))] + typeof(SpawnGameMessage), + typeof(SetTextVariableMessage))] [Reads(typeof(VisibilityComponent), typeof(WindowTypeComponent), typeof(TrespassingPolicyComponent) @@ -40,6 +41,7 @@ public List fontMessages; public List trespassingPolicyMessages; public List spawnGameMessages; + public List setTextVariableMessages; bool showBudget {get;} bool showForest {get;} @@ -67,6 +69,7 @@ this.fontMessages = new List(); this.trespassingPolicyMessages = new List(); this.spawnGameMessages = new List(); + this.setTextVariableMessages = new List(); this.windowStatuses = new Dictionary(); @@ -140,6 +143,14 @@ { SendMessage(message); } + + //This may need to be moved up. + foreach (var message in this.setTextVariableMessages) + { + SendMessage(message); + } + + @@ -161,6 +172,7 @@ this.fontMessages.Clear(); this.trespassingPolicyMessages.Clear(); this.spawnGameMessages.Clear(); + this.setTextVariableMessages.Clear(); } } } diff --git a/isometric-park-fna/Engines/Spawners/GameSpawner.cs b/isometric-park-fna/Engines/Spawners/GameSpawner.cs --- a/isometric-park-fna/Engines/Spawners/GameSpawner.cs +++ b/isometric-park-fna/Engines/Spawners/GameSpawner.cs @@ -4,11 +4,12 @@ using Microsoft.Xna.Framework; +using isometricparkfna.Messages; +using static isometricparkfna.CellMap; +using isometricparkfna.UI; using Encompass; - -using isometricparkfna.Messages; -using static isometricparkfna.CellMap; +using TraceryNet; namespace isometricparkfna.Spawners { @@ -20,11 +21,15 @@ { private Simulation simulation; Random random_generator; + FNAGame game; + Grammar grammar; - public GameSpawner(Simulation simulation) + public GameSpawner(Simulation simulation, FNAGame game, Grammar grammar) { this.simulation = simulation; this.random_generator = new Random(); + this.game = game; + this.grammar = grammar; } protected override void Spawn(in SpawnGameMessage message) @@ -99,6 +104,10 @@ description = "#coop_company_description#", type = OrganizationType.Cooperative }); #endregion +#region dialog + + this.game.enqueueDialog(DialogTrees.flatten(DialogTrees.testTree, this.grammar)); +#endregion Logging.Success("Spawned new game."); } diff --git a/isometric-park-fna/FNAGame.cs b/isometric-park-fna/FNAGame.cs --- a/isometric-park-fna/FNAGame.cs +++ b/isometric-park-fna/FNAGame.cs @@ -252,9 +252,10 @@ WorldBuilder.AddEngine(new ContractStatusEngine(this.simulation)); WorldBuilder.AddEngine(new ContractSpawner(simulation.map.MapWidth, simulation.map.MapHeight, this.simulation, this.grammar)); - WorldBuilder.AddEngine(new GameSpawner(this.simulation)); + WorldBuilder.AddEngine(new GameSpawner(this.simulation, this, this.grammar)); WorldBuilder.AddEngine(new OrganizationSpawner(this.simulation, this.grammar)); WorldBuilder.AddEngine(new PolicyEngine()); + WorldBuilder.AddEngine(new TraceryBridgeEngine(this.grammar)); WorldBuilder.AddGeneralRenderer(new AreaRenderer(this.batch, this.monoFont), 1); WorldBuilder.AddGeneralRenderer(new ImGuiWindowRenderer(this, debugWindow.monoFont, debugWindow.italicFont, this.imGuiWindowBridgeEngine, this.gdm) , 2); @@ -341,9 +342,9 @@ this.remainingDialog = new Queue>(); -#if DEBUG - this.remainingDialog.Enqueue(DialogTrees.flatten(DialogTrees.testTree, this.grammar)); -#endif +// #if DEBUG +// this.remainingDialog.Enqueue(DialogTrees.flatten(DialogTrees.testTree, this.grammar)); +// #endif this.budgetWindow = new BudgetWindow(new Budget { }, this.monoFont, 0, 0); @@ -973,4 +974,9 @@ this.gdm.IsFullScreen = fullscreen; this.gdm.ApplyChanges(); } + + public void enqueueDialog(Node tree) + { + this.remainingDialog.Enqueue(tree); + } } diff --git a/isometric-park-fna/UI/Dialog.cs b/isometric-park-fna/UI/Dialog.cs --- a/isometric-park-fna/UI/Dialog.cs +++ b/isometric-park-fna/UI/Dialog.cs @@ -43,11 +43,12 @@ public static Node testTree = new Node( new DialogOption { - response = "#[name:player]addressGreeting#", + response = "#addressGreetingFormal#", speaker = "#assistantName#" }, - new Node[]{ + new Node(new DialogOption {choice="Call me #playerCasual#", response="Sure", + speaker = "#assistantName#" }), new Node(new DialogOption {choice="Hi.", response="Bye!", speaker = "#assistantName#" }), new Node(new DialogOption {choice="How are you?", response="#howdoing#", @@ -98,7 +99,6 @@ } - } } diff --git a/isometric-park-fna/UI/NewGameWindow.cs b/isometric-park-fna/UI/NewGameWindow.cs --- a/isometric-park-fna/UI/NewGameWindow.cs +++ b/isometric-park-fna/UI/NewGameWindow.cs @@ -19,7 +19,6 @@ Hard } - public static class NewGameWindow { @@ -44,12 +43,14 @@ public static bool showModal; + public const int BUFFER_SIZE = 32; + public static void Initialize() { - parkNameBuffer = new byte[32]; + parkNameBuffer = new byte[BUFFER_SIZE]; pos = 0; - playerNameBuffer = new byte[32]; + playerNameBuffer = new byte[BUFFER_SIZE]; playerNamePos = 0; selectedTitle = ""; @@ -57,7 +58,7 @@ playerName2Buffer = ""; playerName2Pos = 0; - customTitleBuffer = new byte[32]; + customTitleBuffer = new byte[BUFFER_SIZE]; customTitlePos = 0; showModal = true; @@ -179,7 +180,7 @@ //God this sucks: unsafe { - ImGui.InputTextWithHint("##playerName2", "Leave blank to use full name", playerName2Buffer, 32, ImGuiInputTextFlags.AutoSelectAll, null, (IntPtr)(&newPlayerNamePos)); + ImGui.InputTextWithHint("##playerName2", "Leave blank to use full name", ref playerName2Buffer, 32, ImGuiInputTextFlags.AutoSelectAll, null, (IntPtr)(&newPlayerName2Pos)); } NewGameWindow.playerName2Pos = newPlayerName2Pos; @@ -191,6 +192,11 @@ if (ImGui.Button("Okay")) { + + bridgeEngine.setTextVariableMessages.Add(new SetTextVariableMessage { variable = "playerFormal", value = System.Text.Encoding.UTF8.GetString(playerNameBuffer) }); + bridgeEngine.setTextVariableMessages.Add(new SetTextVariableMessage { variable = "playerCasual", value = playerName2Buffer }); + bridgeEngine.setTextVariableMessages.Add(new SetTextVariableMessage { variable = "playerTitle", value = selectedTitle}); + bridgeEngine.spawnGameMessages.Add(new SpawnGameMessage{}); bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage {Window = Window.NewGame}); bridgeEngine.gameStateMessages.Add(new GameStateMessage { isPlaying = true});