From 620a7e3ed5226989aad73ffdf78fac9964fce8b1 Mon Sep 17 00:00:00 2001 From: Linus Probert Date: Thu, 13 Sep 2018 12:49:21 +0200 Subject: [PATCH] Maint: Less complex main --- src/main.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/src/main.c b/src/main.c index 59f8e18..0ff32d9 100644 --- a/src/main.c +++ b/src/main.c @@ -716,26 +716,25 @@ populateUpdateData(UpdateData *data, float deltatime) data->cam = gCamera; } -static void -run_game_update(void) +static bool +check_skillbar_activation(void) { - static UpdateData updateData; static unsigned int playerLevel = 1; - static bool artifactTooltipShown = false; - if (gGameState == IN_GAME_MENU) - menu_update(inGameMenu, &input); - - populateUpdateData(&updateData, deltaTime); - bool skillActivated = false; if (playerLevel != gPlayer->stats.lvl) { playerLevel = gPlayer->stats.lvl; - skillActivated = skillbar_check_skill_activation(gSkillBar, - gPlayer); + return skillbar_check_skill_activation(gSkillBar, gPlayer); } + return false; +} + +static void +check_tooltip_activation(bool skillActivated) +{ + static bool artifactTooltipShown = false; Settings *settings = settings_get(); - if (skillActivated && settings->tooltips_enabled && playerLevel < 5) { + if (skillActivated && settings->tooltips_enabled) { gGui->activeTooltip = new_skill_tooltip; } if (!artifactTooltipShown && gPlayer->equipment.hasArtifacts) { @@ -743,6 +742,20 @@ run_game_update(void) if (settings->tooltips_enabled) gGui->activeTooltip = new_artifact_tooltip; } +} + +static void +run_game_update(void) +{ + static UpdateData updateData; + + if (gGameState == IN_GAME_MENU) + menu_update(inGameMenu, &input); + + populateUpdateData(&updateData, deltaTime); + + bool skillActivated = check_skillbar_activation(); + check_tooltip_activation(skillActivated); if (gGameState == PLAYING && currentTurn == PLAYER) player_update(&updateData);