From 4ad7613609d54163dd49e852f4fda35da7faacb0 Mon Sep 17 00:00:00 2001 From: Maciej Maj Date: Thu, 9 Aug 2018 15:38:15 +0200 Subject: [PATCH 1/7] Upgraded Save system --- Assets/Scripts/ActivityUI.cs | 4 ++ Assets/Scripts/PlacesSave.cs | 41 ++---------------- Assets/Scripts/ReadJson.cs | 5 ++- Assets/Scripts/RightListUI.cs | 2 +- Assets/Scripts/SaveSystem.cs | 69 +++++++++++++++++++++++++++++++ Assets/Scripts/SaveSystem.cs.meta | 13 ++++++ 6 files changed, 93 insertions(+), 41 deletions(-) create mode 100644 Assets/Scripts/SaveSystem.cs create mode 100644 Assets/Scripts/SaveSystem.cs.meta diff --git a/Assets/Scripts/ActivityUI.cs b/Assets/Scripts/ActivityUI.cs index af2a22f..90a1368 100644 --- a/Assets/Scripts/ActivityUI.cs +++ b/Assets/Scripts/ActivityUI.cs @@ -135,5 +135,9 @@ public void ClickOnPlace() { public void DestroyActivity() { ReadJson.instance.activitiesList.Remove(this); Destroy(gameObject); + } + + public void HideClicked(bool hide) { + } } diff --git a/Assets/Scripts/PlacesSave.cs b/Assets/Scripts/PlacesSave.cs index 4630a0b..71c3f43 100644 --- a/Assets/Scripts/PlacesSave.cs +++ b/Assets/Scripts/PlacesSave.cs @@ -2,8 +2,7 @@ using System.Collections.Generic; using UnityEngine; using Newtonsoft.Json; -using System.IO; -using System.Runtime.Serialization.Formatters.Binary; + [System.Serializable] public class PlaceIconSave { @@ -33,42 +32,8 @@ public static void IconChange(long id, int iconNumber) { } } - void OnApplicationQuit() { - Save(); - } - - public static void Load() { - string destination = Application.persistentDataPath + "/save.dat"; - Debug.Log(destination); - FileStream file; - - if (File.Exists(destination)) - file = File.OpenRead(destination); - else { - Debug.LogError("File not found"); - return; - } - - BinaryFormatter bf = new BinaryFormatter(); - List data = (List)bf.Deserialize(file); - file.Close(); - - iconSaves = data; - //iconSaves = (List)JsonConvert.DeserializeObject(data); - } - public static void Save() { - string destination = Application.persistentDataPath + "/save.dat"; - FileStream file; - - if (File.Exists(destination)) - file = File.OpenWrite(destination); - else - file = File.Create(destination); - - BinaryFormatter bf = new BinaryFormatter(); - bf.Serialize(file, iconSaves); - file.Close(); - Debug.Log("Places saved!"); + public static void LoadCategories(List save) { + iconSaves = save; } public static int? FindIcon(long placeId) { diff --git a/Assets/Scripts/ReadJson.cs b/Assets/Scripts/ReadJson.cs index a78ec04..26b8f48 100644 --- a/Assets/Scripts/ReadJson.cs +++ b/Assets/Scripts/ReadJson.cs @@ -110,7 +110,8 @@ public enum PlaceType { public class FullStoryLine { public MovesJson[] day; -} +} +[Serializable] public class MovesJson { public class SummaryInfo { @@ -219,7 +220,7 @@ void Awake() { PlaceColor = placeColor; } void Start() { - PlacesSave.Load(); + SaveSystem.Load(); OpenFileDialog(); if (uploadedFiles.Count > 0) { filesBox.SetupTexts(uploadedFiles); diff --git a/Assets/Scripts/RightListUI.cs b/Assets/Scripts/RightListUI.cs index c9fbc58..9d99b8d 100644 --- a/Assets/Scripts/RightListUI.cs +++ b/Assets/Scripts/RightListUI.cs @@ -44,7 +44,7 @@ public void NewPlace(PlaceGroup place, bool clickedOnMap = false) { // Save places if (savePlacesAfterReload) { savePlacesAfterReload = false; - PlacesSave.Save(); + SaveSystem.Save(); } bool wait = true; diff --git a/Assets/Scripts/SaveSystem.cs b/Assets/Scripts/SaveSystem.cs new file mode 100644 index 0000000..c7fbf29 --- /dev/null +++ b/Assets/Scripts/SaveSystem.cs @@ -0,0 +1,69 @@ +using UnityEngine; +using System.IO; +using System.Runtime.Serialization.Formatters.Binary; +using System.Collections.Generic; +using System; + +[Serializable] +class SaveData { + public List loadedJson; + public List placesSave; + + public SaveData(List loadedJson, List placesSave) { + this.loadedJson = loadedJson; + this.placesSave = placesSave; + } +} + +public class SaveSystem +{ + static Action _OnSaveChange; + public static Action OnSaveChange { + set { + _OnSaveChange = value; + } + } + + public static void Load() { + string destination = Application.persistentDataPath + "/save.dat"; + FileStream file; + + if (File.Exists(destination)) + file = File.OpenRead(destination); + else { + Debug.LogError("File not found"); + return; + } + + BinaryFormatter bf = new BinaryFormatter(); + SaveData data = (SaveData)bf.Deserialize(file); + file.Close(); + + PlacesSave.LoadCategories(data.placesSave); + } + + public static void Save() { + // Setup + string destination = Application.persistentDataPath + "/save.dat"; + SaveData saveData = new SaveData(new List(), PlacesSave.iconSaves); + + // Open/Create file + FileStream file; + + if (File.Exists(destination)) + file = File.OpenWrite(destination); + else + file = File.Create(destination); + + // Save to file + BinaryFormatter bf = new BinaryFormatter(); + bf.Serialize(file, saveData); + file.Close(); + Debug.Log("Saved!"); + } + + public static void SaveChange() { + _OnSaveChange.Invoke(); + } + +} diff --git a/Assets/Scripts/SaveSystem.cs.meta b/Assets/Scripts/SaveSystem.cs.meta new file mode 100644 index 0000000..275d23f --- /dev/null +++ b/Assets/Scripts/SaveSystem.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 4de4ce2c484dc41c380f26f79aeeb527 +timeCreated: 1533821088 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From a8ff2be8d4564184f497f06af4d9fdf7ce368f05 Mon Sep 17 00:00:00 2001 From: Maciej Maj Date: Sat, 11 Aug 2018 20:03:10 +0200 Subject: [PATCH 2/7] Load more files button --- Assets/FilesBox.cs | 8 +- Assets/Graphics/FilterButton smaller.png | Bin 0 -> 1108 bytes Assets/Graphics/FilterButton smaller.png.meta | 112 ++++++ Assets/MainScene.unity | 379 +++++++++++++++--- Assets/Scripts/ReadJson.cs | 9 +- Assets/Scripts/RightListUI.cs | 6 - 6 files changed, 453 insertions(+), 61 deletions(-) create mode 100644 Assets/Graphics/FilterButton smaller.png create mode 100644 Assets/Graphics/FilterButton smaller.png.meta diff --git a/Assets/FilesBox.cs b/Assets/FilesBox.cs index 8559eb5..416a604 100644 --- a/Assets/FilesBox.cs +++ b/Assets/FilesBox.cs @@ -6,11 +6,15 @@ public class FilesBox : MonoBehaviour { public GameObject fileNamePrefab; + public GameObject textSpawner; public void SetupTexts(List files) { + for (int i = 0; i < textSpawner.transform.childCount; i++) { + Destroy(textSpawner.transform.GetChild(i).gameObject); + } foreach (var item in files) { - GameObject go = Instantiate(fileNamePrefab, gameObject.transform.position, gameObject.transform.rotation); - go.transform.SetParent(gameObject.transform); + GameObject go = Instantiate(fileNamePrefab, textSpawner.transform.position, textSpawner.transform.rotation); + go.transform.SetParent(textSpawner.transform); go.transform.localScale = go.transform.lossyScale; go.GetComponent().text = item; } diff --git a/Assets/Graphics/FilterButton smaller.png b/Assets/Graphics/FilterButton smaller.png new file mode 100644 index 0000000000000000000000000000000000000000..de6006737b4943fc0202d312c7cc9eccb91611c4 GIT binary patch literal 1108 zcmV-a1grarP)Px(4oO5oRCodHoj-5WKp4g`5(oy=3W*Jgp%wiMbgI;?17t2k6|plzD=}n(H9M*@ zkhx@FtCWd;h9Wv3u_2*U9iTxXJde3Ew&On+`&1I=d8JoApYJZdUmo4rXWu!v=E)|L z$qI_vfj@$8z}Ml7y92)om;HYNW1PYT{2cxnehNQik+58+4f0mStc+e%hRP)0}{{Nf(`dZk}hrgTAX zz@Ni!!)47S@B>xr!e2vJBiCv=3kqUl*LDcM>sq+dHG;r*)S?Yh4P0vD)LlVLFHso# zSBc4mYO~VtKR+@WD6Lsx3xz^%p@g^a-O`ejU>OMXQORd$t$yZJHdjzaOvlK$nU`7d zOG)4(YQ3E&s-iBBEtABwl$t55G&MnOWLl=6On<3vE)$s|L0~uUnrf=cLqguo@dAA6 zm{5v9jKBopR{HKQAsUE@<4k98-Oa_wDVR%uLkepURWweO?(#TjDKX{p(}5HLYK5AK zENY?9I`O&OC%8tyBRmQ?5a5XVL$p%i^S^it)xiOY$$_AfBnVJ5)J|w&3uRiTFNlc? z%p}o91WF0;f${^kQdU4u5Mjfmxs^Z!QUs_Sjt)d3qM&3VP=`Q^nFDlpe5>*sTrbCw zh^#6BzNB}LO%-3;m6)nxR6a|98rq?t^t{d@(Y7vuO$v$=3S=VSgTMv_wdSKFl_3Ju z5(UMJa+wJDAh5!_yi1g%d2>E+s*EvPD47U&BS1lMCaFvWd=R*xpu9{$_Hi~UW8n#m zC@8*ACldi51kNZZE|?$_0UrcTDJV{hk%@p00w;Pn>;t39Ac4ORhw)MrFUp6Ek%>SJ z0z+zvT^^0oreq>ehd`(yy#ibZq4HV+$yb2QjD?;(s;vmjNT6pl^lx^srcup^P{}QU z>}ga+VO^U_TM=+1(6y}-(}&kkHX~Z8RfIJa-2&0Jj6m^JbSQ0v654Psgdh`vA_CM% z+h`_AXNL`<2qYL_=OBtuKm@W092l)6jwZUi_z`q}@35~mqT)~#wgmbR(^I<>-xdjq z>uVmvH7h1gOyO!vB0_;&m~$K67ef&+1gM4F^);Dh>Ke*q3^x>&Y1;M?p$qjmoaGAh zzu%`8Ohc1f``j)sodefYTnyn5t_8``aGJf(p@BAp#GAEJD{P_SxlMtb!}kWx(NS5m z3GhGWf6XNioy0^O&Mg!ZTQiSoI@sTXJB!lh*LJQ6T;0cm(in`exD*h53$8^s0AT@* zFUJkx@9AifuJ-e0_|YkYxHtouE4gr(f$Jr(dt{tGzz7I)Vq=_#{Qx5$v2i{DhXK5O afbkDiM%MI}L?L7V0000 0) { + filesBox.SetupTexts(uploadedFiles); + } + } // Opening files void OpenFileDialog() { diff --git a/Assets/Scripts/RightListUI.cs b/Assets/Scripts/RightListUI.cs index 9d99b8d..aa4d8ea 100644 --- a/Assets/Scripts/RightListUI.cs +++ b/Assets/Scripts/RightListUI.cs @@ -54,20 +54,14 @@ public void NewPlace(PlaceGroup place, bool clickedOnMap = false) { wait = false; TopBar.instance.SwitchTab(2); } - Debug.Log("Wait1: " + wait); StopAllCoroutines(); - Debug.Log("Wait2: " + wait); if (!clickedOnMap) { - Debug.Log("Wait3: " + wait); RenderMap.instance.UpdateMapSize(0.3f); GlobalVariables.inst.MoveCamera(place.mapObject.gameObject.transform.position); place.mapObject.Select(true); - Debug.Log("Wait4: " + wait); } - Debug.Log("Wait5: " + wait); this.place = place; - Debug.Log("Wait6: " + wait); if (wait) StartCoroutine(AfterAnimationChange()); else From 69834bc8eb9b256ce19e72b8f4e39330531506d0 Mon Sep 17 00:00:00 2001 From: Maciej Maj Date: Sat, 11 Aug 2018 22:31:15 +0200 Subject: [PATCH 3/7] Basic maps files save --- Assets/ButtonTabs.cs | 1 + Assets/Scripts/ActivityUI.cs | 2 +- Assets/Scripts/ChartItem.cs | 1 + Assets/Scripts/ChartUI.cs | 4 +-- Assets/Scripts/ReadJson.cs | 60 ++++++++++++++++++++++++++---------- Assets/Scripts/RenderMap.cs | 3 +- Assets/Scripts/SaveSystem.cs | 20 ++++++++---- 7 files changed, 63 insertions(+), 28 deletions(-) diff --git a/Assets/ButtonTabs.cs b/Assets/ButtonTabs.cs index 1ce4966..3f2320c 100644 --- a/Assets/ButtonTabs.cs +++ b/Assets/ButtonTabs.cs @@ -13,6 +13,7 @@ void Start () { foreach (var item in tabs) { item.SetActive(false); } + Open(1); } public void Open(int id) { diff --git a/Assets/Scripts/ActivityUI.cs b/Assets/Scripts/ActivityUI.cs index 90a1368..cd88dc0 100644 --- a/Assets/Scripts/ActivityUI.cs +++ b/Assets/Scripts/ActivityUI.cs @@ -128,7 +128,7 @@ void SetSize(TimeSpan t) { } public void ClickOnPlace() { - if (placename != null) + if (placename != null && placeGroup != null) RightListUI.instance.NewPlace(placeGroup); } diff --git a/Assets/Scripts/ChartItem.cs b/Assets/Scripts/ChartItem.cs index aafc0c8..10ad5e4 100644 --- a/Assets/Scripts/ChartItem.cs +++ b/Assets/Scripts/ChartItem.cs @@ -3,6 +3,7 @@ using UnityEngine; using UnityEngine.UI; +[System.Serializable] public class ChartItem : MonoBehaviour { public static ChartItem selectedChart; diff --git a/Assets/Scripts/ChartUI.cs b/Assets/Scripts/ChartUI.cs index 8806f2f..72d26d6 100644 --- a/Assets/Scripts/ChartUI.cs +++ b/Assets/Scripts/ChartUI.cs @@ -35,7 +35,7 @@ public void CheckMaxCalories(MovesJson day) { public void CheckChartSelected() { DayClass selectedDay = new DayClass(); ReadJson.instance.days.TryGetValue(ReadJson.instance.selectedDay, out selectedDay); - selectedDay.chart.Select(); + //selectedDay.chart.Select(); } public void SetupCharts() { heightPerCalorie = (float)barsHeight / (float)maxCalories; @@ -47,7 +47,7 @@ public void SetupCharts() { rectT.localScale = rectT.lossyScale; ChartItem chartItem = chart.GetComponent(); chartItem.Setup(item.Value); - item.Value.chart = chartItem; + //item.Value.chart = chartItem; } } } diff --git a/Assets/Scripts/ReadJson.cs b/Assets/Scripts/ReadJson.cs index 414c15c..4a2f0e6 100644 --- a/Assets/Scripts/ReadJson.cs +++ b/Assets/Scripts/ReadJson.cs @@ -6,6 +6,7 @@ using UnityEngine; using UnityEngine.UI; using System.IO; +using System.Linq; public enum ActivityType { walking, //00D55A 0 @@ -113,7 +114,7 @@ public class FullStoryLine { } [Serializable] public class MovesJson { - + [Serializable] public class SummaryInfo { public double distance; public double duration; @@ -122,8 +123,11 @@ public class SummaryInfo { public string group; public ActivityType activity; } + [Serializable] public class SegmentsInfo { + [Serializable] public class ActivitiesInfo { + [Serializable] public class TrackPointsInfo { public string time; public float lon; @@ -140,8 +144,10 @@ public class TrackPointsInfo { public string endTime; public string group; public ActivityType activity; - } - public class PlaceInfo { + } + [Serializable] + public class PlaceInfo { + [Serializable] public class LocationInfo { public float lon; public float lat; @@ -169,10 +175,11 @@ public class LocationInfo { public double caloriesIdle; } +[Serializable] public class DayClass { public DateTime date; public MovesJson day; - public ChartItem chart; + //public ChartItem chart; public int dayNumber; public DayClass(DateTime date, MovesJson day, int number) { @@ -214,6 +221,7 @@ public class ReadJson : MonoBehaviour { [Header("Uploaded files")] public List uploadedFiles; public FilesBox filesBox; + List daysToDraw = new List(); void Awake() { instance = this; @@ -222,8 +230,9 @@ void Awake() { } void Start() { SaveSystem.Load(); - OpenFileDialog(); + //OpenFileDialog(); if (uploadedFiles.Count > 0) { + CalculationAfterLoadedFiles(false); filesBox.SetupTexts(uploadedFiles); CheckIfCanDraw(); } @@ -278,6 +287,7 @@ public void OpenMoreFilesButton() { OpenFileDialog(); if (uploadedFiles.Count > 0) { filesBox.SetupTexts(uploadedFiles); + CheckIfCanDraw(); } } @@ -301,8 +311,10 @@ void OpenFileDialog() { uploadedFiles.Add(GetFileName(tempItem)); string jsonData = File.ReadAllText(tempItem); LoadFiles(jsonData); - } - + } + } + if (daysToDraw.Count > 0) { + CalculationAfterLoadedFiles(); } } string GetFileName(string path) { @@ -318,27 +330,41 @@ string GetFileName(string path) { return output; } - // Loading json files + // Loading json files + public int dayNumber; void LoadFiles(string jsonData) { string text = "{ day: " + jsonData + "}"; FullStoryLine m = JsonConvert.DeserializeObject(text); - int dayNumber = 0; foreach (var item in m.day) { DateTime timelineDay = ReturnSimpleDate(item.date); if (!days.ContainsKey(timelineDay) && item.summary != null) { - days.Add(timelineDay, new DayClass(timelineDay, item, dayNumber++)); - selectedDay = timelineDay; - if (firstDate == null) - firstDate = timelineDay; - lastDate = timelineDay; - PlacesRanking.instance.AnalyseDay(item); - ChartUI.instance.CheckMaxCalories(item); - RenderMap.instance.RenderDay(item); + DayClass tempDay = new DayClass(timelineDay, item, dayNumber++); + days.Add(timelineDay, tempDay); + daysToDraw.Add(tempDay); } } //RenderMap.instance.ChangeDaysRangeFilter(new DateTime(2018, 03, 01), new DateTime(2018, 03, 10)); + } + void CalculationAfterLoadedFiles(bool daysToDrawLoaded = true) { + if (!daysToDrawLoaded) { + foreach (var item in days.Values) { + daysToDraw.Add(item); + } + } + + + foreach (var item in daysToDraw) { + PlacesRanking.instance.AnalyseDay(item.day); + ChartUI.instance.CheckMaxCalories(item.day); + RenderMap.instance.RenderDay(item.day); + } PlacesRanking.instance.SortAndDisplay(); ChartUI.instance.SetupCharts(); + + firstDate = days.Keys.Min(); + lastDate = days.Keys.Max(); + selectedDay = lastDate; + daysToDraw.Clear(); } // Drawing Timeline diff --git a/Assets/Scripts/RenderMap.cs b/Assets/Scripts/RenderMap.cs index 6e5e3a9..46ad510 100644 --- a/Assets/Scripts/RenderMap.cs +++ b/Assets/Scripts/RenderMap.cs @@ -49,8 +49,7 @@ void Update() { } else if (Input.mouseScrollDelta.y < 0) { mapScale *= 1.5f; if (mapScale > 64) - mapScale = 127; - Debug.Log(mapScale); + mapScale = 127; UpdateMapSize(); } } diff --git a/Assets/Scripts/SaveSystem.cs b/Assets/Scripts/SaveSystem.cs index c7fbf29..53483ce 100644 --- a/Assets/Scripts/SaveSystem.cs +++ b/Assets/Scripts/SaveSystem.cs @@ -6,12 +6,16 @@ [Serializable] class SaveData { - public List loadedJson; + public Dictionary loadedJson; public List placesSave; + public List uploadedFiles; + public int dayNumber; - public SaveData(List loadedJson, List placesSave) { - this.loadedJson = loadedJson; + public SaveData(ReadJson main, List placesSave, List uploadedFiles) { + this.loadedJson = main.days; this.placesSave = placesSave; + this.uploadedFiles = uploadedFiles; + this.dayNumber = main.dayNumber; } } @@ -25,7 +29,7 @@ public static Action OnSaveChange { } public static void Load() { - string destination = Application.persistentDataPath + "/save.dat"; + string destination = Application.persistentDataPath + "/save2.dat"; FileStream file; if (File.Exists(destination)) @@ -40,12 +44,16 @@ public static void Load() { file.Close(); PlacesSave.LoadCategories(data.placesSave); + ReadJson.instance.uploadedFiles = data.uploadedFiles; + ReadJson.instance.days = data.loadedJson; } public static void Save() { // Setup - string destination = Application.persistentDataPath + "/save.dat"; - SaveData saveData = new SaveData(new List(), PlacesSave.iconSaves); + string destination = Application.persistentDataPath + "/save2.dat"; + SaveData saveData = new SaveData(ReadJson.instance, + PlacesSave.iconSaves, + ReadJson.instance.uploadedFiles); // Open/Create file FileStream file; From 512335848b768736dd2aeaab43fd87c488c50ff5 Mon Sep 17 00:00:00 2001 From: Maciej Maj Date: Sun, 12 Aug 2018 00:02:04 +0200 Subject: [PATCH 4/7] Reseting saves, small redesign --- Assets/Animations/TabBox/Open.anim | 59 +- Assets/ButtonTabs.cs | 4 + Assets/FilesBox.cs | 5 + Assets/Graphics/Icons/IC Save 24px.png | Bin 0 -> 1563 bytes Assets/Graphics/Icons/IC Save 24px.png.meta | 76 ++ Assets/MainScene.unity | 973 +++++++++++++++----- Assets/Prefabs/TabsButton.prefab | 20 +- Assets/Scripts/PlacesRanking.cs | 4 + Assets/Scripts/PlacesSave.cs | 4 + Assets/Scripts/ReadJson.cs | 13 + Assets/Scripts/RenderMap.cs | 15 +- 11 files changed, 902 insertions(+), 271 deletions(-) create mode 100644 Assets/Graphics/Icons/IC Save 24px.png create mode 100644 Assets/Graphics/Icons/IC Save 24px.png.meta diff --git a/Assets/Animations/TabBox/Open.anim b/Assets/Animations/TabBox/Open.anim index 6151ff5..7ddfb13 100644 --- a/Assets/Animations/TabBox/Open.anim +++ b/Assets/Animations/TabBox/Open.anim @@ -21,13 +21,13 @@ AnimationClip: m_Curve: - serializedVersion: 2 time: 0 - value: -39.9 + value: -31 inSlope: -210.07977 outSlope: -210.07977 tangentMode: 0 - serializedVersion: 2 time: 0.41666666 - value: -54.350006 + value: -46 inSlope: 0 outSlope: 0 tangentMode: 136 @@ -82,6 +82,28 @@ AnimationClip: path: classID: 224 script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: 245.9231 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.41666666 + value: 230.9231 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalPosition.y + path: + classID: 224 + script: {fileID: 0} m_PPtrCurves: [] m_SampleRate: 60 m_WrapMode: 0 @@ -111,6 +133,13 @@ AnimationClip: typeID: 224 customType: 0 isPPtrCurve: 0 + - serializedVersion: 2 + path: 0 + attribute: 3762036201 + script: {fileID: 0} + typeID: 224 + customType: 0 + isPPtrCurve: 0 pptrCurveMapping: [] m_AnimationClipSettings: serializedVersion: 2 @@ -138,13 +167,13 @@ AnimationClip: m_Curve: - serializedVersion: 2 time: 0 - value: -39.9 + value: -31 inSlope: -210.07977 outSlope: -210.07977 tangentMode: 0 - serializedVersion: 2 time: 0.41666666 - value: -54.350006 + value: -46 inSlope: 0 outSlope: 0 tangentMode: 136 @@ -199,6 +228,28 @@ AnimationClip: path: classID: 224 script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: 245.9231 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + - serializedVersion: 2 + time: 0.41666666 + value: 230.9231 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalPosition.y + path: + classID: 224 + script: {fileID: 0} m_EulerEditorCurves: [] m_HasGenericRootTransform: 0 m_HasMotionFloatCurves: 0 diff --git a/Assets/ButtonTabs.cs b/Assets/ButtonTabs.cs index 3f2320c..f67e27d 100644 --- a/Assets/ButtonTabs.cs +++ b/Assets/ButtonTabs.cs @@ -31,4 +31,8 @@ public void Open(int id) { currentlyOpened = id; } } + + public void Save() { + SaveSystem.Save(); + } } diff --git a/Assets/FilesBox.cs b/Assets/FilesBox.cs index 416a604..5fb550a 100644 --- a/Assets/FilesBox.cs +++ b/Assets/FilesBox.cs @@ -4,10 +4,15 @@ using UnityEngine.UI; public class FilesBox : MonoBehaviour { + public static FilesBox instance; public GameObject fileNamePrefab; public GameObject textSpawner; + void Awake() { + instance = this; + } + public void SetupTexts(List files) { for (int i = 0; i < textSpawner.transform.childCount; i++) { Destroy(textSpawner.transform.GetChild(i).gameObject); diff --git a/Assets/Graphics/Icons/IC Save 24px.png b/Assets/Graphics/Icons/IC Save 24px.png new file mode 100644 index 0000000000000000000000000000000000000000..e4423c8c0d41e1953d6d2b11ab71eeebddafec83 GIT binary patch literal 1563 zcmV+$2ITpPP)4Tx062|}Rb6NtRTMtEb7vzY&QokOg>Hg1+lHrgWS zWcKdPn90sKGrRqvPeo9CG3uKX#J{(I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R-i{z@eVn1K##d;wCsm5qU& zffa;Ag%E`IDigUE>ueJ?a?)$;d-u+ls}mG#cJ3;007Yb7Z;#sphz0X&*tlHhhF?qTN&)2f0t>d-4lurlUDlK< z7+(+m!bgsbwdbw^dOU4VxbZ4GElNBU18 zx2pqJdXAjsf*S@Qi&J>XAKP3VI5PodKg;cP-Z0@`bZ$GVan%8K;2R85VCkR FindContaining(string text, List startingLis } return output; } + + public void Clear() { + places.Clear(); + } public void SortAndDisplay() { Dictionary ranking = new Dictionary(); diff --git a/Assets/Scripts/PlacesSave.cs b/Assets/Scripts/PlacesSave.cs index 71c3f43..d809376 100644 --- a/Assets/Scripts/PlacesSave.cs +++ b/Assets/Scripts/PlacesSave.cs @@ -52,4 +52,8 @@ public static PlaceIconSave FindIconSave(long placeId) { } return null; } + + public static void Clear() { + iconSaves.Clear(); + } } diff --git a/Assets/Scripts/ReadJson.cs b/Assets/Scripts/ReadJson.cs index 4a2f0e6..4c45d03 100644 --- a/Assets/Scripts/ReadJson.cs +++ b/Assets/Scripts/ReadJson.cs @@ -244,6 +244,8 @@ void Update() { // SwitchingDays void CheckArrows() { + if (days.Count <= 3) + return; if (Input.GetKey(KeyCode.LeftArrow)) { ChangeLeft(); } else if (Input.GetKey(KeyCode.RightArrow)) { @@ -283,6 +285,7 @@ public void ChangeLeft() { } } + // Files UI public void OpenMoreFilesButton() { OpenFileDialog(); if (uploadedFiles.Count > 0) { @@ -290,6 +293,16 @@ public void OpenMoreFilesButton() { CheckIfCanDraw(); } } + public void RestartFiles() { + days.Clear(); + RenderMap.instance.Clear(); + PlacesRanking.instance.Clear(); + dayNumber = 0; + uploadedFiles.Clear(); + FilesBox.instance.SetupTexts(uploadedFiles); + SaveSystem.Save(); + PlacesSave.Clear(); + } // Opening files void OpenFileDialog() { diff --git a/Assets/Scripts/RenderMap.cs b/Assets/Scripts/RenderMap.cs index 46ad510..aa72141 100644 --- a/Assets/Scripts/RenderMap.cs +++ b/Assets/Scripts/RenderMap.cs @@ -188,12 +188,21 @@ void AddToFilterList(ActivityType activity, GameObject line) { } } - void Clear() { + public void Clear() { foreach (Transform child in gameObject.transform) { Destroy(child.gameObject); - } + } + foreach (Transform child in loactionsGO.transform) { + Destroy(child.gameObject); + } + foreach (var item in filterLines) { + item.Clear(); + } + filterDays.Clear(); + alreadyRenderedPlaces.Clear(); + renderedLines.Clear(); } - + // Filters public void ChangeFilter(FilterTypes filterType, bool state) { if (filterType == FilterTypes.place) { From 050601b4f23e38b02eacc0df56183aa6bb90773a Mon Sep 17 00:00:00 2001 From: Maciej Maj Date: Sun, 12 Aug 2018 00:47:35 +0200 Subject: [PATCH 5/7] Placeholder when no files are loaded --- Assets/ButtonTabs.cs | 7 + Assets/Graphics/Icons/Map 128px.png | Bin 0 -> 3190 bytes Assets/Graphics/Icons/Map 128px.png.meta | 76 +++++ Assets/MainScene.unity | 391 +++++++++++++++++------ Assets/Scripts/ReadJson.cs | 13 +- Assets/TopBar.cs | 5 + 6 files changed, 398 insertions(+), 94 deletions(-) create mode 100644 Assets/Graphics/Icons/Map 128px.png create mode 100644 Assets/Graphics/Icons/Map 128px.png.meta diff --git a/Assets/ButtonTabs.cs b/Assets/ButtonTabs.cs index f67e27d..7024668 100644 --- a/Assets/ButtonTabs.cs +++ b/Assets/ButtonTabs.cs @@ -8,6 +8,7 @@ public class ButtonTabs : MonoBehaviour { public TabsButton[] buttons; public GameObject[] tabs; int? currentlyOpened; + public Text saveButtonText; void Start () { foreach (var item in tabs) { @@ -34,5 +35,11 @@ public void Open(int id) { public void Save() { SaveSystem.Save(); + saveButtonText.text = "Saved!"; + StartCoroutine(RevertAfterTime()); + } + IEnumerator RevertAfterTime() { + yield return new WaitForSeconds(1.5f); + saveButtonText.text = "Save"; } } diff --git a/Assets/Graphics/Icons/Map 128px.png b/Assets/Graphics/Icons/Map 128px.png new file mode 100644 index 0000000000000000000000000000000000000000..5150e13cbf469e46ae8d0149f1a07bef30ba6107 GIT binary patch literal 3190 zcmdUyS3KK~0>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}Z->GcR&~^tsTI;u!%ee_%wSsc6lMd5sVwL9=U|%Feojt!Y}b8Z1Thtp`V+waBK$ zOyRj@YL(~DWjg^xIc88z>sCUfH)AFFc1=vybk=%T{}K#%u`1vqYM2o4nX$>fHG-^D zgVoO{eeV)Z@#;ji#c||p2UqJa+wxq5>+`Lw-z^=sO^ud*LK9q9qZl>~P}d9rSpmmG zMlM_GkiBF1zjlTu6EG?syF{lev(%Mju!oVb1OVB^4e{S>1bK&XB{gjgEm9XSN=5;0Zxhzj_7+swnLy>{+$`V8S?(oJeNKU9%;kE1lzX3u!end`-UI_C7Qbet40 zm$CaqLrPo?q;W7M3WF~982@O94JGP2-X$jOm1Mt{_zy!Cs8zW$gooN2ANWd^k}neDQOsV z=t7KTqf&cLh=%zgho)55`RWK*ALadffbAMT8ZRCDjRS|48XiF{PzyB$Lk8^6sT+r@}DM|+WcQb_LzY1lGM692BF(P-&)4$RNt!>H6A~MFks8(Hj64@)s_89 za%6~!dBEK;;FChQ*JLv)Gsw;u@-*g>tjYB_(C(?BSE5BbQ3B5@PSfN3`N?FR9K$18 z4PQMkv{1>D9s2o6Hd~TYM_{ z`f;PMrwB9zqYmAPZS)rts@*y#7IiV#uX}&?YqqzP$N(v(5XFy~#IIhsSEbM(6x1r2 ztGXe0t~&ws<6B=X@d-1I1o;ca;S!4yFrGVapI&PwxGYBi`tF3h=&wM6q8F2zHl~i@ z9zJ36r^L{!qHfs_gD6vV6dw)FgfHi^Yxi)|8nVWs2Jm2fOfN z+~v$}L`%pkduRk*fA0zZjQ$q;l~L@E)?yaFZd3mN0ta^~8kXD36{T=>E1Kz= z*_0wRKDw`n3b_cFcgtk>g$#_k{!QM2cz4# activitiesList; public Color[] activitesColor; public Color placeColor; + public GameObject blankPlaceholder; public Text[] selectedDayDateText; public Animator animator; @@ -231,11 +232,13 @@ void Awake() { void Start() { SaveSystem.Load(); //OpenFileDialog(); + blankPlaceholder.SetActive(true); if (uploadedFiles.Count > 0) { CalculationAfterLoadedFiles(false); filesBox.SetupTexts(uploadedFiles); CheckIfCanDraw(); - } + } + } void Update() { @@ -302,6 +305,8 @@ public void RestartFiles() { FilesBox.instance.SetupTexts(uploadedFiles); SaveSystem.Save(); PlacesSave.Clear(); + blankPlaceholder.SetActive(true); + TopBar.instance.Clear(); } // Opening files @@ -364,8 +369,8 @@ void CalculationAfterLoadedFiles(bool daysToDrawLoaded = true) { daysToDraw.Add(item); } } - - + if (daysToDraw.Count == 0) + return; foreach (var item in daysToDraw) { PlacesRanking.instance.AnalyseDay(item.day); ChartUI.instance.CheckMaxCalories(item.day); @@ -378,6 +383,8 @@ void CalculationAfterLoadedFiles(bool daysToDrawLoaded = true) { lastDate = days.Keys.Max(); selectedDay = lastDate; daysToDraw.Clear(); + + blankPlaceholder.SetActive(false); } // Drawing Timeline diff --git a/Assets/TopBar.cs b/Assets/TopBar.cs index 2d67837..9c302e4 100644 --- a/Assets/TopBar.cs +++ b/Assets/TopBar.cs @@ -37,4 +37,9 @@ public void SwitchTab(int id) { selectedTab.Select(); currentTab = id; } + + public void Clear() { + SwitchTab(1); + tabButtons[2].GetComponent