コード例 #1
0
ファイル: ChangesNotifier.cpp プロジェクト: Lizard-13/GD
void ChangesNotifier::OnEventsModified(
    gd::Project& game,
    gd::ExternalEvents& events,
    bool indirectChange,
    gd::String sourceOfTheIndirectChange) const {
#if !defined(GD_NO_WX_GUI)  // Compilation is not supported when wxWidgets
                            // support is disabled.
  DependenciesAnalyzer analyzer(game, events);
  gd::String associatedScene = analyzer.ExternalEventsCanBeCompiledForAScene();
  bool externalEventsAreCompiledSeparately = !associatedScene.empty();

  if (!externalEventsAreCompiledSeparately) return;

  std::cout << "Changes occured inside " << events.GetName()
            << " (compiled separately)..." << std::endl;

  // The external events are compiled separately from the scene events:
  // We need to recompile them if the changes occured inside them.

  if (!indirectChange ||
      !game.HasExternalEventsNamed(sourceOfTheIndirectChange)) {
    // Changes occurred directly inside the external events: We need to
    // recompile them
    events.SetLastChangeTimeStamp(wxDateTime::Now().GetTicks());
    CodeCompilationHelpers::CreateExternalEventsCompilationTask(game, events);
    std::cout << "Recompilation triggered." << std::endl;
  } else {
    DependenciesAnalyzer analyzer(
        game, game.GetExternalEvents(sourceOfTheIndirectChange));
    if (analyzer.ExternalEventsCanBeCompiledForAScene() == associatedScene) {
      // Do nothing: Changes occurred in an external event which is compiled
      // separately
      std::cout << "But nothing to do." << std::endl;
    } else {
      // Changes occurred in an another external event which is directly
      // included in our external events.
      events.SetLastChangeTimeStamp(wxDateTime::Now().GetTicks());
      CodeCompilationHelpers::CreateExternalEventsCompilationTask(game, events);
      std::cout << "Recompilation triggered." << std::endl;
    }
  }
#endif
}