From f1358e16438eeee2d052cd873e490b7c7eb0c49c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 10 May 2013 22:01:35 +0200 Subject: [PATCH] (RMenu XUI 360) Add initial Load Game History --- frontend/menu/rmenu_xui.cpp | 94 +++++++++++++++++++ media/360/generate_xuis.bat | 9 ++ media/360/hd/rarch_load_game_history.bat | 14 +++ media/360/sd/rarch_load_game_history.bat | 14 +++ msvc/RetroArch-360/RetroArch-360.vcxproj | 30 ++++++ .../RetroArch-360.vcxproj.filters | 6 ++ 6 files changed, 167 insertions(+) create mode 100644 media/360/hd/rarch_load_game_history.bat create mode 100644 media/360/sd/rarch_load_game_history.bat diff --git a/frontend/menu/rmenu_xui.cpp b/frontend/menu/rmenu_xui.cpp index 884d95aad7..2c6c9d11e4 100644 --- a/frontend/menu/rmenu_xui.cpp +++ b/frontend/menu/rmenu_xui.cpp @@ -153,6 +153,7 @@ CREATE_CLASS(CRetroArchAudioOptions, L"RetroArchAudioOptions"); CREATE_CLASS(CRetroArchCoreOptions, L"RetroArchCoreOptions"); CREATE_CLASS(CRetroArchSettings, L"RetroArchSettings"); CREATE_CLASS(CRetroArchControls, L"RetroArchControls"); +CREATE_CLASS(CRetroArchLoadGameHistory, L"RetroArchLoadGameHistory"); CRetroArch app; @@ -173,6 +174,7 @@ HRESULT CRetroArch::RegisterXuiClasses (void) CRetroArchCoreOptions::Register(); CRetroArchControls::Register(); CRetroArchSettings::Register(); + CRetroArchLoadGameHistory::Register(); return 0; } @@ -189,6 +191,7 @@ HRESULT CRetroArch::UnregisterXuiClasses (void) XuiUnregisterClass(L"RetroArchCoreOptions"); XuiUnregisterClass(L"RetroArchControls"); XuiUnregisterClass(L"RetroArchSettings"); + XuiUnregisterClass(L"RetroArchLoadGameHistory"); return 0; } @@ -331,6 +334,41 @@ static void init_menulist(unsigned menu_id) XuiListSetText(m_menulist, 0, L"No options available."); } break; + case INGAME_MENU_LOAD_GAME_HISTORY_MODE: + { + size_t history_size = rom_history_size(rgui->history); + + if (history_size) + { + size_t opts = history_size; + for (size_t i = 0; i < opts; i++) + { + const char *path = NULL; + const char *core_path = NULL; + const char *core_name = NULL; + + rom_history_get_index(rgui->history, i, + &path, &core_path, &core_name); + + char path_short[PATH_MAX]; + fill_pathname(path_short, path_basename(path), "", sizeof(path_short)); + + char fill_buf[PATH_MAX]; + snprintf(fill_buf, sizeof(fill_buf), "%s (%s)", + path_short, core_name); + + mbstowcs(strw_buffer, fill_buf, sizeof(strw_buffer) / sizeof(wchar_t)); + XuiListInsertItems(m_menulist, i, 1); + XuiListSetText(m_menulist, i, strw_buffer); + } + } + else + { + XuiListInsertItems(m_menulist, 0, 1); + XuiListSetText(m_menulist, 0, L"No history available."); + } + } + break; case INGAME_MENU_INPUT_OPTIONS_MODE: { unsigned i; @@ -431,6 +469,27 @@ static void init_menulist(unsigned menu_id) } } +HRESULT CRetroArchLoadGameHistory::OnControlNavigate( + XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled) +{ + bHandled = TRUE; + + switch(pControlNavigateData->nControlNavigate) + { + case XUI_CONTROL_NAVIGATE_LEFT: + case XUI_CONTROL_NAVIGATE_RIGHT: + case XUI_CONTROL_NAVIGATE_UP: + case XUI_CONTROL_NAVIGATE_DOWN: + pControlNavigateData->hObjDest = pControlNavigateData->hObjSource; + break; + default: + break; + } + + return 0; +} + + HRESULT CRetroArchControls::OnInit(XUIMessageInit * pInitData, BOOL& bHandled) { GetChildById(L"XuiMenuList", &m_menulist); @@ -632,6 +691,19 @@ HRESULT CRetroArchControls::OnControlNavigate( return 0; } +HRESULT CRetroArchLoadGameHistory::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled ) +{ + if ( hObjPressed == m_menulist) + { + XUIMessageControlNavigate controls; + controls.nControlNavigate = (XUI_CONTROL_NAVIGATE)XUI_CONTROL_NAVIGATE_OK; + OnControlNavigate(&controls, bHandled); + } + + bHandled = TRUE; + return 0; +} + HRESULT CRetroArchControls::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled ) { if ( hObjPressed == m_menulist) @@ -645,6 +717,19 @@ HRESULT CRetroArchControls::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled return 0; } +HRESULT CRetroArchLoadGameHistory::OnInit(XUIMessageInit * pInitData, BOOL& bHandled) +{ + GetChildById(L"XuiMenuList", &m_menulist); + GetChildById(L"XuiBackButton", &m_back); + GetChildById(L"XuiTxtTitle", &m_menutitle); + + XuiTextElementSetText(m_menutitle, L"Load History"); + + init_menulist(INGAME_MENU_LOAD_GAME_HISTORY_MODE); + + return 0; +} + HRESULT CRetroArchSettings::OnInit(XUIMessageInit * pInitData, BOOL& bHandled) { GetChildById(L"XuiMenuList", &m_menulist); @@ -1163,6 +1248,15 @@ HRESULT CRetroArchMain::OnControlNavigate(XUIMessageControlNavigate *pControlNav } break; case INGAME_MENU_LOAD_GAME_HISTORY_MODE: + if (input == XUI_CONTROL_NAVIGATE_OK) + { + hr = XuiSceneCreate(hdmenus_allowed ? L"file://game:/media/hd/" : L"file://game:/media/sd/", L"rarch_load_game_history.xur", NULL, ¤t_menu); + + if (hr < 0) + RARCH_ERR("Failed to load scene.\n"); + + XuiSceneNavigateForward(current_obj, false, current_menu, XUSER_INDEX_FOCUS); + } break; case INGAME_MENU_CHANGE_GAME: if (input == XUI_CONTROL_NAVIGATE_OK) diff --git a/media/360/generate_xuis.bat b/media/360/generate_xuis.bat index 4cdf1d11ca..cf52129025 100644 --- a/media/360/generate_xuis.bat +++ b/media/360/generate_xuis.bat @@ -17,6 +17,8 @@ call :subroutine_f call :subroutine_g @echo "Creating sd/rarch_core_options.xui ..." call :subroutine_h +@echo "Creating sd/rarch_load_game_history.xui ..." +call :subroutine_i cd ../ cd hd @@ -37,6 +39,8 @@ call :subroutine_f call :subroutine_g @echo "Creating hd/rarch_core_options.xui ..." call :subroutine_h +@echo "Creating hd/rarch_load_game_history.xui ..." +call :subroutine_i goto :eof :subroutine_a @@ -78,3 +82,8 @@ goto :eof del rarch_core_options.xui 2>NUL call rarch_core_options.bat goto :eof + +:subroutine_i +del rarch_load_game_history.xui 2>NUL +call rarch_load_game_history.bat +goto :eof diff --git a/media/360/hd/rarch_load_game_history.bat b/media/360/hd/rarch_load_game_history.bat new file mode 100644 index 0000000000..f90f53efbb --- /dev/null +++ b/media/360/hd/rarch_load_game_history.bat @@ -0,0 +1,14 @@ +@echo off + +for /f "tokens=* delims=" %%f in ('type rarch_main.xui') do CALL :DOREPLACE "%%f" + +GOTO :EOF +:DOREPLACE +SET INPUT=%* +SET OUTPUT=%INPUT:RetroArchMain=RetroArchLoadGameHistory% + +for /f "tokens=* delims=" %%g in ('ECHO %OUTPUT%') do ECHO %%~g>>rarch_load_game_history.xui + +EXIT /b + +:EOF diff --git a/media/360/sd/rarch_load_game_history.bat b/media/360/sd/rarch_load_game_history.bat new file mode 100644 index 0000000000..f90f53efbb --- /dev/null +++ b/media/360/sd/rarch_load_game_history.bat @@ -0,0 +1,14 @@ +@echo off + +for /f "tokens=* delims=" %%f in ('type rarch_main.xui') do CALL :DOREPLACE "%%f" + +GOTO :EOF +:DOREPLACE +SET INPUT=%* +SET OUTPUT=%INPUT:RetroArchMain=RetroArchLoadGameHistory% + +for /f "tokens=* delims=" %%g in ('ECHO %OUTPUT%') do ECHO %%~g>>rarch_load_game_history.xui + +EXIT /b + +:EOF diff --git a/msvc/RetroArch-360/RetroArch-360.vcxproj b/msvc/RetroArch-360/RetroArch-360.vcxproj index 5ebe05d8ae..88d0aebe7c 100644 --- a/msvc/RetroArch-360/RetroArch-360.vcxproj +++ b/msvc/RetroArch-360/RetroArch-360.vcxproj @@ -555,6 +555,21 @@ $(OutDir)media\sd\rarch_core_options.xur; $(OutDir)media\sd\rarch_core_options.xur; + + Document + $(OutDir)media\sd\rarch_load_game_history.xur; + $(OutDir)media\sd\rarch_load_game_history.xur; + $(OutDir)media\sd\rarch_load_game_history.xur; + $(OutDir)media\sd\rarch_load_game_history.xur; + $(OutDir)media\sd\rarch_load_game_history.xur; + $(OutDir)media\sd\rarch_load_game_history.xur; + xui2bin /D /NOLOGO "%(RelativeDir)rarch_load_game_history.xui" "$(OutDir)media\sd\rarch_load_game_history.xur" + xui2bin /D /NOLOGO "%(RelativeDir)rarch_load_game_history.xui" "$(OutDir)media\sd\rarch_load_game_history.xur" + xui2bin /D /NOLOGO "%(RelativeDir)rarch_load_game_history.xui" "$(OutDir)media\sd\rarch_load_game_history.xur" + xui2bin /D /NOLOGO "%(RelativeDir)rarch_load_game_history.xui" "$(OutDir)media\sd\rarch_load_game_history.xur" + xui2bin /D /NOLOGO "%(RelativeDir)rarch_load_game_history.xui" "$(OutDir)media\sd\rarch_load_game_history.xur" + xui2bin /D /NOLOGO "%(RelativeDir)rarch_load_game_history.xui" "$(OutDir)media\sd\rarch_load_game_history.xur" + @@ -664,6 +679,21 @@ xui2bin /D /NOLOGO "%(RelativeDir)rarch_core_options.xui" "$(OutDir)media\hd\rarch_core_options.xur" xui2bin /D /NOLOGO "%(RelativeDir)rarch_core_options.xui" "$(OutDir)media\hd\rarch_core_options.xur" + + Document + $(OutDir)media\hd\rarch_load_game_history.xur; + $(OutDir)media\hd\rarch_load_game_history.xur; + $(OutDir)media\hd\rarch_load_game_history.xur; + $(OutDir)media\hd\rarch_load_game_history.xur; + $(OutDir)media\hd\rarch_load_game_history.xur; + $(OutDir)media\hd\rarch_load_game_history.xur; + xui2bin /D /NOLOGO "%(RelativeDir)rarch_load_game_history.xui" "$(OutDir)media\hd\rarch_load_game_history.xur" + xui2bin /D /NOLOGO "%(RelativeDir)rarch_load_game_history.xui" "$(OutDir)media\hd\rarch_load_game_history.xur" + xui2bin /D /NOLOGO "%(RelativeDir)rarch_load_game_history.xui" "$(OutDir)media\hd\rarch_load_game_history.xur" + xui2bin /D /NOLOGO "%(RelativeDir)rarch_load_game_history.xui" "$(OutDir)media\hd\rarch_load_game_history.xur" + xui2bin /D /NOLOGO "%(RelativeDir)rarch_load_game_history.xui" "$(OutDir)media\hd\rarch_load_game_history.xur" + xui2bin /D /NOLOGO "%(RelativeDir)rarch_load_game_history.xui" "$(OutDir)media\hd\rarch_load_game_history.xur" + Document $(OutDir)media\hd\rarch_settings.xur; diff --git a/msvc/RetroArch-360/RetroArch-360.vcxproj.filters b/msvc/RetroArch-360/RetroArch-360.vcxproj.filters index 75719beca3..72e55d896c 100644 --- a/msvc/RetroArch-360/RetroArch-360.vcxproj.filters +++ b/msvc/RetroArch-360/RetroArch-360.vcxproj.filters @@ -171,6 +171,12 @@ Source Files\media\sd + + Source Files\media\hd + + + Source Files\media\sd + Source Files\media