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
1
Merge Requests
1
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
nanahira
ygopro
Commits
8e433afc
Commit
8e433afc
authored
Mar 04, 2018
by
edo9300
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'refs/remotes/Fluorohydride/master'
parents
e8c08077
15d26211
Changes
14
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
397 additions
and
76 deletions
+397
-76
gframe/client_card.h
gframe/client_card.h
+3
-3
gframe/client_field.cpp
gframe/client_field.cpp
+12
-12
gframe/config.h
gframe/config.h
+9
-3
gframe/data_manager.cpp
gframe/data_manager.cpp
+22
-29
gframe/duelclient.cpp
gframe/duelclient.cpp
+8
-2
gframe/game.cpp
gframe/game.cpp
+6
-2
gframe/game.h
gframe/game.h
+5
-0
gframe/gframe.cpp
gframe/gframe.cpp
+18
-0
gframe/menu_handler.cpp
gframe/menu_handler.cpp
+78
-0
gframe/menu_handler.h
gframe/menu_handler.h
+3
-1
gframe/replay.cpp
gframe/replay.cpp
+30
-0
gframe/replay.h
gframe/replay.h
+2
-0
gframe/single_mode.cpp
gframe/single_mode.cpp
+1
-0
lflist.conf
lflist.conf
+200
-24
No files found.
gframe/client_card.h
View file @
8e433afc
...
...
@@ -39,9 +39,9 @@ struct CardDataC {
unsigned
int
category
;
};
struct
CardString
{
wchar_t
*
name
;
wchar_t
*
text
;
wchar_t
*
desc
[
16
];
std
::
wstring
name
;
std
::
wstring
text
;
std
::
wstring
desc
[
16
];
};
typedef
std
::
unordered_map
<
unsigned
int
,
CardDataC
>::
const_iterator
code_pointer
;
...
...
gframe/client_field.cpp
View file @
8e433afc
...
...
@@ -654,10 +654,10 @@ void ClientField::ReplaySwap() {
(
*
cit
)
->
is_moving
=
false
;
}
mainGame
->
dInfo
.
isFirst
=
!
mainGame
->
dInfo
.
isFirst
;
mainGame
->
dInfo
.
isReplaySwapped
=
!
mainGame
->
dInfo
.
isReplaySwapped
;
std
::
swap
(
mainGame
->
dInfo
.
lp
[
0
],
mainGame
->
dInfo
.
lp
[
1
]);
std
::
swap
(
mainGame
->
dInfo
.
strLP
[
0
],
mainGame
->
dInfo
.
strLP
[
1
]);
std
::
swap
(
mainGame
->
dInfo
.
hostname
[
0
],
mainGame
->
dInfo
.
clientname
[
0
]);
std
::
swap
(
mainGame
->
dInfo
.
hostname
[
1
],
mainGame
->
dInfo
.
clientname
[
1
]);
std
::
swap
(
mainGame
->
dInfo
.
hostname
,
mainGame
->
dInfo
.
clientname
);
for
(
auto
chit
=
chains
.
begin
();
chit
!=
chains
.
end
();
++
chit
)
{
chit
->
controler
=
1
-
chit
->
controler
;
GetChainLocation
(
chit
->
controler
,
chit
->
location
,
chit
->
sequence
,
&
chit
->
chain_pos
);
...
...
@@ -1413,7 +1413,7 @@ void ClientField::UpdateDeclarableCodeType(bool enter) {
if
(
dataManager
.
GetString
(
trycode
,
&
cstr
)
&&
dataManager
.
GetData
(
trycode
,
&
cd
)
&&
is_declarable
(
cd
,
declarable_type
))
{
mainGame
->
lstANCard
->
clear
();
ancard
.
clear
();
mainGame
->
lstANCard
->
addItem
(
cstr
.
name
);
mainGame
->
lstANCard
->
addItem
(
cstr
.
name
.
c_str
()
);
ancard
.
push_back
(
trycode
);
return
;
}
...
...
@@ -1422,15 +1422,15 @@ void ClientField::UpdateDeclarableCodeType(bool enter) {
mainGame
->
lstANCard
->
clear
();
ancard
.
clear
();
for
(
auto
cit
=
dataManager
.
_strings
.
begin
();
cit
!=
dataManager
.
_strings
.
end
();
++
cit
)
{
if
(
DeckBuilder
::
CardNameCompare
(
cit
->
second
.
name
,
pname
)
!=
0
)
{
if
(
DeckBuilder
::
CardNameCompare
(
cit
->
second
.
name
.
c_str
()
,
pname
)
!=
0
)
{
auto
cp
=
dataManager
.
GetCodePointer
(
cit
->
first
);
//verified by _strings
//datas.alias can be double card names or alias
if
(
is_declarable
(
cp
->
second
,
declarable_type
))
{
if
(
wcscmp
(
pname
,
cit
->
second
.
name
)
==
0
)
{
//exact match
mainGame
->
lstANCard
->
insertItem
(
0
,
cit
->
second
.
name
,
-
1
);
if
(
pname
==
cit
->
second
.
name
)
{
//exact match
mainGame
->
lstANCard
->
insertItem
(
0
,
cit
->
second
.
name
.
c_str
()
,
-
1
);
ancard
.
insert
(
ancard
.
begin
(),
cit
->
first
);
}
else
{
mainGame
->
lstANCard
->
addItem
(
cit
->
second
.
name
);
mainGame
->
lstANCard
->
addItem
(
cit
->
second
.
name
.
c_str
()
);
ancard
.
push_back
(
cit
->
first
);
}
}
...
...
@@ -1445,7 +1445,7 @@ void ClientField::UpdateDeclarableCodeOpcode(bool enter) {
if
(
dataManager
.
GetString
(
trycode
,
&
cstr
)
&&
dataManager
.
GetData
(
trycode
,
&
cd
)
&&
is_declarable
(
cd
,
opcode
))
{
mainGame
->
lstANCard
->
clear
();
ancard
.
clear
();
mainGame
->
lstANCard
->
addItem
(
cstr
.
name
);
mainGame
->
lstANCard
->
addItem
(
cstr
.
name
.
c_str
()
);
ancard
.
push_back
(
trycode
);
return
;
}
...
...
@@ -1454,15 +1454,15 @@ void ClientField::UpdateDeclarableCodeOpcode(bool enter) {
mainGame
->
lstANCard
->
clear
();
ancard
.
clear
();
for
(
auto
cit
=
dataManager
.
_strings
.
begin
();
cit
!=
dataManager
.
_strings
.
end
();
++
cit
)
{
if
(
DeckBuilder
::
CardNameCompare
(
cit
->
second
.
name
,
pname
))
{
if
(
DeckBuilder
::
CardNameCompare
(
cit
->
second
.
name
.
c_str
()
,
pname
))
{
auto
cp
=
dataManager
.
GetCodePointer
(
cit
->
first
);
//verified by _strings
//datas.alias can be double card names or alias
if
(
is_declarable
(
cp
->
second
,
opcode
))
{
if
(
wcscmp
(
pname
,
cit
->
second
.
name
)
==
0
)
{
//exact match
mainGame
->
lstANCard
->
insertItem
(
0
,
cit
->
second
.
name
,
-
1
);
if
(
pname
==
cit
->
second
.
name
)
{
//exact match
mainGame
->
lstANCard
->
insertItem
(
0
,
cit
->
second
.
name
.
c_str
()
,
-
1
);
ancard
.
insert
(
ancard
.
begin
(),
cit
->
first
);
}
else
{
mainGame
->
lstANCard
->
addItem
(
cit
->
second
.
name
);
mainGame
->
lstANCard
->
addItem
(
cit
->
second
.
name
.
c_str
()
);
ancard
.
push_back
(
cit
->
first
);
}
}
...
...
gframe/config.h
View file @
8e433afc
...
...
@@ -12,9 +12,13 @@
#include <ws2tcpip.h>
#ifdef _MSC_VER
#define myswprintf _swprintf
#define myswprintf _swprintf
#define mywcsncasecmp _wcsnicmp
#define mystrncasecmp _strnicmp
#else
#define myswprintf swprintf
#define myswprintf swprintf
#define mywcsncasecmp wcsncasecmp
#define mystrncasecmp strncasecmp
#endif
#define socklen_t int
...
...
@@ -40,7 +44,9 @@
#define SOCKET_ERRNO() (errno)
#include <wchar.h>
#define myswprintf(buf, fmt, ...) swprintf(buf, 4096, fmt, ##__VA_ARGS__)
#define myswprintf(buf, fmt, ...) swprintf(buf, 4096, fmt, ##__VA_ARGS__)
#define mywcsncasecmp wcsncasecmp
#define mystrncasecmp strncasecmp
inline
int
_wtoi
(
const
wchar_t
*
s
)
{
wchar_t
*
endptr
;
return
(
int
)
wcstol
(
s
,
&
endptr
,
10
);
...
...
gframe/data_manager.cpp
View file @
8e433afc
...
...
@@ -17,8 +17,7 @@ bool DataManager::LoadDB(const char* file) {
return
Error
(
pDB
);
CardDataC
cd
;
CardString
cs
;
for
(
int
i
=
0
;
i
<
16
;
++
i
)
cs
.
desc
[
i
]
=
0
;
int
step
=
0
,
len
=
0
;
int
step
=
0
;
do
{
step
=
sqlite3_step
(
pStmt
);
if
(
step
==
SQLITE_BUSY
||
step
==
SQLITE_ERROR
||
step
==
SQLITE_MISUSE
)
...
...
@@ -49,27 +48,21 @@ bool DataManager::LoadDB(const char* file) {
cd
.
attribute
=
sqlite3_column_int
(
pStmt
,
9
);
cd
.
category
=
sqlite3_column_int
(
pStmt
,
10
);
_datas
.
insert
(
std
::
make_pair
(
cd
.
code
,
cd
));
len
=
BufferIO
::
DecodeUTF8
((
const
char
*
)
sqlite3_column_text
(
pStmt
,
12
),
strBuffer
);
if
(
len
)
{
cs
.
name
=
new
wchar_t
[
len
+
1
];
memcpy
(
cs
.
name
,
strBuffer
,
(
len
+
1
)
*
sizeof
(
wchar_t
));
}
else
cs
.
name
=
0
;
len
=
BufferIO
::
DecodeUTF8
((
const
char
*
)
sqlite3_column_text
(
pStmt
,
13
),
strBuffer
);
if
(
len
)
{
cs
.
text
=
new
wchar_t
[
len
+
1
];
memcpy
(
cs
.
text
,
strBuffer
,
(
len
+
1
)
*
sizeof
(
wchar_t
));
}
else
{
cs
.
text
=
new
wchar_t
[
1
];
cs
.
text
[
0
]
=
0
;
if
(
const
char
*
text
=
(
const
char
*
)
sqlite3_column_text
(
pStmt
,
12
))
{
BufferIO
::
DecodeUTF8
(
text
,
strBuffer
);
cs
.
name
=
strBuffer
;
}
for
(
int
i
=
14
;
i
<
30
;
++
i
)
{
len
=
BufferIO
::
DecodeUTF8
((
const
char
*
)
sqlite3_column_text
(
pStmt
,
i
),
strBuffer
);
if
(
len
)
{
cs
.
desc
[
i
-
14
]
=
new
wchar_t
[
len
+
1
];
memcpy
(
cs
.
desc
[
i
-
14
],
strBuffer
,
(
len
+
1
)
*
sizeof
(
wchar_t
));
}
else
cs
.
desc
[
i
-
14
]
=
0
;
if
(
const
char
*
text
=
(
const
char
*
)
sqlite3_column_text
(
pStmt
,
13
))
{
BufferIO
::
DecodeUTF8
(
text
,
strBuffer
);
cs
.
text
=
strBuffer
;
}
_strings
.
insert
(
std
::
make_pair
(
cd
.
code
,
cs
));
for
(
int
i
=
0
;
i
<
16
;
++
i
)
{
if
(
const
char
*
text
=
(
const
char
*
)
sqlite3_column_text
(
pStmt
,
i
+
14
))
{
BufferIO
::
DecodeUTF8
(
text
,
strBuffer
);
cs
.
desc
[
i
]
=
strBuffer
;
}
}
_strings
.
emplace
(
cd
.
code
,
cs
);
}
}
while
(
step
!=
SQLITE_DONE
);
sqlite3_finalize
(
pStmt
);
...
...
@@ -131,8 +124,8 @@ code_pointer DataManager::GetCodePointer(int code) {
bool
DataManager
::
GetString
(
int
code
,
CardString
*
pStr
)
{
auto
csit
=
_strings
.
find
(
code
);
if
(
csit
==
_strings
.
end
())
{
pStr
->
name
=
(
wchar_t
*
)
unknown_string
;
pStr
->
text
=
(
wchar_t
*
)
unknown_string
;
pStr
->
name
=
unknown_string
;
pStr
->
text
=
unknown_string
;
return
false
;
}
*
pStr
=
csit
->
second
;
...
...
@@ -142,16 +135,16 @@ const wchar_t* DataManager::GetName(int code) {
auto
csit
=
_strings
.
find
(
code
);
if
(
csit
==
_strings
.
end
())
return
unknown_string
;
if
(
csit
->
second
.
name
)
return
csit
->
second
.
name
;
if
(
!
csit
->
second
.
name
.
empty
()
)
return
csit
->
second
.
name
.
c_str
()
;
return
unknown_string
;
}
const
wchar_t
*
DataManager
::
GetText
(
int
code
)
{
auto
csit
=
_strings
.
find
(
code
);
if
(
csit
==
_strings
.
end
())
return
unknown_string
;
if
(
csit
->
second
.
text
)
return
csit
->
second
.
text
;
if
(
!
csit
->
second
.
text
.
empty
()
)
return
csit
->
second
.
text
.
c_str
()
;
return
unknown_string
;
}
const
wchar_t
*
DataManager
::
GetDesc
(
u64
strCode
)
{
...
...
@@ -162,8 +155,8 @@ const wchar_t* DataManager::GetDesc(u64 strCode) {
auto
csit
=
_strings
.
find
(
code
);
if
(
csit
==
_strings
.
end
())
return
unknown_string
;
if
(
csit
->
second
.
desc
[
offset
]
)
return
csit
->
second
.
desc
[
offset
];
if
(
!
csit
->
second
.
desc
[
offset
].
empty
()
)
return
csit
->
second
.
desc
[
offset
]
.
c_str
()
;
return
unknown_string
;
}
const
wchar_t
*
DataManager
::
GetSysString
(
int
code
)
{
...
...
gframe/duelclient.cpp
View file @
8e433afc
...
...
@@ -801,6 +801,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame
->
dInfo
.
time_player
=
2
;
mainGame
->
dInfo
.
current_player
[
0
]
=
0
;
mainGame
->
dInfo
.
current_player
[
1
]
=
0
;
mainGame
->
dInfo
.
isReplaySwapped
=
false
;
mainGame
->
is_building
=
false
;
mainGame
->
wCardImg
->
setVisible
(
true
);
mainGame
->
wInfos
->
setVisible
(
true
);
...
...
@@ -937,6 +938,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
wchar_t
timetext
[
80
];
mbstowcs
(
timetext
,
timebuf
,
size
);
mainGame
->
ebRSName
->
setText
(
timetext
);
mainGame
->
wReplaySave
->
setText
(
dataManager
.
GetSysString
(
1340
));
mainGame
->
PopupElement
(
mainGame
->
wReplaySave
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
replaySignal
.
Reset
();
...
...
@@ -1393,6 +1395,12 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame
->
dInfo
.
is_shuffling
=
false
;
if
(
!
mainGame
->
dInfo
.
isReplay
||
!
mainGame
->
dInfo
.
isReplaySkiping
)
mainGame
->
gMutex
.
Unlock
();
if
(
mainGame
->
dInfo
.
isReplaySwapped
)
{
std
::
swap
(
mainGame
->
dInfo
.
hostname
,
mainGame
->
dInfo
.
clientname
);
mainGame
->
dInfo
.
isReplaySwapped
=
false
;
mainGame
->
dField
.
ReplaySwap
();
}
mainGame
->
gMutex
.
Unlock
();
return
true
;
}
case
MSG_UPDATE_DATA
:
{
...
...
@@ -1443,7 +1451,6 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pcard
->
chain_code
=
code
;
mainGame
->
dField
.
conti_cards
.
push_back
(
pcard
);
mainGame
->
dField
.
conti_act
=
true
;
pcard
->
cmdFlag
|=
COMMAND_OPERATION
;
}
else
{
pcard
->
cmdFlag
|=
COMMAND_ACTIVATE
;
if
(
pcard
->
location
==
LOCATION_GRAVE
)
...
...
@@ -1574,7 +1581,6 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pcard
->
chain_code
=
code
;
mainGame
->
dField
.
conti_cards
.
push_back
(
pcard
);
mainGame
->
dField
.
conti_act
=
true
;
pcard
->
cmdFlag
|=
COMMAND_OPERATION
;
}
else
{
pcard
->
cmdFlag
|=
COMMAND_ACTIVATE
;
if
(
pcard
->
location
==
LOCATION_GRAVE
)
...
...
gframe/game.cpp
View file @
8e433afc
...
...
@@ -67,6 +67,8 @@ bool Game::Initialize() {
chain_when_avail
=
false
;
is_building
=
false
;
showingcard
=
0
;
menuHandler
.
prev_operation
=
0
;
menuHandler
.
prev_sel
=
-
1
;
memset
(
&
dInfo
,
0
,
sizeof
(
DuelInfo
));
memset
(
chatTiming
,
0
,
sizeof
(
chatTiming
));
deckManager
.
LoadLFList
();
...
...
@@ -608,8 +610,10 @@ bool Game::Initialize() {
wReplay
->
setVisible
(
false
);
lstReplayList
=
env
->
addListBox
(
rect
<
s32
>
(
10
,
30
,
350
,
400
),
wReplay
,
LISTBOX_REPLAY_LIST
,
true
);
lstReplayList
->
setItemHeight
(
18
);
btnLoadReplay
=
env
->
addButton
(
rect
<
s32
>
(
460
,
355
,
570
,
380
),
wReplay
,
BUTTON_LOAD_REPLAY
,
dataManager
.
GetSysString
(
1348
));
btnReplayCancel
=
env
->
addButton
(
rect
<
s32
>
(
460
,
385
,
570
,
410
),
wReplay
,
BUTTON_CANCEL_REPLAY
,
dataManager
.
GetSysString
(
1347
));
btnLoadReplay
=
env
->
addButton
(
rect
<
s32
>
(
470
,
355
,
570
,
380
),
wReplay
,
BUTTON_LOAD_REPLAY
,
dataManager
.
GetSysString
(
1348
));
btnDeleteReplay
=
env
->
addButton
(
rect
<
s32
>
(
360
,
355
,
460
,
380
),
wReplay
,
BUTTON_DELETE_REPLAY
,
dataManager
.
GetSysString
(
1361
));
btnRenameReplay
=
env
->
addButton
(
rect
<
s32
>
(
360
,
385
,
460
,
410
),
wReplay
,
BUTTON_RENAME_REPLAY
,
dataManager
.
GetSysString
(
1362
));
btnReplayCancel
=
env
->
addButton
(
rect
<
s32
>
(
470
,
385
,
570
,
410
),
wReplay
,
BUTTON_CANCEL_REPLAY
,
dataManager
.
GetSysString
(
1347
));
env
->
addStaticText
(
dataManager
.
GetSysString
(
1349
),
rect
<
s32
>
(
360
,
30
,
570
,
50
),
false
,
true
,
wReplay
);
stReplayInfo
=
env
->
addStaticText
(
L""
,
rect
<
s32
>
(
360
,
60
,
570
,
350
),
false
,
true
,
wReplay
);
chkYrp
=
env
->
addCheckBox
(
false
,
recti
(
360
,
250
,
560
,
270
),
wReplay
,
-
1
,
dataManager
.
GetSysString
(
1356
));
...
...
gframe/game.h
View file @
8e433afc
...
...
@@ -71,6 +71,7 @@ struct DuelInfo {
unsigned
char
time_player
;
unsigned
short
time_limit
;
unsigned
short
time_left
[
2
];
bool
isReplaySwapped
;
};
struct
FadingUnit
{
...
...
@@ -319,6 +320,8 @@ public:
irr
::
gui
::
IGUIStaticText
*
stReplayInfo
;
irr
::
gui
::
IGUICheckBox
*
chkYrp
;
irr
::
gui
::
IGUIButton
*
btnLoadReplay
;
irr
::
gui
::
IGUIButton
*
btnDeleteReplay
;
irr
::
gui
::
IGUIButton
*
btnRenameReplay
;
irr
::
gui
::
IGUIButton
*
btnReplayCancel
;
irr
::
gui
::
IGUIEditBox
*
ebRepStartTurn
;
//single play
...
...
@@ -554,6 +557,8 @@ extern Game* mainGame;
#define LISTBOX_REPLAY_LIST 130
#define BUTTON_LOAD_REPLAY 131
#define BUTTON_CANCEL_REPLAY 132
#define BUTTON_DELETE_REPLAY 133
#define BUTTON_RENAME_REPLAY 134
#define EDITBOX_CHAT 140
#define BUTTON_MSG_OK 200
#define BUTTON_YES 201
...
...
gframe/gframe.cpp
View file @
8e433afc
...
...
@@ -77,6 +77,7 @@ int main(int argc, char* argv[]) {
char
param
[
128
];
GetParameter
(
param
,
&
argv
[
i
][
2
]);
ygo
::
dataManager
.
LoadDB
(
param
);
continue
;
}
if
(
!
strcmp
(
argv
[
i
],
"-e"
))
{
// extra database
++
i
;
...
...
@@ -155,6 +156,23 @@ int main(int argc, char* argv[]) {
if
(
open_file
)
ClickButton
(
ygo
::
mainGame
->
btnLoadSinglePlay
);
break
;
}
else
if
(
argc
==
2
&&
strlen
(
argv
[
1
])
>=
4
)
{
char
*
pstrext
=
argv
[
1
]
+
strlen
(
argv
[
1
])
-
4
;
if
(
!
mystrncasecmp
(
pstrext
,
".ydk"
,
4
))
{
open_file
=
true
;
GetParameterW
(
open_file_name
,
&
argv
[
1
][
0
]);
exit_on_return
=
!
keep_on_return
;
ClickButton
(
ygo
::
mainGame
->
btnDeckEdit
);
break
;
}
if
(
!
mystrncasecmp
(
pstrext
,
".yrp"
,
4
))
{
open_file
=
true
;
GetParameterW
(
open_file_name
,
&
argv
[
1
][
0
]);
exit_on_return
=
!
keep_on_return
;
ClickButton
(
ygo
::
mainGame
->
btnReplayMode
);
ClickButton
(
ygo
::
mainGame
->
btnLoadReplay
);
break
;
}
}
}
ygo
::
mainGame
->
MainLoop
();
...
...
gframe/menu_handler.cpp
View file @
8e433afc
...
...
@@ -36,6 +36,14 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break
;
if
(
mainGame
->
wCustomRules
->
isVisible
()
&&
id
!=
BUTTON_CUSTOM_RULE_OK
&&
(
id
<
CHECKBOX_OBSOLETE
||
id
>
CHECKBOX_EMZONE
))
break
;
if
(
mainGame
->
wQuery
->
isVisible
()
&&
id
!=
BUTTON_YES
&&
id
!=
BUTTON_NO
)
{
mainGame
->
wQuery
->
getParent
()
->
bringToFront
(
mainGame
->
wQuery
);
break
;
}
if
(
mainGame
->
wReplaySave
->
isVisible
()
&&
id
!=
BUTTON_REPLAY_SAVE
&&
id
!=
BUTTON_REPLAY_CANCEL
)
{
mainGame
->
wReplaySave
->
getParent
()
->
bringToFront
(
mainGame
->
wReplaySave
);
break
;
}
switch
(
event
.
GUIEvent
.
EventType
)
{
case
irr
:
:
gui
::
EGET_ELEMENT_HOVERED
:
{
// Set cursor to an I-Beam if hovering over an edit box
...
...
@@ -261,6 +269,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame
->
HideElement
(
mainGame
->
wMainMenu
);
mainGame
->
ShowElement
(
mainGame
->
wReplay
);
mainGame
->
ebRepStartTurn
->
setText
(
L"1"
);
mainGame
->
stReplayInfo
->
setText
(
L""
);
mainGame
->
RefreshReplay
();
break
;
}
...
...
@@ -308,6 +317,33 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
ReplayMode
::
StartReplay
(
start_turn
);
break
;
}
case
BUTTON_DELETE_REPLAY
:
{
int
sel
=
mainGame
->
lstReplayList
->
getSelected
();
if
(
sel
==
-
1
)
break
;
mainGame
->
gMutex
.
Lock
();
wchar_t
textBuffer
[
256
];
myswprintf
(
textBuffer
,
L"%ls
\n
%ls"
,
mainGame
->
lstReplayList
->
getListItem
(
sel
),
dataManager
.
GetSysString
(
1363
));
mainGame
->
SetStaticText
(
mainGame
->
stQMessage
,
310
,
mainGame
->
textFont
,
(
wchar_t
*
)
textBuffer
);
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
gMutex
.
Unlock
();
prev_operation
=
id
;
prev_sel
=
sel
;
break
;
}
case
BUTTON_RENAME_REPLAY
:
{
int
sel
=
mainGame
->
lstReplayList
->
getSelected
();
if
(
sel
==
-
1
)
break
;
mainGame
->
gMutex
.
Lock
();
mainGame
->
wReplaySave
->
setText
(
dataManager
.
GetSysString
(
1364
));
mainGame
->
ebRSName
->
setText
(
mainGame
->
lstReplayList
->
getListItem
(
sel
));
mainGame
->
PopupElement
(
mainGame
->
wReplaySave
);
mainGame
->
gMutex
.
Unlock
();
prev_operation
=
id
;
prev_sel
=
sel
;
break
;
}
case
BUTTON_CANCEL_REPLAY
:
{
mainGame
->
HideElement
(
mainGame
->
wReplay
);
mainGame
->
ShowElement
(
mainGame
->
wMainMenu
);
...
...
@@ -357,6 +393,48 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame
->
deckBuilder
.
Initialize
();
break
;
}
case
BUTTON_YES
:
{
mainGame
->
HideElement
(
mainGame
->
wQuery
);
if
(
prev_operation
==
BUTTON_DELETE_REPLAY
)
{
if
(
Replay
::
DeleteReplay
(
mainGame
->
lstReplayList
->
getListItem
(
prev_sel
)))
{
mainGame
->
stReplayInfo
->
setText
(
L""
);
mainGame
->
lstReplayList
->
removeItem
(
prev_sel
);
}
}
prev_operation
=
0
;
prev_sel
=
-
1
;
break
;
}
case
BUTTON_NO
:
{
mainGame
->
HideElement
(
mainGame
->
wQuery
);
prev_operation
=
0
;
prev_sel
=
-
1
;
break
;
}
case
BUTTON_REPLAY_SAVE
:
{
mainGame
->
HideElement
(
mainGame
->
wReplaySave
);
if
(
prev_operation
==
BUTTON_RENAME_REPLAY
)
{
wchar_t
newname
[
256
];
BufferIO
::
CopyWStr
(
mainGame
->
ebRSName
->
getText
(),
newname
,
256
);
if
(
mywcsncasecmp
(
newname
+
wcslen
(
newname
)
-
4
,
L".yrp"
,
4
))
{
myswprintf
(
newname
,
L"%ls.yrp"
,
mainGame
->
ebRSName
->
getText
());
}
if
(
Replay
::
RenameReplay
(
mainGame
->
lstReplayList
->
getListItem
(
prev_sel
),
newname
))
{
mainGame
->
lstReplayList
->
setItem
(
prev_sel
,
newname
,
-
1
);
}
else
{
mainGame
->
env
->
addMessageBox
(
L""
,
dataManager
.
GetSysString
(
1365
));
}
}
prev_operation
=
0
;
prev_sel
=
-
1
;
break
;
}
case
BUTTON_REPLAY_CANCEL
:
{
mainGame
->
HideElement
(
mainGame
->
wReplaySave
);
prev_operation
=
0
;
prev_sel
=
-
1
;
break
;
}
}
break
;
}
...
...
gframe/menu_handler.h
View file @
8e433afc
...
...
@@ -8,7 +8,9 @@ namespace ygo {
class
MenuHandler
:
public
irr
::
IEventReceiver
{
public:
virtual
bool
OnEvent
(
const
irr
::
SEvent
&
event
);
s32
prev_operation
;
int
prev_sel
;
};
}
...
...
gframe/replay.cpp
View file @
8e433afc
...
...
@@ -248,6 +248,36 @@ bool Replay::ReadStream(std::vector<ReplayPacket>* stream) {
}
return
!!
stream
->
size
();
}
bool
Replay
::
DeleteReplay
(
const
wchar_t
*
name
)
{
wchar_t
fname
[
256
];
myswprintf
(
fname
,
L"./replay/%ls"
,
name
);
#ifdef WIN32
BOOL
result
=
DeleteFileW
(
fname
);
return
!!
result
;
#else
char
filefn
[
256
];
BufferIO
::
EncodeUTF8
(
fname
,
filefn
);
int
result
=
unlink
(
filefn
);
return
result
==
0
;
#endif
}
bool
Replay
::
RenameReplay
(
const
wchar_t
*
oldname
,
const
wchar_t
*
newname
)
{
wchar_t
oldfname
[
256
];
wchar_t
newfname
[
256
];
myswprintf
(
oldfname
,
L"./replay/%ls"
,
oldname
);
myswprintf
(
newfname
,
L"./replay/%ls"
,
newname
);
#ifdef WIN32
BOOL
result
=
MoveFileW
(
oldfname
,
newfname
);
return
!!
result
;
#else
char
oldfilefn
[
256
];
char
newfilefn
[
256
];
BufferIO
::
EncodeUTF8
(
oldfname
,
oldfilefn
);
BufferIO
::
EncodeUTF8
(
newfname
,
newfilefn
);
int
result
=
rename
(
oldfilefn
,
newfilefn
);
return
result
==
0
;
#endif
}
bool
Replay
::
ReadNextResponse
(
unsigned
char
resp
[
64
])
{
if
(
pdata
-
replay_data
>=
(
int
)
replay_size
)
return
false
;
...
...
gframe/replay.h
View file @
8e433afc
...
...
@@ -54,6 +54,8 @@ public:
static
bool
CheckReplay
(
const
wchar_t
*
name
);
bool
ReadNextPacket
(
ReplayPacket
*
packet
);
bool
ReadStream
(
std
::
vector
<
ReplayPacket
>*
stream
);
static
bool
DeleteReplay
(
const
wchar_t
*
name
);
static
bool
RenameReplay
(
const
wchar_t
*
oldname
,
const
wchar_t
*
newname
);
bool
ReadNextResponse
(
unsigned
char
resp
[
64
]);
void
ReadName
(
wchar_t
*
data
);
void
ReadData
(
void
*
data
,
unsigned
int
length
);
...
...
gframe/single_mode.cpp
View file @
8e433afc
...
...
@@ -162,6 +162,7 @@ int SingleMode::SinglePlayThread(void* param) {
wchar_t
timetext
[
80
];
mbstowcs
(
timetext
,
timebuf
,
size
);
mainGame
->
ebRSName
->
setText
(
timetext
);
mainGame
->
wReplaySave
->
setText
(
dataManager
.
GetSysString
(
1340
));
mainGame
->
PopupElement
(
mainGame
->
wReplaySave
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
replaySignal
.
Reset
();
...
...
lflist.conf
View file @
8e433afc
This diff is collapsed.
Click to expand it.
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