first commit

This commit is contained in:
Beyhan Oğur
2026-09-03 04:45:36 +03:00
commit d5f52cc3d3
1038 changed files with 169579 additions and 0 deletions
@@ -0,0 +1,141 @@
#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.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Input;
using ClassicAssist.Data.Autoloot;
using ClassicAssist.Shared.Resources;
using ClassicAssist.Shared.UO;
using ClassicAssist.UI.ViewModels;
using ClassicAssist.UO.Network.Packets;
using ClassicAssist.UO.Objects;
namespace ClassicAssist.Shared.UI.ViewModels.Debug
{
public class DebugAutolootViewModel : BaseViewModel
{
private ICommand _clearResultsCommand;
private int _containerSerial;
private ICommand _retestContainerCommand;
private ICommand _testContainerCommand;
private string _testResults;
public ICommand ClearResultsCommand =>
_clearResultsCommand ?? ( _clearResultsCommand = new RelayCommand( ClearResults, o => true ) );
public int ContainerSerial
{
get => _containerSerial;
set => SetProperty( ref _containerSerial, value );
}
public ICommand RetestContainerCommand =>
_retestContainerCommand ?? ( _retestContainerCommand = new RelayCommand( RetestContainer, o => true ) );
public ICommand TestContainerCommand =>
_testContainerCommand ?? ( _testContainerCommand = new RelayCommandAsync( TestContainerAsync, o => true ) );
public string TestResults
{
get => _testResults;
set => SetProperty( ref _testResults, value );
}
private void ClearResults( object obj )
{
TestResults = string.Empty;
}
private void RetestContainer( object obj )
{
TestContainer( ContainerSerial );
}
private async Task TestContainerAsync( object arg )
{
int serial = await Commands.GetTargeSerialAsync( "Choose container...", 60000 );
if ( serial == 0 )
{
Commands.SystemMessage( Strings.Invalid_container___ );
}
ContainerSerial = serial;
TestContainer( serial );
}
private void TestContainer( int serial )
{
Item[] items = Engine.Items.GetItem( serial )?.Container?.GetItems();
if ( items == null )
{
TestResults += $"{Strings.Cannot_find_container___}\n";
Commands.SystemMessage( Strings.Cannot_find_container___ );
return;
}
Engine.SendPacketToServer( new BatchQueryProperties( items.Select( i => i.Serial ).ToArray() ) );
foreach ( AutolootEntry entry in AutolootManager.GetInstance().GetEntries() )
{
if ( !entry.Enabled )
{
TestResults += $"Entry {entry.Name} disabled...\n";
continue;
}
TestResults += $"Entry {entry.Name}...\n\n";
IEnumerable<Item> matchItems = AutolootHelpers.AutolootFilter( items, entry );
if ( matchItems == null )
{
TestResults += "No items matched...\n";
continue;
}
int count = 0;
foreach ( Item matchItem in matchItems )
{
count++;
TestResults += matchItem.ToString();
if ( matchItem.Properties != null )
{
TestResults += "\nProperties...\n\n";
foreach ( Property property in matchItem.Properties )
{
TestResults += $"{property.Text}\n";
}
}
TestResults += "\n";
}
TestResults += $"{count} matches...\n\n";
}
}
}
}
@@ -0,0 +1,56 @@
using System.Collections.ObjectModel;
using ClassicAssist.Data.BuffIcons;
using ClassicAssist.UI.ViewModels;
using ClassicAssist.UO.Network;
using Microsoft.Scripting.Utils;
namespace ClassicAssist.Shared.UI.ViewModels.Debug
{
public class DebugBuffIconsViewModel : BaseViewModel
{
private readonly BuffIconManager _manager;
private ObservableCollection<string> _items = new ObservableCollection<string>();
private ObservableCollection<string> _messages = new ObservableCollection<string>();
private string _selectedItem;
public DebugBuffIconsViewModel()
{
_manager = BuffIconManager.GetInstance();
Items.AddRange( _manager.GetEnabledNames() );
IncomingPacketHandlers.BufficonEnabledDisabledEvent += OnBufficonEnabledDisabledEvent;
}
public ObservableCollection<string> Items
{
get => _items;
set => SetProperty( ref _items, value );
}
public ObservableCollection<string> Messages
{
get => _messages;
set => SetProperty( ref _messages, value );
}
public string SelectedItem
{
get => _selectedItem;
set => SetProperty( ref _selectedItem, value );
}
private void OnBufficonEnabledDisabledEvent( int type, bool enabled, int duration )
{
BuffIconData data = _manager.GetDataByID( type );
_dispatcher.Invoke( () =>
{
Messages.Add( enabled ? $"Enabled: {data.Name}" : $"Disabled: {data?.Name}" );
Items.Clear();
Items.AddRange( _manager.GetEnabledNames() );
} );
}
}
}
@@ -0,0 +1,96 @@
using System.Collections.ObjectModel;
using System.Text;
using ClassicAssist.UI.ViewModels;
using ClassicAssist.UO.Network;
using ClassicAssist.UO.Objects.Gumps;
namespace ClassicAssist.Shared.UI.ViewModels.Debug
{
public class DebugGumpViewModel : BaseViewModel
{
private ObservableCollection<Gump> _items = new ObservableCollection<Gump>();
private Gump _selectedItem;
private string _text;
public DebugGumpViewModel()
{
if ( Engine.Gumps.GetGumps( out Gump[] gumps ) )
{
foreach ( Gump gump in gumps )
{
Items.Add( gump );
}
}
IncomingPacketHandlers.GumpEvent += ( id, serial, gump ) => _dispatcher.Invoke( () =>
{
if ( Items.Contains( gump ) )
{
UpdateText( gump );
}
else
{
Items.Add( gump );
}
} );
OutgoingPacketHandlers.GumpEvent +=
( id, serial, gump ) => _dispatcher.Invoke( () => Items.Remove( gump ) );
}
public ObservableCollection<Gump> Items
{
get => _items;
set => SetProperty( ref _items, value );
}
public Gump SelectedItem
{
get => _selectedItem;
set
{
SetProperty( ref _selectedItem, value );
UpdateText( value );
}
}
public string Text
{
get => _text;
set => SetProperty( ref _text, value );
}
private void UpdateText( Gump value )
{
if ( value == null )
{
return;
}
StringBuilder sb = new StringBuilder();
sb.AppendLine( $"Gump ID: 0x{value.ID:x8}" );
sb.AppendLine( $"Serial: 0x{value.Serial:x8}" );
sb.AppendLine( $"Pages: {value.Pages?.Length}" );
sb.AppendLine();
sb.AppendLine(
$"Layout: ({value.Layout?.Length})\r\n\r\n{string.Join( "}\r\n", value.Layout?.Split( '}' ) ?? new string[0] )}" );
sb.AppendLine();
sb.AppendLine( $"Text: ({value.Strings.Length})\r\n\r\n{string.Join( "\r\n", value.Strings )}" );
sb.AppendLine();
sb.AppendLine( $"Elements ({value.GumpElements?.Length}):" );
sb.AppendLine();
if ( value.GumpElements != null )
{
foreach ( GumpElement element in value.GumpElements )
{
sb.AppendLine(
$"X: {element.X}, Y: {element.Y}, Type: {element.Type}, Cliloc: {element.Cliloc}, Text: {element.Text}" );
}
}
Text = sb.ToString();
}
}
}
@@ -0,0 +1,68 @@
using System.Collections.ObjectModel;
using System.Text;
using System.Windows.Input;
using ClassicAssist.Data;
using ClassicAssist.UI.ViewModels;
using ClassicAssist.UO.Network;
namespace ClassicAssist.Shared.UI.ViewModels.Debug
{
public class DebugJournalViewModel : BaseViewModel
{
private ICommand _clearCommand;
private ObservableCollection<string> _items = new ObservableCollection<string>();
private string _selectedItem;
public DebugJournalViewModel()
{
JournalEntry[] buffer = Engine.Journal.GetBuffer();
foreach ( JournalEntry journalEntry in buffer )
{
Items.Add( GetString( journalEntry ) );
}
IncomingPacketHandlers.JournalEntryAddedEvent += OnJournalEntryAddedEvent;
}
public ICommand ClearCommand => _clearCommand ?? ( _clearCommand = new RelayCommand( Clear, o => true ) );
public ObservableCollection<string> Items
{
get => _items;
set => SetProperty( ref _items, value );
}
public string SelectedItem
{
get => _selectedItem;
set => SetProperty( ref _selectedItem, value );
}
private void Clear( object obj )
{
Items.Clear();
}
private static string GetString( JournalEntry journalEntry )
{
StringBuilder sb = new StringBuilder();
sb.AppendLine( $"Name: {journalEntry.Name}" );
sb.AppendLine( $"Serial: 0x{journalEntry.Serial:x8}" );
sb.AppendLine( $"ID: 0x{journalEntry.ID:x4}" );
sb.AppendLine( $"Cliloc: {journalEntry.Cliloc}" );
sb.AppendLine( $"Text: {journalEntry.Text}" );
sb.AppendLine( $"Arguments: {string.Join( ",", journalEntry.Arguments ?? new string[0] )}" );
sb.AppendLine( $"Language: {journalEntry.SpeechLanguage}" );
sb.AppendLine( $"Type: {journalEntry.SpeechType}" );
return sb.ToString();
}
private void OnJournalEntryAddedEvent( JournalEntry je )
{
_dispatcher.Invoke( () => { Items.Add( GetString( je ) ); } );
}
}
}
@@ -0,0 +1,117 @@
#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.Collections.ObjectModel;
using System.Text;
using ClassicAssist.UI.ViewModels;
using ClassicAssist.UO.Objects;
namespace ClassicAssist.Shared.UI.ViewModels.Debug
{
public class DebugMenusViewModel : BaseViewModel
{
private ObservableCollection<Menu> _items = new ObservableCollection<Menu>();
private Menu _selectedItem;
private string _text;
public DebugMenusViewModel()
{
if ( Engine.Menus.GetMenus( out Menu[] menus ) )
{
foreach ( Menu menu in menus )
{
Items.Add( menu );
}
}
Engine.Menus.CollectionChangedEvent += OnCollectionChangedEvent;
}
public ObservableCollection<Menu> Items
{
get => _items;
set => SetProperty( ref _items, value );
}
public Menu SelectedItem
{
get => _selectedItem;
set
{
SetProperty( ref _selectedItem, value );
UpdateText( value );
}
}
public string Text
{
get => _text;
set => SetProperty( ref _text, value );
}
private void UpdateText( Menu menu )
{
if ( menu == null )
{
Text = string.Empty;
return;
}
StringBuilder sb = new StringBuilder();
sb.AppendLine( $"GumpID: 0x{menu.ID:x4}" );
sb.AppendLine( $"Serial: 0x{menu.Serial:x8}" );
sb.AppendLine( $"Title: {menu.Title}" );
sb.AppendLine( $"Entries: {menu.Entries?.Length ?? 0}" );
sb.AppendLine();
sb.AppendLine( "Entries:" );
if ( menu.Entries != null )
{
foreach ( MenuEntry menuEntry in menu.Entries )
{
sb.AppendLine( $"Index: {menuEntry.Index}" );
sb.AppendLine( $"ID: 0x{menuEntry.ID:x4}" );
sb.AppendLine( $"Hue: {menuEntry.Hue}" );
sb.AppendLine( $"Title: {menuEntry.Title}" );
sb.AppendLine();
}
}
Text = sb.ToString();
}
private void OnCollectionChangedEvent( Menu[] menus )
{
_dispatcher.Invoke( () =>
{
Items.Clear();
if ( menus == null )
{
return;
}
foreach ( Menu menu in menus )
{
Items.Add( menu );
}
} );
}
}
}
@@ -0,0 +1,93 @@
#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.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Input;
using ClassicAssist.Data.Macros.Commands;
using ClassicAssist.Shared.Resources;
using ClassicAssist.Shared.UO;
using ClassicAssist.UI.ViewModels;
using ClassicAssist.UO;
using ClassicAssist.UO.Data;
using ClassicAssist.UO.Objects;
using Microsoft.Scripting.Utils;
namespace ClassicAssist.Shared.UI.ViewModels.Debug
{
public class DebugPropertiesViewModel : BaseViewModel
{
private ObservableCollection<Property> _items = new ObservableCollection<Property>();
private ICommand _targetCommand;
public ObservableCollection<Property> Items
{
get => _items;
set => SetProperty( ref _items, value );
}
public ICommand TargetCommand =>
_targetCommand ?? ( _targetCommand = new RelayCommandAsync( Target, o => true ) );
private async Task Target( object arg )
{
int serial = await Commands.GetTargeSerialAsync( Strings.Target_object___ );
if ( serial == 0 )
{
return;
}
Entity entity = UOMath.IsMobile( serial )
? Engine.Mobiles.GetMobile( serial )
: (Entity) Engine.Items.GetItem( serial );
if ( entity == null )
{
return;
}
if ( entity.Properties == null )
{
if ( Engine.Features.HasFlag( FeatureFlags.AOS ) )
{
PropertiesCommands.WaitForProperties( entity.Serial, 5000 );
}
if ( entity.Properties == null )
{
Commands.SystemMessage( Strings.Item_properties_null_or_not_loaded___ );
return;
}
}
List<Property> properties = entity.Properties.Select( entityProperty => new Property
{
Cliloc = entityProperty.Cliloc,
Text = Cliloc.GetProperty( entityProperty.Cliloc ),
Arguments = entityProperty.Arguments
} ).ToList();
Items.Clear();
Items.AddRange( properties );
}
}
}
@@ -0,0 +1,53 @@
using System.Collections.ObjectModel;
using ClassicAssist.Data.SpecialMoves;
using ClassicAssist.UI.ViewModels;
using Microsoft.Scripting.Utils;
namespace ClassicAssist.Shared.UI.ViewModels.Debug
{
public class DebugSpecialMovesViewModel : BaseViewModel
{
private readonly SpecialMovesManager _manager;
private ObservableCollection<string> _items = new ObservableCollection<string>();
private ObservableCollection<string> _messages = new ObservableCollection<string>();
private string _selectedItem;
public DebugSpecialMovesViewModel()
{
_manager = SpecialMovesManager.GetInstance();
Items.AddRange( _manager.GetEnabledNames() );
_manager.SpecialMovesChanged += OnSpecialMovesChanged;
}
public ObservableCollection<string> Items
{
get => _items;
set => SetProperty( ref _items, value );
}
public ObservableCollection<string> Messages
{
get => _messages;
set => SetProperty( ref _messages, value );
}
public string SelectedItem
{
get => _selectedItem;
set => SetProperty( ref _selectedItem, value );
}
private void OnSpecialMovesChanged( string name, bool enabled )
{
_dispatcher.Invoke( () =>
{
Messages.Add( enabled ? $"Enabled: {name}" : $"Disabled: {name}" );
Items.Clear();
Items.AddRange( _manager.GetEnabledNames() );
} );
}
}
}
@@ -0,0 +1,77 @@
#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.Collections.ObjectModel;
using System.Linq;
using ClassicAssist.Data.Vendors;
using ClassicAssist.UI.ViewModels;
using ClassicAssist.UO.Data;
using ClassicAssist.UO.Network;
namespace ClassicAssist.Shared.UI.ViewModels.Debug
{
public class DebugVendorBuyViewModel : BaseViewModel
{
private bool _isEnabled;
private ObservableCollection<string> _messages = new ObservableCollection<string>();
public bool IsEnabled
{
get => _isEnabled;
set
{
if ( value != _isEnabled )
{
if ( value )
{
IncomingPacketHandlers.VendorBuyDisplayEvent += OnVendorBuyDisplayEvent;
}
else
{
IncomingPacketHandlers.VendorBuyDisplayEvent -= OnVendorBuyDisplayEvent;
}
}
SetProperty( ref _isEnabled, value );
}
}
public ObservableCollection<string> Messages
{
get => _messages;
set => SetProperty( ref _messages, value );
}
private void OnVendorBuyDisplayEvent( int serial, ShopListEntry[] entries )
{
_dispatcher.Invoke( () =>
{
Messages.Add( $"Vendor: Serial: 0x{serial:x}" );
foreach ( ShopListEntry entry in entries )
{
bool isCliloc = entry.Name.All( char.IsDigit );
Messages.Add(
$"\tName: {entry.Name} {( isCliloc ? $"({Cliloc.GetProperty( int.Parse( entry.Name ) )})" : string.Empty )}, Amount: {entry.Amount}, Price: {entry.Price}, ItemID: {entry.Item.ID} (0x{entry.Item.ID:x})" );
}
} );
}
}
}