Пример #1
0
        public GlobalVariablesEditor(Game game)
        {
            InitializeComponent();
            lvwWords.ListViewItemSorter = new GlobalVariableComparer();
            _game = game;
            _variables = game.GlobalVariables;

            lvwWords.Sorting = SortOrder.Ascending;
            foreach (GlobalVariable variable in _variables.ToList())
            {
                lvwWords.Items.Add(CreateListItemFromVariable(variable));
            }
            lvwWords.Sort();
        }
Пример #2
0
        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();
        }
Пример #3
0
        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();
        }
Пример #4
0
        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();
            }
        }
Пример #5
0
        public void FromXml(XmlNode node)
        {
            node = node.SelectSingleNode("Game");

            _settings.FromXml(node);

            if (node.SelectSingleNode(_defaultSetup.GetType().Name) != null)
            {
                // Only for >= 3.4.1
                _defaultSetup.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 UnloadedRoomFolders(node.SelectSingleNode("Rooms").FirstChild, node);

            _guis = new GUIFolders(node.SelectSingleNode("GUIs").FirstChild, node);

            _inventoryItems = new InventoryItemFolders(node.SelectSingleNode("InventoryItems").FirstChild, node);

            _textParser = new TextParser(node.SelectSingleNode("TextParser"));

            _characters = new CharacterFolders(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 DialogFolders(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 ViewFolders(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 ScriptFolders(node.SelectSingleNode("Scripts").FirstChild, node);

            if (node.SelectSingleNode("AudioClips") != null)
            {
                _audioClips = new AudioClipFolders(node.SelectSingleNode("AudioClips").FirstChild);
            }
            else
            {
                _audioClips = new AudioClipFolders("Main");
                _audioClips.RootFolder.DefaultPriority = AudioClipPriority.Normal;
                _audioClips.RootFolder.DefaultRepeat   = InheritableBool.False;
                _audioClips.RootFolder.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();
            }
        }