From 3d1e0ec874b4873d3466dd4047787f2f4044c031 Mon Sep 17 00:00:00 2001 From: Jan Niklas Hasse Date: Thu, 25 Apr 2024 22:24:00 +0200 Subject: [PATCH 1/3] Improve documentation for Channel --- src/jngl/Achievement.hpp | 5 +++-- src/jngl/Channel.hpp | 12 ++++++++++++ src/jngl/SoundFile.hpp | 9 ++++++++- src/jngl/TextLine.cpp | 4 +--- src/jngl/font.hpp | 4 ++-- 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/jngl/Achievement.hpp b/src/jngl/Achievement.hpp index e068f178a..0edde5369 100644 --- a/src/jngl/Achievement.hpp +++ b/src/jngl/Achievement.hpp @@ -1,16 +1,17 @@ -// Copyright 2023 Jan Niklas Hasse +// Copyright 2023-2024 Jan Niklas Hasse // For conditions of distribution and use, see copyright notice in LICENSE.txt /// Contains jngl::Achievement class /// @file #pragma once -#include +#include #include namespace jngl { class Sprite; +/// Unlockable Achievement (also called Trophy) struct Achievement { Achievement(std::string id, std::string name, std::string description, std::string icon, int initialValue = 0, int maxValue = 1); diff --git a/src/jngl/Channel.hpp b/src/jngl/Channel.hpp index 22acfa0fd..20dba693f 100644 --- a/src/jngl/Channel.hpp +++ b/src/jngl/Channel.hpp @@ -13,6 +13,18 @@ namespace jngl { struct Stream; /// An audio channel, different channels could be for example: "Music", "Speech" and "Sound Effects" +/// +/// Example: +/// \code +/// struct Channels : public jngl::Singleton { +/// jngl::Channel& main = jngl::Channel::main(); +/// jngl::Channel music; +/// jngl::Channel speech; +/// }; +/// +/// // somewhere else: +/// Channels::handle().music.loop("background_music01.ogg"); +/// \endcode class Channel { public: Channel(); diff --git a/src/jngl/SoundFile.hpp b/src/jngl/SoundFile.hpp index ff93b2ef7..e6fd18a92 100644 --- a/src/jngl/SoundFile.hpp +++ b/src/jngl/SoundFile.hpp @@ -25,7 +25,7 @@ struct SoundParams; /// Sound loaded from an OGG file /// /// JNGL keeps a list of loaded sound files, so there's no need for you to use this class directly - -/// you can just use jngl::play. +/// you can just use jngl::play or Channel::play. class SoundFile { public: /// Load an OGG file called \a filename @@ -45,10 +45,17 @@ class SoundFile { /// Play the sound once. If called twice the sound would also play twice void play(); + + /// Play the sound once on the Channel void play(Channel&); /// Stop the last started sound void stop(); + + /// Stop the last started sound of this SoundFile started on the Channel + /// + /// \note If not using the main Channel (i.e. Channel::main()), this method should be used + /// instead of stop(). void stop(Channel&); /// Whether the sound is still playing at least once diff --git a/src/jngl/TextLine.cpp b/src/jngl/TextLine.cpp index 6b78980d5..a1a9d8990 100644 --- a/src/jngl/TextLine.cpp +++ b/src/jngl/TextLine.cpp @@ -1,4 +1,4 @@ -// Copyright 2020-2023 Jan Niklas Hasse +// Copyright 2020-2024 Jan Niklas Hasse // For conditions of distribution and use, see copyright notice in LICENSE.txt #include "TextLine.hpp" @@ -6,8 +6,6 @@ #include "../freetype.hpp" #include "ScaleablePixels.hpp" #include "font.hpp" -#include "matrix.hpp" -#include "screen.hpp" namespace jngl { diff --git a/src/jngl/font.hpp b/src/jngl/font.hpp index 024e8f51e..d458afd9b 100644 --- a/src/jngl/font.hpp +++ b/src/jngl/font.hpp @@ -25,8 +25,8 @@ class Font { /// This can be used to draw an outlined text by e.g. first drawing with a 5% stroke and then /// printing the same text with 0% (or even a negative stroke) over it. /// - /// Example: To increase the size of each character by 2px for a Font with a \a size of 20px - /// pixel, you would pass 10.f for \a strokePercentage. + /// Example: To increase the size of each character by 2px for a Font with a \a size of 20px, + /// you would pass 10.f for \a strokePercentage. Font(const std::string& filename, unsigned int size, float strokePercentage = 0); /// Uses the font to print something at \a x \a y. The color can be specified using setFontColor. From cb68494e5c714a3cb791e1dbeb34428479fabd83 Mon Sep 17 00:00:00 2001 From: Jan Niklas Hasse Date: Sun, 12 May 2024 11:34:11 +0200 Subject: [PATCH 2/3] Android: Gradle 8.6 --- android/test/build.gradle | 2 +- android/test/gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/android/test/build.gradle b/android/test/build.gradle index 36b2ac490..2521163ad 100644 --- a/android/test/build.gradle +++ b/android/test/build.gradle @@ -5,7 +5,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:8.3.2' + classpath 'com.android.tools.build:gradle:8.4.0' } } diff --git a/android/test/gradle/wrapper/gradle-wrapper.properties b/android/test/gradle/wrapper/gradle-wrapper.properties index 3fa8f862f..a80b22ce5 100644 --- a/android/test/gradle/wrapper/gradle-wrapper.properties +++ b/android/test/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME From 4dbc8ee13a806898fbbf97e70913fb1e616cf448 Mon Sep 17 00:00:00 2001 From: Jan Niklas Hasse Date: Sun, 12 May 2024 14:32:46 +0200 Subject: [PATCH 3/3] Disable SDL2 fullscreen bug workaround on newer Linux versions Otherwise the scaling is wrong for HiDPI displays. --- src/sdl/window.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/sdl/window.cpp b/src/sdl/window.cpp index 8c4fb3e43..3c236b248 100644 --- a/src/sdl/window.cpp +++ b/src/sdl/window.cpp @@ -98,9 +98,10 @@ Window::Window(const std::string& title, int width, int height, const bool fulls } } -#ifndef __linux__ // This code was written for UWP, Emscripten and macOS (annoying HiDPI scaling by - // SDL2). On Linux (GNOME) it results in the top of the window being cut off (by - // the header bar height?). +#if !defined(__linux__) || SDL_VERSION_ATLEAST(2, 30, 0) + // This code was written for UWP, Emscripten and macOS (annoying HiDPI scaling by SDL2). On + // Linux (GNOME) it results in the top of the window being cut off (by the header bar height?). + // The bug seems to be fixed in newer SDL2 (or GNOME) versions. { assert(width_ == width); assert(height_ == height);