Commit 356092ea authored by 苍蓝's avatar 苍蓝

update

parent f8613a14
export ASSET_BRANCH_NAME="master"
# if $CI_COMMIT_REF_NAME includes develop or pre, then we use the develop branch
if [[ "$CI_COMMIT_REF_NAME" == *"develop"* || "$CI_COMMIT_REF_NAME" == *".pre"* ]]; then
export ASSET_BRANCH_NAME="develop"
fi
#!/bin/bash #!/bin/bash
set -x set -x
set -o errexit set -o errexit
source .ci/asset-branch
# ygopro-database # ygopro-database
apt update && apt -y install wget git libarchive-tools apt update && apt -y install wget git libarchive-tools sqlite3
git clone --depth=1 https://code.mycard.moe/nanahira/ygopro-database git clone --depth=1 -b master https://code.moenext.com/nanahira/ygopro-database
cp -rf ./ygopro-database/locales/$TARGET_LOCALE/* . cp -rf ./ygopro-database/locales/$TARGET_LOCALE/strings.conf .
cp -rf ./ygopro-database/locales/$TARGET_LOCALE/servers.conf .
rm -f cards.cdb
sqlite3 ./ygopro-database/locales/$TARGET_LOCALE/cards.cdb .dump | sqlite3 cards.cdb
# ygopro-images # ygopro-images
mkdir pics mkdir pics
wget -O - https://cdn01.moecube.com/images/ygopro-images-${TARGET_LOCALE}.zip | bsdtar -C pics -xf - if [[ "$ASSET_BRANCH_NAME" == "develop" ]]; then
echo "This is a pre-release, skipping download."
else
wget -O - https://cdn02.moecube.com:444/images/ygopro-images-${TARGET_LOCALE}.zip | bsdtar -C pics -xf -
fi
#!/bin/bash
libs_to_configure=(
"ogg"
# "opus"
)
cd miniaudio/external
for lib in "${libs_to_configure[@]}"; do
cd $lib
./configure
cd ..
done
#!/bin/sh
set -x
set -o errexit
cd event
./configure --disable-openssl --enable-static=yes --enable-shared=no
sed -f make-event-config.sed < config.h > ./include/event2/event-config.h
cd ..
...@@ -4,21 +4,19 @@ set -o errexit ...@@ -4,21 +4,19 @@ set -o errexit
TARGET_PLATFORM=$(arch) TARGET_PLATFORM=$(arch)
TARGET_YGOPRO_BINARY_PATH=./ygopro-platforms/ygopro-platform-$TARGET_PLATFORM TARGET_YGOPRO_BINARY_PATH=./ygopro-platforms/ygopro-platform-$TARGET_PLATFORM
export EVENT_INCLUDE_DIR=$PWD/libevent-stable/include
export EVENT_LIB_DIR=$PWD/libevent-stable/lib
export IRRLICHT_INCLUDE_DIR=$PWD/irrlicht/include
export IRRLICHT_LIB_DIR=$PWD/irrlicht/lib/$(arch)
./.ci/libevent-prebuild.sh ./.ci/configure-audio.sh
./premake5 gmake --cc=clang --build-freetype --build-sqlite --no-use-irrklang rm -rf sqlite3/VERSION sqlite3/version
./premake5 gmake --cc=clang
cd build cd build
make config=release -j4 make config=release -j$(sysctl -n hw.ncpu)
cd .. cd ..
mkdir ygopro-platforms mkdir ygopro-platforms
mv bin/release/YGOPro.app $TARGET_YGOPRO_BINARY_PATH mv bin/release/YGOPro $TARGET_YGOPRO_BINARY_PATH
#if [[ $TARGET_PLATFORM == "x86" ]]; then #if [[ $TARGET_PLATFORM == "x86" ]]; then
# install_name_tool -change /usr/local/lib/libirrklang.dylib @executable_path/../Frameworks/libirrklang.dylib $TARGET_YGOPRO_BINARY_PATH # install_name_tool -change /usr/local/lib/libirrklang.dylib @executable_path/../Frameworks/libirrklang.dylib $TARGET_YGOPRO_BINARY_PATH
......
...@@ -2,9 +2,15 @@ ...@@ -2,9 +2,15 @@
set -x set -x
set -o errexit set -o errexit
ARCHIVE_FILES=(ygopro lib cards.cdb locales fonts sound textures strings.conf system.conf pack) ARCHIVE_FILES=(ygopro cards.cdb locales fonts sound textures strings.conf system.conf servers.conf pack)
TARGET_PLATFORM=linux if [[ -z "$TARGET_PLATFORM" ]]; then
TARGET_PLATFORM=linux
fi
#if [[ "$TARGET_PLATFORM" != "linuxarm" ]]; then
ARCHIVE_FILES+=(sound)
#fi
apt update && apt -y install tar zstd apt update && apt -y install tar zstd
mkdir dist replay mkdir dist replay
......
...@@ -2,11 +2,17 @@ ...@@ -2,11 +2,17 @@
set -x set -x
set -o errexit set -o errexit
ARCHIVE_FILES=(ygopro LICENSE README.md lib lflist.conf strings.conf system.conf cards.cdb script textures deck single pics replay sound windbot bot bot.conf locales fonts pack) ARCHIVE_FILES=(ygopro LICENSE README.md lflist.conf strings.conf system.conf servers.conf cards.cdb script textures deck single pics replay windbot bot bot.conf locales fonts pack)
# TARGET_LOCALE # TARGET_LOCALE
# ARCHIVE_SUFFIX # ARCHIVE_SUFFIX
TARGET_PLATFORM=linux if [[ -z "$TARGET_PLATFORM" ]]; then
TARGET_PLATFORM=linux
fi
if [[ "$TARGET_PLATFORM" != "linuxarm" ]]; then
ARCHIVE_FILES+=(sound)
fi
apt update && apt -y install tar git zstd apt update && apt -y install tar git zstd
mkdir dist replay mkdir dist replay
......
...@@ -2,9 +2,11 @@ ...@@ -2,9 +2,11 @@
set -x set -x
set -o errexit set -o errexit
ARCHIVE_FILES=(ygopro.app cards.cdb locales fonts textures strings.conf system.conf pack) ARCHIVE_FILES=(ygopro.app cards.cdb locales fonts sound textures strings.conf system.conf servers.conf pack)
TARGET_PLATFORM=darwin if [[ -z "$TARGET_PLATFORM" ]]; then
TARGET_PLATFORM=darwin
fi
apt update && apt -y install tar zstd apt update && apt -y install tar zstd
mkdir dist replay mkdir dist replay
......
...@@ -2,11 +2,13 @@ ...@@ -2,11 +2,13 @@
set -x set -x
set -o errexit set -o errexit
ARCHIVE_FILES=(ygopro.app LICENSE README.md lflist.conf strings.conf system.conf cards.cdb script textures deck single pics replay windbot bot bot.conf locales fonts pack) ARCHIVE_FILES=(ygopro.app LICENSE README.md lflist.conf strings.conf system.conf servers.conf cards.cdb script textures deck single pics replay sound windbot bot bot.conf locales fonts pack)
# TARGET_LOCALE # TARGET_LOCALE
# ARCHIVE_SUFFIX # ARCHIVE_SUFFIX
TARGET_PLATFORM=darwin if [[ -z "$TARGET_PLATFORM" ]]; then
TARGET_PLATFORM=darwin
fi
apt update && apt -y install tar git zstd apt update && apt -y install tar git zstd
mkdir dist replay mkdir dist replay
......
...@@ -2,14 +2,16 @@ ...@@ -2,14 +2,16 @@
set -x set -x
set -o errexit set -o errexit
ARCHIVE_FILES=(ygopro.exe LICENSE README.md lflist.conf strings.conf system.conf cards.cdb script textures deck single pics replay sound bot.conf Bot.exe WindBot locales fonts skin pack) ARCHIVE_FILES=(ygopro.exe vcomp140.dll LICENSE README.md lflist.conf strings.conf system.conf servers.conf cards.cdb script textures deck single pics replay sound bot.conf Bot.exe WindBot locales fonts skin pack)
if [[ "$TARGET_LOCALE" == "zh-CN" ]]; then if [[ "$TARGET_LOCALE" == "zh-CN" ]]; then
ARCHIVE_FILES=("${ARCHIVE_FILES[@]}" update-koishipro) ARCHIVE_FILES=("${ARCHIVE_FILES[@]}" update-koishipro)
fi fi
# TARGET_LOCALE # TARGET_LOCALE
TARGET_PLATFORM=win32 if [[ -z "$TARGET_PLATFORM" ]]; then
TARGET_PLATFORM=win32
fi
apt update && apt -y install p7zip-full git apt update && apt -y install p7zip-full git
mkdir dist replay mkdir dist replay
......
...@@ -2,9 +2,11 @@ ...@@ -2,9 +2,11 @@
set -x set -x
set -o errexit set -o errexit
ARCHIVE_FILES=(ygopro.exe cards.cdb locales fonts sound textures strings.conf system.conf skin pack) ARCHIVE_FILES=(ygopro.exe vcomp140.dll cards.cdb locales fonts sound textures strings.conf system.conf servers.conf skin pack)
TARGET_PLATFORM=win32 if [[ -z "$TARGET_PLATFORM" ]]; then
TARGET_PLATFORM=win32
fi
apt update && apt -y install tar zstd apt update && apt -y install tar zstd
mkdir dist replay mkdir dist replay
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
set -x set -x
set -o errexit set -o errexit
ARCHIVE_FILES=(ygopro.exe LICENSE README.md lflist.conf strings.conf system.conf cards.cdb script textures deck single pics replay sound bot.conf Bot.exe WindBot locales fonts skin pack) ARCHIVE_FILES=(ygopro.exe vcomp140.dll LICENSE README.md lflist.conf strings.conf system.conf servers.conf cards.cdb script textures deck single pics replay sound bot.conf Bot.exe WindBot locales fonts skin pack)
if [[ "$TARGET_LOCALE" == "zh-CN" && "$ARCHIVE_SUFFIX" != "zst" ]]; then if [[ "$TARGET_LOCALE" == "zh-CN" && "$ARCHIVE_SUFFIX" != "zst" ]]; then
ARCHIVE_FILES=("${ARCHIVE_FILES[@]}" update-koishipro) ARCHIVE_FILES=("${ARCHIVE_FILES[@]}" update-koishipro)
...@@ -10,7 +10,9 @@ fi ...@@ -10,7 +10,9 @@ fi
# TARGET_LOCALE # TARGET_LOCALE
# ARCHIVE_SUFFIX # ARCHIVE_SUFFIX
TARGET_PLATFORM=win32 if [[ -z "$TARGET_PLATFORM" ]]; then
TARGET_PLATFORM=win32
fi
apt update && apt -y install tar git zstd apt update && apt -y install tar git zstd
mkdir dist replay mkdir dist replay
......
#!/bin/bash
set -x
set -o errexit
source .ci/prepare-repo
prepare_repo "https://code.moenext.com/mycard/irrlicht-new.git" "irrlicht"
#!/bin/bash
set -x
set -o errexit
source .ci/prepare-repo
prepare_repo "https://code.moenext.com/mycard/miniaudio.git" "miniaudio"
cp -rf miniaudio/extras/miniaudio_split/miniaudio.* miniaudio/
mkdir -p miniaudio/external
install_external() {
dir="$1"
url="$2"
if [ ! -d "miniaudio/external/$dir" ]; then
mkdir -p "miniaudio/external/$dir"
# Download the external library and strip one level of directories from the archive
wget -O - "$url" | tar --strip-components=1 -C "miniaudio/external/$dir" -zxf -
fi
}
install_external "ogg" "https://mat-cacher.moenext.com/https://github.com/xiph/ogg/releases/download/v1.3.5/libogg-1.3.5.tar.gz"
install_external "opus" "https://mat-cacher.moenext.com/https://github.com/xiph/opus/releases/download/v1.5.2/opus-1.5.2.tar.gz"
install_external "opusfile" "https://mat-cacher.moenext.com/https://github.com/xiph/opusfile/releases/download/v0.12/opusfile-0.12.tar.gz"
install_external "vorbis" "https://mat-cacher.moenext.com/https://github.com/xiph/vorbis/releases/download/v1.3.7/libvorbis-1.3.7.tar.gz"
source .ci/asset-branch
BRANCH_NAME="$ASSET_BRANCH_NAME"
prepare_repo() {
REPO_URL="$1"
TARGET_DIR_NAME="$2"
if [ ! -d "$TARGET_DIR_NAME" ]; then
echo "Cloning repository $REPO_URL branch $BRANCH_NAME into $TARGET_DIR_NAME"
git clone --depth=1 --branch "$BRANCH_NAME" "$REPO_URL" "$TARGET_DIR_NAME"
else
echo "Repository $REPO_URL already exists in $TARGET_DIR_NAME, updating to $BRANCH_NAME..."
cd "$TARGET_DIR_NAME"
git remote set-url origin "$REPO_URL"
git fetch origin "$BRANCH_NAME"
git checkout "$BRANCH_NAME"
git reset --hard origin/"$BRANCH_NAME"
cd ..
fi
}
...@@ -33,9 +33,15 @@ runForDepot() { ...@@ -33,9 +33,15 @@ runForDepot() {
echo "$result" | jq . echo "$result" | jq .
} }
runForDepot win32 zh-CN source .ci/asset-branch
runForDepot linux zh-CN
runForDepot darwin zh-CN if [[ "$ASSET_BRANCH_NAME" == "develop" ]]; then
runForDepot win32 en-US echo "This is a pre-release, skipping upload."
runForDepot linux en-US else
runForDepot darwin en-US runForDepot win32 zh-CN
runForDepot linux zh-CN
runForDepot darwin zh-CN
runForDepot win32 en-US
runForDepot linux en-US
runForDepot darwin en-US
fi
...@@ -16,6 +16,7 @@ build ...@@ -16,6 +16,7 @@ build
/irrklang /irrklang
/irrlicht* /irrlicht*
/lua /lua
/miniaudio
# gframe additionals # gframe additionals
/gframe/ygopro.ico /gframe/ygopro.ico
...@@ -76,7 +77,7 @@ build ...@@ -76,7 +77,7 @@ build
/ygopro_*.app /ygopro_*.app
/premake4 /premake4
/premake4.exe /premake4.exe
/premake5 /premake5*
/premake5.exe /premake5.exe
# others # others
......
This diff is collapsed.
No preview for this file type
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)
This diff is collapsed.
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef _C_GUI_IMAGE_BUTTON_H_ #ifndef _C_GUI_IMAGE_BUTTON_H_
#define _C_GUI_IMAGE_BUTTON_H_ #define _C_GUI_IMAGE_BUTTON_H_
#include <irrlicht.h> #include <IrrCompileConfig.h>
#include "CGUIButton.h" #ifdef _IRR_COMPILE_WITH_GUI_
#include <IGUIButton.h>
#include <SColor.h>
namespace irr { namespace irr {
namespace video {
class IVideoDriver;
class ITexture;
}
namespace gui { namespace gui {
class IGUISpriteBank;
void Draw2DImageRotation(video::IVideoDriver* driver, video::ITexture* image, core::rect<s32> sourceRect, void Draw2DImageRotation(video::IVideoDriver* driver, video::ITexture* image, core::rect<s32> sourceRect,
core::position2d<s32> position, core::position2d<s32> rotationPoint, f32 rotation = 0.0f, core::vector2d<s32> position, core::vector2d<s32> rotationPoint, f32 rotation = 0.0f,
core::vector2df scale = core::vector2df(1.0, 1.0), bool useAlphaChannel = true, video::SColor color = 0xffffffff); core::vector2df scale = core::vector2df(1.0, 1.0), bool useAlphaChannel = true, video::SColor color = 0xffffffff);
void Draw2DImageQuad(video::IVideoDriver* driver, video::ITexture* image, core::rect<s32> sourceRect, void Draw2DImageQuad(video::IVideoDriver* driver, video::ITexture* image, core::rect<s32> sourceRect,
core::position2d<s32> corner[4], bool useAlphaChannel = true, video::SColor color = 0xffffffff); core::vector2d<s32> corner[4], bool useAlphaChannel = true, video::SColor color = 0xffffffff);
class CGUIImageButton : public CGUIButton {
class CGUIImageButton : public IGUIButton {
public: public:
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(); //! constructor
virtual void setImage(video::ITexture* image = 0); CGUIImageButton(IGUIEnvironment* environment, IGUIElement* parent,
virtual void setDrawImage(bool b); s32 id, core::rect<s32> rectangle, bool noclip = false);
virtual void setImageRotation(f32 r);
virtual void setImageScale(core::vector2df s); //! destructor
virtual void setImageSize(core::dimension2di s); ~CGUIImageButton() override;
virtual IGUIFont* getOverrideFont(void) const;
virtual IGUIFont* getActiveFont() const; //! called if an event happened.
bool OnEvent(const SEvent& event) override;
private:
//! draws the element and its children
void draw() override;
//! sets another skin independent font. if this is set to zero, the button uses the font of the skin.
void setOverrideFont(IGUIFont* font = 0) override;
//! Gets the override font (if any)
IGUIFont* getOverrideFont() const override;
//! Get the font which is used right now for drawing
IGUIFont* getActiveFont() const override;
//! Sets an image which should be displayed on the button when it is in normal state.
void setImage(video::ITexture* image = 0) override;
//! Sets an image which should be displayed on the button when it is in normal state.
void setImage(video::ITexture* image, const core::rect<s32>& pos) override;
//! Sets an image which should be displayed on the button when it is in pressed state.
void setPressedImage(video::ITexture* image = 0) override;
//! Sets an image which should be displayed on the button when it is in pressed state.
void setPressedImage(video::ITexture* image, const core::rect<s32>& pos) override;
//! Sets the sprite bank used by the button
void setSpriteBank(IGUISpriteBank* bank = 0) override;
//! Sets the animated sprite for a specific button state
/** \param index: Number of the sprite within the sprite bank, use -1 for no sprite
\param state: State of the button to set the sprite for
\param index: The sprite number from the current sprite bank
\param color: The color of the sprite
*/
void setSprite(EGUI_BUTTON_STATE state, s32 index,
video::SColor color = video::SColor(255, 255, 255, 255), bool loop = false) override;
//! Sets if the button should behave like a push button. Which means it
//! can be in two states: Normal or Pressed. With a click on the button,
//! the user can change the state of the button.
void setIsPushButton(bool isPushButton = true) override;
//! Checks whether the button is a push button
bool isPushButton() const override;
//! Sets the pressed state of the button if this is a pushbutton
void setPressed(bool pressed = true) override;
//! Returns if the button is currently pressed
bool isPressed() const override;
//! Sets if the button should use the skin to draw its border
void setDrawBorder(bool border = true) override;
//! Checks if the button face and border are being drawn
bool isDrawingBorder() const override;
//! Sets if the alpha channel should be used for drawing images on the button (default is false)
void setUseAlphaChannel(bool useAlphaChannel = true) override;
//! Checks if the alpha channel should be used for drawing images on the button
bool isAlphaChannelUsed() const override;
//! Sets if the button should scale the button images to fit
void setScaleImage(bool scaleImage = true) override;
//! Checks whether the button scales the used images
bool isScalingImage() const override;
//! Writes attributes of the element.
void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const override;
//! Reads attributes of the element
void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) override;
// from ygopro
void setDrawImage(bool b);
void setImageRotation(f32 r);
void setImageScale(core::vector2df s);
void setImageSize(core::dimension2di s);
protected:
struct ButtonSprite
{
s32 Index;
video::SColor Color;
bool Loop;
};
ButtonSprite ButtonSprites[EGBS_COUNT];
IGUISpriteBank* SpriteBank;
IGUIFont* OverrideFont;
video::ITexture* Image;
video::ITexture* PressedImage;
core::rect<s32> ImageRect;
core::rect<s32> PressedImageRect;
bool IsPushButton;
bool Pressed;
bool UseAlphaChannel;
bool DrawBorder;
bool ScaleImage;
// from ygopro
bool isDrawImage; bool isDrawImage;
bool isFixedSize; bool isFixedSize;
f32 imageRotation; f32 imageRotation;
...@@ -36,4 +155,6 @@ private: ...@@ -36,4 +155,6 @@ private:
} }
} }
#endif // _IRR_COMPILE_WITH_GUI_
#endif //_C_GUI_IMAGE_BUTTON_H_ #endif //_C_GUI_IMAGE_BUTTON_H_
This diff is collapsed.
...@@ -54,7 +54,7 @@ public: ...@@ -54,7 +54,7 @@ public:
//! Structure representing a single TrueType glyph. //! Structure representing a single TrueType glyph.
struct SGUITTGlyph { struct SGUITTGlyph {
//! Constructor. //! Constructor.
SGUITTGlyph() : isLoaded(false), glyph_page(0), surface(0), parent(0) {} SGUITTGlyph() : isLoaded(false), glyph_page(0), advance({}), surface(0), parent(0) {}
//! Destructor. //! Destructor.
~SGUITTGlyph() { ~SGUITTGlyph() {
...@@ -207,93 +207,95 @@ public: ...@@ -207,93 +207,95 @@ public:
static CGUITTFont* create(IrrlichtDevice *device, const io::path& filename, const u32 size, const bool antialias = true, const bool transparency = true); static CGUITTFont* create(IrrlichtDevice *device, const io::path& filename, const u32 size, const bool antialias = true, const bool transparency = true);
//! Destructor //! Destructor
virtual ~CGUITTFont(); ~CGUITTFont() override;
//! Sets the amount of glyphs to batch load. //! Sets the amount of glyphs to batch load.
virtual void setBatchLoadSize(u32 batch_size) { void setBatchLoadSize(u32 batch_size) {
batch_load_size = batch_size; batch_load_size = batch_size;
} }
//! Sets the maximum texture size for a page of glyphs. //! Sets the maximum texture size for a page of glyphs.
virtual void setMaxPageTextureSize(const core::dimension2du& texture_size) { void setMaxPageTextureSize(const core::dimension2du& texture_size) {
max_page_texture_size = texture_size; max_page_texture_size = texture_size;
} }
//! Get the font size. //! Get the font size.
virtual u32 getFontSize() const { u32 getFontSize() const {
return size; return size;
} }
//! Check the font's transparency. //! Check the font's transparency.
virtual bool isTransparent() const { bool isTransparent() const {
return use_transparency; return use_transparency;
} }
//! Check if the font auto-hinting is enabled. //! Check if the font auto-hinting is enabled.
//! Auto-hinting is FreeType's built-in font hinting engine. //! Auto-hinting is FreeType's built-in font hinting engine.
virtual bool useAutoHinting() const { bool useAutoHinting() const {
return use_auto_hinting; return use_auto_hinting;
} }
//! Check if the font hinting is enabled. //! Check if the font hinting is enabled.
virtual bool useHinting() const { bool useHinting() const {
return use_hinting; return use_hinting;
} }
//! Check if the font is being loaded as a monochrome font. //! Check if the font is being loaded as a monochrome font.
//! The font can either be a 256 color grayscale font, or a 2 color monochrome font. //! The font can either be a 256 color grayscale font, or a 2 color monochrome font.
virtual bool useMonochrome() const { bool useMonochrome() const {
return use_monochrome; return use_monochrome;
} }
//! Tells the font to allow transparency when rendering. //! Tells the font to allow transparency when rendering.
//! Default: true. //! Default: true.
//! \param flag If true, the font draws using transparency. //! \param flag If true, the font draws using transparency.
virtual void setTransparency(const bool flag); void setTransparency(const bool flag);
//! Tells the font to use monochrome rendering. //! Tells the font to use monochrome rendering.
//! Default: false. //! Default: false.
//! \param flag If true, the font draws using a monochrome image. If false, the font uses a grayscale image. //! \param flag If true, the font draws using a monochrome image. If false, the font uses a grayscale image.
virtual void setMonochrome(const bool flag); void setMonochrome(const bool flag);
//! Enables or disables font hinting. //! Enables or disables font hinting.
//! Default: Hinting and auto-hinting true. //! Default: Hinting and auto-hinting true.
//! \param enable If false, font hinting is turned off. If true, font hinting is turned on. //! \param enable If false, font hinting is turned off. If true, font hinting is turned on.
//! \param enable_auto_hinting If true, FreeType uses its own auto-hinting algorithm. If false, it tries to use the algorithm specified by the font. //! \param enable_auto_hinting If true, FreeType uses its own auto-hinting algorithm. If false, it tries to use the algorithm specified by the font.
virtual void setFontHinting(const bool enable, const bool enable_auto_hinting = true); void setFontHinting(const bool enable, const bool enable_auto_hinting = true);
//! Draws some text and clips it to the specified rectangle if wanted. //! Draws some text and clips it to the specified rectangle if wanted.
virtual void draw(const core::stringw& text, const core::rect<s32>& position, void draw(const core::stringw& text, const core::rect<s32>& position,
video::SColor color, bool hcenter = false, bool vcenter = false, video::SColor color, bool hcenter = false, bool vcenter = false,
const core::rect<s32>* clip = 0); const core::rect<s32>* clip = 0) override;
void drawUstring(const core::ustring& text, const core::rect<s32>& position,
video::SColor color, bool hcenter = false, bool vcenter = false,
const core::rect<s32>* clip = 0);
//! Returns the dimension of a character produced by this font. //! Returns the dimension of a character produced by this font.
virtual core::dimension2d<u32> getCharDimension(const wchar_t ch) const; core::dimension2d<u32> getCharDimension(const wchar_t ch) const;
//! Returns the dimension of a text string. //! Returns the dimension of a text string.
virtual core::dimension2d<u32> getDimension(const wchar_t* text) const; core::dimension2d<u32> getDimension(const wchar_t* text) const override;
virtual core::dimension2d<u32> getDimension(const core::ustring& text) const; core::dimension2d<u32> getDimension(const core::ustring& text) const;
//! Calculates the index of the character in the text which is on a specific position. //! Calculates the index of the character in the text which is on a specific position.
virtual s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x) const; s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x) const override;
virtual s32 getCharacterFromPos(const core::ustring& text, s32 pixel_x) const; s32 getCharacterFromPos(const core::ustring& text, s32 pixel_x) const;
//! Sets global kerning width for the font. //! Sets global kerning width for the font.
virtual void setKerningWidth(s32 kerning); void setKerningWidth(s32 kerning) override;
//! Sets global kerning height for the font. //! Sets global kerning height for the font.
virtual void setKerningHeight(s32 kerning); void setKerningHeight(s32 kerning) override;
//! Gets kerning values (distance between letters) for the font. If no parameters are provided, //! Gets kerning values (distance between letters) for the font. If no parameters are provided,
virtual s32 getKerningWidth(const wchar_t* thisLetter = 0, const wchar_t* previousLetter = 0) const; s32 getKerningWidth(const wchar_t* thisLetter = 0, const wchar_t* previousLetter = 0) const override;
virtual s32 getKerningWidth(const uchar32_t thisLetter = 0, const uchar32_t previousLetter = 0) const; s32 getKerningWidth(const uchar32_t thisLetter = 0, const uchar32_t previousLetter = 0) const;
//! Returns the distance between letters //! Returns the distance between letters
virtual s32 getKerningHeight() const; s32 getKerningHeight() const override;
//! Define which characters should not be drawn by the font. //! Define which characters should not be drawn by the font.
virtual void setInvisibleCharacters(const wchar_t *s); void setInvisibleCharacters(const wchar_t *s) final;
virtual void setInvisibleCharacters(const core::ustring& s);
//! Get the last glyph page if there's still available slots. //! Get the last glyph page if there's still available slots.
//! If not, it will return zero. //! If not, it will return zero.
...@@ -312,14 +314,14 @@ public: ...@@ -312,14 +314,14 @@ public:
//! Create corresponding character's software image copy from the font, //! Create corresponding character's software image copy from the font,
//! so you can use this data just like any ordinary video::IImage. //! so you can use this data just like any ordinary video::IImage.
//! \param ch The character you need //! \param ch The character you need
virtual video::IImage* createTextureFromChar(const uchar32_t& ch); video::IImage* createTextureFromChar(const uchar32_t& ch);
//! This function is for debugging mostly. If the page doesn't exist it returns zero. //! This function is for debugging mostly. If the page doesn't exist it returns zero.
//! \param page_index Simply return the texture handle of a given page index. //! \param page_index Simply return the texture handle of a given page index.
virtual video::ITexture* getPageTextureByIndex(const u32& page_index) const; video::ITexture* getPageTextureByIndex(const u32& page_index) const;
//! Add a list of scene nodes generated by putting font textures on the 3D planes. //! Add a list of scene nodes generated by putting font textures on the 3D planes.
virtual core::array<scene::ISceneNode*> addTextSceneNode core::array<scene::ISceneNode*> addTextSceneNode
(const wchar_t* text, scene::ISceneManager* smgr, scene::ISceneNode* parent = 0, (const wchar_t* text, scene::ISceneManager* smgr, scene::ISceneNode* parent = 0,
const video::SColor& color = video::SColor(255, 0, 0, 0), bool center = false ); const video::SColor& color = video::SColor(255, 0, 0, 0), bool center = false );
...@@ -340,7 +342,7 @@ private: ...@@ -340,7 +342,7 @@ private:
static scene::IMesh* shared_plane_ptr_; static scene::IMesh* shared_plane_ptr_;
static scene::SMesh shared_plane_; static scene::SMesh shared_plane_;
CGUITTFont(IGUIEnvironment *env); explicit CGUITTFont(IGUIEnvironment *env);
bool load(const io::path& filename, const u32 size, const bool antialias, const bool transparency); bool load(const io::path& filename, const u32 size, const bool antialias, const bool transparency);
void reset_images(); void reset_images();
void update_glyph_pages() const; void update_glyph_pages() const;
......
...@@ -2,44 +2,47 @@ ...@@ -2,44 +2,47 @@
#define BUFFERIO_H #define BUFFERIO_H
#include <cstdint> #include <cstdint>
#include <cwchar>
#include "../ocgcore/buffer.h" #include "../ocgcore/buffer.h"
class BufferIO { class BufferIO {
public: public:
inline static int ReadInt32(unsigned char*& p) { static int ReadInt32(unsigned char*& p) {
return buffer_read<int32_t>(p); return buffer_read<int32_t>(p);
} }
inline static unsigned int ReadUInt32(unsigned char*& p) { static unsigned int ReadUInt32(unsigned char*& p) {
unsigned int ret = *(unsigned int*)p; return buffer_read<uint32_t>(p);
p += 4;
return ret;
} }
inline static short ReadInt16(unsigned char*& p) { static short ReadInt16(unsigned char*& p) {
return buffer_read<int16_t>(p); return buffer_read<int16_t>(p);
} }
inline static unsigned short ReadUInt16(unsigned char*& p) { static unsigned short ReadUInt16(unsigned char*& p) {
unsigned short ret = *(unsigned short*)p; return buffer_read<uint16_t>(p);
p += 2;
return ret;
} }
inline static char ReadInt8(unsigned char*& p) { static char ReadInt8(unsigned char*& p) {
return buffer_read<char>(p); return buffer_read<char>(p);
} }
inline static unsigned char ReadUInt8(unsigned char*& p) { static unsigned char ReadUInt8(unsigned char*& p) {
return buffer_read<unsigned char>(p); return buffer_read<unsigned char>(p);
} }
inline static void WriteInt32(unsigned char*& p, int val) { static void WriteInt32(unsigned char*& p, int val) {
buffer_write<int32_t>(p, val); buffer_write<int32_t>(p, val);
} }
inline static void WriteInt16(unsigned char*& p, short val) { static void WriteInt16(unsigned char*& p, short val) {
buffer_write<int16_t>(p, val); buffer_write<int16_t>(p, val);
} }
inline static void WriteInt8(unsigned char*& p, char val) { static void WriteInt8(unsigned char*& p, char val) {
buffer_write<char>(p, val); buffer_write<char>(p, val);
} }
// return: string length /**
* @brief Copy a C-style string to another C-style string.
* @param src The source wide string
* @param pstr The destination char string
* @param bufsize The length of the destination buffer
* @return The length of the copied string
*/
template<typename T1, typename T2> template<typename T1, typename T2>
inline static int CopyWStr(const T1* src, T2* pstr, int bufsize) { static int CopyWStr(const T1* src, T2* pstr, int bufsize) {
int l = 0; int l = 0;
while(src[l] && l < bufsize - 1) { while(src[l] && l < bufsize - 1) {
pstr[l] = (T2)src[l]; pstr[l] = (T2)src[l];
...@@ -49,7 +52,7 @@ public: ...@@ -49,7 +52,7 @@ public:
return l; return l;
} }
template<typename T1, typename T2> template<typename T1, typename T2>
inline static int CopyWStrRef(const T1* src, T2*& pstr, int bufsize) { static int CopyWStrRef(const T1* src, T2*& pstr, int bufsize) {
int l = 0; int l = 0;
while(src[l] && l < bufsize - 1) { while(src[l] && l < bufsize - 1) {
pstr[l] = (T2)src[l]; pstr[l] = (T2)src[l];
...@@ -59,22 +62,131 @@ public: ...@@ -59,22 +62,131 @@ public:
*pstr = 0; *pstr = 0;
return l; return l;
} }
template<typename T1, typename T2, size_t N>
static int CopyCharArray(const T1* src, T2(&dst)[N]) {
return CopyWStr(src, dst, N);
}
template<size_t N>
static void CopyString(const char* src, char(&dst)[N]) {
std::strncpy(dst, src, N - 1);
dst[N - 1] = 0;
}
template<size_t N>
static void CopyWideString(const wchar_t* src, wchar_t(&dst)[N]) {
std::wcsncpy(dst, src, N - 1);
dst[N - 1] = 0;
}
template<typename T>
static bool CheckUTF8Byte(const T* str, int len) {
for (int i = 1; i < len; ++i) {
if ((str[i] & 0xc0U) != 0x80U)
return false;
}
return true;
}
static unsigned int ConvertUTF8(const char*& p) {
unsigned int cur = 0;
if ((p[0] & 0x80U) == 0) {
cur = p[0] & 0xffU;
p++;
}
else if ((p[0] & 0xe0U) == 0xc0U) {
if (!CheckUTF8Byte(p, 2)) {
p++;
return UINT32_MAX;
}
cur = ((p[0] & 0x1fU) << 6) | (p[1] & 0x3fU);
p += 2;
if(cur < 0x80U)
return UINT32_MAX;
}
else if ((p[0] & 0xf0U) == 0xe0U) {
if (!CheckUTF8Byte(p, 3)) {
p++;
return UINT32_MAX;
}
cur = ((p[0] & 0xfU) << 12) | ((p[1] & 0x3fU) << 6) | (p[2] & 0x3fU);
p += 3;
if (cur < 0x800U)
return UINT32_MAX;
}
else if ((p[0] & 0xf8U) == 0xf0U) {
if (!CheckUTF8Byte(p, 4)) {
p++;
return UINT32_MAX;
}
cur = ((p[0] & 0x7U) << 18) | ((p[1] & 0x3fU) << 12) | ((p[2] & 0x3fU) << 6) | (p[3] & 0x3fU);
p += 4;
if (cur < 0x10000U)
return UINT32_MAX;
}
else {
p++;
return UINT32_MAX;
}
return cur;
}
static bool IsHighSurrogate(unsigned int c) {
return (c >= 0xd800U && c <= 0xdbffU);
}
static bool IsLowSurrogate(unsigned int c) {
return (c >= 0xdc00U && c <= 0xdfffU);
}
static bool IsUnicodeChar(unsigned int c) {
if(IsHighSurrogate(c))
return false;
if (IsLowSurrogate(c))
return false;
if (c > 0x10ffffU)
return false;
return true;
}
// UTF-16/UTF-32 to UTF-8 // UTF-16/UTF-32 to UTF-8
// return: string length // return: string length
static int EncodeUTF8String(const wchar_t* wsrc, char* str, int size) { static int EncodeUTF8String(const wchar_t* wsrc, char* str, int size) {
char* pstr = str; auto pw = wsrc;
while (*wsrc != 0) { auto pstr = str;
unsigned cur = *wsrc; while (*pw != 0) {
unsigned cur = 0;
int codepoint_size = 0; int codepoint_size = 0;
if (sizeof(wchar_t) == 2) {
if (IsHighSurrogate(pw[0])) {
if (pw[1] == 0)
break;
if (IsLowSurrogate(pw[1])) {
cur = ((pw[0] & 0x3ffU) << 10) | (pw[1] & 0x3ffU);
cur += 0x10000;
pw += 2;
}
else {
pw++;
continue;
}
}
else if (IsLowSurrogate(pw[0])) {
pw++;
continue;
}
else {
cur = *pw;
pw++;
}
}
else {
cur = *pw;
pw++;
}
if (!IsUnicodeChar(cur))
continue;
if (cur < 0x80U) if (cur < 0x80U)
codepoint_size = 1; codepoint_size = 1;
else if (cur < 0x800U) else if (cur < 0x800U)
codepoint_size = 2; codepoint_size = 2;
else if (cur < 0x10000U && (cur < 0xd800U || cur > 0xdfffU)) else if (cur < 0x10000U)
codepoint_size = 3; codepoint_size = 3;
else else
codepoint_size = 4; codepoint_size = 4;
if (pstr - str + codepoint_size > size - 1) if ((int)(pstr - str) + codepoint_size > size - 1)
break; break;
switch (codepoint_size) { switch (codepoint_size) {
case 1: case 1:
...@@ -90,13 +202,6 @@ public: ...@@ -90,13 +202,6 @@ public:
pstr[2] = (cur & 0x3f) | 0x80; pstr[2] = (cur & 0x3f) | 0x80;
break; break;
case 4: case 4:
if (sizeof(wchar_t) == 2) {
cur = 0;
cur |= ((unsigned)*wsrc & 0x3ff) << 10;
++wsrc;
cur |= (unsigned)*wsrc & 0x3ff;
cur += 0x10000;
}
pstr[0] = ((cur >> 18) & 0x7) | 0xf0; pstr[0] = ((cur >> 18) & 0x7) | 0xf0;
pstr[1] = ((cur >> 12) & 0x3f) | 0x80; pstr[1] = ((cur >> 12) & 0x3f) | 0x80;
pstr[2] = ((cur >> 6) & 0x3f) | 0x80; pstr[2] = ((cur >> 6) & 0x3f) | 0x80;
...@@ -106,10 +211,9 @@ public: ...@@ -106,10 +211,9 @@ public:
break; break;
} }
pstr += codepoint_size; pstr += codepoint_size;
wsrc++;
} }
*pstr = 0; *pstr = 0;
return pstr - str; return (int)(pstr - str);
} }
// UTF-8 to UTF-16/UTF-32 // UTF-8 to UTF-16/UTF-32
// return: string length // return: string length
...@@ -117,9 +221,11 @@ public: ...@@ -117,9 +221,11 @@ public:
const char* p = src; const char* p = src;
wchar_t* wp = wstr; wchar_t* wp = wstr;
while(*p != 0) { while(*p != 0) {
const unsigned cur = (unsigned)*p & 0xff; unsigned int cur = ConvertUTF8(p);
int codepoint_size = 0; int codepoint_size = 0;
if ((cur & 0xf8) == 0xf0) { if (!IsUnicodeChar(cur))
continue;
if (cur >= 0x10000) {
if (sizeof(wchar_t) == 2) if (sizeof(wchar_t) == 2)
codepoint_size = 2; codepoint_size = 2;
else else
...@@ -127,30 +233,18 @@ public: ...@@ -127,30 +233,18 @@ public:
} }
else else
codepoint_size = 1; codepoint_size = 1;
if (wp - wstr + codepoint_size > size - 1) if ((int)(wp - wstr) + codepoint_size > size - 1)
break; break;
if((cur & 0x80) == 0) { if (codepoint_size == 1) {
*wp = *p; wp[0] = cur;
p++; wp++;
} else if((cur & 0xe0) == 0xc0) { }
*wp = (((unsigned)p[0] & 0x1f) << 6) | ((unsigned)p[1] & 0x3f); else {
p += 2; cur -= 0x10000U;
} else if((cur & 0xf0) == 0xe0) { wp[0] = (cur >> 10) | 0xd800;
*wp = (((unsigned)p[0] & 0xf) << 12) | (((unsigned)p[1] & 0x3f) << 6) | ((unsigned)p[2] & 0x3f); wp[1] = (cur & 0x3ff) | 0xdc00;
p += 3; wp += 2;
} else if((cur & 0xf8) == 0xf0) { }
if (sizeof(wchar_t) == 2) {
unsigned unicode = (((unsigned)p[0] & 0x7) << 18) | (((unsigned)p[1] & 0x3f) << 12) | (((unsigned)p[2] & 0x3f) << 6) | ((unsigned)p[3] & 0x3f);
unicode -= 0x10000;
*wp++ = (unicode >> 10) | 0xd800;
*wp = (unicode & 0x3ff) | 0xdc00;
} else {
*wp = (((unsigned)p[0] & 0x7) << 18) | (((unsigned)p[1] & 0x3f) << 12) | (((unsigned)p[2] & 0x3f) << 6) | ((unsigned)p[3] & 0x3f);
}
p += 4;
} else
p++;
wp++;
} }
*wp = 0; *wp = 0;
return wp - wstr; return wp - wstr;
...@@ -168,14 +262,18 @@ public: ...@@ -168,14 +262,18 @@ public:
str[N - 1] = 0; str[N - 1] = 0;
} }
static int GetVal(const wchar_t* pstr) { static int GetVal(const wchar_t* pstr) {
unsigned int ret = 0; if (*pstr >= L'0' && *pstr <= L'9') {
while(*pstr >= L'0' && *pstr <= L'9') { int ret{};
ret = ret * 10 + (*pstr - L'0'); wchar_t* str_end{};
pstr++; ret = std::wcstol(pstr, &str_end, 10);
if (*str_end == 0)
return ret;
else
return 0;
} }
if (*pstr == 0) else
return (int)ret; return 0;
return 0;
} }
}; };
......
#include "client_card.h" #include "client_card.h"
#include "client_field.h" #include "client_field.h"
#include "data_manager.h"
#include "game.h" #include "game.h"
namespace ygo { namespace ygo {
...@@ -32,12 +31,12 @@ ClientCard::~ClientCard() { ...@@ -32,12 +31,12 @@ ClientCard::~ClientCard() {
} }
overlayed.clear(); overlayed.clear();
} }
void ClientCard::SetCode(int code) { void ClientCard::SetCode(unsigned int x) {
if((location == LOCATION_HAND) && (this->code != (unsigned int)code)) { if((location == LOCATION_HAND) && (code != x)) {
this->code = code; code = x;
mainGame->dField.MoveCard(this, 5); mainGame->dField.MoveCard(this, 5);
} else } else
this->code = code; code = x;
} }
void ClientCard::UpdateInfo(unsigned char* buf) { void ClientCard::UpdateInfo(unsigned char* buf) {
int flag = BufferIO::ReadInt32(buf); int flag = BufferIO::ReadInt32(buf);
...@@ -57,7 +56,7 @@ void ClientCard::UpdateInfo(unsigned char* buf) { ...@@ -57,7 +56,7 @@ void ClientCard::UpdateInfo(unsigned char* buf) {
} }
if(flag & QUERY_POSITION) { if(flag & QUERY_POSITION) {
int pdata = (BufferIO::ReadInt32(buf) >> 24) & 0xff; int pdata = (BufferIO::ReadInt32(buf) >> 24) & 0xff;
if((location & (LOCATION_EXTRA | LOCATION_REMOVED)) && (u8)pdata != position) { if((location & (LOCATION_EXTRA | LOCATION_REMOVED)) && pdata != position) {
position = pdata; position = pdata;
mainGame->dField.MoveCard(this, 1); mainGame->dField.MoveCard(this, 1);
} else } else
...@@ -176,13 +175,13 @@ void ClientCard::UpdateInfo(unsigned char* buf) { ...@@ -176,13 +175,13 @@ void ClientCard::UpdateInfo(unsigned char* buf) {
} }
} }
void ClientCard::ClearTarget() { void ClientCard::ClearTarget() {
for(auto cit = cardTarget.begin(); cit != cardTarget.end(); ++cit) { for (auto& pcard : cardTarget) {
(*cit)->is_showtarget = false; pcard->is_showtarget = false;
(*cit)->ownerTarget.erase(this); pcard->ownerTarget.erase(this);
} }
for(auto cit = ownerTarget.begin(); cit != ownerTarget.end(); ++cit) { for (auto& pcard : ownerTarget) {
(*cit)->is_showtarget = false; pcard->is_showtarget = false;
(*cit)->cardTarget.erase(this); pcard->cardTarget.erase(this);
} }
cardTarget.clear(); cardTarget.clear();
ownerTarget.clear(); ownerTarget.clear();
...@@ -215,101 +214,35 @@ void ClientCard::ClearData() { ...@@ -215,101 +214,35 @@ void ClientCard::ClearData() {
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) if(c1->is_selected != c2->is_selected)
return c1->is_selected < c2->is_selected; return c1->is_selected < c2->is_selected;
int32 cp1 = c1->overlayTarget ? c1->overlayTarget->controler : c1->controler; int cp1 = c1->overlayTarget ? c1->overlayTarget->controler : c1->controler;
int32 cp2 = c2->overlayTarget ? c2->overlayTarget->controler : c2->controler; int cp2 = c2->overlayTarget ? c2->overlayTarget->controler : c2->controler;
if(cp1 != cp2) if(cp1 != cp2)
return cp1 < cp2; return cp1 < cp2;
if(c1->location != c2->location) if(c1->location != c2->location)
return c1->location < c2->location; return c1->location < c2->location;
if (c1->location & LOCATION_OVERLAY) { if (c1->location == LOCATION_OVERLAY) {
if (c1->overlayTarget != c2->overlayTarget) if (c1->overlayTarget != c2->overlayTarget)
return c1->overlayTarget->sequence < c2->overlayTarget->sequence; return c1->overlayTarget->sequence < c2->overlayTarget->sequence;
else else
return c1->sequence < c2->sequence; return c1->sequence < c2->sequence;
} }
else { else if (c1->location == LOCATION_DECK) {
if(c1->location & (LOCATION_DECK | LOCATION_GRAVE | LOCATION_REMOVED | LOCATION_EXTRA)) { return c1->sequence > c2->sequence;
auto it1 = std::find_if(mainGame->dField.chains.rbegin(), mainGame->dField.chains.rend(), [c1](const ChainInfo& ch) { }
return c1 == ch.chain_card || ch.target.find(c1) != ch.target.end(); else if (c1->location & (LOCATION_GRAVE | LOCATION_REMOVED | LOCATION_EXTRA)) {
}); auto it1 = std::find_if(mainGame->dField.chains.rbegin(), mainGame->dField.chains.rend(), [c1](const ChainInfo& ch) {
auto it2 = std::find_if(mainGame->dField.chains.rbegin(), mainGame->dField.chains.rend(), [c2](const ChainInfo& ch) { return c1 == ch.chain_card || ch.target.find(c1) != ch.target.end();
return c2 == ch.chain_card || ch.target.find(c2) != ch.target.end(); });
}); auto it2 = std::find_if(mainGame->dField.chains.rbegin(), mainGame->dField.chains.rend(), [c2](const ChainInfo& ch) {
if(it1 != mainGame->dField.chains.rend() || it2 != mainGame->dField.chains.rend()) { return c2 == ch.chain_card || ch.target.find(c2) != ch.target.end();
return it1 < it2; });
} if (it1 != mainGame->dField.chains.rend() || it2 != mainGame->dField.chains.rend()) {
return c1->sequence > c2->sequence; return it1 < it2;
} }
else return c1->sequence > c2->sequence;
return c1->sequence < c2->sequence;
}
}
bool ClientCard::deck_sort_lv(code_pointer p1, code_pointer p2) {
if((p1->second.type & 0x7) != (p2->second.type & 0x7))
return (p1->second.type & 0x7) < (p2->second.type & 0x7);
if((p1->second.type & 0x7) == 1) {
int type1 = (p1->second.type & 0x48020c0) ? (p1->second.type & 0x48020c1) : (p1->second.type & 0x31);
int type2 = (p2->second.type & 0x48020c0) ? (p2->second.type & 0x48020c1) : (p2->second.type & 0x31);
if(type1 != type2)
return type1 < type2;
if(p1->second.level != p2->second.level)
return p1->second.level > p2->second.level;
if(p1->second.attack != p2->second.attack)
return p1->second.attack > p2->second.attack;
if(p1->second.defense != p2->second.defense)
return p1->second.defense > p2->second.defense;
return p1->first < p2->first;
} }
if((p1->second.type & 0xfffffff8) != (p2->second.type & 0xfffffff8)) else {
return (p1->second.type & 0xfffffff8) < (p2->second.type & 0xfffffff8); return c1->sequence < c2->sequence;
return p1->first < p2->first;
}
bool ClientCard::deck_sort_atk(code_pointer p1, code_pointer p2) {
if((p1->second.type & 0x7) != (p2->second.type & 0x7))
return (p1->second.type & 0x7) < (p2->second.type & 0x7);
if((p1->second.type & 0x7) == 1) {
if(p1->second.attack != p2->second.attack)
return p1->second.attack > p2->second.attack;
if(p1->second.defense != p2->second.defense)
return p1->second.defense > p2->second.defense;
if(p1->second.level != p2->second.level)
return p1->second.level > p2->second.level;
int type1 = (p1->second.type & 0x48020c0) ? (p1->second.type & 0x48020c1) : (p1->second.type & 0x31);
int type2 = (p2->second.type & 0x48020c0) ? (p2->second.type & 0x48020c1) : (p2->second.type & 0x31);
if(type1 != type2)
return type1 < type2;
return p1->first < p2->first;
}
if((p1->second.type & 0xfffffff8) != (p2->second.type & 0xfffffff8))
return (p1->second.type & 0xfffffff8) < (p2->second.type & 0xfffffff8);
return p1->first < p2->first;
}
bool ClientCard::deck_sort_def(code_pointer p1, code_pointer p2) {
if((p1->second.type & 0x7) != (p2->second.type & 0x7))
return (p1->second.type & 0x7) < (p2->second.type & 0x7);
if((p1->second.type & 0x7) == 1) {
if(p1->second.defense != p2->second.defense)
return p1->second.defense > p2->second.defense;
if(p1->second.attack != p2->second.attack)
return p1->second.attack > p2->second.attack;
if(p1->second.level != p2->second.level)
return p1->second.level > p2->second.level;
int type1 = (p1->second.type & 0x48020c0) ? (p1->second.type & 0x48020c1) : (p1->second.type & 0x31);
int type2 = (p2->second.type & 0x48020c0) ? (p2->second.type & 0x48020c1) : (p2->second.type & 0x31);
if(type1 != type2)
return type1 < type2;
return p1->first < p2->first;
} }
if((p1->second.type & 0xfffffff8) != (p2->second.type & 0xfffffff8))
return (p1->second.type & 0xfffffff8) < (p2->second.type & 0xfffffff8);
return p1->first < p2->first;
}
bool ClientCard::deck_sort_name(code_pointer p1, code_pointer p2) {
const wchar_t* name1 = dataManager.GetName(p1->first);
const wchar_t* name2 = dataManager.GetName(p2->first);
int res = wcscmp(name1, name2);
if(res != 0)
return res < 0;
return p1->first < p2->first;
} }
} }
...@@ -2,35 +2,12 @@ ...@@ -2,35 +2,12 @@
#define CLIENT_CARD_H #define CLIENT_CARD_H
#include "config.h" #include "config.h"
#include "../ocgcore/card_data.h"
#include <vector> #include <vector>
#include <set> #include <set>
#include <map> #include <map>
#include <unordered_map>
namespace ygo { namespace ygo {
using CardData = card_data;
struct CardDataC : card_data {
unsigned int ot{};
unsigned int category{};
bool is_setcodes(std::vector <uint32> values) const {
for (auto& value : values) {
if (is_setcode(value))
return true;
}
return false;
}
};
struct CardString {
std::wstring name;
std::wstring text;
std::wstring desc[16];
};
typedef std::unordered_map<unsigned int, CardDataC>::const_iterator code_pointer;
typedef std::unordered_map<unsigned int, CardString>::const_iterator string_pointer;
class ClientCard { class ClientCard {
public: public:
irr::core::matrix4 mTransform; irr::core::matrix4 mTransform;
...@@ -38,9 +15,9 @@ public: ...@@ -38,9 +15,9 @@ public:
irr::core::vector3df curRot; irr::core::vector3df curRot;
irr::core::vector3df dPos; irr::core::vector3df dPos;
irr::core::vector3df dRot; irr::core::vector3df dRot;
u32 curAlpha{ 255 }; irr::u32 curAlpha{ 255 };
u32 dAlpha{ 0 }; irr::u32 dAlpha{ 0 };
u32 aniFrame{ 0 }; irr::u32 aniFrame{ 0 };
bool is_moving{ false }; bool is_moving{ false };
bool is_fading{ false }; bool is_fading{ false };
bool is_hovered{ false }; bool is_hovered{ false };
...@@ -98,15 +75,11 @@ public: ...@@ -98,15 +75,11 @@ public:
ClientCard() = default; ClientCard() = default;
~ClientCard(); ~ClientCard();
void SetCode(int code); void SetCode(unsigned int x);
void UpdateInfo(unsigned char* buf); void UpdateInfo(unsigned char* buf);
void ClearTarget(); void ClearTarget();
void ClearData(); void ClearData();
static bool client_card_sort(ClientCard* c1, ClientCard* c2); static bool client_card_sort(ClientCard* c1, ClientCard* c2);
static bool deck_sort_lv(code_pointer l1, code_pointer l2);
static bool deck_sort_atk(code_pointer l1, code_pointer l2);
static bool deck_sort_def(code_pointer l1, code_pointer l2);
static bool deck_sort_name(code_pointer l1, code_pointer l2);
}; };
} }
......
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#define CLIENT_FIELD_H #define CLIENT_FIELD_H
#include "config.h" #include "config.h"
#include "../ocgcore/mtrandom.h" #include <random>
#include <vector> #include <vector>
#include <set> #include <set>
#include <map> #include <map>
...@@ -58,9 +58,12 @@ public: ...@@ -58,9 +58,12 @@ public:
int select_min{ 0 }; int select_min{ 0 };
int select_max{ 0 }; int select_max{ 0 };
int must_select_count{ 0 }; int must_select_count{ 0 };
int select_curval_l{ 0 };
int select_curval_h{ 0 };
int select_sumval{ 0 }; int select_sumval{ 0 };
int select_mode{ 0 }; int select_mode{ 0 };
bool select_cancelable{ false }; int select_hint{0};
bool select_cancelable{false};
bool select_panalmode{ false }; bool select_panalmode{ false };
bool select_ready{ false }; bool select_ready{ false };
int announce_count{ 0 }; int announce_count{ 0 };
...@@ -71,15 +74,15 @@ public: ...@@ -71,15 +74,15 @@ public:
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> declare_opcodes; std::vector<unsigned 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];
bool grave_act{ false }; bool grave_act[2]{ false };
bool remove_act{ false }; bool remove_act[2]{ false };
bool deck_act{ false }; bool deck_act[2]{ false };
bool extra_act{ false }; bool extra_act[2]{ false };
bool pzone_act[2]{}; bool pzone_act[2]{ false };
bool conti_act{ false }; bool conti_act{ false };
bool chain_forced{ false }; bool chain_forced{ false };
ChainInfo current_chain; ChainInfo current_chain;
...@@ -89,12 +92,13 @@ public: ...@@ -89,12 +92,13 @@ public:
bool cant_check_grave{ false }; bool cant_check_grave{ false };
bool tag_surrender{ false }; bool tag_surrender{ false };
bool tag_teammate_surrender{ false }; bool tag_teammate_surrender{ false };
mt19937 rnd; std::mt19937 rnd;
ClientField(); ClientField();
~ClientField(); ~ClientField();
void Clear(); void Clear();
void Initial(int player, int deckc, int extrac); void Initial(int player, int deckc, int extrac, int sidec = 0);
void ResetSequence(std::vector<ClientCard*>& list, bool reset_height);
ClientCard* GetCard(int controler, int location, int sequence, int sub_seq = 0); ClientCard* GetCard(int controler, int location, int sequence, int sub_seq = 0);
void AddCard(ClientCard* pcard, int controler, int location, int sequence); void AddCard(ClientCard* pcard, int controler, int location, int sequence);
ClientCard* RemoveCard(int controler, int location, int sequence); ClientCard* RemoveCard(int controler, int location, int sequence);
...@@ -117,6 +121,7 @@ public: ...@@ -117,6 +121,7 @@ public:
bool ShowSelectSum(bool panelmode); bool ShowSelectSum(bool panelmode);
bool CheckSelectSum(); bool CheckSelectSum();
bool CheckSelectTribute(); bool CheckSelectTribute();
void get_sum_params(unsigned int opParam, int& op1, int& op2);
bool check_min(const std::set<ClientCard*>& left, std::set<ClientCard*>::const_iterator index, int min, int max); bool check_min(const std::set<ClientCard*>& left, std::set<ClientCard*>::const_iterator index, int min, int max);
bool check_sel_sum_s(const std::set<ClientCard*>& left, int index, int acc); bool check_sel_sum_s(const std::set<ClientCard*>& left, int index, int acc);
void check_sel_sum_t(const std::set<ClientCard*>& left, int acc); void check_sel_sum_t(const std::set<ClientCard*>& left, int acc);
...@@ -129,9 +134,6 @@ public: ...@@ -129,9 +134,6 @@ public:
void RefreshCardCountDisplay(); void RefreshCardCountDisplay();
irr::gui::IGUIElement* panel{ nullptr }; irr::gui::IGUIElement* panel{ nullptr };
bool is_dragging_cardtext{ false };
int dragging_cardtext_start_pos{ 0 };
int dragging_cardtext_start_y{ 0 };
std::vector<int> ancard; std::vector<int> ancard;
int hovered_controler{ 0 }; int hovered_controler{ 0 };
int hovered_location{ 0 }; int hovered_location{ 0 };
...@@ -147,8 +149,8 @@ public: ...@@ -147,8 +149,8 @@ public:
ClientCard* menu_card{ nullptr }; ClientCard* menu_card{ nullptr };
int list_command{ 0 }; int list_command{ 0 };
virtual bool OnEvent(const irr::SEvent& event); bool OnEvent(const irr::SEvent& event) override;
virtual bool OnCommonEvent(const irr::SEvent& event); bool OnCommonEvent(const irr::SEvent& event);
void GetHoverField(int x, int y); void GetHoverField(int x, int y);
void ShowMenu(int flag, int x, int y); void ShowMenu(int flag, int x, int y);
void HideMenu(); void HideMenu();
...@@ -164,8 +166,6 @@ public: ...@@ -164,8 +166,6 @@ public:
} }
//special cards //special cards
#define CARD_MARINE_DOLPHIN 78734254
#define CARD_TWINKLE_MOSS 13857930
#define CARD_QUESTION 38723936 #define CARD_QUESTION 38723936
#endif //CLIENT_FIELD_H #endif //CLIENT_FIELD_H
#ifndef __CONFIG_H #ifndef YGOPRO_CONFIG_H
#define __CONFIG_H #define YGOPRO_CONFIG_H
#pragma once
#define _IRR_STATIC_LIB_ #define _IRR_STATIC_LIB_
#define IRR_COMPILE_WITH_DX9_DEV_PACK #define IRR_COMPILE_WITH_DX9_DEV_PACK
#include <cerrno>
#ifdef _WIN32 #ifdef _WIN32
#define NOMINMAX #define NOMINMAX
...@@ -12,7 +13,7 @@ ...@@ -12,7 +13,7 @@
#include <windows.h> #include <windows.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
#ifdef _MSC_VER #if defined(_MSC_VER) or defined(__MINGW32__)
#define mywcsncasecmp _wcsnicmp #define mywcsncasecmp _wcsnicmp
#define mystrncasecmp _strnicmp #define mystrncasecmp _strnicmp
#else #else
...@@ -24,7 +25,6 @@ ...@@ -24,7 +25,6 @@
#else //_WIN32 #else //_WIN32
#include <errno.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
...@@ -41,49 +41,71 @@ ...@@ -41,49 +41,71 @@
#define SOCKADDR sockaddr #define SOCKADDR sockaddr
#define SOCKET_ERRNO() (errno) #define SOCKET_ERRNO() (errno)
#include <wchar.h>
#define mywcsncasecmp wcsncasecmp #define mywcsncasecmp wcsncasecmp
#define mystrncasecmp strncasecmp #define mystrncasecmp strncasecmp
inline int _wtoi(const wchar_t * s) {
wchar_t * endptr;
return (int)wcstol(s, &endptr, 10);
}
#endif #endif
template<size_t N, typename... TR> #ifndef _WIN32
inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) { #include <wchar.h>
return swprintf(buf, N, fmt, args...); inline int _wtoi(const wchar_t * str){
return (int)wcstol(str, 0, 10);
} }
#endif
#include <irrlicht.h> // load env things
#ifdef __APPLE__ #ifdef _WIN32
#include <OpenGL/gl.h> #include <windows.h>
#include <OpenGL/glu.h> #include <string>
#else //__APPLE__ #else
#include <GL/gl.h> #include <unistd.h>
#include <GL/glu.h>
#endif //__APPLE__
#include "CGUITTFont.h"
#include "CGUIImageButton.h"
#include <iostream>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h>
#include <thread> extern char** environ;
#include <mutex> #endif
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm> #include <algorithm>
#include <string>
#include "bufferio.h" #include "bufferio.h"
#include "myfilesystem.h"
#include "mysignal.h"
#include "../ocgcore/ocgapi.h" #include "../ocgcore/ocgapi.h"
#include "../ocgcore/common.h"
using namespace irr; template<size_t N, typename... TR>
using namespace core; inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
using namespace scene; return std::swprintf(buf, N, fmt, args...);
using namespace video; }
using namespace io;
using namespace gui; inline FILE* mywfopen(const wchar_t* filename, const char* mode) {
FILE* fp{};
#ifdef _WIN32
wchar_t wmode[20]{};
BufferIO::CopyCharArray(mode, wmode);
fp = _wfopen(filename, wmode);
#else
char fname[1024]{};
BufferIO::EncodeUTF8(filename, fname);
fp = std::fopen(fname, mode);
#endif
return fp;
}
#if !defined(_WIN32)
#define myfopen std::fopen
#elif defined(WDK_NTDDI_VERSION) && (WDK_NTDDI_VERSION >= 0x0A000005) // Redstone 4, Version 1803, Build 17134.
#define FOPEN_WINDOWS_SUPPORT_UTF8
#define myfopen std::fopen
#else
inline FILE* myfopen(const char* filename, const char* mode) {
wchar_t wfilename[256]{};
BufferIO::DecodeUTF8(filename, wfilename);
wchar_t wmode[20]{};
BufferIO::CopyCharArray(mode, wmode);
return _wfopen(wfilename, wmode);
}
#endif
#include <irrlicht.h>
extern unsigned short PRO_VERSION; extern unsigned short PRO_VERSION;
extern unsigned int enable_log; extern unsigned int enable_log;
...@@ -92,5 +114,7 @@ extern bool auto_watch_mode; ...@@ -92,5 +114,7 @@ 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;
extern bool expansions_specified;
extern std::vector<std::wstring> expansions_list;
#endif #endif
This diff is collapsed.
#ifndef DATAMANAGER_H #ifndef DATAMANAGER_H
#define DATAMANAGER_H #define DATAMANAGER_H
#include "config.h"
#include "sqlite3.h"
#include "spmemvfs/spmemvfs.h"
#include "client_card.h"
#include <unordered_map> #include <unordered_map>
#include <vector>
#include <string>
#include <sqlite3.h>
#include "../ocgcore/card_data.h"
namespace irr {
namespace io {
class IReadFile;
class IFileSystem;
}
}
namespace ygo { namespace ygo {
constexpr int MAX_STRING_ID = 0x7ff; constexpr int MAX_STRING_ID = 0x7ff;
constexpr unsigned int MIN_CARD_ID = (unsigned int)(MAX_STRING_ID + 1) >> 4; constexpr unsigned int MIN_CARD_ID = (unsigned int)(MAX_STRING_ID + 1) >> 4;
constexpr unsigned int MAX_CARD_ID = 0x0fffffffU;
using CardData = card_data;
struct CardDataC : card_data {
uint32_t ot{};
uint32_t category{};
bool is_setcodes(const std::vector<unsigned int>& values) const {
for (auto& value : values) {
if (is_setcode(value))
return true;
}
return false;
}
};
struct CardString {
std::wstring name;
std::wstring text;
std::wstring desc[16];
};
using code_pointer = std::unordered_map<unsigned int, CardDataC>::const_iterator;
using string_pointer = std::unordered_map<unsigned int, CardString>::const_iterator;
class DataManager { class DataManager {
public: public:
DataManager(); DataManager();
bool ReadDB(sqlite3* pDB);
bool LoadDB(const wchar_t* wfile); bool LoadDB(const wchar_t* wfile);
bool LoadDB(irr::io::IReadFile* reader);
bool LoadStrings(const char* file); bool LoadStrings(const char* file);
bool LoadStrings(IReadFile* reader); bool LoadStrings(const wchar_t* file);
bool LoadStrings(irr::io::IReadFile* reader);
void ReadStringConfLine(const char* linebuf); void ReadStringConfLine(const char* linebuf);
bool Error(spmemvfs_db_t* pDB, sqlite3_stmt* pStmt = 0); bool LoadServerList(const char* file);
bool GetData(unsigned int code, CardData* pData); bool LoadServerList(const wchar_t* file);
bool LoadServerList(irr::io::IReadFile* reader);
void ReadServerConfLine(const char* linebuf);
bool LoadCorresSrvIni(const char* file);
bool LoadCorresSrvIni(const wchar_t* file);
bool LoadCorresSrvIni(irr::io::IReadFile* reader);
void ReadCorresSrvIniLine(const char* linebuf);
std::wstring GetINIValue(const char* line, const char* key);
void InsertServerList();
bool Error(sqlite3* pDB, sqlite3_stmt* pStmt = nullptr);
code_pointer GetCodePointer(unsigned int code) const; code_pointer GetCodePointer(unsigned int code) const;
string_pointer GetStringPointer(unsigned int code) const; string_pointer GetStringPointer(unsigned int code) const;
bool GetString(unsigned int code, CardString* pStr); code_pointer datas_begin() const;
const wchar_t* GetName(unsigned int code); code_pointer datas_end() const;
const wchar_t* GetText(unsigned int code); string_pointer strings_begin() const;
const wchar_t* GetDesc(unsigned int strCode); string_pointer strings_end() const;
const wchar_t* GetSysString(int code); bool GetData(unsigned int code, CardData* pData) const;
const wchar_t* GetVictoryString(int code); bool GetString(unsigned int code, CardString* pStr) const;
const wchar_t* GetCounterName(int code); const wchar_t* GetName(unsigned int code) const;
const wchar_t* GetSetName(int code); const wchar_t* GetText(unsigned int code) const;
std::vector<unsigned int> GetSetCodes(std::wstring setname); const wchar_t* GetDesc(unsigned int strCode) const;
const wchar_t* GetNumString(int num, bool bracket = false); const wchar_t* GetSysString(int code) const;
const wchar_t* FormatLocation(int location, int sequence); const wchar_t* GetVictoryString(int code) const;
const wchar_t* FormatAttribute(int attribute); const wchar_t* GetCounterName(int code) const;
const wchar_t* FormatRace(int race); const wchar_t* GetSetName(int code) const;
const wchar_t* FormatType(int type); std::vector<unsigned int> GetSetCodes(std::wstring setname) const;
const wchar_t* FormatSetName(const uint16_t setcode[]); std::wstring GetNumString(int num, bool bracket = false) const;
const wchar_t* FormatLinkMarker(int link_marker); const wchar_t* FormatLocation(int location, int sequence) const;
std::wstring FormatAttribute(unsigned int attribute) const;
std::wstring FormatRace(unsigned int race) const;
std::wstring FormatType(unsigned int type) const;
std::wstring FormatSetName(const uint16_t setcode[]) const;
std::wstring FormatLinkMarker(unsigned int link_marker) const;
std::unordered_map<unsigned int, std::wstring> _counterStrings; std::unordered_map<unsigned int, std::wstring> _counterStrings;
std::unordered_map<unsigned int, std::wstring> _victoryStrings; std::unordered_map<unsigned int, std::wstring> _victoryStrings;
std::unordered_map<unsigned int, std::wstring> _setnameStrings; std::unordered_map<unsigned int, std::wstring> _setnameStrings;
std::unordered_map<unsigned int, std::wstring> _sysStrings; std::unordered_map<unsigned int, std::wstring> _sysStrings;
code_pointer datas_begin; std::vector<std::pair<std::wstring, std::wstring>> _serverStrings;
code_pointer datas_end; char errmsg[512]{};
string_pointer strings_begin;
string_pointer strings_end;
wchar_t numStrings[301][4]{}; static unsigned char scriptBuffer[0x100000];
wchar_t numBuffer[6]{};
wchar_t attBuffer[128]{};
wchar_t racBuffer[128]{};
wchar_t tpBuffer[128]{};
wchar_t scBuffer[128]{};
wchar_t lmBuffer[32]{};
static byte scriptBuffer[0x20000];
static const wchar_t* unknown_string; static const wchar_t* unknown_string;
static uint32 CardReader(uint32, card_data*); static uint32_t CardReader(uint32_t, card_data*);
static byte* ScriptReaderEx(const char* script_name, int* slen); static unsigned char* ScriptReaderEx(const char* script_name, int* slen);
static byte* ScriptReaderExSingle(const char* path, const char* script_name, int* slen, int pre_len = 2); static unsigned char* ScriptReaderExSingle(const char* path, const char* script_name, int* slen, int pre_len = 2, unsigned int use_irr = FALSE);
static byte* ScriptReader(const char* script_name, int* slen);
static IFileSystem* FileSystem; //read by IFileSystem
static unsigned char* ReadScriptFromIrrFS(const char* script_name, int* slen);
//read by fread
static unsigned char* ReadScriptFromFile(const char* script_name, int* slen);
static irr::io::IFileSystem* FileSystem;
static bool deck_sort_lv(code_pointer l1, code_pointer l2);
static bool deck_sort_atk(code_pointer l1, code_pointer l2);
static bool deck_sort_def(code_pointer l1, code_pointer l2);
static bool deck_sort_name(code_pointer l1, code_pointer l2);
private: private:
std::unordered_map<unsigned int, CardDataC> _datas; std::unordered_map<unsigned int, CardDataC> _datas;
std::unordered_map<unsigned int, CardString> _strings; std::unordered_map<unsigned int, CardString> _strings;
std::unordered_map<unsigned int, std::vector<uint16_t>> extra_setcode; std::unordered_map<unsigned int, std::vector<uint16_t>> extra_setcode;
std::wstring iniName;
std::wstring iniHost;
std::wstring iniPort;
}; };
extern DataManager dataManager; extern DataManager dataManager;
......
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.
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "data_manager.h" #include "data_manager.h"
#include <unordered_map> #include <unordered_map>
#include <queue> #include <queue>
#include <mutex>
namespace ygo { namespace ygo {
...@@ -15,14 +16,14 @@ public: ...@@ -15,14 +16,14 @@ public:
bool Initial(); bool Initial();
//random image //random image
irr::video::ITexture* GetRandomImage(int image_type); irr::video::ITexture* GetRandomImage(int image_type);
irr::video::ITexture* GetRandomImage(int image_type, s32 width, s32 height); irr::video::ITexture* GetRandomImage(int image_type, irr::s32 width, irr::s32 height);
void RefreshRandomImageList(); void RefreshRandomImageList();
void RefreshImageDir(std::wstring path, int image_type); void RefreshImageDir(std::wstring path, int image_type);
void SetDevice(irr::IrrlichtDevice* dev); void SetDevice(irr::IrrlichtDevice* dev);
void ClearTexture(); void ClearTexture();
void RemoveTexture(int code); void RemoveTexture(int code);
void ResizeTexture(); void ResizeTexture();
irr::video::ITexture* GetTextureFromFile(const char* file, s32 width, s32 height); irr::video::ITexture* GetTextureFromFile(const char* file, irr::s32 width, irr::s32 height);
irr::video::ITexture* GetTexture(int code, bool fit = false); irr::video::ITexture* GetTexture(int code, bool fit = false);
irr::video::ITexture* GetBigPicture(int code, float zoom); irr::video::ITexture* GetBigPicture(int code, float zoom);
irr::video::ITexture* GetTextureThumb(int code); irr::video::ITexture* GetTextureThumb(int code);
......
This diff is collapsed.
project "clzma" project "clzma"
kind "StaticLib" kind "StaticLib"
cdialect "C11"
files { "*.c", "*.h" } files { "*.c", "*.h" }
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