Ran clang-format

This commit is contained in:
mibi88 2024-08-02 18:29:56 +02:00
parent fe824d7340
commit a27ad9a14f
2 changed files with 68 additions and 73 deletions

View file

@ -10,20 +10,13 @@ extern bopti_image_t selected_img;
extern bopti_image_t player_male_inv_img; extern bopti_image_t player_male_inv_img;
extern bopti_image_t player_female_inv_img; extern bopti_image_t player_female_inv_img;
char item_types[I_AMOUNT] = { char item_types[I_AMOUNT] = {IT_NONE, IT_ARMOR, IT_WEAPON, IT_WEAPON,
IT_NONE, IT_FOOD, IT_FOOD, IT_TALISMAN};
IT_ARMOR,
IT_WEAPON,
IT_WEAPON,
IT_FOOD,
IT_FOOD,
IT_TALISMAN
};
void inventory_init(Inventory *inventory) { void inventory_init(Inventory *inventory) {
inventory->open = 0; inventory->open = 0;
memset(inventory->slots, 0, sizeof(Slot)*SLOT_NUM); memset(inventory->slots, 0, sizeof(Slot) * SLOT_NUM);
memset(inventory->equipped, 0, sizeof(Slot)*3); memset(inventory->equipped, 0, sizeof(Slot) * 3);
inventory->selected = -1; inventory->selected = -1;
inventory->selection = 0; inventory->selection = 0;
} }
@ -37,12 +30,12 @@ void inventory_draw(Inventory *inventory, Player *player) {
SLOT_Y + (i / SLOT_COLUMNS) * SLOT_SPACING, &items_img, SLOT_Y + (i / SLOT_COLUMNS) * SLOT_SPACING, &items_img,
inventory->slots[i].i * SLOT_W, 0, SLOT_W, SLOT_H, inventory->slots[i].i * SLOT_W, 0, SLOT_W, SLOT_H,
DIMAGE_NONE); DIMAGE_NONE);
if(i == inventory->selection){ if(i == inventory->selection) {
dimage(SLOT_X + (i % SLOT_COLUMNS) * SLOT_SPACING, dimage(SLOT_X + (i % SLOT_COLUMNS) * SLOT_SPACING,
SLOT_Y + (i / SLOT_COLUMNS) * SLOT_SPACING, SLOT_Y + (i / SLOT_COLUMNS) * SLOT_SPACING,
&selection_img); &selection_img);
} }
if(i == inventory->selected){ if(i == inventory->selected) {
dimage(SLOT_X + (i % SLOT_COLUMNS) * SLOT_SPACING, dimage(SLOT_X + (i % SLOT_COLUMNS) * SLOT_SPACING,
SLOT_Y + (i / SLOT_COLUMNS) * SLOT_SPACING, SLOT_Y + (i / SLOT_COLUMNS) * SLOT_SPACING,
&selected_img); &selected_img);
@ -75,7 +68,8 @@ char inventory_add(Inventory *inventory, Item item) {
} }
void inventory_move_from_selected(Inventory *inventory) { void inventory_move_from_selected(Inventory *inventory) {
if(inventory->selected < 0) return; if(inventory->selected < 0)
return;
Slot current = inventory->slots[inventory->selection]; Slot current = inventory->slots[inventory->selection];
Slot new = inventory->slots[inventory->selected]; Slot new = inventory->slots[inventory->selected];
inventory->slots[inventory->selection] = new; inventory->slots[inventory->selection] = new;
@ -84,7 +78,7 @@ void inventory_move_from_selected(Inventory *inventory) {
void inventory_use(Inventory *inventory, Player *player) { void inventory_use(Inventory *inventory, Player *player) {
Item item = inventory->slots[inventory->selection].i; Item item = inventory->slots[inventory->selection].i;
switch(item_types[item]){ switch(item_types[item]) {
case IT_TALISMAN: case IT_TALISMAN:
inventory->equipped[0] = inventory->slots[inventory->selection]; inventory->equipped[0] = inventory->slots[inventory->selection];
break; break;
@ -105,8 +99,9 @@ void inventory_use(Inventory *inventory, Player *player) {
} }
void inventory_unequip(Inventory *inventory, ItemType type) { void inventory_unequip(Inventory *inventory, ItemType type) {
if(inventory->slots[inventory->selection].i) return; if(inventory->slots[inventory->selection].i)
switch(type){ return;
switch(type) {
case IT_TALISMAN: case IT_TALISMAN:
inventory->slots[inventory->selection] = inventory->equipped[0]; inventory->slots[inventory->selection] = inventory->equipped[0];
inventory->equipped[0].i = I_NONE; inventory->equipped[0].i = I_NONE;