Skip to content

Commit

Permalink
Starting post-release fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
chronotrig committed Apr 2, 2018
1 parent 9aaae15 commit 7bb16e3
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 15 deletions.
5 changes: 5 additions & 0 deletions src/PonscripterLabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ sfunc_lut_t::sfunc_lut_t() {
dict["getinsert"] = &PonscripterLabel::getinsertCommand;
dict["getlog"] = &PonscripterLabel::getlogCommand;
dict["getmousepos"] = &PonscripterLabel::getmouseposCommand;
dict["getmouseover"] = &PonscripterLabel::getmouseoverCommand;
dict["getmp3vol"] = &PonscripterLabel::getmp3volCommand;
dict["getpage"] = &PonscripterLabel::getpageCommand;
dict["getpageup"] = &PonscripterLabel::getpageupCommand;
Expand Down Expand Up @@ -243,6 +244,7 @@ sfunc_lut_t::sfunc_lut_t() {
dict["mp3save"] = &PonscripterLabel::mp3Command;
dict["mp3stop"] = &PonscripterLabel::playstopCommand;
dict["mp3vol"] = &PonscripterLabel::mp3volCommand;
dict["movie"] = &PonscripterLabel::movieCommand;
dict["mpegplay"] = &PonscripterLabel::mpegplayCommand;
dict["msp"] = &PonscripterLabel::mspCommand;
dict["msp2"] = &PonscripterLabel::mspCommand;
Expand Down Expand Up @@ -320,6 +322,7 @@ sfunc_lut_t::sfunc_lut_t() {
dict["texton"] = &PonscripterLabel::textonCommand;
dict["textshow"] = &PonscripterLabel::textshowCommand;
dict["textspeed"] = &PonscripterLabel::textspeedCommand;
dict["textspeeddefault"] = &PonscripterLabel::textspeeddefaultCommand;
dict["transbtn"] = &PonscripterLabel::transbtnCommand;
dict["trap"] = &PonscripterLabel::trapCommand;
dict["voicevol"] = &PonscripterLabel::voicevolCommand;
Expand Down Expand Up @@ -2266,6 +2269,8 @@ void PonscripterLabel::disableGetButtonFlag()
getenter_flag = false;
getcursor_flag = false;
spclclk_flag = false;
getmouseover_flag = false;
getmouseover_min = getmouseover_max = 0;
}


Expand Down
7 changes: 6 additions & 1 deletion src/PonscripterLabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class PonscripterLabel : public ScriptParser {
int trapCommand(const pstring& cmd);
int transbtnCommand(const pstring& cmd);
int textspeedCommand(const pstring& cmd);
int textspeeddefaultCommand(const pstring& cmd);
int textshowCommand(const pstring& cmd);
int textonCommand(const pstring& cmd);
int textoffCommand(const pstring& cmd);
Expand Down Expand Up @@ -228,6 +229,7 @@ class PonscripterLabel : public ScriptParser {
int ofscopyCommand(const pstring& cmd);
int negaCommand(const pstring& cmd);
int mspCommand(const pstring& cmd);
int movieCommand(const pstring& cmd);
int mpegplayCommand(const pstring& cmd);
int mp3volCommand(const pstring& cmd);
int mp3fadeoutCommand(const pstring& cmd);
Expand Down Expand Up @@ -273,6 +275,7 @@ class PonscripterLabel : public ScriptParser {
int getpageCommand(const pstring& cmd);
int getmp3volCommand(const pstring& cmd);
int getmouseposCommand(const pstring& cmd);
int getmouseoverCommand(const pstring& cmd);
int getlogCommand(const pstring& cmd);
int getinsertCommand(const pstring& cmd);
int getfunctionCommand(const pstring& cmd);
Expand Down Expand Up @@ -578,6 +581,8 @@ class PonscripterLabel : public ScriptParser {
bool getenter_flag;
bool getcursor_flag;
bool spclclk_flag;
bool getmouseover_flag;
int getmouseover_min, getmouseover_max;

void resetSentenceFont();
void refreshMouseOverButton();
Expand Down Expand Up @@ -829,7 +834,7 @@ class PonscripterLabel : public ScriptParser {
int setVolumeMute(bool do_mute);

SubtitleDefs parseSubtitles(pstring file);
int playMPEG(const pstring& filename, bool click_flag,SubtitleDefs& subtitles);
int playMPEG(const pstring& filename, bool click_flag, bool loop_flag, SubtitleDefs& subtitles);
void playAVI(const pstring& filename, bool click_flag);

enum { WAVE_PLAY = 0,
Expand Down
9 changes: 7 additions & 2 deletions src/PonscripterLabel_animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ void PonscripterLabel::parseTaggedString(AnimationInfo* anim, bool is_mask)

anim->removeTag();

int res_multiplier = 1;
#ifdef USE_2X_MODE
res_multiplier = 2;
#endif

int i;
const char* buffer = anim->image_name;
anim->num_of_cells = 1;
Expand Down Expand Up @@ -316,9 +321,9 @@ void PonscripterLabel::parseTaggedString(AnimationInfo* anim, bool is_mask)
script_h.getNext();

script_h.pushCurrent((char*) buffer); // FIXME: unsafe
anim->font_size_x = script_h.readIntValue();
anim->font_size_x = script_h.readIntValue() * res_multiplier;
anim->font_size_y = script_h.hasMoreArgs()
? script_h.readIntValue()
? script_h.readIntValue() * res_multiplier
: anim->font_size_x;
anim->font_pitch = script_h.hasMoreArgs()
? script_h.readIntValue()
Expand Down
58 changes: 53 additions & 5 deletions src/PonscripterLabel_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ int PonscripterLabel::transbtnCommand(const pstring& cmd)
return RET_CONTINUE;
}

int PonscripterLabel::textspeeddefaultCommand(const pstring& cmd)
{
sentence_font.wait_time = -1;
return RET_CONTINUE;
}

int PonscripterLabel::textspeedCommand(const pstring& cmd)
{
sentence_font.wait_time = script_h.readIntValue();
Expand Down Expand Up @@ -1537,8 +1543,31 @@ int PonscripterLabel::mpegplayCommand(const pstring& cmd)
subtitles = parseSubtitles(script_h.readStrValue());
}
stopBGM(false);
if (playMPEG(name, cancel, subtitles))
if (playMPEG(name, cancel, false, subtitles))
endCommand("end");
return RET_CONTINUE;
}


int PonscripterLabel::movieCommand(const pstring& cmd)
{
pstring name = script_h.readStrValue();
bool cancel = false, loop = false;
SubtitleDefs subtitles;

while (script_h.hasMoreArgs()) {
Expression e = script_h.readStrExpr();
if (e.is_bareword("click")) {
cancel = true;
} else if (e.is_bareword("loop")) {
loop = true;
}
}

stopBGM(false);
if (playMPEG(name, cancel, loop, subtitles))
endCommand("end");

return RET_CONTINUE;
}

Expand Down Expand Up @@ -2248,10 +2277,19 @@ int PonscripterLabel::getspsizeCommand(const pstring& cmd)
{
int no = script_h.readIntValue();

script_h.readIntExpr().mutate(sprite_info[no].pos.w *
screen_ratio2 / screen_ratio1);
script_h.readIntExpr().mutate(sprite_info[no].pos.h *
screen_ratio2 / screen_ratio1);
int res_multiplier = 1;
#ifdef USE_2X_MODE
res_multiplier = 2;
#endif

script_h.readIntExpr().mutate(
(sprite_info[no].pos.w * screen_ratio2 / screen_ratio1) /
res_multiplier
);
script_h.readIntExpr().mutate(
(sprite_info[no].pos.h * screen_ratio2 / screen_ratio1) /
res_multiplier
);
if (script_h.hasMoreArgs())
script_h.readIntExpr().mutate(sprite_info[no].num_of_cells);

Expand Down Expand Up @@ -2394,6 +2432,16 @@ int PonscripterLabel::getmouseposCommand(const pstring& cmd)
}


int PonscripterLabel::getmouseoverCommand(const pstring& cmd)
{
getmouseover_flag = true;
getmouseover_min = script_h.readIntValue();
getmouseover_max = script_h.readIntValue();

return RET_CONTINUE;
}


int PonscripterLabel::getlogCommand(const pstring& cmd)
{
Expression e = script_h.readStrExpr();
Expand Down
27 changes: 26 additions & 1 deletion src/PonscripterLabel_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,33 @@ void PonscripterLabel::mouseMoveEvent(SDL_MouseMotionEvent* event)
current_button_state.x = event->x;
current_button_state.y = event->y;

if (event_mode & WAIT_BUTTON_MODE)
if (event_mode & WAIT_BUTTON_MODE) {
mouseOverCheck(current_button_state.x, current_button_state.y);
if (getmouseover_flag &&
(current_over_button >= getmouseover_min) &&
(current_over_button <= getmouseover_max)){
// Ons used .set here, check for validity
//current_button_state.set(current_over_button);
//volatile_button_state.set(current_over_button);
current_button_state.button = current_over_button;
volatile_button_state.button = current_over_button;
playClickVoice();
stopAnimation(clickstr_state);
advancePhase();
// Onscripter returns boolean??
//return true;
/*
} else if (btnarea_flag &&
( ((btnarea_pos < 0) && (event->y > -btnarea_pos)) ||
((btnarea_pos > 0) && (event->y < btnarea_pos)) )){
current_button_state.set(-4);
volatile_button_state.set(-4);
playClickVoice();
stopCursorAnimation( clickstr_state );
return true;
*/
}
}
}


Expand Down
21 changes: 15 additions & 6 deletions src/PonscripterLabel_sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ void UpdateMPEG(void *data, SMPEG_Frame *frame) {
c->dirty = 1;
}

int PonscripterLabel::playMPEG(const pstring& filename, bool click_flag,
int PonscripterLabel::playMPEG(const pstring& filename, bool click_flag, bool loop_flag,
SubtitleDefs& subtitles)
{
int ret = 0;
Expand Down Expand Up @@ -573,23 +573,32 @@ int PonscripterLabel::playMPEG(const pstring& filename, bool click_flag,

Mix_HookMusic(mp3callback, mpeg_sample);


if (loop_flag) {
SMPEG_loop(mpeg_sample, -1);
}
SMPEG_play(mpeg_sample);

bool done_flag = false;
bool interrupted_redraw = false;
bool done_click_down = false;

while (!(done_flag & click_flag) &&
SMPEG_status(mpeg_sample) == SMPEG_PLAYING)
while (!done_flag)
{
if (SMPEG_status(mpeg_sample) != SMPEG_PLAYING) {
if (loop_flag) {
SMPEG_play( mpeg_sample );
} else {
break;
}
}

SDL_Event event, tmp_event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_KEYUP: {
int s = ((SDL_KeyboardEvent*) &event)->keysym.sym;
if (s == SDLK_RETURN || s == SDLK_SPACE || s == SDLK_ESCAPE)
done_flag = true;
done_flag = click_flag;
if (s == SDLK_m) {
volume_on_flag = !volume_on_flag;
SMPEG_setvolume(mpeg_sample, !volume_on_flag? 0 : music_volume);
Expand All @@ -613,7 +622,7 @@ int PonscripterLabel::playMPEG(const pstring& filename, bool click_flag,
break;
case SDL_MOUSEBUTTONUP:
if(done_click_down)
done_flag = true;
done_flag = click_flag;
break;
case INTERNAL_REDRAW_EVENT:
interrupted_redraw = true;
Expand Down

0 comments on commit 7bb16e3

Please sign in to comment.