Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/SuperTux/supertux into re…
Browse files Browse the repository at this point in the history
…al-master
  • Loading branch information
MatusGuy committed Oct 5, 2024
2 parents eee7139 + 0fbe136 commit 42f9c2a
Show file tree
Hide file tree
Showing 13 changed files with 300 additions and 150 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/gnulinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ jobs:
doxygen docs/Doxyfile
- name: Package
if: ${{ matrix.arch != '32' }}
if: matrix.arch != '32'
env:
OS_NAME: ${{ matrix.os }}
ARCH: ${{ matrix.arch }} # TODO: Working Linux 32-bit packaging
Expand All @@ -224,6 +224,7 @@ jobs:
run: ../.ci_scripts/package.sh

- name: Upload AppImage
if: matrix.build_type != 'Debug' && matrix.glbinding == 'OFF'
uses: actions/upload-artifact@v4
with:
name: "${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.compiler }}-${{ matrix.build_type }}${{ matrix.glbinding == 'ON' && '-glbinding' || '' }}-appimage"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ jobs:
run: ../.ci_scripts/package.sh

- uses: actions/upload-artifact@v4
if: matrix.build_type != 'Debug' && matrix.glbinding == 'OFF'
with:
name: "${{ matrix.os }}-${{ matrix.build_type }}${{ matrix.glbinding == 'ON' && '-glbinding' || '' }}-dmg"
path: build/upload/*.dmg
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ubuntu-touch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ jobs:
~/.local/bin/clickable build --verbose ${BUILD_TYPE} --arch ${ARCH}
- uses: actions/upload-artifact@v4
if: matrix.build_type != 'Debug'
with:
name: "clickable-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.opengl }}-click"
path: build.clickable/*.click
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ jobs:
mv supertux2* upload/
- uses: actions/upload-artifact@v4
if: matrix.build_type != 'Debug'
with:
name: "wasm32-emscripten-${{ matrix.build_type }}-html"
path: build/upload/*
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ jobs:
"./$Env:BUILD_TYPE/run_tests.exe"
- name: Package MSI Installer
if: matrix.build_type != 'Debug' && matrix.glbinding == 'OFF'
shell: pwsh
working-directory: build
env:
Expand Down Expand Up @@ -148,6 +149,7 @@ jobs:
#>
- name: Upload Portable Package
if: matrix.build_type != 'Debug' && matrix.glbinding == 'OFF'
uses: actions/upload-artifact@v4
with:
name: "windows-${{ matrix.arch }}-${{ matrix.build_type }}${{ matrix.glbinding == 'ON' && '-glbinding' || '' }}-portable"
Expand Down
11 changes: 9 additions & 2 deletions src/supertux/level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ Level::~Level()
}

void
Level::initialize()
Level::initialize(const Statistics::Preferences& stat_preferences)
{
if (m_sectors.empty())
throw std::runtime_error("Level has no sectors!");

m_stats.init(*this);
m_stats.init(*this, stat_preferences);

Savegame* savegame = (GameSession::current() && !Editor::current() ?
&GameSession::current()->get_savegame() : nullptr);
Expand Down Expand Up @@ -195,6 +195,13 @@ Level::save(Writer& writer)
if (!m_wmselect_bkg.empty())
writer.write("bkg", m_wmselect_bkg);

if (!m_is_worldmap)
{
writer.start_list("statistics");
m_stats.get_preferences().write(writer);
writer.end_list("statistics");
}

for (auto& sector : m_sectors) {
sector->save(writer);
}
Expand Down
2 changes: 1 addition & 1 deletion src/supertux/level.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Level final
const std::string& get_license() const { return m_license; }

private:
void initialize();
void initialize(const Statistics::Preferences& stat_preferences);

void save(Writer& writer);
void load_old_format(const ReaderMapping& reader);
Expand Down
20 changes: 14 additions & 6 deletions src/supertux/level_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,17 @@ LevelParser::load(const ReaderDocument& doc)
throw std::runtime_error("file is not a supertux-level file.");

auto level = root.get_mapping();
Statistics::Preferences stat_preferences;

int version = 1;
level.get("version", version);
if (version == 1) {
if (version == 1)
{
log_info << "[" << doc.get_filename() << "] level uses old format: version 1" << std::endl;
load_old_format(level);
} else if (version == 2 || version == 3) {
}
else if (version == 2 || version == 3)
{
level.get("tileset", m_level.m_tileset);

level.get("name", m_level.m_name);
Expand All @@ -173,6 +177,10 @@ LevelParser::load(const ReaderDocument& doc)
level.get("icon-locked", m_level.m_icon_locked);
level.get("bkg", m_level.m_wmselect_bkg);

std::optional<ReaderMapping> level_stat_preferences;
if (level.get("statistics", level_stat_preferences))
stat_preferences.parse(*level_stat_preferences);

auto iter = level.get_iter();
while (iter.next())
{
Expand All @@ -189,11 +197,13 @@ LevelParser::load(const ReaderDocument& doc)
<< m_level.m_name << "\". You might not be allowed to share it."
<< std::endl;
}
} else {
}
else
{
log_warning << "[" << doc.get_filename() << "] level format version " << version << " is not supported" << std::endl;
}

m_level.initialize();
m_level.initialize(stat_preferences);
}

void
Expand All @@ -204,8 +214,6 @@ LevelParser::load_old_format(const ReaderMapping& reader)

auto sector = SectorParser::from_reader_old_format(m_level, reader, m_editable);
m_level.add_sector(std::move(sector));

m_level.initialize();
}

void
Expand Down
28 changes: 19 additions & 9 deletions src/supertux/levelintro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,25 @@ LevelIntro::draw(Compositor& compositor)

py += static_cast<int>(Resources::normal_font->get_height());

draw_stats_line(context, py, _("Coins"),
Statistics::coins_to_string(m_best_level_statistics->get_coins(), stats.m_total_coins),
m_best_level_statistics->get_coins() >= stats.m_total_coins);
draw_stats_line(context, py, _("Badguys killed"),
Statistics::frags_to_string(m_best_level_statistics->get_badguys(), stats.m_total_badguys),
m_best_level_statistics->get_badguys() >= stats.m_total_badguys);
draw_stats_line(context, py, _("Secrets"),
Statistics::secrets_to_string(m_best_level_statistics->get_secrets(), stats.m_total_secrets),
m_best_level_statistics->get_secrets() >= stats.m_total_secrets);
const Statistics::Preferences& preferences = m_level.m_stats.get_preferences();
if (preferences.enable_coins)
{
draw_stats_line(context, py, _("Coins"),
Statistics::coins_to_string(m_best_level_statistics->get_coins(), stats.m_total_coins),
m_best_level_statistics->get_coins() >= stats.m_total_coins);
}
if (preferences.enable_badguys)
{
draw_stats_line(context, py, _("Badguys killed"),
Statistics::frags_to_string(m_best_level_statistics->get_badguys(), stats.m_total_badguys),
m_best_level_statistics->get_badguys() >= stats.m_total_badguys);
}
if (preferences.enable_secrets)
{
draw_stats_line(context, py, _("Secrets"),
Statistics::secrets_to_string(m_best_level_statistics->get_secrets(), stats.m_total_secrets),
m_best_level_statistics->get_secrets() >= stats.m_total_secrets);
}

bool targetTimeBeaten = m_level.m_target_time == 0.0f || (m_best_level_statistics->get_time() != 0.0f && m_best_level_statistics->get_time() < m_level.m_target_time);
draw_stats_line(context, py, _("Best time"),
Expand Down
6 changes: 5 additions & 1 deletion src/supertux/menu/editor_level_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ EditorLevelMenu::EditorLevelMenu() :
add_textfield(_("Level Note"), &(level->m_note));
add_file(_("Tileset"), &(level->m_tileset), std::vector<std::string>(1, ".strf"), {}, true);

if (!is_worldmap) {
if (!is_worldmap)
{
add_floatfield(_("Target Time"), &(level->m_target_time));

add_hl();
level->m_stats.add_preferences_to_menu(*this);
}

add_hl();
Expand Down
Loading

0 comments on commit 42f9c2a

Please sign in to comment.