private async void btn_AddFolder_Click(object sender, RoutedEventArgs e) { //var result = await this.ShowInputAsync("Folder Info", "Please type folder address here"); //if(result!=null) { var result = @"E:\GitHub\ATT\ATT.Scripts\bin\Debug"; //var result = @"E:\GitHub\ScriptRunner\ScriptRunner\ScriptSample\bin\Debug"; if (ScriptRunnerManager.ScriptFolders.Where(f => f.Name.ToLower().Trim() == result.ToLower().Trim()).FirstOrDefault() != null) { await(App.Current.MainWindow as MetroWindow).ShowMessageAsync("ERROR", $"The folder:{result} is existed", MessageDialogStyle.Affirmative); } else { ScriptFolder folder = new ScriptFolder(result); await Task.Run(() => { folder.FindScripts(); }); ScriptRunnerManager.ScriptFolders.Add(folder); } } }
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(); } }