private void SelectCharacter(AgsView view, Character character, int xClick, int yClick, RoomEditorState state) { int spriteNum = 0; if (view.Loops[0].Frames.Count > 0) { ViewFrame thisFrame = view.Loops[0].Frames[0]; spriteNum = thisFrame.Image; } int width = GetSpriteWidthForGameResolution(spriteNum); int height = GetSpriteHeightForGameResolution(spriteNum); if ((xClick >= character.StartX - (width / 2)) && (xClick < character.StartX + (width / 2)) && (yClick >= character.StartY - height) && (yClick < character.StartY)) { if (!state.DragFromCenter) { _mouseOffsetX = xClick - character.StartX; _mouseOffsetY = yClick - character.StartY; } else { _mouseOffsetX = 0; _mouseOffsetY = 0; } _selectedCharacter = character; _movingCharacterWithMouse = true; } }
public void MouseDown(MouseEventArgs e, RoomEditorState state) { int xClick = (e.X + state.ScrollOffsetX) / state.ScaleFactor; int yClick = (e.Y + state.ScrollOffsetY) / state.ScaleFactor; _selectedCharacter = null; foreach (Character character in _game.RootCharacterFolder.AllItemsFlat) { if (_room.Number == character.StartingRoom) { AgsView view = _game.FindViewByID(character.NormalView); if (view != null && view.Loops.Count > 0) { SelectCharacter(view, character, xClick, yClick, state); } } } if (_selectedCharacter != null) { Factory.GUIController.SetPropertyGridObject(_selectedCharacter); } else { Factory.GUIController.SetPropertyGridObject(_room); } }
public override void CommandClick(string controlID) { if (controlID == COMMAND_NEW_ITEM) { IList<Character> items = _agsEditor.CurrentGame.Characters; Character newItem = new Character(); newItem.ID = items.Count; newItem.ScriptName = _agsEditor.GetFirstAvailableScriptName("cChar"); newItem.RealName = "New character"; newItem.StartingRoom = -1; items.Add(newItem); _guiController.ProjectTree.StartFromNode(this, TOP_LEVEL_COMMAND_ID); _guiController.ProjectTree.AddTreeLeaf(this, "Chr" + newItem.ID, newItem.ID.ToString() + ": " + newItem.ScriptName, "CharacterIcon"); _guiController.ProjectTree.SelectNode(this, "Chr" + newItem.ID); ShowOrAddPane(newItem); } else if (controlID == COMMAND_IMPORT) { string fileName = _guiController.ShowOpenFileDialog("Select character to import...", CHARACTER_IMPORT_FILE_FILTER); if (fileName != null) { ImportCharacter(fileName); } } else if (controlID == COMMAND_EXPORT) { string fileName = _guiController.ShowSaveFileDialog("Export character as...", CHARACTER_EXPORT_FILE_FILTER); if (fileName != null) { ExportCharacter(_itemRightClicked, fileName); } } else if (controlID == COMMAND_DELETE_ITEM) { if (MessageBox.Show("Are you sure you want to delete this character? Doing so could break any scripts that refer to characters by number.", "Confirm delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int removingID = _itemRightClicked.ID; foreach (Character item in _agsEditor.CurrentGame.Characters) { if (item.ID > removingID) { item.ID--; } } if (_documents.ContainsKey(_itemRightClicked)) { _guiController.RemovePaneIfExists(_documents[_itemRightClicked]); _documents.Remove(_itemRightClicked); } _agsEditor.CurrentGame.Characters.Remove(_itemRightClicked); RePopulateTreeView(); } } else if (controlID != TOP_LEVEL_COMMAND_ID) { Character chosenItem = _agsEditor.CurrentGame.Characters[Convert.ToInt32(controlID.Substring(3))]; ShowOrAddPane(chosenItem); } }
public CharacterEditor(Character characterToEdit) { InitializeComponent(); _character = characterToEdit; _normalFont = lblIsPlayer.Font; _boldFont = new System.Drawing.Font(_normalFont.Name, _normalFont.Size, FontStyle.Bold); viewPreview1.IsCharacterView = true; viewPreview2.IsCharacterView = true; UpdateActivateCharacterText(); UpdateViewPreview(); }
/// <summary> /// Export a 2.72-compatible CHA file. This code is horrid, but it's /// backwards compatible!! /// </summary> public static void ExportCharacter272(Character character, string fileName, Game game) { BinaryWriter writer = new BinaryWriter(new FileStream(fileName, FileMode.Create, FileAccess.Write)); writer.Write(Encoding.ASCII.GetBytes(CHARACTER_FILE_SIGNATURE)); writer.Write((int)6); for (int i = 0; i < 256; i++) { writer.Write((byte)(game.Palette[i].Colour.R / 4)); writer.Write((byte)(game.Palette[i].Colour.G / 4)); writer.Write((byte)(game.Palette[i].Colour.B / 4)); writer.Write((byte)0); } WriteZeros(writer, 4); writer.Write(character.SpeechView); WriteZeros(writer, 4); writer.Write(character.StartingRoom); WriteZeros(writer, 4); writer.Write(character.StartX); writer.Write(character.StartY); WriteZeros(writer, 12); writer.Write(character.IdleView); WriteZeros(writer, 12); writer.Write(character.SpeechColor); writer.Write(character.ThinkingView); writer.Write((short)character.BlinkingView); WriteZeros(writer, 42); writer.Write((short)character.MovementSpeed); writer.Write((short)character.AnimationDelay); WriteZeros(writer, 606); writer.Write(Encoding.Default.GetBytes(character.RealName)); WriteZeros(writer, 40 - character.RealName.Length); string scriptName = character.ScriptName; if (scriptName.StartsWith("c")) { scriptName = scriptName.Substring(1).ToUpper(); } writer.Write(Encoding.Default.GetBytes(scriptName)); WriteZeros(writer, 20 - scriptName.Length); writer.Write((short)0); try { WriteOldStyleView(writer, game.FindViewByID(character.NormalView)); if (character.SpeechView > 0) { WriteOldStyleView(writer, game.FindViewByID(character.SpeechView)); } if (character.IdleView > 0) { WriteOldStyleView(writer, game.FindViewByID(character.IdleView)); } if (character.ThinkingView > 0) { WriteOldStyleView(writer, game.FindViewByID(character.ThinkingView)); } if (character.BlinkingView > 0) { WriteOldStyleView(writer, game.FindViewByID(character.BlinkingView)); } writer.Close(); } catch (Exception ex) { writer.Close(); File.Delete(fileName); throw ex; } }
public Game() { _guis = new GUIFolder(GUIFolder.MAIN_GUI_FOLDER_NAME); _inventoryItems = new InventoryItemFolder(InventoryItemFolder.MAIN_INVENTORY_ITEM_FOLDER_NAME); _cursors = new List<MouseCursor>(); _dialogs = new DialogFolder(DialogFolder.MAIN_DIALOG_FOLDER_NAME); _fonts = new List<Font>(); _characters = new CharacterFolder(CharacterFolder.MAIN_CHARACTER_FOLDER_NAME); _plugins = new List<Plugin>(); _translations = new List<Translation>(); _rooms = new UnloadedRoomFolder(UnloadedRoomFolder.MAIN_UNLOADED_ROOM_FOLDER_NAME); _oldInteractionVariables = new List<OldInteractionVariable>(); _settings = new Settings(); _palette = new PaletteEntry[PALETTE_SIZE]; _sprites = new SpriteFolder("Main"); _views = new ViewFolder("Main"); _audioClips = new AudioClipFolder("Main"); _audioClipTypes = new List<AudioClipType>(); _textParser = new TextParser(); _lipSync = new LipSync(); _propertySchema = new CustomPropertySchema(); _globalVariables = new GlobalVariables(); _globalMessages = new string[NUMBER_OF_GLOBAL_MESSAGES]; _deletedViewIDs = new Dictionary<int, object>(); _scripts = new ScriptFolder(ScriptFolder.MAIN_SCRIPT_FOLDER_NAME); _scriptsToCompile = new Scripts(); ScriptAndHeader globalScript = new ScriptAndHeader( new Script(Script.GLOBAL_HEADER_FILE_NAME, "// script header\r\n", true), new Script(Script.GLOBAL_SCRIPT_FILE_NAME, "// global script\r\n", false)); _scripts.Items.Add(globalScript); _playerCharacter = null; for (int i = 0; i < _globalMessages.Length; i++) { _globalMessages[i] = string.Empty; } InitializeDefaultPalette(); }
public void FromXml(XmlNode node) { node = node.SelectSingleNode("Game"); _settings.FromXml(node); _lipSync.FromXml(node); _propertySchema.FromXml(node); if (node.SelectSingleNode("InventoryHotspotMarker") != null) { // Pre-3.0.3 InventoryHotspotMarker marker = new InventoryHotspotMarker(); marker.FromXml(node); _settings.InventoryHotspotMarker = marker; } foreach (XmlNode msgNode in SerializeUtils.GetChildNodes(node, "GlobalMessages")) { _globalMessages[Convert.ToInt32(msgNode.Attributes["ID"].InnerText) - GLOBAL_MESSAGE_ID_START] = msgNode.InnerText; } _plugins.Clear(); foreach (XmlNode pluginNode in SerializeUtils.GetChildNodes(node, "Plugins")) { _plugins.Add(new Plugin(pluginNode)); } _rooms = new UnloadedRoomFolder(node.SelectSingleNode("Rooms").FirstChild, node); _guis = new GUIFolder(node.SelectSingleNode("GUIs").FirstChild, node); _inventoryItems = new InventoryItemFolder(node.SelectSingleNode("InventoryItems").FirstChild, node); _textParser = new TextParser(node.SelectSingleNode("TextParser")); _characters = new CharacterFolder(node.SelectSingleNode("Characters").FirstChild, node); _playerCharacter = null; string playerCharText = SerializeUtils.GetElementString(node, "PlayerCharacter"); if (playerCharText.Length > 0) { int playerCharID = Convert.ToInt32(playerCharText); foreach (Character character in RootCharacterFolder.AllItemsFlat) { if (character.ID == playerCharID) { _playerCharacter = character; break; } } } _dialogs = new DialogFolder(node.SelectSingleNode("Dialogs").FirstChild, node); _cursors.Clear(); foreach (XmlNode cursNode in SerializeUtils.GetChildNodes(node, "Cursors")) { _cursors.Add(new MouseCursor(cursNode)); } _fonts.Clear(); foreach (XmlNode fontNode in SerializeUtils.GetChildNodes(node, "Fonts")) { _fonts.Add(new Font(fontNode)); } _palette = ReadPaletteFromXML(node); _sprites = new SpriteFolder(node.SelectSingleNode("Sprites").FirstChild); _views = new ViewFolder(node.SelectSingleNode("Views").FirstChild); _deletedViewIDs.Clear(); if (node.SelectSingleNode("DeletedViews") != null) { foreach (XmlNode transNode in SerializeUtils.GetChildNodes(node, "DeletedViews")) { _deletedViewIDs.Add(Convert.ToInt32(transNode.InnerText), null); } } _scripts = new ScriptFolder(node.SelectSingleNode("Scripts").FirstChild, node); if (node.SelectSingleNode("AudioClips") != null) { _audioClips = new AudioClipFolder(node.SelectSingleNode("AudioClips").FirstChild); } else { _audioClips = new AudioClipFolder("Main"); _audioClips.DefaultPriority = AudioClipPriority.Normal; _audioClips.DefaultRepeat = InheritableBool.False; _audioClips.DefaultVolume = 100; } _audioClipTypes.Clear(); if (node.SelectSingleNode("AudioClipTypes") != null) { foreach (XmlNode clipTypeNode in SerializeUtils.GetChildNodes(node, "AudioClipTypes")) { _audioClipTypes.Add(new AudioClipType(clipTypeNode)); } } _translations.Clear(); if (node.SelectSingleNode("Translations") != null) { foreach (XmlNode transNode in SerializeUtils.GetChildNodes(node, "Translations")) { _translations.Add(new Translation(transNode)); } } if (node.SelectSingleNode("GlobalVariables") != null) { _globalVariables = new GlobalVariables(node.SelectSingleNode("GlobalVariables")); } else { _globalVariables = new GlobalVariables(); } _oldInteractionVariables.Clear(); if (node.SelectSingleNode("OldInteractionVariables") != null) { foreach (XmlNode varNode in SerializeUtils.GetChildNodes(node, "OldInteractionVariables")) { _oldInteractionVariables.Add(new OldInteractionVariable(SerializeUtils.GetAttributeString(varNode, "Name"), SerializeUtils.GetAttributeInt(varNode, "Value"))); } } if (_savedXmlVersionIndex == null) { // Pre-3.0.3, upgrade co-ordinates ConvertCoordinatesToNativeResolution(); } }
public static void ExportCharacterNewFormat(Character character, string fileName, Game game) { if (File.Exists(fileName)) { File.Delete(fileName); } XmlTextWriter writer = new XmlTextWriter(fileName, Encoding.Default); writer.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"" + Encoding.Default.WebName + "\""); writer.WriteComment("Fichier de Personnage AGS Exporté. N'ÉDITEZ PAS CE FICHIER MANUELLEMENT, IL EST AUTOMATIQUEMENT GÉNÉRÉ PAR L'ÉDITEUR AGS."); writer.WriteStartElement(CHARACTER_XML_ROOT_NODE); writer.WriteAttributeString(CHARACTER_XML_VERSION_ATTRIBUTE, CHARACTER_XML_CURRENT_VERSION); character.ToXml(writer); writer.WriteStartElement(CHARACTER_XML_VIEWS_NODE); Dictionary<int, object> spritesWritten = new Dictionary<int, object>(); writer.WriteStartElement("NormalView"); WriteNewStyleView(writer, game.FindViewByID(character.NormalView), spritesWritten); writer.WriteEndElement(); if (character.SpeechView > 0) { writer.WriteStartElement("SpeechView"); WriteNewStyleView(writer, game.FindViewByID(character.SpeechView), spritesWritten); writer.WriteEndElement(); } if (character.IdleView > 0) { writer.WriteStartElement("IdleView"); WriteNewStyleView(writer, game.FindViewByID(character.IdleView), spritesWritten); writer.WriteEndElement(); } if (character.ThinkingView > 0) { writer.WriteStartElement("ThinkingView"); WriteNewStyleView(writer, game.FindViewByID(character.ThinkingView), spritesWritten); writer.WriteEndElement(); } if (character.BlinkingView > 0) { writer.WriteStartElement("BlinkingView"); WriteNewStyleView(writer, game.FindViewByID(character.BlinkingView), spritesWritten); writer.WriteEndElement(); } writer.WriteEndElement(); game.WritePaletteToXML(writer); writer.WriteEndElement(); writer.Close(); }
private void DrawCharacter(Character character, RoomEditorState state) { AgsView view = _game.FindViewByID(character.NormalView); if (view != null && view.Loops.Count > 0) { int scale = state.ScaleFactor; int spriteNum = 0; //this is a check to make certain that loop 0 frame 0 of the character normalview has an image; //if not, it defaults to using spriteNum 0 if (view.Loops[0].Frames.Count > 0) { ViewFrame thisFrame = view.Loops[0].Frames[0]; spriteNum = thisFrame.Image; } int xPos = AdjustXCoordinateForWindowScroll(character.StartX, state);// character.StartX* scale; int yPos = AdjustYCoordinateForWindowScroll(character.StartY, state);// character.StartY* scale; int spriteWidth = GetSpriteWidthForGameResolution(spriteNum) * scale;// Factory.NativeProxy.GetRelativeSpriteWidth(spriteNum) * scale; int spriteHeight = GetSpriteHeightForGameResolution(spriteNum) * scale; // Factory.NativeProxy.GetRelativeSpriteHeight(spriteNum) * scale; Factory.NativeProxy.DrawSpriteToBuffer(spriteNum, xPos - spriteWidth / 2, yPos - spriteHeight, scale); } }
public static Character ImportCharacterNew(string fileName, Game game) { XmlDocument doc = new XmlDocument(); try { doc.Load(fileName); } catch (XmlException ex) { throw new AGS.Types.InvalidDataException("This does not appear to be a valid AGS Character file." + Environment.NewLine + Environment.NewLine + ex.Message, ex); } if (doc.DocumentElement.Name != CHARACTER_XML_ROOT_NODE) { throw new AGS.Types.InvalidDataException("Not a valid AGS Character file."); } if (SerializeUtils.GetAttributeString(doc.DocumentElement, CHARACTER_XML_VERSION_ATTRIBUTE) != CHARACTER_XML_CURRENT_VERSION) { throw new AGS.Types.InvalidDataException("This file requires a newer version of AGS to import it."); } Character newChar = new Character(doc.DocumentElement.FirstChild); PaletteEntry[] palette = game.ReadPaletteFromXML(doc.DocumentElement); // Clear any existing event handler function names for (int i = 0; i < newChar.Interactions.ScriptFunctionNames.Length; i++) { newChar.Interactions.ScriptFunctionNames[i] = string.Empty; } SpriteFolder newFolder = new SpriteFolder(newChar.ScriptName + "Import"); game.RootSpriteFolder.SubFolders.Add(newFolder); Dictionary<int, int> spriteMapping = new Dictionary<int, int>(); XmlNode viewsNode = doc.DocumentElement.SelectSingleNode("Views"); newChar.NormalView = ReadAndAddNewStyleView(viewsNode.SelectSingleNode("NormalView"), game, spriteMapping, palette, newFolder); if (newChar.SpeechView > 0) { newChar.SpeechView = ReadAndAddNewStyleView(viewsNode.SelectSingleNode("SpeechView"), game, spriteMapping, palette, newFolder); } if (newChar.IdleView > 0) { newChar.IdleView = ReadAndAddNewStyleView(viewsNode.SelectSingleNode("IdleView"), game, spriteMapping, palette, newFolder); } if (newChar.ThinkingView > 0) { newChar.ThinkingView = ReadAndAddNewStyleView(viewsNode.SelectSingleNode("ThinkingView"), game, spriteMapping, palette, newFolder); } if (newChar.BlinkingView > 0) { newChar.BlinkingView = ReadAndAddNewStyleView(viewsNode.SelectSingleNode("BlinkingView"), game, spriteMapping, palette, newFolder); } EnsureCharacterScriptNameIsUnique(newChar, game); game.RootSpriteFolder.NotifyClientsOfUpdate(); game.NotifyClientsViewsUpdated(); return newChar; }
private Dictionary<string, object> ConstructPropertyObjectList(Character item) { Dictionary<string, object> list = new Dictionary<string, object>(); list.Add(item.ScriptName + " (Character " + item.ID + ")", item); return list; }
public override IList<MenuCommand> GetContextMenu(string controlID) { IList<MenuCommand> menu = new List<MenuCommand>(); if (controlID == TOP_LEVEL_COMMAND_ID) { menu.Add(new MenuCommand(COMMAND_NEW_ITEM, "New character", null)); menu.Add(new MenuCommand(COMMAND_IMPORT, "Import character...", null)); } else { int charID = Convert.ToInt32(controlID.Substring(3)); _itemRightClicked = _agsEditor.CurrentGame.Characters[charID]; menu.Add(new MenuCommand(COMMAND_DELETE_ITEM, "Delete this character", null)); menu.Add(new MenuCommand(COMMAND_EXPORT, "Export character...", null)); } return menu; }
public Game() { _guis = new List<GUI>(); _inventoryItems = new List<InventoryItem>(); _cursors = new List<MouseCursor>(); _dialogs = new List<Dialog>(); _fonts = new List<Font>(); _characters = new List<Character>(); _plugins = new List<Plugin>(); _translations = new List<Translation>(); _rooms = new RoomList(); _oldInteractionVariables = new List<OldInteractionVariable>(); _settings = new Settings(); _palette = new PaletteEntry[PALETTE_SIZE]; _sprites = new SpriteFolder("Main"); _views = new ViewFolder("Main"); _audioClips = new AudioClipFolder("Main"); _audioClipTypes = new List<AudioClipType>(); _textParser = new TextParser(); _lipSync = new LipSync(); _propertySchema = new CustomPropertySchema(); _globalVariables = new GlobalVariables(); _globalMessages = new string[NUMBER_OF_GLOBAL_MESSAGES]; _deletedViewIDs = new Dictionary<int, object>(); _scripts = new Scripts(); _scriptsToCompile = new Scripts(); _scripts.Add(new Script(Script.GLOBAL_HEADER_FILE_NAME, "// script header\r\n", true)); _scripts.Add(new Script(Script.GLOBAL_SCRIPT_FILE_NAME, "// global script\r\n", false)); _playerCharacter = null; for (int i = 0; i < _globalMessages.Length; i++) { _globalMessages[i] = string.Empty; } InitializeDefaultPalette(); }
private void GUIController_OnPropertyObjectChanged(object newPropertyObject) { if (newPropertyObject is Character) { _selectedCharacter = (Character)newPropertyObject; _panel.Invalidate(); } else if (newPropertyObject is Room) { _selectedCharacter = null; _panel.Invalidate(); } }
private Rectangle GetCharacterRect(Character character, int scale, RoomEditorState state) { AgsView view = _game.FindViewByID(character.NormalView); int xPos = AdjustXCoordinateForWindowScroll(character.StartX, state);// character.StartX* scale; int yPos = AdjustYCoordinateForWindowScroll(character.StartY, state);// character.StartY* scale; int spriteNum = 0; if (view.Loops[0].Frames.Count > 0) spriteNum = _game.FindViewByID(character.NormalView).Loops[0].Frames[0].Image; int spriteWidth = GetSpriteWidthForGameResolution(spriteNum) * scale;// Factory.NativeProxy.GetRelativeSpriteWidth(spriteNum) * scale; int spriteHeight = GetSpriteHeightForGameResolution(spriteNum) * scale; // Factory.NativeProxy.GetRelativeSpriteHeight(spriteNum) * scale; return new Rectangle(xPos - spriteWidth / 2, yPos - spriteHeight, spriteWidth, spriteHeight); }
public static void ExportCharacterNewFormat(Character character, string fileName, Game game) { if (File.Exists(fileName)) { File.Delete(fileName); } XmlTextWriter writer = new XmlTextWriter(fileName, Encoding.Default); writer.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"" + Encoding.Default.WebName + "\""); writer.WriteComment("AGS Exported Character file. DO NOT EDIT THIS FILE BY HAND, IT IS GENERATED AUTOMATICALLY BY THE AGS EDITOR."); writer.WriteStartElement(CHARACTER_XML_ROOT_NODE); writer.WriteAttributeString(CHARACTER_XML_VERSION_ATTRIBUTE, CHARACTER_XML_CURRENT_VERSION); character.ToXml(writer); writer.WriteStartElement(CHARACTER_XML_VIEWS_NODE); Dictionary<int, object> spritesWritten = new Dictionary<int, object>(); writer.WriteStartElement("NormalView"); WriteNewStyleView(writer, game.FindViewByID(character.NormalView), spritesWritten); writer.WriteEndElement(); if (character.SpeechView > 0) { writer.WriteStartElement("SpeechView"); WriteNewStyleView(writer, game.FindViewByID(character.SpeechView), spritesWritten); writer.WriteEndElement(); } if (character.IdleView > 0) { writer.WriteStartElement("IdleView"); WriteNewStyleView(writer, game.FindViewByID(character.IdleView), spritesWritten); writer.WriteEndElement(); } if (character.ThinkingView > 0) { writer.WriteStartElement("ThinkingView"); WriteNewStyleView(writer, game.FindViewByID(character.ThinkingView), spritesWritten); writer.WriteEndElement(); } if (character.BlinkingView > 0) { writer.WriteStartElement("BlinkingView"); WriteNewStyleView(writer, game.FindViewByID(character.BlinkingView), spritesWritten); writer.WriteEndElement(); } writer.WriteEndElement(); game.WritePaletteToXML(writer); writer.WriteEndElement(); writer.Close(); }
/// <summary> /// Import a 2.72-compatible CHA file. This code is horrid, but it's /// backwards compatible!! /// </summary> public static Character ImportCharacter272(string fileName, Game game) { BinaryReader reader = new BinaryReader(new FileStream(fileName, FileMode.Open, FileAccess.Read)); string fileSig = Encoding.ASCII.GetString(reader.ReadBytes(12)); if (fileSig != CHARACTER_FILE_SIGNATURE) { reader.Close(); throw new AGS.Types.InvalidDataException("This is not a valid AGS character file."); } int fileVersion = reader.ReadInt32(); if ((fileVersion < 5) || (fileVersion > 6)) { reader.Close(); throw new AGS.Types.InvalidDataException("This character file is not supported by this version of AGS."); } Color []palette = new Color[256]; for (int i = 0; i < 256; i++) { int r = reader.ReadByte(); int g = reader.ReadByte(); int b = reader.ReadByte(); reader.ReadByte(); palette[i] = Color.FromArgb(r * 4, g * 4, b * 4); } Character character = new Character(); reader.ReadInt32(); character.SpeechView = reader.ReadInt32(); reader.ReadInt32(); character.StartingRoom = reader.ReadInt32(); reader.ReadInt32(); character.StartX = reader.ReadInt32(); character.StartY = reader.ReadInt32(); reader.ReadInt32(); reader.ReadInt32(); reader.ReadInt32(); character.IdleView = reader.ReadInt32(); reader.ReadInt32(); reader.ReadInt32(); reader.ReadInt32(); character.SpeechColor = reader.ReadInt32(); character.ThinkingView = reader.ReadInt32(); character.BlinkingView = reader.ReadInt16(); reader.ReadInt16(); reader.ReadBytes(40); character.MovementSpeed = reader.ReadInt16(); character.AnimationDelay = reader.ReadInt16(); reader.ReadBytes(606); character.RealName = ReadNullTerminatedString(reader, 40); character.ScriptName = ReadNullTerminatedString(reader, 20); if (character.ScriptName.Length > 0) { character.ScriptName = "c" + Char.ToUpper(character.ScriptName[0]) + character.ScriptName.Substring(1).ToLower(); EnsureCharacterScriptNameIsUnique(character, game); } reader.ReadInt16(); string viewNamePrefix = character.ScriptName; if (viewNamePrefix.StartsWith("c")) viewNamePrefix = viewNamePrefix.Substring(1); SpriteFolder folder = new SpriteFolder(character.ScriptName + "Sprites"); character.NormalView = ReadAndAddView(viewNamePrefix + "Walk", reader, game, folder, palette); if (character.SpeechView > 0) { character.SpeechView = ReadAndAddView(viewNamePrefix + "Talk", reader, game, folder, palette); } else { character.SpeechView = 0; } if (character.IdleView > 0) { character.IdleView = ReadAndAddView(viewNamePrefix + "Idle", reader, game, folder, palette); } else { character.IdleView = 0; } if ((character.ThinkingView > 0) && (fileVersion >= 6)) { character.ThinkingView = ReadAndAddView(viewNamePrefix + "Think", reader, game, folder, palette); } else { character.ThinkingView = 0; } if ((character.BlinkingView > 0) && (fileVersion >= 6)) { character.BlinkingView = ReadAndAddView(viewNamePrefix + "Blink", reader, game, folder, palette); } else { character.BlinkingView = 0; } reader.Close(); game.RootSpriteFolder.SubFolders.Add(folder); game.RootSpriteFolder.NotifyClientsOfUpdate(); game.NotifyClientsViewsUpdated(); return character; }
private void ExportCharacter(Character character, string fileName) { try { if (fileName.ToLower().EndsWith(NEW_CHARACTER_FILE_EXTENSION)) { ImportExport.ExportCharacterNewFormat(character, fileName, _agsEditor.CurrentGame); } else { ImportExport.ExportCharacter272(character, fileName, _agsEditor.CurrentGame); } } catch (ApplicationException ex) { _guiController.ShowMessage("An error occurred exporting the character file. The error was: " + ex.Message, MessageBoxIcon.Warning); } }
private static void EnsureCharacterScriptNameIsUnique(Character character, Game game) { string scriptNameBase = character.ScriptName; int suffix = 0; while (game.IsScriptNameAlreadyUsed(character.ScriptName, character)) { suffix++; character.ScriptName = scriptNameBase + suffix; } }
private void ShowOrAddPane(Character chosenItem) { if (!_documents.ContainsKey(chosenItem)) { _documents.Add(chosenItem, new ContentDocument(new CharacterEditor(chosenItem), chosenItem.WindowTitle, this, ConstructPropertyObjectList(chosenItem))); _documents[chosenItem].SelectedPropertyGridObject = chosenItem; } _guiController.AddOrShowPane(_documents[chosenItem]); _guiController.ShowCuppit("Characters can move around from room to room within the game, and can take part in conversations. The Player Character is the one that the player is controlling.", "Characters introduction"); }