[add] Added LoadingScene.
This commit is contained in:
parent
0a18f7feae
commit
a6ad04b8d2
@ -8,6 +8,7 @@ import std.algorithm,
|
|||||||
|
|
||||||
import sj.AbstractGame,
|
import sj.AbstractGame,
|
||||||
sj.FontSet,
|
sj.FontSet,
|
||||||
|
sj.LoadingScene,
|
||||||
sj.LobbyWorld,
|
sj.LobbyWorld,
|
||||||
sj.Music,
|
sj.Music,
|
||||||
sj.ProgramSet,
|
sj.ProgramSet,
|
||||||
@ -25,6 +26,8 @@ class Game : AbstractGame {
|
|||||||
const music_list = buildPath(music_dir, "list.json").readText;
|
const music_list = buildPath(music_dir, "list.json").readText;
|
||||||
music_list_ = Music.CreateFromJson(music_list.parseJSON, music_dir);
|
music_list_ = Music.CreateFromJson(music_list.parseJSON, music_dir);
|
||||||
|
|
||||||
|
// To prevent working GC, all objects should be created at here.
|
||||||
|
|
||||||
fonts_ = new FontSet;
|
fonts_ = new FontSet;
|
||||||
programs_ = new ProgramSet;
|
programs_ = new ProgramSet;
|
||||||
|
|
||||||
@ -32,9 +35,11 @@ class Game : AbstractGame {
|
|||||||
|
|
||||||
title_ = new TitleScene(lobby_, programs_);
|
title_ = new TitleScene(lobby_, programs_);
|
||||||
select_ = new SelectScene(lobby_, programs_, fonts_, music_list_);
|
select_ = new SelectScene(lobby_, programs_, fonts_, music_list_);
|
||||||
|
load_ = new LoadingScene(lobby_, programs_, fonts_);
|
||||||
|
|
||||||
title_.SetupSceneDependency(select_);
|
title_ .SetupSceneDependency(select_);
|
||||||
select_.SetupSceneDependency(title_);
|
select_.SetupSceneDependency(title_, load_);
|
||||||
|
load_ .SetupSceneDependency(); // TODO: pass play scene
|
||||||
|
|
||||||
title_.Initialize();
|
title_.Initialize();
|
||||||
super(title_);
|
super(title_);
|
||||||
@ -43,6 +48,7 @@ class Game : AbstractGame {
|
|||||||
~this() {
|
~this() {
|
||||||
title_.destroy();
|
title_.destroy();
|
||||||
select_.destroy();
|
select_.destroy();
|
||||||
|
load_.destroy();
|
||||||
|
|
||||||
lobby_.destroy();
|
lobby_.destroy();
|
||||||
|
|
||||||
@ -60,6 +66,7 @@ class Game : AbstractGame {
|
|||||||
|
|
||||||
LobbyWorld lobby_;
|
LobbyWorld lobby_;
|
||||||
|
|
||||||
TitleScene title_;
|
TitleScene title_;
|
||||||
SelectScene select_;
|
SelectScene select_;
|
||||||
|
LoadingScene load_;
|
||||||
}
|
}
|
||||||
|
43
src/sj/LoadingScene.d
Normal file
43
src/sj/LoadingScene.d
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/// License: MIT
|
||||||
|
module sj.LoadingScene;
|
||||||
|
|
||||||
|
import sj.FontSet,
|
||||||
|
sj.KeyInput,
|
||||||
|
sj.LobbyWorld,
|
||||||
|
sj.Music,
|
||||||
|
sj.ProgramSet,
|
||||||
|
sj.SceneInterface;
|
||||||
|
|
||||||
|
///
|
||||||
|
class LoadingScene : SceneInterface {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
this(LobbyWorld lobby, ProgramSet programs, FontSet fonts) {
|
||||||
|
lobby_ = lobby;
|
||||||
|
programs_ = programs;
|
||||||
|
fonts_ = fonts;
|
||||||
|
}
|
||||||
|
~this() {
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
void SetupSceneDependency() { // TODO: add play scene
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
void Initialize(Music music) {
|
||||||
|
}
|
||||||
|
override SceneInterface Update(KeyInput input) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
override void Draw() {
|
||||||
|
lobby_.Draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
LobbyWorld lobby_;
|
||||||
|
|
||||||
|
ProgramSet programs_;
|
||||||
|
|
||||||
|
FontSet fonts_;
|
||||||
|
}
|
@ -12,6 +12,7 @@ import gl4d;
|
|||||||
|
|
||||||
import sj.FontSet,
|
import sj.FontSet,
|
||||||
sj.KeyInput,
|
sj.KeyInput,
|
||||||
|
sj.LoadingScene,
|
||||||
sj.LobbyWorld,
|
sj.LobbyWorld,
|
||||||
sj.Music,
|
sj.Music,
|
||||||
sj.ProgramSet,
|
sj.ProgramSet,
|
||||||
@ -48,8 +49,9 @@ class SelectScene : SceneInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
void SetupSceneDependency(TitleScene title_scene) {
|
void SetupSceneDependency(TitleScene title_scene, LoadingScene load_scene) {
|
||||||
title_scene_ = title_scene;
|
title_scene_ = title_scene;
|
||||||
|
load_scene_ = load_scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -88,7 +90,8 @@ class SelectScene : SceneInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TitleScene title_scene_;
|
TitleScene title_scene_;
|
||||||
|
LoadingScene load_scene_;
|
||||||
|
|
||||||
LobbyWorld lobby_;
|
LobbyWorld lobby_;
|
||||||
|
|
||||||
@ -267,8 +270,6 @@ private class MusicWaitState : AbstractSceneState {
|
|||||||
|
|
||||||
void Initialize(size_t music_index) {
|
void Initialize(size_t music_index) {
|
||||||
music_index_ = music_index;
|
music_index_ = music_index;
|
||||||
|
|
||||||
auto music = owner.music_list_[music_index_];
|
|
||||||
music.PlayForPreview();
|
music.PlayForPreview();
|
||||||
|
|
||||||
with (owner.text_) {
|
with (owner.text_) {
|
||||||
@ -285,6 +286,12 @@ private class MusicWaitState : AbstractSceneState {
|
|||||||
owner.title_scene_.Initialize();
|
owner.title_scene_.Initialize();
|
||||||
return CreateResult(owner.title_scene_);
|
return CreateResult(owner.title_scene_);
|
||||||
}
|
}
|
||||||
|
if (input.down) {
|
||||||
|
music.StopPlaying();
|
||||||
|
owner.load_scene_.Initialize(music);
|
||||||
|
return CreateResult(owner.load_scene_);
|
||||||
|
}
|
||||||
|
|
||||||
if (input.left && music_index_ != 0) {
|
if (input.left && music_index_ != 0) {
|
||||||
music.StopPlaying();
|
music.StopPlaying();
|
||||||
music_appear_state_.Initialize(music_index_-1);
|
music_appear_state_.Initialize(music_index_-1);
|
||||||
|
Reference in New Issue
Block a user