Exemple #1
0
void djvFileBrowserTest::run(const QStringList & args)
{
    djvFileBrowser fileBrowser(context());

    if (args.count() > 0)
    {
        fileBrowser.setFileInfo(args[0]);
    }
    
    if (QDialog::Accepted == fileBrowser.exec())
    {
        djvSystem::print(fileBrowser.fileInfo());
    }
}
Exemple #2
0
int gui(Exec_info exec_info)
{
	unsigned char path[100] = {'\0'};
	int exec_time, exec_frequency;
	int key = 0;
	int handle = -1;
	nio_DrawConsole(&c1);

	if(exec_info.cycles_count != 0) {
		exec_time = (int)((exec_info.tick_end - exec_info.tick_start)/128);
		exec_frequency = exec_info.cycles_count/(exec_time * 1000);
		nio_printf(&c1, "Game terminated. Execution time : %d s.\n > Average execution frequency : %d kHz\n > ", exec_time, exec_frequency);
	}

#ifndef EMULATOR
	while(handle < 0) {
		nio_GetStr(&c1, path);
		if(!strcmp(path, "exit")) {
			while(1) {
				GetKey(&key);
			}
		}
		else if(!strcmp(path, "help")) nio_printf(&c1, "Type name of the file you want to load\n or, if you want to leave me , write 'exit' :(\n > ");
		else if(!strcmp(path, "fb")) {
#endif
			fileBrowser(path, (unsigned char*)"*.ch", (unsigned char*)"*.CH8", (unsigned char*)"*.ch8", "Files");
			nio_DrawConsole(&c1);
			if(strcmp(path, "")) {
				handle = CC_open_file(path+7);
				if(handle < 0) nio_printf(&c1, "Error opening %s ... Check if the file exists\n > ", path);
				else {
					return handle;
				}
			}
#ifndef EMULATOR
		}
		else {
			handle = CC_open_file(path);
			if(handle < 0) nio_printf(&c1, "Error opening %s ... Check if the file exists\n > ", path);
			else {
				return handle;
			}
		}	
	}
#endif
}
int main(int argc, char *argv[])
{
	QApplication app(argc, argv);
	app.setApplicationName("filebrowser");
	QFile currentFile;

        Q_INIT_RESOURCE(onyx_ui_images);
        sys::SysStatus::instance().setSystemBusy(false);

    	FileBrowser fileBrowser(0);
	/*onyx::screen::watcher().addWatcher(&fileBrowser);*/
	
    	QString path = fileBrowser.showLoadFile(currentFile.fileName());
    	if (path.isEmpty()) {
        	return 1;
    	}

	printf("%s\n",path.toUtf8().data());
    	return 0;
}
Exemple #4
0
void select_strip_script() {
  if(!is_running_in_strip()) {
    printf("This function is only available\n");
    printf("when running as an eActivity\n");
    printf("strip.\n");
    return;
  }
  
  textArea text;

  textElement elem[10];
  text.elements = elem;
  
  elem[0].text = (char*)"This function lets you run a script when this eActivity strip is opened.";
  elem[1].newLine = 1;
  elem[1].text = (char*)"When sharing the eActivity file, it will not be necessary to share any other files - the script is included in the eActivity.";
  elem[2].newLine = 1;
  elem[2].text = (char*)"You will be informed if the script is too big to fit inside the eActivity file.";
  elem[3].newLine = 1;
  elem[3].text = (char*)"Press EXIT now to continue and select a script.";
  text.numelements = 4;
  doTextArea(&text);
  
  char filename[MAX_FILENAME_SIZE+1] = "";
  if(fileBrowser(filename, (unsigned char*)"*.txt", "Scripts")) {
    // get the size of the selected script on SMEM.
    // get free size on the "MCS" of the strip we're running on and see if the script fits
    unsigned short pFile[MAX_FILENAME_SIZE+1];
    Bfile_StrToName_ncpy(pFile, (unsigned char*)filename, strlen(filename)+1); 
    int hFile = Bfile_OpenFile_OS(pFile, READWRITE, 0); // Get handle
    if(hFile >= 0) // Check if it opened
    { //opened
      unsigned int filesize = Bfile_GetFileSize_OS(hFile);  
      //get free size of MCS
      int MCSmaxspace; int MCScurrentload; int MCSfreespace;  
      MCS_GetState( &MCSmaxspace, &MCScurrentload, &MCSfreespace );
      if((int)filesize < MCSfreespace - 50) { // 50 bytes for any headers and the like
        // fits, copy selected script to MCS
        unsigned char* scontents = (unsigned char*)alloca(filesize);
        memset(scontents, filesize, 0);
        int rsize = Bfile_ReadFile_OS(hFile, scontents, filesize, 0);
        scontents[rsize]='\0';
        // script is now in buffer scontents
        // write it to the "MCS"
        int createResult = MCS_CreateDirectory( DIRNAME );
        if(createResult != 0) // Check directory existence
        { // directory already exists, so delete the exiting file that may be there
          MCSDelVar2(DIRNAME, SCRIPTFILE);
        }
        MCSPutVar2(DIRNAME, SCRIPTFILE, rsize, scontents);
        printf("Script set successfully.\n");
      } else {
        printf("The script is too big to be\n");
        printf("included in the eActivity.\n");
      }
      Bfile_CloseFile_OS(hFile);
      return; // don't get to the error message
    }
  }
  printf("There was a problem setting the script for this strip.\n");
}
Exemple #5
0
void select_script_and_run() {
  char filename[MAX_FILENAME_SIZE+1] = "";
  if(fileBrowser(filename, (unsigned char*)"*.txt", "Scripts")) {
    run_script(filename);
  }
}
Exemple #6
0
bool GuiBrowser(GuiWindow *mainWindow, GuiWindow *parentWindow, char *path, const char *label)
{
    char temp[256];
    char title[100];
	int i;

	ShutoffRumble();

	// populate initial directory listing
	if(BrowseDevice() <= 0)
	{
		WindowPrompt(
		"Error",
		"Unable to display files on selected load device",
		"Ok",
		NULL);

        return false;
	}

	int menu = MENU_NONE;
	int dev = 0;
	char mount[2][5] = {"SD", "USB"};

    GuiTrigger trigA;
	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);

    if(OpenDefaultFolder() <= 0)
    {
        BrowseDevice();
        bzero(temp, sizeof(temp));
    }
    else sprintf(temp, "%s/", Settings.UserFolder);

	sprintf(title, "Browse files");
	bzero(path, sizeof(path));

    GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM);
    GuiImageData Textbox(textbox_end_png);
    GuiImage TextboxImg(&Textbox);
    GuiButton InsertURL(TextboxImg.GetWidth(), TextboxImg.GetHeight());

    GuiImageData Device(textbox_begin_png);
    GuiImage DeviceImg(&Device);
    GuiButton InsertDEV(DeviceImg.GetWidth(), DeviceImg.GetHeight());

    GuiText URL(strchr(temp, '/'), 20, (GXColor){0, 0, 0, 255});
    GuiText DEV("SD", 20, (GXColor){0, 0, 0, 255});

    URL.SetMaxWidth(TextboxImg.GetWidth()-20);
    URL.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
    URL.SetPosition(5,0);
    URL.SetScroll(SCROLL_HORIZONTAL);

    InsertURL.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    InsertURL.SetPosition(InsertDEV.GetWidth()/2,30);
    InsertURL.SetLabel(&URL);
    InsertURL.SetImage(&TextboxImg);
    InsertURL.SetSoundOver(&btnSoundOver);
    InsertURL.SetTrigger(&trigA);

    InsertDEV.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    InsertDEV.SetPosition(InsertURL.GetLeft()-InsertDEV.GetWidth()/2,30);
    InsertDEV.SetLabel(&DEV);
    InsertDEV.SetImage(&DeviceImg);
    InsertDEV.SetSoundOver(&btnSoundOver);
    InsertDEV.SetTrigger(&trigA);
    InsertDEV.SetEffectGrow();

    GuiText titleTxt(title, 28, (GXColor){0, 0, 0, 255});
    titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	titleTxt.SetPosition(50,50);

	GuiFileBrowser fileBrowser(552, 248);
	fileBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	fileBrowser.SetPosition(0, 108);
	fileBrowser.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_IN, 30);

	GuiImageData btnOutline(button_png);
	GuiImageData btnOutlineOver(button_over_png);

	GuiText okBtnTxt(label, 24, (GXColor){0, 0, 0, 255});
	GuiImage okBtnImg(&btnOutline);
	GuiImage okBtnImgOver(&btnOutlineOver);
	GuiButton okBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
	okBtn.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
	okBtn.SetPosition(50, -35);
	okBtn.SetLabel(&okBtnTxt);
	okBtn.SetImage(&okBtnImg);
	okBtn.SetImageOver(&okBtnImgOver);
	okBtn.SetTrigger(&trigA);
	okBtn.SetEffectGrow();

    GuiText cancelBtnTxt("Cancel", 24, (GXColor){0, 0, 0, 255});
	GuiImage cancelBtnImg(&btnOutline);
	GuiImage cancelBtnImgOver(&btnOutlineOver);
	GuiButton cancelBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
	cancelBtn.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
	cancelBtn.SetPosition(-50, -35);
	cancelBtn.SetLabel(&cancelBtnTxt);
	cancelBtn.SetImage(&cancelBtnImg);
	cancelBtn.SetImageOver(&cancelBtnImgOver);
	cancelBtn.SetTrigger(&trigA);
	cancelBtn.SetEffectGrow();

	GuiWindow buttonWindow(screenwidth, screenheight);
	buttonWindow.Append(&okBtn);
	buttonWindow.Append(&cancelBtn);
	buttonWindow.Append(&InsertURL);
	buttonWindow.Append(&InsertDEV);
    buttonWindow.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_IN, 30);

    if (mainWindow)
    {
        mainWindow->SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
        while(mainWindow->GetEffect() > 0)
            usleep(100);
    }

    HaltGui();
    if (mainWindow)
        parentWindow->Remove(mainWindow);
    parentWindow->Append(&buttonWindow);
    parentWindow->Append(&fileBrowser);
    ResumeGui();

	while(menu == MENU_NONE)
	{
		usleep(100);
		if(!strlen(URL.GetText()) || URL.GetText()[0] != '/')
        {
            sprintf(temp, "%s", rootdir);
            URL.SetText(strchr(temp, '/'));
        }

        if(InsertURL.GetState() == STATE_CLICKED)
        {
            URL.SetScroll(SCROLL_NONE);
            OnScreenKeyboard(parentWindow, strchr(temp, '/'), 256);
            URL.SetText(strchr(temp, '/'));
            URL.SetScroll(SCROLL_HORIZONTAL);

            InsertURL.ResetState();
        }

        if(InsertDEV.GetState() == STATE_CLICKED)
        {
            InsertDEV.ResetState();
            dev ^= 1;

            if(BrowseDevice(dev) <= 0)
            {
                BrowseDevice();
                dev = 0;
            }

            DEV.SetText(mount[dev]);
            URL.SetText("");
        }

		// update file browser based on arrow buttons
		// set MENU_EXIT if A button pressed on a file
		for(i=0; i < FILE_PAGESIZE; i++)
		{
			if(fileBrowser.fileList[i]->GetState() == STATE_CLICKED)
			{
				fileBrowser.fileList[i]->ResetState();
				// check corresponding browser entry
				if(browserList[browser.selIndex].isdir)
				{
					if(BrowserChangeFolder())
					{
						fileBrowser.ResetState();
						fileBrowser.fileList[0]->SetState(STATE_SELECTED);
						fileBrowser.TriggerUpdate();

                        if(strlen(browser.dir) > 1)
                            sprintf(fullpath, "%s%s/", rootdir, browser.dir+1); // print current path
                        else sprintf(fullpath, "%s", rootdir); // print current path

                        sprintf(temp, fullpath);
                        URL.SetText(strchr(temp, '/'));
					}
					else
					{
						menu = MENU_HOME;
						break;
					}
				}
				else
				{
					ShutoffRumble();
					// load file
					if(strlen(browser.dir) > 1)
                        sprintf(fullpath, "%s%s/%s", rootdir, browser.dir+1, browserList[browser.selIndex].filename); // print current path
                    else sprintf(fullpath, "%s%s", rootdir, browserList[browser.selIndex].filename); // print current path

                    sprintf(temp, fullpath);
                    URL.SetText(strchr(temp, '/'));
				}
			}
		}

		if(okBtn.GetState() == STATE_CLICKED)
		{
		    sprintf(path, temp);
		    menu = MENU_HOME;
		}
        if(cancelBtn.GetState() == STATE_CLICKED)
		    menu = MENU_HOME;
	}

    fileBrowser.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50);
    buttonWindow.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50);
    while(buttonWindow.GetEffect() > 0)
        usleep(100);

    fileBrowser.SetVisible(false);
    buttonWindow.SetVisible(false);

    if(mainWindow)
    {
        mainWindow->SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 30);
        parentWindow->Append(mainWindow);
        while(mainWindow->GetEffect() > 0)
            usleep(100);
    }

    HaltGui();
    parentWindow->Remove(&buttonWindow);
    parentWindow->Remove(&fileBrowser);
    ResumeGui();

    if (isValidPath(path))
        return true;
    return false;
}
Exemple #7
0
/****************************************************************************
 * MenuBrowseDevice
 ***************************************************************************/
static int MenuBrowseDevice() {
    char title[100];
    int i;

    ShutoffRumble();

    // populate initial directory listing
    if (BrowseDevice() <= 0) {
        int choice = WindowPrompt(
                "Error",
                "Unable to display files on selected load device.",
                "Retry",
                "Check Settings");

        if (choice)
            return MENU_BROWSE_DEVICE;
        else
            return MENU_SETTINGS;
    }

    int menu = MENU_NONE;

    sprintf(title, "Browse Files");

    GuiText titleTxt(title, 28, ColorGrey);
    titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
    titleTxt.SetPosition(100, 50);

    GuiTrigger trigA;
    //	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
    trigA.SetSimpleTrigger(-1, 0, PAD_BUTTON_A);

    GuiFileBrowser fileBrowser(1080, 496);
    fileBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    fileBrowser.SetPosition(0, 100);

    GuiImageData btnOutline(xenon_button_png);
    GuiImageData btnOutlineOver(xenon_button_over_png);

    GuiText backBtnTxt("Go Back", 24, ColorGrey2);
    GuiImage backBtnImg(&btnOutline);
    GuiImage backBtnImgOver(&btnOutlineOver);
    GuiButton backBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
    backBtn.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
    backBtn.SetPosition(30, -35);
    backBtn.SetLabel(&backBtnTxt);
    backBtn.SetImage(&backBtnImg);
    backBtn.SetImageOver(&backBtnImgOver);
    backBtn.SetTrigger(&trigA);
    backBtn.SetEffectGrow();

    GuiWindow xenon_buttonWindow(screenwidth, screenheight);
    xenon_buttonWindow.Append(&backBtn);

    HaltGui();
    mainWindow->Append(&titleTxt);
    mainWindow->Append(&fileBrowser);
    mainWindow->Append(&xenon_buttonWindow);
    ResumeGui();

    while (menu == MENU_NONE) {
        UGUI();
        usleep(THREAD_SLEEP);

        // update file browser based on arrow xenon_buttons
        // set MENU_EXIT if A xenon_button pressed on a file
        for (i = 0; i < FILE_PAGESIZE; i++) {
            if (fileBrowser.fileList[i]->GetState() == STATE_CLICKED) {
                fileBrowser.fileList[i]->ResetState();
                // check corresponding browser entry
                if (browserList[browser.selIndex].isdir) {
                    if (BrowserChangeFolder()) {
                        fileBrowser.ResetState();
                        fileBrowser.fileList[0]->SetState(STATE_SELECTED);
                        fileBrowser.TriggerUpdate();
                    } else {
                        menu = MENU_BROWSE_DEVICE;
                        break;
                    }
                } else {
                    ShutoffRumble();
                    mainWindow->SetState(STATE_DISABLED);
                    // load file
                    printf("Launch : %s\r\n",browserList[browser.selIndex].filename);
                    mainWindow->SetState(STATE_DEFAULT);
                }
            }
        }
        if (backBtn.GetState() == STATE_CLICKED)
            menu = MENU_SETTINGS;
    }
    HaltGui();
    mainWindow->Remove(&titleTxt);
    mainWindow->Remove(&xenon_buttonWindow);
    mainWindow->Remove(&fileBrowser);
    return menu;
}