Marketplace download options and refresh button

This commit is contained in:
2025-08-27 21:31:55 -07:00
parent 98782c8ce9
commit d62ea4d09b
4 changed files with 5530 additions and 219 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
f309,f111,f141,f04c,f0e2,f077,f061,f060,f0c8,f00c,f00d,f303,f2ed f309,f111,f141,f04c,f0e2,f077,f061,f060,f0c8,f00c,f00d,f303,f2ed,f0b0

File diff suppressed because it is too large Load Diff

View File

@@ -18,10 +18,74 @@ public class IconMarketplaceDownloadIcon : MonoBehaviour
public GameObject sample; public GameObject sample;
private string statusMessage; private string statusMessage;
private Coroutine statusRoutine; private Coroutine statusRoutine;
public Button refreshButton;
public Button optionsButton;
public GameObject optionsPanel;
public Button optionsPanelSubmitButton;
public TMP_Dropdown optionsPanelSortByDropdown;
public Toggle optionsPanelPriceRangeToggle;
public TMP_InputField optionsPanelPriceRangeMinInput;
public TMP_InputField optionsPanelPriceRangeMaxInput;
public Toggle optionsPanelSearchForToggle;
public TMP_InputField optionsPanelSearchForInputField;
public bool priceRangeEnabled = false;
public string priceRangeMin = "10";
public string priceRangeMax = "250";
public bool searchForEnabled = false;
public string searchForValue = "";
public bool anyChanges = false;
void Awake() void Awake()
{ {
backButton.onClick.AddListener(() => marketplaceManager.SwitchPanel(0)); backButton.onClick.AddListener(() => marketplaceManager.SwitchPanel(0));
refreshButton.onClick.AddListener(GetIcons);
optionsButton.onClick.AddListener(() => optionsPanel.SetActive(true));
optionsPanelSubmitButton.onClick.AddListener(() =>
{
if (anyChanges)
{
anyChanges = false;
optionsPanel.SetActive(false);
GetIcons();
}
});
optionsPanelPriceRangeToggle.onValueChanged.AddListener((on) =>
{
anyChanges = true;
if (!on)
{
optionsPanelPriceRangeMinInput.text = "10";
optionsPanelPriceRangeMaxInput.text = "250";
}
optionsPanelPriceRangeMinInput.interactable = on;
optionsPanelPriceRangeMaxInput.interactable = on;
});
optionsPanelSearchForToggle.onValueChanged.AddListener((on) =>
{
anyChanges = true;
optionsPanelSearchForInputField.text = "";
optionsPanelSearchForInputField.interactable = on;
});
optionsPanelPriceRangeMinInput.onValueChanged.AddListener((value) =>
{
anyChanges = true;
priceRangeMin = value;
});
optionsPanelPriceRangeMaxInput.onValueChanged.AddListener((value) =>
{
anyChanges = true;
priceRangeMax = value;
});
optionsPanelSearchForInputField.onValueChanged.AddListener((value) =>
{
anyChanges = true;
searchForValue = value;
});
} }
internal void Load() internal void Load()
@@ -32,6 +96,8 @@ public class IconMarketplaceDownloadIcon : MonoBehaviour
async void GetIcons() async void GetIcons()
{ {
refreshButton.interactable = false;
optionsButton.interactable = false;
backButton.interactable = false; backButton.interactable = false;
foreach (Transform item in content.transform) foreach (Transform item in content.transform)
{ {
@@ -41,13 +107,21 @@ public class IconMarketplaceDownloadIcon : MonoBehaviour
} }
} }
ShowStatus("Loading..."); ShowStatus("Loading...");
using UnityWebRequest request = UnityWebRequest.Get(SensitiveInfo.SERVER_DATABASE_PREFIX + "getMarketplaceIcons.php"); EncryptedWWWForm dataForm = new();
dataForm.AddField("priceRangeEnabled", priceRangeEnabled.ToString());
dataForm.AddField("priceRangeMin", priceRangeMin);
dataForm.AddField("priceRangeMax", priceRangeMax);
dataForm.AddField("searchForEnabled", searchForEnabled.ToString());
dataForm.AddField("searchForValue", searchForValue);
using UnityWebRequest request = UnityWebRequest.Post(SensitiveInfo.SERVER_DATABASE_PREFIX + "getMarketplaceIcons.php", dataForm.form);
request.SetRequestHeader("Requester", "BerryDashClient"); request.SetRequestHeader("Requester", "BerryDashClient");
request.SetRequestHeader("ClientVersion", Application.version); request.SetRequestHeader("ClientVersion", Application.version);
request.SetRequestHeader("ClientPlatform", Application.platform.ToString()); request.SetRequestHeader("ClientPlatform", Application.platform.ToString());
await request.SendWebRequest(); await request.SendWebRequest();
if (request.result != UnityWebRequest.Result.Success) if (request.result != UnityWebRequest.Result.Success)
{ {
refreshButton.interactable = true;
optionsButton.interactable = true;
backButton.interactable = true; backButton.interactable = true;
ShowStatus("Failed to make HTTP request"); ShowStatus("Failed to make HTTP request");
return; return;
@@ -55,27 +129,19 @@ public class IconMarketplaceDownloadIcon : MonoBehaviour
string response = SensitiveInfo.Decrypt(request.downloadHandler.text, SensitiveInfo.SERVER_RECEIVE_TRANSFER_KEY); string response = SensitiveInfo.Decrypt(request.downloadHandler.text, SensitiveInfo.SERVER_RECEIVE_TRANSFER_KEY);
if (response == "-999") if (response == "-999")
{ {
backButton.interactable = true;
ShowStatus("Server error while fetching data"); ShowStatus("Server error while fetching data");
return;
} }
else if (response == "-998") else if (response == "-998")
{ {
backButton.interactable = true;
ShowStatus("Client version too outdated to access servers"); ShowStatus("Client version too outdated to access servers");
return;
} }
else if (response == "-997") else if (response == "-997")
{ {
backButton.interactable = true;
ShowStatus("Encryption/decryption issues"); ShowStatus("Encryption/decryption issues");
return;
} }
else if (response == "-996") else if (response == "-996")
{ {
backButton.interactable = true;
ShowStatus("Can't send requests on self-built instance"); ShowStatus("Can't send requests on self-built instance");
return;
} }
else else
{ {
@@ -124,6 +190,8 @@ public class IconMarketplaceDownloadIcon : MonoBehaviour
newIcon.SetActive(true); newIcon.SetActive(true);
} }
} }
refreshButton.interactable = true;
optionsButton.interactable = true;
backButton.interactable = true; backButton.interactable = true;
} }