98 #if SDL_VERSION_ATLEAST(2, 0, 0)
100 switch(ev->
ev.window.event)
102 case SDL_WINDOWEVENT_ENTER:
105 case SDL_WINDOWEVENT_LEAVE:
108 case SDL_WINDOWEVENT_RESIZED:
138 std::string hotkey =
static_cast<const char*
>(ev->
ev.
user.
data1);
139 if (hotkey ==
"exit")
144 else if (hotkey ==
"screenshot")
149 else if (hotkey ==
"bigscreenshot")
154 else if (hotkey ==
"togglefullscreen")
160 LOGWARNING(L
"Toggling fullscreen and resizing are disabled on OS X due to a known bug. Please use the config file to change display settings.");
164 else if (hotkey ==
"profile2.enable")
206 int ret =
vfs_opt_auto_build(
"../logs/trace.txt",
"mods/official/official%02d.zip",
"mods/official/mini%02d.zip");
218 int percent = (int)ret;
219 g_ScriptingHost.SetGlobal(
"g_ArchiveBuilderProgress", INT_TO_JSVAL(percent));
233 wchar_t description[100];
234 int progress_percent;
277 PROFILE3(
"renderer incremental load");
279 const double maxTime = 0.1f;
284 more =
g_Renderer.GetTextureManager().MakeProgress();
286 while (more &&
timer_Time() - startTime < maxTime);
306 static double last_time;
308 const float TimeSinceLastFrame = (float)(time-last_time);
314 const float realTimeSinceLastFrame = 1.0 /
g_frequencyFilter->SmoothedFrequency();
316 ENSURE(realTimeSinceLastFrame > 0.0f);
320 bool need_update =
true;
344 if(!is_building_archive)
396 #if SDL_VERSION_ATLEAST(2, 0, 0)
461 if (args.
Has(
"replay"))
471 replay.
Load(args.
Get(
"replay"));
482 if (args.
Has(
"archivebuild"))
488 if (args.
Has(
"archivebuild-output"))
489 zip = args.
Get(
"archivebuild-output");
491 zip = mod.Filename().ChangeExtension(L
".zip");
494 builder.
Build(zip, args.
Has(
"archivebuild-compress"));
527 #define main pyrogenesis_main
528 extern "C" __attribute__((visibility (
"default"))) int
main(
int argc,
char* argv[]);
531 extern "C" int main(
int argc,
char* argv[])
538 std::cerr <<
"********************************************************\n"
539 <<
"WARNING: Attempted to run the game with root permission!\n"
540 <<
"This is not allowed because it can alter home directory \n"
541 <<
"permissions and opens your system to vulnerabilities. \n"
542 <<
"(You received this message because you were either \n"
543 <<
" logged in as root or used e.g. the 'sudo' command.) \n"
544 <<
"********************************************************\n\n";
int SDL_PollEvent(SDL_Event *ev)
void InitGraphics(const CmdLineArgs &args, int flags)
void Update()
Must be called frequently (preferably every frame), to update some internal reconnection timers...
Packages a mod's files into a distributable archive.
CStr Get(const char *name) const
Get the value of the named parameter.
CUserReporter g_UserReporter
CNetClient * g_NetClient
Global network client for the standard game.
static int ProgressiveLoad()
static void FinalShutdown()
void SDL_Delay(Uint32 ms)
void RecordFrameStart()
Call in main thread at the start of a frame.
void GUI_DisplayLoadProgress(int percent, const wchar_t *pending_task)
bool ToggleFullscreen()
Switch between fullscreen and windowed mode.
const OsPath & RData() const
Returns directory for read-only data installed with the game.
bool ATLAS_RunIfOnCmdLine(const CmdLineArgs &args, bool force)
static void RendererIncrementalLoad()
std::string StringifyJSON(jsval obj, bool indent=true)
Stringify to a JSON string, UTF-8 encoded.
void EnableHTTP()
Call in main thread to enable the HTTP server.
static void MainControllerInit()
void WriteScreenshot(const VfsPath &extension)
void SDL_GL_SwapBuffers()
const Status ALL_COMPLETE
int wcscpy_s(wchar_t *dst, size_t max_dst_chars, const wchar_t *src)
return ERR::VFS_DIR_NOT_FOUND if the given real path doesn't exist.
void Load(const std::string &path)
void Flush()
Flush any queued outgoing network messages.
bool ResizeWindow(int w, int h)
Resize the SDL window and associated graphics stuff to the new size.
#define WARN_RETURN_STATUS_IF_ERR(expression)
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
static bool ProgressiveBuildArchive()
#define PROFILE2(region)
Starts timing from now until the end of the current scope.
static bool restart_in_atlas
PIVFS CreateVfs(size_t cacheSize)
create an instance of a Virtual File System.
void IncrementFrameNumber()
Status ReloadChangedFiles()
poll for directory change notifications and reload all affected files.
bool Update(const double deltaRealTime, bool doInterpolate=true)
Periodic heartbeat that controls the process.
int vfs_opt_auto_build(const char *trace_filename, const char *archive_fn_fmt, const char *mini_archive_fn_fmt, bool force_build=false)
bool Has(const char *name) const
Test whether the given name was specified, as either -name or -name=value
void Update(const float deltaRealTime)
Updates all the view information (i.e.
New profiler (complementing the older CProfileManager)
void Build(const OsPath &archive, bool compress)
Do all the processing and packing of files into the archive.
#define ONCE(ONCE_code__)
execute the code passed as a parameter only the first time this is reached.
virtual const char * what() const
const OsPath & Cache() const
Returns cache directory.
static jsval ToJSVal(JSContext *cx, T const &val)
Convert a C++ type to a jsval.
anything mounted from here should be included when building archives.
void TickObjects()
See CGUI::TickObjects; applies to all loaded pages.
CGame * g_Game
Globally accessible pointer to the CGame object.
i64 Status
Error handling system.
static void Terminate()
Call once when shutting down the program, to unload libxml2.
void RenderCursor(bool RenderingState)
enable/disable rendering of the cursor - this does not hide cursor, but reverts to OS style ...
void Poll()
Poll the connection for messages from the server and process them, and send any queued messages...
PIFrequencyFilter g_frequencyFilter
void CancelLoad(const CStrW &message)
ScriptInterface & GetScriptInterface()
static void RunGameOrAtlas(int argc, const char *argv[])
void Update(const float deltaRealTime)
#define PROFILE2_ATTR
Associates a string (with printf-style formatting) with the current region or event.
CGameView * GetView()
Get the pointer to the game view object.
static void MainControllerShutdown()
Wrapper class for OS paths used by the game.
void Shutdown()
Call in main thread to shut everything down.
double timer_Resolution()
void EnableGPU()
Call in main thread to enable the GPU profiling support, after OpenGL has been initialised.
PIFrequencyFilter CreateFrequencyFilter(double resolution, double expectedFrequency)
Status LDR_ProgressiveLoad(double time_budget, wchar_t *description, size_t max_chars, int *progress_percent)
void EarlyInit()
initialize global modules that are be needed before Init.
bool IsGameStarted() const
Get m_GameStarted.
Network client/server sessions.
#define DEBUG_DISPLAY_ERROR(description)
static InReaction MainInputHandler(const SDL_Event_ *ev)
void restart_mainloop_in_atlas()
void ogl_WarnIfError()
raise a warning (break into the debugger) if an OpenGL error is pending.
static void Startup()
Call once when initialising the program, to load libxml2.
PSRETURN ReallyStartGame()
Game initialization has been completed.
int main(int argc, char *argv[])
void WriteBigScreenshot(const VfsPath &extension, int tiles)
JSContext * GetContext() const
void SendEventToAll(const CStr &eventName)
See CGUI::SendEventToAll; applies to the currently active page.