OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
BaseView.h
1 /*
2  * Copyright 2010-2014 OpenXcom Developers.
3  *
4  * This file is part of OpenXcom.
5  *
6  * OpenXcom is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * OpenXcom is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #ifndef OPENXCOM_BASEVIEW_H
20 #define OPENXCOM_BASEVIEW_H
21 
22 #include "../Engine/InteractiveSurface.h"
23 
24 namespace OpenXcom
25 {
26 
27 class Base;
28 class SurfaceSet;
29 class BaseFacility;
30 class RuleBaseFacility;
31 class Font;
32 class Language;
33 class Timer;
34 
41 {
42 private:
43  static const int BASE_SIZE = 6;
44  static const int GRID_SIZE = 32;
45 
46  Base *_base;
47  SurfaceSet *_texture;
48  BaseFacility *_facilities[BASE_SIZE][BASE_SIZE], *_selFacility;
49  Font *_big, *_small;
50  Language *_lang;
51  int _gridX, _gridY, _selSize;
52  Surface *_selector;
53  bool _blink;
54  Timer *_timer;
56  void updateNeighborFacilityBuildTime(BaseFacility* facility, BaseFacility* neighbor);
57 public:
59  BaseView(int width, int height, int x = 0, int y = 0);
61  ~BaseView();
63  void initText(Font *big, Font *small, Language *lang);
65  void setBase(Base *base);
67  void setTexture(SurfaceSet *texture);
71  void resetSelectedFacility();
73  int getGridX() const;
75  int getGridY() const;
77  void setSelectable(int size);
79  bool isPlaceable(RuleBaseFacility *rule) const;
81  bool isQueuedBuilding(RuleBaseFacility *rule) const;
83  void reCalcQueuedBuildings();
85  void think();
87  void blink();
89  void draw();
91  void blit(Surface *surface);
93  void mouseOver(Action *action, State *state);
95  void mouseOut(Action *action, State *state);
96 };
97 
98 }
99 
100 #endif
void resetSelectedFacility()
Prevents any mouseover bugs on dismantling base facilities before setBase has had time to update the ...
Definition: BaseView.cpp:133
Container for all the information associated with a given user action, like mouse clicks...
Definition: Action.h:34
void draw()
Draws the base view.
Definition: BaseView.cpp:346
A game state that receives user input and reacts accordingly.
Definition: State.h:44
Represents a base facility placed in a base.
Definition: BaseFacility.h:38
Timer used to run code in fixed intervals.
Definition: Timer.h:37
Surface that the user can interact with.
Definition: InteractiveSurface.h:39
void mouseOut(Action *action, State *state)
Special handling for mouse hovering out.
Definition: BaseView.cpp:548
void initText(Font *big, Font *small, Language *lang)
Initializes the base view's various resources.
Definition: BaseView.cpp:74
void reCalcQueuedBuildings()
ReCalculates the remaining build-time of all queued buildings.
Definition: BaseView.cpp:255
void think()
Handles the timers.
Definition: BaseView.cpp:303
~BaseView()
Cleans up the base view.
Definition: BaseView.cpp:59
Contains strings used throughout the game for localization.
Definition: Language.h:42
Container of a set of surfaces.
Definition: SurfaceSet.h:38
void blit(Surface *surface)
Blits the base view onto another surface.
Definition: BaseView.cpp:496
int getGridX() const
Gets the X position of the currently selected square.
Definition: BaseView.cpp:145
Takes care of loading and storing each character in a sprite font.
Definition: Font.h:40
bool isPlaceable(RuleBaseFacility *rule) const
Checks if a facility can be placed.
Definition: BaseView.cpp:197
void setBase(Base *base)
Sets the base to display.
Definition: BaseView.cpp:86
bool isQueuedBuilding(RuleBaseFacility *rule) const
Checks if the placed facility is placed in queue or not.
Definition: BaseView.cpp:237
void setTexture(SurfaceSet *texture)
Sets the texture for this base view.
Definition: BaseView.cpp:116
Represents a player base on the globe.
Definition: Base.h:47
Element that is blit (rendered) onto the screen.
Definition: Surface.h:39
void mouseOver(Action *action, State *state)
Special handling for mouse hovers.
Definition: BaseView.cpp:510
BaseView(int width, int height, int x=0, int y=0)
Creates a new base view at the specified position and size.
Definition: BaseView.cpp:45
Interactive view of a base.
Definition: BaseView.h:40
int getGridY() const
Gets the Y position of the currently selected square.
Definition: BaseView.cpp:155
void setSelectable(int size)
Sets whether the base view is selectable.
Definition: BaseView.cpp:165
void blink()
Blinks the selector.
Definition: BaseView.cpp:311
BaseFacility * getSelectedFacility() const
Gets the currently selected facility.
Definition: BaseView.cpp:125
Represents a specific type of base facility.
Definition: RuleBaseFacility.h:35