mirror of
https://github.com/oshima-studios/OshimaGameModule.git
synced 2025-12-05 16:16:35 +00:00
一些修复
This commit is contained in:
parent
5da35bc5f9
commit
0b022fe9c1
52
OshimaModes/MainWindow.xaml
Normal file
52
OshimaModes/MainWindow.xaml
Normal file
@ -0,0 +1,52 @@
|
||||
<Window x:Class="Oshima.FunGame.OshimaModes.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="FunGame WPF UI" Height="720" Width="1280">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- 玩家信息区域 -->
|
||||
<ItemsControl Grid.Column="0" ItemsSource="{Binding Players}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel Orientation="Vertical"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border BorderBrush="Black" BorderThickness="1" Margin="5">
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding PlayerName}" FontWeight="Bold"/>
|
||||
<Image Source="{Binding PlayerImage}" Width="100" Height="100"/>
|
||||
<TextBlock Text="{Binding HP}"/>
|
||||
<TextBlock Text="{Binding MP}"/>
|
||||
<!-- 其他玩家信息 -->
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
||||
<!-- 游戏信息/聊天区域 -->
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- 游戏信息显示 -->
|
||||
<ScrollViewer Grid.Row="0" VerticalScrollBarVisibility="Auto">
|
||||
<TextBlock x:Name="GameInfoTextBlock" TextWrapping="Wrap"/>
|
||||
</ScrollViewer>
|
||||
|
||||
<!-- 聊天输入框 -->
|
||||
<StackPanel Grid.Row="1" Orientation="Horizontal">
|
||||
<TextBox Width="200" x:Name="ChatInputTextBox" KeyDown="ChatInputTextBox_KeyDown"/>
|
||||
<Button Content="发送" Click="SendButton_Click"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
37
OshimaModes/MainWindow.xaml.cs
Normal file
37
OshimaModes/MainWindow.xaml.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Oshima.FunGame.OshimaModes
|
||||
{
|
||||
/// <summary>
|
||||
/// MainWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private MainWindowViewModel ViewModel;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
ViewModel = new MainWindowViewModel();
|
||||
DataContext = ViewModel;
|
||||
Show();
|
||||
}
|
||||
|
||||
private void SendButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 发送聊天消息的逻辑
|
||||
string message = ChatInputTextBox.Text;
|
||||
ViewModel.GameInfoText += $"You: {message}\n";
|
||||
ChatInputTextBox.Clear();
|
||||
}
|
||||
|
||||
private void ChatInputTextBox_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
SendButton_Click(sender, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
57
OshimaModes/MainWindowViewModel.cs
Normal file
57
OshimaModes/MainWindowViewModel.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace Oshima.FunGame.OshimaModes
|
||||
{
|
||||
public class MainWindowViewModel : INotifyPropertyChanged
|
||||
{
|
||||
public ObservableCollection<PlayerInfo> Players { get; set; } = new ObservableCollection<PlayerInfo>();
|
||||
|
||||
private string _gameInfoText;
|
||||
public string GameInfoText
|
||||
{
|
||||
get { return _gameInfoText; }
|
||||
set
|
||||
{
|
||||
_gameInfoText = value;
|
||||
OnPropertyChanged(nameof(GameInfoText));
|
||||
}
|
||||
}
|
||||
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
// 模拟添加玩家
|
||||
for (int i = 1; i <= 12; i++)
|
||||
{
|
||||
Players.Add(new PlayerInfo
|
||||
{
|
||||
PlayerName = $"Player {i}",
|
||||
HP = $"{i * 10}/{i * 100}",
|
||||
MP = $"{i * 5}/{i * 50}",
|
||||
PlayerImage = new BitmapImage(new System.Uri("pack://application:,,,/Oshima.FunGame.WPFUI;component/Images/default_avatar.png")) // 替换为你的默认头像
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected virtual void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
public class PlayerInfo
|
||||
{
|
||||
public string PlayerName { get; set; }
|
||||
public string HP { get; set; }
|
||||
public string MP { get; set; }
|
||||
public BitmapImage PlayerImage { get; set; }
|
||||
}
|
||||
}
|
||||
@ -104,6 +104,7 @@ namespace Oshima.FunGame.OshimaServers
|
||||
{
|
||||
// 因为模组是单例的,需要为这个房间创建一个工作类接收参数,不能直接用本地变量处理
|
||||
ModuleServerWorker worker = new(obj);
|
||||
Workers[obj.Room.Roomid] = worker;
|
||||
TaskUtility.NewTask(async () => await StartGame(obj, worker)).OnError(Controller.Error);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -3,7 +3,9 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Milimoe.FunGame.Core.Api.Transmittal;
|
||||
using Milimoe.FunGame.Core.Api.Utility;
|
||||
using Milimoe.FunGame.Core.Interface;
|
||||
using Milimoe.FunGame.Core.Library.Common.Addon;
|
||||
using Milimoe.FunGame.Core.Library.Common.Event;
|
||||
using Oshima.Core.Configs;
|
||||
using Oshima.Core.Constant;
|
||||
using Oshima.FunGame.OshimaServers.Service;
|
||||
@ -14,7 +16,7 @@ using Oshima.FunGame.WebAPI.Services;
|
||||
|
||||
namespace Oshima.FunGame.WebAPI
|
||||
{
|
||||
public class OshimaWebAPI : WebAPIPlugin
|
||||
public class OshimaWebAPI : WebAPIPlugin, ILoginEvent
|
||||
{
|
||||
public override string Name => OshimaGameModuleConstant.WebAPI;
|
||||
|
||||
@ -64,5 +66,15 @@ namespace Oshima.FunGame.WebAPI
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public void BeforeLoginEvent(object sender, LoginEventArgs e)
|
||||
{
|
||||
Controller.WriteLine(e.Password);
|
||||
}
|
||||
|
||||
public void AfterLoginEvent(object sender, LoginEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user