-
Notifications
You must be signed in to change notification settings - Fork 2
/
view_pet_info.h
108 lines (83 loc) · 3.05 KB
/
view_pet_info.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#ifndef VIEW_PET_INFO_H
#define VIEW_PET_INFO_H
extern struct mre_view_p view_pet_info;
#ifdef VIEWS_SETUP
#include "macro_utils.h"
struct mre_view_p view_pet_info;
static struct {
VMUINT8 pet_sprite_draw_w;
} view_pet_info_magic_numbers;
#define MAGIC_NUMBERS view_pet_info_magic_numbers
static void
setup_pet_info(struct mre* mre) {
const struct WatchDuePet* pet_def = current_pet_state.def;
// assume pet sprites are packed
MAGIC_NUMBERS.pet_sprite_draw_w
= pet_def->sprite.ptr.packed_sprite->w
* pet_def->view_info_adjustments.pet_sprite.scale;
}
static void
view_func_pet_info(struct mre* mre) {
const struct WatchDuePet* pet_def = current_pet_state.def;
struct nk_context* ctx = &mre->ctx;
struct nk_panel layout;
struct nk_image image;
nk_button_default(ctx);
if (nk_begin(ctx, &layout, "Info", nk_rect(0, 0, mre->width, mre->height), NK_WINDOW_NO_SCROLLBAR))
{
nk_layout_row_begin(ctx, NK_STATIC, mre->height/2 + 60 - vm_graphic_get_character_height()*5, 3);
{
// Some left padding
nk_layout_row_push(ctx, (mre->width-MAGIC_NUMBERS.pet_sprite_draw_w)/2);
nk_progress(ctx, &zero, 100, 0);
// Little pet sprite
nk_layout_row_push(ctx, MAGIC_NUMBERS.pet_sprite_draw_w);
image = nk_sprite(current_pet_state.sprite,
pet_def->view_info_adjustments.pet_sprite.scale, pet_sprite_index);
image.xo = pet_def->view_info_adjustments.pet_sprite.x_offset;
image.yo = pet_def->view_info_adjustments.pet_sprite.y_offset;
nk_image(ctx,image);
nk_layout_row_end(ctx);
}
nk_layout_row_static(ctx, vm_graphic_get_character_height(), mre->width/3, 3);
{
char age_str[SMALL_STR_SIZE];
const char* p_type
= P_TYPE_STRS[
get_personality_type(current_pet_state.mood_trait,
current_pet_state.hunger_trait)
];
const char* mood
= MOOD_STRS[
get_current_mood(current_pet_state.mood, current_pet_state.hunger)
];
sprintf(age_str, "%.2f PY", current_pet_state.age);
// General pet stats
nk_text(ctx, NK_TXT("SPECIES"), NK_TEXT_ALIGN_RIGHT);
nk_text(ctx, NK_TXT("~"), NK_TEXT_ALIGN_CENTERED);
nk_text(ctx, NK_TXT(pet_def->species), NK_TEXT_ALIGN_RIGHT);
nk_text(ctx, NK_TXT("P-TYPE"), NK_TEXT_ALIGN_RIGHT);
nk_text(ctx, NK_TXT("~"), NK_TEXT_ALIGN_CENTERED);
nk_text(ctx, NK_TXT(p_type), NK_TEXT_ALIGN_RIGHT);
nk_text(ctx, NK_TXT("AGE"), NK_TEXT_ALIGN_RIGHT);
nk_text(ctx, NK_TXT("~"), NK_TEXT_ALIGN_CENTERED);
nk_text(ctx, NK_TXT(age_str), NK_TEXT_ALIGN_RIGHT);
nk_text(ctx, NK_TXT("MOOD"), NK_TEXT_ALIGN_RIGHT);
nk_text(ctx, NK_TXT("~"), NK_TEXT_ALIGN_CENTERED);
nk_text(ctx, NK_TXT(mood), NK_TEXT_ALIGN_RIGHT);
// a little padding
nk_text(ctx, "", 0, NK_TEXT_ALIGN_CENTERED);
nk_layout_row_end(ctx);
}
// Button back to main view
nk_layout_row_static(ctx, mre->height/2 - 60, mre->width, 1);
ctx->style.button.normal.data.color = btn_color_main;
if(nk_button_label(ctx, NK_TXT_PAD("BACK")) == NK_TAPPED) {
nk_mre_set_view(ctx, &view_watch_due_main);
}
nk_end(ctx);
}
}
#undef MAGIC_NUMBERS
#endif
#endif