1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program 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 this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef ULTIMA4_GAME_CONTEXT_H
24 #define ULTIMA4_GAME_CONTEXT_H
25 
26 #include "ultima/ultima4/map/location.h"
27 #include "ultima/ultima4/game/aura.h"
28 #include "ultima/ultima4/game/names.h"
29 #include "ultima/ultima4/game/person.h"
30 #include "ultima/ultima4/game/script.h"
31 #include "ultima/ultima4/core/types.h"
32 #include "ultima/ultima4/filesys/savegame.h"
33 #include "ultima/shared/std/containers.h"
34 
35 namespace Ultima {
36 namespace Ultima4 {
37 
38 class Object;
39 class Party;
40 class Person;
41 class Script;
42 class StatsArea;
43 
44 enum TransportContext {
45 	TRANSPORT_FOOT      = 0x1,
46 	TRANSPORT_HORSE     = 0x2,
47 	TRANSPORT_SHIP      = 0x4,
48 	TRANSPORT_BALLOON       = 0x8,
49 	TRANSPORT_FOOT_OR_HORSE = TRANSPORT_FOOT | TRANSPORT_HORSE,
50 	TRANSPORT_ANY           = 0xffff
51 };
52 
53 /**
54  * Context class
55  */
56 class Context : public Script::Provider {
57 public:
58 	Context();
59 	~Context();
60 
61 	/**
62 	 * Reset the context
63 	 */
64 	void reset();
65 
66 	StatsArea *_stats;
67 	Aura *_aura;
68 	Party *_party;
69 	Location *_location;
70 	int _line, _col;
71 	int _moonPhase;
72 	int _windDirection;
73 	int _windCounter;
74 	bool _windLock;
75 	int _horseSpeed;
76 	int _opacity;
77 	TransportContext _transportContext;
78 	uint32 _lastCommandTime;
79 	Object *_lastShip;
80 public:
81 	/**
82 	 * Provides scripts with information
83 	 */
translate(Std::vector<Common::String> & parts)84 	Common::String translate(Std::vector<Common::String> &parts) override {
85 		if (parts.size() == 1) {
86 			if (parts[0] == "wind")
87 				return getDirectionName(static_cast<Direction>(_windDirection));
88 		}
89 		return "";
90 	}
91 };
92 
93 extern Context *g_context;
94 
95 } // End of namespace Ultima4
96 } // End of namespace Ultima
97 
98 #endif
99