Fix some strings, and add fr translations
[neverball] / share / state.c
1 /*   
2  * Copyright (C) 2003 Robert Kooima
3  *
4  * NEVERBALL is  free software; you can redistribute  it and/or modify
5  * it under the  terms of the GNU General  Public License as published
6  * by the Free  Software Foundation; either version 2  of the License,
7  * or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT  ANY  WARRANTY;  without   even  the  implied  warranty  of
11  * MERCHANTABILITY or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU
12  * General Public License for more details.
13  */
14
15 #include "glext.h"
16 #include "state.h"
17 #include "config.h"
18
19 /*---------------------------------------------------------------------------*/
20
21 static float  state_time;
22 static struct state *state;
23
24 float time_state(void)
25 {
26     return state_time;
27 }
28
29 void init_state(struct state *st)
30 {
31     state = st;
32 }
33
34 int goto_state(struct state *st)
35 {
36     if (state && state->leave)
37         state->leave(state->gui_id);
38
39     state      = st;
40     state_time =  0;
41
42     if (state && state->enter)
43         state->gui_id = state->enter();
44
45     return 1;
46 }
47
48 /*---------------------------------------------------------------------------*/
49
50 void st_paint(void)
51 {
52     int stereo  = config_get_d(CONFIG_STEREO);
53
54     if (state && state->paint)
55     {
56         if (stereo)
57         {
58             glDrawBuffer(GL_BACK_LEFT);
59             config_clear();
60             state->paint(state->gui_id, (float) (+stereo));
61
62             glDrawBuffer(GL_BACK_RIGHT);
63             config_clear();
64             state->paint(state->gui_id, (float) (-stereo));
65         }
66         else
67         {
68             config_clear();
69             state->paint(state->gui_id, 0.0f);
70         }
71     }
72 }
73
74 void st_timer(float dt)
75 {
76     state_time += dt;
77
78     if (state && state->timer)
79         state->timer(state->gui_id, dt);
80 }
81
82 void st_point(int x, int y, int dx, int dy)
83 {
84     if (state && state->point)
85         state->point(state->gui_id, x, y, dx, dy);
86 }
87
88 void st_stick(int a, int k)
89 {
90     if (state && state->stick)
91         state->stick(state->gui_id, a, k);
92 }
93
94 /*---------------------------------------------------------------------------*/
95
96 int st_click(int b, int d)
97 {
98     return (state && state->click) ? state->click(b, d) : 1;
99 }
100
101 int st_keybd(int c, int d)
102 {
103     return (state && state->keybd) ? state->keybd(c, d) : 1;
104 }
105
106 int st_buttn(int b, int d)
107 {
108     return (state && state->buttn) ? state->buttn(b, d) : 1;
109 }
110
111 /*---------------------------------------------------------------------------*/