From 2bb6119c346f0a7c9ad174c164909915f1e5b12d Mon Sep 17 00:00:00 2001 From: nobbele Date: Tue, 12 Aug 2025 21:43:42 +0200 Subject: [PATCH] MinGW build support on Linux --- .vscode/settings.json | 9 +++ CMakeLists.txt | 29 ++++++++ src/Core/ByteStream.h | 104 +++++++++++--------------- src/Core/Canvas.cpp | 2 +- src/Core/FontData.cpp | 4 +- src/Core/Renderer.cpp | 12 +-- src/Core/TextureImpl.cpp | 2 +- src/Editor/Butterworth.cpp | 1 + src/Editor/Editing.cpp | 3 +- src/Editor/Notefield.cpp | 8 +- src/Editor/NotefieldPreview.cpp | 8 +- src/Editor/Shortcuts.cpp | 4 +- src/Editor/Statusbar.cpp | 40 +++++----- src/Editor/View.cpp | 1 + src/Managers/TempoMan.cpp | 1 + src/Managers/TempoMan.h | 1 + src/Simfile/LoadOsu.cpp | 3 +- src/Simfile/LoadSm.cpp | 5 +- src/Simfile/NoteList.cpp | 5 +- src/Simfile/SaveOsu.cpp | 1 + src/Simfile/Segments.cpp | 125 ++++++++++++++------------------ src/Simfile/Segments.h | 2 + src/Simfile/Tempo.cpp | 2 +- src/System/ArrowVortex.rc | Bin 3274 -> 1542 bytes src/System/CMakeLists.txt | 22 +++++- src/System/Debug.cpp | 2 +- src/System/OpenGL.h | 2 +- src/System/System.cpp | 15 ++-- 28 files changed, 225 insertions(+), 188 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..67a5f32c --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "cmake.environment": { + "VCPKG_ROOT": "/home/nobbele/.local/share/vcpkg" + }, + "cmake.configureArgs": [ + "-DCMAKE_TOOLCHAIN_FILE=/home/nobbele/.local/share/vcpkg/scripts/buildsystems/vcpkg.cmake", + "-DVCPKG_TARGET_TRIPLET=x64-mingw-static" + ] +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f1f4007..597e7268 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,34 @@ cmake_minimum_required(VERSION 3.30) +# Find VCPKG_ROOT from environment variables. +if (DEFINED ENV{VCPKG_ROOT}) + set(VCPKG_ROOT ENV{VCPKG_ROOT}) +elseif(DEFINED ENV{VCPKG_INSTALLATION_ROOT}) + set(VCPKG_ROOT ENV{VCPKG_INSTALLATION_ROOT}) +endif() + +if (LINUX) + if (NOT DEFINED VCPKG_ROOT) + message(FATAL_ERROR "VCPKG_ROOT must be set to build on Linux, CMake will exit.") + endif() + + set(CMAKE_SYSTEM_NAME Windows) + + set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) + set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) + set(VCPKG_TARGET_TRIPLET x64-mingw-static) + + if (NOT DEFINED CMAKE_FIND_ROOT_PATH) + set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32) + endif() + + set(MINGW_BASED true) +endif() + +if(DEFINED VCPKG_ROOT) + set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "") +endif() + set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") set(CMAKE_CXX_STANDARD 20) diff --git a/src/Core/ByteStream.h b/src/Core/ByteStream.h index 3596a80c..5064a936 100644 --- a/src/Core/ByteStream.h +++ b/src/Core/ByteStream.h @@ -22,40 +22,29 @@ struct WriteStream void writeNum(uint32_t num); void writeStr(const std::string& str); - template - inline void writeSz(const void* val) - { - write(val, S); - } - - template <> - inline void writeSz<1>(const void* val) - { - write8(val); - } - - template <> - inline void writeSz<2>(const void* val) - { - write16(val); - } - - template <> - inline void writeSz<4>(const void* val) - { - write32(val); - } - - template <> - inline void writeSz<8>(const void* val) - { - write64(val); - } - template inline void write(const T& val) { - writeSz(&val); + switch (sizeof(T)) { + case 1: + write8(&val); + break; + + case 2: + write16(&val); + break; + + case 4: + write32(&val); + break; + + case 8: + write64(&val); + break; + + default: + write(&val, static_cast(sizeof(T))); + } } // Returns true if all write operations have succeeded. @@ -94,47 +83,36 @@ struct ReadStream void readNum(uint32_t& num); void readStr(std::string& str); - template - inline void readSz(void* out) - { - read(out, S); - } - - template <> - inline void readSz<1>(void* out) - { - read8(out); - } - - template <> - inline void readSz<2>(void* out) - { - read16(out); - } - - template <> - inline void readSz<4>(void* out) - { - read32(out); - } - - template <> - inline void readSz<8>(void* out) - { - read64(out); - } - template inline void read(T& out) { - readSz(&out); + switch (sizeof(T)) { + case 1: + read8(&out); + break; + + case 2: + read16(&out); + break; + + case 4: + read32(&out); + break; + + case 8: + read64(&out); + break; + + default: + read(&out, static_cast(sizeof(T))); + } } template inline T read() { T out = T(); - readSz(&out); + read(out); return out; } diff --git a/src/Core/Canvas.cpp b/src/Core/Canvas.cpp index c5f94b05..0c99eff2 100644 --- a/src/Core/Canvas.cpp +++ b/src/Core/Canvas.cpp @@ -156,7 +156,7 @@ struct GetPolyDist : public DistanceFunc struct Canvas::Data { - Canvas::Data(); + Data(); void draw(float* buf, int w, int h, const areaf& area, DistanceFunc* func); areai mask; diff --git a/src/Core/FontData.cpp b/src/Core/FontData.cpp index cdc30659..5ee69ea6 100644 --- a/src/Core/FontData.cpp +++ b/src/Core/FontData.cpp @@ -9,6 +9,8 @@ #include +#include + namespace Vortex { static const int PADDING = 1; @@ -217,7 +219,7 @@ static Glyph* PutGlyphInCache(GlyphCache* cache, FT_GlyphSlot slot) // Copy the glyph pixels to the cache texture. uint8_t* pixels = CopyGlyphBitmap(bitmapW, bitmapH, bitmap); cache->tex->modify(glyph->box.x, glyph->box.y, bitmapW, bitmapH, pixels); - cache->shelfH = max(cache->shelfH, bitmapH); + cache->shelfH = std::max(cache->shelfH, bitmapH); free(pixels); // Set the glyph uvs. diff --git a/src/Core/Renderer.cpp b/src/Core/Renderer.cpp index dce38768..0442bf0c 100644 --- a/src/Core/Renderer.cpp +++ b/src/Core/Renderer.cpp @@ -9,6 +9,8 @@ #include #include +#include + namespace Vortex { static const int BATCH_QUAD_LIMIT = 256; @@ -206,7 +208,7 @@ void Renderer::pushScissorRect(const recti& r) void Renderer::pushScissorRect(int x, int y, int w, int h) { auto& stack = RI->scissorStack; - w = max(w, 0), h = max(h, 0); + w = std::max(w, 0), h = std::max(h, 0); if(stack.empty()) { // The new scissor region is the first scissor region, use it as-is. @@ -217,10 +219,10 @@ void Renderer::pushScissorRect(int x, int y, int w, int h) { // Calculate the intersection of the current and new scissor region. recti last = stack.back(); - int r = min(last.x + last.w, x + w); - int b = min(last.y + last.h, y + h); - x = max(last.x, x), w = max(0, r - x); - y = max(last.y, y), h = max(0, b - y); + int r = std::min(last.x + last.w, x + w); + int b = std::min(last.y + last.h, y + h); + x = std::max(last.x, x), w = std::max(0, r - x); + y = std::max(last.y, y), h = std::max(0, b - y); stack.push_back({x, y, w, h}); } diff --git a/src/Core/TextureImpl.cpp b/src/Core/TextureImpl.cpp index a7404cd3..07a139c2 100644 --- a/src/Core/TextureImpl.cpp +++ b/src/Core/TextureImpl.cpp @@ -14,7 +14,7 @@ #define WIN32_LEAN_AND_MEAN #include "windows.h" -#include "gl/gl.h" +#include "GL/gl.h" namespace Vortex { namespace { diff --git a/src/Editor/Butterworth.cpp b/src/Editor/Butterworth.cpp index 3774676e..d14d232b 100644 --- a/src/Editor/Butterworth.cpp +++ b/src/Editor/Butterworth.cpp @@ -46,6 +46,7 @@ #include +#undef M_PI #define M_PI 3.14159265358 static double* binomial_mult(int n, double *p); diff --git a/src/Editor/Editing.cpp b/src/Editor/Editing.cpp index 41075853..4407e2cc 100644 --- a/src/Editor/Editing.cpp +++ b/src/Editor/Editing.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -370,7 +371,7 @@ void finishNotePlacement(int col) if (note.quant > 0 && note.quant <= 192) { - note.quant = min(192u, note.quant * gView->getSnapQuant() / gcd(note.quant, gView->getSnapQuant())); + note.quant = min(192, note.quant * gView->getSnapQuant() / gcd(note.quant, gView->getSnapQuant())); } else { diff --git a/src/Editor/Notefield.cpp b/src/Editor/Notefield.cpp index 7236761f..a317d05f 100644 --- a/src/Editor/Notefield.cpp +++ b/src/Editor/Notefield.cpp @@ -795,25 +795,25 @@ void drawSongPreviewArea() // ================================================================================================ // NotefieldImpl :: toggle/check functions. -void NotefieldImpl::toggleShowWaveform() +void toggleShowWaveform() { myShowWaveform = !myShowWaveform; gMenubar->update(Menubar::SHOW_WAVEFORM); } -void NotefieldImpl::toggleShowBeatLines() +void toggleShowBeatLines() { myShowBeatLines = !myShowBeatLines; gMenubar->update(Menubar::SHOW_BEATLINES); } -void NotefieldImpl::toggleShowNotes() +void toggleShowNotes() { myShowNotes = !myShowNotes; gMenubar->update(Menubar::SHOW_NOTES); } -void NotefieldImpl::toggleShowSongPreview() +void toggleShowSongPreview() { myShowSongPreview = !myShowSongPreview; } diff --git a/src/Editor/NotefieldPreview.cpp b/src/Editor/NotefieldPreview.cpp index 77125837..a516891f 100644 --- a/src/Editor/NotefieldPreview.cpp +++ b/src/Editor/NotefieldPreview.cpp @@ -468,7 +468,7 @@ void drawNotes() // ================================================================================================ // NotefieldPreviewImpl :: toggle/check functions. -int NotefieldPreviewImpl::getY() +int getY() { return myY; } @@ -484,20 +484,20 @@ DrawMode getMode() return myDrawMode; } -void NotefieldPreviewImpl::toggleEnabled() +void toggleEnabled() { myEnabled = !myEnabled; gView->adjustForPreview(myEnabled); gMenubar->update(Menubar::PREVIEW_ENABLED); } -void NotefieldPreviewImpl::toggleShowBeatLines() +void toggleShowBeatLines() { myShowBeatLines = !myShowBeatLines; gMenubar->update(Menubar::PREVIEW_SHOW_BEATLINES); } -void NotefieldPreviewImpl::toggleReverseScroll() +void toggleReverseScroll() { myUseReverseScroll = !myUseReverseScroll; gMenubar->update(Menubar::PREVIEW_SHOW_REVERSE_SCROLL); diff --git a/src/Editor/Shortcuts.cpp b/src/Editor/Shortcuts.cpp index 332108ce..571b1309 100644 --- a/src/Editor/Shortcuts.cpp +++ b/src/Editor/Shortcuts.cpp @@ -495,7 +495,7 @@ ShortcutsImpl() // ================================================================================================ // ShortcutsImpl :: API functions. -std::string Shortcuts::getNotation(Action::Type action, bool fullList = false) +std::string getNotation(Action::Type action, bool fullList = false) { std::string out; for(auto& shortcut : shortcutMappings_) @@ -541,7 +541,7 @@ std::string Shortcuts::getNotation(Action::Type action, bool fullList = false) return out; } -Action::Type Shortcuts::getAction(int keyflags, Code key) +Action::Type getAction(int keyflags, Code key) { for(auto& shortcut : shortcutMappings_) { diff --git a/src/Editor/Statusbar.cpp b/src/Editor/Statusbar.cpp index 5c43d327..a721562a 100644 --- a/src/Editor/Statusbar.cpp +++ b/src/Editor/Statusbar.cpp @@ -196,112 +196,112 @@ void draw() // ================================================================================================ // StatusbarImpl :: toggle/check functions. -void StatusbarImpl::toggleChart() +void toggleChart() { myShowChart = !myShowChart; gMenubar->update(Menubar::STATUSBAR_CHART); } -void StatusbarImpl::toggleSnap() +void toggleSnap() { myShowSnap = !myShowSnap; gMenubar->update(Menubar::STATUSBAR_SNAP); } -void StatusbarImpl::toggleBpm() +void toggleBpm() { myShowBpm = !myShowBpm; gMenubar->update(Menubar::STATUSBAR_BPM); } -void StatusbarImpl::toggleRow() +void toggleRow() { myShowRow = !myShowRow; gMenubar->update(Menubar::STATUSBAR_ROW); } -void StatusbarImpl::toggleBeat() +void toggleBeat() { myShowBeat = !myShowBeat; gMenubar->update(Menubar::STATUSBAR_BEAT); } -void StatusbarImpl::toggleMeasure() +void toggleMeasure() { myShowMeasure = !myShowMeasure; gMenubar->update(Menubar::STATUSBAR_MEASURE); } -void StatusbarImpl::toggleTime() +void toggleTime() { myShowTime = !myShowTime; gMenubar->update(Menubar::STATUSBAR_TIME); } -void StatusbarImpl::toggleTimingMode() +void toggleTimingMode() { myShowTimingMode = !myShowTimingMode; gMenubar->update(Menubar::STATUSBAR_TIMING_MODE); } -void StatusbarImpl::toggleScroll() +void toggleScroll() { myShowScroll = !myShowScroll; gMenubar->update(Menubar::STATUSBAR_SCROLL); } -void StatusbarImpl::toggleSpeed() +void toggleSpeed() { myShowSpeed = !myShowSpeed; gMenubar->update(Menubar::STATUSBAR_SPEED); } -bool StatusbarImpl::hasChart() +bool hasChart() { return myShowChart; } -bool StatusbarImpl::hasSnap() +bool hasSnap() { return myShowSnap; } -bool StatusbarImpl::hasBpm() +bool hasBpm() { return myShowBpm; } -bool StatusbarImpl::hasRow() +bool hasRow() { return myShowRow; } -bool StatusbarImpl::hasBeat() +bool hasBeat() { return myShowBeat; } -bool StatusbarImpl::hasMeasure() +bool hasMeasure() { return myShowMeasure; } -bool StatusbarImpl::hasTime() +bool hasTime() { return myShowTime; } -bool StatusbarImpl::hasTimingMode() +bool hasTimingMode() { return myShowTimingMode; } -bool StatusbarImpl::hasScroll() +bool hasScroll() { return myShowScroll; } -bool StatusbarImpl::hasSpeed() +bool hasSpeed() { return myShowSpeed; } diff --git a/src/Editor/View.cpp b/src/Editor/View.cpp index 3ae509fc..94d625a2 100644 --- a/src/Editor/View.cpp +++ b/src/Editor/View.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include diff --git a/src/Managers/TempoMan.cpp b/src/Managers/TempoMan.cpp index d4879b12..adea6028 100644 --- a/src/Managers/TempoMan.cpp +++ b/src/Managers/TempoMan.cpp @@ -21,6 +21,7 @@ #include #include +#include #define TEMPO_MAN ((TempoManImpl*)gTempo) diff --git a/src/Managers/TempoMan.h b/src/Managers/TempoMan.h index a7e4bc75..5e24a7ca 100644 --- a/src/Managers/TempoMan.h +++ b/src/Managers/TempoMan.h @@ -1,6 +1,7 @@ #pragma once #include +#include namespace Vortex { diff --git a/src/Simfile/LoadOsu.cpp b/src/Simfile/LoadOsu.cpp index 24416fdf..f5775150 100644 --- a/src/Simfile/LoadOsu.cpp +++ b/src/Simfile/LoadOsu.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -254,7 +255,7 @@ static void ParseTimingPoints(OsuFile& out, Parser& parser) if(spb > 0) { double bpm = 60.0 / spb; - double roundBPM = round(bpm); + double roundBPM = std::round(bpm); if(abs(bpm - roundBPM) < 0.001) bpm = roundBPM; out.timingPoints[time] = {bpm, 1.0}; parser.bpm = bpm; diff --git a/src/Simfile/LoadSm.cpp b/src/Simfile/LoadSm.cpp index 4a87da37..ef7fedb3 100644 --- a/src/Simfile/LoadSm.cpp +++ b/src/Simfile/LoadSm.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -407,7 +408,7 @@ static void ReadNoteRow(ReadNoteData& data, int row, char* p, int quantization) // Make sure we set the note to its largest quantization to avoid data loss if (data.quants[col] > 0 && hold->quant > 0) { - hold->quant = min(192u, quantization * hold->quant / gcd(quantization, hold->quant)); + hold->quant = std::min(192, quantization * hold->quant / gcd(quantization, hold->quant)); } else // There was some error, so always play safe and use 192 { @@ -554,7 +555,7 @@ static void ParseNotes(ParseData& data, Chart* chart, const std::string& style, // Handle abnormal numbers of lines loading if (ROWS_PER_NOTE_SECTION % numLines != 0) { - ofs = ((int)round(192.0f / numLines * (i + 1)) - (int)round(192.0f / numLines * i)); + ofs = ((int)std::round(192.0f / numLines * (i + 1)) - (int)std::round(192.0f / numLines * i)); } line += numCols; row += ofs; diff --git a/src/Simfile/NoteList.cpp b/src/Simfile/NoteList.cpp index 0c8f5cdf..b9758250 100644 --- a/src/Simfile/NoteList.cpp +++ b/src/Simfile/NoteList.cpp @@ -15,6 +15,7 @@ #include #include +#include namespace Vortex { namespace { @@ -524,8 +525,8 @@ static void ApplyQuantOffset(Note& out, int offsetRows) // then make this the new measure offset if (192 % out.quant > 0 && startingOffset != endingOffset) { - out.row = out.row - endingOffset + (int) round(192.0f / out.quant * round(endingOffset / 192.0f * out.quant)); - out.endrow = out.endrow - endingRowOffset + (int) round(192.0f / out.quant * round(endingRowOffset / 192.0f * out.quant)); + out.row = out.row - endingOffset + (int) std::round(192.0f / out.quant * std::round(endingOffset / 192.0f * out.quant)); + out.endrow = out.endrow - endingRowOffset + (int) std::round(192.0f / out.quant * std::round(endingRowOffset / 192.0f * out.quant)); } } diff --git a/src/Simfile/SaveOsu.cpp b/src/Simfile/SaveOsu.cpp index 62e3a364..7f141b4b 100644 --- a/src/Simfile/SaveOsu.cpp +++ b/src/Simfile/SaveOsu.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include diff --git a/src/Simfile/Segments.cpp b/src/Simfile/Segments.cpp index a21667e7..583e930a 100644 --- a/src/Simfile/Segments.cpp +++ b/src/Simfile/Segments.cpp @@ -15,20 +15,20 @@ namespace Vortex { // ================================================================================================ // Low level segment functions. -template -void Encode(WriteStream& out, const T& seg); +// template +// void Encode(WriteStream& out, const T& seg); -template -void Decode(ReadStream& in, T& seg); +// template +// void Decode(ReadStream& in, T& seg); -template -bool IsRedundant(const T& seg, const T* prev); +// template +// bool IsRedundant(const T& seg, const T* prev); -template -bool IsEquivalent(const T& seg, const T& other); +// template +// bool IsEquivalent(const T& seg, const T& other); -template -std::string GetDescription(const T& seg); +// template +// std::string GetDescription(const T& seg); // ================================================================================================ // Segment wrapper functions. @@ -55,7 +55,7 @@ template static void WrapEnc(WriteStream& out, const Segment* seg) { out.write(seg->row); - Encode(out, *(const T*)seg); + Encode(out, *(const T*)seg); } template @@ -63,26 +63,26 @@ static void WrapDec(ReadStream& in, SegmentGroup* out) { T seg; in.read(seg.row); - Decode(in, seg); + Decode(in, seg); out->append(seg); } template static bool WrapRed(const Segment* seg, const Segment* prev) { - return IsRedundant(*(const T*)seg, (const T*)prev); + return IsRedundant(*(const T*)seg, (const T*)prev); } template static bool WrapEqu(const Segment* seg, const Segment* other) { - return IsEquivalent(*(const T*)seg, *(const T*)other); + return IsEquivalent(*(const T*)seg, *(const T*)other); } template static std::string WrapDsc(const Segment* seg) { - return GetDescription(*(const T*)seg); + return GetDescription(*(const T*)seg); } #define WRAP(x)\ @@ -121,32 +121,27 @@ BpmChange::BpmChange(int row, double bpm) { } -template <> static void Encode(WriteStream& out, const BpmChange& seg) { out.write(seg.bpm); } -template <> static void Decode(ReadStream& in, BpmChange& seg) { in.read(seg.bpm); } -template <> static bool IsRedundant(const BpmChange& seg, const BpmChange* prev) { //return (prev && prev->bpm == seg.bpm); -- original code before Visual Sync commit return prev && prev->row == seg.row; } -template <> static bool IsEquivalent(const BpmChange& seg, const BpmChange& other) { return (seg.bpm == other.bpm); } -template <> static std::string GetDescription(const BpmChange& seg) { return Str::val(seg.bpm, 3, 6); @@ -176,31 +171,26 @@ Stop::Stop(int row, double seconds) { } -template <> static void Encode(WriteStream& out, const Stop& seg) { out.write(seg.seconds); } -template <> static void Decode(ReadStream& in, Stop& seg) { in.read(seg.seconds); } -template <> static bool IsRedundant(const Stop& seg, const Stop* prev) { return (fabs(seg.seconds) < 0.0000005) || (prev && prev->row == seg.row); } -template <> static bool IsEquivalent(const Stop& seg, const Stop& other) { return (seg.seconds == other.seconds); } -template <> static std::string GetDescription(const Stop& seg) { return Str::val(seg.seconds, 3, 6); @@ -230,31 +220,26 @@ Delay::Delay(int row, double seconds) { } -template <> static void Encode(WriteStream& out, const Delay& seg) { out.write(seg.seconds); } -template <> static void Decode(ReadStream& in, Delay& seg) { in.read(seg.seconds); } -template <> static bool IsRedundant(const Delay& seg, const Delay* prev) { return (fabs(seg.seconds) < 0.0005) || (prev && prev->row == seg.row); } -template <> static bool IsEquivalent(const Delay& seg, const Delay& other) { return (seg.seconds == other.seconds); } -template <> static std::string GetDescription(const Delay& seg) { return Str::val(seg.seconds, 3, 6); @@ -284,31 +269,31 @@ Warp::Warp(int row, int numRows) { } -template <> + static void Encode(WriteStream& out, const Warp& seg) { out.write(seg.numRows); } -template <> + static void Decode(ReadStream& in, Warp& seg) { in.read(seg.numRows); } -template <> + static bool IsRedundant(const Warp& seg, const Warp* prev) { return (seg.numRows == 0) || (prev && prev->row == seg.row); } -template <> + static bool IsEquivalent(const Warp& seg, const Warp& other) { return (seg.numRows == other.numRows); } -template <> + static std::string GetDescription(const Warp& seg) { return Str::val(seg.numRows * BEATS_PER_ROW, 3, 6); @@ -338,34 +323,34 @@ TimeSignature::TimeSignature(int row, int rowsPerMeasure, int beatNote) { } -template <> + static void Encode(WriteStream& out, const TimeSignature& seg) { out.write(seg.rowsPerMeasure); out.write(seg.beatNote); } -template <> + static void Decode(ReadStream& in, TimeSignature& seg) { in.read(seg.rowsPerMeasure); in.read(seg.beatNote); } -template <> + static std::string GetDescription(const TimeSignature& seg) { int beatsPerMeasure = seg.rowsPerMeasure / ROWS_PER_BEAT; return Str::fmt("%1/%2").arg(beatsPerMeasure).arg(seg.beatNote); } -template <> + static bool IsRedundant(const TimeSignature& seg, const TimeSignature* prev) { return (prev && prev->rowsPerMeasure == seg.rowsPerMeasure && prev->beatNote == seg.beatNote); } -template <> + static bool IsEquivalent(const TimeSignature& seg, const TimeSignature& other) { return (other.rowsPerMeasure == seg.rowsPerMeasure && other.beatNote == seg.beatNote); @@ -395,31 +380,31 @@ TickCount::TickCount(int row, int ticks) { } -template <> + static void Encode(WriteStream& out, const TickCount& seg) { out.write(seg.ticks); } -template <> + static void Decode(ReadStream& in, TickCount& seg) { in.read(seg.ticks); } -template <> + static std::string GetDescription(const TickCount& seg) { return Str::val(seg.ticks); } -template <> + static bool IsRedundant(const TickCount& seg, const TickCount* prev) { return (prev && prev->ticks == seg.ticks); } -template <> + static bool IsEquivalent(const TickCount& seg, const TickCount& other) { return (other.ticks == seg.ticks); @@ -449,33 +434,33 @@ Combo::Combo(int row, int hit, int miss) { } -template <> + static void Encode(WriteStream& out, const Combo& seg) { out.write(seg.hitCombo); out.write(seg.missCombo); } -template <> + static void Decode(ReadStream& in, Combo& seg) { in.read(seg.hitCombo); in.read(seg.missCombo); } -template <> + static std::string GetDescription(const Combo& seg) { return Str::fmt("%1/%2").arg(seg.hitCombo).arg(seg.missCombo); } -template <> + static bool IsRedundant(const Combo& seg, const Combo* prev) { return (prev && prev->hitCombo == seg.hitCombo && prev->missCombo == seg.missCombo); } -template <> + static bool IsEquivalent(const Combo& seg, const Combo& other) { return (other.hitCombo == seg.hitCombo && other.missCombo == seg.missCombo); @@ -505,7 +490,7 @@ Speed::Speed(int row, double ratio, double delay, int unit) { } -template <> + static void Encode(WriteStream& out, const Speed& seg) { out.write(seg.ratio); @@ -513,7 +498,7 @@ static void Encode(WriteStream& out, const Speed& seg) out.write(seg.unit); } -template <> + static void Decode(ReadStream& in, Speed& seg) { in.read(seg.ratio); @@ -521,19 +506,19 @@ static void Decode(ReadStream& in, Speed& seg) in.read(seg.unit); } -template <> + static std::string GetDescription(const Speed& seg) { return Str::fmt("%1/%2/%3").arg(seg.ratio, 0, 6).arg(seg.delay, 0, 6).arg(seg.unit ? 'T' : 'B'); } -template <> + static bool IsRedundant(const Speed& seg, const Speed* prev) { return (prev && prev->ratio == seg.ratio && prev->delay == seg.delay && prev->unit == seg.unit); } -template <> + static bool IsEquivalent(const Speed& seg, const Speed& other) { return (other.ratio == seg.ratio && other.delay == seg.delay && other.unit == seg.unit); @@ -563,31 +548,31 @@ Scroll::Scroll(int row, double ratio) { } -template <> + static void Encode(WriteStream& out, const Scroll& seg) { out.write(seg.ratio); } -template <> + static void Decode(ReadStream& in, Scroll& seg) { in.read(seg.ratio); } -template <> + static std::string GetDescription(const Scroll& seg) { return Str::val(seg.ratio); } -template <> + static bool IsRedundant(const Scroll& seg, const Scroll* prev) { return (prev && prev->ratio == seg.ratio); } -template <> + static bool IsEquivalent(const Scroll& seg, const Scroll& other) { return (other.ratio == seg.ratio); @@ -617,31 +602,31 @@ Fake::Fake(int row, int numRows) { } -template <> + static void Encode(WriteStream& out, const Fake& seg) { out.write(seg.numRows); } -template <> + static void Decode(ReadStream& in, Fake& seg) { in.read(seg.numRows); } -template <> + static std::string GetDescription(const Fake& seg) { return Str::val(seg.numRows * BEATS_PER_ROW, 3, 6); } -template <> + static bool IsRedundant(const Fake& seg, const Fake* prev) { return (seg.numRows == 0) || (prev && prev->row == seg.row); } -template <> + static bool IsEquivalent(const Fake& seg, const Fake& other) { return (other.numRows == seg.numRows); @@ -670,31 +655,31 @@ Label::Label(int row, std::string str) { } -template <> + static void Encode(WriteStream& out, const Label& seg) { out.writeStr(seg.str); } -template <> + static void Decode(ReadStream& in, Label& seg) { in.readStr(seg.str); } -template <> + static std::string GetDescription(const Label& seg) { return seg.str; } -template <> + static bool IsRedundant(const Label& seg, const Label* prev) { return seg.str.empty() || (prev && prev->row == seg.row); } -template <> + static bool IsEquivalent(const Label& seg, const Label& other) { return (other.str == seg.str); diff --git a/src/Simfile/Segments.h b/src/Simfile/Segments.h index 9a048e2c..e562c55d 100644 --- a/src/Simfile/Segments.h +++ b/src/Simfile/Segments.h @@ -1,5 +1,7 @@ #pragma once +#include "Core/ByteStream.h" + namespace Vortex { struct Segment; diff --git a/src/Simfile/Tempo.cpp b/src/Simfile/Tempo.cpp index 58299522..37c4e9c2 100644 --- a/src/Simfile/Tempo.cpp +++ b/src/Simfile/Tempo.cpp @@ -48,7 +48,7 @@ void Tempo::sanitize(const Chart* owner) auto end = segments->end(); if(bpmc == end || bpmc->row != 0) { - double bpm = (bpmc != end) ? bpmc->bpm : SIM_DEFAULT_BPM; + double bpm = (bpmc != end) ? bpmc->bpm : (double)SIM_DEFAULT_BPM; segments->insert(BpmChange(0, bpm)); std::string suffix; if(owner) diff --git a/src/System/ArrowVortex.rc b/src/System/ArrowVortex.rc index 2ae090220d9a197907b32b65005f32b39abbfbd3..312f2ff33fecdf2b3679cc4bdaa214e06ac51bd8 100644 GIT binary patch literal 1542 zcmcIkZEu?}5dQ98aU)+EwSukv1x|1g8G$H3)k=|&2WGKE?8r9FCiTb9kcK5wTlE98 z5V||t_ww9x_B>efQb{dq0}oucw1N5cHT-0PDQZ{+ifP%Zl7TK2-y0Ws9-44bHf_bg zS-t@EX1xJ5ycZ z`$yZAG|AUE=DiXt2bISvSPLb1Rr9FvsXK$_2bi%;%x9%X%i zi+aQOA^A@H(W~s5eb!m4BJ}Ot0%%5pFh*dPb0V(0-F$TriG74_-#z@7(at~%XQMX4 zIXW9$+`a4Kt2mW(L-ZHb}}5e*+L@^OdAM&c&1IuVBgTv zPIt|fwHgUb=vFbH`+dVpYPh|}kB%&rc9aVZR@Gb^CJfkJ+BBelTXm;hw8UXtg!3eZ z{^z)^XTKj@cvNdPx# literal 3274 zcmds(S#J|D5Xa{kiSJ<2msX&b;}bLoRUs)=jtV5Cs3e3&YLhCPa7g{^!0$hf$u`-5 z2rnyS?b;sC<+(gRz8~3<1#8*Z1~#*)Wqc!>1G@m0*}^XEnqAEvGlG4xk2c|(0iQDu zfz6mjw_r739oUK6*lxi&w1@TpDMvo<0iAGq4ffD+D_|Vjdq$cw=OakRzQId!ZXBb% zCMkpF$|}xTQudtZ$Yn^6V>^dO*LqgBQ+s25Yg+?oo%NYD?H!N~|CUvOG+8HIrEmF0 z(k{)xPO!+jKStPZip2t!yK)Wc-Ftub*B7^Mq`Pnb@>wit z6r*E-trT^mons?eKJhKroU{w}iu}CgQ*2}&1N%AHL4n`1To#SpLXYlc)6n+GoR`E= z%%Tn%(<7g1L{gu4YBI$4juEy}cHz+`YWrw&PBb34)F#j~pgrajkIV!Sp0Zfy4f3;L zPvG7Gvx>Y(CFu<`I|kY$%4LPLv7c&z87zD1%#AeTd$h;8jf&>Q~f(j9r`H z`@CN9UAqBC{YD05)H`DzJBo?xBN}nNW~gsj^&9Ffbh{RHMZW9vuX*2~Tcp)y_wvCd zs(ZPFpK9-%f85Wwg{&b9Oj)b5`N~eWktT=BRqSZCN7t^^yNAb- diff --git a/src/System/CMakeLists.txt b/src/System/CMakeLists.txt index ee50deba..470da65d 100644 --- a/src/System/CMakeLists.txt +++ b/src/System/CMakeLists.txt @@ -10,4 +10,24 @@ add_custom_command( COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/bin $) -target_link_libraries(ArrowVortex PRIVATE System) + +if (MINGW_BASED) + # This imports important static libraries needed by MinGW builders. + list( + APPEND MINGW_ESSENTIAL_LIBS + ${CMAKE_FIND_ROOT_PATH}/lib/libgcc_s.a + ${CMAKE_FIND_ROOT_PATH}/lib/libwinpthread.a + ${CMAKE_FIND_ROOT_PATH}/lib/libstdc++.a + ) + + # This copies the two most important DLLs ever to run ArrowVortex. + # If you do not copy/have these, ArrowVortex will not run (on wine). + file( + COPY + ${CMAKE_FIND_ROOT_PATH}/bin/libgcc_s_seh-1.dll + ${CMAKE_FIND_ROOT_PATH}/bin/libwinpthread-1.dll + DESTINATION . + ) +endif() + +target_link_libraries(ArrowVortex PRIVATE System ${MINGW_ESSENTIAL_LIBS}) diff --git a/src/System/Debug.cpp b/src/System/Debug.cpp index 3872012b..1e7ee3c7 100644 --- a/src/System/Debug.cpp +++ b/src/System/Debug.cpp @@ -9,7 +9,7 @@ #define WIN32_LEAN_AND_MEAN #include -#include +#include #undef ERROR namespace Vortex { diff --git a/src/System/OpenGL.h b/src/System/OpenGL.h index d4bc5265..c8109be7 100644 --- a/src/System/OpenGL.h +++ b/src/System/OpenGL.h @@ -2,5 +2,5 @@ #define WIN32_LEAN_AND_MEAN #include "windows.h" -#include "gl/gl.h" +#include "GL/gl.h" #undef ERROR \ No newline at end of file diff --git a/src/System/System.cpp b/src/System/System.cpp index 644333bf..0059ccbb 100644 --- a/src/System/System.cpp +++ b/src/System/System.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #undef ERROR #include @@ -35,6 +35,7 @@ #include #include #include +#include #undef DELETE @@ -358,10 +359,10 @@ SystemImpl() // Make sure the window is centered on the desktop. mySize = {1200, 900}; RECT wr; - wr.left = max(0, GetSystemMetrics(SM_CXSCREEN) / 2 - mySize.x / 2); - wr.top = max(0, GetSystemMetrics(SM_CYSCREEN) / 2 - mySize.y / 2); - wr.right = wr.left + max(mySize.x, 0); - wr.bottom = wr.top + max(mySize.y, 0); + wr.left = std::max(0, GetSystemMetrics(SM_CXSCREEN) / 2 - mySize.x / 2); + wr.top = std::max(0, GetSystemMetrics(SM_CYSCREEN) / 2 - mySize.y / 2); + wr.right = wr.left + std::max(mySize.x, 0); + wr.bottom = wr.top + std::max(mySize.y, 0); AdjustWindowRectEx(&wr, myStyle, FALSE, myExStyle); int flags = SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOZORDER; SetWindowPos(myHWND, nullptr, wr.left, wr.top, wr.right - wr.left, wr.bottom - wr.top, flags); @@ -480,7 +481,7 @@ void CALLBACK messageLoop() // End of frame auto curTime = Debug::getElapsedTime(); - deltaTime = duration((float)min(max(0, duration(curTime - prevTime).count()), 0.25)); + deltaTime = duration((float)std::min(std::max(0.0, duration(curTime - prevTime).count()), 0.25)); prevTime = curTime; #ifndef NDEBUG @@ -599,7 +600,7 @@ LPCWSTR getCursorResource() { IDC_ARROW, IDC_HAND, IDC_IBEAM, IDC_SIZEALL, IDC_SIZEWE, IDC_SIZENS, IDC_SIZENESW, IDC_SIZENWSE, }; - return cursorMap[min(max(0, myCursor), Cursor::NUM_CURSORS - 1)]; + return cursorMap[std::min(std::max(0, (int)myCursor), (int)Cursor::NUM_CURSORS - 1)]; } int getKeyFlags() const