chiark / gitweb /
Merge branch 'ijackson' into stable-3.x
[ypp-sc-tools.db-live.git] / yarrg / convert.h
1 /*
2  * general header file for yarrg
3  */
4 /*
5  *  This is part of ypp-sc-tools, a set of third-party tools for assisting
6  *  players of Yohoho Puzzle Pirates.
7  * 
8  *  Copyright (C) 2009 Ian Jackson <ijackson@chiark.greenend.org.uk>
9  * 
10  *  This program is free software: you can redistribute it and/or modify
11  *  it under the terms of the GNU General Public License as published by
12  *  the Free Software Foundation, either version 3 of the License, or
13  *  (at your option) any later version.
14  * 
15  *  This program is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *  GNU General Public License for more details.
19  * 
20  *  You should have received a copy of the GNU General Public License
21  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  * 
23  *  Yohoho and Puzzle Pirates are probably trademarks of Three Rings and
24  *  are used without permission.  This program is not endorsed or
25  *  sponsored by Three Rings.
26  */
27
28 #ifndef CONVERT_H
29 #define CONVERT_H
30
31 #include "common.h"
32 #include "ocr.h"
33
34 #include <pam.h>
35 #include <time.h>
36 #include <limits.h>
37
38 #include <sys/time.h>
39
40
41 /*----- from rgbimage.c -----*/
42
43 #define MAXIMGIDENT 100
44
45 typedef uint32_t Rgb; /* red<<0 | green<<8 | blue<<16 */
46
47 typedef struct RgbImage {
48   int w, h;
49   Rgb data[]; /* data[ y*w + x ] */
50 } RgbImage;
51
52 void identify_rgbimage(const RgbImage *base, Rect portion,
53                        char result[MAXIMGIDENT], const char *what);
54 RgbImage *alloc_rgb_image(int w, int h);
55 void fwrite_ppmraw(FILE *f, const RgbImage *ri);
56
57 #define RI_PIXEL32(ri,x,y) ((ri)->data + ((y)*(ri)->w + (x)))
58
59 static inline Rgb ri_rgb(const RgbImage *ri, int x, int y) {
60   return *RI_PIXEL32(ri,x,y);
61 }
62
63 /*----- from structure.c -----*/
64
65 typedef struct PageStruct PageStruct;
66
67 void find_structure(const CanonImage *im,
68                     PageStruct **pagestruct_r, /* caller must free() */
69                     int *max_relevant_y_r,
70                     Point *commod_focus_point_r,
71                     Point *commod_page_point_r,
72                     Point *commod_focuslast_point_r);
73 void store_current_page(CanonImage *ci /*pointer saved*/,
74                         PageStruct *pagestruct, /*freed*/
75                         RgbImage *rgb /*freed*/);
76 void adjust_colours(CanonImage *ci, const RgbImage *rgb);
77
78 void select_page(int page);
79 void check_pager_motion(int first, int stop);
80
81 Rect find_sunshine_widget(void);
82
83 void canon_colour_prepare(void);
84 void find_islandname(void);
85 void check_correct_commodities(void);
86 void read_screenshots(void);
87 void read_one_screenshot(void);
88 void analyse(FILE *tsv_output);
89
90 /*----- from convert.c -----*/
91
92 extern FILE *screenshot_file;
93 void fetch_with_rsync(const char *stem);
94 void fetch_with_rsync_gz(const char *stem);
95
96 void vwarning(const char *fmt, va_list) FMT(1,0);
97 void warning(const char *fmt, ...)      FMT(1,2);
98
99 void vprogress(const char *fmt, va_list) FMT(1,0);
100 void progress(const char *fmt, ...)      FMT(1,2);
101
102 void vprogress_log(const char *fmt, va_list) FMT(1,0);
103 void progress_log(const char *fmt, ...)      FMT(1,2);
104
105 void vprogress_spinner(const char *fmt, va_list) FMT(1,0);
106 void progress_spinner(const char *fmt, ...)      FMT(1,2);
107
108 enum flags {
109   ff_singlepage=          000002,
110   ff_testservers=         000004,
111
112   ff_charset_edit=        000010,
113   ff_charset_allowedit=   000020,
114   ff_charset_havelocal=   000040,
115   ffm_charset=            000070,
116   
117   ff_dict_fetch=          000100,
118   ff_dict_submit=         000200,
119   ff_dict_pirate=         000400,
120   ffs_dict=               000700,
121
122   ff_needisland=          001000,
123   ff_printisland=         002000,
124   ff_upload=              004000,
125   
126   ff_use_yarrg=           010000,
127   ff_use_pctb=            020000,
128   ffm_use=                070000,
129   
130   ffs_printisland=        003000,
131   ffs_upload=             005000,
132 };
133 extern enum flags o_flags;
134
135 enum mode {
136   mf_findwindow=      00001,
137   mf_screenshot=      00010,
138   mf_readscreenshot=  00020,
139   mf_analyse=         00100,
140   mfm_special=        07000,
141   
142   mode_findwindow=    00001,
143   mode_screenshot=    00011,
144   mode_analyse=       00120,
145   mode_showcharset=   01000,
146
147   mode_all=           00111,
148 };
149 extern enum mode o_mode;
150
151 extern const char *o_ocean, *o_pirate;
152 extern int o_quiet;
153
154 /*----- from pages.c -----*/
155
156 void screenshot_startup(void);
157 void set_yppclient_window(unsigned long wul);
158 void find_yppclient_window(void);
159 void take_screenshots(void);
160 void take_one_screenshot(void);
161
162 #define MAX_PAGES 1000
163
164 extern const CanonImage *page_images[MAX_PAGES];
165 extern const RgbImage *page0_rgbimage;
166 extern int npages;
167
168 extern const char *ocean, *pirate;
169 extern char *archipelago, *island;
170
171
172 #endif /*CONVERT_H*/