Exemple #1
0
 void Start()
 {
     slideDeckScript = GameObject.Find("SlideDeck").GetComponentInChildren <SlideDeck>();
     aSlide          = slideDeckScript.activeSlide;
     btn             = GetComponent <Button>();
     btn.onClick.AddListener(() => slideDeckScript.slides[aSlide].LoadMagnification(btnID));
 }
Exemple #2
0
        public async Task <sr <int> > Save(SlideDeck slideDeck)
        {
            // TODO: add user to set author
            slideDeck.AuthorId = 1;

            return(await _base.Post <SlideDeck, int>("api/slideDeck", slideDeck));
        }
        /// <summary>
        /// Updates Loader scene parameters to run the deck on start.
        /// </summary>
        /// <param name="deck">Slide Deck to use.</param>
        private static void updateLoaderScene(SlideDeck deck)
        {
            var sceneSetup = EditorSceneManager.GetSceneManagerSetup();
            var scene      = EditorSceneManager.OpenScene(SceneUtils.LoaderScenePath, OpenSceneMode.Single);
            var loader     = GameObject.FindObjectOfType <Loader>() as Loader;

            if (loader == null)
            {
                Debug.LogError("Failed to update Loader scene. Can't find Loader script");
                return;
            }

            var so = new SerializedObject(loader);

            so.Update();

            // Set properties.
            var prop = so.FindProperty("Properties");

            prop.objectReferenceValue = Properties.Instance;
            var d = so.FindProperty("Deck");

            d.objectReferenceValue = deck;

            so.ApplyModifiedProperties();

            EditorSceneManager.SaveScene(scene);
            EditorSceneManager.RestoreSceneManagerSetup(sceneSetup);
        }
Exemple #4
0
        /// <summary>
        /// Delete a text or image annotation.
        /// </summary>
        /// <param name="rtda"></param>
        private void ReceiveDeleteAnnotation(RTDeleteAnnotation rtda)
        {
            int slideIndex;

            slideIndex = slideMap.GetMapping(rtda.SlideIndex, rtda.DeckGuid);

            //Get the slide
            Slide        s  = SlideDeck.GetSlide(slideIndex);
            SlideOverlay so = SlideDeck.GetOverlay(slideIndex);

            //If the annotation is on the slide, delete it.
            lock (so.TextAnnotations) {
                if (so.TextAnnotations.ContainsKey(rtda.Guid))
                {
                    so.TextAnnotations.Remove(rtda.Guid);
                }
            }

            lock (so.DynamicImages) {
                if (so.DynamicImages.ContainsKey(rtda.Guid))
                {
                    so.DynamicImages.Remove(rtda.Guid);
                }
            }

            so.RefreshDynamicElements();
        }
        /// <summary>
        /// Returns all scenes in build settings which do not belong to the deck.
        /// </summary>
        /// <param name="deck">The Deck.</param>
        /// <returns>A list of scenes.</returns>
        public static List <EditorBuildSettingsScene> GetNonDeckScenes(SlideDeck deck)
        {
            var scenes = new List <EditorBuildSettingsScene>(EditorBuildSettings.scenes);
            var slides = deck.GetSlides(SlideDeck.PlayModeType.All, SlideDeck.VisibilityType.All);

            var nonDeckScenes = new List <EditorBuildSettingsScene>();
            var hash          = new HashSet <string>();
            var count         = slides.Count;

            for (var i = 0; i < count; i++)
            {
                hash.Add(slides[i].ScenePath);
            }

            foreach (var scene in scenes)
            {
                if (hash.Contains(scene.path))
                {
                    continue;
                }
                nonDeckScenes.Add(scene);
            }

            return(nonDeckScenes);
        }
 public static void CopyValues(this SlideDeck slidedeck, SlideDeck other)
 {
     slidedeck.AuthorId    = other.AuthorId;
     slidedeck.Author      = other.Author;
     slidedeck.Slug        = other.Slug;
     slidedeck.Title       = other.Title;
     slidedeck.Description = other.Description;
     slidedeck.Categories  = other.Categories;
     slidedeck.CoverImage  = other.CoverImage;
     slidedeck.Views       = other.Views;
     slidedeck.Rating      = other.Rating;
     slidedeck.Published   = other.Published;
     slidedeck.IsDeleted   = other.IsDeleted;
     slidedeck.Featured    = other.Featured;
     slidedeck.AccessLevel = other.AccessLevel;
     if (slidedeck.Slides?.Count == 0)
     {
         slidedeck.Slides = other.Slides;
     }
     else
     {
         var slidesToDelete = new List <Slide>();
         // instead of x foreachloops and linq should be able to do in 1 pass if first transformed into dictionary or something
         foreach (var slide in slidedeck.Slides)
         {
             var otherSlide = other.Slides.FirstOrDefault(x => x.Id == slide.Id);
             if (otherSlide == null)
             {
                 slidesToDelete.Add(slide);
             }
             else
             {
                 slide.Page        = otherSlide.Page;
                 slide.TextContent = otherSlide.TextContent;
                 slide.ImageUrl    = otherSlide.ImageUrl;
                 slide.VideoUrl    = otherSlide.VideoUrl;
             }
         }
         foreach (var otherSlide in other.Slides.Where(os => os.Id == default(int)))
         {
             slidedeck.Slides.Add(otherSlide);
         }
         foreach (var delete in slidesToDelete)
         {
             // TODO : add IsDeleted property for soft-delete?
             slidedeck.Slides.Remove(delete);
         }
     }
     foreach (var slide in slidedeck.Slides)
     {
         slide.SlideDeck   = slidedeck;
         slide.SlideDeckId = slidedeck.Id;
     }
 }
        /// <summary>
        /// Builds presentation deck as a standalone application.
        /// </summary>
        /// <param name="deck">Slide Deck to build.</param>
        public static void BuildPresentation(SlideDeck deck)
        {
            string path = EditorUtility.SaveFolderPanel("Choose Location of the Presentation build", "", "");

            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            updateLoaderScene(deck);
            deck.PrepareSlidesForBuild();

            var scenes = SceneUtils.GetBuildScenes(deck, SlideDeck.PlayModeType.PlayMode, SlideDeck.VisibilityType.Visible);

            scenes.Insert(0, new EditorBuildSettingsScene(SceneUtils.LoaderScenePath, true));

            var options = BuildOptions.ShowBuiltPlayer;

            if (EditorUserBuildSettings.development)
            {
                options |= BuildOptions.Development;
            }
            if (EditorUserBuildSettings.connectProfiler)
            {
                options |= BuildOptions.ConnectWithProfiler;
            }
            if (EditorUserBuildSettings.allowDebugging)
            {
                options |= BuildOptions.AllowDebugging;
            }

            try
            {
                string name;
                switch (EditorUserBuildSettings.activeBuildTarget)
                {
                case BuildTarget.StandaloneWindows:
                case BuildTarget.StandaloneWindows64:
                    name = "Presentation.exe";
                    break;

                default:
                    name = "Presentation";
                    break;
                }
                BuildPipeline.BuildPlayer(scenes.ToArray(), Path.Combine(path, name), EditorUserBuildSettings.activeBuildTarget, options);
            }
            catch (Exception e)
            {
                Debug.Log(e.Message);
            }
        }
        public static bool step1(int instanceID, int line)
        {
            SlideDeck deck = EditorUtility.InstanceIDToObject(instanceID) as SlideDeck;

            if (deck)
            {
                Engine.Instance.LoadDeck(deck);
                EditorWindow.GetWindow <PresentationWindow>().titleContent = new GUIContent("Presentation");
                return(true);
            }

            return(false);
        }
Exemple #9
0
        public async void UpdateSlides(SlideDeck slideDeck)
        {
            string newData;
            var    jsonSerializerSettings = new JsonSerializerSettings
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            };

            newData = JsonConvert.SerializeObject(slideDeck, jsonSerializerSettings);

            lock (_lock)
            {
                System.IO.File.WriteAllText(@"./data.json", newData);
            }
        }
Exemple #10
0
        private void ReceiveQuickPoll(RTQuickPoll rtqp)
        {
            int slideIndex;

            //If we have already created the QuickPoll slide, get its index:
            slideIndex = slideMap.GetMapping(rtqp.SlideIndex, rtqp.DeckGuid);

            //Get the slide and overlay
            Slide        s  = SlideDeck.GetSlide(slideIndex);
            SlideOverlay so = SlideDeck.GetOverlay(slideIndex);

            so.QuickPoll.Update((int)rtqp.Style, rtqp.Results);
            so.QuickPoll.Enabled = true;

            so.RefreshDynamicElements();
        }
Exemple #11
0
            new Guid("{179222D6-BCC1-4570-8D8F-7E8834C1DD2A}");              //Presenter 2.0

        #endregion Static

        #region Constructor
        /// <summary>
        /// Construct
        /// </summary>
        /// <param name="view">The control where we display slides and ink</param>
        /// <param name="form">The top level form for the app</param>
        public SlideViewerGlue(LockedSlideView view, WebViewerForm form)
        {
            mySlideView = view;
            parent      = form;

            mySlideView.LockObject = form;
            mySlideView.Data       = new SlideViewData();

            currentBackgroundColor = mySlideView.LayerPanel.BackColor;

            this.webClient             = new System.Net.WebClient();
            this.webClient.BaseAddress = "";
            this.webClient.Credentials = null;

            //Scale factors to make ink appear at the right place on this display.
            Graphics g = form.CreateGraphics();

            XinkScaleFactor = 96.0 / g.DpiX;
            YinkScaleFactor = 96.0 / g.DpiY;
            g.Dispose();

            slideDeck         = new SlideDeck();     //Create deck with one blank slide
            currentSlideIndex = 0;
            currentSlideSize  = 1;

            //Put that slide and overlay into SlideViewData:
            mySlideView.Data.ChangeSlide(slideDeck.GetSlide(0), slideDeck.GetOverlay(0));

            //Prepare layers for the SlideView control
            mySlideView.ClearLayers();
            mySlideView.AddLayer(new ImageLayer());
            mySlideView.AddLayer(new DynamicElementsLayer());
            mySlideView.AddLayer(new InkLayer());

            mySlideView.Scrollable = false;              //The app can scroll, but the user can't

            //need this for scrolling:
            workQueue            = new WorkQueue();
            workQueue.LockObject = form;

            baseURL = null;
            extent  = null;

            //Map Presenter2 decks to a flat array.
            slideMap = new SlideMap();
        }
        /// <summary>
        /// Returns slide list for builds settings.
        /// </summary>
        /// <param name="deck">The Deck.</param>
        /// <param name="playmode">Playmode filter.</param>
        /// <param name="visibility">Visibility filter.</param>
        /// <returns>A list of scenes.</returns>
        public static List <EditorBuildSettingsScene> GetBuildScenes(SlideDeck deck, SlideDeck.PlayModeType playmode, SlideDeck.VisibilityType visibility)
        {
            var nonDeckScenes = SceneUtils.GetNonDeckScenes(deck);

            var slides = deck.GetSlides(playmode, visibility);
            var scenes = new List <EditorBuildSettingsScene>(slides.Count + nonDeckScenes.Count);

            foreach (var slide in slides)
            {
                var path = slide.ScenePath;
                if (string.IsNullOrEmpty(path))
                {
                    continue;
                }
                scenes.Add(new EditorBuildSettingsScene(path, true));
            }

            scenes.AddRange(nonDeckScenes);
            return(scenes);
        }
Exemple #13
0
        /// <summary>
        /// These are images that are added to slides "on-the-fly".
        /// </summary>
        /// <param name="rtia"></param>
        private void ReceiveImageAnnotation(RTImageAnnotation rtia)
        {
            //Get the internal slide index:
            int slideIndex = slideMap.GetMapping(rtia.SlideIndex, rtia.DeckGuid);

            //Get the slide and overlay
            Slide        s  = SlideDeck.GetSlide(slideIndex);
            SlideOverlay so = SlideDeck.GetOverlay(slideIndex);

            lock (so.DynamicImages) {
                //If the annotation is already on the slide, replace, otherwise add.
                if (so.DynamicImages.ContainsKey(rtia.Guid))
                {
                    so.DynamicImages[rtia.Guid] = new DynamicImage(rtia.Guid, rtia.Origin, rtia.Width, rtia.Height, rtia.Img);
                }
                else
                {
                    so.DynamicImages.Add(rtia.Guid, new DynamicImage(rtia.Guid, rtia.Origin, rtia.Width, rtia.Height, rtia.Img));
                }
            }
            so.RefreshDynamicElements();
        }
Exemple #14
0
        private void ReceiveTextAnnotation(RTTextAnnotation rtta)
        {
            int slideIndex;

            slideIndex = slideMap.GetMapping(rtta.SlideIndex, rtta.DeckGuid);

            //Get the slide and overlay
            Slide        s  = SlideDeck.GetSlide(slideIndex);
            SlideOverlay so = SlideDeck.GetOverlay(slideIndex);

            lock (so.TextAnnotations) {
                //If the annotation is already on the slide, replace, otherwise add.
                if (so.TextAnnotations.ContainsKey(rtta.Guid))
                {
                    so.TextAnnotations[rtta.Guid] = new TextAnnotation(rtta.Guid, rtta.Text, rtta.Color, rtta.Font, rtta.Origin, rtta.Width, rtta.Height);
                }
                else
                {
                    so.TextAnnotations.Add(rtta.Guid, new TextAnnotation(rtta.Guid, rtta.Text, rtta.Color, rtta.Font, rtta.Origin, rtta.Width, rtta.Height));
                }
            }
            so.RefreshDynamicElements();
        }
        /// <summary>
        /// Draws inspector for a Slide Deck.
        /// </summary>
        /// <param name="deck">Slide Deck to draw.</param>
        /// <param name="scroll">Current vertical scroll value.</param>
        /// <param name="shouldSelect">A function which returns if the current slide should be selected.</param>
        /// <param name="onPlayPress">A function called when "Play" button of a slide is pressed.</param>
        /// <returns>Current vertical scroll value.</returns>
        public static float DrawInspector(SlideDeck deck, float scroll, Func <SlideDeck, int, bool> shouldSelect = null, Action <SlideDeck, int> onPlayPress = null)
        {
            if (styles == null)
            {
                styles = new Styles();
            }

            ReorderableList list;
            var             key = deck.GetInstanceID() + "#" + (shouldSelect != null) + "#" + (onPlayPress != null);

            if (!lists.TryGetValue(key, out list))
            {
                // Init a ReorderableList for the deck and cache it.
                list = new ReorderableList(deck.Slides, typeof(PresentationSlide), true, true, true, true);
                lists.Add(key, list);

                list.onChangedCallback += (l) =>
                {
//					deck.Save();
                };

                list.drawHeaderCallback += (Rect rect) => GUI.Label(rect, deck.IsSavedOnDisk ? deck.Name + ".asset" : "<not saved>");

                list.elementHeightCallback += (int index) => styles.ELEMENT_HEIGHT;

                list.drawElementBackgroundCallback += (Rect rect, int index, bool isActive, bool isFocused) =>
                {
                    if (Event.current.type == EventType.Repaint)
                    {
                        if (index < 0)
                        {
                            return;
                        }

                        var bgcolor = GUI.backgroundColor;
                        var slide   = deck.Slides[index];

                        if (shouldSelect != null && shouldSelect(deck, index))
                        {
                            GUI.backgroundColor = styles.SELECTED_COLOR;
                            rect.height        += 3;
                            styles.BG_SELECTED.Draw(rect, false, isActive, isActive, isFocused);
                        }
                        else
                        if (slide.Visible || isFocused)
                        {
                            styles.BG.Draw(rect, false, isActive, isActive, isFocused);
                        }
                        else
                        {
                            GUI.backgroundColor = styles.INVISIBLE_COLOR;
                            rect.height        += 3;
                            styles.BG_INVISIBLE.Draw(rect, false, isActive, isActive, isFocused);
                        }
                        GUI.backgroundColor = bgcolor;
                    }
                };

                list.drawElementCallback += (Rect rect, int index, bool isActive, bool isFocused) =>
                {
                    var changed = false;
                    var color   = GUI.color;
                    var slide   = deck.Slides[index];

                    // visible
                    EditorGUI.BeginChangeCheck();
                    if (!slide.Visible)
                    {
                        GUI.color = styles.INACTIVE_COLOR;
                    }
                    var newVisible = GUI.Toggle(
                        new Rect(rect.x, rect.y, styles.ICON.fixedWidth, rect.height), slide.Visible, styles.VISIBLE_ICON, styles.ICON);
                    if (EditorGUI.EndChangeCheck())
                    {
                        slide.Visible = newVisible;
                        changed       = true;
                    }
                    GUI.color = color;
                    rect.x   += styles.ICON.fixedWidth;

                    // play mode
                    EditorGUI.BeginChangeCheck();
                    if (!slide.StartInPlayMode)
                    {
                        GUI.color = styles.INACTIVE_COLOR;
                    }
                    var newPlaymode = GUI.Toggle(
                        new Rect(rect.x, rect.y, styles.ICON.fixedWidth, rect.height), slide.StartInPlayMode, styles.PLAYMODE_ICON, styles.ICON);
                    if (EditorGUI.EndChangeCheck())
                    {
                        slide.StartInPlayMode = newPlaymode;
                        changed = true;
                    }
                    GUI.color = color;
                    rect.x   += styles.ICON.fixedWidth;

                    // scene
                    var w = rect.width - styles.ICON.fixedWidth * 2;
                    if (onPlayPress != null)
                    {
                        w -= styles.PLAY_BUTTON.fixedWidth + 6;
                    }
                    var scene = AssetDatabase.LoadAssetAtPath <SceneAsset>(slide.ScenePath);
                    EditorGUI.BeginChangeCheck();
                    var newScene = EditorGUI.ObjectField(new Rect(rect.x, rect.y + 2, w, rect.height - 4), scene, typeof(SceneAsset), false) as SceneAsset;
                    if (EditorGUI.EndChangeCheck())
                    {
                        slide.Scene = newScene;
                        changed     = true;
                    }
                    rect.x += w + 6;

                    if (onPlayPress != null)
                    {
                        rect.y += 2;
                        if (GUI.Button(rect, styles.PLAY_ICON, styles.PLAY_BUTTON))
                        {
                            onPlayPress(deck, index);
                        }
                    }

                    if (changed)
                    {
                        deck.Save();
                    }
                };
            }

            scroll = EditorGUILayout.BeginScrollView(new Vector2(0, scroll), false, false, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)).y;
            var r = GUILayoutUtility.GetRect(0, list.GetHeight() + 20);

            list.DoList(r);

            var propsName   = "presentation_" + deck.name + "_options";
            var showOptions = EditorPrefs.GetBool(propsName, false);

            showOptions = GUIElements.Header(styles.TEXT_OPTIONS, showOptions);
            if (showOptions)
            {
                EditorGUI.indentLevel++;
                deck.BackgroundColor = EditorGUILayout.ColorField(styles.TEXT_BG_COLOR, deck.BackgroundColor, true, false, false, new ColorPickerHDRConfig(0, 1, 0, 1), GUILayout.ExpandWidth(true));
                EditorGUI.indentLevel--;
            }
            EditorPrefs.SetBool(propsName, showOptions);
            EditorGUILayout.EndScrollView();

            return(scroll);
        }
 private void OnEnable()
 {
     instance = target as SlideDeck;
 }
 /// <summary>
 /// Updates scenes in build settings.
 /// </summary>
 /// <param name="deck">The Deck.</param>
 /// <param name="playmode">Playmode filter.</param>
 /// <param name="visibility">Visibility filter.</param>
 public static void UpdateBuildScenes(SlideDeck deck, SlideDeck.PlayModeType playmode, SlideDeck.VisibilityType visibility)
 {
     EditorBuildSettings.scenes = GetBuildScenes(deck, playmode, visibility).ToArray();
 }