浏览代码

Step folders in menu list with right/left arrow

Thomas Buck 11 年前
父节点
当前提交
ed64d4ffb2
共有 3 个文件被更改,包括 69 次插入31 次删除
  1. 2
    0
      ChangeLog
  2. 2
    0
      include/OpenRaider.h
  3. 65
    31
      src/OpenRaider.cpp

+ 2
- 0
ChangeLog 查看文件

9
 	* Removed the `Map` command. Now the PakDir command causes
9
 	* Removed the `Map` command. Now the PakDir command causes
10
 	  a recursive search of the specified directory. Every file found
10
 	  a recursive search of the specified directory. Every file found
11
 	  is added to the map list if it validates.
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
 	[ 20140216 ]
15
 	[ 20140216 ]
14
 	* Removed the FastCard option. Not necessary on todays hardware?!
16
 	* Removed the FastCard option. Not necessary on todays hardware?!

+ 2
- 0
include/OpenRaider.h 查看文件

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

+ 65
- 31
src/OpenRaider.cpp 查看文件

83
 #endif
83
 #endif
84
 
84
 
85
     printf("\nThanks for testing %s\n", VERSION);
85
     printf("\nThanks for testing %s\n", VERSION);
86
-    printf("Please file bug reports\n\n");
87
     printf("Build date: %s @ %s\n", __DATE__, __TIME__);
86
     printf("Build date: %s @ %s\n", __DATE__, __TIME__);
88
     printf("Build host: %s\n", BUILD_HOST);
87
     printf("Build host: %s\n", BUILD_HOST);
89
     printf("Web site  : http://github.com/xythobuz/OpenRaider\n");
88
     printf("Web site  : http://github.com/xythobuz/OpenRaider\n");
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
 void OpenRaider::handleKeyPressEvent(unsigned int key, unsigned int mod)
715
 void OpenRaider::handleKeyPressEvent(unsigned int key, unsigned int mod)
661
 {
716
 {
662
     static bool menu = false;
717
     static bool menu = false;
679
                 menu = false;
734
                 menu = false;
680
                 break;
735
                 break;
681
             case SYS_KEY_DOWN:
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
                 break;
738
                 break;
698
             case SYS_KEY_UP:
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
         return;
750
         return;

正在加载...
取消
保存