mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 06:15:04 +00:00
(svn r23625) -Add: ScriptViewport::ScrollTo, for SinglePlayer only (GameScript only)
This commit is contained in:
parent
d85a628dde
commit
894216083d
@ -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" />
|
||||
|
@ -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>
|
||||
|
@ -3246,6 +3246,10 @@
|
||||
RelativePath=".\..\src\script\api\script_vehiclelist.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\script\api\script_viewport.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\script\api\script_waypoint.hpp"
|
||||
>
|
||||
@ -3462,6 +3466,10 @@
|
||||
RelativePath=".\..\src\script\api\script_vehiclelist.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\script\api\script_viewport.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\script\api\script_waypoint.cpp"
|
||||
>
|
||||
|
@ -3243,6 +3243,10 @@
|
||||
RelativePath=".\..\src\script\api\script_vehiclelist.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\script\api\script_viewport.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\script\api\script_waypoint.hpp"
|
||||
>
|
||||
@ -3459,6 +3463,10 @@
|
||||
RelativePath=".\..\src\script\api\script_vehiclelist.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\script\api\script_viewport.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\script\api\script_waypoint.cpp"
|
||||
>
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
27
src/script/api/game/game_viewport.hpp.sq
Normal file
27
src/script/api/game/game_viewport.hpp.sq
Normal file
@ -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);
|
||||
}
|
24
src/script/api/script_viewport.cpp
Normal file
24
src/script/api/script_viewport.cpp
Normal file
@ -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);
|
||||
}
|
34
src/script/api/script_viewport.hpp
Normal file
34
src/script/api/script_viewport.hpp
Normal file
@ -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 */
|
21
src/script/api/template/template_viewport.hpp.sq
Normal file
21
src/script/api/template/template_viewport.hpp.sq
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user