Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
xmlns:system="clr-namespace:System;assembly=netstandard"
xmlns:generic="clr-namespace:BfmeFoundationProject.AllInOneLauncher.Elements.Generic"
mc:Ignorable="d"
Width="700" HorizontalAlignment="Center" VerticalAlignment="Center">
Width="840" HorizontalAlignment="Center" VerticalAlignment="Center">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
Expand Down Expand Up @@ -62,9 +62,34 @@
</elements:DropdownPicker.Options>
</elements:DropdownPicker>
<TextBlock Grid.Row="4" FontSize="14" FontWeight="SemiBold" Text="{DynamicResource InstallGamePopupLocation}" Foreground="white"/>
<generic:SmoothScrollViewer Grid.Row="6">
<StackPanel x:Name="locations"/>
</generic:SmoothScrollViewer>
<StackPanel Grid.Row="6">
<Border x:Name="LocationPicker" Background="#028BDB" CornerRadius="4" Height="58">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="1"/>
<ColumnDefinition Width="82"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Margin="12,0,10,0" VerticalAlignment="Center">
<TextBlock x:Name="SelectedLocationText" Foreground="White" FontSize="13" FontWeight="Bold" TextTrimming="CharacterEllipsis" ToolTip="{Binding Text, RelativeSource={RelativeSource Self}}"/>
<TextBlock x:Name="SelectedLocationDriveFreeSpace" Foreground="White" FontSize="11" FontWeight="Bold" Margin="0,2,0,0"/>
</StackPanel>
<Rectangle Grid.Column="1" Fill="White" Opacity="0.2" Width="1" Margin="0,10,0,10"/>
<Button Grid.Column="2" Style="{StaticResource FlatButton}" HorizontalContentAlignment="Center" Padding="0" FontWeight="Bold" Background="Transparent" Click="OnBrowseLocationClicked" Content="{DynamicResource GenericBrowse}"/>
</Grid>
</Border>
<Border x:Name="LocationWarning" Visibility="Collapsed" BorderBrush="#D69835" BorderThickness="1" Background="#24D69835" CornerRadius="4" Margin="0,8,0,0" Padding="10,8">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="8"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="!" Foreground="#FFB842" FontSize="14" FontWeight="Bold" VerticalAlignment="Top"/>
<TextBlock Grid.Column="2" x:Name="LocationWarningText" Foreground="#E6FFFFFF" FontSize="13" FontWeight="Medium" TextWrapping="Wrap"/>
</Grid>
</Border>
</StackPanel>
</Grid>
</Grid>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,82 @@
using System;
using System.Collections.Generic;
using System;
using System.IO;
using System.Linq;
using System.Windows;
using BfmeFoundationProject.AllInOneLauncher.Elements.Disk;
using BfmeFoundationProject.AllInOneLauncher.Core.Utils;
using BfmeFoundationProject.AllInOneLauncher.Elements.Generic;
using Microsoft.Win32;

namespace BfmeFoundationProject.AllInOneLauncher.Popups;

public partial class InstallGamePopup : PopupBody
{
private static readonly Dictionary<string, DriveInfo> Drives = DriveInfo.GetDrives().ToDictionary(x => x.RootDirectory.FullName);
private string selectedLocation = "";

public InstallGamePopup()
{
InitializeComponent();

locations.Children.Clear();
foreach (var drive in Drives.Values)
SetSelectedLocation(InstallLocationUtils.GetDefaultDriveRoot());
}

private void OnBrowseLocationClicked(object sender, RoutedEventArgs e)
{
OpenFolderDialog dialog = new()
{
if (!drive.IsReady)
continue;

try
{
locations.Children.Add(new Selectable()
{
Title = new LibraryDriveHeader()
{
LibraryDriveName = string.Concat(drive.VolumeLabel, " (", drive.Name.Replace(@"\", ""), ")"),
LibraryDriveSize = $"{Math.Floor(drive.AvailableFreeSpace / Math.Pow(1024, 3)):N0} GB {App.Current.FindResource("GenericFree")}",
Mini = true
},
Tag = drive.RootDirectory.FullName,
Margin = new Thickness(0, 0, 0, 5),
UseLayoutRounding = true,
SnapsToDevicePixels = true
});
}
catch { }
}
Multiselect = false
};

if (Directory.Exists(selectedLocation))
dialog.InitialDirectory = selectedLocation;
else if (InstallLocationUtils.TryGetDrive(selectedLocation, out DriveInfo? drive) && drive != null)
dialog.InitialDirectory = drive.RootDirectory.FullName;

if (dialog.ShowDialog() == true)
SetSelectedLocation(dialog.FolderName);
}

private void OnInstallClicked(object sender, RoutedEventArgs e) => Submit(LanguageDropdown.SelectedValue, Selectable.GetSelectedTagInContainer(locations)!.ToString()!);
private void OnInstallClicked(object sender, RoutedEventArgs e)
{
if (InstallLocationUtils.IsValidLocation(selectedLocation))
Submit(LanguageDropdown.SelectedValue, selectedLocation);
}

private void OnCancelClicked(object sender, RoutedEventArgs e) => Dismiss();
}

private void SetSelectedLocation(string location)
{
selectedLocation = InstallLocationUtils.NormalizeLocation(location);

SelectedLocationText.Text = selectedLocation;
SelectedLocationText.ToolTip = selectedLocation;

ButtonAccept.IsEnabled = InstallLocationUtils.IsValidLocation(selectedLocation);
UpdateDriveSpace();
UpdateWarning();
}

private void UpdateDriveSpace()
{
SelectedLocationDriveFreeSpace.Text = "";

if (!InstallLocationUtils.TryGetDrive(selectedLocation, out DriveInfo? drive) || drive == null)
return;

try
{
if (drive.IsReady)
SelectedLocationDriveFreeSpace.Text = $"{Math.Floor(drive.AvailableFreeSpace / Math.Pow(1024, 3)):N0} GB {App.Current.FindResource("GenericFree")}";
}
catch
{
SelectedLocationDriveFreeSpace.Text = "";
}
}

private void UpdateWarning()
{
bool showWarning = InstallLocationUtils.IsInProgramFilesFolder(selectedLocation);

LocationWarningText.Text = showWarning ? App.Current.FindResource("InstallGamePopupProgramFilesWarning")?.ToString() ?? "" : "";
LocationWarning.Visibility = showWarning ? Visibility.Visible : Visibility.Collapsed;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<system:String x:Key="GenericLoading">تحميل</system:String>
<system:String x:Key="GenericPlay">تشغيل</system:String>
<system:String x:Key="GenericAdd">إضافة</system:String>
<system:String x:Key="GenericBrowse">استعراض</system:String>
<system:String x:Key="GenericFree">مجاني</system:String>
<system:String x:Key="GenericConfirm">تأكيد</system:String>
<system:String x:Key="GenericYes">نعم</system:String>
Expand Down Expand Up @@ -113,6 +114,7 @@
<system:String x:Key="InstallGamePopupTitle">تثبيت اللعبة</system:String>
<system:String x:Key="InstallGamePopupLanguage">اللغة</system:String>
<system:String x:Key="InstallGamePopupLocation">الموقع</system:String>
<system:String x:Key="InstallGamePopupProgramFilesWarning">من المستحسن التثبيت خارج مجلدات ملفات البرامج لتجنب مشكلات الأذونات المحتملة.</system:String>

<!--===================== PackagePagePopup =====================-->
<system:String x:Key="PackagePagePopupAddToLibrary">إضافة إلى المكتبة</system:String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<system:String x:Key="GenericLoading">LADEN</system:String>
<system:String x:Key="GenericPlay">SPIELEN</system:String>
<system:String x:Key="GenericAdd">HINZUFÜGEN</system:String>
<system:String x:Key="GenericBrowse">DURCHSUCHEN</system:String>
<system:String x:Key="GenericFree">FREI</system:String>
<system:String x:Key="GenericConfirm">BESTÄTIGEN</system:String>
<system:String x:Key="GenericYes">JA</system:String>
Expand Down Expand Up @@ -124,6 +125,7 @@
<system:String x:Key="InstallGamePopupTitle">SPIEL INSTALLIEREN</system:String>
<system:String x:Key="InstallGamePopupLanguage">Sprache</system:String>
<system:String x:Key="InstallGamePopupLocation">Standort</system:String>
<system:String x:Key="InstallGamePopupProgramFilesWarning">Es wird empfohlen, außerhalb der Programme-Ordner zu installieren, um mögliche Berechtigungsprobleme zu vermeiden.</system:String>

<!--===================== PackagePagePopup =====================-->
<system:String x:Key="PackagePagePopupAddToLibrary">ZUR BIBLIOTHEK HINZUFÜGEN</system:String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<system:String x:Key="GenericLoading">LOADING</system:String>
<system:String x:Key="GenericPlay">PLAY</system:String>
<system:String x:Key="GenericAdd">ADD</system:String>
<system:String x:Key="GenericBrowse">BROWSE</system:String>
<system:String x:Key="GenericFree">FREE</system:String>
<system:String x:Key="GenericConfirm">CONFIRM</system:String>
<system:String x:Key="GenericYes">YES</system:String>
Expand Down Expand Up @@ -126,6 +127,7 @@
<system:String x:Key="InstallGamePopupTitle">INSTALL GAME</system:String>
<system:String x:Key="InstallGamePopupLanguage">Language</system:String>
<system:String x:Key="InstallGamePopupLocation">Location</system:String>
<system:String x:Key="InstallGamePopupProgramFilesWarning">It is recommended to install outside Program Files folders to avoid potential permission issues.</system:String>

<!--===================== PackagePagePopup =====================-->
<system:String x:Key="PackagePagePopupAddToLibrary">ADD TO LIBRARY</system:String>
Expand All @@ -151,4 +153,4 @@
<system:String x:Key="ErrorPopupTitle">ERROR</system:String>
<system:String x:Key="ErrorPopupCopyError">Copy text</system:String>
<system:String x:Key="ErrorPopupErrorCopied">Copied!</system:String>
</ResourceDictionary>
</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<system:String x:Key="GenericLoading">CARGANDO</system:String>
<system:String x:Key="GenericPlay">JUGAR</system:String>
<system:String x:Key="GenericAdd">AÑADIR</system:String>
<system:String x:Key="GenericBrowse">EXAMINAR</system:String>
<system:String x:Key="GenericFree">GRATIS</system:String>
<system:String x:Key="GenericConfirm">CONFIRMAR</system:String>
<system:String x:Key="GenericYes">SÍ</system:String>
Expand Down Expand Up @@ -113,6 +114,7 @@
<system:String x:Key="InstallGamePopupTitle">INSTALAR JUEGO</system:String>
<system:String x:Key="InstallGamePopupLanguage">Idioma</system:String>
<system:String x:Key="InstallGamePopupLocation">Ubicación</system:String>
<system:String x:Key="InstallGamePopupProgramFilesWarning">Se recomienda instalar fuera de las carpetas de programas para evitar posibles problemas de permisos.</system:String>

<!--===================== PackagePagePopup =====================-->
<system:String x:Key="PackagePagePopupAddToLibrary">AÑADIR A LA BIBLIOTECA</system:String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<system:String x:Key="GenericLoading">CHARGEMENT</system:String>
<system:String x:Key="GenericPlay">JOUER</system:String>
<system:String x:Key="GenericAdd">AJOUTER</system:String>
<system:String x:Key="GenericBrowse">PARCOURIR</system:String>
<system:String x:Key="GenericFree">GRATUIT</system:String>
<system:String x:Key="GenericConfirm">CONFIRMER</system:String>
<system:String x:Key="GenericYes">OUI</system:String>
Expand Down Expand Up @@ -113,6 +114,7 @@
<system:String x:Key="InstallGamePopupTitle">INSTALLER LE JEU</system:String>
<system:String x:Key="InstallGamePopupLanguage">Langue</system:String>
<system:String x:Key="InstallGamePopupLocation">Emplacement</system:String>
<system:String x:Key="InstallGamePopupProgramFilesWarning">Il est recommandé d’installer hors des dossiers de programmes pour éviter d’éventuels problèmes d’autorisations.</system:String>

<!--===================== PackagePagePopup =====================-->
<system:String x:Key="PackagePagePopupAddToLibrary">AJOUTER À LA BIBLIOTHÈQUE</system:String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<system:String x:Key="GenericLoading">BETÖLTÉS</system:String>
<system:String x:Key="GenericPlay">JÁTSZANI</system:String>
<system:String x:Key="GenericAdd">HOZZÁADÁS</system:String>
<system:String x:Key="GenericBrowse">TALLÓZÁS</system:String>
<system:String x:Key="GenericFree">SZABAD</system:String>
<system:String x:Key="GenericConfirm">IGEN</system:String>
<system:String x:Key="GenericYes">IGEN</system:String>
Expand Down Expand Up @@ -113,6 +114,7 @@
<system:String x:Key="InstallGamePopupTitle">JÁTÉK TELEPÍTÉSE</system:String>
<system:String x:Key="InstallGamePopupLanguage">Nyelv</system:String>
<system:String x:Key="InstallGamePopupLocation">Helyszín</system:String>
<system:String x:Key="InstallGamePopupProgramFilesWarning">Javasolt a programfájlok mappáin kívül telepíteni az esetleges engedélyproblémák elkerülése érdekében.</system:String>

<!--===================== PackagePagePopup =====================-->
<system:String x:Key="PackagePagePopupAddToLibrary">KÖNYVTÁRBAN HOZZÁADÁS</system:String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<system:String x:Key="GenericLoading">CARICAMENTO</system:String>
<system:String x:Key="GenericPlay">GIOCA</system:String>
<system:String x:Key="GenericAdd">AGGIUNGI</system:String>
<system:String x:Key="GenericBrowse">SFOGLIA</system:String>
<system:String x:Key="GenericFree">GRATIS</system:String>
<system:String x:Key="GenericConfirm">CONFERMA</system:String>
<system:String x:Key="GenericYes">SÌ</system:String>
Expand Down Expand Up @@ -113,6 +114,7 @@
<system:String x:Key="InstallGamePopupTitle">INSTALLA GIOCO</system:String>
<system:String x:Key="InstallGamePopupLanguage">Lingua</system:String>
<system:String x:Key="InstallGamePopupLocation">Posizione</system:String>
<system:String x:Key="InstallGamePopupProgramFilesWarning">Si consiglia di installare fuori dalle cartelle dei programmi per evitare potenziali problemi di autorizzazioni.</system:String>

<!--===================== PackagePagePopup =====================-->
<system:String x:Key="PackagePagePopupAddToLibrary">AGGIUNGI ALLA BIBLIOTECA</system:String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<system:String x:Key="GenericLoading">LADEN</system:String>
<system:String x:Key="GenericPlay">SPELEN</system:String>
<system:String x:Key="GenericAdd">TOEVOEGEN</system:String>
<system:String x:Key="GenericBrowse">BLADEREN</system:String>
<system:String x:Key="GenericFree">GRATIS</system:String>
<system:String x:Key="GenericConfirm">BEVESTIGEN</system:String>
<system:String x:Key="GenericYes">JA</system:String>
Expand Down Expand Up @@ -113,6 +114,7 @@
<system:String x:Key="InstallGamePopupTitle">GAME INSTALLEREN</system:String>
<system:String x:Key="InstallGamePopupLanguage">Taal</system:String>
<system:String x:Key="InstallGamePopupLocation">Locatie</system:String>
<system:String x:Key="InstallGamePopupProgramFilesWarning">Het wordt aanbevolen buiten de programmamappen te installeren om mogelijke machtigingsproblemen te voorkomen.</system:String>

<!--===================== PackagePagePopup =====================-->
<system:String x:Key="PackagePagePopupAddToLibrary">TOEVOEGEN AAN BIBLIOTHEEK</system:String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<system:String x:Key="GenericLoading">LASTER</system:String>
<system:String x:Key="GenericPlay">SPILL</system:String>
<system:String x:Key="GenericAdd">LEGG TIL</system:String>
<system:String x:Key="GenericBrowse">BLA GJENNOM</system:String>
<system:String x:Key="GenericFree">GRATIS</system:String>
<system:String x:Key="GenericConfirm">BEKREFT</system:String>
<system:String x:Key="GenericYes">JA</system:String>
Expand Down Expand Up @@ -113,6 +114,7 @@
<system:String x:Key="InstallGamePopupTitle">INSTALLER SPILL</system:String>
<system:String x:Key="InstallGamePopupLanguage">Språk</system:String>
<system:String x:Key="InstallGamePopupLocation">Beliggenhet</system:String>
<system:String x:Key="InstallGamePopupProgramFilesWarning">Det anbefales å installere utenfor programmappene for å unngå mulige tillatelsesproblemer.</system:String>

<!--===================== PackagePagePopup =====================-->
<system:String x:Key="PackagePagePopupAddToLibrary">LEGG TIL I BIBLIOTEKET</system:String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<system:String x:Key="GenericLoading">ŁADOWANIE</system:String>
<system:String x:Key="GenericPlay">GRAJ</system:String>
<system:String x:Key="GenericAdd">DODAJ</system:String>
<system:String x:Key="GenericBrowse">PRZEGLĄDAJ</system:String>
<system:String x:Key="GenericFree">ZA DARMO</system:String>
<system:String x:Key="GenericConfirm">POTWIERDŹ</system:String>
<system:String x:Key="GenericYes">TAK</system:String>
Expand Down Expand Up @@ -113,6 +114,7 @@
<system:String x:Key="InstallGamePopupTitle">INSTALUJ GRĘ</system:String>
<system:String x:Key="InstallGamePopupLanguage">Język</system:String>
<system:String x:Key="InstallGamePopupLocation">Lokalizacja</system:String>
<system:String x:Key="InstallGamePopupProgramFilesWarning">Zaleca się instalowanie poza folderami programów, aby uniknąć potencjalnych problemów z uprawnieniami.</system:String>

<!--===================== PackagePagePopup =====================-->
<system:String x:Key="PackagePagePopupAddToLibrary">DODAJ DO BIBLIOTEKI</system:String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<system:String x:Key="GenericLoading">ЗАГРУЗКА</system:String>
<system:String x:Key="GenericPlay">ИГРАТЬ</system:String>
<system:String x:Key="GenericAdd">ДОБАВИТЬ</system:String>
<system:String x:Key="GenericBrowse">ОБЗОР</system:String>
<system:String x:Key="GenericFree">БЕСПЛАТНО</system:String>
<system:String x:Key="GenericConfirm">ПОДТВЕРДИТЬ</system:String>
<system:String x:Key="GenericYes">ДА</system:String>
Expand Down Expand Up @@ -113,6 +114,7 @@
<system:String x:Key="InstallGamePopupTitle">УСТАНОВКА ИГРЫ</system:String>
<system:String x:Key="InstallGamePopupLanguage">Язык</system:String>
<system:String x:Key="InstallGamePopupLocation">Местоположение</system:String>
<system:String x:Key="InstallGamePopupProgramFilesWarning">Рекомендуется устанавливать вне папок программ, чтобы избежать возможных проблем с разрешениями.</system:String>

<!--===================== PackagePagePopup =====================-->
<system:String x:Key="PackagePagePopupAddToLibrary">ДОБАВИТЬ В БИБЛИОТЕКУ</system:String>
Expand Down
Loading