Changeset 113
- Timestamp:
- 04/14/07 20:03:52 (6 years ago)
- Location:
- branches/grand
- Files:
-
- 38 added
- 8 edited
-
core/conf.c (modified) (1 diff)
-
core/gui.c (modified) (5 diffs)
-
core/gui_draw.h (modified) (1 diff)
-
core/gui_read.c (modified) (5 diffs)
-
fonts (added)
-
fonts/Arial14.rbf (added)
-
fonts/Arial14b.rbf (added)
-
fonts/Arial16.rbf (added)
-
fonts/Arial16b.rbf (added)
-
fonts/Arial18.rbf (added)
-
fonts/Arial18b.rbf (added)
-
fonts/Arial20.rbf (added)
-
fonts/Arial20b.rbf (added)
-
fonts/Lucida14.rbf (added)
-
fonts/Lucida16.rbf (added)
-
fonts/Lucida18.rbf (added)
-
fonts/Lucida20.rbf (added)
-
fonts/Tahoma14.rbf (added)
-
fonts/Tahoma14b.rbf (added)
-
fonts/Tahoma16.rbf (added)
-
fonts/Tahoma16b.rbf (added)
-
fonts/Tahoma18.rbf (added)
-
fonts/Tahoma18b.rbf (added)
-
fonts/Tahoma20.rbf (added)
-
fonts/Tahoma20b.rbf (added)
-
fonts/Times14.rbf (added)
-
fonts/Times14b.rbf (added)
-
fonts/Times16.rbf (added)
-
fonts/Times16b.rbf (added)
-
fonts/Times18.rbf (added)
-
fonts/Times18b.rbf (added)
-
fonts/Times20.rbf (added)
-
fonts/Times20b.rbf (added)
-
fonts/Verdana14.rbf (added)
-
fonts/Verdana14b.rbf (added)
-
fonts/Verdana16.rbf (added)
-
fonts/Verdana16b.rbf (added)
-
fonts/Verdana18.rbf (added)
-
fonts/Verdana18b.rbf (added)
-
fonts/Verdana20.rbf (added)
-
fonts/Verdana20b.rbf (added)
-
include/conf.h (modified) (1 diff)
-
include/font.h (modified) (2 diffs)
-
include/gui.h (modified) (1 diff)
-
lib/font/Makefile (modified) (1 diff)
-
lib/font/rbf_font.c (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/grand/core/conf.c
r110 r113 102 102 CONF_INFO( 43, conf.reader_autoscroll, CONF_DEF_VALUE, i:0, NULL), 103 103 CONF_INFO( 44, conf.reader_autoscroll_delay, CONF_DEF_VALUE, i:5, NULL), 104 CONF_INFO( 45, conf.reader_rbf_file, CONF_DEF_PTR, ptr:"", NULL), 104 105 }; 105 106 #define CONF_NUM (sizeof(conf_info)/sizeof(conf_info[0])) -
branches/grand/core/gui.c
r110 r113 46 46 static void gui_draw_read(int arg); 47 47 static void gui_draw_read_last(int arg); 48 static void gui_draw_load_rbf(int arg); 48 49 static void gui_draw_calendar(int arg); 49 50 static void gui_menuproc_mkbootdisk(int arg); … … 99 100 {"Enable autoscroll", MENUITEM_BOOL, &conf.reader_autoscroll }, 100 101 {"Autoscroll delay (sec)", MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.reader_autoscroll_delay, MENU_MINMAX(0, 60) }, 102 {"Select RBF font", MENUITEM_PROC, (int*)gui_draw_load_rbf }, 101 103 {"<- Back", MENUITEM_UP }, 102 104 {0} … … 835 837 836 838 // if exists "A/SCRIPTS" go into 837 d=opendir( "A/SCRIPTS");839 d=opendir(path); 838 840 if (d) { 839 841 closedir(d); … … 854 856 static void gui_draw_read_selected(const char *fn) { 855 857 if (fn) { 858 if (!rbf_load(conf.reader_rbf_file)) 859 rbf_load_from_8x16(current_font); 856 860 gui_mode = GUI_MODE_READ; 857 861 gui_read_init(fn); … … 887 891 888 892 //------------------------------------------------------------------- 893 static void gui_draw_rbf_selected(const char *fn) { 894 if (fn) { 895 strcpy(conf.reader_rbf_file, fn); 896 } 897 } 898 void gui_draw_load_rbf(int arg) { 899 DIR *d; 900 char *path="A/FONTS"; 901 902 // if exists "A/FONTS" go into 903 d=opendir(path); 904 if (d) { 905 closedir(d); 906 } else { 907 path="A"; 908 } 909 910 gui_fselect_init(path, gui_draw_rbf_selected); 911 } 912 913 //------------------------------------------------------------------- -
branches/grand/core/gui_draw.h
r66 r113 29 29 void draw_init(); 30 30 31 extern void draw_pixel(coord x, coord y, color cl);32 31 extern color draw_get_pixel(coord x, coord y); 33 32 -
branches/grand/core/gui_read.c
r110 r113 5 5 #include "conf.h" 6 6 #include "gui.h" 7 #include "font.h" 7 8 #include "gui_draw.h" 8 9 #include "gui_read.h" … … 14 15 static int read_on_screen; 15 16 static int read_to_draw; 16 static coord x, y, h, w , s;17 #define READ_BUFFER_SIZE (45*15)18 static char buffer[READ_BUFFER_SIZE+ 45];17 static coord x, y, h, w; 18 #define READ_BUFFER_SIZE 100 19 static char buffer[READ_BUFFER_SIZE+1]; 19 20 static long last_time; 21 static int xx, yy; 20 22 21 23 //------------------------------------------------------------------- … … 33 35 } 34 36 read_to_draw = 1; 35 x=0; 36 y=1; 37 w=(screen_width-(x+1)*FONT_WIDTH)/FONT_WIDTH; 38 h=(screen_height-y*FONT_HEIGHT)/FONT_HEIGHT; 39 s=w*h; 37 x=6; 38 y=FONT_HEIGHT; 39 w=screen_width-6-6-8; 40 h=screen_height-y; 40 41 last_time = get_tick_count(); 41 42 43 draw_filled_rect(0, y, screen_width-1, screen_height-1, MAKE_COLOR((conf.reader_color>>8)&0xFF, (conf.reader_color>>8)&0xFF)); 44 42 45 return (read_file >= 0); 43 46 } 44 47 48 //------------------------------------------------------------------- 49 static void read_goto_next_line() { 50 draw_filled_rect(xx, yy, x+w-1, yy+rbf_font_height()-1, MAKE_COLOR(conf.reader_color>>8, conf.reader_color>>8)); 51 xx = x; 52 yy += rbf_font_height(); 53 } 54 55 //------------------------------------------------------------------- 56 static int read_fit_next_char(int ch) { 57 return (xx+rbf_char_width(ch) < x+w); 58 } 45 59 //------------------------------------------------------------------- 46 60 void gui_read_draw() { … … 50 64 } 51 65 if (read_to_draw) { 52 int i, j;66 int n, i; 53 67 54 if (read_to_draw) { 55 lseek(read_file, conf.reader_pos, SEEK_SET); 56 i=read(read_file, buffer, s); 57 buffer[i]=0; 68 xx=x; yy=y; 58 69 59 j=0; i=1; 60 for (read_on_screen=0; read_on_screen<s && j<h; ++read_on_screen) { 61 if (buffer[read_on_screen]) { 62 switch (buffer[read_on_screen]) { 63 case '\r': 64 break; 65 case '\n': 66 for (; i<w-1; ++i) { 67 draw_txt_char(x+i, y+j, ' ', conf.reader_color); //fill the rest 68 } 69 break; 70 case '\t': 71 draw_txt_string(x+i, y+j, " ", conf.reader_color); //text 72 i+=4; 73 break; 74 default: 75 draw_txt_char(x+i, y+j, buffer[read_on_screen], conf.reader_color); //text 76 ++i; 77 break; 70 lseek(read_file, conf.reader_pos, SEEK_SET); 71 read_on_screen=0; 78 72 79 } 80 if (i>=w-1) { 81 ++j; 82 i=1; 83 } 84 } else { 85 for (; j<h; ++j) { 86 for (; i<w-1; ++i) { 87 draw_txt_char(x+i, y+j, ' ', conf.reader_color); //fill the rest 73 while (yy<=y+h-rbf_font_height()) { 74 n=read(read_file, buffer, READ_BUFFER_SIZE); 75 if (n==0) { 76 read_goto_next_line(); 77 if (yy < y+h) 78 draw_filled_rect(x, yy, x+w-1, y+h-1, MAKE_COLOR(conf.reader_color>>8, conf.reader_color>>8)); 79 break; 80 } 81 i=0; 82 while (i<n && yy<=y+h-rbf_font_height()) { 83 switch (buffer[i]) { 84 case '\r': 85 break; 86 case '\n': 87 read_goto_next_line(); 88 break; 89 case '\t': 90 buffer[i] = ' '; 91 continue; 92 default: 93 if (!read_fit_next_char(buffer[i])) { 94 read_goto_next_line(); 95 continue; 88 96 } 89 i=1; 90 } 97 xx+=rbf_draw_char(xx, yy, buffer[i], conf.reader_color); 98 break; 99 } 100 ++i; 101 if (xx >= x+w) { 102 xx = x; 103 yy += rbf_font_height(); 91 104 } 92 105 } 93 94 sprintf(buffer, "(%3d%%) %d/%d%45s", (read_file_size)?(conf.reader_pos*100/read_file_size):0, conf.reader_pos, read_file_size, ""); 95 buffer[screen_width/FONT_WIDTH]=0; 96 draw_txt_string(0, 0, buffer, MAKE_COLOR(COLOR_BLACK, COLOR_WHITE)); //title infoline 106 read_on_screen+=i; 107 } 108 109 sprintf(buffer, "(%3d%%) %d/%d%45s", (read_file_size)?(conf.reader_pos*100/read_file_size):0, conf.reader_pos, read_file_size, ""); 110 buffer[screen_width/FONT_WIDTH]=0; 111 draw_txt_string(0, 0, buffer, MAKE_COLOR(COLOR_BLACK, COLOR_WHITE)); //title infoline 97 112 98 draw_filled_rect(0, y*FONT_HEIGHT, 99 FONT_WIDTH-1, (y+h)*FONT_HEIGHT, MAKE_COLOR((conf.reader_color>>8)&0xFF, (conf.reader_color>>8)&0xFF)); 100 // scrollbar 101 draw_filled_rect((x+w-1)*FONT_WIDTH, y*FONT_HEIGHT, 102 (x+w)*FONT_WIDTH+8, (y+h)*FONT_HEIGHT, MAKE_COLOR((conf.reader_color>>8)&0xFF, (conf.reader_color>>8)&0xFF)); 103 if (read_file_size) { 104 i=h*FONT_HEIGHT-1 -1; // full height 105 j=i*s/read_file_size; // bar height 106 if (j<20) j=20; 107 i=(i-j)*conf.reader_pos/read_file_size; // top pos 108 draw_filled_rect((x+w)*FONT_WIDTH+2, y*FONT_HEIGHT+1, 109 (x+w)*FONT_WIDTH+6, y*FONT_HEIGHT+1+i, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK)); 110 draw_filled_rect((x+w)*FONT_WIDTH+2, y*FONT_HEIGHT+i+j, 111 (x+w)*FONT_WIDTH+6, (y+h)*FONT_HEIGHT-1-1, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK)); 112 draw_filled_rect((x+w)*FONT_WIDTH+2, y*FONT_HEIGHT+1+i, 113 (x+w)*FONT_WIDTH+6, y*FONT_HEIGHT+i+j, MAKE_COLOR(COLOR_WHITE, COLOR_WHITE)); 114 } else { 115 draw_filled_rect((x+w)*FONT_WIDTH+2, y*FONT_HEIGHT+1, 116 (x+w)*FONT_WIDTH+6, (y+h)*FONT_HEIGHT-1-1, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK)); 117 } 113 // scrollbar 114 if (read_file_size) { 115 i=h-1 -1; // full height 116 n=i*read_on_screen/read_file_size; // bar height 117 if (n<20) n=20; 118 i=(i-n)*conf.reader_pos/read_file_size; // top pos 119 draw_filled_rect(x+w+6+2, y+1, x+w+6+6, y+1+i, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK)); 120 draw_filled_rect(x+w+6+2, y+i+n, x+w+6+6, y+h-1-1, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK)); 121 draw_filled_rect(x+w+6+2, y+1+i, x+w+6+6, y+i+n, MAKE_COLOR(COLOR_WHITE, COLOR_WHITE)); 122 } else { 123 draw_filled_rect((x+w)*FONT_WIDTH+2, y*FONT_HEIGHT+1, 124 (x+w)*FONT_WIDTH+6, (y+h)*FONT_HEIGHT-1-1, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK)); 125 } 118 126 119 read_to_draw = 0; 120 last_time = get_tick_count(); 121 } 127 read_to_draw = 0; 128 last_time = get_tick_count(); 122 129 } 123 130 } … … 129 136 case KEY_UP: 130 137 if (conf.reader_pos>0) { 131 conf.reader_pos -= s-w;138 conf.reader_pos -= 45*15; 132 139 if (conf.reader_pos<0) conf.reader_pos=0; 133 140 read_to_draw = 1; -
branches/grand/include/conf.h
r110 r113 59 59 int reader_autoscroll; 60 60 int reader_autoscroll_delay; 61 char reader_rbf_file[100]; 61 62 62 63 int sokoban_level; -
branches/grand/include/font.h
r91 r113 1 1 #ifndef FONT_H 2 2 #define FONT_H 3 4 #include "gui.h" 5 3 6 //------------------------------------------------------------------- 4 5 7 #define FONT_DEFAULT 0 6 8 #define FONT_UNIRUS 1 … … 14 16 extern void font_set(int font); 15 17 18 extern int rbf_load(char *file); 19 extern void rbf_load_from_8x16(const char *font); 20 extern int rbf_font_height(); 21 extern int rbf_char_width(int ch); 22 extern int rbf_draw_char(int x, int y, int ch, color cl); 23 16 24 //------------------------------------------------------------------- 17 25 #endif -
branches/grand/include/gui.h
r108 r113 23 23 extern void gui_force_restore(); 24 24 25 extern void draw_pixel(coord x, coord y, color cl); 26 25 27 extern enum Gui_Mode gui_get_mode(); 26 28 extern void gui_set_mode(enum Gui_Mode mode); -
branches/grand/lib/font/Makefile
r91 r113 3 3 include $(topdir)makefile.inc 4 4 5 OBJS = font_8x16.o 5 OBJS = font_8x16.o rbf_font.o 6 6 7 7 all: libfont.a
Note: See TracChangeset
for help on using the changeset viewer.