Skip to content

Commit

Permalink
feat: support multiple actionbar styles
Browse files Browse the repository at this point in the history
  • Loading branch information
WillowSauceR authored and WillowSauceR committed Aug 26, 2023
1 parent 9042c54 commit f7d1085
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ The subcommands are ``list``, ``play`` and ``stop``.
| Subcommands | Parameters | Examples | Explanation |
| ----------- | ------------------------------------------------------------- | --------------- | ----------------------------------------------------------------- |
| list | None | /mpm list | Get song index |
| play | song index, optional: loop count, optional: progress bar type | /mpm play 1 3 1 | play song (index 1, loop 3 times, use actionbar to show progress) |
| play | song index, optional: loop count, optional: progress bar type | /mpm play 1 3 1 | play song (index 1, loop 3 times, use bossbar to show progress) |
| stop | none | /mpm stop | stop play |

Progress bar type:
0: bossbar
1: actionbar
2: not displayed
0: not displayed
1: bossbar
2: actionbar: JUKEBOX_POPUP
3: actionbar: POPUP
4: actionbar: TIP

Note: Before playing music, please use ``/mpm list`` to get the music list first.
You can also use the ``/mpm`` command inside the game to see how to use it
Expand Down
10 changes: 6 additions & 4 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ NBS音乐文件请放置到``plugins\MediaPlayer\nbs``文件夹中
| 子命令 | 参数 | 示例 | 解释 |
| ------ | ------------------------------------------ | --------------- | -------------------------------------------------- |
| list || /mpm list | 获取歌曲索引 |
| play | 歌曲索引,可选:循环次数,可选:进度条类型 | /mpm play 1 3 1 | 播放歌曲(索引为1, 循环3次,使用actionbar显示进度) |
| play | 歌曲索引,可选:循环次数,可选:进度条类型 | /mpm play 1 3 1 | 播放歌曲(索引为1, 循环3次,使用bossbar显示进度) |
| stop || /mpm stop | 停止播放 |

进度条类型:
0: bossbar
1: actionbar
2: 不显示
0: 不显示
1: bossbar
2: actionbar: JUKEBOX_POPUP
3: actionbar: POPUP
4: actionbar: TIP

注意:在播放音乐之前,请先使用``/mpm list``来获取音乐列表。
具体使用方法,也可以在游戏内使用``/mpm``命令查看
Expand Down
5 changes: 4 additions & 1 deletion include/mediaplayer/music_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ static const char *BUILTIN_INSTRUMENT[NUM_NOTES] = {
};

enum music_bar_type {
MUSIC_BAR_TYPE_NOT_DISPLAY,
MUSIC_BAR_TYPE_BOSS_BAR,
MUSIC_BAR_TYPE_ACTION_BAR
MUSIC_BAR_TYPE_ACTION_BAR_JUKEBOX_POPUP,
MUSIC_BAR_TYPE_ACTION_BAR_POPUP,
MUSIC_BAR_TYPE_ACTION_BAR_TIP
};

struct note_queue_node {
Expand Down
10 changes: 9 additions & 1 deletion src/music_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,21 @@ void set_music_bar(struct player *player, struct music_queue_node *node)
total_time_sec);

switch (node->music_bar_type) {
case MUSIC_BAR_TYPE_NOT_DISPLAY:
break;
case MUSIC_BAR_TYPE_BOSS_BAR:
send_boss_event_packet(player, msg, passed_rate, BOSS_BAR_HIDE);
send_boss_event_packet(player, msg, passed_rate, BOSS_BAR_DISPLAY);
break;
case MUSIC_BAR_TYPE_ACTION_BAR:
case MUSIC_BAR_TYPE_ACTION_BAR_JUKEBOX_POPUP:
send_text_packet(player, TEXT_TYPE_JUKEBOX_POPUP, msg);
break;
case MUSIC_BAR_TYPE_ACTION_BAR_POPUP:
send_text_packet(player, TEXT_TYPE_POPUP, msg);
break;
case MUSIC_BAR_TYPE_ACTION_BAR_TIP:
send_text_packet(player, TEXT_TYPE_TIP, msg);
break;
default:
break;
}
Expand Down

0 comments on commit f7d1085

Please sign in to comment.