From c9c0fb8b56b8413a85160a4f48b740957fd10e6f Mon Sep 17 00:00:00 2001 From: Nemh Date: Sun, 31 May 2015 14:17:43 +0200 Subject: [PATCH] Progress of the configuration menu, and some enhancements --- Eigen.g1w | 2 +- Taumath.cpp | 2 +- config.c | 55 ++++++++++++++++++++++------------------------------ config.h | 2 +- console.c | 6 +++--- draw.cpp | 2 +- print.cpp | 10 +++++++--- prototypes.h | 2 +- 8 files changed, 38 insertions(+), 43 deletions(-) diff --git a/Eigen.g1w b/Eigen.g1w index fbad940..682f79f 100644 --- a/Eigen.g1w +++ b/Eigen.g1w @@ -161,8 +161,8 @@ SourceFile=:tex\disp.src SourceFile=:tex\libText.c SourceFile=:tex\math.c SourceFile=:print.cpp -SourceFile=:draw.cpp SourceFile=:config.c +SourceFile=:coeff.cpp HeaderFile=:defs.h HeaderFile=:prototypes.h HeaderFile=:setjmp.h diff --git a/Taumath.cpp b/Taumath.cpp index d854ccd..94e932f 100644 --- a/Taumath.cpp +++ b/Taumath.cpp @@ -66,7 +66,7 @@ int AddIn_main(int isAppli, unsigned short OptionNum) unsigned char *expr; char fkey = NULL; - fkey = *(get_tex_flag_address()); + //fkey = *(get_tex_flag_address()); initialize_tuamath(); // initialize failed ? diff --git a/config.c b/config.c index 3f03293..aaf1fb6 100644 --- a/config.c +++ b/config.c @@ -1,14 +1,6 @@ #include #include -#ifdef __cplusplus -extern "C"{ -#endif -#include "defs.h" -#ifdef __cplusplus -} -#endif - #include "config.h" #include "console.h" @@ -17,21 +9,15 @@ extern "C"{ #define menu_free_item(item) if(item) free(item->str) -// Draws a menu in a popup-style window. -#ifdef __cplusplus -extern "C"{ -#endif -extern char* get_tex_flag_address(); -#ifdef __cplusplus -} -#endif +extern int* get_tex_flag_address(); + int test; void draw_menu(Menu* menu) { int x, y, i, key; int longest = 0, tmp; - int border = 1, margin = 2, check_box_width = 10, item_height = 7, letter_width = 4; + int border = 1, margin = 2, check_box_width = 15, item_height = 7, letter_width = 4;// inter_line = 1; int cursor_y = 0; DISPBOX box; @@ -44,7 +30,7 @@ void draw_menu(Menu* menu) box.left = (WIDTH/2) - (longest/2) - margin - border; box.right = box.left + longest + 2*margin + 2*border; - box.bottom = (HEIGHT/2) + (menu->items_number * item_height)/2 + margin + border; + box.bottom = (HEIGHT/2) + (menu->items_number * item_height)/2 /*+ margin*/ + border; box.top = HEIGHT - box.bottom; Bdisp_AreaClr_VRAM(&box); @@ -58,16 +44,16 @@ void draw_menu(Menu* menu) PrintMini(box.left + border + margin, box.top + margin + item_height*i, (unsigned char*)menu->items[i]->str, MINI_OVER); if(menu->items[i]->type == CHECK_BOX) { if((menu->items[i]->action.value)) { - if(*(menu->items[i]->action.value)) PrintMini(box.right - border - margin - check_box_width , box.top + margin + item_height*i, (unsigned char*)"[v]", MINI_OVER); - else PrintMini(box.right - border - margin - check_box_width , box.top + margin + item_height*i, (unsigned char*)"[x]", MINI_OVER); + if(*(menu->items[i]->action.value)) PrintMini(box.right - border - margin - (check_box_width/2) , box.top + margin + item_height*i, (unsigned char*)"[x]", MINI_OVER); + else PrintMini(box.right - border - margin - (check_box_width/2) , box.top + margin + item_height*i, (unsigned char*)"[ ]", MINI_OVER); } } } PrintMini(box.left + border + margin, box.top + margin + item_height*cursor_y, (unsigned char*)menu->items[cursor_y]->str, MINI_REV); if(menu->items[cursor_y]->type == CHECK_BOX) { if((menu->items[cursor_y]->action.value)) { - if(*(menu->items[cursor_y]->action.value)) PrintMini(box.right - border - margin - check_box_width , box.top + margin + item_height*cursor_y, (unsigned char*)"[v]", MINI_OVER); - else PrintMini(box.right - border - margin - check_box_width , box.top + margin + item_height*cursor_y, (unsigned char*)"[x]", MINI_OVER); + if(*(menu->items[cursor_y]->action.value)) PrintMini(box.right - border - margin - (check_box_width/2) , box.top + margin + item_height*cursor_y, (unsigned char*)"[x]", MINI_OVER); + else PrintMini(box.right - border - margin - (check_box_width/2) , box.top + margin + item_height*cursor_y, (unsigned char*)"[ ]", MINI_OVER); } } GetKey(&key); @@ -86,39 +72,44 @@ void draw_menu(Menu* menu) else if(menu->items[cursor_y]->type == FUNCTION_CALL) { if(menu->items[cursor_y]->action.function != NULL) { (*(menu->items[cursor_y]->action.function))(); //Calling the function + break; } } } } - - GetKey(&key); } void menu_setup() { - int number = 3; + int number = 2; Menu menu; menu.items = malloc(sizeof(Menu_Item*) * number); - menu.items[0] = menu_create_item("Test string", CHECK_BOX, &test); - menu.items[1] = menu_create_item("Test -- waza(bi)", FUNCTION_CALL, menu_test); - menu.items[2] = menu_create_item("Tex flag", CHECK_BOX, get_tex_flag_address()); - if(menu.items[0] && menu.items[1]&& menu.items[2]) menu.items_number = number; + menu.items[0] = menu_create_item("About", FUNCTION_CALL, menu_about); + menu.items[1] = menu_create_item("Tex flag", CHECK_BOX, get_tex_flag_address()); + if(menu.items[0] && menu.items[1]) menu.items_number = number; else { menu_free_item(menu.items[0]); menu_free_item(menu.items[1]); - menu_free_item(menu.items[2]); } draw_menu(&menu); + menu_free_item(menu.items[0]); + menu_free_item(menu.items[1]); free(menu.items); } -void menu_test() +void menu_about() { int key; - PopUpWin(4); + PopUpWin(5); + PrintMini(12, 6, (unsigned char*)"Eigenmath symbolic maths", MINI_OVER); + PrintMini(51, 13, (unsigned char*)"engine", MINI_OVER); + PrintMini(12, 20, (unsigned char*)"Ported by Mike.", MINI_OVER); + PrintMini(12, 27, (unsigned char*)"Enhanced by Nemh and the", MINI_OVER); + PrintMini(38, 34, (unsigned char*)"PC community.", MINI_OVER); + PrintMini(40, 41, (unsigned char*)"Early build", MINI_OVER); GetKey(&key); return; } diff --git a/config.h b/config.h index 9fdca22..779077f 100644 --- a/config.h +++ b/config.h @@ -27,7 +27,7 @@ typedef struct { void draw_menu(Menu* menu); void menu_setup(); -void menu_test(); +void menu_about(); Menu_Item* menu_create_item(const char* str, Menu_Item_Type type, void* other); #ifdef __cplusplus diff --git a/console.c b/console.c index 2b07b4e..1e49b9d 100644 --- a/console.c +++ b/console.c @@ -617,7 +617,7 @@ int Console_GetKey() return CONSOLE_SUCCEEDED; } - if (key == KEY_CTRL_INS) { + /*if (key == KEY_CTRL_INS) { if (!Line[Current_Line].readonly) { Edit_Line[0] = '\0'; Line[Current_Line].start_col = 0; @@ -626,7 +626,7 @@ int Console_GetKey() Cursor.x = 0; } return Console_Init(); - } + }*/ if (key == KEY_CTRL_SETUP) { menu_setup(); @@ -856,7 +856,7 @@ void Console_FMenu_Init() // Does the file exists ? // Todo : check the error codes... if(!cfg) { - unsigned char conf_standard[] = {"F1 alge\nabs(\ndet(\nadj(\nunit(\nF2 trig\ncosh(\narccosh(\nsinh(\narcsinh(\ntanh(\narctanh(\nF3 cplx\narg(\nconj(\nimag(\nmag(\npolar(\nreal(\nrect(\nF4 calc\nd(\neval(\nintegral(\ntaylor(\nsum(\nsimplify(\nF5 poly\ncoeff(\nquotient(\ndeg(\nexpand(\nfactor(\nroots(\nnroots(\nF6 misc\nf(\ny\nsimplify("}; + unsigned char conf_standard[] = {"F1 calc\nd(\nintegral(\ntaylor(\nsum(\nproduct(\nsimplify(\nfactor(\nF2 trig\ncosh(\narccosh(\nsinh(\narcsinh(\ntanh(\narctanh(\nF3 cplx\nmag(\narg(\nreal(\nimag(\nconj(\npolar(\nrect(\nF4 alge\nabs(\ndet(\nadj(\ncross(\ncurl(\ncontract(\nhilbert(\nF5 poly\nnroots(\ndeg(\ncoeff(\nquotient(\nhermite(\nlaguerre(\nlegendre(\nF6 arit\nmod(\ngcd(\nlcd(\nisprime(\nprime(\nfactor(\n"}; memory_createfile("\\\\fls0\\FMENU.cfg", strlen((char*)conf_standard)+1); handle = memory_openfile("\\\\fls0\\FMENU.cfg", _OPENMODE_READWRITE); memory_writefile(handle, conf_standard, strlen((char*)conf_standard)+1); diff --git a/draw.cpp b/draw.cpp index 20c59be..d24df1e 100644 --- a/draw.cpp +++ b/draw.cpp @@ -26,7 +26,7 @@ static double ymin, ymax; #define YMAX 1000 -typedef static struct { +typedef struct { int x, y; double t; } DRAWBUF; diff --git a/print.cpp b/print.cpp index a074234..ea43907 100644 --- a/print.cpp +++ b/print.cpp @@ -10,7 +10,9 @@ #define MAX_TEX_WIDTH 110 #define MAX_TEX_HEIGHT 50 -static char tex_flag = 0; +//char* get_tex_flag_address(); + +int tex_flag = 1; int out_index, out_length; char *out_str; @@ -18,10 +20,12 @@ static int char_count, last_char; char *power_str = "^"; -char* get_tex_flag_address() +extern "C"{ +int* get_tex_flag_address() { return &tex_flag; } +} void print(U *p) @@ -32,7 +36,7 @@ print(U *p) void printline(U *p) { - int old_tex_flag = *((int*)(get_tex_flag_address)); + int old_tex_flag = tex_flag; #ifdef TEX int width, height, baseline; char* edit_line = (char*)Console_GetEditLine(); diff --git a/prototypes.h b/prototypes.h index 93ceccc..611c6f4 100644 --- a/prototypes.h +++ b/prototypes.h @@ -748,7 +748,7 @@ void prime(void); // primetab.cpp // print.cpp -char* get_tex_flag_address(); +//char* get_tex_flag_address(); void print(U *p); void printline(U *p); void print_subexpr(U *p);