forked from aburch/simutrans
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsimgraph.h
211 lines (154 loc) · 7.52 KB
/
simgraph.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/*
* Copyright (c) 2001 Hansjörg Malthaner
*
* This file is part of the Simugraph engine and may not be used
* in other projects without written permission of the author.
*/
/*
* Versuch einer Graphic fuer Simulationsspiele
* Hj. Malthaner, Aug. 1997
*
*
* 3D, isometrische Darstellung
*/
#ifndef simgraph_h
#define simgraph_h
#ifdef __cplusplus
extern "C" {
// since our simgraph16.c ist a plain c-file, it will never see this
extern int large_font_height;
#endif
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
#include "simcolor.h"
#define LINESPACE 11
// size of koordinates
typedef short KOORD_VAL;
struct clip_dimension {
int x, xx, w, y, yy, h;
};
// helper macros
// save the current clipping and set a new one
#define PUSH_CLIP(x,y,w,h) \
{\
const struct clip_dimension p_cr = display_gib_clip_wh(); \
display_setze_clip_wh(x, y, w, h);
// restore a saved clipping rect
#define POP_CLIP() \
display_setze_clip_wh(p_cr.x, p_cr.y, p_cr.w, p_cr.h); \
}
/* Do no access directly, use the get_tile_raster_width()
* macro instead.
* @author Hj. Malthaner
*/
#define get_tile_raster_width() (tile_raster_width)
extern int tile_raster_width;
/* changes the raster width after loading */
int display_set_base_raster_width(int new_raster);
int get_zoom_factor(void);
void set_zoom_factor(int rw);
/**
* Initialises the graphics module
* @author Hj. Malthaner
*/
int simgraph_init(KOORD_VAL width, KOORD_VAL height, int use_shm, int do_sync, int fullscreen);
int is_display_init(void);
int simgraph_exit(void);
void simgraph_resize(KOORD_VAL w, KOORD_VAL h);
/*
* uncomment to enable unicode
*/
#define UNICODE_SUPPORT
int display_set_unicode(int use_unicode);
/* Loads the fonts (large=true loads large font)
* @author prissi
*/
bool display_load_font(const char *fname, bool large );
/* checks if a small and a large font exists;
* if not the missing font will be emulated
* @author prissi
*/
void display_check_fonts(void);
void register_image(struct bild_t*);
// delete all images above a certain number ...
void display_free_all_images_above( unsigned above );
void display_set_image_offset( unsigned bild, int xoff, int yoff );
void display_get_image_offset( unsigned bild, int *xoff, int *yoff, int *xw, int *yw );
void display_mark_img_dirty( unsigned bild, int x, int y );
int gib_maus_x(void);
int gib_maus_y(void);
void mark_rect_dirty_wc(KOORD_VAL x1, KOORD_VAL y1, KOORD_VAL x2, KOORD_VAL y2);
KOORD_VAL display_get_width(void);
KOORD_VAL display_get_height(void);
KOORD_VAL display_set_height(KOORD_VAL);
int display_get_light(void);
void display_set_light(int new_light_level);
void display_day_night_shift(int night);
// scrolls horizontally, will ignore clipping etc.
void display_scroll_band( const KOORD_VAL start_y, const KOORD_VAL x_offset, const KOORD_VAL h );
// set first and second company color for player
void display_set_player_color_scheme(const int player, const COLOR_VAL col1, const COLOR_VAL col2 );
// display image with day and night change
void display_img_aux(const unsigned n, const KOORD_VAL xp, KOORD_VAL yp, const int dirty, bool player);
#define display_img( n, x, y, d ) display_img_aux( (n), (x), (y), (d), 0 )
/**
* draws the images with alpha, either blended or as outline
* @author kierongreen
*/
void display_img_blend(const unsigned n, const KOORD_VAL xp, KOORD_VAL yp, const PLAYER_COLOR_VAL color, const int daynight, const int dirty);
// display image with color (if there) and optinal day and nightchange
void display_color_img(const unsigned n, const KOORD_VAL xp, const KOORD_VAL yp, const signed char color, const int daynight, const int dirty);
void display_fillbox_wh(KOORD_VAL xp, KOORD_VAL yp, KOORD_VAL w, KOORD_VAL h, PLAYER_COLOR_VAL color, int dirty);
void display_fillbox_wh_clip(KOORD_VAL xp, KOORD_VAL yp, KOORD_VAL w, KOORD_VAL h, PLAYER_COLOR_VAL color, int d);
void display_vline_wh(const KOORD_VAL xp, KOORD_VAL yp, KOORD_VAL h, const PLAYER_COLOR_VAL color, int dirty);
void display_vline_wh_clip(const KOORD_VAL xp, KOORD_VAL yp, KOORD_VAL h, const PLAYER_COLOR_VAL c, int d);
void display_clear(void);
void display_flush_buffer(void);
void display_move_pointer(KOORD_VAL dx, KOORD_VAL dy);
void display_show_pointer(int yesno);
void display_set_pointer(int pointer);
void display_show_load_pointer(int loading);
void display_array_wh(KOORD_VAL xp, KOORD_VAL yp, KOORD_VAL w, KOORD_VAL h, const COLOR_VAL *arr);
// compound painting routines
void display_ddd_box(KOORD_VAL x1, KOORD_VAL y1, KOORD_VAL w, KOORD_VAL h, PLAYER_COLOR_VAL tl_color, PLAYER_COLOR_VAL rd_color);
void display_ddd_box_clip(KOORD_VAL x1, KOORD_VAL y1, KOORD_VAL w, KOORD_VAL h, PLAYER_COLOR_VAL tl_color, PLAYER_COLOR_VAL rd_color);
#define ALIGN_LEFT 0
#define ALIGN_MIDDLE 1
#define ALIGN_RIGHT 2
// unicode save moving in strings
int get_next_char(const char* text, int pos);
int get_prev_char(const char* text, int pos);
/* routines for string len (macros for compatibility with old calls) */
#define small_proportional_string_width(text) display_calc_proportional_string_len_width( text, 0x7FFF, false )
#define proportional_string_width(text) display_calc_proportional_string_len_width( text, 0x7FFF, true )
#define proportional_string_len_width(text,len) display_calc_proportional_string_len_width( text, len, true )
// length of a string in pixel
int display_calc_proportional_string_len_width(const char *text, int len,bool use_large_font );
/*
* len parameter added - use -1 for previous behaviour.
* completely renovated for unicode and 10 bit width and variable height
* @author Volker Meyer, prissi
* @date 15.06.2003, 2.1.2005
*/
int display_text_proportional_len_clip(KOORD_VAL x, KOORD_VAL y, const char *txt, int align, const PLAYER_COLOR_VAL color_index, int dirty, bool use_large_font, int len, bool use_clipping );
/* macro are for compatibility */
#define display_small_proportional( x, y, txt, align, color, dirty) display_text_proportional_len_clip(x, y, txt, align, color, dirty, false, -1, false )
#define display_small_proportional_clip( x, y, txt, align, color, dirty) display_text_proportional_len_clip(x, y, txt, align, color, dirty, false, -1, true )
#define display_small_proportional_len_clip( x, y, txt, len, align, color, dirty) display_text_proportional_len_clip(x, y, txt, align, color, dirty, false, len, true )
#define display_proportional( x, y, txt, align, color, dirty) display_text_proportional_len_clip(x, y, txt, align, color, dirty, true, -1, false )
#define display_proportional_clip( x, y, txt, align, color, dirty) display_text_proportional_len_clip(x, y, txt, align, color, dirty, true, -1, true )
#define display_proportional_len_clip( x, y, txt, len, align, color, dirty) display_text_proportional_len_clip(x, y, txt, align, color, dirty, true, len, true )
void display_ddd_proportional(KOORD_VAL xpos, KOORD_VAL ypos, KOORD_VAL width, KOORD_VAL hgt,PLAYER_COLOR_VAL ddd_farbe, PLAYER_COLOR_VAL text_farbe,const char *text, int dirty);
void display_ddd_proportional_clip(KOORD_VAL xpos, KOORD_VAL ypos, KOORD_VAL width, KOORD_VAL hgt,PLAYER_COLOR_VAL ddd_farbe, PLAYER_COLOR_VAL text_farbe, const char *text, int dirty);
void display_multiline_text(KOORD_VAL x, KOORD_VAL y, const char *inbuf, PLAYER_COLOR_VAL color);
void display_direct_line(const KOORD_VAL x, const KOORD_VAL y, const KOORD_VAL xx, const KOORD_VAL yy, const PLAYER_COLOR_VAL color);
int count_char(const char *str, const char c);
void display_setze_clip_wh(KOORD_VAL x, KOORD_VAL y, KOORD_VAL w, KOORD_VAL h);
struct clip_dimension display_gib_clip_wh(void);
void display_snapshot(void);
#ifdef __cplusplus
}
#endif
#endif