Skip to content

Commit

Permalink
remove line popping
Browse files Browse the repository at this point in the history
  • Loading branch information
corwinkuiper committed Apr 14, 2024
1 parent d43e746 commit 4522a97
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 36 deletions.
25 changes: 0 additions & 25 deletions agb/src/display/object/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,31 +392,6 @@ impl ObjectTextRender<'_> {
);
}

/// Removes one complete line. Returns whether a line could be removed. You must call [`update`][ObjectTextRender::update] after this
pub fn pop_line(&mut self) -> bool {
let width = self.layout.area.x;
let space = self.buffer.font.letter(' ').advance_width as i32;
let line_height = self.buffer.font.line_height();
if let Some(line) = self.buffer.preprocessor.lines(width, space).next() {
// there is a line
if self.number_of_objects >= line.number_of_letter_groups() {
// we have enough rendered letter groups to count
self.number_of_objects -= line.number_of_letter_groups();
for _ in 0..line.number_of_letter_groups() {
self.buffer.letters.letters.pop_front();
self.layout.relative_positions.pop_front();
}
self.layout.line_capacity.pop_front();
self.buffer.preprocessor.pop(&line);
for position in self.layout.relative_positions.iter_mut() {
position.y -= line_height as i16;
}
return true;
}
}
false
}

/// Updates the internal state of the number of letters to write and popped
/// line. Should be called in the same frame as and after
/// [`next_letter_group`][ObjectTextRender::next_letter_group], [`next_line`][ObjectTextRender::next_line], and [`pop_line`][ObjectTextRender::pop_line].
Expand Down
11 changes: 0 additions & 11 deletions agb/src/display/object/font/preprocess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,6 @@ impl Line {
self.width
}
#[inline(always)]
pub(crate) fn number_of_text_elements(&self) -> usize {
self.number_of_text_elements
}
#[inline(always)]
pub(crate) fn number_of_spaces(&self) -> usize {
self.number_of_spaces
}
Expand Down Expand Up @@ -215,13 +211,6 @@ impl Preprocessed {
.add_character(font, c, sprite_width, &mut self.widths);
}

pub(crate) fn pop(&mut self, line: &Line) {
let elements = line.number_of_text_elements();
for _ in 0..elements {
self.widths.pop_front();
}
}

pub(crate) fn lines(&self, layout_width: i32, minimum_space_width: i32) -> Lines<'_> {
Lines {
minimum_space_width,
Expand Down

0 comments on commit 4522a97

Please sign in to comment.