diskwindow is *almost* usable!

This commit is contained in:
Shamus Hammons 2009-02-03 05:30:08 +00:00
parent a6c39ed766
commit 6ad6896385
6 changed files with 51 additions and 4 deletions

View File

@ -146,6 +146,8 @@ bool FloppyDrive::SaveImage(uint8 driveNum/*= 0*/)
fwrite(disk[driveNum], 1, diskSize[driveNum], fp);
fclose(fp);
WriteLog("FLOPPY: Successfully wrote image file '%s'...\n", imageName[driveNum]);
return true;
}
@ -499,6 +501,31 @@ const char * FloppyDrive::GetImageName(uint8 driveNum/*= 0*/)
return nameBuf;
}
void FloppyDrive::EjectImage(uint8 driveNum/*= 0*/)
{
// Probably want to save a dirty image... ;-)
SaveImage(driveNum);
WriteLog("FLOPPY: Ejected image file '%s' from drive %u...\n", imageName[driveNum], driveNum);
if (disk[driveNum])
delete[] disk[driveNum];
disk[driveNum] = NULL;
diskSize[driveNum] = 0;
diskType[driveNum] = DT_UNKNOWN;
imageDirty[driveNum] = false;
imageName[driveNum][0] = 0; // Zero out filenames
memset(nybblizedImage[driveNum], 0xFF, 232960); // Doesn't matter if 00s or FFs...
}
bool FloppyDrive::DriveIsEmpty(uint8 driveNum/*= 0*/)
{
// This is kinda gay, but it works
return (imageName[driveNum][0] == 0 ? true : false);
}
// Memory mapped I/O functions

View File

@ -28,6 +28,8 @@ class FloppyDrive
void CreateBlankImage(uint8 driveNum = 0);
void SwapImages(void);
const char * GetImageName(uint8 driveNum = 0);
void EjectImage(uint8 driveNum = 0);
bool DriveIsEmpty(uint8 driveNum = 0);
// I/O functions ($C0Ex accesses)

View File

@ -29,3 +29,8 @@ void Text::Draw(void)
DrawStringOpaque(screen, r.x, r.y, fgColor, bgColor, "%s", text.c_str());
}
}
void Text::SetText(std::string s)
{
text = s;
}

View File

@ -20,6 +20,7 @@ class Text: public Element
virtual void HandleMouseButton(uint32 x, uint32 y, bool mouseDown) {}
virtual void Draw(void);
virtual void Notify(Element *) {}
void SetText(std::string s);
protected:
// uint32 fgColor, bgColor;

View File

@ -52,7 +52,7 @@ Window::Window(uint32 x/*= 0*/, uint32 y/*= 0*/, uint32 w/*= 0*/, uint32 h/*= 0*
cbDown(SDL_CreateRGBSurfaceFrom(&closeBoxDown[4], cbWidth, cbHeight, 32, cbWidth * 4,
MASK_R, MASK_G, MASK_B, MASK_A)),
cbHover(SDL_CreateRGBSurfaceFrom(&closeBoxHover[4], cbWidth, cbHeight, 32, cbWidth * 4,
MASK_R, MASK_G, MASK_B, MASK_A))
MASK_R, MASK_G, MASK_B, MASK_A)), drawBackground(true)
{
//Could probably move this into the initializer list as well...
// closeButton = new Button(w - (cbWidth + 1), 1, cbUp, cbHover, cbDown, this);
@ -130,9 +130,14 @@ void Window::Draw(void)
for(uint32 i=0; i<list.size(); i++)
list[i]->Draw();
#else
// These are *always* top level and parentless, so no need to traverse up through
// the parent chain...
SDL_FillRect(screen, &extents, bgColor);
if (drawBackground)
{
// These are *always* top level and parentless, so no need to traverse up through
// the parent chain...
SDL_FillRect(screen, &extents, bgColor);
}
else
RestoreScreenFromBackstore();
// Handle the items this window contains...
for(uint32 i=0; i<list.size(); i++)
@ -171,3 +176,8 @@ void Window::AddCloseButton(void)
list.push_back(closeButton);
}
}
void Window::SetBackgroundDraw(bool state)
{
drawBackground = state;
}

View File

@ -25,6 +25,7 @@ class Window: public Element
virtual void Notify(Element *);
void AddElement(Element * e);
void AddCloseButton(void);
void SetBackgroundDraw(bool);
protected:
void (* handler)(Element *);
@ -34,6 +35,7 @@ class Window: public Element
private:
uint16 cbWidth, cbHeight;
SDL_Surface * cbUp, * cbDown, * cbHover;
bool drawBackground;
};
#endif // __WINDOW_H__