Updating buttons and dialogue

This commit is contained in:
Remnants of Forgotten Disney
2024-03-29 11:55:54 -05:00
parent 6bef2b58f2
commit de40daa51e
15 changed files with 462 additions and 818 deletions

View File

@@ -3,7 +3,7 @@
#include <cstring>
#include "text_engine.h"
#include "global_frame_counter.h"
#include "global_frame_controller.h"
#include "pkmn_font.h"
#include "script_array.h"
@@ -14,7 +14,7 @@ script_obj curr_line;
uint char_index;
uint line_char_index;
std::string curr_text;
bool disabled;
bool text_exit;
void init_text_engine()
{
@@ -26,25 +26,25 @@ void init_text_engine()
pal_bg_bank[13][15] = CLR_WHITE;
pal_bg_bank[14][15] = 0b0000001001111111;
pal_bg_bank[15][15] = 0b0001100011100110;
// Set default variables
curr_line = script[SCRIPT_START];
char_index = 0;
line_char_index = 0;
disabled = false;
curr_text = curr_line.get_text();
text_exit = false;
}
void text_next_frame()
int text_loop()
{
if (!disabled)
show_text_box();
tte_set_margins(LEFT, TOP, RIGHT, BOTTOM);
while (true)
{
tte_set_margins(LEFT, TOP, RIGHT, BOTTOM);
tte_set_pos(LEFT, TOP);
if (char_index < curr_text.length() && curr_text.substr(char_index, 1) != "|")
{
if (get_frame_count() % 2 == 0 || key_held(KEY_B))
if (get_frame_count() % 2 == 0 || key_held(KEY_B) || key_held(KEY_A))
{
char_index++;
tte_erase_rect(LEFT, TOP, RIGHT, BOTTOM);
@@ -53,24 +53,31 @@ void text_next_frame()
}
else
{
if (key_hit(KEY_A) || curr_text.length() == 0)
if (key_hit(KEY_A) || key_hit(KEY_B) || curr_text.length() == 0)
{
if (curr_text.substr(char_index, 1) == "|")
{
line_char_index += char_index;
line_char_index++;
curr_text = curr_line.get_text().substr(line_char_index);
char_index = 0;
}
else
{
line_char_index = 0;
curr_line = script[text_next_obj_id(curr_line)];
curr_text = curr_line.get_text();
char_index = 0;
}
char_index = 0;
}
}
if (text_exit)
{
hide_text_box();
tte_erase_rect(LEFT, TOP, RIGHT, BOTTOM);
text_exit = false;
return 0;
}
global_next_frame();
}
}
@@ -90,19 +97,6 @@ int text_next_obj_id(script_obj current_line)
}
}
void text_enable()
{
disabled = false;
show_text_box();
}
void text_disable()
{
disabled = true;
tte_erase_screen();
hide_text_box();
}
void show_text_box()
{
REG_BG2CNT = (REG_BG2CNT & ~BG_PRIO_MASK) | BG_PRIO(1);
@@ -112,3 +106,8 @@ void hide_text_box()
{
REG_BG2CNT = (REG_BG2CNT & ~BG_PRIO_MASK) | BG_PRIO(3);
}
void set_text_exit()
{
text_exit = true;
}