/// <summary> /// Constructor for the button /// </summary> /// <param name="capi">The core client API.</param> /// <param name="color"></param> /// <param name="OnToggled">The action that happens when the button is toggled.</param> /// <param name="bounds">The bounding box of the button.</param> public GuiElementColorListPicker(ICoreClientAPI capi, int color, Common.Action <bool> OnToggled, ElementBounds bounds) : base(capi, bounds) { activeTexture = new LoadedTexture(capi); this.color = color; handler = OnToggled; }
/// <summary> /// Flips through given array of item stacks every second /// </summary> /// <param name="itemstacks"></param> /// <param name="unscaleSize"></param> /// <param name="floatType"></param> public SlideshowItemstackTextComponent(ICoreClientAPI capi, ItemStack[] itemstacks, double unscaleSize, EnumFloat floatType, Common.Action <ItemStack> onStackClicked = null) : base(capi) { initSlot(); this.Itemstacks = itemstacks; this.Float = floatType; this.BoundsPerLine = new LineRectangled[] { new LineRectangled(0, 0, GuiElement.scaled(unscaleSize), GuiElement.scaled(unscaleSize)) }; this.onStackClicked = onStackClicked; }
public ItemstackTextComponent(ICoreClientAPI capi, ItemStack itemstack, double size, double sidePadding = 0, EnumFloat floatType = EnumFloat.Left, Common.Action <ItemStack> onStackClicked = null) : base(capi) { slot = new DummySlot(itemstack); this.onStackClicked = onStackClicked; this.Float = floatType; this.size = size; this.BoundsPerLine = new LineRectangled[] { new LineRectangled(0, 0, size + sidePadding, size) }; //PaddingRight = 0; }
/// <summary> /// A text component with an embedded link. /// </summary> /// <param name="displayText">The text of the Text.</param> /// <param name="url">The link in the text.</param> public LinkTextComponent(ICoreClientAPI api, string displayText, CairoFont font, Common.Action <LinkTextComponent> onLinkClicked) : base(api, displayText, font) { this.onLinkClicked = onLinkClicked; MouseOverCursor = "linkselect"; this.font = this.font.Clone().WithColor(GuiStyle.ActiveButtonTextColor); hoverText = new LoadedTexture(api); normalText = new LoadedTexture(api); }
/// <summary> /// Constructor for the button /// </summary> /// <param name="capi">The core client API.</param> /// <param name="icon">The icon name</param> /// <param name="text">The text for the button.</param> /// <param name="font">The font of the text.</param> /// <param name="OnToggled">The action that happens when the button is toggled.</param> /// <param name="bounds">The bounding box of the button.</param> /// <param name="toggleable">Can the button be toggled on or off?</param> public GuiElementToggleButton(ICoreClientAPI capi, string icon, string text, CairoFont font, Common.Action <bool> OnToggled, ElementBounds bounds, bool toggleable = false) : base(capi, text, font, bounds) { releasedTexture = new LoadedTexture(capi); pressedTexture = new LoadedTexture(capi); hoverTexture = new LoadedTexture(capi); handler = OnToggled; Toggleable = toggleable; this.icon = icon; }
public void SetNewTextWithoutRecompose(string vtmlCode, CairoFont baseFont, Common.Action <LinkTextComponent> didClickLink = null) { if (this.Components != null) { foreach (var val in Components) { val?.Dispose(); } } this.Components = VtmlUtil.Richtextify(api, vtmlCode, baseFont, didClickLink); }
/// <summary> /// Looks at the collectibles handbook groupBy attribute and makes a list of itemstacks from that /// </summary> /// <param name="itemstackgroup"></param> /// <param name="unscaleSize"></param> /// <param name="floatType"></param> public SlideshowItemstackTextComponent(ICoreClientAPI capi, ItemStack itemstackgroup, List <ItemStack> allstacks, double unscaleSize, EnumFloat floatType, Common.Action <ItemStack> onStackClicked = null) : base(capi) { initSlot(); this.onStackClicked = onStackClicked; string[] groups = itemstackgroup.Collectible.Attributes?["handbook"]?["groupBy"]?.AsArray <string>(null); List <ItemStack> nowGroupedStacks = new List <ItemStack>(); List <ItemStack> stacks = new List <ItemStack>(); nowGroupedStacks.Add(itemstackgroup); stacks.Add(itemstackgroup); if (groups != null) { AssetLocation[] groupWildCards = new AssetLocation[groups.Length]; for (int i = 0; i < groups.Length; i++) { if (!groups[i].Contains(":")) { groupWildCards[i] = new AssetLocation(itemstackgroup.Collectible.Code.Domain, groups[i]); } else { groupWildCards[i] = new AssetLocation(groups[i]); } } foreach (var val in allstacks) { for (int i = 0; i < groupWildCards.Length; i++) { if (val.Collectible.WildCardMatch(groupWildCards[i])) { stacks.Add(val); nowGroupedStacks.Add(val); break; } } } } foreach (var val in nowGroupedStacks) { allstacks.Remove(val); } this.Itemstacks = stacks.ToArray(); this.Float = floatType; this.BoundsPerLine = new LineRectangled[] { new LineRectangled(0, 0, GuiElement.scaled(unscaleSize), GuiElement.scaled(unscaleSize)) }; //PaddingRight = 0; }
/// <summary> /// Fades out the current track. /// </summary> /// <param name="seconds">The duration of the fade out in seconds.</param> /// <param name="onFadedOut">What to have happen after the track has faded out.</param> public virtual void FadeOut(float seconds, Common.Action onFadedOut = null) { loading = false; if (Sound != null && IsActive) { Sound.FadeOut(seconds, (sound) => { sound.Dispose(); Sound = null; onFadedOut?.Invoke(); }); return; } }
public Character(GameObject Image_obj, Common.Type t) { obj = Image_obj; act = Common.Action.Walk; type = t; map = Instantiate(Resources.Load <GameObject>("Prefab/Icon")) as GameObject; map.transform.parent = GameObject.Find("Map_base").transform; if (t != Common.Type.Player) { Set_Chara((int)t); //obj.GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("Images/Charactor/Enemy_sprite/Enemy" + (int)t+"_1"); map.GetComponent <Image>().sprite = Resources.Load <Sprite>("Images/GameScene/Small_enemy"); } speed = 1; count = 0; }
/// <summary> /// Fades out the current track. /// </summary> /// <param name="seconds">The duration of the fade out in seconds.</param> /// <param name="onFadedOut">What to have happen after the track has faded out.</param> public void FadeOut(float seconds, Common.Action onFadedOut = null) { loading = false; if (Sound != null && IsActive) { Sound.FadeOut(seconds, (sound) => { sound.Dispose(); Sound = null; onFadedOut?.Invoke(); }); // Half cool down when interupted SetCooldown(0.5f); return; } // Full cooldown when stopped normally SetCooldown(1f); }
public static void DoLog(Common.Action act, string UIDorTELL, int Result, string Exception) { try { Com.Log mLog = new Com.Log() { ActionType = (int)act, Time = DateTime.UtcNow, UIDorTELLNUMBER = UIDorTELL, Result = Result, Exception = Exception }; using (FitnessEntities ent = new FitnessEntities()) { ent.Logs.Add(mLog); ent.SaveChanges(); } } catch (Exception e) { Console.WriteLine("Error On Log: " + e.Message); } }
/// <summary> /// Fade out the track to end. /// </summary> /// <param name="seconds">Seconds to fade out across.</param> /// <param name="onFadedOut">Delegate to have happen once the fade-out is done.</param> public void FadeOut(float seconds, Common.Action onFadedOut = null) { bool wasInterupted = false; foreach (MusicTrackPart part in Parts) { if (part.IsPlaying) { part.Sound.FadeOut(seconds, (sound) => { sound.Dispose(); part.Sound = null; onFadedOut?.Invoke(); }); wasInterupted = true; } } // When naturally stopped, give the player a break from the cave sounds (3-10 minutes) if (!wasInterupted) { cooldownUntilMs = capi.World.ElapsedMilliseconds + (long)(1000 * (3 * 60 + rand.NextDouble() * 7 * 60)); } }
/// <summary> /// Adds a text input to the GUI /// </summary> /// <param name="capi">The Client API</param> /// <param name="bounds">The bounds of the text input.</param> /// <param name="OnTextChanged">The event fired when the text is changed.</param> /// <param name="font">The font of the text.</param> public GuiElementTextInput(ICoreClientAPI capi, ElementBounds bounds, Common.Action <string> OnTextChanged, CairoFont font) : base(capi, font, bounds) { MouseOverCursor = "textselect"; this.OnTextChanged = OnTextChanged; highlightTexture = new LoadedTexture(capi); }
/// <summary> /// Adds multiple buttons with Text. /// </summary> /// <param name="texts">The texts on all the buttons.</param> /// <param name="font">The font for the buttons</param> /// <param name="onToggle">The event fired when the button is pressed.</param> /// <param name="bounds">The bounds of the buttons.</param> /// <param name="key">The key given to the bundle of buttons.</param> public static GuiComposer AddColorListPicker(this GuiComposer composer, int[] colors, Common.Action <int> onToggle, ElementBounds startBounds, int maxLineWidth, string key = null) { if (!composer.composed) { if (key == null) { key = "colorlistpicker"; } int quantityButtons = colors.Length; double lineWidth = 0; for (int i = 0; i < colors.Length; i++) { int index = i; if (lineWidth > maxLineWidth) { startBounds.fixedX -= lineWidth; startBounds.fixedY += startBounds.fixedHeight + 5; lineWidth = 0; } composer.AddInteractiveElement( new GuiElementColorListPicker(composer.Api, colors[i], (on) => { if (on) { onToggle(index); for (int j = 0; j < quantityButtons; j++) { if (j == index) { continue; } composer.GetColorListPicker(key + "-" + j).SetValue(false); } } else { composer.GetColorListPicker(key + "-" + index).SetValue(true); } }, startBounds.FlatCopy()), key + "-" + i ); startBounds.fixedX += startBounds.fixedWidth + 5; lineWidth += startBounds.fixedWidth + 5; } } return(composer); }
public void SetNewText(string vtmlCode, CairoFont baseFont, Common.Action <LinkTextComponent> didClickLink = null) { SetNewTextWithoutRecompose(vtmlCode, baseFont, didClickLink); RecomposeText(); }
public void FadeOut(float seconds, Common.Action <ILoadedSound> onFadedOut) { throw new NotImplementedException(); }
public void Anime(Common.Action action) { obj.GetComponent <Animator>().SetInteger("Move_Int", (int)action); }
public void Anime(int ID, Common.Action action) //ID:見えてるうち、後ろから何番目?、Commn.Action.Battleとかを入れたら遷移するようにする { Chara[ID].Anime().SetInteger("Move_Int", (int)action); }
public void FadeOut(float seconds, Common.Action onFadedOut = null) { throw new NotImplementedException(); }
static void Richtextify(ICoreClientAPI capi, VtmlToken token, ref List <RichTextComponentBase> elems, Stack <CairoFont> fontStack, Common.Action <LinkTextComponent> didClickLink) { if (token is VtmlTagToken) { VtmlTagToken tagToken = token as VtmlTagToken; switch (tagToken.Name) { case "br": elems.Add(new RichTextComponent(capi, "\r\n", fontStack.Peek())); break; case "i": CairoFont font = fontStack.Peek().Clone(); font.Slant = FontSlant.Italic; fontStack.Push(font); foreach (var val in tagToken.ChildElements) { Richtextify(capi, val, ref elems, fontStack, didClickLink); } fontStack.Pop(); break; case "a": LinkTextComponent cmp = new LinkTextComponent(capi, tagToken.ContentText, fontStack.Peek(), didClickLink); tagToken.Attributes.TryGetValue("href", out cmp.Href); elems.Add(cmp); break; case "icon": string iconName; tagToken.Attributes.TryGetValue("name", out iconName); IconComponent iconcmp = new IconComponent(capi, iconName, fontStack.Peek()); elems.Add(iconcmp); break; case "itemstack": string code; string type; float size = (float)fontStack.Peek().GetFontExtents().Height; EnumFloat floatType = EnumFloat.Inline; string floattypestr; if (tagToken.Attributes.TryGetValue("floattype", out floattypestr)) { if (!Enum.TryParse(floattypestr, out floatType)) { floatType = EnumFloat.Inline; } } tagToken.Attributes.TryGetValue("code", out code); if (!tagToken.Attributes.TryGetValue("type", out type)) { type = "block"; } ItemStack stack; if (type == "item") { stack = new ItemStack(capi.World.GetItem(new AssetLocation(code))); } else { stack = new ItemStack(capi.World.GetBlock(new AssetLocation(code))); } ItemstackComponentBase stckcmp = new SlideshowItemstackTextComponent(capi, new ItemStack[] { stack }, size / RuntimeEnv.GUIScale, floatType); elems.Add(stckcmp); break; case "font": fontStack.Push(getFont(tagToken, fontStack)); foreach (var val in tagToken.ChildElements) { Richtextify(capi, val, ref elems, fontStack, didClickLink); } fontStack.Pop(); break; case "clear": elems.Add(new ClearFloatTextComponent(capi)); break; case "strong": fontStack.Push(fontStack.Peek().Clone().WithWeight(Cairo.FontWeight.Bold)); foreach (var val in tagToken.ChildElements) { Richtextify(capi, val, ref elems, fontStack, didClickLink); } fontStack.Pop(); break; } if (tagToken.Name != null && TagConverters.ContainsKey(tagToken.Name)) { RichTextComponentBase elem = TagConverters[tagToken.Name](capi, tagToken, fontStack, didClickLink); if (elem != null) { elems.Add(elem); } } } else { VtmlTextToken textToken = token as VtmlTextToken; elems.Add(new RichTextComponent(capi, textToken.Text, fontStack.Peek())); } }
// Implement methods here as well public override bool DoAction(Common.Action action) { throw new NotImplementedException(); }
/// <summary> /// Flips through given array of grid recipes every second /// </summary> /// <param name="capi"></param> /// <param name="gridrecipes"></param> /// <param name="size"></param> /// <param name="floatType"></param> /// <param name="onStackClicked"></param> /// <param name="allStacks">If set, will resolve wildcards based on this list, otherwise will search all available blocks/items</param> public SlideshowGridRecipeTextComponent(ICoreClientAPI capi, GridRecipe[] gridrecipes, double size, EnumFloat floatType, Common.Action <ItemStack> onStackClicked = null, ItemStack[] allStacks = null) : base(capi) { this.onStackClicked = onStackClicked; this.Float = floatType; this.BoundsPerLine = new LineRectangled[] { new LineRectangled(0, 0, 3 * (size + 3), 3 * (size + 3)) }; //PaddingRight = 0; this.size = size; // Expand wild cards List <GridRecipe> resolvedGridRecipes = new List <GridRecipe>(); Queue <GridRecipe> halfResolvedRecipes = new Queue <GridRecipe>(gridrecipes); bool allResolved = false; while (!allResolved) { allResolved = true; int cnt = halfResolvedRecipes.Count; while (cnt-- > 0) { GridRecipe toTestRecipe = halfResolvedRecipes.Dequeue(); bool thisResolved = true; for (int j = 0; j < toTestRecipe.resolvedIngredients.Length; j++) { CraftingRecipeIngredient ingred = toTestRecipe.resolvedIngredients[j]; if (ingred != null && ingred.IsWildCard) { allResolved = false; thisResolved = false; ItemStack[] stacks = ResolveWildCard(capi.World, ingred, allStacks); if (stacks.Length == 0) { throw new ArgumentException("Attempted to resolve the recipe ingredient wildcard " + ingred.Type + " " + ingred.Code + " but there are no such items/blocks!"); } for (int k = 0; k < stacks.Length; k++) { GridRecipe cloned = toTestRecipe.Clone(); for (int m = 0; m < cloned.resolvedIngredients.Length; m++) { CraftingRecipeIngredient clonedingred = cloned.resolvedIngredients[m]; if (clonedingred != null && clonedingred.Code.Equals(ingred.Code)) { clonedingred.Code = stacks[k].Collectible.Code; clonedingred.IsWildCard = false; clonedingred.ResolvedItemstack = stacks[k]; } } halfResolvedRecipes.Enqueue(cloned); } break; } } if (thisResolved) { resolvedGridRecipes.Add(toTestRecipe); } } } resolveCache.Clear(); this.GridRecipes = resolvedGridRecipes.ToArray(); Random fixedRand = new Random(123); this.GridRecipes.Shuffle(fixedRand); for (int i = 0; i < GridRecipes.Length; i++) { string trait = GridRecipes[i].RequiresTrait; if (trait != null) { extraTexts[i] = capi.Gui.TextTexture.GenTextTexture(Lang.Get("* Requires {0} trait", trait), CairoFont.WhiteDetailText()); } } if (GridRecipes.Length == 0) { throw new ArgumentException("Could not resolve any of the supplied grid recipes?"); } }