From: <geo...@us...> - 2012-12-15 20:17:02
|
Revision: 5545 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=5545&view=rev Author: geoffthemedio Date: 2012-12-15 20:16:56 +0000 (Sat, 15 Dec 2012) Log Message: ----------- Added option disabling map right-click popup menu, which I found would frequently unintentionally appear when attempting to order fleets to move. Modified Paths: -------------- trunk/FreeOrion/UI/MapWnd.cpp trunk/FreeOrion/UI/OptionsWnd.cpp Modified: trunk/FreeOrion/UI/MapWnd.cpp =================================================================== --- trunk/FreeOrion/UI/MapWnd.cpp 2012-12-15 20:15:45 UTC (rev 5544) +++ trunk/FreeOrion/UI/MapWnd.cpp 2012-12-15 20:16:56 UTC (rev 5545) @@ -128,6 +128,8 @@ db.Add("UI.tiny-fleet-button-minimum-zoom", "OPTIONS_DB_UI_TINY_FLEET_BUTTON_MIN_ZOOM", 0.75, RangedStepValidator<double>(0.125, 0.125, 4.0)); db.Add("UI.small-fleet-button-minimum-zoom","OPTIONS_DB_UI_SMALL_FLEET_BUTTON_MIN_ZOOM", 1.50, RangedStepValidator<double>(0.125, 0.125, 4.0)); db.Add("UI.medium-fleet-button-minimum-zoom","OPTIONS_DB_UI_MEDIUM_FLEET_BUTTON_MIN_ZOOM", 4.00, RangedStepValidator<double>(0.125, 0.125, 4.0)); + + db.Add("UI.map-right-click-popup-menu", "OPTIONS_DB_UI_GALAXY_MAP_POPUP", false, Validator<bool>()); } bool temp_bool = RegisterOptions(&AddOptions); @@ -1653,47 +1655,49 @@ } } - // create popup menu with map options in it. - GG::MenuItem menu_contents; - bool fps = GetOptionsDB().Get<bool>("show-fps"); - bool autoselect = GetOptionsDB().Get<bool>("UI.fleet-autoselect"); - bool showPlanets = GetOptionsDB().Get<bool>("UI.sidepanel-planet-shown"); - bool systemCircles = GetOptionsDB().Get<bool>("UI.system-circles"); - bool resourceColor = GetOptionsDB().Get<bool>("UI.resource-starlane-colouring"); - bool fleetSupply = GetOptionsDB().Get<bool>("UI.fleet-supply-lines"); - bool gas = GetOptionsDB().Get<bool>("UI.galaxy-gas-background"); - bool starfields = GetOptionsDB().Get<bool>("UI.galaxy-starfields"); - bool scale = GetOptionsDB().Get<bool>("UI.show-galaxy-map-scale"); - bool zoomSlider = GetOptionsDB().Get<bool>("UI.show-galaxy-map-zoom-slider"); - bool detectionRange = GetOptionsDB().Get<bool>("UI.show-detection-range"); - menu_contents.next_level.push_back(GG::MenuItem(UserString("OPTIONS_SHOW_FPS"), 1, false, fps)); - menu_contents.next_level.push_back(GG::MenuItem(UserString("OPTIONS_AUTOSELECT_FLEET"), 2, false, autoselect)); - menu_contents.next_level.push_back(GG::MenuItem(UserString("OPTIONS_SHOW_SIDEPANEL_PLANETS"), 3, false, showPlanets)); - menu_contents.next_level.push_back(GG::MenuItem(UserString("OPTIONS_UI_SYSTEM_CIRCLES"), 4, false, systemCircles)); - menu_contents.next_level.push_back(GG::MenuItem(UserString("OPTIONS_RESOURCE_STARLANE_COLOURING"), 5, false, resourceColor)); - menu_contents.next_level.push_back(GG::MenuItem(UserString("OPTIONS_FLEET_SUPPLY_LINES"), 6, false, fleetSupply)); - menu_contents.next_level.push_back(GG::MenuItem(UserString("OPTIONS_GALAXY_MAP_GAS"), 7, false, gas)); - menu_contents.next_level.push_back(GG::MenuItem(UserString("OPTIONS_GALAXY_MAP_STARFIELDS"), 8, false, starfields)); - menu_contents.next_level.push_back(GG::MenuItem(UserString("OPTIONS_GALAXY_MAP_SCALE_LINE"), 9, false, scale)); - menu_contents.next_level.push_back(GG::MenuItem(UserString("OPTIONS_GALAXY_MAP_ZOOM_SLIDER"), 10, false, zoomSlider)); - menu_contents.next_level.push_back(GG::MenuItem(UserString("OPTIONS_GALAXY_MAP_DETECTION_RANGE"), 11, false, detectionRange)); - // display popup menu - GG::PopupMenu popup(pt.x, pt.y, ClientUI::GetFont(), menu_contents, ClientUI::TextColor(), - ClientUI::WndOuterBorderColor(), ClientUI::WndColor()); - if (popup.Run()) { - switch (popup.MenuID()) { - case 1: { GetOptionsDB().Set<bool>("show-fps", !fps); break; } - case 2: { GetOptionsDB().Set<bool>("UI.fleet-autoselect", !autoselect); break; } - case 3: { GetOptionsDB().Set<bool>("UI.sidepanel-planet-shown", !showPlanets); break; } - case 4: { GetOptionsDB().Set<bool>("UI.system-circles", !systemCircles); break; } - case 5: { GetOptionsDB().Set<bool>("UI.resource-starlane-colouring", !resourceColor); break; } - case 6: { GetOptionsDB().Set<bool>("UI.fleet-supply-lines", !fleetSupply); break; } - case 7: { GetOptionsDB().Set<bool>("UI.galaxy-gas-background", !gas); break; } - case 8: { GetOptionsDB().Set<bool>("UI.galaxy-starfields", !starfields); break; } - case 9: { GetOptionsDB().Set<bool>("UI.show-galaxy-map-scale", !scale); break; } - case 10: { GetOptionsDB().Set<bool>("UI.show-galaxy-map-zoom-slider",!zoomSlider); break; } - case 11: { GetOptionsDB().Set<bool>("UI.show-detection-range", !detectionRange); break; } - default: break; + if (GetOptionsDB().Get<bool>("UI.map-right-click-popup-menu")) { + // create popup menu with map options in it. + GG::MenuItem menu_contents; + bool fps = GetOptionsDB().Get<bool>("show-fps"); + bool autoselect = GetOptionsDB().Get<bool>("UI.fleet-autoselect"); + bool showPlanets = GetOptionsDB().Get<bool>("UI.sidepanel-planet-shown"); + bool systemCircles = GetOptionsDB().Get<bool>("UI.system-circles"); + bool resourceColor = GetOptionsDB().Get<bool>("UI.resource-starlane-colouring"); + bool fleetSupply = GetOptionsDB().Get<bool>("UI.fleet-supply-lines"); + bool gas = GetOptionsDB().Get<bool>("UI.galaxy-gas-background"); + bool starfields = GetOptionsDB().Get<bool>("UI.galaxy-starfields"); + bool scale = GetOptionsDB().Get<bool>("UI.show-galaxy-map-scale"); + bool zoomSlider = GetOptionsDB().Get<bool>("UI.show-galaxy-map-zoom-slider"); + bool detectionRange = GetOptionsDB().Get<bool>("UI.show-detection-range"); + menu_contents.next_level.push_back(GG::MenuItem(UserString("OPTIONS_SHOW_FPS"), 1, false, fps)); + menu_contents.next_level.push_back(GG::MenuItem(UserString("OPTIONS_AUTOSELECT_FLEET"), 2, false, autoselect)); + menu_contents.next_level.push_back(GG::MenuItem(UserString("OPTIONS_SHOW_SIDEPANEL_PLANETS"), 3, false, showPlanets)); + menu_contents.next_level.push_back(GG::MenuItem(UserString("OPTIONS_UI_SYSTEM_CIRCLES"), 4, false, systemCircles)); + menu_contents.next_level.push_back(GG::MenuItem(UserString("OPTIONS_RESOURCE_STARLANE_COLOURING"), 5, false, resourceColor)); + menu_contents.next_level.push_back(GG::MenuItem(UserString("OPTIONS_FLEET_SUPPLY_LINES"), 6, false, fleetSupply)); + menu_contents.next_level.push_back(GG::MenuItem(UserString("OPTIONS_GALAXY_MAP_GAS"), 7, false, gas)); + menu_contents.next_level.push_back(GG::MenuItem(UserString("OPTIONS_GALAXY_MAP_STARFIELDS"), 8, false, starfields)); + menu_contents.next_level.push_back(GG::MenuItem(UserString("OPTIONS_GALAXY_MAP_SCALE_LINE"), 9, false, scale)); + menu_contents.next_level.push_back(GG::MenuItem(UserString("OPTIONS_GALAXY_MAP_ZOOM_SLIDER"), 10, false, zoomSlider)); + menu_contents.next_level.push_back(GG::MenuItem(UserString("OPTIONS_GALAXY_MAP_DETECTION_RANGE"), 11, false, detectionRange)); + // display popup menu + GG::PopupMenu popup(pt.x, pt.y, ClientUI::GetFont(), menu_contents, ClientUI::TextColor(), + ClientUI::WndOuterBorderColor(), ClientUI::WndColor()); + if (popup.Run()) { + switch (popup.MenuID()) { + case 1: { GetOptionsDB().Set<bool>("show-fps", !fps); break; } + case 2: { GetOptionsDB().Set<bool>("UI.fleet-autoselect", !autoselect); break; } + case 3: { GetOptionsDB().Set<bool>("UI.sidepanel-planet-shown", !showPlanets); break; } + case 4: { GetOptionsDB().Set<bool>("UI.system-circles", !systemCircles); break; } + case 5: { GetOptionsDB().Set<bool>("UI.resource-starlane-colouring", !resourceColor); break; } + case 6: { GetOptionsDB().Set<bool>("UI.fleet-supply-lines", !fleetSupply); break; } + case 7: { GetOptionsDB().Set<bool>("UI.galaxy-gas-background", !gas); break; } + case 8: { GetOptionsDB().Set<bool>("UI.galaxy-starfields", !starfields); break; } + case 9: { GetOptionsDB().Set<bool>("UI.show-galaxy-map-scale", !scale); break; } + case 10: { GetOptionsDB().Set<bool>("UI.show-galaxy-map-zoom-slider",!zoomSlider); break; } + case 11: { GetOptionsDB().Set<bool>("UI.show-detection-range", !detectionRange); break; } + default: break; + } } } } @@ -3073,85 +3077,114 @@ int client_empire_id = HumanClientApp::GetApp()->EmpireID(); const std::set<int>& this_client_known_destroyed_objects = GetUniverse().EmpireKnownDestroyedObjectIDs(client_empire_id); + const std::set<int>& this_client_stale_object_info = GetUniverse().EmpireStaleKnowledgeObjectIDs(client_empire_id); - // for each system, each empire's fleets that are ordered to move, but still at the system: "departing fleets" + // for each system, each empire's fleets that are ordered to move, + // but still at the system: "departing fleets" std::map<const System*, std::map<int, std::vector<const Fleet*> > > departing_fleets; std::vector<const UniverseObject*> departing_fleet_objects = objects.FindObjects(OrderedMovingFleetVisitor()); - for (std::vector<const UniverseObject*>::iterator it = departing_fleet_objects.begin(); it != departing_fleet_objects.end(); ++it) { - // skip known destroyed objects - if (this_client_known_destroyed_objects.find((*it)->ID()) != this_client_known_destroyed_objects.end()) - continue; + for (std::vector<const UniverseObject*>::iterator it = departing_fleet_objects.begin(); + it != departing_fleet_objects.end(); ++it) + { const UniverseObject* obj = *it; + int object_id = obj->ID(); + // skip known destroyed and stale info objects + if (this_client_known_destroyed_objects.find(object_id) != this_client_known_destroyed_objects.end()) + continue; + if (this_client_stale_object_info.find(object_id) != this_client_stale_object_info.end()) + continue; + // skip fleets outside systems if (obj->SystemID() == INVALID_OBJECT_ID) continue; - // TEMORARY: Skip not visible fleets - if (obj->GetVisibility(client_empire_id) < VIS_BASIC_VISIBILITY) - continue; - const System* system = GetSystem(obj->SystemID()); if (!system) { Logger().errorStream() << "couldn't get system with id " << obj->SystemID() << " of an departing fleet named " << obj->Name() << " in RefreshFleetButtons()"; continue; } + // skip empty fleets + const Fleet* fleet = universe_object_cast<const Fleet*>(obj); + if (fleet->Empty()) + continue; + // store in map for this system and the fleet's owner empire - departing_fleets[system][obj->Owner()].push_back(universe_object_cast<const Fleet*>(obj)); + departing_fleets[system][obj->Owner()].push_back(fleet); } departing_fleet_objects.clear(); - // for each system, each empire's fleets in a system, not ordered to move: "stationary fleets" + // for each system, each empire's fleets in a system, not + // ordered to move: "stationary fleets" std::map<const System*, std::map<int, std::vector<const Fleet*> > > stationary_fleets; std::vector<const UniverseObject*> stationary_fleet_objects = objects.FindObjects(StationaryFleetVisitor()); - for (std::vector<const UniverseObject*>::iterator it = stationary_fleet_objects.begin(); it != stationary_fleet_objects.end(); ++it) { - // skip known destroyed objects - if (this_client_known_destroyed_objects.find((*it)->ID()) != this_client_known_destroyed_objects.end()) - continue; + for (std::vector<const UniverseObject*>::iterator it = stationary_fleet_objects.begin(); + it != stationary_fleet_objects.end(); ++it) + { const UniverseObject* obj = *it; + int object_id = obj->ID(); + Logger().debugStream() << "stationary fleet if: " << object_id; + + // skip known destroyed and stale info objects + if (this_client_known_destroyed_objects.find(object_id) != this_client_known_destroyed_objects.end()) + continue; + if (this_client_stale_object_info.find(object_id) != this_client_stale_object_info.end()) + continue; + + Logger().debugStream() << " ... not stale, not destroyed"; + // skip fleets outside systems if (obj->SystemID() == INVALID_OBJECT_ID) continue; - // TEMORARY: Skip not visible fleets - if (obj->GetVisibility(client_empire_id) < VIS_BASIC_VISIBILITY) - continue; - const System* system = GetSystem(obj->SystemID()); if (!system) { Logger().errorStream() << "couldn't get system of a stationary fleet in RefreshFleetButtons()"; continue; } + // skip empty fleets + const Fleet* fleet = universe_object_cast<const Fleet*>(obj); + if (fleet->Empty()) + continue; + // store in map for the system and fleet's owner empire - stationary_fleets[system][obj->Owner()].push_back(universe_object_cast<const Fleet*>(obj)); + stationary_fleets[system][obj->Owner()].push_back(fleet); } stationary_fleet_objects.clear(); - // for each universe location, map from empire id to fleets moving along starlanes: "moving fleets" + // for each universe location, map from empire id to fleets + // moving along starlanes: "moving fleets" std::map<std::pair<double, double>, std::map<int, std::vector<const Fleet*> > > moving_fleets; std::vector<const UniverseObject*> moving_fleet_objects = objects.FindObjects(MovingFleetVisitor()); - for (std::vector<const UniverseObject*>::iterator it = moving_fleet_objects.begin(); it != moving_fleet_objects.end(); ++it) { - // skip known destroyed objects - if (this_client_known_destroyed_objects.find((*it)->ID()) != this_client_known_destroyed_objects.end()) - continue; + for (std::vector<const UniverseObject*>::iterator it = moving_fleet_objects.begin(); + it != moving_fleet_objects.end(); ++it) + { const UniverseObject* obj = *it; + int object_id = obj->ID(); - // TEMORARY: Skip not visible fleets - if (obj->GetVisibility(client_empire_id) < VIS_BASIC_VISIBILITY) + // skip known destroyed and stale info objects + if (this_client_known_destroyed_objects.find(object_id) != this_client_known_destroyed_objects.end()) continue; + if (this_client_stale_object_info.find(object_id) != this_client_stale_object_info.end()) + continue; if (obj->SystemID() != INVALID_OBJECT_ID) { Logger().errorStream() << "a fleet that was supposed to be moving had a valid system in RefreshFleetButtons()"; continue; } + // skip empty fleets + const Fleet* fleet = universe_object_cast<const Fleet*>(obj); + if (fleet->Empty()) + continue; + // store in map - moving_fleets[std::make_pair(obj->X(), obj->Y())][obj->Owner()].push_back(universe_object_cast<const Fleet*>(obj)); + moving_fleets[std::make_pair(obj->X(), obj->Y())][obj->Owner()].push_back(fleet); } moving_fleet_objects.clear(); @@ -3170,8 +3203,8 @@ delete *set_it; m_departing_fleet_buttons.clear(); - for (std::set<FleetButton*>::iterator it = m_moving_fleet_buttons.begin(); it != m_moving_fleet_buttons.end(); ++it) - delete *it; + for (std::set<FleetButton*>::iterator set_it = m_moving_fleet_buttons.begin(); set_it != m_moving_fleet_buttons.end(); ++set_it) + delete *set_it; m_moving_fleet_buttons.clear(); Modified: trunk/FreeOrion/UI/OptionsWnd.cpp =================================================================== --- trunk/FreeOrion/UI/OptionsWnd.cpp 2012-12-15 20:15:45 UTC (rev 5544) +++ trunk/FreeOrion/UI/OptionsWnd.cpp 2012-12-15 20:16:56 UTC (rev 5545) @@ -813,6 +813,7 @@ BoolOption("UI.show-galaxy-map-scale", UserString("OPTIONS_GALAXY_MAP_SCALE_LINE")); BoolOption("UI.show-galaxy-map-zoom-slider", UserString("OPTIONS_GALAXY_MAP_ZOOM_SLIDER")); BoolOption("UI.show-detection-range", UserString("OPTIONS_GALAXY_MAP_DETECTION_RANGE")); + BoolOption("UI.map-right-click-popup-menu", UserString("OPTIONS_GALAXY_MAP_POPUP")); EndSection(); EndPage(); |