Refactoring
This commit is contained in:
parent
2a975da064
commit
93eb59b918
2 changed files with 25 additions and 9 deletions
|
|
@ -51,7 +51,7 @@ namespace gui_to_app {
|
||||||
on_stack = true;
|
on_stack = true;
|
||||||
switch_->set_active(false);
|
switch_->set_active(false);
|
||||||
} else {
|
} else {
|
||||||
app.update_hab_labels();
|
app.update_labels();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!app.erase_obj(obj)) {
|
if (!app.erase_obj(obj)) {
|
||||||
|
|
@ -62,7 +62,7 @@ namespace gui_to_app {
|
||||||
character::BillyObjects::billy_object_to_string(obj).data()
|
character::BillyObjects::billy_object_to_string(obj).data()
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
app.update_hab_labels();
|
app.update_labels();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -206,7 +206,7 @@ namespace gui_to_app {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void convert_to_label(std::array<char, 10> &convert,
|
static void convert_to_label(std::array<char, 10> &convert,
|
||||||
const char *err_msg,
|
const std::string_view &err_msg,
|
||||||
const uint32_t data,
|
const uint32_t data,
|
||||||
Gtk::Label *const __restrict label) noexcept {
|
Gtk::Label *const __restrict label) noexcept {
|
||||||
if (const auto [ptr, ec] = std::to_chars(convert.data(), convert.data() + convert.size(), data);
|
if (const auto [ptr, ec] = std::to_chars(convert.data(), convert.data() + convert.size(), data);
|
||||||
|
|
@ -222,12 +222,28 @@ namespace gui_to_app {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppWin2Back::update_hab_labels() const noexcept {
|
static void update_in_labels(const character::characteristic::Characteristic &charac,
|
||||||
|
const std::string_view short_name,
|
||||||
|
const CaracInterface<Gtk::Label> &labels) noexcept {
|
||||||
std::array<char, 10> convert{};
|
std::array<char, 10> convert{};
|
||||||
convert_to_label(convert, "base hab", sheet.get_habilete().get_base(), hab_labels.base);
|
convert_to_label(convert, std::format("base {}", short_name), charac.get_base(), labels.base);
|
||||||
convert_to_label(convert, "carac hab", sheet.get_habilete().get_carac(), hab_labels.carac);
|
convert_to_label(convert,
|
||||||
convert_to_label(convert, "materiel hab", sheet.get_habilete().get_materiel(), hab_labels.mat);
|
std::format("carac {}", short_name),
|
||||||
convert_to_label(convert, "total hab", sheet.get_habilete().get_total(), hab_labels.total);
|
charac.get_carac(),
|
||||||
|
labels.carac);
|
||||||
|
convert_to_label(convert,
|
||||||
|
std::format("materiel {}", short_name),
|
||||||
|
charac.get_materiel(),
|
||||||
|
labels.mat);
|
||||||
|
convert_to_label(convert,
|
||||||
|
std::format("total {}", short_name),
|
||||||
|
charac.get_total(),
|
||||||
|
labels.total);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppWin2Back::update_labels() const noexcept {
|
||||||
|
update_in_labels(sheet.get_habilete(), "hab", hab_labels);
|
||||||
|
update_in_labels(sheet.get_endurance(), "endu", endu_labels);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AppWin2Back::insert_obj(const character::billyEnums &obj) noexcept {
|
bool AppWin2Back::insert_obj(const character::billyEnums &obj) noexcept {
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ namespace gui_to_app {
|
||||||
|
|
||||||
void debug_button_clicked() const noexcept;
|
void debug_button_clicked() const noexcept;
|
||||||
|
|
||||||
void update_hab_labels() const noexcept;
|
void update_labels() const noexcept;
|
||||||
|
|
||||||
bool insert_obj(const character::billyEnums &obj) noexcept;
|
bool insert_obj(const character::billyEnums &obj) noexcept;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue