Skip to content

Commit

Permalink
Merge branch 'master' of github.com:jhasse/jngl
Browse files Browse the repository at this point in the history
  • Loading branch information
jhasse committed May 18, 2024
2 parents 455ac41 + 4dbc8ee commit d8e3dd4
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/jngl/Achievement.hpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
// Copyright 2023 Jan Niklas Hasse <jhasse@bixense.com>
// Copyright 2023-2024 Jan Niklas Hasse <jhasse@bixense.com>
// For conditions of distribution and use, see copyright notice in LICENSE.txt
/// Contains jngl::Achievement class
/// @file
#pragma once

#include <future>
#include <functional>
#include <string>

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);
Expand Down
12 changes: 12 additions & 0 deletions src/jngl/Channel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Channels> {
/// 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();
Expand Down
9 changes: 8 additions & 1 deletion src/jngl/SoundFile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/jngl/TextLine.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// Copyright 2020-2023 Jan Niklas Hasse <jhasse@bixense.com>
// Copyright 2020-2024 Jan Niklas Hasse <jhasse@bixense.com>
// For conditions of distribution and use, see copyright notice in LICENSE.txt

#include "TextLine.hpp"

#include "../freetype.hpp"
#include "ScaleablePixels.hpp"
#include "font.hpp"
#include "matrix.hpp"
#include "screen.hpp"

namespace jngl {

Expand Down
4 changes: 2 additions & 2 deletions src/jngl/font.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 4 additions & 3 deletions src/sdl/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d8e3dd4

Please sign in to comment.