diff --git a/include/eepp/gaming/cmap.hpp b/include/eepp/gaming/cmap.hpp index c19192c3b..6e9366044 100644 --- a/include/eepp/gaming/cmap.hpp +++ b/include/eepp/gaming/cmap.hpp @@ -131,6 +131,10 @@ class EE_API cMap { const eeVector2i& GetMouseTilePos() const; + eeVector2i GetMouseTilePosCoords(); + + eeVector2i GetTileCoords( const eeVector2i& TilePos ); + const eeVector2i& GetRealMouseTilePos() const; const eeVector2i& GetMouseMapPos() const; diff --git a/include/eepp/gaming/mapeditor/cmapeditor.hpp b/include/eepp/gaming/mapeditor/cmapeditor.hpp index 9a1004bfb..304155d38 100644 --- a/include/eepp/gaming/mapeditor/cmapeditor.hpp +++ b/include/eepp/gaming/mapeditor/cmapeditor.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -49,6 +50,7 @@ class EE_API cMapEditor { Uint32 mCurGOFlags; cUIComplexControl * mSubTextureCont; cUIComplexControl * mLightCont; + cUIComplexControl * mObjectCont; cUIComplexControl * mSGCont; cUIComplexControl * mDICont; cUICheckBox * mChkDI; @@ -71,6 +73,8 @@ class EE_API cMapEditor { cUISpinBox * mLightRadius; cUICheckBox * mLightTypeChk; + std::list mObjContButton; + void OnRedChange( const cUIEvent * Event ); void OnGreenChange( const cUIEvent * Event ); @@ -79,6 +83,10 @@ class EE_API cMapEditor { void CreateLightContainer(); + void AddObjContButton( String text ); + + void CreateObjectsContainer(); + void CreateSubTextureContainer( Int32 Width ); void WindowClose( const cUIEvent * Event ); @@ -151,10 +159,6 @@ class EE_API cMapEditor { void OnMapClose( const cUIEvent * Event ); - void OnSubTextureContClick( const cUIEvent * Event ); - - void OnLightContClick( const cUIEvent * Event ); - void OnNewLight( const cUIEvent * Event ); void OnLightRadiusChangeVal( const cUIEvent * Event ); @@ -165,6 +169,8 @@ class EE_API cMapEditor { void OnLightRadiusChange( cLight * Light ); + void OnObjectModeSel( const cUIEvent * Event ); + void OnNewGOTypeAdded( std::string name, Uint32 hash ); void UpdateGfx(); diff --git a/include/eepp/ui/cuiskinstate.hpp b/include/eepp/ui/cuiskinstate.hpp index f9d829c47..c47330dd9 100644 --- a/include/eepp/ui/cuiskinstate.hpp +++ b/include/eepp/ui/cuiskinstate.hpp @@ -32,6 +32,8 @@ class EE_API cUISkinState { void Draw( const eeFloat& X, const eeFloat& Y, const eeFloat& Width, const eeFloat& Height, const Uint32& Alpha ); bool StateExists( const Uint32& State ); + + const Uint32& GetPrevState() const; protected: friend class cUIControl; diff --git a/include/eepp/ui/cuitheme.hpp b/include/eepp/ui/cuitheme.hpp index d5d34eb46..146668f72 100644 --- a/include/eepp/ui/cuitheme.hpp +++ b/include/eepp/ui/cuitheme.hpp @@ -21,6 +21,7 @@ class cUIListBox; class cUIPopUpMenu; class cUIProgressBar; class cUIPushButton; +class cUISelectButton; class cUIRadioButton; class cUIScrollBar; class cUISlider; @@ -135,6 +136,8 @@ class EE_API cUITheme : protected tResourceManager { virtual cUIPushButton * CreatePushButton( cUIControl * Parent = NULL, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS_CENTERED | UI_AUTO_SIZE, cSubTexture * Icon = NULL, Int32 IconHorizontalMargin = 0, bool IconAutoMargin = true ); + virtual cUISelectButton * CreateSelectButton( cUIControl * Parent = NULL, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS_CENTERED | UI_AUTO_SIZE, cSubTexture * Icon = NULL, Int32 IconHorizontalMargin = 0, bool IconAutoMargin = true ); + virtual cUIWinMenu * CreateWinMenu( cUIControl * Parent = NULL, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS, Uint32 MarginBetweenButtons = 0, Uint32 ButtonMargin = 4, Uint32 MenuHeight = 0, Uint32 FirstButtonMargin = 1 ); virtual cUIWindow * CreateWindow( cUIControl * Parent = NULL, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS_CENTERED, Uint32 WinFlags = UI_WIN_DEFAULT_FLAGS, eeSize MinWindowSize = eeSize(0,0), Uint8 BaseAlpha = 255 ); diff --git a/projects/linux/ee.creator.user b/projects/linux/ee.creator.user index daab0c178..e860b9041 100644 --- a/projects/linux/ee.creator.user +++ b/projects/linux/ee.creator.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget @@ -48,9 +48,9 @@ Desktop Desktop {388e5431-b31b-42b3-b9ad-9002d279d75d} - 8 + 0 0 - 4 + 0 /home/programming/eepp/make/linux diff --git a/src/eepp/gaming/cmap.cpp b/src/eepp/gaming/cmap.cpp index 08d83e46d..53246dfa1 100644 --- a/src/eepp/gaming/cmap.cpp +++ b/src/eepp/gaming/cmap.cpp @@ -455,6 +455,14 @@ eeVector2f cMap::GetMouseMapPosf() const { return eeVector2f( (eeFloat)mMouseMapPos.x, (eeFloat)mMouseMapPos.y ); } +eeVector2i cMap::GetMouseTilePosCoords() { + return GetTileCoords( GetMouseTilePos() ); +} + +eeVector2i cMap::GetTileCoords( const eeVector2i& TilePos ) { + return ( TilePos * mTileSize ); +} + void cMap::ViewSize( const eeSize& viewSize ) { mViewSize = viewSize; diff --git a/src/eepp/gaming/mapeditor/cmapeditor.cpp b/src/eepp/gaming/mapeditor/cmapeditor.cpp index c99569e4b..5c0331ade 100644 --- a/src/eepp/gaming/mapeditor/cmapeditor.cpp +++ b/src/eepp/gaming/mapeditor/cmapeditor.cpp @@ -166,6 +166,8 @@ void cMapEditor::CreateETGMenu() { mLightCont = eeNew( cUIComplexControl, ( CParams ) ); + mObjectCont = eeNew( cUIComplexControl, ( CParams ) ); + mTabWidget = mTheme->CreateTabWidget( mWinContainer, eeSize( Width + DistToBorder, mWinContainer->Size().Height() ), eeVector2i( ContPosX, 4 ), UI_HALIGN_CENTER | UI_VALIGN_BOTTOM | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP ); mTabWidget->AddEventListener( cUIEvent::EventOnTabSelected, cb::Make1( this, &cMapEditor::OnTabSelected ) ); CreateTabs(); @@ -173,6 +175,8 @@ void cMapEditor::CreateETGMenu() { CreateLightContainer(); CreateSubTextureContainer( Width ); + + CreateObjectsContainer(); } void cMapEditor::CreateTabs() { @@ -184,17 +188,22 @@ void cMapEditor::CreateTabs() { mTabWidget->Add( "Lights", mLightCont ); } } + + mTabWidget->Add( "Objects", mObjectCont ); } void cMapEditor::OnTabSelected( const cUIEvent * Event ) { if ( NULL != mUIMap ) { switch ( mTabWidget->GetSelectedTabIndex() ) { case 0: - mUIMap->EditingLights( false ); + mUIMap->EditingDisabled(); break; case 1: mUIMap->EditingLights( true ); break; + case 2: + mUIMap->EditingObjects( true ); + break; } } } @@ -360,6 +369,41 @@ void cMapEditor::CreateLightContainer() { mLightTypeChk->AddEventListener( cUIEvent::EventOnValueChange, cb::Make1( this, &cMapEditor::OnLightTypeChange ) ); } +void cMapEditor::AddObjContButton( String text ) { + static Int32 lastY = 0; + + cUISelectButton * Button = mTheme->CreateSelectButton( mObjectCont, eeSize( mObjectCont->Size().Width(), 22 ), eeVector2i( 0, lastY ) ); + + Button->Text( text ); + + Button->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cMapEditor::OnObjectModeSel ) ); + + lastY += Button->Size().Height() + 4; + + mObjContButton.push_back( Button ); +} + +void cMapEditor::CreateObjectsContainer() { + AddObjContButton( "Select Objects" ); + AddObjContButton( "Edit Polygons" ); + AddObjContButton( "Insert Object" ); + AddObjContButton( "Insert Polygon" ); + AddObjContButton( "Select Polyline" ); +} + +void cMapEditor::OnObjectModeSel( const cUIEvent * Event ) { + cUISelectButton * Button = static_cast( Event->Ctrl() ); + cUISelectButton * ButtonT = NULL; + + for ( std::list::iterator it = mObjContButton.begin(); it != mObjContButton.end(); it++ ) { + ButtonT = *it; + + ButtonT->Unselect(); + } + + Button->Select(); +} + void cMapEditor::CreateUIMap() { cUIComplexControl::CreateParams Params; Params.Parent( mWinContainer ); @@ -460,30 +504,6 @@ void cMapEditor::OnBlueChange( const cUIEvent * Event ) { } } -void cMapEditor::OnSubTextureContClick( const cUIEvent * Event ) { - const cUIEventMouse * MEvent = reinterpret_cast ( Event ); - - if ( MEvent->Flags() & EE_BUTTON_LMASK ) { - mUIMap->EditingLights( false ); - mSubTextureCont->Enabled( true ); - mSubTextureCont->Visible( true ); - mLightCont->Enabled( false ); - mLightCont->Visible( false ); - } -} - -void cMapEditor::OnLightContClick( const cUIEvent * Event ) { - const cUIEventMouse * MEvent = reinterpret_cast ( Event ); - - if ( MEvent->Flags() & EE_BUTTON_LMASK ) { - mUIMap->EditingLights( true ); - mSubTextureCont->Enabled( false ); - mSubTextureCont->Visible( false ); - mLightCont->Enabled( true ); - mLightCont->Visible( true ); - } -} - void cMapEditor::ChkClickDI( const cUIEvent * Event ) { if ( mChkDI->Active() ) { mSGCont->Enabled( false ); @@ -1110,6 +1130,10 @@ void cMapEditor::AddGameObject() { eeVector2i p( tMap->GetMouseMapPos() ); + if ( cUIManager::instance()->GetInput()->IsKeyDown( KEY_LCTRL ) ) { + p = tMap->GetMouseTilePosCoords(); + } + tObj->Pos( eeVector2f( p.x, p.y ) ); tLayer->AddGameObject( tObj ); } diff --git a/src/eepp/gaming/mapeditor/cuimap.cpp b/src/eepp/gaming/mapeditor/cuimap.cpp index a284e7ed3..b9f93f249 100644 --- a/src/eepp/gaming/mapeditor/cuimap.cpp +++ b/src/eepp/gaming/mapeditor/cuimap.cpp @@ -7,6 +7,8 @@ cUIMap::cUIMap( const cUIComplexControl::CreateParams& Params, cMap * Map ) : cUIComplexControl( Params ), mMap( Map ), mEditingLights( false ), + mEditingObjects( false ), + mEditingObjMode( INSERT_OBJECT ), mAddLight( NULL ), mSelLight( NULL ) { @@ -46,8 +48,8 @@ void cUIMap::Update() { if ( NULL != mMap ) { mMap->Update(); - if ( mEnabled && mVisible && mEditingLights ) { - if ( IsMouseOver() ) { + if ( mEnabled && mVisible ) { + if ( mEditingLights && IsMouseOver() ) { Uint32 Flags = cUIManager::instance()->GetInput()->ClickTrigger(); if ( NULL != mSelLight ) { @@ -146,16 +148,6 @@ void cUIMap::AddLight( cLight * Light ) { } } -void cUIMap::EditingLights( const bool& editing ) { - mEditingLights = editing; - - if ( editing && NULL != mMap->GetLightManager() && NULL != mAddLight ) { - mMap->GetLightManager()->RemoveLight( mAddLight ); - - mAddLight = NULL; - } -} - void cUIMap::MapDraw() { if ( mEditingLights && NULL != mSelLight ) { cPrimitives P; @@ -169,10 +161,49 @@ void cUIMap::MapDraw() { } } +void cUIMap::PrivEditingLights( const bool& editing ) { + mEditingLights = editing; + + if ( editing && NULL != mMap->GetLightManager() && NULL != mAddLight ) { + mMap->GetLightManager()->RemoveLight( mAddLight ); + + mAddLight = NULL; + } +} + +void cUIMap::EditingLights( const bool& editing ) { + PrivEditingLights( editing ); + + if ( editing ) { + PrivEditingObjects( false ); + } +} + const bool& cUIMap::EditingLights() { return mEditingLights; } +void cUIMap::PrivEditingObjects( const bool& editing ) { + mEditingObjects = false; +} + +void cUIMap::EditingObjects( const bool& editing ) { + PrivEditingObjects( editing ); + + if ( editing ) { + PrivEditingLights( false ); + } +} + +const bool& cUIMap::EditingObjects() { + return mEditingObjects; +} + +void cUIMap::EditingDisabled() { + EditingLights( false ); + EditingObjects( false ); +} + cLight * cUIMap::GetSelectedLight() { return mSelLight; } diff --git a/src/eepp/gaming/mapeditor/cuimap.hpp b/src/eepp/gaming/mapeditor/cuimap.hpp index 750ca13cd..2c3b6bc43 100644 --- a/src/eepp/gaming/mapeditor/cuimap.hpp +++ b/src/eepp/gaming/mapeditor/cuimap.hpp @@ -30,6 +30,12 @@ class EE_API cUIMap : public cUIComplexControl { const bool& EditingLights(); + void EditingObjects( const bool& editing ); + + void EditingDisabled(); + + const bool& EditingObjects(); + cLight * GetSelectedLight(); cLight * GetAddLight(); @@ -44,8 +50,21 @@ class EE_API cUIMap : public cUIComplexControl { protected: cMap * mMap; bool mEditingLights; + bool mEditingObjects; + + enum EDITING_OBJ_MODE { + SELECT_OBJECTS, + EDIT_POLYGONS, + INSERT_OBJECT, + INSERT_POLYGON, + INSERT_POLYLINE + }; + + Uint32 mEditingObjMode; + cLight * mAddLight; cLight * mSelLight; + LightSelectCb mLightSelCb; LightRadiusChangeCb mLightRadiusChangeCb; @@ -60,6 +79,10 @@ class EE_API cUIMap : public cUIComplexControl { void MapDraw(); void TryToSelectLight(); + + void PrivEditingLights( const bool& editing ); + + void PrivEditingObjects( const bool& editing ); }; }}} diff --git a/src/eepp/graphics/blendmode.cpp b/src/eepp/graphics/blendmode.cpp index 53abc3029..ffe947266 100644 --- a/src/eepp/graphics/blendmode.cpp +++ b/src/eepp/graphics/blendmode.cpp @@ -20,7 +20,10 @@ void BlendMode::SetMode( const EE_BLEND_MODE& blend, bool force ) { GLi->BlendFunc(GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA); break; case ALPHA_BLENDONE: - GLi->BlendFunc(GL_SRC_ALPHA , GL_ONE); + if ( GLi->IsExtension( EEGL_EXT_blend_func_separate ) ) + glBlendFuncSeparateEXT( GL_SRC_ALPHA, GL_ONE, GL_ONE, GL_ONE ); + else + GLi->BlendFunc(GL_SRC_ALPHA , GL_ONE); break; case ALPHA_BLENDTWO: GLi->BlendFunc(GL_SRC_ALPHA , GL_SRC_ALPHA); diff --git a/src/eepp/graphics/ctexturefontloader.cpp b/src/eepp/graphics/ctexturefontloader.cpp index 466ff8ae8..0fbd48b9c 100644 --- a/src/eepp/graphics/ctexturefontloader.cpp +++ b/src/eepp/graphics/ctexturefontloader.cpp @@ -112,7 +112,7 @@ void cTextureFontLoader::LoadFromTex() { } void cTextureFontLoader::LoadFont() { - mFont = eeNew( cTextureFont, ( mFontName ) ); + mFont = cTextureFont::New( mFontName ); if ( TEF_LT_PATH == mLoadType ) LoadFromPath(); diff --git a/src/eepp/ui/cuiskinstate.cpp b/src/eepp/ui/cuiskinstate.cpp index c799eceb7..1e8047253 100644 --- a/src/eepp/ui/cuiskinstate.cpp +++ b/src/eepp/ui/cuiskinstate.cpp @@ -42,6 +42,10 @@ void cUISkinState::SetPrevState() { } } +const Uint32& cUISkinState::GetPrevState() const { + return mLastState; +} + const Uint32& cUISkinState::GetState() const { return mCurState; } diff --git a/src/eepp/ui/cuitheme.cpp b/src/eepp/ui/cuitheme.cpp index ec628a535..68fb014f6 100644 --- a/src/eepp/ui/cuitheme.cpp +++ b/src/eepp/ui/cuitheme.cpp @@ -687,6 +687,25 @@ cUIPushButton * cUITheme::CreatePushButton( cUIControl * Parent, const eeSize& S return Ctrl; } +cUISelectButton * cUITheme::CreateSelectButton( cUIControl * Parent, const eeSize& Size, const eeVector2i& Pos, const Uint32& Flags, cSubTexture * Icon, Int32 IconHorizontalMargin, bool IconAutoMargin ) { + cUIPushButton::CreateParams ButtonParams; + ButtonParams.Parent( Parent ); + ButtonParams.PosSet( Pos ); + ButtonParams.SizeSet( Size ); + ButtonParams.Flags = Flags; + ButtonParams.Icon = Icon; + ButtonParams.IconHorizontalMargin = IconHorizontalMargin; + ButtonParams.IconAutoMargin = IconAutoMargin; + + if ( NULL != Icon ) + ButtonParams.SetIcon( Icon ); + + cUISelectButton * Ctrl = eeNew( cUISelectButton, ( ButtonParams ) ); + Ctrl->Visible( true ); + Ctrl->Enabled( true ); + return Ctrl; +} + cUIWinMenu * cUITheme::CreateWinMenu( cUIControl * Parent, const eeSize& Size, const eeVector2i& Pos, const Uint32& Flags, Uint32 MarginBetweenButtons, Uint32 ButtonMargin, Uint32 MenuHeight, Uint32 FirstButtonMargin ) { cUIWinMenu::CreateParams WinMenuParams; WinMenuParams.Parent( Parent ); diff --git a/src/examples/empty_window/empty_window.cpp b/src/examples/empty_window/empty_window.cpp index 4ebd80627..70d62aec2 100644 --- a/src/examples/empty_window/empty_window.cpp +++ b/src/examples/empty_window/empty_window.cpp @@ -48,5 +48,5 @@ EE_MAIN_FUNC int main (int argc, char * argv []) // If was compiled in debug mode it will print the memory manager report EE::MemoryManager::ShowResults(); - return 0; + return EXIT_SUCCESS; } diff --git a/src/examples/external_shader/external_shader.cpp b/src/examples/external_shader/external_shader.cpp index a3ba8057e..2dea82d39 100644 --- a/src/examples/external_shader/external_shader.cpp +++ b/src/examples/external_shader/external_shader.cpp @@ -273,5 +273,5 @@ EE_MAIN_FUNC int main (int argc, char * argv []) EE::MemoryManager::ShowResults(); - return 0; + return EXIT_SUCCESS; } diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index b81fd7ba2..58a2e4c43 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -1956,5 +1956,5 @@ EE_MAIN_FUNC int main (int argc, char * argv []) { EE::MemoryManager::ShowResults(); - return 0; + return EXIT_SUCCESS; }