Skip to content

Commit

Permalink
Merge pull request #5611 from Web-eWorks/editor-prerequisite
Browse files Browse the repository at this point in the history
Editor Binary and Prerequisites
  • Loading branch information
Webster Sheets authored Aug 26, 2023
2 parents 3f7e6ee + da00e6d commit 1430cfc
Show file tree
Hide file tree
Showing 27 changed files with 1,405 additions and 154 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.13)
project(pioneer LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 17)

# If both libGL.so and libOpenGL.so are found, default to the latter
# (former is a legacy name).
Expand Down Expand Up @@ -371,6 +372,8 @@ if (WIN32)
list(APPEND winLibs shlwapi psapi)
endif (WIN32)

add_subdirectory(src/editor)

target_link_libraries(${PROJECT_NAME} LINK_PRIVATE ${pioneerLibs} ${winLibs})
target_link_libraries(unittest LINK_PRIVATE ${pioneerLibs} ${winLibs})
target_link_libraries(modelcompiler LINK_PRIVATE ${pioneerLibs} ${winLibs})
Expand Down Expand Up @@ -411,7 +414,7 @@ else (MODELCOMPILER)
message(WARNING "No modelcompiler provided, models won't be optimized!")
endif(MODELCOMPILER)

install(TARGETS ${PROJECT_NAME} modelcompiler savegamedump
install(TARGETS ${PROJECT_NAME} editor modelcompiler savegamedump
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(DIRECTORY data/
Expand Down
8 changes: 4 additions & 4 deletions Modelviewer.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
~~~~~~~~~~~~

This is a simple tool to view a game model using the game's rendering engine.
It's main purpose is to test and debug models, and generally isn't for
It's main purpose is to test and debug models, and generally isn't for
end-user use.

Usage:
~~~~~~
pioneer -mv <model>
editor -mv <model>

<model> - name of the model defined in lua

Example:
./pioneer -mv interdictor
./editor -mv interdictor
- will load the model interdictor

./pioneer -mv
./editor -mv
- will launch modelviewer, prompting for a model name.

Keyboard commands:
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Package a build and prepare it for upload via Travis.

BINARIES=("build/pioneer" "build/modelcompiler" "build/savegamedump")
BINARIES=("build/pioneer" "build/modelcompiler" "build/savegamedump" "build/editor")
COPY_DIR=release

# Append .exe to the binaries if we're building for windows.
Expand Down
21 changes: 9 additions & 12 deletions src/Pi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ void Pi::Init(const std::map<std::string, std::string> &options, bool no_gui)
GetApp()->m_gameLoop.Reset(new GameLoop());

m_instance->m_noGui = no_gui;

m_instance->Startup();
}

void Pi::App::SetStartPath(const SystemPath &startPath)
Expand Down Expand Up @@ -307,21 +309,13 @@ void TestGPUJobsSupport()
}
}

void Pi::App::Startup()
void Pi::App::OnStartup()
{
PROFILE_SCOPED()
Profiler::Clock startupTimer;
startupTimer.Start();

Application::Startup();

SetProfilerPath("profiler/");
SetProfileSlowFrames(config->Int("ProfileSlowFrames", 0));
bool profileZones = config->Int("ProfilerZoneOutput", 0);
bool profileTraces = config->Int("ProfilerTraceOutput", 0);

SetProfileZones(profileZones || profileTraces);
SetProfileTrace(profileTraces);
SetupProfiler(Pi::config);

Log::GetLog()->SetLogFile("output.txt");

Expand Down Expand Up @@ -412,7 +406,7 @@ void Pi::App::Startup()
*/

// Immediately destroy everything and end the game.
void Pi::App::Shutdown()
void Pi::App::OnShutdown()
{
PROFILE_SCOPED()
Output("Pi shutting down.\n");
Expand Down Expand Up @@ -461,8 +455,11 @@ void Pi::App::Shutdown()

delete Pi::config;
delete Pi::planner;
}

Application::Shutdown();
void Pi::Uninit()
{
m_instance->Shutdown();

SDL_Quit();
delete Pi::m_instance;
Expand Down
5 changes: 3 additions & 2 deletions src/Pi.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ class Pi {
App() :
GuiApplication("Pioneer") {}

void Startup() override;
void Shutdown() override;
void OnStartup() override;
void OnShutdown() override;

void PreUpdate() override;
void PostUpdate() override;
Expand Down Expand Up @@ -124,6 +124,7 @@ class Pi {

public:
static void Init(const std::map<std::string, std::string> &options, bool no_gui = false);
static void Uninit();

static void StartGame(Game *game);

Expand Down
16 changes: 8 additions & 8 deletions src/core/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@ void Application::Startup()
#endif

SDL_Init(SDL_INIT_EVENTS);

OnStartup();
}

void Application::Shutdown()
{
OnShutdown();

m_taskGraph.reset();
m_syncJobQueue.reset();

Expand Down Expand Up @@ -156,18 +160,16 @@ void Application::HandleJobs()

void Application::Run()
{
Profiler::Clock m_runtime{};
m_runtime.Start();
m_applicationRunning = true;

Startup();

if (!m_queuedLifecycles.size())
throw std::runtime_error("Application::Run must have a queued lifecycle object (did you forget to queue one?)");

// SoftStop updates the elapsed time measured by the clock, and continues to run the clock.
Profiler::Clock m_runtime{};
m_runtime.Start();
m_runtime.SoftStop();
m_totalTime = m_runtime.seconds();

m_applicationRunning = true;
while (m_applicationRunning) {
m_runtime.SoftStop();
double thisTime = m_runtime.seconds();
Expand Down Expand Up @@ -230,6 +232,4 @@ void Application::Run()
Profiler::reset();
#endif
}

Shutdown();
}
10 changes: 8 additions & 2 deletions src/core/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,15 @@ class Application {
// Use this function very sparingly (e.g. when the application is shutting down)
void ClearQueuedLifecycles();

// Perform initialization tasks at program startup
void Startup();

// Runs the application as long as there is a valid lifecycle object
void Run();

// Perform deinitialization tasks at program termination
void Shutdown();

// Get the time between the start of the last update and the current one
float DeltaTime() { return m_deltaTime; }

Expand All @@ -88,10 +94,10 @@ class Application {
// Hooks for inheriting classes to add their own behaviors to.

// Runs before the main loop begins
virtual void Startup();
virtual void OnStartup() {}

// Runs after the main loop ends
virtual void Shutdown();
virtual void OnShutdown() {}

// Handle running pinned tasks and processing queued jobs
virtual void HandleJobs();
Expand Down
13 changes: 13 additions & 0 deletions src/core/GuiApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,19 @@ void GuiApplication::HandleEvents()
DispatchEvents();
}

void GuiApplication::SetupProfiler(IniConfig *config)
{
// Setup common profiling parameters from the config file
bool profileSlow = config->Int("ProfileSlowFrames", 0);
bool profileZones = config->Int("ProfilerZoneOutput", 0);
bool profileTraces = config->Int("ProfilerTraceOutput", 0);

SetProfilerPath("profiler/");
SetProfileSlowFrames(profileSlow);
SetProfileZones(profileZones || profileTraces);
SetProfileTrace(profileTraces);
}

Graphics::Renderer *GuiApplication::StartupRenderer(IniConfig *config, bool hidden)
{
PROFILE_SCOPED()
Expand Down
15 changes: 9 additions & 6 deletions src/core/GuiApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,26 @@ class GuiApplication : public Application {
// framebuffer
void DrawRenderTarget();

// Call this from your OnStartup() method
void SetupProfiler(IniConfig *config);

// TODO: unify config handling, possibly make the config an Application member
// Call this from your Startup() method
// Call this from your OnStartup() method
Graphics::Renderer *StartupRenderer(IniConfig *config, bool hidden = false);

// Call this from your Startup() method
// Call this from your OnStartup() method
Input::Manager *StartupInput(IniConfig *config);

// Call this from your Startup() method
// Call this from your OnStartup() method
PiGui::Instance *StartupPiGui();

// Call this from your Shutdown() method
// Call this from your OnShutdown() method
void ShutdownRenderer();

// Call this from your Shutdown() method
// Call this from your OnShutdown() method
void ShutdownInput();

// Call this from your shutdown() method
// Call this from your OnShutdown() method
void ShutdownPiGui();

// Hook to bind the RT and clear the screen.
Expand Down
30 changes: 30 additions & 0 deletions src/editor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

list(APPEND EDITOR_SRC_FOLDERS
${CMAKE_CURRENT_SOURCE_DIR}
mfd/
)

# Creates variables EDITOR_CXX_FILES and EDITOR_HXX_FILES
add_source_folders(EDITOR EDITOR_SRC_FOLDERS)

list(REMOVE_ITEM EDITOR_CXX_FILES
editormain.cpp
)

# Creates a library, adds it to the build, and sets C++ target properties on it
define_pioneer_library(pioneer-editor EDITOR_CXX_FILES EDITOR_HXX_FILES)
target_include_directories(pioneer-editor PRIVATE ${CMAKE_BINARY_DIR})
target_link_libraries(pioneer-editor LINK_PRIVATE
pioneer-core
pioneer-lib
)

list(APPEND EDITOR_LIBRARIES
pioneer-editor
pioneer-core
)

add_executable(editor WIN32 editormain.cpp ${RESOURCES})
set_cxx_properties(editor)
target_link_libraries(editor LINK_PRIVATE ${EDITOR_LIBRARIES} ${pioneerLibs} ${winLibs})
set_target_properties(editor PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
Loading

0 comments on commit 1430cfc

Please sign in to comment.