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
16bccfc7
Commit
16bccfc7
authored
Jul 19, 2019
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
适配Android卡组管理
parent
3a5df330
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
907 additions
and
210 deletions
+907
-210
Classes/gframe/deck_con.cpp
Classes/gframe/deck_con.cpp
+567
-76
Classes/gframe/deck_con.h
Classes/gframe/deck_con.h
+2
-0
Classes/gframe/deck_manager.cpp
Classes/gframe/deck_manager.cpp
+69
-27
Classes/gframe/deck_manager.h
Classes/gframe/deck_manager.h
+8
-3
Classes/gframe/duelclient.cpp
Classes/gframe/duelclient.cpp
+4
-2
Classes/gframe/game.cpp
Classes/gframe/game.cpp
+101
-43
Classes/gframe/game.h
Classes/gframe/game.h
+48
-14
Classes/gframe/menu_handler.cpp
Classes/gframe/menu_handler.cpp
+31
-44
Classes/gframe/myfilesystem.h
Classes/gframe/myfilesystem.h
+77
-1
No files found.
Classes/gframe/deck_con.cpp
View file @
16bccfc7
This diff is collapsed.
Click to expand it.
Classes/gframe/deck_con.h
View file @
16bccfc7
...
...
@@ -66,10 +66,12 @@ public:
size_t
pre_extrac
;
size_t
pre_sidec
;
code_pointer
draging_pointer
;
int
prev_category
;
int
prev_deck
;
s32
prev_operation
;
int
prev_sel
;
bool
is_modified
;
bool
readonly
;
std
::
unordered_map
<
int
,
int
>*
filterList
;
std
::
vector
<
code_pointer
>
results
;
...
...
Classes/gframe/deck_manager.cpp
View file @
16bccfc7
...
...
@@ -2,6 +2,7 @@
#include "data_manager.h"
#include "network.h"
#include "game.h"
#include "myfilesystem.h"
#include <algorithm>
namespace
ygo
{
...
...
@@ -56,23 +57,6 @@ void DeckManager::LoadLFList(const char* path, bool load_none) {
nolimit
.
content
=
new
std
::
unordered_map
<
int
,
int
>
;
_lfList
.
push_back
(
nolimit
);
}
bool
DeckManager
::
RenameDeck
(
const
wchar_t
*
oldname
,
const
wchar_t
*
newname
)
{
wchar_t
oldfname
[
256
];
wchar_t
newfname
[
256
];
myswprintf
(
oldfname
,
L"./deck/%ls.ydk"
,
oldname
);
myswprintf
(
newfname
,
L"./deck/%ls.ydk"
,
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
}
wchar_t
*
DeckManager
::
GetLFListName
(
int
lfhash
)
{
for
(
size_t
i
=
0
;
i
<
_lfList
.
size
();
++
i
)
{
if
(
_lfList
[
i
].
hash
==
(
unsigned
int
)
lfhash
)
{
...
...
@@ -206,6 +190,37 @@ bool DeckManager::LoadSide(Deck& deck, int* dbuf, int mainc, int sidec) {
deck
=
ndeck
;
return
true
;
}
void
DeckManager
::
GetCategoryPath
(
wchar_t
*
ret
,
int
index
,
const
wchar_t
*
text
)
{
wchar_t
catepath
[
256
];
switch
(
index
)
{
case
0
:
myswprintf
(
catepath
,
L"./pack"
);
break
;
case
1
:
myswprintf
(
catepath
,
L"./windbot/Decks"
);
break
;
case
-
1
:
case
2
:
case
3
:
myswprintf
(
catepath
,
L"./deck"
);
break
;
default:
myswprintf
(
catepath
,
L"./deck/%ls"
,
text
);
}
BufferIO
::
CopyWStr
(
catepath
,
ret
,
256
);
}
void
DeckManager
::
GetDeckFile
(
wchar_t
*
ret
,
irr
::
gui
::
IGUIComboBox
*
cbCategory
,
irr
::
gui
::
IGUIComboBox
*
cbDeck
)
{
wchar_t
filepath
[
256
];
wchar_t
catepath
[
256
];
GetCategoryPath
(
catepath
,
cbCategory
->
getSelected
(),
cbCategory
->
getText
());
myswprintf
(
filepath
,
L"%ls/%ls.ydk"
,
catepath
,
cbDeck
->
getItem
(
cbDeck
->
getSelected
()));
BufferIO
::
CopyWStr
(
filepath
,
ret
,
256
);
}
bool
DeckManager
::
LoadDeck
(
irr
::
gui
::
IGUIComboBox
*
cbCategory
,
irr
::
gui
::
IGUIComboBox
*
cbDeck
)
{
wchar_t
filepath
[
256
];
GetDeckFile
(
filepath
,
cbCategory
,
cbDeck
);
return
LoadDeck
(
filepath
);
}
FILE
*
DeckManager
::
OpenDeckFile
(
const
wchar_t
*
file
,
const
char
*
mode
)
{
#ifdef WIN32
FILE
*
fp
=
_wfopen
(
file
,
(
wchar_t
*
)
mode
);
...
...
@@ -218,11 +233,11 @@ FILE* DeckManager::OpenDeckFile(const wchar_t* file, const char* mode) {
}
bool
DeckManager
::
LoadDeck
(
const
wchar_t
*
file
)
{
int
sp
=
0
,
ct
=
0
,
mainc
=
0
,
sidec
=
0
,
code
;
wchar_t
localfile
[
64
];
myswprintf
(
localfile
,
L"./deck/%ls.ydk"
,
file
);
FILE
*
fp
=
OpenDeckFile
(
localfile
,
"r"
);
FILE
*
fp
=
OpenDeckFile
(
file
,
"r"
);
if
(
!
fp
)
{
fp
=
OpenDeckFile
(
file
,
"r"
);
wchar_t
localfile
[
64
];
myswprintf
(
localfile
,
L"./deck/%ls.ydk"
,
file
);
fp
=
OpenDeckFile
(
localfile
,
"r"
);
}
if
(
!
fp
)
return
false
;
...
...
@@ -248,9 +263,9 @@ bool DeckManager::LoadDeck(const wchar_t* file) {
LoadDeck
(
current_deck
,
cardlist
,
mainc
,
sidec
);
return
true
;
}
bool
DeckManager
::
SaveDeck
(
Deck
&
deck
,
const
wchar_t
*
nam
e
)
{
wchar_t
file
[
64
];
myswprintf
(
file
,
L"./deck/%ls.ydk"
,
name
)
;
bool
DeckManager
::
SaveDeck
(
Deck
&
deck
,
const
wchar_t
*
fil
e
)
{
if
(
!
FileSystem
::
IsDirExists
(
L"./deck"
)
&&
!
FileSystem
::
MakeDir
(
L"./deck"
))
return
false
;
FILE
*
fp
=
OpenDeckFile
(
file
,
"w"
);
if
(
!
fp
)
return
false
;
...
...
@@ -266,9 +281,7 @@ bool DeckManager::SaveDeck(Deck& deck, const wchar_t* name) {
fclose
(
fp
);
return
true
;
}
bool
DeckManager
::
DeleteDeck
(
Deck
&
deck
,
const
wchar_t
*
name
)
{
wchar_t
file
[
64
];
myswprintf
(
file
,
L"./deck/%ls.ydk"
,
name
);
bool
DeckManager
::
DeleteDeck
(
const
wchar_t
*
file
)
{
#ifdef WIN32
BOOL
result
=
DeleteFileW
(
file
);
return
!!
result
;
...
...
@@ -279,6 +292,34 @@ bool DeckManager::DeleteDeck(Deck& deck, const wchar_t* name) {
return
result
==
0
;
#endif
}
bool
DeckManager
::
CreateCategory
(
const
wchar_t
*
name
)
{
if
(
!
FileSystem
::
IsDirExists
(
L"./deck"
)
&&
!
FileSystem
::
MakeDir
(
L"./deck"
))
return
false
;
if
(
name
[
0
]
==
0
)
return
false
;
wchar_t
localname
[
256
];
myswprintf
(
localname
,
L"./deck/%ls"
,
name
);
return
FileSystem
::
MakeDir
(
localname
);
}
bool
DeckManager
::
RenameCategory
(
const
wchar_t
*
oldname
,
const
wchar_t
*
newname
)
{
if
(
!
FileSystem
::
IsDirExists
(
L"./deck"
)
&&
!
FileSystem
::
MakeDir
(
L"./deck"
))
return
false
;
if
(
newname
[
0
]
==
0
)
return
false
;
wchar_t
oldlocalname
[
256
];
wchar_t
newlocalname
[
256
];
myswprintf
(
oldlocalname
,
L"./deck/%ls"
,
oldname
);
myswprintf
(
newlocalname
,
L"./deck/%ls"
,
newname
);
return
FileSystem
::
Rename
(
oldlocalname
,
newlocalname
);
}
bool
DeckManager
::
DeleteCategory
(
const
wchar_t
*
name
)
{
wchar_t
localname
[
256
];
myswprintf
(
localname
,
L"./deck/%ls"
,
name
);
if
(
!
FileSystem
::
IsDirExists
(
localname
))
return
false
;
return
FileSystem
::
DeleteDir
(
localname
);
}
int
DeckManager
::
TypeCount
(
std
::
vector
<
code_pointer
>
list
,
unsigned
int
ctype
)
{
int
res
=
0
;
for
(
size_t
i
=
0
;
i
<
list
.
size
();
++
i
)
{
...
...
@@ -288,4 +329,5 @@ int DeckManager::TypeCount(std::vector<code_pointer> list, unsigned int ctype) {
}
return
res
;
}
}
Classes/gframe/deck_manager.h
View file @
16bccfc7
...
...
@@ -40,11 +40,16 @@ public:
int
CheckDeck
(
Deck
&
deck
,
int
lfhash
,
bool
allow_ocg
,
bool
allow_tcg
);
int
LoadDeck
(
Deck
&
deck
,
int
*
dbuf
,
int
mainc
,
int
sidec
);
bool
LoadSide
(
Deck
&
deck
,
int
*
dbuf
,
int
mainc
,
int
sidec
);
void
GetCategoryPath
(
wchar_t
*
ret
,
int
index
,
const
wchar_t
*
text
);
void
GetDeckFile
(
wchar_t
*
ret
,
irr
::
gui
::
IGUIComboBox
*
cbCategory
,
irr
::
gui
::
IGUIComboBox
*
cbDeck
);
bool
LoadDeck
(
irr
::
gui
::
IGUIComboBox
*
cbCategory
,
irr
::
gui
::
IGUIComboBox
*
cbDeck
);
FILE
*
OpenDeckFile
(
const
wchar_t
*
file
,
const
char
*
mode
);
bool
LoadDeck
(
const
wchar_t
*
file
);
bool
SaveDeck
(
Deck
&
deck
,
const
wchar_t
*
name
);
bool
DeleteDeck
(
Deck
&
deck
,
const
wchar_t
*
name
);
static
bool
RenameDeck
(
const
wchar_t
*
oldname
,
const
wchar_t
*
newname
);
bool
SaveDeck
(
Deck
&
deck
,
const
wchar_t
*
file
);
bool
DeleteDeck
(
const
wchar_t
*
file
);
bool
CreateCategory
(
const
wchar_t
*
name
);
bool
RenameCategory
(
const
wchar_t
*
oldname
,
const
wchar_t
*
newname
);
bool
DeleteCategory
(
const
wchar_t
*
name
);
int
TypeCount
(
std
::
vector
<
code_pointer
>
list
,
unsigned
int
ctype
);
};
...
...
Classes/gframe/duelclient.cpp
View file @
16bccfc7
...
...
@@ -308,6 +308,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
}
}
mainGame
->
env
->
addMessageBox
(
L""
,
msgbuf
);
mainGame
->
cbCategorySelect
->
setEnabled
(
true
);
mainGame
->
cbDeckSelect
->
setEnabled
(
true
);
mainGame
->
gMutex
.
unlock
();
break
;
...
...
@@ -341,7 +342,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
}
case
STOC_SELECT_TP
:
{
mainGame
->
gMutex
.
lock
();
mainGame
->
Popup
Element
(
mainGame
->
wFTSelect
);
mainGame
->
Show
Element
(
mainGame
->
wFTSelect
);
mainGame
->
gMutex
.
unlock
();
break
;
}
...
...
@@ -471,7 +472,8 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame
->
stHostPrepDuelist
[
3
]
->
setText
(
L""
);
mainGame
->
stHostPrepOB
->
setText
(
L""
);
mainGame
->
SetStaticText
(
mainGame
->
stHostPrepRule
,
180
*
mainGame
->
xScale
,
mainGame
->
guiFont
,
str
.
c_str
());
mainGame
->
RefreshDeck
(
mainGame
->
cbDeckSelect
);
mainGame
->
RefreshCategoryDeck
(
mainGame
->
cbCategorySelect
,
mainGame
->
cbDeckSelect
);
mainGame
->
cbCategorySelect
->
setEnabled
(
true
);
mainGame
->
cbDeckSelect
->
setEnabled
(
true
);
if
(
mainGame
->
wCreateHost
->
isVisible
())
mainGame
->
HideElement
(
mainGame
->
wCreateHost
);
...
...
Classes/gframe/game.cpp
View file @
16bccfc7
This diff is collapsed.
Click to expand it.
Classes/gframe/game.h
View file @
16bccfc7
...
...
@@ -23,10 +23,12 @@ struct Config {
wchar_t
lastport
[
10
];
wchar_t
nickname
[
20
];
wchar_t
gamename
[
20
];
wchar_t
lastcategory
[
64
];
wchar_t
lastdeck
[
64
];
wchar_t
textfont
[
256
];
wchar_t
numfont
[
256
];
wchar_t
roompass
[
20
];
wchar_t
bot_deck_path
[
64
];
//settings
int
chkMAutoPos
;
int
chkSTAutoPos
;
...
...
@@ -119,7 +121,9 @@ public:
void
InitStaticText
(
irr
::
gui
::
IGUIStaticText
*
pControl
,
u32
cWidth
,
u32
cHeight
,
irr
::
gui
::
CGUITTFont
*
font
,
const
wchar_t
*
text
);
void
SetStaticText
(
irr
::
gui
::
IGUIStaticText
*
pControl
,
u32
cWidth
,
irr
::
gui
::
CGUITTFont
*
font
,
const
wchar_t
*
text
,
u32
pos
=
0
);
void
LoadExpansions
();
void
RefreshDeck
(
irr
::
gui
::
IGUIComboBox
*
cbDeck
);
void
RefreshCategoryDeck
(
irr
::
gui
::
IGUIComboBox
*
cbCategory
,
irr
::
gui
::
IGUIComboBox
*
cbDeck
,
bool
selectlastused
=
true
);
void
RefreshDeck
(
irr
::
gui
::
IGUIComboBox
*
cbCategory
,
irr
::
gui
::
IGUIComboBox
*
cbDeck
);
void
RefreshDeck
(
const
wchar_t
*
deckpath
,
irr
::
gui
::
IGUIComboBox
*
cbDeck
);
void
RefreshReplay
();
void
RefreshSingleplay
();
void
RefreshBot
();
...
...
@@ -302,6 +306,7 @@ public:
irr
::
gui
::
IGUIStaticText
*
stHostPrepDuelist
[
4
];
irr
::
gui
::
IGUICheckBox
*
chkHostPrepReady
[
4
];
irr
::
gui
::
IGUIButton
*
btnHostPrepKick
[
4
];
irr
::
gui
::
IGUIComboBox
*
cbCategorySelect
;
irr
::
gui
::
IGUIComboBox
*
cbDeckSelect
;
irr
::
gui
::
IGUIStaticText
*
stHostPrepRule
;
irr
::
gui
::
IGUIStaticText
*
stHostPrepOB
;
...
...
@@ -427,8 +432,9 @@ public:
irr
::
gui
::
IGUIButton
*
btnEP
;
//deck edit
irr
::
gui
::
IGUIStaticText
*
wDeckEdit
;
irr
::
gui
::
IGUIComboBox
*
cbDB
LFList
;
irr
::
gui
::
IGUIComboBox
*
cbDB
Category
;
irr
::
gui
::
IGUIComboBox
*
cbDBDecks
;
irr
::
gui
::
IGUIButton
*
btnManageDeck
;
irr
::
gui
::
IGUIButton
*
btnClearDeck
;
irr
::
gui
::
IGUIButton
*
btnSortDeck
;
irr
::
gui
::
IGUIButton
*
btnShuffleDeck
;
...
...
@@ -440,7 +446,7 @@ public:
irr
::
gui
::
IGUIButton
*
btnSideSort
;
irr
::
gui
::
IGUIButton
*
btnSideReload
;
irr
::
gui
::
IGUIEditBox
*
ebDeckname
;
irr
::
gui
::
IGUIStaticText
*
st
Banlist
;
irr
::
gui
::
IGUIStaticText
*
st
DBCategory
;
irr
::
gui
::
IGUIStaticText
*
stDeck
;
irr
::
gui
::
IGUIStaticText
*
stCategory
;
irr
::
gui
::
IGUIStaticText
*
stLimit
;
...
...
@@ -451,12 +457,26 @@ public:
irr
::
gui
::
IGUIStaticText
*
stStar
;
irr
::
gui
::
IGUIStaticText
*
stSearch
;
irr
::
gui
::
IGUIStaticText
*
stScale
;
//deck rename
//deck manage
irr
::
gui
::
IGUIWindow
*
wDeckManage
;
irr
::
gui
::
IGUIListBox
*
lstCategories
;
irr
::
gui
::
IGUIListBox
*
lstDecks
;
irr
::
gui
::
IGUIButton
*
btnNewCategory
;
irr
::
gui
::
IGUIButton
*
btnRenameCategory
;
irr
::
gui
::
IGUIButton
*
btnDeleteCategory
;
irr
::
gui
::
IGUIButton
*
btnNewDeck
;
irr
::
gui
::
IGUIButton
*
btnRenameDeck
;
irr
::
gui
::
IGUIWindow
*
wRenameDeck
;
irr
::
gui
::
IGUIEditBox
*
ebREName
;
irr
::
gui
::
IGUIButton
*
btnREYes
;
irr
::
gui
::
IGUIButton
*
btnRENo
;
irr
::
gui
::
IGUIButton
*
btnDMDeleteDeck
;
irr
::
gui
::
IGUIButton
*
btnMoveDeck
;
irr
::
gui
::
IGUIButton
*
btnCopyDeck
;
irr
::
gui
::
IGUIWindow
*
wDMQuery
;
irr
::
gui
::
IGUIStaticText
*
stDMMessage
;
irr
::
gui
::
IGUIStaticText
*
stDMMessage2
;
irr
::
gui
::
IGUIEditBox
*
ebDMName
;
irr
::
gui
::
IGUIComboBox
*
cbDMCategory
;
irr
::
gui
::
IGUIButton
*
btnDMOK
;
irr
::
gui
::
IGUIButton
*
btnDMCancel
;
irr
::
gui
::
IGUIComboBox
*
cbLFList
;
//filter
irr
::
gui
::
IGUIStaticText
*
wFilter
;
irr
::
gui
::
IGUIScrollBar
*
scrFilter
;
...
...
@@ -568,6 +588,7 @@ extern Game* mainGame;
#define CHECKBOX_HP_READY 125
#define BUTTON_HP_READY 126
#define BUTTON_HP_NOTREADY 127
#define COMBOBOX_HP_CATEGORY 128
#define LISTBOX_REPLAY_LIST 130
#define BUTTON_LOAD_REPLAY 131
#define BUTTON_CANCEL_REPLAY 132
...
...
@@ -656,8 +677,8 @@ extern Game* mainGame;
#define BUTTON_CARD_DISP_OK 296
#define BUTTON_SURRENDER_YES 297
#define BUTTON_SURRENDER_NO 298
#define COMBOBOX_DB
LFLIST
301
#define BUTTON_MANAGE_DECK 300
#define COMBOBOX_DB
CATEGORY
301
#define COMBOBOX_DBDECKS 302
#define BUTTON_CLEAR_DECK 303
#define BUTTON_SAVE_DECK 304
...
...
@@ -682,13 +703,26 @@ extern Game* mainGame;
#define BUTTON_MARKERS_OK 323
#define COMBOBOX_SORTTYPE 324
#define WINDOW_DECK_MANAGE 330
#define BUTTON_NEW_CATEGORY 331
#define BUTTON_RENAME_CATEGORY 332
#define BUTTON_DELETE_CATEGORY 333
#define BUTTON_NEW_DECK 334
#define BUTTON_RENAME_DECK 335
#define BUTTON_DELETE_DECK_DM 336
#define BUTTON_MOVE_DECK 337
#define BUTTON_COPY_DECK 338
#define LISTBOX_CATEGORIES 339
#define LISTBOX_DECKS 340
#define BUTTON_DM_OK 341
#define BUTTON_DM_CANCEL 342
#define COMBOBOX_LFLIST 349
#define CHECKBOX_AUTO_SEARCH 360
#define CHECKBOX_DRAW_FIELD_SPELL 361
#define CHECKBOX_MULTI_KEYWORDS 372
#define CHECKBOX_PREFER_EXPANSION 373
#define CHECKBOX_DISABLE_CHAT 364
//ygomobile function
#define BUTTON_RENAME_DECK 365
#define BUTTON_RENAME_DECK_SAVE 366
#define BUTTON_RENAME_DECK_CANCEL 367
#define CHECKBOX_QUICK_ANIMATION 369
#define SCROLL_TAB_HELPER 370
#define SCROLL_TAB_SYSTEM 371
...
...
Classes/gframe/menu_handler.cpp
View file @
16bccfc7
...
...
@@ -11,6 +11,8 @@
namespace
ygo
{
void
UpdateDeck
()
{
BufferIO
::
CopyWStr
(
mainGame
->
cbCategorySelect
->
getItem
(
mainGame
->
cbCategorySelect
->
getSelected
()),
mainGame
->
gameConf
.
lastcategory
,
64
);
BufferIO
::
CopyWStr
(
mainGame
->
cbDeckSelect
->
getItem
(
mainGame
->
cbDeckSelect
->
getSelected
()),
mainGame
->
gameConf
.
lastdeck
,
64
);
...
...
@@ -52,7 +54,6 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break
;
}
switch
(
event
.
GUIEvent
.
EventType
)
{
//dont merge these cases
case
irr
:
:
gui
::
EGET_BUTTON_CLICKED
:
{
switch
(
id
)
{
case
BUTTON_MODE_EXIT
:
{
...
...
@@ -180,18 +181,20 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
}
case
BUTTON_HP_READY
:
{
mainGame
->
soundEffectPlayer
->
doPressButton
();
if
(
mainGame
->
cbDeckSelect
->
getSelected
()
==
-
1
||
!
deckManager
.
LoadDeck
(
mainGame
->
cb
DeckSelect
->
getItem
(
mainGame
->
cbDeckSelect
->
getSelected
())
))
{
if
(
mainGame
->
cb
CategorySelect
->
getSelected
()
==
-
1
||
mainGame
->
cb
DeckSelect
->
getSelected
()
==
-
1
||
!
deckManager
.
LoadDeck
(
mainGame
->
cb
CategorySelect
,
mainGame
->
cbDeckSelect
))
{
break
;
}
UpdateDeck
();
DuelClient
::
SendPacketToServer
(
CTOS_HS_READY
);
mainGame
->
cbCategorySelect
->
setEnabled
(
false
);
mainGame
->
cbDeckSelect
->
setEnabled
(
false
);
break
;
}
case
BUTTON_HP_NOTREADY
:
{
mainGame
->
soundEffectPlayer
->
doPressButton
();
DuelClient
::
SendPacketToServer
(
CTOS_HS_NOTREADY
);
mainGame
->
cbCategorySelect
->
setEnabled
(
true
);
mainGame
->
cbDeckSelect
->
setEnabled
(
true
);
break
;
}
...
...
@@ -295,42 +298,6 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame
->
ShowElement
(
mainGame
->
wMainMenu
);
break
;
}
case
BUTTON_EXPORT_DECK
:
{
if
(
mainGame
->
lstReplayList
->
getSelected
()
==
-
1
)
break
;
Replay
replay
;
wchar_t
ex_filename
[
256
];
wchar_t
namebuf
[
4
][
20
];
wchar_t
filename
[
256
];
myswprintf
(
ex_filename
,
L"%ls"
,
mainGame
->
lstReplayList
->
getListItem
(
mainGame
->
lstReplayList
->
getSelected
()));
if
(
!
replay
.
OpenReplay
(
ex_filename
))
break
;
const
ReplayHeader
&
rh
=
replay
.
pheader
;
if
(
rh
.
flag
&
REPLAY_SINGLE_MODE
)
break
;
int
max
=
(
rh
.
flag
&
REPLAY_TAG
)
?
4
:
2
;
//player name
for
(
int
i
=
0
;
i
<
max
;
++
i
)
replay
.
ReadName
(
namebuf
[
i
]);
//skip pre infos
for
(
int
i
=
0
;
i
<
4
;
++
i
)
replay
.
ReadInt32
();
//deck
for
(
int
i
=
0
;
i
<
max
;
++
i
)
{
int
main
=
replay
.
ReadInt32
();
Deck
tmp_deck
;
for
(
int
j
=
0
;
j
<
main
;
++
j
)
tmp_deck
.
main
.
push_back
(
dataManager
.
GetCodePointer
(
replay
.
ReadInt32
()));
int
extra
=
replay
.
ReadInt32
();
for
(
int
j
=
0
;
j
<
extra
;
++
j
)
tmp_deck
.
extra
.
push_back
(
dataManager
.
GetCodePointer
(
replay
.
ReadInt32
()));
myswprintf
(
filename
,
L"%ls %ls"
,
ex_filename
,
namebuf
[
i
]);
deckManager
.
SaveDeck
(
tmp_deck
,
filename
);
}
mainGame
->
stACMessage
->
setText
(
dataManager
.
GetSysString
(
1335
));
mainGame
->
PopupElement
(
mainGame
->
wACMessage
,
20
);
break
;
}
//TEST BOT MODE
case
BUTTON_BOT_START
:
{
int
sel
=
mainGame
->
lstBotList
->
getSelected
();
...
...
@@ -417,11 +384,12 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break
;
}
case
BUTTON_DECK_EDIT
:
{
mainGame
->
RefreshCategoryDeck
(
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
mainGame
->
soundEffectPlayer
->
doPressButton
();
mainGame
->
RefreshDeck
(
mainGame
->
cbDBDecks
);
if
(
mainGame
->
cbDBDecks
->
getSelected
()
!=
-
1
)
deckManager
.
LoadDeck
(
mainGame
->
cbDBDecks
->
getItem
(
mainGame
->
cbDBDecks
->
getSelected
()));
if
(
mainGame
->
cbDBCategory
->
getSelected
()
!=
-
1
&&
mainGame
->
cbDBDecks
->
getSelected
()
!=
-
1
)
{
deckManager
.
LoadDeck
(
mainGame
->
cbDBCategory
,
mainGame
->
cbDBDecks
);
mainGame
->
ebDeckname
->
setText
(
L""
);
}
mainGame
->
HideElement
(
mainGame
->
wMainMenu
);
mainGame
->
deckBuilder
.
Initialize
();
break
;
...
...
@@ -574,6 +542,23 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
}
break
;
}
case
irr
:
:
gui
::
EGET_COMBO_BOX_CHANGED
:
{
switch
(
id
)
{
case
COMBOBOX_HP_CATEGORY
:
{
int
catesel
=
mainGame
->
cbCategorySelect
->
getSelected
();
if
(
catesel
==
3
)
{
catesel
=
2
;
mainGame
->
cbCategorySelect
->
setSelected
(
2
);
}
if
(
catesel
>=
0
)
{
mainGame
->
RefreshDeck
(
mainGame
->
cbCategorySelect
,
mainGame
->
cbDeckSelect
);
mainGame
->
cbDeckSelect
->
setSelected
(
0
);
}
break
;
}
}
break
;
}
case
irr
:
:
gui
::
EGET_CHECKBOX_CHANGED
:
{
switch
(
id
)
{
case
CHECKBOX_HP_READY
:
{
...
...
@@ -581,16 +566,18 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break
;
mainGame
->
env
->
setFocus
(
mainGame
->
wHostPrepare
);
if
(
static_cast
<
irr
::
gui
::
IGUICheckBox
*>
(
caller
)
->
isChecked
())
{
if
(
mainGame
->
cbDeckSelect
->
getSelected
()
==
-
1
||
!
deckManager
.
LoadDeck
(
mainGame
->
cbDeckSelect
->
getItem
(
mainGame
->
cbDeckSelect
->
getSelected
())
))
{
if
(
mainGame
->
cb
CategorySelect
->
getSelected
()
==
-
1
||
mainGame
->
cb
DeckSelect
->
getSelected
()
==
-
1
||
!
deckManager
.
LoadDeck
(
mainGame
->
cbCategorySelect
,
mainGame
->
cbDeckSelect
))
{
static_cast
<
irr
::
gui
::
IGUICheckBox
*>
(
caller
)
->
setChecked
(
false
);
break
;
}
UpdateDeck
();
DuelClient
::
SendPacketToServer
(
CTOS_HS_READY
);
mainGame
->
cbCategorySelect
->
setEnabled
(
false
);
mainGame
->
cbDeckSelect
->
setEnabled
(
false
);
}
else
{
DuelClient
::
SendPacketToServer
(
CTOS_HS_NOTREADY
);
mainGame
->
cbCategorySelect
->
setEnabled
(
true
);
mainGame
->
cbDeckSelect
->
setEnabled
(
true
);
}
break
;
...
...
Classes/gframe/myfilesystem.h
View file @
16bccfc7
...
...
@@ -50,6 +50,37 @@ public:
return
MakeDir
(
wdir
);
}
static
bool
Rename
(
const
wchar_t
*
woldname
,
const
wchar_t
*
wnewname
)
{
return
MoveFileW
(
woldname
,
wnewname
);
}
static
bool
Rename
(
const
char
*
oldname
,
const
char
*
newname
)
{
wchar_t
woldname
[
1024
];
wchar_t
wnewname
[
1024
];
BufferIO
::
DecodeUTF8
(
oldname
,
woldname
);
BufferIO
::
DecodeUTF8
(
newname
,
wnewname
);
return
Rename
(
woldname
,
wnewname
);
}
static
bool
DeleteDir
(
const
wchar_t
*
wdir
)
{
wchar_t
pdir
[
256
];
BufferIO
::
CopyWStr
(
wdir
,
pdir
,
256
);
pdir
[
wcslen
(
wdir
)
+
1
]
=
0
;
SHFILEOPSTRUCTW
lpFileOp
;
lpFileOp
.
hwnd
=
NULL
;
lpFileOp
.
wFunc
=
FO_DELETE
;
lpFileOp
.
pFrom
=
pdir
;
lpFileOp
.
pTo
=
0
;
lpFileOp
.
fFlags
=
FOF_ALLOWUNDO
|
FOF_NOCONFIRMATION
|
FOF_NOERRORUI
|
FOF_SILENT
;
return
SHFileOperationW
(
&
lpFileOp
)
==
0
;
}
static
bool
DeleteDir
(
const
char
*
dir
)
{
wchar_t
wdir
[
1024
];
BufferIO
::
DecodeUTF8
(
dir
,
wdir
);
return
DeleteDir
(
wdir
);
}
static
void
TraversalDir
(
const
wchar_t
*
wpath
,
const
std
::
function
<
void
(
const
wchar_t
*
,
bool
)
>&
cb
)
{
wchar_t
findstr
[
1024
];
wcscpy
(
findstr
,
wpath
);
...
...
@@ -59,7 +90,8 @@ public:
if
(
fh
==
INVALID_HANDLE_VALUE
)
return
;
do
{
cb
(
fdataw
.
cFileName
,
(
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
));
if
(
mywcsncasecmp
(
fdataw
.
cFileName
,
L"."
,
1
)
&&
mywcsncasecmp
(
fdataw
.
cFileName
,
L".."
,
2
))
cb
(
fdataw
.
cFileName
,
(
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
));
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
FindClose
(
fh
);
}
...
...
@@ -110,6 +142,48 @@ public:
BufferIO
::
EncodeUTF8
(
wdir
,
dir
);
return
MakeDir
(
dir
);
}
static
bool
Rename
(
const
wchar_t
*
woldname
,
const
wchar_t
*
wnewname
)
{
char
oldname
[
1024
];
char
newname
[
1024
];
BufferIO
::
EncodeUTF8
(
woldname
,
oldname
);
BufferIO
::
EncodeUTF8
(
wnewname
,
newname
);
return
Rename
(
oldname
,
newname
);
}
static
bool
Rename
(
const
char
*
oldname
,
const
char
*
newname
)
{
return
rename
(
oldname
,
newname
)
==
0
;
}
static
bool
DeleteDir
(
const
wchar_t
*
wdir
)
{
char
dir
[
1024
];
BufferIO
::
EncodeUTF8
(
wdir
,
dir
);
return
DeleteDir
(
dir
);
}
static
bool
DeleteDir
(
const
char
*
dir
)
{
bool
success
=
true
;
TraversalDir
(
dir
,
[
dir
,
&
success
](
const
char
*
name
,
bool
isdir
)
{
if
(
strcmp
(
name
,
"."
)
==
0
||
strcmp
(
name
,
".."
)
==
0
)
return
;
char
full_path
[
256
];
sprintf
(
full_path
,
"%s/%s"
,
dir
,
name
);
if
(
isdir
)
{
if
(
!
DeleteDir
(
full_path
))
success
=
false
;
}
else
{
if
(
unlink
(
full_path
)
!=
0
)
success
=
false
;
}
});
if
(
rmdir
(
dir
)
!=
0
)
success
=
false
;
return
success
;
}
struct
file_unit
{
std
::
string
filename
;
...
...
@@ -132,6 +206,8 @@ public:
stat
(
fname
,
&
fileStat
);
funit
.
filename
=
std
::
string
(
dirp
->
d_name
);
funit
.
is_dir
=
S_ISDIR
(
fileStat
.
st_mode
);
if
(
funit
.
is_dir
&&
(
strcmp
(
dirp
->
d_name
,
"."
)
==
0
||
strcmp
(
dirp
->
d_name
,
".."
)
==
0
))
continue
;
file_list
.
push_back
(
funit
);
}
closedir
(
dir
);
...
...
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