Exemplo n.º 1
0
wxString wxsEventsEditor::GetFunctionProposition(const wxsEventDesc* Event)
{
    // Creating proposition of new function name
    wxString NewNameBase;
    wxString VarName = m_Item->IsRootItem() ? _T("") : m_Item->GetVarName();
    if (Manager::Get()->GetConfigManager(_T("wxsmith"))->ReadBool(_T("/removeprefix"), false))
    {
        if (VarName.StartsWith(_T("m_")))
            VarName = VarName.Right(VarName.Len() - 2);
        else if (VarName.StartsWith(_T("_")))
            VarName = VarName.Right(VarName.Len() - 1);
    }

    NewNameBase.Printf(_T("On%s%s"),VarName.c_str(),Event->NewFuncNameBase.c_str());

    int Suffix = 0;
    wxArrayString Functions;
    FindFunctions(_T(""),Functions);
    wxString NewName = NewNameBase;

    while ( Functions.Index(NewName) != wxNOT_FOUND )
    {
        NewName = NewNameBase;
        NewName.Append(wxString::Format(_T("%d"),++Suffix));
    }

    return NewName;
}
Exemplo n.º 2
0
bool CNWNXdmactions::OnCreate(gline *config, const char *LogDir)
{
	char log[128];
	sprintf (log, "%s/nwnx_dmactions.txt", LogDir);

	// call the base class function
	if (!CNWNXBase::OnCreate(config,log))
		return false;
	Log(0,"NWNX DM Actions v0.2.6, 2010\n");

	if(!FindFunctions()) {
		Log(0,"* Failed to hook functions.\n");
		return false;
	}

	return true;
}
Exemplo n.º 3
0
wxString wxsEventsEditor::GetNewFunction(const wxsEventDesc* Event)
{
    wxString Name = GetFunctionProposition(Event);

    for (;;)
    {
        Name = ::cbGetTextFromUser(_("Enter name for new handler:"),_("New handler"),Name);
        if ( !Name.Length() ) return _T("");

        if ( !wxsCodeMarks::ValidateIdentifier(m_Language,Name) )
        {
            wxMessageBox(_("Invalid name"));
            continue;
        }

        wxArrayString Functions;
        FindFunctions(_T(""),Functions);

        if ( Functions.Index(Name) != wxNOT_FOUND )
        {
            wxMessageBox(_("Handler with this name already exists"));
            continue;
        }

        break;
    }

    // Creating new function

    if ( !CreateNewFunction(Event,Name) )
    {
        wxMessageBox(_("Couldn't add new handler"));
        return _T("");
    }

    return Name;
}
Exemplo n.º 4
0
void wxsEventsEditor::BuildEvents(wxsItem* Item,wxsPropertyGridManager* Grid)
{
    m_Item = Item;
    m_Data = 0;
    m_Events = 0;
    m_Ids.Clear();
    m_Source.Clear();
    m_Header.Clear();
    m_Class.Clear();

    int PageIndex = 1;              // TODO: Do not use fixed page number
    Grid->ClearPage(PageIndex);
    #if wxCHECK_VERSION(3, 0, 0) || wxCHECK_PROPGRID_VERSION(1, 4, 0)
    Grid->SelectPage(PageIndex);
    #else
    Grid->SetTargetPage(PageIndex);
    #endif


    if ( !m_Item )
    {
        return;
    }

    m_Events = &m_Item->GetEvents();
    m_Data   = m_Item->GetResourceData();
    m_Source = m_Data->GetSrcFileName();
    m_Header = m_Data->GetHdrFileName();
    m_Class  = m_Data->GetClassName();
    m_Language = m_Data->GetLanguage();

    int Cnt = m_Events->GetCount();
    for ( int i=0; i<Cnt; i++ )
    {
        const wxsEventDesc* Event = m_Events->GetDesc(i);
        const wxString& FunctionName = m_Events->GetHandler(i);

        // TODO: Create new group
        if ( Event->ET == wxsEventDesc::Category )
        {
            m_Ids.Add(0);
            continue;
        }

        wxArrayString Functions;
        FindFunctions(Event->ArgType,Functions);

        wxPGChoices Const;
        Const.Add(NoneStr,0);
        Const.Add(AddNewStr,1);

        int Index = 0;
        for ( int j=0; j<(int)Functions.Count(); j++ )
        {
            Const.Add(Functions[j],j+2);
            if ( Functions[j] == FunctionName )
            {
                Index = j+2;
            }
        }
        if ( Index == 0 )
        {
            m_Events->SetHandler(i,_T(""));
        }

        m_Ids.Add(Grid->Append(NEW_IN_WXPG14X wxEnumProperty(Event->Entry,wxPG_LABEL,Const,Index)));
    }
    #if wxCHECK_VERSION(3, 0, 0) || wxCHECK_PROPGRID_VERSION(1, 4, 0)
    Grid->SelectPage(0);
    #endif
}