Compare commits

...

3 Commits

Author SHA1 Message Date
Christopher A. Mosher 2074de70ce fix bad reference 2024-04-13 17:53:15 -04:00
Christopher A. Mosher 58f9575823 minor fixes 2024-04-13 17:45:58 -04:00
Christopher A. Mosher 2749f8ef74 slight refactor 2024-04-13 15:57:03 -04:00
5 changed files with 28 additions and 32 deletions

View File

@ -4,6 +4,7 @@ set -e
if [ -e "$1/CMakeCache.txt" ] ; then
builddir="$1"
shift
else
mkdir -p tmp
builddir=$(mktemp -d tmp/tmp.XXXXXXXXXX)

View File

@ -95,8 +95,6 @@ public:
const std::filesystem::path GetConfigDir() const;
const std::filesystem::path GetDocumentsDir() const;
E2wxFrame *GetFrame() { return this->frame; }
void StartEmulator();
void StopEmulator();

View File

@ -4,15 +4,14 @@
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <gtk-2.0/gtk/gtkwindow.h>
#include <gtk-2.0/gtk/gtkwidget.h>
void *get_gtk_native_window_handle(void *widget) {
GtkWidget *gtk_widget = GTK_WIDGET(widget);
gtk_widget_realize(gtk_widget);
GdkWindow *gdk_window = gtk_widget_get_window(gtk_widget);
Window xid = gdk_x11_window_get_xid(gdk_window);
return reinterpret_cast<void*>(xid);
}

View File

@ -70,17 +70,18 @@ class ScreenException {
ScreenImage::ScreenImage(Emulator &emulator, KeyEventHandler &k) :
wxFrame(nullptr, wxID_ANY, "Emulator"),
emu(emulator),
window(nullptr),
fullscreen(false),
buffer(true),
display(AnalogTV::TV_OLD_COLOR),
keyEventHandler(k),
slotnames(8),
cassInName(32, ' '),
cassOutName(32, ' '),
keyEventHandler(k) {
cassOutName(32, ' ')
{
createScreen();
Center();
Show();
Bind(wxEVT_IDLE, &ScreenImage::OnIdle, this);
Bind(wxEVT_CLOSE_WINDOW, &ScreenImage::HandleUserCloseWindowRequest, this);
}
@ -91,12 +92,6 @@ ScreenImage::~ScreenImage() {
void ScreenImage::OnIdle(wxIdleEvent &evt) {
// if (!this->FindFocus() || !this->sdl->HasFocus()) {
// this->sdl->SetFocus();
// }
}
void ScreenImage::HandleUserCloseWindowRequest(wxCloseEvent& event) {
wxGetApp().StopEmulator();
}
@ -114,13 +109,13 @@ void ScreenImage::toggleFullScreen() {
}
void ScreenImage::createScreen() {
this->sdl = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(SCRW,SCRH*ASPECT_RATIO));
this->wxPanelEmuScreen = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(SCRW,SCRH*ASPECT_RATIO));
createSdlTexture();
this->sdl->Bind(wxEVT_KEY_DOWN, &ScreenImage::OnKeyDown, this);
this->sdl->Bind(wxEVT_KEY_UP, &ScreenImage::OnKeyUp, this);
this->wxPanelEmuScreen->Bind(wxEVT_KEY_DOWN, &ScreenImage::OnKeyDown, this);
this->wxPanelEmuScreen->Bind(wxEVT_KEY_UP, &ScreenImage::OnKeyUp, this);
wxSizer *pszr = new wxBoxSizer(wxVERTICAL);
pszr->Add(this->sdl);
pszr->Add(this->wxPanelEmuScreen);
SetSizer(pszr);
pszr->SetSizeHints(this);
@ -140,7 +135,7 @@ static void *get_native_window_handle(wxWindowBase *panel) {
}
void ScreenImage::createSdlTexture() {
void *nativeSdl = get_native_window_handle(this->sdl);
void *nativeSdl = get_native_window_handle(this->wxPanelEmuScreen);
this->window = SDL_CreateWindowFrom(nativeSdl);
if (this->window == NULL) {
@ -166,6 +161,9 @@ void ScreenImage::createSdlTexture() {
}
void ScreenImage::destroyScreen() {
if (!this->window) {
return;
}
SDL_DestroyTexture(this->texture);
SDL_DestroyRenderer(this->renderer);
SDL_DestroyWindow(this->window);
@ -335,6 +333,9 @@ void ScreenImage::drawPower(bool on) {
}
void ScreenImage::notifyObservers() {
if (!this->window) {
return;
}
const int e = SDL_UpdateTexture(this->texture, NULL, this->pixels, SCRW*sizeof(unsigned int));
if (e) {
std::cerr << SDL_GetError() << std::endl;
@ -371,6 +372,10 @@ void ScreenImage::removeCard(const int slot, Card* card /* empty */) {
updateSlotName(slot, card);
}
static std::string truncateFilePath(const std::filesystem::path& filepath) {
return filepath.stem().string().substr(0, 12);
}
/*
1 2 3 4 5 6 7 8
789012345678901234567890123456789012345678901234567890123456789012345
@ -392,10 +397,6 @@ void ScreenImage::setDiskFile(int slot, int drive, const std::filesystem::path &
this->slotnames[slot].replace(c - 20, f.length(), f);
}
std::string ScreenImage::truncateFilePath(const std::filesystem::path& filepath) {
return filepath.stem().string().substr(0, 12);
}
void ScreenImage::clearCurrentDrive(int slot, int drive) {
int r(R_SLOT + slot);
int c(35 + 32 * drive);
@ -565,5 +566,5 @@ void ScreenImage::OnKeyUp(wxKeyEvent &evt) {
}
void ScreenImage::getPos(int* px, int* py) {
this->sdl->GetScreenPosition(px,py);
this->wxPanelEmuScreen->GetScreenPosition(px,py);
}

View File

@ -39,7 +39,7 @@ struct SDL_Window;
class ScreenImage : public wxFrame {
private:
Emulator &emu;
wxPanel *sdl;
wxPanel *wxPanelEmuScreen;
SDL_Window* window;
SDL_Renderer* renderer;
SDL_Texture* texture;
@ -48,18 +48,15 @@ private:
bool fullscreen;
bool buffer;
AnalogTV::DisplayType display;
void createScreen();
void createSdlTexture();
void destroyScreen();
KeyEventHandler &keyEventHandler;
std::vector<std::string> slotnames;
std::string cassInName;
std::string cassOutName;
KeyEventHandler &keyEventHandler;
void createScreen();
void createSdlTexture();
void destroyScreen();
static std::string truncateFilePath(const std::filesystem::path& filepath);
void OnIdle(wxIdleEvent &evt);
void OnKeyDown(wxKeyEvent &evt);
void OnKeyUp(wxKeyEvent &evt);
void HandleUserCloseWindowRequest(wxCloseEvent& event);