/// <summary>Collects options and displays the menu at the pointers position. /// Run this on the 'root' option list only (don't call it on submenu's).</summary> public void display(InputPointer ip, bool instant) { // First, collect the options: ContextEvent ce = collectOptions(ip); if (instant) { // Won't actually display - just immediately run op 0: run(); return; } // Even if it collected nothing, attempt to display it. // The event contains the position for us. // Get the widget manager: Widgets.Manager widgets = (ce.contextDocument as HtmlDocument).widgets; // Open a widget (closing an existing one): widget = widgets.get(ce.template, null); if (widget != null) { widget.close(); } widget = widgets.open(ce.template, null, buildGlobals(ce)); }
/// <summary>Opens a widget, passing this timeline as a global.</summary> internal Widgets.Widget openWidget(string template) { if (document == null || template == null) { Dom.Log.Add("PowerSlide requested to open a widget without a document/ template. Request was ignored."); return(null); } if (currentWidget != null) { if (currentWidget.Type == template) { // Unchanged template. return(currentWidget); } currentWidget.close(); currentWidget = null; } // Open it now: currentWidget = document.widgets.open(template, null, "timeline", this); return(currentWidget); }
public static void ClickToContinue(PowerUI.MouseEvent e) { // The widget: Widgets.Widget widget = e.htmlTarget.widget; // Is it a dialogue widget? DialogueWidget dw = widget as DialogueWidget; PowerSlide.Timeline tl; if (dw != null) { // Get the timeline: tl = dw.timeline; // Is there an option on the UI at the moment? if (dw.hasActiveOption) { // Yes - ignore: return; } } else { // Get the timeline: tl = PowerSlide.Timeline.get(widget); } // Cue it: if (tl != null) { tl.cue(); } }
public static void Cue(PowerUI.MouseEvent me) { // The widget: Widgets.Widget widget = me.htmlTarget.widget; // Get the timeline: PowerSlide.Timeline tl = PowerSlide.Timeline.get(widget); // Cue it: if (tl != null) { tl.cue(); } }
/// <summary>Resolves an option from a context menu widget's document.</summary> public static Option ResolveOption(int index, Widgets.Widget widget) { // These widgets are always 'ContextMenuWidget' objects. // They also only ever display one list - submenus are separate widgets. OptionList list = (widget as ContextMenuWidget).List; if (list == null) { return(null); } // Awesome - we can now get the actual option instance: return(list[index]); }
/// <summary>Gets the current instance for the given widget (null if none found).</summary> public static Timeline get(Widgets.Widget widget) { Timeline current = first; while (current != null) { if (current.currentWidget == widget) { return(current); } current = current.after; } return(null); }
/// <summary>This slide is now starting.</summary> internal override void start() { base.start(); Timeline tl = track.timeline; // Display this dialogue slide now! // Any audio? if (!string.IsNullOrEmpty(audioFilePath)) { // Play the audio now. // Note that PowerSlide will follow the lead of the audio engine. playAudio(); } // Get the template to use: string templateToUse = (template == null)? tl.template:template; // Open the widget (which closes the prev one for us): Widgets.Widget widget = tl.openWidget(templateToUse); if (widget != null) { // Trigger a dialogue start event: SlideEvent s = new SlideEvent("dialoguestart", null); s.slide = this; tl.dispatchEvent(s); } if (waitForCue) { // Wait! Advance to the end of the slide now too // (because it has an auto duration which doesn't have any meaning). tl.setPause(true); if (tl.backwards) { tl.currentTime = computedStart; } else { tl.currentTime = computedEnd; } } }
/// <summary>Resets this timeline so it can start over.</summary> public void reset() { // Clear cues: clearCues(); if (first == null && updater != null) { // Stop the updater: updater.Stop(); updater = null; } // Kill any running slides: Slide current = firstRunning; while (current != null) { // Done! current.end(); paused = false; current = current.nextRunning; } // Widget: if (currentWidget != null) { currentWidget.close(); currentWidget = null; } // Clear various settings: currentTime = 0f; backwards = false; direction = KeyframesAnimationDirection.Forward; repeatCount = 1; status_ = TIMELINE_LOADING; }
/// <summary>Closes any visible version of this list.</summary> public void close(bool all) { if (all && parent != null) { // Go up the parent tree to close the root. parent.close(true); return; } // Clear all option elements: for (int i = 0; i < options.Count; i++) { options[i].buttonElement = null; } // Got a widget? if (widget != null) { // Yep - close it! widget.close(); widget = null; } }
/// <summary>Runs this option (or option 0 if this is a list).</summary> public virtual void run() { if (isOpen) { // Sub-menu and it's open. Close it. close(); return; } // If the parent menu is open then we're actually opening up a submenu. if (parent.isOpen) { // Opening a sub-menu. Get the parent widget: ContextMenuWidget cmw = (parent.widget as ContextMenuWidget); // Open it (relative to the parent - if the parent closes, it does too): widget = parent.widget.open(cmw.SubMenuType, null, buildGlobals(null)); } else { // Directly run option 0: run(0); } }