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
fe7f03eb
Commit
fe7f03eb
authored
Dec 26, 2020
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tmp save
parent
9ca608d0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
105 additions
and
17 deletions
+105
-17
gframe/game.cpp
gframe/game.cpp
+104
-15
gframe/game.h
gframe/game.h
+1
-2
No files found.
gframe/game.cpp
View file @
fe7f03eb
...
@@ -883,9 +883,7 @@ bool Game::Initialize() {
...
@@ -883,9 +883,7 @@ bool Game::Initialize() {
}
}
hideChat
=
false
;
hideChat
=
false
;
hideChatTimer
=
0
;
hideChatTimer
=
0
;
screenshotSequence
=
0
;
//testVideoFile = fopen("./test-video", "wb");
sprintf
(
screenshotDirectory
,
"screenshots/ygopro_%u"
,
device
->
getTimer
()
->
getRealTime
());
FileSystem
::
MakeDir
(
screenshotDirectory
);
return
true
;
return
true
;
}
}
void
Game
::
MainLoop
()
{
void
Game
::
MainLoop
()
{
...
@@ -991,6 +989,9 @@ void Game::MainLoop() {
...
@@ -991,6 +989,9 @@ void Game::MainLoop() {
SingleMode
::
StopPlay
(
true
);
SingleMode
::
StopPlay
(
true
);
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
500
));
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
500
));
SaveConfig
();
SaveConfig
();
//if(testVideoFile) {
// fclose(testVideoFile);
//}
// device->drop();
// device->drop();
}
}
void
Game
::
RefreshTimeDisplay
()
{
void
Game
::
RefreshTimeDisplay
()
{
...
@@ -2205,29 +2206,117 @@ void Game::takeScreenshot() {
...
@@ -2205,29 +2206,117 @@ void Game::takeScreenshot() {
}
else
}
else
device
->
getLogger
()
->
log
(
L"Failed to take screenshot."
,
irr
::
ELL_WARNING
);
device
->
getLogger
()
->
log
(
L"Failed to take screenshot."
,
irr
::
ELL_WARNING
);
}
}
void
Game
::
writeImageAsBMP
(
irr
::
video
::
IImage
*
const
image
,
file
*
fp
)
{
irr
::
video
::
SBMPHeader
imageHeader
;
imageHeader
.
Id
=
0x4d42
;
imageHeader
.
Reserved
=
0
;
imageHeader
.
BitmapDataOffset
=
sizeof
(
imageHeader
);
imageHeader
.
BitmapHeaderSize
=
0x28
;
imageHeader
.
Width
=
image
->
getDimension
().
Width
;
imageHeader
.
Height
=
image
->
getDimension
().
Height
;
imageHeader
.
Planes
=
1
;
imageHeader
.
BPP
=
24
;
imageHeader
.
Compression
=
0
;
imageHeader
.
PixelPerMeterX
=
0
;
imageHeader
.
PixelPerMeterY
=
0
;
imageHeader
.
Colors
=
0
;
imageHeader
.
ImportantColors
=
0
;
// data size is rounded up to next larger 4 bytes boundary
imageHeader
.
BitmapDataSize
=
imageHeader
.
Width
*
imageHeader
.
BPP
/
8
;
imageHeader
.
BitmapDataSize
=
(
imageHeader
.
BitmapDataSize
+
3
)
&
~
3
;
imageHeader
.
BitmapDataSize
*=
imageHeader
.
Height
;
// file size is data size plus offset to data
imageHeader
.
FileSize
=
imageHeader
.
BitmapDataOffset
+
imageHeader
.
BitmapDataSize
;
// bitmaps are stored upside down and padded so we always do this
void
(
*
CColorConverter_convertFORMATtoFORMAT
)(
const
void
*
,
s32
,
void
*
)
=
0
;
switch
(
image
->
getColorFormat
())
{
case
ECF_R8G8B8
:
CColorConverter_convertFORMATtoFORMAT
=
CColorConverter
::
convert_R8G8B8toR8G8B8
;
break
;
case
ECF_A8R8G8B8
:
CColorConverter_convertFORMATtoFORMAT
=
CColorConverter
::
convert_A8R8G8B8toB8G8R8
;
break
;
case
ECF_A1R5G5B5
:
CColorConverter_convertFORMATtoFORMAT
=
CColorConverter
::
convert_A1R5G5B5toR8G8B8
;
break
;
case
ECF_R5G6B5
:
CColorConverter_convertFORMATtoFORMAT
=
CColorConverter
::
convert_R5G6B5toR8G8B8
;
break
;
#ifndef _DEBUG
default:
break
;
#endif
}
// couldn't find a color converter
if
(
!
CColorConverter_convertFORMATtoFORMAT
)
return
false
;
// write the bitmap header
if
(
fwrite
(
&
imageHeader
,
sizeof
(
imageHeader
),
1
)
!=
sizeof
(
imageHeader
))
return
false
;
u8
*
scan_lines
=
(
u8
*
)
image
->
lock
();
if
(
!
scan_lines
)
return
false
;
// size of one pixel in bytes
u32
pixel_size
=
image
->
getBytesPerPixel
();
// length of one row of the source image in bytes
u32
row_stride
=
(
pixel_size
*
imageHeader
.
Width
);
// length of one row in bytes, rounded up to nearest 4-byte boundary
s32
row_size
=
((
3
*
imageHeader
.
Width
)
+
3
)
&
~
3
;
// allocate and clear memory for our scan line
u8
*
row_pointer
=
new
u8
[
row_size
];
memset
(
row_pointer
,
0
,
row_size
);
// convert the image to 24-bit BGR and flip it over
s32
y
;
for
(
y
=
imageHeader
.
Height
-
1
;
0
<=
y
;
--
y
)
{
if
(
image
->
getColorFormat
()
==
ECF_R8G8B8
)
CColorConverter
::
convert24BitTo24Bit
(
&
scan_lines
[
y
*
row_stride
],
row_pointer
,
imageHeader
.
Width
,
1
,
0
,
false
,
true
);
else
// source, length [pixels], destination
CColorConverter_convertFORMATtoFORMAT
(
&
scan_lines
[
y
*
row_stride
],
imageHeader
.
Width
,
row_pointer
);
if
(
file
->
write
(
row_pointer
,
row_size
)
<
row_size
)
break
;
}
// clean up our scratch area
delete
[]
row_pointer
;
// give back image handle
image
->
unlock
();
}
void
Game
::
takeScreenshotLoop
()
{
void
Game
::
takeScreenshotLoop
()
{
irr
::
video
::
IImage
*
const
image
=
driver
->
createScreenShot
();
irr
::
video
::
IImage
*
const
image
=
driver
->
createScreenShot
();
//const int currentSequence = ++screenshotSequence;
//const int currentSequence = ++screenshotSequence;
if
(
image
)
{
if
(
image
)
{
//irr::video::ECOLOR_FORMAT colorFormat = image->getColorFormat();
/*
//u32 pixel_size = image->getBytesPerPixel();
//u32 width = image->getDimension().Width;
//u32 height = image->getDimension().Height;
auto data = image->lock();
auto data = image->lock();
auto size = image->getImageDataSizeInBytes();
auto size = image->getImageDataSizeInBytes();
fwrite
(
data
,
size
,
1
,
stderr
);
fwrite(data, size, 1,
testVideoFile
);
fflush
(
stderr
);
fflush(
testVideoFile
);
image->unlock();
image->unlock();
*/
//irr::c8 filename[64];
//snprintf(filename, 64, "%s/%04d.bmp", screenshotDirectory, currentSequence);
//driver->writeImageToFile(image, filename);
image
->
drop
();
image
->
drop
();
}
else
}
else
device
->
getLogger
()
->
log
(
L"Failed to take loop screenshot."
,
irr
::
ELL_WARNING
);
device
->
getLogger
()
->
log
(
L"Failed to take loop screenshot."
,
irr
::
ELL_WARNING
);
}
}
...
...
gframe/game.h
View file @
fe7f03eb
...
@@ -260,8 +260,7 @@ public:
...
@@ -260,8 +260,7 @@ public:
bool
always_chain
;
bool
always_chain
;
bool
ignore_chain
;
bool
ignore_chain
;
bool
chain_when_avail
;
bool
chain_when_avail
;
int
screenshotSequence
;
//FILE *testVideoFile;
char
screenshotDirectory
[
64
];
bool
is_building
;
bool
is_building
;
bool
is_siding
;
bool
is_siding
;
...
...
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