| 1 | //============================================================================ | 
|---|
| 2 | // | 
|---|
| 3 | //   SSSS    tt          lll  lll | 
|---|
| 4 | //  SS  SS   tt           ll   ll | 
|---|
| 5 | //  SS     tttttt  eeee   ll   ll   aaaa | 
|---|
| 6 | //   SSSS    tt   ee  ee  ll   ll      aa | 
|---|
| 7 | //      SS   tt   eeeeee  ll   ll   aaaaa  --  "An Atari 2600 VCS Emulator" | 
|---|
| 8 | //  SS  SS   tt   ee      ll   ll  aa  aa | 
|---|
| 9 | //   SSSS     ttt  eeeee llll llll  aaaaa | 
|---|
| 10 | // | 
|---|
| 11 | // Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony | 
|---|
| 12 | // and the Stella Team | 
|---|
| 13 | // | 
|---|
| 14 | // See the file "License.txt" for information on usage and redistribution of | 
|---|
| 15 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. | 
|---|
| 16 | //============================================================================ | 
|---|
| 17 |  | 
|---|
| 18 | #ifndef LAUNCHER_DIALOG_HXX | 
|---|
| 19 | #define LAUNCHER_DIALOG_HXX | 
|---|
| 20 |  | 
|---|
| 21 | class ButtonWidget; | 
|---|
| 22 | class CommandSender; | 
|---|
| 23 | class ; | 
|---|
| 24 | class DialogContainer; | 
|---|
| 25 | class BrowserDialog; | 
|---|
| 26 | class OptionsDialog; | 
|---|
| 27 | class GlobalPropsDialog; | 
|---|
| 28 | class StellaSettingsDialog; | 
|---|
| 29 | class OSystem; | 
|---|
| 30 | class Properties; | 
|---|
| 31 | class EditTextWidget; | 
|---|
| 32 | class FileListWidget; | 
|---|
| 33 | class RomInfoWidget; | 
|---|
| 34 | class StaticTextWidget; | 
|---|
| 35 | namespace GUI { | 
|---|
| 36 | class MessageBox; | 
|---|
| 37 | } | 
|---|
| 38 |  | 
|---|
| 39 | #include <unordered_map> | 
|---|
| 40 |  | 
|---|
| 41 | #include "bspf.hxx" | 
|---|
| 42 | #include "Dialog.hxx" | 
|---|
| 43 | #include "FSNode.hxx" | 
|---|
| 44 | #include "Stack.hxx" | 
|---|
| 45 |  | 
|---|
| 46 | class LauncherDialog : public Dialog | 
|---|
| 47 | { | 
|---|
| 48 | public: | 
|---|
| 49 | // These must be accessible from dialogs created by this class | 
|---|
| 50 | enum { | 
|---|
| 51 | kLoadROMCmd      = 'STRT',  // load currently selected ROM | 
|---|
| 52 | kRomDirChosenCmd = 'romc'   // rom dir chosen | 
|---|
| 53 | }; | 
|---|
| 54 |  | 
|---|
| 55 | public: | 
|---|
| 56 | LauncherDialog(OSystem& osystem, DialogContainer& parent, | 
|---|
| 57 | int x, int y, int w, int h); | 
|---|
| 58 | virtual ~LauncherDialog() = default; | 
|---|
| 59 |  | 
|---|
| 60 | /** | 
|---|
| 61 | Get path for the currently selected file. | 
|---|
| 62 |  | 
|---|
| 63 | @return path if a valid ROM file, else the empty string | 
|---|
| 64 | */ | 
|---|
| 65 | const string& selectedRom() const; | 
|---|
| 66 |  | 
|---|
| 67 | /** | 
|---|
| 68 | Get MD5sum for the currently selected file. | 
|---|
| 69 | If the MD5 hasn't already been calculated, it will be | 
|---|
| 70 | calculated (and cached) for future use. | 
|---|
| 71 |  | 
|---|
| 72 | @return md5sum if a valid ROM file, else the empty string | 
|---|
| 73 | */ | 
|---|
| 74 | const string& selectedRomMD5(); | 
|---|
| 75 |  | 
|---|
| 76 | /** | 
|---|
| 77 | Get node for the currently selected directory. | 
|---|
| 78 |  | 
|---|
| 79 | @return FilesystemNode currently active | 
|---|
| 80 | */ | 
|---|
| 81 | const FilesystemNode& currentNode() const; | 
|---|
| 82 |  | 
|---|
| 83 | /** | 
|---|
| 84 | Reload the current listing | 
|---|
| 85 | */ | 
|---|
| 86 | void reload(); | 
|---|
| 87 |  | 
|---|
| 88 | private: | 
|---|
| 89 | void center() override { positionAt(0); } | 
|---|
| 90 | void handleKeyDown(StellaKey key, StellaMod mod, bool repeated) override; | 
|---|
| 91 | void handleMouseDown(int x, int y, MouseButton b, int clickCount) override; | 
|---|
| 92 | void handleCommand(CommandSender* sender, int cmd, int data, int id) override; | 
|---|
| 93 | void handleJoyDown(int stick, int button, bool longPress) override; | 
|---|
| 94 | void handleJoyUp(int stick, int button) override; | 
|---|
| 95 | Event::Type getJoyAxisEvent(int stick, JoyAxis axis, JoyDir adir, int button) override; | 
|---|
| 96 |  | 
|---|
| 97 | void loadConfig() override; | 
|---|
| 98 | void updateUI(); | 
|---|
| 99 | void applyFiltering(); | 
|---|
| 100 |  | 
|---|
| 101 | void loadRom(); | 
|---|
| 102 | void loadRomInfo(); | 
|---|
| 103 | void handleContextMenu(); | 
|---|
| 104 | void showOnlyROMs(bool state); | 
|---|
| 105 | void openSettings(); | 
|---|
| 106 |  | 
|---|
| 107 | private: | 
|---|
| 108 | unique_ptr<OptionsDialog> myOptionsDialog; | 
|---|
| 109 | unique_ptr<StellaSettingsDialog> myStellaSettingsDialog; | 
|---|
| 110 | unique_ptr<ContextMenu> ; | 
|---|
| 111 | unique_ptr<GlobalPropsDialog> myGlobalProps; | 
|---|
| 112 | unique_ptr<BrowserDialog> myRomDir; | 
|---|
| 113 |  | 
|---|
| 114 | ButtonWidget* myStartButton; | 
|---|
| 115 | ButtonWidget* myPrevDirButton; | 
|---|
| 116 | ButtonWidget* myOptionsButton; | 
|---|
| 117 | ButtonWidget* myQuitButton; | 
|---|
| 118 |  | 
|---|
| 119 | FileListWidget*   myList; | 
|---|
| 120 | StaticTextWidget* myDirLabel; | 
|---|
| 121 | EditTextWidget*   myDir; | 
|---|
| 122 | StaticTextWidget* myRomCount; | 
|---|
| 123 | EditTextWidget*   myPattern; | 
|---|
| 124 | CheckboxWidget*   myAllFiles; | 
|---|
| 125 |  | 
|---|
| 126 | RomInfoWidget* myRomInfoWidget; | 
|---|
| 127 | std::unordered_map<string,string> myMD5List; | 
|---|
| 128 |  | 
|---|
| 129 | int mySelectedItem; | 
|---|
| 130 |  | 
|---|
| 131 | bool myShowOnlyROMs; | 
|---|
| 132 | bool myUseMinimalUI; | 
|---|
| 133 | bool myEventHandled; | 
|---|
| 134 |  | 
|---|
| 135 | enum { | 
|---|
| 136 | kAllfilesCmd = 'lalf',  // show all files (or ROMs only) | 
|---|
| 137 | kPrevDirCmd  = 'PRVD', | 
|---|
| 138 | kOptionsCmd  = 'OPTI', | 
|---|
| 139 | kQuitCmd     = 'QUIT' | 
|---|
| 140 | }; | 
|---|
| 141 |  | 
|---|
| 142 | private: | 
|---|
| 143 | // Following constructors and assignment operators not supported | 
|---|
| 144 | LauncherDialog() = delete; | 
|---|
| 145 | LauncherDialog(const LauncherDialog&) = delete; | 
|---|
| 146 | LauncherDialog(LauncherDialog&&) = delete; | 
|---|
| 147 | LauncherDialog& operator=(const LauncherDialog&) = delete; | 
|---|
| 148 | LauncherDialog& operator=(LauncherDialog&&) = delete; | 
|---|
| 149 | }; | 
|---|
| 150 |  | 
|---|
| 151 | #endif | 
|---|
| 152 |  | 
|---|