From 7436f6c9cdd13eb6f24b5f5af815c548268a66a9 Mon Sep 17 00:00:00 2001 From: pixel Date: Sun, 19 Dec 2004 03:22:48 +0000 Subject: Updated luapatch, and separated language file. --- MSVC/Tools/Tools.vcproj | 3 + luapatch-languages.h | 201 ++++++++++++++++++++++++++++++++++++++++++++++++ luapatch.cpp | 185 +++++++++++++++++++++----------------------- luapatch.rc | 30 +++----- 4 files changed, 302 insertions(+), 117 deletions(-) create mode 100644 luapatch-languages.h diff --git a/MSVC/Tools/Tools.vcproj b/MSVC/Tools/Tools.vcproj index f3eaad4..55de511 100644 --- a/MSVC/Tools/Tools.vcproj +++ b/MSVC/Tools/Tools.vcproj @@ -51,6 +51,9 @@ + + diff --git a/luapatch-languages.h b/luapatch-languages.h new file mode 100644 index 0000000..0a0f87b --- /dev/null +++ b/luapatch-languages.h @@ -0,0 +1,201 @@ +enum strings_e { + ISOFILE, + CDDRIVE, + ISOSOURCE, + ISODEST, + PATCH, + NO_DESTINATION, + NO_SOURCE, + NO_PATCH, + MSGERROR, + PARASITE_EVE, + VERBOSE_CFG_ERROR, + CFG_ERROR, + END_MSG, + END_TITLE, +}; + +struct texts_t { + int id; + int owner; + char * str; +}; + +struct texts_t t_english[] = { + {IDC_ABOUTTEXT, IDD_ABOUT, +"LuaPatch version 0.4.0\n" +"Hand made special MFC version\n\n" +"A CD patching system\n\n" +"Copyrignt © 2003-2005 Nicolas \"Pixel\" Noble / NOBIS\n\n" +"http://www.nobis-crew.org/luapatch/\n" +"http://www.nobis-crew.org/"}, + {IDOK, IDD_ABOUT, "OK"}, + {IDOK, IDD_FILESELECT, "OK"}, + {IDCANCEL, IDD_FILESELECT, "Quit"}, + {IDC_ABOUT, IDD_FILESELECT, "About"}, + {IDC_ST_SOURCETYPE, IDD_FILESELECT, "Source type:"}, + {IDC_ST_SOURCE, IDD_FILESELECT, "Source:"}, + {IDC_ST_DEST, IDD_FILESELECT, "Destination file:"}, + {IDC_ST_PATCH, IDD_FILESELECT, "Patch file:"}, + + {ISOFILE, 0, "Iso file"}, + {CDDRIVE, 0, "CD drive"}, + {ISODEST, 0, "2352-raw image (*.bin)\0*.BIN\0\0\0"}, + {ISOSOURCE, 0, "2352-raw image (*.bin, *.iso, *.img)\0*.BIN;*.ISO;*.IMG\0\0\0"}, + {PATCH, 0, "PAQ Archive (*.paq)\0*.PAQ\0\0\0"}, + {MSGERROR, 0, "Error"}, + {NO_DESTINATION, 0, "No destination file."}, + {NO_SOURCE, 0, "No source file."}, + {NO_PATCH, 0, "No patch file."}, + {PARASITE_EVE, 0, "Error loading configuration file, switching to old Parasite Eve behavior.\n"}, + {VERBOSE_CFG_ERROR, 0, "Something's wrong with that patch: no valid configuration file.\n"}, + {CFG_ERROR, 0, "No valid configuration file found."}, + {END_MSG, 0, "Patch successfully applied!"}, + {END_TITLE, 0, "Done"}, + + {-1, 0} +}; + +struct texts_t t_french[] = { + {IDC_ABOUTTEXT, IDD_ABOUT, +"LuaPatch version 0.4.0\n" +"Version artisanale spéciale MFC\n\n" +"Un système de patch de CD\n\n" +"Copyrignt © 2003-2005 Nicolas \"Pixel\" Noble / NOBIS\n\n" +"http://www.nobis-crew.org/luapatch/\n" +"http://www.nobis-crew.org/"}, + {IDCANCEL, IDD_FILESELECT, "Quitter"}, + {IDC_ABOUT, IDD_FILESELECT, "A propos"}, + {IDC_ST_SOURCETYPE, IDD_FILESELECT, "Type de source:"}, + {IDC_ST_DEST, IDD_FILESELECT, "Fichier de destination:"}, + {IDC_ST_PATCH, IDD_FILESELECT, "Fichier de patch:"}, + + {ISOFILE, 0, "Fichier ISO"}, + {CDDRIVE, 0, "Lecteur CD"}, + {ISODEST, 0, "Image ISO 2352-raw (*.bin)\0*.BIN\0\0\0"}, + {ISOSOURCE, 0, "Image ISO 2352-raw (*.bin, *.iso, *.img)\0*.BIN;*.ISO;*.IMG\0\0\0"}, + {PATCH, 0, "Archive PAQ (*.paq)\0*.PAQ\0\0\0"}, + {MSGERROR, 0, "Erreur"}, + {NO_DESTINATION, 0, "Pas de fichier de destination."}, + {NO_SOURCE, 0, "Pas de fichier source."}, + {NO_PATCH, 0, "Pas de fichier patch."}, + {PARASITE_EVE, 0, "Erreur au chargement du fichier de configuration, compatibilité descendante avec Parasite Eve activée.\n" }, + {VERBOSE_CFG_ERROR, 0, "Quelque chose ne va pas avec ce patch: pas de fichier de configuration valide.\n"}, + {CFG_ERROR, 0, "Aucun fichier de configuration valide trouvé."}, + {END_MSG, 0, "Patch appliqué avec succès!"}, + {END_TITLE, 0, "Terminé"}, + + {-1, 0} +}; + +struct texts_t t_german[] = { + {IDC_ABOUTTEXT, IDD_ABOUT, +"LuaPatch version 0.4.0\n" +"Adaptierte MFC Version\n\n" +"CD Patch System\n\n" +"Copyright © 2003-2005 Nicolas \"Pixel\" Noble / NOBIS\n\n" +"http://www.nobis-crew.org/luapatch/\n" +"http://www.nobis-crew.org/"}, + {IDCANCEL, IDD_FILESELECT, "Beenden"}, + {IDC_ABOUT, IDD_FILESELECT, "Info"}, + {IDC_ST_SOURCETYPE, IDD_FILESELECT, "Quelletyp:"}, + {IDC_ST_SOURCE, IDD_FILESELECT, "Quelle:"}, + {IDC_ST_DEST, IDD_FILESELECT, "Ziel Datei:"}, + {IDC_ST_PATCH, IDD_FILESELECT, "Patch Datei:"}, + + {ISOFILE, 0, "Iso Image"}, + {CDDRIVE, 0, "CD Laufwerk"}, + {ISODEST, 0, "ISO Image 2352-raw (*.bin)\0*.BIN\0\0\0"}, + {ISOSOURCE, 0, "ISO Image 2352-raw (*.bin, *.iso, *.img)\0*.BIN;*.ISO;*.IMG\0\0\0"}, + {PATCH, 0, "Archiv PAQ (*.paq)\0*.PAQ\0\0\0"}, + {MSGERROR, 0, "Fehler"}, + {NO_DESTINATION, 0, "Keine Zeildatei."}, + {NO_SOURCE, 0, "Keine Quelldatei."}, + {NO_PATCH, 0, "Keine Patchdatei."}, + + {-1, 0} +}; + +struct texts_t t_spanish[] = { + {IDC_ABOUTTEXT, IDD_ABOUT, +"LuaPatch versión 0.4.0\n" +"Versión especial MFC hecha a mano\n\n" +"Un sistema de parcheo de CD\n\n" +"Copyrignt © 2003-2005 Nicolas \"Pixel\" Noble / NOBIS\n\n" +"http://www.nobis-crew.org/luapatch/\n" +"http://www.nobis-crew.org/"}, + {IDCANCEL, IDD_FILESELECT, "Salir"}, + {IDC_ABOUT, IDD_FILESELECT, "Acerca de"}, + {IDC_ST_SOURCETYPE, IDD_FILESELECT, "Tipo de fuente:"}, + {IDC_ST_DEST, IDD_FILESELECT, "Archivo de destino:"}, + {IDC_ST_PATCH, IDD_FILESELECT, "Parche:"}, + + {ISOFILE, 0, "Archivo ISO"}, + {CDDRIVE, 0, "Unidad de CD"}, + {ISODEST, 0, "Imagen 2352-raw (*.bin)\0*.BIN\0\0\0"}, + {ISOSOURCE, 0, "Imagen 2352-raw (*.bin, *.iso, *.img)\0*.BIN;*.ISO;*.IMG\0\0\0"}, + {PATCH, 0, "Fichero PAQ (*.paq)\0*.PAQ\0\0\0"}, + {MSGERROR, 0, "Error"}, + {NO_DESTINATION, 0, "No hay archivo de destino."}, + {NO_SOURCE, 0, "No hay archivo fuente."}, + {NO_PATCH, 0, "No hay parche."}, + {PARASITE_EVE, 0, "Error cargando archivo de configuración, cambiando a viejo estilo Parasite Eve.\n"}, + {VERBOSE_CFG_ERROR, 0, "Algo está mal con ese parche: archivo de configuración inválido.\n"}, + {CFG_ERROR, 0, "No se encontró archivo de configuración válido."}, + {END_MSG, 0, "¡Parche aplicado satisfactoriamente!"}, + {END_TITLE, 0, "Hecho"}, + + {-1, 0} +}; + +struct texts_t t_portuguese[] = { + {IDC_ABOUTTEXT, IDD_ABOUT, +"LuaPatch versão 0.4.0\n" +"Feito em uma versão especial da MFC\n\n" +"Um sistema de Patchs para para CDs\n\n" +"Copyrignt © 2003-2005 Nicolas \"Pixel\" Noble / NOBIS\n\n" +"http://www.nobis-crew.org/luapatch/\n" +"http://www.nobis-crew.org/"}, + {IDCANCEL, IDD_FILESELECT, "Sair"}, + {IDC_ABOUT, IDD_FILESELECT, "Sobre"}, + {IDC_ST_SOURCETYPE, IDD_FILESELECT, "Tipo do arquivo:"}, + {IDC_ST_DEST, IDD_FILESELECT, "Arquivo de destino:"}, + {IDC_ST_PATCH, IDD_FILESELECT, "Arquivo de Patch:"}, + + {ISOFILE, 0, "Arquivo ISO"}, + {CDDRIVE, 0, "Drive de CD"}, + {ISODEST, 0, "2352-raw image (*.bin)\0*.BIN\0\0\0"}, + {ISOSOURCE, 0, "2352-raw image (*.bin, *.iso, *.img)\0*.BIN;*.ISO;*.IMG\0\0\0"}, + {PATCH, 0, "Arquivo PAQ (*.paq)\0*.PAQ\0\0\0"}, + {MSGERROR, 0, "Erro"}, + {NO_DESTINATION, 0, "Arquivo de destino não especificado."}, + {NO_SOURCE, 0, "Arquivo de origem não especificado."}, + {NO_PATCH, 0, "Arquivo de patch não especificado."}, + {PARASITE_EVE, 0, "Erro carregando o arquivo de configuração... mudando para as configurações do Parasite Eve.\n"}, + {VERBOSE_CFG_ERROR, 0, "Há algo errado com o patch: nenhum arquivo de configuração válido foi encontrado.\n"}, + {CFG_ERROR, 0, "Nenhum arquivo de configuração válido foi encontrado."}, + {END_MSG, 0, "Patch aplicado com sucesso!"}, + {END_TITLE, 0, "Pronto"}, + + {-1, 0} +}; + +struct trad_t { + int langid; + struct texts_t * trad; +}; + +struct trad_t trads[] = { + {LANG_NEUTRAL, t_english}, + {LANG_FRENCH, t_french}, + {LANG_GERMAN, t_german}, + {LANG_SPANISH, t_spanish}, + {LANG_PORTUGUESE, t_portuguese}, + {-1, 0} +}; + +enum { + DEST_SELECT, + SOURCE_SELECT, + PATCH_SELECT, +}; diff --git a/luapatch.cpp b/luapatch.cpp index 7665b9e..369b55a 100644 --- a/luapatch.cpp +++ b/luapatch.cpp @@ -2,9 +2,11 @@ #include #include +#include #include #include #include +#include #include "cdabstract.h" #include "cdutils.h" @@ -14,124 +16,78 @@ #include "luapatch-res.h" +#include "luapatch-languages.h" + static int myprint(lua_State * _L) { Lua * L = Lua::find(_L); String t = L->tostring(); + char * tc = t.strdup(); + + Base::printm(M_STATUS, "%s\n", tc); - Base::printm(M_BARE, t + "\n"); + free(tc); return 0; } -bool Verify(HWND); - -enum strings_e { - ISOFILE, - CDDRIVE, - ISOSOURCE, - ISODEST, - PATCH, - NO_DESTINATION, - NO_SOURCE, - NO_PATCH, - MSGERROR, +class Luabasecdtool : public LuaObject { + public: + static void pushstatics(Lua *) throw (GeneralException); }; -bool quit = false; -bool canprobe; -bool fromdrive = false; - -String source, dest, patch; +typedef void basecdtool; -struct texts_t { - int id; - int owner; - char * str; +enum basecdtool_t { + BASECDTOOL_LOAD = 0, }; -struct texts_t t_english[] = { - {ISOFILE, 0, "Iso file"}, - {CDDRIVE, 0, "CD drive"}, - {ISODEST, 0, "2352-raw image (*.bin)\0*.BIN\0\0\0"}, - {ISOSOURCE, 0, "2352-raw image (*.bin, *.iso, *.img)\0*.BIN;*.ISO;*.IMG\0\0\0"}, - {PATCH, 0, "PAQ Archive (*.paq)\0*.PAQ\0\0\0"}, - {MSGERROR, 0, "Error"}, - {NO_DESTINATION, 0, "No destination file."}, - {NO_SOURCE, 0, "No source file."}, - {NO_PATCH, 0, "No patch file."}, - {-1, 0} +struct lua_functypes_t basecdtool_functions[] = { + { BASECDTOOL_LOAD, "load", 0, 1, { LUA_STRING | LUA_OBJECT } }, + { -1, 0, 0, 0, 0 } }; -struct texts_t t_french[] = { - {IDC_ABOUTTEXT, IDD_ABOUT, -"LuaPatch version 0.3.0\n" -"Version artisanale spéciale MFC \"Eve\"\n\n" -"Un système de patch de CD\n\n" -"Copyrignt © 2003-2004 Nicolas \"Pixel\" Noble / NOBIS\n\n" -"http://www.nobis-crew.org/luapatch/\n" -"http://www.nobis-crew.org/"}, - {IDCANCEL, IDD_FILESELECT, "Quitter"}, - {IDC_ABOUT, IDD_FILESELECT, "A propos"}, - {IDC_ST_SOURCETYPE, IDD_FILESELECT, "Type de source:"}, - {IDC_ST_DEST, IDD_FILESELECT, "Fichier de destination:"}, - {IDC_ST_PATCH, IDD_FILESELECT, "Fichier de patch:"}, - {ISOFILE, 0, "Fichier ISO"}, - {CDDRIVE, 0, "Lecteur CD"}, - {ISODEST, 0, "Image ISO 2352-raw (*.bin)\0*.BIN\0\0\0"}, - {ISOSOURCE, 0, "Image ISO 2352-raw (*.bin, *.iso, *.img)\0*.BIN;*.ISO;*.IMG\0\0\0"}, - {PATCH, 0, "Archive PAQ (*.paq)\0*.PAQ\0\0\0"}, - {MSGERROR, 0, "Erreur"}, - {NO_DESTINATION, 0, "Pas de fichier de destination."}, - {NO_SOURCE, 0, "Pas de fichier source."}, - {NO_PATCH, 0, "Pas de fichier patch."}, - {-1, 0} +class sLua_basecdtool : public Base { + public: + DECLARE_FUNCTION(basecdtool, BASECDTOOL_LOAD); + private: + static int basecdtool_proceed_statics(Lua * L, int n, int caller); }; -struct texts_t t_german[] = { - {IDC_ABOUTTEXT, IDD_ABOUT, -"LuaPatch version 0.3.0\n" -"Adaptierte MFC Version \"Eve\"\n\n" -"CD Patch System\n\n" -"Copyright © 2003-2004 Nicolas \"Pixel\" Noble / NOBIS\n\n" -"http://www.nobis-crew.org/luapatch/\n" -"http://www.nobis-crew.org/"}, - {IDCANCEL, IDD_FILESELECT, "Beenden"}, - {IDC_ABOUT, IDD_FILESELECT, "Info"}, - {IDC_ST_SOURCETYPE, IDD_FILESELECT, "Quelletyp:"}, - {IDC_ST_SOURCE, IDD_FILESELECT, "Quelle:"}, - {IDC_ST_DEST, IDD_FILESELECT, "Ziel Datei:"}, - {IDC_ST_PATCH, IDD_FILESELECT, "Patch Datei:"}, - {ISOFILE, 0, "Iso Image"}, - {CDDRIVE, 0, "CD Laufwerk"}, - {ISODEST, 0, "ISO Image 2352-raw (*.bin)\0*.BIN\0\0\0"}, - {ISOSOURCE, 0, "ISO Image 2352-raw (*.bin, *.iso, *.img)\0*.BIN;*.ISO;*.IMG\0\0\0"}, - {PATCH, 0, "Archiv PAQ (*.paq)\0*.PAQ\0\0\0"}, - {MSGERROR, 0, "Fehler"}, - {NO_DESTINATION, 0, "Keine Zeildatei."}, - {NO_SOURCE, 0, "Keine Quelldatei."}, - {NO_PATCH, 0, "Keine Patchdatei."}, - {-1, 0} -}; +void Luabasecdtool::pushstatics(Lua * L) throw (GeneralException ) { + CHECK_FUNCTIONS(basecdtool); + + PUSH_FUNCTION(basecdtool, BASECDTOOL_LOAD); +} -struct trad_t { - int langid; - struct texts_t * trad; -}; +int sLua_basecdtool::basecdtool_proceed_statics(Lua * L, int n, int caller) { + int r = 0; -struct trad_t trads[] = { - {LANG_NEUTRAL, t_english}, - {LANG_FRENCH, t_french}, - {LANG_GERMAN, t_german}, - {-1, 0} -}; + switch (caller) { + case BASECDTOOL_LOAD: + if (!n) { + L->load(&Input("cd-tool.lua")); + } else { + if (L->isstring(1)) { + L->load(&Input(L->tostring(1))); + } else { + Handle * t = (Handle *) LuaObject::getme(L, 1); + L->load(t); + } + } + } -int langid; + return r; +} -enum { - DEST_SELECT, - SOURCE_SELECT, - PATCH_SELECT, -}; +bool Verify(HWND); + +bool quit = false; +bool canprobe; +bool fromdrive = false; + +String source, dest, patch; + +int langid; void translate(int ownerid, HWND hW) { struct trad_t * t; @@ -405,7 +361,7 @@ bool Verify(HWND hW) { CODE_BEGINS virtual int startup(void) throw (GeneralException) { verbosity = M_INFO; - printm(M_BARE, "LuaPatch (C) 2004 Nicolas \"Pixel\" Noble - front-end starting.\n"); + printm(M_BARE, "LuaPatch (C) 2003-2005 Nicolas \"Pixel\" Noble - front-end starting.\n"); int lang; lang = GetUserDefaultLangID(); @@ -436,6 +392,7 @@ virtual int startup(void) throw (GeneralException) { L->open_math(); L->open_string(); L->open_table(); + L->open_dir(); LuaInput::pushconstruct(L); LuaOutput::pushconstruct(L); LuaBuffer::pushconstruct(L); @@ -444,6 +401,7 @@ virtual int startup(void) throw (GeneralException) { L->push("print"); L->push(myprint); L->settable(LUA_GLOBALSINDEX); + Luabasecdtool::pushstatics(L); Luacdutils lcdutil(cdutil); L->push("cdutil"); @@ -453,13 +411,42 @@ virtual int startup(void) throw (GeneralException) { L->push("iso"); liso.push(L); L->setvar(); - L->load(&Input("main")); + + Handle * config_file = 0; + + try { + config_file = new Input("patch.ini"); + } + catch (IOGeneral e) { + } + + if (!config_file) { + printm(M_WARNING, GetString(PARASITE_EVE)); + try { + L->load(&Input("main")); + } + catch (IOGeneral e) { + printm(M_ERROR, GetString(VERBOSE_CFG_ERROR)); + throw GeneralException(GetString(CFG_ERROR)); + } + } else { + ConfigFile cfg(config_file); + Buffer cmd; + + L->load(&Input(cfg["patch"]["filename"])); + cmd << cfg["patch"]["command"]; + L->load(&cmd); + } + + delete config_file; delete b; delete o; delete cdutil; delete iso_r; + MessageBox(0, GetString(END_MSG), GetString(END_TITLE), MB_ICONINFORMATION | MB_OK); + return 0; } CODE_ENDS diff --git a/luapatch.rc b/luapatch.rc index 003f590..b84a91b 100644 --- a/luapatch.rc +++ b/luapatch.rc @@ -65,13 +65,13 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_SYS_DEFAULT // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,3,0,0 - PRODUCTVERSION 0,3,0,0 - FILEFLAGSMASK 0x37L + FILEVERSION 0,4,0,0 + PRODUCTVERSION 0,4,0,0 + FILEFLAGSMASK 0x17L #ifdef _DEBUG - FILEFLAGS 0x21L + FILEFLAGS 0x1L #else - FILEFLAGS 0x20L + FILEFLAGS 0x0L #endif FILEOS 0x4L FILETYPE 0x1L @@ -84,26 +84,20 @@ BEGIN VALUE "Comments", "LuaPatcher - CD Patching system" VALUE "CompanyName", "NOBIS - http://www.nobis-crew.org/" VALUE "FileDescription", "LuaPatcher - Système de patch de CD" - VALUE "FileVersion", "0, 3, 0, 0" - VALUE "InternalName", "Eve" - VALUE "LegalCopyright", "Copyright © 2003-2003 Nicolas ""Pixel"" Noble / NOBIS" - VALUE "OriginalFilename", "Melissa" + VALUE "FileVersion", "0, 4, 0, 0" + VALUE "LegalCopyright", "Copyright © 2003-2005 Nicolas ""Pixel"" Noble / NOBIS" VALUE "ProductName", "LuaPatch" - VALUE "ProductVersion", "0, 3, 0, 0" - VALUE "SpecialBuild", "Eve" + VALUE "ProductVersion", "0, 4, 0, 0" END BLOCK "040c04b0" BEGIN VALUE "Comments", "LuaPatcher - Système de patch de CD" VALUE "CompanyName", "NOBIS - http://www.nobis-crew.org/" VALUE "FileDescription", "NOBIS - http://www.nobis-crew.org/" - VALUE "FileVersion", "0, 3, 0, 0" - VALUE "InternalName", "Eve" - VALUE "LegalCopyright", "Copyright © 2003-2003 Nicolas ""Pixel"" Noble / NOBIS" - VALUE "OriginalFilename", "Mélissa" + VALUE "FileVersion", "0, 4, 0, 0" + VALUE "LegalCopyright", "Copyright © 2003-2005 Nicolas ""Pixel"" Noble / NOBIS" VALUE "ProductName", "LuaPatch" - VALUE "ProductVersion", "0, 3, 0, 0" - VALUE "SpecialBuild", "Eve" + VALUE "ProductVersion", "0, 4, 0, 0" END END BLOCK "VarFileInfo" @@ -151,7 +145,7 @@ CAPTION "About..." FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "OK",IDOK,7,85,50,14,BS_CENTER | BS_FLAT - CTEXT "LuaPatch version 0.3.0\nHand made special MFC version ""Eve""\n\nA CD patching system\n\nCopyrignt © 2003-2004 Nicolas ""Pixel"" Noble / NOBIS\n\nhttp://www.nobis-crew.org/luapatch/\nhttp://www.nobis-crew.org/", + CTEXT "LuaPatch version 0.4.0\nHand made special MFC version\n\nA CD patching system\n\nCopyrignt © 2003-2005 Nicolas ""Pixel"" Noble / NOBIS\n\nhttp://www.nobis-crew.org/luapatch/\nhttp://www.nobis-crew.org/", IDC_ABOUTTEXT,7,7,201,77 END -- cgit v1.2.3