Skip to content

Code cleanup: Simplified cutscene text rendering #1639

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

Merged
merged 1 commit into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
48 changes: 0 additions & 48 deletions src/object/cutscene_info.cpp

This file was deleted.

47 changes: 0 additions & 47 deletions src/object/cutscene_info.hpp

This file was deleted.

2 changes: 0 additions & 2 deletions src/supertux/colorscheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include "supertux/colorscheme.hpp"

#include "object/cutscene_info.hpp"
#include "editor/overlay_widget.hpp"
#include "interface/control.hpp"
#include "object/floating_text.hpp"
Expand Down Expand Up @@ -50,7 +49,6 @@ Color PlayerStatusHUD::text_color(1.f,1.f,0.6f);
Color TextObject::default_color(1.f,1.f,1.f);

Color FloatingText::text_color(1.f,1.f,0.6f);
Color CutsceneInfo::text_color(1.f,1.f,0.6f);

Color LevelTime::text_color(1.f,1.f,0.6f);

Expand Down
29 changes: 0 additions & 29 deletions src/supertux/game_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,35 +353,6 @@ GameSession::update(float dt_sec, const Controller& controller)
// design choice, if you prefer it not to animate when paused, add `if (!m_game_pause)`)
m_level->m_stats.update_timers(dt_sec);

// FIXME: I (Semphris) am responsible for this awful code. I have no idea why I originally did it
// that way. I suppose it was back in the time when I didn't understand the engine very well (3
// months prior to writing this - thanks git). I'm going to remove all of this (and the useless
// CutsceneInfo object) sometime soon and use the damn draw function like a normal programmer
// would do - if I somehow forget, please remind me or do it for me.
if (m_level->m_is_in_cutscene && !m_level->m_skip_cutscene && m_current_cutscene_text == nullptr)
{
/*std::string cutscene_text = _("Press escape to skip");
FloatingText* text = new FloatingText(
// *(new Vector(32, 32)),
m_currentsector->get_camera().get_translation() + *(new Vector(cutscene_text.size() * 8 + 32, 32)),
cutscene_text
);

m_currentsector->add_object(std::unique_ptr<GameObject> (text));*/

//m_current_cutscene_text = std::unique_ptr<GameObject> (cutscene_text);


}
else if ((!m_level->m_is_in_cutscene || m_level->m_skip_cutscene) && m_current_cutscene_text != nullptr)
{
printf("Before\n");
/*try {
m_current_cutscene_text->remove_me();
} catch(...) {}*/
printf("After\n");
}

process_events();

// Unpause the game if the menu has been closed
Expand Down
16 changes: 12 additions & 4 deletions src/supertux/sector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "object/background.hpp"
#include "object/bullet.hpp"
#include "object/camera.hpp"
#include "object/cutscene_info.hpp"
#include "object/display_effect.hpp"
#include "object/gradient.hpp"
#include "object/music_object.hpp"
Expand All @@ -46,12 +45,14 @@
#include "physfs/ifile_stream.hpp"
#include "scripting/sector.hpp"
#include "squirrel/squirrel_environment.hpp"
#include "supertux/colorscheme.hpp"
#include "supertux/constants.hpp"
#include "supertux/debug.hpp"
#include "supertux/game_object_factory.hpp"
#include "supertux/game_session.hpp"
#include "supertux/level.hpp"
#include "supertux/player_status_hud.hpp"
#include "supertux/resources.hpp"
#include "supertux/savegame.hpp"
#include "supertux/tile.hpp"
#include "util/file_system.hpp"
Expand Down Expand Up @@ -159,9 +160,6 @@ Sector::finish_construction(bool editable)

flush_game_objects();

auto cutscene_text = new CutsceneInfo(get_camera(), _("Press escape to skip"), m_level);
add_object(std::unique_ptr<GameObject> (cutscene_text));

m_fully_constructed = true;
}

Expand Down Expand Up @@ -400,6 +398,16 @@ Sector::draw(DrawingContext& context)
}

context.pop_transform();

if (m_level.m_is_in_cutscene && !m_level.m_skip_cutscene)
{
context.color().draw_text(Resources::normal_font,
_("Press escape to skip"),
Vector(32.f, 32.f),
ALIGN_LEFT,
LAYER_OBJECTS + 1000,
ColorScheme::Text::heading_color);
}
}

bool
Expand Down