Skip to content

Commit

Permalink
fix to ctrl-press handling for leaveTextDisplayMode (to not call it d…
Browse files Browse the repository at this point in the history
…uring graphic updating); added savedirCommand
  • Loading branch information
sonozaki committed Jun 24, 2009
1 parent f7b35d5 commit 4f67e0d
Show file tree
Hide file tree
Showing 12 changed files with 169 additions and 119 deletions.
7 changes: 7 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2009-06-23

Changed "wait" command to do an actual timed wait even in ctrl/skip mode,
just for a reduced duration.
Added command "savedir". [Mion]


2009-06-21

Fix for rain effect on PPC.
Expand Down
41 changes: 10 additions & 31 deletions ONScripterLabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,23 +606,6 @@ void ONScripterLabel::setDLLFile(const char *filename)
setStr(&dll_file, filename);
}

void ONScripterLabel::setArchivePath(const char *path)
{
if (archive_path) {
delete archive_path;
archive_path = NULL;
}
archive_path = new DirPaths(path);
//printf("archive_path: %s\n", archive_path->get_all_paths());
}

void ONScripterLabel::setSavePath(const char *path)
{
if (script_h.save_path) delete[] script_h.save_path;
script_h.save_path = new char[ strlen(path) + 2 ];
sprintf( script_h.save_path, "%s%c", path, DELIMITER );
}

void ONScripterLabel::setFullscreenMode()
{
fullscreen_mode = true;
Expand Down Expand Up @@ -818,19 +801,19 @@ int ONScripterLabel::init()
#endif
}
if ( script_h.game_identifier ) {
delete[] script_h.game_identifier;
script_h.game_identifier = NULL;
delete[] script_h.game_identifier;
script_h.game_identifier = NULL;
}

if (strcmp(script_h.save_path,archive_path->get_path(0)) != 0) {
// insert save_path onto the front of archive_path
// The string returned by get_all_paths is deleted in ~DirPaths(), so the
// simplest way to do this is to create the new object before deleting the
// old one.
DirPaths* new_paths = new DirPaths(script_h.save_path);
new_paths->add(archive_path->get_all_paths());
delete archive_path;
archive_path = new_paths;
// The string returned by get_all_paths is deleted in ~DirPaths(), so the
// simplest way to do this is to create the new object before deleting the
// old one.
DirPaths* new_paths = new DirPaths(script_h.save_path);
new_paths->add(archive_path->get_all_paths());
delete archive_path;
archive_path = new_paths;
((DirectReader*) script_h.cBR)->setArchivePath(archive_path);
}

Expand Down Expand Up @@ -981,6 +964,7 @@ void ONScripterLabel::reset()
ctrl_pressed_status = 0;
display_mode = DISPLAY_MODE_NORMAL;
event_mode = IDLE_EVENT_MODE;
did_leavetext = false;
in_effect_blank = false;
all_sprite_hide_flag = false;
all_sprite2_hide_flag = false;
Expand Down Expand Up @@ -1036,11 +1020,6 @@ void ONScripterLabel::reset()

resetSub();

/* ---------------------------------------- */
/* Load global variables if available */
if ( loadFileIOBuf( "gloval.sav" ) == 0 ||
loadFileIOBuf( "global.sav" ) == 0 )
readVariables( script_h.global_variable_border, VARIABLE_RANGE );
}

void ONScripterLabel::resetSub()
Expand Down
3 changes: 1 addition & 2 deletions ONScripterLabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ class ONScripterLabel : public ScriptParser
void setFontFile(const char *filename);
void setRegistryFile(const char *filename);
void setDLLFile(const char *filename);
void setSavePath(const char *path);
void setArchivePath(const char *path);
void setFullscreenMode();
void setWindowMode();
void enableButtonShortCut();
Expand Down Expand Up @@ -427,6 +425,7 @@ class ONScripterLabel : public ScriptParser
int refresh_shadow_text_mode;
int current_refresh_mode;
int display_mode;
bool did_leavetext;
int event_mode;
SDL_Surface *accumulation_surface; // Final image, i.e. picture_surface (+ shadow + text_surface)
SDL_Surface *backup_surface; // Final image w/o (shadow + text_surface) used in leaveTextDisplayMode()
Expand Down
112 changes: 43 additions & 69 deletions ONScripterLabel_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,8 @@ int ONScripterLabel::waitCommand()

int ONScripterLabel::vspCommand()
{
if (!( skip_mode & (SKIP_NORMAL | SKIP_TO_EOP) || ctrl_pressed_status )) {
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;
}
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;

bool vsp2_flag = false;
if (script_h.isName("vsp2")) vsp2_flag = true;
Expand Down Expand Up @@ -323,10 +321,9 @@ int ONScripterLabel::tateyokoCommand()

int ONScripterLabel::talCommand()
{
if (!( skip_mode & (SKIP_NORMAL | SKIP_TO_EOP) || ctrl_pressed_status )) {
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;
}
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;

char loc = script_h.readName()[0];
int no = -1, trans = 0;
if ( loc == 'l' ) no = 0;
Expand Down Expand Up @@ -379,10 +376,8 @@ int ONScripterLabel::systemcallCommand()

int ONScripterLabel::strspCommand()
{
if (!( skip_mode & (SKIP_NORMAL | SKIP_TO_EOP) || ctrl_pressed_status )) {
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;
}
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;

bool v=true;

Expand Down Expand Up @@ -450,10 +445,8 @@ int ONScripterLabel::stopCommand()

int ONScripterLabel::sp_rgb_gradationCommand()
{
if (!( skip_mode & (SKIP_NORMAL | SKIP_TO_EOP) || ctrl_pressed_status )) {
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;
}
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;

int no = script_h.readInt();
int upper_r = script_h.readInt();
Expand Down Expand Up @@ -555,10 +548,8 @@ int ONScripterLabel::spstrCommand()

int ONScripterLabel::spreloadCommand()
{
if (!( skip_mode & (SKIP_NORMAL | SKIP_TO_EOP) || ctrl_pressed_status )) {
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;
}
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;

int no = script_h.readInt();
AnimationInfo *si;
Expand Down Expand Up @@ -1351,10 +1342,8 @@ int ONScripterLabel::puttextCommand()

int ONScripterLabel::prnumclearCommand()
{
if (!( skip_mode & (SKIP_NORMAL | SKIP_TO_EOP) || ctrl_pressed_status )) {
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;
}
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;

for ( int i=0 ; i<MAX_PARAM_NUM ; i++ ) {
if ( prnum_info[i] ) {
Expand All @@ -1368,10 +1357,8 @@ int ONScripterLabel::prnumclearCommand()

int ONScripterLabel::prnumCommand()
{
if (!( skip_mode & (SKIP_NORMAL | SKIP_TO_EOP) || ctrl_pressed_status )) {
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;
}
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;

int no = script_h.readInt();
if ( prnum_info[no] ){
Expand Down Expand Up @@ -1406,10 +1393,8 @@ int ONScripterLabel::prnumCommand()

int ONScripterLabel::printCommand()
{
if (!( skip_mode & (SKIP_NORMAL | SKIP_TO_EOP) || ctrl_pressed_status )) {
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;
}
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;

if ( event_mode & EFFECT_EVENT_MODE ){
return doEffect( parseEffect(false) );
Expand Down Expand Up @@ -1476,10 +1461,8 @@ int ONScripterLabel::negaCommand()

int ONScripterLabel::mspCommand()
{
if (!( skip_mode & (SKIP_NORMAL | SKIP_TO_EOP) || ctrl_pressed_status )) {
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;
}
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;

bool msp2_flag = false;
if (script_h.isName("msp2")) msp2_flag = true;
Expand Down Expand Up @@ -1771,10 +1754,8 @@ int ONScripterLabel::menu_automodeCommand()

int ONScripterLabel::lsp2Command()
{
if (!( skip_mode & (SKIP_NORMAL | SKIP_TO_EOP) || ctrl_pressed_status )) {
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;
}
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;

bool v=true;

Expand Down Expand Up @@ -1843,10 +1824,8 @@ int ONScripterLabel::lsp2Command()

int ONScripterLabel::lspCommand()
{
if (!( skip_mode & (SKIP_NORMAL | SKIP_TO_EOP) || ctrl_pressed_status )) {
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;
}
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;

bool v=true;

Expand Down Expand Up @@ -1957,10 +1936,8 @@ int ONScripterLabel::lookbackbuttonCommand()

int ONScripterLabel::logspCommand()
{
if (!( skip_mode & (SKIP_NORMAL | SKIP_TO_EOP) || ctrl_pressed_status )) {
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;
}
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;

bool logsp2_flag = false;

Expand Down Expand Up @@ -2116,10 +2093,8 @@ int ONScripterLabel::linkcolorCommand()
int ONScripterLabel::ldCommand()
{
//Mion: remove text to animate sprites, if in normal mode
if (!( skip_mode & (SKIP_NORMAL | SKIP_TO_EOP) || ctrl_pressed_status )) {
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;
}
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;

char loc = script_h.readName()[0];
int no = -1;
Expand Down Expand Up @@ -2318,10 +2293,9 @@ int ONScripterLabel::indentCommand()

int ONScripterLabel::humanorderCommand()
{
if (!( skip_mode & (SKIP_NORMAL | SKIP_TO_EOP) || ctrl_pressed_status )) {
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;
}
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;

const char *buf = script_h.readStr();
int i;
for (i=0 ; i<3 ; i++){
Expand Down Expand Up @@ -2799,6 +2773,12 @@ int ONScripterLabel::gameCommand()
int i;
current_mode = NORMAL_MODE;

/* ---------------------------------------- */
/* Load global variables if available */
if ( loadFileIOBuf( "gloval.sav" ) == 0 ||
loadFileIOBuf( "global.sav" ) == 0 )
readVariables( script_h.global_variable_border, VARIABLE_RANGE );

/* ---------------------------------------- */
if ( !lookback_info[0].image_surface ){
setStr( &lookback_info[0].image_name, DEFAULT_LOOKBACK_NAME0 );
Expand Down Expand Up @@ -3270,10 +3250,8 @@ int ONScripterLabel::defineresetCommand()

int ONScripterLabel::cspCommand()
{
if (!( skip_mode & (SKIP_NORMAL | SKIP_TO_EOP) || ctrl_pressed_status )) {
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;
}
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;

bool csp2_flag = false;
if (script_h.isName("csp2")) csp2_flag = true;
Expand Down Expand Up @@ -3392,10 +3370,8 @@ int ONScripterLabel::clickCommand()

int ONScripterLabel::clCommand()
{
if (!( skip_mode & (SKIP_NORMAL | SKIP_TO_EOP) || ctrl_pressed_status )) {
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;
}
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;

char loc = script_h.readName()[0];

Expand Down Expand Up @@ -3868,7 +3844,7 @@ int ONScripterLabel::bgcopyCommand()

int ONScripterLabel::bgCommand()
{
int ret = leaveTextDisplayMode();
int ret = leaveTextDisplayMode(true);
if ( ret != RET_NOMATCH ) return ret;

const char *buf;
Expand Down Expand Up @@ -3979,10 +3955,8 @@ int ONScripterLabel::autoclickCommand()

int ONScripterLabel::amspCommand()
{
if (!( skip_mode & (SKIP_NORMAL | SKIP_TO_EOP) || ctrl_pressed_status )) {
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;
}
int ret = leaveTextDisplayMode();
if ( ret != RET_NOMATCH ) return ret;

bool amsp2_flag = false;
if (script_h.isName("amsp2")) amsp2_flag = true;
Expand Down
21 changes: 17 additions & 4 deletions ONScripterLabel_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ void ONScripterLabel::searchSaveFile( SaveFileInfo &save_file_info, int no )

script_h.getStringFromInteger( save_file_info.sjis_no, no, (num_save_file >= 10)?2:1 );
#if defined(LINUX) || defined(MACOSX)
sprintf( file_name, "%ssave%d.dat", script_h.save_path, no );
if (script_h.savedir)
sprintf( file_name, "%s%ssave%d.dat", script_h.savedir, no );
else
sprintf( file_name, "%ssave%d.dat", script_h.save_path, no );
printf("searchsavefile: %s\n", file_name);
struct stat buf;
struct tm *tm;
if ( stat( file_name, &buf ) != 0 ){
Expand All @@ -72,7 +76,10 @@ void ONScripterLabel::searchSaveFile( SaveFileInfo &save_file_info, int no )
save_file_info.hour = tm->tm_hour;
save_file_info.minute = tm->tm_min;
#elif defined(WIN32)
sprintf( file_name, "%ssave%d.dat", script_h.save_path, no );
if (script_h.savedir)
sprintf( file_name, "%ssave%d.dat", script_h.savedir, no );
else
sprintf( file_name, "%ssave%d.dat", script_h.save_path, no );
HANDLE handle;
FILETIME tm, ltm;
SYSTEMTIME stm;
Expand All @@ -94,7 +101,10 @@ void ONScripterLabel::searchSaveFile( SaveFileInfo &save_file_info, int no )
save_file_info.hour = stm.wHour;
save_file_info.minute = stm.wMinute;
#elif defined(MACOS9)
sprintf( file_name, "%ssave%d.dat", script_h.save_path, no );
if (script_h.savedir)
sprintf( file_name, "%ssave%d.dat", script_h.savedir, no );
else
sprintf( file_name, "%ssave%d.dat", script_h.save_path, no );
CInfoPBRec pb;
Str255 p_file_name;
FSSpec file_spec;
Expand All @@ -118,7 +128,10 @@ void ONScripterLabel::searchSaveFile( SaveFileInfo &save_file_info, int no )
save_file_info.hour = tm.hour;
save_file_info.minute = tm.minute;
#elif defined(PSP)
sprintf( file_name, "%ssave%d.dat", script_h.save_path, no );
if (script_h.savedir)
sprintf( file_name, "%ssave%d.dat", script_h.savedir, no );
else
sprintf( file_name, "%ssave%d.dat", script_h.save_path, no );
SceIoStat buf;
if ( sceIoGetstat(file_name, &buf)<0 ){
save_file_info.valid = false;
Expand Down
Loading

0 comments on commit 4f67e0d

Please sign in to comment.