Remove include of translate.h from stratagus.h

Remove unused StratagusTranslation and GameTranslation
Add translate.pkg
This commit is contained in:
joris 2012-08-06 13:22:03 +02:00
parent 08d5feaead
commit 6cc0f43065
25 changed files with 67 additions and 74 deletions

View file

@ -321,6 +321,7 @@ set(tolua_FILES
src/tolua/player.pkg
src/tolua/sound.pkg
src/tolua/stratagus.pkg
src/tolua/translate.pkg
src/tolua/trigger.pkg
src/tolua/ui.pkg
src/tolua/unit.pkg

View file

@ -47,6 +47,7 @@
#include "player.h"
#include "script.h"
#include "tileset.h"
#include "translate.h"
#include "ui.h"
#include "unit.h"
#include "unittype.h"

View file

@ -41,6 +41,7 @@
#include "player.h"
#include "script.h"
#include "sound.h"
#include "translate.h"
#include "unit.h"
#include "unittype.h"

View file

@ -45,6 +45,7 @@
#include "player.h"
#include "script.h"
#include "sound.h"
#include "translate.h"
#include "unit.h"
#include "ui.h"
#include "unittype.h"

View file

@ -43,6 +43,7 @@
#include "script.h"
#include "sound.h"
#include "player.h"
#include "translate.h"
#include "unit.h"
#include "unitsound.h"
#include "unittype.h"

View file

@ -51,6 +51,7 @@
#include "script.h"
#include "sound.h"
#include "spells.h"
#include "translate.h"
#include "ui.h"
#include "unit.h"
#include "unittype.h"

View file

@ -42,6 +42,7 @@
#include "iolib.h"
#include "player.h"
#include "sound.h"
#include "translate.h"
#include "ui.h"
#include "unit.h"
#include "unitsound.h"

View file

@ -44,6 +44,7 @@
#include "player.h"
#include "script.h"
#include "spells.h"
#include "translate.h"
#include "unit.h"
#include "unittype.h"

View file

@ -43,6 +43,7 @@
#include "player.h"
#include "spells.h"
#include "tileset.h"
#include "translate.h"
#include "upgrade.h"
#include "ui.h"
#include "unit.h"

View file

@ -55,6 +55,7 @@
#include "sound.h"
#include "sound_server.h"
#include "tileset.h"
#include "translate.h"
#include "ui.h"
#include "unit_find.h"
#include "unittype.h"

View file

@ -50,6 +50,7 @@
#include "script.h"
#include "settings.h"
#include "sound.h"
#include "translate.h"
#include "unit_manager.h"
#include "unittype.h"
#include "version.h"

View file

@ -156,15 +156,6 @@ inline char *new_strdup(const char *str)
return newstr;
}
/*----------------------------------------------------------------------------
-- Translate
----------------------------------------------------------------------------*/
#include "translate.h"
#define _(str) Translate(str)
#define N_(str) str
/*----------------------------------------------------------------------------
-- General
----------------------------------------------------------------------------*/

View file

@ -30,15 +30,8 @@
#ifndef __TRANSLATE_H__
#define __TRANSLATE_H__
#include <string>
//@{
/// The PO containing the translations for the stratagus engine
extern std::string StratagusTranslation;
/// The PO containing the translations for the game itself
extern std::string GameTranslation;
/*----------------------------------------------------------------------------
-- Functions
----------------------------------------------------------------------------*/
@ -52,6 +45,8 @@ extern void LoadPO(const char *file);
/// Set the stratagus and game translations
extern void SetTranslationsFiles(const char *stratagusfile, const char *gamefile);
#define _(str) Translate(str)
#define N_(str) str
//@}

View file

@ -228,6 +228,7 @@
#include "player.h"
#include "replay.h"
#include "sound.h"
#include "translate.h"
#include "unit.h"
#include "unit_manager.h"
#include "unittype.h"

View file

@ -45,6 +45,7 @@
#include "network.h"
#include "netconnect.h"
#include "sound.h"
#include "translate.h"
#include "unitsound.h"
#include "unittype.h"
#include "unit.h"

View file

@ -213,6 +213,7 @@ extern int getopt(int argc, char *const *argv, const char *opt);
#include "sound.h"
#include "sound_server.h"
#include "title.h"
#include "translate.h"
#include "ui.h"
#include "unit_manager.h"
#include "util.h"

View file

@ -35,12 +35,12 @@
#include "stratagus.h"
#include <map>
#include <string>
#include "translate.h"
#include "iolib.h"
#include <cstdio>
#include <map>
#include <string>
/*----------------------------------------------------------------------------
-- Variables
@ -48,8 +48,6 @@
typedef std::map<std::string, std::string> EntriesType;
static EntriesType Entries;
std::string StratagusTranslation;
std::string GameTranslation;
/*----------------------------------------------------------------------------
-- Functions
@ -81,13 +79,6 @@ void AddTranslation(const char *str1, const char *str2)
*/
void LoadPO(const char *file)
{
FILE *fd;
char buf[4096];
enum { MSGNONE, MSGID, MSGSTR } state;
char msgid[16 * 1024];
char msgstr[16 * 1024];
char *s;
char *currmsg = NULL;
char fullfile[1024];
if (!file || !*file) {
@ -95,13 +86,16 @@ void LoadPO(const char *file)
}
LibraryFileName(file, fullfile, sizeof(fullfile));
fd = fopen(fullfile, "rb");
FILE *fd = fopen(fullfile, "rb");
if (!fd) {
fprintf(stderr, "Could not open file: %s\n", file);
return;
}
enum { MSGNONE, MSGID, MSGSTR } state = MSGNONE;
char msgid[16 * 1024];
char msgstr[16 * 1024];
char *currmsg = NULL;
state = MSGNONE;
msgid[0] = msgstr[0] = '\0';
// skip 0xEF utf8 intro if found
@ -113,13 +107,13 @@ void LoadPO(const char *file)
rewind(fd);
}
char buf[4096];
while (fgets(buf, sizeof(buf), fd)) {
// Comment
if (buf[0] == '#') {
continue;
}
s = buf;
char *s = buf;
// msgid or msgstr
if (!strncmp(s, "msgid ", 6)) {
@ -192,8 +186,6 @@ void SetTranslationsFiles(const char *stratagusfile, const char *gamefile)
{
LoadPO(stratagusfile);
LoadPO(gamefile);
StratagusTranslation = stratagusfile;
GameTranslation = gamefile;
}
//@}

View file

@ -74,6 +74,7 @@ $pfile "particle.pkg"
$pfile "pathfinder.pkg"
$pfile "player.pkg"
$pfile "sound.pkg"
$pfile "translate.pkg"
$pfile "trigger.pkg"
$pfile "ui.pkg"
$pfile "unit.pkg"
@ -81,13 +82,6 @@ $pfile "unittype.pkg"
$pfile "upgrade.pkg"
$pfile "video.pkg"
extern const char *Translate(const char *str);
extern void AddTranslation(const char *str1, const char *str2);
extern void LoadPO(const char *file);
extern void SetTranslationsFiles(const char *stratagusfile, const char *gamefile);
extern std::string StratagusTranslation;
extern std::string GameTranslation;
extern int SaveGame(const std::string filename);
extern void DeleteSaveGame(const std::string filename);

6
src/tolua/translate.pkg Normal file
View file

@ -0,0 +1,6 @@
$#include "translate.h"
extern const char *Translate(const char *str);
extern void AddTranslation(const char *str1, const char *str2);
extern void LoadPO(const char *file);
extern void SetTranslationsFiles(const char *stratagusfile, const char *gamefile);

View file

@ -34,29 +34,31 @@
-- Includes
----------------------------------------------------------------------------*/
#include <ctype.h>
#include <vector>
#include <sstream>
#include "stratagus.h"
#include "ui.h"
#include "actions.h"
#include "commands.h"
#include "depend.h"
#include "font.h"
#include "guichan/key.h"
#include "guichan/sdl/sdlinput.h"
#include "interface.h"
#include "map.h"
#include "player.h"
#include "sound.h"
#include "spells.h"
#include "translate.h"
#include "trigger.h"
#include "unit.h"
#include "unittype.h"
#include "upgrade.h"
#include "interface.h"
#include "ui.h"
#include "player.h"
#include "spells.h"
#include "depend.h"
#include "sound.h"
#include "map.h"
#include "commands.h"
#include "video.h"
#include "font.h"
#include "actions.h"
#include "trigger.h"
#include "guichan/key.h"
#include "guichan/sdl/sdlinput.h"
#include <ctype.h>
#include <vector>
#include <sstream>
/*----------------------------------------------------------------------------
-- Defines

View file

@ -48,6 +48,7 @@
#include "sound.h"
#include "sound_server.h"
#include "tileset.h"
#include "translate.h"
#include "ui.h"
#include "unit.h"
#include "unit_find.h"

View file

@ -34,10 +34,6 @@
-- Includes
----------------------------------------------------------------------------*/
#include <stdarg.h>
#include <math.h>
#include <sstream>
#include "stratagus.h"
#include "action/action_built.h"
@ -54,6 +50,7 @@
#include "sound.h"
#include "spells.h"
#include "tileset.h"
#include "translate.h"
#include "trigger.h"
#include "ui.h"
#include "unit.h"
@ -66,6 +63,7 @@
#include "../ai/ai_local.h"
#endif
#include <sstream>
/*----------------------------------------------------------------------------
-- MENU BUTTON

View file

@ -57,6 +57,7 @@
#include "sound.h"
#include "spells.h"
#include "tileset.h"
#include "translate.h"
#include "unit.h"
#include "unit_find.h"
#include "unitsound.h"

View file

@ -33,11 +33,6 @@
-- Includes
----------------------------------------------------------------------------*/
#include <limits.h>
#include <math.h>
#include <sstream>
#include <iomanip>
#include "stratagus.h"
#include "unit.h"
@ -61,6 +56,7 @@
#include "sound_server.h"
#include "spells.h"
#include "tileset.h"
#include "translate.h"
#include "ui.h"
#include "unit_find.h"
#include "unit_manager.h"
@ -68,6 +64,9 @@
#include "unittype.h"
#include "video.h"
#include <math.h>
/*----------------------------------------------------------------------------
-- Documentation
----------------------------------------------------------------------------*/

View file

@ -77,17 +77,17 @@
#include "maemo.h"
#endif
#include "video.h"
#include "editor.h"
#include "font.h"
#include "interface.h"
#include "network.h"
#include "ui.h"
#include "sound_server.h"
#include "sound.h"
#include "interface.h"
#include "minimap.h"
#include "network.h"
#include "sound.h"
#include "sound_server.h"
#include "translate.h"
#include "ui.h"
#include "video.h"
#include "widgets.h"
#include "editor.h"
/*----------------------------------------------------------------------------
-- Declarations