Skip to content

Refactor and improve MonologueProcess#27

Merged
RailKill merged 4 commits into
mainfrom
chore/monologue-process
Aug 26, 2024
Merged

Refactor and improve MonologueProcess#27
RailKill merged 4 commits into
mainfrom
chore/monologue-process

Conversation

@RailKill

@RailKill RailKill commented Aug 23, 2024

Copy link
Copy Markdown
Collaborator

This PR cleans up and separates functions a little more clearly in MonologueProcess in preparation for future adaptations to other engines/languages as part of discussion #24. Having well-defined, atomic operations in its own function help with future extensibility, adaptability and testability, makes it more API-like.

Features

  • Improved conditional text processing in NodeSentence.

    Previous Behavior
    You can have {{ if my_variable then something else another }} in NodeSentence, and if my_variable is true, something will be emitted in monologue_sentence(). Only boolean variables were supported.

    New Behavior
    You can now nest and evaluate expressions in the conditional text. See Test/Unit/TestMonologueProcess.gd for automated test examples. Something like:

    {{ if variable_one + 50 < variable_two then if variable_three then a else 10 + 2 else "variable_one" }}
    

    will work. Any words in curly braces will be substituted with variable values if they have the same name unless they are surrounded by quotation marks which indicate they are Strings to be parsed as-is. If they do not exist as variables, you don't need quotation marks.

  • Support runtime loading of .wav and .ogg audio files in SfxLoader. Previously, only .mp3 is supported.

  • Notification.gd's print() now excludes color codes and BB tags, making console logs cleaner and easier to read.

Bug Fixes

Developer Notes

  • SfxPlayer.gd has been removed to streamline things. SfxLoader and AudioStreamPlayer2D is sufficient.
  • The kalimba.wav and mystery_sting.ogg for unit test were recorded by me. I played the instruments, no copyright issues.

Summary by Sourcery

Refactor MonologueProcess for better clarity and future extensibility, enhance conditional text processing, and add support for additional audio formats. Improve console log readability and streamline audio handling by removing SfxPlayer.gd. Update build configurations and CI workflow, and introduce extensive unit tests for MonologueProcess.

New Features:

  • Enhance conditional text processing in NodeSentence to support nested and evaluated expressions, allowing more complex logic in dialogue scripts.
  • Add support for runtime loading of .wav and .ogg audio files in SfxLoader, expanding the range of audio formats that can be used.

Bug Fixes:

Enhancements:

  • Refactor MonologueProcess to improve function separation and clarity, facilitating future adaptations and improving extensibility and testability.
  • Remove SfxPlayer.gd to streamline audio handling, as SfxLoader and AudioStreamPlayer2D are now sufficient.
  • Improve console log readability by removing color codes and BB tags from Notification.gd.

Build:

  • Update export_presets.cfg to exclude certain directories and adjust texture format settings for different platforms.

CI:

  • Modify GitHub Actions workflow to update the path for unit tests, ensuring correct test execution.

Tests:

  • Introduce comprehensive unit tests for MonologueProcess, covering various functionalities such as conditional text processing, audio playback, and node processing.

@sourcery-ai

sourcery-ai Bot commented Aug 23, 2024

Copy link
Copy Markdown

Reviewer's Guide by Sourcery

This pull request refactors and improves the MonologueProcess class, enhancing its functionality and preparing it for future adaptations to other engines and languages. The changes focus on improving code organization, expanding conditional text processing capabilities, and adding support for additional audio formats. The PR also includes extensive unit tests and updates to build configurations and CI paths.

File-Level Changes

Change Details Files
Refactored MonologueProcess class for better clarity and extensibility
  • Improved function separation and organization
  • Enhanced conditional text processing to support nested and evaluated expressions
  • Added support for runtime loading of .wav and .ogg audio files
  • Removed SfxPlayer.gd and streamlined audio handling
  • Updated signal names and parameters for consistency
Test/Scripts/MonologueProcess.gd
Test/Scripts/SfxLoader.gd
Added comprehensive unit tests for MonologueProcess
  • Created TestMonologueProcess.gd with extensive test cases
  • Covered various functionalities including conditional text processing, audio playback, and node processing
Test/Unit/TestMonologueProcess.gd
Updated build configurations and CI workflow
  • Modified export_presets.cfg to exclude certain directories from the build
  • Adjusted texture format settings for different platforms
  • Updated GitHub Actions workflow to use the new path for unit tests
export_presets.cfg
.github/workflows/test.yml
Improved console log readability
  • Modified Notification.gd to remove color codes and BB tags from console logs
Test/Scripts/Notification.gd
Removed unused utility function and updated Main script
  • Removed merge_dict function from Util.gd
  • Updated Main.gd to use new MonologueProcess API and improve code structure
Scripts/Global/Util.gd
Test/Scripts/Main.gd

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @RailKill - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 4 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

Comment thread Test/Scripts/MonologueProcess.gd
Comment thread Test/Scripts/SfxLoader.gd
Comment thread Test/Scripts/MonologueProcess.gd
Comment thread Test/Scripts/MonologueProcess.gd
@RailKill RailKill marked this pull request as draft August 23, 2024 23:44
@RailKill RailKill marked this pull request as ready for review August 24, 2024 00:49

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @RailKill - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

@RailKill RailKill requested a review from atomic-junky August 24, 2024 00:51
@atomic-junky

Copy link
Copy Markdown
Collaborator

I'll test that as soon as I can but it looks awesome 👍

@atomic-junky atomic-junky left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late review!

@RailKill RailKill merged commit 8d5c8cd into main Aug 26, 2024
@RailKill RailKill deleted the chore/monologue-process branch August 26, 2024 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Monologue crashes during Test if ActionOption has invalid option ID

2 participants