Mercurial > molko
comparison src/libmlk-rpg/rpg/battle-bar.h @ 385:3f13dc6c0e37
rpg: separate battle and the bar, closes #2522
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 15 Feb 2022 14:45:11 +0100 |
parents | 460c78706989 |
children | 8f59201dc76b |
comparison
equal
deleted
inserted
replaced
384:c458441ff472 | 385:3f13dc6c0e37 |
---|---|
1 /* | 1 /* |
2 * battle-bar.h -- battle status bar and menu | 2 * battle-bar.h -- abstract battle bar |
3 * | 3 * |
4 * Copyright (c) 2020-2022 David Demelier <markand@malikania.fr> | 4 * Copyright (c) 2020-2022 David Demelier <markand@malikania.fr> |
5 * | 5 * |
6 * Permission to use, copy, modify, and/or distribute this software for any | 6 * Permission to use, copy, modify, and/or distribute this software for any |
7 * purpose with or without fee is hereby granted, provided that the above | 7 * purpose with or without fee is hereby granted, provided that the above |
19 #ifndef MLK_RPG_BATTLE_BAR_H | 19 #ifndef MLK_RPG_BATTLE_BAR_H |
20 #define MLK_RPG_BATTLE_BAR_H | 20 #define MLK_RPG_BATTLE_BAR_H |
21 | 21 |
22 #include <core/core.h> | 22 #include <core/core.h> |
23 | 23 |
24 #include <ui/frame.h> | |
25 #include <ui/gridmenu.h> | |
26 | |
27 struct battle; | 24 struct battle; |
28 struct character; | 25 struct selection; |
29 | 26 |
30 union event; | 27 union event; |
31 | 28 |
32 enum battle_bar_menu { | |
33 BATTLE_BAR_MENU_ATTACK = 0, | |
34 BATTLE_BAR_MENU_MAGIC = 1, | |
35 BATTLE_BAR_MENU_OBJECTS = 2, | |
36 BATTLE_BAR_MENU_SPECIAL = 3 | |
37 }; | |
38 | |
39 enum battle_bar_state { | |
40 BATTLE_BAR_STATE_NONE, | |
41 BATTLE_BAR_STATE_MENU, | |
42 BATTLE_BAR_STATE_SUB | |
43 }; | |
44 | |
45 struct battle_bar { | 29 struct battle_bar { |
46 int x; | 30 void *data; |
47 int y; | 31 void (*start)(struct battle_bar *, struct battle *); |
48 unsigned int w; | 32 void (*select)(struct battle_bar *, struct battle *, const struct selection *); |
49 unsigned int h; | 33 void (*handle)(struct battle_bar *, struct battle *, const union event *); |
50 enum battle_bar_state state; | 34 void (*update)(struct battle_bar *, struct battle *, unsigned int); |
51 | 35 void (*draw)(const struct battle_bar *, const struct battle *); |
52 /* Right status frame. */ | 36 void (*finish)(struct battle_bar *, struct battle *); |
53 struct frame status_frame; | |
54 | |
55 /* Main menu selection. */ | |
56 struct frame menu_frame; | |
57 enum battle_bar_menu menu; | |
58 | |
59 /* Sub menu selection (spells/objects). */ | |
60 char sub_items[GRIDMENU_ENTRY_MAX][128]; | |
61 struct gridmenu sub_grid; | |
62 }; | 37 }; |
63 | 38 |
64 CORE_BEGIN_DECLS | 39 CORE_BEGIN_DECLS |
65 | 40 |
66 void | 41 void |
67 battle_bar_positionate(struct battle_bar *bar, const struct battle *bt); | 42 battle_bar_start(struct battle_bar *, struct battle *); |
68 | |
69 int | |
70 battle_bar_handle(struct battle_bar *bar, | |
71 const struct battle *bt, | |
72 const union event *ev); | |
73 | 43 |
74 void | 44 void |
75 battle_bar_reset(struct battle_bar *bar); | 45 battle_bar_select(struct battle_bar *, struct battle *, const struct selection *); |
76 | 46 |
77 void | 47 void |
78 battle_bar_open_menu(struct battle_bar *bar); | 48 battle_bar_handle(struct battle_bar *, struct battle *, const union event *); |
79 | 49 |
80 void | 50 void |
81 battle_bar_open_spells(struct battle_bar *bar, const struct battle *bt, struct character *ch); | 51 battle_bar_update(struct battle_bar *, struct battle *, unsigned int); |
82 | 52 |
83 void | 53 void |
84 battle_bar_open_items(struct battle_bar *bar, const struct battle *bt); | 54 battle_bar_draw(const struct battle_bar *, const struct battle *); |
85 | 55 |
86 void | 56 void |
87 battle_bar_draw(const struct battle_bar *bar, const struct battle *bt); | 57 battle_bar_finish(struct battle_bar *, struct battle *); |
88 | |
89 void | |
90 battle_bar_finish(struct battle_bar *bar); | |
91 | 58 |
92 CORE_END_DECLS | 59 CORE_END_DECLS |
93 | 60 |
94 #endif /* !MLK_RPG_BATTLE_BAR_H */ | 61 #endif /* !MLK_RPG_BATTLE_BAR_H */ |