@@ -784,16 +784,19 @@ void GUIFormSpecMenu::parseAnimatedImage(parserData *data, const std::string &el
784
784
{
785
785
std::vector<std::string> parts = split (element, ' ;' );
786
786
787
- if (parts.size () != 3 &&
788
- !(parts.size () > 3 && m_formspec_version > FORMSPEC_API_VERSION)) {
789
- errorstream << " Invalid animated image element(" << parts.size ()
790
- << " ): '" << element << " '" << std::endl;
787
+ if (parts.size () != 6 && parts. size () != 7 &&
788
+ !(parts.size () > 7 && m_formspec_version > FORMSPEC_API_VERSION)) {
789
+ errorstream << " Invalid animated_image element(" << parts.size ()
790
+ << " ): '" << element << " '" << std::endl;
791
791
return ;
792
792
}
793
793
794
- std::vector<std::string> v_pos = split (parts[0 ], ' ,' );
795
- std::vector<std::string> v_geom = split (parts[1 ], ' ,' );
796
- std::string name = unescape_string (parts[2 ]);
794
+ std::vector<std::string> v_pos = split (parts[0 ], ' ,' );
795
+ std::vector<std::string> v_geom = split (parts[1 ], ' ,' );
796
+ std::string name = parts[2 ];
797
+ std::string texture_name = unescape_string (parts[3 ]);
798
+ s32 frame_count = stoi (parts[4 ]);
799
+ s32 frame_duration = stoi (parts[5 ]);
797
800
798
801
MY_CHECKPOS (" animated_image" , 0 );
799
802
MY_CHECKGEOM (" animated_image" , 1 );
@@ -811,21 +814,26 @@ void GUIFormSpecMenu::parseAnimatedImage(parserData *data, const std::string &el
811
814
}
812
815
813
816
if (!data->explicit_size )
814
- warningstream << " invalid use of animated_image without a size[] element" << std::endl;
817
+ warningstream << " Invalid use of animated_image without a size[] element" << std::endl;
815
818
816
819
FieldSpec spec (
817
- " " ,
818
- L" " ,
819
- L" " ,
820
- 258 + m_fields.size ()
820
+ name ,
821
+ L" " ,
822
+ L" " ,
823
+ 258 + m_fields.size ()
821
824
);
825
+ spec.ftype = f_AnimatedImage;
826
+ spec.send = true ;
822
827
823
828
core::rect<s32> rect = core::rect<s32>(pos, pos + geom);
824
829
825
- gui::IGUIElement *e = new GUIAnimatedImage (Environment, this , spec.fid ,
826
- rect, name, m_tsrc);
830
+ GUIAnimatedImage *e = new GUIAnimatedImage (Environment, this , spec.fid ,
831
+ rect, texture_name, frame_count, frame_duration, m_tsrc);
832
+
833
+ if (parts.size () >= 7 )
834
+ e->setFrameIndex (stoi (parts[6 ]) - 1 );
827
835
828
- auto style = getStyleForElement (" animated_image" , spec.fname );
836
+ auto style = getStyleForElement (" animated_image" , spec.fname , " image " );
829
837
e->setNotClipped (style.getBool (StyleSpec::NOCLIP, false ));
830
838
e->drop ();
831
839
@@ -3499,7 +3507,7 @@ void GUIFormSpecMenu::acceptInput(FormspecQuitMode quitmode=quit_mode_no)
3499
3507
}
3500
3508
3501
3509
for (const GUIFormSpecMenu::FieldSpec &s : m_fields) {
3502
- if (s.send ) {
3510
+ if (s.send ) {
3503
3511
std::string name = s.fname ;
3504
3512
if (s.ftype == f_Button) {
3505
3513
fields[name] = wide_to_utf8 (s.flabel );
@@ -3508,14 +3516,13 @@ void GUIFormSpecMenu::acceptInput(FormspecQuitMode quitmode=quit_mode_no)
3508
3516
if (table) {
3509
3517
fields[name] = table->checkEvent ();
3510
3518
}
3511
- }
3512
- else if (s.ftype == f_DropDown) {
3513
- // no dynamic cast possible due to some distributions shipped
3514
- // without rtti support in irrlicht
3519
+ } else if (s.ftype == f_DropDown) {
3520
+ // No dynamic cast possible due to some distributions shipped
3521
+ // without rtti support in Irrlicht
3515
3522
IGUIElement *element = getElementFromId (s.fid , true );
3516
3523
gui::IGUIComboBox *e = NULL ;
3517
3524
if ((element) && (element->getType () == gui::EGUIET_COMBO_BOX)) {
3518
- e = static_cast <gui::IGUIComboBox*>(element);
3525
+ e = static_cast <gui::IGUIComboBox *>(element);
3519
3526
} else {
3520
3527
warningstream << " GUIFormSpecMenu::acceptInput: dropdown "
3521
3528
<< " field without dropdown element" << std::endl;
@@ -3529,10 +3536,9 @@ void GUIFormSpecMenu::acceptInput(FormspecQuitMode quitmode=quit_mode_no)
3529
3536
fields[name] = (*dropdown_values)[selected];
3530
3537
}
3531
3538
}
3532
- }
3533
- else if (s.ftype == f_TabHeader) {
3534
- // no dynamic cast possible due to some distributions shipped
3535
- // without rttzi support in irrlicht
3539
+ } else if (s.ftype == f_TabHeader) {
3540
+ // No dynamic cast possible due to some distributions shipped
3541
+ // without rtti support in Irrlicht
3536
3542
IGUIElement *element = getElementFromId (s.fid , true );
3537
3543
gui::IGUITabControl *e = nullptr ;
3538
3544
if ((element) && (element->getType () == gui::EGUIET_TAB_CONTROL)) {
@@ -3544,10 +3550,9 @@ void GUIFormSpecMenu::acceptInput(FormspecQuitMode quitmode=quit_mode_no)
3544
3550
ss << (e->getActiveTab () +1 );
3545
3551
fields[name] = ss.str ();
3546
3552
}
3547
- }
3548
- else if (s.ftype == f_CheckBox) {
3549
- // no dynamic cast possible due to some distributions shipped
3550
- // without rtti support in irrlicht
3553
+ } else if (s.ftype == f_CheckBox) {
3554
+ // No dynamic cast possible due to some distributions shipped
3555
+ // without rtti support in Irrlicht
3551
3556
IGUIElement *element = getElementFromId (s.fid , true );
3552
3557
gui::IGUICheckBox *e = nullptr ;
3553
3558
if ((element) && (element->getType () == gui::EGUIET_CHECK_BOX)) {
@@ -3560,10 +3565,9 @@ void GUIFormSpecMenu::acceptInput(FormspecQuitMode quitmode=quit_mode_no)
3560
3565
else
3561
3566
fields[name] = " false" ;
3562
3567
}
3563
- }
3564
- else if (s.ftype == f_ScrollBar) {
3565
- // no dynamic cast possible due to some distributions shipped
3566
- // without rtti support in irrlicht
3568
+ } else if (s.ftype == f_ScrollBar) {
3569
+ // No dynamic cast possible due to some distributions shipped
3570
+ // without rtti support in Irrlicht
3567
3571
IGUIElement *element = getElementFromId (s.fid , true );
3568
3572
GUIScrollBar *e = nullptr ;
3569
3573
if (element && element->getType () == gui::EGUIET_ELEMENT)
@@ -3577,8 +3581,17 @@ void GUIFormSpecMenu::acceptInput(FormspecQuitMode quitmode=quit_mode_no)
3577
3581
else
3578
3582
fields[name] = " VAL:" + os.str ();
3579
3583
}
3580
- }
3581
- else {
3584
+ } else if (s.ftype == f_AnimatedImage) {
3585
+ // No dynamic cast possible due to some distributions shipped
3586
+ // without rtti support in Irrlicht
3587
+ IGUIElement *element = getElementFromId (s.fid , true );
3588
+ GUIAnimatedImage *e = nullptr ;
3589
+ if (element && element->getType () == gui::EGUIET_ELEMENT)
3590
+ e = static_cast <GUIAnimatedImage *>(element);
3591
+
3592
+ if (e)
3593
+ fields[name] = std::to_string (e->getFrameIndex () + 1 );
3594
+ } else {
3582
3595
IGUIElement *e = getElementFromId (s.fid , true );
3583
3596
if (e)
3584
3597
fields[name] = wide_to_utf8 (e->getText ());
0 commit comments