Beispiel #1
0
void menu_main::populate()
{
	/* add input menu items */
	item_append(_("Input (general)"), "", 0, (void *)INPUT_GROUPS);

	item_append(_("Input (this Machine)"), "", 0, (void *)INPUT_SPECIFIC);

	/* add optional input-related menus */
	if (ui().machine_info().has_analog())
		item_append(_("Analog Controls"), "", 0, (void *)ANALOG);
	if (ui().machine_info().has_dips())
		item_append(_("Dip Switches"), "", 0, (void *)SETTINGS_DIP_SWITCHES);
	if (ui().machine_info().has_configs())
	{
		item_append(_("Machine Configuration"), "", 0, (void *)SETTINGS_DRIVER_CONFIG);
	}

	/* add bookkeeping menu */
	item_append(_("Bookkeeping Info"), "", 0, (void *)BOOKKEEPING);

	/* add game info menu */
	item_append(_("Machine Information"), "", 0, (void *)GAME_INFO);

	for (device_image_interface &image : image_interface_iterator(machine().root_device()))
	{
		if (image.user_loadable())
		{
			/* add image info menu */
			item_append(_("Image Information"), "", 0, (void *)IMAGE_MENU_IMAGE_INFO);

			/* add file manager menu */
			item_append(_("File Manager"), "", 0, (void *)IMAGE_MENU_FILE_MANAGER);

			break;
		}
	}

	/* add tape control menu */
	if (cassette_device_iterator(machine().root_device()).first() != nullptr)
		item_append(_("Tape Control"), "", 0, (void *)TAPE_CONTROL);

	if (pty_interface_iterator(machine().root_device()).first() != nullptr)
		item_append(_("Pseudo terminals"), "", 0, (void *)PTY_INFO);

	if (ui().machine_info().has_bioses())
		item_append(_("Bios Selection"), "", 0, (void *)BIOS_SELECTION);

	/* add slot info menu */
	if (slot_interface_iterator(machine().root_device()).first() != nullptr)
		item_append(_("Slot Devices"), "", 0, (void *)SLOT_DEVICES);

	/* add Barcode reader menu */
	if (barcode_reader_device_iterator(machine().root_device()).first() != nullptr)
		item_append(_("Barcode Reader"), "", 0, (void *)BARCODE_READ);

	/* add network info menu */
	if (network_interface_iterator(machine().root_device()).first() != nullptr)
		item_append(_("Network Devices"), "", 0, (void*)NETWORK_DEVICES);

	/* add keyboard mode menu */
	if (ui().machine_info().has_keyboard() && machine().ioport().natkeyboard().can_post())
		item_append(_("Keyboard Mode"), "", 0, (void *)KEYBOARD_MODE);

	/* add sliders menu */
	item_append(_("Slider Controls"), "", 0, (void *)SLIDERS);

	/* add video options menu */
	item_append(_("Video Options"), "", 0, (machine().render().target_by_index(1) != nullptr) ? (void *)VIDEO_TARGETS : (void *)VIDEO_OPTIONS);

	/* add crosshair options menu */
	if (machine().crosshair().get_usage())
		item_append(_("Crosshair Options"), "", 0, (void *)CROSSHAIR);

	/* add cheat menu */
	if (machine().options().cheat())
		item_append(_("Cheat"), "", 0, (void *)CHEAT);

	if (machine().options().plugins())
		item_append(_("Plugin Options"), "", 0, (void *)PLUGINS);

	// add dats menu
	if (mame_machine_manager::instance()->lua()->call_plugin("", "data_list"))
		item_append(_("External DAT View"), "", 0, (void *)EXTERNAL_DATS);

	item_append(menu_item_type::SEPARATOR);

	/* add favorite menu */
	if (!mame_machine_manager::instance()->favorite().isgame_favorite())
		item_append(_("Add To Favorites"), "", 0, (void *)ADD_FAVORITE);
	else
		item_append(_("Remove From Favorites"), "", 0, (void *)REMOVE_FAVORITE);

	item_append(menu_item_type::SEPARATOR);

//  item_append(_("Quit from Machine"), nullptr, 0, (void *)QUIT_GAME);

	/* add reset and exit menus */
	item_append(_("Select New Machine"), "", 0, (void *)SELECT_GAME);
}
LobbyOptionsTab::LobbyOptionsTab(wxWindow* parent)
    : wxScrolledWindow(parent, -1)
    , m_show_tooltips_label(0)
{
	GetAui().manager->AddPane(this, wxLEFT, _T("lobbyoptionstab"));

	wxBoxSizer* 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(_("Use your system-wide browser preference"));

	m_web_spec_radio = new wxRadioButton(this, SPRING_DEFWEB, _("Specify:"));
	m_web_spec_radio->SetToolTip(_("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(_("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, TowxString(SlPaths::GetEditorPath()));

	m_editor_browse_btn = new wxButton(this, ID_BUT_EDITOR, _("Browse"));
	m_editor_browse_btn->SetToolTip(_("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, wxString::Format(_("If checked, %s will automatically log on to the last used server"), GetSpringlobbyName()));
	m_autojoin = new wxCheckBox(this, -1, _("Autoconnect on lobby start"), wxDefaultPosition, wxDefaultSize, 0);
	m_autojoin->SetValue(cfg().ReadBool(_T( "/Server/Autoconnect")));
	m_autojoin_sizer->Add(m_autoconnect_label, 1, wxEXPAND | wxALL, 5);
	m_autojoin_sizer->Add(m_autojoin, 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);
	wxStaticBoxSizer* m_updater_sizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Automatic updates"));
	m_updater_label = new wxStaticText(this, -1, wxString::Format(_("%s can check at startup if a newer version is available and automatically download it for you."), GetSpringlobbyName()));
	m_updater = new wxCheckBox(this, -1, _("automatically check for updates"), wxDefaultPosition, wxDefaultSize, 0);
	m_updater->SetValue(cfg().ReadBool(_T("/General/AutoUpdate")));
	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_autojoin_sizer, 0, wxEXPAND | wxALL, 5);
	m_main_sizer->Add(m_updater_sizer, 0, wxEXPAND | wxALL, 5);

	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, wxString::Format(_("Requires %s restart to take effect."), GetSpringlobbyName()));
	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);

	wxStaticBoxSizer* m_show_promotions_sizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Battle Promotion"));
	m_show_promotions = new wxCheckBox(this, -1, _("Show notifications when someone promotes battle?"), wxDefaultPosition, wxDefaultSize, 0);
	m_show_promotions->SetValue(cfg().ReadBool("/GUI/ShowPromotions"));
	m_show_promotions_sizer->Add(m_show_promotions, 0, wxEXPAND | 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_show_tooltips_sizer, 0, wxEXPAND | wxALL, 5);
	m_main_sizer->Add(m_show_promotions_sizer, 0, wxEXPAND | wxALL, 5);
	m_main_sizer->Add(m_complete_method_sizer, 0, wxEXPAND | 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(cfg().ReadBool(_T( "/GUI/UseTabIcons" )));
	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_test_notification = new wxButton(this, TEST_NOTIFICATION, _("Test Notification"));
	m_misc_gui_sizer->Add(m_x_on_all_tabs, 1, wxEXPAND | wxALL, 5);
	m_misc_gui_sizer->Add(m_test_notification, 1, wxEXPAND | wxALL, 5);

	wxStaticBoxSizer* m_start_tab_sizer = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Start tab"));
	m_start_tab = new wxChoice(this, -1, wxDefaultPosition, wxDefaultSize, ui().mw().GetTabNames());
	m_start_tab->SetSelection(cfg().ReadLong(_T( "/GUI/StartTab" )));
	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, wxEXPAND | wxALL, 5);
	m_start_tab_sizer->Add(m_start_tab, 0, wxEXPAND | wxALIGN_TOP, 5);

	m_main_sizer->Add(m_misc_gui_sizer, 0, wxEXPAND | wxALL, 5);
	m_main_sizer->Add(m_start_tab_sizer, 0, wxEXPAND | wxALL, 5);

	//dummy event that updates controls to correct state
	wxCommandEvent evt;
	OnRestore(evt);

	SetScrollRate(SCROLL_RATE, SCROLL_RATE);
	SetSizer(m_main_sizer);
	Layout();
}
Beispiel #3
0
int main(int argc, char** argv) {
  glfwSetErrorCallback(glfwError);

  if (!glfwInit()) return 1;

  glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
  glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
  glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

  GLFWmonitor* monitor = glfwGetPrimaryMonitor();
  const GLFWvidmode* mode = glfwGetVideoMode(monitor);

  GLFWwindow* window =
      glfwCreateWindow(mode->width, mode->height, "HumanDetection", NULL, NULL);
  glfwMakeContextCurrent(window);
  glewExperimental = GL_TRUE;
  glewInit();

  fhd_context detector;
  fhd_context_init(&detector, 512, 424, 8, 8);

  ImGui_ImplGlfwGL3_Init(window, true);
  ImGui::GetStyle().WindowRounding = 0.f;
  bool show_window = true;

  fhd_ui ui(&detector);

  if (argc > 1) {
    const char* train_database = argv[1];
    ui.train_mode = true;
    fhd_candidate_db_init(&ui.candidate_db, train_database);
  }

  ImVec4 clear_color = ImColor(218, 223, 225);
  while (!glfwWindowShouldClose(window)) {
    glfwPollEvents();

    if (ImGui::IsKeyPressed(GLFW_KEY_ESCAPE)) break;

    if (ui.train_mode) {
      if (ImGui::IsKeyPressed(GLFW_KEY_X)) {
        fhd_ui_clear_candidate_selection(&ui);
        ui.depth_frame = ui.frame_source->get_frame();
      }

      if (ImGui::IsKeyPressed(GLFW_KEY_SPACE)) {
        fhd_ui_commit_candidates(&ui);
      }
    } else {
      if (ui.update_enabled) {
        ui.depth_frame = ui.frame_source->get_frame();
      }
    }

    if (ui.depth_frame) {
      auto t1 = std::chrono::high_resolution_clock::now();
      fhd_run_pass(&detector, ui.depth_frame);
      auto t2 = std::chrono::high_resolution_clock::now();
      auto duration =
          std::chrono::duration_cast<std::chrono::microseconds>(t2 - t1);
      ui.detection_pass_time_ms = double(duration.count()) / 1000.0;
      fhd_ui_update(&ui, ui.depth_frame);
    }

    ImGui_ImplGlfwGL3_NewFrame();
    int display_w, display_h;
    glfwGetFramebufferSize(window, &display_w, &display_h);

    ImGui::SetNextWindowPos(ImVec2(0, 0));

    ImGuiWindowFlags flags = ImGuiWindowFlags_NoMove |
                             ImGuiWindowFlags_NoResize |
                             ImGuiWindowFlags_NoTitleBar;

    ImGui::Begin("foo", &show_window,
                 ImVec2(float(display_w), float(display_h)), -1.f, flags);

    ImGui::BeginChild("toolbar", ImVec2(300.f, float(display_h)));
    render_db_selection(&ui);
    render_classifier_selection(&ui);

    if (ui.train_mode) {
      ImGui::Text("*** TRAINING DB: %s ***", argv[1]);
    }

    ImGui::Text("detection pass time %.3f ms", ui.detection_pass_time_ms);
    ImGui::Text("frame source: %s", ui.database_name.c_str());
    ImGui::Text("frame %d/%d", ui.frame_source->current_frame(),
                ui.frame_source->total_frames());
    ImGui::Text("classifier: %s", ui.classifier_name.c_str());
    ImGui::Checkbox("update enabled", &ui.update_enabled);
    ImGui::SliderFloat("##det_thresh", &ui.detection_threshold, 0.f, 1.f,
                       "detection threshold %.3f");
    ImGui::InputFloat("seg k depth", &ui.fhd->depth_segmentation_threshold);
    ImGui::InputFloat("seg k normals", &ui.fhd->normal_segmentation_threshold);
    ImGui::SliderFloat("##min_reg_dim", &ui.fhd->min_region_size, 8.f, 100.f,
                       "min region dimension %.1f");
    ImGui::SliderFloat("##merge_dist_x", &ui.fhd->max_merge_distance, 0.1f, 2.f,
                       "max h merge dist (m) %.2f");
    ImGui::SliderFloat("##merge_dist_y", &ui.fhd->max_vertical_merge_distance,
                       0.1f, 3.f, "max v merge dist (m) %.2f");
    ImGui::SliderFloat("##min_inlier", &ui.fhd->min_inlier_fraction, 0.5f, 1.f,
                       "RANSAC min inlier ratio %.2f");
    ImGui::SliderFloat("##max_plane_dist", &ui.fhd->ransac_max_plane_distance,
                       0.01f, 1.f, "RANSAC max plane dist %.2f");
    ImGui::SliderFloat("##reg_height_min", &ui.fhd->min_region_height, 0.1f,
                       3.f, "min region height (m) %.2f");
    ImGui::SliderFloat("##reg_height_max", &ui.fhd->max_region_height, 0.1f,
                       3.f, "max region height (m) %.2f");
    ImGui::SliderFloat("##reg_width_min", &ui.fhd->min_region_width, 0.1f, 1.f,
                       "min region width (m) %.2f");
    ImGui::SliderFloat("##reg_width_max", &ui.fhd->max_region_height, 0.1f,
                       1.5f, "max region width (m) %.2f");
    ImGui::SliderInt("##min_depth_seg_size", &ui.fhd->min_depth_segment_size, 4,
                     200, "min depth seg size");
    ImGui::SliderInt("##min_normal_seg_size", &ui.fhd->min_normal_segment_size,
                     4, 200, "min normal seg size");
    ImGui::EndChild();

    ImGui::SameLine();

    ImGui::BeginGroup();

    ImDrawList* draw_list = ImGui::GetWindowDrawList();

    ImVec2 p = ImGui::GetCursorScreenPos();
    ImGui::Image((void*)intptr_t(ui.depth_texture.handle), ImVec2(512, 424));


    ImU32 rect_color = ImColor(240, 240, 20);
    for (int i = 0; i < detector.candidates_len; i++) {
      const fhd_candidate* candidate = &detector.candidates[i];
      if (candidate->weight >= 1.f) {
        const fhd_image_region region = candidate->depth_position;

        const float x = p.x + float(region.x);
        const float y = p.y + float(region.y);
        const float w = float(region.width);
        const float h = float(region.height);
        ImVec2 points[4] = {
          ImVec2(x, y),
          ImVec2(x + w, y),
          ImVec2(x + w, y + h),
          ImVec2(x, y + h)
        };
        draw_list->AddPolyline(points, 4, rect_color, true, 4.f, true);
      }
    }

    ImGui::BeginGroup();
    ImGui::Image((void*)intptr_t(ui.normals_texture.handle), ImVec2(256, 212));
    ImGui::SameLine();
    ImGui::Image((void*)intptr_t(ui.normals_seg_texture.handle),
                 ImVec2(256, 212));
    ImGui::EndGroup();

    ImGui::BeginGroup();
    ImGui::Image((void*)intptr_t(ui.downscaled_depth.handle), ImVec2(256, 212));
    ImGui::SameLine();
    ImGui::Image((void*)intptr_t(ui.depth_segmentation.handle),
                 ImVec2(256, 212));
    ImGui::EndGroup();

    ImGui::Image((void*)intptr_t(ui.filtered_regions.handle), ImVec2(256, 212));

    ImGui::EndGroup();

    ImGui::SameLine();

    ImGui::BeginGroup();

    if (ui.train_mode) {
      fhd_candidate_selection_grid(&ui, FHD_HOG_WIDTH * 2, FHD_HOG_HEIGHT * 2);
    } else {
      for (int i = 0; i < detector.candidates_len; i++) {
        fhd_texture* t = &ui.textures[i];
        ImGui::Image((void*)intptr_t(t->handle),
                     ImVec2(t->width * 2, t->height * 2));
        if (i % 7 < 6) ImGui::SameLine();
      }
    }

    ImGui::EndGroup();
    ImGui::End();

    glViewport(0, 0, display_w, display_h);
    glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
    glClear(GL_COLOR_BUFFER_BIT);

    ImGui::Render();
    glfwSwapBuffers(window);
  }

  if (ui.train_mode) {
    fhd_candidate_db_close(&ui.candidate_db);
  }

  fhd_texture_destroy(&ui.depth_texture);
  fhd_classifier_destroy(detector.classifier);
  ImGui_ImplGlfwGL3_Shutdown();
  glfwTerminate();

  return 0;
}
Beispiel #4
0
void PlaybackTab<PlaybackTraits>::OnWatch( wxCommandEvent& /*unused*/ )
{
	if ( m_replay_listctrl->GetSelectedIndex() != -1 ) {
		int m_sel_replay_id = m_replay_listctrl->GetSelectedData()->id;

		wxString type = PlaybackTraits::IsReplayType ? _( "replay" ) : _( "savegame" ) ;
		wxLogMessage( _T( "Watching %s %d " ), type.c_str(), m_sel_replay_id );
		try {
			PlaybackType& rep = playbacklist<ListType>().GetPlaybackById( m_sel_replay_id );

			std::map<wxString, wxString> versionlist = sett().GetSpringVersionList();
			if ( versionlist.size() == 0 ) {
				wxLogWarning( _T( "can't get spring version from any unitsync" ) );
				customMessageBox( SL_MAIN_ICON,  _( "Couldn't get your spring versions from any unitsync library." ), _( "Spring error" ), wxICON_EXCLAMATION | wxOK );
				AskForceWatch( rep );
				return;
			}
			bool versionfound = false;
			for ( std::map<wxString, wxString>::const_iterator itor = versionlist.begin(); itor != versionlist.end(); itor++ ) {
				if ( itor->second == rep.SpringVersion ) {
					if ( sett().GetCurrentUsedSpringIndex() != itor->first ) {
						wxLogMessage( _T( "%s requires version: %s, switching to profile: %s" ), type.c_str(), rep.SpringVersion.c_str(), itor->first.c_str() );
						sett().SetUsedSpringIndex( itor->first );
						usync().AddReloadEvent(); // request an unitsync reload
					}
					versionfound = true;
				}
			}
			if ( !ReplayTraits::IsReplayType )
                versionfound = true; // quick hack to bypass spring version check
			if ( !versionfound ) {
				wxString message = wxString::Format( _( "No compatible installed spring version has been found, this %s requires version: %s\n" ), type.c_str(), rep.SpringVersion.c_str() );
				message << _( "Your current installed versions are:" );
				for ( std::map<wxString, wxString>::const_iterator itor = versionlist.begin(); itor != versionlist.end(); itor++ ) message << _T( " " ) << itor->second;
				customMessageBox( SL_MAIN_ICON, message, _( "Spring error" ), wxICON_EXCLAMATION | wxOK );
				wxLogWarning ( _T( "no spring version supported by this replay found" ) );
				AskForceWatch( rep );
				return;
			}
			rep.battle.GetMe().SetNick( usync().GetDefaultNick() );
			bool watchable = rep.battle.MapExists() && rep.battle.ModExists();
			if ( watchable )
				rep.battle.StartSpring();
			else {
#ifdef NO_TORRENT_SYSTEM
				wxString downloadProc = _( "Do you want me to take you to the download page?" );
#else
				wxString downloadProc = _( "Should i try to download it for you?\nYou can see the progress in the \"Download Manager\" tab." );
#endif

				OfflineBattle& battle = rep.battle;

				if ( !battle.ModExists() ) {
					if ( customMessageBox( SL_MAIN_ICON, _( "You need to download the game before you can watch this replay.\n\n" ) + downloadProc, _( "Game not available" ), wxYES_NO | wxICON_QUESTION ) == wxYES ) {
						wxString modhash = battle.GetHostModHash();
						wxString modname = battle.GetHostModName();
						ui().DownloadMod ( modhash, modname );
					}
					else {
						AskForceWatch( rep );
					}
					return;
				}

				if ( !battle.MapExists() ) {
					if ( customMessageBox( SL_MAIN_ICON, _( " I couldn't find the map to be able to watch this replay\nThis can be caused by tasclient writing broken map hash value\nIf you're sure you have the map, press no\nYou need to download the map to be able to watch this replay.\n\n" ) + downloadProc, _( "Map not available" ), wxYES_NO | wxICON_QUESTION ) == wxYES ) {
						wxString maphash = battle.GetHostMapHash();
						wxString mapname = battle.GetHostMapName();
						ui().DownloadMap ( maphash, mapname );
					}
					else {
						AskForceWatch( rep );
					}
				}
			}
		} catch ( std::runtime_error ) {
			return;
		}
	} else {
		Deselected();
	}
}
Beispiel #5
0
BuildingScreen::BuildingScreen(sp<Building> building)
    : Stage(), menuform(ui().GetForm("FORM_BUILDING_SCREEN")), building(building)
{
	auto nameLabel = menuform->FindControlTyped<Label>("LABEL_BUILDING_NAME");
	nameLabel->SetText(tr(building->name));
}
void ServerEvents::OnChannelMessage(const std::string& channel, const std::string& msg)
{
	ui().OnChannelMessage(m_serv.GetChannel(channel), msg);
}
void ServerEvents::RegistrationAccepted(const std::string& user, const std::string& pass)
{
	ui().OnRegistrationAccepted(TowxString(user), TowxString(pass));
}
void MainJoinBattleTab::PreSwitchBattlePerspective( )
{
    ui().mw().SavePerspectives(  );
}
Beispiel #9
0
void menu_software_list::handle()
{
	const entry_info *selected_entry = nullptr;
	int bestmatch = 0;

	// process the menu
	const event *event = process(0);

	if (event && event->itemref)
	{
		if ((uintptr_t)event->itemref == 1 && event->iptkey == IPT_UI_SELECT)
		{
			m_ordered_by_shortname = !m_ordered_by_shortname;

			// reset the char buffer if we change ordering criterion
			m_filename_buffer.clear();

			// reload the menu with the new order
			reset(reset_options::REMEMBER_REF);
			machine().popmessage(_("Switched Order: entries now ordered by %s"), m_ordered_by_shortname ? _("shortname") : _("description"));
		}
		// handle selections
		else if (event->iptkey == IPT_UI_SELECT)
		{
			entry_info *info = (entry_info *) event->itemref;
			m_result = info->short_name;
			stack_pop();
		}
		else if (event->iptkey == IPT_SPECIAL)
		{
			if (input_character(m_filename_buffer, event->unichar, &is_valid_softlist_part_char))
			{
				// display the popup
				ui().popup_time(ERROR_MESSAGE_TIME, "%s", m_filename_buffer);

				// identify the selected entry
				entry_info const *const cur_selected = (uintptr_t(event->itemref) != 1)
						? reinterpret_cast<entry_info const *>(get_selection_ref())
						: nullptr;

				// loop through all entries
				for (auto &entry : m_entrylist)
				{
					// is this entry the selected entry?
					if (cur_selected != &entry)
					{
						auto &compare_name = m_ordered_by_shortname ? entry.short_name : entry.long_name;

						int match = 0;
						for (int i = 0; i < m_filename_buffer.size() + 1; i++)
						{
							if (core_strnicmp(compare_name.c_str(), m_filename_buffer.c_str(), i) == 0)
								match = i;
						}

						if (match > bestmatch)
						{
							bestmatch = match;
							selected_entry = &entry;
						}
					}
				}

				if (selected_entry != nullptr && selected_entry != cur_selected)
				{
					set_selection((void *)selected_entry);
					centre_selection();
				}
			}
		}
		else if (event->iptkey == IPT_UI_CANCEL)
		{
			// reset the char buffer also in this case
			m_filename_buffer.clear();
			m_result = m_filename_buffer;
			stack_pop();
		}
	}
}
Beispiel #10
0
void BattleRoomTab::OnAutoSpec( wxCommandEvent& /*unused*/ )
{
	if ( !m_battle ) return;
	int trigger = wxGetNumberFromUser( _( "Enter timeout before autospeccing a player in minutes" ), _( "Set Timeout" ), _T( "" ), sett().GetBattleLastAutoSpectTime() / 60, 1, 60, ( wxWindow* ) & ui().mw(), wxDefaultPosition );
	if ( trigger < 0 ) trigger = 0;
	trigger = trigger * 60;
	m_autospec_mnu->Check( trigger > 0 );
	sett().SetBattleLastAutoSpectTime( trigger );
}
void MainJoinBattleTab::PostSwitchBattlePerspective( )
{
    ui().mw().LoadPerspectives( );
}
Beispiel #12
0
void BattleRoomTab::OnAutoPaste( wxCommandEvent& /*unused*/ )
{
	if ( !m_battle ) return;
	wxString description = wxGetTextFromUser( _( "Enter a battle description" ), _( "Set description" ), m_battle->GetDescription(), ( wxWindow* ) & ui().mw() );
	m_autopaste_mnu->Check( !description.IsEmpty() );
	if ( !description.IsEmpty() ) m_battle->SetDescription( description );
	sett().SetBattleLastAutoAnnounceDescription( m_autopaste_mnu->IsChecked() );
}
Beispiel #13
0
void menu_file_selector::handle()
{
	osd_file::error err;
	const file_selector_entry *selected_entry = nullptr;
	int bestmatch = 0;

	// process the menu
	const event *event = process(0);
	if (event != nullptr && event->itemref != nullptr)
	{
		// handle selections
		if (event->iptkey == IPT_UI_SELECT)
		{
			auto entry = (const file_selector_entry *) event->itemref;
			switch (entry->type)
			{
			case SELECTOR_ENTRY_TYPE_EMPTY:
				// empty slot - unload
				m_result = result::EMPTY;
				stack_pop();
				break;

			case SELECTOR_ENTRY_TYPE_CREATE:
				// create
				m_result = result::CREATE;
				stack_pop();
				break;

			case SELECTOR_ENTRY_TYPE_SOFTWARE_LIST:
				m_result = result::SOFTLIST;
				stack_pop();
				break;

			case SELECTOR_ENTRY_TYPE_DRIVE:
			case SELECTOR_ENTRY_TYPE_DIRECTORY:
				// drive/directory - first check the path
				err = util::zippath_opendir(entry->fullpath, nullptr);
				if (err != osd_file::error::NONE)
				{
					// this path is problematic; present the user with an error and bail
					ui().popup_time(1, "Error accessing %s", entry->fullpath);
					break;
				}
				m_current_directory.assign(entry->fullpath);
				reset(reset_options::SELECT_FIRST);
				break;

			case SELECTOR_ENTRY_TYPE_FILE:
				// file
				m_current_file.assign(entry->fullpath);
				m_result = result::FILE;
				stack_pop();
				break;
			}

			// reset the char buffer when pressing IPT_UI_SELECT
			m_filename.clear();
		}
		else if (event->iptkey == IPT_SPECIAL)
		{
			// if it's any other key and we're not maxed out, update
			if (input_character(m_filename, event->unichar, uchar_is_printable))
			{
				ui().popup_time(ERROR_MESSAGE_TIME, "%s", m_filename.c_str());

				file_selector_entry const *const cur_selected(reinterpret_cast<file_selector_entry const *>(get_selection_ref()));

				// check for entries which matches our m_filename_buffer:
				for (auto &entry : m_entrylist)
				{
					if (cur_selected != &entry)
					{
						int match = 0;
						for (int i = 0; i < m_filename.size() + 1; i++)
						{
							if (core_strnicmp(entry.basename.c_str(), m_filename.c_str(), i) == 0)
								match = i;
						}

						if (match > bestmatch)
						{
							bestmatch = match;
							selected_entry = &entry;
						}
					}
				}

				if (selected_entry != nullptr && selected_entry != cur_selected)
				{
					set_selection((void *)selected_entry);
					centre_selection();
				}
			}
		}
		else if (event->iptkey == IPT_UI_CANCEL)
		{
			// reset the char buffer also in this case
			m_filename.clear();
		}
	}
}
Beispiel #14
0
void menu_file_selector::populate()
{
	util::zippath_directory *directory = nullptr;
	osd_file::error err;
	const osd::directory::entry *dirent;
	const file_selector_entry *entry;
	const file_selector_entry *selected_entry = nullptr;
	int i;
	const char *volume_name;

	// open the directory
	err = util::zippath_opendir(m_current_directory, &directory);

	// clear out the menu entries
	m_entrylist.clear();

	if (m_has_empty)
	{
		// add the "[empty slot]" entry
		append_entry(SELECTOR_ENTRY_TYPE_EMPTY, "", "");
	}

	if (m_has_create && !util::zippath_is_zip(directory))
	{
		// add the "[create]" entry
		append_entry(SELECTOR_ENTRY_TYPE_CREATE, "", "");
	}

	if (m_has_softlist)
	{
		// add the "[software list]" entry
		entry = &append_entry(SELECTOR_ENTRY_TYPE_SOFTWARE_LIST, "", "");
		selected_entry = entry;
	}

	// add the drives
	i = 0;
	while((volume_name = osd_get_volume_name(i))!=nullptr)
	{
		append_entry(SELECTOR_ENTRY_TYPE_DRIVE,
			volume_name, volume_name);
		i++;
	}

	// build the menu for each item
	if (err == osd_file::error::NONE)
	{
		while((dirent = util::zippath_readdir(directory)) != nullptr)
		{
			// append a dirent entry
			entry = append_dirent_entry(dirent);

			if (entry != nullptr)
			{
				// set the selected item to be the first non-parent directory or file
				if ((selected_entry == nullptr) && strcmp(dirent->name, ".."))
					selected_entry = entry;

				// do we have to select this file?
				if (!core_stricmp(m_current_file.c_str(), dirent->name))
					selected_entry = entry;
			}
		}
	}

	// append all of the menu entries
	for (auto &entry : m_entrylist)
		append_entry_menu_item(&entry);

	// set the selection (if we have one)
	if (selected_entry != nullptr)
		set_selection((void *) selected_entry);

	// set up custom render proc
	customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;

	if (directory != nullptr)
		util::zippath_closedir(directory);
}
void ServerEvents::OnServerMessage(const std::string& message)
{
	wxLogWarning("%s", message);
	ui().OnServerMessage(m_serv, TowxString(message));
}
void ServerEvents::OnLoginDenied(const std::string& reason)
{
	ui().OnLoginDenied(reason);
}
void ServerEvents::OnServerMessageBox(const std::string& message)
{
	wxLogWarning("%s", message);
	ui().ShowMessage(_("Server Message"), TowxString(message));
}
void ServerEvents::OnInvalidFingerprintReceived(const std::string& fingerprint, const std::string& expected_fingerprint)
{
	ui().OnInvalidFingerprintReceived(fingerprint, expected_fingerprint);
}
void ServerEvents::OnUnknownCommand(const std::string& command, const std::string& params)
{
	slLogDebugFunc("");
	ui().OnUnknownCommand(m_serv, TowxString(command), TowxString(params));
}
void ServerEvents::OnMotd(const std::string& msg)
{
	slLogDebugFunc("");
	ui().OnMotd(m_serv, TowxString(msg));
}
void ServerEvents::RegistrationDenied(const std::string& reason)
{
	ui().OnRegistrationDenied(TowxString(reason));
}
void ServerEvents::OnSetBattleInfo(int battleid, const std::string& param, const std::string& value)
{
	slLogDebugFunc("%s, %s", param.c_str(), value.c_str());
	IBattle& battle = m_serv.GetBattle(battleid);
	battle.m_script_tags[param] = value;
	const LSL::StringVector vec = LSL::Util::StringTokenize(param, "/"); //split string by slash

	switch (vec.size()) {
		case 3: { // depth 3
			if (param.find("game/mapoptions") == 0) {
				if (!battle.CustomBattleOptions().setSingleOption(vec[2], value, LSL::Enum::MapOption)) {
					wxLogWarning("OnSetBattleInfo: Couldn't set map option %s", vec[2].c_str());
				}
				return;
			}
			if (param.find("game/modoptions/") == 0) {
				if (!battle.CustomBattleOptions().setSingleOption(vec[2], value, LSL::Enum::ModOption)) {
					wxLogWarning("OnSetBattleInfo: Couldn't set game option %s", vec[2].c_str());
				}
				return;
			}
			if (param.find("game/restrict") == 0) {
				OnBattleDisableUnit(battleid, vec[2], LSL::Util::FromIntString(value));
				return;
			}
			if (param.find("game/") == 0) { //game/team0/startposx=1692.
				int team = -1;
				if (parseTeam(vec[1], team)) {
					const bool xpos = vec[2] == "startposx";
					const bool ypos = vec[2] == "startposy";
					if (xpos || ypos) {
						int numusers = battle.GetNumUsers();
						for (int i = 0; i < numusers; i++) {
							User& usr = battle.GetUser(i);
							UserBattleStatus& status = usr.BattleStatus();
							if (status.team == team) {
								if (xpos) {
									status.pos.x = LSL::Util::FromIntString(value);
								}
								if (ypos) {
									status.pos.y = LSL::Util::FromIntString(value);
								}
								battle.OnUserBattleStatusUpdated(usr, status);
								ui().OnUserBattleStatus(usr);
							}
						}
						return;
					}
				}
			}
			break;
		}
		case 4: { //depth 4
			if (param.find("game/players/") == 0) {
				if (vec[3] == "skill") {
					const std::string nick = vec[2];
					double skill;
					if (parseSkill(value, skill)) {
						battle.OnPlayerTrueskillChanged(nick, skill); //(std::string& nickname, double trueskill_value)
					}
					return;
				}
				if (vec[3] == "skilluncertainty") { //this is ignored
					return;
				}
			}
			break;
		}
		case 2: { //depth 2
			if (param == "game/hosttype") {
				if (battle.m_autohost_manager == nullptr) {
					wxLogWarning("FIXME: battle.m_autohost_manager == nullptr");
					return;
				}
				if (battle.m_autohost_manager->RecognizeAutohost(value)) {
					wxLogInfo("detected %s autohost", value.c_str()); //FIXME: add event for that + add a label?!
				}
				return;
			}
			// i.e. game/startpostype
			battle.CustomBattleOptions().setSingleOption(vec[1], value, LSL::Enum::EngineOption);
			return;
		}
			/*
		//seems unused
		case 1: { //depth 1
			battle.CustomBattleOptions().setSingleOption(vec[0], value, LSL::Enum::EngineOption);
			battle.Update(stdprintf("%d_%s", LSL::Enum::EngineOption, vec[0].c_str()));
			return;
		}
*/
	}
	wxLogWarning("Unhandled SETSCRIPTTAGS: %s=%s", param.c_str(), value.c_str());
}
SingleOptionDialog::SingleOptionDialog(IBattle& battle, const wxString& optiontag)
    : m_battle(battle)
    , m_tag(optiontag)
    , m_checkbox(NULL)
    , m_combobox(NULL)
    , m_spinctrl(NULL)
    , m_textctrl(NULL)
    , m_cancel_button(NULL)
    , m_ok_button(NULL)
{
	LSL::OptionsWrapper& optWrap = m_battle.CustomBattleOptions();
	LSL::Enum::GameOption optFlag = (LSL::Enum::GameOption)FromwxString(optiontag.BeforeFirst('_'));
	const auto key = STD_STRING(optiontag.AfterFirst('_'));
	LSL::Enum::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 LSL::Enum::opt_bool: {
			const auto opt = optWrap.m_opts[optFlag].bool_map[key];
			m_checkbox = new wxCheckBox(this, wxID_ANY, TowxString(opt.name));
			m_checkbox->SetToolTip(opt.description);
			m_checkbox->SetValue(opt.value);
			m_main_sizer->Add(m_checkbox, 0, wxEXPAND);
			break;
		}
		case LSL::Enum::opt_float: {
			const auto opt = optWrap.m_opts[optFlag].float_map[key];
			m_spinctrl = new wxSpinCtrlDouble(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
							  wxSP_ARROW_KEYS, double(opt.min), double(opt.max),
							  double(opt.value), double(opt.stepping), TowxString(opt.key));
			m_spinctrl->SetToolTip(opt.description);
			m_main_sizer->Add(m_spinctrl, 0, wxEXPAND);
			break;
		}
		case LSL::Enum::opt_string: {
			const auto opt = optWrap.m_opts[optFlag].string_map[key];
			m_textctrl = new wxTextCtrl(this, wxID_ANY, TowxString(opt.value), wxDefaultPosition,
						    wxDefaultSize, 0, wxDefaultValidator, TowxString(opt.key));
			m_textctrl->SetToolTip(opt.description);
			m_main_sizer->Add(m_textctrl, 0, wxEXPAND);
			break;
		}
		case LSL::Enum::opt_list: {
			const auto opt = optWrap.m_opts[optFlag].list_map[key];
			const int temp = int(opt.cbx_choices.size() - 1);
			const int index = LSL::Util::Clamp(opt.cur_choice_index, 0, temp);
			m_combobox = new wxComboBox(this, wxID_ANY, TowxString(opt.cbx_choices[index]), wxDefaultPosition, wxDefaultSize,
						    lslTowxArrayString(opt.cbx_choices), wxCB_READONLY, wxDefaultValidator);
			std::string tooltip = opt.description + "\n";
			for (const auto itor : opt.listitems) {
				tooltip += "\n" + itor.name + ": " + itor.desc;
			}
			m_combobox->SetToolTip(tooltip);
			m_main_sizer->Add(m_combobox, 0, wxEXPAND);
			break;
		}
		default: {
			EndModal(wxID_CANCEL);
			return;
		}
	}

	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);
}
void ServerEvents::OnChannelList(const std::string& channel, const int& numusers, const std::string& topic)
{
	ui().mw().OnChannelList(TowxString(channel), numusers, TowxString(topic));
}
static int FUNC(picture_coding_extension)(CodedBitstreamContext *ctx, RWContext *rw,
                                          MPEG2RawPictureCodingExtension *current)
{
    CodedBitstreamMPEG2Context *mpeg2 = ctx->priv_data;
    int err;

    HEADER("Picture Coding Extension");

    ui(4, f_code[0][0]);
    ui(4, f_code[0][1]);
    ui(4, f_code[1][0]);
    ui(4, f_code[1][1]);

    ui(2, intra_dc_precision);
    ui(2, picture_structure);
    ui(1, top_field_first);
    ui(1, frame_pred_frame_dct);
    ui(1, concealment_motion_vectors);
    ui(1, q_scale_type);
    ui(1, intra_vlc_format);
    ui(1, alternate_scan);
    ui(1, repeat_first_field);
    ui(1, chroma_420_type);
    ui(1, progressive_frame);

    if (mpeg2->progressive_sequence) {
        if (current->repeat_first_field) {
            if (current->top_field_first)
                mpeg2->number_of_frame_centre_offsets = 3;
            else
                mpeg2->number_of_frame_centre_offsets = 2;
        } else {
            mpeg2->number_of_frame_centre_offsets = 1;
        }
    } else {
        if (current->picture_structure == 1 || // Top field.
            current->picture_structure == 2) { // Bottom field.
            mpeg2->number_of_frame_centre_offsets = 1;
        } else {
            if (current->repeat_first_field)
                mpeg2->number_of_frame_centre_offsets = 3;
            else
                mpeg2->number_of_frame_centre_offsets = 2;
        }
    }

    ui(1, composite_display_flag);
    if (current->composite_display_flag) {
        ui(1, v_axis);
        ui(3, field_sequence);
        ui(1, sub_carrier);
        ui(7, burst_amplitude);
        ui(8, sub_carrier_phase);
    }

    return 0;
}
void ServerEvents::OnAcceptAgreement(const std::string& agreement)
{
	ui().OnAcceptAgreement(TowxString(agreement));
}
Beispiel #27
0
void menu_control_device_image::handle()
{
	switch(m_state)
	{
	case START_FILE:
		m_submenu_result.filesel = menu_file_selector::result::INVALID;
		menu::stack_push<menu_file_selector>(ui(), container(), &m_image, m_current_directory, m_current_file, true, m_image.image_interface()!=nullptr, m_image.is_creatable(), m_submenu_result.filesel);
		m_state = SELECT_FILE;
		break;

	case START_SOFTLIST:
		m_sld = nullptr;
		menu::stack_push<menu_software>(ui(), container(), m_image.image_interface(), &m_sld);
		m_state = SELECT_SOFTLIST;
		break;

	case START_OTHER_PART:
		m_submenu_result.swparts = menu_software_parts::result::INVALID;
		menu::stack_push<menu_software_parts>(ui(), container(), m_swi, m_swp->interface().c_str(), &m_swp, true, m_submenu_result.swparts);
		m_state = SELECT_OTHER_PART;
		break;

	case SELECT_SOFTLIST:
		if (!m_sld)
		{
			stack_pop();
			break;
		}
		m_software_info_name.clear();
		menu::stack_push<menu_software_list>(ui(), container(), m_sld, m_image.image_interface(), m_software_info_name);
		m_state = SELECT_PARTLIST;
		break;

	case SELECT_PARTLIST:
		m_swi = m_sld->find(m_software_info_name.c_str());
		if (!m_swi)
			m_state = START_SOFTLIST;
		else if (m_swi->has_multiple_parts(m_image.image_interface()))
		{
			m_submenu_result.swparts = menu_software_parts::result::INVALID;
			m_swp = nullptr;
			menu::stack_push<menu_software_parts>(ui(), container(), m_swi, m_image.image_interface(), &m_swp, false, m_submenu_result.swparts);
			m_state = SELECT_ONE_PART;
		}
		else
		{
			m_swp = m_swi->find_part("", m_image.image_interface());
			load_software_part();
		}
		break;

	case SELECT_ONE_PART:
		switch(m_submenu_result.swparts) {
		case menu_software_parts::result::ENTRY: {
			load_software_part();
			break;
		}

		default: // return to list
			m_state = SELECT_SOFTLIST;
			break;

		}
		break;

	case SELECT_OTHER_PART:
		switch(m_submenu_result.swparts) {
		case menu_software_parts::result::ENTRY:
			load_software_part();
			break;

		case menu_software_parts::result::FMGR:
			m_state = START_FILE;
			handle();
			break;

		case menu_software_parts::result::EMPTY:
			m_image.unload();
			stack_pop();
			break;

		case menu_software_parts::result::SWLIST:
			m_state = START_SOFTLIST;
			handle();
			break;

		case menu_software_parts::result::INVALID: // return to system
			stack_pop();
			break;

		}
		break;

	case SELECT_FILE:
		switch(m_submenu_result.filesel)
		{
		case menu_file_selector::result::EMPTY:
			m_image.unload();
			stack_pop();
			break;

		case menu_file_selector::result::FILE:
			hook_load(m_current_file);
			break;

		case menu_file_selector::result::CREATE:
			menu::stack_push<menu_file_create>(ui(), container(), &m_image, m_current_directory, m_current_file, m_create_ok);
			m_state = CHECK_CREATE;
			break;

		case menu_file_selector::result::SOFTLIST:
			m_state = START_SOFTLIST;
			handle();
			break;

		default: // return to system
			stack_pop();
			break;
		}
		break;

	case CREATE_FILE: {
		bool can_create, need_confirm;
		test_create(can_create, need_confirm);
		if(can_create) {
			if(need_confirm) {
				menu::stack_push<menu_confirm_save_as>(ui(), container(), &m_create_confirmed);
				m_state = CREATE_CONFIRM;
			} else {
				m_state = DO_CREATE;
				handle();
			}
		} else {
			m_state = START_FILE;
			handle();
		}
		break;
	}

	case CREATE_CONFIRM:
		m_state = m_create_confirmed ? DO_CREATE : START_FILE;
		handle();
		break;

	case CHECK_CREATE:
		m_state = m_create_ok ? CREATE_FILE : START_FILE;
		handle();
		break;

	case DO_CREATE: {
		auto path = util::zippath_combine(m_current_directory, m_current_file);
		image_init_result err = m_image.create(path, nullptr, nullptr);
		if (err != image_init_result::PASS)
			machine().popmessage("Error: %s", m_image.error());
		stack_pop();
		break;
	}
	}
}
void ServerEvents::OnRing(const std::string& from)
{
	ui().OnRing(TowxString(from));
}
Beispiel #29
0
static void enter_lobby_mode(game_display& disp, const config& game_config,
	game_state& state)
{
	DBG_MP << "entering lobby mode" << std::endl;

	mp::ui::result res;

	while (true) {
		const config &cfg = game_config.child("lobby_music");
		if (cfg) {
			BOOST_FOREACH(const config &i, cfg.child_range("music")) {
				sound::play_music_config(i);
			}
			sound::commit_music_changes();
		} else {
			sound::empty_playlist();
			sound::stop_music();
		}
		lobby_info li(game_config);

		// Force a black background
		const Uint32 color = SDL_MapRGBA(disp.video().getSurface()->format
				, 0
				, 0
				, 0
				, 255);

		sdl_fill_rect(disp.video().getSurface(), NULL, color);

		if(preferences::new_lobby()) {
			gui2::tlobby_main dlg(game_config, li, disp);
			dlg.set_preferences_callback(
				boost::bind(do_preferences_dialog,
					boost::ref(disp), boost::ref(game_config)));
			dlg.show(disp.video());
			//ugly kludge for launching other dialogs like the old lobby
			switch (dlg.get_legacy_result()) {
				case gui2::tlobby_main::CREATE:
					res = mp::ui::CREATE;
					break;
				case gui2::tlobby_main::JOIN:
					res = mp::ui::JOIN;
					break;
				case gui2::tlobby_main::OBSERVE:
					res = mp::ui::OBSERVE;
					break;
				default:
					res = mp::ui::QUIT;
			}
		} else {
			mp::lobby ui(disp, game_config, gamechat, gamelist);
			run_lobby_loop(disp, ui);
			res = ui.get_result();
		}

		switch (res) {
		case mp::ui::JOIN:
			try {
				enter_wait_mode(disp, game_config, state, false);
			} catch(config::error& error) {
				if(!error.message.empty()) {
					gui2::show_error_message(disp.video(), error.message);
				}
				//update lobby content
				network::send_data(config("refresh_lobby"), 0);
			}
			break;
		case mp::ui::OBSERVE:
			try {
				enter_wait_mode(disp, game_config, state, true);
			} catch(config::error& error) {
				if(!error.message.empty()) {
					gui2::show_error_message(disp.video(), error.message);
				}
			}
			// update lobby content unconditionally because we might have left only after the
			// game ended in which case we ignored the gamelist and need to request it again
			network::send_data(config("refresh_lobby"), 0);
			break;
		case mp::ui::CREATE:
			try {
				enter_create_mode(disp, game_config, state, false);
			} catch(config::error& error) {
				if (!error.message.empty())
					gui2::show_error_message(disp.video(), error.message);
				//update lobby content
				network::send_data(config("refresh_lobby"), 0);
			}
			break;
		case mp::ui::QUIT:
			return;
		case mp::ui::PREFERENCES:
			{
				do_preferences_dialog(disp, game_config);
				//update lobby content
				network::send_data(config("refresh_lobby"), 0);
			}
			break;
		default:
			return;
		}
	}
Beispiel #30
0
void menu_main::handle()
{
	/* process the menu */
	const event *menu_event = process(0);
	if (menu_event != nullptr && menu_event->iptkey == IPT_UI_SELECT) {
		switch((long long)(menu_event->itemref)) {
		case INPUT_GROUPS:
			menu::stack_push<menu_input_groups>(ui(), container());
			break;

		case INPUT_SPECIFIC:
			menu::stack_push<menu_input_specific>(ui(), container());
			break;

		case SETTINGS_DIP_SWITCHES:
			menu::stack_push<menu_settings_dip_switches>(ui(), container());
			break;

		case SETTINGS_DRIVER_CONFIG:
			menu::stack_push<menu_settings_driver_config>(ui(), container());
			break;

		case ANALOG:
			menu::stack_push<menu_analog>(ui(), container());
			break;

		case BOOKKEEPING:
			menu::stack_push<menu_bookkeeping>(ui(), container());
			break;

		case GAME_INFO:
			menu::stack_push<menu_game_info>(ui(), container());
			break;

		case IMAGE_MENU_IMAGE_INFO:
			menu::stack_push<menu_image_info>(ui(), container());
			break;

		case IMAGE_MENU_FILE_MANAGER:
			menu::stack_push<menu_file_manager>(ui(), container(), nullptr);
			break;

		case TAPE_CONTROL:
			menu::stack_push<menu_tape_control>(ui(), container(), nullptr);
			break;

		case PTY_INFO:
			menu::stack_push<menu_pty_info>(ui(), container());
			break;

		case SLOT_DEVICES:
			menu::stack_push<menu_slot_devices>(ui(), container());
			break;

		case NETWORK_DEVICES:
			menu::stack_push<menu_network_devices>(ui(), container());
			break;

		case KEYBOARD_MODE:
			menu::stack_push<menu_keyboard_mode>(ui(), container());
			break;

		case SLIDERS:
			menu::stack_push<menu_sliders>(ui(), container(), false);
			break;

		case VIDEO_TARGETS:
			menu::stack_push<menu_video_targets>(ui(), container());
			break;

		case VIDEO_OPTIONS:
			menu::stack_push<menu_video_options>(ui(), container(), machine().render().first_target());
			break;

		case CROSSHAIR:
			menu::stack_push<menu_crosshair>(ui(), container());
			break;

		case CHEAT:
			menu::stack_push<menu_cheat>(ui(), container());
			break;

		case PLUGINS:
			menu::stack_push<menu_plugin>(ui(), container());
			break;

		case SELECT_GAME:
			if (machine().options().ui() == emu_options::UI_SIMPLE)
				menu::stack_push<simple_menu_select_game>(ui(), container(), nullptr);
			else
				menu::stack_push<menu_select_game>(ui(), container(), nullptr);
			break;

		case BIOS_SELECTION:
			menu::stack_push<menu_bios_selection>(ui(), container());
			break;

		case BARCODE_READ:
			menu::stack_push<menu_barcode_reader>(ui(), container(), nullptr);
			break;

		case EXTERNAL_DATS:
			menu::stack_push<menu_dats_view>(ui(), container());
			break;

		case ADD_FAVORITE:
			mame_machine_manager::instance()->favorite().add_favorite_game();
			reset(reset_options::REMEMBER_POSITION);
			break;

		case REMOVE_FAVORITE:
			mame_machine_manager::instance()->favorite().remove_favorite_game();
			reset(reset_options::REMEMBER_POSITION);
			break;

		case QUIT_GAME:
			stack_pop();
			ui().request_quit();
			break;

		default:
			fatalerror("ui::menu_main::handle - unknown reference\n");
		}
	}
}