///////////////////////////////////////////////////////////////////////////// // Name: prefmacros.cpp // tag: This is for those that are actually functions... // Author: David Roundy // Modified by: // Copyright: (c) 2002 David Roundy // Licence: GPL /* 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; either version 2 of the License, or (at your option) any later version. 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 for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ ///////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes . #include #ifndef WX_PRECOMP #include #include #include #include #endif #include "debug.h" #include "prefmacros.h" #include "playerdata.h" #include "ftpfilecache.h" #if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) #include "unknown.xpm" #include "robot.xpm" #endif wxBitmap GetPlayerBitmap(const wxString &playername) { wxString filename = aBridgePlayerData::GetPlayerPic(playername); wxImage my_image; if (!filename.IsSameAs("unknown")) { DebugMsg("Well, there is a filename... " + filename); if (wxFileExists(filename)) { NoDebugMsg("... and there is a file..."); if (my_image.LoadFile(filename)) { DebugMsg("Found image file " + filename); my_image.Rescale(64,64); return my_image.ConvertToBitmap(); } else { DebugMsg("Deleting bad image file"); wxRemoveFile(filename); } } } if (filename.IsSameAs("robot.png")) { #ifdef __WXMSW__ return wxBitmap("Robot", wxBITMAP_TYPE_BMP_RESOURCE); #else return wxBitmap(robot_xpm); #endif } DebugMsg("Playerpic "+filename+" unknown"); #ifdef __WXMSW__ return wxBitmap("Unknown", wxBITMAP_TYPE_BMP_RESOURCE); #else return wxBitmap(unknown_xpm); #endif } wxString GetPlayerBlurb(const wxString &playername) { return aBridgePlayerData::GetPlayerInfo(playername); } wxString SetPlayerPic(const wxString &file) { wxConfig::Get()->Write("/Player/Picture", file); return UploadPlayerPic(); } ftpFileCache GetCache() { return ftpFileCache(GetCacheDir(), "ftp.abridgegame.org", "abridge", "abridge"); } wxString UploadPlayerPic() { wxString m_player_pic_md5 = GetCache().PutFile(GetPlayerPic()); aBridgePlayerData::SetPlayerPic(player_name(), m_player_pic_md5); return m_player_pic_md5; }