| 105 | } |
| 106 | |
| 107 | class CtrScriptHost : public ScriptHost { |
| 108 | public: |
| 109 | int titleCount(void) override |
| 110 | { |
| 111 | refreshExtras(); |
| 112 | return mSaveCount + (int)mExtras.size(); |
| 113 | } |
| 114 | |
| 115 | bool titleAt(int idx, HostTitle& out) override |
| 116 | { |
| 117 | Title title; |
| 118 | if (!catalogTitle(idx, title)) { |
| 119 | return false; |
| 120 | } |
| 121 | out.id = title.id(); |
| 122 | out.name = title.longDescription(); |
| 123 | out.productCode = title.productCode; |
| 124 | out.isCart = title.mediaType() == MEDIATYPE_GAME_CARD; |
| 125 | out.hasSave = title.accessibleSave(); |
| 126 | out.hasExtdata = title.accessibleExtdata(); |
| 127 | return true; |
| 128 | } |
| 129 | |
| 130 | int titleIndexOf(uint64_t id) override |
| 131 | { |
| 132 | const int save = TitleCatalog::get().indexById((u64)id, BackupKind::Save); |
| 133 | if (save >= 0) { |
| 134 | return save; |
| 135 | } |
| 136 | |
| 137 | refreshExtras(); |
| 138 | for (size_t i = 0; i < mExtras.size(); i++) { |
| 139 | if (mExtras[i].id == (u64)id) { |
| 140 | return mSaveCount + (int)i; |
| 141 | } |
| 142 | } |
| 143 | return -1; |
| 144 | } |
| 145 | |
| 146 | std::string titleBackupPath(int idx, int kind) override |
| 147 | { |
| 148 | Title title; |
| 149 | if (!catalogTitle(idx, title)) { |
| 150 | return ""; |
| 151 | } |
| 152 | BackupTarget target = title.backup(kind == 0 ? BackupKind::Save : BackupKind::Extdata); |
| 153 | return StringUtils::UTF16toUTF8(target.rootPath()); |
| 154 | } |
| 155 | |
| 156 | int savOpen(int titleIdx, int kind) override |
| 157 | { |
| 158 | Title title; |
| 159 | if (!catalogTitle(titleIdx, title)) { |
| 160 | return -1; |
| 161 | } |
| 162 | const int slot = freeSlot(); |
| 163 | if (slot < 0) { |
| 164 | return -2; |
nothing calls this directly
no outgoing calls
no test coverage detected