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
REIKAI
ygopro
Commits
d0417aae
Commit
d0417aae
authored
Nov 12, 2018
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
temp merge
parents
48286c13
f48181e1
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
338 additions
and
298 deletions
+338
-298
.gitignore
.gitignore
+1
-1
cards.cdb
cards.cdb
+0
-0
gframe/client_card.cpp
gframe/client_card.cpp
+2
-0
gframe/client_field.cpp
gframe/client_field.cpp
+48
-4
gframe/config.h
gframe/config.h
+1
-0
gframe/deck_manager.cpp
gframe/deck_manager.cpp
+2
-0
gframe/drawing.cpp
gframe/drawing.cpp
+12
-0
gframe/duelclient.cpp
gframe/duelclient.cpp
+10
-6
gframe/event_handler.cpp
gframe/event_handler.cpp
+7
-3
gframe/game.cpp
gframe/game.cpp
+61
-178
gframe/game.h
gframe/game.h
+7
-6
gframe/image_manager.cpp
gframe/image_manager.cpp
+15
-45
gframe/myfilesystem.h
gframe/myfilesystem.h
+145
-0
gframe/premake4.lua
gframe/premake4.lua
+1
-1
gframe/replay.cpp
gframe/replay.cpp
+4
-0
gframe/single_mode.cpp
gframe/single_mode.cpp
+2
-2
gframe/sound_manager.cpp
gframe/sound_manager.cpp
+16
-49
ocgcore
ocgcore
+1
-1
premake5.lua
premake5.lua
+1
-1
script
script
+1
-1
strings.conf
strings.conf
+1
-0
No files found.
.gitignore
View file @
d0417aae
...
...
@@ -13,7 +13,7 @@
/freetype
/sqlite3
/irrklang
/irrlicht
/irrlicht
*
# gframe additionals
/gframe/ygopro.ico
...
...
cards.cdb
View file @
d0417aae
No preview for this file type
gframe/client_card.cpp
View file @
d0417aae
...
...
@@ -125,6 +125,8 @@ void ClientCard::UpdateInfo(char* buf) {
base_defense
=
BufferIO
::
ReadInt32
(
buf
);
if
(
flag
&
QUERY_REASON
)
reason
=
BufferIO
::
ReadInt32
(
buf
);
if
(
flag
&
QUERY_REASON_CARD
)
BufferIO
::
ReadInt32
(
buf
);
if
(
flag
&
QUERY_EQUIP_CARD
)
{
int
c
=
BufferIO
::
ReadInt8
(
buf
);
int
l
=
BufferIO
::
ReadInt8
(
buf
);
...
...
gframe/client_field.cpp
View file @
d0417aae
...
...
@@ -1457,10 +1457,25 @@ void ClientField::UpdateDeclarableCodeType(bool enter) {
ancard
.
push_back
(
trycode
);
return
;
}
if
((
pname
[
0
]
==
0
||
pname
[
1
]
==
0
)
&&
!
enter
)
return
;
bool
try_cache
=
false
;
if
(
pname
[
0
]
==
0
||
pname
[
1
]
==
0
)
{
if
(
!
enter
)
return
;
try_cache
=
true
;
}
mainGame
->
lstANCard
->
clear
();
ancard
.
clear
();
if
(
try_cache
&&
mainGame
->
dInfo
.
announce_cache
.
size
())
{
for
(
int
i
=
0
;
i
<
mainGame
->
dInfo
.
announce_cache
.
size
();
++
i
)
{
unsigned
int
cache_code
=
mainGame
->
dInfo
.
announce_cache
[
i
];
if
(
dataManager
.
GetString
(
cache_code
,
&
cstr
)
&&
dataManager
.
GetData
(
cache_code
,
&
cd
)
&&
is_declarable
(
cd
,
declarable_type
))
{
mainGame
->
lstANCard
->
addItem
(
cstr
.
name
.
c_str
());
ancard
.
push_back
(
cache_code
);
}
}
if
(
ancard
.
size
())
return
;
}
for
(
auto
cit
=
dataManager
.
_strings
.
begin
();
cit
!=
dataManager
.
_strings
.
end
();
++
cit
)
{
if
(
cit
->
second
.
name
.
find
(
pname
)
!=
std
::
wstring
::
npos
)
{
auto
cp
=
dataManager
.
GetCodePointer
(
cit
->
first
);
//verified by _strings
...
...
@@ -1489,10 +1504,25 @@ void ClientField::UpdateDeclarableCodeOpcode(bool enter) {
ancard
.
push_back
(
trycode
);
return
;
}
if
((
pname
[
0
]
==
0
||
pname
[
1
]
==
0
)
&&
!
enter
)
return
;
bool
try_cache
=
false
;
if
(
pname
[
0
]
==
0
||
pname
[
1
]
==
0
)
{
if
(
!
enter
)
return
;
try_cache
=
true
;
}
mainGame
->
lstANCard
->
clear
();
ancard
.
clear
();
if
(
try_cache
&&
mainGame
->
dInfo
.
announce_cache
.
size
())
{
for
(
int
i
=
0
;
i
<
mainGame
->
dInfo
.
announce_cache
.
size
();
++
i
)
{
unsigned
int
cache_code
=
mainGame
->
dInfo
.
announce_cache
[
i
];
if
(
dataManager
.
GetString
(
cache_code
,
&
cstr
)
&&
dataManager
.
GetData
(
cache_code
,
&
cd
)
&&
is_declarable
(
cd
,
opcode
))
{
mainGame
->
lstANCard
->
addItem
(
cstr
.
name
.
c_str
());
ancard
.
push_back
(
cache_code
);
}
}
if
(
ancard
.
size
())
return
;
}
for
(
auto
cit
=
dataManager
.
_strings
.
begin
();
cit
!=
dataManager
.
_strings
.
end
();
++
cit
)
{
if
(
cit
->
second
.
name
.
find
(
pname
)
!=
std
::
wstring
::
npos
)
{
auto
cp
=
dataManager
.
GetCodePointer
(
cit
->
first
);
//verified by _strings
...
...
@@ -1519,6 +1549,7 @@ void ClientField::RefreshCardCountDisplay() {
ClientCard
*
pcard
;
for
(
int
p
=
0
;
p
<
2
;
++
p
)
{
mainGame
->
dInfo
.
card_count
[
p
]
=
hand
[
p
].
size
();
mainGame
->
dInfo
.
total_attack
[
p
]
=
0
;
for
(
auto
it
=
mzone
[
p
].
begin
();
it
!=
mzone
[
p
].
end
();
++
it
)
{
pcard
=
*
it
;
if
(
pcard
)
{
...
...
@@ -1526,6 +1557,8 @@ void ClientField::RefreshCardCountDisplay() {
mainGame
->
dInfo
.
card_count
[
p
]
+=
pcard
->
link
;
else
mainGame
->
dInfo
.
card_count
[
p
]
++
;
if
(
pcard
->
position
==
POS_FACEUP_ATTACK
&&
pcard
->
attack
>
0
&&
(
p
==
1
||
mainGame
->
dInfo
.
curMsg
!=
MSG_SELECT_BATTLECMD
||
pcard
->
cmdFlag
&
COMMAND_ATTACK
))
mainGame
->
dInfo
.
total_attack
[
p
]
+=
pcard
->
attack
;
}
}
for
(
auto
it
=
szone
[
p
].
begin
();
it
!=
szone
[
p
].
end
();
++
it
)
{
...
...
@@ -1534,6 +1567,7 @@ void ClientField::RefreshCardCountDisplay() {
mainGame
->
dInfo
.
card_count
[
p
]
++
;
}
myswprintf
(
mainGame
->
dInfo
.
str_card_count
[
p
],
L"%d"
,
mainGame
->
dInfo
.
card_count
[
p
]);
myswprintf
(
mainGame
->
dInfo
.
str_total_attack
[
p
],
L"%d"
,
mainGame
->
dInfo
.
total_attack
[
p
]);
}
if
(
mainGame
->
dInfo
.
card_count
[
0
]
>
mainGame
->
dInfo
.
card_count
[
1
])
{
mainGame
->
dInfo
.
card_count_color
[
0
]
=
0xffffff00
;
...
...
@@ -1545,5 +1579,15 @@ void ClientField::RefreshCardCountDisplay() {
mainGame
->
dInfo
.
card_count_color
[
0
]
=
0xffffffff
;
mainGame
->
dInfo
.
card_count_color
[
1
]
=
0xffffffff
;
}
if
(
mainGame
->
dInfo
.
total_attack
[
0
]
>
mainGame
->
dInfo
.
total_attack
[
1
])
{
mainGame
->
dInfo
.
total_attack_color
[
0
]
=
0xffffff00
;
mainGame
->
dInfo
.
total_attack_color
[
1
]
=
0xffff0000
;
}
else
if
(
mainGame
->
dInfo
.
total_attack
[
1
]
>
mainGame
->
dInfo
.
total_attack
[
0
])
{
mainGame
->
dInfo
.
total_attack_color
[
1
]
=
0xffffff00
;
mainGame
->
dInfo
.
total_attack_color
[
0
]
=
0xffff0000
;
}
else
{
mainGame
->
dInfo
.
total_attack_color
[
0
]
=
0xffffffff
;
mainGame
->
dInfo
.
total_attack_color
[
1
]
=
0xffffffff
;
}
}
}
gframe/config.h
View file @
d0417aae
...
...
@@ -73,6 +73,7 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
#include <memory.h>
#include <time.h>
#include "bufferio.h"
#include "myfilesystem.h"
#include "mymutex.h"
#include "mysignal.h"
#include "mythread.h"
...
...
gframe/deck_manager.cpp
View file @
d0417aae
...
...
@@ -288,6 +288,8 @@ bool DeckManager::LoadDeck(const wchar_t* file) {
return
true
;
}
bool
DeckManager
::
SaveDeck
(
Deck
&
deck
,
const
wchar_t
*
name
)
{
if
(
!
FileSystem
::
IsDirExists
(
L"./deck"
)
&&
!
FileSystem
::
MakeDir
(
L"./deck"
))
return
false
;
wchar_t
file
[
64
];
myswprintf
(
file
,
L"./deck/%ls.ydk"
,
name
);
FILE
*
fp
=
OpenDeckFile
(
file
,
"w"
);
...
...
gframe/drawing.cpp
View file @
d0417aae
...
...
@@ -567,6 +567,12 @@ void Game::DrawMisc() {
DrawShadowText
(
numFont
,
dInfo
.
str_card_count
[
0
],
Resize
(
550
,
31
,
575
,
50
),
Resize
(
0
,
1
,
2
,
0
),
dInfo
.
card_count_color
[
0
],
0xff000000
,
true
,
false
,
0
);
DrawShadowText
(
numFont
,
dInfo
.
str_card_count
[
1
],
Resize
(
757
,
31
,
782
,
50
),
Resize
(
0
,
1
,
2
,
0
),
dInfo
.
card_count_color
[
1
],
0xff000000
,
true
,
false
,
0
);
DrawShadowText
(
numFont
,
dInfo
.
str_total_attack
[
0
],
Resize
(
486
,
31
,
536
,
50
),
Resize
(
0
,
1
,
2
,
0
),
dInfo
.
total_attack_color
[
0
],
0xff000000
,
true
,
false
,
0
);
DrawShadowText
(
numFont
,
dInfo
.
str_total_attack
[
1
],
Resize
(
793
,
31
,
843
,
50
),
Resize
(
0
,
1
,
2
,
0
),
dInfo
.
total_attack_color
[
1
],
0xff000000
,
true
,
false
,
0
);
driver
->
draw2DImage
(
imageManager
.
tAttack
,
ResizeCardMid
(
477
,
32
,
486
,
50
,
486
,
41
),
recti
(
32
,
0
,
96
,
128
),
0
,
0
,
true
);
driver
->
draw2DImage
(
imageManager
.
tAttack
,
ResizeCardMid
(
784
,
32
,
793
,
50
,
793
,
41
),
recti
(
32
,
0
,
96
,
128
),
0
,
0
,
true
);
/*
driver->draw2DRectangle(Resize(525, 34, 525 + dInfo.time_left[0] * 100 / dInfo.time_limit, 44), 0xa0e0e0e0, 0xa0e0e0e0, 0xa0c0c0c0, 0xa0c0c0c0);
driver->draw2DRectangleOutline(Resize(525, 34, 625, 44), 0xffffffff);
...
...
@@ -580,6 +586,12 @@ void Game::DrawMisc() {
DrawShadowText
(
numFont
,
dInfo
.
str_card_count
[
0
],
Resize
(
600
,
31
,
625
,
50
),
Resize
(
0
,
1
,
2
,
0
),
dInfo
.
card_count_color
[
0
],
0xff000000
,
true
,
false
,
0
);
DrawShadowText
(
numFont
,
dInfo
.
str_card_count
[
1
],
Resize
(
707
,
31
,
732
,
50
),
Resize
(
0
,
1
,
2
,
0
),
dInfo
.
card_count_color
[
1
],
0xff000000
,
true
,
false
,
0
);
DrawShadowText
(
numFont
,
dInfo
.
str_total_attack
[
0
],
Resize
(
536
,
31
,
586
,
50
),
Resize
(
0
,
1
,
2
,
0
),
dInfo
.
total_attack_color
[
0
],
0xff000000
,
true
,
false
,
0
);
DrawShadowText
(
numFont
,
dInfo
.
str_total_attack
[
1
],
Resize
(
743
,
31
,
793
,
50
),
Resize
(
0
,
1
,
2
,
0
),
dInfo
.
total_attack_color
[
1
],
0xff000000
,
true
,
false
,
0
);
driver
->
draw2DImage
(
imageManager
.
tAttack
,
ResizeCardMid
(
527
,
32
,
536
,
50
,
536
,
41
),
recti
(
32
,
0
,
96
,
128
),
0
,
0
,
true
);
driver
->
draw2DImage
(
imageManager
.
tAttack
,
ResizeCardMid
(
734
,
32
,
743
,
50
,
743
,
41
),
recti
(
32
,
0
,
96
,
128
),
0
,
0
,
true
);
}
DrawShadowText
(
numFont
,
dInfo
.
strLP
[
0
],
Resize
(
330
,
12
,
631
,
30
),
Resize
(
0
,
1
,
2
,
0
),
0xffffff00
,
0xff000000
,
true
,
false
,
0
);
DrawShadowText
(
numFont
,
dInfo
.
strLP
[
1
],
Resize
(
691
,
12
,
992
,
30
),
Resize
(
0
,
1
,
2
,
0
),
0xffffff00
,
0xff000000
,
true
,
false
,
0
);
...
...
gframe/duelclient.cpp
View file @
d0417aae
...
...
@@ -601,6 +601,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame
->
RefreshTimeDisplay
();
mainGame
->
dInfo
.
time_player
=
2
;
mainGame
->
dInfo
.
isReplaySwapped
=
false
;
mainGame
->
dInfo
.
announce_cache
.
clear
();
mainGame
->
is_building
=
false
;
mainGame
->
wCardImg
->
setVisible
(
true
);
mainGame
->
wInfos
->
setVisible
(
true
);
...
...
@@ -679,6 +680,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame
->
gMutex
.
Lock
();
mainGame
->
dInfo
.
isStarted
=
false
;
mainGame
->
dInfo
.
isFinished
=
true
;
mainGame
->
dInfo
.
announce_cache
.
clear
();
mainGame
->
is_building
=
false
;
mainGame
->
wDeckEdit
->
setVisible
(
false
);
mainGame
->
btnCreateHost
->
setEnabled
(
true
);
...
...
@@ -728,7 +730,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame
->
actionParam
=
1
;
wchar_t
msgbuf
[
256
];
myswprintf
(
msgbuf
,
dataManager
.
GetSysString
(
1376
),
timetext
);
mainGame
->
SetStaticText
(
mainGame
->
stACMessage
,
310
,
mainGame
->
text
Font
,
msgbuf
);
mainGame
->
SetStaticText
(
mainGame
->
stACMessage
,
310
,
mainGame
->
gui
Font
,
msgbuf
);
mainGame
->
PopupElement
(
mainGame
->
wACMessage
,
20
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
WaitFrameSignal
(
30
);
...
...
@@ -975,7 +977,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame
->
lstLog
->
addItem
(
textBuffer
);
mainGame
->
logParam
.
push_back
(
0
);
mainGame
->
gMutex
.
Lock
();
mainGame
->
SetStaticText
(
mainGame
->
stACMessage
,
310
,
mainGame
->
text
Font
,
textBuffer
);
mainGame
->
SetStaticText
(
mainGame
->
stACMessage
,
310
,
mainGame
->
gui
Font
,
textBuffer
);
mainGame
->
PopupElement
(
mainGame
->
wACMessage
,
20
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
WaitFrameSignal
(
40
);
...
...
@@ -993,7 +995,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame
->
lstLog
->
addItem
(
textBuffer
);
mainGame
->
logParam
.
push_back
(
0
);
mainGame
->
gMutex
.
Lock
();
mainGame
->
SetStaticText
(
mainGame
->
stACMessage
,
310
,
mainGame
->
text
Font
,
textBuffer
);
mainGame
->
SetStaticText
(
mainGame
->
stACMessage
,
310
,
mainGame
->
gui
Font
,
textBuffer
);
mainGame
->
PopupElement
(
mainGame
->
wACMessage
,
20
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
WaitFrameSignal
(
40
);
...
...
@@ -1004,7 +1006,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame
->
lstLog
->
addItem
(
textBuffer
);
mainGame
->
logParam
.
push_back
(
0
);
mainGame
->
gMutex
.
Lock
();
mainGame
->
SetStaticText
(
mainGame
->
stACMessage
,
310
,
mainGame
->
text
Font
,
textBuffer
);
mainGame
->
SetStaticText
(
mainGame
->
stACMessage
,
310
,
mainGame
->
gui
Font
,
textBuffer
);
mainGame
->
PopupElement
(
mainGame
->
wACMessage
,
20
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
WaitFrameSignal
(
40
);
...
...
@@ -1015,7 +1017,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame
->
lstLog
->
addItem
(
textBuffer
);
mainGame
->
logParam
.
push_back
(
data
);
mainGame
->
gMutex
.
Lock
();
mainGame
->
SetStaticText
(
mainGame
->
stACMessage
,
310
,
mainGame
->
text
Font
,
textBuffer
);
mainGame
->
SetStaticText
(
mainGame
->
stACMessage
,
310
,
mainGame
->
gui
Font
,
textBuffer
);
mainGame
->
PopupElement
(
mainGame
->
wACMessage
,
20
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
WaitFrameSignal
(
40
);
...
...
@@ -1026,7 +1028,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame
->
lstLog
->
addItem
(
textBuffer
);
mainGame
->
logParam
.
push_back
(
0
);
mainGame
->
gMutex
.
Lock
();
mainGame
->
SetStaticText
(
mainGame
->
stACMessage
,
310
,
mainGame
->
text
Font
,
textBuffer
);
mainGame
->
SetStaticText
(
mainGame
->
stACMessage
,
310
,
mainGame
->
gui
Font
,
textBuffer
);
mainGame
->
PopupElement
(
mainGame
->
wACMessage
,
20
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
WaitFrameSignal
(
40
);
...
...
@@ -1232,6 +1234,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame
->
dField
.
attackable_cards
.
push_back
(
pcard
);
pcard
->
cmdFlag
|=
COMMAND_ATTACK
;
}
mainGame
->
dField
.
RefreshCardCountDisplay
();
mainGame
->
gMutex
.
Lock
();
if
(
BufferIO
::
ReadInt8
(
pbuf
))
{
mainGame
->
btnM2
->
setVisible
(
true
);
...
...
@@ -2403,6 +2406,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame
->
btnShuffle
->
setVisible
(
false
);
mainGame
->
showcarddif
=
30
;
mainGame
->
showcardp
=
0
;
mainGame
->
dField
.
RefreshCardCountDisplay
();
switch
(
phase
)
{
case
PHASE_DRAW
:
mainGame
->
btnPhaseStatus
->
setText
(
L"
\xff24\xff30
"
);
...
...
gframe/event_handler.cpp
View file @
d0417aae
...
...
@@ -1632,7 +1632,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
str
.
append
(
formatBuffer
);
}
should_show_tip
=
true
;
irr
::
core
::
dimension2d
<
unsigned
int
>
dtip
=
mainGame
->
text
Font
->
getDimension
(
str
.
c_str
())
+
irr
::
core
::
dimension2d
<
unsigned
int
>
(
10
,
10
);
irr
::
core
::
dimension2d
<
unsigned
int
>
dtip
=
mainGame
->
gui
Font
->
getDimension
(
str
.
c_str
())
+
irr
::
core
::
dimension2d
<
unsigned
int
>
(
10
,
10
);
mainGame
->
stTip
->
setRelativePosition
(
recti
(
mousepos
.
X
-
10
-
dtip
.
Width
,
mousepos
.
Y
+
10
,
mousepos
.
X
-
10
,
mousepos
.
Y
+
10
+
dtip
.
Height
));
mainGame
->
stTip
->
setText
(
str
.
c_str
());
}
...
...
@@ -1988,15 +1988,19 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
switch
(
event
.
KeyInput
.
Key
)
{
case
irr
:
:
KEY_KEY_R
:
{
if
(
mainGame
->
gameConf
.
control_mode
==
0
&&
!
event
.
KeyInput
.
PressedDown
&&
!
mainGame
->
HasFocus
(
EGUIET_EDIT_BOX
))
&&
!
event
.
KeyInput
.
PressedDown
&&
!
mainGame
->
HasFocus
(
EGUIET_EDIT_BOX
))
{
mainGame
->
textFont
->
setTransparency
(
true
);
mainGame
->
guiFont
->
setTransparency
(
true
);
}
return
true
;
break
;
}
case
irr
:
:
KEY_F9
:
{
if
(
mainGame
->
gameConf
.
control_mode
==
1
&&
!
event
.
KeyInput
.
PressedDown
&&
!
mainGame
->
HasFocus
(
EGUIET_EDIT_BOX
))
&&
!
event
.
KeyInput
.
PressedDown
&&
!
mainGame
->
HasFocus
(
EGUIET_EDIT_BOX
))
{
mainGame
->
textFont
->
setTransparency
(
true
);
mainGame
->
guiFont
->
setTransparency
(
true
);
}
return
true
;
break
;
}
...
...
gframe/game.cpp
View file @
d0417aae
...
...
@@ -17,16 +17,6 @@
#include <sstream>
#endif //YGOPRO_SERVER_MODE
#ifndef _WIN32
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <unistd.h>
#else
#include <direct.h>
#include <io.h>
#endif
unsigned
short
PRO_VERSION
=
0x1346
;
namespace
ygo
{
...
...
@@ -1117,9 +1107,7 @@ void Game::LoadExpansionDBDirectry(const char* path) {
sprintf
(
filepath
,
"%s/%s"
,
path
,
dirp
->
d_name
);
dataManager
.
LoadDB
(
filepath
);
}
closedir
(
dir
);
}
#endif
});
}
#ifndef YGOPRO_SERVER_MODE
void
Game
::
LoadExpansionStrings
()
{
...
...
@@ -1161,37 +1149,15 @@ void Game::LoadExpansionStringsDirectry(const char* path) {
}
void
Game
::
RefreshDeck
(
irr
::
gui
::
IGUIComboBox
*
cbDeck
)
{
cbDeck
->
clear
();
#ifdef _WIN32
WIN32_FIND_DATAW
fdataw
;
HANDLE
fh
=
FindFirstFileW
(
L"./deck/*.ydk"
,
&
fdataw
);
if
(
fh
==
INVALID_HANDLE_VALUE
)
return
;
do
{
if
(
!
(
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
))
{
wchar_t
*
pf
=
fdataw
.
cFileName
;
while
(
*
pf
)
pf
++
;
while
(
*
pf
!=
L'.'
)
pf
--
;
*
pf
=
0
;
cbDeck
->
addItem
(
fdataw
.
cFileName
);
FileSystem
::
TraversalDir
(
L"./deck"
,
[
cbDeck
](
const
wchar_t
*
name
,
bool
isdir
)
{
if
(
!
isdir
&&
wcsrchr
(
name
,
'.'
)
&&
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".ydk"
,
4
))
{
size_t
len
=
wcslen
(
name
);
wchar_t
deckname
[
256
];
wcsncpy
(
deckname
,
name
,
len
-
4
);
deckname
[
len
-
4
]
=
0
;
cbDeck
->
addItem
(
deckname
);
}
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
FindClose
(
fh
);
#else
DIR
*
dir
;
struct
dirent
*
dirp
;
if
((
dir
=
opendir
(
"./deck/"
))
==
NULL
)
return
;
while
((
dirp
=
readdir
(
dir
))
!=
NULL
)
{
size_t
len
=
strlen
(
dirp
->
d_name
);
if
(
len
<
5
||
strcasecmp
(
dirp
->
d_name
+
len
-
4
,
".ydk"
)
!=
0
)
continue
;
dirp
->
d_name
[
len
-
4
]
=
0
;
wchar_t
wname
[
256
];
BufferIO
::
DecodeUTF8
(
dirp
->
d_name
,
wname
);
cbDeck
->
addItem
(
wname
);
}
closedir
(
dir
);
#endif
});
for
(
size_t
i
=
0
;
i
<
cbDeck
->
getItemCount
();
++
i
)
{
if
(
!
wcscmp
(
cbDeck
->
getItem
(
i
),
gameConf
.
lastdeck
))
{
cbDeck
->
setSelected
(
i
);
...
...
@@ -1201,90 +1167,25 @@ void Game::RefreshDeck(irr::gui::IGUIComboBox* cbDeck) {
}
void
Game
::
RefreshReplay
()
{
lstReplayList
->
clear
();
#ifdef _WIN32
WIN32_FIND_DATAW
fdataw
;
HANDLE
fh
=
FindFirstFileW
(
L"./replay/*.yrp"
,
&
fdataw
);
if
(
fh
==
INVALID_HANDLE_VALUE
)
return
;
do
{
if
(
!
(
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
&&
Replay
::
CheckReplay
(
fdataw
.
cFileName
))
{
lstReplayList
->
addItem
(
fdataw
.
cFileName
);
}
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
FindClose
(
fh
);
#else
DIR
*
dir
;
struct
dirent
*
dirp
;
if
((
dir
=
opendir
(
"./replay/"
))
==
NULL
)
return
;
while
((
dirp
=
readdir
(
dir
))
!=
NULL
)
{
size_t
len
=
strlen
(
dirp
->
d_name
);
if
(
len
<
5
||
strcasecmp
(
dirp
->
d_name
+
len
-
4
,
".yrp"
)
!=
0
)
continue
;
wchar_t
wname
[
256
];
BufferIO
::
DecodeUTF8
(
dirp
->
d_name
,
wname
);
if
(
Replay
::
CheckReplay
(
wname
))
lstReplayList
->
addItem
(
wname
);
}
closedir
(
dir
);
#endif
FileSystem
::
TraversalDir
(
L"./replay"
,
[
this
](
const
wchar_t
*
name
,
bool
isdir
)
{
if
(
!
isdir
&&
wcsrchr
(
name
,
'.'
)
&&
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".yrp"
,
4
)
&&
Replay
::
CheckReplay
(
name
))
lstReplayList
->
addItem
(
name
);
});
}
void
Game
::
RefreshSingleplay
()
{
lstSinglePlayList
->
clear
();
#ifdef _WIN32
WIN32_FIND_DATAW
fdataw
;
HANDLE
fh
=
FindFirstFileW
(
L"./single/*.lua"
,
&
fdataw
);
if
(
fh
==
INVALID_HANDLE_VALUE
)
return
;
do
{
if
(
!
(
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
))
lstSinglePlayList
->
addItem
(
fdataw
.
cFileName
);
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
FindClose
(
fh
);
#else
DIR
*
dir
;
struct
dirent
*
dirp
;
if
((
dir
=
opendir
(
"./single/"
))
==
NULL
)
return
;
while
((
dirp
=
readdir
(
dir
))
!=
NULL
)
{
size_t
len
=
strlen
(
dirp
->
d_name
);
if
(
len
<
5
||
strcasecmp
(
dirp
->
d_name
+
len
-
4
,
".lua"
)
!=
0
)
continue
;
wchar_t
wname
[
256
];
BufferIO
::
DecodeUTF8
(
dirp
->
d_name
,
wname
);
lstSinglePlayList
->
addItem
(
wname
);
}
closedir
(
dir
);
#endif
FileSystem
::
TraversalDir
(
L"./single"
,
[
this
](
const
wchar_t
*
name
,
bool
isdir
)
{
if
(
!
isdir
&&
wcsrchr
(
name
,
'.'
)
&&
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".lua"
,
4
))
lstSinglePlayList
->
addItem
(
name
);
});
}
void
Game
::
RefreshLocales
()
{
cbLocale
->
clear
();
cbLocale
->
addItem
(
L"default"
);
#ifdef _WIN32
WIN32_FIND_DATAW
fdataw
;
HANDLE
fh
=
FindFirstFileW
(
L"./locales/*"
,
&
fdataw
);
if
(
fh
==
INVALID_HANDLE_VALUE
)
return
;
do
{
if
((
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
&&
wcscmp
(
fdataw
.
cFileName
,
L"."
)
&&
wcscmp
(
fdataw
.
cFileName
,
L".."
))
cbLocale
->
addItem
(
fdataw
.
cFileName
);
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
FindClose
(
fh
);
#else
DIR
*
dir
;
struct
dirent
*
dirp
;
if
((
dir
=
opendir
(
"./locales/"
))
==
NULL
)
return
;
while
((
dirp
=
readdir
(
dir
))
!=
NULL
)
{
size_t
len
=
strlen
(
dirp
->
d_name
);
wchar_t
wname
[
256
];
BufferIO
::
DecodeUTF8
(
dirp
->
d_name
,
wname
);
if
(
!
wcscmp
(
wname
,
L"."
)
||
!
wcscmp
(
wname
,
L".."
))
continue
;
cbLocale
->
addItem
(
wname
);
}
closedir
(
dir
);
#endif
FileSystem
::
TraversalDir
(
L"./locales"
,
[
this
](
const
wchar_t
*
name
,
bool
isdir
)
{
if
(
isdir
&&
wcscmp
(
name
,
L"."
)
&&
wcscmp
(
name
,
L".."
))
cbLocale
->
addItem
(
name
);
});
for
(
size_t
i
=
0
;
i
<
cbLocale
->
getItemCount
();
++
i
)
{
if
(
!
wcscmp
(
cbLocale
->
getItem
(
i
),
gameConf
.
locale
))
{
cbLocale
->
setSelected
(
i
);
...
...
@@ -1815,7 +1716,7 @@ void Game::ClearCardInfo(int player) {
stText
->
setText
(
L""
);
scrCardText
->
setVisible
(
false
);
}
void
Game
::
AddChatMsg
(
wchar_t
*
msg
,
int
player
)
{
void
Game
::
AddChatMsg
(
const
wchar_t
*
msg
,
int
player
)
{
for
(
int
i
=
7
;
i
>
0
;
--
i
)
{
chatMsg
[
i
]
=
chatMsg
[
i
-
1
];
chatTiming
[
i
]
=
chatTiming
[
i
-
1
];
...
...
@@ -1871,8 +1772,7 @@ void Game::ClearChatMsg() {
}
}
#endif //YGOPRO_SERVER_MODE
void
Game
::
AddDebugMsg
(
char
*
msg
)
{
void
Game
::
AddDebugMsg
(
const
char
*
msg
)
{
#ifdef YGOPRO_SERVER_MODE
fprintf
(
stderr
,
"%s
\n
"
,
msg
);
#else
...
...
@@ -1886,8 +1786,10 @@ void Game::AddDebugMsg(char* msg)
sprintf
(
msgbuf
,
"[Script Error]: %s"
,
msg
);
ErrorLog
(
msgbuf
);
}
#endif //YGOPRO_SERVER_MODE
}
void
Game
::
ErrorLog
(
char
*
msg
)
{
#ifndef YGOPRO_SERVER_MODE
void
Game
::
ErrorLog
(
const
char
*
msg
)
{
FILE
*
fp
=
fopen
(
"error.log"
,
"at"
);
if
(
!
fp
)
return
;
...
...
@@ -1897,76 +1799,55 @@ void Game::ErrorLog(char* msg) {
strftime
(
timebuf
,
40
,
"%Y-%m-%d %H:%M:%S"
,
localedtime
);
fprintf
(
fp
,
"[%s]%s
\n
"
,
timebuf
,
msg
);
fclose
(
fp
);
#endif //YGOPRO_SERVER_MODE
}
bool
Game
::
MakeDirectory
(
const
std
::
string
folder
)
{
std
::
string
folder_builder
;
std
::
string
sub
;
sub
.
reserve
(
folder
.
size
());
for
(
auto
it
=
folder
.
begin
();
it
!=
folder
.
end
();
++
it
)
{
const
char
c
=
*
it
;
sub
.
push_back
(
c
);
if
(
c
==
'/'
||
it
==
folder
.
end
()
-
1
)
{
folder_builder
.
append
(
sub
);
if
(
access
(
folder_builder
.
c_str
(),
0
)
!=
0
)
#ifdef _WIN32
if
(
mkdir
(
folder_builder
.
c_str
())
!=
0
)
#else
if
(
mkdir
(
folder_builder
.
c_str
(),
0777
)
!=
0
)
#endif
return
false
;
sub
.
clear
();
}
}
return
true
;
}
#endif //YGOPRO_SERVER_MODE
void
Game
::
initUtils
()
{
//user files
MakeDirectory
(
"replay"
);
FileSystem
::
MakeDir
(
"replay"
);
//cards from extra pack
MakeDirectory
(
"expansions"
);
FileSystem
::
MakeDir
(
"expansions"
);
#ifdef YGOPRO_SERVER_MODE
//special scripts
MakeDirectory
(
"specials"
);
MakeDirectory
(
"beta"
);
FileSystem
::
MakeDir
(
"specials"
);
FileSystem
::
MakeDir
(
"beta"
);
#else
MakeDirectory
(
"screenshots"
);
FileSystem
::
MakeDir
(
"screenshots"
);
//files in ygopro-starter-pack
MakeDirectory
(
"deck"
);
MakeDirectory
(
"single"
);
FileSystem
::
MakeDir
(
"deck"
);
FileSystem
::
MakeDir
(
"single"
);
//original files
MakeDirectory
(
"script"
);
MakeDirectory
(
"skin"
);
MakeDirectory
(
"textures"
);
FileSystem
::
MakeDir
(
"script"
);
FileSystem
::
MakeDir
(
"skin"
);
FileSystem
::
MakeDir
(
"textures"
);
//subdirs in textures
MakeDirectory
(
"textures/act"
);
MakeDirectory
(
"textures/attack"
);
MakeDirectory
(
"textures/bg"
);
MakeDirectory
(
"textures/bg_deck"
);
MakeDirectory
(
"textures/bg_menu"
);
MakeDirectory
(
"textures/cover"
);
MakeDirectory
(
"textures/cover2"
);
MakeDirectory
(
"textures/pscale"
);
FileSystem
::
MakeDir
(
"textures/act"
);
FileSystem
::
MakeDir
(
"textures/attack"
);
FileSystem
::
MakeDir
(
"textures/bg"
);
FileSystem
::
MakeDir
(
"textures/bg_deck"
);
FileSystem
::
MakeDir
(
"textures/bg_menu"
);
FileSystem
::
MakeDir
(
"textures/cover"
);
FileSystem
::
MakeDir
(
"textures/cover2"
);
FileSystem
::
MakeDir
(
"textures/pscale"
);
//sound
#ifdef YGOPRO_USE_IRRKLANG
MakeDirectory
(
"sound"
);
MakeDirectory
(
"sound/BGM"
);
MakeDirectory
(
"sound/BGM/advantage"
);
MakeDirectory
(
"sound/BGM/deck"
);
MakeDirectory
(
"sound/BGM/disadvantage"
);
MakeDirectory
(
"sound/BGM/duel"
);
MakeDirectory
(
"sound/BGM/lose"
);
MakeDirectory
(
"sound/BGM/menu"
);
MakeDirectory
(
"sound/BGM/win"
);
FileSystem
::
MakeDir
(
"sound"
);
FileSystem
::
MakeDir
(
"sound/BGM"
);
FileSystem
::
MakeDir
(
"sound/BGM/advantage"
);
FileSystem
::
MakeDir
(
"sound/BGM/deck"
);
FileSystem
::
MakeDir
(
"sound/BGM/disadvantage"
);
FileSystem
::
MakeDir
(
"sound/BGM/duel"
);
FileSystem
::
MakeDir
(
"sound/BGM/lose"
);
FileSystem
::
MakeDir
(
"sound/BGM/menu"
);
FileSystem
::
MakeDir
(
"sound/BGM/win"
);
//custom sound
MakeDirectory
(
"sound/custom"
);
MakeDirectory
(
"sound/BGM/custom"
);
FileSystem
::
MakeDir
(
"sound/custom"
);
FileSystem
::
MakeDir
(
"sound/BGM/custom"
);
#endif
//locales
MakeDirectory
(
"locales"
);
FileSystem
::
MakeDir
(
"locales"
);
//pics
MakeDirectory
(
"pics"
);
MakeDirectory
(
"pics/field"
);
FileSystem
::
MakeDir
(
"pics"
);
FileSystem
::
MakeDir
(
"pics/field"
);
#endif //YGOPRO_SERVER_MODE
}
#ifndef YGOPRO_SERVER_MODE
...
...
@@ -2346,6 +2227,8 @@ void Game::FlashWindow() {
#endif
}
void
Game
::
takeScreenshot
()
{
if
(
!
FileSystem
::
IsDirExists
(
L"./screenshots"
)
&&
!
FileSystem
::
MakeDir
(
L"./screenshots"
))
return
;
irr
::
video
::
IImage
*
const
image
=
driver
->
createScreenShot
();
if
(
image
)
{
irr
::
c8
filename
[
64
];
...
...
gframe/game.h
View file @
d0417aae
...
...
@@ -79,6 +79,7 @@ struct DuelInfo {
int
lp
[
2
];
int
start_lp
[
2
];
int
card_count
[
2
];
int
total_attack
[
2
];
int
duel_rule
;
int
turn
;
short
curMsg
;
...
...
@@ -95,7 +96,9 @@ struct DuelInfo {
wchar_t
str_time_left
[
2
][
16
];
video
::
SColor
time_color
[
2
];
wchar_t
str_card_count
[
2
][
16
];
wchar_t
str_total_attack
[
2
][
16
];
video
::
SColor
card_count_color
[
2
];
video
::
SColor
total_attack_color
[
2
];
bool
isReplaySwapped
;
};
...
...
@@ -130,8 +133,7 @@ public:
void
LoadExpansionDB
();
void
LoadExpansionDBDirectry
(
const
char
*
path
);
void
LoadBetaDB
();
void
AddDebugMsg
(
char
*
msgbuf
);
bool
MakeDirectory
(
const
std
::
string
folder
);
void
AddDebugMsg
(
const
char
*
msgbuf
);
void
initUtils
();
#else
void
MainLoop
();
...
...
@@ -172,11 +174,10 @@ public:
void
SaveConfig
();
void
ShowCardInfo
(
int
code
,
bool
resize
=
false
);
void
ClearCardInfo
(
int
player
=
0
);
void
AddChatMsg
(
wchar_t
*
msg
,
int
player
);
void
AddChatMsg
(
const
wchar_t
*
msg
,
int
player
);
void
ClearChatMsg
();
void
AddDebugMsg
(
char
*
msgbuf
);
void
ErrorLog
(
char
*
msgbuf
);
bool
MakeDirectory
(
const
std
::
string
folder
);
void
AddDebugMsg
(
const
char
*
msgbuf
);
void
ErrorLog
(
const
char
*
msgbuf
);
void
initUtils
();
void
ClearTextures
();
void
CloseDuelWindow
();
...
...
gframe/image_manager.cpp
View file @
d0417aae
#include "image_manager.h"
#include "game.h"
#ifndef _WIN32
#include <dirent.h>
#endif
namespace
ygo
{
...
...
@@ -95,54 +92,27 @@ irr::video::ITexture* ImageManager::GetRandomImage(int image_type, s32 width, s3
return
GetTextureFromFile
(
ImageName
,
width
,
height
);
}
void
ImageManager
::
RefreshRandomImageList
()
{
RefreshImageDir
(
L"bg
/
"
,
TEXTURE_DUEL
);
RefreshImageDir
(
L"bg_duel
/
"
,
TEXTURE_DUEL
);
RefreshImageDir
(
L"bg_deck
/
"
,
TEXTURE_DECK
);
RefreshImageDir
(
L"bg_menu
/
"
,
TEXTURE_MENU
);
RefreshImageDir
(
L"cover
/
"
,
TEXTURE_COVER_S
);
RefreshImageDir
(
L"cover2
/
"
,
TEXTURE_COVER_O
);
RefreshImageDir
(
L"attack
/
"
,
TEXTURE_ATTACK
);
RefreshImageDir
(
L"act
/
"
,
TEXTURE_ACTIVATE
);
RefreshImageDir
(
L"bg"
,
TEXTURE_DUEL
);
RefreshImageDir
(
L"bg_duel"
,
TEXTURE_DUEL
);
RefreshImageDir
(
L"bg_deck"
,
TEXTURE_DECK
);
RefreshImageDir
(
L"bg_menu"
,
TEXTURE_MENU
);
RefreshImageDir
(
L"cover"
,
TEXTURE_COVER_S
);
RefreshImageDir
(
L"cover2"
,
TEXTURE_COVER_O
);
RefreshImageDir
(
L"attack"
,
TEXTURE_ATTACK
);
RefreshImageDir
(
L"act"
,
TEXTURE_ACTIVATE
);
for
(
int
i
=
0
;
i
<
7
;
++
i
)
{
saved_image_id
[
i
]
=
-
1
;
}
}
void
ImageManager
::
RefreshImageDir
(
std
::
wstring
path
,
int
image_type
)
{
#ifdef _WIN32
WIN32_FIND_DATAW
fdataw
;
std
::
wstring
search
=
L"./textures/"
+
path
+
L"*.*"
;
HANDLE
fh
=
FindFirstFileW
(
search
.
c_str
(),
&
fdataw
);
if
(
fh
==
INVALID_HANDLE_VALUE
)
return
;
do
{
size_t
len
=
wcslen
(
fdataw
.
cFileName
);
if
((
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
||
len
<
5
||
!
(
_wcsicmp
(
fdataw
.
cFileName
+
len
-
4
,
L".jpg"
)
==
0
||
_wcsicmp
(
fdataw
.
cFileName
+
len
-
4
,
L".png"
)
==
0
))
continue
;
std
::
wstring
filename
=
path
+
(
std
::
wstring
)
fdataw
.
cFileName
;
ImageList
[
image_type
].
push_back
(
filename
);
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
FindClose
(
fh
);
#else
DIR
*
dir
;
struct
dirent
*
dirp
;
std
::
wstring
wsearchpath
=
L"./textures/"
+
path
;
char
searchpath
[
256
];
BufferIO
::
EncodeUTF8
(
wsearchpath
.
c_str
(),
searchpath
);
if
((
dir
=
opendir
(
searchpath
))
==
NULL
)
return
;
while
((
dirp
=
readdir
(
dir
))
!=
NULL
)
{
size_t
len
=
strlen
(
dirp
->
d_name
);
if
(
len
<
5
||
!
(
strcasecmp
(
dirp
->
d_name
+
len
-
4
,
".jpg"
)
==
0
||
strcasecmp
(
dirp
->
d_name
+
len
-
4
,
".png"
)))
continue
;
wchar_t
wname
[
256
];
BufferIO
::
DecodeUTF8
(
dirp
->
d_name
,
wname
);
std
::
wstring
filename
=
path
+
(
std
::
wstring
)
wname
;
ImageList
[
image_type
].
push_back
(
filename
);
}
closedir
(
dir
);
#endif
std
::
wstring
search
=
L"./textures/"
+
path
;
FileSystem
::
TraversalDir
(
search
.
c_str
(),
[
this
,
&
path
,
image_type
](
const
wchar_t
*
name
,
bool
isdir
)
{
if
(
!
isdir
&&
wcsrchr
(
name
,
'.'
)
&&
(
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".jpg"
,
4
)
||
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".png"
,
4
)))
{
std
::
wstring
filename
=
path
+
L"/"
+
name
;
ImageList
[
image_type
].
push_back
(
filename
);
}
});
}
void
ImageManager
::
SetDevice
(
irr
::
IrrlichtDevice
*
dev
)
{
device
=
dev
;
...
...
gframe/myfilesystem.h
0 → 100644
View file @
d0417aae
#ifndef FILESYSTEM_H
#define FILESYSTEM_H
#include <string.h>
#include <functional>
#include "bufferio.h"
#ifdef _WIN32
#include <direct.h>
#include <sys/stat.h>
#else
#include <dirent.h>
#include <sys/stat.h>
#endif
#ifdef _WIN32
#include <Windows.h>
class
FileSystem
{
public:
static
bool
IsFileExists
(
const
wchar_t
*
wfile
)
{
struct
_stat
fileStat
;
return
(
_wstat
(
wfile
,
&
fileStat
)
==
0
)
&&
!
(
fileStat
.
st_mode
&
_S_IFDIR
);
}
static
bool
IsFileExists
(
const
char
*
file
)
{
wchar_t
wfile
[
1024
];
BufferIO
::
DecodeUTF8
(
file
,
wfile
);
return
IsFileExists
(
wfile
);
}
static
bool
IsDirExists
(
const
wchar_t
*
wdir
)
{
struct
_stat
fileStat
;
return
(
_wstat
(
wdir
,
&
fileStat
)
==
0
)
&&
(
fileStat
.
st_mode
&
_S_IFDIR
);
}
static
bool
IsDirExists
(
const
char
*
dir
)
{
wchar_t
wdir
[
1024
];
BufferIO
::
DecodeUTF8
(
dir
,
wdir
);
return
IsDirExists
(
wdir
);
}
static
bool
MakeDir
(
const
wchar_t
*
wdir
)
{
return
_wmkdir
(
wdir
)
==
0
;
}
static
bool
MakeDir
(
const
char
*
dir
)
{
wchar_t
wdir
[
1024
];
BufferIO
::
DecodeUTF8
(
dir
,
wdir
);
return
MakeDir
(
wdir
);
}
static
void
TraversalDir
(
const
wchar_t
*
wpath
,
const
std
::
function
<
void
(
const
wchar_t
*
,
bool
)
>&
cb
)
{
wchar_t
findstr
[
1024
];
wcscpy
(
findstr
,
wpath
);
wcscat
(
findstr
,
L"/*"
);
WIN32_FIND_DATAW
fdataw
;
HANDLE
fh
=
FindFirstFileW
(
findstr
,
&
fdataw
);
if
(
fh
==
INVALID_HANDLE_VALUE
)
return
;
do
{
cb
(
fdataw
.
cFileName
,
(
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
));
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
FindClose
(
fh
);
}
static
void
TraversalDir
(
const
char
*
path
,
const
std
::
function
<
void
(
const
char
*
,
bool
)
>&
cb
)
{
wchar_t
wpath
[
1024
];
BufferIO
::
DecodeUTF8
(
path
,
wpath
);
TraversalDir
(
wpath
,
[
&
cb
](
const
wchar_t
*
wname
,
bool
isdir
)
{
char
name
[
1024
];
BufferIO
::
EncodeUTF8
(
wname
,
name
);
cb
(
name
,
isdir
);
});
}
};
#else
class
FileSystem
{
public:
static
bool
IsFileExists
(
const
char
*
file
)
{
struct
stat
fileStat
;
return
(
stat
(
file
,
&
fileStat
)
==
0
)
&&
!
S_ISDIR
(
fileStat
.
st_mode
);
}
static
bool
IsFileExists
(
const
wchar_t
*
wfile
)
{
char
file
[
1024
];
BufferIO
::
EncodeUTF8
(
wfile
,
file
);
return
IsFileExists
(
file
);
}
static
bool
IsDirExists
(
const
char
*
dir
)
{
struct
stat
fileStat
;
return
(
stat
(
dir
,
&
fileStat
)
==
0
)
&&
S_ISDIR
(
fileStat
.
st_mode
);
}
static
bool
IsDirExists
(
const
wchar_t
*
wdir
)
{
char
dir
[
1024
];
BufferIO
::
EncodeUTF8
(
wdir
,
dir
);
return
IsDirExists
(
dir
);
}
static
bool
MakeDir
(
const
char
*
dir
)
{
return
mkdir
(
dir
,
0775
)
==
0
;
}
static
bool
MakeDir
(
const
wchar_t
*
wdir
)
{
char
dir
[
1024
];
BufferIO
::
EncodeUTF8
(
wdir
,
dir
);
return
MakeDir
(
dir
);
}
static
void
TraversalDir
(
const
char
*
path
,
const
std
::
function
<
void
(
const
char
*
,
bool
)
>&
cb
)
{
DIR
*
dir
=
nullptr
;
struct
dirent
*
dirp
=
nullptr
;
if
((
dir
=
opendir
(
path
))
==
nullptr
)
return
;
struct
stat
fileStat
;
while
((
dirp
=
readdir
(
dir
))
!=
nullptr
)
{
char
fname
[
1024
];
strcpy
(
fname
,
path
);
strcat
(
fname
,
"/"
);
strcat
(
fname
,
dirp
->
d_name
);
stat
(
fname
,
&
fileStat
);
cb
(
dirp
->
d_name
,
S_ISDIR
(
fileStat
.
st_mode
));
}
closedir
(
dir
);
}
static
void
TraversalDir
(
const
wchar_t
*
wpath
,
const
std
::
function
<
void
(
const
wchar_t
*
,
bool
)
>&
cb
)
{
char
path
[
1024
];
BufferIO
::
EncodeUTF8
(
wpath
,
path
);
TraversalDir
(
path
,
[
&
cb
](
const
char
*
name
,
bool
isdir
)
{
wchar_t
wname
[
1024
];
BufferIO
::
DecodeUTF8
(
name
,
wname
);
cb
(
wname
,
isdir
);
});
}
};
#endif // _WIN32
#endif //FILESYSTEM_H
gframe/premake4.lua
View file @
d0417aae
...
...
@@ -8,7 +8,7 @@ project "ygopro"
if
mr
and
tonumber
(
mr
)
then
defines
{
"DEFAULT_DUEL_RULE="
..
tonumber
(
mr
)
}
end
files
{
"gframe.cpp"
,
"config.h"
,
"game.cpp"
,
"game.h"
,
"game.cpp"
,
"game.h"
,
"myfilesystem.h"
,
"deck_manager.cpp"
,
"deck_manager.h"
,
"data_manager.cpp"
,
"data_manager.h"
,
"replay.cpp"
,
"replay.h"
,
...
...
gframe/replay.cpp
View file @
d0417aae
...
...
@@ -24,6 +24,8 @@ void Replay::BeginRecord() {
#ifdef YGOPRO_SERVER_MODE
if
(
replay_mode
>
0
)
{
#endif
if
(
!
FileSystem
::
IsDirExists
(
L"./replay"
)
&&
!
FileSystem
::
MakeDir
(
L"./replay"
))
return
;
#ifdef _WIN32
if
(
is_recording
)
CloseHandle
(
recording_fp
);
...
...
@@ -177,6 +179,8 @@ void Replay::EndRecord() {
is_recording
=
false
;
}
void
Replay
::
SaveReplay
(
const
wchar_t
*
name
)
{
if
(
!
FileSystem
::
IsDirExists
(
L"./replay"
)
&&
!
FileSystem
::
MakeDir
(
L"./replay"
))
return
;
wchar_t
fname
[
256
];
myswprintf
(
fname
,
L"./replay/%ls.yrp"
,
name
);
#ifdef WIN32
...
...
gframe/single_mode.cpp
View file @
d0417aae
...
...
@@ -152,7 +152,7 @@ int SingleMode::SinglePlayThread(void* param) {
mainGame
->
actionParam
=
1
;
wchar_t
msgbuf
[
256
];
myswprintf
(
msgbuf
,
dataManager
.
GetSysString
(
1376
),
timetext
);
mainGame
->
SetStaticText
(
mainGame
->
stACMessage
,
310
,
mainGame
->
text
Font
,
msgbuf
);
mainGame
->
SetStaticText
(
mainGame
->
stACMessage
,
310
,
mainGame
->
gui
Font
,
msgbuf
);
mainGame
->
PopupElement
(
mainGame
->
wACMessage
,
20
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
WaitFrameSignal
(
30
);
...
...
@@ -779,7 +779,7 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
memcpy
(
msgbuf
,
begin
,
len
+
1
);
BufferIO
::
DecodeUTF8
(
msgbuf
,
msg
);
mainGame
->
gMutex
.
Lock
();
mainGame
->
SetStaticText
(
mainGame
->
stMessage
,
310
,
mainGame
->
text
Font
,
msg
);
mainGame
->
SetStaticText
(
mainGame
->
stMessage
,
310
,
mainGame
->
gui
Font
,
msg
);
mainGame
->
PopupElement
(
mainGame
->
wMessage
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
actionSignal
.
Reset
();
...
...
gframe/sound_manager.cpp
View file @
d0417aae
#include "sound_manager.h"
#ifndef _WIN32
#include <dirent.h>
#endif
#ifdef YGOPRO_USE_IRRKLANG
#include "../ikpmp3/ikpMP3.h"
#endif
...
...
@@ -31,55 +28,25 @@ bool SoundManager::Init() {
void
SoundManager
::
RefreshBGMList
()
{
#ifdef YGOPRO_USE_IRRKLANG
RefershBGMDir
(
L""
,
BGM_DUEL
);
RefershBGMDir
(
L"duel
/
"
,
BGM_DUEL
);
RefershBGMDir
(
L"menu
/
"
,
BGM_MENU
);
RefershBGMDir
(
L"deck
/
"
,
BGM_DECK
);
RefershBGMDir
(
L"advantage
/
"
,
BGM_ADVANTAGE
);
RefershBGMDir
(
L"disadvantage
/
"
,
BGM_DISADVANTAGE
);
RefershBGMDir
(
L"win
/
"
,
BGM_WIN
);
RefershBGMDir
(
L"lose
/
"
,
BGM_LOSE
);
RefershBGMDir
(
L"custom
/
"
,
BGM_CUSTOM
);
RefershBGMDir
(
L"duel"
,
BGM_DUEL
);
RefershBGMDir
(
L"menu"
,
BGM_MENU
);
RefershBGMDir
(
L"deck"
,
BGM_DECK
);
RefershBGMDir
(
L"advantage"
,
BGM_ADVANTAGE
);
RefershBGMDir
(
L"disadvantage"
,
BGM_DISADVANTAGE
);
RefershBGMDir
(
L"win"
,
BGM_WIN
);
RefershBGMDir
(
L"lose"
,
BGM_LOSE
);
RefershBGMDir
(
L"custom"
,
BGM_CUSTOM
);
#endif
}
void
SoundManager
::
RefershBGMDir
(
std
::
wstring
path
,
int
scene
)
{
#ifdef YGOPRO_USE_IRRKLANG
#ifdef _WIN32
WIN32_FIND_DATAW
fdataw
;
std
::
wstring
search
=
L"./sound/BGM/"
+
path
+
L"*.*"
;
HANDLE
fh
=
FindFirstFileW
(
search
.
c_str
(),
&
fdataw
);
if
(
fh
==
INVALID_HANDLE_VALUE
)
return
;
do
{
size_t
len
=
wcslen
(
fdataw
.
cFileName
);
if
((
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
||
len
<
5
||
!
(
_wcsicmp
(
fdataw
.
cFileName
+
len
-
4
,
L".mp3"
)
==
0
||
_wcsicmp
(
fdataw
.
cFileName
+
len
-
4
,
L".ogg"
)
==
0
))
continue
;
std
::
wstring
filename
=
path
+
(
std
::
wstring
)
fdataw
.
cFileName
;
BGMList
[
BGM_ALL
].
push_back
(
filename
);
BGMList
[
scene
].
push_back
(
filename
);
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
FindClose
(
fh
);
#else
DIR
*
dir
;
struct
dirent
*
dirp
;
std
::
wstring
wsearchpath
=
L"./sound/BGM/"
+
path
;
char
searchpath
[
256
];
BufferIO
::
EncodeUTF8
(
wsearchpath
.
c_str
(),
searchpath
);
if
((
dir
=
opendir
(
searchpath
))
==
NULL
)
return
;
while
((
dirp
=
readdir
(
dir
))
!=
NULL
)
{
size_t
len
=
strlen
(
dirp
->
d_name
);
if
(
len
<
5
||
!
(
strcasecmp
(
dirp
->
d_name
+
len
-
4
,
".mp3"
)
==
0
||
strcasecmp
(
dirp
->
d_name
+
len
-
4
,
".ogg"
)))
continue
;
wchar_t
wname
[
256
];
BufferIO
::
DecodeUTF8
(
dirp
->
d_name
,
wname
);
std
::
wstring
filename
=
path
+
(
std
::
wstring
)
wname
;
BGMList
[
BGM_ALL
].
push_back
(
filename
);
BGMList
[
scene
].
push_back
(
filename
);
}
closedir
(
dir
);
#endif
#endif
std
::
wstring
search
=
L"./sound/BGM/"
+
path
;
FileSystem
::
TraversalDir
(
search
.
c_str
(),
[
this
,
&
path
,
scene
](
const
wchar_t
*
name
,
bool
isdir
)
{
if
(
!
isdir
&&
wcsrchr
(
name
,
'.'
)
&&
(
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".mp3"
,
4
)
||
!
mywcsncasecmp
(
wcsrchr
(
name
,
'.'
),
L".ogg"
,
4
)))
{
std
::
wstring
filename
=
path
+
L"/"
+
name
;
BGMList
[
BGM_ALL
].
push_back
(
filename
);
BGMList
[
scene
].
push_back
(
filename
);
}
});
}
void
SoundManager
::
PlaySoundEffect
(
int
sound
)
{
#ifdef YGOPRO_USE_IRRKLANG
...
...
ocgcore
@
a85b90e1
Subproject commit
17c2dfaf1b157fb65e81ab05883106a3cc38e2ae
Subproject commit
a85b90e10c0a93763cc8650f743f924aae5a33b2
premake5.lua
View file @
d0417aae
...
...
@@ -37,7 +37,7 @@ solution "ygo"
optimize
"Speed"
flags
{
"LinkTimeOptimization"
}
staticruntime
"On"
disablewarnings
{
"4244"
,
"4267"
,
"4838"
,
"4577"
,
"4819"
,
"4018"
,
"4996"
,
"4477"
,
"4091"
,
"4305"
,
"4828"
}
disablewarnings
{
"4244"
,
"4267"
,
"4838"
,
"4577"
,
"4819"
,
"4018"
,
"4996"
,
"4477"
,
"4091"
,
"4305"
,
"4828"
,
"4800"
}
configuration
{
"Release"
,
"not vs*"
}
symbols
"On"
...
...
script
@
74c6c3d8
Subproject commit
aaef0a01369bd09bf0e4dd812483df1d0f856f3a
Subproject commit
74c6c3d87e622eaf8f80344d4b1578c69333cd16
strings.conf
View file @
d0417aae
...
...
@@ -939,3 +939,4 @@
!
setname
0
x121
魔妖
!
setname
0
x122
女武神
Valkyrie
!
setname
0
x123
蔷薇龙 ローズ・ドラゴン
!
setname
0
x124
机械天使 機械天使
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