Commit 0ea21cf0 authored by nanahira's avatar nanahira

Merge branch 'master' into inf_time

parents 5565fb21 76590c19
...@@ -5,17 +5,15 @@ ...@@ -5,17 +5,15 @@
# build files # build files
/bin /bin
/build build
/obj /obj
# dependencies # dependencies
/event /event
/freetype /freetype
/sqlite3 /sqlite3
/ikpmp3
/irrklang /irrklang
/irrlicht /irrlicht*
/lua
# gframe additionals # gframe additionals
/gframe/ygopro.ico /gframe/ygopro.ico
...@@ -50,6 +48,7 @@ ...@@ -50,6 +48,7 @@
# ygopro folders # ygopro folders
/deck /deck
/pack
/fonts /fonts
/replay /replay
/single /single
...@@ -57,6 +56,9 @@ ...@@ -57,6 +56,9 @@
/sound/*.wav /sound/*.wav
/sound/custom /sound/custom
/sound/BGM /sound/BGM
/sound/README.md
/sound/LICENSE
/sound/,*
/update /update
/update* /update*
/locales /locales
...@@ -75,13 +77,20 @@ ...@@ -75,13 +77,20 @@
# others # others
*.log *.log
/.vscode .vscode
core*
/bak/ /bak/
/.vs
/bug.txt
/output /output
/replace.sh
/temp /temp
[Tt]humbs.cdb [Tt]humbs.cdb
/PrinterData.txt /PrinterData.txt
/ygopro_*.bat
/ygopro_*.sh /*.bat
/*.sh
/*.sql
/patch.exe.manifest
/patch.exe
/diff.exe
...@@ -3,8 +3,8 @@ os: ...@@ -3,8 +3,8 @@ os:
- linux - linux
- osx - osx
sudo: required sudo: required
dist: xenial dist: bionic
osx_image: xcode8 osx_image: xcode9.4
addons: addons:
ssh_known_hosts: ssh_known_hosts:
- github.com - github.com
...@@ -13,40 +13,38 @@ addons: ...@@ -13,40 +13,38 @@ addons:
- libfreetype6-dev - libfreetype6-dev
- libevent-dev - libevent-dev
- libsqlite3-dev - libsqlite3-dev
- libirrlicht-dev
- libgl1-mesa-dev - libgl1-mesa-dev
- libglu-dev - libglu-dev
- p7zip-full - p7zip-full
- liblua5.3-dev
env: env:
- USE_IRRKLANG=1 - USE_IRRKLANG=1
before_install: before_install:
- git submodule update --init --recursive - git submodule update --init --recursive
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
brew update > /dev/null; brew update;
brew install freetype libevent sqlite p7zip dylibbundler > /dev/null; brew install freetype libevent sqlite dylibbundler p7zip;
sudo cp -r /usr/local/include/freetype2 ./freetype2;
sudo cp -r /usr/local/include/event2 ./event2;
sudo rm -rf /usr/local/include/*;
sudo cp -r ./freetype2 /usr/local/include/freetype2;
sudo cp -r ./event2 /usr/local/include/event2;
curl --retry 5 --location https://www.lua.org/ftp/lua-5.3.5.tar.gz | tar zfx -;
mv lua-5.3.5/src lua;
cp premake/lua/premake4.lua lua/;
fi fi
- curl --location --retry 5 http://www.lua.org/ftp/lua-5.3.5.tar.gz | tar zfx - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mkdir irrlicht ; cd irrlicht ; curl --retry 5 --location https://github.com/moecube/irrlicht/releases/download/test/irrlicht-mycard-mac.tar.gz | tar zfx - ; cp libIrrlicht.a /usr/local/lib/ ; sudo cp -r include /usr/local/include/irrlicht ; cd .. ; fi
- 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
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
curl --location --retry 5 https://github.com/premake/premake-core/releases/download/v5.0.0-alpha12/premake-5.0.0-alpha12-linux.tar.gz | tar zfx -; git clone --depth=1 https://github.com/DailyShana/irrlicht irrlicht_linux;
curl --location --retry 5 https://github.com/premake/premake-core/releases/download/v5.0.0-alpha14/premake-5.0.0-alpha14-linux.tar.gz | tar zfx -;
fi 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/;
...@@ -59,27 +57,27 @@ script: ...@@ -59,27 +57,27 @@ script:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./premake5 gmake --cc=clang; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./premake5 gmake --cc=clang; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./premake5 gmake; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./premake5 gmake; fi
- cd build - cd build
- make config=release ygopro -j4 - make config=release ygopro
- cd .. - cd ..
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mv -f bin/release/ygopro ./; strip ygopro; - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mv bin/release/ygopro ./; strip ygopro;
fi fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - |
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
mkdir -p ygopro.app/Contents/MacOS; mkdir -p ygopro.app/Contents/MacOS;
mv -f bin/release/ygopro ygopro.app/Contents/MacOS; mv bin/release/ygopro ygopro.app/Contents/MacOS;
dylibbundler -x ygopro.app/Contents/MacOS/ygopro -b -d ygopro.app/Contents/Frameworks/ -p @executable_path/../Frameworks/ -cd; dylibbundler -x ygopro.app/Contents/MacOS/ygopro -b -d ygopro.app/Contents/Frameworks/ -p @executable_path/../Frameworks/ -cd;
strip ygopro.app/Contents/MacOS/ygopro; mkdir ygopro.app/Contents/Resources; strip ygopro.app/Contents/MacOS/ygopro; mkdir ygopro.app/Contents/Resources;
mv -f premake/gframe/ygopro.icns ygopro.app/Contents/Resources/Icon.icns; mv premake/gframe/ygopro.icns ygopro.app/Contents/Resources/Icon.icns;
defaults write "$PWD/ygopro.app/Contents/Info.plist" "CFBundleIconFile" "Icon.icns"; defaults write "$PWD/ygopro.app/Contents/Info.plist" "CFBundleIconFile" "Icon.icns";
defaults write "$PWD/ygopro.app/Contents/Info.plist" "CFBundleIdentifier" "moe.mycard.ygopro"; defaults write "$PWD/ygopro.app/Contents/Info.plist" "CFBundleIdentifier" "moe.mycard.ygopro";
if [[ "$TRAVIS_PULL_REQUEST" == "false" ]]; then if [[ "$TRAVIS_PULL_REQUEST" == "false" ]]; then
echo $CERTIFICATE | base64 --decode --output cert.p12; echo $CERTIFICATE | base64 --decode --output cert.p12;
security create-keychain -p "" build.keychain; security unlock-keychain -p "" build.keychain; security create-keychain -p "" build.keychain; security default-keychain -s build.keychain; security unlock-keychain -p "" build.keychain;
security import cert.p12 -k build.keychain -P "$CERTIFICATE_PASSWORD" -T /usr/bin/codesign; security import cert.p12 -P "$CERTIFICATE_PASSWORD" -T /usr/bin/codesign;
codesign --deep --keychain build.keychain --sign "$(security find-identity -v -p security set-key-partition-list -S apple-tool:,apple: -s -k "" build.keychain;
codesigning build.keychain | head -1 | grep -o '".*"' | tr -d '"')" ygopro.app; codesign --deep --sign "$(security find-identity -v -p codesigning build.keychain | head -1 | grep -o '".*"' | tr -d '"')" ygopro.app;
fi fi
fi fi
before_deploy: before_deploy:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
7z a -mx9 -xr!.git* KoishiPro-$TRAVIS_OS_NAME-$TRAVIS_TAG.zip ygopro libIrrKlang.so; 7z a -mx9 -xr!.git* KoishiPro-$TRAVIS_OS_NAME-$TRAVIS_TAG.zip ygopro libIrrKlang.so;
...@@ -88,9 +86,8 @@ before_deploy: ...@@ -88,9 +86,8 @@ before_deploy:
7z a -mx9 -xr!.git* KoishiPro-$TRAVIS_OS_NAME-$TRAVIS_TAG.zip ygopro.app; 7z a -mx9 -xr!.git* KoishiPro-$TRAVIS_OS_NAME-$TRAVIS_TAG.zip ygopro.app;
fi fi
- curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/HuangYuNan/ygopro222-images/archive/master.zip - curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://cdn01.moecube.com/images/ygopro-images-zh-CN.zip
- 7z x -y ygopro222-images-master.zip > /dev/null - 7z x -y -opics ygopro-images-zh-CN.zip > /dev/null
- mv -f ygopro222-images-master pics
- curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/moecube/ygopro-starter-pack/archive/master.zip - curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/moecube/ygopro-starter-pack/archive/master.zip
- 7z x -y ygopro-starter-pack-master.zip > /dev/null - 7z x -y ygopro-starter-pack-master.zip > /dev/null
...@@ -105,9 +102,10 @@ before_deploy: ...@@ -105,9 +102,10 @@ 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-sound/raw/master/{} ; exit 0"
- cd .. - cd ..
- git clone --depth=1 https://github.com/purerosefallen/ygopro-database - git clone --depth=1 https://github.com/purerosefallen/ygopro-database
......
project (ygo)
cmake_minimum_required (VERSION 3.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)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
include (AutoFiles)
include (platform/settings)
if (MSVC)
add_subdirectory (event)
add_subdirectory (freetype)
add_subdirectory (irrlicht)
add_subdirectory (sqlite3)
add_subdirectory (lua)
else ()
find_package(LibEvent REQUIRED)
find_package(Freetype REQUIRED)
find_package(Irrlicht REQUIRED)
find_package(Sqlite REQUIRED)
find_package(Lua 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 (ocgcore)
add_subdirectory (gframe)
...@@ -62,4 +62,4 @@ Xyz materials: ...@@ -62,4 +62,4 @@ Xyz materials:
* textures: Other image files. * textures: Other image files.
* deck: .ydk deck files. * deck: .ydk deck files.
* replay: .yrp replay files. * replay: .yrp replay files.
* expansions: *.cdb will be loaded as extra databases. * expansions: *.cdb will be loaded as extra databases.
\ No newline at end of file
version: '{build}' version: '{build}'
image: Visual Studio 2017
environment: environment:
irrklang_pro: 1 irrklang_pro: 1
...@@ -9,34 +10,33 @@ install: ...@@ -9,34 +10,33 @@ install:
- git submodule update --init --recursive - git submodule update --init --recursive
# environment and system dependency # environment and system dependency
- bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/premake/premake-core/releases/download/v5.0.0-alpha12/premake-5.0.0-alpha12-windows.zip ; exit 0" - bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/premake/premake-core/releases/download/v5.0.0-alpha14/premake-5.0.0-alpha14-windows.zip ; exit 0"
- 7z x -y premake-5.0.0-alpha12-windows.zip - 7z x -y premake-5.0.0-alpha14-windows.zip
- bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz ; exit 0" - bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz ; exit 0"
- tar xf libevent-2.0.22-stable.tar.gz - tar xf libevent-2.0.22-stable.tar.gz
- move libevent-2.0.22-stable event - move libevent-2.0.22-stable event
- xcopy /E event\WIN32-Code event\include - xcopy /E event\WIN32-Code event\include
- bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name http://downloads.sourceforge.net/freetype/freetype-2.9.1.tar.bz2 ; exit 0" - bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name http://downloads.sourceforge.net/freetype/freetype-2.10.1.tar.gz ; exit 0"
- tar xf freetype-2.9.1.tar.bz2 - tar xf freetype-2.10.1.tar.gz
- move freetype-2.9.1 freetype - move freetype-2.10.1 freetype
- bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name http://downloads.sourceforge.net/irrlicht/irrlicht-1.8.4.zip ; exit 0" - bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name http://downloads.sourceforge.net/irrlicht/irrlicht-1.8.4.zip ; exit 0"
- 7z x -y irrlicht-1.8.4.zip - 7z x -y irrlicht-1.8.4.zip
- md irrlicht - md irrlicht
- 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" - 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 - tar xf lua-5.3.5.tar.gz
- move lua-5.3.5\src lua - 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/2020/sqlite-amalgamation-3310100.zip ; exit 0"
- 7z x -y sqlite-amalgamation-3240000.zip - 7z x -y sqlite-amalgamation-3310100.zip
- move sqlite-amalgamation-3240000 sqlite3 - move sqlite-amalgamation-3310100 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/* .
...@@ -45,7 +45,7 @@ install: ...@@ -45,7 +45,7 @@ install:
- patch -p0 < irrlicht\irrlicht.patch - patch -p0 < irrlicht\irrlicht.patch
# premake # premake
- premake5 vs2015 - premake5 vs2017
configuration: Release configuration: Release
...@@ -59,9 +59,8 @@ after_build: ...@@ -59,9 +59,8 @@ after_build:
- bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/purerosefallen/windbot/releases/download/latest/WindBot.7z ; exit 0" - bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/purerosefallen/windbot/releases/download/latest/WindBot.7z ; exit 0"
- 7z x -y WindBot.7z - 7z x -y WindBot.7z
- bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/HuangYuNan/ygopro222-images/archive/master.zip ; exit 0" - bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://cdn01.moecube.com/images/ygopro-images-zh-CN.zip ; exit 0"
- 7z x -y ygopro222-images-master.zip - 7z x -y -opics ygopro-images-zh-CN.zip
- mv -f ygopro222-images-master pics
- bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/purerosefallen/update-koishipro/archive/master.zip ; exit 0" - bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://github.com/purerosefallen/update-koishipro/archive/master.zip ; exit 0"
- 7z x -y update-koishipro-master.zip - 7z x -y update-koishipro-master.zip
...@@ -72,7 +71,7 @@ after_build: ...@@ -72,7 +71,7 @@ after_build:
- cp -rf ygopro-starter-pack-master/* . - cp -rf ygopro-starter-pack-master/* .
- 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-sound/raw/master/{} ; exit 0"
- cd .. - cd ..
- rm -rf pics/thumbnail pics/*.db - rm -rf pics/thumbnail pics/*.db
...@@ -101,9 +100,9 @@ artifacts: ...@@ -101,9 +100,9 @@ artifacts:
name: ygopro full repack name: ygopro full repack
cache: cache:
- premake-5.0.0-alpha12-windows.zip - premake-5.0.0-alpha14-windows.zip
- libevent-2.0.22-stable.tar.gz - libevent-2.0.22-stable.tar.gz
- freetype-2.9.1.tar.bz2 - freetype-2.10.1.tar.gz
- lua-5.3.5.tar.gz
- irrlicht-1.8.4.zip - irrlicht-1.8.4.zip
- lua-5.3.5.tar.gz - sqlite-amalgamation-3310100.zip
- sqlite-amalgamation-3240000.zip
No preview for this file type
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" )
add_definitions ( "-D_UNICODE" "-DUNICODE" "/utf-8" )
include (MSVCMultipleProcessCompile)
include (MSVCStaticRuntime)
include (MSVCJustMyCodeDebugging)
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)
# Locate Lua library
# This module defines
# LUA52_FOUND, if false, do not try to link to Lua
# LUA_LIBRARIES
# LUA_INCLUDE_DIR, where to find lua.h
# LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
#
# Note that the expected include convention is
# #include "lua.h"
# and not
# #include <lua/lua.h>
# This is because, the lua location is not standardized and may exist
# in locations other than lua/
#=============================================================================
# Copyright 2007-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
FIND_PATH(LUA_INCLUDE_DIR lua.h
HINTS
$ENV{LUA_DIR}
PATH_SUFFIXES include/lua53 include/lua5.3 include/lua include
PATHS
~/Library/Frameworks
/Library/Frameworks
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt
)
FIND_LIBRARY(LUA_LIBRARY
NAMES lua53-c++ lua5.3-c++ lua-5.3-c++ lua-c++
HINTS
$ENV{LUA_DIR}
PATH_SUFFIXES lib64 lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/sw
/opt/local
/opt/csw
/opt
)
IF(LUA_LIBRARY)
# include the math library for Unix
IF(UNIX AND NOT APPLE)
FIND_LIBRARY(LUA_MATH_LIBRARY m)
SET( LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
# For Windows and Mac, don't need to explicitly include the math library
ELSE(UNIX AND NOT APPLE)
SET( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries")
ENDIF(UNIX AND NOT APPLE)
ENDIF(LUA_LIBRARY)
IF(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
FILE(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua .+\"")
STRING(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([^\"]+)\".*" "\\1" LUA_VERSION_STRING "${lua_version_str}")
UNSET(lua_version_str)
ENDIF()
INCLUDE(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
# all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
VERSION_VAR LUA_VERSION_STRING)
MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY)
# - 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()
# - Enable Just My Code debugging on MSVC
#
# include(MSVCJustMyCodeDebugging)
#
# Requires these CMake modules:
# ListCombinations.cmake
#
# The cmake property VS_JUST_MY_CODE_DEBUGGING introduced in CMake 3.15
# also add /JMC to Release configuration, which is inappropriate
if(MSVC AND NOT "${MSVC_VERSION}" LESS 1918)
# Only available in VS 2017 15.8 and newer
include(ListCombinations)
list_combinations(_varnames
PREFIXES
CMAKE_CXX_FLAGS_
SUFFIXES
DEBUG
RELWITHDEBINFO)
foreach(_var ${_varnames})
set(${_var} "${${_var}} /JMC")
endforeach()
endif()
# - 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_LIBRARY "libc++")
...@@ -97,8 +97,10 @@ void Draw2DImageQuad(video::IVideoDriver* driver, video::ITexture* image, core:: ...@@ -97,8 +97,10 @@ void Draw2DImageQuad(video::IVideoDriver* driver, video::ITexture* image, core::
CGUIImageButton::CGUIImageButton(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) CGUIImageButton::CGUIImageButton(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: CGUIButton(environment, parent, id, rectangle) { : CGUIButton(environment, parent, id, rectangle) {
isDrawImage = true; isDrawImage = true;
isFixedSize = false;
imageRotation = 0.0f; imageRotation = 0.0f;
imageScale = core::vector2df(1.0f, 1.0f); imageScale = core::vector2df(1.0f, 1.0f);
imageSize = core::dimension2di(rectangle.getWidth(), rectangle.getHeight());
} }
CGUIImageButton* CGUIImageButton::addImageButton(IGUIEnvironment *env, const core::rect<s32>& rectangle, IGUIElement* parent, s32 id) { CGUIImageButton* CGUIImageButton::addImageButton(IGUIEnvironment *env, const core::rect<s32>& rectangle, IGUIElement* parent, s32 id) {
CGUIImageButton* button = new CGUIImageButton(env, parent ? parent : 0, id, rectangle); CGUIImageButton* button = new CGUIImageButton(env, parent ? parent : 0, id, rectangle);
...@@ -129,6 +131,23 @@ void CGUIImageButton::draw() { ...@@ -129,6 +131,23 @@ void CGUIImageButton::draw() {
irr::gui::Draw2DImageRotation(driver, Image, ImageRect, pos, center, imageRotation, imageScale); irr::gui::Draw2DImageRotation(driver, Image, ImageRect, pos, center, imageRotation, imageScale);
IGUIElement::draw(); IGUIElement::draw();
} }
void CGUIImageButton::setImage(video::ITexture* image)
{
if(image)
image->grab();
if(Image)
Image->drop();
Image = image;
if(image) {
ImageRect = core::rect<s32>(core::position2d<s32>(0, 0), image->getOriginalSize());
if(isFixedSize)
imageScale = core::vector2df((irr::f32)imageSize.Width / image->getSize().Width, (irr::f32)imageSize.Height / image->getSize().Height);
}
if(!PressedImage)
setPressedImage(Image);
}
void CGUIImageButton::setDrawImage(bool b) { void CGUIImageButton::setDrawImage(bool b) {
isDrawImage = b; isDrawImage = b;
} }
...@@ -138,6 +157,10 @@ void CGUIImageButton::setImageRotation(f32 r) { ...@@ -138,6 +157,10 @@ void CGUIImageButton::setImageRotation(f32 r) {
void CGUIImageButton::setImageScale(core::vector2df s) { void CGUIImageButton::setImageScale(core::vector2df s) {
imageScale = s; imageScale = s;
} }
void CGUIImageButton::setImageSize(core::dimension2di s) {
isFixedSize = true;
imageSize = s;
}
IGUIFont* CGUIImageButton::getOverrideFont( void ) const IGUIFont* CGUIImageButton::getOverrideFont( void ) const
{ {
......
...@@ -17,16 +17,20 @@ public: ...@@ -17,16 +17,20 @@ public:
CGUIImageButton(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle); CGUIImageButton(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle);
static CGUIImageButton* addImageButton(IGUIEnvironment *env, const core::rect<s32>& rectangle, IGUIElement* parent, s32 id); static CGUIImageButton* addImageButton(IGUIEnvironment *env, const core::rect<s32>& rectangle, IGUIElement* parent, s32 id);
virtual void draw(); virtual void draw();
virtual void setImage(video::ITexture* image = 0);
virtual void setDrawImage(bool b); virtual void setDrawImage(bool b);
virtual void setImageRotation(f32 r); virtual void setImageRotation(f32 r);
virtual void setImageScale(core::vector2df s); virtual void setImageScale(core::vector2df s);
virtual void setImageSize(core::dimension2di s);
virtual IGUIFont* getOverrideFont(void) const; virtual IGUIFont* getOverrideFont(void) const;
virtual IGUIFont* getActiveFont() const; virtual IGUIFont* getActiveFont() const;
private: private:
bool isDrawImage; bool isDrawImage;
bool isFixedSize;
f32 imageRotation; f32 imageRotation;
core::vector2df imageScale; core::vector2df imageScale;
core::dimension2di imageSize;
}; };
} }
......
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"
VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ygopro)
else ()
add_executable (ygopro ${AUTO_FILES_RESULT})
endif ()
target_link_libraries (ygopro ocgcore 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 (APPLE)
find_library(COCOA_LIBRARY Cocoa)
find_library(IOKIT_LIBRARY IOKit)
target_link_libraries(ygopro ${COCOA_LIBRARY} ${IOKIT_LIBRARY})
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 ()
#ifndef BASE64_H
#define BASE64_H
#include <string>
const char kBase64Alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";
class Base64 {
public:
static bool Encode(const std::string &in, std::string *out) {
int i = 0, j = 0;
size_t enc_len = 0;
unsigned char a3[3];
unsigned char a4[4];
out->resize(EncodedLength(in));
int input_len = in.size();
std::string::const_iterator input = in.begin();
while (input_len--) {
a3[i++] = *(input++);
if (i == 3) {
a3_to_a4(a4, a3);
for (i = 0; i < 4; i++) {
(*out)[enc_len++] = kBase64Alphabet[a4[i]];
}
i = 0;
}
}
if (i) {
for (j = i; j < 3; j++) {
a3[j] = '\0';
}
a3_to_a4(a4, a3);
for (j = 0; j < i + 1; j++) {
(*out)[enc_len++] = kBase64Alphabet[a4[j]];
}
while ((i++ < 3)) {
(*out)[enc_len++] = '=';
}
}
return (enc_len == out->size());
}
static bool Encode(const char *input, size_t input_length, char *out, size_t out_length) {
int i = 0, j = 0;
char *out_begin = out;
unsigned char a3[3];
unsigned char a4[4];
size_t encoded_length = EncodedLength(input_length);
if (out_length < encoded_length) return false;
while (input_length--) {
a3[i++] = *input++;
if (i == 3) {
a3_to_a4(a4, a3);
for (i = 0; i < 4; i++) {
*out++ = kBase64Alphabet[a4[i]];
}
i = 0;
}
}
if (i) {
for (j = i; j < 3; j++) {
a3[j] = '\0';
}
a3_to_a4(a4, a3);
for (j = 0; j < i + 1; j++) {
*out++ = kBase64Alphabet[a4[j]];
}
while ((i++ < 3)) {
*out++ = '=';
}
}
return (out == (out_begin + encoded_length));
}
static bool Decode(const std::string &in, std::string *out) {
int i = 0, j = 0;
size_t dec_len = 0;
unsigned char a3[3];
unsigned char a4[4];
int input_len = in.size();
std::string::const_iterator input = in.begin();
out->resize(DecodedLength(in));
while (input_len--) {
if (*input == '=') {
break;
}
a4[i++] = *(input++);
if (i == 4) {
for (i = 0; i <4; i++) {
a4[i] = b64_lookup(a4[i]);
}
a4_to_a3(a3,a4);
for (i = 0; i < 3; i++) {
(*out)[dec_len++] = a3[i];
}
i = 0;
}
}
if (i) {
for (j = i; j < 4; j++) {
a4[j] = '\0';
}
for (j = 0; j < 4; j++) {
a4[j] = b64_lookup(a4[j]);
}
a4_to_a3(a3,a4);
for (j = 0; j < i - 1; j++) {
(*out)[dec_len++] = a3[j];
}
}
return (dec_len == out->size());
}
static bool Decode(const char *input, size_t input_length, char *out, size_t out_length) {
int i = 0, j = 0;
char *out_begin = out;
unsigned char a3[3];
unsigned char a4[4];
size_t decoded_length = DecodedLength(input, input_length);
if (out_length < decoded_length) return false;
while (input_length--) {
if (*input == '=') {
break;
}
a4[i++] = *(input++);
if (i == 4) {
for (i = 0; i <4; i++) {
a4[i] = b64_lookup(a4[i]);
}
a4_to_a3(a3,a4);
for (i = 0; i < 3; i++) {
*out++ = a3[i];
}
i = 0;
}
}
if (i) {
for (j = i; j < 4; j++) {
a4[j] = '\0';
}
for (j = 0; j < 4; j++) {
a4[j] = b64_lookup(a4[j]);
}
a4_to_a3(a3,a4);
for (j = 0; j < i - 1; j++) {
*out++ = a3[j];
}
}
return (out == (out_begin + decoded_length));
}
static int DecodedLength(const char *in, size_t in_length) {
int numEq = 0;
const char *in_end = in + in_length;
while (*--in_end == '=') ++numEq;
return ((6 * in_length) / 8) - numEq;
}
static int DecodedLength(const std::string &in) {
int numEq = 0;
int n = in.size();
for (std::string::const_reverse_iterator it = in.rbegin(); *it == '='; ++it) {
++numEq;
}
return ((6 * n) / 8) - numEq;
}
inline static int EncodedLength(size_t length) {
return (length + 2 - ((length + 2) % 3)) / 3 * 4;
}
inline static int EncodedLength(const std::string &in) {
return EncodedLength(in.length());
}
inline static void StripPadding(std::string *in) {
while (!in->empty() && *(in->rbegin()) == '=') in->resize(in->size() - 1);
}
private:
static inline void a3_to_a4(unsigned char * a4, unsigned char * a3) {
a4[0] = (a3[0] & 0xfc) >> 2;
a4[1] = ((a3[0] & 0x03) << 4) + ((a3[1] & 0xf0) >> 4);
a4[2] = ((a3[1] & 0x0f) << 2) + ((a3[2] & 0xc0) >> 6);
a4[3] = (a3[2] & 0x3f);
}
static inline void a4_to_a3(unsigned char * a3, unsigned char * a4) {
a3[0] = (a4[0] << 2) + ((a4[1] & 0x30) >> 4);
a3[1] = ((a4[1] & 0xf) << 4) + ((a4[2] & 0x3c) >> 2);
a3[2] = ((a4[2] & 0x3) << 6) + a4[3];
}
static inline unsigned char b64_lookup(unsigned char c) {
if(c >='A' && c <='Z') return c - 'A';
if(c >='a' && c <='z') return c - 71;
if(c >='0' && c <='9') return c + 4;
if(c == '+') return 62;
if(c == '/') return 63;
return 255;
}
};
#endif // BASE64_H
...@@ -12,11 +12,21 @@ public: ...@@ -12,11 +12,21 @@ public:
p += 4; p += 4;
return ret; return ret;
} }
inline static unsigned int ReadUInt32(char*& p) {
unsigned int ret = *(unsigned int*)p;
p += 4;
return ret;
}
inline static short ReadInt16(char*& p) { inline static short ReadInt16(char*& p) {
short ret = *(short*)p; short ret = *(short*)p;
p += 2; p += 2;
return ret; return ret;
} }
inline static unsigned short ReadUInt16(char*& p) {
unsigned short ret = *(unsigned short*)p;
p += 2;
return ret;
}
inline static char ReadInt8(char*& p) { inline static char ReadInt8(char*& p) {
char ret = *(char*)p; char ret = *(char*)p;
p++; p++;
......
...@@ -18,7 +18,7 @@ ClientCard::ClientCard() { ...@@ -18,7 +18,7 @@ ClientCard::ClientCard() {
is_showtarget = false; is_showtarget = false;
is_showchaintarget = false; is_showchaintarget = false;
is_highlighting = false; is_highlighting = false;
is_disabled = false; status = 0;
is_reversed = false; is_reversed = false;
cmdFlag = 0; cmdFlag = 0;
code = 0; code = 0;
...@@ -125,12 +125,14 @@ void ClientCard::UpdateInfo(char* buf) { ...@@ -125,12 +125,14 @@ void ClientCard::UpdateInfo(char* buf) {
base_defense = BufferIO::ReadInt32(buf); base_defense = BufferIO::ReadInt32(buf);
if(flag & QUERY_REASON) if(flag & QUERY_REASON)
reason = BufferIO::ReadInt32(buf); reason = BufferIO::ReadInt32(buf);
if(flag & QUERY_REASON_CARD)
buf += 4;
if(flag & QUERY_EQUIP_CARD) { if(flag & QUERY_EQUIP_CARD) {
int c = BufferIO::ReadInt8(buf); int c = BufferIO::ReadInt8(buf);
int l = BufferIO::ReadInt8(buf); int l = BufferIO::ReadInt8(buf);
int s = BufferIO::ReadInt8(buf); int s = BufferIO::ReadInt8(buf);
BufferIO::ReadInt8(buf); BufferIO::ReadInt8(buf);
ClientCard* ecard = mainGame->dField.GetCard(c, l, s); ClientCard* ecard = mainGame->dField.GetCard(mainGame->LocalPlayer(c), l, s);
equipTarget = ecard; equipTarget = ecard;
ecard->equipped.insert(this); ecard->equipped.insert(this);
} }
...@@ -141,7 +143,7 @@ void ClientCard::UpdateInfo(char* buf) { ...@@ -141,7 +143,7 @@ void ClientCard::UpdateInfo(char* buf) {
int l = BufferIO::ReadInt8(buf); int l = BufferIO::ReadInt8(buf);
int s = BufferIO::ReadInt8(buf); int s = BufferIO::ReadInt8(buf);
BufferIO::ReadInt8(buf); BufferIO::ReadInt8(buf);
ClientCard* tcard = mainGame->dField.GetCard(c, l, s); ClientCard* tcard = mainGame->dField.GetCard(mainGame->LocalPlayer(c), l, s);
cardTarget.insert(tcard); cardTarget.insert(tcard);
tcard->ownerTarget.insert(this); tcard->ownerTarget.insert(this);
} }
...@@ -162,10 +164,8 @@ void ClientCard::UpdateInfo(char* buf) { ...@@ -162,10 +164,8 @@ void ClientCard::UpdateInfo(char* buf) {
} }
if(flag & QUERY_OWNER) if(flag & QUERY_OWNER)
owner = BufferIO::ReadInt32(buf); owner = BufferIO::ReadInt32(buf);
if(flag & QUERY_IS_DISABLED) if(flag & QUERY_STATUS)
is_disabled = BufferIO::ReadInt32(buf); status = BufferIO::ReadInt32(buf);
if(flag & QUERY_IS_PUBLIC)
is_public = BufferIO::ReadInt32(buf);
if(flag & QUERY_LSCALE) { if(flag & QUERY_LSCALE) {
lscale = BufferIO::ReadInt32(buf); lscale = BufferIO::ReadInt32(buf);
myswprintf(lscstring, L"%d", lscale); myswprintf(lscstring, L"%d", lscale);
...@@ -199,6 +199,8 @@ void ClientCard::ClearTarget() { ...@@ -199,6 +199,8 @@ void ClientCard::ClearTarget() {
ownerTarget.clear(); ownerTarget.clear();
} }
bool ClientCard::client_card_sort(ClientCard* c1, ClientCard* c2) { bool ClientCard::client_card_sort(ClientCard* c1, ClientCard* c2) {
if(c1->is_selected != c2->is_selected)
return c1->is_selected < c2->is_selected;
int32 cp1 = c1->overlayTarget ? c1->overlayTarget->controler : c1->controler; int32 cp1 = c1->overlayTarget ? c1->overlayTarget->controler : c1->controler;
int32 cp2 = c2->overlayTarget ? c2->overlayTarget->controler : c2->controler; int32 cp2 = c2->overlayTarget ? c2->overlayTarget->controler : c2->controler;
if(cp1 != cp2) if(cp1 != cp2)
...@@ -210,9 +212,18 @@ bool ClientCard::client_card_sort(ClientCard* c1, ClientCard* c2) { ...@@ -210,9 +212,18 @@ bool ClientCard::client_card_sort(ClientCard* c1, ClientCard* c2) {
return c1->overlayTarget->sequence < c2->overlayTarget->sequence; return c1->overlayTarget->sequence < c2->overlayTarget->sequence;
else return c1->sequence < c2->sequence; else return c1->sequence < c2->sequence;
else { else {
if(c1->location & 0x71) if(c1->location & (LOCATION_DECK | LOCATION_GRAVE | LOCATION_REMOVED | LOCATION_EXTRA)) {
auto it1 = std::find_if(mainGame->dField.chains.rbegin(), mainGame->dField.chains.rend(), [c1](const auto& ch) {
return c1 == ch.chain_card || ch.target.find(c1) != ch.target.end();
});
auto it2 = std::find_if(mainGame->dField.chains.rbegin(), mainGame->dField.chains.rend(), [c2](const auto& ch) {
return c2 == ch.chain_card || ch.target.find(c2) != ch.target.end();
});
if(it1 != mainGame->dField.chains.rend() || it2 != mainGame->dField.chains.rend()) {
return it1 < it2;
}
return c1->sequence > c2->sequence; return c1->sequence > c2->sequence;
else } else
return c1->sequence < c2->sequence; return c1->sequence < c2->sequence;
} }
} }
......
...@@ -89,8 +89,7 @@ public: ...@@ -89,8 +89,7 @@ public:
u8 location; u8 location;
u8 sequence; u8 sequence;
u8 position; u8 position;
u8 is_disabled; u32 status;
u8 is_public;
u8 cHint; u8 cHint;
u32 chValue; u32 chValue;
u32 opParam; u32 opParam;
......
This diff is collapsed.
...@@ -61,14 +61,13 @@ public: ...@@ -61,14 +61,13 @@ public:
bool select_panalmode; bool select_panalmode;
bool select_ready; bool select_ready;
int announce_count; int announce_count;
int declarable_type;
int select_counter_count; int select_counter_count;
int select_counter_type; int select_counter_type;
std::vector<ClientCard*> selectable_cards; std::vector<ClientCard*> selectable_cards;
std::vector<ClientCard*> selected_cards; std::vector<ClientCard*> selected_cards;
std::set<ClientCard*> selectsum_cards; std::set<ClientCard*> selectsum_cards;
std::vector<ClientCard*> selectsum_all; std::vector<ClientCard*> selectsum_all;
std::vector<int> opcode; std::vector<int> declare_opcodes;
std::vector<ClientCard*> display_cards; std::vector<ClientCard*> display_cards;
std::vector<int> sort_list; std::vector<int> sort_list;
std::map<int, int> player_desc_hints[2]; std::map<int, int> player_desc_hints[2];
...@@ -113,9 +112,7 @@ public: ...@@ -113,9 +112,7 @@ public:
void check_sel_sum_t(const std::set<ClientCard*>& left, int acc); void check_sel_sum_t(const std::set<ClientCard*>& left, int acc);
bool check_sum(std::set<ClientCard*>::const_iterator index, std::set<ClientCard*>::const_iterator end, int acc, int count); bool check_sum(std::set<ClientCard*>::const_iterator index, std::set<ClientCard*>::const_iterator end, int acc, int count);
void UpdateDeclarableCodeType(bool enter); void UpdateDeclarableList();
void UpdateDeclarableCodeOpcode(bool enter);
void UpdateDeclarableCode(bool enter);
void RefreshCardCountDisplay(); void RefreshCardCountDisplay();
...@@ -141,6 +138,7 @@ public: ...@@ -141,6 +138,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();
......
...@@ -59,10 +59,10 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) { ...@@ -59,10 +59,10 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
#ifdef __APPLE__ #ifdef __APPLE__
#include <OpenGL/gl.h> #include <OpenGL/gl.h>
#include <OpenGL/glu.h> #include <OpenGL/glu.h>
#else #else //__APPLE__
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glu.h> #include <GL/glu.h>
#endif #endif //__APPLE__
#include "CGUITTFont.h" #include "CGUITTFont.h"
#include "CGUIImageButton.h" #include "CGUIImageButton.h"
#include <iostream> #include <iostream>
...@@ -70,10 +70,12 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) { ...@@ -70,10 +70,12 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
#include <stdlib.h> #include <stdlib.h>
#include <memory.h> #include <memory.h>
#include <time.h> #include <time.h>
#include <thread>
#include <mutex>
#include <algorithm>
#include "bufferio.h" #include "bufferio.h"
#include "mymutex.h" #include "myfilesystem.h"
#include "mysignal.h" #include "mysignal.h"
#include "mythread.h"
#include "../ocgcore/ocgapi.h" #include "../ocgcore/ocgapi.h"
#include "../ocgcore/common.h" #include "../ocgcore/common.h"
...@@ -87,6 +89,7 @@ using namespace gui; ...@@ -87,6 +89,7 @@ using namespace gui;
extern unsigned short PRO_VERSION; extern unsigned short PRO_VERSION;
extern int enable_log; extern int enable_log;
extern bool exit_on_return; extern bool exit_on_return;
extern bool auto_watch_mode;
extern bool open_file; extern bool open_file;
extern wchar_t open_file_name[256]; extern wchar_t open_file_name[256];
extern bool bot_mode; extern bool bot_mode;
......
#include "data_manager.h" #include "data_manager.h"
#include "game.h"
#include <stdio.h> #include <stdio.h>
namespace ygo { namespace ygo {
const wchar_t* DataManager::unknown_string = L"???"; const wchar_t* DataManager::unknown_string = L"???";
wchar_t DataManager::strBuffer[4096]; wchar_t DataManager::strBuffer[4096];
byte DataManager::scriptBuffer[0x20000];
IFileSystem* DataManager::FileSystem;
DataManager dataManager; DataManager dataManager;
bool DataManager::LoadDB(const char* file) { bool DataManager::LoadDB(const wchar_t* wfile) {
sqlite3* pDB; char file[256];
if(sqlite3_open_v2(file, &pDB, SQLITE_OPEN_READONLY, 0) != SQLITE_OK) BufferIO::EncodeUTF8(wfile, file);
return Error(pDB); #ifdef _WIN32
IReadFile* reader = FileSystem->createAndOpenFile(wfile);
#else
IReadFile* reader = FileSystem->createAndOpenFile(file);
#endif
if(reader == NULL)
return false;
spmemvfs_db_t db;
spmembuffer_t* mem = (spmembuffer_t*)calloc(sizeof(spmembuffer_t), 1);
spmemvfs_env_init();
mem->total = mem->used = reader->getSize();
mem->data = (char*)malloc(mem->total + 1);
reader->read(mem->data, mem->total);
reader->drop();
(mem->data)[mem->total] = '\0';
if(spmemvfs_open_db(&db, file, mem) != SQLITE_OK)
return Error(&db);
sqlite3* pDB = db.handle;
sqlite3_stmt* pStmt; sqlite3_stmt* pStmt;
const char* sql = "select * from datas,texts where datas.id=texts.id"; const char* sql = "select * from datas,texts where datas.id=texts.id";
if(sqlite3_prepare_v2(pDB, sql, -1, &pStmt, 0) != SQLITE_OK) if(sqlite3_prepare_v2(pDB, sql, -1, &pStmt, 0) != SQLITE_OK)
return Error(pDB); return Error(&db);
CardDataC cd; CardDataC cd;
CardString cs; CardString cs;
int step = 0; int step = 0;
do { do {
step = sqlite3_step(pStmt); step = sqlite3_step(pStmt);
if(step == SQLITE_BUSY || step == SQLITE_ERROR || step == SQLITE_MISUSE) if(step == SQLITE_BUSY || step == SQLITE_ERROR || step == SQLITE_MISUSE)
return Error(pDB, pStmt); return Error(&db, pStmt);
else if(step == SQLITE_ROW) { else if(step == SQLITE_ROW) {
cd.code = sqlite3_column_int(pStmt, 0); cd.code = sqlite3_column_int(pStmt, 0);
cd.ot = sqlite3_column_int(pStmt, 1); cd.ot = sqlite3_column_int(pStmt, 1);
...@@ -61,7 +81,8 @@ bool DataManager::LoadDB(const char* file) { ...@@ -61,7 +81,8 @@ bool DataManager::LoadDB(const char* file) {
} }
} while(step != SQLITE_DONE); } while(step != SQLITE_DONE);
sqlite3_finalize(pStmt); sqlite3_finalize(pStmt);
sqlite3_close(pDB); spmemvfs_close_db(&db);
spmemvfs_env_fini();
return true; return true;
} }
bool DataManager::LoadStrings(const char* file) { bool DataManager::LoadStrings(const char* file) {
...@@ -69,40 +90,59 @@ bool DataManager::LoadStrings(const char* file) { ...@@ -69,40 +90,59 @@ bool DataManager::LoadStrings(const char* file) {
if(!fp) if(!fp)
return false; return false;
char linebuf[256]; char linebuf[256];
char strbuf[256];
int value;
while(fgets(linebuf, 256, fp)) { while(fgets(linebuf, 256, fp)) {
if(linebuf[0] != '!') ReadStringConfLine(linebuf);
continue;
sscanf(linebuf, "!%s", strbuf);
if(!strcmp(strbuf, "system")) {
sscanf(&linebuf[7], "%d %240[^\n]", &value, strbuf);
BufferIO::DecodeUTF8(strbuf, strBuffer);
_sysStrings[value] = strBuffer;
} else if(!strcmp(strbuf, "victory")) {
sscanf(&linebuf[8], "%x %240[^\n]", &value, strbuf);
BufferIO::DecodeUTF8(strbuf, strBuffer);
_victoryStrings[value] = strBuffer;
} else if(!strcmp(strbuf, "counter")) {
sscanf(&linebuf[8], "%x %240[^\n]", &value, strbuf);
BufferIO::DecodeUTF8(strbuf, strBuffer);
_counterStrings[value] = strBuffer;
} else if(!strcmp(strbuf, "setname")) {
sscanf(&linebuf[8], "%x %240[^\t\n]", &value, strbuf);//using tab for comment
BufferIO::DecodeUTF8(strbuf, strBuffer);
_setnameStrings[value] = strBuffer;
}
} }
fclose(fp); fclose(fp);
for(int i = 0; i < 255; ++i) for(int i = 0; i < 255; ++i)
myswprintf(numStrings[i], L"%d", i); myswprintf(numStrings[i], L"%d", i);
return true; return true;
} }
bool DataManager::Error(sqlite3* pDB, sqlite3_stmt* pStmt) { bool DataManager::LoadStrings(IReadFile* reader) {
BufferIO::DecodeUTF8(sqlite3_errmsg(pDB), strBuffer); char ch[2] = " ";
char linebuf[256] = "";
while(reader->read(&ch[0], 1)) {
if(ch[0] == '\0')
break;
strcat(linebuf, ch);
if(ch[0] == '\n') {
ReadStringConfLine(linebuf);
linebuf[0] = '\0';
}
}
reader->drop();
return true;
}
void DataManager::ReadStringConfLine(const char* linebuf) {
if(linebuf[0] != '!')
return;
char strbuf[256];
int value;
sscanf(linebuf, "!%s", strbuf);
if(!strcmp(strbuf, "system")) {
sscanf(&linebuf[7], "%d %240[^\n]", &value, strbuf);
BufferIO::DecodeUTF8(strbuf, strBuffer);
_sysStrings[value] = strBuffer;
} else if(!strcmp(strbuf, "victory")) {
sscanf(&linebuf[8], "%x %240[^\n]", &value, strbuf);
BufferIO::DecodeUTF8(strbuf, strBuffer);
_victoryStrings[value] = strBuffer;
} else if(!strcmp(strbuf, "counter")) {
sscanf(&linebuf[8], "%x %240[^\n]", &value, strbuf);
BufferIO::DecodeUTF8(strbuf, strBuffer);
_counterStrings[value] = strBuffer;
} else if(!strcmp(strbuf, "setname")) {
sscanf(&linebuf[8], "%x %240[^\t\n]", &value, strbuf);//using tab for comment
BufferIO::DecodeUTF8(strbuf, strBuffer);
_setnameStrings[value] = strBuffer;
}
}
bool DataManager::Error(spmemvfs_db_t* pDB, sqlite3_stmt* pStmt) {
BufferIO::DecodeUTF8(sqlite3_errmsg(pDB->handle), strBuffer);
if(pStmt) if(pStmt)
sqlite3_finalize(pStmt); sqlite3_finalize(pStmt);
sqlite3_close(pDB); spmemvfs_close_db(pDB);
spmemvfs_env_fini();
return false; return false;
} }
bool DataManager::GetData(int code, CardData* pData) { bool DataManager::GetData(int code, CardData* pData) {
...@@ -182,8 +222,8 @@ const wchar_t* DataManager::GetSetName(int code) { ...@@ -182,8 +222,8 @@ const wchar_t* DataManager::GetSetName(int code) {
} }
unsigned int DataManager::GetSetCode(const wchar_t* setname) { unsigned int DataManager::GetSetCode(const wchar_t* setname) {
for(auto csit = _setnameStrings.begin(); csit != _setnameStrings.end(); ++csit) { for(auto csit = _setnameStrings.begin(); csit != _setnameStrings.end(); ++csit) {
auto xpos = csit->second.find_first_of(L'|');//setname|extra info auto xpos = csit->second.find_first_of(L'|');//setname|another setname or extra info
if(csit->second.compare(0, xpos, setname) == 0) if(csit->second.compare(0, xpos, setname) == 0 || csit->second.compare(xpos + 1, csit->second.length(), setname) == 0 || mainGame->CheckRegEx(csit->second, setname, true))
return csit->first; return csit->first;
} }
return 0; return 0;
...@@ -309,5 +349,45 @@ int DataManager::CardReader(int code, void* pData) { ...@@ -309,5 +349,45 @@ int DataManager::CardReader(int code, void* pData) {
memset(pData, 0, sizeof(CardData)); memset(pData, 0, sizeof(CardData));
return 0; return 0;
} }
byte* DataManager::ScriptReaderEx(const char* script_name, int* slen) {
byte* buffer;
if(!mainGame->gameConf.prefer_expansion_script) {
buffer = ScriptReaderExSingle("", script_name, slen);
if(buffer)
return buffer;
}
buffer = ScriptReaderExSingle("specials/", script_name, slen, 9);
if(buffer)
return buffer;
buffer = ScriptReaderExSingle("expansions/", script_name, slen);
if(buffer)
return buffer;
return ScriptReaderExSingle("", script_name, slen);
}
byte* DataManager::ScriptReaderExSingle(const char* path, const char* script_name, int* slen, int pre_len) {
char sname[256];
sprintf(sname, "%s%s", path, script_name + pre_len); //default script name: ./script/c%d.lua
return ScriptReader(sname, slen);
}
byte* DataManager::ScriptReader(const char* script_name, int* slen) {
#ifdef _WIN32
wchar_t fname[256];
BufferIO::DecodeUTF8(script_name, fname);
IReadFile* reader = FileSystem->createAndOpenFile(fname);
#else
IReadFile* reader = FileSystem->createAndOpenFile(script_name);
#endif
if(reader == NULL)
return 0;
size_t size = reader->getSize();
if(size > sizeof(scriptBuffer)) {
reader->drop();
return 0;
}
reader->read(scriptBuffer, size);
reader->drop();
*slen = size;
return scriptBuffer;
}
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "config.h" #include "config.h"
#include "sqlite3.h" #include "sqlite3.h"
#include "spmemvfs/spmemvfs.h"
#include "client_card.h" #include "client_card.h"
#include <unordered_map> #include <unordered_map>
...@@ -11,9 +12,11 @@ namespace ygo { ...@@ -11,9 +12,11 @@ namespace ygo {
class DataManager { class DataManager {
public: public:
DataManager(): _datas(8192), _strings(8192) {} DataManager(): _datas(8192), _strings(8192) {}
bool LoadDB(const char* file); bool LoadDB(const wchar_t* wfile);
bool LoadStrings(const char* file); bool LoadStrings(const char* file);
bool Error(sqlite3* pDB, sqlite3_stmt* pStmt = 0); bool LoadStrings(IReadFile* reader);
void ReadStringConfLine(const char* linebuf);
bool Error(spmemvfs_db_t* pDB, sqlite3_stmt* pStmt = 0);
bool GetData(int code, CardData* pData); bool GetData(int code, CardData* pData);
code_pointer GetCodePointer(int code); code_pointer GetCodePointer(int code);
bool GetString(int code, CardString* pStr); bool GetString(int code, CardString* pStr);
...@@ -49,9 +52,13 @@ public: ...@@ -49,9 +52,13 @@ public:
wchar_t lmBuffer[32]; wchar_t lmBuffer[32];
static wchar_t strBuffer[4096]; static wchar_t strBuffer[4096];
static byte scriptBuffer[0x20000];
static const wchar_t* unknown_string; static const wchar_t* unknown_string;
static int CardReader(int, void*); static int CardReader(int, void*);
static byte* ScriptReaderEx(const char* script_name, int* slen);
static byte* ScriptReaderExSingle(const char* path, const char* script_name, int* slen, int pre_len = 2);
static byte* ScriptReader(const char* script_name, int* slen);
static IFileSystem* FileSystem;
}; };
extern DataManager dataManager; extern DataManager dataManager;
......
This diff is collapsed.
...@@ -60,12 +60,14 @@ public: ...@@ -60,12 +60,14 @@ public:
size_t pre_extrac; size_t pre_extrac;
size_t pre_sidec; size_t pre_sidec;
code_pointer draging_pointer; code_pointer draging_pointer;
int prev_category;
int prev_deck; int prev_deck;
s32 prev_operation; s32 prev_operation;
int prev_sel; int prev_sel;
bool is_modified; bool is_modified;
bool readonly;
std::unordered_map<int, int>* filterList; const std::unordered_map<int, int>* filterList;
std::vector<code_pointer> results; std::vector<code_pointer> results;
wchar_t result_string[8]; wchar_t result_string[8];
}; };
......
This diff is collapsed.
...@@ -10,8 +10,8 @@ namespace ygo { ...@@ -10,8 +10,8 @@ namespace ygo {
struct LFList { struct LFList {
unsigned int hash; unsigned int hash;
wchar_t listName[20]; std::wstring listName;
std::unordered_map<int, int>* content; std::unordered_map<int, int> content;
}; };
struct Deck { struct Deck {
std::vector<code_pointer> main; std::vector<code_pointer> main;
...@@ -35,18 +35,27 @@ public: ...@@ -35,18 +35,27 @@ public:
Deck current_deck; Deck current_deck;
std::vector<LFList> _lfList; std::vector<LFList> _lfList;
void LoadLFListSingle(const char* path);
void LoadLFList(); void LoadLFList();
wchar_t* GetLFListName(int lfhash); const wchar_t* GetLFListName(int lfhash);
const std::unordered_map<int, int>* GetLFListContent(int lfhash);
int CheckDeck(Deck& deck, int lfhash, bool allow_ocg, bool allow_tcg); int CheckDeck(Deck& deck, int lfhash, bool allow_ocg, bool allow_tcg);
int LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec); int LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec);
bool LoadSide(Deck& deck, int* dbuf, int mainc, int sidec); bool LoadSide(Deck& deck, int* dbuf, int mainc, int sidec);
void GetCategoryPath(wchar_t* ret, int index, const wchar_t* text);
void GetDeckFile(wchar_t* ret, irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck);
bool LoadDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck);
FILE* OpenDeckFile(const wchar_t * file, const char * mode); FILE* OpenDeckFile(const wchar_t * file, const char * mode);
bool LoadDeck(const wchar_t* file); bool LoadDeck(const wchar_t* file);
bool SaveDeck(Deck& deck, const wchar_t* name); bool SaveDeck(Deck& deck, const wchar_t* file);
bool DeleteDeck(Deck& deck, const wchar_t* name); bool DeleteDeck(const wchar_t* file);
static bool RenameDeck(const wchar_t* oldname, const wchar_t* newname);
wchar_t DeckFormatBuffer[128]; wchar_t DeckFormatBuffer[128];
int TypeCount(std::vector<code_pointer> list, unsigned int ctype); int TypeCount(std::vector<code_pointer> list, unsigned int ctype);
bool LoadDeckFromCode(Deck& deck, const char *code, int len);
int SaveDeckToCode(Deck &deck, char *code);
bool CreateCategory(const wchar_t* name);
bool RenameCategory(const wchar_t* oldname, const wchar_t* newname);
bool DeleteCategory(const wchar_t* name);
}; };
extern DeckManager deckManager; extern DeckManager deckManager;
......
...@@ -126,7 +126,7 @@ void Game::DrawBackGround() { ...@@ -126,7 +126,7 @@ void Game::DrawBackGround() {
driver->drawVertexPrimitiveList(matManager.vField, 4, matManager.iRectangle, 2); driver->drawVertexPrimitiveList(matManager.vField, 4, matManager.iRectangle, 2);
driver->setMaterial(matManager.mBackLine); driver->setMaterial(matManager.mBackLine);
//select field //select field
if(dInfo.curMsg == MSG_SELECT_PLACE || dInfo.curMsg == MSG_SELECT_DISFIELD) { if(dInfo.curMsg == MSG_SELECT_PLACE || dInfo.curMsg == MSG_SELECT_DISFIELD || dInfo.curMsg == MSG_HINT) {
float cv[4] = {0.0f, 0.0f, 1.0f, 1.0f}; float cv[4] = {0.0f, 0.0f, 1.0f, 1.0f};
unsigned int filter = 0x1; unsigned int filter = 0x1;
for (int i = 0; i < 7; ++i, filter <<= 1) { for (int i = 0; i < 7; ++i, filter <<= 1) {
...@@ -405,7 +405,8 @@ void Game::DrawCard(ClientCard* pcard) { ...@@ -405,7 +405,8 @@ void Game::DrawCard(ClientCard* pcard) {
matManager.mTexture.setTexture(0, imageManager.tChainTarget); matManager.mTexture.setTexture(0, imageManager.tChainTarget);
driver->setMaterial(matManager.mTexture); driver->setMaterial(matManager.mTexture);
driver->drawVertexPrimitiveList(matManager.vSymbol, 4, matManager.iRectangle, 2); driver->drawVertexPrimitiveList(matManager.vSymbol, 4, matManager.iRectangle, 2);
} else if(pcard->is_disabled && (pcard->location & LOCATION_ONFIELD) && (pcard->position & POS_FACEUP)) { } else if((pcard->status & (STATUS_DISABLED | STATUS_FORBIDDEN))
&& (pcard->location & LOCATION_ONFIELD) && (pcard->position & POS_FACEUP)) {
matManager.mTexture.setTexture(0, imageManager.tNegated); matManager.mTexture.setTexture(0, imageManager.tNegated);
driver->setMaterial(matManager.mTexture); driver->setMaterial(matManager.mTexture);
driver->drawVertexPrimitiveList(matManager.vNegate, 4, matManager.iRectangle, 2); driver->drawVertexPrimitiveList(matManager.vNegate, 4, matManager.iRectangle, 2);
...@@ -414,7 +415,8 @@ void Game::DrawCard(ClientCard* pcard) { ...@@ -414,7 +415,8 @@ void Game::DrawCard(ClientCard* pcard) {
matManager.mTexture.setTexture(0, imageManager.tAttack); matManager.mTexture.setTexture(0, imageManager.tAttack);
driver->setMaterial(matManager.mTexture); driver->setMaterial(matManager.mTexture);
irr::core::matrix4 atk; irr::core::matrix4 atk;
atk.setTranslation(pcard->curPos + vector3df(0, -atkdy / 4.0f - 0.35f, 0.05f)); atk.setTranslation(pcard->curPos + vector3df(0, (pcard->controler == 0 ? -1 : 1) * (atkdy / 4.0f + 0.35f), 0.05f));
atk.setRotationRadians(vector3df(0, 0, pcard->controler == 0 ? 0 : 3.1415926f));
driver->setTransform(irr::video::ETS_WORLD, atk); driver->setTransform(irr::video::ETS_WORLD, atk);
driver->drawVertexPrimitiveList(matManager.vSymbol, 4, matManager.iRectangle, 2); driver->drawVertexPrimitiveList(matManager.vSymbol, 4, matManager.iRectangle, 2);
} }
...@@ -567,6 +569,12 @@ void Game::DrawMisc() { ...@@ -567,6 +569,12 @@ void Game::DrawMisc() {
DrawShadowText(numFont, dInfo.str_card_count[0], Resize(550, 31, 575, 50), Resize(0, 1, 2, 0), dInfo.card_count_color[0], 0xff000000, true, false, 0); DrawShadowText(numFont, dInfo.str_card_count[0], Resize(550, 31, 575, 50), Resize(0, 1, 2, 0), dInfo.card_count_color[0], 0xff000000, true, false, 0);
DrawShadowText(numFont, dInfo.str_card_count[1], Resize(757, 31, 782, 50), Resize(0, 1, 2, 0), dInfo.card_count_color[1], 0xff000000, true, false, 0); DrawShadowText(numFont, dInfo.str_card_count[1], Resize(757, 31, 782, 50), Resize(0, 1, 2, 0), dInfo.card_count_color[1], 0xff000000, true, false, 0);
DrawShadowText(numFont, dInfo.str_total_attack[0], Resize(486, 31, 536, 50), Resize(0, 1, 2, 0), dInfo.total_attack_color[0], 0xff000000, true, false, 0);
DrawShadowText(numFont, dInfo.str_total_attack[1], Resize(793, 31, 843, 50), Resize(0, 1, 2, 0), dInfo.total_attack_color[1], 0xff000000, true, false, 0);
driver->draw2DImage(imageManager.tAttack, ResizeCardMid(477, 32, 486, 50, 486, 41), recti(32, 0, 96, 128), 0, 0, true);
driver->draw2DImage(imageManager.tAttack, ResizeCardMid(784, 32, 793, 50, 793, 41), recti(32, 0, 96, 128), 0, 0, true);
/* /*
driver->draw2DRectangle(Resize(525, 34, 525 + dInfo.time_left[0] * 100 / dInfo.time_limit, 44), 0xa0e0e0e0, 0xa0e0e0e0, 0xa0c0c0c0, 0xa0c0c0c0); driver->draw2DRectangle(Resize(525, 34, 525 + dInfo.time_left[0] * 100 / dInfo.time_limit, 44), 0xa0e0e0e0, 0xa0e0e0e0, 0xa0c0c0c0, 0xa0c0c0c0);
driver->draw2DRectangleOutline(Resize(525, 34, 625, 44), 0xffffffff); driver->draw2DRectangleOutline(Resize(525, 34, 625, 44), 0xffffffff);
...@@ -580,6 +588,12 @@ void Game::DrawMisc() { ...@@ -580,6 +588,12 @@ void Game::DrawMisc() {
DrawShadowText(numFont, dInfo.str_card_count[0], Resize(600, 31, 625, 50), Resize(0, 1, 2, 0), dInfo.card_count_color[0], 0xff000000, true, false, 0); DrawShadowText(numFont, dInfo.str_card_count[0], Resize(600, 31, 625, 50), Resize(0, 1, 2, 0), dInfo.card_count_color[0], 0xff000000, true, false, 0);
DrawShadowText(numFont, dInfo.str_card_count[1], Resize(707, 31, 732, 50), Resize(0, 1, 2, 0), dInfo.card_count_color[1], 0xff000000, true, false, 0); DrawShadowText(numFont, dInfo.str_card_count[1], Resize(707, 31, 732, 50), Resize(0, 1, 2, 0), dInfo.card_count_color[1], 0xff000000, true, false, 0);
DrawShadowText(numFont, dInfo.str_total_attack[0], Resize(536, 31, 586, 50), Resize(0, 1, 2, 0), dInfo.total_attack_color[0], 0xff000000, true, false, 0);
DrawShadowText(numFont, dInfo.str_total_attack[1], Resize(743, 31, 793, 50), Resize(0, 1, 2, 0), dInfo.total_attack_color[1], 0xff000000, true, false, 0);
driver->draw2DImage(imageManager.tAttack, ResizeCardMid(527, 32, 536, 50, 536, 41), recti(32, 0, 96, 128), 0, 0, true);
driver->draw2DImage(imageManager.tAttack, ResizeCardMid(734, 32, 743, 50, 743, 41), recti(32, 0, 96, 128), 0, 0, true);
} }
DrawShadowText(numFont, dInfo.strLP[0], Resize(330, 12, 631, 30), Resize(0, 1, 2, 0), 0xffffff00, 0xff000000, true, false, 0); DrawShadowText(numFont, dInfo.strLP[0], Resize(330, 12, 631, 30), Resize(0, 1, 2, 0), 0xffffff00, 0xff000000, true, false, 0);
DrawShadowText(numFont, dInfo.strLP[1], Resize(691, 12, 992, 30), Resize(0, 1, 2, 0), 0xffffff00, 0xff000000, true, false, 0); DrawShadowText(numFont, dInfo.strLP[1], Resize(691, 12, 992, 30), Resize(0, 1, 2, 0), 0xffffff00, 0xff000000, true, false, 0);
...@@ -897,8 +911,8 @@ void Game::DrawSpec() { ...@@ -897,8 +911,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,21 +970,24 @@ void Game::DrawSpec() { ...@@ -956,21 +970,24 @@ 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;
} }
} }
if (auto_watch_mode && showcardcode > 9999 && (showcardcode & 0xFFFCFFFC) > 0) {
mainGame->ShowCardInfo(showcardcode);
}
} }
if(is_attacking) { if(is_attacking) {
irr::core::matrix4 matk; irr::core::matrix4 matk;
...@@ -1023,7 +1040,7 @@ void Game::ShowElement(irr::gui::IGUIElement * win, int autoframe) { ...@@ -1023,7 +1040,7 @@ void Game::ShowElement(irr::gui::IGUIElement * win, int autoframe) {
FadingUnit fu; FadingUnit fu;
fu.fadingSize = win->getRelativePosition(); fu.fadingSize = win->getRelativePosition();
for(auto fit = fadingList.begin(); fit != fadingList.end(); ++fit) for(auto fit = fadingList.begin(); fit != fadingList.end(); ++fit)
if(win == fit->guiFading && win != wOptions) // the size of wOptions is always setted by ClientField::ShowSelectOption before showing it if(win == fit->guiFading && win != wOptions && win != wANNumber) // the size of wOptions is always setted by ClientField::ShowSelectOption before showing it
fu.fadingSize = fit->fadingSize; fu.fadingSize = fit->fadingSize;
irr::core::position2di center = fu.fadingSize.getCenter(); irr::core::position2di center = fu.fadingSize.getCenter();
fu.fadingDiff.X = fu.fadingSize.getWidth() / 10; fu.fadingDiff.X = fu.fadingSize.getWidth() / 10;
...@@ -1079,10 +1096,16 @@ void Game::HideElement(irr::gui::IGUIElement * win, bool set_action) { ...@@ -1079,10 +1096,16 @@ void Game::HideElement(irr::gui::IGUIElement * win, bool set_action) {
for(int i = 0; i < 5; ++i) for(int i = 0; i < 5; ++i)
btnCardSelect[i]->setDrawImage(false); btnCardSelect[i]->setDrawImage(false);
dField.conti_selecting = false; dField.conti_selecting = false;
stCardListTip->setVisible(false);
for(auto& pcard : dField.selectable_cards)
dField.SetShowMark(pcard, false);
} }
if(win == wCardDisplay) { if(win == wCardDisplay) {
for(int i = 0; i < 5; ++i) for(int i = 0; i < 5; ++i)
btnCardDisplay[i]->setDrawImage(false); btnCardDisplay[i]->setDrawImage(false);
stCardListTip->setVisible(false);
for(auto& pcard : dField.display_cards)
dField.SetShowMark(pcard, false);
} }
fadingList.push_back(fu); fadingList.push_back(fu);
} }
...@@ -1101,7 +1124,7 @@ void Game::WaitFrameSignal(int frame) { ...@@ -1101,7 +1124,7 @@ void Game::WaitFrameSignal(int frame) {
signalFrame = (gameConf.quick_animation && frame >= 12) ? 12 : frame; signalFrame = (gameConf.quick_animation && frame >= 12) ? 12 : frame;
frameSignal.Wait(); frameSignal.Wait();
} }
void Game::DrawThumb(code_pointer cp, position2di pos, std::unordered_map<int, int>* lflist, bool drag) { void Game::DrawThumb(code_pointer cp, position2di pos, const std::unordered_map<int,int>* lflist, bool drag) {
int code = cp->first; int code = cp->first;
int lcode = cp->second.alias; int lcode = cp->second.alias;
if(lcode == 0) if(lcode == 0)
...@@ -1116,11 +1139,11 @@ void Game::DrawThumb(code_pointer cp, position2di pos, std::unordered_map<int, i ...@@ -1116,11 +1139,11 @@ void Game::DrawThumb(code_pointer cp, position2di pos, std::unordered_map<int, i
if(drag) { if(drag) {
dragloc = recti(pos.X, pos.Y, pos.X + CARD_THUMB_WIDTH * mainGame->xScale, pos.Y + CARD_THUMB_HEIGHT * mainGame->yScale); dragloc = recti(pos.X, pos.Y, pos.X + CARD_THUMB_WIDTH * mainGame->xScale, pos.Y + CARD_THUMB_HEIGHT * mainGame->yScale);
limitloc = recti(pos.X, pos.Y, pos.X + 20 * mainGame->xScale, pos.Y + 20 * mainGame->yScale); limitloc = recti(pos.X, pos.Y, pos.X + 20 * mainGame->xScale, pos.Y + 20 * mainGame->yScale);
otloc = recti(pos.X + 7, pos.Y + 50, pos.X + 37 * mainGame->xScale, pos.Y + 65 * mainGame->yScale); otloc = recti(pos.X + 7, pos.Y + 50 * mainGame->yScale, pos.X + 37 * mainGame->xScale, pos.Y + 65 * mainGame->yScale);
} }
driver->draw2DImage(img, dragloc, rect<s32>(0, 0, size.Width, size.Height)); driver->draw2DImage(img, dragloc, rect<s32>(0, 0, size.Width, size.Height));
if(lflist->count(lcode)) { if(lflist->count(lcode)) {
switch((*lflist)[lcode]) { switch((*lflist).at(lcode)) {
case 0: case 0:
driver->draw2DImage(imageManager.tLim, limitloc, recti(0, 0, 64, 64), 0, 0, true); driver->draw2DImage(imageManager.tLim, limitloc, recti(0, 0, 64, 64), 0, 0, true);
break; break;
...@@ -1258,8 +1281,8 @@ void Game::DrawDeckBd() { ...@@ -1258,8 +1281,8 @@ void Game::DrawDeckBd() {
driver->draw2DRectangleOutline(Resize(313 + i * dx, 563, 359 + i * dx, 629)); driver->draw2DRectangleOutline(Resize(313 + i * dx, 563, 359 + i * dx, 629));
} }
//search result //search result
driver->draw2DRectangle(Resize(805, 137, 915, 157), 0x400000ff, 0x400000ff, 0x40000000, 0x40000000); driver->draw2DRectangle(Resize(805, 137, 926, 157), 0x400000ff, 0x400000ff, 0x40000000, 0x40000000);
driver->draw2DRectangleOutline(Resize(804, 136, 915, 157)); driver->draw2DRectangleOutline(Resize(804, 136, 926, 157));
DrawShadowText(textFont, dataManager.GetSysString(1333), Resize(810, 137, 915, 157), Resize(1, 1, 1, 1), 0xffffffff, 0xff000000, false, true); DrawShadowText(textFont, dataManager.GetSysString(1333), Resize(810, 137, 915, 157), Resize(1, 1, 1, 1), 0xffffffff, 0xff000000, false, true);
DrawShadowText(numFont, deckBuilder.result_string, Resize(875, 137, 935, 157), Resize(1, 1, 1, 1), 0xffffffff, 0xff000000, false, true); DrawShadowText(numFont, deckBuilder.result_string, Resize(875, 137, 935, 157), Resize(1, 1, 1, 1), 0xffffffff, 0xff000000, false, true);
driver->draw2DRectangle(Resize(805, 160, 1020, 630), 0x400000ff, 0x400000ff, 0x40000000, 0x40000000); driver->draw2DRectangle(Resize(805, 160, 1020, 630), 0x400000ff, 0x400000ff, 0x40000000, 0x40000000);
......
This diff is collapsed.
...@@ -29,7 +29,12 @@ private: ...@@ -29,7 +29,12 @@ private:
static char duel_client_read[0x2000]; static char duel_client_read[0x2000];
static char duel_client_write[0x2000]; static char duel_client_write[0x2000];
static bool is_closing; static bool is_closing;
static bool is_swapping;
static int select_hint; static int select_hint;
static int select_unselect_hint;
static int last_select_hint;
static char last_successful_msg[0x2000];
static unsigned int last_successful_msg_length;
static wchar_t event_string[256]; static wchar_t event_string[256];
static mtrandom rnd; static mtrandom rnd;
public: public:
...@@ -43,9 +48,10 @@ public: ...@@ -43,9 +48,10 @@ public:
static void StopClient(bool is_exiting = false); static void StopClient(bool is_exiting = false);
static void ClientRead(bufferevent* bev, void* ctx); static void ClientRead(bufferevent* bev, void* ctx);
static void ClientEvent(bufferevent *bev, short events, void *ctx); static void ClientEvent(bufferevent *bev, short events, void *ctx);
static int ClientThread(void* param); static int ClientThread();
static void HandleSTOCPacketLan(char* data, unsigned int len); static void HandleSTOCPacketLan(char* data, unsigned int len);
static int ClientAnalyze(char* msg, unsigned int len); static int ClientAnalyze(char* msg, unsigned int len);
static void SwapField();
static void SetResponseI(int respI); static void SetResponseI(int respI);
static void SetResponseB(void* respB, unsigned char len); static void SetResponseB(void* respB, unsigned char len);
static void SendResponse(); static void SendResponse();
...@@ -53,6 +59,9 @@ public: ...@@ -53,6 +59,9 @@ public:
char* p = duel_client_write; char* p = duel_client_write;
BufferIO::WriteInt16(p, 1); BufferIO::WriteInt16(p, 1);
BufferIO::WriteInt8(p, proto); BufferIO::WriteInt8(p, proto);
#ifdef YGOPRO_MESSAGE_DEBUG
printf("CTOS: %d\n", proto);
#endif
bufferevent_write(client_bev, duel_client_write, 3); bufferevent_write(client_bev, duel_client_write, 3);
} }
template<typename ST> template<typename ST>
...@@ -61,6 +70,9 @@ public: ...@@ -61,6 +70,9 @@ public:
BufferIO::WriteInt16(p, 1 + sizeof(ST)); BufferIO::WriteInt16(p, 1 + sizeof(ST));
BufferIO::WriteInt8(p, proto); BufferIO::WriteInt8(p, proto);
memcpy(p, &st, sizeof(ST)); memcpy(p, &st, sizeof(ST));
#ifdef YGOPRO_MESSAGE_DEBUG
printf("CTOS: %d Length: %d\n", proto, sizeof(ST));
#endif
bufferevent_write(client_bev, duel_client_write, sizeof(ST) + 3); bufferevent_write(client_bev, duel_client_write, sizeof(ST) + 3);
} }
static void SendBufferToServer(unsigned char proto, void* buffer, size_t len) { static void SendBufferToServer(unsigned char proto, void* buffer, size_t len) {
...@@ -68,6 +80,9 @@ public: ...@@ -68,6 +80,9 @@ public:
BufferIO::WriteInt16(p, 1 + len); BufferIO::WriteInt16(p, 1 + len);
BufferIO::WriteInt8(p, proto); BufferIO::WriteInt8(p, proto);
memcpy(p, buffer, len); memcpy(p, buffer, len);
#ifdef YGOPRO_MESSAGE_DEBUG
printf("CTOS: %d Length: %d\n", proto, len);
#endif
bufferevent_write(client_bev, duel_client_write, len + 3); bufferevent_write(client_bev, duel_client_write, len + 3);
} }
...@@ -78,8 +93,10 @@ protected: ...@@ -78,8 +93,10 @@ protected:
static std::set<unsigned int> remotes; static std::set<unsigned int> remotes;
public: public:
static std::vector<HostPacket> hosts; static std::vector<HostPacket> hosts;
static std::vector<std::wstring> hosts_srvpro;
static bool is_srvpro;
static void BeginRefreshHost(); static void BeginRefreshHost();
static int RefreshThread(void* arg); static int RefreshThread(event_base* broadev);
static void BroadcastReply(evutil_socket_t fd, short events, void* arg); static void BroadcastReply(evutil_socket_t fd, short events, void* arg);
}; };
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
int enable_log = 0; int enable_log = 0;
bool exit_on_return = false; bool exit_on_return = false;
bool auto_watch_mode = false;
bool open_file = false; bool open_file = false;
wchar_t open_file_name[256] = L""; wchar_t open_file_name[256] = L"";
bool bot_mode = false; bool bot_mode = false;
...@@ -77,17 +78,13 @@ int main(int argc, char* argv[]) { ...@@ -77,17 +78,13 @@ int main(int argc, char* argv[]) {
bool keep_on_return = false; bool keep_on_return = false;
for(int i = 1; i < wargc; ++i) { for(int i = 1; i < wargc; ++i) {
if(wargv[i][0] == L'-' && wargv[i][1] == L'e' && wargv[i][2] != L'\0') { if(wargv[i][0] == L'-' && wargv[i][1] == L'e' && wargv[i][2] != L'\0') {
char param[128]; ygo::dataManager.LoadDB(&wargv[i][2]);
BufferIO::EncodeUTF8(&wargv[i][2], param);
ygo::dataManager.LoadDB(param);
continue; continue;
} }
if(!wcscmp(wargv[i], L"-e")) { // extra database if(!wcscmp(wargv[i], L"-e")) { // extra database
++i; ++i;
if(i < wargc) { if(i < wargc) {
char param[128]; ygo::dataManager.LoadDB(wargv[i]);
BufferIO::EncodeUTF8(wargv[i], param);
ygo::dataManager.LoadDB(param);
} }
continue; continue;
} else if(!wcscmp(wargv[i], L"-n")) { // nickName } else if(!wcscmp(wargv[i], L"-n")) { // nickName
...@@ -113,9 +110,12 @@ int main(int argc, char* argv[]) { ...@@ -113,9 +110,12 @@ int main(int argc, char* argv[]) {
} else if(!wcscmp(wargv[i], L"-k")) { // Keep on return } else if(!wcscmp(wargv[i], L"-k")) { // Keep on return
exit_on_return = false; exit_on_return = false;
keep_on_return = true; keep_on_return = true;
} else if(!wcscmp(wargv[i], L"--auto-watch")) { // Auto watch mode
auto_watch_mode = true;
} else if(!wcscmp(wargv[i], L"-d")) { // Deck } else if(!wcscmp(wargv[i], L"-d")) { // Deck
++i; ++i;
if(i + 1 < wargc) { // select deck if(i + 1 < wargc) { // select deck
ygo::mainGame->gameConf.lastcategory[0] = 0;
wcscpy(ygo::mainGame->gameConf.lastdeck, wargv[i]); wcscpy(ygo::mainGame->gameConf.lastdeck, wargv[i]);
continue; continue;
} else { // open deck } else { // open deck
......
This diff is collapsed.
...@@ -21,8 +21,7 @@ public: ...@@ -21,8 +21,7 @@ public:
void ClearTexture(); void ClearTexture();
void RemoveTexture(int code); void RemoveTexture(int code);
void ResizeTexture(); void ResizeTexture();
irr::video::ITexture* GetTextureFromFile(char* file, s32 width, s32 height); irr::video::ITexture* GetTextureFromFile(const char* file, s32 width, s32 height);
irr::video::ITexture* GetTextureUnknown(s32 width, s32 height, int index);
irr::video::ITexture* GetTexture(int code, bool fit = false); irr::video::ITexture* GetTexture(int code, bool fit = false);
irr::video::ITexture* GetTextureThumb(int code); irr::video::ITexture* GetTextureThumb(int code);
irr::video::ITexture* GetTextureField(int code); irr::video::ITexture* GetTextureField(int code);
...@@ -33,7 +32,9 @@ public: ...@@ -33,7 +32,9 @@ public:
irr::IrrlichtDevice* device; irr::IrrlichtDevice* device;
irr::video::IVideoDriver* driver; irr::video::IVideoDriver* driver;
irr::video::ITexture* tCover[4]; irr::video::ITexture* tCover[4];
irr::video::ITexture* tUnknown[3]; irr::video::ITexture* tUnknown;
irr::video::ITexture* tUnknownFit;
irr::video::ITexture* tUnknownThumb;
irr::video::ITexture* tAct; irr::video::ITexture* tAct;
irr::video::ITexture* tAttack; irr::video::ITexture* tAttack;
irr::video::ITexture* tNegated; irr::video::ITexture* tNegated;
......
project (clzma)
set (AUTO_FILES_RESULT)
AutoFiles("." "src" "\\.(cpp|c|h)$")
add_library (clzma STATIC ${AUTO_FILES_RESULT})
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
namespace ygo { namespace ygo {
void UpdateDeck() { void UpdateDeck() {
BufferIO::CopyWStr(mainGame->cbCategorySelect->getItem(mainGame->cbCategorySelect->getSelected()),
mainGame->gameConf.lastcategory, 64);
BufferIO::CopyWStr(mainGame->cbDeckSelect->getItem(mainGame->cbDeckSelect->getSelected()), BufferIO::CopyWStr(mainGame->cbDeckSelect->getItem(mainGame->cbDeckSelect->getSelected()),
mainGame->gameConf.lastdeck, 64); mainGame->gameConf.lastdeck, 64);
char deckbuf[1024]; char deckbuf[1024];
...@@ -62,6 +64,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -62,6 +64,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
} }
case BUTTON_JOIN_HOST: { case BUTTON_JOIN_HOST: {
bot_mode = false; bot_mode = false;
mainGame->TrimText(mainGame->ebJoinHost);
mainGame->TrimText(mainGame->ebJoinPort);
char ip[20]; char ip[20];
const wchar_t* pstr = mainGame->ebJoinHost->getText(); const wchar_t* pstr = mainGame->ebJoinHost->getText();
BufferIO::CopyWStr(pstr, ip, 16); BufferIO::CopyWStr(pstr, ip, 16);
...@@ -80,10 +84,14 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -80,10 +84,14 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
hints.ai_flags = EVUTIL_AI_ADDRCONFIG; hints.ai_flags = EVUTIL_AI_ADDRCONFIG;
int status = evutil_getaddrinfo(hostname, port, &hints, &answer); int status = evutil_getaddrinfo(hostname, port, &hints, &answer);
if(status != 0) { if(status != 0) {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
soundManager.PlaySoundEffect(SOUND_INFO); soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1412)); mainGame->env->addMessageBox(L"", dataManager.GetSysString(1412));
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
if (auto_watch_mode) {
mainGame->actionSignal.Wait(2000);
mainGame->device->closeDevice();
}
break; break;
} else { } else {
sockaddr_in * sin = ((struct sockaddr_in *)answer->ai_addr); sockaddr_in * sin = ((struct sockaddr_in *)answer->ai_addr);
...@@ -141,6 +149,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -141,6 +149,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_HP_DUELIST: { case BUTTON_HP_DUELIST: {
mainGame->cbCategorySelect->setEnabled(true);
mainGame->cbDeckSelect->setEnabled(true); mainGame->cbDeckSelect->setEnabled(true);
DuelClient::SendPacketToServer(CTOS_HS_TODUELIST); DuelClient::SendPacketToServer(CTOS_HS_TODUELIST);
break; break;
...@@ -162,17 +171,19 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -162,17 +171,19 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_HP_READY: { case BUTTON_HP_READY: {
if(mainGame->cbDeckSelect->getSelected() == -1 || if(mainGame->cbCategorySelect->getSelected() == -1 || mainGame->cbDeckSelect->getSelected() == -1 ||
!deckManager.LoadDeck(mainGame->cbDeckSelect->getItem(mainGame->cbDeckSelect->getSelected()))) { !deckManager.LoadDeck(mainGame->cbCategorySelect, mainGame->cbDeckSelect)) {
break; break;
} }
UpdateDeck(); UpdateDeck();
DuelClient::SendPacketToServer(CTOS_HS_READY); DuelClient::SendPacketToServer(CTOS_HS_READY);
mainGame->cbCategorySelect->setEnabled(false);
mainGame->cbDeckSelect->setEnabled(false); mainGame->cbDeckSelect->setEnabled(false);
break; break;
} }
case BUTTON_HP_NOTREADY: { case BUTTON_HP_NOTREADY: {
DuelClient::SendPacketToServer(CTOS_HS_NOTREADY); DuelClient::SendPacketToServer(CTOS_HS_NOTREADY);
mainGame->cbCategorySelect->setEnabled(true);
mainGame->cbDeckSelect->setEnabled(true); mainGame->cbDeckSelect->setEnabled(true);
break; break;
} }
...@@ -245,12 +256,12 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -245,12 +256,12 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int sel = mainGame->lstReplayList->getSelected(); int sel = mainGame->lstReplayList->getSelected();
if(sel == -1) if(sel == -1)
break; break;
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, textBuffer);
mainGame->PopupElement(mainGame->wQuery); mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
prev_operation = id; prev_operation = id;
prev_sel = sel; prev_sel = sel;
break; break;
...@@ -259,11 +270,11 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -259,11 +270,11 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int sel = mainGame->lstReplayList->getSelected(); int sel = mainGame->lstReplayList->getSelected();
if(sel == -1) if(sel == -1)
break; break;
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->wReplaySave->setText(dataManager.GetSysString(1364)); mainGame->wReplaySave->setText(dataManager.GetSysString(1364));
mainGame->ebRSName->setText(mainGame->lstReplayList->getListItem(sel)); mainGame->ebRSName->setText(mainGame->lstReplayList->getListItem(sel));
mainGame->PopupElement(mainGame->wReplaySave); mainGame->PopupElement(mainGame->wReplaySave);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
prev_operation = id; prev_operation = id;
prev_sel = sel; prev_sel = sel;
break; break;
...@@ -302,7 +313,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -302,7 +313,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int extra = replay.ReadInt32(); int extra = replay.ReadInt32();
for(int j = 0; j < extra; ++j) for(int j = 0; j < extra; ++j)
tmp_deck.extra.push_back(dataManager.GetCodePointer(replay.ReadInt32())); tmp_deck.extra.push_back(dataManager.GetCodePointer(replay.ReadInt32()));
myswprintf(filename, L"%ls %ls", ex_filename, namebuf[i]); myswprintf(filename, L"./deck/%ls %ls.ydk", ex_filename, namebuf[i]);
deckManager.SaveDeck(tmp_deck, filename); deckManager.SaveDeck(tmp_deck, filename);
} }
mainGame->stACMessage->setText(dataManager.GetSysString(1335)); mainGame->stACMessage->setText(dataManager.GetSysString(1335));
...@@ -321,7 +332,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -321,7 +332,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
NetServer::StopServer(); NetServer::StopServer();
break; break;
} }
STARTUPINFO si; STARTUPINFOW si;
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si)); ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si); si.cb = sizeof(si);
...@@ -374,7 +385,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -374,7 +385,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_DECK_EDIT: { case BUTTON_DECK_EDIT: {
mainGame->RefreshDeck(mainGame->cbDBDecks); mainGame->RefreshCategoryDeck(mainGame->cbDBCategory, mainGame->cbDBDecks);
if(open_file && deckManager.LoadDeck(open_file_name)) { if(open_file && deckManager.LoadDeck(open_file_name)) {
#ifdef WIN32 #ifdef WIN32
wchar_t *dash = wcsrchr(open_file_name, L'\\'); wchar_t *dash = wcsrchr(open_file_name, L'\\');
...@@ -397,8 +408,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -397,8 +408,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
} }
} }
open_file = false; open_file = false;
} else if(mainGame->cbDBDecks->getSelected() != -1) { } else if(mainGame->cbDBCategory->getSelected() != -1 && mainGame->cbDBDecks->getSelected() != -1) {
deckManager.LoadDeck(mainGame->cbDBDecks->getItem(mainGame->cbDBDecks->getSelected())); deckManager.LoadDeck(mainGame->cbDBCategory, mainGame->cbDBDecks);
mainGame->ebDeckname->setText(L""); mainGame->ebDeckname->setText(L"");
} }
mainGame->HideElement(mainGame->wMainMenu); mainGame->HideElement(mainGame->wMainMenu);
...@@ -456,6 +467,10 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -456,6 +467,10 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int sel = mainGame->lstHostList->getSelected(); int sel = mainGame->lstHostList->getSelected();
if(sel == -1) if(sel == -1)
break; break;
if(DuelClient::is_srvpro) {
mainGame->ebJoinPass->setText(DuelClient::hosts_srvpro[sel].c_str());
break;
}
int addr = DuelClient::hosts[sel].ipaddr; int addr = DuelClient::hosts[sel].ipaddr;
int port = DuelClient::hosts[sel].port; int port = DuelClient::hosts[sel].port;
wchar_t buf[20]; wchar_t buf[20];
...@@ -475,7 +490,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -475,7 +490,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
std::wstring repinfo; std::wstring repinfo;
time_t curtime = ReplayMode::cur_replay.pheader.seed; time_t curtime = ReplayMode::cur_replay.pheader.seed;
tm* st = localtime(&curtime); tm* st = localtime(&curtime);
myswprintf(infobuf, L"%d/%d/%d %02d:%02d:%02d\n", st->tm_year + 1900, st->tm_mon + 1, st->tm_mday, st->tm_hour, st->tm_min, st->tm_sec); wcsftime(infobuf, 256, L"%Y/%m/%d %H:%M:%S\n", st);
repinfo.append(infobuf); repinfo.append(infobuf);
wchar_t namebuf[4][20]; wchar_t namebuf[4][20];
ReplayMode::cur_replay.ReadName(namebuf[0]); ReplayMode::cur_replay.ReadName(namebuf[0]);
...@@ -490,7 +505,57 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -490,7 +505,57 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
myswprintf(infobuf, L"%ls\n===VS===\n%ls\n", namebuf[0], namebuf[1]); myswprintf(infobuf, L"%ls\n===VS===\n%ls\n", namebuf[0], namebuf[1]);
repinfo.append(infobuf); repinfo.append(infobuf);
mainGame->ebRepStartTurn->setText(L"1"); mainGame->ebRepStartTurn->setText(L"1");
mainGame->SetStaticText(mainGame->stReplayInfo, 180, mainGame->guiFont, (wchar_t*)repinfo.c_str()); mainGame->SetStaticText(mainGame->stReplayInfo, 180, mainGame->guiFont, repinfo.c_str());
break;
}
case LISTBOX_SINGLEPLAY_LIST: {
int sel = mainGame->lstSinglePlayList->getSelected();
if(sel == -1)
break;
const wchar_t* name = mainGame->lstSinglePlayList->getListItem(sel);
wchar_t fname[256];
myswprintf(fname, L"./single/%ls", name);
FILE *fp;
#ifdef _WIN32
fp = _wfopen(fname, L"rb");
#else
char filename[256];
BufferIO::EncodeUTF8(fname, filename);
fp = fopen(filename, "rb");
#endif
if(!fp) {
mainGame->stSinglePlayInfo->setText(L"");
break;
}
char linebuf[1024];
wchar_t wlinebuf[1024];
std::wstring message = L"";
bool in_message = false;
while(fgets(linebuf, 1024, fp)) {
if(!strncmp(linebuf, "--[[message", 11)) {
size_t len = strlen(linebuf);
char* msgend = strrchr(linebuf, ']');
if(len <= 13) {
in_message = true;
continue;
} else if(len > 15 && msgend) {
*(msgend - 1) = '\0';
BufferIO::DecodeUTF8(linebuf + 12, wlinebuf);
message.append(wlinebuf);
break;
}
}
if(!strncmp(linebuf, "]]", 2)) {
in_message = false;
break;
}
if(in_message) {
BufferIO::DecodeUTF8(linebuf, wlinebuf);
message.append(wlinebuf);
}
}
fclose(fp);
mainGame->SetStaticText(mainGame->stSinglePlayInfo, 200, mainGame->guiFont, message.c_str());
break; break;
} }
case LISTBOX_BOT_LIST: { case LISTBOX_BOT_LIST: {
...@@ -510,24 +575,43 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -510,24 +575,43 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break; break;
mainGame->env->setFocus(mainGame->wHostPrepare); mainGame->env->setFocus(mainGame->wHostPrepare);
if(static_cast<irr::gui::IGUICheckBox*>(caller)->isChecked()) { if(static_cast<irr::gui::IGUICheckBox*>(caller)->isChecked()) {
if(mainGame->cbDeckSelect->getSelected() == -1 || if(mainGame->cbCategorySelect->getSelected() == -1 || mainGame->cbDeckSelect->getSelected() == -1 ||
!deckManager.LoadDeck(mainGame->cbDeckSelect->getItem(mainGame->cbDeckSelect->getSelected()))) { !deckManager.LoadDeck(mainGame->cbCategorySelect, mainGame->cbDeckSelect)) {
static_cast<irr::gui::IGUICheckBox*>(caller)->setChecked(false); static_cast<irr::gui::IGUICheckBox*>(caller)->setChecked(false);
break; break;
} }
UpdateDeck(); UpdateDeck();
DuelClient::SendPacketToServer(CTOS_HS_READY); DuelClient::SendPacketToServer(CTOS_HS_READY);
mainGame->cbCategorySelect->setEnabled(false);
mainGame->cbDeckSelect->setEnabled(false); mainGame->cbDeckSelect->setEnabled(false);
} else { } else {
DuelClient::SendPacketToServer(CTOS_HS_NOTREADY); DuelClient::SendPacketToServer(CTOS_HS_NOTREADY);
mainGame->cbCategorySelect->setEnabled(true);
mainGame->cbDeckSelect->setEnabled(true); mainGame->cbDeckSelect->setEnabled(true);
} }
break; break;
} }
case CHECKBOX_BOT_OLD_RULE: { }
break;
}
case irr::gui::EGET_COMBO_BOX_CHANGED: {
switch(id) {
case COMBOBOX_BOT_RULE: {
mainGame->RefreshBot(); mainGame->RefreshBot();
break; break;
} }
case COMBOBOX_HP_CATEGORY: {
int catesel = mainGame->cbCategorySelect->getSelected();
if(catesel == 3) {
catesel = 2;
mainGame->cbCategorySelect->setSelected(2);
}
if(catesel >= 0) {
mainGame->RefreshDeck(mainGame->cbCategorySelect, mainGame->cbDeckSelect);
mainGame->cbDeckSelect->setSelected(0);
}
break;
}
} }
break; break;
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -33,7 +33,7 @@ public: ...@@ -33,7 +33,7 @@ public:
static void ServerAcceptError(evconnlistener *listener, void* ctx); static void ServerAcceptError(evconnlistener *listener, void* ctx);
static void ServerEchoRead(bufferevent* bev, void* ctx); static void ServerEchoRead(bufferevent* bev, void* ctx);
static void ServerEchoEvent(bufferevent* bev, short events, void* ctx); static void ServerEchoEvent(bufferevent* bev, short events, void* ctx);
static int ServerThread(void* param); static int ServerThread();
static void DisconnectPlayer(DuelPlayer* dp); static void DisconnectPlayer(DuelPlayer* dp);
static void HandleCTOSPacket(DuelPlayer* dp, char* data, unsigned int len); static void HandleCTOSPacket(DuelPlayer* dp, char* data, unsigned int len);
static void SendPacketToPlayer(DuelPlayer* dp, unsigned char proto) { static void SendPacketToPlayer(DuelPlayer* dp, unsigned char proto) {
......
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.
project "cspmemvfs"
kind "StaticLib"
files { "**.c", "**.h" }
configuration "windows"
includedirs { "../../sqlite3" }
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.
project "ikpmp3"
kind "StaticLib"
files { "*.cpp", "*.h", "decoder/*.c", "decoder/*.h" }
includedirs { "../irrklang/include" }
This diff is collapsed.
This diff is collapsed.
Subproject commit 4021b88fece56ace8d56ba0ec000b9939e561adc Subproject commit 0585a44f2f9e8dc1028423fbdd1f066e7e8db44a
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