Changeset 292
- Timestamp:
- Sep 25, 2016, 2:02:19 PM (8 years ago)
- Location:
- binary-improvements
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/AllocsCommands/ModInfo.xml
r289 r292 5 5 <Description value="Additional commands for server operation" /> 6 6 <Author value="Christian 'Alloc' Illy" /> 7 <Version value=" 9" />7 <Version value="10" /> 8 8 <Website value="http://7dtd.illy.bz" /> 9 9 </ModInfo> -
binary-improvements/MapRendering/ModInfo.xml
r289 r292 5 5 <Description value="Render the game map to image map tiles as it is uncovered" /> 6 6 <Author value="Christian 'Alloc' Illy" /> 7 <Version value="1 6" />7 <Version value="17" /> 8 8 <Website value="http://7dtd.illy.bz" /> 9 9 </ModInfo> -
binary-improvements/MapRendering/Web/Handlers/ItemIconHandler.cs
r291 r292 5 5 6 6 using UnityEngine; 7 using System.IO; 7 8 8 9 namespace AllocsFixes.NetConnections.Servers.Web.Handlers … … 87 88 } 88 89 90 // Get list of used tints for all items 89 91 Dictionary<string, List<Color>> tintedIcons = new Dictionary<string, List<Color>> (); 90 92 foreach (ItemClass ic in ItemClass.list) { … … 102 104 } 103 105 106 // Load icons from vanilla 104 107 foreach (UISpriteData data in sprites) { 105 108 string name = data.name; … … 107 110 tex.SetPixels (atlasTex.GetPixels (data.x, atlasTex.height - data.height - data.y, data.width, data.height)); 108 111 109 icons.Add (name + "__FFFFFF", tex.EncodeToPNG ()); 110 111 if (tintedIcons.ContainsKey (name)) { 112 foreach (Color c in tintedIcons [name]) { 113 string tintedName = name + "__" + AllocsUtils.ColorToHex (c); 114 if (!icons.ContainsKey (tintedName)) { 115 Texture2D tintedTex = new Texture2D (data.width, data.height, TextureFormat.ARGB32, false); 116 117 for (int x = 0; x < data.width; x++) { 118 for (int y = 0; y < data.height; y++) { 119 tintedTex.SetPixel (x, y, tex.GetPixel (x, y) * c); 120 } 121 } 122 123 icons.Add (tintedName, tintedTex.EncodeToPNG ()); 124 125 UnityEngine.Object.Destroy (tintedTex); 126 } 127 } 128 } 112 AddIcon (name, tex, tintedIcons); 129 113 130 114 UnityEngine.Object.Destroy (tex); 131 115 } 116 Resources.UnloadAsset(atlasTex); 132 117 133 Resources.UnloadAsset(atlasTex); 118 // Load icons from mods 119 foreach (Mod mod in ModManager.GetLoadedMods ()) { 120 try { 121 string modIconsPath = mod.Path + "/ItemIcons"; 122 if (Directory.Exists (modIconsPath)) { 123 foreach (string file in Directory.GetFiles (modIconsPath)) { 124 try { 125 if (file.ToLower ().EndsWith (".png")) { 126 string name = Path.GetFileNameWithoutExtension (file); 127 Texture2D tex = new Texture2D (1, 1, TextureFormat.ARGB32, false); 128 if (tex.LoadImage (File.ReadAllBytes (file))) { 129 if (tex.width == elementWidth && tex.height == elementHeight) { 130 AddIcon (name, tex, tintedIcons); 131 } 132 133 UnityEngine.Object.Destroy (tex); 134 } 135 } 136 } catch (Exception e) { 137 Log.Exception (e); 138 } 139 } 140 } 141 } catch (Exception e) { 142 Log.Exception (e); 143 } 144 } 134 145 135 146 loaded = true; … … 139 150 } 140 151 } 152 153 private void AddIcon (string _name, Texture2D _tex, Dictionary<string, List<Color>> _tintedIcons) { 154 icons.Add (_name + "__FFFFFF", _tex.EncodeToPNG ()); 155 156 if (_tintedIcons.ContainsKey (_name)) { 157 foreach (Color c in _tintedIcons [_name]) { 158 string tintedName = _name + "__" + AllocsUtils.ColorToHex (c); 159 if (!icons.ContainsKey (tintedName)) { 160 Texture2D tintedTex = new Texture2D (_tex.width, _tex.height, TextureFormat.ARGB32, false); 161 162 for (int x = 0; x < _tex.width; x++) { 163 for (int y = 0; y < _tex.height; y++) { 164 tintedTex.SetPixel (x, y, _tex.GetPixel (x, y) * c); 165 } 166 } 167 168 icons.Add (tintedName, tintedTex.EncodeToPNG ()); 169 170 UnityEngine.Object.Destroy (tintedTex); 171 } 172 } 173 } 174 } 175 141 176 } 142 177 }
Note:
See TracChangeset
for help on using the changeset viewer.