Commit 2b937193 authored by wind2009's avatar wind2009

Merge branch 'server' into server-develop

parents 0ad54f23 e6f9be30
// 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__
#ifdef _MSC_VER
#pragma warning(disable: 4244)
#endif
// 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
#include "CGUIImageButton.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include <IGUISpriteBank.h>
#include <IGUISkin.h>
#include <IGUIEnvironment.h>
#include <IVideoDriver.h>
#include <IGUIFont.h>
namespace irr {
namespace gui {
void Draw2DImageRotation(video::IVideoDriver* driver, video::ITexture* image, core::rect<s32> sourceRect,
core::position2d<s32> position, core::position2d<s32> rotationPoint, f32 rotation, core::vector2df scale, bool useAlphaChannel, video::SColor color) {
core::vector2d<s32> position, core::vector2d<s32> rotationPoint, f32 rotation, core::vector2df scale, bool useAlphaChannel, video::SColor color) {
irr::video::SMaterial material;
irr::core::matrix4 oldProjMat = driver->getTransform(irr::video::ETS_PROJECTION);
driver->setTransform(irr::video::ETS_PROJECTION, irr::core::matrix4());
......@@ -56,7 +63,7 @@ void Draw2DImageRotation(video::IVideoDriver* driver, video::ITexture* image, co
driver->setTransform(irr::video::ETS_VIEW, oldViewMat);
}
void Draw2DImageQuad(video::IVideoDriver* driver, video::ITexture* image, core::rect<s32> sourceRect,
core::position2d<s32> corner[4], bool useAlphaChannel, video::SColor color) {
core::vector2d<s32> corner[4], bool useAlphaChannel, video::SColor color) {
irr::video::SMaterial material;
irr::core::matrix4 oldProjMat = driver->getTransform(irr::video::ETS_PROJECTION);
driver->setTransform(irr::video::ETS_PROJECTION, irr::core::matrix4());
......@@ -94,26 +101,220 @@ void Draw2DImageQuad(video::IVideoDriver* driver, video::ITexture* image, core::
driver->setTransform(irr::video::ETS_PROJECTION, oldProjMat);
driver->setTransform(irr::video::ETS_VIEW, oldViewMat);
}
CGUIImageButton::CGUIImageButton(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: CGUIButton(environment, parent, id, rectangle) {
CGUIImageButton* CGUIImageButton::addImageButton(IGUIEnvironment *env, const core::rect<s32>& rectangle, IGUIElement* parent, s32 id) {
CGUIImageButton* button = new CGUIImageButton(env, parent ? parent : 0, id, rectangle);
button->drop();
return button;
}
//! constructor
CGUIImageButton::CGUIImageButton(IGUIEnvironment* environment, IGUIElement* parent,
s32 id, core::rect<s32> rectangle, bool noclip)
: IGUIButton(environment, parent, id, rectangle),
SpriteBank(0), OverrideFont(0), Image(0), PressedImage(0),
IsPushButton(false), Pressed(false),
UseAlphaChannel(false), DrawBorder(true), ScaleImage(false) {
#ifdef _DEBUG
setDebugName("CGUIImageButton");
#endif
setNotClipped(noclip);
// Initialize the sprites.
for (u32 i = 0; i < EGBS_COUNT; ++i)
ButtonSprites[i].Index = -1;
// This element can be tabbed.
setTabStop(true);
setTabOrder(-1);
isDrawImage = true;
isFixedSize = false;
imageRotation = 0.0f;
imageScale = core::vector2df(1.0f, 1.0f);
imageSize = core::dimension2di(rectangle.getWidth(), rectangle.getHeight());
}
CGUIImageButton* CGUIImageButton::addImageButton(IGUIEnvironment *env, const core::rect<s32>& rectangle, IGUIElement* parent, s32 id) {
CGUIImageButton* button = new CGUIImageButton(env, parent ? parent : 0, id, rectangle);
button->drop();
return button;
//! destructor
CGUIImageButton::~CGUIImageButton()
{
if (OverrideFont)
OverrideFont->drop();
if (Image)
Image->drop();
if (PressedImage)
PressedImage->drop();
if (SpriteBank)
SpriteBank->drop();
}
//! Sets if the images should be scaled to fit the button
void CGUIImageButton::setScaleImage(bool scaleImage)
{
ScaleImage = scaleImage;
}
//! Returns whether the button scale the used images
bool CGUIImageButton::isScalingImage() const
{
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return ScaleImage;
}
//! Sets if the button should use the skin to draw its border
void CGUIImageButton::setDrawBorder(bool border)
{
DrawBorder = border;
}
void CGUIImageButton::setSpriteBank(IGUISpriteBank* sprites)
{
if (sprites)
sprites->grab();
if (SpriteBank)
SpriteBank->drop();
SpriteBank = sprites;
}
void CGUIImageButton::setSprite(EGUI_BUTTON_STATE state, s32 index, video::SColor color, bool loop)
{
if (SpriteBank)
{
ButtonSprites[(u32)state].Index = index;
ButtonSprites[(u32)state].Color = color;
ButtonSprites[(u32)state].Loop = loop;
}
else
{
ButtonSprites[(u32)state].Index = -1;
}
}
//! called if an event happened.
bool CGUIImageButton::OnEvent(const SEvent& event)
{
if (!isEnabled())
return IGUIElement::OnEvent(event);
switch (event.EventType)
{
case EET_KEY_INPUT_EVENT:
if (event.KeyInput.PressedDown &&
(event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE))
{
if (!IsPushButton)
setPressed(true);
else
setPressed(!Pressed);
return true;
}
if (Pressed && !IsPushButton && event.KeyInput.PressedDown && event.KeyInput.Key == KEY_ESCAPE)
{
setPressed(false);
return true;
}
else
if (!event.KeyInput.PressedDown && Pressed &&
(event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE))
{
if (!IsPushButton)
setPressed(false);
if (Parent)
{
SEvent newEvent;
newEvent.EventType = EET_GUI_EVENT;
newEvent.GUIEvent.Caller = this;
newEvent.GUIEvent.Element = 0;
newEvent.GUIEvent.EventType = EGET_BUTTON_CLICKED;
Parent->OnEvent(newEvent);
}
return true;
}
break;
case EET_GUI_EVENT:
if (event.GUIEvent.Caller == this)
{
if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST)
{
if (!IsPushButton)
setPressed(false);
}
}
break;
case EET_MOUSE_INPUT_EVENT:
if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN)
{
if (Environment->hasFocus(this) &&
!AbsoluteClippingRect.isPointInside(core::vector2d<s32>(event.MouseInput.X, event.MouseInput.Y)))
{
Environment->removeFocus(this);
return false;
}
if (!IsPushButton)
setPressed(true);
Environment->setFocus(this);
return true;
}
else
if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP)
{
bool wasPressed = Pressed;
if (!AbsoluteClippingRect.isPointInside(core::vector2d<s32>(event.MouseInput.X, event.MouseInput.Y)))
{
if (!IsPushButton)
setPressed(false);
return true;
}
if (!IsPushButton)
setPressed(false);
else
{
setPressed(!Pressed);
}
if ((!IsPushButton && wasPressed && Parent) ||
(IsPushButton && wasPressed != Pressed))
{
SEvent newEvent;
newEvent.EventType = EET_GUI_EVENT;
newEvent.GUIEvent.Caller = this;
newEvent.GUIEvent.Element = 0;
newEvent.GUIEvent.EventType = EGET_BUTTON_CLICKED;
Parent->OnEvent(newEvent);
}
return true;
}
break;
default:
break;
}
return Parent ? Parent->OnEvent(event) : false;
}
void CGUIImageButton::draw() {
if (!IsVisible)
return;
IGUISkin* skin = Environment->getSkin();
video::IVideoDriver* driver = Environment->getVideoDriver();
core::position2di center = AbsoluteRect.getCenter();
core::position2di pos = center;
core::vector2di center = AbsoluteRect.getCenter();
core::vector2di pos = center;
pos.X -= (s32)(ImageRect.getWidth() * imageScale.X * 0.5f);
pos.Y -= (s32)(ImageRect.getHeight() * imageScale.Y * 0.5f);
if(Pressed) {
......@@ -140,7 +341,7 @@ void CGUIImageButton::setImage(video::ITexture* image)
Image = image;
if(image) {
ImageRect = core::rect<s32>(core::position2d<s32>(0, 0), image->getOriginalSize());
ImageRect = core::rect<s32>(core::vector2d<s32>(0, 0), image->getOriginalSize());
if(isFixedSize)
imageScale = core::vector2df((irr::f32)imageSize.Width / image->getSize().Width, (irr::f32)imageSize.Height / image->getSize().Height);
}
......@@ -148,6 +349,14 @@ void CGUIImageButton::setImage(video::ITexture* image)
if(!PressedImage)
setPressedImage(Image);
}
//! Sets the image which should be displayed on the button when it is in its normal state.
void CGUIImageButton::setImage(video::ITexture* image, const core::rect<s32>& pos)
{
setImage(image);
ImageRect = pos;
}
void CGUIImageButton::setDrawImage(bool b) {
isDrawImage = b;
}
......@@ -162,6 +371,21 @@ void CGUIImageButton::setImageSize(core::dimension2di s) {
imageSize = s;
}
//! sets another skin independent font. if this is set to zero, the button uses the font of the skin.
void CGUIImageButton::setOverrideFont(IGUIFont* font)
{
if (OverrideFont == font)
return;
if (OverrideFont)
OverrideFont->drop();
OverrideFont = font;
if (OverrideFont)
OverrideFont->grab();
}
IGUIFont* CGUIImageButton::getOverrideFont( void ) const
{
IGUISkin* skin = Environment->getSkin();
......@@ -178,5 +402,137 @@ IGUIFont* CGUIImageButton::getActiveFont() const
return skin->getFont();
}
//! Sets an image which should be displayed on the button when it is in pressed state.
void CGUIImageButton::setPressedImage(video::ITexture* image)
{
if (image)
image->grab();
if (PressedImage)
PressedImage->drop();
PressedImage = image;
if (image)
PressedImageRect = core::rect<s32>(core::vector2d<s32>(0, 0), image->getOriginalSize());
}
//! Sets the image which should be displayed on the button when it is in its pressed state.
void CGUIImageButton::setPressedImage(video::ITexture* image, const core::rect<s32>& pos)
{
setPressedImage(image);
PressedImageRect = pos;
}
//! 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 CGUIImageButton::setIsPushButton(bool isPushButton)
{
IsPushButton = isPushButton;
}
//! Returns if the button is currently pressed
bool CGUIImageButton::isPressed() const
{
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return Pressed;
}
//! Sets the pressed state of the button if this is a pushbutton
void CGUIImageButton::setPressed(bool pressed)
{
if (Pressed != pressed)
{
Pressed = pressed;
}
}
//! Returns whether the button is a push button
bool CGUIImageButton::isPushButton() const
{
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return IsPushButton;
}
//! Sets if the alpha channel should be used for drawing images on the button (default is false)
void CGUIImageButton::setUseAlphaChannel(bool useAlphaChannel)
{
UseAlphaChannel = useAlphaChannel;
}
//! Returns if the alpha channel should be used for drawing images on the button
bool CGUIImageButton::isAlphaChannelUsed() const
{
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return UseAlphaChannel;
}
bool CGUIImageButton::isDrawingBorder() const
{
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return DrawBorder;
}
//! Writes attributes of the element.
void CGUIImageButton::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options = 0) const
{
IGUIButton::serializeAttributes(out, options);
out->addBool("PushButton", IsPushButton);
if (IsPushButton)
out->addBool("Pressed", Pressed);
out->addTexture("Image", Image);
out->addRect("ImageRect", ImageRect);
out->addTexture("PressedImage", PressedImage);
out->addRect("PressedImageRect", PressedImageRect);
out->addBool("UseAlphaChannel", isAlphaChannelUsed());
out->addBool("Border", isDrawingBorder());
out->addBool("ScaleImage", isScalingImage());
// out->addString ("OverrideFont", OverrideFont);
}
//! Reads attributes of the element
void CGUIImageButton::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options = 0)
{
IGUIButton::deserializeAttributes(in, options);
IsPushButton = in->getAttributeAsBool("PushButton");
Pressed = IsPushButton ? in->getAttributeAsBool("Pressed") : false;
core::rect<s32> rec = in->getAttributeAsRect("ImageRect");
if (rec.isValid())
setImage(in->getAttributeAsTexture("Image"), rec);
else
setImage(in->getAttributeAsTexture("Image"));
rec = in->getAttributeAsRect("PressedImageRect");
if (rec.isValid())
setPressedImage(in->getAttributeAsTexture("PressedImage"), rec);
else
setPressedImage(in->getAttributeAsTexture("PressedImage"));
setDrawBorder(in->getAttributeAsBool("Border"));
setUseAlphaChannel(in->getAttributeAsBool("UseAlphaChannel"));
setScaleImage(in->getAttributeAsBool("ScaleImage"));
// setOverrideFont(in->getAttributeAsString("OverrideFont"));
updateAbsolutePosition();
}
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
// 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_
......@@ -505,7 +505,7 @@ void CGUITTFont::drawUstring(const core::ustring& utext, const core::rect<s32>&p
// Set up some variables.
core::dimension2d<s32> textDimension;
core::position2d<s32> offset = position.UpperLeftCorner;
core::vector2d<s32> offset = position.UpperLeftCorner;
// Determine offset positions.
if (hcenter || vcenter) {
......@@ -561,7 +561,7 @@ void CGUITTFont::drawUstring(const core::ustring& utext, const core::rect<s32>&p
// Determine rendering information.
SGUITTGlyph& glyph = Glyphs[n - 1];
CGUITTGlyphPage* const page = Glyph_Pages[glyph.glyph_page];
page->render_positions.push_back(core::position2di(offset.X + offx, offset.Y + offy));
page->render_positions.push_back(core::vector2di(offset.X + offx, offset.Y + offy));
page->render_source_rects.push_back(glyph.source_rect);
Render_Map.set(glyph.glyph_page, page);
}
......@@ -832,7 +832,7 @@ video::IImage* CGUITTFont::createTextureFromChar(const uchar32_t& ch) {
// Copy the image data out of the page texture.
core::dimension2du glyph_size(glyph.source_rect.getSize());
video::IImage* image = Driver->createImage(format, glyph_size);
pageholder->copyTo(image, core::position2di(0, 0), glyph.source_rect);
pageholder->copyTo(image, core::vector2di(0, 0), glyph.source_rect);
tex->unlock();
return image;
......
......@@ -3,6 +3,9 @@
#define _IRR_STATIC_LIB_
#define IRR_COMPILE_WITH_DX9_DEV_PACK
#include <cerrno>
#ifdef _WIN32
#define NOMINMAX
......@@ -22,7 +25,6 @@
#else //_WIN32
#include <errno.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
......@@ -43,7 +45,7 @@
#define mystrncasecmp strncasecmp
#endif
#include <stdio.h>
#include <cstdio>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
......@@ -56,7 +58,7 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
return std::swprintf(buf, N, fmt, args...);
}
inline FILE* myfopen(const wchar_t* filename, const char* mode) {
inline FILE* mywfopen(const wchar_t* filename, const char* mode) {
FILE* fp{};
#ifdef _WIN32
wchar_t wmode[20]{};
......@@ -65,7 +67,7 @@ inline FILE* myfopen(const wchar_t* filename, const char* mode) {
#else
char fname[1024]{};
BufferIO::EncodeUTF8(filename, fname);
fp = fopen(fname, mode);
fp = std::fopen(fname, mode);
#endif
return fp;
}
......
#include "data_manager.h"
#include "game.h"
#include <stdio.h>
#if !defined(YGOPRO_SERVER_MODE) || defined(SERVER_ZIP_SUPPORT)
#include "spmemvfs/spmemvfs.h"
#endif
......@@ -132,14 +131,14 @@ bool DataManager::LoadDB(const wchar_t* wfile) {
}
#ifndef YGOPRO_SERVER_MODE
bool DataManager::LoadStrings(const char* file) {
FILE* fp = fopen(file, "r");
FILE* fp = std::fopen(file, "r");
if(!fp)
return false;
char linebuf[TEXT_LINE_SIZE]{};
while(fgets(linebuf, sizeof linebuf, fp)) {
while(std::fgets(linebuf, sizeof linebuf, fp)) {
ReadStringConfLine(linebuf);
}
fclose(fp);
std::fclose(fp);
return true;
}
bool DataManager::LoadStrings(irr::io::IReadFile* reader) {
......@@ -163,26 +162,26 @@ void DataManager::ReadStringConfLine(const char* linebuf) {
char strbuf[TEXT_LINE_SIZE]{};
int value{};
wchar_t strBuffer[4096]{};
if (sscanf(linebuf, "!%63s", strbuf) != 1)
if (std::sscanf(linebuf, "!%63s", strbuf) != 1)
return;
if(!std::strcmp(strbuf, "system")) {
if (sscanf(&linebuf[7], "%d %240[^\n]", &value, strbuf) != 2)
if (std::sscanf(&linebuf[7], "%d %240[^\n]", &value, strbuf) != 2)
return;
BufferIO::DecodeUTF8(strbuf, strBuffer);
_sysStrings[value] = strBuffer;
} else if(!std::strcmp(strbuf, "victory")) {
if (sscanf(&linebuf[8], "%x %240[^\n]", &value, strbuf) != 2)
if (std::sscanf(&linebuf[8], "%x %240[^\n]", &value, strbuf) != 2)
return;
BufferIO::DecodeUTF8(strbuf, strBuffer);
_victoryStrings[value] = strBuffer;
} else if(!std::strcmp(strbuf, "counter")) {
if (sscanf(&linebuf[8], "%x %240[^\n]", &value, strbuf) != 2)
if (std::sscanf(&linebuf[8], "%x %240[^\n]", &value, strbuf) != 2)
return;
BufferIO::DecodeUTF8(strbuf, strBuffer);
_counterStrings[value] = strBuffer;
} else if(!std::strcmp(strbuf, "setname")) {
//using tab for comment
if (sscanf(&linebuf[8], "%x %240[^\t\n]", &value, strbuf) != 2)
if (std::sscanf(&linebuf[8], "%x %240[^\t\n]", &value, strbuf) != 2)
return;
BufferIO::DecodeUTF8(strbuf, strBuffer);
_setnameStrings[value] = strBuffer;
......@@ -478,7 +477,7 @@ unsigned char* DataManager::ReadScriptFromIrrFS(const char* script_name, int* sl
unsigned char* DataManager::ReadScriptFromFile(const char* script_name, int* slen) {
wchar_t fname[256]{};
BufferIO::DecodeUTF8(script_name, fname);
FILE* fp = myfopen(fname, "rb");
FILE* fp = mywfopen(fname, "rb");
if (!fp)
return nullptr;
size_t len = std::fread(scriptBuffer, 1, sizeof scriptBuffer, fp);
......
......@@ -46,6 +46,14 @@ static inline bool havePopupWindow() {
return mainGame->wQuery->isVisible() || mainGame->wCategories->isVisible() || mainGame->wLinkMarks->isVisible() || mainGame->wDeckManage->isVisible() || mainGame->wDMQuery->isVisible();
}
static inline void get_deck_file(wchar_t* ret) {
deckManager.GetDeckFile(ret, mainGame->cbDBCategory->getSelected(), mainGame->cbDBCategory->getText(), mainGame->cbDBDecks->getText());
}
static inline void load_current_deck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck) {
deckManager.LoadCurrentDeck(cbCategory->getSelected(), cbCategory->getText(), cbDeck->getText());
}
void DeckBuilder::Initialize() {
mainGame->is_building = true;
mainGame->is_siding = false;
......@@ -164,7 +172,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
if(sel == -1)
break;
wchar_t filepath[256];
deckManager.GetDeckFile(filepath, mainGame->cbDBCategory, mainGame->cbDBDecks);
get_deck_file(filepath);
if(deckManager.SaveDeck(deckManager.current_deck, filepath)) {
mainGame->stACMessage->setText(dataManager.GetSysString(1335));
mainGame->PopupElement(mainGame->wACMessage, 20);
......@@ -480,7 +488,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
int decksel = mainGame->lstDecks->getSelected();
const wchar_t* catename = mainGame->lstCategories->getListItem(catesel);
wchar_t oldfilepath[256];
deckManager.GetDeckFile(oldfilepath, mainGame->cbDBCategory, mainGame->cbDBDecks);
get_deck_file(oldfilepath);
const wchar_t* newdeckname = mainGame->ebDMName->getText();
wchar_t newfilepath[256];
if(catesel == 2) {
......@@ -512,7 +520,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
case BUTTON_DELETE_DECK_DM: {
int decksel = mainGame->lstDecks->getSelected();
wchar_t filepath[256];
deckManager.GetDeckFile(filepath, mainGame->cbDBCategory, mainGame->cbDBDecks);
get_deck_file(filepath);
if(deckManager.DeleteDeck(filepath)) {
mainGame->lstDecks->removeItem(decksel);
mainGame->cbDBDecks->removeItem(decksel);
......@@ -523,7 +531,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
if(decksel != -1) {
mainGame->lstDecks->setSelected(decksel);
mainGame->cbDBDecks->setSelected(decksel);
deckManager.LoadCurrentDeck(mainGame->cbDBCategory, mainGame->cbDBDecks);
load_current_deck(mainGame->cbDBCategory, mainGame->cbDBDecks);
}
RefreshReadonly(prev_category);
prev_deck = decksel;
......@@ -542,7 +550,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
wchar_t deckname[256];
BufferIO::CopyWideString(olddeckname, deckname);
wchar_t oldfilepath[256];
deckManager.GetDeckFile(oldfilepath, mainGame->cbDBCategory, mainGame->cbDBDecks);
get_deck_file(oldfilepath);
wchar_t newfilepath[256];
if(oldcatesel != 2 && newcatesel == 0) {
myswprintf(newfilepath, L"./deck/%ls.ydk", deckname);
......@@ -651,7 +659,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break;
}
case BUTTON_SIDE_RELOAD: {
deckManager.LoadCurrentDeck(mainGame->cbCategorySelect, mainGame->cbDeckSelect);
load_current_deck(mainGame->cbCategorySelect, mainGame->cbDeckSelect);
break;
}
case BUTTON_BIG_CARD_ORIG_SIZE: {
......@@ -689,7 +697,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
int sel = prev_sel;
mainGame->cbDBDecks->setSelected(sel);
wchar_t filepath[256];
deckManager.GetDeckFile(filepath, mainGame->cbDBCategory, mainGame->cbDBDecks);
get_deck_file(filepath);
if(deckManager.DeleteDeck(filepath)) {
mainGame->cbDBDecks->removeItem(sel);
int count = mainGame->cbDBDecks->getItemCount();
......@@ -697,7 +705,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
sel = count - 1;
mainGame->cbDBDecks->setSelected(sel);
if(sel != -1)
deckManager.LoadCurrentDeck(mainGame->cbDBCategory, mainGame->cbDBDecks);
load_current_deck(mainGame->cbDBCategory, mainGame->cbDBDecks);
mainGame->stACMessage->setText(dataManager.GetSysString(1338));
mainGame->PopupElement(mainGame->wACMessage, 20);
prev_deck = sel;
......@@ -711,7 +719,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
ChangeCategory(catesel);
} else if(prev_operation == COMBOBOX_DBDECKS) {
int decksel = mainGame->cbDBDecks->getSelected();
deckManager.LoadCurrentDeck(mainGame->cbDBCategory, mainGame->cbDBDecks);
load_current_deck(mainGame->cbDBCategory, mainGame->cbDBDecks);
prev_deck = decksel;
is_modified = false;
} else if(prev_operation == BUTTON_MANAGE_DECK) {
......@@ -828,7 +836,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
}
int decksel = mainGame->cbDBDecks->getSelected();
if(decksel >= 0) {
deckManager.LoadCurrentDeck(mainGame->cbDBCategory, mainGame->cbDBDecks);
load_current_deck(mainGame->cbDBCategory, mainGame->cbDBDecks);
}
prev_deck = decksel;
is_modified = false;
......@@ -1216,7 +1224,7 @@ void DeckBuilder::GetHoveredCard() {
irr::gui::IGUIElement* root = mainGame->env->getRootGUIElement();
if(root->getElementFromPoint(mouse_pos) != root)
return;
position2di pos = mainGame->ResizeReverse(mouse_pos.X, mouse_pos.Y);
irr::core::vector2di pos = mainGame->ResizeReverse(mouse_pos.X, mouse_pos.Y);
int x = pos.X;
int y = pos.Y;
is_lastcard = 0;
......@@ -1630,7 +1638,7 @@ void DeckBuilder::ChangeCategory(int catesel) {
mainGame->RefreshDeck(mainGame->cbDBCategory, mainGame->cbDBDecks);
mainGame->cbDBDecks->setSelected(0);
RefreshReadonly(catesel);
deckManager.LoadCurrentDeck(mainGame->cbDBCategory, mainGame->cbDBDecks);
load_current_deck(mainGame->cbDBCategory, mainGame->cbDBDecks);
is_modified = false;
prev_category = catesel;
prev_deck = 0;
......
#ifndef DECK_CON_H
#define DECK_CON_H
#include "config.h"
#include <unordered_map>
#include <vector>
#include <irrlicht.h>
#include "data_manager.h"
#include "../ocgcore/mtrandom.h"
......@@ -28,7 +28,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);
......@@ -56,7 +56,7 @@ public:
unsigned int filter_scl{};
unsigned int filter_marks{};
int filter_lm{};
position2di mouse_pos;
irr::core::vector2di mouse_pos;
int hovered_code{};
int hovered_pos{};
int hovered_seq{ -1 };
......@@ -74,7 +74,7 @@ public:
code_pointer draging_pointer;
int prev_category{};
int prev_deck{};
s32 prev_operation{};
irr::s32 prev_operation{};
int prev_sel{ -1 };
bool is_modified{};
bool readonly{};
......
#include "deck_manager.h"
#include "game.h"
#include "myfilesystem.h"
#include "network.h"
#include "game.h"
namespace ygo {
......@@ -12,42 +12,39 @@ DeckManager deckManager;
void DeckManager::LoadLFListSingle(const char* path) {
auto cur = _lfList.rend();
FILE* fp = fopen(path, "r");
FILE* fp = std::fopen(path, "r");
char linebuf[256]{};
wchar_t strBuffer[256]{};
if(fp) {
while(fgets(linebuf, 256, fp)) {
while(std::fgets(linebuf, sizeof linebuf, fp)) {
if(linebuf[0] == '#')
continue;
if(linebuf[0] == '!') {
int sa = BufferIO::DecodeUTF8(&linebuf[1], strBuffer);
while(strBuffer[sa - 1] == L'\r' || strBuffer[sa - 1] == L'\n' )
sa--;
strBuffer[sa] = 0;
auto len = std::strcspn(linebuf, "\r\n");
linebuf[len] = 0;
BufferIO::DecodeUTF8(&linebuf[1], strBuffer);
LFList newlist;
newlist.listName = strBuffer;
newlist.hash = 0x7dfcee6a;
_lfList.push_back(newlist);
cur = _lfList.rbegin();
cur->listName = strBuffer;
cur->hash = 0x7dfcee6a;
continue;
}
if(linebuf[0] == 0)
if (cur == _lfList.rend())
continue;
int code = 0;
int count = -1;
if (sscanf(linebuf, "%d %d", &code, &count) != 2)
if (std::sscanf(linebuf, "%9d%*[ ]%9d", &code, &count) != 2)
continue;
if (code <= 0 || code > MAX_CARD_ID)
continue;
if (count < 0 || count > 2)
continue;
if (cur == _lfList.rend())
continue;
unsigned int hcode = code;
cur->content[code] = count;
cur->hash = cur->hash ^ ((hcode << 18) | (hcode >> 14)) ^ ((hcode << (27 + count)) | (hcode >> (5 - count)));
}
fclose(fp);
std::fclose(fp);
}
}
void DeckManager::LoadLFList() {
......@@ -193,25 +190,29 @@ int DeckManager::LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec, bool is_p
return errorcode;
}
int DeckManager::LoadDeck(Deck& deck, std::istringstream& deckStream, bool is_packlist) {
int ct = 0, mainc = 0, sidec = 0, code = 0;
size_t ct = 0;
int mainc = 0, sidec = 0, code = 0;
int cardlist[PACK_MAX_SIZE]{};
bool is_side = false;
std::string linebuf;
while (std::getline(deckStream, linebuf, '\n') && ct < (int)(sizeof cardlist / sizeof cardlist[0])) {
while (std::getline(deckStream, linebuf, '\n') && ct < (sizeof cardlist / sizeof cardlist[0])) {
if (linebuf[0] == '!') {
is_side = true;
continue;
}
if (linebuf[0] < '0' || linebuf[0] > '9')
continue;
code = std::stoi(linebuf);
errno = 0;
code = strtol(linebuf.c_str(), nullptr, 10);
if (errno == ERANGE)
continue;
cardlist[ct++] = code;
if (is_side)
++sidec;
else
++mainc;
}
return LoadDeck(current_deck, cardlist, mainc, sidec, is_packlist);
return LoadDeck(deck, cardlist, mainc, sidec, is_packlist);
}
bool DeckManager::LoadSide(Deck& deck, int* dbuf, int mainc, int sidec) {
std::unordered_map<int, int> pcount;
......@@ -262,12 +263,11 @@ void DeckManager::GetCategoryPath(wchar_t* ret, int index, const wchar_t* text)
}
BufferIO::CopyWStr(catepath, ret, 256);
}
void DeckManager::GetDeckFile(wchar_t* ret, irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck) {
void DeckManager::GetDeckFile(wchar_t* ret, int category_index, const wchar_t* category_name, const wchar_t* deckname) {
wchar_t filepath[256];
wchar_t catepath[256];
const wchar_t* deckname = cbDeck->getItem(cbDeck->getSelected());
if(deckname != nullptr) {
GetCategoryPath(catepath, cbCategory->getSelected(), cbCategory->getText());
GetCategoryPath(catepath, category_index, category_name);
myswprintf(filepath, L"%ls/%ls.ydk", catepath, deckname);
BufferIO::CopyWStr(filepath, ret, 256);
}
......@@ -276,16 +276,16 @@ void DeckManager::GetDeckFile(wchar_t* ret, irr::gui::IGUIComboBox* cbCategory,
}
}
FILE* DeckManager::OpenDeckFile(const wchar_t* file, const char* mode) {
FILE* fp = myfopen(file, mode);
FILE* fp = mywfopen(file, mode);
return fp;
}
IReadFile* DeckManager::OpenDeckReader(const wchar_t* file) {
irr::io::IReadFile* DeckManager::OpenDeckReader(const wchar_t* file) {
#ifdef _WIN32
IReadFile* reader = DataManager::FileSystem->createAndOpenFile(file);
auto reader = DataManager::FileSystem->createAndOpenFile(file);
#else
char file2[256];
BufferIO::EncodeUTF8(file, file2);
IReadFile* reader = DataManager::FileSystem->createAndOpenFile(file2);
auto reader = DataManager::FileSystem->createAndOpenFile(file2);
#endif
return reader;
}
......@@ -314,10 +314,10 @@ bool DeckManager::LoadCurrentDeck(const wchar_t* file, bool is_packlist) {
LoadDeck(current_deck, deckStream, is_packlist);
return true; // the above LoadDeck has return value but we ignore it here for now
}
bool DeckManager::LoadCurrentDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck) {
bool DeckManager::LoadCurrentDeck(int category_index, const wchar_t* category_name, const wchar_t* deckname) {
wchar_t filepath[256];
GetDeckFile(filepath, cbCategory, cbDeck);
bool is_packlist = cbCategory->getSelected() == 0;
GetDeckFile(filepath, category_index, category_name, deckname);
bool is_packlist = (category_index == 0);
bool res = LoadCurrentDeck(filepath, is_packlist);
if (res && mainGame->is_building)
mainGame->deckBuilder.RefreshPackListScroll();
......@@ -329,16 +329,16 @@ bool DeckManager::SaveDeck(Deck& deck, const wchar_t* file) {
FILE* fp = OpenDeckFile(file, "w");
if(!fp)
return false;
fprintf(fp, "#created by ...\n#main\n");
std::fprintf(fp, "#created by ...\n#main\n");
for(size_t i = 0; i < deck.main.size(); ++i)
fprintf(fp, "%d\n", deck.main[i]->first);
fprintf(fp, "#extra\n");
std::fprintf(fp, "%d\n", deck.main[i]->first);
std::fprintf(fp, "#extra\n");
for(size_t i = 0; i < deck.extra.size(); ++i)
fprintf(fp, "%d\n", deck.extra[i]->first);
fprintf(fp, "!side\n");
std::fprintf(fp, "%d\n", deck.extra[i]->first);
std::fprintf(fp, "!side\n");
for(size_t i = 0; i < deck.side.size(); ++i)
fprintf(fp, "%d\n", deck.side[i]->first);
fclose(fp);
std::fprintf(fp, "%d\n", deck.side[i]->first);
std::fclose(fp);
return true;
}
bool DeckManager::DeleteDeck(const wchar_t* file) {
......@@ -388,26 +388,26 @@ bool DeckManager::SaveDeckBuffer(const int deckbuf[], const wchar_t* name) {
int it = 0;
const int mainc = deckbuf[it];
++it;
fprintf(fp, "#created by ...\n#main\n");
std::fprintf(fp, "#created by ...\n#main\n");
for (int i = 0; i < mainc; ++i) {
fprintf(fp, "%d\n", deckbuf[it]);
std::fprintf(fp, "%d\n", deckbuf[it]);
++it;
}
const int extrac = deckbuf[it];
++it;
fprintf(fp, "#extra\n");
std::fprintf(fp, "#extra\n");
for (int i = 0; i < extrac; ++i) {
fprintf(fp, "%d\n", deckbuf[it]);
std::fprintf(fp, "%d\n", deckbuf[it]);
++it;
}
const int sidec = deckbuf[it];
++it;
fprintf(fp, "!side\n");
std::fprintf(fp, "!side\n");
for (int i = 0; i < sidec; ++i) {
fprintf(fp, "%d\n", deckbuf[it]);
std::fprintf(fp, "%d\n", deckbuf[it]);
++it;
}
fclose(fp);
std::fclose(fp);
return true;
}
#endif //YGOPRO_SERVER_MODE
......
#ifndef DECKMANAGER_H
#define DECKMANAGER_H
#include "config.h"
#include "data_manager.h"
#include <unordered_map>
#include <vector>
#include <sstream>
#include "data_manager.h"
#ifndef YGOPRO_MAX_DECK
#define YGOPRO_MAX_DECK 60
......@@ -39,7 +38,7 @@ 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;
......@@ -71,11 +70,11 @@ public:
bool LoadSide(Deck& deck, int* dbuf, int mainc, int sidec);
#ifndef YGOPRO_SERVER_MODE
void GetCategoryPath(wchar_t* ret, int index, const wchar_t* text);
void GetDeckFile(wchar_t* ret, irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck);
void GetDeckFile(wchar_t* ret, int category_index, const wchar_t* category_name, const wchar_t* deckname);
FILE* OpenDeckFile(const wchar_t* file, const char* mode);
IReadFile* OpenDeckReader(const wchar_t* file);
irr::io::IReadFile* OpenDeckReader(const wchar_t* file);
bool LoadCurrentDeck(const wchar_t* file, bool is_packlist = false);
bool LoadCurrentDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck);
bool LoadCurrentDeck(int category_index, const wchar_t* category_name, const wchar_t* deckname);
bool SaveDeck(Deck& deck, const wchar_t* file);
bool DeleteDeck(const wchar_t* file);
bool CreateCategory(const wchar_t* name);
......
......@@ -874,15 +874,15 @@ void Game::DrawSpec() {
float mul = xScale;
if(xScale > yScale)
mul = yScale;
core::position2d<s32> corner[4];
irr::core::vector2d<s32> corner[4];
float y = sin(showcarddif * 3.1415926f / 180.0f) * CARD_IMG_HEIGHT * mul;
s32 winx = midx * xScale + (574 - midx) * mul;
s32 winx2 = midx * xScale + (751 - midx) * mul;
s32 winy = midy * yScale + (404 - midy) * mul;
corner[0] = core::position2d<s32>(winx - (CARD_IMG_HEIGHT * mul - y) * 0.3f, winy - y);
corner[1] = core::position2d<s32>(winx2 + (CARD_IMG_HEIGHT * mul - y) * 0.3f, winy - y);
corner[2] = core::position2d<s32>(winx, winy);
corner[3] = core::position2d<s32>(winx2, winy);
corner[0] = irr::core::vector2d<s32>(winx - (CARD_IMG_HEIGHT * mul - y) * 0.3f, winy - y);
corner[1] = irr::core::vector2d<s32>(winx2 + (CARD_IMG_HEIGHT * mul - y) * 0.3f, winy - y);
corner[2] = irr::core::vector2d<s32>(winx, winy);
corner[3] = irr::core::vector2d<s32>(winx2, winy);
irr::gui::Draw2DImageQuad(driver, imageManager.GetTexture(showcardcode, true), ResizeFit(0, 0, CARD_IMG_WIDTH, CARD_IMG_HEIGHT), corner);
showcardp++;
showcarddif += 9;
......@@ -896,8 +896,8 @@ void Game::DrawSpec() {
}
case 100: {
if(showcardp < 60) {
driver->draw2DImage(imageManager.tHand[(showcardcode >> 16) & 0x3], position2di((615 + 44.5) * xScale - 44.5, (showcarddif + 64) * yScale - 64));
driver->draw2DImage(imageManager.tHand[showcardcode & 0x3], position2di((615 + 44.5) * xScale - 44.5, (540 - showcarddif + 64) * yScale - 64));
driver->draw2DImage(imageManager.tHand[(showcardcode >> 16) & 0x3], irr::core::vector2di((615 + 44.5) * xScale - 44.5, (showcarddif + 64) * yScale - 64));
driver->draw2DImage(imageManager.tHand[showcardcode & 0x3], irr::core::vector2di((615 + 44.5) * xScale - 44.5, (540 - showcarddif + 64) * yScale - 64));
float dy = -0.333333f * showcardp + 10;
showcardp++;
if(showcardp < 30)
......@@ -1020,7 +1020,7 @@ void Game::DrawSpec() {
recti rectloc(x, y - chatRectY - h, x + 2 + w, y - chatRectY);
recti msgloc(x, y - chatRectY - h, x - 4, y - chatRectY);
recti shadowloc = msgloc + position2di(1, 1);
recti shadowloc = msgloc + irr::core::vector2di(1, 1);
driver->draw2DRectangle(rectloc, 0xa0000000, 0xa0000000, 0xa0000000, 0xa0000000);
guiFont->drawUstring(msg, msgloc, 0xff000000, false, false);
......@@ -1041,7 +1041,7 @@ void Game::ShowElement(irr::gui::IGUIElement * win, int autoframe) {
for(auto fit = fadingList.begin(); fit != fadingList.end(); ++fit)
if(win == fit->guiFading && win != wOptions && win != wANNumber) // the size of wOptions is always setted by ClientField::ShowSelectOption before showing it
fu.fadingSize = fit->fadingSize;
irr::core::position2di center = fu.fadingSize.getCenter();
irr::core::vector2di center = fu.fadingSize.getCenter();
fu.fadingDiff.X = fu.fadingSize.getWidth() / 10;
fu.fadingDiff.Y = (fu.fadingSize.getHeight() - 4) / 10;
fu.fadingUL = center;
......@@ -1126,7 +1126,7 @@ void Game::WaitFrameSignal(int frame) {
signalFrame = (gameConf.quick_animation && frame >= 12) ? 12 : frame;
frameSignal.Wait();
}
void Game::DrawThumb(code_pointer cp, position2di pos, const std::unordered_map<int,int>* lflist, bool drag) {
void Game::DrawThumb(code_pointer cp, irr::core::vector2di pos, const std::unordered_map<int,int>* lflist, bool drag) {
int code = cp->first;
int lcode = cp->second.alias;
if(lcode == 0)
......@@ -1217,7 +1217,7 @@ void Game::DrawDeckBd() {
int padding = scrPackCards->getPos() * lx;
for(int i = 0; i < mainsize - padding && i < 7 * lx; ++i) {
int j = i + padding;
DrawThumb(deckManager.current_deck.main[j], position2di(314 + (i % lx) * dx, 164 + (i / lx) * dy), deckBuilder.filterList);
DrawThumb(deckManager.current_deck.main[j], irr::core::vector2di(314 + (i % lx) * dx, 164 + (i / lx) * dy), deckBuilder.filterList);
if(deckBuilder.hovered_pos == 1 && deckBuilder.hovered_seq == j)
driver->draw2DRectangleOutline(Resize(313 + (i % lx) * dx, 163 + (i / lx) * dy, 359 + (i % lx) * dx, 228 + (i / lx) * dy));
}
......@@ -1233,7 +1233,7 @@ void Game::DrawDeckBd() {
dx = 436.0f / 9;
else dx = 436.0f / (deckManager.current_deck.extra.size() - 1);
for(size_t i = 0; i < deckManager.current_deck.extra.size(); ++i) {
DrawThumb(deckManager.current_deck.extra[i], position2di(314 + i * dx, 466), deckBuilder.filterList);
DrawThumb(deckManager.current_deck.extra[i], irr::core::vector2di(314 + i * dx, 466), deckBuilder.filterList);
if(deckBuilder.hovered_pos == 2 && deckBuilder.hovered_seq == (int)i)
driver->draw2DRectangleOutline(Resize(313 + i * dx, 465, 359 + i * dx, 531));
}
......@@ -1248,7 +1248,7 @@ void Game::DrawDeckBd() {
dx = 436.0f / 9;
else dx = 436.0f / (deckManager.current_deck.side.size() - 1);
for(size_t i = 0; i < deckManager.current_deck.side.size(); ++i) {
DrawThumb(deckManager.current_deck.side[i], position2di(314 + i * dx, 564), deckBuilder.filterList);
DrawThumb(deckManager.current_deck.side[i], irr::core::vector2di(314 + i * dx, 564), deckBuilder.filterList);
if(deckBuilder.hovered_pos == 3 && deckBuilder.hovered_seq == (int)i)
driver->draw2DRectangleOutline(Resize(313 + i * dx, 563, 359 + i * dx, 629));
}
......@@ -1275,7 +1275,7 @@ void Game::DrawDeckBd() {
}
if(deckBuilder.hovered_pos == 4 && deckBuilder.hovered_seq == (int)i)
driver->draw2DRectangle(0x80000000, Resize(806, 164 + i * 66, 1019, 230 + i * 66));
DrawThumb(ptr, position2di(810, 165 + i * 66), deckBuilder.filterList);
DrawThumb(ptr, irr::core::vector2di(810, 165 + i * 66), deckBuilder.filterList);
const wchar_t* availBuffer = L"";
if ((ptr->second.ot & AVAIL_OCGTCG) == AVAIL_OCG)
availBuffer = L" [OCG]";
......@@ -1325,7 +1325,7 @@ void Game::DrawDeckBd() {
}
}
if(deckBuilder.is_draging) {
DrawThumb(deckBuilder.draging_pointer, position2di(deckBuilder.dragx - CARD_THUMB_WIDTH / 2 * mainGame->xScale, deckBuilder.dragy - CARD_THUMB_HEIGHT / 2 * mainGame->yScale), deckBuilder.filterList, true);
DrawThumb(deckBuilder.draging_pointer, irr::core::vector2di(deckBuilder.dragx - CARD_THUMB_WIDTH / 2 * mainGame->xScale, deckBuilder.dragy - CARD_THUMB_HEIGHT / 2 * mainGame->yScale), deckBuilder.filterList, true);
}
}
}
......@@ -1073,8 +1073,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(!mainGame->dInfo.isStarted)
break;
hovered_location = 0;
position2di pos = mainGame->ResizeReverse(event.MouseInput.X, event.MouseInput.Y);
position2di mousepos(event.MouseInput.X, event.MouseInput.Y);
irr::core::vector2di pos = mainGame->ResizeReverse(event.MouseInput.X, event.MouseInput.Y);
irr::core::vector2di mousepos(event.MouseInput.X, event.MouseInput.Y);
s32 x = pos.X;
s32 y = pos.Y;
if(x < 300)
......@@ -1496,8 +1496,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(!mainGame->dInfo.isStarted)
break;
bool should_show_tip = false;
position2di pos = mainGame->ResizeReverse(event.MouseInput.X, event.MouseInput.Y);
position2di mousepos = position2di(event.MouseInput.X, event.MouseInput.Y);
irr::core::vector2di pos = mainGame->ResizeReverse(event.MouseInput.X, event.MouseInput.Y);
irr::core::vector2di mousepos = irr::core::vector2di(event.MouseInput.X, event.MouseInput.Y);
s32 x = pos.X;
s32 y = pos.Y;
wchar_t formatBuffer[2048];
......@@ -1554,7 +1554,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(mainGame->stTip->isVisible()) {
should_show_tip = true;
irr::core::recti tpos = mainGame->stTip->getRelativePosition();
mainGame->stTip->setRelativePosition(irr::core::position2di(mousepos.X - tpos.getWidth() - 10, mcard ? mousepos.Y - tpos.getHeight() - 10 : y + 10));
mainGame->stTip->setRelativePosition(irr::core::vector2di(mousepos.X - tpos.getWidth() - 10, mcard ? mousepos.Y - tpos.getHeight() - 10 : y + 10));
}
}
if(mcard != hovered_card) {
......@@ -2078,7 +2078,7 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
void ClientField::GetHoverField(int x, int y) {
irr::core::recti sfRect(430, 504, 875, 600);
irr::core::recti ofRect(531, 135, 800, 191);
irr::core::position2di pos(x, y);
irr::core::vector2di pos(x, y);
int rule = (mainGame->dInfo.duel_rule >= 4) ? 1 : 0;
if(sfRect.isPointInside(pos)) {
int hc = hand[0].size();
......@@ -2315,22 +2315,22 @@ void ClientField::ShowMenu(int flag, int x, int y) {
int offset = mainGame->gameConf.resize_popup_menu ? ((mainGame->yScale >= 0.666) ? 21 * mainGame->yScale : 14) : 21;
if(flag & COMMAND_ACTIVATE) {
mainGame->btnActivate->setVisible(true);
mainGame->btnActivate->setRelativePosition(position2di(1, height));
mainGame->btnActivate->setRelativePosition(irr::core::vector2di(1, height));
height += offset;
} else mainGame->btnActivate->setVisible(false);
if(flag & COMMAND_SUMMON) {
mainGame->btnSummon->setVisible(true);
mainGame->btnSummon->setRelativePosition(position2di(1, height));
mainGame->btnSummon->setRelativePosition(irr::core::vector2di(1, height));
height += offset;
} else mainGame->btnSummon->setVisible(false);
if(flag & COMMAND_SPSUMMON) {
mainGame->btnSPSummon->setVisible(true);
mainGame->btnSPSummon->setRelativePosition(position2di(1, height));
mainGame->btnSPSummon->setRelativePosition(irr::core::vector2di(1, height));
height += offset;
} else mainGame->btnSPSummon->setVisible(false);
if(flag & COMMAND_MSET) {
mainGame->btnMSet->setVisible(true);
mainGame->btnMSet->setRelativePosition(position2di(1, height));
mainGame->btnMSet->setRelativePosition(irr::core::vector2di(1, height));
height += offset;
} else mainGame->btnMSet->setVisible(false);
if(flag & COMMAND_SSET) {
......@@ -2339,7 +2339,7 @@ void ClientField::ShowMenu(int flag, int x, int y) {
else
mainGame->btnSSet->setText(dataManager.GetSysString(1159));
mainGame->btnSSet->setVisible(true);
mainGame->btnSSet->setRelativePosition(position2di(1, height));
mainGame->btnSSet->setRelativePosition(irr::core::vector2di(1, height));
height += offset;
} else mainGame->btnSSet->setVisible(false);
if(flag & COMMAND_REPOS) {
......@@ -2350,27 +2350,27 @@ void ClientField::ShowMenu(int flag, int x, int y) {
else
mainGame->btnRepos->setText(dataManager.GetSysString(1156));
mainGame->btnRepos->setVisible(true);
mainGame->btnRepos->setRelativePosition(position2di(1, height));
mainGame->btnRepos->setRelativePosition(irr::core::vector2di(1, height));
height += offset;
} else mainGame->btnRepos->setVisible(false);
if(flag & COMMAND_ATTACK) {
mainGame->btnAttack->setVisible(true);
mainGame->btnAttack->setRelativePosition(position2di(1, height));
mainGame->btnAttack->setRelativePosition(irr::core::vector2di(1, height));
height += offset;
} else mainGame->btnAttack->setVisible(false);
if(flag & COMMAND_LIST) {
mainGame->btnShowList->setVisible(true);
mainGame->btnShowList->setRelativePosition(position2di(1, height));
mainGame->btnShowList->setRelativePosition(irr::core::vector2di(1, height));
height += offset;
} else mainGame->btnShowList->setVisible(false);
if(flag & COMMAND_OPERATION) {
mainGame->btnOperation->setVisible(true);
mainGame->btnOperation->setRelativePosition(position2di(1, height));
mainGame->btnOperation->setRelativePosition(irr::core::vector2di(1, height));
height += offset;
} else mainGame->btnOperation->setVisible(false);
if(flag & COMMAND_RESET) {
mainGame->btnReset->setVisible(true);
mainGame->btnReset->setRelativePosition(position2di(1, height));
mainGame->btnReset->setRelativePosition(irr::core::vector2di(1, height));
height += offset;
} else mainGame->btnReset->setVisible(false);
panel = mainGame->wCmdMenu;
......
......@@ -76,6 +76,14 @@ bool IsExtension(const wchar_t* filename, const wchar_t* extension) {
return !mywcsncasecmp(filename + (flen - elen), extension, elen);
}
bool IsExtension(const char* filename, const char* extension) {
auto flen = std::strlen(filename);
auto elen = std::strlen(extension);
if (!elen || flen < elen)
return false;
return !mystrncasecmp(filename + (flen - elen), extension, elen);
}
#ifdef YGOPRO_SERVER_MODE
unsigned short server_port;
unsigned short replay_mode;
......@@ -103,7 +111,6 @@ void Game::MainServerLoop() {
}
}
#else //YGOPRO_SERVER_MODE
bool Game::Initialize() {
LoadConfig();
irr::SIrrlichtCreationParameters params = irr::SIrrlichtCreationParameters();
......@@ -134,8 +141,6 @@ bool Game::Initialize() {
ignore_chain = false;
chain_when_avail = false;
is_building = false;
menuHandler.prev_operation = 0;
menuHandler.prev_sel = -1;
deckManager.LoadLFList();
driver = device->getVideoDriver();
driver->setTextureCreationFlag(irr::video::ETCF_CREATE_MIP_MAPS, false);
......@@ -1364,29 +1369,29 @@ void Game::RefreshBot() {
if(!gameConf.enable_bot_mode)
return;
botInfo.clear();
FILE* fp = fopen("bot.conf", "r");
FILE* fp = std::fopen("bot.conf", "r");
char linebuf[256]{};
char strbuf[256]{};
if(fp) {
while(fgets(linebuf, 256, fp)) {
while(std::fgets(linebuf, 256, fp)) {
if(linebuf[0] == '#')
continue;
if(linebuf[0] == '!') {
BotInfo newinfo;
if (sscanf(linebuf, "!%240[^\n]", strbuf) != 1)
if (std::sscanf(linebuf, "!%240[^\n]", strbuf) != 1)
continue;
BufferIO::DecodeUTF8(strbuf, newinfo.name);
if (!fgets(linebuf, 256, fp))
if (!std::fgets(linebuf, 256, fp))
break;
if (sscanf(linebuf, "%240[^\n]", strbuf) != 1)
if (std::sscanf(linebuf, "%240[^\n]", strbuf) != 1)
continue;
BufferIO::DecodeUTF8(strbuf, newinfo.command);
if (!fgets(linebuf, 256, fp))
if (!std::fgets(linebuf, 256, fp))
break;
if (sscanf(linebuf, "%240[^\n]", strbuf) != 1)
if (std::sscanf(linebuf, "%240[^\n]", strbuf) != 1)
continue;
BufferIO::DecodeUTF8(strbuf, newinfo.desc);
if (!fgets(linebuf, 256, fp))
if (!std::fgets(linebuf, 256, fp))
break;
newinfo.support_master_rule_3 = !!std::strstr(linebuf, "SUPPORT_MASTER_RULE_3");
newinfo.support_new_master_rule = !!std::strstr(linebuf, "SUPPORT_NEW_MASTER_RULE");
......@@ -1400,7 +1405,7 @@ void Game::RefreshBot() {
continue;
}
}
fclose(fp);
std::fclose(fp);
}
lstBotList->clear();
stBotInfo->setText(L"");
......@@ -1417,14 +1422,14 @@ void Game::RefreshBot() {
}
}
void Game::LoadConfig() {
FILE* fp = fopen("system.conf", "r");
FILE* fp = std::fopen("system.conf", "r");
if(!fp)
return;
char linebuf[CONFIG_LINE_SIZE]{};
char strbuf[64]{};
char valbuf[960]{};
while(fgets(linebuf, sizeof linebuf, fp)) {
if (sscanf(linebuf, "%63s = %959s", strbuf, valbuf) != 2)
while(std::fgets(linebuf, sizeof linebuf, fp)) {
if (std::sscanf(linebuf, "%63s = %959s", strbuf, valbuf) != 2)
continue;
if(!std::strcmp(strbuf, "antialias")) {
gameConf.antialias = strtol(valbuf, nullptr, 10);
......@@ -1437,7 +1442,7 @@ void Game::LoadConfig() {
enable_log = val & 0xff;
} else if(!std::strcmp(strbuf, "textfont")) {
int textfontsize = 0;
if (sscanf(linebuf, "%63s = %959s %d", strbuf, valbuf, &textfontsize) != 3)
if (std::sscanf(linebuf, "%63s = %959s %d", strbuf, valbuf, &textfontsize) != 3)
continue;
gameConf.textfontsize = textfontsize;
BufferIO::DecodeUTF8(valbuf, gameConf.textfont);
......@@ -1535,7 +1540,7 @@ void Game::LoadConfig() {
#endif
} else {
// options allowing multiple words
if (sscanf(linebuf, "%63s = %959[^\n]", strbuf, valbuf) != 2)
if (std::sscanf(linebuf, "%63s = %959[^\n]", strbuf, valbuf) != 2)
continue;
if (!std::strcmp(strbuf, "nickname")) {
BufferIO::DecodeUTF8(valbuf, gameConf.nickname);
......@@ -1552,81 +1557,81 @@ void Game::LoadConfig() {
}
}
}
fclose(fp);
std::fclose(fp);
}
void Game::SaveConfig() {
FILE* fp = fopen("system.conf", "w");
fprintf(fp, "#config file\n#nickname & gamename should be less than 20 characters\n");
FILE* fp = std::fopen("system.conf", "w");
std::fprintf(fp, "#config file\n#nickname & gamename should be less than 20 characters\n");
char linebuf[CONFIG_LINE_SIZE];
fprintf(fp, "use_d3d = %d\n", gameConf.use_d3d ? 1 : 0);
fprintf(fp, "use_image_scale = %d\n", gameConf.use_image_scale ? 1 : 0);
fprintf(fp, "antialias = %d\n", gameConf.antialias);
fprintf(fp, "errorlog = %u\n", enable_log);
std::fprintf(fp, "use_d3d = %d\n", gameConf.use_d3d ? 1 : 0);
std::fprintf(fp, "use_image_scale = %d\n", gameConf.use_image_scale ? 1 : 0);
std::fprintf(fp, "antialias = %d\n", gameConf.antialias);
std::fprintf(fp, "errorlog = %u\n", enable_log);
BufferIO::CopyWideString(ebNickName->getText(), gameConf.nickname);
BufferIO::EncodeUTF8(gameConf.nickname, linebuf);
fprintf(fp, "nickname = %s\n", linebuf);
std::fprintf(fp, "nickname = %s\n", linebuf);
BufferIO::EncodeUTF8(gameConf.gamename, linebuf);
fprintf(fp, "gamename = %s\n", linebuf);
std::fprintf(fp, "gamename = %s\n", linebuf);
BufferIO::EncodeUTF8(gameConf.lastcategory, linebuf);
fprintf(fp, "lastcategory = %s\n", linebuf);
std::fprintf(fp, "lastcategory = %s\n", linebuf);
BufferIO::EncodeUTF8(gameConf.lastdeck, linebuf);
fprintf(fp, "lastdeck = %s\n", linebuf);
std::fprintf(fp, "lastdeck = %s\n", linebuf);
BufferIO::EncodeUTF8(gameConf.textfont, linebuf);
fprintf(fp, "textfont = %s %d\n", linebuf, gameConf.textfontsize);
std::fprintf(fp, "textfont = %s %d\n", linebuf, gameConf.textfontsize);
BufferIO::EncodeUTF8(gameConf.numfont, linebuf);
fprintf(fp, "numfont = %s\n", linebuf);
fprintf(fp, "serverport = %d\n", gameConf.serverport);
std::fprintf(fp, "numfont = %s\n", linebuf);
std::fprintf(fp, "serverport = %d\n", gameConf.serverport);
BufferIO::EncodeUTF8(gameConf.lasthost, linebuf);
fprintf(fp, "lasthost = %s\n", linebuf);
std::fprintf(fp, "lasthost = %s\n", linebuf);
BufferIO::EncodeUTF8(gameConf.lastport, linebuf);
fprintf(fp, "lastport = %s\n", linebuf);
std::fprintf(fp, "lastport = %s\n", linebuf);
//settings
fprintf(fp, "automonsterpos = %d\n", (chkMAutoPos->isChecked() ? 1 : 0));
fprintf(fp, "autospellpos = %d\n", (chkSTAutoPos->isChecked() ? 1 : 0));
fprintf(fp, "randompos = %d\n", (chkRandomPos->isChecked() ? 1 : 0));
fprintf(fp, "autochain = %d\n", (chkAutoChain->isChecked() ? 1 : 0));
fprintf(fp, "waitchain = %d\n", (chkWaitChain->isChecked() ? 1 : 0));
fprintf(fp, "showchain = %d\n", (chkDefaultShowChain->isChecked() ? 1 : 0));
fprintf(fp, "mute_opponent = %d\n", (chkIgnore1->isChecked() ? 1 : 0));
fprintf(fp, "mute_spectators = %d\n", (chkIgnore2->isChecked() ? 1 : 0));
fprintf(fp, "use_lflist = %d\n", gameConf.use_lflist);
fprintf(fp, "default_lflist = %d\n", gameConf.default_lflist);
fprintf(fp, "default_rule = %d\n", gameConf.default_rule == DEFAULT_DUEL_RULE ? 0 : gameConf.default_rule);
fprintf(fp, "hide_setname = %d\n", gameConf.hide_setname);
fprintf(fp, "hide_hint_button = %d\n", gameConf.hide_hint_button);
fprintf(fp, "#control_mode = 0: Key A/S/D/R Chain Buttons. control_mode = 1: MouseLeft/MouseRight/NULL/F9 Without Chain Buttons\n");
fprintf(fp, "control_mode = %d\n", gameConf.control_mode);
fprintf(fp, "draw_field_spell = %d\n", gameConf.draw_field_spell);
fprintf(fp, "separate_clear_button = %d\n", gameConf.separate_clear_button);
fprintf(fp, "#auto_search_limit >= 0: Start search automatically when the user enters N chars\n");
fprintf(fp, "auto_search_limit = %d\n", gameConf.auto_search_limit);
fprintf(fp, "#search_multiple_keywords = 0: Disable. 1: Search mutiple keywords with separator \" \". 2: with separator \"+\"\n");
fprintf(fp, "search_multiple_keywords = %d\n", gameConf.search_multiple_keywords);
fprintf(fp, "ignore_deck_changes = %d\n", (chkIgnoreDeckChanges->isChecked() ? 1 : 0));
fprintf(fp, "default_ot = %d\n", gameConf.defaultOT);
fprintf(fp, "enable_bot_mode = %d\n", gameConf.enable_bot_mode);
std::fprintf(fp, "automonsterpos = %d\n", (chkMAutoPos->isChecked() ? 1 : 0));
std::fprintf(fp, "autospellpos = %d\n", (chkSTAutoPos->isChecked() ? 1 : 0));
std::fprintf(fp, "randompos = %d\n", (chkRandomPos->isChecked() ? 1 : 0));
std::fprintf(fp, "autochain = %d\n", (chkAutoChain->isChecked() ? 1 : 0));
std::fprintf(fp, "waitchain = %d\n", (chkWaitChain->isChecked() ? 1 : 0));
std::fprintf(fp, "showchain = %d\n", (chkDefaultShowChain->isChecked() ? 1 : 0));
std::fprintf(fp, "mute_opponent = %d\n", (chkIgnore1->isChecked() ? 1 : 0));
std::fprintf(fp, "mute_spectators = %d\n", (chkIgnore2->isChecked() ? 1 : 0));
std::fprintf(fp, "use_lflist = %d\n", gameConf.use_lflist);
std::fprintf(fp, "default_lflist = %d\n", gameConf.default_lflist);
std::fprintf(fp, "default_rule = %d\n", gameConf.default_rule == DEFAULT_DUEL_RULE ? 0 : gameConf.default_rule);
std::fprintf(fp, "hide_setname = %d\n", gameConf.hide_setname);
std::fprintf(fp, "hide_hint_button = %d\n", gameConf.hide_hint_button);
std::fprintf(fp, "#control_mode = 0: Key A/S/D/R Chain Buttons. control_mode = 1: MouseLeft/MouseRight/NULL/F9 Without Chain Buttons\n");
std::fprintf(fp, "control_mode = %d\n", gameConf.control_mode);
std::fprintf(fp, "draw_field_spell = %d\n", gameConf.draw_field_spell);
std::fprintf(fp, "separate_clear_button = %d\n", gameConf.separate_clear_button);
std::fprintf(fp, "#auto_search_limit >= 0: Start search automatically when the user enters N chars\n");
std::fprintf(fp, "auto_search_limit = %d\n", gameConf.auto_search_limit);
std::fprintf(fp, "#search_multiple_keywords = 0: Disable. 1: Search mutiple keywords with separator \" \". 2: with separator \"+\"\n");
std::fprintf(fp, "search_multiple_keywords = %d\n", gameConf.search_multiple_keywords);
std::fprintf(fp, "ignore_deck_changes = %d\n", (chkIgnoreDeckChanges->isChecked() ? 1 : 0));
std::fprintf(fp, "default_ot = %d\n", gameConf.defaultOT);
std::fprintf(fp, "enable_bot_mode = %d\n", gameConf.enable_bot_mode);
BufferIO::EncodeUTF8(gameConf.bot_deck_path, linebuf);
fprintf(fp, "bot_deck_path = %s\n", linebuf);
fprintf(fp, "quick_animation = %d\n", gameConf.quick_animation);
fprintf(fp, "auto_save_replay = %d\n", (chkAutoSaveReplay->isChecked() ? 1 : 0));
fprintf(fp, "draw_single_chain = %d\n", gameConf.draw_single_chain);
fprintf(fp, "hide_player_name = %d\n", gameConf.hide_player_name);
fprintf(fp, "prefer_expansion_script = %d\n", gameConf.prefer_expansion_script);
fprintf(fp, "window_maximized = %d\n", (gameConf.window_maximized ? 1 : 0));
fprintf(fp, "window_width = %d\n", gameConf.window_width);
fprintf(fp, "window_height = %d\n", gameConf.window_height);
fprintf(fp, "resize_popup_menu = %d\n", gameConf.resize_popup_menu ? 1 : 0);
std::fprintf(fp, "bot_deck_path = %s\n", linebuf);
std::fprintf(fp, "quick_animation = %d\n", gameConf.quick_animation);
std::fprintf(fp, "auto_save_replay = %d\n", (chkAutoSaveReplay->isChecked() ? 1 : 0));
std::fprintf(fp, "draw_single_chain = %d\n", gameConf.draw_single_chain);
std::fprintf(fp, "hide_player_name = %d\n", gameConf.hide_player_name);
std::fprintf(fp, "prefer_expansion_script = %d\n", gameConf.prefer_expansion_script);
std::fprintf(fp, "window_maximized = %d\n", (gameConf.window_maximized ? 1 : 0));
std::fprintf(fp, "window_width = %d\n", gameConf.window_width);
std::fprintf(fp, "window_height = %d\n", gameConf.window_height);
std::fprintf(fp, "resize_popup_menu = %d\n", gameConf.resize_popup_menu ? 1 : 0);
#ifdef YGOPRO_USE_IRRKLANG
fprintf(fp, "enable_sound = %d\n", (chkEnableSound->isChecked() ? 1 : 0));
fprintf(fp, "enable_music = %d\n", (chkEnableMusic->isChecked() ? 1 : 0));
fprintf(fp, "#Volume of sound and music, between 0 and 100\n");
std::fprintf(fp, "enable_sound = %d\n", (chkEnableSound->isChecked() ? 1 : 0));
std::fprintf(fp, "enable_music = %d\n", (chkEnableMusic->isChecked() ? 1 : 0));
std::fprintf(fp, "#Volume of sound and music, between 0 and 100\n");
int vol = gameConf.sound_volume * 100;
fprintf(fp, "sound_volume = %d\n", vol);
std::fprintf(fp, "sound_volume = %d\n", vol);
vol = gameConf.music_volume * 100;
fprintf(fp, "music_volume = %d\n", vol);
fprintf(fp, "music_mode = %d\n", (chkMusicMode->isChecked() ? 1 : 0));
std::fprintf(fp, "music_volume = %d\n", vol);
std::fprintf(fp, "music_mode = %d\n", (chkMusicMode->isChecked() ? 1 : 0));
#endif
fclose(fp);
std::fclose(fp);
}
void Game::ShowCardInfo(int code, bool resize) {
if(showingcode == code && !resize)
......@@ -1807,21 +1812,21 @@ void Game::AddDebugMsg(const char* msg) {
}
if (enable_log & 0x2) {
char msgbuf[1040];
snprintf(msgbuf, sizeof msgbuf, "[Script Error]: %s", msg);
std::snprintf(msgbuf, sizeof msgbuf, "[Script Error]: %s", msg);
ErrorLog(msgbuf);
}
#endif //YGOPRO_SERVER_MODE
}
#ifndef YGOPRO_SERVER_MODE
void Game::ErrorLog(const char* msg) {
FILE* fp = fopen("error.log", "at");
FILE* fp = std::fopen("error.log", "a");
if(!fp)
return;
time_t nowtime = std::time(nullptr);
char timebuf[40];
std::strftime(timebuf, sizeof timebuf, "%Y-%m-%d %H:%M:%S", std::localtime(&nowtime));
fprintf(fp, "[%s]%s\n", timebuf, msg);
fclose(fp);
std::fprintf(fp, "[%s]%s\n", timebuf, msg);
std::fclose(fp);
}
void Game::ClearTextures() {
matManager.mCard.setTexture(0, 0);
......@@ -2144,15 +2149,15 @@ recti Game::Resize(s32 x, s32 y, s32 x2, s32 y2, s32 dx, s32 dy, s32 dx2, s32 dy
y2 = y2 * yScale + dy2;
return recti(x, y, x2, y2);
}
position2di Game::Resize(s32 x, s32 y) {
irr::core::vector2di Game::Resize(s32 x, s32 y) {
x = x * xScale;
y = y * yScale;
return position2di(x, y);
return irr::core::vector2di(x, y);
}
position2di Game::ResizeReverse(s32 x, s32 y) {
irr::core::vector2di Game::ResizeReverse(s32 x, s32 y) {
x = x / xScale;
y = y / yScale;
return position2di(x, y);
return irr::core::vector2di(x, y);
}
recti Game::ResizeWin(s32 x, s32 y, s32 x2, s32 y2) {
s32 w = x2 - x;
......@@ -2183,7 +2188,7 @@ recti Game::ResizeCardImgWin(s32 x, s32 y, s32 mx, s32 my) {
recti Game::ResizeCardHint(s32 x, s32 y, s32 x2, s32 y2) {
return ResizeCardMid(x, y, x2, y2, (x + x2) * 0.5, (y + y2) * 0.5);
}
position2di Game::ResizeCardHint(s32 x, s32 y) {
irr::core::vector2di Game::ResizeCardHint(s32 x, s32 y) {
return ResizeCardMid(x, y, x + CARD_IMG_WIDTH * 0.5, y + CARD_IMG_HEIGHT * 0.5);
}
recti Game::ResizeCardMid(s32 x, s32 y, s32 x2, s32 y2, s32 midx, s32 midy) {
......@@ -2198,7 +2203,7 @@ recti Game::ResizeCardMid(s32 x, s32 y, s32 x2, s32 y2, s32 midx, s32 midy) {
y2 = cy + (y2 - midy) * mul;
return recti(x, y, x2, y2);
}
position2di Game::ResizeCardMid(s32 x, s32 y, s32 midx, s32 midy) {
irr::core::vector2di Game::ResizeCardMid(s32 x, s32 y, s32 midx, s32 midy) {
float mul = xScale;
if(xScale > yScale)
mul = yScale;
......@@ -2206,7 +2211,7 @@ position2di Game::ResizeCardMid(s32 x, s32 y, s32 midx, s32 midy) {
s32 cy = midy * yScale;
x = cx + (x - midx) * mul;
y = cy + (y - midy) * mul;
return position2di(x, y);
return irr::core::vector2di(x, y);
}
recti Game::ResizeFit(s32 x, s32 y, s32 x2, s32 y2) {
float mul = xScale;
......
......@@ -37,6 +37,7 @@ constexpr int TEXT_LINE_SIZE = 256;
namespace ygo {
bool IsExtension(const wchar_t* filename, const wchar_t* extension);
bool IsExtension(const char* filename, const char* extension);
#ifndef YGOPRO_SERVER_MODE
struct Config {
......@@ -184,7 +185,7 @@ public:
void HideElement(irr::gui::IGUIElement* element, bool set_action = false);
void PopupElement(irr::gui::IGUIElement* element, int hideframe = 0);
void WaitFrameSignal(int frame);
void DrawThumb(code_pointer cp, position2di pos, const std::unordered_map<int,int>* lflist, bool drag = false);
void DrawThumb(code_pointer cp, irr::core::vector2di pos, const std::unordered_map<int,int>* lflist, bool drag = false);
void DrawDeckBd();
void LoadConfig();
void SaveConfig();
......@@ -220,15 +221,15 @@ public:
void ResizeChatInputWindow();
recti Resize(s32 x, s32 y, s32 x2, s32 y2);
recti Resize(s32 x, s32 y, s32 x2, s32 y2, s32 dx, s32 dy, s32 dx2, s32 dy2);
position2di Resize(s32 x, s32 y);
position2di ResizeReverse(s32 x, s32 y);
irr::core::vector2di Resize(s32 x, s32 y);
irr::core::vector2di ResizeReverse(s32 x, s32 y);
recti ResizePhaseHint(s32 x, s32 y, s32 x2, s32 y2, s32 width);
recti ResizeWin(s32 x, s32 y, s32 x2, s32 y2);
recti ResizeCardImgWin(s32 x, s32 y, s32 mx, s32 my);
recti ResizeCardHint(s32 x, s32 y, s32 x2, s32 y2);
position2di ResizeCardHint(s32 x, s32 y);
irr::core::vector2di ResizeCardHint(s32 x, s32 y);
recti ResizeCardMid(s32 x, s32 y, s32 x2, s32 y2, s32 midx, s32 midy);
position2di ResizeCardMid(s32 x, s32 y, s32 midx, s32 midy);
irr::core::vector2di ResizeCardMid(s32 x, s32 y, s32 midx, s32 midy);
recti ResizeFit(s32 x, s32 y, s32 x2, s32 y2);
void SetWindowsIcon();
......
......@@ -38,17 +38,15 @@ int main(int argc, char* argv[]) {
CFRelease(path);
#endif //__APPLE__
#ifdef _WIN32
#ifndef _DEBUG
char* pstrext;
if(argc == 2 && (pstrext = std::strrchr(argv[1], '.'))
&& (!mystrncasecmp(pstrext, ".ydk", 4) || !mystrncasecmp(pstrext, ".yrp", 4))) {
if (argc == 2 && (ygo::IsExtension(argv[1], ".ydk") || ygo::IsExtension(argv[1], ".yrp"))) { // open file from explorer
wchar_t exepath[MAX_PATH];
GetModuleFileNameW(nullptr, exepath, MAX_PATH);
wchar_t* p = std::wcsrchr(exepath, '\\');
*p = '\0';
SetCurrentDirectoryW(exepath);
wchar_t* p = std::wcsrchr(exepath, L'\\');
if (p) {
*p = 0;
SetCurrentDirectoryW(exepath);
}
}
#endif //_DEBUG
#endif //_WIN32
#ifdef _WIN32
WORD wVersionRequested;
......
......@@ -234,10 +234,10 @@ irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) {
auto tit = tMap[fit ? 1 : 0].find(code);
if(tit == tMap[fit ? 1 : 0].end()) {
char file[256];
snprintf(file, sizeof file, "expansions/pics/%d.jpg", code);
std::snprintf(file, sizeof file, "expansions/pics/%d.jpg", code);
irr::video::ITexture* img = GetTextureFromFile(file, width, height);
if(img == nullptr) {
snprintf(file, sizeof file, "pics/%d.jpg", code);
std::snprintf(file, sizeof file, "pics/%d.jpg", code);
img = GetTextureFromFile(file, width, height);
}
if(img == nullptr && !mainGame->gameConf.use_image_scale) {
......@@ -261,10 +261,10 @@ irr::video::ITexture* ImageManager::GetBigPicture(int code, float zoom) {
}
irr::video::ITexture* texture;
char file[256];
snprintf(file, sizeof file, "expansions/pics/%d.jpg", code);
std::snprintf(file, sizeof file, "expansions/pics/%d.jpg", code);
irr::video::IImage* srcimg = driver->createImageFromFile(file);
if(srcimg == nullptr) {
snprintf(file, sizeof file, "pics/%d.jpg", code);
std::snprintf(file, sizeof file, "pics/%d.jpg", code);
srcimg = driver->createImageFromFile(file);
}
if(srcimg == nullptr) {
......@@ -290,18 +290,18 @@ int ImageManager::LoadThumbThread() {
imageManager.tThumbLoadingCodes.pop();
imageManager.tThumbLoadingMutex.unlock();
char file[256];
snprintf(file, sizeof file, "expansions/pics/thumbnail/%d.jpg", code);
std::snprintf(file, sizeof file, "expansions/pics/thumbnail/%d.jpg", code);
irr::video::IImage* img = imageManager.driver->createImageFromFile(file);
if(img == nullptr) {
snprintf(file, sizeof file, "pics/thumbnail/%d.jpg", code);
std::snprintf(file, sizeof file, "pics/thumbnail/%d.jpg", code);
img = imageManager.driver->createImageFromFile(file);
}
if(img == nullptr && mainGame->gameConf.use_image_scale) {
snprintf(file, sizeof file, "expansions/pics/%d.jpg", code);
std::snprintf(file, sizeof file, "expansions/pics/%d.jpg", code);
img = imageManager.driver->createImageFromFile(file);
}
if(img == nullptr && mainGame->gameConf.use_image_scale) {
snprintf(file, sizeof file, "pics/%d.jpg", code);
std::snprintf(file, sizeof file, "pics/%d.jpg", code);
img = imageManager.driver->createImageFromFile(file);
}
if(img != nullptr) {
......@@ -346,7 +346,7 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
if(lit != tThumbLoading.end()) {
if(lit->second != nullptr) {
char file[256];
snprintf(file, sizeof file, "pics/thumbnail/%d.jpg", code);
std::snprintf(file, sizeof file, "pics/thumbnail/%d.jpg", code);
irr::video::ITexture* texture = driver->addTexture(file, lit->second); // textures must be added in the main thread due to OpenGL
lit->second->drop();
tThumb[code] = texture;
......@@ -379,18 +379,18 @@ irr::video::ITexture* ImageManager::GetTextureField(int code) {
auto tit = tFields.find(code);
if(tit == tFields.end()) {
char file[256];
snprintf(file, sizeof file, "expansions/pics/field/%d.png", code);
std::snprintf(file, sizeof file, "expansions/pics/field/%d.png", code);
irr::video::ITexture* img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale);
if(img == nullptr) {
snprintf(file, sizeof file, "expansions/pics/field/%d.jpg", code);
std::snprintf(file, sizeof file, "expansions/pics/field/%d.jpg", code);
img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale);
}
if(img == nullptr) {
snprintf(file, sizeof file, "pics/field/%d.png", code);
std::snprintf(file, sizeof file, "pics/field/%d.png", code);
img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale);
}
if(img == nullptr) {
snprintf(file, sizeof file, "pics/field/%d.jpg", code);
std::snprintf(file, sizeof file, "pics/field/%d.jpg", code);
img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale);
if(img == nullptr) {
tFields[code] = nullptr;
......
......@@ -4,11 +4,11 @@ namespace ygo {
Materials matManager;
inline void SetS3DVertex(S3DVertex* v, f32 x1, f32 y1, f32 x2, f32 y2, f32 z, f32 nz, f32 tu1, f32 tv1, f32 tu2, f32 tv2) {
v[0] = S3DVertex(x1, y1, z, 0, 0, nz, SColor(255, 255, 255, 255), tu1, tv1);
v[1] = S3DVertex(x2, y1, z, 0, 0, nz, SColor(255, 255, 255, 255), tu2, tv1);
v[2] = S3DVertex(x1, y2, z, 0, 0, nz, SColor(255, 255, 255, 255), tu1, tv2);
v[3] = S3DVertex(x2, y2, z, 0, 0, nz, SColor(255, 255, 255, 255), tu2, tv2);
inline void SetS3DVertex(irr::video::S3DVertex* v, irr::f32 x1, irr::f32 y1, irr::f32 x2, irr::f32 y2, irr::f32 z, irr::f32 nz, irr::f32 tu1, irr::f32 tv1, irr::f32 tu2, irr::f32 tv2) {
v[0] = irr::video::S3DVertex(x1, y1, z, 0, 0, nz, irr::video::SColor(255, 255, 255, 255), tu1, tv1);
v[1] = irr::video::S3DVertex(x2, y1, z, 0, 0, nz, irr::video::SColor(255, 255, 255, 255), tu2, tv1);
v[2] = irr::video::S3DVertex(x1, y2, z, 0, 0, nz, irr::video::SColor(255, 255, 255, 255), tu1, tv2);
v[3] = irr::video::S3DVertex(x2, y2, z, 0, 0, nz, irr::video::SColor(255, 255, 255, 255), tu2, tv2);
}
Materials::Materials() {
......@@ -28,12 +28,12 @@ Materials::Materials() {
/*
//background grids
for (int i = 0; i < 6; ++i) {
vBackLine[i * 6 + 0] = S3DVertex(vector3df(1.2f + i * 1.1f, 0.5f, -0.01f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[i * 6 + 1] = S3DVertex(vector3df(1.2f + i * 1.1f, -0.5f, -0.01f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[i * 6 + 2] = S3DVertex(vector3df(1.2f + i * 1.1f, 1.7f, -0.01f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[i * 6 + 3] = S3DVertex(vector3df(1.2f + i * 1.1f, -1.7f, -0.01f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[i * 6 + 4] = S3DVertex(vector3df(1.2f + i * 1.1f, 2.9f, -0.01f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[i * 6 + 5] = S3DVertex(vector3df(1.2f + i * 1.1f, -2.9f, -0.01f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[i * 6 + 0] = irr::video::S3DVertex(irr::core::vector3df(1.2f + i * 1.1f, 0.5f, -0.01f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[i * 6 + 1] = irr::video::S3DVertex(irr::core::vector3df(1.2f + i * 1.1f, -0.5f, -0.01f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[i * 6 + 2] = irr::video::S3DVertex(irr::core::vector3df(1.2f + i * 1.1f, 1.7f, -0.01f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[i * 6 + 3] = irr::video::S3DVertex(irr::core::vector3df(1.2f + i * 1.1f, -1.7f, -0.01f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[i * 6 + 4] = irr::video::S3DVertex(irr::core::vector3df(1.2f + i * 1.1f, 2.9f, -0.01f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[i * 6 + 5] = irr::video::S3DVertex(irr::core::vector3df(1.2f + i * 1.1f, -2.9f, -0.01f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
}
for(int i = 0; i < 6; ++i) {
iBackLine[i * 4 + 0] = i * 6 + 0;
......@@ -44,10 +44,10 @@ Materials::Materials() {
iBackLine[i * 2 + 25] = 30 + i;
}
//extra0
vBackLine[36] = S3DVertex(vector3df(0.2f, 2.4f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[37] = S3DVertex(vector3df(1.0f, 2.4f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[38] = S3DVertex(vector3df(0.2f, 3.6f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[39] = S3DVertex(vector3df(1.0f, 3.6f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[36] = irr::video::S3DVertex(irr::core::vector3df(0.2f, 2.4f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[37] = irr::video::S3DVertex(irr::core::vector3df(1.0f, 2.4f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[38] = irr::video::S3DVertex(irr::core::vector3df(0.2f, 3.6f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[39] = irr::video::S3DVertex(irr::core::vector3df(1.0f, 3.6f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
iBackLine[36] = 36;
iBackLine[37] = 37;
iBackLine[38] = 36;
......@@ -57,10 +57,10 @@ Materials::Materials() {
iBackLine[42] = 38;
iBackLine[43] = 39;
//field0
vBackLine[40] = S3DVertex(vector3df(0.2f, 1.1f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[41] = S3DVertex(vector3df(1.0f, 1.1f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[42] = S3DVertex(vector3df(0.2f, 2.3f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[43] = S3DVertex(vector3df(1.0f, 2.3f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[40] = irr::video::S3DVertex(irr::core::vector3df(0.2f, 1.1f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[41] = irr::video::S3DVertex(irr::core::vector3df(1.0f, 1.1f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[42] = irr::video::S3DVertex(irr::core::vector3df(0.2f, 2.3f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[43] = irr::video::S3DVertex(irr::core::vector3df(1.0f, 2.3f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
iBackLine[44] = 40;
iBackLine[45] = 41;
iBackLine[46] = 40;
......@@ -70,10 +70,10 @@ Materials::Materials() {
iBackLine[50] = 42;
iBackLine[51] = 43;
//deck0
vBackLine[44] = S3DVertex(vector3df(6.9f, 2.4f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[45] = S3DVertex(vector3df(7.7f, 2.4f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[46] = S3DVertex(vector3df(6.9f, 3.6f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[47] = S3DVertex(vector3df(7.7f, 3.6f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[44] = irr::video::S3DVertex(irr::core::vector3df(6.9f, 2.4f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[45] = irr::video::S3DVertex(irr::core::vector3df(7.7f, 2.4f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[46] = irr::video::S3DVertex(irr::core::vector3df(6.9f, 3.6f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[47] = irr::video::S3DVertex(irr::core::vector3df(7.7f, 3.6f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
iBackLine[52] = 44;
iBackLine[53] = 45;
iBackLine[54] = 44;
......@@ -83,10 +83,10 @@ Materials::Materials() {
iBackLine[58] = 46;
iBackLine[59] = 47;
//grave0
vBackLine[48] = S3DVertex(vector3df(6.9f, 1.1f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[49] = S3DVertex(vector3df(7.7f, 1.1f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[50] = S3DVertex(vector3df(6.9f, 2.3f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[51] = S3DVertex(vector3df(7.7f, 2.3f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[48] = irr::video::S3DVertex(irr::core::vector3df(6.9f, 1.1f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[49] = irr::video::S3DVertex(irr::core::vector3df(7.7f, 1.1f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[50] = irr::video::S3DVertex(irr::core::vector3df(6.9f, 2.3f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[51] = irr::video::S3DVertex(irr::core::vector3df(7.7f, 2.3f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
iBackLine[60] = 48;
iBackLine[61] = 49;
iBackLine[62] = 48;
......@@ -96,10 +96,10 @@ Materials::Materials() {
iBackLine[66] = 50;
iBackLine[67] = 51;
//remove0
vBackLine[52] = S3DVertex(vector3df(6.9f, -0.2f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[53] = S3DVertex(vector3df(7.7f, -0.2f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[54] = S3DVertex(vector3df(6.9f, 1.0f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[55] = S3DVertex(vector3df(7.7f, 1.0f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[52] = irr::video::S3DVertex(irr::core::vector3df(6.9f, -0.2f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[53] = irr::video::S3DVertex(irr::core::vector3df(7.7f, -0.2f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[54] = irr::video::S3DVertex(irr::core::vector3df(6.9f, 1.0f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[55] = irr::video::S3DVertex(irr::core::vector3df(7.7f, 1.0f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
iBackLine[68] = 52;
iBackLine[69] = 53;
iBackLine[70] = 52;
......@@ -109,10 +109,10 @@ Materials::Materials() {
iBackLine[74] = 54;
iBackLine[75] = 55;
//extra1
vBackLine[56] = S3DVertex(vector3df(6.9f, -2.4f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[57] = S3DVertex(vector3df(7.7f, -2.4f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[58] = S3DVertex(vector3df(6.9f, -3.6f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[59] = S3DVertex(vector3df(7.7f, -3.6f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[56] = irr::video::S3DVertex(irr::core::vector3df(6.9f, -2.4f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[57] = irr::video::S3DVertex(irr::core::vector3df(7.7f, -2.4f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[58] = irr::video::S3DVertex(irr::core::vector3df(6.9f, -3.6f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[59] = irr::video::S3DVertex(irr::core::vector3df(7.7f, -3.6f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
iBackLine[76] = 56;
iBackLine[77] = 57;
iBackLine[78] = 56;
......@@ -122,10 +122,10 @@ Materials::Materials() {
iBackLine[82] = 58;
iBackLine[83] = 59;
//field1
vBackLine[60] = S3DVertex(vector3df(6.9f, -1.1f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[61] = S3DVertex(vector3df(7.7f, -1.1f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[62] = S3DVertex(vector3df(6.9f, -2.3f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[63] = S3DVertex(vector3df(7.7f, -2.3f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[60] = irr::video::S3DVertex(irr::core::vector3df(6.9f, -1.1f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[61] = irr::video::S3DVertex(irr::core::vector3df(7.7f, -1.1f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[62] = irr::video::S3DVertex(irr::core::vector3df(6.9f, -2.3f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[63] = irr::video::S3DVertex(irr::core::vector3df(7.7f, -2.3f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
iBackLine[84] = 60;
iBackLine[85] = 61;
iBackLine[86] = 60;
......@@ -135,10 +135,10 @@ Materials::Materials() {
iBackLine[90] = 62;
iBackLine[91] = 63;
//deck1
vBackLine[64] = S3DVertex(vector3df(0.2f, -2.4f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[65] = S3DVertex(vector3df(1.0f, -2.4f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[66] = S3DVertex(vector3df(0.2f, -3.6f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[67] = S3DVertex(vector3df(1.0f, -3.6f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[64] = irr::video::S3DVertex(irr::core::vector3df(0.2f, -2.4f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[65] = irr::video::S3DVertex(irr::core::vector3df(1.0f, -2.4f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[66] = irr::video::S3DVertex(irr::core::vector3df(0.2f, -3.6f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[67] = irr::video::S3DVertex(irr::core::vector3df(1.0f, -3.6f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
iBackLine[92] = 64;
iBackLine[93] = 65;
iBackLine[94] = 64;
......@@ -148,10 +148,10 @@ Materials::Materials() {
iBackLine[98] = 66;
iBackLine[99] = 67;
//grave1
vBackLine[68] = S3DVertex(vector3df(0.2f, -1.1f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[69] = S3DVertex(vector3df(1.0f, -1.1f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[70] = S3DVertex(vector3df(0.2f, -2.3f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[71] = S3DVertex(vector3df(1.0f, -2.3f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[68] = irr::video::S3DVertex(irr::core::vector3df(0.2f, -1.1f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[69] = irr::video::S3DVertex(irr::core::vector3df(1.0f, -1.1f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[70] = irr::video::S3DVertex(irr::core::vector3df(0.2f, -2.3f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[71] = irr::video::S3DVertex(irr::core::vector3df(1.0f, -2.3f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
iBackLine[100] = 68;
iBackLine[101] = 69;
iBackLine[102] = 68;
......@@ -161,10 +161,10 @@ Materials::Materials() {
iBackLine[106] = 70;
iBackLine[107] = 71;
//remove1
vBackLine[72] = S3DVertex(vector3df(0.2f, 0.2f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[73] = S3DVertex(vector3df(1.0f, 0.2f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[74] = S3DVertex(vector3df(0.2f, -1.0f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[75] = S3DVertex(vector3df(1.0f, -1.0f, 0.0f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vBackLine[72] = irr::video::S3DVertex(irr::core::vector3df(0.2f, 0.2f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[73] = irr::video::S3DVertex(irr::core::vector3df(1.0f, 0.2f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[74] = irr::video::S3DVertex(irr::core::vector3df(0.2f, -1.0f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
vBackLine[75] = irr::video::S3DVertex(irr::core::vector3df(1.0f, -1.0f, 0.0f), irr::core::vector3df(0, 0, 1), irr::video::SColor(255, 255, 255, 255), irr::core::vector2df(0, 0));
iBackLine[108] = 72;
iBackLine[109] = 73;
iBackLine[110] = 72;
......@@ -237,10 +237,10 @@ Materials::Materials() {
SetS3DVertex(vFieldSzone[1][7][1], 0.0f, -0.1f, -0.8f, -1.3f, 0, 1, 0, 0, 0, 0);
//conti_act
vFieldContiAct[0] = vector3df(3.5f, -0.6f, 0.0f);
vFieldContiAct[1] = vector3df(4.4f, -0.6f, 0.0f);
vFieldContiAct[2] = vector3df(3.5f, 0.6f, 0.0f);
vFieldContiAct[3] = vector3df(4.4f, 0.6f, 0.0f);
vFieldContiAct[0] = irr::core::vector3df(3.5f, -0.6f, 0.0f);
vFieldContiAct[1] = irr::core::vector3df(4.4f, -0.6f, 0.0f);
vFieldContiAct[2] = irr::core::vector3df(3.5f, 0.6f, 0.0f);
vFieldContiAct[3] = irr::core::vector3df(4.4f, 0.6f, 0.0f);
for(int i = 0; i < 40; ++i)
......@@ -250,7 +250,7 @@ Materials::Materials() {
mCard.DiffuseColor = 0xff000000;
mCard.ColorMaterial = irr::video::ECM_NONE;
mCard.MaterialType = irr::video::EMT_ONETEXTURE_BLEND;
mCard.MaterialTypeParam = pack_textureBlendFunc(EBF_SRC_ALPHA, EBF_ONE_MINUS_SRC_ALPHA, EMFN_MODULATE_1X, EAS_VERTEX_COLOR);
mCard.MaterialTypeParam = pack_textureBlendFunc(irr::video::EBF_SRC_ALPHA, irr::video::EBF_ONE_MINUS_SRC_ALPHA, irr::video::EMFN_MODULATE_1X, irr::video::EAS_VERTEX_COLOR);
mTexture.AmbientColor = 0xffffffff;
mTexture.DiffuseColor = 0xff000000;
mTexture.ColorMaterial = irr::video::ECM_NONE;
......@@ -258,15 +258,15 @@ Materials::Materials() {
mBackLine.ColorMaterial = irr::video::ECM_NONE;
mBackLine.AmbientColor = 0xffffffff;
mBackLine.DiffuseColor = 0xc0000000;
mBackLine.AntiAliasing = EAAM_FULL_BASIC;
mBackLine.AntiAliasing = irr::video::EAAM_FULL_BASIC;
mBackLine.MaterialType = irr::video::EMT_ONETEXTURE_BLEND;
mBackLine.MaterialTypeParam = pack_textureBlendFunc(EBF_SRC_ALPHA, EBF_ONE_MINUS_SRC_ALPHA, EMFN_MODULATE_1X, EAS_VERTEX_COLOR);
mBackLine.MaterialTypeParam = pack_textureBlendFunc(irr::video::EBF_SRC_ALPHA, irr::video::EBF_ONE_MINUS_SRC_ALPHA, irr::video::EMFN_MODULATE_1X, irr::video::EAS_VERTEX_COLOR);
mBackLine.Thickness = 2;
mSelField.ColorMaterial = irr::video::ECM_NONE;
mSelField.AmbientColor = 0xffffffff;
mSelField.DiffuseColor = 0xff000000;
mSelField.MaterialType = irr::video::EMT_ONETEXTURE_BLEND;
mSelField.MaterialTypeParam = pack_textureBlendFunc(EBF_SRC_ALPHA, EBF_ONE_MINUS_SRC_ALPHA, EMFN_MODULATE_1X, EAS_VERTEX_COLOR);
mSelField.MaterialTypeParam = pack_textureBlendFunc(irr::video::EBF_SRC_ALPHA, irr::video::EBF_ONE_MINUS_SRC_ALPHA, irr::video::EMFN_MODULATE_1X, irr::video::EAS_VERTEX_COLOR);
mOutLine.ColorMaterial = irr::video::ECM_AMBIENT;
mOutLine.DiffuseColor = 0xff000000;
mOutLine.Thickness = 2;
......@@ -274,15 +274,15 @@ Materials::Materials() {
mTRTexture.AmbientColor = 0xffffff00;
mATK.ColorMaterial = irr::video::ECM_AMBIENT;
mATK.DiffuseColor = 0x80000000;
mATK.setFlag(EMF_BACK_FACE_CULLING, FALSE);
mATK.setFlag(irr::video::EMF_BACK_FACE_CULLING, false);
mATK.MaterialType = irr::video::EMT_ONETEXTURE_BLEND;
mATK.MaterialTypeParam = pack_textureBlendFunc(EBF_SRC_ALPHA, EBF_ONE_MINUS_SRC_ALPHA, EMFN_MODULATE_1X, EAS_VERTEX_COLOR);
mATK.MaterialTypeParam = pack_textureBlendFunc(irr::video::EBF_SRC_ALPHA, irr::video::EBF_ONE_MINUS_SRC_ALPHA, irr::video::EMFN_MODULATE_1X, irr::video::EAS_VERTEX_COLOR);
}
void Materials::GenArrow(float y) {
float ay = 1.0f;
for (int i = 0; i < 19; ++i) {
vArrow[i * 2] = S3DVertex(vector3df(0.1f, ay * y, -2.0f * (ay * ay - 1.0f)), vector3df(0, ay * y, 1), 0xc000ff00, vector2df(0, 0));
vArrow[i * 2 + 1] = S3DVertex(vector3df(-0.1f, ay * y, -2.0f * (ay * ay - 1.0f)), vector3df(0, ay * y, 1), 0xc000ff00, vector2df(0, 0));
vArrow[i * 2] = irr::video::S3DVertex(irr::core::vector3df(0.1f, ay * y, -2.0f * (ay * ay - 1.0f)), irr::core::vector3df(0, ay * y, 1), 0xc000ff00, irr::core::vector2df(0, 0));
vArrow[i * 2 + 1] = irr::video::S3DVertex(irr::core::vector3df(-0.1f, ay * y, -2.0f * (ay * ay - 1.0f)), irr::core::vector3df(0, ay * y, 1), 0xc000ff00, irr::core::vector2df(0, 0));
ay -= 0.1f;
}
vArrow[36].Pos.X = 0.2f;
......@@ -291,7 +291,7 @@ void Materials::GenArrow(float y) {
vArrow[37].Pos.X = -0.2f;
vArrow[37].Pos.Y = vArrow[35].Pos.Y - 0.01f;
vArrow[37].Pos.Z = vArrow[35].Pos.Z - 0.01f;
vArrow[38] = S3DVertex(vector3df(0.0f, -1.0f * y, 0.0f), vector3df(0.0f, -1.0f, -1.0f), 0xc0ffffff, vector2df(0, 0));
vArrow[38] = irr::video::S3DVertex(irr::core::vector3df(0.0f, -1.0f * y, 0.0f), irr::core::vector3df(0.0f, -1.0f, -1.0f), 0xc0ffffff, irr::core::vector2df(0, 0));
vArrow[39] = vArrow[38];
}
......
#include "config.h"
#ifndef MATERIALS_H
#define MATERIALS_H
#include <irrlicht.h>
namespace ygo {
......@@ -7,31 +10,31 @@ public:
Materials();
void GenArrow(float y);
S3DVertex vCardFront[4];
S3DVertex vCardOutline[4];
S3DVertex vCardOutliner[4];
S3DVertex vCardBack[4];
S3DVertex vSymbol[4];
S3DVertex vNegate[4];
S3DVertex vChainNum[4];
S3DVertex vActivate[4];
S3DVertex vField[4];
S3DVertex vFieldSpell[4];
S3DVertex vFieldSpell1[4];
S3DVertex vFieldSpell2[4];
//S3DVertex vBackLine[76];
S3DVertex vFieldDeck[2][4];
S3DVertex vFieldGrave[2][2][4]; //[player][rule], rule = 0: dule_rule <= 3, 1: dule_rule >= 4
S3DVertex vFieldExtra[2][4];
S3DVertex vFieldRemove[2][2][4]; //[player][rule]
S3DVertex vFieldMzone[2][7][4]; //[player][sequence]
S3DVertex vFieldSzone[2][8][2][4]; //[player][sequence][rule]
irr::video::S3DVertex vCardFront[4];
irr::video::S3DVertex vCardOutline[4];
irr::video::S3DVertex vCardOutliner[4];
irr::video::S3DVertex vCardBack[4];
irr::video::S3DVertex vSymbol[4];
irr::video::S3DVertex vNegate[4];
irr::video::S3DVertex vChainNum[4];
irr::video::S3DVertex vActivate[4];
irr::video::S3DVertex vField[4];
irr::video::S3DVertex vFieldSpell[4];
irr::video::S3DVertex vFieldSpell1[4];
irr::video::S3DVertex vFieldSpell2[4];
//irr::video::S3DVertex vBackLine[76];
irr::video::S3DVertex vFieldDeck[2][4];
irr::video::S3DVertex vFieldGrave[2][2][4]; //[player][rule], rule = 0: dule_rule <= 3, 1: dule_rule >= 4
irr::video::S3DVertex vFieldExtra[2][4];
irr::video::S3DVertex vFieldRemove[2][2][4]; //[player][rule]
irr::video::S3DVertex vFieldMzone[2][7][4]; //[player][sequence]
irr::video::S3DVertex vFieldSzone[2][8][2][4]; //[player][sequence][rule]
irr::core::vector3df vFieldContiAct[4];
S3DVertex vArrow[40];
SColor c2d[4];
u16 iRectangle[6];
//u16 iBackLine[116];
u16 iArrow[40];
irr::video::S3DVertex vArrow[40];
irr::video::SColor c2d[4];
irr::u16 iRectangle[6];
//irr::u16 iBackLine[116];
irr::u16 iArrow[40];
irr::video::SMaterial mCard;
irr::video::SMaterial mTexture;
irr::video::SMaterial mBackLine;
......@@ -44,3 +47,5 @@ public:
extern Materials matManager;
}
#endif //MATERIALS_H
......@@ -176,7 +176,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
}
case BUTTON_HP_READY: {
if(mainGame->cbCategorySelect->getSelected() == -1 || mainGame->cbDeckSelect->getSelected() == -1 ||
!deckManager.LoadCurrentDeck(mainGame->cbCategorySelect, mainGame->cbDeckSelect)) {
!deckManager.LoadCurrentDeck(mainGame->cbCategorySelect->getSelected(), mainGame->cbCategorySelect->getText(), mainGame->cbDeckSelect->getText())) {
mainGame->gMutex.lock();
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1406));
......@@ -367,7 +367,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
wchar_t arg1[512];
if(mainGame->botInfo[sel].select_deckfile) {
wchar_t botdeck[256];
deckManager.GetDeckFile(botdeck, mainGame->cbBotDeckCategory, mainGame->cbBotDeck);
deckManager.GetDeckFile(botdeck, mainGame->cbBotDeckCategory->getSelected(), mainGame->cbBotDeckCategory->getText(), mainGame->cbBotDeck->getText());
myswprintf(arg1, L"%ls DeckFile='%ls'", mainGame->botInfo[sel].command, botdeck);
}
else
......@@ -386,7 +386,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
wchar_t warg1[512];
if(mainGame->botInfo[sel].select_deckfile) {
wchar_t botdeck[256];
deckManager.GetDeckFile(botdeck, mainGame->cbBotDeckCategory, mainGame->cbBotDeck);
deckManager.GetDeckFile(botdeck, mainGame->cbBotDeckCategory->getSelected(), mainGame->cbBotDeckCategory->getText(), mainGame->cbBotDeck->getText());
myswprintf(warg1, L"%ls DeckFile='%ls'", mainGame->botInfo[sel].command, botdeck);
}
else
......@@ -396,9 +396,9 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int flag = 0;
flag += (mainGame->chkBotHand->isChecked() ? 0x1 : 0);
char arg2[8];
snprintf(arg2, sizeof arg2, "%d", flag);
std::snprintf(arg2, sizeof arg2, "%d", flag);
char arg3[8];
snprintf(arg3, sizeof arg3, "%d", mainGame->gameConf.serverport);
std::snprintf(arg3, sizeof arg3, "%d", mainGame->gameConf.serverport);
execl("./bot", "bot", arg1, arg2, arg3, nullptr);
exit(0);
} else {
......@@ -472,7 +472,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
open_file = false;
}
else if(mainGame->cbDBCategory->getSelected() != -1 && mainGame->cbDBDecks->getSelected() != -1) {
deckManager.LoadCurrentDeck(mainGame->cbDBCategory, mainGame->cbDBDecks);
deckManager.LoadCurrentDeck(mainGame->cbDBCategory->getSelected(), mainGame->cbDBCategory->getText(), mainGame->cbDBDecks->getText());
mainGame->ebDeckname->setText(L"");
}
mainGame->HideElement(mainGame->wMainMenu);
......@@ -581,7 +581,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
const wchar_t* name = mainGame->lstSinglePlayList->getListItem(sel);
wchar_t fname[256];
myswprintf(fname, L"./single/%ls", name);
FILE* fp = myfopen(fname, "rb");
FILE* fp = mywfopen(fname, "rb");
if(!fp) {
mainGame->stSinglePlayInfo->setText(L"");
break;
......@@ -590,7 +590,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
wchar_t wlinebuf[1024];
std::wstring message = L"";
bool in_message = false;
while(fgets(linebuf, 1024, fp)) {
while(std::fgets(linebuf, 1024, fp)) {
if(!std::strncmp(linebuf, "--[[message", 11)) {
size_t len = std::strlen(linebuf);
char* msgend = std::strrchr(linebuf, ']');
......@@ -613,7 +613,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
message.append(wlinebuf);
}
}
fclose(fp);
std::fclose(fp);
mainGame->SetStaticText(mainGame->stSinglePlayInfo, 200, mainGame->guiFont, message.c_str());
break;
}
......@@ -637,7 +637,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame->env->setFocus(mainGame->wHostPrepare);
if(static_cast<irr::gui::IGUICheckBox*>(caller)->isChecked()) {
if(mainGame->cbCategorySelect->getSelected() == -1 || mainGame->cbDeckSelect->getSelected() == -1 ||
!deckManager.LoadCurrentDeck(mainGame->cbCategorySelect, mainGame->cbDeckSelect)) {
!deckManager.LoadCurrentDeck(mainGame->cbCategorySelect->getSelected(), mainGame->cbCategorySelect->getText(), mainGame->cbDeckSelect->getText())) {
mainGame->gMutex.lock();
static_cast<irr::gui::IGUICheckBox*>(caller)->setChecked(false);
soundManager.PlaySoundEffect(SOUND_INFO);
......
#ifndef MENU_HANDLER_H
#define MENU_HANDLER_H
#include "config.h"
#include <irrlicht.h>
namespace ygo {
class MenuHandler: public irr::IEventReceiver {
public:
bool OnEvent(const irr::SEvent& event) override;
s32 prev_operation;
int prev_sel;
irr::s32 prev_operation{ 0 };
int prev_sel{ -1 };
};
......
......@@ -94,7 +94,7 @@ public:
if(fh == INVALID_HANDLE_VALUE)
return;
do {
if(mywcsncasecmp(fdataw.cFileName, L".", 1) && mywcsncasecmp(fdataw.cFileName, L"..", 2))
if(std::wcscmp(fdataw.cFileName, L".") && std::wcscmp(fdataw.cFileName, L".."))
cb(fdataw.cFileName, (fdataw.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY));
} while(FindNextFileW(fh, &fdataw));
FindClose(fh);
......@@ -228,7 +228,7 @@ public:
#else
funit.filename = std::string(dirp->d_name);
funit.is_dir = S_ISDIR(fileStat.st_mode);
if(funit.is_dir && (strcmp(dirp->d_name, ".") == 0 || strcmp(dirp->d_name, "..") == 0))
if(funit.is_dir && (std::strcmp(dirp->d_name, ".") == 0 || std::strcmp(dirp->d_name, "..") == 0))
continue;
file_list.push_back(funit);
#endif
......
......@@ -40,7 +40,7 @@ void Replay::BeginRecord() {
return;
#else
if(is_recording)
fclose(fp);
std::fclose(fp);
#ifdef YGOPRO_SERVER_MODE
time_t nowtime = time(NULL);
struct tm *localedtime = localtime(&nowtime);
......@@ -48,9 +48,9 @@ void Replay::BeginRecord() {
strftime(tmppath, 40, "./replay/%Y-%m-%d %H-%M-%S %%u.yrp", localedtime);
char path[40];
sprintf(path, tmppath, server_port);
fp = fopen(path, "wb");
fp = std::fopen(path, "wb");
#else
fp = fopen("./replay/_LastReplay.yrp", "wb");
fp = std::fopen("./replay/_LastReplay.yrp", "wb");
#endif //YGOPRO_SERVER_MODE
if(!fp)
return;
......@@ -72,8 +72,8 @@ void Replay::WriteHeader(ReplayHeader& header) {
DWORD size;
WriteFile(recording_fp, &header, sizeof(header), &size, nullptr);
#else
fwrite(&header, sizeof(header), 1, fp);
fflush(fp);
std::fwrite(&header, sizeof(header), 1, fp);
std::fflush(fp);
#endif
}
void Replay::WriteData(const void* data, size_t length, bool flush) {
......@@ -90,9 +90,9 @@ void Replay::WriteData(const void* data, size_t length, bool flush) {
DWORD size;
WriteFile(recording_fp, data, length, &size, nullptr);
#else
fwrite(data, length, 1, fp);
std::fwrite(data, length, 1, fp);
if(flush)
fflush(fp);
std::fflush(fp);
#endif
}
void Replay::WriteInt32(int32_t data, bool flush) {
......@@ -106,7 +106,7 @@ void Replay::Flush() {
#endif
#ifdef _WIN32
#else
fflush(fp);
std::fflush(fp);
#endif
}
void Replay::EndRecord() {
......@@ -118,7 +118,7 @@ void Replay::EndRecord() {
#ifdef _WIN32
CloseHandle(recording_fp);
#else
fclose(fp);
std::fclose(fp);
#endif
#ifdef YGOPRO_SERVER_MODE
}
......@@ -139,19 +139,19 @@ void Replay::SaveReplay(const wchar_t* name) {
return;
wchar_t fname[256];
myswprintf(fname, L"./replay/%ls.yrp", name);
FILE* rfp = myfopen(fname, "wb");
FILE* rfp = mywfopen(fname, "wb");
if(!rfp)
return;
fwrite(&pheader, sizeof pheader, 1, rfp);
fwrite(comp_data, comp_size, 1, rfp);
fclose(rfp);
std::fwrite(&pheader, sizeof pheader, 1, rfp);
std::fwrite(comp_data, comp_size, 1, rfp);
std::fclose(rfp);
}
bool Replay::OpenReplay(const wchar_t* name) {
FILE* rfp = myfopen(name, "rb");
FILE* rfp = mywfopen(name, "rb");
if(!rfp) {
wchar_t fname[256];
myswprintf(fname, L"./replay/%ls", name);
rfp = myfopen(fname, "rb");
rfp = mywfopen(fname, "rb");
}
if(!rfp)
return false;
......@@ -161,13 +161,13 @@ bool Replay::OpenReplay(const wchar_t* name) {
is_replaying = false;
replay_size = 0;
comp_size = 0;
if(fread(&pheader, sizeof pheader, 1, rfp) < 1) {
fclose(rfp);
if(std::fread(&pheader, sizeof pheader, 1, rfp) < 1) {
std::fclose(rfp);
return false;
}
if(pheader.flag & REPLAY_COMPRESSED) {
comp_size = fread(comp_data, 1, MAX_COMP_SIZE, rfp);
fclose(rfp);
comp_size = std::fread(comp_data, 1, MAX_COMP_SIZE, rfp);
std::fclose(rfp);
if (pheader.datasize > MAX_REPLAY_SIZE)
return false;
replay_size = pheader.datasize;
......@@ -178,8 +178,8 @@ bool Replay::OpenReplay(const wchar_t* name) {
return false;
}
} else {
replay_size = fread(replay_data, 1, MAX_REPLAY_SIZE, rfp);
fclose(rfp);
replay_size = std::fread(replay_data, 1, MAX_REPLAY_SIZE, rfp);
std::fclose(rfp);
comp_size = 0;
}
is_replaying = true;
......@@ -188,12 +188,12 @@ bool Replay::OpenReplay(const wchar_t* name) {
bool Replay::CheckReplay(const wchar_t* name) {
wchar_t fname[256];
myswprintf(fname, L"./replay/%ls", name);
FILE* rfp = myfopen(fname, "rb");
FILE* rfp = mywfopen(fname, "rb");
if(!rfp)
return false;
ReplayHeader rheader;
size_t count = fread(&rheader, sizeof rheader, 1, rfp);
fclose(rfp);
size_t count = std::fread(&rheader, sizeof rheader, 1, rfp);
std::fclose(rfp);
return count == 1 && rheader.id == 0x31707279 && rheader.version >= 0x12d0u && (rheader.version < 0x1353u || (rheader.flag & REPLAY_UNIFORM));
}
bool Replay::DeleteReplay(const wchar_t* name) {
......
......@@ -43,6 +43,10 @@ project "freetype"
"src/type42/type42.c",
"src/winfonts/winfnt.c" }
if os.isfile("src/svg/svg.c") then
files { "src/svg/svg.c" }
end
filter "system:windows"
files { "builds/windows/ftsystem.c",
"builds/windows/ftdebug.c" }
......
1 ICON "ygopro.ico"
1 VERSIONINFO
FILEVERSION 1, 0, 35, 3
PRODUCTVERSION 1, 0, 35, 3
FILEVERSION 1, 0, 36, 1
PRODUCTVERSION 1, 0, 36, 1
FILEOS 0x4
FILETYPE 0x1
......@@ -13,11 +13,11 @@ BLOCK "080404b0"
BEGIN
VALUE "FileDescription", "YGOPro Server Mode"
VALUE "InternalName", "YGOPro Server Mode"
VALUE "LegalCopyright", "Copyright (C) 2022 Fluorohydride"
VALUE "LegalCopyright", "Copyright (C) 2025 Fluorohydride"
VALUE "OriginalFilename", "YGOPro.exe"
VALUE "ProductName", "YGOPro Server Mode"
VALUE "FileVersion", "1.035.3"
VALUE "ProductVersion", "1.035.3"
VALUE "FileVersion", "1.036.1"
VALUE "ProductVersion", "1.036.1"
END
END
BLOCK "VarFileInfo"
......
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