3 xuni, a 2D game written with the SDL with its own unique GUI library \n
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.
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.
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 The GNU General Public License version 2 is included in the file COPYING.
23 dwks@theprogrammingsite.com \n
24 http://dwks.theprogrammingsite.com \n
28 At the time of this writing, xuni can be obtained from:
29 http://dwks.theprogrammingsite.com/myprogs/down/xuni.zip
33 xuni stands for "Explore the Universe". It's entirely coincidental that
34 shifting one of the letters in "xuni" spells UNIX, and that reversing the
35 letters and adding another letter spells Linux. "xuni" is pronounced
36 "zoo-nee" in the author's opinion. But "ecks-you-nee" or
37 "ecks-you-en-eye" or other variations work as well.
39 xuni was written from the ground up without incorporating any code from my
40 numerous previous SDL projects. It uses SDL_image, SDL_gfx, and SDL_ttf
41 (my first project to do so) in addition to the SDL.
63 static const char *get_ctime(void);
64 static void log_printf(const char *format
, ...);
65 static void print_message(const char *type
, const char *message
,
66 const char *file
, int line
);
70 int STDCALL
WinMain(HINSTANCE hInst
, HINSTANCE hPrev
, LPSTR lpCmd
, int nShow
) {
72 int main(int argc
, char *argv
[]) {
79 load_settings(&smode
, &font
, &theme
, &gui
);
83 reload_fonts(&font
, &smode
);
86 resize_theme(&theme
, &smode
, &font
);
88 main_loop(&smode
, &font
, &theme
, &gui
);
90 write_settings(&smode
, &font
, &theme
, &gui
);
99 char *duplicate_string(const char *str
, size_t len
) {
100 char *p
= malloc(len
+ 1);
105 static const char *get_ctime(void) {
111 /*! Calls vfprintf() for stderr and the file LOG_FILE with the same data.
112 @param format Format string, including optional format specifiers
113 @param ... Variables matching format specifiers
115 static void log_printf(const char *format
, ...) {
116 FILE *log
= fopen(LOG_FILE
, "at");
119 va_start(arg
, format
);
120 vfprintf(stderr
, format
, arg
);
124 va_start(arg
, format
);
125 vfprintf(log
, format
, arg
);
132 static void print_message(const char *type
, const char *message
,
133 const char *file
, int line
) {
135 const char *sdlerror
= SDL_GetError(), *t
= get_ctime();
137 log_printf("xuni: %s from %s:%i at %s %s\n SDL: %s\n",
138 type
, file
, line
, t
, message
, sdlerror
);
141 void print_warning(const char *message
, const char *file
, int line
) {
142 print_message("Warning", message
, file
, line
);
145 void settings_error(const char *message
, const char *sfile
, int sline
) {
146 const char *t
= get_ctime();
148 log_printf("xuni: Error in settings file %s:%i at %s %s\n",
149 sfile
, sline
, t
, message
);
152 void fatal_error(const char *message
, const char *file
, int line
) {
153 print_message("Fatal error", message
, file
, line
);