@@ -80,6 +80,7 @@ namespace LevelEditor
80
80
static Feature s_prevObjectFeature = {};
81
81
static bool s_wallShownLast = false ;
82
82
static s32 s_prevCategoryFlags = 0 ;
83
+ static bool s_textInputFocused = false ;
83
84
84
85
static s32 s_groupOpen = -1 ;
85
86
static s32 s_scrollToBottom = SCROLL_FALSE;
@@ -476,30 +477,39 @@ namespace LevelEditor
476
477
const f32 iconBtnTint[] = { 103 .0f / 255 .0f , 122 .0f / 255 .0f , 139 .0f / 255 .0f , 1 .0f };
477
478
char name[64 ];
478
479
strcpy (name, s_level.name .c_str ());
479
-
480
+
480
481
ImGui::Text (" Level Name:" ); ImGui::SameLine ();
482
+
481
483
if (ImGui::InputText (" ##InputLevelName" , name, 64 ))
482
484
{
483
485
s_level.name = name;
484
486
}
487
+ s_textInputFocused |= ImGui::IsItemActive ();
488
+
485
489
ImGui::Text (" Sector Count: %u" , (u32 )s_level.sectors .size ());
486
490
ImGui::Text (" Bounds: (%0.3f, %0.3f, %0.3f)\n (%0.3f, %0.3f, %0.3f)" , s_level.bounds [0 ].x , s_level.bounds [0 ].y , s_level.bounds [0 ].z ,
487
491
s_level.bounds [1 ].x , s_level.bounds [1 ].y , s_level.bounds [1 ].z );
488
492
ImGui::Text (" Layer Range: [%d, %d]" , s_level.layerRange [0 ], s_level.layerRange [1 ]);
489
493
ImGui::LabelText (" ##GridLabel" , " Grid Height" );
490
494
ImGui::SameLine (108 .0f );
491
495
ImGui::SetNextItemWidth (80 .0f );
496
+
492
497
ImGui::InputFloat (" ##GridHeight" , &s_grid.height , 0 .0f , 0 .0f , " %0.2f" , ImGuiInputTextFlags_CharsDecimal);
498
+ s_textInputFocused |= ImGui::IsItemActive ();
493
499
494
500
ImGui::SameLine (0 .0f , 16 .0f );
495
501
ImGui::SetNextItemWidth (86 .0f );
496
502
ImGui::LabelText (" ##DepthLabel" , " View Depth" );
497
503
ImGui::SameLine (0 .0f , 8 .0f );
498
504
ImGui::SetNextItemWidth (80 .0f );
505
+
499
506
ImGui::InputFloat (" ##ViewDepth0" , &s_viewDepth[0 ], 0 .0f , 0 .0f , " %0.2f" , ImGuiInputTextFlags_CharsDecimal);
507
+ s_textInputFocused |= ImGui::IsItemActive ();
508
+
500
509
ImGui::SameLine (0 .0f , 4 .0f );
501
510
ImGui::SetNextItemWidth (80 .0f );
502
511
ImGui::InputFloat (" ##ViewDepth1" , &s_viewDepth[1 ], 0 .0f , 0 .0f , " %0.2f" , ImGuiInputTextFlags_CharsDecimal);
512
+ s_textInputFocused |= ImGui::IsItemActive ();
503
513
504
514
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize
505
515
| ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoFocusOnAppearing;
@@ -647,6 +657,7 @@ namespace LevelEditor
647
657
hadFocusX = true ;
648
658
}
649
659
}
660
+ s_textInputFocused |= ImGui::IsItemActive ();
650
661
bool lostFocusX = !ImGui::IsItemFocused () && !ImGui::IsItemHovered () && !ImGui::IsItemActive ();
651
662
652
663
ImGui::SameLine ();
@@ -658,6 +669,7 @@ namespace LevelEditor
658
669
hadFocusZ = true ;
659
670
}
660
671
}
672
+ s_textInputFocused |= ImGui::IsItemActive ();
661
673
bool lostFocusZ = !ImGui::IsItemFocused () && !ImGui::IsItemHovered () && !ImGui::IsItemActive ();
662
674
663
675
// Only update the value and add the edit when the input loses focus (clicking away or on another control) or
@@ -810,10 +822,12 @@ namespace LevelEditor
810
822
char * endPtr = nullptr ;
811
823
*value = strtol (buf, &endPtr, 10 );
812
824
}
825
+ s_textInputFocused |= ImGui::IsItemActive ();
813
826
}
814
827
else
815
828
{
816
829
result = ImGui::InputInt (labelId, value);
830
+ s_textInputFocused |= ImGui::IsItemActive ();
817
831
}
818
832
ImGui::PopItemWidth ();
819
833
return result;
@@ -832,10 +846,12 @@ namespace LevelEditor
832
846
char * endPtr = nullptr ;
833
847
*value = strtoul (buf, &endPtr, 10 );
834
848
}
849
+ s_textInputFocused |= ImGui::IsItemActive ();
835
850
}
836
851
else
837
852
{
838
853
result = ImGui::InputUInt (labelId, value);
854
+ s_textInputFocused |= ImGui::IsItemActive ();
839
855
}
840
856
ImGui::PopItemWidth ();
841
857
return result;
@@ -854,10 +870,12 @@ namespace LevelEditor
854
870
char * endPtr = nullptr ;
855
871
*value = (f32 )strtod (buf, &endPtr);
856
872
}
873
+ s_textInputFocused |= ImGui::IsItemActive ();
857
874
}
858
875
else
859
876
{
860
877
result = ImGui::InputFloat (labelId, value, 0 .0f , 0 .0f , " %.2f" );
878
+ s_textInputFocused |= ImGui::IsItemActive ();
861
879
}
862
880
ImGui::PopItemWidth ();
863
881
return result;
@@ -1006,6 +1024,15 @@ namespace LevelEditor
1006
1024
return (u32 )s_sectorInfo.size ();
1007
1025
}
1008
1026
1027
+ // TODO: Debug why this happens.
1028
+ SelectionListId selectType = selection_getCurrent ();
1029
+ if (s_editMode == LEDIT_SECTOR && selectType != SEL_SECTOR ||
1030
+ s_editMode == LEDIT_WALL && selectType != SEL_SURFACE)
1031
+ {
1032
+ assert (0 );
1033
+ return 0 ;
1034
+ }
1035
+
1009
1036
s_sectorInfo.clear ();
1010
1037
s_sectorFlags.clear ();
1011
1038
const u32 count = selection_getCount ();
@@ -1510,13 +1537,15 @@ namespace LevelEditor
1510
1537
ImGui::Text (" Mid Offset" );
1511
1538
ImGui::PushItemWidth (136 .0f );
1512
1539
changed |= ImGui::InputFloat2 (" ##MidOffsetInput" , &wall->tex [WP_MID].offset .x , " %.3f" );
1540
+ s_textInputFocused |= ImGui::IsItemActive ();
1513
1541
ImGui::PopItemWidth ();
1514
1542
1515
1543
ImGui::NewLine ();
1516
1544
1517
1545
ImGui::Text (" Sign Offset" );
1518
1546
ImGui::PushItemWidth (136 .0f );
1519
1547
changed |= ImGui::InputFloat2 (" ##SignOffsetInput" , &wall->tex [WP_SIGN].offset .x , " %.3f" );
1548
+ s_textInputFocused |= ImGui::IsItemActive ();
1520
1549
ImGui::PopItemWidth ();
1521
1550
}
1522
1551
ImGui::EndChild ();
@@ -1533,13 +1562,15 @@ namespace LevelEditor
1533
1562
ImGui::Text (" Top Offset" );
1534
1563
ImGui::PushItemWidth (136 .0f );
1535
1564
changed |= ImGui::InputFloat2 (" ##TopOffsetInput" , &wall->tex [WP_TOP].offset .x , " %.3f" );
1565
+ s_textInputFocused |= ImGui::IsItemActive ();
1536
1566
ImGui::PopItemWidth ();
1537
1567
1538
1568
ImGui::NewLine ();
1539
1569
1540
1570
ImGui::Text (" Bottom Offset" );
1541
1571
ImGui::PushItemWidth (136 .0f );
1542
1572
changed |= ImGui::InputFloat2 (" ##BotOffsetInput" , &wall->tex [WP_BOT].offset .x , " %.3f" );
1573
+ s_textInputFocused |= ImGui::IsItemActive ();
1543
1574
ImGui::PopItemWidth ();
1544
1575
}
1545
1576
ImGui::EndChild ();
@@ -1669,6 +1700,7 @@ namespace LevelEditor
1669
1700
sector->name = sectorName;
1670
1701
changed = true ;
1671
1702
}
1703
+ s_textInputFocused |= ImGui::IsItemActive ();
1672
1704
ImGui::PopItemWidth ();
1673
1705
if (otherNameId >= 0 ) { ImGui::PopStyleColor (); }
1674
1706
@@ -1812,13 +1844,15 @@ namespace LevelEditor
1812
1844
ImGui::Text (" Floor Offset" );
1813
1845
ImGui::PushItemWidth (136 .0f );
1814
1846
changed |= ImGui::InputFloat2 (" ##FloorOffsetInput" , §or->floorTex .offset .x , " %.3f" );
1847
+ s_textInputFocused |= ImGui::IsItemActive ();
1815
1848
ImGui::PopItemWidth ();
1816
1849
1817
1850
ImGui::NewLine ();
1818
1851
1819
1852
ImGui::Text (" Ceil Offset" );
1820
1853
ImGui::PushItemWidth (136 .0f );
1821
1854
changed |= ImGui::InputFloat2 (" ##CeilOffsetInput" , §or->ceilTex .offset .x , " %.3f" );
1855
+ s_textInputFocused |= ImGui::IsItemActive ();
1822
1856
ImGui::PopItemWidth ();
1823
1857
}
1824
1858
ImGui::EndChild ();
@@ -2208,6 +2242,7 @@ namespace LevelEditor
2208
2242
{
2209
2243
s_objEntity.name = name;
2210
2244
}
2245
+ s_textInputFocused |= ImGui::IsItemActive ();
2211
2246
ImGui::SameLine (0 .0f , 16 .0f );
2212
2247
// Entity Class/Type
2213
2248
s32 classId = s_objEntity.type ;
@@ -2238,6 +2273,7 @@ namespace LevelEditor
2238
2273
{
2239
2274
s_objEntity.assetName = assetName;
2240
2275
}
2276
+ s_textInputFocused |= ImGui::IsItemActive ();
2241
2277
ImGui::SameLine (0 .0f , 8 .0f );
2242
2278
if (ImGui::Button (" Browse" ))
2243
2279
{
@@ -2264,6 +2300,7 @@ namespace LevelEditor
2264
2300
2265
2301
ImGui::Text (" %s" , " Position" ); ImGui::SameLine (0 .0f , 8 .0f );
2266
2302
ImGui::InputFloat3 (" ##Position" , &obj->pos .x );
2303
+ s_textInputFocused |= ImGui::IsItemActive ();
2267
2304
2268
2305
bool orientAdjusted = false ;
2269
2306
ImGui::Text (" %s" , " Angle" ); ImGui::SameLine (0 .0f , 32 .0f );
@@ -2281,6 +2318,7 @@ namespace LevelEditor
2281
2318
obj->angle = angle * PI / 180 .0f ;
2282
2319
orientAdjusted = true ;
2283
2320
}
2321
+ s_textInputFocused |= ImGui::IsItemActive ();
2284
2322
2285
2323
// Show pitch and roll.
2286
2324
if (s_objEntity.type == ETYPE_3D)
@@ -2295,6 +2333,7 @@ namespace LevelEditor
2295
2333
obj->pitch = pitch * PI / 180 .0f ;
2296
2334
orientAdjusted = true ;
2297
2335
}
2336
+ s_textInputFocused |= ImGui::IsItemActive ();
2298
2337
ImGui::SameLine (0 .0f , 32 .0f );
2299
2338
ImGui::Text (" %s" , " Roll" ); ImGui::SameLine (0 .0f , 8 .0f );
2300
2339
ImGui::SetNextItemWidth (128 .0f );
@@ -2303,6 +2342,7 @@ namespace LevelEditor
2303
2342
obj->roll = roll * PI / 180 .0f ;
2304
2343
orientAdjusted = true ;
2305
2344
}
2345
+ s_textInputFocused |= ImGui::IsItemActive ();
2306
2346
2307
2347
if (orientAdjusted)
2308
2348
{
@@ -2443,11 +2483,13 @@ namespace LevelEditor
2443
2483
{
2444
2484
sprintf (name, " ##VarFloat%d" , i);
2445
2485
ImGui::InputFloat (name, &list[i].value .fValue );
2486
+ s_textInputFocused |= ImGui::IsItemActive ();
2446
2487
} break ;
2447
2488
case EVARTYPE_INT:
2448
2489
{
2449
2490
sprintf (name, " ##VarInt%d" , i);
2450
2491
ImGui::InputInt (name, &list[i].value .iValue );
2492
+ s_textInputFocused |= ImGui::IsItemActive ();
2451
2493
} break ;
2452
2494
case EVARTYPE_FLAGS:
2453
2495
{
@@ -2486,12 +2528,14 @@ namespace LevelEditor
2486
2528
{
2487
2529
list[i].value .sValue = pair1;
2488
2530
}
2531
+ s_textInputFocused |= ImGui::IsItemActive ();
2489
2532
ImGui::SameLine (0 .0f , 8 .0f );
2490
2533
ImGui::SetNextItemWidth (128 .0f );
2491
2534
if (ImGui::InputText (" ###Pair2" , pair2, 256 ))
2492
2535
{
2493
2536
list[i].value .sValue1 = pair2;
2494
2537
}
2538
+ s_textInputFocused |= ImGui::IsItemActive ();
2495
2539
} break ;
2496
2540
}
2497
2541
}
@@ -2614,7 +2658,9 @@ namespace LevelEditor
2614
2658
ImGui::SetNextItemWidth (textWidth);
2615
2659
ImGui::LabelText (" ##Label" , " %s" , label); ImGui::SameLine ();
2616
2660
if (width) { ImGui::SetNextItemWidth ((f32 )width); }
2617
- return ImGui::InputFloat (editor_getUniqueLabel (" " ), value, step, 10 .0f * step, prec);
2661
+ bool changed = ImGui::InputFloat (editor_getUniqueLabel (" " ), value, step, 10 .0f * step, prec);
2662
+ s_textInputFocused |= ImGui::IsItemActive ();
2663
+ return changed;
2618
2664
}
2619
2665
2620
2666
static s32 s_selectedOffset = -1 ;
@@ -2723,10 +2769,12 @@ namespace LevelEditor
2723
2769
ImGui::LabelText (" ##Label" , " Start Fade (3D)" ); ImGui::SameLine ();
2724
2770
ImGui::SetNextItemWidth (128 .0f );
2725
2771
ImGui::InputFloat (" ##StartFade" , ¬e->fade .x , 1 .0f , 10 .0f , " %.1f" );
2772
+ s_textInputFocused |= ImGui::IsItemActive ();
2726
2773
ImGui::SetNextItemWidth (128 .0f );
2727
2774
ImGui::LabelText (" ##Label" , " End Fade (3D)" ); ImGui::SameLine ();
2728
2775
ImGui::SetNextItemWidth (128 .0f );
2729
2776
ImGui::InputFloat (" ##EndFade" , ¬e->fade .z , 1 .0f , 10 .0f , " %.1f" );
2777
+ s_textInputFocused |= ImGui::IsItemActive ();
2730
2778
ImGui::Separator ();
2731
2779
ImGui::SetNextItemWidth (128 .0f );
2732
2780
ImGui::LabelText (" ##Label" , " Icon Color" ); ImGui::SameLine ();
@@ -2753,11 +2801,13 @@ namespace LevelEditor
2753
2801
{
2754
2802
note->note = tmpBuffer;
2755
2803
}
2804
+ s_textInputFocused |= ImGui::IsItemActive ();
2756
2805
}
2757
2806
2758
- void drawInfoPanel (EditorView view)
2807
+ bool drawInfoPanel (EditorView view)
2759
2808
{
2760
2809
bool show = getSelectMode () == SELECTMODE_NONE;
2810
+ s_textInputFocused = false ;
2761
2811
2762
2812
// Draw the info bars.
2763
2813
s_infoHeight = 486 + 44 ;
@@ -2820,6 +2870,7 @@ namespace LevelEditor
2820
2870
}
2821
2871
}
2822
2872
infoToolEnd ();
2873
+ return s_textInputFocused;
2823
2874
}
2824
2875
2825
2876
void infoToolEnd ()
0 commit comments