Merge remote-tracking branch 'gg/development' into gtest-tests

This commit is contained in:
Daniel Buckmaster 2014-08-30 17:51:41 +10:00
commit 5a430af051
47 changed files with 674 additions and 66 deletions

View file

@ -1589,6 +1589,13 @@ DefineEngineFunction( displaySplashWindow, bool, (const char* path), ("art/gui/s
return Platform::displaySplashWindow(path);
}
DefineEngineFunction( closeSplashWindow, void, (),,
"Close our startup splash window.\n\n"
"@note This is currently only implemented on Windows.\n\n"
"@ingroup Platform" )
{
Platform::closeSplashWindow();
}
//-----------------------------------------------------------------------------
DefineEngineFunction( getWebDeployment, bool, (),,

View file

@ -52,6 +52,7 @@ public:
static const U32 getListIndex(){ return mListIndex; }
virtual void *getMemInstPtr() = 0;
virtual const void *getConstMemInstPtr() const = 0;
virtual const dsize_t getMemInstSize() const = 0;
#ifdef TORQUE_ENABLE_THREAD_STATIC_METRICS
@ -143,6 +144,7 @@ private:
public:
TorqueThreadStatic( T instanceVal ) : mInstance( instanceVal ) {}
virtual void *getMemInstPtr() { return &mInstance; }
virtual const void *getConstMemInstPtr() const { return &mInstance; }
// I am not sure these are needed, and I don't want to create confusing-to-debug code
#if 0
@ -181,7 +183,7 @@ public: \
_##name##TorqueThreadStatic() : TorqueThreadStatic<type>( initalvalue ) {} \
virtual const dsize_t getMemInstSize() const { return sizeof( type ); } \
type &_cast() { return *reinterpret_cast<type *>( getMemInstPtr() ); } \
const type &_const_cast() const { return *reinterpret_cast<const type *>( getMemInstPtr() ); } \
const type &_const_cast() const { return *reinterpret_cast<const type *>( getConstMemInstPtr() ); } \
}; \
static _##name##TorqueThreadStatic name##TorqueThreadStatic; \
static _TorqueThreadStaticReg _##name##TTSReg( reinterpret_cast<_TorqueThreadStatic *>( & name##TorqueThreadStatic ) )

View file

@ -732,6 +732,11 @@ void WaterObject::renderObject( ObjectRenderInst *ri, SceneRenderState *state, B
bool doQuery = ( !mPlaneReflector.mQueryPending && query && mReflectorDesc.useOcclusionQuery );
// We need to call this for avoid a DX9 or Nvidia bug.
// At some resollutions read from render target,
// break current occlusion query.
REFLECTMGR->getRefractTex();
if ( doQuery )
query->begin();

View file

@ -121,7 +121,8 @@ GuiCanvas::GuiCanvas(): GuiControl(),
mMiddleMouseLast(false),
mRightMouseLast(false),
mPlatformWindow(NULL),
mLastRenderMs(0)
mLastRenderMs(0),
mDisplayWindow(true)
{
setBounds(0, 0, 640, 480);
mAwake = true;
@ -176,6 +177,8 @@ void GuiCanvas::initPersistFields()
addGroup("Canvas Rendering");
addProtectedField( "numFences", TypeS32, Offset( mNumFences, GuiCanvas ), &setProtectedNumFences, &defaultProtectedGetFn, "The number of GFX fences to use." );
addField("displayWindow", TypeBool, Offset(mDisplayWindow, GuiCanvas), "Controls if the canvas window is rendered or not." );
endGroup("Canvas Rendering");
Parent::initPersistFields();
@ -252,6 +255,19 @@ bool GuiCanvas::onAdd()
// Make sure we're able to render.
newDevice->setAllowRender( true );
if(mDisplayWindow)
{
getPlatformWindow()->show();
WindowManager->setDisplayWindow(true);
getPlatformWindow()->setDisplayWindow(true);
}
else
{
getPlatformWindow()->hide();
WindowManager->setDisplayWindow(false);
getPlatformWindow()->setDisplayWindow(false);
}
// Propagate add to parents.
// CodeReview - if GuiCanvas fails to add for whatever reason, what happens to
// all the event registration above?
@ -2683,3 +2699,23 @@ ConsoleMethod( GuiCanvas, setVideoMode, void, 5, 8,
// Store the new mode into a pref.
Con::setVariable( "$pref::Video::mode", vm.toString() );
}
ConsoleMethod( GuiCanvas, showWindow, void, 2, 2, "" )
{
if (!object->getPlatformWindow())
return;
object->getPlatformWindow()->show();
WindowManager->setDisplayWindow(true);
object->getPlatformWindow()->setDisplayWindow(true);
}
ConsoleMethod( GuiCanvas, hideWindow, void, 2, 2, "" )
{
if (!object->getPlatformWindow())
return;
object->getPlatformWindow()->hide();
WindowManager->setDisplayWindow(false);
object->getPlatformWindow()->setDisplayWindow(false);
}

View file

@ -108,6 +108,8 @@ protected:
bool mClampTorqueCursor;
bool mAlwaysHandleMouseButtons;
bool mDisplayWindow;
/// @}
/// @name Mouse Input

View file

@ -55,7 +55,7 @@ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdL
HMODULE hGame = NULL;
std::wstring dllName = std::wstring();
// The file name is the same as this executable's name, plus a suffix.
const std::wstring dllSuffices[] = {L"", L" DLL"};
const std::wstring dllSuffices[] = {L" DLL", L""};
const unsigned int numSuffices = sizeof(dllSuffices) / sizeof(std::wstring);
for (unsigned int i = 0; i < numSuffices; i++)

View file

@ -338,6 +338,9 @@ namespace Platform
// display Splash Window
bool displaySplashWindow( String path );
// close Splash Window
bool closeSplashWindow();
void openFolder( const char* path );
// Open file at the OS level, according to registered file-types.

View file

@ -118,9 +118,6 @@ public:
static U8 getModifierKeys() {return smModifierKeys;}
static void setModifierKeys(U8 mod) {smModifierKeys = mod;}
static void attemptSwitchToKeyboardLayout( U32 layout );
#ifdef LOG_INPUT
static void log( const char* format, ... );
#endif

View file

@ -70,6 +70,11 @@ bool Platform::displaySplashWindow()
return false;
}
bool Platform::closeSplashWindow()
{
return false;
}
#pragma mark ---- File IO ----
//-----------------------------------------------------------------------------
bool dPathCopy(const char* source, const char* dest, bool nooverwrite)

View file

@ -33,8 +33,6 @@
#include <stdarg.h>
#endif
#include <sstream>
// Static class variables:
InputManager* Input::smManager;
bool Input::smActive;
@ -81,10 +79,6 @@ void Input::init()
destroy();
#ifdef TORQUE_DEFAULT_KEYBOARD_LAYOUT
attemptSwitchToKeyboardLayout( TORQUE_DEFAULT_KEYBOARD_LAYOUT );
#endif
#ifdef LOG_INPUT
struct tm* newTime;
time_t aclock;
@ -493,18 +487,6 @@ InputManager* Input::getManager()
return( smManager );
}
//------------------------------------------------------------------------------
void Input::attemptSwitchToKeyboardLayout( U32 layout )
{
const LANGID lang = MAKELANGID( layout, SUBLANG_DEFAULT );
std::wstringstream ss;
ss << std::hex << lang;
const wchar_t* hexLang = ss.str().c_str();
ActivateKeyboardLayout( LoadKeyboardLayout(
hexLang, KLF_ACTIVATE | KLF_REPLACELANG
), KLF_REORDER );
}
#ifdef LOG_INPUT
//------------------------------------------------------------------------------
void Input::log( const char* format, ... )

View file

@ -93,6 +93,7 @@ void Platform::openFile(const char *path) { }
// window
bool Platform::displaySplashWindow(String path) { return false; }
bool Platform::closeSplashWindow() { return false; }
// font
PlatformFont *createPlatformFont(const char *name, U32 size, U32 charset) { return NULL; }

View file

@ -458,12 +458,8 @@ bool ActionMap::createEventDescriptor(const char* pEventString, EventDescriptor*
}
// Now we need to map the key string to the proper KEY code from event.h
AssertFatal(
dStrlen( pObjectString ) > 0,
"Error, no key was specified!\n"
"Review file 'scripts/client/config.cs' and remove symbols"
" which is not latin. Or delete this file."
);
//
AssertFatal(dStrlen(pObjectString) != 0, "Error, no key was specified!");
if (dStrlen(pObjectString) == 1)
{

View file

@ -89,6 +89,10 @@ protected:
/// Offscreen Render
bool mOffscreenRender;
/// This is set as part of the canvas being shown, and flags that the windows should render as normal from now on.
// Basically a flag that lets the window manager know that we've handled the splash screen, and to operate as normal.
bool mDisplayWindow;
/// Protected constructor so that the win
PlatformWindow()
{
@ -104,6 +108,7 @@ protected:
mSuppressReset = false;
mOffscreenRender = false;
mDisplayWindow = false;
}
public:
@ -180,6 +185,8 @@ public:
/// This is called to poll the window as to it's idle state.
virtual bool getOffscreenRender() { return mOffscreenRender; };
/// Set whether this window is should display as normal
virtual void setDisplayWindow(bool val ) { mDisplayWindow = val; };
/// Set Focused State (Foreground)
///

View file

@ -133,6 +133,9 @@ public:
/// This method removes the curtain window.
virtual void raiseCurtain()=0;
/// This method indicates to created windows to show as normal.
virtual void setDisplayWindow(bool set){}
private:
/// Process command line arguments from StandardMainLoop. This is done to
/// allow web plugin functionality, where we are passed platform-specific

View file

@ -121,6 +121,13 @@ void CloseSplashWindow(HINSTANCE hinst)
}
bool Platform::closeSplashWindow()
{
CloseSplashWindow(GetModuleHandle(NULL));
return true;
}
bool Platform::displaySplashWindow( String path )
{
if(path.isEmpty())

View file

@ -153,7 +153,9 @@ void Win32Window::setVideoMode( const GFXVideoMode &mode )
{
SetWindowLong( getHWND(), GWL_STYLE, WS_POPUP);
SetWindowPos( getHWND(), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
ShowWindow(getHWND(), SW_SHOWNORMAL);
if(mDisplayWindow)
ShowWindow(getHWND(), SW_SHOWNORMAL);
// Clear the menu bar from the window for full screen
HMENU menu = GetMenu(getHWND());
@ -216,7 +218,9 @@ void Win32Window::setVideoMode( const GFXVideoMode &mode )
// We have to force Win32 to update the window frame and make the window
// visible and no longer topmost - this code might be possible to simplify.
SetWindowPos( getHWND(), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
ShowWindow( getHWND(), SW_SHOWNORMAL);
if(mDisplayWindow)
ShowWindow( getHWND(), SW_SHOWNORMAL);
}
mFullscreen = false;

View file

@ -54,6 +54,8 @@ Win32WindowManager::Win32WindowManager()
mOffscreenRender = false;
mDisplayWindow = false;
buildMonitorsList();
}
@ -263,11 +265,13 @@ PlatformWindow *Win32WindowManager::createWindow(GFXDevice *device, const GFXVid
// If we're not rendering offscreen, make sure our window is shown and drawn to.
if (!mOffscreenRender)
ShowWindow( w32w->mWindowHandle, SW_SHOWDEFAULT );
w32w->setDisplayWindow(mDisplayWindow);
// Close any splash screen we created
CloseSplashWindow(winState.appInstance);
if (!mOffscreenRender && mDisplayWindow)
{
ShowWindow( w32w->mWindowHandle, SW_SHOWDEFAULT );
CloseSplashWindow(winState.appInstance);
}
// Bind the window to the specified device.
if(device)

View file

@ -56,6 +56,10 @@ class Win32WindowManager : public PlatformWindowManager
// is intended for offscreen rendering
bool mOffscreenRender;
/// This is set as part of the canvas being shown, and flags that the windows should render as normal from now on.
// Basically a flag that lets the window manager know that we've handled the splash screen, and to operate as normal.
bool mDisplayWindow;
/// Internal structure used when enumerating monitors
struct MonitorInfo {
HMONITOR monitorHandle;
@ -117,6 +121,8 @@ public:
virtual void lowerCurtain();
virtual void raiseCurtain();
virtual void setDisplayWindow(bool set) { mDisplayWindow = set; }
};
#endif