Sfoglia il codice sorgente

Step folders in menu list with right/left arrow

Thomas Buck 10 anni fa
parent
commit
ed64d4ffb2
3 ha cambiato i file con 69 aggiunte e 31 eliminazioni
  1. 2
    0
      ChangeLog
  2. 2
    0
      include/OpenRaider.h
  3. 65
    31
      src/OpenRaider.cpp

+ 2
- 0
ChangeLog Vedi File

@@ -9,6 +9,8 @@
9 9
 	* Removed the `Map` command. Now the PakDir command causes
10 10
 	  a recursive search of the specified directory. Every file found
11 11
 	  is added to the map list if it validates.
12
+	* The menu map list can now be stepped per folder with the
13
+	  right and left arrows.
12 14
 
13 15
 	[ 20140216 ]
14 16
 	* Removed the FastCard option. Not necessary on todays hardware?!

+ 2
- 0
include/OpenRaider.h Vedi File

@@ -199,6 +199,8 @@ private:
199 199
 
200 200
     void loadPakFolderRecursive(const char *dir);
201 201
 
202
+    void menuMapListMove(char dir, bool show);
203
+
202 204
     static OpenRaider *mInstance; //!< Singleton use
203 205
     TombRaider m_tombraider;      //!< Tombraider data support
204 206
     Sound mSound;                 //!< 3d Audio support

+ 65
- 31
src/OpenRaider.cpp Vedi File

@@ -83,7 +83,6 @@ void killOpenRaiderSingleton()
83 83
 #endif
84 84
 
85 85
     printf("\nThanks for testing %s\n", VERSION);
86
-    printf("Please file bug reports\n\n");
87 86
     printf("Build date: %s @ %s\n", __DATE__, __TIME__);
88 87
     printf("Build host: %s\n", BUILD_HOST);
89 88
     printf("Web site  : http://github.com/xythobuz/OpenRaider\n");
@@ -657,6 +656,62 @@ void OpenRaider::handleConsoleKeyPressEvent(unsigned int key,unsigned int mod)
657 656
 }
658 657
 
659 658
 
659
+void OpenRaider::menuMapListMove(char dir, bool show) {
660
+    if (dir == 'f') {
661
+        mMapList.next();
662
+        if (!mMapList.forward())
663
+            mMapList.start();
664
+    } else if (dir == 'b') {
665
+        mMapList.prev();
666
+        if (!mMapList.backward())
667
+            mMapList.finish();
668
+    } else if (dir == 'n') {
669
+        size_t slashPos = strcspn(mMapList.current(), "/");
670
+        if (slashPos < strlen(mMapList.current())) {
671
+            char *dirName = new char[slashPos + 1];
672
+            dirName[slashPos] = '\0';
673
+            strncpy(dirName, mMapList.current(), slashPos);
674
+            do {
675
+                menuMapListMove('f', false);
676
+            } while (strstr(mMapList.current(), dirName) != NULL);
677
+            delete dirName;
678
+        } else {
679
+            do {
680
+                menuMapListMove('f', false);
681
+            } while (strstr(mMapList.current(), "/") == NULL);
682
+        }
683
+    } else if (dir == 'p') {
684
+        size_t slashPos = strcspn(mMapList.current(), "/");
685
+        if (slashPos < strlen(mMapList.current())) {
686
+            char *dirName = new char[slashPos + 1];
687
+            dirName[slashPos] = '\0';
688
+            strncpy(dirName, mMapList.current(), slashPos);
689
+            do {
690
+                menuMapListMove('b', false);
691
+            } while (strstr(mMapList.current(), dirName) != NULL);
692
+            // Yeah, cheap...
693
+            strncpy(dirName, mMapList.current(), slashPos);
694
+            do {
695
+                menuMapListMove('b', false);
696
+            } while (strstr(mMapList.current(), dirName) != NULL);
697
+            menuMapListMove('f', false);
698
+            delete dirName;
699
+        } else {
700
+            do {
701
+                menuMapListMove('b', false);
702
+            } while (strstr(mMapList.current(), "/") == NULL);
703
+        }
704
+    }
705
+
706
+    if (show) {
707
+        if (mMapList.current())
708
+            mText->SetString(textMenu, "Load %s?", mMapList.current());
709
+        else
710
+            mText->SetString(textMenu, "See README for map install");
711
+    }
712
+}
713
+
714
+
660 715
 void OpenRaider::handleKeyPressEvent(unsigned int key, unsigned int mod)
661 716
 {
662 717
     static bool menu = false;
@@ -679,38 +734,17 @@ void OpenRaider::handleKeyPressEvent(unsigned int key, unsigned int mod)
679 734
                 menu = false;
680 735
                 break;
681 736
             case SYS_KEY_DOWN:
682
-                mMapList.prev();
683
-
684
-                if (!mMapList.backward())
685
-                {
686
-                    mMapList.finish();
687
-                }
688
-
689
-                if (mMapList.current())
690
-                {
691
-                    mText->SetString(textMenu, "Load %s?", mMapList.current());
692
-                }
693
-                else
694
-                {
695
-                    mText->SetString(textMenu, "See README for map install");
696
-                }
737
+                menuMapListMove('b', true);
697 738
                 break;
698 739
             case SYS_KEY_UP:
699
-                mMapList.next();
700
-
701
-                if (!mMapList.forward())
702
-                {
703
-                    mMapList.start();
704
-                }
705
-
706
-                if (mMapList.current())
707
-                {
708
-                    mText->SetString(textMenu, "Load %s?", mMapList.current());
709
-                }
710
-                else
711
-                {
712
-                    mText->SetString(textMenu, "See README for map install");
713
-                }
740
+                menuMapListMove('f', true);
741
+                break;
742
+            case SYS_KEY_LEFT:
743
+                menuMapListMove('p', true);
744
+                break;
745
+            case SYS_KEY_RIGHT:
746
+                menuMapListMove('n', true);
747
+                break;
714 748
         }
715 749
 
716 750
         return;

Loading…
Annulla
Salva