forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dialogue_win.h
87 lines (73 loc) · 2.97 KB
/
dialogue_win.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
#pragma once
#ifndef CATA_SRC_DIALOGUE_WIN_H
#define CATA_SRC_DIALOGUE_WIN_H
#include <cstddef>
#include <iosfwd>
#include <vector>
#include "color.h"
#include "cursesdef.h"
struct talk_data {
nc_color color;
std::string hotkey_desc;
std::string text;
};
class ui_adaptor;
/**
* NPC conversation dialogue window.
*/
class dialogue_window
{
public:
dialogue_window() = default;
void resize( ui_adaptor &ui );
void draw( const std::string &npc_name, const std::vector<talk_data> &responses );
void handle_scrolling( const std::string &action, int num_responses );
void refresh_response_display();
/** Adds a message to the conversation history. */
void add_to_history( const std::string &text );
/** Adds a message to the conversation history for a given speaker. */
void add_to_history( const std::string &text, const std::string &speaker_name,
nc_color speaker_color );
/** Adds a separator to the conversation history. */
void add_history_separator();
/** Unhighlights all messages. */
void clear_history_highlights();
bool is_computer = false;
int sel_response = 0;
private:
catacurses::window d_win;
struct history_message {
inline history_message( nc_color c, const std::string &t ) : color( c ), text( t ) {}
nc_color color; // Text color when highlighted
std::string text;
};
void add_to_history( const std::string &text, nc_color color );
void add_to_folded_history( const history_message &message, bool is_highlighted );
void rebuild_folded_history();
/**
* This contains the exchanged words, it is basically like the global message log.
*
* Each responses of the player character and the NPC are added as are information about
* what each of them does (e.g. the npc drops their weapon).
* This will be displayed in the dialog window and should already be translated.
*/
std::vector<history_message> history;
/** Number of history messages to highlight. */
int num_lines_highlighted;
/** Cache of folded history text */
std::vector<history_message> history_folded; // Cache of folded history text
/** Number of folded history messages to highlight. */
int num_folded_lines_highlighted;
/** Stored responses (hotkey, lines) */
std::vector<std::tuple<std::string, std::vector<std::string>>> folded_txt;
std::vector<int> folded_heights;
// yoffset of the current response window
int scroll_yoffset = 0;
bool can_scroll_up = false;
bool can_scroll_down = false;
nc_color default_color();
void print_header( const std::string &name );
void print_history();
bool print_responses( const std::vector<talk_data> &responses );
};
#endif // CATA_SRC_DIALOGUE_WIN_H