Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-2pick
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
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
MyCard
ygopro-2pick
Commits
6168db92
Commit
6168db92
authored
Aug 01, 2018
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'multi_language'
parents
37aafd3b
8e595c99
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
111 additions
and
2 deletions
+111
-2
.gitignore
.gitignore
+1
-0
gframe/event_handler.cpp
gframe/event_handler.cpp
+11
-0
gframe/game.cpp
gframe/game.cpp
+65
-1
gframe/game.h
gframe/game.h
+7
-1
gframe/image_manager.cpp
gframe/image_manager.cpp
+24
-0
strings.conf
strings.conf
+2
-0
system.conf
system.conf
+1
-0
No files found.
.gitignore
View file @
6168db92
...
...
@@ -59,6 +59,7 @@
/sound/BGM
/update
/update*
/locales
# ygopro main program
/ygopro
...
...
gframe/event_handler.cpp
View file @
6168db92
...
...
@@ -1906,6 +1906,17 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
}
break
;
}
case
irr
:
:
gui
::
EGET_COMBO_BOX_CHANGED
:
{
switch
(
id
)
{
case
COMBOBOX_LOCALE
:
{
myswprintf
(
mainGame
->
gameConf
.
locale
,
L"%ls"
,
mainGame
->
cbLocale
->
getItem
(
mainGame
->
cbLocale
->
getSelected
()));
mainGame
->
SaveConfig
();
return
true
;
break
;
}
}
break
;
}
case
irr
:
:
gui
::
EGET_EDITBOX_ENTER
:
{
switch
(
id
)
{
case
EDITBOX_CHAT
:
{
...
...
gframe/game.cpp
View file @
6168db92
...
...
@@ -84,8 +84,10 @@ bool Game::Initialize() {
if
(
!
imageManager
.
Initial
())
return
false
;
LoadExpansionDB
();
if
(
dataManager
.
LoadDB
(
GetLocaleDir
(
"cards.cdb"
)))
{}
else
if
(
!
dataManager
.
LoadDB
(
"cards.cdb"
))
return
false
;
if
(
dataManager
.
LoadStrings
(
GetLocaleDir
(
"strings.conf"
)))
{}
else
if
(
!
dataManager
.
LoadStrings
(
"strings.conf"
))
return
false
;
dataManager
.
LoadStrings
(
"./expansions/strings.conf"
);
...
...
@@ -338,6 +340,10 @@ bool Game::Initialize() {
posY
+=
30
;
chkEnablePScale
=
env
->
addCheckBox
(
false
,
rect
<
s32
>
(
posX
,
posY
,
posX
+
260
,
posY
+
25
),
tabSystem
,
-
1
,
dataManager
.
GetSysString
(
1287
));
chkEnablePScale
->
setChecked
(
gameConf
.
chkEnablePScale
!=
0
);
posY
+=
30
;
env
->
addStaticText
(
dataManager
.
GetSysString
(
1288
),
rect
<
s32
>
(
posX
+
23
,
posY
+
3
,
posX
+
160
,
posY
+
28
),
false
,
false
,
tabSystem
);
cbLocale
=
env
->
addComboBox
(
rect
<
s32
>
(
posX
+
160
,
posY
+
4
,
posX
+
260
,
posY
+
21
),
tabSystem
,
COMBOBOX_LOCALE
);
RefreshLocales
();
//
wHand
=
env
->
addWindow
(
rect
<
s32
>
(
500
,
450
,
825
,
605
),
false
,
L""
);
wHand
->
getCloseButton
()
->
setVisible
(
false
);
...
...
@@ -1048,11 +1054,48 @@ void Game::RefreshSingleplay() {
closedir
(
dir
);
#endif
}
void
Game
::
RefreshLocales
()
{
cbLocale
->
clear
();
cbLocale
->
addItem
(
L"default"
);
#ifdef _WIN32
WIN32_FIND_DATAW
fdataw
;
HANDLE
fh
=
FindFirstFileW
(
L"./locales/*"
,
&
fdataw
);
if
(
fh
==
INVALID_HANDLE_VALUE
)
return
;
do
{
if
((
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
&&
wcscmp
(
fdataw
.
cFileName
,
L"."
)
&&
wcscmp
(
fdataw
.
cFileName
,
L".."
))
cbLocale
->
addItem
(
fdataw
.
cFileName
);
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
FindClose
(
fh
);
#else
DIR
*
dir
;
struct
dirent
*
dirp
;
if
((
dir
=
opendir
(
"./locales/"
))
==
NULL
)
return
;
while
((
dirp
=
readdir
(
dir
))
!=
NULL
)
{
size_t
len
=
strlen
(
dirp
->
d_name
);
wchar_t
wname
[
256
];
BufferIO
::
DecodeUTF8
(
dirp
->
d_name
,
wname
);
if
(
!
wcscmp
(
wname
,
L"."
)
||
!
wcscmp
(
wname
,
L".."
))
continue
;
cbLocale
->
addItem
(
wname
);
}
closedir
(
dir
);
#endif
for
(
size_t
i
=
0
;
i
<
cbLocale
->
getItemCount
();
++
i
)
{
if
(
!
wcscmp
(
cbLocale
->
getItem
(
i
),
gameConf
.
locale
))
{
cbLocale
->
setSelected
(
i
);
break
;
}
}
}
void
Game
::
RefreshBot
()
{
if
(
!
gameConf
.
enable_bot_mode
)
return
;
botInfo
.
clear
();
FILE
*
fp
=
fopen
(
"bot.conf"
,
"r"
);
FILE
*
fp
=
fopen
(
GetLocaleDir
(
"bot.conf"
),
"r"
);
if
(
!
fp
)
fp
=
fopen
(
"bot.conf"
,
"r"
);
char
linebuf
[
256
];
char
strbuf
[
256
];
if
(
fp
)
{
...
...
@@ -1239,6 +1282,9 @@ void Game::LoadConfig() {
}
else
if
(
!
strcmp
(
strbuf
,
"lastdeck"
))
{
BufferIO
::
DecodeUTF8
(
valbuf
,
wstr
);
BufferIO
::
CopyWStr
(
wstr
,
gameConf
.
lastdeck
,
64
);
}
else
if
(
!
strcmp
(
strbuf
,
"locale"
))
{
BufferIO
::
DecodeUTF8
(
valbuf
,
wstr
);
BufferIO
::
CopyWStr
(
wstr
,
gameConf
.
locale
,
64
);
}
}
}
...
...
@@ -1346,6 +1392,9 @@ void Game::LoadConfig() {
}
else
if
(
!
strcmp
(
strbuf
,
"lastdeck"
))
{
BufferIO
::
DecodeUTF8
(
valbuf
,
wstr
);
BufferIO
::
CopyWStr
(
wstr
,
gameConf
.
lastdeck
,
64
);
}
else
if
(
!
strcmp
(
strbuf
,
"locale"
))
{
BufferIO
::
DecodeUTF8
(
valbuf
,
wstr
);
BufferIO
::
CopyWStr
(
wstr
,
gameConf
.
locale
,
64
);
}
}
}
...
...
@@ -1421,6 +1470,8 @@ void Game::SaveConfig() {
#endif
fprintf
(
fp
,
"enable_pendulum_scale = %d
\n
"
,
((
mainGame
->
chkEnablePScale
->
isChecked
())
?
1
:
0
));
fprintf
(
fp
,
"skin_index = %d
\n
"
,
gameConf
.
skin_index
);
BufferIO
::
EncodeUTF8
(
gameConf
.
locale
,
linebuf
);
fprintf
(
fp
,
"locale = %s
\n
"
,
linebuf
);
fclose
(
fp
);
}
void
Game
::
ShowCardInfo
(
int
code
,
bool
resize
)
{
...
...
@@ -1638,6 +1689,8 @@ void Game::initUtils() {
MakeDirectory
(
"sound/custom"
);
MakeDirectory
(
"sound/BGM/custom"
);
#endif
//locales
MakeDirectory
(
"locales"
);
//pics
MakeDirectory
(
"pics"
);
MakeDirectory
(
"pics/field"
);
...
...
@@ -1808,6 +1861,7 @@ void Game::OnResize() {
//sound / music volume bar
scrSoundVolume
->
setRelativePosition
(
recti
(
20
+
126
,
230
+
4
,
20
+
(
300
*
xScale
)
-
40
,
230
+
21
));
scrMusicVolume
->
setRelativePosition
(
recti
(
20
+
126
,
260
+
4
,
20
+
(
300
*
xScale
)
-
40
,
260
+
21
));
cbLocale
->
setRelativePosition
(
recti
(
20
+
160
,
350
+
4
,
20
+
(
300
*
xScale
)
-
40
,
350
+
21
));
if
(
gameConf
.
resize_popup_menu
)
{
int
width
=
100
*
mainGame
->
xScale
;
...
...
@@ -2004,6 +2058,16 @@ void Game::takeScreenshot() {
}
else
device
->
getLogger
()
->
log
(
L"Failed to take screenshot."
,
irr
::
ELL_WARNING
);
}
const
char
*
Game
::
GetLocaleDir
(
const
char
*
dir
)
{
if
(
!
gameConf
.
locale
||
!
wcscmp
(
gameConf
.
locale
,
L"default"
))
return
dir
;
wchar_t
locale_buf
[
256
];
wchar_t
orig_dir
[
64
];
BufferIO
::
DecodeUTF8
(
dir
,
orig_dir
);
myswprintf
(
locale_buf
,
L"locales/%ls/%ls"
,
gameConf
.
locale
,
orig_dir
);
BufferIO
::
EncodeUTF8
(
locale_buf
,
locale_buf_utf8
);
return
locale_buf_utf8
;
}
void
Game
::
SetCursor
(
ECURSOR_ICON
icon
)
{
ICursorControl
*
cursor
=
mainGame
->
device
->
getCursorControl
();
if
(
cursor
->
getActiveIcon
()
!=
icon
)
{
...
...
gframe/game.h
View file @
6168db92
...
...
@@ -26,6 +26,7 @@ struct Config {
wchar_t
textfont
[
256
];
wchar_t
numfont
[
256
];
wchar_t
roompass
[
20
];
wchar_t
locale
[
64
];
//settings
int
chkMAutoPos
;
int
chkSTAutoPos
;
...
...
@@ -124,6 +125,7 @@ public:
void
RefreshReplay
();
void
RefreshSingleplay
();
void
RefreshBot
();
void
RefreshLocales
();
void
DrawSelectionLine
(
irr
::
video
::
S3DVertex
*
vec
,
bool
strip
,
int
width
,
float
*
cv
);
void
DrawSelectionLine
(
irr
::
gui
::
IGUIElement
*
element
,
int
width
,
irr
::
video
::
SColor
color
);
void
DrawBackGround
();
...
...
@@ -156,6 +158,7 @@ public:
int
LocalPlayer
(
int
player
);
const
wchar_t
*
LocalName
(
int
local_player
);
const
char
*
GetLocaleDir
(
const
char
*
dir
);
bool
HasFocus
(
EGUI_ELEMENT_TYPE
type
)
const
{
irr
::
gui
::
IGUIElement
*
focus
=
env
->
getFocus
();
...
...
@@ -233,8 +236,9 @@ public:
irr
::
core
::
dimension2d
<
irr
::
u32
>
window_size
;
float
xScale
;
float
yScale
;
CGUISkinSystem
*
skinSystem
;
char
locale_buf_utf8
[
256
];
ClientField
dField
;
DeckBuilder
deckBuilder
;
...
...
@@ -292,6 +296,7 @@ public:
irr
::
gui
::
IGUIButton
*
btnWinResizeL
;
irr
::
gui
::
IGUIButton
*
btnWinResizeXL
;
irr
::
gui
::
IGUICheckBox
*
chkEnablePScale
;
irr
::
gui
::
IGUIComboBox
*
cbLocale
;
//main menu
irr
::
gui
::
IGUIWindow
*
wMainMenu
;
irr
::
gui
::
IGUIButton
*
btnLanMode
;
...
...
@@ -688,6 +693,7 @@ extern Game* mainGame;
#define BUTTON_WINDOW_RESIZE_M 366
#define BUTTON_WINDOW_RESIZE_L 367
#define BUTTON_WINDOW_RESIZE_XL 368
#define COMBOBOX_LOCALE 369
#define COMBOBOX_SORTTYPE 370
#define COMBOBOX_LIMIT 371
...
...
gframe/image_manager.cpp
View file @
6168db92
...
...
@@ -337,6 +337,14 @@ irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) {
sprintf
(
file
,
"expansions/pics/%d.jpg"
,
code
);
img
=
GetTextureFromFile
(
file
,
width
,
height
);
}
if
(
img
==
NULL
)
{
sprintf
(
file
,
mainGame
->
GetLocaleDir
(
"pics/%d.png"
),
code
);
img
=
GetTextureFromFile
(
file
,
width
,
height
);
}
if
(
img
==
NULL
)
{
sprintf
(
file
,
mainGame
->
GetLocaleDir
(
"pics/%d.jpg"
),
code
);
img
=
GetTextureFromFile
(
file
,
width
,
height
);
}
if
(
img
==
NULL
)
{
sprintf
(
file
,
"pics/%d.png"
,
code
);
img
=
GetTextureFromFile
(
file
,
width
,
height
);
...
...
@@ -371,6 +379,14 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
sprintf
(
file
,
"expansions/pics/thumbnail/%d.jpg"
,
code
);
img
=
GetTextureFromFile
(
file
,
width
,
height
);
}
if
(
img
==
NULL
)
{
sprintf
(
file
,
mainGame
->
GetLocaleDir
(
"pics/thumbnail/%d.png"
),
code
);
img
=
GetTextureFromFile
(
file
,
width
,
height
);
}
if
(
img
==
NULL
)
{
sprintf
(
file
,
mainGame
->
GetLocaleDir
(
"pics/thumbnail/%d.jpg"
),
code
);
img
=
GetTextureFromFile
(
file
,
width
,
height
);
}
if
(
img
==
NULL
)
{
sprintf
(
file
,
"pics/thumbnail/%d.png"
,
code
);
img
=
GetTextureFromFile
(
file
,
width
,
height
);
...
...
@@ -386,6 +402,14 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
sprintf
(
file
,
"expansions/pics/%d.jpg"
,
code
);
img
=
GetTextureFromFile
(
file
,
width
,
height
);
}
if
(
img
==
NULL
)
{
sprintf
(
file
,
mainGame
->
GetLocaleDir
(
"pics/%d.png"
),
code
);
img
=
GetTextureFromFile
(
file
,
width
,
height
);
}
if
(
img
==
NULL
)
{
sprintf
(
file
,
mainGame
->
GetLocaleDir
(
"pics/%d.jpg"
),
code
);
img
=
GetTextureFromFile
(
file
,
width
,
height
);
}
if
(
img
==
NULL
)
{
sprintf
(
file
,
"pics/%d.png"
,
code
);
img
=
GetTextureFromFile
(
file
,
width
,
height
);
...
...
strings.conf
View file @
6168db92
...
...
@@ -314,6 +314,8 @@
!
system
1285
大
!
system
1286
特大
!
system
1287
数字灵摆图片
!
system
1288
语言(重启后生效)
!
system
1289
默认
!
system
1290
忽略对方发言
!
system
1291
忽略观战者发言
!
system
1292
忽略时点
...
...
system.conf
View file @
6168db92
...
...
@@ -43,3 +43,4 @@ window_height = 640
resize_popup_menu
=
0
enable_pendulum_scale
=
1
skin_index
= -
1
locale
=
default
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