~ubuntu-branches/ubuntu/trusty/rlvm/trusty

« back to all changes in this revision

Viewing changes to src/Systems/Base/MouseCursor.cpp

  • Committer: Package Import Robot
  • Author(s): Ying-Chun Liu (PaulLiu)
  • Date: 2013-11-02 02:57:13 UTC
  • mfrom: (10.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20131102025713-yzg31grxr8i7xerh
Tags: 0.13-1
* New upstream release
  - rlvm will now warn on startup when it detects Japanese save data, but
    English patched game files, and offer to reset the save data.
  - Much better support for Little Busters. Most graphical glitches during
    the Little Busters Refrain have been fixed.
  - TCC tone curve effects have been reverse-engineered and implemented
    (thanks to lurkmoar)
  - Sepia scenes (and other graphical filters) should look much better.
  - Simple shake commands implemented (fancy per-layer shaking still
    unimplemented).
  - Make animations smooth: data should be uploaded to the graphics card
    before an animation loop starts, not while the animation loop is
    running.
  - Fixes finding system fonts on Linux
  - Thanks to Elliot Glaysher <glaysher@umich.edu>
* Remove upstreamed patches:
  - debian/patches/002_675426ad62bccf1de10b0ae31dd46331ec47aacb.patch
  - debian/patches/003_5dafabf5448635c4d4526d6e35ea7ec664a27261.patch
  - debian/patches/004_boost-drop-mt.patch
  - debian/patches/005_missing-include.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
#include "Systems/Base/MouseCursor.hpp"
29
29
 
 
30
#include "Systems/Base/EventSystem.hpp"
 
31
#include "Systems/Base/GraphicsSystem.hpp"
30
32
#include "Systems/Base/Surface.hpp"
 
33
#include "Systems/Base/System.hpp"
31
34
 
32
35
const int CURSOR_SIZE_INT = 32;
33
36
const Size CURSOR_SIZE = Size(CURSOR_SIZE_INT, CURSOR_SIZE_INT);
34
 
const Rect CURSOR_RECT = Rect(8, 8, CURSOR_SIZE);
35
37
 
36
38
const int HOTSPOTMASK_X_OFFSET = 8;
37
39
const int HOTSPOTMASK_Y_OFFSET = 48;
41
43
// -----------------------------------------------------------------------
42
44
// MouseCursor (public)
43
45
// -----------------------------------------------------------------------
44
 
MouseCursor::MouseCursor(const boost::shared_ptr<Surface>& cursor_surface)
45
 
  : cursor_surface_(cursor_surface) {
 
46
MouseCursor::MouseCursor(
 
47
    System& system,
 
48
    const boost::shared_ptr<const Surface>& cursor_surface,
 
49
    int count,
 
50
    int speed)
 
51
    : system_(system),
 
52
      cursor_surface_(cursor_surface),
 
53
      count_(count),
 
54
      frame_speed_(speed / count_),
 
55
      current_frame_(0),
 
56
      last_time_frame_incremented_(system.event().getTicks()) {
 
57
  // TODO(erg): Technically, each frame might have a hotspot. In practice, the
 
58
  // hotspot is in the same place every frame.
46
59
  findHotspot();
47
60
 
48
61
  int alphaR, alphaG, alphaB;
49
62
  cursor_surface->getDCPixel(Point(0, 0), alphaR, alphaG, alphaB);
50
63
 
51
 
  cursor_surface_ =
52
 
    cursor_surface->clipAsColorMask(CURSOR_RECT, alphaR, alphaG, alphaB);
 
64
  cursor_surface_ = cursor_surface->clipAsColorMask(
 
65
      Rect(8, 8, Size(CURSOR_SIZE_INT * count_, CURSOR_SIZE_INT)),
 
66
      alphaR, alphaG, alphaB);
53
67
}
54
68
 
55
69
MouseCursor::~MouseCursor() {}
56
70
 
 
71
void MouseCursor::execute(System& system) {
 
72
  unsigned int cur_time = system.event().getTicks();
 
73
 
 
74
  if (last_time_frame_incremented_ + frame_speed_ < cur_time) {
 
75
    last_time_frame_incremented_ = cur_time;
 
76
 
 
77
    system.graphics().markScreenAsDirty(GUT_MOUSE_MOTION);
 
78
 
 
79
    current_frame_++;
 
80
    if (current_frame_ >= count_)
 
81
      current_frame_ = 0;
 
82
  }
 
83
}
 
84
 
57
85
void MouseCursor::renderHotspotAt(const Point& mouse_location) {
58
86
  Point render_point = getTopLeftForHotspotAt(mouse_location);
59
87
  cursor_surface_->renderToScreen(
60
 
    Rect(0, 0, CURSOR_SIZE),
 
88
    Rect(current_frame_ * CURSOR_SIZE_INT, 0, CURSOR_SIZE),
61
89
    Rect(render_point, CURSOR_SIZE));
62
90
}
63
91
 
 
92
// -----------------------------------------------------------------------
 
93
// MouseCursor (private)
 
94
// -----------------------------------------------------------------------
 
95
 
64
96
Point MouseCursor::getTopLeftForHotspotAt(const Point& mouse_location) {
65
97
  return mouse_location - hotspot_offset_;
66
98
}
67
99
 
68
 
// -----------------------------------------------------------------------
69
 
// MouseCursor (private)
70
 
// -----------------------------------------------------------------------
71
 
 
72
100
void MouseCursor::findHotspot() {
73
101
  int r, g, b;
74
102
 
81
109
      if (r == 255 && g == 255 && b == 255) {
82
110
        hotspot_offset_ =
83
111
            Size(x - HOTSPOTMASK_X_OFFSET, y - HOTSPOTMASK_Y_OFFSET);
84
 
        break;
 
112
        return;
85
113
      }
86
114
    }
87
115
  }