Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Commit 8bcbe15

Browse files
bookmark/chapter shortcuts #62
1 parent 836380a commit 8bcbe15

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

localization/localization.csv

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,4 +530,7 @@ SET_CHAPTER_SIZE,Set size,Set size
530530
SAVE_HEATMAP_WITH_CHAPTERS,Save heatmap with chapters,Save heatmap with chapters
531531
CHAPTERS,Chapters,Chapters
532532
CHAPTER,Chapter,Chapter
533-
BEGIN,Begin,Begin
533+
BEGIN,Begin,Begin
534+
CHAPTER_BINDING_GROUP,Chapters,Chapters
535+
ACTION_CREATE_BOOKMARK,Create bookmark,Create bookmark
536+
ACTION_CREATE_CHAPTER,Create chapter,Create chapter

src/OpenFunscripter.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,33 @@ void OpenFunscripter::registerBindings()
11981198
{ { ImGuiMod_None, ImGuiKey_GamepadFaceLeft } });
11991199
}
12001200

1201+
keys->RegisterGroup("Chapters", Tr::CHAPTER_BINDING_GROUP);
1202+
{
1203+
keys->RegisterAction(
1204+
{ "create_chapter",
1205+
[this]() {
1206+
auto& chapterState = chapterMgr->State();
1207+
if (auto chapter = chapterState.AddChapter(player->CurrentTime(), player->Duration())) {
1208+
EV::Enqueue<ChapterStateChanged>();
1209+
}
1210+
},
1211+
false },
1212+
Tr::ACTION_CREATE_CHAPTER, "Chapters",
1213+
{});
1214+
1215+
keys->RegisterAction(
1216+
{ "create_bookmark",
1217+
[this]() {
1218+
auto& chapterState = chapterMgr->State();
1219+
if (auto bookmark = chapterState.AddBookmark(player->CurrentTime())) {
1220+
EV::Enqueue<ChapterStateChanged>();
1221+
}
1222+
},
1223+
false },
1224+
Tr::ACTION_CREATE_BOOKMARK, "Chapters",
1225+
{});
1226+
}
1227+
12011228
// Group where all dynamic actions are placed.
12021229
// Lua functions for example.
12031230
keys->RegisterGroup("Dynamic", Tr::DYNAMIC_BINDING_GROUP);

src/UI/OFS_ChapterManager.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ OFS_ChapterManager::~OFS_ChapterManager() noexcept
1919

2020
}
2121

22+
ChapterState& OFS_ChapterManager::State() noexcept
23+
{
24+
return ChapterState::State(stateHandle);
25+
}
26+
2227
void OFS_ChapterManager::ShowWindow(bool* open) noexcept
2328
{
2429
if(!*open) return;

src/UI/OFS_ChapterManager.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class OFS_ChapterManager
1515
~OFS_ChapterManager() noexcept;
1616

1717
static bool ExportClip(const class Chapter& chapter, const std::string& outputDirStr) noexcept;
18-
1918
void ShowWindow(bool* open) noexcept;
19+
20+
class ChapterState& State() noexcept;
2021
};

0 commit comments

Comments
 (0)