[update] Added a description at SelectScene.

This commit is contained in:
falsycat 2019-10-14 00:00:00 +00:00
parent 8064cdb40e
commit 0f4c3dcc77

View File

@ -27,22 +27,40 @@ import sj.FontSet,
/// ///
class SelectScene : SceneInterface { class SelectScene : SceneInterface {
public: public:
///
enum DescTextScale = vec3(-0.002, 0.002, 0.002);
///
enum DescTextTranslation = vec3(0, -0.3, 0);
///
enum DescTextColor = vec4(0.02, 0.02, 0.02, 1);
/// ///
this(LobbyWorld lobby, ProgramSet program, FontSet fonts, Music[] music_list) { this(LobbyWorld lobby, ProgramSet program, FontSet fonts, Music[] music_list) {
lobby_ = lobby; lobby_ = lobby;
music_list_ = music_list.dup; music_list_ = music_list.dup;
text_ = new Text(program.Get!TextProgram);
fonts_ = fonts; fonts_ = fonts;
description_text_ = new Text(program.Get!TextProgram);
title_text_ = new Text(program.Get!TextProgram);
sound_ = sfSound_create(); sound_ = sfSound_create();
soundres_.Load(); soundres_.Load();
first_state_ = new FirstSetupState(this); first_state_ = new FirstSetupState(this);
status_ = first_state_; status_ = first_state_;
with (description_text_) {
const w = LoadGlyphs(
vec2i(256, 32), "MUSIC SELECT", vec2i(16, 0), fonts_.gothic);
matrix.scale = DescTextScale;
matrix.translation =
DescTextTranslation + vec3(-w/2*matrix.scale.x, 0, 0);
color = DescTextColor;
}
} }
~this() { ~this() {
text_.destroy(); description_text_.destroy();
title_text_.destroy();
sfSound_destroy(sound_); sfSound_destroy(sound_);
soundres_.Unload(); soundres_.Unload();
@ -72,7 +90,10 @@ class SelectScene : SceneInterface {
} }
override void Draw() { override void Draw() {
lobby_.Draw(); lobby_.Draw();
text_.Draw(lobby_.Projection, lobby_.view.Create());
const view = lobby_.view.Create();
description_text_.Draw(lobby_.Projection, view);
title_text_ .Draw(lobby_.Projection, view);
} }
private: private:
@ -95,7 +116,8 @@ class SelectScene : SceneInterface {
LobbyWorld lobby_; LobbyWorld lobby_;
Text text_; Text description_text_;
Text title_text_;
FontSet fonts_; FontSet fonts_;
Music[] music_list_; Music[] music_list_;
@ -164,7 +186,7 @@ private class FirstSetupState : AbstractSceneState {
cube_interval_ease_ = Easing!float(cube_interval, LoadingCubeInterval); cube_interval_ease_ = Easing!float(cube_interval, LoadingCubeInterval);
} }
owner.text_.Clear(); owner.title_text_.Clear();
} }
override UpdateResult Update(KeyInput input) { override UpdateResult Update(KeyInput input) {
const ratio = anime_.Update(); const ratio = anime_.Update();
@ -223,7 +245,7 @@ private class MusicAppearState : AbstractSceneState {
sfSound_play(owner.sound_); sfSound_play(owner.sound_);
const music = owner.music_list_[music_index_]; const music = owner.music_list_[music_index_];
with (owner.text_) { with (owner.title_text_) {
const w = LoadGlyphs(vec2i(1024, 64), const w = LoadGlyphs(vec2i(1024, 64),
music.name.to!dstring, vec2i(TitleTextSize, 0), owner.fonts_.gothic); music.name.to!dstring, vec2i(TitleTextSize, 0), owner.fonts_.gothic);
matrix.scale = TitleTextScale; matrix.scale = TitleTextScale;
@ -272,7 +294,7 @@ private class MusicWaitState : AbstractSceneState {
music_index_ = music_index; music_index_ = music_index;
music.PlayForPreview(); music.PlayForPreview();
with (owner.text_) { with (owner.title_text_) {
matrix.scale = TitleTextScale; matrix.scale = TitleTextScale;
matrix.translation = matrix.translation =
TitleTextTranslation + vec3(-modelWidth/2*matrix.scale.x, 0, 0); TitleTextTranslation + vec3(-modelWidth/2*matrix.scale.x, 0, 0);