mirror of
https://github.com/Kapendev/parin.git
synced 2025-04-26 13:09:56 +03:00
Removed a dependency from container and added basic audio support.
This commit is contained in:
parent
5260610fb4
commit
67a58418aa
2 changed files with 50 additions and 6 deletions
|
@ -7,7 +7,6 @@
|
|||
module popka.core.container;
|
||||
|
||||
import lib = core.stdc.stdlib;
|
||||
import popka.core.fmt;
|
||||
|
||||
@safe @nogc nothrow:
|
||||
|
||||
|
@ -168,9 +167,9 @@ struct FlagList(T) {
|
|||
openIndex = list.openIndex;
|
||||
}
|
||||
|
||||
ref T opIndex(size_t i, const(char)[] file = __FILE__, size_t line = __LINE__) {
|
||||
ref T opIndex(size_t i) {
|
||||
if (!flags[i]) {
|
||||
assert(0, "{}({}): ID {} doesn't exist.".fmt(file, line, i));
|
||||
assert(0, "ID doesn't exist.");
|
||||
}
|
||||
return data[i];
|
||||
}
|
||||
|
@ -183,7 +182,7 @@ struct FlagList(T) {
|
|||
|
||||
void opIndexOpAssign(string op)(T rhs, size_t i, const(char)[] file = __FILE__, size_t line = __LINE__) {
|
||||
if (!flags[i]) {
|
||||
assert(0, "{}({}): ID {} doesn't exist.".fmt(file, line, i));
|
||||
assert(0, "ID doesn't exist.");
|
||||
}
|
||||
mixin("data[i] " ~ op ~ "= rhs;");
|
||||
}
|
||||
|
@ -219,9 +218,9 @@ struct FlagList(T) {
|
|||
}
|
||||
}
|
||||
|
||||
void remove(size_t i, const(char)[] file = __FILE__, size_t line = __LINE__) {
|
||||
void remove(size_t i) {
|
||||
if (!flags[i]) {
|
||||
assert(0, "{}({}): ID {} doesn't exist.".fmt(file, line, i));
|
||||
assert(0, "ID doesn't exist.");
|
||||
}
|
||||
flags[i] = false;
|
||||
hotIndex = i;
|
||||
|
|
|
@ -144,6 +144,51 @@ struct View {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: Needs a lot of testing and changing.
|
||||
// NOTE: This should handle sounds and music.
|
||||
// NOTE: I added this basic layer to use it for a visual novel.
|
||||
struct AudioAsset {
|
||||
ray.Music data;
|
||||
|
||||
@safe @nogc nothrow:
|
||||
|
||||
this(const(char)[] path) {
|
||||
load(path);
|
||||
}
|
||||
|
||||
bool isEmpty() {
|
||||
return data.stream.sampleRate == 0;
|
||||
}
|
||||
|
||||
void load(const(char)[] path) {
|
||||
free();
|
||||
ray.LoadMusicStream(toStrz(path));
|
||||
}
|
||||
|
||||
void free() {
|
||||
if (!isEmpty) {
|
||||
ray.UnloadMusicStream(data);
|
||||
data = ray.Music();
|
||||
}
|
||||
}
|
||||
|
||||
void play() {
|
||||
ray.PlayMusicStream(data);
|
||||
}
|
||||
|
||||
void stop() {
|
||||
ray.StopMusicStream(data);
|
||||
}
|
||||
|
||||
void pause() {
|
||||
ray.PauseMusicStream(data);
|
||||
}
|
||||
|
||||
void resume() {
|
||||
ray.ResumeMusicStream(data);
|
||||
}
|
||||
}
|
||||
|
||||
struct TileMap {
|
||||
Grid!short data;
|
||||
alias data this;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue