Skip to content

Commit

Permalink
Enable xrWeatherEditor on Release
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Jan 21, 2018
1 parent ac1fce0 commit ccce5e7
Show file tree
Hide file tree
Showing 68 changed files with 129 additions and 502 deletions.
2 changes: 1 addition & 1 deletion src/xrCore/ModuleLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void* Module::open(pcstr moduleName)
handle = ::LoadLibrary(moduleName);

if (handle == nullptr)
Msg("Failed to load DLL: %d", GetLastError());
Msg("! Failed to load DLL: %d", GetLastError());

return handle;
}
Expand Down
11 changes: 2 additions & 9 deletions src/xrEngine/Device_Initialize.cpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
#include "stdafx.h"
#include "resource.h"
#ifdef INGAME_EDITOR
#include "Include/editor/ide.hpp"
#include "engine_impl.hpp"
#endif
#include "GameFont.h"
#include "PerformanceAlert.hpp"
#include "xrCore/ModuleLookup.hpp"

extern LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

#ifdef INGAME_EDITOR
void CRenderDevice::initialize_editor()
{
m_editor_module = std::make_unique<XRay::Module>("xrWeatherEditor");
if (!m_editor_module->exist())
{
Msg("! cannot load library \"xrWeatherEditor\"");
return;
}

m_editor_initialize = (initialize_function_ptr)m_editor_module->getProcAddress("initialize");
VERIFY(m_editor_initialize);
Expand All @@ -33,17 +27,16 @@ void CRenderDevice::initialize_editor()
m_hWnd = m_editor->view_handle();
VERIFY(m_hWnd != INVALID_HANDLE_VALUE);
}
#endif // #ifdef INGAME_EDITOR

void CRenderDevice::Initialize()
{
Log("Initializing Engine...");
TimerGlobal.Start();
TimerMM.Start();
#ifdef INGAME_EDITOR

if (strstr(Core.Params, "-editor"))
initialize_editor();
#endif

// Unless a substitute hWnd has been specified, create a window to render into
if (!m_hWnd)
{
Expand Down
6 changes: 1 addition & 5 deletions src/xrEngine/Device_create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ void CRenderDevice::Create()
#endif
fFOV = 90.f;
fASPECT = 1.f;
#ifdef INGAME_EDITOR
bool noEd = !editor();
#else
bool noEd = true;
#endif
const bool noEd = !editor();
GEnv.Render->Create(m_hWnd, dwWidth, dwHeight, fWidth_2, fHeight_2, noEd);
Memory.mem_compact();
b_is_Ready = TRUE;
Expand Down
24 changes: 10 additions & 14 deletions src/xrEngine/Device_wndproc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,30 @@ bool CRenderDevice::on_message(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
{
switch (uMsg)
{
case WM_SYSKEYDOWN: { return true;
}
case WM_ACTIVATE: {
#ifdef INGAME_EDITOR
case WM_SYSKEYDOWN: { return true; }
case WM_ACTIVATE:
{
if (editor())
{
Device.b_is_Active = TRUE;
break;
}
#endif // #ifdef INGAME_EDITOR

OnWM_Activate(wParam, lParam);
return (false);
}
case WM_SETCURSOR: {
#ifdef INGAME_EDITOR
case WM_SETCURSOR:
{
if (editor())
break;
#endif // #ifdef INGAME_EDITOR

result = 1;
return (true);
}
case WM_SYSCOMMAND: {
#ifdef INGAME_EDITOR
case WM_SYSCOMMAND:
{
if (editor())
break;
#endif // #ifdef INGAME_EDITOR

// Prevent moving/sizing and power loss in fullscreen mode
switch (wParam)
Expand All @@ -42,11 +39,10 @@ bool CRenderDevice::on_message(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
}
return (false);
}
case WM_CLOSE: {
#ifdef INGAME_EDITOR
case WM_CLOSE:
{
if (editor())
break;
#endif // #ifdef INGAME_EDITOR

result = 0;
return (true);
Expand Down
54 changes: 22 additions & 32 deletions src/xrEngine/Environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ class CLensFlareDescriptor;

#define DAY_LENGTH 86400.f

#ifdef INGAME_EDITOR
#define INGAME_EDITOR_VIRTUAL virtual
#else // #ifdef INGAME_EDITOR
#define INGAME_EDITOR_VIRTUAL
#endif // #ifdef INGAME_EDITOR

// t-defs
class ENGINE_API CEnvModifier
{
Expand Down Expand Up @@ -69,7 +63,7 @@ class ENGINE_API CEnvAmbient
float wind_blast_strength;
Fvector wind_blast_direction;

INGAME_EDITOR_VIRTUAL ~SEffect() {}
virtual ~SEffect() {}
};
using EffectVec = xr_vector<SEffect*>;

Expand All @@ -95,8 +89,8 @@ class ENGINE_API CEnvAmbient
{
return (m_sound_dist.x < m_sound_dist.y) ? Random.randF(m_sound_dist.x, m_sound_dist.y) : 0;
}
INGAME_EDITOR_VIRTUAL ~SSndChannel() {}
INGAME_EDITOR_VIRTUAL sounds_type& sounds() { return m_sounds; }
virtual ~SSndChannel() {}
virtual sounds_type& sounds() { return m_sounds; }
protected:
xr_vector<ref_sound> m_sounds;
};
Expand All @@ -114,16 +108,16 @@ class ENGINE_API CEnvAmbient
public:
const shared_str& name() { return m_load_section; }
const shared_str& get_ambients_config_filename() { return m_ambients_config_filename; }
INGAME_EDITOR_VIRTUAL void load(CInifile& ambients_config, CInifile& sound_channels_config,
virtual void load(CInifile& ambients_config, CInifile& sound_channels_config,
CInifile& effects_config, const shared_str& section);
SEffect* get_rnd_effect() { return effects().empty() ? 0 : effects()[Random.randI(effects().size())]; }
u32 get_rnd_effect_time() { return Random.randI(m_effect_period.x, m_effect_period.y); }
INGAME_EDITOR_VIRTUAL SEffect* create_effect(CInifile& config, LPCSTR id);
INGAME_EDITOR_VIRTUAL SSndChannel* create_sound_channel(CInifile& config, LPCSTR id);
INGAME_EDITOR_VIRTUAL ~CEnvAmbient();
virtual SEffect* create_effect(CInifile& config, LPCSTR id);
virtual SSndChannel* create_sound_channel(CInifile& config, LPCSTR id);
virtual ~CEnvAmbient();
void destroy();
INGAME_EDITOR_VIRTUAL EffectVec& effects() { return m_effects; }
INGAME_EDITOR_VIRTUAL SSndChannelVec& get_snd_channels() { return m_sound_channels; }
virtual EffectVec& effects() { return m_effects; }
virtual SSndChannelVec& get_snd_channels() { return m_sound_channels; }
};

class ENGINE_API CEnvDescriptor
Expand Down Expand Up @@ -216,7 +210,7 @@ class ENGINE_API CEnvDescriptorMixer : public CEnvDescriptor

public:
CEnvDescriptorMixer(shared_str const& identifier);
INGAME_EDITOR_VIRTUAL void lerp(
virtual void lerp(
CEnvironment* parent, CEnvDescriptor& A, CEnvDescriptor& B, float f, CEnvModifier& M, float m_power);
void clear();
void destroy();
Expand Down Expand Up @@ -302,17 +296,17 @@ class ENGINE_API CEnvironment
void SelectEnvs(float gt);

void UpdateAmbient();
INGAME_EDITOR_VIRTUAL CEnvAmbient* AppendEnvAmb(const shared_str& sect);
virtual CEnvAmbient* AppendEnvAmb(const shared_str& sect);

void Invalidate();

public:
CEnvironment();

INGAME_EDITOR_VIRTUAL ~CEnvironment();
virtual ~CEnvironment();

INGAME_EDITOR_VIRTUAL void load();
INGAME_EDITOR_VIRTUAL void unload();
virtual void load();
virtual void unload();

void mods_load();
void mods_unload();
Expand Down Expand Up @@ -348,9 +342,7 @@ class ENGINE_API CEnvironment
void ED_Reload();
float GetGameTime() { return fGameTime; }
#else // #ifdef _EDITOR
#ifdef INGAME_EDITOR
float GetGameTime() { return fGameTime; }
#endif // #ifdef INGAME_EDITOR

bool m_paused;
#endif // #ifdef _EDITOR
Expand All @@ -363,21 +355,21 @@ class ENGINE_API CEnvironment
CInifile* m_thunderbolts_config;

protected:
INGAME_EDITOR_VIRTUAL CEnvDescriptor* create_descriptor(shared_str const& identifier, CInifile* config);
INGAME_EDITOR_VIRTUAL void load_weathers();
INGAME_EDITOR_VIRTUAL void load_weather_effects();
INGAME_EDITOR_VIRTUAL void create_mixer();
virtual CEnvDescriptor* create_descriptor(shared_str const& identifier, CInifile* config);
virtual void load_weathers();
virtual void load_weather_effects();
virtual void create_mixer();
void destroy_mixer();

void load_level_specific_ambients();

public:
INGAME_EDITOR_VIRTUAL SThunderboltDesc* thunderbolt_description(CInifile& config, shared_str const& section);
INGAME_EDITOR_VIRTUAL SThunderboltCollection* thunderbolt_collection(
virtual SThunderboltDesc* thunderbolt_description(CInifile& config, shared_str const& section);
virtual SThunderboltCollection* thunderbolt_collection(
CInifile* pIni, CInifile* thunderbolts, LPCSTR section);
INGAME_EDITOR_VIRTUAL SThunderboltCollection* thunderbolt_collection(
virtual SThunderboltCollection* thunderbolt_collection(
xr_vector<SThunderboltCollection*>& collection, shared_str const& id);
INGAME_EDITOR_VIRTUAL CLensFlareDescriptor* add_flare(
virtual CLensFlareDescriptor* add_flare(
xr_vector<CLensFlareDescriptor*>& collection, shared_str const& id);

public:
Expand All @@ -391,8 +383,6 @@ class ENGINE_API CEnvironment
float p_fog_color;
};

#undef INGAME_EDITOR_VIRTUAL

ENGINE_API extern Flags32 psEnvFlags;
ENGINE_API extern float psVisDistance;

Expand Down
12 changes: 0 additions & 12 deletions src/xrEngine/IGame_Persistent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@
#include "CustomHUD.h"
#endif

#ifdef _EDITOR
bool g_dedicated_server = false;
#endif

#ifdef INGAME_EDITOR
#include "editor_environment_manager.hpp"
#endif // INGAME_EDITOR

ENGINE_API IGame_Persistent* g_pGamePersistent = nullptr;

Expand All @@ -41,16 +35,10 @@ IGame_Persistent::IGame_Persistent()

m_pMainMenu = nullptr;

#ifndef INGAME_EDITOR
#ifndef _EDITOR
pEnvironment = new CEnvironment();
#endif
#else // #ifdef INGAME_EDITOR
if (RDEVICE.editor())
pEnvironment = new editor::environment::manager();
else
pEnvironment = new CEnvironment();
#endif // #ifdef INGAME_EDITOR
}

IGame_Persistent::~IGame_Persistent()
Expand Down
12 changes: 1 addition & 11 deletions src/xrEngine/Xr_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ float stop_vibration_time = flt_max;
static bool g_exclusive = true;
static void on_error_dialog(bool before)
{
#ifdef INGAME_EDITOR
if (Device.editor())
return;
#endif // #ifdef INGAME_EDITOR
if (!pInput || !g_exclusive)
if (!pInput || !g_exclusive || Device.editor())
return;

if (before)
Expand Down Expand Up @@ -134,9 +130,7 @@ HRESULT CInput::CreateInputDevice(

// Set the cooperativity level to let DirectInput know how this device
// should interact with the system and with other DirectInput applications.
#ifdef INGAME_EDITOR
if (!Device.editor())
#endif // #ifdef INGAME_EDITOR
{
HRESULT _hr = (*device)->SetCooperativeLevel(RDEVICE.m_hWnd, dwFlags);
if (FAILED(_hr) && (_hr == E_NOTIMPL))
Expand Down Expand Up @@ -670,17 +664,13 @@ void CInput::unacquire()
void CInput::acquire(const bool& exclusive)
{
pKeyboard->SetCooperativeLevel(
#ifdef INGAME_EDITOR
Device.editor() ? Device.editor()->main_handle() :
#endif // #ifdef INGAME_EDITOR
RDEVICE.m_hWnd,
(exclusive ? DISCL_EXCLUSIVE : DISCL_NONEXCLUSIVE) | DISCL_FOREGROUND);
pKeyboard->Acquire();

pMouse->SetCooperativeLevel(
#ifdef INGAME_EDITOR
Device.editor() ? Device.editor()->main_handle() :
#endif // #ifdef INGAME_EDITOR
RDEVICE.m_hWnd,
(exclusive ? DISCL_EXCLUSIVE : DISCL_NONEXCLUSIVE) | DISCL_FOREGROUND | DISCL_NOWINKEY);
pMouse->Acquire();
Expand Down
Loading

0 comments on commit ccce5e7

Please sign in to comment.