added something to send global messages to all users

This commit is contained in:
Asval 2019-11-14 22:15:07 +01:00
parent 35c3a263e6
commit 85a581a551
6 changed files with 48 additions and 11 deletions

View File

@ -155,8 +155,9 @@ namespace FModel
//LOAD AND EXTRACT DIFF
if (MI_DifferenceMode.IsChecked && MI_UpdateMode.IsChecked)
{
await PAKsLoader.LoadDifference();
await AssetsLoader.ExtractUpdateMode();
await PAKsLoader.LoadDifference(true);
if (PAKsLoader.umIsOk)
await AssetsLoader.ExtractUpdateMode();
}
}
private void MI_ReloadAESs_Click(object sender, RoutedEventArgs e)

View File

@ -129,7 +129,6 @@ namespace FModel.Methods.Assets
public static async Task ExtractUpdateMode()
{
new UpdateMyProcessEvents("", "").Update();
FWindow.FMain.MI_UpdateMode.IsEnabled = true;
FWindow.FMain.Button_Extract.IsEnabled = false;
FWindow.FMain.Button_Stop.IsEnabled = true;
FWindow.FMain.AssetPropertiesBox_Main.Text = string.Empty;
@ -188,6 +187,7 @@ namespace FModel.Methods.Assets
FWindow.FMain.MI_Auto_Save_Images.IsChecked = false;
FWindow.FMain.Button_Extract.IsEnabled = true;
FWindow.FMain.Button_Stop.IsEnabled = false;
FWindow.FMain.MI_Auto_Save_Images.IsChecked = false;
FProp.Default.FOpenSounds = sound;
new UpdateMyProcessEvents("All assets have been extracted successfully", "Success").Update();
}

View File

@ -7,6 +7,9 @@ using System.Windows;
using System.Windows.Controls;
using FProp = FModel.Properties.Settings;
/// <summary>
/// GLOBAL MESSAGES ARE CHECKED IN THE BACKUP ENDPOINT (This might become the main endpoint soon anyway)
/// </summary>
namespace FModel.Methods.BackupsManager
{
static class RegisterDownloadedBackups

View File

@ -14,6 +14,7 @@ namespace FModel.Methods.PAKs
{
static class PAKsLoader
{
public static bool umIsOk { get; set; }
private static readonly string PAK_PATH = FProp.Default.FPak_Path;
private static SortedTreeViewWindowViewModel srt { get; set; }
@ -78,7 +79,7 @@ namespace FModel.Methods.PAKs
FWindow.FMain.MI_BackupPAKs.IsEnabled = true;
FWindow.FMain.MI_DifferenceMode.IsEnabled = true;
}
public static async Task LoadDifference()
public static async Task LoadDifference(bool updateMode = false)
{
FWindow.FMain.MI_LoadOnePAK.IsEnabled = false;
FWindow.FMain.MI_LoadAllPAKs.IsEnabled = false;
@ -90,6 +91,7 @@ namespace FModel.Methods.PAKs
FWindow.FMain.ImageBox_Main.Source = null;
ListBoxUtility.FilesListWithoutPath = null;
FWindow.FMain.ListBox_Main.Items.Clear();
umIsOk = false;
FWindow.FMain.TreeView_Main.IsEnabled = false;
await Task.Run(async () =>
@ -97,7 +99,7 @@ namespace FModel.Methods.PAKs
PAKEntries.PAKToDisplay = new Dictionary<string, FPakEntry[]>();
LoadPAKFiles(true);
await LoadBackupFile();
await LoadBackupFile(updateMode);
}).ContinueWith(TheTask =>
{
@ -229,7 +231,7 @@ namespace FModel.Methods.PAKs
new UpdateMyProcessEvents(!bAllPAKs ? PAK_PATH + "\\" + FWindow.FCurrentPAK : PAK_PATH, "Success").Update();
}
private static async Task LoadBackupFile()
private static async Task LoadBackupFile(bool updateMode = false)
{
OpenFileDialog openFiledialog = new OpenFileDialog();
openFiledialog.Title = "Choose your Backup File";
@ -292,16 +294,17 @@ namespace FModel.Methods.PAKs
await FWindow.FMain.Dispatcher.InvokeAsync(() =>
{
new UpdateMyProcessEvents("All PAK files have been compared successfully", "Success").Update();
FWindow.FMain.TreeView_Main.IsEnabled = true;
FWindow.FMain.MI_LoadAllPAKs.IsEnabled = true;
FWindow.FMain.MI_BackupPAKs.IsEnabled = true;
FWindow.FMain.MI_DifferenceMode.IsEnabled = true;
if (updateMode) { FWindow.FMain.MI_UpdateMode.IsEnabled = true; }
});
//PRINT REMOVED IF NO FILE SIZE CHECK
if (!FProp.Default.FDiffFileSize)
{
new UpdateMyProcessEvents("Checking deleted items", "Waiting").Update();
IEnumerable<FPakEntry> removedAssets = BackupEntries.Except(LocalEntries.ToArray());
List<string> removedItems = new List<string>();
@ -317,6 +320,9 @@ namespace FModel.Methods.PAKs
removedItems.Distinct().ToList().ForEach(e => new UpdateMyConsole($" - {e.Substring(1)}", CColors.White, true).Append());
}
}
new UpdateMyProcessEvents("All PAK files have been compared successfully", "Success").Update();
umIsOk = true;
}
}
else
@ -324,6 +330,20 @@ namespace FModel.Methods.PAKs
new UpdateMyConsole("You change your mind pretty fast but it's fine ", CColors.White).Append();
new UpdateMyConsole("all paks have been loaded instead", CColors.Blue, true).Append();
FillTreeView(true);
await FWindow.FMain.Dispatcher.InvokeAsync(() =>
{
FWindow.FMain.TreeView_Main.IsEnabled = true;
FWindow.FMain.MI_LoadAllPAKs.IsEnabled = true;
FWindow.FMain.MI_BackupPAKs.IsEnabled = true;
FWindow.FMain.MI_DifferenceMode.IsEnabled = true;
FWindow.FMain.MI_DifferenceMode.IsChecked = false;
if (updateMode)
{
FWindow.FMain.MI_UpdateMode.IsEnabled = true;
FWindow.FMain.MI_UpdateMode.IsChecked = false;
}
});
}
}
}

View File

@ -1,6 +1,7 @@
using Newtonsoft.Json.Linq;
using RestSharp;
using System.Collections.Generic;
using System.Linq;
using FProp = FModel.Properties.Settings;
namespace FModel.Methods.Utilities
@ -21,12 +22,24 @@ namespace FModel.Methods.Utilities
{
if (DLLImport.IsInternetAvailable())
{
string EndpointContent = GetEndpoint("https://dl.dropbox.com/s/mi7oyjywdtatxb0/FModel3_Backups.json?dl=0");
string EndpointContent = GetEndpoint("https://dl.dropbox.com/s/0ykcue03qweb98r/FModel.json?dl=0");
if (!string.IsNullOrEmpty(EndpointContent))
{
List<BackupInfosEntry> ListToReturn = new List<BackupInfosEntry>();
JArray array = JArray.Parse(EndpointContent);
foreach (JProperty prop in array.Children<JObject>().Properties())
JToken FData = JToken.Parse(EndpointContent);
//GLOBAL MESSAGES
JArray FGMessages = FData["Global_Messages"].Value<JArray>();
if (!string.IsNullOrEmpty(FGMessages[0]["Message"].Value<string>()))
{
foreach (JToken t in FGMessages)
{
new UpdateMyConsole(t["Message"].Value<string>(), t["Color"].Value<string>(), t["bNewLine"].Value<bool>()).Append();
}
}
//BACKUPS
foreach (JProperty prop in FData["Backups"].Value<JObject>().Properties())
{
ListToReturn.Add(new BackupInfosEntry(prop.Name, prop.Value.Value<string>()));
}

View File

@ -5,9 +5,9 @@ using System;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Media;
using FProp = FModel.Properties.Settings;
using System.Diagnostics;
using FModel.Methods.MessageBox;
using FProp = FModel.Properties.Settings;
namespace FModel.Methods.Utilities
{