Loading...
Loading...
Compare original and translation side by side
| Type | Use For | Examples |
|---|---|---|
| HUD | Always-on-screen | Health, mana, minimap |
| Overlay | Temporary display | Notifications, titles |
| Screen | Full interface | Inventory, menus |
| Dialog | Popups | Confirmations, NPC chat |
| Widget | Reusable components | Buttons, bars, icons |
| 类型 | 适用场景 | 示例 |
|---|---|---|
| HUD | 始终显示在屏幕上 | 生命值、魔力值、小地图 |
| Overlay(覆盖层) | 临时显示内容 | 通知、标题 |
| Screen(全屏界面) | 完整界面 | 物品栏、菜单 |
| Dialog(对话框) | 弹窗 | 确认提示、NPC对话 |
| Widget(组件) | 可复用组件 | 按钮、进度条、图标 |
MyPack/
└── Common/
└── UI/
├── hud/
│ ├── my_hud.xaml
│ └── my_hud.xaml.cs
├── screens/
│ ├── custom_menu.xaml
│ └── custom_inventory.xaml
└── textures/
├── button_bg.png
└── icons/MyPack/
└── Common/
└── UI/
├── hud/
│ ├── my_hud.xaml
│ └── my_hud.xaml.cs
├── screens/
│ ├── custom_menu.xaml
│ └── custom_inventory.xaml
└── textures/
├── button_bg.png
└── icons/<!-- my_hud.xaml -->
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10">
<!-- Mana Bar -->
<Border Background="#333" CornerRadius="5" Padding="2">
<Grid Width="200" Height="20">
<Rectangle Fill="#224" RadiusX="3" RadiusY="3"/>
<Rectangle x:Name="ManaFill" Fill="#48F" RadiusX="3" RadiusY="3"
HorizontalAlignment="Left" Width="150"/>
<TextBlock Text="150/200" Foreground="White"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</Border>
</Grid>
</UserControl><!-- my_hud.xaml -->
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10">
<!-- Mana Bar -->
<Border Background="#333" CornerRadius="5" Padding="2">
<Grid Width="200" Height="20">
<Rectangle Fill="#224" RadiusX="3" RadiusY="3"/>
<Rectangle x:Name="ManaFill" Fill="#48F" RadiusX="3" RadiusY="3"
HorizontalAlignment="Left" Width="150"/>
<TextBlock Text="150/200" Foreground="White"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</Border>
</Grid>
</UserControl>{
"hudId": "mymod:mana_bar",
"xaml": "ui/hud/mana_bar.xaml",
"position": "top-left",
"offset": { "x": 10, "y": 50 }
}{
"hudId": "mymod:mana_bar",
"xaml": "ui/hud/mana_bar.xaml",
"position": "top-left",
"offset": { "x": 10, "y": 50 }
}| Position | Description |
|---|---|
| Upper left corner |
| Upper center |
| Upper right corner |
| Screen center |
| Lower left |
| Lower center |
| Lower right |
| 位置 | 说明 |
|---|---|
| 左上角 |
| 顶部中央 |
| 右上角 |
| 屏幕中央 |
| 左下角 |
| 底部中央 |
| 右下角 |
<Grid Width="200" Height="20">
<Rectangle Fill="#333" RadiusX="3" RadiusY="3"/>
<Rectangle x:Name="ProgressFill" Fill="#4A4" RadiusX="3" RadiusY="3"
HorizontalAlignment="Left" Width="{Binding Progress}"/>
<TextBlock Text="{Binding ProgressText}" Foreground="White"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid><Grid Width="200" Height="20">
<Rectangle Fill="#333" RadiusX="3" RadiusY="3"/>
<Rectangle x:Name="ProgressFill" Fill="#4A4" RadiusX="3" RadiusY="3"
HorizontalAlignment="Left" Width="{Binding Progress}"/>
<TextBlock Text="{Binding ProgressText}" Foreground="White"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid><Button Width="48" Height="48" Style="{StaticResource IconButton}">
<Image Source="textures/icons/sword.png" Width="32" Height="32"/>
</Button><Button Width="48" Height="48" Style="{StaticResource IconButton}">
<Image Source="textures/icons/sword.png" Width="32" Height="32"/>
</Button><Border Background="#222" CornerRadius="5" Padding="10">
<StackPanel>
<TextBlock Text="{Binding ItemName}" FontWeight="Bold" Foreground="#FF0"/>
<TextBlock Text="{Binding ItemDesc}" Foreground="#AAA" TextWrapping="Wrap"/>
</StackPanel>
</Border><Border Background="#222" CornerRadius="5" Padding="10">
<StackPanel>
<TextBlock Text="{Binding ItemName}" FontWeight="Bold" Foreground="#FF0"/>
<TextBlock Text="{Binding ItemDesc}" Foreground="#AAA" TextWrapping="Wrap"/>
</StackPanel>
</Border><UserControl>
<Grid Background="#88000000">
<Border Background="#333" CornerRadius="10" Padding="20"
HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel Width="300">
<TextBlock Text="My Custom Menu" FontSize="24"
Foreground="White" HorizontalAlignment="Center"/>
<Button Content="Option 1" Margin="0,20,0,0" Height="40"/>
<Button Content="Option 2" Margin="0,10,0,0" Height="40"/>
<Button Content="Close" Margin="0,20,0,0" Height="40"
Click="OnClose"/>
</StackPanel>
</Border>
</Grid>
</UserControl><UserControl>
<Grid Background="#88000000">
<Border Background="#333" CornerRadius="10" Padding="20"
HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel Width="300">
<TextBlock Text="My Custom Menu" FontSize="24"
Foreground="White" HorizontalAlignment="Center"/>
<Button Content="Option 1" Margin="0,20,0,0" Height="40"/>
<Button Content="Option 2" Margin="0,10,0,0" Height="40"/>
<Button Content="Close" Margin="0,20,0,0" Height="40"
Click="OnClose"/>
</StackPanel>
</Border>
</Grid>
</UserControl><ItemsControl ItemsSource="{Binding InventorySlots}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="9" Rows="4"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Width="48" Height="48" Background="#444"
BorderBrush="#666" BorderThickness="1" Margin="2">
<Image Source="{Binding Icon}" Stretch="Uniform"/>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl><ItemsControl ItemsSource="{Binding InventorySlots}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="9" Rows="4"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Width="48" Height="48" Background="#444"
BorderBrush="#666" BorderThickness="1" Margin="2">
<Image Source="{Binding Icon}" Stretch="Uniform"/>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>// Show custom HUD
player.showHUD("mymod:mana_bar");
// Hide HUD
player.hideHUD("mymod:mana_bar");
// Check if visible
boolean visible = player.isHUDVisible("mymod:mana_bar");// Show custom HUD
player.showHUD("mymod:mana_bar");
// Hide HUD
player.hideHUD("mymod:mana_bar");
// Check if visible
boolean visible = player.isHUDVisible("mymod:mana_bar");// Update bound data
player.setHUDData("mymod:mana_bar", "mana", currentMana);
player.setHUDData("mymod:mana_bar", "maxMana", maxMana);
// Or with object
ManaData data = new ManaData(currentMana, maxMana);
player.setHUDData("mymod:mana_bar", data);// Update bound data
player.setHUDData("mymod:mana_bar", "mana", currentMana);
player.setHUDData("mymod:mana_bar", "maxMana", maxMana);
// Or with object
ManaData data = new ManaData(currentMana, maxMana);
player.setHUDData("mymod:mana_bar", data);// Open custom screen
player.openScreen("mymod:custom_menu");
// Open with data
player.openScreen("mymod:shop", shopInventory);
// Close current screen
player.closeScreen();// Open custom screen
player.openScreen("mymod:custom_menu");
// Open with data
player.openScreen("mymod:shop", shopInventory);
// Close current screen
player.closeScreen();// Show toast notification
player.showNotification("Achievement Unlocked!", 5.0f);
// Show title
player.showTitle("Boss Defeated!", "You earned 500 XP", 3.0f);
// Show action bar message
player.showActionBar("Press E to interact");// Show toast notification
player.showNotification("Achievement Unlocked!", 5.0f);
// Show title
player.showTitle("Boss Defeated!", "You earned 500 XP", 3.0f);
// Show action bar message
player.showActionBar("Press E to interact");public class ManaViewModel {
private int mana;
private int maxMana;
public int getMana() { return mana; }
public void setMana(int value) {
this.mana = value;
notifyPropertyChanged("mana");
notifyPropertyChanged("manaPercent");
}
public double getManaPercent() {
return (double) mana / maxMana * 100;
}
}public class ManaViewModel {
private int mana;
private int maxMana;
public int getMana() { return mana; }
public void setMana(int value) {
this.mana = value;
notifyPropertyChanged("mana");
notifyPropertyChanged("manaPercent");
}
public double getManaPercent() {
return (double) mana / maxMana * 100;
}
}<Rectangle Width="{Binding ManaPercent, Converter={StaticResource PercentToWidth}}"/>
<TextBlock Text="{Binding Mana, StringFormat='{}{0} MP'}"/><Rectangle Width="{Binding ManaPercent, Converter={StaticResource PercentToWidth}}"/>
<TextBlock Text="{Binding Mana, StringFormat='{}{0} MP'}"/><Style x:Key="GameButton" TargetType="Button">
<Setter Property="Background" Value="#444"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="BorderBrush" Value="#666"/>
<Setter Property="BorderThickness" Value="2"/>
<Setter Property="Padding" Value="15,8"/>
<Setter Property="FontSize" Value="14"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#555"/>
<Setter Property="BorderBrush" Value="#888"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="#333"/>
</Trigger>
</Style.Triggers>
</Style><Style x:Key="GameButton" TargetType="Button">
<Setter Property="Background" Value="#444"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="BorderBrush" Value="#666"/>
<Setter Property="BorderThickness" Value="2"/>
<Setter Property="Padding" Value="15,8"/>
<Setter Property="FontSize" Value="14"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#555"/>
<Setter Property="BorderBrush" Value="#888"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="#333"/>
</Trigger>
</Style.Triggers>
</Style><Color x:Key="PrimaryColor">#4A90D9</Color>
<Color x:Key="SecondaryColor">#2ECC71</Color>
<Color x:Key="DangerColor">#E74C3C</Color>
<Color x:Key="BackgroundColor">#2C3E50</Color>
<Color x:Key="TextColor">#ECF0F1</Color><Color x:Key="PrimaryColor">#4A90D9</Color>
<Color x:Key="SecondaryColor">#2ECC71</Color>
<Color x:Key="DangerColor">#E74C3C</Color>
<Color x:Key="BackgroundColor">#2C3E50</Color>
<Color x:Key="TextColor">#ECF0F1</Color>| Practice | Why |
|---|---|
| Use data binding | Automatic updates |
| Consistent styling | Professional look |
| Test all resolutions | Accessibility |
| Provide feedback | User understands |
| 实践 | 原因 |
|---|---|
| 使用数据绑定 | 自动更新内容 |
| 保持样式一致 | 呈现专业外观 |
| 测试所有分辨率 | 提升可访问性 |
| 提供操作反馈 | 让用户清晰了解状态 |
| Mistake | Why Bad |
|---|---|
| Too many HUDs | Screen clutter |
| Tiny text | Hard to read |
| No close button | Frustrating |
| Block gameplay | Annoying |
| 错误做法 | 弊端 |
|---|---|
| HUD数量过多 | 造成屏幕杂乱 |
| 文字过小 | 难以阅读 |
| 无关闭按钮 | 引起用户不满 |
| 遮挡游戏内容 | 影响游戏体验 |
| Task | How |
|---|---|
| Create HUD | Define XAML + register JSON |
| Show HUD | |
| Update data | |
| Open screen | |
| Show notification | |
| 任务 | 实现方式 |
|---|---|
| 创建HUD | 定义XAML + 注册JSON |
| 显示HUD | |
| 更新数据 | |
| 打开界面 | |
| 显示通知 | |
hytale-plugin-devhytale-npc-aihytale-plugin-devhytale-npc-ai