Skip to content

Commit

Permalink
WIP UI: Add left side panel, with tabs, UI tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-r-elp committed Jul 23, 2024
1 parent c5e2144 commit 258d395
Show file tree
Hide file tree
Showing 9 changed files with 318 additions and 24 deletions.
24 changes: 24 additions & 0 deletions assets/ConfigMenuSelectionViewController.bsml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<vertical bg="round-rect-panel" min-width="80" min-height="40" child-control-height="false" horizontal-fit="PreferredSize" vertical-fit="PreferredSize" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='https://raw.githubusercontent.com/RedBrumbler/Quest-BSML-Docs/gh-pages/schema.xsd'>
<tab-selector tab-tag='main' pad-top="2" />
<tab tags='main' tab-name='Menu and BGM' >
<vertical pad-left="3" pad-right="3" pad-top="2" pad-bottom="2" horizontal-fit="PreferredSize" vertical-fit="PreferredSize">
<button text="Menu Music" pref-width="50" on-click="MenuMusicButtonPressed" />
<button text="Lobby Music" pref-width="50" on-click="LobbyMusicButtonPressed" />
<button text="Menu Clicks" pref-width="50" on-click="MenuClickButtonPressed" />
</vertical>
</tab>
<tab tags='main' tab-name='Notes' >
<vertical pad-left="3" pad-right="3" pad-top="2" pad-bottom="2" horizontal-fit="PreferredSize" vertical-fit="PreferredSize">
<button text="Hit Sounds" pref-width="50" on-click="HitSoundButtonPressed" />
<button text="Bad Hit Sounds" pref-width="50" on-click="BadHitSoundButtonPressed" />
<button text="Miss Sounds" pref-width="50" on-click="MissSoundButtonPressed" />
</vertical>
</tab>
<tab tags='main' tab-name='Level Results' >
<vertical pad-left="3" pad-right="3" pad-top="2" pad-bottom="2" horizontal-fit="PreferredSize" vertical-fit="PreferredSize">
<button text="Level Cleared Sound" pref-width="50" on-click="LevelClearedButtonPressed" />
<button text="Level Failed" pref-width="50" on-click="LevelFailedButtonPressed" />
<button text="Firworks" pref-width="50" on-click="FireworkButtonPressed" />
</vertical>
</tab>
</vertical>
39 changes: 23 additions & 16 deletions assets/SoundSettingsViewController.bsml
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
<vertical spacing='0.4' min-width='125.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='https://raw.githubusercontent.com/RedBrumbler/Quest-BSML-Docs/gh-pages/schema.xsd'>
<vertical child-align='UpperCenter' child-expand-height='false' child-control-height='true' >
<toggle-setting id='SoundEnabled' text='Sound Enabled' hover-hint='Activates or deactivates this custom sound' value='Active' apply-on-change='true' />
<slider-setting id='SoundVolumeOffset' text='Volume Offset' hover-hint='Lets you select a Volume Offset that is applied to the sound (Preview volume does not necessarily match volume played in-map)' value='VolumeOffset' min='-1.0' max='1.0' increment='0.01' show-buttons='true' apply-on-change='true' active='false' />
<slider-setting id='SoundBeatOffset' text='Hit Sound Offset' hover-hint='Sets a custom HitSound beatOffSet (default: 0.185 ms)' value='BeatOffset' digits='3' min='0.0' max='0.25' increment='0.001' show-buttons='true' apply-on-change='true' active='false' />
<scroll-view min-height='56' >
<vertical id='Sounds' child-align='UpperCenter' child-expand-height='false' child-control-height='true' >
</vertical>
<macro.if value='HasSoundFiles'>
<macro.for-each items='SoundFiles'>
<macro.if value='!IsSetup'>
<horizontal id="NotSetupHorizontal">
<text text='Please select a sound you want to edit on the left panel.' />
</horizontal>
</macro.if>
<macro.if value='IsSetup'>
<toggle-setting id='SoundEnabled' text='Sound Enabled' hover-hint='Activates or deactivates this custom sound' value='Active' apply-on-change='true' />
<slider-setting id='SoundVolumeOffset' text='Volume Offset' hover-hint='Lets you select a Volume Offset that is applied to the sound (Preview volume does not necessarily match volume played in-map)' value='VolumeOffset' min='-1.0' max='1.0' increment='0.01' show-buttons='true' apply-on-change='true' active='false' />
<slider-setting id='SoundBeatOffset' text='Hit Sound Offset' hover-hint='Sets a custom HitSound beatOffSet (default: 0.185 ms)' value='BeatOffset' digits='3' min='0.0' max='0.25' increment='0.001' show-buttons='true' apply-on-change='true' active='false' />
<scroll-view id='SDListScroll' min-height='56' >
<vertical id='Sounds' child-align='UpperCenter' child-expand-height='false' child-control-height='true' >
</vertical>
<macro.if value='HasSoundFiles'>
<!-- <macro.for-each items='SoundFiles'>

</macro.for-each>
</macro.if>
<macro.if value='!HasSoundFiles'>
<horizontal>
<text rich-text='true' text='No sound files were found\nPlease add some sound files' />
</horizontal>
</macro.if>
</scroll-view>
</macro.for-each> -->
</macro.if>
<macro.if value='!HasSoundFiles'>
<horizontal>
<text rich-text='true' text='No sound files were found.&#xA;Please add some sound files.' />
</horizontal>
</macro.if>
</scroll-view>
</macro.if>
</vertical>
</vertical>
30 changes: 30 additions & 0 deletions include/UI/ConfigMenuSelectionViewController.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once

#include "custom-types/shared/macros.hpp"
#include "bsml/shared/macros.hpp"

#include "HMUI/ViewController.hpp"

DECLARE_CLASS_CODEGEN(QuestSounds::UI, ConfigMenuSelectionViewController, HMUI::ViewController,
// DECLARE_INSTANCE_FIELD(ListW<BSML::CustomCellInfo*>, _menus);
// DECLARE_INSTANCE_FIELD(BSML::CustomListTableData*, menuList);

DECLARE_OVERRIDE_METHOD_MATCH(void, DidActivate, &HMUI::ViewController::DidActivate, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling);
// DECLARE_OVERRIDE_METHOD_MATCH(void, DidDeactivate, &HMUI::ViewController::DidDeactivate, bool removedFromHierarchy, bool screenSystemDisabling);

DECLARE_INSTANCE_METHOD(void, MenuMusicButtonPressed);
DECLARE_INSTANCE_METHOD(void, LobbyMusicButtonPressed);
DECLARE_INSTANCE_METHOD(void, MenuClickButtonPressed);
DECLARE_INSTANCE_METHOD(void, HitSoundButtonPressed);
DECLARE_INSTANCE_METHOD(void, BadHitSoundButtonPressed);
DECLARE_INSTANCE_METHOD(void, MissSoundButtonPressed);
DECLARE_INSTANCE_METHOD(void, LevelClearedButtonPressed);
DECLARE_INSTANCE_METHOD(void, LevelFailedButtonPressed);
DECLARE_INSTANCE_METHOD(void, FireworkButtonPressed);

DECLARE_CTOR(ctor);

public:
void set_selectCallback(std::function<void(int)> callback);
std::function<void(int)> callback;
)
5 changes: 5 additions & 0 deletions include/UI/QuestSoundsFlowCoordinator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "HMUI/FlowCoordinator.hpp"

#include "UI/ConfigMenuSelectionViewController.hpp"
#include "UI/SoundSettingsViewController.hpp"

#include "GlobalNamespace/MainFlowCoordinator.hpp"
Expand All @@ -13,11 +14,15 @@

DECLARE_CLASS_CODEGEN(QuestSounds::UI, QuestSoundsFlowCoordinator, HMUI::FlowCoordinator,

DECLARE_INSTANCE_FIELD(QuestSounds::UI::ConfigMenuSelectionViewController*, configMenuSelectionViewController);
DECLARE_INSTANCE_FIELD(QuestSounds::UI::SoundSettingsViewController*, soundSettingsViewController);

DECLARE_INSTANCE_METHOD(void, Awake);
DECLARE_OVERRIDE_METHOD_MATCH(void, DidActivate, &HMUI::FlowCoordinator::DidActivate, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling);
DECLARE_OVERRIDE_METHOD_MATCH(void, DidDeactivate, &HMUI::FlowCoordinator::DidDeactivate, bool removedFromHierarchy, bool screenSystemDisabling);
DECLARE_OVERRIDE_METHOD_MATCH(void, BackButtonWasPressed, &HMUI::FlowCoordinator::BackButtonWasPressed, HMUI::ViewController* topViewController);

DECLARE_INSTANCE_METHOD(void, SubMenuButtonPressed, int index);

DECLARE_DEFAULT_CTOR();
)
13 changes: 13 additions & 0 deletions include/UI/SoundSettingsViewController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

#include "custom-types/shared/macros.hpp"
#include "bsml/shared/macros.hpp"
#include "bsml/shared/BSML/Components/Settings/ToggleSetting.hpp"
#include "bsml/shared/BSML/Components/Settings/IncrementSetting.hpp"
#include "bsml/shared/BSML/Components/Settings/SliderSetting.hpp"
#include "bsml/shared/BSML/Components/CustomListTableData.hpp"

#include "Config.hpp"
#include "Utils/AsyncAudioClipLoader.hpp"

#include "UnityEngine/UI/HorizontalLayoutGroup.hpp"

#include "HMUI/ViewController.hpp"

DECLARE_CLASS_CODEGEN(QuestSounds::UI, SoundSettingsViewController, HMUI::ViewController,
Expand All @@ -19,16 +23,25 @@ DECLARE_CLASS_CODEGEN(QuestSounds::UI, SoundSettingsViewController, HMUI::ViewCo
DECLARE_BSML_PROPERTY(float, VolumeOffset);
DECLARE_BSML_PROPERTY(float, BeatOffset);
DECLARE_BSML_PROPERTY(bool, HasSoundFiles);
DECLARE_BSML_PROPERTY(bool, IsSetup);

DECLARE_INSTANCE_FIELD(ListW<BSML::CustomCellInfo*>, _Sounds);
DECLARE_INSTANCE_METHOD(ListW<BSML::CustomCellInfo*>, get_Sounds);
DECLARE_INSTANCE_FIELD(BSML::CustomListTableData*, soundList);

DECLARE_INSTANCE_FIELD(BSML::ToggleSetting*, SoundEnabled);
DECLARE_INSTANCE_FIELD(BSML::SliderSetting*, SoundVolumeOffset);
DECLARE_INSTANCE_FIELD(BSML::SliderSetting*, SoundBeatOffset);
DECLARE_INSTANCE_FIELD(UnityEngine::UI::HorizontalLayoutGroup*, NotSetupHorizontal);

DECLARE_INSTANCE_FIELD(bool, showSoundVolumeOffset);
DECLARE_INSTANCE_FIELD(bool, showSoundBeatOffset);

DECLARE_OVERRIDE_METHOD_MATCH(void, DidActivate, &HMUI::ViewController::DidActivate, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling);
DECLARE_OVERRIDE_METHOD_MATCH(void, DidDeactivate, &HMUI::ViewController::DidDeactivate, bool removedFromHierarchy, bool screenSystemDisabling);

DECLARE_CTOR(ctor);

public:
void Setup(std::string name, QuestSounds::Sound* sound, QuestSounds::Utils::AsyncAudioClipLoader* loader);
)
1 change: 1 addition & 0 deletions include/assets.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include "kaleb/shared/kaleb.hpp"

DECLARE_FILE(_binary_ConfigMenuSelectionViewController_bsml, Assets, ConfigMenuSelectionViewController_bsml);
DECLARE_FILE(_binary_SoundSettingsViewController_bsml, Assets, SoundSettingsViewController_bsml);
92 changes: 92 additions & 0 deletions src/UI/ConfigMenuSelectionViewController.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#include "UI/ConfigMenuSelectionViewController.hpp"
#include "assets.hpp"
#include "logging.hpp"

#include "bsml/shared/BSML.hpp"

DEFINE_TYPE(QuestSounds::UI, ConfigMenuSelectionViewController);

namespace QuestSounds::UI {
void ConfigMenuSelectionViewController::ctor() {
// _menus = ListW<BSML::CustomCellInfo*>();
getLogger().info("ctor");
return;
}

void ConfigMenuSelectionViewController::DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) {
getLogger().info("DidActivate");
if (firstActivation) {
getLogger().info("DidActivate firstActivation");
BSML::parse_and_construct(Assets::ConfigMenuSelectionViewController_bsml, get_transform(), this);
}
return;
}

void ConfigMenuSelectionViewController::set_selectCallback(std::function<void(int)> callback) {
getLogger().info("Setting selectCallback");
this->callback = callback;
}

void ConfigMenuSelectionViewController::MenuMusicButtonPressed() {
getLogger().info("MenuMusicButtonPressed");
if (callback) {
callback(0);
}
}

void ConfigMenuSelectionViewController::LobbyMusicButtonPressed() {
getLogger().info("LobbyMusicButtonPressed");
if (callback) {
callback(1);
}
}

void ConfigMenuSelectionViewController::MenuClickButtonPressed() {
getLogger().info("MenuClickButtonPressed");
if (callback) {
callback(2);
}
}

void ConfigMenuSelectionViewController::HitSoundButtonPressed() {
getLogger().info("HitSoundButtonPressed");
if (callback) {
callback(3);
}
}

void ConfigMenuSelectionViewController::BadHitSoundButtonPressed() {
getLogger().info("BadHitSoundButtonPressed");
if (callback) {
callback(4);
}
}

void ConfigMenuSelectionViewController::MissSoundButtonPressed() {
getLogger().info("MissSoundButtonPressed");
if (callback) {
callback(5);
}
}

void ConfigMenuSelectionViewController::LevelClearedButtonPressed() {
getLogger().info("LevelClearedButtonPressed");
if (callback) {
callback(6);
}
}

void ConfigMenuSelectionViewController::LevelFailedButtonPressed() {
getLogger().info("LevelFailedButtonPressed");
if (callback) {
callback(7);
}
}

void ConfigMenuSelectionViewController::FireworkButtonPressed() {
getLogger().info("FireworkButtonPressed");
if (callback) {
callback(8);
}
}
}
Loading

0 comments on commit 258d395

Please sign in to comment.