Exemple #1
0
void show_equipment (wujiang & w)
{
	const char * 	name;
	int 			x=0,y=0,sel=0,i=0;
	uint			key = 0;
	pai				*zhuangbei = w.zhuangbei;

	Bdisp_AllClr_VRAM();	

	if(w.juese)
		name = "���";
	else
		name = "����";
		
	ChsPrint(x,y,sel,(PCUCHAR)name);ChsPrint(x+24,y,sel,(PCUCHAR)"��ǰװ��");y+=12;
	
	for(i=0;i<4;++i,y+=12)
	{
		x=0;
		ChsPrint(x,y,sel,(PCUCHAR)EQUIPMENT_TYPE[i]);x+=48;
		if(zhuangbei[0].leixing==-1)
			ChsPrint(x,y,sel,(PCUCHAR)"��");
		else
			ChsPrint(x,y,sel,(PCUCHAR)GetCardInfo(zhuangbei[i]));
		
	}
	while(key!=KEY_CTRL_EXE && key!=KEY_CTRL_EXIT)
	{
		GetKey(&key);
	}
}
Exemple #2
0
int
main()
{
  Bdisp_AllClr_VRAM();
  Bdisp_EnableColor(1);
  DefineStatusAreaFlags(3, SAF_BATTERY | SAF_TEXT | SAF_GLYPH | SAF_ALPHA_SHIFT, 0, 0);
  // disable Catalog function throughout the add-in, as we don't know how to make use of it:
  Bkey_SetAllFlags(0x80);
  
  printf("Welcome to Eigenmath\n");
  printf("To see version information,\npress Shift then Menu.\n");
  run_startup_script();
  aborttimer = Timer_Install(0, check_execution_abort, 100);
  if (aborttimer > 0) { Timer_Start(aborttimer); }
  //in case we're running in a strip, check if this strip has a script to run.
  if(is_running_in_strip()) {
    int MCSsize;
    MCSGetDlen2(DIRNAME, SCRIPTFILE, &MCSsize);
    if (MCSsize > 0) {
      // there is a script to run...
      unsigned char* asrc = (unsigned char*)alloca(MCSsize*sizeof(unsigned char)+5); // 5 more bytes to make sure it fits...
      MCSGetData1(0, MCSsize, asrc); // read script from MCS
      execution_in_progress = 1;
      run((char*)asrc);
      execution_in_progress = 0;
    }
  }
  input_eval_loop(0);
}
Exemple #3
0
void
emit_graph(void)
{
  int i, x, y;
  if(!has_drawn_graph) {
  	Bdisp_AllClr_VRAM();
  	num_graphs = 0;
  } else num_graphs++;
  get_xzero();
  get_yzero();
  emit_xaxis();
  emit_yaxis();
  emit_xscale();
  emit_yscale();

	int curcolor = COLOR_BLUE;
  for(int i=0; i < num_graphs; i++) {
    curcolor = getNextColorInSequence(curcolor);
  }
        
  for (i = 0; i < draw_count; i++) {
          x = draw_buf[i].x;
          y = DIMY - draw_buf[i].y; // flip the y coordinate
          if (x < 0 || x > DIMX)
                  continue;
          if (y < 0 || y > DIMY)
                  continue;
          plot(x+XOFF, y+YOFF, curcolor);
  }
  has_drawn_graph = 1;
}
Exemple #4
0
void I_Error (char *error, ...)
{
#ifdef CG_EMULATOR
    /*// Message first.
    va_start (argptr,error);
    printf ("Error: ");
    printf (error,argptr);
    printf ("\n");
    sprintf(ferror,error,argptr);
    va_end (argptr);
    */
    printf ("Error: %s",error);
    //Inform the user something bad had occured
    //Exit function here
#else
  I_ShutdownGraphics();
    Bdisp_AllClr_VRAM();
    locate_OS( 1, 1 );
    PrintLine( "ERROR:", 21 );
    locate_OS( 1, 2 );
    PrintLine( (unsigned char *)error, 21 );
    {
      if(key == 31)GetKey( &key );
    }
#endif //#ifdef CG_EMULATOR
    //I_Quit();
}
Exemple #5
0
void dConsoleCls ()
{
	line_index	= 0;
	line_x		= 0;
	line_start	= 0;
	line_count	= 0;
	Bdisp_AllClr_VRAM();
}
Exemple #6
0
int select_shoupai (int type,pai * shoupai,int shoupaishu)
{
	uint			key;
	bool			redraw = true;
	int				i,top,bottom,index;
	const int		h_max = 4-1;
	const int		size = shoupaishu;

	index=0,top=0,bottom=h_max;

	while(true)
	{
		if(redraw)
		{
			int x=0,y=12;
			
			if (bottom-top>h_max)bottom = top + h_max;
			if(top>index)
			{
				top = index;
				bottom = index + h_max;
			}
			if (index>bottom)
			{
				bottom = index;
				top = bottom - h_max;
			}
			if(bottom>size - 1)bottom = size - 1;
			
			redraw = false;
			Bdisp_AllClr_VRAM();
			sprintf(card_info,"%s�����%d����",type ? "���鿴��":"��ѡ��",size);
			ChsPrint(0,0,0,(PCUCHAR)card_info);
			if(shoupaishu>0)
			{
				for (i=top;i<=bottom;++i,y+=12)
				{
					//printf("%d %d %d",i,top,bottom);GetKey(&key);
					ChsPrint(x,y,index==i,(PCUCHAR)GetCardInfo(shoupai[i]));
				}
			}
			else
			{
				ChsPrint(x,y,0,"�ճ�");
			}
		}
		GetKey(&key);
		
		if (key==KEY_CTRL_UP) 
			{if(--index<0) index = size - 1;redraw = true;}
		else if (key==KEY_CTRL_DOWN)
			{if(++index>size - 1) index = 0;redraw = true;}
		else if (key==KEY_CTRL_EXIT)	return -1;
		else if (key==KEY_CTRL_EXE) 	return index;
	}
}
Exemple #7
0
void dConsoleRedraw ()
{
	int i,j;
	Bdisp_AllClr_VRAM();
	for(i=0,j=line_start;i<line_count;++i)
	{
		locate(1,i+1);Print((uchar*)line_buf[j]);
		if (++j>=LINE_ROW_MAX) j = 0;
	}
	
}
int main() {
	int key;
	Bdisp_AllClr_VRAM();

	while (1) {
		Bdisp_PutDisp_DD();
		GetKey(&key);
	}

	return 1;
}
int main() {
	int key;
	Bdisp_AllClr_VRAM();

	while (1) {
		printf("Blah\n");
		Bdisp_PutDisp_DD();
		GetKey(&key);
	}

	return 1;
}
Exemple #10
0
void main(void){
    Bdisp_EnableColor(0);//Use 3-bit mode.
    Bdisp_AllClr_VRAM();
    Bdisp_PutDisp_DD();
    for(;;){
        HourGlass();
        if(keyPressed(KEY_PRGM_MENU)){
            int key;
            GetKey(&key);
        }
    }
}
Exemple #11
0
void main(void) {
int key;
    char blah[10];
    blah[1]='k';
     
while (1) {
        Bdisp_AllClr_VRAM();
        GetKey(&key);
switch (key) {
}
}
 
return;
}
Exemple #12
0
void editRules(settings* sets) {


	Bdisp_AllClr_VRAM();
	Bdisp_EnableColor(1);

	switch(sets->sim_type) {
	case GOL:
		GoL_editRules(sets);
	case WW:
		WW_showRules(sets);
	
	}

}
Exemple #13
0
void main(void){
    Bdisp_EnableColor(0);//Use 3-bit mode. The progress bar looks the same in 16-bit mode.
    Bdisp_AllClr_VRAM();
    for(;;){
        int i;
        for(i=0;i<9001;++i){
            ProgressBar2("Acting busy",i,9001);
            if(keyPressed(KEY_PRGM_MENU)){
                int key;
                GetKey(&key);
                break;
            }
        }
        MsgBoxPop();
    }
}
void viewTOTPcode(totp* tkn) {
  unsigned short key = 0; int keyCol, keyRow;
  Bdisp_AllClr_VRAM();
  drawScreenTitle(tkn->name);
  int shown_since_beginning = 0;
  while(key != KEY_PRGM_EXIT && key != KEY_PRGM_LEFT) {
    int ThirtySecCode = computeTOTP(tkn);
    char buffer[10];
    itoa_zeropad(tkn->totpcode, buffer, 6);
    long long int ms_spent_ll = currentUTCUEBT() - (long long int)ThirtySecCode * 30LL * 1000LL;
    int ms_spent = (int)(ms_spent_ll);

    drawCircularCountdownIndicator(LCD_WIDTH_PX/2, 104, 44, COLOR_BLACK, COLOR_WHITE,
                                   (ms_spent*43)/30000, getCurrentSecond() < 30 ? 0 : 1);
    // fade in/out animation for text
    int val = 0;
    if(ms_spent >= 29000) {
      val += (-29000 + ms_spent)/4;
    } else if (ms_spent <= 1020) {
      val += (1020 - ms_spent)/4;
    }
    int color = drawRGB24toRGB565(val, val, val);
    printCentered(buffer, 164, color, COLOR_WHITE);
    if(ms_spent < 2500) shown_since_beginning = 1;
    else if(ms_spent < 15000 && shown_since_beginning)
      DefineStatusMessage((char*)totpHelpMessages[(ms_spent-2500)/2500], 1, 0, 0);
    else
      DefineStatusMessage((char*)"", 1, 0, 0);
    DisplayStatusArea();
    Bdisp_PutDisp_DD();
    key = PRGM_GetKey();
    if(key == KEY_PRGM_MENU)
      GetKeyWait_OS(&keyCol, &keyRow, 2, 0, 0, &key); //this is here to handle the Menu key
    if(key == KEY_PRGM_OPTN) {
      DefineStatusMessage((char*)"", 1, 0, 0);
      GetKeyWait_OS(&keyCol, &keyRow, 2, 0, 0, &key); // clear keybuffer
      RTCunadjustedWizard(0, 1);
      setTimezone();
      return; // so we don't have to redraw etc.
      // Also, this way the Shift+Menu instruction shown in the adjustment wizard becomes vali
      // immediately, which is great if the user wants to repeat the adjustment.
    }
  }
  DefineStatusMessage((char*)"", 1, 0, 0);
  // clear keybuffer:
  GetKeyWait_OS(&keyCol, &keyRow, 2, 0, 0, &key);
}
Exemple #15
0
int main()
{
	Bdisp_AllClr_VRAM();
	Bdisp_EnableColor(1);
	
	// Initialize console 1.
	nio_console c1;

	// The screen can hold up to 64 columns and 27 rows
	// 64 columns, 14 rows. 0px offset for x/y. Background color 15 (white), foreground color 0 (black)
	nio_InitConsole(&c1,64,14,0,0, NIO_COLOR_BLACK, NIO_COLOR_WHITE);
	nio_DrawConsole(&c1);
	
	nio_console c2;
	nio_InitConsole(&c2,64,13,0,14*8, NIO_COLOR_BLACK, NIO_COLOR_WHITE);
	nio_DrawConsole(&c2);
	
	// Just showing printf
	nio_printf(&c1,"%s build at %s, %s\n",__FILE__,__DATE__,__TIME__);
	nio_printf(&c2,"256 text colors available! ");
	int i;
	for(i = 1; i<16; i++)
	{
		nio_SetColor(&c2, 0, i);
		nio_printf(&c2, "%d ", i);
	}
	nio_printf(&c2,"\n");

	// Press EXE to exit
	while(1)
	{
		char text[100];
		// If no text was entered, exit
		if(!nio_GetStr(&c1,text))
			break;
		// Write the text into 2nd console
		nio_printf(&c2,"%s\n",text);
		//Bdisp_PutDisp_DD();
	}
	
	nio_CleanUp(&c1);
	nio_CleanUp(&c2);
	
	return 0;
}
Exemple #16
0
void I_ErrorI (char *error, int i1,int i2,int i3,int i4)
{
  #ifndef CG_EMULATOR

    char buf[21];
    Bdisp_AllClr_VRAM();
    locate_OS( 1, 1 );
    PrintLine( "ERROR:", 21 );
    locate_OS( 1, 2 );
    PrintLine( (unsigned char *)error, 21 );
    locate_OS( 1, 3 );CGDAppendNum0_999("i1",i1,0,buf);PrintLine( (unsigned char *)buf, 21 );
    locate_OS( 1, 4 );CGDAppendNum0_999("i2",i2,0,buf);PrintLine( (unsigned char *)buf, 21 );
    locate_OS( 1, 5 );CGDAppendNum0_999("i3",i3,0,buf);PrintLine( (unsigned char *)buf, 21 );
    locate_OS( 1, 6 );CGDAppendNum0_999("i4",i4,0,buf);PrintLine( (unsigned char *)buf, 21 );
    {
        if(key == 31)GetKey( &key );
    }
#else
      I_Error (error,i1,i2,i3,i4);
#endif
}
Exemple #17
0
void main(void){
	int x,y;
	char buf[1024];//In this example nothing is done with the buffer, I leave it as an exercise to the reader to do something with the inputted text.
	Bdisp_EnableColor(0);
	Bdisp_AllClr_VRAM();
	//Print the "explanation"
	PrintXY(1,1,"  Stop!",0,0);
	x=0;
	y=32;
	PrintMini(&x,&y,"Who would cross the Bridge of Death",0,0xFFFFFFFF,0,0,0,0xFFFF,1,0);
	x=0;
	y=56;
	PrintMini(&x,&y,"must answer me these questions three,",0,0xFFFFFFFF,0,0,0,0xFFFF,1,0);
	x=0;
	y=80;
	PrintMini(&x,&y,"ere the other side he see.",0,0xFFFFFFFF,0,0,0,0xFFFF,1,0);
	PrintXY(1,5,"  What... is",0,0);
	for(;;){
		askQ("  your name?",buf,1024);
		askQ("  your quest?",buf,1024);
		askQ("  your favorite color?",buf,1024);//The text fits by using American spelling. Yes I know Monty Python is a British show.
	}
}
Exemple #18
0
void show_judgement (wujiang & w)
{
	const char * 	name;
	int 			x=0,y=0,sel=0;
	uint			key = 0;
	pai				*pandingpai = w.pandingpai;
	
	Bdisp_AllClr_VRAM();

	if(w.juese)
		name = "���";
	else
		name = "����";
		
	ChsPrint(x,y,sel,(PCUCHAR)name);ChsPrint(x+24,y,sel,(PCUCHAR)"��ǰ�ж�����");y+=12;
	
	if((pandingpai[0]).leixing==-1)ChsPrint(x,y,sel,(PCUCHAR)"��");
	else
	{
		x=0;
		ChsPrint(x,y,sel,(PCUCHAR)GetCardInfo(pandingpai[0]));y+=12;
		if((pandingpai[1]).leixing==-1);
		else
		{
			ChsPrint(x,y,sel,(PCUCHAR)GetCardInfo(pandingpai[1]));y+=12;
			if((pandingpai[2]).leixing==-1);
			else
			{
				ChsPrint(x,y,sel,(PCUCHAR)GetCardInfo(pandingpai[2]));
			}
		}
	}
	while(key!=KEY_CTRL_EXE && key!=KEY_CTRL_EXIT)
	{
		GetKey(&key);
	}
}
Exemple #19
0
int main()
{
	char filename[50] = {'\0'};
	//fileBrowser(filename, (unsigned char*)"*.lua", (unsigned char*)"*.lc", (unsigned char*)"*.txt", "Title"); //*.lua, *.lc, *.txt: filetypes to filter; "Title": small text to show in blue on the top left corner  
	Exec_info exec_info = {0,0,0};
	int key = 0, debug = 0, handle_program, i=0;
	char pc_s[10];
	Bdisp_AllClr_VRAM();

	srand(time_getTicks());

	init_gui();
	init_machine();
	while(1) {
		handle_program = gui(exec_info);
		if(handle_program > 0) {
			init_machine();
			load_game(handle_program);
			exec_info = play_game();
		} else {
			while(i < 10) {
				nio_DrawConsole(&c1);
				GetKey(&key);
				i++;
			}
			i=0;
		}
	}

	nio_CleanUp(&c1);

	while(1) {
		GetKey(&key);
	}
	return 1;
}
Exemple #20
0
void game() {
	/* MAIN LOOP, DO NOT BREAK */
	while (1) {
		/* GETKEY */
		keyupdate();
		// handle [menu]
		if (PRGM_GetKey()==48) {
			GetKey(&key);
		}

		// direction keys
		if (keydownlast(KEY_PRGM_LEFT) && cursor_pos[0]>33) {
			cursor_pos[0] -= cursor_speed;
		} else if (keydownlast(KEY_PRGM_RIGHT) && cursor_pos[0]<LCD_WIDTH_PX-33) {
			cursor_pos[0] += cursor_speed;
		}
		if (keydownlast(KEY_PRGM_UP) && cursor_pos[1]>0) {
			cursor_pos[1] -= cursor_speed;
		} else if (keydownlast(KEY_PRGM_DOWN) && cursor_pos[1]<(LCD_HEIGHT_PX-dash_height-cart_height-man_height-10)) {
			cursor_pos[1] += cursor_speed;
		}

		// control keys
		// shift
		if (keydownlast(KEY_PRGM_SHIFT) && man_is_hanging) {
			// drop man
			man_is_hanging = false;
			man_pos[0] = copter_pos[0];
			man_pos[1] = copter_pos[1]+9;
		}

		/* OPERATIONS */
		// move copter
		if (cursor_pos[0] > copter_pos[0]) {
			copter_pos[0]+=copter_speed;
		} else if (cursor_pos[0] < copter_pos[0]) {
			copter_pos[0]-=copter_speed;
		}

		if (cursor_pos[1] > copter_pos[1]) {
			copter_pos[1]+=copter_speed;
		} else if (cursor_pos[1] < copter_pos[1]) {
			copter_pos[1]-=copter_speed;
		}

		// if man is falling, drop him
		if (!man_is_hanging) {
			man_pos[1] += man_speed;
		}
		// if man is below cart level, check if he is in the cart
		if (!man_is_hanging && man_pos[1]>(LCD_HEIGHT_PX-dash_height-cart_height-5)) {
			if (!man_is_dead && man_pos[0]>cart_pos && man_pos[0]<cart_pos+35) {
				next_try();
			} else {
				die_animation(man_pos[0], man_pos[1]);
			}
		}

		// move cart
		cart_counter = (cart_counter+1) % LCD_WIDTH_PX;
		cart_pos = cart_counter-70;
		// update frame
		cart_frame = (cart_frame+1) % 2;

		/* GRAPHICS */
		// clear screen
		Bdisp_AllClr_VRAM();

		// display functions
		draw_copter(copter_pos[0], copter_pos[1], man_is_hanging);
		draw_cart(cart_pos, LCD_HEIGHT_PX-dash_height-cart_height, cart_frame);

		// if man is falling, draw him
		if (!man_is_hanging /* && !man_is_dead */) {
			draw_man(man_pos[0], man_pos[1]);
		}

		// draw dash
		draw_dash();

		// draw cursor on top of everything
		draw_cursor(cursor_pos[0], cursor_pos[1]);
		
		// copy VRAM to screen
		Bdisp_PutDisp_DD();
	}
}
Exemple #21
0
void iRead_main(const char* filename)
{
    /*
	    阅读界面主函数
		参数说明:
		    filename: 打开的文件名 (从文件浏览器得到)
	*/

    int key,handle;
	char* buf=(char*)malloc(461);
	FONTCHARACTER fname[64];
	
	char tip[64], tmp[64];
	
	page=0;cached=0;
	
	memset(bytes,0,sizeof(bytes));
	memset(bookmark,0,sizeof(bookmark));bookmark[3]=0;
	
	Read_Config(filename,&cached);    //  读取书签及分页配置
	
	//  如果分的页数不满 500 的整数倍,补分页满
	if (cached==0) divide_page(filename,500-cached,1);
	else
	    if (cached%500!=0) divide_page(filename,500-cached%500,1);   // 补至 500 的整数倍
	totbytes=0;
	
	/*  设置状态栏显示文字
		0x0001:显示电量
		0x0100:显示文字
	*/
	DefineStatusAreaFlags(3, 0x01 | 0x02 | 0x100, 0, 0);
	
	beg:
	font16=open_font("\\\\fls0\\24PX.hzk");
	select_font(font16);
	
	Bdisp_AllClr_VRAM();
    draw_pic(0,192,124,22,0,Menu_Read);
	draw_pic(126,192,61,22,0,Menu_Sub_Jump);
	
	//  若翻下一页时超出已缓存页面范围
	if (cached<=page)
	{
	    //  如果分的页数不满 500 的整数倍,补分页满
	    if (!divide_page(filename,1,0)) page=cached-1;
	    else if (cached%500!=0) divide_page(filename,500-cached%500,0);
		
		close_font(font16);
		goto beg;
	}
	totbytes=bytes[page];    //  修正读取字节指针位置
	
	char_to_font(filename,fname);
	handle=Bfile_OpenFile_OS(fname,0);    //  打开文件
	
	Bfile_ReadFile_OS(handle,buf,400,totbytes);
	Bfile_CloseFile_OS(handle);
	
	print_chs_page(0,24,totbytes,(unsigned char*)buf);    //  绘制一页
    close_font(font16);
	
	//  准备显示浏览进度
	char fn_ptr[64];
	memset(fn_ptr, 0, sizeof(fn_ptr));
	GetDisplayFileName(filename, fn_ptr);
	
	memset(tip, 0, sizeof(tip));
	memset(tmp, 0, sizeof(tmp));
	strcat(tip, fn_ptr); strcat(tip, " ");
	itoa(page + 1, tmp, 10); strcat(tip, tmp);
    strcat(tip, "/"); memset(tmp, 0, sizeof(tmp));
	itoa(cached, tmp, 10);strcat(tip, tmp);
	
	//  状态栏显示文件名及进度
	DefineStatusMessage(tip, 0, 0, 0);
	
	while (1)
	{
	    GetKey(&key);
	    switch (key)
		{
		    case KEY_CTRL_UP:    //  跳到上一页
			    if (page>0)
				{
			        --page;
				    goto beg;
				}
				break;
				
		    case KEY_CTRL_DOWN:    //  跳到下一页
			    ++page;
			    goto beg;
				break;
				
			case KEY_CTRL_EXIT:    //  离开,返回文件浏览器
			    Save_Config(filename,cached+1);
				DefineStatusAreaFlags(3, 0x01 | 0x02 | 0x100, 0, 0);
			    return;break;
				
			case KEY_CTRL_F2:    //  打开存储书签对话框
			    Save_Bookmark(filename,page,cached+1);
				goto beg;break;
				
			case KEY_CTRL_F1:    //  打开读取书签对话框
			    Read_Bookmark(filename,&page,&cached);
				goto beg;break;
				
			case KEY_CTRL_F3:    //  打开跳页对话框
			    Page_Jump(filename);
				goto beg;break;
		}
 	}
}
///////////////////////////////////////////////////////////////
//							File List
///////////////////////////////////////////////////////////////
int SelectFiles3 (char * file_name)
// -1 no file , 1 complate ,0 cancel
{
	int key;
	char str[50]; //字符数组长度下标从0开始,共50个元素
	FONTCHARACTER find_path[50];   //获得路径
	FONTCHARACTER find_name[50];   //获得名字
	int find_h;
	int size = 0;
	int top = 0;
	int buttom = 0;
	int index,r,y;
	char *files;
	FILE_INFO file_info;
//	CharToFont("\\\\fls0\\ZDM\\*.zdm",find_path);
	sprintf(str,"%s\\*.zdm",szSrdDir3);
	CharToFonts3(str,find_path);
	if(Bfile_FindFirst (find_path,&find_h,find_name,&file_info)==0)  //函数搜索目录中文件的名称符合指定的文件名
	{
		int i=0,ret;
		BOOL bFindFirst=TRUE; //定义一个布尔型变量初始化为真(true),对于bool类型,值只要不是0就是为真,即true;当值为0时为假,即false;
		size ++;  //使用size之后再加一(先计算再操作)
		while(Bfile_FindNext(find_h,find_name,&file_info)==0) //Bfile_FindNext 函数使用搜索处理定位匹配一个给定名称的文件名称。
		size++;
		Bfile_FindClose(find_h);  //Bfile_FindClose 关闭搜索指定处理函数
		files = (char*)malloc(size*13);
		index = 0;
		for(;;)
		{
			if(bFindFirst)  //if 值为真
				ret=Bfile_FindFirst (find_path,&find_h,find_name,&file_info);
			else 
				ret=Bfile_FindNext(find_h,find_name,&file_info);
			if(ret!=0)  //if 
				break;
			strncpy((files+13*i),FontToChars3(find_name,str),13);
			if(strcmp((files+13*i),setup_data.zdmroute_name)==0) //文件选中后,现在记忆位置
			index=i; 
			i++;
			bFindFirst=FALSE;  //令值为假 即=0
		}
		Bfile_FindClose(find_h);  //Bfile_FindClose 关闭搜索指定处理函数
		r = 1;
		top = 0;
		buttom = 4;
		while(1)   
		{
			if (r)
			{
				Bdisp_AllClr_VRAM();
				//PopUpWin(6);
				DispStr(20,8,"纵断面文件: ");
				if (buttom-top>3)buttom = top + 3;
				if(top>index)
				{
					top = index;
					buttom = index + 3;
				}
				if (index>buttom)
				{
					buttom = index;
					top = buttom - 3;
				}
				if(buttom>size - 1)buttom = size - 1;
				if(top<0) top = 0;
				for (i=top;i<=buttom;++i)
				{
					//sprintf(str,"%13.13s",(files+13*i));
					//y=2+(i-top)*13;   //顶部文件位置
					//SetMyFont(&stHz12x12,&stAsc6x12);
					//DispStr(18,y,str); //str[]是字符串
					//if(index==i)
					//Bdisp_AreaReverseVRAM(15,y,20+13*6,y+11);
				    PrintfXY(20,22+(i-top)*8,index==i,"%13.13s",(files+13*i));
				}
				PrintXY(100,22,top>0?"\xE6\x92":" ",0);
				PrintXY(100,46,buttom<size-1?"\xE6\x93":" ",0);
				r = 0;
			}
			GetKey(&key);
			if (key==KEY_CTRL_UP) 	{if(--index<0) index = size - 1;r = 1;}
			if (key==KEY_CTRL_DOWN)	{if(++index>size - 1) index = 0;r = 1;}
			if (key==KEY_CTRL_EXE)
			{
				strcpy(file_name,(files+13*index));
				free (files);
				return 1;
			}
			if (key==KEY_CTRL_EXIT)
			{
				free (files);
				return 0;
			}
		}
	}
	else
		return -1;
	
}
int PM_parameter()
{
	
	char * table_label[]= {"DH","QDZH","ZDZH","X","Y","FWJ","ZX","QDBJ","ZDBJ"};
	char * icons[]		= {"","","","",""};
	char * ch_text[]	= {"\xb5\xe3\xc3\xfb",
	                        "起点桩号",
							"终点桩号",
							"X坐标 ", 
							"Y坐标 ",
							"方位角 ",
							"转向 ",
							"起点半径",
							"终点半径"};
							
	int x = 0,y = 0,i,j,t;
	int left = 0,top = 0;
	int refresh = REDRAW_ALL;
	int enter,suc;
	char str[13]="";
	char c;
	

	PMproduce(); //打开交点参数转换平面参数
	InsertLine(l_pqx.length,&y,&refresh);
	GetListq();  //取链表链表线元参数

	while(1){
		if (refresh==REDRAW_ALL){
			Bdisp_AllClr_VRAM();
			for (i=0;i<4;++i)
			PrintTablesPM(i,0,table_label[left+i],1,1);
			t = pmroute.size<= 1 ? 2 : 5; //如果交点个数小于等于1 那么T=2 否则等于5
			if 	(t>=2){
			SetMyFont(&stHz8x8,&stAsc6x12);
			DispStr(2,56,"\xCE\xC4\xBC\xFE");
		    DispStr(23,56,"添加");
			}
			if 	(t>2){
			SetMyFont(&stHz8x8,&stAsc6x12);
			DispStr(45,56,"插入 ");
		    DispStr(65,56,"删行 ");
			DispStr(86,56,"清空 ");
			}
			for (i=0;i< t;++i) // i<2 或  i<5
			PrintIcon(i,icons[i],0);  //打印下标 
			PrintIcon(5,"?",0);  //固定打印下标
			refresh = REDRAW_PART; // 重画部分
		}
		if (refresh==REDRAW_PART){  //如果画部分 
			double * sd;
			for (i=top;i<top+4 && i<pmroute.size;++i){ 
				sd =  & (pmroute.set[i].pm_qk);
				for (j=(left==0 ? 1:0);j<4;++j){
					//if (i==0 && j+left>3)  //////////////////////////////////////////
					//PrintTablesPM(j,i+1-top,"",y==i && x-left==j,0);///////////////
					//else/////////
						PrintTableFormatPM(j,i+1-top,y==i && x-left==j,0,"%lf",sd[j+left-1]);
				}
				if (left==0)
					PrintTableFormatPM(0,i+1-top,y==i && x-left==0,0,"%s",pmroute.set[i].name);
				    PrintTableIndexPM(i-top+1,i);
			}
			SetMyFont(&stHz12x12,&stAsc6x12);
			if(x>0){
				//if (!(y==0 && x>2)){
					sd =  & (pmroute.set[y].pm_qk); //取地址的值***************
					DispStr(0,42,ch_text[x]);
					PrintFloat(sd[x-1],49,42,0,setup_data.point); //打印 
				//}
			}else{
				DispStr(0,42,ch_text[x]);
				PrintXY(51,44,pmroute.set[y].name,0);
			}
			refresh = 0;
		}
		GetKey(&key);
		switch (key){
		case KEY_CTRL_UP:
			y--;refresh = REDRAW_ALL;break;
		case KEY_CTRL_DOWN:
			y++;refresh = REDRAW_ALL;break;
		case KEY_CTRL_LEFT:
			x--;refresh = REDRAW_ALL;break;
		case KEY_CTRL_RIGHT:
			x++;refresh = REDRAW_ALL;break;
		case KEY_CTRL_EXIT:
			pmroute_initial(&pmroute);
		    InitList(&l_pqx);
			return 0 ;
			
		case KEY_CTRL_F1:					/* Set */
			refresh = REDRAW_ALL;
			SelectfilePM();
			break;
			
		case KEY_CTRL_F2:					/* Add */
		    pmroute_push_back (&pmroute);
			y = pmroute.size - 1;
			refresh = REDRAW_ALL;
			break;
			
		case KEY_CTRL_F3:					/* ins */
			//if (y==0) break;
			pmroute_insert (&pmroute,y);
			y++;
			refresh = REDRAW_ALL;
			break;
		case KEY_CTRL_F4:					/* Del a point */
			//if (y==0) break;
			refresh = REDRAW_ALL;
			PopUpWin(4);DispStr(25,10,"删 除 一 行?");
			locate(3,5);Print("[F1]Yes   [F6]No");
			GetKey(&key);
			if (key==KEY_CTRL_F1){
				pmroute_del(&pmroute,y);y--;
			}
			break;
			
		 case KEY_CTRL_F5:					/* Del All */
			refresh = REDRAW_ALL;
			PopUpWin(4);DispStr(25,10,"清 空 所 有 ?");
			locate(3,5);Print("[F1]Yes   [F6]No");
			GetKey(&key);
			if (key==KEY_CTRL_F1){
				pmroute_initial(&pmroute);
	            pmroute_push_back(&pmroute);
			}
			break;
			

         case KEY_CTRL_F6:
		    refresh = REDRAW_ALL;
			//PrintfXY (70,30,0,"%.3f",route.set[0].xy_zr);  
			//DispStr(15,10,"线路名称");
			//if(setup_data.pmroute_name[0]==0)
			//{
			 //DispStr(25,27,"请保存线路文件 ");
			//}
			 //else
			//{
             //DispStr(25,27,setup_data.zdmroute_name);
			//}
          	break;	
		default:							/*other things*/
			if (x>0 && (c=GetPressNumChar(key))!=0){
				char buffer[14];
				int r;
				//if (y==0 && x > 3)break;
				buffer[0] = c;
				buffer[1] = '\0';
				r = InputString(49,42,buffer,0,12);
				if (r!=KEY_CTRL_EXIT){
					double * sd;
					sd =  (double*)&(pmroute.set[y].pm_qk);
					sd[x-1] = atof(buffer);
					switch(r){
					case KEY_CTRL_UP:	y--;break;
					case KEY_CTRL_DOWN:	y++;break;
					case KEY_CTRL_EXE:	x++;break;
					}
				}
				refresh = REDRAW_ALL;
			}
			else if (x==0 && (c=GetPressChar(key))!=0){
				char buffer[14];
				int r;
				buffer[0] = c;
				buffer[1] = '\0';
				r = InputString(49,42,buffer,1,12);
				if (r!=KEY_CTRL_EXIT){
					strncpy(pmroute.set[y].name,buffer,12);
					switch(r){
					case KEY_CTRL_UP:	y--;break;
					case KEY_CTRL_DOWN:	y++;break;
					case KEY_CTRL_EXE:	x++;break;
					}
				}
				refresh = REDRAW_ALL;
			}
			break;
		}
		if (x<0) x = 8,y--;
		if (x>8) x = 0,y++;
		if (y<0) y = 0;
		if (y>=pmroute.size) y = pmroute.size - 1;
		if (y>top + 3) top = y - 3;
		if (y<top) top = y;
		if (x>left +3) left = x - 3;
		if (x<left) left = x;
	}
}
Exemple #24
0
int fileBrowserSub(char* browserbasepath, char* filename, char* filter, char* filter2, char* title) {
  Menu menu;
  MenuItemIcon icontable[12];
  buildIconTable(icontable);
  
  // first get file count so we know how much to alloc
  GetFiles(NULL, NULL, browserbasepath, &menu.numitems, filter, filter2);
  MenuItem* menuitems = NULL;
  File* files = NULL;
  if(menu.numitems > 0) {
    menuitems = (MenuItem*)alloca(menu.numitems*sizeof(MenuItem));
    files = (File*)alloca(menu.numitems*sizeof(File));
    // populate arrays
    GetFiles(files, menuitems, browserbasepath, &menu.numitems, filter, filter2);
    menu.items = menuitems;
  }
  
  char titleBuffer[120];
  char titleBufferBuf[120];
  int smemfree;
  unsigned short smemMedia[10]={'\\','\\','f','l','s','0',0};
  Bfile_GetMediaFree_OS( smemMedia, &smemfree );
  
  char friendlypath[MAX_FILENAME_SIZE];
  strcpy(friendlypath, browserbasepath+6);
  friendlypath[strlen(friendlypath)-1] = '\0'; //remove ending slash like OS does
  // test to see if friendlypath is too big
  int jump4=0;
  while(1) {
    int temptextX=7*18+10; // px length of menu title + 10, like menuGUI goes.
    int temptextY=0;
    PrintMini(&temptextX, &temptextY, (char*)friendlypath, 0, 0xFFFFFFFF, 0, 0, COLOR_BLACK, COLOR_WHITE, 0, 0); // fake draw
    if(temptextX>LCD_WIDTH_PX-6) {
      char newfriendlypath[MAX_FILENAME_SIZE];
      shortenDisplayPath(friendlypath, newfriendlypath, (jump4 ? 4 : 1));
      if(strlen(friendlypath) > strlen(newfriendlypath) && strlen(newfriendlypath) > 3) { // check if len > 3 because shortenDisplayPath may return just "..." when the folder name is too big
        // shortenDisplayPath still managed to shorten, copy and continue
        jump4 = 1; //it has been shortened already, so next time jump the first four characters
        strcpy(friendlypath, newfriendlypath);
      } else {
        // shortenDisplayPath can't shorten any more even if it still
        // doesn't fit in the screen, so give up.
        break;
      }
    } else break;
  }
  menu.subtitle = friendlypath;
  menu.type = MENUTYPE_MULTISELECT;
  menu.scrollout=1;
  menu.nodatamsg = (char*)"No Data";
  menu.title = title;
  menu.height=7;
  while(1) {
    Bdisp_AllClr_VRAM();
    drawFkeyLabels((menu.numitems ? 0x03B1 : 0), -1, -1, -1, -1, 0x03DF); // OPEN, VERSION
    itoa(smemfree, (unsigned char*)titleBuffer);
    LocalizeMessage1( 340, titleBufferBuf ); //"bytes free"
    strncat((char*)titleBuffer, (char*)titleBufferBuf, 65);
    menu.statusText = (char*)titleBuffer;
    int res = doMenu(&menu, icontable);
    switch(res) {
      case MENU_RETURN_EXIT:
        if(!strcmp(browserbasepath,"\\\\fls0\\")) { //check that we aren't already in the root folder
          //we are, return 0 so we exit
          //return 0; // in this add-in, the file browser shouldn't return
        } else {
          int i=strlen(browserbasepath)-2;
          while (i>=0 && browserbasepath[i] != '\\')
                  i--;
          if (browserbasepath[i] == '\\') {
            char tmp[MAX_FILENAME_SIZE] = "";
            memcpy(tmp,browserbasepath,i+1);
            tmp[i+1] = '\0';
            strcpy(browserbasepath, tmp);
          }
          return 1; //reload at new folder
        }
        break;
      case KEY_CTRL_F1:
      case MENU_RETURN_SELECTION:
        if(!menu.numitems) break;
        if(menuitems[menu.selection-1].isfolder) {
          strcpy(browserbasepath, files[menu.selection-1].filename); //switch to selected folder
          strcat(browserbasepath, "\\");
          return 1; //reload at new folder
        } else {
          strcpy(filename,files[menu.selection-1].filename);
          return 2;
        }
        break;
      case KEY_CTRL_F6:
        showAbout();
        break;
    }
  }
  return 1;
}
Exemple #25
0
void clear() {
    Bdisp_AllClr_VRAM();
}
Exemple #26
0
int computeFS ()
{
	uint refresh = 2,key;
	int  index = 0,i,hcs;
	char ch;
	double ht,hz,v,bh,hd;
	double value[4] = {0.0,0.0,0.0,0.0};
	const char * context[] = {"","","",""};
	while(1){
			if (refresh == REFRESH_ALL){
			refresh = REFRESH_PART;
			Bdisp_AllClr_VRAM();
			SetMyFont(&stHz12x12,&stAsc6x12);  //¶¨Òå×ÖÌå´óС
			DispStr(2,1, "Ïß ");
			DispStr(2,12,"· ");
			DispStr(2,25,"·´ ");
			DispStr(2,38,"Ëã ");
			ShowTitle(TITLE);
			DispStr(17,0, "×ø±êX: ");
		    DispStr(17,13,"×ø±êY: ");
			DispStr(17,26,"×ø±êZ: ");
			//DispStr(17,39,"×ø±êZ: ");

			for (i=0;i<4;++i){
				PrintXY(50,2+i*12,(uchar*)context[i],0);
			}
			PrintIcon (0,"Rou",0);
			PrintIcon (1,"Set",0);
			PrintIcon (2,"Disp",0);
			PrintIcon (3,"=0=",1);
			PrintIcon (4,"Save",1);
			PrintIcon (5,"?",0);
		}
		if (refresh == REFRESH_PART){
			for (i=0;i<4;++i){
		     PrintFloat(value[i],48,0+i*12,index==i,4);	//ÊäÈë¿òλÖÃ
			}
			refresh = 0;
		}
		GetKey(&key);
		switch(key){
			case KEY_CTRL_F1	:
				SET();	refresh=REFRESH_ALL;	break;
			case KEY_CTRL_F2	:
				ZSSET();	refresh=REFRESH_ALL;	break;
			case KEY_CTRL_F3	:
				RestoreDisp(SAVEDISP_PAGE1);refresh=REFRESH_ALL;WaitKey();break;
			case KEY_CTRL_F4	:
			case KEY_CTRL_F5	:
				Nodata();	refresh=REFRESH_ALL;	break;
			case KEY_CTRL_F6	:
				About();	refresh=REFRESH_ALL;	break;
			case KEY_CTRL_UP	:
				refresh=REFRESH_PART;	--index;	break;
			case KEY_CTRL_DOWN	:
				refresh=REFRESH_PART;	++index;	break;
			case KEY_CTRL_EXE:
			if (index<3){
				refresh = REFRESH_PART;	index++;
			}else{
				yscs.x1 = value[0];	yscs.y1 = value[1];
				hz = value[2];	ht = value[3];
				refresh=REFRESH_ALL;
				//yscs.k=0.0;
				yscs.k=xy_to_sdSrd( yscs.x1, yscs.y1, 0);
				yscs.d=xy_to_sdSrd( yscs.x1, yscs.y1, 1);
				//yscs.k=xy_to_sd( yscs.x1, yscs.y1, 0);
				//yscs.d=xy_to_sd( yscs.x1, yscs.y1, 1);
				
				//FS();
				GC();
				HP();
				if	(yscs.d<0)	hcs=-1;	//Æ«¾à×ó²à
		 		if	(yscs.d>=0)	hcs=1; //Æ«¾àÓÒ²à
		 		if	(yscs.d*hcs<=zfset.zsp)	hd=0;  //
	 			if	(zfset.zsh==0)	hd=0;
	 			if	(yscs.d*hcs>zfset.zsp && yscs.d*hcs-zfset.zsp<zfset.zsh) hd=(yscs.d*hcs-zfset.zsp)*hcs;
				if	(yscs.d*hcs-zfset.zsp>=zfset.zsh)	hd=zfset.zsh*hcs;
				bh=yscs.gch+(yscs.hpd*hd)-ht;
				Bdisp_AllClr_VRAM();
				DispStr(2,0, "¼Æ ");
			    DispStr(2,12,"Ëã ");
			    DispStr(2,26,"½á ");
			    DispStr(2,39,"¹û ");
				ShowTitle(TITLE);
				DispStr(17,0,"×®ºÅ "); 
			    DispStr(17,13,"Æ«¾à ");
			    DispStr(17,26,"ÌîÍÚ: ");
				DispStr(17,39,"»ù¸ß: ");
				PrintfXY (48,2.5,0,"%.4f",yscs.k); 
				PrintfXY (48,15,0,"%.4f",yscs.d);
				PrintfXY (48,28,0,"%.4f",yscs.gch);
				PrintfXY (48,42,0,"%.4f",yscs.hpd);
				//PrintfXY (22,40,0," H= %.3f",bh);
				//PrintfXY (22,48,0," H-Z= %.3f",hz-bh);
				SaveDisp(SAVEDISP_PAGE1);
				WaitKey();
				++index;
			}break;
			case KEY_CTRL_EXIT:
				return 0;
			default:
				if ((ch=GetPressNumChar(key))!=0){
					char buf[14];
					int        r;
					refresh = REFRESH_PART;
					buf[0] = ch;   buf[1] = '\0';
					r = InputString (48,0+index*12,buf,0,12);  //ÊäÈë¿òλÖÃ
					if (r != KEY_CTRL_EXIT){

						value[index] = atof(buf);
						if	(r==KEY_CTRL_DOWN)	++index;
						if	(r==KEY_CTRL_UP)	--index;
						if (r==KEY_CTRL_EXE && index<3)	++index;
					}
					break;
				}
		}
		if (index >=4) index = 2;
		if (index < 0) index = 3;
	}
}
void passwordGenerator() {
  Menu menu;
  menu.type = MENUTYPE_FKEYS;
  menu.title = (char*)"Password Generator";
  menu.height = 7;
  MenuItem items[6];
  int length = 10;
  int seed = RTC_GetTicks() * (GetMainBatteryVoltage(1) % 100);
  char lstr[10];
  items[1].text = (char*)"Include symbols";
  items[1].type = MENUITEM_CHECKBOX;
  items[2].text = (char*)"Include numbers";
  items[2].type = MENUITEM_CHECKBOX;
  items[2].value = MENUITEM_VALUE_CHECKED;
  items[3].text = (char*)"Include uppercase";
  items[3].type = MENUITEM_CHECKBOX;
  items[3].value = MENUITEM_VALUE_CHECKED;
  items[4].text = (char*)"Include confusable";
  items[4].type = MENUITEM_CHECKBOX;
  items[4].value = MENUITEM_VALUE_CHECKED;
  items[5].text = (char*)"Memorable vowel mix";
  items[5].type = MENUITEM_CHECKBOX;
  menu.numitems = 6;
  menu.items = items;
  while(1) {
    drawFkeyLabels(0x03B3, 0, 0, 0, 0, 0x0184); // FILE, EXE (white)
    itoa(length, (unsigned char*)lstr);
    char t[20];
    strcpy(t, "Length: ");
    strcat(t, lstr);
    items[0].text = t;
    switch(doMenu(&menu)) {
      case MENU_RETURN_EXIT:
        return;
      case MENU_RETURN_SELECTION:
        if(menu.selection > 1) items[menu.selection-1].value = !items[menu.selection-1].value;
        else {
          Selector sel;
          sel.min = 6;
          sel.value = length;
          sel.max = 30;
          sel.cycle = 1;
          sel.title = (char*)"Password Generator";
          sel.subtitle = (char*)"Length";
          if(doSelector(&sel) == SELECTOR_RETURN_SELECTION) {
            length = sel.value;
          }
        }
        break;
      case KEY_CTRL_F1:
      {
        Selector sel;
        sel.min = 1;
        sel.value = 10;
        sel.max = 1000;
        sel.cycle = 1;
        sel.title = (char*)"Generate to file";
        sel.subtitle = (char*)"Number of passwords";
        if(doSelector(&sel) != SELECTOR_RETURN_SELECTION) break;

        SetBackGround(10);
        drawScreenTitle("Generate to file", "Filename:");
        char newname[MAX_NAME_SIZE];
        newname[0] = 0;
        textInput input;
        input.forcetext=1;
        input.symbols = 0;
        input.charlimit=MAX_NAME_SIZE;
        input.buffer = (char*)newname;
        int inscreen = 1;
        while(inscreen) {
          input.key=0;
          int res = doTextInput(&input);
          if (res==INPUT_RETURN_EXIT) break; // user aborted
          else if (res==INPUT_RETURN_CONFIRM) {
            inscreen = 0;
          }
        }
        if(inscreen) break;
        char newfilename[MAX_FILENAME_SIZE];
        strcpy(newfilename, SMEM_PREFIX);
        strcat(newfilename, newname);
        strcat(newfilename, ".txt");
        unsigned short pFile[0x10A];
        Bfile_StrToName_ncpy(pFile, newfilename, 0x10A);
        unsigned int size = 1;
        int ntry = 0;
        while(ntry < 2) {
          ntry++;
          int BCEres = Bfile_CreateEntry_OS(pFile, CREATEMODE_FILE, &size);
          if(BCEres >= 0) {
            int hFile = Bfile_OpenFile_OS(pFile, READWRITE, 0); // Get handle
            if(hFile >= 0) {
              char password[35];
              char line[37];
              for(int i = 0; i < sel.value; i++) {
                generateRandomString(password, length, items[1].value, items[2].value,
                                     items[3].value, items[4].value, items[5].value, &seed);
                sprintf(line, "%s\r\n", password);
                Bfile_WriteFile_OS(hFile, line, length+2);
              }
              Bfile_CloseFile_OS(hFile);
            } else AUX_DisplayErrorMessage(0x2B);
            break;
          } else if(ntry < 2) {
            // File creation probably failed due to the presence of a file with the same name
            if(overwriteFilePrompt(newfilename))
              Bfile_DeleteEntry(pFile);
            else
              break;
          } else AUX_DisplayErrorMessage(0x2B);
        }
        break;
      }
      case KEY_CTRL_F6:
        int inscreen = 1;
        while(inscreen) {
          Bdisp_AllClr_VRAM();
          drawScreenTitle("Password Generator", "Generated passwords:");
          textArea text;
          text.type = TEXTAREATYPE_INSTANT_RETURN;
          text.scrollbar = 0;
          text.y = 48+3;
          text.lineHeight = 20;
          textElement e[5];
          char passwords[5][35];
          for(int i = 0; i < 5; i++) {
            generateRandomString(passwords[i], length, items[1].value, items[2].value,
                                 items[3].value, items[4].value, items[5].value, &seed);
            e[i].text = passwords[i];
            if(i) e[i].newLine = 1;
          }
          text.elements = e;
          text.numelements = 5;
          doTextArea(&text);
          drawFkeyLabels(0x036F, 0, 0, 0, 0, 0x02B9); // <, REPEAT (white)
          while(1) {
            int key;
            mGetKey(&key);
            if(key == KEY_CTRL_F6) break;
            if(key == KEY_CTRL_F1 || key == KEY_CTRL_EXIT) {
              inscreen = 0;
              break;
            }
          }
        }
        break;
    }
  }
}
int balanceManagerChild(Menu* menu, char* currentWallet) {
  Currency balance;
  getWalletBalance(&balance, currentWallet);
  char balanceStr[15];
  currencyToString(balanceStr, &balance);
  char subtitle[21];
  strcpy(subtitle, (char*)"Balance: ");
  strcat(subtitle, balanceStr);
  Transaction txs[MAX_DAY_EVENTS];
  char menulabels[MAX_DAY_EVENTS][44];
  menu->numitems = getWalletTransactions(currentWallet, txs);
  MenuItem items[menu->numitems];
  for(int i = 0; i < menu->numitems; i++) {
    char amount[15];
    currencyToString(amount, &txs[i].amount);

    // build menu item so that the text is cut and the values aligned on the right column
    // independently of the description containing multibyte chars and their location
    char* s = txs[i].description;
    int len = 0, glen = 0;
    while(*s) {
      len++;
      glen++;
      if(MB_IsLead(*s)) glen--;
      if(glen >= 14) { // this way we only care about the section that is to be displayed
        break;
      }
      s++;
    }
    memset(menulabels[i], ' ', 43); // blank parts that would not be touched
    int offset = len-glen;
    memcpy(menulabels[i], txs[i].description, (glen > 14 ? 14+offset : len));
    if(MB_IsLead(menulabels[i][14+offset]))
      menulabels[i][14+offset] = ' '; // eliminate half-MB char
    strncpy(menulabels[i]+15+offset, amount, 6);
    menulabels[i][21+offset] = 0;

    if(txs[i].credit) items[i].color = TEXT_COLOR_GREEN;
    else items[i].color = TEXT_COLOR_RED;
    items[i].text = menulabels[i];
  }
  menu->items = items;
  while(1) {
    Bdisp_AllClr_VRAM();
    drawScreenTitle("Balance Manager", subtitle);
    // VIEW, INSERT, EDIT, DELETE, empty, LOAD
    drawFkeyLabels(-1, 0x03B4, -1, -1, -1, 0x03B7);
    if(menu->numitems > 0) drawFkeyLabels(0x049F, -1, 0x0038);
    int res = doMenu(menu);
    switch(res) {
      case MENU_RETURN_EXIT:
        return 0;
        break;
      case KEY_CTRL_F1:
      case MENU_RETURN_SELECTION:
        if(menu->numitems) viewTransaction(&txs[menu->selection-1]);
        break;
      case KEY_CTRL_F2:
        if(addTransactionWizard(currentWallet)) {
          return 1;
        }
        break;
      case KEY_CTRL_F3:
      case KEY_CTRL_DEL:
        if(menu->numitems &&
           deleteTransactionPrompt(txs, currentWallet, menu->numitems, menu->selection-1)) {
          return 1;
        }
        break;
      case KEY_CTRL_F6:
        if(changeWalletScreen(currentWallet)) {
          menu->selection = 0;
          menu->scroll = 0;
          return 1;
        }
        break;
    }
  }
  return 0;
}
Exemple #29
0
int memory_user_select(char **files, int n, int extension, int exit)
{
  const unsigned char icons[7][32] = {
  { 0x0,0x3c,0xf,0xc4,0xf0,0x4,0x80,0x4,0x80,0x2,0x80,0x2,0x40,0x2,0x40,0x2,0x40,0x2,0x40,0x2,0x40,0x1,0x40,0x1,0x20,0x1,0x20,0xf,0x23,0xf0,0x3c,0x0 },
  { 0x0,0x3c,0xf,0xc4,0xf0,0x4,0x80,0x74,0x87,0x82,0x98,0x2,0x40,0x2,0x40,0x3a,0x43,0xc2,0x5c,0x2,0x40,0x39,0x43,0xc1,0x2c,0x1,0x20,0xf,0x23,0xf0,0x3c,0x0 },
  { 0x0,0x3c,0xf,0xc4,0xf0,0x74,0x87,0x94,0xb8,0x12,0xa0,0xa,0x63,0x8a,0x52,0x8a,0x54,0x4a,0x54,0x66,0x54,0x25,0x48,0x1d,0x29,0xe1,0x2e,0xf,0x23,0xf0,0x3c,0x0 },
  { 0x0,0x3c,0xf,0xc4,0xf0,0x4,0x87,0xc4,0x88,0x22,0x8c,0x62,0x4b,0xa2,0x44,0x42,0x42,0x82,0x42,0x82,0x42,0x81,0x44,0x41,0x2f,0xe1,0x20,0xf,0x23,0xf0,0x3c,0x0 },
  { 0x0,0x3c,0xf,0xc4,0xf0,0x4,0x87,0xe4,0x88,0x12,0x88,0x12,0x48,0x12,0x47,0xe2,0x44,0x22,0x44,0x22,0x44,0x21,0x44,0x21,0x23,0xc1,0x20,0xf,0x23,0xf0,0x3c,0x0 },
  { 0x0,0x3c,0xf,0xc4,0xf0,0x4,0x80,0x64,0x87,0xb2,0x98,0x52,0x51,0xb2,0x57,0x52,0x51,0xd2,0x4b,0xa,0x48,0x19,0x49,0xe1,0x2e,0x1,0x20,0xf,0x23,0xf0,0x3c,0x0 },
  { 0x0,0x3c,0xf,0xc4,0xf0,0x4,0x80,0xe4,0x9c,0xa2,0x90,0xa2,0x58,0xe2,0x50,0x2,0x40,0x12,0x4a,0x2a,0x4a,0x39,0x4e,0x29,0x22,0x1,0x20,0xf,0x23,0xf0,0x3c,0x0 } };
  char *exts[19] = { ".txt", ".c", ".h", ".cpp", ".hpp", ".bmp",".jpg",".png",".gif", ".sav", ".g1m",".g2m",".g1r",".g2r", ".g1e",".g2e",".g1a", ".hex",".bin" };
  unsigned char indexs[19] = { 1,1,1,1,1, 2,2,2,2, 3, 4,4,4,4, 5,5,5, 6,6 };
  unsigned char *icoind = malloc(n);
  unsigned int key;

  int i,j,k,t;
  int p=0, offset=0;

  if(!icoind) { memory_error("user_sele.()","malloc()",1); return -2; }

  for(i=0;i<n;i++)
  {
    for(t=-1,j=0;*(*(files+i)+j);j++) if(*(*(files+i)+j) == '.') t = j;
    icoind[i] = (t==-1?1:0);
    for(k=0;k<19;k++)
      if(!strcmp(*(files+i)+t,exts[k])) { icoind[i]=indexs[k]; break; }
    if(!extension && t+1) *(*(files+i)+t) = 0;
  }

  while(1)
  {
    Bdisp_AllClr_VRAM();

    for(t=0;t<(n>3?3:n);t++)
    {
      if(icoind[offset+i]!=255) for(i=0;i<32;i++) {
        k = icons[icoind[offset+t]][i];
        for(j=0;j<8;j++) {
          if(k&1) Bdisp_SetPoint_VRAM(11-j+8*(i&1),20*t+4+(i>>1),1);
          k >>= 1; } }
      PrintXY(24,20*t+9,(const unsigned char *)*(files+offset+t),0);
    }
    Bdisp_DrawLineVRAM(2,20*p+3,2,20*p+20);
    Bdisp_DrawLineVRAM(3,20*p+2,99,20*p+2);
    Bdisp_DrawLineVRAM(3,20*p+21,99,20*p+21);
    Bdisp_DrawLineVRAM(100,20*p+3,100,20*p+20);
    if(offset>0) PrintXY(114,6,(const unsigned char *)"\346\234",0);
    if(offset+3<n) PrintXY(114,51,(const unsigned char *)"\346\235",0);

    while(1)
    {
      GetKey(&key);
      if(key==30002 && exit) { free(icoind); return -1; }
      if(key==30004) break;
      if(key==30018 && (offset||p))    { if(p==2) p--; else if(offset)     offset--; else p--; break; }
      if(key==30023 && (offset+p+1<n)) { if(p==0) p++; else if(offset+3<n) offset++; else p++; break; }
    }

    if(key==30004) break;
  }

  free(icoind);
  return offset+p;
}
Exemple #30
0
int Explorer( int size, char *folder )
{
	int top, redraw;
	int i;
	unsigned int key;
	
	redraw = 1;
	top = index;
	
	while(1)
	{
		if( redraw )
		{
			Bdisp_AllClr_VRAM();
			//DrawPicture( 1, 56, 61, 8, graph_bar );
			PrintMini(1, 58, (unsigned char*)" EXE ", MINI_REV) ; 
			PrintMini(105, 58, (unsigned char*)" EXIT ", MINI_REV) ; 
			locate(1, 1);Print((unsigned char*)"File List  [        ]");
			locate(13, 1);Print( strlen(folder) ? (unsigned char*)folder : (unsigned char*)"Root");
			if( size < 1 ){
				locate( 8, 4 );
				Print( (unsigned char*)"No Data" );
			}
			else{			
				if( top > index )
					top = index;
				if( index > top + N_LINE - 1 )
					top = index - N_LINE + 1;
				if( top < 0 )
					top = 0;
	
				for(i = 0;i < N_LINE && i + top < size; ++i ){
					locate( 1, i + 2 );
					if( files[i + top].filesize == -1 )
						pPrintf( " [%s]", files[i + top].filename );
					else
						pPrintf( " %-12s:%6u ", files[i + top].filename, files[i + top].filesize );
				}
				Bdisp_AreaReverseVRAM( 0, (index-top+1)*8 , 127, (index-top+2)*8-1 );
				if( top > 0 )
					PrintXY( 120, 8, (unsigned char*)"\xE6\x92", top == index );
				if( top + N_LINE < size  )
					PrintXY( 120, N_LINE*8, (unsigned char*)"\xE6\x93" , top + N_LINE - 1 == index );
			}
			redraw = 0;
		}
		GetKey(&key);
		if( key==KEY_CTRL_UP ){
			if( --index < 0 )
				index = size - 1;
			redraw = 1;
		}
		else if( key==KEY_CTRL_DOWN ){
			if( ++index > size - 1 )
				index = 0;
			redraw = 1;
		}
		else if( key==KEY_CTRL_EXE || key == KEY_CTRL_F1)
			break;
		else if( key == KEY_CTRL_F2 ){
			//Help();
			redraw = 1;
		}
		else if( key == KEY_CTRL_F3 ){
			//About();
			redraw = 1;
		}		
		else if( key==KEY_CTRL_EXIT){
			index = size;
			break;
		}
	}
}