Skip to content

Commit

Permalink
Merge pull request #221 from bittiez/dev
Browse files Browse the repository at this point in the history
v3.21.4
  • Loading branch information
bittiez committed Feb 25, 2024
2 parents b92c111 + f07008a commit 7189a0a
Show file tree
Hide file tree
Showing 15 changed files with 112 additions and 122 deletions.
5 changes: 3 additions & 2 deletions src/ClassicUO.Assets/MultiMapLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,12 @@ public override Task Load()
{
_file = new UOFile(path, true);
}
var facetFiles = Directory.GetFiles(UOFileManager.BasePath, "*.mul", SearchOption.TopDirectoryOnly)
.Select(s => Regex.Match(s, "facet0.*\\.mul", RegexOptions.IgnoreCase))
.Where(s => s.Success)
.Select(s => Path.Combine(UOFileManager.BasePath, s.Value))
.OrderBy(s => s)
.ToArray();
_facets = new UOFileMul[facetFiles.Length];
Expand Down Expand Up @@ -152,7 +153,7 @@ int endy
while (_file.Position < _file.Length)
{
byte pic = _file.ReadByte();
byte size = (byte) (pic & 0x7F);
byte size = (byte)(pic & 0x7F);
bool colored = (pic & 0x80) != 0;

int currentHeight = y * pheight;
Expand Down
4 changes: 2 additions & 2 deletions src/ClassicUO.Client/ClassicUO.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<ApplicationIcon>cuoicon.ico</ApplicationIcon>
<AssemblyName>ClassicUO</AssemblyName>
<RootNamespace>ClassicUO</RootNamespace>
<AssemblyVersion>3.21.3</AssemblyVersion>
<FileVersion>3.21.3</FileVersion>
<AssemblyVersion>3.21.4</AssemblyVersion>
<FileVersion>3.21.4</FileVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
Expand Down
1 change: 0 additions & 1 deletion src/ClassicUO.Client/Configuration/Language.cs
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,6 @@ public class TazUO
public string PlayerOffsetY { get; set; } = "Player Offset Y";
public string UseLandTexturesWhereAvailable { get; set; } = "Use land textures where available(Experimental)";
public string SOSGumpID { get; set; } = "SOS Gump ID";
public string UseGumpClosingAnims { get; set; } = "Enable gump closing animation";
#endregion

#region Tooltips
Expand Down
8 changes: 5 additions & 3 deletions src/ClassicUO.Client/Game/GameObjects/Views/ItemView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ float depth
byte animIndex = (byte)AnimIndex;
ushort graphic = GetGraphicForAnimation();

Client.Game.Animations.ConvertBodyIfNeeded(ref graphic);
Client.Game.Animations.ConvertBodyIfNeeded(ref graphic, isCorpse: IsCorpse);
var animGroup = Client.Game.Animations.GetAnimType(graphic);
var animFlags = Client.Game.Animations.GetAnimFlags(graphic);
byte group = AnimationsLoader.Instance.GetDeathAction(
Expand Down Expand Up @@ -603,7 +603,7 @@ public override bool CheckMouseSelection()
continue;
}

Client.Game.Animations.ConvertBodyIfNeeded(ref graphic);
Client.Game.Animations.ConvertBodyIfNeeded(ref graphic, isCorpse: IsCorpse);
var animGroup = Client.Game.Animations.GetAnimType(graphic);
var animFlags = Client.Game.Animations.GetAnimFlags(graphic);
byte group = AnimationsLoader.Instance.GetDeathAction(
Expand All @@ -617,7 +617,9 @@ public override bool CheckMouseSelection()
group,
direction,
out _,
out var isUOP
out var isUOP,
false,
IsCorpse
);

if (frames.IsEmpty)
Expand Down
6 changes: 6 additions & 0 deletions src/ClassicUO.Client/Game/Managers/MacroManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ public void Save()

string path = Path.Combine(ProfileManager.ProfilePath, "macros.xml");

if (!File.Exists(path))
{
Directory.CreateDirectory(ProfileManager.ProfilePath);
File.Create(path).Close();
}

using (XmlTextWriter xml = new XmlTextWriter(path, Encoding.UTF8)
{
Formatting = Formatting.Indented,
Expand Down
22 changes: 11 additions & 11 deletions src/ClassicUO.Client/Game/Managers/NameOverHeadManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,24 @@

#endregion

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using ClassicUO.Configuration;
using ClassicUO.Game.Data;
using ClassicUO.Game.GameObjects;
using ClassicUO.Game.UI.Gumps;
using ClassicUO.Input;
using ClassicUO.Utility.Logging;
using SDL2;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;

namespace ClassicUO.Game.Managers
{
[Flags]
internal enum NameOverheadOptions
public enum NameOverheadOptions
{
None = 0,

Expand Down Expand Up @@ -84,7 +84,7 @@ internal enum NameOverheadOptions
MobilesAndCorpses = AllMobiles | MonsterCorpses | HumanoidCorpses,
}

internal static class NameOverHeadManager
public static class NameOverHeadManager
{
private static NameOverHeadHandlerGump _gump;
private static SDL.SDL_Keycode _lastKeySym = SDL.SDL_Keycode.SDLK_UNKNOWN;
Expand Down Expand Up @@ -132,7 +132,7 @@ private static bool HandleMobileOverhead(Entity serial)
if (mobile == null)
return false;

if(mobile.Equals(World.Player) && ActiveOverheadOptions.HasFlag(NameOverheadOptions.ExcludeSelf))
if (mobile.Equals(World.Player) && ActiveOverheadOptions.HasFlag(NameOverheadOptions.ExcludeSelf))
return false;

// Mobile types
Expand Down Expand Up @@ -167,7 +167,7 @@ private static bool HandleMobileOverhead(Entity serial)
if (ActiveOverheadOptions.HasFlag(NameOverheadOptions.Invulnerable) && mobile.NotorietyFlag == NotorietyFlag.Invulnerable)
return true;

if(ActiveOverheadOptions.HasFlag(NameOverheadOptions.Self) && mobile.Equals(World.Player))
if (ActiveOverheadOptions.HasFlag(NameOverheadOptions.Self) && mobile.Equals(World.Player))
return true;

return false;
Expand Down Expand Up @@ -407,7 +407,7 @@ public static void SetActiveOption(NameOverheadOption option)
}
}

internal class NameOverheadOption
public class NameOverheadOption
{
public NameOverheadOption(string name, SDL.SDL_Keycode key, bool alt, bool ctrl, bool shift, int optionflagscode) : this(name)
{
Expand Down
8 changes: 4 additions & 4 deletions src/ClassicUO.Client/Game/Scenes/GameSceneDrawingSorting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -400,16 +400,16 @@ private void UpdateObjectHandles(Entity obj, bool useObjectHandles)
allowSelection = false;
return true;
}
if (itemData.IsRoof && _noDrawRoofs)
{
return false;
}
if (itemData.IsDoor || itemData.IsRoof)
{
obj.AlphaHue = 65;
allowSelection = itemData.IsDoor;
return true;
}
if (itemData.IsRoof && _noDrawRoofs)
{
return false;
}
if (itemData.IsFoliage || obj.Graphic == Constants.TREE_REPLACE_GRAPHIC || StaticFilters.IsTree(obj.Graphic, out var _) || (!itemData.IsMultiMovable && obj is Static stat && stat.IsVegetation) || (!itemData.IsMultiMovable && obj is Multi multi && multi.IsVegetation))
{
obj.AlphaHue = 65;
Expand Down
62 changes: 0 additions & 62 deletions src/ClassicUO.Client/Game/UI/Controls/Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

#endregion

using ClassicUO.Configuration;
using ClassicUO.Game.Managers;
using ClassicUO.Input;
using ClassicUO.Renderer;
Expand All @@ -56,8 +55,6 @@ public abstract class Control
private bool _handlesKeyboardFocus;
private Point _offset;
private Control _parent;
private uint timetoclose = uint.MaxValue;
private bool delayedDispose = false;
private float alpha = 1.0f;

protected Control(Control parent = null)
Expand Down Expand Up @@ -289,56 +286,6 @@ public virtual bool Draw(UltimaBatcher2D batcher, int x, int y)
return false;
}

if (delayedDispose)
{

if (timetoclose == uint.MaxValue)
{
timetoclose = Time.Ticks + 150;
}

if (Time.Ticks >= timetoclose)
{
Dispose();
return false;
}

float prog = (float)(Time.Ticks - timetoclose + 151) / 150;
prog = Math.Max(0, Math.Min(1, prog)); // Ensure prog is within [0, 1]

int offset = (int)(((float)Math.Min(Width, Height) * prog) / 2f);

if (offset >= Width - (offset * 2) || offset >= Height - (offset * 2))
{
Dispose();
return false;
}

batcher.ClipBegin(x + offset, y + offset, Width - (offset * 2), Height - (offset * 2));

for (int i = 0; i < Children.Count; i++)
{
if (Children.Count <= i)
{
break;
}
Control c = Children.ElementAt(i);

if (c != null && (c.Page == 0 || c.Page == ActivePage))
{
if (c.IsVisible)
{
c.Draw(batcher, c.X + x, c.Y + y);
}
}
}

DrawDebug(batcher, x, y);

batcher.ClipEnd();
return true;
}

for (int i = 0; i < Children.Count; i++)
{
if (Children.Count <= i)
Expand Down Expand Up @@ -1060,15 +1007,6 @@ public virtual void Dispose()
return;
}

if (this is Gumps.Gump)
{
if (!delayedDispose && !IsFromServer && World.InGame && Parent == null && ProfileManager.CurrentProfile != null && ProfileManager.CurrentProfile.EnableGumpCloseAnimation)
{
delayedDispose = true;
return;
}
}

if (Children != null)
{
foreach (Control c in Children)
Expand Down
59 changes: 48 additions & 11 deletions src/ClassicUO.Client/Game/UI/Controls/TextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
using ClassicUO.Renderer;
using FontStashSharp.RichText;
using Microsoft.Xna.Framework;
using System;
using System.Text.RegularExpressions;

namespace ClassicUO.Game.UI.Controls
Expand All @@ -55,7 +54,7 @@ private int getStrokeSize
{
if (ProfileManager.CurrentProfile != null)
return ProfileManager.CurrentProfile.TextBorderSize;
return 2;
return 1;
}
}

Expand All @@ -70,8 +69,9 @@ public TextBox
bool strokeEffect = true,
bool supportsCommands = true,
bool ignoreColorCommands = false,
bool calculateGlyphs = false
) : this(text, font, size, width, ConvertHueToColor(hue), align, strokeEffect, supportsCommands, ignoreColorCommands, calculateGlyphs) { }
bool calculateGlyphs = false,
bool converthtmlcolors = true
) : this(text, font, size, width, ConvertHueToColor(hue), align, strokeEffect, supportsCommands, ignoreColorCommands, calculateGlyphs, converthtmlcolors) { }

public TextBox
(
Expand All @@ -84,11 +84,19 @@ public TextBox
bool strokeEffect = true,
bool supportsCommands = true,
bool ignoreColorCommands = false,
bool calculateGlyphs = false
bool calculateGlyphs = false,
bool converthtmlcolors = true
)
{
if (strokeEffect)
{
text = $"/es[{getStrokeSize}]" + text;
}

if (converthtmlcolors)
{
text = ConvertHTMLColorsToFSS(text);
}

_rtl = new RichTextLayout
{
Expand All @@ -106,7 +114,7 @@ public TextBox
_color = color;

_align = align;

ConvertHtmlColors = converthtmlcolors;
AcceptMouseInput = true;
Width = _rtl.Width == null ? _rtl.Size.X : (int)_rtl.Width;
base.Height = _rtl.Size.Y;
Expand Down Expand Up @@ -169,7 +177,15 @@ public string Text
{
if (_rtl.Text != value)
{
_rtl.Text = value;
if (ConvertHtmlColors)
{
_rtl.Text = ConvertHTMLColorsToFSS(value);
}
else
{
_rtl.Text = value;
}

_dirty = true;
}
}
Expand Down Expand Up @@ -222,13 +238,20 @@ public float Size
}
}

public bool ConvertHtmlColors { get; set; }

/// <summary>
/// Update the text of the TextBox
/// </summary>
/// <param name="text">New string</param>
/// <param name="width">Set to null to ignore width, taking as much width as needed.</param>
public void UpdateText(string text, int? width = null)
public void UpdateText(string text, int? width = null, bool converthtmlcolors = true)
{
if (converthtmlcolors)
{
text = ConvertHTMLColorsToFSS(text);
}

if (width != null && width > 0)
{
_rtl = new RichTextLayout
Expand All @@ -249,16 +272,30 @@ public void UpdateText(string text, int? width = null)
}
}

public static string ConvertHtmlToFontStashSharpCommand(string text)
public static string ConvertHTMLColorsToFSS(string text)
{
string finalString;

if (String.IsNullOrEmpty(text))
if (string.IsNullOrEmpty(text))
return "";

finalString = Regex.Replace(text, "<basefont color=\"?'?(?<color>.*?)\"?'?>", " /c[${color}]", RegexOptions.Multiline | RegexOptions.IgnoreCase);
finalString = Regex.Replace(finalString, "<Bodytextcolor\"?'?(?<color>.*?)\"?'?>", " /c[${color}]", RegexOptions.Multiline | RegexOptions.IgnoreCase);
finalString = finalString.Replace("</basefont>", "/cd").Replace("</BASEFONT>", "/cd").Replace("<br>", "\n").Replace("<BR>", "\n").Replace("\n", "\n/cd");
finalString = finalString.Replace("</basefont>", "/cd").Replace("</BASEFONT>", "/cd").Replace("\n", "\n/cd");

return finalString;
}

public static string ConvertHtmlToFontStashSharpCommand(string text)
{
string finalString;

if (string.IsNullOrEmpty(text))
return "";

finalString = ConvertHTMLColorsToFSS(text);

finalString = finalString.Replace("<br>", "\n").Replace("<BR>", "\n");
finalString = finalString.Replace("<left>", "").Replace("</left>", "");
finalString = finalString.Replace("<b>", "").Replace("</b>", "");
finalString = finalString.Replace("</font>", "").Replace("<h2>", "");
Expand Down

0 comments on commit 7189a0a

Please sign in to comment.