package projectzombie.text; import projectzombie.Main; import projectzombie.init.Textures; import projectzombie.util.gl.GlHelpers; import projectzombie.util.gl.texture.TextureReference; import projectzombie.util.math.vec.Vec2d; public class Text { public static final TextureReference CHAR_A = Textures.texmap.getTextureReference(5, 6, 0, 1); public static final TextureReference CHAR_B = Textures.texmap.getTextureReference(6, 7, 0, 1); public static final TextureReference CHAR_C = Textures.texmap.getTextureReference(7, 8, 0, 1); public static final TextureReference CHAR_D = Textures.texmap.getTextureReference(8, 9, 0, 1); public static final TextureReference CHAR_E = Textures.texmap.getTextureReference(9, 10, 0, 1); public static final TextureReference CHAR_F = Textures.texmap.getTextureReference(10, 11, 0, 1); public static final TextureReference CHAR_G = Textures.texmap.getTextureReference(11, 12, 0, 1); public static final TextureReference CHAR_H = Textures.texmap.getTextureReference(12, 13, 0, 1); public static final TextureReference CHAR_I = Textures.texmap.getTextureReference(13, 14, 0, 1); public static final TextureReference CHAR_J = Textures.texmap.getTextureReference(14, 15, 0, 1); public static final TextureReference CHAR_K = Textures.texmap.getTextureReference(15, 16, 0, 1); public static final TextureReference CHAR_L = Textures.texmap.getTextureReference(5, 6, 1, 2); public static final TextureReference CHAR_M = Textures.texmap.getTextureReference(6, 7, 1, 2); public static final TextureReference CHAR_N = Textures.texmap.getTextureReference(7, 8, 1, 2); public static final TextureReference CHAR_O = Textures.texmap.getTextureReference(8, 9, 1, 2); public static final TextureReference CHAR_P = Textures.texmap.getTextureReference(9, 10, 1, 2); public static final TextureReference CHAR_Q = Textures.texmap.getTextureReference(10, 11, 1, 2); public static final TextureReference CHAR_R = Textures.texmap.getTextureReference(11, 12, 1, 2); public static final TextureReference CHAR_S = Textures.texmap.getTextureReference(12, 13, 1, 2); public static final TextureReference CHAR_T = Textures.texmap.getTextureReference(13, 14, 1, 2); public static final TextureReference CHAR_U = Textures.texmap.getTextureReference(14, 15, 1, 2); public static final TextureReference CHAR_V = Textures.texmap.getTextureReference(15, 16, 1, 2); public static final TextureReference CHAR_W = Textures.texmap.getTextureReference(5, 6, 2, 3); public static final TextureReference CHAR_X = Textures.texmap.getTextureReference(6, 7, 2, 3); public static final TextureReference CHAR_Y = Textures.texmap.getTextureReference(7, 8, 2, 3); public static final TextureReference CHAR_Z = Textures.texmap.getTextureReference(8, 9, 2, 3); public static final TextureReference CHAR_a = Textures.texmap.getTextureReference(9, 10, 2, 3); public static final TextureReference CHAR_b = Textures.texmap.getTextureReference(10, 11, 2, 3); public static final TextureReference CHAR_c = Textures.texmap.getTextureReference(11, 12, 2, 3); public static final TextureReference CHAR_d = Textures.texmap.getTextureReference(12, 13, 2, 3); public static final TextureReference CHAR_e = Textures.texmap.getTextureReference(13, 14, 2, 3); public static final TextureReference CHAR_f = Textures.texmap.getTextureReference(14, 15, 2, 3); public static final TextureReference CHAR_g = Textures.texmap.getTextureReference(15, 16, 2, 3); public static final TextureReference CHAR_h = Textures.texmap.getTextureReference(5, 6, 3, 4); public static final TextureReference CHAR_i = Textures.texmap.getTextureReference(6, 7, 3, 4); public static final TextureReference CHAR_j = Textures.texmap.getTextureReference(7, 8, 3, 4); public static final TextureReference CHAR_k = Textures.texmap.getTextureReference(8, 9, 3, 4); public static final TextureReference CHAR_l = Textures.texmap.getTextureReference(9, 10, 3, 4); public static final TextureReference CHAR_m = Textures.texmap.getTextureReference(10, 11, 3, 4); public static final TextureReference CHAR_n = Textures.texmap.getTextureReference(11, 12, 3, 4); public static final TextureReference CHAR_o = Textures.texmap.getTextureReference(12, 13, 3, 4); public static final TextureReference CHAR_p = Textures.texmap.getTextureReference(13, 14, 3, 4); public static final TextureReference CHAR_q = Textures.texmap.getTextureReference(14, 15, 3, 4); public static final TextureReference CHAR_r = Textures.texmap.getTextureReference(15, 16, 3, 4); public static final TextureReference CHAR_s = Textures.texmap.getTextureReference(5, 6, 4, 5); public static final TextureReference CHAR_t = Textures.texmap.getTextureReference(6, 7, 4, 5); public static final TextureReference CHAR_u = Textures.texmap.getTextureReference(7, 8, 4, 5); public static final TextureReference CHAR_v = Textures.texmap.getTextureReference(8, 9, 4, 5); public static final TextureReference CHAR_w = Textures.texmap.getTextureReference(9, 10, 4, 5); public static final TextureReference CHAR_x = Textures.texmap.getTextureReference(10, 11, 4, 5); public static final TextureReference CHAR_y = Textures.texmap.getTextureReference(11, 12, 4, 5); public static final TextureReference CHAR_z = Textures.texmap.getTextureReference(12, 13, 4, 5); public static final TextureReference CHAR_0 = Textures.texmap.getTextureReference(13, 14, 4, 5); public static final TextureReference CHAR_1 = Textures.texmap.getTextureReference(14, 15, 4, 5); public static final TextureReference CHAR_2 = Textures.texmap.getTextureReference(15, 16, 4, 5); public static final TextureReference CHAR_3 = Textures.texmap.getTextureReference(5, 6, 5, 6); public static final TextureReference CHAR_4 = Textures.texmap.getTextureReference(6, 7, 5, 6); public static final TextureReference CHAR_5 = Textures.texmap.getTextureReference(7, 8, 5, 6); public static final TextureReference CHAR_6 = Textures.texmap.getTextureReference(8, 9, 5, 6); public static final TextureReference CHAR_7 = Textures.texmap.getTextureReference(9, 10, 5, 6); public static final TextureReference CHAR_8 = Textures.texmap.getTextureReference(10, 11, 5, 6); public static final TextureReference CHAR_9 = Textures.texmap.getTextureReference(11, 12, 5, 6); public static final TextureReference CHAR_PEROID = Textures.texmap.getTextureReference(12, 13, 5, 6); public static final TextureReference CHAR_COLON = Textures.texmap.getTextureReference(13, 14, 5, 6); public static final TextureReference CHAR_COMMA = Textures.texmap.getTextureReference(14, 15, 5, 6); public static final TextureReference CHAR_EXMARK = Textures.texmap.getTextureReference(15, 16, 5, 6); public static final TextureReference CHAR_MINUS = Textures.texmap.getTextureReference(0, 1, 10, 11); public static final TextureReference CHAR_PLUS = Textures.texmap.getTextureReference(1, 2, 10, 11); public static final TextureReference CHAR_FSLASH = Textures.texmap.getTextureReference(2, 3, 10, 11); public static final TextureReference CHAR_BSLASH = Textures.texmap.getTextureReference(3, 4, 10, 11); public static final TextureReference CHAR_EQUALS = Textures.texmap.getTextureReference(4, 5, 10, 11); public static final TextureReference CHAR_USCORE = Textures.texmap.getTextureReference(5, 6, 10, 11); public static final TextureReference CHAR_NULL = Textures.texmap.getTextureReference(6, 7, 10, 11); public static final TextureReference CHAR_BRACKET_O = Textures.texmap.getTextureReference(7, 8, 10, 11); public static final TextureReference CHAR_BRACKET_C = Textures.texmap.getTextureReference(8, 9, 10, 11); public static final TextureReference CHAR_PERCENT = Textures.texmap.getTextureReference(9, 10, 10, 11); public static final TextureReference CHAR_VBAR = Textures.texmap.getTextureReference(10, 11, 10, 11); public static final TextureReference CHAR_QMARK = Textures.texmap.getTextureReference(11, 12, 10, 11); public static final TextureReference CHAR_DOLLAR = Textures.texmap.getTextureReference(12, 13, 10, 11); public static final TextureReference CHAR_HASHTAG = Textures.texmap.getTextureReference(13, 14, 10, 11); public static final TextureReference CHAR_L_THEN = Textures.texmap.getTextureReference(14, 15, 10, 11); public static final TextureReference CHAR_G_THEN = Textures.texmap.getTextureReference(15, 16, 10, 11); public static void renderCenter(String text, Vec2d size) { int w = Main.window.getWidth(); int h = Main.window.getHeight(); double aspect_ratio = ((double)w) / ((double)h); GlHelpers.translate2(0 - (text.length() * size.x / 2 / aspect_ratio), 0); Text.render(text, size); } public static void render(String text, Vec2d size) { // Get the bytes from the string byte[] text_b = text.getBytes(); double sx = size.x; double sy = size.y; // Begin quads GlHelpers.begin(); // Loop over the bytes for(int i=0;i'): l = CHAR_G_THEN; break; case('<'): l = CHAR_L_THEN; break; } // Is the letter not null if(l != null) { // Render the character l.texCoord(0, 1); GlHelpers.vertex2(sy*i, 0 ); l.texCoord(0, 0); GlHelpers.vertex2(sy*i, sx); l.texCoord(1, 0); GlHelpers.vertex2(sy*(i+1), sx); l.texCoord(1, 1); GlHelpers.vertex2(sy*(i+1), 0 ); } } // Stop drawing quads GlHelpers.end(); } }