home *** CD-ROM | disk | FTP | other *** search
/ Freelog 17 / Freelog017.iso / BeOS / ababelone / Sources / TextesDuLogiciel.cpp < prev    next >
C/C++ Source or Header  |  2000-11-20  |  5KB  |  157 lines

  1. /*
  2.     Copyright (C) 2000 by Herv├⌐ PHILIPPE <rv@bemail.org>
  3.  
  4.     This library is free software; you can redistribute it and/or
  5.     modify it under the terms of the GNU Library General Public
  6.     License as published by the Free Software Foundation; either
  7.     version 2 of the License, or (at your option) any later version.
  8.  
  9.     This library is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.     Library General Public License for more details.
  13.  
  14.     You should have received a copy of the GNU Library General Public
  15.     License along with this library; if not, write to the Free
  16.     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18.  
  19. #include "TextesDuLogiciel.h"
  20.  
  21.   /////////////////////////////////////////
  22.  // CONSTANTE "m_kTableauNomsAttributs" //
  23. /////////////////////////////////////////-----------------------------
  24. // Constante membre en "static" pour d├⌐finir les noms des attributs --
  25. //--------------------------------------------------------------------
  26. const char* TextesDuLogiciel::m_kTableauNomsAttributs[]={
  27.             "MENU.Fichier",                        // 0
  28.             "MENU.Nouvelle Partie",                // 1
  29.             "MENU.Changer de joueurs",            // 2
  30.             "MENU.Ouvrir",                        // 3
  31.             "MENU.Sauver sous",                    // 4
  32.             "MENU.Quitter",                        // 5
  33.             "MENU.Options",                        // 6
  34.             "MENU.Coup pr├⌐c├⌐dent",                // 7
  35.             "MENU.Coup suivant",                // 8
  36.             "MENU.Coup suivant r├⌐aliste",        // 9
  37.             "MENU.Coup d├⌐placement r├⌐aliste",    // 10
  38.             "MENU.Pause",                        // 11
  39.             "MENU.A propos",                    // 12
  40.             "FICHIER.Nom par d├⌐faut",            // 13
  41.             "FICHIER.Fen├¬tre.Ouvrir",            // 14
  42.             "FICHIER.Fen├¬tre.Sauver",            // 15
  43.             "FICHIER.Erreur",                    // 16
  44.             "FICHIER.Erreur.Lecture1",            // 17
  45.             "FICHIER.Erreur.Lecture2",            // 18
  46.             "FICHIER.Erreur.Ecriture",            // 19
  47.             "FICHIER.Erreur.Chargement",        // 20
  48.             "FICHIER.Tant pis",                    // 21
  49.             "FICHIER.Ouvrir",                    // 22
  50.             "FICHIER.Sauver",                    // 23
  51.             "DIVERS.Humain",                    // 24
  52.             "DIVERS.Ordinateur",                // 25
  53.             "DIVERS.Pause",                        // 26
  54.             "DIVERS.Partie termin├⌐e",            // 27
  55.             "DIVERS.Annuler",                    // 28
  56.             "DIVERS.Niveau",                    // 29
  57.             "DIVERS.Plusieurs joueurs",            // 30
  58.             "DIVERS.S├⌐lection joueurs",            // 31
  59.             "DIVERS.Joueur num├⌐ro",                // 32
  60.             "DIVERS.Commencer partie",            // 33
  61.             "MENU.Langue",                        // 34
  62.             "MENU.Plateau de jeu",                // 35
  63.             "APROPOS.Texte",                    // 36
  64.             "APROPOS.Bouton"                    // 37
  65. // IMPORTANT : en cas d'ajout, ne pas oublier de changer la constante "m_kNombreDAttributs" !
  66. };
  67.   /////////////////////////////////////
  68.  // CONSTANTE "m_kNombreDAttributs" //
  69. /////////////////////////////////////----------------------------------------
  70. // Constante membre en "static" pour d├⌐finir le nombre maximum d'attributs --
  71. //---------------------------------------------------------------------------
  72. const uint8    TextesDuLogiciel::m_kNombreDAttributs = 38;
  73.  
  74.  
  75.   ////////////////////////////////////////
  76.  // CONSTRUCTEUR de "TextesDuLogiciel" //
  77. ////////////////////////////////////////-----------------------------------------
  78. //----------------------------------------------------------------------------------------
  79. TextesDuLogiciel::TextesDuLogiciel()
  80. {
  81.     uint8 i;
  82.  
  83.     m_TableauTextes = new (char*)[m_kNombreDAttributs];
  84.     for (i = 0; i < m_kNombreDAttributs; i++)
  85.         m_TableauTextes[i] = NULL;
  86. }
  87.  
  88.   ///////////////////////////////////////
  89.  // DESTRUCTEUR de "TextesDuLogiciel" //
  90. ///////////////////////////////////////-------
  91. //-----------------------------------------------------
  92. TextesDuLogiciel::~TextesDuLogiciel()
  93. // AUCUN PARAMETRE
  94. {
  95.     uint8 i;
  96.  
  97.     if (m_TableauTextes != NULL) {
  98.         for (i = 0; i < m_kNombreDAttributs; i++)
  99.             if (m_TableauTextes[i] != NULL)
  100.                 delete m_TableauTextes[i];
  101.         delete m_TableauTextes;
  102.     }
  103. }
  104.  
  105.   ///////////////////////////////
  106.  // FONCTION "ChargerFichier" //
  107. ///////////////////////////////---------------
  108. // Charge les textes provenant d'un fichier --
  109. //--------------------------------------------
  110. void        // AUCUNE VALEUR DE RETOUR
  111. TextesDuLogiciel::ChargerFichier(const BEntry* entree_fichier)
  112. // 1 PARAMETRE :                            ENTREE (@)
  113. {
  114.     BFile fichier;
  115.     uint8 i;
  116.     attr_info infos_attribut;
  117.  
  118.     for (i = 0; i < m_kNombreDAttributs; i++)
  119.         if (m_TableauTextes[i] != NULL) {
  120.             delete m_TableauTextes[i];
  121.             m_TableauTextes[i] = NULL;
  122.         }
  123.     if (entree_fichier == NULL)
  124.         return;
  125.  
  126.     fichier.SetTo(entree_fichier, B_READ_ONLY);
  127.     if (fichier.InitCheck() == B_OK) {
  128.         for (i = 0; i < m_kNombreDAttributs; i++) {
  129.             if (fichier.GetAttrInfo(m_kTableauNomsAttributs[i], &infos_attribut) == B_OK) {
  130.                 m_TableauTextes[i] = new char[infos_attribut.size];
  131.                 fichier.ReadAttr(m_kTableauNomsAttributs[i], B_STRING_TYPE, 0, m_TableauTextes[i], infos_attribut.size);
  132.             }
  133.             else {
  134.                 m_TableauTextes[i] = new char[11];
  135.                 strcpy(m_TableauTextes[i], "texte_vide");
  136.             }
  137.         }
  138.         fichier.Unset();
  139.     }
  140. }
  141.  
  142.   //////////////////////
  143.  // FONCTION "Texte" //
  144. //////////////////////---------------------------
  145. // Renvoie le texte correspondant ├á son num├⌐ro --
  146. //-----------------------------------------------
  147. char*        // VALEUR DE RETOUR
  148. TextesDuLogiciel::Texte(uint8 numero_du_texte)
  149. // 1 PARAMETRE :                ENTREE
  150. {
  151.     if (numero_du_texte < m_kNombreDAttributs && m_TableauTextes[numero_du_texte] != NULL)
  152.         return m_TableauTextes[numero_du_texte];
  153.     else
  154.         return "texte_ind├⌐fini";
  155. }
  156.  
  157.