public IEnumerator ReadFile() { var path = Path.Combine(Application.streamingAssetsPath, FilePath); using (StreamReader reader = new StreamReader(path)) { Debug.Log("Using stream reader"); DialogTemplate template = null; string line = ""; while ((line = reader.ReadLine()) != null) { int index = line.IndexOf("]"); if (index != -1) { string iden = line.Substring(1, index - 1); Debug.Log("Identifier: " + iden); Dict.TryGetValue(iden, out template); } string message = line.Substring(index + 1); Debug.Log("Message: " + message); if (template != null) { FillInfo(template, message); yield return(new WaitForSeconds(1f)); yield return(WaitForInput(template.Button)); } } } Switcher.SwitchScenes(); }
public virtual void Initialize(IDialog argument, DialogTemplate template) { _framePresenter = Instantiate(template.frame, _dialogContainer.transform, false); _contentPresenter = Instantiate(template.content, _framePresenter.ContentContainer, false); _framePresenter.Initialize(argument.Frame); _contentPresenter.Initialize(argument.Content); }
public bool AddTemplate(DialogTemplate template) { if (FindTemplate(template.templateName) != null) { return(false); } _templates.Add(template); return(true); }
public override bool Patch(DialogTemplate dialog) { if (dialog.TypeFace != TypeFace || dialog.PointSize != PointSize) { dialog.TypeFace = TypeFace; dialog.PointSize = PointSize; return(true); } return(false); }
public override void Initialize(IDialog argument, DialogTemplate template) { base.Initialize(argument, template); var fp = (ConfirmDialogFramePresenter)_framePresenter; var cd = (ConfirmDialog)argument; for (int i = 0; i < fp.Buttons.Count; i++) { if (i < cd.Buttons.Count) { fp.Buttons[i].gameObject.SetActive(true); var b = fp.Buttons[i]; cd.Buttons[i].Owner = argument; b.Initialize(cd.Buttons[i]); } else { fp.Buttons[i].gameObject.SetActive(false); } } _outSideButton.OnClickAsObservable().Subscribe(_ => { if (argument.CloseOnTouchOutside) { argument.Close(); } }).AddTo(this); argument.ObserveEveryValueChanged(x => x.State).Subscribe(state => { switch (state) { case DialogState.Closed: break; case DialogState.Opening: _canvasGroupFadeAnimator.FadeInAsObservable().Subscribe(_ => { }, () => argument.State = DialogState.Opened).AddTo(this); break; case DialogState.Opened: break; case DialogState.Closing: _canvasGroupFadeAnimator.FadeOutAsObservable().Subscribe(_ => { }, () => argument.State = DialogState.Closed).AddTo(this); break; } }).AddTo(this); }
private void Button_Click_1(object sender, RoutedEventArgs e) { if (vm.CurrentItem != null) { if (vm.CurrentItem.Relookup > 0) { new LookupManagerView(vm.CurrentItem.Relookup); IModalDialogHost dlg = new DialogTemplate(); dlg.Title = "Избери елемент от номенклатура"; dlg.HostedContent = new LookupManagerView(vm.CurrentItem.Relookup);; dlg.Show(DialogClosedHandler); } } }
public void Build() { try { var selection = SelectionTemplate?.CreateContent() as View; var expand = DialogTemplate?.CreateContent() as View; DialogView = CreateDialog(expand); SelectionView = CreateSelection(selection); Content = SelectionView; } catch (Exception ex) { } }
private void FillInfo(DialogTemplate template, string message) { template.SpeakerPortrait.SetActive(true); template.SpeakerText.SetActive(true); template.Background.SetActive(true); template.SpeechBubble.SetActive(true); if (template.Audio != null && !template.AudioHasPlayed()) { template.Audio.Play(); template.SetAudioPlayed(true); if (BGMusic != null && BGMusic.isPlaying) { BGMusic.Pause(); } } else if (BGMusic != null) { if (!BGMusic.isPlaying) { BGMusic.UnPause(); } } // Hide other templates foreach (DialogTemplate t in Dict.Values) { if (!t.Identifier.Equals(template.Identifier)) { t.SpeakerPortrait.SetActive(false); t.SpeakerText.SetActive(false); t.Background.SetActive(false); t.SpeechBubble.SetActive(false); if (t.Audio != null) { t.Audio.Stop(); } } } Text text = template.SpeakerText.GetComponent <Text>(); if (text != null) { text.text = message; } }
public static void InitializeDialogTemplates(JSONObject data) { List <DialogTemplate> dialogs = new List <DialogTemplate>(); foreach (JSONObject templateJson in data["dialogs"].list) { DialogTemplate template = new DialogTemplate(); template.id = templateJson["id"].str; List <string> lines = new List <string>(); foreach (JSONObject lineJson in templateJson["texts"].list) { lines.Add(lineJson.str); } template.lines = lines.ToArray(); dialogs.Add(template); } GameState.dialogTemplates = dialogs.ToArray(); }
public override bool Patch(DialogTemplate dialog) { return(PatchInternal(dialog)); /*if (StringsScraper.IsNormalString(dialog.Caption)) { * string id = StringsScraper.GetResId(dialog); * if (Translation.TryGetValue(id, out string translation)) * dialog.Caption = translation; * } * foreach (var control in dialog.Controls) { * if (StringsScraper.IsNormalString(control.CaptionId.Name)) { * string id = StringsScraper.GetResId(control); * if (Translation.TryGetValue(id, out string translation)) * control.CaptionId = translation; * } * } * return true;*/ }
public async Task<ContentDialogResult> ShowAsync(DialogTemplate template) { if (template == null) throw new ArgumentNullException(nameof(template)); var dialog = new ContentDialog { Title = template.Title, Content = template.Content, PrimaryButtonText = template.PrimaryButtonText, FullSizeDesired = template.FullSizeDesired }; // This check is important due to UWP API if (template.SecondaryButtonText != null) dialog.SecondaryButtonText = template.SecondaryButtonText; return await dialog.ShowAsync(); }
public void TestLoadDialogResources() { Uri uri = new Uri(Assembly.GetExecutingAssembly().CodeBase); string uriPath = Path.GetDirectoryName(HttpUtility.UrlDecode(uri.AbsolutePath)); string filename = Path.Combine(uriPath, @"Binaries\gutils.dll"); using (ResourceInfo ri = new ResourceInfo()) { Console.WriteLine("Loading: {0}", filename); ri.Load(filename); foreach (DialogResource rc in ri[Kernel32.ResourceTypes.RT_DIALOG]) { Console.WriteLine("DialogResource: {0}, {1}", rc.Name, rc.TypeName); Console.WriteLine(rc); } // two dialogs Assert.AreEqual(2, ri[Kernel32.ResourceTypes.RT_DIALOG].Count); DialogResource dlg = (DialogResource)ri[Kernel32.ResourceTypes.RT_DIALOG][0]; Assert.AreEqual("GABRTDLG", dlg.Name.Name); // the first one is called "Printing" DialogTemplate printingTemplate = (DialogTemplate)dlg.Template; Assert.AreEqual(38, printingTemplate.x); Assert.AreEqual(18, printingTemplate.y); Assert.AreEqual(128, printingTemplate.cx); Assert.AreEqual(83, printingTemplate.cy); Assert.AreEqual(3, printingTemplate.ControlCount); Assert.AreEqual(3, printingTemplate.Controls.Count); Assert.AreEqual("Printing", printingTemplate.Caption); Assert.AreEqual("MS Shell Dlg", printingTemplate.TypeFace); Assert.AreEqual(8, printingTemplate.PointSize); // the first control is called "Printing Table" DialogTemplateControl printingTable = (DialogTemplateControl)printingTemplate.Controls[0]; Assert.AreEqual("Printing Table", printingTable.CaptionId.Name); Assert.AreEqual(23, printingTable.x); Assert.AreEqual(18, printingTable.y); Assert.AreEqual(87, printingTable.cx); Assert.AreEqual(8, printingTable.cy); Assert.AreEqual(101, printingTable.Id); } }
public override void Initialize(IDialog argument, DialogTemplate template) { base.Initialize(argument, template); var fp = (MenuDialogFramePresenter)_framePresenter; var cd = (MenuDialog)argument; _outSideButton.OnClickAsObservable().Subscribe(_ => { if (argument.CloseOnTouchOutside) { argument.Close(); } }).AddTo(this); argument.ObserveEveryValueChanged(x => x.State).Subscribe(state => { switch (state) { case DialogState.Closed: break; case DialogState.Opening: _canvasGroupFadeAnimator.FadeInAsObservable().Subscribe(_ => { }, () => argument.State = DialogState.Opened).AddTo(this); break; case DialogState.Opened: break; case DialogState.Closing: _canvasGroupFadeAnimator.FadeOutAsObservable().Subscribe(_ => { }, () => argument.State = DialogState.Closed).AddTo(this); break; } }).AddTo(this); }
public override string ExtractString(SUIStringResource resourceToken) { IntPtr hInstance = IntPtr.Zero; IntPtr hModule = IntPtr.Zero; try { hInstance = SUIWinAPIs.LoadLibraryEx(resourceToken.ResourceDll, IntPtr.Zero, 2); if (resourceToken.StringID is int) { hModule = SUIWinAPIs.FindResource(hInstance, (int)resourceToken.StringID, (int)resourceToken.StringType); } else { hModule = SUIWinAPIs.FindResource(hInstance, (string)resourceToken.StringID, (int)resourceToken.StringType); } IntPtr hResData = SUIWinAPIs.LoadResource(hInstance, hModule); IntPtr ptr = SUIWinAPIs.LockResource(hResData); DialogTemplateEx dlgtemplateex = new DialogTemplateEx(); DialogTemplate dlgtemplate = new DialogTemplate(); Marshal.PtrToStructure(ptr, dlgtemplateex); Marshal.PtrToStructure(ptr, dlgtemplate); if ((dlgtemplateex.wSignature & 0xffff) == 0xffff) //if dlg is extend dlg { ptr = (IntPtr)(ptr.ToInt64() + Marshal.SizeOf(dlgtemplateex)); //directly operation memory address } else { ptr = (IntPtr)(ptr.ToInt64() + 0x12); } if (Marshal.ReadInt16(ptr) == -1) { ptr = (IntPtr)(ptr.ToInt64() + 4); } else { while (Marshal.ReadInt16(ptr) != 0) { ptr = (IntPtr)(ptr.ToInt64() + 2); } ptr = (IntPtr)(ptr.ToInt64() + 2); } if (Marshal.ReadInt16(ptr) == -1) { ptr = (IntPtr)(ptr.ToInt64() + 4); } else { while (Marshal.ReadInt16(ptr) != 0) { ptr = (IntPtr)(ptr.ToInt64() + 2); } ptr = (IntPtr)(ptr.ToInt64() + 2); } return(Marshal.PtrToStringAuto(ptr)); } catch (Exception e) { throw new SUIException("ExactString Error", e); } finally { if (!hInstance.Equals(IntPtr.Zero)) { SUIWinAPIs.FreeLibrary(hInstance); } } }
public override string ExtractString(SUIStringResource resourceToken) { IntPtr hInstance = IntPtr.Zero; IntPtr hModule = IntPtr.Zero; try { hInstance = SUIWinAPIs.LoadLibraryEx(resourceToken.ResourceDll, IntPtr.Zero, 2); if(resourceToken.StringID is int) { hModule = SUIWinAPIs.FindResource(hInstance, (int)resourceToken.StringID, (int)resourceToken.StringType); } else { hModule = SUIWinAPIs.FindResource(hInstance, (string)resourceToken.StringID,(int)resourceToken.StringType); } IntPtr hResData = SUIWinAPIs.LoadResource(hInstance, hModule); IntPtr ptr = SUIWinAPIs.LockResource(hResData); DialogTemplateEx dlgtemplateex = new DialogTemplateEx(); DialogTemplate dlgtemplate = new DialogTemplate(); Marshal.PtrToStructure(ptr, dlgtemplateex); Marshal.PtrToStructure(ptr, dlgtemplate); if ((dlgtemplateex.wSignature & 0xffff) == 0xffff) //if dlg is extend dlg { ptr = (IntPtr)(ptr.ToInt64() + Marshal.SizeOf(dlgtemplateex)); //directly operation memory address } else { ptr = (IntPtr)(ptr.ToInt64() + 0x12); } if (Marshal.ReadInt16(ptr) == -1) { ptr = (IntPtr)(ptr.ToInt64() + 4); } else { while (Marshal.ReadInt16(ptr) != 0) { ptr = (IntPtr)(ptr.ToInt64() + 2); } ptr = (IntPtr)(ptr.ToInt64() + 2); } if (Marshal.ReadInt16(ptr) == -1) { ptr = (IntPtr)(ptr.ToInt64() + 4); } else { while (Marshal.ReadInt16(ptr) != 0) { ptr = (IntPtr)(ptr.ToInt64() + 2); } ptr = (IntPtr)(ptr.ToInt64() + 2); } return Marshal.PtrToStringAuto(ptr); } catch (Exception e) { throw new SUIException("ExactString Error",e); } finally { if (!hInstance.Equals(IntPtr.Zero)) SUIWinAPIs.FreeLibrary(hInstance); } }
private static void ScrapeDialogTemplate(StringBuilder language, StringBuilder normal, DialogTemplate dialog) { AddResString("CAPTION", language, normal, dialog.Caption, GetResId(dialog)); foreach (var control in dialog.Controls) { string commentLine = "CONTROL"; if (control is DialogTemplateControl idControl && idControl.Id != 0) { commentLine += $" {idControl.Id}"; } AddResString(commentLine, language, normal, control.CaptionId.Name, GetResId(control)); } }
public virtual bool Patch(DialogTemplate dialog) => true;
public static void ShowDialog(string dialogId, Dictionary <string, string> parameters = null) { DialogTemplate template = GameState.GetDialogTemplate(dialogId); Dialog.instance.ShowDialog(template.lines, parameters); }