1 /***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
15 #include <fc_config.h>
19 #include "client_main.h"
20 #include "editgui_g.h"
23 #include "chatline_g.h"
24 #include "citydlg_g.h"
25 #include "connectdlg_g.h"
26 #include "dialogs_g.h"
27 #include "editgui_g.h"
28 #include "graphics_g.h"
29 #include "gui_main_g.h"
30 #include "mapview_g.h"
33 #include "gui_interface.h"
35 static struct gui_funcs funcs
;
37 /****************************************************************************
38 Return gui_funcs table. Used by gui side to get table for filling
39 with function addresses.
40 ****************************************************************************/
41 struct gui_funcs
*get_gui_funcs(void)
46 /**************************************************************************
48 **************************************************************************/
54 /**************************************************************************
56 **************************************************************************/
57 void ui_main(int argc
, char *argv
[])
59 funcs
.ui_main(argc
, argv
);
62 /**************************************************************************
64 **************************************************************************/
70 /**************************************************************************
71 Call version_message callback
72 **************************************************************************/
73 void version_message(const char *vertext
)
75 funcs
.version_message(vertext
);
78 /**************************************************************************
79 Call real_output_window_append callback
80 **************************************************************************/
81 void real_output_window_append(const char *astring
,
82 const struct text_tag_list
*tags
,
85 funcs
.real_output_window_append(astring
, tags
, conn_id
);
88 /**************************************************************************
89 Call get_gui_type callback
90 **************************************************************************/
91 enum gui_type
get_gui_type(void)
93 return funcs
.get_gui_type();
96 /**************************************************************************
97 Call insert_client_build_info callback
98 **************************************************************************/
99 void insert_client_build_info(char *outbuf
, size_t outlen
)
101 funcs
.insert_client_build_info(outbuf
, outlen
);
104 /**************************************************************************
105 Call adjust_default_options callback
106 **************************************************************************/
107 void adjust_default_options(void)
109 funcs
.adjust_default_options();
112 /**************************************************************************
113 Call is_view_supported callback
114 **************************************************************************/
115 bool is_view_supported(enum ts_type type
)
117 return funcs
.is_view_supported(type
);
120 /**************************************************************************
121 Call free_intro_radar_sprites callback
122 **************************************************************************/
123 void free_intro_radar_sprites(void)
125 funcs
.free_intro_radar_sprites();
128 /**************************************************************************
129 Call load_gfxfile callback
130 **************************************************************************/
131 struct sprite
*load_gfxfile(const char *filename
)
133 return funcs
.load_gfxfile(filename
);
136 /****************************************************************************
137 Call create_sprite callback
138 ****************************************************************************/
139 struct sprite
*create_sprite(int width
, int height
, struct color
*pcolor
)
141 return funcs
.create_sprite(width
, height
, pcolor
);
144 /**************************************************************************
145 Call get_sprite_dimensions callback
146 **************************************************************************/
147 void get_sprite_dimensions(struct sprite
*sprite
, int *width
, int *height
)
149 funcs
.get_sprite_dimensions(sprite
, width
, height
);
152 /**************************************************************************
153 Call crop_sprite callback
154 **************************************************************************/
155 struct sprite
*crop_sprite(struct sprite
*source
,
156 int x
, int y
, int width
, int height
,
158 int mask_offset_x
, int mask_offset_y
)
160 return funcs
.crop_sprite(source
, x
, y
, width
, height
, mask
,
161 mask_offset_x
, mask_offset_y
);
164 /**************************************************************************
165 Call free_sprite callback
166 **************************************************************************/
167 void free_sprite(struct sprite
*s
)
169 funcs
.free_sprite(s
);
172 /**************************************************************************
173 Call color_alloc callback
174 **************************************************************************/
175 struct color
*color_alloc(int r
, int g
, int b
)
177 return funcs
.color_alloc(r
, g
, b
);
180 /**************************************************************************
181 Call color_free callback
182 **************************************************************************/
183 void color_free(struct color
*pcolor
)
185 return funcs
.color_free(pcolor
);
188 /**************************************************************************
189 Call canvas_create callback
190 **************************************************************************/
191 struct canvas
*canvas_create(int width
, int height
)
193 return funcs
.canvas_create(width
, height
);
196 /**************************************************************************
197 Call canvas_free callback
198 **************************************************************************/
199 void canvas_free(struct canvas
*store
)
201 funcs
.canvas_free(store
);
204 /**************************************************************************
205 Call canvas_set_zoom callback
206 **************************************************************************/
207 void canvas_set_zoom(struct canvas
*store
, float zoom
)
209 funcs
.canvas_set_zoom(store
, zoom
);
212 /**************************************************************************
213 Call has_zoom_support callback
214 **************************************************************************/
215 bool has_zoom_support(void)
217 return funcs
.has_zoom_support();
220 /**************************************************************************
221 Call canvas_copy callback
222 **************************************************************************/
223 void canvas_copy(struct canvas
*dest
, struct canvas
*src
,
224 int src_x
, int src_y
, int dest_x
, int dest_y
, int width
,
227 funcs
.canvas_copy(dest
, src
, src_x
, src_y
, dest_x
, dest_y
, width
, height
);
230 /**************************************************************************
231 Call canvas_put_sprite callback
232 **************************************************************************/
233 void canvas_put_sprite(struct canvas
*pcanvas
,
234 int canvas_x
, int canvas_y
,
235 struct sprite
*psprite
,
236 int offset_x
, int offset_y
, int width
, int height
)
238 funcs
.canvas_put_sprite(pcanvas
, canvas_x
, canvas_y
, psprite
,
239 offset_x
, offset_y
, width
, height
);
242 /**************************************************************************
243 Call canvas_put_sprite_full callback
244 **************************************************************************/
245 void canvas_put_sprite_full(struct canvas
*pcanvas
,
246 int canvas_x
, int canvas_y
,
247 struct sprite
*psprite
)
249 funcs
.canvas_put_sprite_full(pcanvas
, canvas_x
, canvas_y
, psprite
);
252 /**************************************************************************
253 Call canvas_put_sprite_fogged callback
254 **************************************************************************/
255 void canvas_put_sprite_fogged(struct canvas
*pcanvas
,
256 int canvas_x
, int canvas_y
,
257 struct sprite
*psprite
,
258 bool fog
, int fog_x
, int fog_y
)
260 funcs
.canvas_put_sprite_fogged(pcanvas
, canvas_x
, canvas_y
,
261 psprite
, fog
, fog_x
, fog_y
);
264 /**************************************************************************
265 Call canvas_put_rectangle callback
266 **************************************************************************/
267 void canvas_put_rectangle(struct canvas
*pcanvas
,
268 struct color
*pcolor
,
269 int canvas_x
, int canvas_y
, int width
, int height
)
271 funcs
.canvas_put_rectangle(pcanvas
, pcolor
, canvas_x
, canvas_y
,
275 /**************************************************************************
276 Call canvas_fill_sprite_area callback
277 **************************************************************************/
278 void canvas_fill_sprite_area(struct canvas
*pcanvas
,
279 struct sprite
*psprite
, struct color
*pcolor
,
280 int canvas_x
, int canvas_y
)
282 funcs
.canvas_fill_sprite_area(pcanvas
, psprite
, pcolor
, canvas_x
, canvas_y
);
285 /**************************************************************************
286 Call canvas_put_line callback
287 **************************************************************************/
288 void canvas_put_line(struct canvas
*pcanvas
, struct color
*pcolor
,
289 enum line_type ltype
, int start_x
, int start_y
,
292 funcs
.canvas_put_line(pcanvas
, pcolor
, ltype
, start_x
, start_y
, dx
, dy
);
295 /**************************************************************************
296 Call canvas_put_curved_line callback
297 **************************************************************************/
298 void canvas_put_curved_line(struct canvas
*pcanvas
, struct color
*pcolor
,
299 enum line_type ltype
, int start_x
, int start_y
,
302 funcs
.canvas_put_curved_line(pcanvas
, pcolor
, ltype
, start_x
, start_y
,
306 /**************************************************************************
307 Call get_text_size callback
308 **************************************************************************/
309 void get_text_size(int *width
, int *height
,
310 enum client_font font
, const char *text
)
312 funcs
.get_text_size(width
, height
, font
, text
);
315 /**************************************************************************
316 Call canvas_put_text callback
317 **************************************************************************/
318 void canvas_put_text(struct canvas
*pcanvas
, int canvas_x
, int canvas_y
,
319 enum client_font font
, struct color
*pcolor
,
322 funcs
.canvas_put_text(pcanvas
, canvas_x
, canvas_y
, font
, pcolor
, text
);
325 /**************************************************************************
326 Call set_rulesets callback
327 **************************************************************************/
328 void set_rulesets(int num_rulesets
, char **rulesets
)
330 funcs
.set_rulesets(num_rulesets
, rulesets
);
333 /**************************************************************************
334 Call options_extra_init callback
335 **************************************************************************/
336 void options_extra_init(void)
338 funcs
.options_extra_init();
341 /**************************************************************************
342 Call server_connect callback
343 **************************************************************************/
344 void server_connect(void)
346 funcs
.server_connect();
349 /**************************************************************************
350 Call add_net_input callback
351 **************************************************************************/
352 void add_net_input(int sock
)
354 funcs
.add_net_input(sock
);
357 /**************************************************************************
358 Call remove_net_input callback
359 **************************************************************************/
360 void remove_net_input(void)
362 funcs
.remove_net_input();
365 /**************************************************************************
366 Call real_conn_list_dialog_update callback
367 **************************************************************************/
368 void real_conn_list_dialog_update(void)
370 funcs
.real_conn_list_dialog_update();
373 /**************************************************************************
374 Call close_connection_dialog callback
375 **************************************************************************/
376 void close_connection_dialog()
378 funcs
.close_connection_dialog();
381 /**************************************************************************
382 Call add_idle_callback callback
383 **************************************************************************/
384 void add_idle_callback(void (callback
)(void *), void *data
)
386 funcs
.add_idle_callback(callback
, data
);
389 /**************************************************************************
390 Call sound_bell callback
391 **************************************************************************/
392 void sound_bell(void)
397 /**************************************************************************
398 Call real_set_client_page callback
399 **************************************************************************/
400 void real_set_client_page(enum client_pages page
)
402 funcs
.real_set_client_page(page
);
405 /**************************************************************************
406 Call get_current_client_page callback
407 **************************************************************************/
408 enum client_pages
get_current_client_page(void)
410 return funcs
.get_current_client_page();
413 /**************************************************************************
414 Call set_unit_icon callback
415 **************************************************************************/
416 void set_unit_icon(int idx
, struct unit
*punit
)
418 funcs
.set_unit_icon(idx
, punit
);
421 /**************************************************************************
422 Call real_focus_units_changed callback
423 **************************************************************************/
424 void real_focus_units_changed(void)
426 funcs
.real_focus_units_changed();
429 /**************************************************************************
430 Call set_unit_icons_more_arrow callback
431 **************************************************************************/
432 void set_unit_icons_more_arrow(bool onoff
)
434 funcs
.set_unit_icons_more_arrow(onoff
);
437 /****************************************************************************
438 Call gui_update_font callback
439 ****************************************************************************/
440 void gui_update_font(const char *font_name
, const char *font_value
)
442 funcs
.gui_update_font(font_name
, font_value
);
445 /****************************************************************************
446 Call set_city_names_font_sizes callback
447 ****************************************************************************/
448 void set_city_names_font_sizes(int my_city_names_font_size
,
449 int my_city_productions_font_size
)
451 funcs
.set_city_names_font_sizes(my_city_names_font_size
,
452 my_city_productions_font_size
);
455 /****************************************************************************
456 Call editgui_refresh callback
457 ****************************************************************************/
458 void editgui_refresh(void)
460 funcs
.editgui_refresh();
463 /****************************************************************************
464 Call editgui_notify_object_created callback
465 ****************************************************************************/
466 void editgui_notify_object_created(int tag
, int id
)
468 funcs
.editgui_notify_object_created(tag
, id
);
471 /****************************************************************************
472 Call editgui_notify_object_changed callback
473 ****************************************************************************/
474 void editgui_notify_object_changed(int objtype
, int object_id
, bool removal
)
476 funcs
.editgui_notify_object_changed(objtype
, object_id
, removal
);
479 /****************************************************************************
480 Call editgui_popup_properties callback
481 ****************************************************************************/
482 void editgui_popup_properties(const struct tile_list
*tiles
, int objtype
)
484 funcs
.editgui_popup_properties(tiles
, objtype
);
487 /****************************************************************************
488 Call editgui_tileset_changed callback
489 ****************************************************************************/
490 void editgui_tileset_changed(void)
492 funcs
.editgui_tileset_changed();
495 /****************************************************************************
496 Call editgui_popdown_all callback
497 ****************************************************************************/
498 void editgui_popdown_all(void)
500 funcs
.editgui_popdown_all();
503 /****************************************************************************
504 Call update_timeout_label callback
505 ****************************************************************************/
506 void update_timeout_label(void)
508 funcs
.update_timeout_label();
511 /**************************************************************************
512 Call real_city_dialog_popup callback
513 **************************************************************************/
514 void real_city_dialog_popup(struct city
*pcity
)
516 funcs
.real_city_dialog_popup(pcity
);
519 /**************************************************************************
520 Call real_city_dialog_refresh callback
521 **************************************************************************/
522 void real_city_dialog_refresh(struct city
*pcity
)
524 funcs
.real_city_dialog_refresh(pcity
);
527 /**************************************************************************
528 Call popdown_city_dialog callback
529 **************************************************************************/
530 void popdown_city_dialog(struct city
*pcity
)
532 funcs
.popdown_city_dialog(pcity
);
535 /**************************************************************************
536 Call popdown_all_city_dialogs callback
537 **************************************************************************/
538 void popdown_all_city_dialogs()
540 funcs
.popdown_all_city_dialogs();
543 /**************************************************************************
544 Call handmade_scenario_warning callback
545 **************************************************************************/
546 bool handmade_scenario_warning()
548 return funcs
.handmade_scenario_warning();
551 /**************************************************************************
552 Call refresh_unit_city_dialogs callback
553 **************************************************************************/
554 void refresh_unit_city_dialogs(struct unit
*punit
)
556 funcs
.refresh_unit_city_dialogs(punit
);
559 /**************************************************************************
560 Call city_dialog_is_open callback
561 **************************************************************************/
562 bool city_dialog_is_open(struct city
*pcity
)
564 return funcs
.city_dialog_is_open(pcity
);
567 /**************************************************************************
568 Call request_transport callback
569 **************************************************************************/
570 bool request_transport(struct unit
*pcargo
, struct tile
*ptile
)
572 return funcs
.request_transport(pcargo
, ptile
);
575 /**************************************************************************
576 Call gui_load_theme callback
577 **************************************************************************/
578 void gui_load_theme(const char *directory
, const char *theme_name
)
580 funcs
.gui_load_theme(directory
, theme_name
);
583 /**************************************************************************
584 Call gui_clear_theme callback
585 **************************************************************************/
586 void gui_clear_theme(void)
588 funcs
.gui_clear_theme();
591 /**************************************************************************
592 Call get_gui_specific_themes_directories callback
593 **************************************************************************/
594 char **get_gui_specific_themes_directories(int *count
)
596 return funcs
.get_gui_specific_themes_directories(count
);
599 /**************************************************************************
600 Call get_useable_themes_in_directory callback
601 **************************************************************************/
602 char **get_useable_themes_in_directory(const char *directory
, int *count
)
604 return funcs
.get_useable_themes_in_directory(directory
, count
);