From 32e64e3e517ae886e807ea9552b835bd340b5780 Mon Sep 17 00:00:00 2001 From: zeromus Date: Tue, 15 Dec 2009 03:47:22 +0000 Subject: [PATCH] add wx dialog to gtk port as demonstration, but you can't see it because i can't figure out how to add a gtk menu item. anyway, my work here is done: concept proved. --- desmume/configure.ac | 2 + desmume/src/Makefile.am | 3 + desmume/src/driver.cpp | 7 +- desmume/src/gtk/main.cpp | 38 ++ desmume/src/version.h | 2 +- desmume/src/windows/DeSmuME_2005.vcproj | 654 ++++++++++++------------ desmume/src/windows/main.cpp | 92 ++-- desmume/src/wxdlg/desmume.pjd | 2 +- desmume/src/wxdlg/wxdlg3dViewer.cpp | 4 +- desmume/src/wxdlg/wxdlg3dViewer.h | 6 +- 10 files changed, 426 insertions(+), 384 deletions(-) diff --git a/desmume/configure.ac b/desmume/configure.ac index 351abcecc..678dad60e 100644 --- a/desmume/configure.ac +++ b/desmume/configure.ac @@ -208,6 +208,8 @@ if test "x$wxwidget" = "xyes" ; then fi fi +AM_CONDITIONAL([HAVE_WX], [test "x$wxwidget" = "xyes"]) + dnl - Determine which UIs to build and if po/ should be included PO_DIR="" if test "x$HAVE_SDL" = "xyes"; then diff --git a/desmume/src/Makefile.am b/desmume/src/Makefile.am index a4e0fb97d..004cc2d64 100644 --- a/desmume/src/Makefile.am +++ b/desmume/src/Makefile.am @@ -54,6 +54,9 @@ libdesmume_a_SOURCES = \ metaspu/metaspu.cpp metaspu/metaspu.h \ version.cpp version.h +if HAVE_WX +libdesmume_a_SOURCES += wxdlg/wxdlg3dViewer.cpp +endif if HAVE_ALSA libdesmume_a_SOURCES += mic_alsa.cpp else diff --git a/desmume/src/driver.cpp b/desmume/src/driver.cpp index aa97b2bdf..0554e75ad 100644 --- a/desmume/src/driver.cpp +++ b/desmume/src/driver.cpp @@ -25,11 +25,12 @@ #include "gfx3d.h" #ifdef _MSC_VER -#define USE_WX +#define HAVE_WX #endif -#ifdef USE_WX +#ifdef HAVE_WX #include "wx/wxprec.h" +#include "wx/wx.h" #include "wxdlg/wxdlg3dViewer.h" const int kVewportWidth = 512; @@ -159,7 +160,7 @@ void BaseDriver::VIEW3D_Shutdown() void BaseDriver::VIEW3D_Init() { VIEW3D_Shutdown(); -#ifdef USE_WX +#ifdef HAVE_WX view3d = new VIEW3D_Driver_WX(); #endif } diff --git a/desmume/src/gtk/main.cpp b/desmume/src/gtk/main.cpp index d954b424c..6bc2ea95d 100644 --- a/desmume/src/gtk/main.cpp +++ b/desmume/src/gtk/main.cpp @@ -57,6 +57,25 @@ #include "gdbstub.h" #endif + +#ifdef HAVE_WX +#include "wx/wx.h" +class wxDesmumeApp : public wxApp +{ +public: + //call me each frame or something. + //sort of an idle routine + static void frameUpdate() + { + if(!wxTheApp) return; + wxDesmumeApp* self = ((wxDesmumeApp*)wxTheApp); + self->DeletePendingObjects(); + } +}; + +IMPLEMENT_APP_NO_MAIN( wxDesmumeApp ) +#endif + #ifdef HAVE_LIBOSMESA #include #include @@ -108,6 +127,7 @@ static void LoadStateDialog(); void Launch(); void Pause(); static void Printscreen(); +static void View3d(); static void Reset(); static void Edit_Controls(); static void MenuSave(GtkMenuItem *item, gpointer slot); @@ -276,6 +296,10 @@ static const GtkActionEntry action_entries[] = { { "run", "gtk-media-play", "_Run", "r", NULL, Launch }, { "pause", "gtk-media-pause", "_Pause", "p", NULL, Pause }, { "reset", "gtk-refresh", "Re_set", NULL, NULL, Reset }, +#ifdef HAVE_WX + //for some reason the menu item doesnt show up.... + { "view3d", NULL, "View 3d", NULL, NULL, View3d }, +#endif { "FrameskipMenu", NULL, "_Frameskip" }, { "LayersMenu", NULL, "_Layers" }, { "CheatMenu", NULL, "_Cheat" }, @@ -953,6 +977,12 @@ static void OpenRecent(GtkRecentChooser *chooser, gpointer user_data) } #endif +static void View3d() +{ + driver->VIEW3D_Init(); + driver->view3d->Launch(); +} + static void Reset() { NDS_Reset(); @@ -1619,6 +1649,10 @@ gboolean EmuLoop(gpointer data) } } + #ifdef HAVE_WX + wxDesmumeApp::frameUpdate(); + #endif + return TRUE; } @@ -2079,6 +2113,10 @@ int main (int argc, char *argv[]) exit(0); } +#ifdef HAVE_WX + wxInitialize(); +#endif + return common_gtk_main( &my_config); } diff --git a/desmume/src/version.h b/desmume/src/version.h index 9adebfd96..eb005fa0c 100644 --- a/desmume/src/version.h +++ b/desmume/src/version.h @@ -23,4 +23,4 @@ u32 EMU_DESMUME_VERSION_NUMERIC(); const char* EMU_DESMUME_VERSION_STRING(); const char* EMU_DESMUME_NAME_AND_VERSION(); -const char* EMU_DESMUME_COMPILER_DETAIL(); \ No newline at end of file +const char* EMU_DESMUME_COMPILER_DETAIL(); diff --git a/desmume/src/windows/DeSmuME_2005.vcproj b/desmume/src/windows/DeSmuME_2005.vcproj index 4475793b3..fe89fa18a 100644 --- a/desmume/src/windows/DeSmuME_2005.vcproj +++ b/desmume/src/windows/DeSmuME_2005.vcproj @@ -1,4 +1,4 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -972,6 +982,16 @@ Outputs=".libs\7z.tag" /> + + + @@ -982,32 +1002,12 @@ Outputs=".libs\7z.tag" /> - - - - - - @@ -1026,6 +1026,16 @@ Outputs=".libs\directx.tag" /> + + + @@ -1036,6 +1046,16 @@ Outputs=".libs\directx.tag" /> + + + @@ -1046,32 +1066,12 @@ Outputs=".libs\directx.tag" /> - - - - - - @@ -1090,6 +1090,16 @@ Outputs=".libs\glib-vc8.tag" /> + + + @@ -1100,6 +1110,16 @@ Outputs=".libs\glib-vc8.tag" /> + + + @@ -1110,32 +1130,12 @@ Outputs=".libs\glib-vc8.tag" /> - - - - - - @@ -1154,6 +1154,16 @@ Outputs=".libs\lua.tag" /> + + + @@ -1164,6 +1174,16 @@ Outputs=".libs\lua.tag" /> + + + @@ -1174,32 +1194,12 @@ Outputs=".libs\lua.tag" /> - - - - - - @@ -1218,6 +1218,16 @@ Outputs=".libs\wx.tag" /> + + + @@ -1228,6 +1238,16 @@ Outputs=".libs\wx.tag" /> + + + @@ -1238,32 +1258,12 @@ Outputs=".libs\wx.tag" /> - - - - - - @@ -1341,24 +1341,6 @@ XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" /> - - - - - - @@ -1368,6 +1350,15 @@ XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" /> + + + @@ -1377,6 +1368,15 @@ XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" /> + + + @@ -1564,6 +1564,10 @@ RelativePath="..\wxdlg\wxdlg3dViewer.h" > + + DeletePendingObjects(); - } -}; +//class wxDesmumeApp : public wxApp +//{ +//public: +// //call me each frame or something. +// //sort of an idle routine +// static void frameUpdate() +// { +// if(!wxTheApp) return; +// wxDesmumeApp* self = ((wxDesmumeApp*)wxTheApp); +// self->DeletePendingObjects(); +// } +//}; -IMPLEMENT_APP_NO_MAIN( wxDesmumeApp ) +//IMPLEMENT_APP_NO_MAIN( wxDesmumeApp ) void wxTest() { //wxdlg3dViewer *viewer = new wxdlg3dViewer(NULL); @@ -155,8 +151,6 @@ void wxTest() { //frame->Show(true); } -#endif - #ifndef PUBLIC_RELEASE #define DEVELOPER_MENU_ITEMS #endif @@ -2643,36 +2637,36 @@ int _main() return 0; } -int WINAPI WinMain (HINSTANCE hThisInstance, - HINSTANCE hPrevInstance, - LPSTR lpszArgument, - int nFunsterStil) - -{ - TIMECAPS tc; - if (timeGetDevCaps(&tc, sizeof(TIMECAPS))== TIMERR_NOERROR) - { - wmTimerRes = std::min(std::max(tc.wPeriodMin, (UINT)1), tc.wPeriodMax); - timeBeginPeriod (wmTimerRes); - } - else - { - wmTimerRes = 5; - timeBeginPeriod (wmTimerRes); - } - - g_thread_init (NULL); - hAppInst=hThisInstance; - OpenConsole(); // Init debug console - - int ret = _main(); - - timeEndPeriod (wmTimerRes); - - CloseConsole(); - - return ret; -} +//int WINAPI WinMain (HINSTANCE hThisInstance, +// HINSTANCE hPrevInstance, +// LPSTR lpszArgument, +// int nFunsterStil) +// +//{ +// TIMECAPS tc; +// if (timeGetDevCaps(&tc, sizeof(TIMECAPS))== TIMERR_NOERROR) +// { +// wmTimerRes = std::min(std::max(tc.wPeriodMin, (UINT)1), tc.wPeriodMax); +// timeBeginPeriod (wmTimerRes); +// } +// else +// { +// wmTimerRes = 5; +// timeBeginPeriod (wmTimerRes); +// } +// +// g_thread_init (NULL); +// hAppInst=hThisInstance; +// OpenConsole(); // Init debug console +// +// int ret = _main(); +// +// timeEndPeriod (wmTimerRes); +// +// CloseConsole(); +// +// return ret; +//} void UpdateWndRects(HWND hwnd) { diff --git a/desmume/src/wxdlg/desmume.pjd b/desmume/src/wxdlg/desmume.pjd index 5488f8e0a..951611081 100644 --- a/desmume/src/wxdlg/desmume.pjd +++ b/desmume/src/wxdlg/desmume.pjd @@ -333,7 +333,7 @@ "wbStaticBoxSizerProxy" "wxID_ANY" -1 - "Display options" + "Display optionsss" "" "" "" diff --git a/desmume/src/wxdlg/wxdlg3dViewer.cpp b/desmume/src/wxdlg/wxdlg3dViewer.cpp index 045ddea87..c7a091498 100644 --- a/desmume/src/wxdlg/wxdlg3dViewer.cpp +++ b/desmume/src/wxdlg/wxdlg3dViewer.cpp @@ -123,7 +123,7 @@ void wxdlg3dViewer::Init() void wxdlg3dViewer::CreateControls() { ////@begin wxdlg3dViewer content construction - // Generated by DialogBlocks, 14/12/2009 00:57:31 (unregistered) + // Generated by DialogBlocks, 14/12/2009 20:51:53 (unregistered) wxdlg3dViewer* itemDialog1 = this; @@ -135,7 +135,7 @@ void wxdlg3dViewer::CreateControls() itemFlexGridSizer2->AddGrowableCol(4); itemDialog1->SetSizer(itemFlexGridSizer2); - wxStaticBox* itemStaticBoxSizer3Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Display options")); + wxStaticBox* itemStaticBoxSizer3Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Display optionsss")); wxStaticBoxSizer* itemStaticBoxSizer3 = new wxStaticBoxSizer(itemStaticBoxSizer3Static, wxVERTICAL); itemFlexGridSizer2->Add(itemStaticBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); diff --git a/desmume/src/wxdlg/wxdlg3dViewer.h b/desmume/src/wxdlg/wxdlg3dViewer.h index 5cfe6de06..a8c541ce8 100644 --- a/desmume/src/wxdlg/wxdlg3dViewer.h +++ b/desmume/src/wxdlg/wxdlg3dViewer.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: x.h +// Name: wxdlg3dviewer.h // Purpose: // Author: // Modified by: @@ -11,8 +11,8 @@ // Generated by DialogBlocks (unregistered), 12/12/2009 15:45:31 -#ifndef _X_H_ -#define _X_H_ +#ifndef _WXDLG3DVIEWER_H_ +#define _WXDLG3DVIEWER_H_ /*!