first commit
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
#region License
|
||||
|
||||
// Copyright (C) 2020 Reetus
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using ClassicAssist.Data;
|
||||
using ClassicAssist.Shared;
|
||||
using ClassicAssist.UO.Network;
|
||||
using ClassicAssist.UO.Network.Packets;
|
||||
using ClassicAssist.UO.Objects.Gumps;
|
||||
|
||||
namespace ClassicAssist.UO.Data.Gumps
|
||||
{
|
||||
public class BoatGumpExtension : IExtension
|
||||
{
|
||||
public void Initialize()
|
||||
{
|
||||
IncomingPacketHandlers.JournalEntryAddedEvent += OnJournalEntryAddedEvent;
|
||||
}
|
||||
|
||||
private static void OnJournalEntryAddedEvent( JournalEntry je )
|
||||
{
|
||||
switch ( je.Cliloc )
|
||||
{
|
||||
/* You are now piloting this vessel. */
|
||||
case 1116727:
|
||||
new BoatMovementGump().SendGump();
|
||||
break;
|
||||
/* You are no longer piloting this vessel. */
|
||||
case 1149592:
|
||||
Shared.UO.Commands.CloseClientGump( typeof( BoatMovementGump ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class BoatMovementGump : Gump
|
||||
{
|
||||
private static BoatSpeed _lastSpeed = BoatSpeed.OneTile;
|
||||
|
||||
public BoatMovementGump() : base( 100, 100 )
|
||||
{
|
||||
Movable = true;
|
||||
Closable = true;
|
||||
Resizable = false;
|
||||
Disposable = false;
|
||||
AddPage( 0 );
|
||||
AddBackground( 0, 0, 150, 175, 9200 );
|
||||
AddButton( 0, 0, 4507, 4507, (int) Direction.Northwest + 1, GumpButtonType.Reply, 0 );
|
||||
AddButton( 50, 0, 4500, 4500, (int) Direction.North + 1, GumpButtonType.Reply, 0 );
|
||||
AddButton( 100, 0, 4501, 4501, (int) Direction.Northeast + 1, GumpButtonType.Reply, 0 );
|
||||
AddButton( 10, 50, 4506, 4506, (int) Direction.West + 1, GumpButtonType.Reply, 0 );
|
||||
AddButton( 90, 50, 4502, 4502, (int) Direction.East + 1, GumpButtonType.Reply, 0 );
|
||||
AddButton( 0, 100, 4505, 4505, (int) Direction.Southwest + 1, GumpButtonType.Reply, 0 );
|
||||
AddButton( 50, 100, 4504, 4504, (int) Direction.South + 1, GumpButtonType.Reply, 0 );
|
||||
AddButton( 100, 100, 4503, 4503, (int) Direction.Southeast + 1, GumpButtonType.Reply, 0 );
|
||||
AddRadio( 10, 150, 208, 209, _lastSpeed == BoatSpeed.Normal, 1 );
|
||||
AddLabel( 40, 150, 0, "Fast" );
|
||||
AddButton( 60, 60, 2151, 2151, 10, GumpButtonType.Reply, 0 );
|
||||
}
|
||||
|
||||
public override void OnResponse( int buttonID, int[] switches )
|
||||
{
|
||||
if ( buttonID == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BoatSpeed speed = BoatSpeed.OneTile;
|
||||
|
||||
if ( switches?.Any( e => e == 1 ) ?? false )
|
||||
{
|
||||
speed = BoatSpeed.Normal;
|
||||
}
|
||||
|
||||
_lastSpeed = speed;
|
||||
|
||||
if ( buttonID < 9 )
|
||||
{
|
||||
Engine.SendPacketToServer( new WheelBoatMoving( (Direction) buttonID - 1, speed ) );
|
||||
}
|
||||
|
||||
if ( buttonID == 10 )
|
||||
{
|
||||
Engine.SendPacketToServer( new WheelBoatMoving( Direction.North, BoatSpeed.Stop ) );
|
||||
}
|
||||
|
||||
new BoatMovementGump().SendGump();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
#region License
|
||||
|
||||
// Copyright (C) 2020 Reetus
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#endregion
|
||||
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
using ClassicAssist.Shared;
|
||||
using ClassicAssist.Helpers;
|
||||
using ClassicAssist.Misc;
|
||||
using ClassicAssist.UO.Network.PacketFilter;
|
||||
using ClassicAssist.UO.Objects.Gumps;
|
||||
|
||||
namespace ClassicAssist.UO.Gumps
|
||||
{
|
||||
public class ConfirmPromptGump : Gump
|
||||
{
|
||||
public ConfirmPromptGump( string message, bool closable = false ) : base( 500, 500 )
|
||||
{
|
||||
const int width = 300;
|
||||
const int height = 200;
|
||||
|
||||
SetCenterPosition( width, height );
|
||||
Closable = closable;
|
||||
Resizable = false;
|
||||
Disposable = false;
|
||||
Movable = true;
|
||||
AddPage( 0 );
|
||||
AddBackground( 0, 0, width, height, 9200 );
|
||||
AddHtml( 10, 10, width - 20, height - 50, message, true, true );
|
||||
AddButton( width - 140, height - 30, 247, 248, 1, GumpButtonType.Reply, 0 );
|
||||
AddButton( width - 70, height - 30, 241, 242, 2, GumpButtonType.Reply, 0 );
|
||||
}
|
||||
|
||||
public AutoResetEvent AutoResetEvent { get; set; } = new AutoResetEvent( false );
|
||||
|
||||
public bool Result { get; set; }
|
||||
|
||||
public override void OnResponse( int buttonID, int[] switches )
|
||||
{
|
||||
Result = buttonID == 1;
|
||||
AutoResetEvent.Set();
|
||||
}
|
||||
|
||||
public static bool ConfirmPrompt( string message, bool closable = false )
|
||||
{
|
||||
ConfirmPromptGump gump = new ConfirmPromptGump( message, closable );
|
||||
|
||||
PacketFilterInfo pfi = new PacketFilterInfo( 0xB1,
|
||||
new[] { PacketFilterConditions.UIntAtPositionCondition( gump.ID, 7 ) } );
|
||||
|
||||
Engine.AddSendPostFilter( pfi );
|
||||
|
||||
gump.SendGump();
|
||||
|
||||
gump.AutoResetEvent.WaitOne();
|
||||
|
||||
Engine.RemoveSendPostFilter( pfi );
|
||||
|
||||
return gump.Result;
|
||||
}
|
||||
|
||||
private static Point GetWindowSize()
|
||||
{
|
||||
if ( !NativeMethods.GetWindowRect( Engine.WindowHandle, out NativeMethods.RECT rect ) )
|
||||
{
|
||||
return Point.Empty;
|
||||
}
|
||||
|
||||
int windowWidth = rect.Right - rect.Left;
|
||||
int windowHeight = rect.Bottom - rect.Top;
|
||||
|
||||
return new Point( windowWidth, windowHeight );
|
||||
}
|
||||
|
||||
public static Point GetGameWindowCenter()
|
||||
{
|
||||
dynamic currentProfile =
|
||||
Reflection.GetTypePropertyValue<dynamic>( "ClassicUO.Configuration.ProfileManager", "Current", null );
|
||||
|
||||
if ( currentProfile == null )
|
||||
{
|
||||
return Point.Empty;
|
||||
}
|
||||
|
||||
dynamic gameWindowSize =
|
||||
Reflection.GetTypePropertyValue<dynamic>( currentProfile.GetType(), "GameWindowSize", currentProfile );
|
||||
dynamic gameWindowPosition = Reflection.GetTypePropertyValue<dynamic>( currentProfile.GetType(),
|
||||
"GameWindowPosition", currentProfile );
|
||||
|
||||
if ( gameWindowSize == null || gameWindowPosition == null )
|
||||
{
|
||||
return Point.Empty;
|
||||
}
|
||||
|
||||
return new Point( gameWindowPosition.X + ( gameWindowSize.X >> 1 ),
|
||||
gameWindowPosition.Y + ( gameWindowSize.Y >> 1 ) );
|
||||
}
|
||||
|
||||
private void SetCenterPosition( int width, int height )
|
||||
{
|
||||
Point gameCenterPosition = GetGameWindowCenter();
|
||||
|
||||
if ( gameCenterPosition == Point.Empty )
|
||||
{
|
||||
Point size = GetWindowSize();
|
||||
|
||||
X = ( size.X - ( width ) ) >> 1;
|
||||
Y = ( size.Y - ( height ) ) >> 1;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
X = gameCenterPosition.X - width / 2;
|
||||
Y = gameCenterPosition.Y - height / 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
#region License
|
||||
|
||||
// Copyright (C) 2020 Reetus
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using ClassicAssist.Shared;
|
||||
using ClassicAssist.Data;
|
||||
using ClassicAssist.Data.Macros;
|
||||
using ClassicAssist.UO.Objects.Gumps;
|
||||
|
||||
namespace ClassicAssist.UO.Gumps
|
||||
{
|
||||
public class MacrosGump : RepositionableGump
|
||||
{
|
||||
private static Timer _timer;
|
||||
private static string _lastList;
|
||||
private static int _serial = 0x0fe00000;
|
||||
|
||||
public MacrosGump( string html ) : base( 190, 180, _serial++, (uint) _serial++ )
|
||||
{
|
||||
GumpX = Options.CurrentOptions.MacrosGumpX;
|
||||
GumpY = Options.CurrentOptions.MacrosGumpY;
|
||||
|
||||
Movable = false;
|
||||
Closable = false;
|
||||
Resizable = false;
|
||||
Disposable = false;
|
||||
AddPage( 0 );
|
||||
AddBackground( 0, 0, 190, 180, 3500 );
|
||||
AddHtml( 20, 20, 150, 140, html, false, true );
|
||||
}
|
||||
|
||||
public static void ResendGump( bool force = false )
|
||||
{
|
||||
try
|
||||
{
|
||||
MacroManager _macroManager = MacroManager.GetInstance();
|
||||
|
||||
IEnumerable<MacroEntry> macro = _macroManager.Items.Where( e => e.IsRunning );
|
||||
|
||||
string html = string.Empty;
|
||||
|
||||
foreach ( MacroEntry entry in macro )
|
||||
{
|
||||
if ( entry.IsBackground )
|
||||
{
|
||||
html += $"<BASEFONT COLOR=#000000><I>{entry.Name}</I></BASEFONT>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
html += $"<BASEFONT COLOR=#000000>{entry.Name}</BASEFONT>\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ( html.Equals( _lastList ) && !force )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( Engine.Gumps.GetGumps( out Gump[] gumps ) )
|
||||
{
|
||||
foreach ( Gump macrosGump in gumps.Where( g => g is MacrosGump ) )
|
||||
{
|
||||
Shared.UO.Commands.CloseClientGump( macrosGump.ID );
|
||||
}
|
||||
}
|
||||
|
||||
MacrosGump gump = new MacrosGump( html );
|
||||
gump.SendGump();
|
||||
|
||||
_lastList = html;
|
||||
}
|
||||
catch ( InvalidOperationException e )
|
||||
{
|
||||
Console.WriteLine( e.ToString() );
|
||||
}
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
_timer = new Timer( o => ResendGump(), null, 1000, 250 );
|
||||
}
|
||||
|
||||
public override void SetPosition( int x, int y )
|
||||
{
|
||||
base.SetPosition( x, y );
|
||||
|
||||
Options.CurrentOptions.MacrosGumpX = x;
|
||||
Options.CurrentOptions.MacrosGumpY = y;
|
||||
|
||||
ResendGump( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#region License
|
||||
// Copyright (C) 2020 Reetus
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#endregion
|
||||
|
||||
using ClassicAssist.UO.Data;
|
||||
|
||||
namespace ClassicAssist.UO.Network.Packets
|
||||
{
|
||||
public class Pathfind : BasePacket
|
||||
{
|
||||
public Pathfind(int x, int y, int z)
|
||||
{
|
||||
_writer = new PacketWriter(7);
|
||||
_writer.Write((byte)0x38);
|
||||
_writer.Write((short)x);
|
||||
_writer.Write((short)y);
|
||||
_writer.Write((short)z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
#region License
|
||||
|
||||
// Copyright (C) 2020 Reetus
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#endregion
|
||||
|
||||
using System.Threading;
|
||||
using ClassicAssist.Shared;
|
||||
using ClassicAssist.UI.ViewModels;
|
||||
using ClassicAssist.UO.Objects.Gumps;
|
||||
|
||||
namespace ClassicAssist.UO.Gumps
|
||||
{
|
||||
public abstract class RepositionableGump : Gump
|
||||
{
|
||||
private const int REPOSITION_BUTTON_ID = 10;
|
||||
private readonly int _height;
|
||||
private readonly int _width;
|
||||
|
||||
protected RepositionableGump( int width, int height, int serial, uint gumpID ) : base( 0, 0, serial,
|
||||
gumpID )
|
||||
{
|
||||
_width = width;
|
||||
_height = height;
|
||||
}
|
||||
|
||||
public int GumpX { get; set; } = 100;
|
||||
public int GumpY { get; set; } = 100;
|
||||
|
||||
public override void SendGump()
|
||||
{
|
||||
X = GumpX;
|
||||
Y = GumpY;
|
||||
AddButton( _width - 15, 5, 0x82C, 0x82C, REPOSITION_BUTTON_ID, GumpButtonType.Reply, 0 );
|
||||
|
||||
base.SendGump();
|
||||
}
|
||||
|
||||
public override void OnResponse( int buttonID, int[] switches )
|
||||
{
|
||||
if ( buttonID == REPOSITION_BUTTON_ID )
|
||||
{
|
||||
Engine.Dispatcher.Invoke( () =>
|
||||
{
|
||||
Thread t = new Thread( () =>
|
||||
{
|
||||
SetPosition( GumpX, GumpY );
|
||||
RepositionableGumpViewModel vm = new RepositionableGumpViewModel( this, GumpX, GumpY );
|
||||
//TODO UI
|
||||
//RepositionableGumpWindow window = new RepositionableGumpWindow { DataContext = vm };
|
||||
//WindowInteropHelper helper = new WindowInteropHelper( window ) { Owner = Engine.WindowHandle };
|
||||
//window.ShowInTaskbar = false;
|
||||
//window.ShowDialog();
|
||||
} )
|
||||
{ IsBackground = true };
|
||||
|
||||
t.SetApartmentState( ApartmentState.STA );
|
||||
t.Start();
|
||||
} );
|
||||
}
|
||||
|
||||
base.OnResponse( buttonID, switches );
|
||||
}
|
||||
|
||||
public virtual void SetPosition( int x, int y )
|
||||
{
|
||||
GumpX = x;
|
||||
GumpY = y;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using ClassicAssist.Data;
|
||||
using ClassicAssist.Misc;
|
||||
using ClassicAssist.UO.Objects.Gumps;
|
||||
|
||||
namespace ClassicAssist.UO.Gumps
|
||||
{
|
||||
public sealed class UpdateMessageGump : Gump
|
||||
{
|
||||
private readonly Version _version;
|
||||
|
||||
public UpdateMessageGump( IntPtr hWnd, string message, Version version ) : base( 500, 250, -1 )
|
||||
{
|
||||
if ( NativeMethods.GetWindowRect( hWnd, out NativeMethods.RECT rect ) )
|
||||
{
|
||||
int windowWidth = rect.Right - rect.Left;
|
||||
int windowHeight = rect.Bottom - rect.Top;
|
||||
|
||||
X = ( windowWidth - 600 ) / 2;
|
||||
Y = ( windowHeight - 400 ) / 2;
|
||||
}
|
||||
|
||||
_version = version;
|
||||
Closable = true;
|
||||
Disposable = false;
|
||||
|
||||
AddPage( 0 );
|
||||
AddBackground( 0, 0, 500, 400, 9270 );
|
||||
AddHtml( 20, 20, 460, 330, message, true, true );
|
||||
AddButton( 420, 360, 247, 248, 0, GumpButtonType.Reply, 0 );
|
||||
}
|
||||
|
||||
public override void OnResponse( int buttonID, int[] switches )
|
||||
{
|
||||
AssistantOptions.UpdateGumpVersion = _version;
|
||||
base.OnResponse( buttonID, switches );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
using ClassicAssist.Shared;
|
||||
using ClassicAssist.Data;
|
||||
using ClassicAssist.Data.Macros.Commands;
|
||||
using ClassicAssist.UO.Gumps;
|
||||
using ClassicAssist.UO.Objects.Gumps;
|
||||
|
||||
namespace ClassicAssist.UO.Data.Gumps
|
||||
{
|
||||
public class WeaponAbilitiesGump : RepositionableGump
|
||||
{
|
||||
private readonly bool _primaryEnable;
|
||||
private readonly int _primaryId;
|
||||
private readonly bool _secondaryEnable;
|
||||
private readonly int _secondaryId;
|
||||
|
||||
public WeaponAbilitiesGump( int primaryId, bool primaryEnable, int secondaryId, bool secondaryEnable ) : base(
|
||||
90, 40, GumpSerial++, (uint) GumpSerial++ )
|
||||
{
|
||||
if ( Engine.Gumps.GetGumps( out Gump[] gumps ) )
|
||||
{
|
||||
foreach ( Gump gump in gumps )
|
||||
{
|
||||
if ( gump is WeaponAbilitiesGump )
|
||||
{
|
||||
Shared.UO.Commands.CloseClientGump( gump.ID );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GumpX = Options.CurrentOptions.AbilitiesGumpX;
|
||||
GumpY = Options.CurrentOptions.AbilitiesGumpY;
|
||||
|
||||
_primaryId = primaryId;
|
||||
_secondaryId = secondaryId;
|
||||
_primaryEnable = primaryEnable;
|
||||
_secondaryEnable = secondaryEnable;
|
||||
|
||||
Movable = false;
|
||||
Closable = false;
|
||||
AddPage( 0 );
|
||||
AddImage( 0, 0, 0x5200 + ( primaryId - 1 ), primaryEnable ? 37 : 0 );
|
||||
AddImage( 45, 0, 0x5200 + ( secondaryId - 1 ), secondaryEnable ? 37 : 0 );
|
||||
AddButton( 15, 15, 1209, 1210, 1, GumpButtonType.Reply, 0 );
|
||||
AddButton( 60, 15, 1209, 1210, 2, GumpButtonType.Reply, 0 );
|
||||
}
|
||||
|
||||
public static int GumpSerial { get; set; } = 0x0fff0000;
|
||||
|
||||
public override void OnResponse( int buttonID, int[] switches )
|
||||
{
|
||||
switch ( buttonID )
|
||||
{
|
||||
case 1:
|
||||
AbilitiesCommands.SetAbility( "primary" );
|
||||
break;
|
||||
case 2:
|
||||
AbilitiesCommands.SetAbility( "secondary" );
|
||||
break;
|
||||
}
|
||||
|
||||
base.OnResponse( buttonID, switches );
|
||||
}
|
||||
|
||||
private void ResendGump()
|
||||
{
|
||||
WeaponAbilitiesGump gump =
|
||||
new WeaponAbilitiesGump( _primaryId, _primaryEnable, _secondaryId, _secondaryEnable );
|
||||
gump.SendGump();
|
||||
}
|
||||
|
||||
public override void SetPosition( int x, int y )
|
||||
{
|
||||
base.SetPosition( x, y );
|
||||
|
||||
Options.CurrentOptions.AbilitiesGumpX = x;
|
||||
Options.CurrentOptions.AbilitiesGumpY = y;
|
||||
|
||||
ResendGump();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user