In the instance of ship to ship comment who designated what target to engage? Was it the captain? How did that order get to the guns and how would they know which ship he was even talking about? What if they wanted to engage more than one target at the same time?
In the Royal Navy, the officer who chose which ship to engage was the captain. On the bridge, the Captain had a device called, unimaginatively, the 'Captain's Sight'. This was a rotating sight, which could be pointed at the target the captain chose. If the target had been detected by radar, but could not be seen, then the captain would select the target from the radar screen.
The bearing of the target was passed electrically to the 'Director Control Tower', or DCT. The DCT was a rotating structure containing rangefinders and other fire control equipment. The DCT was pointed at the target the captain chose, giving the bearing to the target. The range was taken by the rangefinder in the DCT, as well as by rangefinders in the turrets. These, plus other inputs like the wind speed, were passed to the 'Transmitting Station'. This was a room deep in the bowels of the ship, containing the fire control computer; for battleships and cruisers, this was the Admiralty Fire Control Table (AFCT), for destroyers the simpler Admiralty Fire Control Clock (AFCC), which was also used for secondary armament and as a fall-back instrument on the larger ships. These were electromechanical computers which could calculate the fire control solution - i.e. where the gun had to be pointed - using a complex combination of gears, cams and the like, given the range and bearing of the target as well as measurements of how they were changing. Oddly, the Transmitting Station was typically manned by members of the ship's Royal Marine band, as it was believed that the dexterity needed by musicians was similar to that demanded by the AFCT.
The fire control solution was then passed from the Transmitting Station to the turrets. British ships used 'follow the pointer' devices for this. In the turret were two dials; one for the elevation and one for the training. The solution from the Transmitting Station was displayed on these. The turret crew rotated and elevated the turret to match the pointers on these dials. American ships had 'Remote Power Control' (RPC), where the turret automatically trained and elevated to follow the fire control solution given by the control computers. Once the guns were loaded and the turret was at the correct elevation and training, a button in the turret was pressed; this passed an electrical signal back to the DCT telling the DCT that that turret was ready to fire. Once all the ship's turrets were ready to fire, the gunnery officer in the DCT fired the guns together. The fall of shot was observed from the DCT and the turrets - i.e. whether the shells fell short, long, or on the target. This was used to correct the fire control solution for the next salvo. A diagram from a contemporary manual showing this system can be seen here. Anti-aircraft fire control was similar, but used a different set of sights, director and fire control system (the High Angle Control System, or HACS). Ships typically had two DCTs, one forward and one aft. The fore DCT was the main one, the aft was a secondary one, but could also be used if the ship had to engage two targets. In this case, the AFCT in the Transmitting Station would be used for the solution from the fore tower, while the AFCC would be used for the after DCT.
This system was only fitted to larger ships, from capital ships to destroyers. Smaller ships, like frigates, corvettes and minesweepers, used a simpler system, called 'local control'. In this system, the captain passed the target to the guns vocally from the bridge, using a voicepipe. The gun crew would observe the target, and work out the elevation and training themselves. They would also fire the gun themselves, rather than using a more centralised method. Local control could also be used on the larger ships, but this was not common procedure; it was only done in the event of serious damage.