|
2 | 2 |
|
3 | 3 | import arc.Core; |
4 | 4 | import arc.Events; |
5 | | -import arc.graphics.g2d.Draw; |
6 | | -import arc.graphics.g2d.TextureAtlas; |
7 | | -import arc.graphics.gl.Shader; |
| 5 | +import arc.graphics.g2d.SortedSpriteBatch; |
| 6 | +import arc.graphics.g2d.TextureRegion; |
8 | 7 | import arc.util.Time; |
9 | 8 | import mindustry.Vars; |
10 | 9 | import mindustry.game.EventType; |
11 | 10 | import mindustry.io.SaveVersion; |
12 | 11 | import org.durmiendo.sueno.controllers.CelestialBodyController; |
13 | 12 | import org.durmiendo.sueno.graphics.NTexture; |
14 | | -import org.durmiendo.sueno.graphics.SBlockRenderer; |
15 | | -import org.durmiendo.sueno.graphics.SShaders; |
| 13 | +import org.durmiendo.sueno.graphics.SBatch; |
16 | 14 | import org.durmiendo.sueno.graphics.VoidStriderCollapseEffectController; |
17 | 15 | import org.durmiendo.sueno.processors.SuenoInputProcessor; |
18 | 16 | import org.durmiendo.sueno.settings.SettingsBuilder; |
@@ -99,39 +97,59 @@ private static void loadChunks() { |
99 | 97 | } |
100 | 98 |
|
101 | 99 | private static void loadRender() { |
102 | | - try { |
103 | | - Field f = Vars.renderer.getClass().getDeclaredField("blocks"); |
104 | | - f.setAccessible(true); |
105 | | - f.set(Vars.renderer, new SBlockRenderer()); |
106 | | - } catch (Exception e) { |
107 | | - SLog.err("Renderer dont load :("); |
| 100 | +// try { |
| 101 | +// Field f = Vars.renderer.getClass().getDeclaredField("blocks"); |
| 102 | +// f.setAccessible(true); |
| 103 | +// f.set(Vars.renderer, new SBlockRenderer()); |
| 104 | +// } catch (Exception e) { |
| 105 | +// SLog.err("Renderer dont load :("); |
108 | 106 | // throw new RuntimeException(e); |
109 | | - } |
110 | | - |
111 | | - Events.on(EventType.ClientLoadEvent.class, e -> { |
112 | | - SLog.loadTime(() -> { |
113 | | - final int[] loaded = {0}; |
114 | | - Core.atlas.getRegionMap().each((s, atlasRegion) -> { |
115 | | - TextureAtlas.AtlasRegion n = Core.atlas.find(s + "-normal"); |
116 | | - if (Core.atlas.isFound(n)) { |
117 | | - loaded[0]++; |
118 | | - SLog.load("normal texture, founded: " + s); |
119 | | - n.texture = new NTexture(atlasRegion.texture, n.texture); |
| 107 | +// } |
| 108 | + |
| 109 | + SLog.loadTime(() -> { |
| 110 | + final int[] loaded = {0}; |
| 111 | + Core.atlas.getRegionMap().each((s, atlasRegion) -> { |
| 112 | + SVars.regions.put(atlasRegion.texture, s); |
| 113 | + TextureRegion n = Core.atlas.find(s + "-normal"); |
| 114 | + if (Core.atlas.isFound(n)) { |
| 115 | + loaded[0]++; |
| 116 | + SLog.load("normal texture, founded: " + s); |
| 117 | + SVars.textureToNormal.put(atlasRegion.texture, n.texture); |
| 118 | + atlasRegion.texture = new NTexture(atlasRegion.texture, n.texture); |
| 119 | + Core.atlas.getTextures().remove(atlasRegion.texture); |
| 120 | + Core.atlas.getTextures().add(n.texture); |
| 121 | + } |
| 122 | + }); |
| 123 | + SLog.info(loaded[0] + " normal textures loaded!"); |
| 124 | + |
| 125 | + try { |
| 126 | + Field[] from = Core.batch.getClass().getFields(); |
| 127 | + SortedSpriteBatch b = new SBatch(); |
| 128 | + for (Field fromField : from) { |
| 129 | + try { |
| 130 | + Field toField = b.getClass().getField(fromField.getName()); |
| 131 | + fromField.setAccessible(true); |
| 132 | + toField.setAccessible(true); |
| 133 | + toField.set(b, fromField.get(Core.batch)); |
| 134 | + } catch (Exception ee) { |
| 135 | + SLog.load(ee.getMessage()); |
120 | 136 | } |
121 | | - }); |
122 | | - SLog.info(loaded[0] + " normal textures loaded!"); |
123 | | - Draw.shader(SShaders.normalShader, true); |
124 | | - }, "normal texture load"); |
125 | | - }); |
| 137 | + } |
126 | 138 |
|
127 | | - Shader[] last = new Shader[1]; |
128 | | - |
129 | | - Events.run(EventType.Trigger.drawOver, () -> { |
| 139 | + Core.batch = b; |
| 140 | + } catch (Exception e) { |
| 141 | + SLog.err("Error updating batch: " + e.getMessage()); |
| 142 | + } |
| 143 | + }, "normal texture load"); |
| 144 | +// |
| 145 | +// Shader[] last = new Shader[1]; |
| 146 | +// |
| 147 | +// Events.run(EventType.Trigger.drawOver, () -> { |
130 | 148 | // last[0] = Draw.getShader(); |
131 | 149 |
|
132 | | - }); |
133 | | - |
134 | | - Events.run(EventType.Trigger.uiDrawBegin, () -> Draw.shader(last[0])); |
| 150 | +// }); |
| 151 | +// |
| 152 | +// Events.run(EventType.Trigger.uiDrawBegin, () -> Draw.shader(last[0])); |
135 | 153 |
|
136 | 154 |
|
137 | 155 |
|
|
0 commit comments