Skip to content

Commit

Permalink
Fix: initial screen flicker
Browse files Browse the repository at this point in the history
  • Loading branch information
daelsepara committed Aug 16, 2024
1 parent cd55056 commit 1b4f2d6
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 43 deletions.
2 changes: 1 addition & 1 deletion build/amd64/debian/HeartOfIce.desktop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Desktop Entry]
Name=Heart of Ice
Comment=Heart of Ice
Version=1.0.6
Version=1.0.7
TryExec=/usr/local/games/HeartOfIce/HeartOfIce.exe
Exec=/usr/local/games/HeartOfIce/HeartOfIce.exe
Icon=/usr/local/games/HeartOfIce/icons/snowflakes.png
Expand Down
2 changes: 1 addition & 1 deletion build/amd64/debian/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: heart-of-ice
Version: 1.0.6
Version: 1.0.7
Maintainer: Dael Separa <dael.separa@gmail.com>
Architecture: amd64
Description: Heart of Ice (SDL)
Expand Down
2 changes: 1 addition & 1 deletion build/armhf/raspbian/HeartOfIce.desktop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Desktop Entry]
Name=Heart of Ice
Comment=Heart of Ice
Version=1.0.6
Version=1.0.7
TryExec=/usr/local/games/HeartOfIce/HeartOfIce.exe
Exec=/usr/local/games/HeartOfIce/HeartOfIce.exe
Icon=/usr/local/games/HeartOfIce/icons/snowflakes.png
Expand Down
2 changes: 1 addition & 1 deletion build/armhf/raspbian/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: heart-of-ice
Version: 1.0.6
Version: 1.0.7
Maintainer: Dael Separa <dael.separa@gmail.com>
Architecture: armhf
Description: Heart of Ice (SDL)
Expand Down
2 changes: 1 addition & 1 deletion build/i386/debian/HeartOfIce.desktop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Desktop Entry]
Name=Heart of Ice
Comment=Heart of Ice
Version=1.0.6
Version=1.0.7
TryExec=/usr/local/games/HeartOfIce/HeartOfIce.exe
Exec=/usr/local/games/HeartOfIce/HeartOfIce.exe
Icon=/usr/local/games/HeartOfIce/icons/snowflakes.png
Expand Down
2 changes: 1 addition & 1 deletion build/i386/debian/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: heart-of-ice
Version: 1.0.6
Version: 1.0.7
Maintainer: Dael Separa <dael.separa@gmail.com>
Architecture: i386
Description: Heart of Ice (SDL)
Expand Down
84 changes: 47 additions & 37 deletions src/HeartOfIce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,6 @@ SDL_Surface *createImage(const char *image)
return surface;
}

void initWindowRenderer(SDL_Renderer *renderer)
{
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
}

void createWindow(Uint32 flags, SDL_Window **window, SDL_Renderer **renderer, const char *title, const char *icon)
{
// The window we'll be rendering to
Expand Down Expand Up @@ -128,8 +121,6 @@ void createWindow(Uint32 flags, SDL_Window **window, SDL_Renderer **renderer, co

surface = NULL;
}

initWindowRenderer(*renderer);
}
}

Expand Down Expand Up @@ -686,9 +677,9 @@ bool characterScreen(SDL_Window *window, SDL_Renderer *renderer, Character::Base

renderButtons(renderer, controls, current, intGR, text_space, text_space / 2);

bool scrollUp = false;
bool scrollDown = false;
bool hold = false;
auto scrollUp = false;
auto scrollDown = false;
auto hold = false;

done = Input::GetInput(renderer, controls, current, selected, scrollUp, scrollDown, hold);

Expand Down Expand Up @@ -784,8 +775,8 @@ bool glossaryScreen(SDL_Window *window, SDL_Renderer *renderer, std::vector<Skil

renderButtons(renderer, controls, current, intGR, border_space, border_pts, (offset > 0), glossary && offset < (glossary->h - text_bounds + 2 * text_space));

bool scrollUp = false;
bool scrollDown = false;
auto scrollUp = false;
auto scrollDown = false;

quit = Input::GetInput(renderer, controls, current, selected, scrollUp, scrollDown, hold);

Expand Down Expand Up @@ -1629,9 +1620,9 @@ Character::Base customCharacter(SDL_Window *window, SDL_Renderer *renderer)

auto font = TTF_OpenFont(FONT_FILE, font_size);

bool scrollUp = false;
bool scrollDown = false;
bool hold = false;
auto scrollUp = false;
auto scrollDown = false;
auto hold = false;
auto scrollSpeed = 1;

auto selection = std::vector<int>();
Expand Down Expand Up @@ -1946,9 +1937,9 @@ Character::Base selectCharacter(SDL_Window *window, SDL_Renderer *renderer)

renderTextButtons(renderer, controls, FONT_FILE, current, clrWH, intBK, intRD, font20, TTF_STYLE_NORMAL);

bool scrollUp = false;
bool scrollDown = false;
bool hold = false;
auto scrollUp = false;
auto scrollDown = false;
auto hold = false;

Input::GetInput(renderer, controls, current, selected, scrollUp, scrollDown, hold);

Expand Down Expand Up @@ -2071,9 +2062,9 @@ bool aboutScreen(SDL_Window *window, SDL_Renderer *renderer)
renderText(renderer, text, intLB, startx * 2 + splashw, starty, SCREEN_HEIGHT * (1.0 - 2 * Margin), 0);
renderTextButtons(renderer, controls, FONT_FILE, current, clrWH, intBK, intRD, font_size, TTF_STYLE_NORMAL);

bool scrollUp = false;
bool scrollDown = false;
bool hold = false;
auto scrollUp = false;
auto scrollDown = false;
auto hold = false;

done = Input::GetInput(renderer, controls, current, selected, scrollUp, scrollDown, hold);

Expand Down Expand Up @@ -3389,9 +3380,9 @@ bool mapScreen(SDL_Window *window, SDL_Renderer *renderer)

renderButtons(renderer, controls, current, intWH, 8, 4);

bool scrollUp = false;
bool scrollDown = false;
bool hold = false;
auto scrollUp = false;
auto scrollDown = false;
auto hold = false;

if (splash && texture)
{
Expand Down Expand Up @@ -3640,8 +3631,8 @@ Story::Base *processChoices(SDL_Window *window, SDL_Renderer *renderer, Characte
}
else
{
bool loaded = true;
int weapons = 0;
auto loaded = true;
auto weapons = 0;

for (auto i = 0; i < story->Choices[current].Items.size(); i++)
{
Expand Down Expand Up @@ -4267,7 +4258,6 @@ bool loseSkills(SDL_Window *window, SDL_Renderer *renderer, Character::Base &pla
auto scrollUp = false;
auto scrollDown = false;
auto hold = false;

auto infoh = 0.06 * SCREEN_HEIGHT;
auto boxh = 0.125 * SCREEN_HEIGHT;

Expand Down Expand Up @@ -4315,9 +4305,7 @@ bool loseSkills(SDL_Window *window, SDL_Renderer *renderer, Character::Base &pla

putText(renderer, "SKILLS", font, text_space, clrWH, intLB, TTF_STYLE_NORMAL, splashw, infoh, startx, starty + text_bounds - (boxh + infoh));
putText(renderer, selection.size() > 0 ? to_lose.c_str() : "(None)", font, text_space, clrBK, intBE, TTF_STYLE_NORMAL, splashw, boxh, startx, starty + text_bounds - boxh);

fillRect(renderer, textwidth + arrow_size + button_space, text_bounds, textx, texty, intBE);

renderButtons(renderer, controls, current, intGR, text_space, text_space / 2);

for (auto i = 0; i < player.Skills.size(); i++)
Expand Down Expand Up @@ -4629,8 +4617,8 @@ bool processStory(SDL_Window *window, SDL_Renderer *renderer, Character::Base &p
}
}

bool scrollUp = false;
bool scrollDown = false;
auto scrollUp = false;
auto scrollDown = false;

renderButtons(renderer, controls, vehicle_trigger ? -1 : current, intGR, border_space, border_pts, (offset > 0), text && offset < (text->h - text_bounds + 2 * text_space));

Expand Down Expand Up @@ -5075,21 +5063,43 @@ bool mainScreen(SDL_Window *window, SDL_Renderer *renderer, int storyID)

auto done = false;

auto first = true;

while (!done)
{
// Fill the surface with background
fillWindow(renderer, intLB);

fitImage(renderer, splash, startx, starty, splashw, text_bounds);
renderText(renderer, text, intLB, startx * 2 + splashw, starty, SCREEN_HEIGHT * (1.0 - 2 * Margin), 0);
renderTextButtons(renderer, controls, FONT_FILE, current, clrWH, intBK, intRD, font_size, TTF_STYLE_NORMAL);

bool scrollUp = false;
bool scrollDown = false;
bool hold = false;
auto scrollUp = false;
auto scrollDown = false;
auto hold = false;

Control::Type result;

if (first)
{
SDL_Event user_event;

user_event.type = SDL_MOUSEMOTION;

user_event.motion.x = controls[0].X;

user_event.motion.y = controls[0].Y;

user_event.motion.xrel = controls[0].W / 2;

user_event.motion.yrel = controls[0].H / 2;

SDL_PushEvent(&user_event);

SDL_PumpEvents();

first = false;
}

done = Input::GetInput(renderer, controls, current, selected, scrollUp, scrollDown, hold);

if (selected && current >= 0 && current < controls.size())
Expand Down

0 comments on commit 1b4f2d6

Please sign in to comment.