Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions Controls/AppTile.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,41 @@ public AppTile(string familyName)

startButton.Tapped += (_, _) => StartApp();
}

public async void ShowControllerInteractDialog()
{
ContentDialog dialog = new ContentDialog();
dialog.XamlRoot = App.MainWindow.Content.XamlRoot;
dialog.Title = _package.DisplayName;
StackPanel optionsPanel = new StackPanel();
optionsPanel.HorizontalAlignment = HorizontalAlignment.Center;
dialog.Content = optionsPanel;

TextBlock textBlock = new TextBlock();
textBlock.Text = "NON-FUNCTIONAL";

// todo: onclick for all

// we need to either move the uninstall options somewhere else or figure out a way to make it work with controller
Button uninstallButton = new Button();
uninstallButton.Content = "Uninstall";
uninstallButton.Margin = new Thickness(0, 0, 0, 10);

Button manageSavesButton = new Button();
manageSavesButton.Content = "Manage saves";
manageSavesButton.Margin = new Thickness(0, 0, 0, 10);

Button manageModsButton = new Button();
manageModsButton.Content = "Manage mods";
manageModsButton.Margin = new Thickness(0, 0, 0, 10);

optionsPanel.Children.Add(textBlock);
optionsPanel.Children.Add(uninstallButton);
optionsPanel.Children.Add(manageSavesButton);
optionsPanel.Children.Add(manageModsButton);

await dialog.ShowAsync();
}


public async void StartApp()
Expand Down
13 changes: 13 additions & 0 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ public sealed partial class MainWindow : Window
public AppsListPage AppsListPage;
public SettingsPage SettingsPage;
public AboutPage AboutPage;
public AppMode currentMode;

public enum AppMode
{
DESKTOP,
CONTROLLER
}

private void NavigationInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args)
{
Expand Down Expand Up @@ -141,6 +148,12 @@ private void appTitleBar_SizeChanged(object sender, SizeChangedEventArgs e)
}
}

public void SwitchMode(AppMode mode)
{
currentMode = mode;
navView.PaneDisplayMode = currentMode == AppMode.CONTROLLER ? NavigationViewPaneDisplayMode.Top : NavigationViewPaneDisplayMode.LeftCompact;
}

private void SetupTitleBar()
{
AppWindowTitleBar titleBar = AppWindow.TitleBar;
Expand Down
34 changes: 29 additions & 5 deletions Pages/AppsListPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,29 +151,37 @@

private void OnAppListPage_Loaded(object sender, RoutedEventArgs e)
{
Gamepad.GamepadAdded += onGamepadAdded;
Gamepad.GamepadAdded += OnGamepadAdded;
Gamepad.GamepadRemoved += OnGamepadRemoved;
}

private void OnGamepadRemoved(object sender, Gamepad e)
{
Logger.WriteInformation("Controller disconnected");
gamepad = null;
this.DispatcherQueue.TryEnqueue(() =>
{
App.MainWindow.SwitchMode(MainWindow.AppMode.DESKTOP);
});
}

private void onGamepadAdded(object sender, Gamepad e)
private void OnGamepadAdded(object sender, Gamepad e)
{
Logger.WriteInformation("Controller connected");
gamepad = e;
ListenGamepadInput();
this.DispatcherQueue.TryEnqueue(() =>
{
if (appList.Children.Count > 0)
{
appList.Children[currentIndex].Focus(FocusState.Keyboard);
}
App.MainWindow.SwitchMode(MainWindow.AppMode.CONTROLLER);
});
ListenGamepadInput();
}


// can we make this work everywhere, like in content dialogs?
private async void ListenGamepadInput()
{
while (gamepad != null)
Expand All @@ -183,9 +191,12 @@
bool moveLeft = gamepadInput.LeftThumbstickX < -0.5 || (gamepadInput.Buttons & GamepadButtons.DPadLeft) != 0;
bool moveUp = gamepadInput.LeftThumbstickY > 0.5 || (gamepadInput.Buttons & GamepadButtons.DPadUp) != 0;
bool moveDown = gamepadInput.LeftThumbstickY < -0.5 || (gamepadInput.Buttons & GamepadButtons.DPadDown) != 0;
bool start = (gamepadInput.Buttons & GamepadButtons.Menu) != 0; // start as in the button, not start package
bool view = (gamepadInput.Buttons & GamepadButtons.View) != 0; // TODO: on click it should switch between the navigationview, bottom docked bar, and apps list (needs handling for other pages)
bool actionClicked = (gamepadInput.Buttons & GamepadButtons.A) != 0;


// feel like we should have like event listeners or whatever
// actionClicked += whatever
if (actionClicked && inputProcessed)
{
inputProcessed = false;
Expand All @@ -197,6 +208,19 @@
});
}

// disabled until controller support works
// also pressing start twice will crash cuz 2 contentdialogs
//if (start && inputProcessed)
//{
// inputProcessed = false;
// this.DispatcherQueue.TryEnqueue(() =>
// {
// var appTile = appList.Children[currentIndex] as AppTile;
// appTile.ShowControllerInteractDialog();
// inputProcessed = true;
// });
//}

if ((moveRight || moveLeft || moveUp || moveDown) && inputProcessed)
{
inputProcessed = false;
Expand All @@ -213,7 +237,7 @@
private void MoveFocus(int xOffset, int yOffset)
{
bool firstInput = lastInput == 0;
if (lastInput > DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() - 200)
if (lastInput > DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() - 10)
{
inputProcessed = true;
return;
Expand Down Expand Up @@ -319,7 +343,7 @@
if (File.Exists(manifest))
{
var dialog = new InstallConfirmationDialog(manifest);
dialog.PrimaryButtonClick += async (sender, e) =>

Check warning on line 346 in Pages/AppsListPage.xaml.cs

View workflow job for this annotation

GitHub Actions / build (Debug)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
dialog.Hide();
var controller = new ProgressDialog("Starting installation...", $"Installing {Packages.GetPropertiesFromManifest(manifest).DisplayName}", isIndeterminate: false).GetController();
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ For building you'll need Visual Studio 2022 with the following:
- [X] Scan for already installed EraOS/XUWP stuff
- [X] Allow for any existing installed package to be added to the applist
- [ ] Built in updater
- [ ] Controller support
- [ ] Setup program (maybe MSIX?)
- [ ] Fitting place for extra xbox-specific info
- [ ] Resize content to fit to screen
- [X] Allow for search
Expand Down
Loading