Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YGOPRO-520DIY
ygopro
Commits
e3475c17
Commit
e3475c17
authored
Feb 22, 2025
by
wind2009
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master' into develop
parents
28bb4121
27bf0fe9
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
696 additions
and
1176 deletions
+696
-1176
gframe/CGUIButton.h
gframe/CGUIButton.h
+0
-143
gframe/CGUIImageButton.cpp
gframe/CGUIImageButton.cpp
+365
-9
gframe/CGUIImageButton.h
gframe/CGUIImageButton.h
+136
-15
gframe/config.h
gframe/config.h
+3
-3
gframe/data_manager.cpp
gframe/data_manager.cpp
+9
-12
gframe/deck_con.cpp
gframe/deck_con.cpp
+19
-11
gframe/deck_manager.cpp
gframe/deck_manager.cpp
+33
-37
gframe/deck_manager.h
gframe/deck_manager.h
+4
-5
gframe/game.cpp
gframe/game.cpp
+75
-75
gframe/image_manager.cpp
gframe/image_manager.cpp
+13
-13
gframe/menu_handler.cpp
gframe/menu_handler.cpp
+10
-10
gframe/myfilesystem.h
gframe/myfilesystem.h
+2
-2
gframe/replay.cpp
gframe/replay.cpp
+23
-23
premake/freetype/premake5.lua
premake/freetype/premake5.lua
+4
-0
premake/irrlicht/irrlicht.patch
premake/irrlicht/irrlicht.patch
+0
-818
No files found.
gframe/CGUIButton.h
deleted
100644 → 0
View file @
28bb4121
// 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__
gframe/CGUIImageButton.cpp
View file @
e3475c17
#ifdef _MSC_VER
// Copyright (C) 2002-2012 Nikolaus Gebhardt
#pragma warning(disable: 4244)
// This file is part of the "Irrlicht Engine".
#endif
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CGUIImageButton.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
irr
{
namespace
gui
{
namespace
gui
{
...
@@ -94,19 +101,213 @@ void Draw2DImageQuad(video::IVideoDriver* driver, video::ITexture* image, core::
...
@@ -94,19 +101,213 @@ void Draw2DImageQuad(video::IVideoDriver* driver, video::ITexture* image, core::
driver
->
setTransform
(
irr
::
video
::
ETS_PROJECTION
,
oldProjMat
);
driver
->
setTransform
(
irr
::
video
::
ETS_PROJECTION
,
oldProjMat
);
driver
->
setTransform
(
irr
::
video
::
ETS_VIEW
,
oldViewMat
);
driver
->
setTransform
(
irr
::
video
::
ETS_VIEW
,
oldViewMat
);
}
}
CGUIImageButton
::
CGUIImageButton
(
IGUIEnvironment
*
environment
,
IGUIElement
*
parent
,
s32
id
,
core
::
rect
<
s32
>
rectangle
)
CGUIImageButton
*
CGUIImageButton
::
addImageButton
(
IGUIEnvironment
*
env
,
const
core
::
rect
<
s32
>&
rectangle
,
IGUIElement
*
parent
,
s32
id
)
{
:
CGUIButton
(
environment
,
parent
,
id
,
rectangle
)
{
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
;
isDrawImage
=
true
;
isFixedSize
=
false
;
isFixedSize
=
false
;
imageRotation
=
0.0
f
;
imageRotation
=
0.0
f
;
imageScale
=
core
::
vector2df
(
1.0
f
,
1.0
f
);
imageScale
=
core
::
vector2df
(
1.0
f
,
1.0
f
);
imageSize
=
core
::
dimension2di
(
rectangle
.
getWidth
(),
rectangle
.
getHeight
());
imageSize
=
core
::
dimension2di
(
rectangle
.
getWidth
(),
rectangle
.
getHeight
());
}
}
CGUIImageButton
*
CGUIImageButton
::
addImageButton
(
IGUIEnvironment
*
env
,
const
core
::
rect
<
s32
>&
rectangle
,
IGUIElement
*
parent
,
s32
id
)
{
//! destructor
CGUIImageButton
*
button
=
new
CGUIImageButton
(
env
,
parent
?
parent
:
0
,
id
,
rectangle
);
CGUIImageButton
::~
CGUIImageButton
()
button
->
drop
();
{
return
button
;
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
::
position2d
<
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
::
position2d
<
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
()
{
void
CGUIImageButton
::
draw
()
{
if
(
!
IsVisible
)
if
(
!
IsVisible
)
return
;
return
;
...
@@ -148,6 +349,14 @@ void CGUIImageButton::setImage(video::ITexture* image)
...
@@ -148,6 +349,14 @@ void CGUIImageButton::setImage(video::ITexture* image)
if
(
!
PressedImage
)
if
(
!
PressedImage
)
setPressedImage
(
Image
);
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
)
{
void
CGUIImageButton
::
setDrawImage
(
bool
b
)
{
isDrawImage
=
b
;
isDrawImage
=
b
;
}
}
...
@@ -162,6 +371,21 @@ void CGUIImageButton::setImageSize(core::dimension2di s) {
...
@@ -162,6 +371,21 @@ void CGUIImageButton::setImageSize(core::dimension2di s) {
imageSize
=
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
IGUIFont
*
CGUIImageButton
::
getOverrideFont
(
void
)
const
{
{
IGUISkin
*
skin
=
Environment
->
getSkin
();
IGUISkin
*
skin
=
Environment
->
getSkin
();
...
@@ -178,5 +402,137 @@ IGUIFont* CGUIImageButton::getActiveFont() const
...
@@ -178,5 +402,137 @@ IGUIFont* CGUIImageButton::getActiveFont() const
return
skin
->
getFont
();
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
::
position2d
<
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_
gframe/CGUIImageButton.h
View file @
e3475c17
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef _C_GUI_IMAGE_BUTTON_H_
#ifndef _C_GUI_IMAGE_BUTTON_H_
#define _C_GUI_IMAGE_BUTTON_H_
#define _C_GUI_IMAGE_BUTTON_H_
#include <irrlicht.h>
#include <IrrCompileConfig.h>
#include "CGUIButton.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include <IGUIButton.h>
#include <SColor.h>
namespace
irr
{
namespace
irr
{
namespace
video
{
class
IVideoDriver
;
class
ITexture
;
}
namespace
gui
{
namespace
gui
{
class
IGUISpriteBank
;
void
Draw2DImageRotation
(
video
::
IVideoDriver
*
driver
,
video
::
ITexture
*
image
,
core
::
rect
<
s32
>
sourceRect
,
void
Draw2DImageRotation
(
video
::
IVideoDriver
*
driver
,
video
::
ITexture
*
image
,
core
::
rect
<
s32
>
sourceRect
,
core
::
position2d
<
s32
>
position
,
core
::
position2d
<
s32
>
rotationPoint
,
f32
rotation
=
0.0
f
,
core
::
position2d
<
s32
>
position
,
core
::
position2d
<
s32
>
rotationPoint
,
f32
rotation
=
0.0
f
,
core
::
vector2df
scale
=
core
::
vector2df
(
1.0
,
1.0
),
bool
useAlphaChannel
=
true
,
video
::
SColor
color
=
0xffffffff
);
core
::
vector2df
scale
=
core
::
vector2df
(
1.0
,
1.0
),
bool
useAlphaChannel
=
true
,
video
::
SColor
color
=
0xffffffff
);
void
Draw2DImageQuad
(
video
::
IVideoDriver
*
driver
,
video
::
ITexture
*
image
,
core
::
rect
<
s32
>
sourceRect
,
void
Draw2DImageQuad
(
video
::
IVideoDriver
*
driver
,
video
::
ITexture
*
image
,
core
::
rect
<
s32
>
sourceRect
,
core
::
position2d
<
s32
>
corner
[
4
],
bool
useAlphaChannel
=
true
,
video
::
SColor
color
=
0xffffffff
);
core
::
position2d
<
s32
>
corner
[
4
],
bool
useAlphaChannel
=
true
,
video
::
SColor
color
=
0xffffffff
);
class
CGUIImageButton
:
public
CGUIButton
{
class
CGUIImageButton
:
public
IGUIButton
{
public:
public:
CGUIImageButton
(
IGUIEnvironment
*
environment
,
IGUIElement
*
parent
,
s32
id
,
core
::
rect
<
s32
>
rectangle
);
static
CGUIImageButton
*
addImageButton
(
IGUIEnvironment
*
env
,
const
core
::
rect
<
s32
>&
rectangle
,
IGUIElement
*
parent
,
s32
id
);
static
CGUIImageButton
*
addImageButton
(
IGUIEnvironment
*
env
,
const
core
::
rect
<
s32
>&
rectangle
,
IGUIElement
*
parent
,
s32
id
);
virtual
void
draw
();
//! constructor
virtual
void
setImage
(
video
::
ITexture
*
image
=
0
);
CGUIImageButton
(
IGUIEnvironment
*
environment
,
IGUIElement
*
parent
,
virtual
void
setDrawImage
(
bool
b
);
s32
id
,
core
::
rect
<
s32
>
rectangle
,
bool
noclip
=
false
);
virtual
void
setImageRotation
(
f32
r
);
virtual
void
setImageScale
(
core
::
vector2df
s
);
//! destructor
virtual
void
setImageSize
(
core
::
dimension2di
s
);
~
CGUIImageButton
()
override
;
virtual
IGUIFont
*
getOverrideFont
(
void
)
const
;
virtual
IGUIFont
*
getActiveFont
()
const
;
//! called if an event happened.
bool
OnEvent
(
const
SEvent
&
event
)
override
;
private:
//! draws the element and its children
void
draw
()
override
;
//! sets another skin independent font. if this is set to zero, the button uses the font of the skin.
void
setOverrideFont
(
IGUIFont
*
font
=
0
)
override
;
//! Gets the override font (if any)
IGUIFont
*
getOverrideFont
()
const
override
;
//! Get the font which is used right now for drawing
IGUIFont
*
getActiveFont
()
const
override
;
//! Sets an image which should be displayed on the button when it is in normal state.
void
setImage
(
video
::
ITexture
*
image
=
0
)
override
;
//! Sets an image which should be displayed on the button when it is in normal state.
void
setImage
(
video
::
ITexture
*
image
,
const
core
::
rect
<
s32
>&
pos
)
override
;
//! Sets an image which should be displayed on the button when it is in pressed state.
void
setPressedImage
(
video
::
ITexture
*
image
=
0
)
override
;
//! Sets an image which should be displayed on the button when it is in pressed state.
void
setPressedImage
(
video
::
ITexture
*
image
,
const
core
::
rect
<
s32
>&
pos
)
override
;
//! Sets the sprite bank used by the button
void
setSpriteBank
(
IGUISpriteBank
*
bank
=
0
)
override
;
//! Sets the animated sprite for a specific button state
/** \param index: Number of the sprite within the sprite bank, use -1 for no sprite
\param state: State of the button to set the sprite for
\param index: The sprite number from the current sprite bank
\param color: The color of the sprite
*/
void
setSprite
(
EGUI_BUTTON_STATE
state
,
s32
index
,
video
::
SColor
color
=
video
::
SColor
(
255
,
255
,
255
,
255
),
bool
loop
=
false
)
override
;
//! Sets if the button should behave like a push button. Which means it
//! can be in two states: Normal or Pressed. With a click on the button,
//! the user can change the state of the button.
void
setIsPushButton
(
bool
isPushButton
=
true
)
override
;
//! Checks whether the button is a push button
bool
isPushButton
()
const
override
;
//! Sets the pressed state of the button if this is a pushbutton
void
setPressed
(
bool
pressed
=
true
)
override
;
//! Returns if the button is currently pressed
bool
isPressed
()
const
override
;
//! Sets if the button should use the skin to draw its border
void
setDrawBorder
(
bool
border
=
true
)
override
;
//! Checks if the button face and border are being drawn
bool
isDrawingBorder
()
const
override
;
//! Sets if the alpha channel should be used for drawing images on the button (default is false)
void
setUseAlphaChannel
(
bool
useAlphaChannel
=
true
)
override
;
//! Checks if the alpha channel should be used for drawing images on the button
bool
isAlphaChannelUsed
()
const
override
;
//! Sets if the button should scale the button images to fit
void
setScaleImage
(
bool
scaleImage
=
true
)
override
;
//! Checks whether the button scales the used images
bool
isScalingImage
()
const
override
;
//! Writes attributes of the element.
void
serializeAttributes
(
io
::
IAttributes
*
out
,
io
::
SAttributeReadWriteOptions
*
options
)
const
override
;
//! Reads attributes of the element
void
deserializeAttributes
(
io
::
IAttributes
*
in
,
io
::
SAttributeReadWriteOptions
*
options
)
override
;
// from ygopro
void
setDrawImage
(
bool
b
);
void
setImageRotation
(
f32
r
);
void
setImageScale
(
core
::
vector2df
s
);
void
setImageSize
(
core
::
dimension2di
s
);
protected:
struct
ButtonSprite
{
s32
Index
;
video
::
SColor
Color
;
bool
Loop
;
};
ButtonSprite
ButtonSprites
[
EGBS_COUNT
];
IGUISpriteBank
*
SpriteBank
;
IGUIFont
*
OverrideFont
;
video
::
ITexture
*
Image
;
video
::
ITexture
*
PressedImage
;
core
::
rect
<
s32
>
ImageRect
;
core
::
rect
<
s32
>
PressedImageRect
;
bool
IsPushButton
;
bool
Pressed
;
bool
UseAlphaChannel
;
bool
DrawBorder
;
bool
ScaleImage
;
// from ygopro
bool
isDrawImage
;
bool
isDrawImage
;
bool
isFixedSize
;
bool
isFixedSize
;
f32
imageRotation
;
f32
imageRotation
;
...
@@ -36,4 +155,6 @@ private:
...
@@ -36,4 +155,6 @@ private:
}
}
}
}
#endif // _IRR_COMPILE_WITH_GUI_
#endif //_C_GUI_IMAGE_BUTTON_H_
#endif //_C_GUI_IMAGE_BUTTON_H_
gframe/config.h
View file @
e3475c17
...
@@ -43,7 +43,7 @@
...
@@ -43,7 +43,7 @@
#define mystrncasecmp strncasecmp
#define mystrncasecmp strncasecmp
#endif
#endif
#include <
stdio.h
>
#include <
cstdio
>
#include <stdlib.h>
#include <stdlib.h>
#include <iostream>
#include <iostream>
#include <algorithm>
#include <algorithm>
...
@@ -56,7 +56,7 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
...
@@ -56,7 +56,7 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
return
std
::
swprintf
(
buf
,
N
,
fmt
,
args
...);
return
std
::
swprintf
(
buf
,
N
,
fmt
,
args
...);
}
}
inline
FILE
*
myfopen
(
const
wchar_t
*
filename
,
const
char
*
mode
)
{
inline
FILE
*
my
w
fopen
(
const
wchar_t
*
filename
,
const
char
*
mode
)
{
FILE
*
fp
{};
FILE
*
fp
{};
#ifdef _WIN32
#ifdef _WIN32
wchar_t
wmode
[
20
]{};
wchar_t
wmode
[
20
]{};
...
@@ -65,7 +65,7 @@ inline FILE* myfopen(const wchar_t* filename, const char* mode) {
...
@@ -65,7 +65,7 @@ inline FILE* myfopen(const wchar_t* filename, const char* mode) {
#else
#else
char
fname
[
1024
]{};
char
fname
[
1024
]{};
BufferIO
::
EncodeUTF8
(
filename
,
fname
);
BufferIO
::
EncodeUTF8
(
filename
,
fname
);
fp
=
fopen
(
fname
,
mode
);
fp
=
std
::
fopen
(
fname
,
mode
);
#endif
#endif
return
fp
;
return
fp
;
}
}
...
...
gframe/data_manager.cpp
View file @
e3475c17
#include "data_manager.h"
#include "data_manager.h"
#include "game.h"
#include "game.h"
#include <stdio.h>
#include "spmemvfs/spmemvfs.h"
#include "spmemvfs/spmemvfs.h"
namespace
ygo
{
namespace
ygo
{
...
@@ -109,14 +108,14 @@ bool DataManager::LoadDB(const wchar_t* wfile) {
...
@@ -109,14 +108,14 @@ bool DataManager::LoadDB(const wchar_t* wfile) {
return
ret
;
return
ret
;
}
}
bool
DataManager
::
LoadStrings
(
const
char
*
file
)
{
bool
DataManager
::
LoadStrings
(
const
char
*
file
)
{
FILE
*
fp
=
fopen
(
file
,
"r"
);
FILE
*
fp
=
std
::
fopen
(
file
,
"r"
);
if
(
!
fp
)
if
(
!
fp
)
return
false
;
return
false
;
char
linebuf
[
TEXT_LINE_SIZE
]{};
char
linebuf
[
TEXT_LINE_SIZE
]{};
while
(
fgets
(
linebuf
,
sizeof
linebuf
,
fp
))
{
while
(
std
::
fgets
(
linebuf
,
sizeof
linebuf
,
fp
))
{
ReadStringConfLine
(
linebuf
);
ReadStringConfLine
(
linebuf
);
}
}
fclose
(
fp
);
std
::
fclose
(
fp
);
return
true
;
return
true
;
}
}
bool
DataManager
::
LoadStrings
(
irr
::
io
::
IReadFile
*
reader
)
{
bool
DataManager
::
LoadStrings
(
irr
::
io
::
IReadFile
*
reader
)
{
...
@@ -140,26 +139,26 @@ void DataManager::ReadStringConfLine(const char* linebuf) {
...
@@ -140,26 +139,26 @@ void DataManager::ReadStringConfLine(const char* linebuf) {
char
strbuf
[
TEXT_LINE_SIZE
]{};
char
strbuf
[
TEXT_LINE_SIZE
]{};
int
value
{};
int
value
{};
wchar_t
strBuffer
[
4096
]{};
wchar_t
strBuffer
[
4096
]{};
if
(
sscanf
(
linebuf
,
"!%63s"
,
strbuf
)
!=
1
)
if
(
s
td
::
s
scanf
(
linebuf
,
"!%63s"
,
strbuf
)
!=
1
)
return
;
return
;
if
(
!
std
::
strcmp
(
strbuf
,
"system"
))
{
if
(
!
std
::
strcmp
(
strbuf
,
"system"
))
{
if
(
sscanf
(
&
linebuf
[
7
],
"%d %240[^
\n
]"
,
&
value
,
strbuf
)
!=
2
)
if
(
s
td
::
s
scanf
(
&
linebuf
[
7
],
"%d %240[^
\n
]"
,
&
value
,
strbuf
)
!=
2
)
return
;
return
;
BufferIO
::
DecodeUTF8
(
strbuf
,
strBuffer
);
BufferIO
::
DecodeUTF8
(
strbuf
,
strBuffer
);
_sysStrings
[
value
]
=
strBuffer
;
_sysStrings
[
value
]
=
strBuffer
;
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"victory"
))
{
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"victory"
))
{
if
(
sscanf
(
&
linebuf
[
8
],
"%x %240[^
\n
]"
,
&
value
,
strbuf
)
!=
2
)
if
(
s
td
::
s
scanf
(
&
linebuf
[
8
],
"%x %240[^
\n
]"
,
&
value
,
strbuf
)
!=
2
)
return
;
return
;
BufferIO
::
DecodeUTF8
(
strbuf
,
strBuffer
);
BufferIO
::
DecodeUTF8
(
strbuf
,
strBuffer
);
_victoryStrings
[
value
]
=
strBuffer
;
_victoryStrings
[
value
]
=
strBuffer
;
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"counter"
))
{
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"counter"
))
{
if
(
sscanf
(
&
linebuf
[
8
],
"%x %240[^
\n
]"
,
&
value
,
strbuf
)
!=
2
)
if
(
s
td
::
s
scanf
(
&
linebuf
[
8
],
"%x %240[^
\n
]"
,
&
value
,
strbuf
)
!=
2
)
return
;
return
;
BufferIO
::
DecodeUTF8
(
strbuf
,
strBuffer
);
BufferIO
::
DecodeUTF8
(
strbuf
,
strBuffer
);
_counterStrings
[
value
]
=
strBuffer
;
_counterStrings
[
value
]
=
strBuffer
;
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"setname"
))
{
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"setname"
))
{
//using tab for comment
//using tab for comment
if
(
sscanf
(
&
linebuf
[
8
],
"%x %240[^
\t\n
]"
,
&
value
,
strbuf
)
!=
2
)
if
(
s
td
::
s
scanf
(
&
linebuf
[
8
],
"%x %240[^
\t\n
]"
,
&
value
,
strbuf
)
!=
2
)
return
;
return
;
BufferIO
::
DecodeUTF8
(
strbuf
,
strBuffer
);
BufferIO
::
DecodeUTF8
(
strbuf
,
strBuffer
);
_setnameStrings
[
value
]
=
strBuffer
;
_setnameStrings
[
value
]
=
strBuffer
;
...
@@ -432,9 +431,7 @@ unsigned char* DataManager::ReadScriptFromIrrFS(const char* script_name, int* sl
...
@@ -432,9 +431,7 @@ unsigned char* DataManager::ReadScriptFromIrrFS(const char* script_name, int* sl
return
scriptBuffer
;
return
scriptBuffer
;
}
}
unsigned
char
*
DataManager
::
ReadScriptFromFile
(
const
char
*
script_name
,
int
*
slen
)
{
unsigned
char
*
DataManager
::
ReadScriptFromFile
(
const
char
*
script_name
,
int
*
slen
)
{
wchar_t
fname
[
256
]{};
FILE
*
fp
=
std
::
fopen
(
script_name
,
"rb"
);
BufferIO
::
DecodeUTF8
(
script_name
,
fname
);
FILE
*
fp
=
myfopen
(
fname
,
"rb"
);
if
(
!
fp
)
if
(
!
fp
)
return
nullptr
;
return
nullptr
;
size_t
len
=
std
::
fread
(
scriptBuffer
,
1
,
sizeof
scriptBuffer
,
fp
);
size_t
len
=
std
::
fread
(
scriptBuffer
,
1
,
sizeof
scriptBuffer
,
fp
);
...
...
gframe/deck_con.cpp
View file @
e3475c17
...
@@ -46,6 +46,14 @@ static inline bool havePopupWindow() {
...
@@ -46,6 +46,14 @@ static inline bool havePopupWindow() {
return
mainGame
->
wQuery
->
isVisible
()
||
mainGame
->
wCategories
->
isVisible
()
||
mainGame
->
wLinkMarks
->
isVisible
()
||
mainGame
->
wDeckManage
->
isVisible
()
||
mainGame
->
wDMQuery
->
isVisible
();
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
()
{
void
DeckBuilder
::
Initialize
()
{
mainGame
->
is_building
=
true
;
mainGame
->
is_building
=
true
;
mainGame
->
is_siding
=
false
;
mainGame
->
is_siding
=
false
;
...
@@ -164,7 +172,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -164,7 +172,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
if
(
sel
==
-
1
)
if
(
sel
==
-
1
)
break
;
break
;
wchar_t
filepath
[
256
];
wchar_t
filepath
[
256
];
deckManager
.
GetDeckFile
(
filepath
,
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
get_deck_file
(
filepath
);
if
(
deckManager
.
SaveDeck
(
deckManager
.
current_deck
,
filepath
))
{
if
(
deckManager
.
SaveDeck
(
deckManager
.
current_deck
,
filepath
))
{
mainGame
->
stACMessage
->
setText
(
dataManager
.
GetSysString
(
1335
));
mainGame
->
stACMessage
->
setText
(
dataManager
.
GetSysString
(
1335
));
mainGame
->
PopupElement
(
mainGame
->
wACMessage
,
20
);
mainGame
->
PopupElement
(
mainGame
->
wACMessage
,
20
);
...
@@ -480,7 +488,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -480,7 +488,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
int
decksel
=
mainGame
->
lstDecks
->
getSelected
();
int
decksel
=
mainGame
->
lstDecks
->
getSelected
();
const
wchar_t
*
catename
=
mainGame
->
lstCategories
->
getListItem
(
catesel
);
const
wchar_t
*
catename
=
mainGame
->
lstCategories
->
getListItem
(
catesel
);
wchar_t
oldfilepath
[
256
];
wchar_t
oldfilepath
[
256
];
deckManager
.
GetDeckFile
(
oldfilepath
,
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
get_deck_file
(
oldfilepath
);
const
wchar_t
*
newdeckname
=
mainGame
->
ebDMName
->
getText
();
const
wchar_t
*
newdeckname
=
mainGame
->
ebDMName
->
getText
();
wchar_t
newfilepath
[
256
];
wchar_t
newfilepath
[
256
];
if
(
catesel
==
2
)
{
if
(
catesel
==
2
)
{
...
@@ -512,7 +520,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -512,7 +520,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
case
BUTTON_DELETE_DECK_DM
:
{
case
BUTTON_DELETE_DECK_DM
:
{
int
decksel
=
mainGame
->
lstDecks
->
getSelected
();
int
decksel
=
mainGame
->
lstDecks
->
getSelected
();
wchar_t
filepath
[
256
];
wchar_t
filepath
[
256
];
deckManager
.
GetDeckFile
(
filepath
,
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
get_deck_file
(
filepath
);
if
(
deckManager
.
DeleteDeck
(
filepath
))
{
if
(
deckManager
.
DeleteDeck
(
filepath
))
{
mainGame
->
lstDecks
->
removeItem
(
decksel
);
mainGame
->
lstDecks
->
removeItem
(
decksel
);
mainGame
->
cbDBDecks
->
removeItem
(
decksel
);
mainGame
->
cbDBDecks
->
removeItem
(
decksel
);
...
@@ -523,7 +531,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -523,7 +531,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
if
(
decksel
!=
-
1
)
{
if
(
decksel
!=
-
1
)
{
mainGame
->
lstDecks
->
setSelected
(
decksel
);
mainGame
->
lstDecks
->
setSelected
(
decksel
);
mainGame
->
cbDBDecks
->
setSelected
(
decksel
);
mainGame
->
cbDBDecks
->
setSelected
(
decksel
);
deckManager
.
LoadCurrentD
eck
(
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
load_current_d
eck
(
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
}
}
RefreshReadonly
(
prev_category
);
RefreshReadonly
(
prev_category
);
prev_deck
=
decksel
;
prev_deck
=
decksel
;
...
@@ -542,7 +550,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -542,7 +550,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
wchar_t
deckname
[
256
];
wchar_t
deckname
[
256
];
BufferIO
::
CopyWideString
(
olddeckname
,
deckname
);
BufferIO
::
CopyWideString
(
olddeckname
,
deckname
);
wchar_t
oldfilepath
[
256
];
wchar_t
oldfilepath
[
256
];
deckManager
.
GetDeckFile
(
oldfilepath
,
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
get_deck_file
(
oldfilepath
);
wchar_t
newfilepath
[
256
];
wchar_t
newfilepath
[
256
];
if
(
oldcatesel
!=
2
&&
newcatesel
==
0
)
{
if
(
oldcatesel
!=
2
&&
newcatesel
==
0
)
{
myswprintf
(
newfilepath
,
L"./deck/%ls.ydk"
,
deckname
);
myswprintf
(
newfilepath
,
L"./deck/%ls.ydk"
,
deckname
);
...
@@ -651,7 +659,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -651,7 +659,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break
;
break
;
}
}
case
BUTTON_SIDE_RELOAD
:
{
case
BUTTON_SIDE_RELOAD
:
{
deckManager
.
LoadCurrentD
eck
(
mainGame
->
cbCategorySelect
,
mainGame
->
cbDeckSelect
);
load_current_d
eck
(
mainGame
->
cbCategorySelect
,
mainGame
->
cbDeckSelect
);
break
;
break
;
}
}
case
BUTTON_BIG_CARD_ORIG_SIZE
:
{
case
BUTTON_BIG_CARD_ORIG_SIZE
:
{
...
@@ -689,7 +697,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -689,7 +697,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
int
sel
=
prev_sel
;
int
sel
=
prev_sel
;
mainGame
->
cbDBDecks
->
setSelected
(
sel
);
mainGame
->
cbDBDecks
->
setSelected
(
sel
);
wchar_t
filepath
[
256
];
wchar_t
filepath
[
256
];
deckManager
.
GetDeckFile
(
filepath
,
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
get_deck_file
(
filepath
);
if
(
deckManager
.
DeleteDeck
(
filepath
))
{
if
(
deckManager
.
DeleteDeck
(
filepath
))
{
mainGame
->
cbDBDecks
->
removeItem
(
sel
);
mainGame
->
cbDBDecks
->
removeItem
(
sel
);
int
count
=
mainGame
->
cbDBDecks
->
getItemCount
();
int
count
=
mainGame
->
cbDBDecks
->
getItemCount
();
...
@@ -697,7 +705,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -697,7 +705,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
sel
=
count
-
1
;
sel
=
count
-
1
;
mainGame
->
cbDBDecks
->
setSelected
(
sel
);
mainGame
->
cbDBDecks
->
setSelected
(
sel
);
if
(
sel
!=
-
1
)
if
(
sel
!=
-
1
)
deckManager
.
LoadCurrentD
eck
(
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
load_current_d
eck
(
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
mainGame
->
stACMessage
->
setText
(
dataManager
.
GetSysString
(
1338
));
mainGame
->
stACMessage
->
setText
(
dataManager
.
GetSysString
(
1338
));
mainGame
->
PopupElement
(
mainGame
->
wACMessage
,
20
);
mainGame
->
PopupElement
(
mainGame
->
wACMessage
,
20
);
prev_deck
=
sel
;
prev_deck
=
sel
;
...
@@ -711,7 +719,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -711,7 +719,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
ChangeCategory
(
catesel
);
ChangeCategory
(
catesel
);
}
else
if
(
prev_operation
==
COMBOBOX_DBDECKS
)
{
}
else
if
(
prev_operation
==
COMBOBOX_DBDECKS
)
{
int
decksel
=
mainGame
->
cbDBDecks
->
getSelected
();
int
decksel
=
mainGame
->
cbDBDecks
->
getSelected
();
deckManager
.
LoadCurrentD
eck
(
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
load_current_d
eck
(
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
prev_deck
=
decksel
;
prev_deck
=
decksel
;
is_modified
=
false
;
is_modified
=
false
;
}
else
if
(
prev_operation
==
BUTTON_MANAGE_DECK
)
{
}
else
if
(
prev_operation
==
BUTTON_MANAGE_DECK
)
{
...
@@ -828,7 +836,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -828,7 +836,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
}
}
int
decksel
=
mainGame
->
cbDBDecks
->
getSelected
();
int
decksel
=
mainGame
->
cbDBDecks
->
getSelected
();
if
(
decksel
>=
0
)
{
if
(
decksel
>=
0
)
{
deckManager
.
LoadCurrentD
eck
(
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
load_current_d
eck
(
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
}
}
prev_deck
=
decksel
;
prev_deck
=
decksel
;
is_modified
=
false
;
is_modified
=
false
;
...
@@ -1630,7 +1638,7 @@ void DeckBuilder::ChangeCategory(int catesel) {
...
@@ -1630,7 +1638,7 @@ void DeckBuilder::ChangeCategory(int catesel) {
mainGame
->
RefreshDeck
(
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
mainGame
->
RefreshDeck
(
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
mainGame
->
cbDBDecks
->
setSelected
(
0
);
mainGame
->
cbDBDecks
->
setSelected
(
0
);
RefreshReadonly
(
catesel
);
RefreshReadonly
(
catesel
);
deckManager
.
LoadCurrentD
eck
(
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
load_current_d
eck
(
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
is_modified
=
false
;
is_modified
=
false
;
prev_category
=
catesel
;
prev_category
=
catesel
;
prev_deck
=
0
;
prev_deck
=
0
;
...
...
gframe/deck_manager.cpp
View file @
e3475c17
#include "deck_manager.h"
#include "deck_manager.h"
#include "game.h"
#include "myfilesystem.h"
#include "myfilesystem.h"
#include "network.h"
#include "network.h"
#include "game.h"
namespace
ygo
{
namespace
ygo
{
...
@@ -10,30 +10,27 @@ DeckManager deckManager;
...
@@ -10,30 +10,27 @@ DeckManager deckManager;
void
DeckManager
::
LoadLFListSingle
(
const
char
*
path
)
{
void
DeckManager
::
LoadLFListSingle
(
const
char
*
path
)
{
auto
cur
=
_lfList
.
rend
();
auto
cur
=
_lfList
.
rend
();
FILE
*
fp
=
fopen
(
path
,
"r"
);
FILE
*
fp
=
std
::
fopen
(
path
,
"r"
);
char
linebuf
[
256
]{};
char
linebuf
[
256
]{};
wchar_t
strBuffer
[
256
]{};
wchar_t
strBuffer
[
256
]{};
if
(
fp
)
{
if
(
fp
)
{
while
(
fgets
(
linebuf
,
256
,
fp
))
{
while
(
std
::
fgets
(
linebuf
,
256
,
fp
))
{
if
(
linebuf
[
0
]
==
'#'
)
if
(
linebuf
[
0
]
==
'#'
)
continue
;
continue
;
if
(
linebuf
[
0
]
==
'!'
)
{
if
(
linebuf
[
0
]
==
'!'
)
{
int
sa
=
BufferIO
::
DecodeUTF8
(
&
linebuf
[
1
],
strBuffer
);
auto
len
=
std
::
strcspn
(
linebuf
,
"
\r\n
"
);
while
(
strBuffer
[
sa
-
1
]
==
L'\r'
||
strBuffer
[
sa
-
1
]
==
L'\n'
)
linebuf
[
len
]
=
0
;
sa
--
;
BufferIO
::
DecodeUTF8
(
&
linebuf
[
1
],
strBuffer
);
strBuffer
[
sa
]
=
0
;
LFList
newlist
;
LFList
newlist
;
newlist
.
listName
=
strBuffer
;
newlist
.
hash
=
0x7dfcee6a
;
_lfList
.
push_back
(
newlist
);
_lfList
.
push_back
(
newlist
);
cur
=
_lfList
.
rbegin
();
cur
=
_lfList
.
rbegin
();
cur
->
listName
=
strBuffer
;
cur
->
hash
=
0x7dfcee6a
;
continue
;
continue
;
}
}
if
(
linebuf
[
0
]
==
0
)
continue
;
int
code
=
0
;
int
code
=
0
;
int
count
=
-
1
;
int
count
=
-
1
;
if
(
sscanf
(
linebuf
,
"%d %d"
,
&
code
,
&
count
)
!=
2
)
if
(
s
td
::
s
scanf
(
linebuf
,
"%d %d"
,
&
code
,
&
count
)
!=
2
)
continue
;
continue
;
if
(
code
<=
0
||
code
>
MAX_CARD_ID
)
if
(
code
<=
0
||
code
>
MAX_CARD_ID
)
continue
;
continue
;
...
@@ -45,7 +42,7 @@ void DeckManager::LoadLFListSingle(const char* path) {
...
@@ -45,7 +42,7 @@ void DeckManager::LoadLFListSingle(const char* path) {
cur
->
content
[
code
]
=
count
;
cur
->
content
[
code
]
=
count
;
cur
->
hash
=
cur
->
hash
^
((
hcode
<<
18
)
|
(
hcode
>>
14
))
^
((
hcode
<<
(
27
+
count
))
|
(
hcode
>>
(
5
-
count
)));
cur
->
hash
=
cur
->
hash
^
((
hcode
<<
18
)
|
(
hcode
>>
14
))
^
((
hcode
<<
(
27
+
count
))
|
(
hcode
>>
(
5
-
count
)));
}
}
fclose
(
fp
);
std
::
fclose
(
fp
);
}
}
}
}
void
DeckManager
::
LoadLFList
()
{
void
DeckManager
::
LoadLFList
()
{
...
@@ -252,12 +249,11 @@ void DeckManager::GetCategoryPath(wchar_t* ret, int index, const wchar_t* text)
...
@@ -252,12 +249,11 @@ void DeckManager::GetCategoryPath(wchar_t* ret, int index, const wchar_t* text)
}
}
BufferIO
::
CopyWStr
(
catepath
,
ret
,
256
);
BufferIO
::
CopyWStr
(
catepath
,
ret
,
256
);
}
}
void
DeckManager
::
GetDeckFile
(
wchar_t
*
ret
,
i
rr
::
gui
::
IGUIComboBox
*
cbCategory
,
irr
::
gui
::
IGUIComboBox
*
cbDeck
)
{
void
DeckManager
::
GetDeckFile
(
wchar_t
*
ret
,
i
nt
category_index
,
const
wchar_t
*
category_name
,
const
wchar_t
*
deckname
)
{
wchar_t
filepath
[
256
];
wchar_t
filepath
[
256
];
wchar_t
catepath
[
256
];
wchar_t
catepath
[
256
];
const
wchar_t
*
deckname
=
cbDeck
->
getItem
(
cbDeck
->
getSelected
());
if
(
deckname
!=
nullptr
)
{
if
(
deckname
!=
nullptr
)
{
GetCategoryPath
(
catepath
,
c
bCategory
->
getSelected
(),
cbCategory
->
getText
()
);
GetCategoryPath
(
catepath
,
c
ategory_index
,
category_name
);
myswprintf
(
filepath
,
L"%ls/%ls.ydk"
,
catepath
,
deckname
);
myswprintf
(
filepath
,
L"%ls/%ls.ydk"
,
catepath
,
deckname
);
BufferIO
::
CopyWStr
(
filepath
,
ret
,
256
);
BufferIO
::
CopyWStr
(
filepath
,
ret
,
256
);
}
}
...
@@ -266,16 +262,16 @@ void DeckManager::GetDeckFile(wchar_t* ret, irr::gui::IGUIComboBox* cbCategory,
...
@@ -266,16 +262,16 @@ void DeckManager::GetDeckFile(wchar_t* ret, irr::gui::IGUIComboBox* cbCategory,
}
}
}
}
FILE
*
DeckManager
::
OpenDeckFile
(
const
wchar_t
*
file
,
const
char
*
mode
)
{
FILE
*
DeckManager
::
OpenDeckFile
(
const
wchar_t
*
file
,
const
char
*
mode
)
{
FILE
*
fp
=
myfopen
(
file
,
mode
);
FILE
*
fp
=
my
w
fopen
(
file
,
mode
);
return
fp
;
return
fp
;
}
}
IReadFile
*
DeckManager
::
OpenDeckReader
(
const
wchar_t
*
file
)
{
irr
::
io
::
IReadFile
*
DeckManager
::
OpenDeckReader
(
const
wchar_t
*
file
)
{
#ifdef _WIN32
#ifdef _WIN32
IReadFile
*
reader
=
DataManager
::
FileSystem
->
createAndOpenFile
(
file
);
auto
reader
=
DataManager
::
FileSystem
->
createAndOpenFile
(
file
);
#else
#else
char
file2
[
256
];
char
file2
[
256
];
BufferIO
::
EncodeUTF8
(
file
,
file2
);
BufferIO
::
EncodeUTF8
(
file
,
file2
);
IReadFile
*
reader
=
DataManager
::
FileSystem
->
createAndOpenFile
(
file2
);
auto
reader
=
DataManager
::
FileSystem
->
createAndOpenFile
(
file2
);
#endif
#endif
return
reader
;
return
reader
;
}
}
...
@@ -304,10 +300,10 @@ bool DeckManager::LoadCurrentDeck(const wchar_t* file, bool is_packlist) {
...
@@ -304,10 +300,10 @@ bool DeckManager::LoadCurrentDeck(const wchar_t* file, bool is_packlist) {
LoadDeck
(
current_deck
,
deckStream
,
is_packlist
);
LoadDeck
(
current_deck
,
deckStream
,
is_packlist
);
return
true
;
// the above LoadDeck has return value but we ignore it here for now
return
true
;
// the above LoadDeck has return value but we ignore it here for now
}
}
bool
DeckManager
::
LoadCurrentDeck
(
i
rr
::
gui
::
IGUIComboBox
*
cbCategory
,
irr
::
gui
::
IGUIComboBox
*
cbDeck
)
{
bool
DeckManager
::
LoadCurrentDeck
(
i
nt
category_index
,
const
wchar_t
*
category_name
,
const
wchar_t
*
deckname
)
{
wchar_t
filepath
[
256
];
wchar_t
filepath
[
256
];
GetDeckFile
(
filepath
,
c
bCategory
,
cbDeck
);
GetDeckFile
(
filepath
,
c
ategory_index
,
category_name
,
deckname
);
bool
is_packlist
=
cbCategory
->
getSelected
()
==
0
;
bool
is_packlist
=
(
category_index
==
0
)
;
bool
res
=
LoadCurrentDeck
(
filepath
,
is_packlist
);
bool
res
=
LoadCurrentDeck
(
filepath
,
is_packlist
);
if
(
res
&&
mainGame
->
is_building
)
if
(
res
&&
mainGame
->
is_building
)
mainGame
->
deckBuilder
.
RefreshPackListScroll
();
mainGame
->
deckBuilder
.
RefreshPackListScroll
();
...
@@ -319,16 +315,16 @@ bool DeckManager::SaveDeck(Deck& deck, const wchar_t* file) {
...
@@ -319,16 +315,16 @@ bool DeckManager::SaveDeck(Deck& deck, const wchar_t* file) {
FILE
*
fp
=
OpenDeckFile
(
file
,
"w"
);
FILE
*
fp
=
OpenDeckFile
(
file
,
"w"
);
if
(
!
fp
)
if
(
!
fp
)
return
false
;
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
)
for
(
size_t
i
=
0
;
i
<
deck
.
main
.
size
();
++
i
)
fprintf
(
fp
,
"%d
\n
"
,
deck
.
main
[
i
]
->
first
);
std
::
fprintf
(
fp
,
"%d
\n
"
,
deck
.
main
[
i
]
->
first
);
fprintf
(
fp
,
"#extra
\n
"
);
std
::
fprintf
(
fp
,
"#extra
\n
"
);
for
(
size_t
i
=
0
;
i
<
deck
.
extra
.
size
();
++
i
)
for
(
size_t
i
=
0
;
i
<
deck
.
extra
.
size
();
++
i
)
fprintf
(
fp
,
"%d
\n
"
,
deck
.
extra
[
i
]
->
first
);
std
::
fprintf
(
fp
,
"%d
\n
"
,
deck
.
extra
[
i
]
->
first
);
fprintf
(
fp
,
"!side
\n
"
);
std
::
fprintf
(
fp
,
"!side
\n
"
);
for
(
size_t
i
=
0
;
i
<
deck
.
side
.
size
();
++
i
)
for
(
size_t
i
=
0
;
i
<
deck
.
side
.
size
();
++
i
)
fprintf
(
fp
,
"%d
\n
"
,
deck
.
side
[
i
]
->
first
);
std
::
fprintf
(
fp
,
"%d
\n
"
,
deck
.
side
[
i
]
->
first
);
fclose
(
fp
);
std
::
fclose
(
fp
);
return
true
;
return
true
;
}
}
bool
DeckManager
::
DeleteDeck
(
const
wchar_t
*
file
)
{
bool
DeckManager
::
DeleteDeck
(
const
wchar_t
*
file
)
{
...
@@ -378,26 +374,26 @@ bool DeckManager::SaveDeckBuffer(const int deckbuf[], const wchar_t* name) {
...
@@ -378,26 +374,26 @@ bool DeckManager::SaveDeckBuffer(const int deckbuf[], const wchar_t* name) {
int
it
=
0
;
int
it
=
0
;
const
int
mainc
=
deckbuf
[
it
];
const
int
mainc
=
deckbuf
[
it
];
++
it
;
++
it
;
fprintf
(
fp
,
"#created by ...
\n
#main
\n
"
);
std
::
fprintf
(
fp
,
"#created by ...
\n
#main
\n
"
);
for
(
int
i
=
0
;
i
<
mainc
;
++
i
)
{
for
(
int
i
=
0
;
i
<
mainc
;
++
i
)
{
fprintf
(
fp
,
"%d
\n
"
,
deckbuf
[
it
]);
std
::
fprintf
(
fp
,
"%d
\n
"
,
deckbuf
[
it
]);
++
it
;
++
it
;
}
}
const
int
extrac
=
deckbuf
[
it
];
const
int
extrac
=
deckbuf
[
it
];
++
it
;
++
it
;
fprintf
(
fp
,
"#extra
\n
"
);
std
::
fprintf
(
fp
,
"#extra
\n
"
);
for
(
int
i
=
0
;
i
<
extrac
;
++
i
)
{
for
(
int
i
=
0
;
i
<
extrac
;
++
i
)
{
fprintf
(
fp
,
"%d
\n
"
,
deckbuf
[
it
]);
std
::
fprintf
(
fp
,
"%d
\n
"
,
deckbuf
[
it
]);
++
it
;
++
it
;
}
}
const
int
sidec
=
deckbuf
[
it
];
const
int
sidec
=
deckbuf
[
it
];
++
it
;
++
it
;
fprintf
(
fp
,
"!side
\n
"
);
std
::
fprintf
(
fp
,
"!side
\n
"
);
for
(
int
i
=
0
;
i
<
sidec
;
++
i
)
{
for
(
int
i
=
0
;
i
<
sidec
;
++
i
)
{
fprintf
(
fp
,
"%d
\n
"
,
deckbuf
[
it
]);
std
::
fprintf
(
fp
,
"%d
\n
"
,
deckbuf
[
it
]);
++
it
;
++
it
;
}
}
fclose
(
fp
);
std
::
fclose
(
fp
);
return
true
;
return
true
;
}
}
}
}
gframe/deck_manager.h
View file @
e3475c17
#ifndef DECKMANAGER_H
#ifndef DECKMANAGER_H
#define DECKMANAGER_H
#define DECKMANAGER_H
#include "config.h"
#include "data_manager.h"
#include <unordered_map>
#include <unordered_map>
#include <vector>
#include <vector>
#include <sstream>
#include <sstream>
#include "data_manager.h"
namespace
ygo
{
namespace
ygo
{
constexpr
int
DECK_MAX_SIZE
=
60
;
constexpr
int
DECK_MAX_SIZE
=
60
;
...
@@ -52,11 +51,11 @@ public:
...
@@ -52,11 +51,11 @@ public:
int
LoadDeck
(
Deck
&
deck
,
std
::
istringstream
&
deckStream
,
bool
is_packlist
=
false
);
int
LoadDeck
(
Deck
&
deck
,
std
::
istringstream
&
deckStream
,
bool
is_packlist
=
false
);
bool
LoadSide
(
Deck
&
deck
,
int
*
dbuf
,
int
mainc
,
int
sidec
);
bool
LoadSide
(
Deck
&
deck
,
int
*
dbuf
,
int
mainc
,
int
sidec
);
void
GetCategoryPath
(
wchar_t
*
ret
,
int
index
,
const
wchar_t
*
text
);
void
GetCategoryPath
(
wchar_t
*
ret
,
int
index
,
const
wchar_t
*
text
);
void
GetDeckFile
(
wchar_t
*
ret
,
i
rr
::
gui
::
IGUIComboBox
*
cbCategory
,
irr
::
gui
::
IGUIComboBox
*
cbDeck
);
void
GetDeckFile
(
wchar_t
*
ret
,
i
nt
category_index
,
const
wchar_t
*
category_name
,
const
wchar_t
*
deckname
);
FILE
*
OpenDeckFile
(
const
wchar_t
*
file
,
const
char
*
mode
);
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
(
const
wchar_t
*
file
,
bool
is_packlist
=
false
);
bool
LoadCurrentDeck
(
i
rr
::
gui
::
IGUIComboBox
*
cbCategory
,
irr
::
gui
::
IGUIComboBox
*
cbDeck
);
bool
LoadCurrentDeck
(
i
nt
category_index
,
const
wchar_t
*
category_name
,
const
wchar_t
*
deckname
);
bool
SaveDeck
(
Deck
&
deck
,
const
wchar_t
*
file
);
bool
SaveDeck
(
Deck
&
deck
,
const
wchar_t
*
file
);
bool
DeleteDeck
(
const
wchar_t
*
file
);
bool
DeleteDeck
(
const
wchar_t
*
file
);
bool
CreateCategory
(
const
wchar_t
*
name
);
bool
CreateCategory
(
const
wchar_t
*
name
);
...
...
gframe/game.cpp
View file @
e3475c17
...
@@ -1299,29 +1299,29 @@ void Game::RefreshBot() {
...
@@ -1299,29 +1299,29 @@ void Game::RefreshBot() {
if
(
!
gameConf
.
enable_bot_mode
)
if
(
!
gameConf
.
enable_bot_mode
)
return
;
return
;
botInfo
.
clear
();
botInfo
.
clear
();
FILE
*
fp
=
fopen
(
"bot.conf"
,
"r"
);
FILE
*
fp
=
std
::
fopen
(
"bot.conf"
,
"r"
);
char
linebuf
[
256
]{};
char
linebuf
[
256
]{};
char
strbuf
[
256
]{};
char
strbuf
[
256
]{};
if
(
fp
)
{
if
(
fp
)
{
while
(
fgets
(
linebuf
,
256
,
fp
))
{
while
(
std
::
fgets
(
linebuf
,
256
,
fp
))
{
if
(
linebuf
[
0
]
==
'#'
)
if
(
linebuf
[
0
]
==
'#'
)
continue
;
continue
;
if
(
linebuf
[
0
]
==
'!'
)
{
if
(
linebuf
[
0
]
==
'!'
)
{
BotInfo
newinfo
;
BotInfo
newinfo
;
if
(
sscanf
(
linebuf
,
"!%240[^
\n
]"
,
strbuf
)
!=
1
)
if
(
s
td
::
s
scanf
(
linebuf
,
"!%240[^
\n
]"
,
strbuf
)
!=
1
)
continue
;
continue
;
BufferIO
::
DecodeUTF8
(
strbuf
,
newinfo
.
name
);
BufferIO
::
DecodeUTF8
(
strbuf
,
newinfo
.
name
);
if
(
!
fgets
(
linebuf
,
256
,
fp
))
if
(
!
std
::
fgets
(
linebuf
,
256
,
fp
))
break
;
break
;
if
(
sscanf
(
linebuf
,
"%240[^
\n
]"
,
strbuf
)
!=
1
)
if
(
s
td
::
s
scanf
(
linebuf
,
"%240[^
\n
]"
,
strbuf
)
!=
1
)
continue
;
continue
;
BufferIO
::
DecodeUTF8
(
strbuf
,
newinfo
.
command
);
BufferIO
::
DecodeUTF8
(
strbuf
,
newinfo
.
command
);
if
(
!
fgets
(
linebuf
,
256
,
fp
))
if
(
!
std
::
fgets
(
linebuf
,
256
,
fp
))
break
;
break
;
if
(
sscanf
(
linebuf
,
"%240[^
\n
]"
,
strbuf
)
!=
1
)
if
(
s
td
::
s
scanf
(
linebuf
,
"%240[^
\n
]"
,
strbuf
)
!=
1
)
continue
;
continue
;
BufferIO
::
DecodeUTF8
(
strbuf
,
newinfo
.
desc
);
BufferIO
::
DecodeUTF8
(
strbuf
,
newinfo
.
desc
);
if
(
!
fgets
(
linebuf
,
256
,
fp
))
if
(
!
std
::
fgets
(
linebuf
,
256
,
fp
))
break
;
break
;
newinfo
.
support_master_rule_3
=
!!
std
::
strstr
(
linebuf
,
"SUPPORT_MASTER_RULE_3"
);
newinfo
.
support_master_rule_3
=
!!
std
::
strstr
(
linebuf
,
"SUPPORT_MASTER_RULE_3"
);
newinfo
.
support_new_master_rule
=
!!
std
::
strstr
(
linebuf
,
"SUPPORT_NEW_MASTER_RULE"
);
newinfo
.
support_new_master_rule
=
!!
std
::
strstr
(
linebuf
,
"SUPPORT_NEW_MASTER_RULE"
);
...
@@ -1335,7 +1335,7 @@ void Game::RefreshBot() {
...
@@ -1335,7 +1335,7 @@ void Game::RefreshBot() {
continue
;
continue
;
}
}
}
}
fclose
(
fp
);
std
::
fclose
(
fp
);
}
}
lstBotList
->
clear
();
lstBotList
->
clear
();
stBotInfo
->
setText
(
L""
);
stBotInfo
->
setText
(
L""
);
...
@@ -1352,14 +1352,14 @@ void Game::RefreshBot() {
...
@@ -1352,14 +1352,14 @@ void Game::RefreshBot() {
}
}
}
}
void
Game
::
LoadConfig
()
{
void
Game
::
LoadConfig
()
{
FILE
*
fp
=
fopen
(
"system.conf"
,
"r"
);
FILE
*
fp
=
std
::
fopen
(
"system.conf"
,
"r"
);
if
(
!
fp
)
if
(
!
fp
)
return
;
return
;
char
linebuf
[
CONFIG_LINE_SIZE
]{};
char
linebuf
[
CONFIG_LINE_SIZE
]{};
char
strbuf
[
64
]{};
char
strbuf
[
64
]{};
char
valbuf
[
960
]{};
char
valbuf
[
960
]{};
while
(
fgets
(
linebuf
,
sizeof
linebuf
,
fp
))
{
while
(
std
::
fgets
(
linebuf
,
sizeof
linebuf
,
fp
))
{
if
(
sscanf
(
linebuf
,
"%63s = %959s"
,
strbuf
,
valbuf
)
!=
2
)
if
(
s
td
::
s
scanf
(
linebuf
,
"%63s = %959s"
,
strbuf
,
valbuf
)
!=
2
)
continue
;
continue
;
if
(
!
std
::
strcmp
(
strbuf
,
"antialias"
))
{
if
(
!
std
::
strcmp
(
strbuf
,
"antialias"
))
{
gameConf
.
antialias
=
strtol
(
valbuf
,
nullptr
,
10
);
gameConf
.
antialias
=
strtol
(
valbuf
,
nullptr
,
10
);
...
@@ -1372,7 +1372,7 @@ void Game::LoadConfig() {
...
@@ -1372,7 +1372,7 @@ void Game::LoadConfig() {
enable_log
=
val
&
0xff
;
enable_log
=
val
&
0xff
;
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"textfont"
))
{
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"textfont"
))
{
int
textfontsize
=
0
;
int
textfontsize
=
0
;
if
(
sscanf
(
linebuf
,
"%63s = %959s %d"
,
strbuf
,
valbuf
,
&
textfontsize
)
!=
3
)
if
(
s
td
::
s
scanf
(
linebuf
,
"%63s = %959s %d"
,
strbuf
,
valbuf
,
&
textfontsize
)
!=
3
)
continue
;
continue
;
gameConf
.
textfontsize
=
textfontsize
;
gameConf
.
textfontsize
=
textfontsize
;
BufferIO
::
DecodeUTF8
(
valbuf
,
gameConf
.
textfont
);
BufferIO
::
DecodeUTF8
(
valbuf
,
gameConf
.
textfont
);
...
@@ -1470,7 +1470,7 @@ void Game::LoadConfig() {
...
@@ -1470,7 +1470,7 @@ void Game::LoadConfig() {
#endif
#endif
}
else
{
}
else
{
// options allowing multiple words
// options allowing multiple words
if
(
sscanf
(
linebuf
,
"%63s = %959[^
\n
]"
,
strbuf
,
valbuf
)
!=
2
)
if
(
s
td
::
s
scanf
(
linebuf
,
"%63s = %959[^
\n
]"
,
strbuf
,
valbuf
)
!=
2
)
continue
;
continue
;
if
(
!
std
::
strcmp
(
strbuf
,
"nickname"
))
{
if
(
!
std
::
strcmp
(
strbuf
,
"nickname"
))
{
BufferIO
::
DecodeUTF8
(
valbuf
,
gameConf
.
nickname
);
BufferIO
::
DecodeUTF8
(
valbuf
,
gameConf
.
nickname
);
...
@@ -1487,81 +1487,81 @@ void Game::LoadConfig() {
...
@@ -1487,81 +1487,81 @@ void Game::LoadConfig() {
}
}
}
}
}
}
fclose
(
fp
);
std
::
fclose
(
fp
);
}
}
void
Game
::
SaveConfig
()
{
void
Game
::
SaveConfig
()
{
FILE
*
fp
=
fopen
(
"system.conf"
,
"w"
);
FILE
*
fp
=
std
::
fopen
(
"system.conf"
,
"w"
);
fprintf
(
fp
,
"#config file
\n
#nickname & gamename should be less than 20 characters
\n
"
);
std
::
fprintf
(
fp
,
"#config file
\n
#nickname & gamename should be less than 20 characters
\n
"
);
char
linebuf
[
CONFIG_LINE_SIZE
];
char
linebuf
[
CONFIG_LINE_SIZE
];
fprintf
(
fp
,
"use_d3d = %d
\n
"
,
gameConf
.
use_d3d
?
1
:
0
);
std
::
fprintf
(
fp
,
"use_d3d = %d
\n
"
,
gameConf
.
use_d3d
?
1
:
0
);
fprintf
(
fp
,
"use_image_scale = %d
\n
"
,
gameConf
.
use_image_scale
?
1
:
0
);
std
::
fprintf
(
fp
,
"use_image_scale = %d
\n
"
,
gameConf
.
use_image_scale
?
1
:
0
);
fprintf
(
fp
,
"antialias = %d
\n
"
,
gameConf
.
antialias
);
std
::
fprintf
(
fp
,
"antialias = %d
\n
"
,
gameConf
.
antialias
);
fprintf
(
fp
,
"errorlog = %u
\n
"
,
enable_log
);
std
::
fprintf
(
fp
,
"errorlog = %u
\n
"
,
enable_log
);
BufferIO
::
CopyWideString
(
ebNickName
->
getText
(),
gameConf
.
nickname
);
BufferIO
::
CopyWideString
(
ebNickName
->
getText
(),
gameConf
.
nickname
);
BufferIO
::
EncodeUTF8
(
gameConf
.
nickname
,
linebuf
);
BufferIO
::
EncodeUTF8
(
gameConf
.
nickname
,
linebuf
);
fprintf
(
fp
,
"nickname = %s
\n
"
,
linebuf
);
std
::
fprintf
(
fp
,
"nickname = %s
\n
"
,
linebuf
);
BufferIO
::
EncodeUTF8
(
gameConf
.
gamename
,
linebuf
);
BufferIO
::
EncodeUTF8
(
gameConf
.
gamename
,
linebuf
);
fprintf
(
fp
,
"gamename = %s
\n
"
,
linebuf
);
std
::
fprintf
(
fp
,
"gamename = %s
\n
"
,
linebuf
);
BufferIO
::
EncodeUTF8
(
gameConf
.
lastcategory
,
linebuf
);
BufferIO
::
EncodeUTF8
(
gameConf
.
lastcategory
,
linebuf
);
fprintf
(
fp
,
"lastcategory = %s
\n
"
,
linebuf
);
std
::
fprintf
(
fp
,
"lastcategory = %s
\n
"
,
linebuf
);
BufferIO
::
EncodeUTF8
(
gameConf
.
lastdeck
,
linebuf
);
BufferIO
::
EncodeUTF8
(
gameConf
.
lastdeck
,
linebuf
);
fprintf
(
fp
,
"lastdeck = %s
\n
"
,
linebuf
);
std
::
fprintf
(
fp
,
"lastdeck = %s
\n
"
,
linebuf
);
BufferIO
::
EncodeUTF8
(
gameConf
.
textfont
,
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
);
BufferIO
::
EncodeUTF8
(
gameConf
.
numfont
,
linebuf
);
fprintf
(
fp
,
"numfont = %s
\n
"
,
linebuf
);
std
::
fprintf
(
fp
,
"numfont = %s
\n
"
,
linebuf
);
fprintf
(
fp
,
"serverport = %d
\n
"
,
gameConf
.
serverport
);
std
::
fprintf
(
fp
,
"serverport = %d
\n
"
,
gameConf
.
serverport
);
BufferIO
::
EncodeUTF8
(
gameConf
.
lasthost
,
linebuf
);
BufferIO
::
EncodeUTF8
(
gameConf
.
lasthost
,
linebuf
);
fprintf
(
fp
,
"lasthost = %s
\n
"
,
linebuf
);
std
::
fprintf
(
fp
,
"lasthost = %s
\n
"
,
linebuf
);
BufferIO
::
EncodeUTF8
(
gameConf
.
lastport
,
linebuf
);
BufferIO
::
EncodeUTF8
(
gameConf
.
lastport
,
linebuf
);
fprintf
(
fp
,
"lastport = %s
\n
"
,
linebuf
);
std
::
fprintf
(
fp
,
"lastport = %s
\n
"
,
linebuf
);
//settings
//settings
fprintf
(
fp
,
"automonsterpos = %d
\n
"
,
(
chkMAutoPos
->
isChecked
()
?
1
:
0
));
std
::
fprintf
(
fp
,
"automonsterpos = %d
\n
"
,
(
chkMAutoPos
->
isChecked
()
?
1
:
0
));
fprintf
(
fp
,
"autospellpos = %d
\n
"
,
(
chkSTAutoPos
->
isChecked
()
?
1
:
0
));
std
::
fprintf
(
fp
,
"autospellpos = %d
\n
"
,
(
chkSTAutoPos
->
isChecked
()
?
1
:
0
));
fprintf
(
fp
,
"randompos = %d
\n
"
,
(
chkRandomPos
->
isChecked
()
?
1
:
0
));
std
::
fprintf
(
fp
,
"randompos = %d
\n
"
,
(
chkRandomPos
->
isChecked
()
?
1
:
0
));
fprintf
(
fp
,
"autochain = %d
\n
"
,
(
chkAutoChain
->
isChecked
()
?
1
:
0
));
std
::
fprintf
(
fp
,
"autochain = %d
\n
"
,
(
chkAutoChain
->
isChecked
()
?
1
:
0
));
fprintf
(
fp
,
"waitchain = %d
\n
"
,
(
chkWaitChain
->
isChecked
()
?
1
:
0
));
std
::
fprintf
(
fp
,
"waitchain = %d
\n
"
,
(
chkWaitChain
->
isChecked
()
?
1
:
0
));
fprintf
(
fp
,
"showchain = %d
\n
"
,
(
chkDefaultShowChain
->
isChecked
()
?
1
:
0
));
std
::
fprintf
(
fp
,
"showchain = %d
\n
"
,
(
chkDefaultShowChain
->
isChecked
()
?
1
:
0
));
fprintf
(
fp
,
"mute_opponent = %d
\n
"
,
(
chkIgnore1
->
isChecked
()
?
1
:
0
));
std
::
fprintf
(
fp
,
"mute_opponent = %d
\n
"
,
(
chkIgnore1
->
isChecked
()
?
1
:
0
));
fprintf
(
fp
,
"mute_spectators = %d
\n
"
,
(
chkIgnore2
->
isChecked
()
?
1
:
0
));
std
::
fprintf
(
fp
,
"mute_spectators = %d
\n
"
,
(
chkIgnore2
->
isChecked
()
?
1
:
0
));
fprintf
(
fp
,
"use_lflist = %d
\n
"
,
gameConf
.
use_lflist
);
std
::
fprintf
(
fp
,
"use_lflist = %d
\n
"
,
gameConf
.
use_lflist
);
fprintf
(
fp
,
"default_lflist = %d
\n
"
,
gameConf
.
default_lflist
);
std
::
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
);
std
::
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
);
std
::
fprintf
(
fp
,
"hide_setname = %d
\n
"
,
gameConf
.
hide_setname
);
fprintf
(
fp
,
"hide_hint_button = %d
\n
"
,
gameConf
.
hide_hint_button
);
std
::
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
"
);
std
::
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
);
std
::
fprintf
(
fp
,
"control_mode = %d
\n
"
,
gameConf
.
control_mode
);
fprintf
(
fp
,
"draw_field_spell = %d
\n
"
,
gameConf
.
draw_field_spell
);
std
::
fprintf
(
fp
,
"draw_field_spell = %d
\n
"
,
gameConf
.
draw_field_spell
);
fprintf
(
fp
,
"separate_clear_button = %d
\n
"
,
gameConf
.
separate_clear_button
);
std
::
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
"
);
std
::
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
);
std
::
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
"
);
std
::
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
);
std
::
fprintf
(
fp
,
"search_multiple_keywords = %d
\n
"
,
gameConf
.
search_multiple_keywords
);
fprintf
(
fp
,
"ignore_deck_changes = %d
\n
"
,
(
chkIgnoreDeckChanges
->
isChecked
()
?
1
:
0
));
std
::
fprintf
(
fp
,
"ignore_deck_changes = %d
\n
"
,
(
chkIgnoreDeckChanges
->
isChecked
()
?
1
:
0
));
fprintf
(
fp
,
"default_ot = %d
\n
"
,
gameConf
.
defaultOT
);
std
::
fprintf
(
fp
,
"default_ot = %d
\n
"
,
gameConf
.
defaultOT
);
fprintf
(
fp
,
"enable_bot_mode = %d
\n
"
,
gameConf
.
enable_bot_mode
);
std
::
fprintf
(
fp
,
"enable_bot_mode = %d
\n
"
,
gameConf
.
enable_bot_mode
);
BufferIO
::
EncodeUTF8
(
gameConf
.
bot_deck_path
,
linebuf
);
BufferIO
::
EncodeUTF8
(
gameConf
.
bot_deck_path
,
linebuf
);
fprintf
(
fp
,
"bot_deck_path = %s
\n
"
,
linebuf
);
std
::
fprintf
(
fp
,
"bot_deck_path = %s
\n
"
,
linebuf
);
fprintf
(
fp
,
"quick_animation = %d
\n
"
,
gameConf
.
quick_animation
);
std
::
fprintf
(
fp
,
"quick_animation = %d
\n
"
,
gameConf
.
quick_animation
);
fprintf
(
fp
,
"auto_save_replay = %d
\n
"
,
(
chkAutoSaveReplay
->
isChecked
()
?
1
:
0
));
std
::
fprintf
(
fp
,
"auto_save_replay = %d
\n
"
,
(
chkAutoSaveReplay
->
isChecked
()
?
1
:
0
));
fprintf
(
fp
,
"draw_single_chain = %d
\n
"
,
gameConf
.
draw_single_chain
);
std
::
fprintf
(
fp
,
"draw_single_chain = %d
\n
"
,
gameConf
.
draw_single_chain
);
fprintf
(
fp
,
"hide_player_name = %d
\n
"
,
gameConf
.
hide_player_name
);
std
::
fprintf
(
fp
,
"hide_player_name = %d
\n
"
,
gameConf
.
hide_player_name
);
fprintf
(
fp
,
"prefer_expansion_script = %d
\n
"
,
gameConf
.
prefer_expansion_script
);
std
::
fprintf
(
fp
,
"prefer_expansion_script = %d
\n
"
,
gameConf
.
prefer_expansion_script
);
fprintf
(
fp
,
"window_maximized = %d
\n
"
,
(
gameConf
.
window_maximized
?
1
:
0
));
std
::
fprintf
(
fp
,
"window_maximized = %d
\n
"
,
(
gameConf
.
window_maximized
?
1
:
0
));
fprintf
(
fp
,
"window_width = %d
\n
"
,
gameConf
.
window_width
);
std
::
fprintf
(
fp
,
"window_width = %d
\n
"
,
gameConf
.
window_width
);
fprintf
(
fp
,
"window_height = %d
\n
"
,
gameConf
.
window_height
);
std
::
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
,
"resize_popup_menu = %d
\n
"
,
gameConf
.
resize_popup_menu
?
1
:
0
);
#ifdef YGOPRO_USE_IRRKLANG
#ifdef YGOPRO_USE_IRRKLANG
fprintf
(
fp
,
"enable_sound = %d
\n
"
,
(
chkEnableSound
->
isChecked
()
?
1
:
0
));
std
::
fprintf
(
fp
,
"enable_sound = %d
\n
"
,
(
chkEnableSound
->
isChecked
()
?
1
:
0
));
fprintf
(
fp
,
"enable_music = %d
\n
"
,
(
chkEnableMusic
->
isChecked
()
?
1
:
0
));
std
::
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
,
"#Volume of sound and music, between 0 and 100
\n
"
);
int
vol
=
gameConf
.
sound_volume
*
100
;
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
;
vol
=
gameConf
.
music_volume
*
100
;
fprintf
(
fp
,
"music_volume = %d
\n
"
,
vol
);
std
::
fprintf
(
fp
,
"music_volume = %d
\n
"
,
vol
);
fprintf
(
fp
,
"music_mode = %d
\n
"
,
(
chkMusicMode
->
isChecked
()
?
1
:
0
));
std
::
fprintf
(
fp
,
"music_mode = %d
\n
"
,
(
chkMusicMode
->
isChecked
()
?
1
:
0
));
#endif
#endif
fclose
(
fp
);
std
::
fclose
(
fp
);
}
}
void
Game
::
ShowCardInfo
(
int
code
,
bool
resize
)
{
void
Game
::
ShowCardInfo
(
int
code
,
bool
resize
)
{
if
(
showingcode
==
code
&&
!
resize
)
if
(
showingcode
==
code
&&
!
resize
)
...
@@ -1738,19 +1738,19 @@ void Game::AddDebugMsg(const char* msg) {
...
@@ -1738,19 +1738,19 @@ void Game::AddDebugMsg(const char* msg) {
}
}
if
(
enable_log
&
0x2
)
{
if
(
enable_log
&
0x2
)
{
char
msgbuf
[
1040
];
char
msgbuf
[
1040
];
snprintf
(
msgbuf
,
sizeof
msgbuf
,
"[Script Error]: %s"
,
msg
);
s
td
::
s
nprintf
(
msgbuf
,
sizeof
msgbuf
,
"[Script Error]: %s"
,
msg
);
ErrorLog
(
msgbuf
);
ErrorLog
(
msgbuf
);
}
}
}
}
void
Game
::
ErrorLog
(
const
char
*
msg
)
{
void
Game
::
ErrorLog
(
const
char
*
msg
)
{
FILE
*
fp
=
fopen
(
"error.log"
,
"at"
);
FILE
*
fp
=
std
::
fopen
(
"error.log"
,
"at"
);
if
(
!
fp
)
if
(
!
fp
)
return
;
return
;
time_t
nowtime
=
std
::
time
(
nullptr
);
time_t
nowtime
=
std
::
time
(
nullptr
);
char
timebuf
[
40
];
char
timebuf
[
40
];
std
::
strftime
(
timebuf
,
sizeof
timebuf
,
"%Y-%m-%d %H:%M:%S"
,
std
::
localtime
(
&
nowtime
));
std
::
strftime
(
timebuf
,
sizeof
timebuf
,
"%Y-%m-%d %H:%M:%S"
,
std
::
localtime
(
&
nowtime
));
fprintf
(
fp
,
"[%s]%s
\n
"
,
timebuf
,
msg
);
std
::
fprintf
(
fp
,
"[%s]%s
\n
"
,
timebuf
,
msg
);
fclose
(
fp
);
std
::
fclose
(
fp
);
}
}
void
Game
::
ClearTextures
()
{
void
Game
::
ClearTextures
()
{
matManager
.
mCard
.
setTexture
(
0
,
0
);
matManager
.
mCard
.
setTexture
(
0
,
0
);
...
...
gframe/image_manager.cpp
View file @
e3475c17
...
@@ -234,10 +234,10 @@ irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) {
...
@@ -234,10 +234,10 @@ irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) {
auto
tit
=
tMap
[
fit
?
1
:
0
].
find
(
code
);
auto
tit
=
tMap
[
fit
?
1
:
0
].
find
(
code
);
if
(
tit
==
tMap
[
fit
?
1
:
0
].
end
())
{
if
(
tit
==
tMap
[
fit
?
1
:
0
].
end
())
{
char
file
[
256
];
char
file
[
256
];
snprintf
(
file
,
sizeof
file
,
"expansions/pics/%d.jpg"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"expansions/pics/%d.jpg"
,
code
);
irr
::
video
::
ITexture
*
img
=
GetTextureFromFile
(
file
,
width
,
height
);
irr
::
video
::
ITexture
*
img
=
GetTextureFromFile
(
file
,
width
,
height
);
if
(
img
==
nullptr
)
{
if
(
img
==
nullptr
)
{
snprintf
(
file
,
sizeof
file
,
"pics/%d.jpg"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"pics/%d.jpg"
,
code
);
img
=
GetTextureFromFile
(
file
,
width
,
height
);
img
=
GetTextureFromFile
(
file
,
width
,
height
);
}
}
if
(
img
==
nullptr
&&
!
mainGame
->
gameConf
.
use_image_scale
)
{
if
(
img
==
nullptr
&&
!
mainGame
->
gameConf
.
use_image_scale
)
{
...
@@ -261,10 +261,10 @@ irr::video::ITexture* ImageManager::GetBigPicture(int code, float zoom) {
...
@@ -261,10 +261,10 @@ irr::video::ITexture* ImageManager::GetBigPicture(int code, float zoom) {
}
}
irr
::
video
::
ITexture
*
texture
;
irr
::
video
::
ITexture
*
texture
;
char
file
[
256
];
char
file
[
256
];
snprintf
(
file
,
sizeof
file
,
"expansions/pics/%d.jpg"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"expansions/pics/%d.jpg"
,
code
);
irr
::
video
::
IImage
*
srcimg
=
driver
->
createImageFromFile
(
file
);
irr
::
video
::
IImage
*
srcimg
=
driver
->
createImageFromFile
(
file
);
if
(
srcimg
==
nullptr
)
{
if
(
srcimg
==
nullptr
)
{
snprintf
(
file
,
sizeof
file
,
"pics/%d.jpg"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"pics/%d.jpg"
,
code
);
srcimg
=
driver
->
createImageFromFile
(
file
);
srcimg
=
driver
->
createImageFromFile
(
file
);
}
}
if
(
srcimg
==
nullptr
)
{
if
(
srcimg
==
nullptr
)
{
...
@@ -290,18 +290,18 @@ int ImageManager::LoadThumbThread() {
...
@@ -290,18 +290,18 @@ int ImageManager::LoadThumbThread() {
imageManager
.
tThumbLoadingCodes
.
pop
();
imageManager
.
tThumbLoadingCodes
.
pop
();
imageManager
.
tThumbLoadingMutex
.
unlock
();
imageManager
.
tThumbLoadingMutex
.
unlock
();
char
file
[
256
];
char
file
[
256
];
snprintf
(
file
,
sizeof
file
,
"expansions/pics/thumbnail/%d.jpg"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"expansions/pics/thumbnail/%d.jpg"
,
code
);
irr
::
video
::
IImage
*
img
=
imageManager
.
driver
->
createImageFromFile
(
file
);
irr
::
video
::
IImage
*
img
=
imageManager
.
driver
->
createImageFromFile
(
file
);
if
(
img
==
nullptr
)
{
if
(
img
==
nullptr
)
{
snprintf
(
file
,
sizeof
file
,
"pics/thumbnail/%d.jpg"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"pics/thumbnail/%d.jpg"
,
code
);
img
=
imageManager
.
driver
->
createImageFromFile
(
file
);
img
=
imageManager
.
driver
->
createImageFromFile
(
file
);
}
}
if
(
img
==
nullptr
&&
mainGame
->
gameConf
.
use_image_scale
)
{
if
(
img
==
nullptr
&&
mainGame
->
gameConf
.
use_image_scale
)
{
snprintf
(
file
,
sizeof
file
,
"expansions/pics/%d.jpg"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"expansions/pics/%d.jpg"
,
code
);
img
=
imageManager
.
driver
->
createImageFromFile
(
file
);
img
=
imageManager
.
driver
->
createImageFromFile
(
file
);
}
}
if
(
img
==
nullptr
&&
mainGame
->
gameConf
.
use_image_scale
)
{
if
(
img
==
nullptr
&&
mainGame
->
gameConf
.
use_image_scale
)
{
snprintf
(
file
,
sizeof
file
,
"pics/%d.jpg"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"pics/%d.jpg"
,
code
);
img
=
imageManager
.
driver
->
createImageFromFile
(
file
);
img
=
imageManager
.
driver
->
createImageFromFile
(
file
);
}
}
if
(
img
!=
nullptr
)
{
if
(
img
!=
nullptr
)
{
...
@@ -346,7 +346,7 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
...
@@ -346,7 +346,7 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
if
(
lit
!=
tThumbLoading
.
end
())
{
if
(
lit
!=
tThumbLoading
.
end
())
{
if
(
lit
->
second
!=
nullptr
)
{
if
(
lit
->
second
!=
nullptr
)
{
char
file
[
256
];
char
file
[
256
];
snprintf
(
file
,
sizeof
file
,
"pics/thumbnail/%d.jpg"
,
code
);
s
td
::
s
nprintf
(
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
irr
::
video
::
ITexture
*
texture
=
driver
->
addTexture
(
file
,
lit
->
second
);
// textures must be added in the main thread due to OpenGL
lit
->
second
->
drop
();
lit
->
second
->
drop
();
tThumb
[
code
]
=
texture
;
tThumb
[
code
]
=
texture
;
...
@@ -379,18 +379,18 @@ irr::video::ITexture* ImageManager::GetTextureField(int code) {
...
@@ -379,18 +379,18 @@ irr::video::ITexture* ImageManager::GetTextureField(int code) {
auto
tit
=
tFields
.
find
(
code
);
auto
tit
=
tFields
.
find
(
code
);
if
(
tit
==
tFields
.
end
())
{
if
(
tit
==
tFields
.
end
())
{
char
file
[
256
];
char
file
[
256
];
snprintf
(
file
,
sizeof
file
,
"expansions/pics/field/%d.png"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"expansions/pics/field/%d.png"
,
code
);
irr
::
video
::
ITexture
*
img
=
GetTextureFromFile
(
file
,
512
*
mainGame
->
xScale
,
512
*
mainGame
->
yScale
);
irr
::
video
::
ITexture
*
img
=
GetTextureFromFile
(
file
,
512
*
mainGame
->
xScale
,
512
*
mainGame
->
yScale
);
if
(
img
==
nullptr
)
{
if
(
img
==
nullptr
)
{
snprintf
(
file
,
sizeof
file
,
"expansions/pics/field/%d.jpg"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"expansions/pics/field/%d.jpg"
,
code
);
img
=
GetTextureFromFile
(
file
,
512
*
mainGame
->
xScale
,
512
*
mainGame
->
yScale
);
img
=
GetTextureFromFile
(
file
,
512
*
mainGame
->
xScale
,
512
*
mainGame
->
yScale
);
}
}
if
(
img
==
nullptr
)
{
if
(
img
==
nullptr
)
{
snprintf
(
file
,
sizeof
file
,
"pics/field/%d.png"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"pics/field/%d.png"
,
code
);
img
=
GetTextureFromFile
(
file
,
512
*
mainGame
->
xScale
,
512
*
mainGame
->
yScale
);
img
=
GetTextureFromFile
(
file
,
512
*
mainGame
->
xScale
,
512
*
mainGame
->
yScale
);
}
}
if
(
img
==
nullptr
)
{
if
(
img
==
nullptr
)
{
snprintf
(
file
,
sizeof
file
,
"pics/field/%d.jpg"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"pics/field/%d.jpg"
,
code
);
img
=
GetTextureFromFile
(
file
,
512
*
mainGame
->
xScale
,
512
*
mainGame
->
yScale
);
img
=
GetTextureFromFile
(
file
,
512
*
mainGame
->
xScale
,
512
*
mainGame
->
yScale
);
if
(
img
==
nullptr
)
{
if
(
img
==
nullptr
)
{
tFields
[
code
]
=
nullptr
;
tFields
[
code
]
=
nullptr
;
...
...
gframe/menu_handler.cpp
View file @
e3475c17
...
@@ -176,7 +176,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
...
@@ -176,7 +176,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
}
}
case
BUTTON_HP_READY
:
{
case
BUTTON_HP_READY
:
{
if
(
mainGame
->
cbCategorySelect
->
getSelected
()
==
-
1
||
mainGame
->
cbDeckSelect
->
getSelected
()
==
-
1
||
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
();
mainGame
->
gMutex
.
lock
();
soundManager
.
PlaySoundEffect
(
SOUND_INFO
);
soundManager
.
PlaySoundEffect
(
SOUND_INFO
);
mainGame
->
env
->
addMessageBox
(
L""
,
dataManager
.
GetSysString
(
1406
));
mainGame
->
env
->
addMessageBox
(
L""
,
dataManager
.
GetSysString
(
1406
));
...
@@ -367,7 +367,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
...
@@ -367,7 +367,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
wchar_t
arg1
[
512
];
wchar_t
arg1
[
512
];
if
(
mainGame
->
botInfo
[
sel
].
select_deckfile
)
{
if
(
mainGame
->
botInfo
[
sel
].
select_deckfile
)
{
wchar_t
botdeck
[
256
];
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
);
myswprintf
(
arg1
,
L"%ls DeckFile='%ls'"
,
mainGame
->
botInfo
[
sel
].
command
,
botdeck
);
}
}
else
else
...
@@ -386,7 +386,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
...
@@ -386,7 +386,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
wchar_t
warg1
[
512
];
wchar_t
warg1
[
512
];
if
(
mainGame
->
botInfo
[
sel
].
select_deckfile
)
{
if
(
mainGame
->
botInfo
[
sel
].
select_deckfile
)
{
wchar_t
botdeck
[
256
];
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
);
myswprintf
(
warg1
,
L"%ls DeckFile='%ls'"
,
mainGame
->
botInfo
[
sel
].
command
,
botdeck
);
}
}
else
else
...
@@ -396,9 +396,9 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
...
@@ -396,9 +396,9 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int
flag
=
0
;
int
flag
=
0
;
flag
+=
(
mainGame
->
chkBotHand
->
isChecked
()
?
0x1
:
0
);
flag
+=
(
mainGame
->
chkBotHand
->
isChecked
()
?
0x1
:
0
);
char
arg2
[
8
];
char
arg2
[
8
];
snprintf
(
arg2
,
sizeof
arg2
,
"%d"
,
flag
);
s
td
::
s
nprintf
(
arg2
,
sizeof
arg2
,
"%d"
,
flag
);
char
arg3
[
8
];
char
arg3
[
8
];
snprintf
(
arg3
,
sizeof
arg3
,
"%d"
,
mainGame
->
gameConf
.
serverport
);
s
td
::
s
nprintf
(
arg3
,
sizeof
arg3
,
"%d"
,
mainGame
->
gameConf
.
serverport
);
execl
(
"./bot"
,
"bot"
,
arg1
,
arg2
,
arg3
,
nullptr
);
execl
(
"./bot"
,
"bot"
,
arg1
,
arg2
,
arg3
,
nullptr
);
exit
(
0
);
exit
(
0
);
}
else
{
}
else
{
...
@@ -472,7 +472,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
...
@@ -472,7 +472,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
open_file
=
false
;
open_file
=
false
;
}
}
else
if
(
mainGame
->
cbDBCategory
->
getSelected
()
!=
-
1
&&
mainGame
->
cbDBDecks
->
getSelected
()
!=
-
1
)
{
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
->
ebDeckname
->
setText
(
L""
);
}
}
mainGame
->
HideElement
(
mainGame
->
wMainMenu
);
mainGame
->
HideElement
(
mainGame
->
wMainMenu
);
...
@@ -581,7 +581,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
...
@@ -581,7 +581,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
const
wchar_t
*
name
=
mainGame
->
lstSinglePlayList
->
getListItem
(
sel
);
const
wchar_t
*
name
=
mainGame
->
lstSinglePlayList
->
getListItem
(
sel
);
wchar_t
fname
[
256
];
wchar_t
fname
[
256
];
myswprintf
(
fname
,
L"./single/%ls"
,
name
);
myswprintf
(
fname
,
L"./single/%ls"
,
name
);
FILE
*
fp
=
myfopen
(
fname
,
"rb"
);
FILE
*
fp
=
my
w
fopen
(
fname
,
"rb"
);
if
(
!
fp
)
{
if
(
!
fp
)
{
mainGame
->
stSinglePlayInfo
->
setText
(
L""
);
mainGame
->
stSinglePlayInfo
->
setText
(
L""
);
break
;
break
;
...
@@ -590,7 +590,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
...
@@ -590,7 +590,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
wchar_t
wlinebuf
[
1024
];
wchar_t
wlinebuf
[
1024
];
std
::
wstring
message
=
L""
;
std
::
wstring
message
=
L""
;
bool
in_message
=
false
;
bool
in_message
=
false
;
while
(
fgets
(
linebuf
,
1024
,
fp
))
{
while
(
std
::
fgets
(
linebuf
,
1024
,
fp
))
{
if
(
!
std
::
strncmp
(
linebuf
,
"--[[message"
,
11
))
{
if
(
!
std
::
strncmp
(
linebuf
,
"--[[message"
,
11
))
{
size_t
len
=
std
::
strlen
(
linebuf
);
size_t
len
=
std
::
strlen
(
linebuf
);
char
*
msgend
=
std
::
strrchr
(
linebuf
,
']'
);
char
*
msgend
=
std
::
strrchr
(
linebuf
,
']'
);
...
@@ -613,7 +613,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
...
@@ -613,7 +613,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
message
.
append
(
wlinebuf
);
message
.
append
(
wlinebuf
);
}
}
}
}
fclose
(
fp
);
std
::
fclose
(
fp
);
mainGame
->
SetStaticText
(
mainGame
->
stSinglePlayInfo
,
200
,
mainGame
->
guiFont
,
message
.
c_str
());
mainGame
->
SetStaticText
(
mainGame
->
stSinglePlayInfo
,
200
,
mainGame
->
guiFont
,
message
.
c_str
());
break
;
break
;
}
}
...
@@ -637,7 +637,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
...
@@ -637,7 +637,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame
->
env
->
setFocus
(
mainGame
->
wHostPrepare
);
mainGame
->
env
->
setFocus
(
mainGame
->
wHostPrepare
);
if
(
static_cast
<
irr
::
gui
::
IGUICheckBox
*>
(
caller
)
->
isChecked
())
{
if
(
static_cast
<
irr
::
gui
::
IGUICheckBox
*>
(
caller
)
->
isChecked
())
{
if
(
mainGame
->
cbCategorySelect
->
getSelected
()
==
-
1
||
mainGame
->
cbDeckSelect
->
getSelected
()
==
-
1
||
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
();
mainGame
->
gMutex
.
lock
();
static_cast
<
irr
::
gui
::
IGUICheckBox
*>
(
caller
)
->
setChecked
(
false
);
static_cast
<
irr
::
gui
::
IGUICheckBox
*>
(
caller
)
->
setChecked
(
false
);
soundManager
.
PlaySoundEffect
(
SOUND_INFO
);
soundManager
.
PlaySoundEffect
(
SOUND_INFO
);
...
...
gframe/myfilesystem.h
View file @
e3475c17
...
@@ -94,7 +94,7 @@ public:
...
@@ -94,7 +94,7 @@ public:
if
(
fh
==
INVALID_HANDLE_VALUE
)
if
(
fh
==
INVALID_HANDLE_VALUE
)
return
;
return
;
do
{
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
));
cb
(
fdataw
.
cFileName
,
(
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
));
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
FindClose
(
fh
);
FindClose
(
fh
);
...
@@ -216,7 +216,7 @@ public:
...
@@ -216,7 +216,7 @@ public:
stat
(
fname
,
&
fileStat
);
stat
(
fname
,
&
fileStat
);
funit
.
filename
=
std
::
string
(
dirp
->
d_name
);
funit
.
filename
=
std
::
string
(
dirp
->
d_name
);
funit
.
is_dir
=
S_ISDIR
(
fileStat
.
st_mode
);
funit
.
is_dir
=
S_ISDIR
(
fileStat
.
st_mode
);
if
(
funit
.
is_dir
&&
(
st
rcmp
(
dirp
->
d_name
,
"."
)
==
0
||
strcmp
(
dirp
->
d_name
,
".."
)
==
0
))
if
(
funit
.
is_dir
&&
(
st
d
::
strcmp
(
dirp
->
d_name
,
"."
)
==
0
||
std
::
strcmp
(
dirp
->
d_name
,
".."
)
==
0
))
continue
;
continue
;
file_list
.
push_back
(
funit
);
file_list
.
push_back
(
funit
);
}
}
...
...
gframe/replay.cpp
View file @
e3475c17
...
@@ -23,8 +23,8 @@ void Replay::BeginRecord() {
...
@@ -23,8 +23,8 @@ void Replay::BeginRecord() {
return
;
return
;
#else
#else
if
(
is_recording
)
if
(
is_recording
)
fclose
(
fp
);
std
::
fclose
(
fp
);
fp
=
fopen
(
"./replay/_LastReplay.yrp"
,
"wb"
);
fp
=
std
::
fopen
(
"./replay/_LastReplay.yrp"
,
"wb"
);
if
(
!
fp
)
if
(
!
fp
)
return
;
return
;
#endif
#endif
...
@@ -39,8 +39,8 @@ void Replay::WriteHeader(ReplayHeader& header) {
...
@@ -39,8 +39,8 @@ void Replay::WriteHeader(ReplayHeader& header) {
DWORD
size
;
DWORD
size
;
WriteFile
(
recording_fp
,
&
header
,
sizeof
(
header
),
&
size
,
nullptr
);
WriteFile
(
recording_fp
,
&
header
,
sizeof
(
header
),
&
size
,
nullptr
);
#else
#else
fwrite
(
&
header
,
sizeof
(
header
),
1
,
fp
);
std
::
fwrite
(
&
header
,
sizeof
(
header
),
1
,
fp
);
fflush
(
fp
);
std
::
fflush
(
fp
);
#endif
#endif
}
}
void
Replay
::
WriteData
(
const
void
*
data
,
size_t
length
,
bool
flush
)
{
void
Replay
::
WriteData
(
const
void
*
data
,
size_t
length
,
bool
flush
)
{
...
@@ -54,9 +54,9 @@ void Replay::WriteData(const void* data, size_t length, bool flush) {
...
@@ -54,9 +54,9 @@ void Replay::WriteData(const void* data, size_t length, bool flush) {
DWORD
size
;
DWORD
size
;
WriteFile
(
recording_fp
,
data
,
length
,
&
size
,
nullptr
);
WriteFile
(
recording_fp
,
data
,
length
,
&
size
,
nullptr
);
#else
#else
fwrite
(
data
,
length
,
1
,
fp
);
std
::
fwrite
(
data
,
length
,
1
,
fp
);
if
(
flush
)
if
(
flush
)
fflush
(
fp
);
std
::
fflush
(
fp
);
#endif
#endif
}
}
void
Replay
::
WriteInt32
(
int32_t
data
,
bool
flush
)
{
void
Replay
::
WriteInt32
(
int32_t
data
,
bool
flush
)
{
...
@@ -67,7 +67,7 @@ void Replay::Flush() {
...
@@ -67,7 +67,7 @@ void Replay::Flush() {
return
;
return
;
#ifdef _WIN32
#ifdef _WIN32
#else
#else
fflush
(
fp
);
std
::
fflush
(
fp
);
#endif
#endif
}
}
void
Replay
::
EndRecord
()
{
void
Replay
::
EndRecord
()
{
...
@@ -76,7 +76,7 @@ void Replay::EndRecord() {
...
@@ -76,7 +76,7 @@ void Replay::EndRecord() {
#ifdef _WIN32
#ifdef _WIN32
CloseHandle
(
recording_fp
);
CloseHandle
(
recording_fp
);
#else
#else
fclose
(
fp
);
std
::
fclose
(
fp
);
#endif
#endif
pheader
.
datasize
=
replay_size
;
pheader
.
datasize
=
replay_size
;
pheader
.
flag
|=
REPLAY_COMPRESSED
;
pheader
.
flag
|=
REPLAY_COMPRESSED
;
...
@@ -94,19 +94,19 @@ void Replay::SaveReplay(const wchar_t* name) {
...
@@ -94,19 +94,19 @@ void Replay::SaveReplay(const wchar_t* name) {
return
;
return
;
wchar_t
fname
[
256
];
wchar_t
fname
[
256
];
myswprintf
(
fname
,
L"./replay/%ls.yrp"
,
name
);
myswprintf
(
fname
,
L"./replay/%ls.yrp"
,
name
);
FILE
*
rfp
=
myfopen
(
fname
,
"wb"
);
FILE
*
rfp
=
my
w
fopen
(
fname
,
"wb"
);
if
(
!
rfp
)
if
(
!
rfp
)
return
;
return
;
fwrite
(
&
pheader
,
sizeof
pheader
,
1
,
rfp
);
std
::
fwrite
(
&
pheader
,
sizeof
pheader
,
1
,
rfp
);
fwrite
(
comp_data
,
comp_size
,
1
,
rfp
);
std
::
fwrite
(
comp_data
,
comp_size
,
1
,
rfp
);
fclose
(
rfp
);
std
::
fclose
(
rfp
);
}
}
bool
Replay
::
OpenReplay
(
const
wchar_t
*
name
)
{
bool
Replay
::
OpenReplay
(
const
wchar_t
*
name
)
{
FILE
*
rfp
=
myfopen
(
name
,
"rb"
);
FILE
*
rfp
=
my
w
fopen
(
name
,
"rb"
);
if
(
!
rfp
)
{
if
(
!
rfp
)
{
wchar_t
fname
[
256
];
wchar_t
fname
[
256
];
myswprintf
(
fname
,
L"./replay/%ls"
,
name
);
myswprintf
(
fname
,
L"./replay/%ls"
,
name
);
rfp
=
myfopen
(
fname
,
"rb"
);
rfp
=
my
w
fopen
(
fname
,
"rb"
);
}
}
if
(
!
rfp
)
if
(
!
rfp
)
return
false
;
return
false
;
...
@@ -116,13 +116,13 @@ bool Replay::OpenReplay(const wchar_t* name) {
...
@@ -116,13 +116,13 @@ bool Replay::OpenReplay(const wchar_t* name) {
is_replaying
=
false
;
is_replaying
=
false
;
replay_size
=
0
;
replay_size
=
0
;
comp_size
=
0
;
comp_size
=
0
;
if
(
fread
(
&
pheader
,
sizeof
pheader
,
1
,
rfp
)
<
1
)
{
if
(
std
::
fread
(
&
pheader
,
sizeof
pheader
,
1
,
rfp
)
<
1
)
{
fclose
(
rfp
);
std
::
fclose
(
rfp
);
return
false
;
return
false
;
}
}
if
(
pheader
.
flag
&
REPLAY_COMPRESSED
)
{
if
(
pheader
.
flag
&
REPLAY_COMPRESSED
)
{
comp_size
=
fread
(
comp_data
,
1
,
MAX_COMP_SIZE
,
rfp
);
comp_size
=
std
::
fread
(
comp_data
,
1
,
MAX_COMP_SIZE
,
rfp
);
fclose
(
rfp
);
std
::
fclose
(
rfp
);
if
(
pheader
.
datasize
>
MAX_REPLAY_SIZE
)
if
(
pheader
.
datasize
>
MAX_REPLAY_SIZE
)
return
false
;
return
false
;
replay_size
=
pheader
.
datasize
;
replay_size
=
pheader
.
datasize
;
...
@@ -133,8 +133,8 @@ bool Replay::OpenReplay(const wchar_t* name) {
...
@@ -133,8 +133,8 @@ bool Replay::OpenReplay(const wchar_t* name) {
return
false
;
return
false
;
}
}
}
else
{
}
else
{
replay_size
=
fread
(
replay_data
,
1
,
MAX_REPLAY_SIZE
,
rfp
);
replay_size
=
std
::
fread
(
replay_data
,
1
,
MAX_REPLAY_SIZE
,
rfp
);
fclose
(
rfp
);
std
::
fclose
(
rfp
);
comp_size
=
0
;
comp_size
=
0
;
}
}
is_replaying
=
true
;
is_replaying
=
true
;
...
@@ -143,12 +143,12 @@ bool Replay::OpenReplay(const wchar_t* name) {
...
@@ -143,12 +143,12 @@ bool Replay::OpenReplay(const wchar_t* name) {
bool
Replay
::
CheckReplay
(
const
wchar_t
*
name
)
{
bool
Replay
::
CheckReplay
(
const
wchar_t
*
name
)
{
wchar_t
fname
[
256
];
wchar_t
fname
[
256
];
myswprintf
(
fname
,
L"./replay/%ls"
,
name
);
myswprintf
(
fname
,
L"./replay/%ls"
,
name
);
FILE
*
rfp
=
myfopen
(
fname
,
"rb"
);
FILE
*
rfp
=
my
w
fopen
(
fname
,
"rb"
);
if
(
!
rfp
)
if
(
!
rfp
)
return
false
;
return
false
;
ReplayHeader
rheader
;
ReplayHeader
rheader
;
size_t
count
=
fread
(
&
rheader
,
sizeof
rheader
,
1
,
rfp
);
size_t
count
=
std
::
fread
(
&
rheader
,
sizeof
rheader
,
1
,
rfp
);
fclose
(
rfp
);
std
::
fclose
(
rfp
);
return
count
==
1
&&
rheader
.
id
==
0x31707279
&&
rheader
.
version
>=
0x12d0u
&&
(
rheader
.
version
<
0x1353u
||
(
rheader
.
flag
&
REPLAY_UNIFORM
));
return
count
==
1
&&
rheader
.
id
==
0x31707279
&&
rheader
.
version
>=
0x12d0u
&&
(
rheader
.
version
<
0x1353u
||
(
rheader
.
flag
&
REPLAY_UNIFORM
));
}
}
bool
Replay
::
DeleteReplay
(
const
wchar_t
*
name
)
{
bool
Replay
::
DeleteReplay
(
const
wchar_t
*
name
)
{
...
...
premake/freetype/premake5.lua
View file @
e3475c17
...
@@ -43,6 +43,10 @@ project "freetype"
...
@@ -43,6 +43,10 @@ project "freetype"
"src/type42/type42.c"
,
"src/type42/type42.c"
,
"src/winfonts/winfnt.c"
}
"src/winfonts/winfnt.c"
}
if
os
.
isfile
(
"src/svg/svg.c"
)
then
files
{
"src/svg/svg.c"
}
end
filter
"system:windows"
filter
"system:windows"
files
{
"builds/windows/ftsystem.c"
,
files
{
"builds/windows/ftsystem.c"
,
"builds/windows/ftdebug.c"
}
"builds/windows/ftdebug.c"
}
...
...
premake/irrlicht/irrlicht.patch
deleted
100644 → 0
View file @
28bb4121
diff --git a/include/IOSOperator.h b/include/IOSOperator.h
index 2ab75a1..b574950 100644
--- a/include/IOSOperator.h
+++ b/include/IOSOperator.h
@@ -26,11 +26,11 @@
public:
}
//! Copies text to the clipboard
- virtual void copyToClipboard(const c8* text) const = 0;
+ virtual void copyToClipboard(const c16* text) const = 0;
//! Get text from the clipboard
/** \return Returns 0 if no string is in there. */
- virtual const c8* getTextFromClipboard() const = 0;
+ virtual const c16* getTextFromClipboard() const = 0;
//! Get the processor speed in megahertz
/** \param MHz The integer variable to store the speed in.
diff --git a/include/irrString.h b/include/irrString.h
index 43557cd..ffa06bc 100644
--- a/include/irrString.h
+++ b/include/irrString.h
@@ -1360,6 +1360,15 @@
typedef string<c8> stringc;
//! Typedef for wide character strings
typedef string<wchar_t> stringw;
+//! wrap of mbstowcs
+static inline wchar_t* toWideChar(const char* p)
+{
+ size_t lenOld = strlen(p);
+ wchar_t* ws = new wchar_t[lenOld + 1];
+ size_t lenNew = mbstowcs(ws, p, lenOld);
+ ws[lenNew] = 0;
+ return ws;
+}
} // end namespace core
} // end namespace irr
diff --git a/include/irrTypes.h b/include/irrTypes.h
index 403f890..940e859 100644
--- a/include/irrTypes.h
+++ b/include/irrTypes.h
@@ -48,6 +48,9 @@
typedef __int16 s16;
typedef signed short s16;
#endif
+//! 16 bit character variable.
+/** This is a typedef for wchar_t, it ensures portability of the engine. */
+typedef wchar_t c16;
//! 32 bit unsigned variable.
diff --git a/source/Irrlicht/CGUIEditBox.cpp b/source/Irrlicht/CGUIEditBox.cpp
index 395fb69..cc6b75f 100644
--- a/source/Irrlicht/CGUIEditBox.cpp
+++ b/source/Irrlicht/CGUIEditBox.cpp
@@ -287,7 +287,7 @@
bool CGUIEditBox::processKey(const SEvent& event)
const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd;
const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin;
- core::stringc s;
+ core::stringw s;
s = Text.subString(realmbgn, realmend - realmbgn).c_str();
Operator->copyToClipboard(s.c_str());
}
@@ -300,7 +300,7 @@
bool CGUIEditBox::processKey(const SEvent& event)
const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin;
// copy
- core::stringc sc;
+ core::stringw sc;
sc = Text.subString(realmbgn, realmend - realmbgn).c_str();
Operator->copyToClipboard(sc.c_str());
@@ -330,16 +330,10 @@
bool CGUIEditBox::processKey(const SEvent& event)
const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin;
// add new character
- const c8* p = Operator->getTextFromClipboard();
+ const c16* p = Operator->getTextFromClipboard();
if (p)
{
- // TODO: we should have such a function in core::string
- size_t lenOld = strlen(p);
- wchar_t *ws = new wchar_t[lenOld + 1];
- size_t len = mbstowcs(ws,p,lenOld);
- ws[len] = 0;
- irr::core::stringw widep(ws);
- delete[] ws;
+ irr::core::stringw widep(p);
if (MarkBegin == MarkEnd)
{
@@ -664,6 +658,16 @@
bool CGUIEditBox::processKey(const SEvent& event)
case KEY_ESCAPE:
case KEY_TAB:
case KEY_SHIFT:
+ case KEY_LSHIFT:
+ case KEY_RSHIFT:
+ case KEY_MENU:
+ case KEY_LMENU:
+ case KEY_RMENU:
+ case KEY_LWIN:
+ case KEY_RWIN:
+ case KEY_CAPITAL:
+ case KEY_NUMLOCK:
+ case KEY_SCROLL:
case KEY_F1:
case KEY_F2:
case KEY_F3:
diff --git a/source/Irrlicht/CGUIListBox.cpp b/source/Irrlicht/CGUIListBox.cpp
index 2c19a43..eb834a4 100644
--- a/source/Irrlicht/CGUIListBox.cpp
+++ b/source/Irrlicht/CGUIListBox.cpp
@@ -425,7 +425,7 @@
bool CGUIListBox::OnEvent(const SEvent& event)
}
case EMIE_MOUSE_MOVED:
- if (Selecting || MoveOverSelect)
+ if (MoveOverSelect)
{
if (isPointInside(p))
{
diff --git a/source/Irrlicht/CIrrDeviceLinux.cpp b/source/Irrlicht/CIrrDeviceLinux.cpp
index 39b1888..d359957 100644
--- a/source/Irrlicht/CIrrDeviceLinux.cpp
+++ b/source/Irrlicht/CIrrDeviceLinux.cpp
@@ -63,6 +63,7 @@
namespace
Atom X_ATOM_TARGETS;
Atom X_ATOM_UTF8_STRING;
Atom X_ATOM_TEXT;
+ Atom X_ATOM_XSEL_DATA;
};
namespace irr
@@ -1106,11 +1107,14 @@
bool CIrrDeviceLinux::run()
{
XEvent respond;
XSelectionRequestEvent *req = &(event.xselectionrequest);
- if ( req->target == XA_STRING)
+ if ( req->target == XA_STRING
+ || req->target == X_ATOM_TEXT
+ || req->target == X_ATOM_UTF8_STRING )
{
XChangeProperty (display,
req->requestor,
- req->property, req->target,
+ req->property,
+ req->target == X_ATOM_TEXT ? XA_STRING : req->target,
8, // format
PropModeReplace,
(unsigned char*) Clipboard.c_str(),
@@ -1124,11 +1128,14 @@
bool CIrrDeviceLinux::run()
data[0] = X_ATOM_TEXT;
data[1] = XA_STRING;
- XChangeProperty (display, req->requestor,
- req->property, req->target,
- 8, PropModeReplace,
- (unsigned char *) &data,
- sizeof (data));
+ XChangeProperty (display,
+ req->requestor,
+ req->property,
+ XA_ATOM,
+ 32, // format
+ PropModeReplace,
+ (unsigned char *) &X_ATOM_UTF8_STRING,
+ 1);
respond.xselection.property = req->property;
}
else
@@ -1875,34 +1882,36 @@
const c8* CIrrDeviceLinux::getTextFromClipboard() const
Clipboard = "";
if (ownerWindow != None )
{
- XConvertSelection (display, X_ATOM_CLIPBOARD, XA_STRING, XA_PRIMARY, ownerWindow, CurrentTime);
- XFlush (display);
-
- // check for data
- Atom type;
- int format;
- unsigned long numItems, bytesLeft, dummy;
- unsigned char *data;
- XGetWindowProperty (display, ownerWindow,
- XA_PRIMARY, // property name
- 0, // offset
- 0, // length (we only check for data, so 0)
+ XConvertSelection (display, X_ATOM_CLIPBOARD, X_ATOM_UTF8_STRING, X_ATOM_XSEL_DATA, window, CurrentTime);
+ XSync (display, 0);
+ XEvent event;
+ do nanosleep ((const struct timespec[]){{0, 1L}}, NULL);
+ while (!XCheckTypedEvent (display, SelectionNotify, &event));
+ if ( (event.xselection.selection == X_ATOM_CLIPBOARD) && event.xselection.property )
+ {
+ Atom type;
+ int format;
+ unsigned long size, dummy;
+ unsigned char *data;
+ int result = XGetWindowProperty (event.xselection.display,
+ event.xselection.requestor,
+ event.xselection.property,
+ 0L, // offset
+ (~0L), // length (max)
0, // Delete 0==false
AnyPropertyType, // AnyPropertyType or property identifier
&type, // return type
&format, // return format
- &numItems, // number items
- &bytesLeft, // remaining bytes for partial reads
+ &size, // number items
+ &dummy, // remaining bytes for partial reads
&data); // data
- if ( bytesLeft > 0 )
- {
- // there is some data to get
- int result = XGetWindowProperty (display, ownerWindow, XA_PRIMARY, 0,
- bytesLeft, 0, AnyPropertyType, &type, &format,
- &numItems, &dummy, &data);
- if (result == Success)
- Clipboard = (irr::c8*)data;
- XFree (data);
+ if ( result == Success
+ && (type == X_ATOM_UTF8_STRING || type == XA_STRING) ) // not implemented: INCR (partial reads)
+ {
+ Clipboard = strndup((char*)data, size);
+ XFree (data);
+ }
+ XDeleteProperty (event.xselection.display, event.xselection.requestor, event.xselection.property);
}
}
@@ -1966,6 +1975,7 @@
void CIrrDeviceLinux::initXAtoms()
X_ATOM_TARGETS = XInternAtom(display, "TARGETS", False);
X_ATOM_UTF8_STRING = XInternAtom (display, "UTF8_STRING", False);
X_ATOM_TEXT = XInternAtom (display, "TEXT", False);
+ X_ATOM_XSEL_DATA = XInternAtom (display, "XSEL_DATA", False);
#endif
}
diff --git a/source/Irrlicht/CIrrDeviceWin32.cpp b/source/Irrlicht/CIrrDeviceWin32.cpp
index 28290cb..76dfea1 100644
--- a/source/Irrlicht/CIrrDeviceWin32.cpp
+++ b/source/Irrlicht/CIrrDeviceWin32.cpp
@@ -20,6 +20,8 @@
#include "COSOperator.h"
#include "dimension2d.h"
#include "IGUISpriteBank.h"
+#include "IGUIEnvironment.h"
+#include "IGUIElement.h"
#include <winuser.h>
#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
#ifdef _IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_
@@ -749,6 +751,24 @@
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
return 0;
}
+ dev = getDeviceFromHWnd(hWnd);
+ if (dev)
+ {
+ irr::gui::IGUIElement* ele = dev->getGUIEnvironment()->getFocus();
+ if (!ele || (ele->getType() != irr::gui::EGUIET_EDIT_BOX) || !ele->isEnabled())
+ {
+ HIMC hIMC = ImmGetContext(hWnd);
+ if (hIMC)
+ {
+ ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_COMPLETE, 0);
+ ImmReleaseContext(hWnd, hIMC);
+ }
+ ImmAssociateContextEx(hWnd, NULL, 0);
+ }
+ else
+ ImmAssociateContextEx(hWnd, NULL, IACE_DEFAULT);
+ }
+
switch (message)
{
case WM_PAINT:
@@ -773,7 +793,11 @@
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
event.KeyInput.Key = (irr::EKEY_CODE)wParam;
event.KeyInput.PressedDown = (message==WM_KEYDOWN || message == WM_SYSKEYDOWN);
+#ifdef MAPVK_VSC_TO_VK_EX
+ const UINT MY_MAPVK_VSC_TO_VK_EX = MAPVK_VSC_TO_VK_EX;
+#else
const UINT MY_MAPVK_VSC_TO_VK_EX = 3; // MAPVK_VSC_TO_VK_EX should be in SDK according to MSDN, but isn't in mine.
+#endif
if ( event.KeyInput.Key == irr::KEY_SHIFT )
{
// this will fail on systems before windows NT/2000/XP, not sure _what_ will return there instead.
@@ -904,6 +928,53 @@
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
KEYBOARD_INPUT_HKL = GetKeyboardLayout(0);
KEYBOARD_INPUT_CODEPAGE = LocaleIdToCodepage( LOWORD(KEYBOARD_INPUT_HKL) );
return 0;
+
+ case WM_IME_STARTCOMPOSITION:
+ {
+ dev = getDeviceFromHWnd(hWnd);
+ irr::gui::IGUIElement* ele = dev->getGUIEnvironment()->getFocus();
+ if (!ele)
+ break;
+ irr::core::position2di pos = ele->getAbsolutePosition().UpperLeftCorner;
+ COMPOSITIONFORM CompForm = { CFS_POINT, { pos.X, pos.Y + ele->getAbsolutePosition().getHeight() } };
+ HIMC hIMC = ImmGetContext(hWnd);
+ ImmSetCompositionWindow(hIMC, &CompForm);
+ ImmReleaseContext(hWnd, hIMC);
+ }
+ break;
+
+ case WM_IME_CHAR:
+ event.EventType = irr::EET_KEY_INPUT_EVENT;
+ event.KeyInput.PressedDown = true;
+#ifdef _UNICODE
+ event.KeyInput.Char = wParam;
+#else
+ BYTE ch[3];
+ if (wParam >> 8) {
+ ch[0] = wParam >> 8;
+ ch[1] = wParam & 0xff;
+ ch[2] = 0;
+ } else {
+ ch[0] = wParam;
+ ch[1] = 0;
+ }
+ WORD unicodeChar;
+ MultiByteToWideChar(
+ KEYBOARD_INPUT_CODEPAGE,
+ MB_PRECOMPOSED, // default
+ (LPCSTR)ch,
+ sizeof(wParam),
+ (WCHAR*)&unicodeChar,
+ 1);
+ event.KeyInput.Char = unicodeChar;
+#endif
+ event.KeyInput.Key = irr::KEY_ACCEPT;
+ event.KeyInput.Shift = 0;
+ event.KeyInput.Control = 0;
+ dev = getDeviceFromHWnd(hWnd);
+ if (dev)
+ dev->postEventFromUser(event);
+ return 0;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
@@ -1797,8 +1868,8 @@
void CIrrDeviceWin32::handleSystemMessages()
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
- // No message translation because we don't use WM_CHAR and it would conflict with our
- // deadkey handling.
+ // conflict with deadkey handling.
+ TranslateMessage(&msg);
if (ExternalWindow && msg.hwnd == HWnd)
WndProc(HWnd, msg.message, msg.wParam, msg.lParam);
diff --git a/source/Irrlicht/COSOperator.cpp b/source/Irrlicht/COSOperator.cpp
index c5e4552..3b00628 100644
--- a/source/Irrlicht/COSOperator.cpp
+++ b/source/Irrlicht/COSOperator.cpp
@@ -9,6 +9,7 @@
#include <windows.h>
#endif
#else
+#include <locale.h>
#include <string.h>
#include <unistd.h>
#ifndef _IRR_SOLARIS_PLATFORM_
@@ -54,9 +55,10 @@
const core::stringc& COSOperator::getOperatingSystemVersion() const
//! copies text to the clipboard
-void COSOperator::copyToClipboard(const c8* text) const
+void COSOperator::copyToClipboard(const c16* text) const
{
- if (strlen(text)==0)
+ size_t len = wcslen(text);
+ if (len==0)
return;
// Windows version
@@ -68,15 +70,15 @@
void COSOperator::copyToClipboard(const c8* text) const
EmptyClipboard();
HGLOBAL clipbuffer;
- char * buffer;
+ wchar_t * buffer;
- clipbuffer = GlobalAlloc(GMEM_DDESHARE, strlen(text)+1);
- buffer = (char*)GlobalLock(clipbuffer);
+ clipbuffer = GlobalAlloc(GMEM_DDESHARE, sizeof(wchar_t) * (len + 1));
+ buffer = (wchar_t*)GlobalLock(clipbuffer);
- strcpy(buffer, text);
+ wcscpy(buffer, text);
GlobalUnlock(clipbuffer);
- SetClipboardData(CF_TEXT, clipbuffer);
+ SetClipboardData(CF_UNICODETEXT, clipbuffer);
CloseClipboard();
// MacOSX version
@@ -86,7 +88,18 @@
void COSOperator::copyToClipboard(const c8* text) const
#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_)
if ( IrrDeviceLinux )
- IrrDeviceLinux->copyToClipboard(text);
+ {
+ size_t wlen = sizeof(wchar_t) * (len + 1);
+ char ctext[wlen];
+
+ char* oldLocale = setlocale(LC_CTYPE, NULL);
+ setlocale(LC_CTYPE, "");
+ size_t lenNew = wcstombs(ctext, text, wlen);
+ ctext[lenNew] = 0;
+ setlocale(LC_CTYPE, oldLocale);
+
+ IrrDeviceLinux->copyToClipboard(ctext);
+ }
#else
#endif
@@ -95,7 +108,7 @@
void COSOperator::copyToClipboard(const c8* text) const
//! gets text from the clipboard
//! \return Returns 0 if no string is in there.
-const c8* COSOperator::getTextFromClipboard() const
+const c16* COSOperator::getTextFromClipboard() const
{
#if defined(_IRR_XBOX_PLATFORM_)
return 0;
@@ -103,10 +116,10 @@
const c8* COSOperator::getTextFromClipboard() const
if (!OpenClipboard(NULL))
return 0;
- char * buffer = 0;
+ wchar_t * buffer = 0;
- HANDLE hData = GetClipboardData( CF_TEXT );
- buffer = (char*)GlobalLock( hData );
+ HANDLE hData = GetClipboardData( CF_UNICODETEXT );
+ buffer = (wchar_t*)GlobalLock( hData );
GlobalUnlock( hData );
CloseClipboard();
return buffer;
@@ -116,7 +129,16 @@
const c8* COSOperator::getTextFromClipboard() const
#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_)
if ( IrrDeviceLinux )
- return IrrDeviceLinux->getTextFromClipboard();
+ {
+ const c8 * p = IrrDeviceLinux->getTextFromClipboard();
+
+ char* oldLocale = setlocale(LC_CTYPE, NULL);
+ setlocale(LC_CTYPE, "");
+ wchar_t* ws = core::toWideChar(p);
+ setlocale(LC_CTYPE, oldLocale);
+
+ return ws;
+ }
return 0;
#else
diff --git a/source/Irrlicht/COSOperator.h b/source/Irrlicht/COSOperator.h
index 819805f..a86cb6e 100644
--- a/source/Irrlicht/COSOperator.h
+++ b/source/Irrlicht/COSOperator.h
@@ -27,11 +27,11 @@
public:
virtual const core::stringc& getOperatingSystemVersion() const;
//! copies text to the clipboard
- virtual void copyToClipboard(const c8* text) const;
+ virtual void copyToClipboard(const c16* text) const;
//! gets text from the clipboard
//! \return Returns 0 if no string is in there.
- virtual const c8* getTextFromClipboard() const;
+ virtual const c16* getTextFromClipboard() const;
//! gets the processor speed in megahertz
//! \param Mhz:
diff --git a/source/Irrlicht/MacOSX/AppDelegate.h b/source/Irrlicht/MacOSX/AppDelegate.h
index ccb116d..29705f2 100644
--- a/source/Irrlicht/MacOSX/AppDelegate.h
+++ b/source/Irrlicht/MacOSX/AppDelegate.h
@@ -10,7 +10,7 @@
#import <Cocoa/Cocoa.h>
#import "CIrrDeviceMacOSX.h"
-@interface AppDelegate : NSObject
+@interface AppDelegate : NSTextView <NSApplicationDelegate>
{
BOOL _quit;
irr::CIrrDeviceMacOSX *_device;
diff --git a/source/Irrlicht/MacOSX/AppDelegate.mm b/source/Irrlicht/MacOSX/AppDelegate.mm
index 14a7f86..37f6a51 100644
--- a/source/Irrlicht/MacOSX/AppDelegate.mm
+++ b/source/Irrlicht/MacOSX/AppDelegate.mm
@@ -74,6 +74,35 @@
return (_quit);
}
+- (void)keyDown:(NSEvent *)event
+{
+ [self interpretKeyEvents:@[event]];
+}
+
+- (void)insertText:(id)string
+{
+ [self setString: @""];
+ if ([string isKindOfClass:[NSAttributedString class]])
+ {
+ _device->handleInputEvent([[string string] UTF8String]);
+ }
+ else
+ {
+ _device->handleInputEvent([string UTF8String]);
+ }
+}
+
+- (void)doCommandBySelector:(SEL)selector
+{
+ _device->processKeyEvent();
+}
+
+- (void)paste:(id)sender
+{
+ // TODO: pass the pasted string. Now we discard it otherwise it will be kept in the editbox.
+ [self setString: @""];
+}
+
@end
#endif // _IRR_COMPILE_WITH_OSX_DEVICE_
diff --git a/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h b/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h
index f629588..d2fefae 100644
--- a/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h
+++ b/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h
@@ -95,6 +95,8 @@
namespace irr
void setMouseLocation(int x, int y);
void setResize(int width, int height);
void setCursorVisible(bool visible);
+ void handleInputEvent(const char *str);
+ void processKeyEvent();
private:
diff --git a/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm b/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm
index 60da342..8fd8f4a 100644
--- a/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm
+++ b/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm
@@ -592,6 +592,31 @@
void CIrrDeviceMacOSX::closeDevice()
CGLContext = NULL;
}
+void CIrrDeviceMacOSX::processKeyEvent()
+{
+ irr::SEvent ievent;
+ NSEvent *event = [[NSApplication sharedApplication] currentEvent];
+ postKeyEvent(event, ievent, true);
+}
+
+void CIrrDeviceMacOSX::handleInputEvent(const char *cStr)
+{
+ SEvent ievent;
+ irr::core::stringw widep(irr::core::toWideChar(cStr));
+
+ ievent.EventType = irr::EET_KEY_INPUT_EVENT;
+ ievent.KeyInput.Key = (irr::EKEY_CODE)0;
+ ievent.KeyInput.PressedDown = true;
+ ievent.KeyInput.Shift = false;
+ ievent.KeyInput.Control = false;
+
+ for (int i = 0; i < widep.size(); ++i)
+ {
+ ievent.KeyInput.Char = widep[i];
+ postEventFromUser(ievent);
+ }
+}
+
bool CIrrDeviceMacOSX::createWindow()
{
CGDisplayErr error;
@@ -721,14 +746,20 @@
bool CIrrDeviceMacOSX::createWindow()
[Window setDelegate:(id<NSWindowDelegate>)[NSApp delegate]];
if(CreationParams.DriverType == video::EDT_OPENGL)
+ {
+ [[Window contentView] setWantsBestResolutionOpenGLSurface:NO];
[OGLContext setView:[Window contentView]];
+ }
[Window setAcceptsMouseMovedEvents:TRUE];
[Window setIsVisible:TRUE];
[Window makeKeyAndOrderFront:nil];
}
else if(CreationParams.DriverType == video::EDT_OPENGL) //use another window for drawing
+ {
+ [(NSView*)CreationParams.WindowId setWantsBestResolutionOpenGLSurface:NO];
[OGLContext setView:(NSView*)CreationParams.WindowId];
+ }
if (CreationParams.DriverType == video::EDT_OPENGL)
CGLContext = (CGLContextObj) [OGLContext CGLContextObj];
@@ -881,6 +912,8 @@
bool CIrrDeviceMacOSX::createWindow()
newSwapInterval = (CreationParams.Vsync) ? 1 : 0;
CGLSetParameter(CGLContext,kCGLCPSwapInterval,&newSwapInterval);
}
+
+ [[Window contentView] addSubview:(AppDelegate*)[NSApp delegate]];
}
return (result);
@@ -971,6 +1004,41 @@
bool CIrrDeviceMacOSX::run()
os::Timer::tick();
storeMouseLocation();
+ auto focusElement = getGUIEnvironment()->getFocus();
+ bool editing = focusElement && focusElement->getType() == irr::gui::EGUIET_EDIT_BOX;
+ auto textView = (NSTextView*)[NSApp delegate];
+
+ if (!editing)
+ {
+ [textView setHidden:YES];
+ [Window makeFirstResponder:nil];
+ }
+ else
+ {
+ auto crect = focusElement->getAbsolutePosition();
+
+ // ensure font height enough to fill the rect, otherwize ime window will overlaps the edit box
+ [textView setFont:[NSFont userFontOfSize:crect.getHeight() - 5]];
+
+ // change origin from top left to bottom right
+ auto frameHeight = [[textView superview] frame].size.height;
+ NSRect rect = {
+ (frameHeight - crect.LowerRightCorner.Y > crect.getHeight()) ?
+ crect.UpperLeftCorner.X :
+ crect.UpperLeftCorner.X + crect.getWidth() / 2,
+ (frameHeight - crect.LowerRightCorner.Y > crect.getHeight()) ?
+ frameHeight - crect.LowerRightCorner.Y - crect.getHeight() - 1 :
+ frameHeight - crect.LowerRightCorner.Y,
+ crect.getWidth() / 2,
+ crect.getHeight(),
+ };
+ [textView setFrame:rect];
+ [textView setHidden:NO];
+
+ // start to receive input events
+ [Window makeFirstResponder:textView];
+ }
+
event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES];
if (event != nil)
{
@@ -979,6 +1047,13 @@
bool CIrrDeviceMacOSX::run()
switch([(NSEvent *)event type])
{
case NSKeyDown:
+ if (editing)
+ {
+ // delegate to text edit control to handle text input
+ [NSApp sendEvent:event];
+ break;
+ }
+
postKeyEvent(event,ievent,true);
break;
@@ -1174,13 +1249,11 @@
void CIrrDeviceMacOSX::postKeyEvent(void *event,irr::SEvent &ievent,bool pressed
std::map<int,int>::const_iterator iter;
unsigned int result,c,mkey,mchar;
const unsigned char *cStr;
- BOOL skipCommand;
str = [(NSEvent *)event characters];
if ((str != nil) && ([str length] > 0))
{
mkey = mchar = 0;
- skipCommand = false;
c = [str characterAtIndex:0];
mchar = c;
@@ -1199,19 +1272,11 @@
void CIrrDeviceMacOSX::postKeyEvent(void *event,irr::SEvent &ievent,bool pressed
}
else
{
- cStr = (unsigned char *)[str cStringUsingEncoding:NSWindowsCP1252StringEncoding];
+ cStr = (unsigned char *)[str UTF8String];
if (cStr != NULL && strlen((char*)cStr) > 0)
{
mchar = cStr[0];
mkey = toupper(mchar);
- if ([(NSEvent *)event modifierFlags] & NSCommandKeyMask)
- {
- if (mkey == 'C' || mkey == 'V' || mkey == 'X')
- {
- mchar = 0;
- skipCommand = true;
- }
- }
}
}
}
@@ -1220,14 +1285,9 @@
void CIrrDeviceMacOSX::postKeyEvent(void *event,irr::SEvent &ievent,bool pressed
ievent.KeyInput.Key = (irr::EKEY_CODE)mkey;
ievent.KeyInput.PressedDown = pressed;
ievent.KeyInput.Shift = ([(NSEvent *)event modifierFlags] & NSShiftKeyMask) != 0;
- ievent.KeyInput.Control = ([(NSEvent *)event modifierFlags] & NSControlKeyMask) != 0;
+ ievent.KeyInput.Control = ([(NSEvent *)event modifierFlags] & (NSControlKeyMask | NSCommandKeyMask)) != 0;
ievent.KeyInput.Char = mchar;
- if (skipCommand)
- ievent.KeyInput.Control = true;
- else if ([(NSEvent *)event modifierFlags] & NSCommandKeyMask)
- [NSApp sendEvent:(NSEvent *)event];
-
postEventFromUser(ievent);
}
}
diff --git a/source/Irrlicht/MacOSX/MacOSX.xcodeproj/project.pbxproj b/source/Irrlicht/MacOSX/MacOSX.xcodeproj/project.pbxproj
index 65f4cec..d465792 100644
--- a/source/Irrlicht/MacOSX/MacOSX.xcodeproj/project.pbxproj
+++ b/source/Irrlicht/MacOSX/MacOSX.xcodeproj/project.pbxproj
@@ -6088,10 +6088,12 @@
1DEB922308733DC00010E9CD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ARCHS = "$(NATIVE_ARCH_ACTUAL)";
+ ARCHS = "$(ARCHS_STANDARD)";
+ GCC_PREPROCESSOR_DEFINITIONS = GLES_SILENCE_DEPRECATION;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = NO;
HEADER_SEARCH_PATHS = ../../../include;
+ MACOSX_DEPLOYMENT_TARGET = 10.10;
OTHER_CFLAGS = (
"-DMACOSX",
"-D_DEBUG",
@@ -6104,16 +6106,18 @@
1DEB922408733DC00010E9CD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ARCHS = "$(NATIVE_ARCH_ACTUAL)";
+ ARCHS = "$(ARCHS_STANDARD)";
GCC_DYNAMIC_NO_PIC = YES;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_INLINES_ARE_PRIVATE_EXTERN = YES;
GCC_OPTIMIZATION_LEVEL = 3;
+ GCC_PREPROCESSOR_DEFINITIONS = GLES_SILENCE_DEPRECATION;
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = NO;
HEADER_SEARCH_PATHS = ../../../include;
INSTALL_MODE_FLAG = "a+rwx";
+ MACOSX_DEPLOYMENT_TARGET = 10.10;
OTHER_CFLAGS = "-DMACOSX";
PREBINDING = NO;
SDKROOT = "";
diff --git a/source/Irrlicht/MacOSX/OSXClipboard.h b/source/Irrlicht/MacOSX/OSXClipboard.h
index 68f598d..9d6832d 100644
--- a/source/Irrlicht/MacOSX/OSXClipboard.h
+++ b/source/Irrlicht/MacOSX/OSXClipboard.h
@@ -7,8 +7,8 @@
extern "C" {
#endif
- void OSXCopyToClipboard(const char *text);
- char* OSXCopyFromClipboard();
+ void OSXCopyToClipboard(const wchar_t *text);
+ wchar_t* OSXCopyFromClipboard();
#ifdef __cplusplus
}
diff --git a/source/Irrlicht/MacOSX/OSXClipboard.mm b/source/Irrlicht/MacOSX/OSXClipboard.mm
index d549911..1c9dc0f 100644
--- a/source/Irrlicht/MacOSX/OSXClipboard.mm
+++ b/source/Irrlicht/MacOSX/OSXClipboard.mm
@@ -3,34 +3,35 @@
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h
+#include "irrString.h"
#include "OSXClipboard.h"
#import <Cocoa/Cocoa.h>
-void OSXCopyToClipboard(const char *text)
+void OSXCopyToClipboard(const wchar_t *text)
{
NSString *str;
NSPasteboard *board;
- if ((text != NULL) && (strlen(text) > 0))
+ if ((text != NULL) && (wcslen(text) > 0))
{
- str = [NSString stringWithCString:text encoding:NSWindowsCP1252StringEncoding];
+ str = [[NSString alloc] initWithBytes:text length:wcslen(text)*sizeof(*text) encoding:NSUTF32LittleEndianStringEncoding];
board = [NSPasteboard generalPasteboard];
[board declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:NSApp];
[board setString:str forType:NSStringPboardType];
}
}
-char* OSXCopyFromClipboard()
+wchar_t* OSXCopyFromClipboard()
{
NSString* str;
NSPasteboard* board;
- char* result;
+ wchar_t* result;
result = NULL;
board = [NSPasteboard generalPasteboard];
str = [board stringForType:NSStringPboardType];
if (str != nil)
- result = (char*)[str cStringUsingEncoding:NSWindowsCP1252StringEncoding];
+ result = (wchar_t*)[str cStringUsingEncoding:NSUTF32LittleEndianStringEncoding];
return (result);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment