From 4ed326a8166258375b30cd8a68fd8bfcf9c0abe4 Mon Sep 17 00:00:00 2001 From: spartanj Date: Sun, 1 May 2011 03:46:30 -0300 Subject: [PATCH] Some minor changes. --- src/graphics/cshapegroupmanager.cpp | 147 ++++++++++++++++--- src/graphics/csprite.hpp | 4 +- src/test/eetest.cpp | 8 + src/ui/cuiwinmenu.cpp | 8 +- src/window/backend/SDL/cclipboardsdl.cpp | 2 +- src/window/backend/allegro5/cclipboardal.cpp | 41 +++++- src/window/backend/allegro5/cwindowal.cpp | 8 +- src/window/backend/allegro5/cwindowal.hpp | 4 + src/window/base.hpp | 1 + src/window/cinputtextbuffer.cpp | 2 +- 10 files changed, 196 insertions(+), 29 deletions(-) diff --git a/src/graphics/cshapegroupmanager.cpp b/src/graphics/cshapegroupmanager.cpp index b81b762c3..a3fa4bec0 100644 --- a/src/graphics/cshapegroupmanager.cpp +++ b/src/graphics/cshapegroupmanager.cpp @@ -52,39 +52,148 @@ std::vector cShapeGroupManager::GetShapesByPattern( const std::string& cShape * tShape = NULL; std::string realext = ""; eeInt c = 0; + eeInt t = 0; + eeInt i; + if ( extension.size() ) realext = "." + extension; - do { - if ( c < 100 ) - search = StrFormated( "%s%02d%s", name.c_str(), c, realext.c_str() ); - else if ( c < 1000 ) - search = StrFormated( "%s%03d%s", name.c_str(), c, realext.c_str() ); - else if ( c < 10000 ) - search = StrFormated( "%s%04d%s", name.c_str(), c, realext.c_str() ); - else - found = false; + // Test if name starts with 0 - 1 + for ( i = 0; i < 2; i++ ) { + search = StrFormated( "%s%d%s", name.c_str(), i, realext.c_str() ); + + if ( NULL == SearchInShapeGroup ) + tShape = GetShapeByName( search ); + else + tShape = SearchInShapeGroup->GetByName( search ); + + if ( NULL != tShape ) { + t = 1; + + break; + } + } + + // in case that name doesn't start with 0 - 1, we test with 00 - 01 + if ( 0 == t ) { + for ( i = 0; i < 2; i++ ) { + search = StrFormated( "%s%02d%s", name.c_str(), i, realext.c_str() ); - if ( found ) { if ( NULL == SearchInShapeGroup ) tShape = GetShapeByName( search ); else tShape = SearchInShapeGroup->GetByName( search ); if ( NULL != tShape ) { - Shapes.push_back( tShape ); + t = 2; - found = true; - } else { - if ( 0 == c ) // if didn't found "00", will search at least for "01" - found = true; - else - found = false; + break; } } - c++; - } while ( found ); + // in case that name doesn't start with 0 - 1, we test with 000 - 001 + if ( 0 == t ) { + for ( i = 0; i < 2; i++ ) { + search = StrFormated( "%s%03d%s", name.c_str(), i, realext.c_str() ); + + if ( NULL == SearchInShapeGroup ) + tShape = GetShapeByName( search ); + else + tShape = SearchInShapeGroup->GetByName( search ); + + if ( NULL != tShape ) { + t = 3; + + break; + } + } + + if ( 0 == t ) { + for ( i = 0; i < 2; i++ ) { + search = StrFormated( "%s%04d%s", name.c_str(), i, realext.c_str() ); + + if ( NULL == SearchInShapeGroup ) + tShape = GetShapeByName( search ); + else + tShape = SearchInShapeGroup->GetByName( search ); + + if ( NULL != tShape ) { + t = 4; + + break; + } + } + + if ( 0 == t ) { + for ( i = 0; i < 2; i++ ) { + search = StrFormated( "%s%05d%s", name.c_str(), i, realext.c_str() ); + + if ( NULL == SearchInShapeGroup ) + tShape = GetShapeByName( search ); + else + tShape = SearchInShapeGroup->GetByName( search ); + + if ( NULL != tShape ) { + t = 5; + + break; + } + } + + if ( 0 == t ) { + for ( i = 0; i < 2; i++ ) { + search = StrFormated( "%s%06d%s", name.c_str(), i, realext.c_str() ); + + if ( NULL == SearchInShapeGroup ) + tShape = GetShapeByName( search ); + else + tShape = SearchInShapeGroup->GetByName( search ); + + if ( NULL != tShape ) { + t = 6; + + break; + } + } + } + } + } + } + } + + if ( 0 != t ) { + do { + switch ( t ) { + case 1: search = StrFormated( "%s%d%s", name.c_str(), c, realext.c_str() ); break; + case 2: search = StrFormated( "%s%02d%s", name.c_str(), c, realext.c_str() ); break; + case 3: search = StrFormated( "%s%03d%s", name.c_str(), c, realext.c_str() ); break; + case 4: search = StrFormated( "%s%04d%s", name.c_str(), c, realext.c_str() ); break; + case 5: search = StrFormated( "%s%05d%s", name.c_str(), c, realext.c_str() ); break; + case 6: search = StrFormated( "%s%06d%s", name.c_str(), c, realext.c_str() ); break; + default: found = false; + } + + if ( found ) { + if ( NULL == SearchInShapeGroup ) + tShape = GetShapeByName( search ); + else + tShape = SearchInShapeGroup->GetByName( search ); + + if ( NULL != tShape ) { + Shapes.push_back( tShape ); + + found = true; + } else { + if ( 0 == c ) // if didn't found "00", will search at least for "01" + found = true; + else + found = false; + } + } + + c++; + } while ( found ); + } return Shapes; } diff --git a/src/graphics/csprite.hpp b/src/graphics/csprite.hpp index c4eb22dbd..1e0d3c062 100755 --- a/src/graphics/csprite.hpp +++ b/src/graphics/csprite.hpp @@ -357,14 +357,14 @@ class EE_API cSprite { EE_PRE_BLEND_FUNC mBlend; EE_RENDERTYPE mEffect; - SpriteCallback mCb; - eeUint mCurrentFrame; eeFloat mfCurrentFrame; eeUint mCurrentSubFrame; eeUint mSubFrames; eeUint mAnimTo; + SpriteCallback mCb; + class cFrame { public: std::vector Spr; diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index 537d23ad5..3407d1dc1 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -63,6 +63,14 @@ void cEETest::Init() { run = ( mWindow->Created() && PAK.IsOpen() ); if ( run ) { + std::cout << "Size of cTexture: " << sizeof(cTexture) << std::endl; + std::cout << "Size of cShape: " << sizeof(Graphics::cShape) << std::endl; + std::cout << "Size of cSprite: " << sizeof(cSprite) << std::endl; + std::cout << "Size of cUIControl: " << sizeof(cUIControl) << std::endl; + std::cout << "Size of cUIControlAnim: " << sizeof(cUIControlAnim) << std::endl; + std::cout << "Size of cUITextBox: " << sizeof(cUITextBox) << std::endl; + std::cout << "Size of cUIComplexControl: " << sizeof(cUIComplexControl) << std::endl; + SetScreen( 0 ); mWindow->Caption( "EE++ Test Application" ); diff --git a/src/ui/cuiwinmenu.cpp b/src/ui/cuiwinmenu.cpp index 558ab2011..7c487dec1 100644 --- a/src/ui/cuiwinmenu.cpp +++ b/src/ui/cuiwinmenu.cpp @@ -182,10 +182,12 @@ Uint32 cUIWinMenu::OnMessage( const cUIMessage * Msg ) { tpop->Show(); } } else { - mCurrentMenu = tpop; + if ( Msg->Flags() & EE_BUTTON_LMASK ) { + mCurrentMenu = tpop; - tbut->Select(); - tpop->Show(); + tbut->Select(); + tpop->Show(); + } } return 1; diff --git a/src/window/backend/SDL/cclipboardsdl.cpp b/src/window/backend/SDL/cclipboardsdl.cpp index d3d449a83..2ae5bc971 100644 --- a/src/window/backend/SDL/cclipboardsdl.cpp +++ b/src/window/backend/SDL/cclipboardsdl.cpp @@ -110,7 +110,7 @@ void cClipboardSDL::SetText( const std::string& Text ) { XSetSelectionOwner( display, XA_PRIMARY, window, CurrentTime ); } #elif EE_PLATFORM == EE_PLATFORM_WIN - + /** @TODO Implement */ #endif } diff --git a/src/window/backend/allegro5/cclipboardal.cpp b/src/window/backend/allegro5/cclipboardal.cpp index ba7e7dd2f..bea1bcc7b 100644 --- a/src/window/backend/allegro5/cclipboardal.cpp +++ b/src/window/backend/allegro5/cclipboardal.cpp @@ -1,6 +1,6 @@ #include "cclipboardal.hpp" #include "cwindowal.hpp" - +#include "../../base.hpp" #ifdef EE_BACKEND_ALLEGRO_ACTIVE namespace EE { namespace Window { namespace Backend { namespace Al { @@ -20,10 +20,47 @@ void cClipboardAl::SetText( const std::string& Text ) { } std::string cClipboardAl::GetText() { - return std::string(); + return GetWideText().ToUtf8(); } String cClipboardAl::GetWideText() { + #if defined( EE_X11_PLATFORM ) + /** Not sure if activate this, sometimes freeze the application because of the notification delay. */ + /** + cWindowAl * win = reinterpret_cast ( mWindow ); + eeWindowHandler mDisplay = win->GetWindowHandler(); + X11Window mWin = win->GetX11Window(); + + Atom clipboard = XInternAtom(mDisplay, "CLIPBOARD", True); + X11Window owner = XGetSelectionOwner(mDisplay, clipboard); + + if (owner != None) { + // Request the selection as XA_STRING + XConvertSelection(mDisplay, clipboard, XA_STRING, clipboard, mWin, CurrentTime); + XFlush (mDisplay); + XEvent e; + + // Wait until the selection owner sends us a SelectionNotify event, confirming it has sent us the selection + while (!XCheckTypedWindowEvent(mDisplay, mWin, SelectionNotify, &e)); + + if (e.xselection.property != None) { + Atom type; + int format; + unsigned long dummy, bytes, length; + unsigned char *data; + + XGetWindowProperty( mDisplay, mWin, clipboard, 0, 0, False, AnyPropertyType,&type, &format, &length, &bytes, &data); + + if (bytes) { + XGetWindowProperty(mDisplay, mWin, clipboard, 0, bytes, False, AnyPropertyType, &type, &format, &length, &dummy, &data); + } + + return String::FromUtf8((const char*)data); + } + } + */ + #endif + return String(); } diff --git a/src/window/backend/allegro5/cwindowal.cpp b/src/window/backend/allegro5/cwindowal.cpp index 1f4b28015..ef1fb7b0b 100644 --- a/src/window/backend/allegro5/cwindowal.cpp +++ b/src/window/backend/allegro5/cwindowal.cpp @@ -229,7 +229,7 @@ void cWindowAl::CreatePlatform() { #if defined( EE_X11_PLATFORM ) SetCurrent(); - mPlatform = eeNew( Platform::cX11Impl, ( this, GetWindowHandler(), ((ALLEGRO_DISPLAY_XGLX *)mDisplay)->window, ((ALLEGRO_DISPLAY_XGLX *)mDisplay)->window, al_display_lock, al_display_unlock ) ); + mPlatform = eeNew( Platform::cX11Impl, ( this, GetWindowHandler(), GetX11Window(), GetX11Window(), al_display_lock, al_display_unlock ) ); #elif EE_PLATFORM == EE_PLATFORM_WIN mPlatform = eeNew( Platform::cWinImpl, ( this, GetWindowHandler() ) ); #elif EE_PLATFORM == EE_PLATFORM_MACOSX @@ -239,6 +239,12 @@ void cWindowAl::CreatePlatform() { #endif } +#if defined( EE_X11_PLATFORM ) +X11Window cWindowAl::GetX11Window() { + return ((ALLEGRO_DISPLAY_XGLX *)mDisplay)->window; +} +#endif + void cWindowAl::ToggleFullscreen() { bool WasMaximized = mWindow.Maximized; diff --git a/src/window/backend/allegro5/cwindowal.hpp b/src/window/backend/allegro5/cwindowal.hpp index 9a1e3a750..129155b64 100644 --- a/src/window/backend/allegro5/cwindowal.hpp +++ b/src/window/backend/allegro5/cwindowal.hpp @@ -40,6 +40,10 @@ class EE_API cWindowAl : public cWindow { eeWindowHandler GetWindowHandler(); + #if defined( EE_X11_PLATFORM ) + X11Window GetX11Window(); + #endif + void SetDefaultContext(); ALLEGRO_DISPLAY * GetDisplay() const; diff --git a/src/window/base.hpp b/src/window/base.hpp index 0d3cf85ac..1f35a80e7 100644 --- a/src/window/base.hpp +++ b/src/window/base.hpp @@ -34,6 +34,7 @@ using namespace EE::Graphics; #include #include #include + #include typedef Atom eeScrapType; typedef Window X11Window; typedef Display * eeWindowHandler; diff --git a/src/window/cinputtextbuffer.cpp b/src/window/cinputtextbuffer.cpp index 838ebc628..d08ab4d33 100755 --- a/src/window/cinputtextbuffer.cpp +++ b/src/window/cinputtextbuffer.cpp @@ -91,7 +91,7 @@ void cInputTextBuffer::PromptToLeftFirstNoChar() { } void cInputTextBuffer::PromptToRightFirstNoChar() { - Uint32 s = mText.size(); + Int32 s = static_cast ( mText.size() ); if ( 0 == s ) return;