home *** CD-ROM | disk | FTP | other *** search
- /*
- Copyright (C) 2000 by Hervé PHILIPPE <rv@bemail.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
- #include "TextesDuLogiciel.h"
-
- /////////////////////////////////////////
- // CONSTANTE "m_kTableauNomsAttributs" //
- /////////////////////////////////////////-----------------------------
- // Constante membre en "static" pour définir les noms des attributs --
- //--------------------------------------------------------------------
- const char* TextesDuLogiciel::m_kTableauNomsAttributs[]={
- "MENU.Fichier", // 0
- "MENU.Nouvelle Partie", // 1
- "MENU.Changer de joueurs", // 2
- "MENU.Ouvrir", // 3
- "MENU.Sauver sous", // 4
- "MENU.Quitter", // 5
- "MENU.Options", // 6
- "MENU.Coup précédent", // 7
- "MENU.Coup suivant", // 8
- "MENU.Coup suivant réaliste", // 9
- "MENU.Coup déplacement réaliste", // 10
- "MENU.Pause", // 11
- "MENU.A propos", // 12
- "FICHIER.Nom par défaut", // 13
- "FICHIER.Fenêtre.Ouvrir", // 14
- "FICHIER.Fenêtre.Sauver", // 15
- "FICHIER.Erreur", // 16
- "FICHIER.Erreur.Lecture1", // 17
- "FICHIER.Erreur.Lecture2", // 18
- "FICHIER.Erreur.Ecriture", // 19
- "FICHIER.Erreur.Chargement", // 20
- "FICHIER.Tant pis", // 21
- "FICHIER.Ouvrir", // 22
- "FICHIER.Sauver", // 23
- "DIVERS.Humain", // 24
- "DIVERS.Ordinateur", // 25
- "DIVERS.Pause", // 26
- "DIVERS.Partie terminée", // 27
- "DIVERS.Annuler", // 28
- "DIVERS.Niveau", // 29
- "DIVERS.Plusieurs joueurs", // 30
- "DIVERS.Sélection joueurs", // 31
- "DIVERS.Joueur numéro", // 32
- "DIVERS.Commencer partie", // 33
- "MENU.Langue", // 34
- "MENU.Plateau de jeu", // 35
- "APROPOS.Texte", // 36
- "APROPOS.Bouton" // 37
- // IMPORTANT : en cas d'ajout, ne pas oublier de changer la constante "m_kNombreDAttributs" !
- };
- /////////////////////////////////////
- // CONSTANTE "m_kNombreDAttributs" //
- /////////////////////////////////////----------------------------------------
- // Constante membre en "static" pour définir le nombre maximum d'attributs --
- //---------------------------------------------------------------------------
- const uint8 TextesDuLogiciel::m_kNombreDAttributs = 38;
-
-
- ////////////////////////////////////////
- // CONSTRUCTEUR de "TextesDuLogiciel" //
- ////////////////////////////////////////-----------------------------------------
- //----------------------------------------------------------------------------------------
- TextesDuLogiciel::TextesDuLogiciel()
- {
- uint8 i;
-
- m_TableauTextes = new (char*)[m_kNombreDAttributs];
- for (i = 0; i < m_kNombreDAttributs; i++)
- m_TableauTextes[i] = NULL;
- }
-
- ///////////////////////////////////////
- // DESTRUCTEUR de "TextesDuLogiciel" //
- ///////////////////////////////////////-------
- //-----------------------------------------------------
- TextesDuLogiciel::~TextesDuLogiciel()
- // AUCUN PARAMETRE
- {
- uint8 i;
-
- if (m_TableauTextes != NULL) {
- for (i = 0; i < m_kNombreDAttributs; i++)
- if (m_TableauTextes[i] != NULL)
- delete m_TableauTextes[i];
- delete m_TableauTextes;
- }
- }
-
- ///////////////////////////////
- // FONCTION "ChargerFichier" //
- ///////////////////////////////---------------
- // Charge les textes provenant d'un fichier --
- //--------------------------------------------
- void // AUCUNE VALEUR DE RETOUR
- TextesDuLogiciel::ChargerFichier(const BEntry* entree_fichier)
- // 1 PARAMETRE : ENTREE (@)
- {
- BFile fichier;
- uint8 i;
- attr_info infos_attribut;
-
- for (i = 0; i < m_kNombreDAttributs; i++)
- if (m_TableauTextes[i] != NULL) {
- delete m_TableauTextes[i];
- m_TableauTextes[i] = NULL;
- }
- if (entree_fichier == NULL)
- return;
-
- fichier.SetTo(entree_fichier, B_READ_ONLY);
- if (fichier.InitCheck() == B_OK) {
- for (i = 0; i < m_kNombreDAttributs; i++) {
- if (fichier.GetAttrInfo(m_kTableauNomsAttributs[i], &infos_attribut) == B_OK) {
- m_TableauTextes[i] = new char[infos_attribut.size];
- fichier.ReadAttr(m_kTableauNomsAttributs[i], B_STRING_TYPE, 0, m_TableauTextes[i], infos_attribut.size);
- }
- else {
- m_TableauTextes[i] = new char[11];
- strcpy(m_TableauTextes[i], "texte_vide");
- }
- }
- fichier.Unset();
- }
- }
-
- //////////////////////
- // FONCTION "Texte" //
- //////////////////////---------------------------
- // Renvoie le texte correspondant à son numéro --
- //-----------------------------------------------
- char* // VALEUR DE RETOUR
- TextesDuLogiciel::Texte(uint8 numero_du_texte)
- // 1 PARAMETRE : ENTREE
- {
- if (numero_du_texte < m_kNombreDAttributs && m_TableauTextes[numero_du_texte] != NULL)
- return m_TableauTextes[numero_du_texte];
- else
- return "texte_indéfini";
- }
-
-