mirror of https://github.com/OpenTTD/OpenTTD
Add: scaffolding for finding social plugins on disk
parent
218e9be10e
commit
3122a992bf
|
@ -393,6 +393,8 @@ add_files(
|
|||
slope_type.h
|
||||
smallmap_gui.cpp
|
||||
smallmap_gui.h
|
||||
social_integration.cpp
|
||||
social_integration.h
|
||||
sortlist_type.h
|
||||
sound.cpp
|
||||
sound_func.h
|
||||
|
|
|
@ -2141,6 +2141,7 @@ DEF_CONSOLE_CMD(ConListDirs)
|
|||
{ SAVE_DIR, "save", true },
|
||||
{ AUTOSAVE_DIR, "autosave", true },
|
||||
{ SCREENSHOT_DIR, "screenshot", true },
|
||||
{ SOCIAL_INTEGRATION_DIR, "social_integration", true },
|
||||
};
|
||||
|
||||
if (argc != 2) {
|
||||
|
|
|
@ -52,6 +52,7 @@ static const char * const _subdirs[] = {
|
|||
"game" PATHSEP,
|
||||
"game" PATHSEP "library" PATHSEP,
|
||||
"screenshot" PATHSEP,
|
||||
"social_integration" PATHSEP,
|
||||
};
|
||||
static_assert(lengthof(_subdirs) == NUM_SUBDIRS);
|
||||
|
||||
|
@ -1054,7 +1055,7 @@ void DeterminePaths(const char *exe, bool only_local_path)
|
|||
Debug(misc, 1, "{} found as personal directory", _personal_dir);
|
||||
|
||||
static const Subdirectory default_subdirs[] = {
|
||||
SAVE_DIR, AUTOSAVE_DIR, SCENARIO_DIR, HEIGHTMAP_DIR, BASESET_DIR, NEWGRF_DIR, AI_DIR, AI_LIBRARY_DIR, GAME_DIR, GAME_LIBRARY_DIR, SCREENSHOT_DIR
|
||||
SAVE_DIR, AUTOSAVE_DIR, SCENARIO_DIR, HEIGHTMAP_DIR, BASESET_DIR, NEWGRF_DIR, AI_DIR, AI_LIBRARY_DIR, GAME_DIR, GAME_LIBRARY_DIR, SCREENSHOT_DIR, SOCIAL_INTEGRATION_DIR
|
||||
};
|
||||
|
||||
for (uint i = 0; i < lengthof(default_subdirs); i++) {
|
||||
|
@ -1068,7 +1069,7 @@ void DeterminePaths(const char *exe, bool only_local_path)
|
|||
FillValidSearchPaths(only_local_path);
|
||||
|
||||
/* Create the directory for each of the types of content */
|
||||
const Subdirectory dirs[] = { SCENARIO_DIR, HEIGHTMAP_DIR, BASESET_DIR, NEWGRF_DIR, AI_DIR, AI_LIBRARY_DIR, GAME_DIR, GAME_LIBRARY_DIR };
|
||||
const Subdirectory dirs[] = { SCENARIO_DIR, HEIGHTMAP_DIR, BASESET_DIR, NEWGRF_DIR, AI_DIR, AI_LIBRARY_DIR, GAME_DIR, GAME_LIBRARY_DIR, SOCIAL_INTEGRATION_DIR };
|
||||
for (uint i = 0; i < lengthof(dirs); i++) {
|
||||
FioCreateDirectory(FioGetDirectory(SP_AUTODOWNLOAD_DIR, dirs[i]));
|
||||
}
|
||||
|
|
|
@ -121,6 +121,7 @@ enum Subdirectory {
|
|||
GAME_DIR, ///< Subdirectory for all game scripts
|
||||
GAME_LIBRARY_DIR, ///< Subdirectory for all GS libraries
|
||||
SCREENSHOT_DIR, ///< Subdirectory for all screenshots
|
||||
SOCIAL_INTEGRATION_DIR, ///< Subdirectory for all social integration plugins
|
||||
NUM_SUBDIRS, ///< Number of subdirectories
|
||||
NO_DIRECTORY, ///< A path without any base directory
|
||||
};
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
#include "timer/timer_game_economy.h"
|
||||
#include "timer/timer_game_realtime.h"
|
||||
#include "timer/timer_game_tick.h"
|
||||
#include "social_integration.h"
|
||||
|
||||
#include "linkgraph/linkgraphschedule.h"
|
||||
|
||||
|
@ -752,6 +753,7 @@ int openttd_main(int argc, char *argv[])
|
|||
/* The video driver is now selected, now initialise GUI zoom */
|
||||
AdjustGUIZoom(false);
|
||||
|
||||
SocialIntegration::Initialize();
|
||||
NetworkStartUp(); // initialize network-core
|
||||
|
||||
if (!HandleBootstrap()) {
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* 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 social_integration.cpp Base implementation of social integration support. */
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "social_integration.h"
|
||||
#include "3rdparty/openttd_social_integration_api/openttd_social_integration_api.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "fileio_func.h"
|
||||
#include "library_loader.h"
|
||||
#include "rev.h"
|
||||
#include "string_func.h"
|
||||
|
||||
#include "safeguards.h"
|
||||
|
||||
/** Helper for scanning for files with SocialIntegration as extension */
|
||||
class SocialIntegrationFileScanner : FileScanner {
|
||||
public:
|
||||
void Scan()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
std::string extension = "-social.dll";
|
||||
#elif defined(__APPLE__)
|
||||
std::string extension = "-social.dylib";
|
||||
#else
|
||||
std::string extension = "-social.so";
|
||||
#endif
|
||||
|
||||
this->FileScanner::Scan(extension.c_str(), SOCIAL_INTEGRATION_DIR, false);
|
||||
}
|
||||
|
||||
bool AddFile(const std::string &filename, size_t basepath_length, const std::string &) override
|
||||
{
|
||||
std::string basepath = filename.substr(basepath_length);
|
||||
Debug(misc, 1, "[Social Integration: {}] Loading ...", basepath);
|
||||
}
|
||||
};
|
||||
|
||||
void SocialIntegration::Initialize()
|
||||
{
|
||||
SocialIntegrationFileScanner fs;
|
||||
fs.Scan();
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* 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 social_integration.h Interface definitions for game to report/respond to social integration. */
|
||||
|
||||
#ifndef SOCIAL_INTEGRATION_H
|
||||
#define SOCIAL_INTEGRATION_H
|
||||
|
||||
class SocialIntegration {
|
||||
public:
|
||||
/**
|
||||
* Initialize the social integration system, loading any social integration plugins that are available.
|
||||
*/
|
||||
static void Initialize();
|
||||
};
|
||||
|
||||
#endif /* SOCIAL_INTEGRATION_H */
|
Loading…
Reference in New Issue