~ubuntu-branches/ubuntu/vivid/rlvm/vivid-proposed

« back to all changes in this revision

Viewing changes to src/Systems/Base/HIKScript.hpp

  • Committer: Package Import Robot
  • Author(s): Ying-Chun Liu (PaulLiu)
  • Date: 2014-10-22 03:24:19 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20141022032419-yqxls9ky4n1w811n
Tags: 0.14-1
* New upstream release
* Bump Standards-Version to 3.9.6: nothing needs to be changed

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
// -*- Mode: C++; tab-width:2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3
 
// vi:tw=80:et:ts=2:sts=2
4
 
//
5
 
// -----------------------------------------------------------------------
6
 
//
7
 
// This file is part of RLVM, a RealLive virtual machine clone.
8
 
//
9
 
// -----------------------------------------------------------------------
10
 
//
11
 
// Copyright (C) 2009 Elliot Glaysher
12
 
//
13
 
// This program is free software; you can redistribute it and/or modify
14
 
// it under the terms of the GNU General Public License as published by
15
 
// the Free Software Foundation; either version 3 of the License, or
16
 
// (at your option) any later version.
17
 
//
18
 
// This program is distributed in the hope that it will be useful,
19
 
// but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 
// GNU General Public License for more details.
22
 
//
23
 
// You should have received a copy of the GNU General Public License
24
 
// along with this program; if not, write to the Free Software
25
 
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
26
 
// -----------------------------------------------------------------------
27
 
 
28
 
#ifndef SRC_SYSTEMS_BASE_HIKSCRIPT_HPP_
29
 
#define SRC_SYSTEMS_BASE_HIKSCRIPT_HPP_
30
 
 
31
 
#include <string>
32
 
#include <vector>
33
 
 
34
 
#include <boost/filesystem.hpp>
35
 
#include <boost/shared_ptr.hpp>
36
 
 
37
 
#include "Systems/Base/Rect.hpp"
38
 
 
39
 
class System;
40
 
class Surface;
41
 
 
42
 
// Class that parses and executes HIK files.
43
 
class HIKScript {
44
 
 public:
45
 
  HIKScript(System& system, const boost::filesystem::path& file);
46
 
  ~HIKScript();
47
 
 
48
 
  // Loads our data from a HIK file.
49
 
  void loadHikFile(System& system, const boost::filesystem::path& file);
50
 
 
51
 
  // Make sure all graphics data is ready to be presented to the user.
52
 
  void EnsureUploaded();
53
 
 
54
 
  // The contents of the 40000 keys which define an individual frame.
55
 
  struct Frame {
56
 
    int opacity;
57
 
    std::string image;
58
 
    boost::shared_ptr<const Surface> surface;
59
 
 
60
 
    int grp_pattern;
61
 
    int frame_length_ms;
62
 
  };
63
 
 
64
 
  // The contents of the 30000 keys. I used to call this structure Unkowns;
65
 
  // "Animation" is a tentative name as it contains individual Frames that are
66
 
  // played in sequence.
67
 
  struct Animation {
68
 
    int use_multiframe_animation;
69
 
 
70
 
    // The number of frames as reported by the HIK file. Used for error
71
 
    // checking.
72
 
    int number_of_frames;
73
 
 
74
 
    // All frames to display.
75
 
    std::vector<Frame> frames;
76
 
 
77
 
    // IDEA: This is the animation number in the layer to move to next when
78
 
    // all frames in this animation are played out.
79
 
    int i_30101;
80
 
    // Unknown
81
 
    int i_30102;
82
 
 
83
 
    // The sum of all |frame_length_ms| in frames.
84
 
    int total_time;
85
 
  };
86
 
 
87
 
  // The contents of the 20000 keys.
88
 
  struct Layer {
89
 
    Point top_offset;
90
 
 
91
 
    bool use_scrolling;
92
 
    Point start_point;
93
 
    Point end_point;
94
 
    int x_scroll_time_ms;
95
 
    int y_scroll_time_ms;
96
 
 
97
 
    bool use_clip_area;
98
 
    Rect clip_area;
99
 
 
100
 
    // Number of unknowns as reported by the HIK file on disk.
101
 
    int number_of_animations;
102
 
 
103
 
    std::vector<Animation> animations;
104
 
  };
105
 
 
106
 
 
107
 
  // Returns the HIK layer data.
108
 
  const std::vector<Layer>& layers() const { return layers_; }
109
 
  const Size& size() const { return size_of_hik_; }
110
 
 
111
 
 private:
112
 
  // Returns the current structure being operated on, throwing on logic
113
 
  // errors. Only to be used during parsing of the file.
114
 
  Animation& currentAnimation();
115
 
  Layer& currentLayer();
116
 
  Frame& currentFrame();
117
 
 
118
 
  // Each graphics component in the HIK script.
119
 
  std::vector<Layer> layers_;
120
 
 
121
 
  // The number of layers as reported by the HIK file. Used for error checking.
122
 
  int number_of_layers_;
123
 
 
124
 
  // Size of the hik graphic as reported by the hik.
125
 
  Size size_of_hik_;
126
 
};
127
 
 
128
 
#endif  // SRC_SYSTEMS_BASE_HIKSCRIPT_HPP_