mirror of
https://github.com/OMGeeky/ItemChecklist.git
synced 2025-12-28 07:18:02 +01:00
0.1.0.1: Announcement toggle.
This commit is contained in:
@@ -72,6 +72,7 @@
|
||||
<Compile Include="UICheckbox.cs" />
|
||||
<Compile Include="UIGrid.cs" />
|
||||
<Compile Include="UIHoverImageButton.cs" />
|
||||
<Compile Include="UIToggleHoverImageButton.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="build.txt" />
|
||||
|
||||
@@ -35,7 +35,10 @@ namespace ItemChecklist
|
||||
itemChecklistPlayer.foundItem[item.type] = true;
|
||||
//ItemChecklist.instance.ItemChecklistUI.UpdateCheckboxes();
|
||||
ItemChecklist.instance.ItemChecklistUI.UpdateNeeded();
|
||||
Main.NewText($"Congrats: You found your first {item.name}. Total Progress: {itemChecklistPlayer.totalItemsFound}/{itemChecklistPlayer.totalItemsToFind}");
|
||||
if (ItemChecklistUI.announce)
|
||||
{
|
||||
Main.NewText($"Congrats: You found your first {item.name}. Total Progress: {itemChecklistPlayer.totalItemsFound}/{itemChecklistPlayer.totalItemsToFind}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,16 @@ namespace ItemChecklist.UI
|
||||
class ItemChecklistUI : UIState
|
||||
{
|
||||
public UIHoverImageButton toggleButton;
|
||||
public UIToggleHoverImageButton muteButton;
|
||||
public UIPanel checklistPanel;
|
||||
//public UIList checklistList;
|
||||
public UIGrid checklistList;
|
||||
// private FieldInfo uilistinnerlist;
|
||||
// private FieldInfo uilistinnerlist;
|
||||
|
||||
float spacing = 8f;
|
||||
public static bool visible = false;
|
||||
public static bool showCompleted = true;
|
||||
public static bool announce = true;
|
||||
public static string hoverText = "";
|
||||
|
||||
ItemSlot[] itemSlots;
|
||||
@@ -32,7 +34,8 @@ namespace ItemChecklist.UI
|
||||
{
|
||||
// Is initialize called? (Yes it is called on reload) I want to reset nicely with new character or new loaded mods: visible = false;
|
||||
|
||||
// uilistinnerlist = typeof(UIList).GetField("_innerList", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
// uilistinnerlist = typeof(UIList).GetField("_innerList", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
announce = true;
|
||||
|
||||
checklistPanel = new UIPanel();
|
||||
checklistPanel.SetPadding(10);
|
||||
@@ -49,6 +52,12 @@ namespace ItemChecklist.UI
|
||||
//toggleButton.Top.Pixels = spacing;
|
||||
checklistPanel.Append(toggleButton);
|
||||
|
||||
muteButton = new UIToggleHoverImageButton(Main.itemTexture[ItemID.Megaphone], ItemChecklist.instance.GetTexture("closeButton"), "Toggle Messages", announce);
|
||||
muteButton.OnClick += ToggleMuteButtonClicked;
|
||||
muteButton.Left.Pixels = spacing * 2 + 28;
|
||||
muteButton.Top.Pixels = 4;
|
||||
checklistPanel.Append(muteButton);
|
||||
|
||||
checklistList = new UIGrid(5);
|
||||
checklistList.Top.Pixels = 32f + spacing;
|
||||
checklistList.Width.Set(-25f, 1f);
|
||||
@@ -86,6 +95,13 @@ namespace ItemChecklist.UI
|
||||
UpdateNeeded();
|
||||
}
|
||||
|
||||
private void ToggleMuteButtonClicked(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
Main.PlaySound(10, -1, -1, 1);
|
||||
announce = !announce;
|
||||
muteButton.SetEnabled(announce);
|
||||
}
|
||||
|
||||
private bool updateneeded;
|
||||
internal void UpdateNeeded()
|
||||
{
|
||||
@@ -131,13 +147,13 @@ namespace ItemChecklist.UI
|
||||
|
||||
checklistList._items.Add(box);
|
||||
checklistList._innerList.Append(box);
|
||||
// uilistinner.Append(box);
|
||||
// uilistinner.Append(box);
|
||||
}
|
||||
}
|
||||
}
|
||||
checklistList.UpdateOrder();
|
||||
checklistList._innerList.Recalculate();
|
||||
// uilistinner.Recalculate();
|
||||
// uilistinner.Recalculate();
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
|
||||
62
UIToggleHoverImageButton.cs
Normal file
62
UIToggleHoverImageButton.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria.UI;
|
||||
using ItemChecklist.UI;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Terraria;
|
||||
using Terraria.GameContent.UI.Elements;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIToggleHoverImageButton : UIImageButton
|
||||
{
|
||||
private Texture2D _texture;
|
||||
private Texture2D overlay;
|
||||
private float _visibilityActive = 1f;
|
||||
private float _visibilityInactive = 0.4f;
|
||||
bool enabled;
|
||||
internal string hoverText;
|
||||
|
||||
public UIToggleHoverImageButton(Texture2D texture, Texture2D overlay, string hoverText, bool enabled = false) : base(texture)
|
||||
{
|
||||
this._texture = texture;
|
||||
this.overlay = overlay;
|
||||
this.Width.Set((float)this._texture.Width, 0f);
|
||||
this.Height.Set((float)this._texture.Height, 0f);
|
||||
this.hoverText = hoverText;
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public void SetEnabled(bool enabled)
|
||||
{
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = base.GetDimensions();
|
||||
spriteBatch.Draw(this._texture, dimensions.Position(), Color.White * (base.IsMouseHovering ? this._visibilityActive : this._visibilityInactive));
|
||||
if (!enabled)
|
||||
{
|
||||
spriteBatch.Draw(this.overlay, dimensions.Position(), Color.White * (base.IsMouseHovering ? this._visibilityActive : this._visibilityInactive));
|
||||
}
|
||||
if (IsMouseHovering)
|
||||
{
|
||||
ItemChecklistUI.hoverText = hoverText;
|
||||
}
|
||||
}
|
||||
|
||||
public override void MouseOver(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOver(evt);
|
||||
Main.PlaySound(12, -1, -1, 1, 1f, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
author = jopojelly
|
||||
version = 0.1
|
||||
version = 0.1.0.1
|
||||
displayName = Item Checklist
|
||||
homepage = https://forums.terraria.org/index.php?threads/item-checklist-in-game-100-item-collection-checklist.52786/
|
||||
hideCode = false
|
||||
|
||||
BIN
closeButton.png
Normal file
BIN
closeButton.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
Reference in New Issue
Block a user