Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile-Cn-Ko-En
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
fallenstardust
YGOMobile-Cn-Ko-En
Commits
bc24c894
Commit
bc24c894
authored
Feb 23, 2025
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update Gframe
parent
24b39d1c
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
134 additions
and
135 deletions
+134
-135
Classes/gframe/client_field.cpp
Classes/gframe/client_field.cpp
+2
-1
Classes/gframe/config.h
Classes/gframe/config.h
+5
-3
Classes/gframe/data_manager.cpp
Classes/gframe/data_manager.cpp
+9
-12
Classes/gframe/deck_con.cpp
Classes/gframe/deck_con.cpp
+19
-11
Classes/gframe/deck_manager.cpp
Classes/gframe/deck_manager.cpp
+30
-38
Classes/gframe/deck_manager.h
Classes/gframe/deck_manager.h
+2
-2
Classes/gframe/game.cpp
Classes/gframe/game.cpp
+14
-15
Classes/gframe/image_manager.cpp
Classes/gframe/image_manager.cpp
+6
-6
Classes/gframe/materials.h
Classes/gframe/materials.h
+4
-4
Classes/gframe/menu_handler.cpp
Classes/gframe/menu_handler.cpp
+19
-19
Classes/gframe/replay.cpp
Classes/gframe/replay.cpp
+23
-23
Classes/gframe/single_mode.cpp
Classes/gframe/single_mode.cpp
+1
-1
No files found.
Classes/gframe/client_field.cpp
View file @
bc24c894
...
@@ -615,7 +615,7 @@ void ClientField::ShowLocationCard() {
...
@@ -615,7 +615,7 @@ void ClientField::ShowLocationCard() {
if
(
display_cards
[
i
]
->
code
)
if
(
display_cards
[
i
]
->
code
)
mainGame
->
imageLoading
.
insert
(
std
::
make_pair
(
mainGame
->
btnCardDisplay
[
i
],
display_cards
[
i
]
->
code
));
mainGame
->
imageLoading
.
insert
(
std
::
make_pair
(
mainGame
->
btnCardDisplay
[
i
],
display_cards
[
i
]
->
code
));
else
else
mainGame
->
btnCardDisplay
[
i
]
->
setImage
(
imageManager
.
tCover
[
display_cards
[
i
]
->
controler
]);
mainGame
->
btnCardDisplay
[
i
]
->
setImage
(
imageManager
.
tCover
[
display_cards
[
i
]
->
controler
+
2
]);
mainGame
->
btnCardDisplay
[
i
]
->
setRelativePosition
(
mainGame
->
Resize_Y
(
startpos
+
125
*
i
,
65
,
startpos
+
120
+
125
*
i
,
65
+
170
));
mainGame
->
btnCardDisplay
[
i
]
->
setRelativePosition
(
mainGame
->
Resize_Y
(
startpos
+
125
*
i
,
65
,
startpos
+
120
+
125
*
i
,
65
+
170
));
mainGame
->
btnCardDisplay
[
i
]
->
setPressed
(
false
);
mainGame
->
btnCardDisplay
[
i
]
->
setPressed
(
false
);
mainGame
->
btnCardDisplay
[
i
]
->
setVisible
(
true
);
mainGame
->
btnCardDisplay
[
i
]
->
setVisible
(
true
);
...
@@ -713,6 +713,7 @@ void ClientField::ShowSelectOption(int select_hint) {
...
@@ -713,6 +713,7 @@ void ClientField::ShowSelectOption(int select_hint) {
recti
pos
=
mainGame
->
wOptions
->
getRelativePosition
();
recti
pos
=
mainGame
->
wOptions
->
getRelativePosition
();
pos
.
LowerRightCorner
.
Y
=
pos
.
UpperLeftCorner
.
Y
+
180
*
mainGame
->
yScale
;
pos
.
LowerRightCorner
.
Y
=
pos
.
UpperLeftCorner
.
Y
+
180
*
mainGame
->
yScale
;
mainGame
->
wOptions
->
setRelativePosition
(
pos
);
mainGame
->
wOptions
->
setRelativePosition
(
pos
);
mainGame
->
bgOptions
->
setRelativePosition
(
pos
);
}
}
if
(
select_hint
)
if
(
select_hint
)
myswprintf
(
textBuffer
,
L"%ls"
,
dataManager
.
GetDesc
(
select_hint
));
myswprintf
(
textBuffer
,
L"%ls"
,
dataManager
.
GetDesc
(
select_hint
));
...
...
Classes/gframe/config.h
View file @
bc24c894
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
#include <android/CustomShaderConstantSetCallBack.h>
#include <android/CustomShaderConstantSetCallBack.h>
#endif
#endif
#define socklen_t int
#ifndef TEXT
#ifndef TEXT
#ifdef UNICODE
#ifdef UNICODE
#define TEXT(x) L##x
#define TEXT(x) L##x
...
@@ -44,7 +46,7 @@
...
@@ -44,7 +46,7 @@
#define mywcsncasecmp wcsncasecmp
#define mywcsncasecmp wcsncasecmp
#define mystrncasecmp strncasecmp
#define mystrncasecmp strncasecmp
#include <
stdio.h
>
#include <
cstdio
>
#include <stdlib.h>
#include <stdlib.h>
#include <iostream>
#include <iostream>
#include <algorithm>
#include <algorithm>
...
@@ -57,11 +59,11 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
...
@@ -57,11 +59,11 @@ 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
{};
char
fname
[
1024
]{};
char
fname
[
1024
]{};
BufferIO
::
EncodeUTF8
(
filename
,
fname
);
BufferIO
::
EncodeUTF8
(
filename
,
fname
);
fp
=
fopen
(
fname
,
mode
);
fp
=
std
::
fopen
(
fname
,
mode
);
return
fp
;
return
fp
;
}
}
...
...
Classes/gframe/data_manager.cpp
View file @
bc24c894
#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
{
...
@@ -105,14 +104,14 @@ bool DataManager::LoadDB(const wchar_t* wfile) {
...
@@ -105,14 +104,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
)
{
...
@@ -136,26 +135,26 @@ void DataManager::ReadStringConfLine(const char* linebuf) {
...
@@ -136,26 +135,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
;
...
@@ -423,9 +422,7 @@ unsigned char* DataManager::ReadScriptFromIrrFS(const char* script_name, int* sl
...
@@ -423,9 +422,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
);
...
...
Classes/gframe/deck_con.cpp
View file @
bc24c894
...
@@ -57,6 +57,14 @@ void SetCategoryDeckNameOnButton(irr::gui::IGUIButton* button, wchar_t* string){
...
@@ -57,6 +57,14 @@ void SetCategoryDeckNameOnButton(irr::gui::IGUIButton* button, wchar_t* string){
button
->
setText
(
cate_deck
);
button
->
setText
(
cate_deck
);
}
}
static
inline
void
get_deck_file
(
wchar_t
*
ret
)
{
deckManager
.
GetDeckFile
(
ret
,
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
}
static
inline
void
load_current_deck
(
irr
::
gui
::
IGUIComboBox
*
cbCategory
,
irr
::
gui
::
IGUIComboBox
*
cbDeck
)
{
deckManager
.
LoadCurrentDeck
(
cbCategory
,
cbDeck
);
}
void
DeckBuilder
::
Initialize
()
{
void
DeckBuilder
::
Initialize
()
{
mainGame
->
is_building
=
true
;
mainGame
->
is_building
=
true
;
mainGame
->
is_siding
=
false
;
mainGame
->
is_siding
=
false
;
...
@@ -200,7 +208,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -200,7 +208,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
);
...
@@ -564,7 +572,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -564,7 +572,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
)
{
...
@@ -596,7 +604,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -596,7 +604,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
);
...
@@ -607,7 +615,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -607,7 +615,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
;
...
@@ -626,7 +634,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -626,7 +634,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
);
...
@@ -741,7 +749,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -741,7 +749,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_MSG_OK
:
{
case
BUTTON_MSG_OK
:
{
...
@@ -761,7 +769,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -761,7 +769,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
();
...
@@ -769,7 +777,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -769,7 +777,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
;
...
@@ -784,7 +792,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -784,7 +792,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
)
{
...
@@ -901,7 +909,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -901,7 +909,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
;
...
@@ -1690,7 +1698,7 @@ void DeckBuilder::ChangeCategory(int catesel) {
...
@@ -1690,7 +1698,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
;
...
...
Classes/gframe/deck_manager.cpp
View file @
bc24c894
#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
(
android
::
InitOptions
*
options
)
{
void
DeckManager
::
LoadLFList
(
android
::
InitOptions
*
options
)
{
...
@@ -73,12 +70,12 @@ const std::unordered_map<int, int>* DeckManager::GetLFListContent(int lfhash) {
...
@@ -73,12 +70,12 @@ const std::unordered_map<int, int>* DeckManager::GetLFListContent(int lfhash) {
return
&
lit
->
content
;
return
&
lit
->
content
;
return
nullptr
;
return
nullptr
;
}
}
static
int
checkAvail
(
unsigned
int
ot
,
unsigned
int
avail
)
{
static
unsigned
int
checkAvail
(
unsigned
int
ot
,
unsigned
int
avail
)
{
if
((
ot
&
avail
)
==
avail
)
if
((
ot
&
avail
)
==
avail
)
return
0
;
return
0
;
if
((
ot
&
AVAIL_OCG
)
&&
!
(
avail
=
=
AVAIL_OCG
))
if
((
ot
&
AVAIL_OCG
)
&&
(
avail
!
=
AVAIL_OCG
))
return
DECKERROR_OCGONLY
;
return
DECKERROR_OCGONLY
;
if
((
ot
&
AVAIL_TCG
)
&&
!
(
avail
=
=
AVAIL_TCG
))
if
((
ot
&
AVAIL_TCG
)
&&
(
avail
!
=
AVAIL_TCG
))
return
DECKERROR_TCGONLY
;
return
DECKERROR_TCGONLY
;
return
DECKERROR_NOTAVAIL
;
return
DECKERROR_NOTAVAIL
;
}
}
...
@@ -279,13 +276,13 @@ void DeckManager::GetDeckFile(wchar_t* ret, irr::gui::IGUIComboBox* cbCategory,
...
@@ -279,13 +276,13 @@ 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
)
{
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
);
return
reader
;
return
reader
;
}
}
bool
DeckManager
::
LoadCurrentDeck
(
const
wchar_t
*
file
,
bool
is_packlist
)
{
bool
DeckManager
::
LoadCurrentDeck
(
const
wchar_t
*
file
,
bool
is_packlist
)
{
...
@@ -328,28 +325,23 @@ bool DeckManager::SaveDeck(Deck& deck, const wchar_t* file) {
...
@@ -328,28 +325,23 @@ 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 ygomobile
\n
#main
\n
"
);
std
::
fprintf
(
fp
,
"#created by ygomobile
\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
)
{
#ifdef _WIN32
BOOL
result
=
DeleteFileW
(
file
);
return
!!
result
;
#else
char
filefn
[
256
];
char
filefn
[
256
];
BufferIO
::
EncodeUTF8
(
file
,
filefn
);
BufferIO
::
EncodeUTF8
(
file
,
filefn
);
int
result
=
unlink
(
filefn
);
int
result
=
unlink
(
filefn
);
return
result
==
0
;
return
result
==
0
;
#endif
}
}
bool
DeckManager
::
CreateCategory
(
const
wchar_t
*
name
)
{
bool
DeckManager
::
CreateCategory
(
const
wchar_t
*
name
)
{
if
(
!
FileSystem
::
IsDirExists
(
L"./deck"
)
&&
!
FileSystem
::
MakeDir
(
L"./deck"
))
if
(
!
FileSystem
::
IsDirExists
(
L"./deck"
)
&&
!
FileSystem
::
MakeDir
(
L"./deck"
))
...
@@ -387,26 +379,26 @@ bool DeckManager::SaveDeckBuffer(const int deckbuf[], const wchar_t* name) {
...
@@ -387,26 +379,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
;
}
}
int
DeckManager
::
TypeCount
(
std
::
vector
<
code_pointer
>
list
,
unsigned
int
ctype
)
{
int
DeckManager
::
TypeCount
(
std
::
vector
<
code_pointer
>
list
,
unsigned
int
ctype
)
{
...
...
Classes/gframe/deck_manager.h
View file @
bc24c894
...
@@ -2,10 +2,10 @@
...
@@ -2,10 +2,10 @@
#define DECKMANAGER_H
#define DECKMANAGER_H
#include "config.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
;
...
@@ -54,7 +54,7 @@ public:
...
@@ -54,7 +54,7 @@ public:
void
GetCategoryPath
(
wchar_t
*
ret
,
int
index
,
const
wchar_t
*
text
,
bool
showPack
);
//
void
GetCategoryPath
(
wchar_t
*
ret
,
int
index
,
const
wchar_t
*
text
,
bool
showPack
);
//
void
GetDeckFile
(
wchar_t
*
ret
,
irr
::
gui
::
IGUIComboBox
*
cbCategory
,
irr
::
gui
::
IGUIComboBox
*
cbDeck
);
void
GetDeckFile
(
wchar_t
*
ret
,
irr
::
gui
::
IGUIComboBox
*
cbCategory
,
irr
::
gui
::
IGUIComboBox
*
cbDeck
);
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
(
irr
::
gui
::
IGUIComboBox
*
cbCategory
,
irr
::
gui
::
IGUIComboBox
*
cbDeck
);
bool
LoadCurrentDeck
(
irr
::
gui
::
IGUIComboBox
*
cbCategory
,
irr
::
gui
::
IGUIComboBox
*
cbDeck
);
bool
SaveDeck
(
Deck
&
deck
,
const
wchar_t
*
file
);
bool
SaveDeck
(
Deck
&
deck
,
const
wchar_t
*
file
);
...
...
Classes/gframe/game.cpp
View file @
bc24c894
...
@@ -1483,7 +1483,6 @@ void Game::MainLoop() {
...
@@ -1483,7 +1483,6 @@ void Game::MainLoop() {
if
(
cur_time
<
fps
*
17
-
20
)
if
(
cur_time
<
fps
*
17
-
20
)
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
20
));
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
20
));
if
(
cur_time
>=
1000
)
{
if
(
cur_time
>=
1000
)
{
#ifdef _IRR_ANDROID_PLATFORM_
#ifdef _IRR_ANDROID_PLATFORM_
if
(
stat
)
{
if
(
stat
)
{
stringw
str
=
L"FPS: "
;
stringw
str
=
L"FPS: "
;
...
@@ -1503,7 +1502,7 @@ void Game::MainLoop() {
...
@@ -1503,7 +1502,7 @@ void Game::MainLoop() {
#ifdef _IRR_ANDROID_PLATFORM_
#ifdef _IRR_ANDROID_PLATFORM_
device
->
yield
();
// probably nicer to the battery
device
->
yield
();
// probably nicer to the battery
#endif
#endif
}
}
DuelClient
::
StopClient
(
true
);
DuelClient
::
StopClient
(
true
);
if
(
dInfo
.
isSingleMode
)
if
(
dInfo
.
isSingleMode
)
SingleMode
::
StopPlay
(
true
);
SingleMode
::
StopPlay
(
true
);
...
@@ -1720,29 +1719,29 @@ void Game::RefreshBot() {
...
@@ -1720,29 +1719,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"
);
...
@@ -1756,7 +1755,7 @@ void Game::RefreshBot() {
...
@@ -1756,7 +1755,7 @@ void Game::RefreshBot() {
continue
;
continue
;
}
}
}
}
fclose
(
fp
);
std
::
fclose
(
fp
);
}
}
lstBotList
->
clear
();
lstBotList
->
clear
();
stBotInfo
->
setText
(
L""
);
stBotInfo
->
setText
(
L""
);
...
@@ -2049,19 +2048,19 @@ void Game::AddDebugMsg(const char* msg) {
...
@@ -2049,19 +2048,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
::
addMessageBox
(
const
wchar_t
*
caption
,
const
wchar_t
*
text
)
{
void
Game
::
addMessageBox
(
const
wchar_t
*
caption
,
const
wchar_t
*
text
)
{
SetStaticText
(
stSysMessage
,
370
*
xScale
,
guiFont
,
text
);
SetStaticText
(
stSysMessage
,
370
*
xScale
,
guiFont
,
text
);
...
...
Classes/gframe/image_manager.cpp
View file @
bc24c894
...
@@ -191,10 +191,10 @@ irr::video::ITexture* ImageManager::GetBigPicture(int code, float zoom) {
...
@@ -191,10 +191,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
)
{
...
@@ -222,18 +222,18 @@ irr::video::ITexture* ImageManager::GetTextureField(int code) {
...
@@ -222,18 +222,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
,
"field/%s/%d.jpg"
,
irr
::
android
::
getCardImagePath
(
mainGame
->
appMain
).
c_str
(),
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"field/%s/%d.jpg"
,
irr
::
android
::
getCardImagePath
(
mainGame
->
appMain
).
c_str
(),
code
);
irr
::
video
::
ITexture
*
img
=
driver
->
getTexture
(
file
);
irr
::
video
::
ITexture
*
img
=
driver
->
getTexture
(
file
);
if
(
img
==
nullptr
)
{
if
(
img
==
nullptr
)
{
snprintf
(
file
,
sizeof
file
,
"field/%s/%d.jpg"
,
irr
::
android
::
getCardImagePath
(
mainGame
->
appMain
).
c_str
(),
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"field/%s/%d.jpg"
,
irr
::
android
::
getCardImagePath
(
mainGame
->
appMain
).
c_str
(),
code
);
img
=
driver
->
getTexture
(
file
);
img
=
driver
->
getTexture
(
file
);
}
}
if
(
img
==
nullptr
)
{
if
(
img
==
nullptr
)
{
snprintf
(
file
,
sizeof
file
,
"field/%s/%d.png"
,
irr
::
android
::
getCardImagePath
(
mainGame
->
appMain
).
c_str
(),
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"field/%s/%d.png"
,
irr
::
android
::
getCardImagePath
(
mainGame
->
appMain
).
c_str
(),
code
);
img
=
driver
->
getTexture
(
file
);
img
=
driver
->
getTexture
(
file
);
}
}
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
=
driver
->
getTexture
(
file
);
img
=
driver
->
getTexture
(
file
);
if
(
img
==
nullptr
)
{
if
(
img
==
nullptr
)
{
tFields
[
code
]
=
nullptr
;
tFields
[
code
]
=
nullptr
;
...
...
Classes/gframe/materials.h
View file @
bc24c894
...
@@ -27,11 +27,11 @@ public:
...
@@ -27,11 +27,11 @@ public:
S3DVertex
vSelField
[
4
];
S3DVertex
vSelField
[
4
];
//S3DVertex vBackLine[76];
//S3DVertex vBackLine[76];
S3DVertex
vFieldDeck
[
2
][
4
];
S3DVertex
vFieldDeck
[
2
][
4
];
S3DVertex
vFieldGrave
[
2
][
2
][
4
];
S3DVertex
vFieldGrave
[
2
][
2
][
4
];
//[player][rule], rule = 0: dule_rule <= 3, 1: dule_rule >= 4
S3DVertex
vFieldExtra
[
2
][
4
];
S3DVertex
vFieldExtra
[
2
][
4
];
S3DVertex
vFieldRemove
[
2
][
2
][
4
];
S3DVertex
vFieldRemove
[
2
][
2
][
4
];
//[player][rule]
S3DVertex
vFieldMzone
[
2
][
7
][
4
];
S3DVertex
vFieldMzone
[
2
][
7
][
4
];
//[player][sequence]
S3DVertex
vFieldSzone
[
2
][
8
][
2
][
4
];
S3DVertex
vFieldSzone
[
2
][
8
][
2
][
4
];
//[player][sequence][rule]
irr
::
core
::
vector3df
vFieldContiAct
[
4
];
irr
::
core
::
vector3df
vFieldContiAct
[
4
];
S3DVertex
vArrow
[
40
];
S3DVertex
vArrow
[
40
];
SColor
c2d
[
4
];
SColor
c2d
[
4
];
...
...
Classes/gframe/menu_handler.cpp
View file @
bc24c894
...
@@ -79,7 +79,7 @@ void ChangeHostPrepareDeckCategory(int catesel) {
...
@@ -79,7 +79,7 @@ void ChangeHostPrepareDeckCategory(int catesel) {
mainGame
->
deckBuilder
.
prev_deck
=
0
;
mainGame
->
deckBuilder
.
prev_deck
=
0
;
}
}
void
reSetCategoryDeckNameOnButton
(
irr
::
gui
::
IGUIButton
*
button
,
wchar_t
*
string
){
void
reSetCategoryDeckNameOnButton
(
irr
::
gui
::
IGUIButton
*
button
,
const
wchar_t
*
string
){
wchar_t
cate
[
256
];
wchar_t
cate
[
256
];
wchar_t
cate_deck
[
256
];
wchar_t
cate_deck
[
256
];
myswprintf
(
cate
,
L"%ls%ls"
,
(
mainGame
->
lstCategories
->
getSelected
())
==
1
?
L""
:
mainGame
->
lstCategories
->
getListItem
(
mainGame
->
lstCategories
->
getSelected
()),
(
mainGame
->
lstCategories
->
getSelected
())
==
1
?
L""
:
string
);
myswprintf
(
cate
,
L"%ls%ls"
,
(
mainGame
->
lstCategories
->
getSelected
())
==
1
?
L""
:
mainGame
->
lstCategories
->
getListItem
(
mainGame
->
lstCategories
->
getSelected
()),
(
mainGame
->
lstCategories
->
getSelected
())
==
1
?
L""
:
string
);
...
@@ -369,23 +369,23 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
...
@@ -369,23 +369,23 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
prev_sel
=
sel
;
prev_sel
=
sel
;
break
;
break
;
}
}
case
BUTTON_SHARE_REPLAY
:
{
case
BUTTON_SHARE_REPLAY
:
{
int
sel
=
mainGame
->
lstReplayList
->
getSelected
();
int
sel
=
mainGame
->
lstReplayList
->
getSelected
();
if
(
sel
==
-
1
)
if
(
sel
==
-
1
)
break
;
break
;
mainGame
->
gMutex
.
lock
();
mainGame
->
gMutex
.
lock
();
char
name
[
1024
];
char
name
[
1024
];
BufferIO
::
EncodeUTF8
(
mainGame
->
lstReplayList
->
getListItem
(
sel
),
name
);
BufferIO
::
EncodeUTF8
(
mainGame
->
lstReplayList
->
getListItem
(
sel
),
name
);
mainGame
->
gMutex
.
unlock
();
mainGame
->
gMutex
.
unlock
();
prev_operation
=
id
;
prev_operation
=
id
;
prev_sel
=
sel
;
prev_sel
=
sel
;
#ifdef _IRR_ANDROID_PLATFORM_
#ifdef _IRR_ANDROID_PLATFORM_
ALOGD
(
"cc menu_handler: 1share replay file=%s"
,
name
);
ALOGD
(
"cc menu_handler: 1share replay file=%s"
,
name
);
android
::
OnShareFile
(
mainGame
->
appMain
,
"yrp"
,
name
);
android
::
OnShareFile
(
mainGame
->
appMain
,
"yrp"
,
name
);
ALOGD
(
"cc menu_handler: 2after share replay file:index=%d"
,
sel
);
ALOGD
(
"cc menu_handler: 2after share replay file:index=%d"
,
sel
);
#endif
#endif
break
;
break
;
}
}
case
BUTTON_RENAME_REPLAY
:
{
case
BUTTON_RENAME_REPLAY
:
{
int
sel
=
mainGame
->
lstReplayList
->
getSelected
();
int
sel
=
mainGame
->
lstReplayList
->
getSelected
();
if
(
sel
==
-
1
)
if
(
sel
==
-
1
)
...
@@ -676,7 +676,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
...
@@ -676,7 +676,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
;
...
@@ -685,7 +685,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
...
@@ -685,7 +685,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
,
']'
);
...
@@ -708,7 +708,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
...
@@ -708,7 +708,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
->
xScale
,
mainGame
->
guiFont
,
message
.
c_str
());
mainGame
->
SetStaticText
(
mainGame
->
stSinglePlayInfo
,
200
*
mainGame
->
xScale
,
mainGame
->
guiFont
,
message
.
c_str
());
break
;
break
;
}
}
...
...
Classes/gframe/replay.cpp
View file @
bc24c894
...
@@ -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
)
{
...
...
Classes/gframe/single_mode.cpp
View file @
bc24c894
...
@@ -61,7 +61,7 @@ int SingleMode::SinglePlayThread() {
...
@@ -61,7 +61,7 @@ int SingleMode::SinglePlayThread() {
wchar_t
fname
[
256
]{};
wchar_t
fname
[
256
]{};
myswprintf
(
fname
,
L"./single/%ls"
,
name
);
myswprintf
(
fname
,
L"./single/%ls"
,
name
);
slen
=
BufferIO
::
EncodeUTF8
(
fname
,
filename
);
slen
=
BufferIO
::
EncodeUTF8
(
fname
,
filename
);
if
(
!
preload_script
(
pduel
,
filename
))
if
(
!
preload_script
(
pduel
,
filename
))
slen
=
0
;
slen
=
0
;
if
(
slen
==
0
)
{
if
(
slen
==
0
)
{
end_duel
(
pduel
);
end_duel
(
pduel
);
...
...
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