@@ -157,25 +157,56 @@ void CContentView::DrawHeader()
157
157
DrawByPathLambda (CurrentDir);
158
158
}
159
159
160
+
160
161
int FindStartPosX = (int )ImGui::GetWindowSize ().x ;
161
- if (FindStartPosX > 300 )
162
+
163
+ float w = 0 ;
164
+
165
+ if (FindStartPosX > 400 )
162
166
{
163
167
ImGui::SameLine ();
164
168
int FindSizeX = FindStartPosX / 3 .5f ;
165
169
FindStartPosX -= FindSizeX;
166
170
167
171
ImGui::SetCursorPosX (FindStartPosX);
168
- ImGui::SetNextItemWidth (FindSizeX - 35 );
172
+
173
+ w = FindSizeX - 35 ;
169
174
}
170
175
else
171
176
{
172
- ImGui::SetNextItemWidth ( FindStartPosX - 45 ) ;
177
+ w = FindStartPosX - 45 ;
173
178
}
174
179
180
+ IconData* IconPtr = &GetTexture (" search" );
181
+ ImVec2 IconSize{ 0 ,0 };
182
+
183
+ // Varian 1
184
+ /* if (IconPtr->Icon)
185
+ {
186
+ IconSize={ 16,16 };
187
+ ImGui::Image(IconPtr->Icon->pSurface, IconSize);
188
+ ImGui::SameLine();
189
+ }*/
190
+
191
+ ImGui::SetNextItemWidth (w - IconSize.x *1 .5f );
192
+
175
193
if (ImGui::InputTextWithHint (" ##Search" , " Search" , FindStr, sizeof (FindStr)))
176
194
{
177
195
FindFile ();
178
196
}
197
+
198
+ // Varian 2
199
+ if (IconPtr->Icon )
200
+ {
201
+ IconSize = { 12 ,12 };
202
+
203
+ ImGui::SameLine ();
204
+ ImVec2 cursorPos = ImGui::GetCursorPos ();
205
+ ImGui::SetCursorPos (ImVec2 (cursorPos.x - IconSize.x -10 .f , cursorPos.y +(IconSize.y /4 )));
206
+
207
+ ImGui::Image (IconPtr->Icon ->pSurface , IconSize);
208
+ }
209
+
179
210
ImGui::SameLine ();
180
211
181
212
if (ImGui::BeginPopupContextItem (" MenuCBPpp" ))
@@ -195,7 +226,7 @@ void CContentView::DrawHeader()
195
226
196
227
ImGui::EndMenu ();
197
228
}
198
-
229
+
199
230
ImGui::EndPopup ();
200
231
}
201
232
@@ -561,6 +592,8 @@ void CContentView::Init()
561
592
Icons[" backup" ] = {EDevice->Resources ->_CreateTexture (" ed\\ content_browser\\ backup" ), true };
562
593
Icons[" env_mod" ]= {EDevice->Resources ->_CreateTexture (" ed\\ content_browser\\ env_mod" ), true };
563
594
595
+ Icons[" search" ]= {EDevice->Resources ->_CreateTexture (" ed\\ content_browser\\ search" ), false };
596
+
564
597
MenuIcon = EDevice->Resources ->_CreateTexture (" ed\\ bar\\ menu" );
565
598
}
566
599
@@ -598,6 +631,9 @@ bool CContentView::DrawItemByList(const FileOptData& InitFileName, size_t& HorBt
598
631
if (!IconPtr->Icon )
599
632
return false ;
600
633
634
+ if (FilePath == CopyObjectPath && IsCutting)
635
+ IconColor.w = 0.3 ;
636
+
601
637
OutValue = ImGui::ImageButton
602
638
(
603
639
FileName.c_str (),
@@ -607,7 +643,12 @@ bool CContentView::DrawItemByList(const FileOptData& InitFileName, size_t& HorBt
607
643
);
608
644
}
609
645
610
- DrawItemHelper (FilePath, FileName, InitFileName, IconPtr);
646
+ ImVec4 TextColor = ImVec4 (1 , 1 , 1 , 1 );
647
+
648
+ bool RenameThisItem = RenameObject.Active && RenameObject.Path == FilePath;
649
+
650
+ if (!RenameThisItem && DrawItemHelper (FilePath, FileName, InitFileName, IconPtr))
651
+ TextColor.w = 0.3 ;
611
652
612
653
ImVec2 NextCursorPos = ImGui::GetCursorPos ();
613
654
ImGui::SameLine ();
@@ -617,83 +658,122 @@ bool CContentView::DrawItemByList(const FileOptData& InitFileName, size_t& HorBt
617
658
StartCursorPos.y -= (TextHeight + 2 ) ;
618
659
ImGui::SetCursorPos (StartCursorPos);
619
660
620
- ImGui::Text (Platform::ANSI_TO_UTF8 (FileName).c_str ());
661
+ if (RenameObject.Path == FilePath)
662
+ {
663
+ if (RenameObject.Active )
664
+ {
665
+ if (RenameObject.SetText )
666
+ {
667
+ RenameObject.SetText = false ;
668
+ RenameObject.RenameBuf = Platform::ANSI_TO_UTF8 (FileName).c_str ();
669
+ ImGui::SetKeyboardFocusHere ();
670
+ }
671
+
672
+ ImGuiIO& io = ImGui::GetIO ();
673
+
674
+ if (ImGui::InputText (" ##ren" , RenameObject.RenameBuf .data (), 255 , ImGuiInputTextFlags_EnterReturnsTrue))
675
+ RenameObject.Active = false ;
676
+
677
+ if (io.KeysDown [ImGuiKey_Escape])
678
+ RenameActionEnd ();
679
+
680
+ RenameObject.Focus = ImGui::IsItemHovered ();
681
+ }
682
+ else
683
+ {
684
+ if (strcmp (Platform::ANSI_TO_UTF8 (FileName).c_str (), RenameObject.RenameBuf .c_str ()))
685
+ RenameAction (FilePath, RenameObject.RenameBuf .c_str ());
686
+
687
+ RenameActionEnd ();
688
+ }
689
+ }
690
+ else
691
+ {
692
+ ImGui::TextColored (TextColor, Platform::ANSI_TO_UTF8 (FileName).c_str ());
693
+
694
+ if (ImGui::IsMouseDoubleClicked (0 ) && ImGui::IsItemHovered ())
695
+ {
696
+ if (FilePath.xstring () != " .." && !FilePath.parent_path ().empty () && !IsSpawnElement)
697
+ RenameActionActivate (FilePath);
698
+ }
699
+ }
621
700
622
701
StartCursorPos.y += TextHeight + 2 .f ;
623
702
ImGui::SetCursorPos (StartCursorPos);
624
703
625
704
ImVec4 TooltipTextColor = ImGui::GetStyle ().Colors [ImGuiCol_Text];
626
705
TooltipTextColor.w *= 0 .5f ;
627
706
628
- if (InitFileName.IsDir )
629
- {
630
- ImGui::TextColored (TooltipTextColor, " Directory" );
631
- }
632
- else if (FileName.ends_with (" .dds" ))
633
- {
634
- ImGui::TextColored (TooltipTextColor, " Texture Asset" );
635
- }
636
- else if (FileName.ends_with (" .tga" ))
637
- {
638
- ImGui::TextColored (TooltipTextColor, " Raw Texture Asset" );
639
- }
640
- else if (FileName.ends_with (" .png" ))
641
- {
642
- ImGui::TextColored (TooltipTextColor, " Image" );
643
- }
644
- else if (FileName.ends_with (" .object" ))
645
- {
646
- ImGui::TextColored (TooltipTextColor, " Object Asset" );
647
- }
648
- else if (FileName.ends_with (" .group" ))
649
- {
650
- ImGui::TextColored (TooltipTextColor, " Group object Asset" );
651
- }
652
- else if (FileName.ends_with (" .ogf" ))
653
- {
654
- ImGui::TextColored (TooltipTextColor, " Object" );
655
- }
656
- else if (FileName.ends_with (" .wav" ))
657
- {
658
- ImGui::TextColored (TooltipTextColor, " Raw Sound" );
659
- }
660
- else if (FileName.ends_with (" .ogg" ))
661
- {
662
- ImGui::TextColored (TooltipTextColor, " Sound Asset" );
663
- }
664
- else if (FileName.ends_with (" .ise" ))
665
- {
666
- ImGui::TextColored (TooltipTextColor, " Spawn Component" );
667
- }
668
- else if (FileName.ends_with (" .skl" ))
669
- {
670
- ImGui::TextColored (TooltipTextColor, " Raw Single Animation Asset" );
671
- }
672
- else if (FileName.ends_with (" .skls" ))
673
- {
674
- ImGui::TextColored (TooltipTextColor, " Raw Animations Asset" );
675
- }
676
- else if (FileName.ends_with (" .omf" ))
677
- {
678
- ImGui::TextColored (TooltipTextColor, " Animations Asset" );
679
- }
680
- else if (FileName.ends_with (" .ltx" ))
681
707
{
682
- xr_string PathName = FilePath;
683
- if (PathName.Contains (" scripts\\ " ))
708
+ if (InitFileName.IsDir )
684
709
{
685
- ImGui::TextColored (TooltipTextColor, " Logic Preference " );
710
+ ImGui::TextColored (TooltipTextColor, " Directory " );
686
711
}
687
- else
712
+ else if (FileName. ends_with ( " .dds " ))
688
713
{
689
- ImGui::TextColored (TooltipTextColor, " Config" );
714
+ ImGui::TextColored (TooltipTextColor, " Texture Asset" );
715
+ }
716
+ else if (FileName.ends_with (" .tga" ))
717
+ {
718
+ ImGui::TextColored (TooltipTextColor, " Raw Texture Asset" );
719
+ }
720
+ else if (FileName.ends_with (" .png" ))
721
+ {
722
+ ImGui::TextColored (TooltipTextColor, " Image" );
723
+ }
724
+ else if (FileName.ends_with (" .object" ))
725
+ {
726
+ ImGui::TextColored (TooltipTextColor, " Object Asset" );
727
+ }
728
+ else if (FileName.ends_with (" .group" ))
729
+ {
730
+ ImGui::TextColored (TooltipTextColor, " Group object Asset" );
731
+ }
732
+ else if (FileName.ends_with (" .ogf" ))
733
+ {
734
+ ImGui::TextColored (TooltipTextColor, " Object" );
735
+ }
736
+ else if (FileName.ends_with (" .wav" ))
737
+ {
738
+ ImGui::TextColored (TooltipTextColor, " Raw Sound" );
739
+ }
740
+ else if (FileName.ends_with (" .ogg" ))
741
+ {
742
+ ImGui::TextColored (TooltipTextColor, " Sound Asset" );
743
+ }
744
+ else if (FileName.ends_with (" .ise" ))
745
+ {
746
+ ImGui::TextColored (TooltipTextColor, " Spawn Component" );
747
+ }
748
+ else if (FileName.ends_with (" .skl" ))
749
+ {
750
+ ImGui::TextColored (TooltipTextColor, " Raw Single Animation Asset" );
751
+ }
752
+ else if (FileName.ends_with (" .skls" ))
753
+ {
754
+ ImGui::TextColored (TooltipTextColor, " Raw Animations Asset" );
755
+ }
756
+ else if (FileName.ends_with (" .omf" ))
757
+ {
758
+ ImGui::TextColored (TooltipTextColor, " Animations Asset" );
759
+ }
760
+ else if (FileName.ends_with (" .ltx" ))
761
+ {
762
+ xr_string PathName = FilePath;
763
+ if (PathName.Contains (" scripts\\ " ))
764
+ {
765
+ ImGui::TextColored (TooltipTextColor, " Logic Preference" );
766
+ }
767
+ else
768
+ {
769
+ ImGui::TextColored (TooltipTextColor, " Config" );
770
+ }
771
+ }
772
+ else if (FileName.ends_with (" .script" ))
773
+ {
774
+ ImGui::TextColored (TooltipTextColor, " Lua Script" );
690
775
}
691
776
}
692
- else if (FileName.ends_with (" .script" ))
693
- {
694
- ImGui::TextColored (TooltipTextColor, " Lua Script" );
695
- }
696
-
697
777
ImGui::SetCursorPos (NextCursorPos);
698
778
ImGui::Separator ();
699
779
@@ -713,6 +793,9 @@ void CContentView::AcceptDragDropAction(xr_path& FilePath)
713
793
if (ImData == nullptr )
714
794
ImData = ImGui::AcceptDragDropPayload (" FLDR" );
715
795
796
+ if (ImData == nullptr )
797
+ ImData = ImGui::AcceptDragDropPayload (" OTHR" );
798
+
716
799
if (ImData != nullptr )
717
800
{
718
801
if (ImData != nullptr )
@@ -752,13 +835,13 @@ bool CContentView::BeginDragDropAction(xr_path& FilePath, xr_string& FileName, c
752
835
xr_string Extension = FilePath.extension ().string ().c_str ();
753
836
WeCanDrag = Extension == " .object" || Extension == " .group" || Extension == " .ise" ;
754
837
755
- if (WeCanDrag )
838
+ if (! ImGui::BeginDragDropSource () )
756
839
{
757
- if (!ImGui::BeginDragDropSource ())
758
- {
759
- return false ;
760
- }
840
+ return false ;
841
+ }
761
842
843
+ if (WeCanDrag)
844
+ {
762
845
if (IsSpawnElement || FilePath.xstring ().ends_with (" .ise" ))
763
846
{
764
847
if (InitFileName.ISESect .size () > 0 )
@@ -775,8 +858,8 @@ bool CContentView::BeginDragDropAction(xr_path& FilePath, xr_string& FileName, c
775
858
}
776
859
else
777
860
{
778
- // ImGui::SetDragDropPayload("OTHR", & Data, sizeof(DragDropData)) ;
779
- return false ;
861
+ Data. FileName = FilePath ;
862
+ ImGui::SetDragDropPayload ( " OTHR " , &Data, sizeof (DragDropData)) ;
780
863
}
781
864
}
782
865
else
@@ -909,7 +992,7 @@ bool CContentView::DrawItemByTile(const FileOptData& InitFileName, size_t& HorBt
909
992
if (RenameObject.SetText )
910
993
{
911
994
RenameObject.SetText = false ;
912
- RenameObject.RenameBuf = LabelText;
995
+ RenameObject.RenameBuf = Platform::ANSI_TO_UTF8 ( LabelText) ;
913
996
ImGui::SetKeyboardFocusHere ();
914
997
}
915
998
@@ -918,21 +1001,16 @@ bool CContentView::DrawItemByTile(const FileOptData& InitFileName, size_t& HorBt
918
1001
ImGui::SetCursorPosX (CursorPos.x );
919
1002
ImGui::SetNextItemWidth (BtnSize.x + 10 );
920
1003
if (ImGui::InputText (" ##ren" , RenameObject.RenameBuf .data (), 255 ,ImGuiInputTextFlags_EnterReturnsTrue))
921
- {
922
1004
RenameObject.Active = false ;
923
- }
924
1005
925
- if (io.KeysDown [ImGuiKey_Escape]) {
1006
+ if (io.KeysDown [ImGuiKey_Escape])
926
1007
RenameActionEnd ();
927
- }
928
1008
929
1009
RenameObject.Focus = ImGui::IsItemHovered ();
930
1010
}
931
1011
else
932
1012
{
933
-
934
- bool c = strcmp (LabelText.c_str (), RenameObject.RenameBuf .c_str ());
935
- if (c)
1013
+ if (strcmp (Platform::ANSI_TO_UTF8 (LabelText).c_str (), RenameObject.RenameBuf .c_str ()))
936
1014
RenameAction (FilePath, RenameObject.RenameBuf .c_str ());
937
1015
938
1016
RenameActionEnd ();
@@ -957,7 +1035,6 @@ bool CContentView::DrawItemByTile(const FileOptData& InitFileName, size_t& HorBt
957
1035
RenameActionActivate (FilePath);
958
1036
}
959
1037
}
960
- // }
961
1038
962
1039
InvalidateLambda ();
963
1040
return OutValue;
@@ -1038,7 +1115,7 @@ bool CContentView::DrawContext(const xr_path& Path)
1038
1115
ImGui::Separator ();
1039
1116
}
1040
1117
1041
- if (!ShowOpen) // Actions are temporarily unavailable for levels. The logic is not worked out
1118
+ // if (!ShowOpen) //Actions are temporarily unavailable for levels. The logic is not worked out
1042
1119
{
1043
1120
if (ImGui::MenuItem (" Cut" ))
1044
1121
{
0 commit comments