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

Megashot Fix #174

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 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
18 changes: 11 additions & 7 deletions GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1186,15 +1186,16 @@ void saveMegashot(bool tall)
stonesenseState.map_segment.lockRead();

auto& ssState = stonesenseState.ssState;
// draw_textf_border(font, uiColor(1), ssState.ScreenW/2, ssState.ScreenH/2, ALLEGRO_ALIGN_CENTRE, "saving large screenshot...");
draw_textf_border(stonesenseState.font, uiColor(1), ssState.ScreenW/2, ssState.ScreenH/2, ALLEGRO_ALIGN_CENTRE, "saving large screenshot... Stonesense will become unresponsive after this process completes. Please close and re-open Stonesense.");
draw_textf_border(stonesenseState.font, uiColor(1), ssState.ScreenW/2, ssState.ScreenH/2, ALLEGRO_ALIGN_CENTRE, "saving large screenshot...");
al_flip_display();
std::filesystem::path filename = getAvailableFilename("screenshot");
// int timer = clock();
int timer = clock();
//back up all the relevant values
auto& ssConfig = stonesenseState.ssConfig;
GameConfiguration tempConfig = ssConfig;
GameState tempState = ssState;
uint32_t templiftX = stonesenseState.lift_segment_offscreen_x;
uint32_t templiftY = stonesenseState.lift_segment_offscreen_y;
int tempflags = al_get_new_bitmap_flags();

//now make them real big.
Expand Down Expand Up @@ -1339,19 +1340,22 @@ void saveMegashot(bool tall)


al_save_bitmap(filename.string().c_str(), bigFile);
// al_set_target_bitmap(al_get_backbuffer(al_get_current_display()));
// timer = clock() - timer;
// PrintMessage("\tcreating screenshot took %ims\n", timer);
al_set_target_bitmap(al_get_backbuffer(al_get_current_display()));
timer = clock() - timer;
PrintMessage("\tcreating screenshot took %.2fms\n", clockToMs(timer));
PrintMessage("\tlarge screenshot complete\n");
} else {
LogError("failed to take large screenshot; try zooming out\n");
}
// al_destroy_bitmap(bigFile);
al_destroy_bitmap(bigFile);
//restore everything that we changed.
stonesenseState.lift_segment_offscreen_x = templiftX;
stonesenseState.lift_segment_offscreen_y = templiftY;
ssConfig = tempConfig;
ssState = tempState;
al_set_new_bitmap_flags(tempflags);

al_flip_display();
stonesenseState.map_segment.unlockRead();
}

Expand Down
1 change: 1 addition & 0 deletions StonesenseState.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class StonesenseState
FrameTimers stoneSenseTimers;
bool timeToReloadSegment;
bool timeToReloadConfig;
bool timeToCloseWindow;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, new var for debugging and future use.

Copy link
Member

@myk002 myk002 Feb 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can keep it in a local branch, but as it is, this is just confusing to have in the mainline code

It is not uncommon to have debugging changes in a local branch that you can merge into your local code as needed.

char currentAnimationFrame;
uint32_t currentFrameLong;
bool animationFrameShown;
Expand Down
2 changes: 2 additions & 0 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ void PrintMessage(const char* msg, ...) Wformat(printf,1,2);
void LogVerbose(const char* msg, ...) Wformat(printf,1,2);
void SetTitle(const char *format, ...) Wformat(printf,1,2);

float clockToMs(float clockTicks);

constexpr auto MAX_ANIMFRAME = 6;

// binary 00111111
Expand Down
1 change: 1 addition & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Template for new versions:
- `stonesense`: fixed announcement text rendering off-screen with larger font sizes
- `stonesense`: screen dimensions are now properly set when overriden by a window manager
- `stonesense`: fixed glass cabinets and bookcases being misaligned by 1 pixel
- `stonesense`: megashots no longer leave stonesense unresponsive
- `stonesense`: fixed unrevealed walls being hidden by default
- `stonesense`: vampires no longer show their true name when they shouldn't
- `stonesense`: fixed debug performance timers to show milliseconds as intended
Expand Down
2 changes: 2 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ static void main_loop(ALLEGRO_DISPLAY * display, ALLEGRO_EVENT_QUEUE *queue, ALL

ALLEGRO_EVENT event;
while (!al_get_thread_should_stop(main_thread)) {
if (stonesenseState.timeToCloseWindow) { return;}
realSquidCoder marked this conversation as resolved.
Show resolved Hide resolved

if (redraw && al_event_queue_is_empty(queue)) {

al_rest(0);
Expand Down