void wordcloud_mouse(mmask_t buttons, int x, int y) { if (get_cursor_mode() != CM_WC) set_cursor_mode(CM_WC); else if (buttons & BUTTON1_CLICKED) { if (wc_offset + y < wc_list_n) { int ar_index = wc_offset + y; char *temp = strdup(wc_list[ar_index]); search_in_wc(temp); free(temp); } else { wrong_key(); } } else { wrong_key(); } }
void start_game() { set_cursor_mode(MODE_WALK); filter->SetMousePosition(160,100); newmusic(0); our_eip = -42; for (int kk = 0; kk < numScriptModules; kk++) moduleInst[kk]->RunTextScript("game_start"); gameinst->RunTextScript("game_start"); our_eip = -43; SetRestartPoint(); our_eip=-3; if (displayed_room < 0) { current_fade_out_effect(); load_new_room(playerchar->room,playerchar); // load_new_room updates it, but it should be -1 in the first room playerchar->prevroom = -1; } first_room_initialization(); }
int wgetnstr( WINDOW *w, char *str, int max_len) { int c = 0; int len = 0, insert_mode = 0; set_cursor_mode( 14, 16); while( len < max_len && c != 13) { int x = w->curr_x, y = w->curr_y; set_cursor_loc( y + w->yoffset, x + w->xoffset); c = getch( ); if( !c) c = getch( ) + 256; if( c == ( 82 + 256)) /* Insert key */ { insert_mode ^= 1; set_cursor_mode( 14 - insert_mode * 8, 16); } else if( c != 13) { if( c != 8) { str[len++] = (char)c; waddch( w, (char)c); } else if( len > 0) { len--; str[len] = '\0'; x--; mvwaddch( w, y, x, ' '); wmove( w, y, x); } if( echo_on) wrefresh_rect( w, x, y, x + 1, y + 1); } } str[len] = '\0'; if( insert_mode) set_cursor_mode( 14, 16); return( 0); }
void initialize_start_and_play_game(int override_start_room, const char *loadSaveGameOnStartup) { try { // BEGIN try for ALI3DEXception set_cursor_mode (MODE_WALK); if (convert_16bit_bgr) { // Disable text as speech while displaying the warning message // This happens if the user's graphics card does BGR order 16-bit colour int oldalways = game.options[OPT_ALWAYSSPCH]; game.options[OPT_ALWAYSSPCH] = 0; // PSP: This is normal. Don't show a warning. //Display ("WARNING: AGS has detected that you have an incompatible graphics card for this game. You may experience colour problems during the game. Try running the game with \"--15bit\" command line parameter and see if that helps.[[Click the mouse to continue."); game.options[OPT_ALWAYSSPCH] = oldalways; } srand (play.randseed); play.gamestep = 0; if (override_start_room) playerchar->room = override_start_room; start_game_check_replay(); write_log_debug("Engine initialization complete"); write_log_debug("Starting game"); start_game_init_editor_debugging(); start_game_load_savegame_on_startup(); do_start_game(); do_play_game(); } catch (Ali3DException gfxException) { quit((char*)gfxException._message); } }
// Final processing after successfully restoring from save HSaveError DoAfterRestore(const PreservedParams &pp, const RestoredData &r_data) { // Preserve whether the music vox is available play.separate_music_lib = pp.MusicVOX; // If they had the vox when they saved it, but they don't now if ((pp.SpeechVOX < 0) && (play.want_speech >= 0)) play.want_speech = (-play.want_speech) - 1; // If they didn't have the vox before, but now they do else if ((pp.SpeechVOX >= 0) && (play.want_speech < 0)) play.want_speech = (-play.want_speech) - 1; // recache queued clips for (int i = 0; i < play.new_music_queue_size; ++i) { play.new_music_queue[i].cachedClip = NULL; } // restore these to the ones retrieved from the save game const size_t dynsurf_num = Math::Min((size_t)MAX_DYNAMIC_SURFACES, r_data.DynamicSurfaces.size()); for (size_t i = 0; i < dynsurf_num; ++i) { dynamicallyCreatedSurfaces[i] = r_data.DynamicSurfaces[i]; } for (int i = 0; i < game.numgui; ++i) export_gui_controls(i); update_gui_zorder(); if (create_global_script()) { return new SavegameError(kSvgErr_GameObjectInitFailed, String::FromFormat("Unable to recreate global script: %s", ccErrorString.GetCStr())); } // read the global data into the newly created script if (r_data.GlobalScript.Data.get()) memcpy(gameinst->globaldata, r_data.GlobalScript.Data.get(), Math::Min((size_t)gameinst->globaldatasize, r_data.GlobalScript.Len)); // restore the script module data for (int i = 0; i < numScriptModules; ++i) { if (r_data.ScriptModules[i].Data.get()) memcpy(moduleInst[i]->globaldata, r_data.ScriptModules[i].Data.get(), Math::Min((size_t)moduleInst[i]->globaldatasize, r_data.ScriptModules[i].Len)); } setup_player_character(game.playercharacter); // Save some parameters to restore them after room load int gstimer=play.gscript_timer; int oldx1 = play.mboundx1, oldx2 = play.mboundx2; int oldy1 = play.mboundy1, oldy2 = play.mboundy2; // disable the queue momentarily int queuedMusicSize = play.music_queue_size; play.music_queue_size = 0; update_polled_stuff_if_runtime(); // load the room the game was saved in if (displayed_room >= 0) load_new_room(displayed_room, NULL); update_polled_stuff_if_runtime(); play.gscript_timer=gstimer; // restore the correct room volume (they might have modified // it with SetMusicVolume) thisroom.Options.MusicVolume = r_data.RoomVolume; Mouse::SetMoveLimit(Rect(oldx1, oldy1, oldx2, oldy2)); set_cursor_mode(r_data.CursorMode); set_mouse_cursor(r_data.CursorID); if (r_data.CursorMode == MODE_USE) SetActiveInventory(playerchar->activeinv); // ensure that the current cursor is locked spriteset.Precache(game.mcurs[r_data.CursorID].pic); #if (ALLEGRO_DATE > 19990103) set_window_title(play.game_name); #endif update_polled_stuff_if_runtime(); if (displayed_room >= 0) { for (int i = 0; i < MAX_ROOM_BGFRAMES; ++i) { if (r_data.RoomBkgScene[i]) { thisroom.BgFrames[i].Graphic = r_data.RoomBkgScene[i]; } } in_new_room=3; // don't run "enters screen" events // now that room has loaded, copy saved light levels in for (size_t i = 0; i < MAX_ROOM_REGIONS; ++i) { thisroom.Regions[i].Light = r_data.RoomLightLevels[i]; thisroom.Regions[i].Tint = r_data.RoomTintLevels[i]; } generate_light_table(); for (size_t i = 0; i < MAX_WALK_AREAS + 1; ++i) { thisroom.WalkAreas[i].ScalingFar = r_data.RoomZoomLevels1[i]; thisroom.WalkAreas[i].ScalingNear = r_data.RoomZoomLevels2[i]; } on_background_frame_change(); } gui_disabled_style = convert_gui_disabled_style(game.options[OPT_DISABLEOFF]); // restore the queue now that the music is playing play.music_queue_size = queuedMusicSize; if (play.digital_master_volume >= 0) System_SetVolume(play.digital_master_volume); // Run audio clips on channels // these two crossfading parameters have to be temporarily reset const int cf_in_chan = play.crossfading_in_channel; const int cf_out_chan = play.crossfading_out_channel; play.crossfading_in_channel = 0; play.crossfading_out_channel = 0; // NOTE: channels are array of MAX_SOUND_CHANNELS+1 size for (int i = 0; i <= MAX_SOUND_CHANNELS; ++i) { const RestoredData::ChannelInfo &chan_info = r_data.AudioChans[i]; if (chan_info.ClipID < 0) continue; if (chan_info.ClipID >= game.audioClipCount) { return new SavegameError(kSvgErr_GameObjectInitFailed, String::FromFormat("Invalid audio clip index: %d (clip count: %d).", chan_info.ClipID, game.audioClipCount)); } play_audio_clip_on_channel(i, &game.audioClips[chan_info.ClipID], chan_info.Priority, chan_info.Repeat, chan_info.Pos); if (channels[i] != NULL) { channels[i]->set_volume_direct(chan_info.VolAsPercent, chan_info.Vol); channels[i]->set_speed(chan_info.Speed); channels[i]->set_panning(chan_info.Pan); channels[i]->panningAsPercentage = chan_info.PanAsPercent; } } if ((cf_in_chan > 0) && (channels[cf_in_chan] != NULL)) play.crossfading_in_channel = cf_in_chan; if ((cf_out_chan > 0) && (channels[cf_out_chan] != NULL)) play.crossfading_out_channel = cf_out_chan; // If there were synced audio tracks, the time taken to load in the // different channels will have thrown them out of sync, so re-time it // NOTE: channels are array of MAX_SOUND_CHANNELS+1 size for (int i = 0; i <= MAX_SOUND_CHANNELS; ++i) { int pos = r_data.AudioChans[i].Pos; if ((pos > 0) && (channels[i] != NULL) && (channels[i]->done == 0)) { channels[i]->seek(pos); } } // TODO: investigate loop range for (int i = 1; i < MAX_SOUND_CHANNELS; ++i) { if (r_data.DoAmbient[i]) PlayAmbientSound(i, r_data.DoAmbient[i], ambient[i].vol, ambient[i].x, ambient[i].y); } for (int i = 0; i < game.numgui; ++i) { guibg[i] = BitmapHelper::CreateBitmap(guis[i].Width, guis[i].Height, game.GetColorDepth()); guibg[i] = ReplaceBitmapWithSupportedFormat(guibg[i]); } recreate_overlay_ddbs(); guis_need_update = 1; play.ignore_user_input_until_time = 0; update_polled_stuff_if_runtime(); pl_run_plugin_hooks(AGSE_POSTRESTOREGAME, 0); if (displayed_room < 0) { // the restart point, no room was loaded load_new_room(playerchar->room, playerchar); playerchar->prevroom = -1; first_room_initialization(); } if ((play.music_queue_size > 0) && (cachedQueuedMusic == NULL)) { cachedQueuedMusic = load_music_from_disk(play.music_queue[0], 0); } // test if the playing music was properly loaded if (current_music_type > 0) { if (crossFading > 0 && !channels[crossFading] || crossFading <= 0 && !channels[SCHAN_MUSIC]) { current_music_type = 0; } } set_game_speed(r_data.FPS); return HSaveError::None(); }
void help_system(struct world *mzx_world) { char file[13], file2[13], label[13]; int where, offs, size, t1, t2; enum cursor_mode_types old_cmode; FILE *fp; fp = mzx_world->help_file; if(!fp) return; old_cmode = get_cursor_mode(); rewind(fp); t1 = fgetw(fp); fseek(fp, t1 * 21 + 4 + get_context() * 12, SEEK_SET); // At proper context info where = fgetd(fp); // Where file to load is size = fgetd(fp); // Size of file to load offs = fgetd(fp); // Offset within file of link // Jump to file fseek(fp, where, SEEK_SET); // Read it in fread(help, 1, size, fp); // Display it cursor_off(); labelled: help_display(mzx_world, help, offs, file, label); // File? if(file[0]) { // Yep. Search for file. fseek(fp, 2, SEEK_SET); for(t2 = 0; t2 < t1; t2++) { fread(file2, 1, 13, fp); if(!strcmp(file, file2)) break; fseek(fp, 8, SEEK_CUR); } if(t2 < t1) { // Found file. where = fgetd(fp); size = fgetd(fp); fseek(fp, where, SEEK_SET); fread(help, 1, size, fp); // Search for label for(t2 = 0; t2 < size; t2++) { if(help[t2] != 255) continue; if(help[t2 + 1] != ':') continue; if(!strcmp(help + t2 + 3, label)) break; // Found label! } if(t2 < size) { // Found label. t2 is offset. offs = t2; goto labelled; } } } set_cursor_mode(old_cmode); }