You've already forked KF3_TranslationUpdater
Refactored code. Added update checking for KF3TL.
This commit is contained in:
38
UI/PopupMessage.cs
Normal file
38
UI/PopupMessage.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class PopupMessage : MonoBehaviour
|
||||
{
|
||||
public Text Content;
|
||||
public float MessageTime;
|
||||
|
||||
public System.Action OnFinishedAction;
|
||||
|
||||
public PopupMessage Init(string message, float time = 2)
|
||||
{
|
||||
Content.text = message;
|
||||
MessageTime = time;
|
||||
gameObject.SetActive(true);
|
||||
return this;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (MessageTime > 0)
|
||||
{
|
||||
MessageTime -= Time.deltaTime;
|
||||
|
||||
if (MessageTime <= 0)
|
||||
{
|
||||
OnFinishedAction?.Invoke();
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnClick()
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
OnFinishedAction?.Invoke();
|
||||
}
|
||||
}
|
||||
24
UI/ProgressSlider.cs
Normal file
24
UI/ProgressSlider.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ProgressSlider : MonoBehaviour
|
||||
{
|
||||
public Slider SlUpdateProgress;
|
||||
public Text TextUpdateProgress;
|
||||
|
||||
public void SetUpdateProgress(float value)
|
||||
{
|
||||
if (value == 0 || value >= 1) { SetActive(false); }
|
||||
else
|
||||
{
|
||||
SetActive(true);
|
||||
SlUpdateProgress.value = value;
|
||||
TextUpdateProgress.text = $"{Mathf.Round(value * 10000) / 100}%";
|
||||
}
|
||||
}
|
||||
|
||||
public void SetActive(bool active)
|
||||
{
|
||||
gameObject.SetActive(active);
|
||||
}
|
||||
}
|
||||
86
UI/SettingsPanel.cs
Normal file
86
UI/SettingsPanel.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SettingsPanel : MonoBehaviour
|
||||
{
|
||||
public UpdateHandler Handler;
|
||||
public Dropdown DdRepository;
|
||||
public InputField InRepositoryUrl;
|
||||
|
||||
public Text TextUpdaterVersion;
|
||||
public Text TextTranslatorVersion;
|
||||
public Text TextTranslationVersion;
|
||||
|
||||
private bool _settingsChanged;
|
||||
|
||||
public SettingsPanel Init(string updaterVersion)
|
||||
{
|
||||
_settingsChanged = false;
|
||||
TextUpdaterVersion.text = "Updater Version: " + updaterVersion;
|
||||
TextTranslatorVersion.text = "KF3TL Version:\n" + PlayerPrefs.GetString(UpdateHandler.TRANSLATOR_VER, "undefined");
|
||||
TextTranslationVersion.text = "Translation Version:\n" + PlayerPrefs.GetString(UpdateHandler.TRANSLATION_VER, "undefined");
|
||||
|
||||
int mode = PlayerPrefs.GetInt(UpdateHandler.REPO_CUSTOM_NAME, 0);
|
||||
OnSourceDropdown(mode);
|
||||
DdRepository.SetValueWithoutNotify(mode);
|
||||
|
||||
_settingsChanged = false;
|
||||
gameObject.SetActive(true);
|
||||
transform.SetAsLastSibling();
|
||||
return this;
|
||||
}
|
||||
|
||||
public void OnSourceDropdown(int choice)
|
||||
{
|
||||
switch (choice)
|
||||
{
|
||||
case 0:
|
||||
PlayerPrefs.SetInt(UpdateHandler.REPO_CUSTOM_NAME, 0);
|
||||
InRepositoryUrl.text = UpdateHandler.REPO_DEFAULT;
|
||||
InRepositoryUrl.interactable = false;
|
||||
break;
|
||||
case 1:
|
||||
PlayerPrefs.SetInt(UpdateHandler.REPO_CUSTOM_NAME, 1);
|
||||
InRepositoryUrl.text = PlayerPrefs.GetString(UpdateHandler.REPO_CUSTOM_URL, UpdateHandler.REPO_DEFAULT);
|
||||
InRepositoryUrl.interactable = true;
|
||||
break;
|
||||
}
|
||||
PlayerPrefs.Save();
|
||||
_settingsChanged = true;
|
||||
}
|
||||
|
||||
public void OnSourceEditFinished(string text)
|
||||
{
|
||||
PlayerPrefs.SetString(UpdateHandler.REPO_CUSTOM_URL, text);
|
||||
PlayerPrefs.Save();
|
||||
_settingsChanged = true;
|
||||
}
|
||||
|
||||
public void OnClearTranslatorButton()
|
||||
{
|
||||
PlayerPrefs.SetString(UpdateHandler.TRANSLATOR_VER, "undefined");
|
||||
PlayerPrefs.Save();
|
||||
TextTranslatorVersion.text = "KF3TL Version:\n" + PlayerPrefs.GetString(UpdateHandler.TRANSLATOR_VER, "undefined");
|
||||
_settingsChanged = true;
|
||||
}
|
||||
|
||||
public void OnClearTranslationButton()
|
||||
{
|
||||
PlayerPrefs.SetString(UpdateHandler.TRANSLATION_VER, "undefined");
|
||||
PlayerPrefs.Save();
|
||||
TextTranslationVersion.text = "Translation Version:\n" + PlayerPrefs.GetString(UpdateHandler.TRANSLATION_VER, "undefined");
|
||||
_settingsChanged = true;
|
||||
}
|
||||
|
||||
public void OnSettingsClose()
|
||||
{
|
||||
if (_settingsChanged)
|
||||
{
|
||||
Handler.StopAllCoroutines();
|
||||
Destroy(Handler.gameObject);
|
||||
UpdateHandler.Create();
|
||||
return;
|
||||
}
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
38
UI/UpdateAvailable.cs
Normal file
38
UI/UpdateAvailable.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UpdateAvailable : MonoBehaviour
|
||||
{
|
||||
public Text Header;
|
||||
public Text CurrentVersion;
|
||||
public Text NewVersion;
|
||||
public System.Action OnDownloadAction;
|
||||
public System.Action OnIgnoreAction;
|
||||
public System.Action OnIgnorePersistentAction;
|
||||
public Button IgnorePersistentButton;
|
||||
|
||||
public UpdateAvailable Init(string title, string currentVersion, string newVersion)
|
||||
{
|
||||
Header.text = title;
|
||||
CurrentVersion.text = "Current: " + currentVersion;
|
||||
NewVersion.text = "Update: " + newVersion;
|
||||
gameObject.SetActive(true);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void OnDownload()
|
||||
{
|
||||
OnDownloadAction?.Invoke();
|
||||
}
|
||||
|
||||
public void OnIgnore()
|
||||
{
|
||||
OnIgnoreAction?.Invoke();
|
||||
}
|
||||
|
||||
public void OnIgnorePersistent()
|
||||
{
|
||||
OnIgnorePersistentAction?.Invoke();
|
||||
}
|
||||
}
|
||||
16
UI/UpdateChecker.cs
Normal file
16
UI/UpdateChecker.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class UpdateChecker : MonoBehaviour
|
||||
{
|
||||
public UpdateHandler Handler;
|
||||
|
||||
public void OpenSettings()
|
||||
{
|
||||
Handler.OpenSettingsDetached();
|
||||
}
|
||||
|
||||
public void SetActive(bool active)
|
||||
{
|
||||
gameObject.SetActive(active);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user