Explorar el Código

font: support \b (backspace) in text rendering.

undefined
Sam Hocevar hace 11 años
padre
commit
843cc42ed1
Se han modificado 1 ficheros con 17 adiciones y 9 borrados
  1. +17
    -9
      src/font.cpp

+ 17
- 9
src/font.cpp Ver fichero

@@ -2,6 +2,7 @@
// Lol Engine
//
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
// 2013 Jean-Yves Lamoureux <jylam@lnxscene.org>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
@@ -69,22 +70,29 @@ char const *Font::GetName()

void Font::Print(vec3 pos, char const *str, vec2 scale)
{
int origin_x = pos.x;
float origin_x = pos.x;
while (*str)
{
uint32_t ch = (uint8_t)*str++;

if (ch == '\n')
switch (ch)
{
case '\r': /* carriage return */
pos.x = origin_x;
pos.y-=data->size.y * scale.y;
continue;
}
else if (ch != ' ')
{
g_scene->AddTile(data->tileset, ch & 255, pos, 0, scale);
break;
case '\b': /* backspace */
pos.x -= data->size.x * scale.x;
break;
case '\n': /* new line */
pos.x = origin_x;
pos.y -= data->size.y * scale.y;
break;
default:
if (ch != ' ')
g_scene->AddTile(data->tileset, ch & 255, pos, 0, scale);
pos.x += data->size.x * scale.x;
break;
}
pos.x += data->size.x * scale.x;
}
}



Cargando…
Cancelar
Guardar