summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--projects/openttd_vs100.vcxproj2
-rw-r--r--projects/openttd_vs100.vcxproj.filters6
-rw-r--r--projects/openttd_vs80.vcproj8
-rw-r--r--projects/openttd_vs90.vcproj8
-rw-r--r--source.list2
-rw-r--r--src/game/game_instance.cpp2
-rw-r--r--src/script/api/game/game_viewport.hpp.sq27
-rw-r--r--src/script/api/script_viewport.cpp24
-rw-r--r--src/script/api/script_viewport.hpp34
-rw-r--r--src/script/api/template/template_viewport.hpp.sq21
10 files changed, 134 insertions, 0 deletions
diff --git a/projects/openttd_vs100.vcxproj b/projects/openttd_vs100.vcxproj
index e1371b22c..a6cbf696e 100644
--- a/projects/openttd_vs100.vcxproj
+++ b/projects/openttd_vs100.vcxproj
@@ -978,6 +978,7 @@
<ClInclude Include="..\src\script\api\script_types.hpp" />
<ClInclude Include="..\src\script\api\script_vehicle.hpp" />
<ClInclude Include="..\src\script\api\script_vehiclelist.hpp" />
+ <ClInclude Include="..\src\script\api\script_viewport.hpp" />
<ClInclude Include="..\src\script\api\script_waypoint.hpp" />
<ClInclude Include="..\src\script\api\script_waypointlist.hpp" />
<ClCompile Include="..\src\script\api\script_accounting.cpp" />
@@ -1031,6 +1032,7 @@
<ClCompile Include="..\src\script\api\script_tunnel.cpp" />
<ClCompile Include="..\src\script\api\script_vehicle.cpp" />
<ClCompile Include="..\src\script\api\script_vehiclelist.cpp" />
+ <ClCompile Include="..\src\script\api\script_viewport.cpp" />
<ClCompile Include="..\src\script\api\script_waypoint.cpp" />
<ClCompile Include="..\src\script\api\script_waypointlist.cpp" />
<ClCompile Include="..\src\blitter\32bpp_anim.cpp" />
diff --git a/projects/openttd_vs100.vcxproj.filters b/projects/openttd_vs100.vcxproj.filters
index 6299a1ae7..66ac17eef 100644
--- a/projects/openttd_vs100.vcxproj.filters
+++ b/projects/openttd_vs100.vcxproj.filters
@@ -2163,6 +2163,9 @@
<ClInclude Include="..\src\script\api\script_vehiclelist.hpp">
<Filter>Script API</Filter>
</ClInclude>
+ <ClInclude Include="..\src\script\api\script_viewport.hpp">
+ <Filter>Script API</Filter>
+ </ClInclude>
<ClInclude Include="..\src\script\api\script_waypoint.hpp">
<Filter>Script API</Filter>
</ClInclude>
@@ -2322,6 +2325,9 @@
<ClCompile Include="..\src\script\api\script_vehiclelist.cpp">
<Filter>Script API Implementation</Filter>
</ClCompile>
+ <ClCompile Include="..\src\script\api\script_viewport.cpp">
+ <Filter>Script API Implementation</Filter>
+ </ClCompile>
<ClCompile Include="..\src\script\api\script_waypoint.cpp">
<Filter>Script API Implementation</Filter>
</ClCompile>
diff --git a/projects/openttd_vs80.vcproj b/projects/openttd_vs80.vcproj
index 7b1b4cc77..b07dcdd43 100644
--- a/projects/openttd_vs80.vcproj
+++ b/projects/openttd_vs80.vcproj
@@ -3247,6 +3247,10 @@
>
</File>
<File
+ RelativePath=".\..\src\script\api\script_viewport.hpp"
+ >
+ </File>
+ <File
RelativePath=".\..\src\script\api\script_waypoint.hpp"
>
</File>
@@ -3463,6 +3467,10 @@
>
</File>
<File
+ RelativePath=".\..\src\script\api\script_viewport.cpp"
+ >
+ </File>
+ <File
RelativePath=".\..\src\script\api\script_waypoint.cpp"
>
</File>
diff --git a/projects/openttd_vs90.vcproj b/projects/openttd_vs90.vcproj
index 2805a759d..465f3658e 100644
--- a/projects/openttd_vs90.vcproj
+++ b/projects/openttd_vs90.vcproj
@@ -3244,6 +3244,10 @@
>
</File>
<File
+ RelativePath=".\..\src\script\api\script_viewport.hpp"
+ >
+ </File>
+ <File
RelativePath=".\..\src\script\api\script_waypoint.hpp"
>
</File>
@@ -3460,6 +3464,10 @@
>
</File>
<File
+ RelativePath=".\..\src\script\api\script_viewport.cpp"
+ >
+ </File>
+ <File
RelativePath=".\..\src\script\api\script_waypoint.cpp"
>
</File>
diff --git a/source.list b/source.list
index 3578314a2..8b83002a9 100644
--- a/source.list
+++ b/source.list
@@ -756,6 +756,7 @@ script/api/script_tunnel.hpp
script/api/script_types.hpp
script/api/script_vehicle.hpp
script/api/script_vehiclelist.hpp
+script/api/script_viewport.hpp
script/api/script_waypoint.hpp
script/api/script_waypointlist.hpp
@@ -811,6 +812,7 @@ script/api/script_townlist.cpp
script/api/script_tunnel.cpp
script/api/script_vehicle.cpp
script/api/script_vehiclelist.cpp
+script/api/script_viewport.cpp
script/api/script_waypoint.cpp
script/api/script_waypointlist.cpp
diff --git a/src/game/game_instance.cpp b/src/game/game_instance.cpp
index 872c4829c..998788b61 100644
--- a/src/game/game_instance.cpp
+++ b/src/game/game_instance.cpp
@@ -70,6 +70,7 @@
#include "../script/api/game/game_tunnel.hpp.sq"
#include "../script/api/game/game_vehicle.hpp.sq"
#include "../script/api/game/game_vehiclelist.hpp.sq"
+#include "../script/api/game/game_viewport.hpp.sq"
#include "../script/api/game/game_waypoint.hpp.sq"
#include "../script/api/game/game_waypointlist.hpp.sq"
@@ -165,6 +166,7 @@ void GameInstance::RegisterAPI()
SQGSVehicleList_Depot_Register(this->engine);
SQGSVehicleList_SharedOrders_Register(this->engine);
SQGSVehicleList_Station_Register(this->engine);
+ SQGSViewport_Register(this->engine);
SQGSWaypoint_Register(this->engine);
SQGSWaypointList_Register(this->engine);
SQGSWaypointList_Vehicle_Register(this->engine);
diff --git a/src/script/api/game/game_viewport.hpp.sq b/src/script/api/game/game_viewport.hpp.sq
new file mode 100644
index 000000000..d313f0d75
--- /dev/null
+++ b/src/script/api/game/game_viewport.hpp.sq
@@ -0,0 +1,27 @@
+/* $Id$ */
+
+/*
+ * This file is part of OpenTTD.
+ * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
+ * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */
+
+#include "../script_viewport.hpp"
+#include "../template/template_viewport.hpp.sq"
+
+
+template <> const char *GetClassName<ScriptViewport, ST_GS>() { return "GSViewport"; }
+
+void SQGSViewport_Register(Squirrel *engine)
+{
+ DefSQClass<ScriptViewport, ST_GS> SQGSViewport("GSViewport");
+ SQGSViewport.PreRegister(engine);
+ SQGSViewport.AddConstructor<void (ScriptViewport::*)(), 1>(engine, "x");
+
+ SQGSViewport.DefSQStaticMethod(engine, &ScriptViewport::ScrollTo, "ScrollTo", 2, ".i");
+
+ SQGSViewport.PostRegister(engine);
+}
diff --git a/src/script/api/script_viewport.cpp b/src/script/api/script_viewport.cpp
new file mode 100644
index 000000000..139edb029
--- /dev/null
+++ b/src/script/api/script_viewport.cpp
@@ -0,0 +1,24 @@
+/* $Id$ */
+
+/*
+ * This file is part of OpenTTD.
+ * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
+ * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** @file script_viewport.cpp Implementation of ScriptViewport. */
+
+#include "../../stdafx.h"
+#include "script_viewport.hpp"
+#include "script_game.hpp"
+#include "script_map.hpp"
+#include "../../viewport_func.h"
+
+/* static */ void ScriptViewport::ScrollTo(TileIndex tile)
+{
+ if (ScriptGame::IsMultiplayer()) return;
+ if (!ScriptMap::IsValidTile(tile)) return;
+
+ ScrollMainWindowToTile(tile);
+}
diff --git a/src/script/api/script_viewport.hpp b/src/script/api/script_viewport.hpp
new file mode 100644
index 000000000..1d66c09b3
--- /dev/null
+++ b/src/script/api/script_viewport.hpp
@@ -0,0 +1,34 @@
+/* $Id$ */
+
+/*
+ * This file is part of OpenTTD.
+ * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
+ * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** @file script_viewport.hpp Everything to manipulate the users viewport. */
+
+#ifndef SCRIPT_VIEWPORT_HPP
+#define SCRIPT_VIEWPORT_HPP
+
+#include <string>
+#include "script_object.hpp"
+
+/**
+ * Class that manipultes the users viewport.
+ * @api game
+ */
+class ScriptViewport : public ScriptObject {
+public:
+ /**
+ * Scroll the viewport to the given tile, where the tile will be in the
+ * center of the screen.
+ * @param tile The tile to put in the center of the screen.
+ * @pre !ScriptGame::IsMultiplayer().
+ * @pre ScriptMap::IsValidTile(tile).
+ */
+ static void ScrollTo(TileIndex tile);
+};
+
+#endif /* SCRIPT_ADMIN_HPP */
diff --git a/src/script/api/template/template_viewport.hpp.sq b/src/script/api/template/template_viewport.hpp.sq
new file mode 100644
index 000000000..8a187ae81
--- /dev/null
+++ b/src/script/api/template/template_viewport.hpp.sq
@@ -0,0 +1,21 @@
+/* $Id$ */
+
+/*
+ * This file is part of OpenTTD.
+ * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
+ * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */
+
+#include "../script_viewport.hpp"
+
+namespace SQConvert {
+ /* Allow ScriptViewport to be used as Squirrel parameter */
+ template <> inline ScriptViewport *GetParam(ForceType<ScriptViewport *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptViewport *)instance; }
+ template <> inline ScriptViewport &GetParam(ForceType<ScriptViewport &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptViewport *)instance; }
+ template <> inline const ScriptViewport *GetParam(ForceType<const ScriptViewport *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptViewport *)instance; }
+ template <> inline const ScriptViewport &GetParam(ForceType<const ScriptViewport &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptViewport *)instance; }
+ template <> inline int Return<ScriptViewport *>(HSQUIRRELVM vm, ScriptViewport *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "Viewport", res, NULL, DefSQDestructorCallback<ScriptViewport>, true); return 1; }
+} // namespace SQConvert