Code cleanup
Reformatted code for improved readability. Fixed type casting. Selective merge from uae4arm (android)
This commit is contained in:
parent
89aaed4a53
commit
efb894781e
20 changed files with 7723 additions and 6797 deletions
File diff suppressed because it is too large
Load diff
|
@ -11,7 +11,7 @@
|
|||
#include "sysdeps.h"
|
||||
#include "config.h"
|
||||
#include "options.h"
|
||||
#include "memory.h"
|
||||
#include "include/memory.h"
|
||||
#include "uae.h"
|
||||
#include "autoconf.h"
|
||||
#include "filesys.h"
|
||||
|
@ -22,6 +22,8 @@
|
|||
#define DIALOG_WIDTH 520
|
||||
#define DIALOG_HEIGHT 202
|
||||
|
||||
extern std::string volName;
|
||||
|
||||
static bool dialogResult = false;
|
||||
static bool dialogFinished = false;
|
||||
|
||||
|
@ -43,38 +45,41 @@ static gcn::TextField *txtBootPri;
|
|||
|
||||
class FilesysVirtualActionListener : public gcn::ActionListener
|
||||
{
|
||||
public:
|
||||
void action(const gcn::ActionEvent& actionEvent)
|
||||
{
|
||||
if(actionEvent.getSource() == cmdPath)
|
||||
{
|
||||
char tmp[MAX_PATH];
|
||||
strncpy(tmp, txtPath->getText().c_str(), MAX_PATH);
|
||||
wndEditFilesysVirtual->releaseModalFocus();
|
||||
if(SelectFolder("Select folder", tmp))
|
||||
txtPath->setText(tmp);
|
||||
wndEditFilesysVirtual->requestModalFocus();
|
||||
cmdPath->requestFocus();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (actionEvent.getSource() == cmdOK)
|
||||
{
|
||||
if(txtDevice->getText().length() <= 0)
|
||||
{
|
||||
wndEditFilesysVirtual->setCaption("Please enter a device name.");
|
||||
return;
|
||||
}
|
||||
if(txtVolume->getText().length() <= 0)
|
||||
{
|
||||
wndEditFilesysVirtual->setCaption("Please enter a volume name.");
|
||||
return;
|
||||
}
|
||||
dialogResult = true;
|
||||
}
|
||||
dialogFinished = true;
|
||||
}
|
||||
}
|
||||
public:
|
||||
void action(const gcn::ActionEvent& actionEvent)
|
||||
{
|
||||
if (actionEvent.getSource() == cmdPath)
|
||||
{
|
||||
char tmp[MAX_PATH];
|
||||
strncpy(tmp, txtPath->getText().c_str(), MAX_PATH);
|
||||
wndEditFilesysVirtual->releaseModalFocus();
|
||||
if (SelectFolder("Select folder", tmp))
|
||||
{
|
||||
txtPath->setText(tmp);
|
||||
txtVolume->setText(volName);
|
||||
}
|
||||
wndEditFilesysVirtual->requestModalFocus();
|
||||
cmdPath->requestFocus();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (actionEvent.getSource() == cmdOK)
|
||||
{
|
||||
if (txtDevice->getText().length() <= 0)
|
||||
{
|
||||
wndEditFilesysVirtual->setCaption("Please enter a device name.");
|
||||
return;
|
||||
}
|
||||
if (txtVolume->getText().length() <= 0)
|
||||
{
|
||||
wndEditFilesysVirtual->setCaption("Please enter a volume name.");
|
||||
return;
|
||||
}
|
||||
dialogResult = true;
|
||||
}
|
||||
dialogFinished = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
static FilesysVirtualActionListener* filesysVirtualActionListener;
|
||||
|
||||
|
@ -83,232 +88,247 @@ static void InitEditFilesysVirtual(void)
|
|||
{
|
||||
wndEditFilesysVirtual = new gcn::Window("Edit");
|
||||
wndEditFilesysVirtual->setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
|
||||
wndEditFilesysVirtual->setPosition((GUI_WIDTH - DIALOG_WIDTH) / 2, (GUI_HEIGHT - DIALOG_HEIGHT) / 2);
|
||||
wndEditFilesysVirtual->setBaseColor(gui_baseCol + 0x202020);
|
||||
wndEditFilesysVirtual->setCaption("Volume settings");
|
||||
wndEditFilesysVirtual->setTitleBarHeight(TITLEBAR_HEIGHT);
|
||||
|
||||
filesysVirtualActionListener = new FilesysVirtualActionListener();
|
||||
|
||||
wndEditFilesysVirtual->setPosition((GUI_WIDTH - DIALOG_WIDTH) / 2, (GUI_HEIGHT - DIALOG_HEIGHT) / 2);
|
||||
wndEditFilesysVirtual->setBaseColor(gui_baseCol + 0x202020);
|
||||
wndEditFilesysVirtual->setCaption("Volume settings");
|
||||
wndEditFilesysVirtual->setTitleBarHeight(TITLEBAR_HEIGHT);
|
||||
|
||||
filesysVirtualActionListener = new FilesysVirtualActionListener();
|
||||
|
||||
cmdOK = new gcn::Button("Ok");
|
||||
cmdOK->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
|
||||
cmdOK->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - 2 * BUTTON_WIDTH - DISTANCE_NEXT_X, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
|
||||
cmdOK->setBaseColor(gui_baseCol + 0x202020);
|
||||
cmdOK->setId("virtOK");
|
||||
cmdOK->addActionListener(filesysVirtualActionListener);
|
||||
|
||||
cmdOK->setBaseColor(gui_baseCol + 0x202020);
|
||||
cmdOK->setId("virtOK");
|
||||
cmdOK->addActionListener(filesysVirtualActionListener);
|
||||
|
||||
cmdCancel = new gcn::Button("Cancel");
|
||||
cmdCancel->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
|
||||
cmdCancel->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - BUTTON_WIDTH, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
|
||||
cmdCancel->setBaseColor(gui_baseCol + 0x202020);
|
||||
cmdCancel->setId("virtCancel");
|
||||
cmdCancel->addActionListener(filesysVirtualActionListener);
|
||||
cmdCancel->setBaseColor(gui_baseCol + 0x202020);
|
||||
cmdCancel->setId("virtCancel");
|
||||
cmdCancel->addActionListener(filesysVirtualActionListener);
|
||||
|
||||
lblDevice = new gcn::Label("Device Name:");
|
||||
lblDevice->setSize(100, LABEL_HEIGHT);
|
||||
lblDevice->setAlignment(gcn::Graphics::RIGHT);
|
||||
txtDevice = new gcn::TextField();
|
||||
txtDevice->setSize(80, TEXTFIELD_HEIGHT);
|
||||
txtDevice->setId("virtDev");
|
||||
lblDevice = new gcn::Label("Device Name:");
|
||||
lblDevice->setSize(100, LABEL_HEIGHT);
|
||||
lblDevice->setAlignment(gcn::Graphics::RIGHT);
|
||||
txtDevice = new gcn::TextField();
|
||||
txtDevice->setSize(80, TEXTFIELD_HEIGHT);
|
||||
txtDevice->setId("virtDev");
|
||||
|
||||
lblVolume = new gcn::Label("Volume Label:");
|
||||
lblVolume->setSize(100, LABEL_HEIGHT);
|
||||
lblVolume->setAlignment(gcn::Graphics::RIGHT);
|
||||
txtVolume = new gcn::TextField();
|
||||
txtVolume->setSize(80, TEXTFIELD_HEIGHT);
|
||||
txtVolume->setId("virtVol");
|
||||
lblVolume = new gcn::Label("Volume Label:");
|
||||
lblVolume->setSize(100, LABEL_HEIGHT);
|
||||
lblVolume->setAlignment(gcn::Graphics::RIGHT);
|
||||
txtVolume = new gcn::TextField();
|
||||
txtVolume->setSize(80, TEXTFIELD_HEIGHT);
|
||||
txtVolume->setId("virtVol");
|
||||
|
||||
lblPath = new gcn::Label("Path:");
|
||||
lblPath->setSize(100, LABEL_HEIGHT);
|
||||
lblPath->setAlignment(gcn::Graphics::RIGHT);
|
||||
txtPath = new gcn::TextField();
|
||||
txtPath->setSize(338, TEXTFIELD_HEIGHT);
|
||||
txtPath->setEnabled(false);
|
||||
cmdPath = new gcn::Button("...");
|
||||
cmdPath->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
|
||||
cmdPath->setBaseColor(gui_baseCol + 0x202020);
|
||||
cmdPath->setId("virtPath");
|
||||
cmdPath->addActionListener(filesysVirtualActionListener);
|
||||
lblPath = new gcn::Label("Path:");
|
||||
lblPath->setSize(100, LABEL_HEIGHT);
|
||||
lblPath->setAlignment(gcn::Graphics::RIGHT);
|
||||
txtPath = new gcn::TextField();
|
||||
txtPath->setSize(338, TEXTFIELD_HEIGHT);
|
||||
txtPath->setEnabled(false);
|
||||
cmdPath = new gcn::Button("...");
|
||||
cmdPath->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
|
||||
cmdPath->setBaseColor(gui_baseCol + 0x202020);
|
||||
cmdPath->setId("virtPath");
|
||||
cmdPath->addActionListener(filesysVirtualActionListener);
|
||||
|
||||
chkReadWrite = new gcn::UaeCheckBox("Read/Write", true);
|
||||
chkReadWrite->setId("virtRW");
|
||||
chkReadWrite->setId("virtRW");
|
||||
|
||||
chkAutoboot = new gcn::UaeCheckBox("Bootable", true);
|
||||
chkAutoboot->setId("virtAutoboot");
|
||||
chkAutoboot->setId("virtAutoboot");
|
||||
|
||||
lblBootPri = new gcn::Label("Boot priority:");
|
||||
lblBootPri->setSize(84, LABEL_HEIGHT);
|
||||
lblBootPri->setAlignment(gcn::Graphics::RIGHT);
|
||||
txtBootPri = new gcn::TextField();
|
||||
txtBootPri->setSize(40, TEXTFIELD_HEIGHT);
|
||||
txtBootPri->setId("virtBootpri");
|
||||
|
||||
int posY = DISTANCE_BORDER;
|
||||
wndEditFilesysVirtual->add(lblDevice, DISTANCE_BORDER, posY);
|
||||
wndEditFilesysVirtual->add(txtDevice, DISTANCE_BORDER + lblDevice->getWidth() + 8, posY);
|
||||
wndEditFilesysVirtual->add(chkReadWrite, 250, posY + 1);
|
||||
posY += txtDevice->getHeight() + DISTANCE_NEXT_Y;
|
||||
wndEditFilesysVirtual->add(lblVolume, DISTANCE_BORDER, posY);
|
||||
wndEditFilesysVirtual->add(txtVolume, DISTANCE_BORDER + lblDevice->getWidth() + 8, posY);
|
||||
wndEditFilesysVirtual->add(chkAutoboot, 250, posY + 1);
|
||||
wndEditFilesysVirtual->add(lblBootPri, 374, posY);
|
||||
wndEditFilesysVirtual->add(txtBootPri, 374 + lblBootPri->getWidth() + 8, posY);
|
||||
posY += txtDevice->getHeight() + DISTANCE_NEXT_Y;
|
||||
wndEditFilesysVirtual->add(lblPath, DISTANCE_BORDER, posY);
|
||||
wndEditFilesysVirtual->add(txtPath, DISTANCE_BORDER + lblDevice->getWidth() + 8, posY);
|
||||
wndEditFilesysVirtual->add(cmdPath, wndEditFilesysVirtual->getWidth() - DISTANCE_BORDER - SMALL_BUTTON_WIDTH, posY);
|
||||
posY += txtDevice->getHeight() + DISTANCE_NEXT_Y;
|
||||
lblBootPri = new gcn::Label("Boot priority:");
|
||||
lblBootPri->setSize(84, LABEL_HEIGHT);
|
||||
lblBootPri->setAlignment(gcn::Graphics::RIGHT);
|
||||
txtBootPri = new gcn::TextField();
|
||||
txtBootPri->setSize(40, TEXTFIELD_HEIGHT);
|
||||
txtBootPri->setId("virtBootpri");
|
||||
|
||||
wndEditFilesysVirtual->add(cmdOK);
|
||||
wndEditFilesysVirtual->add(cmdCancel);
|
||||
int posY = DISTANCE_BORDER;
|
||||
wndEditFilesysVirtual->add(lblDevice, DISTANCE_BORDER, posY);
|
||||
wndEditFilesysVirtual->add(txtDevice, DISTANCE_BORDER + lblDevice->getWidth() + 8, posY);
|
||||
wndEditFilesysVirtual->add(chkReadWrite, 250, posY + 1);
|
||||
posY += txtDevice->getHeight() + DISTANCE_NEXT_Y;
|
||||
wndEditFilesysVirtual->add(lblVolume, DISTANCE_BORDER, posY);
|
||||
wndEditFilesysVirtual->add(txtVolume, DISTANCE_BORDER + lblDevice->getWidth() + 8, posY);
|
||||
wndEditFilesysVirtual->add(chkAutoboot, 250, posY + 1);
|
||||
wndEditFilesysVirtual->add(lblBootPri, 374, posY);
|
||||
wndEditFilesysVirtual->add(txtBootPri, 374 + lblBootPri->getWidth() + 8, posY);
|
||||
posY += txtDevice->getHeight() + DISTANCE_NEXT_Y;
|
||||
wndEditFilesysVirtual->add(lblPath, DISTANCE_BORDER, posY);
|
||||
wndEditFilesysVirtual->add(txtPath, DISTANCE_BORDER + lblDevice->getWidth() + 8, posY);
|
||||
wndEditFilesysVirtual->add(cmdPath, wndEditFilesysVirtual->getWidth() - DISTANCE_BORDER - SMALL_BUTTON_WIDTH, posY);
|
||||
posY += txtDevice->getHeight() + DISTANCE_NEXT_Y;
|
||||
|
||||
gui_top->add(wndEditFilesysVirtual);
|
||||
|
||||
txtDevice->requestFocus();
|
||||
wndEditFilesysVirtual->requestModalFocus();
|
||||
wndEditFilesysVirtual->add(cmdOK);
|
||||
wndEditFilesysVirtual->add(cmdCancel);
|
||||
|
||||
gui_top->add(wndEditFilesysVirtual);
|
||||
|
||||
txtDevice->requestFocus();
|
||||
wndEditFilesysVirtual->requestModalFocus();
|
||||
}
|
||||
|
||||
|
||||
static void ExitEditFilesysVirtual(void)
|
||||
{
|
||||
wndEditFilesysVirtual->releaseModalFocus();
|
||||
gui_top->remove(wndEditFilesysVirtual);
|
||||
wndEditFilesysVirtual->releaseModalFocus();
|
||||
gui_top->remove(wndEditFilesysVirtual);
|
||||
|
||||
delete lblDevice;
|
||||
delete txtDevice;
|
||||
delete lblVolume;
|
||||
delete txtVolume;
|
||||
delete lblPath;
|
||||
delete txtPath;
|
||||
delete cmdPath;
|
||||
delete chkReadWrite;
|
||||
delete chkAutoboot;
|
||||
delete lblBootPri;
|
||||
delete txtBootPri;
|
||||
|
||||
delete cmdOK;
|
||||
delete cmdCancel;
|
||||
delete filesysVirtualActionListener;
|
||||
|
||||
delete wndEditFilesysVirtual;
|
||||
delete lblDevice;
|
||||
delete txtDevice;
|
||||
delete lblVolume;
|
||||
delete txtVolume;
|
||||
delete lblPath;
|
||||
delete txtPath;
|
||||
delete cmdPath;
|
||||
delete chkReadWrite;
|
||||
delete chkAutoboot;
|
||||
delete lblBootPri;
|
||||
delete txtBootPri;
|
||||
|
||||
delete cmdOK;
|
||||
delete cmdCancel;
|
||||
delete filesysVirtualActionListener;
|
||||
|
||||
delete wndEditFilesysVirtual;
|
||||
}
|
||||
|
||||
|
||||
static void EditFilesysVirtualLoop(void)
|
||||
{
|
||||
while(!dialogFinished)
|
||||
{
|
||||
SDL_Event event;
|
||||
while(SDL_PollEvent(&event))
|
||||
{
|
||||
if (event.type == SDL_KEYDOWN)
|
||||
{
|
||||
switch(event.key.keysym.sym)
|
||||
{
|
||||
case SDLK_ESCAPE:
|
||||
dialogFinished = true;
|
||||
break;
|
||||
|
||||
case SDLK_UP:
|
||||
if(HandleNavigation(DIRECTION_UP))
|
||||
continue; // Don't change value when enter ComboBox -> don't send event to control
|
||||
break;
|
||||
|
||||
case SDLK_DOWN:
|
||||
if(HandleNavigation(DIRECTION_DOWN))
|
||||
continue; // Don't change value when enter ComboBox -> don't send event to control
|
||||
break;
|
||||
while (!dialogFinished)
|
||||
{
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event))
|
||||
{
|
||||
if (event.type == SDL_KEYDOWN)
|
||||
{
|
||||
switch (event.key.keysym.sym)
|
||||
{
|
||||
case SDLK_ESCAPE:
|
||||
dialogFinished = true;
|
||||
break;
|
||||
|
||||
case SDLK_LEFT:
|
||||
if(HandleNavigation(DIRECTION_LEFT))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
break;
|
||||
|
||||
case SDLK_RIGHT:
|
||||
if(HandleNavigation(DIRECTION_RIGHT))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
break;
|
||||
case SDLK_UP:
|
||||
if (HandleNavigation(DIRECTION_UP))
|
||||
continue; // Don't change value when enter ComboBox -> don't send event to control
|
||||
break;
|
||||
|
||||
case SDLK_PAGEDOWN:
|
||||
case SDLK_HOME:
|
||||
event.key.keysym.sym = SDLK_RETURN;
|
||||
gui_input->pushInput(event); // Fire key down
|
||||
event.type = SDL_KEYUP; // and the key up
|
||||
break;
|
||||
}
|
||||
}
|
||||
case SDLK_DOWN:
|
||||
if (HandleNavigation(DIRECTION_DOWN))
|
||||
continue; // Don't change value when enter ComboBox -> don't send event to control
|
||||
break;
|
||||
|
||||
//-------------------------------------------------
|
||||
// Send event to guichan-controls
|
||||
//-------------------------------------------------
|
||||
gui_input->pushInput(event);
|
||||
}
|
||||
case SDLK_LEFT:
|
||||
if (HandleNavigation(DIRECTION_LEFT))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
break;
|
||||
|
||||
// Now we let the Gui object perform its logic.
|
||||
uae_gui->logic();
|
||||
// Now we let the Gui object draw itself.
|
||||
uae_gui->draw();
|
||||
// Finally we update the screen.
|
||||
wait_for_vsync();
|
||||
SDL_Flip(gui_screen);
|
||||
}
|
||||
case SDLK_RIGHT:
|
||||
if (HandleNavigation(DIRECTION_RIGHT))
|
||||
continue; // Don't change value when enter Slider -> don't send event to control
|
||||
break;
|
||||
|
||||
case SDLK_PAGEDOWN:
|
||||
case SDLK_HOME:
|
||||
event.key.keysym.sym = SDLK_RETURN;
|
||||
gui_input->pushInput(event); // Fire key down
|
||||
event.type = SDL_KEYUP; // and the key up
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Send event to guichan-controls
|
||||
//-------------------------------------------------
|
||||
gui_input->pushInput(event);
|
||||
}
|
||||
|
||||
// Now we let the Gui object perform its logic.
|
||||
uae_gui->logic();
|
||||
// Now we let the Gui object draw itself.
|
||||
uae_gui->draw();
|
||||
// Finally we update the screen.
|
||||
wait_for_vsync();
|
||||
SDL_Flip(gui_screen);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool EditFilesysVirtual(int unit_no)
|
||||
{
|
||||
struct mountedinfo mi;
|
||||
struct uaedev_config_info *uci;
|
||||
std::string strdevname, strvolname, strroot;
|
||||
char tmp[32];
|
||||
|
||||
dialogResult = false;
|
||||
dialogFinished = false;
|
||||
struct mountedinfo mi;
|
||||
struct uaedev_config_info *uci;
|
||||
std::string strdevname, strvolname, strroot;
|
||||
char tmp[32];
|
||||
|
||||
InitEditFilesysVirtual();
|
||||
dialogResult = false;
|
||||
dialogFinished = false;
|
||||
|
||||
if(unit_no >= 0)
|
||||
{
|
||||
uci = &changed_prefs.mountconfig[unit_no];
|
||||
get_filesys_unitconfig(&changed_prefs, unit_no, &mi);
|
||||
InitEditFilesysVirtual();
|
||||
|
||||
strdevname.assign(uci->devname);
|
||||
txtDevice->setText(strdevname);
|
||||
strvolname.assign(uci->volname);
|
||||
txtVolume->setText(strvolname);
|
||||
strroot.assign(uci->rootdir);
|
||||
txtPath->setText(strroot);
|
||||
chkReadWrite->setSelected(!uci->readonly);
|
||||
chkAutoboot->setSelected(uci->bootpri != -128);
|
||||
snprintf(tmp, 32, "%d", uci->bootpri >= -127 ? uci->bootpri : -127);
|
||||
txtBootPri->setText(tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
CreateDefaultDevicename(tmp);
|
||||
txtDevice->setText(tmp);
|
||||
txtVolume->setText(tmp);
|
||||
strroot.assign(currentDir);
|
||||
txtPath->setText(strroot);
|
||||
chkReadWrite->setSelected(true);
|
||||
txtBootPri->setText("0");
|
||||
}
|
||||
if (unit_no >= 0)
|
||||
{
|
||||
uci = &changed_prefs.mountconfig[unit_no];
|
||||
get_filesys_unitconfig(&changed_prefs, unit_no, &mi);
|
||||
|
||||
EditFilesysVirtualLoop();
|
||||
|
||||
if(dialogResult)
|
||||
{
|
||||
int bp = tweakbootpri(atoi(txtBootPri->getText().c_str()), chkAutoboot->isSelected() ? 1 : 0, 0);
|
||||
extractPath((char *) txtPath->getText().c_str(), currentDir);
|
||||
|
||||
uci = add_filesys_config(&changed_prefs, unit_no, (char *) txtDevice->getText().c_str(),
|
||||
(char *) txtVolume->getText().c_str(), (char *) txtPath->getText().c_str(),
|
||||
!chkReadWrite->isSelected(), 0, 0, 0, 0, 0, bp, 0, 0, 0, 0, 0, 0);
|
||||
if (uci)
|
||||
filesys_media_change (uci->rootdir, 1, uci);
|
||||
}
|
||||
strdevname.assign(uci->devname);
|
||||
txtDevice->setText(strdevname);
|
||||
strvolname.assign(uci->volname);
|
||||
txtVolume->setText(strvolname);
|
||||
strroot.assign(uci->rootdir);
|
||||
txtPath->setText(strroot);
|
||||
chkReadWrite->setSelected(!uci->readonly);
|
||||
chkAutoboot->setSelected(uci->bootpri != -128);
|
||||
snprintf(tmp, 32, "%d", uci->bootpri >= -127 ? uci->bootpri : -127);
|
||||
txtBootPri->setText(tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
CreateDefaultDevicename(tmp);
|
||||
txtDevice->setText(tmp);
|
||||
txtVolume->setText(tmp);
|
||||
strroot.assign(currentDir);
|
||||
txtPath->setText(strroot);
|
||||
chkReadWrite->setSelected(true);
|
||||
txtBootPri->setText("0");
|
||||
}
|
||||
|
||||
ExitEditFilesysVirtual();
|
||||
EditFilesysVirtualLoop();
|
||||
|
||||
return dialogResult;
|
||||
if (dialogResult)
|
||||
{
|
||||
int bp = tweakbootpri(atoi(txtBootPri->getText().c_str()), chkAutoboot->isSelected() ? 1 : 0, 0);
|
||||
extractPath((char *) txtPath->getText().c_str(), currentDir);
|
||||
|
||||
uci = add_filesys_config(&changed_prefs,
|
||||
unit_no,
|
||||
(char *) txtDevice->getText().c_str(),
|
||||
(char *) txtVolume->getText().c_str(),
|
||||
(char *) txtPath->getText().c_str(),
|
||||
!chkReadWrite->isSelected(),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
bp,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
if (uci)
|
||||
filesys_media_change(uci->rootdir, 1, uci);
|
||||
}
|
||||
|
||||
ExitEditFilesysVirtual();
|
||||
|
||||
return dialogResult;
|
||||
}
|
||||
|
|
|
@ -14,130 +14,131 @@
|
|||
|
||||
|
||||
extern SDL_Surface *prSDLScreen;
|
||||
extern void flush_screen ();
|
||||
extern void flush_screen();
|
||||
|
||||
static int msg_done = 0;
|
||||
class DoneActionListener : public gcn::ActionListener
|
||||
{
|
||||
public:
|
||||
void action(const gcn::ActionEvent& actionEvent)
|
||||
{
|
||||
msg_done = 1;
|
||||
}
|
||||
public:
|
||||
void action(const gcn::ActionEvent& actionEvent)
|
||||
{
|
||||
msg_done = 1;
|
||||
}
|
||||
};
|
||||
static DoneActionListener* doneActionListener;
|
||||
|
||||
|
||||
void InGameMessage(const char *msg)
|
||||
{
|
||||
gcn::Gui* msg_gui;
|
||||
gcn::SDLGraphics* msg_graphics;
|
||||
gcn::SDLInput* msg_input;
|
||||
gcn::contrib::SDLTrueTypeFont* msg_font;
|
||||
gcn::Color msg_baseCol;
|
||||
gcn::Gui* msg_gui;
|
||||
gcn::SDLGraphics* msg_graphics;
|
||||
gcn::SDLInput* msg_input;
|
||||
gcn::contrib::SDLTrueTypeFont* msg_font;
|
||||
gcn::Color msg_baseCol;
|
||||
|
||||
gcn::Container* msg_top;
|
||||
gcn::Window *wndMsg;
|
||||
gcn::Button* cmdDone;
|
||||
gcn::TextBox* txtMsg;
|
||||
|
||||
int msgWidth = 260;
|
||||
int msgHeight = 100;
|
||||
|
||||
msg_graphics = new gcn::SDLGraphics();
|
||||
msg_graphics->setTarget(prSDLScreen);
|
||||
msg_input = new gcn::SDLInput();
|
||||
msg_gui = new gcn::Gui();
|
||||
msg_gui->setGraphics(msg_graphics);
|
||||
msg_gui->setInput(msg_input);
|
||||
|
||||
msg_baseCol.r = 192;
|
||||
msg_baseCol.g = 192;
|
||||
msg_baseCol.b = 208;
|
||||
gcn::Container* msg_top;
|
||||
gcn::Window *wndMsg;
|
||||
gcn::Button* cmdDone;
|
||||
gcn::TextBox* txtMsg;
|
||||
|
||||
msg_top = new gcn::Container();
|
||||
msg_top->setDimension(gcn::Rectangle((prSDLScreen->w - msgWidth) / 2, (prSDLScreen->h - msgHeight) / 2, msgWidth, msgHeight));
|
||||
msg_top->setBaseColor(msg_baseCol);
|
||||
msg_gui->setTop(msg_top);
|
||||
int msgWidth = 260;
|
||||
int msgHeight = 100;
|
||||
|
||||
TTF_Init();
|
||||
msg_font = new gcn::contrib::SDLTrueTypeFont("data/FreeSans.ttf", 10);
|
||||
gcn::Widget::setGlobalFont(msg_font);
|
||||
msg_graphics = new gcn::SDLGraphics();
|
||||
msg_graphics->setTarget(prSDLScreen);
|
||||
msg_input = new gcn::SDLInput();
|
||||
msg_gui = new gcn::Gui();
|
||||
msg_gui->setGraphics(msg_graphics);
|
||||
msg_gui->setInput(msg_input);
|
||||
|
||||
msg_baseCol.r = 192;
|
||||
msg_baseCol.g = 192;
|
||||
msg_baseCol.b = 208;
|
||||
|
||||
msg_top = new gcn::Container();
|
||||
msg_top->setDimension(gcn::Rectangle((prSDLScreen->w - msgWidth) / 2, (prSDLScreen->h - msgHeight) / 2, msgWidth, msgHeight));
|
||||
msg_top->setBaseColor(msg_baseCol);
|
||||
msg_gui->setTop(msg_top);
|
||||
|
||||
TTF_Init();
|
||||
msg_font = new gcn::contrib::SDLTrueTypeFont("data/FreeSans.ttf", 10);
|
||||
gcn::Widget::setGlobalFont(msg_font);
|
||||
|
||||
doneActionListener = new DoneActionListener();
|
||||
|
||||
doneActionListener = new DoneActionListener();
|
||||
|
||||
wndMsg = new gcn::Window("Load");
|
||||
wndMsg->setSize(msgWidth, msgHeight);
|
||||
wndMsg->setPosition(0, 0);
|
||||
wndMsg->setBaseColor(msg_baseCol + 0x202020);
|
||||
wndMsg->setCaption("Information");
|
||||
wndMsg->setTitleBarHeight(12);
|
||||
wndMsg->setPosition(0, 0);
|
||||
wndMsg->setBaseColor(msg_baseCol + 0x202020);
|
||||
wndMsg->setCaption("Information");
|
||||
wndMsg->setTitleBarHeight(12);
|
||||
|
||||
cmdDone = new gcn::Button("Ok");
|
||||
cmdDone->setSize(40, 20);
|
||||
cmdDone->setBaseColor(msg_baseCol + 0x202020);
|
||||
cmdDone->addActionListener(doneActionListener);
|
||||
|
||||
txtMsg = new gcn::TextBox(msg);
|
||||
txtMsg->setEnabled(false);
|
||||
txtMsg->setPosition(6, 6);
|
||||
txtMsg->setSize(wndMsg->getWidth() - 16, 46);
|
||||
txtMsg->setOpaque(false);
|
||||
|
||||
wndMsg->add(txtMsg, 6, 6);
|
||||
wndMsg->add(cmdDone, (wndMsg->getWidth() - cmdDone->getWidth()) / 2, wndMsg->getHeight() - 38);
|
||||
cmdDone->setBaseColor(msg_baseCol + 0x202020);
|
||||
cmdDone->addActionListener(doneActionListener);
|
||||
|
||||
msg_top->add(wndMsg);
|
||||
cmdDone->requestFocus();
|
||||
|
||||
msg_done = 0;
|
||||
bool drawn = false;
|
||||
while(!msg_done)
|
||||
{
|
||||
//-------------------------------------------------
|
||||
// Check user input
|
||||
//-------------------------------------------------
|
||||
SDL_Event event;
|
||||
while(SDL_PollEvent(&event))
|
||||
{
|
||||
if (event.type == SDL_KEYDOWN)
|
||||
{
|
||||
switch(event.key.keysym.sym)
|
||||
{
|
||||
case SDLK_PAGEDOWN:
|
||||
case SDLK_HOME:
|
||||
case SDLK_RETURN:
|
||||
msg_done = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
txtMsg = new gcn::TextBox(msg);
|
||||
txtMsg->setEnabled(false);
|
||||
txtMsg->setPosition(6, 6);
|
||||
txtMsg->setSize(wndMsg->getWidth() - 16, 46);
|
||||
txtMsg->setOpaque(false);
|
||||
|
||||
//-------------------------------------------------
|
||||
// Send event to guichan-controls
|
||||
//-------------------------------------------------
|
||||
msg_input->pushInput(event);
|
||||
}
|
||||
wndMsg->add(txtMsg, 6, 6);
|
||||
wndMsg->add(cmdDone, (wndMsg->getWidth() - cmdDone->getWidth()) / 2, wndMsg->getHeight() - 38);
|
||||
|
||||
// Now we let the Gui object perform its logic.
|
||||
msg_gui->logic();
|
||||
// Now we let the Gui object draw itself.
|
||||
msg_gui->draw();
|
||||
// Finally we update the screen.
|
||||
//SDL_Flip(prSDLScreen);
|
||||
flush_screen ();
|
||||
}
|
||||
msg_top->add(wndMsg);
|
||||
cmdDone->requestFocus();
|
||||
|
||||
msg_top->remove(wndMsg);
|
||||
msg_done = 0;
|
||||
bool drawn = false;
|
||||
while (!msg_done)
|
||||
{
|
||||
//-------------------------------------------------
|
||||
// Check user input
|
||||
//-------------------------------------------------
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event))
|
||||
{
|
||||
if (event.type == SDL_KEYDOWN)
|
||||
{
|
||||
switch (event.key.keysym.sym)
|
||||
{
|
||||
case SDLK_PAGEDOWN:
|
||||
case SDLK_HOME:
|
||||
case SDLK_RETURN:
|
||||
msg_done = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
delete txtMsg;
|
||||
delete cmdDone;
|
||||
delete doneActionListener;
|
||||
delete wndMsg;
|
||||
|
||||
delete msg_font;
|
||||
delete msg_top;
|
||||
|
||||
delete msg_gui;
|
||||
delete msg_input;
|
||||
delete msg_graphics;
|
||||
//-------------------------------------------------
|
||||
// Send event to guichan-controls
|
||||
//-------------------------------------------------
|
||||
msg_input->pushInput(event);
|
||||
}
|
||||
|
||||
// Now we let the Gui object perform its logic.
|
||||
msg_gui->logic();
|
||||
// Now we let the Gui object draw itself.
|
||||
msg_gui->draw();
|
||||
// Finally we update the screen.
|
||||
if (!drawn)
|
||||
SDL_Flip(prSDLScreen);
|
||||
drawn = true;
|
||||
}
|
||||
|
||||
msg_top->remove(wndMsg);
|
||||
|
||||
delete txtMsg;
|
||||
delete cmdDone;
|
||||
delete doneActionListener;
|
||||
delete wndMsg;
|
||||
|
||||
delete msg_font;
|
||||
delete msg_top;
|
||||
|
||||
delete msg_gui;
|
||||
delete msg_input;
|
||||
delete msg_graphics;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "sysdeps.h"
|
||||
#include "config.h"
|
||||
#include "options.h"
|
||||
#include "memory.h"
|
||||
#include "include/memory.h"
|
||||
#include "uae.h"
|
||||
#include "gui.h"
|
||||
#include "gui_handling.h"
|
||||
|
@ -33,49 +33,54 @@ static gcn::Label* lblSlowsize;
|
|||
static gcn::Slider* sldSlowmem;
|
||||
static gcn::Label* lblFastmem;
|
||||
static gcn::Label* lblFastsize;
|
||||
static gcn::Slider* sldFastmem;
|
||||
static gcn::Slider* sldFastmem;
|
||||
static gcn::Label* lblZ3mem;
|
||||
static gcn::Label* lblZ3size;
|
||||
static gcn::Slider* sldZ3mem;
|
||||
static gcn::Slider* sldZ3mem;
|
||||
static gcn::Label* lblGfxmem;
|
||||
static gcn::Label* lblGfxsize;
|
||||
static gcn::Slider* sldGfxmem;
|
||||
static gcn::Slider* sldGfxmem;
|
||||
|
||||
|
||||
class MemorySliderActionListener : public gcn::ActionListener
|
||||
{
|
||||
public:
|
||||
void action(const gcn::ActionEvent& actionEvent)
|
||||
{
|
||||
if (actionEvent.getSource() == sldChipmem) {
|
||||
changed_prefs.chipmem_size = ChipMem_values[(int)(sldChipmem->getValue())];
|
||||
if ((changed_prefs.chipmem_size > 0x200000) && (changed_prefs.fastmem_size > 0))
|
||||
changed_prefs.fastmem_size = 0;
|
||||
}
|
||||
|
||||
if (actionEvent.getSource() == sldSlowmem) {
|
||||
changed_prefs.bogomem_size = SlowMem_values[(int)(sldSlowmem->getValue())];
|
||||
}
|
||||
|
||||
if (actionEvent.getSource() == sldFastmem) {
|
||||
changed_prefs.fastmem_size = FastMem_values[(int)(sldFastmem->getValue())];
|
||||
if (changed_prefs.fastmem_size > 0 && changed_prefs.chipmem_size > 0x200000)
|
||||
changed_prefs.chipmem_size = 0x200000;
|
||||
}
|
||||
public:
|
||||
void action(const gcn::ActionEvent& actionEvent)
|
||||
{
|
||||
if (actionEvent.getSource() == sldChipmem)
|
||||
{
|
||||
changed_prefs.chipmem_size = ChipMem_values[(int)(sldChipmem->getValue())];
|
||||
if ((changed_prefs.chipmem_size > 0x200000) && (changed_prefs.fastmem_size > 0))
|
||||
changed_prefs.fastmem_size = 0;
|
||||
}
|
||||
|
||||
if (actionEvent.getSource() == sldZ3mem) {
|
||||
changed_prefs.z3fastmem_size = FastMem_values[(int)(sldZ3mem->getValue())];
|
||||
if (changed_prefs.z3fastmem_size > max_z3fastmem)
|
||||
changed_prefs.z3fastmem_size = max_z3fastmem;
|
||||
}
|
||||
if (actionEvent.getSource() == sldSlowmem)
|
||||
{
|
||||
changed_prefs.bogomem_size = SlowMem_values[(int)(sldSlowmem->getValue())];
|
||||
}
|
||||
|
||||
if (actionEvent.getSource() == sldGfxmem) {
|
||||
changed_prefs.rtgmem_size = FastMem_values[(int)(sldGfxmem->getValue())];
|
||||
changed_prefs.rtgmem_type = 1;
|
||||
}
|
||||
if (actionEvent.getSource() == sldFastmem)
|
||||
{
|
||||
changed_prefs.fastmem_size = FastMem_values[(int)(sldFastmem->getValue())];
|
||||
if (changed_prefs.fastmem_size > 0 && changed_prefs.chipmem_size > 0x200000)
|
||||
changed_prefs.chipmem_size = 0x200000;
|
||||
}
|
||||
|
||||
RefreshPanelRAM();
|
||||
}
|
||||
if (actionEvent.getSource() == sldZ3mem)
|
||||
{
|
||||
changed_prefs.z3fastmem_size = FastMem_values[(int)(sldZ3mem->getValue())];
|
||||
if (changed_prefs.z3fastmem_size > max_z3fastmem)
|
||||
changed_prefs.z3fastmem_size = max_z3fastmem;
|
||||
}
|
||||
|
||||
if (actionEvent.getSource() == sldGfxmem)
|
||||
{
|
||||
changed_prefs.rtgmem_size = FastMem_values[(int)(sldGfxmem->getValue())];
|
||||
changed_prefs.rtgmem_type = 1;
|
||||
}
|
||||
|
||||
RefreshPanelRAM();
|
||||
}
|
||||
};
|
||||
static MemorySliderActionListener* memorySliderActionListener;
|
||||
|
||||
|
@ -83,7 +88,7 @@ static MemorySliderActionListener* memorySliderActionListener;
|
|||
void InitPanelRAM(const struct _ConfigCategory& category)
|
||||
{
|
||||
memorySliderActionListener = new MemorySliderActionListener();
|
||||
|
||||
|
||||
lblChipmem = new gcn::Label("Chip:");
|
||||
sldChipmem = new gcn::Slider(0, 4);
|
||||
sldChipmem->setSize(110, SLIDER_HEIGHT);
|
||||
|
@ -147,7 +152,7 @@ void InitPanelRAM(const struct _ConfigCategory& category)
|
|||
grpRAM->add(sldSlowmem, 70, posY);
|
||||
grpRAM->add(lblSlowsize, 70 + sldSlowmem->getWidth() + 12, posY);
|
||||
posY += sldSlowmem->getHeight() + DISTANCE_NEXT_Y;
|
||||
|
||||
|
||||
grpRAM->add(lblFastmem, 8, posY);
|
||||
grpRAM->add(sldFastmem, 70, posY);
|
||||
grpRAM->add(lblFastsize, 70 + sldFastmem->getWidth() + 12, posY);
|
||||
|
@ -166,88 +171,88 @@ void InitPanelRAM(const struct _ConfigCategory& category)
|
|||
grpRAM->setMovable(false);
|
||||
grpRAM->setSize(250, posY + DISTANCE_BORDER);
|
||||
grpRAM->setBaseColor(gui_baseCol);
|
||||
|
||||
|
||||
category.panel->add(grpRAM);
|
||||
|
||||
|
||||
RefreshPanelRAM();
|
||||
}
|
||||
|
||||
|
||||
void ExitPanelRAM(void)
|
||||
{
|
||||
delete lblChipmem;
|
||||
delete sldChipmem;
|
||||
delete lblChipsize;
|
||||
delete lblSlowmem;
|
||||
delete sldSlowmem;
|
||||
delete lblSlowsize;
|
||||
delete lblFastmem;
|
||||
delete sldFastmem;
|
||||
delete lblFastsize;
|
||||
delete lblZ3mem;
|
||||
delete sldZ3mem;
|
||||
delete lblZ3size;
|
||||
delete lblGfxmem;
|
||||
delete sldGfxmem;
|
||||
delete lblGfxsize;
|
||||
delete grpRAM;
|
||||
delete memorySliderActionListener;
|
||||
delete lblChipmem;
|
||||
delete sldChipmem;
|
||||
delete lblChipsize;
|
||||
delete lblSlowmem;
|
||||
delete sldSlowmem;
|
||||
delete lblSlowsize;
|
||||
delete lblFastmem;
|
||||
delete sldFastmem;
|
||||
delete lblFastsize;
|
||||
delete lblZ3mem;
|
||||
delete sldZ3mem;
|
||||
delete lblZ3size;
|
||||
delete lblGfxmem;
|
||||
delete sldGfxmem;
|
||||
delete lblGfxsize;
|
||||
delete grpRAM;
|
||||
delete memorySliderActionListener;
|
||||
}
|
||||
|
||||
|
||||
void RefreshPanelRAM(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i<5; ++i)
|
||||
{
|
||||
if(changed_prefs.chipmem_size == ChipMem_values[i])
|
||||
{
|
||||
sldChipmem->setValue(i);
|
||||
lblChipsize->setCaption(ChipMem_list[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
int i;
|
||||
|
||||
for(i=0; i<5; ++i)
|
||||
{
|
||||
if(changed_prefs.bogomem_size == SlowMem_values[i])
|
||||
{
|
||||
sldSlowmem->setValue(i);
|
||||
lblSlowsize->setCaption(SlowMem_list[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 5; ++i)
|
||||
{
|
||||
if (changed_prefs.chipmem_size == ChipMem_values[i])
|
||||
{
|
||||
sldChipmem->setValue(i);
|
||||
lblChipsize->setCaption(ChipMem_list[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for(i=0; i<5; ++i)
|
||||
{
|
||||
if(changed_prefs.fastmem_size == FastMem_values[i])
|
||||
{
|
||||
sldFastmem->setValue(i);
|
||||
lblFastsize->setCaption(FastMem_list[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 5; ++i)
|
||||
{
|
||||
if (changed_prefs.bogomem_size == SlowMem_values[i])
|
||||
{
|
||||
sldSlowmem->setValue(i);
|
||||
lblSlowsize->setCaption(SlowMem_list[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for(i=0; i<9; ++i)
|
||||
{
|
||||
if(changed_prefs.z3fastmem_size == FastMem_values[i])
|
||||
{
|
||||
sldZ3mem->setValue(i);
|
||||
lblZ3size->setCaption(FastMem_list[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
sldZ3mem->setEnabled(!changed_prefs.address_space_24);
|
||||
for (i = 0; i < 5; ++i)
|
||||
{
|
||||
if (changed_prefs.fastmem_size == FastMem_values[i])
|
||||
{
|
||||
sldFastmem->setValue(i);
|
||||
lblFastsize->setCaption(FastMem_list[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for(i=0; i<6; ++i)
|
||||
{
|
||||
if(changed_prefs.rtgmem_size == FastMem_values[i])
|
||||
{
|
||||
sldGfxmem->setValue(i);
|
||||
lblGfxsize->setCaption(FastMem_list[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
sldGfxmem->setEnabled(!changed_prefs.address_space_24);
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
if (changed_prefs.z3fastmem_size == FastMem_values[i])
|
||||
{
|
||||
sldZ3mem->setValue(i);
|
||||
lblZ3size->setCaption(FastMem_list[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
sldZ3mem->setEnabled(!changed_prefs.address_space_24);
|
||||
|
||||
for (i = 0; i < 6; ++i)
|
||||
{
|
||||
if (changed_prefs.rtgmem_size == FastMem_values[i])
|
||||
{
|
||||
sldGfxmem->setValue(i);
|
||||
lblGfxsize->setCaption(FastMem_list[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
sldGfxmem->setEnabled(!changed_prefs.address_space_24);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#define DIALOG_WIDTH 520
|
||||
#define DIALOG_HEIGHT 400
|
||||
|
||||
#ifdef RASPBERRY
|
||||
#if defined(RASPBERRY) || defined(ANDROID)
|
||||
#define FILE_SELECT_KEEP_POSITION
|
||||
#endif
|
||||
|
||||
|
@ -43,323 +43,323 @@ static gcn::TextField *txtFilename;
|
|||
|
||||
class SelectFileListModel : public gcn::ListModel
|
||||
{
|
||||
std::vector<std::string> dirs;
|
||||
std::vector<std::string> files;
|
||||
std::vector<std::string> dirs;
|
||||
std::vector<std::string> files;
|
||||
|
||||
public:
|
||||
SelectFileListModel(const char * path)
|
||||
{
|
||||
changeDir(path);
|
||||
}
|
||||
|
||||
int getNumberOfElements()
|
||||
{
|
||||
return dirs.size() + files.size();
|
||||
}
|
||||
|
||||
std::string getElementAt(int i)
|
||||
{
|
||||
if(i >= dirs.size() + files.size() || i < 0)
|
||||
return "---";
|
||||
if(i < dirs.size())
|
||||
return dirs[i];
|
||||
return files[i - dirs.size()];
|
||||
}
|
||||
|
||||
void changeDir(const char *path)
|
||||
{
|
||||
ReadDirectory(path, &dirs, &files);
|
||||
if(dirs.size() == 0)
|
||||
dirs.push_back("..");
|
||||
FilterFiles(&files, filefilter);
|
||||
}
|
||||
public:
|
||||
SelectFileListModel(const char * path)
|
||||
{
|
||||
changeDir(path);
|
||||
}
|
||||
|
||||
bool isDir(int i)
|
||||
{
|
||||
return (i < dirs.size());
|
||||
}
|
||||
int getNumberOfElements()
|
||||
{
|
||||
return dirs.size() + files.size();
|
||||
}
|
||||
|
||||
std::string getElementAt(int i)
|
||||
{
|
||||
if (i >= dirs.size() + files.size() || i < 0)
|
||||
return "---";
|
||||
if (i < dirs.size())
|
||||
return dirs[i];
|
||||
return files[i - dirs.size()];
|
||||
}
|
||||
|
||||
void changeDir(const char *path)
|
||||
{
|
||||
ReadDirectory(path, &dirs, &files);
|
||||
if (dirs.size() == 0)
|
||||
dirs.push_back("..");
|
||||
FilterFiles(&files, filefilter);
|
||||
}
|
||||
|
||||
bool isDir(int i)
|
||||
{
|
||||
return (i < dirs.size());
|
||||
}
|
||||
};
|
||||
static SelectFileListModel *fileList;
|
||||
|
||||
|
||||
class FileButtonActionListener : public gcn::ActionListener
|
||||
{
|
||||
public:
|
||||
void action(const gcn::ActionEvent& actionEvent)
|
||||
{
|
||||
if (actionEvent.getSource() == cmdOK)
|
||||
{
|
||||
int selected_item;
|
||||
selected_item = lstFiles->getSelected();
|
||||
if(createNew)
|
||||
{
|
||||
char tmp[MAX_PATH];
|
||||
if(txtFilename->getText().length() <= 0)
|
||||
return;
|
||||
strcpy(tmp, workingDir);
|
||||
strcat(tmp, "/");
|
||||
strcat(tmp, txtFilename->getText().c_str());
|
||||
if(strstr(tmp, filefilter[0]) == NULL)
|
||||
strcat(tmp, filefilter[0]);
|
||||
if(my_existsfile(tmp) == 1)
|
||||
return; // File already exists
|
||||
strcpy(workingDir, tmp);
|
||||
dialogResult = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(fileList->isDir(selected_item))
|
||||
return; // Directory selected -> Ok not possible
|
||||
strcat(workingDir, "/");
|
||||
strcat(workingDir, fileList->getElementAt(selected_item).c_str());
|
||||
dialogResult = true;
|
||||
}
|
||||
}
|
||||
dialogFinished = true;
|
||||
}
|
||||
public:
|
||||
void action(const gcn::ActionEvent& actionEvent)
|
||||
{
|
||||
if (actionEvent.getSource() == cmdOK)
|
||||
{
|
||||
int selected_item;
|
||||
selected_item = lstFiles->getSelected();
|
||||
if (createNew)
|
||||
{
|
||||
char tmp[MAX_PATH];
|
||||
if (txtFilename->getText().length() <= 0)
|
||||
return;
|
||||
strcpy(tmp, workingDir);
|
||||
strcat(tmp, "/");
|
||||
strcat(tmp, txtFilename->getText().c_str());
|
||||
if (strstr(tmp, filefilter[0]) == NULL)
|
||||
strcat(tmp, filefilter[0]);
|
||||
if (my_existsfile(tmp) == 1)
|
||||
return; // File already exists
|
||||
strcpy(workingDir, tmp);
|
||||
dialogResult = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fileList->isDir(selected_item))
|
||||
return; // Directory selected -> Ok not possible
|
||||
strcat(workingDir, "/");
|
||||
strcat(workingDir, fileList->getElementAt(selected_item).c_str());
|
||||
dialogResult = true;
|
||||
}
|
||||
}
|
||||
dialogFinished = true;
|
||||
}
|
||||
};
|
||||
static FileButtonActionListener* fileButtonActionListener;
|
||||
|
||||
|
||||
static void checkfoldername (char *current)
|
||||
static void checkfoldername(char *current)
|
||||
{
|
||||
char *ptr;
|
||||
char actualpath [MAX_PATH];
|
||||
char actualpath[MAX_PATH];
|
||||
DIR *dir;
|
||||
|
||||
|
||||
if (dir = opendir(current))
|
||||
{
|
||||
fileList->changeDir(current);
|
||||
ptr = realpath(current, actualpath);
|
||||
strcpy(workingDir, ptr);
|
||||
closedir(dir);
|
||||
{
|
||||
fileList->changeDir(current);
|
||||
ptr = realpath(current, actualpath);
|
||||
strcpy(workingDir, ptr);
|
||||
closedir(dir);
|
||||
}
|
||||
else
|
||||
strcpy(workingDir, start_path_data);
|
||||
txtCurrent->setText(workingDir);
|
||||
else
|
||||
strcpy(workingDir, start_path_data);
|
||||
txtCurrent->setText(workingDir);
|
||||
}
|
||||
|
||||
static void checkfilename(char *current)
|
||||
{
|
||||
char actfile[MAX_PATH];
|
||||
extractFileName(current, actfile);
|
||||
for(int i=0; i<fileList->getNumberOfElements(); ++i)
|
||||
{
|
||||
if(!fileList->isDir(i) && !strcasecmp(fileList->getElementAt(i).c_str(), actfile))
|
||||
{
|
||||
lstFiles->setSelected(i);
|
||||
selectedOnStart = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
char actfile[MAX_PATH];
|
||||
extractFileName(current, actfile);
|
||||
for (int i = 0; i < fileList->getNumberOfElements(); ++i)
|
||||
{
|
||||
if (!fileList->isDir(i) && !strcasecmp(fileList->getElementAt(i).c_str(), actfile))
|
||||
{
|
||||
lstFiles->setSelected(i);
|
||||
selectedOnStart = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class SelectFileActionListener : public gcn::ActionListener
|
||||
{
|
||||
public:
|
||||
void action(const gcn::ActionEvent& actionEvent)
|
||||
{
|
||||
int selected_item;
|
||||
char foldername[256] = "";
|
||||
public:
|
||||
void action(const gcn::ActionEvent& actionEvent)
|
||||
{
|
||||
int selected_item;
|
||||
char foldername[256] = "";
|
||||
|
||||
selected_item = lstFiles->getSelected();
|
||||
strcpy(foldername, workingDir);
|
||||
strcat(foldername, "/");
|
||||
strcat(foldername, fileList->getElementAt(selected_item).c_str());
|
||||
if(fileList->isDir(selected_item))
|
||||
checkfoldername(foldername);
|
||||
else if(!createNew)
|
||||
{
|
||||
strncpy(workingDir, foldername, sizeof(workingDir));
|
||||
dialogResult = true;
|
||||
dialogFinished = true;
|
||||
}
|
||||
}
|
||||
selected_item = lstFiles->getSelected();
|
||||
strcpy(foldername, workingDir);
|
||||
strcat(foldername, "/");
|
||||
strcat(foldername, fileList->getElementAt(selected_item).c_str());
|
||||
if (fileList->isDir(selected_item))
|
||||
checkfoldername(foldername);
|
||||
else if (!createNew)
|
||||
{
|
||||
strncpy(workingDir, foldername, sizeof(workingDir));
|
||||
dialogResult = true;
|
||||
dialogFinished = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
static SelectFileActionListener* selectFileActionListener;
|
||||
|
||||
|
||||
static void InitSelectFile(const char *title)
|
||||
{
|
||||
wndSelectFile = new gcn::Window("Load");
|
||||
wndSelectFile->setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
|
||||
wndSelectFile->setPosition((GUI_WIDTH - DIALOG_WIDTH) / 2, (GUI_HEIGHT - DIALOG_HEIGHT) / 2);
|
||||
wndSelectFile->setBaseColor(gui_baseCol + 0x202020);
|
||||
wndSelectFile->setCaption(title);
|
||||
wndSelectFile->setTitleBarHeight(TITLEBAR_HEIGHT);
|
||||
|
||||
fileButtonActionListener = new FileButtonActionListener();
|
||||
|
||||
cmdOK = new gcn::Button("Ok");
|
||||
cmdOK->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
|
||||
cmdOK->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - 2 * BUTTON_WIDTH - DISTANCE_NEXT_X, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
|
||||
cmdOK->setBaseColor(gui_baseCol + 0x202020);
|
||||
cmdOK->addActionListener(fileButtonActionListener);
|
||||
|
||||
cmdCancel = new gcn::Button("Cancel");
|
||||
cmdCancel->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
|
||||
cmdCancel->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - BUTTON_WIDTH, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
|
||||
cmdCancel->setBaseColor(gui_baseCol + 0x202020);
|
||||
cmdCancel->addActionListener(fileButtonActionListener);
|
||||
wndSelectFile = new gcn::Window("Load");
|
||||
wndSelectFile->setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
|
||||
wndSelectFile->setPosition((GUI_WIDTH - DIALOG_WIDTH) / 2, (GUI_HEIGHT - DIALOG_HEIGHT) / 2);
|
||||
wndSelectFile->setBaseColor(gui_baseCol + 0x202020);
|
||||
wndSelectFile->setCaption(title);
|
||||
wndSelectFile->setTitleBarHeight(TITLEBAR_HEIGHT);
|
||||
|
||||
txtCurrent = new gcn::TextField();
|
||||
txtCurrent->setSize(DIALOG_WIDTH - 2 * DISTANCE_BORDER - 4, TEXTFIELD_HEIGHT);
|
||||
txtCurrent->setPosition(DISTANCE_BORDER, 10);
|
||||
txtCurrent->setEnabled(false);
|
||||
fileButtonActionListener = new FileButtonActionListener();
|
||||
|
||||
selectFileActionListener = new SelectFileActionListener();
|
||||
fileList = new SelectFileListModel(".");
|
||||
cmdOK = new gcn::Button("Ok");
|
||||
cmdOK->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
|
||||
cmdOK->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - 2 * BUTTON_WIDTH - DISTANCE_NEXT_X, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
|
||||
cmdOK->setBaseColor(gui_baseCol + 0x202020);
|
||||
cmdOK->addActionListener(fileButtonActionListener);
|
||||
|
||||
lstFiles = new gcn::ListBox(fileList);
|
||||
lstFiles->setSize(800, 252);
|
||||
lstFiles->setBaseColor(gui_baseCol);
|
||||
lstFiles->setWrappingEnabled(true);
|
||||
lstFiles->addActionListener(selectFileActionListener);
|
||||
|
||||
scrAreaFiles = new gcn::ScrollArea(lstFiles);
|
||||
scrAreaFiles->setFrameSize(1);
|
||||
scrAreaFiles->setPosition(DISTANCE_BORDER, 10 + TEXTFIELD_HEIGHT + 10);
|
||||
scrAreaFiles->setSize(DIALOG_WIDTH - 2 * DISTANCE_BORDER - 4, 272);
|
||||
scrAreaFiles->setScrollbarWidth(20);
|
||||
scrAreaFiles->setBaseColor(gui_baseCol + 0x202020);
|
||||
cmdCancel = new gcn::Button("Cancel");
|
||||
cmdCancel->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
|
||||
cmdCancel->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - BUTTON_WIDTH, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
|
||||
cmdCancel->setBaseColor(gui_baseCol + 0x202020);
|
||||
cmdCancel->addActionListener(fileButtonActionListener);
|
||||
|
||||
if(createNew)
|
||||
{
|
||||
scrAreaFiles->setSize(DIALOG_WIDTH - 2 * DISTANCE_BORDER - 4, 272 - TEXTFIELD_HEIGHT - DISTANCE_NEXT_Y);
|
||||
lblFilename = new gcn::Label("Filename:");
|
||||
lblFilename->setSize(80, LABEL_HEIGHT);
|
||||
lblFilename->setAlignment(gcn::Graphics::LEFT);
|
||||
lblFilename->setPosition(DISTANCE_BORDER, scrAreaFiles->getY() + scrAreaFiles->getHeight() + DISTANCE_NEXT_Y);
|
||||
txtFilename = new gcn::TextField();
|
||||
txtFilename->setSize(120, TEXTFIELD_HEIGHT);
|
||||
txtFilename->setId("Filename");
|
||||
txtFilename->setPosition(lblFilename->getX() + lblFilename->getWidth() + DISTANCE_NEXT_X, lblFilename->getY());
|
||||
|
||||
wndSelectFile->add(lblFilename);
|
||||
wndSelectFile->add(txtFilename);
|
||||
}
|
||||
|
||||
wndSelectFile->add(cmdOK);
|
||||
wndSelectFile->add(cmdCancel);
|
||||
wndSelectFile->add(txtCurrent);
|
||||
wndSelectFile->add(scrAreaFiles);
|
||||
|
||||
gui_top->add(wndSelectFile);
|
||||
|
||||
lstFiles->requestFocus();
|
||||
lstFiles->setSelected(0);
|
||||
wndSelectFile->requestModalFocus();
|
||||
txtCurrent = new gcn::TextField();
|
||||
txtCurrent->setSize(DIALOG_WIDTH - 2 * DISTANCE_BORDER - 4, TEXTFIELD_HEIGHT);
|
||||
txtCurrent->setPosition(DISTANCE_BORDER, 10);
|
||||
txtCurrent->setEnabled(false);
|
||||
|
||||
selectFileActionListener = new SelectFileActionListener();
|
||||
fileList = new SelectFileListModel(".");
|
||||
|
||||
lstFiles = new gcn::ListBox(fileList);
|
||||
lstFiles->setSize(800, 252);
|
||||
lstFiles->setBaseColor(gui_baseCol);
|
||||
lstFiles->setWrappingEnabled(true);
|
||||
lstFiles->addActionListener(selectFileActionListener);
|
||||
|
||||
scrAreaFiles = new gcn::ScrollArea(lstFiles);
|
||||
scrAreaFiles->setFrameSize(1);
|
||||
scrAreaFiles->setPosition(DISTANCE_BORDER, 10 + TEXTFIELD_HEIGHT + 10);
|
||||
scrAreaFiles->setSize(DIALOG_WIDTH - 2 * DISTANCE_BORDER - 4, 272);
|
||||
scrAreaFiles->setScrollbarWidth(20);
|
||||
scrAreaFiles->setBaseColor(gui_baseCol + 0x202020);
|
||||
|
||||
if (createNew)
|
||||
{
|
||||
scrAreaFiles->setSize(DIALOG_WIDTH - 2 * DISTANCE_BORDER - 4, 272 - TEXTFIELD_HEIGHT - DISTANCE_NEXT_Y);
|
||||
lblFilename = new gcn::Label("Filename:");
|
||||
lblFilename->setSize(80, LABEL_HEIGHT);
|
||||
lblFilename->setAlignment(gcn::Graphics::LEFT);
|
||||
lblFilename->setPosition(DISTANCE_BORDER, scrAreaFiles->getY() + scrAreaFiles->getHeight() + DISTANCE_NEXT_Y);
|
||||
txtFilename = new gcn::TextField();
|
||||
txtFilename->setSize(120, TEXTFIELD_HEIGHT);
|
||||
txtFilename->setId("Filename");
|
||||
txtFilename->setPosition(lblFilename->getX() + lblFilename->getWidth() + DISTANCE_NEXT_X, lblFilename->getY());
|
||||
|
||||
wndSelectFile->add(lblFilename);
|
||||
wndSelectFile->add(txtFilename);
|
||||
}
|
||||
|
||||
wndSelectFile->add(cmdOK);
|
||||
wndSelectFile->add(cmdCancel);
|
||||
wndSelectFile->add(txtCurrent);
|
||||
wndSelectFile->add(scrAreaFiles);
|
||||
|
||||
gui_top->add(wndSelectFile);
|
||||
|
||||
lstFiles->requestFocus();
|
||||
lstFiles->setSelected(0);
|
||||
wndSelectFile->requestModalFocus();
|
||||
}
|
||||
|
||||
|
||||
static void ExitSelectFile(void)
|
||||
{
|
||||
wndSelectFile->releaseModalFocus();
|
||||
gui_top->remove(wndSelectFile);
|
||||
wndSelectFile->releaseModalFocus();
|
||||
gui_top->remove(wndSelectFile);
|
||||
|
||||
delete cmdOK;
|
||||
delete cmdCancel;
|
||||
delete fileButtonActionListener;
|
||||
|
||||
delete txtCurrent;
|
||||
delete lstFiles;
|
||||
delete scrAreaFiles;
|
||||
delete selectFileActionListener;
|
||||
delete fileList;
|
||||
if(createNew)
|
||||
{
|
||||
delete lblFilename;
|
||||
delete txtFilename;
|
||||
}
|
||||
|
||||
delete wndSelectFile;
|
||||
delete cmdOK;
|
||||
delete cmdCancel;
|
||||
delete fileButtonActionListener;
|
||||
|
||||
delete txtCurrent;
|
||||
delete lstFiles;
|
||||
delete scrAreaFiles;
|
||||
delete selectFileActionListener;
|
||||
delete fileList;
|
||||
if (createNew)
|
||||
{
|
||||
delete lblFilename;
|
||||
delete txtFilename;
|
||||
}
|
||||
|
||||
delete wndSelectFile;
|
||||
}
|
||||
|
||||
|
||||
static void SelectFileLoop(void)
|
||||
{
|
||||
while(!dialogFinished)
|
||||
{
|
||||
SDL_Event event;
|
||||
while(SDL_PollEvent(&event))
|
||||
{
|
||||
if (event.type == SDL_KEYDOWN)
|
||||
{
|
||||
switch(event.key.keysym.sym)
|
||||
{
|
||||
case SDLK_ESCAPE:
|
||||
dialogFinished = true;
|
||||
break;
|
||||
|
||||
case SDLK_LEFT:
|
||||
{
|
||||
gcn::FocusHandler* focusHdl = gui_top->_getFocusHandler();
|
||||
gcn::Widget* activeWidget = focusHdl->getFocused();
|
||||
if(activeWidget == lstFiles)
|
||||
cmdCancel->requestFocus();
|
||||
else if(activeWidget == cmdCancel)
|
||||
cmdOK->requestFocus();
|
||||
else if(activeWidget == cmdOK)
|
||||
if(createNew)
|
||||
txtFilename->requestFocus();
|
||||
else
|
||||
lstFiles->requestFocus();
|
||||
else if(activeWidget == txtFilename)
|
||||
lstFiles->requestFocus();
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
||||
case SDLK_RIGHT:
|
||||
{
|
||||
gcn::FocusHandler* focusHdl = gui_top->_getFocusHandler();
|
||||
gcn::Widget* activeWidget = focusHdl->getFocused();
|
||||
if(activeWidget == lstFiles)
|
||||
if(createNew)
|
||||
txtFilename->requestFocus();
|
||||
else
|
||||
cmdOK->requestFocus();
|
||||
else if(activeWidget == txtFilename)
|
||||
cmdOK->requestFocus();
|
||||
else if(activeWidget == cmdCancel)
|
||||
lstFiles->requestFocus();
|
||||
else if(activeWidget == cmdOK)
|
||||
cmdCancel->requestFocus();
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
while (!dialogFinished)
|
||||
{
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event))
|
||||
{
|
||||
if (event.type == SDL_KEYDOWN)
|
||||
{
|
||||
switch (event.key.keysym.sym)
|
||||
{
|
||||
case SDLK_ESCAPE:
|
||||
dialogFinished = true;
|
||||
break;
|
||||
|
||||
case SDLK_PAGEDOWN:
|
||||
case SDLK_HOME:
|
||||
event.key.keysym.sym = SDLK_RETURN;
|
||||
gui_input->pushInput(event); // Fire key down
|
||||
event.type = SDL_KEYUP; // and the key up
|
||||
break;
|
||||
}
|
||||
}
|
||||
case SDLK_LEFT:
|
||||
{
|
||||
gcn::FocusHandler* focusHdl = gui_top->_getFocusHandler();
|
||||
gcn::Widget* activeWidget = focusHdl->getFocused();
|
||||
if (activeWidget == lstFiles)
|
||||
cmdCancel->requestFocus();
|
||||
else if (activeWidget == cmdCancel)
|
||||
cmdOK->requestFocus();
|
||||
else if (activeWidget == cmdOK)
|
||||
if (createNew)
|
||||
txtFilename->requestFocus();
|
||||
else
|
||||
lstFiles->requestFocus();
|
||||
else if (activeWidget == txtFilename)
|
||||
lstFiles->requestFocus();
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
||||
//-------------------------------------------------
|
||||
// Send event to guichan-controls
|
||||
//-------------------------------------------------
|
||||
gui_input->pushInput(event);
|
||||
}
|
||||
case SDLK_RIGHT:
|
||||
{
|
||||
gcn::FocusHandler* focusHdl = gui_top->_getFocusHandler();
|
||||
gcn::Widget* activeWidget = focusHdl->getFocused();
|
||||
if (activeWidget == lstFiles)
|
||||
if (createNew)
|
||||
txtFilename->requestFocus();
|
||||
else
|
||||
cmdOK->requestFocus();
|
||||
else if (activeWidget == txtFilename)
|
||||
cmdOK->requestFocus();
|
||||
else if (activeWidget == cmdCancel)
|
||||
lstFiles->requestFocus();
|
||||
else if (activeWidget == cmdOK)
|
||||
cmdCancel->requestFocus();
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
||||
// Now we let the Gui object perform its logic.
|
||||
uae_gui->logic();
|
||||
// Now we let the Gui object draw itself.
|
||||
uae_gui->draw();
|
||||
// Finally we update the screen.
|
||||
wait_for_vsync();
|
||||
SDL_Flip(gui_screen);
|
||||
|
||||
if(!dialogCreated)
|
||||
{
|
||||
dialogCreated = true;
|
||||
if(selectedOnStart >= 0)
|
||||
scrAreaFiles->setVerticalScrollAmount(selectedOnStart * 19);
|
||||
}
|
||||
}
|
||||
case SDLK_PAGEDOWN:
|
||||
case SDLK_HOME:
|
||||
event.key.keysym.sym = SDLK_RETURN;
|
||||
gui_input->pushInput(event); // Fire key down
|
||||
event.type = SDL_KEYUP; // and the key up
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Send event to guichan-controls
|
||||
//-------------------------------------------------
|
||||
gui_input->pushInput(event);
|
||||
}
|
||||
|
||||
// Now we let the Gui object perform its logic.
|
||||
uae_gui->logic();
|
||||
// Now we let the Gui object draw itself.
|
||||
uae_gui->draw();
|
||||
// Finally we update the screen.
|
||||
wait_for_vsync();
|
||||
SDL_Flip(gui_screen);
|
||||
|
||||
if (!dialogCreated)
|
||||
{
|
||||
dialogCreated = true;
|
||||
if (selectedOnStart >= 0)
|
||||
scrAreaFiles->setVerticalScrollAmount(selectedOnStart * 19);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FILE_SELECT_KEEP_POSITION
|
||||
|
@ -368,46 +368,47 @@ static int Already_init = 0;
|
|||
|
||||
bool SelectFile(const char *title, char *value, const char *filter[], bool create)
|
||||
{
|
||||
dialogResult = false;
|
||||
dialogFinished = false;
|
||||
createNew = create;
|
||||
filefilter = filter;
|
||||
dialogCreated = false;
|
||||
selectedOnStart = -1;
|
||||
dialogResult = false;
|
||||
dialogFinished = false;
|
||||
createNew = create;
|
||||
filefilter = filter;
|
||||
dialogCreated = false;
|
||||
selectedOnStart = -1;
|
||||
|
||||
#ifdef FILE_SELECT_KEEP_POSITION
|
||||
if (Already_init == 0)
|
||||
{
|
||||
InitSelectFile(title);
|
||||
Already_init = 1;
|
||||
} else
|
||||
{
|
||||
strncpy(value,workingDir,MAX_PATH);
|
||||
gui_top->add(wndSelectFile);
|
||||
wndSelectFile->setCaption(title);
|
||||
wndSelectFile->requestModalFocus();
|
||||
wndSelectFile->setVisible(true);
|
||||
gui_top->moveToTop(wndSelectFile);
|
||||
}
|
||||
#else
|
||||
InitSelectFile(title);
|
||||
#endif
|
||||
|
||||
extractPath(value, workingDir);
|
||||
checkfoldername(workingDir);
|
||||
checkfilename(value);
|
||||
SelectFileLoop();
|
||||
#ifdef FILE_SELECT_KEEP_POSITION
|
||||
wndSelectFile->releaseModalFocus();
|
||||
wndSelectFile->setVisible(false);
|
||||
if (Already_init == 0)
|
||||
{
|
||||
InitSelectFile(title);
|
||||
Already_init = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(value, workingDir, MAX_PATH);
|
||||
gui_top->add(wndSelectFile);
|
||||
wndSelectFile->setCaption(title);
|
||||
wndSelectFile->requestModalFocus();
|
||||
wndSelectFile->setVisible(true);
|
||||
gui_top->moveToTop(wndSelectFile);
|
||||
}
|
||||
#else
|
||||
ExitSelectFile();
|
||||
InitSelectFile(title);
|
||||
#endif
|
||||
if(dialogResult)
|
||||
strncpy(value, workingDir, MAX_PATH);
|
||||
extractPath(value, workingDir);
|
||||
checkfoldername(workingDir);
|
||||
checkfilename(value);
|
||||
|
||||
SelectFileLoop();
|
||||
#ifdef FILE_SELECT_KEEP_POSITION
|
||||
else
|
||||
strncpy(workingDir,value, MAX_PATH);
|
||||
wndSelectFile->releaseModalFocus();
|
||||
wndSelectFile->setVisible(false);
|
||||
#else
|
||||
ExitSelectFile();
|
||||
#endif
|
||||
return dialogResult;
|
||||
if (dialogResult)
|
||||
strncpy(value, workingDir, MAX_PATH);
|
||||
#ifdef FILE_SELECT_KEEP_POSITION
|
||||
else
|
||||
strncpy(workingDir, value, MAX_PATH);
|
||||
#endif
|
||||
return dialogResult;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#define DIALOG_WIDTH 520
|
||||
#define DIALOG_HEIGHT 400
|
||||
|
||||
std::string volName;
|
||||
static bool dialogResult = false;
|
||||
static bool dialogFinished = false;
|
||||
static char workingDir[MAX_PATH];
|
||||
|
@ -31,84 +32,85 @@ static gcn::TextField *txtCurrent;
|
|||
|
||||
class ButtonActionListener : public gcn::ActionListener
|
||||
{
|
||||
public:
|
||||
void action(const gcn::ActionEvent& actionEvent)
|
||||
{
|
||||
if (actionEvent.getSource() == cmdOK)
|
||||
{
|
||||
dialogResult = true;
|
||||
}
|
||||
dialogFinished = true;
|
||||
}
|
||||
public:
|
||||
void action(const gcn::ActionEvent& actionEvent)
|
||||
{
|
||||
if (actionEvent.getSource() == cmdOK)
|
||||
{
|
||||
dialogResult = true;
|
||||
}
|
||||
dialogFinished = true;
|
||||
}
|
||||
};
|
||||
static ButtonActionListener* buttonActionListener;
|
||||
|
||||
|
||||
class DirListModel : public gcn::ListModel
|
||||
{
|
||||
std::vector<std::string> dirs;
|
||||
std::vector<std::string> dirs;
|
||||
|
||||
public:
|
||||
DirListModel(const char * path)
|
||||
{
|
||||
changeDir(path);
|
||||
}
|
||||
|
||||
int getNumberOfElements()
|
||||
{
|
||||
return dirs.size();
|
||||
}
|
||||
|
||||
std::string getElementAt(int i)
|
||||
{
|
||||
if(i >= dirs.size() || i < 0)
|
||||
return "---";
|
||||
return dirs[i];
|
||||
}
|
||||
|
||||
void changeDir(const char *path)
|
||||
{
|
||||
ReadDirectory(path, &dirs, NULL);
|
||||
if(dirs.size() == 0)
|
||||
dirs.push_back("..");
|
||||
}
|
||||
public:
|
||||
DirListModel(const char * path)
|
||||
{
|
||||
changeDir(path);
|
||||
}
|
||||
|
||||
int getNumberOfElements()
|
||||
{
|
||||
return dirs.size();
|
||||
}
|
||||
|
||||
std::string getElementAt(int i)
|
||||
{
|
||||
if (i >= dirs.size() || i < 0)
|
||||
return "---";
|
||||
return dirs[i];
|
||||
}
|
||||
|
||||
void changeDir(const char *path)
|
||||
{
|
||||
ReadDirectory(path, &dirs, NULL);
|
||||
if (dirs.size() == 0)
|
||||
dirs.push_back("..");
|
||||
}
|
||||
};
|
||||
static DirListModel dirList(".");
|
||||
|
||||
|
||||
static void checkfoldername (char *current)
|
||||
static void checkfoldername(char *current)
|
||||
{
|
||||
char *ptr;
|
||||
char actualpath [PATH_MAX];
|
||||
char actualpath[PATH_MAX];
|
||||
DIR *dir;
|
||||
|
||||
|
||||
if (dir = opendir(current))
|
||||
{
|
||||
dirList = current;
|
||||
ptr = realpath(current, actualpath);
|
||||
strcpy(workingDir, ptr);
|
||||
closedir(dir);
|
||||
{
|
||||
dirList = current;
|
||||
ptr = realpath(current, actualpath);
|
||||
strcpy(workingDir, ptr);
|
||||
closedir(dir);
|
||||
}
|
||||
else
|
||||
strcpy(workingDir, start_path_data);
|
||||
txtCurrent->setText(workingDir);
|
||||
else
|
||||
strcpy(workingDir, start_path_data);
|
||||
txtCurrent->setText(workingDir);
|
||||
}
|
||||
|
||||
|
||||
class ListBoxActionListener : public gcn::ActionListener
|
||||
{
|
||||
public:
|
||||
void action(const gcn::ActionEvent& actionEvent)
|
||||
{
|
||||
int selected_item;
|
||||
char foldername[256] = "";
|
||||
public:
|
||||
void action(const gcn::ActionEvent& actionEvent)
|
||||
{
|
||||
int selected_item;
|
||||
char foldername[256] = "";
|
||||
|
||||
selected_item = lstFolders->getSelected();
|
||||
strcpy(foldername, workingDir);
|
||||
strcat(foldername, "/");
|
||||
strcat(foldername, dirList.getElementAt(selected_item).c_str());
|
||||
checkfoldername(foldername);
|
||||
}
|
||||
selected_item = lstFolders->getSelected();
|
||||
strcpy(foldername, workingDir);
|
||||
strcat(foldername, "/");
|
||||
strcat(foldername, dirList.getElementAt(selected_item).c_str());
|
||||
volName = dirList.getElementAt(selected_item).c_str();
|
||||
checkfoldername(foldername);
|
||||
}
|
||||
};
|
||||
static ListBoxActionListener* listBoxActionListener;
|
||||
|
||||
|
@ -117,158 +119,158 @@ static void InitSelectFolder(const char *title)
|
|||
{
|
||||
wndSelectFolder = new gcn::Window("Load");
|
||||
wndSelectFolder->setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
|
||||
wndSelectFolder->setPosition((GUI_WIDTH - DIALOG_WIDTH) / 2, (GUI_HEIGHT - DIALOG_HEIGHT) / 2);
|
||||
wndSelectFolder->setBaseColor(gui_baseCol + 0x202020);
|
||||
wndSelectFolder->setCaption(title);
|
||||
wndSelectFolder->setTitleBarHeight(TITLEBAR_HEIGHT);
|
||||
|
||||
buttonActionListener = new ButtonActionListener();
|
||||
|
||||
wndSelectFolder->setPosition((GUI_WIDTH - DIALOG_WIDTH) / 2, (GUI_HEIGHT - DIALOG_HEIGHT) / 2);
|
||||
wndSelectFolder->setBaseColor(gui_baseCol + 0x202020);
|
||||
wndSelectFolder->setCaption(title);
|
||||
wndSelectFolder->setTitleBarHeight(TITLEBAR_HEIGHT);
|
||||
|
||||
buttonActionListener = new ButtonActionListener();
|
||||
|
||||
cmdOK = new gcn::Button("Ok");
|
||||
cmdOK->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
|
||||
cmdOK->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - 2 * BUTTON_WIDTH - DISTANCE_NEXT_X, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
|
||||
cmdOK->setBaseColor(gui_baseCol + 0x202020);
|
||||
cmdOK->addActionListener(buttonActionListener);
|
||||
|
||||
cmdOK->setBaseColor(gui_baseCol + 0x202020);
|
||||
cmdOK->addActionListener(buttonActionListener);
|
||||
|
||||
cmdCancel = new gcn::Button("Cancel");
|
||||
cmdCancel->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
|
||||
cmdCancel->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - BUTTON_WIDTH, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
|
||||
cmdCancel->setBaseColor(gui_baseCol + 0x202020);
|
||||
cmdCancel->addActionListener(buttonActionListener);
|
||||
cmdCancel->setBaseColor(gui_baseCol + 0x202020);
|
||||
cmdCancel->addActionListener(buttonActionListener);
|
||||
|
||||
txtCurrent = new gcn::TextField();
|
||||
txtCurrent->setSize(DIALOG_WIDTH - 2 * DISTANCE_BORDER - 4, TEXTFIELD_HEIGHT);
|
||||
txtCurrent->setPosition(DISTANCE_BORDER, 10);
|
||||
txtCurrent->setEnabled(false);
|
||||
txtCurrent = new gcn::TextField();
|
||||
txtCurrent->setSize(DIALOG_WIDTH - 2 * DISTANCE_BORDER - 4, TEXTFIELD_HEIGHT);
|
||||
txtCurrent->setPosition(DISTANCE_BORDER, 10);
|
||||
txtCurrent->setEnabled(false);
|
||||
|
||||
listBoxActionListener = new ListBoxActionListener();
|
||||
|
||||
lstFolders = new gcn::ListBox(&dirList);
|
||||
lstFolders->setSize(800, 252);
|
||||
lstFolders->setBaseColor(gui_baseCol);
|
||||
lstFolders->setWrappingEnabled(true);
|
||||
lstFolders->addActionListener(listBoxActionListener);
|
||||
|
||||
scrAreaFolders = new gcn::ScrollArea(lstFolders);
|
||||
scrAreaFolders->setFrameSize(1);
|
||||
scrAreaFolders->setPosition(DISTANCE_BORDER, 10 + TEXTFIELD_HEIGHT + 10);
|
||||
scrAreaFolders->setSize(DIALOG_WIDTH - 2 * DISTANCE_BORDER - 4, 272);
|
||||
scrAreaFolders->setScrollbarWidth(20);
|
||||
scrAreaFolders->setBaseColor(gui_baseCol + 0x202020);
|
||||
|
||||
wndSelectFolder->add(cmdOK);
|
||||
wndSelectFolder->add(cmdCancel);
|
||||
wndSelectFolder->add(txtCurrent);
|
||||
wndSelectFolder->add(scrAreaFolders);
|
||||
|
||||
gui_top->add(wndSelectFolder);
|
||||
|
||||
lstFolders->requestFocus();
|
||||
lstFolders->setSelected(0);
|
||||
wndSelectFolder->requestModalFocus();
|
||||
listBoxActionListener = new ListBoxActionListener();
|
||||
|
||||
lstFolders = new gcn::ListBox(&dirList);
|
||||
lstFolders->setSize(800, 252);
|
||||
lstFolders->setBaseColor(gui_baseCol);
|
||||
lstFolders->setWrappingEnabled(true);
|
||||
lstFolders->addActionListener(listBoxActionListener);
|
||||
|
||||
scrAreaFolders = new gcn::ScrollArea(lstFolders);
|
||||
scrAreaFolders->setFrameSize(1);
|
||||
scrAreaFolders->setPosition(DISTANCE_BORDER, 10 + TEXTFIELD_HEIGHT + 10);
|
||||
scrAreaFolders->setSize(DIALOG_WIDTH - 2 * DISTANCE_BORDER - 4, 272);
|
||||
scrAreaFolders->setScrollbarWidth(20);
|
||||
scrAreaFolders->setBaseColor(gui_baseCol + 0x202020);
|
||||
|
||||
wndSelectFolder->add(cmdOK);
|
||||
wndSelectFolder->add(cmdCancel);
|
||||
wndSelectFolder->add(txtCurrent);
|
||||
wndSelectFolder->add(scrAreaFolders);
|
||||
|
||||
gui_top->add(wndSelectFolder);
|
||||
|
||||
lstFolders->requestFocus();
|
||||
lstFolders->setSelected(0);
|
||||
wndSelectFolder->requestModalFocus();
|
||||
}
|
||||
|
||||
|
||||
static void ExitSelectFolder(void)
|
||||
{
|
||||
wndSelectFolder->releaseModalFocus();
|
||||
gui_top->remove(wndSelectFolder);
|
||||
wndSelectFolder->releaseModalFocus();
|
||||
gui_top->remove(wndSelectFolder);
|
||||
|
||||
delete cmdOK;
|
||||
delete cmdCancel;
|
||||
delete buttonActionListener;
|
||||
|
||||
delete txtCurrent;
|
||||
delete lstFolders;
|
||||
delete scrAreaFolders;
|
||||
delete listBoxActionListener;
|
||||
|
||||
delete wndSelectFolder;
|
||||
delete cmdOK;
|
||||
delete cmdCancel;
|
||||
delete buttonActionListener;
|
||||
|
||||
delete txtCurrent;
|
||||
delete lstFolders;
|
||||
delete scrAreaFolders;
|
||||
delete listBoxActionListener;
|
||||
|
||||
delete wndSelectFolder;
|
||||
}
|
||||
|
||||
|
||||
static void SelectFolderLoop(void)
|
||||
{
|
||||
while(!dialogFinished)
|
||||
{
|
||||
SDL_Event event;
|
||||
while(SDL_PollEvent(&event))
|
||||
{
|
||||
if (event.type == SDL_KEYDOWN)
|
||||
{
|
||||
switch(event.key.keysym.sym)
|
||||
{
|
||||
case SDLK_ESCAPE:
|
||||
dialogFinished = true;
|
||||
break;
|
||||
|
||||
case SDLK_LEFT:
|
||||
{
|
||||
gcn::FocusHandler* focusHdl = gui_top->_getFocusHandler();
|
||||
gcn::Widget* activeWidget = focusHdl->getFocused();
|
||||
if(activeWidget == lstFolders)
|
||||
cmdCancel->requestFocus();
|
||||
else if(activeWidget == cmdCancel)
|
||||
cmdOK->requestFocus();
|
||||
else if(activeWidget == cmdOK)
|
||||
lstFolders->requestFocus();
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
||||
case SDLK_RIGHT:
|
||||
{
|
||||
gcn::FocusHandler* focusHdl = gui_top->_getFocusHandler();
|
||||
gcn::Widget* activeWidget = focusHdl->getFocused();
|
||||
if(activeWidget == lstFolders)
|
||||
cmdOK->requestFocus();
|
||||
else if(activeWidget == cmdCancel)
|
||||
lstFolders->requestFocus();
|
||||
else if(activeWidget == cmdOK)
|
||||
cmdCancel->requestFocus();
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
while (!dialogFinished)
|
||||
{
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event))
|
||||
{
|
||||
if (event.type == SDL_KEYDOWN)
|
||||
{
|
||||
switch (event.key.keysym.sym)
|
||||
{
|
||||
case SDLK_ESCAPE:
|
||||
dialogFinished = true;
|
||||
break;
|
||||
|
||||
case SDLK_PAGEDOWN:
|
||||
case SDLK_HOME:
|
||||
event.key.keysym.sym = SDLK_RETURN;
|
||||
gui_input->pushInput(event); // Fire key down
|
||||
event.type = SDL_KEYUP; // and the key up
|
||||
break;
|
||||
}
|
||||
}
|
||||
case SDLK_LEFT:
|
||||
{
|
||||
gcn::FocusHandler* focusHdl = gui_top->_getFocusHandler();
|
||||
gcn::Widget* activeWidget = focusHdl->getFocused();
|
||||
if (activeWidget == lstFolders)
|
||||
cmdCancel->requestFocus();
|
||||
else if (activeWidget == cmdCancel)
|
||||
cmdOK->requestFocus();
|
||||
else if (activeWidget == cmdOK)
|
||||
lstFolders->requestFocus();
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
||||
//-------------------------------------------------
|
||||
// Send event to guichan-controls
|
||||
//-------------------------------------------------
|
||||
gui_input->pushInput(event);
|
||||
}
|
||||
case SDLK_RIGHT:
|
||||
{
|
||||
gcn::FocusHandler* focusHdl = gui_top->_getFocusHandler();
|
||||
gcn::Widget* activeWidget = focusHdl->getFocused();
|
||||
if (activeWidget == lstFolders)
|
||||
cmdOK->requestFocus();
|
||||
else if (activeWidget == cmdCancel)
|
||||
lstFolders->requestFocus();
|
||||
else if (activeWidget == cmdOK)
|
||||
cmdCancel->requestFocus();
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
||||
// Now we let the Gui object perform its logic.
|
||||
uae_gui->logic();
|
||||
// Now we let the Gui object draw itself.
|
||||
uae_gui->draw();
|
||||
// Finally we update the screen.
|
||||
wait_for_vsync();
|
||||
SDL_Flip(gui_screen);
|
||||
}
|
||||
case SDLK_PAGEDOWN:
|
||||
case SDLK_HOME:
|
||||
event.key.keysym.sym = SDLK_RETURN;
|
||||
gui_input->pushInput(event); // Fire key down
|
||||
event.type = SDL_KEYUP; // and the key up
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// Send event to guichan-controls
|
||||
//-------------------------------------------------
|
||||
gui_input->pushInput(event);
|
||||
}
|
||||
|
||||
// Now we let the Gui object perform its logic.
|
||||
uae_gui->logic();
|
||||
// Now we let the Gui object draw itself.
|
||||
uae_gui->draw();
|
||||
// Finally we update the screen.
|
||||
wait_for_vsync();
|
||||
SDL_Flip(gui_screen);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool SelectFolder(const char *title, char *value)
|
||||
{
|
||||
dialogResult = false;
|
||||
dialogFinished = false;
|
||||
InitSelectFolder(title);
|
||||
checkfoldername(value);
|
||||
SelectFolderLoop();
|
||||
ExitSelectFolder();
|
||||
if(dialogResult)
|
||||
{
|
||||
strncpy(value, workingDir, MAX_PATH);
|
||||
if(value[strlen(value) - 1] != '/')
|
||||
strcat(value, "/");
|
||||
}
|
||||
return dialogResult;
|
||||
dialogResult = false;
|
||||
dialogFinished = false;
|
||||
InitSelectFolder(title);
|
||||
checkfoldername(value);
|
||||
SelectFolderLoop();
|
||||
ExitSelectFolder();
|
||||
if (dialogResult)
|
||||
{
|
||||
strncpy(value, workingDir, MAX_PATH);
|
||||
if (value[strlen(value) - 1] != '/')
|
||||
strcat(value, "/");
|
||||
}
|
||||
return dialogResult;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -15,14 +15,20 @@
|
|||
|
||||
#include <png.h>
|
||||
#include <SDL.h>
|
||||
#include <SDL_image.h>
|
||||
#include <SDL_gfxPrimitives.h>
|
||||
#include <SDL/SDL_image.h>
|
||||
#ifndef ANDROID
|
||||
#include <SDL/SDL_gfxPrimitives.h>
|
||||
#endif
|
||||
#include <SDL/SDL_ttf.h>
|
||||
|
||||
#ifdef ANDROIDSDL
|
||||
#ifdef ANDROID
|
||||
#include <android/log.h>
|
||||
#endif
|
||||
|
||||
#ifdef ANDROIDSDL
|
||||
#include <SDL_screenkeyboard.h>
|
||||
#endif
|
||||
|
||||
#include <linux/fb.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
|
@ -33,16 +39,16 @@
|
|||
#define OMAPFB_WAITFORVSYNC_FRAME _IOWR('O', 70, unsigned int)
|
||||
#endif
|
||||
|
||||
|
||||
/* SDL variable for output of emulation */
|
||||
SDL_Surface *prSDLScreen = NULL;
|
||||
static int fbdev = -1;
|
||||
static unsigned int current_vsync_frame = 0;
|
||||
|
||||
/* Possible screen modes (x and y resolutions) */
|
||||
#define MAX_SCREEN_MODES 6
|
||||
static int x_size_table[MAX_SCREEN_MODES] = { 640, 640, 800, 1024, 1152, 1280 };
|
||||
static int y_size_table[MAX_SCREEN_MODES] = { 400, 480, 480, 768, 864, 960 };
|
||||
|
||||
#define MAX_SCREEN_MODES 11
|
||||
static int x_size_table[MAX_SCREEN_MODES] = { 640, 640, 720, 800, 800, 960, 1024, 1024, 1280, 1280, 1920 };
|
||||
static int y_size_table[MAX_SCREEN_MODES] = { 400, 480, 400, 480, 600, 540, 768, 600, 720, 800, 1080 };
|
||||
|
||||
static int red_bits, green_bits, blue_bits;
|
||||
static int red_shift, green_shift, blue_shift;
|
||||
|
@ -362,9 +368,10 @@ void flush_screen ()
|
|||
}
|
||||
current_vsync_frame += currprefs.gfx_framerate;
|
||||
}
|
||||
|
||||
last_synctime = read_processor_time();
|
||||
|
||||
// Android swapped SDL_Flip & last_synctime for fixing performance
|
||||
SDL_Flip(prSDLScreen);
|
||||
last_synctime = read_processor_time();
|
||||
|
||||
if(!screen_is_picasso)
|
||||
gfxvidinfo.bufmem = (uae_u8 *)prSDLScreen->pixels;
|
||||
|
@ -734,7 +741,7 @@ void picasso_InitResolutions (void)
|
|||
modesList();
|
||||
DisplayModes = Displays[0].DisplayModes;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool vsync_switchmode (int hz)
|
||||
{
|
||||
|
@ -799,7 +806,7 @@ bool target_graphics_buffer_update (void)
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifdef PICASSO96
|
||||
|
||||
void gfx_set_picasso_state (int on)
|
||||
{
|
||||
if (on == screen_is_picasso)
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue