34
34
#include "Effects/Effect.hpp"
35
35
#include "Effects/EffectFactory.hpp"
36
#include "MachineBase/GeneralOperations.hpp"
36
37
#include "MachineBase/RLMachine.hpp"
37
38
#include "MachineBase/RLOperation.hpp"
38
39
#include "MachineBase/RLOperation/Argc_T.hpp"
41
42
#include "Modules/Module_Grp.hpp"
42
43
#include "Systems/Base/Colour.hpp"
43
44
#include "Systems/Base/GraphicsSystem.hpp"
45
#include "Systems/Base/HIKRenderer.hpp"
44
46
#include "Systems/Base/HIKScript.hpp"
45
47
#include "Systems/Base/Surface.hpp"
46
48
#include "Systems/Base/System.hpp"
64
66
void operator()(RLMachine& machine, int sel) {
65
67
GraphicsSystem& graphics = machine.system().graphics();
66
68
graphics.setDefaultBgrName("");
67
graphics.setHikScript(NULL);
69
graphics.setHikRenderer(NULL);
68
70
graphics.setGraphicsBackground(BACKGROUND_HIK);
70
72
boost::shared_ptr<Surface> before = graphics.renderToSurface();
92
94
graphics.clearStack();
94
96
fs::path path = system.findFile(filename, HIK_FILETYPES);
97
oss << "Could not find background file: " << filename;
98
throw rlvm::Exception(oss.str());
99
} else if (iends_with(path.string(), "hik")) {
97
if (iends_with(path.string(), "hik")) {
100
98
if (!machine.replaying_graphics_stack())
101
99
graphics.clearAndPromoteObjects();
103
graphics.setHikScript(new HIKScript(system, path));
101
graphics.setHikRenderer(new HIKRenderer(
103
graphics.GetHIKScript(system, filename, path)));
105
105
boost::shared_ptr<Surface> before = graphics.renderToSurface();
106
boost::shared_ptr<Surface> source(
107
graphics.loadSurfaceFromFile(machine, filename));
108
boost::shared_ptr<Surface> haikei = graphics.getHaikei();
109
source->blitToSurface(*haikei,
108
boost::shared_ptr<const Surface> source(
109
graphics.getSurfaceNamedAndMarkViewed(machine, filename));
110
boost::shared_ptr<Surface> haikei = graphics.getHaikei();
111
source->blitToSurface(*haikei,
114
117
// Promote the objects if we're in normal mode. If we're restoring the
115
118
// graphics stack, we already have our layers promoted.
179
183
filename = graphics.defaultBgrName();
181
185
// Load "filename" as the background.
182
shared_ptr<Surface> surface(
183
graphics.loadSurfaceFromFile(machine, filename));
186
shared_ptr<const Surface> surface(
187
graphics.getSurfaceNamedAndMarkViewed(machine, filename));
184
188
surface->blitToSurface(*graphics.getHaikei(),
185
189
surface->rect(), surface->rect(),
191
195
switch (it->type) {
193
197
// 0:copy(strC 'filename')
194
surface = graphics.loadSurfaceFromFile(machine, it->first);
198
surface = graphics.getSurfaceNamedAndMarkViewed(machine, it->first);
195
199
surface->blitToSurface(*graphics.getHaikei(),
196
200
surface->rect(), surface->rect(),
204
208
getSELPointAndRect(machine, it->third.get<1>(), srcRect, dest);
206
surface = graphics.loadSurfaceFromFile(machine, it->third.get<0>());
210
surface = graphics.getSurfaceNamedAndMarkViewed(machine, it->third.get<0>());
207
211
Rect destRect = Rect(dest, srcRect.size());
208
212
surface->blitToSurface(*graphics.getHaikei(), srcRect, destRect,
237
struct bgrNext : public RLOp_Void_Void {
238
void operator()(RLMachine& machine) {
239
HIKRenderer* renderer = machine.system().graphics().getHikRenderer();
241
renderer->NextAnimationFrame();
233
246
struct bgrSetXOffset : public RLOp_Void_1< IntConstant_T > {
234
247
void operator()(RLMachine& machine, int offset) {
235
HIKScript* script = machine.system().graphics().getHikScript();
237
script->set_x_offset(offset);
248
HIKRenderer* renderer = machine.system().graphics().getHikRenderer();
250
renderer->set_x_offset(offset);
242
255
struct bgrSetYOffset : public RLOp_Void_1< IntConstant_T > {
243
256
void operator()(RLMachine& machine, int offset) {
244
HIKScript* script = machine.system().graphics().getHikScript();
246
script->set_y_offset(offset);
257
HIKRenderer* renderer = machine.system().graphics().getHikRenderer();
259
renderer->set_y_offset(offset);
264
struct bgrPreloadScript : public RLOp_Void_2<IntConstant_T, StrConstant_T> {
265
void operator()(RLMachine& machine, int slot, string name) {
266
System& system = machine.system();
267
fs::path path = system.findFile(name, HIK_FILETYPES);
268
if (iends_with(path.string(), "hik")) {
269
system.graphics().PreloadHIKScript(system, slot, name, path);
262
285
addUnsupportedOpcode(100, 0, "bgrMulti");
263
286
addOpcode(100, 1, "bgrMulti", new bgrMulti_1);
288
addOpcode(1000, 0, "bgrNext", new bgrNext);
265
290
addOpcode(1104, 0, "bgrSetXOffset", new bgrSetXOffset);
266
291
addOpcode(1105, 0, "bgrSetYOffset", new bgrSetYOffset);
293
addOpcode(2000, 0, "bgrPreloadScript", new bgrPreloadScript);
294
addOpcode(2001, 0, "bgrClearPreloadedScript",
295
callFunction(&GraphicsSystem::ClearPreloadedHIKScript));
296
addOpcode(2002, 0, "bgrClearAllPreloadedScripts",
297
callFunction(&GraphicsSystem::ClearAllPreloadedHIKScripts));