Minor GUI changes

This commit is contained in:
Paul 2020-04-26 16:49:01 +02:00
parent 1b3cee08a8
commit b027271f26
4 changed files with 151 additions and 140 deletions

View File

@ -40,7 +40,9 @@
"/usr/include/gtkmm-3.0", "/usr/include/gtkmm-3.0",
"/usr/include/gdkmm-3.0/", "/usr/include/gdkmm-3.0/",
"/usr/include/giomm-2.4/", "/usr/include/giomm-2.4/",
"/usr/include/linux/",
"/usr/include/sigc++-2.0", "/usr/include/sigc++-2.0",
"/usr/lib64/gcc/x86_64-pc-linux-gnu/9.3.0/include",
"/usr/lib64/glib-2.0/include/", "/usr/lib64/glib-2.0/include/",
"/usr/lib64/gtkmm-3.0/include/", "/usr/lib64/gtkmm-3.0/include/",
"/usr/lib64/giomm-2.4/include/", "/usr/lib64/giomm-2.4/include/",
@ -48,7 +50,7 @@
"/usr/lib64/sigc++-2.0/include/", "/usr/lib64/sigc++-2.0/include/",
"/usr/lib64/gdkmm-3.0/include/", "/usr/lib64/gdkmm-3.0/include/",
"/usr/lib64/pangomm-1.4/include/", "/usr/lib64/pangomm-1.4/include/",
"${workspaceRoot}" "${workspaceFolder}/src/**"
], ],
"browse": { "browse": {
"limitSymbolsToIncludedHeaders": false, "limitSymbolsToIncludedHeaders": false,

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.2 <!-- Generated with glade 3.22.0
Copyright (C) Copyright (C)
@ -41,9 +41,6 @@ telans (telans)</property>
<property name="artists">Rejedai (rejedai)</property> <property name="artists">Rejedai (rejedai)</property>
<property name="logo">../assets/icon_256.png</property> <property name="logo">../assets/icon_256.png</property>
<property name="license_type">gpl-3-0</property> <property name="license_type">gpl-3-0</property>
<child type="titlebar">
<placeholder/>
</child>
<child internal-child="vbox"> <child internal-child="vbox">
<object class="GtkBox"> <object class="GtkBox">
<property name="can_focus">False</property> <property name="can_focus">False</property>
@ -62,6 +59,9 @@ telans (telans)</property>
</child> </child>
</object> </object>
</child> </child>
<child type="titlebar">
<placeholder/>
</child>
</object> </object>
<object class="GtkBox" id="fetch_achievements_placeholder"> <object class="GtkBox" id="fetch_achievements_placeholder">
<property name="visible">True</property> <property name="visible">True</property>
@ -489,6 +489,122 @@ Did you make a typo? Or maybe this game has no stats.</property>
<property name="height_request">500</property> <property name="height_request">500</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="icon">../assets/icon_256.png</property> <property name="icon">../assets/icon_256.png</property>
<child>
<object class="GtkStack" id="main_stack">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="transition_type">slide-left-right</property>
<child>
<object class="GtkScrolledWindow" id="game_list_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<property name="overlay_scrolling">False</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkListBox" id="game_list">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selection_mode">none</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="name">page0</property>
<property name="title" translatable="yes">page0</property>
</packing>
</child>
<child>
<object class="GtkNotebook" id="achievement_and_stat_notebook">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkScrolledWindow" id="achievement_list_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<property name="overlay_scrolling">False</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkListBox" id="achievement_list">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selection_mode">none</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">🏅 Achievements</property>
<property name="width_chars">20</property>
<property name="max_width_chars">20</property>
</object>
<packing>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="stat_list_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<property name="overlay_scrolling">False</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkListBox" id="stat_list">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selection_mode">none</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">📊 Statistics</property>
<property name="width_chars">20</property>
<property name="max_width_chars">20</property>
</object>
<packing>
<property name="position">1</property>
<property name="tab_fill">False</property>
</packing>
</child>
</object>
<packing>
<property name="name">page1</property>
<property name="title" translatable="yes">page1</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child type="titlebar"> <child type="titlebar">
<object class="GtkHeaderBar"> <object class="GtkHeaderBar">
<property name="visible">True</property> <property name="visible">True</property>
@ -596,122 +712,6 @@ Did you make a typo? Or maybe this game has no stats.</property>
</child> </child>
</object> </object>
</child> </child>
<child>
<object class="GtkStack" id="main_stack">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="transition_type">slide-left-right</property>
<child>
<object class="GtkScrolledWindow" id="game_list_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<property name="overlay_scrolling">False</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkListBox" id="game_list">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selection_mode">none</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="name">page0</property>
<property name="title" translatable="yes">page0</property>
</packing>
</child>
<child>
<object class="GtkNotebook" id="achievement_and_stat_notebook">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkScrolledWindow" id="achievement_list_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<property name="overlay_scrolling">False</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkListBox" id="achievement_list">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selection_mode">none</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Achievements</property>
<property name="width_chars">20</property>
<property name="max_width_chars">20</property>
</object>
<packing>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="stat_list_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<property name="overlay_scrolling">False</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkListBox" id="stat_list">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selection_mode">none</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Stats</property>
<property name="width_chars">20</property>
<property name="max_width_chars">20</property>
</object>
<packing>
<property name="position">1</property>
<property name="tab_fill">False</property>
</packing>
</child>
</object>
<packing>
<property name="name">page1</property>
<property name="title" translatable="yes">page1</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object> </object>
<object class="GtkWindow" id="settings_window"> <object class="GtkWindow" id="settings_window">
<property name="height_request">250</property> <property name="height_request">250</property>
@ -720,9 +720,6 @@ Did you make a typo? Or maybe this game has no stats.</property>
<property name="modal">True</property> <property name="modal">True</property>
<property name="destroy_with_parent">True</property> <property name="destroy_with_parent">True</property>
<property name="icon_name">preferences-system</property> <property name="icon_name">preferences-system</property>
<child type="titlebar">
<placeholder/>
</child>
<child> <child>
<object class="GtkPaned"> <object class="GtkPaned">
<property name="visible">True</property> <property name="visible">True</property>
@ -954,5 +951,8 @@ Did you make a typo? Or maybe this game has no stats.</property>
</child> </child>
</object> </object>
</child> </child>
<child type="titlebar">
<placeholder/>
</child>
</object> </object>
</interface> </interface>

View File

@ -228,16 +228,21 @@ MySteam::remove_modification_ach(const std::string& ach_id) {
void void
MySteam::add_modification_stat(const StatValue_t& stat, std::any new_value) { MySteam::add_modification_stat(const StatValue_t& stat, std::any new_value) {
// The value must already be the proper type for it to be added to the list // The value must already be the proper type for it to be added to the list
#ifdef DEBUG_CERR
std::cout << "Adding stat modification: " << stat.id << ", "; std::cout << "Adding stat modification: " << stat.id << ", ";
if (stat.type == UserStatType::Integer) { if (stat.type == UserStatType::Integer) {
std::cout << "Integer " << std::to_string(std::any_cast<long long>(new_value)); std::cout << "Integer " << std::to_string(std::any_cast<long long>(new_value));
} else if (stat.type == UserStatType::Float) { } else if (stat.type == UserStatType::Float) {
std::cout << "Float " << std::to_string(std::any_cast<double>(new_value)); std::cout << "Float " << std::to_string(std::any_cast<double>(new_value));
} else {
// Input has already been checked in StatBoxRow
exit(EXIT_FAILURE);
} }
std::cout << std::endl; std::cout << std::endl;
#endif
if (stat.type != UserStatType::Integer && stat.type != UserStatType::Float)
{
zenity("This stat isn't well understood by SamRewritten yet. Please notify the developers on Github.");
return;
}
if ( m_pending_stat_modifications.find(stat.id) == m_pending_stat_modifications.end() ) { if ( m_pending_stat_modifications.find(stat.id) == m_pending_stat_modifications.end() ) {
m_pending_stat_modifications.insert( std::pair<std::string, StatChange_t>(stat.id, (StatChange_t){stat.type, stat.id, new_value} ) ); m_pending_stat_modifications.insert( std::pair<std::string, StatChange_t>(stat.id, (StatChange_t){stat.type, stat.id, new_value} ) );
@ -252,7 +257,10 @@ MySteam::add_modification_stat(const StatValue_t& stat, std::any new_value) {
*/ */
void void
MySteam::remove_modification_stat(const StatValue_t& stat) { MySteam::remove_modification_stat(const StatValue_t& stat) {
#ifdef DEBUG_CERR
std::cout << "Removing stat modification: " << stat.id << std::endl; std::cout << "Removing stat modification: " << stat.id << std::endl;
#endif
// If there's not one pending, don't treat it as a warning currently // If there's not one pending, don't treat it as a warning currently
// because we don't really care to differentiate the // because we don't really care to differentiate the
// 0->1 and 2->1 character length transitions over in StatBoxRow // 0->1 and 2->1 character length transitions over in StatBoxRow

View File

@ -19,7 +19,7 @@ StatBoxRow::StatBoxRow(const StatValue_t& data)
Gtk::Box* title_box = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::ORIENTATION_VERTICAL, 0); Gtk::Box* title_box = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::ORIENTATION_VERTICAL, 0);
Gtk::MenuButton* more_info_button = Gtk::make_managed<Gtk::MenuButton>(); Gtk::MenuButton* more_info_button = Gtk::make_managed<Gtk::MenuButton>();
Gtk::Image* more_info_image = Gtk::make_managed<Gtk::Image>("gtk-info", Gtk::BuiltinIconSize::ICON_SIZE_BUTTON); Gtk::Image* more_info_image = Gtk::make_managed<Gtk::Image>("gtk-about", Gtk::BuiltinIconSize::ICON_SIZE_BUTTON);
Gtk::PopoverMenu* popover_menu = Gtk::make_managed<Gtk::PopoverMenu>(); Gtk::PopoverMenu* popover_menu = Gtk::make_managed<Gtk::PopoverMenu>();
Gtk::Box* popover_box = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::ORIENTATION_VERTICAL, 3); Gtk::Box* popover_box = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::ORIENTATION_VERTICAL, 3);
Gtk::Label* more_info_label = Gtk::make_managed<Gtk::Label>(); Gtk::Label* more_info_label = Gtk::make_managed<Gtk::Label>();
@ -30,7 +30,7 @@ StatBoxRow::StatBoxRow(const StatValue_t& data)
Gtk::Label* title_label = Gtk::make_managed<Gtk::Label>(""); Gtk::Label* title_label = Gtk::make_managed<Gtk::Label>("");
Gtk::Label* type_label = Gtk::make_managed<Gtk::Label>(""); Gtk::Label* type_label = Gtk::make_managed<Gtk::Label>("");
Gtk::Label* cur_value_label = Gtk::make_managed<Gtk::Label>(""); Gtk::Label* cur_value_label = Gtk::make_managed<Gtk::Label>("");
Gtk::Label* new_value_label = Gtk::make_managed<Gtk::Label>(""); Gtk::Label* incr_only_label = Gtk::make_managed<Gtk::Label>("");
Glib::RefPtr<Gtk::Adjustment> adjustment; Glib::RefPtr<Gtk::Adjustment> adjustment;
set_size_request(-1, 40); set_size_request(-1, 40);
@ -66,7 +66,6 @@ StatBoxRow::StatBoxRow(const StatValue_t& data)
type_label->set_label("Type: Float"); type_label->set_label("Type: Float");
cur_value_label->set_label("Current value: " + std::to_string(std::any_cast<double>(data.value))); cur_value_label->set_label("Current value: " + std::to_string(std::any_cast<double>(data.value)));
adjustment = Gtk::Adjustment::create(std::any_cast<double>(data.value), -DBL_MAX, DBL_MAX, 0.01, 5.0, 0.0); adjustment = Gtk::Adjustment::create(std::any_cast<double>(data.value), -DBL_MAX, DBL_MAX, 0.01, 5.0, 0.0);
// Reasonably chosen clime rate and digits, can be changed if someone complains..
m_new_value_entry.configure(adjustment, 0.01, 5); m_new_value_entry.configure(adjustment, 0.01, 5);
} else { } else {
type_label->set_label("Type: Unknown"); type_label->set_label("Type: Unknown");
@ -75,17 +74,16 @@ StatBoxRow::StatBoxRow(const StatValue_t& data)
m_new_value_entry.configure(adjustment, 0.0, 0); m_new_value_entry.configure(adjustment, 0.0, 0);
} }
cur_value_label->set_max_width_chars(10); if (data.incrementonly) {
new_value_label->set_label("New value: "); incr_only_label->set_label("Increment Only: Yes");
// Left align labels } else {
cur_value_label->set_xalign(0); incr_only_label->set_label("Increment Only: No");
new_value_label->set_xalign(0); }
title_label->set_label(data.display_name == "" ? data.id : data.display_name);
title_label->set_label(data.display_name);
title_box->pack_start(*title_label, false, true, 0); title_box->pack_start(*title_label, false, true, 0);
new_values_box->pack_start(*new_value_label, true, true, 0);
new_values_box->pack_start(m_new_value_entry, true, true, 0); new_values_box->pack_start(m_new_value_entry, true, true, 0);
values_box->pack_start(*cur_value_label, false, true, 0);
values_box->pack_start(*new_values_box, false, true, 0); values_box->pack_start(*new_values_box, false, true, 0);
layout->pack_start(*title_box, true, true, 0); layout->pack_start(*title_box, true, true, 0);
layout->pack_start(m_invalid_conversion_box, false, true, 0); layout->pack_start(m_invalid_conversion_box, false, true, 0);
@ -96,9 +94,12 @@ StatBoxRow::StatBoxRow(const StatValue_t& data)
popover_box->pack_start(*more_info_label, false, true, 0); popover_box->pack_start(*more_info_label, false, true, 0);
popover_box->pack_start(*sep_one, false, true, 0); popover_box->pack_start(*sep_one, false, true, 0);
popover_box->pack_start(*type_label, false, true, 0); popover_box->pack_start(*type_label, false, true, 0);
popover_box->pack_start(*cur_value_label, false, true, 0);
popover_box->pack_start(*incr_only_label, false, true, 0);
popover_menu->add(*popover_box); popover_menu->add(*popover_box);
popover_box->show_all(); popover_box->show_all();
layout->set_valign(Gtk::Align::ALIGN_CENTER);
add(*layout); add(*layout);
m_new_value_entry.signal_changed().connect(sigc::mem_fun(this, &StatBoxRow::on_new_value_changed)); m_new_value_entry.signal_changed().connect(sigc::mem_fun(this, &StatBoxRow::on_new_value_changed));