Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix page breaks not working properly when any of the 'lang' series of commands are not used #10

Open
wants to merge 1 commit into
base: mod
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/PonscripterLabel_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1739,6 +1739,7 @@ int PonscripterLabel::getreadlangCommand(const pstring& cmd)
int PonscripterLabel::showlangenCommand(const pstring& cmd)
{
current_language = 0;
current_language_set = 1;
//loadSaveFile(15);
text_info.fill(0, 0, 0, 0);
flush(refreshMode(), &sentence_font_info.pos);
Expand All @@ -1749,6 +1750,7 @@ int PonscripterLabel::showlangenCommand(const pstring& cmd)
int PonscripterLabel::showlangjpCommand(const pstring& cmd)
{
current_language = 1;
current_language_set = 1;
//loadSaveFile(15);
text_info.fill(0, 0, 0, 0);
flush(refreshMode(), &sentence_font_info.pos);
Expand All @@ -1759,6 +1761,7 @@ int PonscripterLabel::showlangjpCommand(const pstring& cmd)
int PonscripterLabel::langenCommand(const pstring& cmd)
{
current_read_language = 0;
current_language_set = 1;

return RET_CONTINUE;
}
Expand All @@ -1769,13 +1772,15 @@ int PonscripterLabel::langjpCommand(const pstring& cmd)
// saveSaveFile(15);
//}
current_read_language = 1;
current_language_set = 1;

return RET_CONTINUE;
}

int PonscripterLabel::langallCommand(const pstring& cmd)
{
current_read_language = -1;
current_language_set = 1;

return RET_CONTINUE;
}
Expand Down
2 changes: 1 addition & 1 deletion src/PonscripterLabel_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ int PonscripterLabel::clickNewPage(bool display_char)
{
const char* c = script_h.getStrBuf(string_buffer_offset);

if (current_read_language != -1 && current_read_language != current_language) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like "if current_read_language is not the display language" (AKA "if the script's text is not supposed to be shown")

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The initial state is when langall is set (so current_read_language would be -1).

However, when the 'lang' series of commands are never used, current_read_language would be stuck at -1, so clickstr_state = CLICK_NEWPAGE; never gets executed, resulting in the page break glyph not being shown and text continually printing off screen.

This if statement is the correct one to modify.

if ((current_read_language != -1 && current_read_language != current_language) || (!current_language_set)) {
clickstr_state = CLICK_NEWPAGE;
}

Expand Down
2 changes: 2 additions & 0 deletions src/ScriptParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ ScriptParser::ScriptParser()

current_language = 0;
current_read_language = -1;
current_language_set = 0;
syscall_dict["skip"] = SYSTEM_SKIP;
syscall_dict["reset"] = SYSTEM_RESET;
syscall_dict["save"] = SYSTEM_SAVE;
Expand Down Expand Up @@ -268,6 +269,7 @@ void ScriptParser::reset()
max_text_buffer = MAX_TEXT_BUFFER;
num_chars_in_sentence = 0;
current_read_language = -1;
current_language_set = 0;

// textbufferchange
int i;
Expand Down
1 change: 1 addition & 0 deletions src/ScriptParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ class ScriptParser {
TextBuffer *start_text_buffer[2], *current_text_buffer[2];
int current_language;
int current_read_language;
int current_language_set;

void TextBuffer_dumpstate(int = 0);
int max_text_buffer;
Expand Down