Settings are now saved
Tutorial is only displayed on first start (when no settings file is found)
This commit is contained in:
@@ -1819,7 +1819,7 @@ MonoBehaviour:
|
||||
m_Top: 0
|
||||
m_Bottom: 0
|
||||
m_ChildAlignment: 0
|
||||
m_Spacing: 16
|
||||
m_Spacing: 12
|
||||
m_ChildForceExpandWidth: 1
|
||||
m_ChildForceExpandHeight: 1
|
||||
m_ChildControlWidth: 1
|
||||
@@ -2977,7 +2977,7 @@ RectTransform:
|
||||
m_AnchorMin: {x: 0.5, y: 0}
|
||||
m_AnchorMax: {x: 0.5, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 300}
|
||||
m_SizeDelta: {x: 400, y: 350}
|
||||
m_SizeDelta: {x: 400, y: 420}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!224 &224877065014001232
|
||||
RectTransform:
|
||||
|
||||
@@ -33,11 +33,12 @@ namespace RothenburgAR
|
||||
UIManager.Instance.Initialize();
|
||||
UIManager.Instance.UICamera = UICamera;
|
||||
UIManager.Instance.UIObjectCamera = UIObjectCamera;
|
||||
UIManager.Instance.InitStartView();
|
||||
|
||||
StartCoroutine(UIManager.Instance.InitStartView());
|
||||
|
||||
InputManager.Instance.Initialize();
|
||||
var initDisplayManagerSingleton = DisplayManager.Instance;
|
||||
var initUpdaterSingleton = UpdaterBehaviour.Instance;
|
||||
var initUpdaterSingleton = UpdateManager.Instance;
|
||||
}
|
||||
|
||||
void InitializeData()
|
||||
|
||||
@@ -40,6 +40,11 @@ namespace RothenburgAR.Common
|
||||
get { return Directory.Exists(ExhibitionPath); }
|
||||
}
|
||||
|
||||
public static string SettingsFilePath
|
||||
{
|
||||
get { return Path.Combine(DataPath, "settings.json"); }
|
||||
}
|
||||
|
||||
public static string GetXmlPathFromDirectoryPath(string poiDirectory)
|
||||
{
|
||||
string directoryName = new DirectoryInfo(poiDirectory).Name;
|
||||
|
||||
51
Assets/RothenburgAR/Scripts/Common/SettingsManager.cs
Normal file
51
Assets/RothenburgAR/Scripts/Common/SettingsManager.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using RothenburgAR.UI;
|
||||
|
||||
namespace RothenburgAR.Common
|
||||
{
|
||||
class SettingsManager : Singleton<SettingsManager>
|
||||
{
|
||||
public bool? IsInitialized { get; private set; }
|
||||
|
||||
internal class Settings
|
||||
{
|
||||
public string Language { get; set; }
|
||||
public FontsizeSetting Fontsize { get; set; }
|
||||
public int ColorschemeID { get; set; }
|
||||
}
|
||||
|
||||
private Settings settings;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
if (File.Exists(PathHelper.SettingsFilePath))
|
||||
{
|
||||
//load settings file into settings object if existent
|
||||
var json = File.ReadAllText(PathHelper.SettingsFilePath);
|
||||
settings = JsonConvert.DeserializeObject<Settings>(json);
|
||||
|
||||
LanguageManager.Instance.CurrentLanguageKey = settings.Language;
|
||||
UIColorSchemeManager.Instance.SetUiColorScheme(settings.ColorschemeID);
|
||||
FontsizeManager.Instance.CurrentFontsizeSetting = settings.Fontsize;
|
||||
|
||||
IsInitialized = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
settings = new Settings();
|
||||
IsInitialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void PersistSettings()
|
||||
{
|
||||
settings.Language = LanguageManager.Instance.CurrentLanguageKey;
|
||||
settings.ColorschemeID = UIColorSchemeManager.Instance.CurrentColorSchemeID;
|
||||
settings.Fontsize = FontsizeManager.Instance.CurrentFontsizeSetting;
|
||||
|
||||
var json = JsonConvert.SerializeObject(settings);
|
||||
File.WriteAllText(PathHelper.SettingsFilePath, json);
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Assets/RothenburgAR/Scripts/Common/SettingsManager.cs.meta
Normal file
13
Assets/RothenburgAR/Scripts/Common/SettingsManager.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d50764101604fa14d92f7523c16bdabc
|
||||
timeCreated: 1546388554
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -2,6 +2,7 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections.Generic;
|
||||
using RothenburgAR.Common;
|
||||
|
||||
namespace RothenburgAR.UI
|
||||
{
|
||||
@@ -26,6 +27,8 @@ namespace RothenburgAR.UI
|
||||
selectionCircle.GetComponentInChildren<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
UIColorSchemeManager.Instance.SetUiColorScheme(id);
|
||||
if (!UIManager.Instance.StartingUp) SettingsManager.Instance.PersistSettings();
|
||||
|
||||
if (UIManager.Instance.StartingUp) SwitchToTutorialView();
|
||||
else SwitchToARView();
|
||||
});
|
||||
@@ -45,20 +48,5 @@ namespace RothenburgAR.UI
|
||||
|
||||
return selectionCircle;
|
||||
}
|
||||
|
||||
private void AddSwitchViewEventListener(GameObject selectionCircle)
|
||||
{
|
||||
selectionCircle.GetComponentInChildren<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
if (UIManager.Instance.StartingUp)
|
||||
{
|
||||
SwitchToTutorialView();
|
||||
}
|
||||
else
|
||||
{
|
||||
SwitchToARView();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using RothenburgAR.Common;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
@@ -47,6 +48,7 @@ namespace RothenburgAR.UI
|
||||
{
|
||||
Debug.Log("Switching Font size to '" + Enum.GetName(typeof(FontsizeSetting), setting) + "'");
|
||||
FontsizeManager.Instance.CurrentFontsizeSetting = setting;
|
||||
SettingsManager.Instance.PersistSettings();
|
||||
|
||||
StateManager sm = TrackerManager.Instance.GetStateManager();
|
||||
foreach (var item in sm.GetActiveTrackableBehaviours())
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using RothenburgAR.Common;
|
||||
using System;
|
||||
using System.IO;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
@@ -50,6 +51,7 @@ namespace RothenburgAR.UI
|
||||
{
|
||||
Debug.Log("Switching Language to '" + languageCode + "'");
|
||||
LanguageManager.Instance.CurrentLanguageKey = languageCode;
|
||||
if (!UIManager.Instance.StartingUp) SettingsManager.Instance.PersistSettings();
|
||||
|
||||
StateManager sm = TrackerManager.Instance.GetStateManager();
|
||||
foreach (var item in sm.GetActiveTrackableBehaviours())
|
||||
@@ -58,14 +60,8 @@ namespace RothenburgAR.UI
|
||||
teh.OnTrackableStateChanged(TrackableBehaviour.Status.NOT_FOUND, TrackableBehaviour.Status.TRACKED);
|
||||
}
|
||||
|
||||
if (UIManager.Instance.StartingUp)
|
||||
{
|
||||
SwitchToColorSelectView();
|
||||
}
|
||||
else
|
||||
{
|
||||
SwitchToARView();
|
||||
}
|
||||
if (UIManager.Instance.StartingUp) SwitchToColorSelectView();
|
||||
else SwitchToARView();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using UnityEngine;
|
||||
using RothenburgAR.Common;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RothenburgAR.UI
|
||||
{
|
||||
@@ -20,6 +21,7 @@ namespace RothenburgAR.UI
|
||||
if (Input.GetMouseButtonDown(0) == true ||
|
||||
(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended))
|
||||
{
|
||||
if (UIManager.Instance.StartingUp) SettingsManager.Instance.PersistSettings();
|
||||
UIManager.Instance.SwitchToView(ViewName.ARView);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ namespace RothenburgAR.UI
|
||||
private Dictionary<UIMaterial, Material> _uiMaterials;
|
||||
public List<UIColorScheme> AvailableUIColorSchemes { get; private set; }
|
||||
|
||||
public int CurrentColorSchemeID = 0;
|
||||
|
||||
internal void Initialize()
|
||||
{
|
||||
AvailableUIColorSchemes = new List<UIColorScheme>();
|
||||
@@ -46,6 +48,7 @@ namespace RothenburgAR.UI
|
||||
else
|
||||
{
|
||||
scheme = AvailableUIColorSchemes[uiColorSchemeId];
|
||||
CurrentColorSchemeID = uiColorSchemeId;
|
||||
}
|
||||
|
||||
_uiMaterials[UIMaterial.BaseOpaque].color = scheme.BaseColorOpaque;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using RothenburgAR.Common;
|
||||
using UnityEngine;
|
||||
@@ -26,7 +27,7 @@ namespace RothenburgAR.UI
|
||||
|
||||
public Boolean IsARViewVisible
|
||||
{
|
||||
get { return _currentView.ViewName == ViewName.ARView; }
|
||||
get { return _currentView != null && _currentView.ViewName == ViewName.ARView; }
|
||||
}
|
||||
|
||||
public ARViewBehaviour ARViewBehaviour
|
||||
@@ -132,10 +133,19 @@ namespace RothenburgAR.UI
|
||||
});
|
||||
}
|
||||
|
||||
public void InitStartView()
|
||||
public IEnumerator InitStartView()
|
||||
{
|
||||
SwitchToView(ViewName.LanguageSelectView);
|
||||
StartingUp = true;
|
||||
yield return new WaitUntil(() => SettingsManager.Instance.IsInitialized.HasValue);
|
||||
if (SettingsManager.Instance.IsInitialized.Value == true)
|
||||
{
|
||||
StartingUp = false;
|
||||
SwitchToView(ViewName.ARView);
|
||||
}
|
||||
else
|
||||
{
|
||||
StartingUp = true;
|
||||
SwitchToView(ViewName.LanguageSelectView);
|
||||
}
|
||||
}
|
||||
|
||||
public GameObject SwitchToView(ViewName nextViewName)
|
||||
|
||||
@@ -25,10 +25,10 @@ namespace RothenburgAR.UI
|
||||
|
||||
private void Update()
|
||||
{
|
||||
ProgressBar.value = UpdaterBehaviour.Instance.CurrentProgress;
|
||||
ProgressBar.maxValue = UpdaterBehaviour.Instance.MaxProgress;
|
||||
ProgressBar.value = UpdateManager.Instance.CurrentProgress;
|
||||
ProgressBar.maxValue = UpdateManager.Instance.MaxProgress;
|
||||
|
||||
var state = UpdaterBehaviour.Instance.UpdateState;
|
||||
var state = UpdateManager.Instance.UpdateState;
|
||||
if (state == lastUpdateState) return;
|
||||
lastUpdateState = state;
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace RothenburgAR.UI
|
||||
|
||||
public void TriggerUpdate()
|
||||
{
|
||||
UpdaterBehaviour.Instance.TriggerUpdate();
|
||||
UpdateManager.Instance.TriggerUpdate();
|
||||
}
|
||||
|
||||
public void ExitView()
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace RothenburgAR.Updater
|
||||
Failed
|
||||
}
|
||||
|
||||
public class UpdaterBehaviour : Singleton<UpdaterBehaviour>
|
||||
public class UpdateManager : Singleton<UpdateManager>
|
||||
{
|
||||
public UpdateState UpdateState { get; private set; }
|
||||
|
||||
@@ -143,29 +143,6 @@ namespace RothenburgAR.Updater
|
||||
* ...
|
||||
*/
|
||||
|
||||
/*
|
||||
Update-Konsistenz
|
||||
- was aktuell noch schlecht ist:
|
||||
- metadaten werden erfolgreich heruntergeladen, medien nicht -> nach reset ist exhibition ok und die medien werden nicht nochmal geprüft
|
||||
- parallele downloads evtl schlecht bei brüchiger verbindung
|
||||
- race condition beim azeigen von "ist fertig"
|
||||
|
||||
- Update in einem cache halten, danach prüfen und wegschreiben (per exhibition sollte ok sein)
|
||||
was passieren kann:
|
||||
httpRequest bricht ab mit NetworkError:true
|
||||
httpRequest bricht ab mit HttpError:true
|
||||
httpRequest gibt leeren body zurück
|
||||
|
||||
- In 2 Schritte aufteilen:
|
||||
1: Metadaten, die dann parsen und somit prüfen
|
||||
2: Medien&Tracker, die dann auf 0-byte-länge prüfen
|
||||
somit kann man die kleinen Daten auf einmal machen und die großen bei bedarf einzeln neu versuchen
|
||||
|
||||
- bei Fehler noch 2 weitere male probieren
|
||||
|
||||
- progressbar vllt ersetzen durch durchlaufdingens?
|
||||
*/
|
||||
|
||||
UpdateState = UpdateState.Downloading;
|
||||
|
||||
if (VersionAnswer == null)
|
||||
Reference in New Issue
Block a user