Exemplo n.º 1
0
int createWalletWizard(int isFirstUse) {
  SetBackGround(0x0A);
  drawScreenTitle("Create wallet", "Name:");
  drawFkeyLabels(0, 0, 0, 0, 0, 0x04A3);
  if(isFirstUse) {
    multiPrintMini(0, 5*24, "To use the balance manager, start by\n"
                            "creating a wallet.");
  }
  char wallet[MAX_WALLETNAME_SIZE+2] = "";
  textInput input;
  input.charlimit=MAX_WALLETNAME_SIZE;
  input.acceptF6=1;
  input.forcetext=1;
  input.symbols = 0;
  input.buffer = (char*)wallet;
  while(1) {
    input.key=0;
    int res = doTextInput(&input);
    if (res==INPUT_RETURN_EXIT) return -1; // user aborted
    else if (res==INPUT_RETURN_CONFIRM) break; // continue to next step
  }

  SetBackGround(0x0A);
  drawScreenTitle("Create wallet", "Initial balance:");
  drawFkeyLabels(-1, -1, -1, -1, -1, 0x04A4);
  char balance[20] = "";
  Currency initialBalance;
  textInput input2;
  input2.charlimit=12;
  input2.acceptF6=1;
  input2.symbols = 0; // allow the decimal separator
  input2.buffer = (char*)balance;
  input2.type = INPUTTYPE_NUMERIC;
  while(1) {
    input2.key=0;
    int res = doTextInput(&input2);
    if (res==INPUT_RETURN_EXIT) return -1; // user aborted
    else if (res==INPUT_RETURN_CONFIRM) {
      if(!stringToCurrency(&initialBalance, balance)) break;
      else AUX_DisplayErrorMessage(0x43);
    }
  }
  createWallet(wallet, &initialBalance);
  if(isFirstUse) {
    char fname[MAX_FILENAME_SIZE];
    walletNameToPath(fname, wallet);
    setCurrentWallet(fname);
  }
  return 0;
}
Exemplo n.º 2
0
int renameWalletScreen(char* wallet, char* newWallet) {
  // reload the wallets array after using this function!
  // newWallet will receive the new file name (complete, not friendly)
  // returns 0 if user aborts, 1 if renames.
  SetBackGround(6);
  clearLine(1,8);
  char title[MAX_WALLETNAME_SIZE+6];
  strcpy(title, wallet);
  strcat(title, " to:");
  drawScreenTitle("Rename wallet", title);
  char newname[MAX_WALLETNAME_SIZE];
  strcpy(newname, wallet);
  textInput input;
  input.forcetext=1;
  input.symbols = 0;
  input.charlimit=MAX_WALLETNAME_SIZE;
  input.buffer = (char*)newname;
  while(1) {
    input.key=0;
    int res = doTextInput(&input);
    if (res==INPUT_RETURN_EXIT) return 0; // user aborted
    else if (res==INPUT_RETURN_CONFIRM) {
      char fwallet[MAX_FILENAME_SIZE];
      walletNameToPath(newWallet, newname);
      walletNameToPath(fwallet, wallet);
      renameFile(fwallet, newWallet);
      return 1;
    }
  }
  return 0;
}
Exemplo n.º 3
0
MenuScreen::MenuScreen()
{
	game = NULL;
	app = NULL;
	
	Player *p1 = new Player;
	Player *p2 = new Player;
	Player *p3 = new Player;
	Player *p4 = new Player;
	Player *p5 = new Player;

	p1->Init("monster1.png");
	p2->Init("monster2.png");
	p3->Init("monster3.png");
	p4->Init("monster4.png");
	p5->Init("monster5.png");

	p1->SetPosition((float)((Iw2DGetSurfaceWidth()/2)-65),(float)(Iw2DGetSurfaceHeight()/2-58));
	p2->SetPosition((float)((Iw2DGetSurfaceWidth()/2)+10),(float)(Iw2DGetSurfaceHeight()/2-58));
	p3->SetPosition((float)((Iw2DGetSurfaceWidth()/2)-92),(float)(Iw2DGetSurfaceHeight()/2+10));
	p4->SetPosition((float)((Iw2DGetSurfaceWidth()/2)-28),(float)(Iw2DGetSurfaceHeight()/2+10));
	p5->SetPosition((float)((Iw2DGetSurfaceWidth()/2)+38),(float)(Iw2DGetSurfaceHeight()/2+10));

	Background *bg = new Background;
	bg->Init("bg2.png",(float)Iw2DGetSurfaceWidth(),(float)Iw2DGetSurfaceHeight(),true);

	SetBackGround(bg);
	AddPlayer("monster1",p1);
	AddPlayer("monster2",p2);
	AddPlayer("monster3",p3);
	AddPlayer("monster4",p4);
	AddPlayer("monster5",p5);
}
Exemplo n.º 4
0
BOOL CDisplayDlg::OnInitDialog() 
{
	SetBackGround(IDB_DD_BACKGROUND);

	if (!g_pDisplayMgr)
	{
		g_pDisplayMgr = new CDisplayMgr();
		if (!g_pDisplayMgr->Init("", "display.cfg"))
		{
			OnDestroy();
			return TRUE;
		}
	}

	
	CMoveDialog::OnInitDialog();

	AddButton(IDC_DD_CLOSE,DD_CLOSE_X,DD_CLOSE_Y);
	AddButton(IDC_DD_OK,DD_OK_X,DD_OK_Y);
	AddButton(IDC_DD_CANCEL,DD_CANCEL_X,DD_CANCEL_Y);

	CWnd* pWnd = GetDlgItem(IDC_RENDERER_LIST);
	if(pWnd)
	{
		//pWnd->SetFont(&theApp.m_Font);
		pWnd->SetWindowPos(NULL,DD_RENDERER_LIST_X,DD_RENDERER_LIST_Y,DD_RENDERER_LIST_WIDTH,DD_RENDERER_LIST_HEIGHT,SWP_NOZORDER);
	}
	pWnd = GetDlgItem(IDC_DISPLAY_LIST);
	if(pWnd)
	{
		//pWnd->SetFont(&theApp.m_Font);
		pWnd->SetWindowPos(NULL,DD_DISPLAY_LIST_X,DD_DISPLAY_LIST_Y,DD_DISPLAY_LIST_WIDTH,DD_DISPLAY_LIST_HEIGHT,SWP_NOZORDER);
	}
	pWnd = GetDlgItem(IDC_RESOLUTION_LIST);
	if(pWnd)
	{
		//pWnd->SetFont(&theApp.m_Font);
		pWnd->SetWindowPos(NULL,DD_RESOLUTION_LIST_X,DD_RESOLUTION_LIST_Y,DD_RESOLUTION_LIST_WIDTH,DD_RESOLUTION_LIST_HEIGHT,SWP_NOZORDER);
	}

	if (g_pDisplayMgr->GetNumRenderers() <= 0)
	{
		theApp.MessageBox( IDS_NORENS, IDS_GAME_NAME, MB_OK | MB_ICONSTOP );
		return(0);
	}

	g_pDisplayMgr->FillListBoxes(GetDlgItem(IDC_RENDERER_LIST)->GetSafeHwnd(), GetDlgItem(IDC_DISPLAY_LIST)->GetSafeHwnd(), GetDlgItem(IDC_RESOLUTION_LIST)->GetSafeHwnd());
	g_pDisplayMgr->UpdateListSelections(GetDlgItem(IDC_RENDERER_LIST)->GetSafeHwnd(), GetDlgItem(IDC_DISPLAY_LIST)->GetSafeHwnd(), GetDlgItem(IDC_RESOLUTION_LIST)->GetSafeHwnd());

	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Exemplo n.º 5
0
void KX_KetsjiEngine::ClearFrame()
{
	// clear unless we're drawing overlapping stereo
	if(m_rasterizer->InterlacedStereo() &&
		m_rasterizer->GetEye() == RAS_IRasterizer::RAS_STEREO_RIGHTEYE)
		return;

	// clear the viewports with the background color of the first scene
	bool doclear = false;
	KX_SceneList::iterator sceneit;
	RAS_Rect clearvp, area, viewport;

	for (sceneit = m_scenes.begin(); sceneit != m_scenes.end(); sceneit++)
	{
		KX_Scene* scene = *sceneit;
		//const RAS_FrameSettings &framesettings = scene->GetFramingType();
		list<class KX_Camera*>* cameras = scene->GetCameras();

		list<KX_Camera*>::iterator it;
		for(it = cameras->begin(); it != cameras->end(); it++)
		{
			GetSceneViewport(scene, (*it), area, viewport);

			if(!doclear) {
				clearvp = viewport;
				doclear = true;
			}
			else {
				if(viewport.GetLeft() < clearvp.GetLeft())
					clearvp.SetLeft(viewport.GetLeft());
				if(viewport.GetBottom() < clearvp.GetBottom())
					clearvp.SetBottom(viewport.GetBottom());
				if(viewport.GetRight() > clearvp.GetRight())
					clearvp.SetRight(viewport.GetRight());
				if(viewport.GetTop() > clearvp.GetTop())
					clearvp.SetTop(viewport.GetTop());

			}
		}
	}

	if(doclear) {
		KX_Scene* firstscene = *m_scenes.begin();
		SetBackGround(firstscene->GetWorldInfo());

		m_canvas->SetViewPort(clearvp.GetLeft(), clearvp.GetBottom(),
			clearvp.GetRight(), clearvp.GetTop());	
		m_rasterizer->ClearColorBuffer();
	}
}
Exemplo n.º 6
0
void GameScreen::Init(std::string name)
{
	Player *p1 = new Player;
	p1->Init(name+".png");

	p1->SetPosition((float)((Iw2DGetSurfaceWidth()/2)-28),(float)(Iw2DGetSurfaceHeight()/2-28));
	p1->SetTarget(p1->GetPosition().x,p1->GetPosition().y);
	p1->SetVelocity(1,1);
	Background *bg = new Background;
	bg->Init("bg.png",(float)Iw2DGetSurfaceWidth(),(float)Iw2DGetSurfaceHeight());

	SetBackGround(bg);
	player = name;
	warpID = name + genRandom();
	AddPlayer(warpID,p1);

	WarpClientRef->connect(warpID);
}
Exemplo n.º 7
0
int renameTOTPscreen(int index, char* oldname) {
  //reload the files array after using this function!
  //returns 0 if user aborts, 1 if renames.
  SetBackGround(6);
  clearLine(1,8);
  drawScreenTitle("Rename TOTP token");
  char newname[25];
  strcpy(newname, oldname);
  textInput input;
  input.forcetext=1;
  input.charlimit=21;
  input.buffer = (char*)newname;
  while(1) {
    input.key=0;
    int res = doTextInput(&input);
    if (res==INPUT_RETURN_EXIT) return 0; // user aborted
    else if (res==INPUT_RETURN_CONFIRM) {
      renameTOTP(index, newname);
      return 1;
    }
  }
  return 0;
}
Exemplo n.º 8
0
void textfileEditor(char* filename, char* basefolder) {
  int newfile = (filename == NULL);
  char sText[TEXT_BUFFER_SIZE] = "";
  if(!newfile) {
    newfile = 0;
    int openerror = 0;
    int hFile = fileOpen(filename); // Get handle
    if(hFile >= 0) // Check if it opened
    { //opened
      unsigned int filesize = Bfile_GetFileSize_OS(hFile);
      if(!filesize || filesize > TEXT_BUFFER_SIZE) {
        openerror = 1;
      } else {
        Bfile_ReadFile_OS(hFile, sText, TEXT_BUFFER_SIZE, 0);
      }
      Bfile_CloseFile_OS(hFile);
    } else {
      openerror = 1;
    }
    if(openerror) {
      //Error opening file, abort
      AUX_DisplayErrorMessage(0x2B); // Data ERROR
      return;
    }
  }
  textEdit input;
  //input.forcetext=1;
  input.charlimit=TEXT_BUFFER_SIZE;
  input.buffer = (char*)sText;

  // calculate checksum so we can check for changes
  unsigned char origHash[20] = "";
  sha1((unsigned char*)sText, strlen(sText), origHash);
  while(1) {
    input.key=0;
    int res = doTextEdit(&input);
    int exit = 0;
    switch(res) {
      case TEXTEDIT_RETURN_EXIT:
      {
        exit = 1;
        unsigned char newHash[20] = "";
        sha1((unsigned char*)sText, strlen(sText), newHash);
        if(!memcmp(origHash, newHash, 20)) return;
        else {
          mMsgBoxPush(4);
          mPrintXY(3, 2, "Save this file?", TEXT_MODE_TRANSPARENT_BACKGROUND,
                   TEXT_COLOR_BLACK);
          if(closeMsgBox(1, 4)) {
            // fall through
          } else {
            return;
          }
        }
      }
      case TEXTEDIT_RETURN_CONFIRM:
      {
        char newfilename[MAX_FILENAME_SIZE];
        unsigned short newfilenameshort[0x10A];
        if(newfile) {
          int backToEditor = 0;
          SetBackGround(13);
          drawScreenTitle("Text Editor", "Save file as:");
          drawFkeyLabels(0x036F); // <
          textInput ninput;
          ninput.forcetext=1;
          ninput.charlimit=MAX_NAME_SIZE;
          char nfilename[MAX_NAME_SIZE];
          nfilename[0] = 0;
          ninput.buffer = (char*)nfilename;
          while(1) {
            ninput.key = 0;
            int nres = doTextInput(&ninput);
            if (nres==INPUT_RETURN_EXIT || (nres==INPUT_RETURN_KEYCODE && ninput.key==KEY_CTRL_F1)) {
              // user aborted
              backToEditor = 1;
              break;
            } else if (nres==INPUT_RETURN_CONFIRM) {
              if(stringEndsInG3A(nfilename)) {
                mMsgBoxPush(4);
                multiPrintXY(3, 2, "g3a files can't\nbe created by\nan add-in.",
                             TEXT_MODE_TRANSPARENT_BACKGROUND, TEXT_COLOR_BLACK);
                closeMsgBox();
              } else {
                // create and save file
                strcpy(newfilename, basefolder);
                strcat(newfilename, nfilename);
                Bfile_StrToName_ncpy(newfilenameshort, newfilename, 0x10A);
                break;
              }
            }
          }
          if(backToEditor) continue;
        } else {
          // delete, then create and save file
          Bfile_StrToName_ncpy(newfilenameshort, filename, 0x10A);
          Bfile_DeleteEntry(newfilenameshort);
        }
        size_t size = strlen(sText);
        if(Bfile_CreateEntry_OS(newfilenameshort, CREATEMODE_FILE, &size) < 0) { //create the file
          // it appears file exists, overwrite?
          if(overwriteFilePrompt(newfilename)) {
            Bfile_DeleteEntry(newfilenameshort);
            Bfile_CreateEntry_OS(newfilenameshort, CREATEMODE_FILE, &size);
          }
          else continue; // abort file save so user can discard the file, or type another filename.
        }
        
        int h = Bfile_OpenFile_OS(newfilenameshort, READWRITE, 0);
        if(h >= 0) { // Still failing?
          //Write file contents
          Bfile_WriteFile_OS(h, sText, size);
          Bfile_CloseFile_OS(h);
          // clear unsaved changes "flag":
          sha1((unsigned char*)sText, strlen(sText), origHash);
        }
        if(exit) return;
      }
      break;
    }
  }
}
Exemplo n.º 9
0
int addTOTPwizard() {
  char friendlyname[25] = "";
  char key[32] = "";
  int curstep = 0;
  while(1) {
    SetBackGround(0x0A);
    drawScreenTitle("Add TOTP token");
    // < (first label) and Next or Finish (last label)
    drawFkeyLabels((curstep>0 ? 0x036F : 0), 0, 0, 0, 0, (curstep==1 ? 0x04A4 : 0x04A3));
    if(curstep == 0) {
      drawScreenTitle(NULL, "Friendly name:");
      textInput input;
      input.charlimit=21;
      input.acceptF6=1;
      input.forcetext = 1;
      input.buffer = friendlyname;
      while(1) {
        input.key=0;
        int res = doTextInput(&input);
        if (res==INPUT_RETURN_EXIT) return 0; // user aborted
        else if (res==INPUT_RETURN_CONFIRM) {
          curstep++;
          break;
        }
      }
    } else if(curstep == 1) {
      drawScreenTitle(NULL, "Base32 key:");
      multiPrintMini(0, 3*24+2, "This is often shown as a QR code.\n"
                                "Try looking for the \"I can't scan a QR\n"
                                "code\" option. A key usually looks\n"
                                "like this: JBSWY3DPEHPK3PXP\n"
                                "Some keys are longer.");
      textInput input;
      input.charlimit=32;
      input.acceptF6=1;
      input.symbols = 0;
      input.forcetext = 1;
      input.buffer = key;
      int inloop = 1;
      while(inloop) {
        input.key=0;
        int res = doTextInput(&input);
        if (res==INPUT_RETURN_EXIT) return 0; // user aborted
        else if (res==INPUT_RETURN_CONFIRM) {
          char* b = key;
          for(; *b; b++) {
            *b = toupper(*b);
            // commonly mistyped characters:
            if(*b == '0') *b = 'O';
            if(*b == '1') *b = 'I';
          }
          if(base32_validate(key)) {
            inloop = 0; // all fields complete, continue with token adding
          } else {
            AUX_DisplayErrorMessage(0x3E);
          }
        }
        else if (res==INPUT_RETURN_KEYCODE && input.key == KEY_CTRL_F1) {
          curstep--;
          break;
        }
      }
      if(!inloop) break;
    }
  }
  addTOTP(friendlyname, key);
  return 1;
}
Exemplo n.º 10
0
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;
    }
  }
}
Exemplo n.º 11
0
int addTransactionWizard(char* wallet) {
  Transaction tx;
  tx.date.year = getCurrentYear();
  tx.date.month = getCurrentMonth();
  tx.date.day = getCurrentDay();
  tx.time.hour = getCurrentHour();
  tx.time.minute = getCurrentMinute();
  tx.time.second = getCurrentSecond();
  strcpy(tx.description, (char*)"");
  int curstep = 0;
  while(1) {
    SetBackGround(0x0A);
    drawScreenTitle("Add transaction");
    // < (first label), SELECT of on date step, and Next or Finish (last label)
    drawFkeyLabels(curstep>0 ? 0x036F : -1, curstep == 2 ? 0x000F : 0, 0, 0, 0,
                   curstep==4 ? 0x04A4 : 0x04A3);
    if(curstep == 0) {
      MenuItem menuitems[5];
      menuitems[0].text = (char*)"Debit";
      menuitems[1].text = (char*)"Credit";

      Menu menu;
      menu.items=menuitems;
      menu.type=MENUTYPE_FKEYS;
      menu.numitems=2;
      menu.height=2;
      menu.startY=3;
      menu.pBaRtR=1;
      int inloop=1;
      while(inloop) {
        // this must be here, inside this loop:
        SetBackGround(0x0A);
        drawScreenTitle("Add transaction", "Select type:");
        drawFkeyLabels(-1, -1, -1, -1, -1, 0x04A3);
        int res = doMenu(&menu);
        if(res == MENU_RETURN_EXIT) return 0;
        else if(res == KEY_CTRL_F6 || res == MENU_RETURN_SELECTION) {
          tx.credit = menu.selection == 2;
          curstep++;
          break;
        }
      }
    } else if(curstep == 1) {
      drawScreenTitle(NULL, "Amount:");
      char samount[20] = "";
      if(tx.amount.val) {
        currencyToString(samount, &tx.amount);
      }
      textInput input;
      input.charlimit=12;
      input.acceptF6=1;
      input.symbols = 0; // allow the decimal separator
      input.forcetext = 1;
      input.buffer = (char*)samount;
      input.type = INPUTTYPE_NUMERIC;
      while(1) {
        input.key=0;
        int res = doTextInput(&input);
        if (res==INPUT_RETURN_EXIT) return 0; // user aborted
        else if (res==INPUT_RETURN_CONFIRM) {
          if(!stringToCurrency(&tx.amount, samount)) {
            if(!tx.amount.val) {
              AUX_DisplayErrorMessage(0x4B);
            } else {
              curstep++;
            }
            break;
          } else AUX_DisplayErrorMessage(0x43);
        } else if (res==INPUT_RETURN_KEYCODE && input.key == KEY_CTRL_F1) {
          curstep--;
          break;
        }
      }
    } else if(curstep == 2) {
      drawScreenTitle(NULL, "Date:");
      mPrintXY(7, 4, getInputDateFormatHint(), TEXT_MODE_TRANSPARENT_BACKGROUND, TEXT_COLOR_BLACK);
      textInput input;
      input.x=7;
      input.width=8;
      input.charlimit=8;
      input.acceptF6=1;
      input.type=INPUTTYPE_DATE;
      char datebuffer[15];
      fillInputDate(&tx.date, datebuffer);
      input.buffer = (char*)datebuffer;
      while(1) {
        input.key=0;
        int res = doTextInput(&input);
        if (res==INPUT_RETURN_EXIT) return 0; // user aborted
        else if (res==INPUT_RETURN_CONFIRM) {
          int len = strlen(datebuffer);
          if(len == input.charlimit) {
            int yr,m,d;
            stringToDate(datebuffer, &yr, &m, &d);
            if(isDateValid(yr, m, d)) {
                tx.date.year = yr;
                tx.date.month = m;
                tx.date.day = d;
                curstep++;
                break; // continue to next step
            } else invalidFieldMsg(0);
          } else invalidFieldMsg(0);
        } else if (res==INPUT_RETURN_KEYCODE) {
          if(input.key==KEY_CTRL_F1) {
            curstep=curstep-1; break;
          } else if(input.key==KEY_CTRL_F2) {
            int ey=0, em=0, ed=0;
            if(!selectDateScreen(&ey, &em, &ed,
                                  (char*)"Select transaction date:", NULL, 1)) {
              tx.date.year = ey;
              tx.date.month = em;
              tx.date.day = ed;
              curstep++; break; // continue to next step
            }
            break; //redraw
          }
        }
      }
    } else if(curstep == 3) {
      drawScreenTitle(NULL, "Time:");
      mPrintXY(8, 4, "HHMMSS", TEXT_MODE_TRANSPARENT_BACKGROUND, TEXT_COLOR_BLACK);
      
      textInput input;
      input.x=8;
      input.width=6;
      input.charlimit=6;
      input.acceptF6=1;
      input.type=INPUTTYPE_TIME;
      char tbuffer[15];
      fillInputTime(&tx.time, tbuffer);
      input.buffer = (char*)tbuffer;
      while(1) {
        input.key=0;
        int res = doTextInput(&input);
        if (res==INPUT_RETURN_EXIT) return 0; // user aborted
        else if (res==INPUT_RETURN_CONFIRM) {
          if((int)strlen(tbuffer) == input.charlimit) {
            int h, m, s;
            stringToTime(tbuffer, &h, &m, &s);
            if(isTimeValid(h, m, s)) {
              tx.time.hour = h;
              tx.time.minute = m;
              tx.time.second = s;
              curstep++;
              break; // continue to next step
            } else invalidFieldMsg(1);
          } else invalidFieldMsg(1);
        } 
        else if (res==INPUT_RETURN_KEYCODE && input.key==KEY_CTRL_F1) { curstep--; break; }
      }
    } else if(curstep == 4) {
      drawScreenTitle(NULL, "Description:");
      textInput input;
      input.charlimit=128;
      input.acceptF6=1;
      input.buffer = (char*)tx.description;
      int inloop = 1;
      while(inloop) {
        input.key=0;
        int res = doTextInput(&input);
        if (res==INPUT_RETURN_EXIT)
          return 0; // user aborted
        else if (res==INPUT_RETURN_CONFIRM)
          inloop = 0; // all fields complete, continue with transaction adding
        else if (res==INPUT_RETURN_KEYCODE && input.key == KEY_CTRL_F1) {
          curstep--;
          break;
        }
      }
      if(!inloop) break;
    }
  }
  addTransaction(&tx, wallet);
  return 1;
}