Commit fefc9d5b authored by nanahira's avatar nanahira Committed by GitHub

Merge branch 'master' into patch-sum-param

parents d75e2be6 ec24699d
This diff is collapsed.
......@@ -8,6 +8,8 @@
/pics
/replay
/single
/sound
!/sound/files.txt
/WindBot
/cards.cdb
/error.log
......@@ -18,6 +20,8 @@
/ygopro
/ygopro.exe
/ygopro.app
/ikpMP3.dll
/irrKlang.dll
/bin
/build
......@@ -28,6 +32,7 @@
/irrklang
/ikpmp3
/lua
/miniaudio
/sqlite3
/gframe/*.ico
/gframe/ygopro.rc
......
[submodule "ocgcore"]
path = ocgcore
url = git@github.com:Fluorohydride/ygopro-core.git
url = https://github.com/Fluorohydride/ygopro-core.git
[submodule "script"]
path = script
url = git@github.com:Fluorohydride/ygopro-scripts.git
url = https://github.com/Fluorohydride/ygopro-scripts.git
// 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_BUTTON_H_INCLUDED__
#define __C_GUI_BUTTON_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIButton.h"
#include "IGUISpriteBank.h"
#include "SColor.h"
namespace irr
{
namespace gui
{
class CGUIButton : public IGUIButton
{
public:
//! constructor
CGUIButton(IGUIEnvironment* environment, IGUIElement* parent,
s32 id, core::rect<s32> rectangle, bool noclip=false);
//! destructor
virtual ~CGUIButton();
//! called if an event happened.
virtual bool OnEvent(const SEvent& event);
//! draws the element and its children
virtual void draw();
//! sets another skin independent font. if this is set to zero, the button uses the font of the skin.
virtual void setOverrideFont(IGUIFont* font=0);
//! Gets the override font (if any)
virtual IGUIFont* getOverrideFont() const;
//! Get the font which is used right now for drawing
virtual IGUIFont* getActiveFont() const;
//! Sets an image which should be displayed on the button when it is in normal state.
virtual void setImage(video::ITexture* image=0);
//! Sets an image which should be displayed on the button when it is in normal state.
virtual void setImage(video::ITexture* image, const core::rect<s32>& pos);
//! Sets an image which should be displayed on the button when it is in pressed state.
virtual void setPressedImage(video::ITexture* image=0);
//! Sets an image which should be displayed on the button when it is in pressed state.
virtual void setPressedImage(video::ITexture* image, const core::rect<s32>& pos);
//! Sets the sprite bank used by the button
virtual void setSpriteBank(IGUISpriteBank* bank=0);
//! 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
*/
virtual void setSprite(EGUI_BUTTON_STATE state, s32 index,
video::SColor color=video::SColor(255,255,255,255), bool loop=false);
//! 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.
virtual void setIsPushButton(bool isPushButton=true);
//! Checks whether the button is a push button
virtual bool isPushButton() const;
//! Sets the pressed state of the button if this is a pushbutton
virtual void setPressed(bool pressed=true);
//! Returns if the button is currently pressed
virtual bool isPressed() const;
//! Sets if the button should use the skin to draw its border
virtual void setDrawBorder(bool border=true);
//! Checks if the button face and border are being drawn
virtual bool isDrawingBorder() const;
//! Sets if the alpha channel should be used for drawing images on the button (default is false)
virtual void setUseAlphaChannel(bool useAlphaChannel=true);
//! Checks if the alpha channel should be used for drawing images on the button
virtual bool isAlphaChannelUsed() const;
//! Sets if the button should scale the button images to fit
virtual void setScaleImage(bool scaleImage=true);
//! Checks whether the button scales the used images
virtual bool isScalingImage() const;
//! Writes attributes of the element.
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
//! Reads attributes of the element
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
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;
u32 ClickTime, HoverTime, FocusTime;
bool IsPushButton;
bool Pressed;
bool UseAlphaChannel;
bool DrawBorder;
bool ScaleImage;
};
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif // __C_GUI_BUTTON_H_INCLUDED__
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_
#define _C_GUI_IMAGE_BUTTON_H_
#include <irrlicht.h>
#include "CGUIButton.h"
#include <IrrCompileConfig.h>
#ifdef _IRR_COMPILE_WITH_GUI_
#include <IGUIButton.h>
#include <SColor.h>
namespace irr {
namespace video {
class IVideoDriver;
class ITexture;
}
namespace gui {
class IGUISpriteBank;
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);
void Draw2DImageQuad(video::IVideoDriver* driver, video::ITexture* image, core::rect<s32> sourceRect,
core::position2d<s32> corner[4], bool useAlphaChannel = true, video::SColor color = 0xffffffff);
class CGUIImageButton : public CGUIButton {
core::vector2d<s32> corner[4], bool useAlphaChannel = true, video::SColor color = 0xffffffff);
class CGUIImageButton : public IGUIButton {
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);
virtual void draw();
virtual void setImage(video::ITexture* image = 0);
virtual void setDrawImage(bool b);
virtual void setImageRotation(f32 r);
virtual void setImageScale(core::vector2df s);
virtual void setImageSize(core::dimension2di s);
virtual IGUIFont* getOverrideFont(void) const;
virtual IGUIFont* getActiveFont() const;
private:
static CGUIImageButton* addImageButton(IGUIEnvironment* env, const core::rect<s32>& rectangle, IGUIElement* parent, s32 id);
//! constructor
CGUIImageButton(IGUIEnvironment* environment, IGUIElement* parent,
s32 id, core::rect<s32> rectangle, bool noclip = false);
//! destructor
~CGUIImageButton() override;
//! called if an event happened.
bool OnEvent(const SEvent& event) override;
//! 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 isFixedSize;
f32 imageRotation;
......@@ -36,4 +155,6 @@ private:
}
}
#endif // _IRR_COMPILE_WITH_GUI_
#endif //_C_GUI_IMAGE_BUTTON_H_
This diff is collapsed.
......@@ -54,7 +54,7 @@ public:
//! Structure representing a single TrueType glyph.
struct SGUITTGlyph {
//! Constructor.
SGUITTGlyph() : isLoaded(false), glyph_page(0), surface(0), parent(0) {}
SGUITTGlyph() : isLoaded(false), glyph_page(0), advance({}), surface(0), parent(0) {}
//! Destructor.
~SGUITTGlyph() {
......@@ -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);
//! Destructor
virtual ~CGUITTFont();
~CGUITTFont() override;
//! Sets the amount of glyphs to batch load.
virtual void setBatchLoadSize(u32 batch_size) {
void setBatchLoadSize(u32 batch_size) {
batch_load_size = batch_size;
}
//! 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;
}
//! Get the font size.
virtual u32 getFontSize() const {
u32 getFontSize() const {
return size;
}
//! Check the font's transparency.
virtual bool isTransparent() const {
bool isTransparent() const {
return use_transparency;
}
//! Check if the font auto-hinting is enabled.
//! Auto-hinting is FreeType's built-in font hinting engine.
virtual bool useAutoHinting() const {
bool useAutoHinting() const {
return use_auto_hinting;
}
//! Check if the font hinting is enabled.
virtual bool useHinting() const {
bool useHinting() const {
return use_hinting;
}
//! 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.
virtual bool useMonochrome() const {
bool useMonochrome() const {
return use_monochrome;
}
//! Tells the font to allow transparency when rendering.
//! Default: true.
//! \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.
//! Default: false.
//! \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.
//! Default: Hinting and auto-hinting true.
//! \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.
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.
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,
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.
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.
virtual core::dimension2d<u32> getDimension(const wchar_t* text) const;
virtual core::dimension2d<u32> getDimension(const core::ustring& text) const;
core::dimension2d<u32> getDimension(const wchar_t* text) const override;
core::dimension2d<u32> getDimension(const core::ustring& text) const;
//! 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;
virtual s32 getCharacterFromPos(const core::ustring& text, s32 pixel_x) const;
s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x) const override;
s32 getCharacterFromPos(const core::ustring& text, s32 pixel_x) const;
//! Sets global kerning width for the font.
virtual void setKerningWidth(s32 kerning);
void setKerningWidth(s32 kerning) override;
//! 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,
virtual s32 getKerningWidth(const wchar_t* thisLetter = 0, const wchar_t* previousLetter = 0) const;
virtual s32 getKerningWidth(const uchar32_t thisLetter = 0, const uchar32_t previousLetter = 0) const;
s32 getKerningWidth(const wchar_t* thisLetter = 0, const wchar_t* previousLetter = 0) const override;
s32 getKerningWidth(const uchar32_t thisLetter = 0, const uchar32_t previousLetter = 0) const;
//! Returns the distance between letters
virtual s32 getKerningHeight() const;
s32 getKerningHeight() const override;
//! Define which characters should not be drawn by the font.
virtual void setInvisibleCharacters(const wchar_t *s);
virtual void setInvisibleCharacters(const core::ustring& s);
void setInvisibleCharacters(const wchar_t *s) final;
//! Get the last glyph page if there's still available slots.
//! If not, it will return zero.
......@@ -312,14 +314,14 @@ public:
//! Create corresponding character's software image copy from the font,
//! so you can use this data just like any ordinary video::IImage.
//! \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.
//! \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.
virtual core::array<scene::ISceneNode*> addTextSceneNode
core::array<scene::ISceneNode*> addTextSceneNode
(const wchar_t* text, scene::ISceneManager* smgr, scene::ISceneNode* parent = 0,
const video::SColor& color = video::SColor(255, 0, 0, 0), bool center = false );
......@@ -340,7 +342,7 @@ private:
static scene::IMesh* shared_plane_ptr_;
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);
void reset_images();
void update_glyph_pages() const;
......
#ifndef BUFFERIO_H
#define BUFFERIO_H
#ifdef _MSC_VER
#pragma warning(disable: 4244)
#endif
#include <cstdint>
#include <cwchar>
#include "../ocgcore/buffer.h"
class BufferIO {
public:
inline static int ReadInt32(char*& p) {
int ret = *(int*)p;
p += 4;
return ret;
static int ReadInt32(unsigned char*& p) {
return buffer_read<int32_t>(p);
}
inline static short ReadInt16(char*& p) {
short ret = *(short*)p;
p += 2;
return ret;
static short ReadInt16(unsigned char*& p) {
return buffer_read<int16_t>(p);
}
inline static char ReadInt8(char*& p) {
char ret = *(char*)p;
p++;
return ret;
static char ReadInt8(unsigned char*& p) {
return buffer_read<char>(p);
}
inline static unsigned char ReadUInt8(char*& p) {
unsigned char ret = *(unsigned char*)p;
p++;
return ret;
static unsigned char ReadUInt8(unsigned char*& p) {
return buffer_read<unsigned char>(p);
}
inline static void WriteInt32(char*& p, int val) {
(*(int*)p) = val;
p += 4;
static void WriteInt32(unsigned char*& p, int val) {
buffer_write<int32_t>(p, val);
}
inline static void WriteInt16(char*& p, short val) {
(*(short*)p) = val;
p += 2;
static void WriteInt16(unsigned char*& p, short val) {
buffer_write<int16_t>(p, val);
}
inline static void WriteInt8(char*& p, char val) {
*p = val;
p++;
static void WriteInt8(unsigned char*& p, char val) {
buffer_write<char>(p, val);
}
/**
* @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>
inline static int CopyWStr(T1* src, T2* pstr, int bufsize) {
static int CopyWStr(const T1* src, T2* pstr, int bufsize) {
int l = 0;
while(src[l] && l < bufsize - 1) {
pstr[l] = src[l];
pstr[l] = (T2)src[l];
l++;
}
pstr[l] = 0;
return l;
}
template<typename T1, typename T2>
inline static int CopyWStrRef(T1* src, T2*& pstr, int bufsize) {
static int CopyWStrRef(const T1* src, T2*& pstr, int bufsize) {
int l = 0;
while(src[l] && l < bufsize - 1) {
pstr[l] = src[l];
pstr[l] = (T2)src[l];
l++;
}
pstr += l;
*pstr = 0;
return l;
}
// UTF-16/UTF-32 to UTF-8
static int EncodeUTF8(const wchar_t * wsrc, char * str) {
char* pstr = str;
while(*wsrc != 0) {
if(*wsrc < 0x80) {
*str = *wsrc;
++str;
} else if(*wsrc < 0x800) {
str[0] = ((*wsrc >> 6) & 0x1f) | 0xc0;
str[1] = ((*wsrc) & 0x3f) | 0x80;
str += 2;
} else if(*wsrc < 0x10000 && (*wsrc < 0xd800 || *wsrc > 0xdfff)) {
str[0] = ((*wsrc >> 12) & 0xf) | 0xe0;
str[1] = ((*wsrc >> 6) & 0x3f) | 0x80;
str[2] = ((*wsrc) & 0x3f) | 0x80;
str += 3;
} else {
#ifdef _WIN32
unsigned unicode = 0;
unicode |= (*wsrc++ & 0x3ff) << 10;
unicode |= *wsrc & 0x3ff;
unicode += 0x10000;
str[0] = ((unicode >> 18) & 0x7) | 0xf0;
str[1] = ((unicode >> 12) & 0x3f) | 0x80;
str[2] = ((unicode >> 6) & 0x3f) | 0x80;
str[3] = ((unicode) & 0x3f) | 0x80;
#else
str[0] = ((*wsrc >> 18) & 0x7) | 0xf0;
str[1] = ((*wsrc >> 12) & 0x3f) | 0x80;
str[2] = ((*wsrc >> 6) & 0x3f) | 0x80;
str[3] = ((*wsrc) & 0x3f) | 0x80;
#endif // _WIN32
str += 4;
}
wsrc++;
}
*str = 0;
return str - pstr;
template<typename T1, typename T2, size_t N>
static int CopyCharArray(const T1* src, T2(&dst)[N]) {
return CopyWStr(src, dst, N);
}
// UTF-8 to UTF-16/UTF-32
static int DecodeUTF8(const char * src, wchar_t * wstr) {
const char* p = src;
wchar_t* wp = wstr;
while(*p != 0) {
if((*p & 0x80) == 0) {
*wp = *p;
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++;
} else if((*p & 0xe0) == 0xc0) {
*wp = (((unsigned)p[0] & 0x1f) << 6) | ((unsigned)p[1] & 0x3f);
return UINT32_MAX;
}
cur = ((p[0] & 0x1fU) << 6) | (p[1] & 0x3fU);
p += 2;
} else if((*p & 0xf0) == 0xe0) {
*wp = (((unsigned)p[0] & 0xf) << 12) | (((unsigned)p[1] & 0x3f) << 6) | ((unsigned)p[2] & 0x3f);
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;
} else if((*p & 0xf8) == 0xf0) {
#ifdef _WIN32
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);
#endif // _WIN32
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;
} else
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
// return: string length
static int EncodeUTF8String(const wchar_t* wsrc, char* str, int size) {
auto pw = wsrc;
auto pstr = str;
while (*pw != 0) {
unsigned cur = 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)
codepoint_size = 1;
else if (cur < 0x800U)
codepoint_size = 2;
else if (cur < 0x10000U)
codepoint_size = 3;
else
codepoint_size = 4;
if ((int)(pstr - str) + codepoint_size > size - 1)
break;
switch (codepoint_size) {
case 1:
*pstr = (char)cur;
break;
case 2:
pstr[0] = ((cur >> 6) & 0x1f) | 0xc0;
pstr[1] = (cur & 0x3f) | 0x80;
break;
case 3:
pstr[0] = ((cur >> 12) & 0xf) | 0xe0;
pstr[1] = ((cur >> 6) & 0x3f) | 0x80;
pstr[2] = (cur & 0x3f) | 0x80;
break;
case 4:
pstr[0] = ((cur >> 18) & 0x7) | 0xf0;
pstr[1] = ((cur >> 12) & 0x3f) | 0x80;
pstr[2] = ((cur >> 6) & 0x3f) | 0x80;
pstr[3] = (cur & 0x3f) | 0x80;
break;
default:
break;
}
pstr += codepoint_size;
}
*pstr = 0;
return (int)(pstr - str);
}
// UTF-8 to UTF-16/UTF-32
// return: string length
static int DecodeUTF8String(const char* src, wchar_t* wstr, int size) {
const char* p = src;
wchar_t* wp = wstr;
while(*p != 0) {
unsigned int cur = ConvertUTF8(p);
int codepoint_size = 0;
if (!IsUnicodeChar(cur))
continue;
if (cur >= 0x10000) {
if (sizeof(wchar_t) == 2)
codepoint_size = 2;
else
codepoint_size = 1;
}
else
codepoint_size = 1;
if ((int)(wp - wstr) + codepoint_size > size - 1)
break;
if (codepoint_size == 1) {
wp[0] = cur;
wp++;
}
else {
cur -= 0x10000U;
wp[0] = (cur >> 10) | 0xd800;
wp[1] = (cur & 0x3ff) | 0xdc00;
wp += 2;
}
}
*wp = 0;
return wp - wstr;
}
static int GetVal(const wchar_t* pstr) {
int ret = 0;
while(*pstr >= L'0' && *pstr <= L'9') {
ret = ret * 10 + (*pstr - L'0');
pstr++;
template<size_t N>
static int EncodeUTF8(const wchar_t* src, char(&dst)[N]) {
return EncodeUTF8String(src, dst, N);
}
template<size_t N>
static int DecodeUTF8(const char* src, wchar_t(&dst)[N]) {
return DecodeUTF8String(src, dst, N);
}
template<size_t N, typename T>
static void NullTerminate(T(&str)[N]) {
str[N - 1] = 0;
}
static int GetVal(const wchar_t* pstr) {
if (*pstr >= L'0' && *pstr <= L'9') {
int ret{};
wchar_t* str_end{};
ret = std::wcstol(pstr, &str_end, 10);
if (*str_end == 0)
return ret;
else
return 0;
}
else
return 0;
}
};
......
This diff is collapsed.
......@@ -5,47 +5,9 @@
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
namespace ygo {
struct CardData {
unsigned int code;
unsigned int alias;
unsigned long long setcode;
unsigned int type;
unsigned int level;
unsigned int attribute;
unsigned int race;
int attack;
int defense;
unsigned int lscale;
unsigned int rscale;
unsigned int link_marker;
};
struct CardDataC {
unsigned int code;
unsigned int alias;
unsigned long long setcode;
unsigned int type;
unsigned int level;
unsigned int attribute;
unsigned int race;
int attack;
int defense;
unsigned int lscale;
unsigned int rscale;
unsigned int link_marker;
unsigned int ot;
unsigned int category;
};
struct CardString {
std::wstring name;
std::wstring text;
std::wstring desc[16];
};
typedef std::unordered_map<unsigned int, CardDataC>::const_iterator code_pointer;
class ClientCard {
public:
irr::core::matrix4 mTransform;
......@@ -53,72 +15,71 @@ public:
irr::core::vector3df curRot;
irr::core::vector3df dPos;
irr::core::vector3df dRot;
u32 curAlpha;
u32 dAlpha;
u32 aniFrame;
bool is_moving;
bool is_fading;
bool is_hovered;
bool is_selectable;
bool is_selected;
bool is_showequip;
bool is_showtarget;
bool is_showchaintarget;
bool is_highlighting;
bool is_reversed;
u32 code;
u32 chain_code;
u32 alias;
u32 type;
u32 level;
u32 rank;
u32 link;
u32 attribute;
u32 race;
s32 attack;
s32 defense;
s32 base_attack;
s32 base_defense;
u32 lscale;
u32 rscale;
u32 link_marker;
u32 reason;
u32 select_seq;
u8 owner;
u8 controler;
u8 location;
u8 sequence;
u8 position;
u32 status;
u8 cHint;
u32 chValue;
u32 opParam;
u32 symbol;
u32 cmdFlag;
ClientCard* overlayTarget;
irr::u32 curAlpha{ 255 };
irr::u32 dAlpha{ 0 };
irr::u32 aniFrame{ 0 };
bool is_moving{ false };
bool is_fading{ false };
bool is_hovered{ false };
bool is_selectable{ false };
bool is_selected{ false };
bool is_showequip{ false };
bool is_showtarget{ false };
bool is_showchaintarget{ false };
bool is_highlighting{ false };
bool is_reversed{ false };
unsigned int code{ 0 };
unsigned int chain_code{ 0 };
unsigned int alias{ 0 };
unsigned int type{ 0 };
unsigned int level{ 0 };
unsigned int rank{ 0 };
unsigned int link{ 0 };
unsigned int attribute{ 0 };
unsigned int race{ 0 };
int attack{ 0 };
int defense{ 0 };
int base_attack{ 0 };
int base_defense{ 0 };
unsigned int lscale{ 0 };
unsigned int rscale{ 0 };
unsigned int link_marker{ 0 };
unsigned int reason{ 0 };
unsigned int select_seq{ 0 };
unsigned char owner{ PLAYER_NONE };
unsigned char controler{ PLAYER_NONE };
unsigned char location{ 0 };
unsigned char sequence{ 0 };
unsigned char position{ 0 };
unsigned int status{ 0 };
unsigned char cHint{ 0 };
unsigned int chValue{ 0 };
unsigned int opParam{ 0 };
unsigned int symbol{ 0 };
unsigned int cmdFlag{ 0 };
ClientCard* overlayTarget{ nullptr };
std::vector<ClientCard*> overlayed;
ClientCard* equipTarget;
ClientCard* equipTarget{ nullptr };
std::set<ClientCard*> equipped;
std::set<ClientCard*> cardTarget;
std::set<ClientCard*> ownerTarget;
std::map<int, int> counters;
std::map<int, int> desc_hints;
wchar_t atkstring[16];
wchar_t defstring[16];
wchar_t lvstring[16];
wchar_t linkstring[16];
wchar_t lscstring[16];
wchar_t rscstring[16];
wchar_t atkstring[16]{};
wchar_t defstring[16]{};
wchar_t lvstring[16]{};
wchar_t linkstring[16]{};
wchar_t lscstring[16]{};
wchar_t rscstring[16]{};
ClientCard();
void SetCode(int code);
void UpdateInfo(char* buf);
ClientCard() = default;
~ClientCard();
void SetCode(unsigned int x);
void UpdateInfo(unsigned char* buf);
void ClearTarget();
void ClearData();
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 @@
#define CLIENT_FIELD_H
#include "config.h"
#include "../ocgcore/mtrandom.h"
#include <random>
#include <vector>
#include <set>
#include <map>
......@@ -13,13 +13,13 @@ class ClientCard;
struct ChainInfo {
irr::core::vector3df chain_pos;
ClientCard* chain_card;
int code;
int desc;
int controler;
int location;
int sequence;
bool solved;
ClientCard* chain_card{ nullptr };
int code{ 0 };
int desc{ 0 };
int controler{ 0 };
int location{ 0 };
int sequence{ 0 };
bool solved{ false };
std::set<ClientCard*> target;
};
......@@ -33,6 +33,7 @@ public:
std::vector<ClientCard*> remove[2];
std::vector<ClientCard*> extra[2];
std::set<ClientCard*> overlay_cards;
std::vector<ClientCard*> summonable_cards;
std::vector<ClientCard*> spsummonable_cards;
std::vector<ClientCard*> msetable_cards;
......@@ -45,55 +46,62 @@ public:
std::vector<int> select_options;
std::vector<int> select_options_index;
std::vector<ChainInfo> chains;
int extra_p_count[2];
int extra_p_count[2]{};
size_t selected_option;
ClientCard* attacker;
ClientCard* attack_target;
unsigned int disabled_field;
unsigned int selectable_field;
unsigned int selected_field;
int select_min;
int select_max;
int must_select_count;
int select_sumval;
int select_mode;
bool select_cancelable;
bool select_panalmode;
bool select_ready;
int announce_count;
int select_counter_count;
int select_counter_type;
size_t selected_option{ 0 };
ClientCard* attacker{ nullptr };
ClientCard* attack_target{ nullptr };
unsigned int disabled_field{ 0 };
unsigned int selectable_field{ 0 };
unsigned int selected_field{ 0 };
int select_min{ 0 };
int select_max{ 0 };
int must_select_count{ 0 };
int select_curval_l{ 0 };
int select_curval_h{ 0 };
int select_sumval{ 0 };
int select_mode{ 0 };
int select_hint{0};
bool select_cancelable{false};
bool select_panalmode{ false };
bool select_ready{ false };
int announce_count{ 0 };
int select_counter_count{ 0 };
int select_counter_type{ 0 };
std::vector<ClientCard*> selectable_cards;
std::vector<ClientCard*> selected_cards;
std::set<ClientCard*> selectsum_cards;
std::vector<ClientCard*> selectsum_all;
std::vector<int> declare_opcodes;
std::vector<unsigned int> declare_opcodes;
std::vector<ClientCard*> display_cards;
std::vector<int> sort_list;
std::map<int, int> player_desc_hints[2];
bool grave_act;
bool remove_act;
bool deck_act;
bool extra_act;
bool pzone_act[2];
bool conti_act;
bool chain_forced;
bool grave_act[2]{ false };
bool remove_act[2]{ false };
bool deck_act[2]{ false };
bool extra_act[2]{ false };
bool pzone_act[2]{ false };
bool conti_act{ false };
bool chain_forced{ false };
ChainInfo current_chain;
bool last_chain;
bool deck_reversed;
bool conti_selecting;
bool cant_check_grave;
mt19937 rnd;
bool last_chain{ false };
bool deck_reversed{ false };
bool conti_selecting{ false };
bool cant_check_grave{ false };
bool tag_surrender{ false };
bool tag_teammate_surrender{ false };
std::mt19937 rnd;
ClientField();
~ClientField();
void Clear();
void Initial(int player, int deckc, int extrac);
void ResetSequence(std::vector<ClientCard*>& list, bool reset_height);
ClientCard* GetCard(int controler, int location, int sequence, int sub_seq = 0);
void AddCard(ClientCard* pcard, int controler, int location, int sequence);
ClientCard* RemoveCard(int controler, int location, int sequence);
void UpdateCard(int controler, int location, int sequence, char* data);
void UpdateFieldCard(int controler, int location, char* data);
void UpdateCard(int controler, int location, int sequence, unsigned char* data);
void UpdateFieldCard(int controler, int location, unsigned char* data);
void ClearCommandFlag();
void ClearSelect();
void ClearChainSelect();
......@@ -121,24 +129,24 @@ public:
void UpdateDeclarableList();
irr::gui::IGUIElement* panel;
irr::gui::IGUIElement* panel{ nullptr };
std::vector<int> ancard;
int hovered_controler;
int hovered_location;
size_t hovered_sequence;
int command_controler;
int command_location;
size_t command_sequence;
ClientCard* hovered_card;
int hovered_player;
ClientCard* clicked_card;
ClientCard* command_card;
ClientCard* highlighting_card;
ClientCard* menu_card;
int list_command;
int hovered_controler{ 0 };
int hovered_location{ 0 };
size_t hovered_sequence{ 0 };
int command_controler{ 0 };
int command_location{ 0 };
size_t command_sequence{ 0 };
ClientCard* hovered_card{ nullptr };
int hovered_player{ 0 };
ClientCard* clicked_card{ nullptr };
ClientCard* command_card{ nullptr };
ClientCard* highlighting_card{ nullptr };
ClientCard* menu_card{ nullptr };
int list_command{ 0 };
virtual bool OnEvent(const irr::SEvent& event);
virtual bool OnCommonEvent(const irr::SEvent& event);
bool OnEvent(const irr::SEvent& event) override;
bool OnCommonEvent(const irr::SEvent& event);
void GetHoverField(int x, int y);
void ShowMenu(int flag, int x, int y);
void HideMenu();
......@@ -154,8 +162,6 @@ public:
}
//special cards
#define CARD_MARINE_DOLPHIN 78734254
#define CARD_TWINKLE_MOSS 13857930
#define CARD_QUESTION 38723936
#endif //CLIENT_FIELD_H
#ifndef __CONFIG_H
#define __CONFIG_H
#pragma once
#ifndef YGOPRO_CONFIG_H
#define YGOPRO_CONFIG_H
#define _IRR_STATIC_LIB_
#define IRR_COMPILE_WITH_DX9_DEV_PACK
#include <cerrno>
#ifdef _WIN32
#include <WinSock2.h>
#define NOMINMAX
#include <WinSock2.h>
#include <windows.h>
#include <ws2tcpip.h>
#ifdef _MSC_VER
#if defined(_MSC_VER) or defined(__MINGW32__)
#define mywcsncasecmp _wcsnicmp
#define mystrncasecmp _strnicmp
#else
......@@ -24,14 +25,12 @@
#else //_WIN32
#include <errno.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <locale.h>
#define SD_BOTH 2
#define SOCKET int
......@@ -42,53 +41,56 @@
#define SOCKADDR sockaddr
#define SOCKET_ERRNO() (errno)
#include <wchar.h>
#define mywcsncasecmp wcsncasecmp
#define mystrncasecmp strncasecmp
inline int _wtoi(const wchar_t * s) {
wchar_t * endptr;
return (int)wcstol(s, &endptr, 10);
}
#endif
template<size_t N, typename... TR>
inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
return swprintf(buf, N, fmt, args...);
}
#include <irrlicht.h>
#ifdef __APPLE__
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#else //__APPLE__
#include <GL/gl.h>
#include <GL/glu.h>
#endif //__APPLE__
#include "CGUITTFont.h"
#include "CGUIImageButton.h"
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <time.h>
#include <thread>
#include <mutex>
#include <algorithm>
#include <string>
#include "bufferio.h"
#include "myfilesystem.h"
#include "mysignal.h"
#include "../ocgcore/ocgapi.h"
#include "../ocgcore/common.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
template<size_t N, typename... TR>
inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
return std::swprintf(buf, N, fmt, args...);
}
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 const unsigned short PRO_VERSION;
extern int enable_log;
extern unsigned int enable_log;
extern bool exit_on_return;
extern bool open_file;
extern wchar_t open_file_name[256];
......
This diff is collapsed.
#ifndef DATAMANAGER_H
#define DATAMANAGER_H
#include "config.h"
#include "sqlite3.h"
#include "spmemvfs/spmemvfs.h"
#include "client_card.h"
#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 {
constexpr int MAX_STRING_ID = 0x7ff;
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 {
public:
DataManager(): _datas(8192), _strings(8192) {}
DataManager();
bool ReadDB(sqlite3* pDB);
bool LoadDB(const wchar_t* wfile);
bool LoadStrings(const char* file);
bool LoadStrings(IReadFile* reader);
bool LoadStrings(irr::io::IReadFile* reader);
void ReadStringConfLine(const char* linebuf);
bool Error(spmemvfs_db_t* pDB, sqlite3_stmt* pStmt = 0);
bool GetData(int code, CardData* pData);
code_pointer GetCodePointer(int code);
bool GetString(int code, CardString* pStr);
const wchar_t* GetName(int code);
const wchar_t* GetText(int code);
const wchar_t* GetDesc(unsigned int strCode);
const wchar_t* GetSysString(int code);
const wchar_t* GetVictoryString(int code);
const wchar_t* GetCounterName(int code);
const wchar_t* GetSetName(int code);
unsigned int GetSetCode(const wchar_t* setname);
const wchar_t* GetNumString(int num, bool bracket = false);
const wchar_t* FormatLocation(int location, int sequence);
const wchar_t* FormatAttribute(int attribute);
const wchar_t* FormatRace(int race);
const wchar_t* FormatType(int type);
const wchar_t* FormatSetName(unsigned long long setcode);
const wchar_t* FormatLinkMarker(int link_marker);
bool Error(sqlite3* pDB, sqlite3_stmt* pStmt = nullptr);
code_pointer GetCodePointer(unsigned int code) const;
string_pointer GetStringPointer(unsigned int code) const;
code_pointer datas_begin() const;
code_pointer datas_end() const;
string_pointer strings_begin() const;
string_pointer strings_end() const;
bool GetData(unsigned int code, CardData* pData) const;
bool GetString(unsigned int code, CardString* pStr) const;
const wchar_t* GetName(unsigned int code) const;
const wchar_t* GetText(unsigned int code) const;
const wchar_t* GetDesc(unsigned int strCode) const;
const wchar_t* GetSysString(int code) const;
const wchar_t* GetVictoryString(int code) const;
const wchar_t* GetCounterName(int code) const;
const wchar_t* GetSetName(int code) const;
std::vector<unsigned int> GetSetCodes(std::wstring setname) const;
std::wstring GetNumString(int num, bool bracket = false) const;
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, CardDataC> _datas;
std::unordered_map<unsigned int, CardString> _strings;
std::unordered_map<unsigned int, std::wstring> _counterStrings;
std::unordered_map<unsigned int, std::wstring> _victoryStrings;
std::unordered_map<unsigned int, std::wstring> _setnameStrings;
std::unordered_map<unsigned int, std::wstring> _sysStrings;
char errmsg[512]{};
wchar_t numStrings[301][4];
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 unsigned char scriptBuffer[0x100000];
static const wchar_t* unknown_string;
static int CardReader(int, void*);
static byte* ScriptReaderEx(const char* script_name, int* slen);
static byte* ScriptReader(const char* script_name, int* slen);
static IFileSystem* FileSystem;
static uint32_t CardReader(uint32_t, card_data*);
static unsigned char* ScriptReaderEx(const char* script_path, int* slen);
//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:
std::unordered_map<unsigned int, CardDataC> _datas;
std::unordered_map<unsigned int, CardString> _strings;
std::unordered_map<unsigned int, std::vector<uint16_t>> extra_setcode;
};
extern DataManager dataManager;
......
This diff is collapsed.
#ifndef DECK_CON_H
#define DECK_CON_H
#include "config.h"
#include <unordered_map>
#include <vector>
#include "client_card.h"
#include "../ocgcore/mtrandom.h"
#include <random>
#include <irrlicht.h>
#include "data_manager.h"
#include "deck_manager.h"
namespace ygo {
class DeckBuilder: public irr::IEventReceiver {
public:
virtual bool OnEvent(const irr::SEvent& event);
DeckBuilder();
bool OnEvent(const irr::SEvent& event) override;
void Initialize();
void Terminate();
void GetHoveredCard();
......@@ -28,7 +30,7 @@ public:
void ChangeCategory(int catesel);
void ShowDeckManage();
void ShowBigCard(int code, float zoom);
void ZoomBigCard(s32 centerx = -1, s32 centery = -1);
void ZoomBigCard(irr::s32 centerx = -1, irr::s32 centery = -1);
void CloseBigCard();
bool CardNameContains(const wchar_t *haystack, const wchar_t *needle);
......@@ -41,49 +43,49 @@ public:
void pop_side(int seq);
bool check_limit(code_pointer pointer);
long long filter_effect;
unsigned int filter_type;
unsigned int filter_type2;
unsigned int filter_attrib;
unsigned int filter_race;
unsigned int filter_atktype;
int filter_atk;
unsigned int filter_deftype;
int filter_def;
unsigned int filter_lvtype;
unsigned int filter_lv;
unsigned int filter_scltype;
unsigned int filter_scl;
unsigned int filter_marks;
int filter_lm;
position2di mouse_pos;
int hovered_code;
int hovered_pos;
int hovered_seq;
int is_lastcard;
int click_pos;
bool is_draging;
bool is_starting_dragging;
int dragx;
int dragy;
int bigcard_code;
float bigcard_zoom;
size_t pre_mainc;
size_t pre_extrac;
size_t pre_sidec;
unsigned long long filter_effect{};
unsigned int filter_type{};
unsigned int filter_type2{};
unsigned int filter_attrib{};
unsigned int filter_race{};
unsigned int filter_atktype{};
int filter_atk{};
unsigned int filter_deftype{};
int filter_def{};
unsigned int filter_lvtype{};
unsigned int filter_lv{};
unsigned int filter_scltype{};
unsigned int filter_scl{};
unsigned int filter_marks{};
int filter_lm{};
irr::core::vector2di mouse_pos;
int hovered_code{};
int hovered_pos{};
int hovered_seq{ -1 };
int is_lastcard{};
int click_pos{};
bool is_draging{};
bool is_starting_dragging{};
int dragx{};
int dragy{};
int bigcard_code{};
float bigcard_zoom{};
size_t pre_mainc{};
size_t pre_extrac{};
size_t pre_sidec{};
code_pointer draging_pointer;
int prev_category;
int prev_deck;
s32 prev_operation;
int prev_sel;
bool is_modified;
bool readonly;
bool showing_pack;
mt19937 rnd;
int prev_category{};
int prev_deck{};
irr::s32 prev_operation{};
int prev_sel{ -1 };
bool is_modified{};
bool readonly{};
bool showing_pack{};
std::mt19937 rnd;
const std::unordered_map<int, int>* filterList;
const LFList* filterList{};
std::vector<code_pointer> results;
wchar_t result_string[8];
wchar_t result_string[8]{};
std::vector<std::wstring> expansionPacks;
};
......
This diff is collapsed.
#ifndef DECKMANAGER_H
#define DECKMANAGER_H
#include "config.h"
#include "client_card.h"
#include <unordered_map>
#include <vector>
#include <sstream>
#include "data_manager.h"
namespace ygo {
constexpr int DECK_MAX_SIZE = 60;
constexpr int DECK_MIN_SIZE = 40;
constexpr int EXTRA_MAX_SIZE = 15;
constexpr int SIDE_MAX_SIZE = 15;
constexpr int PACK_MAX_SIZE = 1000;
struct LFList {
unsigned int hash;
unsigned int hash{};
std::wstring listName;
std::unordered_map<int, int> content;
std::unordered_map<unsigned int, int> content;
};
struct Deck {
std::vector<code_pointer> main;
std::vector<code_pointer> extra;
std::vector<code_pointer> side;
Deck() {}
Deck() = default;
Deck(const Deck& ndeck) {
main = ndeck.main;
extra = ndeck.extra;
......@@ -31,6 +35,12 @@ struct Deck {
}
};
struct DeckArray {
std::vector<uint32_t> main;
std::vector<uint32_t> extra;
std::vector<uint32_t> side;
};
class DeckManager {
public:
Deck current_deck;
......@@ -40,23 +50,27 @@ public:
void LoadLFListSingle(const char* path);
void LoadLFList();
const wchar_t* GetLFListName(int lfhash);
const std::unordered_map<int, int>* GetLFListContent(int lfhash);
int CheckDeck(Deck& deck, int lfhash, int rule);
int LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec, bool is_packlist = false);
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);
IReadFile* OpenDeckReader(const wchar_t* file);
bool LoadDeck(const wchar_t* file, bool is_packlist = false);
bool LoadDeck(std::istringstream* deckStream, bool is_packlist = false);
bool SaveDeck(Deck& deck, const wchar_t* file);
bool DeleteDeck(const wchar_t* file);
bool CreateCategory(const wchar_t* name);
bool RenameCategory(const wchar_t* oldname, const wchar_t* newname);
bool DeleteCategory(const wchar_t* name);
const wchar_t* GetLFListName(unsigned int lfhash);
const LFList* GetLFList(unsigned int lfhash);
unsigned int CheckDeck(const Deck& deck, unsigned int lfhash, int rule);
bool LoadCurrentDeck(const wchar_t* file, bool is_packlist = false);
bool LoadCurrentDeck(int category_index, const wchar_t* category_name, const wchar_t* deckname);
bool LoadCurrentDeck(std::istringstream& deckStream, bool is_packlist = false);
static uint32_t LoadDeck(Deck& deck, uint32_t dbuf[], int mainc, int sidec, bool is_packlist = false);
static uint32_t LoadDeckFromStream(Deck& deck, std::istringstream& deckStream, bool is_packlist = false);
static bool LoadSide(Deck& deck, uint32_t dbuf[], int mainc, int sidec);
static void GetCategoryPath(wchar_t* ret, int index, const wchar_t* text);
static void GetDeckFile(wchar_t* ret, int category_index, const wchar_t* category_name, const wchar_t* deckname);
static FILE* OpenDeckFile(const wchar_t* file, const char* mode);
static irr::io::IReadFile* OpenDeckReader(const wchar_t* file);
static bool SaveDeck(const Deck& deck, const wchar_t* file);
static void SaveDeck(const Deck& deck, std::stringstream& deckStream);
static bool DeleteDeck(const wchar_t* file);
static bool CreateCategory(const wchar_t* name);
static bool RenameCategory(const wchar_t* oldname, const wchar_t* newname);
static bool DeleteCategory(const wchar_t* name);
static bool SaveDeckArray(const DeckArray& deck, const wchar_t* name);
};
extern DeckManager deckManager;
......
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 "clzma"
kind "StaticLib"
cdialect "C11"
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.
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