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

« back to all changes in this revision

Viewing changes to src/Systems/Base/GanGraphicsObjectData.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:
88
88
GanGraphicsObjectData::~GanGraphicsObjectData() {}
89
89
 
90
90
void GanGraphicsObjectData::load() {
91
 
  image = system_.graphics().loadNonCGSurfaceFromFile(img_filename_);
 
91
  image_ = system_.graphics().getSurfaceNamed(img_filename_);
 
92
  image_->EnsureUploaded();
92
93
 
93
94
  fs::path gan_file_path = system_.findFile(gan_filename_, GAN_FILETYPES);
94
95
  if (gan_file_path.empty()) {
219
220
  if (current_set_ != -1 && current_frame_ != -1) {
220
221
    const Frame& frame = animation_sets.at(current_set_).at(current_frame_);
221
222
    if (frame.pattern != -1) {
222
 
      const Surface::GrpRect& rect = image->getPattern(frame.pattern);
223
 
      return rect.rect.width();
 
223
      const Surface::GrpRect& rect = image_->getPattern(frame.pattern);
 
224
      return int(rendering_properties.getWidthScaleFactor() *
 
225
                 rect.rect.width());
224
226
    }
225
227
  }
226
228
 
232
234
  if (current_set_ != -1 && current_frame_ != -1) {
233
235
    const Frame& frame = animation_sets.at(current_set_).at(current_frame_);
234
236
    if (frame.pattern != -1) {
235
 
      const Surface::GrpRect& rect = image->getPattern(frame.pattern);
236
 
      return rect.rect.height();
 
237
      const Surface::GrpRect& rect = image_->getPattern(frame.pattern);
 
238
      return int(rendering_properties.getHeightScaleFactor() *
 
239
                 rect.rect.height());
237
240
    }
238
241
  }
239
242
 
244
247
  return new GanGraphicsObjectData(*this);
245
248
}
246
249
 
247
 
void GanGraphicsObjectData::execute() {
 
250
void GanGraphicsObjectData::execute(RLMachine& machine) {
248
251
  if (currentlyPlaying() && current_frame_ >= 0) {
249
252
    unsigned int current_time = system_.event().getTicks();
250
253
    unsigned int time_since_last_frame_change =
271
274
  current_frame_ = 0;
272
275
}
273
276
 
274
 
boost::shared_ptr<Surface> GanGraphicsObjectData::currentSurface(
 
277
boost::shared_ptr<const Surface> GanGraphicsObjectData::currentSurface(
275
278
  const GraphicsObject& go) {
276
279
  if (current_set_ != -1 && current_frame_ != -1) {
277
280
    const Frame& frame = animation_sets.at(current_set_).at(current_frame_);
279
282
    if (frame.pattern != -1) {
280
283
      // We are currently rendering an animation AND the current frame says to
281
284
      // render something to the screen.
282
 
      return image;
 
285
      return image_;
283
286
    }
284
287
  }
285
288
 
286
 
  return boost::shared_ptr<Surface>();
 
289
  return boost::shared_ptr<const Surface>();
287
290
}
288
291
 
289
292
Rect GanGraphicsObjectData::srcRect(const GraphicsObject& go) {
290
293
  const Frame& frame = animation_sets.at(current_set_).at(current_frame_);
291
294
  if (frame.pattern != -1) {
292
 
    return image->getPattern(frame.pattern).rect;
 
295
    return image_->getPattern(frame.pattern).rect;
293
296
  }
294
297
 
295
298
  return Rect();
300
303
  return GraphicsObjectData::dstOrigin(go) - Size(frame.x, frame.y);
301
304
}
302
305
 
303
 
int GanGraphicsObjectData::getRenderingAlpha(const GraphicsObject& go) {
 
306
int GanGraphicsObjectData::getRenderingAlpha(const GraphicsObject& go,
 
307
                                             const GraphicsObject* parent) {
304
308
  const Frame& frame = animation_sets.at(current_set_).at(current_frame_);
305
309
  if (frame.pattern != -1) {
306
310
    // Calculate the combination of our frame alpha with the current object
307
311
    // alpha.
308
 
    return int(((frame.alpha/256.0f) * (go.alpha() / 256.0f)) * 256);
 
312
    float parent_alpha = parent ? (parent->computedAlpha() / 255.0f) : 1;
 
313
    return int(((frame.alpha/255.0f) * (go.computedAlpha() / 255.0f) *
 
314
                parent_alpha) * 255);
309
315
  } else {
310
316
    // Should never happen.
311
 
    return go.alpha();
 
317
    return go.computedAlpha();
312
318
  }
313
319
}
314
320
 
332
338
    & current_frame_ & time_at_last_frame_change_;
333
339
 
334
340
  load();
 
341
 
 
342
  // Saving |time_at_last_frame_change_| as part of the format is obviously a
 
343
  // mistake, but is now baked into the file format. Ask the clock for a more
 
344
  // suitable value.
 
345
  if (time_at_last_frame_change_ != 0) {
 
346
    time_at_last_frame_change_ = system_.event().getTicks();
 
347
    system_.graphics().markScreenAsDirty(GUT_DISPLAY_OBJ);
 
348
  }
335
349
}
336
350
 
337
351
template<class Archive>