Photon is a mod loader for Portal 2.
- Download the newest release from here.
- Place it next to Portal 2's executable (typically in
SteamLibrary/steamapps/common/Portal 2). - Open the game and type
plugin_load photonin the console.
- Install mods by placing them in the
photonfolder inside the Portal 2 directory. - Enable them from the menu that you can open by pressing RShift.
git clone --recurse-submodules https://github.com/aIIison/photon.git
Requires CMake 3.15 or higher.
cmake -B build -A Win32
cmake --build build --config Debug/Release
cmake -B build
cmake --build build --config Debug/Release
Tip
Configure paths in cmake.toml and run cmake --install build after building.
This automatically installs the binaries to Portal 2.
- Follow the code style.
- Do not stage files that you had to configure.
Use the included .clang-format file.
snake_casefor everything.e_prefix for enums.c_prefix for classes.i_prefix for interfaces._tsuffix for data types.
enum class e_example {
example_value
};
struct vec2_t {
float x, y;
};
class i_example {
public:
virtual void example_fn( ) = 0;
};
class c_example : public i_example {
public:
virtual void example_fn( );
};Note
There's an included example mod with a few features you can take a look at.
Download and include the SDK in your project.
/* mod.h */
#pragma once
#include <photon.h>
class c_photon_mod : public photon_api::i_photon_mod {
public:
virtual bool load( photon_api::c_shared* photon );
virtual void unload( );
virtual void on_event( const char* msg );
virtual photon_api::mod_info_t get_info( );
virtual void paint_menu( );
};
extern c_photon_mod mod;
/* mod.cpp */
#include "mod.h"
c_photon_mod mod;
EXPOSE_PHOTON_MOD( c_photon_mod, mod );
photon_api::c_shared* photon;
bool c_photon_mod::load( photon_api::c_shared* photon ) {
::photon = photon; // expose photon interface globally.
return true;
}
void c_photon_mod::unload( ) {
// unallocate stuff here etc.
}
void c_photon_mod::on_event( const char* msg ) {
// handle events here.
}
photon_api::mod_info_t c_photon_mod::get_info( ) {
photon_api::mod_info_t info;
info.name = "Example Mod";
info.author = "hero";
info.version = "0.0.1";
return info;
}
void c_photon_mod::paint_menu( ) {
// add controls to the menu here using functions from photon->menu.
}