public void CleaningUp() { #if DIALOG Father_ControlCollection.Remove(CharacterNameLabel); Father_ControlCollection.Remove(DialogLabel); if (Father_ControlCollection.Contains(LeftCharacterPicture)) { Father_ControlCollection.Remove(LeftCharacterPicture); } if (Father_ControlCollection.Contains(RightCharacterPicture)) { Father_ControlCollection.Remove(LeftCharacterPicture); } //--------------------------------- CharacterNameLabel.Dispose(); DialogLabel.Dispose(); CharacterNameLabel = null; DialogLabel = null; if (LeftCharacterPicture != null) { LeftCharacterPicture.Dispose(); LeftCharacterPicture = null; } if (RightCharacterPicture != null) { RightCharacterPicture.Dispose(); RightCharacterPicture = null; } #endif GC.Collect(); }
private void Button_Click_4(object sender, RoutedEventArgs e) { DialogOption option = (DialogOption)DataContext; if (!option.Enabled) { return; } var result = MessageBox.Show("Are you sure you want to delete this node?", "Delete", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { DialogPage parent = null; DialogLabel label = (DialogLabel)option; while (label.Parent != null) { label = label.Parent; } parent = label as DialogPage; option.Parent.Options.Remove(option); if (OnRefresh != null) { OnRefresh(sender, e); } var owner = parent.Owner; owner.Rebind(); } }
public DialogLabel(string id, List <object> block) { this.id = id; this.block = new List <object>(block); characters = new Dictionary <string, DialogCharacter>() { { "R", new DialogCharacter("R", "Rubus") }, { "H", new DialogCharacter("H", "Hedera") }, { "S", new DialogCharacter("S", "Sternella") }, { "A", new DialogCharacter("A", "Agelaius") }, { "O", new DialogCharacter("O", "Oxx") }, { "B", new DialogCharacter("B", "Bark") }, { "Z", new DialogCharacter("Z", "Riddance") }, }; labels = new Dictionary <string, DialogLabel>(); flags = new Dictionary <string, bool>(); // find all characters and labels // parse them to the characters list and labels list for (int i = 0; i < this.block.Count; i++) { // check for character statement if (CheckStatement(this.block[i], "character")) { DialogCharacter c = DialogCharacter.Load(this.block[i]); if (c == null) { throw new DialogError($"Invalid DialogCharacter.\nYAML: {Reserialize(this.block[i])}"); } if (characters.ContainsKey(c.id)) { throw new DialogError($"Duplicate DialogCharacter '{c.id}'.\nYAML: {Reserialize(this.block[i])}"); } characters[c.id] = c; // remove this.block.RemoveAt(i); i--; continue; } // check for label statement if (CheckStatement(this.block[i], "label")) { DialogLabel l = Load(this.block[i]); if (l == null) { throw new DialogError($"Invalid DialogLabel.\nYAML: {Reserialize(this.block[i])}"); } if (labels.ContainsKey(l.id)) { throw new DialogError($"Duplicate DialogLabel '{l.id}'.\nYAML: {Reserialize(this.block[i])}"); } labels[l.id] = l; l.parent = this; // remove this.block.RemoveAt(i); i--; continue; } } }
public DataVertex createNewVertex(DialogLabel page) { DataVertex dv = new DataVertex(); page.Vertex = dv; dv.Page = page; page.onClick = new RelayCommand(onNodeClick); return(dv); }
public DialogFile(string path, Dictionary <string, bool> flags) { // read text from a file StringReader stringReader = new StringReader(Resources.Load <TextAsset>(path).text); // parse to runnable block List <object> block = new Deserializer().Deserialize <List <object> >(stringReader); main = new DialogLabel("main", block); main.flags = flags; }
//初始化游戏页 protected GamePage() { //渐变图层 mFadeLayer = new FadeLayer(this); //对话框 DialogLabel = new DialogLabel(); //角色等 mActorLayout = new AbsoluteLayout { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill }; //游戏背景 mGameBackgroundImage = new RelevantImage(this) { Source = InterApplication.Resource.LoadImageSource("GamePage." + GetType().Name + ".Background"), RelevantX = 0.5, RelevantY = 0.5, Aspect = Aspect.AspectFill }; //UI背景 mMainUiBacnground = new Image() { Source = InterApplication.Resource.GameMainUi, Aspect = Aspect.Fill }; //主布局 mMainLayout = new AbsoluteLayout { Children = { mGameBackgroundImage, mActorLayout, mMainUiBacnground, DialogLabel, mFadeLayer }, HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, BackgroundColor = Color.Black }; //大小变化 SizeChanged += OnSizeChanged; Content = mMainLayout; }
private void Button_Click_3(object sender, RoutedEventArgs e) { DialogOption option = (DialogOption)DataContext; if (!option.Enabled) { return; } RebindWindow rebind = new RebindWindow(); var lstbox = rebind.DialogList; DialogPage parent = null; DialogLabel label = (DialogLabel)option; while (label.Parent != null) { label = label.Parent; } parent = label as DialogPage; List <DialogPage> pages = new List <DialogPage>(); FindPages(parent, pages); foreach (var page in pages) { if (page == option.Parent) { continue; } if (option.Contains(page)) { continue; } lstbox.Items.Add(page); } rebind.Option = option; rebind.ShowDialog(); if (OnRefresh != null) { OnRefresh(sender, e); } var owner = parent.Owner; owner.Rebind(); }
// traverse the label parents to resolve the label name private DialogLabel FindLabel(string name, DialogLabel label) { DialogLabel current = label; do { if (current.labels.ContainsKey(name)) { return(current.labels[name]); } current = current.parent; }while (current != null); return(null); }
// traverse the label parents to resolve the flag name private bool FindFlag(string name, DialogLabel label) { DialogLabel current = label; do { if (current.flags.ContainsKey(name)) { return(current.flags[name]); } current = current.parent; }while (current != null); // if flag doesn't exist, it has value false return(false); }
/// <summary> /// Set title label /// </summary> private void SetTitleLabel() { if (this.UndefinedLabels.Count() == 0) { return; } // Find the label which is on top and within the title grid DialogLabel titleLabel = this.UndefinedLabels.Where(label => this.TitleGrid.Contains(label.TextLabel.CenterX, label.TextLabel.CenterY) == true && IsValidText(label.TextLabel.Text) == true).OrderBy(label => label.TextLabel.Y).FirstOrDefault(); // If exist, set label type to title if (titleLabel != null) { titleLabel.DialogLabelType = DialogLabel.DialogLabelTypes.Title; } }
private void BuildGraph(DialogPage page, DialogLabel parent) { page.setOwner(this); DataVertex dv; if (parent != null) { if (parent is DialogOption) { dv = ((DialogOption)parent).Target.Vertex; } else { dv = parent.Vertex; } } else { dv = createNewVertex(page); AddNode(dv); } foreach (var option in page.Options) { if (option.Target != null) { var optionDv = createNewVertex(option.Target); AddNode(optionDv); LinkNodes(dv, optionDv); option.Enabled = true; option.Target.OptionOwner = option; option.Target.Vertex = optionDv; option.Target.PageOwner = page; option.Target.Label = option.Label; option.Parent = page; option.Command = option.Command; BuildGraph(option.Target, option); } } }
public GameEventTextPrinterDialogLabel(DialogLabel label, string message, bool doNextAfterClick = true) : base(message) { mDialogLabel = label; mDoNextAfterClick = doNextAfterClick; }
// advance dialog state by one if it is a control flow statement. // otherwise, do nothing and return false. private bool Run() { // if stack is empty, we are done if (stack.Count == 0) { return(false); } int idx = stack.Peek().index; // if current index is past end of block, pop from stack if (stack.Peek().index >= stack.Peek().label.block.Count) { Pop(); return(true); } object cur = stack.Peek().label.block[stack.Peek().index]; // handle all control flow statements // labels: calls and exiting if (CheckStatement(cur, "exit")) { stack.Clear(); return(true); } else if (CheckStatement(cur, "return")) { Pop(); return(true); } else if (CheckStatement(cur, "jump")) { string arg = GetStatementArg(cur, "jump"); DialogLabel next = FindLabel(arg, stack.Peek().label); if (next == null) { throw new DialogError($"Label '{arg}' does not exist in this context.\nYAML: {Reserialize(cur)}"); } Push(next); return(true); } // pass: does nothing else if (CheckStatement(cur, "pass")) { stack.Peek().index++; return(true); } // pause: does nothing, but consumes an advance else if (CheckStatement(cur, "pause")) { return(false); } // conditionals: if statement and variables else if (CheckStatement(cur, "if")) { // load if statement block DialogLabel l = DialogLabel.Load(cur, "if"); // if flag is true, run block if (FindFlag(l.id, stack.Peek().label)) { Push(l); } else { stack.Peek().index++; } return(true); } else if (CheckStatement(cur, "ifnot")) { // load ifnot statement block DialogLabel l = DialogLabel.Load(cur, "ifnot"); // if flag is false, run block if (!FindFlag(l.id, stack.Peek().label)) { Push(l); } else { stack.Peek().index++; } return(true); } else if (CheckStatement(cur, "set")) { string arg = GetStatementArg(cur, "set"); root.flags[arg] = true; stack.Peek().index++; return(true); } else if (CheckStatement(cur, "unset")) { string arg = GetStatementArg(cur, "unset"); root.flags[arg] = false; stack.Peek().index++; return(true); } // if not a control flow statement, we are done return(false); }
public DialogLabelEnumerator(DialogLabel label) { root = label; stack = new Stack <DialogStackEntry>(); Reset(); }
public DialogStackEntry(DialogLabel label, int index) { this.label = label; this.index = index; }
private void Push(DialogLabel label) { stack.Peek().index++; stack.Push(new DialogStackEntry(label, 0)); }