Skip to content

Commit

Permalink
Merge branch 'master' into 3.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sirjuddington committed Jan 31, 2025
2 parents 4afaf7d + 041673e commit 2102fa7
Show file tree
Hide file tree
Showing 35 changed files with 4,765 additions and 4,722 deletions.
99 changes: 70 additions & 29 deletions .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,92 @@ jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
defaults:
run:
shell: ${{ matrix.config.shell }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "macOS",
os: macos-latest,
deps_cmdline: "brew install fluidsynth freeimage ftgl glm lua mpg123 sfml wxwidgets"
}
- {
name: "Linux GCC",
os: ubuntu-24.04,
deps_cmdline: "sudo apt install \
libfluidsynth-dev libfreeimage-dev libwebkit2gtk-4.1-dev \
libglm-dev liblua5.3-dev libmpg123-dev libsfml-dev \
libwxgtk3.2-dev libwxgtk-webview3.2-dev"
}
- {
name: "Linux Clang",
os: ubuntu-24.04,
extra_options: "-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++",
deps_cmdline: "sudo apt install \
libfluidsynth-dev libfreeimage-dev libwebkit2gtk-4.1-dev \
libglm-dev liblua5.3-dev libmpg123-dev libsfml-dev \
libwxgtk3.2-dev libwxgtk-webview3.2-dev"
}
- name: "macOS arm64"
os: macos-latest
release: true
shell: bash
package_name: "mac_arm64"
artifact-path: build/*.dmg

- name: "macOS x64"
os: macos-13
release: true
shell: bash
package_name: "mac_x64"
artifact-path: build/*.dmg

- name: "Linux GCC"
os: ubuntu-24.04
shell: bash

- name: "Linux Clang"
os: ubuntu-24.04
shell: bash
extra_options: "-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++"

steps:
- uses: actions/checkout@v2

- name: Install Dependencies
shell: bash
- name: Install Dependencies (macOS)
if: runner.os == 'macOS'
run: brew install fluidsynth freeimage ftgl glm lua mpg123 sfml wxwidgets dylibbundler create-dmg

- name: Install Dependencies (Linux)
if: runner.os == 'Linux'
run: |
if [[ ! -z "${{ matrix.config.deps_cmdline }}" ]]; then
eval ${{ matrix.config.deps_cmdline }}
fi
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install \
libfluidsynth-dev libfreeimage-dev libglm-dev \
liblua5.4-dev libmpg123-dev libsfml-dev libwxgtk3.2-dev
- name: Configure
shell: bash
run: |
mkdir build
cmake -B build ${{ matrix.config.extra_options }} .
- name: Build
shell: bash
run: |
export MAKEFLAGS=--keep-going
cmake --build build --parallel 3
- name: Package (macOS)
if: runner.os == 'macOS'
run: |
cd build
dylibbundler -od -b -x slade.app/Contents/MacOS/slade -d slade.app/Contents/MacOS/libs -p @executable_path/libs
for i in {1..10};
do
if create-dmg --app-drop-link 10 10 ./slade_${{ matrix.config.package_name }}_${{ github.ref_name }}.dmg ./slade.app;
then
echo "slade_${{ matrix.config.package_name }}_${{ github.ref_name }}.dmg created"
break
else
echo "create-dmg failed $i"
fi
done
- name: Upload Artifacts
if: ${{ matrix.config.package_name }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.config.package_name }}
path: ${{ matrix.config.artifact-path }}

- name: Release
if: ${{ contains(github.ref, 'tags') && matrix.config.release }}
uses: ncipollo/release-action@v1
with:
name: ${{ github.ref_name }}
allowUpdates: true
omitBodyDuringUpdate: true
artifacts: ${{ matrix.config.artifact-path }}
7 changes: 6 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ version: 2
#sphinx:
# configuration: docs/conf.py

# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.12"

# Build documentation with MkDocs
mkdocs:
configuration: docs/mkdocs.yml
Expand All @@ -19,6 +25,5 @@ mkdocs:

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.7
install:
- requirements: docs/requirements.txt
19 changes: 12 additions & 7 deletions src/Audio/MIDIPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,18 @@ class FluidSynthMIDIPlayer : public MIDIPlayer
fs_initialised_ = false;
file_ = "";

// Set fluidsynth driver to alsa in linux (no idea why it defaults to jack)
// Set fluidsynth driver to pulseaudio in linux (no idea why it defaults to jack)
if (app::platform() == app::Platform::Linux && fs_driver.value.empty())
fs_driver = "alsa";
fs_driver = "pulseaudio";

// Init soundfont path
if (fs_soundfont_path.value.empty())
{
if (app::platform() == app::Platform::Linux)
fs_soundfont_path = "/usr/share/sounds/sf2/FluidR3_GM.sf2:/usr/share/sounds/sf2/FluidR3_GS.sf2";
fs_soundfont_path =
"/usr/share/sounds/sf2/FluidR3_GM.sf2"
":/usr/share/sounds/sf2/FluidR3_GS.sf2"
":/usr/share/sounds/sf2/default-GM.sf2";
else
log::warning(1, "No FluidSynth soundfont set, MIDI playback will not work");
}
Expand Down Expand Up @@ -251,17 +254,19 @@ class FluidSynthMIDIPlayer : public MIDIPlayer

elapsed_ms_ += timer_->getElapsedTime().asMilliseconds();

return fluid_player_stop(fs_player_) == FLUID_OK;
auto ok = fluid_player_stop(fs_player_) == FLUID_OK;
fluid_synth_all_notes_off(fs_synth_, -1);

return ok;
}

// -------------------------------------------------------------------------
// Stops playback of the currently loaded MIDI stream
// -------------------------------------------------------------------------
bool stop() override
{
if (isPlaying())
fluid_player_stop(fs_player_);

fluid_player_stop(fs_player_);
fluid_synth_all_notes_off(fs_synth_, -1);
fluid_player_seek(fs_player_, 0);
elapsed_ms_ = 0;

Expand Down
4 changes: 2 additions & 2 deletions src/Game/Decorate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,7 @@ void parseDecorateActor(Tokenizer& tz, std::map<int, ThingType>& types, vector<T
if (strutil::startsWith(token, "//$"))
{
// Doom Builder magic editor comment
editor_properties.emplace_back(Tokenizer::parseEditorComment(token));
tz.advToNextLine();
editor_properties.emplace_back(Tokenizer::parseEditorComment(tz.getLine(true)));
continue;
}

Expand Down Expand Up @@ -571,6 +570,7 @@ void parseDecorateEntry(ArchiveEntry* entry, std::map<int, ThingType>& types, ve
// Init tokenizer
Tokenizer tz;
tz.setSpecialCharacters(":,{}");
tz.enableEditorComments();
tz.openMem(entry->data(), entry->name());

// --- Parse ---
Expand Down
10 changes: 9 additions & 1 deletion src/Game/ZScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ void parseBlocks(ArchiveEntry* entry, vector<ParsedStatement>& parsed, vector<Ar
Tokenizer tz;
tz.setSpecialCharacters(Tokenizer::DEFAULT_SPECIAL_CHARACTERS + "()+-[]&!?.<>");
tz.setCommentTypes(Tokenizer::CommentTypes::CPPStyle | Tokenizer::CommentTypes::CStyle);
tz.enableEditorComments();
tz.openMem(entry->data(), "ZScript");

entry_stack.push_back(entry);
Expand Down Expand Up @@ -871,9 +872,16 @@ bool Class::parseClassBlock(vector<ParsedStatement>& block)
else if (strutil::equalCI(first_token, "states"))
states_.parse(statement);

// DB property comment
// DB property comment(s)
else if (strutil::startsWith(first_token, editor_comment_prefix))
{
db_properties_.emplace_back(Tokenizer::parseEditorComment(first_token));
for (auto i = 1; i < statement.tokens.size(); ++i)
{
if (strutil::startsWith(statement.tokens[i], editor_comment_prefix))
db_properties_.emplace_back(Tokenizer::parseEditorComment(statement.tokens[i]));
}
}

// Function
else if (Function::isFunction(statement))
Expand Down
26 changes: 19 additions & 7 deletions src/Utility/Tokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ std::pair<string, string> Tokenizer::parseEditorComment(string_view token)
// strip whitespace, and drop the quotes if any.

// Find the first space
size_t spos = token.find(" \t");
size_t spos = token.find_first_of(" \t");
if (spos == string_view::npos)
{
string key(token.substr(3));
Expand Down Expand Up @@ -838,13 +838,12 @@ void Tokenizer::tokenizeToken()
}

// Check for end of token
if (isWhitespace(data_[state_.position]) || // Whitespace
isSpecialCharacter(data_[state_.position]) || // Special character
checkCommentBegin() > 0) // Comment
if (isEndOfToken())
{
// End token
state_.state = TokenizeState::State::Unknown;
state_.done = true;
state_.state = TokenizeState::State::Unknown;
state_.done = true;
state_.to_eol = false;

return;
}
Expand All @@ -859,7 +858,7 @@ void Tokenizer::tokenizeToken()
void Tokenizer::tokenizeComment()
{
// Check for decorate //$
if (decorate_ && state_.comment_type == CPPStyle)
if (editor_comments_ && state_.comment_type == CPPStyle)
{
if (data_[state_.position] == '$' && data_[state_.position - 1] == '/' && data_[state_.position - 2] == '/')
{
Expand All @@ -868,6 +867,7 @@ void Tokenizer::tokenizeComment()
state_.current_token.quoted_string = false;
state_.current_token.pos_start = state_.position - 2;
state_.state = TokenizeState::State::Token;
state_.to_eol = true;
return;
}
}
Expand Down Expand Up @@ -991,6 +991,18 @@ void Tokenizer::resetToLineStart()
}
}

bool Tokenizer::isEndOfToken() const
{
// Token is to end of line, only ends on newline
if (state_.to_eol)
return data_[state_.position] == '\n';

// Regular token
return isWhitespace(data_[state_.position]) || // Whitespace
isSpecialCharacter(data_[state_.position]) || // Special character
checkCommentBegin() > 0; // Comment
}


// Testing

Expand Down
24 changes: 13 additions & 11 deletions src/Utility/Tokenizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class Tokenizer
unsigned current_line = 1;
unsigned comment_type = 0;
Token current_token;
bool done = false;
bool done = false;
bool to_eol = false;
};

static std::pair<string, string> parseEditorComment(string_view token);
Expand All @@ -77,7 +78,7 @@ class Tokenizer

// Accessors
const string& source() const { return source_; }
bool decorate() const { return decorate_; }
bool decorate() const { return editor_comments_; }
bool readLowerCase() const { return read_lowercase_; }
const Token& current() const { return token_current_; }
const Token& peek() const;
Expand All @@ -90,8 +91,8 @@ class Tokenizer
}
void setSource(const wxString& source) { source_ = source; }
void setReadLowerCase(bool lower) { read_lowercase_ = lower; }
void enableDecorate(bool enable) { decorate_ = enable; }
void enableDebug(bool enable) { debug_ = enable; }
void enableEditorComments(bool enable = true) { editor_comments_ = enable; }
void enableDebug(bool enable = true) { debug_ = enable; }

// Token Iterating
const Token& next();
Expand Down Expand Up @@ -212,13 +213,13 @@ class Tokenizer
TokenizeState state_ = {};

// Configuration
int comment_types_; // Types of comments to skip
vector<char> special_characters_; // These will always be read as separate tokens
string source_; // What file/entry/chunk is being tokenized
bool decorate_ = false; // Special handling for //$ comments
bool read_lowercase_ = false; // If true, tokens will all be read in lowercase
// (except for quoted strings, obviously)
bool debug_ = false; // Log each token read
int comment_types_; // Types of comments to skip
vector<char> special_characters_; // These will always be read as separate tokens
string source_; // What file/entry/chunk is being tokenized
bool editor_comments_ = false; // Special handling for //$ comments
bool read_lowercase_ = false; // If true, tokens will all be read in lowercase
// (except for quoted strings, obviously)
bool debug_ = false; // Log each token read

// Static
static Token invalid_token_;
Expand All @@ -232,5 +233,6 @@ class Tokenizer
bool readNext(Token* target);
bool readNext() { return readNext(&token_next_); }
void resetToLineStart();
bool isEndOfToken() const;
};
} // namespace slade
6 changes: 6 additions & 0 deletions thirdparty/fmt/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ IndentPPDirectives: AfterHash
IndentCaseLabels: false
AlwaysBreakTemplateDeclarations: false
DerivePointerAlignment: false
AllowShortCaseLabelsOnASingleLine: true
AlignConsecutiveShortCaseStatements:
Enabled: true
AcrossEmptyLines: true
AcrossComments: true
AlignCaseColons: false
Loading

0 comments on commit 2102fa7

Please sign in to comment.