summaryrefslogtreecommitdiffstats
path: root/tools/statepropbuilder/apps/spbuilder/code/sp/builder/eventsframe.cpp
blob: 09ded825dbaf4b1686673846bf295b53de46c510 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
#include <sp/interface.hpp>
#include "eventsframe.h"
#include "main.h"

extern float g_ForceDataUpdate;
extern bool  g_IsDataSaved;

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFrame3 *Frame3;
//---------------------------------------------------------------------------
__fastcall TFrame3::TFrame3(TComponent* Owner , int EventIndex ) :
    TFrame(Owner),
    m_EventIndex( EventIndex )
{
}
//---------------------------------------------------------------------------
void __fastcall TFrame3::EventComboBoxChange(TObject *Sender)
{
    EventData eventData;
    SPGetEventData( SPGetCurrentState() , m_EventIndex , &eventData );
    int index = EventComboBox->ItemIndex;
    AnsiString eventname = EventComboBox->Items->Strings[index];
    SPEditEvent( SPGetCurrentState() , m_EventIndex , eventname.c_str() , index , eventData.toState );
    g_IsDataSaved = false;
}
//---------------------------------------------------------------------------

void __fastcall TFrame3::ToFrameEditBoxChange(TObject *Sender)
{
    EventData eventData;
    SPGetEventData( SPGetCurrentState() , m_EventIndex , &eventData );

    int index = EventComboBox->ItemIndex;
    AnsiString eventname = EventComboBox->Items->Strings[index];
    AnsiString toState = ToFrameEditBox->Text;
    int state = 0;
    try
    {
        state = toState.ToInt();
    }
    catch (Exception&)
    {
        state = eventData.toState + 1;
    }
    if ( state > SPGetNumberOfStates()  || state == 0 )
    {
        state = eventData.toState + 1;
        g_ForceDataUpdate = true;
    }

    SPEditEvent( SPGetCurrentState() , m_EventIndex , eventname.c_str() , index , state - 1 );
    g_IsDataSaved = false;
}
//---------------------------------------------------------------------------

void __fastcall TFrame3::Button1Click(TObject *Sender)
{
    SPDeleteEvent( SPGetCurrentState() , m_EventIndex  );
    g_ForceDataUpdate = true;
    g_IsDataSaved = false;
}
//---------------------------------------------------------------------------

void __fastcall TFrame3::ToFrameEditBoxExit(TObject *Sender)
{
    g_ForceDataUpdate = true;
}
//---------------------------------------------------------------------------