Skip to content

Commit

Permalink
Multiple journal support
Browse files Browse the repository at this point in the history
  • Loading branch information
bittiez committed Feb 1, 2024
1 parent ffb8d25 commit c877e3c
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 31 deletions.
5 changes: 2 additions & 3 deletions src/ClassicUO.Client/Configuration/Profile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -820,10 +820,9 @@ public List<Gump> ReadGumps(string path)
break;

case GumpType.Journal:
//gump = new JournalGump();
gump = new ResizableJournal();
x = ProfileManager.CurrentProfile.JournalPosition.X;
y = ProfileManager.CurrentProfile.JournalPosition.Y;
//x = ProfileManager.CurrentProfile.JournalPosition.X;
//y = ProfileManager.CurrentProfile.JournalPosition.Y;
break;

case GumpType.MacroButton:
Expand Down
29 changes: 3 additions & 26 deletions src/ClassicUO.Client/Game/GameActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

#endregion

using System;
using ClassicUO.Configuration;
using ClassicUO.Game.Data;
using ClassicUO.Game.GameObjects;
Expand All @@ -42,6 +41,7 @@
using ClassicUO.Resources;
using ClassicUO.Utility;
using Microsoft.Xna.Framework;
using System;
using static ClassicUO.Network.NetClient;

namespace ClassicUO.Game
Expand Down Expand Up @@ -147,30 +147,7 @@ public static void OpenStatusBar()

public static void OpenJournal()
{
ResizableJournal resizableJournal = UIManager.GetGump<ResizableJournal>();
if (resizableJournal == null)
UIManager.Add(new ResizableJournal());
else
{
resizableJournal.SetInScreen();
resizableJournal.BringOnTop();
}
//JournalGump journalGump = UIManager.GetGump<JournalGump>();

//if (journalGump == null)
//{
// UIManager.Add(new JournalGump { X = 64, Y = 64 });
//}
//else
//{
// journalGump.SetInScreen();
// journalGump.BringOnTop();

// if (journalGump.IsMinimized)
// {
// journalGump.IsMinimized = false;
// }
//}
UIManager.Add(new ResizableJournal());
}

public static void OpenSkills()
Expand Down Expand Up @@ -207,7 +184,7 @@ public static void OpenMiniMap()
public static void BandageSelf()
{
Item bandage = World.Player.FindBandage();
if(bandage != null)
if (bandage != null)
{
NetClient.Socket.Send_TargetSelectedObject(bandage.Serial, World.Player.Serial);
}
Expand Down
47 changes: 45 additions & 2 deletions src/ClassicUO.Client/Game/UI/Gumps/ResizableJournal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
using ClassicUO.Input;
using ClassicUO.Renderer;
using ClassicUO.Utility.Collections;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using Point = Microsoft.Xna.Framework.Point;

namespace ClassicUO.Game.UI.Gumps
{
Expand All @@ -19,7 +20,7 @@ internal class ResizableJournal : ResizableGump
public static bool ReloadTabs { get; set; } = false;

private static int BORDER_WIDTH = 4;
private static int MIN_WIDTH = (BORDER_WIDTH * 2) + (TAB_WIDTH * 4);
private static int MIN_WIDTH = (BORDER_WIDTH * 2) + (TAB_WIDTH * 4) + 20;
private const int MIN_HEIGHT = 100;
private const int SCROLL_BAR_WIDTH = 14;
#region TABS
Expand Down Expand Up @@ -316,6 +317,46 @@ public static void UpdateJournalOptions()
}
}

public override void Save(XmlTextWriter writer)
{
base.Save(writer);
writer.WriteAttributeString("rw", Width.ToString());
writer.WriteAttributeString("rh", Height.ToString());

int c = 0;
foreach (var tab in _tab)
{
if (tab.IsSelected)
{
writer.WriteAttributeString("tab", c.ToString());
break;
}
c++;
}
}

public override void Restore(XmlElement xml)
{
base.Restore(xml);

Point savedSize = new Microsoft.Xna.Framework.Point(Width, Height);

if (int.TryParse(xml.GetAttribute("rw"), out int width) && width > 0)
{
savedSize.X = width;
}
if (int.TryParse(xml.GetAttribute("rh"), out int height) && height > 0)
{
savedSize.Y = height;
}
if (int.TryParse(xml.GetAttribute("tab"), out int tab))
{
OnButtonClick(tab); //Simulate selecting a tab
}

ResizeWindow(savedSize);
}

protected override void OnMouseWheel(MouseEventType delta)
{
base.OnMouseWheel(delta);
Expand Down Expand Up @@ -385,6 +426,8 @@ public override void Update()
{
base.Update();

if (IsDisposed) { return; }

if (X != _lastX || Y != _lastY)
{
_lastX = X;
Expand Down

0 comments on commit c877e3c

Please sign in to comment.