示例#1
0
CapriceLoadSave::CapriceLoadSave(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine) :
  CFrame(WindowRect, pParent, pFontEngine, "Load / Save", false)
{
  SetModal(true);
  // Make this window listen to incoming CTRL_VALUECHANGE messages (used for updating drop down values)
  CMessageServer::Instance().RegisterMessageClient(this, CMessage::CTRL_VALUECHANGE);
  CMessageServer::Instance().RegisterMessageClient(this, CMessage::CTRL_VALUECHANGING);

  // File type (.SNA, .DSK, .TAP, .VOC)
  m_pTypeLabel = new CLabel(          CPoint(15, 25),             this, "File type: ");
  m_pTypeValue = new CDropDown( CRect(CPoint(80, 20), 150, 20),    this, false);
#ifndef WITH_IPF
  m_pTypeValue->AddItem(SListItem("Drive A (.dsk)"));
  m_pTypeValue->AddItem(SListItem("Drive B (.dsk)"));
#else
  m_pTypeValue->AddItem(SListItem("Drive A (.dsk/.ipf)"));
  m_pTypeValue->AddItem(SListItem("Drive B (.dsk/.ipf)"));
#endif
  m_pTypeValue->AddItem(SListItem("Snapshot (.sna)"));
  m_pTypeValue->AddItem(SListItem("Tape (.cdt/.voc)"));
  m_pTypeValue->AddItem(SListItem("Cartridge (.cpr)"));
  m_pTypeValue->SetListboxHeight(5);
  m_pTypeValue->SelectItem(0);
  m_pTypeValue->SetIsFocusable(true);
  m_fileSpec = { ".dsk", ".zip" };

  // Action: load / save
  m_pActionLabel = new CLabel(          CPoint(15, 55),             this, "Action: ");
  m_pActionValue = new CDropDown( CRect(CPoint(80, 50), 150, 20),   this, false);
  m_pActionValue->AddItem(SListItem("Load"));
  m_pActionValue->AddItem(SListItem("Save"));
  m_pActionValue->SetListboxHeight(2);
  m_pActionValue->SelectItem(0);
  m_pActionValue->SetIsFocusable(true);

  // Directory
  m_pDirectoryLabel = new CLabel(          CPoint(15, 85),             this, "Directory: ");
  m_pDirectoryValue = new CEditBox( CRect( CPoint(80, 80), 150, 20),    this);
  m_pDirectoryValue->SetWindowText(simplifyDirPath(CPC.current_dsk_path));
  m_pDirectoryValue->SetReadOnly(true);

  // File list
  m_pFilesList = new CListBox(CRect(CPoint(80, 115), 150, 80), this, true, 12);
  m_pFilesList->SetIsFocusable(true);
  UpdateFilesList();

  // File name
  m_pFileNameLabel  = new CLabel(          CPoint(15, 215),              this, "File: ");
  m_pFileNameValue  = new CEditBox( CRect( CPoint(80, 210), 150, 20),    this);
  m_pFileNameValue->SetWindowText("");
  m_pFileNameValue->SetReadOnly(true);

  // Buttons
  m_pCancelButton   = new CButton(  CRect( CPoint(250, 180), 50, 20), this, "Cancel");
  m_pCancelButton->SetIsFocusable(true);
  m_pLoadSaveButton = new CButton(  CRect( CPoint(250, 210), 50, 20), this, "Load");
  m_pLoadSaveButton->SetIsFocusable(true);
}
示例#2
0
CapriceOpenDisk::CapriceOpenDisk(const CRect& WindowRect, CWindow* pParent, CFontEngine* pFontEngine, std::string sTitle, int selectedDrive, t_drive* Drive) :
	CFrame(WindowRect, pParent, pFontEngine, sTitle, false)
{
	pDrive=Drive;
    selDrive = selectedDrive;
    if (selDrive)
	 {
	 	DrivePath = CPC.drvB_path;
	 	DriveFile = CPC.drvB_file;
	 	SetWindowText("Drive B Loader ");
	 } else
	 {
	 	DrivePath = CPC.drvA_path;
	 	DriveFile = CPC.drvA_file;
	 	SetWindowText("Drive A Loader");
	 }

	m_pButtonOpen = new CButton(CRect(CPoint( 40, m_ClientRect.Height() - 22), 50, 15), this, "Open");
	m_pButtonClear  = new CButton(CRect(CPoint(100, m_ClientRect.Height() - 22), 50, 15), this, "Clear");
	m_pButtonCancel = new CButton(CRect(CPoint(160, m_ClientRect.Height() - 22), 50, 15), this, "Cancel");

	m_pListBoxDisk = new CListBox(CRect(CPoint(10, 10), m_ClientRect.Width() - 25, 140), this, true);

	std::vector<std::string> diskFiles = getAvailableDisk();
	for (unsigned int i = 0; i < diskFiles.size(); i ++)
	{
		m_pListBoxDisk->AddItem(SListItem(diskFiles.at(i)));
		if (diskFiles.at(i) == DriveFile) { // It's all based on the filename of the ROM,
                                                                    // maybe find a better way.
			m_pListBoxDisk->SetSelection(i, true);
			m_pListBoxDisk->SetFocus(i);
		}
	}
}
示例#3
0
void CapriceLoadSave::UpdateFilesList()
{
  m_pFilesList->ClearItems();

  DIR *dp;
  struct dirent *ep;

  dp = opendir(m_pDirectoryValue->GetWindowText().c_str());
  if(dp == nullptr) {
    std::cerr << "Could not open " << m_pDirectoryValue->GetWindowText() << ": " << strerror(errno) << std::endl;
  } else {
    std::vector<std::string> directories;
    std::vector<std::string> files;
    while((ep = readdir(dp)) != nullptr) {
      std::string entry_name = ep->d_name;
      // ep->d_type is always set to DT_UNKNOWN on my computer => use a call to stat to determine if it's a directory
      struct stat entry_infos;
      std::string full_name = m_pDirectoryValue->GetWindowText() + "/" + entry_name;
      if(stat(full_name.c_str(), &entry_infos) != 0) {
        std::cerr << "Could not retrieve info on " << full_name << ": " << strerror(errno) << std::endl;
      }
      if(/*ep->d_type == DT_DIR*/S_ISDIR(entry_infos.st_mode) && (ep->d_name[0] != '.' || entry_name == "..")) {
        directories.push_back(entry_name + "/");
      } else if(/*ep->d_type == DT_REG*/S_ISREG(entry_infos.st_mode) && MatchCurrentFileSpec(ep->d_name)) {
        files.push_back(entry_name);
      }
    }
    if(closedir(dp) != 0) {
      std::cerr << "Could not close directory: " << strerror(errno) << std::endl;
    }
    std::sort(directories.begin(), directories.end(), stringutils::caseInsensitiveCompare);
    std::sort(files.begin(), files.end(), stringutils::caseInsensitiveCompare);
    for(const auto &directory : directories) {
      m_pFilesList->AddItem(SListItem(directory));
    }
    for(const auto &file : files) {
      m_pFilesList->AddItem(SListItem(file));
    }
  }
}
示例#4
0
CapriceMemoryTool::CapriceMemoryTool(const CRect& WindowRect, CView* pParent, CFontEngine* pFontEngine) :
	CFrame(WindowRect, pParent, pFontEngine, "Memory Tool", false)
{
    m_pMonoFontEngine = CApplication::Instance()->GetFontEngine(std::string(CPC.resources_path) + "/vera_mono.ttf", 8);

    // Make this window listen to incoming KEYBOARD_KEYDOWN messages to capture TAB pressed and change focused field
    CMessageServer::Instance().RegisterMessageClient(this, CMessage::KEYBOARD_KEYDOWN);
    // Make this window listen to incoming CTRL_VALUECHANGING messages for dropdown list update
    CMessageServer::Instance().RegisterMessageClient(this, CMessage::CTRL_VALUECHANGE);
    CMessageServer::Instance().RegisterMessageClient(this, CMessage::CTRL_VALUECHANGING);

    m_pPokeAdressLabel = new CLabel(        CPoint(15, 18),             this, "Adress: ");
    m_pPokeAdress      = new CEditBox(CRect(CPoint(55, 13),  30, 20),   this, NULL);
    m_pPokeValueLabel  = new CLabel(        CPoint(95, 18),             this, "Value: ");
    m_pPokeValue       = new CEditBox(CRect(CPoint(130, 13), 30, 20),   this, NULL);
    m_pButtonPoke      = new CButton( CRect(CPoint(175, 13), 30, 20),   this, "Poke");

    m_pAdressLabel     = new CLabel(        CPoint(15, 50),             this, "Adress: ");
    m_pAdressValue     = new CEditBox(CRect(CPoint(55, 45), 30, 20),    this, NULL);
    m_pButtonDisplay   = new CButton( CRect(CPoint(95, 45), 40, 20),    this, "Display");
    m_pFilterLabel     = new CLabel(        CPoint(15, 80),             this, "Byte: ");
    m_pFilterValue     = new CEditBox(CRect(CPoint(55, 75), 30, 20),    this, NULL);
    m_pButtonFilter    = new CButton( CRect(CPoint(95, 75), 40, 20),    this, "Filter");
    m_pButtonCopy      = new CButton( CRect(CPoint(240, 75), 75, 20),   this, "Dump to stdout");

    m_pBytesPerLineLbl = new CLabel(       CPoint(240, 35),             this, "Bytes per line:");
    m_pBytesPerLine  = new CDropDown( CRect(CPoint(240, 45), 50, 20),   this, NULL, 14);
    m_pBytesPerLine->AddItem(SListItem("1"));
    m_pBytesPerLine->AddItem(SListItem("4"));
    m_pBytesPerLine->AddItem(SListItem("8"));
    m_pBytesPerLine->AddItem(SListItem("16"));
    m_pBytesPerLine->AddItem(SListItem("32"));
    m_pBytesPerLine->AddItem(SListItem("64"));
    m_pBytesPerLine->SetListboxHeight(4);
    m_bytesPerLine = 16;
    m_pBytesPerLine->SelectItem(3);

    // The list box is way to slow to handle so much elements
    //m_pListMemContent  = new CListBox(CRect(CPoint(25, 75), 275, 100), this, true);
    m_pTextMemContent  = new CTextBox(CRect(CPoint(15, 105), 300, 102), this, m_pMonoFontEngine);
    m_pButtonClose     = new CButton( CRect(CPoint(15, 220), 300, 20),  this, "Close");

    m_pPokeAdress->SetContentType(CEditBox::HEXNUMBER);
    m_pPokeValue->SetContentType(CEditBox::HEXNUMBER);
    m_pAdressValue->SetContentType(CEditBox::HEXNUMBER);
    m_pFilterValue->SetContentType(CEditBox::HEXNUMBER);
    m_pTextMemContent->SetReadOnly(true);

    m_filterValue = -1;
    m_displayValue = -1;

    UpdateTextMemory();
}