mirror of
https://github.com/GearsProgress/Poke_Transporter_GB.git
synced 2026-08-28 11:45:14 -05:00
Working menu!
This commit is contained in:
@@ -14,46 +14,54 @@ const int RIGHT = H_MAX - LEFT;
|
||||
const int TOP = 120;
|
||||
const int BOTTOM = V_MAX;
|
||||
|
||||
uint char_count = 0;
|
||||
script_obj curr_line;
|
||||
int frame_count;
|
||||
uint char_count;
|
||||
bool disabled;
|
||||
|
||||
text_engine::text_engine()
|
||||
void init_text_engine()
|
||||
{
|
||||
// Load the TTE
|
||||
tte_init_se(3, BG_CBB(TEXT_CBB)|BG_SBB(TEXT_SBB)|BG_PRIO(0), 0xF000, CLR_PURPLE, 0, &fwf_default, NULL);
|
||||
tte_init_se(3, BG_CBB(TEXT_CBB) | BG_SBB(TEXT_SBB) | BG_PRIO(0), 0xF000, CLR_ORANGE, 0, &fwf_default, NULL);
|
||||
tte_set_margins(LEFT, TOP, RIGHT, BOTTOM);
|
||||
tte_set_pos(LEFT, TOP);
|
||||
|
||||
// Set default variables
|
||||
curr_line = script[0];
|
||||
frame_count = 0;
|
||||
char_count = 0;
|
||||
disabled = false;
|
||||
}
|
||||
|
||||
void text_engine::next_frame()
|
||||
void text_next_frame()
|
||||
{
|
||||
tte_set_pos(LEFT, TOP);
|
||||
if (char_count < curr_line.get_text().length())
|
||||
if (!disabled)
|
||||
{
|
||||
if (frame_count % 2 == 0 || key_held(KEY_B))
|
||||
tte_set_pos(LEFT, TOP);
|
||||
if (char_count < curr_line.get_text().length())
|
||||
{
|
||||
char_count++;
|
||||
tte_erase_rect(LEFT, TOP, RIGHT, BOTTOM);
|
||||
tte_set_ink(CLR_RED);
|
||||
tte_write(curr_line.get_text().substr(0, char_count).c_str());
|
||||
if (frame_count % 2 == 0 || key_held(KEY_B))
|
||||
{
|
||||
char_count++;
|
||||
tte_erase_rect(LEFT, TOP, RIGHT, BOTTOM);
|
||||
tte_set_ink(CLR_RED);
|
||||
tte_write(curr_line.get_text().substr(0, char_count).c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (key_hit(KEY_A) || char_count == 0)
|
||||
else
|
||||
{
|
||||
curr_line = script[get_next_obj_id(curr_line)];
|
||||
char_count = 0;
|
||||
if (key_hit(KEY_A) || char_count == 0)
|
||||
{
|
||||
curr_line = script[text_next_obj_id(curr_line)];
|
||||
char_count = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
frame_count++;
|
||||
frame_count++;
|
||||
}
|
||||
}
|
||||
|
||||
int text_engine::get_next_obj_id(script_obj current_line)
|
||||
int text_next_obj_id(script_obj current_line)
|
||||
{
|
||||
if (current_line.get_cond_id() == 0)
|
||||
{
|
||||
@@ -69,3 +77,15 @@ int text_engine::get_next_obj_id(script_obj current_line)
|
||||
}
|
||||
}
|
||||
|
||||
void text_enable()
|
||||
{
|
||||
disabled = false;
|
||||
REG_BG2CNT = (REG_BG2CNT & ~BG_PRIO_MASK) | BG_PRIO(1);
|
||||
}
|
||||
|
||||
void text_disable()
|
||||
{
|
||||
disabled = true;
|
||||
tte_erase_screen();
|
||||
REG_BG2CNT = (REG_BG2CNT & ~BG_PRIO_MASK) | BG_PRIO(3);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user