/// <summary> /// After selecting game, we load the localization file. /// Deppends on the gameType selected. /// There are two Localization files from ffg, one for D2E and one for MoM /// </summary> private void loadLocalization() { // After content import, we load the localization file if (LocalizationRead.selectDictionary("ffg") == null) { DictionaryI18n ffgDict = new DictionaryI18n(); var localizationFiles = Directory.GetFiles(ContentData.ImportPath() + "/text", "Localization_*.txt"); foreach (string file in localizationFiles) { ffgDict.AddDataFromFile(file); } LocalizationRead.AddDictionary("ffg", ffgDict); // CoSH used for Dunwich Horror data DictionaryI18n cshDict = new DictionaryI18n(); foreach (string file in Directory.GetFiles(ContentData.ImportPath() + "/text", "SCENARIO_CULT_OF_SENTINEL_HILL_MAD22_*.txt")) { cshDict.AddDataFromFile(file); } LocalizationRead.AddDictionary("csh", cshDict); var game = Game.Get(); foreach (var packInfo in game.config.GetPackLanguages(game.gameType.TypeName()) .Where(kv => !string.IsNullOrWhiteSpace(kv.Value))) { LocalizationRead.SetGroupTranslationLanguage(packInfo.Key, packInfo.Value); } } }
// List of quests to copy public void Copy() { // Can copy all quests, not just user questList = QuestLoader.GetQuests(true); Game game = Game.Get(); foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.DIALOG)) { Object.Destroy(go); } // Header UIElement ui = new UIElement(); ui.SetLocation(2, 1, UIScaler.GetWidthUnits() - 4, 3); ui.SetText(new StringKey("val", "SELECT_TO_COPY", game.gameType.QuestName())); ui.SetFont(Game.Get().gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetLargeFont()); UIElementScrollVertical scrollArea = new UIElementScrollVertical(); scrollArea.SetLocation(1, 5, UIScaler.GetWidthUnits() - 2f, 21); new UIElementBorder(scrollArea); // List of quests int offset = 0; foreach (KeyValuePair <string, QuestData.Quest> q in questList) { string key = q.Key; LocalizationRead.AddDictionary("qst", q.Value.localizationDict); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(1, offset, UIScaler.GetWidthUnits() - 5, 1.2f); ui.SetText(new StringKey("val", "INDENT", q.Value.name), Color.black); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetButton(delegate { Copy(key); }); ui.SetBGColor(Color.white); offset += 2; } scrollArea.SetScrollSize(offset); // Back to edit selection ui = new UIElement(); ui.SetLocation(1, UIScaler.GetBottom(-3), 8, 2); ui.SetText(CommonStringKeys.BACK, Color.red); ui.SetFont(Game.Get().gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(CancelCopy); new UIElementBorder(ui, Color.red); }
// Unity fires off this function void Start() { // Find the common objects we use. These are created by unity. cc = GameObject.FindObjectOfType <CameraController>(); uICanvas = GameObject.Find("UICanvas").GetComponent <Canvas>(); boardCanvas = GameObject.Find("BoardCanvas").GetComponent <Canvas>(); tokenCanvas = GameObject.Find("TokenCanvas").GetComponent <Canvas>(); tokenBoard = GameObject.FindObjectOfType <TokenBoard>(); heroCanvas = GameObject.FindObjectOfType <HeroCanvas>(); monsterCanvas = GameObject.FindObjectOfType <MonsterCanvas>(); // Create some things uiScaler = new UIScaler(uICanvas); config = new ConfigFile(); GameObject go = new GameObject("audio"); audioControl = go.AddComponent <Audio>(); if (config.data.Get("UserConfig") == null) { // English is the default current language config.data.Add("UserConfig", "currentLang", DictionaryI18n.DEFAULT_LANG); config.Save(); } currentLang = config.data.Get("UserConfig", "currentLang"); try { TextAsset localizationFile = Resources.Load("Text/Localization") as TextAsset; LocalizationRead.AddDictionary("val", LocalizationRead.ReadFromTextAsset(localizationFile, currentLang)); LocalizationRead.changeCurrentLangTo(currentLang); } catch (System.Exception e) { ValkyrieDebug.Log("Error loading valkyrie localization file:" + e.Message); } roundControl = new RoundController(); // Read the version and add it to the log TextAsset versionFile = Resources.Load("version") as TextAsset; version = versionFile.text.Trim(); // The newline at the end stops the stack trace appearing in the log ValkyrieDebug.Log("Valkyrie Version: " + version + System.Environment.NewLine); // Bring up the Game selector gameSelect = new GameSelectionScreen(); }
// Unity fires off this function void Start() { // Find the common objects we use. These are created by unity. cc = GameObject.FindObjectOfType <CameraController>(); uICanvas = GameObject.Find("UICanvas").GetComponent <Canvas>(); boardCanvas = GameObject.Find("BoardCanvas").GetComponent <Canvas>(); tokenCanvas = GameObject.Find("TokenCanvas").GetComponent <Canvas>(); tokenBoard = GameObject.FindObjectOfType <TokenBoard>(); heroCanvas = GameObject.FindObjectOfType <HeroCanvas>(); monsterCanvas = GameObject.FindObjectOfType <MonsterCanvas>(); // Create some things uiScaler = new UIScaler(uICanvas); config = new ConfigFile(); GameObject go = new GameObject("audio"); audioControl = go.AddComponent <Audio>(); updateList = new List <IUpdateListener>(); if (config.data.Get("UserConfig") == null) { // English is the default current language config.data.Add("UserConfig", "currentLang", "English"); config.Save(); } currentLang = config.data.Get("UserConfig", "currentLang"); DictionaryI18n valDict = new DictionaryI18n(); foreach (string file in System.IO.Directory.GetFiles(Application.streamingAssetsPath + "/text", "Localization*.txt")) { valDict.AddDataFromFile(file); } LocalizationRead.AddDictionary("val", valDict); roundControl = new RoundController(); // Read the version and add it to the log TextAsset versionFile = Resources.Load("version") as TextAsset; version = versionFile.text.Trim(); // The newline at the end stops the stack trace appearing in the log ValkyrieDebug.Log("Valkyrie Version: " + version + System.Environment.NewLine); // Bring up the Game selector gameSelect = new GameSelectionScreen(); }
// This loads content from a pack by object // Duplicate content will be replaced by the higher priority value void LoadContent(ContentPack cp) { // Don't reload content if (loadedPacks.Contains(cp.id)) { return; } foreach (string ini in cp.iniFiles) { IniData d = IniRead.ReadFromIni(ini); // Bad ini file not a fatal error, just ignore (will be in log) if (d == null) { return; } // Add each section foreach (KeyValuePair <string, Dictionary <string, string> > section in d.data) { AddContent(section.Key, section.Value, Path.GetDirectoryName(ini), cp.id); } } foreach (KeyValuePair <string, List <string> > kv in cp.localizationFiles) { DictionaryI18n packageDict = DictionaryI18n.ReadFromFileList("", kv.Value, DictionaryI18n.DEFAULT_LANG, Game.Get().currentLang); if (packageDict == null) { // Unable to load dictionary return; } packageDict.setCurrentLanguage(Game.Get().currentLang); LocalizationRead.AddDictionary(kv.Key, packageDict); } loadedPacks.Add(cp.id); foreach (string s in cp.clone) { LoadContentID(s); } }
// This loads content from a pack by object // Duplicate content will be replaced by the higher priority value void LoadContent(ContentData.ContentPack cp) { // Don't reload content if (cd.loadedPacks.Contains(cp.id)) { return; } foreach (KeyValuePair <string, List <string> > kv in cp.localizationFiles) { DictionaryI18n packageDict = new DictionaryI18n(); foreach (string file in kv.Value) { packageDict.AddDataFromFile(file); } LocalizationRead.AddDictionary(kv.Key, packageDict); } foreach (string ini in cp.iniFiles) { IniData d = IniRead.ReadFromIni(ini); // Bad ini file not a fatal error, just ignore (will be in log) if (d == null) { return; } // Add each section foreach (KeyValuePair <string, Dictionary <string, string> > section in d.data) { LoadContent(section.Key, section.Value, Path.GetDirectoryName(ini), cp.id); } } cd.loadedPacks.Add(cp.id); foreach (string s in cp.clone) { LoadContentID(s); } }
/// <summary> /// After selecting game, we load the localization file. /// Deppends on the gameType selected. /// There are two Localization files from ffg, one for D2E and one for MoM /// </summary> private void loadLocalization() { // After content import, we load the localization file if (LocalizationRead.selectDictionary("ffg") == null) { // FFG default language is always English LocalizationRead.AddDictionary("ffg", new DictionaryI18n( System.IO.File.ReadAllLines(ContentData.ImportPath() + "/text/Localization.txt"), DictionaryI18n.DEFAULT_LANG, Game.Get().currentLang)); // Hack for Dunwich Horror if (System.IO.File.Exists(ContentData.ImportPath() + "/text/SCENARIO_CULT_OF_SENTINEL_HILL_MAD22.txt")) { LocalizationRead.selectDictionary("ffg").Add(new DictionaryI18n(System.IO.File.ReadAllLines(ContentData.ImportPath() + "/text/SCENARIO_CULT_OF_SENTINEL_HILL_MAD22.txt"), DictionaryI18n.DEFAULT_LANG, Game.Get().currentLang)); } } }
/// <summary> /// After selecting game, we load the localization file. /// Deppends on the gameType selected. /// There are two Localization files from ffg, one for D2E and one for MoM /// </summary> private void loadLocalization() { // After content import, we load the localization file if (LocalizationRead.selectDictionary("ffg") == null) { DictionaryI18n ffgDict = new DictionaryI18n(); foreach (string file in Directory.GetFiles(ContentData.ImportPath() + "/text", "Localization_*.txt")) { ffgDict.AddDataFromFile(file); } LocalizationRead.AddDictionary("ffg", ffgDict); // CoSH used for Dunwich Horror data DictionaryI18n cshDict = new DictionaryI18n(); foreach (string file in Directory.GetFiles(ContentData.ImportPath() + "/text", "SCENARIO_CULT_OF_SENTINEL_HILL_MAD22_*.txt")) { cshDict.AddDataFromFile(file); } LocalizationRead.AddDictionary("csh", cshDict); } }
public void DrawList() { localManifest = IniRead.ReadFromString(""); if (File.Exists(saveLocation() + "/manifest.ini")) { localManifest = IniRead.ReadFromIni(saveLocation() + "/manifest.ini"); } // Heading UIElement ui = new UIElement(); ui.SetLocation(2, 1, UIScaler.GetWidthUnits() - 4, 3); ui.SetText(new StringKey("val", "QUEST_NAME_DOWNLOAD", game.gameType.QuestName())); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetLargeFont()); UIElementScrollVertical scrollArea = new UIElementScrollVertical(); scrollArea.SetLocation(1, 5, UIScaler.GetWidthUnits() - 2f, 21f); new UIElementBorder(scrollArea); // Start here float offset = 0; // Loop through all available quests foreach (KeyValuePair <string, Dictionary <string, string> > kv in remoteManifest.data) { string file = kv.Key + ".valkyrie"; LocalizationRead.AddDictionary("qst", localizationDict); string questName = new StringKey("qst", kv.Key + ".name").Translate(); int remoteFormat = 0; int.TryParse(remoteManifest.Get(kv.Key, "format"), out remoteFormat); bool formatOK = (remoteFormat >= QuestData.Quest.minumumFormat) && (remoteFormat <= QuestData.Quest.currentFormat); if (!formatOK) { continue; } bool exists = File.Exists(saveLocation() + "/" + file); bool update = true; if (exists) { string localHash = localManifest.Get(kv.Key, "version"); string remoteHash = remoteManifest.Get(kv.Key, "version"); update = !localHash.Equals(remoteHash); } Color bg = Color.white; if (exists) { bg = new Color(0.7f, 0.7f, 1f); if (!update) { bg = new Color(0.1f, 0.1f, 0.1f); } } // Frame ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(0.95f, offset, UIScaler.GetWidthUnits() - 4.9f, 3.1f); ui.SetBGColor(bg); if (update) { ui.SetButton(delegate { Selection(file); }); } offset += 0.05f; // Draw Image ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(1, offset, 3, 3); ui.SetBGColor(bg); if (update) { ui.SetButton(delegate { Selection(file); }); } int.TryParse(remoteManifest.Get(kv.Key, "format"), out remoteFormat); if (textures.ContainsKey(remoteManifest.Get(kv.Key, "image"))) { ui.SetImage(textures[remoteManifest.Get(kv.Key, "image")]); } ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetBGColor(Color.clear); ui.SetLocation(4, offset, UIScaler.GetWidthUnits() - 8, 3f); ui.SetTextPadding(1.2f); if (update && exists) { ui.SetText(new StringKey("val", "QUEST_NAME_UPDATE", questName), Color.black); } else { ui.SetText(questName, Color.black); } if (update) { ui.SetButton(delegate { Selection(file); }); } ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetFontSize(Mathf.RoundToInt(UIScaler.GetSmallFont() * 1.3f)); // Duration int lengthMax = 0; int.TryParse(remoteManifest.Get(kv.Key, "lengthmax"), out lengthMax); if (lengthMax > 0) { int lengthMin = 0; int.TryParse(remoteManifest.Get(kv.Key, "lengthmin"), out lengthMin); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetRight(-11), offset, 2, 1); ui.SetText(lengthMin.ToString(), Color.black); ui.SetBGColor(Color.clear); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetRight(-9), offset, 1, 1); ui.SetText("-", Color.black); ui.SetBGColor(Color.clear); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetRight(-8), offset, 2, 1); ui.SetText(lengthMax.ToString(), Color.black); ui.SetBGColor(Color.clear); } // Difficulty float difficulty = 0; float.TryParse(remoteManifest.Get(kv.Key, "difficulty"), out difficulty); if (difficulty != 0) { string symbol = "π"; // will if (game.gameType is MoMGameType) { symbol = new StringKey("val", "ICON_SUCCESS_RESULT").Translate(); } ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetRight(-12), offset + 1, 7, 2); ui.SetText(symbol + symbol + symbol + symbol + symbol, Color.black); ui.SetBGColor(Color.clear); ui.SetFontSize(UIScaler.GetMediumFont()); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetRight(-11.95f) + (difficulty * 6.9f), offset + 1, (1 - difficulty) * 6.9f, 2); Color filter = bg; filter.a = 0.7f; ui.SetBGColor(filter); } // Size is 1.2 to be clear of characters with tails if (exists) { ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(((UIScaler.GetWidthUnits() - 3) / 2) - 4, offset + 2.5f, 8, 1.2f); ui.SetBGColor(new Color(0.7f, 0, 0)); ui.SetText(CommonStringKeys.DELETE, Color.black); ui.SetButton(delegate { Delete(file); }); offset += 0.5f; } offset += 4; } foreach (KeyValuePair <string, Dictionary <string, string> > kv in localManifest.data) { // Only looking for files missing from remote if (remoteManifest.data.ContainsKey(kv.Key)) { continue; } string type = localManifest.Get(kv.Key, "type"); // Only looking for packages of this game type if (!game.gameType.TypeName().Equals(type)) { continue; } string file = kv.Key + ".valkyrie"; // Size is 1.2 to be clear of characters with tails if (File.Exists(saveLocation() + "/" + file)) { ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(1, offset, UIScaler.GetWidthUnits() - 8, 1.2f); ui.SetTextPadding(1.2f); ui.SetText(file, Color.black); ui.SetBGColor(new Color(0.1f, 0.1f, 0.1f)); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetWidthUnits() - 12, offset, 8, 1.2f); ui.SetText(CommonStringKeys.DELETE, Color.black); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetButton(delegate { Delete(file); }); ui.SetBGColor(new Color(0.7f, 0, 0)); offset += 2; } } scrollArea.SetScrollSize(offset); ui = new UIElement(); ui.SetLocation(1, UIScaler.GetBottom(-3), 8, 2); ui.SetText(CommonStringKeys.BACK, Color.red); ui.SetButton(delegate { Cancel(); }); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); new UIElementBorder(ui, Color.red); }
// Unity fires off this function void Awake() { // Find the common objects we use. These are created by unity. cc = GameObject.FindObjectOfType <CameraController>(); uICanvas = GameObject.Find("UICanvas").GetComponent <Canvas>(); boardCanvas = GameObject.Find("BoardCanvas").GetComponent <Canvas>(); tokenCanvas = GameObject.Find("TokenCanvas").GetComponent <Canvas>(); tokenBoard = GameObject.FindObjectOfType <TokenBoard>(); heroCanvas = GameObject.FindObjectOfType <HeroCanvas>(); monsterCanvas = GameObject.FindObjectOfType <MonsterCanvas>(); // Create some things uiScaler = new UIScaler(uICanvas); config = new ConfigFile(); GameObject go = new GameObject("audio"); audioControl = go.AddComponent <Audio>(); updateList = new List <IUpdateListener>(); stats = new StatsManager(); stats.DownloadStats(); if (config.data.Get("UserConfig") == null) { // English is the default current language config.data.Add("UserConfig", "currentLang", "English"); config.Save(); } currentLang = config.data.Get("UserConfig", "currentLang"); string vSet = config.data.Get("UserConfig", "editorTransparency"); if (vSet == "") { editorTransparency = 0.3f; } else { float.TryParse(vSet, out editorTransparency); } string s_debug_tests = config.data.Get("Debug", "tests"); if (s_debug_tests != "") { s_debug_tests = s_debug_tests.ToLower(); if (s_debug_tests == "true" || s_debug_tests == "1") { debugTests = true; } } // On android extract streaming assets for use if (Application.platform == RuntimePlatform.Android) { System.IO.Directory.CreateDirectory(ContentData.ContentPath()); using (ZipFile jar = ZipFile.Read(Application.dataPath)) { foreach (ZipEntry e in jar) { if (!e.FileName.StartsWith("assets")) { continue; } if (e.FileName.StartsWith("assets/bin")) { continue; } e.Extract(ContentData.ContentPath() + "../..", ExtractExistingFileAction.OverwriteSilently); } } } DictionaryI18n valDict = new DictionaryI18n(); foreach (string file in System.IO.Directory.GetFiles(ContentData.ContentPath() + "../text", "Localization*.txt")) { valDict.AddDataFromFile(file); } LocalizationRead.AddDictionary("val", valDict); roundControl = new RoundController(); // Read the version and add it to the log TextAsset versionFile = Resources.Load("version") as TextAsset; version = versionFile.text.Trim(); // The newline at the end stops the stack trace appearing in the log ValkyrieDebug.Log("Valkyrie Version: " + version + System.Environment.NewLine); #if UNITY_STANDALONE_WIN SetScreenOrientationToLandscape(); #endif // Bring up the Game selector gameSelect = new GameSelectionScreen(); }
public QuestSelectionScreen(Dictionary <string, QuestData.Quest> ql) { questList = ql; Game game = Game.Get(); // If a dialog window is open we force it closed (this shouldn't happen) foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.DIALOG)) { Object.Destroy(go); } // Clean up downloader if present foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.QUESTUI)) { Object.Destroy(go); } // Heading UIElement ui = new UIElement(); ui.SetLocation(2, 1, UIScaler.GetWidthUnits() - 4, 3); ui.SetText(new StringKey("val", "SELECT", game.gameType.QuestName())); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetLargeFont()); // error message if stats are not available if (game.stats.error_download) { float error_string_width = 0; ui = new UIElement(); if (game.stats.error_download_description == "ERROR NETWORK") { StringKey STATS_ERROR_NETWORK = new StringKey("val", "STATS_ERROR_NETWORK"); ui.SetText(STATS_ERROR_NETWORK, Color.red); error_string_width = ui.GetStringWidth(STATS_ERROR_NETWORK); } else { StringKey STATS_ERROR_HTTP = new StringKey("val", "STATS_ERROR_HTTP", game.stats.error_download_description); ui.SetText(STATS_ERROR_HTTP, Color.red); error_string_width = ui.GetStringWidth(STATS_ERROR_HTTP); } ui.SetLocation(UIScaler.GetHCenter() - (error_string_width / 2f), UIScaler.GetBottom(-3f), error_string_width, 2.4f); ui.SetTextAlignment(TextAnchor.MiddleCenter); ui.SetBGColor(Color.clear); } // error message if stats are not available if (game.stats.download_ongoing) { float ongoing_string_width = 0; ui = new UIElement(); StringKey STATS_DOWNLOAD_ONGOING = new StringKey("val", "STATS_DOWNLOAD_ONGOING"); ui.SetText(STATS_DOWNLOAD_ONGOING, Color.white); ongoing_string_width = ui.GetStringWidth(STATS_DOWNLOAD_ONGOING); ui.SetLocation(UIScaler.GetHCenter() - (ongoing_string_width / 2f), UIScaler.GetBottom(-3f), ongoing_string_width, 2.4f); ui.SetTextAlignment(TextAnchor.MiddleCenter); ui.SetBGColor(Color.clear); } UIElementScrollVertical scrollArea = new UIElementScrollVertical(); scrollArea.SetLocation(1, 5, UIScaler.GetWidthUnits() - 2f, 21f); new UIElementBorder(scrollArea); // Start here float offset = 0; // Loop through all available quests foreach (KeyValuePair <string, QuestData.Quest> q in questList) { if (q.Value.GetMissingPacks(game.cd.GetLoadedPackIDs()).Count == 0) { string key = q.Key; LocalizationRead.AddDictionary("qst", q.Value.localizationDict); string translation = q.Value.name.Translate(); // Frame ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(0.95f, offset, UIScaler.GetWidthUnits() - 4.9f, 3.6f); ui.SetBGColor(Color.white); ui.SetButton(delegate { Selection(key); }); offset += 0.05f; new UIElementBorder(ui, Color.grey); // Draw Image ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(1, offset, 3.5f, 3.5f); ui.SetBGColor(Color.white); ui.SetButton(delegate { Selection(key); }); if (q.Value.image.Length > 0) { ui.SetImage(ContentData.FileToTexture(Path.Combine(q.Value.path, q.Value.image))); } // Quest name ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetBGColor(Color.clear); ui.SetLocation(5f, offset - 0.2f, UIScaler.GetWidthUnits() - 8, 2.5f); ui.SetTextPadding(0.5f); ui.SetText(translation, Color.black); ui.SetButton(delegate { Selection(key); }); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetFontSize(Mathf.RoundToInt(UIScaler.GetSmallFont() * 1.4f)); ui.SetFont(game.gameType.GetHeaderFont()); // Duration if (q.Value.lengthMax != 0) { ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(6.5f, offset + 2.3f, 4, 1); ui.SetText(new StringKey("val", "DURATION"), Color.black); ui.SetButton(delegate { Selection(key); }); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetBGColor(Color.clear); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(10.5f, offset + 2.3f, 5, 1); ui.SetText(q.Value.lengthMin + " - " + q.Value.lengthMax, Color.black); ui.SetButton(delegate { Selection(key); }); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetBGColor(Color.clear); } // Difficulty if (q.Value.difficulty != 0) { ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetHCenter() - 5.5f, offset + 2.3f, 6, 1); ui.SetText(new StringKey("val", "DIFFICULTY"), Color.black); ui.SetButton(delegate { Selection(key); }); ui.SetTextAlignment(TextAnchor.MiddleRight); ui.SetBGColor(Color.clear); string symbol = "π"; // will if (game.gameType is MoMGameType) { symbol = new StringKey("val", "ICON_SUCCESS_RESULT").Translate(); } ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetHCenter(), offset + 1.8f, 9, 2); ui.SetText(symbol + symbol + symbol + symbol + symbol, Color.black); ui.SetBGColor(Color.clear); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { Selection(key); }); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetHCenter() + 1.05f + (q.Value.difficulty * 6.9f), offset + 1.8f, (1 - q.Value.difficulty) * 6.9f, 1.6f); ui.SetBGColor(new Color(1, 1, 1, 0.7f)); ui.SetButton(delegate { Selection(key); }); } // Statistics string filename = Path.GetFileName(key).ToLower(); if (game.stats != null && game.stats.scenarios_stats != null && game.stats.scenarios_stats.ContainsKey(filename)) { ScenarioStats q_stats = game.stats.scenarios_stats[filename]; int win_ratio = (int)(q_stats.scenario_avg_win_ratio * 100); StringKey STATS_AVERAGE_WIN_RATIO = new StringKey("val", "STATS_AVERAGE_WIN_RATIO", win_ratio); StringKey STATS_NO_AVERAGE_WIN_RATIO = new StringKey("val", "STATS_NO_AVERAGE_WIN_RATIO", win_ratio); StringKey STATS_NB_USER_REVIEWS = new StringKey("val", "STATS_NB_USER_REVIEWS", q_stats.scenario_play_count); StringKey STATS_AVERAGE_DURATION = new StringKey("val", "STATS_AVERAGE_DURATION", (int)(q_stats.scenario_avg_duration)); StringKey STATS_NO_AVERAGE_DURATION = new StringKey("val", "STATS_NO_AVERAGE_DURATION"); // rating string symbol = "★"; if (game.gameType is MoMGameType) { symbol = new StringKey("val", "ICON_TENTACLE").Translate(); } float rating = q_stats.scenario_avg_rating / 10; float score_text_width = 0; ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetText(symbol + symbol + symbol + symbol + symbol, Color.black); score_text_width = ui.GetStringWidth(symbol + symbol + symbol + symbol + symbol, (int)System.Math.Round(UIScaler.GetMediumFont() * 1.4f)) + 1; ui.SetLocation(UIScaler.GetRight(-12f), offset + 0.6f, score_text_width, 2); ui.SetBGColor(Color.clear); ui.SetFontSize((int)System.Math.Round(UIScaler.GetMediumFont() * 1.4f)); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetButton(delegate { Selection(key); }); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetRight(-12) + (rating * (score_text_width - 1)), offset + 0.6f, (1 - rating) * score_text_width, 2); ui.SetBGColor(new Color(1, 1, 1, 0.7f)); ui.SetButton(delegate { Selection(key); }); // Number of user reviews float user_review_text_width = 0; ui = new UIElement(scrollArea.GetScrollTransform()); user_review_text_width = ui.GetStringWidth(STATS_NB_USER_REVIEWS, UIScaler.GetSmallFont()) + 1; ui.SetText(STATS_NB_USER_REVIEWS, Color.black); ui.SetLocation(UIScaler.GetRight(-12) + (score_text_width / 2) - (user_review_text_width / 2), offset + 2.3f, user_review_text_width, 1); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetBGColor(Color.clear); ui.SetFontSize(UIScaler.GetSmallFont()); ui.SetButton(delegate { Selection(key); }); if (q_stats.scenario_avg_duration > 0 || win_ratio >= 0) { // Additional information in Grey frame ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(3.5f + 1f, offset + 3.6f, UIScaler.GetWidthUnits() - 4.9f - 3.5f - 0.05f, 1.2f); ui.SetBGColor(Color.grey); ui.SetButton(delegate { Selection(key); }); // average duration ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(5f, offset + 3.8f, 14, 1); if (q_stats.scenario_avg_duration > 0) { ui.SetText(STATS_AVERAGE_DURATION, Color.white); } else { ui.SetText(STATS_NO_AVERAGE_DURATION, Color.white); } ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetBGColor(Color.clear); ui.SetButton(delegate { Selection(key); }); // average win ratio ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetHCenter() - 5.5f, offset + 3.8f, 15, 1); if (win_ratio >= 0) { ui.SetText(STATS_AVERAGE_WIN_RATIO, Color.white); } else { ui.SetText(STATS_NO_AVERAGE_WIN_RATIO, Color.white); } ui.SetBGColor(Color.clear); ui.SetTextAlignment(TextAnchor.MiddleCenter); ui.SetButton(delegate { Selection(key); }); offset += 1.4f; } } offset += 4.5f; } } // Loop through all unavailable quests foreach (KeyValuePair <string, QuestData.Quest> q in questList) { if (q.Value.GetMissingPacks(game.cd.GetLoadedPackIDs()).Count > 0) { string key = q.Key; LocalizationRead.AddDictionary("qst", q.Value.localizationDict); string translation = q.Value.name.Translate(); // Size is 1.2 to be clear of characters with tails ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(1, offset, UIScaler.GetWidthUnits() - 5, 1.2f); ui.SetText(new StringKey("val", "INDENT", translation), Color.black); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetBGColor(new Color(0.4f, 0.4f, 0.4f)); offset += 1.2f; foreach (string s in q.Value.GetMissingPacks(game.cd.GetLoadedPackIDs())) { ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(3, offset, UIScaler.GetWidthUnits() - 9, 1.2f); ui.SetText(new StringKey("val", "REQUIRES_EXPANSION", game.cd.GetContentName(s)), Color.black); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetBGColor(new Color(0.4f, 0.4f, 0.4f)); offset += 1.2f; } offset += 0.8f; } } scrollArea.SetScrollSize(offset); ui = new UIElement(); ui.SetLocation(1, UIScaler.GetBottom(-3), 8, 2); ui.SetText(CommonStringKeys.BACK, Color.red); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { Cancel(); }); new UIElementBorder(ui, Color.red); ui = new UIElement(); ui.SetLocation(UIScaler.GetRight(-9), UIScaler.GetBottom(-3), 8, 2); ui.SetText(DOWNLOAD, Color.green); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { Download(); }); new UIElementBorder(ui, Color.green); }
// Create a pack with list of quests to edit public QuestEditSelection() { Game game = Game.Get(); // clear list of local quests to make sure we take the latest changes game.questsList.UnloadLocalQuests(); // Get list of unpacked quest in user location (editable) // TODO: open/save in packages questList = QuestLoader.GetUserUnpackedQuests(); // If a dialog window is open we force it closed (this shouldn't happen) foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.DIALOG)) { Object.Destroy(go); } // Heading UIElement ui = new UIElement(); ui.SetLocation(2, 1, UIScaler.GetWidthUnits() - 4, 3); ui.SetText(new StringKey("val", "SELECT", game.gameType.QuestName())); ui.SetFont(Game.Get().gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetLargeFont()); UIElementScrollVertical scrollArea = new UIElementScrollVertical(); scrollArea.SetLocation(1, 5, UIScaler.GetWidthUnits() - 2f, 21); new UIElementBorder(scrollArea); // List of quests int offset = 0; foreach (KeyValuePair <string, QuestData.Quest> q in questList) { string key = q.Key; LocalizationRead.AddDictionary("qst", q.Value.localizationDict); string translation = q.Value.name.Translate(); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(1, offset, UIScaler.GetWidthUnits() - 5, 1.2f); ui.SetText(new StringKey("val", "INDENT", translation), Color.black); ui.SetButton(delegate { Selection(key); }); ui.SetBGColor(Color.white); offset += 2; } scrollArea.SetScrollSize(offset); // Main menu ui = new UIElement(); ui.SetLocation(1, UIScaler.GetBottom(-3), 8, 2); ui.SetText(CommonStringKeys.BACK, Color.red); ui.SetFont(Game.Get().gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Cancel); new UIElementBorder(ui, Color.red); // Delete a user quest ui = new UIElement(); ui.SetLocation((UIScaler.GetRight() * 3 / 8) - 4, UIScaler.GetBottom(-3), 8, 2); ui.SetText(CommonStringKeys.DELETE, Color.red); ui.SetFont(Game.Get().gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Delete); new UIElementBorder(ui, Color.red); // Copy a quest ui = new UIElement(); ui.SetLocation((UIScaler.GetRight() * 5 / 8) - 4, UIScaler.GetBottom(-3), 8, 2); ui.SetText(CommonStringKeys.COPY); ui.SetFont(Game.Get().gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Copy); new UIElementBorder(ui); // Create a new quest ui = new UIElement(); ui.SetLocation(UIScaler.GetRight(-9), UIScaler.GetBottom(-3), 8, 2); ui.SetText(CommonStringKeys.NEW); ui.SetFont(Game.Get().gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(NewQuest); new UIElementBorder(ui); }
// Unity fires off this function void Start() { // Find the common objects we use. These are created by unity. cc = GameObject.FindObjectOfType <CameraController>(); uICanvas = GameObject.Find("UICanvas").GetComponent <Canvas>(); boardCanvas = GameObject.Find("BoardCanvas").GetComponent <Canvas>(); tokenCanvas = GameObject.Find("TokenCanvas").GetComponent <Canvas>(); tokenBoard = GameObject.FindObjectOfType <TokenBoard>(); heroCanvas = GameObject.FindObjectOfType <HeroCanvas>(); monsterCanvas = GameObject.FindObjectOfType <MonsterCanvas>(); // Create some things uiScaler = new UIScaler(uICanvas); config = new ConfigFile(); GameObject go = new GameObject("audio"); audioControl = go.AddComponent <Audio>(); updateList = new List <IUpdateListener>(); if (config.data.Get("UserConfig") == null) { // English is the default current language config.data.Add("UserConfig", "currentLang", "English"); config.Save(); } currentLang = config.data.Get("UserConfig", "currentLang"); // On android extract streaming assets for use if (Application.platform == RuntimePlatform.Android) { System.IO.Directory.CreateDirectory(ContentData.ContentPath()); using (ZipFile jar = ZipFile.Read(Application.dataPath)) { foreach (ZipEntry e in jar) { if (e.FileName.IndexOf("assets") != 0) { continue; } if (e.FileName.IndexOf("assets/bin") == 0) { continue; } e.Extract(ContentData.ContentPath() + "../..", ExtractExistingFileAction.OverwriteSilently); } } } DictionaryI18n valDict = new DictionaryI18n(); foreach (string file in System.IO.Directory.GetFiles(ContentData.ContentPath() + "../text", "Localization*.txt")) { valDict.AddDataFromFile(file); } LocalizationRead.AddDictionary("val", valDict); roundControl = new RoundController(); // Read the version and add it to the log TextAsset versionFile = Resources.Load("version") as TextAsset; version = versionFile.text.Trim(); // The newline at the end stops the stack trace appearing in the log ValkyrieDebug.Log("Valkyrie Version: " + version + System.Environment.NewLine); // Bring up the Game selector gameSelect = new GameSelectionScreen(); }
public QuestDetailsScreen(QuestData.Quest q) { Game game = Game.Get(); LocalizationRead.AddDictionary("qst", q.localizationDict); // If a dialog window is open we force it closed (this shouldn't happen) foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.DIALOG)) { Object.Destroy(go); } // Heading UIElement ui = new UIElement(); ui.SetLocation(2, 0.5f, UIScaler.GetWidthUnits() - 4, 3); ui.SetText(q.name); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetLargeFont()); // Draw Image if (q.image.Length > 0) { ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-20), 4, 8, 8); ui.SetImage(ContentData.FileToTexture(Path.Combine(q.path, q.image))); new UIElementBorder(ui); } // Draw Description ui = new UIElement(); float height = ui.GetStringHeight(q.description, 30); if (height > 25) { height = 25; } ui.SetLocation(UIScaler.GetHCenter(-7), 15 - (height / 2), 30, height); ui.SetText(q.description); new UIElementBorder(ui); // Draw authors ui = new UIElement(); height = ui.GetStringHeight(q.authors, 14); if (height > 25) { height = 25; } ui.SetLocation(UIScaler.GetHCenter(-23), 18.5f - (height / 2), 14, height); ui.SetText(q.authors); new UIElementBorder(ui); // Difficulty if (q.difficulty != 0) { ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-13), 27, 11, 1); ui.SetText(new StringKey("val", "DIFFICULTY")); string symbol = "*"; if (game.gameType is MoMGameType) { symbol = new StringKey("val", "ICON_SUCCESS_RESULT").Translate(); } ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-13), 28, 11, 2); ui.SetText(symbol + symbol + symbol + symbol + symbol); ui.SetFontSize(UIScaler.GetMediumFont()); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-10.95f) + (q.difficulty * 6.9f), 28, (1 - q.difficulty) * 6.9f, 2); ui.SetBGColor(new Color(0, 0, 0, 0.7f)); } // Duration if (q.lengthMax != 0) { ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(2), 27, 11, 1); ui.SetText(new StringKey("val", "DURATION")); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(2), 28, 4, 2); ui.SetText(q.lengthMin.ToString()); ui.SetFontSize(UIScaler.GetMediumFont()); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(6.5f), 28, 2, 2); ui.SetText("-"); ui.SetFontSize(UIScaler.GetMediumFont()); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(9), 28, 4, 2); ui.SetText(q.lengthMax.ToString()); ui.SetFontSize(UIScaler.GetMediumFont()); } // DELETE button (only for archive, directory might be edited by user) if (Path.GetExtension(Path.GetFileName(q.path)) == ".valkyrie") { ui = new UIElement(); ui.SetLocation(UIScaler.GetRight(-8.5f), 0.5f, 8, 2); ui.SetText(CommonStringKeys.DELETE, Color.grey); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { Delete(q); }); new UIElementBorder(ui, Color.grey); } ui = new UIElement(); ui.SetLocation(0.5f, UIScaler.GetBottom(-2.5f), 8, 2); ui.SetText(CommonStringKeys.BACK, Color.red); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Cancel); new UIElementBorder(ui, Color.red); ui = new UIElement(); ui.SetLocation(UIScaler.GetRight(-8.5f), UIScaler.GetBottom(-2.5f), 8, 2); ui.SetText(new StringKey("val", "START"), Color.green); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { Start(q); }); new UIElementBorder(ui, Color.green); }
public SaveData(int num = 0) { Game game = Game.Get(); if (!File.Exists(SaveFile(num))) { return; } try { if (!Directory.Exists(Path.GetTempPath() + "/Valkyrie")) { Directory.CreateDirectory(Path.GetTempPath() + "/Valkyrie"); } if (!Directory.Exists(Path.GetTempPath() + "/Valkyrie/Load")) { Directory.CreateDirectory(Path.GetTempPath() + "/Valkyrie/Load"); } Directory.Delete(Path.GetTempPath() + "/Valkyrie/Load", true); ZipFile zip = ZipFile.Read(SaveFile(num)); zip.ExtractAll(Path.GetTempPath() + "/Valkyrie/Load"); zip.Dispose(); image = ContentData.FileToTexture(Path.GetTempPath() + "/Valkyrie/Load/image.png"); // Check that quest in save is valid QuestData.Quest q = new QuestData.Quest(Path.GetTempPath() + "/Valkyrie/Load/quest"); if (!q.valid) { ValkyrieDebug.Log("Warning: Save " + num + " contains unsupported quest version." + System.Environment.NewLine); return; } DictionaryI18n tmpDict = LocalizationRead.selectDictionary("qst"); LocalizationRead.AddDictionary("qst", q.localizationDict); quest = q.name.Translate(); LocalizationRead.AddDictionary("qst", tmpDict); string data = File.ReadAllText(Path.GetTempPath() + "/Valkyrie/Load/save.ini"); IniData saveData = IniRead.ReadFromString(data); saveData.Get("Quest", "valkyrie"); if (VersionNewer(game.version, saveData.Get("Quest", "valkyrie"))) { ValkyrieDebug.Log("Warning: Save " + num + " is from a future version." + System.Environment.NewLine); return; } if (!VersionNewerOrEqual(minValkyieVersion, saveData.Get("Quest", "valkyrie"))) { ValkyrieDebug.Log("Warning: Save " + num + " is from an old unsupported version." + System.Environment.NewLine); return; } saveTime = System.DateTime.Parse(saveData.Get("Quest", "time")); valid = true; } catch (System.Exception e) { ValkyrieDebug.Log("Warning: Unable to open save file: " + SaveFile(num) + " " + e.Message); } }
// Build sorted lists public void SortQuests() { Game game = Game.Get(); if (quests_sorted_by_author == null) { quests_sorted_by_author = new SortedList <string, string>(new DuplicateKeyComparer <string>()); quests_sorted_by_name = new SortedList <string, string>(new DuplicateKeyComparer <string>()); quests_sorted_by_difficulty = new SortedList <float, string>(new DuplicateKeyComparer <float>()); quests_sorted_by_duration = new SortedList <int, string>(new DuplicateKeyComparer <int>()); quests_sorted_by_rating = new SortedList <float, string>(new DuplicateKeyComparer <float>()); quests_sorted_by_date = new SortedList <System.DateTime, string>(new DuplicateKeyComparer <System.DateTime>()); quests_sorted_by_avg_duration = new SortedList <float, string>(new DuplicateKeyComparer <float>()); quests_sorted_by_win_ratio = new SortedList <float, string>(new DuplicateKeyComparer <float>()); } else { quests_sorted_by_author.Clear(); quests_sorted_by_name.Clear(); quests_sorted_by_difficulty.Clear(); quests_sorted_by_duration.Clear(); quests_sorted_by_rating.Clear(); quests_sorted_by_date.Clear(); quests_sorted_by_avg_duration.Clear(); quests_sorted_by_win_ratio.Clear(); } if (quest_list_mode != QuestListMode.ONLINE || force_local_quest) { if (local_quests_data == null) { ValkyrieDebug.Log("INFO: No list of local quests available"); return; } ValkyrieDebug.Log("INFO: Sorting through " + local_quests_data.Count + " local quests"); foreach (KeyValuePair <string, QuestData.Quest> quest_data in local_quests_data) { LocalizationRead.AddDictionary("qst", quest_data.Value.localizationDict); quests_sorted_by_author.Add(quest_data.Value.GetShortAuthor(), quest_data.Key); quests_sorted_by_name.Add(quest_data.Value.name.Translate(), quest_data.Key); quests_sorted_by_difficulty.Add(quest_data.Value.difficulty, quest_data.Key); quests_sorted_by_duration.Add(quest_data.Value.lengthMax, quest_data.Key); } } else { if (game.stats != null && game.stats.scenarios_stats != null) // we should wait for stats to be available { if (remote_quests_data == null) { ValkyrieDebug.Log("INFO: No list of external quests available"); return; } ValkyrieDebug.Log("INFO: Sorting through stats data available for " + remote_quests_data.Count + " scenarios"); foreach (KeyValuePair <string, QuestData.Quest> quest_data in remote_quests_data) { string pkg_name = quest_data.Key.ToLower() + ".valkyrie"; if (game.stats.scenarios_stats.ContainsKey(pkg_name)) { quests_sorted_by_rating.Add(game.stats.scenarios_stats[pkg_name].scenario_avg_rating, quest_data.Key); quests_sorted_by_avg_duration.Add(game.stats.scenarios_stats[pkg_name].scenario_avg_duration, quest_data.Key); quests_sorted_by_win_ratio.Add(game.stats.scenarios_stats[pkg_name].scenario_avg_win_ratio, quest_data.Key); } else { quests_sorted_by_rating.Add(0.0f, quest_data.Key); quests_sorted_by_avg_duration.Add(0.0f, quest_data.Key); quests_sorted_by_win_ratio.Add(0.0f, quest_data.Key); } // Use player selected language or scenario default language for sort by name if (quest_data.Value.languages_name.Keys.Contains(game.currentLang)) { quests_sorted_by_name.Add(quest_data.Value.languages_name[game.currentLang], quest_data.Key); } else { quests_sorted_by_name.Add(quest_data.Value.languages_name[quest_data.Value.defaultLanguage], quest_data.Key); } quests_sorted_by_difficulty.Add(quest_data.Value.difficulty, quest_data.Key); quests_sorted_by_duration.Add(quest_data.Value.lengthMax, quest_data.Key); quests_sorted_by_date.Add(quest_data.Value.latest_update, quest_data.Key); quests_sorted_by_author.Add(quest_data.Value.GetShortAuthor(), quest_data.Key); } } } }
public QuestSelectionScreen(Dictionary <string, QuestData.Quest> ql) { questList = ql; Game game = Game.Get(); // If a dialog window is open we force it closed (this shouldn't happen) foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.DIALOG)) { Object.Destroy(go); } // Clean up downloader if present foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.QUESTUI)) { Object.Destroy(go); } // Heading UIElement ui = new UIElement(); ui.SetLocation(2, 1, UIScaler.GetWidthUnits() - 4, 3); ui.SetText(new StringKey("val", "SELECT", game.gameType.QuestName())); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetLargeFont()); UIElementScrollVertical scrollArea = new UIElementScrollVertical(); scrollArea.SetLocation(1, 5, UIScaler.GetWidthUnits() - 2f, 21f); new UIElementBorder(scrollArea); // Start here float offset = 0; // Loop through all available quests foreach (KeyValuePair <string, QuestData.Quest> q in questList) { if (q.Value.GetMissingPacks(game.cd.GetLoadedPackIDs()).Count == 0) { string key = q.Key; LocalizationRead.AddDictionary("qst", q.Value.localizationDict); string translation = q.Value.name.Translate(); // Frame ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(0.95f, offset, UIScaler.GetWidthUnits() - 4.9f, 3.1f); ui.SetBGColor(Color.white); ui.SetButton(delegate { Selection(key); }); offset += 0.05f; // Draw Image ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(1, offset, 3, 3); ui.SetBGColor(Color.white); ui.SetButton(delegate { Selection(key); }); if (q.Value.image.Length > 0) { ui.SetImage(ContentData.FileToTexture(Path.Combine(q.Value.path, q.Value.image))); } ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetBGColor(Color.clear); ui.SetLocation(4, offset, UIScaler.GetWidthUnits() - 8, 3f); ui.SetTextPadding(1.2f); ui.SetText(translation, Color.black); ui.SetButton(delegate { Selection(key); }); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetFontSize(Mathf.RoundToInt(UIScaler.GetSmallFont() * 1.3f)); // Duration if (q.Value.lengthMax != 0) { ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetRight(-11), offset, 2, 1); ui.SetText(q.Value.lengthMin.ToString(), Color.black); ui.SetButton(delegate { Selection(key); }); ui.SetBGColor(Color.clear); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetRight(-9), offset, 1, 1); ui.SetButton(delegate { Selection(key); }); ui.SetText("-", Color.black); ui.SetBGColor(Color.clear); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetRight(-8), offset, 2, 1); ui.SetText(q.Value.lengthMax.ToString(), Color.black); ui.SetButton(delegate { Selection(key); }); ui.SetBGColor(Color.clear); } // Difficulty if (q.Value.difficulty != 0) { string symbol = "π"; // will if (game.gameType is MoMGameType) { symbol = new StringKey("val", "ICON_SUCCESS_RESULT").Translate(); } ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetRight(-13), offset + 1, 9, 2); ui.SetText(symbol + symbol + symbol + symbol + symbol, Color.black); ui.SetBGColor(Color.clear); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { Selection(key); }); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(UIScaler.GetRight(-11.95f) + (q.Value.difficulty * 6.9f), offset + 1, (1 - q.Value.difficulty) * 6.9f, 2); ui.SetBGColor(new Color(1, 1, 1, 0.7f)); ui.SetButton(delegate { Selection(key); }); } offset += 4; } } // Loop through all unavailable quests foreach (KeyValuePair <string, QuestData.Quest> q in questList) { if (q.Value.GetMissingPacks(game.cd.GetLoadedPackIDs()).Count > 0) { string key = q.Key; LocalizationRead.AddDictionary("qst", q.Value.localizationDict); string translation = q.Value.name.Translate(); // Size is 1.2 to be clear of characters with tails ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(1, offset, UIScaler.GetWidthUnits() - 5, 1.2f); ui.SetText(new StringKey("val", "INDENT", translation), Color.black); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetBGColor(new Color(0.4f, 0.4f, 0.4f)); offset += 1.2f; foreach (string s in q.Value.GetMissingPacks(game.cd.GetLoadedPackIDs())) { ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(3, offset, UIScaler.GetWidthUnits() - 9, 1.2f); ui.SetText(new StringKey("val", "REQUIRES_EXPANSION", game.cd.GetContentName(s)), Color.black); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetBGColor(new Color(0.4f, 0.4f, 0.4f)); offset += 1.2f; } } offset += 0.8f; } scrollArea.SetScrollSize(offset); ui = new UIElement(); ui.SetLocation(1, UIScaler.GetBottom(-3), 8, 2); ui.SetText(CommonStringKeys.BACK, Color.red); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { Cancel(); }); new UIElementBorder(ui, Color.red); ui = new UIElement(); ui.SetLocation(UIScaler.GetRight(-9), UIScaler.GetBottom(-3), 8, 2); ui.SetText(DOWNLOAD, Color.green); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { Download(); }); new UIElementBorder(ui, Color.green); }