OpenXcom  1.0
Open-source clone of the original X-Com
BaseView.h
1 #pragma once
2 /*
3  * Copyright 2010-2016 OpenXcom Developers.
4  *
5  * This file is part of OpenXcom.
6  *
7  * OpenXcom is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * OpenXcom is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
19  */
20 #include "../Engine/InteractiveSurface.h"
21 
22 namespace OpenXcom
23 {
24 
25 class Base;
26 class SurfaceSet;
27 class BaseFacility;
28 class RuleBaseFacility;
29 class Font;
30 class Language;
31 class Timer;
32 
39 {
40 private:
41  static const int BASE_SIZE = 6;
42  static const int GRID_SIZE = 32;
43 
44  Base *_base;
45  SurfaceSet *_texture;
46  BaseFacility *_facilities[BASE_SIZE][BASE_SIZE], *_selFacility;
47  Font *_big, *_small;
48  Language *_lang;
49  int _gridX, _gridY, _selSize;
50  Surface *_selector;
51  bool _blink;
52  Timer *_timer;
53  Uint8 _cellColor, _selectorColor;
55  void updateNeighborFacilityBuildTime(BaseFacility* facility, BaseFacility* neighbor);
56 public:
58  BaseView(int width, int height, int x = 0, int y = 0);
60  ~BaseView();
62  void initText(Font *big, Font *small, Language *lang);
64  void setBase(Base *base);
66  void setTexture(SurfaceSet *texture);
70  void resetSelectedFacility();
72  int getGridX() const;
74  int getGridY() const;
76  void setSelectable(int size);
78  bool isPlaceable(RuleBaseFacility *rule) const;
80  bool isQueuedBuilding(RuleBaseFacility *rule) const;
82  void reCalcQueuedBuildings();
84  void think();
86  void blink();
88  void draw();
90  void blit(Surface *surface);
92  void mouseOver(Action *action, State *state);
94  void mouseOut(Action *action, State *state);
95 
96  void setColor(Uint8 color);
97 
98  void setSecondaryColor(Uint8 color);
99 };
100 
101 }
void resetSelectedFacility()
Prevents any mouseover bugs on dismantling base facilities before setBase has had time to update the ...
Definition: BaseView.cpp:142
Container for all the information associated with a given user action, like mouse clicks...
Definition: Action.h:32
int getGridY() const
Gets the Y position of the currently selected square.
Definition: BaseView.cpp:164
void draw()
Draws the base view.
Definition: BaseView.cpp:355
A game state that receives user input and reacts accordingly.
Definition: State.h:44
void setSecondaryColor(Uint8 color)
Sets the secondary color of the surface.
Definition: BaseView.cpp:573
Represents a base facility placed in a base.
Definition: BaseFacility.h:36
Timer used to run code in fixed intervals.
Definition: Timer.h:35
int getGridX() const
Gets the X position of the currently selected square.
Definition: BaseView.cpp:154
Surface that the user can interact with.
Definition: InteractiveSurface.h:37
BaseFacility * getSelectedFacility() const
Gets the currently selected facility.
Definition: BaseView.cpp:134
void mouseOut(Action *action, State *state)
Special handling for mouse hovering out.
Definition: BaseView.cpp:558
void initText(Font *big, Font *small, Language *lang)
Initializes the base view&#39;s various resources.
Definition: BaseView.cpp:79
void reCalcQueuedBuildings()
ReCalculates the remaining build-time of all queued buildings.
Definition: BaseView.cpp:264
void think()
Handles the timers.
Definition: BaseView.cpp:312
~BaseView()
Cleans up the base view.
Definition: BaseView.cpp:64
void setColor(Uint8 color)
Sets the color of the surface.
Definition: BaseView.cpp:569
Contains strings used throughout the game for localization.
Definition: Language.h:39
Container of a set of surfaces.
Definition: SurfaceSet.h:35
bool isQueuedBuilding(RuleBaseFacility *rule) const
Checks if the placed facility is placed in queue or not.
Definition: BaseView.cpp:246
void blit(Surface *surface)
Blits the base view onto another surface.
Definition: BaseView.cpp:506
Takes care of loading and storing each character in a sprite font.
Definition: Font.h:46
void setBase(Base *base)
Sets the base to display.
Definition: BaseView.cpp:91
bool isPlaceable(RuleBaseFacility *rule) const
Checks if a facility can be placed.
Definition: BaseView.cpp:206
void setTexture(SurfaceSet *texture)
Sets the texture for this base view.
Definition: BaseView.cpp:125
Represents a player base on the globe.
Definition: Base.h:45
Element that is blit (rendered) onto the screen.
Definition: Surface.h:38
void mouseOver(Action *action, State *state)
Special handling for mouse hovers.
Definition: BaseView.cpp:520
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:38
void setSelectable(int size)
Sets whether the base view is selectable.
Definition: BaseView.cpp:174
void blink()
Blinks the selector.
Definition: BaseView.cpp:320
Definition: BaseInfoState.cpp:40
Represents a specific type of base facility.
Definition: RuleBaseFacility.h:35