Mercurial > molko
changeset 386:7d5032755b7d
rpg: cleanup leftovers
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 15 Feb 2022 16:01:29 +0100 |
parents | 3f13dc6c0e37 |
children | 4523476bc4e8 |
files | battle-state-selection.h src/libmlk-rpg/rpg/battle-bar-default.c src/libmlk-rpg/rpg/battle-state-sub.c src/libmlk-rpg/rpg/battle-state-sub.h |
diffstat | 4 files changed, 3 insertions(+), 188 deletions(-) [+] |
line wrap: on
line diff
--- a/battle-state-selection.h Tue Feb 15 14:45:11 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -/* - * battle-state-selection.h -- battle state (selection) - * - * Copyright (c) 2020-2022 David Demelier <markand@malikania.fr> - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef MLK_RPG_BATTLE_STATE_SELECTION_H -#define MLK_RPG_BATTLE_STATE_SELECTION_H - -void -battle_state_selection(struct battle *, const struct selection *); - -#endif /* !MLK_RPG_BATTLE_STATE_SELECTION_H */
--- a/src/libmlk-rpg/rpg/battle-bar-default.c Tue Feb 15 14:45:11 2022 +0100 +++ b/src/libmlk-rpg/rpg/battle-bar-default.c Tue Feb 15 16:01:29 2022 +0100 @@ -416,12 +416,12 @@ bar->state = BATTLE_BAR_DEFAULT_STATE_MENU; return; } - + gridmenu_handle(&bar->sub_grid, ev); if (bar->sub_grid.state == GRIDMENU_STATE_ACTIVATED) { gridmenu_reset(&bar->sub_grid); - + switch (bar->menu) { case BATTLE_BAR_DEFAULT_MENU_MAGIC: switch_selection_spell(bar, bt); @@ -573,7 +573,7 @@ void battle_bar_default_open_item(struct battle_bar_default *bar, const struct battle *bt) { - asssert(bar); + assert(bar); assert(bt); init_gridmenu(bar, bt);
--- a/src/libmlk-rpg/rpg/battle-state-sub.c Tue Feb 15 14:45:11 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,125 +0,0 @@ -/* - * battle-state-sub.c -- battle state (sub) - * - * Copyright (c) 2020-2022 David Demelier <markand@malikania.fr> - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <assert.h> -#include <stdlib.h> - -#include <core/alloc.h> -#include <core/event.h> -#include <core/sprite.h> -#include <core/trace.h> - -#include <ui/theme.h> - -#include <rpg/inventory.h> -#include <rpg/item.h> - -#include "battle-bar.h" -#include "battle-state-menu.h" -#include "battle-state-selection.h" -#include "battle-state-sub.h" -#include "battle-state.h" -#include "battle.h" -#include "character.h" -#include "spell.h" - - -static void -handle(struct battle_state *st, struct battle *bt, const union event *ev) -{ - (void)st; - - battle_state_sub_handle(bt, ev); -} - -static void -draw(const struct battle_state *st, const struct battle *bt) -{ - (void)st; - - battle_state_sub_draw(bt); -} - -static void -finish(struct battle_state *st, struct battle *bt) -{ - (void)bt; - - free(st); -} - -void -battle_state_sub_handle(struct battle *bt, const union event *ev) -{ - assert(bt); - assert(ev); - - switch (ev->type) { - case EVENT_KEYDOWN: - switch (ev->key.key) { - case KEY_ESCAPE: - /* Escape go to the previous state. */ - battle_state_menu(bt); - return; - default: - break; - } - default: - break; - } - - if (battle_bar_handle(&bt->bar, bt, ev)) { - switch (bt->bar.menu) { - case BATTLE_BAR_MENU_MAGIC: - start_select_spell(bt); - break; - default: - start_select_object(bt); - break; - } - } -} - -void -battle_state_sub_draw(const struct battle *bt) -{ - assert(bt); - - battle_bar_draw(&bt->bar, bt); - - if (bt->bar.menu == BATTLE_BAR_MENU_MAGIC) - draw_spell_help(bt); - else if (bt->bar.menu == BATTLE_BAR_MENU_OBJECTS) - draw_object_help(bt); -} - -void -battle_state_sub(struct battle *bt) -{ - assert(bt); - - struct battle_state *state; - - state = alloc_new0(sizeof (*state)); - state->data = bt; - state->handle = handle; - state->draw = draw; - state->finish = finish; - - battle_switch(bt, state); -}
--- a/src/libmlk-rpg/rpg/battle-state-sub.h Tue Feb 15 14:45:11 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -/* - * battle-state-sub.h -- battle state (sub) - * - * Copyright (c) 2020-2022 David Demelier <markand@malikania.fr> - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef MLK_RPG_BATTLE_STATE_SUB_H -#define MLK_RPG_BATTLE_STATE_SUB_H - -struct battle; - -union event; - -void -battle_state_sub_handle(struct battle *, const union event *); - -void -battle_state_sub_draw(const struct battle *); - -void -battle_state_sub(struct battle *); - -#endif /* !MLK_RPG_BATTLE_STATE_SUB_H */