/[pcsx2_0.9.7]/trunk/pcsx2/gui/AppRes.cpp
ViewVC logotype

Contents of /trunk/pcsx2/gui/AppRes.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 280 - (show annotations) (download)
Thu Dec 23 12:02:12 2010 UTC (9 years, 2 months ago) by william
File size: 5922 byte(s)
re-commit (had local access denied errors when committing)
1 /* PCSX2 - PS2 Emulator for PCs
2 * Copyright (C) 2002-2010 PCSX2 Dev Team
3 *
4 * PCSX2 is free software: you can redistribute it and/or modify it under the terms
5 * of the GNU Lesser General Public License as published by the Free Software Found-
6 * ation, either version 3 of the License, or (at your option) any later version.
7 *
8 * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10 * PURPOSE. See the GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License along with PCSX2.
13 * If not, see <http://www.gnu.org/licenses/>.
14 */
15
16 #include "PrecompiledHeader.h"
17 #include "MainFrame.h"
18 #include "AppGameDatabase.h"
19
20 #include <wx/zipstrm.h>
21 #include <wx/wfstream.h>
22 #include <wx/imaglist.h>
23
24 #include "Resources/EmbeddedImage.h"
25 #include "Resources/BackgroundLogo.h"
26
27 #include "Resources/ConfigIcon_Cpu.h"
28 #include "Resources/ConfigIcon_Video.h"
29 #include "Resources/ConfigIcon_Speedhacks.h"
30 #include "Resources/ConfigIcon_Gamefixes.h"
31 #include "Resources/ConfigIcon_Paths.h"
32 #include "Resources/ConfigIcon_Plugins.h"
33 #include "Resources/ConfigIcon_MemoryCard.h"
34 #include "Resources/ConfigIcon_Appearance.h"
35
36 #include "Resources/AppIcon16.h"
37 #include "Resources/AppIcon32.h"
38 #include "Resources/AppIcon64.h"
39
40 const wxImage& LoadImageAny(
41 wxImage& dest, bool useTheme, wxFileName& base, const wxChar* filename, IEmbeddedImage& onFail )
42 {
43 if( useTheme )
44 {
45 base.SetName( filename );
46
47 base.SetExt( L"png" );
48 if( base.FileExists() )
49 {
50 if( dest.LoadFile( base.GetFullPath() ) ) return dest;
51 }
52
53 base.SetExt( L"jpg" );
54 if( base.FileExists() )
55 {
56 if( dest.LoadFile( base.GetFullPath() ) ) return dest;
57 }
58
59 base.SetExt( L"bmp" );
60 if( base.FileExists() )
61 {
62 if( dest.LoadFile( base.GetFullPath() ) ) return dest;
63 }
64 }
65
66 return dest = onFail.Get();
67 }
68
69 RecentIsoList::RecentIsoList()
70 {
71 Menu = new wxMenu();
72 Menu->Append( MenuId_IsoBrowse, _("Browse..."), _("Browse for an Iso that is not in your recent history.") );
73 Manager = new RecentIsoManager( Menu );
74 }
75
76 pxAppResources::pxAppResources()
77 {
78 }
79
80 pxAppResources::~pxAppResources() throw() {}
81
82 wxMenu& Pcsx2App::GetRecentIsoMenu()
83 {
84 if (!m_RecentIsoList) m_RecentIsoList = new RecentIsoList();
85 return *m_RecentIsoList->Menu;
86 }
87
88 RecentIsoManager& Pcsx2App::GetRecentIsoManager()
89 {
90 if (!m_RecentIsoList) m_RecentIsoList = new RecentIsoList();
91 return *m_RecentIsoList->Manager;
92 }
93
94 pxAppResources& Pcsx2App::GetResourceCache()
95 {
96 ScopedLock lock( m_mtx_Resources );
97 if( !m_Resources )
98 m_Resources = new pxAppResources();
99
100 return *m_Resources;
101 }
102
103 const wxIconBundle& Pcsx2App::GetIconBundle()
104 {
105 ScopedPtr<wxIconBundle>& bundle( GetResourceCache().IconBundle );
106 if( !bundle )
107 {
108 bundle = new wxIconBundle();
109 bundle->AddIcon( EmbeddedImage<res_AppIcon32>().GetIcon() );
110 bundle->AddIcon( EmbeddedImage<res_AppIcon64>().GetIcon() );
111 bundle->AddIcon( EmbeddedImage<res_AppIcon16>().GetIcon() );
112 }
113
114 return *bundle;
115 }
116
117 const wxBitmap& Pcsx2App::GetLogoBitmap()
118 {
119 ScopedPtr<wxBitmap>& logo( GetResourceCache().Bitmap_Logo );
120 if( logo ) return *logo;
121
122 wxFileName mess;
123 bool useTheme = (g_Conf->DeskTheme != L"default");
124
125 if( useTheme )
126 {
127 wxDirName theme( PathDefs::GetThemes() + g_Conf->DeskTheme );
128 wxFileName zipped( theme.GetFilename() );
129
130 zipped.SetExt( L"zip" );
131 if( zipped.FileExists() )
132 {
133 // loading theme from zipfile.
134 //wxFileInputStream stream( zipped.ToString() )
135 //wxZipInputStream zstream( stream );
136
137 Console.Error( "Loading themes from zipfile is not supported yet.\nFalling back on default theme." );
138 }
139
140 // Overrides zipfile settings (fix when zipfile support added)
141 mess = theme.ToString();
142 }
143
144 wxImage img;
145 EmbeddedImage<res_BackgroundLogo> temp; // because gcc can't allow non-const temporaries.
146 LoadImageAny( img, useTheme, mess, L"BackgroundLogo", temp );
147 logo = new wxBitmap( img );
148
149 return *logo;
150 }
151
152 wxImageList& Pcsx2App::GetImgList_Config()
153 {
154 ScopedPtr<wxImageList>& images( GetResourceCache().ConfigImages );
155 if( !images )
156 {
157 images = new wxImageList(32, 32);
158 wxFileName mess;
159 bool useTheme = (g_Conf->DeskTheme != L"default");
160
161 if( useTheme )
162 {
163 wxDirName theme( PathDefs::GetThemes() + g_Conf->DeskTheme );
164 mess = theme.ToString();
165 }
166
167 wxImage img;
168
169 // GCC Specific: wxT() macro is required when using string token pasting. For some
170 // reason L generates syntax errors. >_<
171
172 #undef FancyLoadMacro
173 #define FancyLoadMacro( name ) \
174 { \
175 EmbeddedImage<res_ConfigIcon_##name> temp( g_Conf->Listbook_ImageSize, g_Conf->Listbook_ImageSize ); \
176 m_Resources->ImageId.Config.name = images->Add( LoadImageAny( \
177 img, useTheme, mess, L"ConfigIcon_" wxT(#name), temp ) \
178 ); \
179 }
180
181 FancyLoadMacro( Paths );
182 FancyLoadMacro( Plugins );
183 FancyLoadMacro( Gamefixes );
184 FancyLoadMacro( Speedhacks );
185 FancyLoadMacro( MemoryCard );
186 FancyLoadMacro( Video );
187 FancyLoadMacro( Cpu );
188 FancyLoadMacro( Appearance );
189 }
190 return *images;
191 }
192
193 wxImageList& Pcsx2App::GetImgList_Toolbars()
194 {
195 ScopedPtr<wxImageList>& images( GetResourceCache().ToolbarImages );
196
197 if( !images )
198 {
199 const int imgSize = g_Conf->Toolbar_ImageSize ? 64 : 32;
200 images = new wxImageList( imgSize, imgSize );
201 wxFileName mess;
202 bool useTheme = (g_Conf->DeskTheme != L"default");
203
204 if( useTheme )
205 {
206 wxDirName theme( PathDefs::GetThemes() + g_Conf->DeskTheme );
207 mess = theme.ToString();
208 }
209
210 wxImage img;
211 #undef FancyLoadMacro
212 #define FancyLoadMacro( name ) \
213 { \
214 EmbeddedImage<res_ToolbarIcon_##name> temp( imgSize, imgSize ); \
215 m_Resources.ImageId.Toolbars.name = images->Add( LoadImageAny( img, useTheme, mess, L"ToolbarIcon" wxT(#name), temp ) ); \
216 }
217
218 }
219 return *images;
220 }
221
222 const AppImageIds& Pcsx2App::GetImgId() const
223 {
224 return m_Resources->ImageId;
225 }

  ViewVC Help
Powered by ViewVC 1.1.22