Feature: GS methods to scroll viewport for players (#6745)
This commit is contained in:
@@ -21,7 +21,10 @@ void SQGSViewport_Register(Squirrel *engine)
|
||||
SQGSViewport.PreRegister(engine);
|
||||
SQGSViewport.AddConstructor<void (ScriptViewport::*)(), 1>(engine, "x");
|
||||
|
||||
SQGSViewport.DefSQStaticMethod(engine, &ScriptViewport::ScrollTo, "ScrollTo", 2, ".i");
|
||||
SQGSViewport.DefSQStaticMethod(engine, &ScriptViewport::ScrollTo, "ScrollTo", 2, ".i");
|
||||
SQGSViewport.DefSQStaticMethod(engine, &ScriptViewport::ScrollEveryoneTo, "ScrollEveryoneTo", 2, ".i");
|
||||
SQGSViewport.DefSQStaticMethod(engine, &ScriptViewport::ScrollCompanyClientsTo, "ScrollCompanyClientsTo", 3, ".ii");
|
||||
SQGSViewport.DefSQStaticMethod(engine, &ScriptViewport::ScrollClientTo, "ScrollClientTo", 3, ".ii");
|
||||
|
||||
SQGSViewport.PostRegister(engine);
|
||||
}
|
||||
|
@@ -22,6 +22,9 @@
|
||||
* \li GSClient
|
||||
* \li GSClientList
|
||||
* \li GSClientList_Company
|
||||
* \li GSViewport::ScrollEveryoneTo
|
||||
* \li GSViewport::ScrollCompanyClientsTo
|
||||
* \li GSViewport::ScrollClientTo
|
||||
*
|
||||
* \b 1.8.0
|
||||
*
|
||||
|
@@ -10,9 +10,11 @@
|
||||
/** @file script_viewport.cpp Implementation of ScriptViewport. */
|
||||
|
||||
#include "../../stdafx.h"
|
||||
#include "script_error.hpp"
|
||||
#include "script_viewport.hpp"
|
||||
#include "script_game.hpp"
|
||||
#include "script_map.hpp"
|
||||
#include "../script_instance.hpp"
|
||||
#include "../../viewport_func.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
@@ -24,3 +26,34 @@
|
||||
|
||||
ScrollMainWindowToTile(tile);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptViewport::ScrollEveryoneTo(TileIndex tile)
|
||||
{
|
||||
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
|
||||
EnforcePrecondition(false, ScriptMap::IsValidTile(tile));
|
||||
|
||||
return ScriptObject::DoCommand(tile, VST_EVERYONE, 0, CMD_SCROLL_VIEWPORT);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptViewport::ScrollCompanyClientsTo(ScriptCompany::CompanyID company, TileIndex tile)
|
||||
{
|
||||
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
|
||||
EnforcePrecondition(false, ScriptMap::IsValidTile(tile));
|
||||
|
||||
company = ScriptCompany::ResolveCompanyID(company);
|
||||
EnforcePrecondition(false, company != ScriptCompany::COMPANY_INVALID);
|
||||
|
||||
return ScriptObject::DoCommand(tile, VST_COMPANY, company, CMD_SCROLL_VIEWPORT);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptViewport::ScrollClientTo(ScriptClient::ClientID client, TileIndex tile)
|
||||
{
|
||||
EnforcePrecondition(false, ScriptGame::IsMultiplayer());
|
||||
EnforcePrecondition(false, ScriptObject::GetCompany() == OWNER_DEITY);
|
||||
EnforcePrecondition(false, ScriptMap::IsValidTile(tile));
|
||||
|
||||
client = ScriptClient::ResolveClientID(client);
|
||||
EnforcePrecondition(false, client != ScriptClient::CLIENT_INVALID);
|
||||
|
||||
return ScriptObject::DoCommand(tile, VST_CLIENT, client, CMD_SCROLL_VIEWPORT);
|
||||
}
|
||||
|
@@ -13,6 +13,8 @@
|
||||
#define SCRIPT_VIEWPORT_HPP
|
||||
|
||||
#include "script_object.hpp"
|
||||
#include "script_client.hpp"
|
||||
#include "script_company.hpp"
|
||||
|
||||
/**
|
||||
* Class that manipulates the user's viewport.
|
||||
@@ -28,6 +30,38 @@ public:
|
||||
* @pre ScriptMap::IsValidTile(tile).
|
||||
*/
|
||||
static void ScrollTo(TileIndex tile);
|
||||
|
||||
/**
|
||||
* Scroll the viewport of all players 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 ScriptObject::GetCompany() == OWNER_DEITY
|
||||
* @pre ScriptMap::IsValidTile(tile)
|
||||
*/
|
||||
static bool ScrollEveryoneTo(TileIndex tile);
|
||||
|
||||
/**
|
||||
* Scroll the viewports of all players in the company to the given tile,
|
||||
* where the tile will be in the center of the screen.
|
||||
* @param company The company which players to scroll the viewport of.
|
||||
* @param tile The tile to put in the center of the screen.
|
||||
* @pre ScriptObject::GetCompany() == OWNER_DEITY
|
||||
* @pre ScriptMap::IsValidTile(tile)
|
||||
* @pre ResolveCompanyID(company) != COMPANY_INVALID
|
||||
*/
|
||||
static bool ScrollCompanyClientsTo(ScriptCompany::CompanyID company, TileIndex tile);
|
||||
|
||||
/**
|
||||
* Scroll the viewport of the client to the given tile,
|
||||
* where the tile will be in the center of the screen.
|
||||
* @param client The client to scroll the viewport of.
|
||||
* @param tile The tile to put in the center of the screen.
|
||||
* @pre ScriptGame::IsMultiplayer()
|
||||
* @pre ScriptObject::GetCompany() == OWNER_DEITY
|
||||
* @pre ScriptMap::IsValidTile(tile)
|
||||
* @pre ResolveClientID(client) != CLIENT_INVALID
|
||||
*/
|
||||
static bool ScrollClientTo(ScriptClient::ClientID client, TileIndex tile);
|
||||
};
|
||||
|
||||
#endif /* SCRIPT_ADMIN_HPP */
|
||||
|
Reference in New Issue
Block a user