Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Screenshot Functionality #7431

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 8 additions & 23 deletions Source/capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "utils/surface_to_png.hpp"
#endif

#include "effects.h"
#include "engine/backbuffer_state.hpp"
#include "engine/dx.h"
#include "engine/palette.h"
Expand Down Expand Up @@ -57,25 +58,11 @@
return OpenFile(dstPath->c_str(), "wb");
}

/**
* @brief Make a red version of the given palette and apply it to the screen.
*/
void RedPalette()
{
for (int i = 0; i < 256; i++) {
system_palette[i].g = 0;
system_palette[i].b = 0;
}
palette_update();
BltFast(nullptr, nullptr);
RenderPresent();
}

} // namespace

void CaptureScreen()
{
SDL_Color palette[256];

Check warning on line 65 in Source/capture.cpp

View workflow job for this annotation

GitHub Actions / build

'palette': unreferenced local variable
std::string fileName;
const uint32_t startTime = SDL_GetTicks();

Expand All @@ -85,11 +72,10 @@
return;
}
DrawAndBlit();
PaletteGetEntries(256, palette);
RedPalette();
for (int i = 0; i < 256; i++) {
system_palette[i] = palette[i];
}

auto tempPalette = system_palette;

system_palette = orig_palette;
palette_update();

const tl::expected<void, std::string> result =
Expand All @@ -104,11 +90,10 @@
RemoveFile(fileName.c_str());
} else {
Log("Screenshot saved at {}", fileName);
PlaySFX(SfxID::MenuSelect);
}
const uint32_t timePassed = SDL_GetTicks() - startTime;
if (timePassed < 300) {
SDL_Delay(300 - timePassed);
}
system_palette = tempPalette;
palette_update();
RedrawEverything();
}

Expand Down
Loading