Skip to content

Commit

Permalink
Add level downloading through ID
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGreatRambler committed Dec 23, 2021
1 parent 441bba2 commit a169580
Show file tree
Hide file tree
Showing 70 changed files with 2,038 additions and 2,473 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ temp.bcd
test*
*.png
tilesheetFiles.txt
third_party
third_party
*.txt
*.bcd
*.zip
13 changes: 6 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ CPPFLAGS := -Wall -Wextra -Wno-missing-field-initializers -Wno-deprecated-enum-e

ifeq ($(BUILD),release)
# "Release" build - optimization, and no debug symbols
CPPFLAGS += -O3 -s -DNDEBUG
CPPFLAGS += -O3 -s
else
# "Debug" build - no optimization, and debugging symbols
ifeq ($(PLATFORM),web)
CPPFLAGS += -O0 -g -DDEBUG
CPPFLAGS += -O0 -g
else
CPPFLAGS += -Og -g -ggdb -DDEBUG
CPPFLAGS += -Og -g -ggdb
endif
endif

Expand All @@ -34,13 +34,12 @@ ifeq ($(PLATFORM),web)

EMS += -s USE_SDL=2 -s USE_ZLIB=1 -s USE_FREETYPE=1 -s USE_LIBPNG=1 -s DISABLE_EXCEPTION_CATCHING=1
CPPFLAGS += -I./third_party/cairo-1.16.0/src -O2 $(EMS)
LDFLAGS += -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=0 -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_STACK=10000000 -s ASYNCIFY -s FORCE_FILESYSTEM=1 -o bin/index.html --shell-file shell_minimal.html $(PRELOADED_FILES) $(EMS) -L./third_party/cairo-1.16.0/src/.libs -lcairo -L./third_party/pixman-0.40.0/pixman/.libs -lpixman-1
LDFLAGS += -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=0 -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_STACK=10000000 -s ASYNCIFY -s FETCH=1 -s FORCE_FILESYSTEM=1 -o bin/index.html --shell-file shell_minimal.html $(PRELOADED_FILES) $(EMS) -L./third_party/cairo-1.16.0/src/.libs -lcairo -L./third_party/pixman-0.40.0/pixman/.libs -lpixman-1
else
CPPFLAGS += $(shell pkg-config --cflags sdl2 glew glfw3 zlib cairo freetype2) -Wno-cast-function-type
LDFLAGS := -lpthread -lopengl32 $(shell pkg-config --libs --static sdl2 glew glfw3 zlib cairo freetype2) -liconv -mconsole -fPIC -static -static-libgcc -static-libstdc++
CPPFLAGS += $(shell pkg-config --cflags sdl2 glew glfw3 zlib cairo freetype2 libcurl) -Wno-cast-function-type
LDFLAGS := -lpthread -lopengl32 $(shell pkg-config --libs --static sdl2 glew glfw3 zlib cairo freetype2 libcurl) -lunistring -liconv -lbrotlicommon -mconsole -fPIC -static -static-libgcc -static-libstdc++

ifeq ($(UNAME),Msys)
# Needed for sockets on windows
LDFLAGS += -lmingw32 -lws2_32 -lwsock32
else
LDFLAGS += -ldl
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# toost
# Toost

Level viewer for Super Mario Maker 2, based on JiXiaomai's work

# How to build
If building for desktop, obtain development files for `sdl2`, `glew`, `glfw3`, `zlib`, `cairo`, `freetype2`, and `libcurl`, as well as having an up to date GCC and pkg-config. Compilation on Windows should use MSYS2, on Mac should use homebrew and on linux should use standard GCC. Type `make` for a debug build and `make BUILD=release` for a release build.
If building for web, first obtain a working Emscripten build environment and put its binaries on the path, such as `emmake`, `emcc` and `em++`. Next, run `./prepare_web_deps.sh`. This only needs to be done once, as it downloads and compiles Cairo to prepare it for the web environment. Once that is done, you can run `make PLATFORM=web` for a debug build and `make PLATFORM=web BUILD=release` for a release build. To prepare a zip to distribute, run `./build_release.sh` for desktop and `./build_release.sh web` for web.

# Hosting the web build
As long as all files in `bin` are in the same directory on your webserver and you are hosting them over https, you can access index.html to see the viewer.

# Credits
* Ji Xiaomai, as the core level renderer is based on his work
* The Spriters Resource for the sprites
11 changes: 11 additions & 0 deletions build_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
make clean
if [[ "$1" == "web" ]];
then
make PLATFORM=web BUILD=release
rm -rf bin/src
zip -9r build_web.zip bin
else
make BUILD=release
rm -rf bin/src
zip -9r build.zip bin fonts img
fi
Binary file added fonts/NotoSansJP-Bold.otf
Binary file not shown.
Binary file removed fonts/unifont-14.0.01.ttf
Binary file not shown.
Binary file modified img/CMN/A0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/CMN/A1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/CMN/A2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/CMN/A3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/CMN/B.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/CMN/B0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/CMN/B1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/CMN/C0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/CMN/C1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/CMN/C2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/CMN/C3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/CMN/C4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/CMN/C5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/CMN/C6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/CMN/C7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/CMN/C8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/CMN/C9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/CMN/D0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/CMN/D1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/CMN/D2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/CMN/D3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/CMN/E0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/CMN/E1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/CMN/E2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/CMN/E3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/CMN/F0.png
Binary file modified img/CMN/F1.png
Binary file modified img/CMN/G0.png
Binary file modified img/CMN/JA.png
Binary file modified img/CMN/JB.png
Binary file modified img/CMN/JC.png
Binary file modified img/CMN/JD.png
Binary file modified img/CMN/JE.png
Binary file modified img/CMN/JF.png
Binary file modified img/CMN/JG.png
Binary file modified img/CMN/JH.png
Binary file modified img/CMN/JJ.png
Binary file modified img/CMN/JK.png
Binary file modified img/CMN/JM.png
Binary file modified img/CMN/JP.png
Binary file modified img/CMN/JW.png
Binary file modified img/CMN/M.png
Binary file modified img/CMN/P.png
Binary file modified img/CMN/SD.png
Binary file modified img/CMN/SDL.png
Binary file modified img/CMN/SDR.png
Binary file modified img/CMN/SE.png
Binary file modified img/CMN/SL.png
Binary file modified img/CMN/SLD.png
Binary file modified img/CMN/SLU.png
Binary file modified img/CMN/SR.png
Binary file modified img/CMN/SRD.png
Binary file modified img/CMN/SRU.png
Binary file modified img/CMN/SS.png
Binary file modified img/CMN/SU.png
Binary file modified img/CMN/SUL.png
Binary file modified img/CMN/SUR.png
Binary file modified img/CMN/W.png
8 changes: 8 additions & 0 deletions build_web.sh → prepare_web_deps.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
mkdir third_party
wget -c https://www.cairographics.org/releases/cairo-1.16.0.tar.xz
C:/msys64/usr/bin/tar.exe -xvf cairo-1.16.0.tar.xz -C third_party
rm cairo-1.16.0.tar.xz
wget -c https://www.cairographics.org/releases/pixman-0.40.0.tar.gz
C:/msys64/usr/bin/tar.exe -xvf pixman-0.40.0.tar.gz -C third_party
rm pixman-0.40.0.tar.gz

cd third_party/pixman-0.40.0
CC=emcc AR=emar LD=emcc RANLIB=emranlib PNG_LIBS="-L." ./configure --host=wasm32-unknown-emscripten --disable-gtk --enable-libpng --disable-shared --disable-openmp
export EMCC_CFLAGS="-s USE_PTHREADS=1 -s USE_LIBPNG=1 -s USE_ZLIB=1"
Expand Down
4 changes: 2 additions & 2 deletions src/Drawers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4032,7 +4032,7 @@ void Drawers::DrawCID() {
}
} else {
if((level.MapObj[i].CFlag / 0x40000) % 2 == 1) {
DrawImage(fmt::format("{}/img/{}/cid/{]B.png", P, level.LH.GameStyle, level.MapObj[i].CID), LX, LY,
DrawImage(fmt::format("{}/img/{}/cid/{}B.png", P, level.LH.GameStyle, level.MapObj[i].CID), LX, LY,
Zm, Zm);
} else {
DrawImage(fmt::format("{}/img/{}/cid/{}.png", P, level.LH.GameStyle, level.MapObj[i].CID), LX, LY,
Expand Down Expand Up @@ -4083,7 +4083,7 @@ void Drawers::DrawCID() {
default:
if((level.MapObj[i].CFlag / 0x4) % 2 == 1) {
DrawImage(
fmt::format("{}/img/{}/cid/{]A.png", P, level.LH.GameStyle, level.MapObj[i].CID), LX, LY, Zm, Zm);
fmt::format("{}/img/{}/cid/{}A.png", P, level.LH.GameStyle, level.MapObj[i].CID), LX, LY, Zm, Zm);
} else {
DrawImage(
fmt::format("{}/img/{}/cid/{}.png", P, level.LH.GameStyle, level.MapObj[i].CID), LX, LY, Zm, Zm);
Expand Down
13 changes: 13 additions & 0 deletions src/Helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ bool Helpers::LoadTextureFromSurface(cairo_surface_t* surface, GLuint* out_textu
if(image_data == NULL)
return false;

/*
cairo_pattern_t* pattern = cairo_pattern_create_for_surface(surface);
cairo_pattern_set_filter(pattern, CAIRO_FILTER_NEAREST);
int new_width = image_width * scale;
int new_height = image_width * scale;
cairo_surface_t* new_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, new_width, new_height);
cairo_t* cr = cairo_create(new_surface);
cairo_scale(cr, scale, scale);
cairo_set_source(cr, pattern);
cairo_paint(cr);
cairo_pattern_destroy(pattern);
*/

int image_data_pixels = image_width * image_height;
// Need to convert from cairo ARGB to OpenGL RGBA
uint32_t* fixed_image_data = (uint32_t*)malloc(image_data_pixels * 4);
Expand Down
12 changes: 7 additions & 5 deletions src/LevelParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,11 +550,13 @@ class LevelParserMappings {
{ 3, "x3" },
};

const std::string FormatMillisecondTime(int milliseconds) {
int seconds = (milliseconds / 1000) % 60;
int minutes = (milliseconds / 1000) / 60;
milliseconds = milliseconds % 1000;
std::string time = fmt::format("{:02}:{:02}.{:03}", minutes, seconds, milliseconds);
const std::string FormatMillisecondTime(int32_t milliseconds) {
int32_t seconds = (milliseconds / 1000) % 60;
int32_t minutes = (milliseconds / 1000) / 60;
milliseconds = milliseconds % 1000;
// Corrupts the string on emscripten
// std::string time = fmt::format("{:02}:{:02}.{:03}", minutes, seconds, milliseconds);
std::string time = fmt::format("{}:{:02}.{}", minutes, seconds, milliseconds);
return time;
}
};
Expand Down
Loading

0 comments on commit a169580

Please sign in to comment.