Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赤子奈落
ygopro
Commits
589682d3
Commit
589682d3
authored
Jan 23, 2016
by
mercury233
Browse files
Options
Browse Files
Download
Plain Diff
Merge
https://github.com/Fluorohydride/ygopro
into server
parents
2148301e
315ef58a
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
98 additions
and
53 deletions
+98
-53
gframe/deck_con.cpp
gframe/deck_con.cpp
+1
-2
gframe/duelclient.cpp
gframe/duelclient.cpp
+12
-1
gframe/event_handler.cpp
gframe/event_handler.cpp
+30
-3
gframe/game.cpp
gframe/game.cpp
+47
-41
gframe/game.h
gframe/game.h
+2
-0
gframe/gframe.cpp
gframe/gframe.cpp
+1
-3
strings.conf
strings.conf
+1
-1
system.conf
system.conf
+4
-2
No files found.
gframe/deck_con.cpp
View file @
589682d3
...
...
@@ -670,8 +670,7 @@ void DeckBuilder::FilterCards() {
continue
;
switch
(
filter_type
)
{
case
1
:
{
int
type2
=
data
.
type
&
0xe03ef1
;
if
(
!
(
data
.
type
&
TYPE_MONSTER
)
||
(
filter_type2
==
0x21
&&
type2
!=
0x21
)
||
(
data
.
type
&
filter_type2
)
!=
filter_type2
)
if
(
!
(
data
.
type
&
TYPE_MONSTER
)
||
(
data
.
type
&
filter_type2
)
!=
filter_type2
)
continue
;
if
(
filter_race
&&
data
.
race
!=
filter_race
)
continue
;
...
...
gframe/duelclient.cpp
View file @
589682d3
...
...
@@ -70,6 +70,8 @@ void DuelClient::ConnectTimeout(evutil_socket_t fd, short events, void* arg) {
mainGame
->
btnJoinHost
->
setEnabled
(
true
);
mainGame
->
btnJoinCancel
->
setEnabled
(
true
);
mainGame
->
gMutex
.
Lock
();
if
(
!
mainGame
->
wLanWindow
->
isVisible
())
mainGame
->
ShowElement
(
mainGame
->
wLanWindow
);
mainGame
->
env
->
addMessageBox
(
L""
,
dataManager
.
GetSysString
(
1400
));
mainGame
->
gMutex
.
Unlock
();
}
...
...
@@ -138,6 +140,8 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
mainGame
->
btnJoinHost
->
setEnabled
(
true
);
mainGame
->
btnJoinCancel
->
setEnabled
(
true
);
mainGame
->
gMutex
.
Lock
();
if
(
!
mainGame
->
wLanWindow
->
isVisible
())
mainGame
->
ShowElement
(
mainGame
->
wLanWindow
);
mainGame
->
env
->
addMessageBox
(
L""
,
dataManager
.
GetSysString
(
1400
));
mainGame
->
gMutex
.
Unlock
();
}
else
if
(
connect_state
==
0x7
)
{
...
...
@@ -523,7 +527,14 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame
->
wPhase
->
setVisible
(
false
);
if
(
mainGame
->
dInfo
.
player_type
<
7
)
mainGame
->
btnLeaveGame
->
setVisible
(
false
);
mainGame
->
ebRSName
->
setText
(
L""
);
time_t
nowtime
=
time
(
NULL
);
struct
tm
*
localedtime
=
localtime
(
&
nowtime
);
char
timebuf
[
40
];
strftime
(
timebuf
,
40
,
"%Y-%m-%d %H-%M-%S"
,
localedtime
);
size_t
size
=
strlen
(
timebuf
)
+
1
;
wchar_t
timetext
[
80
];
mbstowcs
(
timetext
,
timebuf
,
size
);
mainGame
->
ebRSName
->
setText
(
timetext
);
mainGame
->
PopupElement
(
mainGame
->
wReplaySave
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
replaySignal
.
Reset
();
...
...
gframe/event_handler.cpp
View file @
589682d3
...
...
@@ -892,6 +892,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
irr
::
core
::
position2di
pos
(
x
,
y
);
if
(
x
<
300
)
break
;
if
(
mainGame
->
gameConf
.
control_mode
==
1
)
mainGame
->
always_chain
=
event
.
MouseInput
.
isLeftPressed
();
if
(
mainGame
->
wCmdMenu
->
isVisible
()
&&
!
mainGame
->
wCmdMenu
->
getRelativePosition
().
isPointInside
(
pos
))
mainGame
->
wCmdMenu
->
setVisible
(
false
);
if
(
panel
&&
panel
->
isVisible
())
...
...
@@ -1239,6 +1241,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case
irr
:
:
EMIE_RMOUSE_LEFT_UP
:
{
if
(
mainGame
->
dInfo
.
isReplay
)
break
;
if
(
mainGame
->
gameConf
.
control_mode
==
1
&&
event
.
MouseInput
.
X
>
300
)
mainGame
->
ignore_chain
=
event
.
MouseInput
.
isRightPressed
();
mainGame
->
wCmdMenu
->
setVisible
(
false
);
if
(
mainGame
->
fadingList
.
size
())
break
;
...
...
@@ -1531,6 +1535,20 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case
irr
:
:
EMIE_MOUSE_WHEEL
:
{
break
;
}
case
irr
:
:
EMIE_LMOUSE_PRESSED_DOWN
:
{
if
(
!
mainGame
->
dInfo
.
isStarted
)
break
;
if
(
mainGame
->
gameConf
.
control_mode
==
1
&&
event
.
MouseInput
.
X
>
300
)
mainGame
->
always_chain
=
event
.
MouseInput
.
isLeftPressed
();
break
;
}
case
irr
:
:
EMIE_RMOUSE_PRESSED_DOWN
:
{
if
(
!
mainGame
->
dInfo
.
isStarted
)
break
;
if
(
mainGame
->
gameConf
.
control_mode
==
1
&&
event
.
MouseInput
.
X
>
300
)
mainGame
->
ignore_chain
=
event
.
MouseInput
.
isRightPressed
();
break
;
}
default:
break
;
}
...
...
@@ -1539,15 +1557,18 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case
irr
:
:
EET_KEY_INPUT_EVENT
:
{
switch
(
event
.
KeyInput
.
Key
)
{
case
irr
:
:
KEY_KEY_A
:
{
mainGame
->
always_chain
=
event
.
KeyInput
.
PressedDown
;
if
(
mainGame
->
gameConf
.
control_mode
==
0
)
mainGame
->
always_chain
=
event
.
KeyInput
.
PressedDown
;
break
;
}
case
irr
:
:
KEY_KEY_S
:
{
mainGame
->
ignore_chain
=
event
.
KeyInput
.
PressedDown
;
if
(
mainGame
->
gameConf
.
control_mode
==
0
)
mainGame
->
ignore_chain
=
event
.
KeyInput
.
PressedDown
;
break
;
}
case
irr
:
:
KEY_KEY_R
:
{
if
(
!
event
.
KeyInput
.
PressedDown
&&
!
mainGame
->
HasFocus
(
EGUIET_EDIT_BOX
))
if
(
mainGame
->
gameConf
.
control_mode
==
0
&&
!
event
.
KeyInput
.
PressedDown
&&
!
mainGame
->
HasFocus
(
EGUIET_EDIT_BOX
))
mainGame
->
textFont
->
setTransparency
(
true
);
break
;
}
...
...
@@ -1621,6 +1642,12 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
break
;
}
case
irr
:
:
KEY_F9
:
{
if
(
mainGame
->
gameConf
.
control_mode
==
1
&&
!
event
.
KeyInput
.
PressedDown
&&
!
mainGame
->
HasFocus
(
EGUIET_EDIT_BOX
))
mainGame
->
textFont
->
setTransparency
(
true
);
break
;
}
case
irr
:
:
KEY_ESCAPE
:
{
if
(
!
mainGame
->
HasFocus
(
EGUIET_EDIT_BOX
))
mainGame
->
device
->
minimizeWindow
();
...
...
gframe/game.cpp
View file @
589682d3
...
...
@@ -9,15 +9,13 @@
#include "netserver.h"
//#include "single_mode.h"
#ifdef _WIN32
#include <io.h>
#else
#ifndef _WIN32
#include <sys/types.h>
#include <dirent.h>
#include <unistd.h>
#endif
const
unsigned
short
PRO_VERSION
=
0x133
8
;
const
unsigned
short
PRO_VERSION
=
0x133
9
;
namespace
ygo
{
...
...
@@ -106,39 +104,7 @@ bool Game::Initialize() {
return false;
if(!dataManager.LoadStrings("strings.conf"))
return false;
#ifdef _WIN32
char fpath[1000];
WIN32_FIND_DATAW fdataw;
HANDLE fh = FindFirstFileW(L"./expansions/*.cdb", &fdataw);
if(fh != INVALID_HANDLE_VALUE) {
do {
if(!(fdataw.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
sprintf(fpath, "./expansions/%ls", fdataw.cFileName);
dataManager.LoadDB(fpath);
}
} while(FindNextFileW(fh, &fdataw));
FindClose(fh);
}
#else
DIR * dir;
struct dirent * dirp;
const char *foldername = "./expansions/";
if((dir = opendir(foldername)) != NULL) {
while((dirp = readdir(dir)) != NULL) {
size_t len = strlen(dirp->d_name);
if(len < 5 || strcasecmp(dirp->d_name + len - 4, ".cdb") != 0)
continue;
char *filepath = (char *)malloc(sizeof(char)*(len + strlen(foldername)));
strncpy(filepath, foldername, strlen(foldername)+1);
strncat(filepath, dirp->d_name, len);
std::cout << "Found file " << filepath << std::endl;
if (!dataManager.LoadDB(filepath))
std::cout << "Error loading file" << std::endl;
free(filepath);
}
closedir(dir);
}
#endif
RefreshExpansionDB();
env = device->getGUIEnvironment();
numFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 16);
adFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 12);
...
...
@@ -741,6 +707,41 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu
dataManager.strBuffer[pbuffer] = 0;
pControl->setText(dataManager.strBuffer);
}
void Game::RefreshExpansionDB() {
#ifdef _WIN32
char fpath[1000];
WIN32_FIND_DATAW fdataw;
HANDLE fh = FindFirstFileW(L"./expansions/*.cdb", &fdataw);
if(fh != INVALID_HANDLE_VALUE) {
do {
if(!(fdataw.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
sprintf(fpath, "./expansions/%ls", fdataw.cFileName);
dataManager.LoadDB(fpath);
}
} while(FindNextFileW(fh, &fdataw));
FindClose(fh);
}
#else
DIR * dir;
struct dirent * dirp;
const char *foldername = "./expansions/";
if((dir = opendir(foldername)) != NULL) {
while((dirp = readdir(dir)) != NULL) {
size_t len = strlen(dirp->d_name);
if(len < 5 || strcasecmp(dirp->d_name + len - 4, ".cdb") != 0)
continue;
char *filepath = (char *)malloc(sizeof(char)*(len + strlen(foldername)));
strncpy(filepath, foldername, strlen(foldername) + 1);
strncat(filepath, dirp->d_name, len);
std::cout << "Found file " << filepath << std::endl;
if(!dataManager.LoadDB(filepath))
std::cout << "Error loading file" << std::endl;
free(filepath);
}
closedir(dir);
}
#endif
}
void Game::RefreshDeck(irr::gui::IGUIComboBox* cbDeck) {
cbDeck->clear();
#ifdef _WIN32
...
...
@@ -866,6 +867,7 @@ void Game::LoadConfig() {
gameConf.chkIgnore1 = 0;
gameConf.chkIgnore2 = 0;
gameConf.chkHideSetname = 0;
gameConf.control_mode = 0;
fseek(fp, 0, SEEK_END);
int fsize = ftell(fp);
fseek(fp, 0, SEEK_SET);
...
...
@@ -906,12 +908,14 @@ void Game::LoadConfig() {
gameConf.chkAutoChain = atoi(valbuf);
} else if(!strcmp(strbuf, "waitchain")) {
gameConf.chkWaitChain = atoi(valbuf);
} else if(!strcmp(strbuf, "
ignore1
")) {
} else if(!strcmp(strbuf, "
mute_opponent
")) {
gameConf.chkIgnore1 = atoi(valbuf);
} else if(!strcmp(strbuf, "
ignore2
")) {
} else if(!strcmp(strbuf, "
mute_spectators
")) {
gameConf.chkIgnore2 = atoi(valbuf);
} else if(!strcmp(strbuf, "hide_setname")) {
gameConf.chkHideSetname = atoi(valbuf);
} else if(!strcmp(strbuf, "control_mode")) {
gameConf.control_mode = atoi(valbuf);
} else {
// options allowing multiple words
sscanf(linebuf, "%s = %240[^\n]", strbuf, valbuf);
...
...
@@ -959,9 +963,11 @@ void Game::SaveConfig() {
fprintf(fp, "randompos = %d\n", ((mainGame->chkRandomPos->isChecked()) ? 1 : 0));
fprintf(fp, "autochain = %d\n", ((mainGame->chkAutoChain->isChecked()) ? 1 : 0));
fprintf(fp, "waitchain = %d\n", ((mainGame->chkWaitChain->isChecked()) ? 1 : 0));
fprintf(fp, "
ignore1
= %d\n", ((mainGame->chkIgnore1->isChecked()) ? 1 : 0));
fprintf(fp, "
ignore2
= %d\n", ((mainGame->chkIgnore2->isChecked()) ? 1 : 0));
fprintf(fp, "
mute_opponent
= %d\n", ((mainGame->chkIgnore1->isChecked()) ? 1 : 0));
fprintf(fp, "
mute_spectators
= %d\n", ((mainGame->chkIgnore2->isChecked()) ? 1 : 0));
fprintf(fp, "hide_setname = %d\n", ((mainGame->chkHideSetname->isChecked()) ? 1 : 0));
fprintf(fp, "#control_mode = 0: Key A/S/R. control_mode = 1: MouseLeft/MouseRight/F9\n");
fprintf(fp, "control_mode = %d\n", gameConf.control_mode);
fclose(fp);
}
void Game::ShowCardInfo(int code) {
...
...
gframe/game.h
View file @
589682d3
...
...
@@ -32,6 +32,7 @@ struct Config {
int
chkIgnore1
;
int
chkIgnore2
;
int
chkHideSetname
;
int
control_mode
;
};
struct
DuelInfo
{
...
...
@@ -81,6 +82,7 @@ public:
void BuildProjectionMatrix(irr::core::matrix4& mProjection, f32 left, f32 right, f32 bottom, f32 top, f32 znear, f32 zfar);
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 RefreshExpansionDB();
void RefreshDeck(irr::gui::IGUIComboBox* cbDeck);
void RefreshReplay();
void RefreshSingleplay();
...
...
gframe/gframe.cpp
View file @
589682d3
...
...
@@ -62,9 +62,7 @@ int main(int argc, char* argv[]) {
event.EventType = irr::EET_GUI_EVENT;
event.GUIEvent.EventType = irr::gui::EGET_BUTTON_CLICKED;
if(!strcmp(argv[i], "-j")) {
event.GUIEvent.Caller = ygo::mainGame->btnLanMode;
ygo::mainGame->device->postEventFromUser(event);
//TODO: wait for wLanWindow show. if network connection faster than wLanWindow, wLanWindow will still show on duel scene.
ygo::mainGame->HideElement(ygo::mainGame->wMainMenu);
event.GUIEvent.Caller = ygo::mainGame->btnJoinHost;
ygo::mainGame->device->postEventFromUser(event);
} else if(!strcmp(argv[i], "-d")) {
...
...
strings.conf
View file @
589682d3
...
...
@@ -252,7 +252,7 @@
!
system
1233
每回合抽卡:
!
system
1234
主机名称:
!
system
1235
主机密码:
!
system
1236
旧规则(先攻抽卡、
启
动效果优先权等)
!
system
1236
旧规则(先攻抽卡、
起
动效果优先权等)
!
system
1237
每回合时间:
!
system
1240
OCG
!
system
1241
TCG
...
...
system.conf
View file @
589682d3
...
...
@@ -15,6 +15,8 @@ autopos = 1
randompos
=
0
autochain
=
0
waitchain
=
0
ignore1
=
0
ignore2
=
0
mute_opponent
=
0
mute_spectators
=
0
hide_setname
=
0
#control_mode = 0: Key A/S/R. control_mode = 1: MouseLeft/MouseRight/F9
control_mode
=
0
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