|
From: <cn...@us...> - 2010-01-11 08:43:24
|
Revision: 650
http://hgengine.svn.sourceforge.net/hgengine/?rev=650&view=rev
Author: cnlohr
Date: 2010-01-11 08:43:17 +0000 (Mon, 11 Jan 2010)
Log Message:
-----------
add testing code in Mercury2.cpp for this variable thing
Modified Paths:
--------------
Mercury2/src/Mercury2.cpp
Mercury2/src/MercuryInput.cpp
Mercury2/src/MercuryMessageManager.cpp
Mercury2/src/MercuryMessageManager.h
Mercury2/src/MercuryValue.cpp
Mercury2/src/MercuryValue.h
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2010-01-11 08:01:21 UTC (rev 649)
+++ Mercury2/src/Mercury2.cpp 2010-01-11 08:43:17 UTC (rev 650)
@@ -199,8 +199,30 @@
// printf("Render wait %%%f\n", (RenderWaited/double(totalWaited))*100.0f);
return 0;
-}
+}
+
+
+
+
+
+///XXXXXXXX STUB CODE XXXXXXXXXXX THIS CODE SHOULD BE REMOVED AS SOON AS TESTING OF THE VARIABLE SYSTEM IS COMPLETE
+class TestMouse
+{
+public:
+ TestMouse()
+ {
+ MESSAGEMAN.GetValue( "Input.CursorDeltaX" )->AttachModifyDelegate( (ValueDelegate)&TestMouse::ChangeX, (MessageHandler*)this );
+ }
+
+ void ChangeX( MValue * v )
+ {
+ printf( "Changed: %f\n", v->GetFloat() );
+ }
+} TM;
+///XXXXXXX REMOVE THIS CODE BEFORE ANY RELEASE XXXXXXXXXXx
+
+
/* Copyright (c) 2008, Joshua Allen
* All rights reserved.
*
Modified: Mercury2/src/MercuryInput.cpp
===================================================================
--- Mercury2/src/MercuryInput.cpp 2010-01-11 08:01:21 UTC (rev 649)
+++ Mercury2/src/MercuryInput.cpp 2010-01-11 08:43:17 UTC (rev 650)
@@ -1,6 +1,9 @@
#include <MercuryInput.h>
#include <MercuryMessageManager.h>
+MVRefFloat GlobalMouseX_Set( "Input.CursorDeltaX" );
+MVRefFloat GlobalMouseY_Set( "Input.CursorDeltaY" );
+
MouseInput::MouseInput()
:MessageData(), dx(0), dy(0)
{
@@ -20,7 +23,10 @@
buttons.scrolldown = scrollDownButton;
mi->buttons = buttons;
currentButtonMasks = buttons;
-
+
+ GlobalMouseX_Set.Set( dx );
+ GlobalMouseY_Set.Set( dy );
+
POST_MESSAGE( INPUTEVENT_MOUSE, mi, 0 );
}
Modified: Mercury2/src/MercuryMessageManager.cpp
===================================================================
--- Mercury2/src/MercuryMessageManager.cpp 2010-01-11 08:01:21 UTC (rev 649)
+++ Mercury2/src/MercuryMessageManager.cpp 2010-01-11 08:43:17 UTC (rev 650)
@@ -147,6 +147,17 @@
return mh;
}
+MValue * MercuryMessageManager::GetValue( const MString & sVariableName )
+{
+ MValue * v = m_allValues.get( sVariableName );
+ if( !v )
+ {
+ v = &m_allValues[sVariableName];
+ v->SetReferences( 1 );
+ }
+ return v;
+}
+
MercuryMessageManager& MercuryMessageManager::GetInstance()
{
static MercuryMessageManager *instance = NULL;
Modified: Mercury2/src/MercuryMessageManager.h
===================================================================
--- Mercury2/src/MercuryMessageManager.h 2010-01-11 08:01:21 UTC (rev 649)
+++ Mercury2/src/MercuryMessageManager.h 2010-01-11 08:43:17 UTC (rev 650)
@@ -46,7 +46,9 @@
void RegisterForMessage(const MString& message, MessageHandler* ptr, MessageDelegate d = 0 );
void UnRegisterForMessage(const MString& message, MessageHandler* ptr);
-
+
+ MValue * GetValue( const MString & sVariableName );
+
static MercuryMessageManager& GetInstance();
private:
void FireOffMessage( const MessageHolder & message );
@@ -63,7 +65,8 @@
};
MHash< std::list< MessagePair > > m_messageRecipients;
-
+ MHash< MValue > m_allValues; //Careful - these cannot be deleted.
+
// MercuryMutex m_lock;
MSemaphore m_queueLock;
MSemaphore m_recipientLock;
Modified: Mercury2/src/MercuryValue.cpp
===================================================================
--- Mercury2/src/MercuryValue.cpp 2010-01-11 08:01:21 UTC (rev 649)
+++ Mercury2/src/MercuryValue.cpp 2010-01-11 08:43:17 UTC (rev 650)
@@ -43,6 +43,10 @@
+MValue::MValue( ) : m_References( 0 ), m_CurType( TYPE_UNDEF ), DLDelete( 0 ), DLModify( 0 )
+{
+ m_Data.v = 0;
+}
MValue::MValue( MVType t ) : m_References( 0 ), m_CurType( t ), DLDelete( 0 ), DLModify( 0 )
{
@@ -113,3 +117,43 @@
}
}
+MVRefBase::MVRefBase(const MString & sPath)
+{
+ mv = MESSAGEMAN.GetValue( sPath );
+ MSemaphoreLock( &mv->m_Sema );
+ mv->m_References++;
+}
+
+
+/****************************************************************************
+ * Copyright (C) 2010 by Charles Lohr *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+ ***************************************************************************/
+
Modified: Mercury2/src/MercuryValue.h
===================================================================
--- Mercury2/src/MercuryValue.h 2010-01-11 08:01:21 UTC (rev 649)
+++ Mercury2/src/MercuryValue.h 2010-01-11 08:43:17 UTC (rev 650)
@@ -42,7 +42,7 @@
class MValue
{
public:
-
+ MValue();
MValue( MVType t );
~MValue();
@@ -80,6 +80,15 @@
}
MVType GetType() { return m_CurType; }
+
+ void AttachModifyDelegate( DeletionNotifier NotifyFunction, MessageHandler * NotifyObject )
+ {
+ DelegateNotifierList * d = new DelegateNotifierList( NotifyFunction, NotifyObject );
+ d->Next = DLModify;
+ DLModify = d;
+ }
+
+ void SetReferences( short RefCount ) { m_References = RefCount; }
private:
//Conv functions are not thread protected - this is because the caller of these functions should be.
int ConvInt();
@@ -144,6 +153,9 @@
class MVRefInt : public MVRefBase
{
public:
+ MVRefInt( MValue * m ) : MVRefBase( m ) { }
+ MVRefInt( const MString & p ) : MVRefBase( p ) { }
+
int Get() { return mv->GetInt(); }
void Set( int iv ) { mv->SetInt( iv ); }
};
@@ -152,6 +164,9 @@
class MVRefFloat : public MVRefBase
{
public:
+ MVRefFloat( MValue * m ) : MVRefBase( m ) { }
+ MVRefFloat( const MString & p ) : MVRefBase( p ) { }
+
float Get() { return mv->GetFloat(); }
void Set( float fv ) { mv->SetFloat( fv ); }
};
@@ -160,6 +175,9 @@
class MVRefString : public MVRefBase
{
public:
+ MVRefString( MValue * m ) : MVRefBase( m ) { }
+ MVRefString( const MString & p ) : MVRefBase( p ) { }
+
const MString & Get() { return mv->GetString(); }
void Set( const MString & sv ) { mv->SetString( sv ); }
};
@@ -168,6 +186,9 @@
class MVRefPtr : public MVRefBase
{
public:
+ MVRefPtr( MValue * m ) : MVRefBase( m ) { }
+ MVRefPtr( const MString & p ) : MVRefBase( p ) { }
+
T * Get() {
return (T*)mv->GetPtr();
}
@@ -208,3 +229,4 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
***************************************************************************/
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|