Ejemplo n.º 1
0
void _ji_system_exit()
{
  SetDisplay(NULL);
  set_mouse_cursor(NULL);

  remove_int(clock_inc);
}
Ejemplo n.º 2
0
void Theme::regenerate()
{
  CursorType type = get_mouse_cursor();
  set_mouse_cursor(kNoCursor);

  onRegenerate();

  resetFontAllWidgets();

  // TODO We cannot reinitialize all widgets because this mess all
  // child spacing, border, etc. But it could be good to change the
  // uiscale() and get the new look without the need to restart the
  // whole app.
  //reinitThemeForAllWidgets();

  set_mouse_cursor(type);
}
Ejemplo n.º 3
0
void jmouse_set_cursor(CursorType type)
{
  if (mouse_cursor_type == type)
    return;

  Theme* theme = CurrentTheme::get();
  mouse_cursor_type = type;

  if (type == kNoCursor) {
    show_mouse(NULL);
    set_mouse_cursor(NULL);
  }
  else {
    show_mouse(NULL);
    set_mouse_cursor(theme->getCursor(type));
  }

  dirty_display_flag = true;
}
Ejemplo n.º 4
0
void set_inv_item_cursorpic(int invItemId, int piccy) 
{
    game.invinfo[invItemId].cursorPic = piccy;

    if ((cur_cursor == MODE_USE) && (playerchar->activeinv == invItemId)) 
    {
        update_inv_cursor(invItemId);
        set_mouse_cursor(cur_cursor);
    }
}
Ejemplo n.º 5
0
static gboolean mouse_move_callback(GtkWidget *text_view, GdkEventMotion *event)
{
	gint x, y;

	gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(text_view),
		GTK_TEXT_WINDOW_WIDGET, event->x, event->y, &x, &y);
	set_mouse_cursor(GTK_TEXT_VIEW(text_view), x, y);

	gdk_window_get_pointer(text_view->window, NULL, NULL, NULL);

	return FALSE;
}
Ejemplo n.º 6
0
static gboolean toggle_visibility_callback(GtkWidget *text_view,
	GdkEventVisibility *event)
{
	gint wx, wy, x, y;

	gdk_window_get_pointer(text_view->window, &wx, &wy, NULL);
	gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(text_view),
		GTK_TEXT_WINDOW_WIDGET, wx, wy, &x, &y);

	set_mouse_cursor(GTK_TEXT_VIEW(text_view), x, y);

	return FALSE;
}
Ejemplo n.º 7
0
void set_display(she::Display* display)
{
  CursorType cursor = get_mouse_cursor();

  set_mouse_cursor(kNoCursor);
  mouse_display = display;

  if (display) {
    Manager* manager = Manager::getDefault();
    if (manager) {
      manager->setDisplay(display);

      // Update default-manager size
      if ((manager->getBounds().w != ui::display_w() ||
           manager->getBounds().h != ui::display_h())) {
        manager->setBounds(gfx::Rect(0, 0, ui::display_w(), ui::display_h()));
      }
    }

    set_mouse_cursor(cursor);  // Restore mouse cursor
  }
}
Ejemplo n.º 8
0
bool LinkLabel::onProcessMessage(Message* msg)
{
  switch (msg->type()) {

    case kSetCursorMessage:
      // TODO theme stuff
      if (isEnabled() && hasMouseOver()) {
        set_mouse_cursor(kHandCursor);
        return true;
      }
      break;

    case kMouseEnterMessage:
    case kMouseLeaveMessage:
      if (isEnabled()) {
        if (hasCapture())
          setSelected(msg->type() == kMouseEnterMessage);

        invalidate();           // TODO theme specific
      }
      break;

    case kMouseMoveMessage:
      if (isEnabled() && hasCapture())
        setSelected(hasMouseOver());
      break;

    case kMouseDownMessage:
      if (isEnabled()) {
        captureMouse();
        setSelected(true);
      }
      break;

    case kMouseUpMessage:
      if (hasCapture()) {
        releaseMouse();

        setSelected(false);
        invalidate();           // TODO theme specific

        if (hasMouseOver())
          onClick();
      }
      break;
  }

  return CustomLabel::onProcessMessage(msg);
}
Ejemplo n.º 9
0
bool TextBox::onProcessMessage(Message* msg)
{
  switch (msg->type()) {

    case kKeyDownMessage:
      if (hasFocus()) {
        View* view = View::getView(this);
        if (view) {
          gfx::Rect vp = view->getViewportBounds();
          gfx::Point scroll = view->getViewScroll();
          int textheight = getTextHeight();

          switch (static_cast<KeyMessage*>(msg)->scancode()) {

            case kKeyLeft:
              scroll.x -= vp.w/2;
              view->setViewScroll(scroll);
              break;

            case kKeyRight:
              scroll.x += vp.w/2;
              view->setViewScroll(scroll);
              break;

            case kKeyUp:
              scroll.y -= vp.h/2;
              view->setViewScroll(scroll);
              break;

            case kKeyDown:
              scroll.y += vp.h/2;
              view->setViewScroll(scroll);
              break;

            case kKeyPageUp:
              scroll.y -= (vp.h-textheight);
              view->setViewScroll(scroll);
              break;

            case kKeyPageDown:
              scroll.y += (vp.h-textheight);
              view->setViewScroll(scroll);
              break;

            case kKeyHome:
              scroll.y = 0;
              view->setViewScroll(scroll);
              break;

            case kKeyEnd:
              scroll.y = getBounds().h - vp.h;
              view->setViewScroll(scroll);
              break;

            default:
              return Widget::onProcessMessage(msg);
          }
        }
        return true;
      }
      break;

    case kMouseDownMessage: {
      View* view = View::getView(this);
      if (view) {
        captureMouse();
        m_oldPos = static_cast<MouseMessage*>(msg)->position();
        set_mouse_cursor(kScrollCursor);
        return true;
      }
      break;
    }

    case kMouseMoveMessage: {
      View* view = View::getView(this);
      if (view && hasCapture()) {
        gfx::Point scroll = view->getViewScroll();
        gfx::Point newPos = static_cast<MouseMessage*>(msg)->position();

        scroll += m_oldPos - newPos;
        view->setViewScroll(scroll);

        m_oldPos = newPos;
      }
      break;
    }

    case kMouseUpMessage: {
      View* view = View::getView(this);
      if (view && hasCapture()) {
        releaseMouse();
        set_mouse_cursor(kArrowCursor);
        return true;
      }
      break;
    }

    case kMouseWheelMessage: {
      View* view = View::getView(this);
      if (view) {
        gfx::Point scroll = view->getViewScroll();

        scroll += static_cast<MouseMessage*>(msg)->wheelDelta() * getTextHeight()*3;

        view->setViewScroll(scroll);
      }
      break;
    }
  }

  return Widget::onProcessMessage(msg);
}
Ejemplo n.º 10
0
// 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();
}
Ejemplo n.º 11
0
void DisableInterface() {
  play.disabled_user_interface++;
  guis_need_update = 1;
  set_mouse_cursor(CURS_WAIT);
  }