diff --git a/factory.c b/factory.c index 213ab606..17a95fce 100644 --- a/factory.c +++ b/factory.c @@ -45,6 +45,13 @@ #include #include +/// +/// Number of characters for name in fileselector. +/// Window is adjusted according to it. +#define NAME_WIDTH 34 +/// Position of fileselector top, in window space +#define FILESEL_Y 18 + // Work data that can be used during a script static byte * Brush_backup = NULL; static word Brush_backup_width; @@ -287,13 +294,92 @@ void Draw_script_name(word x, word y, word index, byte highlighted) if (Scripts_list.Nb_elements) { + short name_size; + current_item = Get_item_by_index(&Scripts_list, index); - Print_in_window(x, y, current_item->Short_name, MC_Black, + + Print_in_window_limited(x, y, current_item->Full_name, NAME_WIDTH, MC_Black, (highlighted)?MC_Dark:MC_Light); + name_size=strlen(current_item->Full_name); + // Clear remaining area on the right + if (name_sizeFull_name && script_item->Full_name[0]!='\0') + { + strcpy(full_name, Data_directory); + strcat(full_name, "scripts/"); + strcat(full_name, script_item->Full_name); + + + x=0; + y=0; + text_block[0][0] = text_block[1][0] = text_block[2][0] = '\0'; + // Start reading + script_file = fopen(full_name, "r"); + if (script_file != NULL) + { + int c; + c = fgetc(script_file); + while (c != EOF && y<3) + { + if (c == '\n') + { + if (x<2) + break; // Carriage return without comment: Stopping + y++; + x=0; + } + else if (x==0 || x==1) + { + if (c != '-') + break; // Non-comment line was encountered. Stopping. + x++; + } + else + { + if (x < NAME_WIDTH+4) + { + // Adding character + text_block[y][x-2] = (c<32 || c>255) ? ' ' : c; + text_block[y][x-1] = '\0'; + } + x++; + } + // Read next + c = fgetc(script_file); + } + fclose(script_file); + } + + Print_in_window(7, FILESEL_Y + 89 , text_block[0], MC_Light, MC_Black); + Print_in_window(7, FILESEL_Y + 89+ 8, text_block[1], MC_Light, MC_Black); + Print_in_window(7, FILESEL_Y + 89+16, text_block[2], MC_Light, MC_Black); + + } + Display_cursor(); + Update_window_area(7, FILESEL_Y + 89, (NAME_WIDTH+2)*8+2, 3*8); + +} + +// Add a script to the list void Add_script(const char *name) { Add_element_to_list(&Scripts_list, Find_last_slash(name)+1, 0); @@ -306,7 +392,7 @@ void Button_Brush_Factory(void) T_Scroller_button* scriptscroll; char scriptdir[MAX_PATH_CHARACTERS]; - Open_window(175, 162, "Brush Factory"); + Open_window(33+8*NAME_WIDTH, 162, "Brush Factory"); // Here we use the same data container as the fileselectors. // Reinitialize the list @@ -318,19 +404,24 @@ void Button_Brush_Factory(void) // Sort it Sort_list_of_files(&Scripts_list); - Window_set_normal_button(77, 141, 67, 14, "Cancel", 0, 1, KEY_ESC); // 1 + Window_set_normal_button(85, 141, 67, 14, "Cancel", 0, 1, KEY_ESC); // 1 Window_set_normal_button(10, 141, 67, 14, "Run", 0, 1, 0); // 2 - #define FILESEL_Y 18 - Window_display_frame_in(6, FILESEL_Y - 2, 148, 84); // File selector + Window_display_frame_in(6, FILESEL_Y - 2, NAME_WIDTH*8+4, 84); // File selector scriptlist = Window_set_list_button( // Fileselector - Window_set_special_button(8, FILESEL_Y + 1, 144, 80), // 3 + Window_set_special_button(8, FILESEL_Y + 1, NAME_WIDTH*8, 80), // 3 // Scroller for the fileselector - (scriptscroll = Window_set_scroller_button(154, FILESEL_Y - 1, 82, + (scriptscroll = Window_set_scroller_button(NAME_WIDTH*8+14, FILESEL_Y - 1, 82, Scripts_list.Nb_elements, 10, 0)), // 4 Draw_script_name); // 5 + + Window_display_frame_in(6, FILESEL_Y + 88, (NAME_WIDTH+2)*8+4, 3*8+2); // Descr. + Window_redraw_list(scriptlist); + Draw_script_information(Get_item_by_index(&Scripts_list, + scriptlist->List_start + scriptlist->Cursor_position)); + Update_window_area(0, 0, Window_width, Window_height); Display_cursor(); @@ -340,6 +431,12 @@ void Button_Brush_Factory(void) switch (clicked_button) { + case 5: + Draw_script_information(Get_item_by_index(&Scripts_list, + scriptlist->List_start + scriptlist->Cursor_position)); + break; + + default: break; } diff --git a/scripts/aafilter.lua b/scripts/aafilter.lua index 0a076320..224e1a28 100644 --- a/scripts/aafilter.lua +++ b/scripts/aafilter.lua @@ -1,3 +1,5 @@ +-- Apply a kind of AA filter on picture + -- Get the picture size w, h = getpicturesize(); diff --git a/scripts/dawnbringer1.lua b/scripts/dawnbringer1.lua index c011484f..a1307d02 100644 --- a/scripts/dawnbringer1.lua +++ b/scripts/dawnbringer1.lua @@ -1,4 +1,6 @@ --- Picture scene: Amigaball (by Richard Fhager, code adopted from Evalion) +-- Picture scene: Amigaball +-- by Richard Fhager, code adopted +-- from Evalion w = 256 h = 256 diff --git a/scripts/nitrofurano1.lua b/scripts/nitrofurano1.lua index 7a6c37c7..c25b73d1 100644 --- a/scripts/nitrofurano1.lua +++ b/scripts/nitrofurano1.lua @@ -1,4 +1,4 @@ --- x1palettetopicture.lua +-- x1 palette to picture w,h=getpicturesize(); for y1=0,7,1 do for x1=0,31,1 do diff --git a/scripts/nitrofurano2.lua b/scripts/nitrofurano2.lua index 96e3a067..c6fd10dd 100644 --- a/scripts/nitrofurano2.lua +++ b/scripts/nitrofurano2.lua @@ -1,4 +1,4 @@ --- x8palettetopicture.lua +-- x8 palette to picture setpicturesize(256,64); for y1=0,7,1 do for x1=0,31,1 do diff --git a/scripts/nitrofurano3.lua b/scripts/nitrofurano3.lua index 66028257..52c2965b 100644 --- a/scripts/nitrofurano3.lua +++ b/scripts/nitrofurano3.lua @@ -1,4 +1,4 @@ --- drawgrid8x8.lua +-- Draw 8x8 grid w,h=getpicturesize(); for y=0,h-1,1 do for x=0,w-1,8 do diff --git a/scripts/nitrofurano4.lua b/scripts/nitrofurano4.lua index 184230c0..a7e8828a 100644 --- a/scripts/nitrofurano4.lua +++ b/scripts/nitrofurano4.lua @@ -1,4 +1,4 @@ --- drawgrid8x8matchcolor.lua +-- Draw red 8x8 grid w,h=getpicturesize(); c=matchcolor(0xFF,0x00,0x00) for y=0,h-1,1 do diff --git a/scripts/nitrofurano5.lua b/scripts/nitrofurano5.lua index bcab8b81..edae4162 100644 --- a/scripts/nitrofurano5.lua +++ b/scripts/nitrofurano5.lua @@ -1,4 +1,4 @@ --- drawisometricgrid.lua +-- Draw isometric grid w,h=getpicturesize(); for y=0,h-1,8 do for x=0,w-1,1 do diff --git a/scripts/nitrofurano6.lua b/scripts/nitrofurano6.lua index 0d16eed2..b3b219e4 100644 --- a/scripts/nitrofurano6.lua +++ b/scripts/nitrofurano6.lua @@ -1,4 +1,5 @@ --- 12bitcolourspacefrompalette.lua +-- 12bit colour space from palette +-- w,h=getpicturesize(); for y1=0,3,1 do for x1=0,3,1 do diff --git a/scripts/nitrofurano7.lua b/scripts/nitrofurano7.lua index 3568e59a..29b768e1 100644 --- a/scripts/nitrofurano7.lua +++ b/scripts/nitrofurano7.lua @@ -1,4 +1,5 @@ --- 15bitcolourspacefrompalette.lua +-- 15bit colour space from palette +-- w,h=getpicturesize(); for y1=0,3,1 do for x1=0,7,1 do diff --git a/scripts/nitrofurano8.lua b/scripts/nitrofurano8.lua index bb782c19..f3933668 100644 --- a/scripts/nitrofurano8.lua +++ b/scripts/nitrofurano8.lua @@ -1,4 +1,5 @@ --- 18bitcolourspacefrompalette.lua +-- 18bit colour space from palette +-- w,h=getpicturesize(); for y1=0,7,1 do for x1=0,7,1 do diff --git a/scripts/nitrofurano9.lua b/scripts/nitrofurano9.lua index 6fcc1668..dbdf8456 100644 --- a/scripts/nitrofurano9.lua +++ b/scripts/nitrofurano9.lua @@ -1,3 +1,4 @@ +-- ? w,h=getpicturesize(); for y1=0,h-1,8 do for x1=0,w-1,8 do