diff --git a/unity/Assets/Scripts/Content/RemoteContentPack.cs b/unity/Assets/Scripts/Content/RemoteContentPack.cs index 1e19723b..57ef3aaf 100644 --- a/unity/Assets/Scripts/Content/RemoteContentPack.cs +++ b/unity/Assets/Scripts/Content/RemoteContentPack.cs @@ -15,14 +15,10 @@ public class RemoteContentPack public string identifier; public string type; public string version; - public int format; public string package_url; public DateTime latest_update; public string defaultLanguage = ValkyrieConstants.DefaultLanguage; - public static int currentFormat = QuestFormat.CURRENT_VERSION; - public static int minimumFormat = 4; - // is package available locally public bool downloaded = false; public bool update_available = false; @@ -72,16 +68,6 @@ public bool Populate(Dictionary iniData) type = iniData["type"]; } - if (iniData.ContainsKey("format")) - { - int.TryParse(iniData["format"], out format); - } - - if (format > currentFormat || format < minimumFormat) - { - return false; - } - if (iniData.ContainsKey("image")) { string value = iniData["image"]; @@ -118,7 +104,6 @@ override public string ToString() r.AppendLine($"[{ValkyrieConstants.RemoteContentPackIniType}]"); r.Append("identifier=").AppendLine(identifier.ToString()); r.Append("type=").AppendLine(type.ToString()); - r.Append("format=").AppendLine(currentFormat.ToString()); r.Append("type=").AppendLine(Game.Get().gameType.TypeName()); r.Append("defaultlanguage=").AppendLine(defaultLanguage); diff --git a/unity/Assets/Scripts/UI/Screens/ContentSelectDownloadScreen.cs b/unity/Assets/Scripts/UI/Screens/ContentSelectDownloadScreen.cs index 82c83ee4..9be50b85 100644 --- a/unity/Assets/Scripts/UI/Screens/ContentSelectDownloadScreen.cs +++ b/unity/Assets/Scripts/UI/Screens/ContentSelectDownloadScreen.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Windows.Forms; using Assets.Scripts.Content; using UnityEngine; using UnityEngine.Events; @@ -12,8 +11,6 @@ namespace Assets.Scripts.UI.Screens { public class ContentSelectDownloadScreen : MonoBehaviour, IContentImageDrawer { - private const int LARGE_FONT_LIMIT = 32; - private static readonly StringKey CONTENTPACK_DOWNLOAD = new StringKey("val", "CONTENTPACK_DOWNLOAD_HEADER"); public Game game; @@ -21,7 +18,6 @@ public class ContentSelectDownloadScreen : MonoBehaviour, IContentImageDrawer // Persistent UI Element private UIElement text_connection_status = null; private UIElementScrollVertical scrollArea = null; - private RemoteContentPackManager manager; private readonly StringKey GO_OFFLINE = new StringKey("val", "GO_OFFLINE"); private readonly StringKey GO_ONLINE = new StringKey("val", "GO_ONLINE"); private readonly StringKey DOWNLOAD_ONGOING = new StringKey("val", "DOWNLOAD_ONGOING"); @@ -35,7 +31,6 @@ public class ContentSelectDownloadScreen : MonoBehaviour, IContentImageDrawer Texture2D picture_pin = null; private Texture2D button_download = null; private Texture2D button_update = null; - private Texture2D button_play = null; private Texture2D button_no_entry = null; // Display coroutine Coroutine co_display = null; @@ -53,7 +48,6 @@ public ContentSelectDownloadScreen() picture_pin = Resources.Load("sprites/scenario_list/picture_pin") as Texture2D; button_download = Resources.Load("sprites/scenario_list/button_download") as Texture2D; button_update = Resources.Load("sprites/scenario_list/button_update") as Texture2D; - button_play = Resources.Load("sprites/scenario_list/button_play") as Texture2D; button_no_entry = Resources.Load("sprites/scenario_list/button_no_entry") as Texture2D; // Clean everything up @@ -295,8 +289,6 @@ private void DrawOnlineModeButton() text_connection_status = new UIElement(); - - //TODO Continue here // Display connection status message if (game.remoteContentPackManager.content_pack_list_Mode == RemoteContentPackManager.RemoteContentPackListMode.ERROR_DOWNLOAD) { @@ -307,20 +299,27 @@ private void DrawOnlineModeButton() { // Download ongoing text_connection_status.SetText(DOWNLOAD_ONGOING, Color.cyan); - manager.Register_cb_download(RemoteQuestsListDownload_cb); + game.remoteContentPackManager.Register_cb_download(RemoteQuestsListDownload_cb); } else if (game.remoteContentPackManager.content_pack_list_Mode == RemoteContentPackManager.RemoteContentPackListMode.ONLINE) { // Download done, we are online text_connection_status.SetText(GO_OFFLINE, Color.red); - text_connection_status.SetButton(delegate { SetOnlineMode(false); }); + text_connection_status.SetButton( + delegate { + SetOnlineMode(false); + }); border = true; } else { // Download done, user has switched offline modline text_connection_status.SetText(GO_ONLINE, Color.green); - text_connection_status.SetButton(delegate { SetOnlineMode(true); }); + text_connection_status.SetButton( + delegate + { + SetOnlineMode(true); + }); border = true; } @@ -332,11 +331,12 @@ private void DrawOnlineModeButton() if (border) new UIElementBorder(text_connection_status, text_connection_status.GetTextColor()); - //TODO check routine logic + //TODO check how Coroutine logic works //if (co_display != null) // StopCoroutine(co_display); //co_display = StartCoroutine(DrawContentPackList()); + //TODO when Coroutine logic works remove this line DrawContentPackList(); } @@ -346,17 +346,42 @@ private void SetOnlineMode(bool go_online) { ValkyrieDebug.Log("INFO: Set online mode for quests"); - game.questsList.SetMode(QuestsManager.QuestListMode.ONLINE); + game.remoteContentPackManager.SetMode(RemoteContentPackManager.RemoteContentPackListMode.ONLINE); } else { ValkyrieDebug.Log("INFO: Set offline mode for quests"); - game.questsList.SetMode(QuestsManager.QuestListMode.LOCAL); + game.remoteContentPackManager.SetMode(RemoteContentPackManager.RemoteContentPackListMode.LOCAL); } DrawOnlineModeButton(); - //TODO - //ReloadQuestList(); + + ReloadContentPackList(); + } + + public void ReloadContentPackList() + { + CleanContentPackList(); + + //TODO check how Coroutine logic works + //co_display = StartCoroutine(DrawContentPackList()); + //TODO when Coroutine logic works remove this line + DrawContentPackList(); + } + + public void CleanContentPackList() + { + // Clean up everything marked as 'questlist' + foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.CONTENTPACKLIST)) + Destroy(go); + + scrollArea = null; + + // quest images + images_list.Clear(); + + if (co_display != null) + StopCoroutine(co_display); } private void RemoteQuestsListDownload_cb(bool is_available)