*Added Filebrowser from libwiigui 1.03 (modified a bit). It will be used by giantpune later. Right now its not used.

*Created a function to get SVN_REV to avoid long compiling times when small changes are done in the source.
This commit is contained in:
dimok321 2009-07-24 20:34:55 +00:00
parent 9b051ac7d7
commit 9b8f289ca3
17 changed files with 926 additions and 7 deletions

File diff suppressed because one or more lines are too long

235
source/filebrowser.cpp Normal file
View File

@ -0,0 +1,235 @@
/****************************************************************************
* libwiigui Template
* Tantric 2009
*
* modified by dimok
*
* filebrowser.cpp
*
* Generic file routines - reading, writing, browsing
***************************************************************************/
#include <gccore.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wiiuse/wpad.h>
#include <sys/dir.h>
#include <malloc.h>
#include "filebrowser.h"
#include "menu.h"
BROWSERINFO browser;
BROWSERENTRY * browserList = NULL; // list of files/folders in browser
/****************************************************************************
* ResetBrowser()
* Clears the file browser memory, and allocates one initial entry
***************************************************************************/
void ResetBrowser()
{
browser.numEntries = 0;
browser.selIndex = 0;
browser.pageIndex = 0;
// Clear any existing values
if(browserList != NULL)
{
free(browserList);
browserList = NULL;
}
// set aside space for 1 entry
browserList = (BROWSERENTRY *)malloc(sizeof(BROWSERENTRY));
memset(browserList, 0, sizeof(BROWSERENTRY));
}
/****************************************************************************
* UpdateDirName()
* Update curent directory name for file browser
***************************************************************************/
int UpdateDirName()
{
int size=0;
char * test;
char temp[1024];
/* current directory doesn't change */
if (strcmp(browserList[browser.selIndex].filename,".") == 0)
{
return 0;
}
/* go up to parent directory */
else if (strcmp(browserList[browser.selIndex].filename,"..") == 0)
{
/* determine last subdirectory namelength */
sprintf(temp,"%s",browser.dir);
test = strtok(temp,"/");
while (test != NULL)
{
size = strlen(test);
test = strtok(NULL,"/");
}
/* remove last subdirectory name */
size = strlen(browser.dir) - size - 1;
browser.dir[size] = 0;
return 1;
}
/* Open a directory */
else
{
/* test new directory namelength */
if ((strlen(browser.dir)+1+strlen(browserList[browser.selIndex].filename)) < MAXPATHLEN)
{
/* update current directory name */
sprintf(browser.dir, "%s/%s",browser.dir, browserList[browser.selIndex].filename);
return 1;
}
else
{
return -1;
}
}
}
/****************************************************************************
* FileSortCallback
*
* Quick sort callback to sort file entries with the following order:
* .
* ..
* <dirs>
* <files>
***************************************************************************/
int FileSortCallback(const void *f1, const void *f2)
{
/* Special case for implicit directories */
if(((BROWSERENTRY *)f1)->filename[0] == '.' || ((BROWSERENTRY *)f2)->filename[0] == '.')
{
if(strcmp(((BROWSERENTRY *)f1)->filename, ".") == 0) { return -1; }
if(strcmp(((BROWSERENTRY *)f2)->filename, ".") == 0) { return 1; }
if(strcmp(((BROWSERENTRY *)f1)->filename, "..") == 0) { return -1; }
if(strcmp(((BROWSERENTRY *)f2)->filename, "..") == 0) { return 1; }
}
/* If one is a file and one is a directory the directory is first. */
if(((BROWSERENTRY *)f1)->isdir && !(((BROWSERENTRY *)f2)->isdir)) return -1;
if(!(((BROWSERENTRY *)f1)->isdir) && ((BROWSERENTRY *)f2)->isdir) return 1;
return stricmp(((BROWSERENTRY *)f1)->filename, ((BROWSERENTRY *)f2)->filename);
}
/***************************************************************************
* Browse subdirectories
**************************************************************************/
int
ParseDirectory()
{
DIR_ITER *dir = NULL;
char fulldir[MAXPATHLEN];
char filename[MAXPATHLEN];
struct stat filestat;
// reset browser
ResetBrowser();
// open the directory
sprintf(fulldir, "%s%s", browser.rootdir, browser.dir); // add currentDevice to path
dir = diropen(fulldir);
// if we can't open the dir, try opening the root dir
if (dir == NULL)
{
sprintf(browser.dir,"/");
dir = diropen(browser.rootdir);
if (dir == NULL)
{
return -1;
}
}
// index files/folders
int entryNum = 0;
while(dirnext(dir,filename,&filestat) == 0)
{
if(strcmp(filename,".") != 0)
{
BROWSERENTRY * newBrowserList = (BROWSERENTRY *)realloc(browserList, (entryNum+1) * sizeof(BROWSERENTRY));
if(!newBrowserList) // failed to allocate required memory
{
ResetBrowser();
entryNum = -1;
break;
}
else
{
browserList = newBrowserList;
}
memset(&(browserList[entryNum]), 0, sizeof(BROWSERENTRY)); // clear the new entry
strncpy(browserList[entryNum].filename, filename, MAXJOLIET);
if(strcmp(filename,"..") == 0)
{
sprintf(browserList[entryNum].displayname, "..");
}
else
{
strcpy(browserList[entryNum].displayname, filename); // crop name for display
}
browserList[entryNum].length = filestat.st_size;
browserList[entryNum].isdir = (filestat.st_mode & _IFDIR) == 0 ? 0 : 1; // flag this as a dir
entryNum++;
}
}
// close directory
dirclose(dir);
// Sort the file list
qsort(browserList, entryNum, sizeof(BROWSERENTRY), FileSortCallback);
browser.numEntries = entryNum;
return entryNum;
}
/****************************************************************************
* BrowserChangeFolder
*
* Update current directory and set new entry list if directory has changed
***************************************************************************/
int BrowserChangeFolder()
{
if(!UpdateDirName())
return -1;
ParseDirectory();
return browser.numEntries;
}
/****************************************************************************
* BrowseDevice
* Displays a list of files on the selected device
***************************************************************************/
int BrowseDevice(int device)
{
sprintf(browser.dir, "/");
switch(device)
{
case SD:
sprintf(browser.rootdir, "SD:");
break;
case USB:
sprintf(browser.rootdir, "USB:");
break;
}
ParseDirectory(); // Parse root directory
return browser.numEntries;
}

55
source/filebrowser.h Normal file
View File

@ -0,0 +1,55 @@
/****************************************************************************
* libwiigui Template
* Tantric 2009
*
* modified by dimok
*
* filebrowser.h
*
* Generic file routines - reading, writing, browsing
****************************************************************************/
#ifndef _FILEBROWSER_H_
#define _FILEBROWSER_H_
#include <unistd.h>
#include <gccore.h>
#define MAXJOLIET 255
#define MAXDISPLAY MAXPATHLEN
enum {
SD,
USB
};
typedef struct
{
char dir[MAXPATHLEN]; // directory path of browserList
char rootdir[10]; // directory path of browserList
int numEntries; // # of entries in browserList
int selIndex; // currently selected index of browserList
int pageIndex; // starting index of browserList page display
} BROWSERINFO;
typedef struct
{
u64 offset; // DVD offset
u64 length; // file length in 64 bytes for sizes higher than 4GB
char isdir; // 0 - file, 1 - directory
char filename[MAXJOLIET + 1]; // full filename
char displayname[MAXDISPLAY + 1]; // name for browser display
} BROWSERENTRY;
extern BROWSERINFO browser;
extern BROWSERENTRY * browserList;
int UpdateDirName();
int FileSortCallback(const void *f1, const void *f2);
void ResetBrowser();
int ParseDirectory();
int BrowserChangeFolder();
int BrowseDevice(int device);
#endif

View File

@ -101,6 +101,18 @@ extern const u32 bg_options_settings_png_size;
extern const u8 settings_background_png[];
extern const u32 settings_background_png_size;
extern const u8 bg_browser_png[];
extern const u32 bg_browser_png_size;
extern const u8 folder_png[];
extern const u32 folder_png_size;
extern const u8 bg_browser_selection_png[];
extern const u32 bg_browser_selection_png_size;
extern const u8 addressbar_textbox_png[];
extern const u32 addressbar_textbox_png_size;
extern const u8 browser_png[];
extern const u32 browser_png_size;
@ -315,7 +327,7 @@ extern const u8 Wiimote1_png[];
extern const u32 Wiimote1_png_size;
extern const u8 Wiimote2_png[];
extern const u32 Wiimote2_png_size;
extern const u32 Wiimote2_png_size;
extern const u8 wifi1_png[];
extern const u32 wifi1_png_size;

7
source/getrev.c Normal file
View File

@ -0,0 +1,7 @@
#include "svnrev.h"
char *GetRev() {
return SVN_REV;
}

14
source/getrev.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef GETREV_H
#ifdef __cplusplus
extern "C"
{
#endif
char *GetRev();
#ifdef __cplusplus
}
#endif
#endif

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

BIN
source/images/folder.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -232,6 +232,9 @@ class GuiElement
//!Set the element's parent
//!\param e Pointer to parent element
void SetParent(GuiElement * e);
//!Gets the element's parent
//!\return Pointer to parent element
GuiElement * GetParent();
//!Gets the current leftmost coordinate of the element
//!Considers horizontal alignment, x offset, width, and parent element's GetLeft() / GetWidth() values
//!\return left coordinate
@ -1029,4 +1032,52 @@ class GuiOptionBrowser : public GuiElement
GuiTrigger * trigB;
GuiTrigger * trigHeldA;
};
//!Display a list of files
class GuiFileBrowser : public GuiElement
{
public:
GuiFileBrowser(int w, int h);
~GuiFileBrowser();
void DisableTriggerUpdate(bool set);
void ResetState();
void SetFocus(int f);
void Draw();
void TriggerUpdate();
void Update(GuiTrigger * t);
GuiButton * fileList[PAGESIZE];
protected:
int selectedItem;
bool listChanged;
bool triggerdisabled;
GuiText * fileListText[PAGESIZE];
GuiText * fileListTextOver[PAGESIZE];
GuiImage * fileListBg[PAGESIZE];
GuiImage * fileListFolder[PAGESIZE];
GuiButton * arrowUpBtn;
GuiButton * arrowDownBtn;
GuiButton * scrollbarBoxBtn;
GuiImage * bgFileSelectionImg;
GuiImage * scrollbarImg;
GuiImage * arrowDownImg;
GuiImage * arrowUpImg;
GuiImage * scrollbarBoxImg;
GuiImageData * bgFileSelection;
GuiImageData * bgFileSelectionEntry;
GuiImageData * fileFolder;
GuiImageData * scrollbar;
GuiImageData * arrowDown;
GuiImageData * arrowUp;
GuiImageData * scrollbarBox;
GuiSound * btnSoundOver;
GuiSound * btnSoundClick;
GuiTrigger * trigA;
GuiTrigger * trigHeldA;
};
#endif

View File

@ -80,6 +80,11 @@ void GuiElement::SetParent(GuiElement * e)
LOCK(this);
parentElement = e;
}
GuiElement * GuiElement::GetParent()
{
return parentElement;
}
/**
* Get the left position of the GuiElement.
* @see SetLeft()

View File

@ -0,0 +1,402 @@
/****************************************************************************
* libwiigui
*
* Tantric 2009
*
* gui_filebrowser.cpp
*
* GUI class definitions
***************************************************************************/
#include "gui.h"
#include "filebrowser.h"
#define FILEBROWSERSIZE 8
/**
* Constructor for the GuiFileBrowser class.
*/
GuiFileBrowser::GuiFileBrowser(int w, int h)
{
width = w;
height = h;
selectedItem = 0;
selectable = true;
listChanged = true; // trigger an initial list update
triggerdisabled = false; // trigger disable
focus = 1; // allow focus
trigA = new GuiTrigger;
trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
trigHeldA = new GuiTrigger;
trigHeldA->SetHeldTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
btnSoundOver = new GuiSound(button_over_pcm, button_over_pcm_size, SOUND_PCM);
btnSoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, SOUND_PCM);
bgFileSelection = new GuiImageData(bg_browser_png);
bgFileSelectionImg = new GuiImage(bgFileSelection);
bgFileSelectionImg->SetParent(this);
bgFileSelectionImg->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
bgFileSelectionEntry = new GuiImageData(bg_browser_selection_png);
fileFolder = new GuiImageData(folder_png);
scrollbar = new GuiImageData(scrollbar_png);
scrollbarImg = new GuiImage(scrollbar);
scrollbarImg->SetParent(this);
scrollbarImg->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
scrollbarImg->SetPosition(0, 30);
arrowDown = new GuiImageData(scrollbar_arrowdown_png);
arrowDownImg = new GuiImage(arrowDown);
arrowUp = new GuiImageData(scrollbar_arrowup_png);
arrowUpImg = new GuiImage(arrowUp);
scrollbarBox = new GuiImageData(scrollbar_box_png);
scrollbarBoxImg = new GuiImage(scrollbarBox);
arrowUpBtn = new GuiButton(arrowUpImg->GetWidth(), arrowUpImg->GetHeight());
arrowUpBtn->SetParent(this);
arrowUpBtn->SetImage(arrowUpImg);
arrowUpBtn->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
arrowUpBtn->SetSelectable(false);
arrowUpBtn->SetClickable(false);
arrowUpBtn->SetHoldable(true);
arrowUpBtn->SetTrigger(trigHeldA);
arrowUpBtn->SetSoundOver(btnSoundOver);
arrowUpBtn->SetSoundClick(btnSoundClick);
arrowDownBtn = new GuiButton(arrowDownImg->GetWidth(), arrowDownImg->GetHeight());
arrowDownBtn->SetParent(this);
arrowDownBtn->SetImage(arrowDownImg);
arrowDownBtn->SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
arrowDownBtn->SetSelectable(false);
arrowDownBtn->SetClickable(false);
arrowDownBtn->SetHoldable(true);
arrowDownBtn->SetTrigger(trigHeldA);
arrowDownBtn->SetSoundOver(btnSoundOver);
arrowDownBtn->SetSoundClick(btnSoundClick);
scrollbarBoxBtn = new GuiButton(scrollbarBoxImg->GetWidth(), scrollbarBoxImg->GetHeight());
scrollbarBoxBtn->SetParent(this);
scrollbarBoxBtn->SetImage(scrollbarBoxImg);
scrollbarBoxBtn->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
scrollbarBoxBtn->SetMinY(0);
scrollbarBoxBtn->SetMaxY(136);
scrollbarBoxBtn->SetSelectable(false);
scrollbarBoxBtn->SetClickable(false);
scrollbarBoxBtn->SetHoldable(true);
scrollbarBoxBtn->SetTrigger(trigHeldA);
for(int i=0; i<FILEBROWSERSIZE; i++)
{
fileListText[i] = new GuiText(NULL,20, (GXColor){0, 0, 0, 0xff});
fileListText[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
fileListText[i]->SetPosition(5,0);
fileListText[i]->SetMaxWidth(bgFileSelectionImg->GetWidth() - (arrowDownImg->GetWidth()+20), GuiText::DOTTED);
fileListTextOver[i] = new GuiText(NULL,20, (GXColor){0, 0, 0, 0xff});
fileListTextOver[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
fileListTextOver[i]->SetPosition(5,0);
fileListTextOver[i]->SetMaxWidth(bgFileSelectionImg->GetWidth() - (arrowDownImg->GetWidth()+20), GuiText::SCROLL);
fileListBg[i] = new GuiImage(bgFileSelectionEntry);
fileListFolder[i] = new GuiImage(fileFolder);
fileList[i] = new GuiButton(512,30);
fileList[i]->SetParent(this);
fileList[i]->SetLabel(fileListText[i]);
fileList[i]->SetLabelOver(fileListTextOver[i]);
fileList[i]->SetImageOver(fileListBg[i]);
fileList[i]->SetPosition(2,30*i+3);
fileList[i]->SetTrigger(trigA);
fileList[i]->SetRumble(false);
fileList[i]->SetSoundClick(btnSoundClick);
}
}
/**
* Destructor for the GuiFileBrowser class.
*/
GuiFileBrowser::~GuiFileBrowser()
{
delete arrowUpBtn;
delete arrowDownBtn;
delete scrollbarBoxBtn;
delete bgFileSelectionImg;
delete scrollbarImg;
delete arrowDownImg;
delete arrowUpImg;
delete scrollbarBoxImg;
delete bgFileSelection;
delete bgFileSelectionEntry;
delete fileFolder;
delete scrollbar;
delete arrowDown;
delete arrowUp;
delete scrollbarBox;
delete btnSoundOver;
delete btnSoundClick;
delete trigHeldA;
delete trigA;
for(int i=0; i<FILEBROWSERSIZE; i++)
{
delete fileListText[i];
delete fileListTextOver[i];
delete fileList[i];
delete fileListBg[i];
delete fileListFolder[i];
}
}
void GuiFileBrowser::SetFocus(int f)
{
focus = f;
for(int i=0; i<FILEBROWSERSIZE; i++)
fileList[i]->ResetState();
if(f == 1)
fileList[selectedItem]->SetState(STATE_SELECTED);
}
void GuiFileBrowser::DisableTriggerUpdate(bool set)
{
triggerdisabled = set;
}
void GuiFileBrowser::ResetState()
{
state = STATE_DEFAULT;
stateChan = -1;
selectedItem = 0;
for(int i=0; i<FILEBROWSERSIZE; i++)
{
fileList[i]->ResetState();
}
}
void GuiFileBrowser::TriggerUpdate()
{
listChanged = true;
}
/**
* Draw the button on screen
*/
void GuiFileBrowser::Draw()
{
if(!this->IsVisible())
return;
bgFileSelectionImg->Draw();
for(int i=0; i<FILEBROWSERSIZE; i++)
{
fileList[i]->Draw();
}
scrollbarImg->Draw();
arrowUpBtn->Draw();
arrowDownBtn->Draw();
scrollbarBoxBtn->Draw();
this->UpdateEffects();
}
void GuiFileBrowser::Update(GuiTrigger * t)
{
if(state == STATE_DISABLED || !t || triggerdisabled)
return;
int position = 0;
int positionWiimote = 0;
arrowUpBtn->Update(t);
arrowDownBtn->Update(t);
scrollbarBoxBtn->Update(t);
// move the file listing to respond to wiimote cursor movement
if(scrollbarBoxBtn->GetState() == STATE_HELD &&
scrollbarBoxBtn->GetStateChan() == t->chan &&
t->wpad.ir.valid &&
browser.numEntries > FILEBROWSERSIZE
)
{
scrollbarBoxBtn->SetPosition(0,0);
positionWiimote = t->wpad.ir.y - 60 - scrollbarBoxBtn->GetTop();
if(positionWiimote < scrollbarBoxBtn->GetMinY())
positionWiimote = scrollbarBoxBtn->GetMinY();
else if(positionWiimote > scrollbarBoxBtn->GetMaxY())
positionWiimote = scrollbarBoxBtn->GetMaxY();
browser.pageIndex = (positionWiimote * browser.numEntries)/136.0 - selectedItem;
if(browser.pageIndex <= 0)
{
browser.pageIndex = 0;
}
else if(browser.pageIndex+FILEBROWSERSIZE >= browser.numEntries)
{
browser.pageIndex = browser.numEntries-FILEBROWSERSIZE;
}
listChanged = true;
focus = false;
}
if(arrowDownBtn->GetState() == STATE_HELD && arrowDownBtn->GetStateChan() == t->chan)
{
t->wpad.btns_h |= WPAD_BUTTON_DOWN;
if(!this->IsFocused())
((GuiWindow *)this->GetParent())->ChangeFocus(this);
}
else if(arrowUpBtn->GetState() == STATE_HELD && arrowUpBtn->GetStateChan() == t->chan)
{
t->wpad.btns_h |= WPAD_BUTTON_UP;
if(!this->IsFocused())
((GuiWindow *)this->GetParent())->ChangeFocus(this);
}
// pad/joystick navigation
if(!focus)
{
goto endNavigation; // skip navigation
listChanged = false;
}
if(t->Right())
{
if(browser.pageIndex < browser.numEntries && browser.numEntries > FILEBROWSERSIZE)
{
browser.pageIndex += FILEBROWSERSIZE;
if(browser.pageIndex+FILEBROWSERSIZE >= browser.numEntries)
browser.pageIndex = browser.numEntries-FILEBROWSERSIZE;
listChanged = true;
}
}
else if(t->Left())
{
if(browser.pageIndex > 0)
{
browser.pageIndex -= FILEBROWSERSIZE;
if(browser.pageIndex < 0)
browser.pageIndex = 0;
listChanged = true;
}
}
else if(t->Down())
{
if(browser.pageIndex + selectedItem + 1 < browser.numEntries)
{
if(selectedItem == FILEBROWSERSIZE-1)
{
// move list down by 1
browser.pageIndex++;
listChanged = true;
}
else if(fileList[selectedItem+1]->IsVisible())
{
fileList[selectedItem]->ResetState();
fileList[++selectedItem]->SetState(STATE_SELECTED, t->chan);
}
}
}
else if(t->Up())
{
if(selectedItem == 0 && browser.pageIndex + selectedItem > 0)
{
// move list up by 1
browser.pageIndex--;
listChanged = true;
}
else if(selectedItem > 0)
{
fileList[selectedItem]->ResetState();
fileList[--selectedItem]->SetState(STATE_SELECTED, t->chan);
}
}
endNavigation:
for(int i=0; i<FILEBROWSERSIZE; i++)
{
if(listChanged)
{
if(browser.pageIndex+i < browser.numEntries)
{
if(fileList[i]->GetState() == STATE_DISABLED)
fileList[i]->SetState(STATE_DEFAULT);
fileList[i]->SetVisible(true);
fileListText[i]->SetText(browserList[browser.pageIndex+i].displayname);
fileListTextOver[i]->SetText(browserList[browser.pageIndex+i].displayname);
if(browserList[browser.pageIndex+i].isdir) // directory
{
fileList[i]->SetIcon(fileListFolder[i]);
fileListText[i]->SetPosition(30,0);
fileListTextOver[i]->SetPosition(30,0);
}
else
{
fileList[i]->SetIcon(NULL);
fileListText[i]->SetPosition(10,0);
fileListTextOver[i]->SetPosition(10,0);
}
}
else
{
fileList[i]->SetVisible(false);
fileList[i]->SetState(STATE_DISABLED);
}
}
if(i != selectedItem && fileList[i]->GetState() == STATE_SELECTED)
fileList[i]->ResetState();
else if(focus && i == selectedItem && fileList[i]->GetState() == STATE_DEFAULT)
fileList[selectedItem]->SetState(STATE_SELECTED, t->chan);
int currChan = t->chan;
if(t->wpad.ir.valid && !fileList[i]->IsInside(t->wpad.ir.x, t->wpad.ir.y))
t->chan = -1;
fileList[i]->Update(t);
t->chan = currChan;
if(fileList[i]->GetState() == STATE_SELECTED)
{
selectedItem = i;
browser.selIndex = browser.pageIndex + i;
}
}
// update the location of the scroll box based on the position in the file list
if(positionWiimote > 0)
{
position = positionWiimote; // follow wiimote cursor
}
else
{
position = 136*(browser.pageIndex + FILEBROWSERSIZE/2.0) / (browser.numEntries*1.0);
if(browser.pageIndex/(FILEBROWSERSIZE/2.0) < 1)
position = 0;
else if((browser.pageIndex+FILEBROWSERSIZE)/(FILEBROWSERSIZE*1.0) >= (browser.numEntries)/(FILEBROWSERSIZE*1.0))
position = 136;
}
scrollbarBoxBtn->SetPosition(0,position+36);
listChanged = false;
if(updateCB)
updateCB(this);
}

View File

@ -16,7 +16,7 @@
#include "settings/cfg.h"
#include "main.h"
#include "http.h"
#include "svnrev.h"
#include "getrev.h"
#define PORT 4299
@ -271,7 +271,7 @@ int CheckUpdate()
return -1;
int revnumber = 0;
int currentrev = atoi(SVN_REV);
int currentrev = atoi(GetRev());
#ifdef NOTFULLCHANNEL
struct block file = downloadfile("http://www.techjawa.com/usbloadergx/rev.txt");

View File

@ -28,7 +28,7 @@
#include "wad/wad.h"
#include "unzip/unzip.h"
#include "zlib.h"
#include "svnrev.h"
#include "getrev.h"
/*** Variables that are also used extern ***/
@ -174,11 +174,11 @@ void WindowCredits()
#ifdef NOTFULLCHANNEL
char SvnRev[30];
snprintf(SvnRev,sizeof(SvnRev), "Rev%s IOS%u (Rev %u)", SVN_REV, IOS_GetVersion(), IOS_GetRevision());
snprintf(SvnRev,sizeof(SvnRev), "Rev%s IOS%u (Rev %u)", GetRev(), IOS_GetVersion(), IOS_GetRevision());
#else
char svnTmp[4];//did this to hide the M after the rev# that is made by altering it
//to be ready to be in a full channel
snprintf(svnTmp,sizeof(svnTmp), "%s", SVN_REV);
snprintf(svnTmp,sizeof(svnTmp), "%s", GetRev());
char SvnRev[30];
snprintf(SvnRev,sizeof(SvnRev), "Rev%sc IOS%u (Rev %u)", svnTmp, IOS_GetVersion(), IOS_GetRevision());
#endif

4
source/svnrev.h Normal file
View File

@ -0,0 +1,4 @@
#ifndef SVNREV_H
#define SVNREV_H
#define SVN_REV "643M"
#endif /* SVNREV_H */

134
source/testfilebrowser.cpp Normal file
View File

@ -0,0 +1,134 @@
#include <gccore.h>
#include <stdio.h>
#include "language/gettext.h"
#include "prompts/PromptWindows.h"
#include "libwiigui/gui.h"
#include "filebrowser.h"
#include "menu.h"
#include "sys.h"
/*** Extern variables ***/
extern GuiWindow * mainWindow;
extern u8 shutdown;
extern u8 reset;
/*** Extern functions ***/
extern void ResumeGui();
extern void HaltGui();
/****************************************************************************
* MenuBrowseDevice
***************************************************************************/
int MenuBrowseDevice()
{
int i;
char currentdir[50];
// populate initial directory listing
if(BrowseDevice(SD) <= 0)
{
int choice = WindowPrompt("Error",
"Unable to load device.",
"Retry",
"Change Settings");
if(choice) {
return MENU_DISCLIST;
}
}
int menu = MENU_NONE;
GuiText titleTxt("Browse Files", 28, (GXColor){0, 0, 0, 230});
titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
titleTxt.SetPosition(70,20);
GuiTrigger trigA;
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
GuiTrigger trigPlus;
trigPlus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0);
GuiTrigger trigMinus;
trigMinus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0);
GuiFileBrowser fileBrowser(552, 248);
fileBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
fileBrowser.SetPosition(0, 100);
GuiImageData btnOutline(button_dialogue_box_png);
GuiText ExitBtnTxt("Exit", 24, (GXColor){0, 0, 0, 255});
GuiImage ExitBtnImg(&btnOutline);
GuiButton ExitBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
ExitBtn.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
ExitBtn.SetPosition(100, -35);
ExitBtn.SetLabel(&ExitBtnTxt);
ExitBtn.SetImage(&ExitBtnImg);
ExitBtn.SetTrigger(&trigA);
ExitBtn.SetEffectGrow();
GuiImageData Address(addressbar_textbox_png);
snprintf(currentdir, sizeof(currentdir), "%s%s", browser.rootdir, browser.dir);
GuiText AdressText(currentdir, 20, (GXColor) {0, 0, 0, 255});
AdressText.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
AdressText.SetPosition(20, 0);
AdressText.SetMaxWidth(Address.GetWidth()-40, GuiText::SCROLL);
GuiImage AdressbarImg(&Address);
GuiButton Adressbar(Address.GetWidth(), Address.GetHeight());
Adressbar.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
Adressbar.SetPosition(60, fileBrowser.GetTop()-45);
Adressbar.SetImage(&AdressbarImg);
Adressbar.SetLabel(&AdressText);
HaltGui();
GuiWindow w(screenwidth, screenheight);
w.Append(&ExitBtn);
w.Append(&titleTxt);
w.Append(&fileBrowser);
w.Append(&Adressbar);
mainWindow->Append(&w);
ResumeGui();
while(menu == MENU_NONE)
{
VIDEO_WaitVSync();
if(shutdown == 1)
Sys_Shutdown();
if(reset == 1)
Sys_Reboot();
for(i=0; i<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();
AdressText.SetTextf("%s%s", browser.rootdir, browser.dir);
} else {
menu = MENU_DISCLIST;
break;
}
} else {
mainWindow->SetState(STATE_DISABLED);
mainWindow->SetState(STATE_DEFAULT);
}
}
}
if(ExitBtn.GetState() == STATE_CLICKED)
menu = MENU_DISCLIST;
}
HaltGui();
mainWindow->Remove(&w);
ResumeGui();
return menu;
}