Merge branch 'unicode'

This commit is contained in:
jacob1 2018-05-06 20:15:23 -04:00
commit 56cba4595c
199 changed files with 4475 additions and 2646 deletions

View File

@ -67,6 +67,7 @@ AddSconsOption('static', False, False, "Compile statically.")
AddSconsOption('opengl', False, False, "Build with OpenGL interface support.")
AddSconsOption('opengl-renderer', False, False, "Build with OpenGL renderer support (turns on --opengl).") #Note: this has nothing to do with --renderer, only tells the game to render particles with opengl
AddSconsOption('renderer', False, False, "Build the save renderer.")
AddSconsOption('font', False, False, "Build the font editor.")
AddSconsOption('wall', False, False, "Error on all warnings.")
AddSconsOption('no-warnings', False, False, "Disable all compiler warnings.")
@ -266,7 +267,7 @@ def findLibs(env, conf):
else:
FatalError("SDL.h not found")
if not GetOption('nolua') and not GetOption('renderer'):
if not GetOption('nolua') and not GetOption('renderer') and not GetOption('font'):
#Look for Lua
if platform == "FreeBSD":
luaver = "lua-5.1"
@ -494,7 +495,7 @@ if GetOption('static'):
#Add other flags and defines
if not GetOption('nofft'):
env.Append(CPPDEFINES=['GRAVFFT'])
if not GetOption('nolua') and not GetOption('renderer'):
if not GetOption('nolua') and not GetOption('renderer') and not GetOption('font'):
env.Append(CPPDEFINES=['LUACONSOLE'])
if GetOption('opengl') or GetOption('opengl-renderer'):
@ -507,6 +508,9 @@ if GetOption('renderer'):
else:
env.Append(CPPDEFINES=['USE_SDL'])
if GetOption('font'):
env.Append(CPPDEFINES=['FONTEDITOR'])
if GetOption("wall"):
if msvc:
env.Append(CCFLAGS=['/WX'])
@ -540,7 +544,7 @@ if GetOption('beta'):
#Generate list of sources to compile
sources = Glob("src/*.cpp") + Glob("src/*/*.cpp") + Glob("src/*/*/*.cpp") + Glob("generated/*.cpp")
if not GetOption('nolua') and not GetOption('renderer'):
if not GetOption('nolua') and not GetOption('renderer') and not GetOption('font'):
sources += Glob("src/lua/socket/*.c") + Glob("src/lua/LuaCompat.c")
if platform == "Windows":
@ -559,7 +563,11 @@ elif platform == "Darwin":
if GetOption('output'):
programName = GetOption('output')
else:
programName = GetOption('renderer') and "render" or "powder"
programName = "powder"
if GetOption('renderer'):
programName = "render"
if GetOption('font'):
programName = "font"
if "BIT" in env and env["BIT"] == 64:
programName += "64"
if isX86 and GetOption('no-sse'):

View File

@ -1,303 +1,320 @@
#ifndef FONT_H_CHECK
#define FONT_H_CHECK
#define FONT_H 10
#define FONT_H 12
#ifndef FONTEDITOR
#ifdef INCLUDE_FONTDATA
unsigned char font_data[] = {
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0xC7, 0x31, 0x0C, 0x02, 0x70, 0x04, 0x00, 0x00,
0x05, 0xCC, 0x74, 0x23, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x80, 0x19, 0xCC, 0xE0, 0x3F, 0xCC, 0xF0, 0x2F, 0xCC, 0x90, 0x09, 0x00, 0x00, 0x00,
0x06, 0x30, 0xD0, 0x3F, 0x33, 0xE1, 0x07, 0xF4, 0x12, 0x33, 0xFF, 0x00, 0x03, 0x00, 0x00, 0x00,
0x07, 0x2D, 0xCE, 0xCC, 0xE1, 0x1D, 0xC0, 0x03, 0x74, 0x4B, 0x33, 0xB3, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x7D, 0x30, 0x0C, 0x13, 0xD0, 0x32, 0xB3, 0x33, 0x1C, 0x7D, 0x07, 0x00, 0x00, 0x00, 0x00,
0x03, 0x4C, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x34, 0x1D, 0x07, 0x03, 0x07, 0x1D, 0x34, 0x00, 0x00, 0x00,
0x04, 0x07, 0x1D, 0x34, 0x30, 0x34, 0x1D, 0x07, 0x00, 0x00, 0x00,
0x06, 0x44, 0xD0, 0x1C, 0x64, 0xF0, 0x3F, 0x64, 0xD0, 0x1C, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x02, 0x30, 0xE0, 0x2F, 0x30, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0D, 0x03, 0x00,
0x05, 0x00, 0x00, 0x00, 0xC0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x40, 0x70, 0x00, 0x00, 0x00,
0x06, 0x80, 0x02, 0x0C, 0xA0, 0x00, 0x03, 0x28, 0xC0, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0xF8, 0xE0, 0x39, 0x07, 0x33, 0x32, 0x03, 0xB3, 0x38, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x30, 0xF0, 0x60, 0x03, 0x0C, 0x30, 0xC0, 0x40, 0x07, 0x00, 0x00, 0x00, 0x00,
0x06, 0xFC, 0xB1, 0x34, 0x41, 0x03, 0x0A, 0x2C, 0x70, 0x00, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00,
0x06, 0xFC, 0x71, 0x34, 0x01, 0x03, 0x1E, 0x00, 0x33, 0x34, 0xFE, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0xC0, 0x03, 0x37, 0x1C, 0x73, 0x34, 0xBF, 0x03, 0x30, 0x40, 0x03, 0x00, 0x00, 0x00, 0x00,
0x06, 0xFF, 0x33, 0x00, 0x57, 0xE0, 0x2F, 0x00, 0x13, 0x30, 0xFE, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0xF4, 0xD3, 0x00, 0x07, 0xF0, 0x1F, 0x03, 0x33, 0x34, 0xFD, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0xFF, 0x07, 0x34, 0x80, 0x03, 0x0E, 0x38, 0xD0, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0xFC, 0xB1, 0x34, 0x03, 0xD3, 0x1F, 0x03, 0x73, 0x34, 0xFD, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0xFC, 0xB1, 0x34, 0x03, 0xC3, 0x3F, 0x40, 0x23, 0x30, 0xFD, 0x01, 0x00, 0x00, 0x00, 0x00,
0x03, 0x00, 0x70, 0x04, 0x40, 0x70, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x1C, 0x04, 0x00, 0x0C, 0x0D, 0x03, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0xC0, 0xC3, 0x0B, 0x1B, 0xC0, 0x0B, 0xC0, 0x03, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x0F, 0x80, 0x0F, 0x90, 0x83, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0xFD, 0x71, 0x30, 0x81, 0x03, 0x0E, 0x34, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0xF8, 0x0F, 0x1D, 0x30, 0xE7, 0x37, 0x73, 0x1C, 0xE3, 0x2F, 0x07, 0x00, 0xFD, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x74, 0xD0, 0x1D, 0x47, 0x33, 0x30, 0xFF, 0x33, 0x30, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00,
0x06, 0xBF, 0x30, 0x38, 0x43, 0xF3, 0x1F, 0x43, 0x33, 0x34, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0xF4, 0xD1, 0x34, 0x03, 0x31, 0x00, 0x03, 0x70, 0x34, 0xFD, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0x7F, 0x30, 0x1D, 0x43, 0x33, 0x30, 0x03, 0x33, 0x34, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0xFF, 0x32, 0x00, 0x03, 0xF0, 0x0B, 0x03, 0x30, 0x10, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00,
0x06, 0xFF, 0x33, 0x10, 0x03, 0xF0, 0x0B, 0x03, 0x30, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0xF4, 0xD1, 0x34, 0x03, 0x30, 0x3E, 0x03, 0x73, 0x34, 0xFD, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0x47, 0x33, 0x30, 0x03, 0xF3, 0x3F, 0x03, 0x33, 0x30, 0x47, 0x03, 0x00, 0x00, 0x00, 0x00,
0x04, 0x1D, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1D, 0x00, 0x00, 0x00,
0x06, 0xD0, 0x01, 0x0C, 0xC0, 0x00, 0x0C, 0xC0, 0x10, 0x0D, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x47, 0xC3, 0x34, 0x70, 0x03, 0xBC, 0x00, 0xB3, 0xC0, 0xB0, 0x70, 0xB4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x07, 0x30, 0x00, 0x03, 0x30, 0x00, 0x03, 0x30, 0x10, 0xFF, 0x02, 0x00, 0x00, 0x00, 0x00,
0x08, 0x03, 0x30, 0x1F, 0x3D, 0x7B, 0x3B, 0xE3, 0x32, 0x83, 0x30, 0x03, 0x30, 0x03, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x07, 0xCD, 0x03, 0x73, 0xC3, 0x8C, 0x32, 0xC3, 0xCD, 0xC0, 0x33, 0xD0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0xF4, 0x41, 0xC7, 0x71, 0xD0, 0x0C, 0x30, 0x03, 0xCD, 0xD1, 0xD1, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x7F, 0x30, 0x1D, 0x43, 0x73, 0x34, 0xFF, 0x31, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0xF4, 0x41, 0xD3, 0x71, 0xD0, 0x0C, 0x30, 0xC3, 0xCD, 0xD1, 0xD1, 0xDF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0xFF, 0x31, 0x34, 0x03, 0xF3, 0x0F, 0xD7, 0x30, 0x34, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00,
0x06, 0xFC, 0xB1, 0x31, 0x07, 0xD0, 0x0F, 0x90, 0x23, 0x34, 0xFE, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0xFF, 0x13, 0x13, 0x30, 0x00, 0x03, 0x30, 0x00, 0x03, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x03, 0xCC, 0x00, 0x33, 0xC0, 0x0C, 0x30, 0x03, 0xCD, 0xD2, 0xD1, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x03, 0x33, 0x30, 0x03, 0xB3, 0x38, 0xCD, 0xC1, 0x0D, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x03, 0x30, 0x43, 0x30, 0xC7, 0x34, 0xCD, 0x1C, 0xED, 0x1E, 0x2C, 0x0E, 0x0C, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x03, 0x4C, 0xC3, 0x81, 0x3B, 0xD0, 0x03, 0xDC, 0x42, 0xC3, 0x31, 0xC0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x03, 0xB3, 0x38, 0xDC, 0x40, 0x07, 0x30, 0x00, 0x03, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0xFF, 0x0F, 0xD0, 0x02, 0x2C, 0xC0, 0x02, 0x2D, 0xC0, 0x06, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x2F, 0x03, 0x03, 0x03, 0x03, 0x03, 0x2F, 0x00, 0x00, 0x00,
0x05, 0x03, 0x28, 0xC0, 0x00, 0x0A, 0x30, 0x80, 0x02, 0x0C, 0x00, 0x00, 0x00, 0x00,
0x04, 0x3E, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3E, 0x00, 0x00, 0x00,
0x04, 0x1D, 0x37, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00,
0x03, 0x83, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xD0, 0x47, 0x30, 0xFC, 0x0C, 0xD3, 0x1F, 0x00, 0x00, 0x00, 0x00,
0x05, 0x07, 0x0C, 0xF0, 0xC7, 0x35, 0xC3, 0x0C, 0xF3, 0x07, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xD0, 0xC3, 0x25, 0x03, 0x4C, 0xD2, 0x03, 0x00, 0x00, 0x00, 0x00,
0x05, 0xD0, 0x00, 0x83, 0x8F, 0x33, 0xC3, 0x1C, 0xD3, 0x1F, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xD0, 0xC7, 0x30, 0xBF, 0x0C, 0xD0, 0x0B, 0x00, 0x00, 0x00, 0x00,
0x04, 0x3D, 0x07, 0x03, 0x2F, 0x03, 0x03, 0x07, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xC0, 0xCB, 0x32, 0xC3, 0xF4, 0x03, 0x4C, 0x30, 0x7E, 0x00, 0x00,
0x05, 0x03, 0x0C, 0xF0, 0xC7, 0x39, 0xC3, 0x0C, 0x73, 0x1C, 0x00, 0x00, 0x00, 0x00,
0x04, 0x04, 0x1C, 0x00, 0x0D, 0x0C, 0x0C, 0x1D, 0x00, 0x00, 0x00,
0x04, 0x00, 0x30, 0x00, 0x34, 0x30, 0x30, 0x30, 0x30, 0x1E, 0x00,
0x05, 0x03, 0x0C, 0x31, 0xCE, 0x0E, 0x1F, 0xCC, 0x31, 0x1C, 0x00, 0x00, 0x00, 0x00,
0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x47, 0x3D, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x9B, 0x71, 0x37, 0x33, 0x33, 0x32, 0x43, 0x03, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xF0, 0xC7, 0x31, 0xC3, 0x0C, 0x33, 0x0D, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xD0, 0xC7, 0x31, 0xC3, 0x4C, 0xD3, 0x07, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xF0, 0xC7, 0x31, 0xC3, 0x4C, 0xF3, 0xC7, 0x00, 0x03, 0x00, 0x00,
0x05, 0x00, 0x00, 0xD0, 0xDF, 0x31, 0xC3, 0x4C, 0xD3, 0x0F, 0x30, 0xC0, 0x00, 0x05,
0x04, 0x00, 0x00, 0x33, 0x1F, 0x07, 0x03, 0x03, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xC0, 0xC7, 0x10, 0x3C, 0x04, 0xF3, 0x03, 0x00, 0x00, 0x00, 0x00,
0x04, 0x0C, 0x0C, 0x3F, 0x0C, 0x0C, 0x1C, 0x74, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x70, 0xDC, 0x30, 0xC3, 0x4C, 0xD3, 0x1F, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x30, 0xCC, 0x30, 0xD3, 0xDC, 0xC2, 0x02, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x47, 0x33, 0x32, 0x33, 0x73, 0x37, 0xCD, 0x01, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x30, 0xCD, 0x32, 0x7D, 0x8C, 0x73, 0x0C, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x30, 0xCC, 0x30, 0xC7, 0x74, 0x43, 0x07, 0x0C, 0x1F, 0x00, 0x00,
0x05, 0x00, 0x00, 0xF0, 0x4F, 0x2C, 0x2C, 0x2C, 0xF1, 0x0F, 0x00, 0x00, 0x00, 0x00,
0x04, 0x38, 0x0C, 0x0C, 0x03, 0x0C, 0x0C, 0x38, 0x00, 0x00, 0x00,
0x02, 0x32, 0x33, 0x33, 0x13, 0x00,
0x04, 0x0B, 0x0C, 0x0C, 0x30, 0x0C, 0x0C, 0x0B, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x1D, 0x72, 0x37, 0xD2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x07, 0x00, 0x1F, 0x00, 0x7F, 0x00, 0xFF, 0x01, 0xFF, 0x07, 0xFF, 0x1F, 0xFF, 0x7F, 0xFF, 0x1B, 0xBF, 0x01, 0x1B, 0x00,
0x0C, 0x00, 0x40, 0xFF, 0x00, 0x00, 0xF8, 0xF0, 0x3F, 0xEE, 0x2C, 0x30, 0xCB, 0x0B, 0x30, 0x42, 0xC3, 0x33, 0x00, 0x03, 0x30, 0x00, 0xF3, 0x33, 0x00, 0x03, 0x30, 0x00, 0xFF, 0x3F, 0x00,
0x0C, 0xC2, 0x00, 0x00, 0xCB, 0x00, 0x00, 0xEE, 0xC0, 0xFF, 0xF8, 0xB0, 0xC0, 0xFF, 0x2C, 0xC0, 0x00, 0x0C, 0xCF, 0x00, 0x0C, 0xC0, 0x00, 0xCC, 0xCF, 0x00, 0x0C, 0xC0, 0x00, 0xFC, 0xFF,
0x0A, 0x00, 0x00, 0x0D, 0x00, 0x70, 0x00, 0x00, 0xF3, 0xFF, 0xD3, 0x03, 0xE0, 0x3C, 0x3F, 0x38, 0x03, 0xD0, 0x33, 0xFF, 0x38, 0x03, 0xE0, 0xF0, 0xFF, 0x03,
0x0C, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x8B, 0xF7, 0x0C, 0x13, 0x9F, 0x3B, 0x37, 0x00, 0xC0, 0x23, 0xFF, 0xFF, 0x8B, 0x03, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0xD0, 0x7F, 0x80, 0x03, 0x2C, 0x0D, 0x00, 0x37, 0x00, 0xC0, 0xF3, 0xFF, 0x3C, 0xFF, 0xCF, 0x03, 0x00, 0xDC, 0x00, 0x70, 0x38, 0xC0, 0x02, 0xFD, 0x07,
0x0A, 0x00, 0x00, 0x00, 0xFC, 0x03, 0xF0, 0xFF, 0xC0, 0xFF, 0x3F, 0xFC, 0xFF, 0xC3, 0xFF, 0x3F, 0xFC, 0xFF, 0x03, 0xFF, 0x0F, 0xC0, 0x3F, 0x00, 0x00, 0x00,
0x0A, 0xFF, 0xFF, 0x3F, 0x00, 0xC0, 0x03, 0x00, 0x3C, 0xF0, 0xC0, 0xC3, 0x3A, 0x3C, 0x0B, 0xCE, 0x2B, 0x80, 0x7E, 0x00, 0xD0, 0x03, 0x00, 0xFC, 0xFF, 0xFF,
0x0A, 0x00, 0x00, 0xC0, 0xFF, 0x3F, 0xFC, 0xFF, 0xC3, 0xFF, 0x3F, 0xFC, 0xFF, 0xC3, 0xFF, 0x3F, 0xFC, 0xFF, 0xC3, 0xFF, 0x3F, 0xFC, 0xFF, 0x03, 0x00, 0x00,
0x0A, 0xD0, 0x7F, 0x80, 0x03, 0x2C, 0x0D, 0x0F, 0x37, 0xF0, 0xC0, 0xF3, 0xFF, 0x3C, 0xFF, 0xCF, 0x03, 0x0F, 0xDC, 0xF0, 0x70, 0x38, 0xC0, 0x02, 0xFD, 0x07,
0x0A, 0x40, 0x1F, 0x00, 0xAD, 0x07, 0xB0, 0xC5, 0x00, 0x17, 0x0C, 0x70, 0xD0, 0x00, 0x0C, 0x03, 0xBC, 0xEF, 0xB3, 0x11, 0xE0, 0x07, 0x05, 0x3C, 0x52, 0xC8,
0x0A, 0x00, 0x00, 0x00, 0xF0, 0x00, 0xC0, 0x3F, 0x00, 0xFC, 0x03, 0xC0, 0x3F, 0x00, 0xF0, 0x00, 0xC0, 0x30, 0xC0, 0xFF, 0x3F, 0xFC, 0xFF, 0xC3, 0xFF, 0x3F,
0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0xFC, 0xFF, 0x0F, 0xFC, 0xFF, 0x3F, 0xFC, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0xB8, 0xE0, 0x2F, 0xFF, 0xE3, 0x2F, 0xB8, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0xD0, 0x7F, 0x80, 0xFF, 0x2F, 0xFD, 0xFF, 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF, 0xFF, 0x7F, 0xF8, 0xFF, 0x02, 0xFD, 0x07,
0x0A, 0x40, 0x01, 0x00, 0x02, 0x00, 0xC8, 0x07, 0x10, 0xC3, 0x00, 0x31, 0x0D, 0x00, 0xFD, 0x01, 0x00, 0x74, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0xF0, 0xF0, 0x00, 0x0F, 0x0F, 0xF0, 0xF0, 0x00, 0x0F, 0x0F, 0xF0, 0xF0, 0x00, 0x0F, 0x0F, 0xF0, 0xF0, 0x00, 0x00, 0x00,
0x0A, 0x40, 0x05, 0x80, 0xFF, 0x8B, 0x1E, 0xD0, 0x2E, 0x00, 0xF0, 0x00, 0xE0, 0xFF, 0x0B, 0x00, 0x0F, 0x00, 0xB8, 0x03, 0xB0, 0xE2, 0xFF, 0x02, 0x50, 0x01,
0x08, 0xFF, 0x07, 0x03, 0x1E, 0x03, 0x73, 0x03, 0xEF, 0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, 0xFF, 0xFF,
0x0B, 0x00, 0x00, 0x00, 0xE4, 0x2F, 0xE0, 0x1B, 0x0C, 0x1D, 0x00, 0xFF, 0x03, 0xBE, 0xF0, 0xC1, 0x01, 0xAD, 0x34, 0xC0, 0x36, 0x0B, 0x30, 0xDC, 0xE4, 0x07, 0xFD, 0x1B, 0x00,
0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA8, 0x02, 0xA0, 0xAA, 0x00, 0xA8, 0xC2, 0x0F, 0x2A, 0xFF, 0x03, 0xCA, 0x3F, 0x80, 0xFC, 0x0F, 0x20, 0x0F, 0x00, 0x00, 0x00, 0x00,
0x0C, 0x00, 0xC0, 0x01, 0x00, 0xC0, 0x07, 0xAA, 0xEA, 0x1F, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xAA, 0xEA, 0x1F, 0x00, 0xC0, 0x07, 0x00, 0xC0, 0x01, 0x00, 0x00, 0x00,
0x0C, 0x40, 0x03, 0x00, 0xD0, 0x03, 0x00, 0xF4, 0xAB, 0xAA, 0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, 0xFF, 0xFF, 0xF4, 0xAB, 0xAA, 0xD0, 0x03, 0x00, 0x40, 0x03, 0x00, 0x00, 0x00, 0x00,
0x09, 0xFE, 0xFF, 0xE3, 0xFF, 0x0F, 0xAA, 0x3E, 0x0A, 0xF8, 0x2E, 0xE0, 0xBF, 0x80, 0xFF, 0xAA, 0xFE, 0xFF, 0xE2, 0xFF, 0x02, 0x02, 0x00, 0x00,
0x09, 0x00, 0x80, 0x04, 0xD0, 0xE2, 0xFF, 0x02, 0x00, 0x00, 0xFF, 0x6F, 0x00, 0x40, 0xE6, 0xAF, 0x50, 0x00, 0x09, 0x00, 0x20, 0x00, 0x64, 0x00,
0x09, 0xE0, 0x3F, 0x70, 0x60, 0x63, 0xC0, 0xE4, 0x80, 0xC2, 0x03, 0x07, 0x0F, 0x1E, 0x6C, 0xFF, 0x27, 0xFF, 0x3F, 0xE0, 0x2F, 0x00, 0x00, 0x00,
0x09, 0x44, 0x44, 0x00, 0x12, 0x41, 0x88, 0x04, 0x21, 0x21, 0x84, 0x48, 0x20, 0x23, 0xC2, 0xCC, 0x08, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
0x09, 0x00, 0x1D, 0x00, 0x1D, 0x00, 0x78, 0x00, 0xB4, 0x07, 0xF0, 0x2F, 0xC0, 0xFB, 0x00, 0xBE, 0x02, 0xF4, 0x07, 0xFD, 0xFF, 0x01, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x01, 0x00, 0x19, 0x00, 0xA8, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0xFC, 0xFF, 0x3F, 0x00, 0xF0, 0xDC, 0xCB, 0x03, 0x00, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0xFC, 0xFF, 0x3F, 0x00, 0xF0, 0xDC, 0xCB, 0x03, 0x00, 0xFF, 0xFF, 0x0F, 0x30, 0x00, 0xC0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0xFC, 0xFF, 0x3F, 0x00, 0xF0, 0xDC, 0xCB, 0x03, 0x00, 0xFF, 0xFF, 0x0F, 0x40, 0x07, 0x00, 0x74, 0x00, 0x40, 0x03, 0x00, 0x00,
0x09, 0x00, 0x00, 0xFC, 0xFF, 0x3F, 0x00, 0xF0, 0xDC, 0xCB, 0x03, 0x00, 0xFF, 0xFF, 0x4F, 0x07, 0x40, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0x0F, 0xFF, 0x3F, 0xFC, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0xFF, 0xFF, 0x3F, 0x00, 0xC0, 0x07, 0x00, 0xBD, 0x02, 0xE8, 0xB3, 0xE0, 0x3C, 0xAC, 0xC3, 0x03, 0x0F, 0x3C, 0x00, 0xC0, 0x03, 0x00, 0xFC, 0xFF, 0xFF,
0x0B, 0xC0, 0xC8, 0xC0, 0x91, 0x1B, 0xCD, 0x36, 0xE7, 0x00, 0x47, 0x03, 0xA7, 0x80, 0x36, 0xFD, 0xFF, 0xC1, 0x9B, 0xF9, 0xB8, 0xB8, 0xB8, 0xB7, 0x99, 0xF7, 0xFF, 0xFF, 0x0F,
0x0B, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0xF0, 0x03, 0x00, 0xFC, 0x00, 0xC0, 0xFF, 0x00, 0xF0, 0x3F, 0x00, 0xFF, 0x3F, 0xF0, 0xFF, 0x3F, 0xFC, 0xFF, 0xCF, 0xFF, 0xFF, 0x0F,
0x08, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x1F, 0xCB, 0x30, 0xC3, 0x3F, 0xC7, 0x00, 0x7E, 0x2F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0xFC, 0xFF, 0xC3, 0xFF, 0x3F, 0x0C, 0x00, 0xC3, 0xFC, 0x33, 0x0C, 0x24, 0xC3, 0xC0, 0x31, 0x0C, 0x06, 0xC3, 0x30, 0x30, 0x0C, 0x00, 0xC3, 0xFF, 0x3F,
0x0A, 0xFF, 0x3F, 0x30, 0x00, 0x03, 0xC3, 0x30, 0x30, 0x3F, 0xFF, 0xFF, 0x3F, 0x3C, 0x00, 0xFF, 0xFF, 0xFF, 0x0C, 0x0C, 0xC3, 0xC0, 0x00, 0x0C, 0xFC, 0xFF,
0x0A, 0x00, 0x00, 0xC0, 0xFF, 0x00, 0xFC, 0x0F, 0xC0, 0xFF, 0x00, 0xFC, 0x0F, 0xC0, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x03, 0x00, 0x3C, 0x00, 0xC0, 0x03, 0xF0, 0x3F, 0x00, 0xFF, 0x03, 0x00, 0x00,
0x09, 0xE0, 0x2F, 0xF0, 0xFF, 0xE3, 0xB8, 0xEC, 0x9B, 0xF9, 0xBF, 0xF8, 0xBF, 0x99, 0xEF, 0xB8, 0x2C, 0xFF, 0x3F, 0xE0, 0x2F, 0x00, 0x00, 0x00,
0x04, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0x03, 0x87, 0x87, 0xC3, 0x30, 0x0C, 0xE3, 0xDE, 0x01,
0x03, 0x74, 0xBB, 0x0C, 0xC3, 0x30, 0x2C, 0x2D, 0x0D,
0x05, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x0F,
0x05, 0x00, 0x00, 0xD0, 0xC7, 0x34, 0xC3, 0x0C, 0x73, 0x4C, 0x1F, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x39, 0xC0, 0x00, 0x43, 0x2F, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xD0, 0x87, 0x30, 0x60, 0x60, 0x60, 0xC0, 0x3F, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xD0, 0x87, 0x30, 0xB8, 0x00, 0x23, 0x4C, 0x1F, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x0E, 0x36, 0xC6, 0xFC, 0x03, 0x0C, 0x30, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xF0, 0xCB, 0x00, 0x7F, 0x40, 0x13, 0x8C, 0x1F, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xD0, 0xCB, 0x10, 0x2F, 0x4C, 0x33, 0x4C, 0x1F, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xF0, 0x0F, 0x30, 0x60, 0x60, 0xC0, 0x00, 0x03, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xD0, 0xC7, 0x30, 0x7D, 0x4C, 0x33, 0x4C, 0x1F, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0xD0, 0xC7, 0x30, 0xC6, 0xE0, 0x03, 0x8C, 0x1F, 0x00, 0x00, 0x00,
0x04, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
0x03, 0xC0, 0xF0, 0x3C, 0xCF, 0xF3, 0x3C, 0x03, 0x00,
0x03, 0x00, 0xCC, 0xF3, 0x3C, 0xCF, 0xF3, 0x30, 0x00,
0x05, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x00,
0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x03, 0x30, 0xC0, 0x0F, 0x30, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0xD0, 0x7F, 0x40, 0xFF, 0x1F, 0xFC, 0xFF, 0x43, 0xFF, 0x1F, 0x40, 0x15, 0x00, 0x00, 0x00,
0x0A, 0xE4, 0x06, 0x90, 0x91, 0x01, 0x06, 0x24, 0x30, 0x90, 0x1B, 0x46, 0x6E, 0x96, 0xB9, 0x91, 0xE4, 0x06, 0x0C, 0x18, 0x90, 0x40, 0x46, 0x06, 0x90, 0x1B,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x3F, 0x02, 0xC2, 0xAB, 0xAA, 0x3E, 0x20, 0xE0, 0xAB, 0xAA, 0x3E, 0x02, 0xC2, 0xFF, 0xFF, 0x0F, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x08, 0x02, 0xC0, 0x30, 0x00, 0x0C, 0x03, 0xF0, 0xFF, 0x00, 0xFE, 0x0B, 0xD0, 0x7F, 0x00, 0xA4, 0x01, 0x00, 0x0A, 0x00, 0xA0, 0x00,
0x0A, 0x00, 0x80, 0x00, 0x81, 0x24, 0x10, 0x85, 0x00, 0x20, 0x66, 0x40, 0x15, 0x45, 0x62, 0x90, 0x4D, 0xD0, 0xF1, 0x23, 0x01, 0xFD, 0x41, 0x41, 0x07, 0x00,
0x0A, 0x00, 0x05, 0x00, 0xA0, 0x00, 0x40, 0x1F, 0x00, 0xF8, 0x02, 0xD0, 0x7F, 0x00, 0xFE, 0x0B, 0xF0, 0xEF, 0x00, 0xFF, 0x0D, 0xD0, 0x77, 0x00, 0xF4, 0x01,
0x0A, 0x00, 0x20, 0x00, 0x00, 0x3C, 0x00, 0xD4, 0x01, 0xD0, 0x06, 0x40, 0x7F, 0x00, 0xFD, 0x01, 0xF4, 0x07, 0xD0, 0x1F, 0x00, 0x7F, 0x00, 0xD0, 0x01, 0x00,
0x0A, 0x40, 0x15, 0x00, 0xFE, 0x0B, 0x88, 0x2F, 0x52, 0xF0, 0x50, 0x01, 0x0A, 0xD4, 0xAF, 0x7F, 0xFD, 0xF5, 0xC7, 0x0B, 0x3E, 0x70, 0xD0, 0x00, 0xA8, 0x02,
0x0A, 0x80, 0x2F, 0x80, 0x5F, 0x2F, 0x0C, 0x00, 0xC3, 0x00, 0x30, 0x0C, 0x00, 0xC3, 0x01, 0x34, 0x34, 0xC0, 0x01, 0x07, 0x0D, 0xD0, 0x75, 0x00, 0xF4, 0x01,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0xF4, 0x01, 0xC0, 0x3F, 0x00, 0xF0, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0xF0, 0x00, 0xE0, 0xEF, 0x00, 0xBB, 0x0B, 0xA0, 0xAA, 0x00, 0xAA, 0x0A, 0x80, 0x19, 0x00, 0x64, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x10, 0x2D, 0x80, 0xE7, 0x0B, 0xBE, 0xF8, 0xFA, 0x02, 0xFE, 0x0B, 0x80, 0x2F, 0x00, 0x50, 0x00,
0x0A, 0x00, 0x05, 0x00, 0xF8, 0x02, 0xE0, 0xBF, 0x80, 0xAF, 0x2F, 0xBE, 0xE0, 0xDB, 0x02, 0x78, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x05, 0x00, 0xA0, 0x00, 0x40, 0x1F, 0x50, 0xFE, 0x5B, 0xFD, 0xFF, 0x47, 0xFF, 0x1F, 0xE0, 0xBF, 0x00, 0xFE, 0x0B, 0xF0, 0xF5, 0x40, 0x01, 0x14,
0x0A, 0x40, 0x1A, 0x00, 0x09, 0x06, 0x20, 0x80, 0x00, 0x02, 0x08, 0xFC, 0xFF, 0xC3, 0x00, 0x30, 0x0C, 0x00, 0xC3, 0x00, 0x30, 0x0C, 0x00, 0xC3, 0xFF, 0x3F,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAA, 0x0A, 0xF0, 0xFF, 0x00, 0xAA, 0x0A, 0xF0, 0xFF, 0x00, 0x00, 0x00,
0x09, 0xE0, 0x2F, 0xF0, 0xFF, 0xE3, 0xFF, 0xED, 0xFF, 0xE1, 0xDF, 0xE1, 0x2F, 0xE1, 0xEF, 0xE2, 0x2F, 0xEF, 0x3F, 0xE0, 0x2F, 0x00, 0x00, 0x00,
0x0A, 0xC0, 0x31, 0x00, 0x30, 0x01, 0x40, 0x34, 0x00, 0xCC, 0x00, 0x00, 0x0A, 0x00, 0xF8, 0x02, 0xE0, 0xBF, 0x80, 0xFF, 0x2F, 0xFE, 0xFF, 0xFB, 0xFF, 0xFF,
0x0A, 0x00, 0x00, 0x80, 0xFF, 0x2F, 0xFC, 0xFF, 0xC3, 0x07, 0x3D, 0x3C, 0xC0, 0xC3, 0x03, 0x3C, 0x7C, 0xD0, 0xC3, 0xFF, 0x3F, 0xF8, 0xFF, 0x02, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x3C, 0x00, 0xC0, 0x03, 0x00, 0x00, 0x00, 0xC0, 0xF3, 0x3C, 0x3C, 0xCF, 0x03, 0x00, 0x00,
0x0A, 0xB9, 0x91, 0xE3, 0x46, 0x2E, 0x1B, 0xB9, 0x61, 0xE4, 0x06, 0x91, 0x1B, 0x41, 0x6E, 0x24, 0xB9, 0x91, 0xE3, 0x46, 0x2E, 0x1B, 0xB9, 0x01, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x0C, 0xC0, 0x23, 0x00, 0x80, 0x08, 0x00, 0x20, 0x0F, 0xC0, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0xE0, 0x2F, 0xC0, 0x01, 0x0D, 0x06, 0x40, 0x32, 0x00, 0x30, 0x03, 0x00, 0x33, 0x00, 0x30, 0x06, 0x40, 0xC2, 0x01, 0x0D, 0xE0, 0x2F, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x20, 0x00, 0x20, 0x23, 0x80, 0x32, 0x0A, 0x0D, 0xC3, 0xD1, 0x10, 0x1C, 0x0D, 0xC0, 0x81, 0x02, 0x0A, 0xE0, 0x2F, 0x00, 0x54, 0x00,
0x0A, 0x00, 0x00, 0x00, 0xFC, 0x03, 0xB0, 0xE0, 0x00, 0x03, 0x0C, 0x30, 0xC0, 0x00, 0x0B, 0x0E, 0xC0, 0x3F, 0x00, 0xAC, 0x03, 0xC0, 0x3A, 0x00, 0xAC, 0x03,
0x05, 0x6F, 0xBC, 0xF1, 0xC6, 0x1B, 0x6F, 0xBC, 0xF1, 0xC6, 0x1B, 0x6F, 0x00, 0x00,
0x08, 0xE4, 0x6F, 0xE4, 0x6F, 0xE4, 0x6F, 0xE4, 0x6F, 0xE4, 0x6F, 0xE4, 0x6F, 0xE4, 0x6F, 0xE4, 0x6F, 0xE4, 0x6F, 0x00, 0x00,
0x09, 0x00, 0xE4, 0x03, 0x90, 0x0F, 0x40, 0x3E, 0x00, 0xF9, 0x00, 0xE4, 0x03, 0x90, 0x0F, 0x40, 0x3E, 0x00, 0xF9, 0x00, 0xE4, 0x03, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0xFF, 0x03, 0xF0, 0x3F, 0x00, 0xFF, 0x03, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x08, 0x82, 0xE0, 0xBA, 0x2E, 0x08, 0x82, 0x80, 0x20, 0x08, 0xAE, 0xEB, 0x82, 0x20, 0x08, 0x08, 0x82, 0xE0, 0xBA, 0x2E, 0x08, 0x82, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x30, 0x00, 0x00, 0x03, 0x30, 0xFC, 0x00, 0x43, 0x07, 0xFC, 0x20, 0x40, 0x07, 0x30, 0x20, 0x00, 0x03, 0x00, 0xFC, 0x00, 0x40, 0x07, 0x00, 0x20,
0x0A, 0x00, 0x43, 0xC0, 0x20, 0x1D, 0x20, 0x61, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x84, 0x01, 0x24, 0xB4, 0xF1, 0x01, 0xFE, 0x0F, 0xD0, 0x0F, 0x00, 0xFC,
0x0A, 0x00, 0x00, 0x00, 0x54, 0x00, 0x90, 0x1A, 0x40, 0xFE, 0x06, 0xE4, 0x6F, 0x40, 0xFE, 0x06, 0x90, 0x1A, 0x00, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x88, 0x88, 0x88, 0x55, 0x55, 0x55, 0xFF, 0x00, 0x54, 0x55, 0x55, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x02, 0x00, 0x64, 0x00, 0xA5, 0x6B, 0x01, 0x64, 0x00, 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0xC0, 0x00, 0x00, 0xFF, 0x86, 0xC0, 0x00, 0x2C, 0x40, 0xFE, 0x0B, 0xE4, 0xBF, 0x0C, 0xC0, 0xF2, 0x6F, 0x08, 0x0C, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x05, 0x00, 0xF4, 0x01, 0xC0, 0x30, 0x00, 0x0D, 0x07, 0xF0, 0xF0, 0x40, 0x5F, 0x1F, 0xFC, 0xFA, 0xD3, 0xFF, 0x7F, 0xFF, 0xF0, 0xDF, 0xFF, 0x7F,
0x0C, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x1E, 0x00, 0x80, 0x07, 0x00, 0xE0, 0x01, 0x00, 0x78, 0x60, 0x00, 0x24, 0x98, 0x01, 0x80, 0x42, 0x06, 0x00, 0x00, 0x19, 0x00, 0x00, 0x04,
0x0A, 0x00, 0x00, 0x40, 0x7F, 0x00, 0x5C, 0x0D, 0xC0, 0xC1, 0x00, 0x1C, 0x0C, 0x40, 0xFF, 0x01, 0x00, 0x74, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x01, 0x00, 0x68, 0x00, 0xA2, 0x02, 0x80, 0x0A, 0x00, 0x25, 0x00, 0x44, 0x08, 0x10, 0x01, 0x40, 0x04, 0x00, 0x14, 0x00, 0x10, 0x00, 0x00,
0x0A, 0xF0, 0xFF, 0x00, 0xFF, 0x0F, 0xF0, 0xFF, 0x00, 0xFF, 0x0F, 0xF0, 0xFF, 0x00, 0xFF, 0x0F, 0xF0, 0xFA, 0x00, 0x5B, 0x0E, 0x60, 0x90, 0x00, 0x01, 0x04,
0x06, 0xCD, 0xF1, 0x3F, 0xFD, 0x41, 0x06, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0x00, 0x70, 0x1C, 0xC3, 0x20, 0x00, 0x47, 0x00, 0x00,
0x05, 0x00, 0x00, 0xC0, 0x4C, 0x37, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x00, 0x80, 0x19, 0xCC, 0xE0, 0x3F, 0xCC, 0xF0, 0x2F, 0xCC, 0x90, 0x09, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x30, 0xD0, 0x3F, 0x33, 0xE1, 0x07, 0xF4, 0x12, 0x33, 0xFF, 0x00, 0x03, 0x00, 0x00, 0x00,
0x07, 0x00, 0x00, 0x00, 0xD0, 0xE2, 0xCC, 0x1C, 0xDE, 0x01, 0x3C, 0x40, 0xB7, 0x34, 0x33, 0x8B, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x7D, 0x30, 0x0C, 0x13, 0xD0, 0x32, 0xB3, 0x33, 0x1C, 0x7D, 0x07, 0x00, 0x00, 0x00, 0x00,
0x03, 0x00, 0xC0, 0x34, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x34, 0x1D, 0x07, 0x03, 0x07, 0x1D, 0x34, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x07, 0x1D, 0x34, 0x30, 0x34, 0x1D, 0x07, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x44, 0xD0, 0x1C, 0x64, 0xF0, 0x3F, 0x64, 0xD0, 0x1C, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x30, 0xE0, 0x2F, 0x30, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0D, 0x03, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x07, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x80, 0x02, 0x0C, 0xA0, 0x00, 0x03, 0x28, 0xC0, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0xF8, 0xE0, 0x39, 0x07, 0x33, 0x32, 0x03, 0xB3, 0x38, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x36, 0xC0, 0x00, 0x03, 0x0C, 0x74, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0xFC, 0xB1, 0x34, 0x41, 0x03, 0x0A, 0x2C, 0x70, 0x00, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0xFC, 0x71, 0x34, 0x01, 0x03, 0x1E, 0x00, 0x33, 0x34, 0xFE, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0xC0, 0x03, 0x37, 0x1C, 0x73, 0x34, 0xBF, 0x03, 0x30, 0x40, 0x03, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0xFF, 0x33, 0x00, 0x57, 0xE0, 0x2F, 0x00, 0x13, 0x30, 0xFE, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0xF4, 0xD3, 0x00, 0x07, 0xF0, 0x1F, 0x03, 0x33, 0x34, 0xFD, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0xFF, 0x07, 0x34, 0x80, 0x03, 0x0E, 0x38, 0xD0, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0xFC, 0xB1, 0x34, 0x03, 0xD3, 0x1F, 0x03, 0x73, 0x34, 0xFD, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0xFC, 0xB1, 0x34, 0x03, 0xC3, 0x3F, 0x40, 0x23, 0x30, 0xFD, 0x01, 0x00, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x07, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x04, 0x00, 0x0C, 0x0D, 0x03, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC3, 0x0B, 0x1B, 0xC0, 0x0B, 0xC0, 0x03, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x80, 0x0F, 0x90, 0x83, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0xFD, 0x71, 0x30, 0x81, 0x03, 0x0E, 0x34, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x0F, 0x1D, 0x30, 0xE7, 0x37, 0x73, 0x1C, 0xE3, 0x2F, 0x07, 0x00, 0xFD, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x74, 0xD0, 0x1D, 0x47, 0x33, 0x30, 0xFF, 0x33, 0x30, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0xBF, 0x30, 0x38, 0x43, 0xF3, 0x1F, 0x43, 0x33, 0x34, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0xF4, 0xD1, 0x34, 0x03, 0x31, 0x00, 0x03, 0x70, 0x34, 0xFD, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x7F, 0x30, 0x1D, 0x43, 0x33, 0x30, 0x03, 0x33, 0x34, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0xFF, 0x32, 0x00, 0x03, 0xF0, 0x0B, 0x03, 0x30, 0x10, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0xFF, 0x33, 0x10, 0x03, 0xF0, 0x0B, 0x03, 0x30, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0xF4, 0xD1, 0x34, 0x03, 0x30, 0x3E, 0x03, 0x73, 0x34, 0xFD, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x47, 0x33, 0x30, 0x03, 0xF3, 0x3F, 0x03, 0x33, 0x30, 0x47, 0x03, 0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x1D, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1D, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0xD0, 0x01, 0x0C, 0xC0, 0x00, 0x0C, 0xC0, 0x10, 0x0D, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x00, 0x00, 0x00, 0x70, 0x34, 0x4C, 0x03, 0x37, 0xC0, 0x0B, 0x30, 0x0B, 0x0C, 0x0B, 0x47, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x07, 0x30, 0x00, 0x03, 0x30, 0x00, 0x03, 0x30, 0x10, 0xFF, 0x02, 0x00, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00, 0x00, 0x03, 0x30, 0x1F, 0x3D, 0x7B, 0x3B, 0xE3, 0x32, 0x83, 0x30, 0x03, 0x30, 0x03, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x00, 0x00, 0x00, 0x70, 0xD0, 0x3C, 0x30, 0x37, 0xCC, 0x28, 0x33, 0xDC, 0x0C, 0x3C, 0x03, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x00, 0x00, 0x00, 0x40, 0x1F, 0x74, 0x1C, 0x07, 0xCD, 0x00, 0x33, 0xD0, 0x1C, 0x1D, 0xFD, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x7F, 0x30, 0x1D, 0x43, 0x73, 0x34, 0xFF, 0x31, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x00, 0x00, 0x00, 0x40, 0x1F, 0x34, 0x1D, 0x07, 0xCD, 0x00, 0x33, 0xDC, 0x1C, 0x1D, 0xFD, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0xFF, 0x31, 0x34, 0x03, 0xF3, 0x0F, 0xD7, 0x30, 0x34, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0xFC, 0xB1, 0x31, 0x07, 0xD0, 0x0F, 0x90, 0x23, 0x34, 0xFE, 0x01, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0xFF, 0x13, 0x13, 0x30, 0x00, 0x03, 0x30, 0x00, 0x03, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x00, 0x00, 0x00, 0x30, 0xC0, 0x0C, 0x30, 0x03, 0xCC, 0x00, 0x33, 0xD0, 0x2C, 0x1D, 0xFD, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x03, 0x33, 0x30, 0x03, 0xB3, 0x38, 0xCD, 0xC1, 0x0D, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00, 0x00, 0x03, 0x30, 0x43, 0x30, 0xC7, 0x34, 0xCD, 0x1C, 0xED, 0x1E, 0x2C, 0x0E, 0x0C, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x00, 0x00, 0x00, 0x30, 0xC0, 0x34, 0x1C, 0xB8, 0x03, 0x3D, 0xC0, 0x2D, 0x34, 0x1C, 0x03, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x03, 0xB3, 0x38, 0xDC, 0x40, 0x07, 0x30, 0x00, 0x03, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0x00, 0x2D, 0xC0, 0x02, 0x2C, 0xD0, 0x02, 0x6C, 0x00, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x2F, 0x03, 0x03, 0x03, 0x03, 0x03, 0x2F, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x30, 0x80, 0x02, 0x0C, 0xA0, 0x00, 0x03, 0x28, 0xC0, 0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x3E, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3E, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x1D, 0x37, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00,
0x03, 0x00, 0x30, 0x18, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7D, 0x04, 0xC3, 0xCF, 0x30, 0xFD, 0x01, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x70, 0xC0, 0x00, 0x7F, 0x5C, 0x33, 0xCC, 0x30, 0x7F, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3D, 0x5C, 0x32, 0xC0, 0x24, 0x3D, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x0D, 0x30, 0xF8, 0x38, 0x33, 0xCC, 0x31, 0xFD, 0x01, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7D, 0x0C, 0xF3, 0xCB, 0x00, 0xBD, 0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x3D, 0x07, 0x03, 0x2F, 0x03, 0x03, 0x07, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBC, 0x2C, 0x33, 0x4C, 0x3F, 0xC0, 0x04, 0xE3, 0x07, 0x00,
0x05, 0x00, 0x00, 0x30, 0xC0, 0x00, 0x7F, 0x9C, 0x33, 0xCC, 0x30, 0xC7, 0x01, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x04, 0x1C, 0x00, 0x0D, 0x0C, 0x0C, 0x1D, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x30, 0x00, 0x34, 0x30, 0x30, 0x30, 0x30, 0x1E, 0x00,
0x05, 0x00, 0x00, 0x30, 0xC0, 0x10, 0xE3, 0xEC, 0xF0, 0xC1, 0x1C, 0xC3, 0x01, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x47, 0x3D, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9B, 0x71, 0x37, 0x33, 0x33, 0x32, 0x43, 0x03, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x1C, 0x33, 0xCC, 0x30, 0xD3, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7D, 0x1C, 0x33, 0xCC, 0x34, 0x7D, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x1C, 0x33, 0xCC, 0x34, 0x7F, 0x0C, 0x30, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFD, 0x1D, 0x33, 0xCC, 0x34, 0xFD, 0x00, 0x03, 0x0C, 0x50,
0x04, 0x00, 0x00, 0x00, 0x00, 0x33, 0x1F, 0x07, 0x03, 0x03, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x0C, 0xC1, 0x43, 0x30, 0x3F, 0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x0C, 0x0C, 0x3F, 0x0C, 0x0C, 0x1C, 0x74, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC7, 0x0D, 0x33, 0xCC, 0x34, 0xFD, 0x01, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0x0C, 0x33, 0xCD, 0x2D, 0x2C, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x33, 0x32, 0x33, 0x73, 0x37, 0xCD, 0x01, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD3, 0x2C, 0xD3, 0xC7, 0x38, 0xC7, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0x0C, 0x73, 0x4C, 0x37, 0x74, 0xC0, 0xF0, 0x01, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xC4, 0xC2, 0xC2, 0x12, 0xFF, 0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x38, 0x0C, 0x0C, 0x03, 0x0C, 0x0C, 0x38, 0x00, 0x00, 0x00,
0x02, 0x00, 0x32, 0x33, 0x33, 0x13, 0x00,
0x04, 0x00, 0x00, 0x0B, 0x0C, 0x0C, 0x30, 0x0C, 0x0C, 0x0B, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1D, 0x72, 0x37, 0xD2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x1F, 0x00, 0x7F, 0x00, 0xFF, 0x01, 0xFF, 0x07, 0xFF, 0x1F, 0xFF, 0x7F, 0xFF, 0x1B, 0xBF, 0x01, 0x1B, 0x00,
0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xFF, 0x00, 0x00, 0xF8, 0xF0, 0x3F, 0xEE, 0x2C, 0x30, 0xCB, 0x0B, 0x30, 0x42, 0xC3, 0x33, 0x00, 0x03, 0x30, 0x00, 0xF3, 0x33, 0x00, 0x03, 0x30, 0x00, 0xFF, 0x3F, 0x00,
0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC2, 0x00, 0x00, 0xCB, 0x00, 0x00, 0xEE, 0xC0, 0xFF, 0xF8, 0xB0, 0xC0, 0xFF, 0x2C, 0xC0, 0x00, 0x0C, 0xCF, 0x00, 0x0C, 0xC0, 0x00, 0xCC, 0xCF, 0x00, 0x0C, 0xC0, 0x00, 0xFC, 0xFF,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x70, 0x00, 0x00, 0xF3, 0xFF, 0xD3, 0x03, 0xE0, 0x3C, 0x3F, 0x38, 0x03, 0xD0, 0x33, 0xFF, 0x38, 0x03, 0xE0, 0xF0, 0xFF, 0x03,
0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x8B, 0xF7, 0x0C, 0x13, 0x9F, 0x3B, 0x37, 0x00, 0xC0, 0x23, 0xFF, 0xFF, 0x8B, 0x03, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD0, 0x7F, 0x80, 0x03, 0x2C, 0x0D, 0x00, 0x37, 0x00, 0xC0, 0xF3, 0xFF, 0x3C, 0xFF, 0xCF, 0x03, 0x00, 0xDC, 0x00, 0x70, 0x38, 0xC0, 0x02, 0xFD, 0x07,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x03, 0xF0, 0xFF, 0xC0, 0xFF, 0x3F, 0xFC, 0xFF, 0xC3, 0xFF, 0x3F, 0xFC, 0xFF, 0x03, 0xFF, 0x0F, 0xC0, 0x3F, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x3F, 0x00, 0xC0, 0x03, 0x00, 0x3C, 0xF0, 0xC0, 0xC3, 0x3A, 0x3C, 0x0B, 0xCE, 0x2B, 0x80, 0x7E, 0x00, 0xD0, 0x03, 0x00, 0xFC, 0xFF, 0xFF,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0x3F, 0xFC, 0xFF, 0xC3, 0xFF, 0x3F, 0xFC, 0xFF, 0xC3, 0xFF, 0x3F, 0xFC, 0xFF, 0xC3, 0xFF, 0x3F, 0xFC, 0xFF, 0x03, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD0, 0x7F, 0x80, 0x03, 0x2C, 0x0D, 0x0F, 0x37, 0xF0, 0xC0, 0xF3, 0xFF, 0x3C, 0xFF, 0xCF, 0x03, 0x0F, 0xDC, 0xF0, 0x70, 0x38, 0xC0, 0x02, 0xFD, 0x07,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x1F, 0x00, 0xAD, 0x07, 0xB0, 0xC5, 0x00, 0x17, 0x0C, 0x70, 0xD0, 0x00, 0x0C, 0x03, 0xBC, 0xEF, 0xB3, 0x11, 0xE0, 0x07, 0x05, 0x3C, 0x52, 0xC8,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0xC0, 0x3F, 0x00, 0xFC, 0x03, 0xC0, 0x3F, 0x00, 0xF0, 0x00, 0xC0, 0x30, 0xC0, 0xFF, 0x3F, 0xFC, 0xFF, 0xC3, 0xFF, 0x3F,
0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0xFC, 0xFF, 0x0F, 0xFC, 0xFF, 0x3F, 0xFC, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB8, 0xE0, 0x2F, 0xFF, 0xE3, 0x2F, 0xB8, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD0, 0x7F, 0x80, 0xFF, 0x2F, 0xFD, 0xFF, 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF, 0xFF, 0x7F, 0xF8, 0xFF, 0x02, 0xFD, 0x07,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01, 0x00, 0x02, 0x00, 0xC8, 0x07, 0x10, 0xC3, 0x00, 0x31, 0x0D, 0x00, 0xFD, 0x01, 0x00, 0x74, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0xF0, 0xF0, 0x00, 0x0F, 0x0F, 0xF0, 0xF0, 0x00, 0x0F, 0x0F, 0xF0, 0xF0, 0x00, 0x0F, 0x0F, 0xF0, 0xF0, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x80, 0xFF, 0x8B, 0x1E, 0xD0, 0x2E, 0x00, 0xF0, 0x00, 0xE0, 0xFF, 0x0B, 0x00, 0x0F, 0x00, 0xB8, 0x03, 0xB0, 0xE2, 0xFF, 0x02, 0x50, 0x01,
0x08, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x07, 0x03, 0x1E, 0x03, 0x73, 0x03, 0xEF, 0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, 0xFF, 0xFF,
0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xFE, 0x02, 0xBE, 0xC1, 0xD0, 0x01, 0xF0, 0x3F, 0xE0, 0x0B, 0x1F, 0x1C, 0xD0, 0x4A, 0x03, 0x6C, 0xB3, 0x00, 0xC3, 0x4D, 0x7E, 0xD0, 0xBF, 0x01,
0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x2A, 0x00, 0xAA, 0x0A, 0x80, 0x2A, 0xFC, 0xA0, 0xF2, 0x3F, 0xA0, 0xFC, 0x03, 0xC8, 0xFF, 0x00, 0xF2, 0x00, 0x00, 0x00, 0x00,
0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x01, 0x00, 0xC0, 0x07, 0xAA, 0xEA, 0x1F, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xAA, 0xEA, 0x1F, 0x00, 0xC0, 0x07, 0x00, 0xC0, 0x01, 0x00, 0x00, 0x00,
0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x03, 0x00, 0xD0, 0x03, 0x00, 0xF4, 0xAB, 0xAA, 0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, 0xFF, 0xFF, 0xF4, 0xAB, 0xAA, 0xD0, 0x03, 0x00, 0x40, 0x03, 0x00, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x3F, 0xFE, 0xFF, 0xA0, 0xEA, 0xA3, 0x80, 0xEF, 0x02, 0xFE, 0x0B, 0xF8, 0xAF, 0xEA, 0xFF, 0x2F, 0xFE, 0x2F, 0x20, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x2D, 0xFE, 0x2F, 0x00, 0x00, 0xF0, 0xFF, 0x06, 0x00, 0x64, 0xFE, 0x0A, 0x05, 0x90, 0x00, 0x00, 0x02, 0x40, 0x06,
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x03, 0x07, 0x36, 0x06, 0x4C, 0x0E, 0x28, 0x3C, 0x70, 0xF0, 0xE0, 0xC1, 0xF6, 0x7F, 0xF2, 0xFF, 0x03, 0xFE, 0x02, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0x40, 0x44, 0x04, 0x20, 0x11, 0x84, 0x48, 0x10, 0x12, 0x42, 0x88, 0x04, 0x32, 0x22, 0xCC, 0x8C, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD0, 0x01, 0xD0, 0x01, 0x80, 0x07, 0x40, 0x7B, 0x00, 0xFF, 0x02, 0xBC, 0x0F, 0xE0, 0x2B, 0x40, 0x7F, 0xD0, 0xFF, 0x1F, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x14, 0x00, 0x90, 0x01, 0x80, 0x0A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0xFF, 0x03, 0x00, 0xCF, 0xBD, 0x3C, 0x00, 0xF0, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0xFF, 0x03, 0x00, 0xCF, 0xBD, 0x3C, 0x00, 0xF0, 0xFF, 0xFF, 0x00, 0x03, 0x00, 0x0C, 0x00, 0x30, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0xFF, 0x03, 0x00, 0xCF, 0xBD, 0x3C, 0x00, 0xF0, 0xFF, 0xFF, 0x00, 0x74, 0x00, 0x40, 0x07, 0x00, 0x34, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0xFF, 0x03, 0x00, 0xCF, 0xBD, 0x3C, 0x00, 0xF0, 0xFF, 0xFF, 0x74, 0x00, 0x74, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xF0, 0xFF, 0xC3, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x3F, 0x00, 0xC0, 0x07, 0x00, 0xBD, 0x02, 0xE8, 0xB3, 0xE0, 0x3C, 0xAC, 0xC3, 0x03, 0x0F, 0x3C, 0x00, 0xC0, 0x03, 0x00, 0xFC, 0xFF, 0xFF,
0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8C, 0x0C, 0x1C, 0xB9, 0xD1, 0x6C, 0x73, 0x0E, 0x70, 0x34, 0x70, 0x0A, 0x68, 0xD3, 0xFF, 0x1F, 0xBC, 0x99, 0x8F, 0x8B, 0x8B, 0x7B, 0x9B, 0x79, 0xFF, 0xFF, 0xFF,
0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x3F, 0x00, 0xC0, 0x0F, 0x00, 0xFC, 0x0F, 0x00, 0xFF, 0x03, 0xF0, 0xFF, 0x03, 0xFF, 0xFF, 0xC3, 0xFF, 0xFF, 0xFC, 0xFF, 0xFF,
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x1F, 0xCB, 0x30, 0xC3, 0x3F, 0xC7, 0x00, 0x7E, 0x2F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xC3, 0xFF, 0x3F, 0x0C, 0x00, 0xC3, 0xFC, 0x33, 0x0C, 0x24, 0xC3, 0xC0, 0x31, 0x0C, 0x06, 0xC3, 0x30, 0x30, 0x0C, 0x00, 0xC3, 0xFF, 0x3F,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x3F, 0x30, 0x00, 0x03, 0xC3, 0x30, 0x30, 0x3F, 0xFF, 0xFF, 0x3F, 0x3C, 0x00, 0xFF, 0xFF, 0xFF, 0x0C, 0x0C, 0xC3, 0xC0, 0x00, 0x0C, 0xFC, 0xFF,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0x00, 0xFC, 0x0F, 0xC0, 0xFF, 0x00, 0xFC, 0x0F, 0xC0, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x03, 0x00, 0x3C, 0x00, 0xC0, 0x03, 0xF0, 0x3F, 0x00, 0xFF, 0x03, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x02, 0xFF, 0x3F, 0x8E, 0xCB, 0xBE, 0x99, 0xFF, 0x8B, 0xFF, 0x9B, 0xF9, 0x8E, 0xCB, 0xF2, 0xFF, 0x03, 0xFE, 0x02, 0x00, 0x00,
0x04, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0x03, 0x00, 0x70, 0x78, 0x38, 0x0C, 0xC3, 0x30, 0xEE, 0x1D,
0x03, 0x00, 0x40, 0xB7, 0xCB, 0x30, 0x0C, 0xC3, 0xD2, 0xD2,
0x05, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7D, 0x4C, 0x33, 0xCC, 0x30, 0xC7, 0xF4, 0x01, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xF0, 0x90, 0x03, 0x0C, 0x30, 0xF4, 0x02, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7D, 0x08, 0x03, 0x06, 0x06, 0x06, 0xFC, 0x03, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7D, 0x08, 0x83, 0x0B, 0x30, 0xC2, 0xF4, 0x01, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x60, 0x63, 0xCC, 0x3F, 0xC0, 0x00, 0x03, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBF, 0x0C, 0xF0, 0x07, 0x34, 0xC1, 0xF8, 0x01, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBD, 0x0C, 0xF1, 0xC2, 0x34, 0xC3, 0xF4, 0x01, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x03, 0x06, 0x06, 0x0C, 0x30, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7D, 0x0C, 0xD3, 0xC7, 0x34, 0xC3, 0xF4, 0x01, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7D, 0x0C, 0x63, 0x0C, 0x3E, 0xC0, 0xF8, 0x01, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
0x03, 0x00, 0x00, 0x0C, 0xCF, 0xF3, 0x3C, 0xCF, 0x33, 0x00,
0x03, 0x00, 0x00, 0xC0, 0x3C, 0xCF, 0xF3, 0x3C, 0x0F, 0x03,
0x05, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x00,
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x03, 0x30, 0xC0, 0x0F, 0x30, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0xD0, 0x7F, 0x40, 0xFF, 0x1F, 0xFC, 0xFF, 0x43, 0xFF, 0x1F, 0x40, 0x15, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE4, 0x06, 0x90, 0x91, 0x01, 0x06, 0x24, 0x30, 0x90, 0x1B, 0x46, 0x6E, 0x96, 0xB9, 0x91, 0xE4, 0x06, 0x0C, 0x18, 0x90, 0x40, 0x46, 0x06, 0x90, 0x1B,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x3F, 0x02, 0xC2, 0xAB, 0xAA, 0x3E, 0x20, 0xE0, 0xAB, 0xAA, 0x3E, 0x02, 0xC2, 0xFF, 0xFF, 0x0F, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x02, 0xC0, 0x30, 0x00, 0x0C, 0x03, 0xF0, 0xFF, 0x00, 0xFE, 0x0B, 0xD0, 0x7F, 0x00, 0xA4, 0x01, 0x00, 0x0A, 0x00, 0xA0, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x81, 0x24, 0x10, 0x85, 0x00, 0x20, 0x66, 0x40, 0x15, 0x45, 0x62, 0x90, 0x4D, 0xD0, 0xF1, 0x23, 0x01, 0xFD, 0x41, 0x41, 0x07, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0xA0, 0x00, 0x40, 0x1F, 0x00, 0xF8, 0x02, 0xD0, 0x7F, 0x00, 0xFE, 0x0B, 0xF0, 0xEF, 0x00, 0xFF, 0x0D, 0xD0, 0x77, 0x00, 0xF4, 0x01,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x3C, 0x00, 0xD4, 0x01, 0xD0, 0x06, 0x40, 0x7F, 0x00, 0xFD, 0x01, 0xF4, 0x07, 0xD0, 0x1F, 0x00, 0x7F, 0x00, 0xD0, 0x01, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x15, 0x00, 0xFE, 0x0B, 0x88, 0x2F, 0x52, 0xF0, 0x50, 0x01, 0x0A, 0xD4, 0xAF, 0x7F, 0xFD, 0xF5, 0xC7, 0x0B, 0x3E, 0x70, 0xD0, 0x00, 0xA8, 0x02,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x2F, 0x80, 0x5F, 0x2F, 0x0C, 0x00, 0xC3, 0x00, 0x30, 0x0C, 0x00, 0xC3, 0x01, 0x34, 0x34, 0xC0, 0x01, 0x07, 0x0D, 0xD0, 0x75, 0x00, 0xF4, 0x01,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0xF4, 0x01, 0xC0, 0x3F, 0x00, 0xF0, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0xE0, 0xEF, 0x00, 0xBB, 0x0B, 0xA0, 0xAA, 0x00, 0xAA, 0x0A, 0x80, 0x19, 0x00, 0x64, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x10, 0x2D, 0x80, 0xE7, 0x0B, 0xBE, 0xF8, 0xFA, 0x02, 0xFE, 0x0B, 0x80, 0x2F, 0x00, 0x50, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0xF8, 0x02, 0xE0, 0xBF, 0x80, 0xAF, 0x2F, 0xBE, 0xE0, 0xDB, 0x02, 0x78, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0xA0, 0x00, 0x40, 0x1F, 0x50, 0xFE, 0x5B, 0xFD, 0xFF, 0x47, 0xFF, 0x1F, 0xE0, 0xBF, 0x00, 0xFE, 0x0B, 0xF0, 0xF5, 0x40, 0x01, 0x14,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x1A, 0x00, 0x09, 0x06, 0x20, 0x80, 0x00, 0x02, 0x08, 0xFC, 0xFF, 0xC3, 0x00, 0x30, 0x0C, 0x00, 0xC3, 0x00, 0x30, 0x0C, 0x00, 0xC3, 0xFF, 0x3F,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAA, 0x0A, 0xF0, 0xFF, 0x00, 0xAA, 0x0A, 0xF0, 0xFF, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x02, 0xFF, 0x3F, 0xFE, 0xDF, 0xFE, 0x1F, 0xFE, 0x1D, 0xFE, 0x12, 0xFE, 0x2E, 0xFE, 0xF2, 0xFE, 0x03, 0xFE, 0x02, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x31, 0x00, 0x30, 0x01, 0x40, 0x34, 0x00, 0xCC, 0x00, 0x00, 0x0A, 0x00, 0xF8, 0x02, 0xE0, 0xBF, 0x80, 0xFF, 0x2F, 0xFE, 0xFF, 0xFB, 0xFF, 0xFF,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x2F, 0xFC, 0xFF, 0xC3, 0x07, 0x3D, 0x3C, 0xC0, 0xC3, 0x03, 0x3C, 0x7C, 0xD0, 0xC3, 0xFF, 0x3F, 0xF8, 0xFF, 0x02, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x3C, 0x00, 0xC0, 0x03, 0x00, 0x00, 0x00, 0xC0, 0xF3, 0x3C, 0x3C, 0xCF, 0x03, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB9, 0x91, 0xE3, 0x46, 0x2E, 0x1B, 0xB9, 0x61, 0xE4, 0x06, 0x91, 0x1B, 0x41, 0x6E, 0x24, 0xB9, 0x91, 0xE3, 0x46, 0x2E, 0x1B, 0xB9, 0x01, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x0C, 0xC0, 0x23, 0x00, 0x80, 0x08, 0x00, 0x20, 0x0F, 0xC0, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x2F, 0xC0, 0x01, 0x0D, 0x06, 0x40, 0x32, 0x00, 0x30, 0x03, 0x00, 0x33, 0x00, 0x30, 0x06, 0x40, 0xC2, 0x01, 0x0D, 0xE0, 0x2F, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x20, 0x23, 0x80, 0x32, 0x0A, 0x0D, 0xC3, 0xD1, 0x10, 0x1C, 0x0D, 0xC0, 0x81, 0x02, 0x0A, 0xE0, 0x2F, 0x00, 0x54, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x03, 0xB0, 0xE0, 0x00, 0x03, 0x0C, 0x30, 0xC0, 0x00, 0x0B, 0x0E, 0xC0, 0x3F, 0x00, 0xAC, 0x03, 0xC0, 0x3A, 0x00, 0xAC, 0x03,
0x05, 0x00, 0x00, 0xF0, 0xC6, 0x1B, 0x6F, 0xBC, 0xF1, 0xC6, 0x1B, 0x6F, 0xBC, 0xF1, 0x06, 0x00,
0x08, 0x00, 0x00, 0x00, 0x00, 0xE4, 0x6F, 0xE4, 0x6F, 0xE4, 0x6F, 0xE4, 0x6F, 0xE4, 0x6F, 0xE4, 0x6F, 0xE4, 0x6F, 0xE4, 0x6F, 0xE4, 0x6F, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x3E, 0x00, 0xF9, 0x00, 0xE4, 0x03, 0x90, 0x0F, 0x40, 0x3E, 0x00, 0xF9, 0x00, 0xE4, 0x03, 0x90, 0x0F, 0x40, 0x3E, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0xFF, 0x03, 0xF0, 0x3F, 0x00, 0xFF, 0x03, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x82, 0xE0, 0xBA, 0x2E, 0x08, 0x82, 0x80, 0x20, 0x08, 0xAE, 0xEB, 0x82, 0x20, 0x08, 0x08, 0x82, 0xE0, 0xBA, 0x2E, 0x08, 0x82, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x03, 0x30, 0xFC, 0x00, 0x43, 0x07, 0xFC, 0x20, 0x40, 0x07, 0x30, 0x20, 0x00, 0x03, 0x00, 0xFC, 0x00, 0x40, 0x07, 0x00, 0x20,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0xC0, 0x20, 0x1D, 0x20, 0x61, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x84, 0x01, 0x24, 0xB4, 0xF1, 0x01, 0xFE, 0x0F, 0xD0, 0x0F, 0x00, 0xFC,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x00, 0x90, 0x1A, 0x40, 0xFE, 0x06, 0xE4, 0x6F, 0x40, 0xFE, 0x06, 0x90, 0x1A, 0x00, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x81, 0x88, 0x88, 0x58, 0x55, 0x55, 0xF5, 0x0F, 0x40, 0x55, 0x55, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x02, 0x00, 0x64, 0x00, 0xA5, 0x6B, 0x01, 0x64, 0x00, 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0xFF, 0x86, 0xC0, 0x00, 0x2C, 0x40, 0xFE, 0x0B, 0xE4, 0xBF, 0x0C, 0xC0, 0xF2, 0x6F, 0x08, 0x0C, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0xF4, 0x01, 0xC0, 0x30, 0x00, 0x0D, 0x07, 0xF0, 0xF0, 0x40, 0x5F, 0x1F, 0xFC, 0xFA, 0xD3, 0xFF, 0x7F, 0xFF, 0xF0, 0xDF, 0xFF, 0x7F,
0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x1E, 0x00, 0x80, 0x07, 0x00, 0xE0, 0x01, 0x00, 0x78, 0x60, 0x00, 0x24, 0x98, 0x01, 0x80, 0x42, 0x06, 0x00, 0x00, 0x19, 0x00, 0x00, 0x04,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x7F, 0x00, 0x5C, 0x0D, 0xC0, 0xC1, 0x00, 0x1C, 0x0C, 0x40, 0xFF, 0x01, 0x00, 0x74, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x68, 0x00, 0xA2, 0x02, 0x80, 0x0A, 0x00, 0x25, 0x00, 0x44, 0x08, 0x10, 0x01, 0x40, 0x04, 0x00, 0x14, 0x00, 0x10, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0x00, 0xFF, 0x0F, 0xF0, 0xFF, 0x00, 0xFF, 0x0F, 0xF0, 0xFF, 0x00, 0xFF, 0x0F, 0xF0, 0xFA, 0x00, 0x5B, 0x0E, 0x60, 0x90, 0x00, 0x01, 0x04,
0x06, 0x00, 0x00, 0x00, 0xCD, 0xF1, 0x3F, 0xFD, 0x41, 0x06, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x06, 0x00, 0x00, 0x00, 0x74, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0xDC, 0xC0, 0x0C, 0x99, 0x31, 0x30, 0x89, 0x41, 0x07,
0x0A, 0x00, 0x00, 0x00, 0x74, 0x00, 0xD0, 0x1F, 0x40, 0x8B, 0x07, 0x3D, 0xF3, 0xF1, 0x3F, 0x3F, 0xFD, 0xF8, 0x41, 0xFF, 0x07, 0xD0, 0x1C, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
short font_ptrs[] = {
0x0000, 0x000E, 0x001C, 0x002A, 0x0038, 0x0046, 0x0054, 0x0062,
0x0070, 0x007E, 0x008C, 0x009A, 0x00A8, 0x00B6, 0x00C4, 0x00D2,
0x00E0, 0x00EE, 0x00FC, 0x010A, 0x0118, 0x0126, 0x0134, 0x0142,
0x0150, 0x015E, 0x016C, 0x017A, 0x0188, 0x0196, 0x01A4, 0x01B2,
0x01C0, 0x01CE, 0x01D7, 0x01E5, 0x01F5, 0x0205, 0x0218, 0x0228,
0x0231, 0x023C, 0x0247, 0x0257, 0x0267, 0x0272, 0x0280, 0x0289,
0x0299, 0x02A9, 0x02B7, 0x02C7, 0x02D7, 0x02E7, 0x02F7, 0x0307,
0x0317, 0x0327, 0x0337, 0x0340, 0x034B, 0x035B, 0x036B, 0x037B,
0x038B, 0x03A0, 0x03B0, 0x03C0, 0x03D0, 0x03E0, 0x03F0, 0x0400,
0x0410, 0x0420, 0x042B, 0x043B, 0x044E, 0x045E, 0x0473, 0x0486,
0x0499, 0x04A9, 0x04BC, 0x04CC, 0x04DC, 0x04EC, 0x04FF, 0x050F,
0x0524, 0x0537, 0x0547, 0x055A, 0x0565, 0x0573, 0x057E, 0x0589,
0x0599, 0x05A2, 0x05B0, 0x05BE, 0x05CC, 0x05DA, 0x05E8, 0x05F3,
0x0601, 0x060F, 0x061A, 0x0625, 0x0633, 0x063E, 0x064E, 0x065C,
0x066A, 0x0678, 0x0686, 0x0691, 0x069F, 0x06AA, 0x06B8, 0x06C6,
0x06D6, 0x06E4, 0x06F2, 0x0700, 0x070B, 0x0711, 0x071C, 0x072C,
0x0737, 0x074C, 0x076B, 0x078A, 0x07A4, 0x07C3, 0x07DD, 0x07F7,
0x0811, 0x082B, 0x0845, 0x085F, 0x0879, 0x0898, 0x08A8, 0x08C2,
0x08DC, 0x08F6, 0x0910, 0x0925, 0x0942, 0x095F, 0x097E, 0x099D,
0x09B5, 0x09CD, 0x09E5, 0x09FD, 0x0A15, 0x0A2D, 0x0A45, 0x0A5D,
0x0A75, 0x0A8D, 0x0AA5, 0x0ABF, 0x0ADC, 0x0AF9, 0x0B0E, 0x0B28,
0x0B42, 0x0B5C, 0x0B76, 0x0B8E, 0x0B99, 0x0BA2, 0x0BAB, 0x0BB9,
0x0BC7, 0x0BD5, 0x0BE3, 0x0BF1, 0x0BFF, 0x0C0D, 0x0C1B, 0x0C29,
0x0C37, 0x0C45, 0x0C50, 0x0C59, 0x0C62, 0x0C70, 0x0C80, 0x0C90,
0x0CAA, 0x0CC4, 0x0CDE, 0x0CF8, 0x0D12, 0x0D2C, 0x0D46, 0x0D60,
0x0D7A, 0x0D94, 0x0DAE, 0x0DC8, 0x0DE2, 0x0DFC, 0x0E16, 0x0E30,
0x0E48, 0x0E62, 0x0E7C, 0x0E96, 0x0EB0, 0x0ECA, 0x0EE4, 0x0EFE,
0x0F18, 0x0F26, 0x0F3B, 0x0F53, 0x0F6D, 0x0F87, 0x0FA1, 0x0FBB,
0x0FD5, 0x0FF2, 0x100C, 0x1026, 0x1040, 0x105F, 0x1079, 0x1093,
0x10AD, 0x10BD, 0x10CD, 0x10DD, 0x10ED, 0x10FD, 0x110D, 0x111D,
0x112D, 0x113D, 0x114D, 0x115D, 0x116D, 0x117D, 0x118D, 0x119D,
0x11AD, 0x11BD, 0x11CD, 0x11DD, 0x11ED, 0x11FD, 0x120D, 0x121D,
unsigned short font_ptrs[] = {
0x0000, 0x0010, 0x0020, 0x0030, 0x0040, 0x0050, 0x0060, 0x0070,
0x0080, 0x0090, 0x00A0, 0x00B0, 0x00C0, 0x00D0, 0x00E0, 0x00F0,
0x0100, 0x0110, 0x0120, 0x0130, 0x0140, 0x0150, 0x0160, 0x0170,
0x0180, 0x0190, 0x01A0, 0x01B0, 0x01C0, 0x01D0, 0x01E0, 0x01F0,
0x0200, 0x0210, 0x021A, 0x022A, 0x023D, 0x0250, 0x0266, 0x0279,
0x0283, 0x0290, 0x029D, 0x02B0, 0x02C3, 0x02D0, 0x02E0, 0x02EA,
0x02FD, 0x0310, 0x0320, 0x0333, 0x0346, 0x0359, 0x036C, 0x037F,
0x0392, 0x03A5, 0x03B8, 0x03C2, 0x03CF, 0x03E2, 0x03F5, 0x0408,
0x041B, 0x0434, 0x0447, 0x045A, 0x046D, 0x0480, 0x0493, 0x04A6,
0x04B9, 0x04CC, 0x04D9, 0x04EC, 0x0502, 0x0515, 0x052E, 0x0544,
0x055A, 0x056D, 0x0583, 0x0596, 0x05A9, 0x05BC, 0x05D2, 0x05E5,
0x05FE, 0x0614, 0x0627, 0x063D, 0x064A, 0x065A, 0x0667, 0x0674,
0x0687, 0x0691, 0x06A1, 0x06B1, 0x06C1, 0x06D1, 0x06E1, 0x06EE,
0x06FE, 0x070E, 0x071B, 0x0728, 0x0738, 0x0745, 0x0758, 0x0768,
0x0778, 0x0788, 0x0798, 0x07A5, 0x07B5, 0x07C2, 0x07D2, 0x07E2,
0x07F5, 0x0805, 0x0815, 0x0825, 0x0832, 0x0839, 0x0846, 0x0859,
0x0866, 0x087F, 0x08A4, 0x08C9, 0x08E8, 0x090D, 0x092C, 0x094B,
0x096A, 0x0989, 0x09A8, 0x09C7, 0x09E6, 0x0A0B, 0x0A1E, 0x0A3D,
0x0A5C, 0x0A7B, 0x0A9A, 0x0AB3, 0x0AD5, 0x0AF7, 0x0B1C, 0x0B41,
0x0B5D, 0x0B79, 0x0B95, 0x0BB1, 0x0BCD, 0x0BE9, 0x0C05, 0x0C21,
0x0C3D, 0x0C59, 0x0C75, 0x0C94, 0x0CB6, 0x0CD8, 0x0CF1, 0x0D10,
0x0D2F, 0x0D4E, 0x0D6D, 0x0D89, 0x0D96, 0x0DA0, 0x0DAA, 0x0DBA,
0x0DCA, 0x0DDA, 0x0DEA, 0x0DFA, 0x0E0A, 0x0E1A, 0x0E2A, 0x0E3A,
0x0E4A, 0x0E5A, 0x0E67, 0x0E71, 0x0E7B, 0x0E8B, 0x0E9E, 0x0EB1,
0x0ED0, 0x0EEF, 0x0F0E, 0x0F2D, 0x0F4C, 0x0F6B, 0x0F8A, 0x0FA9,
0x0FC8, 0x0FE7, 0x1006, 0x1025, 0x1044, 0x1063, 0x1082, 0x10A1,
0x10BD, 0x10DC, 0x10FB, 0x111A, 0x1139, 0x1158, 0x1177, 0x1196,
0x11B5, 0x11C5, 0x11DE, 0x11FA, 0x1219, 0x1238, 0x1257, 0x1276,
0x1295, 0x12B7, 0x12D6, 0x12F5, 0x1314, 0x1339, 0x1358, 0x1377,
0x1396, 0x13A9, 0x13BC, 0x13CF, 0x13E2, 0x13F5, 0x1408, 0x141B,
0x142E, 0x1441, 0x1454, 0x1467, 0x147A, 0x148D, 0x14A0, 0x14B3,
0x14C6, 0x14D9, 0x14EC, 0x14FF, 0x1512, 0x1525, 0x1538, 0x154B,
0x155E,
};
unsigned int font_ranges[][2] = {
{ 0x000000, 0x00007F },
{ 0x00E000, 0x00E07F },
{ 0x00FFFD, 0x00FFFD },
{ 0, 0 },
};
#else
extern unsigned char font_data[];
extern short font_ptrs[];
extern unsigned short font_ptrs[];
extern unsigned int font_ranges[][2];
#endif
#else
extern unsigned char *font_data;
extern unsigned short *font_ptrs;
extern unsigned int (*font_ranges)[2];
#endif
#endif

View File

@ -7,7 +7,7 @@
#include <SDL/SDL.h>
#define CELLW 12
#define CELLH 10
#define CELLH 12
#define XRES 800
#define YRES 600

View File

@ -6,7 +6,7 @@
#include <math.h>
#define CELLW 12
#define CELLH 10
#define CELLH 12
//#define EXTENDED_FONT 1
char font[256][CELLH][CELLW];

View File

@ -11,7 +11,7 @@
#include "font.h"
#define CELLW 12
#define CELLH 10
#define CELLH 12
char font[256][CELLH][CELLW];
char width[256];

View File

@ -1,6 +1,6 @@
#include <ctime>
#include <string>
#include "common/String.h"
#include <stdexcept>
#include <iostream>
#include <iterator>
@ -9,7 +9,7 @@
#include "Format.h"
#include "graphics/Graphics.h"
std::string format::URLEncode(std::string source)
ByteString format::URLEncode(ByteString source)
{
char * src = (char *)source.c_str();
char * dst = new char[(source.length()*3)+2];
@ -33,12 +33,12 @@ std::string format::URLEncode(std::string source)
}
*d = 0;
std::string finalString(dst);
ByteString finalString(dst);
delete[] dst;
return finalString;
}
std::string format::UnixtimeToDate(time_t unixtime, std::string dateFormat)
ByteString format::UnixtimeToDate(time_t unixtime, ByteString dateFormat)
{
struct tm * timeData;
char buffer[128];
@ -46,10 +46,10 @@ std::string format::UnixtimeToDate(time_t unixtime, std::string dateFormat)
timeData = localtime(&unixtime);
strftime(buffer, 128, dateFormat.c_str(), timeData);
return std::string(buffer);
return ByteString(buffer);
}
std::string format::UnixtimeToDateMini(time_t unixtime)
ByteString format::UnixtimeToDateMini(time_t unixtime)
{
time_t currentTime = time(NULL);
struct tm currentTimeData = *localtime(&currentTime);
@ -69,7 +69,7 @@ std::string format::UnixtimeToDateMini(time_t unixtime)
}
}
std::string format::CleanString(std::string dirtyString, bool ascii, bool color, bool newlines, bool numeric)
String format::CleanString(String dirtyString, bool ascii, bool color, bool newlines, bool numeric)
{
for (size_t i = 0; i < dirtyString.size(); i++)
{
@ -226,7 +226,7 @@ struct PNGChunk
//char[4] CRC();
PNGChunk(int length, std::string name)
PNGChunk(int length, ByteString name)
{
if (name.length()!=4)
throw std::runtime_error("Invalid chunk name");

View File

@ -1,6 +1,6 @@
#pragma once
#include <sstream>
#include "common/String.h"
#include <vector>
class VideoBuffer;
@ -9,24 +9,10 @@ namespace format
{
const static char hex[] = "0123456789ABCDEF";
template <typename T> std::string NumberToString(T number)
{
std::stringstream ss;
ss << number;
return ss.str();
}
template <typename T> T StringToNumber(const std::string & text)
{
std::stringstream ss(text);
T number;
return (ss >> number)?number:0;
}
std::string URLEncode(std::string value);
std::string UnixtimeToDate(time_t unixtime, std::string dateFomat = "%d %b %Y");
std::string UnixtimeToDateMini(time_t unixtime);
std::string CleanString(std::string dirtyString, bool ascii, bool color, bool newlines, bool numeric = false);
ByteString URLEncode(ByteString value);
ByteString UnixtimeToDate(time_t unixtime, ByteString dateFomat = "%d %b %Y");
ByteString UnixtimeToDateMini(time_t unixtime);
String CleanString(String dirtyString, bool ascii, bool color, bool newlines, bool numeric = false);
std::vector<char> VideoBufferToPNG(const VideoBuffer & vidBuf);
std::vector<char> VideoBufferToBMP(const VideoBuffer & vidBuf);
std::vector<char> VideoBufferToPPM(const VideoBuffer & vidBuf);

View File

@ -2,8 +2,6 @@
#define UTILS_H
#include <cstdio>
#include <cstdlib>
#include <string>
#include <sstream>
#include <vector>
//Linear interpolation

View File

@ -20,9 +20,9 @@
namespace Platform
{
std::string ExecutableName()
ByteString ExecutableName()
{
std::string ret;
ByteString ret;
#if defined(WIN)
char *name = (char *)malloc(64);
DWORD max = 64, res;
@ -73,7 +73,7 @@ std::string ExecutableName()
void DoRestart()
{
std::string exename = ExecutableName();
ByteString exename = ExecutableName();
if (exename.length())
{
#ifdef WIN
@ -85,7 +85,7 @@ void DoRestart()
exit(-1);
}
void OpenURI(std::string uri)
void OpenURI(ByteString uri)
{
#if defined(WIN)
ShellExecute(0, "OPEN", uri.c_str(), NULL, NULL, 0);

View File

@ -1,14 +1,14 @@
#ifndef PLATFORM_H
#define PLATFORM_H
#include <string>
#include "common/String.h"
namespace Platform
{
std::string ExecutableName();
ByteString ExecutableName();
void DoRestart();
void OpenURI(std::string uri);
void OpenURI(ByteString uri);
void Millisleep(long int t);
long unsigned int GetTime();

View File

@ -1,9 +1,8 @@
#pragma once
#include <string>
void EngineProcess();
void ClipboardPush(std::string text);
std::string ClipboardPull();
void ClipboardPush(ByteString text);
ByteString ClipboardPull();
int GetModifiers();
bool LoadWindowPosition(int scale);
void SetCursorEnabled(int enabled);

View File

@ -2,11 +2,10 @@
#include <ctime>
#include <iostream>
#include <sstream>
#include <string>
#include <fstream>
#include <vector>
#include "common/String.h"
#include "Config.h"
#include "Format.h"
#include "gui/interface/Engine.h"
@ -18,16 +17,16 @@
void EngineProcess() {}
void ClipboardPush(std::string) {}
std::string ClipboardPull() { return ""; }
void ClipboardPush(ByteString) {}
ByteString ClipboardPull() { return ""; }
int GetModifiers() { return 0; }
void SetCursorEnabled(int enabled) {}
unsigned int GetTicks() { return 0; }
void readFile(std::string filename, std::vector<char> & storage)
void readFile(ByteString filename, std::vector<char> & storage)
{
std::ifstream fileStream;
fileStream.open(std::string(filename).c_str(), std::ios::binary);
fileStream.open(filename.c_str(), std::ios::binary);
if(fileStream.is_open())
{
fileStream.seekg(0, std::ios::end);
@ -45,10 +44,10 @@ void readFile(std::string filename, std::vector<char> & storage)
}
}
void writeFile(std::string filename, std::vector<char> & fileData)
void writeFile(ByteString filename, std::vector<char> & fileData)
{
std::ofstream fileStream;
fileStream.open(std::string(filename).c_str(), std::ios::binary);
fileStream.open(filename.c_str(), std::ios::binary);
if(fileStream.is_open())
{
fileStream.write(&fileData[0], fileData.size());
@ -59,13 +58,13 @@ void writeFile(std::string filename, std::vector<char> & fileData)
int main(int argc, char *argv[])
{
ui::Engine * engine;
std::string outputPrefix, inputFilename;
ByteString outputPrefix, inputFilename;
std::vector<char> inputFile;
std::string ppmFilename, ptiFilename, ptiSmallFilename, pngFilename, pngSmallFilename;
ByteString ppmFilename, ptiFilename, ptiSmallFilename, pngFilename, pngSmallFilename;
std::vector<char> ppmFile, ptiFile, ptiSmallFile, pngFile, pngSmallFile;
inputFilename = std::string(argv[1]);
outputPrefix = std::string(argv[2]);
inputFilename = argv[1];
outputPrefix = argv[2];
ppmFilename = outputPrefix+".ppm";
ptiFilename = outputPrefix+".pti";
@ -88,7 +87,7 @@ int main(int argc, char *argv[])
catch (ParseException e)
{
//Render the save again later or something? I don't know
if (e.what() == "Save from newer version")
if (ByteString(e.what()).FromUtf8() == "Save from newer version")
throw e;
}

View File

@ -1,7 +1,7 @@
#ifdef USE_SDL
#include <map>
#include <string>
#include "common/String.h"
#include <ctime>
#include <climits>
#ifdef WIN
@ -18,9 +18,9 @@
#endif
#include <iostream>
#include <sstream>
#include <string>
#include "common/String.h"
#include "Config.h"
#include "common/String.h"
#include "graphics/Graphics.h"
#if defined(LIN)
#include "icon.h"
@ -50,6 +50,8 @@ extern "C" {
#include "gui/game/GameController.h"
#include "gui/game/GameView.h"
#include "gui/font/FontEditor.h"
#include "gui/dialogues/ErrorMessage.h"
#include "gui/dialogues/ConfirmPrompt.h"
#include "gui/interface/Keys.h"
@ -66,7 +68,7 @@ SDL_SysWMinfo sdl_wminfo;
Atom XA_CLIPBOARD, XA_TARGETS, XA_UTF8_STRING;
#endif
std::string clipboardText = "";
ByteString clipboardText = "";
int desktopWidth = 1280, desktopHeight = 1024;
@ -74,7 +76,7 @@ SDL_Surface * sdl_scrn;
int scale = 1;
bool fullscreen = false;
void ClipboardPush(std::string text)
void ClipboardPush(ByteString text)
{
clipboardText = text;
#ifdef MACOSX
@ -108,11 +110,11 @@ void ClipboardPush(std::string text)
void EventProcess(SDL_Event event);
std::string ClipboardPull()
ByteString ClipboardPull()
{
#ifdef MACOSX
const char *text = readClipboard();
return text ? std::string(text) : "";
return text ? ByteString(text).FromUtf8() : "";
#elif defined(WIN)
if (OpenClipboard(NULL))
{
@ -123,10 +125,10 @@ std::string ClipboardPull()
glbuffer = (char*)GlobalLock(cbuffer);
GlobalUnlock(cbuffer);
CloseClipboard();
return glbuffer ? std::string(glbuffer) : "";
return glbuffer ? ByteString(glbuffer) : "";
}
#elif defined(LIN) && defined(SDL_VIDEO_DRIVER_X11)
std::string text = "";
ByteString text = "";
Window selectionOwner;
sdl_wminfo.info.x11.lock_func();
selectionOwner = XGetSelectionOwner(sdl_wminfo.info.x11.display, XA_CLIPBOARD);
@ -166,7 +168,7 @@ std::string ClipboardPull()
result = XGetWindowProperty(sdl_wminfo.info.x11.display, sdl_wminfo.info.x11.window, XA_CLIPBOARD, 0, bytesLeft, 0, AnyPropertyType, &type, &format, &len, &bytesLeft, &data);
if (result == Success)
{
text = data ? (const char*)data : "";
text = data ? ByteString((char const *)data) : "";
XFree(data);
}
else
@ -524,9 +526,9 @@ unsigned int GetTicks()
return SDL_GetTicks();
}
std::map<std::string, std::string> readArguments(int argc, char * argv[])
std::map<ByteString, ByteString> readArguments(int argc, char * argv[])
{
std::map<std::string, std::string> arguments;
std::map<ByteString, ByteString> arguments;
//Defaults
arguments["scale"] = "";
@ -543,12 +545,12 @@ std::map<std::string, std::string> readArguments(int argc, char * argv[])
{
if (!strncmp(argv[i], "scale:", 6) && argv[i]+6)
{
arguments["scale"] = std::string(argv[i]+6);
arguments["scale"] = argv[i]+6;
}
else if (!strncmp(argv[i], "proxy:", 6))
{
if(argv[i]+6)
arguments["proxy"] = std::string(argv[i]+6);
arguments["proxy"] = argv[i]+6;
else
arguments["proxy"] = "false";
}
@ -570,17 +572,17 @@ std::map<std::string, std::string> readArguments(int argc, char * argv[])
}
else if (!strncmp(argv[i], "open", 5) && i+1<argc)
{
arguments["open"] = std::string(argv[i+1]);;
arguments["open"] = argv[i+1];
i++;
}
else if (!strncmp(argv[i], "ddir", 5) && i+1<argc)
{
arguments["ddir"] = std::string(argv[i+1]);
arguments["ddir"] = argv[i+1];
i++;
}
else if (!strncmp(argv[i], "ptsave", 7) && i+1<argc)
{
arguments["ptsave"] = std::string(argv[i+1]);
arguments["ptsave"] = argv[i+1];
i++;
break;
}
@ -751,11 +753,11 @@ void EventProcess(SDL_Event event)
void DoubleScreenDialog()
{
std::stringstream message;
StringBuilder message;
message << "Switching to double size mode since your screen was determined to be large enough: ";
message << desktopWidth << "x" << desktopHeight << " detected, " << WINDOWW*2 << "x" << WINDOWH*2 << " required";
message << "\nTo undo this, hit Cancel. You can toggle double size mode in settings at any time.";
if (!ConfirmPrompt::Blocking("Large screen detected", message.str()))
if (!ConfirmPrompt::Blocking("Large screen detected", message.Build()))
{
Client::Ref().SetPref("Scale", 1);
engine->SetScale(1);
@ -914,28 +916,28 @@ bool SaveWindowPosition()
#endif
void BlueScreen(const char * detailMessage){
void BlueScreen(String detailMessage){
ui::Engine * engine = &ui::Engine::Ref();
engine->g->fillrect(0, 0, engine->GetWidth(), engine->GetHeight(), 17, 114, 169, 210);
std::string errorTitle = "ERROR";
std::string errorDetails = "Details: " + std::string(detailMessage);
std::string errorHelp = "An unrecoverable fault has occurred, please report the error by visiting the website below\n"
String errorTitle = "ERROR";
String errorDetails = "Details: " + detailMessage;
String errorHelp = "An unrecoverable fault has occurred, please report the error by visiting the website below\n"
"http://" SERVER;
int currentY = 0, width, height;
int errorWidth = 0;
Graphics::textsize(errorHelp.c_str(), errorWidth, height);
Graphics::textsize(errorHelp, errorWidth, height);
engine->g->drawtext((engine->GetWidth()/2)-(errorWidth/2), ((engine->GetHeight()/2)-100) + currentY, errorTitle.c_str(), 255, 255, 255, 255);
Graphics::textsize(errorTitle.c_str(), width, height);
Graphics::textsize(errorTitle, width, height);
currentY += height + 4;
engine->g->drawtext((engine->GetWidth()/2)-(errorWidth/2), ((engine->GetHeight()/2)-100) + currentY, errorDetails.c_str(), 255, 255, 255, 255);
Graphics::textsize(errorTitle.c_str(), width, height);
Graphics::textsize(errorTitle, width, height);
currentY += height + 4;
engine->g->drawtext((engine->GetWidth()/2)-(errorWidth/2), ((engine->GetHeight()/2)-100) + currentY, errorHelp.c_str(), 255, 255, 255, 255);
Graphics::textsize(errorTitle.c_str(), width, height);
Graphics::textsize(errorTitle, width, height);
currentY += height + 4;
//Death loop
@ -983,7 +985,7 @@ int main(int argc, char * argv[])
currentHeight = WINDOWH;
std::map<std::string, std::string> arguments = readArguments(argc, argv);
std::map<ByteString, ByteString> arguments = readArguments(argc, argv);
if(arguments["ddir"].length())
#ifdef WIN
@ -1007,11 +1009,11 @@ int main(int argc, char * argv[])
if(arguments["scale"].length())
{
tempScale = format::StringToNumber<int>(arguments["scale"]);
tempScale = arguments["scale"].ToNumber<int>();
Client::Ref().SetPref("Scale", tempScale);
}
std::string proxyString = "";
ByteString proxyString = "";
if(arguments["proxy"].length())
{
if(arguments["proxy"] == "false")
@ -1027,7 +1029,7 @@ int main(int argc, char * argv[])
}
else if(Client::Ref().GetPrefString("Proxy", "").length())
{
proxyString = (Client::Ref().GetPrefString("Proxy", ""));
proxyString = (Client::Ref().GetPrefByteString("Proxy", ""));
}
Client::Ref().Initialise(proxyString);
@ -1108,6 +1110,7 @@ int main(int argc, char * argv[])
try {
#endif
#ifndef FONTEDITOR
gameController = new GameController();
engine->ShowWindow(gameController->GetView());
@ -1137,7 +1140,7 @@ int main(int argc, char * argv[])
}
catch(std::exception & e)
{
new ErrorMessage("Error", "Could not open save file:\n"+std::string(e.what())) ;
new ErrorMessage("Error", "Could not open save file:\n" + ByteString(e.what()).FromUtf8()) ;
}
}
else
@ -1160,38 +1163,32 @@ int main(int argc, char * argv[])
else
blit(engine->g->vid);
#endif
std::string ptsaveArg = arguments["ptsave"];
ByteString ptsaveArg = arguments["ptsave"];
try
{
if (ptsaveArg.find("ptsave:"))
throw std::runtime_error("Invalid save link");
std::string saveIdPart = "";
int saveId;
size_t hashPos = ptsaveArg.find('#');
if (hashPos != std::string::npos)
ByteString saveIdPart;
if (ByteString::Split split = arguments["ptsave"].SplitBy(':'))
{
saveIdPart = ptsaveArg.substr(7, hashPos-7);
if (split.Before() != "ptsave")
throw std::runtime_error("Not a ptsave link");
saveIdPart = split.After().SplitBy('#').Before();
}
else
{
saveIdPart = ptsaveArg.substr(7);
}
if (!saveIdPart.length())
throw std::runtime_error("Invalid save link");
if (!saveIdPart.size())
throw std::runtime_error("No Save ID");
#ifdef DEBUG
std::cout << "Got Ptsave: id: " << saveIdPart << std::endl;
std::cout << "Got Ptsave: id: " << saveIdPart << std::endl;
#endif
saveId = format::StringToNumber<int>(saveIdPart);
if (!saveId)
throw std::runtime_error("Invalid Save ID");
int saveId = saveIdPart.ToNumber<int>();
SaveInfo * newSave = Client::Ref().GetSave(saveId, 0);
if (!newSave)
throw std::runtime_error("Could not load save info");
std::vector<unsigned char> saveData = Client::Ref().GetSaveData(saveId, 0);
if (!saveData.size())
throw std::runtime_error("Could not load save\n" + Client::Ref().GetLastError());
throw std::runtime_error(("Could not load save\n" + Client::Ref().GetLastError()).ToUtf8());
GameSave * newGameSave = new GameSave(saveData);
newSave->SetGameSave(newGameSave);
@ -1200,10 +1197,16 @@ int main(int argc, char * argv[])
}
catch (std::exception & e)
{
new ErrorMessage("Error", e.what());
new ErrorMessage("Error", ByteString(e.what()).FromUtf8());
}
}
#else // FONTEDITOR
if(argc <= 1)
throw std::runtime_error("Not enough arguments");
engine->ShowWindow(new FontEditor(argv[1]));
#endif
//initial mouse coords
int sdl_x, sdl_y;
SDL_GetMouseState(&sdl_x, &sdl_y);
@ -1218,7 +1221,7 @@ int main(int argc, char * argv[])
}
catch(exception& e)
{
BlueScreen(e.what());
BlueScreen(ByteString(e.what()).FromUtf8());
}
#endif

View File

@ -26,7 +26,7 @@
// returns 1 on failure, 0 on success
int update_start(char *data, unsigned int len)
{
std::string exeName = Platform::ExecutableName(), updName;
ByteString exeName = Platform::ExecutableName(), updName;
FILE *f;
if (!exeName.length())
@ -34,7 +34,7 @@ int update_start(char *data, unsigned int len)
#ifdef WIN
updName = exeName;
std::string extension = exeName.substr(exeName.length() - 4);
ByteString extension = exeName.substr(exeName.length() - 4);
if (extension == ".exe")
updName = exeName.substr(0, exeName.length() - 4);
updName = updName + "_upd.exe";
@ -95,7 +95,7 @@ int update_start(char *data, unsigned int len)
int update_finish()
{
#ifdef WIN
std::string exeName = Platform::ExecutableName(), updName;
ByteString exeName = Platform::ExecutableName(), updName;
int timeout = 5, err;
#ifdef DEBUG
@ -103,7 +103,7 @@ int update_finish()
#endif
updName = exeName;
std::string extension = exeName.substr(exeName.length() - 4);
ByteString extension = exeName.substr(exeName.length() - 4);
if (extension == ".exe")
updName = exeName.substr(0, exeName.length() - 4);
updName = updName + "_upd.exe";
@ -122,7 +122,7 @@ int update_finish()
#endif
// Old versions of powder toy name their update files with _update.exe, delete that upgrade file here
updName = exeName;
std::string extension = exeName.substr(exeName.length() - 4);
ByteString extension = exeName.substr(exeName.length() - 4);
if (extension == ".exe")
updName = exeName.substr(0, exeName.length() - 4);
updName = updName + "_update.exe";

File diff suppressed because it is too large Load Diff

View File

@ -5,6 +5,7 @@
#include <vector>
#include <list>
#include "common/String.h"
#include "Config.h"
#include "common/Singleton.h"
@ -34,24 +35,24 @@ class UpdateInfo
{
public:
enum BuildType { Stable, Beta, Snapshot };
std::string File;
std::string Changelog;
ByteString File;
String Changelog;
int Major;
int Minor;
int Build;
int Time;
BuildType Type;
UpdateInfo() : File(""), Changelog(""), Major(0), Minor(0), Build(0), Time(0), Type(Stable) {}
UpdateInfo(int major, int minor, int build, std::string file, std::string changelog, BuildType type) : File(file), Changelog(changelog), Major(major), Minor(minor), Build(build), Time(0), Type(type) {}
UpdateInfo(int time, std::string file, std::string changelog, BuildType type) : File(file), Changelog(changelog), Major(0), Minor(0), Build(0), Time(time), Type(type) {}
UpdateInfo(int major, int minor, int build, ByteString file, String changelog, BuildType type) : File(file), Changelog(changelog), Major(major), Minor(minor), Build(build), Time(0), Type(type) {}
UpdateInfo(int time, ByteString file, String changelog, BuildType type) : File(file), Changelog(changelog), Major(0), Minor(0), Build(0), Time(time), Type(type) {}
};
class RequestListener;
class ClientListener;
class Client: public Singleton<Client> {
private:
std::string messageOfTheDay;
std::vector<std::pair<std::string, std::string> > serverNotifications;
String messageOfTheDay;
std::vector<std::pair<String, ByteString> > serverNotifications;
void * versionCheckRequest;
void * alternateVersionCheckRequest;
@ -59,10 +60,10 @@ private:
bool updateAvailable;
UpdateInfo updateInfo;
std::string lastError;
String lastError;
bool firstRun;
std::list<std::string> stampIDs;
std::list<ByteString> stampIDs;
unsigned lastStampTime;
int lastStampName;
@ -75,16 +76,16 @@ private:
void * activeThumbRequests[IMGCONNS];
int activeThumbRequestTimes[IMGCONNS];
int activeThumbRequestCompleteTimes[IMGCONNS];
std::string activeThumbRequestIDs[IMGCONNS];
ByteString activeThumbRequestIDs[IMGCONNS];
void notifyUpdateAvailable();
void notifyAuthUserChanged();
void notifyMessageOfTheDay();
void notifyNewNotification(std::pair<std::string, std::string> notification);
void notifyNewNotification(std::pair<String, ByteString> notification);
// internal preferences handling
Json::Value preferences;
Json::Value GetPref(Json::Value root, std::string prop, Json::Value defaultValue = Json::nullValue);
Json::Value SetPrefHelper(Json::Value root, std::string prop, Json::Value value);
Json::Value GetPref(Json::Value root, ByteString prop, Json::Value defaultValue = Json::nullValue);
Json::Value SetPrefHelper(Json::Value root, ByteString prop, Json::Value value);
// Save stealing info
Json::Value authors;
@ -107,30 +108,30 @@ public:
Client();
~Client();
std::vector<std::string> DirectorySearch(std::string directory, std::string search, std::vector<std::string> extensions);
std::vector<std::string> DirectorySearch(std::string directory, std::string search, std::string extension);
std::vector<ByteString> DirectorySearch(ByteString directory, ByteString search, std::vector<ByteString> extensions);
std::vector<ByteString> DirectorySearch(ByteString directory, ByteString search, ByteString extension);
std::string FileOpenDialogue();
ByteString FileOpenDialogue();
//std::string FileSaveDialogue();
bool DoInstallation();
std::vector<unsigned char> ReadFile(std::string filename);
std::vector<unsigned char> ReadFile(ByteString filename);
void AddServerNotification(std::pair<std::string, std::string> notification);
std::vector<std::pair<std::string, std::string> > GetServerNotifications();
void AddServerNotification(std::pair<String, ByteString> notification);
std::vector<std::pair<String, ByteString> > GetServerNotifications();
void SetMessageOfTheDay(std::string message);
std::string GetMessageOfTheDay();
void SetMessageOfTheDay(String message);
String GetMessageOfTheDay();
void Initialise(std::string proxyString);
void SetProxy(std::string proxy);
void Initialise(ByteString proxyString);
void SetProxy(ByteString proxy);
bool IsFirstRun();
int MakeDirectory(const char * dirname);
bool WriteFile(std::vector<unsigned char> fileData, std::string filename);
bool WriteFile(std::vector<char> fileData, std::string filename);
bool FileExists(std::string filename);
bool WriteFile(std::vector<unsigned char> fileData, ByteString filename);
bool WriteFile(std::vector<char> fileData, ByteString filename);
bool FileExists(ByteString filename);
void AddListener(ClientListener * listener);
void RemoveListener(ClientListener * listener);
@ -138,30 +139,30 @@ public:
RequestStatus ExecVote(int saveID, int direction);
RequestStatus UploadSave(SaveInfo & save);
SaveFile * GetStamp(std::string stampID);
void DeleteStamp(std::string stampID);
std::string AddStamp(GameSave * saveData);
std::vector<std::string> GetStamps(int start, int count);
SaveFile * GetStamp(ByteString stampID);
void DeleteStamp(ByteString stampID);
ByteString AddStamp(GameSave * saveData);
std::vector<ByteString> GetStamps(int start, int count);
void RescanStamps();
int GetStampsCount();
SaveFile * GetFirstStamp();
void MoveStampToFront(std::string stampID);
void MoveStampToFront(ByteString stampID);
void updateStamps();
RequestStatus AddComment(int saveID, std::string comment);
RequestStatus AddComment(int saveID, String comment);
//Retrieves a "UserInfo" object
RequestBroker::Request * GetUserInfoAsync(std::string username);
RequestBroker::Request * GetUserInfoAsync(ByteString username);
RequestBroker::Request * SaveUserInfoAsync(UserInfo info);
RequestBroker::Request * GetSaveDataAsync(int saveID, int saveDate);
unsigned char * GetSaveData(int saveID, int saveDate, int & dataLength);
std::vector<unsigned char> GetSaveData(int saveID, int saveDate);
LoginStatus Login(std::string username, std::string password, User & user);
LoginStatus Login(ByteString username, ByteString password, User & user);
void ClearThumbnailRequests();
std::vector<SaveInfo*> * SearchSaves(int start, int count, std::string query, std::string sort, std::string category, int & resultCount);
std::vector<std::pair<std::string, int> > * GetTags(int start, int count, std::string query, int & resultCount);
std::vector<SaveInfo*> * SearchSaves(int start, int count, String query, ByteString sort, ByteString category, int & resultCount);
std::vector<std::pair<ByteString, int> > * GetTags(int start, int count, String query, int & resultCount);
RequestBroker::Request * GetCommentsAsync(int saveID, int start, int count);
@ -169,15 +170,15 @@ public:
RequestBroker::Request * GetSaveAsync(int saveID, int saveDate);
RequestStatus DeleteSave(int saveID);
RequestStatus ReportSave(int saveID, std::string message);
RequestStatus ReportSave(int saveID, String message);
RequestStatus UnpublishSave(int saveID);
RequestStatus PublishSave(int saveID);
RequestStatus FavouriteSave(int saveID, bool favourite);
void SetAuthUser(User user);
User GetAuthUser();
std::list<std::string> * RemoveTag(int saveID, std::string tag); //TODO RequestStatus
std::list<std::string> * AddTag(int saveID, std::string tag);
std::string GetLastError() {
std::list<ByteString> * RemoveTag(int saveID, ByteString tag); //TODO RequestStatus
std::list<ByteString> * AddTag(int saveID, ByteString tag);
String GetLastError() {
return lastError;
}
RequestStatus ParseServerReturn(char *result, int status, bool json);
@ -188,19 +189,22 @@ public:
// preferences functions
void WritePrefs();
std::string GetPrefString(std::string prop, std::string defaultValue);
double GetPrefNumber(std::string prop, double defaultValue);
int GetPrefInteger(std::string prop, int defaultValue);
unsigned int GetPrefUInteger(std::string prop, unsigned int defaultValue);
bool GetPrefBool(std::string prop, bool defaultValue);
std::vector<std::string> GetPrefStringArray(std::string prop);
std::vector<double> GetPrefNumberArray(std::string prop);
std::vector<int> GetPrefIntegerArray(std::string prop);
std::vector<unsigned int> GetPrefUIntegerArray(std::string prop);
std::vector<bool> GetPrefBoolArray(std::string prop);
ByteString GetPrefByteString(ByteString prop, ByteString defaultValue);
String GetPrefString(ByteString prop, String defaultValue);
double GetPrefNumber(ByteString prop, double defaultValue);
int GetPrefInteger(ByteString prop, int defaultValue);
unsigned int GetPrefUInteger(ByteString prop, unsigned int defaultValue);
bool GetPrefBool(ByteString prop, bool defaultValue);
std::vector<ByteString> GetPrefByteStringArray(ByteString prop);
std::vector<String> GetPrefStringArray(ByteString prop);
std::vector<double> GetPrefNumberArray(ByteString prop);
std::vector<int> GetPrefIntegerArray(ByteString prop);
std::vector<unsigned int> GetPrefUIntegerArray(ByteString prop);
std::vector<bool> GetPrefBoolArray(ByteString prop);
void SetPref(std::string prop, Json::Value value);
void SetPref(std::string property, std::vector<Json::Value> value);
void SetPref(ByteString prop, Json::Value value);
void SetPref(ByteString property, std::vector<Json::Value> value);
void SetPrefUnicode(ByteString prop, String value);
};
#endif // CLIENT_H

View File

@ -11,7 +11,7 @@ public:
virtual void NotifyUpdateAvailable(Client * sender) {}
virtual void NotifyAuthUserChanged(Client * sender) {}
virtual void NotifyMessageOfTheDay(Client * sender) {}
virtual void NotifyNewNotification(Client * sender, std::pair<std::string, std::string> notification) {}
virtual void NotifyNewNotification(Client * sender, std::pair<String, ByteString> notification) {}
};

View File

@ -3,7 +3,7 @@
#include "DownloadManager.h"
#include "HTTP.h"
Download::Download(std::string uri_, bool keepAlive):
Download::Download(ByteString uri_, bool keepAlive):
http(NULL),
keepAlive(keepAlive),
downloadData(NULL),
@ -17,7 +17,7 @@ Download::Download(std::string uri_, bool keepAlive):
downloadCanceled(false),
downloadStarted(false)
{
uri = std::string(uri_);
uri = ByteString(uri_);
DownloadManager::Ref().AddDownload(this);
}
@ -31,20 +31,20 @@ Download::~Download()
}
// add post data to a request
void Download::AddPostData(std::map<std::string, std::string> data)
void Download::AddPostData(std::map<ByteString, ByteString> data)
{
postDataBoundary = FindBoundary(data, "");
postData = GetMultipartMessage(data, postDataBoundary);
}
void Download::AddPostData(std::pair<std::string, std::string> data)
void Download::AddPostData(std::pair<ByteString, ByteString> data)
{
std::map<std::string, std::string> postData;
std::map<ByteString, ByteString> postData;
postData.insert(data);
AddPostData(postData);
}
// add userID and sessionID headers to the download. Must be done after download starts for some reason
void Download::AuthHeaders(std::string ID, std::string session)
void Download::AuthHeaders(ByteString ID, ByteString session)
{
if (ID != "0")
userID = ID;
@ -68,13 +68,13 @@ void Download::Start()
}
// for persistent connections (keepAlive = true), reuse the open connection to make another request
bool Download::Reuse(std::string newuri)
bool Download::Reuse(ByteString newuri)
{
if (!keepAlive || !CheckDone() || CheckCanceled())
{
return false;
}
uri = std::string(newuri);
uri = newuri;
DownloadManager::Ref().Lock();
downloadFinished = false;
DownloadManager::Ref().Unlock();

View File

@ -1,12 +1,12 @@
#ifndef DOWNLOAD_H
#define DOWNLOAD_H
#include <map>
#include <string>
#include "common/String.h"
class DownloadManager;
class Download
{
std::string uri;
ByteString uri;
void *http;
bool keepAlive;
@ -14,25 +14,25 @@ class Download
int downloadSize;
int downloadStatus;
std::string postData;
std::string postDataBoundary;
ByteString postData;
ByteString postDataBoundary;
std::string userID;
std::string userSession;
ByteString userID;
ByteString userSession;
volatile bool downloadFinished;
volatile bool downloadCanceled;
volatile bool downloadStarted;
public:
Download(std::string uri, bool keepAlive = false);
Download(ByteString uri, bool keepAlive = false);
~Download();
void AddPostData(std::map<std::string, std::string> data);
void AddPostData(std::pair<std::string, std::string> data);
void AuthHeaders(std::string ID, std::string session);
void AddPostData(std::map<ByteString, ByteString> data);
void AddPostData(std::pair<ByteString, ByteString> data);
void AuthHeaders(ByteString ID, ByteString session);
void Start();
bool Reuse(std::string newuri);
bool Reuse(ByteString newuri);
char* Finish(int *length, int *status);
void Cancel();

View File

@ -1,6 +1,5 @@
#include "common/tpt-minmax.h"
#include <iostream>
#include <sstream>
#include <cmath>
#include <climits>
#include <memory>
@ -630,10 +629,10 @@ void GameSave::readOPS(char * data, int dataLength)
int bz2ret;
if ((bz2ret = BZ2_bzBuffToBuffDecompress((char*)bsonData, &bsonDataLen, (char*)(inputData+12), inputDataLen-12, 0, 0)) != BZ_OK)
{
throw ParseException(ParseException::Corrupt, "Unable to decompress (ret " + format::NumberToString<int>(bz2ret) + ")");
throw ParseException(ParseException::Corrupt, String::Build("Unable to decompress (ret ", bz2ret, ")"));
}
set_bson_err_handler([](const char* err) { throw ParseException(ParseException::Corrupt, "BSON error when parsing save: " + std::string(err)); });
set_bson_err_handler([](const char* err) { throw ParseException(ParseException::Corrupt, "BSON error when parsing save: " + ByteString(err).FromUtf8()); });
bson_init_data_size(&b, (char*)bsonData, bsonDataLen);
bson_iterator_init(&iter, &b);
@ -679,7 +678,7 @@ void GameSave::readOPS(char * data, int dataLength)
{
if (!strcmp(bson_iterator_key(&signiter), "text") && bson_iterator_type(&signiter) == BSON_STRING)
{
tempSign.text = format::CleanString(bson_iterator_string(&signiter), true, true, true).substr(0, 45);
tempSign.text = format::CleanString(ByteString(bson_iterator_string(&signiter)).FromUtf8(), true, true, true).Substr(0, 45);
}
else if (!strcmp(bson_iterator_key(&signiter), "justification") && bson_iterator_type(&signiter) == BSON_INT)
{
@ -764,7 +763,7 @@ void GameSave::readOPS(char * data, int dataLength)
{
if (bson_iterator_type(&subiter) == BSON_INT)
{
std::string id = std::string(bson_iterator_key(&subiter));
ByteString id = bson_iterator_key(&subiter);
int num = bson_iterator_int(&subiter);
palette.push_back(PaletteItem(id, num));
}
@ -806,13 +805,12 @@ void GameSave::readOPS(char * data, int dataLength)
if (major > SAVE_VERSION || (major == SAVE_VERSION && minor > MINOR_VERSION))
#endif
{
std::stringstream errorMessage;
#ifdef RENDERER
errorMessage << "Save from a newer version: Requires render version " << renderMajor << "." << renderMinor;
String errorMessage = String::Build("Save from a newer version: Requires render version ", renderMajor, ".", renderMinor);
#else
errorMessage << "Save from a newer version: Requires version " << major << "." << minor;
String errorMessage = String::Build("Save from a newer version: Requires version ", major, ".", minor);
#endif
throw ParseException(ParseException::WrongVersion, errorMessage.str());
throw ParseException(ParseException::WrongVersion, errorMessage);
}
#if defined(SNAPSHOT) || defined(DEBUG)
else if (major > SAVE_VERSION || (major == SAVE_VERSION && minor > MINOR_VERSION))
@ -1333,18 +1331,8 @@ void GameSave::readPSv(char * saveDataChar, int dataLength)
sign tempSign("", 0, 0, sign::Left);
//Gol data used to read older saves
int goltype[NGOL];
int grule[NGOL+1][10];
int golRulesCount;
int * golRulesT = LoadGOLRules(golRulesCount);
memcpy(grule, golRulesT, sizeof(int) * (golRulesCount*10));
free(golRulesT);
int golTypesCount;
int * golTypesT = LoadGOLTypes(golTypesCount);
memcpy(goltype, golTypesT, sizeof(int) * (golTypesCount));
free(golTypesT);
std::vector<int> goltype = LoadGOLTypes();
std::vector<std::array<int, 10> > grule = LoadGOLRules();
std::vector<Element> elements = GetElements();
@ -1418,11 +1406,7 @@ void GameSave::readPSv(char * saveDataChar, int dataLength)
int bzStatus = 0;
if ((bzStatus = BZ2_bzBuffToBuffDecompress((char *)data, (unsigned *)&size, (char *)(saveData+12), dataLength-12, 0, 0)))
{
std::stringstream bzStatusStr;
bzStatusStr << bzStatus;
throw ParseException(ParseException::Corrupt, "Cannot decompress: " + bzStatusStr.str());
}
throw ParseException(ParseException::Corrupt, String::Build("Cannot decompress: ", bzStatus));
dataLength = size;
#ifdef DEBUG
@ -1963,7 +1947,7 @@ void GameSave::readPSv(char * saveDataChar, int dataLength)
x = 254;
memcpy(tempSignText, data+p, x);
tempSignText[x] = 0;
tempSign.text = format::CleanString(tempSignText, true, true, true).substr(0, 45);
tempSign.text = format::CleanString(ByteString(tempSignText).FromUtf8(), true, true, true).Substr(0, 45);
tempSigns.push_back(tempSign);
p += x;
}
@ -2399,7 +2383,7 @@ char * GameSave::serialiseOPS(unsigned int & dataLength)
// Use unique_ptr with a custom deleter to ensure that bson_destroy is called even when an exception is thrown
std::unique_ptr<bson, decltype(bson_deleter)> b_ptr(&b, bson_deleter);
set_bson_err_handler([](const char* err) { throw BuildException("BSON error when parsing save: " + std::string(err)); });
set_bson_err_handler([](const char* err) { throw BuildException("BSON error when parsing save: " + ByteString(err).FromUtf8()); });
bson_init(&b);
bson_append_start_object(&b, "origin");
bson_append_int(&b, "majorVersion", SAVE_VERSION);
@ -2504,7 +2488,7 @@ char * GameSave::serialiseOPS(unsigned int & dataLength)
if(signs[i].text.length() && signs[i].x>=0 && signs[i].x<=fullW && signs[i].y>=0 && signs[i].y<=fullH)
{
bson_append_start_object(&b, "sign");
bson_append_string(&b, "text", signs[i].text.c_str());
bson_append_string(&b, "text", signs[i].text.ToUtf8().c_str());
bson_append_int(&b, "justification", signs[i].ju);
bson_append_int(&b, "x", signs[i].x);
bson_append_int(&b, "y", signs[i].y);
@ -2526,7 +2510,7 @@ char * GameSave::serialiseOPS(unsigned int & dataLength)
unsigned int finalDataLen = bson_size(&b);
auto outputData = std::unique_ptr<unsigned char[]>(new unsigned char[finalDataLen*2+12]);
if (!outputData)
throw BuildException("Save error, out of memory (finalData): " + format::NumberToString<unsigned int>(finalDataLen*2+12));
throw BuildException(String::Build("Save error, out of memory (finalData): ", finalDataLen*2+12));
outputData[0] = 'O';
outputData[1] = 'P';
@ -2544,7 +2528,7 @@ char * GameSave::serialiseOPS(unsigned int & dataLength)
unsigned int compressedSize = finalDataLen*2, bz2ret;
if ((bz2ret = BZ2_bzBuffToBuffCompress((char*)(outputData.get()+12), &compressedSize, (char*)finalData, bson_size(&b), 9, 0, 0)) != BZ_OK)
{
throw BuildException("Save error, could not compress (ret " + format::NumberToString<int>(bz2ret) + ")");
throw BuildException(String::Build("Save error, could not compress (ret ", bz2ret, ")"));
}
#ifdef DEBUG
@ -2563,7 +2547,7 @@ void GameSave::ConvertBsonToJson(bson_iterator *iter, Json::Value *j, int depth)
bson_iterator_subiterator(iter, &subiter);
while (bson_iterator_next(&subiter))
{
std::string key = bson_iterator_key(&subiter);
ByteString key = bson_iterator_key(&subiter);
if (bson_iterator_type(&subiter) == BSON_STRING)
(*j)[key] = bson_iterator_string(&subiter);
else if (bson_iterator_type(&subiter) == BSON_BOOL)
@ -2604,7 +2588,7 @@ std::set<int> GetNestedSaveIDs(Json::Value j)
std::set<int> saveIDs = std::set<int>();
for (Json::Value::Members::iterator iter = members.begin(), end = members.end(); iter != end; ++iter)
{
std::string member = *iter;
ByteString member = *iter;
if (member == "id" && j[member].isInt())
saveIDs.insert(j[member].asInt());
else if (j[member].isArray())
@ -2633,7 +2617,7 @@ void GameSave::ConvertJsonToBson(bson *b, Json::Value j, int depth)
Json::Value::Members members = j.getMemberNames();
for (Json::Value::Members::iterator iter = members.begin(), end = members.end(); iter != end; ++iter)
{
std::string member = *iter;
ByteString member = *iter;
if (j[member].isString())
bson_append_string(b, member.c_str(), j[member].asCString());
else if (j[member].isBool())

View File

@ -2,7 +2,7 @@
#define The_Powder_Toy_GameSave_h
#include <vector>
#include <string>
#include "common/String.h"
#include "Config.h"
#include "Misc.h"
@ -15,24 +15,24 @@
struct ParseException: public std::exception {
enum ParseResult { OK = 0, Corrupt, WrongVersion, InvalidDimensions, InternalError, MissingElement };
std::string message;
String message;
ParseResult result;
public:
ParseException(ParseResult result, std::string message_): message(message_), result(result) {}
ParseException(ParseResult result, String message_): message(message_), result(result) {}
const char * what() const throw()
{
return message.c_str();
return message.ToUtf8().c_str();
}
~ParseException() throw() {}
};
struct BuildException: public std::exception {
std::string message;
String message;
public:
BuildException(std::string message_): message(message_) {}
BuildException(String message_): message(message_) {}
const char * what() const throw()
{
return message.c_str();
return message.ToUtf8().c_str();
}
~BuildException() throw() {}
};
@ -104,7 +104,7 @@ public:
StkmData stkm;
//Element palette
typedef std::pair<std::string, int> PaletteItem;
typedef std::pair<ByteString, int> PaletteItem;
std::vector<PaletteItem> palette;
// author information

View File

@ -20,8 +20,7 @@
*/
#include <string>
#include <sstream>
#include "common/String.h"
#include <cstdio>
#include <cstdlib>
#include <cstring>
@ -193,11 +192,7 @@ void http_init(char *proxy)
free(host);
free(port);
}
std::stringstream userAgentBuilder;
userAgentBuilder << "PowderToy/" << SAVE_VERSION << "." << MINOR_VERSION << " ";
userAgentBuilder << "(" << IDENT_PLATFORM << "; " << IDENT_BUILD << "; M" << MOD_ID << ") ";
userAgentBuilder << "TPTPP/" << SAVE_VERSION << "." << MINOR_VERSION << "." << BUILD_NUM << IDENT_RELTYPE << "." << SNAPSHOT_ID;
std::string newUserAgent = userAgentBuilder.str();
ByteString newUserAgent = ByteString::Build("PowderToy/", SAVE_VERSION, ".", MINOR_VERSION, " (", IDENT_PLATFORM, "; ", IDENT_BUILD, "; M", MOD_ID, ") TPTPP/", SAVE_VERSION, ".", MINOR_VERSION, ".", BUILD_NUM, IDENT_RELTYPE, ".", SNAPSHOT_ID);
userAgent = new char[newUserAgent.length()+1];
std::copy(newUserAgent.begin(), newUserAgent.end(), userAgent);
userAgent[newUserAgent.length()] = 0;
@ -938,17 +933,17 @@ const char *http_ret_text(int ret)
// Find the boundary used in the multipart POST request
// the boundary is a string that never appears in any of the parts, ex. 'A92'
// keeps looking recursively until it finds one
std::string FindBoundary(std::map<std::string, std::string> parts, std::string boundary)
ByteString FindBoundary(std::map<ByteString, ByteString> parts, ByteString boundary)
{
// we only look for a-zA-Z0-9 chars
unsigned int map[62];
size_t blen = boundary.length();
std::fill(&map[0], &map[62], 0);
for (std::map<std::string, std::string>::iterator iter = parts.begin(); iter != parts.end(); iter++)
for (std::map<ByteString, ByteString>::iterator iter = parts.begin(); iter != parts.end(); iter++)
{
// loop through every character in each part and search for the substring, adding 1 to map for every character found (character after the substring)
for (ssize_t j = 0; j < (ssize_t)((*iter).second.length()-blen); j++)
if (!blen || (*iter).second.substr(j, blen) == boundary)
if (!blen || (*iter).second.Substr(j, blen) == boundary)
{
unsigned char ch = (*iter).second[j+blen];
if (ch >= '0' && ch <= '9')
@ -986,26 +981,25 @@ std::string FindBoundary(std::map<std::string, std::string> parts, std::string b
// Generates a MIME multipart message to be used in POST requests
// see https://en.wikipedia.org/wiki/MIME#Multipart_messages
// this function used in Download class, and eventually all http requests
std::string GetMultipartMessage(std::map<std::string, std::string> parts, std::string boundary)
ByteString GetMultipartMessage(std::map<ByteString, ByteString> parts, ByteString boundary)
{
std::stringstream data;
ByteStringBuilder data;
// loop through each part, adding it
for (std::map<std::string, std::string>::iterator iter = parts.begin(); iter != parts.end(); iter++)
for (std::map<ByteString, ByteString>::iterator iter = parts.begin(); iter != parts.end(); iter++)
{
std::string name = (*iter).first;
std::string value = (*iter).second;
ByteString name = (*iter).first;
ByteString value = (*iter).second;
data << "--" << boundary << "\r\n";
data << "Content-transfer-encoding: binary" << "\r\n";
// colon p
size_t colonP = name.find(':');
if (colonP != name.npos)
if (ByteString::Split split = name.SplitBy(':'))
{
// used to upload files (save data)
data << "content-disposition: form-data; name=\"" << name.substr(0, colonP) << "\"";
data << "filename=\"" << name.substr(colonP+1) << "\"";
data << "content-disposition: form-data; name=\"" << split.Before() << "\"";
data << "filename=\"" << split.After() << "\"";
}
else
{
@ -1016,13 +1010,13 @@ std::string GetMultipartMessage(std::map<std::string, std::string> parts, std::s
data << "\r\n";
}
data << "--" << boundary << "--\r\n";
return data.str();
return data.Build();
}
// add the header needed to make POSTS work
void http_add_multipart_header(void *ctx, std::string boundary)
void http_add_multipart_header(void *ctx, ByteString boundary)
{
std::string header = "multipart/form-data; boundary=" + boundary;
ByteString header = "multipart/form-data; boundary=" + boundary;
http_async_add_header(ctx, "Content-type", header.c_str());
}

View File

@ -21,7 +21,7 @@
#define HTTP_H
#include <map>
#include <string>
#include "common/String.h"
static const char hexChars[] = "0123456789abcdef";
static const long http_timeout = 15;
@ -43,9 +43,9 @@ char *http_async_req_stop(void *ctx, int *ret, int *len);
void http_async_req_close(void *ctx);
void http_force_close(void *ctx);
std::string FindBoundary(std::map<std::string, std::string>, std::string boundary);
std::string GetMultipartMessage(std::map<std::string, std::string>, std::string boundary);
void http_add_multipart_header(void *ctx, std::string boundary);
ByteString FindBoundary(std::map<ByteString, ByteString>, ByteString boundary);
ByteString GetMultipartMessage(std::map<ByteString, ByteString>, ByteString boundary);
void http_add_multipart_header(void *ctx, ByteString boundary);
char *http_multipart_post(const char *uri, const char *const *names, const char *const *parts, size_t *plens, const char *user, const char *pass, const char * session_id, int *ret, int *len);
void *http_multipart_post_async(const char *uri, const char *const *names, const char *const *parts, int *plens, const char *user, const char *pass, const char *session_id);

View File

@ -26,11 +26,11 @@ void SaveFile::SetThumbnail(Thumbnail * thumb)
thumbnail = thumb;
}
SaveFile::SaveFile(std::string filename):
SaveFile::SaveFile(ByteString filename):
thumbnail(NULL),
gameSave(NULL),
filename(filename),
displayName(filename),
displayName(filename.FromUtf8()),
loadingError("")
{
@ -46,32 +46,32 @@ void SaveFile::SetGameSave(GameSave * save)
gameSave = save;
}
std::string SaveFile::GetName()
ByteString SaveFile::GetName()
{
return filename;
}
void SaveFile::SetFileName(std::string fileName)
void SaveFile::SetFileName(ByteString fileName)
{
this->filename = fileName;
}
std::string SaveFile::GetDisplayName()
String SaveFile::GetDisplayName()
{
return displayName;
}
void SaveFile::SetDisplayName(std::string displayName)
void SaveFile::SetDisplayName(String displayName)
{
this->displayName = displayName;
}
std::string SaveFile::GetError()
String SaveFile::GetError()
{
return loadingError;
}
void SaveFile::SetLoadingError(std::string error)
void SaveFile::SetLoadingError(String error)
{
loadingError = error;
}

View File

@ -1,7 +1,7 @@
#ifndef SAVEFILE_H_
#define SAVEFILE_H_
#include <string>
#include "common/String.h"
class GameSave;
class Thumbnail;
@ -9,26 +9,26 @@ class Thumbnail;
class SaveFile {
public:
SaveFile(SaveFile & save);
SaveFile(std::string filename);
SaveFile(ByteString filename);
Thumbnail * GetThumbnail();
GameSave * GetGameSave();
void SetThumbnail(Thumbnail * thumb);
void SetGameSave(GameSave * save);
std::string GetDisplayName();
void SetDisplayName(std::string displayName);
std::string GetName();
void SetFileName(std::string fileName);
std::string GetError();
void SetLoadingError(std::string error);
String GetDisplayName();
void SetDisplayName(String displayName);
ByteString GetName();
void SetFileName(ByteString fileName);
String GetError();
void SetLoadingError(String error);
virtual ~SaveFile();
private:
Thumbnail * thumbnail;
GameSave * gameSave;
std::string filename;
std::string displayName;
std::string loadingError;
ByteString filename;
String displayName;
String loadingError;
};
#endif /* SAVEFILE_H_ */

View File

@ -19,14 +19,14 @@ SaveInfo::SaveInfo(SaveInfo & save):
Published(save.Published),
gameSave(NULL)
{
std::list<std::string> tagsSorted = save.tags;
std::list<ByteString> tagsSorted = save.tags;
tagsSorted.sort();
tags = tagsSorted;
if (save.gameSave)
gameSave = new GameSave(*save.gameSave);
}
SaveInfo::SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, int _votesDown, std::string _userName, std::string _name):
SaveInfo::SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, int _votesDown, ByteString _userName, String _name):
id(_id),
createdDate(_createdDate),
updatedDate(_updatedDate),
@ -47,7 +47,7 @@ SaveInfo::SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, in
}
SaveInfo::SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, int _votesDown, int _vote, std::string _userName, std::string _name, std::string description_, bool published_, std::list<std::string> tags_):
SaveInfo::SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, int _votesDown, int _vote, ByteString _userName, String _name, String description_, bool published_, std::list<ByteString> tags_):
id(_id),
createdDate(_createdDate),
updatedDate(_updatedDate),
@ -65,7 +65,7 @@ SaveInfo::SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, in
tags(),
gameSave(NULL)
{
std::list<std::string> tagsSorted = tags_;
std::list<ByteString> tagsSorted = tags_;
tagsSorted.sort();
tags=tagsSorted;
}
@ -78,20 +78,20 @@ SaveInfo::~SaveInfo()
}
}
void SaveInfo::SetName(std::string name)
void SaveInfo::SetName(String name)
{
this->name = name;
}
std::string SaveInfo::GetName()
String SaveInfo::GetName()
{
return name;
}
void SaveInfo::SetDescription(std::string description)
void SaveInfo::SetDescription(String description)
{
Description = description;
}
std::string SaveInfo::GetDescription()
String SaveInfo::GetDescription()
{
return Description;
}
@ -114,12 +114,12 @@ int SaveInfo::GetVote()
return vote;
}
void SaveInfo::SetUserName(std::string userName)
void SaveInfo::SetUserName(ByteString userName)
{
this->userName = userName;
}
std::string SaveInfo::GetUserName()
ByteString SaveInfo::GetUserName()
{
return userName;
}
@ -160,14 +160,14 @@ int SaveInfo::GetVersion()
return Version;
}
void SaveInfo::SetTags(std::list<std::string> tags)
void SaveInfo::SetTags(std::list<ByteString> tags)
{
std::list<std::string> tagsSorted = tags;
std::list<ByteString> tagsSorted = tags;
tagsSorted.sort();
this->tags=tagsSorted;
}
std::list<std::string> SaveInfo::GetTags()
std::list<ByteString> SaveInfo::GetTags()
{
return tags;
}

View File

@ -3,7 +3,7 @@
#include <list>
#include <vector>
#include <string>
#include "common/String.h"
#include <cstdlib>
#include <iostream>
@ -23,34 +23,34 @@ public:
int Views;
int Version;
std::string userName;
ByteString userName;
std::string name;
std::string Description;
String name;
String Description;
bool Published;
std::list<std::string> tags;
std::list<ByteString> tags;
GameSave * gameSave;
SaveInfo(SaveInfo & save);
SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, int _votesDown, std::string _userName, std::string _name);
SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, int _votesDown, ByteString _userName, String _name);
SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, int _votesDown, int _vote, std::string _userName, std::string _name, std::string description_, bool published_, std::list<std::string> tags);
SaveInfo(int _id, int _createdDate, int _updatedDate, int _votesUp, int _votesDown, int _vote, ByteString _userName, String _name, String description_, bool published_, std::list<ByteString> tags);
~SaveInfo();
void SetName(std::string name);
std::string GetName();
void SetName(String name);
String GetName();
void SetDescription(std::string description);
std::string GetDescription();
void SetDescription(String description);
String GetDescription();
void SetPublished(bool published);
bool GetPublished();
void SetUserName(std::string userName);
std::string GetUserName();
void SetUserName(ByteString userName);
ByteString GetUserName();
void SetID(int id);
int GetID();
@ -67,8 +67,8 @@ public:
void SetVersion(int version);
int GetVersion();
void SetTags(std::list<std::string> tags);
std::list<std::string> GetTags();
void SetTags(std::list<ByteString> tags);
std::list<ByteString> GetTags();
GameSave * GetGameSave();
void SetGameSave(GameSave * gameSave);

View File

@ -1,7 +1,7 @@
#ifndef USER_H_
#define USER_H_
#include <string>
#include "common/String.h"
class User
@ -12,11 +12,11 @@ public:
ElevationAdmin, ElevationModerator, ElevationNone
};
int UserID;
std::string Username;
std::string SessionID;
std::string SessionKey;
ByteString Username;
ByteString SessionID;
ByteString SessionKey;
Elevation UserElevation;
User(int id, std::string username):
User(int id, ByteString username):
UserID(id),
Username(username),
SessionID(""),

View File

@ -1,17 +1,17 @@
#ifndef USERINFO_H_
#define USERINFO_H_
#include <string>
#include "common/String.h"
class UserInfo
{
public:
int UserID;
int age;
std::string username;
std::string biography;
std::string location;
std::string website;
ByteString username;
String biography;
String location;
ByteString website;
int saveCount;
float averageScore;
@ -21,7 +21,7 @@ public:
int topicReplies;
int reputation;
UserInfo(int id, int age, std::string username, std::string biography, std::string location, std::string website, int saveCount, float averageScore, int highestScore, int topicCount, int topicReplies, int reputation):
UserInfo(int id, int age, ByteString username, String biography, String location, ByteString website, int saveCount, float averageScore, int highestScore, int topicCount, int topicReplies, int reputation):
UserID(id),
age(age),
username(username),

View File

@ -9,7 +9,7 @@
#include "client/HTTP.h"
#include "APIResultParser.h"
APIRequest::APIRequest(std::string url, APIResultParser * parser, ListenerHandle listener, int identifier):
APIRequest::APIRequest(ByteString url, APIResultParser * parser, ListenerHandle listener, int identifier):
RequestBroker::Request(API, listener, identifier)
{
Post = false;
@ -18,7 +18,7 @@ APIRequest::APIRequest(std::string url, APIResultParser * parser, ListenerHandle
URL = url;
}
APIRequest::APIRequest(std::string url, std::map<std::string, std::string> postData, APIResultParser * parser, ListenerHandle listener, int identifier):
APIRequest::APIRequest(ByteString url, std::map<ByteString, ByteString> postData, APIResultParser * parser, ListenerHandle listener, int identifier):
RequestBroker::Request(API, listener, identifier)
{
Post = true;
@ -81,11 +81,11 @@ RequestBroker::ProcessResponse APIRequest::Process(RequestBroker & rb)
int * postLength = new int[PostData.size()];
int i = 0;
std::map<std::string, std::string>::iterator iter = PostData.begin();
std::map<ByteString, ByteString>::iterator iter = PostData.begin();
while(iter != PostData.end())
{
std::string name = iter->first;
std::string data = iter->second;
ByteString name = iter->first;
ByteString data = iter->second;
char * cName = new char[name.length() + 1];
char * cData = new char[data.length() + 1];
std::strcpy(cName, name.c_str());
@ -103,7 +103,7 @@ RequestBroker::ProcessResponse APIRequest::Process(RequestBroker & rb)
User user = Client::Ref().GetAuthUser();
char userName[12];
char *userSession = new char[user.SessionID.length() + 1];
std::strcpy(userName, format::NumberToString<int>(user.UserID).c_str());
std::strcpy(userName, ByteString::Build(user.UserID).c_str());
std::strcpy(userSession, user.SessionID.c_str());
HTTPContext = http_multipart_post_async((char*)URL.c_str(), postNames, postData, postLength, userName, NULL, userSession);
delete[] userSession;
@ -122,7 +122,7 @@ RequestBroker::ProcessResponse APIRequest::Process(RequestBroker & rb)
User user = Client::Ref().GetAuthUser();
char userName[12];
char *userSession = new char[user.SessionID.length() + 1];
std::strcpy(userName, format::NumberToString<int>(user.UserID).c_str());
std::strcpy(userName, ByteString::Build(user.UserID).c_str());
std::strcpy(userSession, user.SessionID.c_str());
http_auth_headers(HTTPContext, userName, NULL, userSession);
delete[] userSession;

View File

@ -7,11 +7,11 @@ class APIRequest: public RequestBroker::Request
public:
bool Post;
APIResultParser * Parser;
std::string URL;
std::map<std::string, std::string> PostData;
ByteString URL;
std::map<ByteString, ByteString> PostData;
void * HTTPContext;
APIRequest(std::string url, APIResultParser * parser, ListenerHandle listener = ListenerHandle(0, (RequestListener*)0), int identifier = 0);
APIRequest(std::string url, std::map<std::string, std::string>, APIResultParser * parser, ListenerHandle listener = ListenerHandle(0, (RequestListener*)0), int identifier = 0);
APIRequest(ByteString url, APIResultParser * parser, ListenerHandle listener = ListenerHandle(0, (RequestListener*)0), int identifier = 0);
APIRequest(ByteString url, std::map<ByteString, ByteString>, APIResultParser * parser, ListenerHandle listener = ListenerHandle(0, (RequestListener*)0), int identifier = 0);
virtual RequestBroker::ProcessResponse Process(RequestBroker & rb);
virtual ~APIRequest();
virtual void Cleanup();

View File

@ -5,7 +5,7 @@
#include "graphics/Graphics.h"
#include "client/HTTP.h"
ImageRequest::ImageRequest(std::string url, int width, int height, ListenerHandle listener, int identifier):
ImageRequest::ImageRequest(ByteString url, int width, int height, ListenerHandle listener, int identifier):
Request(Image, listener, identifier)
{
URL = url;
@ -24,7 +24,7 @@ RequestBroker::ProcessResponse ImageRequest::Process(RequestBroker & rb)
VideoBuffer * image = NULL;
//Have a look at the thumbnail cache
for(std::deque<std::pair<std::string, VideoBuffer*> >::iterator iter = rb.imageCache.begin(), end = rb.imageCache.end(); iter != end; ++iter)
for(std::deque<std::pair<ByteString, VideoBuffer*> >::iterator iter = rb.imageCache.begin(), end = rb.imageCache.end(); iter != end; ++iter)
{
if((*iter).first == URL)
{
@ -71,7 +71,7 @@ RequestBroker::ProcessResponse ImageRequest::Process(RequestBroker & rb)
delete rb.imageCache.front().second;
rb.imageCache.pop_front();
}
rb.imageCache.push_back(std::pair<std::string, VideoBuffer*>(URL, image));
rb.imageCache.push_back(std::pair<ByteString, VideoBuffer*>(URL, image));
}
else
{

View File

@ -4,11 +4,11 @@ class ImageRequest: public RequestBroker::Request
{
public:
int Width, Height;
std::string URL;
ByteString URL;
int RequestTime;
void * HTTPContext;
bool started = false;
ImageRequest(std::string url, int width, int height, ListenerHandle listener, int identifier = 0);
ImageRequest(ByteString url, int width, int height, ListenerHandle listener, int identifier = 0);
virtual RequestBroker::ProcessResponse Process(RequestBroker & rb);
virtual ~ImageRequest();
virtual void Cleanup();

View File

@ -1,7 +1,6 @@
#include <algorithm>
#include <iostream>
#include <typeinfo>
#include <sstream>
#include <ctime>
#include "RequestBroker.h"
#include "RequestListener.h"
@ -35,7 +34,7 @@ RequestBroker::RequestBroker()
RequestBroker::~RequestBroker()
{
for(std::deque<std::pair<std::string, VideoBuffer*> >::iterator iter = imageCache.begin(), end = imageCache.end(); iter != end; ++iter)
for(std::deque<std::pair<ByteString, VideoBuffer*> >::iterator iter = imageCache.begin(), end = imageCache.end(); iter != end; ++iter)
{
delete (*iter).second;
}
@ -98,23 +97,22 @@ void RequestBroker::RenderThumbnail(GameSave * gameSave, bool decorations, bool
void RequestBroker::RetrieveThumbnail(int saveID, int saveDate, int width, int height, RequestListener * tListener)
{
std::stringstream urlStream;
urlStream << "http://" << STATICSERVER << "/" << saveID;
ByteStringBuilder url;
url << "http://" << STATICSERVER << "/" << saveID;
if(saveDate)
{
urlStream << "_" << saveDate;
url << "_" << saveDate;
}
urlStream << "_small.pti";
url << "_small.pti";
RetrieveImage(urlStream.str(), width, height, tListener);
RetrieveImage(url.Build(), width, height, tListener);
}
void RequestBroker::RetrieveAvatar(std::string username, int width, int height, RequestListener * tListener)
void RequestBroker::RetrieveAvatar(ByteString username, int width, int height, RequestListener * tListener)
{
std::stringstream urlStream;
urlStream << "http://" << STATICSERVER << "/avatars/" << username << ".pti";
ByteString url = ByteString::Build("http://", STATICSERVER, "/avatars/", username, ".pti");
RetrieveImage(urlStream.str(), width, height, tListener);
RetrieveImage(url, width, height, tListener);
}
void RequestBroker::Start(Request * request, RequestListener * tListener, int identifier)
@ -130,7 +128,7 @@ void RequestBroker::Start(Request * request, RequestListener * tListener, int id
assureRunning();
}
void RequestBroker::RetrieveImage(std::string imageUrl, int width, int height, RequestListener * tListener)
void RequestBroker::RetrieveImage(ByteString imageUrl, int width, int height, RequestListener * tListener)
{
ListenerHandle handle = AttachRequestListener(tListener);

View File

@ -3,7 +3,7 @@
#include <list>
#include <utility>
#include <deque>
#include <string>
#include "common/String.h"
#include "common/tpt-thread.h"
#include "Config.h"
@ -33,7 +33,7 @@ private:
std::vector<ListenerHandle> validListeners;
std::deque<std::pair<std::string, VideoBuffer*> > imageCache;
std::deque<std::pair<ByteString, VideoBuffer*> > imageCache;
std::queue<Request*> completeQueue;
std::vector<Request*> requestQueue;
@ -51,12 +51,12 @@ public:
void Shutdown();
void FlushThumbQueue();
void RetrieveImage(std::string imageUrl, int width, int height, RequestListener * tListener);
void RetrieveImage(ByteString imageUrl, int width, int height, RequestListener * tListener);
void RenderThumbnail(GameSave * gameSave, bool decorations, bool fire, int width, int height, RequestListener * tListener);
void RenderThumbnail(GameSave * gameSave, int width, int height, RequestListener * tListener);
void RetrieveThumbnail(int saveID, int saveDate, int width, int height, RequestListener * tListener);
void RetrieveThumbnail(int saveID, int width, int height, RequestListener * tListener);
void RetrieveAvatar(std::string username, int width, int height, RequestListener * tListener);
void RetrieveAvatar(ByteString username, int width, int height, RequestListener * tListener);
void Start(Request * request, RequestListener * tLIstener, int identifier = 0);
bool CheckRequestListener(ListenerHandle handle);

View File

@ -10,7 +10,7 @@
#include "client/HTTP.h"
#include "APIResultParser.h"
WebRequest::WebRequest(std::string url, ListenerHandle listener, int identifier):
WebRequest::WebRequest(ByteString url, ListenerHandle listener, int identifier):
RequestBroker::Request(API, listener, identifier)
{
Post = false;
@ -18,7 +18,7 @@ WebRequest::WebRequest(std::string url, ListenerHandle listener, int identifier)
URL = url;
}
WebRequest::WebRequest(std::string url, std::map<std::string, std::string> postData, ListenerHandle listener, int identifier):
WebRequest::WebRequest(ByteString url, std::map<ByteString, ByteString> postData, ListenerHandle listener, int identifier):
RequestBroker::Request(API, listener, identifier)
{
Post = true;
@ -81,11 +81,11 @@ RequestBroker::ProcessResponse WebRequest::Process(RequestBroker & rb)
int * postLength = new int[PostData.size()];
int i = 0;
std::map<std::string, std::string>::iterator iter = PostData.begin();
std::map<ByteString, ByteString>::iterator iter = PostData.begin();
while(iter != PostData.end())
{
std::string name = iter->first;
std::string data = iter->second;
ByteString name = iter->first;
ByteString data = iter->second;
char * cName = new char[name.length() + 1];
char * cData = new char[data.length() + 1];
std::strcpy(cName, name.c_str());
@ -106,7 +106,7 @@ RequestBroker::ProcessResponse WebRequest::Process(RequestBroker & rb)
User user = Client::Ref().GetAuthUser();
char userName[12];
char *userSession = new char[user.SessionID.length() + 1];
std::strcpy(userName, format::NumberToString<int>(user.UserID).c_str());
std::strcpy(userName, ByteString::Build(user.UserID).c_str());
std::strcpy(userSession, user.SessionID.c_str());
HTTPContext = http_multipart_post_async((char*)URL.c_str(), postNames, postData, postLength, userName, NULL, userSession);
delete[] userSession;
@ -125,7 +125,7 @@ RequestBroker::ProcessResponse WebRequest::Process(RequestBroker & rb)
User user = Client::Ref().GetAuthUser();
char userName[12];
char *userSession = new char[user.SessionID.length() + 1];
std::strcpy(userName, format::NumberToString<int>(user.UserID).c_str());
std::strcpy(userName, ByteString::Build(user.UserID).c_str());
std::strcpy(userSession, user.SessionID.c_str());
http_auth_headers(HTTPContext, userName, NULL, userSession);
delete[] userSession;

View File

@ -5,11 +5,11 @@ class WebRequest: public RequestBroker::Request
{
public:
bool Post;
std::string URL;
std::map<std::string, std::string> PostData;
ByteString URL;
std::map<ByteString, ByteString> PostData;
void * HTTPContext;
WebRequest(std::string url, ListenerHandle listener = ListenerHandle(0, (RequestListener*)0), int identifier = 0);
WebRequest(std::string url, std::map<std::string, std::string>, ListenerHandle listener = ListenerHandle(0, (RequestListener*)0), int identifier = 0);
WebRequest(ByteString url, ListenerHandle listener = ListenerHandle(0, (RequestListener*)0), int identifier = 0);
WebRequest(ByteString url, std::map<ByteString, ByteString>, ListenerHandle listener = ListenerHandle(0, (RequestListener*)0), int identifier = 0);
virtual RequestBroker::ProcessResponse Process(RequestBroker & rb);
virtual ~WebRequest();
virtual void Cleanup();

231
src/common/Format.h Normal file
View File

@ -0,0 +1,231 @@
#pragma once
#include <functional>
#include <ios>
#include "common/String.h"
template<typename T> class FormatProxy
{
T const &value;
inline FormatProxy(T const &_value): value(_value) {}
public:
inline void Write(StringBuilder &b) { b << value; }
};
namespace Format
{
template<typename T, std::ios_base::fmtflags set, std::ios_base::fmtflags reset> struct FlagsOverride
{
T value;
inline FlagsOverride(T _value): value(_value) {}
};
template<std::ios_base::fmtflags set, std::ios_base::fmtflags reset> struct FlagsOverride<void, set, reset>
{
inline FlagsOverride() {}
};
template<typename T> struct FillOverride
{
T value;
size_t fill;
inline FillOverride(T _value, size_t _fill): value(_value), fill(_fill) {}
};
template<> struct FillOverride<void>
{
String::value_type fill;
inline FillOverride(size_t _fill): fill(_fill) {}
};
template<typename T> struct WidthOverride
{
T value;
size_t width;
inline WidthOverride(T _value, size_t _width): value(_value), width(_width) {}
};
template<> struct WidthOverride<void>
{
size_t width;
inline WidthOverride(size_t _width): width(_width) {}
};
template<typename T> struct PrecisionOverride
{
T value;
size_t precision;
inline PrecisionOverride(T _value, size_t _precision): value(_value), precision(_precision) {}
};
template<> struct PrecisionOverride<void>
{
size_t precision;
inline PrecisionOverride(size_t _precision): precision(_precision) {}
};
template<typename T> inline FlagsOverride<T, std::ios_base::oct, std::ios_base::basefield> Oct(T value) { return FlagsOverride<T, std::ios_base::oct, std::ios_base::basefield>(value); }
template<typename T> inline FlagsOverride<T, std::ios_base::dec, std::ios_base::basefield> Dec(T value) { return FlagsOverride<T, std::ios_base::dec, std::ios_base::basefield>(value); }
template<typename T> inline FlagsOverride<T, std::ios_base::hex, std::ios_base::basefield> Hex(T value) { return FlagsOverride<T, std::ios_base::hex, std::ios_base::basefield>(value); }
inline FlagsOverride<void, std::ios_base::oct, std::ios_base::basefield> Oct() { return FlagsOverride<void, std::ios_base::oct, std::ios_base::basefield>(); }
inline FlagsOverride<void, std::ios_base::dec, std::ios_base::basefield> Dec() { return FlagsOverride<void, std::ios_base::dec, std::ios_base::basefield>(); }
inline FlagsOverride<void, std::ios_base::hex, std::ios_base::basefield> Hex() { return FlagsOverride<void, std::ios_base::hex, std::ios_base::basefield>(); }
template<typename T> inline FlagsOverride<T, std::ios_base::uppercase, std::ios_base::uppercase> Uppercase(T value) { return FlagsOverride<T, std::ios_base::uppercase, std::ios_base::uppercase>(value); }
template<typename T> inline FlagsOverride<T, std::ios_base::showpoint, std::ios_base::showpoint> ShowPoint(T value) { return FlagsOverride<T, std::ios_base::showpoint, std::ios_base::showpoint>(value); }
template<typename T> inline FlagsOverride<T, std::ios_base::fmtflags{}, std::ios_base::uppercase> NoUppercase(T value) { return FlagsOverride<T, std::ios_base::fmtflags{}, std::ios_base::uppercase>(value); }
template<typename T> inline FlagsOverride<T, std::ios_base::fmtflags{}, std::ios_base::showpoint> NoShowPoint(T value) { return FlagsOverride<T, std::ios_base::fmtflags{}, std::ios_base::showpoint>(value); }
inline FlagsOverride<void, std::ios_base::uppercase, std::ios_base::uppercase> Uppercase() { return FlagsOverride<void, std::ios_base::uppercase, std::ios_base::uppercase>(); }
inline FlagsOverride<void, std::ios_base::showpoint, std::ios_base::showpoint> ShowPoint() { return FlagsOverride<void, std::ios_base::showpoint, std::ios_base::showpoint>(); }
inline FlagsOverride<void, std::ios_base::skipws, std::ios_base::skipws> SkipWS() { return FlagsOverride<void, std::ios_base::skipws, std::ios_base::skipws>(); }
inline FlagsOverride<void, std::ios_base::fmtflags{}, std::ios_base::uppercase> NoUppercase() { return FlagsOverride<void, std::ios_base::fmtflags{}, std::ios_base::uppercase>(); }
inline FlagsOverride<void, std::ios_base::fmtflags{}, std::ios_base::showpoint> NoShowPoint() { return FlagsOverride<void, std::ios_base::fmtflags{}, std::ios_base::showpoint>(); }
inline FlagsOverride<void, std::ios_base::fmtflags{}, std::ios_base::skipws> NoSkipWS() { return FlagsOverride<void, std::ios_base::fmtflags{}, std::ios_base::skipws>(); }
template<typename T> inline FlagsOverride<T, std::ios_base::fixed, std::ios_base::floatfield> Fixed(T value) { return FlagsOverride<T, std::ios_base::fixed, std::ios_base::floatfield>(value); }
template<typename T> inline FlagsOverride<T, std::ios_base::scientific, std::ios_base::floatfield> Scientific(T value) { return FlagsOverride<T, std::ios_base::scientific, std::ios_base::floatfield>(value); }
template<typename T> inline FlagsOverride<T, std::ios_base::fmtflags{}, std::ios_base::floatfield> FloatDefault(T value) { return FlagsOverride<T, std::ios_base::fmtflags{}, std::ios_base::floatfield>(value); }
inline FlagsOverride<void, std::ios_base::fixed, std::ios_base::floatfield> Fixed() { return FlagsOverride<void, std::ios_base::fixed, std::ios_base::floatfield>(); }
inline FlagsOverride<void, std::ios_base::scientific, std::ios_base::floatfield> Scientific() { return FlagsOverride<void, std::ios_base::scientific, std::ios_base::floatfield>(); }
inline FlagsOverride<void, std::ios_base::fmtflags{}, std::ios_base::floatfield> FloatDefault() { return FlagsOverride<void, std::ios_base::fmtflags{}, std::ios_base::floatfield>(); }
template<typename T> inline FillOverride<T> Fill(T value, String::value_type fill) { return FillOverride<T>(value, fill); }
template<typename T> inline WidthOverride<T> Width(T value, size_t width) { return WidthOverride<T>(value, width); }
template<typename T> inline PrecisionOverride<T> Precision(T value, size_t precision) { return PrecisionOverride<T>(value, precision); }
inline FillOverride<void> Fill(String::value_type fill) { return FillOverride<void>(fill); }
inline WidthOverride<void> Width(size_t width) { return WidthOverride<void>(width); }
inline PrecisionOverride<void> Precision(size_t precision) { return PrecisionOverride<void>(precision); }
};
template<typename T, std::ios_base::fmtflags set, std::ios_base::fmtflags reset> inline ByteStringBuilder &operator<<(ByteStringBuilder &b, Format::FlagsOverride<T, set, reset> data)
{
std::ios_base::fmtflags oldflags = b.flags;
b.flags = (b.flags & ~reset) | set;
b << data.value;
b.flags = oldflags;
return b;
}
template<std::ios_base::fmtflags set, std::ios_base::fmtflags reset> inline ByteStringBuilder &operator<<(ByteStringBuilder &b, Format::FlagsOverride<void, set, reset> data)
{
b.flags = (b.flags & ~reset) | set;
return b;
}
template<typename T> inline ByteStringBuilder &operator<<(ByteStringBuilder &b, Format::FillOverride<T> data)
{
size_t oldfill = b.fill;
b.fill = data.fill;
b << data.value;
b.fill = oldfill;
return b;
}
inline ByteStringBuilder &operator<<(ByteStringBuilder &b, Format::FillOverride<void> data)
{
b.fill = data.fill;
return b;
}
template<typename T> inline ByteStringBuilder &operator<<(ByteStringBuilder &b, Format::WidthOverride<T> data)
{
String::value_type oldfill = b.fill;
if(oldfill == ' ')
b.fill = '0';
size_t oldwidth = b.width;
b.width = data.width;
b << data.value;
b.width = oldwidth;
b.fill = oldfill;
return b;
}
inline ByteStringBuilder &operator<<(ByteStringBuilder &b, Format::WidthOverride<void> data)
{
if(b.fill == ' ')
b.fill = '0';
b.width = data.width;
return b;
}
template<typename T> inline ByteStringBuilder &operator<<(ByteStringBuilder &b, Format::PrecisionOverride<T> data)
{
std::ios_base::fmtflags oldflags = b.flags;
if(!(oldflags & std::ios_base::floatfield))
b.flags |= std::ios_base::fixed;
size_t oldprecision = b.precision;
b.precision = data.precision;
b << data.value;
b.precision = oldprecision;
b.flags = oldflags;
return b;
}
inline ByteStringBuilder &operator<<(ByteStringBuilder &b, Format::PrecisionOverride<void> data)
{
if(!(b.flags & std::ios_base::floatfield))
b.flags |= std::ios_base::fixed;
b.precision = data.precision;
return b;
}
template<typename T, std::ios_base::fmtflags set, std::ios_base::fmtflags reset> inline StringBuilder &operator<<(StringBuilder &b, Format::FlagsOverride<T, set, reset> data)
{
std::ios_base::fmtflags oldflags = b.flags;
b.flags = (b.flags & ~reset) | set;
b << data.value;
b.flags = oldflags;
return b;
}
template<std::ios_base::fmtflags set, std::ios_base::fmtflags reset> inline StringBuilder &operator<<(StringBuilder &b, Format::FlagsOverride<void, set, reset> data)
{
b.flags = (b.flags & ~reset) | set;
return b;
}
template<typename T> inline StringBuilder &operator<<(StringBuilder &b, Format::FillOverride<T> data)
{
size_t oldfill = b.fill;
b.fill = data.fill;
b << data.value;
b.fill = oldfill;
return b;
}
inline StringBuilder &operator<<(StringBuilder &b, Format::FillOverride<void> data)
{
b.fill = data.fill;
return b;
}
template<typename T> inline StringBuilder &operator<<(StringBuilder &b, Format::WidthOverride<T> data)
{
String::value_type oldfill = b.fill;
if(oldfill == ' ')
b.fill = '0';
size_t oldwidth = b.width;
b.width = data.width;
b << data.value;
b.width = oldwidth;
b.fill = oldfill;
return b;
}
inline StringBuilder &operator<<(StringBuilder &b, Format::WidthOverride<void> data)
{
if(b.fill == ' ')
b.fill = '0';
b.width = data.width;
return b;
}
template<typename T> inline StringBuilder &operator<<(StringBuilder &b, Format::PrecisionOverride<T> data)
{
std::ios_base::fmtflags oldflags = b.flags;
if(!(oldflags & std::ios_base::floatfield))
b.flags |= std::ios_base::fixed;
size_t oldprecision = b.precision;
b.precision = data.precision;
b << data.value;
b.precision = oldprecision;
b.flags = oldflags;
return b;
}
inline StringBuilder &operator<<(StringBuilder &b, Format::PrecisionOverride<void> data)
{
if(!(b.flags & std::ios_base::floatfield))
b.flags |= std::ios_base::fixed;
b.precision = data.precision;
return b;
}

631
src/common/String.cpp Normal file
View File

@ -0,0 +1,631 @@
#include <sstream>
#include <vector>
#include <locale>
#include <codecvt>
#include <limits>
#include "String.h"
ByteString ConversionError::formatError(ByteString::value_type const *at, ByteString::value_type const *upto)
{
std::stringstream ss;
ss << "Could not convert sequence to UTF-8:";
for(int i = 0; i < 4 && at + i < upto; i++)
ss << " " << std::hex << (unsigned int)std::make_unsigned<ByteString::value_type>::type(at[i]);
return ss.str();
}
static std::codecvt_utf8<String::value_type> convert(1);
std::vector<ByteString> ByteString::PartitionBy(value_type ch, bool includeEmpty) const
{
std::vector<ByteString> result;
size_t at = 0;
while(true)
{
Split split = SplitBy(ch, at);
ByteString part = split.Before();
if(includeEmpty || part.size())
result.push_back(part);
at = split.PositionAfter();
if(!split)
break;
}
return result;
}
std::vector<ByteString> ByteString::PartitionBy(ByteString const &str, bool includeEmpty) const
{
std::vector<ByteString> result;
size_t at = 0;
while(true)
{
Split split = SplitBy(str, at);
ByteString part = split.Before();
if(includeEmpty || part.size())
result.push_back(part);
at = split.PositionAfter();
if(!split)
break;
}
return result;
}
std::vector<ByteString> ByteString::PartitionByAny(ByteString const &str, bool includeEmpty) const
{
std::vector<ByteString> result;
size_t at = 0;
while(true)
{
Split split = SplitByAny(str, at);
ByteString part = split.Before();
if(includeEmpty || part.size())
result.push_back(part);
at = split.PositionAfter();
if(!split)
break;
}
return result;
}
ByteString &ByteString::Substitute(ByteString const &needle, ByteString const &replacement)
{
size_t needleSize = needle.size();
size_t replacementSize = replacement.size();
size_t at = super::find(needle);
while(at != npos)
{
super::replace(at, needleSize, replacement);
at += replacementSize + !needleSize;
at = super::find(needle, at);
}
return *this;
}
String ByteString::FromUtf8(bool ignoreError) const
{
std::vector<String::value_type> destination = std::vector<String::value_type>(size(), String::value_type());
std::codecvt_utf8<String::value_type>::state_type state;
ByteString::value_type const *from = data(), *from_next;
String::value_type *to = destination.data(), *to_next;
while(true)
{
std::codecvt_utf8<String::value_type>::result result = convert.in(state, from, data() + size(), from_next, to, destination.data() + destination.size(), to_next);
from = from_next;
to = to_next;
if(result == std::codecvt_base::ok || result == std::codecvt_base::noconv)
{
destination.resize(to - destination.data());
return String(destination.data(), destination.size());
}
else if(result == std::codecvt_base::partial && to == destination.data() + destination.size())
{
String::value_type *old_data = destination.data();
destination.resize(2 * destination.size());
to = destination.data() + (to - old_data);
}
else
{
if(!ignoreError)
throw ConversionError(from, data() + size());
if(to == destination.data() + destination.size())
{
String::value_type *old_data = destination.data();
destination.resize(2 * destination.size());
to = destination.data() + (to - old_data);
}
*(to++) = std::make_unsigned<ByteString::value_type>::type(*(from++));
}
}
}
std::vector<String> String::PartitionBy(value_type ch, bool includeEmpty) const
{
std::vector<String> result;
size_t at = 0;
while(true)
{
Split split = SplitBy(ch, at);
String part = split.Before();
if(includeEmpty || part.size())
result.push_back(part);
at = split.PositionAfter();
if(!split)
break;
}
return result;
}
std::vector<String> String::PartitionBy(String const &str, bool includeEmpty) const
{
std::vector<String> result;
size_t at = 0;
while(true)
{
Split split = SplitBy(str, at);
String part = split.Before();
if(includeEmpty || part.size())
result.push_back(part);
at = split.PositionAfter();
if(!split)
break;
}
return result;
}
std::vector<String> String::PartitionByAny(String const &str, bool includeEmpty) const
{
std::vector<String> result;
size_t at = 0;
while(true)
{
Split split = SplitByAny(str, at);
String part = split.Before();
if(includeEmpty || part.size())
result.push_back(part);
at = split.PositionAfter();
if(!split)
break;
}
return result;
}
String &String::Substitute(String const &needle, String const &replacement)
{
size_t needleSize = needle.size();
size_t replacementSize = replacement.size();
size_t at = super::find(needle);
while(at != npos)
{
super::replace(at, needleSize, replacement);
at += replacementSize + !needleSize;
at = super::find(needle, at);
}
return *this;
}
ByteString String::ToUtf8() const
{
std::vector<ByteString::value_type> destination = std::vector<ByteString::value_type>(size(), ByteString::value_type());
std::codecvt_utf8<String::value_type>::state_type state;
String::value_type const *from = data(), *from_next;
ByteString::value_type *to = destination.data(), *to_next;
while(true)
{
std::codecvt_utf8<String::value_type>::result result = convert.out(state, from, data() + size(), from_next, to, destination.data() + destination.size(), to_next);
from = from_next;
to = to_next;
if(result == std::codecvt_base::ok || result == std::codecvt_base::noconv)
{
destination.resize(to - destination.data());
return ByteString(destination.data(), destination.size());
}
else if(result == std::codecvt_base::error)
{
throw ConversionError(true);
}
else if(result == std::codecvt_base::partial)
{
ByteString::value_type *old_data = destination.data();
destination.resize(2 * destination.size());
to = destination.data() + (to - old_data);
}
}
}
inline String::value_type widen_wchar(wchar_t ch)
{
return std::make_unsigned<wchar_t>::type(ch);
}
inline bool representable_wchar(String::value_type ch)
{
return ch < String::value_type(std::make_unsigned<wchar_t>::type(std::numeric_limits<wchar_t>::max()));
}
inline wchar_t narrow_wchar(String::value_type ch)
{
return wchar_t(ch);
}
char const numberChars[] = "-.+0123456789ABCDEFXabcdefx";
ByteString numberByteString(numberChars);
String numberString(numberChars);
static thread_local struct LocaleImpl
{
std::basic_stringstream<char> stream;
std::basic_stringstream<wchar_t> wstream;
LocaleImpl()
{
stream.imbue(std::locale::classic());
wstream.imbue(std::locale::classic());
}
inline void PrepareStream(ByteStringBuilder &b)
{
stream.flags(b.flags);
stream.width(b.width);
stream.precision(b.precision);
stream.fill(b.fill);
stream.clear();
}
inline void PrepareStream(ByteString const &str, size_t pos, std::ios_base::fmtflags set, std::ios_base::fmtflags reset)
{
stream.flags((std::ios_base::dec & ~ reset) | set);
std::basic_string<char> bstr;
while(pos < str.size() && numberByteString.Contains(str[pos]))
bstr.push_back(narrow_wchar(str[pos++]));
stream.str(bstr);
stream.clear();
}
inline void FlushStream(ByteStringBuilder &b)
{
std::basic_string<char> str = stream.str();
b.AddChars(str.data(), str.size());
stream.str(std::basic_string<char>());
}
inline void FlushStream()
{
stream.str(std::basic_string<char>());
}
inline void PrepareWStream(StringBuilder &b)
{
wstream.flags(b.flags);
wstream.width(b.width);
wstream.precision(b.precision);
wstream.fill(b.fill);
wstream.clear();
}
inline void PrepareWStream(String const &str, size_t pos, std::ios_base::fmtflags set, std::ios_base::fmtflags reset)
{
wstream.flags((std::ios_base::dec & ~ reset) | set);
std::basic_string<wchar_t> wstr;
while(pos < str.size() && representable_wchar(str[pos]) && numberString.Contains(str[pos]))
wstr.push_back(narrow_wchar(str[pos++]));
wstream.str(wstr);
wstream.clear();
}
inline void FlushWStream(StringBuilder &b)
{
std::basic_string<wchar_t> wstr = wstream.str();
std::vector<String::value_type> chars; // operator new?
chars.reserve(wstr.size());
for(wchar_t ch : wstream.str())
chars.push_back(widen_wchar(ch));
b.AddChars(chars.data(), chars.size());
wstream.str(std::basic_string<wchar_t>());
}
inline void FlushWStream()
{
wstream.str(std::basic_string<wchar_t>());
}
}
LocaleImpl;
ByteString ByteStringBuilder::Build() const
{
return ByteString(buffer.begin(), buffer.end());
}
void ByteStringBuilder::AddChars(ByteString::value_type const *data, size_t count)
{
buffer.reserve(buffer.size() + count);
buffer.insert(buffer.end(), data, data + count);
}
ByteStringBuilder &operator<<(ByteStringBuilder &b, short int data)
{
LocaleImpl.PrepareStream(b);
LocaleImpl.stream << data;
LocaleImpl.FlushStream(b);
return b;
}
ByteStringBuilder &operator<<(ByteStringBuilder &b, int data)
{
LocaleImpl.PrepareStream(b);
LocaleImpl.stream << data;
LocaleImpl.FlushStream(b);
return b;
}
ByteStringBuilder &operator<<(ByteStringBuilder &b, long int data)
{
LocaleImpl.PrepareStream(b);
LocaleImpl.stream << data;
LocaleImpl.FlushStream(b);
return b;
}
ByteStringBuilder &operator<<(ByteStringBuilder &b, long long int data)
{
LocaleImpl.PrepareStream(b);
LocaleImpl.stream << data;
LocaleImpl.FlushStream(b);
return b;
}
ByteStringBuilder &operator<<(ByteStringBuilder &b, unsigned short int data)
{
LocaleImpl.PrepareStream(b);
LocaleImpl.stream << data;
LocaleImpl.FlushStream(b);
return b;
}
ByteStringBuilder &operator<<(ByteStringBuilder &b, unsigned int data)
{
LocaleImpl.PrepareStream(b);
LocaleImpl.stream << data;
LocaleImpl.FlushStream(b);
return b;
}
ByteStringBuilder &operator<<(ByteStringBuilder &b, unsigned long int data)
{
LocaleImpl.PrepareStream(b);
LocaleImpl.stream << data;
LocaleImpl.FlushStream(b);
return b;
}
ByteStringBuilder &operator<<(ByteStringBuilder &b, unsigned long long int data)
{
LocaleImpl.PrepareStream(b);
LocaleImpl.stream << data;
LocaleImpl.FlushStream(b);
return b;
}
ByteStringBuilder &operator<<(ByteStringBuilder &b, ByteString::value_type data)
{
b.AddChars(&data, 1);
return b;
}
ByteStringBuilder &operator<<(ByteStringBuilder &b, ByteString::value_type const *data)
{
return b << ByteString(data);
}
ByteStringBuilder &operator<<(ByteStringBuilder &b, ByteString const &data)
{
b.AddChars(data.data(), data.size());
return b;
}
ByteStringBuilder &operator<<(ByteStringBuilder &b, float data)
{
LocaleImpl.PrepareStream(b);
LocaleImpl.stream << data;
LocaleImpl.FlushStream(b);
return b;
}
ByteStringBuilder &operator<<(ByteStringBuilder &b, double data)
{
LocaleImpl.PrepareStream(b);
LocaleImpl.stream << data;
LocaleImpl.FlushStream(b);
return b;
}
ByteString::Split ByteString::SplitSigned(long long int &value, size_t pos, std::ios_base::fmtflags set, std::ios_base::fmtflags reset) const
{
LocaleImpl.PrepareStream(*this, pos, set, reset);
LocaleImpl.stream >> value;
if(LocaleImpl.stream.fail())
{
LocaleImpl.FlushStream();
return Split(*this, pos, npos, 0, false);
}
LocaleImpl.stream.clear();
Split split(*this, pos, pos + LocaleImpl.stream.tellg(), 0, false);
LocaleImpl.FlushStream();
return split;
}
ByteString::Split ByteString::SplitUnsigned(unsigned long long int &value, size_t pos, std::ios_base::fmtflags set, std::ios_base::fmtflags reset) const
{
LocaleImpl.PrepareStream(*this, pos, set, reset);
LocaleImpl.stream >> value;
if(LocaleImpl.stream.fail())
{
LocaleImpl.FlushStream();
return Split(*this, pos, npos, 0, false);
}
LocaleImpl.stream.clear();
Split split(*this, pos, pos + LocaleImpl.stream.tellg(), 0, false);
LocaleImpl.FlushStream();
return split;
}
ByteString::Split ByteString::SplitFloat(double &value, size_t pos, std::ios_base::fmtflags set, std::ios_base::fmtflags reset) const
{
LocaleImpl.PrepareStream(*this, pos, set, reset);
LocaleImpl.stream >> value;
if(LocaleImpl.stream.fail())
{
LocaleImpl.FlushStream();
return Split(*this, pos, npos, 0, false);
}
LocaleImpl.stream.clear();
Split split(*this, pos, pos + LocaleImpl.stream.tellg(), 0, false);
LocaleImpl.FlushStream();
return split;
}
String StringBuilder::Build() const
{
return String(buffer.begin(), buffer.end());
}
void StringBuilder::AddChars(String::value_type const *data, size_t count)
{
buffer.reserve(buffer.size() + count);
buffer.insert(buffer.end(), data, data + count);
}
StringBuilder &operator<<(StringBuilder &b, short int data)
{
LocaleImpl.PrepareWStream(b);
LocaleImpl.wstream << data;
LocaleImpl.FlushWStream(b);
return b;
}
StringBuilder &operator<<(StringBuilder &b, int data)
{
LocaleImpl.PrepareWStream(b);
LocaleImpl.wstream << data;
LocaleImpl.FlushWStream(b);
return b;
}
StringBuilder &operator<<(StringBuilder &b, long int data)
{
LocaleImpl.PrepareWStream(b);
LocaleImpl.wstream << data;
LocaleImpl.FlushWStream(b);
return b;
}
StringBuilder &operator<<(StringBuilder &b, long long int data)
{
LocaleImpl.PrepareWStream(b);
LocaleImpl.wstream << data;
LocaleImpl.FlushWStream(b);
return b;
}
StringBuilder &operator<<(StringBuilder &b, unsigned short int data)
{
LocaleImpl.PrepareWStream(b);
LocaleImpl.wstream << data;
LocaleImpl.FlushWStream(b);
return b;
}
StringBuilder &operator<<(StringBuilder &b, unsigned int data)
{
LocaleImpl.PrepareWStream(b);
LocaleImpl.wstream << data;
LocaleImpl.FlushWStream(b);
return b;
}
StringBuilder &operator<<(StringBuilder &b, unsigned long int data)
{
LocaleImpl.PrepareWStream(b);
LocaleImpl.wstream << data;
LocaleImpl.FlushWStream(b);
return b;
}
StringBuilder &operator<<(StringBuilder &b, unsigned long long int data)
{
LocaleImpl.PrepareWStream(b);
LocaleImpl.wstream << data;
LocaleImpl.FlushWStream(b);
return b;
}
StringBuilder &operator<<(StringBuilder &b, ByteString::value_type data)
{
String::value_type ch = data;
b.AddChars(&ch, 1);
return b;
}
StringBuilder &operator<<(StringBuilder &b, String::value_type data)
{
b.AddChars(&data, 1);
return b;
}
StringBuilder &operator<<(StringBuilder &b, String::value_type const *data)
{
return b << String(data);
}
StringBuilder &operator<<(StringBuilder &b, String const &data)
{
b.AddChars(data.data(), data.size());
return b;
}
StringBuilder &operator<<(StringBuilder &b, float data)
{
LocaleImpl.PrepareWStream(b);
LocaleImpl.wstream << data;
LocaleImpl.FlushWStream(b);
return b;
}
StringBuilder &operator<<(StringBuilder &b, double data)
{
LocaleImpl.PrepareWStream(b);
LocaleImpl.wstream << data;
LocaleImpl.FlushWStream(b);
return b;
}
String::Split String::SplitSigned(long long int &value, size_t pos, std::ios_base::fmtflags set, std::ios_base::fmtflags reset) const
{
LocaleImpl.PrepareWStream(*this, pos, set, reset);
LocaleImpl.wstream >> value;
if(LocaleImpl.wstream.fail())
{
LocaleImpl.FlushWStream();
return Split(*this, pos, npos, 0, false);
}
LocaleImpl.wstream.clear();
Split split(*this, pos, pos + LocaleImpl.wstream.tellg(), 0, false);
LocaleImpl.FlushWStream();
return split;
}
String::Split String::SplitUnsigned(unsigned long long int &value, size_t pos, std::ios_base::fmtflags set, std::ios_base::fmtflags reset) const
{
LocaleImpl.PrepareWStream(*this, pos, set, reset);
LocaleImpl.wstream >> value;
if(LocaleImpl.wstream.fail())
{
LocaleImpl.FlushWStream();
return Split(*this, pos, npos, 0, false);
}
LocaleImpl.wstream.clear();
Split split(*this, pos, pos + LocaleImpl.wstream.tellg(), 0, false);
LocaleImpl.FlushWStream();
return split;
}
String::Split String::SplitFloat(double &value, size_t pos, std::ios_base::fmtflags set, std::ios_base::fmtflags reset) const
{
LocaleImpl.PrepareWStream(*this, pos, set, reset);
LocaleImpl.wstream >> value;
if(LocaleImpl.wstream.fail())
{
LocaleImpl.FlushWStream();
return Split(*this, pos, npos, 0, false);
}
LocaleImpl.wstream.clear();
Split split(*this, pos, pos + LocaleImpl.wstream.tellg(), 0, false);
LocaleImpl.FlushWStream();
return split;
}

481
src/common/String.h Normal file
View File

@ -0,0 +1,481 @@
#pragma once
#include <stdexcept>
#include <sstream>
#include <vector>
#include <string>
#include <ios>
class ByteStringBuilder;
class String;
class StringBuilder;
namespace Format { template<typename T, std::ios_base::fmtflags set, std::ios_base::fmtflags reset> struct FlagsOverride; }
template<typename T> class SplitBase
{
T const &parent;
size_t posFrom;
size_t posBefore;
size_t posAfter;
bool reverse;
inline SplitBase(T const &_parent, size_t _posFrom, size_t _posBefore, size_t offset, bool _reverse):
parent(_parent),
posFrom(_posFrom),
posBefore(_posBefore),
posAfter(_posBefore == T::npos ? T::npos : _posBefore + offset),
reverse(_reverse)
{}
public:
inline T Before(bool includeSeparator = false) const
{
if(posBefore == T::npos)
return reverse ? T() : parent.Substr(posFrom);
return parent.Between(reverse ? 0 : posFrom, includeSeparator ? posAfter : posBefore);
}
inline T After(bool includeSeparator = false) const
{
if(posBefore == T::npos)
return reverse ? parent.Substr(0, posFrom) : T();
return parent.Between(includeSeparator ? posBefore : posAfter, reverse ? posFrom : T::npos);
}
inline size_t PositionFrom() const { return posFrom; }
inline size_t PositionBefore() const { return posBefore; }
inline size_t PositionAfter() const { return posAfter; }
inline operator bool() const { return posBefore != T::npos; }
friend T;
};
class ByteString : public std::basic_string<char>
{
using super = std::basic_string<char>;
public:
inline ByteString(): super() {}
inline ByteString(value_type ch): super(1, ch) {}
inline ByteString(size_type count, value_type ch): super(count, ch) {}
inline ByteString(value_type const *ch, size_type count): super(ch, count) {}
inline ByteString(value_type const *ch): super(ch) {}
template<class It> inline ByteString(It first, It last): super(first, last) {}
inline ByteString(super const &other): super(other) {}
inline ByteString(super &&other): super(std::move(other)) {}
inline ByteString(ByteString const &other): super(other) {}
inline ByteString(ByteString &&other): super(std::move(other)) {}
inline ByteString &operator=(ByteString const &other) { super::operator=(other); return *this; }
inline ByteString &operator=(ByteString &&other) { super::operator=(other); return *this; }
inline ByteString &operator+=(ByteString const &other) { super::operator+=(other); return *this; }
inline ByteString &operator+=(ByteString &&other) { super::operator+=(std::move(other)); return *this; }
inline ByteString Substr(size_t pos = 0, size_t count = npos) const { return super::substr(pos, count); }
inline ByteString SubstrFromEnd(size_t rpos = 0, size_t rcount = npos) const { return super::substr(rcount == npos || rcount > rpos ? 0 : rpos - rcount, size() - rpos); }
inline ByteString Between(size_t from, size_t to) const { return to == npos ? super::substr(from) : from >= to ? ByteString() : super::substr(from, to - from); }
inline bool Contains(value_type ch) const { return super::find(ch) != npos; }
inline bool Contains(ByteString const &other) const { return super::find(other) != npos; }
inline bool BeginsWith(ByteString const &other) const { return !super::compare(0, other.size(), other); }
inline bool EndsWith(ByteString const &other) const { return !super::compare(size() - other.size(), other.size(), other); }
using Split = SplitBase<ByteString>;
inline Split SplitBy(value_type ch, size_t pos = 0) const { return Split(*this, pos, super::find(ch, pos), 1, false); }
inline Split SplitBy(ByteString const &str, size_t pos = 0) const { return Split(*this, pos, super::find(str, pos), str.size(), false); }
inline Split SplitByAny(ByteString const &str, size_t pos = 0) const { return Split(*this, pos, super::find_first_of(str, pos), 1, false); }
inline Split SplitByNot(ByteString const &str, size_t pos = 0) const { return Split(*this, pos, super::find_first_not_of(str, pos), 1, false); }
inline Split SplitFromEndBy(value_type ch, size_t pos = npos) const { return Split(*this, pos, super::rfind(ch, pos), 1, true); }
inline Split SplitFromEndBy(ByteString const &str, size_t pos = npos) const { return Split(*this, pos, super::find(str, pos), str.size(), true); }
inline Split SplitFromEndByAny(ByteString const &str, size_t pos = npos) const { return Split(*this, pos, super::find_last_of(str, pos), 1, true); }
inline Split SplitFromEndByNot(ByteString const &str, size_t pos = npos) const { return Split(*this, pos, super::find_last_not_of(str, pos), 1, true); }
private:
Split SplitSigned(long long int &, size_t, std::ios_base::fmtflags, std::ios_base::fmtflags) const;
Split SplitUnsigned(unsigned long long int &, size_t, std::ios_base::fmtflags, std::ios_base::fmtflags) const;
Split SplitFloat(double &, size_t, std::ios_base::fmtflags, std::ios_base::fmtflags) const;
public:
template<typename T> inline Split SplitSigned(T &ref, size_t pos, std::ios_base::fmtflags set, std::ios_base::fmtflags reset) const
{
long long int value = 0;
Split split = SplitSigned(value, pos, set, reset);
ref = value;
return split;
}
template<typename T> inline Split SplitUnsigned(T &ref, size_t pos, std::ios_base::fmtflags set, std::ios_base::fmtflags reset) const
{
unsigned long long int value = 0;
Split split = SplitUnsigned(value, pos, set, reset);
ref = value;
return split;
}
template<typename T> inline Split SplitFloat(T &ref, size_t pos, std::ios_base::fmtflags set, std::ios_base::fmtflags reset) const
{
double value = 0;
Split split = SplitFloat(value, pos, set, reset);
ref = value;
return split;
}
inline Split SplitNumber(short int &ref, size_t pos = 0) const { return SplitSigned(ref, pos, std::ios_base::fmtflags(), std::ios_base::fmtflags()); }
inline Split SplitNumber(int &ref, size_t pos = 0) const { return SplitSigned(ref, pos, std::ios_base::fmtflags(), std::ios_base::fmtflags()); }
inline Split SplitNumber(long int &ref, size_t pos = 0) const { return SplitSigned(ref, pos, std::ios_base::fmtflags(), std::ios_base::fmtflags()); }
inline Split SplitNumber(long long int &ref, size_t pos = 0) const { return SplitSigned(ref, pos, std::ios_base::fmtflags(), std::ios_base::fmtflags()); }
inline Split SplitNumber(unsigned short int &ref, size_t pos = 0) const { return SplitUnsigned(ref, pos, std::ios_base::fmtflags(), std::ios_base::fmtflags()); }
inline Split SplitNumber(unsigned int &ref, size_t pos = 0) const { return SplitUnsigned(ref, pos, std::ios_base::fmtflags(), std::ios_base::fmtflags()); }
inline Split SplitNumber(unsigned long int &ref, size_t pos = 0) const { return SplitUnsigned(ref, pos, std::ios_base::fmtflags(), std::ios_base::fmtflags()); }
inline Split SplitNumber(unsigned long long int &ref, size_t pos = 0) const { return SplitUnsigned(ref, pos, std::ios_base::fmtflags(), std::ios_base::fmtflags()); }
inline Split SplitNumber(float &ref, size_t pos = 0) const { return SplitFloat(ref, pos, std::ios_base::fmtflags(), std::ios_base::fmtflags()); }
inline Split SplitNumber(double &ref, size_t pos = 0) const { return SplitFloat(ref, pos, std::ios_base::fmtflags(), std::ios_base::fmtflags()); }
template<std::ios_base::fmtflags set, std::ios_base::fmtflags reset> inline Split SplitNumber(short int &ref, Format::FlagsOverride<void, set, reset>, size_t pos = 0) const { return SplitSigned(ref, pos, set, reset); }
template<std::ios_base::fmtflags set, std::ios_base::fmtflags reset> inline Split SplitNumber(int &ref, Format::FlagsOverride<void, set, reset>, size_t pos = 0) const { return SplitSigned(ref, pos, set, reset); }
template<std::ios_base::fmtflags set, std::ios_base::fmtflags reset> inline Split SplitNumber(long int &ref, Format::FlagsOverride<void, set, reset>, size_t pos = 0) const { return SplitSigned(ref, pos, set, reset); }
template<std::ios_base::fmtflags set, std::ios_base::fmtflags reset> inline Split SplitNumber(long long int &ref, Format::FlagsOverride<void, set, reset>, size_t pos = 0) const { return SplitSigned(ref, pos, set, reset); }
template<std::ios_base::fmtflags set, std::ios_base::fmtflags reset> inline Split SplitNumber(unsigned short int &ref, Format::FlagsOverride<void, set, reset>, size_t pos = 0) const { return SplitUnsigned(ref, pos, set, reset); }
template<std::ios_base::fmtflags set, std::ios_base::fmtflags reset> inline Split SplitNumber(unsigned int &ref, Format::FlagsOverride<void, set, reset>, size_t pos = 0) const { return SplitUnsigned(ref, pos, set, reset); }
template<std::ios_base::fmtflags set, std::ios_base::fmtflags reset> inline Split SplitNumber(unsigned long int &ref, Format::FlagsOverride<void, set, reset>, size_t pos = 0) const { return SplitUnsigned(ref, pos, set, reset); }
template<std::ios_base::fmtflags set, std::ios_base::fmtflags reset> inline Split SplitNumber(unsigned long long int &ref, Format::FlagsOverride<void, set, reset>, size_t pos = 0) const { return SplitUnsigned(ref, pos, set, reset); }
template<std::ios_base::fmtflags set, std::ios_base::fmtflags reset> inline Split SplitNumber(float &ref, Format::FlagsOverride<void, set, reset>, size_t pos = 0) const { return SplitFloat(ref, pos, set, reset); }
template<std::ios_base::fmtflags set, std::ios_base::fmtflags reset> inline Split SplitNumber(double &ref, Format::FlagsOverride<void, set, reset>, size_t pos = 0) const { return SplitFloat(ref, pos, set, reset); }
template<typename T> T ToNumber(bool noThrow = false) const
{
T value = T();
Split split = SplitNumber(value);
if(split.PositionBefore() != size())
return noThrow ? T() : throw std::runtime_error("Not a number");
return value;
}
template<typename T, std::ios_base::fmtflags set, std::ios_base::fmtflags reset> inline T ToNumber(Format::FlagsOverride<void, set, reset> fmt, bool noThrow = false) const
{
T value = T();
Split split = SplitNumber(value, fmt);
if(split.PositionBefore() != size())
return noThrow ? T() : throw std::runtime_error("Not a number");
return value;
}
std::vector<ByteString> PartitionBy(value_type ch, bool includeEmpty = false) const;
std::vector<ByteString> PartitionBy(ByteString const &str, bool includeEmpty = false) const;
std::vector<ByteString> PartitionByAny(ByteString const &str, bool includeEmpty = false) const;
ByteString &Substitute(ByteString const &needle, ByteString const &replacement);
inline ByteString &Insert(size_t pos, ByteString const &str) { super::insert(pos, str); return *this; }
inline ByteString &Erase(size_t pos, size_t count) { super::erase(pos, count); return *this; }
inline ByteString &EraseBetween(size_t from, size_t to) { if(from < to) super::erase(from, to - from); return *this; }
String FromUtf8(bool ignoreError = true) const;
inline String FromAscii() const;
template<typename... Ts> static ByteString Build(Ts&&... args);
};
inline ByteString operator+(ByteString const &lhs, ByteString const &rhs) { return static_cast<std::basic_string<char> const &>(lhs) + static_cast<std::basic_string<char> const &>(rhs); }
inline ByteString operator+(ByteString const &lhs, ByteString &&rhs) { return static_cast<std::basic_string<char> const &>(lhs) + static_cast<std::basic_string<char> &&>(rhs); }
inline ByteString operator+(ByteString &&lhs, ByteString const &rhs) { return static_cast<std::basic_string<char> &&>(lhs) + static_cast<std::basic_string<char> const &>(rhs); }
inline ByteString operator+(ByteString &&lhs, ByteString &&rhs) { return static_cast<std::basic_string<char> &&>(lhs) + static_cast<std::basic_string<char> &&>(rhs); }
inline ByteString operator+(ByteString const &lhs, std::basic_string<char> const &rhs) { return static_cast<std::basic_string<char> const &>(lhs) + rhs; }
inline ByteString operator+(ByteString const &lhs, std::basic_string<char> &&rhs) { return static_cast<std::basic_string<char> const &>(lhs) + std::move(rhs); }
inline ByteString operator+(ByteString &&lhs, std::basic_string<char> const &rhs) { return static_cast<std::basic_string<char> &&>(lhs) + rhs; }
inline ByteString operator+(ByteString &&lhs, std::basic_string<char> &&rhs) { return static_cast<std::basic_string<char> &&>(lhs) + std::move(rhs); }
inline ByteString operator+(ByteString const &lhs, ByteString::value_type rhs) { return static_cast<std::basic_string<char> const &>(lhs) + rhs; }
inline ByteString operator+(ByteString &&lhs, ByteString::value_type rhs) { return static_cast<std::basic_string<char> &&>(lhs) + rhs; }
inline ByteString operator+(ByteString const &lhs, ByteString::value_type const *rhs) { return static_cast<std::basic_string<char> const &>(lhs) + rhs; }
inline ByteString operator+(ByteString &&lhs, ByteString::value_type const *rhs) { return static_cast<std::basic_string<char> &&>(lhs) + rhs; }
inline ByteString operator+(std::basic_string<char> const &lhs, ByteString const &rhs) { return lhs + static_cast<std::basic_string<char> const &>(rhs); }
inline ByteString operator+(std::basic_string<char> const &lhs, ByteString &&rhs) { return lhs + static_cast<std::basic_string<char> &&>(rhs); }
inline ByteString operator+(std::basic_string<char> &&lhs, ByteString const &rhs) { return std::move(lhs) + static_cast<std::basic_string<char> const &>(rhs); }
inline ByteString operator+(std::basic_string<char> &&lhs, ByteString &&rhs) { return std::move(lhs) + static_cast<std::basic_string<char> &&>(rhs); }
inline ByteString operator+(ByteString::value_type lhs, ByteString const &rhs) { return lhs + static_cast<std::basic_string<char> const &>(rhs); }
inline ByteString operator+(ByteString::value_type lhs, ByteString &&rhs) { return lhs + static_cast<std::basic_string<char> &&>(rhs); }
inline ByteString operator+(ByteString::value_type const *lhs, ByteString const &rhs) { return lhs + static_cast<std::basic_string<char> const &>(rhs); }
inline ByteString operator+(ByteString::value_type const *lhs, ByteString &&rhs) { return lhs + static_cast<std::basic_string<char> &&>(rhs); }
inline bool operator==(ByteString const &lhs, ByteString const &rhs) { return static_cast<std::basic_string<char> const &>(lhs) == static_cast<std::basic_string<char> const &>(rhs); }
inline bool operator==(ByteString const &lhs, std::basic_string<char> const &rhs) { return static_cast<std::basic_string<char> const &>(lhs) == rhs; }
inline bool operator==(ByteString const &lhs, ByteString::value_type const *rhs) { return static_cast<std::basic_string<char> const &>(lhs) == rhs; }
inline bool operator==(std::basic_string<char> const &lhs, ByteString const &rhs) { return lhs == static_cast<std::basic_string<char> const &>(rhs); }
inline bool operator==(ByteString::value_type const *lhs, ByteString const &rhs) { return lhs == static_cast<std::basic_string<char> const &>(rhs); }
inline bool operator!=(ByteString const &lhs, ByteString const &rhs) { return static_cast<std::basic_string<char> const &>(lhs) != static_cast<std::basic_string<char> const &>(rhs); }
inline bool operator!=(ByteString const &lhs, std::basic_string<char> const &rhs) { return static_cast<std::basic_string<char> const &>(lhs) != rhs; }
inline bool operator!=(ByteString const &lhs, ByteString::value_type const *rhs) { return static_cast<std::basic_string<char> const &>(lhs) != rhs; }
inline bool operator!=(std::basic_string<char> const &lhs, ByteString const &rhs) { return lhs != static_cast<std::basic_string<char> const &>(rhs); }
inline bool operator!=(ByteString::value_type const *lhs, ByteString const &rhs) { return lhs != static_cast<std::basic_string<char> const &>(rhs); }
class String : public std::basic_string<char32_t>
{
using super = std::basic_string<char32_t>;
public:
inline String(): super() {}
inline String(value_type ch): super(1, ch) {}
inline String(size_type count, value_type ch): super(count, ch) {}
inline String(value_type const *ch, size_type count): super(ch, count) {}
inline String(value_type const *ch): super(ch) {}
template<class It> inline String(It first, It last): super(first, last) {}
inline String(super const &other): super(other) {}
inline String(super &&other): super(std::move(other)) {}
inline String(String const &other): super(other) {}
inline String(String &&other): super(std::move(other)) {}
template<size_t N> inline String(ByteString::value_type const (&ch)[N]): super(ByteString(ch, N - 1).FromAscii()) {}
inline String &operator=(String const &other) { super::operator=(other); return *this; }
inline String &operator=(String &&other) { super::operator=(other); return *this; }
inline String &operator+=(String const &other) { super::operator+=(other); return *this; }
inline String &operator+=(String &&other) { super::operator+=(std::move(other)); return *this; }
inline String Substr(size_t pos = 0, size_t count = npos) const { return super::substr(pos, count); }
inline String SubstrFromEnd(size_t rpos = 0, size_t rcount = npos) const { return super::substr(rcount == npos || rcount > rpos ? 0 : rpos - rcount, size() - rpos); }
inline String Between(size_t from, size_t to) const { return to == npos ? super::substr(from) : from >= to ? String() : super::substr(from, to - from); }
inline bool Contains(value_type ch) const { return super::find(ch) != npos; }
inline bool Contains(String const &other) const { return super::find(other) != npos; }
inline bool BeginsWith(String const &other) const { return !super::compare(0, other.size(), other); }
inline bool EndsWith(String const &other) const { return !super::compare(size() - other.size(), other.size(), other); }
using Split = SplitBase<String>;
inline Split SplitBy(value_type ch, size_t pos = 0) const { return Split(*this, pos, super::find(ch, pos), 1, false); }
inline Split SplitBy(String const &str, size_t pos = 0) const { return Split(*this, pos, super::find(str, pos), str.size(), false); }
inline Split SplitByAny(String const &str, size_t pos = 0) const { return Split(*this, pos, super::find_first_of(str, pos), 1, false); }
inline Split SplitByNot(String const &str, size_t pos = 0) const { return Split(*this, pos, super::find_first_not_of(str, pos), 1, false); }
inline Split SplitFromEndBy(value_type ch, size_t pos = npos) const { return Split(*this, pos, super::rfind(ch, pos), 1, true); }
inline Split SplitFromEndBy(String const &str, size_t pos = npos) const { return Split(*this, pos, super::find(str, pos), str.size(), true); }
inline Split SplitFromEndByAny(String const &str, size_t pos = npos) const { return Split(*this, pos, super::find_last_of(str, pos), 1, true); }
inline Split SplitFromEndByNot(String const &str, size_t pos = npos) const { return Split(*this, pos, super::find_last_not_of(str, pos), 1, true); }
private:
Split SplitSigned(long long int &, size_t, std::ios_base::fmtflags, std::ios_base::fmtflags) const;
Split SplitUnsigned(unsigned long long int &, size_t, std::ios_base::fmtflags, std::ios_base::fmtflags) const;
Split SplitFloat(double &, size_t, std::ios_base::fmtflags, std::ios_base::fmtflags) const;
public:
template<typename T> inline Split SplitSigned(T &ref, size_t pos, std::ios_base::fmtflags set, std::ios_base::fmtflags reset) const
{
long long int value = 0;
Split split = SplitSigned(value, pos, set, reset);
ref = value;
return split;
}
template<typename T> inline Split SplitUnsigned(T &ref, size_t pos, std::ios_base::fmtflags set, std::ios_base::fmtflags reset) const
{
unsigned long long int value = 0;
Split split = SplitUnsigned(value, pos, set, reset);
ref = value;
return split;
}
template<typename T> inline Split SplitFloat(T &ref, size_t pos, std::ios_base::fmtflags set, std::ios_base::fmtflags reset) const
{
double value = 0;
Split split = SplitFloat(value, pos, set, reset);
ref = value;
return split;
}
inline Split SplitNumber(short int &ref, size_t pos = 0) const { return SplitSigned(ref, pos, std::ios_base::fmtflags(), std::ios_base::fmtflags()); }
inline Split SplitNumber(int &ref, size_t pos = 0) const { return SplitSigned(ref, pos, std::ios_base::fmtflags(), std::ios_base::fmtflags()); }
inline Split SplitNumber(long int &ref, size_t pos = 0) const { return SplitSigned(ref, pos, std::ios_base::fmtflags(), std::ios_base::fmtflags()); }
inline Split SplitNumber(long long int &ref, size_t pos = 0) const { return SplitSigned(ref, pos, std::ios_base::fmtflags(), std::ios_base::fmtflags()); }
inline Split SplitNumber(unsigned short int &ref, size_t pos = 0) const { return SplitUnsigned(ref, pos, std::ios_base::fmtflags(), std::ios_base::fmtflags()); }
inline Split SplitNumber(unsigned int &ref, size_t pos = 0) const { return SplitUnsigned(ref, pos, std::ios_base::fmtflags(), std::ios_base::fmtflags()); }
inline Split SplitNumber(unsigned long int &ref, size_t pos = 0) const { return SplitUnsigned(ref, pos, std::ios_base::fmtflags(), std::ios_base::fmtflags()); }
inline Split SplitNumber(unsigned long long int &ref, size_t pos = 0) const { return SplitUnsigned(ref, pos, std::ios_base::fmtflags(), std::ios_base::fmtflags()); }
inline Split SplitNumber(float &ref, size_t pos = 0) const { return SplitFloat(ref, pos, std::ios_base::fmtflags(), std::ios_base::fmtflags()); }
inline Split SplitNumber(double &ref, size_t pos = 0) const { return SplitFloat(ref, pos, std::ios_base::fmtflags(), std::ios_base::fmtflags()); }
template<std::ios_base::fmtflags set, std::ios_base::fmtflags reset> inline Split SplitNumber(short int &ref, Format::FlagsOverride<void, set, reset>, size_t pos = 0) const { return SplitSigned(ref, pos, set, reset); }
template<std::ios_base::fmtflags set, std::ios_base::fmtflags reset> inline Split SplitNumber(int &ref, Format::FlagsOverride<void, set, reset>, size_t pos = 0) const { return SplitSigned(ref, pos, set, reset); }
template<std::ios_base::fmtflags set, std::ios_base::fmtflags reset> inline Split SplitNumber(long int &ref, Format::FlagsOverride<void, set, reset>, size_t pos = 0) const { return SplitSigned(ref, pos, set, reset); }
template<std::ios_base::fmtflags set, std::ios_base::fmtflags reset> inline Split SplitNumber(long long int &ref, Format::FlagsOverride<void, set, reset>, size_t pos = 0) const { return SplitSigned(ref, pos, set, reset); }
template<std::ios_base::fmtflags set, std::ios_base::fmtflags reset> inline Split SplitNumber(unsigned short int &ref, Format::FlagsOverride<void, set, reset>, size_t pos = 0) const { return SplitUnsigned(ref, pos, set, reset); }
template<std::ios_base::fmtflags set, std::ios_base::fmtflags reset> inline Split SplitNumber(unsigned int &ref, Format::FlagsOverride<void, set, reset>, size_t pos = 0) const { return SplitUnsigned(ref, pos, set, reset); }
template<std::ios_base::fmtflags set, std::ios_base::fmtflags reset> inline Split SplitNumber(unsigned long int &ref, Format::FlagsOverride<void, set, reset>, size_t pos = 0) const { return SplitUnsigned(ref, pos, set, reset); }
template<std::ios_base::fmtflags set, std::ios_base::fmtflags reset> inline Split SplitNumber(unsigned long long int &ref, Format::FlagsOverride<void, set, reset>, size_t pos = 0) const { return SplitUnsigned(ref, pos, set, reset); }
template<std::ios_base::fmtflags set, std::ios_base::fmtflags reset> inline Split SplitNumber(float &ref, Format::FlagsOverride<void, set, reset>, size_t pos = 0) const { return SplitFloat(ref, pos, set, reset); }
template<std::ios_base::fmtflags set, std::ios_base::fmtflags reset> inline Split SplitNumber(double &ref, Format::FlagsOverride<void, set, reset>, size_t pos = 0) const { return SplitFloat(ref, pos, set, reset); }
template<typename T> T ToNumber(bool noThrow = false) const
{
T value = T();
Split split = SplitNumber(value);
if(split.PositionBefore() != size())
return noThrow ? T() : throw std::runtime_error("Not a number");
return value;
}
template<typename T, std::ios_base::fmtflags set, std::ios_base::fmtflags reset> inline T ToNumber(Format::FlagsOverride<void, set, reset> fmt, bool noThrow = false) const
{
T value = T();
Split split = SplitNumber(value, fmt);
if(split.PositionBefore() != size())
return noThrow ? T() : throw std::runtime_error("Not a number");
return value;
}
std::vector<String> PartitionBy(value_type ch, bool includeEmpty = false) const;
std::vector<String> PartitionBy(String const &str, bool includeEmpty = false) const;
std::vector<String> PartitionByAny(String const &str, bool includeEmpty = false) const;
String &Substitute(String const &needle, String const &replacement);
inline String &Insert(size_t pos, String const &str) { super::insert(pos, str); return *this; }
inline String &Erase(size_t pos, size_t count) { super::erase(pos, count); return *this; }
inline String &EraseBetween(size_t from, size_t to) { if(from < to) super::erase(from, to - from); return *this; }
ByteString ToUtf8() const;
ByteString ToAscii() const;
template<typename... Ts> static String Build(Ts&&... args);
};
inline String operator+(String const &lhs, String const &rhs) { return static_cast<std::basic_string<char32_t> const &>(lhs) + static_cast<std::basic_string<char32_t> const &>(rhs); }
inline String operator+(String const &lhs, String &&rhs) { return static_cast<std::basic_string<char32_t> const &>(lhs) + static_cast<std::basic_string<char32_t> &&>(rhs); }
inline String operator+(String &&lhs, String const &rhs) { return static_cast<std::basic_string<char32_t> &&>(lhs) + static_cast<std::basic_string<char32_t> const &>(rhs); }
inline String operator+(String &&lhs, String &&rhs) { return static_cast<std::basic_string<char32_t> &&>(lhs) + static_cast<std::basic_string<char32_t> &&>(rhs); }
inline String operator+(String const &lhs, std::basic_string<char32_t> const &rhs) { return static_cast<std::basic_string<char32_t> const &>(lhs) + rhs; }
inline String operator+(String const &lhs, std::basic_string<char32_t> &&rhs) { return static_cast<std::basic_string<char32_t> const &>(lhs) + std::move(rhs); }
inline String operator+(String &&lhs, std::basic_string<char32_t> const &rhs) { return static_cast<std::basic_string<char32_t> &&>(lhs) + rhs; }
inline String operator+(String &&lhs, std::basic_string<char32_t> &&rhs) { return static_cast<std::basic_string<char32_t> &&>(lhs) + std::move(rhs); }
inline String operator+(String const &lhs, String::value_type rhs) { return static_cast<std::basic_string<char32_t> const &>(lhs) + rhs; }
inline String operator+(String &&lhs, String::value_type rhs) { return static_cast<std::basic_string<char32_t> &&>(lhs) + rhs; }
inline String operator+(String const &lhs, String::value_type const *rhs) { return static_cast<std::basic_string<char32_t> const &>(lhs) + rhs; }
inline String operator+(String &&lhs, String::value_type const *rhs) { return static_cast<std::basic_string<char32_t> &&>(lhs) + rhs; }
template<size_t N> inline String operator+(String const &lhs, ByteString::value_type const (&rhs)[N]) { return static_cast<std::basic_string<char32_t> const &>(lhs) + std::move(ByteString(rhs).FromAscii()); }
template<size_t N> inline String operator+(String &&lhs, ByteString::value_type const (&rhs)[N]) { return static_cast<std::basic_string<char32_t> &&>(lhs) + std::move(ByteString(rhs).FromAscii()); }
inline String operator+(std::basic_string<char32_t> const &lhs, String const &rhs) { return lhs + static_cast<std::basic_string<char32_t> const &>(rhs); }
inline String operator+(std::basic_string<char32_t> const &lhs, String &&rhs) { return lhs + static_cast<std::basic_string<char32_t> &&>(rhs); }
inline String operator+(std::basic_string<char32_t> &&lhs, String const &rhs) { return std::move(lhs) + static_cast<std::basic_string<char32_t> const &>(rhs); }
inline String operator+(std::basic_string<char32_t> &&lhs, String &&rhs) { return std::move(lhs) + static_cast<std::basic_string<char32_t> &&>(rhs); }
inline String operator+(String::value_type lhs, String const &rhs) { return lhs + static_cast<std::basic_string<char32_t> const &>(rhs); }
inline String operator+(String::value_type lhs, String &&rhs) { return lhs + static_cast<std::basic_string<char32_t> &&>(rhs); }
inline String operator+(String::value_type const *lhs, String const &rhs) { return lhs + static_cast<std::basic_string<char32_t> const &>(rhs); }
inline String operator+(String::value_type const *lhs, String &&rhs) { return lhs + static_cast<std::basic_string<char32_t> &&>(rhs); }
template<size_t N> inline String operator+(ByteString::value_type const (&lhs)[N], String const &rhs) { return std::move(ByteString(lhs).FromAscii()) + static_cast<std::basic_string<char32_t> const &>(rhs); }
template<size_t N> inline String operator+(ByteString::value_type const (&lhs)[N], String &&rhs) { return std::move(ByteString(lhs).FromAscii()) + static_cast<std::basic_string<char32_t> &&>(rhs); }
inline bool operator==(String const &lhs, String const &rhs) { return static_cast<std::basic_string<char32_t> const &>(lhs) == static_cast<std::basic_string<char32_t> const &>(rhs); }
inline bool operator==(String const &lhs, std::basic_string<char32_t> const &rhs) { return static_cast<std::basic_string<char32_t> const &>(lhs) == rhs; }
inline bool operator==(String const &lhs, String::value_type const *rhs) { return static_cast<std::basic_string<char32_t> const &>(lhs) == rhs; }
template<size_t N> inline bool operator==(String const &lhs, ByteString::value_type const (&rhs)[N]) { return static_cast<std::basic_string<char32_t> const &>(lhs) == std::move(ByteString(rhs).FromAscii()); }
inline bool operator==(std::basic_string<char32_t> const &lhs, String const &rhs) { return lhs == static_cast<std::basic_string<char32_t> const &>(rhs); }
inline bool operator==(String::value_type const *lhs, String const &rhs) { return lhs == static_cast<std::basic_string<char32_t> const &>(rhs); }
template<size_t N> inline bool operator==(ByteString::value_type const (&lhs)[N], String const &rhs) { return std::move(ByteString(lhs).FromAscii()) == static_cast<std::basic_string<char32_t> const &>(rhs); }
inline bool operator!=(String const &lhs, String const &rhs) { return static_cast<std::basic_string<char32_t> const &>(lhs) != static_cast<std::basic_string<char32_t> const &>(rhs); }
inline bool operator!=(String const &lhs, std::basic_string<char32_t> const &rhs) { return static_cast<std::basic_string<char32_t> const &>(lhs) != rhs; }
inline bool operator!=(String const &lhs, String::value_type const *rhs) { return static_cast<std::basic_string<char32_t> const &>(lhs) != rhs; }
template<size_t N> inline bool operator!=(String const &lhs, ByteString::value_type const (&rhs)[N]) { return static_cast<std::basic_string<char32_t> const &>(lhs) != std::move(ByteString(rhs).FromAscii()); }
inline bool operator!=(std::basic_string<char32_t> const &lhs, String const &rhs) { return lhs != static_cast<std::basic_string<char32_t> const &>(rhs); }
inline bool operator!=(String::value_type const *lhs, String const &rhs) { return lhs != static_cast<std::basic_string<char32_t> const &>(rhs); }
template<size_t N> inline bool operator!=(ByteString::value_type const (&lhs)[N], String const &rhs) { return std::move(ByteString(lhs).FromAscii()) != static_cast<std::basic_string<char32_t> const &>(rhs); }
inline String ByteString::FromAscii() const
{
String destination = String(size(), String::value_type());
for(size_t i = 0; i < size(); i++)
destination[i] = String::value_type(std::make_unsigned<ByteString::value_type>::type(operator[](i)));
return destination;
}
inline ByteString String::ToAscii() const
{
ByteString destination = ByteString(size(), ByteString::value_type());
for(size_t i = 0; i < size(); i++)
destination[i] = ByteString::value_type(operator[](i));
return destination;
}
class ConversionError : public std::runtime_error
{
static ByteString formatError(ByteString::value_type const *at, ByteString::value_type const *upto);
public:
inline ConversionError(ByteString::value_type const *at, ByteString::value_type const *upto): std::runtime_error(formatError(at, upto)) {}
inline ConversionError(bool to): std::runtime_error(to ? "Could not convert to UTF-8" : "Could not convert from UTF-8") {}
};
class ByteStringBuilder
{
std::vector<ByteString::value_type> buffer;
public:
std::ios_base::fmtflags flags;
ByteString::value_type fill;
size_t width, precision;
inline ByteStringBuilder(): flags(std::ios_base::skipws | std::ios_base::dec), fill(' '), width(0), precision(6) {}
void AddChars(ByteString::value_type const *, size_t);
size_t Size() const { return buffer.size(); }
ByteString Build() const;
template<typename T> ByteStringBuilder &operator<<(T) &&= delete;
template<typename T, typename... Ts> ByteStringBuilder &Add(T &&arg, Ts&&... args)
{
return (*this << std::forward<T>(arg)).Add(std::forward<Ts>(args)...);
}
ByteStringBuilder &Add() { return *this; }
};
ByteStringBuilder &operator<<(ByteStringBuilder &, short int);
ByteStringBuilder &operator<<(ByteStringBuilder &, int);
ByteStringBuilder &operator<<(ByteStringBuilder &, long int);
ByteStringBuilder &operator<<(ByteStringBuilder &, long long int);
ByteStringBuilder &operator<<(ByteStringBuilder &, unsigned short int);
ByteStringBuilder &operator<<(ByteStringBuilder &, unsigned int);
ByteStringBuilder &operator<<(ByteStringBuilder &, unsigned long int);
ByteStringBuilder &operator<<(ByteStringBuilder &, unsigned long long int);
ByteStringBuilder &operator<<(ByteStringBuilder &, ByteString::value_type);
ByteStringBuilder &operator<<(ByteStringBuilder &, ByteString::value_type const *);
ByteStringBuilder &operator<<(ByteStringBuilder &, ByteString const &);
ByteStringBuilder &operator<<(ByteStringBuilder &, float);
ByteStringBuilder &operator<<(ByteStringBuilder &, double);
template<typename... Ts> ByteString ByteString::Build(Ts&&... args)
{
ByteStringBuilder b;
b.Add(std::forward<Ts>(args)...);
return b.Build();
}
class StringBuilder
{
std::vector<String::value_type> buffer;
public:
std::ios_base::fmtflags flags;
String::value_type fill;
size_t width, precision;
inline StringBuilder(): flags(std::ios_base::skipws | std::ios_base::dec), fill(' '), width(0), precision(6) {}
void AddChars(String::value_type const *, size_t);
size_t Size() const { return buffer.size(); }
String Build() const;
template<typename T> StringBuilder &operator<<(T) = delete;
template<typename T, typename... Ts> StringBuilder &Add(T &&arg, Ts&&... args)
{
return (*this << std::forward<T>(arg)).Add(std::forward<Ts>(args)...);
}
StringBuilder &Add() { return *this; }
};
StringBuilder &operator<<(StringBuilder &, short int);
StringBuilder &operator<<(StringBuilder &, int);
StringBuilder &operator<<(StringBuilder &, long int);
StringBuilder &operator<<(StringBuilder &, long long int);
StringBuilder &operator<<(StringBuilder &, unsigned short int);
StringBuilder &operator<<(StringBuilder &, unsigned int);
StringBuilder &operator<<(StringBuilder &, unsigned long int);
StringBuilder &operator<<(StringBuilder &, unsigned long long int);
StringBuilder &operator<<(StringBuilder &, ByteString::value_type);
StringBuilder &operator<<(StringBuilder &, String::value_type);
StringBuilder &operator<<(StringBuilder &, String::value_type const *);
StringBuilder &operator<<(StringBuilder &, String const &);
StringBuilder &operator<<(StringBuilder &, float);
StringBuilder &operator<<(StringBuilder &, double);
template<size_t N> StringBuilder &operator<<(StringBuilder &b, ByteString::value_type const (&data)[N]) { return b << ByteString(data).FromUtf8(); }
template<typename... Ts> String String::Build(Ts&&... args)
{
StringBuilder b;
b.Add(std::forward<Ts>(args)...);
return b.Build();
}
#include "common/Format.h"

View File

@ -27,21 +27,18 @@ void DebugLines::Draw()
g->draw_line(0, drawPoint2.Y, XRES, drawPoint2.Y, 255, 255, 255, 120);
g->draw_line(drawPoint2.X, 0, drawPoint2.X, YRES, 255, 255, 255, 120);
std::stringstream info;
info << drawPoint2.X << " x " << drawPoint2.Y;
g->drawtext_outline(drawPoint2.X+(drawPoint2.X>drawPoint1.X?3:-g->textwidth(info.str().c_str())-3), drawPoint2.Y+(drawPoint2.Y<drawPoint1.Y?-10:3), info.str().c_str(), 255, 255, 255, 200);
String info;
info = String::Build(drawPoint2.X, " x ", drawPoint2.Y);
g->drawtext_outline(drawPoint2.X+(drawPoint2.X>drawPoint1.X?3:-g->textwidth(info)-3), drawPoint2.Y+(drawPoint2.Y<drawPoint1.Y?-10:3), info, 255, 255, 255, 200);
info.str("");
info << drawPoint1.X << " x " << drawPoint1.Y;
g->drawtext_outline(drawPoint1.X+(drawPoint2.X<drawPoint1.X?3:-g->textwidth(info.str().c_str())-2), drawPoint1.Y+(drawPoint2.Y>drawPoint1.Y?-10:3), info.str().c_str(), 255, 255, 255, 200);
info = String::Build(drawPoint1.X, " x ", drawPoint1.Y);
g->drawtext_outline(drawPoint1.X+(drawPoint2.X<drawPoint1.X?3:-g->textwidth(info)-2), drawPoint1.Y+(drawPoint2.Y>drawPoint1.Y?-10:3), info, 255, 255, 255, 200);
info.str("");
info << std::abs(drawPoint2.X-drawPoint1.X);
g->drawtext_outline((drawPoint1.X+drawPoint2.X)/2-g->textwidth(info.str().c_str())/2, drawPoint1.Y+(drawPoint2.Y>drawPoint1.Y?-10:3), info.str().c_str(), 255, 255, 255, 200);
info = String::Build(std::abs(drawPoint2.X-drawPoint1.X));
g->drawtext_outline((drawPoint1.X+drawPoint2.X)/2-g->textwidth(info)/2, drawPoint1.Y+(drawPoint2.Y>drawPoint1.Y?-10:3), info, 255, 255, 255, 200);
info.str("");
info << std::abs(drawPoint2.Y-drawPoint1.Y);
g->drawtext_outline(drawPoint1.X+(drawPoint2.X<drawPoint1.X?3:-g->textwidth(info.str().c_str())-2), (drawPoint1.Y+drawPoint2.Y)/2-3, info.str().c_str(), 255, 255, 255, 200);
info = String::Build(std::abs(drawPoint2.Y-drawPoint1.Y));
g->drawtext_outline(drawPoint1.X+(drawPoint2.X<drawPoint1.X?3:-g->textwidth(info)-2), (drawPoint1.Y+drawPoint2.Y)/2-3, info, 255, 255, 255, 200);
}
}

View File

@ -1,5 +1,4 @@
#include <iomanip>
#include <sstream>
#include "DebugParts.h"
#include "gui/interface/Engine.h"
#include "simulation/Simulation.h"
@ -16,8 +15,7 @@ void DebugParts::Draw()
Graphics * g = ui::Engine::Ref().g;
int x = 0, y = 0, lpx = 0, lpy = 0;
std::stringstream info;
info << sim->parts_lastActiveIndex << "/" << NPART << " (" << std::fixed << std::setprecision(2) << (float)sim->parts_lastActiveIndex/(NPART)*100.0f << "%)";
String info = String::Build(sim->parts_lastActiveIndex, "/", NPART, " (", Format::Precision((float)sim->parts_lastActiveIndex/(NPART)*100.0f, 2), "%)");
for (int i = 0; i < NPART; i++)
{
if (sim->parts[i].type)
@ -46,8 +44,8 @@ void DebugParts::Draw()
g->addpixel(lpx, lpy+1, 255, 50, 50, 120);
g->addpixel(lpx, lpy-1, 255, 50, 50, 120);
g->fillrect(7, YRES-26, g->textwidth(info.str().c_str())+5, 14, 0, 0, 0, 180);
g->drawtext(10, YRES-22, info.str().c_str(), 255, 255, 255, 255);
g->fillrect(7, YRES-26, g->textwidth(info)+5, 14, 0, 0, 0, 180);
g->drawtext(10, YRES-22, info, 255, 255, 255, 255);
}
DebugParts::~DebugParts()

View File

@ -18,8 +18,8 @@ void ElementPopulationDebug::Draw()
int yBottom = YRES-10;
int xStart = 10;
std::string maxValString;
std::string halfValString;
String maxValString;
String halfValString;
float maxVal = 255;
@ -37,11 +37,11 @@ void ElementPopulationDebug::Draw()
maxAverage = (maxAverage*(1.0f-0.015f)) + (0.015f*maxVal);
scale = 255.0f/maxAverage;
maxValString = format::NumberToString<int>(maxAverage);
halfValString = format::NumberToString<int>(maxAverage/2);
maxValString = String::Build(maxAverage);
halfValString = String::Build(maxAverage/2);
g->fillrect(xStart-5, yBottom - 263, bars+10+Graphics::textwidth(maxValString.c_str())+10, 255 + 13, 0, 0, 0, 180);
g->fillrect(xStart-5, yBottom - 263, bars+10+Graphics::textwidth(maxValString)+10, 255 + 13, 0, 0, 0, 180);
bars = 0;
for(int i = 0; i < PT_NUM; i++)

View File

@ -1,4 +1,3 @@
#include <sstream>
#include "ParticleDebug.h"
#include "gui/interface/Engine.h"
#include "gui/game/GameView.h"
@ -16,7 +15,7 @@ void ParticleDebug::Debug(int mode, int x, int y)
{
int debug_currentParticle = sim->debug_currentParticle;
int i = 0;
std::stringstream logmessage;
String logmessage;
if (mode == 0)
{
@ -26,21 +25,21 @@ void ParticleDebug::Debug(int mode, int x, int y)
while (i < NPART && !sim->parts[i].type)
i++;
if (i == NPART)
logmessage << "End of particles reached, updated sim";
logmessage = "End of particles reached, updated sim";
else
logmessage << "Updated particle #" << i;
logmessage = String::Build("Updated particle #", i);
}
else if (mode == 1)
{
if (x < 0 || x >= XRES || y < 0 || y >= YRES || !sim->pmap[y][x] || (i = ID(sim->pmap[y][x])) < debug_currentParticle)
{
i = NPART;
logmessage << "Updated particles from #" << debug_currentParticle << " to end, updated sim";
logmessage = String::Build("Updated particles from #", debug_currentParticle, " to end, updated sim");
}
else
logmessage << "Updated particles #" << debug_currentParticle << " through #" << i;
logmessage = String::Build("Updated particles #", debug_currentParticle, " through #", i);
}
model->Log(logmessage.str(), false);
model->Log(logmessage, false);
if (sim->debug_currentParticle == 0)
{
@ -90,9 +89,8 @@ bool ParticleDebug::KeyPress(int key, Uint16 character, bool shift, bool ctrl, b
{
sim->UpdateParticles(sim->debug_currentParticle, NPART);
sim->AfterSim();
std::stringstream logmessage;
logmessage << "Updated particles from #" << sim->debug_currentParticle << " to end, updated sim";
model->Log(logmessage.str(), false);
String logmessage = String::Build("Updated particles from #", sim->debug_currentParticle, " to end, updated sim");
model->Log(logmessage, false);
sim->debug_currentParticle = 0;
}
else

View File

@ -1,7 +1,6 @@
int drawtext(int x, int y, const char *s, int r, int g, int b, int a);
int drawtext(int x, int y, std::string s, int r, int g, int b, int a);
int drawchar(int x, int y, int c, int r, int g, int b, int a);
int addchar(int x, int y, int c, int r, int g, int b, int a);
int drawtext(int x, int y, String s, int r, int g, int b, int a);
int drawchar(int x, int y, String::value_type c, int r, int g, int b, int a);
int addchar(int x, int y, String::value_type c, int r, int g, int b, int a);
void xor_pixel(int x, int y);
void xor_line(int x, int y, int x2, int y2);

2
src/graphics/Font.cpp Normal file
View File

@ -0,0 +1,2 @@
#define INCLUDE_FONTDATA
#include "font.h"

59
src/graphics/Font.h Normal file
View File

@ -0,0 +1,59 @@
#include <cstddef>
#include "common/String.h"
#include "font.h"
class FontReader
{
unsigned char *pointer;
int width;
int pixels;
int data;
inline FontReader(unsigned char *_pointer):
pointer(_pointer + 1),
width(*_pointer),
pixels(0),
data(0)
{}
static inline unsigned char *lookupChar(String::value_type ch)
{
size_t offset = 0;
for(int i = 0; font_ranges[i][1]; i++)
if(font_ranges[i][0] > ch)
break;
else if(font_ranges[i][1] >= ch)
return &font_data[font_ptrs[offset + (ch - font_ranges[i][0])]];
else
offset += font_ranges[i][1] - font_ranges[i][0] + 1;
if(ch == 0xFFFD)
return &font_data[0];
else
return lookupChar(0xFFFD);
}
public:
inline FontReader(String::value_type ch):
FontReader(lookupChar(ch))
{
}
inline int GetWidth() const
{
return width;
}
inline int NextPixel()
{
if(!pixels)
{
data = *(pointer++);
pixels = 4;
}
int old = data;
pixels--;
data >>= 2;
return old & 0x3;
}
};

View File

@ -1,12 +1,11 @@
#include <cmath>
#include <iostream>
#include <bzlib.h>
#include <string>
#include "common/String.h"
#include "Config.h"
#include "Misc.h"
#include "Graphics.h"
#define INCLUDE_FONTDATA
#include "font.h"
#include "Font.h"
#ifdef HIGH_QUALITY_RESAMPLE
#include "resampler/resampler.h"
#endif
@ -86,64 +85,31 @@ void VideoBuffer::Resize(int width, int height, bool resample, bool fixedRatio)
}
}
int VideoBuffer::SetCharacter(int x, int y, int c, int r, int g, int b, int a)
int VideoBuffer::SetCharacter(int x, int y, String::value_type c, int r, int g, int b, int a)
{
int i, j, w, bn = 0, ba = 0;
unsigned char *rp = font_data + font_ptrs[c];
w = *(rp++);
for (j=0; j<FONT_H; j++)
for (i=0; i<w; i++)
{
if (!bn)
{
ba = *(rp++);
bn = 8;
}
SetPixel(x+i, y+j, r, g, b, ((ba&3)*a)/3);
ba >>= 2;
bn -= 2;
}
return x + w;
FontReader reader(c);
for (int j = -2; j < FONT_H - 2; j++)
for (int i = 0; i < reader.GetWidth(); i++)
SetPixel(x + i, y + j, r, g, b, reader.NextPixel() * a / 3);
return x + reader.GetWidth();
}
int VideoBuffer::BlendCharacter(int x, int y, int c, int r, int g, int b, int a)
int VideoBuffer::BlendCharacter(int x, int y, String::value_type c, int r, int g, int b, int a)
{
int i, j, w, bn = 0, ba = 0;
unsigned char *rp = font_data + font_ptrs[c];
w = *(rp++);
for (j=0; j<FONT_H; j++)
for (i=0; i<w; i++)
{
if (!bn)
{
ba = *(rp++);
bn = 8;
}
BlendPixel(x+i, y+j, r, g, b, ((ba&3)*a)/3);
ba >>= 2;
bn -= 2;
}
return x + w;
FontReader reader(c);
for (int j = -2; j < FONT_H - 2; j++)
for (int i = 0; i < reader.GetWidth(); i++)
BlendPixel(x + i, y + j, r, g, b, reader.NextPixel() * a / 3);
return x + reader.GetWidth();
}
int VideoBuffer::AddCharacter(int x, int y, int c, int r, int g, int b, int a)
int VideoBuffer::AddCharacter(int x, int y, String::value_type c, int r, int g, int b, int a)
{
int i, j, w, bn = 0, ba = 0;
unsigned char *rp = font_data + font_ptrs[c];
w = *(rp++);
for (j=0; j<FONT_H; j++)
for (i=0; i<w; i++)
{
if (!bn)
{
ba = *(rp++);
bn = 8;
}
AddPixel(x+i, y+j, r, g, b, ((ba&3)*a)/3);
ba >>= 2;
bn -= 2;
}
return x + w;
FontReader reader(c);
for (int j = -2; j < FONT_H - 2; j++)
for (int i = 0; i < reader.GetWidth(); i++)
AddPixel(x + i, y + j, r, g, b, reader.NextPixel() * a / 3);
return x + reader.GetWidth();
}
VideoBuffer::~VideoBuffer()
@ -566,9 +532,10 @@ pixel *Graphics::rescale_img(pixel *src, int sw, int sh, int *qw, int *qh, int f
return q;
}
int Graphics::textwidth(const char *s)
int Graphics::textwidth(String str)
{
int x = 0;
String::value_type const *s = str.c_str();
for (; *s; s++)
{
if(((char)*s)=='\b')
@ -581,19 +548,20 @@ int Graphics::textwidth(const char *s)
s+=3;
continue;
}
x += font_data[font_ptrs[(int)(*(unsigned char *)s)]];
x += FontReader(*s).GetWidth();
}
return x-1;
}
int Graphics::CharWidth(unsigned char c)
int Graphics::CharWidth(String::value_type c)
{
return font_data[font_ptrs[(int)c]];
return FontReader(c).GetWidth();
}
int Graphics::textnwidth(char *s, int n)
int Graphics::textnwidth(String str, int n)
{
int x = 0;
String::value_type const *s = str.c_str();
for (; *s; s++)
{
if (!n)
@ -608,36 +576,39 @@ int Graphics::textnwidth(char *s, int n)
s+=3;
continue;
}
x += font_data[font_ptrs[(int)(*(unsigned char *)s)]];
x += FontReader(*s).GetWidth();
n--;
}
return x-1;
}
void Graphics::textnpos(char *s, int n, int w, int *cx, int *cy)
void Graphics::textnpos(String str, int n, int w, int *cx, int *cy)
{
int x = 0;
int y = 0;
int wordlen, charspace;
String::value_type const *s = str.c_str();
while (*s&&n)
{
wordlen = strcspn(s," .,!?\n");
wordlen = 0;
while(*s && String(" .,!?\n").Contains(*s))
s++;
charspace = textwidthx(s, w-x);
if (charspace<wordlen && wordlen && w-x<w/3)
{
x = 0;
y += FONT_H+2;
y += FONT_H;
}
for (; *s && --wordlen>=-1; s++)
{
if (!n) {
break;
}
x += font_data[font_ptrs[(int)(*(unsigned char *)s)]];
x += FontReader(*s).GetWidth();
if (x>=w)
{
x = 0;
y += FONT_H+2;
y += FONT_H;
}
n--;
}
@ -646,9 +617,10 @@ void Graphics::textnpos(char *s, int n, int w, int *cx, int *cy)
*cy = y;
}
int Graphics::textwidthx(char *s, int w)
int Graphics::textwidthx(String str, int w)
{
int x=0,n=0,cw;
String::value_type const *s = str.c_str();
for (; *s; s++)
{
if((char)*s == '\b')
@ -662,7 +634,7 @@ int Graphics::textwidthx(char *s, int w)
s+=3;
continue;
}
cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]];
cw = FontReader(*s).GetWidth();
if (x+(cw/2) >= w)
break;
x += cw;
@ -671,9 +643,10 @@ int Graphics::textwidthx(char *s, int w)
return n;
}
int Graphics::PositionAtCharIndex(char *s, int charIndex, int & positionX, int & positionY)
int Graphics::PositionAtCharIndex(String str, int charIndex, int & positionX, int & positionY)
{
int x = 0, y = 0, lines = 1;
String::value_type const *s = str.c_str();
for (; *s; s++)
{
if (!charIndex)
@ -681,7 +654,7 @@ int Graphics::PositionAtCharIndex(char *s, int charIndex, int & positionX, int &
if(*s == '\n') {
lines++;
x = 0;
y += FONT_H+2;
y += FONT_H;
charIndex--;
continue;
} else if(*s =='\b') {
@ -695,7 +668,7 @@ int Graphics::PositionAtCharIndex(char *s, int charIndex, int & positionX, int &
charIndex-=4;
continue;
}
x += font_data[font_ptrs[(int)(*(unsigned char *)s)]];
x += FontReader(*s).GetWidth();
charIndex--;
}
positionX = x;
@ -703,14 +676,15 @@ int Graphics::PositionAtCharIndex(char *s, int charIndex, int & positionX, int &
return lines;
}
int Graphics::CharIndexAtPosition(char *s, int positionX, int positionY)
int Graphics::CharIndexAtPosition(String str, int positionX, int positionY)
{
int x=0, y=0,charIndex=0,cw;
int x=0, y=-2,charIndex=0,cw;
String::value_type const *s = str.c_str();
for (; *s; s++)
{
if(*s == '\n') {
x = 0;
y += FONT_H+2;
y += FONT_H;
charIndex++;
continue;
} else if(*s == '\b') {
@ -724,7 +698,7 @@ int Graphics::CharIndexAtPosition(char *s, int positionX, int positionY)
charIndex+=4;
continue;
}
cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]];
cw = FontReader(*s).GetWidth();
if ((x+(cw/2) >= positionX && y+FONT_H >= positionY) || y > positionY)
break;
x += cw;
@ -734,26 +708,29 @@ int Graphics::CharIndexAtPosition(char *s, int positionX, int positionY)
}
int Graphics::textwrapheight(char *s, int width)
int Graphics::textwrapheight(String str, int width)
{
int x=0, height=FONT_H+2, cw;
int x=0, height=FONT_H, cw;
int wordlen;
int charspace;
String::value_type const *s = str.c_str();
while (*s)
{
wordlen = strcspn(s," .,!?\n");
wordlen = 0;
while(*s && String(" .,!?\n").Contains(*s))
s++;
charspace = textwidthx(s, width-x);
if (charspace<wordlen && wordlen && width-x<width/3)
{
x = 0;
height += FONT_H+2;
height += FONT_H;
}
for (; *s && --wordlen>=-1; s++)
{
if (*s == '\n')
{
x = 0;
height += FONT_H+2;
height += FONT_H;
}
else if (*s == '\b')
{
@ -767,11 +744,11 @@ int Graphics::textwrapheight(char *s, int width)
}
else
{
cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]];
cw = FontReader(*s).GetWidth();
if (x+cw>=width)
{
x = 0;
height += FONT_H+2;
height += FONT_H;
}
x += cw;
}
@ -780,22 +757,23 @@ int Graphics::textwrapheight(char *s, int width)
return height;
}
void Graphics::textsize(const char * s, int & width, int & height)
void Graphics::textsize(String str, int & width, int & height)
{
if(!strlen(s))
if(!str.size())
{
width = 0;
height = FONT_H;
height = FONT_H-2;
return;
}
int cHeight = FONT_H, cWidth = 0, lWidth = 0;
int cHeight = FONT_H-2, cWidth = 0, lWidth = 0;
String::value_type const *s = str.c_str();
for (; *s; s++)
{
if (*s == '\n')
{
cWidth = 0;
cHeight += FONT_H+2;
cHeight += FONT_H;
}
else if (*s == '\x0F')
{
@ -809,7 +787,7 @@ void Graphics::textsize(const char * s, int & width, int & height)
}
else
{
cWidth += font_data[font_ptrs[(int)(*(unsigned char *)s)]];
cWidth += FontReader(*s).GetWidth();
if(cWidth>lWidth)
lWidth = cWidth;
}
@ -825,262 +803,262 @@ void Graphics::draw_icon(int x, int y, Icon icon, unsigned char alpha, bool inve
{
case IconOpen:
if(invert)
drawchar(x, y, 0x81, 0, 0, 0, alpha);
drawchar(x, y, 0xE001, 0, 0, 0, alpha);
else
drawchar(x, y, 0x81, 255, 255, 255, alpha);
drawchar(x, y, 0xE001, 255, 255, 255, alpha);
break;
case IconReload:
if(invert)
drawchar(x, y, 0x91, 0, 0, 0, alpha);
drawchar(x, y, 0xE011, 0, 0, 0, alpha);
else
drawchar(x, y, 0x91, 255, 255, 255, alpha);
drawchar(x, y, 0xE011, 255, 255, 255, alpha);
break;
case IconSave:
if(invert)
drawchar(x, y, 0x82, 0, 0, 0, alpha);
drawchar(x, y, 0xE002, 0, 0, 0, alpha);
else
drawchar(x, y, 0x82, 255, 255, 255, alpha);
drawchar(x, y, 0xE002, 255, 255, 255, alpha);
break;
case IconVoteUp:
if(invert)
{
drawchar(x-11, y+1, 0xCB, 0, 100, 0, alpha);
drawchar(x-11, y+1, 0xE04B, 0, 100, 0, alpha);
drawtext(x+2, y+1, "Vote", 0, 100, 0, alpha);
}
else
{
drawchar(x-11, y+1, 0xCB, 0, 187, 18, alpha);
drawchar(x-11, y+1, 0xE04B, 0, 187, 18, alpha);
drawtext(x+2, y+1, "Vote", 0, 187, 18, alpha);
}
break;
case IconVoteDown:
if(invert)
drawchar(x, y, 0xCA, 100, 10, 0, alpha);
drawchar(x, y, 0xE04A, 100, 10, 0, alpha);
else
drawchar(x, y, 0xCA, 187, 40, 0, alpha);
drawchar(x, y, 0xE04A, 187, 40, 0, alpha);
break;
case IconTag:
if(invert)
drawchar(x, y, 0x83, 0, 0, 0, alpha);
drawchar(x, y, 0xE003, 0, 0, 0, alpha);
else
drawchar(x, y, 0x83, 255, 255, 255, alpha);
drawchar(x, y, 0xE003, 255, 255, 255, alpha);
break;
case IconNew:
if(invert)
drawchar(x, y, 0x92, 0, 0, 0, alpha);
drawchar(x, y, 0xE012, 0, 0, 0, alpha);
else
drawchar(x, y, 0x92, 255, 255, 255, alpha);
drawchar(x, y, 0xE012, 255, 255, 255, alpha);
break;
case IconLogin:
if(invert)
drawchar(x, y+1, 0x84, 0, 0, 0, alpha);
drawchar(x, y+1, 0xE004, 0, 0, 0, alpha);
else
drawchar(x, y+1, 0x84, 255, 255, 255, alpha);
drawchar(x, y+1, 0xE004, 255, 255, 255, alpha);
break;
case IconSimulationSettings:
if(invert)
drawchar(x, y+1, 0xCF, 0, 0, 0, alpha);
drawchar(x, y+1, 0xE04F, 0, 0, 0, alpha);
else
drawchar(x, y+1, 0xCF, 255, 255, 255, alpha);
drawchar(x, y+1, 0xE04F, 255, 255, 255, alpha);
break;
case IconRenderSettings:
if(invert)
{
drawchar(x, y+1, 0xD8, 255, 0, 0, alpha);
drawchar(x, y+1, 0xD9, 0, 255, 0, alpha);
drawchar(x, y+1, 0xDA, 0, 0, 255, alpha);
drawchar(x, y+1, 0xE058, 255, 0, 0, alpha);
drawchar(x, y+1, 0xE059, 0, 255, 0, alpha);
drawchar(x, y+1, 0xE05A, 0, 0, 255, alpha);
}
else
{
addchar(x, y+1, 0xD8, 255, 0, 0, alpha);
addchar(x, y+1, 0xD9, 0, 255, 0, alpha);
addchar(x, y+1, 0xDA, 0, 0, 255, alpha);
addchar(x, y+1, 0xE058, 255, 0, 0, alpha);
addchar(x, y+1, 0xE059, 0, 255, 0, alpha);
addchar(x, y+1, 0xE05A, 0, 0, 255, alpha);
}
break;
case IconPause:
if(invert)
drawchar(x, y, 0x90, 0, 0, 0, alpha);
drawchar(x, y, 0xE010, 0, 0, 0, alpha);
else
drawchar(x, y, 0x90, 255, 255, 255, alpha);
drawchar(x, y, 0xE010, 255, 255, 255, alpha);
break;
case IconFavourite:
if(invert)
drawchar(x, y, 0xCC, 100, 80, 32, alpha);
drawchar(x, y, 0xE04C, 100, 80, 32, alpha);
else
drawchar(x, y, 0xCC, 192, 160, 64, alpha);
drawchar(x, y, 0xE04C, 192, 160, 64, alpha);
break;
case IconReport:
if(invert)
drawchar(x, y, 0xE3, 140, 140, 0, alpha);
drawchar(x, y, 0xE063, 140, 140, 0, alpha);
else
drawchar(x, y, 0xE3, 255, 255, 0, alpha);
drawchar(x, y, 0xE063, 255, 255, 0, alpha);
break;
case IconUsername:
if(invert)
{
drawchar(x, y, 0x8B, 32, 64, 128, alpha);
drawchar(x, y, 0x8A, 0, 0, 0, alpha);
drawchar(x, y, 0xE00B, 32, 64, 128, alpha);
drawchar(x, y, 0xE00A, 0, 0, 0, alpha);
}
else
{
drawchar(x, y, 0x8B, 32, 64, 128, alpha);
drawchar(x, y, 0x8A, 255, 255, 255, alpha);
drawchar(x, y, 0xE00B, 32, 64, 128, alpha);
drawchar(x, y, 0xE00A, 255, 255, 255, alpha);
}
break;
case IconPassword:
if(invert)
{
drawchar(x, y, 0x8C, 160, 144, 32, alpha);
drawchar(x, y, 0x84, 0, 0, 0, alpha);
drawchar(x, y, 0xE00C, 160, 144, 32, alpha);
drawchar(x, y, 0xE004, 0, 0, 0, alpha);
}
else
{
drawchar(x, y, 0x8C, 160, 144, 32, alpha);
drawchar(x, y, 0x84, 255, 255, 255, alpha);
drawchar(x, y, 0xE00C, 160, 144, 32, alpha);
drawchar(x, y, 0xE004, 255, 255, 255, alpha);
}
break;
case IconClose:
if(invert)
drawchar(x, y, 0xAA, 20, 20, 20, alpha);
drawchar(x, y, 0xE02A, 20, 20, 20, alpha);
else
drawchar(x, y, 0xAA, 230, 230, 230, alpha);
drawchar(x, y, 0xE02A, 230, 230, 230, alpha);
break;
case IconVoteSort:
if (invert)
{
drawchar(x, y, 0xA9, 44, 48, 32, alpha);
drawchar(x, y, 0xA8, 32, 44, 32, alpha);
drawchar(x, y, 0xA7, 128, 128, 128, alpha);
drawchar(x, y, 0xE029, 44, 48, 32, alpha);
drawchar(x, y, 0xE028, 32, 44, 32, alpha);
drawchar(x, y, 0xE027, 128, 128, 128, alpha);
}
else
{
drawchar(x, y, 0xA9, 144, 48, 32, alpha);
drawchar(x, y, 0xA8, 32, 144, 32, alpha);
drawchar(x, y, 0xA7, 255, 255, 255, alpha);
drawchar(x, y, 0xE029, 144, 48, 32, alpha);
drawchar(x, y, 0xE028, 32, 144, 32, alpha);
drawchar(x, y, 0xE027, 255, 255, 255, alpha);
}
break;
case IconDateSort:
if (invert)
{
drawchar(x, y, 0xA6, 32, 32, 32, alpha);
drawchar(x, y, 0xE026, 32, 32, 32, alpha);
}
else
{
drawchar(x, y, 0xA6, 255, 255, 255, alpha);
drawchar(x, y, 0xE026, 255, 255, 255, alpha);
}
break;
case IconMyOwn:
if (invert)
{
drawchar(x, y, 0x94, 192, 160, 64, alpha);
drawchar(x, y, 0x93, 32, 32, 32, alpha);
drawchar(x, y, 0xE014, 192, 160, 64, alpha);
drawchar(x, y, 0xE013, 32, 32, 32, alpha);
}
else
{
drawchar(x, y, 0x94, 192, 160, 64, alpha);
drawchar(x, y, 0x93, 255, 255, 255, alpha);
drawchar(x, y, 0xE014, 192, 160, 64, alpha);
drawchar(x, y, 0xE013, 255, 255, 255, alpha);
}
break;
case IconSearch:
drawchar(x, y, 0x8E, 30, 30, 180, alpha);
drawchar(x, y, 0x8F, 255, 255, 255, alpha);
drawchar(x, y, 0xE00E, 30, 30, 180, alpha);
drawchar(x, y, 0xE00F, 255, 255, 255, alpha);
break;
case IconDelete:
if(invert)
{
drawchar(x, y, 0x86, 159, 47, 31, alpha);
drawchar(x, y, 0x85, 0, 0, 0, alpha);
drawchar(x, y, 0xE006, 159, 47, 31, alpha);
drawchar(x, y, 0xE005, 0, 0, 0, alpha);
}
else
{
drawchar(x, y, 0x86, 159, 47, 31, alpha);
drawchar(x, y, 0x85, 255, 255, 255, alpha);
drawchar(x, y, 0xE006, 159, 47, 31, alpha);
drawchar(x, y, 0xE005, 255, 255, 255, alpha);
}
break;
case IconAdd:
if(invert)
{
drawchar(x, y, 0x86, 32, 144, 32, alpha);
drawchar(x, y, 0x89, 0, 0, 0, alpha);
drawchar(x, y, 0xE006, 32, 144, 32, alpha);
drawchar(x, y, 0xE009, 0, 0, 0, alpha);
}
else
{
drawchar(x, y, 0x86, 32, 144, 32, alpha);
drawchar(x, y, 0x89, 255, 255, 255, alpha);
drawchar(x, y, 0xE006, 32, 144, 32, alpha);
drawchar(x, y, 0xE009, 255, 255, 255, alpha);
}
break;
case IconVelocity:
drawchar(x+1, y, 0x98, 128, 160, 255, alpha);
drawchar(x+1, y, 0xE018, 128, 160, 255, alpha);
break;
case IconPressure:
if(invert)
drawchar(x+1, y+1, 0x99, 180, 160, 16, alpha);
drawchar(x+1, y+1, 0xE019, 180, 160, 16, alpha);
else
drawchar(x+1, y+1, 0x99, 255, 212, 32, alpha);
drawchar(x+1, y+1, 0xE019, 255, 212, 32, alpha);
break;
case IconPersistant:
if(invert)
drawchar(x+1, y+1, 0x9A, 20, 20, 20, alpha);
drawchar(x+1, y+1, 0xE01A, 20, 20, 20, alpha);
else
drawchar(x+1, y+1, 0x9A, 212, 212, 212, alpha);
drawchar(x+1, y+1, 0xE01A, 212, 212, 212, alpha);
break;
case IconFire:
drawchar(x+1, y+1, 0x9B, 255, 0, 0, alpha);
drawchar(x+1, y+1, 0x9C, 255, 255, 64, alpha);
drawchar(x+1, y+1, 0xE01B, 255, 0, 0, alpha);
drawchar(x+1, y+1, 0xE01C, 255, 255, 64, alpha);
break;
case IconBlob:
if(invert)
drawchar(x+1, y, 0xBF, 55, 180, 55, alpha);
drawchar(x+1, y, 0xE03F, 55, 180, 55, alpha);
else
drawchar(x+1, y, 0xBF, 55, 255, 55, alpha);
drawchar(x+1, y, 0xE03F, 55, 255, 55, alpha);
break;
case IconHeat:
drawchar(x+3, y, 0xBE, 255, 0, 0, alpha);
drawchar(x+3, y, 0xE03E, 255, 0, 0, alpha);
if(invert)
drawchar(x+3, y, 0xBD, 0, 0, 0, alpha);
drawchar(x+3, y, 0xE03D, 0, 0, 0, alpha);
else
drawchar(x+3, y, 0xBD, 255, 255, 255, alpha);
drawchar(x+3, y, 0xE03D, 255, 255, 255, alpha);
break;
case IconBlur:
if(invert)
drawchar(x+1, y, 0xC4, 50, 70, 180, alpha);
drawchar(x+1, y, 0xE044, 50, 70, 180, alpha);
else
drawchar(x+1, y, 0xC4, 100, 150, 255, alpha);
drawchar(x+1, y, 0xE044, 100, 150, 255, alpha);
break;
case IconGradient:
if(invert)
drawchar(x+1, y+1, 0xD3, 255, 50, 255, alpha);
drawchar(x+1, y+1, 0xE053, 255, 50, 255, alpha);
else
drawchar(x+1, y+1, 0xD3, 205, 50, 205, alpha);
drawchar(x+1, y+1, 0xE053, 205, 50, 205, alpha);
break;
case IconLife:
if(invert)
drawchar(x, y+1, 0xE0, 0, 0, 0, alpha);
drawchar(x, y+1, 0xE060, 0, 0, 0, alpha);
else
drawchar(x, y+1, 0xE0, 255, 255, 255, alpha);
drawchar(x, y+1, 0xE060, 255, 255, 255, alpha);
break;
case IconEffect:
drawchar(x+1, y, 0xE1, 255, 255, 160, alpha);
drawchar(x+1, y, 0xE061, 255, 255, 160, alpha);
break;
case IconGlow:
drawchar(x+1, y, 0xDF, 200, 255, 255, alpha);
drawchar(x+1, y, 0xE05F, 200, 255, 255, alpha);
break;
case IconWarp:
drawchar(x+1, y, 0xDE, 255, 255, 255, alpha);
drawchar(x+1, y, 0xE05E, 255, 255, 255, alpha);
break;
case IconBasic:
if(invert)
drawchar(x+1, y+1, 0xDB, 50, 50, 0, alpha);
drawchar(x+1, y+1, 0xE05B, 50, 50, 0, alpha);
else
drawchar(x+1, y+1, 0xDB, 255, 255, 200, alpha);
drawchar(x+1, y+1, 0xE05B, 255, 255, 200, alpha);
break;
case IconAltAir:
if(invert) {
drawchar(x+1, y+1, 0xD4, 180, 55, 55, alpha);
drawchar(x+1, y+1, 0xD5, 55, 180, 55, alpha);
drawchar(x+1, y+1, 0xE054, 180, 55, 55, alpha);
drawchar(x+1, y+1, 0xE055, 55, 180, 55, alpha);
} else {
drawchar(x+1, y+1, 0xD4, 255, 55, 55, alpha);
drawchar(x+1, y+1, 0xD5, 55, 255, 55, alpha);
drawchar(x+1, y+1, 0xE054, 255, 55, 55, alpha);
drawchar(x+1, y+1, 0xE055, 55, 255, 55, alpha);
}
break;
default:

View File

@ -1,7 +1,7 @@
#ifndef GRAPHICS_H
#define GRAPHICS_H
#include <string>
#include "common/String.h"
#include <cstdlib>
#include <cstring>
#include <vector>
@ -84,9 +84,9 @@ public:
b = 255;
Buffer[y*(Width)+x] = PIXRGB(r,g,b);
}
int SetCharacter(int x, int y, int c, int r, int g, int b, int a);
int BlendCharacter(int x, int y, int c, int r, int g, int b, int a);
int AddCharacter(int x, int y, int c, int r, int g, int b, int a);
int SetCharacter(int x, int y, String::value_type c, int r, int g, int b, int a);
int BlendCharacter(int x, int y, String::value_type c, int r, int g, int b, int a);
int AddCharacter(int x, int y, String::value_type c, int r, int g, int b, int a);
~VideoBuffer();
};
@ -116,15 +116,15 @@ public:
static pixel *render_packed_rgb(void *image, int width, int height, int cmp_size);
//Font/text metrics
static int CharIndexAtPosition(char *s, int positionX, int positionY);
static int PositionAtCharIndex(char *s, int charIndex, int & positionX, int & positionY);
static int CharWidth(unsigned char c);
static int textnwidth(char *s, int n);
static void textnpos(char *s, int n, int w, int *cx, int *cy);
static int textwidthx(char *s, int w);
static int textwrapheight(char *s, int width);
static int textwidth(const char *s);
static void textsize(const char * s, int & width, int & height);
static int CharIndexAtPosition(String s, int positionX, int positionY);
static int PositionAtCharIndex(String s, int charIndex, int & positionX, int & positionY);
static int CharWidth(String::value_type c);
static int textnwidth(String s, int n);
static void textnpos(String s, int n, int w, int *cx, int *cy);
static int textwidthx(String s, int w);
static int textwrapheight(String s, int width);
static int textwidth(String s);
static void textsize(String s, int & width, int & height);
VideoBuffer DumpFrame();
@ -139,11 +139,10 @@ public:
void Clear();
void Finalise();
//
int drawtext_outline(int x, int y, const char *s, int r, int g, int b, int a);
int drawtext(int x, int y, const char *s, int r, int g, int b, int a);
int drawtext(int x, int y, std::string s, int r, int g, int b, int a);
int drawchar(int x, int y, int c, int r, int g, int b, int a);
int addchar(int x, int y, int c, int r, int g, int b, int a);
int drawtext_outline(int x, int y, String s, int r, int g, int b, int a);
int drawtext(int x, int y, String s, int r, int g, int b, int a);
int drawchar(int x, int y, String::value_type c, int r, int g, int b, int a);
int addchar(int x, int y, String::value_type c, int r, int g, int b, int a);
void xor_pixel(int x, int y);
void xor_line(int x, int y, int x2, int y2);

View File

@ -1,7 +1,7 @@
#include "../data/font.h"
#include <cmath>
int PIXELMETHODS_CLASS::drawtext_outline(int x, int y, const char *s, int r, int g, int b, int a)
int PIXELMETHODS_CLASS::drawtext_outline(int x, int y, String s, int r, int g, int b, int a)
{
drawtext(x-1, y-1, s, 0, 0, 0, 120);
drawtext(x+1, y+1, s, 0, 0, 0, 120);
@ -12,7 +12,7 @@ int PIXELMETHODS_CLASS::drawtext_outline(int x, int y, const char *s, int r, int
return drawtext(x, y, s, r, g, b, a);
}
int PIXELMETHODS_CLASS::drawtext(int x, int y, const char *s, int r, int g, int b, int a)
int PIXELMETHODS_CLASS::drawtext(int x, int y, String str, int r, int g, int b, int a)
{
bool invert = false;
if(!strlen(s))
@ -23,6 +23,7 @@ int PIXELMETHODS_CLASS::drawtext(int x, int y, const char *s, int r, int g, int
VideoBuffer texture(width, height);
int characterX = 0, characterY = 0;
int startX = characterX;
String::value_type *s = str.c_str();
for (; *s; s++)
{
if (*s == '\n')
@ -98,7 +99,7 @@ int PIXELMETHODS_CLASS::drawtext(int x, int y, const char *s, int r, int g, int
}
else
{
characterX = texture.SetCharacter(characterX, characterY, *(unsigned char *)s, r, g, b, a);
characterX = texture.SetCharacter(characterX, characterY, *s, r, g, b, a);
}
}
glEnable(GL_TEXTURE_2D);
@ -128,12 +129,7 @@ int PIXELMETHODS_CLASS::drawtext(int x, int y, const char *s, int r, int g, int
return x;
}
int PIXELMETHODS_CLASS::drawtext(int x, int y, std::string s, int r, int g, int b, int a)
{
return drawtext(x, y, s.c_str(), r, g, b, a);
}
int PIXELMETHODS_CLASS::drawchar(int x, int y, int c, int r, int g, int b, int a)
int PIXELMETHODS_CLASS::drawchar(int x, int y, String::value_type c, int r, int g, int b, int a)
{
unsigned char *rp = font_data + font_ptrs[c];
int w = *(rp++);
@ -162,7 +158,7 @@ int PIXELMETHODS_CLASS::drawchar(int x, int y, int c, int r, int g, int b, int a
return x + w;
}
int PIXELMETHODS_CLASS::addchar(int x, int y, int c, int r, int g, int b, int a)
int PIXELMETHODS_CLASS::addchar(int x, int y, String::value_type c, int r, int g, int b, int a)
{
unsigned char *rp = font_data + font_ptrs[c];
int w = *(rp++);

View File

@ -1,5 +1,5 @@
#include "Graphics.h"
#include "font.h"
#include "Font.h"
#include "common/tpt-thread.h"
#ifdef OGLI

View File

@ -1,7 +1,7 @@
#include "font.h"
#include <cmath>
#include "Font.h"
int PIXELMETHODS_CLASS::drawtext_outline(int x, int y, const char *s, int r, int g, int b, int a)
int PIXELMETHODS_CLASS::drawtext_outline(int x, int y, String s, int r, int g, int b, int a)
{
drawtext(x-1, y-1, s, 0, 0, 0, 120);
drawtext(x+1, y+1, s, 0, 0, 0, 120);
@ -12,21 +12,22 @@ int PIXELMETHODS_CLASS::drawtext_outline(int x, int y, const char *s, int r, int
return drawtext(x, y, s, r, g, b, a);
}
int PIXELMETHODS_CLASS::drawtext(int x, int y, const char *s, int r, int g, int b, int a)
int PIXELMETHODS_CLASS::drawtext(int x, int y, String str, int r, int g, int b, int a)
{
if(!strlen(s))
if(!str.size())
return 0;
int invert = 0;
int oR = r, oG = g, oB = b;
int characterX = x, characterY = y;
int startX = characterX;
String::value_type const *s = str.c_str();
for (; *s; s++)
{
if (*s == '\n')
{
characterX = startX;
characterY += FONT_H+2;
characterY += FONT_H;
}
else if (*s == '\x0F')
{
@ -96,57 +97,28 @@ int PIXELMETHODS_CLASS::drawtext(int x, int y, const char *s, int r, int g, int
}
else
{
characterX = drawchar(characterX, characterY, *(unsigned char *)s, r, g, b, a);
characterX = drawchar(characterX, characterY, *s, r, g, b, a);
}
}
return x;
}
int PIXELMETHODS_CLASS::drawtext(int x, int y, std::string s, int r, int g, int b, int a)
int PIXELMETHODS_CLASS::drawchar(int x, int y, String::value_type c, int r, int g, int b, int a)
{
return drawtext(x, y, s.c_str(), r, g, b, a);
FontReader reader(c);
for (int j = -2; j < FONT_H - 2; j++)
for (int i = 0; i < reader.GetWidth(); i++)
blendpixel(x + i, y + j, r, g, b, reader.NextPixel() * a / 3);
return x + reader.GetWidth();
}
int PIXELMETHODS_CLASS::drawchar(int x, int y, int c, int r, int g, int b, int a)
int PIXELMETHODS_CLASS::addchar(int x, int y, String::value_type c, int r, int g, int b, int a)
{
int i, j, w, bn = 0, ba = 0;
unsigned char *rp = font_data + font_ptrs[c];
w = *(rp++);
for (j=0; j<FONT_H; j++)
for (i=0; i<w; i++)
{
if (!bn)
{
ba = *(rp++);
bn = 8;
}
blendpixel(x+i, y+j, r, g, b, ((ba&3)*a)/3);
ba >>= 2;
bn -= 2;
}
return x + w;
}
int PIXELMETHODS_CLASS::addchar(int x, int y, int c, int r, int g, int b, int a)
{
int i, j, w, bn = 0, ba = 0;
unsigned char *rp = font_data + font_ptrs[c];
w = *(rp++);
for (j=0; j<FONT_H; j++)
for (i=0; i<w; i++)
{
if (!bn)
{
ba = *(rp++);
bn = 8;
}
{
addpixel(x+i, y+j, r, g, b, ((ba&3)*a)/3);
}
ba >>= 2;
bn -= 2;
}
return x + w;
FontReader reader(c);
for (int j = -2; j < FONT_H - 2; j++)
for (int i = 0; i < reader.GetWidth(); i++)
addpixel(x + i, y + j, r, g, b, reader.NextPixel() * a / 3);
return x + reader.GetWidth();
}
TPT_INLINE void PIXELMETHODS_CLASS::xor_pixel(int x, int y)

View File

@ -1,5 +1,6 @@
#include <cmath>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <cstdlib>
@ -519,17 +520,16 @@ void Renderer::RenderZoom()
#endif
}
int Renderer_wtypesCount;
wall_type * Renderer_wtypes = LoadWalls(Renderer_wtypesCount);
std::vector<wall_type> Renderer_wtypes = LoadWalls();
VideoBuffer * Renderer::WallIcon(int wallID, int width, int height)
{
int i, j;
int wt = wallID;
if (wt<0 || wt>=Renderer_wtypesCount)
if (wt<0 || wt>=(int)Renderer_wtypes.size())
return 0;
wall_type *wtypes = Renderer_wtypes;
wall_type *wtypes = Renderer_wtypes.data();
pixel pc = wtypes[wt].colour;
pixel gc = wtypes[wt].eglow;
VideoBuffer * newTexture = new VideoBuffer(width, height);
@ -677,7 +677,7 @@ VideoBuffer * Renderer::WallIcon(int wallID, int width, int height)
newTexture->SetPixel(i, j, PIXR(pc), PIXG(pc), PIXB(pc), 255);
}
}
newTexture->SetCharacter(4, 2, 0x8D, 255, 255, 255, 255);
newTexture->AddCharacter(4, 2, 0xE00D, 255, 255, 255, 255);
for (i=width/3; i<width; i++)
{
newTexture->SetPixel(i, 7+(int)(3.9f*cos(i*0.3f)), 255, 255, 255, 255);
@ -805,7 +805,7 @@ void Renderer::DrawWalls()
// there is no velocity here, draw a streamline and continue
if (!xVel && !yVel)
{
drawtext(x*CELL, y*CELL-2, "\x8D", 255, 255, 255, 128);
drawtext(x*CELL, y*CELL-2, 0xE00D, 255, 255, 255, 128);
addpixel(oldX, oldY, 255, 255, 255, 255);
continue;
}
@ -836,7 +836,7 @@ void Renderer::DrawWalls()
xf += xVel;
yf += yVel;
}
drawtext(x*CELL, y*CELL-2, "\x8D", 255, 255, 255, 128);
drawtext(x*CELL, y*CELL-2, 0xE00D, 255, 255, 255, 128);
}
break;
case 1:
@ -985,8 +985,8 @@ void Renderer::DrawSigns()
for (size_t i = 0; i < signs.size(); i++)
if (signs[i].text.length())
{
char type = 0;
std::string text = signs[i].getText(sim);
String::value_type type = 0;
String text = signs[i].getText(sim);
sign::splitsign(signs[i].text, &type);
signs[i].pos(text, x, y, w, h);
clearrect(x, y, w+1, h);
@ -1496,9 +1496,8 @@ void Renderer::render_parts()
if (mousePos.X>(nx-3) && mousePos.X<(nx+3) && mousePos.Y<(ny+3) && mousePos.Y>(ny-3)) //If mouse is in the head
{
char buff[12]; //Buffer for HP
sprintf(buff, "%3d", sim->parts[i].life); //Show HP
drawtext(mousePos.X-8-2*(sim->parts[i].life<100)-2*(sim->parts[i].life<10), mousePos.Y-12, buff, 255, 255, 255, 255);
String hp = String::Build(Format::Width(sim->parts[i].life, 3));
drawtext(mousePos.X-8-2*(sim->parts[i].life<100)-2*(sim->parts[i].life<10), mousePos.Y-12, hp, 255, 255, 255, 255);
}
if (findingElement == t)

View File

@ -113,11 +113,10 @@ public:
void draw_icon(int x, int y, Icon icon);
int drawtext_outline(int x, int y, const char *s, int r, int g, int b, int a);
int drawtext(int x, int y, const char *s, int r, int g, int b, int a);
int drawtext(int x, int y, std::string s, int r, int g, int b, int a);
int drawchar(int x, int y, int c, int r, int g, int b, int a);
int addchar(int x, int y, int c, int r, int g, int b, int a);
int drawtext_outline(int x, int y, String s, int r, int g, int b, int a);
int drawtext(int x, int y, String s, int r, int g, int b, int a);
int drawchar(int x, int y, String::value_type c, int r, int g, int b, int a);
int addchar(int x, int y, String::value_type c, int r, int g, int b, int a);
void xor_pixel(int x, int y);
void xor_line(int x, int y, int x2, int y2);

View File

@ -28,10 +28,10 @@ ColourPickerActivity::ColourPickerActivity(ui::Colour initialColour, ColourPicke
void TextChangedCallback(ui::Textbox * sender)
{
int r, g, b, alpha;
r = format::StringToNumber<int>(a->rValue->GetText());
g = format::StringToNumber<int>(a->gValue->GetText());
b = format::StringToNumber<int>(a->bValue->GetText());
alpha = format::StringToNumber<int>(a->aValue->GetText());
r = a->rValue->GetText().ToNumber<int>(true);
g = a->gValue->GetText().ToNumber<int>(true);
b = a->bValue->GetText().ToNumber<int>(true);
alpha = a->aValue->GetText().ToNumber<int>(true);
if (r > 255)
r = 255;
if (g > 255)
@ -82,9 +82,9 @@ ColourPickerActivity::ColourPickerActivity(ui::Colour initialColour, ColourPicke
void ActionCallback(ui::Button * sender)
{
int Red, Green, Blue;
Red = format::StringToNumber<int>(a->rValue->GetText());
Green = format::StringToNumber<int>(a->gValue->GetText());
Blue = format::StringToNumber<int>(a->bValue->GetText());
Red = a->rValue->GetText().ToNumber<int>(true);
Green = a->gValue->GetText().ToNumber<int>(true);
Blue = a->bValue->GetText().ToNumber<int>(true);
ui::Colour col(Red, Green, Blue, a->currentAlpha);
if(a->callback)
a->callback->ColourPicked(col);
@ -104,13 +104,11 @@ ColourPickerActivity::ColourPickerActivity(ui::Colour initialColour, ColourPicke
void ColourPickerActivity::UpdateTextboxes(int r, int g, int b, int a)
{
rValue->SetText(format::NumberToString<int>(r));
gValue->SetText(format::NumberToString<int>(g));
bValue->SetText(format::NumberToString<int>(b));
aValue->SetText(format::NumberToString<int>(a));
std::stringstream hex;
hex << std::hex << "0x" << std::setfill('0') << std::setw(2) << std::uppercase << a << std::setw(2) << r << std::setw(2) << g << std::setw(2) << b;
hexValue->SetText(hex.str());
rValue->SetText(String::Build(r));
gValue->SetText(String::Build(g));
bValue->SetText(String::Build(b));
aValue->SetText(String::Build(a));
hexValue->SetText(String::Build(Format::Hex(), Format::Uppercase(), Format::Width(2), a, r, g, b));
}
void ColourPickerActivity::OnTryExit(ExitMethod method)
{

View File

@ -1,7 +1,7 @@
#pragma once
#include <vector>
#include <string>
#include "common/String.h"
#include "Activity.h"
#include "gui/interface/Window.h"
#include "gui/interface/Textbox.h"

View File

@ -4,18 +4,18 @@
class ConsoleCommand
{
public:
ConsoleCommand(std::string command, int returnStatus, std::string returnValue):
ConsoleCommand(String command, int returnStatus, String returnValue):
Command(command), ReturnStatus(returnStatus), ReturnValue(returnValue)
{
}
std::string Command;
String Command;
int ReturnStatus;
std::string ReturnValue;
String ReturnValue;
operator std::string() const
operator ByteString() const
{
return Command;
return Command.ToUtf8();
}
};

View File

@ -13,11 +13,11 @@ ConsoleController::ConsoleController(ControllerCallback * callback, CommandInter
this->commandInterface = commandInterface;
}
void ConsoleController::EvaluateCommand(std::string command)
void ConsoleController::EvaluateCommand(String command)
{
if(command.length())
{
if (command.substr(0, 6) == "!load ")
if (command.BeginsWith("!load "))
CloseConsole();
int returnCode = commandInterface->Command(command);
consoleModel->AddLastCommand(ConsoleCommand(command, returnCode, commandInterface->GetLastError()));
@ -31,7 +31,7 @@ void ConsoleController::CloseConsole()
consoleView->CloseActiveWindow();
}
std::string ConsoleController::FormatCommand(std::string command)
String ConsoleController::FormatCommand(String command)
{
return commandInterface->FormatCommand(command);
}

View File

@ -1,7 +1,7 @@
#ifndef CONSOLECONTROLLER_H_
#define CONSOLECONTROLLER_H_
#include <string>
#include "common/String.h"
#include "Controller.h"
#include "ConsoleView.h"
#include "ConsoleModel.h"
@ -18,8 +18,8 @@ class ConsoleController {
public:
bool HasDone;
ConsoleController(ControllerCallback * callback, CommandInterface * commandInterface);
std::string FormatCommand(std::string command);
void EvaluateCommand(std::string command);
String FormatCommand(String command);
void EvaluateCommand(String command);
void NextCommand();
void PreviousCommand();
void Exit();

View File

@ -2,8 +2,8 @@
#include "ConsoleModel.h"
ConsoleModel::ConsoleModel() {
std::vector<std::string> previousHistory = Client::Ref().GetPrefStringArray("Console.History");
for(std::vector<std::string>::reverse_iterator iter = previousHistory.rbegin(), end = previousHistory.rend(); iter != end; ++iter)
std::vector<String> previousHistory = Client::Ref().GetPrefStringArray("Console.History");
for(std::vector<String>::reverse_iterator iter = previousHistory.rbegin(), end = previousHistory.rend(); iter != end; ++iter)
{
if(previousCommands.size()<25)
{

View File

@ -6,7 +6,7 @@
#include "gui/interface/ScrollPanel.h"
#include "PowderToy.h"
ConfirmPrompt::ConfirmPrompt(std::string title, std::string message, ConfirmDialogueCallback * callback_):
ConfirmPrompt::ConfirmPrompt(String title, String message, ConfirmDialogueCallback * callback_):
ui::Window(ui::Point(-1, -1), ui::Point(250, 35)),
callback(callback_)
{
@ -68,7 +68,7 @@ ConfirmPrompt::ConfirmPrompt(std::string title, std::string message, ConfirmDial
MakeActiveWindow();
}
ConfirmPrompt::ConfirmPrompt(std::string title, std::string message, std::string buttonText, ConfirmDialogueCallback * callback_):
ConfirmPrompt::ConfirmPrompt(String title, String message, String buttonText, ConfirmDialogueCallback * callback_):
ui::Window(ui::Point(-1, -1), ui::Point(250, 50)),
callback(callback_)
{
@ -130,7 +130,7 @@ ConfirmPrompt::ConfirmPrompt(std::string title, std::string message, std::string
MakeActiveWindow();
}
bool ConfirmPrompt::Blocking(std::string title, std::string message, std::string buttonText)
bool ConfirmPrompt::Blocking(String title, String message, String buttonText)
{
class BlockingPromptCallback: public ConfirmDialogueCallback {
public:

View File

@ -1,16 +1,16 @@
#ifndef CONFIRMPROMPT_H_
#define CONFIRMPROMPT_H_
#include <string>
#include "common/String.h"
#include "gui/interface/Window.h"
class ConfirmDialogueCallback;
class ConfirmPrompt: public ui::Window {
public:
enum DialogueResult { ResultCancel, ResultOkay };
ConfirmPrompt(std::string title, std::string message, ConfirmDialogueCallback * callback_ = NULL);
ConfirmPrompt(std::string title, std::string message, std::string buttonText, ConfirmDialogueCallback * callback_ = NULL);
static bool Blocking(std::string title, std::string message, std::string buttonText = "Confirm");
ConfirmPrompt(String title, String message, ConfirmDialogueCallback * callback_ = NULL);
ConfirmPrompt(String title, String message, String buttonText, ConfirmDialogueCallback * callback_ = NULL);
static bool Blocking(String title, String message, String buttonText = "Confirm");
virtual void OnDraw();
virtual ~ConfirmPrompt();
ConfirmDialogueCallback * callback;

View File

@ -5,7 +5,7 @@
#include "gui/interface/Label.h"
#include "PowderToy.h"
ErrorMessage::ErrorMessage(std::string title, std::string message, ErrorMessageCallback * callback_):
ErrorMessage::ErrorMessage(String title, String message, ErrorMessageCallback * callback_):
ui::Window(ui::Point(-1, -1), ui::Point(200, 35)),
callback(callback_)
{
@ -50,7 +50,7 @@ ErrorMessage::ErrorMessage(std::string title, std::string message, ErrorMessage
MakeActiveWindow();
}
void ErrorMessage::Blocking(std::string title, std::string message)
void ErrorMessage::Blocking(String title, String message)
{
class BlockingDismissCallback: public ErrorMessageCallback {
public:

View File

@ -7,8 +7,8 @@ class ErrorMessageCallback;
class ErrorMessage: public ui::Window {
ErrorMessageCallback * callback;
public:
ErrorMessage(std::string title, std::string message, ErrorMessageCallback * callback_ = NULL);
static void Blocking(std::string title, std::string message);
ErrorMessage(String title, String message, ErrorMessageCallback * callback_ = NULL);
static void Blocking(String title, String message);
virtual void OnDraw();
virtual ~ErrorMessage();
};

View File

@ -5,7 +5,7 @@
#include "gui/interface/Label.h"
#include "gui/interface/ScrollPanel.h"
InformationMessage::InformationMessage(std::string title, std::string message, bool large):
InformationMessage::InformationMessage(String title, String message, bool large):
ui::Window(ui::Point(-1, -1), ui::Point(200, 35))
{
if (large) //Maybe also use this large mode for changelogs eventually, or have it as a customizable size?

View File

@ -5,7 +5,7 @@
class InformationMessage: public ui::Window {
public:
InformationMessage(std::string title, std::string message, bool large);
InformationMessage(String title, String message, bool large);
virtual void OnDraw();
virtual ~InformationMessage();
};

View File

@ -2,10 +2,10 @@
//Legacy blocking prompts
//This are not implemented here, but rather in the engine bootstrapper
bool ConfirmUI(std::string title, std::string message, std::string confirmText) {}
bool ConfirmUI(String title, String message, String confirmText) {}
void ErrorUI(std::string title, std::string message) {}
void ErrorUI(String title, String message) {}
void InformationUI(std::string title, std::string message) {}
void InformationUI(String title, String message) {}
std::string MessagePromptUI(std::string title, std::string message, std::string text, std::string placeholder) {}
String MessagePromptUI(String title, String message, String text, String placeholder) {}

View File

@ -28,8 +28,8 @@ SaveIDMessage::SaveIDMessage(int id):
copyTextLabel->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
AddComponent(copyTextLabel);
textWidth = Graphics::textwidth(format::NumberToString<int>(id).c_str());
ui::CopyTextButton * copyTextButton = new ui::CopyTextButton(ui::Point((Size.X-textWidth-10)/2, 50), ui::Point(textWidth+10, 18), format::NumberToString<int>(id), copyTextLabel);
textWidth = Graphics::textwidth(String::Build(id));
ui::CopyTextButton * copyTextButton = new ui::CopyTextButton(ui::Point((Size.X-textWidth-10)/2, 50), ui::Point(textWidth+10, 18), String::Build(id), copyTextLabel);
AddComponent(copyTextButton);
class DismissAction: public ui::ButtonAction

View File

@ -21,7 +21,7 @@ public:
}
};
TextPrompt::TextPrompt(std::string title, std::string message, std::string text, std::string placeholder, bool multiline, TextDialogueCallback * callback_):
TextPrompt::TextPrompt(String title, String message, String text, String placeholder, bool multiline, TextDialogueCallback * callback_):
ui::Window(ui::Point(-1, -1), ui::Point(200, 65)),
callback(callback_)
{
@ -77,15 +77,15 @@ TextPrompt::TextPrompt(std::string title, std::string message, std::string text,
MakeActiveWindow();
}
std::string TextPrompt::Blocking(std::string title, std::string message, std::string text, std::string placeholder, bool multiline)
String TextPrompt::Blocking(String title, String message, String text, String placeholder, bool multiline)
{
std::string returnString = "";
String returnString = "";
class BlockingTextCallback: public TextDialogueCallback {
std::string & outputString;
String & outputString;
public:
BlockingTextCallback(std::string & output) : outputString(output) {}
virtual void TextCallback(TextPrompt::DialogueResult result, std::string resultText) {
BlockingTextCallback(String & output) : outputString(output) {}
virtual void TextCallback(TextPrompt::DialogueResult result, String resultText) {
if(result == ResultOkay)
outputString = resultText;
else

View File

@ -11,8 +11,8 @@ protected:
public:
friend class CloseAction;
enum DialogueResult { ResultCancel, ResultOkay };
TextPrompt(std::string title, std::string message, std::string text, std::string placeholder, bool multiline, TextDialogueCallback * callback_);
static std::string Blocking(std::string title, std::string message, std::string text, std::string placeholder, bool multiline);
TextPrompt(String title, String message, String text, String placeholder, bool multiline, TextDialogueCallback * callback_);
static String Blocking(String title, String message, String text, String placeholder, bool multiline);
virtual void OnDraw();
virtual ~TextPrompt();
TextDialogueCallback * callback;
@ -21,7 +21,7 @@ public:
class TextDialogueCallback
{
public:
virtual void TextCallback(TextPrompt::DialogueResult result, std::string resultText) {}
virtual void TextCallback(TextPrompt::DialogueResult result, String resultText) {}
virtual ~TextDialogueCallback() {}
};

View File

@ -1,4 +1,5 @@
#include <algorithm>
#include "common/String.h"
#include "ElementSearchActivity.h"
#include "gui/interface/Textbox.h"
#include "gui/interface/Label.h"
@ -91,7 +92,7 @@ ElementSearchActivity::ElementSearchActivity(GameController * gameController, st
searchTools("");
}
void ElementSearchActivity::searchTools(std::string query)
void ElementSearchActivity::searchTools(String query)
{
firstResult = NULL;
for(std::vector<ToolButton*>::iterator iter = toolButtons.begin(), end = toolButtons.end(); iter != end; ++iter) {
@ -103,7 +104,7 @@ void ElementSearchActivity::searchTools(std::string query)
ui::Point viewPosition = searchField->Position + ui::Point(2+0, searchField->Size.Y+2+8);
ui::Point current = ui::Point(0, 0);
std::string queryLower = std::string(query);
ByteString queryLower = query.ToAscii();
std::transform(queryLower.begin(), queryLower.end(), queryLower.begin(), ::tolower);
std::vector<Tool *> matches;
@ -112,13 +113,13 @@ void ElementSearchActivity::searchTools(std::string query)
for(std::vector<Tool*>::const_iterator iter = tools.begin(), end = tools.end(); iter != end; ++iter)
{
std::string nameLower = std::string((*iter)->GetName());
ByteString nameLower = (*iter)->GetName();
std::transform(nameLower.begin(), nameLower.end(), nameLower.begin(), ::tolower);
if(!strcmp(nameLower.c_str(), queryLower.c_str()))
if(nameLower == queryLower)
exactmatches.push_back(*iter);
else if(!strncmp(nameLower.c_str(), queryLower.c_str(), queryLower.length()))
else if(nameLower.BeginsWith(queryLower))
frontmatches.push_back(*iter);
else if(strstr(nameLower.c_str(), queryLower.c_str()))
else if(nameLower.Contains(queryLower))
matches.push_back(*iter);
}
@ -180,7 +181,7 @@ void ElementSearchActivity::SetActiveTool(int selectionState, Tool * tool)
gameController->RebuildFavoritesMenu();
}
else if (ctrlPressed && altPressed && !shiftPressed &&
tool->GetIdentifier().find("DEFAULT_PT_") != tool->GetIdentifier().npos)
tool->GetIdentifier().Contains("DEFAULT_PT_"))
{
gameController->SetActiveTool(3, tool);
}
@ -198,7 +199,7 @@ void ElementSearchActivity::OnDraw()
g->drawrect(Position.X+searchField->Position.X, Position.Y+searchField->Position.Y+searchField->Size.Y+8, searchField->Size.X, Size.Y-(searchField->Position.Y+searchField->Size.Y+8)-23, 255, 255, 255, 180);
if (toolTipPresence && toolTip.length())
{
g->drawtext(10, Size.Y+70, (char*)toolTip.c_str(), 255, 255, 255, toolTipPresence>51?255:toolTipPresence*5);
g->drawtext(10, Size.Y+70, toolTip, 255, 255, 255, toolTipPresence>51?255:toolTipPresence*5);
}
}
@ -265,7 +266,7 @@ void ElementSearchActivity::OnKeyRelease(int key, Uint16 character, bool shift,
}
}
void ElementSearchActivity::ToolTip(ui::Point senderPosition, std::string toolTip)
void ElementSearchActivity::ToolTip(ui::Point senderPosition, String toolTip)
{
this->toolTip = toolTip;
this->isToolTipFadingIn = true;

View File

@ -2,7 +2,6 @@
#define ELEMENTSEARCHACTIVITY_H_
#include <vector>
#include <string>
#include "Activity.h"
#include "gui/interface/Window.h"
#include "gui/interface/Textbox.h"
@ -18,13 +17,13 @@ class ElementSearchActivity: public WindowActivity
std::vector<Tool*> tools;
ui::Textbox * searchField;
std::vector<ToolButton*> toolButtons;
std::string toolTip;
String toolTip;
int toolTipPresence;
bool shiftPressed;
bool ctrlPressed;
bool altPressed;
bool isToolTipFadingIn;
void searchTools(std::string query);
void searchTools(String query);
public:
class ToolAction;
@ -37,7 +36,7 @@ public:
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void OnDraw();
virtual void ToolTip(ui::Point senderPosition, std::string ToolTip);
virtual void ToolTip(ui::Point senderPosition, String ToolTip);
};
#endif /* ELEMENTSEARCHACTIVITY_H_ */

View File

@ -1,4 +1,3 @@
#include <sstream>
#include <iostream>
#include <algorithm>
#include "FileBrowserActivity.h"
@ -42,8 +41,8 @@ public:
//Currently, reading is done on another thread, we can't render outside the main thread due to some bullshit with OpenGL
class LoadFilesTask: public Task
{
std::string directory;
std::string search;
ByteString directory;
ByteString search;
std::vector<SaveFile*> saveFiles;
virtual void before()
@ -58,15 +57,15 @@ class LoadFilesTask: public Task
virtual bool doWork()
{
std::vector<std::string> files = Client::Ref().DirectorySearch(directory, search, ".cps");
std::sort(files.rbegin(), files.rend(), [](std::string a, std::string b) {
std::vector<ByteString> files = Client::Ref().DirectorySearch(directory, search, ".cps");
std::sort(files.rbegin(), files.rend(), [](ByteString a, ByteString b) {
std::transform(a.begin(), a.end(), a.begin(), ::tolower);
std::transform(b.begin(), b.end(), b.begin(), ::tolower);
return a < b;
});
notifyProgress(-1);
for(std::vector<std::string>::iterator iter = files.begin(), end = files.end(); iter != end; ++iter)
for(std::vector<ByteString>::iterator iter = files.begin(), end = files.end(); iter != end; ++iter)
{
SaveFile * saveFile = new SaveFile(*iter);
try
@ -76,18 +75,9 @@ class LoadFilesTask: public Task
saveFile->SetGameSave(tempSave);
saveFiles.push_back(saveFile);
std::string filename = *iter;
size_t folderPos = filename.rfind(PATH_SEP);
if(folderPos!=std::string::npos && folderPos+1 < filename.size())
{
filename = filename.substr(folderPos+1);
}
size_t extPos = filename.rfind(".");
if(extPos!=std::string::npos)
{
filename = filename.substr(0, extPos);
}
saveFile->SetDisplayName(filename);
ByteString filename = (*iter).SplitFromEndBy(PATH_SEP).After();
filename = filename.SplitBy('.').Before();
saveFile->SetDisplayName(filename.FromUtf8());
}
catch(std::exception & e)
{
@ -103,7 +93,7 @@ public:
return saveFiles;
}
LoadFilesTask(std::string directory, std::string search):
LoadFilesTask(ByteString directory, ByteString search):
directory(directory),
search(search)
{
@ -117,11 +107,11 @@ public:
FileBrowserActivity * a;
SearchAction(FileBrowserActivity * a) : a(a) {}
virtual void TextChangedCallback(ui::Textbox * sender) {
a->DoSearch(sender->GetText());
a->DoSearch(sender->GetText().ToUtf8());
}
};
FileBrowserActivity::FileBrowserActivity(std::string directory, FileSelectedCallback * callback):
FileBrowserActivity::FileBrowserActivity(ByteString directory, FileSelectedCallback * callback):
WindowActivity(ui::Point(-1, -1), ui::Point(450, 300)),
callback(callback),
directory(directory),
@ -167,7 +157,7 @@ FileBrowserActivity::FileBrowserActivity(std::string directory, FileSelectedCall
loadDirectory(directory, "");
}
void FileBrowserActivity::DoSearch(std::string search)
void FileBrowserActivity::DoSearch(ByteString search)
{
if(!loadFiles)
{
@ -184,7 +174,7 @@ void FileBrowserActivity::SelectSave(SaveFile * file)
void FileBrowserActivity::DeleteSave(SaveFile * file)
{
std::string deleteMessage = "Are you sure you want to delete " + file->GetDisplayName() + ".cps?";
String deleteMessage = "Are you sure you want to delete " + file->GetDisplayName() + ".cps?";
if (ConfirmPrompt::Blocking("Delete Save", deleteMessage))
{
remove(file->GetName().c_str());
@ -194,7 +184,7 @@ void FileBrowserActivity::DeleteSave(SaveFile * file)
void FileBrowserActivity::RenameSave(SaveFile * file)
{
std::string newName = TextPrompt::Blocking("Rename", "Change save name", file->GetDisplayName(), "", 0);
ByteString newName = TextPrompt::Blocking("Rename", "Change save name", file->GetDisplayName(), "", 0).ToUtf8();
if (newName.length())
{
newName = directory + PATH_SEP + newName + ".cps";
@ -208,7 +198,7 @@ void FileBrowserActivity::RenameSave(SaveFile * file)
ErrorMessage::Blocking("Error", "No save name given");
}
void FileBrowserActivity::loadDirectory(std::string directory, std::string search)
void FileBrowserActivity::loadDirectory(ByteString directory, ByteString search)
{
for (size_t i = 0; i < components.size(); i++)
{

View File

@ -1,7 +1,7 @@
#pragma once
#include <vector>
#include <string>
#include "common/String.h"
#include "Activity.h"
#include "gui/interface/Window.h"
#include "tasks/TaskListener.h"
@ -33,7 +33,7 @@ class FileBrowserActivity: public TaskListener, public WindowActivity
std::vector<SaveFile*> files;
std::vector<ui::Component*> components;
std::vector<ui::Component*> componentsQueue;
std::string directory;
ByteString directory;
ui::ProgressBar * progressBar;
@ -46,16 +46,16 @@ class FileBrowserActivity: public TaskListener, public WindowActivity
class SearchAction;
void populateList();
public:
FileBrowserActivity(std::string directory, FileSelectedCallback * callback);
FileBrowserActivity(ByteString directory, FileSelectedCallback * callback);
virtual void OnDraw();
virtual void OnTick(float dt);
virtual void OnTryExit(ExitMethod method);
virtual void OnMouseDown(int x, int y, unsigned button);
void loadDirectory(std::string directory, std::string search);
void loadDirectory(ByteString directory, ByteString search);
void SelectSave(SaveFile * file);
void DeleteSave(SaveFile * file);
void RenameSave(SaveFile * file);
void DoSearch(std::string search);
void DoSearch(ByteString search);
virtual ~FileBrowserActivity();
virtual void NotifyDone(Task * task);

657
src/gui/font/FontEditor.cpp Normal file
View File

@ -0,0 +1,657 @@
#include <stdexcept>
#include <fstream>
#include <iterator>
#include <iomanip>
#include <iostream>
#include "FontEditor.h"
#include "Config.h"
#include "gui/interface/Engine.h"
#include "gui/interface/Point.h"
#include "gui/interface/Button.h"
#include "gui/interface/Mouse.h"
#include "gui/interface/Keys.h"
#include "graphics/Graphics.h"
#ifdef FONTEDITOR
unsigned char *font_data;
unsigned short *font_ptrs;
unsigned int (*font_ranges)[2];
void FontEditor::ReadHeader(ByteString header)
{
std::fstream file;
file.open(header, std::ios_base::in);
if(!file)
throw std::runtime_error("Could not open " + header);
file >> std::skipws;
ByteString word;
while(word != "font_data[]")
file >> word;
file >> word >> word;
size_t startFontData = file.tellg();
fontData.clear();
do
{
unsigned int value;
file >> std::hex >> value;
if(!file.fail())
{
fontData.push_back(value);
file >> word;
}
}
while(!file.fail());
file.clear();
size_t endFontData = file.tellg();
while(word != "font_ptrs[]")
file >> word;
file >> word >> word;
size_t startFontPtrs = file.tellg();
fontPtrs.clear();
do
{
unsigned int value;
file >> std::hex >> value;
if(!file.fail())
{
fontPtrs.push_back(value);
file >> word;
}
}
while(!file.fail());
file.clear();
size_t endFontPtrs = file.tellg();
while(word != "font_ranges[][2]")
file >> word;
file >> word >> word;
size_t startFontRanges = file.tellg();
fontRanges.clear();
while(true)
{
unsigned int value1, value2;
file >> word >> std::hex >> value1 >> word >> std::hex >> value2 >> word;
if(file.fail())
break;
fontRanges.push_back({value1, value2});
if(!value2)
break;
}
file.clear();
size_t endFontRanges = file.tellg();
do
{
file >> word;
}
while(!file.fail());
file.clear();
size_t eof = file.tellg();
file.seekg(0);
beforeFontData = ByteString(startFontData, 0);
file.read(&beforeFontData[0], startFontData);
file.seekg(endFontData);
afterFontData = ByteString(startFontPtrs - endFontData, 0);
file.read(&afterFontData[0], startFontPtrs - endFontData);
file.seekg(endFontPtrs);
afterFontPtrs = ByteString(startFontRanges - endFontPtrs, 0);
file.read(&afterFontPtrs[0], startFontRanges - endFontPtrs);
file.seekg(endFontRanges);
afterFontRanges = ByteString(eof - endFontRanges, 0);
file.read(&afterFontRanges[0], eof - endFontRanges);
file.close();
}
void FontEditor::WriteHeader(ByteString header, std::vector<unsigned char> const &fontData, std::vector<unsigned short> const &fontPtrs, std::vector<std::array<unsigned int, 2> > const &fontRanges)
{
std::fstream file;
file.open(header, std::ios_base::out | std::ios_base::trunc);
if(!file)
throw std::runtime_error("Could not open " + header);
file << std::setfill('0') << std::hex << std::uppercase;
file << beforeFontData << std::endl;
size_t pos = 0;
size_t ptrpos = 0;
while(pos < fontData.size())
{
file << " " << "0x" << std::setw(2) << (unsigned int)fontData[pos] << ", ";
for(pos++; pos < fontData.size() && (ptrpos == fontPtrs.size() - 1 || pos < (size_t)fontPtrs[ptrpos + 1]); pos++)
file << " " << "0x" << std::setw(2) << (unsigned int)fontData[pos] << ",";
file << std::endl;
ptrpos++;
}
file << afterFontData;
pos = 0;
for(size_t i = 0; pos < fontPtrs.size() && fontRanges[i][1]; i++)
{
bool first = true;
for(String::value_type ch = fontRanges[i][0]; ch <= fontRanges[i][1]; ch++)
{
if(!(ch & 0x7) || first)
file << std::endl << " ";
else
file << " ";
first = false;
file << "0x" << std::setw(4) << (unsigned int)fontPtrs[pos++] << ",";
}
file << std::endl;
}
file << afterFontPtrs << std::endl;
for(size_t i = 0; i < fontRanges.size() - 1; i++)
file << " { 0x" << std::setw(6) << (unsigned int)fontRanges[i][0] << ", 0x" << std::setw(6) << (unsigned int)fontRanges[i][1] << " }," << std::endl;
file << " { 0, 0 },";
file << afterFontRanges;
file.close();
}
void FontEditor::UnpackData(
std::map<String::value_type, unsigned char> &fontWidths,
std::map<String::value_type, std::array<std::array<char, MAX_WIDTH>, FONT_H> > &fontPixels,
std::vector<unsigned char> const &fontData,
std::vector<unsigned short> const &fontPtrs,
std::vector<std::array<unsigned int, 2> > const &fontRanges)
{
fontWidths.clear();
fontPixels.clear();
size_t pos = 0;
for(size_t range = 0; fontRanges[range][1]; range++)
for(String::value_type ch = fontRanges[range][0]; ch <= fontRanges[range][1]; ch++)
{
unsigned char const *pointer = &fontData[fontPtrs[pos]];
int width = fontWidths[ch] = *(pointer++);
int pixels = 0;
int data = 0;
for(int j = 0; j < FONT_H; j++)
for(int i = 0; i < width; i++)
{
if(!pixels)
{
data = *(pointer++);
pixels = 4;
}
fontPixels[ch][j][i] = data & 3;
data >>= 2;
pixels--;
}
pos++;
}
}
void FontEditor::PackData(
std::map<String::value_type, unsigned char> const &fontWidths,
std::map<String::value_type, std::array<std::array<char, MAX_WIDTH>, FONT_H> > const &fontPixels,
std::vector<unsigned char> &fontData,
std::vector<unsigned short> &fontPtrs,
std::vector<std::array<unsigned int, 2> > &fontRanges)
{
fontData.clear();
fontPtrs.clear();
fontRanges.clear();
bool first = true;
String::value_type rangeStart;
String::value_type prev;
for(std::map<String::value_type, unsigned char>::const_iterator it = fontWidths.begin(); it != fontWidths.end(); it++)
{
String::value_type ch = it->first;
if(first)
{
rangeStart = ch;
first = false;
}
else
if(ch != prev + 1)
{
fontRanges.push_back({rangeStart, prev});
rangeStart = ch;
}
fontPtrs.push_back(fontData.size());
fontData.push_back(it->second);
int pixels = 0;
int data = 0;
for(int j = 0; j < FONT_H; j++)
for(int i = 0; i < it->second; i++)
{
if(pixels == 4)
{
fontData.push_back(data);
pixels = 0;
data = 0;
}
data >>= 2;
data |= fontPixels.at(ch)[j][i] << 6;
pixels++;
}
if(pixels)
fontData.push_back(data);
prev = ch;
}
fontRanges.push_back({rangeStart, prev});
fontRanges.push_back({0, 0});
}
#define FONT_SCALE 16
FontEditor::FontEditor(ByteString _header):
ui::Window(ui::Point(0, 0), ui::Point(WINDOWW, WINDOWH)),
header(_header),
currentChar(0x80),
fgR(255), fgG(255), fgB(255), bgR(0), bgG(0), bgB(0),
grid(1),
rulers(1)
{
ReadHeader(header);
UnpackData(fontWidths, fontPixels, fontData, fontPtrs, fontRanges);
font_data = fontData.data();
font_ptrs = fontPtrs.data();
font_ranges = (unsigned int (*)[2])fontRanges.data();
int baseline = 8 + FONT_H * FONT_SCALE + 4 + FONT_H + 4 + 1;
int currentX = 1;
class PrevCharAction : public ui::ButtonAction
{
FontEditor *v;
public:
PrevCharAction(FontEditor *_v): v(_v) {}
void ActionCallback(ui::Button *)
{
v->PrevChar();
}
};
ui::Button *prev = new ui::Button(ui::Point(currentX, baseline), ui::Point(17, 17), 0xE016);
currentX += 18;
prev->SetActionCallback(new PrevCharAction(this));
AddComponent(prev);
class CharNumberAction : public ui::TextboxAction
{
FontEditor *v;
public:
CharNumberAction(FontEditor *_v): v(_v) {}
void TextChangedCallback(ui::Textbox *)
{
unsigned int number = v->currentCharTextbox->GetText().ToNumber<unsigned int>(true);
if(number <= 0x10FFFF)
v->currentChar = number;
}
};
currentCharTextbox = new ui::Textbox(ui::Point(currentX, baseline), ui::Point(31, 17));
currentX += 32;
currentCharTextbox->SetActionCallback(new CharNumberAction(this));
UpdateCharNumber();
AddComponent(currentCharTextbox);
class NextCharAction : public ui::ButtonAction
{
FontEditor *v;
public:
NextCharAction(FontEditor *_v): v(_v) {}
void ActionCallback(ui::Button *)
{
v->NextChar();
}
};
ui::Button *next = new ui::Button(ui::Point(currentX, baseline), ui::Point(17, 17), 0xE015);
currentX += 18;
next->SetActionCallback(new NextCharAction(this));
AddComponent(next);
class ShrinkCharAction : public ui::ButtonAction
{
FontEditor *v;
public:
ShrinkCharAction(FontEditor *_v): v(_v) {}
void ActionCallback(ui::Button *)
{
v->ShrinkChar();
}
};
ui::Button *shrink = new ui::Button(ui::Point(currentX, baseline), ui::Point(17, 17), "><");
currentX += 18;
shrink->SetActionCallback(new ShrinkCharAction(this));
AddComponent(shrink);
class GrowCharAction : public ui::ButtonAction
{
FontEditor *v;
public:
GrowCharAction(FontEditor *_v): v(_v) {}
void ActionCallback(ui::Button *)
{
v->GrowChar();
}
};
ui::Button *grow = new ui::Button(ui::Point(currentX, baseline), ui::Point(17, 17), "<>");
currentX += 18;
grow->SetActionCallback(new GrowCharAction(this));
AddComponent(grow);
class AddCharAction : public ui::ButtonAction
{
FontEditor *v;
public:
AddCharAction(FontEditor *_v): v(_v) {}
void ActionCallback(ui::Button *)
{
if(v->fontWidths.find(v->currentChar) == v->fontWidths.end())
{
v->savedButton->SetToggleState(false);
v->fontWidths[v->currentChar] = 5;
v->fontPixels[v->currentChar];
}
}
};
ui::Button *add = new ui::Button(ui::Point(currentX, baseline), ui::Point(36, 17), "Add");
currentX += 37;
add->SetActionCallback(new AddCharAction(this));
AddComponent(add);
class RemoveCharAction : public ui::ButtonAction
{
FontEditor *v;
public:
RemoveCharAction(FontEditor *_v): v(_v) {}
void ActionCallback(ui::Button *)
{
if(v->fontWidths.find(v->currentChar) != v->fontWidths.end())
{
v->savedButton->SetToggleState(false);
v->fontWidths.erase(v->currentChar);
v->fontPixels.erase(v->currentChar);
}
}
};
ui::Button *remove = new ui::Button(ui::Point(currentX, baseline), ui::Point(36, 17), "Remove");
currentX += 37;
remove->SetActionCallback(new RemoveCharAction(this));
AddComponent(remove);
class ToggleAction : public ui::ButtonAction
{
int &toggle;
public:
ToggleAction(int &_toggle): toggle(_toggle) {}
void ActionCallback(ui::Button *button)
{
toggle = button->GetToggleState();
}
};
ui::Button *showGrid = new ui::Button(ui::Point(currentX, baseline), ui::Point(32, 17), "Grid");
currentX += 33;
showGrid->SetTogglable(true);
showGrid->SetToggleState(grid);
showGrid->SetActionCallback(new ToggleAction(grid));
AddComponent(showGrid);
ui::Button *showRulers = new ui::Button(ui::Point(currentX, baseline), ui::Point(32, 17), "Rulers");
currentX += 33;
showRulers->SetTogglable(true);
showRulers->SetToggleState(grid);
showRulers->SetActionCallback(new ToggleAction(rulers));
AddComponent(showRulers);
baseline += 18;
currentX = 1;
class ColorComponentAction : public ui::TextboxAction
{
int &color;
public:
ColorComponentAction(int &_color): color(_color) {}
void TextChangedCallback(ui::Textbox *box)
{
color = box->GetText().ToNumber<int>(true);
}
};
int *refs[6] = {&fgR, &fgG, &fgB, &bgR, &bgG, &bgB};
for(int i = 0; i < 6; i++)
{
ui::Textbox *colorComponent = new ui::Textbox(ui::Point(currentX, baseline), ui::Point(27, 17), String::Build(*refs[i]));
currentX += 28;
colorComponent->SetActionCallback(new ColorComponentAction(*refs[i]));
AddComponent(colorComponent);
}
baseline += 18;
currentX = 1;
class RenderAction : public ui::ButtonAction
{
FontEditor *v;
public:
RenderAction(FontEditor *_v): v(_v) {}
void ActionCallback(ui::Button *)
{
v->Render();
}
};
ui::Button *render = new ui::Button(ui::Point(currentX, baseline), ui::Point(50, 17), "Render");
currentX += 51;
render->SetActionCallback(new RenderAction(this));
AddComponent(render);
class SaveAction : public ui::ButtonAction
{
FontEditor *v;
public:
SaveAction(FontEditor *_v): v(_v) {}
void ActionCallback(ui::Button *)
{
v->Save();
}
};
savedButton = new ui::Button(ui::Point(currentX, baseline), ui::Point(50, 17), "Save");
currentX += 51;
savedButton->SetTogglable(true);
savedButton->SetToggleState(true);
savedButton->SetActionCallback(new SaveAction(this));
AddComponent(savedButton);
baseline += 18;
outputPreview = new ui::Label(ui::Point(0, baseline + (Size.Y - baseline) * 3 / 5), ui::Point(Size.X, (Size.Y - baseline) * 2 / 5), "");
outputPreview->SetMultiline(true);
outputPreview->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
outputPreview->Appearance.VerticalAlign = ui::Appearance::AlignTop;
AddComponent(outputPreview);
class PreviewAction : public ui::TextboxAction
{
FontEditor *v;
public:
PreviewAction(FontEditor *_v): v(_v) {}
void TextChangedCallback(ui::Textbox *box)
{
String str = box->GetText();
size_t at = 0;
StringBuilder text;
while(at < str.size())
{
unsigned int ch;
if(str[at] != ' ')
if(String::Split split = str.SplitNumber(ch, Format::Hex(), at))
{
text << String::value_type(ch);
at = split.PositionAfter();
}
else
{
text << str[at++];
}
else
at++;
}
v->outputPreview->SetText(text.Build());
}
};
ui::Textbox *inputPreview = new ui::Textbox(ui::Point(0, baseline), ui::Point(Size.X, (Size.Y - baseline) * 3 / 5));
inputPreview->SetMultiline(true);
inputPreview->SetInputType(ui::Textbox::Multiline);
inputPreview->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
inputPreview->Appearance.VerticalAlign = ui::Appearance::AlignTop;
inputPreview->SetActionCallback(new PreviewAction(this));
StringBuilder input;
input << Format::Hex() << Format::Width(2);
for(unsigned int ch = 0x20; ch <= 0xFF; ch++)
{
if(!(ch & 0x3F))
input << 0x20 << " ";
input << ch << " ";
}
inputPreview->SetText(input.Build());
PreviewAction(this).TextChangedCallback(inputPreview);
AddComponent(inputPreview);
}
void FontEditor::OnDraw()
{
Graphics *g = GetGraphics();
if(fontWidths.find(currentChar) != fontWidths.end())
{
int width = fontWidths[currentChar];
std::array<std::array<char, MAX_WIDTH>, FONT_H> const &pixels = fontPixels[currentChar];
int areaWidth = 8 + width * FONT_SCALE + 8;
g->fillrect(0, 0, areaWidth, 8 + FONT_H * FONT_SCALE + 4 + FONT_H + 4, bgR, bgG, bgB, 255);
for(int j = 0; j < FONT_H; j++)
for(int i = 0; i < width; i++)
g->fillrect(8 + i * FONT_SCALE, 8 + j * FONT_SCALE, FONT_SCALE - grid, FONT_SCALE - grid, fgR, fgG, fgB, pixels[j][i] * 255 / 3);
for(int j = 0; j < FONT_H; j++)
for(int i = 0; i < width; i++)
g->blendpixel(8 + i, 8 + FONT_H * FONT_SCALE + 4 + j, fgR, fgG, fgB, pixels[j][i] * 255 / 3);
if(rulers)
{
g->draw_line(0, 7 + 0 * FONT_SCALE , areaWidth - 1, 7 + 0 * FONT_SCALE, 128, 128, 128, 255);
g->draw_line(0, 7 + 2 * FONT_SCALE , areaWidth - 1, 7 + 2 * FONT_SCALE, 128, 128, 128, 255);
g->draw_line(0, 7 + 4 * FONT_SCALE , areaWidth - 1, 7 + 4 * FONT_SCALE, 128, 128, 128, 255);
g->draw_line(0, 7 + 9 * FONT_SCALE , areaWidth - 1, 7 + 9 * FONT_SCALE, 128, 128, 128, 255);
g->draw_line(0, 7 + 12 * FONT_SCALE , areaWidth - 1, 7 + 12 * FONT_SCALE, 128, 128, 128, 255);
g->draw_line(7, 8, 7, 7 + FONT_H * FONT_SCALE, 128, 128, 128, 255);
g->draw_line(7 + width * FONT_SCALE, 8, 7 + width * FONT_SCALE, 7 + FONT_H * FONT_SCALE, 128, 128, 128, 255);
}
}
else
{
g->drawtext(8, 8, "No character", 255, 0, 0, 255);
}
}
void FontEditor::OnMouseDown(int x, int y, unsigned button)
{
if(fontWidths.find(currentChar) != fontWidths.end())
{
x = (x - 8) / FONT_SCALE;
y = (y - 8) / FONT_SCALE;
if(x >= 0 && y >= 0 && x < fontWidths[currentChar] && y < FONT_H)
{
if(button == SDL_BUTTON_LEFT)
fontPixels[currentChar][y][x] = (fontPixels[currentChar][y][x] + 1) % 4;
else
fontPixels[currentChar][y][x] = (fontPixels[currentChar][y][x] + 3) % 4;
savedButton->SetToggleState(false);
}
}
}
void FontEditor::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
{
if(IsFocused(NULL))
{
switch(key)
{
case SDLK_LEFT:
PrevChar(); break;
case SDLK_RIGHT:
PrevChar(); break;
case SDLK_ESCAPE:
case 'q':
if(savedButton->GetToggleState())
ui::Engine::Ref().Exit();
else
ui::Engine::Ref().ConfirmExit();
break;
}
}
}
void FontEditor::UpdateCharNumber()
{
currentCharTextbox->SetText(String::Build(Format::Hex((unsigned int)currentChar)));
}
void FontEditor::PrevChar()
{
if(currentChar > 0)
currentChar--;
UpdateCharNumber();
}
void FontEditor::NextChar()
{
if(currentChar <= 0x10FFFF)
currentChar++;
UpdateCharNumber();
}
void FontEditor::ShrinkChar()
{
if(fontWidths[currentChar] > 0)
fontWidths[currentChar]--;
savedButton->SetToggleState(false);
}
void FontEditor::GrowChar()
{
if(fontWidths[currentChar] < MAX_WIDTH - 1)
fontWidths[currentChar]++;
savedButton->SetToggleState(false);
}
void FontEditor::Render()
{
PackData(fontWidths, fontPixels, fontData, fontPtrs, fontRanges);
font_data = fontData.data();
font_ptrs = fontPtrs.data();
font_ranges = (unsigned int (*)[2])fontRanges.data();
}
void FontEditor::Save()
{
std::vector<unsigned char> tmpFontData;
std::vector<unsigned short> tmpFontPtrs;
std::vector<std::array<unsigned int, 2> > tmpFontRanges;
PackData(fontWidths, fontPixels, tmpFontData, tmpFontPtrs, tmpFontRanges);
WriteHeader(header, tmpFontData, tmpFontPtrs, tmpFontRanges);
savedButton->SetToggleState(true);
}
#endif

72
src/gui/font/FontEditor.h Normal file
View File

@ -0,0 +1,72 @@
#ifndef FONTEDITOR_H
#define FONTEDITOR_H
#include <vector>
#include <array>
#include <map>
#include "font.h"
#include "gui/interface/Window.h"
#include "gui/interface/Textbox.h"
#define MAX_WIDTH 64
class FontEditor: public ui::Window
{
private:
ByteString header;
std::map<String::value_type, unsigned char> fontWidths;
std::map<String::value_type, std::array<std::array<char, MAX_WIDTH>, FONT_H> > fontPixels;
std::vector<unsigned char> fontData;
std::vector<unsigned short> fontPtrs;
std::vector<std::array<unsigned int, 2> > fontRanges;
ByteString beforeFontData;
ByteString afterFontData;
ByteString afterFontPtrs;
ByteString afterFontRanges;
void ReadHeader(ByteString header);
void WriteHeader(ByteString header, std::vector<unsigned char> const &fontData, std::vector<unsigned short> const &fontPtrs, std::vector<std::array<unsigned int, 2> > const &fontRanges);
static void PackData(
std::map<String::value_type, unsigned char> const &fontWidths,
std::map<String::value_type, std::array<std::array<char, MAX_WIDTH>, FONT_H> > const &fontPixels,
std::vector<unsigned char> &fontData,
std::vector<unsigned short> &fontPtrs,
std::vector<std::array<unsigned int, 2> > &fontRanges);
static void UnpackData(
std::map<String::value_type, unsigned char> &fontWidths,
std::map<String::value_type, std::array<std::array<char, MAX_WIDTH>, FONT_H> > &fontPixels,
std::vector<unsigned char> const &fontData,
std::vector<unsigned short> const &fontPtrs,
std::vector<std::array<unsigned int, 2> > const &fontRanges);
ui::Textbox *currentCharTextbox;
ui::Button *savedButton;
ui::Label *outputPreview;
String::value_type currentChar;
int fgR, fgG, fgB;
int bgR, bgG, bgB;
int grid;
int rulers;
void UpdateCharNumber();
void PrevChar();
void NextChar();
void ShrinkChar();
void GrowChar();
void Render();
void Save();
public:
FontEditor(ByteString header);
void OnDraw();
void OnMouseDown(int x, int y, unsigned button);
void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
};
#endif

View File

@ -58,7 +58,7 @@ public:
return newTexture;
}
DecorationTool(Renderer *ren_, int decoMode, string name, string description, int r, int g, int b, std::string identifier):
DecorationTool(Renderer *ren_, int decoMode, ByteString name, String description, int r, int g, int b, ByteString identifier):
Tool(decoMode, name, description, r, g, b, identifier),
Red(0),
Green(0),

View File

@ -4,16 +4,16 @@
#include <algorithm>
Favorite::Favorite():
favoritesList(std::vector<std::string>())
favoritesList(std::vector<ByteString>())
{}
std::vector<std::string> Favorite::GetFavoritesList()
std::vector<ByteString> Favorite::GetFavoritesList()
{
return favoritesList;
}
bool Favorite::IsFavorite(std::string identifier)
bool Favorite::IsFavorite(ByteString identifier)
{
return std::find(favoritesList.begin(), favoritesList.end(), identifier) != favoritesList.end();
}
@ -23,7 +23,7 @@ bool Favorite::AnyFavorites()
return favoritesList.size() == 0;
}
void Favorite::AddFavorite(std::string identifier)
void Favorite::AddFavorite(ByteString identifier)
{
if (!IsFavorite(identifier))
{
@ -31,7 +31,7 @@ void Favorite::AddFavorite(std::string identifier)
}
}
void Favorite::RemoveFavorite(std::string identifier)
void Favorite::RemoveFavorite(ByteString identifier)
{
favoritesList.erase(std::remove(favoritesList.begin(), favoritesList.end(), identifier), favoritesList.end());
}
@ -43,5 +43,5 @@ void Favorite::SaveFavoritesToPrefs()
void Favorite::LoadFavoritesFromPrefs()
{
favoritesList = Client::Ref().GetPrefStringArray("Favorites");
favoritesList = Client::Ref().GetPrefByteStringArray("Favorites");
}

View File

@ -1,23 +1,23 @@
#ifndef FAVORITE_H
#define FAVORITE_H
#include <string>
#include "common/String.h"
#include <vector>
#include "common/Singleton.h"
class Favorite : public Singleton<Favorite>
{
std::vector<std::string> favoritesList;
std::vector<ByteString> favoritesList;
public:
Favorite();
std::vector<std::string> GetFavoritesList();
bool IsFavorite(std::string identifier);
std::vector<ByteString> GetFavoritesList();
bool IsFavorite(ByteString identifier);
bool AnyFavorites();
void AddFavorite(std::string identifier);
void RemoveFavorite(std::string identifier);
void AddFavorite(ByteString identifier);
void RemoveFavorite(ByteString identifier);
void SaveFavoritesToPrefs();
void LoadFavoritesFromPrefs();

View File

@ -57,7 +57,7 @@ public:
}
catch(GameModelException & ex)
{
new ErrorMessage("Cannot open save", ex.what());
new ErrorMessage("Cannot open save", ByteString(ex.what()).FromUtf8());
}
}
}
@ -79,7 +79,7 @@ public:
}
catch(GameModelException & ex)
{
new ErrorMessage("Cannot open save", ex.what());
new ErrorMessage("Cannot open save", ByteString(ex.what()).FromUtf8());
}
}
}
@ -322,7 +322,7 @@ int GameController::GetSignAt(int x, int y)
}
// assumed to already be a valid sign
std::string GameController::GetSignText(int signID)
String GameController::GetSignText(int signID)
{
return gameModel->GetSimulation()->signs[signID].text;
}
@ -573,7 +573,7 @@ void GameController::ToolClick(int toolSelection, ui::Point point)
activeTool->Click(sim, cBrush, point);
}
std::string GameController::StampRegion(ui::Point point1, ui::Point point2, bool includePressure)
ByteString GameController::StampRegion(ui::Point point1, ui::Point point2, bool includePressure)
{
bool incPressure = Client::Ref().GetPrefBool("Simulation.IncludePressure", true);
if (!incPressure)
@ -583,7 +583,7 @@ std::string GameController::StampRegion(ui::Point point1, ui::Point point2, bool
if(newSave)
{
newSave->paused = gameModel->GetPaused();
std::string stampName = Client::Ref().AddStamp(newSave);
ByteString stampName = Client::Ref().AddStamp(newSave);
delete newSave;
if (stampName.length() == 0)
new ErrorMessage("Could not create stamp", "Error serializing save file");
@ -666,20 +666,20 @@ bool GameController::MouseUp(int x, int y, unsigned button, char type)
if (foundSignID != -1)
{
sign foundSign = gameModel->GetSimulation()->signs[foundSignID];
std::string str = foundSign.text;
char type;
String str = foundSign.text;
String::value_type type;
int pos = sign::splitsign(str, &type);
if (pos)
{
ret = false;
if (type == 'c' || type == 't' || type == 's')
{
std::string link = str.substr(3, pos-3);
String link = str.Substr(3, pos-3);
switch (type)
{
case 'c':
{
int saveID = format::StringToNumber<int>(link);
int saveID = link.ToNumber<int>(true);
if (saveID)
OpenSavePreview(saveID, 0, false);
break;
@ -687,9 +687,7 @@ bool GameController::MouseUp(int x, int y, unsigned button, char type)
case 't':
{
// buff is already confirmed to be a number by sign::splitsign
std::stringstream uri;
uri << "http://powdertoy.co.uk/Discussions/Thread/View.html?Thread=" << link;
Platform::OpenURI(uri.str());
Platform::OpenURI(ByteString::Build("http://powdertoy.co.uk/Discussions/Thread/View.html?Thread=", link.ToUtf8()));
break;
}
case 's':
@ -983,7 +981,7 @@ void GameController::Update()
{
int rightSelected = PT_DUST;
Tool * activeTool = gameModel->GetActiveTool(1);
if (activeTool->GetIdentifier().find("DEFAULT_PT_") != activeTool->GetIdentifier().npos)
if (activeTool->GetIdentifier().BeginsWith("DEFAULT_PT_"))
{
int sr = activeTool->GetToolID();
if (sr && sim->IsValidElement(sr))
@ -1175,7 +1173,7 @@ void GameController::SetActiveTool(int toolSelection, Tool * tool)
((PropertyTool *)tool)->OpenWindow(gameModel->GetSimulation());
}
void GameController::SetActiveTool(int toolSelection, std::string identifier)
void GameController::SetActiveTool(int toolSelection, ByteString identifier)
{
Tool *tool = gameModel->GetToolFromIdentifier(identifier);
if (!tool)
@ -1198,7 +1196,7 @@ void GameController::SetReplaceModeFlags(int flags)
gameModel->GetSimulation()->replaceModeFlags = flags;
}
void GameController::OpenSearch(std::string searchText)
void GameController::OpenSearch(String searchText)
{
if(!search)
search = new SearchController(new SearchCallback(this));
@ -1524,7 +1522,7 @@ void GameController::Vote(int direction)
}
catch(GameModelException & ex)
{
new ErrorMessage("Error while voting", ex.what());
new ErrorMessage("Error while voting", ByteString(ex.what()).FromUtf8());
}
}
}
@ -1555,14 +1553,14 @@ void GameController::ReloadSim()
}
}
std::string GameController::ElementResolve(int type, int ctype)
ByteString GameController::ElementResolve(int type, int ctype)
{
if(gameModel && gameModel->GetSimulation())
{
if (type == PT_LIFE && ctype >= 0 && ctype < NGOL)
return gameModel->GetSimulation()->gmenu[ctype].name;
else if (type >= 0 && type < PT_NUM)
return std::string(gameModel->GetSimulation()->elements[type].Name);
return gameModel->GetSimulation()->elements[type].Name;
}
return "";
}
@ -1577,10 +1575,10 @@ bool GameController::IsValidElement(int type)
return false;
}
std::string GameController::WallName(int type)
String GameController::WallName(int type)
{
if(gameModel && gameModel->GetSimulation() && type >= 0 && type < UI_WALLCOUNT)
return std::string(gameModel->GetSimulation()->wtypes[type].name);
return gameModel->GetSimulation()->wtypes[type].name;
else
return "";
}
@ -1596,13 +1594,13 @@ void GameController::NotifyAuthUserChanged(Client * sender)
gameModel->SetUser(newUser);
}
void GameController::NotifyNewNotification(Client * sender, std::pair<std::string, std::string> notification)
void GameController::NotifyNewNotification(Client * sender, std::pair<String, ByteString> notification)
{
class LinkNotification : public Notification
{
std::string link;
ByteString link;
public:
LinkNotification(std::string link_, std::string message) : Notification(message), link(link_) {}
LinkNotification(ByteString link_, String message) : Notification(message), link(link_) {}
virtual ~LinkNotification() {}
virtual void Action()
@ -1632,13 +1630,13 @@ void GameController::NotifyUpdateAvailable(Client * sender)
{
GameController * c;
public:
UpdateNotification(GameController * c, std::string message) : Notification(message), c(c) {}
UpdateNotification(GameController * c, String message) : Notification(message), c(c) {}
virtual ~UpdateNotification() {}
virtual void Action()
{
UpdateInfo info = Client::Ref().GetUpdateInfo();
std::stringstream updateMessage;
StringBuilder updateMessage;
updateMessage << "Are you sure you want to run the updater? Please save any changes before updating.\n\nCurrent version:\n ";
#ifdef SNAPSHOT
@ -1666,7 +1664,7 @@ void GameController::NotifyUpdateAvailable(Client * sender)
if (info.Changelog.length())
updateMessage << "\n\nChangelog:\n" << info.Changelog;
new ConfirmPrompt("Run Updater", updateMessage.str(), new UpdateConfirmation(c));
new ConfirmPrompt("Run Updater", updateMessage.Build(), new UpdateConfirmation(c));
}
};
@ -1674,16 +1672,16 @@ void GameController::NotifyUpdateAvailable(Client * sender)
{
case UpdateInfo::Snapshot:
#if MOD_ID > 0
gameModel->AddNotification(new UpdateNotification(this, std::string("A new mod update is available - click here to update")));
gameModel->AddNotification(new UpdateNotification(this, "A new mod update is available - click here to update"));
#else
gameModel->AddNotification(new UpdateNotification(this, std::string("A new snapshot is available - click here to update")));
gameModel->AddNotification(new UpdateNotification(this, "A new snapshot is available - click here to update"));
#endif
break;
case UpdateInfo::Stable:
gameModel->AddNotification(new UpdateNotification(this, std::string("A new version is available - click here to update")));
gameModel->AddNotification(new UpdateNotification(this, "A new version is available - click here to update"));
break;
case UpdateInfo::Beta:
gameModel->AddNotification(new UpdateNotification(this, std::string("A new beta is available - click here to update")));
gameModel->AddNotification(new UpdateNotification(this, "A new beta is available - click here to update"));
break;
}
}

View File

@ -58,7 +58,7 @@ public:
~GameController();
GameView * GetView();
int GetSignAt(int x, int y);
std::string GetSignText(int signID);
String GetSignText(int signID);
bool MouseMove(int x, int y, int dx, int dy);
bool MouseDown(int x, int y, unsigned button);
@ -89,7 +89,7 @@ public:
void DrawRect(int toolSelection, ui::Point point1, ui::Point point2);
void DrawLine(int toolSelection, ui::Point point1, ui::Point point2);
void DrawFill(int toolSelection, ui::Point point);
std::string StampRegion(ui::Point point1, ui::Point point2, bool includePressure);
ByteString StampRegion(ui::Point point1, ui::Point point2, bool includePressure);
void CopyRegion(ui::Point point1, ui::Point point2, bool includePressure);
void CutRegion(ui::Point point1, ui::Point point2, bool includePressure);
void Update();
@ -109,7 +109,7 @@ public:
void RebuildFavoritesMenu();
Tool * GetActiveTool(int selection);
void SetActiveTool(int toolSelection, Tool * tool);
void SetActiveTool(int toolSelection, std::string identifier);
void SetActiveTool(int toolSelection, ByteString identifier);
void SetLastTool(Tool * tool);
int GetReplaceModeFlags();
void SetReplaceModeFlags(int flags);
@ -119,7 +119,7 @@ public:
void SetToolStrength(float value);
void LoadSaveFile(SaveFile * file);
void LoadSave(SaveInfo * save);
void OpenSearch(std::string searchText);
void OpenSearch(String searchText);
void OpenLogin();
void OpenProfile();
void OpenTags();
@ -147,9 +147,9 @@ public:
bool MouseInZoom(ui::Point position);
ui::Point PointTranslate(ui::Point point);
ui::Point NormaliseBlockCoord(ui::Point point);
std::string ElementResolve(int type, int ctype);
ByteString ElementResolve(int type, int ctype);
bool IsValidElement(int type);
std::string WallName(int type);
String WallName(int type);
int Record(bool record);
void ResetAir();
@ -167,7 +167,7 @@ public:
virtual void NotifyUpdateAvailable(Client * sender);
virtual void NotifyAuthUserChanged(Client * sender);
virtual void NotifyNewNotification(Client * sender, std::pair<std::string, std::string> notification);
virtual void NotifyNewNotification(Client * sender, std::pair<String, ByteString> notification);
void RunUpdater();
};

View File

@ -105,7 +105,7 @@ GameModel::GameModel():
brushList.push_back(new TriangleBrush(ui::Point(4, 4)));
//Load more from brushes folder
std::vector<string> brushFiles = Client::Ref().DirectorySearch(BRUSH_DIR, "", ".ptb");
std::vector<ByteString> brushFiles = Client::Ref().DirectorySearch(BRUSH_DIR, "", ".ptb");
for (size_t i = 0; i < brushFiles.size(); i++)
{
std::vector<unsigned char> brushData = Client::Ref().ReadFile(brushFiles[i]);
@ -234,7 +234,7 @@ void GameModel::BuildMenus()
if(activeMenu != -1)
lastMenu = activeMenu;
std::string activeToolIdentifiers[4];
ByteString activeToolIdentifiers[4];
if(regularToolset[0])
activeToolIdentifiers[0] = regularToolset[0]->GetIdentifier();
if(regularToolset[1])
@ -264,7 +264,7 @@ void GameModel::BuildMenus()
//Create menus
for (int i = 0; i < SC_TOTAL; i++)
{
menuList.push_back(new Menu((const char)sim->msections[i].icon[0], sim->msections[i].name, sim->msections[i].doshow));
menuList.push_back(new Menu(sim->msections[i].icon, sim->msections[i].name, sim->msections[i].doshow));
}
//Build menus from Simulation elements
@ -305,14 +305,14 @@ void GameModel::BuildMenus()
//Build menu for GOL types
for(int i = 0; i < NGOL; i++)
{
Tool * tempTool = new ElementTool(PT_LIFE|PMAPID(i), sim->gmenu[i].name, std::string(sim->gmenu[i].description), PIXR(sim->gmenu[i].colour), PIXG(sim->gmenu[i].colour), PIXB(sim->gmenu[i].colour), "DEFAULT_PT_LIFE_"+std::string(sim->gmenu[i].name));
Tool * tempTool = new ElementTool(PT_LIFE|PMAPID(i), sim->gmenu[i].name, sim->gmenu[i].description, PIXR(sim->gmenu[i].colour), PIXG(sim->gmenu[i].colour), PIXB(sim->gmenu[i].colour), "DEFAULT_PT_LIFE_"+sim->gmenu[i].name);
menuList[SC_LIFE]->AddTool(tempTool);
}
//Build other menus from wall data
for(int i = 0; i < UI_WALLCOUNT; i++)
{
Tool * tempTool = new WallTool(i, "", std::string(sim->wtypes[i].descs), PIXR(sim->wtypes[i].colour), PIXG(sim->wtypes[i].colour), PIXB(sim->wtypes[i].colour), sim->wtypes[i].identifier, sim->wtypes[i].textureGen);
Tool * tempTool = new WallTool(i, "", sim->wtypes[i].descs, PIXR(sim->wtypes[i].colour), PIXG(sim->wtypes[i].colour), PIXB(sim->wtypes[i].colour), sim->wtypes[i].identifier, sim->wtypes[i].textureGen);
menuList[SC_WALL]->AddTool(tempTool);
//sim->wtypes[i]
}
@ -386,7 +386,7 @@ void GameModel::BuildFavoritesMenu()
{
menuList[SC_FAVORITES]->ClearTools();
std::vector<std::string> favList = Favorite::Ref().GetFavoritesList();
std::vector<ByteString> favList = Favorite::Ref().GetFavoritesList();
for (size_t i = 0; i < favList.size(); i++)
{
Tool *tool = GetToolFromIdentifier(favList[i]);
@ -403,7 +403,7 @@ void GameModel::BuildFavoritesMenu()
notifyLastToolChanged();
}
Tool * GameModel::GetToolFromIdentifier(std::string identifier)
Tool * GameModel::GetToolFromIdentifier(ByteString identifier)
{
for (std::vector<Menu*>::iterator iter = menuList.begin(), end = menuList.end(); iter != end; ++iter)
{
@ -657,8 +657,8 @@ void GameModel::SetSave(SaveInfo * newSave)
saveData->authors["type"] = "save";
saveData->authors["id"] = newSave->id;
saveData->authors["username"] = newSave->userName;
saveData->authors["title"] = newSave->name;
saveData->authors["description"] = newSave->Description;
saveData->authors["title"] = newSave->name.ToUtf8();
saveData->authors["description"] = newSave->Description.ToUtf8();
saveData->authors["published"] = (int)newSave->Published;
saveData->authors["date"] = newSave->updatedDate;
}
@ -912,12 +912,11 @@ void GameModel::SetPaused(bool pauseState)
{
if (!pauseState && sim->debug_currentParticle > 0)
{
std::stringstream logmessage;
logmessage << "Updated particles from #" << sim->debug_currentParticle << " to end due to unpause";
String logmessage = String::Build("Updated particles from #", sim->debug_currentParticle, " to end due to unpause");
sim->UpdateParticles(sim->debug_currentParticle, NPART);
sim->AfterSim();
sim->debug_currentParticle = 0;
Log(logmessage.str(), false);
Log(logmessage, false);
}
sim->sys_pause = pauseState?1:0;
@ -1048,17 +1047,17 @@ GameSave * GameModel::GetPlaceSave()
return placeSave;
}
void GameModel::Log(string message, bool printToFile)
void GameModel::Log(String message, bool printToFile)
{
consoleLog.push_front(message);
if(consoleLog.size()>100)
consoleLog.pop_back();
notifyLogChanged(message);
if (printToFile)
std::cout << message << std::endl;
std::cout << message.ToUtf8() << std::endl;
}
deque<string> GameModel::GetLog()
deque<String> GameModel::GetLog()
{
return consoleLog;
}
@ -1088,24 +1087,24 @@ void GameModel::RemoveNotification(Notification * notification)
notifyNotificationsChanged();
}
void GameModel::SetToolTip(std::string text)
void GameModel::SetToolTip(String text)
{
toolTip = text;
notifyToolTipChanged();
}
void GameModel::SetInfoTip(std::string text)
void GameModel::SetInfoTip(String text)
{
infoTip = text;
notifyInfoTipChanged();
}
std::string GameModel::GetToolTip()
String GameModel::GetToolTip()
{
return toolTip;
}
std::string GameModel::GetInfoTip()
String GameModel::GetInfoTip()
{
return infoTip;
}
@ -1246,7 +1245,7 @@ void GameModel::notifyPlaceSaveChanged()
}
}
void GameModel::notifyLogChanged(string entry)
void GameModel::notifyLogChanged(String entry)
{
for (size_t i = 0; i < observers.size(); i++)
{

View File

@ -41,7 +41,7 @@ private:
//unsigned char * clipboardData;
GameSave * clipboard;
GameSave * placeSave;
deque<string> consoleLog;
deque<String> consoleLog;
vector<GameView*> observers;
vector<Tool*> toolList;
@ -77,8 +77,8 @@ private:
int edgeMode;
std::string infoTip;
std::string toolTip;
String infoTip;
String toolTip;
//bool zoomEnabled;
void notifyRendererChanged();
void notifySimulationChanged();
@ -98,7 +98,7 @@ private:
void notifyColourPresetsChanged();
void notifyColourActivePresetChanged();
void notifyNotificationsChanged();
void notifyLogChanged(string entry);
void notifyLogChanged(String entry);
void notifyInfoTipChanged();
void notifyToolTipChanged();
void notifyQuickOptionsChanged();
@ -123,10 +123,10 @@ public:
void SetColourSelectorColour(ui::Colour colour);
ui::Colour GetColourSelectorColour();
void SetToolTip(std::string text);
void SetInfoTip(std::string text);
std::string GetToolTip();
std::string GetInfoTip();
void SetToolTip(String text);
void SetInfoTip(String text);
String GetToolTip();
String GetInfoTip();
void BuildMenus();
void BuildFavoritesMenu();
@ -149,7 +149,7 @@ public:
float GetToolStrength();
Tool * GetLastTool();
void SetLastTool(Tool * newTool);
Tool * GetToolFromIdentifier(std::string identifier);
Tool * GetToolFromIdentifier(ByteString identifier);
Tool * GetElementTool(int elementID);
vector<Tool*> GetToolList();
vector<Tool*> GetUnlistedTools();
@ -200,8 +200,8 @@ public:
ui::Point GetZoomWindowPosition();
void SetClipboard(GameSave * save);
void SetPlaceSave(GameSave * save);
void Log(string message, bool printToFile);
deque<string> GetLog();
void Log(String message, bool printToFile);
deque<String> GetLog();
GameSave * GetClipboard();
GameSave * GetPlaceSave();

View File

@ -1,17 +1,16 @@
#ifndef GAMEMODELEXCEPTION_H_
#define GAMEMODELEXCEPTION_H_
#include <string>
#include "common/String.h"
#include <exception>
using namespace std;
struct GameModelException: public exception {
string message;
String message;
public:
GameModelException(string message_): message(message_) {}
GameModelException(String message_): message(message_) {}
const char * what() const throw()
{
return message.c_str();
return message.ToUtf8().c_str();
}
~GameModelException() throw() {};
};

View File

@ -1,4 +1,3 @@
#include <sstream>
#include <iomanip>
#include <algorithm>
#include "GameView.h"
@ -40,10 +39,10 @@ private:
bool leftDown;
bool showSplit;
int splitPosition;
std::string toolTip2;
String toolTip2;
SplitButtonAction * splitActionCallback;
public:
SplitButton(ui::Point position, ui::Point size, std::string buttonText, std::string toolTip, std::string toolTip2, int split) :
SplitButton(ui::Point position, ui::Point size, String buttonText, String toolTip, String toolTip2, int split) :
Button(position, size, buttonText, toolTip),
showSplit(true),
splitPosition(split),
@ -52,7 +51,7 @@ public:
{
}
void SetRightToolTip(std::string tooltip) { toolTip2 = tooltip; }
void SetRightToolTip(String tooltip) { toolTip2 = tooltip; }
bool GetShowSplit() { return showSplit; }
void SetShowSplit(bool split) { showSplit = split; }
SplitButtonAction * GetSplitActionCallback() { return splitActionCallback; }
@ -101,12 +100,12 @@ public:
return;
SetToolTip(x, y);
}
virtual void TextPosition(std::string ButtonText)
virtual void TextPosition(String ButtonText)
{
ui::Button::TextPosition(ButtonText);
textPosition.X += 3;
}
void SetToolTips(std::string newToolTip1, std::string newToolTip2)
void SetToolTips(String newToolTip1, String newToolTip2)
{
toolTip = newToolTip1;
toolTip2 = newToolTip2;
@ -183,7 +182,7 @@ GameView::GameView():
buttonTip(""),
isButtonTipFadingIn(false),
introText(2048),
introTextMessage(introTextData),
introTextMessage(ByteString(introTextData).FromAscii()),
doScreenshot(false),
screenshotIndex(0),
@ -434,7 +433,7 @@ GameView::GameView():
v->c->OpenElementSearch();
}
};
ui::Button * tempButton = new ui::Button(ui::Point(WINDOWW-16, WINDOWH-32), ui::Point(15, 15), "\xE5", "Search for elements");
ui::Button * tempButton = new ui::Button(ui::Point(WINDOWW-16, WINDOWH-32), ui::Point(15, 15), 0xE065, "Search for elements");
tempButton->Appearance.Margin = ui::Border(0, 2, 3, 2);
tempButton->SetActionCallback(new ElementSearchAction(this));
AddComponent(tempButton);
@ -556,7 +555,7 @@ public:
else
{
if (v->CtrlBehaviour() && v->AltBehaviour() && !v->ShiftBehaviour())
if (tool->GetIdentifier().find("DEFAULT_PT_") != tool->GetIdentifier().npos)
if (tool->GetIdentifier().BeginsWith("DEFAULT_PT_"))
sender->SetSelectionState(3);
if (sender->GetSelectionState() >= 0 && sender->GetSelectionState() <= 3)
@ -610,9 +609,9 @@ void GameView::NotifyMenuListChanged(GameModel * sender)
{
if (menuList[i]->GetVisible())
{
std::string tempString = "";
String tempString = "";
tempString += menuList[i]->GetIcon();
std::string description = menuList[i]->GetDescription();
String description = menuList[i]->GetDescription();
if (i == SC_FAVORITES && Favorite::Ref().AnyFavorites())
description += " (Use ctrl+shift+click to favorite an element)";
ui::Button * tempButton = new ui::Button(ui::Point(WINDOWW-16, currentY), ui::Point(15, 15), tempString, description);
@ -677,18 +676,15 @@ void GameView::NotifyActiveToolsChanged(GameModel * sender)
if(sender->GetActiveTool(0) == tool)
{
toolButtons[i]->SetSelectionState(0); //Primary
if (tool->GetIdentifier().find("DEFAULT_UI_WIND") != tool->GetIdentifier().npos)
windTool = true;
else
windTool = false;
windTool = tool->GetIdentifier() == "DEFAULT_UI_WIND";
if (sender->GetActiveTool(0)->GetIdentifier().find("DEFAULT_DECOR_") != sender->GetActiveTool(0)->GetIdentifier().npos)
if (sender->GetActiveTool(0)->GetIdentifier().BeginsWith("DEFAULT_DECOR_"))
decoBrush = true;
}
else if(sender->GetActiveTool(1) == tool)
{
toolButtons[i]->SetSelectionState(1); //Secondary
if (sender->GetActiveTool(1)->GetIdentifier().find("DEFAULT_DECOR_") != sender->GetActiveTool(1)->GetIdentifier().npos)
if (sender->GetActiveTool(1)->GetIdentifier().BeginsWith("DEFAULT_DECOR_"))
decoBrush = true;
}
else if(sender->GetActiveTool(2) == tool)
@ -709,7 +705,7 @@ void GameView::NotifyActiveToolsChanged(GameModel * sender)
if (sender->GetRenderer()->findingElement)
{
Tool *active = sender->GetActiveTool(0);
if (active->GetIdentifier().find("_PT_") == active->GetIdentifier().npos)
if (active->GetIdentifier().Contains("_PT_"))
ren->findingElement = 0;
else
ren->findingElement = sender->GetActiveTool(0)->GetToolID()%256;
@ -724,10 +720,7 @@ void GameView::NotifyLastToolChanged(GameModel * sender)
if (sender->GetLastTool())
{
wallBrush = sender->GetLastTool()->GetBlocky();
if (sender->GetLastTool()->GetIdentifier().find("DEFAULT_TOOL_") != sender->GetLastTool()->GetIdentifier().npos)
toolBrush = true;
else
toolBrush = false;
toolBrush = sender->GetLastTool()->GetIdentifier().BeginsWith("DEFAULT_TOOL_");
}
}
@ -912,7 +905,7 @@ void GameView::NotifyUserChanged(GameModel * sender)
}
else
{
loginButton->SetText(sender->GetUser().Username);
loginButton->SetText(sender->GetUser().Username.FromUtf8());
((SplitButton*)loginButton)->SetShowSplit(true);
((SplitButton*)loginButton)->SetRightToolTip("Edit profile");
}
@ -978,17 +971,17 @@ void GameView::NotifySaveChanged(GameModel * sender)
tagSimulationButton->Enabled = sender->GetSave()->GetID();
if (sender->GetSave()->GetID())
{
std::stringstream tagsStream;
std::list<string> tags = sender->GetSave()->GetTags();
StringBuilder tagsStream;
std::list<ByteString> tags = sender->GetSave()->GetTags();
if (tags.size())
{
for (std::list<std::string>::const_iterator iter = tags.begin(), begin = tags.begin(), end = tags.end(); iter != end; iter++)
for (std::list<ByteString>::const_iterator iter = tags.begin(), begin = tags.begin(), end = tags.end(); iter != end; iter++)
{
if (iter != begin)
tagsStream << " ";
tagsStream << *iter;
tagsStream << iter->FromUtf8();
}
tagSimulationButton->SetText(tagsStream.str());
tagSimulationButton->SetText(tagsStream.Build());
}
else
{
@ -1067,10 +1060,8 @@ int GameView::Record(bool record)
{
time_t startTime = time(NULL);
recordingFolder = startTime;
std::stringstream recordingDir;
recordingDir << "recordings" << PATH_SEP << recordingFolder;
Client::Ref().MakeDirectory("recordings");
Client::Ref().MakeDirectory(recordingDir.str().c_str());
Client::Ref().MakeDirectory(ByteString::Build("recordings", PATH_SEP, recordingFolder).c_str());
recording = true;
recordingIndex = 0;
}
@ -1327,7 +1318,7 @@ void GameView::OnMouseUp(int x, int y, unsigned button)
UpdateDrawMode();
}
void GameView::ToolTip(ui::Point senderPosition, std::string toolTip)
void GameView::ToolTip(ui::Point senderPosition, String toolTip)
{
// buttom button tooltips
if (senderPosition.Y > Size.Y-17)
@ -1342,16 +1333,16 @@ void GameView::ToolTip(ui::Point senderPosition, std::string toolTip)
else if(senderPosition.X > Size.X-BARSIZE)// < Size.Y-(quickOptionButtons.size()+1)*16)
{
this->toolTip = toolTip;
toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth((char*)toolTip.c_str()), senderPosition.Y+3);
toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth(toolTip), senderPosition.Y+3);
if(toolTipPosition.Y+10 > Size.Y-MENUSIZE)
toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth((char*)toolTip.c_str()), Size.Y-MENUSIZE-10);
toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth(toolTip), Size.Y-MENUSIZE-10);
isToolTipFadingIn = true;
}
// element tooltips
else
{
this->toolTip = toolTip;
toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth((char*)toolTip.c_str()), Size.Y-MENUSIZE-10);
toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth(toolTip), Size.Y-MENUSIZE-10);
isToolTipFadingIn = true;
}
}
@ -1490,8 +1481,8 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
if ((Client::Ref().GetAuthUser().UserElevation == User::ElevationModerator
|| Client::Ref().GetAuthUser().UserElevation == User::ElevationAdmin) && ctrl)
{
std::string authorString = Client::Ref().GetAuthorInfo().toStyledString();
new InformationMessage("Save authorship info", authorString, true);
ByteString authorString = Client::Ref().GetAuthorInfo().toStyledString();
new InformationMessage("Save authorship info", authorString.FromUtf8(), true);
}
break;
case 'r':
@ -1505,7 +1496,7 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
if (ctrl)
{
Tool *active = c->GetActiveTool(0);
if (active->GetIdentifier().find("_PT_") == active->GetIdentifier().npos || ren->findingElement == active->GetToolID()%256)
if (!active->GetIdentifier().Contains("_PT_") || ren->findingElement == active->GetToolID()%256)
ren->findingElement = 0;
else
ren->findingElement = active->GetToolID()%256;
@ -1609,7 +1600,7 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
break;
case 'l':
{
std::vector<std::string> stampList = Client::Ref().GetStamps(0, 1);
std::vector<ByteString> stampList = Client::Ref().GetStamps(0, 1);
if (stampList.size())
{
SaveFile *saveFile = Client::Ref().GetStamp(stampList[0]);
@ -1735,13 +1726,13 @@ void GameView::OnTick(float dt)
int foundSignID = c->GetSignAt(mousePosition.X, mousePosition.Y);
if (foundSignID != -1)
{
std::string str = c->GetSignText(foundSignID);
char type = '\0';
String str = c->GetSignText(foundSignID);
String::value_type type = '\0';
int pos = sign::splitsign(str, &type);
if (type == 'c' || type == 't' || type == 's')
{
std::string linkSign = str.substr(3, pos-3);
std::stringstream tooltip;
String linkSign = str.Substr(3, pos-3);
StringBuilder tooltip;
switch (type)
{
case 'c':
@ -1754,7 +1745,7 @@ void GameView::OnTick(float dt)
tooltip << "Search for " << linkSign;
break;
}
ToolTip(ui::Point(0, Size.Y), tooltip.str());
ToolTip(ui::Point(0, Size.Y), tooltip.Build());
}
}
@ -1903,7 +1894,7 @@ void GameView::NotifyNotificationsChanged(GameModel * sender)
int currentY = YRES-23;
for(std::vector<Notification*>::iterator iter = notifications.begin(), end = notifications.end(); iter != end; ++iter)
{
int width = (Graphics::textwidth((*iter)->Message.c_str()))+8;
int width = (Graphics::textwidth((*iter)->Message))+8;
ui::Button * tempButton = new ui::Button(ui::Point(XRES-width-22, currentY), ui::Point(width, 15), (*iter)->Message);
tempButton->SetActionCallback(new NotificationButtonAction(*iter));
tempButton->Appearance.BorderInactive = style::Colour::WarningTitle;
@ -1913,7 +1904,7 @@ void GameView::NotifyNotificationsChanged(GameModel * sender)
AddComponent(tempButton);
notificationComponents.push_back(tempButton);
tempButton = new ui::Button(ui::Point(XRES-20, currentY), ui::Point(15, 15), "\xAA");
tempButton = new ui::Button(ui::Point(XRES-20, currentY), ui::Point(15, 15), 0xE02A);
//tempButton->SetIcon(IconClose);
tempButton->SetActionCallback(new CloseNotificationButtonAction(this, *iter));
tempButton->Appearance.Margin.Left -= 1;
@ -1934,9 +1925,9 @@ void GameView::NotifyZoomChanged(GameModel * sender)
zoomEnabled = sender->GetZoomEnabled();
}
void GameView::NotifyLogChanged(GameModel * sender, string entry)
void GameView::NotifyLogChanged(GameModel * sender, String entry)
{
logEntries.push_front(std::pair<std::string, int>(entry, 600));
logEntries.push_front(std::pair<String, int>(entry, 600));
if (logEntries.size() > 20)
logEntries.pop_back();
}
@ -2218,12 +2209,9 @@ void GameView::OnDraw()
VideoBuffer screenshot(ren->DumpFrame());
std::vector<char> data = format::VideoBufferToPNG(screenshot);
std::stringstream filename;
filename << "screenshot_";
filename << std::setfill('0') << std::setw(6) << (screenshotIndex++);
filename << ".png";
ByteString filename = ByteString::Build("screenshot_", Format::Width(screenshotIndex++, 6), ".png");
Client::Ref().WriteFile(data, filename.str());
Client::Ref().WriteFile(data, filename);
doScreenshot = false;
}
@ -2232,23 +2220,19 @@ void GameView::OnDraw()
VideoBuffer screenshot(ren->DumpFrame());
std::vector<char> data = format::VideoBufferToPPM(screenshot);
std::stringstream filename;
filename << "recordings" << PATH_SEP << recordingFolder << PATH_SEP;
filename << "frame_";
filename << std::setfill('0') << std::setw(6) << (recordingIndex++);
filename << ".ppm";
ByteString filename = ByteString::Build("recordings", PATH_SEP, recordingFolder, PATH_SEP, "frame_", Format::Width(screenshotIndex++, 6), ".ppm");
Client::Ref().WriteFile(data, filename.str());
Client::Ref().WriteFile(data, filename);
}
if (logEntries.size())
{
int startX = 20;
int startY = YRES-20;
deque<std::pair<std::string, int> >::iterator iter;
deque<std::pair<String, int> >::iterator iter;
for(iter = logEntries.begin(); iter != logEntries.end(); iter++)
{
string message = (*iter).first;
String message = (*iter).first;
int alpha = std::min((*iter).second, 255);
if (alpha <= 0) //erase this and everything older
{
@ -2256,8 +2240,8 @@ void GameView::OnDraw()
break;
}
startY -= 14;
g->fillrect(startX-3, startY-3, Graphics::textwidth((char*)message.c_str())+6, 14, 0, 0, 0, 100);
g->drawtext(startX, startY, message.c_str(), 255, 255, 255, alpha);
g->fillrect(startX-3, startY-3, Graphics::textwidth(message)+6, 14, 0, 0, 0, 100);
g->drawtext(startX, startY, message, 255, 255, 255, alpha);
(*iter).second -= 3;
}
}
@ -2265,13 +2249,11 @@ void GameView::OnDraw()
if(recording)
{
std::stringstream sampleInfo;
sampleInfo << recordingIndex;
sampleInfo << ". \x8E REC";
String sampleInfo = String::Build(recordingIndex, ". ", String(0xE00E), " REC");
int textWidth = Graphics::textwidth((char*)sampleInfo.str().c_str());
int textWidth = Graphics::textwidth(sampleInfo);
g->fillrect(XRES-20-textWidth, 12, textWidth+8, 15, 0, 0, 0, 255*0.5);
g->drawtext(XRES-16-textWidth, 16, (const char*)sampleInfo.str().c_str(), 255, 50, 20, 255);
g->drawtext(XRES-16-textWidth, 16, sampleInfo, 255, 50, 20, 255);
}
else if(showHud)
{
@ -2281,8 +2263,8 @@ void GameView::OnDraw()
alpha = 255-toolTipPresence*3;
if (alpha < 50)
alpha = 50;
std::stringstream sampleInfo;
sampleInfo.precision(2);
StringBuilder sampleInfo;
sampleInfo << Format::Precision(2);
int type = sample.particle.type;
if (type)
@ -2295,15 +2277,15 @@ void GameView::OnDraw()
if (showDebug)
{
if (type == PT_LAVA && c->IsValidElement(ctype))
sampleInfo << "Molten " << c->ElementResolve(ctype, -1);
sampleInfo << "Molten " << c->ElementResolve(ctype, -1).FromAscii();
else if ((type == PT_PIPE || type == PT_PPIP) && c->IsValidElement(ctype))
sampleInfo << c->ElementResolve(type, -1) << " with " << c->ElementResolve(ctype, (int)sample.particle.pavg[1]);
sampleInfo << c->ElementResolve(type, -1).FromAscii() << " with " << c->ElementResolve(ctype, (int)sample.particle.pavg[1]).FromAscii();
else if (type == PT_LIFE)
sampleInfo << c->ElementResolve(type, ctype);
sampleInfo << c->ElementResolve(type, ctype).FromAscii();
else if (type == PT_FILT)
{
sampleInfo << c->ElementResolve(type, ctype);
const char* filtModes[] = {"set colour", "AND", "OR", "subtract colour", "red shift", "blue shift", "no effect", "XOR", "NOT", "old QRTZ scattering", "variable red shift", "variable blue shift"};
sampleInfo << c->ElementResolve(type, ctype).FromAscii();
String filtModes[] = {"set colour", "AND", "OR", "subtract colour", "red shift", "blue shift", "no effect", "XOR", "NOT", "old QRTZ scattering", "variable red shift", "variable blue shift"};
if (sample.particle.tmp>=0 && sample.particle.tmp<=11)
sampleInfo << " (" << filtModes[sample.particle.tmp] << ")";
else
@ -2311,18 +2293,18 @@ void GameView::OnDraw()
}
else
{
sampleInfo << c->ElementResolve(type, ctype);
sampleInfo << c->ElementResolve(type, ctype).FromAscii();
if (wavelengthGfx)
sampleInfo << " (" << ctype << ")";
// Some elements store extra LIFE info in upper bits of ctype, instead of tmp/tmp2
else if (type == PT_CRAY || type == PT_DRAY || type == PT_CONV)
sampleInfo << " (" << c->ElementResolve(TYP(ctype), ID(ctype)) << ")";
sampleInfo << " (" << c->ElementResolve(TYP(ctype), ID(ctype)).FromAscii() << ")";
else if (c->IsValidElement(ctype))
sampleInfo << " (" << c->ElementResolve(ctype, -1) << ")";
sampleInfo << " (" << c->ElementResolve(ctype, -1).FromAscii() << ")";
else
sampleInfo << " ()";
}
sampleInfo << ", Temp: " << std::fixed << sample.particle.temp -273.15f << " C";
sampleInfo << ", Temp: " << (sample.particle.temp - 273.15f) << " C";
sampleInfo << ", Life: " << sample.particle.life;
if (sample.particle.type != PT_RFRG && sample.particle.type != PT_RFGL)
sampleInfo << ", Tmp: " << sample.particle.tmp;
@ -2331,39 +2313,39 @@ void GameView::OnDraw()
if (type == PT_CRAY || type == PT_DRAY || type == PT_EXOT || type == PT_LIGH || type == PT_SOAP || type == PT_TRON || type == PT_VIBR || type == PT_VIRS || type == PT_WARP || type == PT_LCRY || type == PT_CBNW || type == PT_TSNS || type == PT_DTEC || type == PT_LSNS || type == PT_PSTN)
sampleInfo << ", Tmp2: " << sample.particle.tmp2;
sampleInfo << ", Pressure: " << std::fixed << sample.AirPressure;
sampleInfo << ", Pressure: " << sample.AirPressure;
}
else
{
if (type == PT_LAVA && c->IsValidElement(ctype))
sampleInfo << "Molten " << c->ElementResolve(ctype, -1);
sampleInfo << "Molten " << c->ElementResolve(ctype, -1).FromAscii();
else if ((type == PT_PIPE || type == PT_PPIP) && c->IsValidElement(ctype))
sampleInfo << c->ElementResolve(type, -1) << " with " << c->ElementResolve(ctype, (int)sample.particle.pavg[1]);
sampleInfo << c->ElementResolve(type, -1).FromAscii() << " with " << c->ElementResolve(ctype, (int)sample.particle.pavg[1]).FromAscii();
else if (type == PT_LIFE)
sampleInfo << c->ElementResolve(type, ctype);
sampleInfo << c->ElementResolve(type, ctype).FromAscii();
else
sampleInfo << c->ElementResolve(type, ctype);
sampleInfo << ", Temp: " << std::fixed << sample.particle.temp - 273.15f << " C";
sampleInfo << ", Pressure: " << std::fixed << sample.AirPressure;
sampleInfo << c->ElementResolve(type, ctype).FromAscii();
sampleInfo << ", Temp: " << sample.particle.temp - 273.15f << " C";
sampleInfo << ", Pressure: " << sample.AirPressure;
}
}
else if (sample.WallType)
{
sampleInfo << c->WallName(sample.WallType);
sampleInfo << ", Pressure: " << std::fixed << sample.AirPressure;
sampleInfo << ", Pressure: " << sample.AirPressure;
}
else if (sample.isMouseInSim)
{
sampleInfo << "Empty, Pressure: " << std::fixed << sample.AirPressure;
sampleInfo << "Empty, Pressure: " << sample.AirPressure;
}
else
{
sampleInfo << "Empty";
}
int textWidth = Graphics::textwidth((char*)sampleInfo.str().c_str());
int textWidth = Graphics::textwidth(sampleInfo.Build());
g->fillrect(XRES-20-textWidth, 12, textWidth+8, 15, 0, 0, 0, alpha*0.5f);
g->drawtext(XRES-16-textWidth, 16, (const char*)sampleInfo.str().c_str(), 255, 255, 255, alpha*0.75f);
g->drawtext(XRES-16-textWidth, 16, sampleInfo.Build(), 255, 255, 255, alpha*0.75f);
#ifndef OGLI
if (wavelengthGfx)
@ -2404,7 +2386,8 @@ void GameView::OnDraw()
if (showDebug)
{
sampleInfo.str(std::string());
StringBuilder sampleInfo;
sampleInfo << Format::Precision(2);
if (type)
sampleInfo << "#" << sample.ParticleID << ", ";
@ -2415,22 +2398,21 @@ void GameView::OnDraw()
sampleInfo << ", GX: " << sample.GravityVelocityX << " GY: " << sample.GravityVelocityY;
if (c->GetAHeatEnable())
sampleInfo << ", AHeat: " << std::fixed << sample.AirTemperature -273.15f << " C";
sampleInfo << ", AHeat: " << sample.AirTemperature - 273.15f << " C";
textWidth = Graphics::textwidth((char*)sampleInfo.str().c_str());
textWidth = Graphics::textwidth(sampleInfo.Build());
g->fillrect(XRES-20-textWidth, 27, textWidth+8, 14, 0, 0, 0, alpha*0.5f);
g->drawtext(XRES-16-textWidth, 30, (const char*)sampleInfo.str().c_str(), 255, 255, 255, alpha*0.75f);
g->drawtext(XRES-16-textWidth, 30, sampleInfo.Build(), 255, 255, 255, alpha*0.75f);
}
}
if(showHud && introText < 51)
{
//FPS and some version info
std::stringstream fpsInfo;
fpsInfo.precision(2);
fpsInfo << "FPS: " << std::fixed << ui::Engine::Ref().GetFps();
StringBuilder fpsInfo;
fpsInfo << Format::Precision(2) << "FPS: " << ui::Engine::Ref().GetFps();
#ifdef DEBUG
fpsInfo << " Delta: " << std::fixed << ui::Engine::Ref().GetDelta();
fpsInfo << " Delta: " << ui::Engine::Ref().GetDelta();
#endif
if (showDebug)
@ -2449,37 +2431,37 @@ void GameView::OnDraw()
if (ren && ren->findingElement)
fpsInfo << " [FIND]";
int textWidth = Graphics::textwidth((char*)fpsInfo.str().c_str());
int textWidth = Graphics::textwidth(fpsInfo.Build());
int alpha = 255-introText*5;
g->fillrect(12, 12, textWidth+8, 15, 0, 0, 0, alpha*0.5);
g->drawtext(16, 16, (const char*)fpsInfo.str().c_str(), 32, 216, 255, alpha*0.75);
g->drawtext(16, 16, fpsInfo.Build(), 32, 216, 255, alpha*0.75);
}
//Tooltips
if(infoTipPresence)
{
int infoTipAlpha = (infoTipPresence>50?50:infoTipPresence)*5;
g->drawtext_outline((XRES-Graphics::textwidth((char*)infoTip.c_str()))/2, (YRES/2)-2, (char*)infoTip.c_str(), 255, 255, 255, infoTipAlpha);
g->drawtext_outline((XRES-Graphics::textwidth(infoTip))/2, (YRES/2)-2, infoTip, 255, 255, 255, infoTipAlpha);
}
if(toolTipPresence && toolTipPosition.X!=-1 && toolTipPosition.Y!=-1 && toolTip.length())
{
if (toolTipPosition.Y == Size.Y-MENUSIZE-10)
g->drawtext_outline(toolTipPosition.X, toolTipPosition.Y, (char*)toolTip.c_str(), 255, 255, 255, toolTipPresence>51?255:toolTipPresence*5);
g->drawtext_outline(toolTipPosition.X, toolTipPosition.Y, toolTip, 255, 255, 255, toolTipPresence>51?255:toolTipPresence*5);
else
g->drawtext(toolTipPosition.X, toolTipPosition.Y, (char*)toolTip.c_str(), 255, 255, 255, toolTipPresence>51?255:toolTipPresence*5);
g->drawtext(toolTipPosition.X, toolTipPosition.Y, toolTip, 255, 255, 255, toolTipPresence>51?255:toolTipPresence*5);
}
if(buttonTipShow > 0)
{
g->drawtext(16, Size.Y-MENUSIZE-24, (char*)buttonTip.c_str(), 255, 255, 255, buttonTipShow>51?255:buttonTipShow*5);
g->drawtext(16, Size.Y-MENUSIZE-24, buttonTip, 255, 255, 255, buttonTipShow>51?255:buttonTipShow*5);
}
//Introduction text
if(introText)
{
g->fillrect(0, 0, WINDOWW, WINDOWH, 0, 0, 0, introText>51?102:introText*2);
g->drawtext(16, 20, (char*)introTextMessage.c_str(), 255, 255, 255, introText>51?255:introText*5);
g->drawtext(16, 20, introTextMessage, 255, 255, 255, introText>51?255:introText*5);
}
// Clear menu areas, to ensure particle graphics don't overlap

View File

@ -4,7 +4,7 @@
#include <vector>
#include <queue>
#include <deque>
#include <string>
#include "common/String.h"
#include "GameController.h"
#include "GameModel.h"
#include "gui/interface/Window.h"
@ -54,16 +54,16 @@ private:
int lastMenu;
int toolTipPresence;
std::string toolTip;
String toolTip;
bool isToolTipFadingIn;
ui::Point toolTipPosition;
int infoTipPresence;
std::string infoTip;
String infoTip;
int buttonTipShow;
std::string buttonTip;
String buttonTip;
bool isButtonTipFadingIn;
int introText;
std::string introTextMessage;
String introTextMessage;
bool doScreenshot;
int screenshotIndex;
@ -80,7 +80,7 @@ private:
vector<ui::Button*> menuButtons;
vector<ToolButton*> toolButtons;
vector<ui::Component*> notificationComponents;
deque<std::pair<std::string, int> > logEntries;
deque<std::pair<String, int> > logEntries;
ui::Button * scrollBar;
ui::Button * searchButton;
ui::Button * reloadButton;
@ -178,14 +178,14 @@ public:
void NotifyColourActivePresetChanged(GameModel * sender);
void NotifyPlaceSaveChanged(GameModel * sender);
void NotifyNotificationsChanged(GameModel * sender);
void NotifyLogChanged(GameModel * sender, string entry);
void NotifyLogChanged(GameModel * sender, String entry);
void NotifyToolTipChanged(GameModel * sender);
void NotifyInfoTipChanged(GameModel * sender);
void NotifyQuickOptionsChanged(GameModel * sender);
void NotifyLastToolChanged(GameModel * sender);
virtual void ToolTip(ui::Point senderPosition, std::string toolTip);
virtual void ToolTip(ui::Point senderPosition, String toolTip);
virtual void OnMouseMove(int x, int y, int dx, int dy);
virtual void OnMouseDown(int x, int y, unsigned button);

View File

@ -1,19 +1,20 @@
#ifndef MENU_H_
#define MENU_H_
#include "common/String.h"
#include "Tool.h"
class Menu
{
char icon;
string description;
vector<Tool*> tools;
String::value_type icon;
String description;
std::vector<Tool*> tools;
bool visible;
public:
Menu(char icon_, string description_, int visible_):
Menu(String::value_type icon_, String description_, int visible_):
icon(icon_),
description(description_),
tools(vector<Tool*>()),
tools(std::vector<Tool*>()),
visible(visible_ ? true : false)
{
@ -28,17 +29,17 @@ public:
tools.clear();
}
vector<Tool*> GetToolList()
std::vector<Tool*> GetToolList()
{
return tools;
}
char GetIcon()
String::value_type GetIcon()
{
return icon;
}
string GetDescription()
String GetDescription()
{
return description;
}

View File

@ -1,14 +1,14 @@
#ifndef NOTIFICATION_H_
#define NOTIFICATION_H_
#include <string>
#include "common/String.h"
class Notification
{
public:
Notification(std::string message) : Message(message) {}
Notification(String message) : Message(message) {}
virtual ~Notification() {};
std::string Message;
String Message;
virtual void Action() { }
};

View File

@ -1,5 +1,4 @@
#include <iostream>
#include <sstream>
#include "Tool.h"
#include "client/Client.h"
#include "gui/Style.h"
@ -69,7 +68,7 @@ sim(sim_)
PropertyWindow * w;
public:
PropertyChanged(PropertyWindow * w): w(w) { }
virtual void OptionChanged(ui::DropDown * sender, std::pair<std::string, int> option)
virtual void OptionChanged(ui::DropDown * sender, std::pair<String, int> option)
{
w->FocusComponent(w->textField);
}
@ -79,7 +78,7 @@ sim(sim_)
AddComponent(property);
for (size_t i = 0; i < properties.size(); i++)
{
property->AddOption(std::pair<std::string, int>(properties[i].Name, i));
property->AddOption(std::pair<String, int>(properties[i].Name.FromAscii(), i));
}
property->SetOption(Client::Ref().GetPrefInteger("Prop.Type", 0));
@ -97,7 +96,7 @@ void PropertyWindow::SetProperty()
{
if(property->GetOption().second!=-1 && textField->GetText().length() > 0)
{
std::string value = textField->GetText();
String value = textField->GetText();
try {
switch(properties[property->GetOption().second].Type)
{
@ -105,26 +104,20 @@ void PropertyWindow::SetProperty()
case StructProperty::ParticleType:
{
int v;
if(value.length() > 2 && value.substr(0, 2) == "0x")
if(value.length() > 2 && value.BeginsWith("0x"))
{
//0xC0FFEE
std::stringstream buffer;
buffer.exceptions(std::stringstream::failbit | std::stringstream::badbit);
buffer << std::hex << value.substr(2);
buffer >> v;
v = value.Substr(2).ToNumber<unsigned int>(Format::Hex());
}
else if(value.length() > 1 && value[0] == '#')
else if(value.length() > 1 && value.BeginsWith("0"))
{
//#C0FFEE
std::stringstream buffer;
buffer.exceptions(std::stringstream::failbit | std::stringstream::badbit);
buffer << std::hex << value.substr(1);
buffer >> v;
v = value.Substr(1).ToNumber<unsigned int>(Format::Hex());
}
else
{
int type;
if (properties[property->GetOption().second].Type == StructProperty::ParticleType && (type = sim->GetParticleType(value)) != -1)
if (properties[property->GetOption().second].Type == StructProperty::ParticleType && (type = sim->GetParticleType(value.ToUtf8())) != -1)
{
v = type;
@ -134,9 +127,7 @@ void PropertyWindow::SetProperty()
}
else
{
std::stringstream buffer(value);
buffer.exceptions(std::stringstream::failbit | std::stringstream::badbit);
buffer >> v;
v = value.ToNumber<int>();
}
}
@ -156,27 +147,19 @@ void PropertyWindow::SetProperty()
case StructProperty::UInteger:
{
unsigned int v;
if(value.length() > 2 && value.substr(0, 2) == "0x")
if(value.length() > 2 && value.BeginsWith("0x"))
{
//0xC0FFEE
std::stringstream buffer;
buffer.exceptions(std::stringstream::failbit | std::stringstream::badbit);
buffer << std::hex << value.substr(2);
buffer >> v;
v = value.Substr(2).ToNumber<unsigned int>(Format::Hex());
}
else if(value.length() > 1 && value[0] == '#')
else if(value.length() > 1 && value.BeginsWith("#"))
{
//#C0FFEE
std::stringstream buffer;
buffer.exceptions(std::stringstream::failbit | std::stringstream::badbit);
buffer << std::hex << value.substr(1);
buffer >> v;
v = value.Substr(1).ToNumber<unsigned int>(Format::Hex());
}
else
{
std::stringstream buffer(value);
buffer.exceptions(std::stringstream::failbit | std::stringstream::badbit);
buffer >> v;
v = value.ToNumber<unsigned int>();
}
#ifdef DEBUG
std::cout << "Got uint value " << v << std::endl;
@ -186,16 +169,17 @@ void PropertyWindow::SetProperty()
}
case StructProperty::Float:
{
std::stringstream buffer(value);
buffer.exceptions(std::stringstream::failbit | std::stringstream::badbit);
buffer >> tool->propValue.Float;
if (properties[property->GetOption().second].Name == "temp" && value.length())
if (value.EndsWith("C"))
{
if (value.substr(value.length()-1) == "C")
tool->propValue.Float += 273.15;
else if (value.substr(value.length()-1) == "F")
tool->propValue.Float = (tool->propValue.Float-32.0f)*5/9+273.15f;
float v = value.SubstrFromEnd(1).ToNumber<float>();
tool->propValue.Float = v + 273.15;
}
else if(value.EndsWith("F"))
{
float v = value.SubstrFromEnd(1).ToNumber<float>();
tool->propValue.Float = (v-32.0f)*5/9+273.15f;
}
tool->propValue.Float = value.ToNumber<float>();
#ifdef DEBUG
std::cout << "Got float value " << tool->propValue.Float << std::endl;
#endif
@ -212,7 +196,7 @@ void PropertyWindow::SetProperty()
return;
}
Client::Ref().SetPref("Prop.Type", property->GetOption().second);
Client::Ref().SetPref("Prop.Value", textField->GetText());
Client::Ref().SetPrefUnicode("Prop.Value", textField->GetText());
}
}

View File

@ -1,6 +1,6 @@
#pragma once
#include <string>
#include "common/String.h"
#include <vector>
class GameModel;
@ -23,9 +23,9 @@ protected:
std::vector<QuickOptionListener*> listeners;
GameModel * m;
Type type;
std::string icon;
std::string description;
QuickOption(std::string icon, std::string description, GameModel * m, Type type) :
String icon;
String description;
QuickOption(String icon, String description, GameModel * m, Type type) :
m(m),
type(type),
icon(icon),
@ -57,10 +57,10 @@ public:
virtual int GetMutli() { return 0;}
virtual int GetMultiCount() { return 0;}
std::string GetIcon() { return icon; }
void SetIcon(std::string icon) { this->icon = icon; }
std::string GetDescription() { return description; }
void SetDescription(std::string description) { this->description = description; }
String GetIcon() { return icon; }
void SetIcon(String icon) { this->icon = icon; }
String GetDescription() { return description; }
void SetDescription(String description) { this->description = description; }
void Perform()
{
perform();

View File

@ -3,13 +3,13 @@
class RenderPreset
{
public:
std::string Name;
String Name;
std::vector<unsigned int> RenderModes;
std::vector<unsigned int> DisplayModes;
unsigned int ColourMode;
RenderPreset(): Name(""), ColourMode(0) {}
RenderPreset(std::string name, std::vector<unsigned int> renderModes, std::vector<unsigned int> displayModes, unsigned int colourMode):
RenderPreset(String name, std::vector<unsigned int> renderModes, std::vector<unsigned int> displayModes, unsigned int colourMode):
Name(name),
RenderModes(renderModes),
DisplayModes(displayModes),

View File

@ -15,7 +15,7 @@ VideoBuffer * SampleTool::GetIcon(int toolID, int width, int height)
newTexture->SetPixel(x, y, PIXR(pc), PIXG(pc), PIXB(pc), 255);
}
}
newTexture->SetCharacter((width/2)-5, (height/2)-5, 0xE6, 255, 255, 255, 255);
newTexture->AddCharacter((width/2)-5, (height/2)-5, 0xE066, 255, 255, 255, 255);
newTexture->BlendPixel(10, 9, 100, 180, 255, 255);
newTexture->BlendPixel(11, 8, 100, 180, 255, 255);
newTexture->BlendPixel(12, 7, 100, 180, 255, 255);

View File

@ -128,10 +128,10 @@ SignWindow::SignWindow(SignTool * tool_, Simulation * sim_, int signID_, ui::Poi
justification = new ui::DropDown(ui::Point(52, 48), ui::Point(50, 16));
AddComponent(justification);
justification->AddOption(std::pair<std::string, int>("\xA0 Left", (int)sign::Left));
justification->AddOption(std::pair<std::string, int>("\x9E Middle", (int)sign::Middle));
justification->AddOption(std::pair<std::string, int>("\x9F Right", (int)sign::Right));
justification->AddOption(std::pair<std::string, int>("\x9D None", (int)sign::None));
justification->AddOption(std::pair<String, int>(0xE020 + String(" Left"), (int)sign::Left));
justification->AddOption(std::pair<String, int>(0xE01E + String(" Middle"), (int)sign::Middle));
justification->AddOption(std::pair<String, int>(0xE01F + String(" Right"), (int)sign::Right));
justification->AddOption(std::pair<String, int>(0xE01D + String(" None"), (int)sign::None));
justification->SetOption(1);
justification->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
@ -181,9 +181,9 @@ void SignWindow::DoDraw()
{
sign & currentSign = *iter;
int x, y, w, h, dx, dy;
char type = 0;
String::value_type type = 0;
Graphics * g = GetGraphics();
std::string text = currentSign.getText(sim);
String text = currentSign.getText(sim);
sign::splitsign(currentSign.text, &type);
currentSign.pos(text, x, y, w, h);
g->clearrect(x, y, w+1, h);
@ -268,8 +268,8 @@ VideoBuffer * SignTool::GetIcon(int toolID, int width, int height)
newTexture->SetPixel(x, y, PIXR(pc), PIXG(pc), PIXB(pc), 255);
}
}
newTexture->SetCharacter((width/2)-5, (height/2)-5, 0xA1, 32, 64, 128, 255);
newTexture->BlendCharacter((width/2)-5, (height/2)-5, 0xA0, 255, 255, 255, 255);
newTexture->AddCharacter((width/2)-5, (height/2)-5, 0xE021, 32, 64, 128, 255);
newTexture->BlendCharacter((width/2)-5, (height/2)-5, 0xE020, 255, 255, 255, 255);
return newTexture;
}

View File

@ -1,4 +1,4 @@
#include <string>
#include "common/String.h"
#include "Tool.h"
#include "gui/game/Brush.h"
@ -6,7 +6,7 @@
using namespace std;
Tool::Tool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int)):
Tool::Tool(int id, ByteString name, String description, int r, int g, int b, ByteString identifier, VideoBuffer * (*textureGen)(int, int, int)):
textureGen(textureGen),
toolID(id),
toolName(name),
@ -32,9 +32,9 @@ void Tool::SetTextureGen(VideoBuffer * (*textureGen)(int, int, int))
{
this->textureGen = textureGen;
}
std::string Tool::GetIdentifier() { return identifier; }
string Tool::GetName() { return toolName; }
string Tool::GetDescription() { return toolDescription; }
ByteString Tool::GetIdentifier() { return identifier; }
ByteString Tool::GetName() { return toolName; }
String Tool::GetDescription() { return toolDescription; }
Tool::~Tool() {}
void Tool::Click(Simulation * sim, Brush * brush, ui::Point position) { }
@ -50,7 +50,7 @@ void Tool::DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Po
void Tool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {}
ElementTool::ElementTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int)):
ElementTool::ElementTool(int id, ByteString name, String description, int r, int g, int b, ByteString identifier, VideoBuffer * (*textureGen)(int, int, int)):
Tool(id, name, description, r, g, b, identifier, textureGen)
{
}
@ -69,7 +69,7 @@ void ElementTool::DrawFill(Simulation * sim, Brush * brush, ui::Point position)
}
WallTool::WallTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int)):
WallTool::WallTool(int id, ByteString name, String description, int r, int g, int b, ByteString identifier, VideoBuffer * (*textureGen)(int, int, int)):
Tool(id, name, description, r, g, b, identifier, textureGen)
{
blocky = true;
@ -110,7 +110,7 @@ void WallTool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {
sim->FloodWalls(position.X, position.Y, toolID, -1);
}
WindTool::WindTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int)):
WindTool::WindTool(int id, ByteString name, String description, int r, int g, int b, ByteString identifier, VideoBuffer * (*textureGen)(int, int, int)):
Tool(id, name, description, r, g, b, identifier, textureGen)
{
}

View File

@ -3,8 +3,7 @@
#include <iostream>
using namespace std;
#include "common/String.h"
#include "gui/interface/Point.h"
#include "simulation/StructProperty.h"
@ -17,19 +16,19 @@ class Tool
protected:
VideoBuffer * (*textureGen)(int, int, int);
int toolID;
string toolName;
string toolDescription;
ByteString toolName;
String toolDescription;
float strength;
bool blocky;
std::string identifier;
ByteString identifier;
public:
int colRed, colGreen, colBlue;
Tool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL);
Tool(int id, ByteString name, String description, int r, int g, int b, ByteString identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL);
int GetToolID() { return toolID; }
string GetName();
string GetDescription();
std::string GetIdentifier();
ByteString GetName();
String GetDescription();
ByteString GetIdentifier();
int GetBlocky() { return blocky; }
void SetStrength(float value) { strength = value; }
float GetStrength() { return strength; }
@ -106,7 +105,7 @@ public:
class ElementTool: public Tool
{
public:
ElementTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL);
ElementTool(int id, ByteString name, String description, int r, int g, int b, ByteString identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL);
virtual ~ElementTool();
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position);
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging = false);
@ -117,7 +116,7 @@ public:
class Element_LIGH_Tool: public ElementTool
{
public:
Element_LIGH_Tool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL):
Element_LIGH_Tool(int id, ByteString name, String description, int r, int g, int b, ByteString identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL):
ElementTool(id, name, description, r, g, b, identifier, textureGen)
{ }
virtual ~Element_LIGH_Tool() { }
@ -130,7 +129,7 @@ public:
class Element_TESC_Tool: public ElementTool
{
public:
Element_TESC_Tool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL):
Element_TESC_Tool(int id, ByteString name, String description, int r, int g, int b, ByteString identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL):
ElementTool(id, name, description, r, g, b, identifier, textureGen)
{ }
virtual ~Element_TESC_Tool() {}
@ -141,7 +140,7 @@ public:
class PlopTool: public ElementTool
{
public:
PlopTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL):
PlopTool(int id, ByteString name, String description, int r, int g, int b, ByteString identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL):
ElementTool(id, name, description, r, g, b, identifier, textureGen)
{ }
virtual ~PlopTool() { }
@ -155,7 +154,7 @@ public:
class WallTool: public Tool
{
public:
WallTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL);
WallTool(int id, ByteString name, String description, int r, int g, int b, ByteString identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL);
virtual ~WallTool();
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position);
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging = false);
@ -166,7 +165,7 @@ public:
class WindTool: public Tool
{
public:
WindTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL);
WindTool(int id, ByteString name, String description, int r, int g, int b, ByteString identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL);
virtual ~WindTool() { }
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position) { }
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging = false);

View File

@ -4,8 +4,8 @@
#include "gui/interface/Mouse.h"
#include "Favorite.h"
ToolButton::ToolButton(ui::Point position, ui::Point size, std::string text_, std::string toolIdentifier, std::string toolTip):
ui::Button(position, size, text_, toolTip),
ToolButton::ToolButton(ui::Point position, ui::Point size, ByteString text_, ByteString toolIdentifier, String toolTip):
ui::Button(position, size, text_.FromAscii(), toolTip),
toolIdentifier(toolIdentifier)
{
SetSelectionState(-1);
@ -13,7 +13,7 @@ ToolButton::ToolButton(ui::Point position, ui::Point size, std::string text_, st
Appearance.BorderFavorite = ui::Colour(255, 255, 0);
//don't use "..." on elements that have long names
buttonDisplayText = ButtonText.substr(0, 7);
buttonDisplayText = ButtonText.Substr(0, 7);
Component::TextPosition(buttonDisplayText);
}
@ -67,7 +67,7 @@ void ToolButton::Draw(const ui::Point& screenPos)
}
if (Favorite::Ref().IsFavorite(toolIdentifier))
{
g->drawtext(screenPos.X, screenPos.Y, "\xE8", Appearance.BorderFavorite.Red, Appearance.BorderFavorite.Green, Appearance.BorderFavorite.Blue, Appearance.BorderFavorite.Alpha);
g->drawtext(screenPos.X, screenPos.Y, 0xE068, Appearance.BorderFavorite.Red, Appearance.BorderFavorite.Green, Appearance.BorderFavorite.Blue, Appearance.BorderFavorite.Alpha);
}
if (totalColour<544)

View File

@ -6,9 +6,9 @@
class ToolButton: public ui::Button
{
int currentSelection;
std::string toolIdentifier;
ByteString toolIdentifier;
public:
ToolButton(ui::Point position, ui::Point size, std::string text_, std::string toolIdentifier, std::string toolTip = "");
ToolButton(ui::Point position, ui::Point size, ByteString text_, ByteString toolIdentifier, String toolTip = "");
virtual void OnMouseUnclick(int x, int y, unsigned int button);
virtual void OnMouseUp(int x, int y, unsigned int button);
virtual void OnMouseClick(int x, int y, unsigned int button);

View File

@ -12,7 +12,7 @@
namespace ui {
AvatarButton::AvatarButton(Point position, Point size, std::string username):
AvatarButton::AvatarButton(Point position, Point size, ByteString username):
Component(position, size),
avatar(NULL),
name(username),

View File

@ -1,7 +1,7 @@
#ifndef AVATARBUTTON_H_
#define AVATARBUTTON_H_
#include <string>
#include "common/String.h"
#include "Component.h"
#include "graphics/Graphics.h"
@ -21,10 +21,10 @@ public:
class AvatarButton : public Component, public RequestListener
{
VideoBuffer * avatar;
std::string name;
ByteString name;
bool tried;
public:
AvatarButton(Point position, Point size, std::string username);
AvatarButton(Point position, Point size, ByteString username);
virtual ~AvatarButton();
virtual void OnMouseClick(int x, int y, unsigned int button);
@ -42,8 +42,8 @@ public:
virtual void DoAction();
void SetUsername(std::string username) { name = username; }
std::string GetUsername() { return name; }
void SetUsername(ByteString username) { name = username; }
ByteString GetUsername() { return name; }
void SetActionCallback(AvatarButtonAction * action);
protected:
bool isMouseInside, isButtonDown;

View File

@ -6,7 +6,7 @@
namespace ui {
Button::Button(Point position, Point size, std::string buttonText, std::string toolTip):
Button::Button(Point position, Point size, String buttonText, String toolTip):
Component(position, size),
ButtonText(buttonText),
toolTip(toolTip),
@ -19,14 +19,14 @@ Button::Button(Point position, Point size, std::string buttonText, std::string t
TextPosition(ButtonText);
}
void Button::TextPosition(std::string ButtonText)
void Button::TextPosition(String ButtonText)
{
buttonDisplayText = ButtonText;
if(buttonDisplayText.length())
{
if(Graphics::textwidth((char *)buttonDisplayText.c_str()) > Size.X - (Appearance.icon? 22 : 0))
if(Graphics::textwidth(buttonDisplayText) > Size.X - (Appearance.icon? 22 : 0))
{
int position = Graphics::textwidthx((char *)buttonDisplayText.c_str(), Size.X - (Appearance.icon? 38 : 22));
int position = Graphics::textwidthx(buttonDisplayText, Size.X - (Appearance.icon? 38 : 22));
buttonDisplayText = buttonDisplayText.erase(position, buttonDisplayText.length()-position);
buttonDisplayText += "...";
}
@ -41,7 +41,7 @@ void Button::SetIcon(Icon icon)
TextPosition(ButtonText);
}
void Button::SetText(std::string buttonText)
void Button::SetText(String buttonText)
{
ButtonText = buttonText;
TextPosition(ButtonText);

Some files were not shown because too many files have changed in this diff Show More