Heroes::heroes_t Dialog::SelectHeroes(Heroes::heroes_t cur)
{
    Display & display = Display::Get();
    Cursor & cursor = Cursor::Get();
    LocalEvent & le = LocalEvent::Get();

    std::vector<int> heroes(static_cast<int>(Heroes::SANDYSANDY), Heroes::UNKNOWN);

    cursor.Hide();
    cursor.SetThemes(cursor.POINTER);


    for(size_t ii = 0; ii < heroes.size(); ++ii) heroes[ii] = Heroes::ConvertID(ii);

    const u16 window_w = 240;
    const u16 window_h = 280;

    Dialog::FrameBorder frameborder;
    frameborder.SetPosition((display.w() - window_w) / 2 - BORDERWIDTH,
			    (display.h() - window_h) / 2 - BORDERWIDTH, window_w, window_h);
    frameborder.Redraw(AGG::GetICN(ICN::TEXTBAK2, 0));

    const Rect & area = frameborder.GetArea();

    SelectEnumHeroes listbox(area);

    listbox.SetListContent(heroes);
    if(cur != Heroes::UNKNOWN)
	listbox.SetCurrent(static_cast<int>(cur));
    listbox.Redraw();

    ButtonGroups btnGroups(area, Dialog::OK|Dialog::CANCEL);
    btnGroups.Draw();

    cursor.Show();
    display.Flip();

    u16 result = Dialog::ZERO;

    while(result == Dialog::ZERO && ! listbox.ok && le.HandleEvents())
    {
        result = btnGroups.QueueEventProcessing();
        listbox.QueueEventProcessing();

        if(!cursor.isVisible())
        {
            listbox.Redraw();
            cursor.Show();
            display.Flip();
        }
    }

    return result == Dialog::OK || listbox.ok ?
	Heroes::ConvertID(listbox.GetCurrent()) : Heroes::UNKNOWN;
}
int Dialog::SelectHeroes(int cur)
{
    Display & display = Display::Get();
    Cursor & cursor = Cursor::Get();
    LocalEvent & le = LocalEvent::Get();

    std::vector<int> heroes(static_cast<int>(Heroes::SANDYSANDY), Heroes::UNKNOWN);

    cursor.Hide();
    cursor.SetThemes(cursor.POINTER);


    for(size_t ii = 0; ii < heroes.size(); ++ii) heroes[ii] = ii;

    Dialog::FrameBorder frameborder(Size(240, 280), AGG::GetICN(ICN::TEXTBAK2, 0));
    const Rect & area = frameborder.GetArea();

    SelectEnumHeroes listbox(area);

    listbox.SetListContent(heroes);
    if(cur != Heroes::UNKNOWN)
	listbox.SetCurrent(cur);
    listbox.Redraw();

    ButtonGroups btnGroups(area, Dialog::OK|Dialog::CANCEL);
    btnGroups.Draw();

    cursor.Show();
    display.Flip();

    int result = Dialog::ZERO;
    while(result == Dialog::ZERO && ! listbox.ok && le.HandleEvents())
    {
        result = btnGroups.QueueEventProcessing();
        listbox.QueueEventProcessing();

        if(!cursor.isVisible())
        {
            listbox.Redraw();
            cursor.Show();
            display.Flip();
        }
    }

    return result == Dialog::OK || listbox.ok ?
	listbox.GetCurrent() : Heroes::UNKNOWN;
}
示例#3
0
    virtual ~HeroTrackingVisitor()
    {
        std::ofstream heroes(_basepath + "heroes.txt");

        for(auto& kv : _files) {
            // Write out the hero names
            heroes << kv.first << std::endl;

            if(_json) {
                *kv.second << "]" << std::endl;
            }

            // And close all the files.
            kv.second->flush();
            delete kv.second;
        }

        if(_json) {
            _all << "]" << std::endl;
        }
    }