Skip to content

Commit

Permalink
Merge branch 'main' into feature/pets
Browse files Browse the repository at this point in the history
  • Loading branch information
JamzOJamz committed Jan 9, 2025
2 parents 61eff1b + f80518e commit 49f64ff
Show file tree
Hide file tree
Showing 49 changed files with 757 additions and 362 deletions.
Binary file modified Assets/Misc/MenuLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Misc/_Unused/MenuLogoAlt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Pokemon/Bulbasaur_Mini.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Pokemon/Bulbasaur_Mini_Highlighted.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Pokemon/Bulbasaur_Mini_S.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Pokemon/Butterfree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Pokemon/Butterfree_Mini.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Pokemon/Butterfree_Mini_S.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Pokemon/Butterfree_S.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Pokemon/Caterpie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Pokemon/Caterpie_Mini.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Pokemon/Caterpie_Mini_S.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Pokemon/Caterpie_S.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Pokemon/Eevee.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Pokemon/Eevee_Mini.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Pokemon/Eevee_Mini_S.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Pokemon/Eevee_S.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Pokemon/Ivysaur_Mini.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Pokemon/Ivysaur_Mini_S.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Pokemon/Ivysaur_S.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Pokemon/Kakuna.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Pokemon/Kakuna_Mini.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Pokemon/Kakuna_Mini_S.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Pokemon/Kakuna_S.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Pokemon/Metapod.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Pokemon/Metapod_Mini.png
Binary file modified Assets/Pokemon/Metapod_Mini_S.png
Binary file modified Assets/Pokemon/Metapod_S.png
Binary file modified Assets/Pokemon/Venusaur_Mini.png
Binary file modified Assets/Pokemon/Venusaur_Mini_S.png
Binary file modified Assets/Pokemon/Weedle_Mini.png
Binary file modified Assets/Pokemon/Weedle_Mini_S.png
240 changes: 240 additions & 0 deletions Content/GUI/MenuSocialWidget.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
using ReLogic.Graphics;
using Terramon.Helpers;
using Terraria.Audio;
using Terraria.GameContent;

namespace Terramon.Content.GUI;

internal sealed class MenuSocialWidget
{
private const string DiscordURL = "https://discord.gg/qDn5eW27c4"; // Terramon Mod, #rules-and-info
private const string DiscordInviteCode = "qDn5eW27c4";
private const string WikiURL = "https://terrariamods.wiki.gg/wiki/Terramon_Mod";
private const string YouTubeURL = "https://www.youtube.com/@TerramonMod";
private const string GitHubURL = "https://github.com/JamzOJamz/Terramon";

private static readonly Item FakeItem = new();
private static readonly bool[] LastHoveringInteractableText = new bool[4];
private static DateTime _lastDiscordClientCheck = DateTime.MinValue;
private const double DiscordClientCheckInterval = 5;
private static bool _isDiscordClientRunning;

public static void Setup()
{
On_Main.DrawVersionNumber += MainDrawVersionNumber_Detour;
}

private static void MainDrawVersionNumber_Detour(On_Main.orig_DrawVersionNumber orig, Color menucolor, float upbump)
{
orig(menucolor, upbump);

// Wait until the mod is loaded by TML
var mod = Terramon.Instance;
if (mod == null) return;

// Check if Discord client is open on the player's system every X seconds
if (DateTime.UtcNow - _lastDiscordClientCheck > TimeSpan.FromSeconds(DiscordClientCheckInterval))
{
_lastDiscordClientCheck = DateTime.UtcNow;
_isDiscordClientRunning = DiscordInviteBeamer.IsClientRunning();
}

var drawPos = new Vector2(15, 15);
if (Main.showFrameRate)
drawPos.Y += 22;
if (ModLoader.HasMod("TerrariaOverhaul"))
drawPos.Y = Main.screenHeight / 2f - 74;
DrawOutlinedStringOnMenu(Main.spriteBatch, FontAssets.MouseText.Value,
$"{mod.DisplayNameClean} v{mod.Version}", drawPos, Color.White, 0f, Vector2.Zero,
1.07f, SpriteEffects.None, 0f, alphaMult: 0.76f);

// Draw "Join the Discord community" text in blurple below the version number
const string discordText = "Discord Server";
var discordTextSize = FontAssets.MouseText.Value.MeasureString(discordText);
discordTextSize.Y *= 0.9f;
drawPos.Y += 30;
var hovered = Main.MouseScreen.Between(drawPos, drawPos + discordTextSize);
if (hovered)
{
Main.LocalPlayer.mouseInterface = true;
if (!LastHoveringInteractableText[0])
SoundEngine.PlaySound(SoundID.MenuTick);
if (_isDiscordClientRunning)
{
FakeItem.SetDefaults(0, true);
const string textValue = "[c/FFFFFF:Discord client detected \u2713]\n[c/BABAC6:Click to go directly to the server!]";
FakeItem.SetNameOverride(textValue);
FakeItem.type = ItemID.IronPickaxe;
FakeItem.scale = 0f;
FakeItem.value = -1;
Main.HoverItem = FakeItem;
Main.instance.MouseText("");
Main.mouseText = true;
}

if (Main.mouseLeft && Main.mouseLeftRelease)
{
SoundEngine.PlaySound(SoundID.MenuOpen);
Main.mouseLeftRelease = false;

if (_isDiscordClientRunning)
{
Task.Run(() => DiscordInviteBeamer.Send(DiscordInviteCode));
}
else
{
Utils.OpenToURL(DiscordURL);
}
}

LastHoveringInteractableText[0] = true;
}
else
{
LastHoveringInteractableText[0] = false;
}

DrawOutlinedStringOnMenu(Main.spriteBatch, FontAssets.MouseText.Value, discordText, drawPos,
hovered ? new Color(237, 246, 255) : new Color(173, 173, 198), 0f, Vector2.Zero, 1.02f, SpriteEffects.None,
0f, alphaMult: 0.76f);

// Draw Terramon Wiki link text
const string wikiText = "Terramon Wiki";
var wikiTextSize = FontAssets.MouseText.Value.MeasureString(wikiText);
wikiTextSize.Y *= 0.9f;
drawPos.Y += 28;
var hoveredWiki = Main.MouseScreen.Between(drawPos, drawPos + wikiTextSize);
if (hoveredWiki)
{
Main.LocalPlayer.mouseInterface = true;
if (!LastHoveringInteractableText[1])
SoundEngine.PlaySound(SoundID.MenuTick);

if (Main.mouseLeft && Main.mouseLeftRelease)
{
SoundEngine.PlaySound(SoundID.MenuOpen);
Main.mouseLeftRelease = false;

Utils.OpenToURL(WikiURL);
}

LastHoveringInteractableText[1] = true;
}
else
{
LastHoveringInteractableText[1] = false;
}

DrawOutlinedStringOnMenu(Main.spriteBatch, FontAssets.MouseText.Value, wikiText, drawPos,
hoveredWiki ? new Color(237, 246, 255) : new Color(173, 173, 198), 0f, Vector2.Zero, 1.02f,
SpriteEffects.None,
0f, alphaMult: 0.76f);

// Draw YouTube link text
const string youtubeText = "YouTube";
var youtubeTextSize = FontAssets.MouseText.Value.MeasureString(youtubeText);
youtubeTextSize.Y *= 0.9f;
drawPos.Y += 28;
var hoveredYoutube = Main.MouseScreen.Between(drawPos, drawPos + youtubeTextSize);
if (hoveredYoutube)
{
Main.LocalPlayer.mouseInterface = true;
if (!LastHoveringInteractableText[2])
SoundEngine.PlaySound(SoundID.MenuTick);

if (Main.mouseLeft && Main.mouseLeftRelease)
{
SoundEngine.PlaySound(SoundID.MenuOpen);
Main.mouseLeftRelease = false;

Utils.OpenToURL(YouTubeURL);
}

LastHoveringInteractableText[2] = true;
}
else
{
LastHoveringInteractableText[2] = false;
}

DrawOutlinedStringOnMenu(Main.spriteBatch, FontAssets.MouseText.Value, youtubeText, drawPos,
hoveredYoutube ? new Color(237, 246, 255) : new Color(173, 173, 198), 0f, Vector2.Zero, 1.02f,
SpriteEffects.None,
0f, alphaMult: 0.76f);

// Draw GitHub link text
const string githubText = "GitHub";
var githubTextSize = FontAssets.MouseText.Value.MeasureString(githubText);
githubTextSize.Y *= 0.9f;
drawPos.Y += 28;
var hoveredGithub = Main.MouseScreen.Between(drawPos, drawPos + githubTextSize);
if (hoveredGithub)
{
Main.LocalPlayer.mouseInterface = true;
if (!LastHoveringInteractableText[3])
SoundEngine.PlaySound(SoundID.MenuTick);

if (Main.mouseLeft && Main.mouseLeftRelease)
{
SoundEngine.PlaySound(SoundID.MenuOpen);
Main.mouseLeftRelease = false;

Utils.OpenToURL(GitHubURL);
}

LastHoveringInteractableText[3] = true;
}
else
{
LastHoveringInteractableText[3] = false;
}

DrawOutlinedStringOnMenu(Main.spriteBatch, FontAssets.MouseText.Value, githubText, drawPos,
hoveredGithub ? new Color(237, 246, 255) : new Color(173, 173, 198), 0f, Vector2.Zero, 1.02f,
SpriteEffects.None,
0f, alphaMult: 0.76f);
}

private static void DrawOutlinedStringOnMenu(SpriteBatch spriteBatch, DynamicSpriteFont font, string text,
Vector2 position, Color drawColor, float rotation, Vector2 origin, float scale, SpriteEffects effects,
float layerDepth, bool special = false, float alphaMult = 0.3f)
{
for (var i = 0; i < 5; i++)
{
var color = Color.Black;
if (i == 4)
{
color = drawColor;
if (special)
{
color.R = (byte)((255 + color.R) / 2);
color.G = (byte)((255 + color.R) / 2);
color.B = (byte)((255 + color.R) / 2);
}
}

color.A = (byte)(color.A * alphaMult);

var offX = 0;
var offY = 0;
switch (i)
{
case 0:
offX = -2;
break;
case 1:
offX = 2;
break;
case 2:
offY = -2;
break;
case 3:
offY = 2;
break;
}

spriteBatch.DrawString(font, text, position + new Vector2(offX, offY), color, rotation, origin, scale,
effects, layerDepth);
}
}
}
15 changes: 11 additions & 4 deletions Content/NPCs/NPCWalkingBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Terramon.Content.NPCs;
public sealed class NPCWalkingBehaviour : NPCAIComponent
{
private int _collideTimer;
public string AnimationType = "StraightForward";
public AnimType AnimationType = AnimType.StraightForward;
public bool IsClassic = true; //TODO: remove once all classic pokemon sprites are replaced with custom ones
public int StopFrequency = 225;
public float WalkSpeed = 1f;
Expand Down Expand Up @@ -139,19 +139,19 @@ public override void FindFrame(NPC npc, int frameHeight)

switch (AnimationType)
{
case "StraightForward": // Animates all frames in a sequential order
case AnimType.StraightForward: // Animates all frames in a sequential order
if (NPC.frameCounter < FrameTime * FrameCount)
NPC.frame.Y = (int)Math.Floor(NPC.frameCounter / FrameTime) * frameHeight;
else
NPC.frameCounter = 0;
break;
case "IdleForward": // Same as StraightForward, but skips the first frame (which is idle only)
case AnimType.IdleForward: // Same as StraightForward, but skips the first frame (which is idle only)
if (NPC.frameCounter < FrameTime * (FrameCount - 1))
NPC.frame.Y = ((int)Math.Floor(NPC.frameCounter / FrameTime) + 1) * frameHeight;
else
NPC.frameCounter = 0;
break;
case "Alternate": // Alternates between frame sequences
case AnimType.Alternate: // Alternates between frame sequences
var cycleLength = FrameCount + 1;
var alternateFrame = (int)(NPC.frameCounter / FrameTime) % cycleLength;
NPC.frame.Y = cycleLength switch
Expand Down Expand Up @@ -186,4 +186,11 @@ private enum ActionState
Idle,
Walking
}
public enum AnimType : byte
{
None,
StraightForward,
IdleForward,
Alternate
}
}
9 changes: 7 additions & 2 deletions Content/Pokemon/Butterfree.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
{
Transform:
{
DrawOffsetY: -2
Width: 30
Height: 32
}
WanderingHoverBehaviour:
{
FrameCount: 5
FrameTime: 4
}
WanderingHoverBehaviour: {}
SpawnController:
{
Stage: 3
Expand Down
12 changes: 10 additions & 2 deletions Content/Pokemon/Caterpie.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@
{
Transform:
{
DrawOffsetY: -2
Width: 32
Height: 26
}
WalkingBehaviour:
{
WalkSpeed: 0.7
FrameCount: 5
FrameTime: 7
AnimationType: IdleForward
IsClassic: false
}
WalkingBehaviour: {}
SpawnController:
{
Stage: 1
Expand Down
11 changes: 9 additions & 2 deletions Content/Pokemon/Eevee.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
{
Transform:
{
DrawOffsetY: -2
Width: 26
Height: 34
}
WalkingBehaviour:
{
FrameCount: 7
FrameTime: 8
AnimationType: IdleForward
IsClassic: false
}
WalkingBehaviour: {}
SpawnController:
{
Stage: 1
Expand Down
15 changes: 13 additions & 2 deletions Content/Pokemon/Kakuna.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,20 @@
{
Transform:
{
DrawOffsetY: -2
Width: 20
Height: 28
}
BounceBehaviour:
{
BounceMinRange: -2.5
BounceMaxRange: -1.75
BounceFrequency: 18
HorizontalSpeedMin: 0.7
HorizontalSpeedMax: 0.7
ChangeDirectionChance: 0.5
MaxJumpClearance: 1
FrameCount: 4
}
WalkingBehaviour: {}
SpawnController:
{
Stage: 2
Expand Down
15 changes: 13 additions & 2 deletions Content/Pokemon/Metapod.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,20 @@
{
Transform:
{
DrawOffsetY: -2
Width: 26
Height: 28
}
BounceBehaviour:
{
BounceMinRange: -2.5
BounceMaxRange: -1.75
BounceFrequency: 18
HorizontalSpeedMin: 0.7
HorizontalSpeedMax: 0.7
ChangeDirectionChance: 0.5
MaxJumpClearance: 1
FrameCount: 4
}
WalkingBehaviour: {}
SpawnController:
{
Stage: 2
Expand Down
Loading

0 comments on commit 49f64ff

Please sign in to comment.