Author Topic: [DONE] Choose tabs when using "open_info_win"  (Read 318 times)

0 Members and 1 Guest are viewing this topic.

Offline Yona-TYT

[DONE] Choose tabs when using "open_info_win"
« on: April 19, 2017, 01:56:59 PM »
I have modified the following:

/gui/scenario_info.h (line 61)
Code: [Select]
    void open_info_tab();

    void open_goal_tab();

    void open_rules_tab();

    void open_result_tab();

    void open_about_tab();

/gui/scenario_info.cc (line 165)
Code: [Select]
void scenario_info_t::open_info_tab()
{
    tabs.set_active_tab_index(0);
    resize(scr_coord(0,0));
    set_dirty();
}

void scenario_info_t::open_goal_tab()
{
    tabs.set_active_tab_index(1);
    resize(scr_coord(0,0));
    set_dirty();
}

void scenario_info_t::open_rules_tab()
{
    tabs.set_active_tab_index(2);
    resize(scr_coord(0,0));
    set_dirty();
}

void scenario_info_t::open_result_tab()
{
    tabs.set_active_tab_index(3);
    resize(scr_coord(0,0));
    set_dirty();
}

void scenario_info_t::open_about_tab()
{
    tabs.set_active_tab_index(4);
    resize(scr_coord(0,0));
    set_dirty();
}

/dataobj/scenario.h (line 282)
Code: [Select]
    bool open_info_win(int opt) const;

/dataobj/scenario.cc (line 780)
Code: [Select]
bool scenario_t::open_info_win(int opt) const
{
    // pop up for the win
    scenario_info_t *si = (scenario_info_t*)win_get_magic(magic_scenario_info);
    if (si == NULL) {
        si = new scenario_info_t();
        create_win(si, w_info, magic_scenario_info);
    }
    if (opt==0)
        si->open_info_tab();
    else if (opt==1)
        si->open_goal_tab();
    else if (opt==2)
        si->open_rules_tab();
    else if (opt==3)
        si->open_result_tab();
    else
        si->open_about_tab();
    return true; // dummy return value
}

/script/api/api_gui.cc (line 45)
Code: [Select]
        /**
        * Opens scenario info window.
         * @param no.0 open Information windows
         * @param no.1 open Goal windows
         * @param no.2 open Rules windows
         * @param no.3 open Result windows
         * @param no.4 open About windows
        * @note Only available in scenario mode.
        */
        STATIC register_method(vm, &scenario_t::open_info_win, "open_info_win");
« Last Edit: April 29, 2017, 05:03:48 PM by Dwachs »

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4236
  • Total likes: 170
  • Helpful: 149
  • Languages: EN, DE, AT
Re: Choose tabs when using "open_info_win"
« Reply #1 on: April 29, 2017, 03:12:38 PM »
Something like this is now in r8220:
Code: [Select]
gui.open_info_win_at("goal")

see http://dwachs.github.io/simutrans-sqapi-doc/classgui.html#ad0301330af295052343584a0d7f9eefb
Parsley, sage, rosemary, and maggikraut.