mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-06-02 19:46:29 +03:00
Optimized the lighting system.
Fixed a couple of bugs on the ui. Fixed Mac OS X build.
This commit is contained in:
5
Makefile
5
Makefile
@@ -66,7 +66,12 @@ endif
|
||||
ifeq ($(BACKEND_SDL), yes)
|
||||
|
||||
ifeq ($(SDLVERSION), 1.3.0)
|
||||
ifeq ($(OS), darwin)
|
||||
SDL_BACKEND_LINK = -framework Cocoa -lSDL -lSDLmain
|
||||
else
|
||||
SDL_BACKEND_LINK = libs/$(OS)/libSDL.a
|
||||
endif
|
||||
|
||||
SDL_BACKEND_SRC = $(wildcard ./src/window/backend/SDL13/*.cpp)
|
||||
else
|
||||
ifeq ($(OS), darwin)
|
||||
|
||||
@@ -64,10 +64,19 @@ void cLightManager::UpdateByVertex() {
|
||||
eeAABB TileAABB( Pos.x, Pos.y, Pos.x + TileSize.x, Pos.y + TileSize.y );
|
||||
|
||||
if ( Intersect( TileAABB, Light->GetAABB() ) ) {
|
||||
mTileColors[x][y][0]->Assign( Light->ProcessVertex( Pos.x, Pos.y, *(mTileColors[x][y][0]), *(mTileColors[x][y][0]) ) );
|
||||
if ( y > 0 )
|
||||
mTileColors[x][y][0]->Assign( *mTileColors[x][y - 1][1] );
|
||||
else
|
||||
mTileColors[x][y][0]->Assign( Light->ProcessVertex( Pos.x, Pos.y, *(mTileColors[x][y][0]), *(mTileColors[x][y][0]) ) );
|
||||
|
||||
mTileColors[x][y][1]->Assign( Light->ProcessVertex( Pos.x, Pos.y + TileSize.Height(), *(mTileColors[x][y][1]), *(mTileColors[x][y][1]) ) );
|
||||
|
||||
mTileColors[x][y][2]->Assign( Light->ProcessVertex( Pos.x + TileSize.Width(), Pos.y + TileSize.Height(), *(mTileColors[x][y][2]), *(mTileColors[x][y][2]) ) );
|
||||
mTileColors[x][y][3]->Assign( Light->ProcessVertex( Pos.x + TileSize.Width(), Pos.y, *(mTileColors[x][y][3]), *(mTileColors[x][y][3]) ) );
|
||||
|
||||
if ( y > 0 )
|
||||
mTileColors[x][y][3]->Assign( *mTileColors[x][y - 1][2] );
|
||||
else
|
||||
mTileColors[x][y][3]->Assign( Light->ProcessVertex( Pos.x + TileSize.Width(), Pos.y, *(mTileColors[x][y][3]), *(mTileColors[x][y][3]) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,7 +261,27 @@ void cMap::GridDraw() {
|
||||
|
||||
ty = y * mTileSize.y;
|
||||
|
||||
mTileTex->Draw( tx, ty, 0, 1, TileTexCol );
|
||||
if ( LightsEnabled() ) {
|
||||
eeVector2i TPos( x, y );
|
||||
|
||||
if ( mLightManager->IsByVertex() ) {
|
||||
eeColorA TileTexCol0( *mLightManager->GetTileColor( TPos, 0 ) );
|
||||
eeColorA TileTexCol1( *mLightManager->GetTileColor( TPos, 1 ) );
|
||||
eeColorA TileTexCol2( *mLightManager->GetTileColor( TPos, 2 ) );
|
||||
eeColorA TileTexCol3( *mLightManager->GetTileColor( TPos, 3 ) );
|
||||
|
||||
TileTexCol0.Alpha = TileTexCol1.Alpha = TileTexCol2.Alpha = TileTexCol3.Alpha = mBackAlpha;
|
||||
|
||||
mTileTex->DrawEx( tx, ty, 0, 0, 0, 1, TileTexCol0, TileTexCol1, TileTexCol2, TileTexCol3 );
|
||||
} else {
|
||||
TileTexCol = *mLightManager->GetTileColor( TPos );
|
||||
TileTexCol.Alpha = mBackAlpha;
|
||||
|
||||
mTileTex->Draw( tx, ty, 0, 1, TileTexCol );
|
||||
}
|
||||
} else {
|
||||
mTileTex->Draw( tx, ty, 0, 1, TileTexCol );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ void cMapEditor::CreateWinMenu() {
|
||||
PU1->AddEventListener( cUIEvent::EventOnItemClicked, cb::Make1( this, &cMapEditor::FileMenuClick ) );
|
||||
WinMenu->AddMenuButton( "File", PU1 );
|
||||
|
||||
cUIPopUpMenu * PU3 = mTheme->CreatePopUpMenu();
|
||||
cUIPopUpMenu * PU3 = mTheme->CreatePopUpMenu( mUIContainer );
|
||||
mChkShowGrid = reinterpret_cast<cUIMenuCheckBox*>( PU3->GetItem( PU3->AddCheckBox( "Show Grid" ) ) );
|
||||
|
||||
mChkShowGrid->Active( true );
|
||||
@@ -95,6 +95,13 @@ void cMapEditor::CreateWinMenu() {
|
||||
|
||||
mChkShowBlocked = reinterpret_cast<cUIMenuCheckBox*>( PU3->GetItem( PU3->AddCheckBox( "Show Blocked" ) ) );
|
||||
|
||||
PU3->AddSeparator();
|
||||
mUIWindow->AddShortcut( KEY_KP_PLUS , KEYMOD_CTRL, reinterpret_cast<cUIPushButton*> ( PU3->GetItem( PU3->Add( "Zoom In", mTheme->GetIconByName( "zoom-in" ) ) ) ) );
|
||||
mUIWindow->AddShortcut( KEY_KP_MINUS, KEYMOD_CTRL, reinterpret_cast<cUIPushButton*> ( PU3->GetItem( PU3->Add( "Zoom Out", mTheme->GetIconByName( "zoom-out" ) ) ) ) );
|
||||
mUIWindow->AddShortcut( KEY_KP0 , KEYMOD_CTRL, reinterpret_cast<cUIPushButton*> ( PU3->GetItem( PU3->Add( "Normal Size", mTheme->GetIconByName( "zoom-original" ) ) ) ) );
|
||||
PU3->AddSeparator();
|
||||
|
||||
|
||||
PU3->AddEventListener( cUIEvent::EventOnItemClicked, cb::Make1( this, &cMapEditor::ViewMenuClick ) );
|
||||
WinMenu->AddMenuButton( "View", PU3 );
|
||||
|
||||
@@ -803,6 +810,66 @@ void cMapEditor::ViewMenuClick( const cUIEvent * Event ) {
|
||||
mUIMap->Map()->DrawTileOver( reinterpret_cast<cUIMenuCheckBox*> ( Event->Ctrl() )->Active() );
|
||||
} else if ( "Show Blocked" == txt ) {
|
||||
mUIMap->Map()->ShowBlocked( reinterpret_cast<cUIMenuCheckBox*> ( Event->Ctrl() )->Active() );
|
||||
} else if ( "Zoom In" == txt ) {
|
||||
ZoomIn();
|
||||
} else if ( "Zoom Out" == txt ) {
|
||||
ZoomOut();
|
||||
} else if ( "Normal Size" == txt ) {
|
||||
mUIMap->Map()->Scale( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
void cMapEditor::ZoomIn() {
|
||||
cMap * Map = mUIMap->Map();
|
||||
eeFloat S = mUIMap->Map()->Scale();
|
||||
|
||||
if ( S < 4 ) {
|
||||
if ( 0.0625f == S ) {
|
||||
Map->Scale( 0.125f );
|
||||
} else if ( 0.125f == S ) {
|
||||
Map->Scale( 0.25f );
|
||||
} else if ( 0.25f == S ) {
|
||||
Map->Scale( 0.5f );
|
||||
} else if ( 0.5f == S ) {
|
||||
Map->Scale( 0.75f );
|
||||
} else if ( 0.75f == S ) {
|
||||
Map->Scale( 1.0f );
|
||||
} else if ( 1.0f == S ) {
|
||||
Map->Scale( 1.5f );
|
||||
} else if ( 1.5f == S ) {
|
||||
Map->Scale( 2.0f );
|
||||
} else if ( 2.0f == S ) {
|
||||
Map->Scale( 3.0f );
|
||||
} else if ( 3.0f == S ) {
|
||||
Map->Scale( 4.0f );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cMapEditor::ZoomOut() {
|
||||
cMap * Map = mUIMap->Map();
|
||||
eeFloat S = mUIMap->Map()->Scale();
|
||||
|
||||
if ( S > 0.0625f ) {
|
||||
if ( 0.125f == S ) {
|
||||
Map->Scale( 0.0625f );
|
||||
} else if ( 0.25f == S ) {
|
||||
Map->Scale( 0.125f );
|
||||
} else if ( 0.5f == S ) {
|
||||
Map->Scale( 0.25f );
|
||||
} else if ( 0.75f == S ) {
|
||||
Map->Scale( 0.5f );
|
||||
} else if ( 1.0f == S ) {
|
||||
Map->Scale( 0.75f );
|
||||
} else if ( 1.5f == S ) {
|
||||
Map->Scale( 1.0f );
|
||||
} else if ( 2.0f == S ) {
|
||||
Map->Scale( 1.5f );
|
||||
} else if ( 3.0f == S ) {
|
||||
Map->Scale( 2.0f );
|
||||
} else if ( 4.0f == S ) {
|
||||
Map->Scale( 3.0f );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -196,6 +196,10 @@ class EE_API cMapEditor {
|
||||
void SetViewOptions();
|
||||
|
||||
cGameObject * GetCurrentGOOver();
|
||||
|
||||
void ZoomIn();
|
||||
|
||||
void ZoomOut();
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
@@ -158,16 +158,14 @@ void cUIMap::EditingLights( const bool& editing ) {
|
||||
|
||||
void cUIMap::MapDraw() {
|
||||
if ( mEditingLights && NULL != mSelLight ) {
|
||||
if ( Intersect( mMap->GetViewAreaAABB(), mSelLight->GetAABB() ) ) {
|
||||
cPrimitives P;
|
||||
P.SetColor( eeColorA( 255, 0, 0, (Uint8)mAlpha ) );
|
||||
cPrimitives P;
|
||||
P.SetColor( eeColorA( 255, 0, 0, (Uint8)mAlpha ) );
|
||||
|
||||
eeVector2f Pos( mSelLight->GetAABB().Left, mSelLight->GetAABB().Top );
|
||||
eeAABB AB( mSelLight->GetAABB() );
|
||||
eeSizef Size( AB.Size() );
|
||||
eeVector2f Pos( mSelLight->GetAABB().Left, mSelLight->GetAABB().Top );
|
||||
eeAABB AB( mSelLight->GetAABB() );
|
||||
eeSizef Size( AB.Size() );
|
||||
|
||||
P.DrawRectangle( Pos.x, Pos.y, Size.Width(), Size.Height(), 0, 1, EE_DRAW_LINE );
|
||||
}
|
||||
P.DrawRectangle( Pos.x, Pos.y, Size.Width(), Size.Height(), 0, 1, EE_DRAW_LINE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -365,11 +365,11 @@ eeVector3f cGL::ProjectCurrent( const eeVector3f& point ) {
|
||||
GLint viewPort[4];
|
||||
GetViewport( viewPort );
|
||||
|
||||
eeVector3f tv3;
|
||||
Vector3<GLfloat> tv3;
|
||||
|
||||
Project( point.x, point.y, point.z, projMat, modelMat, viewPort, &tv3.x, &tv3.y, &tv3.z );
|
||||
Project( (GLfloat)point.x, (GLfloat)point.y, (GLfloat)point.z, projMat, modelMat, viewPort, &tv3.x, &tv3.y, &tv3.z );
|
||||
|
||||
return tv3;
|
||||
return eeVector3f( tv3.x, tv3.y, tv3.z );
|
||||
}
|
||||
|
||||
eeVector3f cGL::UnProjectCurrent( const eeVector3f& point ) {
|
||||
@@ -382,11 +382,11 @@ eeVector3f cGL::UnProjectCurrent( const eeVector3f& point ) {
|
||||
GLint viewPort[4];
|
||||
GetViewport( viewPort );
|
||||
|
||||
eeVector3f tv3;
|
||||
Vector3<GLfloat> tv3;
|
||||
|
||||
UnProject( point.x, point.y, point.z, projMat, modelMat, viewPort, &tv3.x, &tv3.y, &tv3.z );
|
||||
UnProject( (GLfloat)point.x, (GLfloat)point.y, (GLfloat)point.z, projMat, modelMat, viewPort, &tv3.x, &tv3.y, &tv3.z );
|
||||
|
||||
return tv3;
|
||||
return eeVector3f( tv3.x, tv3.y, tv3.z );
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -1792,15 +1792,6 @@ void cEETest::End() {
|
||||
cEngine::DestroySingleton();
|
||||
}
|
||||
|
||||
#if EE_PLATFORM == EE_PLATFORM_MACOSX
|
||||
#ifdef EE_BACKEND_SDL_ACTIVE
|
||||
#include <SDL/SDL_main.h>
|
||||
#endif
|
||||
#ifdef EE_BACKEND_ALLEGRO_ACTIVE
|
||||
#include <allegro5/allegro.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int main (int argc, char * argv []) {
|
||||
cEETest * Test = eeNew( cEETest, () );
|
||||
|
||||
|
||||
@@ -329,7 +329,7 @@ Uint32 cUIMenu::OnMessage( const cUIMessage * Msg ) {
|
||||
switch ( Msg->Msg() ) {
|
||||
case cUIMessage::MsgMouseUp:
|
||||
{
|
||||
if ( Msg->Sender()->Parent() == this && Msg->Sender()->Parent()->Visible() && ( Msg->Flags() & EE_BUTTONS_LRM ) ) {
|
||||
if ( Msg->Sender()->Parent() == this && ( Msg->Flags() & EE_BUTTONS_LRM ) ) {
|
||||
cUIEvent ItemEvent( Msg->Sender(), cUIEvent::EventOnItemClicked );
|
||||
SendEvent( &ItemEvent );
|
||||
}
|
||||
|
||||
@@ -83,7 +83,8 @@ Uint32 cUIPopUpMenu::OnMessage( const cUIMessage * Msg ) {
|
||||
if ( !Msg->Sender()->IsType( UI_TYPE_MENUSUBMENU ) && ( Msg->Flags() & EE_BUTTONS_LRM ) ) {
|
||||
SendCommonEvent( cUIEvent::EventOnHideByClick );
|
||||
|
||||
cUIManager::instance()->MainControl()->SetFocus();
|
||||
if ( Visible() )
|
||||
cUIManager::instance()->MainControl()->SetFocus();
|
||||
|
||||
Hide();
|
||||
}
|
||||
|
||||
@@ -760,6 +760,7 @@ void cUIWindow::CheckShortcuts( const Uint32& KeyCode, const Uint32& Mod ) {
|
||||
KeyboardShortcut kb = (*it);
|
||||
|
||||
if ( KeyCode == kb.KeyCode && ( Mod & kb.Mod ) ) {
|
||||
cUIManager::instance()->SendMouseUp( kb.Button, eeVector2i(0,0), EE_BUTTON_LMASK );
|
||||
cUIManager::instance()->SendMouseClick( kb.Button, eeVector2i(0,0), EE_BUTTON_LMASK );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,9 +310,9 @@ std::vector< std::pair<unsigned int, unsigned int> > cWindowSDL::GetPossibleReso
|
||||
}
|
||||
|
||||
void cWindowSDL::SetGamma( eeFloat Red, eeFloat Green, eeFloat Blue ) {
|
||||
eeclamp( &Red , 0.1f, 10.0f );
|
||||
eeclamp( &Green , 0.1f, 10.0f );
|
||||
eeclamp( &Blue , 0.1f, 10.0f );
|
||||
eeclamp( &Red , (eeFloat)0.1f, (eeFloat)10.0f );
|
||||
eeclamp( &Green , (eeFloat)0.1f, (eeFloat)10.0f );
|
||||
eeclamp( &Blue , (eeFloat)0.1f, (eeFloat)10.0f );
|
||||
|
||||
Uint16 red_ramp[256];
|
||||
Uint16 green_ramp[256];
|
||||
|
||||
Reference in New Issue
Block a user