fix: fix toggle soulshot method
This commit is contained in:
36
Client/Application/Components/Item.xaml
Normal file
36
Client/Application/Components/Item.xaml
Normal file
@@ -0,0 +1,36 @@
|
||||
<Button x:Class="Client.Application.Components.Item"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Client.Application.Components"
|
||||
xmlns:services="clr-namespace:Client.Application.Services"
|
||||
mc:Ignorable="d"
|
||||
ToolTipService.ShowOnDisabled="True"
|
||||
x:Name="root">
|
||||
<Button.InputBindings>
|
||||
<MouseBinding Gesture="LeftClick" Command="{Binding MouseLeftClickCommand}" />
|
||||
<MouseBinding Gesture="RightClick" Command="{Binding MouseRightClickCommand}" />
|
||||
</Button.InputBindings>
|
||||
<Button.Resources>
|
||||
<services:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||
<services:NullToVisibilityConverter x:Key="NullToVisibilityConverter"/>
|
||||
<DataTemplate x:Key="ToolTipContent">
|
||||
<StackPanel MaxWidth="300">
|
||||
<TextBlock Text="{Binding ItemName,Mode=OneWay}" TextWrapping="Wrap" FontWeight="Bold" FontSize="14" Margin="0,0,0,5" />
|
||||
<TextBlock
|
||||
TextWrapping="Wrap"
|
||||
Text="{Binding Source={x:Reference root},Path=Description,Mode=OneWay}"
|
||||
/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</Button.Resources>
|
||||
<Button.Content>
|
||||
<Grid>
|
||||
<Image Source="{Binding Path=ImageSource,ElementName=root}" Height="32" Width="32" />
|
||||
</Grid>
|
||||
</Button.Content>
|
||||
<Button.ToolTip >
|
||||
<ContentControl ContentTemplate="{StaticResource ToolTipContent}"/>
|
||||
</Button.ToolTip>
|
||||
</Button>
|
50
Client/Application/Components/Item.xaml.cs
Normal file
50
Client/Application/Components/Item.xaml.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Client.Application.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for Item.xaml
|
||||
/// </summary>
|
||||
public partial class Item : Button
|
||||
{
|
||||
public static readonly DependencyProperty ImageSourceProperty =
|
||||
DependencyProperty.Register("ImageSource", typeof(ImageSource), typeof(Item), new PropertyMetadata(default(ImageSource)));
|
||||
public static readonly DependencyProperty ItemNameProperty =
|
||||
DependencyProperty.Register("ItemName", typeof(string), typeof(Item), new PropertyMetadata("Item"));
|
||||
public static readonly DependencyProperty DescriptionProperty =
|
||||
DependencyProperty.Register("Description", typeof(string), typeof(Item), new PropertyMetadata(""));
|
||||
|
||||
public Item()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public ImageSource ImageSource
|
||||
{
|
||||
get { return (ImageSource)GetValue(ImageSourceProperty); }
|
||||
set { SetValue(ImageSourceProperty, value); }
|
||||
}
|
||||
public string ItemName
|
||||
{
|
||||
get { return (string)GetValue(ItemNameProperty); }
|
||||
set { SetValue(ItemNameProperty, value); }
|
||||
}
|
||||
public string? Description
|
||||
{
|
||||
get { return (string?)GetValue(DescriptionProperty); }
|
||||
set { SetValue(DescriptionProperty, value); }
|
||||
}
|
||||
}
|
||||
}
|
@@ -44,7 +44,7 @@ namespace Client.Application.ViewModels
|
||||
worldHandler.RequestMoveToEntity(Id);
|
||||
}
|
||||
|
||||
public CreatureListViewModel(CreatureInterface creature, Hero hero, WorldHandler worldHandler)
|
||||
public CreatureListViewModel(WorldHandler worldHandler, CreatureInterface creature, Hero hero)
|
||||
{
|
||||
creature.PropertyChanged += Creature_PropertyChanged;
|
||||
creature.Transform.Position.PropertyChanged += Position_PropertyChanged;
|
||||
|
@@ -82,7 +82,7 @@ namespace Client.Application.ViewModels
|
||||
worldHandler.RequestMoveToEntity(Id);
|
||||
}
|
||||
|
||||
public CreatureMapViewModel(CreatureInterface creature, Hero hero, WorldHandler worldHandler)
|
||||
public CreatureMapViewModel(WorldHandler worldHandler, CreatureInterface creature, Hero hero)
|
||||
{
|
||||
this.creature = creature;
|
||||
this.hero = hero;
|
||||
|
@@ -79,7 +79,7 @@ namespace Client.Application.ViewModels
|
||||
worldHandler.RequestMoveToEntity(Id);
|
||||
}
|
||||
|
||||
public DropListViewModel(Drop drop, Hero hero, WorldHandler worldHandler)
|
||||
public DropListViewModel(WorldHandler worldHandler, Drop drop, Hero hero)
|
||||
{
|
||||
this.drop = drop;
|
||||
this.hero = hero;
|
||||
|
@@ -61,7 +61,7 @@ namespace Client.Application.ViewModels
|
||||
worldHandler.RequestMoveToEntity(Id);
|
||||
}
|
||||
|
||||
public DropMapViewModel(Drop drop, Hero hero, WorldHandler worldHandler)
|
||||
public DropMapViewModel(WorldHandler worldHandler, Drop drop, Hero hero)
|
||||
{
|
||||
this.drop = drop;
|
||||
this.hero = hero;
|
||||
|
46
Client/Application/ViewModels/ItemListViewModel.cs
Normal file
46
Client/Application/ViewModels/ItemListViewModel.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Client.Application.Commands;
|
||||
using Client.Application.Components;
|
||||
using Client.Domain.Common;
|
||||
using Client.Domain.Entities;
|
||||
using Client.Domain.Service;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Client.Application.ViewModels
|
||||
{
|
||||
public class ItemListViewModel : ObservableObject
|
||||
{
|
||||
public uint Id => item.Id;
|
||||
public string Name => item.Name;
|
||||
public string Description => item.FullDescription;
|
||||
public string IconName => "/Assets/icons/" + item.IconName + ".png";
|
||||
|
||||
public ICommand MouseLeftClickCommand { get; }
|
||||
public ICommand MouseRightClickCommand { get; }
|
||||
private void OnLeftMouseClick(object? obj)
|
||||
{
|
||||
worldHandler.RequestUseItem(Id);
|
||||
}
|
||||
private void OnRightMouseClick(object? obj)
|
||||
{
|
||||
worldHandler.RequestToggleAutouseSoulshot(Id);
|
||||
}
|
||||
|
||||
public ItemListViewModel(WorldHandler worldHandler, ItemInterface item)
|
||||
{
|
||||
this.worldHandler = worldHandler;
|
||||
this.item = item;
|
||||
|
||||
//skill.PropertyChanged += Skill_PropertyChanged;
|
||||
MouseLeftClickCommand = new RelayCommand(OnLeftMouseClick);
|
||||
MouseRightClickCommand = new RelayCommand(OnRightMouseClick);
|
||||
}
|
||||
|
||||
private readonly WorldHandler worldHandler;
|
||||
private readonly ItemInterface item;
|
||||
}
|
||||
}
|
@@ -59,7 +59,7 @@ namespace Client.Application.ViewModels
|
||||
{
|
||||
if (hero != null)
|
||||
{
|
||||
Creatures.Add(new CreatureListViewModel(@event.Creature, hero, worldHandler));
|
||||
Creatures.Add(new CreatureListViewModel(worldHandler, @event.Creature, hero));
|
||||
AddCreature(@event.Creature);
|
||||
}
|
||||
}
|
||||
@@ -74,8 +74,8 @@ namespace Client.Application.ViewModels
|
||||
{
|
||||
if (hero != null)
|
||||
{
|
||||
Drops.Add(new DropListViewModel(@event.Drop, hero, worldHandler));
|
||||
Map.Drops.Add(new DropMapViewModel(@event.Drop, hero, worldHandler));
|
||||
Drops.Add(new DropListViewModel(worldHandler, @event.Drop, hero));
|
||||
Map.Drops.Add(new DropMapViewModel(worldHandler, @event.Drop, hero));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,20 +115,28 @@ namespace Client.Application.ViewModels
|
||||
{
|
||||
if (hero != null)
|
||||
{
|
||||
Items.Add(@event.Item);
|
||||
if (!@event.Item.IsQuest)
|
||||
{
|
||||
Items.Add(new ItemListViewModel(worldHandler, @event.Item));
|
||||
}
|
||||
else
|
||||
{
|
||||
QuestItems.Add(new ItemListViewModel(worldHandler, @event.Item));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Handle(ItemDeletedEvent @event)
|
||||
{
|
||||
Items.RemoveAll(x => x.Id == @event.Id);
|
||||
QuestItems.RemoveAll(x => x.Id == @event.Id);
|
||||
}
|
||||
|
||||
private void AddCreature(CreatureInterface creature)
|
||||
{
|
||||
if (hero != null)
|
||||
{
|
||||
Map.Creatures.Add(new CreatureMapViewModel(creature, hero, worldHandler));
|
||||
Map.Creatures.Add(new CreatureMapViewModel(worldHandler, creature, hero));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +156,8 @@ namespace Client.Application.ViewModels
|
||||
public ObservableCollection<DropListViewModel> Drops { get; } = new ObservableCollection<DropListViewModel>();
|
||||
public ObservableCollection<SkillListViewModel> ActiveSkills { get; } = new ObservableCollection<SkillListViewModel>();
|
||||
public ObservableCollection<SkillListViewModel> PassiveSkills { get; } = new ObservableCollection<SkillListViewModel>();
|
||||
public ObservableCollection<BaseItem> Items { get; } = new ObservableCollection<BaseItem>();
|
||||
public ObservableCollection<ItemListViewModel> Items { get; } = new ObservableCollection<ItemListViewModel>();
|
||||
public ObservableCollection<ItemListViewModel> QuestItems { get; } = new ObservableCollection<ItemListViewModel>();
|
||||
public HeroSummaryInfoViewModel? Hero { get; private set; }
|
||||
public MapViewModel Map { get; private set; }
|
||||
public Hero? hero;
|
||||
|
23
Client/Application/Views/ItemPanel.xaml
Normal file
23
Client/Application/Views/ItemPanel.xaml
Normal file
@@ -0,0 +1,23 @@
|
||||
<ItemsControl x:Class="Client.Application.Views.ItemPanel"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Client.Application.Views"
|
||||
xmlns:components="clr-namespace:Client.Application.Components"
|
||||
mc:Ignorable="d">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<components:Item
|
||||
ImageSource="{Binding Path=IconName,Mode=OneWay}"
|
||||
ItemName="{Binding Path=Name,Mode=OneWay}"
|
||||
Description="{Binding Path=Description,Mode=OneWay}"
|
||||
/>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
</ItemsControl>
|
27
Client/Application/Views/ItemPanel.xaml.cs
Normal file
27
Client/Application/Views/ItemPanel.xaml.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Client.Application.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ItemPanel.xaml
|
||||
/// </summary>
|
||||
public partial class ItemPanel : ItemsControl
|
||||
{
|
||||
public ItemPanel()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@@ -140,50 +140,13 @@
|
||||
<TabItem>
|
||||
<TabItem.Header>Items</TabItem.Header>
|
||||
<TabItem.Content>
|
||||
<ItemsControl ItemsSource="{Binding Path=Items}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Button>
|
||||
<Button.Resources>
|
||||
<services:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||
<services:NullToVisibilityConverter x:Key="NullToVisibilityConverter"/>
|
||||
<DataTemplate x:Key="ToolTipContent">
|
||||
<StackPanel MaxWidth="300">
|
||||
<TextBlock TextWrapping="Wrap" FontWeight="Bold" FontSize="14" Margin="0,0,0,5">
|
||||
<TextBlock.Text>
|
||||
<MultiBinding StringFormat="{}{0} ({1})">
|
||||
<Binding Path="Name" Mode="OneWay" />
|
||||
<Binding Path="Amount" Mode="OneWay" />
|
||||
</MultiBinding>
|
||||
</TextBlock.Text>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</Button.Resources>
|
||||
<Button.Content>
|
||||
<Grid>
|
||||
<!--Image Source="{Binding Path=ImageSource}" Height="32" Width="32" /-->
|
||||
<TextBlock Text="{Binding Name,Mode=OneWay}" />
|
||||
</Grid>
|
||||
</Button.Content>
|
||||
<Button.ToolTip >
|
||||
<ContentControl ContentTemplate="{StaticResource ToolTipContent}"/>
|
||||
</Button.ToolTip>
|
||||
</Button>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
</ItemsControl>
|
||||
<views:ItemPanel ItemsSource="{Binding Items,Mode=OneWay}" />
|
||||
</TabItem.Content>
|
||||
</TabItem>
|
||||
<TabItem>
|
||||
<TabItem.Header>Quest Items</TabItem.Header>
|
||||
<TabItem.Content>
|
||||
<Label Content="Under construction" />
|
||||
<views:ItemPanel ItemsSource="{Binding QuestItems,Mode=OneWay}" />
|
||||
</TabItem.Content>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
Reference in New Issue
Block a user