qtgui: parent the agent injector/brain viewer correctly, and fix some onSelect functi...
[openc2e.git] / Camera.h
blob90eba6880557d39e8edce9cdec161dd03d7fa005
1 /*
2 * Camera.h
3 * openc2e
5 * Created by Alyssa Milburn on Tue May 25 2004.
6 * Copyright (c) 2004 Alyssa Milburn. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
20 #ifndef _OPENC2E_CAMERA_H
21 #define _OPENC2E_CAMERA_H
23 #include <vector>
24 #include "AgentRef.h"
26 enum cameratransition { none = 0, fliphorz = 1, burst = 2 };
27 enum trackstyle { brittle = 0, flexible = 1, hard = 2 };
28 enum panstyle { jump = 0, smoothscroll = 1, smoothscrollifvisible = 2 };
30 class Camera {
31 protected:
32 int x, y;
33 unsigned int metaroom;
35 bool panning;
36 unsigned int destx, desty;
37 float velx, vely;
39 AgentRef trackedagent;
40 trackstyle trackingstyle;
42 public:
43 Camera();
44 virtual unsigned int const getWidth() = 0;
45 virtual unsigned int const getHeight() = 0;
47 unsigned int const getX() { return x; }
48 unsigned int const getY() { return y; }
49 unsigned int const getXCentre() { return x + (getWidth() / 2); }
50 unsigned int const getYCentre() { return y + (getHeight() / 2); }
52 class MetaRoom * const getMetaRoom();
53 void goToMetaRoom(unsigned int m);
54 void goToMetaRoom(unsigned int m, int x, int y, cameratransition transition);
55 virtual void moveTo(int _x, int _y, panstyle pan = jump);
56 void trackAgent(AgentRef a, int xp, int yp, trackstyle s, cameratransition transition);
57 AgentRef trackedAgent() { return trackedagent; }
58 void checkBounds();
60 void tick();
61 void updateTracking();
63 virtual ~Camera() {}
66 class PartCamera : public Camera {
67 protected:
68 class CameraPart *part;
70 public:
71 PartCamera(class CameraPart *p) { part = p; }
72 unsigned int const getWidth();
73 unsigned int const getHeight();
75 void setZoom(int pixels, int _x, int _y);
78 class Backend;
80 class MainCamera : public Camera {
81 protected:
82 boost::shared_ptr<Backend> backend;
83 std::vector<AgentRef> floated;
85 public:
86 MainCamera() { }
87 void setBackend(boost::shared_ptr<Backend> b) { backend = b; }
88 unsigned int const getWidth();
89 unsigned int const getHeight();
90 void moveTo(int _x, int _y, panstyle pan = jump);
92 void addFloated(AgentRef);
93 void delFloated(AgentRef);
96 #endif
98 /* vim: set noet: */