wx 2.8 compat fixes, centos support, cmake fixes

Add support for RHEL/centos to installdeps. There is no SFML package.

Add some string compatibility stuff so that everything builds on wx 2.8
unicode builds.

TODO: add travis slaves for 2.8, with and without unicode

Disable the game frame spacer code on 2.8 because it does not work (the
frame does not expand.)

cmake improvements:

- set ENABLE_LTO=OFF for Debug builds by default

- set ENABLE_LINK=OFF if SFML cannot be found and continue

- use better logic for finding wx utilities wx-config and wxrc

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Closes #395
Closes #297
This commit is contained in:
Rafael Kitover 2019-03-28 21:45:06 +00:00
parent b69fced749
commit 2097b5aaa5
No known key found for this signature in database
GPG Key ID: 08AB596679D86240
13 changed files with 413 additions and 155 deletions

View File

@ -116,8 +116,9 @@ option(ENABLE_FFMPEG "Enable ffmpeg A/V recording" ${FFMPEG_DEFAULT})
set(LTO_DEFAULT ON) set(LTO_DEFAULT ON)
if(WIN32 AND CMAKE_COMPILER_IS_GNUCXX AND AMD64) # lto produces buggy binaries for 64 bit win32
# lto produces buggy binaries for 64 bit win32 # and we generally don't want it when debugging because it makes linking slow
if((WIN32 AND CMAKE_COMPILER_IS_GNUCXX AND AMD64) OR CMAKE_BUILD_TYPE MATCHES Debug)
set(LTO_DEFAULT OFF) set(LTO_DEFAULT OFF)
endif() endif()
@ -168,7 +169,7 @@ endif()
include_directories(${CMAKE_BINARY_DIR}) include_directories(${CMAKE_BINARY_DIR})
configure_file("${CMAKE_SOURCE_DIR}/src/version.h.in" "${CMAKE_BINARY_DIR}/version.h" @ONLY) configure_file("${CMAKE_SOURCE_DIR}/src/version.h.in" "${CMAKE_BINARY_DIR}/version.h" @ONLY)
if(CMAKE_BUILD_TYPE STREQUAL "Debug") if(CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(-DDEBUG) add_definitions(-DDEBUG)
else() else()
add_definitions(-DNDEBUG) add_definitions(-DNDEBUG)
@ -196,7 +197,11 @@ endif()
# Look for some dependencies using CMake scripts # Look for some dependencies using CMake scripts
find_package(ZLIB REQUIRED) find_package(ZLIB REQUIRED)
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
find_package(PNG REQUIRED) find_package(PNG REQUIRED)
if(EXISTS /etc/redhat-release) if(EXISTS /etc/redhat-release)
@ -220,7 +225,13 @@ if(ENABLE_LINK)
if(WIN32 AND ((NOT (MINGW AND MSYS)) OR CMAKE_TOOLCHAIN_FILE MATCHES mxe) AND NOT CMAKE_TOOLCHAIN_FILE MATCHES vcpkg) if(WIN32 AND ((NOT (MINGW AND MSYS)) OR CMAKE_TOOLCHAIN_FILE MATCHES mxe) AND NOT CMAKE_TOOLCHAIN_FILE MATCHES vcpkg)
set(SFML_STATIC_LIBRARIES TRUE) set(SFML_STATIC_LIBRARIES TRUE)
endif() endif()
find_package(SFML 2 COMPONENTS network system REQUIRED)
find_package(SFML 2 COMPONENTS network system)
if(NOT SFML_FOUND)
message(WARNING "SFML not found, LINK will be disabled")
set(ENABLE_LINK NO)
endif()
endif() endif()
# set the standard libraries all ports use # set the standard libraries all ports use
@ -479,7 +490,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
set(MY_C_FLAGS ${MY_C_FLAGS} -static-libgcc -static-libstdc++) set(MY_C_FLAGS ${MY_C_FLAGS} -static-libgcc -static-libstdc++)
endif() endif()
if(CMAKE_BUILD_TYPE STREQUAL Debug) if(CMAKE_BUILD_TYPE MATCHES Debug)
set(MY_C_FLAGS ${MY_C_FLAGS} ${MY_C_DBG_FLAGS} -Wall -Wextra) set(MY_C_FLAGS ${MY_C_FLAGS} ${MY_C_DBG_FLAGS} -Wall -Wextra)
else() else()
set(MY_C_FLAGS ${MY_C_FLAGS} ${MY_C_OPT_FLAGS} -Wno-error) set(MY_C_FLAGS ${MY_C_FLAGS} ${MY_C_OPT_FLAGS} -Wno-error)

View File

@ -60,8 +60,8 @@ cmake ..
make -j`nproc` make -j`nproc`
``` ```
`./installdeps` is supported on MSys2, Linux (Debian/Ubuntu, Fedora, Arch or `./installdeps` is supported on MSys2, Linux (Debian/Ubuntu, Fedora, Arch,
Solus) and Mac OS X (homebrew, macports or fink.) Solus and RHEL/CentOS) and Mac OS X (homebrew, macports or fink.)
The Ninja cmake generator is also now supported, including on msys2 and Visual Studio. The Ninja cmake generator is also now supported, including on msys2 and Visual Studio.

View File

@ -155,6 +155,8 @@ linux_installdeps() {
debian_installdeps debian_installdeps
elif [ -f /etc/fedora-release ]; then elif [ -f /etc/fedora-release ]; then
fedora_installdeps fedora_installdeps
elif [ -f /etc/redhat-release ] || [ -f /etc/centos-release ]; then
rhel_installdeps
elif [ -f /etc/arch-release ]; then elif [ -f /etc/arch-release ]; then
archlinux_installdeps archlinux_installdeps
elif [ -f /etc/solus-release ]; then elif [ -f /etc/solus-release ]; then
@ -407,7 +409,7 @@ fedora_installdeps() {
fi fi
# non-multiarch packages first # non-multiarch packages first
check sudo dnf -y --nogpgcheck --best --allowerasing install gcc gcc-c++ make cmake ccache git nasm redhat-rpm-config pkgconfig ccache check sudo dnf -y --nogpgcheck --best --allowerasing install gcc gcc-c++ make cmake ccache git nasm redhat-rpm-config pkgconfig ccache ninja-build
# try to install multiarch libgcc, glibc-devel and pkgconfig if available # try to install multiarch libgcc, glibc-devel and pkgconfig if available
if [ -n "$amd64" ]; then if [ -n "$amd64" ]; then
@ -427,7 +429,7 @@ fedora_installdeps() {
# this is sometimes necessary for rawhide # this is sometimes necessary for rawhide
set -- --exclude='glibc32*' set -- --exclude='glibc32*'
fi fi
for pkg in zlib-devel mesa-libGL-devel ffmpeg-devel gettext-devel libpng-devel SDL2-devel SFML-devel openal-soft-devel wxGTK3-devel gtk2-devel gtk3-devel; do for pkg in zlib-devel mesa-libGL-devel ffmpeg-devel gettext-devel libpng-devel SDL2-devel SFML-devel openal-soft-devel wxGTK3-devel gtk3-devel; do
case $pkg in case $pkg in
*ffmpeg*) *ffmpeg*)
[ -n "$no_ffmpeg" ] && continue [ -n "$no_ffmpeg" ] && continue
@ -535,6 +537,190 @@ fedora_installdeps() {
build_instructions build_instructions
} }
rhel_installdeps() {
rhel=1
ffmpeg=ffmpeg-devel
no_ffmpeg=
rpms_installed=
check_cross
installing
warning=
rhel_release=$(rpm -E %rhel)
tries=3
curdir=$(pwd)
# this source is necessary for mingw packages on rhel, and may be for other things in the future
check sudo yum -y install epel-release
# make sure rpmfusion is installed for ffmpeg
while [ $tries -gt 0 ]; do
mkdir -p "${tmp}/fusion"
cd "${tmp}/fusion"
if ! curl -fLO https://download1.rpmfusion.org/free/el/rpmfusion-free-release-${rhel_release}.noarch.rpm; then
rhel_release=$((rhel_release - 1))
tries=$((tries - 1))
continue
fi
if ! curl -fLO https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-${rhel_release}.noarch.rpm; then
tries=0
break
fi
# check if already installed
if rpm -q rpmfusion-free-release-${rhel_release} >/dev/null 2>&1 && rpm -q rpmfusion-nonfree-release-${rhel_release} >/dev/null 2>&1; then
info_msg 'rpmfusion already installed, good'
break
fi
# otherwise try to install
if ! sudo rpm --nodeps -Uvh ./rpmfusion-*.rpm; then
tries=0
break
fi
break
done
cd "$curdir"
if [ $tries -eq 0 ]; then
warning 'installing rpmfusion repos failed, continuing without ffmpeg'
no_ffmpeg=1
cmake_flags="$cmake_flags -DENABLE_FFMPEG=NO"
fi
# non-multiarch packages first
CMAKE=cmake3
check sudo yum -y install gcc gcc-c++ make cmake3 ccache git nasm redhat-rpm-config pkgconfig ccache ninja-build
# try to install multiarch libgcc, glibc-devel and pkgconfig if available
if [ -n "$amd64" ]; then
for pkg in pkgconfig libgcc glibc-devel; do
if [ "$target" = m32 ]; then
sudo yum -y install "$pkg".i686
else
sudo yum -y install "$pkg".x86_64
fi
done
fi
set --
if [ -z "$target" -o "$target" = m32 ]; then
# try to install both 64 bit and 32 bit versions on 64 bit hosts (see below)
if [ -n "$amd64" ]; then
# this is sometimes necessary for rawhide
set -- --exclude='glibc32*'
fi
warning='RHEL does not currently have SFML packages, LINK support will be disabled'
cmake_flags="$cmake_flags -DENABLE_LINK=NO"
for pkg in zlib-devel mesa-libGL-devel ffmpeg-devel gettext-devel libpng-devel SDL2-devel openal-soft-devel wxGTK3-devel gtk3-devel wxGTK-devel; do
case $pkg in
*ffmpeg*)
[ -n "$no_ffmpeg" ] && continue
;;
esac
if [ -n "$amd64" ]; then
if [ "$target" = m32 ]; then
set -- "$@" "${pkg}.i686"
else
set -- "$@" "${pkg}.x86_64"
fi
else
set -- "$@" "$pkg"
fi
done
# redhat has a bug where all necessary -devel packages are not pulled in for 32 bit direct -devel deps
# this hack adds them to the list
if [ -n "$amd64" -a "$target" = m32 ]; then
info_msg 'Calculating dependencies, this will take a while..'
curdeps=
newdeps=$@
while [ "$curdeps" != "$newdeps" ]; do
curdeps=$newdeps
set -- $(echo "$@" $(repoquery --deplist "$@" 2>/dev/null | sed -n 's/\.x86_64$/.i686/; s/^ *provider: *\([^ ]*-devel-.*\)$/\1/p' | sort -u) | sed 's/ */\n/g' | sort -u)
newdeps=$@
printf '%s' .
done
echo
info_msg 'Done'
## install the RPMs with rpm --force get around file conflicts
host_rpms=$(echo "$@" | sed 's/\.i686//g')
# first update the host arch versions to reduce chances of conflicts
check sudo yum -y install $host_rpms
oldcwd=$PWD
mkdir "$tmp/rpms"
cd "$tmp/rpms"
check sudo yum -y download "$@"
# first try installing with yum to pull in deps
check sudo yum -y --skip-broken install *.rpm
# follow up with rpm --force to ignore conflicts
check sudo rpm -Uvh --force *.rpm
rm -f *.rpm
# reinstall the host rpms to make sure any overwritten files are the host version
check sudo yum -y download $host_rpms
check sudo yum -y --skip-broken install *.rpm
check sudo rpm -Uvh --force *.rpm
cd "$oldcwd"
rm -rf "$tmp/rpms"
ffmpeg=ffmpeg-devel.i686
rpms_installed=1
fi
else # mingw build
set -- "$@" pkgconfig
case "$target" in
mingw-w64-i686)
target=mingw32
cmake_flags="$cmake_flags -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-cross-MinGW-w64-i686.cmake -DENABLE_LINK=NO"
;;
mingw-w64-x86_64)
target=mingw64
cmake_flags="$cmake_flags -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-cross-MinGW-w64-x86_64.cmake -DENABLE_LINK=NO"
;;
*)
error 'unknown cross target (this should not happen)'
;;
esac
# install static deps
for pkg in zlib gettext libpng SDL2 wxWidgets; do
set -- "$@" "${target}-${pkg}-static"
done
# install deps that are not available as static
for pkg in openal-soft; do
set -- "$@" "${target}-${pkg}"
done
warning='SFML is required for LINK support, RHEL/EPEL does not currently have a MinGW SFML package, if you want LINK support you will need to install it manually'
fi
[ -z "$rpms_installed" ] && check sudo yum -y install "$@"
if ! rpm -q $ffmpeg >/dev/null 2>&1; then
warning 'ffmpeg failed to install (probably due to conflicts)'
cmake_flags="$cmake_flags -DENABLE_FFMPEG=NO"
fi
[ -n "$warning" ] && warning "$warning"
build_instructions
}
suse_installdeps() { suse_installdeps() {
suse=1 suse=1
check_cross check_cross

View File

@ -68,7 +68,7 @@ endif()
if(WIN32 AND CMAKE_TOOLCHAIN_FILE MATCHES vcpkg AND (X86_32 OR AMD64)) if(WIN32 AND CMAKE_TOOLCHAIN_FILE MATCHES vcpkg AND (X86_32 OR AMD64))
# set up wxwidgets stuff # set up wxwidgets stuff
add_definitions(-D_UNICODE -DUNICODE -DWXUSINGDLL -DwxUSE_GUI=1 -D__WXMSW__) add_definitions(-D_UNICODE -DUNICODE -DWXUSINGDLL -DwxUSE_GUI=1 -D__WXMSW__)
if("${CMAKE_BUILD_TYPE}" MATCHES "Debug") if(CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(-D_DEBUG) add_definitions(-D_DEBUG)
include_directories(${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows/debug/lib/mswud) include_directories(${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows/debug/lib/mswud)
include_directories(${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows/include) include_directories(${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows/include)
@ -117,7 +117,7 @@ if(WIN32 AND CMAKE_TOOLCHAIN_FILE MATCHES vcpkg AND (X86_32 OR AMD64))
file(COPY ${_VCPKG_ROOT_DIR}/installed/${WINARCH}-windows/bin/SDL2.dll DESTINATION ${CMAKE_BINARY_DIR}) file(COPY ${_VCPKG_ROOT_DIR}/installed/${WINARCH}-windows/bin/SDL2.dll DESTINATION ${CMAKE_BINARY_DIR})
endif() endif()
else() else()
if(CMAKE_BUILD_TYPE STREQUAL "Debug") if(CMAKE_BUILD_TYPE MATCHES Debug)
set(wxWidgets_USE_DEBUG ON) # noop if wx is compiled with --disable-debug, like in Mac Homebrew atm set(wxWidgets_USE_DEBUG ON) # noop if wx is compiled with --disable-debug, like in Mac Homebrew atm
endif() endif()
@ -156,12 +156,42 @@ else()
set(wxWidgets_USE_UNICODE ON) set(wxWidgets_USE_UNICODE ON)
function(find_wx_util var util)
foreach(conf_suffix gtk4 gtk3 "")
foreach(major_version 4 3 2 "")
foreach(minor_version RANGE 0 101)
unset(suffix)
if(conf_suffix)
set(suffix "-${conf_suffix}")
endif()
if(major_version)
set(suffix "${suffix}-${major_version}")
endif()
if(NOT minor_version EQUAL 101)
set(suffix "${suffix}.${minor_version}")
endif()
find_program(${var} NAMES "${util}${suffix}")
if(${${var}})
return()
endif()
endforeach()
endforeach()
endforeach()
endfunction()
# Check for gtk4 then gtk3 packages first, some dists like arch rename the # Check for gtk4 then gtk3 packages first, some dists like arch rename the
# wx-config utility for these packages to e.g. wx-config-gtk3 # wx-config utility for these packages to e.g. wx-config-gtk3
# #
# Do not do the check if the WX_CONFIG env var is set. # Do not do the check if the WX_CONFIG env var is set or the cmake variable
if(NOT WIN32 AND NOT APPLE AND "$ENV{WX_CONFIG}" STREQUAL "") # is set
find_program(wxWidgets_CONFIG_EXECUTABLE NAMES wx-config-gtk4 wx-config-gtk3 wx-config) if(NOT wxWidgets_CONFIG_EXECUTABLE)
if(DEFINED ENV{WX_CONFIG})
separate_arguments(wxWidgets_CONFIG_EXECUTABLE UNIX_COMMAND $ENV{WX_CONFIG})
else()
find_wx_util(wxWidgets_CONFIG_EXECUTABLE wx-config)
endif()
endif() endif()
# adv is for wxAboutBox # adv is for wxAboutBox
@ -180,7 +210,7 @@ else()
include_directories(${wxWidgets_INCLUDE_DIRS}) include_directories(${wxWidgets_INCLUDE_DIRS})
if(CMAKE_BUILD_TYPE STREQUAL "Debug") if(CMAKE_BUILD_TYPE MATCHES Debug)
# tell wx to enable debug mode if possible, if the cmake module did not do it for us # tell wx to enable debug mode if possible, if the cmake module did not do it for us
execute_process(COMMAND "${wxWidgets_CONFIG_EXECUTABLE} --debug=yes" RESULT_VARIABLE WX_CONFIG_DEBUG OUTPUT_QUIET ERROR_QUIET) execute_process(COMMAND "${wxWidgets_CONFIG_EXECUTABLE} --debug=yes" RESULT_VARIABLE WX_CONFIG_DEBUG OUTPUT_QUIET ERROR_QUIET)
@ -257,13 +287,19 @@ int WINAPI DetourMessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uT
class MyApp : public wxAppConsole { class MyApp : public wxAppConsole {
public: public:
virtual bool OnInit(); virtual bool OnInit();
// this is necessary for 2.8 to make the class non-abstract
virtual int OnRun() { return 0; }
}; };
bool MyApp::OnInit() { bool MyApp::OnInit() {
exit(0); exit(0);
} }
#if wxCHECK_VERSION(2, 9, 0)
wxIMPLEMENT_APP_NO_MAIN(MyApp); wxIMPLEMENT_APP_NO_MAIN(MyApp);
#else
IMPLEMENT_APP_NO_MAIN(MyApp);
#endif
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
@ -518,8 +554,27 @@ include(HostCompile)
host_compile(${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c ${BIN2C}) host_compile(${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c ${BIN2C})
if(WXRC) if(WXRC)
separate_arguments(WXRC UNIX_COMMAND "${WXRC}") separate_arguments(WXRC UNIX_COMMAND ${WXRC})
else() elseif(DEFINED ENV{WXRC})
separate_arguments(WXRC UNIX_COMMAND $ENV{WXRC})
elseif(wxWidgets_CONFIG_EXECUTABLE)
execute_process(
COMMAND ${wxWidgets_CONFIG_EXECUTABLE} --utility=wxrc
OUTPUT_VARIABLE WXRC
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# check if the path from wx-config is good
if(NOT EXISTS ${WXRC})
unset(WXRC)
endif()
endif()
if(NOT WXRC)
find_wx_util(WXRC wxrc)
endif()
if(NOT WXRC)
message(WARNING "could not find your wxrc executable")
set(WXRC wxrc) set(WXRC wxrc)
endif() endif()
@ -723,7 +778,7 @@ endif()
if(CMAKE_COMPILER_IS_GNUCXX) if(CMAKE_COMPILER_IS_GNUCXX)
if(WIN32) if(WIN32)
# Build a console app in debug mode on Windows # Build a console app in debug mode on Windows
if(CMAKE_BUILD_TYPE STREQUAL Debug) if(CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -Wl,--subsystem,console") set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -Wl,--subsystem,console")
else() else()
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -Wl,--subsystem,windows") set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -Wl,--subsystem,windows")
@ -767,7 +822,7 @@ if(APPLE)
# bundle dylibs and relink them for releasing .app # bundle dylibs and relink them for releasing .app
# also install translations into the .app # also install translations into the .app
# but only in Release mode # but only in Release mode
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") if(NOT CMAKE_BUILD_TYPE MATCHES Debug)
add_custom_command( add_custom_command(
TARGET visualboyadvance-m POST_BUILD TARGET visualboyadvance-m POST_BUILD
COMMAND ${CMAKE_SOURCE_DIR}/tools/osx/third_party_libs_tool ./visualboyadvance-m.app COMMAND ${CMAKE_SOURCE_DIR}/tools/osx/third_party_libs_tool ./visualboyadvance-m.app

View File

@ -527,7 +527,7 @@ EVT_HANDLER_MASK(RomInformation, "ROM information...", CMDEN_GB | CMDEN_GBA)
} while (0) } while (0)
#define setblabs(id, b, ts) \ #define setblabs(id, b, ts) \
do { \ do { \
s.Printf(wxT("%02x (%s)"), (unsigned int)b, ts); \ s.Printf(wxT("%02x (%s)"), (unsigned int)b, ts.c_str()); \
setlab(id); \ setlab(id); \
} while (0) } while (0)
#define setlabs(id, ts, l) \ #define setlabs(id, ts, l) \
@ -865,9 +865,9 @@ EVT_HANDLER_MASK(ImportBatteryFile, "Import battery file...", CMDEN_GB | CMDEN_G
wxString msg; wxString msg;
if (panel->emusys->emuReadBattery(fn.mb_fn_str())) if (panel->emusys->emuReadBattery(fn.mb_fn_str()))
msg.Printf(_("Loaded battery %s"), fn.mb_str()); msg.Printf(_("Loaded battery %s"), fn.c_str());
else else
msg.Printf(_("Error loading battery %s"), fn.mb_str()); msg.Printf(_("Error loading battery %s"), fn.c_str());
systemScreenMessage(msg); systemScreenMessage(msg);
} }
@ -903,7 +903,7 @@ EVT_HANDLER_MASK(ImportGamesharkCodeFile, "Import GameShark code file...", CMDEN
wxFFile f(fn, wxT("rb")); wxFFile f(fn, wxT("rb"));
if (!f.IsOpened()) { if (!f.IsOpened()) {
wxLogError(_("Cannot open file %s"), fn.mb_str()); wxLogError(_("Cannot open file %s"), fn.c_str());
return; return;
} }
@ -913,7 +913,7 @@ EVT_HANDLER_MASK(ImportGamesharkCodeFile, "Import GameShark code file...", CMDEN
char buf[14]; char buf[14];
if (f.Read(&len, sizeof(len)) != sizeof(len) || wxUINT32_SWAP_ON_BE(len) != 14 || f.Read(buf, 14) != 14 || memcmp(buf, "SharkPortCODES", 14)) { if (f.Read(&len, sizeof(len)) != sizeof(len) || wxUINT32_SWAP_ON_BE(len) != 14 || f.Read(buf, 14) != 14 || memcmp(buf, "SharkPortCODES", 14)) {
wxLogError(_("Unsupported code file %s"), fn.mb_str()); wxLogError(_("Unsupported code file %s"), fn.c_str());
return; return;
} }
@ -983,9 +983,9 @@ EVT_HANDLER_MASK(ImportGamesharkCodeFile, "Import GameShark code file...", CMDEN
} }
if (res) if (res)
msg.Printf(_("Loaded code file %s"), fn.mb_str()); msg.Printf(_("Loaded code file %s"), fn.c_str());
else else
msg.Printf(_("Error loading code file %s"), fn.mb_str()); msg.Printf(_("Error loading code file %s"), fn.c_str());
systemScreenMessage(msg); systemScreenMessage(msg);
} }
@ -1031,9 +1031,9 @@ EVT_HANDLER_MASK(ImportGamesharkActionReplaySnapshot,
} }
if (res) if (res)
msg.Printf(_("Loaded snapshot file %s"), fn.mb_str()); msg.Printf(_("Loaded snapshot file %s"), fn.c_str());
else else
msg.Printf(_("Error loading snapshot file %s"), fn.mb_str()); msg.Printf(_("Error loading snapshot file %s"), fn.c_str());
systemScreenMessage(msg); systemScreenMessage(msg);
} }
@ -1056,9 +1056,9 @@ EVT_HANDLER_MASK(ExportBatteryFile, "Export battery file...", CMDEN_GB | CMDEN_G
wxString msg; wxString msg;
if (panel->emusys->emuWriteBattery(fn.mb_fn_str())) if (panel->emusys->emuWriteBattery(fn.mb_fn_str()))
msg.Printf(_("Wrote battery %s"), fn.mb_str()); msg.Printf(_("Wrote battery %s"), fn.c_str());
else else
msg.Printf(_("Error writing battery %s"), fn.mb_str()); msg.Printf(_("Error writing battery %s"), fn.c_str());
systemScreenMessage(msg); systemScreenMessage(msg);
} }
@ -1097,11 +1097,11 @@ EVT_HANDLER_MASK(ExportGamesharkSnapshot, "Export GameShark snapshot...", CMDEN_
// FIXME: this will fail on big-endian machines if file format is // FIXME: this will fail on big-endian machines if file format is
// little-endian // little-endian
// fix in GBA.cpp // fix in GBA.cpp
if (CPUWriteGSASnapshot(fn.mb_str(), tit->GetValue().mb_str(), if (CPUWriteGSASnapshot(fn.utf8_str(), tit->GetValue().utf8_str(),
dsc->GetValue().mb_str(), n->GetValue().mb_str())) dsc->GetValue().utf8_str(), n->GetValue().utf8_str()))
msg.Printf(_("Saved snapshot file %s"), fn.mb_str()); msg.Printf(_("Saved snapshot file %s"), fn.c_str());
else else
msg.Printf(_("Error saving snapshot file %s"), fn.mb_str()); msg.Printf(_("Error saving snapshot file %s"), fn.c_str());
systemScreenMessage(msg); systemScreenMessage(msg);
} }
@ -1141,7 +1141,7 @@ EVT_HANDLER_MASK(ScreenCapture, "Screen capture...", CMDEN_GB | CMDEN_GBA)
panel->emusys->emuWriteBMP(fn.mb_fn_str()); panel->emusys->emuWriteBMP(fn.mb_fn_str());
wxString msg; wxString msg;
msg.Printf(_("Wrote snapshot %s"), fn.mb_str()); msg.Printf(_("Wrote snapshot %s"), fn.c_str());
systemScreenMessage(msg); systemScreenMessage(msg);
} }
@ -1937,7 +1937,7 @@ void MainFrame::GDBBreak()
if (!debugOpenPty()) if (!debugOpenPty())
return; return;
msg.Printf(_("Waiting for connection at %s"), debugGetSlavePty().mb_str()); msg.Printf(_("Waiting for connection at %s"), debugGetSlavePty().c_str());
} else } else
#endif #endif
{ {
@ -2242,7 +2242,7 @@ EVT_HANDLER(GameBoyAdvanceConfigure, "Game Boy Advance options...")
vba_over.append(wxTextFile::GetEOL()); vba_over.append(wxTextFile::GetEOL());
fn.Mkdir(0777, wxPATH_MKDIR_FULL); fn.Mkdir(0777, wxPATH_MKDIR_FULL);
wxTempFileOutputStream fos(fn.GetFullPath()); wxTempFileOutputStream fos(fn.GetFullPath());
fos.Write(vba_over.mb_str(), vba_over.size()); fos.Write(vba_over.c_str(), vba_over.size());
fos.Commit(); fos.Commit();
} }
} }

View File

@ -17,7 +17,6 @@
#include <wx/filepicker.h> #include <wx/filepicker.h>
#include <wx/progdlg.h> #include <wx/progdlg.h>
#include <wx/spinctrl.h> #include <wx/spinctrl.h>
#include <wx/valnum.h>
#include <wx/stockitem.h> #include <wx/stockitem.h>
#include <wx/tokenzr.h> #include <wx/tokenzr.h>
#include <wx/txtstrm.h> #include <wx/txtstrm.h>
@ -88,7 +87,7 @@ public:
return; return;
if (!server) { if (!server) {
bool valid = SetLinkServerHost(gopts.link_host.mb_str()); bool valid = SetLinkServerHost(gopts.link_host.c_str());
if (!valid) { if (!valid) {
wxMessageBox(_("You must enter a valid host name"), wxMessageBox(_("You must enter a valid host name"),
@ -111,10 +110,10 @@ public:
char host[length]; char host[length];
GetLinkServerHost(host, length); GetLinkServerHost(host, length);
title.Printf(_("Waiting for clients...")); title.Printf(_("Waiting for clients..."));
connmsg.Printf(_("Server IP address is: %s\n"), wxString(host, wxConvLibc).mb_str()); connmsg.Printf(_("Server IP address is: %s\n"), wxString(host, wxConvLibc).c_str());
} else { } else {
title.Printf(_("Waiting for connection...")); title.Printf(_("Waiting for connection..."));
connmsg.Printf(_("Connecting to %s\n"), gopts.link_host.mb_str()); connmsg.Printf(_("Connecting to %s\n"), gopts.link_host.c_str());
} }
// Init link // Init link
@ -436,9 +435,9 @@ public:
if (isgb) { if (isgb) {
if (!ce_type) if (!ce_type)
gbAddGsCheat(tok.mb_str(), ce_desc.mb_str()); gbAddGsCheat(tok.utf8_str(), ce_desc.utf8_str());
else else
gbAddGgCheat(tok.mb_str(), ce_desc.mb_str()); gbAddGgCheat(tok.utf8_str(), ce_desc.utf8_str());
} else { } else {
// Flashcart CHT format // Flashcart CHT format
if (tok.Contains(wxT("="))) { if (tok.Contains(wxT("="))) {
@ -446,16 +445,16 @@ public:
} }
// Generic Code // Generic Code
else if (tok.Contains(wxT(":"))) else if (tok.Contains(wxT(":")))
cheatsAddCheatCode(tok.mb_str(), ce_desc.mb_str()); cheatsAddCheatCode(tok.utf8_str(), ce_desc.utf8_str());
// following determination of type by lengths is // following determination of type by lengths is
// same used by win32 and gtk code // same used by win32 and gtk code
// and like win32/gtk code, user-chosen fmt is ignored // and like win32/gtk code, user-chosen fmt is ignored
else if (tok.size() == 12) { else if (tok.size() == 12) {
tok = tok.substr(0, 8) + wxT(' ') + tok.substr(8); tok = tok.substr(0, 8) + wxT(' ') + tok.substr(8);
cheatsAddCBACode(tok.mb_str(), ce_desc.mb_str()); cheatsAddCBACode(tok.utf8_str(), ce_desc.utf8_str());
} else if (tok.size() == 16) } else if (tok.size() == 16)
// not sure why 1-tok is !v3 and 2-tok is v3.. // not sure why 1-tok is !v3 and 2-tok is v3..
cheatsAddGSACode(tok.mb_str(), ce_desc.mb_str(), false); cheatsAddGSACode(tok.utf8_str(), ce_desc.utf8_str(), false);
// CBA codes are assumed to be N+4, and anything else // CBA codes are assumed to be N+4, and anything else
// is assumed to be GSA v3 (although I assume the // is assumed to be GSA v3 (although I assume the
// actual formats should be 8+4 and 8+8) // actual formats should be 8+4 and 8+8)
@ -463,18 +462,18 @@ public:
if (!tk.HasMoreTokens()) { if (!tk.HasMoreTokens()) {
// throw an error appropriate to chosen type // throw an error appropriate to chosen type
if (ce_type == 1) // GSA if (ce_type == 1) // GSA
cheatsAddGSACode(tok.mb_str(), ce_desc.mb_str(), false); cheatsAddGSACode(tok.utf8_str(), ce_desc.utf8_str(), false);
else else
cheatsAddCBACode(tok.mb_str(), ce_desc.mb_str()); cheatsAddCBACode(tok.utf8_str(), ce_desc.utf8_str());
} else { } else {
wxString tok2 = tk.GetNextToken(); wxString tok2 = tk.GetNextToken();
if (tok2.size() == 4) { if (tok2.size() == 4) {
tok += wxT(' ') + tok2; tok += wxT(' ') + tok2;
cheatsAddCBACode(tok.mb_str(), ce_desc.mb_str()); cheatsAddCBACode(tok.utf8_str(), ce_desc.utf8_str());
} else { } else {
tok += tok2; tok += tok2;
cheatsAddGSACode(tok.mb_str(), ce_desc.mb_str(), true); cheatsAddGSACode(tok.utf8_str(), ce_desc.utf8_str(), true);
} }
} }
} }
@ -624,7 +623,7 @@ public:
} else if (ce_desc != odesc) { } else if (ce_desc != odesc) {
*dirty = true; *dirty = true;
char* p = isgb ? gbCheatList[id].cheatDesc : cheatsList[id].desc; char* p = isgb ? gbCheatList[id].cheatDesc : cheatsList[id].desc;
strncpy(p, ce_desc.mb_str(), sizeof(cheatsList[0].desc)); strncpy(p, ce_desc.utf8_str(), sizeof(cheatsList[0].desc));
p[sizeof(cheatsList[0].desc) - 1] = 0; p[sizeof(cheatsList[0].desc) - 1] = 0;
item1.SetId(id); item1.SetId(id);
item1.SetText(wxString(p, wxConvUTF8)); item1.SetText(wxString(p, wxConvUTF8));
@ -674,7 +673,7 @@ void CheatList_t::ParseChtLine(wxString desc, wxString tok)
wxString cheat_value; wxString cheat_value;
uint32_t address = 0; uint32_t address = 0;
uint32_t value = 0; uint32_t value = 0;
sscanf(cheat_addr.mb_str(), "%8x", &address); sscanf(cheat_addr.utf8_str(), "%8x", &address);
if (address < 0x40000) if (address < 0x40000)
address += 0x2000000; address += 0x2000000;
@ -685,11 +684,11 @@ void CheatList_t::ParseChtLine(wxString desc, wxString tok)
while (value_tk.HasMoreTokens()) { while (value_tk.HasMoreTokens()) {
wxString value_token = value_tk.GetNextToken(); wxString value_token = value_tk.GetNextToken();
sscanf(value_token.mb_str(), "%2x", &value); sscanf(value_token.utf8_str(), "%2x", &value);
cheat_line.Printf(wxT("%08X"), address); cheat_line.Printf(wxT("%08X"), address);
cheat_value.Printf(wxT("%02X"), value); cheat_value.Printf(wxT("%02X"), value);
cheat_line = cheat_line + wxT(":") + cheat_value; cheat_line = cheat_line + wxT(":") + cheat_value;
cheatsAddCheatCode(cheat_line.mb_str(), cheat_desc.mb_str()); cheatsAddCheatCode(cheat_line.utf8_str(), cheat_desc.utf8_str());
address++; address++;
} }
} }
@ -1070,7 +1069,7 @@ public:
for (int i = 0; i < (1 << size); i++) { for (int i = 0; i < (1 << size); i++) {
addr_s.Printf(wxT("%02X%02X%02X%02X"), bank, val & 0xff, addr_s.Printf(wxT("%02X%02X%02X%02X"), bank, val & 0xff,
addr & 0xff, addr >> 8); addr & 0xff, addr >> 8);
gbAddGsCheat(addr_s.mb_str(), ca_desc.mb_str()); gbAddGsCheat(addr_s.utf8_str(), ca_desc.utf8_str());
val >>= 8; val >>= 8;
addr++; addr++;
} }
@ -1092,7 +1091,7 @@ public:
} }
addr_s.append(s); addr_s.append(s);
cheatsAddCheatCode(addr_s.mb_str(), ca_desc.mb_str()); cheatsAddCheatCode(addr_s.utf8_str(), ca_desc.utf8_str());
} }
} }
@ -1572,7 +1571,7 @@ public:
if (newapi == lastapi) if (newapi == lastapi)
return; return;
gopts.audio_dev = ""; gopts.audio_dev = wxT("");
FillDev(newapi); FillDev(newapi);
} }
} sound_config_handler; } sound_config_handler;
@ -1812,7 +1811,7 @@ public:
// to put the plugins... it depends on where program was // to put the plugins... it depends on where program was
// installed, and of course OS // installed, and of course OS
wxString msg; wxString msg;
msg.Printf(_("No usable rpi plugins found in %s"), plpath.mb_str()); msg.Printf(_("No usable rpi plugins found in %s"), plpath.c_str());
systemScreenMessage(msg); systemScreenMessage(msg);
ch->Hide(); ch->Hide();
txt->Hide(); txt->Hide();
@ -2357,7 +2356,7 @@ void CheckThrowXRCError(T pointer, const wxString& name)
std::string errormessage = "Unable to load a \""; std::string errormessage = "Unable to load a \"";
errormessage += typeid(pointer).name(); errormessage += typeid(pointer).name();
errormessage += "\" from the builtin xrc file: "; errormessage += "\" from the builtin xrc file: ";
errormessage += name.mb_str(); errormessage += name.utf8_str();
throw std::runtime_error(errormessage); throw std::runtime_error(errormessage);
} }
} }
@ -2760,9 +2759,9 @@ bool MainFrame::BindControls()
if (a->GetFlags() == e->GetFlags() && a->GetKeyCode() == e->GetKeyCode()) { if (a->GetFlags() == e->GetFlags() && a->GetKeyCode() == e->GetKeyCode()) {
if (e->GetMenuItem()) { if (e->GetMenuItem()) {
wxLogInfo(_("Duplicate menu accelerator: %s for %s and %s; keeping first"), wxLogInfo(_("Duplicate menu accelerator: %s for %s and %s; keeping first"),
wxKeyTextCtrl::ToString(a->GetFlags(), a->GetKeyCode()).mb_str(), wxKeyTextCtrl::ToString(a->GetFlags(), a->GetKeyCode()).c_str(),
e->GetMenuItem()->GetItemLabelText().mb_str(), e->GetMenuItem()->GetItemLabelText().c_str(),
mi->GetItemLabelText().mb_str()); mi->GetItemLabelText().c_str());
delete a; delete a;
a = 0; a = 0;
} else { } else {
@ -2774,9 +2773,9 @@ bool MainFrame::BindControls()
break; break;
wxLogInfo(_("Menu accelerator %s for %s overrides default for %s ; keeping menu"), wxLogInfo(_("Menu accelerator %s for %s overrides default for %s ; keeping menu"),
wxKeyTextCtrl::ToString(a->GetFlags(), a->GetKeyCode()).mb_str(), wxKeyTextCtrl::ToString(a->GetFlags(), a->GetKeyCode()).c_str(),
mi->GetItemLabelText().mb_str(), mi->GetItemLabelText().c_str(),
cmdtab[cmd].cmd); cmdtab[cmd].cmd.c_str());
} }
sys_accels.erase(e); sys_accels.erase(e);
@ -2880,7 +2879,7 @@ bool MainFrame::BindControls()
for (int i = 0; i < checkable_mi.size(); i++) for (int i = 0; i < checkable_mi.size(); i++)
if (!checkable_mi[i].boolopt && !checkable_mi[i].intopt) { if (!checkable_mi[i].boolopt && !checkable_mi[i].intopt) {
wxLogError(_("Invalid menu item %s; removing"), wxLogError(_("Invalid menu item %s; removing"),
checkable_mi[i].mi->GetItemLabelText().mb_str()); checkable_mi[i].mi->GetItemLabelText().c_str());
checkable_mi[i].mi->GetMenu()->Remove(checkable_mi[i].mi); checkable_mi[i].mi->GetMenu()->Remove(checkable_mi[i].mi);
checkable_mi[i].mi = NULL; checkable_mi[i].mi = NULL;
} }
@ -3784,7 +3783,7 @@ bool MainFrame::BindControls()
bool isv = !gopts.link_host.empty(); bool isv = !gopts.link_host.empty();
if (isv) { if (isv) {
isv = SetLinkServerHost(gopts.link_host.mb_str()); isv = SetLinkServerHost(gopts.link_host.c_str());
} }
if (!isv) { if (!isv) {

View File

@ -148,7 +148,7 @@ bool OpenAL::init(long sampleRate)
assert(initialized == false); assert(initialized == false);
if (!gopts.audio_dev.empty()) { if (!gopts.audio_dev.empty()) {
device = alcOpenDevice(gopts.audio_dev.mb_str()); device = alcOpenDevice(gopts.audio_dev.utf8_str());
} else { } else {
device = alcOpenDevice(NULL); device = alcOpenDevice(NULL);
} }

View File

@ -374,7 +374,7 @@ void load_opts()
for (cont = cfg->GetFirstEntry(s, grp_idx); cont; for (cont = cfg->GetFirstEntry(s, grp_idx); cont;
cont = cfg->GetNextEntry(s, grp_idx)) { cont = cfg->GetNextEntry(s, grp_idx)) {
//wxLogWarning(_("Invalid option %s present; removing if possible"), s.mb_str()); //wxLogWarning(_("Invalid option %s present; removing if possible"), s.c_str());
item_del.push_back(s); item_del.push_back(s);
} }
@ -412,7 +412,7 @@ void load_opts()
for (cont = cfg->GetFirstGroup(e, key_idx); cont; for (cont = cfg->GetFirstGroup(e, key_idx); cont;
cont = cfg->GetNextGroup(e, key_idx)) { cont = cfg->GetNextGroup(e, key_idx)) {
s.append(e); s.append(e);
//wxLogWarning(_("Invalid option group %s present; removing if possible"), s.mb_str()); //wxLogWarning(_("Invalid option group %s present; removing if possible"), s.c_str());
grp_del.push_back(s); grp_del.push_back(s);
s.resize(poff2); s.resize(poff2);
} }
@ -427,7 +427,7 @@ void load_opts()
if (i == NUM_KEYS) { if (i == NUM_KEYS) {
s.append(e); s.append(e);
//wxLogWarning(_("Invalid option %s present; removing if possible"), s.mb_str()); //wxLogWarning(_("Invalid option %s present; removing if possible"), s.c_str());
item_del.push_back(s); item_del.push_back(s);
s.resize(poff2); s.resize(poff2);
} }
@ -439,7 +439,7 @@ void load_opts()
} else { } else {
s.append(wxT('/')); s.append(wxT('/'));
s.append(e); s.append(e);
//wxLogWarning(_("Invalid option group %s present; removing if possible"), s.mb_str()); //wxLogWarning(_("Invalid option group %s present; removing if possible"), s.c_str());
grp_del.push_back(s); grp_del.push_back(s);
s.resize(poff); s.resize(poff);
} }
@ -454,7 +454,7 @@ void load_opts()
if (!std::binary_search(&cmdtab[0], &cmdtab[ncmds], dummy, cmditem_lt)) { if (!std::binary_search(&cmdtab[0], &cmdtab[ncmds], dummy, cmditem_lt)) {
s.append(wxT('/')); s.append(wxT('/'));
s.append(e); s.append(e);
//wxLogWarning(_("Invalid option %s present; removing if possible"), s.mb_str()); //wxLogWarning(_("Invalid option %s present; removing if possible"), s.c_str());
item_del.push_back(s); item_del.push_back(s);
s.resize(poff); s.resize(poff);
} }
@ -465,7 +465,7 @@ void load_opts()
wxString opt_name(dummy.opt); wxString opt_name(dummy.opt);
if (!std::binary_search(&opts[0], &opts[num_opts], dummy, opt_lt) && opt_name != wxT("General/LastUpdated") && opt_name != wxT("General/LastUpdatedFileName")) { if (!std::binary_search(&opts[0], &opts[num_opts], dummy, opt_lt) && opt_name != wxT("General/LastUpdated") && opt_name != wxT("General/LastUpdatedFileName")) {
//wxLogWarning(_("Invalid option %s present; removing if possible"), s.mb_str()); //wxLogWarning(_("Invalid option %s present; removing if possible"), s.c_str());
item_del.push_back(s); item_del.push_back(s);
} }
@ -510,9 +510,9 @@ void load_opts()
// technically, the translation for this string could incorproate // technically, the translation for this string could incorproate
// the equals sign if necessary instead of doing it this way // the equals sign if necessary instead of doing it this way
wxLogWarning(_("Invalid value %s for option %s; valid values are %s%s%s"), wxLogWarning(_("Invalid value %s for option %s; valid values are %s%s%s"),
s, opt.opt, ev, s.c_str(), opt.opt.c_str(), ev.c_str(),
isx ? wxT(" = ") : wxT(""), isx ? wxT(" = ") : wxT(""),
isx ? evx : wxT("")); isx ? evx.c_str() : wxT(""));
// write first option // write first option
cfg->Write(opt.opt, enum_opts[0]); cfg->Write(opt.opt, enum_opts[0]);
} else } else
@ -526,14 +526,14 @@ void load_opts()
cfg->Read(opt.opt, &opt.curint, *opt.intopt); cfg->Read(opt.opt, &opt.curint, *opt.intopt);
if (opt.curint < opt.min || opt.curint > opt.max) { if (opt.curint < opt.min || opt.curint > opt.max) {
wxLogWarning(_("Invalid value %d for option %s; valid values are %d - %d"), opt.curint, opt.opt, opt.min, opt.max); wxLogWarning(_("Invalid value %d for option %s; valid values are %d - %d"), opt.curint, opt.opt.c_str(), opt.min, opt.max);
} else } else
*opt.intopt = opt.curint; *opt.intopt = opt.curint;
} else if (opt.doubleopt) { } else if (opt.doubleopt) {
cfg->Read(opt.opt, &opt.curdouble, *opt.doubleopt); cfg->Read(opt.opt, &opt.curdouble, *opt.doubleopt);
if (opt.curdouble < opt.min || opt.curdouble > opt.max) { if (opt.curdouble < opt.min || opt.curdouble > opt.max) {
wxLogWarning(_("Invalid value %f for option %s; valid values are %f - %f"), opt.curdouble, opt.opt, opt.min, opt.max); wxLogWarning(_("Invalid value %f for option %s; valid values are %f - %f"), opt.curdouble, opt.opt.c_str(), opt.min, opt.max);
} else } else
*opt.doubleopt = opt.curdouble; *opt.doubleopt = opt.curdouble;
} else if (opt.uintopt) { } else if (opt.uintopt) {
@ -542,7 +542,7 @@ void load_opts()
opt.curuint = val; opt.curuint = val;
if (opt.curuint < opt.min || opt.curuint > opt.max) { if (opt.curuint < opt.min || opt.curuint > opt.max) {
wxLogWarning(_("Invalid value %f for option %s; valid values are %f - %f"), opt.curuint, opt.opt, opt.min, opt.max); wxLogWarning(_("Invalid value %f for option %s; valid values are %f - %f"), opt.curuint, opt.opt.c_str(), opt.min, opt.max);
} else } else
*opt.uintopt = opt.curuint; *opt.uintopt = opt.curuint;
} else if (opt.boolopt) { } else if (opt.boolopt) {
@ -594,14 +594,14 @@ void load_opts()
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
for (int j = 0; j < NUM_KEYS; j++) { for (int j = 0; j < NUM_KEYS; j++) {
wxString optname; wxString optname;
optname.Printf(wxT("Joypad/%d/%s"), i + 1, joynames[j]); optname.Printf(wxT("Joypad/%d/%s"), i + 1, joynames[j].c_str());
bool gotit = cfg->Read(optname, &s); bool gotit = cfg->Read(optname, &s);
if (gotit) { if (gotit) {
gopts.joykey_bindings[i][j] = wxJoyKeyTextCtrl::FromString(s); gopts.joykey_bindings[i][j] = wxJoyKeyTextCtrl::FromString(s);
if (s.size() && !gopts.joykey_bindings[i][j].size()) if (s.size() && !gopts.joykey_bindings[i][j].size())
wxLogWarning(_("Invalid key binding %s for %s"), s.mb_str(), optname.mb_str()); wxLogWarning(_("Invalid key binding %s for %s"), s.c_str(), optname.c_str());
} else { } else {
s = wxJoyKeyTextCtrl::ToString(gopts.joykey_bindings[i][j]); s = wxJoyKeyTextCtrl::ToString(gopts.joykey_bindings[i][j]);
cfg->Write(optname, s); cfg->Write(optname, s);
@ -622,7 +622,7 @@ void load_opts()
wxAcceleratorEntry_v val = wxKeyTextCtrl::FromString(s); wxAcceleratorEntry_v val = wxKeyTextCtrl::FromString(s);
if (!val.size()) if (!val.size())
wxLogWarning(_("Invalid key binding %s for %s"), s.mb_str(), kbopt.mb_str()); wxLogWarning(_("Invalid key binding %s for %s"), s.c_str(), kbopt.c_str());
else { else {
for (int j = 0; j < val.size(); j++) for (int j = 0; j < val.size(); j++)
val[j].Set(val[j].GetFlags(), val[j].GetKeyCode(), val[j].Set(val[j].GetFlags(), val[j].GetKeyCode(),
@ -670,7 +670,7 @@ void update_opts()
cfg->Write(opt.opt, (opt.curdouble = *opt.doubleopt)); cfg->Write(opt.opt, (opt.curdouble = *opt.doubleopt));
} else if (opt.uintopt) { } else if (opt.uintopt) {
if (*opt.uintopt != opt.curuint) if (*opt.uintopt != opt.curuint)
cfg->Write(opt.opt, (opt.curuint = *opt.uintopt)); cfg->Write(opt.opt, (long)(opt.curuint = *opt.uintopt));
} else if (opt.boolopt) { } else if (opt.boolopt) {
if (*opt.boolopt != opt.curbool) if (*opt.boolopt != opt.curbool)
cfg->Write(opt.opt, (opt.curbool = *opt.boolopt)); cfg->Write(opt.opt, (opt.curbool = *opt.boolopt));
@ -708,7 +708,7 @@ void update_opts()
for (int j = 0; j < NUM_KEYS; j++) { for (int j = 0; j < NUM_KEYS; j++) {
wxString s, o; wxString s, o;
wxString optname; wxString optname;
optname.Printf(wxT("Joypad/%d/%s"), i + 1, joynames[j]); optname.Printf(wxT("Joypad/%d/%s"), i + 1, joynames[j].c_str());
s = wxJoyKeyTextCtrl::ToString(gopts.joykey_bindings[i][j]); s = wxJoyKeyTextCtrl::ToString(gopts.joykey_bindings[i][j]);
cfg->Read(optname, &o); cfg->Read(optname, &o);
@ -786,7 +786,7 @@ bool opt_set(const wxString& name, const wxString& val)
else if (opt->boolopt) { else if (opt->boolopt) {
if (!(val == wxT('0') || val == wxT('1'))) if (!(val == wxT('0') || val == wxT('1')))
wxLogWarning(_("Invalid flag option %s - %s ignored"), wxLogWarning(_("Invalid flag option %s - %s ignored"),
name, val); name.c_str(), val.c_str());
else else
*opt->boolopt = val == wxT('1'); *opt->boolopt = val == wxT('1');
} else if (!opt->enumvals.empty()) { } else if (!opt->enumvals.empty()) {
@ -803,9 +803,9 @@ bool opt_set(const wxString& name, const wxString& val)
// technically, the translation for this string could incorproate // technically, the translation for this string could incorproate
// the equals sign if necessary instead of doing it this way // the equals sign if necessary instead of doing it this way
wxLogWarning(_("Invalid value %s for option %s; valid values are %s%s%s"), wxLogWarning(_("Invalid value %s for option %s; valid values are %s%s%s"),
s, opt->opt, opt->enumvals, s.c_str(), opt->opt.c_str(), opt->enumvals.c_str(),
isx ? wxT(" = ") : wxT(""), isx ? wxT(" = ") : wxT(""),
isx ? evx : wxT("")); isx ? evx.c_str() : wxT(""));
} else { } else {
*opt->intopt = found_pos; *opt->intopt = found_pos;
} }
@ -814,7 +814,7 @@ bool opt_set(const wxString& name, const wxString& val)
long ival; long ival;
if (!s.ToLong(&ival) || ival < opt->min || ival > opt->max) if (!s.ToLong(&ival) || ival < opt->min || ival > opt->max)
wxLogWarning(_("Invalid value %d for option %s; valid values are %d - %d"), ival, name, opt->min, opt->max); wxLogWarning(_("Invalid value %d for option %s; valid values are %d - %d"), ival, name.c_str(), opt->min, opt->max);
else else
*opt->intopt = ival; *opt->intopt = ival;
} else if (opt->doubleopt) { } else if (opt->doubleopt) {
@ -822,7 +822,7 @@ bool opt_set(const wxString& name, const wxString& val)
double dval; double dval;
if (!s.ToDouble(&dval) || dval < opt->min || dval > opt->max) if (!s.ToDouble(&dval) || dval < opt->min || dval > opt->max)
wxLogWarning(_("Invalid value %f for option %s; valid values are %f - %f"), dval, name, opt->min, opt->max); wxLogWarning(_("Invalid value %f for option %s; valid values are %f - %f"), dval, name.c_str(), opt->min, opt->max);
else else
*opt->doubleopt = dval; *opt->doubleopt = dval;
} else if (opt->uintopt) { } else if (opt->uintopt) {
@ -830,7 +830,7 @@ bool opt_set(const wxString& name, const wxString& val)
unsigned long uival; unsigned long uival;
if (!s.ToULong(&uival) || uival < opt->min || uival > opt->max) if (!s.ToULong(&uival) || uival < opt->min || uival > opt->max)
wxLogWarning(_("Invalid value %f for option %s; valid values are %f - %f"), uival, name, opt->min, opt->max); wxLogWarning(_("Invalid value %f for option %s; valid values are %f - %f"), uival, name.c_str(), opt->min, opt->max);
else else
*opt->uintopt = (uint32_t)uival; *opt->uintopt = (uint32_t)uival;
} else { } else {
@ -899,7 +899,7 @@ bool opt_set(const wxString& name, const wxString& val)
cmd->cmd_id); cmd->cmd_id);
if (!aval.size()) if (!aval.size())
wxLogWarning(_("Invalid key binding %s for %s"), val, name); wxLogWarning(_("Invalid key binding %s for %s"), val.c_str(), name.c_str());
else else
gopts.accels.insert(gopts.accels.end(), aval.begin(), aval.end()); gopts.accels.insert(gopts.accels.end(), aval.begin(), aval.end());
} }
@ -925,7 +925,7 @@ bool opt_set(const wxString& name, const wxString& val)
auto b = wxJoyKeyTextCtrl::FromString(val); auto b = wxJoyKeyTextCtrl::FromString(val);
if (!b.size()) if (!b.size())
wxLogWarning(_("Invalid key binding %s for %s"), val, name); wxLogWarning(_("Invalid key binding %s for %s"), val.c_str(), name.c_str());
else else
gopts.joykey_bindings[jno][kno] = b; gopts.joykey_bindings[jno][kno] = b;
} }

View File

@ -83,7 +83,7 @@ void GameArea::LoadGame(const wxString& name)
if (t == IMAGE_UNKNOWN) { if (t == IMAGE_UNKNOWN) {
wxString s; wxString s;
s.Printf(_("%s is not a valid ROM file"), name.mb_str()); s.Printf(_("%s is not a valid ROM file"), name.c_str());
wxMessageDialog dlg(GetParent(), s, _("Problem loading file"), wxOK | wxICON_ERROR); wxMessageDialog dlg(GetParent(), s, _("Problem loading file"), wxOK | wxICON_ERROR);
dlg.ShowModal(); dlg.ShowModal();
return; return;
@ -140,7 +140,7 @@ void GameArea::LoadGame(const wxString& name)
if (t == IMAGE_GB) { if (t == IMAGE_GB) {
if (!gbLoadRom(fn)) { if (!gbLoadRom(fn)) {
wxString s; wxString s;
s.Printf(_("Unable to load Game Boy ROM %s"), name.mb_str()); s.Printf(_("Unable to load Game Boy ROM %s"), name.c_str());
wxMessageDialog dlg(GetParent(), s, _("Problem loading file"), wxOK | wxICON_ERROR); wxMessageDialog dlg(GetParent(), s, _("Problem loading file"), wxOK | wxICON_ERROR);
dlg.ShowModal(); dlg.ShowModal();
return; return;
@ -192,7 +192,7 @@ void GameArea::LoadGame(const wxString& name)
gbCPUInit(fn, use_bios); gbCPUInit(fn, use_bios);
if (use_bios && !useBios) { if (use_bios && !useBios) {
wxLogError(_("Could not load BIOS %s"), (gbCgbMode ? gopts.gbc_bios : gopts.gb_bios).mb_str()); wxLogError(_("Could not load BIOS %s"), (gbCgbMode ? gopts.gbc_bios : gopts.gb_bios).c_str());
// could clear use flag & file name now, but better to force // could clear use flag & file name now, but better to force
// user to do it // user to do it
} }
@ -215,7 +215,7 @@ void GameArea::LoadGame(const wxString& name)
{ {
if (!(rom_size = CPULoadRom(fn))) { if (!(rom_size = CPULoadRom(fn))) {
wxString s; wxString s;
s.Printf(_("Unable to load Game Boy Advance ROM %s"), name.mb_str()); s.Printf(_("Unable to load Game Boy Advance ROM %s"), name.c_str());
wxMessageDialog dlg(GetParent(), s, _("Problem loading file"), wxOK | wxICON_ERROR); wxMessageDialog dlg(GetParent(), s, _("Problem loading file"), wxOK | wxICON_ERROR);
dlg.ShowModal(); dlg.ShowModal();
return; return;
@ -285,7 +285,7 @@ void GameArea::LoadGame(const wxString& name)
CPUInit(gopts.gba_bios.mb_fn_str(), useBiosFileGBA); CPUInit(gopts.gba_bios.mb_fn_str(), useBiosFileGBA);
if (useBiosFileGBA && !useBios) { if (useBiosFileGBA && !useBios) {
wxLogError(_("Could not load BIOS %s"), gopts.gba_bios.mb_str()); wxLogError(_("Could not load BIOS %s"), gopts.gba_bios.c_str());
// could clear use flag & file name now, but better to force // could clear use flag & file name now, but better to force
// user to do it // user to do it
} }
@ -354,7 +354,7 @@ void GameArea::LoadGame(const wxString& name)
if (emusys->emuReadBattery(fnb.data())) { if (emusys->emuReadBattery(fnb.data())) {
wxString msg; wxString msg;
msg.Printf(_("Loaded battery %s"), bat.GetFullPath().mb_str()); msg.Printf(_("Loaded battery %s"), bat.GetFullPath().c_str());
systemScreenMessage(msg); systemScreenMessage(msg);
if (cpuSaveType == 0 && ovSaveType == 0 && t == IMAGE_GBA) { if (cpuSaveType == 0 && ovSaveType == 0 && t == IMAGE_GBA) {
@ -572,7 +572,7 @@ bool GameArea::LoadState()
bool GameArea::LoadState(int slot) bool GameArea::LoadState(int slot)
{ {
wxString fname; wxString fname;
fname.Printf(SAVESLOT_FMT, game_name().mb_str(), slot); fname.Printf(SAVESLOT_FMT, game_name().c_str(), slot);
return LoadState(wxFileName(statedir, fname)); return LoadState(wxFileName(statedir, fname));
} }
@ -606,7 +606,7 @@ bool GameArea::LoadState(const wxFileName& fname)
wxString msg; wxString msg;
msg.Printf(ret ? _("Loaded state %s") : _("Error loading state %s"), msg.Printf(ret ? _("Loaded state %s") : _("Error loading state %s"),
fname.GetFullPath().mb_str()); fname.GetFullPath().c_str());
systemScreenMessage(msg); systemScreenMessage(msg);
return ret; return ret;
} }
@ -619,7 +619,7 @@ bool GameArea::SaveState()
bool GameArea::SaveState(int slot) bool GameArea::SaveState(int slot)
{ {
wxString fname; wxString fname;
fname.Printf(SAVESLOT_FMT, game_name().mb_str(), slot); fname.Printf(SAVESLOT_FMT, game_name().c_str(), slot);
return SaveState(wxFileName(statedir, fname)); return SaveState(wxFileName(statedir, fname));
} }
@ -630,7 +630,7 @@ bool GameArea::SaveState(const wxFileName& fname)
wxGetApp().frame->update_state_ts(true); wxGetApp().frame->update_state_ts(true);
wxString msg; wxString msg;
msg.Printf(ret ? _("Saved state %s") : _("Error saving state %s"), msg.Printf(ret ? _("Saved state %s") : _("Error saving state %s"),
fname.GetFullPath().mb_str()); fname.GetFullPath().c_str());
systemScreenMessage(msg); systemScreenMessage(msg);
return ret; return ret;
} }
@ -660,7 +660,7 @@ void GameArea::SaveBattery()
// of course some games just write battery way too often for such // of course some games just write battery way too often for such
// a thing to be useful // a thing to be useful
if (!emusys->emuWriteBattery(fnb.data())) if (!emusys->emuWriteBattery(fnb.data()))
wxLogError(_("Error writing battery %s"), fn); wxLogError(_("Error writing battery %s"), fn.c_str());
systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
} }
@ -1018,7 +1018,6 @@ void GameArea::OnIdle(wxIdleEvent& event)
// set userdata so we know it's the panel and not the frame being resized // set userdata so we know it's the panel and not the frame being resized
// the userdata is freed on disconnect/destruction // the userdata is freed on disconnect/destruction
w->Connect(wxEVT_SIZE, wxSizeEventHandler(GameArea::OnSize), new wxObject, this);
this->Connect(wxEVT_SIZE, wxSizeEventHandler(GameArea::OnSize), NULL, this); this->Connect(wxEVT_SIZE, wxSizeEventHandler(GameArea::OnSize), NULL, this);
w->SetBackgroundStyle(wxBG_STYLE_CUSTOM); w->SetBackgroundStyle(wxBG_STYLE_CUSTOM);
@ -1032,19 +1031,29 @@ void GameArea::OnIdle(wxIdleEvent& event)
AdjustMinSize(); AdjustMinSize();
AdjustSize(false); AdjustSize(false);
unsigned frame_priority = 0;
// add spacers on top and bottom to center panel vertically // add spacers on top and bottom to center panel vertically
// but not on 2.8 which does not handle this correctly
#if wxCHECK_VERSION(2, 9, 0)
GetSizer()->Add(0, 0, 1, wxEXPAND); GetSizer()->Add(0, 0, 1, wxEXPAND);
#else
frame_priority = 1;
#endif
// On windows with the vcpkg version of wxWidgets which is 3.1.2, the // On windows with the vcpkg version of wxWidgets which is 3.1.2, the
// wxEXPAND flag throws an XRC error, but everything works fine without it. // wxEXPAND flag throws an XRC error, but everything works fine without it.
// On GTK however, the flag is necessary. // On GTK however, the flag is necessary.
#if defined(__WXMSW__) #if defined(__WXMSW__)
GetSizer()->Add(w, 0, gopts.retain_aspect ? (wxSHAPED | wxALIGN_CENTER_HORIZONTAL) : wxEXPAND); GetSizer()->Add(w, frame_priority, gopts.retain_aspect ? (wxSHAPED | wxALIGN_CENTER_HORIZONTAL) : wxEXPAND);
#else #else
GetSizer()->Add(w, 0, gopts.retain_aspect ? (wxSHAPED | wxALIGN_CENTER_HORIZONTAL | wxEXPAND) : wxEXPAND); GetSizer()->Add(w, frame_priority, gopts.retain_aspect ? (wxSHAPED | wxALIGN_CENTER_HORIZONTAL | wxEXPAND) : wxEXPAND);
#endif #endif
#if wxCHECK_VERSION(2, 9, 0)
GetSizer()->Add(0, 0, 1, wxEXPAND); GetSizer()->Add(0, 0, 1, wxEXPAND);
#endif
Layout(); Layout();
if (pointer_blanked) if (pointer_blanked)
@ -1280,10 +1289,8 @@ void GameArea::EraseBackground(wxEraseEvent& ev)
void GameArea::OnSize(wxSizeEvent& ev) void GameArea::OnSize(wxSizeEvent& ev)
{ {
if (!ev.GetEventUserData()) { // is frame draw_black_background(this);
draw_black_background(this); Layout();
Layout();
}
// panel may resize // panel may resize
if (panel) if (panel)
@ -1812,7 +1819,7 @@ void DrawingPanelBase::DrawArea(uint8_t** data)
if (panel->osdstat.size()) if (panel->osdstat.size())
drawText(todraw + outstride * (systemColorDepth != 24), outstride, drawText(todraw + outstride * (systemColorDepth != 24), outstride,
10, 20, panel->osdstat.mb_str(), showSpeedTransparent); 10, 20, panel->osdstat.utf8_str(), showSpeedTransparent);
if (!disableStatusMessages && !panel->osdtext.empty()) { if (!disableStatusMessages && !panel->osdtext.empty()) {
if (systemGetClock() - panel->osdtime < OSD_TIME) { if (systemGetClock() - panel->osdtime < OSD_TIME) {
@ -1820,7 +1827,7 @@ void DrawingPanelBase::DrawArea(uint8_t** data)
int linelen = std::ceil(width * scale - 20) / 8; int linelen = std::ceil(width * scale - 20) / 8;
int nlines = (message.size() + linelen - 1) / linelen; int nlines = (message.size() + linelen - 1) / linelen;
int cury = height - 14 - nlines * 10; int cury = height - 14 - nlines * 10;
char* buf = strdup(message.mb_str()); char* buf = strdup(message.utf8_str());
char* ptr = buf; char* ptr = buf;
while (nlines > 1) { while (nlines > 1) {
@ -2323,7 +2330,7 @@ void GameArea::StartVidRecording(const wxString& fname)
if ((ret = vid_rec.Record(fnb.data(), basic_width, basic_height, if ((ret = vid_rec.Record(fnb.data(), basic_width, basic_height,
systemColorDepth)) systemColorDepth))
!= MRET_OK) != MRET_OK)
wxLogError(_("Unable to begin recording to %s (%s)"), fname.mb_str(), wxLogError(_("Unable to begin recording to %s (%s)"), fname.c_str(),
media_err(ret)); media_err(ret));
else { else {
MainFrame* mf = wxGetApp().frame; MainFrame* mf = wxGetApp().frame;
@ -2354,7 +2361,7 @@ void GameArea::StartSoundRecording(const wxString& fname)
MediaRet ret; MediaRet ret;
if ((ret = snd_rec.Record(fnb.data())) != MRET_OK) if ((ret = snd_rec.Record(fnb.data())) != MRET_OK)
wxLogError(_("Unable to begin recording to %s (%s)"), fname.mb_str(), wxLogError(_("Unable to begin recording to %s (%s)"), fname.c_str(),
media_err(ret)); media_err(ret));
else { else {
MainFrame* mf = wxGetApp().frame; MainFrame* mf = wxGetApp().frame;

View File

@ -44,7 +44,7 @@ void systemMessage(int id, const char* fmt, ...)
va_list args; va_list args;
// auto-conversion of wxCharBuffer to const char * seems broken // auto-conversion of wxCharBuffer to const char * seems broken
// so save underlying wxCharBuffer (or create one of none is used) // so save underlying wxCharBuffer (or create one of none is used)
wxCharBuffer _fmt(wxString(wxGetTranslation(wxString(fmt, wxConvLibc))).mb_str()); wxCharBuffer _fmt(wxString(wxGetTranslation(wxString(fmt, wxConvLibc))).utf8_str());
if (!buf) { if (!buf) {
buf = (char*)malloc(buflen); buf = (char*)malloc(buflen);
@ -71,7 +71,7 @@ void systemMessage(int id, const char* fmt, ...)
exit(1); exit(1);
} }
wxLogError(wxT("%s"), wxString(buf, wxConvLibc).mb_str()); wxLogError(wxT("%s"), wxString(buf, wxConvLibc).c_str());
} }
static int frames = 0; static int frames = 0;
@ -129,7 +129,7 @@ void systemStartGameRecording(const wxString& fname)
uint32_t version = 1; uint32_t version = 1;
if (!game_file.Open(fn, wxT("wb")) || game_file.Write(&version, sizeof(version)) != sizeof(version)) { if (!game_file.Open(fn, wxT("wb")) || game_file.Write(&version, sizeof(version)) != sizeof(version)) {
wxLogError(_("Cannot open output file %s"), fname.mb_str()); wxLogError(_("Cannot open output file %s"), fname.c_str());
return; return;
} }
@ -190,7 +190,7 @@ void systemStartGamePlayback(const wxString& fname)
uint32_t version; uint32_t version;
if (!game_file.Open(fn, wxT("rb")) || game_file.Read(&version, sizeof(version)) != sizeof(version) || wxUINT32_SWAP_ON_BE(version) != 1) { if (!game_file.Open(fn, wxT("rb")) || game_file.Read(&version, sizeof(version)) != sizeof(version) || wxUINT32_SWAP_ON_BE(version) != 1) {
wxLogError(_("Cannot open recording file %s"), fname.mb_str()); wxLogError(_("Cannot open recording file %s"), fname.c_str());
return; return;
} }
@ -415,7 +415,7 @@ void systemScreenCapture(int num)
do { do {
wxString bfn; wxString bfn;
bfn.Printf(wxT("%s%02d"), panel->game_name().mb_str(), bfn.Printf(wxT("%s%02d"), panel->game_name().c_str(),
num++); num++);
if (captureFormat == 0) if (captureFormat == 0)
@ -434,7 +434,7 @@ void systemScreenCapture(int num)
panel->emusys->emuWriteBMP(fn.GetFullPath().mb_fn_str()); panel->emusys->emuWriteBMP(fn.GetFullPath().mb_fn_str());
wxString msg; wxString msg;
msg.Printf(_("Wrote snapshot %s"), fn.GetFullPath().mb_str()); msg.Printf(_("Wrote snapshot %s"), fn.GetFullPath().c_str());
systemScreenMessage(msg); systemScreenMessage(msg);
} }
@ -805,7 +805,7 @@ void PrintDialog::DoSave(wxCommandEvent&)
if (scimg.SaveFile(of)) { if (scimg.SaveFile(of)) {
wxString msg; wxString msg;
msg.Printf(_("Wrote printer output to %s"), of.mb_str()); msg.Printf(_("Wrote printer output to %s"), of.c_str());
systemScreenMessage(msg); systemScreenMessage(msg);
wxButton* cb = wxStaticCast(dlg->FindWindow(wxID_CANCEL), wxButton); wxButton* cb = wxStaticCast(dlg->FindWindow(wxID_CANCEL), wxButton);
@ -963,7 +963,7 @@ void systemGbPrint(uint8_t* data, int len, int pages, int feed, int pal, int con
do { do {
wxString bfn; wxString bfn;
bfn.Printf(wxT("%s-print%02d"), panel->game_name().mb_str(), bfn.Printf(wxT("%s-print%02d"), panel->game_name().c_str(),
num++); num++);
if (captureFormat == 0) if (captureFormat == 0)
@ -986,7 +986,7 @@ void systemGbPrint(uint8_t* data, int len, int pages, int feed, int pal, int con
if (ret) { if (ret) {
wxString msg; wxString msg;
msg.Printf(_("Wrote printer output to %s"), of.mb_str()); msg.Printf(_("Wrote printer output to %s"), of.c_str());
systemScreenMessage(msg); systemScreenMessage(msg);
} }
@ -1174,7 +1174,7 @@ bool debugOpenPty()
if ((pty_master = posix_openpt(O_RDWR | O_NOCTTY)) < 0 || grantpt(pty_master) < 0 || unlockpt(pty_master) < 0 || !(slave_name = ptsname(pty_master))) { if ((pty_master = posix_openpt(O_RDWR | O_NOCTTY)) < 0 || grantpt(pty_master) < 0 || unlockpt(pty_master) < 0 || !(slave_name = ptsname(pty_master))) {
wxLogError(_("Error opening pseudo tty: %s"), wxString(strerror(errno), wxLogError(_("Error opening pseudo tty: %s"), wxString(strerror(errno),
wxConvLibc) wxConvLibc)
.mb_str()); .c_str());
if (pty_master >= 0) { if (pty_master >= 0) {
close(pty_master); close(pty_master);
@ -1311,7 +1311,7 @@ void log(const char* defaultMsg, ...)
if (out == NULL) { if (out == NULL) {
// FIXME: this should be an option // FIXME: this should be an option
wxFileName trace_log(wxGetApp().GetConfigurationPath(), wxT("trace.log")); wxFileName trace_log(wxGetApp().GetConfigurationPath(), wxT("trace.log"));
out = fopen(trace_log.GetFullPath().mb_str(), "w"); out = fopen(trace_log.GetFullPath().utf8_str(), "w");
if (!out) if (!out)
return; return;

View File

@ -686,7 +686,7 @@ public:
wxFileName fn(memsave_fn); wxFileName fn(memsave_fn);
if (!fn.IsFileReadable()) { if (!fn.IsFileReadable()) {
wxLogError(wxT("Can't open file %s"), memsave_fn.mb_str()); wxLogError(wxT("Can't open file %s"), memsave_fn.c_str());
return; return;
} }

View File

@ -58,7 +58,7 @@ protected:
// on errors, abort program // on errors, abort program
#define baddialog() \ #define baddialog() \
do { \ do { \
wxLogError(_("Unable to load dialog %s from resources"), dname); \ wxLogError(_("Unable to load dialog %s from resources"), dname.c_str()); \
wxGetApp().frame->Close(true); \ wxGetApp().frame->Close(true); \
return; \ return; \
} while (0) } while (0)

View File

@ -60,14 +60,14 @@ static void get_config_path(wxPathList& path, bool exists = true)
static bool debug_dumped = false; static bool debug_dumped = false;
if (!debug_dumped) { if (!debug_dumped) {
wxLogDebug(wxT("GetUserLocalDataDir(): %s"), stdp.GetUserLocalDataDir().mb_str()); wxLogDebug(wxT("GetUserLocalDataDir(): %s"), stdp.GetUserLocalDataDir().c_str());
wxLogDebug(wxT("GetUserDataDir(): %s"), stdp.GetUserDataDir().mb_str()); wxLogDebug(wxT("GetUserDataDir(): %s"), stdp.GetUserDataDir().c_str());
wxLogDebug(wxT("GetLocalizedResourcesDir(wxGetApp().locale.GetCanonicalName()): %s"), stdp.GetLocalizedResourcesDir(wxGetApp().locale.GetCanonicalName()).mb_str()); wxLogDebug(wxT("GetLocalizedResourcesDir(wxGetApp().locale.GetCanonicalName()): %s"), stdp.GetLocalizedResourcesDir(wxGetApp().locale.GetCanonicalName()).c_str());
wxLogDebug(wxT("GetResourcesDir(): %s"), stdp.GetResourcesDir().mb_str()); wxLogDebug(wxT("GetResourcesDir(): %s"), stdp.GetResourcesDir().c_str());
wxLogDebug(wxT("GetDataDir(): %s"), stdp.GetDataDir().mb_str()); wxLogDebug(wxT("GetDataDir(): %s"), stdp.GetDataDir().c_str());
wxLogDebug(wxT("GetLocalDataDir(): %s"), stdp.GetLocalDataDir().mb_str()); wxLogDebug(wxT("GetLocalDataDir(): %s"), stdp.GetLocalDataDir().c_str());
wxLogDebug(wxT("plugins_dir: %s"), wxGetApp().GetPluginsDir().mb_str()); wxLogDebug(wxT("plugins_dir: %s"), wxGetApp().GetPluginsDir().c_str());
wxLogDebug(wxT("XdgConfigDir: %s"), get_xdg_user_config_home() + current_app_name); wxLogDebug(wxT("XdgConfigDir: %s"), (wxString(get_xdg_user_config_home().c_str(), wxConvLibc) + current_app_name).c_str());
debug_dumped = true; debug_dumped = true;
} }
@ -76,8 +76,8 @@ static void get_config_path(wxPathList& path, bool exists = true)
#if defined(__WXGTK__) #if defined(__WXGTK__)
// XDG spec manual support // XDG spec manual support
// ${XDG_CONFIG_HOME:-$HOME/.config}/`appname` // ${XDG_CONFIG_HOME:-$HOME/.config}/`appname`
wxString old_config = wxString(getenv("HOME")) + FILE_SEP + ".vbam"; wxString old_config = wxString(getenv("HOME"), wxConvLibc) + wxT(FILE_SEP) + wxT(".vbam");
wxString new_config(get_xdg_user_config_home()); wxString new_config(get_xdg_user_config_home().c_str(), wxConvLibc);
if (!wxDirExists(old_config) && wxIsWritable(new_config)) if (!wxDirExists(old_config) && wxIsWritable(new_config))
{ {
wxFileName new_path(new_config, wxEmptyString); wxFileName new_path(new_config, wxEmptyString);
@ -120,7 +120,7 @@ const wxString wxvbamApp::GetPluginsDir()
wxString wxvbamApp::GetConfigurationPath() wxString wxvbamApp::GetConfigurationPath()
{ {
wxString config("vbam.ini"); wxString config(wxT("vbam.ini"));
// first check if config files exists in reverse order // first check if config files exists in reverse order
// (from system paths to more local paths.) // (from system paths to more local paths.)
if (data_path.empty()) { if (data_path.empty()) {
@ -247,17 +247,17 @@ bool wxvbamApp::OnInit()
// this needs to be in a subdir to support other config as well // this needs to be in a subdir to support other config as well
// but subdir flag behaves differently 2.8 vs. 2.9. Oh well. // but subdir flag behaves differently 2.8 vs. 2.9. Oh well.
// NOTE: this does not support XDG (freedesktop.org) paths // NOTE: this does not support XDG (freedesktop.org) paths
wxString confname("vbam.ini"); wxString confname(wxT("vbam.ini"));
wxFileName vbamconf(GetConfigurationPath(), confname); wxFileName vbamconf(GetConfigurationPath(), confname);
// /MIGRATION // /MIGRATION
// migrate from 'vbam.{cfg,conf}' to 'vbam.ini' to manage a single config // migrate from 'vbam.{cfg,conf}' to 'vbam.ini' to manage a single config
// file for all platforms. // file for all platforms.
#if !defined(__WXMSW__) && !defined(__APPLE__) #if !defined(__WXMSW__) && !defined(__APPLE__)
wxString oldConf(GetConfigurationPath() + FILE_SEP + "vbam.conf"); wxString oldConf(GetConfigurationPath() + wxT(FILE_SEP) + wxT("vbam.conf"));
#else #else
wxString oldConf(GetConfigurationPath() + FILE_SEP + "vbam.cfg"); wxString oldConf(GetConfigurationPath() + wxT(FILE_SEP) + wxT("vbam.cfg"));
#endif #endif
wxString newConf(GetConfigurationPath() + FILE_SEP + "vbam.ini"); wxString newConf(GetConfigurationPath() + wxT(FILE_SEP) + wxT("vbam.ini"));
if (wxFileExists(oldConf)) if (wxFileExists(oldConf))
{ {
wxRenameFile(oldConf, newConf, false); wxRenameFile(oldConf, newConf, false);
@ -533,7 +533,7 @@ bool wxvbamApp::OnCmdLineParsed(wxCmdLineParser& cl)
"To override, remove all but changed root node(s). " "To override, remove all but changed root node(s). "
"First found root node of correct name in any .xrc or " "First found root node of correct name in any .xrc or "
".xrs files in following search path overrides built-in:"), ".xrs files in following search path overrides built-in:"),
s.mb_str()); s.c_str());
tack_full_path(lm); tack_full_path(lm);
wxLogMessage(lm); wxLogMessage(lm);
console_mode = true; console_mode = true;
@ -560,7 +560,7 @@ bool wxvbamApp::OnCmdLineParsed(wxCmdLineParser& cl)
wxString lm; wxString lm;
lm.Printf(_("Wrote built-in override file to %s\n" lm.Printf(_("Wrote built-in override file to %s\n"
"To override, delete all but changed section. First found section is used from search path:"), "To override, delete all but changed section. First found section is used from search path:"),
s.mb_str()); s.c_str());
wxString oi = wxFileName::GetPathSeparator(); wxString oi = wxFileName::GetPathSeparator();
oi += wxT("vba-over.ini"); oi += wxT("vba-over.ini");
tack_full_path(lm, oi); tack_full_path(lm, oi);
@ -580,17 +580,17 @@ bool wxvbamApp::OnCmdLineParsed(wxCmdLineParser& cl)
"For flag options, true and false are specified as 1 and 0, respectively.\n\n")); "For flag options, true and false are specified as 1 and 0, respectively.\n\n"));
for (int i = 0; i < num_opts; i++) { for (int i = 0; i < num_opts; i++) {
wxPrintf(wxT("%s (%s"), opts[i].opt, wxPrintf(wxT("%s (%s"), opts[i].opt.c_str(),
opts[i].boolopt ? wxT("flag") : opts[i].stropt ? wxT("string") : !opts[i].enumvals.empty() ? opts[i].enumvals : (wxString)(opts[i].intopt ? wxT("int") : opts[i].doubleopt ? wxT("decimal") : wxT("string"))); opts[i].boolopt ? wxT("flag") : opts[i].stropt ? wxT("string") : !opts[i].enumvals.empty() ? opts[i].enumvals.c_str() : (opts[i].intopt ? wxT("int") : opts[i].doubleopt ? wxT("decimal") : wxT("string")));
if (!opts[i].enumvals.empty()) { if (!opts[i].enumvals.empty()) {
const wxString evx = wxGetTranslation(opts[i].enumvals); const wxString evx = wxGetTranslation(opts[i].enumvals);
if (wxStrcmp(evx, opts[i].enumvals)) if (wxStrcmp(evx, opts[i].enumvals))
wxPrintf(wxT(" = %s"), evx); wxPrintf(wxT(" = %s"), evx.c_str());
} }
wxPrintf(wxT(")\n\t%s\n\n"), opts[i].desc); wxPrintf(wxT(")\n\t%s\n\n"), opts[i].desc.c_str());
if (!opts[i].enumvals.empty()) if (!opts[i].enumvals.empty())
opts[i].enumvals = wxGetTranslation(opts[i].enumvals); opts[i].enumvals = wxGetTranslation(opts[i].enumvals);
@ -599,7 +599,7 @@ bool wxvbamApp::OnCmdLineParsed(wxCmdLineParser& cl)
wxPrintf(_("The commands available for the Keyboard/* option are:\n\n")); wxPrintf(_("The commands available for the Keyboard/* option are:\n\n"));
for (int i = 0; i < ncmds; i++) for (int i = 0; i < ncmds; i++)
wxPrintf(wxT("%s (%s)\n"), cmdtab[i].cmd, cmdtab[i].name); wxPrintf(wxT("%s (%s)\n"), cmdtab[i].cmd.c_str(), cmdtab[i].name.c_str());
console_mode = true; console_mode = true;
return true; return true;
@ -631,11 +631,11 @@ bool wxvbamApp::OnCmdLineParsed(wxCmdLineParser& cl)
} else { } else {
if (!complained) { if (!complained) {
wxFprintf(stderr, _("Bad configuration option or multiple ROM files given:\n")); wxFprintf(stderr, _("Bad configuration option or multiple ROM files given:\n"));
wxFprintf(stderr, wxT("%s\n"), pending_load.mb_str()); wxFprintf(stderr, wxT("%s\n"), pending_load.c_str());
complained = true; complained = true;
} }
wxFprintf(stderr, wxT("%s\n"), p); wxFprintf(stderr, wxT("%s\n"), p.c_str());
} }
} }
} }
@ -649,12 +649,12 @@ bool wxvbamApp::OnCmdLineParsed(wxCmdLineParser& cl)
wxString wxvbamApp::GetConfigDir() wxString wxvbamApp::GetConfigDir()
{ {
return GetAbsolutePath(get_xdg_user_config_home() + DOT_DIR); return GetAbsolutePath(wxString((get_xdg_user_config_home() + DOT_DIR).c_str(), wxConvLibc));
} }
wxString wxvbamApp::GetDataDir() wxString wxvbamApp::GetDataDir()
{ {
return GetAbsolutePath(get_xdg_user_data_home() + DOT_DIR); return GetAbsolutePath(wxString((get_xdg_user_data_home() + DOT_DIR).c_str(), wxConvLibc));
} }
wxvbamApp::~wxvbamApp() { wxvbamApp::~wxvbamApp() {
@ -796,7 +796,7 @@ wxString MainFrame::GetGamePath(wxString path)
if (!wxIsWritable(game_path)) if (!wxIsWritable(game_path))
{ {
game_path = wxGetApp().GetAbsolutePath(get_xdg_user_data_home() + DOT_DIR); game_path = wxGetApp().GetAbsolutePath(wxString((get_xdg_user_data_home() + DOT_DIR).c_str(), wxConvLibc));
wxFileName::Mkdir(game_path, 0777, wxPATH_MKDIR_FULL); wxFileName::Mkdir(game_path, 0777, wxPATH_MKDIR_FULL);
} }
@ -865,7 +865,7 @@ void MainFrame::update_state_ts(bool force)
if (panel->game_type() != IMAGE_UNKNOWN) { if (panel->game_type() != IMAGE_UNKNOWN) {
wxString fn; wxString fn;
fn.Printf(SAVESLOT_FMT, panel->game_name().mb_str(), i + 1); fn.Printf(SAVESLOT_FMT, panel->game_name().c_str(), i + 1);
wxFileName fp(panel->state_dir(), fn); wxFileName fp(panel->state_dir(), fn);
wxDateTime ts; // = wxInvalidDateTime wxDateTime ts; // = wxInvalidDateTime