~ubuntu-branches/ubuntu/raring/powermanga/raring

« back to all changes in this revision

Viewing changes to src/chaine.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese
  • Date: 2006-08-19 10:15:56 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060819101556-llg7innyzoadukro
Tags: 0.80-3ubuntu1
* Re-merge with Debian
* Fix desktop file for validation
* Install icon in /usr/share/pixmaps

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//*****************************************************************************
2
 
// copyright (c) 1998-2004 TLK Games all rights reserved
 
2
// copyright (c) 1998-2005 TLK Games all rights reserved
3
3
//-----------------------------------------------------------------------------
4
4
// file         : "_chaine.cpp"
5
5
// created      : 1998-05-21
6
 
// updates      : 2004-08-01
 
6
// updates      : 2005-01-11
7
7
//-----------------------------------------------------------------------------
8
8
// description  : Implementation de la classe _chaine
9
9
//                gere des chaines de caractere, avec un affichage 'sprite'
28
28
//*****************************************************************************
29
29
#include "linux.hpp"
30
30
#include "chaine.hpp"
31
 
#include "powermanga.hpp"
32
 
 
 
31
#include "powermanga.hpp"
 
32
 
33
33
#ifndef SDL_TLK
34
34
#include <X11/keysym.h>
35
35
#include <X11/keysymdef.h>
100
100
// *****************************************************************************
101
101
 
102
102
// Constructeurs ---------------------------------------------------------------
103
 
_chaine::_chaine()
 
103
        _chaine::_chaine()
104
104
{
105
105
  razMembres();
106
106
}
107
 
_chaine::_chaine(char *_pChaine, int _iPositionX, int _iPositionY, int _iOffsetH)
 
107
        _chaine::_chaine(char *_pChaine, int _iPositionX, int _iPositionY,
 
108
                 int _iOffsetH)
108
109
{
109
110
  razMembres();
110
111
  initialise(_pChaine, _iPositionX, _iPositionY, _iOffsetH, 0);
128
129
  iTempoCycle = 0;
129
130
  pCaracteres = (_caractere *)NULL;
130
131
  pAscii = (char *)NULL;
 
132
  iCurseurAction = 0;
131
133
  pAscii_allocted = 0;
132
 
  iCurseurAction = 0;
 
134
  pCaracteres = 0;
 
135
  pAscii = 0;
133
136
}
134
137
 
135
138
// Destructeur -----------------------------------------------------------------
136
139
_chaine::~_chaine()
137
140
{
138
 
  if(pCaracteres)
 
141
  if(pCaracteres != 0)
139
142
    delete [] pCaracteres;
140
143
  //printf("_chaine::~_chaine() %i %s 2\n", pAscii_allocted, pAscii);
141
144
  if(pAscii && pAscii_allocted)
161
164
void _chaine::initialise(char *_pChaine, int _iPositionX, int _iPositionY,
162
165
                         int _iOffsetH, int _iTypeFonte)
163
166
{
164
 
 
165
 
  iNombreCaracteres = strlen(_pChaine);
166
 
  if(pAscii == (char *)0x0)
167
 
  { pAscii_allocted = 1;
168
 
    pAscii = new char[iNombreCaracteres + 1];
169
 
  }
170
 
  strcpy(pAscii, _pChaine);
171
 
 
172
 
  init(_iPositionX, _iPositionY, _iOffsetH, _iTypeFonte);
 
167
        iNombreCaracteres = strlen(_pChaine);
 
168
        if(pAscii == (char *)0x0) {
 
169
                pAscii_allocted = 1;
 
170
                pAscii = new char[iNombreCaracteres + 1];
 
171
        }
 
172
        strcpy(pAscii, _pChaine);
 
173
        init(_iPositionX, _iPositionY, _iOffsetH, _iTypeFonte);
173
174
}
174
175
 
175
 
 
176
 
 // Initialise une nouvelle chaine de caracteres --------------------------------
 
176
// Initialise une nouvelle chaine de caracteres --------------------------------
177
177
void _chaine::initialise(char *_pChaine, int _iNombreCaractere,
178
178
                         int _iPositionX, int _iPositionY, int _iOffsetH,
179
179
                         int _iTypeFonte)
187
187
void _chaine::init(int _iPositionX, int _iPositionY, int _iOffsetH,
188
188
                   int _iTypeFonte)
189
189
{
190
 
  iCurseurPosition = 0;
191
 
  iPositionX = _iPositionX;
192
 
  iPositionY = _iPositionY;
193
 
  iCentreX = _iPositionX;
194
 
  iCentreY = _iPositionY;
195
 
  iOffsetH = _iOffsetH;
196
 
  if(pCaracteres == (_caractere *) 0x0)
197
 
    pCaracteres = new _caractere[iNombreCaracteres];
198
 
  for(int _iIndex = 0; _iIndex < iNombreCaracteres; _iIndex++)
199
 
  {  _caractere  *_oCaractere = &pCaracteres[_iIndex];
200
 
     char _cAscii = pAscii[_iIndex];
201
 
    _oCaractere->initialise_caractere(_cAscii,
202
 
                                      iPositionX + _iIndex * iOffsetH,
203
 
                                      iPositionY, _iTypeFonte);
204
 
  }
 
190
        iCurseurPosition = 0;
 
191
        iPositionX = _iPositionX;
 
192
        iPositionY = _iPositionY;
 
193
        iCentreX = _iPositionX;
 
194
        iCentreY = _iPositionY;
 
195
        iOffsetH = _iOffsetH;
 
196
        if(pCaracteres == (_caractere *) 0x0)   
 
197
                pCaracteres = new _caractere[iNombreCaracteres];
 
198
        for(int _iIndex = 0; _iIndex < iNombreCaracteres; _iIndex++)
 
199
        {       _caractere *_oCaractere = &pCaracteres[_iIndex];
 
200
                char _cAscii = pAscii[_iIndex];
 
201
                _oCaractere->initialise_caractere(_cAscii,
 
202
                        iPositionX + _iIndex * iOffsetH,
 
203
                        iPositionY, _iTypeFonte);
 
204
        }
205
205
}
206
206
 
207
207
void _chaine::initialiseChaine(char *_pChaine)
339
339
#else
340
340
    case XK_BackSpace:
341
341
#endif
342
 
      int j;
343
 
      if (iCurseurPosition > 0)
344
 
        j = iCurseurPosition;
345
 
      else
346
 
        j = 1;
347
 
      for(_iIndex = j; _iIndex < iNombreCaracteres; _iIndex++)
348
 
        pAscii[_iIndex - 1] = pAscii[_iIndex];
 
342
      /*for(_iIndex = iCurseurPosition; _iIndex < iNombreCaracteres; _iIndex++)
 
343
      { pAscii[_iIndex - 1] = pAscii[_iIndex];
 
344
      }*/
 
345
 
 
346
          int j;
 
347
          if (iCurseurPosition > 0)
 
348
                  j = iCurseurPosition;
 
349
          else
 
350
                  j = 1;
 
351
 
 
352
          for(_iIndex = j; _iIndex < iNombreCaracteres; _iIndex++)
 
353
      { 
 
354
                  pAscii[_iIndex - 1] = pAscii[_iIndex];
 
355
      }
 
356
 
349
357
      pAscii[iNombreCaracteres - 1] = ' ';
350
358
      iCurseurPosition--;
351
359
      initialiseSprite();
356
364
#else
357
365
    case XK_Delete:
358
366
#endif
359
 
      for(_iIndex = iCurseurPosition; _iIndex < iNombreCaracteres - 2;
 
367
      for(_iIndex = iCurseurPosition; _iIndex < iNombreCaracteres - 2;  // - 1
360
368
          _iIndex++)
361
 
        pAscii[_iIndex] = pAscii[_iIndex + 1];
 
369
      { pAscii[_iIndex] = pAscii[_iIndex + 1];
 
370
      }
362
371
      pAscii[iNombreCaracteres - 1] = ' ';
363
372
      initialiseSprite();
364
373
      break;