~ubuntu-branches/ubuntu/saucy/dossizola/saucy

« back to all changes in this revision

Viewing changes to .pc/debian-changes-1.0-8.3/dossizola/fct.c

  • Committer: Bazaar Package Importer
  • Author(s): Jari Aalto
  • Date: 2010-11-05 16:16:25 UTC
  • Revision ID: james.westby@ubuntu.com-20101105161625-sih2fme049kwo4th
Tags: 1.0-8.3
* Non-maintainer upload.
  - Move to packaging format "3.0 (quilt)" due to desktop image files.
  - NMU approved by maintainer, see #549545.
* debian/compat
  - Update obsolete 5 to 8.
* debian/control
  - (Build-Depends): Add autotools-dev due to config.{sub,guess}.
    Update to debhelper 8.
  - (Depends) update tag "Source-Version" to "source:Version"
    to correct binNMU. Patch tanks to Lior Kaplan <kaplan@debian.org>
    (normal; Closes: #435939).
  - (Homepage): New field.
  - (Standards-Version): Update to 3.9.1.
  - Package dossizola
    + (Depends): Add ${misc:Depends} (Lintian).
  - Package dossizola-data
    + (Depends): New. Add ${misc:Depends} (Lintian).
    + (Description): Extend (Lintian).
* debian/copyright
  - Point to GPL-2, save as UTF-8, add copyright years (Lintian).
  - Add FSF preamble (Lintian).
  - Point URL to canonical Sourceforge project.
* debian/dossizola.{desktop,png,xcf}
  - New. Supplied by Stéphane Blondon <stephane.blondon@gmail.com>.
    (minor; Closes: #573870).
* debian/dossizola.sgml
  - (refnamediv): Fix bad whatis entry. Must be same as <refmeta> (Lintian).
* debian/rules
  - (PACKAGE, PKGDIR, SHAREROOTDIR, ICONDIR, DESKTOPDIR): New variables.
  - (binary-indep): Comment out dh_installchangelogs because upsream
    ChangeLog is empty (Lintian).
  - (clean): Cann makefile only if it exists. Delete Makefile.
  - (configure-stamp): use latest config.{sub,guess}
    (wishlist, FTBFS avr32; Closes: #549545).
  - (install): Change obsolete "dh_clean -k" to "dh_prep" (Lintian).
    Add install commands for *.desktop file and icons.
* debian/preinst
  - Add "set -e" (Lintian).
* debian/source/{format,include-binaries}
  - New files.
* debian/watch
  - New file (Lintian).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <SDL/SDL.h>
 
2
#include "isola.h"
 
3
 
 
4
// ****************************************************************************
 
5
// ********************************** Alea ************************************
 
6
// ****************************************************************************
 
7
int Alea (short min, short max)
 
8
{
 
9
        return (unsigned short)rand() * (max - min) / 65536 + min;
 
10
}
 
11
 
 
12
 
 
13
// ****************************************************************************
 
14
// ****************************** ImageErreur *********************************
 
15
// ****************************************************************************
 
16
void ImageErreur (char *image)
 
17
{
 
18
        // Affiche un message d'erreur et quitte le programme
 
19
        fprintf (stderr, "Impossible de charger l'image %s (%s)\n", image, SDL_GetError ());
 
20
        exit (1);
 
21
}
 
22
 
 
23
 
 
24
// ****************************************************************************
 
25
// ****************************** Case2Coord **********************************
 
26
// ****************************************************************************
 
27
int Case2CoordX (int x, GRILLE grille)
 
28
{
 
29
        // Renvoit l'abscisse �cran du coin haut gauche de la case
 
30
        return grille.x1 + x * grille.tc;
 
31
}
 
32
 
 
33
int Case2CoordY (int y, GRILLE grille)
 
34
{
 
35
        // Renvoit l'abscisse �cran du coin haut gauche de la case
 
36
        return grille.y1 + y * grille.tc;
 
37
}
 
38
 
 
39
 
 
40
// ****************************************************************************
 
41
// ****************************** Clic2Case ***********************************
 
42
// ****************************************************************************
 
43
int Clic2CaseX (int x, GRILLE grille)
 
44
{
 
45
        // Renvoit l'abscisse de la case cliqu�e ou -1 si en dehors de la grille
 
46
        if (x >= grille.x1 && x < grille.x2)
 
47
                return (x - grille.x1 - 1) / grille.tc;
 
48
        else
 
49
                return -1;
 
50
}
 
51
 
 
52
int Clic2CaseY (int y, GRILLE grille)
 
53
{
 
54
        // Renvoit l'ordonn�e de la case cliqu�e ou -1 si en dehors de la grille
 
55
        if (y >= grille.y1 && y <= grille.y2)
 
56
                return (y - grille.y1 - 1) / grille.tc;
 
57
        else
 
58
                return -1;
 
59
}
 
60
 
 
61
 
 
62
// ****************************************************************************
 
63
// ******************************* Attendre_FPS *******************************
 
64
// ****************************************************************************
 
65
void Attendre_FPS (void)
 
66
{
 
67
        static int temps = 0;                           // Moment du dernier appel de cette fonction
 
68
        
 
69
        // Marque une pause pour synchroniser l'affichage sur la vitesse choisie pour que
 
70
        // le temps entre 2 appels de cette fonction soit de: 1000 ms / Frames Par Seconde
 
71
        while (SDL_GetTicks() < temps + 1000 / FPS);
 
72
        
 
73
        temps = SDL_GetTicks ();                        // Moment o� cette fonction se termine
 
74
}
 
75
 
 
76
 
 
77
// ****************************************************************************
 
78
// ********************************* Dans_Rect ********************************
 
79
// ****************************************************************************
 
80
BOOL Dans_Rect (int x, int y, SDL_Rect rect)
 
81
{
 
82
        if (x >= rect.x && x <= (rect.x + rect.w) && y >= rect.y && y <= (rect.y + rect.h))
 
83
                return OUI;
 
84
        else
 
85
                return NON;
 
86
}
 
87
 
 
88
 
 
89
// ****************************************************************************
 
90
// ************************** Afficher_Caractere ******************************
 
91
// ****************************************************************************
 
92
void Afficher_Caractere (int x, int y, char c, POLICE police, SDL_Surface *ecran)
 
93
{
 
94
        SDL_Rect dest;
 
95
 
 
96
        // Place le rectangle sur la bonne image du caract�re � afficher
 
97
        if (c >= 'A' && c <= 'Z') police.rect.x = (c - 'A') * police.rect.w;
 
98
        else if (c >= 'a' && c <= 'z') police.rect.x = (c - 'a') * police.rect.w;
 
99
        else if (c >= '0' && c <= '9') police.rect.x = (c - '0' + 26) * police.rect.w;
 
100
        else if (c == ':') police.rect.x = 36 * police.rect.w;
 
101
        else return;
 
102
 
 
103
        // Position sur l'�cran
 
104
        dest.x = x;
 
105
        dest.y = y;
 
106
        dest.w = police.rect.w;
 
107
        dest.h = police.rect.h;
 
108
 
 
109
        // Copie le caract�re et met � jour
 
110
        SDL_BlitSurface (police.img, &police.rect, ecran, &dest);
 
111
        SDL_UpdateRects (ecran, 1, &dest);
 
112
}
 
113
 
 
114
 
 
115
// ****************************************************************************
 
116
// **************************** Afficher_Chaine *******************************
 
117
// ****************************************************************************
 
118
BOOL Afficher_Chaine (int x, int y, int vitesse, char chaine[], POLICE police, SDL_Surface *ecran, SDL_Surface *back)
 
119
{
 
120
        SDL_Rect dest = {0, 0, police.rect.w, police.rect.h};
 
121
        SDL_Event evt;
 
122
        int xDep, yDep, xDest, yDest;
 
123
        int c;
 
124
        int frame;
 
125
 
 
126
        // Parcours la chaine de caract�re et affiche les caract�res un par un en
 
127
        // les faisant glisser de l'un des bord de l'�cran
 
128
        for (c = 0; chaine[c] != '\0'; c ++)
 
129
        {
 
130
                // Choisit al�atoirement le bord de l'�cran et sa position dessus
 
131
                switch (Alea (0, 2))
 
132
                {
 
133
                        case 0: xDep = Alea (0, ecran->w - police.rect.w);
 
134
                                        yDep = Alea (0, 2) ? 0 : ecran->h - police.rect.h;
 
135
                                        break;
 
136
                        case 1: xDep = Alea (0, 2) ? 0 : ecran->w - police.rect.w;
 
137
                                        yDep = Alea (0, ecran->h - police.rect.h);
 
138
                                        break;
 
139
                        default:        xDep = yDep = 0;
 
140
                }
 
141
                
 
142
                xDest = x + c * police.rect.w;
 
143
                yDest = y;
 
144
                
 
145
                // Fait glisser le caract�re du bord de l'�cran vers sa position finale
 
146
                if (vitesse > 0)
 
147
                for (frame = 0; frame <= vitesse; frame ++)
 
148
                {
 
149
                        // Quitte sur un appui sur la touche [ESC]
 
150
                        if (SDL_PollEvent (&evt) && evt.type == SDL_KEYDOWN && evt.key.keysym.sym == SDLK_ESCAPE) return OUI;
 
151
                
 
152
                        // Efface l'ancienne position
 
153
                        SDL_BlitSurface (back, &dest, ecran, &dest);
 
154
                        
 
155
                        // Affiche le caract�re au bon endroit
 
156
                        Afficher_Caractere (xDep + ((xDest - xDep) * frame) / vitesse, yDep + ((yDest - yDep) * frame) / vitesse, chaine[c], police, ecran);
 
157
                        SDL_UpdateRects (ecran, 1, &dest);
 
158
                        
 
159
                        // Fait la moyenne pour savoir o� doit �tre affich� le caract�re
 
160
                        dest.x = xDep + ((xDest - xDep) * frame) / vitesse;
 
161
                        dest.y = yDep + ((yDest - yDep) * frame) / vitesse;
 
162
                        Attendre_FPS ();
 
163
                }
 
164
 
 
165
                // Affiche le caract�re � sa position finale
 
166
                Afficher_Caractere (xDest, yDest, chaine[c], police, ecran);
 
167
                Afficher_Caractere (xDest, yDest, chaine[c], police, back);
 
168
        }
 
169
        
 
170
        return NON;
 
171
}
 
172
 
 
173
 
 
174
// ****************************************************************************
 
175
// ******************************* Questionner ********************************
 
176
// ****************************************************************************
 
177
BOOL Questionner (char ch[], POLICE police1, POLICE police2, POLICE police3, SDL_Surface *ecran)
 
178
{
 
179
        SDL_Surface *save, *noire;
 
180
        SDL_Event evt;
 
181
        SDL_Rect box;                   // Rect de copie de la "boite de dialogue"
 
182
        SDL_Rect oui, non;              // Rects de cliquage des boutons OUI et NON
 
183
        
 
184
        // Rect de la boite de dialogue du message
 
185
        box.w = police1.rect.w * (strlen (ch) + 3);
 
186
        box.h = police1.rect.h * 5;
 
187
        box.x = (ecran->w - box.w) / 2;
 
188
        box.y = (ecran->h - box.h) / 2 + police1.rect.h / 3;
 
189
        
 
190
        // Cr�e une surface pour sauvegarder la partie de l'�cran qui sera recouverte par le message
 
191
        save = SDL_CreateRGBSurface (SDL_SWSURFACE, box.w, box.h, 32, 0, 0, 0, 0);
 
192
        SDL_BlitSurface (ecran, &box, save, NULL);
 
193
        
 
194
        // Cr�e une surface noire semi-transparente qui servira � assombrir une partie de l'�cran
 
195
        if (!(noire = SDL_DisplayFormat (save)))
 
196
        {       fprintf (stderr, "Impossible de cr�er un back buffer (%s)\n", SDL_GetError ());
 
197
                SDL_FreeSurface (save);
 
198
                SDL_FreeSurface (noire);
 
199
                exit (1);
 
200
        }
 
201
        SDL_FillRect (noire, NULL, SDL_MapRGB (noire->format, 0, 0, 0));
 
202
        SDL_SetAlpha (noire, SDL_SRCALPHA, 128);
 
203
        
 
204
        // Assombrit l'�cran et met � jour
 
205
        SDL_BlitSurface (noire, NULL, ecran, &box);
 
206
        SDL_UpdateRects (ecran, 1, &box);
 
207
        SDL_FreeSurface (noire);
 
208
        
 
209
        // Rects des boutons OUI et NON
 
210
        oui.w = strlen (TXT_OUI) * police3.rect.w;
 
211
        oui.h = police3.rect.h;
 
212
        oui.x = ecran->w / 2 + police3.rect.w;
 
213
        oui.y = ecran->h / 2 + police3.rect.h;
 
214
        
 
215
        non.w = strlen (TXT_NON) * police2.rect.w;
 
216
        non.h = police2.rect.h;
 
217
        non.x = ecran->w / 2 - non.w - police2.rect.w;
 
218
        non.y = ecran->h / 2 + police2.rect.h;
 
219
        
 
220
        // Affiche le texte de la question et les textes des boutons OUI et NON
 
221
        Afficher_Chaine ((ecran->w - strlen (ch) * police1.rect.w) / 2, ecran->h / 2 - police1.rect.h, 0, ch, police1, ecran, ecran);
 
222
        Afficher_Chaine (oui.x, oui.y, 0, TXT_OUI, police3, ecran, ecran);
 
223
        Afficher_Chaine (non.x, non.y, 0, TXT_NON, police2, ecran, ecran);
 
224
        
 
225
        while (1)
 
226
        if (SDL_PollEvent (&evt))
 
227
        {       
 
228
                // Anulle sur un appui de la touche [ESC], ou un clic sur NON
 
229
                if ((evt.type == SDL_KEYDOWN && evt.key.keysym.sym == SDLK_ESCAPE) || (evt.type == SDL_MOUSEBUTTONDOWN && evt.button.button == 1 && Dans_Rect (evt.button.x, evt.button.y, non)))
 
230
                {       SDL_BlitSurface (save, NULL, ecran, &box);
 
231
                        SDL_UpdateRects (ecran, 1, &box);
 
232
                        SDL_FreeSurface (save);
 
233
                        return NON;
 
234
                }
 
235
                
 
236
                // Retourne OUI � la fonction ayant pos� cette question
 
237
                if (evt.type == SDL_MOUSEBUTTONDOWN && evt.button.button == 1 && Dans_Rect (evt.button.x, evt.button.y, oui))
 
238
                {       SDL_BlitSurface (save, NULL, ecran, &box);
 
239
                        SDL_UpdateRects (ecran, 1, &box);
 
240
                        SDL_FreeSurface (save);
 
241
                        return OUI;
 
242
                }
 
243
        }
 
244
}
 
245
 
 
246
 
 
247
// ****************************************************************************
 
248
// ******************************** Informer **********************************
 
249
// ****************************************************************************
 
250
BOOL Informer (char ch[], POLICE police, SDL_Surface *ecran)
 
251
{
 
252
        SDL_Rect box;                   // Rect de copie de la "boite de dialogue"
 
253
        SDL_Surface *noire;
 
254
        
 
255
        // Rect de la boite de dialogue du message
 
256
        box.w = police.rect.w * (strlen (ch) + 3);
 
257
        box.h = police.rect.h * 3;
 
258
        box.x = (ecran->w - box.w) / 2;
 
259
        box.y = (ecran->h - box.h) / 2;
 
260
        
 
261
        // Cr�e une surface noire semi-transparente qui servira � assombrir une partie de l'�cran
 
262
        if (!(noire = SDL_CreateRGBSurface (SDL_SWSURFACE, box.w, box.h, 32, 0, 0, 0, 0)))
 
263
        {       fprintf (stderr, "Impossible de cr�er une surface (%s)\n", SDL_GetError ());
 
264
                SDL_FreeSurface (noire);
 
265
                exit (1);
 
266
        }
 
267
        SDL_FillRect (noire, NULL, SDL_MapRGB (noire->format, 0, 0, 0));
 
268
        SDL_SetAlpha (noire, SDL_SRCALPHA, 128);
 
269
        
 
270
        // Assombrit l'�cran et met � jour
 
271
        SDL_BlitSurface (noire, NULL, ecran, &box);
 
272
        SDL_UpdateRects (ecran, 1, &box);
 
273
        SDL_FreeSurface (noire);
 
274
        
 
275
        // Affiche le texte de la question et les textes des boutons OUI et NON
 
276
        Afficher_Chaine ((ecran->w - strlen (ch) * police.rect.w) / 2, (ecran->h - police.rect.h) / 2, 0, ch, police, ecran, ecran);
 
277
}
 
 
b'\\ No newline at end of file'