diff --git a/core/assets-raw/sprites/ui/icons/icon-arrow-down.png b/core/assets-raw/sprites/ui/icons/icon-arrow-down.png index e3e941b082..8c6a7fc3b9 100644 Binary files a/core/assets-raw/sprites/ui/icons/icon-arrow-down.png and b/core/assets-raw/sprites/ui/icons/icon-arrow-down.png differ diff --git a/core/assets-raw/sprites/ui/icons/icon-arrow-up.png b/core/assets-raw/sprites/ui/icons/icon-arrow-up.png index 30e1a4201c..da89b30c25 100644 Binary files a/core/assets-raw/sprites/ui/icons/icon-arrow-up.png and b/core/assets-raw/sprites/ui/icons/icon-arrow-up.png differ diff --git a/core/assets/mindustry-maps/maps.json b/core/assets/mindustry-maps/maps.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/core/assets/mindustry-maps/maps.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/core/assets/mindustry-saves/0.mins b/core/assets/mindustry-saves/0.mins new file mode 100644 index 0000000000..090f2aa2c4 Binary files /dev/null and b/core/assets/mindustry-saves/0.mins differ diff --git a/core/assets/shaders/shield.fragment b/core/assets/shaders/shield.fragment index 08cc456823..b32e5a76bb 100644 --- a/core/assets/shaders/shield.fragment +++ b/core/assets/shaders/shield.fragment @@ -1,6 +1,6 @@ #ifdef GL_ES -precision mediump float; -precision mediump int; +precision highp float; +precision highp int; #endif #define MAX_HITS 64 @@ -13,6 +13,7 @@ uniform vec4 u_color; uniform vec2 u_texsize; uniform float u_time; uniform float u_scaling; +uniform float u_dp; uniform vec2 u_offset; uniform int u_hitamount; uniform vec3 u_hits[MAX_HITS]; @@ -20,15 +21,19 @@ uniform vec3 u_hits[MAX_HITS]; varying vec4 v_color; varying vec2 v_texCoord; +float round(float f){ + return float(int(f)); +} + void main() { vec2 T = v_texCoord.xy; vec2 coords = (T * u_texsize) + u_offset; - T += vec2(sin(coords.y / 3.0 + u_time / 20.0) / 250.0, sin(coords.x / 3.0 + u_time / 20.0) / 250.0) * u_scaling; + T += vec2(sin(coords.y / 3.0 + u_time / 20.0) / 240.0, sin(coords.x / 3.0 + u_time / 20.0) / 240.0) * u_scaling; - float si = 1.0 + sin(u_time / 20.0 /*+ (coords.x + coords.y) / 30.0*/) / 8.0; + float si = 1.0 + sin(u_time / 20.0) / 8.0; vec4 color = texture2D(u_texture, T) * vec4(si, si, si, 1.0); @@ -47,10 +52,9 @@ void main() { if(any){ gl_FragColor = u_color * vec4(si, si, si, 1.0); }else{ - - //coords.x = float(int(coords.x)); + if(color.a > 0.1){ - if(mod(coords.x + coords.y + sin(coords.x / 5.0) * 3.0 + sin(coords.y / 5.0) * 3.0 + u_time / 4.0, 10.0) < 2.0){ + if(mod(coords.x / u_dp + coords.y / u_dp + sin(round(coords.x / u_dp) / 5.0) * 3.0 + sin(round(coords.y / u_dp) / 5.0) * 3.0 + u_time / 4.0, 10.0) < 2.0){ color *= 1.65; } diff --git a/core/assets/sprites/sprites.atlas b/core/assets/sprites/sprites.atlas index d43a165017..25f37e416b 100644 --- a/core/assets/sprites/sprites.atlas +++ b/core/assets/sprites/sprites.atlas @@ -48,28 +48,28 @@ blocks/blackstone2 index: -1 blocks/blackstone3 rotate: false - xy: 736, 253 + xy: 748, 254 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/blackstoneblock1 rotate: false - xy: 736, 243 + xy: 575, 205 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/blackstoneblock2 rotate: false - xy: 748, 266 + xy: 575, 195 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/blackstoneblock3 rotate: false - xy: 740, 233 + xy: 533, 125 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -83,7 +83,7 @@ blocks/blackstoneedge index: -1 blocks/block rotate: false - xy: 575, 195 + xy: 533, 105 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -118,112 +118,112 @@ blocks/chainturret-icon index: -1 blocks/coal1 rotate: false - xy: 533, 115 + xy: 543, 117 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coal2 rotate: false - xy: 533, 105 + xy: 543, 107 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coal3 rotate: false - xy: 543, 127 + xy: 813, 449 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coaldrill rotate: false - xy: 543, 117 + xy: 813, 439 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coalgenerator rotate: false - xy: 543, 107 + xy: 813, 429 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coalgenerator-top rotate: false - xy: 813, 449 + xy: 813, 419 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/coalpurifier rotate: false - xy: 813, 439 + xy: 333, 79 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/combustiongenerator rotate: false - xy: 813, 429 + xy: 343, 79 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/compositewall rotate: false - xy: 813, 419 + xy: 353, 79 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conduit rotate: false - xy: 333, 79 + xy: 363, 79 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conduitbottom rotate: false - xy: 343, 79 + xy: 373, 79 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conduitliquid rotate: false - xy: 353, 79 + xy: 383, 79 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conduittop rotate: false - xy: 363, 79 + xy: 393, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conveyor rotate: false - xy: 373, 79 + xy: 403, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conveyormove rotate: false - xy: 383, 79 + xy: 413, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/conveyortunnel rotate: false - xy: 393, 83 + xy: 423, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -237,42 +237,42 @@ blocks/core index: -1 blocks/cross rotate: false - xy: 403, 83 + xy: 433, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/crucible rotate: false - xy: 413, 83 + xy: 443, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/deepwater rotate: false - xy: 423, 83 + xy: 453, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/dirt1 rotate: false - xy: 433, 83 + xy: 463, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/dirt2 rotate: false - xy: 443, 83 + xy: 473, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/dirt3 rotate: false - xy: 453, 83 + xy: 483, 83 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -286,7 +286,7 @@ blocks/dirtedge index: -1 blocks/door rotate: false - xy: 463, 83 + xy: 575, 185 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -300,7 +300,7 @@ blocks/door-large index: -1 blocks/door-large-icon rotate: false - xy: 473, 83 + xy: 393, 73 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -314,7 +314,7 @@ blocks/door-large-open index: -1 blocks/door-open rotate: false - xy: 483, 83 + xy: 403, 73 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -328,7 +328,7 @@ blocks/doubleturret index: -1 blocks/duriumwall rotate: false - xy: 740, 223 + xy: 413, 73 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -342,14 +342,14 @@ blocks/duriumwall-large index: -1 blocks/duriumwall-large-icon rotate: false - xy: 575, 185 + xy: 423, 73 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/enemyspawn rotate: false - xy: 393, 73 + xy: 433, 73 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -363,42 +363,42 @@ blocks/flameturret index: -1 blocks/fluxpump rotate: false - xy: 413, 73 + xy: 453, 73 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grass1 rotate: false - xy: 423, 73 + xy: 463, 73 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grass2 rotate: false - xy: 433, 73 + xy: 473, 73 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grass3 rotate: false - xy: 443, 73 + xy: 483, 73 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grassblock1 rotate: false - xy: 453, 73 + xy: 598, 222 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grassblock2 rotate: false - xy: 463, 73 + xy: 608, 222 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -412,21 +412,21 @@ blocks/grassedge index: -1 blocks/ice1 rotate: false - xy: 473, 73 + xy: 618, 222 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/ice2 rotate: false - xy: 483, 73 + xy: 628, 222 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/ice3 rotate: false - xy: 598, 222 + xy: 881, 485 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -440,98 +440,98 @@ blocks/iceedge index: -1 blocks/icerock1 rotate: false - xy: 608, 222 + xy: 891, 485 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/icerock2 rotate: false - xy: 618, 222 + xy: 901, 485 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/icerockshadow1 rotate: false - xy: 628, 222 + xy: 911, 485 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rockshadow1 rotate: false - xy: 628, 222 + xy: 911, 485 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/icerockshadow2 rotate: false - xy: 881, 485 + xy: 921, 485 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rockshadow2 rotate: false - xy: 881, 485 + xy: 921, 485 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/iron1 rotate: false - xy: 961, 485 + xy: 1001, 485 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/iron2 rotate: false - xy: 971, 485 + xy: 748, 244 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/iron3 rotate: false - xy: 981, 485 + xy: 513, 97 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/irondrill rotate: false - xy: 991, 485 + xy: 523, 97 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/ironwall rotate: false - xy: 1001, 485 + xy: 533, 95 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/junction rotate: false - xy: 748, 256 + xy: 543, 97 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/laserturret rotate: false - xy: 441, 93 + xy: 465, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/lava rotate: false - xy: 746, 246 + xy: 801, 413 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -545,63 +545,63 @@ blocks/lavaedge index: -1 blocks/lavasmelter rotate: false - xy: 750, 233 + xy: 800, 403 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/liquiditemjunction rotate: false - xy: 750, 223 + xy: 811, 409 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/liquidjunction rotate: false - xy: 513, 97 + xy: 810, 399 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/liquidrouter rotate: false - xy: 523, 97 + xy: 1011, 479 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/machineturret rotate: false - xy: 453, 93 + xy: 477, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/megarepairturret rotate: false - xy: 465, 93 + xy: 1012, 489 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/mortarturret rotate: false - xy: 477, 93 + xy: 551, 203 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/mossblock rotate: false - xy: 543, 97 + xy: 112, 84 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/mossstone rotate: false - xy: 543, 97 + xy: 112, 84 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -622,7 +622,7 @@ blocks/nuclearreactor-center index: -1 blocks/nuclearreactor-icon rotate: false - xy: 800, 403 + xy: 132, 84 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -643,7 +643,7 @@ blocks/nuclearreactor-small index: -1 blocks/oil rotate: false - xy: 811, 409 + xy: 142, 84 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -657,182 +657,182 @@ blocks/oiledge index: -1 blocks/oilrefinery rotate: false - xy: 810, 399 + xy: 152, 84 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/omnidrill rotate: false - xy: 1011, 479 + xy: 162, 84 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/plasmaturret rotate: false - xy: 1012, 489 + xy: 551, 191 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/playerspawn rotate: false - xy: 656, 220 + xy: 172, 80 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/powerbooster rotate: false - xy: 666, 220 + xy: 95, 74 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/poweredconveyor rotate: false - xy: 762, 321 + xy: 95, 64 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/poweredconveyormove rotate: false - xy: 551, 141 + xy: 105, 74 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/powerlaser rotate: false - xy: 553, 131 + xy: 95, 54 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/powerlasercorner rotate: false - xy: 553, 121 + xy: 105, 64 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/powerlaserrouter rotate: false - xy: 553, 111 + xy: 115, 74 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/pulseconduit rotate: false - xy: 553, 101 + xy: 95, 44 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/pulseconduitbottom rotate: false - xy: 553, 91 + xy: 105, 54 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/pulseconduittop rotate: false - xy: 543, 87 + xy: 115, 64 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/pump rotate: false - xy: 553, 81 + xy: 125, 74 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/repairturret rotate: false - xy: 551, 203 + xy: 556, 215 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/rock1 rotate: false - xy: 582, 219 + xy: 105, 44 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rock2 rotate: false - xy: 585, 209 + xy: 115, 54 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/router rotate: false - xy: 585, 199 + xy: 125, 64 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rtgenerator rotate: false - xy: 585, 189 + xy: 135, 74 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rtgenerator-top rotate: false - xy: 595, 212 + xy: 95, 24 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/sand1 rotate: false - xy: 595, 202 + xy: 105, 34 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/sand2 rotate: false - xy: 605, 212 + xy: 115, 44 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/sand3 rotate: false - xy: 595, 192 + xy: 125, 54 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/sandblock1 rotate: false - xy: 605, 202 + xy: 135, 64 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/sandblock2 rotate: false - xy: 615, 212 + xy: 145, 74 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/sandblock3 rotate: false - xy: 605, 192 + xy: 95, 14 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -846,91 +846,91 @@ blocks/sandedge index: -1 blocks/shadow rotate: false - xy: 551, 191 + xy: 568, 215 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/shieldgenerator rotate: false - xy: 625, 212 + xy: 115, 34 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/shotgunturret rotate: false - xy: 556, 215 + xy: 563, 203 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/shrub rotate: false - xy: 625, 192 + xy: 145, 64 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/shrubshadow rotate: false - xy: 585, 179 + xy: 155, 74 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/smelter rotate: false - xy: 595, 182 + xy: 105, 14 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/sniperturret rotate: false - xy: 568, 215 + xy: 563, 191 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/snow1 rotate: false - xy: 605, 182 + xy: 115, 24 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/snow2 rotate: false - xy: 615, 182 + xy: 125, 34 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/snow3 rotate: false - xy: 625, 182 + xy: 135, 44 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/snowblock1 rotate: false - xy: 635, 212 + xy: 145, 54 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/snowblock2 rotate: false - xy: 635, 202 + xy: 155, 64 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/snowblock3 rotate: false - xy: 635, 192 + xy: 115, 14 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -944,28 +944,28 @@ blocks/snowedge index: -1 blocks/sorter rotate: false - xy: 635, 182 + xy: 125, 24 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/steelconveyor rotate: false - xy: 595, 172 + xy: 135, 34 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/steelconveyormove rotate: false - xy: 605, 172 + xy: 145, 44 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/steelwall rotate: false - xy: 615, 172 + xy: 155, 54 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -979,56 +979,56 @@ blocks/steelwall-large index: -1 blocks/steelwall-large-icon rotate: false - xy: 625, 172 + xy: 125, 14 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stone1 rotate: false - xy: 635, 172 + xy: 135, 24 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stone2 rotate: false - xy: 645, 218 + xy: 145, 34 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stone3 rotate: false - xy: 645, 208 + xy: 155, 44 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock1 rotate: false - xy: 645, 198 + xy: 135, 14 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock2 rotate: false - xy: 645, 188 + xy: 145, 24 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock3 rotate: false - xy: 645, 178 + xy: 155, 34 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stonedrill rotate: false - xy: 655, 210 + xy: 145, 14 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -1042,35 +1042,35 @@ blocks/stoneedge index: -1 blocks/stoneformer rotate: false - xy: 655, 200 + xy: 155, 24 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stonewall rotate: false - xy: 665, 210 + xy: 155, 14 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/teleporter rotate: false - xy: 655, 190 + xy: 95, 4 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/teleporter-top rotate: false - xy: 665, 200 + xy: 105, 4 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/thermalgenerator rotate: false - xy: 655, 180 + xy: 115, 4 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -1084,56 +1084,56 @@ blocks/titancannon index: -1 blocks/titancannon-icon rotate: false - xy: 563, 203 + xy: 736, 263 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/titanium1 rotate: false - xy: 665, 190 + xy: 125, 4 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titanium2 rotate: false - xy: 665, 180 + xy: 135, 4 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titanium3 rotate: false - xy: 645, 168 + xy: 145, 4 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumdrill rotate: false - xy: 655, 170 + xy: 155, 4 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumpurifier rotate: false - xy: 665, 170 + xy: 165, 70 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumshieldwall rotate: false - xy: 833, 477 + xy: 165, 60 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumwall rotate: false - xy: 843, 477 + xy: 165, 50 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -1147,49 +1147,49 @@ blocks/titaniumwall-large index: -1 blocks/titaniumwall-large-icon rotate: false - xy: 853, 477 + xy: 165, 40 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/turret rotate: false - xy: 563, 191 + xy: 736, 251 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 blocks/uranium1 rotate: false - xy: 760, 236 + xy: 165, 10 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/uranium2 rotate: false - xy: 760, 226 + xy: 175, 70 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/uranium3 rotate: false - xy: 760, 216 + xy: 175, 60 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/uraniumdrill rotate: false - xy: 821, 409 + xy: 175, 50 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/water rotate: false - xy: 820, 399 + xy: 175, 40 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -1203,14 +1203,14 @@ blocks/wateredge index: -1 blocks/waveturret rotate: false - xy: 736, 263 + xy: 748, 264 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 bullet rotate: false - xy: 533, 125 + xy: 543, 127 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -1483,49 +1483,49 @@ enemyarrow index: -1 icon-coal rotate: false - xy: 891, 485 + xy: 931, 485 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-dirium rotate: false - xy: 901, 485 + xy: 941, 485 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-iron rotate: false - xy: 911, 485 + xy: 951, 485 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-steel rotate: false - xy: 921, 485 + xy: 961, 485 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-stone rotate: false - xy: 931, 485 + xy: 971, 485 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-titanium rotate: false - xy: 941, 485 + xy: 981, 485 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-uranium rotate: false - xy: 951, 485 + xy: 991, 485 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -1560,28 +1560,28 @@ mechs/mech-standard index: -1 shell rotate: false - xy: 615, 202 + xy: 105, 24 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 shot rotate: false - xy: 615, 192 + xy: 125, 44 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 shot-long rotate: false - xy: 625, 202 + xy: 135, 54 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 titanshell rotate: false - xy: 863, 477 + xy: 165, 30 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -1706,20 +1706,34 @@ ui/icons/icon-arrow orig: 14, 14 offset: 0, 0 index: -1 -ui/icons/icon-arrow-left +ui/icons/icon-arrow-down rotate: false xy: 869, 487 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 -ui/icons/icon-arrow-right +ui/icons/icon-arrow-left rotate: false xy: 805, 459 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 +ui/icons/icon-arrow-right + rotate: false + xy: 801, 447 + size: 10, 10 + orig: 10, 10 + offset: 0, 0 + index: -1 +ui/icons/icon-arrow-up + rotate: false + xy: 801, 435 + size: 10, 10 + orig: 10, 10 + offset: 0, 0 + index: -1 ui/icons/icon-back rotate: false xy: 779, 402 @@ -1764,21 +1778,21 @@ ui/icons/icon-close-over index: -1 ui/icons/icon-crafting rotate: false - xy: 801, 447 + xy: 801, 423 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icons/icon-cursor rotate: false - xy: 801, 435 + xy: 273, 85 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icons/icon-defense rotate: false - xy: 801, 423 + xy: 285, 85 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1792,7 +1806,7 @@ ui/icons/icon-discord index: -1 ui/icons/icon-distribution rotate: false - xy: 273, 85 + xy: 297, 85 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1848,14 +1862,14 @@ ui/icons/icon-grid index: -1 ui/icons/icon-hold rotate: false - xy: 285, 85 + xy: 309, 85 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icons/icon-holdDelete rotate: false - xy: 297, 85 + xy: 321, 85 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1869,7 +1883,7 @@ ui/icons/icon-home index: -1 ui/icons/icon-info rotate: false - xy: 309, 85 + xy: 333, 89 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1911,21 +1925,21 @@ ui/icons/icon-loading index: -1 ui/icons/icon-menu rotate: false - xy: 321, 85 + xy: 345, 89 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icons/icon-none rotate: false - xy: 333, 89 + xy: 357, 89 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icons/icon-pause rotate: false - xy: 345, 89 + xy: 369, 89 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1946,7 +1960,7 @@ ui/icons/icon-pick index: -1 ui/icons/icon-play rotate: false - xy: 357, 89 + xy: 381, 89 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -1960,14 +1974,14 @@ ui/icons/icon-play-2 index: -1 ui/icons/icon-power rotate: false - xy: 369, 89 + xy: 393, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icons/icon-production rotate: false - xy: 381, 89 + xy: 405, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -2044,7 +2058,7 @@ ui/icons/icon-save-map index: -1 ui/icons/icon-settings rotate: false - xy: 393, 93 + xy: 417, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -2065,14 +2079,14 @@ ui/icons/icon-tools index: -1 ui/icons/icon-touch rotate: false - xy: 405, 93 + xy: 429, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 index: -1 ui/icons/icon-touchDelete rotate: false - xy: 417, 93 + xy: 441, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -2093,7 +2107,7 @@ ui/icons/icon-undo index: -1 ui/icons/icon-weapon rotate: false - xy: 429, 93 + xy: 453, 93 size: 10, 10 orig: 10, 10 offset: 0, 0 @@ -2205,7 +2219,7 @@ ui/slider-knob-over index: -1 ui/slider-vertical rotate: false - xy: 746, 243 + xy: 92, 91 size: 8, 1 orig: 8, 1 offset: 0, 0 @@ -2314,42 +2328,42 @@ ui/window-empty index: -1 weapons/blaster rotate: false - xy: 575, 205 + xy: 533, 115 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/flamer rotate: false - xy: 403, 73 + xy: 443, 73 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/mortar rotate: false - xy: 533, 95 + xy: 102, 84 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/multigun rotate: false - xy: 801, 413 + xy: 122, 84 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/railgun rotate: false - xy: 819, 463 + xy: 95, 34 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/triblaster rotate: false - xy: 756, 246 + xy: 165, 20 size: 8, 8 orig: 8, 8 offset: 0, 0 diff --git a/core/assets/sprites/sprites.png b/core/assets/sprites/sprites.png index 47f8dad5ef..fd18eaa9e6 100644 Binary files a/core/assets/sprites/sprites.png and b/core/assets/sprites/sprites.png differ diff --git a/core/src/io/anuke/mindustry/Mindustry.java b/core/src/io/anuke/mindustry/Mindustry.java index 91722e269e..fe5553e141 100644 --- a/core/src/io/anuke/mindustry/Mindustry.java +++ b/core/src/io/anuke/mindustry/Mindustry.java @@ -1,14 +1,21 @@ package io.anuke.mindustry; import java.util.Date; +import java.util.Locale; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.utils.Array; +import com.badlogic.gdx.utils.I18NBundle; import io.anuke.mindustry.core.*; import io.anuke.mindustry.core.GameState.State; +import io.anuke.mindustry.io.BundleUtil; import io.anuke.mindustry.io.PlatformFunction; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.blocks.*; +import io.anuke.ucore.UCore; +import io.anuke.ucore.core.Core; import io.anuke.ucore.core.Inputs; import io.anuke.ucore.core.Timers; import io.anuke.ucore.function.Callable; @@ -26,27 +33,41 @@ public class Mindustry extends ModuleCore { @Override public void addDialog(TextField field){} }; - //always initialize blocks in this order, otherwise there are ID errors - public Block[] blockClasses = { - Blocks.air, - DefenseBlocks.compositewall, - DistributionBlocks.conduit, - ProductionBlocks.coaldrill, - WeaponBlocks.chainturret, - SpecialBlocks.enemySpawn - }; - @Override public void init(){ + loadBundle(); + module(Vars.world = new World()); module(Vars.control = new Control()); module(Vars.renderer = new Renderer()); module(Vars.ui = new UI()); } + + public void loadBundle(){ + I18NBundle.setExceptionOnMissingKey(false); + + FileHandle handle = Gdx.files.internal("bundles/bundle"); + + Locale locale = Locale.getDefault(); + Core.bundle = I18NBundle.createBundle(handle, locale); + + //always initialize blocks in this order, otherwise there are ID errors + Block[] blockClasses = { + Blocks.air, + DefenseBlocks.compositewall, + DistributionBlocks.conduit, + ProductionBlocks.coaldrill, + WeaponBlocks.chainturret, + SpecialBlocks.enemySpawn + }; + + UCore.log("Block classes: " + blockClasses.length); + } @Override public void postInit(){ Vars.control.reset(); + BundleUtil.buildBundle(Gdx.files.absolute("/home/anuke/bundle_en_US.properties")); } @Override diff --git a/core/src/io/anuke/mindustry/Vars.java b/core/src/io/anuke/mindustry/Vars.java index b1fe6f1961..673eb697a5 100644 --- a/core/src/io/anuke/mindustry/Vars.java +++ b/core/src/io/anuke/mindustry/Vars.java @@ -70,8 +70,6 @@ public class Vars{ public static final int tilesize = 8; - public static I18NBundle bundle; - public static Control control; public static Renderer renderer; public static UI ui; diff --git a/core/src/io/anuke/mindustry/core/Control.java b/core/src/io/anuke/mindustry/core/Control.java index acbc16a3c7..3388ad12a3 100644 --- a/core/src/io/anuke/mindustry/core/Control.java +++ b/core/src/io/anuke/mindustry/core/Control.java @@ -3,6 +3,7 @@ package io.anuke.mindustry.core; import static io.anuke.mindustry.Vars.*; import java.util.Arrays; +import java.util.Locale; import com.badlogic.gdx.Application.ApplicationType; import com.badlogic.gdx.Gdx; @@ -12,7 +13,9 @@ import com.badlogic.gdx.audio.Music; import com.badlogic.gdx.controllers.Controller; import com.badlogic.gdx.controllers.ControllerAdapter; import com.badlogic.gdx.controllers.Controllers; +import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.utils.Array; +import com.badlogic.gdx.utils.I18NBundle; import com.badlogic.gdx.utils.reflect.ClassReflection; import io.anuke.mindustry.Mindustry; @@ -27,6 +30,7 @@ import io.anuke.mindustry.graphics.Fx; import io.anuke.mindustry.input.AndroidInput; import io.anuke.mindustry.input.DesktopInput; import io.anuke.mindustry.input.InputHandler; +import io.anuke.mindustry.io.BundleUtil; import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.resource.ItemStack; import io.anuke.mindustry.resource.Weapon; @@ -80,6 +84,11 @@ public class Control extends Module{ if(Mindustry.args.contains("-debug", false)) Vars.debug = true; + FileHandle handle = Gdx.files.internal("bundles/bundle"); + + Locale locale = Locale.getDefault(); + Core.bundle = I18NBundle.createBundle(handle, locale); + Inputs.useControllers(false); log("Total blocks loaded: " + Block.getAllBlocks().size); diff --git a/core/src/io/anuke/mindustry/core/Tutorial.java b/core/src/io/anuke/mindustry/core/Tutorial.java index 314df42489..e3fd04eecf 100644 --- a/core/src/io/anuke/mindustry/core/Tutorial.java +++ b/core/src/io/anuke/mindustry/core/Tutorial.java @@ -18,6 +18,7 @@ import io.anuke.ucore.scene.builders.table; import io.anuke.ucore.scene.ui.ImageButton; import io.anuke.ucore.scene.ui.Label; import io.anuke.ucore.scene.ui.TextButton; +import io.anuke.ucore.util.Bundles; import io.anuke.ucore.util.Mathf; import io.anuke.ucore.util.Tmp; @@ -171,35 +172,30 @@ public class Tutorial{ } } - enum Stage{ + public enum Stage{ intro{ { - text = "[yellow]Welcome to the tutorial.[] To begin, press 'next'."; } }, moveDesktop{ { desktopOnly = true; - text = "To move, use the [orange][[WASD][] keys. Hold [orange]shift[] to boost. Hold [orange]CTRL[] while using the [orange]scrollwheel[] to zoom in or out."; } }, shoot{ { desktopOnly = true; - text = "Use your mouse to aim, hold [orange]left mouse button[] to shoot. Try practicing on the [yellow]target[]."; } }, moveAndroid{ { androidOnly = true; - text = "To pan the view, drag one finger across the screen. Pinch and drag to zoom in or out."; } }, placeSelect{ { canBack = false; canPlace = true; - text = "Try selecting a [yellow]conveyor[] from the block menu in the bottom right."; } void onSwitch(){ @@ -216,7 +212,6 @@ public class Tutorial{ blockPlaceX = 0; blockPlaceY = -2; targetBlock = DistributionBlocks.conveyor; - text = "Use the [orange][[scrollwheel][] to rotate the conveyor to face [orange]forwards[], then place it in the [yellow]marked location[] using the [orange][[left mouse button][]."; } }, placeConveyorAndroid{ @@ -229,16 +224,12 @@ public class Tutorial{ blockPlaceX = 0; blockPlaceY = -2; targetBlock = DistributionBlocks.conveyor; - text = "Use the [orange][[rotate button][] to rotate the conveyor to face [orange]forwards[], drag it into position with one finger, then place it in the [yellow]marked location[] using the [orange][[checkmark][]."; } }, placeConveyorAndroidInfo{ { androidOnly = true; canBack = false; - text = "Alternatively, you can press the crosshair icon in the bottom left to switch to [orange][[touch mode][], and " - + "place blocks by tapping on the screen. In touch mode, blocks can be rotated with the arrow at the bottom left. " - + "Press [yellow]next[] to try it out."; } void onSwitch(){ @@ -254,7 +245,6 @@ public class Tutorial{ blockPlaceX = 0; blockPlaceY = -3; targetBlock = ProductionBlocks.stonedrill; - text = "Now, select and place a [yellow]stone drill[] at the marked location."; } void onSwitch(){ @@ -264,27 +254,23 @@ public class Tutorial{ blockInfo{ { canBack = true; - text = "If you want to learn more about a block, you can tap the [orange]question mark[] in the top right to read its description."; } }, deselectDesktop{ { desktopOnly = true; canBack = false; - text = "You can de-select a block using the [orange][[right mouse button][]."; } }, deselectAndroid{ { androidOnly = true; canBack = false; - text = "You can deselect a block by pressing the [orange]X[] button."; } }, drillPlaced{ { canBack = false; - text = "The drill will now produce [yellow]stone,[] output it onto the conveyor, then move it into the [yellow]core[]."; } void onSwitch(){ @@ -293,18 +279,15 @@ public class Tutorial{ }, drillInfo{ { - text = "Different ores need different drills. Stone requires stone drills, iron requires iron drills, etc."; } }, drillPlaced2{ { - text = "Moving items into the core puts them in your [yellow]item inventory[], in the top left. Placing blocks uses items from your inventory."; } }, moreDrills{ { canBack = false; - text = "You can link many drills and conveyors up together, like so."; } void onSwitch(){ @@ -327,23 +310,20 @@ public class Tutorial{ targetBlock = Blocks.air; blockPlaceX = 2; blockPlaceY = -2; - text = !Vars.android ? - "You can delete blocks by clicking the [orange]right mouse button[] on the block you want to delete. Try deleting this conveyor.": - "You can delete blocks by [orange]selecting the crosshair[] in the [orange]break mode menu[] in the bottom left and tapping a block. Try deleting this conveyor."; + desktopOnly = true; } }, - /* - deleteBlock2{ + deleteBlockAndroid{ { canBack = false; canForward = false; showBlock = true; targetBlock = Blocks.air; - blockPlaceX = -2; + blockPlaceX = 2; blockPlaceY = -2; - text = "Try deleting this other conveyor too."; + androidOnly = true; } - },*/ + }, placeTurret{ { canBack = false; @@ -353,7 +333,6 @@ public class Tutorial{ targetBlock = WeaponBlocks.turret; blockPlaceX = 2; blockPlaceY = 2; - text = "Now, select and place a [yellow]turret[] at the [yellow]marked location[]."; } void onSwitch(){ @@ -363,8 +342,6 @@ public class Tutorial{ placedTurretAmmo{ { canBack = false; - text = "This turret will now accept [yellow]ammo[] from the conveyor. You can see how much ammo it has by " + - (Vars.android ? "tapping it" : "hovering over it") + " and checking the [green]green bar[]."; } void onSwitch(){ @@ -377,38 +354,30 @@ public class Tutorial{ turretExplanation{ { canBack = false; - text = "Turrets will automatically shoot at the nearest enemy in range, as long as they have enough ammo."; } }, waves{ { - text = "Every [yellow]" + (int)(Vars.wavespace/60) + "[] seconds, a wave of [coral]enemies[] will spawn in specific locations and attempt to destroy the core."; } }, coreDestruction{ { - text = "Your objective is to [yellow]defend the core[]. If the core is destroyed, you [coral]lose the game[]."; } }, pausingDesktop{ { desktopOnly = true; - text = "If you ever need to take a break, press the [orange]pause button[] in the top left or [orange]space[] " - + "to pause the game. You can still select and place blocks while paused, but cannot move or shoot."; } }, pausingAndroid{ { androidOnly = true; - text = "If you ever need to take a break, press the [orange]pause button[] in the top left" - + " to pause the game. You can still place select and place blocks while paused."; } }, purchaseWeapons{ { desktopOnly = true; canBack = false; - text = "You can purchase new [yellow]weapons[] for your mech by opening the upgrade menu in the bottom left."; } void onSwitch(){ @@ -420,7 +389,6 @@ public class Tutorial{ { canBack = false; desktopOnly = true; - text = "Switch weapons by either clicking its icon in the bottom left, or using numbers [orange][[1-9][]."; } void onSwitch(){ @@ -435,7 +403,6 @@ public class Tutorial{ { canBack = false; canForward = false; - text = "Here comes a wave now. Destroy them."; } void update(Tutorial t){ @@ -453,7 +420,6 @@ public class Tutorial{ pumpDesc{ { canBack = false; - text = "In later waves, you might need to use [yellow]pumps[] to distribute liquids for generators or extractors."; } }, pumpPlace{ @@ -465,7 +431,6 @@ public class Tutorial{ targetBlock = ProductionBlocks.pump; blockPlaceX = 6; blockPlaceY = -2; - text = "Pumps work similarly to drills, except that they produce liquids instead of items. Try placing a pump on the [yellow]designated oil[]."; } void onSwitch(){ @@ -484,7 +449,6 @@ public class Tutorial{ blockPlaceX = 5; blockPlaceY = -2; blockRotation = 2; - text = "Now place a [orange]conduit[] leading away from the pump."; } void onSwitch(){ @@ -502,7 +466,6 @@ public class Tutorial{ blockPlaceX = 4; blockPlaceY = -2; blockRotation = 1; - text = "And a few more..."; } void onSwitch(){ @@ -519,7 +482,6 @@ public class Tutorial{ blockPlaceX = 4; blockPlaceY = -1; blockRotation = 1; - text = "And a few more..."; } void onSwitch(){ @@ -535,7 +497,6 @@ public class Tutorial{ targetBlock = ProductionBlocks.combustiongenerator; blockPlaceX = 4; blockPlaceY = 0; - text = "Now, place a [orange]combustion generator[] block at the end of the conduit."; } void onSwitch(){ @@ -548,7 +509,6 @@ public class Tutorial{ generatorExplain{ { canBack = false; - text = "This generator will now create [yellow]power[] from the oil."; } }, lasers{ @@ -557,7 +517,6 @@ public class Tutorial{ canForward = false; showBlock = true; canPlace = true; - text = "Power is distributed using [yellow]power lasers[]. Rotate and place one here."; blockPlaceX = 4; blockPlaceY = 4; blockRotation = 2; @@ -571,14 +530,11 @@ public class Tutorial{ laserExplain{ { canBack = false; - text = "The generator will now move power into the laser block. An [yellow]opaque[] beam means that it is currently transmitting power, " - + "and a [yellow]transparent[] beam means it is not."; } }, laserMore{ { canBack = false; - text = "You can check how much power a block has by hovering over it and checking the [yellow]yellow bar[] at the top."; } }, healingTurret{ @@ -591,7 +547,6 @@ public class Tutorial{ blockPlaceX = 1; blockPlaceY = 4; targetBlock = DefenseBlocks.repairturret; - text = "This laser can be used to power a [lime]repair turret[]. Place one here."; } void onSwitch(){ @@ -601,7 +556,6 @@ public class Tutorial{ healingTurretExplain{ { canBack = false; - text = "As long as it has power, this turret will [lime]repair nearby blocks.[] When playing, make sure you get one in your base as quickly as possible!"; } }, smeltery{ @@ -614,7 +568,6 @@ public class Tutorial{ blockPlaceX = 0; blockPlaceY = -6; targetBlock = ProductionBlocks.smelter; - text = "Many blocks require [orange]steel[] to make, which requires a [orange]smelter[] to craft. Place one here."; } void onSwitch(){ @@ -627,7 +580,6 @@ public class Tutorial{ smelterySetup{ { canBack = false; - text = "This smelter will now produce [orange]steel[] from the input coal and iron."; } void onSwitch(){ @@ -643,11 +595,10 @@ public class Tutorial{ }, end{ { - text = "And that concludes the tutorial! Good luck!"; canBack = false; } }; - String text = "no text"; + public final String text = Bundles.getNotNull("tutorial."+name()+".text"); boolean androidOnly; boolean desktopOnly; diff --git a/core/src/io/anuke/mindustry/core/UI.java b/core/src/io/anuke/mindustry/core/UI.java index 287fe3ddf4..fef4f27cf3 100644 --- a/core/src/io/anuke/mindustry/core/UI.java +++ b/core/src/io/anuke/mindustry/core/UI.java @@ -43,6 +43,7 @@ import io.anuke.ucore.scene.ui.*; import io.anuke.ucore.scene.ui.Window.WindowStyle; import io.anuke.ucore.scene.ui.layout.Table; import io.anuke.ucore.scene.ui.layout.Unit; +import io.anuke.ucore.util.Bundles; public class UI extends SceneModule{ Table loadingtable, desctable, configtable; @@ -190,20 +191,18 @@ public class UI extends SceneModule{ settingserror.hide(); }).size(80f, 55f).pad(4); - gameerror = new Dialog("An error has occured", "dialog"); - gameerror.content().add(new Label("[SCARLET]An unexpected error has occured, which would have caused a crash. " - + "[]Please report the exact circumstances under which this error occured to the developer: " - + "\n[ORANGE]anukendev@gmail.com[]"){{ - setWrap(true); - }}).width(600f).pad(10f); - gameerror.buttons().addButton("OK", gameerror::hide).size(200f, 50); + gameerror = new Dialog("$text.error.crashtitle", "dialog"); + gameerror.content().labelWrap("$text.error.crashmessage").width(600f).pad(10f); + gameerror.buttons().addButton("#text.ok", gameerror::hide).size(200f, 50); discord = new Dialog("Discord", "dialog"); discord.content().margin(12f); - discord.content().add("Join the mindustry discord!\n[orange]" + Vars.discordURL); + discord.content().add("$text.discord"); + discord.content().row(); + discord.content().add("[orange]"+Vars.discordURL); discord.buttons().defaults().size(200f, 50); - discord.buttons().addButton("Open link", () -> Mindustry.platforms.openLink(Vars.discordURL)); - discord.buttons().addButton("Back", discord::hide); + discord.buttons().addButton("$text.openlink", () -> Mindustry.platforms.openLink(Vars.discordURL)); + discord.buttons().addButton("$text.back", discord::hide); load = new LoadDialog(); @@ -218,18 +217,18 @@ public class UI extends SceneModule{ prefs.sound.volumePrefs(); - prefs.game.sliderPref("difficulty", "Difficulty", 1, 0, 2, i -> i == 0 ? "Easy" : i == 1 ? "Normal" : "Hard"); + prefs.game.sliderPref("difficulty", 1, 0, 2, i -> Bundles.get("setting.difficulty." + (i == 0 ? "easy" : i == 1 ? "normal" : "hard"))); prefs.game.screenshakePref(); - prefs.game.checkPref("smoothcam", "Smooth Camera", true); - prefs.game.checkPref("indicators", "Enemy Indicators", true); - prefs.game.checkPref("effects", "Display Effects", true); - prefs.game.sliderPref("sensitivity", "Controller Sensitivity", 100, 10, 300, i -> i + "%"); + prefs.game.checkPref("smoothcam", true); + prefs.game.checkPref("indicators", true); + prefs.game.checkPref("effects", true); + prefs.game.sliderPref("sensitivity", 100, 10, 300, i -> i + "%"); - prefs.graphics.checkPref("fps", "Show FPS", false); - prefs.graphics.checkPref("vsync", "VSync", true, b -> Gdx.graphics.setVSync(b)); - prefs.graphics.checkPref("lasers", "Show Power Lasers", true); - prefs.graphics.checkPref("healthbars", "Show Entity Health bars", true); - prefs.graphics.checkPref("pixelate", "Pixelate Screen", true, b->{ + prefs.graphics.checkPref("fps", false); + prefs.graphics.checkPref("vsync", true, b -> Gdx.graphics.setVSync(b)); + prefs.graphics.checkPref("lasers", true); + prefs.graphics.checkPref("healthbars", true); + prefs.graphics.checkPref("pixelate", true, b->{ if(b){ Vars.renderer.pixelSurface.setScale(Core.cameraScale); Vars.renderer.shadowSurface.setScale(Core.cameraScale); @@ -270,19 +269,20 @@ public class UI extends SceneModule{ about.content().row(); } - restart = new Dialog("The core was destroyed.", "dialog"); + restart = new Dialog("$text.gameover", "dialog"); restart.shown(()->{ restart.content().clearChildren(); if(control.isHighScore()){ - restart.content().add("[YELLOW]New highscore!").pad(6); + restart.content().add("$text.highscore").pad(6); restart.content().row(); } - restart.content().add("You lasted until wave [GREEN]" + control.getWave() + "[].").pad(12).get(); + restart.content().add("$text.lasted").pad(12).get(); + restart.content().add("[GREEN]" + control.getWave()); restart.pack(); }); - restart.getButtonTable().addButton("Back to menu", ()->{ + restart.getButtonTable().addButton("$text.menu", ()->{ restart.hide(); GameState.set(State.menu); control.reset(); @@ -305,7 +305,7 @@ public class UI extends SceneModule{ get().addImage("white").growX() .height(3f).pad(4f).growX().get().setColor(Colors.get("accent")); row(); - new label("[accent]Loading..."){{ + new label("$text.loading"){{ get().setName("namelabel"); }}.pad(10); row(); @@ -370,7 +370,7 @@ public class UI extends SceneModule{ } public void showError(String text){ - new Dialog("[crimson]An error has occured", "dialog"){{ + new Dialog("$text.error.title", "dialog"){{ content().margin(15); content().add(text); getButtonTable().addButton("OK", this::hide).size(90, 50).pad(4); @@ -378,7 +378,7 @@ public class UI extends SceneModule{ } public void showErrorClose(String text){ - new Dialog("[crimson]A critical error has occured", "dialog"){{ + new Dialog("$text.error.title", "dialog"){{ content().margin(15); content().add(text); getButtonTable().addButton("Exit", Gdx.app::exit).size(90, 50).pad(4); @@ -386,7 +386,7 @@ public class UI extends SceneModule{ } public void showLoading(){ - showLoading("[accent]Loading.."); + showLoading("$text.loading"); } public void showLoading(String text){ @@ -479,13 +479,17 @@ public class UI extends SceneModule{ public void updateItems(){ ((HudFragment)hudfrag).updateItems(); } - + + public MindustrySettingsDialog getPrefs() { + return prefs; + } + public void showConfirm(String title, String text, Listenable confirmed){ FloatingDialog dialog = new FloatingDialog(title); dialog.content().add(text).pad(4f); dialog.buttons().defaults().size(200f, 54f).pad(2f); - dialog.buttons().addButton("Cancel", dialog::hide); - dialog.buttons().addButton("OK", () -> { + dialog.buttons().addButton("$text.cancel", dialog::hide); + dialog.buttons().addButton("$text.ok", () -> { dialog.hide(); confirmed.listen(); }); diff --git a/core/src/io/anuke/mindustry/io/BundleUtil.java b/core/src/io/anuke/mindustry/io/BundleUtil.java new file mode 100644 index 0000000000..eaa3d570a9 --- /dev/null +++ b/core/src/io/anuke/mindustry/io/BundleUtil.java @@ -0,0 +1,79 @@ +package io.anuke.mindustry.io; + +import com.badlogic.gdx.Game; +import com.badlogic.gdx.files.FileHandle; +import io.anuke.mindustry.Vars; +import io.anuke.mindustry.core.Tutorial; +import io.anuke.mindustry.core.Tutorial.Stage; +import io.anuke.mindustry.resource.Item; +import io.anuke.mindustry.resource.Liquid; +import io.anuke.mindustry.resource.Weapon; +import io.anuke.mindustry.world.Block; +import io.anuke.mindustry.world.GameMode; +import io.anuke.mindustry.world.Map; +import io.anuke.ucore.core.Inputs.DeviceType; +import io.anuke.ucore.core.KeyBinds; +import io.anuke.ucore.core.KeyBinds.Keybind; +import io.anuke.ucore.scene.ui.SettingsDialog.SettingsTable.Setting; +import io.anuke.ucore.util.Mathf; + +import java.io.File; + +public class BundleUtil { + private static FileHandle file; + + public static void buildBundle(FileHandle file){ + BundleUtil.file = file; + + file.writeString("", false); + write("about.text=" + join(Vars.aboutText)); + write("discord.text=Join the mindustry discord!\n[orange]"); + + Mathf.each(table -> { + for(Setting setting : table.getSettings()){ + write("setting." + setting.name + ".name=" + setting.title); + } + }, Vars.ui.getPrefs().game, Vars.ui.getPrefs().graphics, Vars.ui.getPrefs().sound); + + for(Map map : Vars.world.maps().list()){ + write("map." + map.name + ".name=" + map.name); + } + for(Tutorial.Stage stage : Stage.values()){ + write("tutorial." + stage.name() + ".text=" + stage.text); + } + for(Keybind bind : KeyBinds.getSection("default").keybinds.get(DeviceType.keyboard)){ + write("keybind." + bind.name + ".name=" + bind.name); + } + for(GameMode mode : GameMode.values()){ + write("mode." + mode.name() + ".name=" + mode.name()); + } + for(Weapon weapon : Weapon.values()){ + write("weapon." + weapon.name() + ".name=" + weapon.name()); + write("weapon." + weapon.name() + ".description=" + weapon.description); + } + for(Item item : Item.values()){ + write("item." + item.name() + ".name=" + item.name()); + } + for(Liquid liquid : Liquid.values()){ + write("liquid." + liquid.name() + ".name=" + liquid.name()); + } + for(Block block : Block.getAllBlocks()){ + write("block." + block.name + ".name=" + block.formalName); + if(block.fullDescription != null) write("block." + block.name + ".fulldescription=" + block.fullDescription); + if(block.description != null) write("block." + block.name + ".description=" + block.description); + } + } + + private static void write(String string){ + file.writeString(string.replaceAll("\\n", "\\\\n") + "\n", true); + } + + public static String join(String[] strings){ + String s = ""; + for(String string : strings){ + s += string + "\n"; + } + return s; + } + +} diff --git a/core/src/io/anuke/mindustry/resource/Weapon.java b/core/src/io/anuke/mindustry/resource/Weapon.java index 9ebad11f24..58eee87e4c 100644 --- a/core/src/io/anuke/mindustry/resource/Weapon.java +++ b/core/src/io/anuke/mindustry/resource/Weapon.java @@ -12,10 +12,11 @@ import io.anuke.mindustry.graphics.Fx; import io.anuke.ucore.core.Effects; import io.anuke.ucore.entities.Entity; import io.anuke.ucore.util.Angles; +import io.anuke.ucore.util.Bundles; import io.anuke.ucore.util.Mathf; public enum Weapon{ - blaster(15, BulletType.shot, "Shoots a slow, weak bullet."){ + blaster(15, BulletType.shot){ { unlocked = true; } @@ -26,7 +27,7 @@ public enum Weapon{ Effects.effect(Fx.shoot3, p.x + vector.x, p.y+vector.y); } }, - triblaster(13, BulletType.shot, "Shoots 3 bullets in a spread.", stack(Item.iron, 40)){ + triblaster(13, BulletType.shot, stack(Item.iron, 40)){ @Override public void shoot(Player p){ @@ -41,7 +42,7 @@ public enum Weapon{ } }, - multigun(6, BulletType.multishot, "Shoots inaccurate bullets with a high\nrate of fire.", stack(Item.iron, 60), stack(Item.steel, 20)){ + multigun(6, BulletType.multishot, stack(Item.iron, 60), stack(Item.steel, 20)){ @Override public void shoot(Player p){ float ang = mouseAngle(p); @@ -52,7 +53,7 @@ public enum Weapon{ Effects.effect(Fx.shoot2, p.x + vector.x, p.y+vector.y); } }, - flamer(5, BulletType.flame, "Shoots a stream of fire.", stack(Item.steel, 60), stack(Item.coal, 60)){ + flamer(5, BulletType.flame, stack(Item.steel, 60), stack(Item.coal, 60)){ { shootsound = "flame2"; @@ -67,7 +68,7 @@ public enum Weapon{ bullet(p, p.x, p.y, ang + Mathf.range(12)); } }, - railgun(40, BulletType.sniper, "Shoots one long-range bullet.", stack(Item.steel, 60), stack(Item.iron, 60)){ + railgun(40, BulletType.sniper, stack(Item.steel, 60), stack(Item.iron, 60)){ { shootsound = "railgun"; @@ -81,7 +82,7 @@ public enum Weapon{ Effects.effect(Fx.railshoot, p.x + vector.x, p.y+vector.y); } }, - mortar(100, BulletType.shell, "Shoots a slow, but damaging shell.", stack(Item.titanium, 40), stack(Item.steel, 60)){ + mortar(100, BulletType.shell, stack(Item.titanium, 40), stack(Item.steel, 60)){ { shootsound = "bigshot"; @@ -100,15 +101,15 @@ public enum Weapon{ public String shootsound = "shoot"; public boolean unlocked; public ItemStack[] requirements; - public String description = "no desc for you"; + public final String description; Vector2 vector = new Vector2(); - private Weapon(float reload, BulletType type, String desc, ItemStack... requirements){ + private Weapon(float reload, BulletType type, ItemStack... requirements){ this.reload = reload; this.type = type; this.requirements = requirements; - this.description = desc; + this.description = Bundles.getNotNull("weapon."+name()+".description"); } public void shoot(Player p){ diff --git a/core/src/io/anuke/mindustry/ui/FileChooser.java b/core/src/io/anuke/mindustry/ui/FileChooser.java index 286637b07f..0427588377 100644 --- a/core/src/io/anuke/mindustry/ui/FileChooser.java +++ b/core/src/io/anuke/mindustry/ui/FileChooser.java @@ -59,7 +59,7 @@ public class FileChooser extends FloatingDialog{ if(!open) Mindustry.platforms.addDialog(filefield); filefield.setDisabled(open); - ok = new TextButton(open ? "Open" : "Save"); + ok = new TextButton(open ? "$text.save" : "$text.save"); ok.clicked(() -> { if(ok.isDisabled()) return; @@ -74,8 +74,8 @@ public class FileChooser extends FloatingDialog{ filefield.change(); - TextButton cancel = new TextButton("Cancel"); - cancel.clicked(() -> hide()); + TextButton cancel = new TextButton("$text.cancel"); + cancel.clicked(this::hide); navigation = new TextField(""); navigation.setTouchable(Touchable.disabled); diff --git a/core/src/io/anuke/mindustry/ui/LevelDialog.java b/core/src/io/anuke/mindustry/ui/LevelDialog.java index 6fbbdf34bb..f176d9f760 100644 --- a/core/src/io/anuke/mindustry/ui/LevelDialog.java +++ b/core/src/io/anuke/mindustry/ui/LevelDialog.java @@ -14,6 +14,7 @@ import io.anuke.ucore.scene.ui.layout.Stack; import io.anuke.ucore.scene.ui.layout.Table; import io.anuke.ucore.scene.utils.ClickListener; import io.anuke.ucore.scene.utils.Elements; +import io.anuke.ucore.util.Bundles; import io.anuke.ucore.util.Tmp; public class LevelDialog extends FloatingDialog{ @@ -22,7 +23,7 @@ public class LevelDialog extends FloatingDialog{ private ScrollPane pane; public LevelDialog(){ - super("Level Select"); + super("$text.level.select"); getTitleTable().getCell(title()).growX().center(); getTitleTable().center(); addCloseButton(); @@ -43,10 +44,10 @@ public class LevelDialog extends FloatingDialog{ Table selmode = new Table(); ButtonGroup group = new ButtonGroup<>(); - selmode.add("Gamemode: ").padRight(10f); + selmode.add("$text.level.mode").padRight(15f); for(GameMode mode : GameMode.values()){ - TextButton b = Elements.newButton(mode.toString(), "toggle", ()->{ + TextButton b = Elements.newButton("$mode."+mode.name()+".name", "toggle", ()->{ Vars.control.setMode(mode); }); group.add(b); @@ -66,9 +67,9 @@ public class LevelDialog extends FloatingDialog{ } Table inset = new Table("pane-button"); - inset.add("[accent]"+map.name).pad(3f); + inset.add("[accent]" + Bundles.get("map."+map.name+".name", map.name)).pad(3f); inset.row(); - inset.label((() -> "High Score: [accent]" + Settings.getInt("hiscore" + map.name))) + inset.label((() -> Bundles.format("text.level.highscore", Settings.getInt("hiscore" + map.name)))) .pad(3f); inset.pack(); @@ -87,7 +88,7 @@ public class LevelDialog extends FloatingDialog{ image.row(); delete[0] = image.addButton("Delete", () -> { Timers.run(1f, () -> { - Vars.ui.showConfirm("Confirm Delete", "Are you sure you want to delete\nthe map \"[orange]" + map.name + "[]\"?", () -> { + Vars.ui.showConfirm("$text.level.delete.title", Bundles.format("text.level.delete", Bundles.get("map."+map.name+".name", map.name)), () -> { Vars.world.maps().removeMap(map); reload(); Core.scene.setScrollFocus(pane); diff --git a/core/src/io/anuke/mindustry/ui/LoadDialog.java b/core/src/io/anuke/mindustry/ui/LoadDialog.java index c90e5070ef..d9469de536 100644 --- a/core/src/io/anuke/mindustry/ui/LoadDialog.java +++ b/core/src/io/anuke/mindustry/ui/LoadDialog.java @@ -12,12 +12,13 @@ import io.anuke.ucore.scene.ui.Label; import io.anuke.ucore.scene.ui.ScrollPane; import io.anuke.ucore.scene.ui.TextButton; import io.anuke.ucore.scene.ui.layout.Table; +import io.anuke.ucore.util.Bundles; public class LoadDialog extends FloatingDialog{ ScrollPane pane; public LoadDialog() { - this("Load Game"); + this("$text.loadgame"); } public LoadDialog(String title) { @@ -35,7 +36,7 @@ public class LoadDialog extends FloatingDialog{ private void setup(){ content().clear(); - content().add("Select a save slot.").padBottom(2); + content().add("$text.selectslot").padBottom(2); content().row(); Table slots = new Table(); @@ -46,15 +47,15 @@ public class LoadDialog extends FloatingDialog{ for(int i = 0; i < Vars.saveSlots; i++){ - TextButton button = new TextButton("[accent]Slot " + (i + 1)); + TextButton button = new TextButton(Bundles.format("text.slot", (i + 1))); button.margin(12); button.getLabelCell().top().left().growX(); button.row(); - Label info = new Label("[gray]" + (!SaveIO.isSaveValid(i) ? "" : SaveIO.getMode(i) + ", " - + SaveIO.getMap(i).name + ", Wave " + SaveIO.getWave(i) - + "\nLast Saved: " + SaveIO.getTimeString(i))); + Label info = new Label("[gray]" + (!SaveIO.isSaveValid(i) ? Bundles.get("text.empty") : SaveIO.getMode(i) + ", " + + SaveIO.getMap(i).name + ", " + Bundles.format("text.save.wave", SaveIO.getWave(i)) + "\n" + + Bundles.format("text.save.date", SaveIO.getTimeString(i)))); info.setAlignment(Align.center, Align.center); button.add(info).padBottom(3).padTop(7); @@ -88,7 +89,7 @@ public class LoadDialog extends FloatingDialog{ Vars.ui.hideMenu(); GameState.set(State.menu); Vars.control.reset(); - Vars.ui.showError("[orange]Save file corrupted or invalid!"); + Vars.ui.showError("$text.save.corrupted"); return; } }); diff --git a/core/src/io/anuke/mindustry/ui/MenuDialog.java b/core/src/io/anuke/mindustry/ui/MenuDialog.java index e923274856..05846f0337 100644 --- a/core/src/io/anuke/mindustry/ui/MenuDialog.java +++ b/core/src/io/anuke/mindustry/ui/MenuDialog.java @@ -31,32 +31,32 @@ public class MenuDialog extends FloatingDialog{ if(!Vars.android){ content().defaults().width(220).height(50); - content().addButton("Back", () -> { + content().addButton("$text.back", () -> { hide(); if(!wasPaused) GameState.set(State.playing); }); content().row(); - content().addButton("Settings", () -> { + content().addButton("$text.settings", () -> { ui.showPrefs(); }); if(!Vars.gwt){ content().row(); - content().addButton("Save Game", () -> { + content().addButton("$text.savegame", () -> { save.show(); }); content().row(); - content().addButton("Load Game", () -> { + content().addButton("$text.loadgame", () -> { load.show(); }); } content().row(); - content().addButton("Quit", () -> { - new ConfirmDialog("Confirm", "Are you sure you want to quit?", () -> { + content().addButton("$text.quit", () -> { + new ConfirmDialog("$text.confirm", "$text.quit.confirm", () -> { hide(); GameState.set(State.menu); }){ @@ -79,16 +79,16 @@ public class MenuDialog extends FloatingDialog{ hide(); if(!wasPaused) GameState.set(State.playing); - }).text("Back").padTop(4f); + }).text("$text.back").padTop(4f); - new imagebutton("icon-tools", isize, () -> ui.showPrefs()).text("Settings").padTop(4f); + new imagebutton("icon-tools", isize, () -> ui.showPrefs()).text("$text.settings").padTop(4f); - new imagebutton("icon-save", isize, ()-> save.show()).text("Save").padTop(4f); + new imagebutton("icon-save", isize, ()-> save.show()).text("$text.save").padTop(4f); - new imagebutton("icon-load", isize, () -> load.show()).text("Load").padTop(4f); + new imagebutton("icon-load", isize, () -> load.show()).text("$text.load").padTop(4f); new imagebutton("icon-quit", isize, () -> { - new ConfirmDialog("Confirm", "Are you sure you want to quit?", () -> { + new ConfirmDialog("$text.confirm", "$text.quit.confirm", () -> { hide(); GameState.set(State.menu); }){{ diff --git a/core/src/io/anuke/mindustry/ui/MindustryKeybindDialog.java b/core/src/io/anuke/mindustry/ui/MindustryKeybindDialog.java index 3e25ec66e5..86a3c2d3b9 100644 --- a/core/src/io/anuke/mindustry/ui/MindustryKeybindDialog.java +++ b/core/src/io/anuke/mindustry/ui/MindustryKeybindDialog.java @@ -21,7 +21,7 @@ public class MindustryKeybindDialog extends KeybindDialog{ @Override public void addCloseButton(){ - buttons().addImageTextButton("Back", "icon-arrow-left", 30f, this::hide).size(230f, 64f); + buttons().addImageTextButton("$text.back", "icon-arrow-left", 30f, this::hide).size(230f, 64f); keyDown(key->{ if(key == Keys.ESCAPE || key == Keys.BACK) diff --git a/core/src/io/anuke/mindustry/ui/MindustrySettingsDialog.java b/core/src/io/anuke/mindustry/ui/MindustrySettingsDialog.java index 6beeb53919..c71f9c786f 100644 --- a/core/src/io/anuke/mindustry/ui/MindustrySettingsDialog.java +++ b/core/src/io/anuke/mindustry/ui/MindustrySettingsDialog.java @@ -39,7 +39,7 @@ public class MindustrySettingsDialog extends SettingsDialog{ Consumer s = table -> { table.row(); - table.addImageTextButton("Back", "icon-arrow-left", 10*3, this::back).size(240f, 60f).colspan(2).padTop(15f); + table.addImageTextButton("$text.back", "icon-arrow-left", 10*3, this::back).size(240f, 60f).colspan(2).padTop(15f); }; game = new SettingsTable(s); @@ -51,15 +51,15 @@ public class MindustrySettingsDialog extends SettingsDialog{ prefs.margin(14f); menu.defaults().size(300f, 60f).pad(3f); - menu.addButton("Game", () -> visible(0)); + menu.addButton("$text.settings.game", () -> visible(0)); menu.row(); - menu.addButton("Graphics", () -> visible(1)); + menu.addButton("$text.settings.graphics", () -> visible(1)); menu.row(); - menu.addButton("Sound", () -> visible(2)); + menu.addButton("$text.settings.sound", () -> visible(2)); if(!Vars.android) { menu.row(); - menu.addButton("Controls", () -> Vars.ui.showControls()); + menu.addButton("$text.settings.controls", () -> Vars.ui.showControls()); } prefs.clearChildren(); @@ -89,7 +89,7 @@ public class MindustrySettingsDialog extends SettingsDialog{ @Override public void addCloseButton(){ - buttons().addImageTextButton("Menu", "icon-arrow-left", 30f, this::hide).size(230f, 64f); + buttons().addImageTextButton("$text.menu", "icon-arrow-left", 30f, this::hide).size(230f, 64f); keyDown(key->{ if(key == Keys.ESCAPE || key == Keys.BACK) diff --git a/core/src/io/anuke/mindustry/ui/SaveDialog.java b/core/src/io/anuke/mindustry/ui/SaveDialog.java index 486d367bb1..edb2b27f5c 100644 --- a/core/src/io/anuke/mindustry/ui/SaveDialog.java +++ b/core/src/io/anuke/mindustry/ui/SaveDialog.java @@ -8,18 +8,19 @@ import io.anuke.ucore.core.Timers; import io.anuke.ucore.scene.ui.ConfirmDialog; import io.anuke.ucore.scene.ui.TextButton; import io.anuke.ucore.scene.ui.layout.Cell; +import io.anuke.ucore.util.Bundles; public class SaveDialog extends LoadDialog{ public SaveDialog() { - super("Save Game"); + super("$text.savegame"); } @Override public void modifyButton(TextButton button, int slot){ button.clicked(() -> { if(SaveIO.isSaveValid(slot)){ - new ConfirmDialog("Overwrite", "Are you sure you want to overwrite\nthis save slot?", () -> { + new ConfirmDialog("$text.overwrite", "$text.save.overwrite", () -> { save(slot); }){ { @@ -35,7 +36,7 @@ public class SaveDialog extends LoadDialog{ } void save(int slot){ - Vars.ui.showLoading("[accent]Saving..."); + Vars.ui.showLoading("text.saveload"); Timers.runTask(5f, () -> { hide(); @@ -45,7 +46,7 @@ public class SaveDialog extends LoadDialog{ }catch(Throwable e){ e = (e.getCause() == null ? e : e.getCause()); - Vars.ui.showError("[orange]Failed to save game!\n[white]" + ClassReflection.getSimpleName(e.getClass()) + ": " + e.getMessage() + "\n" + "at " + e.getStackTrace()[0].getFileName() + ":" + e.getStackTrace()[0].getLineNumber()); + Vars.ui.showError("[orange]"+Bundles.get("text.savefail")+"\n[white]" + ClassReflection.getSimpleName(e.getClass()) + ": " + e.getMessage() + "\n" + "at " + e.getStackTrace()[0].getFileName() + ":" + e.getStackTrace()[0].getLineNumber()); } }); } diff --git a/core/src/io/anuke/mindustry/ui/UpgradeDialog.java b/core/src/io/anuke/mindustry/ui/UpgradeDialog.java index fdaac77827..a4057979a0 100644 --- a/core/src/io/anuke/mindustry/ui/UpgradeDialog.java +++ b/core/src/io/anuke/mindustry/ui/UpgradeDialog.java @@ -21,7 +21,7 @@ public class UpgradeDialog extends FloatingDialog{ boolean wasPaused = false; public UpgradeDialog() { - super("Upgrades"); + super("$text.upgrades"); setup(); } @@ -107,7 +107,7 @@ public class UpgradeDialog extends FloatingDialog{ tiptable.add("[gray]" + description).left(); tiptable.row(); if(control.hasWeapon(weapon)){ - tiptable.add("[LIME]Purchased!").padTop(6).left(); + tiptable.add("$text.purchased").padTop(6).left(); } tiptable.margin(14f); }; @@ -131,7 +131,7 @@ public class UpgradeDialog extends FloatingDialog{ }); } - content().add("Weapons"); + content().add("$text.weapons"); content().row(); content().add(weptab); content().row(); diff --git a/core/src/io/anuke/mindustry/ui/fragments/BlocksFragment.java b/core/src/io/anuke/mindustry/ui/fragments/BlocksFragment.java index 6ddd0482da..45272a9b2e 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/BlocksFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/BlocksFragment.java @@ -2,9 +2,12 @@ package io.anuke.mindustry.ui.fragments; import static io.anuke.mindustry.Vars.*; +import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Colors; import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.math.Interpolation; +import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Array; import io.anuke.mindustry.core.GameState; @@ -13,9 +16,11 @@ import io.anuke.mindustry.resource.ItemStack; import io.anuke.mindustry.resource.Recipe; import io.anuke.mindustry.resource.Section; import io.anuke.mindustry.ui.FloatingDialog; +import io.anuke.ucore.UCore; import io.anuke.ucore.core.Core; import io.anuke.ucore.core.Draw; import io.anuke.ucore.graphics.Hue; +import io.anuke.ucore.scene.actions.Actions; import io.anuke.ucore.scene.builders.button; import io.anuke.ucore.scene.builders.imagebutton; import io.anuke.ucore.scene.builders.table; @@ -23,6 +28,7 @@ import io.anuke.ucore.scene.event.Touchable; import io.anuke.ucore.scene.ui.*; import io.anuke.ucore.scene.ui.layout.Stack; import io.anuke.ucore.scene.ui.layout.Table; +import io.anuke.ucore.util.Bundles; import io.anuke.ucore.util.Mathf; public class BlocksFragment implements Fragment{ @@ -38,7 +44,7 @@ public class BlocksFragment implements Fragment{ visible(() -> !GameState.is(State.menu)); - new table(){{ + Table blocks = new table(){{ new table("button") {{ visible(() -> player.recipe != null); @@ -108,10 +114,8 @@ public class BlocksFragment implements Fragment{ image.getImageCell().size(size); image.update(() -> { - boolean canPlace = !control.getTutorial().active() || control.getTutorial().canPlace(); boolean has = (control.hasItems(r.requirements)) && canPlace; - //image.setDisabled(!has); image.setChecked(player.recipe == r); image.setTouchable(canPlace ? Touchable.enabled : Touchable.disabled); image.getImage().setColor(has ? Color.WHITE : Hue.lightness(0.33f)); @@ -133,22 +137,42 @@ public class BlocksFragment implements Fragment{ add(stack).colspan(Section.values().length); margin(10f); - get().marginLeft(0f); - get().marginRight(0f); + marginLeft(0f); + marginRight(0f); end(); }}.right().bottom().uniformX(); visible(() -> !GameState.is(State.menu) && shown); - }}.end(); + }}.end().get(); row(); - new imagebutton("icon-arrow-down", 10*2, () -> { - shown = !shown; - }).padBottom(-5).uniformX().fillX() - .update(i -> i.getStyle().imageUp = Core.skin.getDrawable(shown ? "icon-arrow-down" : "icon-arrow-up")); + ImageButton buttons[] = new ImageButton[2]; + float size = 46f; + + float t = 0.2f; + Interpolation ip = Interpolation.pow3Out; + + //TODO fix glitch when resizing + buttons[0] = new imagebutton("icon-arrow-down", 10*2, () -> { + if(blocks.getActions().size != 0) return; + blocks.actions(Actions.translateBy(0, -blocks.getHeight(), t, ip), Actions.call(() -> shown = false)); + buttons[0].actions(Actions.fadeOut(t)); + buttons[1].actions(Actions.fadeIn(t)); + }).padBottom(-5).visible(() -> shown).height(size).uniformX().fillX() + .update(i -> i.getStyle().imageUp = Core.skin.getDrawable(shown ? "icon-arrow-down" : "icon-arrow-up")).get(); + + buttons[1] = new imagebutton("icon-arrow-up", 10*2, () -> { + if(blocks.getActions().size != 0) return; + blocks.actions(Actions.translateBy(0, blocks.getHeight(), t, ip)); + shown = true; + buttons[0].actions(Actions.fadeIn(t)); + buttons[1].actions(Actions.fadeOut(t)); + }).touchable(() -> shown ? Touchable.disabled : Touchable.enabled).size(size).padBottom(-5).padLeft(-size).get(); + + buttons[1].getColor().a = 0f; }}.end(); } @@ -187,7 +211,7 @@ public class BlocksFragment implements Fragment{ boolean wasPaused = GameState.is(State.paused); GameState.set(State.paused); - FloatingDialog d = new FloatingDialog("Block Info"); + FloatingDialog d = new FloatingDialog("$text.blocks.blockinfo"); Table table = new Table(); table.defaults().pad(1f); ScrollPane pane = new ScrollPane(table, "clear"); @@ -204,7 +228,7 @@ public class BlocksFragment implements Fragment{ d.content().add(pane).grow(); if(statlist.size > 0){ - table.add("[accent]extra block info:").padTop(6).padBottom(5).left(); + table.add("$text.blocks.extrainfo").padTop(6).padBottom(5).left(); table.row(); } @@ -213,7 +237,7 @@ public class BlocksFragment implements Fragment{ table.row(); } - d.buttons().addButton("OK", ()->{ + d.buttons().addButton("$text.ok", ()->{ if(!wasPaused) GameState.set(State.playing); d.hide(); }).size(110, 50).pad(10f); @@ -252,7 +276,7 @@ public class BlocksFragment implements Fragment{ desctable.row(); - Label label = new Label("[health]health: " + recipe.result.health + (recipe.result.description == null ? + Label label = new Label("[health]"+ Bundles.get("text.health")+": " + recipe.result.health + (recipe.result.description == null ? "" : ("\n[]" + recipe.result.description))); label.setWrap(true); desctable.add(label).width(200).padTop(4).padBottom(2); diff --git a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java index 910f016d6d..676be94c8b 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java @@ -23,6 +23,7 @@ import io.anuke.ucore.scene.ui.Image; import io.anuke.ucore.scene.ui.Label; import io.anuke.ucore.scene.ui.layout.Cell; import io.anuke.ucore.scene.ui.layout.Table; +import io.anuke.ucore.util.Bundles; public class HudFragment implements Fragment{ private Table itemtable, respawntable; @@ -91,7 +92,7 @@ public class HudFragment implements Fragment{ atop(); new table("pane"){{ - new label("[orange]< paused >").scale(0.75f).pad(6); + new label("[orange]< "+ Bundles.get("text.paused") + " >").scale(0.75f).pad(6); }}.end(); }}.end(); @@ -122,7 +123,7 @@ public class HudFragment implements Fragment{ new table(){{ new table("pane"){{ - new label(()->"[orange]Respawning in " + (int)(control.getRespawnTime()/60)).scale(0.75f).pad(10); + new label(()->"[orange]"+Bundles.get("text.respawn")+" " + (int)(control.getRespawnTime()/60)).scale(0.75f).pad(10); visible(()->control.getRespawnTime() > 0 && !GameState.is(State.menu)); @@ -149,10 +150,10 @@ public class HudFragment implements Fragment{ } } - private String printEnemiesRemaining() { + private String getEnemiesRemaining() { if(control.getEnemiesRemaining() == 1) { - return " enemy left"; - } else return " enemies left"; + return Bundles.format("text.single", control.getEnemiesRemaining()); + } else return Bundles.format("text.enemies", control.getEnemiesRemaining()); } private void addWaveTable(){ @@ -163,13 +164,14 @@ public class HudFragment implements Fragment{ new table(){{ aleft(); - new label(()->"[orange]Wave " + control.getWave()).scale(fontscale*1.5f).left(); + new label(() -> Bundles.format("text.wave", control.getWave())).scale(fontscale*1.5f).left(); row(); new label(()-> control.getEnemiesRemaining() > 0 ? - control.getEnemiesRemaining() + printEnemiesRemaining() : - (control.getTutorial().active() || Vars.control.getMode().toggleWaves) ? "waiting..." : "Wave in " + (int) (control.getWaveCountdown() / 60f)) + getEnemiesRemaining() : + (control.getTutorial().active() || Vars.control.getMode().toggleWaves) ? "$text.waiting" + : Bundles.format("text.wave.waiting", (int) (control.getWaveCountdown() / 60f))) .minWidth(140).left(); margin(12f); diff --git a/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java b/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java index f1633310ee..08a24e1ff6 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/MenuFragment.java @@ -56,22 +56,22 @@ public class MenuFragment implements Fragment{ defaults().size(120f).pad(5); float isize = 14f*4; - new imagebutton("icon-play-2", isize, () -> ui.showLevels()).text("Play").padTop(4f); + new imagebutton("icon-play-2", isize, () -> ui.showLevels()).text("$text.play").padTop(4f); - new imagebutton("icon-tutorial", isize, () -> control.playMap(world.maps().getMap("tutorial"))).text("Tutorial").padTop(4f); + new imagebutton("icon-tutorial", isize, () -> control.playMap(world.maps().getMap("tutorial"))).text("$text.tutorial").padTop(4f); - new imagebutton("icon-load", isize, () -> ui.showLoadGame()).text("Load").padTop(4f); + new imagebutton("icon-load", isize, () -> ui.showLoadGame()).text("$text.load").padTop(4f); row(); - new imagebutton("icon-editor", isize, () -> ui.showEditor()).text("Editor").padTop(4f); + new imagebutton("icon-editor", isize, () -> ui.showEditor()).text("$text.editor").padTop(4f); - new imagebutton("icon-tools", isize, () -> ui.showPrefs()).text("Settings").padTop(4f); + new imagebutton("icon-tools", isize, () -> ui.showPrefs()).text("$text.settings").padTop(4f); if(Mindustry.donationsCallable != null){ new imagebutton("icon-donate", isize, () -> { Mindustry.donationsCallable.run(); - }).text("Donate").padTop(4f); + }).text("$text.donate").padTop(4f); } visible(()->GameState.is(State.menu)); diff --git a/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java b/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java index 162d08c5e6..ee4e71c7a4 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java @@ -28,7 +28,7 @@ public class PlacementFragment implements Fragment{ touchable(Touchable.enabled); aleft(); - new label("place mode"); + new label("$text.placemode"); row(); new table("pane"){{ @@ -76,7 +76,7 @@ public class PlacementFragment implements Fragment{ abottom(); aleft(); - new label("break mode"); + new label("$text.breakmode"); row(); new table("pane"){{ diff --git a/core/src/io/anuke/mindustry/ui/fragments/WeaponFragment.java b/core/src/io/anuke/mindustry/ui/fragments/WeaponFragment.java index a65bfbaa93..0ed2654e16 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/WeaponFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/WeaponFragment.java @@ -28,7 +28,7 @@ public class WeaponFragment implements Fragment{ public void updateWeapons(){ weapontable.clearChildren(); - ButtonGroup group = new ButtonGroup(); + ButtonGroup group = new ButtonGroup<>(); weapontable.defaults().size(58, 62); @@ -52,14 +52,14 @@ public class WeaponFragment implements Fragment{ String description = weapon.description; tiptable.background("button"); - tiptable.add("" + weapon.name(), 0.5f).left().padBottom(3f); + tiptable.add("weapon."+weapon.name()+".name", 0.5f).left().padBottom(3f); tiptable.row(); tiptable.row(); tiptable.add("[GRAY]" + description).left(); tiptable.margin(14f); - Tooltip tip = new Tooltip(tiptable); + Tooltip tip = new Tooltip<>(tiptable); tip.setInstant(true); diff --git a/core/src/io/anuke/mindustry/world/Block.java b/core/src/io/anuke/mindustry/world/Block.java index 04f06e4595..1b8dc783ee 100644 --- a/core/src/io/anuke/mindustry/world/Block.java +++ b/core/src/io/anuke/mindustry/world/Block.java @@ -15,6 +15,7 @@ import io.anuke.mindustry.resource.Liquid; import io.anuke.ucore.core.Draw; import io.anuke.ucore.core.Effects; import io.anuke.ucore.core.Effects.Effect; +import io.anuke.ucore.util.Bundles; import io.anuke.ucore.util.Mathf; import io.anuke.ucore.util.Tmp; public class Block{ @@ -29,7 +30,7 @@ public class Block{ /**internal ID*/ public final int id; /**display name*/ - public String formalName; + public final String formalName; /**played on destroy*/ public Effect explosionEffect = Fx.blockexplosion; /**played on destroy*/ @@ -67,9 +68,9 @@ public class Block{ /**multiblock width/height*/ public int width = 1, height = 1; /**Brief block description. Should be short enough fit in the place menu.*/ - public String description; + public final String description; /**Detailed description of the block. Can be as long as necesary.*/ - public String fullDescription; + public final String fullDescription; /**Whether to draw this block in the expanded draw range.*/ public boolean expanded = false; /**Max of timers used.*/ @@ -83,7 +84,9 @@ public class Block{ blocks.add(this); this.name = name; - this.formalName = name; + this.formalName = Bundles.get("block." + name + ".name", name); + this.description = Bundles.get("block." + name + ".description"); + this.fullDescription = Bundles.get("block." + name + ".fulldescription"); this.solid = false; this.id = lastid++; } diff --git a/core/src/io/anuke/mindustry/world/blocks/DefenseBlocks.java b/core/src/io/anuke/mindustry/world/blocks/DefenseBlocks.java index 625581c371..70f21a9d30 100644 --- a/core/src/io/anuke/mindustry/world/blocks/DefenseBlocks.java +++ b/core/src/io/anuke/mindustry/world/blocks/DefenseBlocks.java @@ -11,66 +11,43 @@ public class DefenseBlocks{ stonewall = new Wall("stonewall"){{ health = 50; - formalName = "stone wall"; - fullDescription = "A cheap defensive block. Useful for protecting the core and turrets in the first few waves."; }}, ironwall = new Wall("ironwall"){{ health = 80; - formalName = "iron wall"; - fullDescription = "A basic defensive block. Provides protection from enemies."; }}, steelwall = new Wall("steelwall"){{ health = 110; - formalName = "steel wall"; - fullDescription = "A standard defensive block. adequate protection from enemies."; }}, titaniumwall = new Wall("titaniumwall"){{ health = 150; - formalName = "titanium wall"; - fullDescription = "A strong defensive block. Provides protection from enemies."; }}, diriumwall = new Wall("duriumwall"){{ health = 190; - formalName = "dirium wall"; - fullDescription = "A very strong defensive block. Provides protection from enemies."; }}, compositewall = new Wall("compositewall"){{ health = 270; - formalName = "composite wall"; }}, steelwalllarge = new Wall("steelwall-large"){{ health = 110*4; - formalName = "large steel wall"; width = height = 2; - fullDescription = "A standard defensive block. Spans multiple tiles."; }}, titaniumwalllarge = new Wall("titaniumwall-large"){{ health = 150*4; - formalName = "large titanium wall"; width = height = 2; - fullDescription = "A strong defensive block. Spans multiple tiles."; }}, diriumwalllarge = new Wall("duriumwall-large"){{ health = 190*4; - formalName = "large dirium wall"; width = height = 2; - fullDescription = "A very strong defensive block. Spans multiple tiles."; }}, titaniumshieldwall = new ShieldedWallBlock("titaniumshieldwall"){{ - fullDescription = "A strong defensive block, with an extra built-in shield. Requires power. " - + "Uses energy to absorb enemy bullets. It is recommended to use power boosters to provide energy to this block."; health = 150; - formalName = "shielded wall"; }}, repairturret = new RepairTurret("repairturret"){ { - fullDescription = "Repairs nearby damaged blocks in range at a slow rate. " - + "Uses small amounts of power."; - formalName = "repair turret"; range = 30; reload = 60f; health = 60; @@ -79,9 +56,6 @@ public class DefenseBlocks{ megarepairturret = new RepairTurret("megarepairturret"){ { - fullDescription = "Repairs nearby damaged blocks in range at a decent rate. " - + "Uses power."; - formalName = "repair turret II"; range = 44; reload = 30f; powerUsed = 0.15f; @@ -91,21 +65,13 @@ public class DefenseBlocks{ shieldgenerator = new ShieldBlock("shieldgenerator"){ { - //TODO - fullDescription = "An advanced defensive block. Shields all the blocks in a radius from attack. Uses power at a slow rate when idle, " - + "but drains energy quickly on bullet contact."; - formalName = "shield generator"; + } }, door = new Door("door"){{ - fullDescription = "A block than can be opened and closed by tapping it."; - description = "Opens and closes.\n[interact]Tap to toggle"; health = 90; }}, largedoor = new Door("door-large"){{ - formalName = "large door"; - fullDescription = "A block than can be opened and closed by tapping it."; - description = "Opens and closes.\n[interact]Tap to toggle"; openfx = Fx.dooropenlarge; closefx = Fx.doorcloselarge; health = 90*4; diff --git a/core/src/io/anuke/mindustry/world/blocks/DistributionBlocks.java b/core/src/io/anuke/mindustry/world/blocks/DistributionBlocks.java index 59818120dc..2153999a45 100644 --- a/core/src/io/anuke/mindustry/world/blocks/DistributionBlocks.java +++ b/core/src/io/anuke/mindustry/world/blocks/DistributionBlocks.java @@ -9,107 +9,58 @@ public class DistributionBlocks{ public static final Block conduit = new LiquidBlock("conduit"){{ - fullDescription = "Basic liquid transport block. Works like a conveyor, but with liquids. " - + "Best used with pumps or other conduits. Can be used as a bridge over liquids for enemies and players."; health = 45; }}, pulseconduit = new LiquidBlock("pulseconduit"){{ - formalName = "pulse conduit"; - fullDescription = "Advanced liquid transport block. Transports liquids faster and stores more than standard conduits."; liquidCapacity = 16f; flowfactor = 4.9f; health = 65; }}, liquidrouter = new LiquidRouter("liquidrouter"){{ - description = "Splits input liquid into 3 directions."; - fullDescription = "Works similarly to a router. Accepts liquid input from one side and outputs it to the other sides. " - + "Useful for splitting liquid from a single conduit into multiple other conduits."; - formalName = "liquid router"; + }}, conveyor = new Conveyor("conveyor"){{ - fullDescription = "Basic item transport block. Moves items forward and automatically deposits them into turrets or crafters. " - + "Rotatable. Can be used as a bridge over liquids for enemies and players."; }}, steelconveyor = new Conveyor("steelconveyor"){{ health = 55; speed = 0.04f; - formalName = "steel conveyor"; - fullDescription = "Advanced item transport block. Moves items faster than standard conveyors."; }}, pulseconveyor = new Conveyor("poweredconveyor"){{ health = 75; speed = 0.09f; - formalName = "pulse conveyor"; - fullDescription = "The ultimate item transport block. Moves items faster than steel conveyors."; }}, router = new Router("router"){{ - description = "Split input materials into 3 directions."; - fullDescription = "Accepts items from one direction and outputs them to 3 other directions. Can also store a certain amount of items." - + "Useful for splitting the materials from one drill into multiple turrets."; + }}, junction = new Junction("junction"){{ - description = "Serves as a conveyor junction."; - fullDescription = "Acts as a bridge for two crossing conveyor belts. Useful in situations with " - + "two different conveyors carrying different materials to different locations."; }}, tunnel = new TunnelConveyor("conveyortunnel"){{ - formalName = "conveyor tunnel"; - description = "Transports items under blocks."; - fullDescription = "Transports item under blocks. " - + "To use, place one tunnel leading into the block to be tunneled under, and one on the other side."; }}, liquidjunction = new LiquidJunction("liquidjunction"){{ - formalName = "liquid junction"; - fullDescription = "Acts as a bridge for two crossing conduits. Useful in situations with " - + "two different conduits carrying different liquids to different locations."; + }}, liquiditemjunction = new LiquidItemJunction("liquiditemjunction"){{ - formalName = "liquid-item junction"; - description = "Serves as a junction for items and liquids."; - fullDescription = "Acts as a bridge for crossing conduits and conveyors."; }}, powerbooster = new PowerBooster("powerbooster"){{ - formalName = "power booster"; powerRange = 4; - description = "Distributes power within a radius."; - fullDescription = "Distributes power to all blocks within its radius. "; }}, powerlaser = new PowerLaser("powerlaser"){{ - formalName = "power laser"; - description = "Transmits power."; - fullDescription = "Creates a laser that transmits power to the block in front of it. Does not generate any power itself. " - + "Best used with generators or other lasers."; }}, powerlaserrouter = new PowerLaserRouter("powerlaserrouter"){{ - formalName = "laser router"; - description = "Splits input power into 3 lasers."; - fullDescription = "Laser that distributes power to three directions at once. " - + "Useful in situations where it is required to power multiple blocks from one generator."; }}, powerlasercorner = new PowerLaserRouter("powerlasercorner"){{ laserDirections = 2; - formalName = "laser corner"; - description = "Splits input power into 2 lasers."; - fullDescription = "Laser that distributes power to two directions at once. " - + "Useful in situations where it is required to power multiple blocks from one generator, and a router is imprecise."; }}, teleporter = new Teleporter("teleporter"){{ - description = "[interact]Tap block to config[]"; - fullDescription = "Advanced item transport block. Teleporters input items to other teleporters of the same color." - + " Does nothing if no teleporters of the same color exist. If multiple teleporters exist of the same color, a random one is selected." - + " Tap and click the arrows to change color."; }}, sorter = new Sorter("sorter"){{ - description = "[interact]Tap block to config[]"; - fullDescription = "Sorts item by material type. Material to accept is indicated by the color in the block. " - + "All items that match the sort material are outputted forward, everything else is outputted to the left and right."; }}; } diff --git a/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java b/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java index 98a2d7b36d..ada072edf1 100644 --- a/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java +++ b/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java @@ -7,46 +7,20 @@ import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.resource.Liquid; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; +import io.anuke.mindustry.world.blocks.types.defense.CoreBlock; import io.anuke.mindustry.world.blocks.types.production.*; import io.anuke.ucore.core.Effects; public class ProductionBlocks{ public static final Block - core = new Block("core"){ - { - health = 800; - solid = true; - destructible = true; - width = 3; - height = 3; - } - - @Override - public int handleDamage(Tile tile, int amount){ - return Vars.debug ? 0 : amount; - } - - @Override - public void handleItem(Item item, Tile tile, Tile source){ - Vars.control.addItem(item, 1); - } - - @Override - public boolean acceptItem(Item item, Tile dest, Tile source){ - return true; - } - }, + core = new CoreBlock("core"), pump = new Pump("pump"){{ - description = "Pumps liquids into nearby conduits."; - fullDescription = "Pumps liquids from a source block- usually water, lava or oil. Outputs liquid into nearby conduits."; }}, fluxpump = new Pump("fluxpump"){{ pumpAmount = 3f; - description = "Pumps liquids into nearby conduits."; - fullDescription = "An advanced version of the pump. Stores more liquid and pumps liquid faster."; }}, smelter = new Crafter("smelter"){ @@ -54,8 +28,6 @@ public class ProductionBlocks{ health = 70; requirements = new Item[]{Item.coal, Item.iron}; result = Item.steel; - description = "Converts coal + iron to steel."; - fullDescription = "The essential crafting block. When inputted 1x iron and 1x coal, outputs one steel."; } }, @@ -64,14 +36,11 @@ public class ProductionBlocks{ health = 90; requirements = new Item[]{Item.titanium, Item.steel}; result = Item.dirium; - description = "Converts steel + titanium to dirium."; - fullDescription = "An advanced crafting block. When inputted 1x titanium and 1x steel, outputs one dirium."; } }, coalpurifier = new LiquidCrafter("coalpurifier"){ { - formalName = "coal extractor"; input = Item.stone; inputAmount = 5; inputLiquid = Liquid.water; @@ -79,14 +48,11 @@ public class ProductionBlocks{ output = Item.coal; health = 50; purifyTime = 50; - description = "Converts stone + water to coal."; - fullDescription = "A basic extractor block. Outputs coal when supplied with large amounts of water and stone."; } }, titaniumpurifier = new LiquidCrafter("titaniumpurifier"){ { - formalName = "titanium extractor"; input = Item.iron; inputAmount = 6; inputLiquid = Liquid.water; @@ -95,14 +61,11 @@ public class ProductionBlocks{ purifyTime = 60; output = Item.titanium; health = 70; - description = "Converts iron + water to titanium."; - fullDescription = "A standard extractor block. Outputs titanium when supplied with large amounts of water and iron."; } }, oilrefinery = new LiquidCrafter("oilrefinery"){ { - formalName = "oil refinery"; inputLiquid = Liquid.oil; liquidAmount = 45f; liquidCapacity = 46f; @@ -110,14 +73,11 @@ public class ProductionBlocks{ output = Item.coal; health = 80; craftEffect = Fx.purifyoil; - description = "Converts oil to coal."; - fullDescription = "Refines large amounts of oil into coal items. Useful for fueling coal-based turrets when coal veins are scarce."; } }, stoneformer = new LiquidCrafter("stoneformer"){ { - formalName = "stone former"; input = null; inputLiquid = Liquid.lava; liquidAmount = 16f; @@ -126,14 +86,11 @@ public class ProductionBlocks{ output = Item.stone; health = 80; craftEffect = Fx.purifystone; - description = "Converts lava to stone."; - fullDescription = "Soldifies liquid lava into stone. Useful for producing massive amounts of stone for coal purifiers."; } }, lavasmelter = new LiquidCrafter("lavasmelter"){ { - formalName = "lava smelter"; input = Item.iron; inputAmount = 1; inputLiquid = Liquid.lava; @@ -143,8 +100,6 @@ public class ProductionBlocks{ output = Item.steel; health = 80; craftEffect = Fx.purifystone; - description = "Converts iron + lava to steel."; - fullDescription = "Uses lava to convert iron to steel. An alternative to smelteries. Useful in situations where coal is scarace."; } }, @@ -152,42 +107,27 @@ public class ProductionBlocks{ resource = Blocks.stone; result = Item.stone; time = 4; - formalName = "stone drill"; - description = "Mines 1 "+resource.name+" every "+time+" seconds."; - fullDescription = "The essential drill. When placed on stone tiles, outputs stone at a slow pace indefinitely."; }}, irondrill = new Drill("irondrill"){{ resource = Blocks.iron; result = Item.iron; - formalName = "iron drill"; - description = "Mines 1 "+resource.name+" every "+time+" seconds."; - fullDescription = "A basic drill. When placed on iron ore tiles, outputs iron at a slow pace indefinitely."; }}, coaldrill = new Drill("coaldrill"){{ resource = Blocks.coal; result = Item.coal; - formalName = "coal drill"; - description = "Mines 1 "+resource.name+" every "+time+" seconds."; - fullDescription = "A basic drill. When placed on coal ore tiles, outputs coal at a slow pace indefinitely."; }}, uraniumdrill = new Drill("uraniumdrill"){{ resource = Blocks.uranium; result = Item.uranium; - formalName = "uranium drill"; time = 7; - description = "Mines 1 "+resource.name+" every "+time+" seconds."; - fullDescription = "An advanced drill. When placed on uranium ore tiles, outputs uranium at a slow pace indefinitely."; }}, titaniumdrill = new Drill("titaniumdrill"){{ resource = Blocks.titanium; result = Item.titanium; - formalName = "titanium drill"; - description = "Mines 1 "+resource.name+" every "+time+" seconds."; - fullDescription = "An advanced drill. When placed on titanium ore tiles, outputs titanium at a slow pace indefinitely."; }}, omnidrill = new Drill("omnidrill"){ @@ -196,9 +136,6 @@ public class ProductionBlocks{ resource = null; result = null; time = 3; - formalName = "omnidrill"; - description = "Mines 1 of any resource every "+time+" seconds."; - fullDescription = "The ultimate drill. Will mine any ore it is placed on at a rapid pace."; } @Override @@ -217,62 +154,42 @@ public class ProductionBlocks{ }, coalgenerator = new ItemPowerGenerator("coalgenerator"){ { - //TODO - formalName = "coal generator"; generateItem = Item.coal; powerOutput = 0.05f; powerCapacity = 40f; - description = "Generates power from coal."; - fullDescription = "The essential generator. Generates power from coal. Outputs power as lasers to its 4 sides."; } }, thermalgenerator = new LiquidPowerGenerator("thermalgenerator"){ { - formalName = "thermal generator"; - //TODO generateLiquid = Liquid.lava; maxLiquidGenerate = 0.5f; powerPerLiquid = 0.09f; powerCapacity = 40f; - description = "Generates power from lava."; - fullDescription = "Generates power from lava. Outputs power as lasers to its 4 sides."; generateEffect = Fx.redgeneratespark; } }, combustiongenerator = new LiquidPowerGenerator("combustiongenerator"){ { - formalName = "combustion generator"; - //TODO generateLiquid = Liquid.oil; maxLiquidGenerate = 0.4f; powerPerLiquid = 0.13f; powerCapacity = 40f; - description = "Generates power from oil."; - fullDescription = "Generates power from oil. Outputs power as lasers to its 4 sides."; } }, rtgenerator = new ItemPowerGenerator("rtgenerator"){ { - //TODO make this generate slowly - formalName = "RTG generator"; generateItem = Item.uranium; powerCapacity = 40f; powerOutput = 0.04f; itemDuration = 240f; - description = "Generates power from uranium."; - fullDescription = "Generates small amounts of power from the radioactive decay of uranium. Outputs power as lasers to its 4 sides."; } }, nuclearReactor = new NuclearReactor("nuclearreactor"){ { - //TODO - formalName = "nuclear reactor"; width = 3; height = 3; health = 600; breaktime *= 2.3f; - fullDescription = "An advanced version of the RTG Generator, and the ultimate power generator. Generates power from uranium. Requires constant water cooling. " - + "Highly volatile; will explode violently if insufficient amounts of coolant are supplied. "; } }; } diff --git a/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java b/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java index bffbfc34c9..07ce77b5f7 100644 --- a/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java +++ b/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java @@ -22,26 +22,22 @@ public class WeaponBlocks{ turret = new Turret("turret"){ { - formalName = "turret"; range = 52; reload = 15f; bullet = BulletType.stone; health = 50; ammo = Item.stone; - fullDescription = "A basic, cheap turret. Uses stone for ammo. Has slightly more range than the double-turret."; } }, doubleturret = new Turret("doubleturret"){ { - formalName = "double turret"; range = 44; reload = 13f; bullet = BulletType.stone; ammo = Item.stone; health = 55; health = 50; - fullDescription = "A slightly more powerful version of the turret. Uses stone for ammo. Does significantly more damage, but has a lower range. Shoots two bullets."; } @Override @@ -58,19 +54,16 @@ public class WeaponBlocks{ machineturret = new Turret("machineturret"){ { - formalName = "gattling turret"; range = 65; reload = 7f; bullet = BulletType.iron; ammo = Item.iron; health = 65; - fullDescription = "A standard all-around turret. Uses iron for ammo. Has a fast fire rate with decent damage."; } }, shotgunturret = new Turret("shotgunturret"){ { - formalName = "splitter turret"; range = 50; reload = 30f; bullet = BulletType.iron; @@ -79,36 +72,28 @@ public class WeaponBlocks{ shots = 5; inaccuracy = 15f; shotDelayScale = 0.7f; - fullDescription = "A standard turret. Uses iron for ammo. Shoots a spread of 7 bullets. " - + "Lower range, but higher damage output than the gattling turret."; } }, flameturret = new Turret("flameturret"){ { - formalName = "flamer turret"; range = 35f; reload = 5f; bullet = BulletType.flame; ammo = Item.coal; health = 90; - fullDescription = "Advanced close-range turret. Uses coal for ammo. Has very low range, but very high damage. " - + "Good for close quarters. Recommended to be used behind walls."; } }, sniperturret = new Turret("sniperturret"){ { shootsound = "railgun"; - formalName = "railgun turret"; range = 120; reload = 50f; bullet = BulletType.sniper; ammo = Item.steel; health = 70; shootEffect = Fx.railshot; - fullDescription = "Advanced long-range turret. Uses steel for ammo. Very high damage, but low fire rate. " - + "Expensive to use, but can be placed far away from enemy lines due to its range."; } }, @@ -116,16 +101,12 @@ public class WeaponBlocks{ { shootsound = "bigshot"; rotatespeed = 0.1f; - formalName = "flak turret"; range = 120; reload = 100f; bullet = BulletType.shell; ammo = Item.coal; ammoMultiplier = 5; health = 110; - fullDescription = "Advanced splash-damage turret. Uses coal for ammo. " - + "Very slow fire rate and bullets, but very high single-target and splash damage. " - + "Useful for large crowds of enemies."; shootEffect = Fx.mortarshot; shootShake = 2f; } @@ -135,27 +116,21 @@ public class WeaponBlocks{ { shootsound = "laser"; beamColor = Color.SKY; - formalName = "laser turret"; range = 60; reload = 4f; damage = 10; health = 110; powerUsed = 0.2f; - fullDescription = "Advanced single-target turret. Uses power. Good medium-range all-around turret. " - + "Single-target only. Never misses."; } }, teslaturret = new PowerTurret("waveturret"){ { shootsound = "tesla"; - formalName = "tesla turret"; range = 70; reload = 15f; bullet = BulletType.shell; health = 140; - fullDescription = "Advanced multi-target turret. Uses power. Medium range. Never misses." - + "Average to low damage, but can hit multiple enemies simultaneously with chain lighting."; } @Override @@ -172,15 +147,12 @@ public class WeaponBlocks{ { shootsound = "flame2"; inaccuracy = 7f; - formalName = "plasma turret"; range = 60f; reload = 3f; bullet = BulletType.plasmaflame; ammo = Item.coal; health = 180; ammoMultiplier = 40; - fullDescription = "Highly advanced version of the flamer turret. Uses coal as ammo. " - + "Very high damage, low to medium range."; } }, @@ -188,7 +160,6 @@ public class WeaponBlocks{ { shootsound = "bigshot"; inaccuracy = 8f; - formalName = "chain turret"; range = 80f; reload = 8f; bullet = BulletType.chain; @@ -198,8 +169,6 @@ public class WeaponBlocks{ shootCone = 9f; ammoMultiplier = 8; shots = 2; - fullDescription = "The ultimate rapid-fire turret. Uses uranium as ammo. Shoots large slugs at a high fire rate. " - + "Medium range. Spans multiple tiles. Extremely tough."; shootEffect = Fx.chainshot; } @@ -226,7 +195,6 @@ public class WeaponBlocks{ titanturret = new Turret("titancannon"){ { shootsound = "blast"; - formalName = "titan cannon"; range = 120f; reload = 23f; bullet = BulletType.titanshell; @@ -236,8 +204,6 @@ public class WeaponBlocks{ width = height = 3; rotatespeed = 0.07f; shootCone = 9f; - fullDescription = "The ultimate long-range turret. Uses uranium as ammo. Shoots large splash-damage shells at a medium rate of fire. " - + "Long range. Spans multiple tiles. Extremely tough."; shootEffect = Fx.titanshot; shootShake = 3f; } diff --git a/core/src/io/anuke/mindustry/world/blocks/types/defense/CoreBlock.java b/core/src/io/anuke/mindustry/world/blocks/types/defense/CoreBlock.java new file mode 100644 index 0000000000..abf97f32d5 --- /dev/null +++ b/core/src/io/anuke/mindustry/world/blocks/types/defense/CoreBlock.java @@ -0,0 +1,34 @@ +package io.anuke.mindustry.world.blocks.types.defense; + +import io.anuke.mindustry.Vars; +import io.anuke.mindustry.resource.Item; +import io.anuke.mindustry.world.Block; +import io.anuke.mindustry.world.Tile; + +public class CoreBlock extends Block { + + public CoreBlock(String name) { + super(name); + + health = 800; + solid = true; + destructible = true; + width = 3; + height = 3; + } + + @Override + public int handleDamage(Tile tile, int amount){ + return Vars.debug ? 0 : amount; + } + + @Override + public void handleItem(Item item, Tile tile, Tile source){ + Vars.control.addItem(item, 1); + } + + @Override + public boolean acceptItem(Item item, Tile dest, Tile source){ + return true; + } +} diff --git a/core/src/io/anuke/mindustry/world/blocks/types/defense/PowerTurret.java b/core/src/io/anuke/mindustry/world/blocks/types/defense/PowerTurret.java index ce0987ca1a..eb6df6e021 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/defense/PowerTurret.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/defense/PowerTurret.java @@ -26,11 +26,6 @@ public class PowerTurret extends Turret implements PowerAcceptor{ ammo = null; } - @Override - public void postInit(){ - description = "[turretinfo]Uses power."; - } - @Override public void getStats(Array list){ super.getStats(list); diff --git a/core/src/io/anuke/mindustry/world/blocks/types/defense/RepairTurret.java b/core/src/io/anuke/mindustry/world/blocks/types/defense/RepairTurret.java index 81f3305f9e..b21691e49a 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/defense/RepairTurret.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/defense/RepairTurret.java @@ -32,11 +32,6 @@ public class RepairTurret extends PowerTurret{ list.add("[turretinfo]Repairs/Second: " + Strings.toFixed(60f/reload, 1)); } - @Override - public void postInit(){ - description = "[powerinfo]Uses power[white]\nRepairs nearby blocks."; - } - @Override public void update(Tile tile){ PowerTurretEntity entity = tile.entity(); diff --git a/core/src/io/anuke/mindustry/world/blocks/types/defense/Turret.java b/core/src/io/anuke/mindustry/world/blocks/types/defense/Turret.java index 471f216ddb..5b103d4d73 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/defense/Turret.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/defense/Turret.java @@ -71,12 +71,6 @@ public class Turret extends Block{ list.add("[turretinfo]Shots: " + shots); } - @Override - public void postInit(){ - if(ammo != null) - description = "[turretinfo]Ammo: " + ammo; - } - @Override public boolean canReplace(Block other){ return other instanceof Turret;