[Scummvm-cvs-logs] SF.net SVN: scummvm:[48700] tools/trunk

criezy at users.sourceforge.net criezy at users.sourceforge.net
Sun Apr 18 20:05:51 CEST 2010


Revision: 48700
          http://scummvm.svn.sourceforge.net/scummvm/?rev=48700&view=rev
Author:   criezy
Date:     2010-04-18 18:05:51 +0000 (Sun, 18 Apr 2010)

Log Message:
-----------
Fix bug #2984217: TOOLS: The media directory is not installed

Adds a datadir option to configure (default to $prefix/share) and make install now copies the files from gui/media/ into $5DESTDIR)$(DATADIR)/scummvm-tools/
Also changes the way the GUI loads the picture files so that it has more chances to succeed (e.g. should now work without the need to install or when wxStandardPaths::GetResourcesDir() fails).

Modified Paths:
--------------
    tools/trunk/Makefile.common
    tools/trunk/configure
    tools/trunk/gui/main.cpp
    tools/trunk/gui/main.h

Modified: tools/trunk/Makefile.common
===================================================================
--- tools/trunk/Makefile.common	2010-04-18 12:09:22 UTC (rev 48699)
+++ tools/trunk/Makefile.common	2010-04-18 18:05:51 UTC (rev 48700)
@@ -87,6 +87,8 @@
 
 install: $(TARGETS)
 	for i in $^ ; do $(INSTALL) -p -m 0755 $$i $(DESTDIR)$(BINDIR) ; done
+	$(INSTALL) -m 0755 -d $(DESTDIR)$(DATADIR)/scummvm-tools
+	$(INSTALL) -p -m 0644 $(srcdir)/gui/media/*.* $(DESTDIR)$(DATADIR)/scummvm-tools
 
 bundle_name = ScummVM\ Tools.app
 bundle: scummvm-tools$(EXEEXT)

Modified: tools/trunk/configure
===================================================================
--- tools/trunk/configure	2010-04-18 12:09:22 UTC (rev 48699)
+++ tools/trunk/configure	2010-04-18 18:05:51 UTC (rev 48700)
@@ -264,6 +264,7 @@
 Installation directories:
   --prefix=DIR           use this prefix for installing the ScummVM Tools [/usr/local]
   --bindir=DIR           directory to install the tool binaries in [PREFIX/bin]
+  --datadir=DIR          directory to install the GUI tool media files in [PREFIX/share]
   --mandir=DIR           directory to install the manpage in [PREFIX/share/man]
   --libdir=DIR           directory to install the plugins in [PREFIX/lib]
 
@@ -397,6 +398,9 @@
 	--bindir=*)
 		_bindir=`echo $ac_option | cut -d '=' -f 2`
 		;;
+	--datadir=*)
+		_datadir=`echo $ac_option | cut -d '=' -f 2`
+		;;
 	--mandir=*)
 		_mandir=`echo $ac_option | cut -d '=' -f 2`
 		;;
@@ -1117,9 +1121,11 @@
 # Figure out installation directories
 #
 test -z "$_bindir" && _bindir="$_prefix/bin"
+test -z "$_datadir" && _datadir="$_prefix/share"
 test -z "$_mandir" && _mandir="$_prefix/share/man"
 test -z "$_libdir" && _libdir="$_prefix/lib"
 
+_def_media_path='#define APP_MEDIA_PATH "'$_datadir'"'
 
 #
 # Do CXXFLAGS now we know the compiler version
@@ -1167,6 +1173,9 @@
 
 $_config_h_data
 
+/* paths */
+$_def_media_path
+
 /* Data types */
 typedef unsigned $type_1_byte byte;
 typedef unsigned int uint;
@@ -1212,6 +1221,7 @@
 
 PREFIX := $_prefix
 BINDIR := $_bindir
+DATADIR := $_datadir
 MANDIR := $_mandir
 LIBDIR := $_libdir
 

Modified: tools/trunk/gui/main.cpp
===================================================================
--- tools/trunk/gui/main.cpp	2010-04-18 12:09:22 UTC (rev 48699)
+++ tools/trunk/gui/main.cpp	2010-04-18 18:05:51 UTC (rev 48700)
@@ -36,6 +36,9 @@
 #include <wx/hyperlink.h>
 #include <wx/notebook.h>
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
 #include "gui/main.h"
 #include "gui/pages.h"
 #include "gui/gui_tools.h"
@@ -525,15 +528,8 @@
 		wxImage::AddHandler(new wxGIFHandler);
 
 	// Load image files
-#ifdef __WXMSW__
-	// Windows likes subfolders for media files
-	_logo.LoadFile(wxT("media/") + logo, wxBITMAP_TYPE_JPEG);
-	_tile.LoadFile(wxT("media/") + tile, wxBITMAP_TYPE_GIF);
-#else
-	// On other platforms, files are more scattered, and we use the standard resource dir
-	_logo.LoadFile(wxStandardPaths::Get().GetResourcesDir() + wxT("/") + logo, wxBITMAP_TYPE_JPEG);
-	_tile.LoadFile(wxStandardPaths::Get().GetResourcesDir() + wxT("/") + tile, wxBITMAP_TYPE_GIF);
-#endif
+	_logo = loadBitmapFile(logo, wxBITMAP_TYPE_JPEG);
+	_tile = loadBitmapFile(tile, wxBITMAP_TYPE_GIF);
 
 	// Load font
 	_font = wxFont(10, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false);
@@ -573,6 +569,27 @@
 	dc.DrawText(_title, 290, 70);
 }
 
+wxBitmap Header::loadBitmapFile(const wxString& file, wxBitmapType type) {
+	wxBitmap bitmap;
+
+	// Tries the following locations (in that order):
+	// - wxStandardPaths::GetResourcesDir()
+	// - APP_MEDIA_PATH/scummvm-tools (this one is because GetResourcesDir() is not always correct on Linux/Unix)
+	// - CURRENT_DIR/media (mainly for Windows when installed)
+	// - CURRENT_DIR/gui/media (for all platforms when not installed)
+	bitmap.LoadFile(wxStandardPaths::Get().GetResourcesDir() + wxT("/") + file, type);
+#ifdef APP_MEDIA_PATH
+	if (!bitmap.IsOk())
+		bitmap.LoadFile(wxString(wxT(APP_MEDIA_PATH)) + wxT("/scummvm-tools/") + file, type);
+#endif
+	if (!bitmap.IsOk())
+		bitmap.LoadFile(wxT("media/") + file, type);
+	if (!bitmap.IsOk())
+		bitmap.LoadFile(wxT("gui/media/") + file, type);
+
+	return bitmap;
+}
+
 AdvancedSettingsDialog::AdvancedSettingsDialog(wxWindow *parent, Configuration &defaults) :
 	wxDialog(parent, wxID_ANY, wxT("Default Settings"), wxDefaultPosition, wxDefaultSize),
 	_defaults(defaults)

Modified: tools/trunk/gui/main.h
===================================================================
--- tools/trunk/gui/main.h	2010-04-18 12:09:22 UTC (rev 48699)
+++ tools/trunk/gui/main.h	2010-04-18 18:05:51 UTC (rev 48700)
@@ -235,6 +235,8 @@
 
 	void onPaint(wxPaintEvent &evt);
 protected:
+	wxBitmap loadBitmapFile(const wxString&, wxBitmapType);
+
 	wxFont _font;
 	wxBitmap _logo;
 	wxBitmap _tile;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list