Ticket #8647: title_translation.diff

File title_translation.diff, 1.7 KB (added by jvprat, 17 years ago)

Support for translated game titles

  • base/game.h

     
    2929#include "common/array.h"
    3030#include "common/hash-str.h"
    3131
     32struct GameTitleTranslation {
     33        Common::Language language;
     34        const char *title;
     35};
     36
     37#define END_TRANS {Common::UNK_LANG, NULL}
     38#define NO_TRANS {END_TRANS}
     39
    3240struct PlainGameDescriptor {
    3341        const char *gameid;
    3442        const char *description;        // TODO: Rename this to "title" or so
     43        GameTitleTranslation translations[10];
    3544};
    3645
    3746class GameDescriptor : public Common::StringMap {
     
    91100// TODO: Find a better place for this function.
    92101GameDescriptor findGame(const Common::String &gameName, const Plugin **plugin = NULL);
    93102
     103const char* getGameTitle(const PlainGameDescriptor &pgd, Common::Language l);
     104
    94105} // End of namespace Base
    95106
    96107
  • base/game.cpp

     
    7777        return result;
    7878}
    7979
     80const char* getGameTitle(const PlainGameDescriptor &pgd, Common::Language l) {
     81        const GameTitleTranslation *trans = pgd.translations;
     82        while (trans->language != Common::UNK_LANG) {
     83                if (trans->language == l)
     84                        return trans->title;
     85                trans++;
     86        }
     87
     88        return pgd.description;
     89}
     90
    8091} // End of namespace Base
  • common/advancedDetector.cpp

     
    123123
    124124        while (sg->gameid) {
    125125                if (!scumm_stricmp(g.gameid, sg->gameid))
    126                         title = sg->description;
     126                        title = Base::getGameTitle(*sg, g.language);
    127127                sg++;
    128128        }
    129129