Commit 7ab4f578 authored by nanahira's avatar nanahira

merge

parents 6d829366 ab6e84b9
...@@ -12,10 +12,8 @@ ...@@ -12,10 +12,8 @@
/event /event
/freetype /freetype
/sqlite3 /sqlite3
/ikpmp3
/irrklang /irrklang
/irrlicht /irrlicht
/lua
# gframe additionals # gframe additionals
/gframe/ygopro.ico /gframe/ygopro.ico
...@@ -77,11 +75,14 @@ ...@@ -77,11 +75,14 @@
*.log *.log
/.vscode /.vscode
/bak/ /bak/
/bug.txt
/output /output
/temp /temp
[Tt]humbs.cdb [Tt]humbs.cdb
/PrinterData.txt /PrinterData.txt
/ygopro_*.bat
/ygopro_*.sh
/*.bat /*.bat
/*.sh /*.sh
/*.txt
...@@ -26,16 +26,6 @@ before_install: ...@@ -26,16 +26,6 @@ before_install:
brew install freetype libevent sqlite p7zip dylibbundler > /dev/null; brew install freetype libevent sqlite p7zip dylibbundler > /dev/null;
fi fi
- curl --location --retry 5 http://www.lua.org/ftp/lua-5.3.5.tar.gz | tar zfx -
- cd lua-5.3.5
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
sudo make macosx test install > /dev/null;
fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
sudo make linux test install > /dev/null;
fi
- cd ..
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
curl --location --retry 5 https://github.com/premake/premake-core/releases/download/v5.0.0-alpha12/premake-5.0.0-alpha12-macosx.tar.gz | tar zfx -; curl --location --retry 5 https://github.com/premake/premake-core/releases/download/v5.0.0-alpha12/premake-5.0.0-alpha12-macosx.tar.gz | tar zfx -;
fi fi
...@@ -46,7 +36,6 @@ before_install: ...@@ -46,7 +36,6 @@ before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name http://downloads.sourceforge.net/irrlicht/irrlicht-1.8.4.zip; unzip irrlicht-1.8.4.zip ; cd irrlicht-1.8.4/ ; cp ../premake/irrlicht/irrlicht-mac.patch . ; patch -p1 < irrlicht-mac.patch ; cd source/Irrlicht/MacOSX/ ; xcodebuild -project MacOSX.xcodeproj ; cp build/Release/libIrrlicht.a /usr/local/lib/ ; cp -r ../../../include /usr/local/include/irrlicht ; cd ../../../../ ; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name http://downloads.sourceforge.net/irrlicht/irrlicht-1.8.4.zip; unzip irrlicht-1.8.4.zip ; cd irrlicht-1.8.4/ ; cp ../premake/irrlicht/irrlicht-mac.patch . ; patch -p1 < irrlicht-mac.patch ; cd source/Irrlicht/MacOSX/ ; xcodebuild -project MacOSX.xcodeproj ; cp build/Release/libIrrlicht.a /usr/local/lib/ ; cp -r ../../../include /usr/local/include/irrlicht ; cd ../../../../ ; fi
- git clone --depth=1 https://$NANAHIRA@github.com/purerosefallen/irrklang - git clone --depth=1 https://$NANAHIRA@github.com/purerosefallen/irrklang
- mv -f irrklang/plugins/ikpmp3 .
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
sudo cp -rf irrklang/bin/macosx-gcc/libirrklang.dylib /usr/local/lib/; sudo cp -rf irrklang/bin/macosx-gcc/libirrklang.dylib /usr/local/lib/;
...@@ -105,6 +94,7 @@ before_deploy: ...@@ -105,6 +94,7 @@ before_deploy:
- mv -f WindBot windbot - mv -f WindBot windbot
- curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/purerosefallen/windbot/raw/master/BotWrapper/BotWrapper.sh - curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/purerosefallen/windbot/raw/master/BotWrapper/BotWrapper.sh
- mv -f BotWrapper.sh bot - mv -f BotWrapper.sh bot
- chmod +x bot
- cd sound - cd sound
- bash -c "grep '.wav' files.txt | xargs -I {} curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/purerosefallen/ygopro-222DIY-data/raw/master/sound/{} ; exit 0" - bash -c "grep '.wav' files.txt | xargs -I {} curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/purerosefallen/ygopro-222DIY-data/raw/master/sound/{} ; exit 0"
......
project (ygo)
cmake_minimum_required (VERSION 2.8)
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting build type to 'Debug' as none was specified.")
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/macros")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
include (AutoFiles)
include (platform/settings)
if (MSVC)
add_subdirectory (event)
add_subdirectory (freetype)
add_subdirectory (irrlicht)
add_subdirectory (sqlite3)
else ()
find_package(LibEvent REQUIRED)
find_package(Freetype REQUIRED)
find_package(Irrlicht REQUIRED)
find_package(Sqlite REQUIRED)
find_package(OpenGL REQUIRED)
endif ()
option(USE_IRRKLANG "Use irrKlang sound library" OFF)
if (USE_IRRKLANG)
set(IRRKLANG_DIR ${CMAKE_SOURCE_DIR}/irrKlang)
endif ()
add_subdirectory (lua)
add_subdirectory (ocgcore)
add_subdirectory (gframe)
...@@ -27,16 +27,11 @@ install: ...@@ -27,16 +27,11 @@ install:
- move irrlicht-1.8.4\source\Irrlicht irrlicht\src - move irrlicht-1.8.4\source\Irrlicht irrlicht\src
- move irrlicht-1.8.4\include irrlicht\include - move irrlicht-1.8.4\include irrlicht\include
- bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://www.lua.org/ftp/lua-5.3.5.tar.gz ; exit 0"
- tar xf lua-5.3.5.tar.gz
- move lua-5.3.5\src lua
- bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://www.sqlite.org/2018/sqlite-amalgamation-3240000.zip ; exit 0" - bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://www.sqlite.org/2018/sqlite-amalgamation-3240000.zip ; exit 0"
- 7z x -y sqlite-amalgamation-3240000.zip - 7z x -y sqlite-amalgamation-3240000.zip
- move sqlite-amalgamation-3240000 sqlite3 - move sqlite-amalgamation-3240000 sqlite3
- git clone --depth=1 https://%access_token%@github.com/purerosefallen/irrklang - git clone --depth=1 https://%access_token%@github.com/purerosefallen/irrklang
- mv -f irrklang/plugins/ikpmp3 .
# let premake happy # let premake happy
- cp -rf premake/* . - cp -rf premake/* .
...@@ -105,5 +100,4 @@ cache: ...@@ -105,5 +100,4 @@ cache:
- libevent-2.0.22-stable.tar.gz - libevent-2.0.22-stable.tar.gz
- freetype-2.9.1.tar.bz2 - freetype-2.9.1.tar.bz2
- irrlicht-1.8.4.zip - irrlicht-1.8.4.zip
- lua-5.3.5.tar.gz
- sqlite-amalgamation-3240000.zip - sqlite-amalgamation-3240000.zip
No preview for this file type
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
add_definitions ( "-fexceptions" "-fomit-frame-pointer" "-fno-strict-aliasing" "-Wno-format-security" )
add_definitions ( "-static-libgcc" "-static-libstdc++" )
add_definitions ( "-wd4996" "-D_CRT_SECURE_NO_WARNINGS" "-D_ITERATOR_DEBUG_LEVEL=0" )
add_definitions ( "-D_UNICODE" "-DUNICODE" "/utf-8" )
include (MSVCMultipleProcessCompile)
include (MSVCStaticRuntime)
function (AutoFiles _folder _base _pattern)
if (ARGC GREATER 3)
set(_exclude ${ARGN})
else ()
set(_exclude)
endif ()
file (GLOB _files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/ ${_folder}/*)
set (folderFiles)
foreach (_fname ${_files})
if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${_fname})
AutoFiles ("${_fname}" "${_base}" "${_pattern}" "${_exclude}")
elseif (_fname MATCHES ${_pattern})
if(_exclude)
if (NOT _fname MATCHES ${_exclude})
set(folderFiles ${folderFiles} ${_fname})
endif ()
else ()
set(folderFiles ${folderFiles} ${_fname})
endif ()
endif ()
endforeach ()
string(REPLACE "./" "" _folder2 ${_folder})
string(REPLACE "/" "\\" _folder2 ${_folder2})
if (_folder2 STREQUAL ".")
source_group(${_base} FILES ${folderFiles})
else ()
source_group(${_base}\\${_folder2} FILES ${folderFiles})
endif ()
set(AUTO_FILES_RESULT ${AUTO_FILES_RESULT} ${folderFiles} PARENT_SCOPE)
endfunction ()
# - Try to find the dl library
# Once done this will define
#
# DL_FOUND - System has libdl
# DL_LIBRARIES - The libraries needed to use libdl
# DL_DEFINITIONS - Compiler switches required for using libdl
FIND_PATH(DL_INCLUDE_DIR dlfcn.h
PATH_SUFFIXES include
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
FIND_LIBRARY(DL_LIBRARIES NAMES dl
PATH_SUFFIXES lib64 lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(libdl DEFAULT_MSG DL_LIBRARIES DL_INCLUDE_DIR)
MARK_AS_ADVANCED(DL_INCLUDE_DIR DL_LIBRARIES)
# - Try to find the Lib library
# Once done this will define
#
# FREETYPE_FOUND - System has freetype
# FREETYPE_INCLUDE_DIR - The freetype include directory
# FREETYPE_LIBRARIES - The libraries needed to use freetype
# FREETYPE_DEFINITIONS - Compiler switches required for using freetype
SET(FREETYPE_DEFINITIONS ${PC_FREETYPE_CFLAGS_OTHER})
FIND_PATH(FREETYPE_INCLUDE_DIR ft2build.h
HINTS
${PC_FREETYPE_INCLUDEDIR}
${PC_FREETYPE_INCLUDE_DIRS}
PATH_SUFFIXES freetype2
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
FIND_LIBRARY(FREETYPE_LIBRARIES NAMES freetype
HINTS
${PC_FREETYPE_LIBDIR}
${PC_FREETYPE_LIBRARY_DIRS}
PATH_SUFFIXES lib64 lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
SET(FREETYPE_LIBRARIES ${FREETYPE_LIBRARIES})
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(FREETYPE DEFAULT_MSG FREETYPE_LIBRARIES FREETYPE_INCLUDE_DIR)
MARK_AS_ADVANCED(FREETYPE_INCLUDE_DIR FREETYPE_LIBRARIES)
# - Try to find the Lib library
# Once done this will define
#
# IRRLICHT_FOUND - System has IRRLICHT
# IRRLICHT_INCLUDE_DIR - The IRRLICHT include directory
# IRRLICHT_LIBRARIES - The libraries needed to use IRRLICHT
# IRRLICHT_DEFINITIONS - Compiler switches required for using IRRLICHT
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
#FIND_PACKAGE(PkgConfig)
#PKG_SEARCH_MODULE(PC_IRRLICHT Irrlicht)
SET(IRRLICHT_DEFINITIONS ${PC_IRRLICHT_CFLAGS_OTHER})
FIND_PATH(IRRLICHT_INCLUDE_DIR irrlicht.h
HINTS
${PC_IRRLICHT_INCLUDEDIR}
${PC_IRRLICHT_INCLUDE_DIRS}
PATH_SUFFIXES include include/irrlicht
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
FIND_LIBRARY(IRRLICHT_LIBRARIES NAMES Irrlicht irrlicht
HINTS
${PC_IRRLICHT_LIBDIR}
${PC_IRRLICHT_LIBRARY_DIRS}
PATH_SUFFIXES lib64 lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Irrlicht DEFAULT_MSG IRRLICHT_LIBRARIES IRRLICHT_INCLUDE_DIR)
MARK_AS_ADVANCED(IRRLICHT_INCLUDE_DIR IRRLICHT_LIBRARIES)
# - Try to find the Lib library
# Once done this will define
#
# LIBEVENT_FOUND - System has Libevent
# LIBEVENT_INCLUDE_DIR - The Libevent include directory
# LIBEVENT_LIBRARIES - The libraries needed to use Libevent
# LIBEVENT_DEFINITIONS - Compiler switches required for using Libevent
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
#FIND_PACKAGE(PkgConfig)
#PKG_SEARCH_MODULE(PC_LIBEVENT event)
SET(LIBEVENT_DEFINITIONS ${PC_LIBEVENT_CFLAGS_OTHER})
FIND_PATH(LIBEVENT_INCLUDE_DIR event2/event.h
HINTS
${PC_LIBEVENT_INCLUDEDIR}
${PC_LIBEVENT_INCLUDE_DIRS}
PATH_SUFFIXES include
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
FIND_LIBRARY(LIBEVENT_LIBRARIES NAMES event
HINTS
${PC_LIBEVENT_LIBDIR}
${PC_LIBEVENT_LIBRARY_DIRS}
PATH_SUFFIXES lib64 lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
FIND_LIBRARY(LIBEVENT_LIBRARIES_PTHREADS NAMES event_pthreads
HINTS
${PC_LIBEVENT_LIBDIR}
${PC_LIBEVENT_LIBRARY_DIRS}
PATH_SUFFIXES lib64 lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
SET(LIBEVENT_LIBRARIES ${LIBEVENT_LIBRARIES} ${LIBEVENT_LIBRARIES_PTHREADS})
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibEvent DEFAULT_MSG LIBEVENT_LIBRARIES LIBEVENT_INCLUDE_DIR)
MARK_AS_ADVANCED(LIBEVENT_INCLUDE_DIR LIBEVENT_LIBRARIES)
# - Try to find the Lib library
# Once done this will define
#
# SQLITE_FOUND - System has sqlite
# SQLITE_INCLUDE_DIR - The sqlite include directory
# SQLITE_LIBRARIES - The libraries needed to use sqlite
# SQLITE_DEFINITIONS - Compiler switches required for using sqlite
SET(SQLITE_DEFINITIONS ${PC_SQLITE_CFLAGS_OTHER})
FIND_PATH(SQLITE_INCLUDE_DIR sqlite3.h
HINTS
${PC_SQLITE_INCLUDEDIR}
${PC_SQLITE_INCLUDE_DIRS}
PATH_SUFFIXES include
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
FIND_LIBRARY(SQLITE_LIBRARIES NAMES sqlite3
HINTS
${PC_SQLITE_LIBDIR}
${PC_SQLITE_LIBRARY_DIRS}
PATH_SUFFIXES lib64 lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
SET(SQLITE_LIBRARIES ${SQLITE_LIBRARIES})
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SQLITE DEFAULT_MSG SQLITE_LIBRARIES SQLITE_INCLUDE_DIR)
MARK_AS_ADVANCED(SQLITE_INCLUDE_DIR SQLITE_LIBRARIES)
# - Combine lists of prefixes and suffixes in all combinations
#
# list_combinations(var PREFIXES listitems... SUFFIXES listitems...) -
# where var is the name of your desired output variable and PREFIXES
# and SUFFIXES are special arguments that indicate the start of your
# list of prefixes or suffixes respectively.
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
if(__list_combinations)
return()
endif()
set(__list_combinations YES)
function(list_combinations var)
# Parse arguments
set(_prefixes)
set(_suffixes)
set(_nowhere)
set(_curdest _nowhere)
foreach(_element ${ARGN})
if("${_element}" STREQUAL "PREFIXES")
set(_curdest _prefixes)
elseif("${_element}" STREQUAL "SUFFIXES")
set(_curdest _suffixes)
else()
list(APPEND ${_curdest} "${_element}")
endif()
endforeach()
if(_nowhere)
message(STATUS "_prefixes ${_prefixes}")
message(STATUS "_prefixes ${_suffixes}")
message(STATUS "_prefixes ${_nowhere}")
message(FATAL_ERROR
"Syntax error in use of ${CMAKE_CURRENT_LIST_FILE}")
endif()
foreach(_prefix ${_prefixes})
foreach(_suffix ${_suffixes})
list(APPEND _out "${_prefix}${_suffix}")
endforeach()
endforeach()
set(${var} "${_out}" PARENT_SCOPE)
endfunction()
# - Compile with multiple processes on MSVC
#
# include(MSVCMultipleProcessCompile)
#
# Requires these CMake modules:
# ListCombinations.cmake
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
if(MSVC AND NOT "${MSVC_VERSION}" LESS 1400)
# Only available in VS 2005 and newer
string(TOUPPER "${CMAKE_CONFIGURATION_TYPES}" _conftypesUC)
include(ListCombinations)
list_combinations(_varnames
PREFIXES
CMAKE_C_FLAGS_
CMAKE_CXX_FLAGS_
SUFFIXES
${_conftypesUC})
foreach(_var ${_varnames})
set(${_var} "${${_var}} /MP")
endforeach()
endif()
# - Modify compile flags to use the static runtimes of MSVC
#
# include(MSVCStaticRuntime)
#
# Requires these CMake modules:
# ListCombinations.cmake
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
if(MSVC)
string(TOUPPER "${CMAKE_CONFIGURATION_TYPES}" _conftypesUC)
include(ListCombinations)
list_combinations(_varnames
PREFIXES
CMAKE_C_FLAGS_
CMAKE_CXX_FLAGS_
SUFFIXES
${_conftypesUC})
foreach(_var ${_varnames})
string(REPLACE "/MDd" "/MTd" ${_var} "${${_var}}")
string(REPLACE "/MD" "/MT" ${_var} "${${_var}}")
endforeach()
endif()
set(Boost_USE_STATIC_LIBS ON)
add_definitions ( "-DLUA_USE_MACOSX" )
add_definitions ( "-DLUA_USE_POSIX" )
add_definitions ( "-DLUA_USE_LINUX" )
if(CMAKE_SIZEOF_VOID_P MATCHES 8)
set(PLATFORM 64)
MESSAGE(STATUS "Detected 64-bit platform")
else()
set(PLATFORM 32)
MESSAGE(STATUS "Detected 32-bit platform")
endif()
if(WIN32)
include(platform/win)
elseif(UNIX)
include(platform/unix)
endif()
if (APPLE)
include (platform/apple)
if ("${CMAKE_GENERATOR}" MATCHES "Xcode")
include (platform/xcode)
endif ()
elseif (CMAKE_SYSTEM MATCHES Linux)
include (platform/linux)
else ()
include (platform/common)
endif ()
if(CMAKE_C_COMPILER MATCHES "icc")
include(compiler/icc)
elseif(CMAKE_C_COMPILER MATCHES "clang")
include(compiler/clang-compile)
elseif(CMAKE_C_COMPILER MATCHES "cc")
include(compiler/gcc)
endif()
find_package(Threads)
find_package(DL)
if ( MSVC )
include(compiler/msvc)
elseif ( MINGW )
if(CMAKE_C_COMPILER MATCHES "clang")
include(compiler/clang)
elseif(CMAKE_C_COMPILER MATCHES "cc")
include(compiler/gcc)
endif()
include(compiler/mingw)
endif()
set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvm.clang.1_0")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++14")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
project (ygopro)
if (NOT WIN32 AND NOT APPLE)
include (FindX11)
endif ()
add_subdirectory (lzma)
set (AUTO_FILES_RESULT)
if (MSVC)
AutoFiles("." "res" "\\.(rc)$")
AutoFiles("." "src" "\\.(cpp|c|h)$" "CGUIButton.cpp|lzma/\\.*")
else ()
AutoFiles("." "src" "\\.(cpp|c|h)$" "lzma/\\.*")
endif ()
if (MSVC)
add_executable (ygopro WIN32 ${AUTO_FILES_RESULT})
set_target_properties (ygopro PROPERTIES LINK_FLAGS /ENTRY:"mainCRTStartup")
else ()
add_executable (ygopro ${AUTO_FILES_RESULT})
endif ()
target_link_libraries (ygopro ocgcore lua clzma)
if (MSVC)
target_link_libraries (ygopro irrlicht freetype sqlite3 event)
include_directories ( "../irrlicht/include" "../freetype/include" "../event/include" "../sqlite3" )
else ()
target_link_libraries (ygopro
${IRRLICHT_LIBRARIES}
${FREETYPE_LIBRARIES}
${SQLITE_LIBRARIES}
${LIBEVENT_LIBRARIES}
${OPENGL_gl_LIBRARY}
)
include_directories (
${IRRLICHT_INCLUDE_DIR}
${FREETYPE_INCLUDE_DIR}
${SQLITE_INCLUDE_DIRS}
${LIBEVENT_INCLUDE_DIR}
${OPENGL_INCLUDE_DIR}
)
target_link_libraries (ygopro ${CMAKE_THREAD_LIBS_INIT} ${DL_LIBRARIES})
endif ()
if (USE_IRRKLANG)
add_definitions ( "-DYGOPRO_USE_IRRKLANG" )
if (MSVC)
target_link_libraries (ygopro ${IRRKLANG_DIR}/lib/Win32-visualStudio/irrKlang.lib)
elseif (CMAKE_SYSTEM MATCHES Linux)
target_link_libraries (ygopro ${IRRKLANG_DIR}/bin/linux-gcc-64/libIrrKlang.so)
endif ()
include_directories ( "${IRRKLANG_DIR}/include" )
endif ()
if (WIN32)
target_link_libraries (ygopro ws2_32 winmm gdi32 kernel32 user32 imm32 opengl32)
endif ()
...@@ -408,7 +408,7 @@ void ClientField::ShowSelectCard(bool buttonok, bool chain) { ...@@ -408,7 +408,7 @@ void ClientField::ShowSelectCard(bool buttonok, bool chain) {
else if(conti_selecting) else if(conti_selecting)
mainGame->imageLoading.insert(std::make_pair(mainGame->btnCardSelect[i], selectable_cards[i]->chain_code)); mainGame->imageLoading.insert(std::make_pair(mainGame->btnCardSelect[i], selectable_cards[i]->chain_code));
else else
mainGame->btnCardSelect[i]->setImage(imageManager.tCover[selectable_cards[i]->controler + 2], rect<s32>(0, 0, CARD_IMG_WIDTH, CARD_IMG_HEIGHT)); mainGame->btnCardSelect[i]->setImage(imageManager.tCover[selectable_cards[i]->controler + 2]);
mainGame->btnCardSelect[i]->setRelativePosition(rect<s32>(startpos + i * 125, 55, startpos + 120 + i * 125, 225)); mainGame->btnCardSelect[i]->setRelativePosition(rect<s32>(startpos + i * 125, 55, startpos + 120 + i * 125, 225));
mainGame->btnCardSelect[i]->setPressed(false); mainGame->btnCardSelect[i]->setPressed(false);
mainGame->btnCardSelect[i]->setVisible(true); mainGame->btnCardSelect[i]->setVisible(true);
...@@ -494,7 +494,7 @@ void ClientField::ShowChainCard() { ...@@ -494,7 +494,7 @@ void ClientField::ShowChainCard() {
if(selectable_cards[i]->code) if(selectable_cards[i]->code)
mainGame->imageLoading.insert(std::make_pair(mainGame->btnCardSelect[i], selectable_cards[i]->code)); mainGame->imageLoading.insert(std::make_pair(mainGame->btnCardSelect[i], selectable_cards[i]->code));
else else
mainGame->btnCardSelect[i]->setImage(imageManager.tCover[selectable_cards[i]->controler + 2], rect<s32>(0, 0, CARD_IMG_WIDTH, CARD_IMG_HEIGHT)); mainGame->btnCardSelect[i]->setImage(imageManager.tCover[selectable_cards[i]->controler + 2]);
mainGame->btnCardSelect[i]->setRelativePosition(rect<s32>(startpos + i * 125, 55, startpos + 120 + i * 125, 225)); mainGame->btnCardSelect[i]->setRelativePosition(rect<s32>(startpos + i * 125, 55, startpos + 120 + i * 125, 225));
mainGame->btnCardSelect[i]->setPressed(false); mainGame->btnCardSelect[i]->setPressed(false);
mainGame->btnCardSelect[i]->setVisible(true); mainGame->btnCardSelect[i]->setVisible(true);
...@@ -549,7 +549,7 @@ void ClientField::ShowLocationCard() { ...@@ -549,7 +549,7 @@ void ClientField::ShowLocationCard() {
if(display_cards[i]->code) if(display_cards[i]->code)
mainGame->imageLoading.insert(std::make_pair(mainGame->btnCardDisplay[i], display_cards[i]->code)); mainGame->imageLoading.insert(std::make_pair(mainGame->btnCardDisplay[i], display_cards[i]->code));
else else
mainGame->btnCardDisplay[i]->setImage(imageManager.tCover[display_cards[i]->controler + 2], rect<s32>(0, 0, CARD_IMG_WIDTH, CARD_IMG_HEIGHT)); mainGame->btnCardDisplay[i]->setImage(imageManager.tCover[display_cards[i]->controler + 2]);
mainGame->btnCardDisplay[i]->setRelativePosition(rect<s32>(startpos + i * 125, 55, startpos + 120 + i * 125, 225)); mainGame->btnCardDisplay[i]->setRelativePosition(rect<s32>(startpos + i * 125, 55, startpos + 120 + i * 125, 225));
mainGame->btnCardDisplay[i]->setPressed(false); mainGame->btnCardDisplay[i]->setPressed(false);
mainGame->btnCardDisplay[i]->setVisible(true); mainGame->btnCardDisplay[i]->setVisible(true);
......
...@@ -141,6 +141,7 @@ public: ...@@ -141,6 +141,7 @@ public:
void UpdateChainButtons(); void UpdateChainButtons();
void ShowCancelOrFinishButton(int buttonOp); void ShowCancelOrFinishButton(int buttonOp);
void SetShowMark(ClientCard* pcard, bool enable); void SetShowMark(ClientCard* pcard, bool enable);
void ShowCardInfoInList(ClientCard* pcard, irr::gui::IGUIElement* element, irr::gui::IGUIElement* parent);
void SetResponseSelectedCards() const; void SetResponseSelectedCards() const;
void SetResponseSelectedOption() const; void SetResponseSelectedOption() const;
void CancelOrFinish(); void CancelOrFinish();
......
...@@ -130,7 +130,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -130,7 +130,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
switch(id) { switch(id) {
case BUTTON_CLEAR_DECK: { case BUTTON_CLEAR_DECK: {
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, (wchar_t*)dataManager.GetSysString(1339)); mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, (wchar_t*)dataManager.GetSysString(1339));
mainGame->PopupElement(mainGame->wQuery); mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
prev_operation = id; prev_operation = id;
...@@ -226,7 +226,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -226,7 +226,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
wchar_t textBuffer[256]; wchar_t textBuffer[256];
myswprintf(textBuffer, L"%ls\n%ls", mainGame->cbDBDecks->getItem(sel), dataManager.GetSysString(1337)); myswprintf(textBuffer, L"%ls\n%ls", mainGame->cbDBDecks->getItem(sel), dataManager.GetSysString(1337));
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, (wchar_t*)textBuffer); mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, (wchar_t*)textBuffer);
mainGame->PopupElement(mainGame->wQuery); mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
prev_operation = id; prev_operation = id;
...@@ -236,7 +236,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -236,7 +236,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
case BUTTON_LEAVE_GAME: { case BUTTON_LEAVE_GAME: {
if(is_modified && !mainGame->chkIgnoreDeckChanges->isChecked()) { if(is_modified && !mainGame->chkIgnoreDeckChanges->isChecked()) {
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, (wchar_t*)dataManager.GetSysString(1356)); mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, (wchar_t*)dataManager.GetSysString(1356));
mainGame->PopupElement(mainGame->wQuery); mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
prev_operation = id; prev_operation = id;
...@@ -403,7 +403,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -403,7 +403,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
case COMBOBOX_DBDECKS: { case COMBOBOX_DBDECKS: {
if(is_modified && !mainGame->chkIgnoreDeckChanges->isChecked()) { if(is_modified && !mainGame->chkIgnoreDeckChanges->isChecked()) {
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, (wchar_t*)dataManager.GetSysString(1356)); mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, (wchar_t*)dataManager.GetSysString(1356));
mainGame->PopupElement(mainGame->wQuery); mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
prev_operation = id; prev_operation = id;
......
...@@ -897,8 +897,8 @@ void Game::DrawSpec() { ...@@ -897,8 +897,8 @@ void Game::DrawSpec() {
} }
case 100: { case 100: {
if(showcardp < 60) { if(showcardp < 60) {
driver->draw2DImage(imageManager.tHand[(showcardcode >> 16) & 0x3], Resize(615, showcarddif)); driver->draw2DImage(imageManager.tHand[(showcardcode >> 16) & 0x3], position2di((615 + 44.5) * xScale - 44.5, (showcarddif + 64) * yScale - 64));
driver->draw2DImage(imageManager.tHand[showcardcode & 0x3], Resize(615, 540 - showcarddif)); driver->draw2DImage(imageManager.tHand[showcardcode & 0x3], position2di((615 + 44.5) * xScale - 44.5, (540 - showcarddif + 64) * yScale - 64));
float dy = -0.333333f * showcardp + 10; float dy = -0.333333f * showcardp + 10;
showcardp++; showcardp++;
if(showcardp < 30) if(showcardp < 30)
...@@ -956,16 +956,16 @@ void Game::DrawSpec() { ...@@ -956,16 +956,16 @@ void Game::DrawSpec() {
auto pos = lpcFont->getDimension(lstr); auto pos = lpcFont->getDimension(lstr);
if(showcardp < 10) { if(showcardp < 10) {
int alpha = (showcardp * 25) << 24; int alpha = (showcardp * 25) << 24;
DrawShadowText(lpcFont, lstr, ResizeElem(650 - pos.Width / 2 - (9 - showcardp) * 40, 290, 950, 370), Resize(-1, -1, 0, 0), alpha | 0xffffff, alpha); DrawShadowText(lpcFont, lstr, ResizePhaseHint(660 - (9 - showcardp) * 40, 290, 960, 370, pos.Width), Resize(-1, -1, 0, 0), alpha | 0xffffff, alpha);
} else if(showcardp < showcarddif) { } else if(showcardp < showcarddif) {
DrawShadowText(lpcFont, lstr, ResizeElem(650 - pos.Width / 2, 290, 950, 370), Resize(-1, -1, 0, 0), 0xffffffff); DrawShadowText(lpcFont, lstr, ResizePhaseHint(660, 290, 960, 370, pos.Width), Resize(-1, -1, 0, 0), 0xffffffff);
if(dInfo.vic_string && (showcardcode == 1 || showcardcode == 2)) { if(dInfo.vic_string && (showcardcode == 1 || showcardcode == 2)) {
driver->draw2DRectangle(0xa0000000, ResizeElem(540, 320, 800, 340)); driver->draw2DRectangle(0xa0000000, Resize(540, 320, 790, 340));
DrawShadowText(guiFont, dInfo.vic_string, ResizeElem(500, 320, 840, 340), Resize(-2, -1, 0, 0), 0xffffffff, 0xff000000, true, true, 0); DrawShadowText(guiFont, dInfo.vic_string, Resize(490, 320, 840, 340), Resize(-2, -1, 0, 0), 0xffffffff, 0xff000000, true, true, 0);
} }
} else if(showcardp < showcarddif + 10) { } else if(showcardp < showcarddif + 10) {
int alpha = ((showcarddif + 10 - showcardp) * 25) << 24; int alpha = ((showcarddif + 10 - showcardp) * 25) << 24;
DrawShadowText(lpcFont, lstr, ResizeElem(650 - pos.Width / 2 + (showcardp - showcarddif) * 40, 290, 950, 370), Resize(-1, -1, 0, 0), alpha | 0xffffff, alpha); DrawShadowText(lpcFont, lstr, ResizePhaseHint(660 + (showcardp - showcarddif) * 40, 290, 960, 370, pos.Width), Resize(-1, -1, 0, 0), alpha | 0xffffff, alpha);
} }
showcardp++; showcardp++;
break; break;
......
...@@ -668,6 +668,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -668,6 +668,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->btnCancelOrFinish->setVisible(false); mainGame->btnCancelOrFinish->setVisible(false);
if(!mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping) if(!mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping)
mainGame->dInfo.isReplaySkiping = false; mainGame->dInfo.isReplaySkiping = false;
mainGame->wSurrender->setVisible(false);
mainGame->stMessage->setText(dataManager.GetSysString(1500)); mainGame->stMessage->setText(dataManager.GetSysString(1500));
mainGame->PopupElement(mainGame->wMessage); mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
...@@ -702,6 +703,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -702,6 +703,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
case STOC_REPLAY: { case STOC_REPLAY: {
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->wPhase->setVisible(false); mainGame->wPhase->setVisible(false);
mainGame->wSurrender->setVisible(false);
if(mainGame->dInfo.player_type < 7) if(mainGame->dInfo.player_type < 7)
mainGame->btnLeaveGame->setVisible(false); mainGame->btnLeaveGame->setVisible(false);
mainGame->btnChainIgnore->setVisible(false); mainGame->btnChainIgnore->setVisible(false);
...@@ -1380,7 +1382,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1380,7 +1382,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
myswprintf(textBuffer, dataManager.GetDesc(desc), dataManager.GetName(code)); myswprintf(textBuffer, dataManager.GetDesc(desc), dataManager.GetName(code));
} }
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, textBuffer); mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, textBuffer);
mainGame->PopupElement(mainGame->wQuery); mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
return false; return false;
...@@ -1390,7 +1392,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1390,7 +1392,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
int desc = BufferIO::ReadInt32(pbuf); int desc = BufferIO::ReadInt32(pbuf);
mainGame->dField.highlighting_card = 0; mainGame->dField.highlighting_card = 0;
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, (wchar_t*)dataManager.GetDesc(desc)); mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, (wchar_t*)dataManager.GetDesc(desc));
mainGame->PopupElement(mainGame->wQuery); mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
return false; return false;
...@@ -1642,7 +1644,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1642,7 +1644,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
myswprintf(textBuffer, L"%ls\n%ls", dataManager.GetSysString(201), dataManager.GetSysString(202)); myswprintf(textBuffer, L"%ls\n%ls", dataManager.GetSysString(201), dataManager.GetSysString(202));
else else
myswprintf(textBuffer, L"%ls\n%ls", event_string, dataManager.GetSysString(203)); myswprintf(textBuffer, L"%ls\n%ls", event_string, dataManager.GetSysString(203));
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, (wchar_t*)textBuffer); mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, (wchar_t*)textBuffer);
mainGame->PopupElement(mainGame->wQuery); mainGame->PopupElement(mainGame->wQuery);
} }
} }
...@@ -2349,6 +2351,8 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2349,6 +2351,8 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dInfo.is_swapped = !mainGame->dInfo.is_swapped; mainGame->dInfo.is_swapped = !mainGame->dInfo.is_swapped;
return true; return true;
} }
if(mainGame->wSurrender->isVisible())
mainGame->HideElement(mainGame->wSurrender);
if(!mainGame->dInfo.isReplay && mainGame->dInfo.player_type < 7) { if(!mainGame->dInfo.isReplay && mainGame->dInfo.player_type < 7) {
mainGame->btnLeaveGame->setText(dataManager.GetSysString(1351)); mainGame->btnLeaveGame->setText(dataManager.GetSysString(1351));
mainGame->btnLeaveGame->setVisible(true); mainGame->btnLeaveGame->setVisible(true);
...@@ -2811,6 +2815,16 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2811,6 +2815,16 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->showcarddif = 0; mainGame->showcarddif = 0;
mainGame->showcard = 1; mainGame->showcard = 1;
pcard->is_highlighting = true; pcard->is_highlighting = true;
if(pcard->location & 0x30) {
float shift = -0.15f;
if(cc == 1) shift = 0.15f;
pcard->dPos = irr::core::vector3df(shift, 0, 0);
pcard->dRot = irr::core::vector3df(0, 0, 0);
pcard->is_moving = true;
pcard->aniFrame = 5;
mainGame->WaitFrameSignal(30);
mainGame->dField.MoveCard(pcard, 5);
} else
mainGame->WaitFrameSignal(30); mainGame->WaitFrameSignal(30);
pcard->is_highlighting = false; pcard->is_highlighting = false;
mainGame->dField.current_chain.chain_card = pcard; mainGame->dField.current_chain.chain_card = pcard;
...@@ -2944,6 +2958,15 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2944,6 +2958,15 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dField.FadeCard(pcard, 255, 5); mainGame->dField.FadeCard(pcard, 255, 5);
mainGame->WaitFrameSignal(5); mainGame->WaitFrameSignal(5);
} }
} else if(pcard->location & 0x30) {
float shift = -0.15f;
if(c == 1) shift = 0.15f;
pcard->dPos = irr::core::vector3df(shift, 0, 0);
pcard->dRot = irr::core::vector3df(0, 0, 0);
pcard->is_moving = true;
pcard->aniFrame = 5;
mainGame->WaitFrameSignal(30);
mainGame->dField.MoveCard(pcard, 5);
} else } else
mainGame->WaitFrameSignal(30); mainGame->WaitFrameSignal(30);
myswprintf(textBuffer, dataManager.GetSysString(1610), dataManager.GetName(pcard->code), dataManager.FormatLocation(l, s), s + 1); myswprintf(textBuffer, dataManager.GetSysString(1610), dataManager.GetName(pcard->code), dataManager.FormatLocation(l, s), s + 1);
......
...@@ -147,8 +147,19 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -147,8 +147,19 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(exit_on_return) if(exit_on_return)
mainGame->device->closeDevice(); mainGame->device->closeDevice();
} else { } else {
mainGame->PopupElement(mainGame->wSurrender);
}
break;
}
case BUTTON_SURRENDER_YES: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
DuelClient::SendPacketToServer(CTOS_SURRENDER); DuelClient::SendPacketToServer(CTOS_SURRENDER);
mainGame->HideElement(mainGame->wSurrender);
break;
} }
case BUTTON_SURRENDER_NO: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
mainGame->HideElement(mainGame->wSurrender);
break; break;
} }
case BUTTON_CHAIN_IGNORE: { case BUTTON_CHAIN_IGNORE: {
...@@ -279,7 +290,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -279,7 +290,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->btnOptionn->setVisible(true); mainGame->btnOptionn->setVisible(true);
if(selected_option == 0) if(selected_option == 0)
mainGame->btnOptionp->setVisible(false); mainGame->btnOptionp->setVisible(false);
mainGame->SetStaticText(mainGame->stOptions, 310, mainGame->textFont, (wchar_t*)dataManager.GetDesc(select_options[selected_option])); mainGame->SetStaticText(mainGame->stOptions, 310, mainGame->guiFont, (wchar_t*)dataManager.GetDesc(select_options[selected_option]));
break; break;
} }
case BUTTON_OPTION_NEXT: { case BUTTON_OPTION_NEXT: {
...@@ -288,7 +299,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -288,7 +299,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->btnOptionp->setVisible(true); mainGame->btnOptionp->setVisible(true);
if(selected_option == select_options.size() - 1) if(selected_option == select_options.size() - 1)
mainGame->btnOptionn->setVisible(false); mainGame->btnOptionn->setVisible(false);
mainGame->SetStaticText(mainGame->stOptions, 310, mainGame->textFont, (wchar_t*)dataManager.GetDesc(select_options[selected_option])); mainGame->SetStaticText(mainGame->stOptions, 310, mainGame->guiFont, (wchar_t*)dataManager.GetDesc(select_options[selected_option]));
break; break;
} }
case BUTTON_OPTION_0: { case BUTTON_OPTION_0: {
...@@ -856,7 +867,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -856,7 +867,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
else if(conti_selecting) else if(conti_selecting)
mainGame->btnCardSelect[i]->setImage(imageManager.GetTexture(selectable_cards[i + pos]->chain_code)); mainGame->btnCardSelect[i]->setImage(imageManager.GetTexture(selectable_cards[i + pos]->chain_code));
else else
mainGame->btnCardSelect[i]->setImage(imageManager.tCover[selectable_cards[i + pos]->controler + 2], rect<s32>(0, 0, CARD_IMG_WIDTH, CARD_IMG_HEIGHT)); mainGame->btnCardSelect[i]->setImage(imageManager.tCover[selectable_cards[i + pos]->controler + 2]);
mainGame->btnCardSelect[i]->setRelativePosition(rect<s32>(30 + i * 125, 55, 30 + 120 + i * 125, 225)); mainGame->btnCardSelect[i]->setRelativePosition(rect<s32>(30 + i * 125, 55, 30 + 120 + i * 125, 225));
// text // text
wchar_t formatBuffer[2048]; wchar_t formatBuffer[2048];
...@@ -919,7 +930,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -919,7 +930,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(display_cards[i + pos]->code) if(display_cards[i + pos]->code)
mainGame->btnCardDisplay[i]->setImage(imageManager.GetTexture(display_cards[i + pos]->code)); mainGame->btnCardDisplay[i]->setImage(imageManager.GetTexture(display_cards[i + pos]->code));
else else
mainGame->btnCardDisplay[i]->setImage(imageManager.tCover[display_cards[i + pos]->controler + 2], rect<s32>(0, 0, CARD_IMG_WIDTH, CARD_IMG_HEIGHT)); mainGame->btnCardDisplay[i]->setImage(imageManager.tCover[display_cards[i + pos]->controler + 2]);
mainGame->btnCardDisplay[i]->setRelativePosition(rect<s32>(30 + i * 125, 55, 30 + 120 + i * 125, 225)); mainGame->btnCardDisplay[i]->setRelativePosition(rect<s32>(30 + i * 125, 55, 30 + 120 + i * 125, 225));
wchar_t formatBuffer[2048]; wchar_t formatBuffer[2048];
if(display_cards[i + pos]->location == LOCATION_OVERLAY) { if(display_cards[i + pos]->location == LOCATION_OVERLAY) {
...@@ -979,6 +990,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -979,6 +990,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(id >= BUTTON_CARD_0 && id <= BUTTON_CARD_4) { if(id >= BUTTON_CARD_0 && id <= BUTTON_CARD_4) {
int pos = mainGame->scrCardList->getPos() / 10; int pos = mainGame->scrCardList->getPos() / 10;
ClientCard* mcard = selectable_cards[id - BUTTON_CARD_0 + pos]; ClientCard* mcard = selectable_cards[id - BUTTON_CARD_0 + pos];
SetShowMark(mcard, true);
ShowCardInfoInList(mcard, mainGame->btnCardSelect[id - BUTTON_CARD_0], mainGame->wCardSelect);
if(mcard->code) { if(mcard->code) {
mainGame->ShowCardInfo(mcard->code); mainGame->ShowCardInfo(mcard->code);
} else { } else {
...@@ -988,12 +1001,35 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -988,12 +1001,35 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(id >= BUTTON_DISPLAY_0 && id <= BUTTON_DISPLAY_4) { if(id >= BUTTON_DISPLAY_0 && id <= BUTTON_DISPLAY_4) {
int pos = mainGame->scrDisplayList->getPos() / 10; int pos = mainGame->scrDisplayList->getPos() / 10;
ClientCard* mcard = display_cards[id - BUTTON_DISPLAY_0 + pos]; ClientCard* mcard = display_cards[id - BUTTON_DISPLAY_0 + pos];
SetShowMark(mcard, true);
ShowCardInfoInList(mcard, mainGame->btnCardDisplay[id - BUTTON_DISPLAY_0], mainGame->wCardDisplay);
if(mcard->code) { if(mcard->code) {
mainGame->ShowCardInfo(mcard->code); mainGame->ShowCardInfo(mcard->code);
} else { } else {
mainGame->ClearCardInfo(mcard->controler); mainGame->ClearCardInfo(mcard->controler);
} }
} }
if(id == TEXT_CARD_LIST_TIP) {
mainGame->stCardListTip->setVisible(true);
}
break;
}
case irr::gui::EGET_ELEMENT_LEFT: {
if(id >= BUTTON_CARD_0 && id <= BUTTON_CARD_4) {
int pos = mainGame->scrCardList->getPos() / 10;
ClientCard* mcard = selectable_cards[id - BUTTON_CARD_0 + pos];
SetShowMark(mcard, false);
mainGame->stCardListTip->setVisible(false);
}
if(id >= BUTTON_DISPLAY_0 && id <= BUTTON_DISPLAY_4) {
int pos = mainGame->scrDisplayList->getPos() / 10;
ClientCard* mcard = display_cards[id - BUTTON_DISPLAY_0 + pos];
SetShowMark(mcard, false);
mainGame->stCardListTip->setVisible(false);
}
if(id == TEXT_CARD_LIST_TIP) {
mainGame->stCardListTip->setVisible(false);
}
break; break;
} }
default: default:
...@@ -1409,6 +1445,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1409,6 +1445,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->chain_when_avail = false; mainGame->chain_when_avail = false;
UpdateChainButtons(); UpdateChainButtons();
} }
if(mainGame->wSurrender->isVisible())
mainGame->HideElement(mainGame->wSurrender);
mainGame->wCmdMenu->setVisible(false); mainGame->wCmdMenu->setVisible(false);
if(mainGame->fadingList.size()) if(mainGame->fadingList.size())
break; break;
...@@ -1889,6 +1927,18 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) { ...@@ -1889,6 +1927,18 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
break; break;
} }
#endif #endif
case SCROLL_TAB_HELPER: {
rect<s32> pos = mainGame->tabHelper->getRelativePosition();
mainGame->tabHelper->setRelativePosition(recti(0, mainGame->scrTabHelper->getPos() * -1, pos.LowerRightCorner.X, pos.LowerRightCorner.Y));
return true;
break;
}
case SCROLL_TAB_SYSTEM: {
rect<s32> pos = mainGame->tabSystem->getRelativePosition();
mainGame->tabSystem->setRelativePosition(recti(0, mainGame->scrTabSystem->getPos() * -1, pos.LowerRightCorner.X, pos.LowerRightCorner.Y));
return true;
break;
}
} }
break; break;
} }
...@@ -1897,8 +1947,6 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) { ...@@ -1897,8 +1947,6 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
case COMBOBOX_LOCALE: { case COMBOBOX_LOCALE: {
myswprintf(mainGame->gameConf.locale, L"%ls", mainGame->cbLocale->getItem(mainGame->cbLocale->getSelected())); myswprintf(mainGame->gameConf.locale, L"%ls", mainGame->cbLocale->getItem(mainGame->cbLocale->getSelected()));
mainGame->SaveConfig(); mainGame->SaveConfig();
return true;
break;
} }
} }
break; break;
...@@ -2272,6 +2320,39 @@ void ClientField::SetShowMark(ClientCard* pcard, bool enable) { ...@@ -2272,6 +2320,39 @@ void ClientField::SetShowMark(ClientCard* pcard, bool enable) {
chit->chain_card->is_showchaintarget = enable; chit->chain_card->is_showchaintarget = enable;
} }
} }
void ClientField::ShowCardInfoInList(ClientCard* pcard, irr::gui::IGUIElement* element, irr::gui::IGUIElement* parent) {
std::wstring str(L"");
if(pcard->code) {
str.append(dataManager.GetName(pcard->code));
}
for(size_t i = 0; i < chains.size(); ++i) {
wchar_t formatBuffer[2048];
auto chit = chains[i];
if(pcard == chit.chain_card) {
myswprintf(formatBuffer, dataManager.GetSysString(216), i + 1);
str.append(L"\n").append(formatBuffer);
}
if(chit.target.find(pcard) != chit.target.end()) {
myswprintf(formatBuffer, dataManager.GetSysString(217), i + 1, dataManager.GetName(chit.chain_card->code));
str.append(L"\n").append(formatBuffer);
}
}
if(str.length() > 0) {
parent->addChild(mainGame->stCardListTip);
irr::core::rect<s32> ePos = element->getRelativePosition();
s32 x = (ePos.UpperLeftCorner.X + ePos.LowerRightCorner.X) / 2;
s32 y = ePos.LowerRightCorner.Y;
mainGame->SetStaticText(mainGame->stCardListTip, 320, mainGame->guiFont, str.c_str());
irr::core::dimension2d<unsigned int> dTip = mainGame->guiFont->getDimension(mainGame->stCardListTip->getText()) + irr::core::dimension2d<unsigned int>(10, 10);
s32 w = dTip.Width / 2;
if(x - w < 10)
x = w + 10;
if(x + w > 670)
x = 670 - w;
mainGame->stCardListTip->setRelativePosition(recti(x - w, y - 10, x + w, y - 10 + dTip.Height));
mainGame->stCardListTip->setVisible(true);
}
}
void ClientField::SetResponseSelectedCards() const { void ClientField::SetResponseSelectedCards() const {
unsigned char respbuf[64]; unsigned char respbuf[64];
respbuf[0] = selected_cards.size(); respbuf[0] = selected_cards.size();
......
This diff is collapsed.
...@@ -174,7 +174,7 @@ public: ...@@ -174,7 +174,7 @@ public:
recti Resize(s32 x, s32 y, s32 x2, s32 y2, s32 dx, s32 dy, s32 dx2, s32 dy2); recti Resize(s32 x, s32 y, s32 x2, s32 y2, s32 dx, s32 dy, s32 dx2, s32 dy2);
position2di Resize(s32 x, s32 y); position2di Resize(s32 x, s32 y);
position2di ResizeReverse(s32 x, s32 y); position2di ResizeReverse(s32 x, s32 y);
recti ResizeElem(s32 x, s32 y, s32 x2, s32 y2); recti ResizePhaseHint(s32 x, s32 y, s32 x2, s32 y2, s32 width);
recti ResizeWin(s32 x, s32 y, s32 x2, s32 y2, bool chat = false); recti ResizeWin(s32 x, s32 y, s32 x2, s32 y2, bool chat = false);
recti ResizeCard(s32 x, s32 y, s32 x2, s32 y2); recti ResizeCard(s32 x, s32 y, s32 x2, s32 y2);
recti ResizeCardHint(s32 x, s32 y, s32 x2, s32 y2); recti ResizeCardHint(s32 x, s32 y, s32 x2, s32 y2);
...@@ -270,6 +270,7 @@ public: ...@@ -270,6 +270,7 @@ public:
//hint text //hint text
irr::gui::IGUIStaticText* stHintMsg; irr::gui::IGUIStaticText* stHintMsg;
irr::gui::IGUIStaticText* stTip; irr::gui::IGUIStaticText* stTip;
irr::gui::IGUIStaticText* stCardListTip;
//infos //infos
irr::gui::IGUITabControl* wInfos; irr::gui::IGUITabControl* wInfos;
irr::gui::IGUIStaticText* stName; irr::gui::IGUIStaticText* stName;
...@@ -281,12 +282,18 @@ public: ...@@ -281,12 +282,18 @@ public:
irr::gui::IGUIListBox* lstLog; irr::gui::IGUIListBox* lstLog;
irr::gui::IGUIButton* btnClearLog; irr::gui::IGUIButton* btnClearLog;
irr::gui::IGUIButton* btnSaveLog; irr::gui::IGUIButton* btnSaveLog;
irr::gui::IGUIWindow* tabHelper;
irr::gui::IGUIElement* elmTabHelperLast;
irr::gui::IGUIScrollBar* scrTabHelper;
irr::gui::IGUICheckBox* chkMAutoPos; irr::gui::IGUICheckBox* chkMAutoPos;
irr::gui::IGUICheckBox* chkSTAutoPos; irr::gui::IGUICheckBox* chkSTAutoPos;
irr::gui::IGUICheckBox* chkRandomPos; irr::gui::IGUICheckBox* chkRandomPos;
irr::gui::IGUICheckBox* chkAutoChain; irr::gui::IGUICheckBox* chkAutoChain;
irr::gui::IGUICheckBox* chkWaitChain; irr::gui::IGUICheckBox* chkWaitChain;
irr::gui::IGUICheckBox* chkQuickAnimation; irr::gui::IGUICheckBox* chkQuickAnimation;
irr::gui::IGUIWindow* tabSystem;
irr::gui::IGUIElement* elmTabSystemLast;
irr::gui::IGUIScrollBar* scrTabSystem;
irr::gui::IGUICheckBox* chkHideSetname; irr::gui::IGUICheckBox* chkHideSetname;
irr::gui::IGUICheckBox* chkHideHintButton; irr::gui::IGUICheckBox* chkHideHintButton;
irr::gui::IGUICheckBox* chkIgnoreDeckChanges; irr::gui::IGUICheckBox* chkIgnoreDeckChanges;
...@@ -394,6 +401,11 @@ public: ...@@ -394,6 +401,11 @@ public:
irr::gui::IGUIStaticText* stQMessage; irr::gui::IGUIStaticText* stQMessage;
irr::gui::IGUIButton* btnYes; irr::gui::IGUIButton* btnYes;
irr::gui::IGUIButton* btnNo; irr::gui::IGUIButton* btnNo;
//surrender yes/no
irr::gui::IGUIWindow* wSurrender;
irr::gui::IGUIStaticText* stSurrenderMessage;
irr::gui::IGUIButton* btnSurrenderYes;
irr::gui::IGUIButton* btnSurrenderNo;
//options //options
irr::gui::IGUIWindow* wOptions; irr::gui::IGUIWindow* wOptions;
irr::gui::IGUIStaticText* stOptions; irr::gui::IGUIStaticText* stOptions;
...@@ -622,6 +634,7 @@ extern Game* mainGame; ...@@ -622,6 +634,7 @@ extern Game* mainGame;
#define BUTTON_CARD_4 234 #define BUTTON_CARD_4 234
#define SCROLL_CARD_SELECT 235 #define SCROLL_CARD_SELECT 235
#define BUTTON_CARD_SEL_OK 236 #define BUTTON_CARD_SEL_OK 236
#define TEXT_CARD_LIST_TIP 237
#define BUTTON_CMD_ACTIVATE 240 #define BUTTON_CMD_ACTIVATE 240
#define BUTTON_CMD_SUMMON 241 #define BUTTON_CMD_SUMMON 241
#define BUTTON_CMD_SPSUMMON 242 #define BUTTON_CMD_SPSUMMON 242
...@@ -657,6 +670,8 @@ extern Game* mainGame; ...@@ -657,6 +670,8 @@ extern Game* mainGame;
#define BUTTON_DISPLAY_4 294 #define BUTTON_DISPLAY_4 294
#define SCROLL_CARD_DISPLAY 295 #define SCROLL_CARD_DISPLAY 295
#define BUTTON_CARD_DISP_OK 296 #define BUTTON_CARD_DISP_OK 296
#define BUTTON_SURRENDER_YES 297
#define BUTTON_SURRENDER_NO 298
#define BUTTON_CATEGORY_OK 300 #define BUTTON_CATEGORY_OK 300
#define COMBOBOX_DBLFLIST 301 #define COMBOBOX_DBLFLIST 301
#define COMBOBOX_DBDECKS 302 #define COMBOBOX_DBDECKS 302
...@@ -688,9 +703,11 @@ extern Game* mainGame; ...@@ -688,9 +703,11 @@ extern Game* mainGame;
#define BUTTON_BOT_START 340 #define BUTTON_BOT_START 340
#define LISTBOX_BOT_LIST 341 #define LISTBOX_BOT_LIST 341
#define CHECKBOX_BOT_OLD_RULE 342 #define CHECKBOX_BOT_OLD_RULE 342
#define LISTBOX_SINGLEPLAY_LIST 350 #define LISTBOX_SINGLEPLAY_LIST 343
#define BUTTON_LOAD_SINGLEPLAY 351 #define BUTTON_LOAD_SINGLEPLAY 344
#define BUTTON_CANCEL_SINGLEPLAY 352 #define BUTTON_CANCEL_SINGLEPLAY 345
#define SCROLL_TAB_HELPER 350
#define SCROLL_TAB_SYSTEM 351
#define CHECKBOX_AUTO_SEARCH 360 #define CHECKBOX_AUTO_SEARCH 360
#define CHECKBOX_ENABLE_SOUND 361 #define CHECKBOX_ENABLE_SOUND 361
#define CHECKBOX_ENABLE_MUSIC 362 #define CHECKBOX_ENABLE_MUSIC 362
......
...@@ -13,8 +13,14 @@ bool ImageManager::Initial() { ...@@ -13,8 +13,14 @@ bool ImageManager::Initial() {
tCover[0] = NULL; tCover[0] = NULL;
tCover[1] = NULL; tCover[1] = NULL;
tCover[2] = NULL; tCover[2] = GetRandomImage(TEXTURE_COVER_S, CARD_IMG_WIDTH, CARD_IMG_HEIGHT);
tCover[3] = NULL; if(!tCover[2])
tCover[2] = GetTextureFromFile("textures/cover.jpg", CARD_IMG_WIDTH, CARD_IMG_HEIGHT);
tCover[3] = GetRandomImage(TEXTURE_COVER_O, CARD_IMG_WIDTH, CARD_IMG_HEIGHT);
if(!tCover[3])
tCover[3] = GetTextureFromFile("textures/cover2.jpg", CARD_IMG_WIDTH, CARD_IMG_HEIGHT);
if(!tCover[3])
tCover[3] = tCover[2];
//tUnknown = NULL; //tUnknown = NULL;
tUnknown[0] = NULL; tUnknown[0] = NULL;
tUnknown[1] = NULL; tUnknown[1] = NULL;
...@@ -196,18 +202,6 @@ void ImageManager::ResizeTexture() { ...@@ -196,18 +202,6 @@ void ImageManager::ResizeTexture() {
tCover[1] = GetRandomImage(TEXTURE_COVER_S, imgWidth, imgHeight); tCover[1] = GetRandomImage(TEXTURE_COVER_S, imgWidth, imgHeight);
if(!tCover[1]) if(!tCover[1])
tCover[1] = tCover[0]; tCover[1] = tCover[0];
if(!tCover[2])
tCover[2] = GetRandomImage(TEXTURE_COVER_S, CARD_IMG_WIDTH, CARD_IMG_HEIGHT);
if(!tCover[2])
tCover[2] = GetTextureFromFile("textures/cover.jpg", CARD_IMG_WIDTH, CARD_IMG_HEIGHT);
if(!tCover[2])
tCover[2] = tCover[0];
if(!tCover[3])
tCover[3] = GetRandomImage(TEXTURE_COVER_O, CARD_IMG_WIDTH, CARD_IMG_HEIGHT);
if(!tCover[3])
tCover[3] = GetTextureFromFile("textures/cover2.jpg", CARD_IMG_WIDTH, CARD_IMG_HEIGHT);
if(!tCover[3])
tCover[3] = tCover[2];
//driver->removeTexture(tUnknown); //driver->removeTexture(tUnknown);
//tUnknown = GetTextureFromFile("textures/unknown.jpg", imgWidth, imgHeight); //tUnknown = GetTextureFromFile("textures/unknown.jpg", imgWidth, imgHeight);
driver->removeTexture(tBackGround); driver->removeTexture(tBackGround);
......
project (clzma)
set (AUTO_FILES_RESULT)
AutoFiles("." "src" "\\.(cpp|c|h)$")
add_library (clzma STATIC ${AUTO_FILES_RESULT})
...@@ -248,7 +248,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -248,7 +248,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
wchar_t textBuffer[256]; wchar_t textBuffer[256];
myswprintf(textBuffer, L"%ls\n%ls", mainGame->lstReplayList->getListItem(sel), dataManager.GetSysString(1363)); myswprintf(textBuffer, L"%ls\n%ls", mainGame->lstReplayList->getListItem(sel), dataManager.GetSysString(1363));
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, (wchar_t*)textBuffer); mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, (wchar_t*)textBuffer);
mainGame->PopupElement(mainGame->wQuery); mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
prev_operation = id; prev_operation = id;
......
...@@ -33,7 +33,7 @@ project "ygopro" ...@@ -33,7 +33,7 @@ project "ygopro"
configuration "not vs*" configuration "not vs*"
buildoptions { "-std=c++14", "-fno-rtti" } buildoptions { "-std=c++14", "-fno-rtti" }
configuration "not windows" configuration "not windows"
includedirs { "/usr/include/lua", "/usr/include/lua5.3", "/usr/include/lua/5.3", "/usr/include/irrlicht", "/usr/include/freetype2" } includedirs { "/usr/include/irrlicht", "/usr/include/freetype2" }
excludes { "COSOperator.*" } excludes { "COSOperator.*" }
links { "event_pthreads", "GL", "dl", "pthread" } links { "event_pthreads", "GL", "dl", "pthread" }
configuration "linux" configuration "linux"
......
...@@ -221,6 +221,8 @@ void SoundManager::PlayDialogSound(irr::gui::IGUIElement * element) { ...@@ -221,6 +221,8 @@ void SoundManager::PlayDialogSound(irr::gui::IGUIElement * element) {
PlaySoundEffect(SOUND_INFO); PlaySoundEffect(SOUND_INFO);
} else if(element == mainGame->wQuery) { } else if(element == mainGame->wQuery) {
PlaySoundEffect(SOUND_QUESTION); PlaySoundEffect(SOUND_QUESTION);
} else if(element == mainGame->wSurrender) {
PlaySoundEffect(SOUND_QUESTION);
} else if(element == mainGame->wOptions) { } else if(element == mainGame->wOptions) {
PlaySoundEffect(SOUND_QUESTION); PlaySoundEffect(SOUND_QUESTION);
} else if(element == mainGame->wANAttribute) { } else if(element == mainGame->wANAttribute) {
......
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "irrKlang" library.
// For conditions of distribution and use, see copyright notice in irrKlang.h
#include "CIrrKlangAudioStreamLoaderMP3.h"
#include "CIrrKlangAudioStreamMP3.h"
#include <string.h>
namespace irrklang
{
CIrrKlangAudioStreamLoaderMP3::CIrrKlangAudioStreamLoaderMP3()
{
}
//! Returns true if the file maybe is able to be loaded by this class.
bool CIrrKlangAudioStreamLoaderMP3::isALoadableFileExtension(const ik_c8* fileName)
{
return strstr(fileName, ".mp3") != 0;
}
//! Creates an audio file input stream from a file
IAudioStream* CIrrKlangAudioStreamLoaderMP3::createAudioStream(irrklang::IFileReader* file)
{
CIrrKlangAudioStreamMP3* stream = new CIrrKlangAudioStreamMP3(file);
if (stream && !stream->isOK())
{
stream->drop();
stream = 0;
}
return stream;
}
} // end namespace irrklang
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "irrKlang" library.
// For conditions of distribution and use, see copyright notice in irrKlang.h
#ifndef __C_IRRKLANG_AUDIO_STREAM_LOADER_MP3_H_INCLUDED__
#define __C_IRRKLANG_AUDIO_STREAM_LOADER_MP3_H_INCLUDED__
#include <ik_IAudioStreamLoader.h>
namespace irrklang
{
//! Class which is able to create an audio file stream from a file.
class CIrrKlangAudioStreamLoaderMP3 : public IAudioStreamLoader
{
public:
CIrrKlangAudioStreamLoaderMP3();
//! Returns true if the file maybe is able to be loaded by this class.
/** This decision should be based only on the file extension (e.g. ".wav") */
virtual bool isALoadableFileExtension(const ik_c8* fileName);
//! Creates an audio file input stream from a file
/** \return Pointer to the created audio stream. Returns 0 if loading failed.
If you no longer need the stream, you should call IAudioFileStream::drop().
See IRefCounted::drop() for more information. */
virtual IAudioStream* createAudioStream(irrklang::IFileReader* file);
};
} // end namespace irrklang
#endif
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// Part of the code for this plugin for irrKlang is based on:
// MP3 input for Audiere by Matt Campbell <mattcampbell@pobox.com>, based on
// libavcodec from ffmpeg (http://ffmpeg.sourceforge.net/).
// See license.txt for license details of this plugin.
#include "CIrrKlangAudioStreamMP3.h"
#include <memory.h>
#include <stdlib.h> // free, malloc and realloc
#include <string.h>
#include <algorithm>
namespace irrklang
{
CIrrKlangAudioStreamMP3::CIrrKlangAudioStreamMP3(IFileReader* file)
: File(file), TheMPAuDecContext(0), InputPosition(0), InputLength(0),
DecodeBuffer(0), FirstFrameRead(false), EndOfFileReached(0),
FileBegin(0), Position(0)
{
if (File)
{
File->grab();
TheMPAuDecContext = new MPAuDecContext();
if (!TheMPAuDecContext || mpaudec_init(TheMPAuDecContext) < 0)
{
File->drop();
File = 0;
delete TheMPAuDecContext;
TheMPAuDecContext = 0;
return;
}
// init, get format
DecodeBuffer = new ik_u8[MPAUDEC_MAX_AUDIO_FRAME_SIZE];
if (File->getSize()>0)
{
// seekable file, now parse file to get size
// (needed to make it possible for the engine to loop a stream correctly)
skipID3IfNecessary();
TheMPAuDecContext->parse_only = 1;
Format.FrameCount = 0;
while(!EndOfFileReached)
{
if (!decodeFrame())
break;
Format.FrameCount += TheMPAuDecContext->frame_size;
if (!EndOfFileReached /*&& File->isSeekable()*/ )
{
// to be able to seek in the stream, store offsets and sizes
SFramePositionData data;
data.size = TheMPAuDecContext->frame_size;
data.offset = File->getPos() - (InputLength - InputPosition) - TheMPAuDecContext->coded_frame_size;
FramePositionData.push_back(data);
}
}
TheMPAuDecContext->parse_only = 0;
setPosition(0);
}
else
decodeFrame(); // decode first frame to read audio format
if (!TheMPAuDecContext->channels ||
!TheMPAuDecContext->sample_rate )
{
File->drop();
File = 0;
delete TheMPAuDecContext;
TheMPAuDecContext = 0;
return;
}
}
}
CIrrKlangAudioStreamMP3::~CIrrKlangAudioStreamMP3()
{
if (File)
File->drop();
if (TheMPAuDecContext)
{
mpaudec_clear(TheMPAuDecContext);
delete TheMPAuDecContext;
}
delete [] DecodeBuffer;
}
//! returns format of the audio stream
SAudioStreamFormat CIrrKlangAudioStreamMP3::getFormat()
{
return Format;
}
//! tells the audio stream to read n audio frames into the specified buffer
ik_s32 CIrrKlangAudioStreamMP3::readFrames(void* target, ik_s32 frameCountToRead)
{
const int frameSize = Format.getFrameSize();
int framesRead = 0;
ik_u8* out = (ik_u8*)target;
while (framesRead < frameCountToRead)
{
// no more samples? ask the MP3 for more
if (DecodedQueue.getSize() < frameSize)
{
if (!decodeFrame() || EndOfFileReached)
return framesRead;
// if the buffer is still empty, we are done
if (DecodedQueue.getSize() < frameSize)
return framesRead;
}
const int framesLeft = frameCountToRead - framesRead;
const int dequeSize = DecodedQueue.getSize() / frameSize;
const int framesToRead = framesLeft < dequeSize ? framesLeft : dequeSize;
DecodedQueue.read(out, framesToRead * frameSize);
out += framesToRead * frameSize;
framesRead += framesToRead;
Position += framesToRead;
}
return framesRead;
}
bool CIrrKlangAudioStreamMP3::decodeFrame()
{
int outputSize = 0;
while (!outputSize)
{
if (InputPosition == InputLength)
{
InputPosition = 0;
InputLength = File->read(InputBuffer, IKP_MP3_INPUT_BUFFER_SIZE);
if (InputLength == 0)
{
EndOfFileReached = true;
return true;
}
}
int rv = mpaudec_decode_frame( TheMPAuDecContext, (ik_s16*)DecodeBuffer,
&outputSize,
(ik_u8*)InputBuffer + InputPosition,
InputLength - InputPosition);
if (rv < 0)
return false;
InputPosition += rv;
} // end while
if (!FirstFrameRead)
{
Format.ChannelCount = TheMPAuDecContext->channels;
Format.SampleRate = TheMPAuDecContext->sample_rate;
Format.SampleFormat = ESF_S16;
Format.FrameCount = -1; // unknown lenght
FirstFrameRead = true;
}
else
if (TheMPAuDecContext->channels != Format.ChannelCount ||
TheMPAuDecContext->sample_rate != Format.SampleRate)
{
// Can't handle format changes mid-stream.
return false;
}
if (!TheMPAuDecContext->parse_only)
{
if (outputSize < 0)
{
// Couldn't decode this frame. Too bad, already lost it.
// This should only happen when seeking.
outputSize = TheMPAuDecContext->frame_size;
memset(DecodeBuffer, 0, outputSize * Format.getFrameSize());
}
DecodedQueue.write(DecodeBuffer, outputSize);
}
return true;
}
//! sets the position of the audio stream.
/** For example to let the stream be read from the beginning of the file again,
setPosition(0) would be called. This is usually done be the sound engine to
loop a stream after if has reached the end. Return true if sucessful and 0 if not. */
bool CIrrKlangAudioStreamMP3::setPosition(ik_s32 pos)
{
if (!File || !TheMPAuDecContext)
return false;
if (pos == 0)
{
// usually done for looping, just reset to start
File->seek(FileBegin); // skip possible ID3 header
EndOfFileReached = false;
DecodedQueue.clear();
MPAuDecContext oldContext = *TheMPAuDecContext;
mpaudec_clear(TheMPAuDecContext);
mpaudec_init(TheMPAuDecContext);
TheMPAuDecContext->bit_rate = oldContext.bit_rate;
TheMPAuDecContext->channels = oldContext.channels;
TheMPAuDecContext->frame_size = oldContext.frame_size;
TheMPAuDecContext->sample_rate = oldContext.sample_rate;
InputPosition = 0;
InputLength = 0;
Position = 0;
CurrentFramePosition = 0;
return true;
}
else
{
// user wants to seek in the stream, so do this here
int scan_position = 0;
int target_frame = 0;
int frame_count = (int)FramePositionData.size();
while (target_frame < frame_count)
{
int frame_size = FramePositionData[target_frame].size;
if (pos <= scan_position + frame_size)
break;
else
{
scan_position += frame_size;
target_frame++;
}
}
const int MAX_FRAME_DEPENDENCY = 10;
target_frame = std::max(0, target_frame - MAX_FRAME_DEPENDENCY);
setPosition(0);
File->seek(FramePositionData[target_frame].offset, false);
int i;
for (i = 0; i < target_frame; i++)
{
if (i>=(int)FramePositionData.size())
{
// internal error
setPosition(0);
return false;
}
Position += FramePositionData[i].size;
}
if (!decodeFrame() || EndOfFileReached)
{
setPosition(0);
return false;
}
int frames_to_consume = pos - Position; // PCM frames now
if (frames_to_consume > 0)
{
ik_u8 *buf = new ik_u8[frames_to_consume * Format.getFrameSize()];
readFrames(buf, frames_to_consume);
delete[] buf;
}
return true;
}
return false;
}
CIrrKlangAudioStreamMP3::QueueBuffer::QueueBuffer()
{
Capacity = 256;
Size = 0;
Buffer = (ik_u8*)malloc(Capacity);
}
CIrrKlangAudioStreamMP3::QueueBuffer::~QueueBuffer()
{
free(Buffer);
}
int CIrrKlangAudioStreamMP3::QueueBuffer::getSize()
{
return Size;
}
void CIrrKlangAudioStreamMP3::QueueBuffer::write(const void* buffer, int size)
{
bool needRealloc = false;
while (size + Size > Capacity)
{
Capacity *= 2;
needRealloc = true;
}
if (needRealloc)
{
Buffer = (ik_u8*)realloc(Buffer, Capacity);
}
memcpy(Buffer + Size, buffer, size);
Size += size;
}
int CIrrKlangAudioStreamMP3::QueueBuffer::read(void* buffer, int size)
{
int toRead = size < Size ? size : Size;
memcpy(buffer, Buffer, toRead);
memmove(Buffer, Buffer + toRead, Size - toRead);
Size -= toRead;
return toRead;
}
void CIrrKlangAudioStreamMP3::QueueBuffer::clear()
{
Size = 0;
}
void CIrrKlangAudioStreamMP3::skipID3IfNecessary()
{
char header[10];
int read = File->read(&header, 10);
if (read == 10 &&
header[0] == 'I' && header[1] == 'D' && header[2] == '3')
{
int versionMajor = header[3];
int versionMinor = header[4];
int flags = header[5];
// IDv2 size looks like the following: ID3v2 size 4 * %0xxxxxxx.
// Sick, but that's how it works.
int size = 0;
size = (header[6] & 0x7f) << (3*7);
size |= (header[7] & 0x7f) << (2*7);
size |= (header[8] & 0x7f) << (1*7);
size |= (header[9] & 0x7f) ;
size += 10; // header size
FileBegin = size;
File->seek(FileBegin);
}
else
File->seek(0);
}
} // end namespace irrklang
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// Part of the code for this plugin for irrKlang is based on:
// MP3 input for Audiere by Matt Campbell <mattcampbell@pobox.com>, based on
// libavcodec from ffmpeg (http://ffmpeg.sourceforge.net/).
// See license.txt for license details of this plugin.
#ifndef __C_IRRKLANG_AUDIO_STREAM_MP3_H_INCLUDED__
#define __C_IRRKLANG_AUDIO_STREAM_MP3_H_INCLUDED__
#include <ik_IAudioStream.h>
#include <ik_IFileReader.h>
#include <vector>
#include "decoder/mpaudec.h"
namespace irrklang
{
const int IKP_MP3_INPUT_BUFFER_SIZE = 4096;
//! Reads and decodes audio data into an usable audio stream for the ISoundEngine
/** To extend irrKlang with new audio format decoders, the only thing needed to do
is implementing the IAudioStream interface. All the code available in this class is only for
mp3 decoding and may make this class look a bit more complicated then it actually is. */
class CIrrKlangAudioStreamMP3 : public IAudioStream
{
public:
CIrrKlangAudioStreamMP3(IFileReader* file);
~CIrrKlangAudioStreamMP3();
//! returns format of the audio stream
virtual SAudioStreamFormat getFormat();
//! tells the audio stream to read n audio frames into the specified buffer
/** \param target: Target data buffer to the method will write the read frames into. The
specified buffer will be getFormat().getFrameSize()*frameCount big.
\param frameCount: amount of frames to be read.
\returns Returns amount of frames really read. Should be frameCountToRead in most cases. */
virtual ik_s32 readFrames(void* target, ik_s32 frameCountToRead);
//! sets the position of the audio stream.
/** For example to let the stream be read from the beginning of the file again,
setPosition(0) would be called. This is usually done be the sound engine to
loop a stream after if has reached the end. Return true if sucessful and 0 if not. */
virtual bool setPosition(ik_s32 pos);
// just for the CIrrKlangAudioStreamLoaderMP3 to let him know if loading worked
bool isOK() { return File != 0; }
protected:
ik_s32 readFrameForMP3(void* target, ik_s32 frameCountToRead, bool parseOnly=false);
bool decodeFrame();
void skipID3IfNecessary();
irrklang::IFileReader* File;
SAudioStreamFormat Format;
// mpaudec specific
MPAuDecContext* TheMPAuDecContext;
ik_u8 InputBuffer[IKP_MP3_INPUT_BUFFER_SIZE];
int InputPosition;
int InputLength;
int Position;
ik_u8* DecodeBuffer;
ik_s32 FileBegin;
ik_u32 CurrentFramePosition;
bool FirstFrameRead;
bool EndOfFileReached;
// helper class for managing the streaming decoded audio data
class QueueBuffer
{
public:
QueueBuffer();
~QueueBuffer();
int getSize();
void write(const void* buffer, int size);
int read(void* buffer, int size);
void clear();
private:
ik_u8* Buffer;
int Capacity;
int Size;
};
struct SFramePositionData
{
int offset;
int size;
};
std::vector<SFramePositionData> FramePositionData;
QueueBuffer DecodedQueue;
};
} // end namespace irrklang
#endif
/*
* Common bit i/o utils
* Copyright (c) 2000, 2001 Fabrice Bellard.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Modified by Matt Campbell <mattcampbell@pobox.com> for the stand-alone
* mpaudec library. Based on common.c from libavcodec.
*/
#include "internal.h"
/**
* init GetBitContext.
* @param buffer bitstream buffer
* @param bit_size the size of the buffer in bits
*/
void init_get_bits(GetBitContext *s,
const uint8_t *buffer, int bit_size)
{
s->buffer= buffer;
s->size_in_bits= bit_size;
s->index=0;
}
unsigned int show_bits(const GetBitContext *s, int n)
{
int i;
unsigned int result = 0;
assert(s->size_in_bits - s->index >= n);
for (i = s->index; i < s->index + n; i++) {
int byte_index = i / 8;
unsigned int right_shift = 7 - (i % 8);
uint8_t byte = s->buffer[byte_index];
uint8_t bit;
result <<= 1;
if (right_shift == 0)
bit = byte & 0x1;
else
bit = (byte >> right_shift) & 0x1;
result |= (unsigned int)bit;
}
return result;
}
void skip_bits(GetBitContext *s, int n)
{
s->index += n;
}
unsigned int get_bits(GetBitContext *s, int n)
{
unsigned int result = show_bits(s, n);
skip_bits(s, n);
return result;
}
int get_bits_count(const GetBitContext *s)
{
return s->index;
}
/* VLC decoding */
/*#define DEBUG_VLC*/
#define GET_DATA(v, table, i, wrap, size) \
{\
const uint8_t *ptr = (const uint8_t *)table + i * wrap;\
switch(size) {\
case 1:\
v = *(const uint8_t *)ptr;\
break;\
case 2:\
v = *(const uint16_t *)ptr;\
break;\
default:\
v = *(const uint32_t *)ptr;\
break;\
}\
}
static int alloc_table(VLC *vlc, int size)
{
int index;
index = vlc->table_size;
vlc->table_size += size;
if (vlc->table_size > vlc->table_allocated) {
vlc->table_allocated += (1 << vlc->bits);
vlc->table = realloc(vlc->table,
sizeof(VLC_TYPE) * 2 * vlc->table_allocated);
if (!vlc->table)
return -1;
}
return index;
}
static int build_table(VLC *vlc, int table_nb_bits,
int nb_codes,
const void *bits, int bits_wrap, int bits_size,
const void *codes, int codes_wrap, int codes_size,
uint32_t code_prefix, int n_prefix)
{
int i, j, k, n, table_size, table_index, nb, n1, index;
uint32_t code;
VLC_TYPE (*table)[2];
table_size = 1 << table_nb_bits;
table_index = alloc_table(vlc, table_size);
#ifdef DEBUG_VLC
printf("new table index=%d size=%d code_prefix=%x n=%d\n",
table_index, table_size, code_prefix, n_prefix);
#endif
if (table_index < 0)
return -1;
table = &vlc->table[table_index];
for(i=0;i<table_size;i++) {
table[i][1] = 0; /*bits*/
table[i][0] = -1; /*codes*/
}
/* first pass: map codes and compute auxillary table sizes */
for(i=0;i<nb_codes;i++) {
GET_DATA(n, bits, i, bits_wrap, bits_size);
GET_DATA(code, codes, i, codes_wrap, codes_size);
/* we accept tables with holes */
if (n <= 0)
continue;
#if defined(DEBUG_VLC) && 0
printf("i=%d n=%d code=0x%x\n", i, n, code);
#endif
/* if code matches the prefix, it is in the table */
n -= n_prefix;
if (n > 0 && (code >> n) == code_prefix) {
if (n <= table_nb_bits) {
/* no need to add another table */
j = (code << (table_nb_bits - n)) & (table_size - 1);
nb = 1 << (table_nb_bits - n);
for(k=0;k<nb;k++) {
#ifdef DEBUG_VLC
printf("%4x: code=%d n=%d\n",
j, i, n);
#endif
assert(table[j][1] /*bits*/ == 0);
table[j][1] = n; /*bits*/
table[j][0] = i; /*code*/
j++;
}
} else {
n -= table_nb_bits;
j = (code >> n) & ((1 << table_nb_bits) - 1);
#ifdef DEBUG_VLC
printf("%4x: n=%d (subtable)\n",
j, n);
#endif
/* compute table size */
n1 = -table[j][1]; /*bits*/
if (n > n1)
n1 = n;
table[j][1] = -n1; /*bits*/
}
}
}
/* second pass : fill auxillary tables recursively */
for(i=0;i<table_size;i++) {
n = table[i][1]; /*bits*/
if (n < 0) {
n = -n;
if (n > table_nb_bits) {
n = table_nb_bits;
table[i][1] = -n; /*bits*/
}
index = build_table(vlc, n, nb_codes,
bits, bits_wrap, bits_size,
codes, codes_wrap, codes_size,
(code_prefix << table_nb_bits) | i,
n_prefix + table_nb_bits);
if (index < 0)
return -1;
/* note: realloc has been done, so reload tables */
table = &vlc->table[table_index];
table[i][0] = index; /*code*/
}
}
return table_index;
}
/* Build VLC decoding tables suitable for use with get_vlc().
'nb_bits' set thee decoding table size (2^nb_bits) entries. The
bigger it is, the faster is the decoding. But it should not be too
big to save memory and L1 cache. '9' is a good compromise.
'nb_codes' : number of vlcs codes
'bits' : table which gives the size (in bits) of each vlc code.
'codes' : table which gives the bit pattern of of each vlc code.
'xxx_wrap' : give the number of bytes between each entry of the
'bits' or 'codes' tables.
'xxx_size' : gives the number of bytes of each entry of the 'bits'
or 'codes' tables.
'wrap' and 'size' allows to use any memory configuration and types
(byte/word/long) to store the 'bits' and 'codes' tables.
*/
int init_vlc(VLC *vlc, int nb_bits, int nb_codes,
const void *bits, int bits_wrap, int bits_size,
const void *codes, int codes_wrap, int codes_size)
{
vlc->bits = nb_bits;
vlc->table = NULL;
vlc->table_allocated = 0;
vlc->table_size = 0;
#ifdef DEBUG_VLC
printf("build table nb_codes=%d\n", nb_codes);
#endif
if (build_table(vlc, nb_bits, nb_codes,
bits, bits_wrap, bits_size,
codes, codes_wrap, codes_size,
0, 0) < 0) {
free(vlc->table);
return -1;
}
return 0;
}
void free_vlc(VLC *vlc)
{
free(vlc->table);
}
int get_vlc(GetBitContext *s, const VLC *vlc)
{
int code = 0;
int depth = 0, max_depth = 3;
int n, index, bits = vlc->bits;
do {
index = show_bits(s, bits) + code;
code = vlc->table[index][0];
n = vlc->table[index][1];
depth++;
if (n < 0 && depth < max_depth) {
skip_bits(s, bits);
bits = -n;
}
} while (n < 0 && depth < max_depth);
skip_bits(s, n);
return code;
}
/* Based on common.h from libavcodec. Modified extensively by Matt Campbell
<mattcampbell@pobox.com> for the stand-alone mpaudec library. */
#ifndef INTERNAL_H
#define INTERNAL_H
#if defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
# define CONFIG_WIN32
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <stddef.h>
#include "mpaudec.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifdef CONFIG_WIN32
/* windows */
typedef unsigned short uint16_t;
typedef signed short int16_t;
typedef unsigned char uint8_t;
typedef unsigned int uint32_t;
typedef unsigned __int64 uint64_t;
typedef signed char int8_t;
typedef signed int int32_t;
typedef signed __int64 int64_t;
# ifdef _DEBUG
# define DEBUG
# endif
/* CONFIG_WIN32 end */
#else
/* unix */
#include <inttypes.h>
#endif /* !CONFIG_WIN32 */
/* debug stuff */
#if !defined(DEBUG) && !defined(NDEBUG)
# define NDEBUG
#endif
#include <assert.h>
/* bit input */
typedef struct GetBitContext {
const uint8_t *buffer;
int index;
int size_in_bits;
} GetBitContext;
int get_bits_count(const GetBitContext *s);
#define VLC_TYPE int16_t
typedef struct VLC {
int bits;
VLC_TYPE (*table)[2];
int table_size, table_allocated;
} VLC;
unsigned int get_bits(GetBitContext *s, int n);
unsigned int show_bits(const GetBitContext *s, int n);
void skip_bits(GetBitContext *s, int n);
void init_get_bits(GetBitContext *s,
const uint8_t *buffer, int buffer_size);
int init_vlc(VLC *vlc, int nb_bits, int nb_codes,
const void *bits, int bits_wrap, int bits_size,
const void *codes, int codes_wrap, int codes_size);
void free_vlc(VLC *vlc);
int get_vlc(GetBitContext *s, const VLC *vlc);
#endif /* INTERNAL_H */
This diff is collapsed.
/* Portions based on avcodec.h from libavcodec. */
#ifndef MPAUDEC_H
#define MPAUDEC_H
#ifdef __cplusplus
extern "C" {
#endif
/* in bytes */
#define MPAUDEC_MAX_AUDIO_FRAME_SIZE 4608
typedef struct MPAuDecContext {
int bit_rate;
int layer;
int sample_rate;
int channels;
int frame_size;
void *priv_data;
int parse_only;
int coded_frame_size;
} MPAuDecContext;
int mpaudec_init(MPAuDecContext *mpctx);
int mpaudec_decode_frame(MPAuDecContext * mpctx,
void *data, int *data_size,
const unsigned char * buf, int buf_size);
void mpaudec_clear(MPAuDecContext *mpctx);
#ifdef __cplusplus
}
#endif
#endif /* MPAUDEC_H */
This diff is collapsed.
/* Modified slightly by Matt Campbell <mattcampbell@pobox.com> for the
stand-alone mpaudec library. Based on mpegaudio.h from libavcodec. */
/* max frame size, in samples */
#define MPA_FRAME_SIZE 1152
/* max compressed frame size */
#define MPA_MAX_CODED_FRAME_SIZE 1792
#define MPA_MAX_CHANNELS 2
#define SBLIMIT 32 /* number of subbands */
#define MPA_STEREO 0
#define MPA_JSTEREO 1
#define MPA_DUAL 2
#define MPA_MONO 3
#include <irrKlang.h>
#include <stdio.h>
#include <string.h>
#include "CIrrKlangAudioStreamLoaderMP3.h"
using namespace irrklang;
#ifdef WIN32
// Windows version
extern "C" __declspec(dllexport) void ikpMP3Init(ISoundEngine* engine)
#else
// Linux version
extern "C" void ikpMP3Init(ISoundEngine* engine)
#endif
{
// create and register the loader
CIrrKlangAudioStreamLoaderMP3* loader = new CIrrKlangAudioStreamLoaderMP3();
engine->registerAudioStreamLoader(loader);
loader->drop();
// that's it, that's all.
}
#include <irrKlang.h>
namespace irrklang
{
#ifdef WIN32
// Windows version
extern "C" __declspec(dllexport) void ikpMP3Init(ISoundEngine* engine);
#else
// Linux version
extern "C" void ikpMP3Init(ISoundEngine* engine);
#endif
}
\ No newline at end of file
diff -ur ikpmp3/CIrrKlangAudioStreamMP3.cpp ikpmp3-static/CIrrKlangAudioStreamMP3.cpp
--- ikpmp3/CIrrKlangAudioStreamMP3.cpp 2009-01-02 07:33:40.000000000 +0800
+++ ikpmp3-static/CIrrKlangAudioStreamMP3.cpp 2017-11-27 19:18:34.295546800 +0800
@@ -8,6 +8,7 @@
#include <memory.h>
#include <stdlib.h> // free, malloc and realloc
#include <string.h>
+#include <algorithm>
namespace irrklang
{
diff -ur ikpmp3/ikpMP3.cpp ikpmp3-static/ikpMP3.cpp
--- ikpmp3/ikpMP3.cpp 2007-10-28 18:14:00.000000000 +0800
+++ ikpmp3-static/ikpMP3.cpp 2017-11-27 19:49:02.119092400 +0800
@@ -6,30 +6,14 @@
using namespace irrklang;
-// this is the only function needed to be implemented for the plugin, it gets
-// called by irrKlang when loaded.
-// In this plugin, we create an audiostream loader class and register
-// it at the engine, but a plugin can do anything.
-// Be sure to name the function 'irrKlangPluginInit' and let the dll start with 'ikp'.
-
#ifdef WIN32
// Windows version
-__declspec(dllexport) void __stdcall irrKlangPluginInit(ISoundEngine* engine, const char* version)
+extern "C" __declspec(dllexport) void ikpMP3Init(ISoundEngine* engine)
#else
// Linux version
-void irrKlangPluginInit(ISoundEngine* engine, const char* version)
+extern "C" void ikpMP3Init(ISoundEngine* engine)
#endif
{
- // do some version security check to be sure that this plugin isn't begin used
- // by some newer irrKlang version with changed interfaces which could possibily
- // cause crashes.
-
- if (strcmp(version, IRR_KLANG_VERSION))
- {
- printf("This MP3 plugin only supports irrKlang version %s, mp3 playback disabled.\n", IRR_KLANG_VERSION);
- return;
- }
-
// create and register the loader
CIrrKlangAudioStreamLoaderMP3* loader = new CIrrKlangAudioStreamLoaderMP3();
This diff is collapsed.
project "ikpmp3"
kind "StaticLib"
files { "*.cpp", "*.h", "decoder/*.c", "decoder/*.h" }
includedirs { "../irrklang/include" }
ikpMP3 is a plugin for irrKlang.
Copyright (C) 2002-2007 Nikolaus Gebhardt
Part of the code for this plugin for irrKlang is based on:
MP3 input for Audiere by Matt Campbell <mattcampbell@pobox.com>, based on
libavcodec from ffmpeg (http://ffmpeg.sourceforge.net/).
See license.txt for license details of this plugin.
project (lua)
set (AUTO_FILES_RESULT)
AutoFiles("." "src" "\\.(cpp|c|h)$" "lua.c|luac.c")
set_source_files_properties(${AUTO_FILES_RESULT} PROPERTIES LANGUAGE CXX)
add_library (lua STATIC ${AUTO_FILES_RESULT})
This diff is collapsed.
/*
** $Id: lapi.h,v 2.9.1.1 2017/04/19 17:20:42 roberto Exp $
** Auxiliary functions from Lua API
** See Copyright Notice in lua.h
*/
#ifndef lapi_h
#define lapi_h
#include "llimits.h"
#include "lstate.h"
#define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \
"stack overflow");}
#define adjustresults(L,nres) \
{ if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; }
#define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \
"not enough elements in the stack")
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
** $Id: lcode.h,v 1.64.1.1 2017/04/19 17:20:42 roberto Exp $
** Code generator for Lua
** See Copyright Notice in lua.h
*/
#ifndef lcode_h
#define lcode_h
#include "llex.h"
#include "lobject.h"
#include "lopcodes.h"
#include "lparser.h"
/*
** Marks the end of a patch list. It is an invalid value both as an absolute
** address, and as a list link (would link an element to itself).
*/
#define NO_JUMP (-1)
/*
** grep "ORDER OPR" if you change these enums (ORDER OP)
*/
typedef enum BinOpr {
OPR_ADD, OPR_SUB, OPR_MUL, OPR_MOD, OPR_POW,
OPR_DIV,
OPR_IDIV,
OPR_BAND, OPR_BOR, OPR_BXOR,
OPR_SHL, OPR_SHR,
OPR_CONCAT,
OPR_EQ, OPR_LT, OPR_LE,
OPR_NE, OPR_GT, OPR_GE,
OPR_AND, OPR_OR,
OPR_NOBINOPR
} BinOpr;
typedef enum UnOpr { OPR_MINUS, OPR_BNOT, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr;
/* get (pointer to) instruction of given 'expdesc' */
#define getinstruction(fs,e) ((fs)->f->code[(e)->u.info])
#define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx)
#define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET)
#define luaK_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t)
LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx);
LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C);
LUAI_FUNC int luaK_codek (FuncState *fs, int reg, int k);
LUAI_FUNC void luaK_fixline (FuncState *fs, int line);
LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n);
LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n);
LUAI_FUNC void luaK_checkstack (FuncState *fs, int n);
LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s);
LUAI_FUNC int luaK_intK (FuncState *fs, lua_Integer n);
LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e);
LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e);
LUAI_FUNC void luaK_exp2anyregup (FuncState *fs, expdesc *e);
LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e);
LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e);
LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e);
LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key);
LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k);
LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e);
LUAI_FUNC void luaK_goiffalse (FuncState *fs, expdesc *e);
LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e);
LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults);
LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e);
LUAI_FUNC int luaK_jump (FuncState *fs);
LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret);
LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target);
LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list);
LUAI_FUNC void luaK_patchclose (FuncState *fs, int list, int level);
LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2);
LUAI_FUNC int luaK_getlabel (FuncState *fs);
LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v, int line);
LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v);
LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1,
expdesc *v2, int line);
LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore);
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
** $Id: ldebug.h,v 2.14.1.1 2017/04/19 17:20:42 roberto Exp $
** Auxiliary functions from Debug Interface module
** See Copyright Notice in lua.h
*/
#ifndef ldebug_h
#define ldebug_h
#include "lstate.h"
#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1)
#define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : -1)
#define resethookcount(L) (L->hookcount = L->basehookcount)
LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o,
const char *opname);
LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1,
const TValue *p2);
LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1,
const TValue *p2,
const char *msg);
LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1,
const TValue *p2);
LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1,
const TValue *p2);
LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...);
LUAI_FUNC const char *luaG_addinfo (lua_State *L, const char *msg,
TString *src, int line);
LUAI_FUNC l_noret luaG_errormsg (lua_State *L);
LUAI_FUNC void luaG_traceexec (lua_State *L);
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment