mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-16 06:31:46 -06:00
Hints notification random weighted order with saving used hints to cache/hints.cereal
This commit is contained in:
parent
d3f11a6ab7
commit
cfcfbc38d2
3 changed files with 180 additions and 68 deletions
|
@ -9,7 +9,10 @@ namespace GUI {
|
|||
// Database of hints updatable
|
||||
struct HintData
|
||||
{
|
||||
std::string id_string;
|
||||
std::string text;
|
||||
size_t weight;
|
||||
bool was_displayed;
|
||||
std::string hypertext;
|
||||
std::string follow_text;
|
||||
std::string disabled_tags;
|
||||
|
@ -33,11 +36,12 @@ private:
|
|||
: m_hint_id(0)
|
||||
{}
|
||||
public:
|
||||
~HintDatabase();
|
||||
HintDatabase(HintDatabase const&) = delete;
|
||||
void operator=(HintDatabase const&) = delete;
|
||||
|
||||
// return true if HintData filled;
|
||||
HintData* get_hint(bool up = true);
|
||||
HintData* get_hint(bool new_hint = true);
|
||||
size_t get_count() {
|
||||
if (!m_initialized)
|
||||
return 0;
|
||||
|
@ -46,10 +50,17 @@ public:
|
|||
private:
|
||||
void init();
|
||||
void load_hints_from_file(const boost::filesystem::path& path);
|
||||
bool is_used(const std::string& id);
|
||||
void set_used(const std::string& id);
|
||||
void clear_used();
|
||||
// Returns position in m_loaded_hints with next hint chosed randomly with weights
|
||||
size_t get_next();
|
||||
size_t m_hint_id;
|
||||
bool m_initialized { false };
|
||||
std::vector<HintData> m_loaded_hints;
|
||||
|
||||
bool m_sorted_hints { false };
|
||||
std::vector<std::string> m_used_ids;
|
||||
bool m_used_ids_loaded { false };
|
||||
};
|
||||
// Notification class - shows current Hint ("Did you know")
|
||||
class NotificationManager::HintNotification : public NotificationManager::PopNotification
|
||||
|
@ -58,10 +69,10 @@ public:
|
|||
HintNotification(const NotificationData& n, NotificationIDProvider& id_provider, wxEvtHandler* evt_handler, bool new_hint)
|
||||
: PopNotification(n, id_provider, evt_handler)
|
||||
{
|
||||
retrieve_data(new_hint ? 0 : -1);
|
||||
retrieve_data(new_hint);
|
||||
}
|
||||
virtual void init() override;
|
||||
void open_next() { retrieve_data(0); }
|
||||
void open_next() { retrieve_data(); }
|
||||
protected:
|
||||
virtual void set_next_window_size(ImGuiWrapper& imgui) override;
|
||||
virtual void count_spaces() override;
|
||||
|
@ -87,7 +98,7 @@ protected:
|
|||
const float win_size_x, const float win_size_y,
|
||||
const float win_pos_x, const float win_pos_y);
|
||||
// recursion counter -1 tells to retrieve same hint as last time
|
||||
void retrieve_data(int recursion_counter = 0);
|
||||
void retrieve_data(bool new_hint = true);
|
||||
void open_documentation();
|
||||
|
||||
bool m_has_hint_data { false };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue