Skyscraper 2.0
control.h
Go to the documentation of this file.
1/*
2 Scalable Building Simulator - Control Object
3 The Skyscraper Project - Version 2.0
4 Copyright (C)2004-2024 Ryan Thoryk
5 https://www.skyscrapersim.net
6 https://sourceforge.net/projects/skyscraper/
7 Contact - ryan@skyscrapersim.net
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22*/
23
24#ifndef _SBS_CONTROL_H
25#define _SBS_CONTROL_H
26
27#include "lock.h"
28
29namespace SBS {
30
31class SBSIMPEXP Control : public Object, public Lock
32{
33public:
34 std::string Direction;
35
36 //functions
37 Control(Object *parent, const std::string &name, bool permanent, const std::string &sound, const std::vector<std::string> &action_names, const std::vector<Action*> &actions, std::vector<std::string> &textures, const std::string &direction, Real width, Real height, bool center, int selection_position);
38 ~Control();
39 void Enabled(bool value);
40 bool SetSelectPosition(int position);
41 bool ChangeSelectPosition(int position);
42 bool NextSelectPosition(bool check_state = true);
43 bool PreviousSelectPosition(bool check_state = true);
44 int GetSelectPosition();
45 std::string GetPositionAction(int position);
46 std::string GetSelectPositionAction();
47 int GetNextSelectPosition();
48 int GetPreviousSelectPosition();
49 int GetPositions();
50 void PlaySound();
51 void SetTexture(int position, const std::string &texture);
52 std::string GetTexture(int position);
53 int FindActionPosition(const std::string &name);
54 int FindNumericActionPosition();
55 bool DoAction();
56 bool Press(bool reverse = false);
57 void ChangeFloorLight(int floor, bool value);
58 void ChangeLight(bool value);
59 void RemoveAction(Action *action);
60 bool IsEnabled() { return is_enabled; }
61 bool GetLightStatus() { return light_status; }
62 void OnClick(Vector3 &position, bool shift, bool ctrl, bool alt, bool right);
63 void OnUnclick(bool right);
64 void Report(const std::string &message);
65 bool ReportError(const std::string &message);
66
67private:
68 MeshObject* ControlMesh; //control mesh object
69 int current_position; //current control position
70 std::vector<std::string> TextureArray; //selection texture array
71 std::vector<std::string> ActionNames; //control actions (uses name-based searches, slower and for dynamic controls)
72 std::vector<Action*> Actions; //control actions (faster and for static controls, uses pointer storage)
73
74 Sound *sound; //sound object
75 bool light_status; //light on/off value, used for floor buttons
77 bool action_hold; //storage for current position action's "hold" value
78 bool action_result; //value of last DoAction result
79};
80
81}
82
83#endif
int current_position
Definition control.h:69
bool light_status
Definition control.h:75
bool IsEnabled()
Definition control.h:60
bool action_hold
Definition control.h:77
bool GetLightStatus()
Definition control.h:61
std::vector< std::string > ActionNames
Definition control.h:71
std::vector< std::string > TextureArray
Definition control.h:70
std::vector< Action * > Actions
Definition control.h:72
Sound * sound
Definition control.h:74
bool is_enabled
Definition control.h:76
bool action_result
Definition control.h:78
std::string Direction
Definition control.h:34
MeshObject * ControlMesh
Definition control.h:68
Ogre::Vector3 Vector3
Definition globals.h:58
Ogre::Real Real
Definition globals.h:57
#define SBSIMPEXP
Definition globals.h:53