25 #include "textlines.h"
31 #include "texture_handler.h"
37 extern enablerst enabler
;
40 init_displayst::init_displayst()
42 flag
.set_size_on_flag_num(INIT_DISPLAY_FLAGNUM
);
43 windowed
=INIT_DISPLAY_WINDOW_PROMPT
;
45 partial_print_count
=0;
50 static bool called
= false;
54 string small_font
="data/art/curses_640x300.png";
55 string large_font
="data/art/curses_640x300.png";
56 std::ifstream
fseed("data/init/init.txt");
61 while(std::getline(fseed
,str
))
68 grab_token_string_pos(token
,str
,1);
69 if(str
.length()>=token
.length()+2)
71 grab_token_string_pos(token2
,str
,token
.length()+2);
73 if(!token
.compare("TRUETYPE")) {
74 const char *str
= token2
.c_str();
76 int limit
= strtol(str
, &endptr
, 10);
79 font
.use_ttf
= ttf_auto
;
80 font
.ttf_limit
= limit
;
81 } else if (token2
== "YES") {
82 font
.use_ttf
= ttf_on
;
84 font
.use_ttf
= ttf_off
;
88 if(!token
.compare("FONT"))
90 small_font
="data/art/";
93 if(!token
.compare("FULLFONT"))
95 large_font
="data/art/";
98 if(!token
.compare("WINDOWEDX"))
100 display
.desired_windowed_width
=convert_string_to_long(token2
);
102 if(!token
.compare("WINDOWEDY"))
104 display
.desired_windowed_height
=convert_string_to_long(token2
);
106 if(!token
.compare("RESIZABLE")) {
108 display
.flag
.add_flag(INIT_DISPLAY_FLAG_NOT_RESIZABLE
);
110 if(!token
.compare("FULLSCREENX"))
112 display
.desired_fullscreen_width
=convert_string_to_long(token2
);
114 if(!token
.compare("FULLSCREENY"))
116 display
.desired_fullscreen_height
=convert_string_to_long(token2
);
119 if(token
=="PRINT_MODE")
121 if(token2
=="PARTIAL")
123 display
.flag
.add_flag(INIT_DISPLAY_FLAG_PARTIAL_PRINT
);
126 if(str
.length()>=token
.length()+token2
.length()+3)
128 grab_token_string_pos(token3
,str
,token
.length()+token2
.length()+3);
130 long l
=convert_string_to_long(token3
);
133 display
.partial_print_count
=(char)l
;
137 int answer
= MessageBox(NULL
, "Using only 2D (Click no) is more reliable, but means you lose features and, often, speed. Edit data/init/init.txt PRINT_MODE to avoid this dialog box.", "Use OpenGL?", MB_YESNO
);
145 display
.flag
.add_flag(INIT_DISPLAY_FLAG_TEXT
);
146 display
.flag
.add_flag(INIT_DISPLAY_FLAG_PARTIAL_PRINT
);
147 display
.partial_print_count
=0;
149 MessageBox(NULL
, "Text mode not supported on your platform, using 2D", 0, 0);
153 if(token2
=="FRAME_BUFFER")
155 display
.flag
.add_flag(INIT_DISPLAY_FLAG_FRAME_BUFFER
);
156 display
.flag
.add_flag(INIT_DISPLAY_FLAG_PARTIAL_PRINT
);
157 display
.partial_print_count
=0;
159 if(token2
=="ACCUM_BUFFER")
161 display
.flag
.add_flag(INIT_DISPLAY_FLAG_ACCUM_BUFFER
);
162 display
.flag
.add_flag(INIT_DISPLAY_FLAG_PARTIAL_PRINT
);
163 display
.partial_print_count
=0;
167 display
.flag
.add_flag(INIT_DISPLAY_FLAG_VBO
);
168 // display.flag.add_flag(INIT_DISPLAY_FLAG_PARTIAL_PRINT);
169 display
.partial_print_count
=0;
173 display
.flag
.add_flag(INIT_DISPLAY_FLAG_2D
);
174 display
.flag
.add_flag(INIT_DISPLAY_FLAG_PARTIAL_PRINT
);
175 display
.partial_print_count
=0;
177 if(token2
=="2D" || token2
=="2DHW")
179 display
.flag
.add_flag(INIT_DISPLAY_FLAG_2D
);
180 display
.flag
.add_flag(INIT_DISPLAY_FLAG_2DHW
);
181 display
.flag
.add_flag(INIT_DISPLAY_FLAG_PARTIAL_PRINT
);
182 display
.partial_print_count
=0;
184 if(token2
=="2DASYNC")
186 display
.flag
.add_flag(INIT_DISPLAY_FLAG_2D
);
187 display
.flag
.add_flag(INIT_DISPLAY_FLAG_2DHW
);
188 display
.flag
.add_flag(INIT_DISPLAY_FLAG_2DASYNC
);
189 display
.flag
.add_flag(INIT_DISPLAY_FLAG_PARTIAL_PRINT
);
190 display
.partial_print_count
=0;
194 display
.flag
.add_flag(INIT_DISPLAY_FLAG_SHADER
);
198 if(token
=="SINGLE_BUFFER")
202 display
.flag
.add_flag(INIT_DISPLAY_FLAG_SINGLE_BUFFER
);
206 if(display
.flag
.has_flag(INIT_DISPLAY_FLAG_USE_GRAPHICS
))
208 if(!token
.compare("GRAPHICS_FONT"))
210 small_font
="data/art/";
213 if(!token
.compare("GRAPHICS_FULLFONT"))
215 large_font
="data/art/";
218 if(!token
.compare("GRAPHICS_WINDOWEDX"))
220 display
.desired_windowed_width
=convert_string_to_long(token2
);
222 if(!token
.compare("GRAPHICS_WINDOWEDY"))
224 display
.desired_windowed_height
=convert_string_to_long(token2
);
226 if(!token
.compare("GRAPHICS_FULLSCREENX"))
228 display
.desired_fullscreen_width
=convert_string_to_long(token2
);
230 if(!token
.compare("GRAPHICS_FULLSCREENY"))
232 display
.desired_fullscreen_height
=convert_string_to_long(token2
);
234 if(!token
.compare("GRAPHICS_BLACK_SPACE"))
238 display
.flag
.add_flag(INIT_DISPLAY_FLAG_BLACK_SPACE
);
240 else display
.flag
.remove_flag(INIT_DISPLAY_FLAG_BLACK_SPACE
);
244 if(!token
.compare("GRAPHICS"))
248 display
.flag
.add_flag(INIT_DISPLAY_FLAG_USE_GRAPHICS
);
252 if(!token
.compare("BLACK_SPACE"))
256 display
.flag
.add_flag(INIT_DISPLAY_FLAG_BLACK_SPACE
);
260 if(token
=="ZOOM_SPEED")
262 input
.zoom_speed
= convert_string_to_long(token2
);
268 input
.flag
.add_flag(INIT_INPUT_FLAG_MOUSE_OFF
);
275 window
.flag
.add_flag(INIT_WINDOW_FLAG_VSYNC_ON
);
279 window
.flag
.add_flag(INIT_WINDOW_FLAG_VSYNC_OFF
);
282 if(token
=="ARB_SYNC") {
284 display
.flag
.add_flag(INIT_DISPLAY_FLAG_ARB_SYNC
);
288 if(token
=="PRIORITY")
290 if(token2
=="REALTIME")
292 SetPriorityClass(GetCurrentProcess(),REALTIME_PRIORITY_CLASS
);
296 SetPriorityClass(GetCurrentProcess(),HIGH_PRIORITY_CLASS
);
298 if(token2
=="ABOVE_NORMAL")
300 SetPriorityClass(GetCurrentProcess(),ABOVE_NORMAL_PRIORITY_CLASS
);
304 SetPriorityClass(GetCurrentProcess(),NORMAL_PRIORITY_CLASS
);
306 if(token2
=="BELOW_NORMAL")
308 SetPriorityClass(GetCurrentProcess(),BELOW_NORMAL_PRIORITY_CLASS
);
312 SetPriorityClass(GetCurrentProcess(),IDLE_PRIORITY_CLASS
);
317 if(token
=="TEXTURE_PARAM")
321 window
.flag
.add_flag(INIT_WINDOW_FLAG_TEXTURE_LINEAR
);
328 window
.flag
.add_flag(INIT_WINDOW_FLAG_TOPMOST
);
335 gps
.display_frames
=1;
338 if(token
=="MOUSE_PICTURE")
342 input
.flag
.add_flag(INIT_INPUT_FLAG_MOUSE_PICTURE
);
345 if(!token
.compare("FPS_CAP"))
347 enabler
.set_fps(convert_string_to_long(token2
));
349 if(!token
.compare("G_FPS_CAP"))
351 enabler
.set_gfps(convert_string_to_long(token2
));
353 if(token
=="WINDOWED")
357 display
.windowed
=INIT_DISPLAY_WINDOW_TRUE
;
361 display
.windowed
=INIT_DISPLAY_WINDOW_FALSE
;
365 display
.windowed
=INIT_DISPLAY_WINDOW_PROMPT
;
368 if(!token
.compare("SOUND"))
372 media
.flag
.add_flag(INIT_MEDIA_FLAG_SOUND_OFF
);
375 if(!token
.compare("INTRO"))
379 media
.flag
.add_flag(INIT_MEDIA_FLAG_INTRO_OFF
);
382 if(!token
.compare("VOLUME"))
384 media
.volume
=convert_string_to_long(token2
);
386 if(!token
.compare("KEY_HOLD_MS"))
388 input
.hold_time
=convert_string_to_long(token2
);
390 if(input
.hold_time
<100)input
.hold_time
=100;
392 if(token
=="KEY_REPEAT_MS")
394 input
.repeat_time
=convert_string_to_long(token2
);
396 if(input
.repeat_time
<100)input
.repeat_time
=100;
398 if(token
=="KEY_REPEAT_ACCEL_LIMIT") {
399 input
.repeat_accel_limit
= convert_string_to_long(token2
);
400 if (input
.repeat_accel_limit
< 1) input
.repeat_accel_limit
= 1;
402 if(token
=="KEY_REPEAT_ACCEL_START") {
403 input
.repeat_accel_start
= convert_string_to_long(token2
);
405 if(token
=="MACRO_MS")
407 input
.macro_time
=convert_string_to_long(token2
);
409 if(input
.macro_time
<1)input
.macro_time
=1;
411 if(token
=="RECENTER_INTERFACE_SHUTDOWN_MS")
413 input
.pause_zoom_no_interface_ms
=convert_string_to_long(token2
);
415 if(input
.pause_zoom_no_interface_ms
<0)input
.pause_zoom_no_interface_ms
=0;
417 if(token
=="COMPRESSED_SAVES")
421 media
.flag
.add_flag(INIT_MEDIA_FLAG_COMPRESS_SAVES
);
429 std::ifstream
fseed2("data/init/colors.txt");
434 while(std::getline(fseed2
,str
))
441 grab_token_string_pos(token
,str
,1);
442 if(str
.length()>=token
.length()+2)
444 grab_token_string_pos(token2
,str
,token
.length()+2);
447 if(!token
.compare("BLACK_R"))
449 enabler
.ccolor
[0][0]=(float)convert_string_to_long(token2
)/255.0f
;
451 if(!token
.compare("BLACK_G"))
453 enabler
.ccolor
[0][1]=(float)convert_string_to_long(token2
)/255.0f
;
455 if(!token
.compare("BLACK_B"))
457 enabler
.ccolor
[0][2]=(float)convert_string_to_long(token2
)/255.0f
;
459 if(!token
.compare("BLUE_R"))
461 enabler
.ccolor
[1][0]=(float)convert_string_to_long(token2
)/255.0f
;
463 if(!token
.compare("BLUE_G"))
465 enabler
.ccolor
[1][1]=(float)convert_string_to_long(token2
)/255.0f
;
467 if(!token
.compare("BLUE_B"))
469 enabler
.ccolor
[1][2]=(float)convert_string_to_long(token2
)/255.0f
;
471 if(!token
.compare("GREEN_R"))
473 enabler
.ccolor
[2][0]=(float)convert_string_to_long(token2
)/255.0f
;
475 if(!token
.compare("GREEN_G"))
477 enabler
.ccolor
[2][1]=(float)convert_string_to_long(token2
)/255.0f
;
479 if(!token
.compare("GREEN_B"))
481 enabler
.ccolor
[2][2]=(float)convert_string_to_long(token2
)/255.0f
;
483 if(!token
.compare("CYAN_R"))
485 enabler
.ccolor
[3][0]=(float)convert_string_to_long(token2
)/255.0f
;
487 if(!token
.compare("CYAN_G"))
489 enabler
.ccolor
[3][1]=(float)convert_string_to_long(token2
)/255.0f
;
491 if(!token
.compare("CYAN_B"))
493 enabler
.ccolor
[3][2]=(float)convert_string_to_long(token2
)/255.0f
;
495 if(!token
.compare("RED_R"))
497 enabler
.ccolor
[4][0]=(float)convert_string_to_long(token2
)/255.0f
;
499 if(!token
.compare("RED_G"))
501 enabler
.ccolor
[4][1]=(float)convert_string_to_long(token2
)/255.0f
;
503 if(!token
.compare("RED_B"))
505 enabler
.ccolor
[4][2]=(float)convert_string_to_long(token2
)/255.0f
;
507 if(!token
.compare("MAGENTA_R"))
509 enabler
.ccolor
[5][0]=(float)convert_string_to_long(token2
)/255.0f
;
511 if(!token
.compare("MAGENTA_G"))
513 enabler
.ccolor
[5][1]=(float)convert_string_to_long(token2
)/255.0f
;
515 if(!token
.compare("MAGENTA_B"))
517 enabler
.ccolor
[5][2]=(float)convert_string_to_long(token2
)/255.0f
;
519 if(!token
.compare("BROWN_R"))
521 enabler
.ccolor
[6][0]=(float)convert_string_to_long(token2
)/255.0f
;
523 if(!token
.compare("BROWN_G"))
525 enabler
.ccolor
[6][1]=(float)convert_string_to_long(token2
)/255.0f
;
527 if(!token
.compare("BROWN_B"))
529 enabler
.ccolor
[6][2]=(float)convert_string_to_long(token2
)/255.0f
;
531 if(!token
.compare("LGRAY_R"))
533 enabler
.ccolor
[7][0]=(float)convert_string_to_long(token2
)/255.0f
;
535 if(!token
.compare("LGRAY_G"))
537 enabler
.ccolor
[7][1]=(float)convert_string_to_long(token2
)/255.0f
;
539 if(!token
.compare("LGRAY_B"))
541 enabler
.ccolor
[7][2]=(float)convert_string_to_long(token2
)/255.0f
;
543 if(!token
.compare("DGRAY_R"))
545 enabler
.ccolor
[8][0]=(float)convert_string_to_long(token2
)/255.0f
;
547 if(!token
.compare("DGRAY_G"))
549 enabler
.ccolor
[8][1]=(float)convert_string_to_long(token2
)/255.0f
;
551 if(!token
.compare("DGRAY_B"))
553 enabler
.ccolor
[8][2]=(float)convert_string_to_long(token2
)/255.0f
;
555 if(!token
.compare("LBLUE_R"))
557 enabler
.ccolor
[9][0]=(float)convert_string_to_long(token2
)/255.0f
;
559 if(!token
.compare("LBLUE_G"))
561 enabler
.ccolor
[9][1]=(float)convert_string_to_long(token2
)/255.0f
;
563 if(!token
.compare("LBLUE_B"))
565 enabler
.ccolor
[9][2]=(float)convert_string_to_long(token2
)/255.0f
;
567 if(!token
.compare("LGREEN_R"))
569 enabler
.ccolor
[10][0]=(float)convert_string_to_long(token2
)/255.0f
;
571 if(!token
.compare("LGREEN_G"))
573 enabler
.ccolor
[10][1]=(float)convert_string_to_long(token2
)/255.0f
;
575 if(!token
.compare("LGREEN_B"))
577 enabler
.ccolor
[10][2]=(float)convert_string_to_long(token2
)/255.0f
;
579 if(!token
.compare("LCYAN_R"))
581 enabler
.ccolor
[11][0]=(float)convert_string_to_long(token2
)/255.0f
;
583 if(!token
.compare("LCYAN_G"))
585 enabler
.ccolor
[11][1]=(float)convert_string_to_long(token2
)/255.0f
;
587 if(!token
.compare("LCYAN_B"))
589 enabler
.ccolor
[11][2]=(float)convert_string_to_long(token2
)/255.0f
;
591 if(!token
.compare("LRED_R"))
593 enabler
.ccolor
[12][0]=(float)convert_string_to_long(token2
)/255.0f
;
595 if(!token
.compare("LRED_G"))
597 enabler
.ccolor
[12][1]=(float)convert_string_to_long(token2
)/255.0f
;
599 if(!token
.compare("LRED_B"))
601 enabler
.ccolor
[12][2]=(float)convert_string_to_long(token2
)/255.0f
;
603 if(!token
.compare("LMAGENTA_R"))
605 enabler
.ccolor
[13][0]=(float)convert_string_to_long(token2
)/255.0f
;
607 if(!token
.compare("LMAGENTA_G"))
609 enabler
.ccolor
[13][1]=(float)convert_string_to_long(token2
)/255.0f
;
611 if(!token
.compare("LMAGENTA_B"))
613 enabler
.ccolor
[13][2]=(float)convert_string_to_long(token2
)/255.0f
;
615 if(!token
.compare("YELLOW_R"))
617 enabler
.ccolor
[14][0]=(float)convert_string_to_long(token2
)/255.0f
;
619 if(!token
.compare("YELLOW_G"))
621 enabler
.ccolor
[14][1]=(float)convert_string_to_long(token2
)/255.0f
;
623 if(!token
.compare("YELLOW_B"))
625 enabler
.ccolor
[14][2]=(float)convert_string_to_long(token2
)/255.0f
;
627 if(!token
.compare("WHITE_R"))
629 enabler
.ccolor
[15][0]=(float)convert_string_to_long(token2
)/255.0f
;
631 if(!token
.compare("WHITE_G"))
633 enabler
.ccolor
[15][1]=(float)convert_string_to_long(token2
)/255.0f
;
635 if(!token
.compare("WHITE_B"))
637 enabler
.ccolor
[15][2]=(float)convert_string_to_long(token2
)/255.0f
;
645 enabler
.window
.isFullScreen
= FALSE
;
648 //FULL SCREEN QUERY, UNLESS IT'S ALREADY SET IN INIT
650 if (!display
.flag
.has_flag(INIT_DISPLAY_FLAG_TEXT
)) {
651 if(enabler
.command_line
.empty())
653 if(display
.windowed
==INIT_DISPLAY_WINDOW_TRUE
)
655 enabler
.fullscreen
= false;
657 else if(display
.windowed
==INIT_DISPLAY_WINDOW_FALSE
)
659 enabler
.fullscreen
= true;
663 if (MessageBox (NULL
, "Run in Fullscreen Mode? You can set your preferences in data\\init\\init.txt.\rUnless you've changed your bindings, you can press F11 to toggle this setting any time.", "Start FullScreen?", MB_YESNO
| MB_ICONQUESTION
) == IDNO
) {
664 enabler
.fullscreen
= false; // If Not, Run In Windowed Mode
666 enabler
.fullscreen
= true;
670 else enabler
.fullscreen
= false;
675 enabler
.textures
.load_multi_pdim(small_font
,font
.small_font_texpos
,16,16,true,&font
.small_font_dispx
,&font
.small_font_dispy
);
676 enabler
.textures
.load_multi_pdim(large_font
,font
.large_font_texpos
,16,16,true,&font
.large_font_dispx
,&font
.large_font_dispy
);
678 // compute the desired window size, if set to auto
679 if (display
.desired_windowed_width
< MAX_GRID_X
&& display
.desired_windowed_height
< MAX_GRID_Y
) {
680 int dimx
= MAX(display
.desired_windowed_width
,80);
681 int dimy
= MAX(display
.desired_windowed_height
,25);
682 display
.desired_windowed_width
= font
.small_font_dispx
* dimx
;
683 display
.desired_windowed_height
= font
.small_font_dispy
* dimy
;