[update] Implemented creating a context of music.
This commit is contained in:
parent
a6ad04b8d2
commit
52a2159300
@ -19,7 +19,7 @@ int main(string[] unparsed_args) {
|
||||
if (!ParseArgs(unparsed_args, args)) return 1;
|
||||
|
||||
auto win = CreateWindow(args);
|
||||
auto game = new Game;
|
||||
auto game = new Game(args);
|
||||
scope(exit) game.destroy();
|
||||
|
||||
while (true) {
|
||||
|
@ -7,6 +7,7 @@ import std.algorithm,
|
||||
std.path;
|
||||
|
||||
import sj.AbstractGame,
|
||||
sj.Args,
|
||||
sj.FontSet,
|
||||
sj.LoadingScene,
|
||||
sj.LobbyWorld,
|
||||
@ -19,7 +20,7 @@ import sj.AbstractGame,
|
||||
class Game : AbstractGame {
|
||||
public:
|
||||
///
|
||||
this() {
|
||||
this(in ref Args args) {
|
||||
const path = thisExePath.dirName;
|
||||
|
||||
const music_dir = buildPath(path, "music");
|
||||
@ -35,7 +36,7 @@ class Game : AbstractGame {
|
||||
|
||||
title_ = new TitleScene(lobby_, programs_);
|
||||
select_ = new SelectScene(lobby_, programs_, fonts_, music_list_);
|
||||
load_ = new LoadingScene(lobby_, programs_, fonts_);
|
||||
load_ = new LoadingScene(args, lobby_, programs_, fonts_);
|
||||
|
||||
title_ .SetupSceneDependency(select_);
|
||||
select_.SetupSceneDependency(title_, load_);
|
||||
|
@ -1,7 +1,10 @@
|
||||
/// License: MIT
|
||||
module sj.LoadingScene;
|
||||
|
||||
import sj.FontSet,
|
||||
import gl4d;
|
||||
|
||||
import sj.Args,
|
||||
sj.FontSet,
|
||||
sj.KeyInput,
|
||||
sj.LobbyWorld,
|
||||
sj.Music,
|
||||
@ -12,7 +15,12 @@ import sj.FontSet,
|
||||
class LoadingScene : SceneInterface {
|
||||
public:
|
||||
///
|
||||
this(LobbyWorld lobby, ProgramSet programs, FontSet fonts) {
|
||||
this(
|
||||
in ref Args args,
|
||||
LobbyWorld lobby,
|
||||
ProgramSet programs,
|
||||
FontSet fonts) {
|
||||
args_ = args;
|
||||
lobby_ = lobby;
|
||||
programs_ = programs;
|
||||
fonts_ = fonts;
|
||||
@ -26,18 +34,34 @@ class LoadingScene : SceneInterface {
|
||||
|
||||
///
|
||||
void Initialize(Music music) {
|
||||
music_ = music;
|
||||
|
||||
first_drawn_ = false;
|
||||
}
|
||||
override SceneInterface Update(KeyInput input) {
|
||||
if (first_drawn_) {
|
||||
// TODO: parallelize contex creation
|
||||
// auto context = music_.CreatePlayerContext(
|
||||
// vec2i(args_.window_size, args_.window_size), programs_.player);
|
||||
// TODO: pass the context to play scene
|
||||
}
|
||||
return this;
|
||||
}
|
||||
override void Draw() {
|
||||
lobby_.Draw();
|
||||
first_drawn_ = true;
|
||||
}
|
||||
|
||||
private:
|
||||
const Args args_;
|
||||
|
||||
LobbyWorld lobby_;
|
||||
|
||||
ProgramSet programs_;
|
||||
|
||||
FontSet fonts_;
|
||||
|
||||
Music music_;
|
||||
|
||||
bool first_drawn_;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ module sj.Music;
|
||||
import std.array,
|
||||
std.conv,
|
||||
std.exception,
|
||||
std.file,
|
||||
std.json,
|
||||
std.path,
|
||||
std.string;
|
||||
@ -80,8 +81,10 @@ class Music {
|
||||
}
|
||||
|
||||
///
|
||||
sjplayer.Context CreatePlayerContext() const {
|
||||
assert(false); // TODO:
|
||||
sjplayer.Context CreatePlayerContext(
|
||||
vec2i winsz, sjplayer.ProgramSet programs) const {
|
||||
return sjplayer.CreateContextFromText(
|
||||
script_path_.readText, winsz, programs);
|
||||
}
|
||||
|
||||
///
|
||||
|
@ -21,13 +21,13 @@ class ProgramSet {
|
||||
|
||||
///
|
||||
this() {
|
||||
for_player_ = new sjplayer.ProgramSet;
|
||||
player_ = new sjplayer.ProgramSet;
|
||||
foreach (ref p; programs_) {
|
||||
p = new typeof(p);
|
||||
}
|
||||
}
|
||||
~this() {
|
||||
for_player_.destroy();
|
||||
player_.destroy();
|
||||
foreach (p; programs_) {
|
||||
p.destroy();
|
||||
}
|
||||
@ -39,12 +39,17 @@ class ProgramSet {
|
||||
static if (index >= 0) {
|
||||
return programs_[index];
|
||||
} else {
|
||||
return for_player_.Get!T;
|
||||
return player_.Get!T;
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
@property sjplayer.ProgramSet player() {
|
||||
return player_;
|
||||
}
|
||||
|
||||
private:
|
||||
sjplayer.ProgramSet for_player_;
|
||||
sjplayer.ProgramSet player_;
|
||||
|
||||
Programs programs_;
|
||||
}
|
||||
|
Reference in New Issue
Block a user