#define FLAG_FLIP_ROTATING 0x400
#define FLAG_TARGETED 0x800
+#define FLAG_INPUT_NICE 0x1000
+
/*
0000 0 | 0001 1 | 0010 2 | 0011 3
| | | | |
float lvl_load_time;
float world_transition;
+ ui_ctx world_text;
}
st;
if( cell->state & FLAG_WALL )
height = 0xFF-0x3F + hash21i( (v2i){x,y}, 0x3F );
- config = 0xF;
+ config = cell->state & FLAG_INPUT_NICE? 0xB: 0xF;
}
pcell((v2i){x,y})->config = config;
{
text_buffers.title_count = gen_text_buffer( pLevel->title, &font_Ubuntu, (v2f){ -5.0f, -0.6f }, 0.6f, text_buffers.title_start );
text_buffers.desc_count = gen_text_buffer( pLevel->description, &font_Ubuntu, (v2f){ -5.0, -0.9f }, 0.25f, text_buffers.desc_start );
+
+ // Old style UI.
+ ui_px const unit_scale_px = 4*UI_GLYPH_SPACING_X; // 4 char per unit
+ ui_begin( &world.st.world_text, world.w*unit_scale_px, world.h*unit_scale_px );
+
+ for( int i = 0; i < vg_list_size( pLevel->strings ); i ++ )
+ {
+ struct world_string *wstr = &pLevel->strings[i];
+
+ if( wstr->str )
+ {
+ ui_px pos[2];
+
+ pos[0] = -UI_GLYPH_SPACING_X/2;
+
+ if( wstr->placement == k_placement_bottom )
+ pos[1] = 2*-unit_scale_px;
+ else
+ pos[1] = (world.h-1)*-unit_scale_px -6;
+
+ ui_text( &world.st.world_text, pos, wstr->str, 1, k_text_align_left );
+ }
+ }
+
+ ui_resolve( &world.st.world_text );
}
static int map_load( const char *str, const char *name )
reg_end ++;
}
+ else if( *c == '.' ) cell->state = FLAG_INPUT_NICE;
else if( *c == '#' ) cell->state = FLAG_WALL;
else if( ((u32)*c >= (u32)'A') && ((u32)*c <= (u32)'A'+0xf) )
{
struct cell *cell = pcell( (v2i){ x, y } );
if( cell->state & FLAG_WALL ) fputc( '#', stream );
+ else if( cell->state & FLAG_INPUT_NICE ) fputc( '.', stream );
else if( cell->state & FLAG_INPUT ) fputc( '+', stream );
else if( cell->state & FLAG_OUTPUT ) fputc( '-', stream );
else if( cell->state & FLAG_EMITTER ) fputc( '*', stream );
static void render_tile( v2i pos, struct cell *ptr, v4f const regular_colour, v4f const selected_colour )
{
int selected = world.selected == pos[1]*world.w + pos[0];
-
- int tile_offsets[][2] =
- {
- {2, 0}, {0, 3}, {0, 2}, {2, 2},
- {1, 0}, {2, 3}, {3, 2}, {1, 3},
- {3, 1}, {0, 1}, {1, 2}, {2, 1},
- {1, 1}, {3, 3}, {2, 1}, {2, 1}
- };
-
int uv[2];
- uv[0] = tile_offsets[ ptr->config ][0];
- uv[1] = tile_offsets[ ptr->config ][1];
+ uv[0] = ptr->config & 0x3;
+ uv[1] = ptr->config >> 2;
glUniform4f( SHADER_UNIFORM( shader_tile_main, "uOffset" ),
(float)pos[0],
{
struct cell *cell = pcell((v2i){x,y});
- if( cell->state & (FLAG_CANAL|FLAG_INPUT|FLAG_OUTPUT|FLAG_EMITTER) )
+ if( cell->state & (FLAG_CANAL|FLAG_INPUT|FLAG_OUTPUT|FLAG_EMITTER|FLAG_INPUT_NICE) )
{
struct render_cmd *cmd;
- if( cell->config == k_cell_type_split || (cell->state & FLAG_EMITTER || cell->state & FLAG_IS_TRIGGER) )
+ if(
+ (cell->config == k_cell_type_split && (cell->state & FLAG_CANAL))
+ || (cell->state & (FLAG_EMITTER|FLAG_IS_TRIGGER))
+ )
cmd = &world.cmd_buf_tiles[ world.max_commands - (++ world.tile_special_count) ];
else
cmd = &world.cmd_buf_tiles[ world.tile_count ++ ];
glUniform4f( SHADER_UNIFORM( shader_tile_main, "uOffset" ),
(float)cmd->pos[0],
(float)cmd->pos[1] + 0.125f,
- cell->state & FLAG_TARGETED? 3.0f: 0.0f,
- 0.0f
+ cell->state & FLAG_TARGETED? 3.0f: 2.0f,
+ 3.0f
);
draw_mesh( 0, 2 );
}
glUniform4f( SHADER_UNIFORM( shader_sdf, "uColour" ), 1.0f, 1.0f, 1.0f, 0.17f );
glDrawElements( GL_TRIANGLES, text_buffers.grid_count*6, GL_UNSIGNED_SHORT, (void*)( text_buffers.grid_start*6*sizeof(u16) ) );
+ // Old style
+ m3x3f mvp_text;
+ m3x3_identity( mvp_text );
+ m3x3_scale( mvp_text, (v3f){
+ 1.0f/ ((float)UI_GLYPH_SPACING_X*4.0f),
+ 1.0f/ -((float)UI_GLYPH_SPACING_X*4.0f),
+ 1.0f
+ });
+
+ m3x3_mul( vg_pv, mvp_text, mvp_text );
+ ui_draw( &world.st.world_text, mvp_text );
+
// WIRES
// ========================================================================================================
- //glDisable(GL_BLEND);
+ glEnable(GL_BLEND);
SHADER_USE( shader_wire );
glBindVertexArray( world.wire.vao );
resource_load_main();
+ // Init world text
+ {
+ ui_init_context( &world.st.world_text, 15000 );
+ }
+
// Create text buffers
{
// Work out the counts for each 'segment'
free_mesh( &world.shapes );
+ ui_context_free( &world.st.world_text );
+
map_free();
}