/// <summary> /// Adds the serialization plugin to the interface. /// </summary> /// <param name="plugin">The plugin.</param> private void AddSerializationPlugin(ISerializerPlugin plugin) { Trace.WriteLine("Adding menu item for '" + plugin.Name + "' plugin...", "UI"); //TODO: Perhaps it would be better to load the plugins and don't add them to the uxImportMenuItem //Instead we have a simple import button, and it has the filetypes with the supported plugins. //Example: .em and .pe (or something similar) are the only visible types in the import dialog. //Doing it this way will prevent loading of dynamic menu items and fix the bug where the menu items is //still displayed even tho the load dialog has been displayed. if (plugin.CanDeserialize) { ToolStripMenuItem item = new ToolStripMenuItem { //Image = Image.FromFile(plugin.DisplayIcon.AbsolutePath), Text = plugin.Name, ToolTipText = plugin.Description, Tag = plugin }; this.uxImportMenuItem.DropDownItems.Add(item); } if (plugin.CanSerialize) { ToolStripMenuItem item = new ToolStripMenuItem { //Image = Image.FromFile(plugin.DisplayIcon.AbsolutePath), Text = plugin.Name, ToolTipText = plugin.Description, Tag = plugin }; this.uxExportMenuItem.DropDownItems.Add(item); } }
private static SerializerBase ShowOpenFileDialog(MainForm main) { try { var filter = main.GetTvDataFileFilter(out var supportedExtensions, out var numberOfFilters); using var dlg = new OpenFileDialog(); dlg.InitialDirectory = Config.Default.ReferenceListFolder ?? Path.Combine(Path.GetDirectoryName(Application.ExecutablePath) ?? ".", "ReferenceLists"); dlg.AddExtension = true; dlg.Filter = filter + string.Format(Resources.MainForm_FileDialog_OpenFileFilter, supportedExtensions); dlg.FilterIndex = numberOfFilters + 1; dlg.CheckFileExists = true; dlg.RestoreDirectory = true; dlg.DereferenceLinks = true; dlg.Title = Resources.ReferenceListForm_ShowOpenFileDialog_Title; if (dlg.ShowDialog(main) != DialogResult.OK) { return(null); } Config.Default.ReferenceListFolder = Path.GetDirectoryName(dlg.FileName); if (main.DetectCommonFileCorruptions(dlg.FileName)) { return(null); } ISerializerPlugin hint = dlg.FilterIndex <= main.Plugins.Count ? main.Plugins[dlg.FilterIndex - 1] : null; return(main.GetSerializerForFile(dlg.FileName, ref hint)); } catch { return(null); } }
/// <summary> /// Handles the ItemActivate event of the uxLibraryListView control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void uxLibraryListView_ItemActivate(object sender, EventArgs e) { if (MessageBox.Show("Are you sure you wish to open this effect? Unsaved changes will be lost.", "Confirm", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) { ListViewItem item = uxLibraryListView.SelectedItems[0]; ISerializerPlugin plugin = item.Tag as ISerializerPlugin; string filePath = Application.StartupPath + "\\EffectLibrary\\" + item.Text; this.OnDeserialize(new SerializeEventArgs(plugin, filePath)); } }
private void Load_LocalStorage() { VirtualCurrency[GhostTokensIdentifier] = PlayerPrefsHelpers.TryGet(GhostTokensIdentifier, 0); VirtualCurrency[EnergieIdentifier] = PlayerPrefsHelpers.TryGet(EnergieIdentifier, 0); int numberOfItemsToLoad = PlayerPrefsHelpers.TryGet(NumberOfItemsIdentifier, 0); ISerializerPlugin serializer = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer); for (int index = 0; index < Inventory.Count; index++) { string ItemJson = PlayerPrefsHelpers.TryGet(ItemIdentifier + index.ToString("000"), ""); if (string.IsNullOrWhiteSpace(ItemJson) == false) { ItemInstance Item = serializer.DeserializeObject <ItemInstance>(ItemJson); } } }
public static void Init() { _jsonWrapper = PlayFab.PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer); _endpoint = Environment.GetEnvironmentVariable(HEARTBEAT_ENDPOINT_VARIABLE_NAME); sessionId = Environment.GetEnvironmentVariable(SERVER_ID_VARIABLE_NAME); logFolder = Environment.GetEnvironmentVariable(LOG_FOLDER_VARIABLE_NAME); baseURL = string.Format("http://{0}/v1/sessionHosts/{1}/heartbeats", _endpoint, sessionId); CurrentState.currentGameState = SessionHostStatus.Initializing; CurrentErrorState = ErrorStates.Ok; if (IsDebugging) { Debug.Log(baseURL); Debug.Log(sessionId); Debug.Log(logFolder); } //Create an agent that can talk on the main-tread and pull on an interval. //This is a unity thing, need an object in the scene. GameObject agentView = new GameObject("PlayFabAgentView"); agentView.AddComponent <PlayFabAgentView>(); }
public static void Start() { _jsonWrapper = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer); string fileName = Environment.GetEnvironmentVariable(GsdkConfigFileEnvVarKey); if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName)) { _gsdkconfig = _jsonWrapper.DeserializeObject <GSDKConfiguration>(File.ReadAllText(fileName)); } else { Debug.LogError(string.Format("Environment variable {0} not defined", GsdkConfigFileEnvVarKey)); Application.Quit(); } _baseUrl = string.Format("http://{0}/v1/sessionHosts/{1}/heartbeats", _gsdkconfig.HeartbeatEndpoint, _gsdkconfig.SessionHostId); CurrentState.CurrentGameState = GameState.Initializing; CurrentErrorState = ErrorStates.Ok; CurrentState.CurrentPlayers = new List <ConnectedPlayer>(); if (_configMap == null) { _configMap = CreateConfigMap(_gsdkconfig); } if (IsDebugging) { Debug.Log(_baseUrl); Debug.Log(_gsdkconfig.SessionHostId); Debug.Log(_gsdkconfig.LogFolder); } //Create an agent that can talk on the main-tread and pull on an interval. //This is a unity thing, need an object in the scene. GameObject agentView = new GameObject("PlayFabAgentView"); agentView.AddComponent <PlayFabMultiplayerAgentView>(); }
private void LoadFiles(ISerializerPlugin plugin, string tvDataFile) { bool dataUpdated = false; try { if (DetectCommonFileCorruptions(tvDataFile)) return; if (!this.LoadTvDataFile(plugin, tvDataFile)) return; dataUpdated = true; this.gviewRight.BeginDataUpdate(); this.gviewLeft.BeginDataUpdate(); this.editor = new Editor(); this.editor.DataRoot = this.dataRoot; this.currentChannelList = null; this.editor.ChannelList = null; this.gridRight.DataSource = null; this.gridLeft.DataSource = null; this.FillChannelListCombo(); //this.SetControlsEnabled(!this.dataRoot.IsEmpty); this.UpdateFavoritesEditor(this.dataRoot.SupportedFavorites); if (this.dataRoot.Warnings.Length > 0 && this.miShowWarningsAfterLoad.Checked) this.BeginInvoke((Action)this.ShowFileInformation); this.BeginInvoke((Action)this.InitInitialChannelOrder); } catch (Exception ex) { if (!(ex is IOException)) throw; string name = plugin != null ? plugin.PluginName : "Loader"; XtraMessageBox.Show(this, name + "\n\n" + ex.Message, Resources.MainForm_LoadFiles_IOException, MessageBoxButtons.OK, MessageBoxIcon.Error); this.currentPlugin = null; this.currentTvFile = null; this.currentTvSerializer = null; this.Text = this.title; } finally { if (dataUpdated) { this.gviewRight.EndDataUpdate(); this.gviewLeft.EndDataUpdate(); } } }
private void ReLoadFiles(ISerializerPlugin plugin) { int listIndex = this.tabChannelList.SelectedTabPageIndex; this.LoadFiles(plugin, this.currentTvFile); this.tabChannelList.SelectedTabPageIndex = listIndex; }
private bool LoadTvDataFile(ISerializerPlugin plugin, string tvDataFile) { if (!File.Exists(tvDataFile)) { XtraMessageBox.Show(this, Resources.MainForm_LoadTvDataFile_FileNotFound_Caption, string.Format(Resources.MainForm_LoadTvDataFile_FileNotFound_Message, tvDataFile), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return false; } if (plugin == null) plugin = this.GetPluginForFile(tvDataFile); // abort action if there is no currentTvSerializer for the input file var serializer = plugin == null ? null : plugin.CreateSerializer(tvDataFile); if (serializer == null) return false; if (!this.PromptSaveAndContinue()) return false; serializer.DefaultEncoding = this.defaultEncoding; serializer.Load(); this.SetFileName(tvDataFile); this.currentPlugin = plugin; this.currentTvSerializer = serializer; this.dataRoot = this.currentTvSerializer.DataRoot; this.AddFileToMruList(this.currentTvFile); this.UpdateMruMenu(); return true; }
public CloudScriptListener() { json = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer); }
public CalendarAlertCommand() { json = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer); }
public static void TestChannelAndFavListEditing(string tempFile, ISerializerPlugin plugin, bool swapChans = true, int firstProgNr = 1) { var ser = plugin.CreateSerializer(tempFile); ser.Load(); var root = ser.DataRoot; root.ValidateAfterLoad(); foreach (var l in root.ChannelLists) { foreach (var ch in l.Channels) { ch.NewProgramNr = ch.OldProgramNr; ch.ResetFavorites(); } } int maxFav = Math.Min(4, ser.DataRoot.FavListCount); int chanCount = Math.Max(2, maxFav); var editor = new Editor(); editor.DataRoot = root; var list = root.ChannelLists.FirstOrDefault(l => l.Channels.Count(ch => !ch.IsDeleted) >= chanCount); Assert.IsNotNull(list); editor.ChannelList = list; // swap channels 1 and 2 if (swapChans) { var chans1 = list.GetChannelByNewProgNr(firstProgNr + 0); var chans2 = list.GetChannelByNewProgNr(firstProgNr + 1); Assert.AreEqual(1, chans1.Count); Assert.AreEqual(1, chans2.Count); Assert.AreEqual(firstProgNr + 0, chans1[0].NewProgramNr); Assert.AreEqual(firstProgNr + 1, chans2[0].NewProgramNr); editor.SetSlotNumber(chans2, firstProgNr, false, false); Assert.AreEqual(firstProgNr + 0, chans2[0].NewProgramNr); Assert.AreEqual(firstProgNr + 1, chans1[0].NewProgramNr); } // set channels 4-1 as favorites 1-4 (using reverse order to catch bugs with equal progNr and favNr) var orderedFav = root.SortedFavorites; if (root.FavoritesMode != FavoritesMode.None) { for (int i = 1; i <= maxFav; i++) { var progNr = maxFav + 1 - i; var chans = list.GetChannelByNewProgNr(firstProgNr + progNr - 1); Assert.AreEqual(1, chans.Count); editor.SetFavorites(chans, i - 1, true); Assert.AreEqual(orderedFav ? 1 : firstProgNr + progNr - 1, chans[0].GetPosition(i)); } } ser.Save(tempFile); ser = plugin.CreateSerializer(tempFile); ser.Load(); root = ser.DataRoot; root.ValidateAfterLoad(); root.ApplyCurrentProgramNumbers(); list = root.ChannelLists.FirstOrDefault(l => l.Count >= chanCount); Assert.IsNotNull(list); // validate program number and fav numbers for (int i = 1; i <= chanCount; i++) { var chans = list.GetChannelByNewProgNr(firstProgNr + i - 1); Assert.AreEqual(1, chans.Count); if (i <= maxFav) // ignore favs for lists that don't support favs { Assert.AreEqual(orderedFav ? 1 : chans[0].NewProgramNr, chans[0].GetPosition(maxFav + 1 - i)); } } }
/// <summary> /// Initializes a new instance of the <see cref="SerializeEventArgs"/> class. /// </summary> /// <param name="plugin">The plugin.</param> /// <param name="filePath">The file path.</param> public SerializeEventArgs(ISerializerPlugin plugin, String filePath) : base() { this.Plugin = plugin; this.FilePath = filePath; }