Skip to content

Instantly share code, notes, and snippets.

View MartinZikmund's full-sized avatar
⌨️
Coding

Martin Zikmund MartinZikmund

⌨️
Coding
View GitHub Profile
if (_doom == null || Gamepad.Gamepads.Count == 0)
return;
var gamepad = Gamepad.Gamepads[0]; // Use first gamepad
var reading = gamepad.GetCurrentReading();
ProcessButtons(reading);
ProcessMovementStick(reading.LeftThumbstickX, reading.LeftThumbstickY);
ProcessLookStick(reading.RightThumbstickX, reading.RightThumbstickY);
ProcessTriggers(reading.LeftTrigger, reading.RightTrigger);
if (_movementPointerId.HasValue)
{
var dx = _movementCurrent.X - _movementCenter.X;
var dy = _movementCurrent.Y - _movementCenter.Y;
var distance = Math.Sqrt(dx * dx + dy * dy);
var normalizedDistance = Math.Min(distance / JoystickRadius, 1.0);
if (normalizedDistance > DeadZone)
{
var angle = Math.Atan2(dy, dx);
if (IsInFireButton(position) && !_firePointerId.HasValue)
{
_firePointerId = pointerId;
SetFirePressed(true);
CapturePointer(e.Pointer);
e.Handled = true;
return;
}
if (IsInUseButton(position) && !_usePointerId.HasValue)
<UserControl
x:Class="UnoDoom.Game.TouchInputOverlay"
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:toolkit="using:Uno.UI.Toolkit"
IsHitTestVisible="True"
Opacity="0.85"
mc:Ignorable="d">
private static string _localWadPath;
/// <summary>
/// Prepares assets for WebAssembly by downloading them via HTTP
/// </summary>
public static async Task PrepareAssetsAsync()
{
var localFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("Wads", CreationCollisionOption.OpenIfExists);
foreach (var name in iwadNames)
{
public partial class MainViewModel : PageViewModel
{
private readonly IBlueskyService _blueskyService;
public MainViewModel(INavigationService navigationService, IBlueskyService blueskyService) : base(navigationService)
{
_blueskyService = blueskyService;
}
[ObservableProperty]
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ListView SelectionMode="None" ItemsSource="{x:Bind ViewModel.Feed, Mode=OneWay}">
<ListView.ItemTemplate>
<DataTemplate x:DataType="vm:FeedItemViewModel">
<StackPanel CornerRadius="8" Margin="8,4,8,4" Padding="8" Spacing="8" Background="{ThemeResource ButtonBackground}">
<TextBlock Text="{x:Bind Text}" TextWrapping="WrapWholeWords" />
using Birdsky.Core.Services.Bluesky;
using Birdsky.Services.Navigation;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using MZikmund.Toolkit.WinUI.Infrastructure;
namespace Birdsky.Core.ViewModels;
public partial class LoginViewModel : PageViewModel
{
private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
{
ViewModel!.AppPassword = ((PasswordBox)sender).Password;
}
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Spacing="10">
<TextBox Header="Handle" Text="{Binding Handle, Mode=TwoWay}" Width="300" />
<PasswordBox Header="App Password" Width="300" PasswordChanged="PasswordBox_PasswordChanged" />
<Button Content="Login" Command="{Binding LoginCommand}" Width="300" />
</StackPanel>