mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-30 10:06:35 +03:00
eepp: Removed PlusCallback dependency.
ecode: Added the possibility to search and replace by replacing captures from Lua Pattern, for example, searching for: "function (%w+)%(%)" and replacing for "fn $1()" will replace the function declaration from "function (functionName)()" to "fn (functionName)()". The feature was used to remove the PlusCallback dependency =).
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include <eepp/thirdparty/PlusCallback/callback.hpp>
|
||||
|
||||
#include <eepp/config.hpp>
|
||||
|
||||
#include <eepp/core/core.hpp>
|
||||
|
||||
@@ -5,6 +5,5 @@
|
||||
#include <eepp/core/debug.hpp>
|
||||
#include <eepp/core/memorymanager.hpp>
|
||||
#include <eepp/core/string.hpp>
|
||||
#include <eepp/core/utf.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -40,7 +40,7 @@ enum class ParticleEffect : Uint32 {
|
||||
/** @brief Basic but powerfull Particle System */
|
||||
class EE_API ParticleSystem {
|
||||
public:
|
||||
typedef cb::Callback2<void, Particle*, ParticleSystem*> ParticleCallback;
|
||||
typedef std::function<void( Particle*, ParticleSystem* )> ParticleCallback;
|
||||
|
||||
ParticleSystem();
|
||||
|
||||
|
||||
1981
include/eepp/thirdparty/PlusCallback/callback.hpp
vendored
1981
include/eepp/thirdparty/PlusCallback/callback.hpp
vendored
File diff suppressed because it is too large
Load Diff
@@ -94,7 +94,7 @@ class EE_API TextureAtlasEditor {
|
||||
|
||||
void update();
|
||||
|
||||
UIWidget* createTextureAtlasTextureRegionEditor( std::string name );
|
||||
UIWidget* createTextureAtlasTextureRegionEditor();
|
||||
};
|
||||
|
||||
}}} // namespace EE::UI::Tools
|
||||
|
||||
@@ -165,6 +165,7 @@ newoption { trigger = "with-mold-linker", description = "Tries to use the mold l
|
||||
newoption { trigger = "with-debug-symbols", description = "Release builds are built with debug symbols." }
|
||||
newoption { trigger = "thread-sanitizer", description ="Compile with ThreadSanitizer." }
|
||||
newoption { trigger = "address-sanitizer", description = "Compile with AddressSanitizer." }
|
||||
newoption { trigger = "time-trace", description = "Compile with time trace." }
|
||||
newoption {
|
||||
trigger = "with-backend",
|
||||
description = "Select the backend to use for window and input handling.\n\t\t\tIf no backend is selected or if the selected is not installed the script will search for a backend present in the system, and will use it.",
|
||||
@@ -712,6 +713,10 @@ function parse_args()
|
||||
links { "asan" }
|
||||
end
|
||||
end
|
||||
|
||||
if _OPTIONS["time-trace"] then
|
||||
buildoptions { "-ftime-trace" }
|
||||
end
|
||||
end
|
||||
|
||||
function add_static_links()
|
||||
|
||||
@@ -13,6 +13,7 @@ newoption { trigger = "with-mold-linker", description = "Tries to use the mold l
|
||||
newoption { trigger = "with-debug-symbols", description = "Release builds are built with debug symbols." }
|
||||
newoption { trigger = "thread-sanitizer", description = "Compile with ThreadSanitizer." }
|
||||
newoption { trigger = "address-sanitizer", description = "Compile with AddressSanitizer." }
|
||||
newoption { trigger = "time-trace", description = "Compile with time tracing." }
|
||||
newoption {
|
||||
trigger = "with-backend",
|
||||
description = "Select the backend to use for window and input handling.\n\t\t\tIf no backend is selected or if the selected is not installed the script will search for a backend present in the system, and will use it.",
|
||||
@@ -454,6 +455,10 @@ function parse_args()
|
||||
links { "asan" }
|
||||
end
|
||||
end
|
||||
|
||||
if _OPTIONS["time-trace"] then
|
||||
buildoptions { "-ftime-trace" }
|
||||
end
|
||||
end
|
||||
|
||||
function add_static_links()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 12.0.1, 2024-02-10T17:28:39. -->
|
||||
<!-- Written by QtCreator 12.0.2, 2024-02-21T01:01:02. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
@@ -1173,7 +1173,6 @@
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
|
||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
|
||||
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">true</value>
|
||||
<value type="QString" key="RunConfiguration.Arguments">--css=/root/.config/ecode/style.css --language=de</value>
|
||||
<value type="int" key="RunConfiguration.UseCppDebugger">0</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
|
||||
<value type="int" key="RunConfiguration.UseQmlDebugger">1</value>
|
||||
|
||||
@@ -301,7 +301,6 @@
|
||||
../../include/eepp/thirdparty/chipmunk/cpSpace.h
|
||||
../../include/eepp/thirdparty/chipmunk/cpSpatialIndex.h
|
||||
../../include/eepp/thirdparty/chipmunk/cpVect.h
|
||||
../../include/eepp/thirdparty/PlusCallback/callback.hpp
|
||||
../../include/eepp/ui/models/model.hpp
|
||||
../../include/eepp/ui/abstract/uiabstracttableview.hpp
|
||||
../../include/eepp/ui/abstract/uiabstractview.hpp
|
||||
|
||||
@@ -307,7 +307,7 @@ void ParticleSystem::reset( Particle* P ) {
|
||||
break;
|
||||
}
|
||||
case ParticleEffect::Callback: {
|
||||
if ( mPC.IsSet() ) {
|
||||
if ( mPC ) {
|
||||
mPC( P, this );
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
namespace EE { namespace UI { namespace Tools {
|
||||
|
||||
UIWidget* TextureAtlasEditor::createTextureAtlasTextureRegionEditor( std::string ) {
|
||||
UIWidget* TextureAtlasEditor::createTextureAtlasTextureRegionEditor() {
|
||||
mTextureRegionEditor = TextureAtlasTextureRegionEditor::New( this );
|
||||
return mTextureRegionEditor;
|
||||
}
|
||||
@@ -113,9 +113,9 @@ TextureAtlasEditor::TextureAtlasEditor( UIWindow* attachTo, const TGEditorCloseC
|
||||
</LinearLayout>
|
||||
)xml";
|
||||
|
||||
UIWidgetCreator::addCustomWidgetCallback(
|
||||
"TextureAtlasTextureRegionEditor",
|
||||
cb::Make1( this, &TextureAtlasEditor::createTextureAtlasTextureRegionEditor ) );
|
||||
UIWidgetCreator::addCustomWidgetCallback( "TextureAtlasTextureRegionEditor", [this]( auto ) {
|
||||
return createTextureAtlasTextureRegionEditor();
|
||||
} );
|
||||
|
||||
if ( NULL != mUIContainer->getSceneNode()->asType<UISceneNode>()->getUIThemeManager() )
|
||||
mUIContainer->getSceneNode()->asType<UISceneNode>()->loadLayoutFromString( layout,
|
||||
@@ -125,56 +125,53 @@ TextureAtlasEditor::TextureAtlasEditor( UIWindow* attachTo, const TGEditorCloseC
|
||||
|
||||
mUIContainer->bind( "TextureRegionList", mTextureRegionList );
|
||||
mTextureRegionList->addEventListener(
|
||||
Event::OnItemSelected, cb::Make1( this, &TextureAtlasEditor::onTextureRegionChange ) );
|
||||
Event::OnItemSelected, [this]( auto event ) { onTextureRegionChange( event ); } );
|
||||
|
||||
mUIContainer->bind( "gridlayout", mTextureRegionGrid );
|
||||
|
||||
mUIContainer->bind( "offX", mSpinOffX );
|
||||
mSpinOffX->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &TextureAtlasEditor::onOffXChange ) );
|
||||
[this]( auto event ) { onOffXChange( event ); } );
|
||||
|
||||
mUIContainer->bind( "offY", mSpinOffY );
|
||||
mSpinOffY->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &TextureAtlasEditor::onOffYChange ) );
|
||||
[this]( auto event ) { onOffYChange( event ); } );
|
||||
|
||||
mUIContainer->bind( "destW", mSpinDestW );
|
||||
mSpinDestW->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &TextureAtlasEditor::onDestWChange ) );
|
||||
[this]( auto event ) { onDestWChange( event ); } );
|
||||
|
||||
mUIContainer->bind( "destH", mSpinDestH );
|
||||
mSpinDestH->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &TextureAtlasEditor::onDestHChange ) );
|
||||
[this]( auto event ) { onDestHChange( event ); } );
|
||||
|
||||
mUIContainer->bind( "textureFilter", mTextureFilterList );
|
||||
mTextureFilterList->addEventListener(
|
||||
Event::OnItemSelected, cb::Make1( this, &TextureAtlasEditor::onTextureFilterChange ) );
|
||||
Event::OnItemSelected, [this]( auto event ) { onTextureFilterChange( event ); } );
|
||||
|
||||
mUIContainer->find<UIPushButton>( "resetDest" )
|
||||
->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &TextureAtlasEditor::onResetDestSize ) );
|
||||
->addEventListener( Event::MouseClick, [this]( auto event ) { onResetDestSize( event ); } );
|
||||
|
||||
mUIContainer->find<UIPushButton>( "resetOff" )
|
||||
->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &TextureAtlasEditor::onResetOffset ) );
|
||||
->addEventListener( Event::MouseClick, [this]( auto event ) { onResetOffset( event ); } );
|
||||
|
||||
mUIContainer->find<UIPushButton>( "centerOff" )
|
||||
->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &TextureAtlasEditor::onCenterOffset ) );
|
||||
->addEventListener( Event::MouseClick, [this]( auto event ) { onCenterOffset( event ); } );
|
||||
|
||||
mUIContainer->find<UIPushButton>( "hbotOff" )
|
||||
->addEventListener( Event::MouseClick, cb::Make1( this, &TextureAtlasEditor::onHBOffset ) );
|
||||
->addEventListener( Event::MouseClick, [this]( auto event ) { onHBOffset( event ); } );
|
||||
|
||||
mUIContainer->find<UIPopUpMenu>( "fileMenu" )
|
||||
->addEventListener( Event::OnItemClicked,
|
||||
cb::Make1( this, &TextureAtlasEditor::fileMenuClick ) );
|
||||
[this]( auto event ) { fileMenuClick( event ); } );
|
||||
|
||||
if ( NULL != mUIWindow ) {
|
||||
mUIWindow->setTitle( "Texture Atlas Editor" );
|
||||
mUIWindow->addEventListener( Event::OnWindowClose,
|
||||
cb::Make1( this, &TextureAtlasEditor::windowClose ) );
|
||||
[this]( auto event ) { windowClose( event ); } );
|
||||
} else {
|
||||
mUIContainer->addEventListener( Event::OnClose,
|
||||
cb::Make1( this, &TextureAtlasEditor::windowClose ) );
|
||||
[this]( auto event ) { windowClose( event ); } );
|
||||
mUIContainer->find<UINode>( "texture_atlas_editor_root" )
|
||||
->setThemeSkin( mUIContainer->getSceneNode()
|
||||
->asType<UISceneNode>()
|
||||
@@ -291,14 +288,14 @@ void TextureAtlasEditor::fileMenuClick( const Event* Event ) {
|
||||
const String& txt = Event->getNode()->asType<UIMenuItem>()->getText();
|
||||
|
||||
if ( "New..." == txt ) {
|
||||
eeNew( TextureAtlasNew, ( cb::Make1( this, &TextureAtlasEditor::onTextureAtlasCreate ) ) );
|
||||
eeNew( TextureAtlasNew, ( [this]( auto event ) { onTextureAtlasCreate( event ); } ) );
|
||||
} else if ( "Open..." == txt ) {
|
||||
UIFileDialog* TGDialog = UIFileDialog::New(
|
||||
UIFileDialog::DefaultFlags, std::string( "*" ) + EE_TEXTURE_ATLAS_EXTENSION );
|
||||
TGDialog->setWindowFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL );
|
||||
TGDialog->setTitle( "Open Texture Atlas" );
|
||||
TGDialog->addEventListener( Event::OpenFile,
|
||||
cb::Make1( this, &TextureAtlasEditor::openTextureAtlas ) );
|
||||
[this]( auto event ) { openTextureAtlas( event ); } );
|
||||
TGDialog->center();
|
||||
TGDialog->show();
|
||||
} else if ( "Save" == txt ) {
|
||||
@@ -311,7 +308,7 @@ void TextureAtlasEditor::fileMenuClick( const Event* Event ) {
|
||||
"Do you really want to close the current "
|
||||
"texture atlas?\nAll changes will be lost." );
|
||||
MsgBox->addEventListener( Event::OnConfirm,
|
||||
cb::Make1( this, &TextureAtlasEditor::onTextureAtlasClose ) );
|
||||
[this]( auto event ) { onTextureAtlasClose( event ); } );
|
||||
MsgBox->setTitle( "Close Texture Atlas?" );
|
||||
MsgBox->center();
|
||||
MsgBox->show();
|
||||
@@ -350,7 +347,7 @@ void TextureAtlasEditor::onTextureAtlasCreate( TexturePacker* TexPacker ) {
|
||||
|
||||
mTextureAtlasLoader =
|
||||
TextureAtlasLoader::New( FPath, Engine::instance()->isThreaded(),
|
||||
cb::Make1( this, &TextureAtlasEditor::onTextureAtlasLoaded ) );
|
||||
[this]( auto event ) { onTextureAtlasLoaded( event ); } );
|
||||
}
|
||||
|
||||
void TextureAtlasEditor::updateWidgets() {
|
||||
@@ -400,7 +397,7 @@ void TextureAtlasEditor::fillTextureRegionList() {
|
||||
->setGravity( UI_HALIGN_CENTER | UI_VALIGN_CENTER )
|
||||
->setParent( mTextureRegionGrid )
|
||||
->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &TextureAtlasEditor::onTextureRegionChange ) );
|
||||
[this]( auto event ) { onTextureRegionChange( event ); } );
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -449,7 +446,7 @@ void TextureAtlasEditor::openTextureAtlas( const Event* Event ) {
|
||||
|
||||
mTextureAtlasLoader = TextureAtlasLoader::New(
|
||||
Event->getNode()->asType<UIFileDialog>()->getFullPath(), Engine::instance()->isThreaded(),
|
||||
cb::Make1( this, &TextureAtlasEditor::onTextureAtlasLoaded ) );
|
||||
[this]( auto event ) { onTextureAtlasLoaded( event ); } );
|
||||
}
|
||||
|
||||
void TextureAtlasEditor::onTextureAtlasLoaded( TextureAtlasLoader* textureAtlasLoader ) {
|
||||
|
||||
@@ -16,7 +16,7 @@ TextureAtlasNew::TextureAtlasNew( TGCreateCb NewTGCb ) : mUIWindow( NULL ), mNew
|
||||
UI_WIN_MODAL );
|
||||
|
||||
mUIWindow->addEventListener( Event::OnWindowClose,
|
||||
cb::Make1( this, &TextureAtlasNew::windowClose ) );
|
||||
[this] ( auto event ) { windowClose( event ); } );
|
||||
mUIWindow->setTitle( "New Texture Atlas" );
|
||||
|
||||
static const auto layout = R"xml(
|
||||
@@ -105,11 +105,11 @@ TextureAtlasNew::TextureAtlasNew( TGCreateCb NewTGCb ) : mUIWindow( NULL ), mNew
|
||||
mComboHeight->getListBox()->setSelected( "2048" );
|
||||
|
||||
mSetPathButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &TextureAtlasNew::onDialogFolderSelect ) );
|
||||
[this] ( auto event ) { onDialogFolderSelect( event ); } );
|
||||
mUIWindow->find<UIPushButton>( "okButton" )
|
||||
->addEventListener( Event::MouseClick, cb::Make1( this, &TextureAtlasNew::okClick ) );
|
||||
->addEventListener( Event::MouseClick, [this] ( auto event ) { okClick( event ); } );
|
||||
mUIWindow->find<UIPushButton>( "cancelButton" )
|
||||
->addEventListener( Event::MouseClick, cb::Make1( this, &TextureAtlasNew::cancelClick ) );
|
||||
->addEventListener( Event::MouseClick, [this] ( auto event ) { cancelClick( event ); } );
|
||||
|
||||
container->addEventListener( Event::OnLayoutUpdate, [this]( const Event* event ) {
|
||||
mUIWindow->setMinWindowSize( event->getNode()->getSize() );
|
||||
@@ -133,7 +133,7 @@ void TextureAtlasNew::okClick( const Event* event ) {
|
||||
TGDialog->setWindowFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL );
|
||||
TGDialog->setTitle( "Save Texture Atlas" );
|
||||
TGDialog->addEventListener( Event::SaveFile,
|
||||
cb::Make1( this, &TextureAtlasNew::textureAtlasSave ) );
|
||||
[this] ( auto event ) { textureAtlasSave( event ); } );
|
||||
TGDialog->center();
|
||||
TGDialog->show();
|
||||
}
|
||||
@@ -212,7 +212,7 @@ void TextureAtlasNew::onDialogFolderSelect( const Event* event ) {
|
||||
TGDialog->setWindowFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL );
|
||||
TGDialog->setTitle( "Create Texture Atlas ( Select Folder Containing Textures )" );
|
||||
TGDialog->addEventListener( Event::OpenFile,
|
||||
cb::Make1( this, &TextureAtlasNew::onSelectFolder ) );
|
||||
[this] ( auto event ) { onSelectFolder( event ); } );
|
||||
TGDialog->center();
|
||||
TGDialog->show();
|
||||
}
|
||||
|
||||
@@ -248,10 +248,10 @@ UIColorPicker::UIColorPicker( UIWindow* attachTo, const UIColorPicker::ColorPick
|
||||
if ( NULL != mUIWindow ) {
|
||||
mUIWindow->setTitle( "Color Picker" );
|
||||
mUIWindow->addEventListener( Event::OnWindowClose,
|
||||
cb::Make1( this, &UIColorPicker::windowClose ) );
|
||||
[this] ( auto event ) { windowClose( event ); } );
|
||||
} else {
|
||||
mUIContainer->addEventListener( Event::OnClose,
|
||||
cb::Make1( this, &UIColorPicker::windowClose ) );
|
||||
[this] ( auto event ) { windowClose( event ); } );
|
||||
}
|
||||
|
||||
if ( NULL != mUIWindow && mUIWindow->isModal() ) {
|
||||
|
||||
@@ -38,15 +38,15 @@ UIDropDownList::UIDropDownList( const std::string& tag ) :
|
||||
mListBox->setParent( this );
|
||||
|
||||
mListBox->addEventListener( Event::OnWidgetFocusLoss,
|
||||
cb::Make1( this, &UIDropDownList::onListBoxFocusLoss ) );
|
||||
[this] ( auto event ) { onListBoxFocusLoss( event ); } );
|
||||
mListBox->addEventListener( Event::OnItemSelected,
|
||||
cb::Make1( this, &UIDropDownList::onItemSelected ) );
|
||||
[this] ( auto event ) { onItemSelected( event ); } );
|
||||
mListBox->addEventListener( Event::OnItemClicked,
|
||||
cb::Make1( this, &UIDropDownList::onItemClicked ) );
|
||||
[this] ( auto event ) { onItemClicked( event ); } );
|
||||
mListBox->addEventListener( Event::OnItemKeyDown,
|
||||
cb::Make1( this, &UIDropDownList::onItemKeyDown ) );
|
||||
mListBox->addEventListener( Event::KeyDown, cb::Make1( this, &UIDropDownList::onItemKeyDown ) );
|
||||
mListBox->addEventListener( Event::OnClear, cb::Make1( this, &UIDropDownList::onWidgetClear ) );
|
||||
[this] ( auto event ) { onItemKeyDown( event ); } );
|
||||
mListBox->addEventListener( Event::KeyDown, [this] ( auto event ) { onItemKeyDown( event ); } );
|
||||
mListBox->addEventListener( Event::OnClear, [this] ( auto event ) { onWidgetClear( event ); } );
|
||||
mListBox->addEventListener( Event::OnClose, [this]( const Event* ) { mListBox = nullptr; } );
|
||||
mListBox->addEventListener( Event::OnSelectionChanged, [this]( auto ) {
|
||||
if ( !mListBox->hasSelection() )
|
||||
|
||||
@@ -80,7 +80,7 @@ UIFileDialog::UIFileDialog( Uint32 dialogFlags, const std::string& defaultFilePa
|
||||
->setLayoutSizePolicy( SizePolicy::WrapContent, SizePolicy::WrapContent )
|
||||
->setLayoutWeight( 1 )
|
||||
->setParent( hLayout );
|
||||
mPath->addEventListener( Event::OnPressEnter, cb::Make1( this, &UIFileDialog::onPressEnter ) );
|
||||
mPath->addEventListener( Event::OnPressEnter, [this] ( auto event ) { onPressEnter( event ); } );
|
||||
|
||||
mButtonUp = UIPushButton::New();
|
||||
mButtonUp->setText( i18n( "uifiledialog_go_up", "Up" ) )
|
||||
@@ -198,7 +198,7 @@ UIFileDialog::UIFileDialog( Uint32 dialogFlags, const std::string& defaultFilePa
|
||||
->setParent( hLayout );
|
||||
mFile->setLayoutMargin( Rectf( 0, 0, 4, 0 ) );
|
||||
mFile->addEventListener( Event::OnPressEnter,
|
||||
cb::Make1( this, &UIFileDialog::onPressFileEnter ) );
|
||||
[this] ( auto event ) { onPressFileEnter( event ); } );
|
||||
|
||||
mButtonOpen = UIPushButton::New();
|
||||
mButtonOpen
|
||||
|
||||
@@ -59,7 +59,7 @@ UIListBox::UIListBox( const std::string& tag ) :
|
||||
mVScrollBar->setEnabled( false )->setVisible( false );
|
||||
mVScrollBar->addEventListener( Event::OnSizeChange, cb );
|
||||
mVScrollBar->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &UIListBox::onScrollValueChange ) );
|
||||
[this] ( auto event ) { onScrollValueChange( event ); } );
|
||||
|
||||
mHScrollBar = UIScrollBar::NewHorizontal();
|
||||
mHScrollBar->setParent( this );
|
||||
@@ -68,7 +68,7 @@ UIListBox::UIListBox( const std::string& tag ) :
|
||||
mHScrollBar->setEnabled( false )->setVisible( false );
|
||||
mHScrollBar->addEventListener( Event::OnSizeChange, cb );
|
||||
mHScrollBar->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &UIListBox::onHScrollValueChange ) );
|
||||
[this] ( auto event ) { onHScrollValueChange( event ); } );
|
||||
|
||||
mDummyItem = createListBoxItem( "" );
|
||||
mDummyItem->setSize( 0, 0 );
|
||||
|
||||
@@ -19,9 +19,9 @@ UIScrollableWidget::UIScrollableWidget( const std::string& tag ) :
|
||||
mHScroll->setParent( this );
|
||||
|
||||
mVScroll->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &UIScrollableWidget::onValueChangeCb ) );
|
||||
[this] ( auto event ) { onValueChangeCb( event ); } );
|
||||
mHScroll->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &UIScrollableWidget::onValueChangeCb ) );
|
||||
[this] ( auto event ) { onValueChangeCb( event ); } );
|
||||
|
||||
applyDefaultTheme();
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ UIScrollBar::UIScrollBar( const std::string& tag, const UIOrientation& orientati
|
||||
mSlider->setAllowHalfSliderOut( false );
|
||||
mSlider->setExpandBackground( false );
|
||||
mSlider->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &UIScrollBar::onValueChangeCb ) );
|
||||
[this] ( auto event ) { onValueChangeCb( event ); } );
|
||||
if ( orientation == UIOrientation::Vertical ) {
|
||||
mSlider->getSliderButton()->setElementTag( mTag + "::vbutton" );
|
||||
mSlider->getBackSlider()->setElementTag( mTag + "::vback" );
|
||||
|
||||
@@ -30,9 +30,9 @@ UIScrollView::UIScrollView() :
|
||||
mContainer->enableReportSizeChangeToChilds();
|
||||
|
||||
mVScroll->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &UIScrollView::onValueChangeCb ) );
|
||||
[this] ( auto event ) { onValueChangeCb( event ); } );
|
||||
mHScroll->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &UIScrollView::onValueChangeCb ) );
|
||||
[this] ( auto event ) { onValueChangeCb( event ); } );
|
||||
|
||||
applyDefaultTheme();
|
||||
}
|
||||
@@ -76,9 +76,9 @@ void UIScrollView::onChildCountChange( Node* child, const bool& removed ) {
|
||||
mScrollView = child;
|
||||
mScrollView->setParent( mContainer );
|
||||
mSizeChangeCb = mScrollView->addEventListener(
|
||||
Event::OnSizeChange, cb::Make1( this, &UIScrollView::onScrollViewSizeChange ) );
|
||||
Event::OnSizeChange, [this] ( auto event ) { onScrollViewSizeChange( event ); } );
|
||||
mPosChangeCb = mScrollView->addEventListener(
|
||||
Event::OnPositionChange, cb::Make1( this, &UIScrollView::onScrollViewPositionChange ) );
|
||||
Event::OnPositionChange, [this] ( auto event ) { onScrollViewPositionChange( event ); } );
|
||||
|
||||
containerUpdate();
|
||||
}
|
||||
|
||||
@@ -58,9 +58,9 @@ UIWidgetTable::UIWidgetTable() :
|
||||
mVScrollBar->setEnabled( ScrollBarMode::AlwaysOn == mVScrollMode );
|
||||
|
||||
mVScrollBar->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &UIWidgetTable::onScrollValueChange ) );
|
||||
[this] ( auto event ) { onScrollValueChange( event ); } );
|
||||
mHScrollBar->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &UIWidgetTable::onScrollValueChange ) );
|
||||
[this] ( auto event ) { onScrollValueChange( event ); } );
|
||||
|
||||
mVScrollBar->addEventListener( Event::OnSizeChange, cb );
|
||||
mHScrollBar->addEventListener( Event::OnSizeChange, cb );
|
||||
|
||||
@@ -84,7 +84,7 @@ UIWindow::UIWindow( UIWindow::WindowBaseContainerType type, const StyleConfig& w
|
||||
mContainer->setClipType( ClipType::ContentBox );
|
||||
mContainer->enableReportSizeChangeToChilds();
|
||||
mContainer->addEventListener( Event::OnPositionChange,
|
||||
cb::Make1( this, &UIWindow::onContainerPositionChange ) );
|
||||
[this] ( auto event ) { onContainerPositionChange( event ); } );
|
||||
|
||||
updateWinFlags();
|
||||
|
||||
|
||||
@@ -73,11 +73,11 @@ MapEditor::MapEditor( UIWindow* AttatchTo, const MapEditorCloseCb& callback ) :
|
||||
mUIContainer = mUIWindow->getContainer();
|
||||
mUIWindow->setTitle( "Map Editor" );
|
||||
mUIWindow->addEventListener( Event::OnWindowClose,
|
||||
cb::Make1( this, &MapEditor::windowClose ) );
|
||||
[this]( auto event ) { windowClose( event ); } );
|
||||
} else {
|
||||
mUIContainer = SceneManager::instance()->getUISceneNode();
|
||||
mUIContainer->addEventListener( Event::OnClose,
|
||||
cb::Make1( this, &MapEditor::windowClose ) );
|
||||
[this]( auto event ) { windowClose( event ); } );
|
||||
}
|
||||
|
||||
createME();
|
||||
@@ -139,7 +139,7 @@ void MapEditor::createMenuBar() {
|
||||
PU1->add( "Quit",
|
||||
PU1->getUISceneNode()->findIconDrawable( "quit", PixelDensity::dpToPxI( 16 ) ) );
|
||||
|
||||
PU1->addEventListener( Event::OnItemClicked, cb::Make1( this, &MapEditor::fileMenuClick ) );
|
||||
PU1->addEventListener( Event::OnItemClicked, [this]( auto event ) { fileMenuClick( event ); } );
|
||||
MenuBar->addMenuButton( "File", PU1 );
|
||||
|
||||
UIPopUpMenu* PU3 = UIPopUpMenu::New();
|
||||
@@ -166,7 +166,7 @@ void MapEditor::createMenuBar() {
|
||||
|
||||
PU3->addSeparator();
|
||||
|
||||
PU3->addEventListener( Event::OnItemClicked, cb::Make1( this, &MapEditor::viewMenuClick ) );
|
||||
PU3->addEventListener( Event::OnItemClicked, [this]( auto event ) { viewMenuClick( event ); } );
|
||||
MenuBar->addMenuButton( "View", PU3 );
|
||||
|
||||
UIPopUpMenu* PU4 = UIPopUpMenu::New();
|
||||
@@ -174,7 +174,7 @@ void MapEditor::createMenuBar() {
|
||||
PU4->add( "Properties..." );
|
||||
PU4->add( "Resize..." );
|
||||
|
||||
PU4->addEventListener( Event::OnItemClicked, cb::Make1( this, &MapEditor::mapMenuClick ) );
|
||||
PU4->addEventListener( Event::OnItemClicked, [this]( auto event ) { mapMenuClick( event ); } );
|
||||
MenuBar->addMenuButton( "Map", PU4 );
|
||||
|
||||
UIPopUpMenu* PU5 = UIPopUpMenu::New();
|
||||
@@ -196,7 +196,8 @@ void MapEditor::createMenuBar() {
|
||||
|
||||
mLayerChkVisible = PU5->addCheckBox( "Visible" );
|
||||
|
||||
PU5->addEventListener( Event::OnItemClicked, cb::Make1( this, &MapEditor::layerMenuClick ) );
|
||||
PU5->addEventListener( Event::OnItemClicked,
|
||||
[this]( auto event ) { layerMenuClick( event ); } );
|
||||
MenuBar->addMenuButton( "Layer", PU5 );
|
||||
|
||||
UIPopUpMenu* PU6 = UIPopUpMenu::New();
|
||||
@@ -204,7 +205,7 @@ void MapEditor::createMenuBar() {
|
||||
PU6->add( "New Texture Atlas..." );
|
||||
PU6->add( "Add External Texture Atlas..." );
|
||||
MenuBar->addMenuButton( "Atlases", PU6 );
|
||||
PU6->addEventListener( Event::OnItemClicked, cb::Make1( this, &MapEditor::mapMenuClick ) );
|
||||
PU6->addEventListener( Event::OnItemClicked, [this]( auto event ) { mapMenuClick( event ); } );
|
||||
|
||||
mWinContainer = UIWidget::New();
|
||||
mWinContainer->enableReportSizeChangeToChilds();
|
||||
@@ -249,7 +250,7 @@ void MapEditor::createETGMenu() {
|
||||
->setPosition( ContPosX, DistFromTopMenu );
|
||||
|
||||
mTabWidget->addEventListener( Event::OnTabSelected,
|
||||
cb::Make1( this, &MapEditor::onTabSelected ) );
|
||||
[this]( auto event ) { onTabSelected( event ); } );
|
||||
|
||||
createTabs();
|
||||
|
||||
@@ -313,7 +314,7 @@ void MapEditor::createTextureRegionContainer( Int32 Width ) {
|
||||
->setPosition( TAB_CONT_X_DIST, Txt->getPosition().y + Txt->getSize().getHeight() + 4 );
|
||||
|
||||
mGOTypeList->addEventListener( Event::OnItemSelected,
|
||||
cb::Make1( this, &MapEditor::onTypeChange ) );
|
||||
[this]( auto event ) { onTypeChange( event ); } );
|
||||
fillGotyList();
|
||||
|
||||
mBtnGOTypeAdd = UIPushButton::New();
|
||||
@@ -327,7 +328,7 @@ void MapEditor::createTextureRegionContainer( Int32 Width ) {
|
||||
->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP );
|
||||
mBtnGOTypeAdd->setTooltipText( "Adds a new game object type\nunknown by the map editor." );
|
||||
mBtnGOTypeAdd->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &MapEditor::addNewGOType ) );
|
||||
[this]( auto event ) { addNewGOType( event ); } );
|
||||
|
||||
if ( NULL == mBtnGOTypeAdd->getIcon()->getDrawable() )
|
||||
mBtnGOTypeAdd->setText( "..." );
|
||||
@@ -344,7 +345,7 @@ void MapEditor::createTextureRegionContainer( Int32 Width ) {
|
||||
->setPosition( TAB_CONT_X_DIST, Txt->getPosition().y + Txt->getSize().getHeight() + 4 );
|
||||
|
||||
mLayerList->addEventListener( Event::OnItemSelected,
|
||||
cb::Make1( this, &MapEditor::onLayerSelect ) );
|
||||
[this]( auto event ) { onLayerSelect( event ); } );
|
||||
|
||||
Txt = createTextBox( "Game Object Flags:", mTextureRegionCont, Sizef( Width, 16 ),
|
||||
Vector2f( TAB_CONT_X_DIST, mLayerList->getPosition().y +
|
||||
@@ -360,7 +361,7 @@ void MapEditor::createTextureRegionContainer( Int32 Width ) {
|
||||
->setPosition( TAB_CONT_X_DIST, Txt->getPosition().y + Txt->getSize().getHeight() + 4 );
|
||||
mChkMirrored->setText( "Mirrored" );
|
||||
mChkMirrored->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &MapEditor::chkClickMirrored ) );
|
||||
[this]( auto event ) { chkClickMirrored( event ); } );
|
||||
|
||||
mChkFliped = UICheckBox::New();
|
||||
mChkFliped->setFontStyle( Text::Shadow )
|
||||
@@ -370,7 +371,7 @@ void MapEditor::createTextureRegionContainer( Int32 Width ) {
|
||||
mChkMirrored->getPosition().y );
|
||||
mChkFliped->setText( "Fliped" );
|
||||
mChkFliped->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &MapEditor::chkClickFlipped ) );
|
||||
[this]( auto event ) { chkClickFlipped( event ); } );
|
||||
|
||||
mChkBlocked = UICheckBox::New();
|
||||
mChkBlocked->setFontStyle( Text::Shadow )
|
||||
@@ -381,7 +382,7 @@ void MapEditor::createTextureRegionContainer( Int32 Width ) {
|
||||
mChkBlocked->setText( "Blocked" );
|
||||
mChkBlocked->setTooltipText( "Blocks the tile occupied by the sprite." );
|
||||
mChkBlocked->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &MapEditor::chkClickBlocked ) );
|
||||
[this]( auto event ) { chkClickBlocked( event ); } );
|
||||
|
||||
mChkAnim = UICheckBox::New();
|
||||
mChkAnim->setFontStyle( Text::Shadow )
|
||||
@@ -392,7 +393,7 @@ void MapEditor::createTextureRegionContainer( Int32 Width ) {
|
||||
mChkAnim->setText( "Animated" );
|
||||
mChkAnim->setTooltipText( "Indicates if the Sprite is animated." );
|
||||
mChkAnim->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &MapEditor::chkClickAnimated ) );
|
||||
[this]( auto event ) { chkClickAnimated( event ); } );
|
||||
|
||||
mChkRot90 = UICheckBox::New();
|
||||
mChkRot90->setFontStyle( Text::Shadow )
|
||||
@@ -402,7 +403,7 @@ void MapEditor::createTextureRegionContainer( Int32 Width ) {
|
||||
mChkBlocked->getPosition().y + mChkBlocked->getSize().getHeight() + 4 );
|
||||
mChkRot90->setText( String::fromUtf8( std::string_view{ "Rotate 90º" } ) );
|
||||
mChkRot90->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &MapEditor::chkClickRot90 ) );
|
||||
[this]( auto event ) { chkClickRot90( event ); } );
|
||||
|
||||
mChkAutoFix = UICheckBox::New();
|
||||
mChkAutoFix->setFontStyle( Text::Shadow )
|
||||
@@ -414,7 +415,7 @@ void MapEditor::createTextureRegionContainer( Int32 Width ) {
|
||||
mChkAutoFix->setTooltipText( "In a tiled layer if the sprite is moved,\nit will update the "
|
||||
"current tile position automatically." );
|
||||
mChkAutoFix->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &MapEditor::chkClickAutoFix ) );
|
||||
[this]( auto event ) { chkClickAutoFix( event ); } );
|
||||
|
||||
mChkBlendAdd = UICheckBox::New();
|
||||
mChkBlendAdd->setFontStyle( Text::Shadow )
|
||||
@@ -425,7 +426,7 @@ void MapEditor::createTextureRegionContainer( Int32 Width ) {
|
||||
mChkBlendAdd->setText( "Additive Blend" );
|
||||
mChkBlendAdd->setTooltipText( "Use additive blend mode." );
|
||||
mChkBlendAdd->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &MapEditor::chkClickAutoFix ) );
|
||||
[this]( auto event ) { chkClickAutoFix( event ); } );
|
||||
|
||||
Txt = createTextBox( "Game Object Data:", mTextureRegionCont, Sizef( Width, 16 ),
|
||||
Vector2f( TAB_CONT_X_DIST, mChkBlendAdd->getPosition().y +
|
||||
@@ -440,7 +441,7 @@ void MapEditor::createTextureRegionContainer( Int32 Width ) {
|
||||
mChkDI->setText( "Add as DataId" );
|
||||
mChkDI->setTooltipText(
|
||||
"If the resource it's not a sprite,\nyou can reference it with a data id" );
|
||||
mChkDI->addEventListener( Event::OnValueChange, cb::Make1( this, &MapEditor::chkClickDI ) );
|
||||
mChkDI->addEventListener( Event::OnValueChange, [this]( auto event ) { chkClickDI( event ); } );
|
||||
|
||||
mSGCont = UIWidget::New();
|
||||
mSGCont->setParent( mTextureRegionCont )
|
||||
@@ -459,8 +460,8 @@ void MapEditor::createTextureRegionContainer( Int32 Width ) {
|
||||
->setParent( mSGCont )
|
||||
->setSize( Width, 0 )
|
||||
->setPosition( 0, Txt->getPosition().y + Txt->getSize().getHeight() + 4 );
|
||||
mTextureAtlasesList->addEventListener( Event::OnItemSelected,
|
||||
cb::Make1( this, &MapEditor::onTextureAtlasChange ) );
|
||||
mTextureAtlasesList->addEventListener(
|
||||
Event::OnItemSelected, [this]( auto event ) { onTextureAtlasChange( event ); } );
|
||||
|
||||
mTextureRegionList = UIListBox::New();
|
||||
mTextureRegionList->setParent( mSGCont )
|
||||
@@ -470,8 +471,8 @@ void MapEditor::createTextureRegionContainer( Int32 Width ) {
|
||||
mTextureRegionList->getContainerPadding().Top +
|
||||
mTextureRegionList->getContainerPadding().Bottom );
|
||||
mTextureRegionList->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP );
|
||||
mTextureRegionList->addEventListener( Event::OnItemSelected,
|
||||
cb::Make1( this, &MapEditor::onTextureRegionChange ) );
|
||||
mTextureRegionList->addEventListener(
|
||||
Event::OnItemSelected, [this]( auto event ) { onTextureRegionChange( event ); } );
|
||||
|
||||
mGfxPreview = UITextureRegion::New();
|
||||
mGfxPreview->setScaleType( UIScaleType::FitInside )
|
||||
@@ -510,7 +511,8 @@ void MapEditor::createLighContainer() {
|
||||
->setSize( mLightCont->getSize().getWidth() - TAB_CONT_X_DIST * 2, 0 )
|
||||
->setPosition( TAB_CONT_X_DIST, 0 );
|
||||
NewLightBut->setText( "New Light" );
|
||||
NewLightBut->addEventListener( Event::MouseClick, cb::Make1( this, &MapEditor::onNewLight ) );
|
||||
NewLightBut->addEventListener( Event::MouseClick,
|
||||
[this]( auto event ) { onNewLight( event ); } );
|
||||
|
||||
UITextView* Txt =
|
||||
createTextBox( "Light Color:", mLightCont, Sizef(), Vector2f( TAB_CONT_X_DIST, 32 ),
|
||||
@@ -539,7 +541,7 @@ void MapEditor::createLighContainer() {
|
||||
mUIRedSlider->setMaxValue( 255 );
|
||||
mUIRedSlider->setValue( 255 );
|
||||
mUIRedSlider->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &MapEditor::onRedChange ) );
|
||||
[this]( auto event ) { onRedChange( event ); } );
|
||||
|
||||
mUIRedTxt = createTextBox(
|
||||
String::toString( (Uint32)255 ), mLightCont, Sizef(),
|
||||
@@ -559,7 +561,7 @@ void MapEditor::createLighContainer() {
|
||||
mUIGreenSlider->setMaxValue( 255 );
|
||||
mUIGreenSlider->setValue( 255 );
|
||||
mUIGreenSlider->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &MapEditor::onGreenChange ) );
|
||||
[this]( auto event ) { onGreenChange( event ); } );
|
||||
|
||||
mUIGreenTxt = createTextBox(
|
||||
String::toString( (Uint32)255 ), mLightCont, Sizef(),
|
||||
@@ -579,7 +581,7 @@ void MapEditor::createLighContainer() {
|
||||
mUIBlueSlider->setMaxValue( 255 );
|
||||
mUIBlueSlider->setValue( 255 );
|
||||
mUIBlueSlider->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &MapEditor::onBlueChange ) );
|
||||
[this]( auto event ) { onBlueChange( event ); } );
|
||||
|
||||
mUIBlueTxt = createTextBox(
|
||||
String::toString( (Uint32)255 ), mLightCont, Sizef(),
|
||||
@@ -599,7 +601,7 @@ void MapEditor::createLighContainer() {
|
||||
Txt->getPosition().y + Txt->getSize().getHeight() + 8 );
|
||||
mLightRadius->setMaxValue( 2000 );
|
||||
mLightRadius->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &MapEditor::onLightRadiusChangeVal ) );
|
||||
[this]( auto event ) { onLightRadiusChangeVal( event ); } );
|
||||
|
||||
mLightTypeChk = UICheckBox::New();
|
||||
mLightTypeChk->setFlags( UI_AUTO_SIZE )
|
||||
@@ -609,7 +611,7 @@ void MapEditor::createLighContainer() {
|
||||
mLightTypeChk->setText( "Isometric Light" );
|
||||
mLightTypeChk->setChecked( false );
|
||||
mLightTypeChk->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &MapEditor::onLightTypeChange ) );
|
||||
[this]( auto event ) { onLightTypeChange( event ); } );
|
||||
}
|
||||
|
||||
UISelectButton* MapEditor::addObjContButton( String text, Uint32 mode ) {
|
||||
@@ -620,7 +622,8 @@ UISelectButton* MapEditor::addObjContButton( String text, Uint32 mode ) {
|
||||
Button->setText( text );
|
||||
Button->setData( mode );
|
||||
|
||||
Button->addEventListener( Event::MouseClick, cb::Make1( this, &MapEditor::onObjectModeSel ) );
|
||||
Button->addEventListener( Event::MouseClick,
|
||||
[this]( auto event ) { onObjectModeSel( event ); } );
|
||||
|
||||
mLastSelButtonY += Button->getSize().getHeight() + 4;
|
||||
|
||||
@@ -644,7 +647,7 @@ void MapEditor::createObjectsContainer() {
|
||||
mChkClampToTile->resetFlags( ChkFlags )->setParent( mObjectCont )->setPosition( 12, nextY );
|
||||
mChkClampToTile->setText( "Clamp Position to Tile" );
|
||||
mChkClampToTile->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &MapEditor::chkClickClampToTile ) );
|
||||
[this]( auto event ) { chkClickClampToTile( event ); } );
|
||||
mChkClampToTile->setChecked( true );
|
||||
}
|
||||
|
||||
@@ -687,14 +690,18 @@ void MapEditor::createUIMap() {
|
||||
mUIMap->setVisible( true );
|
||||
mUIMap->setEnabled( true );
|
||||
createNewEmptyMap();
|
||||
mUIMap->addEventListener( Event::OnSizeChange, cb::Make1( this, &MapEditor::onMapSizeChange ) );
|
||||
mUIMap->addEventListener( Event::MouseDown, cb::Make1( this, &MapEditor::onMapMouseDown ) );
|
||||
mUIMap->addEventListener( Event::MouseClick, cb::Make1( this, &MapEditor::onMapMouseClick ) );
|
||||
mUIMap->setLightSelectCb( cb::Make1( this, &MapEditor::onLightSelect ) );
|
||||
mUIMap->setLightRadiusChangeCb( cb::Make1( this, &MapEditor::onLightRadiusChange ) );
|
||||
mUIMap->setAddObjectCallback( cb::Make2( this, &MapEditor::onAddObject ) );
|
||||
mUIMap->setAlertCb( cb::Make2( this, &MapEditor::createAlert ) );
|
||||
mUIMap->setUpdateScrollCb( cb::Make0( this, &MapEditor::updateScroll ) );
|
||||
mUIMap->addEventListener( Event::OnSizeChange,
|
||||
[this]( auto event ) { onMapSizeChange( event ); } );
|
||||
mUIMap->addEventListener( Event::MouseDown, [this]( auto event ) { onMapMouseDown( event ); } );
|
||||
mUIMap->addEventListener( Event::MouseClick,
|
||||
[this]( auto event ) { onMapMouseClick( event ); } );
|
||||
mUIMap->setLightSelectCb( [this]( auto event ) { onLightSelect( event ); } );
|
||||
mUIMap->setLightRadiusChangeCb( [this]( auto event ) { onLightRadiusChange( event ); } );
|
||||
mUIMap->setAddObjectCallback(
|
||||
[this]( Uint32 Type, Polygon2f poly ) { onAddObject( Type, poly ); } );
|
||||
mUIMap->setAlertCb(
|
||||
[this]( const String& title, const String& text ) { return createAlert( title, text ); } );
|
||||
mUIMap->setUpdateScrollCb( [this] { updateScroll(); } );
|
||||
mUIMap->setTileBox( mTileBox );
|
||||
|
||||
mMapHScroll = UIScrollBar::New();
|
||||
@@ -704,7 +711,7 @@ void MapEditor::createUIMap() {
|
||||
->setPosition( 0, mWinContainer->getSize().getHeight() - ScrollH );
|
||||
mMapHScroll->setAnchors( UI_ANCHOR_LEFT | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM );
|
||||
mMapHScroll->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &MapEditor::onScrollMapH ) );
|
||||
[this]( auto event ) { onScrollMapH( event ); } );
|
||||
|
||||
mMapVScroll = UIScrollBar::New();
|
||||
mMapVScroll->setParent( mWinContainer )
|
||||
@@ -712,7 +719,7 @@ void MapEditor::createUIMap() {
|
||||
->setPosition( mWinContainer->getSize().getWidth() - 225 - ScrollV, 0 );
|
||||
mMapVScroll->setAnchors( UI_ANCHOR_TOP | UI_ANCHOR_BOTTOM );
|
||||
mMapVScroll->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &MapEditor::onScrollMapV ) );
|
||||
[this]( auto event ) { onScrollMapV( event ); } );
|
||||
|
||||
mapCreated();
|
||||
}
|
||||
@@ -936,7 +943,9 @@ void MapEditor::chkClickAnimated( const Event* ) {
|
||||
}
|
||||
|
||||
void MapEditor::addNewGOType( const Event* ) {
|
||||
eeNew( UIGOTypeNew, ( cb::Make2( this, &MapEditor::onNewGOTypeAdded ) ) );
|
||||
eeNew( UIGOTypeNew, ( [this]( std::string name, String::HashType hash ) {
|
||||
onNewGOTypeAdded( name, hash );
|
||||
} ) );
|
||||
}
|
||||
|
||||
void MapEditor::onNewGOTypeAdded( std::string name, String::HashType ) {
|
||||
@@ -1023,7 +1032,7 @@ void MapEditor::onTextureAtlasChange( const Event* ) {
|
||||
}
|
||||
|
||||
void MapEditor::createNewMap() {
|
||||
eeNew( UIMapNew, ( mUIMap, cb::Make0( this, &MapEditor::mapCreated ) ) );
|
||||
eeNew( UIMapNew, ( mUIMap, [this] { mapCreated(); } ) );
|
||||
}
|
||||
|
||||
void MapEditor::createNewEmptyMap() {
|
||||
@@ -1136,7 +1145,7 @@ void MapEditor::fileMenuClick( const Event* Event ) {
|
||||
UIFileDialog* TGDialog = UIFileDialog::New( UIFileDialog::DefaultFlags, "*.eem" );
|
||||
TGDialog->setWindowFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL );
|
||||
TGDialog->setTitle( "Open Map" );
|
||||
TGDialog->addEventListener( Event::OpenFile, cb::Make1( this, &MapEditor::mapOpen ) );
|
||||
TGDialog->addEventListener( Event::OpenFile, [this]( auto event ) { mapOpen( event ); } );
|
||||
TGDialog->center();
|
||||
TGDialog->show();
|
||||
} else if ( "Save As..." == txt ) {
|
||||
@@ -1144,7 +1153,7 @@ void MapEditor::fileMenuClick( const Event* Event ) {
|
||||
UIFileDialog::New( UIFileDialog::DefaultFlags | UIFileDialog::SaveDialog, "*.eem" );
|
||||
TGDialog->setWindowFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL );
|
||||
TGDialog->setTitle( "Save Map" );
|
||||
TGDialog->addEventListener( Event::SaveFile, cb::Make1( this, &MapEditor::mapSave ) );
|
||||
TGDialog->addEventListener( Event::SaveFile, [this]( auto event ) { mapSave( event ); } );
|
||||
TGDialog->center();
|
||||
TGDialog->show();
|
||||
} else if ( "Save" == txt ) {
|
||||
@@ -1155,7 +1164,7 @@ void MapEditor::fileMenuClick( const Event* Event ) {
|
||||
UIMessageBox* MsgBox = UIMessageBox::New(
|
||||
UIMessageBox::OK_CANCEL,
|
||||
"Do you really want to close the current map?\nAll changes will be lost." );
|
||||
MsgBox->addEventListener( Event::OnConfirm, cb::Make1( this, &MapEditor::onMapClose ) );
|
||||
MsgBox->addEventListener( Event::OnConfirm, [this]( auto event ) { onMapClose( event ); } );
|
||||
MsgBox->setTitle( "Close Map?" );
|
||||
MsgBox->center();
|
||||
MsgBox->show();
|
||||
@@ -1279,13 +1288,14 @@ void MapEditor::mapMenuClick( const Event* Event ) {
|
||||
TGDialog->setWindowFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL );
|
||||
TGDialog->setTitle( "Load Texture Atlas..." );
|
||||
TGDialog->addEventListener( Event::OpenFile,
|
||||
cb::Make1( this, &MapEditor::cextureAtlasOpen ) );
|
||||
[this]( auto event ) { cextureAtlasOpen( event ); } );
|
||||
TGDialog->center();
|
||||
TGDialog->show();
|
||||
} else if ( "Properties..." == txt ) {
|
||||
eeNew( TileMapProperties, ( mUIMap->Map() ) );
|
||||
} else if ( "Resize..." ) {
|
||||
eeNew( UIMapNew, ( mUIMap, cb::Make0( this, &MapEditor::onMapLoad ), true ) );
|
||||
eeNew( UIMapNew, (
|
||||
mUIMap, [this] { onMapLoad(); }, true ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1297,10 +1307,10 @@ void MapEditor::layerMenuClick( const Event* Event ) {
|
||||
|
||||
if ( "Add Tile Layer..." == txt ) {
|
||||
eeNew( UIMapLayerNew,
|
||||
( mUIMap, MAP_LAYER_TILED, cb::Make1( this, &MapEditor::onLayerAdd ) ) );
|
||||
( mUIMap, MAP_LAYER_TILED, [this]( auto event ) { onLayerAdd( event ); } ) );
|
||||
} else if ( "Add Object Layer..." == txt ) {
|
||||
eeNew( UIMapLayerNew,
|
||||
( mUIMap, MAP_LAYER_OBJECT, cb::Make1( this, &MapEditor::onLayerAdd ) ) );
|
||||
( mUIMap, MAP_LAYER_OBJECT, [this]( auto event ) { onLayerAdd( event ); } ) );
|
||||
} else if ( "Remove Layer" == txt ) {
|
||||
removeLayer();
|
||||
} else if ( "Move Layer Up" == txt ) {
|
||||
@@ -1309,8 +1319,7 @@ void MapEditor::layerMenuClick( const Event* Event ) {
|
||||
moveLayerDown();
|
||||
} else if ( "Layer Properties..." == txt ) {
|
||||
if ( NULL != mCurLayer ) {
|
||||
eeNew( MapLayerProperties,
|
||||
( mCurLayer, cb::Make0( this, &MapEditor::refreshLayersList ) ) );
|
||||
eeNew( MapLayerProperties, ( mCurLayer, [this] { refreshLayersList(); } ) );
|
||||
} else {
|
||||
createNoLayerAlert( "Error retrieving layer properties" );
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ MapLayerProperties::MapLayerProperties( MapLayer* Map, RefreshLayerListCb Cb ) :
|
||||
->setMinWindowSize( 500, 500 );
|
||||
|
||||
mUIWindow->addEventListener( Event::OnWindowClose,
|
||||
cb::Make1( this, &MapLayerProperties::onWindowClose ) );
|
||||
[this] ( auto event ) { onWindowClose( event ); } );
|
||||
mUIWindow->setTitle( "Layer Properties" );
|
||||
|
||||
Int32 InitialY = 16;
|
||||
@@ -47,7 +47,7 @@ MapLayerProperties::MapLayerProperties( MapLayer* Map, RefreshLayerListCb Cb ) :
|
||||
->setPosition( Txt->getPosition().x + DistFromTitle, Txt->getPosition().y + DistFromTitle );
|
||||
mUIInput->setText( mLayer->getName() );
|
||||
mUIInput->addEventListener( Event::OnPressEnter,
|
||||
cb::Make1( this, &MapLayerProperties::onOKClick ) );
|
||||
[this] ( auto event ) { onOKClick( event ); } );
|
||||
|
||||
UITextView* TxtBox = UITextView::New();
|
||||
TxtBox->setFontStyle( Text::Shadow )
|
||||
@@ -72,7 +72,7 @@ MapLayerProperties::MapLayerProperties( MapLayer* Map, RefreshLayerListCb Cb ) :
|
||||
mUIWindow->getContainer()->getSize().getWidth() - OKButton->getSize().getWidth() - 4,
|
||||
mUIWindow->getContainer()->getSize().getHeight() - OKButton->getSize().getHeight() - 4 );
|
||||
OKButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &MapLayerProperties::onOKClick ) );
|
||||
[this] ( auto event ) { onOKClick( event ); } );
|
||||
OKButton->setText( "OK" );
|
||||
OKButton->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM );
|
||||
|
||||
@@ -83,7 +83,7 @@ MapLayerProperties::MapLayerProperties( MapLayer* Map, RefreshLayerListCb Cb ) :
|
||||
OKButton->getPosition().y );
|
||||
CancelButton->setIcon( sceneNode->findIconDrawable( "cancel", PixelDensity::dpToPxI( 16 ) ) );
|
||||
CancelButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &MapLayerProperties::onCancelClick ) );
|
||||
[this] ( auto event ) { onCancelClick( event ); } );
|
||||
CancelButton->setText( "Cancel" );
|
||||
CancelButton->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM );
|
||||
|
||||
@@ -107,7 +107,7 @@ MapLayerProperties::MapLayerProperties( MapLayer* Map, RefreshLayerListCb Cb ) :
|
||||
AddButton->setIcon( sceneNode->findIconDrawable( "add", PixelDensity::dpToPxI( 16 ) ) );
|
||||
AddButton->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP );
|
||||
AddButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &MapLayerProperties::onAddCellClick ) );
|
||||
[this] ( auto event ) { onAddCellClick( event ); } );
|
||||
|
||||
if ( NULL == AddButton->getIcon()->getDrawable() )
|
||||
AddButton->setText( "+" );
|
||||
@@ -119,7 +119,7 @@ MapLayerProperties::MapLayerProperties( MapLayer* Map, RefreshLayerListCb Cb ) :
|
||||
RemoveButton->setIcon( sceneNode->findIconDrawable( "remove", PixelDensity::dpToPxI( 16 ) ) );
|
||||
RemoveButton->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP );
|
||||
RemoveButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &MapLayerProperties::onRemoveCellClick ) );
|
||||
[this] ( auto event ) { onRemoveCellClick( event ); } );
|
||||
|
||||
if ( NULL == RemoveButton->getIcon()->getDrawable() )
|
||||
RemoveButton->setText( "-" );
|
||||
|
||||
@@ -43,7 +43,7 @@ MapObjectProperties::MapObjectProperties( GameObjectObject* Obj ) :
|
||||
->setMinWindowSize( 500, 500 );
|
||||
|
||||
mUIWindow->addEventListener( Event::OnWindowClose,
|
||||
cb::Make1( this, &MapObjectProperties::onWindowClose ) );
|
||||
[this] ( auto event ) { onWindowClose( event ); } );
|
||||
mUIWindow->setTitle( "Object Properties" );
|
||||
|
||||
Int32 InitialY = 16;
|
||||
@@ -59,7 +59,7 @@ MapObjectProperties::MapObjectProperties( GameObjectObject* Obj ) :
|
||||
mUIInput->setMaxLength( 64 );
|
||||
mUIInput->setText( mObj->getName() );
|
||||
mUIInput->addEventListener( Event::OnPressEnter,
|
||||
cb::Make1( this, &MapObjectProperties::onOKClick ) );
|
||||
[this] ( auto event ) { onOKClick( event ); } );
|
||||
|
||||
UITextView* Txt2 = createTextBox( "Object type:", mUIWindow->getContainer(), Sizef(),
|
||||
Vector2f( 50 + 192, InitialY ),
|
||||
@@ -72,7 +72,7 @@ MapObjectProperties::MapObjectProperties( GameObjectObject* Obj ) :
|
||||
mUIInput2->setMaxLength( 64 );
|
||||
mUIInput2->setText( mObj->getTypeName() );
|
||||
mUIInput2->addEventListener( Event::OnPressEnter,
|
||||
cb::Make1( this, &MapObjectProperties::onOKClick ) );
|
||||
[this] ( auto event ) { onOKClick( event ); } );
|
||||
|
||||
Uint32 TxtBoxFlags = UI_NODE_DEFAULT_FLAGS | UI_HALIGN_CENTER | UI_VALIGN_CENTER;
|
||||
createTextBox( "Property Name", mUIWindow->getContainer(), Sizef( 192, 24 ),
|
||||
@@ -90,7 +90,7 @@ MapObjectProperties::MapObjectProperties( GameObjectObject* Obj ) :
|
||||
mUIWindow->getContainer()->getSize().getWidth() - OKButton->getSize().getWidth() - 4,
|
||||
mUIWindow->getContainer()->getSize().getHeight() - OKButton->getSize().getHeight() - 4 );
|
||||
OKButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &MapObjectProperties::onOKClick ) );
|
||||
[this] ( auto event ) { onOKClick( event ); } );
|
||||
OKButton->setText( "OK" );
|
||||
OKButton->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM );
|
||||
|
||||
@@ -101,7 +101,7 @@ MapObjectProperties::MapObjectProperties( GameObjectObject* Obj ) :
|
||||
OKButton->getPosition().y );
|
||||
CancelButton->setIcon( sceneNode->findIconDrawable( "cancel", PixelDensity::dpToPxI( 16 ) ) );
|
||||
CancelButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &MapObjectProperties::onCancelClick ) );
|
||||
[this] ( auto event ) { onCancelClick( event ); } );
|
||||
CancelButton->setText( "Cancel" );
|
||||
CancelButton->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM );
|
||||
|
||||
@@ -125,7 +125,7 @@ MapObjectProperties::MapObjectProperties( GameObjectObject* Obj ) :
|
||||
AddButton->setIcon( sceneNode->findIconDrawable( "add", PixelDensity::dpToPxI( 16 ) ) );
|
||||
AddButton->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP );
|
||||
AddButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &MapObjectProperties::onAddCellClick ) );
|
||||
[this] ( auto event ) { onAddCellClick( event ); } );
|
||||
|
||||
if ( NULL == AddButton->getIcon()->getDrawable() )
|
||||
AddButton->setText( "+" );
|
||||
@@ -137,7 +137,7 @@ MapObjectProperties::MapObjectProperties( GameObjectObject* Obj ) :
|
||||
RemoveButton->setIcon( sceneNode->findIconDrawable( "remove", PixelDensity::dpToPxI( 16 ) ) );
|
||||
RemoveButton->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP );
|
||||
RemoveButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &MapObjectProperties::onRemoveCellClick ) );
|
||||
[this] ( auto event ) { onRemoveCellClick( event ); } );
|
||||
|
||||
if ( NULL == RemoveButton->getIcon()->getDrawable() )
|
||||
RemoveButton->setText( "-" );
|
||||
|
||||
@@ -44,7 +44,7 @@ TileMapProperties::TileMapProperties( TileMap* Map ) :
|
||||
->setMinWindowSize( 500, 500 );
|
||||
|
||||
mUIWindow->addEventListener( Event::OnWindowClose,
|
||||
cb::Make1( this, &TileMapProperties::onWindowClose ) );
|
||||
[this] ( auto event ) { onWindowClose( event ); } );
|
||||
mUIWindow->setTitle( "Map Properties" );
|
||||
|
||||
Uint32 DiffIfLights = 0;
|
||||
@@ -78,7 +78,7 @@ TileMapProperties::TileMapProperties( TileMap* Map ) :
|
||||
mUIRedSlider->setMaxValue( 255 );
|
||||
mUIRedSlider->setValue( mMap->getBaseColor().r );
|
||||
mUIRedSlider->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &TileMapProperties::onRedChange ) );
|
||||
[this] ( auto event ) { onRedChange( event ); } );
|
||||
|
||||
mUIRedTxt = createTextBox(
|
||||
String::toString( (Uint32)mMap->getBaseColor().r ), mUIWindow->getContainer(), Sizef(),
|
||||
@@ -99,7 +99,7 @@ TileMapProperties::TileMapProperties( TileMap* Map ) :
|
||||
mUIGreenSlider->setMaxValue( 255 );
|
||||
mUIGreenSlider->setValue( mMap->getBaseColor().g );
|
||||
mUIGreenSlider->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &TileMapProperties::onGreenChange ) );
|
||||
[this] ( auto event ) { onGreenChange( event ); } );
|
||||
|
||||
mUIGreenTxt = createTextBox(
|
||||
String::toString( (Uint32)mMap->getBaseColor().g ), mUIWindow->getContainer(), Sizef(),
|
||||
@@ -119,7 +119,7 @@ TileMapProperties::TileMapProperties( TileMap* Map ) :
|
||||
mUIBlueSlider->setMaxValue( 255 );
|
||||
mUIBlueSlider->setValue( mMap->getBaseColor().b );
|
||||
mUIBlueSlider->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &TileMapProperties::onBlueChange ) );
|
||||
[this] ( auto event ) { onBlueChange( event ); } );
|
||||
|
||||
mUIBlueTxt = createTextBox(
|
||||
String::toString( (Uint32)mMap->getBaseColor().b ), mUIWindow->getContainer(), Sizef(),
|
||||
@@ -142,7 +142,7 @@ TileMapProperties::TileMapProperties( TileMap* Map ) :
|
||||
mUIWindow->getContainer()->getSize().getWidth() - OKButton->getSize().getWidth() - 4,
|
||||
mUIWindow->getContainer()->getSize().getHeight() - OKButton->getSize().getHeight() - 4 );
|
||||
OKButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &TileMapProperties::onOKClick ) );
|
||||
[this] ( auto event ) { onOKClick( event ); } );
|
||||
OKButton->setText( "OK" );
|
||||
OKButton->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM );
|
||||
|
||||
@@ -153,7 +153,7 @@ TileMapProperties::TileMapProperties( TileMap* Map ) :
|
||||
OKButton->getPosition().y );
|
||||
CancelButton->setIcon( sceneNode->findIconDrawable( "cancel", PixelDensity::dpToPxI( 16 ) ) );
|
||||
CancelButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &TileMapProperties::onCancelClick ) );
|
||||
[this] ( auto event ) { onCancelClick( event ); } );
|
||||
CancelButton->setText( "Cancel" );
|
||||
CancelButton->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM );
|
||||
|
||||
@@ -177,7 +177,7 @@ TileMapProperties::TileMapProperties( TileMap* Map ) :
|
||||
AddButton->setIcon( sceneNode->findIconDrawable( "add", PixelDensity::dpToPxI( 16 ) ) );
|
||||
AddButton->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP );
|
||||
AddButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &TileMapProperties::onAddCellClick ) );
|
||||
[this] ( auto event ) { onAddCellClick( event ); } );
|
||||
|
||||
if ( NULL == AddButton->getIcon()->getDrawable() )
|
||||
AddButton->setText( "+" );
|
||||
@@ -189,7 +189,7 @@ TileMapProperties::TileMapProperties( TileMap* Map ) :
|
||||
RemoveButton->setIcon( sceneNode->findIconDrawable( "remove", PixelDensity::dpToPxI( 16 ) ) );
|
||||
RemoveButton->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP );
|
||||
RemoveButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &TileMapProperties::onRemoveCellClick ) );
|
||||
[this] ( auto event ) { onRemoveCellClick( event ); } );
|
||||
|
||||
if ( NULL == RemoveButton->getIcon()->getDrawable() )
|
||||
RemoveButton->setText( "-" );
|
||||
|
||||
@@ -23,7 +23,7 @@ UIGOTypeNew::UIGOTypeNew( std::function<void( std::string, Uint32 )> Cb ) :
|
||||
->setMinWindowSize( 278, 114 );
|
||||
|
||||
mUIWindow->addEventListener( Event::OnWindowClose,
|
||||
cb::Make1( this, &UIGOTypeNew::onWindowClose ) );
|
||||
[this] ( auto event ) { onWindowClose( event ); } );
|
||||
mUIWindow->setTitle( "Add GameObject Type" );
|
||||
|
||||
Int32 InitialY = 16;
|
||||
@@ -47,8 +47,8 @@ UIGOTypeNew::UIGOTypeNew( std::function<void( std::string, Uint32 )> Cb ) :
|
||||
OKButton->setPosition(
|
||||
mUIWindow->getContainer()->getSize().getWidth() - OKButton->getSize().getWidth() - 4,
|
||||
mUIWindow->getContainer()->getSize().getHeight() - OKButton->getSize().getHeight() - 4 );
|
||||
OKButton->addEventListener( Event::MouseClick, cb::Make1( this, &UIGOTypeNew::onOKClick ) );
|
||||
mUIInput->addEventListener( Event::OnPressEnter, cb::Make1( this, &UIGOTypeNew::onOKClick ) );
|
||||
OKButton->addEventListener( Event::MouseClick, [this] ( auto event ) { onOKClick( event ); } );
|
||||
mUIInput->addEventListener( Event::OnPressEnter, [this] ( auto event ) { onOKClick( event ); } );
|
||||
|
||||
OKButton->setText( "Add" );
|
||||
|
||||
@@ -59,7 +59,7 @@ UIGOTypeNew::UIGOTypeNew( std::function<void( std::string, Uint32 )> Cb ) :
|
||||
OKButton->getPosition().y );
|
||||
CancelButton->setIcon( sceneNode->findIconDrawable( "cancel", PixelDensity::dpToPxI( 16 ) ) );
|
||||
CancelButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &UIGOTypeNew::onCancelClick ) );
|
||||
[this] ( auto event ) { onCancelClick( event ); } );
|
||||
CancelButton->setText( "Cancel" );
|
||||
|
||||
mUIWindow->center();
|
||||
|
||||
@@ -42,7 +42,7 @@ UIMap::UIMap( UITheme* Theme, TileMap* Map ) :
|
||||
mMap->setBackColor( Color( 100, 100, 100, 100 ) );
|
||||
mMap->setGridLinesColor( Color( 150, 150, 150, 150 ) );
|
||||
mMap->setScale( PixelDensity::getPixelDensity() );
|
||||
mMap->setDrawCallback( cb::Make0( this, &UIMap::mapDraw ) );
|
||||
mMap->setDrawCallback( [this] { mapDraw(); } );
|
||||
mMap->setViewSize( mSize );
|
||||
|
||||
mDragButton = EE_BUTTON_MMASK;
|
||||
@@ -586,7 +586,7 @@ void UIMap::createObjPopUpMenu() {
|
||||
Menu->add( "Remove Object" );
|
||||
Menu->addSeparator();
|
||||
Menu->add( "Object Properties..." );
|
||||
Menu->addEventListener( Event::OnItemClicked, cb::Make1( this, &UIMap::objItemClick ) );
|
||||
Menu->addEventListener( Event::OnItemClicked, [this] ( auto event ) { objItemClick( event ); } );
|
||||
|
||||
if ( Menu->show() ) {
|
||||
Vector2f Pos = getEventDispatcher()->getMousePosf();
|
||||
|
||||
@@ -28,7 +28,7 @@ UIMapLayerNew::UIMapLayerNew( UIMap* Map, EE_LAYER_TYPE Type, NewLayerCb newLaye
|
||||
->setMinWindowSize( 278, 114 );
|
||||
|
||||
mUIWindow->addEventListener( Event::OnWindowClose,
|
||||
cb::Make1( this, &UIMapLayerNew::onWindowClose ) );
|
||||
[this] ( auto event ) { onWindowClose( event ); } );
|
||||
|
||||
if ( MAP_LAYER_TILED == mType )
|
||||
mUIWindow->setTitle( "New Tile Layer" );
|
||||
@@ -57,9 +57,9 @@ UIMapLayerNew::UIMapLayerNew( UIMap* Map, EE_LAYER_TYPE Type, NewLayerCb newLaye
|
||||
OKButton->setPosition(
|
||||
mUIWindow->getContainer()->getSize().getWidth() - OKButton->getSize().getWidth() - 4,
|
||||
mUIWindow->getContainer()->getSize().getHeight() - OKButton->getSize().getHeight() - 4 );
|
||||
OKButton->addEventListener( Event::MouseClick, cb::Make1( this, &UIMapLayerNew::onOKClick ) );
|
||||
OKButton->addEventListener( Event::MouseClick, [this] ( auto event ) { onOKClick( event ); } );
|
||||
mUILayerName->addEventListener( Event::OnPressEnter,
|
||||
cb::Make1( this, &UIMapLayerNew::onOKClick ) );
|
||||
[this] ( auto event ) { onOKClick( event ); } );
|
||||
|
||||
OKButton->setText( "Add" );
|
||||
|
||||
@@ -70,10 +70,10 @@ UIMapLayerNew::UIMapLayerNew( UIMap* Map, EE_LAYER_TYPE Type, NewLayerCb newLaye
|
||||
OKButton->getPosition().y );
|
||||
CancelButton->setIcon( sceneNode->findIconDrawable( "cancel", PixelDensity::dpToPxI( 16 ) ) );
|
||||
CancelButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &UIMapLayerNew::onCancelClick ) );
|
||||
[this] ( auto event ) { onCancelClick( event ); } );
|
||||
CancelButton->setText( "Cancel" );
|
||||
|
||||
mUIWindow->addEventListener( Event::KeyUp, cb::Make1( this, &UIMapLayerNew::onOnKeyUp ) );
|
||||
mUIWindow->addEventListener( Event::KeyUp, [this] ( auto event ) { onOnKeyUp( event ); } );
|
||||
|
||||
mUIWindow->center();
|
||||
mUIWindow->show();
|
||||
|
||||
@@ -43,7 +43,7 @@ UIMapNew::UIMapNew( UIMap* Map, std::function<void()> NewMapCb, bool ResizeMap )
|
||||
->setMinWindowSize( 320, 380 );
|
||||
|
||||
mUIWindow->addEventListener( Event::OnWindowClose,
|
||||
cb::Make1( this, &UIMapNew::onWindowClose ) );
|
||||
[this] ( auto event ) { onWindowClose( event ); } );
|
||||
|
||||
if ( !mResizeMap ) {
|
||||
mUIWindow->setTitle( "New Map" );
|
||||
@@ -217,7 +217,7 @@ UIMapNew::UIMapNew( UIMap* Map, std::function<void()> NewMapCb, bool ResizeMap )
|
||||
mUIRedSlider->setMaxValue( 255 );
|
||||
mUIRedSlider->setValue( 255 );
|
||||
mUIRedSlider->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &UIMapNew::onRedChange ) );
|
||||
[this] ( auto event ) { onRedChange( event ); } );
|
||||
|
||||
mUIRedTxt = createTextBox(
|
||||
String::toString( 255 ), mUIWindow->getContainer(), Sizef(),
|
||||
@@ -242,7 +242,7 @@ UIMapNew::UIMapNew( UIMap* Map, std::function<void()> NewMapCb, bool ResizeMap )
|
||||
mUIGreenSlider->setMaxValue( 255 );
|
||||
mUIGreenSlider->setValue( 255 );
|
||||
mUIGreenSlider->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &UIMapNew::onGreenChange ) );
|
||||
[this] ( auto event ) { onGreenChange( event ); } );
|
||||
|
||||
mUIGreenTxt = createTextBox(
|
||||
String::toString( 255 ), mUIWindow->getContainer(), Sizef(),
|
||||
@@ -267,7 +267,7 @@ UIMapNew::UIMapNew( UIMap* Map, std::function<void()> NewMapCb, bool ResizeMap )
|
||||
mUIBlueSlider->setMaxValue( 255 );
|
||||
mUIBlueSlider->setValue( 255 );
|
||||
mUIBlueSlider->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &UIMapNew::onBlueChange ) );
|
||||
[this] ( auto event ) { onBlueChange( event ); } );
|
||||
|
||||
mUIBlueTxt = createTextBox(
|
||||
String::toString( 255 ), mUIWindow->getContainer(), Sizef(),
|
||||
@@ -285,7 +285,7 @@ UIMapNew::UIMapNew( UIMap* Map, std::function<void()> NewMapCb, bool ResizeMap )
|
||||
OKButton->setPosition(
|
||||
mUIWindow->getContainer()->getSize().getWidth() - OKButton->getSize().getWidth() - 4,
|
||||
mUIWindow->getContainer()->getSize().getHeight() - OKButton->getSize().getHeight() - 4 );
|
||||
OKButton->addEventListener( Event::MouseClick, cb::Make1( this, &UIMapNew::onOKClick ) );
|
||||
OKButton->addEventListener( Event::MouseClick, [this] ( auto event ) { onOKClick( event ); } );
|
||||
OKButton->setText( "OK" );
|
||||
|
||||
UIPushButton* CancelButton = UIPushButton::New();
|
||||
@@ -295,7 +295,7 @@ UIMapNew::UIMapNew( UIMap* Map, std::function<void()> NewMapCb, bool ResizeMap )
|
||||
OKButton->getPosition().y );
|
||||
CancelButton->setIcon( sceneNode->findIconDrawable( "cancel", PixelDensity::dpToPxI( 16 ) ) );
|
||||
CancelButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &UIMapNew::onCancelClick ) );
|
||||
[this] ( auto event ) { onCancelClick( event ); } );
|
||||
CancelButton->setText( "Cancel" );
|
||||
|
||||
mUIWindow->center();
|
||||
|
||||
@@ -15,8 +15,7 @@ namespace EE { namespace Maps { namespace Private {
|
||||
|
||||
class EE_MAPS_API UIMapNew {
|
||||
public:
|
||||
UIMapNew( UIMap* Map, std::function<void()> NewMapCb = cb::Callback0<void>(),
|
||||
bool ResizeMap = false );
|
||||
UIMapNew( UIMap* Map, std::function<void()> NewMapCb = {}, bool ResizeMap = false );
|
||||
|
||||
virtual ~UIMapNew();
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ void EETest::init() {
|
||||
setScreen( StartScreen );
|
||||
|
||||
mWindow->setTitle( "eepp - Test Application" );
|
||||
mWindow->pushResizeCallback( cb::Make1( this, &EETest::onWindowResize ) );
|
||||
mWindow->pushResizeCallback( [this]( auto event ) { onWindowResize( event ); } );
|
||||
|
||||
TF = TextureFactory::instance();
|
||||
TF->allocate( 40 );
|
||||
@@ -152,12 +152,12 @@ void EETest::init() {
|
||||
|
||||
PS.resize( 5 );
|
||||
|
||||
Scenes[0] = cb::Make0( this, &EETest::physicsUpdate );
|
||||
Scenes[1] = cb::Make0( this, &EETest::screen1 );
|
||||
Scenes[2] = cb::Make0( this, &EETest::screen2 );
|
||||
Scenes[3] = cb::Make0( this, &EETest::screen3 );
|
||||
Scenes[4] = cb::Make0( this, &EETest::screen4 );
|
||||
Scenes[5] = cb::Make0( this, &EETest::screen5 );
|
||||
Scenes[0] = [this] { physicsUpdate(); };
|
||||
Scenes[1] = [this] { screen1(); };
|
||||
Scenes[2] = [this] { screen2(); };
|
||||
Scenes[3] = [this] { screen3(); };
|
||||
Scenes[4] = [this] { screen4(); };
|
||||
Scenes[5] = [this] { screen5(); };
|
||||
|
||||
setRandomSeed( static_cast<Uint32>( Sys::getSystemTime() * 1000 ) );
|
||||
|
||||
@@ -276,7 +276,7 @@ void EETest::onFontLoaded() {
|
||||
Con = UIConsole::NewOpt( monospace, true, true, 8191 );
|
||||
Con->setQuakeMode( true );
|
||||
Con->setVisible( false );
|
||||
Con->addCommand( "setparticlesnum", cb::Make1( this, &EETest::cmdSetPartsNum ) );
|
||||
Con->addCommand( "setparticlesnum", [this]( auto event ) { cmdSetPartsNum( event ); } );
|
||||
|
||||
mEEText.create( TTF, "Entropia Engine++\nCTRL + Number to change Demo Screen\nRight click to "
|
||||
"see the PopUp Menu" );
|
||||
@@ -372,8 +372,8 @@ void EETest::createBaseUI() {
|
||||
|
||||
tWin->setTitle( "Widgets Test" );
|
||||
|
||||
tWin->addEventListener( Event::MouseUp, cb::Make1( this, &EETest::onWinMouseUp ) );
|
||||
C->addEventListener( Event::MouseUp, cb::Make1( this, &EETest::onWinMouseUp ) );
|
||||
tWin->addEventListener( Event::MouseUp, [this]( auto event ) { onWinMouseUp( event ); } );
|
||||
C->addEventListener( Event::MouseUp, [this]( auto event ) { onWinMouseUp( event ); } );
|
||||
|
||||
UISprite* sprite = UISprite::New();
|
||||
sprite->setFlags( UI_AUTO_SIZE );
|
||||
@@ -397,7 +397,7 @@ void EETest::createBaseUI() {
|
||||
Button->setParent( C )->setPosition( 225, 215 )->setSize( 90, 0 );
|
||||
Button->setIcon( mSceneNode->findIconDrawable( "ok", PixelDensity::dpToPxI( 16 ) ) );
|
||||
Button->setText( "Click Me" );
|
||||
Button->addEventListener( Event::MouseClick, cb::Make1( this, &EETest::onButtonClick ) );
|
||||
Button->addEventListener( Event::MouseClick, [this]( auto event ) { onButtonClick( event ); } );
|
||||
Button->setTooltipText( "Click and see what happens..." );
|
||||
|
||||
UICheckBox* Checkbox = UICheckBox::New();
|
||||
@@ -418,7 +418,7 @@ void EETest::createBaseUI() {
|
||||
->setPosition( 220, 80 )
|
||||
->setSize( 80, 24 );
|
||||
mSlider->addEventListener( Event::OnValueChange,
|
||||
cb::Make1( this, &EETest::onSliderValueChange ) );
|
||||
[this]( auto event ) { onSliderValueChange( event ); } );
|
||||
|
||||
UISlider::New()
|
||||
->setOrientation( UIOrientation::Vertical )
|
||||
@@ -437,7 +437,8 @@ void EETest::createBaseUI() {
|
||||
|
||||
mScrollBar = UIScrollBar::New();
|
||||
mScrollBar->setParent( C )->setSize( 0, 240 );
|
||||
mScrollBar->addEventListener( Event::OnValueChange, cb::Make1( this, &EETest::onValueChange ) );
|
||||
mScrollBar->addEventListener( Event::OnValueChange,
|
||||
[this]( auto event ) { onValueChange( event ); } );
|
||||
|
||||
mProgressBar = UIProgressBar::New();
|
||||
mProgressBar->setParent( C )->setSize( 200, 24 )->setPosition( 20, 190 );
|
||||
@@ -559,12 +560,12 @@ void EETest::createBaseUI() {
|
||||
Menu->addSeparator();
|
||||
Menu->add( "Quit" );
|
||||
|
||||
Menu->addEventListener( Event::OnItemClicked, cb::Make1( this, &EETest::onItemClick ) );
|
||||
Menu->addEventListener( Event::OnItemClicked, [this]( auto event ) { onItemClick( event ); } );
|
||||
Menu->getItem( "Quit" )->addEventListener( Event::MouseUp,
|
||||
cb::Make1( this, &EETest::onQuitClick ) );
|
||||
[this]( auto event ) { onQuitClick( event ); } );
|
||||
|
||||
SceneManager::instance()->getUISceneNode()->getRoot()->addEventListener(
|
||||
Event::MouseClick, cb::Make1( this, &EETest::onMainClick ) );
|
||||
Event::MouseClick, [this]( auto event ) { onMainClick( event ); } );
|
||||
|
||||
#ifdef EE_PLATFORM_TOUCH
|
||||
UISkin nSkin( "button-te" );
|
||||
@@ -584,7 +585,7 @@ void EETest::createBaseUI() {
|
||||
mShowMenu->setPosition( screenSize.getWidth() - mShowMenu->getSize().getWidth() - 32,
|
||||
screenSize.getHeight() - mShowMenu->getSize().getHeight() - 9 );
|
||||
mShowMenu->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM );
|
||||
mShowMenu->addEventListener( Event::MouseClick, cb::Make1( this, &EETest::onShowMenu ) );
|
||||
mShowMenu->addEventListener( Event::MouseClick, [this]( auto event ) { onShowMenu( event ); } );
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -659,9 +660,10 @@ void EETest::createNewUI() {
|
||||
scrollView->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent )
|
||||
->setParent( relLay );
|
||||
scrollView->getContainer()->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &EETest::onMainClick ) );
|
||||
[this]( auto event ) { onMainClick( event ); } );
|
||||
container->setParent( scrollView );
|
||||
container->addEventListener( Event::MouseClick, cb::Make1( this, &EETest::onMainClick ) );
|
||||
container->addEventListener( Event::MouseClick,
|
||||
[this]( auto event ) { onMainClick( event ); } );
|
||||
|
||||
UILoader* loader = UILoader::New();
|
||||
loader->setOutlineThickness( 4 )
|
||||
@@ -1011,7 +1013,7 @@ void EETest::createMapEditor() {
|
||||
tWin->setStyleConfig( windowStyleConfig );
|
||||
|
||||
Clock mapEditorTime;
|
||||
mMapEditor = MapEditor::New( tWin, cb::Make0( this, &EETest::onMapEditorClose ) );
|
||||
mMapEditor = MapEditor::New( tWin, [this] { onMapEditorClose(); } );
|
||||
Log::info( "Map Editor created in: %s.", mapEditorTime.getElapsedTime().toString().c_str() );
|
||||
tWin->center();
|
||||
tWin->show();
|
||||
@@ -1076,7 +1078,8 @@ void EETest::createDecoratedWindow() {
|
||||
->setMinWindowSize( 530, 350 )
|
||||
->setPosition( 200, 50 );
|
||||
|
||||
mUIWindow->addEventListener( Event::OnWindowClose, cb::Make1( this, &EETest::onCloseClick ) );
|
||||
mUIWindow->addEventListener( Event::OnWindowClose,
|
||||
[this]( auto event ) { onCloseClick( event ); } );
|
||||
mUIWindow->setTitle( "Test Window" );
|
||||
mUIWindow->addEventListener( Event::OnDragStart, onWinDragStart );
|
||||
mUIWindow->addEventListener( Event::OnDragStop, onWinDragStop );
|
||||
@@ -1138,7 +1141,7 @@ void EETest::createDecoratedWindow() {
|
||||
Button->setText( "Click Me" );
|
||||
Button->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent )
|
||||
->setParent( lay );
|
||||
Button->addEventListener( Event::MouseClick, cb::Make1( this, &EETest::onButtonClick ) );
|
||||
Button->addEventListener( Event::MouseClick, [this]( auto event ) { onButtonClick( event ); } );
|
||||
|
||||
mUIWindow->setKeyBindingCommand( "button-click", [this] { addFlyingIcon(); } );
|
||||
mUIWindow->addKeyBinding( { KEY_C, KEYMOD_LALT }, "button-click" );
|
||||
@@ -1380,7 +1383,7 @@ void EETest::loadTextures() {
|
||||
SndMng.loadFromFile( "mysound", MyPath + "sounds/sound.ogg" );
|
||||
|
||||
mResLoad.setThreaded( EE->isSharedGLContextEnabled() );
|
||||
mResLoad.load( cb::Make1( this, &EETest::onTextureLoaded ) );
|
||||
mResLoad.load( [this]( auto event ) { onTextureLoaded( event ); } );
|
||||
|
||||
TN.resize( 12 );
|
||||
TNP.resize( 12 );
|
||||
@@ -1423,7 +1426,8 @@ void EETest::loadTextures() {
|
||||
SP.addFrame( TN[4], Sizef( 0, 0 ), Vector2i( 0, 0 ),
|
||||
Rect( mx * 64, my * 64, mx * 64 + 64, my * 64 + 64 ) );
|
||||
|
||||
PS[0].setCallbackReset( cb::Make2( this, &EETest::particlesCallback ) );
|
||||
PS[0].setCallbackReset(
|
||||
[this]( Particle* P, ParticleSystem* Me ) { particlesCallback( P, Me ); } );
|
||||
PS[0].create( ParticleEffect::Callback, 500, TN[5], Vector2f( 0, 0 ), 16, true );
|
||||
PS[1].create( ParticleEffect::Heal, 250, TN[5],
|
||||
Vector2f( mWindow->getWidth() * 0.5f, mWindow->getHeight() * 0.5f ), 16, true );
|
||||
@@ -2355,7 +2359,8 @@ cpBool EETest::catcherBarBegin( Arbiter* arb, Physics::Space*, void* ) {
|
||||
|
||||
emitter->queue++;
|
||||
|
||||
mSpace->addPostStepCallback( cb::Make3( this, &EETest::postStepRemove ), b, NULL );
|
||||
mSpace->addPostStepCallback(
|
||||
[this]( Space* s, void* tshape, void* v ) { postStepRemove( s, tshape, v ); }, b, NULL );
|
||||
|
||||
return cpFalse;
|
||||
}
|
||||
@@ -2391,15 +2396,17 @@ void EETest::demo2Create() {
|
||||
Space::CollisionHandler handler;
|
||||
handler.a = BLOCKING_SENSOR_TYPE;
|
||||
handler.b = BALL_TYPE;
|
||||
handler.begin = cb::Make3( this, &EETest::blockerBegin );
|
||||
handler.separate = cb::Make3( this, &EETest::blockerSeparate );
|
||||
handler.begin = [this]( Arbiter* arb, Space* s, void* v ) { return blockerBegin( arb, s, v ); };
|
||||
handler.separate = [this]( Arbiter* arb, Space* s, void* v ) { blockerSeparate( arb, s, v ); };
|
||||
mSpace->addCollisionHandler( handler );
|
||||
|
||||
handler.reset(); // Reset all the values and the callbacks ( set the callbacks as !IsSet()
|
||||
|
||||
handler.a = CATCH_SENSOR_TYPE;
|
||||
handler.b = BALL_TYPE;
|
||||
handler.begin = cb::Make3( this, &EETest::catcherBarBegin );
|
||||
handler.begin = [this]( Arbiter* arb, Physics::Space* s, void* v ) {
|
||||
return catcherBarBegin( arb, s, v );
|
||||
};
|
||||
mSpace->addCollisionHandler( handler );
|
||||
}
|
||||
|
||||
@@ -2448,14 +2455,14 @@ void EETest::physicsCreate() {
|
||||
|
||||
physicDemo demo;
|
||||
|
||||
demo.init = cb::Make0( this, &EETest::demo1Create );
|
||||
demo.update = cb::Make0( this, &EETest::demo1Update );
|
||||
demo.destroy = cb::Make0( this, &EETest::demo1Destroy );
|
||||
demo.init = [this] { demo1Create(); };
|
||||
demo.update = [this] { demo1Update(); };
|
||||
demo.destroy = [this] { demo1Destroy(); };
|
||||
mDemo.push_back( demo );
|
||||
|
||||
demo.init = cb::Make0( this, &EETest::demo2Create );
|
||||
demo.update = cb::Make0( this, &EETest::demo2Update );
|
||||
demo.destroy = cb::Make0( this, &EETest::demo2Destroy );
|
||||
demo.init = [this] { demo2Create(); };
|
||||
demo.update = [this] { demo2Update(); };
|
||||
demo.destroy = [this] { demo2Destroy(); };
|
||||
mDemo.push_back( demo );
|
||||
|
||||
changeDemo( 0 );
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "globalsearchcontroller.hpp"
|
||||
#include "ecode.hpp"
|
||||
#include "globalsearchcontroller.hpp"
|
||||
#include "uitreeviewglobalsearch.hpp"
|
||||
|
||||
namespace ecode {
|
||||
@@ -33,6 +33,26 @@ static bool replaceInFile( const std::string& path, const std::string& replaceTe
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool replaceInFile( const std::string& path, const std::vector<std::string>& replaceTexts,
|
||||
const std::vector<std::pair<Int64, Int64>>& replacements ) {
|
||||
std::string data;
|
||||
if ( !FileSystem::fileGet( path, data ) )
|
||||
return false;
|
||||
|
||||
Int64 diff = 0;
|
||||
int pos = 0;
|
||||
for ( const auto& range : replacements ) {
|
||||
data.replace( range.first + diff, range.second - range.first, replaceTexts[pos] );
|
||||
diff += replaceTexts[pos].size() - ( range.second - range.first );
|
||||
pos++;
|
||||
}
|
||||
|
||||
if ( !FileSystem::fileWrite( path, (const Uint8*)data.c_str(), data.size() ) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t GlobalSearchController::replaceInFiles( const std::string& replaceText,
|
||||
std::shared_ptr<ProjectSearch::ResultModel> model ) {
|
||||
size_t count = 0;
|
||||
@@ -42,6 +62,39 @@ size_t GlobalSearchController::replaceInFiles( const std::string& replaceText,
|
||||
}
|
||||
|
||||
const ProjectSearch::Result& res = model.get()->getResult();
|
||||
bool hasCaptures =
|
||||
model->isResultFromLuaPattern() && LuaPattern::find( replaceText, "$%d+" ).isValid();
|
||||
|
||||
if ( hasCaptures ) {
|
||||
for ( const auto& fileResult : res ) {
|
||||
std::vector<std::pair<Int64, Int64>> replacements;
|
||||
std::vector<std::string> replaceTexts;
|
||||
|
||||
for ( const auto& result : fileResult.results ) {
|
||||
if ( !result.selected )
|
||||
continue;
|
||||
replacements.push_back( { result.start, result.end } );
|
||||
std::string newText( replaceText );
|
||||
LuaPattern ptrn( "$(%d+)" );
|
||||
for ( auto& match : ptrn.gmatch( replaceText ) ) {
|
||||
std::string matchSubStr( match.group( 0 ) ); // $1 $2 ...
|
||||
std::string matchNum( match.group( 1 ) ); // 1 2 ...
|
||||
int num;
|
||||
if ( String::fromString( num, matchNum ) && num > 0 &&
|
||||
num - 1 < static_cast<int>( result.captures.size() ) ) {
|
||||
String::replaceAll( newText, matchSubStr, result.captures[num - 1] );
|
||||
replaceTexts.emplace_back( std::move( newText ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( replacements.size() == replaceTexts.size() &&
|
||||
replaceInFile( fileResult.file, replaceTexts, replacements ) )
|
||||
count += replacements.size();
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
for ( const auto& fileResult : res ) {
|
||||
std::vector<std::pair<Int64, Int64>> replacements;
|
||||
@@ -116,13 +169,12 @@ void GlobalSearchController::initGlobalSearchBar(
|
||||
mGlobalSearchHistoryList =
|
||||
mGlobalSearchBarLayout->find<UIDropDownList>( "global_search_history" );
|
||||
mGlobalSearchBarLayout->setCommand( "global-search-clear-history", [this] { clearHistory(); } );
|
||||
mGlobalSearchBarLayout->setCommand(
|
||||
"search-in-files",
|
||||
[this, caseSensitiveChk, wholeWordChk, luaPatternChk, escapeSequenceChk] {
|
||||
doGlobalSearch( mGlobalSearchInput->getText(), caseSensitiveChk->isChecked(),
|
||||
wholeWordChk->isChecked(), luaPatternChk->isChecked(),
|
||||
escapeSequenceChk->isChecked(), false );
|
||||
} );
|
||||
mGlobalSearchBarLayout->setCommand( "search-in-files", [this, caseSensitiveChk, wholeWordChk,
|
||||
luaPatternChk, escapeSequenceChk] {
|
||||
doGlobalSearch( mGlobalSearchInput->getText(), caseSensitiveChk->isChecked(),
|
||||
wholeWordChk->isChecked(), luaPatternChk->isChecked(),
|
||||
escapeSequenceChk->isChecked(), false );
|
||||
} );
|
||||
mGlobalSearchBarLayout->setCommand(
|
||||
"search-again", [this, caseSensitiveChk, wholeWordChk, luaPatternChk, escapeSequenceChk] {
|
||||
auto listBox = mGlobalSearchHistoryList->getListBox();
|
||||
@@ -275,22 +327,22 @@ void GlobalSearchController::initGlobalSearchBar(
|
||||
escapeSequenceChk->isChecked(), true );
|
||||
}
|
||||
} );
|
||||
mGlobalSearchBarLayout->setCommand( "replace-in-files", [this, replaceInput,
|
||||
escapeSequenceChk] {
|
||||
auto listBox = mGlobalSearchHistoryList->getListBox();
|
||||
if ( listBox->getItemSelectedIndex() < mGlobalSearchHistory.size() ) {
|
||||
const auto& replaceData = mGlobalSearchHistory[mGlobalSearchHistory.size() - 1 -
|
||||
listBox->getItemSelectedIndex()];
|
||||
String text( replaceInput->getText() );
|
||||
if ( escapeSequenceChk->isChecked() )
|
||||
text.unescape();
|
||||
size_t count = replaceInFiles( text.toUtf8(), replaceData.second );
|
||||
mGlobalSearchBarLayout->execute( "search-again" );
|
||||
mGlobalSearchBarLayout->execute( "close-global-searchbar" );
|
||||
mApp->getNotificationCenter()->addNotification(
|
||||
String::format( "Replaced %zu occurrences.", count ) );
|
||||
}
|
||||
} );
|
||||
mGlobalSearchBarLayout->setCommand(
|
||||
"replace-in-files", [this, replaceInput, escapeSequenceChk] {
|
||||
auto listBox = mGlobalSearchHistoryList->getListBox();
|
||||
if ( listBox->getItemSelectedIndex() < mGlobalSearchHistory.size() ) {
|
||||
const auto& replaceData = mGlobalSearchHistory[mGlobalSearchHistory.size() - 1 -
|
||||
listBox->getItemSelectedIndex()];
|
||||
String text( replaceInput->getText() );
|
||||
if ( escapeSequenceChk->isChecked() )
|
||||
text.unescape();
|
||||
size_t count = replaceInFiles( text.toUtf8(), replaceData.second );
|
||||
mGlobalSearchBarLayout->execute( "search-again" );
|
||||
mGlobalSearchBarLayout->execute( "close-global-searchbar" );
|
||||
mApp->getNotificationCenter()->addNotification(
|
||||
String::format( "Replaced %zu occurrences.", count ) );
|
||||
}
|
||||
} );
|
||||
mGlobalSearchTreeSearch =
|
||||
UITreeViewGlobalSearch::New( mSplitter->getCurrentColorScheme(), false );
|
||||
mGlobalSearchTreeReplace =
|
||||
@@ -500,14 +552,15 @@ void GlobalSearchController::doGlobalSearch( String text, bool caseSensitive, bo
|
||||
#if EE_PLATFORM != EE_PLATFORM_EMSCRIPTEN || defined( __EMSCRIPTEN_PTHREADS__ )
|
||||
mApp->getThreadPool(),
|
||||
#endif
|
||||
[this, clock, search, loader, searchReplace, searchAgain,
|
||||
escapeSequence]( const ProjectSearch::Result& res ) {
|
||||
[this, clock, search, loader, searchReplace, searchAgain, escapeSequence,
|
||||
luaPattern]( const ProjectSearch::Result& res ) {
|
||||
Log::info( "Global search for \"%s\" took %.2fms", search.c_str(),
|
||||
clock->getElapsedTime().asMilliseconds() );
|
||||
eeDelete( clock );
|
||||
mUISceneNode->runOnMainThread( [this, loader, res, search, searchReplace,
|
||||
searchAgain, escapeSequence] {
|
||||
searchAgain, escapeSequence, luaPattern] {
|
||||
auto model = ProjectSearch::asModel( res );
|
||||
model->setResultFromLuaPattern( luaPattern );
|
||||
updateGlobalSearchHistory( model, search, searchReplace, searchAgain,
|
||||
escapeSequence );
|
||||
updateGlobalSearchBarResults( search, model, searchReplace, escapeSequence );
|
||||
|
||||
@@ -25,7 +25,7 @@ static int countNewLines( const std::string& text, const size_t& start, const si
|
||||
return count;
|
||||
}
|
||||
|
||||
static String textLine( const std::string& fileText, const size_t& fromPos, size_t& relCol ) {
|
||||
static String textLine( const std::string& fileText, const size_t& fromPos, Int64& relCol ) {
|
||||
const char* stringStartPtr = fileText.c_str();
|
||||
const char* startPtr = fileText.c_str() + fromPos;
|
||||
const char* endPtr = startPtr;
|
||||
@@ -68,7 +68,7 @@ searchInFileHorspool( const std::string& file, const std::string& text, const bo
|
||||
searchRes += text.size();
|
||||
continue;
|
||||
}
|
||||
size_t relCol;
|
||||
Int64 relCol;
|
||||
totNl += countNewLines( fileText, lSearchRes, searchRes );
|
||||
String str(
|
||||
textLine( caseSensitive ? fileText : fileTextOriginal, searchRes, relCol ) );
|
||||
@@ -91,8 +91,8 @@ searchInFileLuaPattern( const std::string& file, const std::string& text, const
|
||||
std::string fileText;
|
||||
FileSystem::fileGet( file, fileText );
|
||||
LuaPattern pattern( text );
|
||||
std::vector<ProjectSearch::ResultData::Result> res;
|
||||
size_t totNl = 0;
|
||||
std::vector<ProjectSearch::ResultData::Result> results;
|
||||
Int64 totNl = 0;
|
||||
bool matched = false;
|
||||
Int64 searchRes = 0;
|
||||
std::string fileTextOriginal;
|
||||
@@ -102,28 +102,43 @@ searchInFileLuaPattern( const std::string& file, const std::string& text, const
|
||||
String::toLowerInPlace( fileText );
|
||||
}
|
||||
|
||||
LuaPattern::Range matches[12];
|
||||
do {
|
||||
int start, end = 0;
|
||||
if ( ( matched = pattern.find( fileText, start, end, searchRes ) ) ) {
|
||||
|
||||
if ( ( matched = pattern.matches( fileText, matches, searchRes ) ) ) {
|
||||
start = matches[0].start;
|
||||
end = matches[0].end;
|
||||
|
||||
if ( wholeWord &&
|
||||
!String::isWholeWord( fileText, fileText.substr( start, end - start ), start ) ) {
|
||||
searchRes = end;
|
||||
continue;
|
||||
}
|
||||
size_t relCol;
|
||||
|
||||
Int64 relCol;
|
||||
totNl += countNewLines( fileText, searchRes, start );
|
||||
String str( textLine( caseSensitive ? fileText : fileTextOriginal, start, relCol ) );
|
||||
int len = end - start;
|
||||
res.push_back(
|
||||
{ str,
|
||||
{ { (Int64)totNl, (Int64)relCol }, { (Int64)totNl, (Int64)( relCol + len ) } },
|
||||
start,
|
||||
end } );
|
||||
ProjectSearch::ResultData::Result res;
|
||||
res.line = std::move( str );
|
||||
res.position = { { totNl, (Int64)relCol }, { totNl, (Int64)( relCol + len ) } };
|
||||
res.start = start;
|
||||
res.end = end;
|
||||
for ( size_t c = 1; c < 12; c++ ) {
|
||||
if ( matches[c].isValid() ) {
|
||||
res.captures.push_back(
|
||||
fileText.substr( matches[c].start, matches[c].end - matches[c].start ) );
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
results.emplace_back( std::move( res ) );
|
||||
searchRes = end;
|
||||
}
|
||||
} while ( matched );
|
||||
|
||||
return res;
|
||||
return results;
|
||||
}
|
||||
|
||||
void ProjectSearch::find( const std::vector<std::string> files, const std::string& string,
|
||||
|
||||
@@ -28,6 +28,7 @@ class ProjectSearch {
|
||||
Int64 start{ 0 };
|
||||
Int64 end{ 0 };
|
||||
bool selected{ true };
|
||||
std::vector<std::string> captures;
|
||||
};
|
||||
std::string file;
|
||||
std::vector<Result> results;
|
||||
@@ -190,9 +191,14 @@ class ProjectSearch {
|
||||
|
||||
bool isResultFromSymbolReference() const { return mResultFromSymbolReference; }
|
||||
|
||||
void setResultFromLuaPattern( bool ref ) { mResultFromLuaPattern = ref; }
|
||||
|
||||
bool isResultFromLuaPattern() const { return mResultFromLuaPattern; }
|
||||
|
||||
protected:
|
||||
Result mResult;
|
||||
bool mResultFromSymbolReference{ false };
|
||||
bool mResultFromLuaPattern{ false };
|
||||
};
|
||||
|
||||
static std::shared_ptr<ResultModel> asModel( const Result& result ) {
|
||||
|
||||
Reference in New Issue
Block a user