From 816049d451abdf2b27bef8d41f8ff99f233520ce Mon Sep 17 00:00:00 2001 From: headassbtw Date: Sun, 18 Jul 2021 03:40:18 -0700 Subject: [PATCH] tried to fix a bug but fuck???? --- CustomMenuText.sln | 12 +++---- CustomMenuText/CustomMenuText.csproj | 8 +++++ .../TextSelectorViewController.cs | 32 +++++++++++++------ 3 files changed, 37 insertions(+), 15 deletions(-) diff --git a/CustomMenuText.sln b/CustomMenuText.sln index 0650978..f55cb42 100644 --- a/CustomMenuText.sln +++ b/CustomMenuText.sln @@ -7,14 +7,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomMenuText", "CustomMen EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BD778688-A364-4686-9D97-B7FB0E34C684}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BD778688-A364-4686-9D97-B7FB0E34C684}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BD778688-A364-4686-9D97-B7FB0E34C684}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BD778688-A364-4686-9D97-B7FB0E34C684}.Release|Any CPU.Build.0 = Release|Any CPU + {BD778688-A364-4686-9D97-B7FB0E34C684}.Debug|x64.ActiveCfg = Debug|x64 + {BD778688-A364-4686-9D97-B7FB0E34C684}.Debug|x64.Build.0 = Debug|x64 + {BD778688-A364-4686-9D97-B7FB0E34C684}.Release|x64.ActiveCfg = Release|x64 + {BD778688-A364-4686-9D97-B7FB0E34C684}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/CustomMenuText/CustomMenuText.csproj b/CustomMenuText/CustomMenuText.csproj index a003da7..2d06e7c 100644 --- a/CustomMenuText/CustomMenuText.csproj +++ b/CustomMenuText/CustomMenuText.csproj @@ -39,6 +39,14 @@ True True + + bin\x64\Release\ + x64 + + + bin\x64\Debug\ + x64 + False diff --git a/CustomMenuText/Views/TextSelector/TextSelectorViewController.cs b/CustomMenuText/Views/TextSelector/TextSelectorViewController.cs index c03d0b5..53ad89e 100644 --- a/CustomMenuText/Views/TextSelector/TextSelectorViewController.cs +++ b/CustomMenuText/Views/TextSelector/TextSelectorViewController.cs @@ -345,28 +345,42 @@ public void SetupTextList() } public void SetupFontList() { + //this should prevent selecting a font that doesn't exist if (Configuration.PluginConfig.Instance.Font > FontManager.Fonts.Count) Configuration.PluginConfig.Instance.Font = FontManager.Fonts.Count; fontListData.data.Clear(); foreach (var font in FontManager.Fonts) { - string name = Path.GetFileNameWithoutExtension(font.sourceFontFile.name); - Plugin.Log.Notice($"adding font\"{name}\" to table"); - CustomListTableData.CustomCellInfo fontCell; - if (name.ToLower().Equals("neontubes2") || name.ToLower().Equals("beon") || name.ToLower().Equals("teko")) + try { - fontCell = new CustomListTableData.CustomCellInfo(name, "Built-In"); - fontListData.data.Add(fontCell); + string name = Path.GetFileNameWithoutExtension(font.sourceFontFile.name); + Plugin.Log.Notice($"adding font\"{name}\" to table"); + + if (name.ToLower().Equals("neontubes2") || name.ToLower().Equals("beon") || name.ToLower().Equals("teko")) + { + fontCell = new CustomListTableData.CustomCellInfo(name, "Built-In"); + fontListData.data.Add(fontCell); + } + else + { + fontCell = new CustomListTableData.CustomCellInfo(name); + fontListData.data.Add(fontCell); + } } - else + catch (Exception e) { - fontCell = new CustomListTableData.CustomCellInfo(name); + fontCell = new CustomListTableData.CustomCellInfo("Broken Font", "please remove it"); fontListData.data.Add(fontCell); + Plugin.Log.Critical("Exception while adding font:"); + Console.WriteLine(e.ToString()); } + } fontListData.tableView.ReloadData(); - fontListData.tableView.SelectCellWithIdx(Configuration.PluginConfig.Instance.Font); + + try{fontListData.tableView.SelectCellWithIdx(Configuration.PluginConfig.Instance.Font);} + catch(IndexOutOfRangeException){Plugin.Log.Critical("Tried to select a font beyond the bounds of the list");} Plugin.mainText.font = FontManager.Fonts[Configuration.PluginConfig.Instance.Font]; Plugin.bottomText.font = FontManager.Fonts[Configuration.PluginConfig.Instance.Font]; }