@@ -24,6 +24,23 @@ namespace tgui {
24
24
character ( L' ' ), foreground( screen::color::WHITE ), background( screen::color::BLACK ) {
25
25
}
26
26
27
+ void screen_buffer::cell::render ( screen::color& last_foreground, screen::color& last_background ) const {
28
+ bool foreground_differs = foreground != last_foreground;
29
+ bool background_differs = background != last_background;
30
+
31
+ if ( foreground_differs && background_differs )
32
+ screen::set_color ( foreground, background );
33
+ else if ( foreground_differs )
34
+ screen::set_foreground_color ( foreground );
35
+ else if ( background_differs )
36
+ screen::set_background_color ( background );
37
+
38
+ std::wcout << character;
39
+
40
+ last_foreground = foreground;
41
+ last_background = background;
42
+ }
43
+
27
44
bool screen_buffer::cell::operator == ( const cell& rhs ) const {
28
45
return (character == rhs.character ) && (foreground == rhs.foreground ) && (background == rhs.background );
29
46
}
@@ -44,12 +61,33 @@ namespace tgui {
44
61
return cells[pos.column ][pos.row ] != old_buffer.cells [pos.column ][pos.row ];
45
62
};
46
63
} else {
47
- cell_changed = [](const screen::position&) {return true ;};
64
+ cell_changed = [](const screen::position&) {
65
+ return true ;
66
+ };
48
67
}
49
68
69
+ screen::position cur_pos;
70
+ screen::color last_foreground = screen::color::WHITE;
71
+ screen::color last_background = screen::color::BLACK;
72
+ bool continuous = true ;
73
+
50
74
screen::set_cursor_position ( 0 , 0 );
75
+ screen::set_color ( last_foreground, last_background );
76
+
77
+ for ( cur_pos.column = 0 ; cur_pos.column < size.column ; ++cur_pos.column ) {
78
+ for ( cur_pos.row = 0 ; cur_pos.row < size.row ; ++cur_pos.row ) {
79
+ if ( cell_changed ( cur_pos ) ) {
80
+ if ( !continuous )
81
+ screen::set_cursor_position ( cur_pos );
51
82
52
- // TODO actual rendering
83
+ cells[cur_pos.column ][cur_pos.row ].render ( last_foreground, last_background );
84
+
85
+ continuous = true ;
86
+ } else {
87
+ continuous = false ;
88
+ }
89
+ }
90
+ }
53
91
}
54
92
55
93
bool screen_buffer::operator == ( const screen_buffer& rhs ) const {
0 commit comments