mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-10 04:31:34 -10:00
Several handle types in the scripting API used inheritance where composition would be more appropriate. This refactors those types, as well as removing the various handle types that were just aliases for `model_h`. These are just the C++-side types; all the Lua types remain as-is. This also refactors `sound_h` to move the previous `isSoundValid` to `isValid` so that `ade_set_args` will work properly for sounds with the `Lua_API_returns_nil_instead_of_invalid_object` flag. The subclassing from `sound_entry_h` was removed and the "full validity check" was moved to `isValidWithEntry`. The Lua side remains unaffected, but additional documentation was added to clarify the usage. Follow-up to #6009 and prerequisite to #6006 due to the `isValid` refactor for `sound_h`.
62 lines
970 B
C++
62 lines
970 B
C++
#pragma once
|
|
|
|
#include <sound/ds.h>
|
|
#include "scripting/ade_api.h"
|
|
#include "gamesnd/gamesnd.h"
|
|
#include "sound/sound.h"
|
|
|
|
namespace scripting {
|
|
namespace api {
|
|
|
|
|
|
struct sound_entry_h
|
|
{
|
|
gamesnd_id idx;
|
|
|
|
sound_entry_h();
|
|
|
|
explicit sound_entry_h(gamesnd_id n_idx);
|
|
|
|
game_snd *Get() const;
|
|
|
|
bool isValid() const;
|
|
};
|
|
|
|
//**********HANDLE: SoundEntry
|
|
DECLARE_ADE_OBJ(l_SoundEntry, sound_entry_h);
|
|
|
|
struct sound_h
|
|
{
|
|
sound_entry_h entryh;
|
|
sound_handle sig;
|
|
|
|
sound_h();
|
|
|
|
sound_h(gamesnd_id n_gs_idx, sound_handle n_sig);
|
|
|
|
sound_handle getSignature() const;
|
|
|
|
bool isValid() const; // This is the function that is checked by ade_set_args
|
|
bool isValidWithEntry() const;
|
|
};
|
|
|
|
//**********HANDLE: Sound
|
|
DECLARE_ADE_OBJ(l_Sound, sound_h);
|
|
|
|
|
|
DECLARE_ADE_OBJ(l_Sound3D, sound_h);
|
|
|
|
|
|
//**********HANDLE: Soundfile
|
|
|
|
struct soundfile_h {
|
|
sound_load_id idx;
|
|
|
|
explicit soundfile_h(sound_load_id id = sound_load_id::invalid());
|
|
};
|
|
|
|
DECLARE_ADE_OBJ(l_Soundfile, soundfile_h);
|
|
}
|
|
}
|
|
|