Skip to content

Commit

Permalink
dust765_x_tazuo
Browse files Browse the repository at this point in the history
thanks to https://github.com/bittiez/ClassicUO for doing most work
TazUO on b7d63e1
  • Loading branch information
dust765 committed May 23, 2023
1 parent d17e877 commit a06fe4e
Show file tree
Hide file tree
Showing 48 changed files with 6,014 additions and 148 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,36 @@ This project is to address a problem constructed within the toxicity of this com

![dust765_logo](https://user-images.githubusercontent.com/77043734/209156140-14558d04-eaf9-42f0-9939-ddec9cf6c1ac.png)

# Featuring TazUO

check the great Github of [TazUO](https://github.com/bittiez/ClassicUO)

Join TazUO's discord for ideas/support/updates -> https://discord.gg/SqwtB5g95H

This version of CUO adds [grid containers](https://github.com/bittiez/ClassicUO/wiki/TazUO.Grid-Containers) to the regular CUO client

Searchable

Resizable

Scrollable

Can lock items in specific place

Quick preview for containers inside *if the client has already cached that bag*

Item scaling!

[Cool down bars](https://github.com/bittiez/ClassicUO/wiki/TazUO.Cooldown-bars)

[Follow mode improvements](https://github.com/bittiez/ClassicUO/wiki/TazUO.Follow-mode)

[Improved journal](https://github.com/bittiez/ClassicUO/wiki/TazUO.Journal)

[Nameplate healthbars](https://github.com/bittiez/ClassicUO/wiki/TazUO.Nameplate-Healthbars)

And others in the TazUO [wiki](https://github.com/bittiez/ClassicUO/wiki)

# contact and team info

Discord: dust765#2787
Expand Down
11 changes: 10 additions & 1 deletion src/ClassicUO.Assets/ArtLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ private bool LoadData(Span<uint> data, int g, out short width, out short height,
* into every pixel in 'data'. We must zero the buffer here since it is
* re-used. But we only have to zero out the (width * height) worth.
*/
data.Slice(0, (width * height)).Fill(0);
data.Slice(0, (width * height)).Fill(0);

ushort fixedGraphic = (ushort)(g - 0x4000);

Expand Down Expand Up @@ -301,6 +301,15 @@ public Texture2D GetStaticTexture(uint g, out Rectangle bounds)
{
g += 0x4000;

// ## BEGIN - END ## // TAZUO
Texture2D png = PNGLoader.LoadArtTexture(g);
if (png != null)
{
bounds = png.Bounds;
return png;
}
// ## BEGIN - END ## // TAZUO

ref var spriteInfo = ref _spriteInfos[g];

if (spriteInfo.Texture == null)
Expand Down
13 changes: 11 additions & 2 deletions src/ClassicUO.Assets/GumpsLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,15 @@ struct SpriteInfo

public Texture2D GetGumpTexture(uint g, out Rectangle bounds)
{
// ## BEGIN - END ## // TAZUO
Texture2D png = PNGLoader.LoadGumpTexture(g);
if (png != null)
{
bounds = png.Bounds;
return png;
}
// ## BEGIN - END ## // TAZUO

ref var spriteInfo = ref _spriteInfos[g];

if (spriteInfo.Texture == null)
Expand Down Expand Up @@ -261,12 +270,12 @@ private unsafe void AddSpriteToAtlas(TextureAtlas atlas, uint index)
if (buffer != null)
{
System.Buffers.ArrayPool<uint>.Shared.Return(buffer, true);
}
}
}
}



public bool PixelCheck(int index, int x, int y)
{
return _picker.Get((ulong) index, x, y);
Expand Down
149 changes: 149 additions & 0 deletions src/ClassicUO.Assets/PNGLoader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
using ClassicUO.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

namespace ClassicUO.Assets
{
public static class PNGLoader
{
private const string IMAGES_FOLDER = "ExternalImages", GUMP_EXTERNAL_FOLDER = "gumps", ART_EXTERNAL_FOLDER = "art";

private static string exePath;

private static uint[] gump_availableIDs;
private static Dictionary<uint, Texture2D> gump_textureCache = new Dictionary<uint, Texture2D>();

private static uint[] art_availableIDs;
private static Dictionary<uint, Texture2D> art_textureCache = new Dictionary<uint, Texture2D>();

public static GraphicsDevice GraphicsDevice { set; get; }

public static Texture2D GetImageTexture(string fullImagePath)
{
Texture2D texture = null;

if (GraphicsDevice != null && File.Exists(fullImagePath))
{
FileStream titleStream = File.OpenRead(fullImagePath);
texture = Texture2D.FromStream(GraphicsDevice, titleStream);
titleStream.Close();
Color[] buffer = new Color[texture.Width * texture.Height];
texture.GetData(buffer);
for (int i = 0; i < buffer.Length; i++)
buffer[i] = Color.FromNonPremultiplied(buffer[i].R, buffer[i].G, buffer[i].B, buffer[i].A);
texture.SetData(buffer);
}

return texture;
}

public static Texture2D LoadGumpTexture(uint graphic)
{
Texture2D texture;

if (gump_availableIDs == null)
return null;

int index = Array.IndexOf(gump_availableIDs, graphic);
if (index == -1) return null;

gump_textureCache.TryGetValue(graphic, out texture);

if (exePath != null && texture == null && GraphicsDevice != null)
{
string fullImagePath = Path.Combine(exePath, IMAGES_FOLDER, GUMP_EXTERNAL_FOLDER, ((int)graphic).ToString() + ".png");

if (File.Exists(fullImagePath))
{
FileStream titleStream = File.OpenRead(fullImagePath);
texture = Texture2D.FromStream(GraphicsDevice, titleStream);
titleStream.Close();
Color[] buffer = new Color[texture.Width * texture.Height];
texture.GetData(buffer);
for (int i = 0; i < buffer.Length; i++)
buffer[i] = Color.FromNonPremultiplied(buffer[i].R, buffer[i].G, buffer[i].B, buffer[i].A);
texture.SetData(buffer);

gump_textureCache.Add(graphic, texture);
}
}

return texture;
}

public static Texture2D LoadArtTexture(uint graphic)
{
Texture2D texture;

if (art_availableIDs == null)
return null;

int index = Array.IndexOf(art_availableIDs, graphic);
if (index == -1) return null;

art_textureCache.TryGetValue(graphic, out texture);

if (exePath != null && texture == null && GraphicsDevice != null)
{
string fullImagePath = Path.Combine(exePath, IMAGES_FOLDER, ART_EXTERNAL_FOLDER, ((int)graphic).ToString() + ".png");

if (File.Exists(fullImagePath))
{
FileStream titleStream = File.OpenRead(fullImagePath);
texture = Texture2D.FromStream(GraphicsDevice, titleStream);
titleStream.Close();
Color[] buffer = new Color[texture.Width * texture.Height];
texture.GetData(buffer);
for (int i = 0; i < buffer.Length; i++)
buffer[i] = Color.FromNonPremultiplied(buffer[i].R, buffer[i].G, buffer[i].B, buffer[i].A);
texture.SetData(buffer);

art_textureCache.Add(graphic, texture);
}
}

return texture;
}

public static Task Load()
{
return Task.Run
(() =>
{
string strExeFilePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
exePath = Path.GetDirectoryName(strExeFilePath);

string gumpPath = Path.Combine(exePath, IMAGES_FOLDER, GUMP_EXTERNAL_FOLDER);
if (Directory.Exists(gumpPath))
{
string[] files = Directory.GetFiles(gumpPath, "*.png", SearchOption.TopDirectoryOnly);
gump_availableIDs = new uint[files.Length];

for (int i = 0; i < files.Length; i++)
{
string fname = Path.GetFileName(files[i]);
uint.TryParse(fname.Substring(0, fname.Length - 4), out gump_availableIDs[i]);
}
}

string artPath = Path.Combine(exePath, IMAGES_FOLDER, ART_EXTERNAL_FOLDER);
if (Directory.Exists(artPath))
{
string[] files = Directory.GetFiles(artPath, "*.png", SearchOption.TopDirectoryOnly);
art_availableIDs = new uint[files.Length];

for (int i = 0; i < files.Length; i++)
{
string fname = Path.GetFileName(files[i]);
uint.TryParse(fname.Substring(0, fname.Length - 4), out art_availableIDs[i]);
}
}
});
}
}
}
11 changes: 9 additions & 2 deletions src/ClassicUO.Assets/UOFileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,17 @@ public static void Load(ClientVersion version, string basePath, bool useVerdata,
SpeechesLoader.Instance.Load(),
LightsLoader.Instance.Load(),
SoundsLoader.Instance.Load(),
MultiMapLoader.Instance.Load()
MultiMapLoader.Instance.Load(),
// ## BEGIN - END ## // TAZUO
PNGLoader.Load()
// ## BEGIN - END ## // TAZUO
};

if (!Task.WhenAll(tasks).Wait(TimeSpan.FromSeconds(10)))
// ## BEGIN - END ## // TAZUO
//if (!Task.WhenAll(tasks).Wait(TimeSpan.FromSeconds(10)))
// ## BEGIN - END ## // TAZUO
if (!Task.WhenAll(tasks).Wait(TimeSpan.FromSeconds(15)))
// ## BEGIN - END ## // TAZUO
{
Log.Panic("Loading files timeout.");
}
Expand Down
Loading

0 comments on commit a06fe4e

Please sign in to comment.