ReconnectDialog::ReconnectDialog(): wxDialog( (wxFrame*)&ui().mw(), -1, _( "Reconnect Dialog" ), wxDefaultPosition, wxSize( 400, 150 ), wxRESIZE_BORDER | wxDEFAULT_DIALOG_STYLE ), WindowAttributesPickle( _T("reconnectdialog"), this, wxSize( 400, 150 ) ) { this->SetSizeHints( wxDefaultSize, wxDefaultSize ); SetSizeHints( wxDefaultSize, wxDefaultSize ); wxBoxSizer* m_main_sizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* m_buttons_sizer; m_buttons_sizer = new wxBoxSizer( wxHORIZONTAL ); wxButton* m_retry_btn = new wxButton( this, CONNECT_RECONNECT, _( "Try Reconnecting" ), wxDefaultPosition, wxDefaultSize, 0 ); m_retry_btn->SetToolTip( TE( _( "Tries to connect to the next server in the list." ) ) ); m_buttons_sizer->Add( m_retry_btn, 0, wxALL, 5 ); wxButton* m_next_btn = new wxButton( this, CONNECT_NEXT, _( "Try Next Server" ), wxDefaultPosition, wxDefaultSize, 0 ); m_next_btn->SetToolTip( TE( _( "Tries to connect to the next server in the list." ) ) ); m_buttons_sizer->Add( m_next_btn, 0, wxALL, 5 ); wxButton* m_cancel_btn = new wxButton( this, CONNECT_CANCEL, _( "Do nothing" ), wxDefaultPosition, wxDefaultSize, 0 ); m_buttons_sizer->Add( m_cancel_btn, 0, wxALL, 5 ); m_main_sizer->Add( CreateTextSizer( _( "Couldn't estabilish a connection with the server\nWhat would you like to do?" ) ), 1, wxALL | wxEXPAND | wxCENTER, 10 ); m_main_sizer->Add( m_buttons_sizer, 1, wxALL | wxEXPAND | wxCENTER, 10 ); SetSizer( m_main_sizer ); SetAutoLayout( true ); Raise(); m_next_btn->SetFocus(); ConnectGlobalEvent(this, GlobalEvent::OnQuit, wxObjectEventFunction(&ReconnectDialog::OnQuit)); }
static int rwmime(struct rfc2045 *p) { static char mimever[]="Mime-Version: 1.0\n"; const char *te; struct rfc2045attr *a; if (!p->parent) if (fdout_add(mimever, sizeof(mimever)-1)) return (-1); if (p->content_type) { if (fdout_add("Content-Type: ", 14) || fdout_add(p->content_type, strlen(p->content_type))) return (-1); for (a=p->content_type_attr; a; a=a->next) { if (!a->name || strcmp(a->name, "boundary") == 0) continue; if ( fdout_add("; ", 2) || fdout_attr(a)) return (-1); } } if (p->firstpart && p->firstpart->next /* ADDED 8/30/99, see below */) { char buf[80]; ++rw_boundary_cnt; sprintf(buf, "-%d", rw_boundary_cnt); if ( fdout_add("; boundary=\"", 12) || fdout_add(rw_boundary_root, strlen(rw_boundary_root)) || fdout_add(buf, strlen(buf)) || fdout_add("\"", 1)) return (-1); } if (fdout_add("\n", 1)) return (-1); /* Show content transfer encoding for top section, or if it's ** different than the parent. */ te=TE(p); if (te && (!p->parent || strcmp(te, TE(p->parent)))) { if (fdout_add("Content-Transfer-Encoding: ", 27) || fdout_add(te, strlen(te)) || fdout_add("\n", 1)) return (-1); } return (0); }
/* SUBGOAL action-close ?grasper ?object */ void PA_ActionClose(Context *cx, Subgoal *sg, Ts *ts, Obj *a, Obj *o) { Dur d; Dbg(DBGPLAN, DBGOK, "PA_ActionClose", E); switch (sg->state) { case STBEGIN: if (!DbIsPartOf(ts, NULL, I(o,1), a)) { Dbg(DBGPLAN, DBGDETAIL, "failure: grasper not part of actor", E); goto failure; } /* todo: Cannot already be holding too much. */ SG(cx, sg, 1, STFAILURE, L(N("near-graspable"), I(o,1), I(o,2), E)); return; case 1: d = DurationOf(I(o, 0)); /* Depends on object. */ AA(ts, d, o); TsIncrement(ts, d); if (!TE(ts, L(N("open"), I(o,2), E))) { Dbg(DBGPLAN, DBGBAD, "object not already open", E); } AS(ts, 0, L(N("closed"), I(o,2), E)); TOSTATE(cx, sg, STSUCCESS); return; default: Dbg(DBGPLAN, DBGBAD, "PA_ActionClose: undefined state %d", sg->state); } failure: TOSTATE(cx, sg, STFAILURE); }
void PA_MoveObject(Ts *ts, Obj *obj, Obj *grid, GridCoord torow, GridCoord tocol) { if (grid) { TE(ts, L(N("at-grid"), obj, grid, ObjWild)); AS(ts, 0, ObjAtGridCreate(obj, grid, torow, tocol)); } }
void CustomVirtListCtrl<T,L>::SetTipWindowText( const long /*unused*/ , const wxPoint& position) { int column = getColumnFromPosition(position); if (column >= int(m_colinfovec.size()) || column < 0) { m_tiptext = wxEmptyString; } else { m_tiptimer.Start(m_tooltip_delay, wxTIMER_ONE_SHOT); m_tiptext = TE(m_colinfovec[column].tip); } }
AutoBalanceDialog::AutoBalanceDialog( wxWindow* parent, const BalanceOptions& defaultval, unsigned int maxnum ) { wxFlexGridSizer* m_choices_sizer; wxBoxSizer* m_buttons_sizer; wxBoxSizer* m_main_sizer; Create(parent, wxID_ANY, _("Autobalance players into teams"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("wxID_ANY")); m_main_sizer = new wxBoxSizer(wxVERTICAL); m_choices_sizer = new wxFlexGridSizer(0, 2, wxDLG_UNIT(this,wxSize(4,0)).GetWidth(), wxDLG_UNIT(this,wxSize(10,0)).GetWidth()); m_method_label = new wxStaticText(this, ID_STATICTEXT1, _("Method"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1")); m_choices_sizer->Add(m_method_label, 0, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 0); m_method_choice = new wxChoice(this, ID_METHOD, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_METHOD")); m_method_choice->SetSelection( m_method_choice->Append(_("Divide ranks evenly")) ); m_method_choice->Append(_("Random")); m_choices_sizer->Add(m_method_choice, 0, wxALL|wxEXPAND|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 0); StaticText1 = new wxStaticText(this, ID_STATICTEXT2, _("Clans"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT2")); m_choices_sizer->Add(StaticText1, 0, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 0); m_clans_choice = new wxChoice(this, ID_CHOICE1, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_CHOICE1")); m_clans_choice->SetSelection( m_clans_choice->Append(_("None")) ); m_clans_choice->Append(_("Fair")); m_clans_choice->Append(_("Always")); m_clans_choice->SetToolTip(TE(_("Put members of same clan ( users having same clantag, like \'[smurfzor]Alice\' and \'[smurfzor]Bob\' ) together into same alliance. \nNone: nothing special for clans.\nFair: put clanmembers into alliance, unless this makes alliances unfair.\nAlways: always put clanmembers into alliance, even if that alliance is unfair."))); m_choices_sizer->Add(m_clans_choice, 0, wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 0); StaticText2 = new wxStaticText(this, ID_STATICTEXT3, _("Number of allies"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT3")); m_choices_sizer->Add(StaticText2, 0, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 0); m_group_choice = new wxChoice(this, ID_CHOICE2, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_CHOICE2")); m_group_choice->Append( _("Auto select") ); for ( unsigned int i = 1; i < (maxnum + 1); i++ ) m_group_choice->Append( TowxString( i ) ); m_choices_sizer->Add(m_group_choice, 0, wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 0); m_main_sizer->Add(m_choices_sizer, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); wxSize __SpacerSize_1 = wxDLG_UNIT(this,wxSize(0,0)); m_main_sizer->Add(__SpacerSize_1.GetWidth(),__SpacerSize_1.GetHeight(),0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); m_separator1 = new wxStaticLine(this, ID_STATICLINE1, wxDefaultPosition, wxSize(10,-1), wxLI_HORIZONTAL, _T("ID_STATICLINE1")); m_main_sizer->Add(m_separator1, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); m_buttons_sizer = new wxBoxSizer(wxHORIZONTAL); m_cancel_button = new wxButton(this, ID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CANCEL")); m_buttons_sizer->Add(m_cancel_button, 0, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); m_buttons_sizer->Add(0,0,1, wxALL|wxEXPAND|wxSHAPED|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); m_ok_button = new wxButton(this, ID_OK, _("Ok"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_OK")); m_buttons_sizer->Add(m_ok_button, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5); m_main_sizer->Add(m_buttons_sizer, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); SetSizer(m_main_sizer); m_main_sizer->Fit(this); m_main_sizer->SetSizeHints(this); Connect(ID_CANCEL,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&AutoBalanceDialog::OnCancel); Connect(ID_OK,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&AutoBalanceDialog::OnOk); m_method_choice->SetSelection( defaultval.type ); m_clans_choice->SetSelection( defaultval.respectclans + ( defaultval.respectclans && defaultval.strongclans ) ); m_group_choice->SetSelection( defaultval.groupingsize ); }
void skeletonize(const cv::Mat &input, cv::Mat &output, bool save_images) { TS(total); TS(imwrite_0); if (save_images) cv::imwrite("0-input.png", input); TE(imwrite_0); // Convert to grayscale my cv::Mat gray_image_my; ConvertColor_BGR2GRAY_BT709_fpt(input, gray_image_my); if (save_images) cv::imwrite("1-convertcolor_my.png", gray_image_my); // Convert to grayscale my cv::Mat gray_image; ConvertColor_BGR2GRAY_BT709(input, gray_image); if (save_images) cv::imwrite("1-convertcolor.png", gray_image); // Downscale input image cv::Mat small_image; cv::Size small_size(input.cols / 1.5, input.rows / 1.5); ImageResize(gray_image, small_image, small_size); if (save_images) cv::imwrite("2-resize.png", small_image); // Binarization and inversion cv::threshold(small_image, small_image, 128, 255, cv::THRESH_BINARY_INV); if (save_images) cv::imwrite("3-threshold.png", small_image); // Thinning cv::Mat thinned_image; GuoHallThinning(small_image, thinned_image); if (save_images) cv::imwrite("4-thinning.png", thinned_image); // Back inversion output = 255 - thinned_image; if (save_images) cv::imwrite("5-output.png", output); TE(total); }
void PA_GrasperMove(Ts *ts, Obj *grasper, Obj *grid, GridCoord torow, GridCoord tocol) { ObjList *objs, *p; /* Grasper which moves is no longer near-graspable anything. */ TE(ts, L(N("near-graspable"), grasper, ObjWild, E)); /* (S5), (S6), (S7), (S8) */ objs = RE(ts, L(N("holding"), grasper, ObjWild, E)); for (p = objs; p; p = p->next) { PA_HeldObjectMove(ts, I(p->obj, 2), grid, torow, tocol); } ObjListFree(objs); }
void PA_HeldObjectMove(Ts *ts, Obj *held, Obj *grid, GridCoord torow, GridCoord tocol) { ObjList *objs, *p; /* (S8) -> (S2)+(S6): Held object which moves is no longer * inside anything. (Holding overrides inside.) * todo: Actor holds key in pocket while walking. */ TE(ts, L(N("inside"), held, ObjWild, E)); if (grid) { /* Optimization. */ /* (S7): <held> is small container. */ objs = RE(ts, L(N("inside"), ObjWild, held, E)); for (p = objs; p; p = p->next) { PA_SmallContainedObjectMove(ts, I(p->obj, 1), grid, torow, tocol); } ObjListFree(objs); } PA_MoveObject(ts, held, grid, torow, tocol); }
void PA_ActorMove(Ts *ts, Obj *a, Obj *grid, GridCoord torow, GridCoord tocol, int is_walk) { ObjList *objs, *p; if (is_walk) { /* (L3) -> (L1) */ TE(ts, L(N("inside"), a, ObjWild, E)); } objs = PA_Graspers(ts, a); for (p = objs; p; p = p->next) { PA_GrasperMove(ts, p->obj, grid, torow, tocol); } ObjListFree(objs); /* todo: Need to do parts of <a> and parts (such as pockets containing * keys) of clothing worn by <a>. */ PA_MoveObject(ts, a, grid, torow, tocol); }
/* SUBGOAL release ?grasper ?object */ void PA_Release(Context *cx, Subgoal *sg, Ts *ts, Obj *a, Obj *o) { Dur d; Dbg(DBGPLAN, DBGOK, "PA_Release", E); switch (sg->state) { case STBEGIN: if (!DbIsPartOf(ts, NULL, I(o,1), a)) { Dbg(DBGPLAN, DBGDETAIL, "failure: grasper not part of actor", E); goto failure; } d = DurationOf(I(o, 0)); AA(ts, d, o); TsIncrement(ts, d); if (!TE(ts, L(N("holding"), I(o,1), I(o,2), E))) { Dbg(DBGPLAN, DBGBAD, "not already holding object", E); } TOSTATE(cx, sg, STSUCCESS); return; default: Dbg(DBGPLAN, DBGBAD, "PA_Release: undefined state %d", sg->state); } failure: TOSTATE(cx, sg, STFAILURE); }
SinglePlayerTab::SinglePlayerTab(wxWindow* parent, MainSinglePlayerTab& msptab): wxScrolledWindow( parent, -1 ), m_battle(msptab) { GetAui().manager->AddPane( this, wxLEFT, _T("singleplayertab") ); wxBoxSizer* m_main_sizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* m_mapabour_sizer = new wxBoxSizer( wxHORIZONTAL ); wxBoxSizer* m_map_sizer = new wxBoxSizer( wxHORIZONTAL ); // m_map_sizer->SetMinSize( wxSize( 352, -1 ) ); m_minimap = new MapCtrl( this, 100, &m_battle, false, false, true, true ); m_minimap->SetToolTip( TE(_("You can drag the sun/bot icon around to define start position.\n " "Hover over the icon for a popup that lets you change side, ally and bonus." )) ); m_map_sizer->Add( m_minimap, 1, wxALL | wxEXPAND, 2 ); m_mapabour_sizer->Add(m_map_sizer, 1, wxEXPAND, 2 ); //map description and parametrs like in battletab wxBoxSizer* m_opts_sizer = new wxBoxSizer( wxVERTICAL ); m_map_opts_list = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxSize( 150, 160 ), wxLC_NO_HEADER | wxLC_REPORT ); m_map_opts_list->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) ); m_map_opts_list->SetFont( wxFont( 8, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_LIGHT ) ); wxListItem col; col.SetText( _( "Option" ) ); m_map_opts_list->InsertColumn( 0, col ); col.SetText( _( "Value" ) ); m_map_opts_list->InsertColumn( 1, col ); m_map_opts_list->SetColumnWidth( 0, 90 ); m_map_opts_list->SetColumnWidth( 1, 50 ); m_map_opts_list->InsertItem( 0, _( "Size" ) ); m_map_opts_list->InsertItem( 1, _( "Windspeed" ) ); m_map_opts_list->InsertItem( 2, _( "Tidal strength" ) ); m_map_opts_list->InsertItem( 3, _( "Gravity" ) ); m_map_opts_list->InsertItem( 4, _( "Extractor radius" ) ); m_map_opts_list->InsertItem( 5, _( "Max metal" ) ); m_opts_sizer->Add( m_map_opts_list, 0, wxALL, 2 ); m_map_desc = new wxStaticText(this,-1,wxEmptyString); m_map_desc->Wrap(160); m_opts_sizer->Add( m_map_desc, 0, wxALL, 2 ); m_mapabour_sizer->Add( m_opts_sizer, 0, wxALL | wxEXPAND, 2 ); m_main_sizer->Add( m_mapabour_sizer, 1, wxEXPAND, 5 ); wxBoxSizer* m_ctrl_sizer = new wxBoxSizer( wxHORIZONTAL ); m_map_lbl = new wxStaticText( this, -1, _("Map:") ); m_ctrl_sizer->Add( m_map_lbl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); m_map_pick = new wxChoice( this, SP_MAP_PICK ); m_ctrl_sizer->Add( m_map_pick, 1, wxALL, 5 ); m_select_btn = new wxButton( this, SP_BROWSE_MAP, _T("..."), wxDefaultPosition, wxSize(CONTROL_HEIGHT, CONTROL_HEIGHT), wxBU_EXACTFIT ); m_ctrl_sizer->Add( m_select_btn, 0, wxBOTTOM|wxRIGHT|wxTOP, 5 ); m_mod_lbl = new wxStaticText( this, -1, _("Game:") ); m_ctrl_sizer->Add( m_mod_lbl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); m_mod_pick = new wxChoice( this, SP_MOD_PICK ); m_ctrl_sizer->Add( m_mod_pick, 1, wxALL, 5 ); // m_ctrl_sizer->Add( 0, 0, 1, wxEXPAND, 0 ); m_addbot_btn = new wxButton( this, SP_ADD_BOT, _("Add bot..."), wxDefaultPosition, wxSize(80, CONTROL_HEIGHT), 0 ); m_ctrl_sizer->Add( m_addbot_btn, 0, wxALL, 5 ); m_main_sizer->Add( m_ctrl_sizer, 0, wxEXPAND, 5 ); m_buttons_sep = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); m_main_sizer->Add( m_buttons_sep, 0, wxLEFT|wxRIGHT|wxEXPAND, 5 ); wxBoxSizer* m_buttons_sizer = new wxBoxSizer( wxHORIZONTAL ); // see http://projects.springlobby.info/issues/show/649 // m_reset_btn = new wxButton( this, SP_RESET, _("Reset"), wxDefaultPosition, wxSize(80, CONTROL_HEIGHT), 0 ); // m_buttons_sizer->Add( m_reset_btn, 0, wxALL, 5 ); m_buttons_sizer->Add( 0, 0, 1, wxEXPAND, 0 ); m_color_btn = new ColorButton( this, SP_COLOUR, sett().GetBattleLastColour(), wxDefaultPosition, wxSize(30, CONTROL_HEIGHT) ); m_buttons_sizer->Add( m_color_btn, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0 ); m_spectator_check = new wxCheckBox( this, SP_SPECTATE, _("Spectate only") ); m_buttons_sizer->Add( m_spectator_check, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); m_random_check = new wxCheckBox( this, SP_RANDOM, _("Random start positions") ); m_buttons_sizer->Add( m_random_check, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); m_start_btn = new wxButton( this, SP_START, _("Start"), wxDefaultPosition, wxSize(80, CONTROL_HEIGHT), 0 ); m_buttons_sizer->Add( m_start_btn, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); m_main_sizer->Add( m_buttons_sizer, 0, wxEXPAND, 5 ); SetScrollRate( SCROLL_RATE, SCROLL_RATE ); this->SetSizer( m_main_sizer ); this->Layout(); ReloadMaplist(); ReloadModlist(); ConnectGlobalEvent(this, GlobalEvent::OnUnitsyncReloaded, wxObjectEventFunction(&SinglePlayerTab::OnUnitsyncReloaded)); }
SingleOptionDialog::SingleOptionDialog( IBattle& battle, const wxString& optiontag ) : m_battle( battle ), m_tag( optiontag ), m_checkbox( 0 ), m_combobox( 0 ), m_spinctrl( 0 ), m_textctrl( 0 ) { OptionsWrapper& optWrap = m_battle.CustomBattleOptions(); OptionsWrapper::GameOption optFlag = ( OptionsWrapper::GameOption )s2l( optiontag.BeforeFirst( '_' ) ); wxString key = optiontag.AfterFirst( '_' ); OptionType type = optWrap.GetSingleOptionType( key ); Create( (wxWindow*)&ui().mw(), wxID_ANY, _( "Change option" ), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T( "OptionDialog" ) ); if ( !optWrap.keyExists( key, optFlag, false, type ) ) { EndModal( wxID_CANCEL ); return; } wxBoxSizer* m_main_sizer = new wxBoxSizer( wxVERTICAL ); // wxStaticText* m_labelctrl = wxStaticText(); switch ( type ) { case opt_bool: { mmOptionBool opt = optWrap.m_opts[optFlag].bool_map[key]; m_checkbox = new wxCheckBox( this, wxID_ANY, opt.name ); m_checkbox->SetToolTip( TE( opt.description ) ); m_checkbox->SetValue( opt.value ); m_main_sizer->Add( m_checkbox, 0, wxEXPAND ); break; } case opt_float: { mmOptionFloat opt = optWrap.m_opts[optFlag].float_map[key]; m_spinctrl = new SlSpinCtrlDouble<SingleOptionDialog>(); m_spinctrl->Create( this, wxID_ANY, _T( "" ), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, double( opt.min ), double( opt.max ), double( opt.value ), double( opt.stepping ), opt.key ); m_spinctrl->SetToolTip( TE( opt.description ) ); m_main_sizer->Add( m_spinctrl, 0, wxEXPAND ); break; } case opt_string: { mmOptionString opt = optWrap.m_opts[optFlag].string_map[key]; m_textctrl = new wxTextCtrl( this, wxID_ANY, opt.value, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, opt.key ); m_textctrl->SetToolTip( TE( opt.description ) ); m_main_sizer->Add( m_textctrl, 0, wxEXPAND ); break; } case opt_list: { mmOptionList opt = optWrap.m_opts[optFlag].list_map[key]; int temp = int( opt.cbx_choices.GetCount() - 1 ); int index = clamp( opt.cur_choice_index, 0, temp ); m_combobox = new wxComboBox( this, wxID_ANY, opt.cbx_choices[index], wxDefaultPosition, wxDefaultSize, opt.cbx_choices, wxCB_READONLY, wxDefaultValidator ); wxString tooltip = opt.description + _T( "\n" ); for ( ListItemVec::iterator itor = opt.listitems.begin(); itor != opt.listitems.end(); itor++ ) { tooltip += _T( "\n" ) + itor->name + _T( ": " ) + itor->desc; } m_combobox->SetToolTip( TE( tooltip ) ); m_main_sizer->Add( m_combobox, 0, wxEXPAND ); break; } default: { EndModal( wxID_CANCEL ); return; break; } } wxSize __SpacerSize_1 = wxDLG_UNIT( this, wxSize( 0, 0 ) ); m_main_sizer->Add( __SpacerSize_1.GetWidth(), __SpacerSize_1.GetHeight(), 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5 ); wxStaticLine* m_separator1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxSize( 10, -1 ), wxLI_HORIZONTAL, _T( "ID_STATICLINE1" ) ); m_main_sizer->Add( m_separator1, 0, wxALL | wxEXPAND | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5 ); wxBoxSizer* m_buttons_sizer = new wxBoxSizer( wxHORIZONTAL ); m_cancel_button = new wxButton( this, ID_CANCEL, _( "Cancel" ), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T( "ID_CANCEL" ) ); m_buttons_sizer->Add( m_cancel_button, 0, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 5 ); m_buttons_sizer->Add( 0, 0, 1, wxALL | wxEXPAND | wxSHAPED | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 0 ); m_ok_button = new wxButton( this, ID_OK, _( "Ok" ), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T( "ID_OK" ) ); m_buttons_sizer->Add( m_ok_button, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5 ); m_main_sizer->Add( m_buttons_sizer, 0, wxALL | wxEXPAND | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 0 ); m_main_sizer->Fit( this ); m_main_sizer->SetSizeHints( this ); SetSizer( m_main_sizer ); Layout(); Connect( ID_CANCEL, wxEVT_COMMAND_BUTTON_CLICKED, ( wxObjectEventFunction )&SingleOptionDialog::OnCancel ); Connect( ID_OK, wxEVT_COMMAND_BUTTON_CLICKED, ( wxObjectEventFunction )&SingleOptionDialog::OnOk ); }
LobbyOptionsTab::LobbyOptionsTab(wxWindow* parent) : wxScrolledWindow( parent, -1 ), m_show_tooltips_label( 0 ) { GetAui().manager->AddPane( this, wxLEFT, _T("lobbyoptionstab") ); m_main_sizer = new wxBoxSizer ( wxVERTICAL ); /* ================================ * Web browser */ wxStaticBox* m_web_box = new wxStaticBox( this , -1, _("Web Browser") ); m_web_loc_text = new wxStaticText( this, -1, _("Web Browser") ); m_web_def_radio = new wxRadioButton( this, SPRING_DEFWEB, _("Default Browser."), wxDefaultPosition, wxDefaultSize, wxRB_GROUP ); m_web_def_radio->SetToolTip(TE(_("Use your system-wide browser preference"))); m_web_spec_radio = new wxRadioButton( this, SPRING_DEFWEB, _("Specify:") ); m_web_spec_radio->SetToolTip(TE(_("Specify the web browser you want to use"))); m_web_edit = new wxTextCtrl( this, -1, sett().GetWebBrowserPath() ); m_web_browse_btn = new wxButton( this, SPRING_WEBBROWSE, _("Browse") ); m_web_browse_btn->SetToolTip(TE(_("Use a file dialog to find the web browser"))); if ( sett().GetWebBrowserUseDefault() ) m_web_def_radio->SetValue( true ); else m_web_spec_radio->SetValue( true ); m_web_loc_sizer = new wxBoxSizer( wxHORIZONTAL ); m_web_loc_sizer->Add( m_web_loc_text, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2 ); m_web_loc_sizer->Add( m_web_edit, 1, wxEXPAND ); m_web_loc_sizer->Add( m_web_browse_btn ); m_web_box_sizer = new wxStaticBoxSizer( m_web_box, wxVERTICAL ); m_web_box_sizer->Add( m_web_def_radio, 0, wxALL, 2 ); m_web_box_sizer->Add( m_web_spec_radio, 0, wxALL, 2 ); m_web_box_sizer->Add( m_web_loc_sizer, 0, wxEXPAND | wxALL, 2 ); ///// wxStaticBox* m_editor_box = new wxStaticBox( this , -1, _("External text editor") ); m_editor_loc_text = new wxStaticText( this, -1, _("Path") ); m_editor_edit = new wxTextCtrl( this, -1, sett().GetEditorPath() ); m_editor_browse_btn = new wxButton( this, ID_BUT_EDITOR, _("Browse") ); m_editor_browse_btn->SetToolTip(TE(_("Use a file dialog to find the editor binary"))); m_editor_loc_sizer = new wxBoxSizer( wxHORIZONTAL ); m_editor_loc_sizer->Add( m_editor_loc_text, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2 ); m_editor_loc_sizer->Add( m_editor_edit, 1, wxEXPAND ); m_editor_loc_sizer->Add( m_editor_browse_btn ); m_editor_box_sizer = new wxStaticBoxSizer( m_editor_box, wxVERTICAL ); m_editor_box_sizer->Add( m_editor_loc_sizer, 0, wxEXPAND | wxALL, 2 ); //////// wxStaticBoxSizer* m_autojoin_sizer= new wxStaticBoxSizer ( wxVERTICAL, this, _("Autoconnect") ); m_autoconnect_label = new wxStaticText ( this, -1, _("If checked, SpringLobby will automatically log on to the last used server") ); m_autojoin = new wxCheckBox( this, -1, _("Autoconnect on lobby start"), wxDefaultPosition, wxDefaultSize, 0 ); m_autojoin->SetValue( sett().GetAutoConnect() ); m_autojoin_sizer->Add( m_autoconnect_label, 1, wxEXPAND | wxALL, 5 ); m_autojoin_sizer->Add( m_autojoin, 0, wxEXPAND | wxALL, 5 ); wxStaticBoxSizer* m_reportstats_sizer = new wxStaticBoxSizer ( wxVERTICAL, this, _("Report statistics") ); m_reportstats_label = new wxStaticText ( this, -1, _("By default SpringLobby will send some statistics (OS,SpringLobby version) to server,\nto both make helping you in case of problems easier and inform of critical updates.\nUncheck to disable.") ); m_reportstats = new wxCheckBox( this, -1, _("report statistics"), wxDefaultPosition, wxDefaultSize, 0 ); m_reportstats->SetValue( sett().GetReportStats() ); m_reportstats_sizer->Add( m_reportstats_label, 1, wxEXPAND|wxALL, 5); m_reportstats_sizer->Add( m_reportstats, 0, wxEXPAND|wxALL, 5); m_main_sizer->Add( m_web_box_sizer, 0, wxEXPAND | wxALL, 5 ); m_main_sizer->Add( m_editor_box_sizer, 0, wxEXPAND | wxALL, 5 ); m_main_sizer->Add( m_autojoin_sizer, 0, wxALL, 5 ); m_main_sizer->Add( m_reportstats_sizer, 0, wxALL, 5 ); #ifdef __WXMSW__ wxStaticBoxSizer* m_updater_sizer = new wxStaticBoxSizer ( wxVERTICAL, this, _("Automatic updates") ); m_updater_label = new wxStaticText ( this, -1, _("SpringLobby can check at startup if a newer version is available and automatically download it for you.") ); m_updater = new wxCheckBox( this, -1, _("automatically check for updates"), wxDefaultPosition, wxDefaultSize, 0 ); m_updater->SetValue( sett().GetAutoUpdate() ); m_updater_sizer->Add( m_updater_label, 1, wxEXPAND|wxALL, 5); m_updater_sizer->Add( m_updater, 0, wxEXPAND|wxALL, 5); m_main_sizer->Add( m_updater_sizer, 0, wxALL, 5 ); #endif wxStaticBoxSizer* m_show_tooltips_sizer = new wxStaticBoxSizer ( wxVERTICAL, this, _("Tooltips") ); m_show_tooltips = new wxCheckBox( this, -1, _("Show Tooltips?"), wxDefaultPosition, wxDefaultSize, 0 ); m_show_tooltips->SetValue( sett().GetShowTooltips() ); #ifndef __WXMSW__ // on windows this change is immediate m_show_tooltips_label = new wxStaticText ( this, -1, _("Requires SpringLobby restart to take effect.") ); m_show_tooltips_sizer->Add( m_show_tooltips_label, 1, wxEXPAND|wxALL, 5); #endif m_show_tooltips_sizer->Add( m_show_tooltips, 0, wxEXPAND|wxALL, 5); m_main_sizer->Add( m_show_tooltips_sizer, 0, wxALL, 5 ); wxStaticBoxSizer* m_complete_method_sizer = new wxStaticBoxSizer ( wxVERTICAL, this, _("Tab completion method") ); m_complete_method_label = new wxStaticText ( this, -1, _("\"Match exact\" will complete a word if there is one and only one match.\n" "\"Match nearest\" will select the (first) match that has closest Levenshtein distance") ); m_complete_method_old = new wxRadioButton( this, -1, _("Match exact"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP ); m_complete_method_new = new wxRadioButton( this, -1, _("Match nearest"), wxDefaultPosition, wxDefaultSize ); m_complete_method_old->SetValue( sett().GetCompletionMethod() == Settings::MatchExact ); m_complete_method_new->SetValue( sett().GetCompletionMethod() == Settings::MatchNearest ); m_complete_method_sizer->Add( m_complete_method_label, 1, wxEXPAND|wxALL, 5); m_complete_method_sizer->Add( m_complete_method_old, 0, wxEXPAND|wxALL, 5); m_complete_method_sizer->Add( m_complete_method_new, 0, wxEXPAND|wxALL, 5); m_main_sizer->Add( m_complete_method_sizer, 0, wxALL, 5 ); wxStaticBoxSizer* m_misc_gui_sizer = new wxStaticBoxSizer ( wxVERTICAL, this, _("Misc GUI") ); m_use_tabicons = new wxCheckBox( this, -1, _("Show big icons in mainwindow tabs?"), wxDefaultPosition, wxDefaultSize, 0 ); m_use_tabicons->SetValue( sett().GetUseTabIcons() ); m_misc_gui_sizer->Add( m_use_tabicons , 0, wxEXPAND | wxALL, 5 ); m_use_notif_popups = new wxCheckBox( this, -1, _("Use notification popups?"), wxDefaultPosition, wxDefaultSize, 0 ); m_misc_gui_sizer->Add( m_use_notif_popups, 0, wxEXPAND | wxALL, 5 ); m_notif_popup_pos_sizer = new wxBoxSizer( wxHORIZONTAL ); m_notif_popup_pos_label = new wxStaticText( this, -1, _("Screen position for notification popups") ); m_notif_popup_pos = new wxChoice( this, -1, wxDefaultPosition, wxDefaultSize, ScreenPosition() ); m_notif_popup_pos_sizer->Add( m_notif_popup_pos_label, 0, wxALL| wxALIGN_CENTER_VERTICAL, 5 ); m_notif_popup_pos_sizer->Add( m_notif_popup_pos, 0, wxALL| wxALIGN_CENTER_VERTICAL, 5 ); m_misc_gui_sizer->Add( m_notif_popup_pos_sizer, 0, wxEXPAND | wxALL, 0 ); m_notif_popup_time_sizer = new wxBoxSizer( wxHORIZONTAL ); m_notif_popup_time = new wxSpinCtrl( this, wxID_ANY ); m_notif_popup_time_label = new wxStaticText( this, -1, _("Display time for popup notifications in seconds") ); m_notif_popup_time_sizer->Add( m_notif_popup_time_label, 0, wxALL| wxALIGN_CENTER_VERTICAL, 5 ); m_notif_popup_time_sizer->Add( m_notif_popup_time, 0, wxALL| wxALIGN_CENTER_VERTICAL, 5 ); m_misc_gui_sizer->Add( m_notif_popup_time_sizer, 0, wxEXPAND | wxALL, 0 ); m_x_on_all_tabs = new wxCheckBox( this, -1, _("Show close button on all tabs? (needs restart to take effect)"), wxDefaultPosition, wxDefaultSize, 0 ); m_x_on_all_tabs->SetValue( sett().GetShowXallTabs() ); m_misc_gui_sizer->Add( m_x_on_all_tabs , 1, wxEXPAND | wxALL, 5 ); m_main_sizer->Add( m_misc_gui_sizer , 0, wxALL, 5 ); wxStaticBoxSizer* m_start_tab_sizer = new wxStaticBoxSizer ( wxHORIZONTAL, this, _("Start tab") ); m_start_tab = new wxChoice( this, -1, wxDefaultPosition, wxDefaultSize, MainWindow::GetTabNames() ); m_start_tab->SetSelection( sett().GetStartTab() ); wxStaticText* m_start_tab_label = new wxStaticText ( this, -1, _("Select which tab to show at startup") ); m_start_tab_sizer->Add( m_start_tab_label , 0, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxALL, 5 ); m_start_tab_sizer->Add( m_start_tab , 0, wxALIGN_CENTER_VERTICAL , 5 ); m_main_sizer->Add( m_start_tab_sizer, 0, wxALL, 5 ); //dummy event that updates controls to correct state wxCommandEvent evt; OnRestore( evt ); SetScrollRate( SCROLL_RATE, SCROLL_RATE ); SetSizer( m_main_sizer ); Layout(); }
AddBotDialog::AddBotDialog( wxWindow* parent, IBattle& battle , bool singleplayer) : wxDialog( parent, wxID_ANY, _("Add bot"), wxDefaultPosition, wxDefaultSize, wxRESIZE_BORDER | wxDEFAULT_DIALOG_STYLE ), WindowAttributesPickle( _T("ADDBOTDIALOG"), this, wxSize(-1, 255) ), m_battle( battle ), m_sp(singleplayer) { //this->SetSizeHints( wxDefaultSize, wxDefaultSize ); m_main_sizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* m_nick_sizer; m_nick_sizer = new wxBoxSizer( wxHORIZONTAL ); m_nick_lbl = new wxStaticText( this, wxID_ANY, _("Nickname:"), wxDefaultPosition, wxDefaultSize, 0 ); m_nick_sizer->Add( m_nick_lbl, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); int bot = m_battle.GetNumBots()+1; m_nick = new wxTextCtrl( this, wxID_ANY, wxString::Format( _T("Bot%d"), bot ), wxDefaultPosition, wxDefaultSize, 0 ); m_nick_sizer->Add( m_nick, 2, wxALL, 5 ); m_main_sizer->Add( m_nick_sizer, 0, wxEXPAND, 5 ); wxBoxSizer* m_ai_sizer; m_ai_sizer = new wxBoxSizer( wxHORIZONTAL ); m_ai_lbl = new wxStaticText( this, wxID_ANY, _("AI:"), wxDefaultPosition, wxDefaultSize, 0 ); m_ai_sizer->Add( m_ai_lbl, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); m_ai = new wxChoice( this, ADDBOT_AI ); m_ai->SetToolTip( TE(_("Choose the AI library to use with this bot.") ) ); m_ai_sizer->Add( m_ai, 2, wxALL, 5 ); m_main_sizer->Add( m_ai_sizer, 0, wxEXPAND, 5 ); if ( usync().VersionSupports( IUnitSync::USYNC_GetSkirmishAI ) ) { m_ai_infos_lst = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxLC_REPORT | wxLC_SINGLE_SEL | wxLC_NO_HEADER ); wxListItem col; col.SetText( _("property") ); col.SetImage( -1 ); m_ai_infos_lst->InsertColumn( 0, col ); wxListItem col2; col2.SetText( _("value") ); col2.SetImage( -1 ); m_ai_infos_lst->InsertColumn( 1, col2 ); m_opts_list = new wxListCtrl( this, ADDBOT_OPTIONLIST, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxLC_REPORT | wxLC_SINGLE_SEL | wxLC_NO_HEADER ); wxListItem col3; col3.SetText( _("property") ); col3.SetImage( -1 ); m_opts_list->InsertColumn( 0, col3 ); wxListItem col4; col4.SetText( _("value") ); col4.SetImage( -1 ); m_opts_list->InsertColumn( 1, col4 ); m_info_sizer = new wxBoxSizer(wxVERTICAL); m_info_sizer->Add( m_ai_infos_lst, 1, wxALL|wxEXPAND ); m_info_sizer->Add( m_opts_list, 1, wxALL|wxEXPAND ); m_main_sizer->Add( m_info_sizer, 1, wxALL|wxEXPAND ); } else { m_main_sizer->AddStretchSpacer(); } m_buttons_sep = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); m_main_sizer->Add( m_buttons_sep, 0, wxALL|wxEXPAND ); wxBoxSizer* m_buttons_sizer; m_buttons_sizer = new wxBoxSizer( wxHORIZONTAL ); m_cancel_btn = new wxButton( this, ADDBOT_CANCEL, _("Cancel"), wxDefaultPosition, wxSize(-1,CONTROL_HEIGHT), 0 ); m_buttons_sizer->Add( m_cancel_btn, 0, wxALL ); m_buttons_sizer->Add( 0, 0, 1, wxEXPAND ); m_add_btn = new wxButton( this, ADDBOT_ADD, _("Add Bot"), wxDefaultPosition, wxSize(-1,CONTROL_HEIGHT), 0 ); m_buttons_sizer->Add( m_add_btn, 0, wxALL ); m_main_sizer->Add( m_buttons_sizer, 0, wxEXPAND ); this->SetSizer( m_main_sizer ); this->Layout(); ReloadAIList(); }
//! @brief Constructor //! //! @param parent Parent window ConnectWindow::ConnectWindow( wxWindow* parent, Ui& ui ) : wxDialog( parent, -1, _("Connect to lobby server"), wxDefaultPosition, wxSize(300, 300), wxDEFAULT_DIALOG_STYLE | wxCLIP_CHILDREN ), m_ui(ui) { wxString server; wxString username; wxString password; bool savepass; bool autoconnect; SetIcon( wxIcon(connect_xpm) ); server = sett().GetDefaultServer(); username = sett().GetServerAccountNick( sett().GetDefaultServer() ); password = sett().GetServerAccountPass( sett().GetDefaultServer() ); savepass = sett().GetServerAccountSavePass( sett().GetDefaultServer() ); autoconnect = sett().GetAutoConnect(); // Create all UI elements. m_tabs = new wxNotebook( this , -1 ); m_login_tab = new wxPanel ( m_tabs, -1 ); m_register_tab = new wxPanel ( m_tabs, -1 ); m_server_lbl = new wxStaticText( m_login_tab, -1, _("Server") ); m_server_combo = new wxComboBox ( m_login_tab, CON_SERV_SEL, server ); m_server_combo->SetToolTip( TE(_("Server to connect to. You can connect to any server you like by typing in hostaddress:port format.")) ); m_ser_acc_line = new wxStaticLine( m_login_tab ); m_nick_lbl = new wxStaticText( m_login_tab, -1, _("Nickname") ); m_nick_text = new wxTextCtrl ( m_login_tab, -1, username ); m_pass_lbl = new wxStaticText( m_login_tab, -1, _("Password") ); m_pass_text = new wxTextCtrl ( m_login_tab, -1, password, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD ); m_rpass_check = new wxCheckBox ( m_login_tab, -1, _("Remember password") ); m_autoconnect_check = new wxCheckBox ( m_login_tab, -1, _("Autoconnect next time") ); m_autoconnect_check->SetToolTip( TE(_("remember connection details and automatically connect to server on next lobby startup")) ); wxToolTip::Enable( false ); m_rpass_check->SetValue( savepass ); m_autoconnect_check->SetValue( autoconnect ); m_acc_note_line = new wxStaticLine( m_login_tab ); m_note_lbl = new wxStaticText( m_login_tab, -1, _("Note: If you do not have an account, you\n can register one for free on the\n\"Register\" tab.") ); m_ok_btn = new wxButton( this, wxID_OK, _("Ok") ); m_cancel_btn = new wxButton( this, wxID_CANCEL, _("Cancel") ); // Add tabs to tab control. m_tabs->AddPage( m_login_tab, _("Login"), true ); m_tabs->AddPage( m_register_tab, _("Register"), false ); // Create sizers. m_main_sizer = new wxBoxSizer( wxVERTICAL ); m_login_main_sizer = new wxBoxSizer( wxVERTICAL ); m_server_sizer = new wxBoxSizer( wxHORIZONTAL ); m_nick_sizer = new wxBoxSizer( wxHORIZONTAL ); m_pass_sizer = new wxBoxSizer( wxHORIZONTAL ); m_rpass_sizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* m_check_sizer = new wxBoxSizer( wxHORIZONTAL ); m_buttons_sizer = new wxStdDialogButtonSizer(); // Add UI elements to sizers. m_buttons_sizer->Add( m_ok_btn ); m_buttons_sizer->AddStretchSpacer(); m_buttons_sizer->Add( m_cancel_btn ); m_rpass_sizer->Add( m_rpass_check, 2, wxEXPAND | wxALL | wxALIGN_RIGHT, 4 ); m_rpass_sizer->Add( m_autoconnect_check, 2, wxEXPAND | wxALL | wxALIGN_RIGHT, 4 ); m_pass_sizer->Add( m_pass_lbl, 1, wxALL | wxALIGN_CENTER_VERTICAL, 4 ); m_pass_sizer->Add( m_pass_text, 2, wxEXPAND | wxALL, 4 ); //FIXME was lazy, absoulte positioning isn't that nice //probably causing http://springlobby.info/issues/1094 int pos1 = (m_pass_lbl->GetSize()).GetWidth() + 40; m_check_sizer->Add(pos1,0,0); m_check_sizer->Add( m_rpass_sizer, 0, wxEXPAND | wxALIGN_RIGHT); m_nick_sizer->Add( m_nick_lbl, 1, wxALL | wxALIGN_CENTER_VERTICAL, 4 ); m_nick_sizer->Add( m_nick_text, 2, wxEXPAND | wxALL, 4 ); m_server_sizer->Add( m_server_lbl, 1, wxALL | wxALIGN_CENTER_VERTICAL, 4 ); m_server_sizer->Add( m_server_combo, 2, wxEXPAND | wxALL, 4 ); m_login_main_sizer->Add( m_server_sizer, 0, wxEXPAND | wxALL, 0 ); m_login_main_sizer->Add( m_ser_acc_line, 0, wxEXPAND | wxALL, 4 ); m_login_main_sizer->Add( m_nick_sizer, 0, wxEXPAND ); m_login_main_sizer->Add( m_pass_sizer, 0, wxEXPAND ); m_login_main_sizer->Add( m_check_sizer, 0, wxEXPAND ); m_login_main_sizer->Add( m_acc_note_line, 0, wxEXPAND | wxALL, 4 ); m_login_main_sizer->Add( m_note_lbl, 0, wxEXPAND | wxALL, 4 ); m_login_main_sizer->AddStretchSpacer(); m_login_tab->SetSizer( m_login_main_sizer ); m_main_sizer->Add( m_tabs, 1, wxEXPAND ); m_main_sizer->Add( m_buttons_sizer, 0, wxEXPAND ); // Register page wxBoxSizer* m_register_sizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* m_regnick_sizer = new wxBoxSizer( wxHORIZONTAL ); m_regnick_lbl = new wxStaticText( m_register_tab, wxID_ANY, _("Nick"), wxDefaultPosition, wxDefaultSize, 0 ); m_regnick_sizer->Add( m_regnick_lbl, 1, wxALL | wxALIGN_CENTER_VERTICAL, 4 ); m_regnick_text = new wxTextCtrl( m_register_tab, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_regnick_sizer->Add( m_regnick_text, 1, wxALL, 4 ); m_register_sizer->Add( m_regnick_sizer, 0, wxEXPAND, 4 ); m_regpass_sep = new wxStaticLine( m_register_tab, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); m_register_sizer->Add( m_regpass_sep, 0, wxALL|wxEXPAND, 4 ); wxBoxSizer* m_regpass1_sizer = new wxBoxSizer( wxHORIZONTAL ); m_regpass1_lbl = new wxStaticText( m_register_tab, wxID_ANY, _("Password"), wxDefaultPosition, wxDefaultSize, 0 ); m_regpass1_sizer->Add( m_regpass1_lbl, 1, wxALL | wxALIGN_CENTER_VERTICAL, 4 ); m_regpass1_text = new wxTextCtrl( m_register_tab, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD ); m_regpass1_sizer->Add( m_regpass1_text, 1, wxALL, 4 ); m_register_sizer->Add( m_regpass1_sizer, 0, wxEXPAND, 4 ); wxBoxSizer* m_regpass1_sizer1 = new wxBoxSizer( wxHORIZONTAL ); m_regpass2_lbl = new wxStaticText( m_register_tab, wxID_ANY, wxT("Retype password"), wxDefaultPosition, wxDefaultSize, 0 ); m_regpass1_sizer1->Add( m_regpass2_lbl, 1, wxALL | wxALIGN_CENTER_VERTICAL, 4 ); m_regpass2_text = new wxTextCtrl( m_register_tab, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD ); m_regpass1_sizer1->Add( m_regpass2_text, 1, wxALL, 4 ); m_register_sizer->Add( m_regpass1_sizer1, 0, wxEXPAND, 4 ); m_register_tab->SetSizer( m_register_sizer ); m_register_tab->Layout(); m_register_sizer->Fit( m_register_tab ); // Set sizer. SetSizer( m_main_sizer ); if ( !username.empty() ) { m_ok_btn->SetFocus(); } else { m_nick_text->SetFocus(); } m_ok_btn->SetDefault(); Layout(); m_main_sizer->SetSizeHints( this ); #ifdef __WXMSW__ SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) ); #endif ReloadServerList(); }
BattleRoomTab::BattleRoomTab( wxWindow* parent, Battle* battle ) : wxScrolledWindow( parent, -1 ), m_battle( battle ), m_BattleActionSink( this, &UiEvents::GetUiEventSender( UiEvents::OnBattleActionEvent )) { GetAui().manager->AddPane( this, wxLEFT, _T( "battleroomtab" ) ); // Create all widgets m_splitter = new wxSplitterWindow( this, -1, wxDefaultPosition, wxSize( 100, 60 ) ); m_player_panel = new wxScrolledWindow( m_splitter , -1 ); m_player_panel->SetScrollRate( SCROLL_RATE, SCROLL_RATE ); m_team_sel = new wxComboBox( m_player_panel, BROOM_TEAMSEL, _T( "1" ), wxDefaultPosition, wxSize( 50, CONTROL_HEIGHT ), team_choices ); m_team_sel->SetToolTip( TE( _( "Players with the same team number share control of their units." ) ) ); m_ally_sel = new wxComboBox( m_player_panel, BROOM_ALLYSEL, _T( "1" ), wxDefaultPosition, wxSize( 50, CONTROL_HEIGHT ), ally_choices ); m_ally_sel->SetToolTip( TE( _( "Players with the same ally number work together to achieve victory." ) ) ); m_color_sel = new ColorButton( m_player_panel, BROOM_COLOURSEL, wxColour (0,0,0), wxDefaultPosition, wxSize( -1, CONTROL_HEIGHT ) ); m_color_sel->SetToolTip( TE( _( "Select a color to identify your units in-game" ) ) ); m_side_sel = new wxBitmapComboBox( m_player_panel, BROOM_SIDESEL, _T( "" ), wxDefaultPosition, wxSize( -1, CONTROL_HEIGHT ) ); m_side_sel->SetToolTip( TE( _( "Select your faction" ) ) ); m_spec_chk = new wxCheckBox( m_player_panel, BROOM_SPEC, _( "Spectator" ), wxDefaultPosition, wxSize( -1, CONTROL_HEIGHT ) ); m_spec_chk->SetToolTip( TE( _( "Spectate (watch) the battle instead of playing" ) ) ); m_ready_chk = new wxCheckBox( m_player_panel, BROOM_IMREADY, _( "I'm ready" ), wxDefaultPosition, wxSize( -1, CONTROL_HEIGHT ) ); m_ready_chk->SetToolTip( TE( _( "Click this if you are content with the battle settings." ) ) ); m_team_lbl = new wxStaticText( m_player_panel, -1, _( "Team" ) ); m_ally_lbl = new wxStaticText( m_player_panel, -1, _( "Ally" ) ); m_color_lbl = new wxStaticText( m_player_panel, -1, _( "Color" ) ); m_side_lbl = new wxStaticText( m_player_panel, -1, _( "Side" ) ); m_ally_setup_lbl = new wxStaticText( m_player_panel, -1, wxString::Format( _( "Setup: %s" ), _T("") ) ); m_ok_count_lbl = new wxStaticText( m_player_panel, -1, wxString::Format( _( "Unready: %d" ), 0 ) ); //XXX not needed ? // m_size_lbl = new wxStaticText( this, -1, _T( "" ) ); // m_wind_lbl = new wxStaticText( this, -1, _T( "" ) ); // m_tidal_lbl = new wxStaticText( this, -1, _T( "" ) ); m_map_combo = new wxComboBox( this, BROOM_MAP_SEL, _T( "" ), wxDefaultPosition, wxDefaultSize ); m_minimap = new MapCtrl( this, 162, m_battle, true, true, true, false ); m_minimap->SetToolTip( TE( _( "A preview of the selected map. You can see the starting positions, or (if set) starting boxes." ) ) ); m_browse_map_btn = new wxButton( this, BROOM_MAP_BROWSE, _( "Map" ), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); m_browse_map_btn->SetSize( m_browse_map_btn->GetSize().GetWidth() * 2 , m_browse_map_btn->GetSize().GetHeight() ) ; // has 0 effect m_players = new BattleroomListCtrl( m_player_panel, m_battle, false, true ); m_chat = new ChatPanel( m_splitter, m_battle ); m_command_line = new wxStaticLine( this, -1, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); m_host_new_btn = new wxButton( this, BROOM_HOST_NEW, _( "Host new" ), wxDefaultPosition, wxDefaultSize ); m_host_new_btn->SetToolTip( TE( _( "Host a new battle" ) ) ); m_leave_btn = new wxButton( this, BROOM_LEAVE, _( "Leave" ), wxDefaultPosition, wxSize( -1, CONTROL_HEIGHT ) ); m_leave_btn->SetToolTip( TE( _( "Leave the battle and return to the battle list" ) ) ); m_start_btn = new wxButton( this, BROOM_START, _( "Start" ), wxDefaultPosition, wxSize( -1, CONTROL_HEIGHT ) ); m_start_btn->SetToolTip( TE( _( "Start the battle" ) ) ); m_manage_players_btn = new wxButton( this, BROOM_MANAGE_MENU, _( "Player Management" ), wxDefaultPosition, wxSize( -1, CONTROL_HEIGHT ) ); m_manage_players_btn->SetToolTip( TE( _( "Various functions to make team games simplers to setup" ) ) ); m_addbot_btn = new wxButton( this, BROOM_ADDBOT, _( "Add Bot..." ), wxDefaultPosition, wxSize( -1, CONTROL_HEIGHT ) ); m_addbot_btn->SetToolTip( TE( _( "Add a computer-controlled player to the game" ) ) ); m_autolock_chk = new wxCheckBox( this, BROOM_AUTOLOCK, _( "Autolock on start" ), wxDefaultPosition, wxSize( -1, CONTROL_HEIGHT ) ); m_autolock_chk->SetToolTip( TE( _( "Automatically locks the battle when the game starts and unlock when it's finished." ) ) ); m_autolock_chk->SetValue( sett().GetLastAutolockStatus() ); m_lock_chk = new wxCheckBox( this, BROOM_LOCK, _( "Locked" ), wxDefaultPosition, wxSize( -1, CONTROL_HEIGHT ) ); m_lock_chk->SetToolTip( TE( _( "Prevent additional players from joining the battle" ) ) ); m_manage_users_mnu = new wxMenu(); m_autohost_mnu = new wxMenuItem( m_manage_users_mnu, BROOM_AUTOHOST, _( "Autohost" ), _( "Toggle autohost mode. This allows players to control your battle using commands like '!balance' and '!start'." ), wxITEM_CHECK ); m_manage_users_mnu->Append( m_autohost_mnu ); m_autohost_mnu->Check( false ); m_autopaste_mnu = new wxMenuItem( m_manage_users_mnu, BROOM_AUTOPASTE, _( "AutoPaste Description" ), _( "Automatically paste battle's descriptoin when a new user joins" ), wxITEM_CHECK ); m_manage_users_mnu->Append( m_autopaste_mnu ); m_autopaste_mnu->Check( sett().GetBattleLastAutoAnnounceDescription() ); m_autospec_mnu = new wxMenuItem( m_manage_users_mnu, BROOM_AUTOSPECT, _( "AutoSpect" ), _( "Automatically spectate players that don't ready up or become synced within x seconds." ), wxITEM_CHECK ); m_manage_users_mnu->Append( m_autospec_mnu ); m_autospec_mnu->Check( sett().GetBattleLastAutoSpectTime() > 0 ); m_autocontrol_mnu = new wxMenuItem( m_manage_users_mnu, BROOM_AUTOCONTROL, _( "AutoControlBalance" ), _( "Automatically balance teams and allies and fix colors when all players are ready and synced" ), wxITEM_CHECK ); m_manage_users_mnu->Append( m_autocontrol_mnu ); m_autocontrol_mnu->Check( sett().GetBattleLastAutoControlState() ); m_autostart_mnu = new wxMenuItem( m_manage_users_mnu, BROOM_AUTOSTART, _( "AutoStart" ), _( "Automatically start the battle when all players are ready and synced" ), wxITEM_CHECK ); m_manage_users_mnu->Append( m_autostart_mnu ); m_autostart_mnu->Check( sett().GetBattleLastAutoStartState() ); m_lock_balance_mnu = new wxMenuItem( m_manage_users_mnu, BROOM_LOCK_BALANCE, _( "Lock Balance" ), _( "When activated, prevents anyone but the host to change team and ally" ), wxITEM_CHECK ); m_manage_users_mnu->Append( m_lock_balance_mnu ); m_lock_balance_mnu->Check( false ); wxMenu* ring_menu = new wxMenu; wxMenuItem* ring_unready = new wxMenuItem( ring_menu, BROOM_RING_UNREADY, _( "Ring unready" ), _( "Rings all players that don't have ready status and aren't spectators" ) ); ring_menu->Append( ring_unready ); wxMenuItem* ring_unsynced = new wxMenuItem( ring_menu, BROOM_RING_UNSYNC, _( "Ring unsynced" ), _( "Rings all players that don't have sync status and aren't spectators" ) ); ring_menu->Append( ring_unsynced ); wxMenuItem* ring_unready_unsynced = new wxMenuItem( ring_menu, BROOM_RING_UNREADY_UNSYNC, _( "Ring unready and unsynced" ), _( "Rings all players that don't have sync status or don't have ready status and aren't spectators" ) ); ring_menu->Append( ring_unready_unsynced ); m_manage_users_mnu->Append( wxID_ANY, _( "Ring ..." ), ring_menu ); wxMenu* spect_menu = new wxMenu; wxMenuItem* spect_unready = new wxMenuItem( spect_menu, BROOM_SPECT_UNREADY, _( "Spect unready" ), _( "Force to spectate all players that don't have ready status" ) ); spect_menu->Append( spect_unready ); wxMenuItem* spect_unsynced = new wxMenuItem( spect_menu, BROOM_SPECT_UNSYNC, _( "Spect unsynced" ), _( "Force to spectate all players that don't have sync status" ) ); spect_menu->Append( spect_unsynced ); wxMenuItem* spect_unready_unsynced = new wxMenuItem( spect_menu, BROOM_SPECT_UNREADY_UNSYNC, _( "Force to spectate unready and unsynced" ), _( "Rings all players that don't have sync status or don't have ready status" ) ); spect_menu->Append( spect_unready_unsynced ); m_manage_users_mnu->Append( wxID_ANY, _( "Force spectate ..." ), spect_menu ); wxMenuItem* m_balance_mnu = new wxMenuItem( m_manage_users_mnu, BROOM_BALANCE, _( "Balance alliances" ), _( "Automatically balance players into two or more alliances" ) ); m_manage_users_mnu->Append( m_balance_mnu ); wxMenuItem* m_fix_colours_mnu = new wxMenuItem( m_manage_users_mnu, BROOM_FIXCOLOURS, _( "Fix colours" ), _( "Make player colors unique" ) ); m_manage_users_mnu->Append( m_fix_colours_mnu ); wxMenuItem* m_fix_team_mnu = new wxMenuItem( m_manage_users_mnu, BROOM_FIXID, _( "Balance teams" ), _( "Automatically balance players into control teams, by default none shares control" ) ); m_manage_users_mnu->Append( m_fix_team_mnu ); wxStaticBoxSizer* m_preset_sizer; m_preset_sizer = new wxStaticBoxSizer( new wxStaticBox( this, 0, _( "Manage Presets" ) ), wxVERTICAL ); wxBoxSizer* m_preset_btns_sizer; m_preset_btns_sizer = new wxBoxSizer( wxHORIZONTAL ); m_options_preset_sel = new wxComboBox( this, BROOM_PRESETSEL, _T(""), wxDefaultPosition, wxDefaultSize, sett().GetPresetList(), wxCB_READONLY ); m_options_preset_sel->SetToolTip( TE( _( "Load battle preset" ) ) ); m_preset_sizer->Add( m_options_preset_sel, 0, wxEXPAND | wxALL ); m_save_btn = new wxButton( this, BROOM_SAVEPRES, _( "Save" ), wxDefaultPosition, wxDefaultSize ); m_save_btn->SetToolTip( TE( _( "Save a set of options." ) ) ); m_preset_btns_sizer->Add( m_save_btn, 0, wxEXPAND ); m_delete_btn = new wxButton( this, BROOM_DELETEPRES, _( "Delete" ), wxDefaultPosition, wxDefaultSize ); m_delete_btn->SetToolTip( TE( _( "Delete a set of options." ) ) ); m_preset_btns_sizer->Add( m_delete_btn, 0, wxEXPAND ); m_default_btn = new wxButton( this, BROOM_SETDEFAULTPRES, _( "Set default" ), wxDefaultPosition, wxDefaultSize ); m_default_btn->SetToolTip( TE( _( "Use the current set of options as game's default." ) ) ); m_preset_btns_sizer->Add( m_default_btn, 0, wxEXPAND ); m_preset_sizer->Add( m_preset_btns_sizer, 0, wxEXPAND ); m_opts_list = new wxListCtrl( this, BROOM_OPTIONLIST, wxDefaultPosition, wxDefaultSize, wxLC_NO_HEADER | wxLC_REPORT ); //m_opts_list->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) ); m_opts_list->SetFont( wxFont( 8, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_LIGHT ) ); m_opts_list->SetToolTip( TE( _( "Activate an element to quickly change it" ) ) ); wxListItem col; col.SetText( _( "Option" ) ); m_opts_list->InsertColumn( 0, col ); col.SetText( _( "Value" ) ); m_opts_list->InsertColumn( 1, col ); // Create Sizers m_players_sizer = new wxBoxSizer( wxVERTICAL ); m_player_sett_sizer = new wxBoxSizer( wxHORIZONTAL ); wxBoxSizer* m_map_select_sizer = new wxBoxSizer( wxHORIZONTAL ); m_info_sizer = new wxBoxSizer( wxVERTICAL ); m_top_sizer = new wxBoxSizer( wxHORIZONTAL ); m_buttons_sizer = new wxBoxSizer( wxHORIZONTAL ); //m_info1_sizer = new wxBoxSizer( wxHORIZONTAL ); m_main_sizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* m_side_sel_sizer = new wxBoxSizer( wxHORIZONTAL ); #ifndef HAVE_WX29 int side_sel_width = m_side_sel->GetWidestItemWidth(); m_side_sel_sizer->SetMinSize( side_sel_width, CONTROL_HEIGHT ); #endif m_side_sel_sizer->Add( m_side_sel, 1, wxEXPAND ); // Put widgets in place m_player_sett_sizer->Add( m_team_lbl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2 ); m_player_sett_sizer->Add( m_team_sel, 0, wxEXPAND | wxALL, 2 ); m_player_sett_sizer->Add( m_ally_lbl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2 ); m_player_sett_sizer->Add( m_ally_sel, 0, wxEXPAND | wxALL, 2 ); m_player_sett_sizer->Add( m_color_lbl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2 ); m_player_sett_sizer->Add( m_color_sel, 0, wxEXPAND | wxALL, 2 ); m_player_sett_sizer->Add( m_side_lbl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2 ); m_player_sett_sizer->Add( m_side_sel_sizer, 0, wxEXPAND | wxALL, 2 ); m_player_sett_sizer->Add( m_spec_chk, 0, wxEXPAND | wxALL, 2 ); m_player_sett_sizer->Add( m_ready_chk, 0, wxEXPAND | wxALL, 2 ); m_player_sett_sizer->AddStretchSpacer(); m_player_sett_sizer->Add( m_ally_setup_lbl, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 2 ); m_player_sett_sizer->Add( m_ok_count_lbl, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 2 ); m_players_sizer->Add( m_players, 1, wxEXPAND ); m_players_sizer->Add( m_player_sett_sizer, 0, wxEXPAND ); m_player_panel->SetSizer( m_players_sizer ); SplitSizerHorizontally( sett().GetSplitBRoomHorizontally() ); //m_info1_sizer->Add( m_wind_lbl, 1, wxEXPAND ); //m_info1_sizer->Add( m_size_lbl, 1, wxEXPAND ); m_info_sizer->Add( m_minimap, 0, wxEXPAND ); m_map_select_sizer->Add( m_map_combo, 0, wxALL | wxEXPAND | wxALIGN_CENTER_VERTICAL ); m_map_select_sizer->Add( m_browse_map_btn, 0, wxALIGN_RIGHT ); m_info_sizer->Add( m_map_select_sizer, 0, wxALL ); //m_info_sizer->Add( m_info1_sizer, 0, wxEXPAND ); //m_info_sizer->Add( m_tidal_lbl, 0, wxEXPAND ); m_info_sizer->Add( m_opts_list, 1, wxEXPAND | wxTOP, 4 ); m_info_sizer->Add( m_preset_sizer, 0, wxEXPAND, 4 ); m_top_sizer->Add( m_splitter, 1, wxEXPAND | wxALL, 2 ); m_top_sizer->Add( m_info_sizer, 0, wxEXPAND | wxALL, 2 ); m_buttons_sizer->AddStretchSpacer(); m_buttons_sizer->Add( m_host_new_btn, 0, wxEXPAND | wxALL, 2 ); m_buttons_sizer->AddStretchSpacer(); m_buttons_sizer->Add( m_leave_btn, 0, wxEXPAND | wxALL, 2 ); m_buttons_sizer->Add( m_addbot_btn, 0, wxEXPAND | wxALL, 2 ); m_buttons_sizer->Add( m_autolock_chk, 0, wxEXPAND | wxALL, 2 ); m_buttons_sizer->Add( m_lock_chk, 0, wxEXPAND | wxALL, 2 ); m_buttons_sizer->Add( m_manage_players_btn, 0, wxEXPAND | wxALL, 2 ); m_buttons_sizer->Add( m_start_btn, 0, wxEXPAND | wxALL, 2 ); m_main_sizer->Add( m_top_sizer, 1, wxEXPAND ); m_main_sizer->Add( m_command_line, 0, wxEXPAND ); m_main_sizer->Add( m_buttons_sizer, 0, wxEXPAND ); m_splitter->SetMinimumPaneSize( 240 ); SetBattle( battle ); SetScrollRate( SCROLL_RATE, SCROLL_RATE ); SetSizer( m_main_sizer ); Layout(); unsigned int widthfraction = m_opts_list->GetClientSize().GetWidth() / 3; m_opts_list->SetColumnWidth( 0, widthfraction * 1.95 ); m_opts_list->SetColumnWidth( 1, widthfraction * 0.95 ); }
HostBattleDialog::HostBattleDialog( wxWindow* parent ) : wxDialog( parent, -1, _( "Host new battle" ), wxDefaultPosition, wxSize( 410, 441 ), wxRESIZE_BORDER | wxDEFAULT_DIALOG_STYLE ), WindowHintsPickle ( _T("hostbattledialog"), this, wxSize( 410, 441 ) ), m_last_relayhost( sett().GetLastRelayedHost() ) { // this->SetSizeHints( GetSize(), wxDefaultSize ); m_panel = new wxScrolledWindow( this ); // m_panel ->SetSizeHints( GetSize(), wxDefaultSize ); wxBoxSizer* all_sizer = new wxBoxSizer( wxVERTICAL ); wxFlexGridSizer* topsizer = new wxFlexGridSizer( 2, 0, 10); // topsizer->AddGrowableCol( 1, 1 ); // SetSizeHints( wxDefaultSize, wxDefaultSize ); wxBoxSizer* m_main_sizer; m_main_sizer = new wxBoxSizer( wxVERTICAL ); m_desc_lbl = new wxStaticText( m_panel, wxID_ANY, _( "Description" ), wxDefaultPosition, wxDefaultSize, 0 ); m_desc_lbl->Wrap( -1 ); topsizer->Add( m_desc_lbl, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); // wxBoxSizer* desc_sizer = new wxBoxSizer( wxVERTICAL ); m_desc_text = new wxTextCtrl( m_panel, wxID_ANY, sett().GetLastHostDescription(), wxDefaultPosition, wxDefaultSize, 0 ); m_desc_text->SetToolTip( TE( _( "A short description of the game, this will show up in the battle list." ) ) ); topsizer ->Add( m_desc_text, 1, wxALL | wxEXPAND, 5 ); m_desc_check = new wxCheckBox( m_panel, wxID_ANY, _( "Autopaste description" ) ); m_desc_check->SetValue( sett().GetBattleLastAutoAnnounceDescription() ); m_desc_check->SetToolTip( TE( _( "Automatically write the battle description when a user joins." ) ) ); topsizer->AddStretchSpacer(); topsizer->Add( m_desc_check, 0, wxLEFT, 5 ); // topsizer->Add( desc_sizer , 0, wxEXPAND | wxALL, 0 ); m_mod_lbl = new wxStaticText( m_panel, wxID_ANY, _( "Game" ), wxDefaultPosition, wxDefaultSize, 0 ); m_mod_lbl->Wrap( -1 ); topsizer->Add( m_mod_lbl, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 ); wxArrayString m_mod_picChoices; wxBoxSizer* mod_choice_button_sizer = new wxBoxSizer( wxHORIZONTAL ); m_mod_pic = new wxChoice( m_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_mod_picChoices, 0 ); m_mod_pic->SetToolTip( TE( _( "Select the game to play." ) ) ); mod_choice_button_sizer->Add( m_mod_pic, 0, wxALL , 5 ); wxBitmap mp = charArr2wxBitmap( arrow_refresh_png, sizeof( arrow_refresh_png ) ); m_refresh_btn = new wxBitmapButton( m_panel, BTN_REFRESH, mp ); mod_choice_button_sizer->Add( m_refresh_btn, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); topsizer->Add( mod_choice_button_sizer, 0, wxEXPAND|wxALL ,1 ); m_pwd_lbl = new wxStaticText( m_panel, wxID_ANY, _( "Password\n(no spaces)" ), wxDefaultPosition, wxDefaultSize, 0 ); m_pwd_lbl->Wrap( -1 ); topsizer->Add( m_pwd_lbl, 1, wxALL| wxALIGN_CENTER_VERTICAL, 5 ); m_pwd_text = new wxTextCtrl( m_panel, wxID_ANY, sett().GetLastHostPassword(), wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD ); m_pwd_text->SetToolTip( TE( _( "Password needed to join game. Keep empty for no password" ) ) ); topsizer->Add( m_pwd_text, 1, wxALL| wxEXPAND, 5 ); m_port_lbl = new wxStaticText( m_panel, wxID_ANY, _( "Port" ), wxDefaultPosition, wxDefaultSize, 0 ); m_port_lbl->Wrap( -1 ); topsizer->Add( m_port_lbl, 1, wxALL| wxALIGN_CENTER_VERTICAL, 5 ); m_port_text = new wxTextCtrl( m_panel, wxID_ANY, wxFormat( _T( "%d" ) ) % sett().GetLastHostPort(), wxDefaultPosition, wxDefaultSize, 0 ); m_port_text->SetToolTip( TE( _( "UDP port to host game on. Default is 8452." ) ) ); topsizer->Add( m_port_text, 1, wxALL| wxEXPAND, 5 ); // m_port_test_check = new wxCheckBox( m_panel, wxID_ANY, _("Test firewall"), wxDefaultPosition, wxDefaultSize, 0 ); // m_port_test_check->SetValue( sett().GetTestHostPort() ); // m_port_sizer->Add( m_port_test_check, 1, wxALL|wxEXPAND, 5 ); m_relayed_host_check = new wxCheckBox( m_panel, CHK_USE_RELAY, _( "Use relayhost" ), wxDefaultPosition, wxDefaultSize, 0 ); m_relayed_host_check->SetToolTip( TE( _( "host and control game on remote server, helps if you have trouble hosting" ) ) ); m_relayed_host_pick = new wxButton( m_panel, PICK_RELAYHOST, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); m_relayed_host_pick->SetLabel( m_last_relayhost.IsEmpty() ? _T("automatic") : m_last_relayhost ); m_relayhost_list = new wxMenu(); wxMenuItem* automatic_pick = new wxMenuItem( m_relayhost_list, AUTO_PICK_HOST, _("Chose automatically"), _("Randomly picks an available one"), wxITEM_RADIO ); m_relayhost_list->Append( automatic_pick ); automatic_pick->Check( m_last_relayhost.IsEmpty() ); m_relayhost_list->AppendSeparator(); wxMenuItem* manual_pick_relay = new wxMenuItem( m_relayhost_list, MANUAL_PICK_HOST, _("Manually enter the manager name"), _("You'll get prompted for the exact manager name"), wxITEM_RADIO ); m_relayhost_list->Append( manual_pick_relay ); m_relayhost_list->AppendSeparator(); m_relayhost_array_list = serverSelector().GetServer().GetRelayHostList(); for ( unsigned int i = 0; i < m_relayhost_array_list.GetCount(); i++ ) { wxMenuItem* newitem = new wxMenuItem( m_relayhost_list, MANUAL_PICK_HOST + 1 + i, m_relayhost_array_list[i], _T("") , wxITEM_RADIO ); m_relayhost_list->Append( newitem ); newitem->Check( m_last_relayhost == m_relayhost_array_list[i] ); } m_relayed_host_check->SetValue( sett().GetLastHostRelayedMode() ); m_relayed_host_pick->Show( m_relayed_host_check->IsChecked() ); topsizer->Add( m_relayed_host_check, 1, wxALL | wxEXPAND, 5 ); topsizer->Add( m_relayed_host_pick, 0, wxALL | wxEXPAND, 5); m_main_sizer->Add( topsizer, 0, wxEXPAND, 0 ); wxStaticBoxSizer* m_players_box; m_players_box = new wxStaticBoxSizer( new wxStaticBox( m_panel, -1, _( "Number of players" ) ), wxVERTICAL ); m_players_box->SetMinSize( wxSize( -1, 60 ) ); m_players_slide = new wxSlider( m_panel, wxID_ANY, sett().GetLastHostPlayerNum(), 2, SPRING_MAX_USERS, wxDefaultPosition, wxDefaultSize, wxSL_AUTOTICKS | wxSL_BOTH | wxSL_HORIZONTAL | wxSL_LABELS ); m_players_slide->SetToolTip( TE( _( "The maximum number of players to allow in the battle." ) ) ); m_players_box->Add( m_players_slide, 0, wxALL | wxEXPAND, 5 ); m_main_sizer->Add( m_players_box, 0, wxALL | wxEXPAND, 5 ); wxBoxSizer* m_pl_nat_sizer; m_pl_nat_sizer = new wxBoxSizer( wxHORIZONTAL ); wxString m_nat_radiosChoices[] = { _( "None" ), _( "Hole punching" )/*, _("Fixed source ports")*/ }; int m_nat_radiosNChoices = sizeof( m_nat_radiosChoices ) / sizeof( wxString ); m_nat_radios = new wxRadioBox( m_panel, CHOSE_NAT, _( "NAT traversal" ), wxDefaultPosition, wxDefaultSize, m_nat_radiosNChoices, m_nat_radiosChoices, 1, wxRA_SPECIFY_COLS ); m_nat_radios->SetSelection( sett().GetLastHostNATSetting() ); //m_nat_radios->Enable( false ); m_nat_radios->Enable( true ); m_nat_radios->SetToolTip( TE( _( "NAT traversal to use." ) ) ); m_pl_nat_sizer->Add( m_nat_radios, 1, wxALL | wxEXPAND, 5 ); wxStaticBoxSizer* m_rank_box; m_rank_box = new wxStaticBoxSizer( new wxStaticBox( m_panel, -1, _( "Rank requirement" ) ), wxVERTICAL ); wxArrayString rankFilterChoices; rankFilterChoices.Add(_("At least")); rankFilterChoices.Add(_("No greater than")); m_rank_direction = new wxChoice( m_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, rankFilterChoices, 0 ); m_rank_direction->SetToolTip( TE( _( "Select the type of rank enforcement." ) ) ); m_rank_box->Add(m_rank_direction); wxFlexGridSizer* m_rank_sizer; m_rank_sizer = new wxFlexGridSizer( 2, 6, 0, 0 ); m_rank_sizer->SetFlexibleDirection( wxBOTH ); m_rank0_radio = new wxRadioButton( m_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxRB_GROUP ); m_rank_sizer->Add( m_rank0_radio, 0, wxALL, 5 ); m_rank0_img = new wxStaticBitmap( m_panel, wxID_ANY, wxBitmap( rank0_xpm ), wxDefaultPosition, wxSize( 16, 16 ), 0 ); m_rank_sizer->Add( m_rank0_img, 0, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL, 5 ); m_rank1_radio = new wxRadioButton( m_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_rank_sizer->Add( m_rank1_radio, 0, wxALL, 5 ); m_rank1_img = new wxStaticBitmap( m_panel, wxID_ANY, wxBitmap( rank1_xpm ), wxDefaultPosition, wxSize( 16, 16 ), 0 ); m_rank_sizer->Add( m_rank1_img, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL | wxALL, 2 ); m_rank2_radio = new wxRadioButton( m_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_rank_sizer->Add( m_rank2_radio, 0, wxALL, 5 ); m_rank2_img = new wxStaticBitmap( m_panel, wxID_ANY, wxBitmap( rank2_xpm ), wxDefaultPosition, wxSize( 16, 16 ), 0 ); m_rank_sizer->Add( m_rank2_img, 0, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL, 2 ); m_rank3_radio = new wxRadioButton( m_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_rank_sizer->Add( m_rank3_radio, 0, wxALL, 5 ); m_rank3_img = new wxStaticBitmap( m_panel, wxID_ANY, wxBitmap( rank3_xpm ), wxDefaultPosition, wxSize( 16, 16 ), 0 ); m_rank_sizer->Add( m_rank3_img, 0, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL, 2 ); m_rank4_radio = new wxRadioButton( m_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_rank_sizer->Add( m_rank4_radio, 0, wxALL, 5 ); m_rank4_img = new wxStaticBitmap( m_panel, wxID_ANY, wxBitmap( rank4_xpm ), wxDefaultPosition, wxSize( 16, 16 ), 0 ); m_rank_sizer->Add( m_rank4_img, 0, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL, 2 ); m_rank5_radio = new wxRadioButton( m_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_rank_sizer->Add( m_rank5_radio, 0, wxALL, 5 ); m_rank5_img = new wxStaticBitmap( m_panel, wxID_ANY, wxBitmap( rank5_xpm ), wxDefaultPosition, wxSize( 16, 16 ), 0 ); m_rank_sizer->Add( m_rank5_img, 0, wxALL | wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL, 5 ); m_rank6_radio = new wxRadioButton( m_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_rank_sizer->Add( m_rank6_radio, 0, wxALL, 5 ); m_rank6_img = new wxStaticBitmap( m_panel, wxID_ANY, wxBitmap( rank6_xpm ), wxDefaultPosition, wxSize( 16, 16 ), 0 ); m_rank_sizer->Add( m_rank6_img, 0, wxALL, 5 ); m_rank7_radio = new wxRadioButton( m_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_rank_sizer->Add( m_rank7_radio, 0, wxALL, 5 ); m_rank7_img = new wxStaticBitmap( m_panel, wxID_ANY, wxBitmap( rank7_xpm ), wxDefaultPosition, wxSize( 16, 16 ), 0 ); m_rank_sizer->Add( m_rank7_img, 0, wxALL, 5 ); m_rank_box->Add( m_rank_sizer, 1, wxEXPAND, 5 ); m_pl_nat_sizer->Add( m_rank_box, 1, wxALL | wxEXPAND, 5 ); m_main_sizer->Add( m_pl_nat_sizer, 0, wxEXPAND, 5 ); m_main_sizer->Add( 0, 0, 1, wxEXPAND, 0 ); m_buttons_sep = new wxStaticLine( m_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); m_main_sizer->Add( m_buttons_sep, 0, wxALL | wxEXPAND, 2 ); wxBoxSizer* m_buttons_sizer; m_buttons_sizer = new wxBoxSizer( wxHORIZONTAL ); m_cancel_btn = new wxButton( m_panel, HOST_CANCEL, _( "Cancel" ), wxDefaultPosition, wxDefaultSize, 0 ); m_buttons_sizer->Add( 0, 0, 1, wxEXPAND, 0 ); m_buttons_sizer->Add( m_cancel_btn, 0, wxALL, 5 ); m_host_btn = new wxButton( m_panel, HOST_OK, _( "Host" ), wxDefaultPosition, wxDefaultSize, 0 ); m_host_btn->SetToolTip( TE( _( "Start hosting the battle." ) ) ); m_buttons_sizer->Add( m_host_btn, 0, wxALL, 5 ); m_main_sizer->Add( m_buttons_sizer, 0, wxEXPAND, 5 ); m_panel->SetSizer( m_main_sizer ); all_sizer->Add( m_panel, 1, wxEXPAND, 0 ); this->SetSizer( all_sizer ); m_panel->SetScrollRate( SCROLL_RATE, SCROLL_RATE ); this->Layout(); m_host_btn->SetFocus(); ReloadModList(); }
ChatOptionsTab::ChatOptionsTab( wxWindow* parent ) : wxScrolledWindow( parent, -1 ) { GetAui().manager->AddPane( this, wxLEFT, _T( "chatoptionstab" ) ); wxBoxSizer* bMainSizerV; bMainSizerV = new wxBoxSizer( wxVERTICAL ); wxStaticBoxSizer* sbColorsSizer; sbColorsSizer = new wxStaticBoxSizer( new wxStaticBox( this, -1, _( "Colors and font" ) ), wxHORIZONTAL ); wxBoxSizer* bColorsVSizer; bColorsVSizer = new wxBoxSizer( wxVERTICAL ); m_use_sys_colors = new wxCheckBox( this, ID_SYSCOLS, _( "Use system colors" ), wxDefaultPosition, wxDefaultSize, 0 ); m_use_sys_colors->Enable( false ); bColorsVSizer->Add( m_use_sys_colors, 0, wxALL, 5 ); m_custom_colors = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxTAB_TRAVERSAL ); m_custom_colors->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_MENU ) ); wxBoxSizer* bCustomColorsSizer; bCustomColorsSizer = new wxBoxSizer( wxHORIZONTAL ); wxBoxSizer* bColorSizer; bColorSizer = new wxBoxSizer( wxHORIZONTAL ); wxBoxSizer* bColorsSizer1; bColorsSizer1 = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* bNormlColorSizer; bNormlColorSizer = new wxBoxSizer( wxHORIZONTAL ); m_normal_color = new ColorButton( m_custom_colors, ID_NORMAL, wxBitmap(), wxDefaultPosition, wxSize( 20, 20 ), 0 ); m_normal_color->SetColor( wxColour( 0, 0, 0 ) ); bNormlColorSizer->Add( m_normal_color, 0, wxALL, 5 ); m_normal_label = new wxStaticText( m_custom_colors, wxID_ANY, _( "Normal" ), wxDefaultPosition, wxDefaultSize, 0 ); m_normal_label->Wrap( -1 ); bNormlColorSizer->Add( m_normal_label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); bColorsSizer1->Add( bNormlColorSizer, 0, wxEXPAND, 5 ); wxBoxSizer* bBGColorSizer; bBGColorSizer = new wxBoxSizer( wxHORIZONTAL ); m_bg_color = new ColorButton( m_custom_colors, ID_BG, wxBitmap(), wxDefaultPosition, wxSize( 20, 20 ), 0 ); m_bg_color->SetColor( wxColour( 255, 255, 255 ) ); bBGColorSizer->Add( m_bg_color, 0, wxALL, 5 ); m_bg_label = new wxStaticText( m_custom_colors, wxID_ANY, _( "Background" ), wxDefaultPosition, wxDefaultSize, 0 ); m_bg_label->Wrap( -1 ); bBGColorSizer->Add( m_bg_label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); bColorsSizer1->Add( bBGColorSizer, 0, wxEXPAND, 5 ); wxBoxSizer* bActionColorSizer; bActionColorSizer = new wxBoxSizer( wxHORIZONTAL ); m_action_color = new ColorButton( m_custom_colors, ID_ACTION, wxBitmap(), wxDefaultPosition, wxSize( 20, 20 ), 0 ); m_action_color->SetColor( wxColour( 255, 0, 249 ) ); bActionColorSizer->Add( m_action_color, 0, wxALL, 5 ); m_action_label = new wxStaticText( m_custom_colors, wxID_ANY, _( "Action" ), wxDefaultPosition, wxDefaultSize, 0 ); m_action_label->Wrap( -1 ); bActionColorSizer->Add( m_action_label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); bColorsSizer1->Add( bActionColorSizer, 0, wxEXPAND, 5 ); wxBoxSizer* bHighlightColorSizer; bHighlightColorSizer = new wxBoxSizer( wxHORIZONTAL ); m_highlight_color = new ColorButton( m_custom_colors, ID_HIGHLIGHT, wxBitmap(), wxDefaultPosition, wxSize( 20, 20 ), 0 ); m_highlight_color->SetColor( wxColour( 255, 0, 44 ) ); bHighlightColorSizer->Add( m_highlight_color, 0, wxALL, 5 ); m_highlight_label = new wxStaticText( m_custom_colors, wxID_ANY, _( "Highlight" ), wxDefaultPosition, wxDefaultSize, 0 ); m_highlight_label->Wrap( -1 ); bHighlightColorSizer->Add( m_highlight_label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); bColorsSizer1->Add( bHighlightColorSizer, 0, wxEXPAND, 5 ); wxBoxSizer* bJoinLeaveColorSizer; bJoinLeaveColorSizer = new wxBoxSizer( wxHORIZONTAL ); m_joinleave_color = new ColorButton( m_custom_colors, ID_JOINLEAVE, wxBitmap(), wxDefaultPosition, wxSize( 20, 20 ), 0 ); m_joinleave_color->SetColor( wxColour( 24, 255, 0 ) ); bJoinLeaveColorSizer->Add( m_joinleave_color, 0, wxALL, 5 ); m_joinleave_label = new wxStaticText( m_custom_colors, wxID_ANY, _( "Join/Leave" ), wxDefaultPosition, wxDefaultSize, 0 ); m_joinleave_label->Wrap( -1 ); bJoinLeaveColorSizer->Add( m_joinleave_label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); bColorsSizer1->Add( bJoinLeaveColorSizer, 0, wxEXPAND, 5 ); wxBoxSizer* bMyColorSizer; bMyColorSizer = new wxBoxSizer( wxHORIZONTAL ); m_my_color = new ColorButton( m_custom_colors, ID_MYMESS, wxBitmap(), wxDefaultPosition, wxSize( 20, 20 ), 0 ); m_my_color->SetColor( wxColour( 160, 160, 160 ) ); bMyColorSizer->Add( m_my_color, 0, wxALL, 5 ); m_my_label = new wxStaticText( m_custom_colors, wxID_ANY, _( "My messages" ), wxDefaultPosition, wxDefaultSize, 0 ); m_my_label->Wrap( -1 ); bMyColorSizer->Add( m_my_label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); bColorsSizer1->Add( bMyColorSizer, 1, wxEXPAND, 5 ); bColorSizer->Add( bColorsSizer1, 1, wxEXPAND, 5 ); wxBoxSizer* bColorSizer2; bColorSizer2 = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* bServerColorSizer; bServerColorSizer = new wxBoxSizer( wxHORIZONTAL ); m_server_color = new ColorButton( m_custom_colors, ID_SERVER, wxBitmap(), wxDefaultPosition, wxSize( 20, 20 ), 0 ); m_server_color->SetColor( wxColour( 255, 189, 0 ) ); bServerColorSizer->Add( m_server_color, 0, wxALL, 5 ); m_server_label = new wxStaticText( m_custom_colors, wxID_ANY, _( "Server" ), wxDefaultPosition, wxDefaultSize, 0 ); m_server_label->Wrap( -1 ); bServerColorSizer->Add( m_server_label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); bColorSizer2->Add( bServerColorSizer, 0, wxEXPAND, 5 ); wxBoxSizer* bClientolorSizer; bClientolorSizer = new wxBoxSizer( wxHORIZONTAL ); m_client_color = new ColorButton( m_custom_colors, ID_CLIENT, wxBitmap(), wxDefaultPosition, wxSize( 20, 20 ), 0 ); m_client_color->SetColor( wxColour( 255, 189, 0 ) ); bClientolorSizer->Add( m_client_color, 0, wxALL, 5 ); m_client_label = new wxStaticText( m_custom_colors, wxID_ANY, _( "Client" ), wxDefaultPosition, wxDefaultSize, 0 ); m_client_label->Wrap( -1 ); bClientolorSizer->Add( m_client_label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); bColorSizer2->Add( bClientolorSizer, 0, wxEXPAND, 5 ); wxBoxSizer* bErrorColorSizer; bErrorColorSizer = new wxBoxSizer( wxHORIZONTAL ); m_error_color = new ColorButton( m_custom_colors, ID_ERROR, wxBitmap(), wxDefaultPosition, wxSize( 20, 20 ), 0 ); m_error_color->SetColor( wxColour( 255, 0, 0 ) ); bErrorColorSizer->Add( m_error_color, 0, wxALL, 5 ); m_error_label = new wxStaticText( m_custom_colors, wxID_ANY, _( "Error" ), wxDefaultPosition, wxDefaultSize, 0 ); m_error_label->Wrap( -1 ); bErrorColorSizer->Add( m_error_label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); bColorSizer2->Add( bErrorColorSizer, 0, wxEXPAND, 5 ); wxBoxSizer* bTSColorSizer; bTSColorSizer = new wxBoxSizer( wxHORIZONTAL ); m_ts_color = new ColorButton( m_custom_colors, ID_TIMESTAMP, wxBitmap(), wxDefaultPosition, wxSize( 20, 20 ), 0 ); m_ts_color->SetColor( wxColour( 160, 160, 160 ) ); bTSColorSizer->Add( m_ts_color, 0, wxALL, 5 ); m_ts_label = new wxStaticText( m_custom_colors, wxID_ANY, _( "Timestamp" ), wxDefaultPosition, wxDefaultSize, 0 ); m_ts_label->Wrap( -1 ); bTSColorSizer->Add( m_ts_label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); bColorSizer2->Add( bTSColorSizer, 0, wxEXPAND, 5 ); wxBoxSizer* bNoteColorSizer; bNoteColorSizer = new wxBoxSizer( wxHORIZONTAL ); m_note_color = new ColorButton( m_custom_colors, ID_NOTIFICATION, wxBitmap(), wxDefaultPosition, wxSize( 20, 20 ), 0 ); m_note_color->SetColor( wxColour( 255, 191, 0 ) ); bNoteColorSizer->Add( m_note_color, 0, wxALL, 5 ); m_note_label = new wxStaticText( m_custom_colors, wxID_ANY, _( "Notification" ), wxDefaultPosition, wxDefaultSize, 0 ); m_note_label->Wrap( -1 ); bNoteColorSizer->Add( m_note_label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); bColorSizer2->Add( bNoteColorSizer, 0, wxEXPAND, 5 ); bColorSizer->Add( bColorSizer2, 1, wxEXPAND, 5 ); bCustomColorsSizer->Add( bColorSizer, 1, wxEXPAND, 5 ); m_test_text = new wxTextCtrl( m_custom_colors, wxID_ANY, _( "[19:35] ** Server ** Connected to Server.\n[22:30] <Dude> hi everyone\n[22:30] ** Dude2 joined the channel.\n[22:30] * Dude2 thinks his colors looks nice\n[22:45] <Dude> Dude2: orl?\n[22:46] <Dude2> But could be better, should tweak them some more...\n" ), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH ); bCustomColorsSizer->Add( m_test_text, 1, wxALL | wxEXPAND, 5 ); m_custom_colors->SetSizer( bCustomColorsSizer ); m_custom_colors->Layout(); bCustomColorsSizer->Fit( m_custom_colors ); bColorsVSizer->Add( m_custom_colors, 1, wxEXPAND | wxALL, 0 ); wxBoxSizer* bFontNameSizer; bFontNameSizer = new wxBoxSizer( wxHORIZONTAL ); m_font_label = new wxStaticText( this, wxID_ANY, _( "Font:" ), wxDefaultPosition, wxDefaultSize, 0 ); m_font_label->Wrap( -1 ); bFontNameSizer->Add( m_font_label, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 ); m_fontname = new wxStaticText( this, wxID_ANY, _( "default" ), wxDefaultPosition, wxDefaultSize, 0 ); m_fontname->Wrap( -1 ); bFontNameSizer->Add( m_fontname, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 ); m_select_font = new wxButton( this, ID_SELFONT, _( "Select..." ), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); bFontNameSizer->Add( m_select_font, 0, wxALL, 5 ); bColorsVSizer->Add( bFontNameSizer, 0, wxEXPAND, 5 ); sbColorsSizer->Add( bColorsVSizer, 1, wxEXPAND, 5 ); bMainSizerV->Add( sbColorsSizer, 0, wxEXPAND | wxBOTTOM | wxRIGHT | wxLEFT | wxTOP, 5 ); wxStaticBoxSizer* sbBehaviorSizer; sbBehaviorSizer = new wxStaticBoxSizer( new wxStaticBox( this, -1, _( "Behavior" ) ), wxHORIZONTAL ); m_irc_colors = new wxCheckBox( this, wxID_ANY, _( "Enable Irc colors in chat messages" ), wxDefaultPosition, wxDefaultSize, 0 ); m_irc_colors->SetValue( sett().GetUseIrcColors() ); sbBehaviorSizer->Add( m_irc_colors, 0, wxALL, 5 ); #ifndef DISABLE_SOUND m_play_sounds = new wxCheckBox( this, ID_PLAY_SOUNDS, _( "Play notification sounds" ), wxDefaultPosition, wxDefaultSize, 0 ); m_play_sounds->SetValue( sett().GetChatPMSoundNotificationEnabled() ); sbBehaviorSizer->Add( m_play_sounds, 0, wxALL, 5 ); #endif m_broadcast_check = new wxCheckBox( this, wxID_ANY, _( "Copy server messages in current channel" ), wxDefaultPosition, wxDefaultSize, 0 ); m_broadcast_check->SetValue( sett().GetBroadcastEverywhere() ); sbBehaviorSizer->Add( m_broadcast_check, 0, wxALL, 5 ); bMainSizerV->Add( sbBehaviorSizer, 0, wxEXPAND | wxBOTTOM | wxRIGHT | wxLEFT, 5 ); wxBoxSizer* bBotomSizer; bBotomSizer = new wxBoxSizer( wxHORIZONTAL ); wxStaticBoxSizer* sbChatLogSizer; wxStaticBox* sbChatLog = new wxStaticBox( this, -1, _( "Chat logs" ) ); sbChatLogSizer = new wxStaticBoxSizer( sbChatLog, wxVERTICAL ); m_save_logs = new wxCheckBox( this, wxID_ANY, _( "Save chat logs" ), wxDefaultPosition, wxDefaultSize, 0 ); m_save_logs->SetValue( sett().GetChatLogEnable() ); sbChatLogSizer->Add( m_save_logs, 0, wxALL, 5 ); wxBoxSizer* m_num_lines_sizer = new wxBoxSizer( wxHORIZONTAL ); m_num_lines = new wxSpinCtrl( this, wxID_ANY ); m_num_lines_lbl = new wxStaticText( this, wxID_ANY, _( "approx. number of lines loaded from log into chat" ), wxDefaultPosition, wxDefaultSize, 0 ); m_num_lines_sizer->Add( m_num_lines ); m_num_lines_sizer->Add( m_num_lines_lbl, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 5 ); sbChatLogSizer->Add( m_num_lines_sizer, 0, wxALL, 5 ); bBotomSizer->Add( sbChatLogSizer, 1, wxEXPAND | wxRIGHT, 5 ); wxStaticBoxSizer* sbHighlightSizer; sbHighlightSizer = new wxStaticBoxSizer( new wxStaticBox( this, -1, _( "Highlight words" ) ), wxVERTICAL ); m_hilight_words_label = new wxStaticText( this, wxID_ANY, _( "Words to highlight in chat:" ), wxDefaultPosition, wxDefaultSize, 0 ); m_hilight_words_label->Wrap( -1 ); sbHighlightSizer->Add( m_hilight_words_label, 0, wxALL, 5 ); sbHighlightSizer->Add( 0, 0, 1, wxEXPAND, 5 ); m_highlight_words = new wxTextCtrl( this, ID_HIWORDS, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_highlight_words->SetToolTip ( TE( _( "enter a ; seperated list" ) ) ); sbHighlightSizer->Add( m_highlight_words, 0, wxALL | wxEXPAND, 5 ); m_highlight_req = new wxCheckBox( this, ID_HL_REQ, _( "Additionally play sound/flash titlebar " ), wxDefaultPosition, wxDefaultSize, 0 ); sbHighlightSizer->Add( m_highlight_req , 0, wxALL | wxEXPAND, 5 ); bBotomSizer->Add( sbHighlightSizer, 1, wxEXPAND, 5 ); bMainSizerV->Add( bBotomSizer, 0, wxEXPAND | wxBOTTOM | wxRIGHT | wxLEFT, 5 ); bMainSizerV->Add( 0, 0, 1, wxEXPAND | wxALL, 5 ); SetScrollRate( SCROLL_RATE, SCROLL_RATE ); SetSizer( bMainSizerV ); Layout(); if ( sett().IsPortableMode() ) sbChatLog->Disable(); DoRestore(); UpdateTextSample(); }
BattleroomMMOptionsTab<BattleType>::BattleroomMMOptionsTab( BattleType* battle, wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxScrolledWindow( parent, id, pos, size, style | wxHSCROLL ),m_battle(battle) { GetAui().manager->AddPane( this, wxLEFT, _T("battleroommmoptionstab") ); m_main_sizer = new wxBoxSizer( wxVERTICAL ); wxStaticBoxSizer* m_preset_sizer; m_preset_sizer = new wxStaticBoxSizer( new wxStaticBox( this, -1, _("Manage Presets") ), wxHORIZONTAL ); m_options_preset_sel = new wxComboBox( this, BOPTS_CHOSEPRES, _T(""), wxDefaultPosition, wxDefaultSize, sett().GetPresetList(), wxCB_READONLY ); m_options_preset_sel->SetToolTip(TE(_("Set name."))); m_preset_sizer->Add( m_options_preset_sel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); m_load_btn = new wxButton( this, BOPTS_LOADPRES, _("Load..."), wxDefaultPosition, wxDefaultSize, 0 ); m_load_btn->SetToolTip( TE(_("Load a saved set of options.")) ); m_preset_sizer->Add( m_load_btn, 0, wxALL, 5 ); m_save_btn = new wxButton( this, BOPTS_SAVEPRES, _("Save..."), wxDefaultPosition, wxDefaultSize, 0 ); m_save_btn->SetToolTip( TE(_("Save a set of options.")) ); m_preset_sizer->Add( m_save_btn, 0, wxALL, 5 ); m_delete_btn = new wxButton( this, BOPTS_DELETEPRES, _("Delete..."), wxDefaultPosition, wxDefaultSize, 0 ); m_delete_btn->SetToolTip( TE(_("Delete a set of options.")) ); m_preset_sizer->Add( m_delete_btn, 0, wxALL, 5 ); m_default_btn = new wxButton( this, BOPTS_SETDEFAULTPRES, _("Set default..."), wxDefaultPosition, wxDefaultSize, 0 ); m_default_btn->SetToolTip( TE(_("Use the current set of options as game's default.")) ); m_preset_sizer->Add( m_default_btn, 0, wxALL, 5 ); m_preset_sizer->Add( 0, 0, 1, wxEXPAND, 0 ); m_map_mod_container = new wxBoxSizer( wxVERTICAL ); m_mod_options_sizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Game Options") ), wxVERTICAL ); m_mod_layout = new wxBoxSizer( wxVERTICAL); setupOptionsSizer(m_mod_layout,OptionsWrapper::ModOption); m_mod_options_sizer->Add( m_mod_layout, 1, wxEXPAND, 5 ); m_map_options_sizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Map Options") ), wxVERTICAL ); m_map_layout = new wxBoxSizer( wxVERTICAL); setupOptionsSizer(m_map_layout,OptionsWrapper::MapOption); m_map_options_sizer->Add( m_map_layout, 1, wxEXPAND, 5 ); m_main_sizer->Add( m_preset_sizer, 0, wxALL|wxEXPAND, 5 ); m_map_mod_container->Add( m_mod_options_sizer, 0, wxALL|wxEXPAND, 5 ); m_map_mod_container->Add( m_map_options_sizer, 0, wxALL|wxEXPAND, 5 ); m_main_sizer->Add( m_map_mod_container, 1, wxALL|wxEXPAND, 5 ); //m_main_sizer->FitInside(this); SetBattle( battle ); SetScrollRate( SCROLL_RATE, SCROLL_RATE ); SetSizer( m_main_sizer ); Layout(); }
int BattleroomMMOptionsTab<BattleType>::setupOptionsSectionSizer(const mmOptionSection& section, wxBoxSizer* parent_sizer, OptionsWrapper::GameOption optFlag) { if ( !m_battle ) return -1; const int col_gap = 35; wxString pref = wxFormat( _T("%d%s") ) % optFlag % wxsep; OptionsWrapper optWrap = m_battle->CustomBattleOptions(); bool enable = m_battle->IsFounderMe(); wxFlexGridSizer* cbxSizer = new wxFlexGridSizer( 4, 2, 10, 10 ); wxFlexGridSizer* spinSizer = new wxFlexGridSizer( 4, 10, 10 ); wxFlexGridSizer* textSizer = new wxFlexGridSizer( 4, 10, 10 ); wxFlexGridSizer* chkSizer = new wxFlexGridSizer( 4, 10, 10 ); const int b_gap = 1; int total_count = 0; int ctrl_count = 0; for (SpringUnitSync::OptionMapBoolIter i = optWrap.m_opts[optFlag].bool_map.begin(); i != optWrap.m_opts[optFlag].bool_map.end();++i) { if ( i->second.section == section.key ) { mmOptionBool current = i->second; wxCheckBox* temp = new wxCheckBox(this,BOOL_START_ID+ctrl_count,current.name); temp->SetToolTip(TE(current.description)); m_name_info_map[pref+current.key] = current.description; temp->SetName(pref+current.key); m_chkbox_map[pref+current.key] = temp; temp->SetValue(current.value); temp->Enable(enable); wxBoxSizer* ct_sizer = new wxBoxSizer( wxHORIZONTAL ); ct_sizer->Add(temp, 0, wxRIGHT| wxALIGN_CENTER_VERTICAL, b_gap); ct_sizer->Add(getButton(BOOL_START_ID+ctrl_count,pref+current.key), 0, wxRIGHT| wxALIGN_CENTER_VERTICAL, col_gap); chkSizer->Add( ct_sizer ); ctrl_count++; } } total_count += ctrl_count; ctrl_count = 0; for ( SpringUnitSync::OptionMapFloatIter it = optWrap.m_opts[optFlag].float_map.begin(); it != optWrap.m_opts[optFlag].float_map.end(); ++it) { wxString seckey = it->second.section; wxString kkey = section.key ; if ( it->second.section == section.key ) { mmOptionFloat current = it->second; SlSpinCtrlDouble<ThisType>* tempspin = new SlSpinCtrlDouble<ThisType>(); tempspin->Create(this, FLOAT_START_ID+ctrl_count, _T(""), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, double(current.min), double(current.max), double(current.value),double(current.stepping), current.key); tempspin->SetSnapToTicks( true ); tempspin->SetToolTip(TE(current.description)); m_name_info_map[pref+current.key] = current.description; tempspin->Enable(enable); tempspin->SetName(pref+current.key); m_spinctrl_map[pref+current.key] = tempspin; wxStaticText* tempst = new wxStaticText(this,-1,current.name); m_statictext_map[pref+current.key] = tempst; spinSizer->Add(tempst,0, wxALIGN_CENTER_VERTICAL); wxBoxSizer* ct_sizer = new wxBoxSizer( wxHORIZONTAL ); ct_sizer->Add(tempspin, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, b_gap); ct_sizer->Add(getButton(FLOAT_START_ID+ctrl_count,pref+current.key), 0, wxRIGHT , col_gap); spinSizer->Add( ct_sizer ); ctrl_count++; } } total_count += ctrl_count; ctrl_count = 0; for ( SpringUnitSync::OptionMapListIter it = optWrap.m_opts[optFlag].list_map.begin(); it != optWrap.m_opts[optFlag].list_map.end(); ++it) { if ( it->second.section == section.key ) { mmOptionList current = it->second; int temp = int(current.cbx_choices.GetCount()-1); int index = clamp(current.cur_choice_index,0,temp); wxComboBox* tempchoice = new wxComboBox(this, LIST_START_ID+ctrl_count, current.cbx_choices[index], wxDefaultPosition, wxDefaultSize, current.cbx_choices, wxCB_READONLY, wxDefaultValidator); wxString tooltip = current.description + _T("\n"); for ( ListItemVec::const_iterator itor = current.listitems.begin(); itor != current.listitems.end(); ++itor ) { tooltip+= _T("\n") + itor->name + _T(": ") + itor->desc; } tempchoice->SetToolTip(TE(tooltip)); m_name_info_map[pref+current.key] = tooltip; tempchoice->SetName(pref+current.key); tempchoice->Enable(enable); m_combox_map[pref+current.key] = tempchoice; wxStaticText* tempst = new wxStaticText(this,-1,current.name); m_statictext_map[pref+current.key] = tempst; cbxSizer->Add(tempst,0, wxALIGN_CENTER_VERTICAL); wxBoxSizer* ct_sizer = new wxBoxSizer( wxHORIZONTAL ); ct_sizer->Add(tempchoice, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, b_gap); ct_sizer->Add(getButton(LIST_START_ID+ctrl_count,pref+current.key), 0, wxRIGHT, col_gap); cbxSizer->Add( ct_sizer ); ctrl_count++; } } total_count += ctrl_count; ctrl_count = 0; for ( SpringUnitSync::OptionMapStringIter it = optWrap.m_opts[optFlag].string_map.begin(); it != optWrap.m_opts[optFlag].string_map.end(); ++it) { if ( it->second.section == section.key ) { mmOptionString current = it->second; wxTextCtrl* temptext = new wxTextCtrl(this, STRING_START_ID+ctrl_count, current.value, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, current.key); temptext->SetToolTip(TE(current.description)); m_name_info_map[pref+current.key] = current.description; temptext->SetName(pref+current.key); temptext->Enable(enable); m_textctrl_map[pref+current.key] = temptext; wxStaticText* tempst = new wxStaticText(this,-1,current.name); m_statictext_map[pref+current.key] = tempst; textSizer->Add(tempst,0, wxALIGN_CENTER_VERTICAL); wxBoxSizer* ct_sizer = new wxBoxSizer( wxHORIZONTAL ); ct_sizer->Add(temptext,0, wxALIGN_CENTER_VERTICAL | wxRIGHT, b_gap); ct_sizer->Add(getButton(STRING_START_ID+ctrl_count,pref+current.key),0, wxRIGHT, col_gap); textSizer->Add( ct_sizer ); ctrl_count++; } } total_count += ctrl_count; parent_sizer->Add( chkSizer, 0, wxALL, chkSizer->GetChildren().size() > 0 ? 5 : 0 ); parent_sizer->Add( spinSizer, 0, wxALL, spinSizer->GetChildren().size() > 0 ? 5 : 0 ); parent_sizer->Add( cbxSizer, 0, wxALL, cbxSizer->GetChildren().size() > 0 ? 5 : 0 ); parent_sizer->Add( textSizer, 0, wxALL, textSizer->GetChildren().size() > 0 ? 5 : 0 ); return total_count; }
void ChatPanel::CreateControls( ) { wxLogDebugFunc( _T( "" ) ); // Creating sizers m_main_sizer = new wxBoxSizer( wxHORIZONTAL ); m_chat_sizer = new wxBoxSizer( wxVERTICAL ); m_say_sizer = new wxBoxSizer( wxHORIZONTAL ); if ( m_show_nick_list ) { m_splitter = new wxSplitterWindow( this, -1, wxDefaultPosition, wxDefaultSize, wxSP_3D ); m_splitter->SetSashGravity( 0.9 ); m_nick_panel = new wxPanel( m_splitter, -1 ); m_chat_panel = new wxPanel( m_splitter, -1 ); m_nick_sizer = new wxBoxSizer( wxVERTICAL ); unsigned int numusers = 0; if ( m_type == CPT_Channel ) numusers = GetChannel()->GetNumUsers(); else if ( m_type == CPT_Server && m_server ) numusers = m_server->GetNumUsers(); m_usercount_label = new wxStaticText( m_nick_panel, wxID_ANY, wxString::Format( _("%d users"), numusers ) ); CreatePopup();//ensures m_popup_menu is constructed //SL_GENERIC::UserMenu<ChatPanelMenu>* usermenu = m_popup_menu->GetUserMenu(); assert ( m_popup_menu->GetUserMenu() ); m_nicklist = new NickListCtrl( m_nick_panel, true, m_popup_menu->GetUserMenu() ); // m_nick_filter = new wxComboBox( m_nick_panel, -1, _("Show all"), wxDefaultPosition, wxSize(80,CONTROL_HEIGHT), 0, 0, wxCB_READONLY ); // m_nick_filter->Disable(); m_nick_sizer->Add( m_usercount_label, 0 ); m_nick_sizer->Add( m_nicklist, 1, wxEXPAND ); // m_nick_sizer->Add( m_nick_filter, 0, wxEXPAND | wxTOP, 2 ); m_nick_panel->SetSizer( m_nick_sizer ); } else { m_chat_panel = this; m_nick_sizer = 0; m_nicklist = 0; m_nick_filter = 0; m_splitter = 0; } // Creating ui elements m_chatlog_text = new wxTextCtrl( m_chat_panel, CHAT_LOG, _T( "" ), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH | wxTE_AUTO_URL ); if ( m_type == CPT_Channel ) { m_chatlog_text->SetToolTip( TE(_("right click for options (like autojoin)" ) ) ); m_chan_opts_button = new wxBitmapButton(m_chat_panel, CHAT_CHAN_OPTS, icons().GetBitmap(icons().ICON_CHANNEL_OPTIONS), wxDefaultPosition , wxSize( CONTROL_HEIGHT, CONTROL_HEIGHT ) ); } else if ( m_type == CPT_User ) { if ( m_user ) { m_chan_opts_button = new wxBitmapButton(m_chat_panel, CHAT_CHAN_OPTS, icons().GetBitmap(icons().GetUserBattleStateIcon(m_user->GetStatus()) ), wxDefaultPosition , wxSize( CONTROL_HEIGHT, CONTROL_HEIGHT ) ); } } else { m_chan_opts_button = 0; } m_say_text = new wxTextCtrlHist( textcompletiondatabase, m_chat_panel, CHAT_TEXT, _T( "" ), wxDefaultPosition, wxSize( 100, CONTROL_HEIGHT ), wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB ); m_say_button = new wxButton( m_chat_panel, CHAT_SEND, _( "Send" ), wxDefaultPosition, wxSize( 80, CONTROL_HEIGHT ) ); // Adding elements to sizers if ( m_type == CPT_Channel ) m_say_sizer->Add( m_chan_opts_button ); if ( m_type == CPT_User ) m_say_sizer->Add( m_chan_opts_button ); m_say_sizer->Add( m_say_text, 1, wxEXPAND ); m_say_sizer->Add( m_say_button ); m_chat_sizer->Add( m_chatlog_text, 1, wxEXPAND ); m_chat_sizer->Add( m_say_sizer, 0, wxEXPAND | wxTOP, 2 ); if ( m_show_nick_list ) { m_chat_panel->SetSizer( m_chat_sizer ); m_splitter->SplitVertically( m_chat_panel, m_nick_panel, 100 ); m_splitter->SetMinimumPaneSize( 30 ); m_main_sizer->Add( m_splitter, 1, wxEXPAND | wxALL, 2 ); } else { m_main_sizer->Add( m_chat_sizer, 4, wxEXPAND | wxALL, 2 ); } // Assign sizer to panel SetSizer( m_main_sizer ); if ( m_show_nick_list ) { wxSize s = m_splitter->GetSize(); m_splitter->SetSashPosition( s.GetWidth() - 238, true ); } m_chatlog_text->SetBackgroundColour( sett().GetChatColorBackground() ); m_chatlog_text->SetFont( sett().GetChatFont() ); m_say_text->SetBackgroundColour( sett().GetChatColorBackground() ); m_say_text->SetFont( sett().GetChatFont() ); m_say_text->SetForegroundColour(sett().GetChatColorNormal()); // Fill up TextCompletionDatabase textcompletiondatabase.Insert_Mapping( _T("DLDK"), _T("Der Lockruf des Kaos") ); textcompletiondatabase.Insert_Mapping( _T("lol"), _T("Laughing out loud") ); textcompletiondatabase.Insert_Mapping( _T("wb"), _T("Welcome back") ); textcompletiondatabase.Insert_Mapping( _T("hf"), _T("Have Fun!") ); textcompletiondatabase.Insert_Mapping( _T("glhf"), _T("Good luck, have Fun!") ); textcompletiondatabase.Insert_Mapping( _T("kaot"), _T("Have Fun!") ); textcompletiondatabase.Insert_Mapping( _T("kaot_H"), _T("Der Kaot aus der HĂślle.") ); }
BattleOptionsTab::BattleOptionsTab( wxWindow* parent,IBattle* battle ) : wxScrolledWindow( parent, -1 ), m_battle( battle ) { GetAui().manager->AddPane( this, wxLEFT, _T( "battleoptionstab" ) ); wxBoxSizer* m_main_sizer; m_main_sizer = new wxBoxSizer( wxHORIZONTAL ); // wxBoxSizer* m_main_options_sizer; // m_main_options_sizer = new wxBoxSizer( wxVERTICAL ); wxStaticBoxSizer* m_restr_box; m_restr_box = new wxStaticBoxSizer( new wxStaticBox( this, -1, _( "Unit restrictions" ) ), wxVERTICAL ); wxBoxSizer* m_top_restr_sizer; m_top_restr_sizer = new wxBoxSizer( wxHORIZONTAL ); wxBoxSizer* m_allowed_sizer; m_allowed_sizer = new wxBoxSizer( wxVERTICAL ); m_aloowed_lbl = new wxStaticText( this, wxID_ANY, _( "Allowed units" ), wxDefaultPosition, wxDefaultSize, 0 ); m_allowed_sizer->Add( m_aloowed_lbl, 0, wxALL, 5 ); m_allowed_list = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_MULTIPLE | wxLB_NEEDED_SB| wxLB_SORT); m_allowed_list->SetToolTip( TE( _( "Units in this list will be available in the game." ) ) ); m_allowed_sizer->Add( m_allowed_list, 1, wxALL | wxEXPAND, 5 ); m_top_restr_sizer->Add( m_allowed_sizer, 1, wxEXPAND, 5 ); wxBoxSizer* m_mid_btn_sizer; m_mid_btn_sizer = new wxBoxSizer( wxVERTICAL ); m_mid_btn_sizer->Add( 0, 50, 0, wxEXPAND, 0 ); m_restrict_btn = new wxButton( this, BOPTS_RESTRICT, _T( ">" ), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); m_restrict_btn->SetToolTip( TE( _( "Disable selected units." ) ) ); m_mid_btn_sizer->Add( m_restrict_btn, 0, wxALL, 5 ); m_allow_btn = new wxButton( this, BOPTS_ALLOW, _T( "<" ), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); m_allow_btn->SetToolTip( TE( _( "Re-enable selected units." ) ) ); m_mid_btn_sizer->Add( m_allow_btn, 0, wxALL, 5 ); m_clear_btn = new wxButton( this, BOPTS_CLEARRES, _( "<<" ), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); m_clear_btn->SetToolTip( TE( _( "Enable all units." ) ) ); m_mid_btn_sizer->Add( m_clear_btn, 0, wxALL, 5 ); m_top_restr_sizer->Add( m_mid_btn_sizer, 0, wxEXPAND, 5 ); wxBoxSizer* m_restricted_sizer; m_restricted_sizer = new wxBoxSizer( wxVERTICAL ); m_restricted_lbl = new wxStaticText( this, wxID_ANY, _( "Restricted units" ), wxDefaultPosition, wxDefaultSize, 0 ); m_restricted_sizer->Add( m_restricted_lbl, 0, wxALL, 5 ); m_restrict_list = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_MULTIPLE | wxLB_NEEDED_SB | wxLB_SORT ); m_restrict_list->SetToolTip( TE( _( "Units in this list will not be available in the game." ) ) ); m_restricted_sizer->Add( m_restrict_list, 1, wxALL | wxEXPAND, 5 ); m_top_restr_sizer->Add( m_restricted_sizer, 1, wxEXPAND, 5 ); m_restr_box->Add( m_top_restr_sizer, 1, wxEXPAND, 5 ); m_main_sizer->Add( m_restr_box, 1, wxALL | wxEXPAND, 5 ); SetScrollRate( SCROLL_RATE, SCROLL_RATE ); this->SetSizer( m_main_sizer ); this->Layout(); }
int main(int argc, char *argv[]) { int indx = 6, indy = 7, npx = 48, npy = 12; float tend = 65.0f, dt = 0.1f; // parse in parameters if(argc == 7) { indx = atoi(argv[1]); indy = atoi(argv[2]); npx = atoi(argv[3]); npy = atoi(argv[4]); tend = atof(argv[5]); dt = atof(argv[6]); if(!(indx && indy && npx && npy && tend && dt)) { printf("One or more parameters are invalid.\n"); exit(1); } } else if(argc != 1) { printf("Usage: %s indx indy npx npy tend dt\n", argv[0]); exit(1); } else { printf("Using default parameters...\n"); } int ndim = 2; float qme = -1.0; float vtx = 1.0, vty = 1.0, vx0 = 0.0, vy0 = 0.0; float ax = .912871, ay = .912871; /* idimp = dimension of phase space = 4 */ /* sortime = number of time steps between standard electron sorting */ int idimp = 4, ipbc = 1, sortime = 50; float wke = 0.0, we = 0.0, wt = 0.0; /* declare scalars for standard code */ int j; int np, nx, ny, nxh, nyh, nxe, nye, nxeh, nxyh, nxhy; int ny1, ntime, nloop, isign; float qbme, affp; /* declare arrays for standard code */ float *part = NULL, *part2 = NULL, *tpart = NULL; float *qe = NULL; float *fxye = NULL; float complex *ffc = NULL; int *mixup = NULL; float complex *sct = NULL; int *npicy = NULL; /* declare and initialize timing data */ float time; struct timeval itime; float tdpost = 0.0, tguard = 0.0, tfft = 0.0, tfield = 0.0; float tpush = 0.0, tsort = 0.0; double dtime; /* initialize scalars for standard code */ np = npx*npy; nx = 1L<<indx; ny = 1L<<indy; nxh = nx/2; nyh = ny/2; nxe = nx + 2; nye = ny + 1; nxeh = nxe/2; nxyh = (nx > ny ? nx : ny)/2; nxhy = nxh > ny ? nxh : ny; ny1 = ny + 1; nloop = tend/dt + .0001; ntime = 0; qbme = qme; affp = (float) (nx*ny)/(float ) np; /* allocate and initialize data for standard code */ part = (float *) malloc(idimp*np*sizeof(float)); part2 = (float *) malloc(idimp*np*sizeof(float)); qe = (float *) malloc(nxe*nye*sizeof(float)); fxye = (float *) malloc(ndim*nxe*nye*sizeof(float)); ffc = (float complex *) malloc(nxh*nyh*sizeof(float complex)); mixup = (int *) malloc(nxhy*sizeof(int)); sct = (float complex *) malloc(nxyh*sizeof(float complex)); npicy = (int *) malloc(ny1*sizeof(int)); /* prepare fft tables */ cwfft2rinit(mixup,sct,indx,indy,nxhy,nxyh); /* calculate form factors */ isign = 0; cpois22((float complex *)qe,(float complex *)fxye,isign,ffc,ax,ay,affp, &we,nx,ny,nxeh,nye,nxh,nyh); /* initialize electrons */ cdistr2(part,vtx,vty,vx0,vy0,npx,npy,idimp,np,nx,ny,ipbc); /* --------------------------------------------------------------------------*/ /* ---------------------------- set up ------------------------------------- */ /* --------------------------------------------------------------------------*/ int sz_qe = nxe * nye * sizeof(float); int sz_part = idimp * np * sizeof(float); int sz_fxye = ndim*nxe*nye*sizeof(float); float* g_part = (float*)copyToGPU(part, sz_part); float* g_qe = (float*)copyToGPU(qe, sz_qe); float* g_fxye = (float*)copyToGPU(fxye, sz_fxye); float* g_wke = (float*)copyToGPU(&wke, sizeof(float)); int* mutexes = createMutexes(nxe * nye); /* --------------------------------------------------------------------------*/ if(VALIDATE) { float* t = (float*)copyFromGPU(g_part, sz_part); float* t2 = (float*)copyFromGPU(g_qe, sz_qe); if(floatArrayCompare(t, part, sz_part / sizeof(float), "copy", "orig", 0) != 0 || floatArrayCompare(t2, qe, sz_qe / sizeof(float), "copy", "orig", 0) !=0) { printf("Copying to and from GPU failed validation.\n"); exit(1); } free(t); } /* * * * start main iteration loop * * * */ L500: if (nloop <= ntime) goto L2000; /* printf("ntime = %i\n",ntime); */ /* deposit charge with standard procedure: updates qe */ TS; cgpost2l_cuda(g_part, g_qe, qme, np, idimp, nxe, nye, npx, npy, mutexes); TE(tdpost); for (j = 0; j < nxe*nye; j++) qe[j] = 0.0; cgpost2l(part,qe,qme,np,idimp,nxe,nye); if(VALIDATE) { float* t = (float*)copyFromGPU(g_qe, sz_qe); if(floatArrayCompare(t, qe, sz_qe / sizeof(float), "gpu", "cpu", 1e-4) != 0) { printf("cgpost2l failed validation, ntime=%d\n", ntime); exit(1); } free(t); } /* add guard cells with standard procedure: updates qe */ TS; caguard2l_cuda(g_qe,nx,ny,nxe,nye); TE(tguard); caguard2l(qe,nx,ny,nxe,nye); if(VALIDATE) { float* t = (float*)copyFromGPU(g_qe, sz_qe); if(floatArrayCompare(t, qe, sz_qe / sizeof(float), "gpu", "cpu", 1e-4) != 0) { printf("caguard2l failed validation, ntime=%d\n", ntime); exit(1); } free(t); } /* transform charge to fourier space with standard procedure: updates qe */ TS; copyFromGPU2(qe, g_qe, sz_qe); isign = -1; cwfft2rx((float complex *)qe,isign,mixup,sct,indx,indy,nxeh,nye, nxhy,nxyh); copyToGPU2(g_qe, qe, sz_qe); TE(tfft); /* calculate force/charge in fourier space with standard procedure: */ /* updates fxye */ TS; isign = -1; cpois22((float complex *)qe,(float complex *)fxye,isign,ffc,ax,ay, affp,&we,nx,ny,nxeh,nye,nxh,nyh); TE(tfield); /* transform force to real space with standard procedure: updates fxye */ TS; isign = 1; cwfft2r2((float complex *)fxye,isign,mixup,sct,indx,indy,nxeh,nye, nxhy,nxyh); TE(tfft); /* copy guard cells with standard procedure: updates fxye */ TS; ccguard2l(fxye,nx,ny,nxe,nye); TE(tguard); /* push particles with standard precision: updates part, wke */ TS; copyToGPU2(g_fxye, fxye, sz_fxye); cgpush2l_cuda(g_part,g_fxye,qbme,dt,g_wke,idimp,np,nx,ny,nxe,nye,ipbc,npx,npy,mutexes); TE(tpush); wke = 0.0; cgpush2l(part,fxye,qbme,dt,&wke,idimp,np,nx,ny,nxe,nye,ipbc); if(VALIDATE) { float* t = (float*)copyFromGPU(g_part, sz_part); if(floatArrayCompare(t, part, sz_part / sizeof(float), "gpu", "cpu", 1e-4) != 0) { printf("cgpush2l failed sdfsdf validation, ntime=%d\n", ntime); exit(1); } free(t); } /* sort particles by cell for standard code */ if (sortime > 0) { if (ntime%sortime==0) { TS; cdsortp2yl(part,part2,npicy,idimp,np,ny1); /* exchange pointers */ tpart = part; part = part2; part2 = tpart; copyToGPU2(g_part, part, sz_part); TE(tsort); } } if (ntime==0) { printf("Initial Field, Kinetic and Total Energies:\n"); printf("%e %e %e\n",we,wke,wke+we); } ntime += 1; goto L500; L2000: /* * * * end main iteration loop * * * */ printf("ntime = %i\n",ntime); printf("Final Field, Kinetic and Total Energies:\n"); printf("%e %e %e\n",we,wke,wke+we); printf("\n"); printf("deposit time = %f\n",tdpost); printf("guard time = %f\n",tguard); printf("solver time = %f\n",tfield); printf("fft time = %f\n",tfft); printf("push time = %f\n",tpush); printf("sort time = %f\n",tsort); tfield += tguard + tfft; printf("total solver time = %f\n",tfield); time = tdpost + tpush + tsort; printf("total particle time = %f\n",time); wt = time + tfield; printf("total time = %f\n",wt); printf("\n"); wt = 1.0e+09/(((float) nloop)*((float) np)); printf("Push Time (nsec) = %f\n",tpush*wt); printf("Deposit Time (nsec) = %f\n",tdpost*wt); printf("Sort Time (nsec) = %f\n",tsort*wt); printf("Total Particle Time (nsec) = %f\n",time*wt); freeOnGPU(g_part); freeOnGPU(g_qe); freeOnGPU(g_fxye); return 0; }