Some bugfixes and added Map Editor tool.

--HG--
branch : dev-2.1
This commit is contained in:
Martín Lucas Golini
2018-01-28 04:55:26 -03:00
parent c55e86455d
commit 6edbf33ac6
12 changed files with 117 additions and 12 deletions
+1
View File
@@ -49,3 +49,4 @@ bin/libeepp.dylib
*.iml
.idea
eepp.kdev4
bin/eepp-MapEditor*
@@ -38,6 +38,8 @@ class EE_API MapEditor {
public:
typedef cb::Callback0<void> MapEditorCloseCb;
static MapEditor * New( UIWindow * AttatchTo = NULL, const MapEditorCloseCb& callback = MapEditorCloseCb() );
MapEditor( UIWindow * AttatchTo = NULL, const MapEditorCloseCb& callback = MapEditorCloseCb() );
~MapEditor();
+1 -1
View File
@@ -140,7 +140,7 @@ class tColor {
//! @return The color represented as an Uint32 ( as 0xRRGGBBAA for Little Endian )
Uint32 getValue() const {
return Value;
return BitOp::swapBE32( Value );
}
/** @brief Assign the RGBA colors, from each component. */
+6
View File
@@ -959,6 +959,12 @@ solution "eepp"
files { "src/tools/textureatlaseditor/*.cpp" }
build_link_configuration( "eepp-TextureAtlasEditor", true )
project "eepp-mapeditor"
set_kind()
language "C++"
files { "src/tools/mapeditor/*.cpp" }
build_link_configuration( "eepp-MapEditor", true )
if os.isfile("external_projects.lua") then
dofile("external_projects.lua")
end
+1
View File
@@ -6,6 +6,7 @@
../../src/eepp/window/backend/SFML/displaymanagersfml.cpp
../../src/eepp/window/backend/SFML/displaymanagersfml.hpp
../../src/eepp/window/displaymanager.cpp
../../src/tools/mapeditor/mapeditor.cpp
../../src/tools/textureatlaseditor/textureatlaseditor.cpp
../../include/eepp/graphics/arcdrawable.hpp
../../include/eepp/graphics/circledrawable.hpp
+5
View File
@@ -6,8 +6,11 @@
#include <eepp/system/filesystem.hpp>
#include <eepp/system/mutex.hpp>
#include <eepp/system/lock.hpp>
#include <eepp/window/engine.hpp>
using namespace EE::System;
using namespace EE::Window;
namespace EE {
@@ -90,6 +93,8 @@ void MemoryManager::showResults() {
EE::PrintDebugInLog = false;
}
Engine::destroySingleton();
eePRINTL("\n|--Memory Manager Report-------------------------------------|");
eePRINTL("|");
+1 -1
View File
@@ -319,7 +319,7 @@ bool TextureAtlasLoader::updateTextureAtlas() {
if ( NULL != tTextureRegion ) {
tSh->OffsetX = tTextureRegion->getOffset().x;
tSh->OffsetY = tTextureRegion->getOffset().x;
tSh->OffsetY = tTextureRegion->getOffset().y;
tSh->DestWidth = (Int32)tTextureRegion->getDestSize().x;
tSh->DestHeight = (Int32)tTextureRegion->getDestSize().y;
}
+1 -1
View File
@@ -128,7 +128,7 @@ RenderMode GameObject::getRenderModeFromFlags() {
}
BlendMode GameObject::getBlendModeFromFlags() {
return isBlendAdd() ? BlendAdd : BlendAlpha;
return isBlendAdd() ? BlendMode( BlendMode::DstColor, BlendMode::One ) : BlendAlpha;
}
MapLayer * GameObject::getLayer() const {
+9 -5
View File
@@ -32,10 +32,14 @@ bool GameObjectSprite::isType( const Uint32& type ) {
void GameObjectSprite::draw() {
if ( NULL != mSprite ) {
TextureRegion * TextureRegion = mSprite->getCurrentTextureRegion();
Sizef destSizeO = TextureRegion->getDestSize();
Sizei realSize = TextureRegion->getRealSize();
TextureRegion->setDestSize( Sizef( (Float)realSize.getWidth(), (Float)realSize.getHeight() ) );
TextureRegion * textureRegion = mSprite->getCurrentTextureRegion();
if ( NULL == textureRegion )
return;
Sizef destSizeO = textureRegion->getDestSize();
Sizei realSize = textureRegion->getRealSize();
textureRegion->setDestSize( Sizef( (Float)realSize.getWidth(), (Float)realSize.getHeight() ) );
mSprite->setRotation( getRotation() );
@@ -73,7 +77,7 @@ void GameObjectSprite::draw() {
mSprite->draw();
TextureRegion->setDestSize( destSizeO );
textureRegion->setDestSize( destSizeO );
}
}
+4
View File
@@ -37,6 +37,10 @@ static UITextView * createTextBox( const String& Text = "", UINode * Parent = NU
return Ctrl;
}
MapEditor *MapEditor::New(UIWindow * AttatchTo, const MapEditor::MapEditorCloseCb & callback) {
return eeNew( MapEditor, ( AttatchTo, callback ) );
}
MapEditor::MapEditor( UIWindow * AttatchTo, const MapEditorCloseCb& callback ) :
mUIWindow( AttatchTo ),
mTheme( UIThemeManager::instance()->getDefaultTheme() ),
+18 -4
View File
@@ -10,6 +10,7 @@
#include <eepp/maps/mapobjectlayer.hpp>
#include <eepp/system/packmanager.hpp>
#include <eepp/system/virtualfilesystem.hpp>
#include <eepp/graphics/renderer/opengl.hpp>
#include <eepp/graphics/renderer/renderer.hpp>
#include <eepp/graphics/primitives.hpp>
@@ -836,7 +837,15 @@ bool TileMap::loadFromStream( IOStream& IOS ) {
if ( NULL == TextureAtlasManager::instance()->getByName( sgname ) ) {
TextureAtlasLoader * tgl = eeNew( TextureAtlasLoader, () );
tgl->loadFromFile( Sys::getProcessPath() + TextureAtlases[i] );
if ( !VirtualFileSystem::instance()->fileExists( TextureAtlases[i] ) && !FileSystem::fileExists( TextureAtlases[i] ) ) {
std::string path( FileSystem::fileRemoveFileName( mPath ) );
if ( FileSystem::fileExists( path + TextureAtlases[i] ) || VirtualFileSystem::instance()->fileExists( path + TextureAtlases[i] ) ) {
TextureAtlases[i] = path + TextureAtlases[i];
}
}
tgl->loadFromFile( TextureAtlases[i] );
eeSAFE_DELETE( tgl );
}
@@ -1046,7 +1055,6 @@ bool TileMap::loadFromFile( const std::string& path ) {
Pack * tPack = PackManager::instance()->exists( tPath ) ;
if ( NULL != tPack ) {
mPath = tPath;
return loadFromPack( tPack, tPath );
}
}
@@ -1060,6 +1068,8 @@ bool TileMap::loadFromPack( Pack * Pack, const std::string& FilePackPath ) {
Pack->extractFileToMemory( FilePackPath, PData );
mPath = FilePackPath;
return loadFromMemory( reinterpret_cast<const char*> ( PData.data ), PData.size );
}
@@ -1120,6 +1130,10 @@ void TileMap::saveToStream( IOStream& IOS ) {
memset( tSG.Path, 0, MAP_TEXTUREATLAS_PATH_SIZE );
if ( !mPath.empty() && String::startsWith( TextureAtlases[i], FileSystem::fileRemoveFileName( mPath ) ) ) {
TextureAtlases[i] = TextureAtlases[i].substr( FileSystem::fileRemoveFileName( mPath ).size() );
}
String::strCopy( tSG.Path, TextureAtlases[i].c_str(), MAP_TEXTUREATLAS_PATH_SIZE );
IOS.write( (const char*)&tSG, sizeof(sMapTextureAtlas) );
@@ -1359,11 +1373,11 @@ void TileMap::saveToStream( IOStream& IOS ) {
void TileMap::saveToFile( const std::string& path ) {
if ( !FileSystem::isDirectory( path ) ) {
mPath = path;
IOStreamFile IOS( path, std::ios::out | std::ios::binary );
saveToStream( IOS );
mPath = path;
}
}
+68
View File
@@ -0,0 +1,68 @@
#include <eepp/ee.hpp>
EE::Window::Window * win = NULL;
UIMessageBox * MsgBox = NULL;
void mainLoop() {
win->getInput()->update();
if ( win->getInput()->isKeyUp( KEY_ESCAPE ) && NULL == MsgBox ) {
MsgBox = UIMessageBox::New( MSGBOX_OKCANCEL, "Do you really want to close the current map?\nAll changes will be lost." );
MsgBox->addEventListener( UIEvent::MsgBoxConfirmClick, cb::Make1<void, const UIEvent*>( []( const UIEvent * event ) { win->close(); } ) );
MsgBox->addEventListener( UIEvent::OnClose, cb::Make1<void, const UIEvent*>( []( const UIEvent * event ) { MsgBox = NULL; } ) );
MsgBox->setTitle( "Close Map?" );
MsgBox->center();
MsgBox->show();
}
UIManager::instance()->update();
if ( UIManager::instance()->getMainControl()->invalidated() ) {
win->clear();
UIManager::instance()->draw();
win->display();
} else {
Sys::sleep( Milliseconds(8) );
}
}
EE_MAIN_FUNC int main (int argc, char * argv []) {
Display * currentDisplay = Engine::instance()->getDisplayManager()->getDisplayIndex(0);
Float pixelDensity = PixelDensity::toFloat( currentDisplay->getPixelDensity() );
DisplayMode currentMode = currentDisplay->getCurrentMode();
Uint32 width = eemin( currentMode.Width, (Uint32)( 1280 * pixelDensity ) );
Uint32 height = eemin( currentMode.Height, (Uint32)( 720 * pixelDensity ) );
win = Engine::instance()->createWindow( WindowSettings( width, height, "eepp - Texture Atlas Editor", WindowStyle::Default, WindowBackend::Default, 32, "assets/icon/ee.png", pixelDensity ), ContextSettings( true, GLv_default, true, 24, 1, 0, false ) );
if ( win->isOpen() ) {
UIManager::instance()->init( UI_MANAGER_USE_DRAW_INVALIDATION );
{
std::string pd;
if ( PixelDensity::getPixelDensity() >= 1.5f ) pd = "1.5x";
else if ( PixelDensity::getPixelDensity() >= 2.f ) pd = "2x";
TextureAtlasLoader tgl( "assets/ui/uitheme" + pd + ".eta" );
UITheme * theme = UITheme::loadFromTextureAtlas( UIThemeDefault::New( "uitheme" + pd, "uitheme" + pd ), TextureAtlasManager::instance()->getByName( "uitheme" + pd ) );
FontTrueType * font = FontTrueType::New( "NotoSans-Regular", "assets/fonts/NotoSans-Regular.ttf" );
UIThemeManager::instance()->setDefaultEffectsEnabled( true )->setDefaultTheme( theme )->setDefaultFont( font )->add( theme );
}
MapEditor::New();
win->runMainLoop( &mainLoop );
}
Engine::destroySingleton();
MemoryManager::showResults();
return EXIT_SUCCESS;
}