Skip to content

Commit db32ae7

Browse files
committed
fix changing domain issue
now it will synchronize domain with a settings file hosted on github for an easier way to change it if needed
1 parent d40a92e commit db32ae7

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.vs/
22
bin/
33
obj/
4+
*.user

FloatTool/App.xaml.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
- Copyright(C) 2022 Prevter
2+
- Copyright(C) 2022-2023 Prevter
33
-
44
- This program is free software: you can redistribute it and/or modify
55
- it under the terms of the GNU General Public License as published by
@@ -112,8 +112,10 @@ public App()
112112
e.SetObserved();
113113
};
114114

115-
//Get path for %AppData%
116-
var appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
115+
Utils.GetApiUrl();
116+
117+
//Get path for %AppData%
118+
var appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
117119
var subfolder = "floattool";
118120
var combined = Path.Combine(appdata, subfolder);
119121

FloatTool/Common/Utils.cs

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
- Copyright(C) 2022 Prevter
2+
- Copyright(C) 2022-2023 Prevter
33
-
44
- This program is free software: you can redistribute it and/or modify
55
- it under the terms of the GNU General Public License as published by
@@ -23,6 +23,7 @@
2323
using System.Diagnostics;
2424
using System.IO;
2525
using System.Linq;
26+
using System.Net;
2627
using System.Net.Http;
2728
using System.Text.RegularExpressions;
2829
using System.Threading;
@@ -99,9 +100,22 @@ public static string FirstCharToUpper(this string input) =>
99100

100101
public static class Utils
101102
{
102-
public const string API_URL = "https://prevter.ml/api/floattool";
103+
public static string API_URL = "";
104+
public static string HOME_URL = "";
103105
private static readonly HttpClient Client = new();
104106

107+
/// <summary>
108+
/// Fetches home URL to allow for dynamic updates
109+
/// </summary>
110+
public static void GetApiUrl()
111+
{
112+
string global_settings_url = "https://raw.githubusercontent.com/Prevter/Prevter/main/globals.json";
113+
string global_settings = Client.GetStringAsync(global_settings_url).Result;
114+
dynamic json = JsonConvert.DeserializeObject(global_settings);
115+
HOME_URL = json["home_url"] + "floattool";
116+
API_URL = json["home_url"] + "api/floattool";
117+
}
118+
105119
public static async Task<double> GetWearFromInspectURL(string inspect_url)
106120
{
107121
string url = AppHelpers.Settings.FloatAPI switch

FloatTool/Views/MainWindow.xaml.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
- Copyright(C) 2022 Prevter
2+
- Copyright(C) 2022-2023 Prevter
33
-
44
- This program is free software: you can redistribute it and/or modify
55
- it under the terms of the GNU General Public License as published by
@@ -119,10 +119,10 @@ private void Window_KeyUp(object sender, KeyEventArgs e)
119119
switch (e.Key)
120120
{
121121
case Key.F1:
122-
Process.Start(new ProcessStartInfo { FileName = "https://prevter.ml/floattool/table", UseShellExecute = true });
122+
Process.Start(new ProcessStartInfo { FileName = $"{Utils.HOME_URL}/table", UseShellExecute = true });
123123
break;
124124
case Key.F2:
125-
Process.Start(new ProcessStartInfo { FileName = "https://prevter.ml/floattool/tools", UseShellExecute = true });
125+
Process.Start(new ProcessStartInfo { FileName = $"{Utils.HOME_URL}/tools", UseShellExecute = true });
126126
break;
127127
case Key.F3:
128128
string skin = $"{ViewModel.WeaponName} | {ViewModel.SkinName}";

0 commit comments

Comments
 (0)