Skip to content

Commit

Permalink
fix more itens
Browse files Browse the repository at this point in the history
  • Loading branch information
jeannsebold6666 committed Oct 13, 2024
1 parent 9ac9e0c commit 390dab1
Show file tree
Hide file tree
Showing 16 changed files with 131 additions and 134 deletions.
4 changes: 2 additions & 2 deletions src/ClassicUO.Client/Configuration/Profile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ public List<Gump> ReadGumps(World world, string path)
break;
case GumpType.GridContainer:
ushort ogContainer = ushort.Parse(xml.GetAttribute("ogContainer"));
gump = new GridContainer(serial, ogContainer);
gump = new GridContainer(world, serial, ogContainer);
if (((GridContainer)gump).IsPlayerBackpack)
{
x = ProfileManager.CurrentProfile.BackpackGridPosition.X;
Expand Down Expand Up @@ -1029,7 +1029,7 @@ public List<Gump> ReadGumps(World world, string path)
break;
case GumpType.GridContainer:
ushort ogContainer = ushort.Parse(xml.GetAttribute("ogContainer"));
gump = new GridContainer(serial, ogContainer);
gump = new GridContainer(world, serial, ogContainer);
break;
case GumpType.Journal:
gump = new ResizableJournal();
Expand Down
6 changes: 3 additions & 3 deletions src/ClassicUO.Client/Game/GameObjects/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ public enum HitsRequestStatus
Received
}

internal abstract class Entity : GameObject, IEquatable<Entity>
public abstract class Entity : GameObject, IEquatable<Entity>
{
private static readonly RenderedText[] _hitsPercText = new RenderedText[101];
private Direction _direction;


protected Entity(World world, uint serial) : base(world)
internal Entity(World world, uint serial) : base(world)
{
Serial = serial;
}
Expand Down Expand Up @@ -104,7 +104,7 @@ public Direction Direction

public bool Exists => World.Contains(Serial);

public RenderedText HitsTexture => _hitsPercText[HitsPercentage % _hitsPercText.Length];
internal RenderedText HitsTexture => _hitsPercText[HitsPercentage % _hitsPercText.Length];


public bool Equals(Entity e)
Expand Down
8 changes: 4 additions & 4 deletions src/ClassicUO.Client/Game/GameObjects/GameObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@

namespace ClassicUO.Game.GameObjects
{
internal class BaseGameObject : LinkedObject
public class BaseGameObject : LinkedObject
{
protected BaseGameObject(World world) => World = world;
internal BaseGameObject(World world) => World = world;

public Point RealScreenPosition;

public World World { get; set; }
internal World World { get; set; }
}

partial class GameObject : BaseGameObject
public partial class GameObject : BaseGameObject
{
internal GameObject(World world) : base(world) { }

Expand Down
2 changes: 1 addition & 1 deletion src/ClassicUO.Client/Game/GameObjects/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

namespace ClassicUO.Game.GameObjects
{
internal partial class Item : Entity
public partial class Item : Entity
{
//private static readonly QueuedPool<Item> _pool = new QueuedPool<Item>(
// Constants.PREDICTABLE_CHUNKS * 3,
Expand Down
18 changes: 9 additions & 9 deletions src/ClassicUO.Client/Game/GameObjects/Mobile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,22 @@

#endregion

using ClassicUO.Assets;
using System;
using ClassicUO.Configuration;
using ClassicUO.Game.Data;
using ClassicUO.Game.Managers;
using ClassicUO.Game.UI.Gumps;
using ClassicUO.Assets;
using ClassicUO.Resources;
using ClassicUO.Utility;
using ClassicUO.Utility.Collections;
using Microsoft.Xna.Framework;
using ClassicUO.Game.Scenes;
using System;

namespace ClassicUO.Game.GameObjects
{
internal partial class Mobile : Entity

public partial class Mobile : Entity

Check failure on line 48 in src/ClassicUO.Client/Game/GameObjects/Mobile.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Partial declarations of 'Mobile' have conflicting accessibility modifiers

Check failure on line 48 in src/ClassicUO.Client/Game/GameObjects/Mobile.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Partial declarations of 'Mobile' have conflicting accessibility modifiers

Check failure on line 48 in src/ClassicUO.Client/Game/GameObjects/Mobile.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Partial declarations of 'Mobile' have conflicting accessibility modifiers

Check failure on line 48 in src/ClassicUO.Client/Game/GameObjects/Mobile.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Partial declarations of 'Mobile' have conflicting accessibility modifiers
{
//private static readonly QueuedPool<Mobile> _pool = new QueuedPool<Mobile>(
// Constants.PREDICTABLE_CHUNKS,
Expand Down Expand Up @@ -144,7 +145,7 @@ internal Mobile(World world, uint serial) : base(world, serial)

internal Mobile(World world) : base(world, 0) { }

public Deque<Step> Steps { get; } = new Deque<Step>(Constants.MAX_STEP_COUNT);
internal Deque<Step> Steps { get; } = new Deque<Step>(Constants.MAX_STEP_COUNT);
public bool IsParalyzed => (Flags & Flags.Frozen) != 0;
public bool IsYellowHits => (Flags & Flags.YellowBar) != 0;
public bool IsPoisoned =>
Expand Down Expand Up @@ -429,7 +430,7 @@ public void SetIdleAnimation()
//);

AnimationGroupsType type = animations.GetAnimType(graphic);
AnimationFlags flags = animations.GetAnimFlags(graphic);
AnimationFlags flags = animations.GetAnimFlags(graphic);
AnimationGroups animGroup = AnimationGroups.None;

bool isLowExtended = false;
Expand Down Expand Up @@ -785,7 +786,7 @@ public void ProcessSteps(out byte dir, bool evalutate = false)
absX = X;
absY = Y;

Pathfinder.GetNewXY((byte)(step.Direction & 7), ref absX, ref absY);
Pathfinder.GetNewXY((byte)(step.Direction & 7), ref absX, ref absY);

badStep = absX != step.X || absY != step.Y;
}
Expand Down Expand Up @@ -953,7 +954,7 @@ public override void UpdateTextCoordsV()
return;
}

int offY = NameOverheadGump.CurrentHeight;
int offY = 0;

bool health = ProfileManager.CurrentProfile.ShowMobilesHP;
int alwaysHP = ProfileManager.CurrentProfile.MobileHPShowWhen;
Expand Down Expand Up @@ -1092,13 +1093,12 @@ public override void Destroy()
if (!(this is PlayerMobile))
{
UIManager.GetGump<PaperDollGump>(serial)?.Dispose();
UIManager.GetGump<ModernPaperdoll>(serial)?.Dispose();

//_pool.ReturnOne(this);
}
}

public struct Step
internal struct Step
{
public int X,
Y;
Expand Down
2 changes: 1 addition & 1 deletion src/ClassicUO.Client/Game/LinkedObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

namespace ClassicUO.Game
{
internal abstract class LinkedObject
public partial class LinkedObject
{
public bool IsEmpty => Items == null;
public LinkedObject Previous, Next, Items;
Expand Down
18 changes: 18 additions & 0 deletions src/ClassicUO.Client/Game/Managers/MacroManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1881,6 +1881,20 @@ public Macro(string name)
public bool Alt { get; set; }
public bool Ctrl { get; set; }
public bool Shift { get; set; }
public bool HideLabel { get; set; }

public ushort Hue = 0x00;
public ushort? Graphic = null;
private byte _scale = 100;
public byte Scale
{
get { return _scale; }
set
{
if (value <= 10) _scale = 10;
else _scale = value;
}
}

public bool Equals(Macro other)
{
Expand Down Expand Up @@ -1927,6 +1941,10 @@ public void Save(XmlTextWriter writer)
writer.WriteAttributeString("alt", Alt.ToString());
writer.WriteAttributeString("ctrl", Ctrl.ToString());
writer.WriteAttributeString("shift", Shift.ToString());
writer.WriteAttributeString("hidelabel", HideLabel.ToString());
writer.WriteAttributeString("hue", Hue.ToString());
writer.WriteAttributeString("graphic", Graphic.HasValue ? Graphic.ToString() : string.Empty);
writer.WriteAttributeString("scale", Scale.ToString());

writer.WriteStartElement("actions");

Expand Down
4 changes: 3 additions & 1 deletion src/ClassicUO.Client/Game/Managers/TargetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ internal enum CursorTarget
Grab,
SetGrabBag,
HueCommandTarget,
IgnorePlayerTarget
IgnorePlayerTarget,
MoveItemContainer,
Internal
}

internal class CursorType
Expand Down
111 changes: 60 additions & 51 deletions src/ClassicUO.Client/Game/Managers/ToolTipOverrideManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,22 @@

namespace ClassicUO.Game.Managers
{
[JsonSerializable(typeof(ToolTipOverrideData))]
public static class FileDialog
{
public static string OpenFileDialog(string filter)
{

return Path.Combine(ProfileManager.ProfilePath, "tooltip.json"); // Retorne o caminho do arquivo selecionado.
}

public static string SaveFileDialog(string filter)
{
// Implemente sua lógica de diálogo de salvamento aqui
// Retorne o caminho do arquivo ou uma string vazia se o usuário cancelar.
return Path.Combine(ProfileManager.ProfilePath, "tooltip.json"); // Exemplo fictício
}
}

internal class ToolTipOverrideData
{
public ToolTipOverrideData() { }
Expand Down Expand Up @@ -39,6 +54,7 @@ public ToolTipOverrideData(int index, string searchText, string formattedText, i
public TooltipLayers ItemLayer { get; set; }

public bool IsNew { get; set; } = false;
private static World _world;

public static ToolTipOverrideData Get(int index)
{
Expand Down Expand Up @@ -154,28 +170,22 @@ public static void ExportOverrideSettings()
{
Thread t = new Thread(() =>
{
System.Windows.Forms.SaveFileDialog saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
saveFileDialog1.Filter = "Json|*.json";
saveFileDialog1.Title = "Save tooltip override settings";
saveFileDialog1.ShowDialog();
string filePath = FileDialog.SaveFileDialog("Json|*.json");
string result = JsonSerializer.Serialize(allData);
// If the file name is not an empty string open it for saving.
if (saveFileDialog1.FileName != "")
if (!string.IsNullOrEmpty(filePath))
{
System.IO.FileStream fs =
(System.IO.FileStream)saveFileDialog1.OpenFile();
// NOTE that the FilterIndex property is one-based.
switch (saveFileDialog1.FilterIndex)
string result = JsonSerializer.Serialize(allData);
try
{
default:
byte[] data = Encoding.UTF8.GetBytes(result);
fs.Write(data, 0, data.Length);
break;
// Usando File.WriteAllText para simplificar a escrita do arquivo
File.WriteAllText(filePath, result, Encoding.UTF8);
}
catch (Exception e)
{
GameActions.Print(_world, e.Message);
GameActions.Print(_world, "Failed to save tooltip override settings.", 32);
}
fs.Close();
}
});
t.SetApartmentState(ApartmentState.STA);
Expand All @@ -189,46 +199,45 @@ public static void ImportOverrideSettings()
{
Thread t = new Thread(() =>
{
System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog();
openFileDialog.Filter = "Json|*.json";
openFileDialog.Title = "Import tooltip override settings";
openFileDialog.ShowDialog();
// If the file name is not an empty string open it for saving.
if (openFileDialog.FileName != "")
string filePath = FileDialog.OpenFileDialog("Json|*.json");
if (!string.IsNullOrEmpty(filePath) && File.Exists(filePath))
{
// NOTE that the FilterIndex property is one-based.
switch (openFileDialog.FilterIndex)
try
{
default:
try
{
string result = File.ReadAllText(openFileDialog.FileName);
ToolTipOverrideData[] imported = JsonSerializer.Deserialize<ToolTipOverrideData[]>(result);
foreach (ToolTipOverrideData importedData in imported)
//GameActions.Print(importedData.searchText);
new ToolTipOverrideData(ProfileManager.CurrentProfile.ToolTipOverride_SearchText.Count, importedData.searchText, importedData.FormattedText, importedData.Min1, importedData.Max1, importedData.Min2, importedData.Max2, (byte)importedData.ItemLayer).Save();
ToolTipOverideMenu.Reopen = true;
}
catch (System.Exception e)
{
GameActions.Print(e.Message);
GameActions.Print("It looks like there was an error trying to import your override settings.", 32);
}
break;
string result = File.ReadAllText(filePath);
ToolTipOverrideData[] imported = JsonSerializer.Deserialize<ToolTipOverrideData[]>(result);
foreach (ToolTipOverrideData importedData in imported)
{
new ToolTipOverrideData(ProfileManager.CurrentProfile.ToolTipOverride_SearchText.Count,
importedData.searchText,
importedData.FormattedText,
importedData.Min1,
importedData.Max1,
importedData.Min2,
importedData.Max2,
(byte)importedData.ItemLayer).Save();
}
ToolTipOverideMenu.Reopen = true;
}
catch (Exception e)
{
GameActions.Print(_world, e.Message);
GameActions.Print(_world, "It looks like there was an error trying to import your override settings.", 32);
}
}
else
{
GameActions.Print(_world, "File not found or selection was canceled.", 32);
}
});
t.SetApartmentState(ApartmentState.STA);
t.Start();
}
else
{
GameActions.Print("This feature is not currently supported on Unix.", 32);
GameActions.Print(_world, "This feature is not currently supported on Unix.", 32);
}
}

Expand All @@ -239,11 +248,11 @@ public static string ProcessTooltipText(uint serial, uint compareTo = uint.MinVa

if (compareTo != uint.MinValue)
{
itemPropertiesData = new ItemPropertiesData(World.Items.Get(serial), World.Items.Get(compareTo));
itemPropertiesData = new ItemPropertiesData(_world.Items.Get(serial), _world.Items.Get(compareTo));
}
else
{
itemPropertiesData = new ItemPropertiesData(World.Items.Get(serial));
itemPropertiesData = new ItemPropertiesData(_world.Items.Get(serial));
}

ToolTipOverrideData[] result = GetAllToolTipOverrides();
Expand Down
Loading

0 comments on commit 390dab1

Please sign in to comment.