~ubuntu-branches/ubuntu/trusty/gcompris/trusty

« back to all changes in this revision

Viewing changes to src/gcompris/board.c

  • Committer: Bazaar Package Importer
  • Author(s): Yann Dirson
  • Date: 2002-04-21 16:16:27 UTC
  • Revision ID: james.westby@ubuntu.com-20020421161627-s07yahahm817qxs6
Tags: upstream-1.0.3
ImportĀ upstreamĀ versionĀ 1.0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  GCompris -- This files comes from XMMS
 
2
 * 
 
3
 *  XMMS - Cross-platform multimedia player
 
4
 *  Copyright (C) 1998-2000  Peter Alm, Mikael Alm, Olle Hallnas, Thomas Nilsson and 4Front Technologies
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; either version 2 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  This program is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with this program; if not, write to the Free Software
 
18
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
19
 */
 
20
#include "gcompris.h"
 
21
 
 
22
struct BoardPluginData *bp_data;
 
23
 
 
24
 
 
25
BoardPlugin *get_current_board_plugin(void)
 
26
{
 
27
  return bp_data->current_board_plugin;
 
28
}
 
29
 
 
30
void set_current_board_plugin(BoardPlugin * bp)
 
31
{
 
32
  bp_data->current_board_plugin = bp;
 
33
}
 
34
 
 
35
GcomprisBoard *get_current_gcompris_board(void)
 
36
{
 
37
  return bp_data->current_gcompris_board;
 
38
}
 
39
 
 
40
void set_current_gcompris_board(GcomprisBoard * gcomprisBoard)
 
41
{
 
42
  bp_data->current_gcompris_board = gcomprisBoard;
 
43
}
 
44
 
 
45
GList *get_board_list(void)
 
46
{
 
47
  return bp_data->board_list;
 
48
}
 
49
        
 
50
gboolean board_check_file(GcomprisBoard *gcomprisBoard)
 
51
{
 
52
  GList *node;
 
53
  BoardPlugin *bp;
 
54
 
 
55
  node = get_board_list();
 
56
  while (node)
 
57
    {
 
58
      bp = (BoardPlugin *) node->data;
 
59
      if (bp && bp->is_our_board(gcomprisBoard))
 
60
        {
 
61
          return TRUE;
 
62
        }
 
63
      node = node->next;
 
64
    }
 
65
  return FALSE;
 
66
}
 
67
 
 
68
void board_play(GcomprisBoard *gcomprisBoard)
 
69
{
 
70
  GList *node;
 
71
  BoardPlugin *bp;
 
72
 
 
73
  node = get_board_list();
 
74
  while (node)
 
75
    {
 
76
      bp = (BoardPlugin *) node->data;
 
77
      if (bp && bp->is_our_board(gcomprisBoard))
 
78
        {
 
79
          set_current_board_plugin(bp);
 
80
          set_current_gcompris_board(gcomprisBoard);
 
81
          bp->start_board(gcomprisBoard);
 
82
          bp_data->playing = TRUE;
 
83
          return;
 
84
 
 
85
        }
 
86
      node = node->next;
 
87
    }
 
88
  /* We set the playing flag even if no boardplugin
 
89
     recognizes the board. This way we are sure it will be skipped. */
 
90
  bp_data->playing = TRUE;
 
91
  set_current_board_plugin(NULL);
 
92
}
 
93
 
 
94
void board_pause(void)
 
95
{
 
96
  if (get_board_playing() && get_current_board_plugin())
 
97
    {
 
98
      bp_data->paused = !bp_data->paused;
 
99
      get_current_board_plugin()->pause_board(bp_data->paused);
 
100
    }
 
101
}
 
102
 
 
103
void board_stop(void)
 
104
{
 
105
  if (bp_data->playing && get_current_board_plugin())
 
106
    {
 
107
      bp_data->playing = FALSE;
 
108
 
 
109
      if (bp_data->paused)
 
110
        board_pause();
 
111
      if (get_current_board_plugin()->end_board)
 
112
        get_current_board_plugin()->end_board();
 
113
      
 
114
      bp_data->paused = FALSE;
 
115
      gcompris_end_board();
 
116
      return;
 
117
    }
 
118
  bp_data->playing = FALSE;
 
119
}
 
120
 
 
121
gboolean get_board_playing(void)
 
122
{
 
123
  return bp_data->playing;
 
124
}
 
125
 
 
126
gboolean get_board_paused(void)
 
127
{
 
128
  return bp_data->paused;
 
129
}
 
130
 
 
131
void board_about(gint index)
 
132
{
 
133
  BoardPlugin *bp;
 
134
 
 
135
  bp = g_list_nth(bp_data->board_list, index)->data;
 
136
  if (bp && bp->about)
 
137
    bp->about();
 
138
}
 
139
 
 
140
void board_configure(gint index)
 
141
{
 
142
  BoardPlugin *bp;
 
143
 
 
144
  bp = g_list_nth(bp_data->board_list, index)->data;
 
145
  if (bp && bp->configure)
 
146
    bp->configure();
 
147
}
 
148
 
 
149
 
 
150
/* Local Variables: */
 
151
/* mode:c */
 
152
/* eval:(load-library "time-stamp") */
 
153
/* eval:(make-local-variable 'write-file-hooks) */
 
154
/* eval:(add-hook 'write-file-hooks 'time-stamp) */
 
155
/* eval:(setq time-stamp-format '(time-stamp-yyyy/mm/dd time-stamp-hh:mm:ss user-login-name)) */
 
156
/* End: */
 
157
 
 
158
 
 
159
 
 
160