Finished textbox, learned that windows aren't transparent
This commit is contained in:
@@ -21,7 +21,7 @@ inline void conversationTextboxInit() {
|
||||
TEXTBOX_STATE = 0;
|
||||
|
||||
// Setup window data
|
||||
// move_win(7, SCREENHEIGHT - (TEXTBOX_HEIGHT_IN_TILES * 8));
|
||||
move_win(7, SCREENHEIGHT - (TEXTBOX_HEIGHT_IN_TILES * 8));
|
||||
set_win_data(FONT_DATA_POSITION, FONT_IMAGE_TILES, FONT_IMAGE);
|
||||
set_win_data(BORDER_DATA_POSITION, BORDER_IMAGE_TILES, BORDER_IMAGE);
|
||||
|
||||
@@ -41,9 +41,8 @@ inline void conversationTextboxInit() {
|
||||
TEXTBOX_TILES[TEXTBOX_WIDTH_IN_TILES * (i+1) - 1] = BORDER_TILE_CENTER_RIGHT;
|
||||
}
|
||||
|
||||
// Setup tiles.
|
||||
set_win_tiles(
|
||||
0, 0,
|
||||
0x00, 0x00,
|
||||
TEXTBOX_WIDTH_IN_TILES, TEXTBOX_HEIGHT_IN_TILES,
|
||||
TEXTBOX_TILES
|
||||
);
|
||||
@@ -53,7 +52,10 @@ void conversationTextboxSetText(char *text) {
|
||||
uint8_t i, j, k, rowStart, stateFlags;
|
||||
char c, c2;
|
||||
|
||||
// Begin by filling the textbox text chars with whitespace to begin.
|
||||
// TODO: I'm pretty sure I can move this lower and optimize.
|
||||
for(i = 0; i < TEXTBOX_SCROLL_ROWS_MAX * TEXTBOX_CHARS_PER_ROW; i++) {
|
||||
break;
|
||||
TEXTBOX_TEXTS[i] = ' ';
|
||||
}
|
||||
|
||||
@@ -66,9 +68,9 @@ void conversationTextboxSetText(char *text) {
|
||||
|
||||
// Copy source text to buffer, also determine wordwrapping here.
|
||||
i = 0, j = 0, rowStart = 0, stateFlags = 0;
|
||||
while((c = text[i]) != '\0') {
|
||||
while((c = text[i]) != '\0') {// "For each char in string"
|
||||
if(c == ' ') {
|
||||
// Scan ahead and look at how many chars remain to the next space
|
||||
// Scan ahead and look at how many chars remain to the next space.
|
||||
k = i + 1;
|
||||
while(
|
||||
(c2 = text[k]) != '\0' &&
|
||||
@@ -86,16 +88,18 @@ void conversationTextboxSetText(char *text) {
|
||||
stateFlags |= 1 << 0;
|
||||
}
|
||||
|
||||
// Do we need to newline?
|
||||
// Do we need to insert newline where we are currently?
|
||||
if((stateFlags & (1 << 0)) != 0) {
|
||||
stateFlags &= ~(1 << 0);
|
||||
rowStart = i;
|
||||
j = ((j / TEXTBOX_CHARS_PER_ROW) + 1) * TEXTBOX_CHARS_PER_ROW;
|
||||
stateFlags &= ~(1 << 0);// Remove newline flag
|
||||
i++;
|
||||
rowStart = i;// Update the row start (Should this be i+1?)
|
||||
//TODO: can I optimize the next line by using rowStart somehow?
|
||||
j = ((j / TEXTBOX_CHARS_PER_ROW) + 1) * TEXTBOX_CHARS_PER_ROW;// Update destination character position.
|
||||
TEXTBOX_ROW_COUNT++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Insert the character
|
||||
TEXTBOX_TEXTS[j] = c;
|
||||
i++;
|
||||
j++;
|
||||
@@ -162,8 +166,8 @@ inline void conversationTextboxUpdate() {
|
||||
} else {
|
||||
tiles[0] = c - 33 + FONT_DATA_POSITION;
|
||||
set_win_tiles(
|
||||
1 + (TEXTBOX_SCROLL % TEXTBOX_CHARS_PER_ROW),
|
||||
1 + (TEXTBOX_SCROLL / TEXTBOX_CHARS_PER_ROW),
|
||||
0x01 + (TEXTBOX_SCROLL % TEXTBOX_CHARS_PER_ROW),
|
||||
0x01 + (TEXTBOX_SCROLL / TEXTBOX_CHARS_PER_ROW),
|
||||
1, 1,
|
||||
tiles
|
||||
);
|
||||
|
Reference in New Issue
Block a user