Separate dropped file processing.
Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
parent
1ac7710b07
commit
283a74d7e7
4 changed files with 66 additions and 38 deletions
|
@ -14,6 +14,7 @@ set(SOURCE_FILES
|
|||
sdirectsound.cpp
|
||||
utils.cpp
|
||||
sdlframe.cpp
|
||||
processfile.cpp
|
||||
renderer/sdlrendererframe.cpp
|
||||
)
|
||||
|
||||
|
@ -22,6 +23,7 @@ set(HEADER_FILES
|
|||
sdirectsound.h
|
||||
utils.h
|
||||
sdlframe.h
|
||||
processfile.h
|
||||
renderer/sdlrendererframe.h
|
||||
)
|
||||
|
||||
|
|
56
source/frontends/sdl/processfile.cpp
Normal file
56
source/frontends/sdl/processfile.cpp
Normal file
|
@ -0,0 +1,56 @@
|
|||
#include "StdAfx.h"
|
||||
#include "frontends/sdl/processfile.h"
|
||||
#include "frontends/sdl/sdlframe.h"
|
||||
#include "frontends/common2/utils.h"
|
||||
|
||||
#include "CardManager.h"
|
||||
#include "Disk.h"
|
||||
#include "Core.h"
|
||||
#include "Harddisk.h"
|
||||
|
||||
|
||||
namespace sa2
|
||||
{
|
||||
|
||||
void processFile(SDLFrame * frame, const char * filename, const size_t dragAndDropSlot)
|
||||
{
|
||||
const char * yaml = ".yaml";
|
||||
if (strlen(filename) > strlen(yaml) && !strcmp(filename + strlen(filename) - strlen(yaml), yaml))
|
||||
{
|
||||
common2::setSnapshotFilename(filename, true);
|
||||
frame->ResetSpeed();
|
||||
}
|
||||
else
|
||||
{
|
||||
CardManager & cardManager = GetCardMgr();
|
||||
SS_CARDTYPE cardInSlot = cardManager.QuerySlot(dragAndDropSlot);
|
||||
switch (cardInSlot)
|
||||
{
|
||||
case CT_Disk2:
|
||||
{
|
||||
// for now we insert in DRIVE_1
|
||||
Disk2InterfaceCard * card2 = dynamic_cast<Disk2InterfaceCard*>(cardManager.GetObj(dragAndDropSlot));
|
||||
const ImageError_e error = card2->InsertDisk(dragAndDropSlot, filename, IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE);
|
||||
if (error != eIMAGE_ERROR_NONE)
|
||||
{
|
||||
card2->NotifyInvalidImage(dragAndDropSlot, filename, error);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CT_GenericHDD:
|
||||
{
|
||||
if (!HD_Insert(dragAndDropSlot, filename))
|
||||
{
|
||||
frame->FrameMessageBox("Invalid HD image", "ERROR", MB_OK);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
frame->FrameMessageBox("Invalid D&D target", "ERROR", MB_OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
6
source/frontends/sdl/processfile.h
Normal file
6
source/frontends/sdl/processfile.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
namespace sa2
|
||||
{
|
||||
class SDLFrame;
|
||||
|
||||
void processFile(SDLFrame * frame, const char * filename, const size_t dragAndDropSlot);
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
#include "StdAfx.h"
|
||||
#include "frontends/sdl/processfile.h"
|
||||
#include "frontends/sdl/sdlframe.h"
|
||||
#include "frontends/sdl/utils.h"
|
||||
#include "frontends/sdl/sdirectsound.h"
|
||||
|
@ -316,44 +317,7 @@ namespace sa2
|
|||
|
||||
void SDLFrame::ProcessDropEvent(const SDL_DropEvent & drop)
|
||||
{
|
||||
const char * filename = drop.file;
|
||||
const char * yaml = ".yaml";
|
||||
if (strlen(filename) > strlen(yaml) && !strcmp(filename + strlen(filename) - strlen(yaml), yaml))
|
||||
{
|
||||
common2::setSnapshotFilename(filename, true);
|
||||
mySpeed.reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
CardManager & cardManager = GetCardMgr();
|
||||
SS_CARDTYPE cardInSlot = cardManager.QuerySlot(myDragAndDropSlot);
|
||||
switch (cardInSlot)
|
||||
{
|
||||
case CT_Disk2:
|
||||
{
|
||||
// for now we insert in DRIVE_1
|
||||
Disk2InterfaceCard * card2 = dynamic_cast<Disk2InterfaceCard*>(cardManager.GetObj(myDragAndDropSlot));
|
||||
const ImageError_e error = card2->InsertDisk(myDragAndDropDrive, drop.file, IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE);
|
||||
if (error != eIMAGE_ERROR_NONE)
|
||||
{
|
||||
card2->NotifyInvalidImage(myDragAndDropDrive, drop.file, error);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CT_GenericHDD:
|
||||
{
|
||||
if (!HD_Insert(myDragAndDropDrive, drop.file))
|
||||
{
|
||||
FrameMessageBox("Invalid HD image", "ERROR", MB_OK);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
FrameMessageBox("Invalid D&D target", "ERROR", MB_OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
processFile(this, drop.file, myDragAndDropSlot);
|
||||
}
|
||||
|
||||
void SDLFrame::ProcessKeyDown(const SDL_KeyboardEvent & key)
|
||||
|
|
Loading…
Add table
Reference in a new issue