Skip to content

Commit

Permalink
Readme note and popup warning for encore -> ch
Browse files Browse the repository at this point in the history
  • Loading branch information
mtolly committed Sep 28, 2024
1 parent 8b6817e commit 1b3085a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
22 changes: 20 additions & 2 deletions haskell/packages/onyx-exe-toolkit/src/Onyx/GUI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2420,6 +2420,7 @@ data QuickFoFTask
= QFoFInPlace
| QFoFKeepOriginal
| QFoFDeleteOriginal
deriving (Eq)

pageQuickConvertCH
:: (?preferences :: Preferences)
Expand Down Expand Up @@ -2536,7 +2537,15 @@ pageQuickConvertCH sink rect tab startTasks = mdo
FL.setCallback btnGo $ \_ -> do
qfofs <- readMVar loadedFiles
transform <- getTransform
let warningText = "This will modify the selected songs, and the old versions will be deleted."
let warningText = T.unlines $ concat
[ ["This will modify the selected songs, and the old versions will be deleted."]
, do
guard $ any (\qfof -> qfof.format == FoFEncore) qfofs
[ ""
, "WARNING: This will convert Encore-format songs into CH-compatible ones, removing the original files."
, "Select a different mode if you want to keep them."
]
]
FL.flChoice warningText "Cancel" (Just "Start") Nothing >>= \case
1 -> sink $ EventOnyx $ do
-- TODO this is a hack to avoid stale .sng references after editing them.
Expand All @@ -2549,7 +2558,7 @@ pageQuickConvertCH sink rect tab startTasks = mdo
stackIO $ case qfof.format of
FoFFormat FoFFolder -> saveQuickFoFFolder loc qfof
FoFFormat FoFSNG -> fillRequiredMetadata qfof >>= saveQuickFoFSNG loc
FoFEncore -> saveQuickFoFFolder loc qfof -- TODO forbid this!
FoFEncore -> saveQuickFoFFolder loc qfof
return [loc]
in (loc, task)
_ -> return ()
Expand All @@ -2561,17 +2570,26 @@ pageQuickConvertCH sink rect tab startTasks = mdo
then QFoFInPlace
else if deleteOriginals then QFoFDeleteOriginal else QFoFKeepOriginal
return (qfof, fin, task, fout)
promptTasks :: [(QuickFoF, FilePath, QuickFoFTask, FilePath)] -> IO () -> IO ()
promptTasks tasks f = let
numInPlace = length [ () | (_, _, QFoFInPlace , _) <- tasks ]
numKeepOriginal = length [ () | (_, _, QFoFKeepOriginal , _) <- tasks ]
numDeleteOriginal = length [ () | (_, _, QFoFDeleteOriginal, _) <- tasks ]
numDeleteEncore = length $ do
(qfof, _, task, _) <- tasks
guard $ qfof.format == FoFEncore
guard $ elem task [QFoFInPlace, QFoFDeleteOriginal]
return ()
numSongs 1 = "1 song"
numSongs n = T.pack (show n) <> " songs"
warningText = T.unlines $ concat
[ ["Based on the filename template, these operations will be performed:"]
, guard (numInPlace /= 0) >> ["- " <> numSongs numInPlace <> " will be overwritten with new versions"]
, guard (numKeepOriginal /= 0) >> ["- " <> numSongs numKeepOriginal <> " will be converted to new versions"]
, guard (numDeleteOriginal /= 0) >> ["- " <> numSongs numDeleteOriginal <> " will be converted to new versions, and the old versions will be deleted"]
, do
guard $ numDeleteEncore /= 0
["", "WARNING: Some Encore-format songs will be removed/replaced by CH-compatible ones"]
]
in FL.flChoice warningText "Cancel" (Just "Start") Nothing >>= \case
1 -> f
Expand Down
1 change: 1 addition & 0 deletions haskell/readme/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ <h2 id="quick-convert">Quick Convert</h2>
<li>Convert between folder and <code>.sng</code> formats</li>
<li>Reencode audio from other formats to .ogg or .opus</li>
<li>Convert .chart files to MIDI</li>
<li>Convert from Encore format to CH-compatible folder or <code>.sng</code></li>
</ul>
<p>Songs can be modified in place, or new folders or <code>.sng</code> files can be created via a filename template.</p>
</li>
Expand Down

0 comments on commit 1b3085a

Please sign in to comment.