2013-06-10 20:06:51 +00:00
// Copyright (c) 2013- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
2013-11-26 13:45:36 +00:00
# include <cmath>
2013-11-27 10:15:46 +00:00
# include <algorithm>
2013-11-26 13:45:36 +00:00
2013-06-10 20:06:51 +00:00
# include "base/colorutil.h"
# include "base/timeutil.h"
2013-11-18 13:05:26 +00:00
# include "file/path.h"
2013-08-18 18:25:33 +00:00
# include "gfx_es2/draw_buffer.h"
2013-06-10 20:06:51 +00:00
# include "math/curves.h"
2013-12-06 10:44:46 +00:00
# include "base/stringutil.h"
2013-06-10 20:06:51 +00:00
# include "ui/ui_context.h"
# include "ui/view.h"
# include "ui/viewgroup.h"
2013-07-21 11:31:46 +00:00
# include "Common/FileUtil.h"
# include "Core/System.h"
2013-09-01 20:29:23 +00:00
# include "Core/Host.h"
2013-07-21 11:31:46 +00:00
# include "Core/SaveState.h"
2013-06-10 20:06:51 +00:00
# include "UI/EmuScreen.h"
# include "UI/MainScreen.h"
# include "UI/GameScreen.h"
# include "UI/GameInfoCache.h"
2013-07-17 20:27:05 +00:00
# include "UI/GameSettingsScreen.h"
2013-08-24 03:28:21 +00:00
# include "UI/CwCheatScreen.h"
2013-08-14 21:05:02 +00:00
# include "UI/MiscScreens.h"
2013-09-07 15:29:44 +00:00
# include "UI/ControlMappingScreen.h"
2013-11-20 13:42:48 +00:00
# include "UI/Store.h"
2013-06-10 20:06:51 +00:00
# include "UI/ui_atlas.h"
# include "Core/Config.h"
2013-07-21 23:33:18 +00:00
# include "GPU/GPUInterface.h"
2013-08-11 15:25:50 +00:00
# include "i18n/i18n.h"
2013-06-27 14:28:11 +00:00
2013-11-24 03:02:36 +00:00
# include "Core/HLE/sceUmd.h"
2013-10-15 11:28:09 +00:00
# ifdef _WIN32
# include "Windows/W32Util/ShellUtil.h"
# include "Windows/WndMainWindow.h"
# endif
2013-08-17 23:24:34 +00:00
# ifdef USING_QT_UI
# include <QFileDialog>
# include <QFile>
# include <QDir>
# endif
2013-10-08 13:38:50 +00:00
# include <sstream>
2013-12-06 11:29:27 +00:00
bool MainScreen : : showHomebrewTab = false ;
2013-06-10 20:06:51 +00:00
class GameButton : public UI : : Clickable {
public :
2013-08-16 10:52:16 +00:00
GameButton ( const std : : string & gamePath , bool gridStyle , UI : : LayoutParams * layoutParams = 0 )
2013-12-11 19:37:57 +00:00
: UI : : Clickable ( layoutParams ) , gridStyle_ ( gridStyle ) , gamePath_ ( gamePath ) , holdFrameCount_ ( 0 ) , holdEnabled_ ( true ) { }
2013-06-10 20:06:51 +00:00
virtual void Draw ( UIContext & dc ) ;
virtual void GetContentDimensions ( const UIContext & dc , float & w , float & h ) const {
2013-08-16 10:52:16 +00:00
if ( gridStyle_ ) {
w = 144 ;
h = 80 ;
} else {
w = 500 ;
h = 50 ;
}
2013-06-10 20:06:51 +00:00
}
2013-08-16 10:52:16 +00:00
2013-06-10 20:06:51 +00:00
const std : : string & GamePath ( ) const { return gamePath_ ; }
2013-12-06 10:44:46 +00:00
2013-12-11 19:37:57 +00:00
void SetHoldEnabled ( bool hold ) {
holdEnabled_ = hold ;
}
2013-07-22 20:36:56 +00:00
virtual void Touch ( const TouchInput & input ) {
UI : : Clickable : : Touch ( input ) ;
2014-01-25 19:24:06 +00:00
hovering_ = bounds_ . Contains ( input . x , input . y ) ;
2013-07-22 20:36:56 +00:00
if ( input . flags & TOUCH_UP ) {
holdFrameCount_ = 0 ;
}
}
2013-12-06 10:44:46 +00:00
2014-01-25 19:24:06 +00:00
virtual void Key ( const KeyInput & key ) {
std : : vector < int > pspKeys ;
bool showInfo = false ;
2014-01-31 05:54:38 +00:00
if ( KeyMap : : KeyToPspButton ( key . deviceId , key . keyCode , & pspKeys ) ) {
2014-01-25 19:24:06 +00:00
for ( auto it = pspKeys . begin ( ) , end = pspKeys . end ( ) ; it ! = end ; + + it ) {
// If the button mapped to triangle, then show the info.
2014-01-31 05:54:38 +00:00
if ( HasFocus ( ) & & ( key . flags & KEY_UP ) & & * it = = CTRL_TRIANGLE ) {
2014-01-25 19:24:06 +00:00
showInfo = true ;
}
}
} else if ( hovering_ & & key . deviceId = = DEVICE_ID_MOUSE & & key . keyCode = = NKCODE_EXT_MOUSEBUTTON_2 ) {
// If it's the right mouse button, and it's not otherwise mapped, show the info also.
2014-01-31 05:54:38 +00:00
if ( key . flags & KEY_UP ) {
2014-01-25 19:24:06 +00:00
showInfo = true ;
}
}
if ( showInfo ) {
TriggerOnHoldClick ( ) ;
return ;
}
Clickable : : Key ( key ) ;
}
2013-07-22 20:36:56 +00:00
virtual void Update ( const InputState & input_state ) {
2013-12-11 19:37:57 +00:00
if ( down_ & & holdEnabled_ )
2013-07-22 20:36:56 +00:00
holdFrameCount_ + + ;
2013-08-12 22:06:48 +00:00
else
holdFrameCount_ = 0 ;
2014-01-25 19:24:06 +00:00
// Hold button for 1.5 seconds to launch the game options
2013-07-22 20:36:56 +00:00
if ( holdFrameCount_ > 90 ) {
2014-01-25 19:24:06 +00:00
TriggerOnHoldClick ( ) ;
2013-07-22 20:36:56 +00:00
}
}
UI : : Event OnHoldClick ;
2013-06-10 20:06:51 +00:00
private :
2014-01-25 19:24:06 +00:00
void TriggerOnHoldClick ( ) {
holdFrameCount_ = 0 ;
UI : : EventParams e ;
e . v = this ;
e . s = gamePath_ ;
down_ = false ;
OnHoldClick . Trigger ( e ) ;
}
2013-08-16 10:52:16 +00:00
bool gridStyle_ ;
2013-06-10 20:06:51 +00:00
std : : string gamePath_ ;
2013-12-06 10:44:46 +00:00
std : : string title_ ;
2013-10-09 14:26:15 +00:00
2013-07-22 20:36:56 +00:00
int holdFrameCount_ ;
2013-12-11 19:37:57 +00:00
bool holdEnabled_ ;
2014-01-25 19:24:06 +00:00
bool hovering_ ;
2013-06-10 20:06:51 +00:00
} ;
void GameButton : : Draw ( UIContext & dc ) {
GameInfo * ginfo = g_gameInfoCache . GetInfo ( gamePath_ , false ) ;
Texture * texture = 0 ;
2013-07-15 15:41:24 +00:00
u32 color = 0 , shadowColor = 0 ;
2013-06-10 20:06:51 +00:00
if ( ginfo - > iconTexture ) {
texture = ginfo - > iconTexture ;
}
int x = bounds_ . x ;
int y = bounds_ . y ;
2013-08-16 10:52:16 +00:00
int w = 144 ;
2013-06-10 20:06:51 +00:00
int h = bounds_ . h ;
2013-08-16 10:52:16 +00:00
UI : : Style style = dc . theme - > itemStyle ;
2013-08-20 16:18:30 +00:00
if ( down_ )
style = dc . theme - > itemDownStyle ;
2013-08-16 10:52:16 +00:00
if ( ! gridStyle_ | | ! texture ) {
h = 50 ;
if ( HasFocus ( ) )
style = down_ ? dc . theme - > itemDownStyle : dc . theme - > itemFocusedStyle ;
2013-12-11 19:37:57 +00:00
Drawable bg = style . background ;
2013-08-18 20:30:34 +00:00
dc . Draw ( ) - > Flush ( ) ;
dc . RebindTexture ( ) ;
2013-12-11 19:37:57 +00:00
dc . FillRect ( bg , bounds_ ) ;
2013-08-18 20:30:34 +00:00
dc . Draw ( ) - > Flush ( ) ;
2013-08-16 10:52:16 +00:00
}
2013-06-10 20:06:51 +00:00
if ( texture ) {
color = whiteAlpha ( ease ( ( time_now_d ( ) - ginfo - > timeIconWasLoaded ) * 2 ) ) ;
2013-07-15 15:41:24 +00:00
shadowColor = blackAlpha ( ease ( ( time_now_d ( ) - ginfo - > timeIconWasLoaded ) * 2 ) ) ;
2013-06-10 20:06:51 +00:00
float tw = texture - > Width ( ) ;
float th = texture - > Height ( ) ;
// Adjust position so we don't stretch the image vertically or horizontally.
// TODO: Add a param to specify fit? The below assumes it's never too wide.
float nw = h * tw / th ;
x + = ( w - nw ) / 2.0f ;
w = nw ;
}
int txOffset = down_ ? 4 : 0 ;
2013-08-20 16:18:30 +00:00
if ( ! gridStyle_ ) txOffset = 0 ;
2013-06-10 20:06:51 +00:00
2013-12-11 19:37:57 +00:00
Bounds overlayBounds = bounds_ ;
u32 overlayColor = 0 ;
if ( holdEnabled_ )
overlayColor = whiteAlpha ( ( holdFrameCount_ - 15 ) * 0.01f ) ;
2013-06-10 20:06:51 +00:00
// Render button
int dropsize = 10 ;
if ( texture ) {
2013-08-12 22:06:48 +00:00
if ( txOffset ) {
dropsize = 3 ;
y + = txOffset * 2 ;
2013-12-11 19:37:57 +00:00
overlayBounds . y + = txOffset * 2 ;
2013-08-12 22:06:48 +00:00
}
2013-07-15 15:41:24 +00:00
if ( HasFocus ( ) ) {
2013-08-19 22:49:25 +00:00
dc . Draw ( ) - > Flush ( ) ;
dc . RebindTexture ( ) ;
2013-12-11 19:37:57 +00:00
dc . Draw ( ) - > DrawImage4Grid ( dc . theme - > dropShadow4Grid , x - dropsize * 1.5f , y - dropsize * 1.5f , x + w + dropsize * 1.5f , y + h + dropsize * 1.5f , alphaMul ( color , 1.0f ) , 1.0f ) ;
2013-08-19 22:49:25 +00:00
dc . Draw ( ) - > Flush ( ) ;
2013-07-15 15:41:24 +00:00
} else {
2013-08-10 21:04:23 +00:00
dc . Draw ( ) - > Flush ( ) ;
dc . RebindTexture ( ) ;
2013-08-19 22:49:25 +00:00
dc . Draw ( ) - > DrawImage4Grid ( dc . theme - > dropShadow4Grid , x - dropsize , y - dropsize * 0.5f , x + w + dropsize , y + h + dropsize * 1.5 , alphaMul ( shadowColor , 0.5f ) , 1.0f ) ;
2013-07-15 15:41:24 +00:00
dc . Draw ( ) - > Flush ( ) ;
2013-06-10 20:06:51 +00:00
}
}
if ( texture ) {
2013-07-15 16:57:42 +00:00
dc . Draw ( ) - > Flush ( ) ;
2013-06-10 20:06:51 +00:00
texture - > Bind ( 0 ) ;
2013-07-22 20:36:56 +00:00
if ( holdFrameCount_ > 60 ) {
// Blink before launching by holding
if ( ( ( holdFrameCount_ > > 3 ) & 1 ) = = 0 )
color = darkenColor ( color ) ;
}
2013-06-10 20:06:51 +00:00
dc . Draw ( ) - > DrawTexRect ( x , y , x + w , y + h , 0 , 0 , 1 , 1 , color ) ;
dc . Draw ( ) - > Flush ( ) ;
2013-08-16 10:52:16 +00:00
}
2013-11-25 17:14:11 +00:00
char discNumInfo [ 8 ] ;
if ( ginfo - > disc_total > 1 )
2013-11-28 06:22:39 +00:00
sprintf ( discNumInfo , " -DISC%d " , ginfo - > disc_number ) ;
2013-11-25 17:14:11 +00:00
else
2013-11-28 06:22:39 +00:00
strcpy ( discNumInfo , " " ) ;
2013-11-25 17:14:11 +00:00
2013-08-18 20:30:34 +00:00
dc . Draw ( ) - > Flush ( ) ;
dc . RebindTexture ( ) ;
2013-08-30 12:47:28 +00:00
dc . SetFontStyle ( dc . theme - > uiFont ) ;
2013-08-16 10:52:16 +00:00
if ( ! gridStyle_ ) {
2013-11-26 13:45:36 +00:00
float tw , th ;
2013-08-18 20:30:34 +00:00
dc . Draw ( ) - > Flush ( ) ;
dc . PushScissor ( bounds_ ) ;
2013-12-06 10:44:46 +00:00
if ( title_ . empty ( ) & & ! ginfo - > title . empty ( ) ) {
title_ = ReplaceAll ( ginfo - > title + discNumInfo , " & " , " && " ) ;
2013-12-11 09:32:39 +00:00
title_ = ReplaceAll ( title_ , " \n " , " " ) ;
2013-12-06 10:44:46 +00:00
}
2013-11-26 13:45:36 +00:00
2013-12-06 10:44:46 +00:00
dc . MeasureText ( dc . GetFontStyle ( ) , title_ . c_str ( ) , & tw , & th , 0 ) ;
2013-11-26 13:45:36 +00:00
int availableWidth = bounds_ . w - 150 ;
float sineWidth = std : : max ( 0.0f , ( tw - availableWidth ) ) / 2.0f ;
float tx = 150 ;
if ( availableWidth < tw ) {
tx - = ( 1.0f + sin ( time_now_d ( ) * 1.5f ) ) * sineWidth ;
Bounds tb = bounds_ ;
tb . x = bounds_ . x + 150 ;
tb . w = bounds_ . w - 150 ;
dc . PushScissor ( tb ) ;
}
2013-12-06 10:44:46 +00:00
dc . DrawText ( title_ . c_str ( ) , bounds_ . x + tx , bounds_ . centerY ( ) , style . fgColor , ALIGN_VCENTER ) ;
2013-11-26 13:45:36 +00:00
if ( availableWidth < tw ) {
dc . PopScissor ( ) ;
}
2013-08-18 20:30:34 +00:00
dc . Draw ( ) - > Flush ( ) ;
dc . PopScissor ( ) ;
} else if ( ! texture ) {
dc . Draw ( ) - > Flush ( ) ;
2013-08-16 10:52:16 +00:00
dc . PushScissor ( bounds_ ) ;
2013-12-06 10:44:46 +00:00
dc . DrawText ( title_ . c_str ( ) , bounds_ . x + 4 , bounds_ . centerY ( ) , style . fgColor , ALIGN_VCENTER ) ;
2013-08-18 20:30:34 +00:00
dc . Draw ( ) - > Flush ( ) ;
2013-08-16 10:52:16 +00:00
dc . PopScissor ( ) ;
2013-08-18 20:30:34 +00:00
} else {
dc . Draw ( ) - > Flush ( ) ;
2013-06-10 20:06:51 +00:00
}
2013-12-11 19:37:57 +00:00
if ( overlayColor ) {
dc . FillRect ( Drawable ( overlayColor ) , overlayBounds ) ;
}
2013-08-30 12:47:28 +00:00
dc . RebindTexture ( ) ;
2013-06-10 20:06:51 +00:00
}
2013-11-29 12:02:08 +00:00
enum GameBrowserFlags {
FLAG_HOMEBREWSTOREBUTTON = 1
} ;
2013-12-11 10:03:43 +00:00
class DirButton : public UI : : Button {
public :
2013-12-08 06:39:35 +00:00
DirButton ( const std : : string & path , UI : : LayoutParams * layoutParams )
: UI : : Button ( path , layoutParams ) , path_ ( path ) , absolute_ ( false ) { }
DirButton ( const std : : string & path , const std : : string & text , LayoutParams * layoutParams = 0 )
: UI : : Button ( text , layoutParams ) , path_ ( path ) , absolute_ ( true ) { }
2013-12-11 10:03:43 +00:00
virtual void Draw ( UIContext & dc ) ;
2013-12-08 06:39:35 +00:00
const std : : string GetPath ( ) const {
return path_ ;
}
bool PathAbsolute ( ) const {
return absolute_ ;
}
private :
std : : string path_ ;
bool absolute_ ;
2013-12-11 10:03:43 +00:00
} ;
void DirButton : : Draw ( UIContext & dc ) {
Style style = dc . theme - > buttonStyle ;
if ( HasFocus ( ) ) style = dc . theme - > buttonFocusedStyle ;
if ( down_ ) style = dc . theme - > buttonDownStyle ;
if ( ! IsEnabled ( ) ) style = dc . theme - > buttonDisabledStyle ;
dc . FillRect ( style . background , bounds_ ) ;
const std : : string text = GetText ( ) ;
int image = I_FOLDER ;
if ( text = = " .. " ) {
image = I_UP_DIRECTORY ;
}
float tw , th ;
dc . MeasureText ( dc . GetFontStyle ( ) , text . c_str ( ) , & tw , & th , 0 ) ;
bool compact = bounds_ . w < 180 ;
if ( compact ) {
// No icon, except "up"
dc . PushScissor ( bounds_ ) ;
if ( image = = I_FOLDER ) {
dc . DrawText ( text . c_str ( ) , bounds_ . x + 5 , bounds_ . centerY ( ) , style . fgColor , ALIGN_VCENTER ) ;
} else {
dc . Draw ( ) - > DrawImage ( image , bounds_ . centerX ( ) , bounds_ . centerY ( ) , 1.0f , 0xFFFFFFFF , ALIGN_CENTER ) ;
}
dc . PopScissor ( ) ;
} else {
bool scissor = false ;
if ( tw + 150 > bounds_ . w ) {
dc . PushScissor ( bounds_ ) ;
scissor = true ;
}
dc . Draw ( ) - > DrawImage ( image , bounds_ . x + 72 , bounds_ . centerY ( ) , .88f , 0xFFFFFFFF , ALIGN_CENTER ) ;
dc . DrawText ( text . c_str ( ) , bounds_ . x + 150 , bounds_ . centerY ( ) , style . fgColor , ALIGN_VCENTER ) ;
if ( scissor ) {
dc . PopScissor ( ) ;
}
}
}
2013-08-16 10:52:16 +00:00
class GameBrowser : public UI : : LinearLayout {
2013-06-27 14:28:11 +00:00
public :
2013-11-29 12:02:08 +00:00
GameBrowser ( std : : string path , bool allowBrowsing , bool * gridStyle_ , std : : string lastText , std : : string lastLink , int flags = 0 , UI : : LayoutParams * layoutParams = 0 ) ;
2013-06-10 20:06:51 +00:00
UI : : Event OnChoice ;
2013-07-22 20:36:56 +00:00
UI : : Event OnHoldChoice ;
2013-10-21 10:21:22 +00:00
2013-11-29 12:02:08 +00:00
UI : : Choice * HomebrewStoreButton ( ) { return homebrewStoreButton_ ; }
2013-06-10 20:06:51 +00:00
private :
void Refresh ( ) ;
2013-12-08 06:39:35 +00:00
bool IsCurrentPathPinned ( ) ;
const std : : vector < std : : string > GetPinnedPaths ( ) ;
const std : : string GetBaseName ( const std : : string & path ) ;
2013-06-10 20:06:51 +00:00
UI : : EventReturn GameButtonClick ( UI : : EventParams & e ) ;
2013-07-22 20:36:56 +00:00
UI : : EventReturn GameButtonHoldClick ( UI : : EventParams & e ) ;
2013-06-27 14:28:11 +00:00
UI : : EventReturn NavigateClick ( UI : : EventParams & e ) ;
2013-08-16 10:52:16 +00:00
UI : : EventReturn LayoutChange ( UI : : EventParams & e ) ;
UI : : EventReturn LastClick ( UI : : EventParams & e ) ;
UI : : EventReturn HomeClick ( UI : : EventParams & e ) ;
2013-12-08 06:39:35 +00:00
UI : : EventReturn PinToggleClick ( UI : : EventParams & e ) ;
2013-06-27 14:28:11 +00:00
2013-08-16 10:52:16 +00:00
UI : : ViewGroup * gameList_ ;
2013-06-27 14:28:11 +00:00
PathBrowser path_ ;
2013-08-18 20:30:34 +00:00
bool * gridStyle_ ;
2013-07-08 01:34:44 +00:00
bool allowBrowsing_ ;
2013-08-16 10:52:16 +00:00
std : : string lastText_ ;
2013-10-08 09:07:18 +00:00
std : : string lastLink_ ;
2013-11-29 12:02:08 +00:00
int flags_ ;
UI : : Choice * homebrewStoreButton_ ;
2013-06-10 20:06:51 +00:00
} ;
2013-11-29 12:02:08 +00:00
GameBrowser : : GameBrowser ( std : : string path , bool allowBrowsing , bool * gridStyle , std : : string lastText , std : : string lastLink , int flags , UI : : LayoutParams * layoutParams )
: LinearLayout ( UI : : ORIENT_VERTICAL , layoutParams ) , gameList_ ( 0 ) , path_ ( path ) , gridStyle_ ( gridStyle ) , allowBrowsing_ ( allowBrowsing ) , lastText_ ( lastText ) , lastLink_ ( lastLink ) , flags_ ( flags ) {
2013-08-16 10:52:16 +00:00
using namespace UI ;
2013-06-27 14:28:11 +00:00
Refresh ( ) ;
2013-08-16 10:52:16 +00:00
}
2013-06-27 14:28:11 +00:00
2013-08-16 10:52:16 +00:00
UI : : EventReturn GameBrowser : : LayoutChange ( UI : : EventParams & e ) {
2013-08-18 20:30:34 +00:00
* gridStyle_ = e . a = = 0 ? true : false ;
2013-08-16 10:52:16 +00:00
Refresh ( ) ;
return UI : : EVENT_DONE ;
}
UI : : EventReturn GameBrowser : : LastClick ( UI : : EventParams & e ) {
LaunchBrowser ( lastLink_ . c_str ( ) ) ;
return UI : : EVENT_DONE ;
}
UI : : EventReturn GameBrowser : : HomeClick ( UI : : EventParams & e ) {
2013-10-15 11:28:09 +00:00
# ifdef ANDROID
2013-10-15 06:03:39 +00:00
path_ . SetPath ( g_Config . memCardDirectory ) ;
2013-10-19 18:48:28 +00:00
# elif defined(USING_QT_UI)
I18NCategory * m = GetI18NCategory ( " MainMenu " ) ;
QString fileName = QFileDialog : : getExistingDirectory ( NULL , " Browse for Folder " , g_Config . currentDirectory . c_str ( ) ) ;
2013-11-21 02:44:06 +00:00
if ( QDir ( fileName ) . exists ( ) )
2013-10-19 18:48:28 +00:00
path_ . SetPath ( fileName . toStdString ( ) ) ;
2013-11-21 02:44:06 +00:00
else
return UI : : EVENT_DONE ;
2013-10-15 11:28:09 +00:00
# elif defined(_WIN32)
I18NCategory * m = GetI18NCategory ( " MainMenu " ) ;
std : : string folder = W32Util : : BrowseForFolder ( MainWindow : : GetHWND ( ) , m - > T ( " Choose folder " ) ) ;
if ( ! folder . size ( ) )
return UI : : EVENT_DONE ;
path_ . SetPath ( folder ) ;
2013-11-19 15:25:36 +00:00
# elif defined(BLACKBERRY)
2013-11-21 02:44:06 +00:00
path_ . SetPath ( std : : string ( getenv ( " PERIMETER_HOME " ) ) + " /shared/misc " ) ;
2013-10-21 10:21:22 +00:00
# else
path_ . SetPath ( getenv ( " HOME " ) ) ;
2013-10-15 11:28:09 +00:00
# endif
2013-08-19 22:49:25 +00:00
g_Config . currentDirectory = path_ . GetPath ( ) ;
Refresh ( ) ;
2013-08-16 10:52:16 +00:00
return UI : : EVENT_DONE ;
2013-06-27 14:28:11 +00:00
}
2013-12-08 06:39:35 +00:00
UI : : EventReturn GameBrowser : : PinToggleClick ( UI : : EventParams & e ) {
auto & pinnedPaths = g_Config . vPinnedPaths ;
if ( IsCurrentPathPinned ( ) ) {
pinnedPaths . erase ( std : : remove ( pinnedPaths . begin ( ) , pinnedPaths . end ( ) , path_ . GetPath ( ) ) , pinnedPaths . end ( ) ) ;
} else {
pinnedPaths . push_back ( path_ . GetPath ( ) ) ;
}
Refresh ( ) ;
return UI : : EVENT_DONE ;
}
2013-06-10 20:06:51 +00:00
void GameBrowser : : Refresh ( ) {
2013-08-16 10:52:16 +00:00
using namespace UI ;
2013-11-29 12:02:08 +00:00
homebrewStoreButton_ = 0 ;
2013-08-16 10:52:16 +00:00
// Kill all the contents
Clear ( ) ;
2013-12-03 16:38:58 +00:00
Add ( new Spacer ( 1.0f ) ) ;
2013-08-20 18:12:58 +00:00
I18NCategory * m = GetI18NCategory ( " MainMenu " ) ;
2013-08-20 10:28:17 +00:00
2013-12-03 15:17:24 +00:00
// No topbar on recent screen
if ( path_ . GetPath ( ) ! = " !RECENT " ) {
LinearLayout * topBar = new LinearLayout ( ORIENT_HORIZONTAL , new LinearLayoutParams ( FILL_PARENT , WRAP_CONTENT ) ) ;
if ( allowBrowsing_ ) {
2013-12-03 16:38:58 +00:00
topBar - > Add ( new Spacer ( 2.0f ) ) ;
2013-12-03 15:17:24 +00:00
Margins pathMargins ( 5 , 0 ) ;
2013-12-03 16:38:58 +00:00
topBar - > Add ( new TextView ( path_ . GetFriendlyPath ( ) . c_str ( ) , ALIGN_VCENTER , true , new LinearLayoutParams ( 1.0f ) ) ) ;
2013-11-21 02:44:06 +00:00
# if defined(_WIN32) || defined(USING_QT_UI)
2013-12-03 15:17:24 +00:00
topBar - > Add ( new Choice ( m - > T ( " Browse " , " Browse... " ) ) ) - > OnClick . Handle ( this , & GameBrowser : : HomeClick ) ;
2013-10-21 10:21:22 +00:00
# else
2013-12-03 15:17:24 +00:00
topBar - > Add ( new Choice ( m - > T ( " Home " ) ) ) - > OnClick . Handle ( this , & GameBrowser : : HomeClick ) ;
2013-08-16 10:52:16 +00:00
# endif
2013-12-03 15:17:24 +00:00
} else {
topBar - > Add ( new Spacer ( new LinearLayoutParams ( 1.0f ) ) ) ;
}
2013-11-29 15:46:47 +00:00
2013-12-03 15:17:24 +00:00
ChoiceStrip * layoutChoice = topBar - > Add ( new ChoiceStrip ( ORIENT_HORIZONTAL ) ) ;
layoutChoice - > AddChoice ( I_GRID ) ;
layoutChoice - > AddChoice ( I_LINES ) ;
layoutChoice - > SetSelection ( * gridStyle_ ? 0 : 1 ) ;
layoutChoice - > OnChoice . Handle ( this , & GameBrowser : : LayoutChange ) ;
Add ( topBar ) ;
}
2013-11-29 15:46:47 +00:00
2013-08-18 20:30:34 +00:00
if ( * gridStyle_ ) {
2013-08-16 10:52:16 +00:00
gameList_ = new UI : : GridLayout ( UI : : GridLayoutSettings ( 150 , 85 ) , new LinearLayoutParams ( FILL_PARENT , WRAP_CONTENT ) ) ;
} else {
2013-08-20 16:18:30 +00:00
UI : : LinearLayout * gl = new UI : : LinearLayout ( UI : : ORIENT_VERTICAL , new LinearLayoutParams ( FILL_PARENT , WRAP_CONTENT ) ) ;
gl - > SetSpacing ( 4.0f ) ;
gameList_ = gl ;
2013-08-16 10:52:16 +00:00
}
Add ( gameList_ ) ;
2013-06-10 20:06:51 +00:00
// Find games in the current directory and create new ones.
2013-12-08 06:39:35 +00:00
std : : vector < DirButton * > dirButtons ;
2013-06-27 14:28:11 +00:00
std : : vector < GameButton * > gameButtons ;
if ( path_ . GetPath ( ) = = " !RECENT " ) {
for ( size_t i = 0 ; i < g_Config . recentIsos . size ( ) ; i + + ) {
2013-08-20 15:41:02 +00:00
gameButtons . push_back ( new GameButton ( g_Config . recentIsos [ i ] , * gridStyle_ , new UI : : LinearLayoutParams ( * gridStyle_ = = true ? UI : : WRAP_CONTENT : UI : : FILL_PARENT , UI : : WRAP_CONTENT ) ) ) ;
2013-06-27 14:28:11 +00:00
}
} else {
2013-06-10 20:06:51 +00:00
std : : vector < FileInfo > fileInfo ;
2013-06-27 14:28:11 +00:00
path_ . GetListing ( fileInfo , " iso:cso:pbp:elf:prx: " ) ;
2013-06-10 20:06:51 +00:00
for ( size_t i = 0 ; i < fileInfo . size ( ) ; i + + ) {
2013-12-08 06:54:23 +00:00
bool isGame = ! fileInfo [ i ] . isDirectory ;
// Check if eboot directory
if ( ! isGame & & path_ . GetPath ( ) . size ( ) > = 4 & & File : : Exists ( path_ . GetPath ( ) + fileInfo [ i ] . name + " /EBOOT.PBP " ) )
isGame = true ;
else if ( ! isGame & & File : : Exists ( path_ . GetPath ( ) + fileInfo [ i ] . name + " /PSP_GAME/SYSDIR " ) )
isGame = true ;
if ( ! isGame ) {
2013-12-11 09:11:01 +00:00
if ( allowBrowsing_ ) {
2013-12-11 10:03:43 +00:00
dirButtons . push_back ( new DirButton ( fileInfo [ i ] . name , new UI : : LinearLayoutParams ( UI : : FILL_PARENT , UI : : FILL_PARENT ) ) ) ;
2013-12-11 09:11:01 +00:00
}
2013-06-27 14:28:11 +00:00
} else {
2013-08-18 20:30:34 +00:00
gameButtons . push_back ( new GameButton ( fileInfo [ i ] . fullName , * gridStyle_ , new UI : : LinearLayoutParams ( * gridStyle_ = = true ? UI : : WRAP_CONTENT : UI : : FILL_PARENT , UI : : WRAP_CONTENT ) ) ) ;
2013-06-27 14:28:11 +00:00
}
2013-06-10 20:06:51 +00:00
}
2013-08-19 22:49:25 +00:00
// Put RAR/ZIP files at the end to get them out of the way. They're only shown so that people
// can click them and get an explanation that they need to unpack them. This is necessary due
// to a flood of support email...
if ( allowBrowsing_ ) {
fileInfo . clear ( ) ;
path_ . GetListing ( fileInfo , " zip:rar:r01: " ) ;
2013-12-11 17:25:55 +00:00
if ( ! fileInfo . empty ( ) ) {
UI : : LinearLayout * zl = new UI : : LinearLayout ( UI : : ORIENT_VERTICAL , new LinearLayoutParams ( FILL_PARENT , WRAP_CONTENT ) ) ;
2013-12-11 19:01:17 +00:00
zl - > SetSpacing ( 4.0f ) ;
2013-12-11 17:25:55 +00:00
Add ( zl ) ;
for ( size_t i = 0 ; i < fileInfo . size ( ) ; i + + ) {
if ( ! fileInfo [ i ] . isDirectory ) {
2013-12-11 19:37:57 +00:00
GameButton * b = zl - > Add ( new GameButton ( fileInfo [ i ] . fullName , false , new UI : : LinearLayoutParams ( UI : : FILL_PARENT , UI : : WRAP_CONTENT ) ) ) ;
b - > OnClick . Handle ( this , & GameBrowser : : GameButtonClick ) ;
b - > SetHoldEnabled ( false ) ;
2013-12-11 17:25:55 +00:00
}
2013-08-19 22:49:25 +00:00
}
}
}
2013-06-10 20:06:51 +00:00
}
2013-12-05 11:07:21 +00:00
if ( allowBrowsing_ ) {
2013-12-11 10:03:43 +00:00
gameList_ - > Add ( new DirButton ( " .. " , new UI : : LinearLayoutParams ( UI : : FILL_PARENT , UI : : FILL_PARENT ) ) ) - >
OnClick . Handle ( this , & GameBrowser : : NavigateClick ) ;
2013-12-08 06:39:35 +00:00
// Add any pinned paths before other directories.
auto pinnedPaths = GetPinnedPaths ( ) ;
for ( auto it = pinnedPaths . begin ( ) , end = pinnedPaths . end ( ) ; it ! = end ; + + it ) {
gameList_ - > Add ( new DirButton ( * it , GetBaseName ( * it ) , new UI : : LinearLayoutParams ( UI : : FILL_PARENT , UI : : FILL_PARENT ) ) ) - >
OnClick . Handle ( this , & GameBrowser : : NavigateClick ) ;
}
2013-12-05 11:07:21 +00:00
}
2013-06-27 14:28:11 +00:00
for ( size_t i = 0 ; i < dirButtons . size ( ) ; i + + ) {
2013-08-16 10:52:16 +00:00
gameList_ - > Add ( dirButtons [ i ] ) - > OnClick . Handle ( this , & GameBrowser : : NavigateClick ) ;
2013-06-27 14:28:11 +00:00
}
for ( size_t i = 0 ; i < gameButtons . size ( ) ; i + + ) {
2013-08-16 10:52:16 +00:00
GameButton * b = gameList_ - > Add ( gameButtons [ i ] ) ;
2013-07-22 20:36:56 +00:00
b - > OnClick . Handle ( this , & GameBrowser : : GameButtonClick ) ;
b - > OnHoldClick . Handle ( this , & GameBrowser : : GameButtonHoldClick ) ;
2013-06-10 20:06:51 +00:00
}
2013-08-16 10:52:16 +00:00
2013-12-08 06:39:35 +00:00
// Show a button to toggle pinning at the very end.
if ( allowBrowsing_ ) {
std : : string caption = IsCurrentPathPinned ( ) ? " - " : " + " ;
if ( ! * gridStyle_ ) {
2013-12-08 07:02:29 +00:00
caption = IsCurrentPathPinned ( ) ? m - > T ( " UnpinPath " , " Unpin " ) : m - > T ( " PinPath " , " Pin " ) ;
2013-12-08 06:39:35 +00:00
}
gameList_ - > Add ( new UI : : Button ( caption , new UI : : LinearLayoutParams ( UI : : FILL_PARENT , UI : : FILL_PARENT ) ) ) - >
OnClick . Handle ( this , & GameBrowser : : PinToggleClick ) ;
}
2013-12-05 11:07:21 +00:00
if ( g_Config . bHomebrewStore & & ( flags_ & FLAG_HOMEBREWSTOREBUTTON ) ) {
2013-11-29 12:02:08 +00:00
Add ( new Spacer ( ) ) ;
2013-12-13 13:58:06 +00:00
homebrewStoreButton_ = Add ( new Choice ( m - > T ( " DownloadFromStore " , " Download from the PPSSPP Homebrew Store " ) , new UI : : LinearLayoutParams ( UI : : WRAP_CONTENT , UI : : WRAP_CONTENT ) ) ) ;
2013-12-05 11:07:21 +00:00
} else {
homebrewStoreButton_ = 0 ;
2013-11-29 12:02:08 +00:00
}
2013-08-17 04:47:50 +00:00
if ( ! lastText_ . empty ( ) & & gameButtons . empty ( ) ) {
2013-08-16 10:52:16 +00:00
Add ( new Spacer ( ) ) ;
2013-08-16 14:48:43 +00:00
Add ( new Choice ( lastText_ , new UI : : LinearLayoutParams ( UI : : WRAP_CONTENT , UI : : WRAP_CONTENT ) ) ) - > OnClick . Handle ( this , & GameBrowser : : LastClick ) ;
2013-08-16 10:52:16 +00:00
}
2013-06-10 20:06:51 +00:00
}
2013-12-08 06:39:35 +00:00
bool GameBrowser : : IsCurrentPathPinned ( ) {
const auto paths = g_Config . vPinnedPaths ;
return std : : find ( paths . begin ( ) , paths . end ( ) , path_ . GetPath ( ) ) ! = paths . end ( ) ;
}
const std : : vector < std : : string > GameBrowser : : GetPinnedPaths ( ) {
2014-01-02 00:45:37 +00:00
# ifndef _WIN32
2013-12-08 06:39:35 +00:00
static const std : : string sepChars = " / " ;
# else
static const std : : string sepChars = " / \\ " ;
# endif
const std : : string currentPath = path_ . GetPath ( ) ;
const std : : vector < std : : string > paths = g_Config . vPinnedPaths ;
std : : vector < std : : string > results ;
for ( size_t i = 0 ; i < paths . size ( ) ; + + i ) {
// We want to exclude the current path, and its direct children.
if ( paths [ i ] = = currentPath ) {
continue ;
}
if ( startsWith ( paths [ i ] , currentPath ) ) {
std : : string descendant = paths [ i ] . substr ( currentPath . size ( ) ) ;
// If there's only one separator (or none), its a direct child.
if ( descendant . find_last_of ( sepChars ) = = descendant . find_first_of ( sepChars ) ) {
continue ;
}
}
results . push_back ( paths [ i ] ) ;
}
return results ;
}
const std : : string GameBrowser : : GetBaseName ( const std : : string & path ) {
2014-01-02 00:45:37 +00:00
# ifndef _WIN32
2013-12-08 06:39:35 +00:00
static const std : : string sepChars = " / " ;
# else
static const std : : string sepChars = " / \\ " ;
# endif
auto trailing = path . find_last_not_of ( sepChars ) ;
if ( trailing ! = path . npos ) {
size_t start = path . find_last_of ( sepChars , trailing ) ;
if ( start ! = path . npos ) {
return path . substr ( start + 1 , trailing - start ) ;
}
return path . substr ( 0 , trailing ) ;
}
size_t start = path . find_last_of ( sepChars ) ;
if ( start ! = path . npos ) {
return path . substr ( start + 1 ) ;
}
return path ;
}
2013-06-10 20:06:51 +00:00
UI : : EventReturn GameBrowser : : GameButtonClick ( UI : : EventParams & e ) {
GameButton * button = static_cast < GameButton * > ( e . v ) ;
UI : : EventParams e2 ;
e2 . s = button - > GamePath ( ) ;
// Insta-update - here we know we are already on the right thread.
OnChoice . Trigger ( e2 ) ;
return UI : : EVENT_DONE ;
}
2013-07-22 20:36:56 +00:00
UI : : EventReturn GameBrowser : : GameButtonHoldClick ( UI : : EventParams & e ) {
GameButton * button = static_cast < GameButton * > ( e . v ) ;
UI : : EventParams e2 ;
e2 . s = button - > GamePath ( ) ;
// Insta-update - here we know we are already on the right thread.
OnHoldChoice . Trigger ( e2 ) ;
return UI : : EVENT_DONE ;
}
2013-06-27 14:28:11 +00:00
UI : : EventReturn GameBrowser : : NavigateClick ( UI : : EventParams & e ) {
2013-12-08 06:39:35 +00:00
DirButton * button = static_cast < DirButton * > ( e . v ) ;
std : : string text = button - > GetPath ( ) ;
if ( button - > PathAbsolute ( ) ) {
path_ . SetPath ( text ) ;
} else {
path_ . Navigate ( text ) ;
}
2013-06-27 14:28:11 +00:00
g_Config . currentDirectory = path_ . GetPath ( ) ;
Refresh ( ) ;
return UI : : EVENT_DONE ;
}
2013-11-20 15:36:58 +00:00
MainScreen : : MainScreen ( ) : backFromStore_ ( false ) {
2013-12-04 16:41:59 +00:00
System_SendMessage ( " event " , " mainscreen " ) ;
}
2013-06-10 20:06:51 +00:00
void MainScreen : : CreateViews ( ) {
// Information in the top left.
// Back button to the bottom left.
// Scrolling action menu to the right.
using namespace UI ;
2013-10-15 22:47:57 +00:00
// Vertical mode is not finished.
bool vertical = false ; // dp_yres > dp_xres;
2013-10-10 09:09:48 +00:00
2013-08-11 15:25:50 +00:00
I18NCategory * m = GetI18NCategory ( " MainMenu " ) ;
2013-08-20 18:02:20 +00:00
Margins actionMenuMargins ( 0 , 10 , 10 , 0 ) ;
2013-06-10 20:06:51 +00:00
2013-10-09 14:26:15 +00:00
TabHolder * leftColumn = new TabHolder ( ORIENT_HORIZONTAL , 64 ) ;
2013-11-20 15:36:58 +00:00
tabHolder_ = leftColumn ;
2013-08-20 10:28:17 +00:00
leftColumn - > SetClip ( true ) ;
2013-06-10 20:06:51 +00:00
2013-06-27 14:28:11 +00:00
ScrollView * scrollRecentGames = new ScrollView ( ORIENT_VERTICAL , new LinearLayoutParams ( FILL_PARENT , WRAP_CONTENT ) ) ;
ScrollView * scrollAllGames = new ScrollView ( ORIENT_VERTICAL , new LinearLayoutParams ( FILL_PARENT , WRAP_CONTENT ) ) ;
ScrollView * scrollHomebrew = new ScrollView ( ORIENT_VERTICAL , new LinearLayoutParams ( FILL_PARENT , WRAP_CONTENT ) ) ;
2013-08-16 10:52:16 +00:00
GameBrowser * tabRecentGames = new GameBrowser (
2013-11-29 12:02:08 +00:00
" !RECENT " , false , & g_Config . bGridView1 , " " , " " , 0 ,
2013-08-16 10:52:16 +00:00
new LinearLayoutParams ( FILL_PARENT , FILL_PARENT ) ) ;
2013-11-20 15:36:58 +00:00
GameBrowser * tabAllGames = new GameBrowser ( g_Config . currentDirectory , true , & g_Config . bGridView2 ,
2013-11-29 12:02:08 +00:00
m - > T ( " How to get games " ) , " http://www.ppsspp.org/getgames.html " , 0 ,
2013-08-16 10:52:16 +00:00
new LinearLayoutParams ( FILL_PARENT , FILL_PARENT ) ) ;
2013-10-15 06:03:39 +00:00
GameBrowser * tabHomebrew = new GameBrowser ( GetSysDirectory ( DIRECTORY_GAME ) , false , & g_Config . bGridView3 ,
2013-11-29 10:36:47 +00:00
m - > T ( " How to get homebrew & demos " , " How to get homebrew && demos " ) , " http://www.ppsspp.org/gethomebrew.html " ,
2013-11-29 12:02:08 +00:00
FLAG_HOMEBREWSTOREBUTTON ,
2013-08-16 10:52:16 +00:00
new LinearLayoutParams ( FILL_PARENT , FILL_PARENT ) ) ;
2013-06-27 14:28:11 +00:00
2013-12-05 11:07:21 +00:00
Choice * hbStore = tabHomebrew - > HomebrewStoreButton ( ) ;
if ( hbStore ) {
hbStore - > OnClick . Handle ( this , & MainScreen : : OnHomebrewStore ) ;
}
2013-11-29 12:02:08 +00:00
2013-06-27 14:28:11 +00:00
scrollRecentGames - > Add ( tabRecentGames ) ;
scrollAllGames - > Add ( tabAllGames ) ;
scrollHomebrew - > Add ( tabHomebrew ) ;
2013-08-11 15:25:50 +00:00
leftColumn - > AddTab ( m - > T ( " Recent " ) , scrollRecentGames ) ;
leftColumn - > AddTab ( m - > T ( " Games " ) , scrollAllGames ) ;
leftColumn - > AddTab ( m - > T ( " Homebrew & Demos " ) , scrollHomebrew ) ;
2013-06-10 20:06:51 +00:00
2013-08-16 10:52:16 +00:00
tabRecentGames - > OnChoice . Handle ( this , & MainScreen : : OnGameSelectedInstant ) ;
tabAllGames - > OnChoice . Handle ( this , & MainScreen : : OnGameSelectedInstant ) ;
tabHomebrew - > OnChoice . Handle ( this , & MainScreen : : OnGameSelectedInstant ) ;
tabRecentGames - > OnHoldChoice . Handle ( this , & MainScreen : : OnGameSelected ) ;
tabAllGames - > OnHoldChoice . Handle ( this , & MainScreen : : OnGameSelected ) ;
tabHomebrew - > OnHoldChoice . Handle ( this , & MainScreen : : OnGameSelected ) ;
2013-06-10 20:06:51 +00:00
2013-10-20 16:18:06 +00:00
if ( g_Config . recentIsos . size ( ) > 0 ) {
leftColumn - > SetCurrentTab ( 0 ) ;
2013-11-20 15:36:58 +00:00
} else {
2013-10-20 16:18:06 +00:00
leftColumn - > SetCurrentTab ( 1 ) ;
}
2013-06-10 20:06:51 +00:00
2013-12-06 11:29:27 +00:00
if ( backFromStore_ | | showHomebrewTab ) {
2013-11-20 15:36:58 +00:00
leftColumn - > SetCurrentTab ( 2 ) ;
backFromStore_ = false ;
2013-12-06 11:29:27 +00:00
showHomebrewTab = false ;
2013-11-20 15:36:58 +00:00
}
2013-11-29 15:46:47 +00:00
/* if (info) {
2013-11-20 15:36:58 +00:00
texvGameIcon_ = leftColumn - > Add ( new TextureView ( 0 , IS_DEFAULT , new AnchorLayoutParams ( 144 * 2 , 80 * 2 , 10 , 10 , NONE , NONE ) ) ) ;
tvTitle_ = leftColumn - > Add ( new TextView ( 0 , info - > title , ALIGN_LEFT , 1.0f , new AnchorLayoutParams ( 10 , 200 , NONE , NONE ) ) ) ;
tvGameSize_ = leftColumn - > Add ( new TextView ( 0 , " ... " , ALIGN_LEFT , 1.0f , new AnchorLayoutParams ( 10 , 250 , NONE , NONE ) ) ) ;
tvSaveDataSize_ = leftColumn - > Add ( new TextView ( 0 , " ... " , ALIGN_LEFT , 1.0f , new AnchorLayoutParams ( 10 , 290 , NONE , NONE ) ) ) ;
2013-11-29 15:46:47 +00:00
} */
2013-11-20 15:36:58 +00:00
2013-10-09 14:26:15 +00:00
ViewGroup * rightColumn = new ScrollView ( ORIENT_VERTICAL ) ;
LinearLayout * rightColumnItems = new LinearLayout ( ORIENT_VERTICAL , new LinearLayoutParams ( FILL_PARENT , WRAP_CONTENT ) ) ;
2013-10-22 14:18:43 +00:00
rightColumnItems - > SetSpacing ( 0.0f ) ;
2013-06-10 20:06:51 +00:00
rightColumn - > Add ( rightColumnItems ) ;
2013-06-27 14:28:11 +00:00
2013-08-19 22:49:25 +00:00
char versionString [ 256 ] ;
sprintf ( versionString , " %s " , PPSSPP_GIT_VERSION ) ;
rightColumnItems - > SetSpacing ( 0.0f ) ;
LinearLayout * logos = new LinearLayout ( ORIENT_HORIZONTAL ) ;
# ifdef GOLD
2013-11-12 04:54:38 +00:00
logos - > Add ( new ImageView ( I_ICONGOLD , IS_DEFAULT , new AnchorLayoutParams ( 64 , 64 , 10 , 10 , NONE , NONE , false ) ) ) ;
2013-08-19 22:49:25 +00:00
# else
logos - > Add ( new ImageView ( I_ICON , IS_DEFAULT , new AnchorLayoutParams ( 64 , 64 , 10 , 10 , NONE , NONE , false ) ) ) ;
# endif
logos - > Add ( new ImageView ( I_LOGO , IS_DEFAULT , new LinearLayoutParams ( Margins ( - 12 , 0 , 0 , 0 ) ) ) ) ;
rightColumnItems - > Add ( logos ) ;
2013-08-30 12:47:28 +00:00
rightColumnItems - > Add ( new TextView ( versionString , new LinearLayoutParams ( Margins ( 70 , - 6 , 0 , 0 ) ) ) ) - > SetSmall ( true ) ;
2013-11-26 15:45:38 +00:00
# if defined(_WIN32) || defined(USING_QT_UI)
2013-08-11 15:25:50 +00:00
rightColumnItems - > Add ( new Choice ( m - > T ( " Load " , " Load... " ) ) ) - > OnClick . Handle ( this , & MainScreen : : OnLoadFile ) ;
2013-06-27 14:28:11 +00:00
# endif
2013-10-20 15:33:18 +00:00
rightColumnItems - > Add ( new Choice ( m - > T ( " Game Settings " , " Settings " ) ) ) - > OnClick . Handle ( this , & MainScreen : : OnGameSettings ) ;
2013-08-11 15:25:50 +00:00
rightColumnItems - > Add ( new Choice ( m - > T ( " Credits " ) ) ) - > OnClick . Handle ( this , & MainScreen : : OnCredits ) ;
2013-09-12 00:57:27 +00:00
# ifndef __SYMBIAN32__
2013-08-19 22:49:25 +00:00
rightColumnItems - > Add ( new Choice ( m - > T ( " www.ppsspp.org " ) ) ) - > OnClick . Handle ( this , & MainScreen : : OnPPSSPPOrg ) ;
2013-09-12 00:57:27 +00:00
# endif
2013-10-31 12:34:34 +00:00
# ifndef GOLD
Choice * gold = rightColumnItems - > Add ( new Choice ( m - > T ( " Support PPSSPP " ) ) ) ;
gold - > OnClick . Handle ( this , & MainScreen : : OnSupport ) ;
gold - > SetIcon ( I_ICONGOLD ) ;
# endif
2013-10-28 09:41:09 +00:00
rightColumnItems - > Add ( new Choice ( m - > T ( " Exit " ) ) ) - > OnClick . Handle ( this , & MainScreen : : OnExit ) ;
2013-11-26 13:04:29 +00:00
2013-10-09 14:26:15 +00:00
if ( vertical ) {
root_ = new LinearLayout ( ORIENT_VERTICAL ) ;
rightColumn - > ReplaceLayoutParams ( new LinearLayoutParams ( FILL_PARENT , WRAP_CONTENT ) ) ;
2013-11-29 15:46:47 +00:00
leftColumn - > ReplaceLayoutParams ( new LinearLayoutParams ( 1.0 ) ) ;
root_ - > Add ( rightColumn ) ;
2013-10-09 14:26:15 +00:00
root_ - > Add ( leftColumn ) ;
} else {
root_ = new LinearLayout ( ORIENT_HORIZONTAL ) ;
leftColumn - > ReplaceLayoutParams ( new LinearLayoutParams ( 1.0 ) ) ;
rightColumn - > ReplaceLayoutParams ( new LinearLayoutParams ( 300 , FILL_PARENT , actionMenuMargins ) ) ;
2013-11-24 08:08:05 +00:00
root_ - > Add ( leftColumn ) ;
2013-10-09 14:26:15 +00:00
root_ - > Add ( rightColumn ) ;
}
2013-11-26 13:04:29 +00:00
I18NCategory * u = GetI18NCategory ( " Upgrade " ) ;
upgradeBar_ = 0 ;
if ( ! g_Config . upgradeMessage . empty ( ) ) {
upgradeBar_ = new LinearLayout ( ORIENT_HORIZONTAL , new LinearLayoutParams ( FILL_PARENT , WRAP_CONTENT ) ) ;
UI : : Margins textMargins ( 10 , 5 ) ;
UI : : Margins buttonMargins ( 0 , 0 ) ;
UI : : Drawable solid ( 0xFFbd9939 ) ;
upgradeBar_ - > SetBG ( solid ) ;
upgradeBar_ - > Add ( new TextView ( u - > T ( " New version of PPSSPP available " ) + std : : string ( " : " ) + g_Config . upgradeVersion , new LinearLayoutParams ( 1.0f , textMargins ) ) ) ;
upgradeBar_ - > Add ( new Button ( u - > T ( " Download " ) , new LinearLayoutParams ( buttonMargins ) ) ) - > OnClick . Handle ( this , & MainScreen : : OnDownloadUpgrade ) ;
upgradeBar_ - > Add ( new Button ( u - > T ( " Dismiss " ) , new LinearLayoutParams ( buttonMargins ) ) ) - > OnClick . Handle ( this , & MainScreen : : OnDismissUpgrade ) ;
// Slip in under root_
LinearLayout * newRoot = new LinearLayout ( ORIENT_VERTICAL ) ;
newRoot - > Add ( root_ ) ;
newRoot - > Add ( upgradeBar_ ) ;
root_ - > ReplaceLayoutParams ( new LinearLayoutParams ( 1.0 ) ) ;
root_ = newRoot ;
}
}
UI : : EventReturn MainScreen : : OnDownloadUpgrade ( UI : : EventParams & e ) {
# ifdef ANDROID
// Go to app store
# ifdef GOLD
LaunchBrowser ( " market://details?id=org.ppsspp.ppssppgold " ) ;
# else
LaunchBrowser ( " market://details?id=org.ppsspp.ppsspp " ) ;
# endif
# else
// Go directly to ppsspp.org and let the user sort it out
LaunchBrowser ( " http://www.ppsspp.org/downloads.html " ) ;
# endif
return EVENT_DONE ;
}
UI : : EventReturn MainScreen : : OnDismissUpgrade ( UI : : EventParams & e ) {
g_Config . DismissUpgrade ( ) ;
upgradeBar_ - > SetVisibility ( V_GONE ) ;
return EVENT_DONE ;
2013-06-10 20:06:51 +00:00
}
2013-07-08 10:35:08 +00:00
void MainScreen : : sendMessage ( const char * message , const char * value ) {
2013-10-21 20:52:44 +00:00
// Always call the base class method first to handle the most common messages.
UIScreenWithBackground : : sendMessage ( message , value ) ;
2013-07-08 10:35:08 +00:00
if ( ! strcmp ( message , " boot " ) ) {
screenManager ( ) - > switchScreen ( new EmuScreen ( value ) ) ;
}
2013-09-07 15:29:44 +00:00
if ( ! strcmp ( message , " control mapping " ) ) {
2013-09-15 16:35:58 +00:00
UpdateUIState ( UISTATE_MENU ) ;
2013-09-07 15:29:44 +00:00
screenManager ( ) - > push ( new ControlMappingScreen ( ) ) ;
}
if ( ! strcmp ( message , " settings " ) ) {
2013-09-15 16:35:58 +00:00
UpdateUIState ( UISTATE_MENU ) ;
2013-09-07 15:29:44 +00:00
screenManager ( ) - > push ( new GameSettingsScreen ( " " ) ) ;
}
2013-07-08 10:35:08 +00:00
}
2013-07-21 11:31:46 +00:00
void MainScreen : : update ( InputState & input ) {
UIScreen : : update ( input ) ;
2013-09-15 16:35:58 +00:00
UpdateUIState ( UISTATE_MENU ) ;
2013-06-10 20:06:51 +00:00
}
2013-06-27 14:28:11 +00:00
UI : : EventReturn MainScreen : : OnLoadFile ( UI : : EventParams & e ) {
2013-11-26 15:45:38 +00:00
# if defined(USING_QT_UI)
2013-12-09 09:50:19 +00:00
QString fileName = QFileDialog : : getOpenFileName ( NULL , " Load ROM " , g_Config . currentDirectory . c_str ( ) , " PSP ROMs (*.iso *.cso *.pbp *.elf *.zip) " ) ;
2013-08-17 23:24:34 +00:00
if ( QFile : : exists ( fileName ) ) {
QDir newPath ;
g_Config . currentDirectory = newPath . filePath ( fileName ) . toStdString ( ) ;
g_Config . Save ( ) ;
screenManager ( ) - > switchScreen ( new EmuScreen ( fileName . toStdString ( ) ) ) ;
}
2014-02-08 19:11:50 +00:00
# elif defined(USING_WIN_UI)
2013-06-27 14:28:11 +00:00
MainWindow : : BrowseAndBoot ( " " ) ;
# endif
return UI : : EVENT_DONE ;
}
2013-06-10 20:06:51 +00:00
UI : : EventReturn MainScreen : : OnGameSelected ( UI : : EventParams & e ) {
2013-09-15 04:08:53 +00:00
# ifdef _WIN32
2013-10-12 00:03:11 +00:00
std : : string path = ReplaceAll ( e . s , " \\ " , " / " ) ;
2013-09-15 04:08:53 +00:00
# else
std : : string path = e . s ;
# endif
screenManager ( ) - > push ( new GameScreen ( path ) ) ;
2013-06-10 20:06:51 +00:00
return UI : : EVENT_DONE ;
}
2013-08-16 10:52:16 +00:00
UI : : EventReturn MainScreen : : OnGameSelectedInstant ( UI : : EventParams & e ) {
2013-09-15 04:08:53 +00:00
# ifdef _WIN32
2013-10-12 00:03:11 +00:00
std : : string path = ReplaceAll ( e . s , " \\ " , " / " ) ;
2013-09-15 04:08:53 +00:00
# else
std : : string path = e . s ;
# endif
2013-07-22 20:36:56 +00:00
// Go directly into the game.
2013-09-15 04:08:53 +00:00
screenManager ( ) - > switchScreen ( new EmuScreen ( path ) ) ;
2013-07-22 20:36:56 +00:00
return UI : : EVENT_DONE ;
}
2013-08-16 10:52:16 +00:00
UI : : EventReturn MainScreen : : OnGameSettings ( UI : : EventParams & e ) {
// screenManager()->push(new SettingsScreen());
2013-09-01 20:29:23 +00:00
auto gameSettings = new GameSettingsScreen ( " " , " " ) ;
2013-09-07 16:44:28 +00:00
gameSettings - > OnRecentChanged . Handle ( this , & MainScreen : : OnRecentChange ) ;
2013-09-01 20:29:23 +00:00
screenManager ( ) - > push ( gameSettings ) ;
return UI : : EVENT_DONE ;
}
2013-09-07 16:44:28 +00:00
UI : : EventReturn MainScreen : : OnRecentChange ( UI : : EventParams & e ) {
RecreateViews ( ) ;
if ( host ) {
host - > UpdateUI ( ) ;
}
return UI : : EVENT_DONE ;
}
2013-06-10 20:06:51 +00:00
UI : : EventReturn MainScreen : : OnCredits ( UI : : EventParams & e ) {
screenManager ( ) - > push ( new CreditsScreen ( ) ) ;
return UI : : EVENT_DONE ;
}
2013-11-20 13:42:48 +00:00
UI : : EventReturn MainScreen : : OnHomebrewStore ( UI : : EventParams & e ) {
screenManager ( ) - > push ( new StoreScreen ( ) ) ;
return UI : : EVENT_DONE ;
}
2013-06-10 20:06:51 +00:00
UI : : EventReturn MainScreen : : OnSupport ( UI : : EventParams & e ) {
2013-07-15 15:41:24 +00:00
# ifdef ANDROID
LaunchBrowser ( " market://details?id=org.ppsspp.ppssppgold " ) ;
# else
LaunchBrowser ( " http://central.ppsspp.org/buygold " ) ;
# endif
2013-06-10 20:06:51 +00:00
return UI : : EVENT_DONE ;
2013-06-27 17:40:45 +00:00
}
2013-06-28 12:29:15 +00:00
2013-08-19 22:49:25 +00:00
UI : : EventReturn MainScreen : : OnPPSSPPOrg ( UI : : EventParams & e ) {
LaunchBrowser ( " http://www.ppsspp.org " ) ;
return UI : : EVENT_DONE ;
}
UI : : EventReturn MainScreen : : OnForums ( UI : : EventParams & e ) {
LaunchBrowser ( " http://forums.ppsspp.org " ) ;
return UI : : EVENT_DONE ;
}
2013-06-28 12:29:15 +00:00
UI : : EventReturn MainScreen : : OnExit ( UI : : EventParams & e ) {
2013-12-04 16:41:59 +00:00
System_SendMessage ( " event " , " exitprogram " ) ;
2013-06-28 12:29:15 +00:00
NativeShutdown ( ) ;
return UI : : EVENT_DONE ;
}
2013-07-21 11:31:46 +00:00
2013-11-20 15:36:58 +00:00
void MainScreen : : dialogFinished ( const Screen * dialog , DialogResult result ) {
if ( dialog - > tag ( ) = = " store " ) {
backFromStore_ = true ;
RecreateViews ( ) ;
}
}
2013-07-21 11:31:46 +00:00
void GamePauseScreen : : update ( InputState & input ) {
2013-09-15 16:35:58 +00:00
UpdateUIState ( UISTATE_PAUSEMENU ) ;
2013-07-21 11:31:46 +00:00
UIScreen : : update ( input ) ;
}
GamePauseScreen : : ~ GamePauseScreen ( ) {
2013-09-15 21:58:49 +00:00
if ( saveSlots_ ! = NULL ) {
g_Config . iCurrentStateSlot = saveSlots_ - > GetSelection ( ) ;
g_Config . Save ( ) ;
}
2013-07-21 11:31:46 +00:00
}
void GamePauseScreen : : CreateViews ( ) {
2013-11-29 15:46:47 +00:00
static const int NUM_SAVESLOTS = 5 ;
2013-10-08 13:38:50 +00:00
2013-07-21 11:31:46 +00:00
using namespace UI ;
Margins actionMenuMargins ( 0 , 100 , 15 , 0 ) ;
2013-08-11 15:25:50 +00:00
I18NCategory * gs = GetI18NCategory ( " Graphics " ) ;
I18NCategory * i = GetI18NCategory ( " Pause " ) ;
2013-07-21 11:31:46 +00:00
root_ = new LinearLayout ( ORIENT_HORIZONTAL ) ;
ViewGroup * leftColumn = new ScrollView ( ORIENT_VERTICAL , new LinearLayoutParams ( 300 , FILL_PARENT , actionMenuMargins ) ) ;
root_ - > Add ( leftColumn ) ;
root_ - > Add ( new Spacer ( new LinearLayoutParams ( 1.0 ) ) ) ;
ViewGroup * leftColumnItems = new LinearLayout ( ORIENT_VERTICAL ) ;
leftColumn - > Add ( leftColumnItems ) ;
2013-10-27 09:04:38 +00:00
2013-07-21 11:31:46 +00:00
saveSlots_ = leftColumnItems - > Add ( new ChoiceStrip ( ORIENT_HORIZONTAL , new LinearLayoutParams ( 300 , WRAP_CONTENT ) ) ) ;
2013-10-08 13:38:50 +00:00
for ( int i = 0 ; i < NUM_SAVESLOTS ; i + + ) {
std : : stringstream saveSlotText ;
2013-10-27 09:04:38 +00:00
saveSlotText < < " " < < i + 1 < < " " ;
2013-10-08 13:38:50 +00:00
saveSlots_ - > AddChoice ( saveSlotText . str ( ) ) ;
if ( SaveState : : HasSaveInSlot ( i ) ) {
2013-10-07 16:16:02 +00:00
saveSlots_ - > HighlightChoice ( i ) ;
}
}
2013-10-27 09:04:38 +00:00
saveSlots_ - > SetSelection ( g_Config . iCurrentStateSlot ) ;
2013-08-20 16:12:16 +00:00
saveSlots_ - > OnChoice . Handle ( this , & GamePauseScreen : : OnStateSelected ) ;
2013-10-27 09:04:38 +00:00
2013-08-22 02:42:58 +00:00
saveStateButton_ = leftColumnItems - > Add ( new Choice ( i - > T ( " Save State " ) ) ) ;
2013-08-20 16:12:16 +00:00
saveStateButton_ - > OnClick . Handle ( this , & GamePauseScreen : : OnSaveState ) ;
2013-07-21 11:31:46 +00:00
2013-08-22 02:42:58 +00:00
loadStateButton_ = leftColumnItems - > Add ( new Choice ( i - > T ( " Load State " ) ) ) ;
2013-08-20 16:12:16 +00:00
loadStateButton_ - > OnClick . Handle ( this , & GamePauseScreen : : OnLoadState ) ;
2013-07-21 11:31:46 +00:00
2013-11-03 01:33:23 +00:00
if ( g_Config . iRewindFlipFrequency > 0 ) {
UI : : Choice * rewindButton = leftColumnItems - > Add ( new Choice ( i - > T ( " Rewind " ) ) ) ;
rewindButton - > SetEnabled ( SaveState : : CanRewind ( ) ) ;
rewindButton - > OnClick . Handle ( this , & GamePauseScreen : : OnRewind ) ;
}
2013-07-21 11:31:46 +00:00
ViewGroup * rightColumn = new ScrollView ( ORIENT_VERTICAL , new LinearLayoutParams ( 300 , FILL_PARENT , actionMenuMargins ) ) ;
root_ - > Add ( rightColumn ) ;
2013-10-28 15:04:53 +00:00
LinearLayout * rightColumnItems = new LinearLayout ( ORIENT_VERTICAL ) ;
2013-07-21 11:31:46 +00:00
rightColumn - > Add ( rightColumnItems ) ;
2013-10-28 15:04:53 +00:00
rightColumnItems - > SetSpacing ( 0.0f ) ;
2013-11-24 08:08:05 +00:00
if ( getUMDReplacePermit ( ) ) {
2013-11-24 03:02:36 +00:00
rightColumnItems - > Add ( new Choice ( i - > T ( " Switch UMD " ) ) ) - > OnClick . Handle ( this , & GamePauseScreen : : OnSwitchUMD ) ;
}
2013-10-27 09:04:38 +00:00
rightColumnItems - > Add ( new Choice ( i - > T ( " Continue " ) ) ) - > OnClick . Handle < UIScreen > ( this , & UIScreen : : OnBack ) ;
2013-08-11 15:25:50 +00:00
rightColumnItems - > Add ( new Choice ( i - > T ( " Game Settings " ) ) ) - > OnClick . Handle ( this , & GamePauseScreen : : OnGameSettings ) ;
2013-08-23 00:46:30 +00:00
if ( g_Config . bEnableCheats ) {
rightColumnItems - > Add ( new Choice ( i - > T ( " Cheats " ) ) ) - > OnClick . Handle ( this , & GamePauseScreen : : OnCwCheat ) ;
}
2013-08-11 15:25:50 +00:00
rightColumnItems - > Add ( new Choice ( i - > T ( " Exit to menu " ) ) ) - > OnClick . Handle ( this , & GamePauseScreen : : OnExitToMenu ) ;
2013-08-20 16:12:16 +00:00
UI : : EventParams e ;
e . a = g_Config . iCurrentStateSlot ;
saveSlots_ - > OnChoice . Trigger ( e ) ;
2013-07-21 11:31:46 +00:00
}
UI : : EventReturn GamePauseScreen : : OnGameSettings ( UI : : EventParams & e ) {
2013-10-28 15:04:53 +00:00
screenManager ( ) - > push ( new GameSettingsScreen ( gamePath_ ) ) ;
2013-07-21 11:31:46 +00:00
return UI : : EVENT_DONE ;
}
2013-08-20 16:12:16 +00:00
UI : : EventReturn GamePauseScreen : : OnStateSelected ( UI : : EventParams & e ) {
int st = e . a ;
loadStateButton_ - > SetEnabled ( SaveState : : HasSaveInSlot ( st ) ) ;
return UI : : EVENT_DONE ;
}
2013-10-27 09:04:38 +00:00
void GamePauseScreen : : onFinish ( DialogResult result ) {
// Do we really always need to "gpu->Resized" here?
if ( gpu )
gpu - > Resized ( ) ;
2013-07-21 11:31:46 +00:00
}
UI : : EventReturn GamePauseScreen : : OnExitToMenu ( UI : : EventParams & e ) {
2013-07-30 19:38:41 +00:00
screenManager ( ) - > finishDialog ( this , DR_OK ) ;
2013-07-21 11:31:46 +00:00
return UI : : EVENT_DONE ;
}
UI : : EventReturn GamePauseScreen : : OnLoadState ( UI : : EventParams & e ) {
SaveState : : LoadSlot ( saveSlots_ - > GetSelection ( ) , 0 , 0 ) ;
screenManager ( ) - > finishDialog ( this , DR_CANCEL ) ;
return UI : : EVENT_DONE ;
}
UI : : EventReturn GamePauseScreen : : OnSaveState ( UI : : EventParams & e ) {
SaveState : : SaveSlot ( saveSlots_ - > GetSelection ( ) , 0 , 0 ) ;
screenManager ( ) - > finishDialog ( this , DR_CANCEL ) ;
return UI : : EVENT_DONE ;
}
2013-11-03 01:33:23 +00:00
UI : : EventReturn GamePauseScreen : : OnRewind ( UI : : EventParams & e ) {
SaveState : : Rewind ( 0 , 0 ) ;
screenManager ( ) - > finishDialog ( this , DR_CANCEL ) ;
return UI : : EVENT_DONE ;
}
2013-08-24 03:28:21 +00:00
UI : : EventReturn GamePauseScreen : : OnCwCheat ( UI : : EventParams & e ) {
screenManager ( ) - > push ( new CwCheatScreen ( ) ) ;
return UI : : EVENT_DONE ;
}
2013-09-04 02:06:05 +00:00
2013-11-24 03:02:36 +00:00
UI : : EventReturn GamePauseScreen : : OnSwitchUMD ( UI : : EventParams & e ) {
screenManager ( ) - > push ( new UmdReplaceScreen ( ) ) ;
return UI : : EVENT_DONE ;
}
2013-09-04 02:06:05 +00:00
void GamePauseScreen : : sendMessage ( const char * message , const char * value ) {
2013-10-21 20:52:44 +00:00
// Since the language message isn't allowed to be in native, we have to have add this
// to every screen which directly inherits from UIScreen(which are few right now, luckily).
2013-11-02 20:33:27 +00:00
if ( ! strcmp ( message , " language " ) ) {
screenManager ( ) - > RecreateAllViews ( ) ;
2013-09-04 02:06:05 +00:00
}
}
2013-11-24 03:02:36 +00:00
void UmdReplaceScreen : : CreateViews ( ) {
2013-11-24 04:14:44 +00:00
Margins actionMenuMargins ( 0 , 100 , 15 , 0 ) ;
2013-11-24 03:02:36 +00:00
I18NCategory * m = GetI18NCategory ( " MainMenu " ) ;
2013-11-26 21:57:14 +00:00
I18NCategory * d = GetI18NCategory ( " Dialog " ) ;
2013-11-24 03:02:36 +00:00
2013-11-24 04:14:44 +00:00
TabHolder * leftColumn = new TabHolder ( ORIENT_HORIZONTAL , 64 , new LinearLayoutParams ( 1.0 ) ) ;
2013-11-24 03:02:36 +00:00
leftColumn - > SetClip ( true ) ;
2013-11-24 04:14:44 +00:00
ViewGroup * rightColumn = new ScrollView ( ORIENT_VERTICAL , new LinearLayoutParams ( 270 , FILL_PARENT , actionMenuMargins ) ) ;
LinearLayout * rightColumnItems = new LinearLayout ( ORIENT_VERTICAL , new LinearLayoutParams ( FILL_PARENT , WRAP_CONTENT ) ) ;
rightColumnItems - > SetSpacing ( 0.0f ) ;
rightColumn - > Add ( rightColumnItems ) ;
2013-11-24 03:02:36 +00:00
ScrollView * scrollRecentGames = new ScrollView ( ORIENT_VERTICAL , new LinearLayoutParams ( FILL_PARENT , WRAP_CONTENT ) ) ;
ScrollView * scrollAllGames = new ScrollView ( ORIENT_VERTICAL , new LinearLayoutParams ( FILL_PARENT , WRAP_CONTENT ) ) ;
GameBrowser * tabRecentGames = new GameBrowser (
2013-11-29 12:02:08 +00:00
" !RECENT " , false , & g_Config . bGridView1 , " " , " " , 0 ,
2013-11-24 03:02:36 +00:00
new LinearLayoutParams ( FILL_PARENT , FILL_PARENT ) ) ;
2013-11-29 12:02:08 +00:00
GameBrowser * tabAllGames = new GameBrowser ( g_Config . currentDirectory , true , & g_Config . bGridView2 ,
m - > T ( " How to get games " ) , " http://www.ppsspp.org/getgames.html " , 0 ,
2013-11-24 03:02:36 +00:00
new LinearLayoutParams ( FILL_PARENT , FILL_PARENT ) ) ;
scrollRecentGames - > Add ( tabRecentGames ) ;
scrollAllGames - > Add ( tabAllGames ) ;
leftColumn - > AddTab ( m - > T ( " Recent " ) , scrollRecentGames ) ;
leftColumn - > AddTab ( m - > T ( " Games " ) , scrollAllGames ) ;
tabRecentGames - > OnChoice . Handle ( this , & UmdReplaceScreen : : OnGameSelectedInstant ) ;
tabAllGames - > OnChoice . Handle ( this , & UmdReplaceScreen : : OnGameSelectedInstant ) ;
tabRecentGames - > OnHoldChoice . Handle ( this , & UmdReplaceScreen : : OnGameSelected ) ;
tabAllGames - > OnHoldChoice . Handle ( this , & UmdReplaceScreen : : OnGameSelected ) ;
2013-11-26 21:57:14 +00:00
rightColumnItems - > Add ( new Choice ( d - > T ( " Cancel " ) ) ) - > OnClick . Handle ( this , & UmdReplaceScreen : : OnCancel ) ;
2013-11-24 04:14:44 +00:00
rightColumnItems - > Add ( new Choice ( m - > T ( " Game Settings " ) ) ) - > OnClick . Handle ( this , & UmdReplaceScreen : : OnGameSettings ) ;
2013-11-24 03:02:36 +00:00
if ( g_Config . recentIsos . size ( ) > 0 ) {
leftColumn - > SetCurrentTab ( 0 ) ;
} else {
leftColumn - > SetCurrentTab ( 1 ) ;
}
root_ = new LinearLayout ( ORIENT_HORIZONTAL ) ;
2013-11-29 12:02:08 +00:00
root_ - > Add ( leftColumn ) ;
root_ - > Add ( rightColumn ) ;
2013-11-24 03:02:36 +00:00
}
void UmdReplaceScreen : : update ( InputState & input ) {
UpdateUIState ( UISTATE_PAUSEMENU ) ;
UIScreen : : update ( input ) ;
}
UI : : EventReturn UmdReplaceScreen : : OnGameSelected ( UI : : EventParams & e ) {
__UmdReplace ( e . s ) ;
screenManager ( ) - > finishDialog ( this , DR_OK ) ;
return UI : : EVENT_DONE ;
}
2013-11-24 04:14:44 +00:00
UI : : EventReturn UmdReplaceScreen : : OnCancel ( UI : : EventParams & e ) {
screenManager ( ) - > finishDialog ( this , DR_CANCEL ) ;
return UI : : EVENT_DONE ;
}
UI : : EventReturn UmdReplaceScreen : : OnGameSettings ( UI : : EventParams & e ) {
screenManager ( ) - > push ( new GameSettingsScreen ( " " ) ) ;
return UI : : EVENT_DONE ;
}
2013-11-24 03:02:36 +00:00
UI : : EventReturn UmdReplaceScreen : : OnGameSelectedInstant ( UI : : EventParams & e ) {
__UmdReplace ( e . s ) ;
screenManager ( ) - > finishDialog ( this , DR_OK ) ;
return UI : : EVENT_DONE ;
}