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
nanahira
ygopro
Commits
5f0c0cdf
Commit
5f0c0cdf
authored
Dec 18, 2017
by
nanahira
Committed by
GitHub
Dec 18, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update image_manager.cpp
parent
d727eacf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
53 deletions
+38
-53
gframe/image_manager.cpp
gframe/image_manager.cpp
+38
-53
No files found.
gframe/image_manager.cpp
View file @
5f0c0cdf
#include "image_manager.h"
#include "image_manager.h"
#include "game.h"
#include "game.h"
#ifndef _WIN32
#include <dirent.h>
#endif
namespace
ygo
{
namespace
ygo
{
ImageManager
imageManager
;
ImageManager
imageManager
;
bool
ImageManager
::
Initial
()
{
bool
ImageManager
::
Initial
()
{
#ifdef _WIN32
RefreshRandomImageList
();
RefreshRandomImageList
();
#endif
#ifdef _WIN32
tCover
[
0
]
=
GetRandomImage
(
TEXTURE_COVER_S
);
tCover
[
0
]
=
GetRandomImage
(
TEXTURE_COVER_S
);
if
(
!
tCover
[
0
])
if
(
!
tCover
[
0
])
tCover
[
0
]
=
driver
->
getTexture
(
"textures/cover.jpg"
);
tCover
[
0
]
=
driver
->
getTexture
(
"textures/cover.jpg"
);
...
@@ -19,24 +19,15 @@ bool ImageManager::Initial() {
...
@@ -19,24 +19,15 @@ bool ImageManager::Initial() {
tCover
[
1
]
=
driver
->
getTexture
(
"textures/cover2.jpg"
);
tCover
[
1
]
=
driver
->
getTexture
(
"textures/cover2.jpg"
);
if
(
!
tCover
[
1
])
if
(
!
tCover
[
1
])
tCover
[
1
]
=
GetRandomImage
(
TEXTURE_COVER_S
);
tCover
[
1
]
=
GetRandomImage
(
TEXTURE_COVER_S
);
#else
tCover
[
0
]
=
driver
->
getTexture
(
"textures/cover.jpg"
);
tCover
[
1
]
=
driver
->
getTexture
(
"textures/cover2.jpg"
);
#endif
if
(
!
tCover
[
1
])
if
(
!
tCover
[
1
])
tCover
[
1
]
=
tCover
[
0
];
tCover
[
1
]
=
tCover
[
0
];
tUnknown
=
driver
->
getTexture
(
"textures/unknown.jpg"
);
tUnknown
=
driver
->
getTexture
(
"textures/unknown.jpg"
);
#ifdef _WIN32
tAct
=
GetRandomImage
(
TEXTURE_ACTIVATE
);
tAct
=
GetRandomImage
(
TEXTURE_ACTIVATE
);
tAttack
=
GetRandomImage
(
TEXTURE_ATTACK
);
tAttack
=
GetRandomImage
(
TEXTURE_ATTACK
);
if
(
!
tAct
)
if
(
!
tAct
)
tAct
=
driver
->
getTexture
(
"textures/act.png"
);
tAct
=
driver
->
getTexture
(
"textures/act.png"
);
if
(
!
tAttack
)
if
(
!
tAttack
)
tAttack
=
driver
->
getTexture
(
"textures/attack.png"
);
tAttack
=
driver
->
getTexture
(
"textures/attack.png"
);
#else
tAct
=
driver
->
getTexture
(
"textures/act.png"
);
tAttack
=
driver
->
getTexture
(
"textures/attack.png"
);
#endif
tChain
=
driver
->
getTexture
(
"textures/chain.png"
);
tChain
=
driver
->
getTexture
(
"textures/chain.png"
);
tNegated
=
driver
->
getTexture
(
"textures/negated.png"
);
tNegated
=
driver
->
getTexture
(
"textures/negated.png"
);
tNumber
=
driver
->
getTexture
(
"textures/number.png"
);
tNumber
=
driver
->
getTexture
(
"textures/number.png"
);
...
@@ -51,7 +42,6 @@ bool ImageManager::Initial() {
...
@@ -51,7 +42,6 @@ bool ImageManager::Initial() {
tHand
[
0
]
=
driver
->
getTexture
(
"textures/f1.jpg"
);
tHand
[
0
]
=
driver
->
getTexture
(
"textures/f1.jpg"
);
tHand
[
1
]
=
driver
->
getTexture
(
"textures/f2.jpg"
);
tHand
[
1
]
=
driver
->
getTexture
(
"textures/f2.jpg"
);
tHand
[
2
]
=
driver
->
getTexture
(
"textures/f3.jpg"
);
tHand
[
2
]
=
driver
->
getTexture
(
"textures/f3.jpg"
);
#ifdef _WIN32
tBackGround
=
GetRandomImage
(
TEXTURE_DUEL
);
tBackGround
=
GetRandomImage
(
TEXTURE_DUEL
);
if
(
!
tBackGround
)
if
(
!
tBackGround
)
tBackGround
=
driver
->
getTexture
(
"textures/bg.jpg"
);
tBackGround
=
driver
->
getTexture
(
"textures/bg.jpg"
);
...
@@ -71,24 +61,12 @@ bool ImageManager::Initial() {
...
@@ -71,24 +61,12 @@ bool ImageManager::Initial() {
tBackGround_deck
=
GetRandomImage
(
TEXTURE_DUEL
);
tBackGround_deck
=
GetRandomImage
(
TEXTURE_DUEL
);
if
(
!
tBackGround_deck
)
if
(
!
tBackGround_deck
)
tBackGround_deck
=
tBackGround
;
tBackGround_deck
=
tBackGround
;
#else
tBackGround
=
driver
->
getTexture
(
"textures/bg.jpg"
);
if
(
!
tBackGround
)
tBackGround
=
driver
->
getTexture
(
"textures/bg_duel.jpg"
);
tBackGround_menu
=
driver
->
getTexture
(
"textures/bg_menu.jpg"
);
if
(
!
tBackGround_menu
)
tBackGround_menu
=
tBackGround
;
tBackGround_deck
=
driver
->
getTexture
(
"textures/bg_deck.jpg"
);
if
(
!
tBackGround_deck
)
tBackGround_deck
=
tBackGround
;
#endif
tField
[
0
]
=
driver
->
getTexture
(
"textures/field2.png"
);
tField
[
0
]
=
driver
->
getTexture
(
"textures/field2.png"
);
tFieldTransparent
[
0
]
=
driver
->
getTexture
(
"textures/field-transparent2.png"
);
tFieldTransparent
[
0
]
=
driver
->
getTexture
(
"textures/field-transparent2.png"
);
tField
[
1
]
=
driver
->
getTexture
(
"textures/field3.png"
);
tField
[
1
]
=
driver
->
getTexture
(
"textures/field3.png"
);
tFieldTransparent
[
1
]
=
driver
->
getTexture
(
"textures/field-transparent3.png"
);
tFieldTransparent
[
1
]
=
driver
->
getTexture
(
"textures/field-transparent3.png"
);
return
true
;
return
true
;
}
}
#ifdef _WIN32
irr
::
video
::
ITexture
*
ImageManager
::
GetRandomImage
(
int
image_type
)
{
irr
::
video
::
ITexture
*
ImageManager
::
GetRandomImage
(
int
image_type
)
{
int
count
=
ImageList
[
image_type
].
size
();
int
count
=
ImageList
[
image_type
].
size
();
if
(
count
<=
0
)
if
(
count
<=
0
)
...
@@ -102,44 +80,51 @@ irr::video::ITexture* ImageManager::GetRandomImage(int image_type) {
...
@@ -102,44 +80,51 @@ irr::video::ITexture* ImageManager::GetRandomImage(int image_type) {
return
driver
->
getTexture
(
ImageName
);
return
driver
->
getTexture
(
ImageName
);
}
}
void
ImageManager
::
RefreshRandomImageList
()
{
void
ImageManager
::
RefreshRandomImageList
()
{
Refresh
JPG
Dir
(
L"bg/"
,
TEXTURE_DUEL
);
Refresh
Image
Dir
(
L"bg/"
,
TEXTURE_DUEL
);
Refresh
JPG
Dir
(
L"bg_duel/"
,
TEXTURE_DUEL
);
Refresh
Image
Dir
(
L"bg_duel/"
,
TEXTURE_DUEL
);
Refresh
JPG
Dir
(
L"bg_deck/"
,
TEXTURE_DECK
);
Refresh
Image
Dir
(
L"bg_deck/"
,
TEXTURE_DECK
);
Refresh
JPG
Dir
(
L"bg_menu/"
,
TEXTURE_MENU
);
Refresh
Image
Dir
(
L"bg_menu/"
,
TEXTURE_MENU
);
Refresh
JPG
Dir
(
L"cover/"
,
TEXTURE_COVER_S
);
Refresh
Image
Dir
(
L"cover/"
,
TEXTURE_COVER_S
);
Refresh
JPG
Dir
(
L"cover2/"
,
TEXTURE_COVER_O
);
Refresh
Image
Dir
(
L"cover2/"
,
TEXTURE_COVER_O
);
Refresh
PNG
Dir
(
L"attack/"
,
TEXTURE_ATTACK
);
Refresh
Image
Dir
(
L"attack/"
,
TEXTURE_ATTACK
);
Refresh
PNG
Dir
(
L"act/"
,
TEXTURE_ACTIVATE
);
Refresh
Image
Dir
(
L"act/"
,
TEXTURE_ACTIVATE
);
}
}
void
ImageManager
::
RefreshPNGDir
(
std
::
wstring
path
,
int
image_type
)
{
void
ImageManager
::
RefreshImageDir
(
std
::
wstring
path
,
int
image_type
)
{
#ifdef _WIN32
WIN32_FIND_DATAW
fdataw
;
WIN32_FIND_DATAW
fdataw
;
std
::
wstring
search
=
L"./textures/"
+
path
+
L"*.
png
"
;
std
::
wstring
search
=
L"./textures/"
+
path
+
L"*.
*
"
;
HANDLE
fh
=
FindFirstFileW
(
search
.
c_str
(),
&
fdataw
);
HANDLE
fh
=
FindFirstFileW
(
search
.
c_str
(),
&
fdataw
);
if
(
fh
==
INVALID_HANDLE_VALUE
)
if
(
fh
==
INVALID_HANDLE_VALUE
)
return
;
return
;
do
{
do
{
if
(
!
(
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
))
{
size_t
len
=
wcslen
(
fdataw
.
cFileName
);
std
::
wstring
filename
=
path
+
(
std
::
wstring
)
fdataw
.
cFileName
;
if
((
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
||
len
<
5
ImageList
[
image_type
].
push_back
(
filename
);
||
!
(
wcsicmp
(
fdataw
.
cFileName
+
len
-
4
,
L".jpg"
)
==
0
||
wcsicmp
(
fdataw
.
cFileName
+
len
-
4
,
L".png"
)
==
0
))
}
continue
;
std
::
wstring
filename
=
path
+
(
std
::
wstring
)
fdataw
.
cFileName
;
ImageList
[
image_type
].
push_back
(
filename
);
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
FindClose
(
fh
);
FindClose
(
fh
);
}
#else
void
ImageManager
::
RefreshJPGDir
(
std
::
wstring
path
,
int
image_type
)
{
DIR
*
dir
;
WIN32_FIND_DATAW
fdataw
;
struct
dirent
*
dirp
;
std
::
wstring
search
=
L"./textures/"
+
path
+
L"*.jpg"
;
std
::
wstring
wsearchpath
=
L"./textures/"
+
path
;
HANDLE
fh
=
FindFirstFileW
(
search
.
c_str
(),
&
fdataw
);
char
searchpath
[
256
];
if
(
fh
==
INVALID_HANDLE_VALUE
)
BufferIO
::
EncodeUTF8
(
wsearchpath
.
c_str
(),
searchpath
);
if
((
dir
=
opendir
(
searchpath
))
==
NULL
)
return
;
return
;
do
{
while
((
dirp
=
readdir
(
dir
))
!=
NULL
)
{
if
(
!
(
fdataw
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
))
{
size_t
len
=
strlen
(
dirp
->
d_name
);
std
::
wstring
filename
=
path
+
(
std
::
wstring
)
fdataw
.
cFileName
;
if
(
len
<
5
||
!
(
strcasecmp
(
dirp
->
d_name
+
len
-
4
,
".jpg"
)
==
0
||
strcasecmp
(
dirp
->
d_name
+
len
-
4
,
".png"
)))
ImageList
[
image_type
].
push_back
(
filename
);
continue
;
}
wchar_t
wname
[
256
];
}
while
(
FindNextFileW
(
fh
,
&
fdataw
));
BufferIO
::
DecodeUTF8
(
dirp
->
d_name
,
wname
);
FindClose
(
fh
);
std
::
wstring
filename
=
path
+
(
std
::
wstring
)
wname
;
}
ImageList
[
image_type
].
push_back
(
filename
);
}
closedir
(
dir
);
#endif
#endif
}
void
ImageManager
::
SetDevice
(
irr
::
IrrlichtDevice
*
dev
)
{
void
ImageManager
::
SetDevice
(
irr
::
IrrlichtDevice
*
dev
)
{
device
=
dev
;
device
=
dev
;
driver
=
dev
->
getVideoDriver
();
driver
=
dev
->
getVideoDriver
();
...
...
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