Skip to content

Commit eca6a3b

Browse files
authored
Merge branch 'master' into textbox-fix
2 parents 7a24c82 + 0914fe0 commit eca6a3b

File tree

12 files changed

+219
-23
lines changed

12 files changed

+219
-23
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ target_link_libraries(supertux2 supertux2_lib Boost::filesystem Boost::locale)
930930
set_target_properties(supertux2_lib PROPERTIES OUTPUT_NAME supertux2_lib)
931931
set_target_properties(supertux2_lib PROPERTIES COMPILE_FLAGS "${SUPERTUX2_EXTRA_WARNING_FLAGS}")
932932
if(EMSCRIPTEN)
933-
target_link_options(supertux2 PUBLIC -sEXPORTED_FUNCTIONS=['_main','_set_resolution','_save_config','_onDownloadProgress','_onDownloadFinished','_onDownloadError','_onDownloadAborted'] PUBLIC -sEXPORTED_RUNTIME_METHODS=['ccall','cwrap'] PUBLIC -sEXTRA_EXPORTED_RUNTIME_METHODS=['ccall','cwrap'])
933+
target_link_options(supertux2 PUBLIC -sEXPORTED_FUNCTIONS=['_main','_set_resolution','_save_config','_onDownloadProgress','_onDownloadFinished','_onDownloadError','_onDownloadAborted','_getExceptionMessage'] PUBLIC -sEXPORTED_RUNTIME_METHODS=['ccall','cwrap'] PUBLIC -sEXTRA_EXPORTED_RUNTIME_METHODS=['ccall','cwrap'])
934934
endif(EMSCRIPTEN)
935935

936936
if(WIN32 AND NOT VCPKG_BUILD)

data/levels/bonus2/level17.stl

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@
44
(author "Marek Moeckel")
55
(license "GPL 2+ / CC-by-sa 3.0")
66
(target-time 55)
7+
(icon "")
8+
(icon-locked "")
79
(sector
810
(name "main")
911
(ambient-light
1012
(color 1 1 1)
1113
)
1214
(background
13-
(scroll-offset-y 345)
1415
(color 1 1 1)
15-
(x 11776)
16-
(y 832)
17-
(alignment "top")
16+
(alignment "bottom")
1817
(scroll-speed-x 0.5)
1918
(scroll-speed-y 0.5)
2019
(speed 0.5)
@@ -24,10 +23,8 @@
2423
(z-pos -290)
2524
)
2625
(background
27-
(scroll-offset-y -265)
26+
(scroll-offset-y -10)
2827
(color 1 1 1)
29-
(x 12288)
30-
(y 800)
3128
(alignment "top")
3229
(scroll-speed-x 0.5)
3330
(scroll-speed-y 0.5)
@@ -208,6 +205,7 @@
208205
(path
209206
(name "c1c8f4db-1cbf-46bf-b0b1-96a47db6910c")
210207
(path
208+
(adapt_speed #f)
211209
(node
212210
(x 2272)
213211
(y 512)
@@ -217,6 +215,7 @@
217215
(path
218216
(name "2a08bac6-b9f3-478c-ba9f-ff946cd7235b")
219217
(path
218+
(adapt_speed #f)
220219
(node
221220
(x 4704)
222221
(y 608)
@@ -226,6 +225,7 @@
226225
(path
227226
(name "736a59ab-bd63-4bec-b6fd-6c0beddf20db")
228227
(path
228+
(adapt_speed #f)
229229
(node
230230
(x 10688)
231231
(y 544)
@@ -235,6 +235,7 @@
235235
(path
236236
(name "d895a7d0-d5b3-46d8-980f-46d22e280c6d")
237237
(path
238+
(adapt_speed #f)
238239
(node
239240
(x 12544)
240241
(y 448)
@@ -377,6 +378,9 @@
377378
(x 10030)
378379
(y 425)
379380
)
381+
(textobject
382+
(name "Text")
383+
)
380384
(tilemap
381385
(solid #f)
382386
(z-pos -100)
@@ -466,6 +470,12 @@
466470
)
467471
)
468472
(tilemap
473+
(handle
474+
(scale_x 0)
475+
(scale_y 0)
476+
(offset_x 0)
477+
(offset_y 0)
478+
)
469479
(solid #f)
470480
(z-pos 100)
471481
(name "s1")
@@ -481,6 +491,12 @@
481491
)
482492
)
483493
(tilemap
494+
(handle
495+
(scale_x 0)
496+
(scale_y 0)
497+
(offset_x 0)
498+
(offset_y 0)
499+
)
484500
(solid #f)
485501
(z-pos 100)
486502
(name "s2")
@@ -496,6 +512,12 @@
496512
)
497513
)
498514
(tilemap
515+
(handle
516+
(scale_x 0)
517+
(scale_y 0)
518+
(offset_x 0)
519+
(offset_y 0)
520+
)
499521
(solid #f)
500522
(z-pos 100)
501523
(name "s3")
@@ -513,6 +535,12 @@
513535
)
514536
)
515537
(tilemap
538+
(handle
539+
(scale_x 0)
540+
(scale_y 0)
541+
(offset_x 0)
542+
(offset_y 0)
543+
)
516544
(solid #f)
517545
(z-pos 0)
518546
(name "frgrd")

data/levels/bonus2/level2.stl

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
(author "Kevin")
55
(license "GPL 2+ / CC-by-sa 3.0")
66
(target-time 350)
7+
(icon "")
8+
(icon-locked "")
79
(sector
810
(name "main")
911
(ambient-light
@@ -18,8 +20,6 @@
1820
)
1921
(background
2022
(color 1 1 1)
21-
(x 736)
22-
(y 448)
2323
(scroll-speed-x 0.5)
2424
(scroll-speed-y 0.5)
2525
(speed 0.5)
@@ -30,8 +30,6 @@
3030
)
3131
(background
3232
(color 1 1 1)
33-
(x 832)
34-
(y 416)
3533
(scroll-speed-x 0.5)
3634
(scroll-speed-y 0.5)
3735
(speed 0.5)
@@ -80,6 +78,12 @@
8078
(name "Camera")
8179
(mode "autoscroll")
8280
(path-ref "4fecb608-cc73-4761-9b95-0f2ed114a61a")
81+
(handle
82+
(scale_x 0)
83+
(scale_y 0)
84+
(offset_x 0)
85+
(offset_y 0)
86+
)
8387
)
8488
(coin
8589
(x 2080)
@@ -642,19 +646,11 @@
642646
(node
643647
(x 0)
644648
(y 0)
645-
(bezier_before_x 0)
646-
(bezier_before_y 0)
647-
(bezier_after_x 0)
648-
(bezier_after_y 0)
649649
(time 250)
650650
)
651651
(node
652652
(x 22848)
653653
(y 0)
654-
(bezier_before_x 22848)
655-
(bezier_before_y 0)
656-
(bezier_after_x 22848)
657-
(bezier_after_y 0)
658654
)
659655
)
660656
)
@@ -898,6 +894,9 @@
898894
(x 20994)
899895
(y 255)
900896
)
897+
(textobject
898+
(name "Text")
899+
)
901900
(tilemap
902901
(solid #f)
903902
(z-pos -100)

mk/emscripten/template.html.in

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,10 @@
341341
};
342342

343343
Module.setStatus("Downloading...");
344-
window.onerror = function (e) {
345-
Module.setStatus("Oops!<br><br>An error occured and SuperTux crashed.<br><br><pre>" + e + "</pre>");
344+
window.onerror = function (message, source, line, col, error) {
345+
if (typeof error == "number")
346+
message = Module.ccall('getExceptionMessage', 'string', ['number'], [error]);
347+
Module.setStatus("Oops!<br><br>An error occured and SuperTux crashed.<br><br><pre>" + message + "</pre>");
346348
spinnerElement.style.display = "none";
347349
Module.setStatus = function (e) {
348350
if (e)

src/physfs/util.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,23 @@ bool remove(const std::string& filename)
6060
return PHYSFS_delete(filename.c_str()) == 0;
6161
}
6262

63+
void
64+
remove_with_content(const std::string& filename)
65+
{
66+
char** files = PHYSFS_enumerateFiles(filename.c_str());
67+
68+
for (const char* const* file = files; *file != nullptr; file++)
69+
{
70+
std::string path = FileSystem::join(filename, *file);
71+
if (is_directory(path))
72+
remove_with_content(path);
73+
PHYSFS_delete(path.c_str());
74+
}
75+
76+
PHYSFS_delete(filename.c_str());
77+
PHYSFS_freeList(files);
78+
}
79+
6380
} // namespace physfsutil
6481

6582
/* EOF */

src/physfs/util.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ bool is_directory(const std::string& path);
3131

3232
bool remove(const std::string& filenam);
3333

34+
/** Removes directory with content */
35+
void remove_with_content(const std::string& filename);
36+
3437
} // namespace physfsutil
3538

3639
#endif

src/port/emscripten.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

1717
// Export functions for emscripten
18+
// If you add functions here, make sure to make CMakeLists.txt export them!
1819
#ifdef __EMSCRIPTEN__
1920

2021
#include <emscripten.h>
@@ -35,6 +36,7 @@ void onDownloadProgress(int id, int loaded, int total);
3536
void onDownloadFinished(int id);
3637
void onDownloadError(int id);
3738
void onDownloadAborted(int id);
39+
const char* getExceptionMessage(intptr_t address);
3840

3941
EMSCRIPTEN_KEEPALIVE // This is probably not useful, I just want ppl to know it exists
4042
void
@@ -75,6 +77,12 @@ onDownloadAborted(int id)
7577
AddonManager::current()->onDownloadAborted(id);
7678
}
7779

80+
const char*
81+
getExceptionMessage(intptr_t address)
82+
{
83+
return reinterpret_cast<std::exception*>(address)->what();
84+
}
85+
7886
} // extern "C"
7987

8088
void
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// SuperTux
2+
// Copyright (C) 2021 mrkubax10 <[email protected]>
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
#include "supertux/menu/editor_delete_levelset_menu.hpp"
18+
19+
#include "editor/editor.hpp"
20+
#include "gui/dialog.hpp"
21+
#include "physfs/util.hpp"
22+
#include "supertux/menu/editor_levelset_select_menu.hpp"
23+
#include "supertux/world.hpp"
24+
#include "util/gettext.hpp"
25+
#include "util/log.hpp"
26+
27+
EditorDeleteLevelsetMenu::EditorDeleteLevelsetMenu(EditorLevelsetSelectMenu* editor_levelset_select_menu) :
28+
m_editor_levelset_select_menu(editor_levelset_select_menu)
29+
{
30+
refresh();
31+
}
32+
33+
void
34+
EditorDeleteLevelsetMenu::refresh()
35+
{
36+
clear();
37+
38+
add_label(_("Delete World"));
39+
add_hl();
40+
41+
unsigned int i = 0;
42+
std::vector<std::string>& contrib_worlds = m_editor_levelset_select_menu->get_contrib_worlds();
43+
for(std::string& level_world : contrib_worlds)
44+
{
45+
std::unique_ptr<World> world = World::from_directory(level_world);
46+
if (world->hide_from_contribs())
47+
{
48+
continue;
49+
}
50+
if (!world->is_levelset() && !world->is_worldmap())
51+
{
52+
log_warning << level_world << ": unknown World type" << std::endl;
53+
continue;
54+
}
55+
auto title = world->get_title();
56+
if (title.empty())
57+
{
58+
continue;
59+
}
60+
add_entry(i++, title);
61+
}
62+
63+
add_hl();
64+
65+
add_back(_("Back"));
66+
}
67+
68+
void
69+
EditorDeleteLevelsetMenu::menu_action(MenuItem& item)
70+
{
71+
int id = item.get_id();
72+
73+
if (id >= 0)
74+
{
75+
std::vector<std::string>& contrib_worlds = m_editor_levelset_select_menu->get_contrib_worlds();
76+
if (Editor::is_active() && Editor::current()->get_world() && Editor::current()->get_world()->get_basedir() == contrib_worlds[id])
77+
Dialog::show_message(_("You cannot delete the world that you are editing"));
78+
else
79+
{
80+
physfsutil::remove_with_content(contrib_worlds[id]);
81+
m_editor_levelset_select_menu->reload_menu();
82+
refresh();
83+
}
84+
}
85+
}
86+
87+
/* EOF */

0 commit comments

Comments
 (0)