public static void ProcessAllGameText(IGameTextProcessor processor, Game game, CompileMessages errors) { foreach (Dialog dialog in game.RootDialogFolder.AllItemsFlat) { foreach (DialogOption option in dialog.Options) { option.Text = processor.ProcessText(option.Text, GameTextType.DialogOption, game.PlayerCharacter.ID); } dialog.Script = processor.ProcessText(dialog.Script, GameTextType.DialogScript); } foreach (ScriptAndHeader script in game.RootScriptFolder.AllItemsFlat) { string newScript = processor.ProcessText(script.Script.Text, GameTextType.Script); if (newScript != script.Script.Text) { // Only cause it to flag Modified if we changed it script.Script.Text = newScript; } } foreach (GUI gui in game.RootGUIFolder.AllItemsFlat) { foreach (GUIControl control in gui.Controls) { GUILabel label = control as GUILabel; if (label != null) { label.Text = processor.ProcessText(label.Text, GameTextType.ItemDescription); } else { GUIButton button = control as GUIButton; if (button != null) { button.Text = processor.ProcessText(button.Text, GameTextType.ItemDescription); } } } } foreach (Character character in game.RootCharacterFolder.AllItemsFlat) { character.RealName = processor.ProcessText(character.RealName, GameTextType.ItemDescription); } foreach (InventoryItem item in game.RootInventoryItemFolder.AllItemsFlat) { item.Description = processor.ProcessText(item.Description, GameTextType.ItemDescription); } for (int i = 0; i < game.GlobalMessages.Length; i++) { game.GlobalMessages[i] = processor.ProcessText(game.GlobalMessages[i], GameTextType.Message); } Factory.AGSEditor.RunProcessAllGameTextsEvent(processor, errors); }
public static void ProcessAllGameText(IGameTextProcessor processor, Game game, CompileMessages errors) { foreach (Dialog dialog in game.Dialogs) { foreach (DialogOption option in dialog.Options) { option.Text = processor.ProcessText(option.Text, GameTextType.DialogOption, game.PlayerCharacter.ID); } dialog.Script = processor.ProcessText(dialog.Script, GameTextType.DialogScript); } foreach (Script script in game.Scripts) { if (!script.IsHeader) { string newScript = processor.ProcessText(script.Text, GameTextType.Script); if (newScript != script.Text) { // Only cause it to flag Modified if we changed it script.Text = newScript; } } } foreach (GUI gui in game.GUIs) { foreach (GUIControl control in gui.Controls) { if (control is GUILabel) { ((GUILabel)control).Text = processor.ProcessText(((GUILabel)control).Text, GameTextType.ItemDescription); } else if (control is GUIButton) { ((GUIButton)control).Text = processor.ProcessText(((GUIButton)control).Text, GameTextType.ItemDescription); } } } foreach (Character character in game.Characters) { character.RealName = processor.ProcessText(character.RealName, GameTextType.ItemDescription); } foreach (InventoryItem item in game.InventoryItems) { item.Description = processor.ProcessText(item.Description, GameTextType.ItemDescription); } for (int i = 0; i < game.GlobalMessages.Length; i++) { game.GlobalMessages[i] = processor.ProcessText(game.GlobalMessages[i], GameTextType.Message); } Factory.AGSEditor.RunProcessAllGameTextsEvent(processor, errors); }
private static void ProcessPropertySchema(IGameTextProcessor processor, CustomPropertySchema schema, CompileMessages errors) { foreach (var def in schema.PropertyDefinitions.Where(n => n.Type == CustomPropertyType.Text)) { def.DefaultValue = processor.ProcessText(def.DefaultValue, GameTextType.ItemDescription); } }
public static void ProcessProperties(IGameTextProcessor processor, CustomPropertySchema schema, CustomProperties props, CompileMessages errors) { foreach (var def in schema.PropertyDefinitions.Where(n => n.Type == CustomPropertyType.Text)) { CustomProperty prop; if (props.PropertyValues.TryGetValue(def.Name, out prop)) { prop.Value = processor.ProcessText(prop.Value, GameTextType.ItemDescription); } } }
private void AGSEditor_ProcessAllGameTexts(IGameTextProcessor processor, CompileMessages errors) { if (processor.MakesChanges) { if (!CheckOutAllRoomsAndScripts()) { errors.Add(new CompileError("Failed to open room files for writing")); return; } } foreach (UnloadedRoom unloadedRoom in _agsEditor.CurrentGame.Rooms) { UnloadCurrentRoom(); Room room = LoadNewRoomIntoMemory(unloadedRoom, errors); room.Script.Text = processor.ProcessText(room.Script.Text, GameTextType.Script); if (processor.MakesChanges) { room.Script.SaveToDisk(); } foreach (RoomMessage message in room.Messages) { int charId = message.CharacterID; if (!message.ShowAsSpeech) { charId = Character.NARRATOR_CHARACTER_ID; } message.Text = processor.ProcessText(message.Text, GameTextType.Message, charId); } foreach (RoomHotspot hotspot in room.Hotspots) { hotspot.Description = processor.ProcessText(hotspot.Description, GameTextType.ItemDescription); } foreach (RoomObject obj in room.Objects) { obj.Description = processor.ProcessText(obj.Description, GameTextType.ItemDescription); } if (processor.MakesChanges) { CompileMessages roomErrors = new CompileMessages(); SaveRoomButDoNotShowAnyErrors(room, roomErrors, "Saving updates to room " + room.Number + "..."); if (roomErrors.Count > 0) { errors.Add(new CompileError("Failed to save room " + room.FileName + "; details below")); errors.Add(roomErrors[0]); } } } }