Changeset 505
- Timestamp:
- Apr 10, 2025, 3:30:00 PM (3 days ago)
- Location:
- TFP-WebServer
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
TFP-WebServer/WebServer/ModInfo.xml
r504 r505 5 5 <Description value="Integrated Webserver for the Web Dashboard and server APIs" /> 6 6 <Author value="The Fun Pimps LLC" /> 7 <Version value="2.0.0. 1" />7 <Version value="2.0.0.3" /> 8 8 <Website value="" /> 9 9 </xml> -
TFP-WebServer/WebServer/src/ModApi.cs
r504 r505 27 27 28 28 if (ItemIconHandler.Instance != null) { 29 ItemIconHandler.Instance.LoadIcons ();29 ThreadManager.StartCoroutine (ItemIconHandler.Instance.LoadIcons ()); 30 30 } 31 31 } -
TFP-WebServer/WebServer/src/UrlHandlers/ItemIconHandler.cs
r467 r505 1 1 using System; 2 using System.Collections; 2 3 using System.Collections.Generic; 3 4 using System.IO; … … 68 69 } 69 70 70 public bool LoadIcons () { 71 private const int LoadingMaxMsPerFrame = 100; 72 private bool loading; 73 public IEnumerator LoadIcons () { 71 74 72 75 lock (icons) { 73 if (loaded) { 74 return true; 75 } 76 if (loading || loaded) { 77 yield break; 78 } 79 80 loading = true; 81 82 MicroStopwatch mswPerFrame = new MicroStopwatch (true); 76 83 77 84 LoadingStats stats = new LoadingStats (); … … 99 106 } 100 107 101 try { 102 loadIconsFromFolder (GameIO.GetGameDir ("Data/ItemIcons"), tintedIcons, stats); 103 } catch (Exception e) { 104 Log.Error ("[Web] Failed loading icons from base game"); 105 Log.Exception (e); 106 } 108 yield return loadIconsFromFolder (GameIO.GetGameDir ("Data/ItemIcons"), tintedIcons, stats, mswPerFrame); 107 109 108 110 // Load icons from mods 109 111 foreach (Mod mod in ModManager.GetLoadedMods ()) { 110 try { 111 string modIconsPath = $"{mod.Path}/ItemIcons"; 112 loadIconsFromFolder (modIconsPath, tintedIcons, stats); 113 } catch (Exception e) { 114 Log.Error ($"[Web] Failed loading icons from mod {mod.Name}"); 115 Log.Exception (e); 116 } 112 string modIconsPath = $"{mod.Path}/ItemIcons"; 113 yield return loadIconsFromFolder (modIconsPath, tintedIcons, stats, mswPerFrame); 117 114 } 118 115 … … 133 130 Log.Out ($"[Web] IconHandler: Cached {totalSize / 1024} KiB"); 134 131 } 135 136 return true; 137 } 138 } 139 140 private void loadIconsFromFolder (string _path, Dictionary<string, List<Color>> _tintedIcons, LoadingStats _stats) { 132 } 133 } 134 135 private IEnumerator loadIconsFromFolder (string _path, Dictionary<string, List<Color>> _tintedIcons, LoadingStats _stats, 136 MicroStopwatch _mswPerFrame) { 141 137 if (!Directory.Exists (_path)) { 142 return; 143 } 138 yield break; 139 } 140 141 _mswPerFrame.ResetAndRestart (); 144 142 145 143 foreach (string file in Directory.GetFiles (_path)) { … … 164 162 Object.Destroy (tex); 165 163 } catch (Exception e) { 164 Log.Error ($"[Web] Failed loading icon from {_path}"); 166 165 Log.Exception (e); 166 } 167 168 if (_mswPerFrame.ElapsedMilliseconds >= LoadingMaxMsPerFrame) { 169 yield return null; 170 _mswPerFrame.ResetAndRestart (); 167 171 } 168 172 } -
TFP-WebServer/WebServer/src/WebAPI/APIs/WorldState/Player.cs
r487 r505 158 158 159 159 _writer.WriteRaw (jsonLevelKey); 160 _writer.Write Null (); // TODO160 _writer.WriteInt32 (entity.Progression.Level); 161 161 162 162 _writer.WriteRaw (jsonHealthKey); -
TFP-WebServer/bin/Mods/TFP_WebServer/ModInfo.xml
r504 r505 5 5 <Description value="Integrated Webserver for the Web Dashboard and server APIs" /> 6 6 <Author value="The Fun Pimps LLC" /> 7 <Version value="2.0.0. 1" />7 <Version value="2.0.0.3" /> 8 8 <Website value="" /> 9 9 </xml>
Note:
See TracChangeset
for help on using the changeset viewer.