С Днём России!
  • 2.170
  • 6
Дорогие друзья! Поздравляю вас с Днём России! Этот праздник напоминает нам о богатой истории и культуре нашей страны, о её величии и непоколебимом духе народа! Желаю вам крепкого здоровья...
Новости Анонсирован Atomic Heart II
Новости Анонсирован ремастер Final Fantasy Tactics
  • 778
  • 1
Культовая пошаговая тактическая RPG от Square Enix получит второе дыхание. На проходящей выставке State of Play, где анонсируются игры для Play Station, состоялся анонс ремастера Final Fantasy...
Новости Моддеры Oblivion Remastered нашли способ внедрения абсолютно любых скриптов
  • 960
  • 4
Сообщество моддинга Oblivion Remastered (ORM) переживает настоящий расцвет. После долгих месяцев работы, энтузиасты научили игру работать с мощным скриптовым языком Lua, открыв перед создателями...
Union: Создание и запуск плагина / Creating and running a plugin

Гайд Union: Создание и запуск плагина / Creating and running a plugin

Работа с плагином Юнион. Этап создания плагина.
*Before the beginning, read this topic.

Creating a project:
Launch Visual studio, select 'Create project', or hold Ctrl + Shift + N.
In the window that opens, we find the plugin template UnionPlugin_X_Xx for Visual C ++.
Click ok and look in the browser window.

We have the interfaces of 4 versions of ZenGin and several source code files. Now we need Application.cpp.
Open the file and you can see several functions. Each will be called automatically when a game event is performed:
- Game_Entry occurs when initializing game resources and entering the main menu.
- Game_Init occurs when the game ends correctly.
- Game_Exit occurs every time the frame is redrawn during the game.
- Game_Loop happens before saving starts.
- Game_SaveBegin occurs before saving starts.
- Game_SaveEnd occurs after saving is completed.
- LoadBegin before any game loading.
- LoadEnd occurs after any loading of the game
- Game_LoadBegin_NewGame happens before loading a new game.
- Game_LoadEnd_NewGame happens after loading a new game.
- Game_LoadBegin_SaveGame happens before loading a saved game.
- Game_LoadEnd_SaveGame occurs after loading a saved game.
- Game_LoadBegin_ChangeLevel happens before loading another location.
- Game_LoadEnd_ChangeLevel occurs after loading another location.
- Game_LoadBegin_Trigger occurs before loading another location via a trigger (before calling Game_LoadBegin_ChangeLevel).
- Game_LoadEnd_Trigger occurs before loading another location via a trigger (after calling Game_LoadEnd_ChangeLevel)
- Game_Pause occurs when a game is paused.
- Game_Unpause occurs when the game resumes.
- Game_DefineExternals occurs before initializing external script functions.

Program code implementation:

These functions will be basic in writing any plugin. Therefore, within the framework of the current tutorial, I propose to check how they work.
When entering the main menu, we will output a message with the name of the current plugin, version of Union and the current engine.
We will use the Game_Init function.
C++:
// The function returns the name of the engine based on its version.
string GetEngineVersionName(TEngineVersion version) {
  switch( version ) {
  case Engine_G1:  return "Gothic I Classic";
  case Engine_G1A: return "Gothic I Addon";
  case Engine_G2:  return "Gothic II Classic";
  case Engine_G2A: return "Gothic II Addon";
  }
  return "Unknown";
}

void Game_Init() {

  // We get a pointer to the current
  // plugin and get its name
  const CPlugin* plugin = CPlugin::GetCurrentPlugin();
  string pluginName = plugin->GetName();

  // Get the instance version of the union
  // and convert it to a text string.
  TVersion unionVersion = Union.GetUnionVersion();
  string unionVersionName = unionVersion.ToString();

  // Get the version of the engine and its name
  TEngineVersion engineVersion = Union.GetEngineVersion();
  string engineVersionName = GetEngineVersionName(engineVersion);

  // Show a message on the screen
  Message::Info( string::Combine(
    "Plugin name: %s\nUnion version: %s\nEngine version: %s",
    pluginName,
    unionVersionName,
    engineVersionName
  ) );
}
Compilation and running:
In the project 'Configuration manager', set 'Release'. We collect the project and add it to the ini file. We start the game and wait for the menu to load.

Result:
Сверху Снизу