public virtual void addStoryTag(StoryTag sTag) // Add a story tag element to the view { Text storyTagElement = Instantiate(storyTagPrefab, contentField) as Text; var storyTagScript = storyTagElement.GetComponent <StoryTagScript>(); storyTagScript.setStoryTag(sTag); float elementWidth = storyTagElement.rectTransform.rect.width * 0.8f; storyTagElement.rectTransform.localPosition = new Vector3( defaultSpawnPos.x + elementWidth * storyTagElements.Count, defaultSpawnPos.y, 0); storyTagElement.rectTransform.localScale = new Vector3(0.8f, 0.8f); storyTagElements.Add(storyTagElement.GetComponent <StoryTagScript>()); // TODO: Make the prefab require a StoryTagScrit foreach (var listener in storyTagClickListeners) { storyTagElement.GetComponent <Button>().onClick.AddListener(() => listener(storyTagScript)); } autofitContentField(); }
public void addStoryTag(StoryTag sTag, StoryLink sLink) { print("Converting storytag for transmission"); var sTagID = assetManager.getID(sTag); var sLinkStruct = new StoryLinkStruct(); sLinkStruct.endStoryTagID = sTagID; if (sLink.traitLink != null) { sLinkStruct.isLinkedToTrait = true; sLinkStruct.linkedElementID = assetManager.getID(sLink.traitLink); } else if (sLink.storyTagLink != null) { sLinkStruct.isLinkedToTrait = false; sLinkStruct.linkedElementID = assetManager.getID(sLink.storyTagLink); } else { return; } addStoryTag(sTagID, sLinkStruct); }
public override void addStoryTag(StoryTag sTag) // Add a story tag element to the view { if (currentSlot >= sTagSlots.Count) { print("Exceeded slots"); return; } GameObject gObject = sTagSlots[currentSlot]; var storyTagElement = gObject.GetComponent <StoryTagScript>(); currentSlot++; print("gObject: " + gObject); print("StorytagElement: " + storyTagElement); if (gObject == null) { print("gObject was null!"); addStoryTag(sTag); return; } if (storyTagElement == null) { print("StorytagElement was null, adding new one"); storyTagElement = gObject.AddComponent <StoryTagScript>(); } storyTagElement.enabled = true; storyTagElement.GetComponent <Text>().enabled = true; storyTagElement.setStoryTag(sTag); print("storyTagElement.enabled: " + storyTagElement.GetComponent <Text>().enabled); storyTagElements.Add(storyTagElement); }
public StoryAggregate Update(string Token, StoryAggregate StoryInstance) { try { var Handler = new JwtSecurityTokenHandler(); Token = Token.Replace("Bearer", "").Trim(); var JsonToken = Handler.ReadJwtToken(Token); string Id = JsonToken.Claims.First(c => c.Type == "id").Value; Console.WriteLine("============================================"); Console.WriteLine("============================================"); Console.WriteLine("============================================"); Console.WriteLine(JsonConvert.SerializeObject(StoryInstance)); Story Story = this.StoryContextInstance.Stories.SingleOrDefault(s => s.Id == StoryInstance.StoryInfo.Id); this.StoryContextInstance.Stories.Update(Story); List <Tag> Tags = new List <Tag>(); Tags.AddRange(StoryInstance.Tags); Tags.ForEach(Tag => { StoryTag StoryTag = new StoryTag(); StoryTag.TagId = Tag.Id; StoryTag.StoryId = Story.Id; if (this.StoryContextInstance.StoryTags.SingleOrDefault(st => st.TagId == StoryTag.TagId && st.StoryId == StoryTag.StoryId) == null) { this.StoryContextInstance.StoryTags.Add(StoryTag); } }); this.StoryContextInstance.SaveChanges(); return(StoryInstance); } catch (Exception ex) { Console.WriteLine("++++++++++++++++++++++++++++++++++++++++++++++++++++"); Console.WriteLine("++++++++++++++++++++++++++++++++++++++++++++++++++++"); Console.WriteLine("++++++++++++++++++++++++++++++++++++++++++++++++++++"); Console.WriteLine("++++++++++++++++++++++++++++++++++++++++++++++++++++"); if (ex is CustomHttpResponseException) { CustomHttpResponseException cex = ex as CustomHttpResponseException; Console.WriteLine(JsonConvert.SerializeObject(cex.CustomData)); } else { Console.WriteLine(JsonConvert.SerializeObject(ex)); } throw ex; } }
public void addStoryTag(StoryTag sTag, StoryLink sLink) { storytags.Add(sTag); storylinks.Add(sLink); foreach (var onNewSTag in newStoryTagListeners) { onNewSTag(sTag, sLink); } }
public void onNewStoryTagAdded(StoryTag sTag, StoryLink sLink) { foreach (var sTagE in storyTagElements) { if (sTagE.StoryTagObject == sTag) { return; } } addStoryTag(sTag); addStoryLink(sLink); }
public object Deserialize(JsonValue json, JsonMapper mapper) { StoryTag video = null; if ( json != null && !json.IsNull ) { video = new StoryTag(); video.ID = json.ContainsName("id" ) ? json.GetValue<string>("id" ) : String.Empty; video.Name = json.ContainsName("name" ) ? json.GetValue<string>("name" ) : String.Empty; video.Offset = json.ContainsName("offset") ? json.GetValue<int >("offset") : 0; video.Length = json.ContainsName("length") ? json.GetValue<int >("length") : 0; } return video; }
public ActionResult Create([Bind(Include = "IsAboutId,CommissionedBy,IsCannon,TheContent,Title")] StoryCreateVM story, List <short> tags) { story.DateTold = System.DateTime.Now.Date; if (ModelState.IsValid) { Story daStory = new Story { DateTold = story.DateTold, CommissionedBy = story.CommissionedBy, IsAboutId = story.IsAboutId, IsCannon = story.IsCannon, TheContent = story.TheContent, Title = story.Title }; db.Stories.Add(daStory); db.SaveChanges(); short storyId = db.Stories.Max(s => s.StoryId); #region Adding Tags //if the story is labled as non-canon auto add the non-cannon tag as the first tag if (!story.IsCannon) { short noncanTagID = db.Tags.Where(t => t.TagName == "Non-Canon").Select(t => t.TagId).First(); if (tags.Contains(noncanTagID)) { tags.Remove(noncanTagID); } tags.Insert(0, noncanTagID); } //add story tags if (tags != null) { foreach (short t in tags) { StoryTag storyTag = new StoryTag { StoryId = storyId, TagId = t }; db.StoryTags.Add(storyTag); } } #endregion db.SaveChanges(); return(RedirectToAction("Details", "Infos", new { id = story.IsAboutId })); } ViewBag.IsAboutId = new SelectList(db.Infos, "InfoId", "Name", story.IsAboutId); ViewBag.Tags = new MultiSelectList(db.Tags, "TagId", "TagName", tags); return(View(story)); }
public object Deserialize(JsonValue json, JsonMapper mapper) { StoryTag video = null; if (json != null && !json.IsNull) { video = new StoryTag(); video.ID = json.ContainsName("id") ? json.GetValue <string>("id") : String.Empty; video.Name = json.ContainsName("name") ? json.GetValue <string>("name") : String.Empty; video.Offset = json.ContainsName("offset") ? json.GetValue <int>("offset") : 0; video.Length = json.ContainsName("length") ? json.GetValue <int>("length") : 0; } return(video); }
public ActionResult Edit([Bind(Include = "StoryId,IsAboutId,DateTold,CommissionedBy,IsCannon,TheContent,Title")] StoryEditVM story, List <short> tags) { if (ModelState.IsValid) { #region Update Story Story daStory = new Story { StoryId = story.StoryId, DateTold = story.DateTold, CommissionedBy = story.CommissionedBy, IsAboutId = story.IsAboutId, IsCannon = story.IsCannon, TheContent = story.TheContent, Title = story.Title }; db.Entry(daStory).State = EntityState.Modified; db.SaveChanges(); #endregion #region Update Tags List <short> currentTagIds = db.StoryTags.Where(x => x.StoryId == story.StoryId).Select(x => x.StoryId).ToList(); if (tags != null) { foreach (short t in tags) { //if this is an already existing tag if (currentTagIds.Contains(t)) { currentTagIds.Remove(t); } else { StoryTag newTag = new StoryTag { StoryId = story.StoryId, TagId = t }; db.StoryTags.Add(newTag); } } } if (currentTagIds.Count != 0) { foreach (short id in currentTagIds) { StoryTag gone = db.StoryTags.Where(x => x.StoryId == story.StoryId & x.TagId == id).FirstOrDefault(); db.StoryTags.Remove(gone); } } db.SaveChanges(); #endregion return(RedirectToAction("Details", "Infos", new { id = story.IsAboutId })); } ViewBag.IsAboutId = new SelectList(db.Infos, "InfoId", "Name", story.IsAboutId); ViewBag.Tags = db.Tags.ToList(); if (tags != null) { ViewBag.Selected = tags; } else { ViewBag.Selected = new List <short>(); } return(View(story)); }
public void setStoryTag(StoryTag storytag) { StoryTagObject = storytag; GetComponent <Text>().text = storytag.description; }
public StoryLink(StoryTag parent, StoryTag link) { endStoryTag = parent; storyTagLink = link; }
public StoryLink(StoryTag parent, Trait link) { endStoryTag = parent; traitLink = link; }
public int getID(StoryTag sTag) { return(storyTagList.IndexOf(sTag)); }
public async Task <StoryAggregate> Create(string Token, StoryAggregate StoryInstance) { try { var Handler = new JwtSecurityTokenHandler(); Token = Token.Replace("Bearer", "").Trim(); var JsonToken = Handler.ReadJwtToken(Token); string Id = JsonToken.Claims.First(c => c.Type == "id").Value; User User = this.StoryContextInstance.Users.SingleOrDefault(u => u.Id == Id); if (User == null) { User = await this.AccountServiceInstance.Detail("Bearer " + Token); this.StoryContextInstance.Users.Add(User); this.StoryContextInstance.SaveChanges(); } Story Story = StoryInstance.StoryInfo; Story.UserId = Id; Story.User = User; Story.Category = this.StoryContextInstance.Categories.SingleOrDefault(c => c.Id == Story.CategoryId); this.StoryContextInstance.Stories.Add(Story); List <Tag> Tags = new List <Tag>(); Tags.AddRange(StoryInstance.Tags); Tags.ForEach(Tag => { StoryTag StoryTag = new StoryTag(); StoryTag.TagId = Tag.Id; StoryTag.StoryId = Story.Id; this.StoryContextInstance.StoryTags.Add(StoryTag); }); this.StoryContextInstance.SaveChanges(); return(StoryInstance); } catch (Exception ex) { Console.WriteLine("++++++++++++++++++++++++++++++++++++++++++++++++++++"); Console.WriteLine("++++++++++++++++++++++++++++++++++++++++++++++++++++"); Console.WriteLine("++++++++++++++++++++++++++++++++++++++++++++++++++++"); Console.WriteLine("++++++++++++++++++++++++++++++++++++++++++++++++++++"); if (ex is CustomHttpResponseException) { CustomHttpResponseException cex = ex as CustomHttpResponseException; Console.WriteLine(JsonConvert.SerializeObject(cex.CustomData)); } else { Console.WriteLine(JsonConvert.SerializeObject(ex)); } throw ex; } }