From 23669127a8f3d46489476d6ab4f9e46aa5ad89ef Mon Sep 17 00:00:00 2001 From: Taylor Richards Date: Wed, 26 Feb 2014 21:06:34 -0500 Subject: [PATCH] get fonttool cleaned up and working --- CMakeLists.txt | 6 ++++ include/fonttool.h | 6 +--- src/fonttool/fontkern.cpp | 62 +++++++++++++------------------------- src/fonttool/fontstubs.cpp | 2 +- src/fonttool/fonttool.cpp | 12 +++----- 5 files changed, 33 insertions(+), 55 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9df9e2e..ae59620 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,6 +148,12 @@ add_executable(fonttool src/fonttool/fonttool.cpp ) +add_custom_command(TARGET fonttool + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/src/fonttool" + COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/src/fonttool/fonttool.pcx" "${CMAKE_CURRENT_BINARY_DIR}/src/fonttool" +) + target_link_libraries( fonttool code diff --git a/include/fonttool.h b/include/fonttool.h index 3e394df..2f8cd43 100644 --- a/include/fonttool.h +++ b/include/fonttool.h @@ -43,11 +43,7 @@ #include "2d.h" #include "font.h" -#ifdef PLAT_UNIX - void fonttool_edit_kerning(char *fname1, char *argv[]); -#else - void fonttool_edit_kerning(char *fname1); -#endif +void fonttool_edit_kerning(char *fname1, char *extras_dir); void fonttool_kerning_copy( char *fname1, char *fname2 ); void fonttool_create_font(char *pcx_filename, char *font_filename); diff --git a/src/fonttool/fontkern.cpp b/src/fonttool/fontkern.cpp index c57c100..ce7304b 100644 --- a/src/fonttool/fontkern.cpp +++ b/src/fonttool/fontkern.cpp @@ -123,6 +123,7 @@ #include "timer.h" #include "bmpman.h" #include "osregistry.h" +#include "cmdline.h" #include "fonttool.h" @@ -133,7 +134,9 @@ const char *SampleText = "This is some sample text that is here to\n" \ static void myexit(int value) { -// getch(); +#ifdef WIN32 + getch(); +#endif exit(value); } @@ -307,7 +310,7 @@ void fonttool_remove_kerning( font *fnt ) } -void fonttool_edit_kerning(char *fname1, char *argv[]) +void fonttool_edit_kerning(char *fname1, char *extras_dir) { int i, k,x; int done; @@ -322,7 +325,6 @@ void fonttool_edit_kerning(char *fname1, char *argv[]) int current_item = 0; int num_items_displayed = 1; int last_good_pair = -1; - const char *ptr; color ac; printf( "Editing kerning data for %s\n", fname1 ); @@ -335,48 +337,24 @@ void fonttool_edit_kerning(char *fname1, char *argv[]) //SDL_assert(c != NULL); //char *tok = strtok(c, " "); //SDL_assert(tok != NULL); -#ifdef PLAT_UNIX - char whee[1024]; - getcwd (whee, 1024); - strcat(whee, "/"); - strcat(whee, fname1); - cfile_init(whee); -#else - cfile_init(argv[0]); -#endif + + cfile_init(extras_dir); os_init( "FontTool", "FontTool - Kerning Table Editor" ); - // init the registry -#ifndef PLAT_UNIX - os_init_registry_stuff(Osreg_company_name, Osreg_app_name,NULL); -#endif - ptr = os_config_read_string(NULL, NOX("Videocard"), NULL); - if((ptr == NULL) || !stricmp(ptr, "Aucune acc�l�ration 3D") || !stricmp(ptr, "Keine 3D-Beschleunigerkarte") || !stricmp(ptr, "No 3D acceleration")){ -#ifndef PLAT_UNIX - MessageBox((HWND)os_get_window(), "Warning, Freespace 2 requires Glide or Direct3D hardware accleration. You will not be able to run Freespace 2 without it", "Warning", MB_OK); -#endif - exit(1); - } - if (!stricmp(ptr, NOX("3DFX Glide"))) { - // Glide - gr_init(GR_640, GR_GLIDE); - } else if (strstr(ptr, NOX("Direct 3D -"))){ - // Direct 3D - gr_init(GR_640, GR_DIRECT3D); - } else if (strstr(ptr, NOX("OpenGL"))){ - // OpenGL - gr_init(GR_640, GR_OPENGL); - } else { - Int3(); - } + // always run this thing in a window + Cmdline_fullscreen = 0; + Cmdline_window = 1; + + gr_init(GR_640, GR_OPENGL); gr_set_palette("none",NULL); -#ifndef PLAT_UNIX - bkg = bm_load( "code\\fonttool\\FontTool" ); -#else - bkg = bm_load( "fonttool" ); -#endif + + char fonttool_pcx[128]; + sprintf(fonttool_pcx, "src%sfonttool%sfonttool", DIR_SEPARATOR_STR, DIR_SEPARATOR_STR); + + bkg = bm_load( fonttool_pcx ); + if ( bkg < 0 ) { printf("Error loading FontTool\n" ); myexit(1); @@ -630,10 +608,12 @@ void fonttool_edit_kerning(char *fname1, char *argv[]) gr_flip(); + // sleep a little bit, don't need high framerate here + SDL_Delay(10); } // cleanup - if (bkg >= -1) { + if (bkg > -1) { bm_unload(bkg); } diff --git a/src/fonttool/fontstubs.cpp b/src/fonttool/fontstubs.cpp index ae86fe6..a0f1b76 100644 --- a/src/fonttool/fontstubs.cpp +++ b/src/fonttool/fontstubs.cpp @@ -90,7 +90,7 @@ int Show_target_debug_info; int Sun_drew; int Game_subspace_effect; void game_load_palette(){} -void game_format_time(long, char*){} +void game_format_time(int, char*){} float Freespace_gamma; void get_version_string(char*){} int game_get_default_skill_level(){return 0;} diff --git a/src/fonttool/fonttool.cpp b/src/fonttool/fonttool.cpp index 474ff3a..c1e09c4 100644 --- a/src/fonttool/fonttool.cpp +++ b/src/fonttool/fonttool.cpp @@ -65,7 +65,7 @@ #include "fonttool.h" -char Usage[] = "Usage:\n" \ +static const char Usage[] = "Usage:\n" \ "\nFontTool x.pcx [y.vf]\n" \ "\n If you specify a PCX file, then a font will be\n" \ " created with the same base name. If you also\n" \ @@ -109,7 +109,7 @@ int main(int argc, char *argv[] ) } if ( argc > 1 ) { - strlwr( argv[1] ); + SDL_strlwr( argv[1] ); if ( strstr( argv[1], ".pcx" ) ) t1 = PCX; @@ -118,7 +118,7 @@ int main(int argc, char *argv[] ) } if ( argc > 2 ) { - strlwr( argv[2] ); + SDL_strlwr( argv[2] ); if ( strstr( argv[2], ".pcx" ) ) t2 = PCX; @@ -131,11 +131,7 @@ int main(int argc, char *argv[] ) else if ( (t1==PCX) && (t2==FONT) ) fonttool_create_font( argv[1], argv[2] ); else if ( (t1==FONT) && (t2==NONE) ) -#ifdef PLAT_UNIX - fonttool_edit_kerning( argv[1], NULL ); -#else - fonttool_edit_kerning( argv[1] ); -#endif + fonttool_edit_kerning( argv[1], argv[0] ); else if ( (t1==FONT) && (t2==FONT) ) fonttool_kerning_copy( argv[1], argv[2] ); else -- 2.39.2