Skip to content

Commit

Permalink
Minor update to fix the flag editor malfunctioning
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximumADHD committed Dec 18, 2024
1 parent 3d289f0 commit cd3a344
Show file tree
Hide file tree
Showing 8 changed files with 290 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Config/LatestReleaseTag.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2024.03.02
v2024.12.18
4 changes: 4 additions & 0 deletions ProjectSrc/Bootstrapper/StudioBootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class StudioBootstrapper

public Channel Channel { get; set; } = "LIVE";
public string OverrideStudioDirectory { get; set; } = "";
public string OverrideGuid { get; set; } = "";

public bool CanShutdownStudio { get; set; } = true;
public bool CanForceStudioShutdown { get; set; } = false;
Expand Down Expand Up @@ -768,6 +769,9 @@ public async Task<bool> Bootstrap(string targetVersion = "")
var getVersionInfo = GetCurrentVersionInfo(currentChannel, versionRegistry, targetVersion);
ClientVersionInfo versionInfo = await getVersionInfo.ConfigureAwait(true);

if (OverrideGuid != "")
versionInfo = new ClientVersionInfo(versionInfo.Channel, versionInfo.Version, OverrideGuid);

string studioDir = GetLocalStudioDirectory();
buildVersion = versionInfo.VersionGuid;

Expand Down
71 changes: 62 additions & 9 deletions ProjectSrc/Forms/FlagEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using System.Windows.Forms;

Expand Down Expand Up @@ -180,11 +181,15 @@ private void refreshFlags()

private async void InitializeEditor()
{
string localAppData = Environment.GetEnvironmentVariable("LocalAppData");
var flagNames = new HashSet<string>();

var studioPath = StudioBootstrapper.GetStudioPath();
FlagScanner.PerformScan(studioPath, flagNames);

string localAppData = Environment.GetEnvironmentVariable("LocalAppData");
string settingsDir = Path.Combine(localAppData, "Roblox", "ClientSettings");
string settingsPath = Path.Combine(settingsDir, "StudioAppSettings.json");

string settingsPath = Path.Combine(settingsDir, "StudioAppSettings.json");
string lastExecVersion = versionRegistry.LastExecutedVersion;
string versionGuid = versionRegistry.VersionGuid;

Expand Down Expand Up @@ -228,7 +233,6 @@ private async void InitializeEditor()
}

// Initialize flag browser
string[] flagNames = flagRegistry.Keys.ToArray();
string[] flagNameStrings = Array.Empty<string>();

string settings = File.ReadAllText(settingsPath);
Expand All @@ -241,6 +245,56 @@ private async void InitializeEditor()
json = data.ToObject<Dictionary<string, string>>();
}

/*
Dictionary<string, string> webJson;
using (WebClient http = new WebClient())
{
http.Headers.Set("UserAgent", "RobloxStudioModManager");
var rawData = await http.DownloadStringTaskAsync($"https://clientsettingscdn.roblox.com/v2/settings/application/PCStudioApp");
using (var reader = new StringReader(rawData))
using (var jsonReader = new JsonTextReader(reader))
{
var data = JObject.Load(jsonReader);
var appSettings = data["applicationSettings"];
webJson = appSettings.ToObject<Dictionary<string, string>>();
}
}*/

foreach (var key in flagNames)
{
if (!json.ContainsKey(key))
{
string flagClass = "";

if (key.StartsWith("SF"))
flagClass = "SF";
else if (key.StartsWith("DF"))
flagClass = "DF";
else if (key.StartsWith("F"))
flagClass = "F";

if (flagClass != "")
{
var prefix = key.Substring(flagClass.Length);

foreach (var pair in flagTypes)
{
if (prefix.StartsWith(pair.Key))
{
json.Add(key, pair.Value);
break;
}
}
}
else
{
json.Add(key, "??");
}
}
}

int numFlags = json.Count;
var flagSetup = new List<FVariable>(numFlags);
var autoComplete = new AutoCompleteStringCollection();
Expand All @@ -267,14 +321,17 @@ private async void InitializeEditor()
if (!flagRegistry.TryGetValue(key, out var flag))
flag = new FVariable(key, value);

autoComplete.Add(flag.Name);
if (flag.Type == "")
continue;

autoComplete.Add(flag.Key);
flagSetup.Add(flag);
}

flagSearchFilter.AutoCompleteCustomSource = autoComplete;

allFlags = flagSetup
.OrderBy(flag => flag.Name)
.OrderBy(flag => flag.Key)
.ToList();

refreshFlags();
Expand Down Expand Up @@ -468,10 +525,6 @@ private void overrideDataGridView_CellEndEdit(object sender, DataGridViewCellEve
{
badInput = !int.TryParse(value, out int _);
}
else if (flagType.EndsWith("Log", format))
{
badInput = !byte.TryParse(value, out byte _);
}

if (flagLookup.ContainsKey(flagKey))
{
Expand Down
5 changes: 5 additions & 0 deletions ProjectSrc/Forms/Launcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,16 @@ private async void editExplorerIcons_Click(object sender, EventArgs e)
private async void launchStudio_Click(object sender = null, EventArgs e = null)
{
// var channel = getSelectedChannel();
var overrideGuid = "";

if (args != null && args.Length > 0 && args[0].StartsWith("version-"))
overrideGuid = args[0];

var bootstrapper = new StudioBootstrapper
{
ForceInstall = forceRebuild.Checked,
ApplyModManagerPatches = true,
OverrideGuid = overrideGuid,
Channel = channel
};

Expand Down
12 changes: 4 additions & 8 deletions ProjectSrc/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static class Program
public const string RepoOwner = "MaximumADHD";
public const string RepoName = "Roblox-Studio-Mod-Manager";

public const string ReleaseTag = "v2024.03.02";
public const string ReleaseTag = "v2024.12.18";
public static readonly string BaseConfigUrl = $"https://raw.githubusercontent.com/{RepoOwner}/{RepoName}/{RepoBranch}/Config/";

public static readonly RegistryKey LegacyRegistry = Registry.CurrentUser.GetSubKey("SOFTWARE", "Roblox Studio Mod Manager");
Expand Down Expand Up @@ -155,14 +155,10 @@ static void Main(string[] args)
File.WriteAllText(stateFile, json);
}

try
{
State = JsonConvert.DeserializeObject<ModManagerState>(json);
}
catch
{
State = JsonConvert.DeserializeObject<ModManagerState>(json);

if (State == null)
State = new ModManagerState();
}

// Make sure HTTPS uses TLS 1.2
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
Expand Down
1 change: 1 addition & 0 deletions ProjectSrc/RobloxStudioModManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
<Compile Include="History\*.cs" />
<Compile Include="Utility\AppState.cs" />
<Compile Include="Utility\CustomFlag.cs" />
<Compile Include="Utility\FlagScanner.cs" />
<Compile Include="Utility\FVariable.cs" />
<Compile Include="Utility\KnownRoot.cs" />
<Compile Include="Utility\OrdinalSortJson.cs" />
Expand Down
Loading

0 comments on commit cd3a344

Please sign in to comment.