Browse Source

Add keybind to open skin selection menu

kiwec 2 months ago
parent
commit
e7843a0635

+ 2 - 0
src/App/Osu/Changelog.cpp

@@ -29,12 +29,14 @@ Changelog::Changelog() : ScreenBackable() {
     CHANGELOG latest;
     latest.title =
         UString::format("%.2f (%s, %s)", convar->getConVarByName("osu_version")->getFloat(), __DATE__, __TIME__);
+    latest.changes.push_back("- Added keybind to open skin selection menu");
     latest.changes.push_back("- Added slider instafade setting");
     latest.changes.push_back(
         "- Added \"tooearly.wav\" and \"toolate.wav\" hitsounds, which play when you hit too early or too late (if "
         "your skin has them)");
     latest.changes.push_back("- Fixed local scores not saving avatar");
     latest.changes.push_back("- Fixed Nightcore getting auto-selected instead of Double Time in some cases");
+    latest.changes.push_back("- Linux: fixed \"Skin.ini\" failing to load");
     changelogs.push_back(latest);
 
     CHANGELOG v35_09;

+ 2 - 0
src/App/Osu/KeyBindings.cpp

@@ -37,6 +37,7 @@ ConVar KeyBindings::SAVE_SCREENSHOT("osu_key_save_screenshot", (int)KEY_F12, FCV
 ConVar KeyBindings::DISABLE_MOUSE_BUTTONS("osu_key_disable_mouse_buttons", (int)KEY_F10, FCVAR_DEFAULT);
 ConVar KeyBindings::TOGGLE_MAP_BACKGROUND("key_toggle_map_background", 0, FCVAR_DEFAULT);
 ConVar KeyBindings::BOSS_KEY("osu_key_boss", (int)KEY_INSERT, FCVAR_DEFAULT);
+ConVar KeyBindings::OPEN_SKIN_SELECT_MENU("key_open_skin_select_menu", 0, FCVAR_DEFAULT);
 
 ConVar KeyBindings::TOGGLE_MODSELECT("osu_key_toggle_modselect", (int)KEY_F1, FCVAR_DEFAULT);
 ConVar KeyBindings::RANDOM_BEATMAP("osu_key_random_beatmap", (int)KEY_F2, FCVAR_DEFAULT);
@@ -83,6 +84,7 @@ std::vector<ConVar*> KeyBindings::ALL = {&KeyBindings::LEFT_CLICK,
                                          &KeyBindings::DISABLE_MOUSE_BUTTONS,
                                          &KeyBindings::TOGGLE_MAP_BACKGROUND,
                                          &KeyBindings::BOSS_KEY,
+                                         &KeyBindings::OPEN_SKIN_SELECT_MENU,
 
                                          &KeyBindings::TOGGLE_MODSELECT,
                                          &KeyBindings::RANDOM_BEATMAP,

+ 1 - 0
src/App/Osu/KeyBindings.h

@@ -43,6 +43,7 @@ class KeyBindings {
     static ConVar DISABLE_MOUSE_BUTTONS;
     static ConVar TOGGLE_MAP_BACKGROUND;
     static ConVar BOSS_KEY;
+    static ConVar OPEN_SKIN_SELECT_MENU;
 
     static ConVar TOGGLE_MODSELECT;
     static ConVar RANDOM_BEATMAP;

+ 30 - 10
src/App/Osu/OptionsMenu.cpp

@@ -994,6 +994,7 @@ OptionsMenu::OptionsMenu() : ScreenBackable() {
     addKeyBindButton("Disable Mouse Buttons", &KeyBindings::DISABLE_MOUSE_BUTTONS);
     addKeyBindButton("Toggle Map Background", &KeyBindings::TOGGLE_MAP_BACKGROUND);
     addKeyBindButton("Boss Key (Minimize)", &KeyBindings::BOSS_KEY);
+    addKeyBindButton("Open Skin Selection Menu", &KeyBindings::OPEN_SKIN_SELECT_MENU);
     addSubSection("Keys - Song Select", keyboardSectionTags);
     addKeyBindButton("Toggle Mod Selection Screen", &KeyBindings::TOGGLE_MODSELECT)
         ->setTooltipText("(F1 can not be unbound. This is just an additional key.)");
@@ -1390,7 +1391,10 @@ OptionsMenu::~OptionsMenu() {
 
 void OptionsMenu::draw(Graphics *g) {
     const bool isAnimating = anim->isAnimating(&m_fAnimation);
-    if(!m_bVisible && !isAnimating) return;
+    if(!m_bVisible && !isAnimating) {
+        m_contextMenu->draw(g);
+        return;
+    }
 
     m_sliderPreviewElement->setDrawSliderHack(!isAnimating);
 
@@ -1468,12 +1472,12 @@ void OptionsMenu::draw(Graphics *g) {
 }
 
 void OptionsMenu::mouse_update(bool *propagate_clicks) {
-    if(!m_bVisible) return;
-
     // force context menu focus
     m_contextMenu->mouse_update(propagate_clicks);
     if(!*propagate_clicks) return;
 
+    if(!m_bVisible) return;
+
     ScreenBackable::mouse_update(propagate_clicks);
     if(!*propagate_clicks) return;
 
@@ -1749,13 +1753,10 @@ void OptionsMenu::setVisibleInt(bool visible, bool fromOnBack) {
     m_bVisible = visible;
     osu->m_chat->updateVisibility();
 
-    if(visible)
+    if(visible) {
         updateLayout();
-    else {
+    } else {
         m_contextMenu->setVisible2(false);
-
-        // anim->deleteExistingAnimation(&m_fAnimation);
-        // m_fAnimation = 0.0f;
     }
 
     // usability: auto scroll to fposu settings if opening options while in fposu gamemode
@@ -2406,6 +2407,8 @@ void OptionsMenu::openCurrentSkinFolder() {
 }
 
 void OptionsMenu::onSkinSelect() {
+    // XXX: Instead of a dropdown, we should make a dedicated skin select screen with search bar
+
     updateOsuFolder();
 
     if(osu->isSkinLoading()) return;
@@ -2448,8 +2451,16 @@ void OptionsMenu::onSkinSelect() {
     }
 
     if(skinFolders.size() > 0) {
-        m_contextMenu->setPos(m_skinSelectLocalButton->getPos());
-        m_contextMenu->setRelPos(m_skinSelectLocalButton->getRelPos());
+        m_contextMenu->setVisible2(false);
+
+        if(m_bVisible) {
+            m_contextMenu->setPos(m_skinSelectLocalButton->getPos());
+            m_contextMenu->setRelPos(m_skinSelectLocalButton->getRelPos());
+        } else {
+            // Put it 50px from top, we'll move it later
+            m_contextMenu->setPos(Vector2{0, 100});
+        }
+
         m_contextMenu->begin();
 
         const UString defaultText = "default";
@@ -2465,6 +2476,15 @@ void OptionsMenu::onSkinSelect() {
         }
         m_contextMenu->end(false, true);
         m_contextMenu->setClickCallback(fastdelegate::MakeDelegate(this, &OptionsMenu::onSkinSelect2));
+
+        if(!m_bVisible) {
+            // Center context menu
+            m_contextMenu->setPos(Vector2{
+                osu->getScreenWidth() / 2.f - m_contextMenu->getSize().x / 2.f,
+                osu->getScreenHeight() / 2.f - m_contextMenu->getSize().y / 2.f,
+            });
+            m_contextMenu->setVisible(true);
+        }
     } else {
         osu->getNotificationOverlay()->addNotification("Error: Couldn't find any skins", 0xffff0000);
         m_options->scrollToTop();

+ 8 - 0
src/App/Osu/Osu.cpp

@@ -1227,6 +1227,12 @@ void Osu::onKeyDown(KeyboardEvent &key) {
         key.consume();
     }
 
+    if(key == (KEYCODE)KeyBindings::OPEN_SKIN_SELECT_MENU.getInt()) {
+        m_optionsMenu->onSkinSelect();
+        key.consume();
+        return;
+    }
+
     // disable mouse buttons hotkey
     if(key == (KEYCODE)KeyBindings::DISABLE_MOUSE_BUTTONS.getInt()) {
         if(osu_disable_mousebuttons.getBool()) {
@@ -1245,6 +1251,8 @@ void Osu::onKeyDown(KeyboardEvent &key) {
         } else {
             diff->draw_background = !diff->draw_background;
         }
+        key.consume();
+        return;
     }
 
     // F8 toggle chat

+ 2 - 4
src/App/Osu/Skin.cpp

@@ -486,7 +486,8 @@ void Skin::load() {
     // skin ini
     randomizeFilePath();
     m_sSkinIniFilePath = m_sFilePath;
-    m_sSkinIniFilePath.append("skin.ini");
+    m_sSkinIniFilePath.append(fix_filename_casing(m_sFilePath, "skin.ini"));
+
     bool parseSkinIni1Status = true;
     bool parseSkinIni2Status = true;
     if(!parseSkinINI(m_sSkinIniFilePath)) {
@@ -1589,7 +1590,6 @@ void Skin::checkLoadSound(Sound **addressOfPointer, std::string skinElementName,
 
             std::string path = base_path;
             path.append(fn);
-            debugLog("Loading %s\n", path.c_str());
 
             if(env->fileExists(path)) {
                 if(osu_skin_async.getBool()) {
@@ -1599,8 +1599,6 @@ void Skin::checkLoadSound(Sound **addressOfPointer, std::string skinElementName,
             }
         }
 
-        debugLog("Failed to load %s\n", filename.c_str());
-
         return (Sound *)NULL;
     };
 

+ 2 - 0
src/App/Osu/VolumeOverlay.cpp

@@ -19,6 +19,7 @@
 #include "SongBrowser/SongBrowser.h"
 #include "Sound.h"
 #include "SoundEngine.h"
+#include "UIContextMenu.h"
 #include "UIVolumeSlider.h"
 
 VolumeOverlay::VolumeOverlay() : OsuScreen() {
@@ -244,6 +245,7 @@ bool VolumeOverlay::canChangeVolume() {
         can_scroll = false;
     }
     if(osu->m_optionsMenu->isVisible()) can_scroll = false;
+    if(osu->m_optionsMenu->m_contextMenu->isVisible()) can_scroll = false;
     if(osu->m_changelog->isVisible()) can_scroll = false;
     if(osu->m_rankingScreen->isVisible()) can_scroll = false;
     if(osu->m_modSelector->isMouseInScrollView()) can_scroll = false;